@v-c/cascader 1.0.0 → 1.0.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/dist/OptionList/List.d.ts +1 -0
- package/dist/OptionList/List.js +15 -6
- package/dist/OptionList/index.js +6 -3
- package/package.json +5 -5
- package/dist/Cascader.cjs +0 -647
- package/dist/OptionList/CacheContent.cjs +0 -38
- package/dist/OptionList/CacheContent.d.ts +0 -7
- package/dist/OptionList/CacheContent.js +0 -32
- package/dist/OptionList/Checkbox.cjs +0 -75
- package/dist/OptionList/Column.cjs +0 -224
- package/dist/OptionList/List.cjs +0 -195
- package/dist/OptionList/index.cjs +0 -24
- package/dist/OptionList/useActive.cjs +0 -19
- package/dist/OptionList/useKeyboard.cjs +0 -108
- package/dist/Panel.cjs +0 -209
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/context.cjs +0 -12
- package/dist/hooks/useDisplayValues.cjs +0 -39
- package/dist/hooks/useEntities.cjs +0 -41
- package/dist/hooks/useMissingValues.cjs +0 -17
- package/dist/hooks/useOptions.cjs +0 -25
- package/dist/hooks/useSearchConfig.cjs +0 -34
- package/dist/hooks/useSearchOptions.cjs +0 -46
- package/dist/hooks/useSelect.cjs +0 -36
- package/dist/hooks/useValues.cjs +0 -25
- package/dist/index.cjs +0 -16
- package/dist/utils/commonUtil.cjs +0 -56
- package/dist/utils/treeUtil.cjs +0 -34
- package/dist/utils/warningPropsUtil.cjs +0 -19
package/dist/Panel.cjs
DELETED
|
@@ -1,209 +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_context = require("./context.cjs");
|
|
7
|
-
const require_commonUtil = require("./utils/commonUtil.cjs");
|
|
8
|
-
const require_treeUtil = require("./utils/treeUtil.cjs");
|
|
9
|
-
const require_useMissingValues = require("./hooks/useMissingValues.cjs");
|
|
10
|
-
const require_useOptions = require("./hooks/useOptions.cjs");
|
|
11
|
-
const require_useSelect = require("./hooks/useSelect.cjs");
|
|
12
|
-
const require_useValues = require("./hooks/useValues.cjs");
|
|
13
|
-
const require_List = require("./OptionList/List.cjs");
|
|
14
|
-
let vue = require("vue");
|
|
15
|
-
let _v_c_util = require("@v-c/util");
|
|
16
|
-
let _v_c_util_dist_hooks_useEvent = require("@v-c/util/dist/hooks/useEvent");
|
|
17
|
-
_v_c_util_dist_hooks_useEvent = require_rolldown_runtime.__toESM(_v_c_util_dist_hooks_useEvent);
|
|
18
|
-
function noop() {}
|
|
19
|
-
var panelDefaults = {
|
|
20
|
-
prefixCls: "vc-cascader",
|
|
21
|
-
expandIcon: ">",
|
|
22
|
-
showCheckedStrategy: require_commonUtil.SHOW_PARENT,
|
|
23
|
-
notFoundContent: "Not Found"
|
|
24
|
-
};
|
|
25
|
-
var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
26
|
-
const multiple = (0, vue.computed)(() => !!props.checkable);
|
|
27
|
-
const mergedShowCheckedStrategy = (0, vue.computed)(() => props.showCheckedStrategy ?? panelDefaults.showCheckedStrategy);
|
|
28
|
-
const internalRawValues = (0, vue.shallowRef)(props?.value ?? props?.defaultValue);
|
|
29
|
-
(0, vue.watch)(() => props.value, () => {
|
|
30
|
-
internalRawValues.value = props?.value;
|
|
31
|
-
});
|
|
32
|
-
const setRawValues = (values) => {
|
|
33
|
-
internalRawValues.value = values;
|
|
34
|
-
};
|
|
35
|
-
const rawValues = (0, vue.computed)(() => require_commonUtil.toRawValues(internalRawValues.value));
|
|
36
|
-
const mergedFieldNames = (0, vue.computed)(() => require_commonUtil.fillFieldNames(props.fieldNames));
|
|
37
|
-
const [mergedOptions, getPathKeyEntities, getValueByKeyPath] = require_useOptions.default(mergedFieldNames, (0, vue.computed)(() => props.options));
|
|
38
|
-
const valuesInfo = require_useValues.default(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, require_useMissingValues.default(mergedOptions, mergedFieldNames));
|
|
39
|
-
const checkedValues = (0, vue.computed)(() => valuesInfo.value[0]);
|
|
40
|
-
const halfCheckedValues = (0, vue.computed)(() => valuesInfo.value[1]);
|
|
41
|
-
const missingCheckedValues = (0, vue.computed)(() => valuesInfo.value[2]);
|
|
42
|
-
const handleSelection = require_useSelect.default(multiple, (0, _v_c_util_dist_hooks_useEvent.default)((nextValues) => {
|
|
43
|
-
setRawValues(nextValues);
|
|
44
|
-
if (props.onChange) {
|
|
45
|
-
const nextRawValues = require_commonUtil.toRawValues(nextValues);
|
|
46
|
-
const valueOptions = nextRawValues.map((valueCells) => require_treeUtil.toPathOptions(valueCells, mergedOptions.value, mergedFieldNames.value).map((valueOpt) => valueOpt.option));
|
|
47
|
-
const triggerValues = multiple.value ? nextRawValues : nextRawValues[0];
|
|
48
|
-
const triggerOptions = multiple.value ? valueOptions : valueOptions[0];
|
|
49
|
-
props.onChange(triggerValues, triggerOptions);
|
|
50
|
-
}
|
|
51
|
-
}), checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, mergedShowCheckedStrategy);
|
|
52
|
-
const onInternalSelect = (0, _v_c_util_dist_hooks_useEvent.default)((valuePath) => {
|
|
53
|
-
handleSelection(valuePath);
|
|
54
|
-
});
|
|
55
|
-
require_context.useCascaderProvider((0, vue.computed)(() => ({
|
|
56
|
-
options: mergedOptions.value,
|
|
57
|
-
fieldNames: mergedFieldNames.value,
|
|
58
|
-
values: checkedValues.value,
|
|
59
|
-
halfValues: halfCheckedValues.value,
|
|
60
|
-
changeOnSelect: props.changeOnSelect,
|
|
61
|
-
onSelect: onInternalSelect,
|
|
62
|
-
checkable: props.checkable,
|
|
63
|
-
searchOptions: [],
|
|
64
|
-
popupPrefixCls: void 0,
|
|
65
|
-
loadData: props.loadData,
|
|
66
|
-
expandTrigger: props.expandTrigger,
|
|
67
|
-
expandIcon: props.expandIcon !== void 0 ? props.expandIcon : panelDefaults.expandIcon,
|
|
68
|
-
loadingIcon: props.loadingIcon,
|
|
69
|
-
popupMenuColumnStyle: void 0,
|
|
70
|
-
optionRender: props.optionRender
|
|
71
|
-
})));
|
|
72
|
-
return () => {
|
|
73
|
-
const panelPrefixCls = `${props.prefixCls ?? panelDefaults.prefixCls}-panel`;
|
|
74
|
-
const isEmpty = !mergedOptions.value.length;
|
|
75
|
-
return (0, vue.createVNode)("div", {
|
|
76
|
-
"class": (0, _v_c_util.clsx)(panelPrefixCls, {
|
|
77
|
-
[`${panelPrefixCls}-rtl`]: props.direction === "rtl",
|
|
78
|
-
[`${panelPrefixCls}-empty`]: isEmpty
|
|
79
|
-
}, props.className),
|
|
80
|
-
"style": props.style
|
|
81
|
-
}, [isEmpty ? props.notFoundContent ?? panelDefaults.notFoundContent : (0, vue.createVNode)(require_List.default, {
|
|
82
|
-
"prefixCls": props.prefixCls ?? panelDefaults.prefixCls,
|
|
83
|
-
"searchValue": "",
|
|
84
|
-
"multiple": multiple.value,
|
|
85
|
-
"toggleOpen": noop,
|
|
86
|
-
"open": true,
|
|
87
|
-
"direction": props.direction,
|
|
88
|
-
"disabled": props.disabled
|
|
89
|
-
}, null)]);
|
|
90
|
-
};
|
|
91
|
-
}, { props: /* @__PURE__ */ (0, vue.mergeDefaults)({
|
|
92
|
-
value: {
|
|
93
|
-
required: false,
|
|
94
|
-
default: void 0
|
|
95
|
-
},
|
|
96
|
-
defaultValue: {
|
|
97
|
-
required: false,
|
|
98
|
-
default: void 0
|
|
99
|
-
},
|
|
100
|
-
changeOnSelect: {
|
|
101
|
-
type: Boolean,
|
|
102
|
-
required: false,
|
|
103
|
-
default: void 0
|
|
104
|
-
},
|
|
105
|
-
onChange: {
|
|
106
|
-
type: Function,
|
|
107
|
-
required: false,
|
|
108
|
-
default: void 0
|
|
109
|
-
},
|
|
110
|
-
options: {
|
|
111
|
-
type: Array,
|
|
112
|
-
required: false,
|
|
113
|
-
default: void 0
|
|
114
|
-
},
|
|
115
|
-
prefixCls: {
|
|
116
|
-
type: String,
|
|
117
|
-
required: false,
|
|
118
|
-
default: void 0
|
|
119
|
-
},
|
|
120
|
-
checkable: {
|
|
121
|
-
required: false,
|
|
122
|
-
default: void 0
|
|
123
|
-
},
|
|
124
|
-
fieldNames: {
|
|
125
|
-
type: Object,
|
|
126
|
-
required: false,
|
|
127
|
-
default: void 0
|
|
128
|
-
},
|
|
129
|
-
showCheckedStrategy: {
|
|
130
|
-
required: false,
|
|
131
|
-
default: void 0
|
|
132
|
-
},
|
|
133
|
-
loadData: {
|
|
134
|
-
type: Function,
|
|
135
|
-
required: false,
|
|
136
|
-
default: void 0
|
|
137
|
-
},
|
|
138
|
-
expandTrigger: {
|
|
139
|
-
type: String,
|
|
140
|
-
required: false,
|
|
141
|
-
default: void 0
|
|
142
|
-
},
|
|
143
|
-
expandIcon: {
|
|
144
|
-
type: [
|
|
145
|
-
Object,
|
|
146
|
-
Function,
|
|
147
|
-
String,
|
|
148
|
-
Number,
|
|
149
|
-
null,
|
|
150
|
-
Boolean,
|
|
151
|
-
Array
|
|
152
|
-
],
|
|
153
|
-
required: false,
|
|
154
|
-
default: void 0
|
|
155
|
-
},
|
|
156
|
-
loadingIcon: {
|
|
157
|
-
type: [
|
|
158
|
-
Object,
|
|
159
|
-
Function,
|
|
160
|
-
String,
|
|
161
|
-
Number,
|
|
162
|
-
null,
|
|
163
|
-
Boolean,
|
|
164
|
-
Array
|
|
165
|
-
],
|
|
166
|
-
required: false,
|
|
167
|
-
default: void 0
|
|
168
|
-
},
|
|
169
|
-
className: {
|
|
170
|
-
type: String,
|
|
171
|
-
required: false,
|
|
172
|
-
default: void 0
|
|
173
|
-
},
|
|
174
|
-
style: {
|
|
175
|
-
type: Object,
|
|
176
|
-
required: false,
|
|
177
|
-
default: void 0
|
|
178
|
-
},
|
|
179
|
-
direction: {
|
|
180
|
-
type: String,
|
|
181
|
-
required: false,
|
|
182
|
-
default: void 0
|
|
183
|
-
},
|
|
184
|
-
notFoundContent: {
|
|
185
|
-
type: [
|
|
186
|
-
Object,
|
|
187
|
-
Function,
|
|
188
|
-
String,
|
|
189
|
-
Number,
|
|
190
|
-
null,
|
|
191
|
-
Boolean,
|
|
192
|
-
Array
|
|
193
|
-
],
|
|
194
|
-
required: false,
|
|
195
|
-
default: void 0
|
|
196
|
-
},
|
|
197
|
-
disabled: {
|
|
198
|
-
type: Boolean,
|
|
199
|
-
required: false,
|
|
200
|
-
default: void 0
|
|
201
|
-
},
|
|
202
|
-
optionRender: {
|
|
203
|
-
type: Function,
|
|
204
|
-
required: false,
|
|
205
|
-
default: void 0
|
|
206
|
-
}
|
|
207
|
-
}, panelDefaults) });
|
|
208
|
-
var Panel_default = Panel;
|
|
209
|
-
exports.default = Panel_default;
|
|
@@ -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/context.cjs
DELETED
|
@@ -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 CascaderContextKey = Symbol("CascaderContext");
|
|
5
|
-
function useCascaderProvider(value) {
|
|
6
|
-
(0, vue.provide)(CascaderContextKey, value);
|
|
7
|
-
}
|
|
8
|
-
function useCascaderContext() {
|
|
9
|
-
return (0, vue.inject)(CascaderContextKey, (0, vue.ref)(null));
|
|
10
|
-
}
|
|
11
|
-
exports.useCascaderContext = useCascaderContext;
|
|
12
|
-
exports.useCascaderProvider = useCascaderProvider;
|
|
@@ -1,39 +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_commonUtil = require("../utils/commonUtil.cjs");
|
|
7
|
-
const require_treeUtil = require("../utils/treeUtil.cjs");
|
|
8
|
-
let vue = require("vue");
|
|
9
|
-
var useDisplayValues_default = (rawValues, options, fieldNames, multiple, displayRender) => {
|
|
10
|
-
return (0, vue.computed)(() => {
|
|
11
|
-
const mergedDisplayRender = displayRender.value || ((labels) => {
|
|
12
|
-
const mergedLabels = multiple.value ? labels.slice(-1) : labels;
|
|
13
|
-
const split = " / ";
|
|
14
|
-
if (mergedLabels.every((label) => ["string", "number"].includes(typeof label))) return mergedLabels.join(split);
|
|
15
|
-
return mergedLabels.reduce((list, label, index) => {
|
|
16
|
-
const nextLabel = (0, vue.isVNode)(label) ? (0, vue.cloneVNode)(label, { key: index }) : label;
|
|
17
|
-
if (index === 0) return [nextLabel];
|
|
18
|
-
return [
|
|
19
|
-
...list,
|
|
20
|
-
split,
|
|
21
|
-
nextLabel
|
|
22
|
-
];
|
|
23
|
-
}, []);
|
|
24
|
-
});
|
|
25
|
-
return rawValues.value.map((valueCells) => {
|
|
26
|
-
const valueOptions = require_treeUtil.toPathOptions(valueCells, options.value, fieldNames.value);
|
|
27
|
-
const label = mergedDisplayRender(valueOptions.map(({ option, value: value$1 }) => option?.[fieldNames.value.label] ?? value$1), valueOptions.map(({ option }) => option));
|
|
28
|
-
const value = require_commonUtil.toPathKey(valueCells);
|
|
29
|
-
return {
|
|
30
|
-
label,
|
|
31
|
-
value,
|
|
32
|
-
key: value,
|
|
33
|
-
valueCells,
|
|
34
|
-
disabled: valueOptions[valueOptions.length - 1]?.option?.disabled
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
exports.default = useDisplayValues_default;
|
|
@@ -1,41 +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_commonUtil = require("../utils/commonUtil.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
let _v_c_tree = require("@v-c/tree");
|
|
9
|
-
function useEntities(options, fieldNames) {
|
|
10
|
-
const cacheRef = (0, vue.shallowRef)({
|
|
11
|
-
options: [],
|
|
12
|
-
fieldNames: null,
|
|
13
|
-
info: {
|
|
14
|
-
keyEntities: {},
|
|
15
|
-
pathKeyEntities: {}
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
const getEntities = () => {
|
|
19
|
-
const mergedOptions = options.value;
|
|
20
|
-
const mergedFieldNames = fieldNames.value;
|
|
21
|
-
if (cacheRef.value.options !== mergedOptions || cacheRef.value.fieldNames !== mergedFieldNames) {
|
|
22
|
-
cacheRef.value.options = mergedOptions;
|
|
23
|
-
cacheRef.value.fieldNames = mergedFieldNames;
|
|
24
|
-
cacheRef.value.info = (0, _v_c_tree.convertDataToEntities)(mergedOptions, {
|
|
25
|
-
fieldNames: mergedFieldNames,
|
|
26
|
-
initWrapper: (wrapper) => ({
|
|
27
|
-
...wrapper,
|
|
28
|
-
pathKeyEntities: {}
|
|
29
|
-
}),
|
|
30
|
-
processEntity: (entity, wrapper) => {
|
|
31
|
-
const pathKey = entity.nodes.map((node) => node[mergedFieldNames.value]).join(require_commonUtil.VALUE_SPLIT);
|
|
32
|
-
wrapper.pathKeyEntities[pathKey] = entity;
|
|
33
|
-
entity.key = pathKey;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return cacheRef.value.info.pathKeyEntities;
|
|
38
|
-
};
|
|
39
|
-
return getEntities;
|
|
40
|
-
}
|
|
41
|
-
exports.default = useEntities;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_treeUtil = require("../utils/treeUtil.cjs");
|
|
6
|
-
function useMissingValues(options, fieldNames) {
|
|
7
|
-
return (rawValues) => {
|
|
8
|
-
const missingValues = [];
|
|
9
|
-
const existsValues = [];
|
|
10
|
-
rawValues.forEach((valueCell) => {
|
|
11
|
-
if (require_treeUtil.toPathOptions(valueCell, options.value, fieldNames.value).every((opt) => opt.option)) existsValues.push(valueCell);
|
|
12
|
-
else missingValues.push(valueCell);
|
|
13
|
-
});
|
|
14
|
-
return [existsValues, missingValues];
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.default = useMissingValues;
|
|
@@ -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
|
-
const require_useEntities = require("./useEntities.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
function useOptions(mergedFieldNames, options) {
|
|
9
|
-
const emptyOptions = [];
|
|
10
|
-
const mergedOptions = (0, vue.computed)(() => options.value || emptyOptions);
|
|
11
|
-
const getPathKeyEntities = require_useEntities.default(mergedOptions, mergedFieldNames);
|
|
12
|
-
const getValueByKeyPath = (pathKeys) => {
|
|
13
|
-
const keyPathEntities = getPathKeyEntities();
|
|
14
|
-
return pathKeys.map((pathKey) => {
|
|
15
|
-
const { nodes } = keyPathEntities[pathKey];
|
|
16
|
-
return nodes.map((node) => node[mergedFieldNames.value.value]);
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
return [
|
|
20
|
-
mergedOptions,
|
|
21
|
-
getPathKeyEntities,
|
|
22
|
-
getValueByKeyPath
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
exports.default = useOptions;
|
|
@@ -1,34 +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_util = require("@v-c/util");
|
|
8
|
-
function useSearchConfig(showSearch, props) {
|
|
9
|
-
const mergedShowSearch = (0, vue.computed)(() => {
|
|
10
|
-
if (!showSearch.value) return false;
|
|
11
|
-
return typeof showSearch.value === "object" ? true : !!showSearch.value;
|
|
12
|
-
});
|
|
13
|
-
return [mergedShowSearch, (0, vue.computed)(() => {
|
|
14
|
-
if (!mergedShowSearch.value) return {};
|
|
15
|
-
const { autoClearSearchValue, searchValue, onSearch } = props.value;
|
|
16
|
-
let config = {
|
|
17
|
-
matchInputWidth: true,
|
|
18
|
-
limit: 50,
|
|
19
|
-
autoClearSearchValue,
|
|
20
|
-
searchValue,
|
|
21
|
-
onSearch
|
|
22
|
-
};
|
|
23
|
-
if (showSearch.value && typeof showSearch.value === "object") config = {
|
|
24
|
-
...config,
|
|
25
|
-
...showSearch.value
|
|
26
|
-
};
|
|
27
|
-
if (config.limit <= 0) {
|
|
28
|
-
config.limit = false;
|
|
29
|
-
if (process.env.NODE_ENV !== "production") (0, _v_c_util.warning)(false, "'limit' of showSearch should be positive number or false.");
|
|
30
|
-
}
|
|
31
|
-
return config;
|
|
32
|
-
})];
|
|
33
|
-
}
|
|
34
|
-
exports.default = useSearchConfig;
|
|
@@ -1,46 +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
|
-
const SEARCH_MARK = "__vc_cascader_search_mark__";
|
|
8
|
-
var defaultFilter = (search, options, { label = "" }) => options.some((opt) => String(opt[label]).toLowerCase().includes(search.toLowerCase()));
|
|
9
|
-
var defaultRender = (_inputValue, path, _prefixCls, fieldNames) => path.map((opt) => opt[fieldNames.label]).join(" / ");
|
|
10
|
-
function useSearchOptions(search, options, fieldNames, prefixCls, config, enableHalfPath) {
|
|
11
|
-
return (0, vue.computed)(() => {
|
|
12
|
-
const mergedSearch = search.value;
|
|
13
|
-
const mergedOptions = options.value;
|
|
14
|
-
const mergedFieldNames = fieldNames.value;
|
|
15
|
-
const mergedPrefixCls = prefixCls.value;
|
|
16
|
-
const { filter = defaultFilter, render = defaultRender, limit = 50, sort } = config.value;
|
|
17
|
-
const filteredOptions = [];
|
|
18
|
-
if (!mergedSearch) return [];
|
|
19
|
-
function dig(list, pathOptions, parentDisabled = false) {
|
|
20
|
-
list.forEach((option) => {
|
|
21
|
-
if (!sort && limit !== false && limit > 0 && filteredOptions.length >= limit) return;
|
|
22
|
-
const connectedPathOptions = [...pathOptions, option];
|
|
23
|
-
const children = option[mergedFieldNames.children];
|
|
24
|
-
const mergedDisabled = parentDisabled || option.disabled;
|
|
25
|
-
if (!children || children.length === 0 || enableHalfPath?.value) {
|
|
26
|
-
if (filter?.(mergedSearch, connectedPathOptions, { label: mergedFieldNames.label })) filteredOptions.push({
|
|
27
|
-
...option,
|
|
28
|
-
disabled: mergedDisabled,
|
|
29
|
-
[mergedFieldNames.label]: render?.(mergedSearch, connectedPathOptions, mergedPrefixCls, mergedFieldNames),
|
|
30
|
-
[SEARCH_MARK]: connectedPathOptions,
|
|
31
|
-
[mergedFieldNames.children]: void 0
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (children) dig(option[mergedFieldNames.children], connectedPathOptions, mergedDisabled);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
dig(mergedOptions, []);
|
|
38
|
-
if (sort) filteredOptions.sort((a, b) => {
|
|
39
|
-
return sort(a[SEARCH_MARK], b[SEARCH_MARK], mergedSearch, mergedFieldNames);
|
|
40
|
-
});
|
|
41
|
-
return limit !== false && limit > 0 ? filteredOptions.slice(0, limit) : filteredOptions;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
var useSearchOptions_default = useSearchOptions;
|
|
45
|
-
exports.SEARCH_MARK = SEARCH_MARK;
|
|
46
|
-
exports.default = useSearchOptions_default;
|
package/dist/hooks/useSelect.cjs
DELETED
|
@@ -1,36 +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_commonUtil = require("../utils/commonUtil.cjs");
|
|
7
|
-
const require_treeUtil = require("../utils/treeUtil.cjs");
|
|
8
|
-
let _v_c_tree = require("@v-c/tree");
|
|
9
|
-
function useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy) {
|
|
10
|
-
return (valuePath) => {
|
|
11
|
-
if (!multiple.value) triggerChange(valuePath);
|
|
12
|
-
else {
|
|
13
|
-
const pathKey = require_commonUtil.toPathKey(valuePath);
|
|
14
|
-
const checkedPathKeys = require_commonUtil.toPathKeys(checkedValues.value);
|
|
15
|
-
const halfCheckedPathKeys = require_commonUtil.toPathKeys(halfCheckedValues.value);
|
|
16
|
-
const existInChecked = checkedPathKeys.includes(pathKey);
|
|
17
|
-
const existInMissing = missingCheckedValues.value.some((valueCells) => require_commonUtil.toPathKey(valueCells) === pathKey);
|
|
18
|
-
let nextCheckedValues = checkedValues.value;
|
|
19
|
-
let nextMissingValues = missingCheckedValues.value;
|
|
20
|
-
if (existInMissing && !existInChecked) nextMissingValues = missingCheckedValues.value.filter((valueCells) => require_commonUtil.toPathKey(valueCells) !== pathKey);
|
|
21
|
-
else {
|
|
22
|
-
const nextRawCheckedKeys = existInChecked ? checkedPathKeys.filter((key) => key !== pathKey) : [...checkedPathKeys, pathKey];
|
|
23
|
-
const pathKeyEntities = getPathKeyEntities();
|
|
24
|
-
let checkedKeys;
|
|
25
|
-
if (existInChecked) ({checkedKeys} = (0, _v_c_tree.conductCheck)(nextRawCheckedKeys, {
|
|
26
|
-
checked: false,
|
|
27
|
-
halfCheckedKeys: halfCheckedPathKeys
|
|
28
|
-
}, pathKeyEntities));
|
|
29
|
-
else ({checkedKeys} = (0, _v_c_tree.conductCheck)(nextRawCheckedKeys, true, pathKeyEntities));
|
|
30
|
-
nextCheckedValues = getValueByKeyPath(require_treeUtil.formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy?.value));
|
|
31
|
-
}
|
|
32
|
-
triggerChange([...nextMissingValues, ...nextCheckedValues]);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.default = useSelect;
|
package/dist/hooks/useValues.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
|
-
const require_commonUtil = require("../utils/commonUtil.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
let _v_c_tree = require("@v-c/tree");
|
|
9
|
-
function useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues) {
|
|
10
|
-
return (0, vue.computed)(() => {
|
|
11
|
-
const [existValues, missingValues] = getMissingValues(rawValues.value);
|
|
12
|
-
if (!multiple.value || !rawValues.value.length) return [
|
|
13
|
-
existValues,
|
|
14
|
-
[],
|
|
15
|
-
missingValues
|
|
16
|
-
];
|
|
17
|
-
const { checkedKeys, halfCheckedKeys } = (0, _v_c_tree.conductCheck)(require_commonUtil.toPathKeys(existValues), true, getPathKeyEntities());
|
|
18
|
-
return [
|
|
19
|
-
getValueByKeyPath(checkedKeys),
|
|
20
|
-
getValueByKeyPath(halfCheckedKeys),
|
|
21
|
-
missingValues
|
|
22
|
-
];
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.default = useValues;
|
package/dist/index.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_commonUtil = require("./utils/commonUtil.cjs");
|
|
6
|
-
const require_Cascader = require("./Cascader.cjs");
|
|
7
|
-
const require_Panel = require("./Panel.cjs");
|
|
8
|
-
var ExportCascader = require_Cascader.default;
|
|
9
|
-
ExportCascader.Panel = require_Panel.default;
|
|
10
|
-
ExportCascader.SHOW_PARENT = require_commonUtil.SHOW_PARENT;
|
|
11
|
-
ExportCascader.SHOW_CHILD = require_commonUtil.SHOW_CHILD;
|
|
12
|
-
var src_default = ExportCascader;
|
|
13
|
-
exports.Panel = require_Panel.default;
|
|
14
|
-
exports.SHOW_CHILD = require_commonUtil.SHOW_CHILD;
|
|
15
|
-
exports.SHOW_PARENT = require_commonUtil.SHOW_PARENT;
|
|
16
|
-
exports.default = src_default;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_useSearchOptions = require("../hooks/useSearchOptions.cjs");
|
|
3
|
-
const VALUE_SPLIT = "__VC_CASCADER_SPLIT__";
|
|
4
|
-
const SHOW_PARENT = "SHOW_PARENT";
|
|
5
|
-
const SHOW_CHILD = "SHOW_CHILD";
|
|
6
|
-
function toPathKey(value) {
|
|
7
|
-
return value.join(VALUE_SPLIT);
|
|
8
|
-
}
|
|
9
|
-
function toPathKeys(value) {
|
|
10
|
-
return value.map(toPathKey);
|
|
11
|
-
}
|
|
12
|
-
function toPathValueStr(pathKey) {
|
|
13
|
-
return pathKey.split(VALUE_SPLIT);
|
|
14
|
-
}
|
|
15
|
-
function fillFieldNames(fieldNames) {
|
|
16
|
-
const { label, value, children } = fieldNames || {};
|
|
17
|
-
const val = value || "value";
|
|
18
|
-
return {
|
|
19
|
-
label: label || "label",
|
|
20
|
-
value: val,
|
|
21
|
-
key: val,
|
|
22
|
-
children: children || "children"
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
function isLeaf(option, fieldNames) {
|
|
26
|
-
return option.isLeaf ?? !option[fieldNames.children]?.length;
|
|
27
|
-
}
|
|
28
|
-
function scrollIntoParentView(element) {
|
|
29
|
-
const parent = element.parentElement;
|
|
30
|
-
if (!parent) return;
|
|
31
|
-
const elementToParent = element.offsetTop - parent.offsetTop;
|
|
32
|
-
if (elementToParent - parent.scrollTop < 0) parent.scrollTo({ top: elementToParent });
|
|
33
|
-
else if (elementToParent + element.offsetHeight - parent.scrollTop > parent.offsetHeight) parent.scrollTo({ top: elementToParent + element.offsetHeight - parent.offsetHeight });
|
|
34
|
-
}
|
|
35
|
-
function getFullPathKeys(options, fieldNames) {
|
|
36
|
-
return options.map((item) => item[require_useSearchOptions.SEARCH_MARK]?.map((opt) => opt[fieldNames.value]));
|
|
37
|
-
}
|
|
38
|
-
function isMultipleValue(value) {
|
|
39
|
-
return Array.isArray(value) && Array.isArray(value[0]);
|
|
40
|
-
}
|
|
41
|
-
function toRawValues(value) {
|
|
42
|
-
if (!value) return [];
|
|
43
|
-
if (isMultipleValue(value)) return value;
|
|
44
|
-
return (value.length === 0 ? [] : [value]).map((val) => Array.isArray(val) ? val : [val]);
|
|
45
|
-
}
|
|
46
|
-
exports.SHOW_CHILD = SHOW_CHILD;
|
|
47
|
-
exports.SHOW_PARENT = SHOW_PARENT;
|
|
48
|
-
exports.VALUE_SPLIT = VALUE_SPLIT;
|
|
49
|
-
exports.fillFieldNames = fillFieldNames;
|
|
50
|
-
exports.getFullPathKeys = getFullPathKeys;
|
|
51
|
-
exports.isLeaf = isLeaf;
|
|
52
|
-
exports.scrollIntoParentView = scrollIntoParentView;
|
|
53
|
-
exports.toPathKey = toPathKey;
|
|
54
|
-
exports.toPathKeys = toPathKeys;
|
|
55
|
-
exports.toPathValueStr = toPathValueStr;
|
|
56
|
-
exports.toRawValues = toRawValues;
|
package/dist/utils/treeUtil.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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;
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|