@hi-ui/tree-select 4.2.1 → 4.3.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @hi-ui/tree-select
2
2
 
3
+ ## 4.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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)
8
+
9
+ - Updated dependencies [[`80a909d2d`](https://github.com/XiaoMi/hiui/commit/80a909d2dae99d68d71f2ec6f4b210080d032ec0)]:
10
+ - @hi-ui/picker@4.1.8
11
+ - @hi-ui/popper@4.1.7
12
+
13
+ ## 4.3.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#3172](https://github.com/XiaoMi/hiui/pull/3172) [`a883d8e19`](https://github.com/XiaoMi/hiui/commit/a883d8e197446ef0e7cefcc5cc44d21ed1d0807f) Thanks [@zyprepare](https://github.com/zyprepare)! - feat(mock-input): 增加 onClear 参数 (#3171)
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [[`7bf0630`](https://github.com/XiaoMi/hiui/commit/7bf063053a73923af41c33370c31371325206276), [`a883d8e19`](https://github.com/XiaoMi/hiui/commit/a883d8e197446ef0e7cefcc5cc44d21ed1d0807f)]:
22
+ - @hi-ui/highlighter@4.1.2
23
+ - @hi-ui/input@4.4.0
24
+
3
25
  ## 4.2.1
4
26
 
5
27
  ### Patch Changes
@@ -76,6 +76,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
76
76
  keywordProp = _a.keyword,
77
77
  onSearchProp = _a.onSearch,
78
78
  clearable = _a.clearable,
79
+ onClear = _a.onClear,
79
80
  invalid = _a.invalid,
80
81
  displayRenderProp = _a.displayRender,
81
82
  placeholderProp = _a.placeholder,
@@ -88,8 +89,9 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
88
89
  prefix = _a.prefix,
89
90
  suffix = _a.suffix,
90
91
  customRender = _a.customRender,
91
- 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", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "size", "prefix", "suffix", "customRender"]);
92
+ 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"]);
92
93
  var i18n = core.useLocaleContext();
94
+ var pickerInnerRef = React.useRef(null);
93
95
  var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
94
96
  var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
95
97
  visible: visible,
@@ -221,8 +223,16 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
221
223
  return flattedData;
222
224
  }, [selectedItem, flattedData]);
223
225
  var cls = classname.cx(prefixCls, className);
226
+ React.useEffect(function () {
227
+ var _a;
228
+ if (menuVisible) {
229
+ // 数据改变时更新弹窗显示位置,避免弹窗内容被遮挡
230
+ (_a = pickerInnerRef.current) === null || _a === void 0 ? void 0 : _a.update();
231
+ }
232
+ }, [menuVisible, treeProps.expandedIds]);
224
233
  return /*#__PURE__*/React__default["default"].createElement(picker.Picker, Object.assign({
225
234
  ref: ref,
235
+ innerRef: pickerInnerRef,
226
236
  className: cls
227
237
  }, rest, {
228
238
  visible: menuVisible,
@@ -242,6 +252,7 @@ var TreeSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
242
252
  // disabled={disabled}
243
253
  size: size,
244
254
  clearable: clearable,
255
+ onClear: onClear,
245
256
  placeholder: placeholder,
246
257
  displayRender: displayRenderProp,
247
258
  prefix: prefix,
@@ -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';
@@ -64,6 +64,7 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
64
64
  keywordProp = _a.keyword,
65
65
  onSearchProp = _a.onSearch,
66
66
  clearable = _a.clearable,
67
+ onClear = _a.onClear,
67
68
  invalid = _a.invalid,
68
69
  displayRenderProp = _a.displayRender,
69
70
  placeholderProp = _a.placeholder,
@@ -76,8 +77,9 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
76
77
  prefix = _a.prefix,
77
78
  suffix = _a.suffix,
78
79
  customRender = _a.customRender,
79
- 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", "invalid", "displayRender", "placeholder", "appearance", "virtual", "itemHeight", "height", "size", "prefix", "suffix", "customRender"]);
80
+ 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"]);
80
81
  var i18n = useLocaleContext();
82
+ var pickerInnerRef = useRef(null);
81
83
  var placeholder = isUndef(placeholderProp) ? i18n.get('treeSelect.placeholder') : placeholderProp;
82
84
  var _useUncontrolledToggl = useUncontrolledToggle({
83
85
  visible: visible,
@@ -209,8 +211,16 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
209
211
  return flattedData;
210
212
  }, [selectedItem, flattedData]);
211
213
  var cls = cx(prefixCls, className);
214
+ useEffect(function () {
215
+ var _a;
216
+ if (menuVisible) {
217
+ // 数据改变时更新弹窗显示位置,避免弹窗内容被遮挡
218
+ (_a = pickerInnerRef.current) === null || _a === void 0 ? void 0 : _a.update();
219
+ }
220
+ }, [menuVisible, treeProps.expandedIds]);
212
221
  return /*#__PURE__*/React.createElement(Picker, Object.assign({
213
222
  ref: ref,
223
+ innerRef: pickerInnerRef,
214
224
  className: cls
215
225
  }, rest, {
216
226
  visible: menuVisible,
@@ -230,6 +240,7 @@ var TreeSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
230
240
  // disabled={disabled}
231
241
  size: size,
232
242
  clearable: clearable,
243
+ onClear: onClear,
233
244
  placeholder: placeholder,
234
245
  displayRender: displayRenderProp,
235
246
  prefix: prefix,
@@ -102,6 +102,10 @@ export interface TreeSelectProps extends Omit<PickerProps, 'data' | 'onChange' |
102
102
  * 是否可清空
103
103
  */
104
104
  clearable?: boolean;
105
+ /**
106
+ * 点击关闭按钮时触发
107
+ */
108
+ onClear?: () => void;
105
109
  /**
106
110
  * 设置展现形式
107
111
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/tree-select",
3
- "version": "4.2.1",
3
+ "version": "4.3.1",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -47,11 +47,11 @@
47
47
  "@hi-ui/classname": "^4.0.5",
48
48
  "@hi-ui/env": "^4.0.5",
49
49
  "@hi-ui/func-utils": "^4.0.4",
50
- "@hi-ui/highlighter": "^4.0.9",
50
+ "@hi-ui/highlighter": "^4.1.2",
51
51
  "@hi-ui/icons": "^4.0.19",
52
- "@hi-ui/input": "^4.1.1",
53
- "@hi-ui/picker": "^4.1.6",
54
- "@hi-ui/popper": "^4.1.5",
52
+ "@hi-ui/input": "^4.4.0",
53
+ "@hi-ui/picker": "^4.1.8",
54
+ "@hi-ui/popper": "^4.1.7",
55
55
  "@hi-ui/tree": "^4.6.1",
56
56
  "@hi-ui/tree-utils": "^4.1.4",
57
57
  "@hi-ui/type-assertion": "^4.0.4",