@94ai/nf-virtual-select 100.1.44 → 100.1.46

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
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,
@@ -234,24 +231,6 @@ const _sfc_main = {
234
231
  height: {
235
232
  type: String,
236
233
  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
234
  }
256
235
  },
257
236
  data() {
@@ -269,11 +248,6 @@ const _sfc_main = {
269
248
  default() {
270
249
  return {};
271
250
  }
272
- },
273
- showTip: {
274
- // 提示
275
- type: Boolean,
276
- default: true
277
251
  }
278
252
  },
279
253
  render(h) {
@@ -281,7 +255,7 @@ const _sfc_main = {
281
255
  attrs: {
282
256
  label: that.keyValue[0],
283
257
  value: that.keyValue[1],
284
- showTip: this.showTip,
258
+ showTip: that.showTip,
285
259
  source: this.source,
286
260
  index: this.index
287
261
  }
@@ -300,18 +274,16 @@ const _sfc_main = {
300
274
  },
301
275
  set(v) {
302
276
  this.$emit("input", v);
277
+ this.$emit("change", v);
278
+ this.$emit("update:value", v);
303
279
  }
304
280
  },
305
- isSelect() {
306
- return Object.prototype.hasOwnProperty.call(this.itemOptions, "virtualList") && !this.itemOptions.virtualList || !this.virtualList;
307
- },
308
281
  isVirtualSelect() {
309
282
  return this.virtualList || this.itemOptions.virtualList;
310
283
  },
311
284
  // 绑定属性
312
285
  bindProps() {
313
286
  let obj = {
314
- size: this.size,
315
287
  clearable: true,
316
288
  ...this.$attrs,
317
289
  ...this.formatItemOptions
@@ -341,13 +313,10 @@ const _sfc_main = {
341
313
  formatItemOptions() {
342
314
  const that = this;
343
315
  return {
344
- size: this.size,
345
316
  ...this.itemOptions,
346
317
  ...this.$attrs,
347
- element: "el-select",
348
318
  virtualList: this.itemOptions.virtualList || this.virtualList,
349
319
  placeholder: this.itemOptions.placeholder || this.placeholder,
350
- filterable: this.itemOptions.filterable || this.filterable,
351
320
  multiple: this.itemOptions.multiple || this.multiple,
352
321
  options: this.optionsList,
353
322
  events: {
@@ -366,9 +335,6 @@ const _sfc_main = {
366
335
  } else {
367
336
  return [];
368
337
  }
369
- },
370
- maxLimitElWidth() {
371
- return this.isFitWidth ? this.width : null;
372
338
  }
373
339
  },
374
340
  watch: {
@@ -450,6 +416,8 @@ const _sfc_main = {
450
416
  this.itemOptions.events.change(event, this);
451
417
  } else {
452
418
  this.$emit("change", event);
419
+ this.$emit("input", event);
420
+ this.$emit("update:value", event);
453
421
  }
454
422
  },
455
423
  init() {
@@ -484,7 +452,11 @@ const _sfc_main = {
484
452
  });
485
453
  },
486
454
  // 搜索
487
- filterMethod(query) {
455
+ async filterMethod(query) {
456
+ const filterHandler = this.bindProps["filter-method"];
457
+ if (filterHandler) {
458
+ await filterHandler(query);
459
+ }
488
460
  if (query !== "") {
489
461
  this.$refs.virtualSelectList.scrollToIndex(0);
490
462
  let timer = setTimeout(() => {
@@ -524,6 +496,7 @@ const _sfc_main = {
524
496
  this.reset();
525
497
  this.init();
526
498
  }
499
+ this.$emit("visible-change", bool);
527
500
  }
528
501
  },
529
502
  beforeDestroy() {
@@ -542,18 +515,17 @@ var _sfc_render = function render2() {
542
515
  var _vm = this, _c = _vm._self._c;
543
516
  return _c("div", {
544
517
  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};`,
518
+ }, [_vm.isVirtualSelect ? _c("el-select", _vm._g(_vm._b({
519
+ ref: "nfVirtualSelect",
520
+ staticClass: "nf-virtual-select-el-select",
548
521
  attrs: {
549
- "popper-class": "nf-virtual-list-select",
550
- "disabled": _vm.$attrs.disabled,
551
- "filter-method": _vm.filterMethod,
552
- "filterable": ""
522
+ "popper-class": "nf-virtual-select-virtual-list-popper",
523
+ "filterable": "",
524
+ "filter-method": _vm.filterMethod
553
525
  },
554
526
  on: {
555
- "visible-change": _vm.visibleChange,
556
- "change": _vm.handleChange
527
+ "change": _vm.handleChange,
528
+ "visible-change": _vm.visibleChange
557
529
  },
558
530
  model: {
559
531
  value: _vm.currentVal,
@@ -562,10 +534,14 @@ var _sfc_render = function render2() {
562
534
  },
563
535
  expression: "currentVal"
564
536
  }
565
- }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_c("virtual-list", {
537
+ }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_vm._t("prefix", null, {
538
+ "slot": "prefix"
539
+ }), _vm._t("empty", null, {
540
+ "slot": "empty"
541
+ }), _c("virtual-list", {
566
542
  ref: "virtualSelectList",
567
543
  staticClass: "nf-virtual-select-list",
568
- style: `max-height: ${_vm.height};width: ${_vm.maxLimitElWidth}; overflow-y: auto;`,
544
+ style: `max-height: ${_vm.height};min-width: ${_vm.width}; overflow-y: auto;`,
569
545
  attrs: {
570
546
  "offset": _vm.offset,
571
547
  "start": _vm.start,
@@ -587,12 +563,12 @@ var _sfc_render = function render2() {
587
563
  "footer-tag": _vm.footerTag,
588
564
  "footer-class": _vm.footerClass,
589
565
  "footer-style": _vm.footerStyle,
566
+ "extra-props": _vm.extraProps,
567
+ "data-component": _vm.itemComponent,
568
+ "data-sources": _vm.selectArr,
590
569
  "data-key": _vm.dataKey,
591
570
  "estimate-size": _vm.estimateSize,
592
- "data-sources": _vm.selectArr,
593
- "data-component": _vm.itemComponent,
594
- "keeps": _vm.keeps,
595
- "extra-props": _vm.extraProps
571
+ "keeps": _vm.keeps
596
572
  },
597
573
  on: {
598
574
  "scroll": _vm.scroll,
@@ -600,10 +576,15 @@ var _sfc_render = function render2() {
600
576
  "tobottom": _vm.tobottom,
601
577
  "resized": _vm.resized
602
578
  }
603
- })], 1)] : _vm.isSelect ? _c("el-select", _vm._g(_vm._b({
604
- style: `width: ${_vm.width};`,
579
+ }, [_vm._t("footer", null, {
580
+ "slot": "footer"
581
+ }), _vm._t("header", null, {
582
+ "slot": "header"
583
+ })], 2), _vm._t("default")], 2) : _c("el-select", _vm._g(_vm._b({
584
+ ref: "nfVirtualSelect",
585
+ staticClass: "nf-virtual-select-el-select",
605
586
  attrs: {
606
- "popper-class": "select-popper"
587
+ "popper-class": "nf-virtual-select-el-select-popper"
607
588
  },
608
589
  on: {
609
590
  "change": _vm.handleChange
@@ -615,7 +596,11 @@ var _sfc_render = function render2() {
615
596
  },
616
597
  expression: "currentVal"
617
598
  }
618
- }, "el-select", _vm.bindProps, false), _vm.bindEvents), _vm._l(_vm.selectArr, function(item, index) {
599
+ }, "el-select", _vm.bindProps, false), _vm.bindEvents), [_vm._t("prefix", null, {
600
+ "slot": "prefix"
601
+ }), _vm._t("empty", null, {
602
+ "slot": "empty"
603
+ }), _vm._t("header"), _vm._l(_vm.selectArr, function(item, index) {
619
604
  return _c("el-option", {
620
605
  key: item[_vm.keyValue[0]] + "_" + index,
621
606
  attrs: {
@@ -623,15 +608,15 @@ var _sfc_render = function render2() {
623
608
  "value": item[_vm.keyValue[1]],
624
609
  "disabled": item.disabled
625
610
  }
626
- }, [_c("el-tooltip", {
611
+ }, [_vm.showTip ? _c("el-tooltip", {
627
612
  attrs: {
628
613
  "content": item[_vm.keyValue[0]],
629
614
  "open-delay": 1e3,
630
615
  "effect": "dark",
631
616
  "placement": "left"
632
617
  }
633
- }, [_c("span", [_vm._v(_vm._s(item[_vm.keyValue[0]]))])])], 1);
634
- }), 1) : _vm._e()], 2);
618
+ }, [_c("span", [_vm._v(_vm._s(item[_vm.keyValue[0]]))])]) : _c("span", [_vm._v(" " + _vm._s(item[_vm.keyValue[0]]) + " ")])], 1);
619
+ }), _vm._t("default"), _vm._t("footer")], 2)], 1);
635
620
  };
636
621
  var _sfc_staticRenderFns = [];
637
622
  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;
@@ -133,24 +143,6 @@ declare const _default: import("vue").DefineComponent<{
133
143
  type: StringConstructor;
134
144
  default: string;
135
145
  };
136
- isFitWidth: {
137
- type: BooleanConstructor;
138
- default: boolean;
139
- };
140
- dataComponent: {
141
- type: ObjectConstructor;
142
- };
143
- extraProps: {
144
- type: ObjectConstructor;
145
- default: () => {
146
- label: string;
147
- value: string;
148
- };
149
- };
150
- dataKey: {
151
- type: (StringConstructor | FunctionConstructor)[];
152
- default: string;
153
- };
154
146
  }, {}, {
155
147
  itemComponent: any;
156
148
  selectArr: never[];
@@ -159,13 +151,11 @@ declare const _default: import("vue").DefineComponent<{
159
151
  get(): any;
160
152
  set(v: any): void;
161
153
  };
162
- isSelect(): boolean;
163
154
  isVirtualSelect(): any;
164
155
  bindProps(): any;
165
156
  bindEvents(): any;
166
157
  formatItemOptions(): any;
167
158
  optionsList(): any;
168
- maxLimitElWidth(): any;
169
159
  }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
170
160
  offset: {
171
161
  type: NumberConstructor;
@@ -254,22 +244,32 @@ declare const _default: import("vue").DefineComponent<{
254
244
  type: NumberConstructor;
255
245
  default: number;
256
246
  };
247
+ extraProps: {
248
+ type: ObjectConstructor;
249
+ default: () => {
250
+ label: string;
251
+ value: string;
252
+ };
253
+ };
254
+ dataComponent: {
255
+ type: ObjectConstructor;
256
+ };
257
+ dataKey: {
258
+ type: (StringConstructor | FunctionConstructor)[];
259
+ default: string;
260
+ };
257
261
  value: {
258
262
  type: (NumberConstructor | StringConstructor | ArrayConstructor)[];
259
263
  default: () => "";
260
264
  };
261
- size: {
262
- type: StringConstructor;
263
- default: undefined;
265
+ showTip: {
266
+ type: BooleanConstructor;
267
+ default: boolean;
264
268
  };
265
269
  keyValue: {
266
270
  type: ArrayConstructor;
267
271
  default: () => string[];
268
272
  };
269
- placeholder: {
270
- type: StringConstructor;
271
- default: string;
272
- };
273
273
  itemOptions: {
274
274
  type: ObjectConstructor;
275
275
  default(): {
@@ -285,9 +285,9 @@ declare const _default: import("vue").DefineComponent<{
285
285
  type: ArrayConstructor;
286
286
  default: () => never[];
287
287
  };
288
- filterable: {
289
- type: BooleanConstructor;
290
- default: boolean;
288
+ placeholder: {
289
+ type: StringConstructor;
290
+ default: string;
291
291
  };
292
292
  multiple: {
293
293
  type: BooleanConstructor;
@@ -301,26 +301,9 @@ declare const _default: import("vue").DefineComponent<{
301
301
  type: StringConstructor;
302
302
  default: string;
303
303
  };
304
- isFitWidth: {
305
- type: BooleanConstructor;
306
- default: boolean;
307
- };
308
- dataComponent: {
309
- type: ObjectConstructor;
310
- };
311
- extraProps: {
312
- type: ObjectConstructor;
313
- default: () => {
314
- label: string;
315
- value: string;
316
- };
317
- };
318
- dataKey: {
319
- type: (StringConstructor | FunctionConstructor)[];
320
- default: string;
321
- };
322
304
  }>>, {
323
305
  value: string | number | unknown[];
306
+ showTip: boolean;
324
307
  placeholder: string;
325
308
  options: unknown[];
326
309
  offset: number;
@@ -344,16 +327,13 @@ declare const _default: import("vue").DefineComponent<{
344
327
  footerStyle: Record<string, any>;
345
328
  keeps: number;
346
329
  estimateSize: number;
347
- size: string;
330
+ extraProps: Record<string, any>;
331
+ dataKey: string | Function;
348
332
  keyValue: unknown[];
349
333
  itemOptions: Record<string, any>;
350
334
  virtualList: boolean;
351
- filterable: boolean;
352
335
  multiple: boolean;
353
336
  width: string;
354
337
  height: string;
355
- isFitWidth: boolean;
356
- extraProps: Record<string, any>;
357
- dataKey: string | Function;
358
338
  }>;
359
339
  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="1000" 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
  }