@hi-ui/tree-select 5.0.0-canary.8 → 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 CHANGED
@@ -1,149 +1,100 @@
1
1
  # @hi-ui/tree-select
2
2
 
3
- ## 5.0.0-canary.8
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [efce04a26]
8
- - Updated dependencies [9106dca82]
9
- - @hi-ui/picker@5.0.0-canary.10
10
- - @hi-ui/popper@5.0.0-canary.6
11
- - @hi-ui/core@5.0.0-canary.3
12
- - @hi-ui/input@5.0.0-canary.10
13
- - @hi-ui/icons@5.0.0-canary.3
14
- - @hi-ui/highlighter@5.0.0-canary.3
15
- - @hi-ui/tree@5.0.0-canary.4
16
-
17
- ## 5.0.0-canary.7
18
-
19
- ### Patch Changes
20
-
21
- - 643c0e09f: style(picker): 移除 picker 组件中的 \_\_text 样式定义 (5.0)
22
- - Updated dependencies [7182c7bb8]
23
- - @hi-ui/input@5.0.0-canary.9
24
-
25
- ## 5.0.0-canary.6
26
-
27
- ### Patch Changes
28
-
29
- - chore: rebase master (5.0)
30
- - Updated dependencies
31
- - @hi-ui/core@5.0.0-canary.2
32
- - @hi-ui/use-data-source@5.0.0-canary.2
33
- - @hi-ui/use-search-mode@5.0.0-canary.2
34
- - @hi-ui/use-toggle@5.0.0-canary.2
35
- - @hi-ui/use-uncontrolled-state@5.0.0-canary.2
36
- - @hi-ui/icons@5.0.0-canary.2
37
- - @hi-ui/highlighter@5.0.0-canary.2
38
- - @hi-ui/input@5.0.0-canary.7
39
- - @hi-ui/picker@5.0.0-canary.8
40
- - @hi-ui/popper@5.0.0-canary.3
41
- - @hi-ui/tree@5.0.0-canary.3
42
- - @hi-ui/array-utils@5.0.0-canary.2
43
- - @hi-ui/classname@5.0.0-canary.2
44
- - @hi-ui/env@5.0.0-canary.2
45
- - @hi-ui/func-utils@5.0.0-canary.2
46
- - @hi-ui/tree-utils@5.0.0-canary.2
47
- - @hi-ui/type-assertion@5.0.0-canary.2
48
-
49
- ## 5.0.0-canary.5
50
-
51
- ### Patch Changes
52
-
53
- - 4b09e728b: build: 将 package.json 中 exports 配置中的 types 配置放在最上面 (5.0)
54
- - Updated dependencies [ba7c324c2]
55
- - Updated dependencies [ba7c324c2]
56
- - Updated dependencies [4b09e728b]
57
- - Updated dependencies [ba7c324c2]
58
- - @hi-ui/tree@5.0.0-canary.2
59
- - @hi-ui/picker@5.0.0-canary.7
60
- - @hi-ui/core@5.0.0-canary.1
61
- - @hi-ui/use-data-source@5.0.0-canary.1
62
- - @hi-ui/use-search-mode@5.0.0-canary.1
63
- - @hi-ui/use-toggle@5.0.0-canary.1
64
- - @hi-ui/use-uncontrolled-state@5.0.0-canary.1
65
- - @hi-ui/icons@5.0.0-canary.1
66
- - @hi-ui/highlighter@5.0.0-canary.1
67
- - @hi-ui/input@5.0.0-canary.6
68
- - @hi-ui/popper@5.0.0-canary.2
69
- - @hi-ui/array-utils@5.0.0-canary.1
70
- - @hi-ui/classname@5.0.0-canary.1
71
- - @hi-ui/env@5.0.0-canary.1
72
- - @hi-ui/func-utils@5.0.0-canary.1
73
- - @hi-ui/tree-utils@5.0.0-canary.1
74
- - @hi-ui/type-assertion@5.0.0-canary.1
75
-
76
- ## 5.0.0-canary.4
77
-
78
- ### Patch Changes
79
-
80
- - 40f819417: fix: 修复 UI 问题 (5.0)
81
- - Updated dependencies [40f819417]
82
- - @hi-ui/input@5.0.0-canary.5
83
-
84
- ## 5.0.0-canary.3
85
-
86
- ### Patch Changes
87
-
88
- - a89b3b3ae: fix: 修改组件问题 (5.0)
89
-
90
- ## 5.0.0-canary.2
91
-
92
- ### Patch Changes
93
-
94
- - df3615e78: <br>
95
- - style(tag-input): 间距调整 (5.0)
96
- - style(select): 选择类组件选项圆角改为 4px (5.0)
97
- - style(picker): 搜索框样式调整 (5.0)
98
- - Updated dependencies [3cb3377dc]
99
- - Updated dependencies [df3615e78]
100
- - @hi-ui/picker@5.0.0-canary.3
101
-
102
- ## 5.0.0-canary.1
103
-
104
- ### Minor Changes
105
-
106
- - 6c4bf35af: feat: 下拉选择类组件 appearance 参数增加 contained 类型 (5.0)
107
-
108
- ### Patch Changes
109
-
110
- - Updated dependencies [6c4bf35af]
111
- - @hi-ui/input@5.0.0-canary.2
112
-
113
- ## 5.0.0-canary.0
3
+ ## 5.0.0-experimental.0
114
4
 
115
5
  ### Major Changes
116
6
 
117
- - 225ebaa51: feat: 组件的 package.json 中的 exports 统一加上 types 配置 (5.0)
7
+ - 8f3aa85e4: feat: 组件的 package.json 中的 exports 统一加上 types 配置 (5.0)
118
8
 
119
9
  ### Minor Changes
120
10
 
121
- - 428716024: <br>
11
+ - b9989e482: feat(picker): 增加 clearSearchOnClosed api 默认是 false (5.0)
12
+ - f1ab51725: <br>
122
13
  - feat(picker): 下拉选择类组件增加 xs 尺寸 (5.0)
123
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)
124
18
 
125
19
  ### Patch Changes
126
20
 
127
- - Updated dependencies [428716024]
128
- - Updated dependencies [225ebaa51]
129
- - Updated dependencies [428716024]
130
- - @hi-ui/input@5.0.0-canary.0
131
- - @hi-ui/picker@5.0.0-canary.0
132
- - @hi-ui/core@5.0.0-canary.0
133
- - @hi-ui/use-data-source@5.0.0-canary.0
134
- - @hi-ui/use-search-mode@5.0.0-canary.0
135
- - @hi-ui/use-toggle@5.0.0-canary.0
136
- - @hi-ui/use-uncontrolled-state@5.0.0-canary.0
137
- - @hi-ui/icons@5.0.0-canary.0
138
- - @hi-ui/highlighter@5.0.0-canary.0
139
- - @hi-ui/popper@5.0.0-canary.0
140
- - @hi-ui/tree@5.0.0-canary.0
141
- - @hi-ui/array-utils@5.0.0-canary.0
142
- - @hi-ui/classname@5.0.0-canary.0
143
- - @hi-ui/env@5.0.0-canary.0
144
- - @hi-ui/func-utils@5.0.0-canary.0
145
- - @hi-ui/tree-utils@5.0.0-canary.0
146
- - @hi-ui/type-assertion@5.0.0-canary.0
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
147
98
 
148
99
  ## 4.3.1
149
100
 
@@ -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
- _a$size = _a.size,
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
- 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", "clearable", "onClear", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "size", "prefix", "suffix", "customRender", "label"]);
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 _b = useSearchMode.useAsyncSearch({
168
+ var _c = useSearchMode.useAsyncSearch({
161
169
  dataSource: dataSource
162
170
  }),
163
- loading = _b.loading,
164
- hasError = _b.hasError,
165
- dataSourceStrategy = tslib.__rest(_b, ["loading", "hasError"]);
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(searchValue, 'ig')
211
+ keyword: new RegExp(escapedSearchValue, 'ig')
202
212
  }, node.title)) : true;
203
213
  return ret;
204
214
  }, [titleRender, searchValue, searchMode]);
@@ -223,6 +233,9 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
223
233
  }
224
234
  return flattedData;
225
235
  }, [selectedItem, flattedData]);
236
+ var customRenderContent = React.useMemo(function () {
237
+ return customRender ? typeof customRender === 'function' ? customRender(selectedItem) : customRender : null;
238
+ }, [customRender, selectedItem]);
226
239
  var cls = classname.cx(prefixCls, className);
227
240
  React.useEffect(function () {
228
241
  var _a;
@@ -246,8 +259,10 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
246
259
  searchable: searchable,
247
260
  keyword: keywordProp,
248
261
  onSearch: funcUtils.callAllFuncs(onSearchProp, onSearch),
262
+ clearSearchOnClosed: clearSearchOnClosed,
249
263
  loading: rest.loading !== undefined ? rest.loading : loading,
250
- trigger: customRender ? typeof customRender === 'function' ? customRender(selectedItem) : customRender : ( /*#__PURE__*/React__default["default"].createElement(input.MockInput, {
264
+ header: renderExtraHeader === null || renderExtraHeader === void 0 ? void 0 : renderExtraHeader(),
265
+ trigger: customRender ? customRenderContent : ( /*#__PURE__*/React__default["default"].createElement(input.MockInput, {
251
266
  style: {
252
267
  maxWidth: appearance === 'contained' ? '360px' : undefined
253
268
  },
@@ -258,6 +273,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
258
273
  placeholder: placeholder,
259
274
  displayRender: displayRenderProp,
260
275
  prefix: prefix,
276
+ showIndicator: showIndicator,
261
277
  suffix: [menuVisible ? /*#__PURE__*/React__default["default"].createElement(icons.UpOutlined, null) : /*#__PURE__*/React__default["default"].createElement(icons.DownOutlined, null), suffix],
262
278
  focused: menuVisible,
263
279
  value: value,
@@ -269,7 +285,6 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
269
285
  label: label
270
286
  }))
271
287
  }), typeAssertion.isArrayNonEmpty(treeProps.data) ? ( /*#__PURE__*/React__default["default"].createElement(tree.Tree, Object.assign({
272
- size: 'md',
273
288
  className: prefixCls + "__tree",
274
289
  selectable: true,
275
290
  selectedId: value,
@@ -280,7 +295,8 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
280
295
  onLoadChildren: onLoadChildren,
281
296
  virtual: virtual,
282
297
  itemHeight: itemHeight,
283
- height: height
298
+ height: height,
299
+ shouldShowSwitcher: shouldShowSwitcher
284
300
  }, treeProps))) : null);
285
301
  });
286
302
  if (env.__DEV__) {
@@ -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
- _a$size = _a.size,
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
- 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", "clearable", "onClear", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "size", "prefix", "suffix", "customRender", "label"]);
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 _b = useAsyncSearch({
156
+ var _c = useAsyncSearch({
149
157
  dataSource: dataSource
150
158
  }),
151
- loading = _b.loading,
152
- hasError = _b.hasError,
153
- dataSourceStrategy = __rest(_b, ["loading", "hasError"]);
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(searchValue, 'ig')
199
+ keyword: new RegExp(escapedSearchValue, 'ig')
190
200
  }, node.title)) : true;
191
201
  return ret;
192
202
  }, [titleRender, searchValue, searchMode]);
@@ -211,6 +221,9 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
211
221
  }
212
222
  return flattedData;
213
223
  }, [selectedItem, flattedData]);
224
+ var customRenderContent = useMemo(function () {
225
+ return customRender ? typeof customRender === 'function' ? customRender(selectedItem) : customRender : null;
226
+ }, [customRender, selectedItem]);
214
227
  var cls = cx(prefixCls, className);
215
228
  useEffect(function () {
216
229
  var _a;
@@ -234,8 +247,10 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
234
247
  searchable: searchable,
235
248
  keyword: keywordProp,
236
249
  onSearch: callAllFuncs(onSearchProp, onSearch),
250
+ clearSearchOnClosed: clearSearchOnClosed,
237
251
  loading: rest.loading !== undefined ? rest.loading : loading,
238
- trigger: customRender ? typeof customRender === 'function' ? customRender(selectedItem) : customRender : ( /*#__PURE__*/React.createElement(MockInput, {
252
+ header: renderExtraHeader === null || renderExtraHeader === void 0 ? void 0 : renderExtraHeader(),
253
+ trigger: customRender ? customRenderContent : ( /*#__PURE__*/React.createElement(MockInput, {
239
254
  style: {
240
255
  maxWidth: appearance === 'contained' ? '360px' : undefined
241
256
  },
@@ -246,6 +261,7 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
246
261
  placeholder: placeholder,
247
262
  displayRender: displayRenderProp,
248
263
  prefix: prefix,
264
+ showIndicator: showIndicator,
249
265
  suffix: [menuVisible ? /*#__PURE__*/React.createElement(UpOutlined, null) : /*#__PURE__*/React.createElement(DownOutlined, null), suffix],
250
266
  focused: menuVisible,
251
267
  value: value,
@@ -257,7 +273,6 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
257
273
  label: label
258
274
  }))
259
275
  }), isArrayNonEmpty(treeProps.data) ? ( /*#__PURE__*/React.createElement(Tree, Object.assign({
260
- size: 'md',
261
276
  className: prefixCls + "__tree",
262
277
  selectable: true,
263
278
  selectedId: value,
@@ -268,7 +283,8 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
268
283
  onLoadChildren: onLoadChildren,
269
284
  virtual: virtual,
270
285
  itemHeight: itemHeight,
271
- height: height
286
+ height: height,
287
+ shouldShowSwitcher: shouldShowSwitcher
272
288
  }, treeProps))) : null);
273
289
  });
274
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
  }
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  export declare const TreeSelectProvider: import("react").Provider<any>;
3
2
  export declare const useTreeSelectContext: () => any;
@@ -48,4 +48,4 @@ export interface TreeSelectDataSource<T = any> {
48
48
  */
49
49
  transformResponse?: (response: object) => T;
50
50
  }
51
- export declare type TreeSelectAppearanceEnum = HiBaseAppearanceEnum | 'contained' | undefined;
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-canary.8",
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-canary.2",
48
- "@hi-ui/classname": "^5.0.0-canary.2",
49
- "@hi-ui/env": "^5.0.0-canary.2",
50
- "@hi-ui/func-utils": "^5.0.0-canary.2",
51
- "@hi-ui/highlighter": "^5.0.0-canary.3",
52
- "@hi-ui/icons": "^5.0.0-canary.3",
53
- "@hi-ui/input": "^5.0.0-canary.10",
54
- "@hi-ui/picker": "^5.0.0-canary.10",
55
- "@hi-ui/popper": "^5.0.0-canary.6",
56
- "@hi-ui/tree": "^5.0.0-canary.4",
57
- "@hi-ui/tree-utils": "^5.0.0-canary.2",
58
- "@hi-ui/type-assertion": "^5.0.0-canary.2",
59
- "@hi-ui/use-data-source": "^5.0.0-canary.2",
60
- "@hi-ui/use-search-mode": "^5.0.0-canary.2",
61
- "@hi-ui/use-toggle": "^5.0.0-canary.2",
62
- "@hi-ui/use-uncontrolled-state": "^5.0.0-canary.2"
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-canary.3",
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-canary.3",
71
- "@hi-ui/core-css": "^5.0.0-canary.6",
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
  }