@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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Cascader.cjs +647 -0
  3. package/dist/Cascader.d.ts +90 -0
  4. package/dist/Cascader.js +639 -0
  5. package/dist/OptionList/CacheContent.cjs +38 -0
  6. package/dist/OptionList/CacheContent.d.ts +7 -0
  7. package/dist/OptionList/CacheContent.js +32 -0
  8. package/dist/OptionList/Checkbox.cjs +75 -0
  9. package/dist/OptionList/Checkbox.d.ts +12 -0
  10. package/dist/OptionList/Checkbox.js +69 -0
  11. package/dist/OptionList/Column.cjs +223 -0
  12. package/dist/OptionList/Column.d.ts +23 -0
  13. package/dist/OptionList/Column.js +215 -0
  14. package/dist/OptionList/List.cjs +195 -0
  15. package/dist/OptionList/List.d.ts +12 -0
  16. package/dist/OptionList/List.js +189 -0
  17. package/dist/OptionList/index.cjs +24 -0
  18. package/dist/OptionList/index.d.ts +2 -0
  19. package/dist/OptionList/index.js +18 -0
  20. package/dist/OptionList/useActive.cjs +19 -0
  21. package/dist/OptionList/useActive.d.ts +7 -0
  22. package/dist/OptionList/useActive.js +14 -0
  23. package/dist/OptionList/useKeyboard.cjs +108 -0
  24. package/dist/OptionList/useKeyboard.d.ts +9 -0
  25. package/dist/OptionList/useKeyboard.js +102 -0
  26. package/dist/Panel.cjs +209 -0
  27. package/dist/Panel.d.ts +5 -0
  28. package/dist/Panel.js +202 -0
  29. package/dist/_virtual/rolldown_runtime.cjs +21 -0
  30. package/dist/context.cjs +12 -0
  31. package/dist/context.d.ts +23 -0
  32. package/dist/context.js +9 -0
  33. package/dist/hooks/useDisplayValues.cjs +39 -0
  34. package/dist/hooks/useDisplayValues.d.ts +4 -0
  35. package/dist/hooks/useDisplayValues.js +34 -0
  36. package/dist/hooks/useEntities.cjs +41 -0
  37. package/dist/hooks/useEntities.d.ts +10 -0
  38. package/dist/hooks/useEntities.js +36 -0
  39. package/dist/hooks/useMissingValues.cjs +17 -0
  40. package/dist/hooks/useMissingValues.d.ts +4 -0
  41. package/dist/hooks/useMissingValues.js +13 -0
  42. package/dist/hooks/useOptions.cjs +25 -0
  43. package/dist/hooks/useOptions.d.ts +9 -0
  44. package/dist/hooks/useOptions.js +20 -0
  45. package/dist/hooks/useSearchConfig.cjs +34 -0
  46. package/dist/hooks/useSearchConfig.d.ts +4 -0
  47. package/dist/hooks/useSearchConfig.js +29 -0
  48. package/dist/hooks/useSearchOptions.cjs +46 -0
  49. package/dist/hooks/useSearchOptions.d.ts +5 -0
  50. package/dist/hooks/useSearchOptions.js +40 -0
  51. package/dist/hooks/useSelect.cjs +36 -0
  52. package/dist/hooks/useSelect.d.ts +4 -0
  53. package/dist/hooks/useSelect.js +31 -0
  54. package/dist/hooks/useValues.cjs +25 -0
  55. package/dist/hooks/useValues.d.ts +9 -0
  56. package/dist/hooks/useValues.js +20 -0
  57. package/dist/index.cjs +16 -0
  58. package/dist/index.d.ts +12 -0
  59. package/dist/index.js +9 -0
  60. package/dist/utils/commonUtil.cjs +56 -0
  61. package/dist/utils/commonUtil.d.ts +18 -0
  62. package/dist/utils/commonUtil.js +45 -0
  63. package/dist/utils/treeUtil.cjs +34 -0
  64. package/dist/utils/treeUtil.d.ts +8 -0
  65. package/dist/utils/treeUtil.js +32 -0
  66. package/dist/utils/warningPropsUtil.cjs +19 -0
  67. package/dist/utils/warningPropsUtil.d.ts +2 -0
  68. package/dist/utils/warningPropsUtil.js +17 -0
  69. package/package.json +38 -0
@@ -0,0 +1,102 @@
1
+ import { SEARCH_MARK } from "../hooks/useSearchOptions.js";
2
+ import { getFullPathKeys, toPathKey } from "../utils/commonUtil.js";
3
+ import KeyCode from "@v-c/util/dist/KeyCode";
4
+ function useKeyboard(options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect, contextProps) {
5
+ const getActiveStatus = () => {
6
+ let activeIndex = -1;
7
+ let currentOptions = options.value;
8
+ const mergedActiveIndexes = [];
9
+ const mergedActiveValueCells = [];
10
+ const len = activeValueCells.value.length;
11
+ const pathKeys = getFullPathKeys(options.value, fieldNames.value);
12
+ for (let i = 0; i < len && currentOptions; i += 1) {
13
+ const nextActiveIndex = currentOptions.findIndex((option, index) => (pathKeys[index] ? toPathKey(pathKeys[index]) : option[fieldNames.value.value]) === activeValueCells.value[i]);
14
+ if (nextActiveIndex === -1) break;
15
+ activeIndex = nextActiveIndex;
16
+ mergedActiveIndexes.push(activeIndex);
17
+ mergedActiveValueCells.push(activeValueCells.value[i]);
18
+ currentOptions = currentOptions[activeIndex]?.[fieldNames.value.children];
19
+ }
20
+ let activeOptions = options.value;
21
+ for (let i = 0; i < mergedActiveIndexes.length - 1; i += 1) activeOptions = activeOptions[mergedActiveIndexes[i]]?.[fieldNames.value.children] || [];
22
+ return {
23
+ validActiveValueCells: mergedActiveValueCells,
24
+ lastActiveIndex: activeIndex,
25
+ lastActiveOptions: activeOptions,
26
+ fullPathKeys: pathKeys
27
+ };
28
+ };
29
+ const internalSetActiveValueCells = (next) => {
30
+ setActiveValueCells(next);
31
+ };
32
+ const offsetActiveOption = (offset) => {
33
+ const { lastActiveOptions, lastActiveIndex, fullPathKeys, validActiveValueCells } = getActiveStatus();
34
+ const len = lastActiveOptions.length;
35
+ let currentIndex = lastActiveIndex;
36
+ if (currentIndex === -1 && offset < 0) currentIndex = len;
37
+ for (let i = 0; i < len; i += 1) {
38
+ currentIndex = (currentIndex + offset + len) % len;
39
+ const option = lastActiveOptions[currentIndex];
40
+ if (option && !option.disabled) {
41
+ internalSetActiveValueCells(validActiveValueCells.slice(0, -1).concat(fullPathKeys[currentIndex] ? toPathKey(fullPathKeys[currentIndex]) : option[fieldNames.value.value]));
42
+ return;
43
+ }
44
+ }
45
+ };
46
+ const prevColumn = () => {
47
+ const { validActiveValueCells } = getActiveStatus();
48
+ if (validActiveValueCells.length > 1) internalSetActiveValueCells(validActiveValueCells.slice(0, -1));
49
+ else contextProps.toggleOpen(false);
50
+ };
51
+ const nextColumn = () => {
52
+ const { lastActiveOptions, lastActiveIndex, validActiveValueCells } = getActiveStatus();
53
+ const nextOption = (lastActiveOptions[lastActiveIndex]?.[fieldNames.value.children] || []).find((option) => !option.disabled);
54
+ if (nextOption) internalSetActiveValueCells([...validActiveValueCells, nextOption[fieldNames.value.value]]);
55
+ };
56
+ return {
57
+ scrollTo: () => {},
58
+ onKeyDown: (event) => {
59
+ const { which } = event;
60
+ const rtl = contextProps.direction.value === "rtl";
61
+ const searchValue = contextProps.searchValue.value;
62
+ const open = contextProps.open.value;
63
+ switch (which) {
64
+ case KeyCode.UP:
65
+ case KeyCode.DOWN: {
66
+ let offset = 0;
67
+ if (which === KeyCode.UP) offset = -1;
68
+ else if (which === KeyCode.DOWN) offset = 1;
69
+ if (offset !== 0) offsetActiveOption(offset);
70
+ break;
71
+ }
72
+ case KeyCode.LEFT:
73
+ if (searchValue) break;
74
+ if (rtl) nextColumn();
75
+ else prevColumn();
76
+ break;
77
+ case KeyCode.RIGHT:
78
+ if (searchValue) break;
79
+ if (rtl) prevColumn();
80
+ else nextColumn();
81
+ break;
82
+ case KeyCode.BACKSPACE:
83
+ if (!searchValue) prevColumn();
84
+ break;
85
+ case KeyCode.ENTER: {
86
+ const { validActiveValueCells, lastActiveOptions, lastActiveIndex } = getActiveStatus();
87
+ if (validActiveValueCells.length) {
88
+ const originOptions = lastActiveOptions[lastActiveIndex]?.["__vc_cascader_search_mark__"] || [];
89
+ if (originOptions.length) onKeyBoardSelect(originOptions.map((opt) => opt[fieldNames.value.value]), originOptions[originOptions.length - 1]);
90
+ else onKeyBoardSelect(validActiveValueCells, lastActiveOptions[lastActiveIndex]);
91
+ }
92
+ break;
93
+ }
94
+ case KeyCode.ESC:
95
+ contextProps.toggleOpen(false);
96
+ if (open) event.stopPropagation();
97
+ }
98
+ },
99
+ onKeyUp: () => {}
100
+ };
101
+ }
102
+ export { useKeyboard as default };
package/dist/Panel.cjs ADDED
@@ -0,0 +1,209 @@
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;
@@ -0,0 +1,5 @@
1
+ import { CascaderProps, DefaultOptionType } from './Cascader';
2
+ export type PickType = 'value' | 'defaultValue' | 'changeOnSelect' | 'onChange' | 'options' | 'prefixCls' | 'checkable' | 'fieldNames' | 'showCheckedStrategy' | 'loadData' | 'expandTrigger' | 'expandIcon' | 'loadingIcon' | 'className' | 'style' | 'direction' | 'notFoundContent' | 'disabled' | 'optionRender';
3
+ export type PanelProps<OptionType extends DefaultOptionType = DefaultOptionType, ValueField extends keyof OptionType = keyof OptionType, Multiple extends boolean | any = false> = Pick<CascaderProps<OptionType, ValueField, Multiple>, PickType>;
4
+ declare const Panel: import('vue').DefineSetupFnComponent<PanelProps<DefaultOptionType, string, false>, {}, {}, PanelProps<DefaultOptionType, string, false> & {}, import('vue').PublicProps>;
5
+ export default Panel;
package/dist/Panel.js ADDED
@@ -0,0 +1,202 @@
1
+ import { useCascaderProvider } from "./context.js";
2
+ import { SHOW_PARENT, fillFieldNames, toRawValues } from "./utils/commonUtil.js";
3
+ import { toPathOptions } from "./utils/treeUtil.js";
4
+ import useMissingValues from "./hooks/useMissingValues.js";
5
+ import useOptions from "./hooks/useOptions.js";
6
+ import useSelect from "./hooks/useSelect.js";
7
+ import useValues from "./hooks/useValues.js";
8
+ import List_default from "./OptionList/List.js";
9
+ import { computed, createVNode, defineComponent, mergeDefaults, shallowRef, watch } from "vue";
10
+ import { clsx } from "@v-c/util";
11
+ import useEvent from "@v-c/util/dist/hooks/useEvent";
12
+ function noop() {}
13
+ var panelDefaults = {
14
+ prefixCls: "vc-cascader",
15
+ expandIcon: ">",
16
+ showCheckedStrategy: SHOW_PARENT,
17
+ notFoundContent: "Not Found"
18
+ };
19
+ var Panel_default = /* @__PURE__ */ defineComponent((props) => {
20
+ const multiple = computed(() => !!props.checkable);
21
+ const mergedShowCheckedStrategy = computed(() => props.showCheckedStrategy ?? panelDefaults.showCheckedStrategy);
22
+ const internalRawValues = shallowRef(props?.value ?? props?.defaultValue);
23
+ watch(() => props.value, () => {
24
+ internalRawValues.value = props?.value;
25
+ });
26
+ const setRawValues = (values) => {
27
+ internalRawValues.value = values;
28
+ };
29
+ const rawValues = computed(() => toRawValues(internalRawValues.value));
30
+ const mergedFieldNames = computed(() => fillFieldNames(props.fieldNames));
31
+ const [mergedOptions, getPathKeyEntities, getValueByKeyPath] = useOptions(mergedFieldNames, computed(() => props.options));
32
+ const valuesInfo = useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, useMissingValues(mergedOptions, mergedFieldNames));
33
+ const checkedValues = computed(() => valuesInfo.value[0]);
34
+ const halfCheckedValues = computed(() => valuesInfo.value[1]);
35
+ const missingCheckedValues = computed(() => valuesInfo.value[2]);
36
+ const handleSelection = useSelect(multiple, useEvent((nextValues) => {
37
+ setRawValues(nextValues);
38
+ if (props.onChange) {
39
+ const nextRawValues = toRawValues(nextValues);
40
+ const valueOptions = nextRawValues.map((valueCells) => toPathOptions(valueCells, mergedOptions.value, mergedFieldNames.value).map((valueOpt) => valueOpt.option));
41
+ const triggerValues = multiple.value ? nextRawValues : nextRawValues[0];
42
+ const triggerOptions = multiple.value ? valueOptions : valueOptions[0];
43
+ props.onChange(triggerValues, triggerOptions);
44
+ }
45
+ }), checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, mergedShowCheckedStrategy);
46
+ const onInternalSelect = useEvent((valuePath) => {
47
+ handleSelection(valuePath);
48
+ });
49
+ useCascaderProvider(computed(() => ({
50
+ options: mergedOptions.value,
51
+ fieldNames: mergedFieldNames.value,
52
+ values: checkedValues.value,
53
+ halfValues: halfCheckedValues.value,
54
+ changeOnSelect: props.changeOnSelect,
55
+ onSelect: onInternalSelect,
56
+ checkable: props.checkable,
57
+ searchOptions: [],
58
+ popupPrefixCls: void 0,
59
+ loadData: props.loadData,
60
+ expandTrigger: props.expandTrigger,
61
+ expandIcon: props.expandIcon !== void 0 ? props.expandIcon : panelDefaults.expandIcon,
62
+ loadingIcon: props.loadingIcon,
63
+ popupMenuColumnStyle: void 0,
64
+ optionRender: props.optionRender
65
+ })));
66
+ return () => {
67
+ const panelPrefixCls = `${props.prefixCls ?? panelDefaults.prefixCls}-panel`;
68
+ const isEmpty = !mergedOptions.value.length;
69
+ return createVNode("div", {
70
+ "class": clsx(panelPrefixCls, {
71
+ [`${panelPrefixCls}-rtl`]: props.direction === "rtl",
72
+ [`${panelPrefixCls}-empty`]: isEmpty
73
+ }, props.className),
74
+ "style": props.style
75
+ }, [isEmpty ? props.notFoundContent ?? panelDefaults.notFoundContent : createVNode(List_default, {
76
+ "prefixCls": props.prefixCls ?? panelDefaults.prefixCls,
77
+ "searchValue": "",
78
+ "multiple": multiple.value,
79
+ "toggleOpen": noop,
80
+ "open": true,
81
+ "direction": props.direction,
82
+ "disabled": props.disabled
83
+ }, null)]);
84
+ };
85
+ }, { props: /* @__PURE__ */ mergeDefaults({
86
+ value: {
87
+ required: false,
88
+ default: void 0
89
+ },
90
+ defaultValue: {
91
+ required: false,
92
+ default: void 0
93
+ },
94
+ changeOnSelect: {
95
+ type: Boolean,
96
+ required: false,
97
+ default: void 0
98
+ },
99
+ onChange: {
100
+ type: Function,
101
+ required: false,
102
+ default: void 0
103
+ },
104
+ options: {
105
+ type: Array,
106
+ required: false,
107
+ default: void 0
108
+ },
109
+ prefixCls: {
110
+ type: String,
111
+ required: false,
112
+ default: void 0
113
+ },
114
+ checkable: {
115
+ required: false,
116
+ default: void 0
117
+ },
118
+ fieldNames: {
119
+ type: Object,
120
+ required: false,
121
+ default: void 0
122
+ },
123
+ showCheckedStrategy: {
124
+ required: false,
125
+ default: void 0
126
+ },
127
+ loadData: {
128
+ type: Function,
129
+ required: false,
130
+ default: void 0
131
+ },
132
+ expandTrigger: {
133
+ type: String,
134
+ required: false,
135
+ default: void 0
136
+ },
137
+ expandIcon: {
138
+ type: [
139
+ Object,
140
+ Function,
141
+ String,
142
+ Number,
143
+ null,
144
+ Boolean,
145
+ Array
146
+ ],
147
+ required: false,
148
+ default: void 0
149
+ },
150
+ loadingIcon: {
151
+ type: [
152
+ Object,
153
+ Function,
154
+ String,
155
+ Number,
156
+ null,
157
+ Boolean,
158
+ Array
159
+ ],
160
+ required: false,
161
+ default: void 0
162
+ },
163
+ className: {
164
+ type: String,
165
+ required: false,
166
+ default: void 0
167
+ },
168
+ style: {
169
+ type: Object,
170
+ required: false,
171
+ default: void 0
172
+ },
173
+ direction: {
174
+ type: String,
175
+ required: false,
176
+ default: void 0
177
+ },
178
+ notFoundContent: {
179
+ type: [
180
+ Object,
181
+ Function,
182
+ String,
183
+ Number,
184
+ null,
185
+ Boolean,
186
+ Array
187
+ ],
188
+ required: false,
189
+ default: void 0
190
+ },
191
+ disabled: {
192
+ type: Boolean,
193
+ required: false,
194
+ default: void 0
195
+ },
196
+ optionRender: {
197
+ type: Function,
198
+ required: false,
199
+ default: void 0
200
+ }
201
+ }, panelDefaults) });
202
+ export { Panel_default as default };
@@ -0,0 +1,21 @@
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;
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,23 @@
1
+ import { Ref } from 'vue';
2
+ import { CascaderProps, DefaultOptionType, InternalFieldNames, SingleValueType } from './Cascader';
3
+ export interface CascaderContextProps {
4
+ options: NonNullable<CascaderProps['options']>;
5
+ fieldNames: InternalFieldNames;
6
+ values: SingleValueType[];
7
+ halfValues: SingleValueType[];
8
+ changeOnSelect?: boolean;
9
+ onSelect: (valuePath: SingleValueType) => void;
10
+ checkable?: boolean | any;
11
+ searchOptions: DefaultOptionType[];
12
+ popupPrefixCls?: string;
13
+ loadData?: (selectOptions: DefaultOptionType[]) => void;
14
+ expandTrigger?: 'hover' | 'click';
15
+ expandIcon?: any;
16
+ loadingIcon?: any;
17
+ popupMenuColumnStyle?: CascaderProps['popupMenuColumnStyle'];
18
+ optionRender?: CascaderProps['optionRender'];
19
+ classNames?: CascaderProps['classNames'];
20
+ styles?: CascaderProps['styles'];
21
+ }
22
+ export declare function useCascaderProvider(value: Ref<CascaderContextProps>): void;
23
+ export declare function useCascaderContext(): Ref<CascaderContextProps | null>;
@@ -0,0 +1,9 @@
1
+ import { inject, provide, ref } from "vue";
2
+ var CascaderContextKey = Symbol("CascaderContext");
3
+ function useCascaderProvider(value) {
4
+ provide(CascaderContextKey, value);
5
+ }
6
+ function useCascaderContext() {
7
+ return inject(CascaderContextKey, ref(null));
8
+ }
9
+ export { useCascaderContext, useCascaderProvider };
@@ -0,0 +1,39 @@
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;
@@ -0,0 +1,4 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { CascaderProps, DefaultOptionType, InternalFieldNames, SingleValueType } from '../Cascader';
3
+ declare const _default: (rawValues: Ref<SingleValueType[]>, options: Ref<DefaultOptionType[]>, fieldNames: Ref<InternalFieldNames>, multiple: Ref<boolean>, displayRender: Ref<CascaderProps["displayRender"] | undefined>) => ComputedRef<any[]>;
4
+ export default _default;
@@ -0,0 +1,34 @@
1
+ import { toPathKey } from "../utils/commonUtil.js";
2
+ import { toPathOptions } from "../utils/treeUtil.js";
3
+ import { cloneVNode, computed, isVNode } from "vue";
4
+ var useDisplayValues_default = (rawValues, options, fieldNames, multiple, displayRender) => {
5
+ return computed(() => {
6
+ const mergedDisplayRender = displayRender.value || ((labels) => {
7
+ const mergedLabels = multiple.value ? labels.slice(-1) : labels;
8
+ const split = " / ";
9
+ if (mergedLabels.every((label) => ["string", "number"].includes(typeof label))) return mergedLabels.join(split);
10
+ return mergedLabels.reduce((list, label, index) => {
11
+ const nextLabel = isVNode(label) ? cloneVNode(label, { key: index }) : label;
12
+ if (index === 0) return [nextLabel];
13
+ return [
14
+ ...list,
15
+ split,
16
+ nextLabel
17
+ ];
18
+ }, []);
19
+ });
20
+ return rawValues.value.map((valueCells) => {
21
+ const valueOptions = toPathOptions(valueCells, options.value, fieldNames.value);
22
+ const label = mergedDisplayRender(valueOptions.map(({ option, value: value$1 }) => option?.[fieldNames.value.label] ?? value$1), valueOptions.map(({ option }) => option));
23
+ const value = toPathKey(valueCells);
24
+ return {
25
+ label,
26
+ value,
27
+ key: value,
28
+ valueCells,
29
+ disabled: valueOptions[valueOptions.length - 1]?.option?.disabled
30
+ };
31
+ });
32
+ });
33
+ };
34
+ export { useDisplayValues_default as default };