@94ai/nf-popup-lazy-select 3.2.72 → 3.2.75

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,9 +1,21 @@
1
- import { defineComponent, ref } from "vue-demi";
1
+ import { defineComponent, ref, computed } from "vue-demi";
2
2
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
3
  const __sfc_main = defineComponent({
4
4
  name: "nf-popup-lazy-select"
5
5
  });
6
6
  __sfc_main.props = {
7
+ popdownOnSelect: {
8
+ key: "popdownOnSelect",
9
+ required: false,
10
+ type: Boolean,
11
+ default: false
12
+ },
13
+ assignmentOnSelect: {
14
+ key: "assignmentOnSelect",
15
+ required: false,
16
+ type: Boolean,
17
+ default: true
18
+ },
7
19
  keywordAlias: {
8
20
  key: "keywordAlias",
9
21
  required: false,
@@ -94,12 +106,6 @@ __sfc_main.props = {
94
106
  type: Boolean,
95
107
  default: false
96
108
  },
97
- popperAppendToBody: {
98
- key: "popperAppendToBody",
99
- required: false,
100
- type: Boolean,
101
- default: true
102
- },
103
109
  placeholder: {
104
110
  key: "placeholder",
105
111
  required: false,
@@ -280,7 +286,7 @@ __sfc_main.props = {
280
286
  key: "width",
281
287
  required: false,
282
288
  type: String,
283
- default: "100%"
289
+ default: "calc(100% - 6px)"
284
290
  },
285
291
  height: {
286
292
  key: "height",
@@ -288,62 +294,73 @@ __sfc_main.props = {
288
294
  type: String,
289
295
  default: "245px"
290
296
  },
297
+ maxWidth: {
298
+ key: "maxWidth",
299
+ required: false,
300
+ type: String,
301
+ default: "calc(100% - 6px)"
302
+ },
291
303
  showTip: {
292
304
  key: "showTip",
293
305
  required: false,
294
306
  type: Boolean,
295
307
  default: false
296
308
  },
297
- lazySelectPopWidth: {
298
- key: "lazySelectPopWidth",
309
+ popupWidth: {
310
+ key: "popupWidth",
299
311
  required: false,
300
312
  type: [String, Number],
301
- default: "160"
313
+ default: "200"
302
314
  },
303
- lazySelectPopperClass: {
304
- key: "lazySelectPopperClass",
315
+ popupClass: {
316
+ key: "popupClass",
305
317
  required: false,
306
318
  type: String,
307
319
  default: ""
308
320
  },
309
- lazySelectPopDisabled: {
310
- key: "lazySelectPopDisabled",
321
+ popupTitle: {
322
+ key: "popupTitle",
323
+ required: false,
324
+ type: String
325
+ },
326
+ popupDisabled: {
327
+ key: "popupDisabled",
311
328
  required: false,
312
329
  type: Boolean,
313
330
  default: false
314
331
  },
315
- lazySelectPopOffset: {
316
- key: "lazySelectPopOffset",
332
+ popupOffset: {
333
+ key: "popupOffset",
317
334
  required: false,
318
335
  type: Number,
319
336
  default: 0
320
337
  },
321
- placement: {
322
- key: "placement",
338
+ popupPlacement: {
339
+ key: "popupPlacement",
323
340
  required: false,
324
341
  type: String,
325
342
  default: "bottom"
326
343
  },
327
- trigger: {
328
- key: "trigger",
344
+ popupTrigger: {
345
+ key: "popupTrigger",
329
346
  required: false,
330
347
  type: String,
331
348
  default: "click"
332
349
  },
333
- transition: {
334
- key: "transition",
350
+ popupTransition: {
351
+ key: "popupTransition",
335
352
  required: false,
336
353
  type: String,
337
354
  default: "fade-in-linear"
338
355
  },
339
- visibleArrow: {
340
- key: "visibleArrow",
356
+ popupVisibleArrow: {
357
+ key: "popupVisibleArrow",
341
358
  required: false,
342
359
  type: Boolean,
343
360
  default: true
344
361
  },
345
- popperOptions: {
346
- key: "popperOptions",
362
+ popupOptions: {
363
+ key: "popupOptions",
347
364
  required: false,
348
365
  type: Object,
349
366
  default: () => ({
@@ -351,20 +368,19 @@ __sfc_main.props = {
351
368
  gpuAcceleration: false
352
369
  })
353
370
  },
354
- openDelay: {
355
- key: "openDelay",
371
+ popupOpenDelay: {
372
+ key: "popupOpenDelay",
356
373
  required: false,
357
- type: Number,
358
- default: void 0
374
+ type: Number
359
375
  },
360
- closeDelay: {
361
- key: "closeDelay",
376
+ popupCloseDelay: {
377
+ key: "popupCloseDelay",
362
378
  required: false,
363
379
  type: Number,
364
380
  default: 200
365
381
  },
366
- tabindex: {
367
- key: "tabindex",
382
+ popupTabindex: {
383
+ key: "popupTabindex",
368
384
  required: false,
369
385
  type: Number,
370
386
  default: 0
@@ -374,46 +390,143 @@ __sfc_main.props = {
374
390
  required: false,
375
391
  type: String,
376
392
  default: "mini"
393
+ },
394
+ value: {
395
+ key: "value",
396
+ required: false,
397
+ type: [String, Number, Array],
398
+ default: void 0
377
399
  }
378
400
  };
379
401
  __sfc_main.setup = (__props, __ctx) => {
380
- const keyword = ref();
381
- return {
382
- keyword
402
+ const props = __props;
403
+ const emit = __ctx.emit;
404
+ const changeShow = () => {
405
+ var _a, _b, _c, _d, _e;
406
+ const visible = (_e = (_d = (_c = (_b = (_a = popLazySelectRef.value) == null ? void 0 : _a.$refs) == null ? void 0 : _b.nfLazySelect) == null ? void 0 : _c.$refs) == null ? void 0 : _d.nfVirtualSelect) == null ? void 0 : _e.visible;
407
+ if (popup.value && typeof visible === "boolean" && !visible) {
408
+ popLazySelectRef.value.$refs.nfLazySelect.$refs.nfVirtualSelect.toggleMenu();
409
+ }
410
+ emit("popup-show", popup.value);
411
+ };
412
+ const popLazySelectRef = ref();
413
+ const popup = ref(false);
414
+ const dataList = ref([]);
415
+ const dataMap = ref({});
416
+ const lockVisibleChange = ref(false);
417
+ const visibleChange = async (e) => {
418
+ if (lockVisibleChange.value) {
419
+ lockVisibleChange.value = false;
420
+ return "break";
421
+ }
422
+ emit("visible-change", e);
423
+ };
424
+ const fetchDataHandler = (e) => {
425
+ var _a;
426
+ (_a = e.originData) == null ? void 0 : _a.forEach((data) => {
427
+ if (!dataMap.value[data[props.valueAlias]]) {
428
+ dataMap.value[data[props.valueAlias]] = true;
429
+ dataList.value.push(data);
430
+ }
431
+ });
432
+ emit("fetch-data", {
433
+ allCachedList: dataList.value,
434
+ currentList: e.originData,
435
+ event: e
436
+ });
383
437
  };
438
+ const currentVal = computed({
439
+ get() {
440
+ return props.value;
441
+ },
442
+ set(val) {
443
+ const changeVal = (value) => {
444
+ emit("input", value);
445
+ emit("update:value", value);
446
+ emit("change", value);
447
+ };
448
+ const getValItem = () => {
449
+ if (props.multiple) {
450
+ return val == null ? void 0 : val.map((it) => dataList.value.find((item) => item[props.valueAlias] === it));
451
+ } else {
452
+ return val ? dataList.value.find((item) => item[props.valueAlias] === val) : val;
453
+ }
454
+ };
455
+ if (!props.multiple) {
456
+ if (props.popdownOnSelect) {
457
+ changeVal(void 0);
458
+ if (val) {
459
+ popup.value = false;
460
+ }
461
+ } else {
462
+ if (!props.assignmentOnSelect) {
463
+ changeVal(void 0);
464
+ } else {
465
+ changeVal(val);
466
+ }
467
+ }
468
+ if (val) {
469
+ lockVisibleChange.value = true;
470
+ }
471
+ } else {
472
+ changeVal(val);
473
+ }
474
+ emit("select-item", getValItem());
475
+ }
476
+ });
477
+ return Object.assign({
478
+ changeShow,
479
+ popLazySelectRef,
480
+ popup,
481
+ dataList,
482
+ visibleChange,
483
+ fetchDataHandler,
484
+ currentVal
485
+ }, {
486
+ currentVal,
487
+ dataMap,
488
+ dataList,
489
+ popup,
490
+ popLazySelectRef
491
+ });
384
492
  };
385
493
  var _sfc_render = function render() {
386
494
  var _vm = this, _c = _vm._self._c;
387
495
  _vm._self._setupProxy;
388
- return _c("div", {
389
- staticClass: "nf-popup-lazy-select"
390
- }, [_c("el-popover", {
496
+ return _c("el-popover", {
497
+ staticClass: "nf-popup-lazy-select",
391
498
  attrs: {
392
- "placement": _vm.placement,
393
- "width": _vm.lazySelectPopWidth,
394
- "trigger": _vm.trigger,
395
- "disabled": _vm.lazySelectPopDisabled,
396
- "popper-class": (_vm.lazySelectPopperClass || "") + " nf-popup-lazy-select-popover",
397
- "offset": _vm.lazySelectPopOffset,
398
- "transition": _vm.transition,
399
- "visible-arrow": _vm.visibleArrow,
400
- "popper-options": _vm.popperOptions,
401
- "open-delay": _vm.openDelay,
402
- "close-delay": _vm.closeDelay,
403
- "tabindex": _vm.tabindex
499
+ "width": _vm.popupWidth,
500
+ "disabled": _vm.popupDisabled,
501
+ "popper-class": (_vm.popupClass || "") + " nf-popup-lazy-select-popover",
502
+ "offset": _vm.popupOffset,
503
+ "title": _vm.popupTitle,
504
+ "trigger": _vm.popupTrigger,
505
+ "placement": _vm.popupPlacement,
506
+ "transition": _vm.popupTransition,
507
+ "visible-arrow": _vm.popupVisibleArrow,
508
+ "popper-options": _vm.popupOptions,
509
+ "open-delay": _vm.popupOpenDelay,
510
+ "close-delay": _vm.popupCloseDelay,
511
+ "tabindex": _vm.popupTabindex
404
512
  },
405
513
  on: {
406
- "after-enter": (e) => _vm.$emit("after-enter", e),
407
- "after-leave": (e) => _vm.$emit("after-leave", e),
408
- "hide": (e) => _vm.$emit("hide", e),
409
- "show": (e) => _vm.$emit("show", e)
410
- }
411
- }, [_c("span", {
412
- attrs: {
413
- "slot": "reference"
514
+ "after-enter": (e) => _vm.$emit("popup-after-enter", e),
515
+ "after-leave": (e) => _vm.$emit("popup-after-leave", e),
516
+ "hide": (e) => _vm.$emit("popup-hide", e),
517
+ "show": _vm.changeShow
414
518
  },
415
- slot: "reference"
416
- }, [_vm._t("default")], 2), _c("nf-virtual-select", _vm._b({
519
+ model: {
520
+ value: _vm.popup,
521
+ callback: function($$v) {
522
+ _vm.popup = $$v;
523
+ },
524
+ expression: "popup"
525
+ }
526
+ }, [_vm._t("default", null, {
527
+ "slot": "reference"
528
+ }), _c("nf-lazy-select", _vm._b({
529
+ ref: "popLazySelectRef",
417
530
  attrs: {
418
531
  "request": _vm.request,
419
532
  "page-size": _vm.pageSize,
@@ -431,7 +544,7 @@ var _sfc_render = function render() {
431
544
  "multiple": _vm.multiple,
432
545
  "reserve-keyword": _vm.reserveKeyword,
433
546
  "default-first-option": _vm.defaultFirstOption,
434
- "popper-append-to-body": _vm.popperAppendToBody,
547
+ "popper-append-to-body": false,
435
548
  "key-value": _vm.keyValue,
436
549
  "data-key": _vm.dataKey,
437
550
  "virtual-list": _vm.virtualList,
@@ -457,28 +570,47 @@ var _sfc_render = function render() {
457
570
  "footer-tag": _vm.footerTag,
458
571
  "footer-class": _vm.footerClass,
459
572
  "footer-style": _vm.footerStyle,
460
- "extra-props": _vm.extraProps
573
+ "extra-props": _vm.extraProps,
574
+ "size": _vm.size,
575
+ "showTip": _vm.showTip,
576
+ "width": _vm.width,
577
+ "max-width": _vm.maxWidth,
578
+ "height": _vm.dataList.length ? _vm.height : "0"
461
579
  },
462
580
  on: {
463
581
  "scroll": (e) => _vm.$emit("scroll", e),
464
582
  "totop": (e) => _vm.$emit("totop", e),
465
583
  "tobottom": (e) => _vm.$emit("tobottom", e),
466
584
  "resized": (e) => _vm.$emit("resized", e),
467
- "fetch-data": (e) => _vm.$emit(e),
468
585
  "remove-tag": (e) => _vm.$emit("remove-tag", e),
469
586
  "blur": (e) => _vm.$emit("blur", e),
470
- "focus": (e) => _vm.$emit("tobottom", e),
471
- "clear": (e) => _vm.$emit("tobottom", e),
472
- "visible-change": (e) => _vm.$emit("tobottom", e)
587
+ "focus": (e) => _vm.$emit("focus", e),
588
+ "clear": (e) => _vm.$emit("clear", e),
589
+ "visible-change": _vm.visibleChange,
590
+ "fetch-data": _vm.fetchDataHandler
473
591
  },
474
592
  model: {
475
- value: _vm.keyword,
593
+ value: _vm.currentVal,
476
594
  callback: function($$v) {
477
- _vm.keyword = $$v;
595
+ _vm.currentVal = $$v;
478
596
  },
479
- expression: "keyword"
597
+ expression: "currentVal"
480
598
  }
481
- }, "nf-virtual-select", _vm.$attrs, false))], 1)], 1);
599
+ }, "nf-lazy-select", _vm.$attrs, false), [!_vm.multiple ? _vm._t("prefix", function() {
600
+ return [_c("span", {
601
+ staticClass: "nf-input__prefix el-input__prefix"
602
+ }, [_c("i", {
603
+ staticClass: "el-icon-search"
604
+ })])];
605
+ }, {
606
+ "slot": "prefix"
607
+ }) : _vm._e(), _vm._t("header", null, {
608
+ "slot": "header"
609
+ }), _vm._t("empty", null, {
610
+ "slot": "empty"
611
+ }), _vm._t("loading", null, {
612
+ "slot": "loading"
613
+ })], 2)], 2);
482
614
  };
483
615
  var _sfc_staticRenderFns = [];
484
616
  var __component__ = /* @__PURE__ */ normalizeComponent(__sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);