@v-c/tree-select 1.0.0 → 1.0.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.
- package/package.json +5 -5
- package/dist/LegacyContext.cjs +0 -12
- package/dist/OptionList.cjs +0 -230
- package/dist/TreeNode.cjs +0 -11
- package/dist/TreeSelect.cjs +0 -953
- package/dist/TreeSelectContext.cjs +0 -12
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/hooks/useCache.cjs +0 -25
- package/dist/hooks/useCheckedKeys.cjs +0 -25
- package/dist/hooks/useDataEntities.cjs +0 -40
- package/dist/hooks/useFilterTreeData.cjs +0 -28
- package/dist/hooks/useRefFunc.cjs +0 -15
- package/dist/hooks/useSearchConfig.cjs +0 -23
- package/dist/hooks/useTreeData.cjs +0 -43
- package/dist/index.cjs +0 -18
- package/dist/interface.cjs +0 -1
- package/dist/utils/legacyUtil.cjs +0 -85
- package/dist/utils/strategyUtil.cjs +0 -22
- package/dist/utils/valueUtil.cjs +0 -36
- package/dist/utils/warningPropsUtil.cjs +0 -18
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
3
|
-
let vue = require("vue");
|
|
4
|
-
var TreeSelectContextKey = Symbol("TreeSelectContext");
|
|
5
|
-
function useTreeSelectProvider(value) {
|
|
6
|
-
(0, vue.provide)(TreeSelectContextKey, value);
|
|
7
|
-
}
|
|
8
|
-
function useTreeSelectContext() {
|
|
9
|
-
return (0, vue.inject)(TreeSelectContextKey, (0, vue.ref)(null));
|
|
10
|
-
}
|
|
11
|
-
exports.useTreeSelectContext = useTreeSelectContext;
|
|
12
|
-
exports.useTreeSelectProvider = useTreeSelectProvider;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
9
|
-
key = keys[i];
|
|
10
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
-
get: ((k) => from[k]).bind(null, key),
|
|
12
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
-
value: mod,
|
|
19
|
-
enumerable: true
|
|
20
|
-
}) : target, mod));
|
|
21
|
-
exports.__toESM = __toESM;
|
package/dist/hooks/useCache.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
function useCache(values) {
|
|
8
|
-
const cacheRef = (0, vue.shallowRef)({ valueLabels: /* @__PURE__ */ new Map() });
|
|
9
|
-
return [(0, vue.computed)(() => {
|
|
10
|
-
const { valueLabels } = cacheRef.value;
|
|
11
|
-
const valueLabelsCache = /* @__PURE__ */ new Map();
|
|
12
|
-
const merged = values.value.map((item) => {
|
|
13
|
-
const { value, label } = item;
|
|
14
|
-
const mergedLabel = label ?? valueLabels.get(value);
|
|
15
|
-
valueLabelsCache.set(value, mergedLabel);
|
|
16
|
-
return {
|
|
17
|
-
...item,
|
|
18
|
-
label: mergedLabel
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
cacheRef.value.valueLabels = valueLabelsCache;
|
|
22
|
-
return merged;
|
|
23
|
-
})];
|
|
24
|
-
}
|
|
25
|
-
exports.default = useCache;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
let _v_c_tree = require("@v-c/tree");
|
|
8
|
-
function useCheckedKeys(rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities) {
|
|
9
|
-
const merged = (0, vue.computed)(() => {
|
|
10
|
-
const extractValues = (values) => values.map(({ value }) => value);
|
|
11
|
-
const checkedKeys = extractValues(rawLabeledValues.value);
|
|
12
|
-
const halfCheckedKeys = extractValues(rawHalfCheckedValues.value);
|
|
13
|
-
const missingValues = checkedKeys.filter((key) => !keyEntities.value[String(key)]);
|
|
14
|
-
let finalCheckedKeys = checkedKeys;
|
|
15
|
-
let finalHalfCheckedKeys = halfCheckedKeys;
|
|
16
|
-
if (treeConduction.value) {
|
|
17
|
-
const conductResult = (0, _v_c_tree.conductCheck)(checkedKeys, true, keyEntities.value);
|
|
18
|
-
finalCheckedKeys = conductResult.checkedKeys;
|
|
19
|
-
finalHalfCheckedKeys = conductResult.halfCheckedKeys;
|
|
20
|
-
}
|
|
21
|
-
return [Array.from(new Set([...missingValues, ...finalCheckedKeys])), finalHalfCheckedKeys];
|
|
22
|
-
});
|
|
23
|
-
return [(0, vue.computed)(() => merged.value[0]), (0, vue.computed)(() => merged.value[1])];
|
|
24
|
-
}
|
|
25
|
-
exports.default = useCheckedKeys;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_valueUtil = require("../utils/valueUtil.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
let _v_c_tree = require("@v-c/tree");
|
|
9
|
-
let _v_c_util = require("@v-c/util");
|
|
10
|
-
function useDataEntities(treeData, fieldNames) {
|
|
11
|
-
const valueEntities = (0, vue.shallowRef)(/* @__PURE__ */ new Map());
|
|
12
|
-
const keyEntities = (0, vue.shallowRef)({});
|
|
13
|
-
(0, vue.watchEffect)(() => {
|
|
14
|
-
const mergedFieldNames = fieldNames.value;
|
|
15
|
-
const collection = (0, _v_c_tree.convertDataToEntities)(treeData.value, {
|
|
16
|
-
fieldNames: mergedFieldNames,
|
|
17
|
-
initWrapper: (wrapper) => ({
|
|
18
|
-
...wrapper,
|
|
19
|
-
valueEntities: /* @__PURE__ */ new Map()
|
|
20
|
-
}),
|
|
21
|
-
processEntity: (entity, wrapper) => {
|
|
22
|
-
const val = entity.node[mergedFieldNames.value];
|
|
23
|
-
if (process.env.NODE_ENV !== "production") {
|
|
24
|
-
const key = entity.node.key;
|
|
25
|
-
(0, _v_c_util.warning)(!require_valueUtil.isNil(val), "TreeNode `value` is invalidate: undefined");
|
|
26
|
-
(0, _v_c_util.warning)(!wrapper.valueEntities.has(val), `Same \`value\` exist in the tree: ${val}`);
|
|
27
|
-
(0, _v_c_util.warning)(!key || String(key) === String(val), `\`key\` or \`value\` with TreeNode must be the same or you can remove one of them. key: ${key}, value: ${val}.`);
|
|
28
|
-
}
|
|
29
|
-
wrapper.valueEntities.set(val, entity);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
keyEntities.value = collection.keyEntities;
|
|
33
|
-
valueEntities.value = collection.valueEntities;
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
valueEntities,
|
|
37
|
-
keyEntities
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
exports.default = useDataEntities;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_legacyUtil = require("../utils/legacyUtil.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
function useFilterTreeData(treeData, searchValue, options) {
|
|
9
|
-
return (0, vue.computed)(() => {
|
|
10
|
-
const { children: fieldChildren } = options.fieldNames.value;
|
|
11
|
-
const mergedSearchValue = searchValue.value;
|
|
12
|
-
if (!mergedSearchValue || options.filterTreeNode.value === false) return treeData.value;
|
|
13
|
-
const filterOptionFunc = typeof options.filterTreeNode.value === "function" ? options.filterTreeNode.value : (_, dataNode) => String(dataNode[options.treeNodeFilterProp.value]).toUpperCase().includes(mergedSearchValue.toUpperCase());
|
|
14
|
-
const filterTreeNodes = (nodes, keepAll = false) => nodes.reduce((filtered, node) => {
|
|
15
|
-
const children = node[fieldChildren];
|
|
16
|
-
const isMatch = keepAll || filterOptionFunc(mergedSearchValue, require_legacyUtil.fillLegacyProps(node));
|
|
17
|
-
const filteredChildren = filterTreeNodes(children || [], isMatch);
|
|
18
|
-
if (isMatch || filteredChildren.length) filtered.push({
|
|
19
|
-
...node,
|
|
20
|
-
isLeaf: void 0,
|
|
21
|
-
[fieldChildren]: filteredChildren
|
|
22
|
-
});
|
|
23
|
-
return filtered;
|
|
24
|
-
}, []);
|
|
25
|
-
return filterTreeNodes(treeData.value);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
exports.default = useFilterTreeData;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
function useRefFunc(callback) {
|
|
8
|
-
const callbackRef = (0, vue.shallowRef)(callback);
|
|
9
|
-
callbackRef.value = callback;
|
|
10
|
-
const cacheFn = ((...args) => {
|
|
11
|
-
return callbackRef.value(...args);
|
|
12
|
-
});
|
|
13
|
-
return cacheFn;
|
|
14
|
-
}
|
|
15
|
-
exports.default = useRefFunc;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
function useSearchConfig(showSearch, props) {
|
|
8
|
-
return [(0, vue.computed)(() => {
|
|
9
|
-
return typeof showSearch.value === "object" ? true : showSearch.value;
|
|
10
|
-
}), (0, vue.computed)(() => {
|
|
11
|
-
const { searchValue, inputValue, onSearch, autoClearSearchValue, filterTreeNode, treeNodeFilterProp } = props.value;
|
|
12
|
-
const isObject = typeof showSearch.value === "object";
|
|
13
|
-
return {
|
|
14
|
-
searchValue: searchValue ?? inputValue,
|
|
15
|
-
onSearch,
|
|
16
|
-
autoClearSearchValue,
|
|
17
|
-
filterTreeNode,
|
|
18
|
-
treeNodeFilterProp,
|
|
19
|
-
...isObject ? showSearch.value : {}
|
|
20
|
-
};
|
|
21
|
-
})];
|
|
22
|
-
}
|
|
23
|
-
exports.default = useSearchConfig;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
function buildTreeStructure(nodes, config) {
|
|
8
|
-
const { id, pId, rootPId } = config;
|
|
9
|
-
const nodeMap = /* @__PURE__ */ new Map();
|
|
10
|
-
const rootNodes = [];
|
|
11
|
-
nodes.forEach((node) => {
|
|
12
|
-
const nodeKey = node[id];
|
|
13
|
-
const clonedNode = {
|
|
14
|
-
...node,
|
|
15
|
-
key: node.key || nodeKey
|
|
16
|
-
};
|
|
17
|
-
nodeMap.set(nodeKey, clonedNode);
|
|
18
|
-
});
|
|
19
|
-
nodeMap.forEach((node) => {
|
|
20
|
-
const parentKey = node[pId];
|
|
21
|
-
const parent = nodeMap.get(parentKey);
|
|
22
|
-
if (parent) {
|
|
23
|
-
parent.children = parent.children || [];
|
|
24
|
-
parent.children.push(node);
|
|
25
|
-
} else if (parentKey === rootPId || rootPId === null) rootNodes.push(node);
|
|
26
|
-
});
|
|
27
|
-
return rootNodes;
|
|
28
|
-
}
|
|
29
|
-
function useTreeData(treeData, simpleMode) {
|
|
30
|
-
return (0, vue.computed)(() => {
|
|
31
|
-
if (simpleMode.value) {
|
|
32
|
-
const config = {
|
|
33
|
-
id: "id",
|
|
34
|
-
pId: "pId",
|
|
35
|
-
rootPId: null,
|
|
36
|
-
...typeof simpleMode.value === "object" ? simpleMode.value : {}
|
|
37
|
-
};
|
|
38
|
-
return buildTreeStructure(treeData.value, config);
|
|
39
|
-
}
|
|
40
|
-
return treeData.value;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
exports.default = useTreeData;
|
package/dist/index.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_TreeNode = require("./TreeNode.cjs");
|
|
6
|
-
const require_strategyUtil = require("./utils/strategyUtil.cjs");
|
|
7
|
-
const require_TreeSelect = require("./TreeSelect.cjs");
|
|
8
|
-
var ExportTreeSelect = require_TreeSelect.default;
|
|
9
|
-
ExportTreeSelect.TreeNode = require_TreeNode.default;
|
|
10
|
-
ExportTreeSelect.SHOW_ALL = require_strategyUtil.SHOW_ALL;
|
|
11
|
-
ExportTreeSelect.SHOW_PARENT = require_strategyUtil.SHOW_PARENT;
|
|
12
|
-
ExportTreeSelect.SHOW_CHILD = require_strategyUtil.SHOW_CHILD;
|
|
13
|
-
var src_default = ExportTreeSelect;
|
|
14
|
-
exports.SHOW_ALL = require_strategyUtil.SHOW_ALL;
|
|
15
|
-
exports.SHOW_CHILD = require_strategyUtil.SHOW_CHILD;
|
|
16
|
-
exports.SHOW_PARENT = require_strategyUtil.SHOW_PARENT;
|
|
17
|
-
exports.TreeNode = require_TreeNode.default;
|
|
18
|
-
exports.default = src_default;
|
package/dist/interface.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
-
const require_TreeNode = require("../TreeNode.cjs");
|
|
4
|
-
let vue = require("vue");
|
|
5
|
-
let _v_c_util_dist_warning = require("@v-c/util/dist/warning");
|
|
6
|
-
_v_c_util_dist_warning = require_rolldown_runtime.__toESM(_v_c_util_dist_warning);
|
|
7
|
-
function getNodeChildren(children) {
|
|
8
|
-
let finalChildren = children;
|
|
9
|
-
if (typeof children === "function") finalChildren = children();
|
|
10
|
-
else if (children && typeof children === "object" && "default" in children) finalChildren = typeof children.default === "function" ? children.default() : children.default;
|
|
11
|
-
return Array.isArray(finalChildren) ? finalChildren : [];
|
|
12
|
-
}
|
|
13
|
-
function convertChildrenToData(nodes = []) {
|
|
14
|
-
return (0, vue.toRaw)(nodes).map((node) => {
|
|
15
|
-
if (!(0, vue.isVNode)(node) || !node.type) return null;
|
|
16
|
-
const { key, props, children } = node;
|
|
17
|
-
const { value, ...restProps } = props || {};
|
|
18
|
-
const data = {
|
|
19
|
-
key,
|
|
20
|
-
value,
|
|
21
|
-
...restProps
|
|
22
|
-
};
|
|
23
|
-
const childData = convertChildrenToData(getNodeChildren(children));
|
|
24
|
-
if (childData.length) data.children = childData;
|
|
25
|
-
return data;
|
|
26
|
-
}).filter((data) => data !== null);
|
|
27
|
-
}
|
|
28
|
-
function fillLegacyProps(dataNode) {
|
|
29
|
-
if (!dataNode) return dataNode;
|
|
30
|
-
const cloneNode = { ...dataNode };
|
|
31
|
-
if (!("props" in cloneNode)) Object.defineProperty(cloneNode, "props", { get() {
|
|
32
|
-
(0, _v_c_util_dist_warning.default)(false, "New `vc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access.");
|
|
33
|
-
return cloneNode;
|
|
34
|
-
} });
|
|
35
|
-
return cloneNode;
|
|
36
|
-
}
|
|
37
|
-
function fillAdditionalInfo(extra, triggerValue, checkedValues, treeData, showPosition, fieldNames) {
|
|
38
|
-
let triggerNode = null;
|
|
39
|
-
let nodeList = null;
|
|
40
|
-
function generateMap() {
|
|
41
|
-
function dig(list, level = "0", parentIncluded = false) {
|
|
42
|
-
return (list || []).map((option, index) => {
|
|
43
|
-
const pos = `${level}-${index}`;
|
|
44
|
-
const value = option[fieldNames.value];
|
|
45
|
-
const included = checkedValues.includes(value);
|
|
46
|
-
const children = dig(option[fieldNames.children] || [], pos, included);
|
|
47
|
-
const node = (0, vue.createVNode)(require_TreeNode.default, option, { default: () => children.map((child) => child.node) });
|
|
48
|
-
if (triggerValue === value) triggerNode = node;
|
|
49
|
-
if (included) {
|
|
50
|
-
const checkedNode = {
|
|
51
|
-
pos,
|
|
52
|
-
node,
|
|
53
|
-
children
|
|
54
|
-
};
|
|
55
|
-
if (!parentIncluded) nodeList.push(checkedNode);
|
|
56
|
-
return checkedNode;
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}).filter((node) => node !== null);
|
|
60
|
-
}
|
|
61
|
-
if (!nodeList) {
|
|
62
|
-
nodeList = [];
|
|
63
|
-
dig(treeData);
|
|
64
|
-
nodeList.sort((a, b) => {
|
|
65
|
-
const val1 = a.node.props?.value;
|
|
66
|
-
const val2 = b.node.props?.value;
|
|
67
|
-
return checkedValues.indexOf(val1) - checkedValues.indexOf(val2);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
Object.defineProperty(extra, "triggerNode", { get() {
|
|
72
|
-
(0, _v_c_util_dist_warning.default)(false, "`triggerNode` is deprecated. Please consider decoupling data with node.");
|
|
73
|
-
generateMap();
|
|
74
|
-
return triggerNode;
|
|
75
|
-
} });
|
|
76
|
-
Object.defineProperty(extra, "allCheckedNodes", { get() {
|
|
77
|
-
(0, _v_c_util_dist_warning.default)(false, "`allCheckedNodes` is deprecated. Please consider decoupling data with node.");
|
|
78
|
-
generateMap();
|
|
79
|
-
if (showPosition) return nodeList;
|
|
80
|
-
return (nodeList || []).map(({ node }) => node);
|
|
81
|
-
} });
|
|
82
|
-
}
|
|
83
|
-
exports.convertChildrenToData = convertChildrenToData;
|
|
84
|
-
exports.fillAdditionalInfo = fillAdditionalInfo;
|
|
85
|
-
exports.fillLegacyProps = fillLegacyProps;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_valueUtil = require("./valueUtil.cjs");
|
|
3
|
-
const SHOW_ALL = "SHOW_ALL";
|
|
4
|
-
const SHOW_PARENT = "SHOW_PARENT";
|
|
5
|
-
const SHOW_CHILD = "SHOW_CHILD";
|
|
6
|
-
function formatStrategyValues(values, strategy, keyEntities, fieldNames) {
|
|
7
|
-
const valueSet = new Set(values);
|
|
8
|
-
if (strategy === "SHOW_CHILD") return values.filter((key) => {
|
|
9
|
-
const entity = keyEntities[String(key)];
|
|
10
|
-
return !entity || !entity.children || !entity.children.some(({ node }) => valueSet.has(node[fieldNames.value])) || !entity.children.every(({ node }) => require_valueUtil.isCheckDisabled(node) || valueSet.has(node[fieldNames.value]));
|
|
11
|
-
});
|
|
12
|
-
if (strategy === "SHOW_PARENT") return values.filter((key) => {
|
|
13
|
-
const entity = keyEntities[String(key)];
|
|
14
|
-
const parent = entity ? entity.parent : null;
|
|
15
|
-
return !parent || require_valueUtil.isCheckDisabled(parent.node) || !valueSet.has(parent.key);
|
|
16
|
-
});
|
|
17
|
-
return values;
|
|
18
|
-
}
|
|
19
|
-
exports.SHOW_ALL = SHOW_ALL;
|
|
20
|
-
exports.SHOW_CHILD = SHOW_CHILD;
|
|
21
|
-
exports.SHOW_PARENT = SHOW_PARENT;
|
|
22
|
-
exports.formatStrategyValues = formatStrategyValues;
|
package/dist/utils/valueUtil.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
function toArray(value) {
|
|
3
|
-
return Array.isArray(value) ? value : value !== void 0 ? [value] : [];
|
|
4
|
-
}
|
|
5
|
-
function fillFieldNames(fieldNames) {
|
|
6
|
-
const { label, value, children } = fieldNames || {};
|
|
7
|
-
return {
|
|
8
|
-
_title: label ? [label] : ["title", "label"],
|
|
9
|
-
value: value || "value",
|
|
10
|
-
key: value || "value",
|
|
11
|
-
children: children || "children"
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function isCheckDisabled(node) {
|
|
15
|
-
return !node || node.disabled || node.disableCheckbox || node.checkable === false;
|
|
16
|
-
}
|
|
17
|
-
function getAllKeys(treeData, fieldNames) {
|
|
18
|
-
const keys = [];
|
|
19
|
-
const dig = (list) => {
|
|
20
|
-
list.forEach((item) => {
|
|
21
|
-
const children = item[fieldNames.children];
|
|
22
|
-
if (children) {
|
|
23
|
-
keys.push(item[fieldNames.value]);
|
|
24
|
-
dig(children);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
dig(treeData);
|
|
29
|
-
return keys;
|
|
30
|
-
}
|
|
31
|
-
const isNil = (val) => val === null || val === void 0;
|
|
32
|
-
exports.fillFieldNames = fillFieldNames;
|
|
33
|
-
exports.getAllKeys = getAllKeys;
|
|
34
|
-
exports.isCheckDisabled = isCheckDisabled;
|
|
35
|
-
exports.isNil = isNil;
|
|
36
|
-
exports.toArray = toArray;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
const require_valueUtil = require("./valueUtil.cjs");
|
|
7
|
-
let _v_c_util_dist_warning = require("@v-c/util/dist/warning");
|
|
8
|
-
_v_c_util_dist_warning = require_rolldown_runtime.__toESM(_v_c_util_dist_warning);
|
|
9
|
-
function warningProps(props) {
|
|
10
|
-
const { searchPlaceholder, treeCheckStrictly, treeCheckable, labelInValue, value, multiple, showCheckedStrategy, maxCount } = props;
|
|
11
|
-
(0, _v_c_util_dist_warning.default)(!searchPlaceholder, "`searchPlaceholder` has been removed.");
|
|
12
|
-
if (treeCheckStrictly && labelInValue === false) (0, _v_c_util_dist_warning.default)(false, "`treeCheckStrictly` will force set `labelInValue` to `true`.");
|
|
13
|
-
if (labelInValue || treeCheckStrictly) (0, _v_c_util_dist_warning.default)(require_valueUtil.toArray(value).every((val) => val && typeof val === "object" && "value" in val), "Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead.");
|
|
14
|
-
if (treeCheckStrictly || multiple || treeCheckable) (0, _v_c_util_dist_warning.default)(!value || Array.isArray(value), "`value` should be an array when `TreeSelect` is checkable or multiple.");
|
|
15
|
-
else (0, _v_c_util_dist_warning.default)(!Array.isArray(value), "`value` should not be array when `TreeSelect` is single mode.");
|
|
16
|
-
if (maxCount && (showCheckedStrategy === "SHOW_ALL" && !treeCheckStrictly || showCheckedStrategy === "SHOW_PARENT")) (0, _v_c_util_dist_warning.default)(false, "`maxCount` not work with `showCheckedStrategy=SHOW_ALL` (when `treeCheckStrictly=false`) or `showCheckedStrategy=SHOW_PARENT`.");
|
|
17
|
-
}
|
|
18
|
-
exports.default = warningProps;
|