From 570063d9efd5b758079cd930f283c66c825cb236 Mon Sep 17 00:00:00 2001 From: shamilfrontend Date: Thu, 26 May 2022 16:20:45 +0300 Subject: [PATCH 1/6] feat: types --- src/qComponents/QSelect/index.ts | 24 +++- src/qComponents/QSelect/src/QSelect.vue | 145 ++++++++++++++++++++---- src/qComponents/QSelect/src/types.ts | 90 +++++++++++---- 3 files changed, 210 insertions(+), 49 deletions(-) diff --git a/src/qComponents/QSelect/index.ts b/src/qComponents/QSelect/index.ts index ede98c2c..7ba09023 100644 --- a/src/qComponents/QSelect/index.ts +++ b/src/qComponents/QSelect/index.ts @@ -5,9 +5,29 @@ import Select from './src/QSelect.vue'; export const QSelect = withInstall(Select); export type { - QSelectPropModelValue, NewOption, QSelectProvider, QSelectState, - QSelectProps + QSelectProps, + QSelectPropModelValue, + QSelectPropAutocomplete, + QSelectPropCanLoadMore, + QSelectPropDisabled, + QSelectPropClearable, + QSelectPropFilterable, + QSelectPropAllowCreate, + QSelectPropLoading, + QSelectPropRemote, + QSelectPropLoadingText, + QSelectPropLoadMoreText, + QSelectPropNoMatchText, + QSelectPropNoDataText, + QSelectPropMultiple, + QSelectPropMultipleLimit, + QSelectPropPlaceholder, + QSelectPropSelectAllShown, + QSelectPropSelectAllText, + QSelectPropValueKey, + QSelectPropCollapseTags, + QSelectPropTeleportTo } from './src/types'; diff --git a/src/qComponents/QSelect/src/QSelect.vue b/src/qComponents/QSelect/src/QSelect.vue index d19b755d..a6c8c6c3 100644 --- a/src/qComponents/QSelect/src/QSelect.vue +++ b/src/qComponents/QSelect/src/QSelect.vue @@ -128,17 +128,38 @@ import QSelectDropdown from './QSelectDropdown.vue'; import QSelectTags from './QSelectTags.vue'; import type { QSelectPropModelValue, - NewOption, + QSelectPropAutocomplete, + QSelectPropCanLoadMore, + QSelectPropDisabled, + QSelectPropClearable, + QSelectPropFilterable, + QSelectPropAllowCreate, + QSelectPropLoading, + QSelectPropRemote, + QSelectPropLoadingText, + QSelectPropLoadMoreText, + QSelectPropNoMatchText, + QSelectPropNoDataText, + QSelectPropMultiple, + QSelectPropMultipleLimit, + QSelectPropPlaceholder, + QSelectPropSelectAllShown, + QSelectPropSelectAllText, + QSelectPropValueKey, + QSelectPropCollapseTags, + QSelectPropTeleportTo, + QSelectProps, QSelectInstance, + NewOption, QSelectProvider, QSelectState, - QSelectProps, QSelectTagsInstance, QSelectDropdownInstance } from './types'; export default defineComponent({ name: 'QSelect', + componentName: 'QSelect', components: { @@ -154,88 +175,168 @@ export default defineComponent({ type: [String, Number, Object, Array] as PropType, default: null }, + /** * the autocomplete attribute of select input */ - autocomplete: { type: String as PropType<'on' | 'off'>, default: 'off' }, + autocomplete: { + type: String as PropType, + default: 'off' + }, + /** * whether loadMoreText is shown */ - canLoadMore: { type: Boolean, default: false }, + canLoadMore: { + type: Boolean as PropType, + default: false + }, + /** * whether Select is disabled */ - disabled: { type: Boolean, default: false }, + disabled: { + type: Boolean as PropType, + default: false + }, + /** * whether select can be cleared */ - clearable: { type: Boolean, default: false }, + clearable: { + type: Boolean as PropType, + default: false + }, + /** * whether Select is filterable */ - filterable: { type: Boolean, default: false }, + filterable: { + type: Boolean as PropType, + default: false + }, + /** * whether creating new items is allowed. To use this, `filterable` must be true */ - allowCreate: { type: Boolean, default: false }, + allowCreate: { + type: Boolean as PropType, + default: false + }, + /** * whether Select is loading data from server */ - loading: { type: Boolean, default: false }, + loading: { + type: Boolean as PropType, + default: false + }, + /** * whether options are loaded from server */ - remote: { type: Boolean, default: false }, + remote: { + type: Boolean as PropType, + default: false + }, + /** * text that is shown when `loading` is true */ - loadingText: { type: String, default: null }, + loadingText: { + type: String as PropType, + default: null + }, + /** * text that is shown when `canLoadMore` is true */ - loadMoreText: { type: String, default: null }, + loadMoreText: { + type: String as PropType, + default: null + }, + /** * text of no match state */ - noMatchText: { type: String, default: null }, + noMatchText: { + type: String as PropType, + default: null + }, + /** * text of no data state */ - noDataText: { type: String, default: null }, + noDataText: { + type: String as PropType, + default: null + }, + /** * whether multiple-select is activated */ - multiple: { type: Boolean, default: false }, + multiple: { + type: Boolean as PropType, + default: false + }, + /** * maximum number of options user can select when `multiple` is true. No `limit` when set to 0 */ - multipleLimit: { type: Number, default: 0 }, + multipleLimit: { + type: Number as PropType, + default: 0 + }, + /** * placeholder */ - placeholder: { type: String, default: '' }, + placeholder: { + type: String as PropType, + default: '' + }, + /** * whether select all button is shown */ - selectAllShown: { type: Boolean, default: false }, + selectAllShown: { + type: Boolean as PropType, + default: false + }, + /** * text of select all button */ - selectAllText: { type: String, default: null }, + selectAllText: { + type: String as PropType, + default: null + }, + /** * unique identity key name for value, required when option's value is an object */ - valueKey: { type: String, default: 'value' }, + valueKey: { + type: String as PropType, + default: 'value' + }, + /** * whether to collapse tags to a text when multiple selecting */ - collapseTags: { type: Boolean, default: false }, + collapseTags: { + type: Boolean as PropType, + default: false + }, + /** * Specifies a target element where QSelect will be moved. * (has to be a valid query selector, or an HTMLElement) */ teleportTo: { - type: [String, isServer ? Object : HTMLElement], + type: [ + String, + isServer ? Object : HTMLElement + ] as PropType, default: null } }, diff --git a/src/qComponents/QSelect/src/types.ts b/src/qComponents/QSelect/src/types.ts index c3db8ad0..01af5871 100644 --- a/src/qComponents/QSelect/src/types.ts +++ b/src/qComponents/QSelect/src/types.ts @@ -7,10 +7,74 @@ import type { QScrollbarInstance } from '@/qComponents/QScrollbar'; import type { Nullable, Optional, UnwrappedInstance } from '#/helpers'; -type QSelectPropModelValue = Nullable< +export type QSelectPropModelValue = Nullable< string | number | QOptionPropValue | (string | number | QOptionPropValue)[] >; +export type QSelectPropAutocomplete = Nullable<'on' | 'off'>; + +export type QSelectPropCanLoadMore = Nullable; + +export type QSelectPropDisabled = Nullable; + +export type QSelectPropClearable = Nullable; + +export type QSelectPropFilterable = Nullable; + +export type QSelectPropAllowCreate = Nullable; + +export type QSelectPropLoading = Nullable; + +export type QSelectPropRemote = Nullable; + +export type QSelectPropLoadingText = Nullable; + +export type QSelectPropLoadMoreText = Nullable; + +export type QSelectPropNoMatchText = Nullable; + +export type QSelectPropNoDataText = Nullable; + +export type QSelectPropMultiple = Nullable; + +export type QSelectPropMultipleLimit = Nullable; + +export type QSelectPropPlaceholder = Nullable; + +export type QSelectPropSelectAllShown = Nullable; + +export type QSelectPropSelectAllText = Nullable; + +export type QSelectPropValueKey = Nullable; + +export type QSelectPropCollapseTags = Nullable; + +export type QSelectPropTeleportTo = Nullable; + +interface QSelectProps { + modelValue: QSelectPropModelValue; + autocomplete: QSelectPropAutocomplete; + canLoadMore: QSelectPropCanLoadMore; + disabled: QSelectPropDisabled; + clearable: QSelectPropClearable; + filterable: QSelectPropFilterable; + allowCreate: QSelectPropAllowCreate; + loading: QSelectPropLoading; + remote: QSelectPropRemote; + loadingText: QSelectPropLoadingText; + loadMoreText: QSelectPropLoadMoreText; + noMatchText: QSelectPropNoMatchText; + noDataText: QSelectPropNoDataText; + multiple: QSelectPropMultiple; + multipleLimit: QSelectPropMultipleLimit; + placeholder: QSelectPropPlaceholder; + selectAllShown: QSelectPropSelectAllShown; + selectAllText: QSelectPropSelectAllText; + valueKey: QSelectPropValueKey; + collapseTags: QSelectPropCollapseTags; + teleportTo: QSelectPropTeleportTo; +} + type NewOption = { value: QSelectPropModelValue; key: QSelectPropModelValue; @@ -72,29 +136,6 @@ interface QSelectProvider { modelValue: Ref; } -interface QSelectProps { - selectAllShown: Nullable; - selectAllText: Nullable; - loadMoreText: Nullable; - filterable: Nullable; - collapseTags: Nullable; - autocomplete: Nullable<'on' | 'off'>; - multiple: Nullable; - modelValue: Nullable; - placeholder: Nullable; - disabled: Nullable; - canLoadMore: Nullable; - loading: Nullable; - loadingText: Nullable; - noMatchText: Nullable; - noDataText: Nullable; - allowCreate: Nullable; - clearable: Nullable; - remote: Nullable; - valueKey: Nullable; - multipleLimit: Nullable; -} - interface QSelectState { options: QOptionModel[]; selected: Nullable; @@ -149,7 +190,6 @@ interface QSelectTagsInstance { export { QOptionPropValue, - QSelectPropModelValue, NewOption, QSelectInstance, QSelectProps, From f993569191add5fc738d3440c787462f5ecf6a77 Mon Sep 17 00:00:00 2001 From: shamilfrontend Date: Thu, 26 May 2022 16:51:39 +0300 Subject: [PATCH 2/6] feat: components --- .../QSelect/src/components/QSelectDropdown/index.ts | 3 +++ .../QSelectDropdown/index.vue} | 5 ++++- .../{ => components/QSelectDropdown}/q-select-dropdown.scss | 0 .../QSelect/src/components/QSelectDropdown/types.ts | 0 src/qComponents/QSelect/src/components/QSelectTags/index.ts | 3 +++ .../{QSelectTags.vue => components/QSelectTags/index.vue} | 3 ++- .../src/{ => components/QSelectTags}/q-select-tags.scss | 0 src/qComponents/QSelect/src/components/QSelectTags/types.ts | 0 src/qComponents/QSelect/src/q-select.scss | 4 ++-- 9 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/qComponents/QSelect/src/components/QSelectDropdown/index.ts rename src/qComponents/QSelect/src/{QSelectDropdown.vue => components/QSelectDropdown/index.vue} (98%) rename src/qComponents/QSelect/src/{ => components/QSelectDropdown}/q-select-dropdown.scss (100%) create mode 100644 src/qComponents/QSelect/src/components/QSelectDropdown/types.ts create mode 100644 src/qComponents/QSelect/src/components/QSelectTags/index.ts rename src/qComponents/QSelect/src/{QSelectTags.vue => components/QSelectTags/index.vue} (97%) rename src/qComponents/QSelect/src/{ => components/QSelectTags}/q-select-tags.scss (100%) create mode 100644 src/qComponents/QSelect/src/components/QSelectTags/types.ts diff --git a/src/qComponents/QSelect/src/components/QSelectDropdown/index.ts b/src/qComponents/QSelect/src/components/QSelectDropdown/index.ts new file mode 100644 index 00000000..a56fddaf --- /dev/null +++ b/src/qComponents/QSelect/src/components/QSelectDropdown/index.ts @@ -0,0 +1,3 @@ +import QSelectDropdown from './index.vue'; + +export default QSelectDropdown; diff --git a/src/qComponents/QSelect/src/QSelectDropdown.vue b/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue similarity index 98% rename from src/qComponents/QSelect/src/QSelectDropdown.vue rename to src/qComponents/QSelect/src/components/QSelectDropdown/index.vue index 4cda69b6..5fdb31b8 100644 --- a/src/qComponents/QSelect/src/QSelectDropdown.vue +++ b/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue @@ -76,7 +76,10 @@ import type { QSelectProvider } from '@/qComponents/QSelect'; import type { Nullable, UnwrappedInstance } from '#/helpers'; -import type { QSelectDropdownInstance, QSelectDropdownProps } from './types'; +import type { + QSelectDropdownInstance, + QSelectDropdownProps +} from '../../types'; const DEFAULT_Z_INDEX = 2000; diff --git a/src/qComponents/QSelect/src/q-select-dropdown.scss b/src/qComponents/QSelect/src/components/QSelectDropdown/q-select-dropdown.scss similarity index 100% rename from src/qComponents/QSelect/src/q-select-dropdown.scss rename to src/qComponents/QSelect/src/components/QSelectDropdown/q-select-dropdown.scss diff --git a/src/qComponents/QSelect/src/components/QSelectDropdown/types.ts b/src/qComponents/QSelect/src/components/QSelectDropdown/types.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/qComponents/QSelect/src/components/QSelectTags/index.ts b/src/qComponents/QSelect/src/components/QSelectTags/index.ts new file mode 100644 index 00000000..c179c43a --- /dev/null +++ b/src/qComponents/QSelect/src/components/QSelectTags/index.ts @@ -0,0 +1,3 @@ +import QSelectTags from './index.vue'; + +export default QSelectTags; diff --git a/src/qComponents/QSelect/src/QSelectTags.vue b/src/qComponents/QSelect/src/components/QSelectTags/index.vue similarity index 97% rename from src/qComponents/QSelect/src/QSelectTags.vue rename to src/qComponents/QSelect/src/components/QSelectTags/index.vue index e85996e1..1bc0c6a5 100644 --- a/src/qComponents/QSelect/src/QSelectTags.vue +++ b/src/qComponents/QSelect/src/components/QSelectTags/index.vue @@ -57,10 +57,11 @@ import type { QSelectProvider } from '@/qComponents/QSelect'; import type { Nullable } from '#/helpers'; -import type { NewOption, QSelectTagsInstance } from './types'; +import type { NewOption, QSelectTagsInstance } from '../../types'; export default defineComponent({ name: 'QSelectTags', + componentName: 'QSelectTags', emits: ['remove-tag', 'exit', 'update:query', 'focus', 'keyup-enter'], diff --git a/src/qComponents/QSelect/src/q-select-tags.scss b/src/qComponents/QSelect/src/components/QSelectTags/q-select-tags.scss similarity index 100% rename from src/qComponents/QSelect/src/q-select-tags.scss rename to src/qComponents/QSelect/src/components/QSelectTags/q-select-tags.scss diff --git a/src/qComponents/QSelect/src/components/QSelectTags/types.ts b/src/qComponents/QSelect/src/components/QSelectTags/types.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/qComponents/QSelect/src/q-select.scss b/src/qComponents/QSelect/src/q-select.scss index bef69864..c5ce3c50 100644 --- a/src/qComponents/QSelect/src/q-select.scss +++ b/src/qComponents/QSelect/src/q-select.scss @@ -1,5 +1,5 @@ -@import './q-select-tags'; -@import './q-select-dropdown'; +@import './components/QSelectTags/q-select-tags'; +@import './components/QSelectDropdown/q-select-dropdown'; .q-select { position: relative; From ba388873f95b33d26d24d446326f74f5d564c941 Mon Sep 17 00:00:00 2001 From: shamilfrontend Date: Fri, 27 May 2022 10:18:54 +0300 Subject: [PATCH 3/6] feat: types --- src/qComponents/QSelect/src/QSelect.vue | 10 +-- .../src/components/QSelectDropdown/index.ts | 2 + .../src/components/QSelectDropdown/index.vue | 59 ++++++++++++---- .../src/components/QSelectDropdown/types.ts | 32 +++++++++ .../src/components/QSelectTags/index.ts | 2 + .../src/components/QSelectTags/index.vue | 8 ++- .../src/components/QSelectTags/types.ts | 20 ++++++ src/qComponents/QSelect/src/types.ts | 67 +++---------------- 8 files changed, 121 insertions(+), 79 deletions(-) diff --git a/src/qComponents/QSelect/src/QSelect.vue b/src/qComponents/QSelect/src/QSelect.vue index a6c8c6c3..7182ae39 100644 --- a/src/qComponents/QSelect/src/QSelect.vue +++ b/src/qComponents/QSelect/src/QSelect.vue @@ -124,8 +124,10 @@ import type { QOptionModel, QOptionPropValue } from '@/qComponents/QOption'; import type { Nullable, Optional, UnwrappedInstance } from '#/helpers'; -import QSelectDropdown from './QSelectDropdown.vue'; -import QSelectTags from './QSelectTags.vue'; +import QSelectDropdown from './components/QSelectDropdown'; +import type { QSelectDropdownInstance } from './components/QSelectDropdown'; +import QSelectTags from './components/QSelectTags'; +import type { QSelectTagsInstance } from './components/QSelectTags'; import type { QSelectPropModelValue, QSelectPropAutocomplete, @@ -152,9 +154,7 @@ import type { QSelectInstance, NewOption, QSelectProvider, - QSelectState, - QSelectTagsInstance, - QSelectDropdownInstance + QSelectState } from './types'; export default defineComponent({ diff --git a/src/qComponents/QSelect/src/components/QSelectDropdown/index.ts b/src/qComponents/QSelect/src/components/QSelectDropdown/index.ts index a56fddaf..5fb08cdf 100644 --- a/src/qComponents/QSelect/src/components/QSelectDropdown/index.ts +++ b/src/qComponents/QSelect/src/components/QSelectDropdown/index.ts @@ -1,3 +1,5 @@ import QSelectDropdown from './index.vue'; export default QSelectDropdown; + +export type { QSelectDropdownProps, QSelectDropdownInstance } from './types'; diff --git a/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue b/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue index 5fdb31b8..c965e1a2 100644 --- a/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue +++ b/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue @@ -76,15 +76,13 @@ import type { QSelectProvider } from '@/qComponents/QSelect'; import type { Nullable, UnwrappedInstance } from '#/helpers'; -import type { - QSelectDropdownInstance, - QSelectDropdownProps -} from '../../types'; +import type { QSelectDropdownInstance, QSelectDropdownProps } from './types'; const DEFAULT_Z_INDEX = 2000; export default defineComponent({ name: 'QSelectDropdown', + componentName: 'QSelectDropdown', components: { @@ -94,15 +92,50 @@ export default defineComponent({ }, props: { - shown: { type: Boolean, required: true }, - selectAllShown: { type: Boolean, required: true }, - selectAllText: { type: String, required: true }, - showEmptyContent: { type: Boolean, required: true }, - emptyText: { type: String, required: true }, - isCanLoadMoreShown: { type: Boolean, required: true }, - loadMoreText: { type: String, required: true }, - isNewOptionShown: { type: Boolean, required: true }, - width: { type: Number, default: null } + shown: { + type: Boolean, + required: true + }, + + selectAllShown: { + type: Boolean, + required: true + }, + + selectAllText: { + type: String, + required: true + }, + + showEmptyContent: { + type: Boolean, + required: true + }, + + emptyText: { + type: String, + required: true + }, + + isCanLoadMoreShown: { + type: Boolean, + required: true + }, + + loadMoreText: { + type: String, + required: true + }, + + isNewOptionShown: { + type: Boolean, + required: true + }, + + width: { + type: Number, + default: null + } }, emits: ['select-all'], diff --git a/src/qComponents/QSelect/src/components/QSelectDropdown/types.ts b/src/qComponents/QSelect/src/components/QSelectDropdown/types.ts index e69de29b..93af8cf0 100644 --- a/src/qComponents/QSelect/src/components/QSelectDropdown/types.ts +++ b/src/qComponents/QSelect/src/components/QSelectDropdown/types.ts @@ -0,0 +1,32 @@ +import type { ComputedRef, Ref } from 'vue'; + +import type { QScrollbarInstance } from '@/qComponents/QScrollbar'; +import type { QSelectState } from '@/qComponents/QSelect'; + +import type { Nullable, UnwrappedInstance } from '#/helpers'; + +export interface QSelectDropdownProps { + shown: Nullable; + selectAllShown: Nullable; + selectAllText: Nullable; + showEmptyContent: Nullable; + emptyText: Nullable; + isCanLoadMoreShown: Nullable; + loadMoreText: Nullable; + isNewOptionShown: Nullable; + width: Nullable; +} + +export interface QSelectDropdownInstance { + zIndex: Ref; + styles: ComputedRef>>; + isVisibleOptionExist: ComputedRef; + areAllSelected: ComputedRef; + isIndeterminate: ComputedRef; + navigateDropdown: (e: KeyboardEvent) => void; + handleSelectAllClick: () => void; + root: Ref>; + multiple: Ref> | boolean; + scrollbar: Ref>; + qSelectState: Partial>; +} diff --git a/src/qComponents/QSelect/src/components/QSelectTags/index.ts b/src/qComponents/QSelect/src/components/QSelectTags/index.ts index c179c43a..726887d8 100644 --- a/src/qComponents/QSelect/src/components/QSelectTags/index.ts +++ b/src/qComponents/QSelect/src/components/QSelectTags/index.ts @@ -1,3 +1,5 @@ import QSelectTags from './index.vue'; export default QSelectTags; + +export type { QSelectTagsInstance } from './types'; diff --git a/src/qComponents/QSelect/src/components/QSelectTags/index.vue b/src/qComponents/QSelect/src/components/QSelectTags/index.vue index 1bc0c6a5..84186ba7 100644 --- a/src/qComponents/QSelect/src/components/QSelectTags/index.vue +++ b/src/qComponents/QSelect/src/components/QSelectTags/index.vue @@ -39,7 +39,7 @@ :value="query" type="text" class="q-select-tags__input" - :autocomplete="autocomplete" + :autocomplete="autocomplete ?? 'off'" @focus="$emit('focus')" @keyup.esc="$emit('exit')" @keyup.enter="$emit('keyup-enter')" @@ -57,7 +57,9 @@ import type { QSelectProvider } from '@/qComponents/QSelect'; import type { Nullable } from '#/helpers'; -import type { NewOption, QSelectTagsInstance } from '../../types'; +import type { NewOption } from '../../types'; + +import type { QSelectTagsInstance } from './types'; export default defineComponent({ name: 'QSelectTags', @@ -88,7 +90,7 @@ export default defineComponent({ ctx.emit('remove-tag', option); }; - const handleInput = (event: KeyboardEvent): void => { + const handleInput = (event: Event): void => { const target = event.target as HTMLInputElement; ctx.emit('update:query', target.value); }; diff --git a/src/qComponents/QSelect/src/components/QSelectTags/types.ts b/src/qComponents/QSelect/src/components/QSelectTags/types.ts index e69de29b..7e370ecf 100644 --- a/src/qComponents/QSelect/src/components/QSelectTags/types.ts +++ b/src/qComponents/QSelect/src/components/QSelectTags/types.ts @@ -0,0 +1,20 @@ +import type { Ref } from 'vue'; + +import type { QOptionModel } from '@/qComponents/QOption'; + +import type { Nullable, Optional } from '#/helpers'; + +import type { NewOption, QSelectState } from '../../types'; + +export interface QSelectTagsInstance { + filterable: Ref | boolean>; + collapseTags: Ref | boolean>; + isDisabled: Ref | boolean>; + autocomplete: Ref>; + selected: Ref>; + query: Ref>; + handleBackspaceKeyDown: () => void; + handleTagClose: (option: Nullable) => void; + handleInput: (event: Event) => void; + input: Ref>; +} diff --git a/src/qComponents/QSelect/src/types.ts b/src/qComponents/QSelect/src/types.ts index 01af5871..149aed30 100644 --- a/src/qComponents/QSelect/src/types.ts +++ b/src/qComponents/QSelect/src/types.ts @@ -3,9 +3,11 @@ import type { Ref, ComputedRef } from 'vue'; import type { QInputInstance } from '@/qComponents/QInput'; import type { QOptionModel, QOptionPropValue } from '@/qComponents/QOption'; -import type { QScrollbarInstance } from '@/qComponents/QScrollbar'; -import type { Nullable, Optional, UnwrappedInstance } from '#/helpers'; +import type { Nullable, UnwrappedInstance } from '#/helpers'; + +import type { QSelectDropdownInstance } from './components/QSelectDropdown/types'; +import type { QSelectTagsInstance } from './components/QSelectTags/types'; export type QSelectPropModelValue = Nullable< string | number | QOptionPropValue | (string | number | QOptionPropValue)[] @@ -51,7 +53,7 @@ export type QSelectPropCollapseTags = Nullable; export type QSelectPropTeleportTo = Nullable; -interface QSelectProps { +export interface QSelectProps { modelValue: QSelectPropModelValue; autocomplete: QSelectPropAutocomplete; canLoadMore: QSelectPropCanLoadMore; @@ -75,13 +77,13 @@ interface QSelectProps { teleportTo: QSelectPropTeleportTo; } -type NewOption = { +export type NewOption = { value: QSelectPropModelValue; key: QSelectPropModelValue; preparedLabel: string | number; }; -interface QSelectInstance { +export interface QSelectInstance { input: Ref>; tags: Ref>; dropdown: Ref>; @@ -117,7 +119,7 @@ interface QSelectInstance { t: (key: string) => string; } -interface QSelectProvider { +export interface QSelectProvider { toggleMenu: (event: MouseEvent | KeyboardEvent) => void; toggleOptionSelection: (option: QOptionModel) => void; setSelected: () => void; @@ -136,7 +138,7 @@ interface QSelectProvider { modelValue: Ref; } -interface QSelectState { +export interface QSelectState { options: QOptionModel[]; selected: Nullable; inputWidth: number; @@ -148,54 +150,3 @@ interface QSelectState { popper: Nullable; isDropdownShown: boolean; } - -interface QSelectDropdownInstance { - zIndex: Ref; - styles: ComputedRef>>; - isVisibleOptionExist: ComputedRef; - areAllSelected: ComputedRef; - isIndeterminate: ComputedRef; - navigateDropdown: (e: KeyboardEvent) => void; - handleSelectAllClick: () => void; - root: Ref>; - multiple: Ref> | boolean; - scrollbar: Ref>; - qSelectState: Partial>; -} - -interface QSelectDropdownProps { - shown: Nullable; - selectAllShown: Nullable; - selectAllText: Nullable; - showEmptyContent: Nullable; - emptyText: Nullable; - isCanLoadMoreShown: Nullable; - loadMoreText: Nullable; - isNewOptionShown: Nullable; - width: Nullable; -} - -interface QSelectTagsInstance { - filterable: Ref | boolean>; - collapseTags: Ref | boolean>; - isDisabled: Ref | boolean>; - autocomplete: Ref>; - selected: Ref>; - query: Ref>; - handleBackspaceKeyDown: () => void; - handleTagClose: (option: Nullable) => void; - handleInput: (event: KeyboardEvent) => void; - input: Ref>; -} - -export { - QOptionPropValue, - NewOption, - QSelectInstance, - QSelectProps, - QSelectProvider, - QSelectState, - QSelectDropdownInstance, - QSelectDropdownProps, - QSelectTagsInstance -}; From 43d786cbb30abea20d7ae012335bcf1e42419755 Mon Sep 17 00:00:00 2001 From: shamilfrontend Date: Mon, 30 May 2022 09:42:34 +0300 Subject: [PATCH 4/6] fix: by comments --- .../src/components/QSelectDropdown/index.vue | 60 ++++--------------- .../src/components/QSelectDropdown/types.ts | 6 +- .../src/components/QSelectTags/types.ts | 6 +- src/qComponents/QSelect/src/types.ts | 20 ------- 4 files changed, 19 insertions(+), 73 deletions(-) diff --git a/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue b/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue index c965e1a2..8e363bc9 100644 --- a/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue +++ b/src/qComponents/QSelect/src/components/QSelectDropdown/index.vue @@ -64,7 +64,8 @@