@v-c/cascader 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/Cascader.cjs +647 -0
- package/dist/Cascader.d.ts +90 -0
- package/dist/Cascader.js +639 -0
- package/dist/OptionList/CacheContent.cjs +38 -0
- package/dist/OptionList/CacheContent.d.ts +7 -0
- package/dist/OptionList/CacheContent.js +32 -0
- package/dist/OptionList/Checkbox.cjs +75 -0
- package/dist/OptionList/Checkbox.d.ts +12 -0
- package/dist/OptionList/Checkbox.js +69 -0
- package/dist/OptionList/Column.cjs +223 -0
- package/dist/OptionList/Column.d.ts +23 -0
- package/dist/OptionList/Column.js +215 -0
- package/dist/OptionList/List.cjs +195 -0
- package/dist/OptionList/List.d.ts +12 -0
- package/dist/OptionList/List.js +189 -0
- package/dist/OptionList/index.cjs +24 -0
- package/dist/OptionList/index.d.ts +2 -0
- package/dist/OptionList/index.js +18 -0
- package/dist/OptionList/useActive.cjs +19 -0
- package/dist/OptionList/useActive.d.ts +7 -0
- package/dist/OptionList/useActive.js +14 -0
- package/dist/OptionList/useKeyboard.cjs +108 -0
- package/dist/OptionList/useKeyboard.d.ts +9 -0
- package/dist/OptionList/useKeyboard.js +102 -0
- package/dist/Panel.cjs +209 -0
- package/dist/Panel.d.ts +5 -0
- package/dist/Panel.js +202 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/context.cjs +12 -0
- package/dist/context.d.ts +23 -0
- package/dist/context.js +9 -0
- package/dist/hooks/useDisplayValues.cjs +39 -0
- package/dist/hooks/useDisplayValues.d.ts +4 -0
- package/dist/hooks/useDisplayValues.js +34 -0
- package/dist/hooks/useEntities.cjs +41 -0
- package/dist/hooks/useEntities.d.ts +10 -0
- package/dist/hooks/useEntities.js +36 -0
- package/dist/hooks/useMissingValues.cjs +17 -0
- package/dist/hooks/useMissingValues.d.ts +4 -0
- package/dist/hooks/useMissingValues.js +13 -0
- package/dist/hooks/useOptions.cjs +25 -0
- package/dist/hooks/useOptions.d.ts +9 -0
- package/dist/hooks/useOptions.js +20 -0
- package/dist/hooks/useSearchConfig.cjs +34 -0
- package/dist/hooks/useSearchConfig.d.ts +4 -0
- package/dist/hooks/useSearchConfig.js +29 -0
- package/dist/hooks/useSearchOptions.cjs +46 -0
- package/dist/hooks/useSearchOptions.d.ts +5 -0
- package/dist/hooks/useSearchOptions.js +40 -0
- package/dist/hooks/useSelect.cjs +36 -0
- package/dist/hooks/useSelect.d.ts +4 -0
- package/dist/hooks/useSelect.js +31 -0
- package/dist/hooks/useValues.cjs +25 -0
- package/dist/hooks/useValues.d.ts +9 -0
- package/dist/hooks/useValues.js +20 -0
- package/dist/index.cjs +16 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +9 -0
- package/dist/utils/commonUtil.cjs +56 -0
- package/dist/utils/commonUtil.d.ts +18 -0
- package/dist/utils/commonUtil.js +45 -0
- package/dist/utils/treeUtil.cjs +34 -0
- package/dist/utils/treeUtil.d.ts +8 -0
- package/dist/utils/treeUtil.js +32 -0
- package/dist/utils/warningPropsUtil.cjs +19 -0
- package/dist/utils/warningPropsUtil.d.ts +2 -0
- package/dist/utils/warningPropsUtil.js +17 -0
- package/package.json +38 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_commonUtil = require("./commonUtil.cjs");
|
|
3
|
+
function formatStrategyValues(pathKeys, getKeyPathEntities, showCheckedStrategy) {
|
|
4
|
+
const valueSet = new Set(pathKeys);
|
|
5
|
+
const keyPathEntities = getKeyPathEntities();
|
|
6
|
+
return pathKeys.filter((key) => {
|
|
7
|
+
const entity = keyPathEntities[key];
|
|
8
|
+
const parent = entity ? entity.parent : null;
|
|
9
|
+
const children = entity ? entity.children : null;
|
|
10
|
+
if (entity && entity.node.disabled) return true;
|
|
11
|
+
return showCheckedStrategy === "SHOW_CHILD" ? !(children && children.some((child) => child.key && valueSet.has(child.key))) : !(parent && !parent.node.disabled && valueSet.has(parent.key));
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function toPathOptions(valueCells, options, fieldNames, stringMode = false) {
|
|
15
|
+
let currentList = options;
|
|
16
|
+
const valueOptions = [];
|
|
17
|
+
for (let i = 0; i < valueCells.length; i += 1) {
|
|
18
|
+
const valueCell = valueCells[i];
|
|
19
|
+
const foundIndex = currentList?.findIndex((option) => {
|
|
20
|
+
const val = option[fieldNames.value];
|
|
21
|
+
return stringMode ? String(val) === String(valueCell) : val === valueCell;
|
|
22
|
+
});
|
|
23
|
+
const foundOption = foundIndex !== -1 ? currentList?.[foundIndex] : null;
|
|
24
|
+
valueOptions.push({
|
|
25
|
+
value: foundOption?.[fieldNames.value] ?? valueCell,
|
|
26
|
+
index: foundIndex,
|
|
27
|
+
option: foundOption
|
|
28
|
+
});
|
|
29
|
+
currentList = foundOption?.[fieldNames.children];
|
|
30
|
+
}
|
|
31
|
+
return valueOptions;
|
|
32
|
+
}
|
|
33
|
+
exports.formatStrategyValues = formatStrategyValues;
|
|
34
|
+
exports.toPathOptions = toPathOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DefaultOptionType, InternalFieldNames, LegacyKey, ShowCheckedStrategy, SingleValueType } from '../Cascader';
|
|
2
|
+
import { GetEntities } from '../hooks/useEntities';
|
|
3
|
+
export declare function formatStrategyValues(pathKeys: LegacyKey[], getKeyPathEntities: GetEntities, showCheckedStrategy?: ShowCheckedStrategy): LegacyKey[];
|
|
4
|
+
export declare function toPathOptions(valueCells: SingleValueType, options: DefaultOptionType[], fieldNames: InternalFieldNames, stringMode?: boolean): {
|
|
5
|
+
value: SingleValueType[number];
|
|
6
|
+
index: number;
|
|
7
|
+
option: DefaultOptionType;
|
|
8
|
+
}[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SHOW_CHILD } from "./commonUtil.js";
|
|
2
|
+
function formatStrategyValues(pathKeys, getKeyPathEntities, showCheckedStrategy) {
|
|
3
|
+
const valueSet = new Set(pathKeys);
|
|
4
|
+
const keyPathEntities = getKeyPathEntities();
|
|
5
|
+
return pathKeys.filter((key) => {
|
|
6
|
+
const entity = keyPathEntities[key];
|
|
7
|
+
const parent = entity ? entity.parent : null;
|
|
8
|
+
const children = entity ? entity.children : null;
|
|
9
|
+
if (entity && entity.node.disabled) return true;
|
|
10
|
+
return showCheckedStrategy === "SHOW_CHILD" ? !(children && children.some((child) => child.key && valueSet.has(child.key))) : !(parent && !parent.node.disabled && valueSet.has(parent.key));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function toPathOptions(valueCells, options, fieldNames, stringMode = false) {
|
|
14
|
+
let currentList = options;
|
|
15
|
+
const valueOptions = [];
|
|
16
|
+
for (let i = 0; i < valueCells.length; i += 1) {
|
|
17
|
+
const valueCell = valueCells[i];
|
|
18
|
+
const foundIndex = currentList?.findIndex((option) => {
|
|
19
|
+
const val = option[fieldNames.value];
|
|
20
|
+
return stringMode ? String(val) === String(valueCell) : val === valueCell;
|
|
21
|
+
});
|
|
22
|
+
const foundOption = foundIndex !== -1 ? currentList?.[foundIndex] : null;
|
|
23
|
+
valueOptions.push({
|
|
24
|
+
value: foundOption?.[fieldNames.value] ?? valueCell,
|
|
25
|
+
index: foundIndex,
|
|
26
|
+
option: foundOption
|
|
27
|
+
});
|
|
28
|
+
currentList = foundOption?.[fieldNames.children];
|
|
29
|
+
}
|
|
30
|
+
return valueOptions;
|
|
31
|
+
}
|
|
32
|
+
export { formatStrategyValues, toPathOptions };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
3
|
+
let _v_c_util = require("@v-c/util");
|
|
4
|
+
function warningNullOptions(options, fieldNames) {
|
|
5
|
+
if (options) {
|
|
6
|
+
const recursiveOptions = (optionsList) => {
|
|
7
|
+
for (let i = 0; i < optionsList.length; i += 1) {
|
|
8
|
+
const option = optionsList[i];
|
|
9
|
+
if (option[fieldNames?.value] === null) {
|
|
10
|
+
(0, _v_c_util.warning)(false, "`value` in Cascader options should not be `null`.");
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(option[fieldNames?.children]) && recursiveOptions(option[fieldNames?.children])) return true;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
recursiveOptions(options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.warningNullOptions = warningNullOptions;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { warning } from "@v-c/util";
|
|
2
|
+
function warningNullOptions(options, fieldNames) {
|
|
3
|
+
if (options) {
|
|
4
|
+
const recursiveOptions = (optionsList) => {
|
|
5
|
+
for (let i = 0; i < optionsList.length; i += 1) {
|
|
6
|
+
const option = optionsList[i];
|
|
7
|
+
if (option[fieldNames?.value] === null) {
|
|
8
|
+
warning(false, "`value` in Cascader options should not be `null`.");
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(option[fieldNames?.children]) && recursiveOptions(option[fieldNames?.children])) return true;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
recursiveOptions(options);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { warningNullOptions };
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@v-c/cascader",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./dist/*": "./dist/*",
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"package.json"
|
|
22
|
+
],
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"vue": "^3.0.0"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@v-c/select": "^1.0.3",
|
|
28
|
+
"@v-c/tree": "^0.0.1",
|
|
29
|
+
"@v-c/util": "^1.0.4"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "vite build",
|
|
33
|
+
"prepublish": "pnpm build",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"patch": "bumpp --release patch",
|
|
36
|
+
"bump": "bumpp"
|
|
37
|
+
}
|
|
38
|
+
}
|