@94ai/nf-virtual-select 3.2.56 → 3.2.57

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.
@@ -29,12 +29,11 @@ const _sfc_main$1 = {
29
29
  showTip: {
30
30
  // 提示
31
31
  type: Boolean,
32
- default: true
32
+ default: false
33
33
  }
34
34
  }
35
35
  };
36
36
  var _sfc_render$1 = function render() {
37
- var _a, _b, _c2, _d, _e, _f, _g, _h;
38
37
  var _vm = this, _c = _vm._self._c;
39
38
  return _c("el-option", {
40
39
  key: _vm.index,
@@ -43,35 +42,14 @@ var _sfc_render$1 = function render() {
43
42
  "value": _vm.source[_vm.value],
44
43
  "disabled": _vm.source["disabled"]
45
44
  }
46
- }, [((_b = (_a = _vm.source) == null ? void 0 : _a.slotContent) == null ? void 0 : _b.firstCall) || ((_d = (_c2 = _vm.source) == null ? void 0 : _c2.slotContent) == null ? void 0 : _d.recall) ? _c("el-tooltip", {
47
- attrs: {
48
- "effect": "dark",
49
- "placement": "right"
50
- }
51
- }, [_c("div", {
52
- staticStyle: {
53
- "max-width": "350px"
54
- },
55
- attrs: {
56
- "slot": "content"
57
- },
58
- slot: "content"
59
- }, [_vm._v(" " + _vm._s((_f = (_e = _vm.source) == null ? void 0 : _e.slotContent) == null ? void 0 : _f.firstCall) + " "), _c("br"), _vm._v(" "), _c("br"), _vm._v(" " + _vm._s((_h = (_g = _vm.source) == null ? void 0 : _g.slotContent) == null ? void 0 : _h.recall) + " ")]), _c("span", [_vm._v(_vm._s(_vm.source[_vm.label]))])]) : _vm._e(), _vm.showTip ? _c("el-tooltip", {
45
+ }, [_vm.showTip ? _c("el-tooltip", {
60
46
  attrs: {
61
47
  "content": _vm.source[_vm.label],
62
- "open-delay": 0,
48
+ "open-delay": 1e3,
63
49
  "effect": "dark",
64
50
  "placement": "left"
65
51
  }
66
- }, [_c("div", {
67
- staticStyle: {
68
- "max-width": "120px"
69
- },
70
- attrs: {
71
- "slot": "content"
72
- },
73
- slot: "content"
74
- }, [_vm._v(" " + _vm._s(_vm.source[_vm.label]) + " ")]), _c("span", [_vm._v(_vm._s(_vm.source[_vm.label]))])]) : _vm._e()], 1);
52
+ }, [_c("span", [_vm._v(_vm._s(_vm.source[_vm.label]))])]) : _c("span", [_vm._v(_vm._s(_vm.source[_vm.label]))])], 1);
75
53
  };
76
54
  var _sfc_staticRenderFns$1 = [];
77
55
  var __component__$1 = /* @__PURE__ */ normalizeComponent(_sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, null, null, null);
@@ -83,6 +61,9 @@ const _sfc_main = {
83
61
  },
84
62
  inheritAttrs: false,
85
63
  props: {
64
+ /**
65
+ * 虚拟滚动属性
66
+ */
86
67
  offset: {
87
68
  type: Number,
88
69
  default: 0
@@ -160,7 +141,7 @@ const _sfc_main = {
160
141
  },
161
142
  footerTag: {
162
143
  type: String,
163
- default: "div"
144
+ default: "span"
164
145
  },
165
146
  footerClass: {
166
147
  type: String,
@@ -176,32 +157,48 @@ const _sfc_main = {
176
157
  type: Number,
177
158
  default: 30
178
159
  },
179
- /**
180
- * 每个项目的估计大小,如果它更接近平均大小,滚动条长度看起来更准确。建议指定自己计算的平均值。
181
- */
160
+ // 每个项目的估计大小,如果它更接近平均大小,滚动条长度看起来更准确。建议指定自己计算的平均值。
182
161
  estimateSize: {
183
162
  type: Number,
184
163
  default: 50
185
164
  },
165
+ extraProps: {
166
+ type: Object,
167
+ default: () => ({
168
+ label: "label",
169
+ value: "value"
170
+ })
171
+ },
172
+ dataComponent: {
173
+ type: Object
174
+ },
175
+ dataKey: {
176
+ type: [String, Function],
177
+ default: "templateId"
178
+ },
179
+ /**
180
+ * 选中值
181
+ */
186
182
  value: {
187
183
  type: [String, Number, Array],
188
184
  default: () => {
189
185
  return "";
190
186
  }
191
187
  },
192
- size: {
193
- type: String,
194
- default: void 0
188
+ /**
189
+ * 开启tooltip
190
+ */
191
+ showTip: {
192
+ type: Boolean,
193
+ default: false
195
194
  },
196
- // 默认['label','value']
195
+ /**
196
+ * keyValue别名
197
+ */
197
198
  keyValue: {
198
199
  type: Array,
199
200
  default: () => ["label", "value"]
200
201
  },
201
- placeholder: {
202
- type: String,
203
- default: "请选择"
204
- },
205
202
  itemOptions: {
206
203
  type: Object,
207
204
  default() {
@@ -219,9 +216,9 @@ const _sfc_main = {
219
216
  type: Array,
220
217
  default: () => []
221
218
  },
222
- filterable: {
223
- type: Boolean,
224
- default: false
219
+ placeholder: {
220
+ type: String,
221
+ default: "请选择"
225
222
  },
226
223
  multiple: {
227
224
  type: Boolean,
@@ -231,27 +228,13 @@ const _sfc_main = {
231
228
  type: String,
232
229
  default: "100%"
233
230
  },
231
+ maxWidth: {
232
+ type: String,
233
+ default: null
234
+ },
234
235
  height: {
235
236
  type: String,
236
237
  default: "245px"
237
- },
238
- isFitWidth: {
239
- type: Boolean,
240
- default: true
241
- },
242
- dataComponent: {
243
- type: Object
244
- },
245
- extraProps: {
246
- type: Object,
247
- default: () => ({
248
- label: "label",
249
- value: "value"
250
- })
251
- },
252
- dataKey: {
253
- type: [String, Function],
254
- default: "templateId"
255
238
  }
256
239
  },
257
240
  data() {
@@ -269,11 +252,6 @@ const _sfc_main = {
269
252
  default() {
270
253
  return {};
271
254
  }
272
- },
273
- showTip: {
274
- // 提示
275
- type: Boolean,
276
- default: true
277
255
  }
278
256
  },
279
257
  render(h) {
@@ -281,7 +259,7 @@ const _sfc_main = {
281
259
  attrs: {
282
260
  label: that.keyValue[0],
283
261
  value: that.keyValue[1],
284
- showTip: this.showTip,
262
+ showTip: that.showTip,
285
263
  source: this.source,
286
264
  index: this.index
287
265
  }
@@ -300,18 +278,16 @@ const _sfc_main = {
300
278
  },
301
279
  set(v) {
302
280
  this.$emit("input", v);
281
+ this.$emit("change", v);
282
+ this.$emit("update:value", v);
303
283
  }
304
284
  },
305
- isSelect() {
306
- return Object.prototype.hasOwnProperty.call(this.itemOptions, "virtualList") && !this.itemOptions.virtualList || !this.virtualList;
307
- },
308
285
  isVirtualSelect() {
309
286
  return this.virtualList || this.itemOptions.virtualList;
310
287
  },
311
288
  // 绑定属性
312
289
  bindProps() {
313
290
  let obj = {
314
- size: this.size,
315
291
  clearable: true,
316
292
  ...this.$attrs,
317
293
  ...this.formatItemOptions
@@ -341,13 +317,10 @@ const _sfc_main = {
341
317
  formatItemOptions() {
342
318
  const that = this;
343
319
  return {
344
- size: this.size,
345
320
  ...this.itemOptions,
346
321
  ...this.$attrs,
347
- element: "el-select",
348
322
  virtualList: this.itemOptions.virtualList || this.virtualList,
349
323
  placeholder: this.itemOptions.placeholder || this.placeholder,
350
- filterable: this.itemOptions.filterable || this.filterable,
351
324
  multiple: this.itemOptions.multiple || this.multiple,
352
325
  options: this.optionsList,
353
326
  events: {
@@ -366,9 +339,6 @@ const _sfc_main = {
366
339
  } else {
367
340
  return [];
368
341
  }
369
- },
370
- maxLimitElWidth() {
371
- return this.isFitWidth ? this.width : null;
372
342
  }
373
343
  },
374
344
  watch: {
@@ -450,6 +420,8 @@ const _sfc_main = {
450
420
  this.itemOptions.events.change(event, this);
451
421
  } else {
452
422
  this.$emit("change", event);
423
+ this.$emit("input", event);
424
+ this.$emit("update:value", event);
453
425
  }
454
426
  },
455
427
  init() {
@@ -484,7 +456,11 @@ const _sfc_main = {
484
456
  });
485
457
  },
486
458
  // 搜索
487
- filterMethod(query) {
459
+ async filterMethod(query) {
460
+ const filterHandler = this.bindProps["filter-method"];
461
+ if (filterHandler) {
462
+ await filterHandler(query);
463
+ }
488
464
  if (query !== "") {
489
465
  this.$refs.virtualSelectList.scrollToIndex(0);
490
466
  let timer = setTimeout(() => {
@@ -524,6 +500,7 @@ const _sfc_main = {
524
500
  this.reset();
525
501
  this.init();
526
502
  }
503
+ this.$emit("visible-change", bool);
527
504
  }
528
505
  },
529
506
  beforeDestroy() {
@@ -542,18 +519,17 @@ var _sfc_render = function render2() {
542
519
  var _vm = this, _c = _vm._self._c;
543
520
  return _c("div", {
544
521
  staticClass: "nf-virtual-select"
545
- }, [_vm.isVirtualSelect ? [_c("el-select", _vm._g(_vm._b({
546
- staticClass: "nf-virtual-list-form-item-select",
547
- style: `width: ${_vm.width};`,
522
+ }, [_vm.isVirtualSelect ? _c("el-select", _vm._g(_vm._b({
523
+ ref: "nfVirtualSelect",
524
+ class: ["nf-virtual-select-el-select", _vm.bindProps["collapse-tags"] ? "nf-virtual-select-collapse-tags" : ""],
548
525
  attrs: {
549
- "popper-class": "nf-virtual-list-select",
550
- "disabled": _vm.$attrs.disabled,
551
- "filter-method": _vm.filterMethod,
552
- "filterable": ""
526
+ "popper-class": "nf-virtual-select-virtual-list-popper",
527
+ "filterable": "",
528
+ "filter-method": _vm.filterMethod
553
529
  },
554
530
  on: {
555
- "visible-change": _vm.visibleChange,
556
- "change": _vm.handleChange
531
+ "change": _vm.handleChange,
532
+ "visible-change": _vm.visibleChange
557
533
  },
558
534
  model: {
559
535
  value: _vm.currentVal,
@@ -562,10 +538,14 @@ var _sfc_render = function render2() {
562
538
  },
563
539
  expression: "currentVal"
564
540
  }
565
- }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_c("virtual-list", {
541
+ }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_vm._t("prefix", null, {
542
+ "slot": "prefix"
543
+ }), _vm._t("empty", null, {
544
+ "slot": "empty"
545
+ }), _c("virtual-list", {
566
546
  ref: "virtualSelectList",
567
547
  staticClass: "nf-virtual-select-list",
568
- style: `max-height: ${_vm.height};width: ${_vm.maxLimitElWidth}; overflow-y: auto;`,
548
+ style: `max-height: ${_vm.height};min-width: ${_vm.width};max-width: ${_vm.maxWidth};overflow-y: auto;`,
569
549
  attrs: {
570
550
  "offset": _vm.offset,
571
551
  "start": _vm.start,
@@ -587,12 +567,12 @@ var _sfc_render = function render2() {
587
567
  "footer-tag": _vm.footerTag,
588
568
  "footer-class": _vm.footerClass,
589
569
  "footer-style": _vm.footerStyle,
570
+ "extra-props": _vm.extraProps,
571
+ "data-component": _vm.itemComponent,
572
+ "data-sources": _vm.selectArr,
590
573
  "data-key": _vm.dataKey,
591
574
  "estimate-size": _vm.estimateSize,
592
- "data-sources": _vm.selectArr,
593
- "data-component": _vm.itemComponent,
594
- "keeps": _vm.keeps,
595
- "extra-props": _vm.extraProps
575
+ "keeps": _vm.keeps
596
576
  },
597
577
  on: {
598
578
  "scroll": _vm.scroll,
@@ -600,10 +580,15 @@ var _sfc_render = function render2() {
600
580
  "tobottom": _vm.tobottom,
601
581
  "resized": _vm.resized
602
582
  }
603
- })], 1)] : _vm.isSelect ? _c("el-select", _vm._g(_vm._b({
604
- style: `width: ${_vm.width};`,
583
+ }, [_vm._t("footer", null, {
584
+ "slot": "footer"
585
+ }), _vm._t("header", null, {
586
+ "slot": "header"
587
+ })], 2), _vm._t("default")], 2) : _c("el-select", _vm._g(_vm._b({
588
+ ref: "nfVirtualSelect",
589
+ staticClass: "nf-virtual-select-el-select",
605
590
  attrs: {
606
- "popper-class": "select-popper"
591
+ "popper-class": "nf-virtual-select-el-select-popper"
607
592
  },
608
593
  on: {
609
594
  "change": _vm.handleChange
@@ -615,7 +600,11 @@ var _sfc_render = function render2() {
615
600
  },
616
601
  expression: "currentVal"
617
602
  }
618
- }, "el-select", _vm.bindProps, false), _vm.bindEvents), _vm._l(_vm.selectArr, function(item, index) {
603
+ }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_vm._t("prefix", null, {
604
+ "slot": "prefix"
605
+ }), _vm._t("empty", null, {
606
+ "slot": "empty"
607
+ }), _vm._t("header"), _vm._l(_vm.selectArr, function(item, index) {
619
608
  return _c("el-option", {
620
609
  key: item[_vm.keyValue[0]] + "_" + index,
621
610
  attrs: {
@@ -623,15 +612,15 @@ var _sfc_render = function render2() {
623
612
  "value": item[_vm.keyValue[1]],
624
613
  "disabled": item.disabled
625
614
  }
626
- }, [_c("el-tooltip", {
615
+ }, [_vm.showTip ? _c("el-tooltip", {
627
616
  attrs: {
628
617
  "content": item[_vm.keyValue[0]],
629
618
  "open-delay": 1e3,
630
619
  "effect": "dark",
631
620
  "placement": "left"
632
621
  }
633
- }, [_c("span", [_vm._v(_vm._s(item[_vm.keyValue[0]]))])])], 1);
634
- }), 1) : _vm._e()], 2);
622
+ }, [_c("span", [_vm._v(_vm._s(item[_vm.keyValue[0]]))])]) : _c("span", [_vm._v(" " + _vm._s(item[_vm.keyValue[0]]) + " ")])], 1);
623
+ }), _vm._t("default"), _vm._t("footer")], 2)], 1);
635
624
  };
636
625
  var _sfc_staticRenderFns = [];
637
626
  var __component__ = /* @__PURE__ */ normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
@@ -86,22 +86,32 @@ declare const _default: import("vue").DefineComponent<{
86
86
  type: NumberConstructor;
87
87
  default: number;
88
88
  };
89
+ extraProps: {
90
+ type: ObjectConstructor;
91
+ default: () => {
92
+ label: string;
93
+ value: string;
94
+ };
95
+ };
96
+ dataComponent: {
97
+ type: ObjectConstructor;
98
+ };
99
+ dataKey: {
100
+ type: (StringConstructor | FunctionConstructor)[];
101
+ default: string;
102
+ };
89
103
  value: {
90
104
  type: (NumberConstructor | StringConstructor | ArrayConstructor)[];
91
105
  default: () => "";
92
106
  };
93
- size: {
94
- type: StringConstructor;
95
- default: undefined;
107
+ showTip: {
108
+ type: BooleanConstructor;
109
+ default: boolean;
96
110
  };
97
111
  keyValue: {
98
112
  type: ArrayConstructor;
99
113
  default: () => string[];
100
114
  };
101
- placeholder: {
102
- type: StringConstructor;
103
- default: string;
104
- };
105
115
  itemOptions: {
106
116
  type: ObjectConstructor;
107
117
  default(): {
@@ -117,9 +127,9 @@ declare const _default: import("vue").DefineComponent<{
117
127
  type: ArrayConstructor;
118
128
  default: () => never[];
119
129
  };
120
- filterable: {
121
- type: BooleanConstructor;
122
- default: boolean;
130
+ placeholder: {
131
+ type: StringConstructor;
132
+ default: string;
123
133
  };
124
134
  multiple: {
125
135
  type: BooleanConstructor;
@@ -129,26 +139,12 @@ declare const _default: import("vue").DefineComponent<{
129
139
  type: StringConstructor;
130
140
  default: string;
131
141
  };
132
- height: {
142
+ maxWidth: {
133
143
  type: StringConstructor;
134
- default: string;
135
- };
136
- isFitWidth: {
137
- type: BooleanConstructor;
138
- default: boolean;
139
- };
140
- dataComponent: {
141
- type: ObjectConstructor;
144
+ default: null;
142
145
  };
143
- extraProps: {
144
- type: ObjectConstructor;
145
- default: () => {
146
- label: string;
147
- value: string;
148
- };
149
- };
150
- dataKey: {
151
- type: (StringConstructor | FunctionConstructor)[];
146
+ height: {
147
+ type: StringConstructor;
152
148
  default: string;
153
149
  };
154
150
  }, {}, {
@@ -159,13 +155,11 @@ declare const _default: import("vue").DefineComponent<{
159
155
  get(): any;
160
156
  set(v: any): void;
161
157
  };
162
- isSelect(): boolean;
163
158
  isVirtualSelect(): any;
164
159
  bindProps(): any;
165
160
  bindEvents(): any;
166
161
  formatItemOptions(): any;
167
162
  optionsList(): any;
168
- maxLimitElWidth(): any;
169
163
  }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
170
164
  offset: {
171
165
  type: NumberConstructor;
@@ -254,22 +248,32 @@ declare const _default: import("vue").DefineComponent<{
254
248
  type: NumberConstructor;
255
249
  default: number;
256
250
  };
251
+ extraProps: {
252
+ type: ObjectConstructor;
253
+ default: () => {
254
+ label: string;
255
+ value: string;
256
+ };
257
+ };
258
+ dataComponent: {
259
+ type: ObjectConstructor;
260
+ };
261
+ dataKey: {
262
+ type: (StringConstructor | FunctionConstructor)[];
263
+ default: string;
264
+ };
257
265
  value: {
258
266
  type: (NumberConstructor | StringConstructor | ArrayConstructor)[];
259
267
  default: () => "";
260
268
  };
261
- size: {
262
- type: StringConstructor;
263
- default: undefined;
269
+ showTip: {
270
+ type: BooleanConstructor;
271
+ default: boolean;
264
272
  };
265
273
  keyValue: {
266
274
  type: ArrayConstructor;
267
275
  default: () => string[];
268
276
  };
269
- placeholder: {
270
- type: StringConstructor;
271
- default: string;
272
- };
273
277
  itemOptions: {
274
278
  type: ObjectConstructor;
275
279
  default(): {
@@ -285,9 +289,9 @@ declare const _default: import("vue").DefineComponent<{
285
289
  type: ArrayConstructor;
286
290
  default: () => never[];
287
291
  };
288
- filterable: {
289
- type: BooleanConstructor;
290
- default: boolean;
292
+ placeholder: {
293
+ type: StringConstructor;
294
+ default: string;
291
295
  };
292
296
  multiple: {
293
297
  type: BooleanConstructor;
@@ -297,30 +301,17 @@ declare const _default: import("vue").DefineComponent<{
297
301
  type: StringConstructor;
298
302
  default: string;
299
303
  };
300
- height: {
304
+ maxWidth: {
301
305
  type: StringConstructor;
302
- default: string;
303
- };
304
- isFitWidth: {
305
- type: BooleanConstructor;
306
- default: boolean;
307
- };
308
- dataComponent: {
309
- type: ObjectConstructor;
306
+ default: null;
310
307
  };
311
- extraProps: {
312
- type: ObjectConstructor;
313
- default: () => {
314
- label: string;
315
- value: string;
316
- };
317
- };
318
- dataKey: {
319
- type: (StringConstructor | FunctionConstructor)[];
308
+ height: {
309
+ type: StringConstructor;
320
310
  default: string;
321
311
  };
322
312
  }>>, {
323
313
  value: string | number | unknown[];
314
+ showTip: boolean;
324
315
  placeholder: string;
325
316
  options: unknown[];
326
317
  offset: number;
@@ -344,16 +335,14 @@ declare const _default: import("vue").DefineComponent<{
344
335
  footerStyle: Record<string, any>;
345
336
  keeps: number;
346
337
  estimateSize: number;
347
- size: string;
338
+ extraProps: Record<string, any>;
339
+ dataKey: string | Function;
348
340
  keyValue: unknown[];
349
341
  itemOptions: Record<string, any>;
350
342
  virtualList: boolean;
351
- filterable: boolean;
352
343
  multiple: boolean;
353
344
  width: string;
345
+ maxWidth: string;
354
346
  height: string;
355
- isFitWidth: boolean;
356
- extraProps: Record<string, any>;
357
- dataKey: string | Function;
358
347
  }>;
359
348
  export default _default;
@@ -1,18 +1,19 @@
1
1
  <template>
2
- <el-option :key="index" :label="source[label]" :value="source[value]" :disabled="source['disabled']">
3
- <el-tooltip v-if="source?.slotContent?.firstCall || source?.slotContent?.recall" effect="dark" placement="right">
4
- <div slot="content" style="max-width: 350px;">
5
- {{ source?.slotContent?.firstCall }} <br> <br>
6
- {{ source?.slotContent?.recall }}
7
- </div>
8
- <span>{{ source[label] }}</span>
9
- </el-tooltip>
10
- <el-tooltip v-if="showTip" :content="source[label]" :open-delay="0" effect="dark" placement="left">
11
- <div slot="content" style="max-width: 120px;">
12
- {{ source[label] }}
13
- </div>
2
+ <el-option
3
+ :key="index"
4
+ :label="source[label]"
5
+ :value="source[value]"
6
+ :disabled="source['disabled']"
7
+ >
8
+ <el-tooltip v-if="showTip"
9
+ :content="source[label]"
10
+ :open-delay="1000"
11
+ effect="dark"
12
+ placement="left"
13
+ >
14
14
  <span>{{ source[label] }}</span>
15
15
  </el-tooltip>
16
+ <span v-else>{{ source[label] }}</span>
16
17
  </el-option>
17
18
  </template>
18
19
 
@@ -40,7 +41,7 @@ export default {
40
41
  },
41
42
  showTip: { // 提示
42
43
  type: Boolean,
43
- default: true
44
+ default: false
44
45
  }
45
46
  }
46
47
  }