@weitutech/by-components 1.2.1 → 1.2.3

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=804df886
96019
- var ByCascaderPanelProvue_type_template_id_804df886_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=075d43fb
96019
+ var ByCascaderPanelProvue_type_template_id_075d43fb_render = function render() {
96020
96020
  var _vm = this,
96021
96021
  _c = _vm._self._c;
96022
96022
  return _c('div', {
@@ -96258,8 +96258,215 @@ var ByCascaderPanelProvue_type_template_id_804df886_render = function render() {
96258
96258
  staticClass: "empty-state"
96259
96259
  }, [_vm._v("暂无选中项")])], 1)])])])]);
96260
96260
  };
96261
- var ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns = [];
96261
+ var ByCascaderPanelProvue_type_template_id_075d43fb_staticRenderFns = [];
96262
96262
 
96263
+ ;// ./src/components/cascader-panel-pro/cascaderStorePro.js
96264
+
96265
+
96266
+
96267
+
96268
+
96269
+
96270
+ /**
96271
+ * 级联树扁平化存储,初始化时预计算子树叶子元数据,供 O(1) 级勾选/聚合
96272
+ */
96273
+
96274
+ let nodeIdSeed = 0;
96275
+ function nextId() {
96276
+ nodeIdSeed += 1;
96277
+ return nodeIdSeed;
96278
+ }
96279
+ function resetCascaderStoreIdSeed() {
96280
+ nodeIdSeed = 0;
96281
+ }
96282
+
96283
+ /**
96284
+ * @param {Array} options
96285
+ * @param {Object} config - disabledField/disabledValue/disabledCheck
96286
+ * @param {Object} cascaderProps
96287
+ * @param {Object} utils - CascaderUtilsPro
96288
+ */
96289
+ function buildCascaderStore(options, config, cascaderProps, utils) {
96290
+ resetCascaderStoreIdSeed();
96291
+ const valueKey = cascaderProps.value || 'value';
96292
+ const labelKey = cascaderProps.label || 'label';
96293
+ const childrenKey = cascaderProps.children || 'children';
96294
+ const disabledKey = cascaderProps.disabled || 'disabled';
96295
+ const nodes = [];
96296
+ const nodeById = new Map();
96297
+ const nodeByValue = new Map();
96298
+ const childrenByParentId = new Map();
96299
+ const rootIds = [];
96300
+ const pathByLeafValue = new Map();
96301
+ const allLeafValues = [];
96302
+ const allLeafPaths = [];
96303
+ const createNode = (raw, parentPath, level, parentId) => {
96304
+ const value = raw[valueKey];
96305
+ const children = raw[childrenKey];
96306
+ const hasChildren = Array.isArray(children) && children.length > 0;
96307
+ const id = nextId();
96308
+ const nodePath = parentId == null ? [value] : parentPath.concat(value);
96309
+ const node = {
96310
+ id,
96311
+ value,
96312
+ label: raw[labelKey],
96313
+ path: nodePath,
96314
+ level,
96315
+ parentId,
96316
+ childIds: [],
96317
+ isLeaf: !hasChildren,
96318
+ disabled: !!raw[disabledKey],
96319
+ raw,
96320
+ descendantLeafValues: [],
96321
+ descendantLeafCount: 0,
96322
+ descendantPaths: []
96323
+ };
96324
+ nodes.push(node);
96325
+ nodeById.set(id, node);
96326
+ if (!nodeByValue.has(value)) {
96327
+ nodeByValue.set(value, node);
96328
+ }
96329
+ if (parentId == null) {
96330
+ rootIds.push(id);
96331
+ } else {
96332
+ const siblings = childrenByParentId.get(parentId) || [];
96333
+ siblings.push(id);
96334
+ childrenByParentId.set(parentId, siblings);
96335
+ const parent = nodeById.get(parentId);
96336
+ if (parent) {
96337
+ parent.childIds.push(id);
96338
+ }
96339
+ }
96340
+ if (hasChildren) {
96341
+ children.forEach(child => {
96342
+ createNode(child, nodePath, level + 1, id);
96343
+ });
96344
+ } else {
96345
+ pathByLeafValue.set(value, nodePath);
96346
+ if (!node.disabled) {
96347
+ allLeafValues.push(value);
96348
+ allLeafPaths.push(nodePath);
96349
+ }
96350
+ }
96351
+ return node;
96352
+ };
96353
+ const walkRoots = (items, ancestorDisabled = false) => {
96354
+ items.forEach(item => {
96355
+ const isDisabled = ancestorDisabled || utils.isItemDisabled(item, config);
96356
+ const cloned = {
96357
+ ...item
96358
+ };
96359
+ if (isDisabled) {
96360
+ cloned[disabledKey] = true;
96361
+ }
96362
+ createNode(cloned, [], 0, null);
96363
+ });
96364
+ };
96365
+ walkRoots(options || []);
96366
+
96367
+ // 自底向上汇总子树叶子
96368
+ const sorted = nodes.slice().sort((a, b) => b.level - a.level);
96369
+ sorted.forEach(node => {
96370
+ if (node.isLeaf) {
96371
+ node.descendantLeafValues = [node.value];
96372
+ node.descendantLeafCount = 1;
96373
+ node.descendantPaths = [node.path];
96374
+ return;
96375
+ }
96376
+ const leafValues = [];
96377
+ const leafPaths = [];
96378
+ node.childIds.forEach(childId => {
96379
+ const child = nodeById.get(childId);
96380
+ if (!child || child.descendantLeafCount === 0) {
96381
+ return;
96382
+ }
96383
+ leafValues.push(...child.descendantLeafValues);
96384
+ leafPaths.push(...child.descendantPaths);
96385
+ });
96386
+ node.descendantLeafValues = leafValues;
96387
+ node.descendantLeafCount = leafValues.length;
96388
+ node.descendantPaths = leafPaths;
96389
+ });
96390
+ return {
96391
+ nodes,
96392
+ nodeById,
96393
+ nodeByValue,
96394
+ childrenByParentId,
96395
+ rootIds,
96396
+ pathByLeafValue,
96397
+ allLeafValues,
96398
+ allLeafPaths,
96399
+ totalLeafCount: allLeafPaths.length
96400
+ };
96401
+ }
96402
+ function getStoreChildren(store, parentId) {
96403
+ if (parentId == null) {
96404
+ return store.rootIds.map(id => store.nodeById.get(id)).filter(Boolean);
96405
+ }
96406
+ const childIds = store.childrenByParentId.get(parentId) || [];
96407
+ return childIds.map(id => store.nodeById.get(id)).filter(Boolean);
96408
+ }
96409
+ function resolveStoreNodeByValue(store, value) {
96410
+ if (!store || value == null || value === '') {
96411
+ return null;
96412
+ }
96413
+ if (store.nodeByValue.has(value)) {
96414
+ return store.nodeByValue.get(value);
96415
+ }
96416
+ const num = Number(value);
96417
+ if (!Number.isNaN(num) && store.nodeByValue.has(num)) {
96418
+ return store.nodeByValue.get(num);
96419
+ }
96420
+ const str = String(value);
96421
+ if (str !== value && store.nodeByValue.has(str)) {
96422
+ return store.nodeByValue.get(str);
96423
+ }
96424
+ for (const [key, node] of store.nodeByValue) {
96425
+ if (key == value) {
96426
+ return node;
96427
+ }
96428
+ }
96429
+ return null;
96430
+ }
96431
+ function getStoreLeafPath(store, leafValue) {
96432
+ if (!store || leafValue == null || leafValue === '') {
96433
+ return null;
96434
+ }
96435
+ if (store.pathByLeafValue.has(leafValue)) {
96436
+ return store.pathByLeafValue.get(leafValue);
96437
+ }
96438
+ const node = resolveStoreNodeByValue(store, leafValue);
96439
+ if (node && node.isLeaf) {
96440
+ return node.path;
96441
+ }
96442
+ for (const [key, path] of store.pathByLeafValue) {
96443
+ if (key == leafValue) {
96444
+ return path;
96445
+ }
96446
+ }
96447
+ return null;
96448
+ }
96449
+ function storeHasLeafValue(store, leafValue) {
96450
+ return getStoreLeafPath(store, leafValue) != null;
96451
+ }
96452
+ function findStoreNodeByPath(store, pathValues) {
96453
+ if (!pathValues || pathValues.length === 0) {
96454
+ return null;
96455
+ }
96456
+ let node = resolveStoreNodeByValue(store, pathValues[0]);
96457
+ if (!node || pathValues.length === 1) {
96458
+ return node;
96459
+ }
96460
+ for (let i = 1; i < pathValues.length; i++) {
96461
+ const target = pathValues[i];
96462
+ const children = getStoreChildren(store, node.id);
96463
+ node = children.find(child => child.value == target) || null;
96464
+ if (!node) {
96465
+ return null;
96466
+ }
96467
+ }
96468
+ return node;
96469
+ }
96263
96470
  ;// ./src/components/cascader-panel-pro/cascaderUtilsPro.js
96264
96471
 
96265
96472
 
@@ -96279,7 +96486,46 @@ var ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns = [];
96279
96486
  /**
96280
96487
  * 级联选择器工具类(Pro 版,独立于 CascaderUtils)
96281
96488
  */
96489
+
96282
96490
  class CascaderUtilsPro {
96491
+ static isTreeLeafNode(node, cascaderProps) {
96492
+ const childrenKey = cascaderProps && cascaderProps.children || 'children';
96493
+ const children = node[childrenKey];
96494
+ return !Array.isArray(children) || children.length === 0;
96495
+ }
96496
+
96497
+ /**
96498
+ * 将单个外部 value(含 __parent__ 前缀)同步到面板 selection
96499
+ */
96500
+ static addValueToSelection(store, selection, value, options, cascaderProps, prefix = '__parent__') {
96501
+ if (!store || !selection || value == null || value === '') {
96502
+ return;
96503
+ }
96504
+ const isParent = this.isParentNodeValue(value, prefix);
96505
+ const actualValue = isParent ? this.extractParentNodeValue(value, prefix) : value;
96506
+ const node = resolveStoreNodeByValue(store, actualValue);
96507
+ if (node) {
96508
+ if (node.isLeaf) {
96509
+ selection.selectedLeafSet.add(node.value);
96510
+ } else {
96511
+ node.descendantLeafValues.forEach(leaf => selection.selectedLeafSet.add(leaf));
96512
+ }
96513
+ return;
96514
+ }
96515
+ let paths = isParent ? this.getLeafPathsByParentValue(actualValue, options, cascaderProps) : this.findPathsByValues([actualValue], options, cascaderProps);
96516
+ if (paths.length === 0 && !isParent) {
96517
+ paths = this.getLeafPathsByParentValue(actualValue, options, cascaderProps);
96518
+ }
96519
+ paths.forEach(path => {
96520
+ const leafValue = path[path.length - 1];
96521
+ const leafPath = getStoreLeafPath(store, leafValue);
96522
+ if (leafPath) {
96523
+ selection.selectedLeafSet.add(leafPath[leafPath.length - 1]);
96524
+ } else {
96525
+ selection.selectedLeafSet.add(leafValue);
96526
+ }
96527
+ });
96528
+ }
96283
96529
  /**
96284
96530
  * 估算级联节点标签文本宽度(px)
96285
96531
  */
@@ -96542,16 +96788,13 @@ class CascaderUtilsPro {
96542
96788
 
96543
96789
  // 检查当前节点是否禁用
96544
96790
  const isCurrentDisabled = this.isItemDisabled(node, config);
96545
- if (!node[cascaderProps.children]) {
96791
+ if (this.isTreeLeafNode(node, cascaderProps)) {
96546
96792
  // 只包含非禁用项且路径上没有禁选项的叶子节点
96547
96793
  if (!isCurrentDisabled && !this.isPathDisabled(tree, newPath, config, cascaderProps)) {
96548
96794
  paths.push(newPath);
96549
96795
  }
96550
- } else {
96551
- // 如果当前节点禁用,则其所有子节点都不可选
96552
- if (!isCurrentDisabled) {
96553
- traverse(node[cascaderProps.children], newPath);
96554
- }
96796
+ } else if (!isCurrentDisabled) {
96797
+ traverse(node[cascaderProps.children], newPath);
96555
96798
  }
96556
96799
  });
96557
96800
  };
@@ -96621,14 +96864,14 @@ class CascaderUtilsPro {
96621
96864
  }
96622
96865
  const items = [];
96623
96866
  selection.selectedLeafSet.forEach(leafValue => {
96624
- const path = store.pathByLeafValue.get(leafValue);
96625
- const node = store.nodeByValue.get(leafValue);
96867
+ const path = getStoreLeafPath(store, leafValue);
96868
+ const node = resolveStoreNodeByValue(store, leafValue);
96626
96869
  if (!path || !node) {
96627
96870
  return;
96628
96871
  }
96629
96872
  items.push({
96630
96873
  ...node.raw,
96631
- value: leafValue,
96874
+ value: node.value,
96632
96875
  label: node.label,
96633
96876
  path
96634
96877
  });
@@ -96752,7 +96995,7 @@ class CascaderUtilsPro {
96752
96995
  const items = [];
96753
96996
  const walk = nodeId => {
96754
96997
  const node = store.nodeById.get(nodeId);
96755
- if (!node || node.disabled) {
96998
+ if (!node) {
96756
96999
  return;
96757
97000
  }
96758
97001
  const state = selection.getCheckState(nodeId);
@@ -96941,12 +97184,14 @@ class CascaderUtilsPro {
96941
97184
  for (const node of nodes) {
96942
97185
  const newPath = [...currentPath, node[cascaderProps.value]];
96943
97186
  if (node[cascaderProps.value] == parentValue) {
96944
- // 找到目标非叶子节点,获取其所有叶子节点路径
96945
- this.getAllLeafPaths([node], {}, cascaderProps).forEach(leafPath => {
96946
- // 将叶子节点路径与当前路径合并
96947
- const fullPath = [...currentPath, ...leafPath];
96948
- paths.push(fullPath);
96949
- });
97187
+ if (this.isTreeLeafNode(node, cascaderProps)) {
97188
+ paths.push(newPath);
97189
+ } else {
97190
+ this.getAllLeafPaths([node], {}, cascaderProps).forEach(leafPath => {
97191
+ const fullPath = [...currentPath, ...leafPath];
97192
+ paths.push(fullPath);
97193
+ });
97194
+ }
96950
97195
  return true;
96951
97196
  }
96952
97197
 
@@ -96980,8 +97225,10 @@ class CascaderUtilsPro {
96980
97225
  const leafPaths = this.getLeafPathsByParentValue(actualValue, options, cascaderProps);
96981
97226
  paths.push(...leafPaths);
96982
97227
  } else {
96983
- // 普通值,查找对应的路径
96984
- const valuePaths = this.findPathsByValues([value], options, cascaderProps);
97228
+ let valuePaths = this.findPathsByValues([value], options, cascaderProps);
97229
+ if (valuePaths.length === 0) {
97230
+ valuePaths = this.getLeafPathsByParentValue(value, options, cascaderProps);
97231
+ }
96985
97232
  paths.push(...valuePaths);
96986
97233
  }
96987
97234
  }
@@ -97000,15 +97247,10 @@ class CascaderUtilsPro {
97000
97247
  const findPath = (nodes, targetValues, currentPath = []) => {
97001
97248
  for (const option of nodes) {
97002
97249
  const newPath = [...currentPath, option[cascaderProps.value]];
97003
- if (targetValues.includes(option[cascaderProps.value])) {
97004
- // 如果是叶子节点(没有children属性),添加到路径中
97005
- if (!option[cascaderProps.children]) {
97006
- paths.push(newPath);
97007
- }
97250
+ if (targetValues.some(target => target == option[cascaderProps.value]) && this.isTreeLeafNode(option, cascaderProps)) {
97251
+ paths.push(newPath);
97008
97252
  }
97009
-
97010
- // 递归查找子节点
97011
- if (option[cascaderProps.children] && option[cascaderProps.children].length > 0) {
97253
+ if (!this.isTreeLeafNode(option, cascaderProps)) {
97012
97254
  findPath(option[cascaderProps.children], targetValues, newPath);
97013
97255
  }
97014
97256
  }
@@ -97265,170 +97507,6 @@ var VirtualList_component = normalizeComponent(
97265
97507
  )
97266
97508
 
97267
97509
  /* harmony default export */ var VirtualList = (VirtualList_component.exports);
97268
- ;// ./src/components/cascader-panel-pro/cascaderStorePro.js
97269
-
97270
-
97271
-
97272
-
97273
-
97274
-
97275
- /**
97276
- * 级联树扁平化存储,初始化时预计算子树叶子元数据,供 O(1) 级勾选/聚合
97277
- */
97278
-
97279
- let nodeIdSeed = 0;
97280
- function nextId() {
97281
- nodeIdSeed += 1;
97282
- return nodeIdSeed;
97283
- }
97284
- function resetCascaderStoreIdSeed() {
97285
- nodeIdSeed = 0;
97286
- }
97287
-
97288
- /**
97289
- * @param {Array} options
97290
- * @param {Object} config - disabledField/disabledValue/disabledCheck
97291
- * @param {Object} cascaderProps
97292
- * @param {Object} utils - CascaderUtilsPro
97293
- */
97294
- function buildCascaderStore(options, config, cascaderProps, utils) {
97295
- resetCascaderStoreIdSeed();
97296
- const valueKey = cascaderProps.value || 'value';
97297
- const labelKey = cascaderProps.label || 'label';
97298
- const childrenKey = cascaderProps.children || 'children';
97299
- const disabledKey = cascaderProps.disabled || 'disabled';
97300
- const nodes = [];
97301
- const nodeById = new Map();
97302
- const nodeByValue = new Map();
97303
- const childrenByParentId = new Map();
97304
- const rootIds = [];
97305
- const pathByLeafValue = new Map();
97306
- const allLeafValues = [];
97307
- const allLeafPaths = [];
97308
- const createNode = (raw, parentPath, level, parentId) => {
97309
- const value = raw[valueKey];
97310
- const children = raw[childrenKey];
97311
- const hasChildren = Array.isArray(children) && children.length > 0;
97312
- const id = nextId();
97313
- const nodePath = parentId == null ? [value] : parentPath.concat(value);
97314
- const node = {
97315
- id,
97316
- value,
97317
- label: raw[labelKey],
97318
- path: nodePath,
97319
- level,
97320
- parentId,
97321
- childIds: [],
97322
- isLeaf: !hasChildren,
97323
- disabled: !!raw[disabledKey],
97324
- raw,
97325
- descendantLeafValues: [],
97326
- descendantLeafCount: 0,
97327
- descendantPaths: []
97328
- };
97329
- nodes.push(node);
97330
- nodeById.set(id, node);
97331
- if (!nodeByValue.has(value)) {
97332
- nodeByValue.set(value, node);
97333
- }
97334
- if (parentId == null) {
97335
- rootIds.push(id);
97336
- } else {
97337
- const siblings = childrenByParentId.get(parentId) || [];
97338
- siblings.push(id);
97339
- childrenByParentId.set(parentId, siblings);
97340
- const parent = nodeById.get(parentId);
97341
- if (parent) {
97342
- parent.childIds.push(id);
97343
- }
97344
- }
97345
- if (hasChildren) {
97346
- children.forEach(child => {
97347
- createNode(child, nodePath, level + 1, id);
97348
- });
97349
- } else if (!node.disabled) {
97350
- pathByLeafValue.set(value, nodePath);
97351
- allLeafValues.push(value);
97352
- allLeafPaths.push(nodePath);
97353
- }
97354
- return node;
97355
- };
97356
- const walkRoots = (items, ancestorDisabled = false) => {
97357
- items.forEach(item => {
97358
- const isDisabled = ancestorDisabled || utils.isItemDisabled(item, config);
97359
- const cloned = {
97360
- ...item
97361
- };
97362
- if (isDisabled) {
97363
- cloned[disabledKey] = true;
97364
- }
97365
- createNode(cloned, [], 0, null);
97366
- });
97367
- };
97368
- walkRoots(options || []);
97369
-
97370
- // 自底向上汇总子树叶子
97371
- const sorted = nodes.slice().sort((a, b) => b.level - a.level);
97372
- sorted.forEach(node => {
97373
- if (node.isLeaf) {
97374
- if (!node.disabled) {
97375
- node.descendantLeafValues = [node.value];
97376
- node.descendantLeafCount = 1;
97377
- node.descendantPaths = [node.path];
97378
- }
97379
- return;
97380
- }
97381
- const leafValues = [];
97382
- const leafPaths = [];
97383
- node.childIds.forEach(childId => {
97384
- const child = nodeById.get(childId);
97385
- if (!child || child.descendantLeafCount === 0) {
97386
- return;
97387
- }
97388
- leafValues.push(...child.descendantLeafValues);
97389
- leafPaths.push(...child.descendantPaths);
97390
- });
97391
- node.descendantLeafValues = leafValues;
97392
- node.descendantLeafCount = leafValues.length;
97393
- node.descendantPaths = leafPaths;
97394
- });
97395
- return {
97396
- nodes,
97397
- nodeById,
97398
- nodeByValue,
97399
- childrenByParentId,
97400
- rootIds,
97401
- pathByLeafValue,
97402
- allLeafValues,
97403
- allLeafPaths,
97404
- totalLeafCount: allLeafPaths.length
97405
- };
97406
- }
97407
- function getStoreChildren(store, parentId) {
97408
- if (parentId == null) {
97409
- return store.rootIds.map(id => store.nodeById.get(id)).filter(Boolean);
97410
- }
97411
- const childIds = store.childrenByParentId.get(parentId) || [];
97412
- return childIds.map(id => store.nodeById.get(id)).filter(Boolean);
97413
- }
97414
- function findStoreNodeByPath(store, pathValues) {
97415
- if (!pathValues || pathValues.length === 0) {
97416
- return null;
97417
- }
97418
- let node = store.nodeByValue.get(pathValues[0]);
97419
- if (!node || pathValues.length === 1) {
97420
- return node;
97421
- }
97422
- for (let i = 1; i < pathValues.length; i++) {
97423
- const target = pathValues[i];
97424
- const children = getStoreChildren(store, node.id);
97425
- node = children.find(child => child.value == target) || null;
97426
- if (!node) {
97427
- return null;
97428
- }
97429
- }
97430
- return node;
97431
- }
97432
97510
  ;// ./src/components/cascader-panel-pro/selectionStatePro.js
97433
97511
 
97434
97512
 
@@ -97440,6 +97518,7 @@ function findStoreNodeByPath(store, pathValues) {
97440
97518
 
97441
97519
 
97442
97520
 
97521
+
97443
97522
  const COMPACT_EMIT_THRESHOLD = 300;
97444
97523
 
97445
97524
  class SelectionStatePro {
@@ -97604,32 +97683,40 @@ class SelectionStatePro {
97604
97683
  return;
97605
97684
  }
97606
97685
  const leafValue = path[path.length - 1];
97607
- if (this.store.pathByLeafValue.has(leafValue)) {
97608
- this.selectedLeafSet.add(leafValue);
97686
+ const leafPath = getStoreLeafPath(this.store, leafValue);
97687
+ if (leafPath) {
97688
+ this.selectedLeafSet.add(leafPath[leafPath.length - 1]);
97609
97689
  }
97610
97690
  });
97611
97691
  this._reconcileAllRoots();
97612
97692
  }
97613
97693
  getCheckState(nodeId) {
97614
97694
  const node = this.store.nodeById.get(nodeId);
97615
- if (!node || node.disabled) {
97695
+ if (!node) {
97616
97696
  return 'disabled';
97617
97697
  }
97698
+ let selectionState;
97618
97699
  if (node.isLeaf) {
97619
- return this.selectedLeafSet.has(node.value) ? 'checked' : 'unchecked';
97620
- }
97621
- const total = node.descendantLeafCount;
97622
- if (total === 0) {
97623
- return 'unchecked';
97624
- }
97625
- const selected = this.subtreeSelectedCount.get(node.id) || 0;
97626
- if (selected === 0) {
97627
- return 'unchecked';
97700
+ selectionState = this.selectedLeafSet.has(node.value) ? 'checked' : 'unchecked';
97701
+ } else {
97702
+ const total = node.descendantLeafCount;
97703
+ if (total === 0) {
97704
+ selectionState = 'unchecked';
97705
+ } else {
97706
+ const selected = this.subtreeSelectedCount.get(node.id) || 0;
97707
+ if (selected === 0) {
97708
+ selectionState = 'unchecked';
97709
+ } else if (selected >= total) {
97710
+ selectionState = 'checked';
97711
+ } else {
97712
+ selectionState = 'indeterminate';
97713
+ }
97714
+ }
97628
97715
  }
97629
- if (selected >= total) {
97630
- return 'checked';
97716
+ if (node.disabled && selectionState === 'unchecked') {
97717
+ return 'disabled';
97631
97718
  }
97632
- return 'indeterminate';
97719
+ return selectionState;
97633
97720
  }
97634
97721
  isChecked(nodeId) {
97635
97722
  return this.getCheckState(nodeId) === 'checked';
@@ -97675,9 +97762,13 @@ class SelectionStatePro {
97675
97762
  if (typeof val === 'string' && val.startsWith(prefix)) {
97676
97763
  rootValue = val.substring(prefix.length);
97677
97764
  }
97678
- const node = this.store.nodeByValue.get(rootValue);
97679
- if (node && !node.isLeaf && !node.disabled) {
97680
- node.descendantLeafValues.forEach(v => this.selectedLeafSet.add(v));
97765
+ const node = resolveStoreNodeByValue(this.store, rootValue);
97766
+ if (node) {
97767
+ if (node.isLeaf) {
97768
+ this.selectedLeafSet.add(node.value);
97769
+ } else {
97770
+ node.descendantLeafValues.forEach(v => this.selectedLeafSet.add(v));
97771
+ }
97681
97772
  }
97682
97773
  });
97683
97774
  this._reconcileAllRoots();
@@ -98205,6 +98296,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
98205
98296
 
98206
98297
 
98207
98298
 
98299
+
98208
98300
  /* harmony default export */ var ByCascaderPanelProvue_type_script_lang_js = ({
98209
98301
  name: 'ByCascaderPanelPro',
98210
98302
  components: {
@@ -98513,7 +98605,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
98513
98605
  this.selectedValues = value && value.length ? [value] : [];
98514
98606
  }
98515
98607
  },
98516
- applyPanelSelectionChange() {
98608
+ refreshSelectionDisplayFromPanel() {
98517
98609
  const panel = this.$refs.cascaderPanel;
98518
98610
  if (!panel || !panel.store || !panel.selection) {
98519
98611
  return;
@@ -98523,36 +98615,65 @@ var VirtualCascaderPanel_component = normalizeComponent(
98523
98615
  selection
98524
98616
  } = panel;
98525
98617
  if (this.aggregationMode) {
98526
- const items = CascaderUtilsPro.getAggregatedItemsFromSelection(store, selection, this.filteredOptions, this.cascaderProps);
98618
+ let items = CascaderUtilsPro.getAggregatedItemsFromSelection(store, selection, this.filteredOptions, this.cascaderProps);
98619
+ if (items.length === 0 && selection.size() > 0) {
98620
+ const paths = selection.getCheckedPaths();
98621
+ if (paths.length > 0) {
98622
+ items = CascaderUtilsPro.getAggregatedSelectedItems(paths, this.filteredOptions, this.cascaderProps);
98623
+ }
98624
+ }
98625
+ if (items.length === 0 && this.hasExternalValue()) {
98626
+ const paths = this.resolveExternalValueToPaths();
98627
+ if (paths.length > 0) {
98628
+ items = CascaderUtilsPro.getAggregatedSelectedItems(paths, this.filteredOptions, this.cascaderProps);
98629
+ }
98630
+ }
98527
98631
  this.selectedItems = items;
98528
98632
  this.selectedCount = items.length;
98529
98633
  this.isAllSelected = selection.size() === store.totalLeafCount && store.totalLeafCount > 0;
98530
98634
  if (!selection.isCompactSelection()) {
98531
98635
  this.selectedValues = selection.getCheckedPaths();
98532
98636
  }
98637
+ panel.bumpSelectionView();
98638
+ return;
98639
+ }
98640
+ if (selection.isCompactSelection()) {
98641
+ this.selectedItems = this.buildSelectedItemsFromValuesLazy(panel);
98642
+ this.selectedCount = selection.size();
98643
+ this.isAllSelected = selection.size() === store.totalLeafCount;
98644
+ panel.bumpSelectionView();
98645
+ return;
98646
+ }
98647
+ this.selectedValues = selection.getCheckedPaths();
98648
+ this.updateSelectedItems();
98649
+ panel.bumpSelectionView();
98650
+ },
98651
+ applyPanelSelectionChange() {
98652
+ const panel = this.$refs.cascaderPanel;
98653
+ if (!panel || !panel.store || !panel.selection) {
98654
+ return;
98655
+ }
98656
+ const {
98657
+ store,
98658
+ selection
98659
+ } = panel;
98660
+ this.refreshSelectionDisplayFromPanel();
98661
+ if (this.aggregationMode) {
98533
98662
  this.isInternalUpdate = true;
98534
- let emitValue = CascaderUtilsPro.getAggregatedEmitValues(items, this.parentNodePrefix);
98663
+ let emitValue = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
98535
98664
  if (!this.isMultiple && emitValue.length > 0) {
98536
98665
  emitValue = emitValue[0];
98537
98666
  }
98538
98667
  this.$emit('input', emitValue);
98539
98668
  this.$emit('change', this.getSelectedData());
98540
- panel.bumpSelectionView();
98541
98669
  return;
98542
98670
  }
98543
98671
  if (selection.isCompactSelection()) {
98544
- this.selectedItems = this.buildSelectedItemsFromValuesLazy(panel);
98545
- this.selectedCount = this.aggregationMode ? this.selectedItems.length : selection.size();
98546
- this.isAllSelected = selection.size() === store.totalLeafCount;
98547
98672
  this.isInternalUpdate = true;
98548
98673
  this.$emit('input', this.currentValue);
98549
98674
  this.$emit('change', this.getSelectedData());
98550
- panel.bumpSelectionView();
98551
98675
  return;
98552
98676
  }
98553
- this.selectedValues = selection.getCheckedPaths();
98554
- this.updateSelectedItems();
98555
- panel.bumpSelectionView();
98556
98677
  this.$nextTick(() => {
98557
98678
  this.isInternalUpdate = true;
98558
98679
  let emitValue = this.currentValue;
@@ -98581,16 +98702,21 @@ var VirtualCascaderPanel_component = normalizeComponent(
98581
98702
  return false;
98582
98703
  }
98583
98704
  if (!this.hasExternalValue()) {
98584
- panel.clearCheckedNodes();
98705
+ if (panel.selection) {
98706
+ panel.selection.clear();
98707
+ panel.bumpSelectionView();
98708
+ }
98585
98709
  this.selectedItems = [];
98586
98710
  this.selectedValues = [];
98587
98711
  return true;
98588
98712
  }
98589
98713
  panel.selection.clear();
98590
- this.applyExternalValueToPanelSelection(panel);
98714
+ this.getExternalValueList().forEach(val => {
98715
+ CascaderUtilsPro.addValueToSelection(panel.store, panel.selection, val, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
98716
+ });
98591
98717
  panel.selection._reconcileAllRoots();
98592
98718
  panel.bumpSelectionView();
98593
- this.applyPanelSelectionChange();
98719
+ this.refreshSelectionDisplayFromPanel();
98594
98720
  this.expandPanelToExternalValue(panel);
98595
98721
  return true;
98596
98722
  },
@@ -98609,34 +98735,8 @@ var VirtualCascaderPanel_component = normalizeComponent(
98609
98735
  store,
98610
98736
  selection
98611
98737
  } = 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
98738
  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
- }
98739
+ CascaderUtilsPro.addValueToSelection(store, selection, val, this.filteredOptions, this.cascaderProps, this.parentNodePrefix);
98640
98740
  });
98641
98741
  },
98642
98742
  getExternalValueList() {
@@ -98667,7 +98767,8 @@ var VirtualCascaderPanel_component = normalizeComponent(
98667
98767
  if (!this.hasExternalValue()) {
98668
98768
  const panel = this.$refs.cascaderPanel;
98669
98769
  if (panel && panel.selection) {
98670
- panel.clearCheckedNodes();
98770
+ panel.selection.clear();
98771
+ panel.bumpSelectionView();
98671
98772
  }
98672
98773
  this.selectedItems = [];
98673
98774
  this.selectedValues = [];
@@ -98707,15 +98808,17 @@ var VirtualCascaderPanel_component = normalizeComponent(
98707
98808
  let pathValues = [];
98708
98809
  if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(firstValue, this.parentNodePrefix)) {
98709
98810
  const actualValue = CascaderUtilsPro.extractParentNodeValue(firstValue, this.parentNodePrefix);
98710
- const node = panel.store.nodeByValue.get(actualValue);
98811
+ const node = resolveStoreNodeByValue(panel.store, actualValue);
98711
98812
  pathValues = node ? [...node.path] : [];
98712
- } else if (panel.store.pathByLeafValue.has(firstValue)) {
98713
- const path = panel.store.pathByLeafValue.get(firstValue);
98714
- pathValues = path ? path.slice(0, -1) : [];
98715
98813
  } else {
98716
- const node = panel.store.nodeByValue.get(firstValue);
98717
- if (node) {
98718
- pathValues = node.isLeaf ? node.path.slice(0, -1) : [...node.path];
98814
+ const leafPath = getStoreLeafPath(panel.store, firstValue);
98815
+ if (leafPath) {
98816
+ pathValues = leafPath.slice(0, -1);
98817
+ } else {
98818
+ const node = resolveStoreNodeByValue(panel.store, firstValue);
98819
+ if (node) {
98820
+ pathValues = node.isLeaf ? node.path.slice(0, -1) : [...node.path];
98821
+ }
98719
98822
  }
98720
98823
  }
98721
98824
  if (pathValues.length > 0) {
@@ -98976,23 +99079,23 @@ var VirtualCascaderPanel_component = normalizeComponent(
98976
99079
  const panel = this.$refs.cascaderPanel;
98977
99080
  if (panel && panel.selection) {
98978
99081
  if (item.isAggregated) {
98979
- const node = panel.store.nodeByValue.get(item.value);
99082
+ const node = resolveStoreNodeByValue(panel.store, item.value);
98980
99083
  if (node) {
98981
99084
  panel.selection.toggleNode(node.id, false);
98982
99085
  }
98983
99086
  } else if (item.path && item.path.length > 0) {
98984
99087
  const leafValue = item.path[item.path.length - 1];
98985
- const leafNode = panel.store.nodeByValue.get(leafValue);
99088
+ const leafNode = resolveStoreNodeByValue(panel.store, leafValue);
98986
99089
  if (leafNode) {
98987
99090
  panel.selection.toggleNode(leafNode.id, false);
98988
99091
  } else {
98989
- const node = panel.store.nodeByValue.get(item.value);
99092
+ const node = resolveStoreNodeByValue(panel.store, item.value);
98990
99093
  if (node) {
98991
99094
  panel.selection.toggleNode(node.id, false);
98992
99095
  }
98993
99096
  }
98994
99097
  } else {
98995
- const node = panel.store.nodeByValue.get(item.value);
99098
+ const node = resolveStoreNodeByValue(panel.store, item.value);
98996
99099
  if (node) {
98997
99100
  panel.selection.toggleNode(node.id, false);
98998
99101
  }
@@ -99132,15 +99235,10 @@ var VirtualCascaderPanel_component = normalizeComponent(
99132
99235
  const findPath = (options, targetValues, currentPath = []) => {
99133
99236
  for (const option of options) {
99134
99237
  const newPath = [...currentPath, option[this.cascaderProps.value]];
99135
- if (targetValues.includes(option[this.cascaderProps.value])) {
99136
- // 如果是叶子节点(没有children属性),添加到路径中
99137
- if (!option[this.cascaderProps.children]) {
99138
- paths.push(newPath);
99139
- }
99238
+ if (targetValues.some(target => target == option[this.cascaderProps.value]) && CascaderUtilsPro.isTreeLeafNode(option, this.cascaderProps)) {
99239
+ paths.push(newPath);
99140
99240
  }
99141
-
99142
- // 递归查找子节点
99143
- if (option[this.cascaderProps.children] && option[this.cascaderProps.children].length > 0) {
99241
+ if (!CascaderUtilsPro.isTreeLeafNode(option, this.cascaderProps)) {
99144
99242
  findPath(option[this.cascaderProps.children], targetValues, newPath);
99145
99243
  }
99146
99244
  }
@@ -99178,8 +99276,9 @@ var VirtualCascaderPanel_component = normalizeComponent(
99178
99276
  if (panel && panel.selection && panel.store) {
99179
99277
  matchedPaths.forEach(path => {
99180
99278
  const leafValue = path[path.length - 1];
99181
- if (panel.store.pathByLeafValue.has(leafValue)) {
99182
- panel.selection.selectedLeafSet.add(leafValue);
99279
+ const leafPath = getStoreLeafPath(panel.store, leafValue);
99280
+ if (leafPath) {
99281
+ panel.selection.selectedLeafSet.add(leafPath[leafPath.length - 1]);
99183
99282
  }
99184
99283
  });
99185
99284
  panel.selection._reconcileAllRoots();
@@ -99282,8 +99381,8 @@ var VirtualCascaderPanel_component = normalizeComponent(
99282
99381
  ;
99283
99382
  var ByCascaderPanelPro_component = normalizeComponent(
99284
99383
  cascader_panel_pro_ByCascaderPanelProvue_type_script_lang_js,
99285
- ByCascaderPanelProvue_type_template_id_804df886_render,
99286
- ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns,
99384
+ ByCascaderPanelProvue_type_template_id_075d43fb_render,
99385
+ ByCascaderPanelProvue_type_template_id_075d43fb_staticRenderFns,
99287
99386
  false,
99288
99387
  null,
99289
99388
  null,