@hi-ui/tree-select 4.0.0-beta.8 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/TreeSelect.js +36 -23
- package/lib/cjs/index.js +1 -2
- package/lib/cjs/styles/index.scss.js +3 -4
- package/lib/esm/TreeSelect.js +30 -16
- package/lib/esm/index.js +1 -2
- package/lib/esm/styles/index.scss.js +4 -6
- package/lib/types/TreeSelect.d.ts +21 -13
- package/lib/types/context.d.ts +2 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/types.d.ts +4 -11
- package/package.json +23 -21
- package/lib/cjs/TreeSelect.js.map +0 -1
- package/lib/cjs/hooks/use-latest/lib/esm/index.js +0 -65
- package/lib/cjs/hooks/use-latest/lib/esm/index.js.map +0 -1
- package/lib/cjs/hooks/use-merge-refs/lib/esm/index.js +0 -77
- package/lib/cjs/hooks/use-merge-refs/lib/esm/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/styles/index.scss.js.map +0 -1
- package/lib/cjs/ui/input/lib/esm/Input.js +0 -243
- package/lib/cjs/ui/input/lib/esm/Input.js.map +0 -1
- package/lib/cjs/ui/input/lib/esm/MockInput.js +0 -164
- package/lib/cjs/ui/input/lib/esm/MockInput.js.map +0 -1
- package/lib/cjs/ui/input/lib/esm/styles/index.scss.js +0 -32
- package/lib/cjs/ui/input/lib/esm/styles/index.scss.js.map +0 -1
- package/lib/cjs/ui/input/lib/esm/use-input.js +0 -139
- package/lib/cjs/ui/input/lib/esm/use-input.js.map +0 -1
- package/lib/cjs/ui/input/lib/esm/utils/index.js +0 -202
- package/lib/cjs/ui/input/lib/esm/utils/index.js.map +0 -1
- package/lib/cjs/utils/dom-utils/lib/esm/index.js +0 -34
- package/lib/cjs/utils/dom-utils/lib/esm/index.js.map +0 -1
- package/lib/esm/TreeSelect.js.map +0 -1
- package/lib/esm/hooks/use-latest/lib/esm/index.js +0 -57
- package/lib/esm/hooks/use-latest/lib/esm/index.js.map +0 -1
- package/lib/esm/hooks/use-merge-refs/lib/esm/index.js +0 -69
- package/lib/esm/hooks/use-merge-refs/lib/esm/index.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/styles/index.scss.js.map +0 -1
- package/lib/esm/ui/input/lib/esm/Input.js +0 -219
- package/lib/esm/ui/input/lib/esm/Input.js.map +0 -1
- package/lib/esm/ui/input/lib/esm/MockInput.js +0 -142
- package/lib/esm/ui/input/lib/esm/MockInput.js.map +0 -1
- package/lib/esm/ui/input/lib/esm/styles/index.scss.js +0 -27
- package/lib/esm/ui/input/lib/esm/styles/index.scss.js.map +0 -1
- package/lib/esm/ui/input/lib/esm/use-input.js +0 -128
- package/lib/esm/ui/input/lib/esm/use-input.js.map +0 -1
- package/lib/esm/ui/input/lib/esm/utils/index.js +0 -186
- package/lib/esm/ui/input/lib/esm/utils/index.js.map +0 -1
- package/lib/esm/utils/dom-utils/lib/esm/index.js +0 -29
- package/lib/esm/utils/dom-utils/lib/esm/index.js.map +0 -1
- package/lib/types/use-tree-select.d.ts +0 -8
package/lib/cjs/TreeSelect.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @hi-ui/tree-select
|
3
3
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
@@ -39,15 +39,13 @@ var arrayUtils = require('@hi-ui/array-utils');
|
|
39
39
|
|
40
40
|
var highlighter = require('@hi-ui/highlighter');
|
41
41
|
|
42
|
-
require('
|
43
|
-
|
44
|
-
require('./ui/input/lib/esm/Input.js');
|
45
|
-
|
46
|
-
var MockInput = require('./ui/input/lib/esm/MockInput.js');
|
42
|
+
var input = require('@hi-ui/input');
|
47
43
|
|
48
44
|
var icons = require('@hi-ui/icons');
|
49
45
|
|
50
|
-
var
|
46
|
+
var core = require('@hi-ui/core');
|
47
|
+
|
48
|
+
var funcUtils = require('@hi-ui/func-utils');
|
51
49
|
|
52
50
|
var useSearchMode = require('@hi-ui/use-search-mode');
|
53
51
|
|
@@ -77,6 +75,9 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
77
75
|
dataSource = _a.dataSource,
|
78
76
|
_a$disabled = _a.disabled,
|
79
77
|
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
78
|
+
visible = _a.visible,
|
79
|
+
onOpen = _a.onOpen,
|
80
|
+
onClose = _a.onClose,
|
80
81
|
_a$fieldNames = _a.fieldNames,
|
81
82
|
fieldNames = _a$fieldNames === void 0 ? DEFAULT_FIELD_NAMES : _a$fieldNames,
|
82
83
|
_a$defaultExpandAll = _a.defaultExpandAll,
|
@@ -94,19 +95,28 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
94
95
|
onLoadChildren = _a.onLoadChildren,
|
95
96
|
titleRender = _a.render,
|
96
97
|
filterOption = _a.filterOption,
|
98
|
+
onSearchProp = _a.onSearch,
|
97
99
|
clearable = _a.clearable,
|
98
100
|
invalid = _a.invalid,
|
99
101
|
displayRenderProp = _a.displayRender,
|
100
102
|
placeholderProp = _a.placeholder,
|
101
103
|
appearance = _a.appearance,
|
102
|
-
|
104
|
+
virtual = _a.virtual,
|
105
|
+
itemHeight = _a.itemHeight,
|
106
|
+
height = _a.height,
|
107
|
+
rest = tslib.__rest(_a, ["prefixCls", "role", "className", "data", "dataSource", "disabled", "visible", "onOpen", "onClose", "fieldNames", "defaultExpandAll", "expandedIds", "defaultExpandedIds", "onExpand", "defaultValue", "value", "onChange", "searchable", "searchMode", "onLoadChildren", "render", "filterOption", "onSearch", "clearable", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height"]);
|
103
108
|
|
104
|
-
var i18n =
|
109
|
+
var i18n = core.useLocaleContext();
|
105
110
|
var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
|
106
111
|
|
107
|
-
var
|
108
|
-
|
109
|
-
|
112
|
+
var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
|
113
|
+
visible: visible,
|
114
|
+
disabled: disabled,
|
115
|
+
onOpen: onOpen,
|
116
|
+
onClose: onClose
|
117
|
+
}),
|
118
|
+
menuVisible = _useUncontrolledToggl[0],
|
119
|
+
menuVisibleAction = _useUncontrolledToggl[1];
|
110
120
|
/**
|
111
121
|
* 转换对象
|
112
122
|
*/
|
@@ -184,7 +194,8 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
184
194
|
var filterSearchStrategy = useSearchMode.useFilterSearch({
|
185
195
|
enabled: searchModeProp === 'filter',
|
186
196
|
data: data,
|
187
|
-
flattedData: flattedData
|
197
|
+
flattedData: flattedData,
|
198
|
+
fieldNames: fieldNames
|
188
199
|
});
|
189
200
|
var highlightSearchStrategy = useSearchMode.useHighlightSearch({
|
190
201
|
data: data,
|
@@ -213,7 +224,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
213
224
|
|
214
225
|
|
215
226
|
var highlight = !!searchValue && (searchMode === 'highlight' || searchMode === 'filter');
|
216
|
-
var ret = highlight ? /*#__PURE__*/React__default[
|
227
|
+
var ret = highlight ? /*#__PURE__*/React__default["default"].createElement(highlighter.Highlighter, {
|
217
228
|
keyword: searchValue
|
218
229
|
}, node.title) : true;
|
219
230
|
return ret;
|
@@ -241,7 +252,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
241
252
|
return flattedData;
|
242
253
|
}, [selectedItem, flattedData]);
|
243
254
|
var cls = classname.cx(prefixCls, className);
|
244
|
-
return /*#__PURE__*/React__default[
|
255
|
+
return /*#__PURE__*/React__default["default"].createElement(picker.Picker, Object.assign({
|
245
256
|
ref: ref,
|
246
257
|
className: cls
|
247
258
|
}, rest, {
|
@@ -253,15 +264,15 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
253
264
|
// onChange={tryChangeValue}
|
254
265
|
// data={mergedData}
|
255
266
|
searchable: searchable,
|
256
|
-
onSearch: onSearch,
|
267
|
+
onSearch: funcUtils.callAllFuncs(onSearchProp, onSearch),
|
257
268
|
loading: loading,
|
258
|
-
trigger: /*#__PURE__*/React__default[
|
269
|
+
trigger: /*#__PURE__*/React__default["default"].createElement(input.MockInput // disabled={disabled}
|
259
270
|
, {
|
260
271
|
// disabled={disabled}
|
261
272
|
clearable: clearable,
|
262
273
|
placeholder: placeholder,
|
263
274
|
displayRender: displayRenderProp,
|
264
|
-
suffix: menuVisible ? /*#__PURE__*/React__default[
|
275
|
+
suffix: menuVisible ? /*#__PURE__*/React__default["default"].createElement(icons.UpOutlined, null) : /*#__PURE__*/React__default["default"].createElement(icons.DownOutlined, null),
|
265
276
|
focused: menuVisible,
|
266
277
|
value: value,
|
267
278
|
onChange: tryChangeValue,
|
@@ -270,15 +281,18 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
270
281
|
invalid: invalid,
|
271
282
|
appearance: appearance
|
272
283
|
})
|
273
|
-
}), typeAssertion.isArrayNonEmpty(treeProps.data) ? /*#__PURE__*/React__default[
|
284
|
+
}), typeAssertion.isArrayNonEmpty(treeProps.data) ? /*#__PURE__*/React__default["default"].createElement(tree.Tree, Object.assign({
|
274
285
|
className: prefixCls + "__tree",
|
275
286
|
selectable: true,
|
276
287
|
selectedId: value,
|
277
288
|
onSelect: onSelect,
|
289
|
+
fieldNames: fieldNames,
|
278
290
|
// onLoadChildren 缓存数据
|
279
|
-
//
|
280
|
-
|
281
|
-
|
291
|
+
// @ts-ignore
|
292
|
+
onLoadChildren: onLoadChildren,
|
293
|
+
virtual: virtual,
|
294
|
+
itemHeight: itemHeight,
|
295
|
+
height: height
|
282
296
|
}, treeProps)) : null);
|
283
297
|
});
|
284
298
|
|
@@ -287,4 +301,3 @@ if (env.__DEV__) {
|
|
287
301
|
}
|
288
302
|
|
289
303
|
exports.TreeSelect = TreeSelect;
|
290
|
-
//# sourceMappingURL=TreeSelect.js.map
|
package/lib/cjs/index.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @hi-ui/tree-select
|
3
3
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
@@ -19,4 +19,3 @@ var TreeSelect = require('./TreeSelect.js');
|
|
19
19
|
|
20
20
|
exports.TreeSelect = TreeSelect.TreeSelect;
|
21
21
|
exports["default"] = TreeSelect.TreeSelect;
|
22
|
-
//# sourceMappingURL=index.js.map
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @hi-ui/tree-select
|
3
3
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
@@ -12,11 +12,10 @@
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
var css_248z = "
|
15
|
+
var css_248z = "";
|
16
16
|
|
17
|
-
var __styleInject__ = require('
|
17
|
+
var __styleInject__ = require('inject-head-style')["default"];
|
18
18
|
|
19
19
|
__styleInject__(css_248z);
|
20
20
|
|
21
21
|
exports["default"] = css_248z;
|
22
|
-
//# sourceMappingURL=index.scss.js.map
|
package/lib/esm/TreeSelect.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @hi-ui/tree-select
|
3
3
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
@@ -11,7 +11,7 @@ import { __rest } from 'tslib';
|
|
11
11
|
import React, { forwardRef, useCallback, useMemo, useState } from 'react';
|
12
12
|
import { getPrefixCls, cx } from '@hi-ui/classname';
|
13
13
|
import { __DEV__ } from '@hi-ui/env';
|
14
|
-
import {
|
14
|
+
import { useUncontrolledToggle } from '@hi-ui/use-toggle';
|
15
15
|
import { Tree } from '@hi-ui/tree';
|
16
16
|
import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
|
17
17
|
import { Picker } from '@hi-ui/picker';
|
@@ -19,11 +19,10 @@ import { baseFlattenTree } from '@hi-ui/tree-utils';
|
|
19
19
|
import { isUndef, isArrayNonEmpty } from '@hi-ui/type-assertion';
|
20
20
|
import { uniqBy } from '@hi-ui/array-utils';
|
21
21
|
import { Highlighter } from '@hi-ui/highlighter';
|
22
|
-
import '
|
23
|
-
import './ui/input/lib/esm/Input.js';
|
24
|
-
import { MockInput } from './ui/input/lib/esm/MockInput.js';
|
22
|
+
import { MockInput } from '@hi-ui/input';
|
25
23
|
import { UpOutlined, DownOutlined } from '@hi-ui/icons';
|
26
|
-
import { useLocaleContext } from '@hi-ui/
|
24
|
+
import { useLocaleContext } from '@hi-ui/core';
|
25
|
+
import { callAllFuncs } from '@hi-ui/func-utils';
|
27
26
|
import { useAsyncSearch, useTreeCustomSearch, useFilterSearch, useHighlightSearch, useSearchMode } from '@hi-ui/use-search-mode';
|
28
27
|
var TREE_SELECT_PREFIX = getPrefixCls('tree-select');
|
29
28
|
var DEFAULT_DATA = []; // const DEFAULT_VALUE = [] as []
|
@@ -43,6 +42,9 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
43
42
|
dataSource = _a.dataSource,
|
44
43
|
_a$disabled = _a.disabled,
|
45
44
|
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
45
|
+
visible = _a.visible,
|
46
|
+
onOpen = _a.onOpen,
|
47
|
+
onClose = _a.onClose,
|
46
48
|
_a$fieldNames = _a.fieldNames,
|
47
49
|
fieldNames = _a$fieldNames === void 0 ? DEFAULT_FIELD_NAMES : _a$fieldNames,
|
48
50
|
_a$defaultExpandAll = _a.defaultExpandAll,
|
@@ -60,19 +62,28 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
60
62
|
onLoadChildren = _a.onLoadChildren,
|
61
63
|
titleRender = _a.render,
|
62
64
|
filterOption = _a.filterOption,
|
65
|
+
onSearchProp = _a.onSearch,
|
63
66
|
clearable = _a.clearable,
|
64
67
|
invalid = _a.invalid,
|
65
68
|
displayRenderProp = _a.displayRender,
|
66
69
|
placeholderProp = _a.placeholder,
|
67
70
|
appearance = _a.appearance,
|
68
|
-
|
71
|
+
virtual = _a.virtual,
|
72
|
+
itemHeight = _a.itemHeight,
|
73
|
+
height = _a.height,
|
74
|
+
rest = __rest(_a, ["prefixCls", "role", "className", "data", "dataSource", "disabled", "visible", "onOpen", "onClose", "fieldNames", "defaultExpandAll", "expandedIds", "defaultExpandedIds", "onExpand", "defaultValue", "value", "onChange", "searchable", "searchMode", "onLoadChildren", "render", "filterOption", "onSearch", "clearable", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height"]);
|
69
75
|
|
70
76
|
var i18n = useLocaleContext();
|
71
77
|
var placeholder = isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
|
72
78
|
|
73
|
-
var
|
74
|
-
|
75
|
-
|
79
|
+
var _useUncontrolledToggl = useUncontrolledToggle({
|
80
|
+
visible: visible,
|
81
|
+
disabled: disabled,
|
82
|
+
onOpen: onOpen,
|
83
|
+
onClose: onClose
|
84
|
+
}),
|
85
|
+
menuVisible = _useUncontrolledToggl[0],
|
86
|
+
menuVisibleAction = _useUncontrolledToggl[1];
|
76
87
|
/**
|
77
88
|
* 转换对象
|
78
89
|
*/
|
@@ -150,7 +161,8 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
150
161
|
var filterSearchStrategy = useFilterSearch({
|
151
162
|
enabled: searchModeProp === 'filter',
|
152
163
|
data: data,
|
153
|
-
flattedData: flattedData
|
164
|
+
flattedData: flattedData,
|
165
|
+
fieldNames: fieldNames
|
154
166
|
});
|
155
167
|
var highlightSearchStrategy = useHighlightSearch({
|
156
168
|
data: data,
|
@@ -219,7 +231,7 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
219
231
|
// onChange={tryChangeValue}
|
220
232
|
// data={mergedData}
|
221
233
|
searchable: searchable,
|
222
|
-
onSearch: onSearch,
|
234
|
+
onSearch: callAllFuncs(onSearchProp, onSearch),
|
223
235
|
loading: loading,
|
224
236
|
trigger: /*#__PURE__*/React.createElement(MockInput // disabled={disabled}
|
225
237
|
, {
|
@@ -241,10 +253,13 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
241
253
|
selectable: true,
|
242
254
|
selectedId: value,
|
243
255
|
onSelect: onSelect,
|
256
|
+
fieldNames: fieldNames,
|
244
257
|
// onLoadChildren 缓存数据
|
245
|
-
//
|
246
|
-
|
247
|
-
|
258
|
+
// @ts-ignore
|
259
|
+
onLoadChildren: onLoadChildren,
|
260
|
+
virtual: virtual,
|
261
|
+
itemHeight: itemHeight,
|
262
|
+
height: height
|
248
263
|
}, treeProps)) : null);
|
249
264
|
});
|
250
265
|
|
@@ -253,4 +268,3 @@ if (__DEV__) {
|
|
253
268
|
}
|
254
269
|
|
255
270
|
export { TreeSelect };
|
256
|
-
//# sourceMappingURL=TreeSelect.js.map
|
package/lib/esm/index.js
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
* @hi-ui/tree-select
|
3
3
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
10
|
import './styles/index.scss.js';
|
11
11
|
export { TreeSelect, TreeSelect as default } from './TreeSelect.js';
|
12
|
-
//# sourceMappingURL=index.js.map
|
@@ -2,16 +2,14 @@
|
|
2
2
|
* @hi-ui/tree-select
|
3
3
|
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
4
|
*
|
5
|
-
* Copyright (c)
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
|
11
|
-
|
12
|
-
var __styleInject__ = require('style-inject/dist/style-inject.es.js')["default"];
|
10
|
+
import __styleInject__ from 'inject-head-style';
|
11
|
+
var css_248z = "";
|
13
12
|
|
14
13
|
__styleInject__(css_248z);
|
15
14
|
|
16
|
-
export default
|
17
|
-
//# sourceMappingURL=index.scss.js.map
|
15
|
+
export { css_248z as default };
|
@@ -1,13 +1,14 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import { TreeSelectDataItem } from './types';
|
3
3
|
import { TreeNodeEventData } from '@hi-ui/tree';
|
4
4
|
import { PickerProps } from '@hi-ui/picker';
|
5
5
|
import { HiBaseAppearanceEnum } from '@hi-ui/core';
|
6
|
+
import { UseDataSource } from '@hi-ui/use-data-source';
|
6
7
|
/**
|
7
8
|
* TODO: What is TreeSelect
|
8
9
|
*/
|
9
10
|
export declare const TreeSelect: React.ForwardRefExoticComponent<TreeSelectProps & React.RefAttributes<HTMLDivElement | null>>;
|
10
|
-
export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' | 'trigger'> {
|
11
|
+
export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' | 'trigger' | 'scrollable'> {
|
11
12
|
/**
|
12
13
|
* 展示数据
|
13
14
|
*/
|
@@ -15,11 +16,7 @@ export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' |
|
|
15
16
|
/**
|
16
17
|
* 设置 data 中 id, title, disabled, children 对应的 key (3.0 新增) object - { title: 'title', id: 'id',disabled:'disabled', children: 'children'}
|
17
18
|
*/
|
18
|
-
fieldNames?:
|
19
|
-
/**
|
20
|
-
* 数据选择类型
|
21
|
-
*/
|
22
|
-
type?: 'single' | 'multiple';
|
19
|
+
fieldNames?: Record<string, string>;
|
23
20
|
/**
|
24
21
|
* 是否有边框
|
25
22
|
*/
|
@@ -79,13 +76,10 @@ export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' |
|
|
79
76
|
*/
|
80
77
|
onLoadChildren?: (node: TreeNodeEventData) => void | Promise<TreeSelectDataItem[] | void>;
|
81
78
|
/**
|
82
|
-
*
|
79
|
+
* 异步加载数据。暂不对外暴露
|
80
|
+
* @private
|
83
81
|
*/
|
84
|
-
|
85
|
-
/**
|
86
|
-
* 异步加载数据
|
87
|
-
*/
|
88
|
-
dataSource?: DataSourceFunc | TreeSelectDataSource | Promise<TreeSelectDataItem[]>;
|
82
|
+
dataSource?: UseDataSource<TreeSelectDataItem[]>;
|
89
83
|
/**
|
90
84
|
* 没有选项时的提示
|
91
85
|
*/
|
@@ -112,4 +106,18 @@ export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' |
|
|
112
106
|
* 设置展现形式
|
113
107
|
*/
|
114
108
|
appearance?: HiBaseAppearanceEnum;
|
109
|
+
/**
|
110
|
+
* 设置虚拟滚动容器的可视高度。暂不对外暴露
|
111
|
+
* @private
|
112
|
+
*/
|
113
|
+
height?: number;
|
114
|
+
/**
|
115
|
+
* 设置虚拟列表每项的固定高度。暂不对外暴露
|
116
|
+
* @private
|
117
|
+
*/
|
118
|
+
itemHeight?: number;
|
119
|
+
/**
|
120
|
+
* 设置 `true` 开启虚拟滚动
|
121
|
+
*/
|
122
|
+
virtual?: boolean;
|
115
123
|
}
|
package/lib/types/context.d.ts
CHANGED
@@ -1,7 +1,3 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
export declare const TreeSelectProvider: import("react").Provider<
|
3
|
-
|
4
|
-
}, "rootProps"> | null>;
|
5
|
-
export declare const useTreeSelectContext: () => Omit<{
|
6
|
-
rootProps: {};
|
7
|
-
}, "rootProps">;
|
2
|
+
export declare const TreeSelectProvider: import("react").Provider<any>;
|
3
|
+
export declare const useTreeSelectContext: () => any;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/types.d.ts
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
import { HiBaseDataItem } from '@hi-ui/core';
|
1
2
|
import React from 'react';
|
2
|
-
export interface TreeSelectDataItem {
|
3
|
+
export interface TreeSelectDataItem extends HiBaseDataItem {
|
3
4
|
/**
|
4
5
|
* 节点唯一 id
|
5
6
|
*/
|
6
|
-
id
|
7
|
+
id?: React.ReactText;
|
7
8
|
/**
|
8
9
|
* 节点标题
|
9
10
|
*/
|
10
|
-
title
|
11
|
+
title?: React.ReactNode;
|
11
12
|
/**
|
12
13
|
* 子级数据
|
13
14
|
*/
|
@@ -47,11 +48,3 @@ export interface TreeSelectDataSource<T = any> {
|
|
47
48
|
*/
|
48
49
|
transformResponse?: (response: object) => T;
|
49
50
|
}
|
50
|
-
export declare type FilterOptionFunc = (keyword: string, item: TreeSelectDataItem) => boolean;
|
51
|
-
export declare type DataSourceFunc = (keyword: string) => TreeSelectDataSource;
|
52
|
-
export declare type FieldNames = {
|
53
|
-
id?: string;
|
54
|
-
title?: string;
|
55
|
-
disabled?: string;
|
56
|
-
children?: string;
|
57
|
-
};
|
package/package.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hi-ui/tree-select",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.1",
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
5
5
|
"keywords": [],
|
6
|
-
"author": "
|
6
|
+
"author": "HiUI <mi-hiui@xiaomi.com>",
|
7
7
|
"homepage": "https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme",
|
8
8
|
"license": "MIT",
|
9
9
|
"directories": {
|
@@ -43,32 +43,34 @@
|
|
43
43
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
|
-
"@hi-ui/array-utils": "^4.0.0
|
47
|
-
"@hi-ui/classname": "^4.0.0
|
48
|
-
"@hi-ui/
|
49
|
-
"@hi-ui/
|
50
|
-
"@hi-ui/
|
51
|
-
"@hi-ui/
|
52
|
-
"@hi-ui/
|
53
|
-
"@hi-ui/
|
54
|
-
"@hi-ui/
|
55
|
-
"@hi-ui/
|
56
|
-
"@hi-ui/
|
57
|
-
"@hi-ui/
|
58
|
-
"@hi-ui/
|
59
|
-
"@hi-ui/
|
60
|
-
"@hi-ui/use-
|
61
|
-
"@hi-ui/use-
|
62
|
-
"@hi-ui/use-uncontrolled-state": "^4.0.0-beta.1"
|
46
|
+
"@hi-ui/array-utils": "^4.0.0",
|
47
|
+
"@hi-ui/classname": "^4.0.0",
|
48
|
+
"@hi-ui/env": "^4.0.0",
|
49
|
+
"@hi-ui/func-utils": "^4.0.0",
|
50
|
+
"@hi-ui/highlighter": "^4.0.1",
|
51
|
+
"@hi-ui/icons": "^4.0.0",
|
52
|
+
"@hi-ui/input": "^4.0.0",
|
53
|
+
"@hi-ui/picker": "^4.0.0",
|
54
|
+
"@hi-ui/popper": "^4.0.0",
|
55
|
+
"@hi-ui/tree": "^4.0.1",
|
56
|
+
"@hi-ui/tree-utils": "^4.0.0",
|
57
|
+
"@hi-ui/type-assertion": "^4.0.0",
|
58
|
+
"@hi-ui/use-data-source": "^4.0.0",
|
59
|
+
"@hi-ui/use-search-mode": "^4.0.1",
|
60
|
+
"@hi-ui/use-toggle": "^4.0.0",
|
61
|
+
"@hi-ui/use-uncontrolled-state": "^4.0.0"
|
63
62
|
},
|
64
63
|
"peerDependencies": {
|
64
|
+
"@hi-ui/core": ">=4.0.0",
|
65
65
|
"react": ">=16.8.6",
|
66
66
|
"react-dom": ">=16.8.6"
|
67
67
|
},
|
68
68
|
"devDependencies": {
|
69
|
-
"@hi-ui/
|
69
|
+
"@hi-ui/core": "^4.0.0",
|
70
|
+
"@hi-ui/core-css": "^4.0.0",
|
71
|
+
"@hi-ui/hi-build": "^4.0.0",
|
70
72
|
"react": "^17.0.1",
|
71
73
|
"react-dom": "^17.0.1"
|
72
74
|
},
|
73
|
-
"gitHead": "
|
75
|
+
"gitHead": "318d9e83b849d81605731b2c2beaa04df5701072"
|
74
76
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"TreeSelect.js","sources":["../../src/TreeSelect.tsx"],"sourcesContent":[null],"names":["TREE_SELECT_PREFIX","getPrefixCls","DEFAULT_DATA","DEFAULT_FIELD_NAMES","DEFAULT_EXPANDED_IDS","TreeSelect","forwardRef","_a","ref","prefixCls","className","data","dataSource","disabled","fieldNames","defaultExpandAll","expandedIdsProp","expandedIds","defaultExpandedIds","onExpand","defaultValue","valueProp","value","onChange","searchableProp","searchable","searchModeProp","searchMode","onLoadChildren","titleRender","render","filterOption","clearable","invalid","displayRenderProp","displayRender","placeholderProp","placeholder","appearance","rest","i18n","useLocaleContext","isUndef","get","useToggle","menuVisible","menuVisibleAction","getKeyFields","useCallback","node","key","flattedData","useMemo","baseFlattenTree","tree","childrenFieldName","transform","flattedNode","raw","id","title","isLeaf","useUncontrolledState","getDefaultExpandedIds","map","tryChangeExpandedIds","tryChangeValue","onSelect","selectedId","selectedNode","setSelectedItem","off","useState","selectedItem","_b","useAsyncSearch","loading","hasError","dataSourceStrategy","customSearchStrategy","useTreeCustomSearch","filterSearchStrategy","useFilterSearch","enabled","highlightSearchStrategy","useHighlightSearch","useSearchMode","strategies","stateInSearch","state","setStateInSearch","onSearch","searchValue","keyword","proxyTitleRender","ret","highlight","React","Highlighter","shouldUseSearch","treeProps","ids","prev","mergedData","nextData","concat","uniqBy","cls","cx","Picker","visible","onOpen","on","onClose","trigger","MockInput","suffix","UpOutlined","DownOutlined","focused","isArrayNonEmpty","Tree","selectable","__DEV__","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAMA,kBAAkB,GAAGC,sBAAAA,CAAa,aAAbA,CAA3B;AACA,IAAMC,YAAY,GAAG,EAArB;;AAEA,IAAMC,mBAAmB,GAAG,EAA5B;AACA,IAAMC,oBAAoB,GAAG,EAA7B;AAEA;;;;IAGaC,UAAU,gBAAGC,gBAAAA,CACxB,UACEC,EADF,EAmCEC,GAnCF;wBAEIC;MAAAA,sCAAYT;MAEZU,eAAAA;mBACAC;MAAAA,4BAAOT;MACPU,gBAAAA;uBACAC;MAAAA,oCAAW;yBAGXC;MAAAA,wCAAaX;+BACbY;MAAAA,oDAAmB;MACNC,qBAAbC;iCACAC;MAAAA,wDAAqBd;MACrBe,cAAAA;2BACAC;MAAAA,4CAAe;MACRC,eAAPC;MACAC,cAAAA;MACYC,oBAAZC;MACYC,oBAAZC;MACAC,oBAAAA;MACQC,iBAARC;MACAC,kBAAAA;MAMAC,eAAAA;MACAC,aAAAA;MACeC,uBAAfC;MACaC,qBAAbC;MACAC,gBAAAA;MACGC,wBAhCL,YAAA,QAAA,aAAA,QAAA,cAAA,YAAA,cAAA,oBAAA,eAAA,sBAAA,YAAA,gBAAA,SAAA,YAAA,cAAA,cAAA,kBAAA,UAAA,gBAAA,aAAA,WAAA,iBAAA,eAAA,cAAA;;MAoCMC,IAAI,GAAGC,8BAAAA;MAEPJ,WAAW,GAAGK,qBAAAA,CAAQN,eAARM,IAChBF,IAAI,CAACG,GAALH,CAAS,wBAATA,CADgBE,GAEhBN;;mBAEqCQ,mB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vH,GAAyB,YAAzBA;;;"}
|
@@ -1,65 +0,0 @@
|
|
1
|
-
/** @LICENSE
|
2
|
-
* @hi-ui/tree-select
|
3
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tree-select#readme
|
4
|
-
*
|
5
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
Object.defineProperty(exports, '__esModule', {
|
13
|
-
value: true
|
14
|
-
});
|
15
|
-
|
16
|
-
var React = require('react');
|
17
|
-
/** @LICENSE
|
18
|
-
* @hi-ui/use-latest
|
19
|
-
* https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-latest#readme
|
20
|
-
*
|
21
|
-
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
22
|
-
*
|
23
|
-
* This source code is licensed under the MIT license found in the
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
25
|
-
*/
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Keep value up-to-date if it changes.
|
29
|
-
*
|
30
|
-
* @param value
|
31
|
-
* @returns
|
32
|
-
*/
|
33
|
-
|
34
|
-
|
35
|
-
var useLatestRef = function useLatestRef(value) {
|
36
|
-
var ref = React.useRef(value);
|
37
|
-
ref.current = value;
|
38
|
-
return ref;
|
39
|
-
};
|
40
|
-
/**
|
41
|
-
* Keep callback function up-to-date if it changes.
|
42
|
-
*
|
43
|
-
* @param callback
|
44
|
-
* @returns
|
45
|
-
*/
|
46
|
-
|
47
|
-
|
48
|
-
var useLatestCallback = function useLatestCallback(callback) {
|
49
|
-
var ref = useLatestRef(callback);
|
50
|
-
return React.useCallback(function () {
|
51
|
-
var _a2;
|
52
|
-
|
53
|
-
var _a;
|
54
|
-
|
55
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
56
|
-
args[_key] = arguments[_key];
|
57
|
-
}
|
58
|
-
|
59
|
-
return (_a = ref.current) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [ref].concat(args));
|
60
|
-
}, []);
|
61
|
-
};
|
62
|
-
|
63
|
-
exports.useLatestCallback = useLatestCallback;
|
64
|
-
exports.useLatestRef = useLatestRef;
|
65
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../../hooks/use-latest/lib/esm/index.js"],"sourcesContent":["/** @LICENSE\n * @hi-ui/use-latest\n * https://github.com/XiaoMi/hiui/tree/master/packages/hooks/use-latest#readme\n *\n * Copyright (c) HIUI <mi-hiui@xiaomi.com>.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { useRef, useCallback } from 'react';\n/**\n * Keep value up-to-date if it changes.\n *\n * @param value\n * @returns\n */\n\nvar useLatestRef = function useLatestRef(value) {\n var ref = useRef(value);\n ref.current = value;\n return ref;\n};\n/**\n * Keep callback function up-to-date if it changes.\n *\n * @param callback\n * @returns\n */\n\n\nvar useLatestCallback = function useLatestCallback(callback) {\n var ref = useLatestRef(callback);\n return useCallback(function () {\n var _a2;\n\n var _a;\n\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return (_a = ref.current) === null || _a === void 0 ? void 0 : (_a2 = _a).call.apply(_a2, [ref].concat(args));\n }, []);\n};\n\nexport { useLatestCallback, useLatestRef };\n//# sourceMappingURL=index.js.map\n"],"names":["useLatestRef","value","ref","useRef","useLatestCallback","callback","useCallback","args","_a","current","_a2","call","apply","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;;;IAMaA,YAAY,GAAG,SAAfA,YAAe,CAAAC,KAAA,EAAA;MACpBC,GAAG,GAAGC,YAAAA,CAAMF,KAANE;AACZD,EAAAA,GAAG,CAAHA,OAAAA,GAAAA,KAAAA;SACOA;;AAGT;;;;;;;;IAMaE,iBAAiB,GAAG,SAApBA,iBAAoB,CAAAC,QAAA,EAAA;MAGzBH,GAAG,GAAGF,YAAY,CAAAK,QAAA;SACjBC,iBAAAA,CAAY,YAAA;;;;;sCAAIC,IAAAA,GAAAA,IAAAA,KAAAA,CAAAA,IAAAA,GAAAA,IAAAA,GAAAA,GAAAA,IAAAA,GAAAA,MAAAA,IAAAA,IAAAA;AAAAA,MAAAA,IAAAA,CAAAA,IAAAA,CAAAA,GAAAA,SAAAA,CAAAA,IAAAA,CAAAA;;;WAAgB,CAAAC,EAAA,GAAAN,GAAG,CAAHO,OAAA,MAAA,IAAA,IAAAD,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAAE,GAAA,GAAAF,EAAA,EAAAG,IAAA,CAAAC,KAAA,CAAAF,GAAA,EAAA,CAAAR,GAAA,EAAAW,MAAA,CAAiBN,IAAjB,CAAA;AAArB,GAAXD,EAAW,EAAXA;;;;"}
|