@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.
@@ -31,12 +31,11 @@ const _sfc_main$1 = {
31
31
  showTip: {
32
32
  // 提示
33
33
  type: Boolean,
34
- default: true
34
+ default: false
35
35
  }
36
36
  }
37
37
  };
38
38
  var _sfc_render$1 = function render() {
39
- var _a, _b, _c2, _d, _e, _f, _g, _h;
40
39
  var _vm = this, _c = _vm._self._c;
41
40
  return _c("el-option", {
42
41
  key: _vm.index,
@@ -45,35 +44,14 @@ var _sfc_render$1 = function render() {
45
44
  "value": _vm.source[_vm.value],
46
45
  "disabled": _vm.source["disabled"]
47
46
  }
48
- }, [((_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", {
49
- attrs: {
50
- "effect": "dark",
51
- "placement": "right"
52
- }
53
- }, [_c("div", {
54
- staticStyle: {
55
- "max-width": "350px"
56
- },
57
- attrs: {
58
- "slot": "content"
59
- },
60
- slot: "content"
61
- }, [_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", {
47
+ }, [_vm.showTip ? _c("el-tooltip", {
62
48
  attrs: {
63
49
  "content": _vm.source[_vm.label],
64
- "open-delay": 0,
50
+ "open-delay": 1e3,
65
51
  "effect": "dark",
66
52
  "placement": "left"
67
53
  }
68
- }, [_c("div", {
69
- staticStyle: {
70
- "max-width": "120px"
71
- },
72
- attrs: {
73
- "slot": "content"
74
- },
75
- slot: "content"
76
- }, [_vm._v(" " + _vm._s(_vm.source[_vm.label]) + " ")]), _c("span", [_vm._v(_vm._s(_vm.source[_vm.label]))])]) : _vm._e()], 1);
54
+ }, [_c("span", [_vm._v(_vm._s(_vm.source[_vm.label]))])]) : _c("span", [_vm._v(_vm._s(_vm.source[_vm.label]))])], 1);
77
55
  };
78
56
  var _sfc_staticRenderFns$1 = [];
79
57
  var __component__$1 = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main$1, _sfc_render$1, _sfc_staticRenderFns$1, false, null, null, null, null);
@@ -85,6 +63,9 @@ const _sfc_main = {
85
63
  },
86
64
  inheritAttrs: false,
87
65
  props: {
66
+ /**
67
+ * 虚拟滚动属性
68
+ */
88
69
  offset: {
89
70
  type: Number,
90
71
  default: 0
@@ -162,7 +143,7 @@ const _sfc_main = {
162
143
  },
163
144
  footerTag: {
164
145
  type: String,
165
- default: "div"
146
+ default: "span"
166
147
  },
167
148
  footerClass: {
168
149
  type: String,
@@ -178,32 +159,48 @@ const _sfc_main = {
178
159
  type: Number,
179
160
  default: 30
180
161
  },
181
- /**
182
- * 每个项目的估计大小,如果它更接近平均大小,滚动条长度看起来更准确。建议指定自己计算的平均值。
183
- */
162
+ // 每个项目的估计大小,如果它更接近平均大小,滚动条长度看起来更准确。建议指定自己计算的平均值。
184
163
  estimateSize: {
185
164
  type: Number,
186
165
  default: 50
187
166
  },
167
+ extraProps: {
168
+ type: Object,
169
+ default: () => ({
170
+ label: "label",
171
+ value: "value"
172
+ })
173
+ },
174
+ dataComponent: {
175
+ type: Object
176
+ },
177
+ dataKey: {
178
+ type: [String, Function],
179
+ default: "templateId"
180
+ },
181
+ /**
182
+ * 选中值
183
+ */
188
184
  value: {
189
185
  type: [String, Number, Array],
190
186
  default: () => {
191
187
  return "";
192
188
  }
193
189
  },
194
- size: {
195
- type: String,
196
- default: void 0
190
+ /**
191
+ * 开启tooltip
192
+ */
193
+ showTip: {
194
+ type: Boolean,
195
+ default: false
197
196
  },
198
- // 默认['label','value']
197
+ /**
198
+ * keyValue别名
199
+ */
199
200
  keyValue: {
200
201
  type: Array,
201
202
  default: () => ["label", "value"]
202
203
  },
203
- placeholder: {
204
- type: String,
205
- default: "请选择"
206
- },
207
204
  itemOptions: {
208
205
  type: Object,
209
206
  default() {
@@ -221,9 +218,9 @@ const _sfc_main = {
221
218
  type: Array,
222
219
  default: () => []
223
220
  },
224
- filterable: {
225
- type: Boolean,
226
- default: false
221
+ placeholder: {
222
+ type: String,
223
+ default: "请选择"
227
224
  },
228
225
  multiple: {
229
226
  type: Boolean,
@@ -233,27 +230,13 @@ const _sfc_main = {
233
230
  type: String,
234
231
  default: "100%"
235
232
  },
233
+ maxWidth: {
234
+ type: String,
235
+ default: null
236
+ },
236
237
  height: {
237
238
  type: String,
238
239
  default: "245px"
239
- },
240
- isFitWidth: {
241
- type: Boolean,
242
- default: true
243
- },
244
- dataComponent: {
245
- type: Object
246
- },
247
- extraProps: {
248
- type: Object,
249
- default: () => ({
250
- label: "label",
251
- value: "value"
252
- })
253
- },
254
- dataKey: {
255
- type: [String, Function],
256
- default: "templateId"
257
240
  }
258
241
  },
259
242
  data() {
@@ -271,11 +254,6 @@ const _sfc_main = {
271
254
  default() {
272
255
  return {};
273
256
  }
274
- },
275
- showTip: {
276
- // 提示
277
- type: Boolean,
278
- default: true
279
257
  }
280
258
  },
281
259
  render(h) {
@@ -283,7 +261,7 @@ const _sfc_main = {
283
261
  attrs: {
284
262
  label: that.keyValue[0],
285
263
  value: that.keyValue[1],
286
- showTip: this.showTip,
264
+ showTip: that.showTip,
287
265
  source: this.source,
288
266
  index: this.index
289
267
  }
@@ -302,18 +280,16 @@ const _sfc_main = {
302
280
  },
303
281
  set(v) {
304
282
  this.$emit("input", v);
283
+ this.$emit("change", v);
284
+ this.$emit("update:value", v);
305
285
  }
306
286
  },
307
- isSelect() {
308
- return Object.prototype.hasOwnProperty.call(this.itemOptions, "virtualList") && !this.itemOptions.virtualList || !this.virtualList;
309
- },
310
287
  isVirtualSelect() {
311
288
  return this.virtualList || this.itemOptions.virtualList;
312
289
  },
313
290
  // 绑定属性
314
291
  bindProps() {
315
292
  let obj = {
316
- size: this.size,
317
293
  clearable: true,
318
294
  ...this.$attrs,
319
295
  ...this.formatItemOptions
@@ -343,13 +319,10 @@ const _sfc_main = {
343
319
  formatItemOptions() {
344
320
  const that = this;
345
321
  return {
346
- size: this.size,
347
322
  ...this.itemOptions,
348
323
  ...this.$attrs,
349
- element: "el-select",
350
324
  virtualList: this.itemOptions.virtualList || this.virtualList,
351
325
  placeholder: this.itemOptions.placeholder || this.placeholder,
352
- filterable: this.itemOptions.filterable || this.filterable,
353
326
  multiple: this.itemOptions.multiple || this.multiple,
354
327
  options: this.optionsList,
355
328
  events: {
@@ -368,9 +341,6 @@ const _sfc_main = {
368
341
  } else {
369
342
  return [];
370
343
  }
371
- },
372
- maxLimitElWidth() {
373
- return this.isFitWidth ? this.width : null;
374
344
  }
375
345
  },
376
346
  watch: {
@@ -452,6 +422,8 @@ const _sfc_main = {
452
422
  this.itemOptions.events.change(event, this);
453
423
  } else {
454
424
  this.$emit("change", event);
425
+ this.$emit("input", event);
426
+ this.$emit("update:value", event);
455
427
  }
456
428
  },
457
429
  init() {
@@ -486,7 +458,11 @@ const _sfc_main = {
486
458
  });
487
459
  },
488
460
  // 搜索
489
- filterMethod(query) {
461
+ async filterMethod(query) {
462
+ const filterHandler = this.bindProps["filter-method"];
463
+ if (filterHandler) {
464
+ await filterHandler(query);
465
+ }
490
466
  if (query !== "") {
491
467
  this.$refs.virtualSelectList.scrollToIndex(0);
492
468
  let timer = setTimeout(() => {
@@ -526,6 +502,7 @@ const _sfc_main = {
526
502
  this.reset();
527
503
  this.init();
528
504
  }
505
+ this.$emit("visible-change", bool);
529
506
  }
530
507
  },
531
508
  beforeDestroy() {
@@ -544,18 +521,17 @@ var _sfc_render = function render2() {
544
521
  var _vm = this, _c = _vm._self._c;
545
522
  return _c("div", {
546
523
  staticClass: "nf-virtual-select"
547
- }, [_vm.isVirtualSelect ? [_c("el-select", _vm._g(_vm._b({
548
- staticClass: "nf-virtual-list-form-item-select",
549
- style: `width: ${_vm.width};`,
524
+ }, [_vm.isVirtualSelect ? _c("el-select", _vm._g(_vm._b({
525
+ ref: "nfVirtualSelect",
526
+ class: ["nf-virtual-select-el-select", _vm.bindProps["collapse-tags"] ? "nf-virtual-select-collapse-tags" : ""],
550
527
  attrs: {
551
- "popper-class": "nf-virtual-list-select",
552
- "disabled": _vm.$attrs.disabled,
553
- "filter-method": _vm.filterMethod,
554
- "filterable": ""
528
+ "popper-class": "nf-virtual-select-virtual-list-popper",
529
+ "filterable": "",
530
+ "filter-method": _vm.filterMethod
555
531
  },
556
532
  on: {
557
- "visible-change": _vm.visibleChange,
558
- "change": _vm.handleChange
533
+ "change": _vm.handleChange,
534
+ "visible-change": _vm.visibleChange
559
535
  },
560
536
  model: {
561
537
  value: _vm.currentVal,
@@ -564,10 +540,14 @@ var _sfc_render = function render2() {
564
540
  },
565
541
  expression: "currentVal"
566
542
  }
567
- }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_c("virtual-list", {
543
+ }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_vm._t("prefix", null, {
544
+ "slot": "prefix"
545
+ }), _vm._t("empty", null, {
546
+ "slot": "empty"
547
+ }), _c("virtual-list", {
568
548
  ref: "virtualSelectList",
569
549
  staticClass: "nf-virtual-select-list",
570
- style: `max-height: ${_vm.height};width: ${_vm.maxLimitElWidth}; overflow-y: auto;`,
550
+ style: `max-height: ${_vm.height};min-width: ${_vm.width};max-width: ${_vm.maxWidth};overflow-y: auto;`,
571
551
  attrs: {
572
552
  "offset": _vm.offset,
573
553
  "start": _vm.start,
@@ -589,12 +569,12 @@ var _sfc_render = function render2() {
589
569
  "footer-tag": _vm.footerTag,
590
570
  "footer-class": _vm.footerClass,
591
571
  "footer-style": _vm.footerStyle,
572
+ "extra-props": _vm.extraProps,
573
+ "data-component": _vm.itemComponent,
574
+ "data-sources": _vm.selectArr,
592
575
  "data-key": _vm.dataKey,
593
576
  "estimate-size": _vm.estimateSize,
594
- "data-sources": _vm.selectArr,
595
- "data-component": _vm.itemComponent,
596
- "keeps": _vm.keeps,
597
- "extra-props": _vm.extraProps
577
+ "keeps": _vm.keeps
598
578
  },
599
579
  on: {
600
580
  "scroll": _vm.scroll,
@@ -602,10 +582,15 @@ var _sfc_render = function render2() {
602
582
  "tobottom": _vm.tobottom,
603
583
  "resized": _vm.resized
604
584
  }
605
- })], 1)] : _vm.isSelect ? _c("el-select", _vm._g(_vm._b({
606
- style: `width: ${_vm.width};`,
585
+ }, [_vm._t("footer", null, {
586
+ "slot": "footer"
587
+ }), _vm._t("header", null, {
588
+ "slot": "header"
589
+ })], 2), _vm._t("default")], 2) : _c("el-select", _vm._g(_vm._b({
590
+ ref: "nfVirtualSelect",
591
+ staticClass: "nf-virtual-select-el-select",
607
592
  attrs: {
608
- "popper-class": "select-popper"
593
+ "popper-class": "nf-virtual-select-el-select-popper"
609
594
  },
610
595
  on: {
611
596
  "change": _vm.handleChange
@@ -617,7 +602,11 @@ var _sfc_render = function render2() {
617
602
  },
618
603
  expression: "currentVal"
619
604
  }
620
- }, "el-select", _vm.bindProps, false), _vm.bindEvents), _vm._l(_vm.selectArr, function(item, index) {
605
+ }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_vm._t("prefix", null, {
606
+ "slot": "prefix"
607
+ }), _vm._t("empty", null, {
608
+ "slot": "empty"
609
+ }), _vm._t("header"), _vm._l(_vm.selectArr, function(item, index) {
621
610
  return _c("el-option", {
622
611
  key: item[_vm.keyValue[0]] + "_" + index,
623
612
  attrs: {
@@ -625,15 +614,15 @@ var _sfc_render = function render2() {
625
614
  "value": item[_vm.keyValue[1]],
626
615
  "disabled": item.disabled
627
616
  }
628
- }, [_c("el-tooltip", {
617
+ }, [_vm.showTip ? _c("el-tooltip", {
629
618
  attrs: {
630
619
  "content": item[_vm.keyValue[0]],
631
620
  "open-delay": 1e3,
632
621
  "effect": "dark",
633
622
  "placement": "left"
634
623
  }
635
- }, [_c("span", [_vm._v(_vm._s(item[_vm.keyValue[0]]))])])], 1);
636
- }), 1) : _vm._e()], 2);
624
+ }, [_c("span", [_vm._v(_vm._s(item[_vm.keyValue[0]]))])]) : _c("span", [_vm._v(" " + _vm._s(item[_vm.keyValue[0]]) + " ")])], 1);
625
+ }), _vm._t("default"), _vm._t("footer")], 2)], 1);
637
626
  };
638
627
  var _sfc_staticRenderFns = [];
639
628
  var __component__ = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);