@hi-ui/tree-select 4.3.0 → 4.4.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 +21 -0
- package/lib/cjs/TreeSelect.js +13 -2
- package/lib/esm/TreeSelect.js +14 -3
- package/lib/types/TreeSelect.d.ts +4 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @hi-ui/tree-select
|
|
2
2
|
|
|
3
|
+
## 4.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#3472](https://github.com/XiaoMi/hiui/pull/3472) [`1fae66f2d`](https://github.com/XiaoMi/hiui/commit/1fae66f2d10e4b3eba30e2af74bc793af91061d0) Thanks [@zyprepare](https://github.com/zyprepare)! - feat(tree): add shouldShowSwitcher prop for custom switcher display logic (#3471)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`1fae66f2d`](https://github.com/XiaoMi/hiui/commit/1fae66f2d10e4b3eba30e2af74bc793af91061d0)]:
|
|
12
|
+
- @hi-ui/tree@4.7.0
|
|
13
|
+
|
|
14
|
+
## 4.3.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#3196](https://github.com/XiaoMi/hiui/pull/3196) [`80a909d2d`](https://github.com/XiaoMi/hiui/commit/80a909d2dae99d68d71f2ec6f4b210080d032ec0) Thanks [@KEH3](https://github.com/KEH3)! - fix(popper): ref 中增加更新位置方法解决上游组件弹窗被遮挡问题 (#3195)
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`80a909d2d`](https://github.com/XiaoMi/hiui/commit/80a909d2dae99d68d71f2ec6f4b210080d032ec0)]:
|
|
21
|
+
- @hi-ui/picker@4.1.8
|
|
22
|
+
- @hi-ui/popper@4.1.7
|
|
23
|
+
|
|
3
24
|
## 4.3.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/lib/cjs/TreeSelect.js
CHANGED
|
@@ -89,8 +89,10 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
89
89
|
prefix = _a.prefix,
|
|
90
90
|
suffix = _a.suffix,
|
|
91
91
|
customRender = _a.customRender,
|
|
92
|
-
|
|
92
|
+
shouldShowSwitcher = _a.shouldShowSwitcher,
|
|
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", "shouldShowSwitcher"]);
|
|
93
94
|
var i18n = core.useLocaleContext();
|
|
95
|
+
var pickerInnerRef = React.useRef(null);
|
|
94
96
|
var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
|
|
95
97
|
var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
|
|
96
98
|
visible: visible,
|
|
@@ -222,8 +224,16 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
222
224
|
return flattedData;
|
|
223
225
|
}, [selectedItem, flattedData]);
|
|
224
226
|
var cls = classname.cx(prefixCls, className);
|
|
227
|
+
React.useEffect(function () {
|
|
228
|
+
var _a;
|
|
229
|
+
if (menuVisible) {
|
|
230
|
+
// 数据改变时更新弹窗显示位置,避免弹窗内容被遮挡
|
|
231
|
+
(_a = pickerInnerRef.current) === null || _a === void 0 ? void 0 : _a.update();
|
|
232
|
+
}
|
|
233
|
+
}, [menuVisible, treeProps.expandedIds]);
|
|
225
234
|
return /*#__PURE__*/React__default["default"].createElement(picker.Picker, Object.assign({
|
|
226
235
|
ref: ref,
|
|
236
|
+
innerRef: pickerInnerRef,
|
|
227
237
|
className: cls
|
|
228
238
|
}, rest, {
|
|
229
239
|
visible: menuVisible,
|
|
@@ -268,7 +278,8 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
|
|
|
268
278
|
onLoadChildren: onLoadChildren,
|
|
269
279
|
virtual: virtual,
|
|
270
280
|
itemHeight: itemHeight,
|
|
271
|
-
height: height
|
|
281
|
+
height: height,
|
|
282
|
+
shouldShowSwitcher: shouldShowSwitcher
|
|
272
283
|
}, treeProps))) : null);
|
|
273
284
|
});
|
|
274
285
|
if (env.__DEV__) {
|
package/lib/esm/TreeSelect.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
10
|
import { __rest } from 'tslib';
|
|
11
|
-
import React, { forwardRef, useCallback, useMemo, useState } from 'react';
|
|
11
|
+
import React, { forwardRef, useRef, useCallback, useMemo, useState, useEffect } from 'react';
|
|
12
12
|
import { getPrefixCls, cx } from '@hi-ui/classname';
|
|
13
13
|
import { __DEV__ } from '@hi-ui/env';
|
|
14
14
|
import { useUncontrolledToggle } from '@hi-ui/use-toggle';
|
|
@@ -77,8 +77,10 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
77
77
|
prefix = _a.prefix,
|
|
78
78
|
suffix = _a.suffix,
|
|
79
79
|
customRender = _a.customRender,
|
|
80
|
-
|
|
80
|
+
shouldShowSwitcher = _a.shouldShowSwitcher,
|
|
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", "shouldShowSwitcher"]);
|
|
81
82
|
var i18n = useLocaleContext();
|
|
83
|
+
var pickerInnerRef = useRef(null);
|
|
82
84
|
var placeholder = isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
|
|
83
85
|
var _useUncontrolledToggl = useUncontrolledToggle({
|
|
84
86
|
visible: visible,
|
|
@@ -210,8 +212,16 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
210
212
|
return flattedData;
|
|
211
213
|
}, [selectedItem, flattedData]);
|
|
212
214
|
var cls = cx(prefixCls, className);
|
|
215
|
+
useEffect(function () {
|
|
216
|
+
var _a;
|
|
217
|
+
if (menuVisible) {
|
|
218
|
+
// 数据改变时更新弹窗显示位置,避免弹窗内容被遮挡
|
|
219
|
+
(_a = pickerInnerRef.current) === null || _a === void 0 ? void 0 : _a.update();
|
|
220
|
+
}
|
|
221
|
+
}, [menuVisible, treeProps.expandedIds]);
|
|
213
222
|
return /*#__PURE__*/React.createElement(Picker, Object.assign({
|
|
214
223
|
ref: ref,
|
|
224
|
+
innerRef: pickerInnerRef,
|
|
215
225
|
className: cls
|
|
216
226
|
}, rest, {
|
|
217
227
|
visible: menuVisible,
|
|
@@ -256,7 +266,8 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
|
256
266
|
onLoadChildren: onLoadChildren,
|
|
257
267
|
virtual: virtual,
|
|
258
268
|
itemHeight: itemHeight,
|
|
259
|
-
height: height
|
|
269
|
+
height: height,
|
|
270
|
+
shouldShowSwitcher: shouldShowSwitcher
|
|
260
271
|
}, treeProps))) : null);
|
|
261
272
|
});
|
|
262
273
|
if (__DEV__) {
|
|
@@ -140,4 +140,8 @@ export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' |
|
|
|
140
140
|
* 自定义触发器
|
|
141
141
|
*/
|
|
142
142
|
customRender?: React.ReactNode | ((selectedItem: TreeSelectDataItem | null) => React.ReactNode);
|
|
143
|
+
/**
|
|
144
|
+
* 自定义切换器显示逻辑
|
|
145
|
+
*/
|
|
146
|
+
shouldShowSwitcher?: (node: TreeNodeEventData) => boolean;
|
|
143
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ui/tree-select",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "A sub-package for @hi-ui/hiui.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "HiUI <mi-hiui@xiaomi.com>",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"@hi-ui/highlighter": "^4.1.2",
|
|
51
51
|
"@hi-ui/icons": "^4.0.19",
|
|
52
52
|
"@hi-ui/input": "^4.4.0",
|
|
53
|
-
"@hi-ui/picker": "^4.1.
|
|
54
|
-
"@hi-ui/popper": "^4.1.
|
|
55
|
-
"@hi-ui/tree": "^4.
|
|
53
|
+
"@hi-ui/picker": "^4.1.8",
|
|
54
|
+
"@hi-ui/popper": "^4.1.7",
|
|
55
|
+
"@hi-ui/tree": "^4.7.0",
|
|
56
56
|
"@hi-ui/tree-utils": "^4.1.4",
|
|
57
57
|
"@hi-ui/type-assertion": "^4.0.4",
|
|
58
58
|
"@hi-ui/use-data-source": "^4.0.4",
|