@94ai/nf-virtual-select 3.2.72 → 3.2.76

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.
@@ -3,6 +3,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  const virtualList = require("vue-virtual-scroll-list");
4
4
  const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
5
5
  const lodashEs = require("lodash-es");
6
+ const vueDemi = require("vue-demi");
6
7
  const _sfc_main$1 = {
7
8
  name: "ItemComponent",
8
9
  props: {
@@ -311,6 +312,7 @@ const _sfc_main = {
311
312
  },
312
313
  // 绑定方法
313
314
  bindEvents() {
315
+ var _a;
314
316
  const events = {
315
317
  ...this.$listeners || {},
316
318
  ...this.itemOptions.events
@@ -318,6 +320,9 @@ const _sfc_main = {
318
320
  if (events == null ? void 0 : events.change) {
319
321
  delete events.change;
320
322
  }
323
+ if ((events == null ? void 0 : events["visible-change"]) && (this.virtualList || ((_a = this.itemOptions) == null ? void 0 : _a.virtualList))) {
324
+ delete events["visible-change"];
325
+ }
321
326
  return events || {};
322
327
  },
323
328
  formatItemOptions() {
@@ -453,53 +458,61 @@ const _sfc_main = {
453
458
  },
454
459
  // 搜索
455
460
  async filterMethod(query) {
461
+ var _a, _b, _c;
456
462
  const filterHandler = this.bindProps["filter-method"];
457
463
  if (query !== "") {
458
464
  this.$refs.virtualSelectList.scrollToIndex(0);
459
- let timer = setTimeout(async () => {
460
- var _a, _b, _c;
461
- clearTimeout(timer);
462
- timer = null;
463
- if (filterHandler) {
464
- await filterHandler(query);
465
- } else {
466
- const arr = ((_b = (_a = this.itemOptions) == null ? void 0 : _a.options) == null ? void 0 : _b.length) ? this.itemOptions.options : ((_c = this.options) == null ? void 0 : _c.length) ? this.options : [];
467
- const selectArr = arr.filter((item) => {
468
- if (item[this.keyValue[0]]) {
469
- return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1;
470
- }
471
- });
472
- this.selectArr = (selectArr || []).map((it) => {
473
- return {
474
- [this.keyValue[0]]: it[this.keyValue[0]],
475
- [this.keyValue[1]]: it[this.keyValue[1]],
476
- [this.dataKey]: it[this.keyValue[1]],
477
- disabled: it["disabled"] ? it["disabled"] : false,
478
- slotContent: (it == null ? void 0 : it.slotContent) || {}
479
- };
480
- });
481
- }
482
- }, 100);
483
- this.$once("hook:beforeDestroy", () => {
484
- clearTimeout(timer);
485
- timer = null;
486
- });
487
- this.$once("hook:deactivated", () => {
488
- clearTimeout(timer);
489
- timer = null;
465
+ await vueDemi.nextTick();
466
+ await new Promise((resolve) => {
467
+ let timer = setTimeout(() => {
468
+ clearTimeout(timer);
469
+ timer = void 0;
470
+ resolve(true);
471
+ }, 30);
490
472
  });
473
+ if (filterHandler) {
474
+ await filterHandler(query);
475
+ } else {
476
+ const arr = ((_b = (_a = this.itemOptions) == null ? void 0 : _a.options) == null ? void 0 : _b.length) ? this.itemOptions.options : ((_c = this.options) == null ? void 0 : _c.length) ? this.options : [];
477
+ const selectArr = arr.filter((item) => {
478
+ if (item[this.keyValue[0]]) {
479
+ return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1;
480
+ }
481
+ });
482
+ this.selectArr = (selectArr || []).map((it) => {
483
+ return {
484
+ [this.keyValue[0]]: it[this.keyValue[0]],
485
+ [this.keyValue[1]]: it[this.keyValue[1]],
486
+ [this.dataKey]: it[this.keyValue[1]],
487
+ disabled: it["disabled"] ? it["disabled"] : false,
488
+ slotContent: (it == null ? void 0 : it.slotContent) || {}
489
+ };
490
+ });
491
+ }
491
492
  } else if (filterHandler) {
492
493
  await filterHandler(query);
493
494
  } else {
494
495
  this.init();
495
496
  }
496
497
  },
497
- visibleChange(bool) {
498
+ async visibleChange(bool) {
499
+ const events = {
500
+ ...this.$listeners || {},
501
+ ...this.itemOptions.events
502
+ };
503
+ if (events["visible-change"]) {
504
+ const go = await events["visible-change"](bool);
505
+ if (go === "break") {
506
+ return go;
507
+ }
508
+ }
498
509
  if (!bool) {
499
510
  this.reset();
500
511
  this.init();
501
512
  }
502
- this.$emit("visible-change", bool);
513
+ if (!events["visible-change"]) {
514
+ this.$emit("visible-change", bool);
515
+ }
503
516
  }
504
517
  },
505
518
  beforeDestroy() {
@@ -543,7 +556,7 @@ var _sfc_render = function render2() {
543
556
  }), _c("virtual-list", {
544
557
  ref: "virtualSelectList",
545
558
  staticClass: "nf-virtual-select-list",
546
- style: `max-height: ${_vm.height};min-width: ${_vm.width};max-width: ${_vm.maxWidth};overflow-y: auto;`,
559
+ style: `max-height: ${_vm.height};min-width: ${_vm.width};max-width: ${_vm.maxWidth};`,
547
560
  attrs: {
548
561
  "offset": _vm.offset,
549
562
  "start": _vm.start,
@@ -1,6 +1,7 @@
1
1
  import virtualList from "vue-virtual-scroll-list";
2
2
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
3
  import { isEqual } from "lodash-es";
4
+ import { nextTick } from "vue-demi";
4
5
  const _sfc_main$1 = {
5
6
  name: "ItemComponent",
6
7
  props: {
@@ -309,6 +310,7 @@ const _sfc_main = {
309
310
  },
310
311
  // 绑定方法
311
312
  bindEvents() {
313
+ var _a;
312
314
  const events = {
313
315
  ...this.$listeners || {},
314
316
  ...this.itemOptions.events
@@ -316,6 +318,9 @@ const _sfc_main = {
316
318
  if (events == null ? void 0 : events.change) {
317
319
  delete events.change;
318
320
  }
321
+ if ((events == null ? void 0 : events["visible-change"]) && (this.virtualList || ((_a = this.itemOptions) == null ? void 0 : _a.virtualList))) {
322
+ delete events["visible-change"];
323
+ }
319
324
  return events || {};
320
325
  },
321
326
  formatItemOptions() {
@@ -451,53 +456,61 @@ const _sfc_main = {
451
456
  },
452
457
  // 搜索
453
458
  async filterMethod(query) {
459
+ var _a, _b, _c;
454
460
  const filterHandler = this.bindProps["filter-method"];
455
461
  if (query !== "") {
456
462
  this.$refs.virtualSelectList.scrollToIndex(0);
457
- let timer = setTimeout(async () => {
458
- var _a, _b, _c;
459
- clearTimeout(timer);
460
- timer = null;
461
- if (filterHandler) {
462
- await filterHandler(query);
463
- } else {
464
- const arr = ((_b = (_a = this.itemOptions) == null ? void 0 : _a.options) == null ? void 0 : _b.length) ? this.itemOptions.options : ((_c = this.options) == null ? void 0 : _c.length) ? this.options : [];
465
- const selectArr = arr.filter((item) => {
466
- if (item[this.keyValue[0]]) {
467
- return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1;
468
- }
469
- });
470
- this.selectArr = (selectArr || []).map((it) => {
471
- return {
472
- [this.keyValue[0]]: it[this.keyValue[0]],
473
- [this.keyValue[1]]: it[this.keyValue[1]],
474
- [this.dataKey]: it[this.keyValue[1]],
475
- disabled: it["disabled"] ? it["disabled"] : false,
476
- slotContent: (it == null ? void 0 : it.slotContent) || {}
477
- };
478
- });
479
- }
480
- }, 100);
481
- this.$once("hook:beforeDestroy", () => {
482
- clearTimeout(timer);
483
- timer = null;
484
- });
485
- this.$once("hook:deactivated", () => {
486
- clearTimeout(timer);
487
- timer = null;
463
+ await nextTick();
464
+ await new Promise((resolve) => {
465
+ let timer = setTimeout(() => {
466
+ clearTimeout(timer);
467
+ timer = void 0;
468
+ resolve(true);
469
+ }, 30);
488
470
  });
471
+ if (filterHandler) {
472
+ await filterHandler(query);
473
+ } else {
474
+ const arr = ((_b = (_a = this.itemOptions) == null ? void 0 : _a.options) == null ? void 0 : _b.length) ? this.itemOptions.options : ((_c = this.options) == null ? void 0 : _c.length) ? this.options : [];
475
+ const selectArr = arr.filter((item) => {
476
+ if (item[this.keyValue[0]]) {
477
+ return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1;
478
+ }
479
+ });
480
+ this.selectArr = (selectArr || []).map((it) => {
481
+ return {
482
+ [this.keyValue[0]]: it[this.keyValue[0]],
483
+ [this.keyValue[1]]: it[this.keyValue[1]],
484
+ [this.dataKey]: it[this.keyValue[1]],
485
+ disabled: it["disabled"] ? it["disabled"] : false,
486
+ slotContent: (it == null ? void 0 : it.slotContent) || {}
487
+ };
488
+ });
489
+ }
489
490
  } else if (filterHandler) {
490
491
  await filterHandler(query);
491
492
  } else {
492
493
  this.init();
493
494
  }
494
495
  },
495
- visibleChange(bool) {
496
+ async visibleChange(bool) {
497
+ const events = {
498
+ ...this.$listeners || {},
499
+ ...this.itemOptions.events
500
+ };
501
+ if (events["visible-change"]) {
502
+ const go = await events["visible-change"](bool);
503
+ if (go === "break") {
504
+ return go;
505
+ }
506
+ }
496
507
  if (!bool) {
497
508
  this.reset();
498
509
  this.init();
499
510
  }
500
- this.$emit("visible-change", bool);
511
+ if (!events["visible-change"]) {
512
+ this.$emit("visible-change", bool);
513
+ }
501
514
  }
502
515
  },
503
516
  beforeDestroy() {
@@ -541,7 +554,7 @@ var _sfc_render = function render2() {
541
554
  }), _c("virtual-list", {
542
555
  ref: "virtualSelectList",
543
556
  staticClass: "nf-virtual-select-list",
544
- style: `max-height: ${_vm.height};min-width: ${_vm.width};max-width: ${_vm.maxWidth};overflow-y: auto;`,
557
+ style: `max-height: ${_vm.height};min-width: ${_vm.width};max-width: ${_vm.maxWidth};`,
545
558
  attrs: {
546
559
  "offset": _vm.offset,
547
560
  "start": _vm.start,
@@ -1,4 +1,4 @@
1
- declare const _default: import("vue").DefineComponent<{
1
+ declare const _default: import("vue-demi").DefineComponent<{
2
2
  offset: {
3
3
  type: NumberConstructor;
4
4
  default: number;
@@ -160,7 +160,7 @@ declare const _default: import("vue").DefineComponent<{
160
160
  bindEvents(): any;
161
161
  formatItemOptions(): any;
162
162
  optionsList(): any;
163
- }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<{
163
+ }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue-demi").ExtractPropTypes<{
164
164
  offset: {
165
165
  type: NumberConstructor;
166
166
  default: number;
@@ -47,7 +47,7 @@
47
47
  @totop="totop"
48
48
  @tobottom="tobottom"
49
49
  @resized="resized"
50
- :style="`max-height: ${height};min-width: ${width};max-width: ${maxWidth};overflow-y: auto;`"
50
+ :style="`max-height: ${height};min-width: ${width};max-width: ${maxWidth};`"
51
51
  >
52
52
  <slot slot="footer" name="footer" />
53
53
  <slot slot="header" name="header" />
@@ -94,6 +94,7 @@
94
94
  import virtualList from 'vue-virtual-scroll-list'
95
95
  import ElOptionNode from './el-option-node.vue'
96
96
  import { isEqual } from 'lodash-es'
97
+ import { nextTick } from 'vue-demi'
97
98
  export default {
98
99
  name: 'nf-virtual-select',
99
100
  components: { 'virtual-list': virtualList },
@@ -350,6 +351,9 @@ export default {
350
351
  if (events?.change) {
351
352
  delete events.change
352
353
  }
354
+ if (events?.['visible-change'] && (this.virtualList || this.itemOptions?.virtualList)) {
355
+ delete events['visible-change']
356
+ }
353
357
  return events || {}
354
358
  },
355
359
  formatItemOptions() {
@@ -491,49 +495,54 @@ export default {
491
495
  const filterHandler = this.bindProps['filter-method']
492
496
  if (query !== '') {
493
497
  this.$refs.virtualSelectList.scrollToIndex(0)// 滚动到顶部
494
- let timer = setTimeout(async () => {
495
- clearTimeout(timer)
496
- timer = null
497
- if (filterHandler) {
498
- await filterHandler(query)
499
- } else {
500
- const arr = this.itemOptions?.options?.length ? this.itemOptions.options : this.options?.length ? this.options : []
501
- const selectArr = arr.filter(item => {
502
- if (item[this.keyValue[0]]) {
503
- return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1
504
- }
505
- })
506
- this.selectArr = (selectArr || []).map(it => {
507
- return {
508
- [this.keyValue[0]]: it[this.keyValue[0]],
509
- [this.keyValue[1]]: it[this.keyValue[1]],
510
- [this.dataKey]: it[this.keyValue[1]],
511
- disabled: it['disabled'] ? it['disabled'] : false,
512
- slotContent: it?.slotContent || {}
513
- }
514
- })
515
- }
516
- }, 100)
517
- this.$once('hook:beforeDestroy', () => {
518
- clearTimeout(timer)
519
- timer = null
520
- })
521
- this.$once('hook:deactivated', () => {
522
- clearTimeout(timer)
523
- timer = null
498
+ await nextTick()
499
+ await new Promise((resolve) => {
500
+ let timer = setTimeout(() => {
501
+ clearTimeout(timer)
502
+ timer = undefined
503
+ resolve(true)
504
+ }, 30)
524
505
  })
506
+ if (filterHandler) {
507
+ await filterHandler(query)
508
+ } else {
509
+ const arr = this.itemOptions?.options?.length ? this.itemOptions.options : this.options?.length ? this.options : []
510
+ const selectArr = arr.filter(item => {
511
+ if (item[this.keyValue[0]]) {
512
+ return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1
513
+ }
514
+ })
515
+ this.selectArr = (selectArr || []).map(it => {
516
+ return {
517
+ [this.keyValue[0]]: it[this.keyValue[0]],
518
+ [this.keyValue[1]]: it[this.keyValue[1]],
519
+ [this.dataKey]: it[this.keyValue[1]],
520
+ disabled: it['disabled'] ? it['disabled'] : false,
521
+ slotContent: it?.slotContent || {}
522
+ }
523
+ })
524
+ }
525
525
  } else if (filterHandler) {
526
526
  await filterHandler(query)
527
527
  } else {
528
528
  this.init()
529
529
  }
530
530
  },
531
- visibleChange(bool) {
531
+ async visibleChange(bool) {
532
+ const events = { ...(this.$listeners || {}), ...this.itemOptions.events }
533
+ if (events['visible-change']) {
534
+ const go = await (events['visible-change'])(bool)
535
+ if (go === 'break') {
536
+ return go
537
+ }
538
+ }
532
539
  if (!bool) {
533
540
  this.reset()
534
541
  this.init()
535
542
  }
536
- this.$emit('visible-change', bool)
543
+ if (!events['visible-change']) {
544
+ this.$emit('visible-change', bool)
545
+ }
537
546
  }
538
547
  },
539
548
  beforeDestroy() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-virtual-select",
3
- "version": "3.2.72",
3
+ "version": "3.2.76",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "DESKTOP-1EDDQ79\\dev026 <liuxiangxiang@94ai.com>",
@@ -14,8 +14,8 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-utils": "^3.2.72",
18
- "@94ai/nf-theme-chalk": "^3.2.72",
17
+ "@94ai/common-utils": "^3.2.76",
18
+ "@94ai/nf-theme-chalk": "^3.2.76",
19
19
  "lodash-es": "^4.17.21",
20
20
  "vue-demi": "^0.14.5",
21
21
  "vue-virtual-scroll-list": "^2.3.5"
@@ -33,5 +33,5 @@
33
33
  "types": "lib/index.d.ts",
34
34
  "main": "lib/nf-virtual-select.cjs.js",
35
35
  "module": "lib/nf-virtual-select.esm-bundler.js",
36
- "gitHead": "92c79145b64d591457896ae871b4b553ab096422"
36
+ "gitHead": "07f6d8aca65e93849c2f70cf0b83fdf2ae2cc0f1"
37
37
  }