@danielgindi/selectbox 2.0.56 → 2.0.58
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/dist/lib.cjs.js +203 -160
- 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 +203 -160
- 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 +203 -160
- 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 +343 -0
- package/dist/types/DropList.d.ts.map +1 -0
- package/dist/types/SelectBox.d.ts +497 -0
- package/dist/types/SelectBox.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +207 -0
- package/dist/types/types.d.ts.map +1 -0
- package/eslint.config.mjs +8 -0
- package/lib/DropList.js +1 -3412
- package/lib/SelectBox.js +1 -3689
- package/lib/index.js +1 -4
- package/package.json +9 -4
- package/tsconfig.json +35 -0
- package/vue/DropList.vue +450 -509
- package/vue/DropList.vue.d.ts +4 -0
- package/vue/SelectBox.vue +855 -981
- package/vue/SelectBox.vue.d.ts +4 -0
- package/vue/component-types.d.ts +210 -0
- package/vue/index.d.ts +4 -0
- package/vue/index.js +3 -4
- package/vue/utils/slots.js +89 -96
- package/lib/utils/escapeRegex.js +0 -1
- package/lib/utils/throttle.js +0 -48
package/vue/DropList.vue
CHANGED
|
@@ -2,54 +2,51 @@
|
|
|
2
2
|
<span v-show="false" />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script>
|
|
6
|
-
import DropList, { DefaultOptions } from '../lib/DropList';
|
|
7
|
-
import DomEventsSink from '@danielgindi/dom-utils/lib/DomEventsSink';
|
|
8
|
-
import { createSlotBasedRenderFunc, createSlotBasedUnrenderFunc } from './utils/slots.js';
|
|
9
|
-
import { version } from 'vue';
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type: String,
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
type:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
type: Boolean,
|
|
51
|
-
default: false,
|
|
52
|
-
},
|
|
5
|
+
<script>
|
|
6
|
+
import DropList, { DefaultOptions } from '../lib/DropList';
|
|
7
|
+
import DomEventsSink from '@danielgindi/dom-utils/lib/DomEventsSink';
|
|
8
|
+
import { createSlotBasedRenderFunc, createSlotBasedUnrenderFunc } from './utils/slots.js';
|
|
9
|
+
import { defineComponent, version } from 'vue';
|
|
10
|
+
const isVue3 = version > '3.';
|
|
11
|
+
const AllListEvents = [
|
|
12
|
+
'itemfocus', 'itemblur', 'select',
|
|
13
|
+
'show:before', 'show',
|
|
14
|
+
'hide:before', 'hide', 'hide:after',
|
|
15
|
+
'check', 'groupcheck', 'blur',
|
|
16
|
+
'show_subitems', 'hide_subitems',
|
|
17
|
+
'subitems:select', 'subitems:blur',
|
|
18
|
+
];
|
|
19
|
+
export const PropTypes = {
|
|
20
|
+
baseClassName: {
|
|
21
|
+
type: String,
|
|
22
|
+
},
|
|
23
|
+
additionalClasses: {
|
|
24
|
+
type: [Object, Array, String],
|
|
25
|
+
},
|
|
26
|
+
direction: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: undefined,
|
|
29
|
+
},
|
|
30
|
+
autoFocus: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: true,
|
|
33
|
+
},
|
|
34
|
+
autoItemBlur: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: true,
|
|
37
|
+
},
|
|
38
|
+
autoItemBlurDelay: {
|
|
39
|
+
type: Number,
|
|
40
|
+
default: 300,
|
|
41
|
+
},
|
|
42
|
+
capturesFocus: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: true,
|
|
45
|
+
},
|
|
46
|
+
multi: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
53
50
|
isHeaderVisible: {
|
|
54
51
|
type: Boolean,
|
|
55
52
|
default: false,
|
|
@@ -61,499 +58,443 @@ export const PropTypes = {
|
|
|
61
58
|
searchable: {
|
|
62
59
|
type: Boolean,
|
|
63
60
|
default: false,
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
type: String,
|
|
67
|
-
required: false,
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
type:
|
|
71
|
-
required: false,
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
type:
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: false,
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
type: Boolean,
|
|
83
|
-
default: false,
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
type:
|
|
87
|
-
default:
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
type:
|
|
91
|
-
default: undefined,
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
type:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
type:
|
|
102
|
-
default:
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
type: Boolean,
|
|
106
|
-
default: true,
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
type: Boolean,
|
|
110
|
-
default:
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
type:
|
|
114
|
-
default:
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
type: Boolean,
|
|
118
|
-
default:
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
type: Number,
|
|
122
|
-
default:
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
type:
|
|
126
|
-
default:
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
type:
|
|
130
|
-
default:
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
type:
|
|
134
|
-
default:
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
type:
|
|
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
|
-
|
|
180
|
-
'
|
|
181
|
-
'
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
computed: {
|
|
196
|
-
computedOptions() {
|
|
197
|
-
let opts = {
|
|
198
|
-
on: this._handleListEvents.bind(this),
|
|
199
|
-
positionOptionsProvider: () => this.positionOptions,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (this.direction) {
|
|
211
|
-
opts.direction = this.direction;
|
|
212
|
-
}
|
|
213
|
-
|
|
61
|
+
},
|
|
62
|
+
searchPlaceholder: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: false,
|
|
65
|
+
},
|
|
66
|
+
noResultsText: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: false,
|
|
69
|
+
},
|
|
70
|
+
filterThrottleWindow: {
|
|
71
|
+
type: Number,
|
|
72
|
+
required: false,
|
|
73
|
+
},
|
|
74
|
+
filterOnEmptyTerm: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
78
|
+
filterGroups: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
82
|
+
filterEmptyGroups: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false,
|
|
85
|
+
},
|
|
86
|
+
filterFn: {
|
|
87
|
+
type: Function,
|
|
88
|
+
default: undefined,
|
|
89
|
+
},
|
|
90
|
+
filterDependencies: {
|
|
91
|
+
type: [Array, String, Number, Boolean, Object],
|
|
92
|
+
default: undefined,
|
|
93
|
+
},
|
|
94
|
+
keyDownHandler: {
|
|
95
|
+
type: Function,
|
|
96
|
+
},
|
|
97
|
+
onError: {
|
|
98
|
+
type: Function,
|
|
99
|
+
default: undefined,
|
|
100
|
+
},
|
|
101
|
+
autoCheckGroupChildren: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: true,
|
|
104
|
+
},
|
|
105
|
+
useExactTargetWidth: {
|
|
106
|
+
type: Boolean,
|
|
107
|
+
default: false,
|
|
108
|
+
},
|
|
109
|
+
constrainToWindow: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: true,
|
|
112
|
+
},
|
|
113
|
+
autoFlipDirection: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: true,
|
|
116
|
+
},
|
|
117
|
+
estimatedItemHeight: {
|
|
118
|
+
type: Number,
|
|
119
|
+
default: 20,
|
|
120
|
+
},
|
|
121
|
+
estimateWidth: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: false,
|
|
124
|
+
},
|
|
125
|
+
virtualMinItems: {
|
|
126
|
+
type: Number,
|
|
127
|
+
default: 10,
|
|
128
|
+
},
|
|
129
|
+
labelProp: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: 'label',
|
|
132
|
+
},
|
|
133
|
+
valueProp: {
|
|
134
|
+
type: String,
|
|
135
|
+
default: 'value',
|
|
136
|
+
},
|
|
137
|
+
items: {
|
|
138
|
+
type: Array,
|
|
139
|
+
default: () => [],
|
|
140
|
+
},
|
|
141
|
+
[isVue3 ? 'modelValue' : 'value']: {
|
|
142
|
+
type: [Number, String, Object, Array],
|
|
143
|
+
},
|
|
144
|
+
renderItem: {
|
|
145
|
+
type: Function,
|
|
146
|
+
},
|
|
147
|
+
unrenderItem: {
|
|
148
|
+
type: Function,
|
|
149
|
+
},
|
|
150
|
+
positionOptions: {
|
|
151
|
+
type: Object,
|
|
152
|
+
},
|
|
153
|
+
autoRelayoutOnItemsChange: {
|
|
154
|
+
type: Boolean,
|
|
155
|
+
default: true,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
export default defineComponent({
|
|
159
|
+
inheritAttrs: false,
|
|
160
|
+
props: PropTypes,
|
|
161
|
+
emits: [
|
|
162
|
+
// vue events
|
|
163
|
+
'update:modelValue',
|
|
164
|
+
// DropList.js events (passthrough)
|
|
165
|
+
'itemfocus',
|
|
166
|
+
'itemblur',
|
|
167
|
+
'select',
|
|
168
|
+
'show:before',
|
|
169
|
+
'show',
|
|
170
|
+
'hide:before',
|
|
171
|
+
'hide',
|
|
172
|
+
'check',
|
|
173
|
+
'groupcheck',
|
|
174
|
+
'blur',
|
|
175
|
+
'show_subitems',
|
|
176
|
+
'hide_subitems',
|
|
177
|
+
'subitems:select',
|
|
178
|
+
'subitems:blur',
|
|
179
|
+
// Element events
|
|
180
|
+
'keypress',
|
|
181
|
+
'keydown',
|
|
182
|
+
],
|
|
183
|
+
data() {
|
|
184
|
+
return {
|
|
185
|
+
el: undefined,
|
|
186
|
+
nonReactive: Object.seal({
|
|
187
|
+
instance: undefined,
|
|
188
|
+
sink: new DomEventsSink(),
|
|
189
|
+
}),
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
computed: {
|
|
193
|
+
computedOptions() {
|
|
194
|
+
let opts = {
|
|
195
|
+
on: this._handleListEvents.bind(this),
|
|
196
|
+
positionOptionsProvider: () => this.positionOptions,
|
|
197
|
+
};
|
|
198
|
+
if (this.baseClassName) {
|
|
199
|
+
opts.baseClassName = this.baseClassName;
|
|
200
|
+
}
|
|
201
|
+
if (this.additionalClassesList) {
|
|
202
|
+
opts.additionalClasses = this.additionalClassesList;
|
|
203
|
+
}
|
|
204
|
+
if (this.direction) {
|
|
205
|
+
opts.direction = this.direction;
|
|
206
|
+
}
|
|
214
207
|
for (let key of ['autoItemBlur', 'capturesFocus', 'multi',
|
|
215
208
|
'autoCheckGroupChildren', 'useExactTargetWidth', 'constrainToWindow',
|
|
216
209
|
'autoFlipDirection', 'estimateWidth',
|
|
217
210
|
'isHeaderVisible', 'isFooterVisible',
|
|
218
211
|
'searchable', 'filterOnEmptyTerm',
|
|
219
212
|
'filterGroups', 'filterEmptyGroups']) {
|
|
220
|
-
if (typeof this[key] === 'boolean') {
|
|
221
|
-
opts[key] = this[key];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (typeof this.
|
|
238
|
-
opts.
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
opts.renderItem = this.renderItem ?? createSlotBasedRenderFunc(this, 'item');
|
|
242
|
-
|
|
243
|
-
opts.unrenderItem
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
opts.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (this.nonReactive.instance)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (this.nonReactive.instance)
|
|
310
|
-
this.nonReactive.instance.
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
this.
|
|
340
|
-
},
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
renderNoResultsItem() {
|
|
347
|
-
this._recreateList();
|
|
348
|
-
},
|
|
349
|
-
|
|
350
|
-
unrenderNoResultsItem() {
|
|
351
|
-
this._recreateList();
|
|
352
|
-
},
|
|
353
|
-
|
|
354
|
-
searchable(v) {
|
|
355
|
-
if (this.nonReactive.instance)
|
|
356
|
-
this.nonReactive.instance.setSearchable(v);
|
|
357
|
-
this.relayout();
|
|
358
|
-
},
|
|
359
|
-
|
|
213
|
+
if (typeof this[key] === 'boolean') {
|
|
214
|
+
opts[key] = this[key];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
for (let key of ['autoItemBlurDelay', 'estimatedItemHeight', 'virtualMinItems']) {
|
|
218
|
+
if (typeof this[key] === 'number') {
|
|
219
|
+
opts[key] = this[key];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
for (let key of ['labelProp', 'valueProp']) {
|
|
223
|
+
if (typeof this[key] === 'string') {
|
|
224
|
+
opts[key] = this[key];
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (typeof this.keyDownHandler === 'function') {
|
|
228
|
+
opts.keyDownHandler = this.keyDownHandler;
|
|
229
|
+
}
|
|
230
|
+
if (typeof this.onError === 'function') {
|
|
231
|
+
opts.onError = this.onError;
|
|
232
|
+
}
|
|
233
|
+
opts.searchPlaceholder = this.searchPlaceholder;
|
|
234
|
+
opts.renderItem = this.renderItem ?? createSlotBasedRenderFunc(this, 'item');
|
|
235
|
+
opts.unrenderItem = this.unrenderItem;
|
|
236
|
+
if (!opts.unrenderItem) {
|
|
237
|
+
let fn = createSlotBasedUnrenderFunc(this, 'item');
|
|
238
|
+
if (fn) {
|
|
239
|
+
opts.unrenderItem = (item, el) => fn(el);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
opts.renderNoResultsItem = this.computedRenderNoResultsItem ?? createSlotBasedRenderFunc(this, 'no-results-item');
|
|
243
|
+
opts.unrenderNoResultsItem = this.computedUnrenderNoResultsItem;
|
|
244
|
+
if (!opts.unrenderNoResultsItem) {
|
|
245
|
+
let fn = createSlotBasedUnrenderFunc(this, 'no-results-item');
|
|
246
|
+
if (fn) {
|
|
247
|
+
opts.unrenderNoResultsItem = (item, el) => fn(el);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return opts;
|
|
251
|
+
},
|
|
252
|
+
additionalClassesList() {
|
|
253
|
+
return this._concatClassesObject(this.additionalClasses);
|
|
254
|
+
},
|
|
255
|
+
listRef() {
|
|
256
|
+
return this.nonReactive.instance;
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
watch: {
|
|
260
|
+
items(value) {
|
|
261
|
+
if (this.nonReactive.instance) {
|
|
262
|
+
const instance = this.nonReactive.instance;
|
|
263
|
+
instance.setItems(Array.isArray(value) ? value : []);
|
|
264
|
+
if (this.autoRelayoutOnItemsChange && instance.isVisible())
|
|
265
|
+
instance.relayout();
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
[isVue3 ? 'modelValue' : 'value'](value, old) {
|
|
269
|
+
if (Array.isArray(value) && Array.isArray(old) &&
|
|
270
|
+
value.length === old && value.every((v, i) => old[i] === v))
|
|
271
|
+
return;
|
|
272
|
+
if (this.nonReactive.instance) {
|
|
273
|
+
if (this.multi) {
|
|
274
|
+
this.nonReactive.instance.setCheckedValues(Array.isArray(value) ? value : value == null ? [] : [value]);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.nonReactive.instance.setSingleSelectedItemByValue(value === null ? undefined : value);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
additionalClasses() {
|
|
282
|
+
if (this.nonReactive.instance)
|
|
283
|
+
this.nonReactive.instance.setAdditionalClasses(this.additionalClassesList);
|
|
284
|
+
},
|
|
285
|
+
direction(value) {
|
|
286
|
+
if (this.nonReactive.instance)
|
|
287
|
+
this.nonReactive.instance.setDirection(value);
|
|
288
|
+
},
|
|
289
|
+
noResultsText(value) {
|
|
290
|
+
if (this.nonReactive.instance)
|
|
291
|
+
this.nonReactive.instance.setNoResultsText(value ?? DefaultOptions.noResultsText);
|
|
292
|
+
},
|
|
293
|
+
filterThrottleWindow(value) {
|
|
294
|
+
if (this.nonReactive.instance)
|
|
295
|
+
this.nonReactive.instance.setFilterThrottleWindow(value ?? DefaultOptions.filterThrottleWindow ?? 0);
|
|
296
|
+
},
|
|
297
|
+
filterOnEmptyTerm(value) {
|
|
298
|
+
if (this.nonReactive.instance)
|
|
299
|
+
this.nonReactive.instance.setFilterOnEmptyTerm(value);
|
|
300
|
+
},
|
|
301
|
+
filterGroups(value) {
|
|
302
|
+
if (this.nonReactive.instance)
|
|
303
|
+
this.nonReactive.instance.setFilterGroups(value);
|
|
304
|
+
},
|
|
305
|
+
filterEmptyGroups(value) {
|
|
306
|
+
if (this.nonReactive.instance)
|
|
307
|
+
this.nonReactive.instance.setFilterEmptyGroups(value);
|
|
308
|
+
},
|
|
309
|
+
filterFn() {
|
|
310
|
+
if (this.nonReactive.instance)
|
|
311
|
+
this.nonReactive.instance.setFilterFn(this.filterFn);
|
|
312
|
+
},
|
|
313
|
+
onError() {
|
|
314
|
+
if (this.nonReactive.instance)
|
|
315
|
+
this.nonReactive.instance.setOnError(this.onError);
|
|
316
|
+
},
|
|
317
|
+
renderItem() {
|
|
318
|
+
this._recreateList();
|
|
319
|
+
},
|
|
320
|
+
unrenderItem() {
|
|
321
|
+
this._recreateList();
|
|
322
|
+
},
|
|
323
|
+
renderNoResultsItem() {
|
|
324
|
+
this._recreateList();
|
|
325
|
+
},
|
|
326
|
+
unrenderNoResultsItem() {
|
|
327
|
+
this._recreateList();
|
|
328
|
+
},
|
|
329
|
+
searchable(v) {
|
|
330
|
+
if (this.nonReactive.instance)
|
|
331
|
+
this.nonReactive.instance.setSearchable(v);
|
|
332
|
+
this.relayout();
|
|
333
|
+
},
|
|
334
|
+
searchPlaceholder(value) {
|
|
335
|
+
if (this.nonReactive.instance)
|
|
336
|
+
this.nonReactive.instance.setSearchPlaceholder(value ?? DefaultOptions.searchPlaceholder);
|
|
337
|
+
},
|
|
360
338
|
isHeaderVisible(v) {
|
|
361
339
|
if (this.nonReactive.instance)
|
|
362
340
|
this.nonReactive.instance.setHeaderVisible(v);
|
|
363
341
|
this.relayout();
|
|
364
342
|
},
|
|
365
|
-
|
|
366
343
|
isFooterVisible(v) {
|
|
367
344
|
if (this.nonReactive.instance)
|
|
368
345
|
this.nonReactive.instance.setFooterVisible(v);
|
|
369
346
|
this.relayout();
|
|
370
347
|
},
|
|
371
|
-
|
|
372
348
|
positionOptions: {
|
|
373
|
-
deep: true,
|
|
374
|
-
handler() {
|
|
375
|
-
this.relayout();
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
this.
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
this
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
case '
|
|
423
|
-
case '
|
|
424
|
-
case 'select':
|
|
425
|
-
case '
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
this.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
this.nonReactive.sink.add(this.nonReactive.instance.el, 'keydown.vue', evt => {
|
|
452
|
-
this.$emit('keydown', evt);
|
|
453
|
-
}, true);
|
|
454
|
-
|
|
455
|
-
if (Array.isArray(this.items))
|
|
456
|
-
list.addItems(this.items);
|
|
457
|
-
|
|
458
|
-
const modelValue = isVue3 ? this.modelValue : this.value;
|
|
459
|
-
if (this.multi) {
|
|
460
|
-
list.setCheckedValues(Array.isArray(modelValue) ? modelValue : modelValue == null ? [] : [modelValue]);
|
|
461
|
-
} else {
|
|
462
|
-
list.setSingleSelectedItemByValue(modelValue === null ? undefined : modelValue);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
const headerRenderer = createSlotBasedRenderFunc(this, 'header');
|
|
349
|
+
deep: true,
|
|
350
|
+
handler() {
|
|
351
|
+
this.relayout();
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
...(isVue3 ? {} : {
|
|
355
|
+
$scopedSlots() {
|
|
356
|
+
this._recreateList();
|
|
357
|
+
},
|
|
358
|
+
}),
|
|
359
|
+
$slots() {
|
|
360
|
+
this._recreateList();
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
mounted() {
|
|
364
|
+
this._createList();
|
|
365
|
+
},
|
|
366
|
+
[isVue3 ? 'unmounted' : 'destroyed']() {
|
|
367
|
+
this._destroyList();
|
|
368
|
+
},
|
|
369
|
+
methods: {
|
|
370
|
+
_handleListEvents(event, data) {
|
|
371
|
+
if ((event === 'select' && !this.multi) ||
|
|
372
|
+
event === 'check' && !event.isCheckingGroup ||
|
|
373
|
+
event === 'groupcheck') {
|
|
374
|
+
this.$emit(isVue3 ? 'update:modelValue' : 'input', event === 'select'
|
|
375
|
+
? data.value
|
|
376
|
+
: this.nonReactive.instance.getCheckedValues(false));
|
|
377
|
+
}
|
|
378
|
+
if (event === 'hide') {
|
|
379
|
+
this._clearAutoRelayout();
|
|
380
|
+
}
|
|
381
|
+
if (event === 'show') {
|
|
382
|
+
this.relayout();
|
|
383
|
+
if (this.autoFocus) {
|
|
384
|
+
this.nonReactive.instance.el.focus();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
switch (event) {
|
|
388
|
+
case 'itemfocus':
|
|
389
|
+
case 'itemblur':
|
|
390
|
+
case 'select':
|
|
391
|
+
case 'show:before':
|
|
392
|
+
case 'show':
|
|
393
|
+
case 'hide:before':
|
|
394
|
+
case 'hide':
|
|
395
|
+
case 'check':
|
|
396
|
+
case 'groupcheck':
|
|
397
|
+
case 'blur':
|
|
398
|
+
case 'show_subitems':
|
|
399
|
+
case 'hide_subitems':
|
|
400
|
+
case 'subitems:select':
|
|
401
|
+
case 'subitems:blur':
|
|
402
|
+
this.$emit(event, ...(data === undefined ? [] : [data]));
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
_createList() {
|
|
407
|
+
this._destroyList();
|
|
408
|
+
if (!this.$root)
|
|
409
|
+
return;
|
|
410
|
+
let list = new DropList(this.computedOptions);
|
|
411
|
+
this.el = list.el;
|
|
412
|
+
this.nonReactive.instance = list;
|
|
413
|
+
this.nonReactive.sink.add(this.nonReactive.instance.el, 'keydown.vue', (evt) => {
|
|
414
|
+
this.$emit('keydown', evt);
|
|
415
|
+
}, true);
|
|
416
|
+
if (Array.isArray(this.items))
|
|
417
|
+
list.addItems(this.items);
|
|
418
|
+
const modelValue = isVue3 ? this.modelValue : this.value;
|
|
419
|
+
if (this.multi) {
|
|
420
|
+
list.setCheckedValues(Array.isArray(modelValue) ? modelValue : modelValue == null ? [] : [modelValue]);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
list.setSingleSelectedItemByValue(modelValue === null ? undefined : modelValue);
|
|
424
|
+
}
|
|
425
|
+
const headerRenderer = createSlotBasedRenderFunc(this, 'header');
|
|
466
426
|
if (headerRenderer) {
|
|
467
427
|
headerRenderer({}, list.getHeaderElement());
|
|
468
428
|
}
|
|
469
|
-
|
|
470
429
|
const footerRenderer = createSlotBasedRenderFunc(this, 'footer');
|
|
471
430
|
if (footerRenderer) {
|
|
472
431
|
footerRenderer({}, list.getFooterElement());
|
|
473
432
|
}
|
|
474
|
-
|
|
475
433
|
list.show();
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
this.
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
parent.scrollWidth > parent.offsetWidth) {
|
|
530
|
-
if (parent === document.documentElement) {
|
|
531
|
-
parent = window;
|
|
532
|
-
}
|
|
533
|
-
this.nonReactive.sink.add(parent, 'scroll.trackposition', () => this.relayout());
|
|
534
|
-
}
|
|
535
|
-
parent = parent.parentNode;
|
|
536
|
-
}
|
|
537
|
-
},
|
|
538
|
-
|
|
539
|
-
relayout() {
|
|
540
|
-
if (this.nonReactive.instance)
|
|
541
|
-
this.nonReactive.instance.relayout();
|
|
542
|
-
},
|
|
543
|
-
|
|
434
|
+
this._setupAutoRelayout();
|
|
435
|
+
},
|
|
436
|
+
_destroyList() {
|
|
437
|
+
this._clearAutoRelayout();
|
|
438
|
+
if (this.nonReactive.instance) {
|
|
439
|
+
this.nonReactive.instance.destroy();
|
|
440
|
+
this.nonReactive.instance = undefined;
|
|
441
|
+
}
|
|
442
|
+
this.el = undefined;
|
|
443
|
+
this.nonReactive.sink.remove(null, '.vue');
|
|
444
|
+
},
|
|
445
|
+
_recreateList() {
|
|
446
|
+
this._destroyList();
|
|
447
|
+
this._createList();
|
|
448
|
+
},
|
|
449
|
+
_concatClassesObject(classes) {
|
|
450
|
+
if (Array.isArray(classes)) {
|
|
451
|
+
return classes.join(' ');
|
|
452
|
+
}
|
|
453
|
+
else if (classes && typeof classes === 'object') {
|
|
454
|
+
let arr = [];
|
|
455
|
+
for (let [key, value] of Object.entries(classes)) {
|
|
456
|
+
if (value)
|
|
457
|
+
arr.push(key);
|
|
458
|
+
}
|
|
459
|
+
return arr.join(' ');
|
|
460
|
+
}
|
|
461
|
+
return classes || '';
|
|
462
|
+
},
|
|
463
|
+
_clearAutoRelayout() {
|
|
464
|
+
this.nonReactive.sink.remove(null, '.trackposition');
|
|
465
|
+
},
|
|
466
|
+
_setupAutoRelayout() {
|
|
467
|
+
this._clearAutoRelayout();
|
|
468
|
+
if (!this.nonReactive.instance)
|
|
469
|
+
return;
|
|
470
|
+
this.nonReactive.sink.add(window, 'resize.trackposition', () => this.relayout());
|
|
471
|
+
let parent = this.nonReactive.instance.el.parentNode;
|
|
472
|
+
while (parent) {
|
|
473
|
+
if (parent.scrollHeight > parent.offsetHeight ||
|
|
474
|
+
parent.scrollWidth > parent.offsetWidth) {
|
|
475
|
+
if (parent === document.documentElement) {
|
|
476
|
+
parent = window;
|
|
477
|
+
}
|
|
478
|
+
this.nonReactive.sink.add(parent, 'scroll.trackposition', () => this.relayout());
|
|
479
|
+
}
|
|
480
|
+
parent = parent.parentNode;
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
relayout() {
|
|
484
|
+
if (this.nonReactive.instance)
|
|
485
|
+
this.nonReactive.instance.relayout();
|
|
486
|
+
},
|
|
544
487
|
getHeaderElement() {
|
|
545
488
|
if (this.nonReactive.instance)
|
|
546
489
|
return this.nonReactive.instance.getHeaderElement();
|
|
547
490
|
},
|
|
548
|
-
|
|
549
491
|
getFooterElement() {
|
|
550
492
|
if (this.nonReactive.instance)
|
|
551
493
|
return this.nonReactive.instance.getFooterElement();
|
|
552
494
|
},
|
|
553
|
-
|
|
554
495
|
elContains(other, considerSublists = true) {
|
|
555
|
-
return !!this.listRef?.elContains(other, considerSublists);
|
|
556
|
-
},
|
|
557
|
-
},
|
|
558
|
-
};
|
|
496
|
+
return !!this.listRef?.elContains(other, considerSublists);
|
|
497
|
+
},
|
|
498
|
+
},
|
|
499
|
+
});
|
|
559
500
|
</script>
|