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