@94ai/nf-virtual-select 8.3.23 → 10.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.
@@ -1,4 +1,439 @@
1
- declare var _default: import("vue").DefineComponent<import("vue").ComponentPropsOptions<import("vue").Data>, {}, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<string[]> | import("vue").ExtractPropTypes<import("vue/types/v3-component-props").ComponentObjectPropsOptions<import("vue").Data>>>, {
2
- [x: number]: string;
3
- } | {}>;
1
+ declare var _default: import("vue").DefineComponent<{
2
+ tag: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ };
6
+ offset: {
7
+ type: NumberConstructor;
8
+ default: number;
9
+ };
10
+ start: {
11
+ type: NumberConstructor;
12
+ default: number;
13
+ };
14
+ pageMode: {
15
+ type: BooleanConstructor;
16
+ default: boolean;
17
+ };
18
+ direction: {
19
+ type: StringConstructor;
20
+ default: string;
21
+ };
22
+ topThreshold: {
23
+ type: NumberConstructor;
24
+ default: number;
25
+ };
26
+ bottomThreshold: {
27
+ type: NumberConstructor;
28
+ default: number;
29
+ };
30
+ rootTag: {
31
+ type: StringConstructor;
32
+ default: string;
33
+ };
34
+ wrapTag: {
35
+ type: StringConstructor;
36
+ default: string;
37
+ };
38
+ wrapStyle: {
39
+ type: ObjectConstructor;
40
+ default: () => {};
41
+ };
42
+ itemTag: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ itemClass: {
47
+ type: StringConstructor;
48
+ default: string;
49
+ };
50
+ itemClassAdd: {
51
+ type: FunctionConstructor;
52
+ };
53
+ itemStyle: {
54
+ type: ObjectConstructor;
55
+ default: () => {};
56
+ };
57
+ headerTag: {
58
+ type: StringConstructor;
59
+ default: string;
60
+ };
61
+ headeClass: {
62
+ type: StringConstructor;
63
+ default: string;
64
+ };
65
+ headerStyle: {
66
+ type: ObjectConstructor;
67
+ default: () => {};
68
+ };
69
+ footerTag: {
70
+ type: StringConstructor;
71
+ default: string;
72
+ };
73
+ footerClass: {
74
+ type: StringConstructor;
75
+ default: string;
76
+ };
77
+ footerStyle: {
78
+ type: ObjectConstructor;
79
+ default: () => {};
80
+ };
81
+ keeps: {
82
+ type: NumberConstructor;
83
+ default: number;
84
+ };
85
+ estimateSize: {
86
+ type: NumberConstructor;
87
+ default: number;
88
+ };
89
+ echoValueTop: {
90
+ type: BooleanConstructor;
91
+ default: boolean;
92
+ };
93
+ extraProps: {
94
+ type: ObjectConstructor;
95
+ default: () => {
96
+ label: string;
97
+ value: string;
98
+ };
99
+ };
100
+ dataComponent: {
101
+ type: ObjectConstructor;
102
+ };
103
+ dataKey: {
104
+ type: (StringConstructor | FunctionConstructor)[];
105
+ default: string;
106
+ };
107
+ value: {
108
+ type: (NumberConstructor | StringConstructor | ArrayConstructor | BooleanConstructor)[];
109
+ default: () => "";
110
+ };
111
+ showTip: {
112
+ type: BooleanConstructor;
113
+ default: boolean;
114
+ };
115
+ keyValue: {
116
+ type: ArrayConstructor;
117
+ default: () => string[];
118
+ };
119
+ itemOptions: {
120
+ type: ObjectConstructor;
121
+ default(): {
122
+ options: never[];
123
+ virtualList: boolean;
124
+ };
125
+ };
126
+ virtualList: {
127
+ type: BooleanConstructor;
128
+ default: boolean;
129
+ };
130
+ options: {
131
+ type: ArrayConstructor;
132
+ default: () => never[];
133
+ };
134
+ placeholder: {
135
+ type: StringConstructor;
136
+ default: undefined;
137
+ };
138
+ multiple: {
139
+ type: BooleanConstructor;
140
+ default: boolean;
141
+ };
142
+ selectAll: {
143
+ type: BooleanConstructor;
144
+ default: boolean;
145
+ };
146
+ selectAllText: {
147
+ type: StringConstructor;
148
+ default: undefined;
149
+ };
150
+ width: {
151
+ type: StringConstructor;
152
+ default: string;
153
+ };
154
+ maxWidth: {
155
+ type: StringConstructor;
156
+ default: undefined;
157
+ };
158
+ height: {
159
+ type: StringConstructor;
160
+ default: string;
161
+ };
162
+ filterable: {
163
+ type: BooleanConstructor;
164
+ default: boolean;
165
+ };
166
+ keywordHighlight: {
167
+ type: BooleanConstructor;
168
+ default: boolean;
169
+ };
170
+ keywordLabelAlias: {
171
+ type: StringConstructor;
172
+ default: string;
173
+ };
174
+ clearable: {
175
+ type: BooleanConstructor;
176
+ default: boolean;
177
+ };
178
+ reserveKeyword: {
179
+ type: BooleanConstructor;
180
+ default: boolean;
181
+ };
182
+ }, {}, {
183
+ itemComponent: never;
184
+ selectArr: never[];
185
+ keyword: string;
186
+ }, {
187
+ localeText(): {
188
+ placeholder: any;
189
+ selectAllText: any;
190
+ };
191
+ isKeywordHighlight(): any;
192
+ config(): {
193
+ 'filter-method'?: any;
194
+ filterable?: boolean | undefined;
195
+ 'popper-class': string;
196
+ };
197
+ currentVal: {
198
+ get(): any;
199
+ set(v: any): void;
200
+ };
201
+ bindProps(): any;
202
+ bindEvents(): any;
203
+ isVirtualSelect(): any;
204
+ isMultipleSelect(): any;
205
+ isReserveKeyword(): any;
206
+ placeholderDesc(): any;
207
+ optionsList(): any;
208
+ nfVirtualSelect(): any;
209
+ matchedCount(): any;
210
+ }, {}, {
211
+ methods: {
212
+ t(path: string, params?: Record<string, any> | undefined): string;
213
+ };
214
+ }, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
215
+ tag: {
216
+ type: StringConstructor;
217
+ default: string;
218
+ };
219
+ offset: {
220
+ type: NumberConstructor;
221
+ default: number;
222
+ };
223
+ start: {
224
+ type: NumberConstructor;
225
+ default: number;
226
+ };
227
+ pageMode: {
228
+ type: BooleanConstructor;
229
+ default: boolean;
230
+ };
231
+ direction: {
232
+ type: StringConstructor;
233
+ default: string;
234
+ };
235
+ topThreshold: {
236
+ type: NumberConstructor;
237
+ default: number;
238
+ };
239
+ bottomThreshold: {
240
+ type: NumberConstructor;
241
+ default: number;
242
+ };
243
+ rootTag: {
244
+ type: StringConstructor;
245
+ default: string;
246
+ };
247
+ wrapTag: {
248
+ type: StringConstructor;
249
+ default: string;
250
+ };
251
+ wrapStyle: {
252
+ type: ObjectConstructor;
253
+ default: () => {};
254
+ };
255
+ itemTag: {
256
+ type: StringConstructor;
257
+ default: string;
258
+ };
259
+ itemClass: {
260
+ type: StringConstructor;
261
+ default: string;
262
+ };
263
+ itemClassAdd: {
264
+ type: FunctionConstructor;
265
+ };
266
+ itemStyle: {
267
+ type: ObjectConstructor;
268
+ default: () => {};
269
+ };
270
+ headerTag: {
271
+ type: StringConstructor;
272
+ default: string;
273
+ };
274
+ headeClass: {
275
+ type: StringConstructor;
276
+ default: string;
277
+ };
278
+ headerStyle: {
279
+ type: ObjectConstructor;
280
+ default: () => {};
281
+ };
282
+ footerTag: {
283
+ type: StringConstructor;
284
+ default: string;
285
+ };
286
+ footerClass: {
287
+ type: StringConstructor;
288
+ default: string;
289
+ };
290
+ footerStyle: {
291
+ type: ObjectConstructor;
292
+ default: () => {};
293
+ };
294
+ keeps: {
295
+ type: NumberConstructor;
296
+ default: number;
297
+ };
298
+ estimateSize: {
299
+ type: NumberConstructor;
300
+ default: number;
301
+ };
302
+ echoValueTop: {
303
+ type: BooleanConstructor;
304
+ default: boolean;
305
+ };
306
+ extraProps: {
307
+ type: ObjectConstructor;
308
+ default: () => {
309
+ label: string;
310
+ value: string;
311
+ };
312
+ };
313
+ dataComponent: {
314
+ type: ObjectConstructor;
315
+ };
316
+ dataKey: {
317
+ type: (StringConstructor | FunctionConstructor)[];
318
+ default: string;
319
+ };
320
+ value: {
321
+ type: (NumberConstructor | StringConstructor | ArrayConstructor | BooleanConstructor)[];
322
+ default: () => "";
323
+ };
324
+ showTip: {
325
+ type: BooleanConstructor;
326
+ default: boolean;
327
+ };
328
+ keyValue: {
329
+ type: ArrayConstructor;
330
+ default: () => string[];
331
+ };
332
+ itemOptions: {
333
+ type: ObjectConstructor;
334
+ default(): {
335
+ options: never[];
336
+ virtualList: boolean;
337
+ };
338
+ };
339
+ virtualList: {
340
+ type: BooleanConstructor;
341
+ default: boolean;
342
+ };
343
+ options: {
344
+ type: ArrayConstructor;
345
+ default: () => never[];
346
+ };
347
+ placeholder: {
348
+ type: StringConstructor;
349
+ default: undefined;
350
+ };
351
+ multiple: {
352
+ type: BooleanConstructor;
353
+ default: boolean;
354
+ };
355
+ selectAll: {
356
+ type: BooleanConstructor;
357
+ default: boolean;
358
+ };
359
+ selectAllText: {
360
+ type: StringConstructor;
361
+ default: undefined;
362
+ };
363
+ width: {
364
+ type: StringConstructor;
365
+ default: string;
366
+ };
367
+ maxWidth: {
368
+ type: StringConstructor;
369
+ default: undefined;
370
+ };
371
+ height: {
372
+ type: StringConstructor;
373
+ default: string;
374
+ };
375
+ filterable: {
376
+ type: BooleanConstructor;
377
+ default: boolean;
378
+ };
379
+ keywordHighlight: {
380
+ type: BooleanConstructor;
381
+ default: boolean;
382
+ };
383
+ keywordLabelAlias: {
384
+ type: StringConstructor;
385
+ default: string;
386
+ };
387
+ clearable: {
388
+ type: BooleanConstructor;
389
+ default: boolean;
390
+ };
391
+ reserveKeyword: {
392
+ type: BooleanConstructor;
393
+ default: boolean;
394
+ };
395
+ }>>, {
396
+ value: string | number | boolean | unknown[];
397
+ showTip: boolean;
398
+ keywordLabelAlias: string;
399
+ tag: string;
400
+ multiple: boolean;
401
+ offset: number;
402
+ start: number;
403
+ pageMode: boolean;
404
+ direction: string;
405
+ topThreshold: number;
406
+ bottomThreshold: number;
407
+ rootTag: string;
408
+ wrapTag: string;
409
+ wrapStyle: Record<string, any>;
410
+ itemTag: string;
411
+ itemClass: string;
412
+ itemStyle: Record<string, any>;
413
+ headerTag: string;
414
+ headeClass: string;
415
+ headerStyle: Record<string, any>;
416
+ footerTag: string;
417
+ footerClass: string;
418
+ footerStyle: Record<string, any>;
419
+ keeps: number;
420
+ estimateSize: number;
421
+ echoValueTop: boolean;
422
+ extraProps: Record<string, any>;
423
+ dataKey: string | Function;
424
+ keyValue: unknown[];
425
+ itemOptions: Record<string, any>;
426
+ virtualList: boolean;
427
+ options: unknown[];
428
+ placeholder: string;
429
+ selectAll: boolean;
430
+ selectAllText: string;
431
+ width: string;
432
+ maxWidth: string;
433
+ height: string;
434
+ filterable: boolean;
435
+ keywordHighlight: boolean;
436
+ clearable: boolean;
437
+ reserveKeyword: boolean;
438
+ }>;
4
439
  export default _default;
@@ -66,7 +66,7 @@
66
66
  <el-checkbox
67
67
  :value="matchedCount === selectArr?.length"
68
68
  @change="toggleCheckAll"
69
- >{{selectAllText}}
69
+ >{{localeText.selectAllText}}
70
70
  <span v-if="selectArr?.length">({{`${matchedCount}/${selectArr?.length}`}})</span>
71
71
  </el-checkbox>
72
72
  </div>
@@ -99,6 +99,8 @@
99
99
  </template>
100
100
 
101
101
  <script>
102
+ import { LocaleMixin } from '@94ai/common-utils'
103
+
102
104
  import virtualList from 'vue-virtual-scroll-list'
103
105
  import ElOptionNode from './el-option-node.vue'
104
106
  import { isEqual } from 'lodash-es'
@@ -106,6 +108,7 @@ import VirtualSelectContainer from './nf-virtual-select-container.vue'
106
108
 
107
109
  export default {
108
110
  name: 'nf-virtual-select',
111
+ mixins: [LocaleMixin],
109
112
  components: {
110
113
  'virtual-list': virtualList,
111
114
  'virtual-select-container': VirtualSelectContainer
@@ -272,7 +275,7 @@ export default {
272
275
  },
273
276
  placeholder: {
274
277
  type: String,
275
- default: '请选择'
278
+ default: undefined
276
279
  },
277
280
  multiple: {
278
281
  type: Boolean,
@@ -286,7 +289,7 @@ export default {
286
289
  /** 全部 文字(兼容国际化翻译) */
287
290
  selectAllText: {
288
291
  type: String,
289
- default: '全部'
292
+ default: undefined
290
293
  },
291
294
  width: {
292
295
  type: String,
@@ -360,6 +363,12 @@ export default {
360
363
  }
361
364
  },
362
365
  computed: {
366
+ localeText() {
367
+ return {
368
+ placeholder: this.placeholder ?? this.t('nf.common.placeholderSelect'),
369
+ selectAllText: this.selectAllText ?? this.t('nf.common.all'),
370
+ }
371
+ },
363
372
  /** 当前条件是否符合关键词高亮 */
364
373
  isKeywordHighlight() {
365
374
  return this.bindProps.keywordHighlight && !!(this.bindProps.filterable || this.isVirtualSelect)
@@ -426,7 +435,7 @@ export default {
426
435
  },
427
436
  // 绑定方法
428
437
  bindEvents() {
429
- const events = { ...(this.$listeners || {}), ...this.itemOptions.events }
438
+ const events = { ...this.$listeners, ...this.itemOptions.events }
430
439
  if (events?.change) {
431
440
  delete events.change
432
441
  }
@@ -439,7 +448,7 @@ export default {
439
448
  if (events?.['visible-change']) {
440
449
  delete events['visible-change']
441
450
  }
442
- return events || {}
451
+ return events
443
452
  },
444
453
  isVirtualSelect() {
445
454
  return this.virtualList || this.itemOptions.virtualList
@@ -451,7 +460,7 @@ export default {
451
460
  return this.reserveKeyword || this.itemOptions.reserveKeyword
452
461
  },
453
462
  placeholderDesc() {
454
- return this.itemOptions.placeholder || this.placeholder
463
+ return this.itemOptions.placeholder || this.localeText.placeholder
455
464
  },
456
465
  optionsList() {
457
466
  if (this.options.length) {
@@ -467,8 +476,8 @@ export default {
467
476
  },
468
477
  matchedCount() {
469
478
  const matchedNum = this.currentVal.filter(id =>
470
- this.selectArr?.some(obj => obj[this.keyValue[1]] === id)
471
- ).length || 0;;
479
+ this.selectArr.some(obj => obj[this.keyValue[1]] === id)
480
+ ).length;
472
481
  return matchedNum
473
482
  }
474
483
  },
@@ -555,13 +564,13 @@ export default {
555
564
  if ((this.isVirtualSelect)) {
556
565
  // 虚拟
557
566
  // 无回显值
558
- let selectArr = this.optionsList?.map(it => ({
567
+ let selectArr = this.optionsList.map(it => ({
559
568
  ...it,
560
569
  [this.keyValue[0]]: it[this.keyValue[0]],
561
570
  [this.keyValue[1]]: it[this.keyValue[1]],
562
571
  [this.dataKey]: typeof it[this.keyValue[1]] === 'boolean' ? `${it[this.keyValue[0]]}${it[this.keyValue[1]]}` : it[this.keyValue[1]],
563
572
  disabled: it['disabled'] ?? false
564
- })) ?? []
573
+ }))
565
574
  if (this.currentVal && this.echoValueTop) {
566
575
  // 有回显值
567
576
  if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) {
@@ -587,7 +596,7 @@ export default {
587
596
  } else {
588
597
  // 非虚拟选择器
589
598
  let selectArr = []
590
- selectArr = (this.optionsList || []).map(it => ({
599
+ selectArr = this.optionsList.map(it => ({
591
600
  ...it,
592
601
  [this.keyValue[0]]: it[this.keyValue[0]],
593
602
  [this.keyValue[1]]: it[this.keyValue[1]],
@@ -596,7 +605,7 @@ export default {
596
605
  if (this.isKeywordHighlight) {
597
606
  if (this.keyword) {
598
607
  const queryLower = this.keyword.toLowerCase().trim();
599
- const queryText = (this.keyword || '').replace(/\,/g, ',')
608
+ const queryText = this.keyword.replace(/\,/g, ',')
600
609
  let querySet = null
601
610
  if (queryText.includes(',')) {
602
611
  querySet = new Set(queryText.split(","))
@@ -633,7 +642,7 @@ export default {
633
642
  } else {
634
643
  if(needReset) this.reset()
635
644
  const queryLower = query.toLowerCase().trim();
636
- const queryText = (query || '').replace(/\,/g, ',')
645
+ const queryText = query.replace(/\,/g, ',')
637
646
  let querySet = null
638
647
  if (queryText.includes(',')) {
639
648
  querySet = new Set(queryText.split(","))
@@ -659,7 +668,7 @@ export default {
659
668
  const multiple_elements = selectArr.filter(item => this.currentVal.includes(item[this.keyValue[1]]))
660
669
  selectArr = [...multiple_elements, ...selectArr.filter(item => !multiple_elements.includes(item))]
661
670
  }
662
- this.selectArr = (selectArr || []).map(it => {
671
+ this.selectArr = selectArr.map(it => {
663
672
  return {
664
673
  [this.keyValue[0]]: it[this.keyValue[0]],
665
674
  [this.keyValue[1]]: it[this.keyValue[1]],
@@ -681,7 +690,7 @@ export default {
681
690
  }
682
691
  },
683
692
  async visibleChange(bool) {
684
- const events = { ...(this.$listeners || {}), ...this.itemOptions.events }
693
+ const events = { ...this.$listeners, ...this.itemOptions.events }
685
694
  const fn = events['visible-change']
686
695
  if (fn) {
687
696
  let go = fn(bool)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-virtual-select",
3
- "version": "8.3.23",
3
+ "version": "10.0.0",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>,DESKTOP-1EDDQ79\\dev026 <liuxiangxiang@94ai.com>",
@@ -11,15 +11,16 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
14
+ "url": "http://gitlab.94ai.pro/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-utils": "^8.3.23",
18
- "@94ai/nf-theme-chalk": "^8.3.23",
17
+ "@94ai/common-utils": "^10.0.0",
18
+ "@94ai/nf-theme-chalk": "^10.0.0",
19
19
  "lodash-es": "^4.17.21",
20
20
  "sortablejs": "^1.15.3",
21
21
  "vue-demi": "^0.14.5",
22
- "vue-virtual-scroll-list": "^2.3.5"
22
+ "vue-virtual-scroll-list": "^2.3.5",
23
+ "@94ai/vue2-runtime-helpers": "1.0.1"
23
24
  },
24
25
  "peerDependenciesMeta": {
25
26
  "@vue/composition-api": {
@@ -28,11 +29,10 @@
28
29
  },
29
30
  "peerDependencies": {
30
31
  "@vue/composition-api": "^1.0.0-rc.1",
31
- "element-ui": ">=2.13.2",
32
- "vue": "^2.0.0 || >=3.0.0"
32
+ "vue": "^2.0.0 || >=3.0.0",
33
+ "element-ui": ">=2.13.2"
33
34
  },
34
35
  "types": "lib/index.d.ts",
35
36
  "main": "lib/nf-virtual-select.cjs.js",
36
- "module": "lib/nf-virtual-select.esm-bundler.js",
37
- "gitHead": "74e871c7972dc4576480bee02b1dc61a3eafc6ba"
37
+ "module": "lib/nf-virtual-select.esm-bundler.js"
38
38
  }