@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/README.md +150 -130
- package/css/droplist.css +1 -1
- package/css/droplist.css.map +1 -1
- package/css/selectbox.css +1 -1
- package/css/selectbox.css.map +1 -1
- package/dist/lib.cjs.js +50 -40
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +51 -40
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +50 -40
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/dist/types/DropList.d.ts.map +1 -1
- package/dist/types/SelectBox.d.ts.map +1 -1
- package/eslint.config.mjs +153 -151
- package/package.json +23 -13
- package/scss/droplist.scss +62 -71
- package/scss/selectbox.scss +126 -210
- package/vite.config.mjs +29 -0
- package/vue/DropList.vue +20 -20
- package/vue/SelectBox.vue +15 -20
- package/vue/component-types.d.ts +223 -221
- package/vue/utils/slots.js +17 -64
- package/vite.config.js +0 -9
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
|
|
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
|
-
|
|
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 =
|
|
549
|
+
const modelValue = this.modelValue;
|
|
551
550
|
this.instance.setValue(modelValue === null && (!this.acceptNullAsValue || this.multi) ? undefined : modelValue);
|
|
552
551
|
}
|
|
553
552
|
},
|
|
554
|
-
|
|
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.
|
|
576
|
+
if (this.instance) this.instance.setListOptions(this.computedListOptions);
|
|
578
577
|
},
|
|
579
578
|
unrenderNoResultsItem () {
|
|
580
|
-
if (this.instance) this.instance.
|
|
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' && !
|
|
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(
|
|
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 =
|
|
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>
|
package/vue/component-types.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
50
|
-
modelValue?: any;
|
|
51
|
-
renderItem?: DropListOptions['renderItem'];
|
|
52
|
-
unrenderItem?: DropListOptions['unrenderItem'];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
'
|
|
178
|
-
|
|
179
|
-
'search:
|
|
180
|
-
'
|
|
181
|
-
|
|
182
|
-
'
|
|
183
|
-
|
|
184
|
-
'
|
|
185
|
-
|
|
186
|
-
'
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
{},
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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 };
|
package/vue/utils/slots.js
CHANGED
|
@@ -1,71 +1,24 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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]
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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 };
|