@rc-component/tree-select 1.0.0
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.md +22 -0
- package/README.md +140 -0
- package/assets/icons.png +0 -0
- package/assets/index.less +2 -0
- package/assets/loading.gif +0 -0
- package/assets/minus.gif +0 -0
- package/assets/select.less +3 -0
- package/assets/tree.less +3 -0
- package/dist/223.90c7e648.async.js +3 -0
- package/dist/338.a2a48f3b.async.js +15 -0
- package/dist/338.e8c51481.chunk.css +5 -0
- package/dist/404.html +20 -0
- package/dist/439.67bede3f.async.js +137 -0
- package/dist/929.df8dd03f.async.js +32 -0
- package/dist/demo/basic/index.html +20 -0
- package/dist/demo/big-data/index.html +20 -0
- package/dist/demo/controlled/index.html +20 -0
- package/dist/demo/custom-icons/index.html +20 -0
- package/dist/demo/debug/index.html +20 -0
- package/dist/demo/disable/index.html +20 -0
- package/dist/demo/dynamic/index.html +20 -0
- package/dist/demo/field-names/index.html +20 -0
- package/dist/demo/filter/index.html +20 -0
- package/dist/demo/form/index.html +20 -0
- package/dist/demo/mutiple-with-max-count/index.html +20 -0
- package/dist/demo/tree-node-label-prop/index.html +20 -0
- package/dist/demo/width/index.html +20 -0
- package/dist/demos.f221b577.async.js +1 -0
- package/dist/docs__demo__basic.md.bcb0edb7.async.js +1 -0
- package/dist/docs__demo__big-data.md.8783cd6b.async.js +1 -0
- package/dist/docs__demo__controlled.md.e65ef7d7.async.js +1 -0
- package/dist/docs__demo__custom-icons.md.d53bf2f9.async.js +1 -0
- package/dist/docs__demo__debug.md.099ad226.async.js +1 -0
- package/dist/docs__demo__disable.md.6ba57652.async.js +1 -0
- package/dist/docs__demo__dynamic.md.f7559890.async.js +1 -0
- package/dist/docs__demo__fieldNames.md.16131d9f.async.js +1 -0
- package/dist/docs__demo__filter.md.02527db4.async.js +1 -0
- package/dist/docs__demo__form.md.6b77dffe.async.js +1 -0
- package/dist/docs__demo__mutiple-with-maxCount.md.7268d4ad.async.js +1 -0
- package/dist/docs__demo__treeNodeLabelProp.md.24709916.async.js +1 -0
- package/dist/docs__demo__width.md.24bfecd6.async.js +1 -0
- package/dist/docs__index.md.a6e45331.async.js +1 -0
- package/dist/dumi__tmp-production__dumi__theme__ContextWrapper.f56a0670.async.js +1 -0
- package/dist/index.html +20 -0
- package/dist/meta__docs.255fc42b.chunk.css +1 -0
- package/dist/meta__docs.dbf04b66.async.js +3359 -0
- package/dist/nm__dumi__dist__client__pages__404.8b85f2d9.chunk.css +1 -0
- package/dist/nm__dumi__dist__client__pages__404.ca2add38.async.js +1 -0
- package/dist/nm__dumi__dist__client__pages__Demo__index.29e9ef8f.async.js +1 -0
- package/dist/nm__dumi__dist__client__pages__Demo__index.578aa5c0.chunk.css +1 -0
- package/dist/nm__dumi__theme-default__layouts__DocLayout__index.8ed833d7.async.js +1 -0
- package/dist/preload_helper.d41c4da0.js +1 -0
- package/dist/umi.4f47b921.js +124 -0
- package/dist/umi.8faca2de.css +1 -0
- package/dist/~demos/:id/index.html +20 -0
- package/dist/~demos/docs-demo-basic-demo-basic/index.html +20 -0
- package/dist/~demos/docs-demo-big-data-demo-big-data/index.html +20 -0
- package/dist/~demos/docs-demo-controlled-demo-controlled/index.html +20 -0
- package/dist/~demos/docs-demo-custom-icons-demo-custom-icons/index.html +20 -0
- package/dist/~demos/docs-demo-debug-demo-debug/index.html +20 -0
- package/dist/~demos/docs-demo-disable-demo-disable/index.html +20 -0
- package/dist/~demos/docs-demo-dynamic-demo-dynamic/index.html +20 -0
- package/dist/~demos/docs-demo-field-names-demo-fieldnames/index.html +20 -0
- package/dist/~demos/docs-demo-filter-demo-filter/index.html +20 -0
- package/dist/~demos/docs-demo-form-demo-form/index.html +20 -0
- package/dist/~demos/docs-demo-mutiple-with-max-count-demo-mutiple-with-maxcount/index.html +20 -0
- package/dist/~demos/docs-demo-tree-node-label-prop-demo-treenodelabelprop/index.html +20 -0
- package/dist/~demos/docs-demo-width-demo-width/index.html +20 -0
- package/es/LegacyContext.d.ts +24 -0
- package/es/LegacyContext.js +3 -0
- package/es/OptionList.d.ts +8 -0
- package/es/OptionList.js +351 -0
- package/es/TreeNode.d.ts +9 -0
- package/es/TreeNode.js +5 -0
- package/es/TreeSelect.d.ts +65 -0
- package/es/TreeSelect.js +507 -0
- package/es/TreeSelectContext.d.ts +25 -0
- package/es/TreeSelectContext.js +3 -0
- package/es/hooks/useCache.d.ts +7 -0
- package/es/hooks/useCache.js +32 -0
- package/es/hooks/useCheckedKeys.d.ts +5 -0
- package/es/hooks/useCheckedKeys.js +21 -0
- package/es/hooks/useDataEntities.d.ts +7 -0
- package/es/hooks/useDataEntities.js +26 -0
- package/es/hooks/useFilterTreeData.d.ts +8 -0
- package/es/hooks/useFilterTreeData.js +33 -0
- package/es/hooks/useRefFunc.d.ts +5 -0
- package/es/hooks/useRefFunc.js +14 -0
- package/es/hooks/useTreeData.d.ts +7 -0
- package/es/hooks/useTreeData.js +52 -0
- package/es/index.d.ts +7 -0
- package/es/index.js +5 -0
- package/es/interface.d.ts +57 -0
- package/es/interface.js +1 -0
- package/es/utils/legacyUtil.d.ts +5 -0
- package/es/utils/legacyUtil.js +120 -0
- package/es/utils/strategyUtil.d.ts +7 -0
- package/es/utils/strategyUtil.js +25 -0
- package/es/utils/valueUtil.d.ts +11 -0
- package/es/utils/valueUtil.js +30 -0
- package/es/utils/warningPropsUtil.d.ts +5 -0
- package/es/utils/warningPropsUtil.js +30 -0
- package/lib/LegacyContext.d.ts +24 -0
- package/lib/LegacyContext.js +11 -0
- package/lib/OptionList.d.ts +8 -0
- package/lib/OptionList.js +359 -0
- package/lib/TreeNode.d.ts +9 -0
- package/lib/TreeNode.js +11 -0
- package/lib/TreeSelect.d.ts +65 -0
- package/lib/TreeSelect.js +516 -0
- package/lib/TreeSelectContext.d.ts +25 -0
- package/lib/TreeSelectContext.js +11 -0
- package/lib/hooks/useCache.d.ts +7 -0
- package/lib/hooks/useCache.js +41 -0
- package/lib/hooks/useCheckedKeys.d.ts +5 -0
- package/lib/hooks/useCheckedKeys.js +29 -0
- package/lib/hooks/useDataEntities.d.ts +7 -0
- package/lib/hooks/useDataEntities.js +36 -0
- package/lib/hooks/useFilterTreeData.d.ts +8 -0
- package/lib/hooks/useFilterTreeData.js +41 -0
- package/lib/hooks/useRefFunc.d.ts +5 -0
- package/lib/hooks/useRefFunc.js +21 -0
- package/lib/hooks/useTreeData.d.ts +7 -0
- package/lib/hooks/useTreeData.js +60 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +35 -0
- package/lib/interface.d.ts +57 -0
- package/lib/interface.js +5 -0
- package/lib/utils/legacyUtil.d.ts +5 -0
- package/lib/utils/legacyUtil.js +131 -0
- package/lib/utils/strategyUtil.d.ts +7 -0
- package/lib/utils/strategyUtil.js +32 -0
- package/lib/utils/valueUtil.d.ts +11 -0
- package/lib/utils/valueUtil.js +41 -0
- package/lib/utils/warningPropsUtil.d.ts +5 -0
- package/lib/utils/warningPropsUtil.js +37 -0
- package/package.json +89 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _select = require("@rc-component/select");
|
|
8
|
+
var _useId = _interopRequireDefault(require("@rc-component/select/lib/hooks/useId"));
|
|
9
|
+
var _conductUtil = require("rc-tree/lib/utils/conductUtil");
|
|
10
|
+
var _useMergedState = _interopRequireDefault(require("@rc-component/util/lib/hooks/useMergedState"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _useCache = _interopRequireDefault(require("./hooks/useCache"));
|
|
13
|
+
var _useCheckedKeys = _interopRequireDefault(require("./hooks/useCheckedKeys"));
|
|
14
|
+
var _useDataEntities = _interopRequireDefault(require("./hooks/useDataEntities"));
|
|
15
|
+
var _useFilterTreeData = _interopRequireDefault(require("./hooks/useFilterTreeData"));
|
|
16
|
+
var _useRefFunc = _interopRequireDefault(require("./hooks/useRefFunc"));
|
|
17
|
+
var _useTreeData = _interopRequireDefault(require("./hooks/useTreeData"));
|
|
18
|
+
var _LegacyContext = _interopRequireDefault(require("./LegacyContext"));
|
|
19
|
+
var _OptionList = _interopRequireDefault(require("./OptionList"));
|
|
20
|
+
var _TreeNode = _interopRequireDefault(require("./TreeNode"));
|
|
21
|
+
var _TreeSelectContext = _interopRequireDefault(require("./TreeSelectContext"));
|
|
22
|
+
var _legacyUtil = require("./utils/legacyUtil");
|
|
23
|
+
var _strategyUtil = require("./utils/strategyUtil");
|
|
24
|
+
var _valueUtil = require("./utils/valueUtil");
|
|
25
|
+
var _warningPropsUtil = _interopRequireDefault(require("./utils/warningPropsUtil"));
|
|
26
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
30
|
+
function isRawValue(value) {
|
|
31
|
+
return !value || typeof value !== 'object';
|
|
32
|
+
}
|
|
33
|
+
const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
34
|
+
const {
|
|
35
|
+
id,
|
|
36
|
+
prefixCls = 'rc-tree-select',
|
|
37
|
+
// Value
|
|
38
|
+
value,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onChange,
|
|
41
|
+
onSelect,
|
|
42
|
+
onDeselect,
|
|
43
|
+
// Search
|
|
44
|
+
searchValue,
|
|
45
|
+
inputValue,
|
|
46
|
+
onSearch,
|
|
47
|
+
autoClearSearchValue = true,
|
|
48
|
+
filterTreeNode,
|
|
49
|
+
treeNodeFilterProp = 'value',
|
|
50
|
+
// Selector
|
|
51
|
+
showCheckedStrategy,
|
|
52
|
+
treeNodeLabelProp,
|
|
53
|
+
// Mode
|
|
54
|
+
multiple,
|
|
55
|
+
treeCheckable,
|
|
56
|
+
treeCheckStrictly,
|
|
57
|
+
labelInValue,
|
|
58
|
+
maxCount,
|
|
59
|
+
// FieldNames
|
|
60
|
+
fieldNames,
|
|
61
|
+
// Data
|
|
62
|
+
treeDataSimpleMode,
|
|
63
|
+
treeData,
|
|
64
|
+
children,
|
|
65
|
+
loadData,
|
|
66
|
+
treeLoadedKeys,
|
|
67
|
+
onTreeLoad,
|
|
68
|
+
// Expanded
|
|
69
|
+
treeDefaultExpandAll,
|
|
70
|
+
treeExpandedKeys,
|
|
71
|
+
treeDefaultExpandedKeys,
|
|
72
|
+
onTreeExpand,
|
|
73
|
+
treeExpandAction,
|
|
74
|
+
// Options
|
|
75
|
+
virtual,
|
|
76
|
+
listHeight = 200,
|
|
77
|
+
listItemHeight = 20,
|
|
78
|
+
listItemScrollOffset = 0,
|
|
79
|
+
onPopupVisibleChange,
|
|
80
|
+
popupMatchSelectWidth = true,
|
|
81
|
+
// Tree
|
|
82
|
+
treeLine,
|
|
83
|
+
treeIcon,
|
|
84
|
+
showTreeIcon,
|
|
85
|
+
switcherIcon,
|
|
86
|
+
treeMotion,
|
|
87
|
+
treeTitleRender,
|
|
88
|
+
onPopupScroll,
|
|
89
|
+
...restProps
|
|
90
|
+
} = props;
|
|
91
|
+
const mergedId = (0, _useId.default)(id);
|
|
92
|
+
const treeConduction = treeCheckable && !treeCheckStrictly;
|
|
93
|
+
const mergedCheckable = treeCheckable || treeCheckStrictly;
|
|
94
|
+
const mergedLabelInValue = treeCheckStrictly || labelInValue;
|
|
95
|
+
const mergedMultiple = mergedCheckable || multiple;
|
|
96
|
+
const [internalValue, setInternalValue] = (0, _useMergedState.default)(defaultValue, {
|
|
97
|
+
value
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// `multiple` && `!treeCheckable` should be show all
|
|
101
|
+
const mergedShowCheckedStrategy = React.useMemo(() => {
|
|
102
|
+
if (!treeCheckable) {
|
|
103
|
+
return _strategyUtil.SHOW_ALL;
|
|
104
|
+
}
|
|
105
|
+
return showCheckedStrategy || _strategyUtil.SHOW_CHILD;
|
|
106
|
+
}, [showCheckedStrategy, treeCheckable]);
|
|
107
|
+
|
|
108
|
+
// ========================== Warning ===========================
|
|
109
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
110
|
+
(0, _warningPropsUtil.default)(props);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ========================= FieldNames =========================
|
|
114
|
+
const mergedFieldNames = React.useMemo(() => (0, _valueUtil.fillFieldNames)(fieldNames), /* eslint-disable react-hooks/exhaustive-deps */
|
|
115
|
+
[JSON.stringify(fieldNames)]
|
|
116
|
+
/* eslint-enable react-hooks/exhaustive-deps */);
|
|
117
|
+
|
|
118
|
+
// =========================== Search ===========================
|
|
119
|
+
const [mergedSearchValue, setSearchValue] = (0, _useMergedState.default)('', {
|
|
120
|
+
value: searchValue !== undefined ? searchValue : inputValue,
|
|
121
|
+
postState: search => search || ''
|
|
122
|
+
});
|
|
123
|
+
const onInternalSearch = searchText => {
|
|
124
|
+
setSearchValue(searchText);
|
|
125
|
+
onSearch?.(searchText);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// ============================ Data ============================
|
|
129
|
+
// `useTreeData` only do convert of `children` or `simpleMode`.
|
|
130
|
+
// Else will return origin `treeData` for perf consideration.
|
|
131
|
+
// Do not do anything to loop the data.
|
|
132
|
+
const mergedTreeData = (0, _useTreeData.default)(treeData, children, treeDataSimpleMode);
|
|
133
|
+
const {
|
|
134
|
+
keyEntities,
|
|
135
|
+
valueEntities
|
|
136
|
+
} = (0, _useDataEntities.default)(mergedTreeData, mergedFieldNames);
|
|
137
|
+
|
|
138
|
+
/** Get `missingRawValues` which not exist in the tree yet */
|
|
139
|
+
const splitRawValues = React.useCallback(newRawValues => {
|
|
140
|
+
const missingRawValues = [];
|
|
141
|
+
const existRawValues = [];
|
|
142
|
+
|
|
143
|
+
// Keep missing value in the cache
|
|
144
|
+
newRawValues.forEach(val => {
|
|
145
|
+
if (valueEntities.has(val)) {
|
|
146
|
+
existRawValues.push(val);
|
|
147
|
+
} else {
|
|
148
|
+
missingRawValues.push(val);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
missingRawValues,
|
|
153
|
+
existRawValues
|
|
154
|
+
};
|
|
155
|
+
}, [valueEntities]);
|
|
156
|
+
|
|
157
|
+
// Filtered Tree
|
|
158
|
+
const filteredTreeData = (0, _useFilterTreeData.default)(mergedTreeData, mergedSearchValue, {
|
|
159
|
+
fieldNames: mergedFieldNames,
|
|
160
|
+
treeNodeFilterProp,
|
|
161
|
+
filterTreeNode
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// =========================== Label ============================
|
|
165
|
+
const getLabel = React.useCallback(item => {
|
|
166
|
+
if (item) {
|
|
167
|
+
if (treeNodeLabelProp) {
|
|
168
|
+
return item[treeNodeLabelProp];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Loop from fieldNames
|
|
172
|
+
const {
|
|
173
|
+
_title: titleList
|
|
174
|
+
} = mergedFieldNames;
|
|
175
|
+
for (let i = 0; i < titleList.length; i += 1) {
|
|
176
|
+
const title = item[titleList[i]];
|
|
177
|
+
if (title !== undefined) {
|
|
178
|
+
return title;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, [mergedFieldNames, treeNodeLabelProp]);
|
|
183
|
+
|
|
184
|
+
// ========================= Wrap Value =========================
|
|
185
|
+
const toLabeledValues = React.useCallback(draftValues => {
|
|
186
|
+
const values = (0, _valueUtil.toArray)(draftValues);
|
|
187
|
+
return values.map(val => {
|
|
188
|
+
if (isRawValue(val)) {
|
|
189
|
+
return {
|
|
190
|
+
value: val
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return val;
|
|
194
|
+
});
|
|
195
|
+
}, []);
|
|
196
|
+
const convert2LabelValues = React.useCallback(draftValues => {
|
|
197
|
+
const values = toLabeledValues(draftValues);
|
|
198
|
+
return values.map(item => {
|
|
199
|
+
let {
|
|
200
|
+
label: rawLabel
|
|
201
|
+
} = item;
|
|
202
|
+
const {
|
|
203
|
+
value: rawValue,
|
|
204
|
+
halfChecked: rawHalfChecked
|
|
205
|
+
} = item;
|
|
206
|
+
let rawDisabled;
|
|
207
|
+
const entity = valueEntities.get(rawValue);
|
|
208
|
+
|
|
209
|
+
// Fill missing label & status
|
|
210
|
+
if (entity) {
|
|
211
|
+
rawLabel = treeTitleRender ? treeTitleRender(entity.node) : rawLabel ?? getLabel(entity.node);
|
|
212
|
+
rawDisabled = entity.node.disabled;
|
|
213
|
+
} else if (rawLabel === undefined) {
|
|
214
|
+
// We try to find in current `labelInValue` value
|
|
215
|
+
const labelInValueItem = toLabeledValues(internalValue).find(labeledItem => labeledItem.value === rawValue);
|
|
216
|
+
rawLabel = labelInValueItem.label;
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
label: rawLabel,
|
|
220
|
+
value: rawValue,
|
|
221
|
+
halfChecked: rawHalfChecked,
|
|
222
|
+
disabled: rawDisabled
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
}, [valueEntities, getLabel, toLabeledValues, internalValue]);
|
|
226
|
+
|
|
227
|
+
// =========================== Values ===========================
|
|
228
|
+
const rawMixedLabeledValues = React.useMemo(() => toLabeledValues(internalValue === null ? [] : internalValue), [toLabeledValues, internalValue]);
|
|
229
|
+
|
|
230
|
+
// Split value into full check and half check
|
|
231
|
+
const [rawLabeledValues, rawHalfLabeledValues] = React.useMemo(() => {
|
|
232
|
+
const fullCheckValues = [];
|
|
233
|
+
const halfCheckValues = [];
|
|
234
|
+
rawMixedLabeledValues.forEach(item => {
|
|
235
|
+
if (item.halfChecked) {
|
|
236
|
+
halfCheckValues.push(item);
|
|
237
|
+
} else {
|
|
238
|
+
fullCheckValues.push(item);
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return [fullCheckValues, halfCheckValues];
|
|
242
|
+
}, [rawMixedLabeledValues]);
|
|
243
|
+
|
|
244
|
+
// const [mergedValues] = useCache(rawLabeledValues);
|
|
245
|
+
const rawValues = React.useMemo(() => rawLabeledValues.map(item => item.value), [rawLabeledValues]);
|
|
246
|
+
|
|
247
|
+
// Convert value to key. Will fill missed keys for conduct check.
|
|
248
|
+
const [rawCheckedValues, rawHalfCheckedValues] = (0, _useCheckedKeys.default)(rawLabeledValues, rawHalfLabeledValues, treeConduction, keyEntities);
|
|
249
|
+
|
|
250
|
+
// Convert rawCheckedKeys to check strategy related values
|
|
251
|
+
const displayValues = React.useMemo(() => {
|
|
252
|
+
// Collect keys which need to show
|
|
253
|
+
const displayKeys = (0, _strategyUtil.formatStrategyValues)(rawCheckedValues, mergedShowCheckedStrategy, keyEntities, mergedFieldNames);
|
|
254
|
+
|
|
255
|
+
// Convert to value and filled with label
|
|
256
|
+
const values = displayKeys.map(key => keyEntities[key]?.node?.[mergedFieldNames.value] ?? key);
|
|
257
|
+
|
|
258
|
+
// Back fill with origin label
|
|
259
|
+
const labeledValues = values.map(val => {
|
|
260
|
+
const targetItem = rawLabeledValues.find(item => item.value === val);
|
|
261
|
+
const label = labelInValue ? targetItem?.label : treeTitleRender?.(targetItem);
|
|
262
|
+
return {
|
|
263
|
+
value: val,
|
|
264
|
+
label
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
const rawDisplayValues = convert2LabelValues(labeledValues);
|
|
268
|
+
const firstVal = rawDisplayValues[0];
|
|
269
|
+
if (!mergedMultiple && firstVal && (0, _valueUtil.isNil)(firstVal.value) && (0, _valueUtil.isNil)(firstVal.label)) {
|
|
270
|
+
return [];
|
|
271
|
+
}
|
|
272
|
+
return rawDisplayValues.map(item => ({
|
|
273
|
+
...item,
|
|
274
|
+
label: item.label ?? item.value
|
|
275
|
+
}));
|
|
276
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
277
|
+
}, [mergedFieldNames, mergedMultiple, rawCheckedValues, rawLabeledValues, convert2LabelValues, mergedShowCheckedStrategy, keyEntities]);
|
|
278
|
+
const [cachedDisplayValues] = (0, _useCache.default)(displayValues);
|
|
279
|
+
|
|
280
|
+
// ========================== MaxCount ==========================
|
|
281
|
+
const mergedMaxCount = React.useMemo(() => {
|
|
282
|
+
if (mergedMultiple && (mergedShowCheckedStrategy === 'SHOW_CHILD' || treeCheckStrictly || !treeCheckable)) {
|
|
283
|
+
return maxCount;
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
}, [maxCount, mergedMultiple, treeCheckStrictly, mergedShowCheckedStrategy, treeCheckable]);
|
|
287
|
+
|
|
288
|
+
// =========================== Change ===========================
|
|
289
|
+
const triggerChange = (0, _useRefFunc.default)((newRawValues, extra, source) => {
|
|
290
|
+
const formattedKeyList = (0, _strategyUtil.formatStrategyValues)(newRawValues, mergedShowCheckedStrategy, keyEntities, mergedFieldNames);
|
|
291
|
+
|
|
292
|
+
// Not allow pass with `maxCount`
|
|
293
|
+
if (mergedMaxCount && formattedKeyList.length > mergedMaxCount) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const labeledValues = convert2LabelValues(newRawValues);
|
|
297
|
+
setInternalValue(labeledValues);
|
|
298
|
+
|
|
299
|
+
// Clean up if needed
|
|
300
|
+
if (autoClearSearchValue) {
|
|
301
|
+
setSearchValue('');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Generate rest parameters is costly, so only do it when necessary
|
|
305
|
+
if (onChange) {
|
|
306
|
+
let eventValues = newRawValues;
|
|
307
|
+
if (treeConduction) {
|
|
308
|
+
eventValues = formattedKeyList.map(key => {
|
|
309
|
+
const entity = valueEntities.get(key);
|
|
310
|
+
return entity ? entity.node[mergedFieldNames.value] : key;
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
const {
|
|
314
|
+
triggerValue,
|
|
315
|
+
selected
|
|
316
|
+
} = extra || {
|
|
317
|
+
triggerValue: undefined,
|
|
318
|
+
selected: undefined
|
|
319
|
+
};
|
|
320
|
+
let returnRawValues = eventValues;
|
|
321
|
+
|
|
322
|
+
// We need fill half check back
|
|
323
|
+
if (treeCheckStrictly) {
|
|
324
|
+
const halfValues = rawHalfLabeledValues.filter(item => !eventValues.includes(item.value));
|
|
325
|
+
returnRawValues = [...returnRawValues, ...halfValues];
|
|
326
|
+
}
|
|
327
|
+
const returnLabeledValues = convert2LabelValues(returnRawValues);
|
|
328
|
+
const additionalInfo = {
|
|
329
|
+
// [Legacy] Always return as array contains label & value
|
|
330
|
+
preValue: rawLabeledValues,
|
|
331
|
+
triggerValue
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// [Legacy] Fill legacy data if user query.
|
|
335
|
+
// This is expansive that we only fill when user query
|
|
336
|
+
// https://github.com/react-component/tree-select/blob/fe33eb7c27830c9ac70cd1fdb1ebbe7bc679c16a/src/Select.jsx
|
|
337
|
+
let showPosition = true;
|
|
338
|
+
if (treeCheckStrictly || source === 'selection' && !selected) {
|
|
339
|
+
showPosition = false;
|
|
340
|
+
}
|
|
341
|
+
(0, _legacyUtil.fillAdditionalInfo)(additionalInfo, triggerValue, newRawValues, mergedTreeData, showPosition, mergedFieldNames);
|
|
342
|
+
if (mergedCheckable) {
|
|
343
|
+
additionalInfo.checked = selected;
|
|
344
|
+
} else {
|
|
345
|
+
additionalInfo.selected = selected;
|
|
346
|
+
}
|
|
347
|
+
const returnValues = mergedLabelInValue ? returnLabeledValues : returnLabeledValues.map(item => item.value);
|
|
348
|
+
onChange(mergedMultiple ? returnValues : returnValues[0], mergedLabelInValue ? null : returnLabeledValues.map(item => item.label), additionalInfo);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// ========================== Options ===========================
|
|
353
|
+
/** Trigger by option list */
|
|
354
|
+
const onOptionSelect = React.useCallback((selectedKey, {
|
|
355
|
+
selected,
|
|
356
|
+
source
|
|
357
|
+
}) => {
|
|
358
|
+
const entity = keyEntities[selectedKey];
|
|
359
|
+
const node = entity?.node;
|
|
360
|
+
const selectedValue = node?.[mergedFieldNames.value] ?? selectedKey;
|
|
361
|
+
|
|
362
|
+
// Never be falsy but keep it safe
|
|
363
|
+
if (!mergedMultiple) {
|
|
364
|
+
// Single mode always set value
|
|
365
|
+
triggerChange([selectedValue], {
|
|
366
|
+
selected: true,
|
|
367
|
+
triggerValue: selectedValue
|
|
368
|
+
}, 'option');
|
|
369
|
+
} else {
|
|
370
|
+
let newRawValues = selected ? [...rawValues, selectedValue] : rawCheckedValues.filter(v => v !== selectedValue);
|
|
371
|
+
|
|
372
|
+
// Add keys if tree conduction
|
|
373
|
+
if (treeConduction) {
|
|
374
|
+
// Should keep missing values
|
|
375
|
+
const {
|
|
376
|
+
missingRawValues,
|
|
377
|
+
existRawValues
|
|
378
|
+
} = splitRawValues(newRawValues);
|
|
379
|
+
const keyList = existRawValues.map(val => valueEntities.get(val).key);
|
|
380
|
+
|
|
381
|
+
// Conduction by selected or not
|
|
382
|
+
let checkedKeys;
|
|
383
|
+
if (selected) {
|
|
384
|
+
({
|
|
385
|
+
checkedKeys
|
|
386
|
+
} = (0, _conductUtil.conductCheck)(keyList, true, keyEntities));
|
|
387
|
+
} else {
|
|
388
|
+
({
|
|
389
|
+
checkedKeys
|
|
390
|
+
} = (0, _conductUtil.conductCheck)(keyList, {
|
|
391
|
+
checked: false,
|
|
392
|
+
halfCheckedKeys: rawHalfCheckedValues
|
|
393
|
+
}, keyEntities));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Fill back of keys
|
|
397
|
+
newRawValues = [...missingRawValues, ...checkedKeys.map(key => keyEntities[key].node[mergedFieldNames.value])];
|
|
398
|
+
}
|
|
399
|
+
triggerChange(newRawValues, {
|
|
400
|
+
selected,
|
|
401
|
+
triggerValue: selectedValue
|
|
402
|
+
}, source || 'option');
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Trigger select event
|
|
406
|
+
if (selected || !mergedMultiple) {
|
|
407
|
+
onSelect?.(selectedValue, (0, _legacyUtil.fillLegacyProps)(node));
|
|
408
|
+
} else {
|
|
409
|
+
onDeselect?.(selectedValue, (0, _legacyUtil.fillLegacyProps)(node));
|
|
410
|
+
}
|
|
411
|
+
}, [splitRawValues, valueEntities, keyEntities, mergedFieldNames, mergedMultiple, rawValues, triggerChange, treeConduction, onSelect, onDeselect, rawCheckedValues, rawHalfCheckedValues, maxCount]);
|
|
412
|
+
|
|
413
|
+
// ========================== Dropdown ==========================
|
|
414
|
+
const onInternalPopupVisibleChange = React.useCallback(open => {
|
|
415
|
+
if (onPopupVisibleChange) {
|
|
416
|
+
onPopupVisibleChange(open);
|
|
417
|
+
}
|
|
418
|
+
}, [onPopupVisibleChange]);
|
|
419
|
+
|
|
420
|
+
// ====================== Display Change ========================
|
|
421
|
+
const onDisplayValuesChange = (0, _useRefFunc.default)((newValues, info) => {
|
|
422
|
+
const newRawValues = newValues.map(item => item.value);
|
|
423
|
+
if (info.type === 'clear') {
|
|
424
|
+
triggerChange(newRawValues, {}, 'selection');
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// TreeSelect only have multiple mode which means display change only has remove
|
|
429
|
+
if (info.values.length) {
|
|
430
|
+
onOptionSelect(info.values[0].value, {
|
|
431
|
+
selected: false,
|
|
432
|
+
source: 'selection'
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// ========================== Context ===========================
|
|
438
|
+
const treeSelectContext = React.useMemo(() => {
|
|
439
|
+
return {
|
|
440
|
+
virtual,
|
|
441
|
+
popupMatchSelectWidth,
|
|
442
|
+
listHeight,
|
|
443
|
+
listItemHeight,
|
|
444
|
+
listItemScrollOffset,
|
|
445
|
+
treeData: filteredTreeData,
|
|
446
|
+
fieldNames: mergedFieldNames,
|
|
447
|
+
onSelect: onOptionSelect,
|
|
448
|
+
treeExpandAction,
|
|
449
|
+
treeTitleRender,
|
|
450
|
+
onPopupScroll,
|
|
451
|
+
leftMaxCount: maxCount === undefined ? null : maxCount - cachedDisplayValues.length,
|
|
452
|
+
leafCountOnly: mergedShowCheckedStrategy === 'SHOW_CHILD' && !treeCheckStrictly && !!treeCheckable,
|
|
453
|
+
valueEntities
|
|
454
|
+
};
|
|
455
|
+
}, [virtual, popupMatchSelectWidth, listHeight, listItemHeight, listItemScrollOffset, filteredTreeData, mergedFieldNames, onOptionSelect, treeExpandAction, treeTitleRender, onPopupScroll, maxCount, cachedDisplayValues.length, mergedShowCheckedStrategy, treeCheckStrictly, treeCheckable, valueEntities]);
|
|
456
|
+
|
|
457
|
+
// ======================= Legacy Context =======================
|
|
458
|
+
const legacyContext = React.useMemo(() => ({
|
|
459
|
+
checkable: mergedCheckable,
|
|
460
|
+
loadData,
|
|
461
|
+
treeLoadedKeys,
|
|
462
|
+
onTreeLoad,
|
|
463
|
+
checkedKeys: rawCheckedValues,
|
|
464
|
+
halfCheckedKeys: rawHalfCheckedValues,
|
|
465
|
+
treeDefaultExpandAll,
|
|
466
|
+
treeExpandedKeys,
|
|
467
|
+
treeDefaultExpandedKeys,
|
|
468
|
+
onTreeExpand,
|
|
469
|
+
treeIcon,
|
|
470
|
+
treeMotion,
|
|
471
|
+
showTreeIcon,
|
|
472
|
+
switcherIcon,
|
|
473
|
+
treeLine,
|
|
474
|
+
treeNodeFilterProp,
|
|
475
|
+
keyEntities
|
|
476
|
+
}), [mergedCheckable, loadData, treeLoadedKeys, onTreeLoad, rawCheckedValues, rawHalfCheckedValues, treeDefaultExpandAll, treeExpandedKeys, treeDefaultExpandedKeys, onTreeExpand, treeIcon, treeMotion, showTreeIcon, switcherIcon, treeLine, treeNodeFilterProp, keyEntities]);
|
|
477
|
+
|
|
478
|
+
// =========================== Render ===========================
|
|
479
|
+
return /*#__PURE__*/React.createElement(_TreeSelectContext.default.Provider, {
|
|
480
|
+
value: treeSelectContext
|
|
481
|
+
}, /*#__PURE__*/React.createElement(_LegacyContext.default.Provider, {
|
|
482
|
+
value: legacyContext
|
|
483
|
+
}, /*#__PURE__*/React.createElement(_select.BaseSelect, _extends({
|
|
484
|
+
ref: ref
|
|
485
|
+
}, restProps, {
|
|
486
|
+
// >>> MISC
|
|
487
|
+
id: mergedId,
|
|
488
|
+
prefixCls: prefixCls,
|
|
489
|
+
mode: mergedMultiple ? 'multiple' : undefined
|
|
490
|
+
// >>> Display Value
|
|
491
|
+
,
|
|
492
|
+
displayValues: cachedDisplayValues,
|
|
493
|
+
onDisplayValuesChange: onDisplayValuesChange
|
|
494
|
+
// >>> Search
|
|
495
|
+
,
|
|
496
|
+
searchValue: mergedSearchValue,
|
|
497
|
+
onSearch: onInternalSearch
|
|
498
|
+
// >>> Options
|
|
499
|
+
,
|
|
500
|
+
OptionList: _OptionList.default,
|
|
501
|
+
emptyOptions: !mergedTreeData.length,
|
|
502
|
+
onPopupVisibleChange: onInternalPopupVisibleChange,
|
|
503
|
+
popupMatchSelectWidth: popupMatchSelectWidth
|
|
504
|
+
}))));
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
// Assign name for Debug
|
|
508
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
509
|
+
TreeSelect.displayName = 'TreeSelect';
|
|
510
|
+
}
|
|
511
|
+
const GenericTreeSelect = TreeSelect;
|
|
512
|
+
GenericTreeSelect.TreeNode = _TreeNode.default;
|
|
513
|
+
GenericTreeSelect.SHOW_ALL = _strategyUtil.SHOW_ALL;
|
|
514
|
+
GenericTreeSelect.SHOW_PARENT = _strategyUtil.SHOW_PARENT;
|
|
515
|
+
GenericTreeSelect.SHOW_CHILD = _strategyUtil.SHOW_CHILD;
|
|
516
|
+
var _default = exports.default = GenericTreeSelect;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ExpandAction } from 'rc-tree/lib/Tree';
|
|
3
|
+
import type { DataNode, FieldNames, Key } from './interface';
|
|
4
|
+
import type useDataEntities from './hooks/useDataEntities';
|
|
5
|
+
export interface TreeSelectContextProps {
|
|
6
|
+
virtual?: boolean;
|
|
7
|
+
popupMatchSelectWidth?: boolean | number;
|
|
8
|
+
listHeight: number;
|
|
9
|
+
listItemHeight: number;
|
|
10
|
+
listItemScrollOffset?: number;
|
|
11
|
+
treeData: DataNode[];
|
|
12
|
+
fieldNames: FieldNames;
|
|
13
|
+
onSelect: (value: Key, info: {
|
|
14
|
+
selected: boolean;
|
|
15
|
+
}) => void;
|
|
16
|
+
treeExpandAction?: ExpandAction;
|
|
17
|
+
treeTitleRender?: (node: any) => React.ReactNode;
|
|
18
|
+
onPopupScroll?: React.UIEventHandler<HTMLDivElement>;
|
|
19
|
+
leftMaxCount: number | null;
|
|
20
|
+
/** When `true`, only take leaf node as count, or take all as count with `maxCount` limitation */
|
|
21
|
+
leafCountOnly: boolean;
|
|
22
|
+
valueEntities: ReturnType<typeof useDataEntities>['valueEntities'];
|
|
23
|
+
}
|
|
24
|
+
declare const TreeSelectContext: React.Context<TreeSelectContextProps>;
|
|
25
|
+
export default TreeSelectContext;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
const TreeSelectContext = /*#__PURE__*/React.createContext(null);
|
|
11
|
+
var _default = exports.default = TreeSelectContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LabeledValueType } from '../interface';
|
|
2
|
+
/**
|
|
3
|
+
* This function will try to call requestIdleCallback if available to save performance.
|
|
4
|
+
* No need `getLabel` here since already fetch on `rawLabeledValue`.
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: (values: LabeledValueType[]) => [LabeledValueType[]];
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
/**
|
|
11
|
+
* This function will try to call requestIdleCallback if available to save performance.
|
|
12
|
+
* No need `getLabel` here since already fetch on `rawLabeledValue`.
|
|
13
|
+
*/
|
|
14
|
+
var _default = values => {
|
|
15
|
+
const cacheRef = React.useRef({
|
|
16
|
+
valueLabels: new Map()
|
|
17
|
+
});
|
|
18
|
+
return React.useMemo(() => {
|
|
19
|
+
const {
|
|
20
|
+
valueLabels
|
|
21
|
+
} = cacheRef.current;
|
|
22
|
+
const valueLabelsCache = new Map();
|
|
23
|
+
const filledValues = values.map(item => {
|
|
24
|
+
const {
|
|
25
|
+
value,
|
|
26
|
+
label
|
|
27
|
+
} = item;
|
|
28
|
+
const mergedLabel = label ?? valueLabels.get(value);
|
|
29
|
+
|
|
30
|
+
// Save in cache
|
|
31
|
+
valueLabelsCache.set(value, mergedLabel);
|
|
32
|
+
return {
|
|
33
|
+
...item,
|
|
34
|
+
label: mergedLabel
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
cacheRef.current.valueLabels = valueLabelsCache;
|
|
38
|
+
return [filledValues];
|
|
39
|
+
}, [values]);
|
|
40
|
+
};
|
|
41
|
+
exports.default = _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { DataEntity } from 'rc-tree/lib/interface';
|
|
3
|
+
import type { LabeledValueType, SafeKey } from '../interface';
|
|
4
|
+
declare const useCheckedKeys: (rawLabeledValues: LabeledValueType[], rawHalfCheckedValues: LabeledValueType[], treeConduction: boolean, keyEntities: Record<SafeKey, DataEntity>) => React.Key[][];
|
|
5
|
+
export default useCheckedKeys;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _conductUtil = require("rc-tree/lib/utils/conductUtil");
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
const useCheckedKeys = (rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities) => {
|
|
12
|
+
return React.useMemo(() => {
|
|
13
|
+
const extractValues = values => values.map(({
|
|
14
|
+
value
|
|
15
|
+
}) => value);
|
|
16
|
+
const checkedKeys = extractValues(rawLabeledValues);
|
|
17
|
+
const halfCheckedKeys = extractValues(rawHalfCheckedValues);
|
|
18
|
+
const missingValues = checkedKeys.filter(key => !keyEntities[key]);
|
|
19
|
+
let finalCheckedKeys = checkedKeys;
|
|
20
|
+
let finalHalfCheckedKeys = halfCheckedKeys;
|
|
21
|
+
if (treeConduction) {
|
|
22
|
+
const conductResult = (0, _conductUtil.conductCheck)(checkedKeys, true, keyEntities);
|
|
23
|
+
finalCheckedKeys = conductResult.checkedKeys;
|
|
24
|
+
finalHalfCheckedKeys = conductResult.halfCheckedKeys;
|
|
25
|
+
}
|
|
26
|
+
return [Array.from(new Set([...missingValues, ...finalCheckedKeys])), finalHalfCheckedKeys];
|
|
27
|
+
}, [rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities]);
|
|
28
|
+
};
|
|
29
|
+
var _default = exports.default = useCheckedKeys;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataEntity } from 'rc-tree/lib/interface';
|
|
2
|
+
import type { SafeKey, FieldNames } from '../interface';
|
|
3
|
+
declare const _default: (treeData: any, fieldNames: FieldNames) => {
|
|
4
|
+
valueEntities: Map<SafeKey, DataEntity>;
|
|
5
|
+
keyEntities: Record<string, DataEntity>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|