@94ai/nf-virtual-select 8.3.23 → 10.0.0

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,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const commonUtils = require("@94ai/common-utils");
3
4
  const virtualList = require("vue-virtual-scroll-list");
4
5
  const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
5
6
  const lodashEs = require("lodash-es");
@@ -2181,7 +2182,7 @@ var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
2181
2182
  clearInterval(autoScrolls[layersOut].pid);
2182
2183
  if (vx != 0 || vy != 0) {
2183
2184
  scrollThisInstance = true;
2184
- autoScrolls[layersOut].pid = setInterval((function() {
2185
+ autoScrolls[layersOut].pid = setInterval(function() {
2185
2186
  if (isFallback && this.layer === 0) {
2186
2187
  Sortable.active._onTouchMove(touchEvt$1);
2187
2188
  }
@@ -2193,7 +2194,7 @@ var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
2193
2194
  }
2194
2195
  }
2195
2196
  scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2196
- }).bind({
2197
+ }.bind({
2197
2198
  layer: layersOut
2198
2199
  }), 24);
2199
2200
  }
@@ -2357,6 +2358,7 @@ var __component__$1 = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc
2357
2358
  const VirtualSelectContainer = __component__$1.exports;
2358
2359
  const _sfc_main = {
2359
2360
  name: "nf-virtual-select",
2361
+ mixins: [commonUtils.LocaleMixin],
2360
2362
  components: {
2361
2363
  "virtual-list": virtualList,
2362
2364
  "virtual-select-container": VirtualSelectContainer
@@ -2523,7 +2525,7 @@ const _sfc_main = {
2523
2525
  },
2524
2526
  placeholder: {
2525
2527
  type: String,
2526
- default: "请选择"
2528
+ default: void 0
2527
2529
  },
2528
2530
  multiple: {
2529
2531
  type: Boolean,
@@ -2537,7 +2539,7 @@ const _sfc_main = {
2537
2539
  /** 全部 文字(兼容国际化翻译) */
2538
2540
  selectAllText: {
2539
2541
  type: String,
2540
- default: "全部"
2542
+ default: void 0
2541
2543
  },
2542
2544
  width: {
2543
2545
  type: String,
@@ -2575,6 +2577,7 @@ const _sfc_main = {
2575
2577
  }
2576
2578
  },
2577
2579
  data() {
2580
+ var _a;
2578
2581
  const that = this;
2579
2582
  const ElOption = {
2580
2583
  props: {
@@ -2607,13 +2610,20 @@ const _sfc_main = {
2607
2610
  }
2608
2611
  };
2609
2612
  return {
2610
- itemComponent: this.dataComponent ?? ElOption,
2613
+ itemComponent: (_a = this.dataComponent) != null ? _a : ElOption,
2611
2614
  selectArr: [],
2612
2615
  keyword: ""
2613
2616
  // 当前搜索关键词
2614
2617
  };
2615
2618
  },
2616
2619
  computed: {
2620
+ localeText() {
2621
+ var _a, _b;
2622
+ return {
2623
+ placeholder: (_a = this.placeholder) != null ? _a : this.t("nf.common.placeholderSelect"),
2624
+ selectAllText: (_b = this.selectAllText) != null ? _b : this.t("nf.common.all")
2625
+ };
2626
+ },
2617
2627
  /** 当前条件是否符合关键词高亮 */
2618
2628
  isKeywordHighlight() {
2619
2629
  return this.bindProps.keywordHighlight && !!(this.bindProps.filterable || this.isVirtualSelect);
@@ -2687,7 +2697,7 @@ const _sfc_main = {
2687
2697
  // 绑定方法
2688
2698
  bindEvents() {
2689
2699
  const events = {
2690
- ...this.$listeners || {},
2700
+ ...this.$listeners,
2691
2701
  ...this.itemOptions.events
2692
2702
  };
2693
2703
  if (events == null ? void 0 : events.change) {
@@ -2702,7 +2712,7 @@ const _sfc_main = {
2702
2712
  if (events == null ? void 0 : events["visible-change"]) {
2703
2713
  delete events["visible-change"];
2704
2714
  }
2705
- return events || {};
2715
+ return events;
2706
2716
  },
2707
2717
  isVirtualSelect() {
2708
2718
  return this.virtualList || this.itemOptions.virtualList;
@@ -2714,7 +2724,7 @@ const _sfc_main = {
2714
2724
  return this.reserveKeyword || this.itemOptions.reserveKeyword;
2715
2725
  },
2716
2726
  placeholderDesc() {
2717
- return this.itemOptions.placeholder || this.placeholder;
2727
+ return this.itemOptions.placeholder || this.localeText.placeholder;
2718
2728
  },
2719
2729
  optionsList() {
2720
2730
  var _a;
@@ -2731,10 +2741,7 @@ const _sfc_main = {
2731
2741
  return (_b = (_a = this.$refs.nfVirtualSelectContainer) == null ? void 0 : _a.$refs) == null ? void 0 : _b.nfVirtualSelect;
2732
2742
  },
2733
2743
  matchedCount() {
2734
- const matchedNum = this.currentVal.filter((id) => {
2735
- var _a;
2736
- return (_a = this.selectArr) == null ? void 0 : _a.some((obj) => obj[this.keyValue[1]] === id);
2737
- }).length || 0;
2744
+ const matchedNum = this.currentVal.filter((id) => this.selectArr.some((obj) => obj[this.keyValue[1]] === id)).length;
2738
2745
  return matchedNum;
2739
2746
  }
2740
2747
  },
@@ -2821,15 +2828,17 @@ const _sfc_main = {
2821
2828
  }
2822
2829
  },
2823
2830
  init() {
2824
- var _a;
2825
2831
  if (this.isVirtualSelect) {
2826
- let selectArr = ((_a = this.optionsList) == null ? void 0 : _a.map((it) => ({
2827
- ...it,
2828
- [this.keyValue[0]]: it[this.keyValue[0]],
2829
- [this.keyValue[1]]: it[this.keyValue[1]],
2830
- [this.dataKey]: typeof it[this.keyValue[1]] === "boolean" ? `${it[this.keyValue[0]]}${it[this.keyValue[1]]}` : it[this.keyValue[1]],
2831
- disabled: it["disabled"] ?? false
2832
- }))) ?? [];
2832
+ let selectArr = this.optionsList.map((it) => {
2833
+ var _a;
2834
+ return {
2835
+ ...it,
2836
+ [this.keyValue[0]]: it[this.keyValue[0]],
2837
+ [this.keyValue[1]]: it[this.keyValue[1]],
2838
+ [this.dataKey]: typeof it[this.keyValue[1]] === "boolean" ? `${it[this.keyValue[0]]}${it[this.keyValue[1]]}` : it[this.keyValue[1]],
2839
+ disabled: (_a = it["disabled"]) != null ? _a : false
2840
+ };
2841
+ });
2833
2842
  if (this.currentVal && this.echoValueTop) {
2834
2843
  if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) {
2835
2844
  const multiple_elements = selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]]));
@@ -2851,16 +2860,19 @@ const _sfc_main = {
2851
2860
  }
2852
2861
  } else {
2853
2862
  let selectArr = [];
2854
- selectArr = (this.optionsList || []).map((it) => ({
2855
- ...it,
2856
- [this.keyValue[0]]: it[this.keyValue[0]],
2857
- [this.keyValue[1]]: it[this.keyValue[1]],
2858
- disabled: it["disabled"] ?? false
2859
- }));
2863
+ selectArr = this.optionsList.map((it) => {
2864
+ var _a;
2865
+ return {
2866
+ ...it,
2867
+ [this.keyValue[0]]: it[this.keyValue[0]],
2868
+ [this.keyValue[1]]: it[this.keyValue[1]],
2869
+ disabled: (_a = it["disabled"]) != null ? _a : false
2870
+ };
2871
+ });
2860
2872
  if (this.isKeywordHighlight) {
2861
2873
  if (this.keyword) {
2862
2874
  const queryLower = this.keyword.toLowerCase().trim();
2863
- const queryText = (this.keyword || "").replace(/\,/g, ",");
2875
+ const queryText = this.keyword.replace(/\,/g, ",");
2864
2876
  let querySet = null;
2865
2877
  if (queryText.includes(",")) {
2866
2878
  querySet = new Set(queryText.split(","));
@@ -2895,7 +2907,7 @@ const _sfc_main = {
2895
2907
  if (needReset)
2896
2908
  this.reset();
2897
2909
  const queryLower = query.toLowerCase().trim();
2898
- const queryText = (query || "").replace(/\,/g, ",");
2910
+ const queryText = query.replace(/\,/g, ",");
2899
2911
  let querySet = null;
2900
2912
  if (queryText.includes(",")) {
2901
2913
  querySet = new Set(queryText.split(","));
@@ -2918,7 +2930,7 @@ const _sfc_main = {
2918
2930
  const multiple_elements = selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]]));
2919
2931
  selectArr = [...multiple_elements, ...selectArr.filter((item) => !multiple_elements.includes(item))];
2920
2932
  }
2921
- this.selectArr = (selectArr || []).map((it) => {
2933
+ this.selectArr = selectArr.map((it) => {
2922
2934
  return {
2923
2935
  [this.keyValue[0]]: it[this.keyValue[0]],
2924
2936
  [this.keyValue[1]]: it[this.keyValue[1]],
@@ -2941,7 +2953,7 @@ const _sfc_main = {
2941
2953
  },
2942
2954
  async visibleChange(bool) {
2943
2955
  const events = {
2944
- ...this.$listeners || {},
2956
+ ...this.$listeners,
2945
2957
  ...this.itemOptions.events
2946
2958
  };
2947
2959
  const fn = events["visible-change"];
@@ -3087,7 +3099,7 @@ var _sfc_render = function render2() {
3087
3099
  on: {
3088
3100
  "change": _vm.toggleCheckAll
3089
3101
  }
3090
- }, [_vm._v(_vm._s(_vm.selectAllText) + " "), ((_f = _vm.selectArr) == null ? void 0 : _f.length) ? _c("span", [_vm._v("(" + _vm._s(`${_vm.matchedCount}/${(_g = _vm.selectArr) == null ? void 0 : _g.length}`) + ")")]) : _vm._e()])], 1) : _vm._e(), _vm._l(_vm.selectArr, function(item, index2) {
3102
+ }, [_vm._v(_vm._s(_vm.localeText.selectAllText) + " "), ((_f = _vm.selectArr) == null ? void 0 : _f.length) ? _c("span", [_vm._v("(" + _vm._s(`${_vm.matchedCount}/${(_g = _vm.selectArr) == null ? void 0 : _g.length}`) + ")")]) : _vm._e()])], 1) : _vm._e(), _vm._l(_vm.selectArr, function(item, index2) {
3091
3103
  return _c("el-option", {
3092
3104
  key: item[_vm.keyValue[0]] + "_" + index2,
3093
3105
  attrs: {
@@ -1,3 +1,4 @@
1
+ import { LocaleMixin } from "@94ai/common-utils";
1
2
  import virtualList from "vue-virtual-scroll-list";
2
3
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
4
  import { isEqual } from "lodash-es";
@@ -2179,7 +2180,7 @@ var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
2179
2180
  clearInterval(autoScrolls[layersOut].pid);
2180
2181
  if (vx != 0 || vy != 0) {
2181
2182
  scrollThisInstance = true;
2182
- autoScrolls[layersOut].pid = setInterval((function() {
2183
+ autoScrolls[layersOut].pid = setInterval(function() {
2183
2184
  if (isFallback && this.layer === 0) {
2184
2185
  Sortable.active._onTouchMove(touchEvt$1);
2185
2186
  }
@@ -2191,7 +2192,7 @@ var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
2191
2192
  }
2192
2193
  }
2193
2194
  scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2194
- }).bind({
2195
+ }.bind({
2195
2196
  layer: layersOut
2196
2197
  }), 24);
2197
2198
  }
@@ -2355,6 +2356,7 @@ var __component__$1 = /* @__PURE__ */ normalizeComponent(_sfc_main$1, _sfc_rende
2355
2356
  const VirtualSelectContainer = __component__$1.exports;
2356
2357
  const _sfc_main = {
2357
2358
  name: "nf-virtual-select",
2359
+ mixins: [LocaleMixin],
2358
2360
  components: {
2359
2361
  "virtual-list": virtualList,
2360
2362
  "virtual-select-container": VirtualSelectContainer
@@ -2521,7 +2523,7 @@ const _sfc_main = {
2521
2523
  },
2522
2524
  placeholder: {
2523
2525
  type: String,
2524
- default: "请选择"
2526
+ default: void 0
2525
2527
  },
2526
2528
  multiple: {
2527
2529
  type: Boolean,
@@ -2535,7 +2537,7 @@ const _sfc_main = {
2535
2537
  /** 全部 文字(兼容国际化翻译) */
2536
2538
  selectAllText: {
2537
2539
  type: String,
2538
- default: "全部"
2540
+ default: void 0
2539
2541
  },
2540
2542
  width: {
2541
2543
  type: String,
@@ -2573,6 +2575,7 @@ const _sfc_main = {
2573
2575
  }
2574
2576
  },
2575
2577
  data() {
2578
+ var _a;
2576
2579
  const that = this;
2577
2580
  const ElOption = {
2578
2581
  props: {
@@ -2605,13 +2608,20 @@ const _sfc_main = {
2605
2608
  }
2606
2609
  };
2607
2610
  return {
2608
- itemComponent: this.dataComponent ?? ElOption,
2611
+ itemComponent: (_a = this.dataComponent) != null ? _a : ElOption,
2609
2612
  selectArr: [],
2610
2613
  keyword: ""
2611
2614
  // 当前搜索关键词
2612
2615
  };
2613
2616
  },
2614
2617
  computed: {
2618
+ localeText() {
2619
+ var _a, _b;
2620
+ return {
2621
+ placeholder: (_a = this.placeholder) != null ? _a : this.t("nf.common.placeholderSelect"),
2622
+ selectAllText: (_b = this.selectAllText) != null ? _b : this.t("nf.common.all")
2623
+ };
2624
+ },
2615
2625
  /** 当前条件是否符合关键词高亮 */
2616
2626
  isKeywordHighlight() {
2617
2627
  return this.bindProps.keywordHighlight && !!(this.bindProps.filterable || this.isVirtualSelect);
@@ -2685,7 +2695,7 @@ const _sfc_main = {
2685
2695
  // 绑定方法
2686
2696
  bindEvents() {
2687
2697
  const events = {
2688
- ...this.$listeners || {},
2698
+ ...this.$listeners,
2689
2699
  ...this.itemOptions.events
2690
2700
  };
2691
2701
  if (events == null ? void 0 : events.change) {
@@ -2700,7 +2710,7 @@ const _sfc_main = {
2700
2710
  if (events == null ? void 0 : events["visible-change"]) {
2701
2711
  delete events["visible-change"];
2702
2712
  }
2703
- return events || {};
2713
+ return events;
2704
2714
  },
2705
2715
  isVirtualSelect() {
2706
2716
  return this.virtualList || this.itemOptions.virtualList;
@@ -2712,7 +2722,7 @@ const _sfc_main = {
2712
2722
  return this.reserveKeyword || this.itemOptions.reserveKeyword;
2713
2723
  },
2714
2724
  placeholderDesc() {
2715
- return this.itemOptions.placeholder || this.placeholder;
2725
+ return this.itemOptions.placeholder || this.localeText.placeholder;
2716
2726
  },
2717
2727
  optionsList() {
2718
2728
  var _a;
@@ -2729,10 +2739,7 @@ const _sfc_main = {
2729
2739
  return (_b = (_a = this.$refs.nfVirtualSelectContainer) == null ? void 0 : _a.$refs) == null ? void 0 : _b.nfVirtualSelect;
2730
2740
  },
2731
2741
  matchedCount() {
2732
- const matchedNum = this.currentVal.filter((id) => {
2733
- var _a;
2734
- return (_a = this.selectArr) == null ? void 0 : _a.some((obj) => obj[this.keyValue[1]] === id);
2735
- }).length || 0;
2742
+ const matchedNum = this.currentVal.filter((id) => this.selectArr.some((obj) => obj[this.keyValue[1]] === id)).length;
2736
2743
  return matchedNum;
2737
2744
  }
2738
2745
  },
@@ -2819,15 +2826,17 @@ const _sfc_main = {
2819
2826
  }
2820
2827
  },
2821
2828
  init() {
2822
- var _a;
2823
2829
  if (this.isVirtualSelect) {
2824
- let selectArr = ((_a = this.optionsList) == null ? void 0 : _a.map((it) => ({
2825
- ...it,
2826
- [this.keyValue[0]]: it[this.keyValue[0]],
2827
- [this.keyValue[1]]: it[this.keyValue[1]],
2828
- [this.dataKey]: typeof it[this.keyValue[1]] === "boolean" ? `${it[this.keyValue[0]]}${it[this.keyValue[1]]}` : it[this.keyValue[1]],
2829
- disabled: it["disabled"] ?? false
2830
- }))) ?? [];
2830
+ let selectArr = this.optionsList.map((it) => {
2831
+ var _a;
2832
+ return {
2833
+ ...it,
2834
+ [this.keyValue[0]]: it[this.keyValue[0]],
2835
+ [this.keyValue[1]]: it[this.keyValue[1]],
2836
+ [this.dataKey]: typeof it[this.keyValue[1]] === "boolean" ? `${it[this.keyValue[0]]}${it[this.keyValue[1]]}` : it[this.keyValue[1]],
2837
+ disabled: (_a = it["disabled"]) != null ? _a : false
2838
+ };
2839
+ });
2831
2840
  if (this.currentVal && this.echoValueTop) {
2832
2841
  if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) {
2833
2842
  const multiple_elements = selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]]));
@@ -2849,16 +2858,19 @@ const _sfc_main = {
2849
2858
  }
2850
2859
  } else {
2851
2860
  let selectArr = [];
2852
- selectArr = (this.optionsList || []).map((it) => ({
2853
- ...it,
2854
- [this.keyValue[0]]: it[this.keyValue[0]],
2855
- [this.keyValue[1]]: it[this.keyValue[1]],
2856
- disabled: it["disabled"] ?? false
2857
- }));
2861
+ selectArr = this.optionsList.map((it) => {
2862
+ var _a;
2863
+ return {
2864
+ ...it,
2865
+ [this.keyValue[0]]: it[this.keyValue[0]],
2866
+ [this.keyValue[1]]: it[this.keyValue[1]],
2867
+ disabled: (_a = it["disabled"]) != null ? _a : false
2868
+ };
2869
+ });
2858
2870
  if (this.isKeywordHighlight) {
2859
2871
  if (this.keyword) {
2860
2872
  const queryLower = this.keyword.toLowerCase().trim();
2861
- const queryText = (this.keyword || "").replace(/\,/g, ",");
2873
+ const queryText = this.keyword.replace(/\,/g, ",");
2862
2874
  let querySet = null;
2863
2875
  if (queryText.includes(",")) {
2864
2876
  querySet = new Set(queryText.split(","));
@@ -2893,7 +2905,7 @@ const _sfc_main = {
2893
2905
  if (needReset)
2894
2906
  this.reset();
2895
2907
  const queryLower = query.toLowerCase().trim();
2896
- const queryText = (query || "").replace(/\,/g, ",");
2908
+ const queryText = query.replace(/\,/g, ",");
2897
2909
  let querySet = null;
2898
2910
  if (queryText.includes(",")) {
2899
2911
  querySet = new Set(queryText.split(","));
@@ -2916,7 +2928,7 @@ const _sfc_main = {
2916
2928
  const multiple_elements = selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]]));
2917
2929
  selectArr = [...multiple_elements, ...selectArr.filter((item) => !multiple_elements.includes(item))];
2918
2930
  }
2919
- this.selectArr = (selectArr || []).map((it) => {
2931
+ this.selectArr = selectArr.map((it) => {
2920
2932
  return {
2921
2933
  [this.keyValue[0]]: it[this.keyValue[0]],
2922
2934
  [this.keyValue[1]]: it[this.keyValue[1]],
@@ -2939,7 +2951,7 @@ const _sfc_main = {
2939
2951
  },
2940
2952
  async visibleChange(bool) {
2941
2953
  const events = {
2942
- ...this.$listeners || {},
2954
+ ...this.$listeners,
2943
2955
  ...this.itemOptions.events
2944
2956
  };
2945
2957
  const fn = events["visible-change"];
@@ -3085,7 +3097,7 @@ var _sfc_render = function render2() {
3085
3097
  on: {
3086
3098
  "change": _vm.toggleCheckAll
3087
3099
  }
3088
- }, [_vm._v(_vm._s(_vm.selectAllText) + " "), ((_f = _vm.selectArr) == null ? void 0 : _f.length) ? _c("span", [_vm._v("(" + _vm._s(`${_vm.matchedCount}/${(_g = _vm.selectArr) == null ? void 0 : _g.length}`) + ")")]) : _vm._e()])], 1) : _vm._e(), _vm._l(_vm.selectArr, function(item, index2) {
3100
+ }, [_vm._v(_vm._s(_vm.localeText.selectAllText) + " "), ((_f = _vm.selectArr) == null ? void 0 : _f.length) ? _c("span", [_vm._v("(" + _vm._s(`${_vm.matchedCount}/${(_g = _vm.selectArr) == null ? void 0 : _g.length}`) + ")")]) : _vm._e()])], 1) : _vm._e(), _vm._l(_vm.selectArr, function(item, index2) {
3089
3101
  return _c("el-option", {
3090
3102
  key: item[_vm.keyValue[0]] + "_" + index2,
3091
3103
  attrs: {