@danielgindi/selectbox 2.0.65 → 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
@@ -3,11 +3,10 @@
3
3
  </template>
4
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,
@@ -296,6 +295,14 @@ export const PropTypes = {
296
295
  autoFlipListDirection: {
297
296
  type: Boolean,
298
297
  default: true
298
+ },
299
+ listZIndex: {
300
+ type: [
301
+ Number,
302
+ String,
303
+ Function
304
+ ],
305
+ default: undefined
299
306
  }
300
307
  };
301
308
  export default defineComponent({
@@ -347,6 +354,9 @@ export default defineComponent({
347
354
  }
348
355
  opts.virtualMinItems = this.virtualMinItems;
349
356
  opts.useExactTargetWidth = this.fixedDroplistWidth;
357
+ if (this.listZIndex !== undefined) {
358
+ opts.zIndex = this.listZIndex;
359
+ }
350
360
  opts.renderItem = this.renderListItem;
351
361
  if (!opts.renderItem) {
352
362
  opts.renderItem = createSlotBasedRenderFunc(this, 'list-item');
@@ -512,6 +522,9 @@ export default defineComponent({
512
522
  onError () {
513
523
  if (this.instance) this.instance.setOnError(this.onError);
514
524
  },
525
+ listZIndex (value) {
526
+ if (this.instance) this.instance.setListZIndex(value);
527
+ },
515
528
  labelProp (value) {
516
529
  if (this.instance) this.instance.setLabelProp(value);
517
530
  },
@@ -533,11 +546,11 @@ export default defineComponent({
533
546
  items (value) {
534
547
  if (this.instance) {
535
548
  this.instance.setItems(value, false);
536
- const modelValue = isVue3 ? this.modelValue : this.value;
549
+ const modelValue = this.modelValue;
537
550
  this.instance.setValue(modelValue === null && (!this.acceptNullAsValue || this.multi) ? undefined : modelValue);
538
551
  }
539
552
  },
540
- [isVue3 ? 'modelValue' : 'value'] (value, old) {
553
+ modelValue (value, old) {
541
554
  if (Array.isArray(value) && Array.isArray(old) && value.length === old && value.every((v, i)=>old[i] === v)) return;
542
555
  if (this.instance) this.instance.setValue(value === null && (!this.acceptNullAsValue || this.multi) ? undefined : value);
543
556
  },
@@ -560,10 +573,10 @@ export default defineComponent({
560
573
  if (this.instance) this.instance.setRenderRestMultiItem(this.computedRenderRestMultiItem, this.computedUnrenderRestMultiItem);
561
574
  },
562
575
  renderNoResultsItem () {
563
- if (this.instance) this.instance.setRenderNoResultsItem(this.computedRenderNoResultsItem, this.computedUnrenderNoResultsItem);
576
+ if (this.instance) this.instance.setListOptions(this.computedListOptions);
564
577
  },
565
578
  unrenderNoResultsItem () {
566
- if (this.instance) this.instance.setRenderNoResultsItem(this.computedRenderNoResultsItem, this.computedUnrenderNoResultsItem);
579
+ if (this.instance) this.instance.setListOptions(this.computedListOptions);
567
580
  },
568
581
  renderListItem () {
569
582
  if (this.instance) this.instance.setListOptions(this.computedListOptions);
@@ -571,11 +584,6 @@ export default defineComponent({
571
584
  unrenderListItem () {
572
585
  if (this.instance) this.instance.setListOptions(this.computedListOptions);
573
586
  },
574
- ...isVue3 ? {} : {
575
- $scopedSlots () {
576
- if (this.instance) this.instance.setListOptions(this.computedListOptions);
577
- }
578
- },
579
587
  $slots () {
580
588
  if (this.instance) this.instance.setListOptions(this.computedListOptions);
581
589
  },
@@ -626,6 +634,7 @@ export default defineComponent({
626
634
  },
627
635
  unmounted () {
628
636
  this.isMounted = false;
637
+ this._destroyBox();
629
638
  },
630
639
  methods: {
631
640
  _handleBoxEvents (event, data) {
@@ -653,10 +662,10 @@ export default defineComponent({
653
662
  this.$emit(event, data.value);
654
663
  break;
655
664
  }
656
- 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) {
657
666
  let value = event === 'select' ? data.value : this.instance.getValue();
658
667
  if (value === undefined && event !== 'select' && this.emitNullForEmptyValue) value = null;
659
- this.$emit(isVue3 ? 'update:modelValue' : 'input', value);
668
+ this.$emit('update:modelValue', value);
660
669
  }
661
670
  },
662
671
  _createBox () {
@@ -710,7 +719,7 @@ export default defineComponent({
710
719
  clearInputWhen: this.clearInputWhen,
711
720
  treatGroupSelectionAsItems: this.treatGroupSelectionAsItems
712
721
  });
713
- const modelValue = isVue3 ? this.modelValue : this.value;
722
+ const modelValue = this.modelValue;
714
723
  box.setValue(modelValue === null && (!this.acceptNullAsValue || this.multi) ? undefined : modelValue);
715
724
  this.instance = markRaw(box);
716
725
  this.el = box.el;
@@ -1,217 +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
- autoRelayoutOnItemsChange?: boolean;
55
- }
56
-
57
- export type DropListVueEmits = {
58
- 'update:modelValue': [value: any];
59
- itemfocus: [data: any];
60
- itemblur: [data: any];
61
- select: [data: any];
62
- 'show:before': [data: any];
63
- show: [data: any];
64
- 'hide:before': [data: any];
65
- hide: [data: any];
66
- check: [data: any];
67
- groupcheck: [data: any];
68
- blur: [];
69
- show_subitems: [data: any];
70
- hide_subitems: [data: any];
71
- 'subitems:select': [data: any];
72
- 'subitems:blur': [data: any];
73
- keypress: [event: KeyboardEvent];
74
- keydown: [event: KeyboardEvent];
75
- };
76
-
77
- // Plain object type literals (not interfaces) here - DefineComponent's C/M generic
78
- // slots require an index signature (ComputedOptions/MethodOptions), and TS only infers
79
- // one implicitly for object type literals, not for named interfaces.
80
- export type DropListVueComputed = {
81
- /** The underlying `DropList` instance, once mounted. */
82
- listRef: () => DropList | undefined;
83
- };
84
-
85
- export type DropListVueMethods = {
86
- relayout(): void;
87
- getHeaderElement(): HTMLElement | undefined;
88
- getFooterElement(): HTMLElement | undefined;
89
- elContains(other: any, considerSublists?: boolean): boolean;
90
- handleInputKeydown(event: KeyboardEvent, options?: DropListInputKeydownOptions): void;
91
- };
92
-
93
- export type DropListVueComponent = DefineComponent<
94
- DropListVueProps,
95
- {},
96
- {},
97
- DropListVueComputed,
98
- DropListVueMethods,
99
- ComponentOptionsMixin,
100
- ComponentOptionsMixin,
101
- DropListVueEmits
102
- >;
103
-
104
- export interface SelectBoxVueProps {
105
- disabled?: boolean;
106
- readOnly?: boolean;
107
- clearable?: boolean;
108
- hasOpenIndicator?: boolean;
109
- placeholder?: string;
110
- sortSelectedItems?: boolean;
111
- sortListItems?: boolean;
112
- sortListCheckedFirst?: boolean;
113
- stickyValues?: any[];
114
- sortItemComparator?: SelectBoxOptions['sortItemComparator'];
115
- splitListCheckedGroups?: boolean;
116
- showSelection?: boolean;
117
- showPlaceholderInTooltip?: boolean;
118
- multiPlaceholderFormatter?: SelectBoxOptions['multiPlaceholderFormatter'];
119
- blurOnSingleSelection?: boolean | 'touch';
120
- multi?: boolean;
121
- searchable?: boolean;
122
- allowTypeToSelect?: boolean;
123
- noResultsText?: string;
124
- filterThrottleWindow?: number;
125
- filterOnEmptyTerm?: boolean;
126
- filterFn?: SelectBoxOptions['filterFn'];
127
- filterDependencies?: any;
128
- labelProp?: string;
129
- valueProp?: string;
130
- multiItemLabelProp?: string;
131
- multiItemRemovePosition?: 'before' | 'after' | 'none';
132
- items?: ItemBase[];
133
- /** Vue 3 (`v-model`). Under Vue 2 compat this is `value` (+ `input` event) instead - untyped here. */
134
- modelValue?: any;
135
- maxMultiItems?: number;
136
- multiItemsRestLabelProvider?: SelectBoxOptions['multiItemsRestLabelProvider'];
137
- renderSingleItem?: SelectBoxOptions['renderSingleItem'];
138
- unrenderSingleItem?: SelectBoxOptions['unrenderSingleItem'];
139
- renderMultiItem?: SelectBoxOptions['renderMultiItem'];
140
- unrenderMultiItem?: SelectBoxOptions['unrenderMultiItem'];
141
- renderRestMultiItem?: SelectBoxOptions['renderRestMultiItem'];
142
- unrenderRestMultiItem?: SelectBoxOptions['unrenderRestMultiItem'];
143
- renderNoResultsItem?: (item: ItemBase, itemEl: Element) => (any | false);
144
- unrenderNoResultsItem?: (item: ItemBase, itemEl: Element) => void;
145
- /** Rendered items in the drop list (as opposed to `renderSingleItem`/`renderMultiItem`, which render the *selected* item representation). */
146
- renderListItem?: (item: ItemBase, itemEl: Element) => (any | false);
147
- unrenderListItem?: (item: ItemBase, itemEl: Element) => void;
148
- virtualMinItems?: number;
149
- baseClass?: string;
150
- droplistBaseClass?: string;
151
- additionalClasses?: string | string[] | Record<string, boolean>;
152
- additionalDroplistClasses?: string | string[] | Record<string, boolean>;
153
- direction?: string;
154
- fixedDroplistWidth?: boolean;
155
- acceptNullAsValue?: boolean;
156
- emitNullForEmptyValue?: boolean;
157
- isLoadingMode?: boolean;
158
- closeListWhenLoading?: boolean;
159
- clearInputWhen?: string[];
160
- treatGroupSelectionAsItems?: boolean;
161
- autoCheckGroupChildren?: boolean;
162
- constrainListToWindow?: boolean;
163
- autoFlipListDirection?: boolean;
164
- }
165
-
166
- export type SelectBoxVueEmits = {
167
- 'update:modelValue': [value: any];
168
- 'clear:before': [cancellable: { cancel: boolean }];
169
- clear: [];
170
- open: [data: { list: any }];
171
- 'open:before': [data: { list: any }];
172
- close: [];
173
- 'search:focus': [];
174
- 'search:blur': [];
175
- 'search:term': [term: string];
176
- 'addsel:before': [cancellable: { value: any; item: any; cancel: boolean }];
177
- addsel: [data: { value: any; item: any }];
178
- 'removesel:before': [cancellable: { value: any; item: any; cancel: boolean }];
179
- removesel: [data: { value: any; item: any }];
180
- 'select:before': [cancellable: { value: any; item: any; cancel: boolean }];
181
- select: [data: { value: any; item: any }];
182
- 'input:resize': [];
183
- itemschanged: [data: { term: string | null; mutated: boolean; count: number }];
184
- search: [value: string];
185
- };
186
-
187
- export type SelectBoxVueMethods = {
188
- toggleLoading(on?: boolean): void;
189
- toggleList(open?: boolean): void;
190
- openList(): void;
191
- closeList(): void;
192
- isListOpen(): boolean;
193
- updateItemByValue(value: any, newItem: ItemBase): void;
194
- getSelectedItems(): ItemBase[];
195
- setSearchTerm(term: string, performSearch?: boolean): void;
196
- getSearchTerm(): string;
197
- getFilteredItemCount(): number;
198
- isFilterPending(): boolean;
199
- focus(): void;
200
- blur(): void;
201
- droplistElContains(other: any, considerSublists?: boolean): boolean | undefined;
202
- };
203
-
204
- export type SelectBoxVueComponent = DefineComponent<
205
- SelectBoxVueProps,
206
- {},
207
- {},
208
- {},
209
- SelectBoxVueMethods,
210
- ComponentOptionsMixin,
211
- ComponentOptionsMixin,
212
- SelectBoxVueEmits
213
- >;
214
-
215
- // Referenced only for documentation/traceability above (which lib class each
216
- // wrapper controls) - not part of the emitted type surface itself.
217
- 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 };