@weitutech/by-components 1.2.1 → 1.2.2
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.
- package/lib/by-components.common.js +305 -226
- package/lib/by-components.umd.js +305 -226
- package/lib/by-components.umd.min.js +1 -1
- package/package.json +1 -1
package/lib/by-components.umd.js
CHANGED
|
@@ -96025,8 +96025,8 @@ var ByCascaderPanel_component = normalizeComponent(
|
|
|
96025
96025
|
)
|
|
96026
96026
|
|
|
96027
96027
|
/* harmony default export */ var ByCascaderPanel = (ByCascaderPanel_component.exports);
|
|
96028
|
-
;// ./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-82.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=
|
|
96029
|
-
var
|
|
96028
|
+
;// ./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-82.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=37aef47d
|
|
96029
|
+
var ByCascaderPanelProvue_type_template_id_37aef47d_render = function render() {
|
|
96030
96030
|
var _vm = this,
|
|
96031
96031
|
_c = _vm._self._c;
|
|
96032
96032
|
return _c('div', {
|
|
@@ -96268,8 +96268,215 @@ var ByCascaderPanelProvue_type_template_id_804df886_render = function render() {
|
|
|
96268
96268
|
staticClass: "empty-state"
|
|
96269
96269
|
}, [_vm._v("暂无选中项")])], 1)])])])]);
|
|
96270
96270
|
};
|
|
96271
|
-
var
|
|
96271
|
+
var ByCascaderPanelProvue_type_template_id_37aef47d_staticRenderFns = [];
|
|
96272
96272
|
|
|
96273
|
+
;// ./src/components/cascader-panel-pro/cascaderStorePro.js
|
|
96274
|
+
|
|
96275
|
+
|
|
96276
|
+
|
|
96277
|
+
|
|
96278
|
+
|
|
96279
|
+
|
|
96280
|
+
/**
|
|
96281
|
+
* 级联树扁平化存储,初始化时预计算子树叶子元数据,供 O(1) 级勾选/聚合
|
|
96282
|
+
*/
|
|
96283
|
+
|
|
96284
|
+
let nodeIdSeed = 0;
|
|
96285
|
+
function nextId() {
|
|
96286
|
+
nodeIdSeed += 1;
|
|
96287
|
+
return nodeIdSeed;
|
|
96288
|
+
}
|
|
96289
|
+
function resetCascaderStoreIdSeed() {
|
|
96290
|
+
nodeIdSeed = 0;
|
|
96291
|
+
}
|
|
96292
|
+
|
|
96293
|
+
/**
|
|
96294
|
+
* @param {Array} options
|
|
96295
|
+
* @param {Object} config - disabledField/disabledValue/disabledCheck
|
|
96296
|
+
* @param {Object} cascaderProps
|
|
96297
|
+
* @param {Object} utils - CascaderUtilsPro
|
|
96298
|
+
*/
|
|
96299
|
+
function buildCascaderStore(options, config, cascaderProps, utils) {
|
|
96300
|
+
resetCascaderStoreIdSeed();
|
|
96301
|
+
const valueKey = cascaderProps.value || 'value';
|
|
96302
|
+
const labelKey = cascaderProps.label || 'label';
|
|
96303
|
+
const childrenKey = cascaderProps.children || 'children';
|
|
96304
|
+
const disabledKey = cascaderProps.disabled || 'disabled';
|
|
96305
|
+
const nodes = [];
|
|
96306
|
+
const nodeById = new Map();
|
|
96307
|
+
const nodeByValue = new Map();
|
|
96308
|
+
const childrenByParentId = new Map();
|
|
96309
|
+
const rootIds = [];
|
|
96310
|
+
const pathByLeafValue = new Map();
|
|
96311
|
+
const allLeafValues = [];
|
|
96312
|
+
const allLeafPaths = [];
|
|
96313
|
+
const createNode = (raw, parentPath, level, parentId) => {
|
|
96314
|
+
const value = raw[valueKey];
|
|
96315
|
+
const children = raw[childrenKey];
|
|
96316
|
+
const hasChildren = Array.isArray(children) && children.length > 0;
|
|
96317
|
+
const id = nextId();
|
|
96318
|
+
const nodePath = parentId == null ? [value] : parentPath.concat(value);
|
|
96319
|
+
const node = {
|
|
96320
|
+
id,
|
|
96321
|
+
value,
|
|
96322
|
+
label: raw[labelKey],
|
|
96323
|
+
path: nodePath,
|
|
96324
|
+
level,
|
|
96325
|
+
parentId,
|
|
96326
|
+
childIds: [],
|
|
96327
|
+
isLeaf: !hasChildren,
|
|
96328
|
+
disabled: !!raw[disabledKey],
|
|
96329
|
+
raw,
|
|
96330
|
+
descendantLeafValues: [],
|
|
96331
|
+
descendantLeafCount: 0,
|
|
96332
|
+
descendantPaths: []
|
|
96333
|
+
};
|
|
96334
|
+
nodes.push(node);
|
|
96335
|
+
nodeById.set(id, node);
|
|
96336
|
+
if (!nodeByValue.has(value)) {
|
|
96337
|
+
nodeByValue.set(value, node);
|
|
96338
|
+
}
|
|
96339
|
+
if (parentId == null) {
|
|
96340
|
+
rootIds.push(id);
|
|
96341
|
+
} else {
|
|
96342
|
+
const siblings = childrenByParentId.get(parentId) || [];
|
|
96343
|
+
siblings.push(id);
|
|
96344
|
+
childrenByParentId.set(parentId, siblings);
|
|
96345
|
+
const parent = nodeById.get(parentId);
|
|
96346
|
+
if (parent) {
|
|
96347
|
+
parent.childIds.push(id);
|
|
96348
|
+
}
|
|
96349
|
+
}
|
|
96350
|
+
if (hasChildren) {
|
|
96351
|
+
children.forEach(child => {
|
|
96352
|
+
createNode(child, nodePath, level + 1, id);
|
|
96353
|
+
});
|
|
96354
|
+
} else {
|
|
96355
|
+
pathByLeafValue.set(value, nodePath);
|
|
96356
|
+
if (!node.disabled) {
|
|
96357
|
+
allLeafValues.push(value);
|
|
96358
|
+
allLeafPaths.push(nodePath);
|
|
96359
|
+
}
|
|
96360
|
+
}
|
|
96361
|
+
return node;
|
|
96362
|
+
};
|
|
96363
|
+
const walkRoots = (items, ancestorDisabled = false) => {
|
|
96364
|
+
items.forEach(item => {
|
|
96365
|
+
const isDisabled = ancestorDisabled || utils.isItemDisabled(item, config);
|
|
96366
|
+
const cloned = {
|
|
96367
|
+
...item
|
|
96368
|
+
};
|
|
96369
|
+
if (isDisabled) {
|
|
96370
|
+
cloned[disabledKey] = true;
|
|
96371
|
+
}
|
|
96372
|
+
createNode(cloned, [], 0, null);
|
|
96373
|
+
});
|
|
96374
|
+
};
|
|
96375
|
+
walkRoots(options || []);
|
|
96376
|
+
|
|
96377
|
+
// 自底向上汇总子树叶子
|
|
96378
|
+
const sorted = nodes.slice().sort((a, b) => b.level - a.level);
|
|
96379
|
+
sorted.forEach(node => {
|
|
96380
|
+
if (node.isLeaf) {
|
|
96381
|
+
node.descendantLeafValues = [node.value];
|
|
96382
|
+
node.descendantLeafCount = 1;
|
|
96383
|
+
node.descendantPaths = [node.path];
|
|
96384
|
+
return;
|
|
96385
|
+
}
|
|
96386
|
+
const leafValues = [];
|
|
96387
|
+
const leafPaths = [];
|
|
96388
|
+
node.childIds.forEach(childId => {
|
|
96389
|
+
const child = nodeById.get(childId);
|
|
96390
|
+
if (!child || child.descendantLeafCount === 0) {
|
|
96391
|
+
return;
|
|
96392
|
+
}
|
|
96393
|
+
leafValues.push(...child.descendantLeafValues);
|
|
96394
|
+
leafPaths.push(...child.descendantPaths);
|
|
96395
|
+
});
|
|
96396
|
+
node.descendantLeafValues = leafValues;
|
|
96397
|
+
node.descendantLeafCount = leafValues.length;
|
|
96398
|
+
node.descendantPaths = leafPaths;
|
|
96399
|
+
});
|
|
96400
|
+
return {
|
|
96401
|
+
nodes,
|
|
96402
|
+
nodeById,
|
|
96403
|
+
nodeByValue,
|
|
96404
|
+
childrenByParentId,
|
|
96405
|
+
rootIds,
|
|
96406
|
+
pathByLeafValue,
|
|
96407
|
+
allLeafValues,
|
|
96408
|
+
allLeafPaths,
|
|
96409
|
+
totalLeafCount: allLeafPaths.length
|
|
96410
|
+
};
|
|
96411
|
+
}
|
|
96412
|
+
function getStoreChildren(store, parentId) {
|
|
96413
|
+
if (parentId == null) {
|
|
96414
|
+
return store.rootIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
96415
|
+
}
|
|
96416
|
+
const childIds = store.childrenByParentId.get(parentId) || [];
|
|
96417
|
+
return childIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
96418
|
+
}
|
|
96419
|
+
function resolveStoreNodeByValue(store, value) {
|
|
96420
|
+
if (!store || value == null || value === '') {
|
|
96421
|
+
return null;
|
|
96422
|
+
}
|
|
96423
|
+
if (store.nodeByValue.has(value)) {
|
|
96424
|
+
return store.nodeByValue.get(value);
|
|
96425
|
+
}
|
|
96426
|
+
const num = Number(value);
|
|
96427
|
+
if (!Number.isNaN(num) && store.nodeByValue.has(num)) {
|
|
96428
|
+
return store.nodeByValue.get(num);
|
|
96429
|
+
}
|
|
96430
|
+
const str = String(value);
|
|
96431
|
+
if (str !== value && store.nodeByValue.has(str)) {
|
|
96432
|
+
return store.nodeByValue.get(str);
|
|
96433
|
+
}
|
|
96434
|
+
for (const [key, node] of store.nodeByValue) {
|
|
96435
|
+
if (key == value) {
|
|
96436
|
+
return node;
|
|
96437
|
+
}
|
|
96438
|
+
}
|
|
96439
|
+
return null;
|
|
96440
|
+
}
|
|
96441
|
+
function getStoreLeafPath(store, leafValue) {
|
|
96442
|
+
if (!store || leafValue == null || leafValue === '') {
|
|
96443
|
+
return null;
|
|
96444
|
+
}
|
|
96445
|
+
if (store.pathByLeafValue.has(leafValue)) {
|
|
96446
|
+
return store.pathByLeafValue.get(leafValue);
|
|
96447
|
+
}
|
|
96448
|
+
const node = resolveStoreNodeByValue(store, leafValue);
|
|
96449
|
+
if (node && node.isLeaf) {
|
|
96450
|
+
return node.path;
|
|
96451
|
+
}
|
|
96452
|
+
for (const [key, path] of store.pathByLeafValue) {
|
|
96453
|
+
if (key == leafValue) {
|
|
96454
|
+
return path;
|
|
96455
|
+
}
|
|
96456
|
+
}
|
|
96457
|
+
return null;
|
|
96458
|
+
}
|
|
96459
|
+
function storeHasLeafValue(store, leafValue) {
|
|
96460
|
+
return getStoreLeafPath(store, leafValue) != null;
|
|
96461
|
+
}
|
|
96462
|
+
function findStoreNodeByPath(store, pathValues) {
|
|
96463
|
+
if (!pathValues || pathValues.length === 0) {
|
|
96464
|
+
return null;
|
|
96465
|
+
}
|
|
96466
|
+
let node = resolveStoreNodeByValue(store, pathValues[0]);
|
|
96467
|
+
if (!node || pathValues.length === 1) {
|
|
96468
|
+
return node;
|
|
96469
|
+
}
|
|
96470
|
+
for (let i = 1; i < pathValues.length; i++) {
|
|
96471
|
+
const target = pathValues[i];
|
|
96472
|
+
const children = getStoreChildren(store, node.id);
|
|
96473
|
+
node = children.find(child => child.value == target) || null;
|
|
96474
|
+
if (!node) {
|
|
96475
|
+
return null;
|
|
96476
|
+
}
|
|
96477
|
+
}
|
|
96478
|
+
return node;
|
|
96479
|
+
}
|
|
96273
96480
|
;// ./src/components/cascader-panel-pro/cascaderUtilsPro.js
|
|
96274
96481
|
|
|
96275
96482
|
|
|
@@ -96289,6 +96496,7 @@ var ByCascaderPanelProvue_type_template_id_804df886_staticRenderFns = [];
|
|
|
96289
96496
|
/**
|
|
96290
96497
|
* 级联选择器工具类(Pro 版,独立于 CascaderUtils)
|
|
96291
96498
|
*/
|
|
96499
|
+
|
|
96292
96500
|
class CascaderUtilsPro {
|
|
96293
96501
|
/**
|
|
96294
96502
|
* 估算级联节点标签文本宽度(px)
|
|
@@ -96631,14 +96839,14 @@ class CascaderUtilsPro {
|
|
|
96631
96839
|
}
|
|
96632
96840
|
const items = [];
|
|
96633
96841
|
selection.selectedLeafSet.forEach(leafValue => {
|
|
96634
|
-
const path = store
|
|
96635
|
-
const node = store
|
|
96842
|
+
const path = getStoreLeafPath(store, leafValue);
|
|
96843
|
+
const node = resolveStoreNodeByValue(store, leafValue);
|
|
96636
96844
|
if (!path || !node) {
|
|
96637
96845
|
return;
|
|
96638
96846
|
}
|
|
96639
96847
|
items.push({
|
|
96640
96848
|
...node.raw,
|
|
96641
|
-
value:
|
|
96849
|
+
value: node.value,
|
|
96642
96850
|
label: node.label,
|
|
96643
96851
|
path
|
|
96644
96852
|
});
|
|
@@ -96762,7 +96970,7 @@ class CascaderUtilsPro {
|
|
|
96762
96970
|
const items = [];
|
|
96763
96971
|
const walk = nodeId => {
|
|
96764
96972
|
const node = store.nodeById.get(nodeId);
|
|
96765
|
-
if (!node
|
|
96973
|
+
if (!node) {
|
|
96766
96974
|
return;
|
|
96767
96975
|
}
|
|
96768
96976
|
const state = selection.getCheckState(nodeId);
|
|
@@ -97010,7 +97218,7 @@ class CascaderUtilsPro {
|
|
|
97010
97218
|
const findPath = (nodes, targetValues, currentPath = []) => {
|
|
97011
97219
|
for (const option of nodes) {
|
|
97012
97220
|
const newPath = [...currentPath, option[cascaderProps.value]];
|
|
97013
|
-
if (targetValues.
|
|
97221
|
+
if (targetValues.some(target => target == option[cascaderProps.value])) {
|
|
97014
97222
|
// 如果是叶子节点(没有children属性),添加到路径中
|
|
97015
97223
|
if (!option[cascaderProps.children]) {
|
|
97016
97224
|
paths.push(newPath);
|
|
@@ -97275,170 +97483,6 @@ var VirtualList_component = normalizeComponent(
|
|
|
97275
97483
|
)
|
|
97276
97484
|
|
|
97277
97485
|
/* harmony default export */ var VirtualList = (VirtualList_component.exports);
|
|
97278
|
-
;// ./src/components/cascader-panel-pro/cascaderStorePro.js
|
|
97279
|
-
|
|
97280
|
-
|
|
97281
|
-
|
|
97282
|
-
|
|
97283
|
-
|
|
97284
|
-
|
|
97285
|
-
/**
|
|
97286
|
-
* 级联树扁平化存储,初始化时预计算子树叶子元数据,供 O(1) 级勾选/聚合
|
|
97287
|
-
*/
|
|
97288
|
-
|
|
97289
|
-
let nodeIdSeed = 0;
|
|
97290
|
-
function nextId() {
|
|
97291
|
-
nodeIdSeed += 1;
|
|
97292
|
-
return nodeIdSeed;
|
|
97293
|
-
}
|
|
97294
|
-
function resetCascaderStoreIdSeed() {
|
|
97295
|
-
nodeIdSeed = 0;
|
|
97296
|
-
}
|
|
97297
|
-
|
|
97298
|
-
/**
|
|
97299
|
-
* @param {Array} options
|
|
97300
|
-
* @param {Object} config - disabledField/disabledValue/disabledCheck
|
|
97301
|
-
* @param {Object} cascaderProps
|
|
97302
|
-
* @param {Object} utils - CascaderUtilsPro
|
|
97303
|
-
*/
|
|
97304
|
-
function buildCascaderStore(options, config, cascaderProps, utils) {
|
|
97305
|
-
resetCascaderStoreIdSeed();
|
|
97306
|
-
const valueKey = cascaderProps.value || 'value';
|
|
97307
|
-
const labelKey = cascaderProps.label || 'label';
|
|
97308
|
-
const childrenKey = cascaderProps.children || 'children';
|
|
97309
|
-
const disabledKey = cascaderProps.disabled || 'disabled';
|
|
97310
|
-
const nodes = [];
|
|
97311
|
-
const nodeById = new Map();
|
|
97312
|
-
const nodeByValue = new Map();
|
|
97313
|
-
const childrenByParentId = new Map();
|
|
97314
|
-
const rootIds = [];
|
|
97315
|
-
const pathByLeafValue = new Map();
|
|
97316
|
-
const allLeafValues = [];
|
|
97317
|
-
const allLeafPaths = [];
|
|
97318
|
-
const createNode = (raw, parentPath, level, parentId) => {
|
|
97319
|
-
const value = raw[valueKey];
|
|
97320
|
-
const children = raw[childrenKey];
|
|
97321
|
-
const hasChildren = Array.isArray(children) && children.length > 0;
|
|
97322
|
-
const id = nextId();
|
|
97323
|
-
const nodePath = parentId == null ? [value] : parentPath.concat(value);
|
|
97324
|
-
const node = {
|
|
97325
|
-
id,
|
|
97326
|
-
value,
|
|
97327
|
-
label: raw[labelKey],
|
|
97328
|
-
path: nodePath,
|
|
97329
|
-
level,
|
|
97330
|
-
parentId,
|
|
97331
|
-
childIds: [],
|
|
97332
|
-
isLeaf: !hasChildren,
|
|
97333
|
-
disabled: !!raw[disabledKey],
|
|
97334
|
-
raw,
|
|
97335
|
-
descendantLeafValues: [],
|
|
97336
|
-
descendantLeafCount: 0,
|
|
97337
|
-
descendantPaths: []
|
|
97338
|
-
};
|
|
97339
|
-
nodes.push(node);
|
|
97340
|
-
nodeById.set(id, node);
|
|
97341
|
-
if (!nodeByValue.has(value)) {
|
|
97342
|
-
nodeByValue.set(value, node);
|
|
97343
|
-
}
|
|
97344
|
-
if (parentId == null) {
|
|
97345
|
-
rootIds.push(id);
|
|
97346
|
-
} else {
|
|
97347
|
-
const siblings = childrenByParentId.get(parentId) || [];
|
|
97348
|
-
siblings.push(id);
|
|
97349
|
-
childrenByParentId.set(parentId, siblings);
|
|
97350
|
-
const parent = nodeById.get(parentId);
|
|
97351
|
-
if (parent) {
|
|
97352
|
-
parent.childIds.push(id);
|
|
97353
|
-
}
|
|
97354
|
-
}
|
|
97355
|
-
if (hasChildren) {
|
|
97356
|
-
children.forEach(child => {
|
|
97357
|
-
createNode(child, nodePath, level + 1, id);
|
|
97358
|
-
});
|
|
97359
|
-
} else if (!node.disabled) {
|
|
97360
|
-
pathByLeafValue.set(value, nodePath);
|
|
97361
|
-
allLeafValues.push(value);
|
|
97362
|
-
allLeafPaths.push(nodePath);
|
|
97363
|
-
}
|
|
97364
|
-
return node;
|
|
97365
|
-
};
|
|
97366
|
-
const walkRoots = (items, ancestorDisabled = false) => {
|
|
97367
|
-
items.forEach(item => {
|
|
97368
|
-
const isDisabled = ancestorDisabled || utils.isItemDisabled(item, config);
|
|
97369
|
-
const cloned = {
|
|
97370
|
-
...item
|
|
97371
|
-
};
|
|
97372
|
-
if (isDisabled) {
|
|
97373
|
-
cloned[disabledKey] = true;
|
|
97374
|
-
}
|
|
97375
|
-
createNode(cloned, [], 0, null);
|
|
97376
|
-
});
|
|
97377
|
-
};
|
|
97378
|
-
walkRoots(options || []);
|
|
97379
|
-
|
|
97380
|
-
// 自底向上汇总子树叶子
|
|
97381
|
-
const sorted = nodes.slice().sort((a, b) => b.level - a.level);
|
|
97382
|
-
sorted.forEach(node => {
|
|
97383
|
-
if (node.isLeaf) {
|
|
97384
|
-
if (!node.disabled) {
|
|
97385
|
-
node.descendantLeafValues = [node.value];
|
|
97386
|
-
node.descendantLeafCount = 1;
|
|
97387
|
-
node.descendantPaths = [node.path];
|
|
97388
|
-
}
|
|
97389
|
-
return;
|
|
97390
|
-
}
|
|
97391
|
-
const leafValues = [];
|
|
97392
|
-
const leafPaths = [];
|
|
97393
|
-
node.childIds.forEach(childId => {
|
|
97394
|
-
const child = nodeById.get(childId);
|
|
97395
|
-
if (!child || child.descendantLeafCount === 0) {
|
|
97396
|
-
return;
|
|
97397
|
-
}
|
|
97398
|
-
leafValues.push(...child.descendantLeafValues);
|
|
97399
|
-
leafPaths.push(...child.descendantPaths);
|
|
97400
|
-
});
|
|
97401
|
-
node.descendantLeafValues = leafValues;
|
|
97402
|
-
node.descendantLeafCount = leafValues.length;
|
|
97403
|
-
node.descendantPaths = leafPaths;
|
|
97404
|
-
});
|
|
97405
|
-
return {
|
|
97406
|
-
nodes,
|
|
97407
|
-
nodeById,
|
|
97408
|
-
nodeByValue,
|
|
97409
|
-
childrenByParentId,
|
|
97410
|
-
rootIds,
|
|
97411
|
-
pathByLeafValue,
|
|
97412
|
-
allLeafValues,
|
|
97413
|
-
allLeafPaths,
|
|
97414
|
-
totalLeafCount: allLeafPaths.length
|
|
97415
|
-
};
|
|
97416
|
-
}
|
|
97417
|
-
function getStoreChildren(store, parentId) {
|
|
97418
|
-
if (parentId == null) {
|
|
97419
|
-
return store.rootIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
97420
|
-
}
|
|
97421
|
-
const childIds = store.childrenByParentId.get(parentId) || [];
|
|
97422
|
-
return childIds.map(id => store.nodeById.get(id)).filter(Boolean);
|
|
97423
|
-
}
|
|
97424
|
-
function findStoreNodeByPath(store, pathValues) {
|
|
97425
|
-
if (!pathValues || pathValues.length === 0) {
|
|
97426
|
-
return null;
|
|
97427
|
-
}
|
|
97428
|
-
let node = store.nodeByValue.get(pathValues[0]);
|
|
97429
|
-
if (!node || pathValues.length === 1) {
|
|
97430
|
-
return node;
|
|
97431
|
-
}
|
|
97432
|
-
for (let i = 1; i < pathValues.length; i++) {
|
|
97433
|
-
const target = pathValues[i];
|
|
97434
|
-
const children = getStoreChildren(store, node.id);
|
|
97435
|
-
node = children.find(child => child.value == target) || null;
|
|
97436
|
-
if (!node) {
|
|
97437
|
-
return null;
|
|
97438
|
-
}
|
|
97439
|
-
}
|
|
97440
|
-
return node;
|
|
97441
|
-
}
|
|
97442
97486
|
;// ./src/components/cascader-panel-pro/selectionStatePro.js
|
|
97443
97487
|
|
|
97444
97488
|
|
|
@@ -97450,6 +97494,7 @@ function findStoreNodeByPath(store, pathValues) {
|
|
|
97450
97494
|
|
|
97451
97495
|
|
|
97452
97496
|
|
|
97497
|
+
|
|
97453
97498
|
const COMPACT_EMIT_THRESHOLD = 300;
|
|
97454
97499
|
|
|
97455
97500
|
class SelectionStatePro {
|
|
@@ -97614,32 +97659,40 @@ class SelectionStatePro {
|
|
|
97614
97659
|
return;
|
|
97615
97660
|
}
|
|
97616
97661
|
const leafValue = path[path.length - 1];
|
|
97617
|
-
|
|
97618
|
-
|
|
97662
|
+
const leafPath = getStoreLeafPath(this.store, leafValue);
|
|
97663
|
+
if (leafPath) {
|
|
97664
|
+
this.selectedLeafSet.add(leafPath[leafPath.length - 1]);
|
|
97619
97665
|
}
|
|
97620
97666
|
});
|
|
97621
97667
|
this._reconcileAllRoots();
|
|
97622
97668
|
}
|
|
97623
97669
|
getCheckState(nodeId) {
|
|
97624
97670
|
const node = this.store.nodeById.get(nodeId);
|
|
97625
|
-
if (!node
|
|
97671
|
+
if (!node) {
|
|
97626
97672
|
return 'disabled';
|
|
97627
97673
|
}
|
|
97674
|
+
let selectionState;
|
|
97628
97675
|
if (node.isLeaf) {
|
|
97629
|
-
|
|
97630
|
-
}
|
|
97631
|
-
|
|
97632
|
-
|
|
97633
|
-
|
|
97634
|
-
|
|
97635
|
-
|
|
97636
|
-
|
|
97637
|
-
|
|
97676
|
+
selectionState = this.selectedLeafSet.has(node.value) ? 'checked' : 'unchecked';
|
|
97677
|
+
} else {
|
|
97678
|
+
const total = node.descendantLeafCount;
|
|
97679
|
+
if (total === 0) {
|
|
97680
|
+
selectionState = 'unchecked';
|
|
97681
|
+
} else {
|
|
97682
|
+
const selected = this.subtreeSelectedCount.get(node.id) || 0;
|
|
97683
|
+
if (selected === 0) {
|
|
97684
|
+
selectionState = 'unchecked';
|
|
97685
|
+
} else if (selected >= total) {
|
|
97686
|
+
selectionState = 'checked';
|
|
97687
|
+
} else {
|
|
97688
|
+
selectionState = 'indeterminate';
|
|
97689
|
+
}
|
|
97690
|
+
}
|
|
97638
97691
|
}
|
|
97639
|
-
if (
|
|
97640
|
-
return '
|
|
97692
|
+
if (node.disabled && selectionState === 'unchecked') {
|
|
97693
|
+
return 'disabled';
|
|
97641
97694
|
}
|
|
97642
|
-
return
|
|
97695
|
+
return selectionState;
|
|
97643
97696
|
}
|
|
97644
97697
|
isChecked(nodeId) {
|
|
97645
97698
|
return this.getCheckState(nodeId) === 'checked';
|
|
@@ -97685,8 +97738,8 @@ class SelectionStatePro {
|
|
|
97685
97738
|
if (typeof val === 'string' && val.startsWith(prefix)) {
|
|
97686
97739
|
rootValue = val.substring(prefix.length);
|
|
97687
97740
|
}
|
|
97688
|
-
const node = this.store
|
|
97689
|
-
if (node && !node.isLeaf
|
|
97741
|
+
const node = resolveStoreNodeByValue(this.store, rootValue);
|
|
97742
|
+
if (node && !node.isLeaf) {
|
|
97690
97743
|
node.descendantLeafValues.forEach(v => this.selectedLeafSet.add(v));
|
|
97691
97744
|
}
|
|
97692
97745
|
});
|
|
@@ -98215,6 +98268,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98215
98268
|
|
|
98216
98269
|
|
|
98217
98270
|
|
|
98271
|
+
|
|
98218
98272
|
/* harmony default export */ var ByCascaderPanelProvue_type_script_lang_js = ({
|
|
98219
98273
|
name: 'ByCascaderPanelPro',
|
|
98220
98274
|
components: {
|
|
@@ -98523,7 +98577,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98523
98577
|
this.selectedValues = value && value.length ? [value] : [];
|
|
98524
98578
|
}
|
|
98525
98579
|
},
|
|
98526
|
-
|
|
98580
|
+
refreshSelectionDisplayFromPanel() {
|
|
98527
98581
|
const panel = this.$refs.cascaderPanel;
|
|
98528
98582
|
if (!panel || !panel.store || !panel.selection) {
|
|
98529
98583
|
return;
|
|
@@ -98540,29 +98594,46 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98540
98594
|
if (!selection.isCompactSelection()) {
|
|
98541
98595
|
this.selectedValues = selection.getCheckedPaths();
|
|
98542
98596
|
}
|
|
98597
|
+
panel.bumpSelectionView();
|
|
98598
|
+
return;
|
|
98599
|
+
}
|
|
98600
|
+
if (selection.isCompactSelection()) {
|
|
98601
|
+
this.selectedItems = this.buildSelectedItemsFromValuesLazy(panel);
|
|
98602
|
+
this.selectedCount = selection.size();
|
|
98603
|
+
this.isAllSelected = selection.size() === store.totalLeafCount;
|
|
98604
|
+
panel.bumpSelectionView();
|
|
98605
|
+
return;
|
|
98606
|
+
}
|
|
98607
|
+
this.selectedValues = selection.getCheckedPaths();
|
|
98608
|
+
this.updateSelectedItems();
|
|
98609
|
+
panel.bumpSelectionView();
|
|
98610
|
+
},
|
|
98611
|
+
applyPanelSelectionChange() {
|
|
98612
|
+
const panel = this.$refs.cascaderPanel;
|
|
98613
|
+
if (!panel || !panel.store || !panel.selection) {
|
|
98614
|
+
return;
|
|
98615
|
+
}
|
|
98616
|
+
const {
|
|
98617
|
+
store,
|
|
98618
|
+
selection
|
|
98619
|
+
} = panel;
|
|
98620
|
+
this.refreshSelectionDisplayFromPanel();
|
|
98621
|
+
if (this.aggregationMode) {
|
|
98543
98622
|
this.isInternalUpdate = true;
|
|
98544
|
-
let emitValue = CascaderUtilsPro.getAggregatedEmitValues(
|
|
98623
|
+
let emitValue = CascaderUtilsPro.getAggregatedEmitValues(this.selectedItems, this.parentNodePrefix);
|
|
98545
98624
|
if (!this.isMultiple && emitValue.length > 0) {
|
|
98546
98625
|
emitValue = emitValue[0];
|
|
98547
98626
|
}
|
|
98548
98627
|
this.$emit('input', emitValue);
|
|
98549
98628
|
this.$emit('change', this.getSelectedData());
|
|
98550
|
-
panel.bumpSelectionView();
|
|
98551
98629
|
return;
|
|
98552
98630
|
}
|
|
98553
98631
|
if (selection.isCompactSelection()) {
|
|
98554
|
-
this.selectedItems = this.buildSelectedItemsFromValuesLazy(panel);
|
|
98555
|
-
this.selectedCount = this.aggregationMode ? this.selectedItems.length : selection.size();
|
|
98556
|
-
this.isAllSelected = selection.size() === store.totalLeafCount;
|
|
98557
98632
|
this.isInternalUpdate = true;
|
|
98558
98633
|
this.$emit('input', this.currentValue);
|
|
98559
98634
|
this.$emit('change', this.getSelectedData());
|
|
98560
|
-
panel.bumpSelectionView();
|
|
98561
98635
|
return;
|
|
98562
98636
|
}
|
|
98563
|
-
this.selectedValues = selection.getCheckedPaths();
|
|
98564
|
-
this.updateSelectedItems();
|
|
98565
|
-
panel.bumpSelectionView();
|
|
98566
98637
|
this.$nextTick(() => {
|
|
98567
98638
|
this.isInternalUpdate = true;
|
|
98568
98639
|
let emitValue = this.currentValue;
|
|
@@ -98600,7 +98671,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98600
98671
|
this.applyExternalValueToPanelSelection(panel);
|
|
98601
98672
|
panel.selection._reconcileAllRoots();
|
|
98602
98673
|
panel.bumpSelectionView();
|
|
98603
|
-
this.
|
|
98674
|
+
this.refreshSelectionDisplayFromPanel();
|
|
98604
98675
|
this.expandPanelToExternalValue(panel);
|
|
98605
98676
|
return true;
|
|
98606
98677
|
},
|
|
@@ -98621,9 +98692,13 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98621
98692
|
} = panel;
|
|
98622
98693
|
const paths = this.resolveExternalValueToPaths();
|
|
98623
98694
|
paths.forEach(path => {
|
|
98695
|
+
if (!Array.isArray(path) || path.length === 0) {
|
|
98696
|
+
return;
|
|
98697
|
+
}
|
|
98624
98698
|
const leafValue = path[path.length - 1];
|
|
98625
|
-
|
|
98626
|
-
|
|
98699
|
+
const leafPath = getStoreLeafPath(store, leafValue);
|
|
98700
|
+
if (leafPath) {
|
|
98701
|
+
selection.selectedLeafSet.add(leafPath[leafPath.length - 1]);
|
|
98627
98702
|
}
|
|
98628
98703
|
});
|
|
98629
98704
|
|
|
@@ -98631,20 +98706,21 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98631
98706
|
this.getExternalValueList().forEach(val => {
|
|
98632
98707
|
if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(val, this.parentNodePrefix)) {
|
|
98633
98708
|
const actualValue = CascaderUtilsPro.extractParentNodeValue(val, this.parentNodePrefix);
|
|
98634
|
-
const node = store
|
|
98635
|
-
if (node && !node.isLeaf
|
|
98709
|
+
const node = resolveStoreNodeByValue(store, actualValue);
|
|
98710
|
+
if (node && !node.isLeaf) {
|
|
98636
98711
|
node.descendantLeafValues.forEach(leaf => selection.selectedLeafSet.add(leaf));
|
|
98637
98712
|
}
|
|
98638
98713
|
return;
|
|
98639
98714
|
}
|
|
98640
|
-
|
|
98641
|
-
|
|
98715
|
+
const leafPath = getStoreLeafPath(store, val);
|
|
98716
|
+
if (leafPath) {
|
|
98717
|
+
selection.selectedLeafSet.add(leafPath[leafPath.length - 1]);
|
|
98642
98718
|
return;
|
|
98643
98719
|
}
|
|
98644
|
-
const node = store
|
|
98645
|
-
if (node && node.isLeaf
|
|
98646
|
-
selection.selectedLeafSet.add(
|
|
98647
|
-
} else if (node && !node.isLeaf
|
|
98720
|
+
const node = resolveStoreNodeByValue(store, val);
|
|
98721
|
+
if (node && node.isLeaf) {
|
|
98722
|
+
selection.selectedLeafSet.add(node.value);
|
|
98723
|
+
} else if (node && !node.isLeaf) {
|
|
98648
98724
|
node.descendantLeafValues.forEach(leaf => selection.selectedLeafSet.add(leaf));
|
|
98649
98725
|
}
|
|
98650
98726
|
});
|
|
@@ -98717,15 +98793,17 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98717
98793
|
let pathValues = [];
|
|
98718
98794
|
if (this.aggregationMode && CascaderUtilsPro.isParentNodeValue(firstValue, this.parentNodePrefix)) {
|
|
98719
98795
|
const actualValue = CascaderUtilsPro.extractParentNodeValue(firstValue, this.parentNodePrefix);
|
|
98720
|
-
const node = panel.store
|
|
98796
|
+
const node = resolveStoreNodeByValue(panel.store, actualValue);
|
|
98721
98797
|
pathValues = node ? [...node.path] : [];
|
|
98722
|
-
} else if (panel.store.pathByLeafValue.has(firstValue)) {
|
|
98723
|
-
const path = panel.store.pathByLeafValue.get(firstValue);
|
|
98724
|
-
pathValues = path ? path.slice(0, -1) : [];
|
|
98725
98798
|
} else {
|
|
98726
|
-
const
|
|
98727
|
-
if (
|
|
98728
|
-
pathValues =
|
|
98799
|
+
const leafPath = getStoreLeafPath(panel.store, firstValue);
|
|
98800
|
+
if (leafPath) {
|
|
98801
|
+
pathValues = leafPath.slice(0, -1);
|
|
98802
|
+
} else {
|
|
98803
|
+
const node = resolveStoreNodeByValue(panel.store, firstValue);
|
|
98804
|
+
if (node) {
|
|
98805
|
+
pathValues = node.isLeaf ? node.path.slice(0, -1) : [...node.path];
|
|
98806
|
+
}
|
|
98729
98807
|
}
|
|
98730
98808
|
}
|
|
98731
98809
|
if (pathValues.length > 0) {
|
|
@@ -98986,23 +99064,23 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
98986
99064
|
const panel = this.$refs.cascaderPanel;
|
|
98987
99065
|
if (panel && panel.selection) {
|
|
98988
99066
|
if (item.isAggregated) {
|
|
98989
|
-
const node = panel.store
|
|
99067
|
+
const node = resolveStoreNodeByValue(panel.store, item.value);
|
|
98990
99068
|
if (node) {
|
|
98991
99069
|
panel.selection.toggleNode(node.id, false);
|
|
98992
99070
|
}
|
|
98993
99071
|
} else if (item.path && item.path.length > 0) {
|
|
98994
99072
|
const leafValue = item.path[item.path.length - 1];
|
|
98995
|
-
const leafNode = panel.store
|
|
99073
|
+
const leafNode = resolveStoreNodeByValue(panel.store, leafValue);
|
|
98996
99074
|
if (leafNode) {
|
|
98997
99075
|
panel.selection.toggleNode(leafNode.id, false);
|
|
98998
99076
|
} else {
|
|
98999
|
-
const node = panel.store
|
|
99077
|
+
const node = resolveStoreNodeByValue(panel.store, item.value);
|
|
99000
99078
|
if (node) {
|
|
99001
99079
|
panel.selection.toggleNode(node.id, false);
|
|
99002
99080
|
}
|
|
99003
99081
|
}
|
|
99004
99082
|
} else {
|
|
99005
|
-
const node = panel.store
|
|
99083
|
+
const node = resolveStoreNodeByValue(panel.store, item.value);
|
|
99006
99084
|
if (node) {
|
|
99007
99085
|
panel.selection.toggleNode(node.id, false);
|
|
99008
99086
|
}
|
|
@@ -99142,7 +99220,7 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
99142
99220
|
const findPath = (options, targetValues, currentPath = []) => {
|
|
99143
99221
|
for (const option of options) {
|
|
99144
99222
|
const newPath = [...currentPath, option[this.cascaderProps.value]];
|
|
99145
|
-
if (targetValues.
|
|
99223
|
+
if (targetValues.some(target => target == option[this.cascaderProps.value])) {
|
|
99146
99224
|
// 如果是叶子节点(没有children属性),添加到路径中
|
|
99147
99225
|
if (!option[this.cascaderProps.children]) {
|
|
99148
99226
|
paths.push(newPath);
|
|
@@ -99188,8 +99266,9 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
99188
99266
|
if (panel && panel.selection && panel.store) {
|
|
99189
99267
|
matchedPaths.forEach(path => {
|
|
99190
99268
|
const leafValue = path[path.length - 1];
|
|
99191
|
-
|
|
99192
|
-
|
|
99269
|
+
const leafPath = getStoreLeafPath(panel.store, leafValue);
|
|
99270
|
+
if (leafPath) {
|
|
99271
|
+
panel.selection.selectedLeafSet.add(leafPath[leafPath.length - 1]);
|
|
99193
99272
|
}
|
|
99194
99273
|
});
|
|
99195
99274
|
panel.selection._reconcileAllRoots();
|
|
@@ -99292,8 +99371,8 @@ var VirtualCascaderPanel_component = normalizeComponent(
|
|
|
99292
99371
|
;
|
|
99293
99372
|
var ByCascaderPanelPro_component = normalizeComponent(
|
|
99294
99373
|
cascader_panel_pro_ByCascaderPanelProvue_type_script_lang_js,
|
|
99295
|
-
|
|
99296
|
-
|
|
99374
|
+
ByCascaderPanelProvue_type_template_id_37aef47d_render,
|
|
99375
|
+
ByCascaderPanelProvue_type_template_id_37aef47d_staticRenderFns,
|
|
99297
99376
|
false,
|
|
99298
99377
|
null,
|
|
99299
99378
|
null,
|