@weitutech/by-components 1.2.0 → 1.2.1

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.
@@ -96015,8 +96015,8 @@ var ByCascaderPanel_component = normalizeComponent(
96015
96015
  )
96016
96016
 
96017
96017
  /* harmony default export */ var ByCascaderPanel = (ByCascaderPanel_component.exports);
96018
- ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/cascader-panel-pro/ByCascaderPanelPro.vue?vue&type=template&id=4bdb9820
96019
- var ByCascaderPanelProvue_type_template_id_4bdb9820_render = function render() {
96018
+ ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/cascader-panel-pro/ByCascaderPanelPro.vue?vue&type=template&id=804df886
96019
+ var ByCascaderPanelProvue_type_template_id_804df886_render = function render() {
96020
96020
  var _vm = this,
96021
96021
  _c = _vm._self._c;
96022
96022
  return _c('div', {
@@ -96154,7 +96154,8 @@ var ByCascaderPanelProvue_type_template_id_4bdb9820_render = function render() {
96154
96154
  },
96155
96155
  on: {
96156
96156
  "input": _vm.onMainPanelInput,
96157
- "change": _vm.handleValueChange
96157
+ "change": _vm.handleValueChange,
96158
+ "store-ready": _vm.schedulePanelSyncFromExternalValue
96158
96159
  }
96159
96160
  }) : _vm._e(), _vm.searchOptions.length > 0 ? _c('VirtualCascaderPanel', {
96160
96161
  directives: [{
@@ -96257,7 +96258,7 @@ var ByCascaderPanelProvue_type_template_id_4bdb9820_render = function render() {
96257
96258
  staticClass: "empty-state"
96258
96259
  }, [_vm._v("暂无选中项")])], 1)])])])]);
96259
96260
  };
96260
- var ByCascaderPanelProvue_type_template_id_4bdb9820_staticRenderFns = [];
96261
+ var ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns = [];
96261
96262
 
96262
96263
  ;// ./src/components/cascader-panel-pro/cascaderUtilsPro.js
96263
96264
 
@@ -97016,8 +97017,8 @@ class CascaderUtilsPro {
97016
97017
  return paths;
97017
97018
  }
97018
97019
  }
97019
- ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/cascader-panel-pro/VirtualCascaderPanel.vue?vue&type=template&id=23086f90
97020
- var VirtualCascaderPanelvue_type_template_id_23086f90_render = function render() {
97020
+ ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/cascader-panel-pro/VirtualCascaderPanel.vue?vue&type=template&id=05f77638
97021
+ var VirtualCascaderPanelvue_type_template_id_05f77638_render = function render() {
97021
97022
  var _vm = this,
97022
97023
  _c = _vm._self._c;
97023
97024
  return _c('div', {
@@ -97108,7 +97109,7 @@ var VirtualCascaderPanelvue_type_template_id_23086f90_render = function render()
97108
97109
  })], 1);
97109
97110
  }), 0);
97110
97111
  };
97111
- var VirtualCascaderPanelvue_type_template_id_23086f90_staticRenderFns = [];
97112
+ var VirtualCascaderPanelvue_type_template_id_05f77638_staticRenderFns = [];
97112
97113
 
97113
97114
  ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"8cd600e8-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/cascader-panel-pro/VirtualList.vue?vue&type=template&id=43cb1148
97114
97115
  var VirtualListvue_type_template_id_43cb1148_render = function render() {
@@ -97876,6 +97877,9 @@ class SelectionStatePro {
97876
97877
  }
97877
97878
  this.$nextTick(() => {
97878
97879
  this.syncHorizontalOverflow();
97880
+ if (!this.syncValueFromParent) {
97881
+ this.$emit('store-ready');
97882
+ }
97879
97883
  });
97880
97884
  },
97881
97885
  syncFromValue() {
@@ -98173,8 +98177,8 @@ class SelectionStatePro {
98173
98177
  ;
98174
98178
  var VirtualCascaderPanel_component = normalizeComponent(
98175
98179
  cascader_panel_pro_VirtualCascaderPanelvue_type_script_lang_js,
98176
- VirtualCascaderPanelvue_type_template_id_23086f90_render,
98177
- VirtualCascaderPanelvue_type_template_id_23086f90_staticRenderFns,
98180
+ VirtualCascaderPanelvue_type_template_id_05f77638_render,
98181
+ VirtualCascaderPanelvue_type_template_id_05f77638_staticRenderFns,
98178
98182
  false,
98179
98183
  null,
98180
98184
  null,
@@ -98335,7 +98339,8 @@ var VirtualCascaderPanel_component = normalizeComponent(
98335
98339
  compactPanelValue: [],
98336
98340
  // 紧凑模式下稳定的空 value 引用,避免 watch 误触发清空
98337
98341
  searchDebounceTimer: null,
98338
- searchLeafSetCache: null
98342
+ searchLeafSetCache: null,
98343
+ panelSyncTimer: null
98339
98344
  };
98340
98345
  },
98341
98346
  computed: {
@@ -98495,6 +98500,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
98495
98500
  clearTimeout(this.searchDebounceTimer);
98496
98501
  this.searchDebounceTimer = null;
98497
98502
  }
98503
+ this.clearPanelSyncTimer();
98498
98504
  },
98499
98505
  methods: {
98500
98506
  onMainPanelInput(value) {
@@ -98572,44 +98578,132 @@ var VirtualCascaderPanel_component = normalizeComponent(
98572
98578
  syncPanelFromExternalValue() {
98573
98579
  const panel = this.$refs.cascaderPanel;
98574
98580
  if (!panel || !panel.selection || !panel.store) {
98575
- return;
98581
+ return false;
98576
98582
  }
98577
- if (!Array.isArray(this.value) || this.value.length === 0) {
98583
+ if (!this.hasExternalValue()) {
98578
98584
  panel.clearCheckedNodes();
98579
98585
  this.selectedItems = [];
98580
98586
  this.selectedValues = [];
98581
- return;
98587
+ return true;
98582
98588
  }
98583
- const paths = this.resolveExternalValueToPaths();
98584
98589
  panel.selection.clear();
98585
- paths.forEach(path => {
98586
- const leafValue = path[path.length - 1];
98587
- if (panel.store.pathByLeafValue.has(leafValue)) {
98588
- panel.selection.selectedLeafSet.add(leafValue);
98589
- }
98590
- });
98590
+ this.applyExternalValueToPanelSelection(panel);
98591
98591
  panel.selection._reconcileAllRoots();
98592
98592
  panel.bumpSelectionView();
98593
98593
  this.applyPanelSelectionChange();
98594
98594
  this.expandPanelToExternalValue(panel);
98595
+ return true;
98596
+ },
98597
+ hasExternalValue() {
98598
+ const val = this.value;
98599
+ if (val == null || val === '') {
98600
+ return false;
98601
+ }
98602
+ if (Array.isArray(val)) {
98603
+ return val.length > 0;
98604
+ }
98605
+ return true;
98606
+ },
98607
+ applyExternalValueToPanelSelection(panel) {
98608
+ const {
98609
+ store,
98610
+ selection
98611
+ } = panel;
98612
+ const paths = this.resolveExternalValueToPaths();
98613
+ paths.forEach(path => {
98614
+ const leafValue = path[path.length - 1];
98615
+ if (store.pathByLeafValue.has(leafValue)) {
98616
+ selection.selectedLeafSet.add(leafValue);
98617
+ }
98618
+ });
98619
+
98620
+ // 直接按外部 value 再补一遍,避免 paths 解析遗漏(聚合父节点、异步 options 等)
98621
+ this.getExternalValueList().forEach(val => {
98622
+ if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(val, this.parentNodePrefix)) {
98623
+ const actualValue = CascaderUtilsPro.extractParentNodeValue(val, this.parentNodePrefix);
98624
+ const node = store.nodeByValue.get(actualValue);
98625
+ if (node && !node.isLeaf && !node.disabled) {
98626
+ node.descendantLeafValues.forEach(leaf => selection.selectedLeafSet.add(leaf));
98627
+ }
98628
+ return;
98629
+ }
98630
+ if (store.pathByLeafValue.has(val)) {
98631
+ selection.selectedLeafSet.add(val);
98632
+ return;
98633
+ }
98634
+ const node = store.nodeByValue.get(val);
98635
+ if (node && node.isLeaf && !node.disabled) {
98636
+ selection.selectedLeafSet.add(val);
98637
+ } else if (node && !node.isLeaf && !node.disabled) {
98638
+ node.descendantLeafValues.forEach(leaf => selection.selectedLeafSet.add(leaf));
98639
+ }
98640
+ });
98641
+ },
98642
+ getExternalValueList() {
98643
+ const val = this.value;
98644
+ if (val == null || val === '') {
98645
+ return [];
98646
+ }
98647
+ if (Array.isArray(val)) {
98648
+ if (val.length === 0) {
98649
+ return [];
98650
+ }
98651
+ if (Array.isArray(val[0])) {
98652
+ return val.map(path => path[path.length - 1]);
98653
+ }
98654
+ return val;
98655
+ }
98656
+ return [val];
98657
+ },
98658
+ clearPanelSyncTimer() {
98659
+ if (this.panelSyncTimer) {
98660
+ clearTimeout(this.panelSyncTimer);
98661
+ this.panelSyncTimer = null;
98662
+ }
98663
+ },
98664
+ schedulePanelSyncFromExternalValue(retry = 0) {
98665
+ this.clearPanelSyncTimer();
98666
+ this.$nextTick(() => {
98667
+ if (!this.hasExternalValue()) {
98668
+ const panel = this.$refs.cascaderPanel;
98669
+ if (panel && panel.selection) {
98670
+ panel.clearCheckedNodes();
98671
+ }
98672
+ this.selectedItems = [];
98673
+ this.selectedValues = [];
98674
+ return;
98675
+ }
98676
+ const synced = this.syncPanelFromExternalValue();
98677
+ if (!synced && retry < 20) {
98678
+ this.panelSyncTimer = setTimeout(() => {
98679
+ this.schedulePanelSyncFromExternalValue(retry + 1);
98680
+ }, 50);
98681
+ }
98682
+ });
98595
98683
  },
98596
98684
  resolveExternalValueToPaths() {
98597
- if (!Array.isArray(this.value) || this.value.length === 0) {
98685
+ const val = this.value;
98686
+ if (val == null || val === '') {
98598
98687
  return [];
98599
98688
  }
98600
- if (typeof this.value[0] === 'string' || typeof this.value[0] === 'number') {
98689
+ if (Array.isArray(val) && val.length > 0 && Array.isArray(val[0])) {
98690
+ return [...val];
98691
+ }
98692
+ const values = Array.isArray(val) ? val : [val];
98693
+ if (typeof values[0] === 'string' || typeof values[0] === 'number') {
98601
98694
  if (this.aggregationMode) {
98602
- return CascaderUtilsPro.processValuesWithParentNodes(this.value, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
98695
+ return CascaderUtilsPro.processValuesWithParentNodes(values, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
98603
98696
  }
98604
- return this.findPathsByValues(this.value);
98697
+ return this.findPathsByValues(values);
98605
98698
  }
98606
- return [...this.value];
98699
+ return Array.isArray(val) ? [...val] : [];
98607
98700
  },
98608
98701
  expandPanelToExternalValue(panel) {
98609
- if (!panel || !panel.store || !Array.isArray(this.value) || this.value.length === 0) {
98702
+ if (!panel || !panel.store || !this.hasExternalValue()) {
98610
98703
  return;
98611
98704
  }
98612
- const firstValue = this.value[0];
98705
+ const values = this.getExternalValueList();
98706
+ const firstValue = values[0];
98613
98707
  let pathValues = [];
98614
98708
  if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(firstValue, this.parentNodePrefix)) {
98615
98709
  const actualValue = CascaderUtilsPro.extractParentNodeValue(firstValue, this.parentNodePrefix);
@@ -98642,11 +98736,15 @@ var VirtualCascaderPanel_component = normalizeComponent(
98642
98736
  },
98643
98737
  // 处理 value 值
98644
98738
  processValue() {
98739
+ if (!this.hasExternalValue()) {
98740
+ this.selectedValues = [];
98741
+ this.selectedItems = [];
98742
+ this.schedulePanelSyncFromExternalValue();
98743
+ return;
98744
+ }
98645
98745
  if (this.useCompactSelection && this.isMultiple) {
98646
98746
  this.selectedValues = [];
98647
- this.$nextTick(() => {
98648
- this.syncPanelFromExternalValue();
98649
- });
98747
+ this.schedulePanelSyncFromExternalValue();
98650
98748
  return;
98651
98749
  }
98652
98750
  if (this.isMultiple) {
@@ -98688,27 +98786,14 @@ var VirtualCascaderPanel_component = normalizeComponent(
98688
98786
  this.selectedValues = [];
98689
98787
  }
98690
98788
  }
98691
- this.updateSelectedItems();
98692
-
98693
- // 单选模式下,确保级联面板正确显示选中状态
98694
- if (!this.isMultiple && this.selectedValues.length > 0) {
98695
- this.$nextTick(() => {
98696
- const panel = this.$refs.cascaderPanel;
98697
- if (panel) {
98698
- panel.syncCheckedValue();
98699
- this.updateSelectedItems();
98700
- }
98701
- });
98702
- }
98789
+ this.schedulePanelSyncFromExternalValue();
98703
98790
  },
98704
98791
  // 初始化选项数据
98705
98792
  initOptions() {
98706
98793
  this.filteredOptions = this.processOptions(this.options);
98707
98794
  this.countTotalItems();
98708
- if (this.isMultiple && Array.isArray(this.value) && this.value.length > 0 && (this.useCompactSelection || this.$refs.cascaderPanel)) {
98709
- this.$nextTick(() => {
98710
- this.syncPanelFromExternalValue();
98711
- });
98795
+ if (this.hasExternalValue()) {
98796
+ this.schedulePanelSyncFromExternalValue();
98712
98797
  } else {
98713
98798
  this.updateSelectedItems();
98714
98799
  }
@@ -99039,7 +99124,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
99039
99124
  this.selectedValues = [];
99040
99125
  }
99041
99126
  }
99042
- this.updateSelectedItems();
99127
+ this.schedulePanelSyncFromExternalValue();
99043
99128
  },
99044
99129
  // 根据values找到对应的路径
99045
99130
  findPathsByValues(values) {
@@ -99197,8 +99282,8 @@ var VirtualCascaderPanel_component = normalizeComponent(
99197
99282
  ;
99198
99283
  var ByCascaderPanelPro_component = normalizeComponent(
99199
99284
  cascader_panel_pro_ByCascaderPanelProvue_type_script_lang_js,
99200
- ByCascaderPanelProvue_type_template_id_4bdb9820_render,
99201
- ByCascaderPanelProvue_type_template_id_4bdb9820_staticRenderFns,
99285
+ ByCascaderPanelProvue_type_template_id_804df886_render,
99286
+ ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns,
99202
99287
  false,
99203
99288
  null,
99204
99289
  null,