@v-c/cascader 1.0.2 → 1.1.0-rc.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/dist/Cascader.js +8 -6
- package/dist/OptionList/Checkbox.js +5 -4
- package/dist/OptionList/Column.js +84 -89
- package/dist/OptionList/List.js +12 -12
- package/dist/OptionList/index.js +6 -4
- package/dist/OptionList/useActive.js +6 -2
- package/dist/OptionList/useKeyboard.js +3 -1
- package/dist/Panel.js +6 -4
- package/dist/context.js +2 -0
- package/dist/hooks/useDisplayValues.js +3 -1
- package/dist/hooks/useEntities.js +3 -0
- package/dist/hooks/useMissingValues.js +2 -0
- package/dist/hooks/useOptions.js +3 -0
- package/dist/hooks/useSearchConfig.js +2 -0
- package/dist/hooks/useSearchOptions.js +4 -3
- package/dist/hooks/useSelect.js +2 -0
- package/dist/hooks/useValues.js +2 -0
- package/dist/index.js +7 -6
- package/dist/utils/commonUtil.js +11 -3
- package/dist/utils/treeUtil.js +3 -1
- package/dist/utils/warningPropsUtil.js +2 -0
- package/package.json +4 -4
package/dist/Cascader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCascaderProvider } from "./context.js";
|
|
2
|
-
import
|
|
2
|
+
import useSearchOptions from "./hooks/useSearchOptions.js";
|
|
3
3
|
import { SHOW_PARENT, fillFieldNames, toPathKeys, toRawValues } from "./utils/commonUtil.js";
|
|
4
4
|
import { formatStrategyValues, toPathOptions } from "./utils/treeUtil.js";
|
|
5
5
|
import useDisplayValues_default from "./hooks/useDisplayValues.js";
|
|
@@ -8,13 +8,14 @@ import useOptions from "./hooks/useOptions.js";
|
|
|
8
8
|
import useSearchConfig from "./hooks/useSearchConfig.js";
|
|
9
9
|
import useSelect from "./hooks/useSelect.js";
|
|
10
10
|
import useValues from "./hooks/useValues.js";
|
|
11
|
-
import
|
|
11
|
+
import OptionList from "./OptionList/index.js";
|
|
12
12
|
import { warningNullOptions } from "./utils/warningPropsUtil.js";
|
|
13
13
|
import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef, watch } from "vue";
|
|
14
14
|
import { BaseSelect } from "@v-c/select";
|
|
15
15
|
import { useId, useMergedState } from "@v-c/util";
|
|
16
16
|
import useEvent from "@v-c/util/dist/hooks/useEvent";
|
|
17
17
|
import omit from "@v-c/util/dist/omit";
|
|
18
|
+
//#region src/Cascader.tsx
|
|
18
19
|
var cascaderDefaults = {
|
|
19
20
|
prefixCls: "vc-cascader",
|
|
20
21
|
expandIcon: ">",
|
|
@@ -54,7 +55,7 @@ var omitKeyList = [
|
|
|
54
55
|
"classNames",
|
|
55
56
|
"styles"
|
|
56
57
|
];
|
|
57
|
-
var
|
|
58
|
+
var Cascader = /* @__PURE__ */ defineComponent((props, { attrs, slots, expose }) => {
|
|
58
59
|
const baseSelectRef = shallowRef(null);
|
|
59
60
|
expose({
|
|
60
61
|
focus: (options) => baseSelectRef.value?.focus(options),
|
|
@@ -86,7 +87,7 @@ var Cascader_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, e
|
|
|
86
87
|
setSearchValue(searchText);
|
|
87
88
|
if (info.source !== "blur") searchConfig.value.onSearch?.(searchText);
|
|
88
89
|
};
|
|
89
|
-
const searchOptions =
|
|
90
|
+
const searchOptions = useSearchOptions(mergedSearchValue, mergedOptions, mergedFieldNames, computed(() => props.popupPrefixCls || props.prefixCls || cascaderDefaults.prefixCls), searchConfig, computed(() => !!props.changeOnSelect || multiple.value));
|
|
90
91
|
const valuesInfo = useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, useMissingValues(mergedOptions, mergedFieldNames));
|
|
91
92
|
const checkedValues = computed(() => valuesInfo.value[0]);
|
|
92
93
|
const halfCheckedValues = computed(() => valuesInfo.value[1]);
|
|
@@ -168,7 +169,7 @@ var Cascader_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, e
|
|
|
168
169
|
"searchValue": mergedSearchValue.value,
|
|
169
170
|
"onSearch": onInternalSearch,
|
|
170
171
|
"showSearch": mergedShowSearch.value,
|
|
171
|
-
"OptionList":
|
|
172
|
+
"OptionList": OptionList,
|
|
172
173
|
"emptyOptions": emptyOptions.value,
|
|
173
174
|
"open": props.open,
|
|
174
175
|
"popupClassName": props.popupClassName,
|
|
@@ -636,4 +637,5 @@ var Cascader_default = /* @__PURE__ */ defineComponent((props, { attrs, slots, e
|
|
|
636
637
|
default: void 0
|
|
637
638
|
}
|
|
638
639
|
}, cascaderDefaults) });
|
|
639
|
-
|
|
640
|
+
//#endregion
|
|
641
|
+
export { Cascader as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useCascaderContext } from "../context.js";
|
|
2
2
|
import { createVNode, defineComponent, mergeDefaults } from "vue";
|
|
3
3
|
import { clsx } from "@v-c/util";
|
|
4
|
-
|
|
4
|
+
//#region src/OptionList/Checkbox.tsx
|
|
5
|
+
var Checkbox = /* @__PURE__ */ defineComponent((props) => {
|
|
5
6
|
const context = useCascaderContext();
|
|
6
7
|
return () => {
|
|
7
8
|
const checkable = context.value?.checkable;
|
|
@@ -18,8 +19,7 @@ var Checkbox_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
18
19
|
}, { props: /* @__PURE__ */ mergeDefaults({
|
|
19
20
|
prefixCls: {
|
|
20
21
|
type: String,
|
|
21
|
-
required: true
|
|
22
|
-
default: void 0
|
|
22
|
+
required: true
|
|
23
23
|
},
|
|
24
24
|
checked: {
|
|
25
25
|
type: Boolean,
|
|
@@ -66,4 +66,5 @@ var Checkbox_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
66
66
|
disabled: false,
|
|
67
67
|
disableCheckbox: false
|
|
68
68
|
}) });
|
|
69
|
-
|
|
69
|
+
//#endregion
|
|
70
|
+
export { Checkbox as default };
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import { useCascaderContext } from "../context.js";
|
|
2
2
|
import { SEARCH_MARK } from "../hooks/useSearchOptions.js";
|
|
3
3
|
import { isLeaf, scrollIntoParentView, toPathKey } from "../utils/commonUtil.js";
|
|
4
|
-
import
|
|
4
|
+
import Checkbox from "./Checkbox.js";
|
|
5
5
|
import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, ref, watch } from "vue";
|
|
6
6
|
import { clsx } from "@v-c/util";
|
|
7
7
|
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
options: [],
|
|
12
|
-
prevValuePath: [],
|
|
13
|
-
onToggleOpen: () => {},
|
|
14
|
-
onSelect: () => {},
|
|
15
|
-
onActive: () => {},
|
|
16
|
-
checkedSet: /* @__PURE__ */ new Set(),
|
|
17
|
-
halfCheckedSet: /* @__PURE__ */ new Set(),
|
|
18
|
-
loadingKeys: [],
|
|
19
|
-
isSelectable: () => false
|
|
20
|
-
};
|
|
21
|
-
var Column_default = /* @__PURE__ */ defineComponent((props) => {
|
|
8
|
+
//#region src/OptionList/Column.tsx
|
|
9
|
+
var FIX_LABEL = "__cascader_fix_label__";
|
|
10
|
+
var Column = /* @__PURE__ */ defineComponent((props) => {
|
|
22
11
|
const menuRef = ref(null);
|
|
23
12
|
const context = useCascaderContext();
|
|
24
13
|
const menuPrefixCls = computed(() => `${props.prefixCls}-menu`);
|
|
@@ -123,7 +112,7 @@ var Column_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
123
112
|
e.preventDefault();
|
|
124
113
|
}
|
|
125
114
|
}), [
|
|
126
|
-
props.multiple && createVNode(
|
|
115
|
+
props.multiple && createVNode(Checkbox, {
|
|
127
116
|
"prefixCls": `${props.prefixCls}-checkbox`,
|
|
128
117
|
"checked": checked,
|
|
129
118
|
"halfChecked": halfChecked,
|
|
@@ -141,76 +130,82 @@ var Column_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
141
130
|
]);
|
|
142
131
|
})]);
|
|
143
132
|
};
|
|
144
|
-
}, {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
133
|
+
}, {
|
|
134
|
+
props: /* @__PURE__ */ mergeDefaults({
|
|
135
|
+
prefixCls: {
|
|
136
|
+
type: String,
|
|
137
|
+
required: true
|
|
138
|
+
},
|
|
139
|
+
multiple: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
required: false,
|
|
142
|
+
default: void 0
|
|
143
|
+
},
|
|
144
|
+
options: {
|
|
145
|
+
type: Array,
|
|
146
|
+
required: true
|
|
147
|
+
},
|
|
148
|
+
activeValue: {
|
|
149
|
+
type: [String, Number],
|
|
150
|
+
required: false,
|
|
151
|
+
default: void 0
|
|
152
|
+
},
|
|
153
|
+
prevValuePath: {
|
|
154
|
+
type: Array,
|
|
155
|
+
required: true
|
|
156
|
+
},
|
|
157
|
+
onToggleOpen: {
|
|
158
|
+
type: Function,
|
|
159
|
+
required: true
|
|
160
|
+
},
|
|
161
|
+
onSelect: {
|
|
162
|
+
type: Function,
|
|
163
|
+
required: true
|
|
164
|
+
},
|
|
165
|
+
onActive: {
|
|
166
|
+
type: Function,
|
|
167
|
+
required: true
|
|
168
|
+
},
|
|
169
|
+
checkedSet: {
|
|
170
|
+
type: Set,
|
|
171
|
+
required: true
|
|
172
|
+
},
|
|
173
|
+
halfCheckedSet: {
|
|
174
|
+
type: Set,
|
|
175
|
+
required: true
|
|
176
|
+
},
|
|
177
|
+
loadingKeys: {
|
|
178
|
+
type: Array,
|
|
179
|
+
required: true
|
|
180
|
+
},
|
|
181
|
+
isSelectable: {
|
|
182
|
+
type: Function,
|
|
183
|
+
required: true
|
|
184
|
+
},
|
|
185
|
+
disabled: {
|
|
186
|
+
type: Boolean,
|
|
187
|
+
required: false,
|
|
188
|
+
default: void 0
|
|
189
|
+
},
|
|
190
|
+
style: {
|
|
191
|
+
type: Object,
|
|
192
|
+
required: false,
|
|
193
|
+
default: void 0
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
196
|
+
prefixCls: "",
|
|
197
|
+
options: [],
|
|
198
|
+
prevValuePath: [],
|
|
199
|
+
onToggleOpen: () => {},
|
|
200
|
+
onSelect: () => {},
|
|
201
|
+
onActive: () => {},
|
|
202
|
+
checkedSet: /* @__PURE__ */ new Set(),
|
|
203
|
+
halfCheckedSet: /* @__PURE__ */ new Set(),
|
|
204
|
+
loadingKeys: [],
|
|
205
|
+
isSelectable: () => false
|
|
206
|
+
}),
|
|
207
|
+
name: "Column",
|
|
208
|
+
inheritAttrs: false
|
|
209
|
+
});
|
|
210
|
+
//#endregion
|
|
211
|
+
export { FIX_LABEL, Column as default };
|
package/dist/OptionList/List.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useCascaderContext } from "../context.js";
|
|
2
2
|
import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from "../utils/commonUtil.js";
|
|
3
3
|
import { toPathOptions } from "../utils/treeUtil.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import Column, { FIX_LABEL } from "./Column.js";
|
|
5
|
+
import useActive from "./useActive.js";
|
|
6
6
|
import useKeyboard from "./useKeyboard.js";
|
|
7
7
|
import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, onBeforeUpdate, ref, shallowRef, watch, watchEffect } from "vue";
|
|
8
8
|
import { clsx } from "@v-c/util";
|
|
9
|
-
|
|
9
|
+
//#region src/OptionList/List.tsx
|
|
10
|
+
var RawOptionList = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
10
11
|
const containerRef = ref(null);
|
|
11
12
|
const rtl = computed(() => props.direction === "rtl");
|
|
12
13
|
const context = useCascaderContext();
|
|
@@ -39,7 +40,7 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
39
40
|
});
|
|
40
41
|
const checkedSet = computed(() => new Set(toPathKeys(context.value?.values || [])));
|
|
41
42
|
const halfCheckedSet = computed(() => new Set(toPathKeys(context.value?.halfValues || [])));
|
|
42
|
-
const [activeValueCells, setActiveValueCells] =
|
|
43
|
+
const [activeValueCells, setActiveValueCells] = useActive(computed(() => !!props.multiple), computed(() => props.open));
|
|
43
44
|
const onPathOpen = (nextValueCells) => {
|
|
44
45
|
setActiveValueCells(nextValueCells);
|
|
45
46
|
internalLoadData(nextValueCells);
|
|
@@ -108,7 +109,6 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
108
109
|
disabled: true
|
|
109
110
|
}];
|
|
110
111
|
const columnProps = {
|
|
111
|
-
...props,
|
|
112
112
|
multiple: !isEmpty && props.multiple,
|
|
113
113
|
onSelect: onPathSelect,
|
|
114
114
|
onActive: onPathOpen,
|
|
@@ -116,12 +116,13 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
116
116
|
checkedSet: checkedSet.value,
|
|
117
117
|
halfCheckedSet: halfCheckedSet.value,
|
|
118
118
|
loadingKeys: loadingKeys.value,
|
|
119
|
-
isSelectable
|
|
119
|
+
isSelectable,
|
|
120
|
+
disabled: props.disabled
|
|
120
121
|
};
|
|
121
122
|
const columnNodes = (isEmpty ? [{ options: emptyList }] : optionColumns.value).map((col, index) => {
|
|
122
123
|
const prevValuePath = activeValueCells.value.slice(0, index);
|
|
123
124
|
const activeValue = activeValueCells.value[index];
|
|
124
|
-
return createVNode(
|
|
125
|
+
return createVNode(Column, mergeProps({ "key": index }, columnProps, {
|
|
125
126
|
"prefixCls": mergedPrefixCls.value,
|
|
126
127
|
"options": col.options,
|
|
127
128
|
"prevValuePath": prevValuePath,
|
|
@@ -140,8 +141,7 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
140
141
|
props: /* @__PURE__ */ mergeDefaults({
|
|
141
142
|
prefixCls: {
|
|
142
143
|
type: String,
|
|
143
|
-
required: true
|
|
144
|
-
default: void 0
|
|
144
|
+
required: true
|
|
145
145
|
},
|
|
146
146
|
multiple: {
|
|
147
147
|
type: Boolean,
|
|
@@ -155,8 +155,7 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
155
155
|
},
|
|
156
156
|
toggleOpen: {
|
|
157
157
|
type: Function,
|
|
158
|
-
required: true
|
|
159
|
-
default: void 0
|
|
158
|
+
required: true
|
|
160
159
|
},
|
|
161
160
|
notFoundContent: {
|
|
162
161
|
required: false,
|
|
@@ -195,4 +194,5 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
|
195
194
|
name: "RawOptionList",
|
|
196
195
|
inheritAttrs: false
|
|
197
196
|
});
|
|
198
|
-
|
|
197
|
+
//#endregion
|
|
198
|
+
export { RawOptionList as default };
|
package/dist/OptionList/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import RawOptionList from "./List.js";
|
|
2
2
|
import { createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
3
3
|
import { useBaseProps } from "@v-c/select";
|
|
4
|
-
|
|
4
|
+
//#region src/OptionList/index.tsx
|
|
5
|
+
var OptionList = /* @__PURE__ */ defineComponent((_, { expose }) => {
|
|
5
6
|
const baseProps = useBaseProps();
|
|
6
7
|
const listRef = shallowRef(null);
|
|
7
8
|
expose({
|
|
8
9
|
onKeyDown: (event) => listRef.value?.onKeyDown(event),
|
|
9
10
|
onKeyUp: (event) => listRef.value?.onKeyUp(event)
|
|
10
11
|
});
|
|
11
|
-
return () => createVNode(
|
|
12
|
+
return () => createVNode(RawOptionList, mergeProps(baseProps.value || {}, {
|
|
12
13
|
"lockOptions": baseProps.value?.lockOptions,
|
|
13
14
|
"ref": (el) => {
|
|
14
15
|
listRef.value = el;
|
|
@@ -18,4 +19,5 @@ var OptionList_default = /* @__PURE__ */ defineComponent((_, { expose }) => {
|
|
|
18
19
|
name: "OptionList",
|
|
19
20
|
inheritAttrs: false
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
//#endregion
|
|
23
|
+
export { OptionList as default };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useCascaderContext } from "../context.js";
|
|
2
2
|
import { ref, watch } from "vue";
|
|
3
|
+
//#region src/OptionList/useActive.ts
|
|
4
|
+
/**
|
|
5
|
+
* Control the active open options path.
|
|
6
|
+
*/
|
|
3
7
|
function useActive(multiple, open) {
|
|
4
8
|
const context = useCascaderContext();
|
|
5
9
|
const activeValueCells = ref([]);
|
|
@@ -10,5 +14,5 @@ function useActive(multiple, open) {
|
|
|
10
14
|
activeValueCells.value = next;
|
|
11
15
|
}];
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
export {
|
|
17
|
+
//#endregion
|
|
18
|
+
export { useActive as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../hooks/useSearchOptions.js";
|
|
2
2
|
import { getFullPathKeys, toPathKey } from "../utils/commonUtil.js";
|
|
3
3
|
import KeyCode from "@v-c/util/dist/KeyCode";
|
|
4
|
+
//#region src/OptionList/useKeyboard.ts
|
|
4
5
|
function useKeyboard(options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect, contextProps) {
|
|
5
6
|
const getActiveStatus = () => {
|
|
6
7
|
let activeIndex = -1;
|
|
@@ -99,4 +100,5 @@ function useKeyboard(options, fieldNames, activeValueCells, setActiveValueCells,
|
|
|
99
100
|
onKeyUp: () => {}
|
|
100
101
|
};
|
|
101
102
|
}
|
|
103
|
+
//#endregion
|
|
102
104
|
export { useKeyboard as default };
|
package/dist/Panel.js
CHANGED
|
@@ -5,10 +5,11 @@ import useMissingValues from "./hooks/useMissingValues.js";
|
|
|
5
5
|
import useOptions from "./hooks/useOptions.js";
|
|
6
6
|
import useSelect from "./hooks/useSelect.js";
|
|
7
7
|
import useValues from "./hooks/useValues.js";
|
|
8
|
-
import
|
|
8
|
+
import RawOptionList from "./OptionList/List.js";
|
|
9
9
|
import { computed, createVNode, defineComponent, mergeDefaults, shallowRef, watch } from "vue";
|
|
10
10
|
import { clsx } from "@v-c/util";
|
|
11
11
|
import useEvent from "@v-c/util/dist/hooks/useEvent";
|
|
12
|
+
//#region src/Panel.tsx
|
|
12
13
|
function noop() {}
|
|
13
14
|
var panelDefaults = {
|
|
14
15
|
prefixCls: "vc-cascader",
|
|
@@ -16,7 +17,7 @@ var panelDefaults = {
|
|
|
16
17
|
showCheckedStrategy: SHOW_PARENT,
|
|
17
18
|
notFoundContent: "Not Found"
|
|
18
19
|
};
|
|
19
|
-
var
|
|
20
|
+
var Panel = /* @__PURE__ */ defineComponent((props) => {
|
|
20
21
|
const multiple = computed(() => !!props.checkable);
|
|
21
22
|
const mergedShowCheckedStrategy = computed(() => props.showCheckedStrategy ?? panelDefaults.showCheckedStrategy);
|
|
22
23
|
const internalRawValues = shallowRef(props?.value ?? props?.defaultValue);
|
|
@@ -72,7 +73,7 @@ var Panel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
72
73
|
[`${panelPrefixCls}-empty`]: isEmpty
|
|
73
74
|
}, props.className),
|
|
74
75
|
"style": props.style
|
|
75
|
-
}, [isEmpty ? props.notFoundContent ?? panelDefaults.notFoundContent : createVNode(
|
|
76
|
+
}, [isEmpty ? props.notFoundContent ?? panelDefaults.notFoundContent : createVNode(RawOptionList, {
|
|
76
77
|
"prefixCls": props.prefixCls ?? panelDefaults.prefixCls,
|
|
77
78
|
"searchValue": "",
|
|
78
79
|
"multiple": multiple.value,
|
|
@@ -199,4 +200,5 @@ var Panel_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
199
200
|
default: void 0
|
|
200
201
|
}
|
|
201
202
|
}, panelDefaults) });
|
|
202
|
-
|
|
203
|
+
//#endregion
|
|
204
|
+
export { Panel as default };
|
package/dist/context.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inject, provide, ref } from "vue";
|
|
2
|
+
//#region src/context.ts
|
|
2
3
|
var CascaderContextKey = Symbol("CascaderContext");
|
|
3
4
|
function useCascaderProvider(value) {
|
|
4
5
|
provide(CascaderContextKey, value);
|
|
@@ -6,4 +7,5 @@ function useCascaderProvider(value) {
|
|
|
6
7
|
function useCascaderContext() {
|
|
7
8
|
return inject(CascaderContextKey, ref(null));
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
9
11
|
export { useCascaderContext, useCascaderProvider };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toPathKey } from "../utils/commonUtil.js";
|
|
2
2
|
import { toPathOptions } from "../utils/treeUtil.js";
|
|
3
3
|
import { cloneVNode, computed, isVNode } from "vue";
|
|
4
|
+
//#region src/hooks/useDisplayValues.ts
|
|
4
5
|
var useDisplayValues_default = (rawValues, options, fieldNames, multiple, displayRender) => {
|
|
5
6
|
return computed(() => {
|
|
6
7
|
const mergedDisplayRender = displayRender.value || ((labels) => {
|
|
@@ -19,7 +20,7 @@ var useDisplayValues_default = (rawValues, options, fieldNames, multiple, displa
|
|
|
19
20
|
});
|
|
20
21
|
return rawValues.value.map((valueCells) => {
|
|
21
22
|
const valueOptions = toPathOptions(valueCells, options.value, fieldNames.value);
|
|
22
|
-
const label = mergedDisplayRender(valueOptions.map(({ option, value
|
|
23
|
+
const label = mergedDisplayRender(valueOptions.map(({ option, value }) => option?.[fieldNames.value.label] ?? value), valueOptions.map(({ option }) => option));
|
|
23
24
|
const value = toPathKey(valueCells);
|
|
24
25
|
return {
|
|
25
26
|
label,
|
|
@@ -31,4 +32,5 @@ var useDisplayValues_default = (rawValues, options, fieldNames, multiple, displa
|
|
|
31
32
|
});
|
|
32
33
|
});
|
|
33
34
|
};
|
|
35
|
+
//#endregion
|
|
34
36
|
export { useDisplayValues_default as default };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { VALUE_SPLIT } from "../utils/commonUtil.js";
|
|
2
2
|
import { shallowRef } from "vue";
|
|
3
3
|
import { convertDataToEntities } from "@v-c/tree";
|
|
4
|
+
//#region src/hooks/useEntities.ts
|
|
5
|
+
/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */
|
|
4
6
|
function useEntities(options, fieldNames) {
|
|
5
7
|
const cacheRef = shallowRef({
|
|
6
8
|
options: [],
|
|
@@ -33,4 +35,5 @@ function useEntities(options, fieldNames) {
|
|
|
33
35
|
};
|
|
34
36
|
return getEntities;
|
|
35
37
|
}
|
|
38
|
+
//#endregion
|
|
36
39
|
export { useEntities as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toPathOptions } from "../utils/treeUtil.js";
|
|
2
|
+
//#region src/hooks/useMissingValues.ts
|
|
2
3
|
function useMissingValues(options, fieldNames) {
|
|
3
4
|
return (rawValues) => {
|
|
4
5
|
const missingValues = [];
|
|
@@ -10,4 +11,5 @@ function useMissingValues(options, fieldNames) {
|
|
|
10
11
|
return [existsValues, missingValues];
|
|
11
12
|
};
|
|
12
13
|
}
|
|
14
|
+
//#endregion
|
|
13
15
|
export { useMissingValues as default };
|
package/dist/hooks/useOptions.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import useEntities from "./useEntities.js";
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
//#region src/hooks/useOptions.ts
|
|
3
4
|
function useOptions(mergedFieldNames, options) {
|
|
4
5
|
const emptyOptions = [];
|
|
5
6
|
const mergedOptions = computed(() => options.value || emptyOptions);
|
|
6
7
|
const getPathKeyEntities = useEntities(mergedOptions, mergedFieldNames);
|
|
8
|
+
/** Convert path key back to value format */
|
|
7
9
|
const getValueByKeyPath = (pathKeys) => {
|
|
8
10
|
const keyPathEntities = getPathKeyEntities();
|
|
9
11
|
return pathKeys.map((pathKey) => {
|
|
@@ -17,4 +19,5 @@ function useOptions(mergedFieldNames, options) {
|
|
|
17
19
|
getValueByKeyPath
|
|
18
20
|
];
|
|
19
21
|
}
|
|
22
|
+
//#endregion
|
|
20
23
|
export { useOptions as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { warning } from "@v-c/util";
|
|
3
|
+
//#region src/hooks/useSearchConfig.ts
|
|
3
4
|
function useSearchConfig(showSearch, props) {
|
|
4
5
|
const mergedShowSearch = computed(() => {
|
|
5
6
|
if (!showSearch.value) return false;
|
|
@@ -26,4 +27,5 @@ function useSearchConfig(showSearch, props) {
|
|
|
26
27
|
return config;
|
|
27
28
|
})];
|
|
28
29
|
}
|
|
30
|
+
//#endregion
|
|
29
31
|
export { useSearchConfig as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
-
|
|
2
|
+
//#region src/hooks/useSearchOptions.ts
|
|
3
|
+
var SEARCH_MARK = "__vc_cascader_search_mark__";
|
|
3
4
|
var defaultFilter = (search, options, { label = "" }) => options.some((opt) => String(opt[label]).toLowerCase().includes(search.toLowerCase()));
|
|
4
5
|
var defaultRender = (_inputValue, path, _prefixCls, fieldNames) => path.map((opt) => opt[fieldNames.label]).join(" / ");
|
|
5
6
|
function useSearchOptions(search, options, fieldNames, prefixCls, config, enableHalfPath) {
|
|
@@ -36,5 +37,5 @@ function useSearchOptions(search, options, fieldNames, prefixCls, config, enable
|
|
|
36
37
|
return limit !== false && limit > 0 ? filteredOptions.slice(0, limit) : filteredOptions;
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
export { SEARCH_MARK,
|
|
40
|
+
//#endregion
|
|
41
|
+
export { SEARCH_MARK, useSearchOptions as default };
|
package/dist/hooks/useSelect.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toPathKey, toPathKeys } from "../utils/commonUtil.js";
|
|
2
2
|
import { formatStrategyValues } from "../utils/treeUtil.js";
|
|
3
3
|
import { conductCheck } from "@v-c/tree";
|
|
4
|
+
//#region src/hooks/useSelect.ts
|
|
4
5
|
function useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy) {
|
|
5
6
|
return (valuePath) => {
|
|
6
7
|
if (!multiple.value) triggerChange(valuePath);
|
|
@@ -28,4 +29,5 @@ function useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, mi
|
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
}
|
|
32
|
+
//#endregion
|
|
31
33
|
export { useSelect as default };
|
package/dist/hooks/useValues.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toPathKeys } from "../utils/commonUtil.js";
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { conductCheck } from "@v-c/tree";
|
|
4
|
+
//#region src/hooks/useValues.ts
|
|
4
5
|
function useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues) {
|
|
5
6
|
return computed(() => {
|
|
6
7
|
const [existValues, missingValues] = getMissingValues(rawValues.value);
|
|
@@ -17,4 +18,5 @@ function useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, g
|
|
|
17
18
|
];
|
|
18
19
|
});
|
|
19
20
|
}
|
|
21
|
+
//#endregion
|
|
20
22
|
export { useValues as default };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SHOW_CHILD, SHOW_PARENT } from "./utils/commonUtil.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
ExportCascader
|
|
2
|
+
import Cascader from "./Cascader.js";
|
|
3
|
+
import Panel from "./Panel.js";
|
|
4
|
+
//#region src/index.tsx
|
|
5
|
+
var ExportCascader = Cascader;
|
|
6
|
+
ExportCascader.Panel = Panel;
|
|
6
7
|
ExportCascader.SHOW_PARENT = SHOW_PARENT;
|
|
7
8
|
ExportCascader.SHOW_CHILD = SHOW_CHILD;
|
|
8
|
-
|
|
9
|
-
export {
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Panel, SHOW_CHILD, SHOW_PARENT, ExportCascader as default };
|
package/dist/utils/commonUtil.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { SEARCH_MARK } from "../hooks/useSearchOptions.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
//#region src/utils/commonUtil.ts
|
|
3
|
+
var VALUE_SPLIT = "__VC_CASCADER_SPLIT__";
|
|
4
|
+
var SHOW_PARENT = "SHOW_PARENT";
|
|
5
|
+
var SHOW_CHILD = "SHOW_CHILD";
|
|
6
|
+
/**
|
|
7
|
+
* Will convert value to string, and join with `VALUE_SPLIT`
|
|
8
|
+
*/
|
|
5
9
|
function toPathKey(value) {
|
|
6
10
|
return value.join(VALUE_SPLIT);
|
|
7
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Batch convert value to string, and join with `VALUE_SPLIT`
|
|
14
|
+
*/
|
|
8
15
|
function toPathKeys(value) {
|
|
9
16
|
return value.map(toPathKey);
|
|
10
17
|
}
|
|
@@ -42,4 +49,5 @@ function toRawValues(value) {
|
|
|
42
49
|
if (isMultipleValue(value)) return value;
|
|
43
50
|
return (value.length === 0 ? [] : [value]).map((val) => Array.isArray(val) ? val : [val]);
|
|
44
51
|
}
|
|
52
|
+
//#endregion
|
|
45
53
|
export { SHOW_CHILD, SHOW_PARENT, VALUE_SPLIT, fillFieldNames, getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr, toRawValues };
|
package/dist/utils/treeUtil.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./commonUtil.js";
|
|
2
|
+
//#region src/utils/treeUtil.ts
|
|
2
3
|
function formatStrategyValues(pathKeys, getKeyPathEntities, showCheckedStrategy) {
|
|
3
4
|
const valueSet = new Set(pathKeys);
|
|
4
5
|
const keyPathEntities = getKeyPathEntities();
|
|
@@ -29,4 +30,5 @@ function toPathOptions(valueCells, options, fieldNames, stringMode = false) {
|
|
|
29
30
|
}
|
|
30
31
|
return valueOptions;
|
|
31
32
|
}
|
|
33
|
+
//#endregion
|
|
32
34
|
export { formatStrategyValues, toPathOptions };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { warning } from "@v-c/util";
|
|
2
|
+
//#region src/utils/warningPropsUtil.ts
|
|
2
3
|
function warningNullOptions(options, fieldNames) {
|
|
3
4
|
if (options) {
|
|
4
5
|
const recursiveOptions = (optionsList) => {
|
|
@@ -14,4 +15,5 @@ function warningNullOptions(options, fieldNames) {
|
|
|
14
15
|
recursiveOptions(options);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
18
|
+
//#endregion
|
|
17
19
|
export { warningNullOptions };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/cascader",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.1.0-rc.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"vue": "^3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@v-c/select": "^1.0.
|
|
28
|
-
"@v-c/tree": "^1.0.
|
|
29
|
-
"@v-c/util": "^1.0.
|
|
27
|
+
"@v-c/select": "^1.0.23",
|
|
28
|
+
"@v-c/tree": "^1.1.0-rc.1",
|
|
29
|
+
"@v-c/util": "^1.0.19"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "vite build",
|