@v-c/tree-select 0.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/LICENSE +21 -0
- package/dist/LegacyContext.cjs +12 -0
- package/dist/LegacyContext.d.ts +25 -0
- package/dist/LegacyContext.js +9 -0
- package/dist/OptionList.cjs +230 -0
- package/dist/OptionList.d.ts +2 -0
- package/dist/OptionList.js +223 -0
- package/dist/TreeNode.cjs +11 -0
- package/dist/TreeNode.d.ts +7 -0
- package/dist/TreeNode.js +5 -0
- package/dist/TreeSelect.cjs +953 -0
- package/dist/TreeSelect.d.ts +76 -0
- package/dist/TreeSelect.js +947 -0
- package/dist/TreeSelectContext.cjs +12 -0
- package/dist/TreeSelectContext.d.ts +28 -0
- package/dist/TreeSelectContext.js +9 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/hooks/useCache.cjs +25 -0
- package/dist/hooks/useCache.d.ts +6 -0
- package/dist/hooks/useCache.js +20 -0
- package/dist/hooks/useCheckedKeys.cjs +25 -0
- package/dist/hooks/useCheckedKeys.d.ts +4 -0
- package/dist/hooks/useCheckedKeys.js +20 -0
- package/dist/hooks/useDataEntities.cjs +40 -0
- package/dist/hooks/useDataEntities.d.ts +7 -0
- package/dist/hooks/useDataEntities.js +35 -0
- package/dist/hooks/useFilterTreeData.cjs +28 -0
- package/dist/hooks/useFilterTreeData.d.ts +8 -0
- package/dist/hooks/useFilterTreeData.js +23 -0
- package/dist/hooks/useRefFunc.cjs +15 -0
- package/dist/hooks/useRefFunc.d.ts +5 -0
- package/dist/hooks/useRefFunc.js +10 -0
- package/dist/hooks/useSearchConfig.cjs +23 -0
- package/dist/hooks/useSearchConfig.d.ts +6 -0
- package/dist/hooks/useSearchConfig.js +18 -0
- package/dist/hooks/useTreeData.cjs +43 -0
- package/dist/hooks/useTreeData.d.ts +6 -0
- package/dist/hooks/useTreeData.js +38 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +10 -0
- package/dist/interface.cjs +1 -0
- package/dist/interface.d.ts +57 -0
- package/dist/interface.js +0 -0
- package/dist/utils/legacyUtil.cjs +85 -0
- package/dist/utils/legacyUtil.d.ts +5 -0
- package/dist/utils/legacyUtil.js +80 -0
- package/dist/utils/strategyUtil.cjs +22 -0
- package/dist/utils/strategyUtil.d.ts +7 -0
- package/dist/utils/strategyUtil.js +18 -0
- package/dist/utils/valueUtil.cjs +36 -0
- package/dist/utils/valueUtil.d.ts +11 -0
- package/dist/utils/valueUtil.js +31 -0
- package/dist/utils/warningPropsUtil.cjs +18 -0
- package/dist/utils/warningPropsUtil.d.ts +4 -0
- package/dist/utils/warningPropsUtil.js +12 -0
- package/package.json +43 -0
|
@@ -0,0 +1,85 @@
|
|
|
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;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
|
+
import { ChangeEventExtra, DataNode, FieldNames, SafeKey } from '../interface';
|
|
3
|
+
export declare function convertChildrenToData(nodes?: VNode[]): DataNode[];
|
|
4
|
+
export declare function fillLegacyProps(dataNode: DataNode): any;
|
|
5
|
+
export declare function fillAdditionalInfo(extra: ChangeEventExtra, triggerValue: SafeKey, checkedValues: SafeKey[], treeData: DataNode[], showPosition: boolean, fieldNames: FieldNames): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import TreeNode_default from "../TreeNode.js";
|
|
2
|
+
import { createVNode, isVNode, toRaw } from "vue";
|
|
3
|
+
import warning from "@v-c/util/dist/warning";
|
|
4
|
+
function getNodeChildren(children) {
|
|
5
|
+
let finalChildren = children;
|
|
6
|
+
if (typeof children === "function") finalChildren = children();
|
|
7
|
+
else if (children && typeof children === "object" && "default" in children) finalChildren = typeof children.default === "function" ? children.default() : children.default;
|
|
8
|
+
return Array.isArray(finalChildren) ? finalChildren : [];
|
|
9
|
+
}
|
|
10
|
+
function convertChildrenToData(nodes = []) {
|
|
11
|
+
return toRaw(nodes).map((node) => {
|
|
12
|
+
if (!isVNode(node) || !node.type) return null;
|
|
13
|
+
const { key, props, children } = node;
|
|
14
|
+
const { value, ...restProps } = props || {};
|
|
15
|
+
const data = {
|
|
16
|
+
key,
|
|
17
|
+
value,
|
|
18
|
+
...restProps
|
|
19
|
+
};
|
|
20
|
+
const childData = convertChildrenToData(getNodeChildren(children));
|
|
21
|
+
if (childData.length) data.children = childData;
|
|
22
|
+
return data;
|
|
23
|
+
}).filter((data) => data !== null);
|
|
24
|
+
}
|
|
25
|
+
function fillLegacyProps(dataNode) {
|
|
26
|
+
if (!dataNode) return dataNode;
|
|
27
|
+
const cloneNode = { ...dataNode };
|
|
28
|
+
if (!("props" in cloneNode)) Object.defineProperty(cloneNode, "props", { get() {
|
|
29
|
+
warning(false, "New `vc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access.");
|
|
30
|
+
return cloneNode;
|
|
31
|
+
} });
|
|
32
|
+
return cloneNode;
|
|
33
|
+
}
|
|
34
|
+
function fillAdditionalInfo(extra, triggerValue, checkedValues, treeData, showPosition, fieldNames) {
|
|
35
|
+
let triggerNode = null;
|
|
36
|
+
let nodeList = null;
|
|
37
|
+
function generateMap() {
|
|
38
|
+
function dig(list, level = "0", parentIncluded = false) {
|
|
39
|
+
return (list || []).map((option, index) => {
|
|
40
|
+
const pos = `${level}-${index}`;
|
|
41
|
+
const value = option[fieldNames.value];
|
|
42
|
+
const included = checkedValues.includes(value);
|
|
43
|
+
const children = dig(option[fieldNames.children] || [], pos, included);
|
|
44
|
+
const node = createVNode(TreeNode_default, option, { default: () => children.map((child) => child.node) });
|
|
45
|
+
if (triggerValue === value) triggerNode = node;
|
|
46
|
+
if (included) {
|
|
47
|
+
const checkedNode = {
|
|
48
|
+
pos,
|
|
49
|
+
node,
|
|
50
|
+
children
|
|
51
|
+
};
|
|
52
|
+
if (!parentIncluded) nodeList.push(checkedNode);
|
|
53
|
+
return checkedNode;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}).filter((node) => node !== null);
|
|
57
|
+
}
|
|
58
|
+
if (!nodeList) {
|
|
59
|
+
nodeList = [];
|
|
60
|
+
dig(treeData);
|
|
61
|
+
nodeList.sort((a, b) => {
|
|
62
|
+
const val1 = a.node.props?.value;
|
|
63
|
+
const val2 = b.node.props?.value;
|
|
64
|
+
return checkedValues.indexOf(val1) - checkedValues.indexOf(val2);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
Object.defineProperty(extra, "triggerNode", { get() {
|
|
69
|
+
warning(false, "`triggerNode` is deprecated. Please consider decoupling data with node.");
|
|
70
|
+
generateMap();
|
|
71
|
+
return triggerNode;
|
|
72
|
+
} });
|
|
73
|
+
Object.defineProperty(extra, "allCheckedNodes", { get() {
|
|
74
|
+
warning(false, "`allCheckedNodes` is deprecated. Please consider decoupling data with node.");
|
|
75
|
+
generateMap();
|
|
76
|
+
if (showPosition) return nodeList;
|
|
77
|
+
return (nodeList || []).map(({ node }) => node);
|
|
78
|
+
} });
|
|
79
|
+
}
|
|
80
|
+
export { convertChildrenToData, fillAdditionalInfo, fillLegacyProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataEntity } from '@v-c/tree';
|
|
2
|
+
import { FieldNames, SafeKey } from '../interface';
|
|
3
|
+
export declare const SHOW_ALL = "SHOW_ALL";
|
|
4
|
+
export declare const SHOW_PARENT = "SHOW_PARENT";
|
|
5
|
+
export declare const SHOW_CHILD = "SHOW_CHILD";
|
|
6
|
+
export type CheckedStrategy = typeof SHOW_ALL | typeof SHOW_PARENT | typeof SHOW_CHILD;
|
|
7
|
+
export declare function formatStrategyValues(values: SafeKey[], strategy: CheckedStrategy, keyEntities: Record<string, DataEntity>, fieldNames: FieldNames): SafeKey[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isCheckDisabled } from "./valueUtil.js";
|
|
2
|
+
const SHOW_ALL = "SHOW_ALL";
|
|
3
|
+
const SHOW_PARENT = "SHOW_PARENT";
|
|
4
|
+
const SHOW_CHILD = "SHOW_CHILD";
|
|
5
|
+
function formatStrategyValues(values, strategy, keyEntities, fieldNames) {
|
|
6
|
+
const valueSet = new Set(values);
|
|
7
|
+
if (strategy === "SHOW_CHILD") return values.filter((key) => {
|
|
8
|
+
const entity = keyEntities[String(key)];
|
|
9
|
+
return !entity || !entity.children || !entity.children.some(({ node }) => valueSet.has(node[fieldNames.value])) || !entity.children.every(({ node }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]));
|
|
10
|
+
});
|
|
11
|
+
if (strategy === "SHOW_PARENT") return values.filter((key) => {
|
|
12
|
+
const entity = keyEntities[String(key)];
|
|
13
|
+
const parent = entity ? entity.parent : null;
|
|
14
|
+
return !parent || isCheckDisabled(parent.node) || !valueSet.has(parent.key);
|
|
15
|
+
});
|
|
16
|
+
return values;
|
|
17
|
+
}
|
|
18
|
+
export { SHOW_ALL, SHOW_CHILD, SHOW_PARENT, formatStrategyValues };
|
|
@@ -0,0 +1,36 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataNode, FieldNames, SafeKey } from '../interface';
|
|
2
|
+
export declare function toArray<T>(value: T | T[]): T[];
|
|
3
|
+
export declare function fillFieldNames(fieldNames?: FieldNames): {
|
|
4
|
+
_title: string[];
|
|
5
|
+
value: string;
|
|
6
|
+
key: string;
|
|
7
|
+
children: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function isCheckDisabled(node: DataNode): boolean;
|
|
10
|
+
export declare function getAllKeys(treeData: DataNode[], fieldNames: FieldNames): SafeKey[];
|
|
11
|
+
export declare const isNil: (val: any) => boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function toArray(value) {
|
|
2
|
+
return Array.isArray(value) ? value : value !== void 0 ? [value] : [];
|
|
3
|
+
}
|
|
4
|
+
function fillFieldNames(fieldNames) {
|
|
5
|
+
const { label, value, children } = fieldNames || {};
|
|
6
|
+
return {
|
|
7
|
+
_title: label ? [label] : ["title", "label"],
|
|
8
|
+
value: value || "value",
|
|
9
|
+
key: value || "value",
|
|
10
|
+
children: children || "children"
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function isCheckDisabled(node) {
|
|
14
|
+
return !node || node.disabled || node.disableCheckbox || node.checkable === false;
|
|
15
|
+
}
|
|
16
|
+
function getAllKeys(treeData, fieldNames) {
|
|
17
|
+
const keys = [];
|
|
18
|
+
const dig = (list) => {
|
|
19
|
+
list.forEach((item) => {
|
|
20
|
+
const children = item[fieldNames.children];
|
|
21
|
+
if (children) {
|
|
22
|
+
keys.push(item[fieldNames.value]);
|
|
23
|
+
dig(children);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
dig(treeData);
|
|
28
|
+
return keys;
|
|
29
|
+
}
|
|
30
|
+
const isNil = (val) => val === null || val === void 0;
|
|
31
|
+
export { fillFieldNames, getAllKeys, isCheckDisabled, isNil, toArray };
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { toArray } from "./valueUtil.js";
|
|
2
|
+
import warning from "@v-c/util/dist/warning";
|
|
3
|
+
function warningProps(props) {
|
|
4
|
+
const { searchPlaceholder, treeCheckStrictly, treeCheckable, labelInValue, value, multiple, showCheckedStrategy, maxCount } = props;
|
|
5
|
+
warning(!searchPlaceholder, "`searchPlaceholder` has been removed.");
|
|
6
|
+
if (treeCheckStrictly && labelInValue === false) warning(false, "`treeCheckStrictly` will force set `labelInValue` to `true`.");
|
|
7
|
+
if (labelInValue || treeCheckStrictly) warning(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.");
|
|
8
|
+
if (treeCheckStrictly || multiple || treeCheckable) warning(!value || Array.isArray(value), "`value` should be an array when `TreeSelect` is checkable or multiple.");
|
|
9
|
+
else warning(!Array.isArray(value), "`value` should not be array when `TreeSelect` is single mode.");
|
|
10
|
+
if (maxCount && (showCheckedStrategy === "SHOW_ALL" && !treeCheckStrictly || showCheckedStrategy === "SHOW_PARENT")) warning(false, "`maxCount` not work with `showCheckedStrategy=SHOW_ALL` (when `treeCheckStrictly=false`) or `showCheckedStrategy=SHOW_PARENT`.");
|
|
11
|
+
}
|
|
12
|
+
export { warningProps as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@v-c/tree-select",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"trigger"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./dist/*": "./dist/*",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"vue": "^3.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@v-c/util": "^1.0.4",
|
|
33
|
+
"@v-c/tree": "^0.0.1",
|
|
34
|
+
"@v-c/select": "^1.0.3"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build",
|
|
38
|
+
"test": "vitest",
|
|
39
|
+
"prepublish": "pnpm build",
|
|
40
|
+
"patch": "bumpp --release patch",
|
|
41
|
+
"bump": "bumpp"
|
|
42
|
+
}
|
|
43
|
+
}
|