@danielgindi/selectbox 2.0.66 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/vue/SelectBox.vue CHANGED
@@ -1,13 +1,12 @@
1
- <template>
2
- <span :ref="v => el = v" />
3
- </template>
4
-
1
+ <template>
2
+ <span :ref="v => el = v" />
3
+ </template>
4
+
5
5
  <script>
6
- import { defineComponent, markRaw, version } from 'vue';
6
+ import { defineComponent, markRaw } from 'vue';
7
7
  import { SelectBox, SelectBoxDefaultOptions as DefaultOptions } from '@danielgindi/selectbox';
8
8
  import { createSlotBasedRenderFunc, createSlotBasedUnrenderFunc } from './utils/slots';
9
9
  import deepEqual from 'fast-deep-equal';
10
- const isVue3 = version > '3.';
11
10
  export const PropTypes = {
12
11
  disabled: {
13
12
  type: Boolean,
@@ -151,7 +150,7 @@ export const PropTypes = {
151
150
  type: Array,
152
151
  default: ()=>[]
153
152
  },
154
- [isVue3 ? 'modelValue' : 'value']: {
153
+ modelValue: {
155
154
  type: [
156
155
  String,
157
156
  Number,
@@ -547,11 +546,11 @@ export default defineComponent({
547
546
  items (value) {
548
547
  if (this.instance) {
549
548
  this.instance.setItems(value, false);
550
- const modelValue = isVue3 ? this.modelValue : this.value;
549
+ const modelValue = this.modelValue;
551
550
  this.instance.setValue(modelValue === null && (!this.acceptNullAsValue || this.multi) ? undefined : modelValue);
552
551
  }
553
552
  },
554
- [isVue3 ? 'modelValue' : 'value'] (value, old) {
553
+ modelValue (value, old) {
555
554
  if (Array.isArray(value) && Array.isArray(old) && value.length === old && value.every((v, i)=>old[i] === v)) return;
556
555
  if (this.instance) this.instance.setValue(value === null && (!this.acceptNullAsValue || this.multi) ? undefined : value);
557
556
  },
@@ -574,10 +573,10 @@ export default defineComponent({
574
573
  if (this.instance) this.instance.setRenderRestMultiItem(this.computedRenderRestMultiItem, this.computedUnrenderRestMultiItem);
575
574
  },
576
575
  renderNoResultsItem () {
577
- if (this.instance) this.instance.setRenderNoResultsItem(this.computedRenderNoResultsItem, this.computedUnrenderNoResultsItem);
576
+ if (this.instance) this.instance.setListOptions(this.computedListOptions);
578
577
  },
579
578
  unrenderNoResultsItem () {
580
- if (this.instance) this.instance.setRenderNoResultsItem(this.computedRenderNoResultsItem, this.computedUnrenderNoResultsItem);
579
+ if (this.instance) this.instance.setListOptions(this.computedListOptions);
581
580
  },
582
581
  renderListItem () {
583
582
  if (this.instance) this.instance.setListOptions(this.computedListOptions);
@@ -585,11 +584,6 @@ export default defineComponent({
585
584
  unrenderListItem () {
586
585
  if (this.instance) this.instance.setListOptions(this.computedListOptions);
587
586
  },
588
- ...isVue3 ? {} : {
589
- $scopedSlots () {
590
- if (this.instance) this.instance.setListOptions(this.computedListOptions);
591
- }
592
- },
593
587
  $slots () {
594
588
  if (this.instance) this.instance.setListOptions(this.computedListOptions);
595
589
  },
@@ -640,6 +634,7 @@ export default defineComponent({
640
634
  },
641
635
  unmounted () {
642
636
  this.isMounted = false;
637
+ this._destroyBox();
643
638
  },
644
639
  methods: {
645
640
  _handleBoxEvents (event, data) {
@@ -667,10 +662,10 @@ export default defineComponent({
667
662
  this.$emit(event, data.value);
668
663
  break;
669
664
  }
670
- if (event === 'select' || event === 'clear' || event === 'groupcheck' || event === 'addsel' && !event.isCheckingGroup || event === 'removesel' && !event.isCheckingGroup) {
665
+ if (event === 'select' || event === 'clear' || event === 'groupcheck' || event === 'addsel' && !data?.isCheckingGroup || event === 'removesel' && !data?.isCheckingGroup) {
671
666
  let value = event === 'select' ? data.value : this.instance.getValue();
672
667
  if (value === undefined && event !== 'select' && this.emitNullForEmptyValue) value = null;
673
- this.$emit(isVue3 ? 'update:modelValue' : 'input', value);
668
+ this.$emit('update:modelValue', value);
674
669
  }
675
670
  },
676
671
  _createBox () {
@@ -724,7 +719,7 @@ export default defineComponent({
724
719
  clearInputWhen: this.clearInputWhen,
725
720
  treatGroupSelectionAsItems: this.treatGroupSelectionAsItems
726
721
  });
727
- const modelValue = isVue3 ? this.modelValue : this.value;
722
+ const modelValue = this.modelValue;
728
723
  box.setValue(modelValue === null && (!this.acceptNullAsValue || this.multi) ? undefined : modelValue);
729
724
  this.instance = markRaw(box);
730
725
  this.el = box.el;
@@ -796,4 +791,4 @@ export default defineComponent({
796
791
  }
797
792
  }
798
793
  });
799
- </script>
794
+ </script>
@@ -1,221 +1,223 @@
1
- // Hand-authored component type declarations for the Vue wrapper components.
2
- // These aren't derived from the .vue source by a compiler (there's no vue-tsc
3
- // in this toolchain) - they're a manually maintained mirror of each component's
4
- // props/emits/exposed-instance-surface. Keep in sync with DropList.vue / SelectBox.vue
5
- // when either one's public surface (PropTypes, emits, or public methods/computed) changes.
6
-
7
- import type { ComponentOptionsMixin, DefineComponent } from 'vue';
8
- import type DropList from '../dist/types/DropList.js';
9
- import type SelectBox from '../dist/types/SelectBox.js';
10
- import type {
11
- DropListInputKeydownOptions,
12
- DropListOptions,
13
- ItemBase,
14
- PositionOptions,
15
- SelectBoxOptions,
16
- } from '../dist/types/types.js';
17
-
18
- export interface DropListVueProps {
19
- baseClassName?: string;
20
- additionalClasses?: string | string[] | Record<string, boolean>;
21
- direction?: 'ltr' | 'rtl' | 'auto';
22
- autoFocus?: boolean;
23
- autoItemBlur?: boolean;
24
- autoItemBlurDelay?: number;
25
- capturesFocus?: boolean;
26
- multi?: boolean;
27
- isHeaderVisible?: boolean;
28
- isFooterVisible?: boolean;
29
- searchable?: boolean;
30
- searchPlaceholder?: string;
31
- noResultsText?: string;
32
- filterThrottleWindow?: number;
33
- filterOnEmptyTerm?: boolean;
34
- filterGroups?: boolean;
35
- filterEmptyGroups?: boolean;
36
- filterFn?: DropListOptions['filterFn'];
37
- filterDependencies?: any;
38
- keyDownHandler?: DropListOptions['keyDownHandler'];
39
- autoCheckGroupChildren?: boolean;
40
- useExactTargetWidth?: boolean;
41
- constrainToWindow?: boolean;
42
- autoFlipDirection?: boolean;
43
- estimatedItemHeight?: number;
44
- estimateWidth?: boolean;
45
- virtualMinItems?: number;
46
- labelProp?: string;
47
- valueProp?: string;
48
- items?: ItemBase[];
49
- /** Vue 3 (`v-model`). Under Vue 2 compat this is `value` (+ `input` event) instead - untyped here. */
50
- modelValue?: any;
51
- renderItem?: DropListOptions['renderItem'];
52
- unrenderItem?: DropListOptions['unrenderItem'];
53
- positionOptions?: PositionOptions;
54
- /** z-index for the drop list (see `DropListOptions.zIndex`). `undefined` uses `DropListDefaultOptions.zIndex`. */
55
- zIndex?: DropListOptions['zIndex'];
56
- autoRelayoutOnItemsChange?: boolean;
57
- }
58
-
59
- export type DropListVueEmits = {
60
- 'update:modelValue': [value: any];
61
- itemfocus: [data: any];
62
- itemblur: [data: any];
63
- select: [data: any];
64
- 'show:before': [data: any];
65
- show: [data: any];
66
- 'hide:before': [data: any];
67
- hide: [data: any];
68
- check: [data: any];
69
- groupcheck: [data: any];
70
- blur: [];
71
- show_subitems: [data: any];
72
- hide_subitems: [data: any];
73
- 'subitems:select': [data: any];
74
- 'subitems:blur': [data: any];
75
- keypress: [event: KeyboardEvent];
76
- keydown: [event: KeyboardEvent];
77
- };
78
-
79
- // Plain object type literals (not interfaces) here - DefineComponent's C/M generic
80
- // slots require an index signature (ComputedOptions/MethodOptions), and TS only infers
81
- // one implicitly for object type literals, not for named interfaces.
82
- export type DropListVueComputed = {
83
- /** The underlying `DropList` instance, once mounted. */
84
- listRef: () => DropList | undefined;
85
- };
86
-
87
- export type DropListVueMethods = {
88
- relayout(): void;
89
- getHeaderElement(): HTMLElement | undefined;
90
- getFooterElement(): HTMLElement | undefined;
91
- elContains(other: any, considerSublists?: boolean): boolean;
92
- handleInputKeydown(event: KeyboardEvent, options?: DropListInputKeydownOptions): void;
93
- };
94
-
95
- export type DropListVueComponent = DefineComponent<
96
- DropListVueProps,
97
- {},
98
- {},
99
- DropListVueComputed,
100
- DropListVueMethods,
101
- ComponentOptionsMixin,
102
- ComponentOptionsMixin,
103
- DropListVueEmits
104
- >;
105
-
106
- export interface SelectBoxVueProps {
107
- disabled?: boolean;
108
- readOnly?: boolean;
109
- clearable?: boolean;
110
- hasOpenIndicator?: boolean;
111
- placeholder?: string;
112
- sortSelectedItems?: boolean;
113
- sortListItems?: boolean;
114
- sortListCheckedFirst?: boolean;
115
- stickyValues?: any[];
116
- sortItemComparator?: SelectBoxOptions['sortItemComparator'];
117
- splitListCheckedGroups?: boolean;
118
- showSelection?: boolean;
119
- showPlaceholderInTooltip?: boolean;
120
- multiPlaceholderFormatter?: SelectBoxOptions['multiPlaceholderFormatter'];
121
- blurOnSingleSelection?: boolean | 'touch';
122
- multi?: boolean;
123
- searchable?: boolean;
124
- allowTypeToSelect?: boolean;
125
- noResultsText?: string;
126
- filterThrottleWindow?: number;
127
- filterOnEmptyTerm?: boolean;
128
- filterFn?: SelectBoxOptions['filterFn'];
129
- filterDependencies?: any;
130
- labelProp?: string;
131
- valueProp?: string;
132
- multiItemLabelProp?: string;
133
- multiItemRemovePosition?: 'before' | 'after' | 'none';
134
- items?: ItemBase[];
135
- /** Vue 3 (`v-model`). Under Vue 2 compat this is `value` (+ `input` event) instead - untyped here. */
136
- modelValue?: any;
137
- maxMultiItems?: number;
138
- multiItemsRestLabelProvider?: SelectBoxOptions['multiItemsRestLabelProvider'];
139
- renderSingleItem?: SelectBoxOptions['renderSingleItem'];
140
- unrenderSingleItem?: SelectBoxOptions['unrenderSingleItem'];
141
- renderMultiItem?: SelectBoxOptions['renderMultiItem'];
142
- unrenderMultiItem?: SelectBoxOptions['unrenderMultiItem'];
143
- renderRestMultiItem?: SelectBoxOptions['renderRestMultiItem'];
144
- unrenderRestMultiItem?: SelectBoxOptions['unrenderRestMultiItem'];
145
- renderNoResultsItem?: (item: ItemBase, itemEl: Element) => (any | false);
146
- unrenderNoResultsItem?: (item: ItemBase, itemEl: Element) => void;
147
- /** Rendered items in the drop list (as opposed to `renderSingleItem`/`renderMultiItem`, which render the *selected* item representation). */
148
- renderListItem?: (item: ItemBase, itemEl: Element) => (any | false);
149
- unrenderListItem?: (item: ItemBase, itemEl: Element) => void;
150
- virtualMinItems?: number;
151
- baseClass?: string;
152
- droplistBaseClass?: string;
153
- additionalClasses?: string | string[] | Record<string, boolean>;
154
- additionalDroplistClasses?: string | string[] | Record<string, boolean>;
155
- direction?: string;
156
- fixedDroplistWidth?: boolean;
157
- acceptNullAsValue?: boolean;
158
- emitNullForEmptyValue?: boolean;
159
- isLoadingMode?: boolean;
160
- closeListWhenLoading?: boolean;
161
- clearInputWhen?: string[];
162
- treatGroupSelectionAsItems?: boolean;
163
- autoCheckGroupChildren?: boolean;
164
- constrainListToWindow?: boolean;
165
- autoFlipListDirection?: boolean;
166
- /** z-index for the drop list (see `DropListOptions.zIndex`). `undefined` uses `DropListDefaultOptions.zIndex`. */
167
- listZIndex?: DropListOptions['zIndex'];
168
- }
169
-
170
- export type SelectBoxVueEmits = {
171
- 'update:modelValue': [value: any];
172
- 'clear:before': [cancellable: { cancel: boolean }];
173
- clear: [];
174
- open: [data: { list: any }];
175
- 'open:before': [data: { list: any }];
176
- close: [];
177
- 'search:focus': [];
178
- 'search:blur': [];
179
- 'search:term': [term: string];
180
- 'addsel:before': [cancellable: { value: any; item: any; cancel: boolean }];
181
- addsel: [data: { value: any; item: any }];
182
- 'removesel:before': [cancellable: { value: any; item: any; cancel: boolean }];
183
- removesel: [data: { value: any; item: any }];
184
- 'select:before': [cancellable: { value: any; item: any; cancel: boolean }];
185
- select: [data: { value: any; item: any }];
186
- 'input:resize': [];
187
- itemschanged: [data: { term: string | null; mutated: boolean; count: number }];
188
- search: [value: string];
189
- };
190
-
191
- export type SelectBoxVueMethods = {
192
- toggleLoading(on?: boolean): void;
193
- toggleList(open?: boolean): void;
194
- openList(): void;
195
- closeList(): void;
196
- isListOpen(): boolean;
197
- updateItemByValue(value: any, newItem: ItemBase): void;
198
- getSelectedItems(): ItemBase[];
199
- setSearchTerm(term: string, performSearch?: boolean): void;
200
- getSearchTerm(): string;
201
- getFilteredItemCount(): number;
202
- isFilterPending(): boolean;
203
- focus(): void;
204
- blur(): void;
205
- droplistElContains(other: any, considerSublists?: boolean): boolean | undefined;
206
- };
207
-
208
- export type SelectBoxVueComponent = DefineComponent<
209
- SelectBoxVueProps,
210
- {},
211
- {},
212
- {},
213
- SelectBoxVueMethods,
214
- ComponentOptionsMixin,
215
- ComponentOptionsMixin,
216
- SelectBoxVueEmits
217
- >;
218
-
219
- // Referenced only for documentation/traceability above (which lib class each
220
- // wrapper controls) - not part of the emitted type surface itself.
221
- export type { DropList as _DropListInstance, SelectBox as _SelectBoxInstance };
1
+ // Hand-authored component type declarations for the Vue wrapper components.
2
+ // These aren't derived from the .vue source by a compiler (there's no vue-tsc
3
+ // in this toolchain) - they're a manually maintained mirror of each component's
4
+ // props/emits/exposed-instance-surface. Keep in sync with DropList.vue / SelectBox.vue
5
+ // when either one's public surface (PropTypes, emits, or public methods/computed) changes.
6
+
7
+ import type { ComponentOptionsMixin, DefineComponent } from 'vue';
8
+ import type DropList from '../dist/types/DropList.js';
9
+ import type SelectBox from '../dist/types/SelectBox.js';
10
+ import type {
11
+ DropListInputKeydownOptions,
12
+ DropListOptions,
13
+ ItemBase,
14
+ PositionOptions,
15
+ SelectBoxOptions,
16
+ } from '../dist/types/types.js';
17
+
18
+ export interface DropListVueProps {
19
+ baseClassName?: string;
20
+ additionalClasses?: string | string[] | Record<string, boolean>;
21
+ direction?: 'ltr' | 'rtl' | 'auto';
22
+ autoFocus?: boolean;
23
+ autoItemBlur?: boolean;
24
+ autoItemBlurDelay?: number;
25
+ capturesFocus?: boolean;
26
+ multi?: boolean;
27
+ isHeaderVisible?: boolean;
28
+ isFooterVisible?: boolean;
29
+ searchable?: boolean;
30
+ searchPlaceholder?: string;
31
+ noResultsText?: string;
32
+ filterThrottleWindow?: number;
33
+ filterOnEmptyTerm?: boolean;
34
+ filterGroups?: boolean;
35
+ filterEmptyGroups?: boolean;
36
+ filterFn?: DropListOptions['filterFn'];
37
+ filterDependencies?: any;
38
+ keyDownHandler?: DropListOptions['keyDownHandler'];
39
+ autoCheckGroupChildren?: boolean;
40
+ useExactTargetWidth?: boolean;
41
+ constrainToWindow?: boolean;
42
+ autoFlipDirection?: boolean;
43
+ estimatedItemHeight?: number;
44
+ estimateWidth?: boolean;
45
+ virtualMinItems?: number;
46
+ labelProp?: string;
47
+ valueProp?: string;
48
+ items?: ItemBase[];
49
+ /** The bound value (`v-model`). */
50
+ modelValue?: any;
51
+ renderItem?: DropListOptions['renderItem'];
52
+ unrenderItem?: DropListOptions['unrenderItem'];
53
+ renderNoResultsItem?: DropListOptions['renderNoResultsItem'];
54
+ unrenderNoResultsItem?: DropListOptions['unrenderNoResultsItem'];
55
+ positionOptions?: PositionOptions;
56
+ /** z-index for the drop list (see `DropListOptions.zIndex`). `undefined` uses `DropListDefaultOptions.zIndex`. */
57
+ zIndex?: DropListOptions['zIndex'];
58
+ autoRelayoutOnItemsChange?: boolean;
59
+ }
60
+
61
+ export type DropListVueEmits = {
62
+ 'update:modelValue': [value: any];
63
+ itemfocus: [data: any];
64
+ itemblur: [data: any];
65
+ select: [data: any];
66
+ 'show:before': [data: any];
67
+ show: [data: any];
68
+ 'hide:before': [data: any];
69
+ hide: [data: any];
70
+ check: [data: any];
71
+ groupcheck: [data: any];
72
+ blur: [];
73
+ show_subitems: [data: any];
74
+ hide_subitems: [data: any];
75
+ 'subitems:select': [data: any];
76
+ 'subitems:blur': [data: any];
77
+ keypress: [event: KeyboardEvent];
78
+ keydown: [event: KeyboardEvent];
79
+ };
80
+
81
+ // Plain object type literals (not interfaces) here - DefineComponent's C/M generic
82
+ // slots require an index signature (ComputedOptions/MethodOptions), and TS only infers
83
+ // one implicitly for object type literals, not for named interfaces.
84
+ export type DropListVueComputed = {
85
+ /** The underlying `DropList` instance, once mounted. */
86
+ listRef: () => DropList | undefined;
87
+ };
88
+
89
+ export type DropListVueMethods = {
90
+ relayout(): void;
91
+ getHeaderElement(): HTMLElement | undefined;
92
+ getFooterElement(): HTMLElement | undefined;
93
+ elContains(other: any, considerSublists?: boolean): boolean;
94
+ handleInputKeydown(event: KeyboardEvent, options?: DropListInputKeydownOptions): void;
95
+ };
96
+
97
+ export type DropListVueComponent = DefineComponent<
98
+ DropListVueProps,
99
+ {},
100
+ {},
101
+ DropListVueComputed,
102
+ DropListVueMethods,
103
+ ComponentOptionsMixin,
104
+ ComponentOptionsMixin,
105
+ DropListVueEmits
106
+ >;
107
+
108
+ export interface SelectBoxVueProps {
109
+ disabled?: boolean;
110
+ readOnly?: boolean;
111
+ clearable?: boolean;
112
+ hasOpenIndicator?: boolean;
113
+ placeholder?: string;
114
+ sortSelectedItems?: boolean;
115
+ sortListItems?: boolean;
116
+ sortListCheckedFirst?: boolean;
117
+ stickyValues?: any[];
118
+ sortItemComparator?: SelectBoxOptions['sortItemComparator'];
119
+ splitListCheckedGroups?: boolean;
120
+ showSelection?: boolean;
121
+ showPlaceholderInTooltip?: boolean;
122
+ multiPlaceholderFormatter?: SelectBoxOptions['multiPlaceholderFormatter'];
123
+ blurOnSingleSelection?: boolean | 'touch';
124
+ multi?: boolean;
125
+ searchable?: boolean;
126
+ allowTypeToSelect?: boolean;
127
+ noResultsText?: string;
128
+ filterThrottleWindow?: number;
129
+ filterOnEmptyTerm?: boolean;
130
+ filterFn?: SelectBoxOptions['filterFn'];
131
+ filterDependencies?: any;
132
+ labelProp?: string;
133
+ valueProp?: string;
134
+ multiItemLabelProp?: string;
135
+ multiItemRemovePosition?: 'before' | 'after' | 'none';
136
+ items?: ItemBase[];
137
+ /** The bound value (`v-model`). */
138
+ modelValue?: any;
139
+ maxMultiItems?: number;
140
+ multiItemsRestLabelProvider?: SelectBoxOptions['multiItemsRestLabelProvider'];
141
+ renderSingleItem?: SelectBoxOptions['renderSingleItem'];
142
+ unrenderSingleItem?: SelectBoxOptions['unrenderSingleItem'];
143
+ renderMultiItem?: SelectBoxOptions['renderMultiItem'];
144
+ unrenderMultiItem?: SelectBoxOptions['unrenderMultiItem'];
145
+ renderRestMultiItem?: SelectBoxOptions['renderRestMultiItem'];
146
+ unrenderRestMultiItem?: SelectBoxOptions['unrenderRestMultiItem'];
147
+ renderNoResultsItem?: (item: ItemBase, itemEl: Element) => (any | false);
148
+ unrenderNoResultsItem?: (item: ItemBase, itemEl: Element) => void;
149
+ /** Rendered items in the drop list (as opposed to `renderSingleItem`/`renderMultiItem`, which render the *selected* item representation). */
150
+ renderListItem?: (item: ItemBase, itemEl: Element) => (any | false);
151
+ unrenderListItem?: (item: ItemBase, itemEl: Element) => void;
152
+ virtualMinItems?: number;
153
+ baseClass?: string;
154
+ droplistBaseClass?: string;
155
+ additionalClasses?: string | string[] | Record<string, boolean>;
156
+ additionalDroplistClasses?: string | string[] | Record<string, boolean>;
157
+ direction?: string;
158
+ fixedDroplistWidth?: boolean;
159
+ acceptNullAsValue?: boolean;
160
+ emitNullForEmptyValue?: boolean;
161
+ isLoadingMode?: boolean;
162
+ closeListWhenLoading?: boolean;
163
+ clearInputWhen?: string[];
164
+ treatGroupSelectionAsItems?: boolean;
165
+ autoCheckGroupChildren?: boolean;
166
+ constrainListToWindow?: boolean;
167
+ autoFlipListDirection?: boolean;
168
+ /** z-index for the drop list (see `DropListOptions.zIndex`). `undefined` uses `DropListDefaultOptions.zIndex`. */
169
+ listZIndex?: DropListOptions['zIndex'];
170
+ }
171
+
172
+ export type SelectBoxVueEmits = {
173
+ 'update:modelValue': [value: any];
174
+ 'clear:before': [cancellable: { cancel: boolean }];
175
+ clear: [];
176
+ open: [data: { list: any }];
177
+ 'open:before': [data: { list: any }];
178
+ close: [];
179
+ 'search:focus': [];
180
+ 'search:blur': [];
181
+ 'search:term': [term: string];
182
+ 'addsel:before': [cancellable: { value: any; item: any; cancel: boolean }];
183
+ addsel: [data: { value: any; item: any }];
184
+ 'removesel:before': [cancellable: { value: any; item: any; cancel: boolean }];
185
+ removesel: [data: { value: any; item: any }];
186
+ 'select:before': [cancellable: { value: any; item: any; cancel: boolean }];
187
+ select: [data: { value: any; item: any }];
188
+ 'input:resize': [];
189
+ itemschanged: [data: { term: string | null; mutated: boolean; count: number }];
190
+ search: [value: string];
191
+ };
192
+
193
+ export type SelectBoxVueMethods = {
194
+ toggleLoading(on?: boolean): void;
195
+ toggleList(open?: boolean): void;
196
+ openList(): void;
197
+ closeList(): void;
198
+ isListOpen(): boolean;
199
+ updateItemByValue(value: any, newItem: ItemBase): void;
200
+ getSelectedItems(): ItemBase[];
201
+ setSearchTerm(term: string, performSearch?: boolean): void;
202
+ getSearchTerm(): string;
203
+ getFilteredItemCount(): number;
204
+ isFilterPending(): boolean;
205
+ focus(): void;
206
+ blur(): void;
207
+ droplistElContains(other: any, considerSublists?: boolean): boolean | undefined;
208
+ };
209
+
210
+ export type SelectBoxVueComponent = DefineComponent<
211
+ SelectBoxVueProps,
212
+ {},
213
+ {},
214
+ {},
215
+ SelectBoxVueMethods,
216
+ ComponentOptionsMixin,
217
+ ComponentOptionsMixin,
218
+ SelectBoxVueEmits
219
+ >;
220
+
221
+ // Referenced only for documentation/traceability above (which lib class each
222
+ // wrapper controls) - not part of the emitted type surface itself.
223
+ export type { DropList as _DropListInstance, SelectBox as _SelectBoxInstance };
@@ -1,71 +1,24 @@
1
- import * as VueModule from 'vue';
2
- const isVue3 = VueModule.version > '3.';
3
- const render3 = VueModule.render;
4
- const createVNode3 = VueModule.createVNode;
5
- const createInstanceFromVnode = (vnode)=>{
6
- return new VueModule({
7
- render () {
8
- return vnode;
9
- }
10
- });
11
- };
12
- const createInstanceFromVnodes = (vnodes)=>{
13
- return new VueModule({
14
- render (h) {
15
- return h('div', vnodes);
16
- }
17
- });
18
- };
1
+ import { createVNode, render } from 'vue';
19
2
  const VueInstanceSymbol = Symbol('vue_instance');
20
3
  const createSlotBasedRenderFunc = (vue, slotName)=>{
21
- if (vue.$slots[slotName]) {
22
- return (item, parent)=>{
23
- if (isVue3) {
24
- let slotVnode = vue.$slots[slotName](item);
25
- let vnode = createVNode3({
26
- render () {
27
- return slotVnode;
28
- }
29
- });
30
- render3(vnode, parent);
31
- parent[VueInstanceSymbol] = true;
32
- } else {
33
- let slotVnode = vue.$slots[slotName];
34
- let vm = createInstanceFromVnode(slotVnode);
35
- vm.$mount();
36
- parent[VueInstanceSymbol] = vm;
37
- parent.appendChild(vm.$el);
38
- }
39
- };
40
- }
41
- if (!isVue3 && vue.$scopedSlots && vue.$scopedSlots[slotName]) {
42
- return (item, parent)=>{
43
- let vnode = vue.$scopedSlots[slotName](item);
44
- let vm;
45
- if (Array.isArray(vnode)) {
46
- vm = createInstanceFromVnodes(vnode);
47
- vm.$mount();
48
- let nodes = vm.$el.childNodes;
49
- parent[VueInstanceSymbol] = vm;
50
- for (let node of nodes)parent.appendChild(node);
51
- } else {
52
- vm = createInstanceFromVnode(vnode);
53
- vm.$mount();
54
- parent[VueInstanceSymbol] = vm;
55
- parent.appendChild(vm.$el);
4
+ if (!vue.$slots[slotName]) return undefined;
5
+ return (item, parent)=>{
6
+ const slotVnode = vue.$slots[slotName](item);
7
+ const vnode = createVNode({
8
+ render () {
9
+ return slotVnode;
56
10
  }
57
- };
58
- }
11
+ });
12
+ render(vnode, parent);
13
+ parent[VueInstanceSymbol] = true;
14
+ };
59
15
  };
60
16
  const createSlotBasedUnrenderFunc = (vue, slotName)=>{
61
- if (vue.$slots[slotName] || !isVue3 && vue.$scopedSlots && vue.$scopedSlots[slotName]) {
62
- return (parent)=>{
63
- const vmOrApp = parent[VueInstanceSymbol];
64
- if (!vmOrApp) return;
65
- if (isVue3) render3(null, parent);
66
- else vmOrApp.$destroy();
67
- delete parent[VueInstanceSymbol];
68
- };
69
- }
17
+ if (!vue.$slots[slotName]) return undefined;
18
+ return (parent)=>{
19
+ if (!parent[VueInstanceSymbol]) return;
20
+ render(null, parent);
21
+ delete parent[VueInstanceSymbol];
22
+ };
70
23
  };
71
24
  export { createSlotBasedRenderFunc, createSlotBasedUnrenderFunc };
package/vite.config.js DELETED
@@ -1,9 +0,0 @@
1
- import { defineConfig } from 'vite';
2
-
3
- export default defineConfig({
4
- root: 'example',
5
- base: './',
6
- server: {
7
- open: true,
8
- },
9
- });