@hi-ui/check-select 4.6.3 → 4.6.4

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,17 @@
1
1
  # @hi-ui/check-select
2
2
 
3
+ ## 4.6.4
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
+ - [#3208](https://github.com/XiaoMi/hiui/pull/3208) [`36086f4c8`](https://github.com/XiaoMi/hiui/commit/36086f4c8ab11728dd4d0bb34b4d9301c6068452) Thanks [@zyprepare](https://github.com/zyprepare)! - fix(select): 修复多级分组下分组标题左间距不对问题 (#3207)
10
+
11
+ - Updated dependencies [[`80a909d2d`](https://github.com/XiaoMi/hiui/commit/80a909d2dae99d68d71f2ec6f4b210080d032ec0)]:
12
+ - @hi-ui/picker@4.1.8
13
+ - @hi-ui/popper@4.1.7
14
+
3
15
  ## 4.6.3
4
16
 
5
17
  ### Patch Changes
@@ -101,6 +101,7 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
101
101
  var i18n = core.useLocaleContext();
102
102
  var placeholder = typeAssertion.isUndef(placeholderProp) ? i18n.get('checkSelect.placeholder') : placeholderProp;
103
103
  // ************************** Picker ************************* //
104
+ var pickerInnerRef = React.useRef(null);
104
105
  var _useUncontrolledToggl = useToggle.useUncontrolledToggle({
105
106
  visible: visible,
106
107
  disabled: disabled,
@@ -292,16 +293,21 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
292
293
  var cls = classname.cx(prefixCls, className, prefixCls + "--" + (menuVisible ? 'open' : 'closed'));
293
294
  var listRef = React.useRef(null);
294
295
  React.useEffect(function () {
295
- var _a;
296
- // 每次打开或数据改变时触发一次滚动条显示
297
- if (menuVisible && typeAssertion.isArrayNonEmpty(showData)) {
298
- (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(undefined);
296
+ var _a, _b;
297
+ if (menuVisible) {
298
+ // 数据改变时更新弹窗显示位置,避免弹窗内容被遮挡
299
+ (_a = pickerInnerRef.current) === null || _a === void 0 ? void 0 : _a.update();
300
+ // 数据改变时触发一次滚动条显示
301
+ if (typeAssertion.isArrayNonEmpty(showData)) {
302
+ (_b = listRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo(undefined);
303
+ }
299
304
  }
300
305
  }, [menuVisible, showData]);
301
306
  return /*#__PURE__*/React__default["default"].createElement(context.CheckSelectProvider, {
302
307
  value: context$1
303
308
  }, /*#__PURE__*/React__default["default"].createElement(picker.Picker, Object.assign({
304
309
  ref: ref,
310
+ innerRef: pickerInnerRef,
305
311
  className: cls
306
312
  }, rootProps, {
307
313
  visible: menuVisible,
@@ -378,7 +384,8 @@ var CheckSelect = /*#__PURE__*/React.forwardRef(function (_a, ref) {
378
384
  }, virtualListProps), function (node, index) {
379
385
  /* 反向 map,搜索删选数据时会对数据进行处理 */
380
386
  return 'groupTitle' in node ? ( /*#__PURE__*/React__default["default"].createElement(CheckSelectOptionGroup, {
381
- label: node.groupTitle
387
+ label: node.groupTitle,
388
+ depth: node.depth
382
389
  })) : ( /*#__PURE__*/React__default["default"].createElement(CheckSelectOption, {
383
390
  option: node,
384
391
  depth: node.depth,
@@ -451,12 +458,13 @@ var CheckSelectOptionGroup = /*#__PURE__*/React.forwardRef(function (_a, ref) {
451
458
  prefixCls = _a$prefixCls3 === void 0 ? optionGroupPrefix : _a$prefixCls3,
452
459
  className = _a.className,
453
460
  label = _a.label,
454
- rest = tslib.__rest(_a, ["prefixCls", "className", "label"]);
461
+ depth = _a.depth,
462
+ rest = tslib.__rest(_a, ["prefixCls", "className", "label", "depth"]);
455
463
  var cls = classname.cx(prefixCls, className);
456
464
  return /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
457
465
  ref: ref,
458
466
  className: cls
459
- }, rest), /*#__PURE__*/React__default["default"].createElement("span", null, label));
467
+ }, rest), renderIndent(prefixCls, !depth || depth === 0 ? 0 : depth - 1), /*#__PURE__*/React__default["default"].createElement("span", null, label));
460
468
  });
461
469
  // @ts-ignore
462
470
  CheckSelectOptionGroup.HiName = 'CheckSelectOptionGroup';
@@ -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, useEffect, useRef } 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 { useCheckSelect } from './use-check-select.js';
@@ -87,6 +87,7 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
87
87
  var i18n = useLocaleContext();
88
88
  var placeholder = isUndef(placeholderProp) ? i18n.get('checkSelect.placeholder') : placeholderProp;
89
89
  // ************************** Picker ************************* //
90
+ var pickerInnerRef = useRef(null);
90
91
  var _useUncontrolledToggl = useUncontrolledToggle({
91
92
  visible: visible,
92
93
  disabled: disabled,
@@ -278,16 +279,21 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
278
279
  var cls = cx(prefixCls, className, prefixCls + "--" + (menuVisible ? 'open' : 'closed'));
279
280
  var listRef = useRef(null);
280
281
  useEffect(function () {
281
- var _a;
282
- // 每次打开或数据改变时触发一次滚动条显示
283
- if (menuVisible && isArrayNonEmpty(showData)) {
284
- (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(undefined);
282
+ var _a, _b;
283
+ if (menuVisible) {
284
+ // 数据改变时更新弹窗显示位置,避免弹窗内容被遮挡
285
+ (_a = pickerInnerRef.current) === null || _a === void 0 ? void 0 : _a.update();
286
+ // 数据改变时触发一次滚动条显示
287
+ if (isArrayNonEmpty(showData)) {
288
+ (_b = listRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo(undefined);
289
+ }
285
290
  }
286
291
  }, [menuVisible, showData]);
287
292
  return /*#__PURE__*/React.createElement(CheckSelectProvider, {
288
293
  value: context
289
294
  }, /*#__PURE__*/React.createElement(Picker, Object.assign({
290
295
  ref: ref,
296
+ innerRef: pickerInnerRef,
291
297
  className: cls
292
298
  }, rootProps, {
293
299
  visible: menuVisible,
@@ -364,7 +370,8 @@ var CheckSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
364
370
  }, virtualListProps), function (node, index) {
365
371
  /* 反向 map,搜索删选数据时会对数据进行处理 */
366
372
  return 'groupTitle' in node ? ( /*#__PURE__*/React.createElement(CheckSelectOptionGroup, {
367
- label: node.groupTitle
373
+ label: node.groupTitle,
374
+ depth: node.depth
368
375
  })) : ( /*#__PURE__*/React.createElement(CheckSelectOption, {
369
376
  option: node,
370
377
  depth: node.depth,
@@ -437,12 +444,13 @@ var CheckSelectOptionGroup = /*#__PURE__*/forwardRef(function (_a, ref) {
437
444
  prefixCls = _a$prefixCls3 === void 0 ? optionGroupPrefix : _a$prefixCls3,
438
445
  className = _a.className,
439
446
  label = _a.label,
440
- rest = __rest(_a, ["prefixCls", "className", "label"]);
447
+ depth = _a.depth,
448
+ rest = __rest(_a, ["prefixCls", "className", "label", "depth"]);
441
449
  var cls = cx(prefixCls, className);
442
450
  return /*#__PURE__*/React.createElement("div", Object.assign({
443
451
  ref: ref,
444
452
  className: cls
445
- }, rest), /*#__PURE__*/React.createElement("span", null, label));
453
+ }, rest), renderIndent(prefixCls, !depth || depth === 0 ? 0 : depth - 1), /*#__PURE__*/React.createElement("span", null, label));
446
454
  });
447
455
  // @ts-ignore
448
456
  CheckSelectOptionGroup.HiName = 'CheckSelectOptionGroup';
@@ -124,4 +124,8 @@ export interface CheckSelectOptionProps extends HiBaseHTMLProps {
124
124
  }
125
125
  export declare const CheckSelectOptionGroup: React.ForwardRefExoticComponent<Pick<CheckSelectOptionGroupProps, string | number> & React.RefAttributes<HTMLDivElement | null>>;
126
126
  export interface CheckSelectOptionGroupProps extends HiBaseHTMLProps {
127
+ /**
128
+ * 深度
129
+ */
130
+ depth?: number;
127
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hi-ui/check-select",
3
- "version": "4.6.3",
3
+ "version": "4.6.4",
4
4
  "description": "A sub-package for @hi-ui/hiui.",
5
5
  "keywords": [],
6
6
  "author": "HiUI <mi-hiui@xiaomi.com>",
@@ -52,8 +52,8 @@
52
52
  "@hi-ui/highlighter": "^4.1.0",
53
53
  "@hi-ui/icons": "^4.0.19",
54
54
  "@hi-ui/input": "^4.3.0",
55
- "@hi-ui/picker": "^4.1.6",
56
- "@hi-ui/popper": "^4.1.6",
55
+ "@hi-ui/picker": "^4.1.8",
56
+ "@hi-ui/popper": "^4.1.7",
57
57
  "@hi-ui/tag-input": "^4.1.3",
58
58
  "@hi-ui/times": "^4.0.4",
59
59
  "@hi-ui/tree-utils": "^4.1.6",