@hi-ui/tree-select 5.0.0-canary.9 → 5.0.0-experimental.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/CHANGELOG.md +84 -141
- package/lib/cjs/TreeSelect.js +23 -10
- package/lib/esm/TreeSelect.js +24 -11
- package/lib/types/TreeSelect.d.ts +14 -1
- package/lib/types/context.d.ts +0 -1
- package/lib/types/types.d.ts +1 -1
- package/package.json +20 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,157 +1,100 @@
|
|
|
1
1
|
# @hi-ui/tree-select
|
|
2
2
|
|
|
3
|
-
## 5.0.0-
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- eba118692: perf: 对下拉选择类组件的 customRender 的内容增加 memoization 以优化性能 (5.0)
|
|
8
|
-
- Updated dependencies [eaf6005e4]
|
|
9
|
-
- @hi-ui/input@5.0.0-canary.12
|
|
10
|
-
|
|
11
|
-
## 5.0.0-canary.8
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- Updated dependencies [efce04a26]
|
|
16
|
-
- Updated dependencies [9106dca82]
|
|
17
|
-
- @hi-ui/picker@5.0.0-canary.10
|
|
18
|
-
- @hi-ui/popper@5.0.0-canary.6
|
|
19
|
-
- @hi-ui/core@5.0.0-canary.3
|
|
20
|
-
- @hi-ui/input@5.0.0-canary.10
|
|
21
|
-
- @hi-ui/icons@5.0.0-canary.3
|
|
22
|
-
- @hi-ui/highlighter@5.0.0-canary.3
|
|
23
|
-
- @hi-ui/tree@5.0.0-canary.4
|
|
24
|
-
|
|
25
|
-
## 5.0.0-canary.7
|
|
26
|
-
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
- 643c0e09f: style(picker): 移除 picker 组件中的 \_\_text 样式定义 (5.0)
|
|
30
|
-
- Updated dependencies [7182c7bb8]
|
|
31
|
-
- @hi-ui/input@5.0.0-canary.9
|
|
32
|
-
|
|
33
|
-
## 5.0.0-canary.6
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- chore: rebase master (5.0)
|
|
38
|
-
- Updated dependencies
|
|
39
|
-
- @hi-ui/core@5.0.0-canary.2
|
|
40
|
-
- @hi-ui/use-data-source@5.0.0-canary.2
|
|
41
|
-
- @hi-ui/use-search-mode@5.0.0-canary.2
|
|
42
|
-
- @hi-ui/use-toggle@5.0.0-canary.2
|
|
43
|
-
- @hi-ui/use-uncontrolled-state@5.0.0-canary.2
|
|
44
|
-
- @hi-ui/icons@5.0.0-canary.2
|
|
45
|
-
- @hi-ui/highlighter@5.0.0-canary.2
|
|
46
|
-
- @hi-ui/input@5.0.0-canary.7
|
|
47
|
-
- @hi-ui/picker@5.0.0-canary.8
|
|
48
|
-
- @hi-ui/popper@5.0.0-canary.3
|
|
49
|
-
- @hi-ui/tree@5.0.0-canary.3
|
|
50
|
-
- @hi-ui/array-utils@5.0.0-canary.2
|
|
51
|
-
- @hi-ui/classname@5.0.0-canary.2
|
|
52
|
-
- @hi-ui/env@5.0.0-canary.2
|
|
53
|
-
- @hi-ui/func-utils@5.0.0-canary.2
|
|
54
|
-
- @hi-ui/tree-utils@5.0.0-canary.2
|
|
55
|
-
- @hi-ui/type-assertion@5.0.0-canary.2
|
|
56
|
-
|
|
57
|
-
## 5.0.0-canary.5
|
|
58
|
-
|
|
59
|
-
### Patch Changes
|
|
60
|
-
|
|
61
|
-
- 4b09e728b: build: 将 package.json 中 exports 配置中的 types 配置放在最上面 (5.0)
|
|
62
|
-
- Updated dependencies [ba7c324c2]
|
|
63
|
-
- Updated dependencies [ba7c324c2]
|
|
64
|
-
- Updated dependencies [4b09e728b]
|
|
65
|
-
- Updated dependencies [ba7c324c2]
|
|
66
|
-
- @hi-ui/tree@5.0.0-canary.2
|
|
67
|
-
- @hi-ui/picker@5.0.0-canary.7
|
|
68
|
-
- @hi-ui/core@5.0.0-canary.1
|
|
69
|
-
- @hi-ui/use-data-source@5.0.0-canary.1
|
|
70
|
-
- @hi-ui/use-search-mode@5.0.0-canary.1
|
|
71
|
-
- @hi-ui/use-toggle@5.0.0-canary.1
|
|
72
|
-
- @hi-ui/use-uncontrolled-state@5.0.0-canary.1
|
|
73
|
-
- @hi-ui/icons@5.0.0-canary.1
|
|
74
|
-
- @hi-ui/highlighter@5.0.0-canary.1
|
|
75
|
-
- @hi-ui/input@5.0.0-canary.6
|
|
76
|
-
- @hi-ui/popper@5.0.0-canary.2
|
|
77
|
-
- @hi-ui/array-utils@5.0.0-canary.1
|
|
78
|
-
- @hi-ui/classname@5.0.0-canary.1
|
|
79
|
-
- @hi-ui/env@5.0.0-canary.1
|
|
80
|
-
- @hi-ui/func-utils@5.0.0-canary.1
|
|
81
|
-
- @hi-ui/tree-utils@5.0.0-canary.1
|
|
82
|
-
- @hi-ui/type-assertion@5.0.0-canary.1
|
|
83
|
-
|
|
84
|
-
## 5.0.0-canary.4
|
|
85
|
-
|
|
86
|
-
### Patch Changes
|
|
87
|
-
|
|
88
|
-
- 40f819417: fix: 修复 UI 问题 (5.0)
|
|
89
|
-
- Updated dependencies [40f819417]
|
|
90
|
-
- @hi-ui/input@5.0.0-canary.5
|
|
91
|
-
|
|
92
|
-
## 5.0.0-canary.3
|
|
93
|
-
|
|
94
|
-
### Patch Changes
|
|
95
|
-
|
|
96
|
-
- a89b3b3ae: fix: 修改组件问题 (5.0)
|
|
97
|
-
|
|
98
|
-
## 5.0.0-canary.2
|
|
99
|
-
|
|
100
|
-
### Patch Changes
|
|
101
|
-
|
|
102
|
-
- df3615e78: <br>
|
|
103
|
-
- style(tag-input): 间距调整 (5.0)
|
|
104
|
-
- style(select): 选择类组件选项圆角改为 4px (5.0)
|
|
105
|
-
- style(picker): 搜索框样式调整 (5.0)
|
|
106
|
-
- Updated dependencies [3cb3377dc]
|
|
107
|
-
- Updated dependencies [df3615e78]
|
|
108
|
-
- @hi-ui/picker@5.0.0-canary.3
|
|
109
|
-
|
|
110
|
-
## 5.0.0-canary.1
|
|
111
|
-
|
|
112
|
-
### Minor Changes
|
|
113
|
-
|
|
114
|
-
- 6c4bf35af: feat: 下拉选择类组件 appearance 参数增加 contained 类型 (5.0)
|
|
115
|
-
|
|
116
|
-
### Patch Changes
|
|
117
|
-
|
|
118
|
-
- Updated dependencies [6c4bf35af]
|
|
119
|
-
- @hi-ui/input@5.0.0-canary.2
|
|
120
|
-
|
|
121
|
-
## 5.0.0-canary.0
|
|
3
|
+
## 5.0.0-experimental.0
|
|
122
4
|
|
|
123
5
|
### Major Changes
|
|
124
6
|
|
|
125
|
-
-
|
|
7
|
+
- 8f3aa85e4: feat: 组件的 package.json 中的 exports 统一加上 types 配置 (5.0)
|
|
126
8
|
|
|
127
9
|
### Minor Changes
|
|
128
10
|
|
|
129
|
-
-
|
|
11
|
+
- b9989e482: feat(picker): 增加 clearSearchOnClosed api 默认是 false (5.0)
|
|
12
|
+
- f1ab51725: <br>
|
|
130
13
|
- feat(picker): 下拉选择类组件增加 xs 尺寸 (5.0)
|
|
131
14
|
- feat(input): 输入框组件增加 xs 尺寸 (5.0)
|
|
15
|
+
- 6dca7795c: feat: 下拉选择组件增加 showIndicator 参数 & 修改 appearance 中的 unset 样式 (5.0)
|
|
16
|
+
- 77d969c2e: feat: 下拉选择类组件 appearance 参数增加 contained 类型 (5.0)
|
|
17
|
+
- 1fae66f2d: feat(tree): add shouldShowSwitcher prop for custom switcher display logic (#3471)
|
|
132
18
|
|
|
133
19
|
### Patch Changes
|
|
134
20
|
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
21
|
+
- cf89262c7: style(picker): 移除 picker 组件中的 \_\_text 样式定义 (5.0)
|
|
22
|
+
- be5a59325: style: 修改样式问题 (5.0)
|
|
23
|
+
- 79ea480f3: feat(global-context): 增加 size api 全局配置 (5.0)
|
|
24
|
+
- 2e56529f7: styles: 主题定制功能完善&&样式变量化写法改造&&兼容 RTL (5.0)
|
|
25
|
+
- eb718e940: fix: 修改组件问题 (5.0)
|
|
26
|
+
- de8d058dc: perf: 对下拉选择类组件的 customRender 的内容增加 memoization 以优化性能 (5.0)
|
|
27
|
+
- 5210770d9: feat(picker): add header api (5.0)
|
|
28
|
+
- 33da3144e: build: 将 package.json 中 exports 配置中的 types 配置放在最上面 (5.0)
|
|
29
|
+
- 0a4e90dbd: <br>
|
|
30
|
+
- style(tag-input): 间距调整 (5.0)
|
|
31
|
+
- style(select): 选择类组件选项圆角改为 4px (5.0)
|
|
32
|
+
- style(picker): 搜索框样式调整 (5.0)
|
|
33
|
+
- 99801c2d1: fix: 修复 UI 问题 (5.0)
|
|
34
|
+
- Updated dependencies [0b34e1c15]
|
|
35
|
+
- Updated dependencies [4a31cea53]
|
|
36
|
+
- Updated dependencies [da2e63a14]
|
|
37
|
+
- Updated dependencies [1e226cd66]
|
|
38
|
+
- Updated dependencies [b9989e482]
|
|
39
|
+
- Updated dependencies [9b34d99bc]
|
|
40
|
+
- Updated dependencies [1662753e0]
|
|
41
|
+
- Updated dependencies [122d1d859]
|
|
42
|
+
- Updated dependencies [f1ab51725]
|
|
43
|
+
- Updated dependencies [41552be0b]
|
|
44
|
+
- Updated dependencies [8c0ee78f0]
|
|
45
|
+
- Updated dependencies [9b34d99bc]
|
|
46
|
+
- Updated dependencies [8f3aa85e4]
|
|
47
|
+
- Updated dependencies [f4fc0ef30]
|
|
48
|
+
- Updated dependencies [ec4c7faa2]
|
|
49
|
+
- Updated dependencies [29cae09ea]
|
|
50
|
+
- Updated dependencies [fd4c20bbd]
|
|
51
|
+
- Updated dependencies [be5a59325]
|
|
52
|
+
- Updated dependencies [71fc15e5c]
|
|
53
|
+
- Updated dependencies [79ea480f3]
|
|
54
|
+
- Updated dependencies [2e56529f7]
|
|
55
|
+
- Updated dependencies [277c5033a]
|
|
56
|
+
- Updated dependencies [95abba983]
|
|
57
|
+
- Updated dependencies [4a31cea53]
|
|
58
|
+
- Updated dependencies [98df634ac]
|
|
59
|
+
- Updated dependencies [976ec929d]
|
|
60
|
+
- Updated dependencies [223bd1397]
|
|
61
|
+
- Updated dependencies [f1ab51725]
|
|
62
|
+
- Updated dependencies [6dca7795c]
|
|
63
|
+
- Updated dependencies [7b956b1eb]
|
|
64
|
+
- Updated dependencies [5210770d9]
|
|
65
|
+
- Updated dependencies [e2d184e74]
|
|
66
|
+
- Updated dependencies [77d969c2e]
|
|
67
|
+
- Updated dependencies [e42e2badf]
|
|
68
|
+
- Updated dependencies [33da3144e]
|
|
69
|
+
- Updated dependencies [7f3abee55]
|
|
70
|
+
- Updated dependencies [6fcda9bf2]
|
|
71
|
+
- Updated dependencies [0a4e90dbd]
|
|
72
|
+
- Updated dependencies [58ad82e94]
|
|
73
|
+
- Updated dependencies [a0f0c9d6b]
|
|
74
|
+
- Updated dependencies [4a31cea53]
|
|
75
|
+
- Updated dependencies [f2be367e9]
|
|
76
|
+
- Updated dependencies [1fae66f2d]
|
|
77
|
+
- Updated dependencies [1972fd16a]
|
|
78
|
+
- Updated dependencies [99801c2d1]
|
|
79
|
+
- Updated dependencies [86910f5e2]
|
|
80
|
+
- Updated dependencies [cb7b794d0]
|
|
81
|
+
- @hi-ui/picker@5.0.0-experimental.0
|
|
82
|
+
- @hi-ui/tree@5.0.0-experimental.0
|
|
83
|
+
- @hi-ui/input@5.0.0-experimental.0
|
|
84
|
+
- @hi-ui/popper@5.0.0-experimental.0
|
|
85
|
+
- @hi-ui/icons@5.0.0-experimental.0
|
|
86
|
+
- @hi-ui/core@5.0.0-experimental.0
|
|
87
|
+
- @hi-ui/use-data-source@5.0.0-experimental.0
|
|
88
|
+
- @hi-ui/use-search-mode@5.0.0-experimental.0
|
|
89
|
+
- @hi-ui/use-toggle@5.0.0-experimental.0
|
|
90
|
+
- @hi-ui/use-uncontrolled-state@5.0.0-experimental.0
|
|
91
|
+
- @hi-ui/highlighter@5.0.0-experimental.0
|
|
92
|
+
- @hi-ui/array-utils@5.0.0-experimental.0
|
|
93
|
+
- @hi-ui/classname@5.0.0-experimental.0
|
|
94
|
+
- @hi-ui/env@5.0.0-experimental.0
|
|
95
|
+
- @hi-ui/func-utils@5.0.0-experimental.0
|
|
96
|
+
- @hi-ui/tree-utils@5.0.0-experimental.0
|
|
97
|
+
- @hi-ui/type-assertion@5.0.0-experimental.0
|
|
155
98
|
|
|
156
99
|
## 4.3.1
|
|
157
100
|
|
package/lib/cjs/TreeSelect.js
CHANGED
|
@@ -45,6 +45,7 @@ var DEFAULT_EXPANDED_IDS = [];
|
|
|
45
45
|
* 树形选择器
|
|
46
46
|
*/
|
|
47
47
|
var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
48
|
+
var _b;
|
|
48
49
|
var _a$prefixCls = _a.prefixCls,
|
|
49
50
|
prefixCls = _a$prefixCls === void 0 ? TREE_SELECT_PREFIX : _a$prefixCls,
|
|
50
51
|
className = _a.className,
|
|
@@ -75,6 +76,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
75
76
|
filterOption = _a.filterOption,
|
|
76
77
|
keywordProp = _a.keyword,
|
|
77
78
|
onSearchProp = _a.onSearch,
|
|
79
|
+
clearSearchOnClosed = _a.clearSearchOnClosed,
|
|
78
80
|
clearable = _a.clearable,
|
|
79
81
|
onClear = _a.onClear,
|
|
80
82
|
invalid = _a.invalid,
|
|
@@ -84,13 +86,19 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
84
86
|
virtual = _a.virtual,
|
|
85
87
|
itemHeight = _a.itemHeight,
|
|
86
88
|
height = _a.height,
|
|
87
|
-
|
|
88
|
-
size = _a$size === void 0 ? 'md' : _a$size,
|
|
89
|
+
sizeProp = _a.size,
|
|
89
90
|
prefix = _a.prefix,
|
|
90
91
|
suffix = _a.suffix,
|
|
91
92
|
customRender = _a.customRender,
|
|
93
|
+
shouldShowSwitcher = _a.shouldShowSwitcher,
|
|
92
94
|
label = _a.label,
|
|
93
|
-
|
|
95
|
+
_a$showIndicator = _a.showIndicator,
|
|
96
|
+
showIndicator = _a$showIndicator === void 0 ? true : _a$showIndicator,
|
|
97
|
+
renderExtraHeader = _a.renderExtraHeader,
|
|
98
|
+
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", "keyword", "onSearch", "clearSearchOnClosed", "clearable", "onClear", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "size", "prefix", "suffix", "customRender", "shouldShowSwitcher", "label", "showIndicator", "renderExtraHeader"]);
|
|
99
|
+
var _useGlobalContext = core.useGlobalContext(),
|
|
100
|
+
globalSize = _useGlobalContext.size;
|
|
101
|
+
var size = (_b = sizeProp !== null && sizeProp !== void 0 ? sizeProp : globalSize) !== null && _b !== void 0 ? _b : 'md';
|
|
94
102
|
var i18n = core.useLocaleContext();
|
|
95
103
|
var pickerInnerRef = React.useRef(null);
|
|
96
104
|
var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
|
|
@@ -157,12 +165,12 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
157
165
|
setSelectedItem = _useState[1];
|
|
158
166
|
// ************************** 异步搜索 ************************* //
|
|
159
167
|
// const { loading, hasError, loadRemoteData } = useDataSource({ dataSource, validate: isArray })
|
|
160
|
-
var
|
|
168
|
+
var _c = useSearchMode.useAsyncSearch({
|
|
161
169
|
dataSource: dataSource
|
|
162
170
|
}),
|
|
163
|
-
loading =
|
|
164
|
-
hasError =
|
|
165
|
-
dataSourceStrategy = tslib.__rest(
|
|
171
|
+
loading = _c.loading,
|
|
172
|
+
hasError = _c.hasError,
|
|
173
|
+
dataSourceStrategy = tslib.__rest(_c, ["loading", "hasError"]);
|
|
166
174
|
var customSearchStrategy = useSearchMode.useTreeCustomSearch({
|
|
167
175
|
data: data,
|
|
168
176
|
filterOption: filterOption
|
|
@@ -197,8 +205,10 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
197
205
|
}
|
|
198
206
|
// 本地搜索执行默认高亮规则
|
|
199
207
|
var highlight = !!searchValue && (searchMode === 'highlight' || searchMode === 'filter');
|
|
208
|
+
// 转义正则表达式特殊字符,避免 searchValue 包含 [ 等特殊字符时报错
|
|
209
|
+
var escapedSearchValue = searchValue.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
200
210
|
var ret = highlight ? ( /*#__PURE__*/React__default["default"].createElement(highlighter.Highlighter, {
|
|
201
|
-
keyword: new RegExp(
|
|
211
|
+
keyword: new RegExp(escapedSearchValue, 'ig')
|
|
202
212
|
}, node.title)) : true;
|
|
203
213
|
return ret;
|
|
204
214
|
}, [titleRender, searchValue, searchMode]);
|
|
@@ -249,7 +259,9 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
249
259
|
searchable: searchable,
|
|
250
260
|
keyword: keywordProp,
|
|
251
261
|
onSearch: funcUtils.callAllFuncs(onSearchProp, onSearch),
|
|
262
|
+
clearSearchOnClosed: clearSearchOnClosed,
|
|
252
263
|
loading: rest.loading !== undefined ? rest.loading : loading,
|
|
264
|
+
header: renderExtraHeader === null || renderExtraHeader === void 0 ? void 0 : renderExtraHeader(),
|
|
253
265
|
trigger: customRender ? customRenderContent : ( /*#__PURE__*/React__default["default"].createElement(input.MockInput, {
|
|
254
266
|
style: {
|
|
255
267
|
maxWidth: appearance === 'contained' ? '360px' : undefined
|
|
@@ -261,6 +273,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
261
273
|
placeholder: placeholder,
|
|
262
274
|
displayRender: displayRenderProp,
|
|
263
275
|
prefix: prefix,
|
|
276
|
+
showIndicator: showIndicator,
|
|
264
277
|
suffix: [menuVisible ? /*#__PURE__*/React__default["default"].createElement(icons.UpOutlined, null) : /*#__PURE__*/React__default["default"].createElement(icons.DownOutlined, null), suffix],
|
|
265
278
|
focused: menuVisible,
|
|
266
279
|
value: value,
|
|
@@ -272,7 +285,6 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
272
285
|
label: label
|
|
273
286
|
}))
|
|
274
287
|
}), typeAssertion.isArrayNonEmpty(treeProps.data) ? ( /*#__PURE__*/React__default["default"].createElement(tree.Tree, Object.assign({
|
|
275
|
-
size: 'md',
|
|
276
288
|
className: prefixCls + "__tree",
|
|
277
289
|
selectable: true,
|
|
278
290
|
selectedId: value,
|
|
@@ -283,7 +295,8 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
283
295
|
onLoadChildren: onLoadChildren,
|
|
284
296
|
virtual: virtual,
|
|
285
297
|
itemHeight: itemHeight,
|
|
286
|
-
height: height
|
|
298
|
+
height: height,
|
|
299
|
+
shouldShowSwitcher: shouldShowSwitcher
|
|
287
300
|
}, treeProps))) : null);
|
|
288
301
|
});
|
|
289
302
|
if (env.__DEV__) {
|
package/lib/esm/TreeSelect.js
CHANGED
|
@@ -21,7 +21,7 @@ import { uniqBy } from '@hi-ui/array-utils';
|
|
|
21
21
|
import { Highlighter } from '@hi-ui/highlighter';
|
|
22
22
|
import { MockInput } from '@hi-ui/input';
|
|
23
23
|
import { UpOutlined, DownOutlined } from '@hi-ui/icons';
|
|
24
|
-
import { useLocaleContext } from '@hi-ui/core';
|
|
24
|
+
import { useGlobalContext, useLocaleContext } from '@hi-ui/core';
|
|
25
25
|
import { callAllFuncs } from '@hi-ui/func-utils';
|
|
26
26
|
import { useAsyncSearch, useTreeCustomSearch, useFilterSearch, useHighlightSearch, useSearchMode } from '@hi-ui/use-search-mode';
|
|
27
27
|
var TREE_SELECT_PREFIX = getPrefixCls('tree-select');
|
|
@@ -33,6 +33,7 @@ var DEFAULT_EXPANDED_IDS = [];
|
|
|
33
33
|
* 树形选择器
|
|
34
34
|
*/
|
|
35
35
|
var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
36
|
+
var _b;
|
|
36
37
|
var _a$prefixCls = _a.prefixCls,
|
|
37
38
|
prefixCls = _a$prefixCls === void 0 ? TREE_SELECT_PREFIX : _a$prefixCls,
|
|
38
39
|
className = _a.className,
|
|
@@ -63,6 +64,7 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
63
64
|
filterOption = _a.filterOption,
|
|
64
65
|
keywordProp = _a.keyword,
|
|
65
66
|
onSearchProp = _a.onSearch,
|
|
67
|
+
clearSearchOnClosed = _a.clearSearchOnClosed,
|
|
66
68
|
clearable = _a.clearable,
|
|
67
69
|
onClear = _a.onClear,
|
|
68
70
|
invalid = _a.invalid,
|
|
@@ -72,13 +74,19 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
72
74
|
virtual = _a.virtual,
|
|
73
75
|
itemHeight = _a.itemHeight,
|
|
74
76
|
height = _a.height,
|
|
75
|
-
|
|
76
|
-
size = _a$size === void 0 ? 'md' : _a$size,
|
|
77
|
+
sizeProp = _a.size,
|
|
77
78
|
prefix = _a.prefix,
|
|
78
79
|
suffix = _a.suffix,
|
|
79
80
|
customRender = _a.customRender,
|
|
81
|
+
shouldShowSwitcher = _a.shouldShowSwitcher,
|
|
80
82
|
label = _a.label,
|
|
81
|
-
|
|
83
|
+
_a$showIndicator = _a.showIndicator,
|
|
84
|
+
showIndicator = _a$showIndicator === void 0 ? true : _a$showIndicator,
|
|
85
|
+
renderExtraHeader = _a.renderExtraHeader,
|
|
86
|
+
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", "keyword", "onSearch", "clearSearchOnClosed", "clearable", "onClear", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "size", "prefix", "suffix", "customRender", "shouldShowSwitcher", "label", "showIndicator", "renderExtraHeader"]);
|
|
87
|
+
var _useGlobalContext = useGlobalContext(),
|
|
88
|
+
globalSize = _useGlobalContext.size;
|
|
89
|
+
var size = (_b = sizeProp !== null && sizeProp !== void 0 ? sizeProp : globalSize) !== null && _b !== void 0 ? _b : 'md';
|
|
82
90
|
var i18n = useLocaleContext();
|
|
83
91
|
var pickerInnerRef = useRef(null);
|
|
84
92
|
var placeholder = isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
|
|
@@ -145,12 +153,12 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
145
153
|
setSelectedItem = _useState[1];
|
|
146
154
|
// ************************** 异步搜索 ************************* //
|
|
147
155
|
// const { loading, hasError, loadRemoteData } = useDataSource({ dataSource, validate: isArray })
|
|
148
|
-
var
|
|
156
|
+
var _c = useAsyncSearch({
|
|
149
157
|
dataSource: dataSource
|
|
150
158
|
}),
|
|
151
|
-
loading =
|
|
152
|
-
hasError =
|
|
153
|
-
dataSourceStrategy = __rest(
|
|
159
|
+
loading = _c.loading,
|
|
160
|
+
hasError = _c.hasError,
|
|
161
|
+
dataSourceStrategy = __rest(_c, ["loading", "hasError"]);
|
|
154
162
|
var customSearchStrategy = useTreeCustomSearch({
|
|
155
163
|
data: data,
|
|
156
164
|
filterOption: filterOption
|
|
@@ -185,8 +193,10 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
185
193
|
}
|
|
186
194
|
// 本地搜索执行默认高亮规则
|
|
187
195
|
var highlight = !!searchValue && (searchMode === 'highlight' || searchMode === 'filter');
|
|
196
|
+
// 转义正则表达式特殊字符,避免 searchValue 包含 [ 等特殊字符时报错
|
|
197
|
+
var escapedSearchValue = searchValue.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
188
198
|
var ret = highlight ? ( /*#__PURE__*/React.createElement(Highlighter, {
|
|
189
|
-
keyword: new RegExp(
|
|
199
|
+
keyword: new RegExp(escapedSearchValue, 'ig')
|
|
190
200
|
}, node.title)) : true;
|
|
191
201
|
return ret;
|
|
192
202
|
}, [titleRender, searchValue, searchMode]);
|
|
@@ -237,7 +247,9 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
237
247
|
searchable: searchable,
|
|
238
248
|
keyword: keywordProp,
|
|
239
249
|
onSearch: callAllFuncs(onSearchProp, onSearch),
|
|
250
|
+
clearSearchOnClosed: clearSearchOnClosed,
|
|
240
251
|
loading: rest.loading !== undefined ? rest.loading : loading,
|
|
252
|
+
header: renderExtraHeader === null || renderExtraHeader === void 0 ? void 0 : renderExtraHeader(),
|
|
241
253
|
trigger: customRender ? customRenderContent : ( /*#__PURE__*/React.createElement(MockInput, {
|
|
242
254
|
style: {
|
|
243
255
|
maxWidth: appearance === 'contained' ? '360px' : undefined
|
|
@@ -249,6 +261,7 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
249
261
|
placeholder: placeholder,
|
|
250
262
|
displayRender: displayRenderProp,
|
|
251
263
|
prefix: prefix,
|
|
264
|
+
showIndicator: showIndicator,
|
|
252
265
|
suffix: [menuVisible ? /*#__PURE__*/React.createElement(UpOutlined, null) : /*#__PURE__*/React.createElement(DownOutlined, null), suffix],
|
|
253
266
|
focused: menuVisible,
|
|
254
267
|
value: value,
|
|
@@ -260,7 +273,6 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
260
273
|
label: label
|
|
261
274
|
}))
|
|
262
275
|
}), isArrayNonEmpty(treeProps.data) ? ( /*#__PURE__*/React.createElement(Tree, Object.assign({
|
|
263
|
-
size: 'md',
|
|
264
276
|
className: prefixCls + "__tree",
|
|
265
277
|
selectable: true,
|
|
266
278
|
selectedId: value,
|
|
@@ -271,7 +283,8 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
271
283
|
onLoadChildren: onLoadChildren,
|
|
272
284
|
virtual: virtual,
|
|
273
285
|
itemHeight: itemHeight,
|
|
274
|
-
height: height
|
|
286
|
+
height: height,
|
|
287
|
+
shouldShowSwitcher: shouldShowSwitcher
|
|
275
288
|
}, treeProps))) : null);
|
|
276
289
|
});
|
|
277
290
|
if (__DEV__) {
|
|
@@ -8,7 +8,7 @@ import { UseDataSource } from '@hi-ui/use-data-source';
|
|
|
8
8
|
* 树形选择器
|
|
9
9
|
*/
|
|
10
10
|
export declare const TreeSelect: React.ForwardRefExoticComponent<TreeSelectProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
11
|
-
export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' | 'trigger' | 'scrollable'> {
|
|
11
|
+
export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' | 'trigger' | 'scrollable' | 'header'> {
|
|
12
12
|
/**
|
|
13
13
|
* 展示数据
|
|
14
14
|
*/
|
|
@@ -144,4 +144,17 @@ export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' |
|
|
|
144
144
|
* 自定义触发器
|
|
145
145
|
*/
|
|
146
146
|
customRender?: React.ReactNode | ((selectedItem: TreeSelectDataItem | null) => React.ReactNode);
|
|
147
|
+
/**
|
|
148
|
+
* 自定义切换器显示逻辑
|
|
149
|
+
*/
|
|
150
|
+
shouldShowSwitcher?: (node: TreeNodeEventData) => boolean;
|
|
151
|
+
/**
|
|
152
|
+
* 是否展示指示器
|
|
153
|
+
* @default true
|
|
154
|
+
*/
|
|
155
|
+
showIndicator?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* 自定义下拉菜单顶部渲染
|
|
158
|
+
*/
|
|
159
|
+
renderExtraHeader?: () => React.ReactNode;
|
|
147
160
|
}
|
package/lib/types/context.d.ts
CHANGED
package/lib/types/types.d.ts
CHANGED
|
@@ -48,4 +48,4 @@ export interface TreeSelectDataSource<T = any> {
|
|
|
48
48
|
*/
|
|
49
49
|
transformResponse?: (response: object) => T;
|
|
50
50
|
}
|
|
51
|
-
export
|
|
51
|
+
export type TreeSelectAppearanceEnum = HiBaseAppearanceEnum | 'contained' | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/tree-select",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-experimental.0",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
@@ -44,31 +44,31 @@
|
|
|
44
44
|
"url": "https://github.com/XiaoMi/hiui/issues"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@hi-ui/array-utils": "^5.0.0-
|
|
48
|
-
"@hi-ui/classname": "^5.0.0-
|
|
49
|
-
"@hi-ui/env": "^5.0.0-
|
|
50
|
-
"@hi-ui/func-utils": "^5.0.0-
|
|
51
|
-
"@hi-ui/highlighter": "^5.0.0-
|
|
52
|
-
"@hi-ui/icons": "^5.0.0-
|
|
53
|
-
"@hi-ui/input": "^5.0.0-
|
|
54
|
-
"@hi-ui/picker": "^5.0.0-
|
|
55
|
-
"@hi-ui/popper": "^5.0.0-
|
|
56
|
-
"@hi-ui/tree": "^5.0.0-
|
|
57
|
-
"@hi-ui/tree-utils": "^5.0.0-
|
|
58
|
-
"@hi-ui/type-assertion": "^5.0.0-
|
|
59
|
-
"@hi-ui/use-data-source": "^5.0.0-
|
|
60
|
-
"@hi-ui/use-search-mode": "^5.0.0-
|
|
61
|
-
"@hi-ui/use-toggle": "^5.0.0-
|
|
62
|
-
"@hi-ui/use-uncontrolled-state": "^5.0.0-
|
|
47
|
+
"@hi-ui/array-utils": "^5.0.0-experimental.0",
|
|
48
|
+
"@hi-ui/classname": "^5.0.0-experimental.0",
|
|
49
|
+
"@hi-ui/env": "^5.0.0-experimental.0",
|
|
50
|
+
"@hi-ui/func-utils": "^5.0.0-experimental.0",
|
|
51
|
+
"@hi-ui/highlighter": "^5.0.0-experimental.0",
|
|
52
|
+
"@hi-ui/icons": "^5.0.0-experimental.0",
|
|
53
|
+
"@hi-ui/input": "^5.0.0-experimental.0",
|
|
54
|
+
"@hi-ui/picker": "^5.0.0-experimental.0",
|
|
55
|
+
"@hi-ui/popper": "^5.0.0-experimental.0",
|
|
56
|
+
"@hi-ui/tree": "^5.0.0-experimental.0",
|
|
57
|
+
"@hi-ui/tree-utils": "^5.0.0-experimental.0",
|
|
58
|
+
"@hi-ui/type-assertion": "^5.0.0-experimental.0",
|
|
59
|
+
"@hi-ui/use-data-source": "^5.0.0-experimental.0",
|
|
60
|
+
"@hi-ui/use-search-mode": "^5.0.0-experimental.0",
|
|
61
|
+
"@hi-ui/use-toggle": "^5.0.0-experimental.0",
|
|
62
|
+
"@hi-ui/use-uncontrolled-state": "^5.0.0-experimental.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@hi-ui/core": ">=5.0.0-
|
|
65
|
+
"@hi-ui/core": ">=5.0.0-experimental.0",
|
|
66
66
|
"react": ">=16.8.6",
|
|
67
67
|
"react-dom": ">=16.8.6"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@hi-ui/core": "^5.0.0-
|
|
71
|
-
"@hi-ui/core-css": "^5.0.0-
|
|
70
|
+
"@hi-ui/core": "^5.0.0-experimental.0",
|
|
71
|
+
"@hi-ui/core-css": "^5.0.0-experimental.0",
|
|
72
72
|
"react": "^17.0.1",
|
|
73
73
|
"react-dom": "^17.0.1"
|
|
74
74
|
}
|