@94ai/nf-virtual-select 3.1.13
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/.eslintrc.cjs +49 -0
- package/README.md +16 -0
- package/components.d.ts +8 -0
- package/lib/el-option-node.vue.d.ts +47 -0
- package/lib/index.d.ts +1056 -0
- package/lib/nf-virtual-select-container.vue.d.ts +32 -0
- package/lib/nf-virtual-select.cjs.js +701 -0
- package/lib/nf-virtual-select.esm-bundler.js +701 -0
- package/lib/nf-virtual-select.vue.d.ts +369 -0
- package/lib/style/css.d.ts +1 -0
- package/lib/style/css.js +1 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +1 -0
- package/package/el-option-node.vue +48 -0
- package/package/index.ts +8 -0
- package/package/nf-virtual-select-container.vue +68 -0
- package/package/nf-virtual-select.vue +571 -0
- package/package/style/css.ts +1 -0
- package/package/style/index.ts +1 -0
- package/package.json +37 -0
- package/postcss.config.js +8 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<virtual-select-container
|
|
3
|
+
v-model="currentVal"
|
|
4
|
+
v-on="bindEvents"
|
|
5
|
+
@visible-change="visibleChange"
|
|
6
|
+
ref="nfVirtualSelectContainer"
|
|
7
|
+
:class="['nf-virtual-select nf-virtual-select-el-select', bindProps['collapse-tags'] ? 'nf-virtual-select-collapse-tags' : '']"
|
|
8
|
+
:config="config"
|
|
9
|
+
:tag="tag"
|
|
10
|
+
>
|
|
11
|
+
<template v-if="isVirtualSelect">
|
|
12
|
+
<slot name="prefix" slot="prefix" />
|
|
13
|
+
<slot name="empty" slot="empty" />
|
|
14
|
+
<virtual-list
|
|
15
|
+
:offset="offset"
|
|
16
|
+
:start="start"
|
|
17
|
+
:page-mode="pageMode"
|
|
18
|
+
:direction="direction"
|
|
19
|
+
:top-threshold="topThreshold"
|
|
20
|
+
:bottom-threshold="bottomThreshold"
|
|
21
|
+
:root-tag="rootTag"
|
|
22
|
+
:wrap-tag="wrapTag"
|
|
23
|
+
:wrap-style="wrapStyle"
|
|
24
|
+
:item-tag="itemTag"
|
|
25
|
+
:item-class="itemClass"
|
|
26
|
+
:item-class-add="itemClassAdd"
|
|
27
|
+
:item-style="itemStyle"
|
|
28
|
+
:item-scoped-slots="itemScopedSlots"
|
|
29
|
+
:header-tag="headerTag"
|
|
30
|
+
:header-class="headeClass"
|
|
31
|
+
:header-style="headerStyle"
|
|
32
|
+
:footer-tag="footerTag"
|
|
33
|
+
:footer-class="footerClass"
|
|
34
|
+
:footer-style="footerStyle"
|
|
35
|
+
:extra-props="extraProps"
|
|
36
|
+
:data-component="itemComponent"
|
|
37
|
+
:data-sources="selectArr"
|
|
38
|
+
:data-key="dataKey"
|
|
39
|
+
:estimate-size="estimateSize"
|
|
40
|
+
:keeps="keeps"
|
|
41
|
+
ref="virtualSelectList"
|
|
42
|
+
class="nf-virtual-select-list"
|
|
43
|
+
@scroll="scroll"
|
|
44
|
+
@totop="totop"
|
|
45
|
+
@tobottom="tobottom"
|
|
46
|
+
@resized="resized"
|
|
47
|
+
:style="`max-height: ${height};min-width: ${width};max-width: ${maxWidth};`"
|
|
48
|
+
>
|
|
49
|
+
<slot slot="footer" name="footer" />
|
|
50
|
+
<slot slot="header" name="header" />
|
|
51
|
+
</virtual-list>
|
|
52
|
+
<slot />
|
|
53
|
+
</template>
|
|
54
|
+
<template v-else>
|
|
55
|
+
<slot name="header" />
|
|
56
|
+
<el-option
|
|
57
|
+
v-for="(item, index) in selectArr"
|
|
58
|
+
:key="item[keyValue[0]] + '_' + index"
|
|
59
|
+
:label="item[keyValue[0]]"
|
|
60
|
+
:value="item[keyValue[1]]"
|
|
61
|
+
:disabled="item.disabled"
|
|
62
|
+
>
|
|
63
|
+
<el-tooltip :content="item[keyValue[0]]"
|
|
64
|
+
:open-delay="1000"
|
|
65
|
+
effect="dark"
|
|
66
|
+
placement="left"
|
|
67
|
+
v-if="showTip">
|
|
68
|
+
<span>{{ item[keyValue[0]] }}</span>
|
|
69
|
+
</el-tooltip>
|
|
70
|
+
<span v-else>
|
|
71
|
+
{{ item[keyValue[0]] }}
|
|
72
|
+
</span>
|
|
73
|
+
</el-option>
|
|
74
|
+
<slot />
|
|
75
|
+
<slot name="footer" />
|
|
76
|
+
</template>
|
|
77
|
+
</virtual-select-container>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<script>
|
|
81
|
+
import virtualList from 'vue-virtual-scroll-list'
|
|
82
|
+
import ElOptionNode from './el-option-node.vue'
|
|
83
|
+
import { isEqual } from 'lodash-es'
|
|
84
|
+
import VirtualSelectContainer from './nf-virtual-select-container.vue'
|
|
85
|
+
|
|
86
|
+
export default {
|
|
87
|
+
name: 'nf-virtual-select',
|
|
88
|
+
components: {
|
|
89
|
+
'virtual-list': virtualList,
|
|
90
|
+
'virtual-select-container': VirtualSelectContainer
|
|
91
|
+
},
|
|
92
|
+
inheritAttrs: false,
|
|
93
|
+
props: {
|
|
94
|
+
tag: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: 'el-select'
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* 虚拟滚动属性
|
|
100
|
+
*/
|
|
101
|
+
offset: {
|
|
102
|
+
type: Number,
|
|
103
|
+
default: 0
|
|
104
|
+
},
|
|
105
|
+
start: {
|
|
106
|
+
type: Number,
|
|
107
|
+
default: 0
|
|
108
|
+
},
|
|
109
|
+
pageMode: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: false
|
|
112
|
+
},
|
|
113
|
+
direction: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: 'vertical'
|
|
116
|
+
},
|
|
117
|
+
topThreshold: {
|
|
118
|
+
type: Number,
|
|
119
|
+
default: 0
|
|
120
|
+
},
|
|
121
|
+
bottomThreshold: {
|
|
122
|
+
type: Number,
|
|
123
|
+
default: 0
|
|
124
|
+
},
|
|
125
|
+
rootTag: {
|
|
126
|
+
type: String,
|
|
127
|
+
default: 'div'
|
|
128
|
+
},
|
|
129
|
+
wrapTag: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: 'div'
|
|
132
|
+
},
|
|
133
|
+
wrapStyle: {
|
|
134
|
+
type: Object,
|
|
135
|
+
default: () => {
|
|
136
|
+
return {}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
itemTag: {
|
|
140
|
+
type: String,
|
|
141
|
+
default: 'div'
|
|
142
|
+
},
|
|
143
|
+
itemClass: {
|
|
144
|
+
type: String,
|
|
145
|
+
default: ''
|
|
146
|
+
},
|
|
147
|
+
itemClassAdd: {
|
|
148
|
+
type: Function
|
|
149
|
+
},
|
|
150
|
+
itemStyle: {
|
|
151
|
+
type: Object,
|
|
152
|
+
default: () => {
|
|
153
|
+
return {}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
itemScopedSlots: {
|
|
157
|
+
type: Object,
|
|
158
|
+
default: () => {
|
|
159
|
+
return {}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
headerTag: {
|
|
163
|
+
type: String,
|
|
164
|
+
default: 'div'
|
|
165
|
+
},
|
|
166
|
+
headeClass: {
|
|
167
|
+
type: String,
|
|
168
|
+
default: ''
|
|
169
|
+
},
|
|
170
|
+
headerStyle: {
|
|
171
|
+
type: Object,
|
|
172
|
+
default: () => {
|
|
173
|
+
return {}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
footerTag: {
|
|
177
|
+
type: String,
|
|
178
|
+
default: 'span'
|
|
179
|
+
},
|
|
180
|
+
footerClass: {
|
|
181
|
+
type: String,
|
|
182
|
+
default: ''
|
|
183
|
+
},
|
|
184
|
+
footerStyle: {
|
|
185
|
+
type: Object,
|
|
186
|
+
default: () => {
|
|
187
|
+
return {}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
keeps: {
|
|
191
|
+
type: Number,
|
|
192
|
+
default: 30
|
|
193
|
+
},
|
|
194
|
+
// 每个项目的估计大小,如果它更接近平均大小,滚动条长度看起来更准确。建议指定自己计算的平均值。
|
|
195
|
+
estimateSize: {
|
|
196
|
+
type: Number,
|
|
197
|
+
default: 50
|
|
198
|
+
},
|
|
199
|
+
echoValueTop: { // 处理当回显值在虚拟滚动渲染外不能正确回显问题
|
|
200
|
+
type: Boolean,
|
|
201
|
+
default: true
|
|
202
|
+
},
|
|
203
|
+
extraProps: {
|
|
204
|
+
type: Object,
|
|
205
|
+
default: () => ({
|
|
206
|
+
label: 'label',
|
|
207
|
+
value: 'value'
|
|
208
|
+
})
|
|
209
|
+
},
|
|
210
|
+
dataComponent: {
|
|
211
|
+
type: Object
|
|
212
|
+
},
|
|
213
|
+
dataKey: {
|
|
214
|
+
type: [String, Function],
|
|
215
|
+
default: 'templateId'
|
|
216
|
+
},
|
|
217
|
+
/**
|
|
218
|
+
* 选中值
|
|
219
|
+
*/
|
|
220
|
+
value: {
|
|
221
|
+
type: [String, Number, Array],
|
|
222
|
+
default: () => {
|
|
223
|
+
return ''
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
/**
|
|
227
|
+
* 开启tooltip
|
|
228
|
+
*/
|
|
229
|
+
showTip: {
|
|
230
|
+
type: Boolean,
|
|
231
|
+
default: true
|
|
232
|
+
},
|
|
233
|
+
/**
|
|
234
|
+
* keyValue别名
|
|
235
|
+
*/
|
|
236
|
+
keyValue: {
|
|
237
|
+
type: Array,
|
|
238
|
+
default: () => ['label', 'value']
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
itemOptions: {
|
|
242
|
+
type: Object,
|
|
243
|
+
default() {
|
|
244
|
+
return {
|
|
245
|
+
options: [],
|
|
246
|
+
virtualList: false
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
virtualList: {
|
|
251
|
+
type: Boolean,
|
|
252
|
+
default: false
|
|
253
|
+
},
|
|
254
|
+
options: {
|
|
255
|
+
type: Array,
|
|
256
|
+
default: () => []
|
|
257
|
+
},
|
|
258
|
+
placeholder: {
|
|
259
|
+
type: String,
|
|
260
|
+
default: '请选择'
|
|
261
|
+
},
|
|
262
|
+
multiple: {
|
|
263
|
+
type: Boolean,
|
|
264
|
+
default: false
|
|
265
|
+
},
|
|
266
|
+
width: {
|
|
267
|
+
type: String,
|
|
268
|
+
default: '100%'
|
|
269
|
+
},
|
|
270
|
+
maxWidth: {
|
|
271
|
+
type: String,
|
|
272
|
+
default: undefined
|
|
273
|
+
},
|
|
274
|
+
height: {
|
|
275
|
+
type: String,
|
|
276
|
+
default: '245px'
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
data() {
|
|
280
|
+
const that = this
|
|
281
|
+
const ElOption = {
|
|
282
|
+
props: {
|
|
283
|
+
index: { // 每一行的索引
|
|
284
|
+
type: Number,
|
|
285
|
+
required: true
|
|
286
|
+
},
|
|
287
|
+
source: { // 每一行的内容
|
|
288
|
+
type: Object,
|
|
289
|
+
default() {
|
|
290
|
+
return {}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
render(h) {
|
|
295
|
+
return h(ElOptionNode, {
|
|
296
|
+
attrs: {
|
|
297
|
+
label: that.keyValue[0],
|
|
298
|
+
value: that.keyValue[1],
|
|
299
|
+
showTip: that.showTip,
|
|
300
|
+
source: this.source,
|
|
301
|
+
index: this.index
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
itemComponent: this.dataComponent ?? ElOption,
|
|
308
|
+
selectArr: []
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
computed: {
|
|
312
|
+
config() {
|
|
313
|
+
const configData = {
|
|
314
|
+
...this.bindProps,
|
|
315
|
+
'popper-class': (this.bindProps.popperClass || '') + ` ${this.isVirtualSelect ? 'nf-virtual-select-virtual-list-popper' : 'nf-virtual-select-el-select-popper'}`
|
|
316
|
+
}
|
|
317
|
+
if (this.isVirtualSelect) {
|
|
318
|
+
return {
|
|
319
|
+
...configData,
|
|
320
|
+
'filter-method': this.filterMethod,
|
|
321
|
+
filterable: true,
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return configData
|
|
325
|
+
},
|
|
326
|
+
currentVal: {
|
|
327
|
+
get() {
|
|
328
|
+
return this.value
|
|
329
|
+
},
|
|
330
|
+
set(v) {
|
|
331
|
+
this.$emit('input', v)
|
|
332
|
+
this.$emit('change', v)
|
|
333
|
+
this.$emit('update:value', v)
|
|
334
|
+
if (this.itemOptions.events?.change) {
|
|
335
|
+
this.itemOptions.events.change(v, this)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
// 绑定属性
|
|
340
|
+
bindProps() {
|
|
341
|
+
let obj = {
|
|
342
|
+
clearable: true,
|
|
343
|
+
...this.itemOptions,
|
|
344
|
+
...this.$attrs,
|
|
345
|
+
virtualList: this.isVirtualSelect,
|
|
346
|
+
placeholder: this.placeholderDesc,
|
|
347
|
+
multiple: this.isMultipleSelect,
|
|
348
|
+
options: this.optionsList
|
|
349
|
+
}
|
|
350
|
+
if (obj.element === 'custom-select' || (obj.element === 'el-select')) {
|
|
351
|
+
if (obj.multiple) {
|
|
352
|
+
obj = {
|
|
353
|
+
'collapse-tags': true,
|
|
354
|
+
...obj
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
delete obj.options
|
|
358
|
+
}
|
|
359
|
+
return obj
|
|
360
|
+
},
|
|
361
|
+
// 绑定方法
|
|
362
|
+
bindEvents() {
|
|
363
|
+
const events = { ...(this.$listeners || {}), ...this.itemOptions.events }
|
|
364
|
+
if (events?.change) {
|
|
365
|
+
delete events.change
|
|
366
|
+
}
|
|
367
|
+
if (events?.input) {
|
|
368
|
+
delete events.input
|
|
369
|
+
}
|
|
370
|
+
if (events?.['update:value']) {
|
|
371
|
+
delete events['update:value']
|
|
372
|
+
}
|
|
373
|
+
if (events?.['visible-change']) {
|
|
374
|
+
delete events['visible-change']
|
|
375
|
+
}
|
|
376
|
+
return events || {}
|
|
377
|
+
},
|
|
378
|
+
isVirtualSelect() {
|
|
379
|
+
return this.virtualList || this.itemOptions.virtualList
|
|
380
|
+
},
|
|
381
|
+
isMultipleSelect() {
|
|
382
|
+
return this.multiple || this.itemOptions.multiple
|
|
383
|
+
},
|
|
384
|
+
placeholderDesc() {
|
|
385
|
+
return this.itemOptions.placeholder || this.placeholder
|
|
386
|
+
},
|
|
387
|
+
optionsList() {
|
|
388
|
+
if (this.options.length) {
|
|
389
|
+
return this.options
|
|
390
|
+
} else if (this.itemOptions.options?.length) {
|
|
391
|
+
return this.itemOptions.options
|
|
392
|
+
} else {
|
|
393
|
+
return []
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
nfVirtualSelect() {
|
|
397
|
+
return this.$refs.nfVirtualSelectContainer?.$refs?.nfVirtualSelect
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
watch: {
|
|
401
|
+
optionsList(newVal, value) {
|
|
402
|
+
if (!isEqual(newVal, value)) {
|
|
403
|
+
this.init()
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
currentVal: {
|
|
407
|
+
handler(newVal, value) {
|
|
408
|
+
this.init()
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
mounted() {
|
|
413
|
+
this.init()
|
|
414
|
+
},
|
|
415
|
+
methods: {
|
|
416
|
+
reset() {
|
|
417
|
+
if (this.isVirtualSelect) {
|
|
418
|
+
this.$refs.virtualSelectList?.reset()
|
|
419
|
+
} else {
|
|
420
|
+
const container = this.nfVirtualSelect?.$refs?.popper?.$el?.querySelector('.el-select-dropdown__wrap')
|
|
421
|
+
if (container) {
|
|
422
|
+
container.scrollTop = 0
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
scrollToBottom() {
|
|
427
|
+
this.$refs.virtualSelectList.scrollToBottom()
|
|
428
|
+
},
|
|
429
|
+
scrollToIndex(index) {
|
|
430
|
+
this.$refs.virtualSelectList?.scrollToIndex(index)
|
|
431
|
+
},
|
|
432
|
+
scrollToOffset(offset) {
|
|
433
|
+
this.$refs.virtualSelectList.scrollToOffset(offset)
|
|
434
|
+
},
|
|
435
|
+
getSize(id) {
|
|
436
|
+
return this.$refs.virtualSelectList.getSize(id)
|
|
437
|
+
},
|
|
438
|
+
getClientSize() {
|
|
439
|
+
return this.$refs.virtualSelectList.getClientSize()
|
|
440
|
+
},
|
|
441
|
+
getScrollSize() {
|
|
442
|
+
return this.$refs.virtualSelectList.getScrollSize()
|
|
443
|
+
},
|
|
444
|
+
updatePageModeFront() {
|
|
445
|
+
this.$refs.virtualSelectList?.updatePageModeFront()
|
|
446
|
+
},
|
|
447
|
+
scroll(event) {
|
|
448
|
+
if (this.itemOptions.events?.scroll) {
|
|
449
|
+
this.itemOptions.events.scroll(event, this)
|
|
450
|
+
} else {
|
|
451
|
+
// @scroll 事件
|
|
452
|
+
this.$emit('scroll', event)
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
totop(event) {
|
|
456
|
+
if (this.itemOptions.events?.totop) {
|
|
457
|
+
this.itemOptions.events.totop(event, this)
|
|
458
|
+
} else {
|
|
459
|
+
// @totop 事件
|
|
460
|
+
this.$emit('totop', event)
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
tobottom(event) {
|
|
464
|
+
if (this.itemOptions.events?.tobottom) {
|
|
465
|
+
this.itemOptions.events.tobottom(event, this)
|
|
466
|
+
} else {
|
|
467
|
+
// @tobottom 事件
|
|
468
|
+
this.$emit('tobottom', event)
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
resized(event) {
|
|
472
|
+
if (this.itemOptions.events?.resized) {
|
|
473
|
+
this.itemOptions.events.resized(event, this)
|
|
474
|
+
} else {
|
|
475
|
+
// @resized 事件
|
|
476
|
+
this.$emit('resized', event)
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
init() {
|
|
480
|
+
if ((this.isVirtualSelect)) {
|
|
481
|
+
// 虚拟
|
|
482
|
+
// 无回显值
|
|
483
|
+
this.selectArr = this.optionsList?.map(it => ({
|
|
484
|
+
[this.keyValue[0]]: it[this.keyValue[0]],
|
|
485
|
+
[this.keyValue[1]]: it[this.keyValue[1]],
|
|
486
|
+
[this.dataKey]: it[this.keyValue[1]],
|
|
487
|
+
disabled: it['disabled'] ?? false
|
|
488
|
+
})) ?? []
|
|
489
|
+
if (this.currentVal && this.echoValueTop) {
|
|
490
|
+
// 有回显值
|
|
491
|
+
if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) {
|
|
492
|
+
// 多选
|
|
493
|
+
const multiple_elements = this.selectArr.filter(item => this.currentVal.includes(item[this.keyValue[1]]))
|
|
494
|
+
this.selectArr = [...multiple_elements, ...this.selectArr.filter(item => !multiple_elements.includes(item))]
|
|
495
|
+
} else {
|
|
496
|
+
// 单选
|
|
497
|
+
const index = this.selectArr.findIndex(item => item.value === this.currentVal)
|
|
498
|
+
if (index !== -1) {
|
|
499
|
+
const obj = this.selectArr.splice(index, 1)[0]
|
|
500
|
+
this.selectArr.unshift(obj)
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
// 非虚拟选择器
|
|
506
|
+
this.selectArr = (this.optionsList || []).map(it => ({
|
|
507
|
+
[this.keyValue[0]]: it[this.keyValue[0]],
|
|
508
|
+
[this.keyValue[1]]: it[this.keyValue[1]],
|
|
509
|
+
disabled: it['disabled'] ?? false
|
|
510
|
+
}))
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
// 搜索
|
|
514
|
+
async filterMethod(query) {
|
|
515
|
+
const filterHandler = this.bindProps['filter-method']
|
|
516
|
+
if (query !== '') {
|
|
517
|
+
if (filterHandler) {
|
|
518
|
+
await filterHandler(query)
|
|
519
|
+
} else {
|
|
520
|
+
this.reset()
|
|
521
|
+
const selectArr = this.optionsList.filter(item => {
|
|
522
|
+
if (item[this.keyValue[0]]) {
|
|
523
|
+
return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1
|
|
524
|
+
}
|
|
525
|
+
})
|
|
526
|
+
this.selectArr = (selectArr || []).map(it => {
|
|
527
|
+
return {
|
|
528
|
+
[this.keyValue[0]]: it[this.keyValue[0]],
|
|
529
|
+
[this.keyValue[1]]: it[this.keyValue[1]],
|
|
530
|
+
[this.dataKey]: it[this.keyValue[1]],
|
|
531
|
+
disabled: it['disabled'] ? it['disabled'] : false
|
|
532
|
+
}
|
|
533
|
+
})
|
|
534
|
+
}
|
|
535
|
+
} else if (filterHandler) {
|
|
536
|
+
await filterHandler(query)
|
|
537
|
+
} else {
|
|
538
|
+
this.init()
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
async visibleChange(bool) {
|
|
542
|
+
const events = { ...(this.$listeners || {}), ...this.itemOptions.events }
|
|
543
|
+
const fn = events['visible-change']
|
|
544
|
+
if (fn) {
|
|
545
|
+
let go = fn(bool)
|
|
546
|
+
if (Promise.resolve(go) === go) {
|
|
547
|
+
go = await go
|
|
548
|
+
}
|
|
549
|
+
if (go === 'break') {
|
|
550
|
+
return go
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (!bool && this.isVirtualSelect) {
|
|
554
|
+
this.reset()
|
|
555
|
+
this.init()
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
beforeDestroy() {
|
|
560
|
+
this.reset()
|
|
561
|
+
this.selectArr = []
|
|
562
|
+
},
|
|
563
|
+
activated() {
|
|
564
|
+
this.init()
|
|
565
|
+
},
|
|
566
|
+
deactivated() {
|
|
567
|
+
this.reset()
|
|
568
|
+
this.selectArr = []
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/css/nf-virtual-select.css'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/nf-virtual-select.scss'
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@94ai/nf-virtual-select",
|
|
3
|
+
"version": "3.1.13",
|
|
4
|
+
"description": "> TODO: description",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "zoujiahe <zoujiahe@94ai.com>,DESKTOP-1EDDQ79\\dev026 <liuxiangxiang@94ai.com>",
|
|
7
|
+
"homepage": "https://oss.xccjh.top/common-ui/#/ai-index",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@94ai/common-utils": "^3.1.13",
|
|
18
|
+
"@94ai/nf-theme-chalk": "^3.1.13",
|
|
19
|
+
"lodash-es": "^4.17.21",
|
|
20
|
+
"vue-demi": "^0.14.5",
|
|
21
|
+
"vue-virtual-scroll-list": "^2.3.5"
|
|
22
|
+
},
|
|
23
|
+
"peerDependenciesMeta": {
|
|
24
|
+
"@vue/composition-api": {
|
|
25
|
+
"optional": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@vue/composition-api": "^1.0.0-rc.1",
|
|
30
|
+
"element-ui": ">=2.13.2",
|
|
31
|
+
"vue": "^2.0.0 || >=3.0.0"
|
|
32
|
+
},
|
|
33
|
+
"types": "lib/index.d.ts",
|
|
34
|
+
"main": "lib/nf-virtual-select.cjs.js",
|
|
35
|
+
"module": "lib/nf-virtual-select.esm-bundler.js",
|
|
36
|
+
"gitHead": "a8c56183ccc8e979008e2d38bfde2d7d1448654c"
|
|
37
|
+
}
|