@douyinfe/semi-ui 2.6.0-beta.0 → 2.6.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.
@@ -46,15 +46,15 @@ export default class Button extends PureComponent<ButtonProps> {
46
46
  disabled: PropTypes.Requireable<boolean>;
47
47
  prefixCls: PropTypes.Requireable<string>;
48
48
  style: PropTypes.Requireable<object>;
49
- size: PropTypes.Requireable<unknown>;
50
- type: PropTypes.Requireable<unknown>;
49
+ size: PropTypes.Requireable<"default" | "small" | "large">;
50
+ type: PropTypes.Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
51
51
  block: PropTypes.Requireable<boolean>;
52
52
  onClick: PropTypes.Requireable<(...args: any[]) => any>;
53
53
  onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
54
54
  circle: PropTypes.Requireable<boolean>;
55
55
  loading: PropTypes.Requireable<boolean>;
56
- htmlType: PropTypes.Requireable<unknown>;
57
- theme: PropTypes.Requireable<unknown>;
56
+ htmlType: PropTypes.Requireable<"button" | "reset" | "submit">;
57
+ theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
58
58
  className: PropTypes.Requireable<string>;
59
59
  onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
60
60
  onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
@@ -16,8 +16,8 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
16
16
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
17
  disabled: PropTypes.Requireable<boolean>;
18
18
  type: PropTypes.Requireable<string>;
19
- size: PropTypes.Requireable<unknown>;
20
- theme: PropTypes.Requireable<unknown>;
19
+ size: PropTypes.Requireable<"default" | "small" | "large">;
20
+ theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
21
21
  'aria-label': PropTypes.Requireable<string>;
22
22
  };
23
23
  static defaultProps: {
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
- import { ButtonProps as BaseButtonProps } from './Button';
3
2
  import { IconButtonProps } from '../iconButton';
4
3
  export { ButtonProps as BaseButtonProps, HtmlType, Size, Theme, Type } from './Button';
5
4
  export { HorizontalPaddingType } from '../iconButton';
6
5
  export { ButtonGroupProps } from './buttonGroup';
7
6
  export { SplitButtonGroupProps } from './splitButtonGroup';
8
- export interface ButtonProps extends IconButtonProps, BaseButtonProps {
7
+ export interface ButtonProps extends IconButtonProps {
9
8
  }
10
9
  declare class Button extends React.PureComponent<ButtonProps> {
11
10
  static propTypes: {
@@ -18,18 +17,18 @@ declare class Button extends React.PureComponent<ButtonProps> {
18
17
  noHorizontalPadding: import("prop-types").Requireable<string | boolean | any[]>;
19
18
  children: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
20
19
  theme: import("prop-types").Requireable<string>;
21
- iconPosition: import("prop-types").Requireable<unknown>;
20
+ iconPosition: import("prop-types").Requireable<"left" | "right">;
22
21
  className: import("prop-types").Requireable<string>;
23
22
  onMouseEnter: import("prop-types").Requireable<(...args: any[]) => any>;
24
23
  onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
25
24
  disabled: import("prop-types").Requireable<boolean>;
26
- size: import("prop-types").Requireable<unknown>;
27
- type: import("prop-types").Requireable<unknown>;
25
+ size: import("prop-types").Requireable<"default" | "small" | "large">;
26
+ type: import("prop-types").Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
28
27
  block: import("prop-types").Requireable<boolean>;
29
28
  onClick: import("prop-types").Requireable<(...args: any[]) => any>;
30
29
  onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
31
30
  circle: import("prop-types").Requireable<boolean>;
32
- htmlType: import("prop-types").Requireable<unknown>;
31
+ htmlType: import("prop-types").Requireable<"button" | "reset" | "submit">;
33
32
  'aria-label': import("prop-types").Requireable<string>;
34
33
  };
35
34
  constructor(props?: {});
@@ -19,7 +19,7 @@ export interface IconButtonProps extends ButtonProps {
19
19
  }
20
20
  declare class IconButton extends PureComponent<IconButtonProps> {
21
21
  static defaultProps: {
22
- iconPosition: any;
22
+ iconPosition: "left";
23
23
  prefixCls: string;
24
24
  loading: boolean;
25
25
  noHorizontalPadding: boolean;
@@ -36,7 +36,7 @@ declare class IconButton extends PureComponent<IconButtonProps> {
36
36
  noHorizontalPadding: PropTypes.Requireable<string | boolean | any[]>;
37
37
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
38
38
  theme: PropTypes.Requireable<string>;
39
- iconPosition: PropTypes.Requireable<unknown>;
39
+ iconPosition: PropTypes.Requireable<"left" | "right">;
40
40
  className: PropTypes.Requireable<string>;
41
41
  onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
42
42
  onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
@@ -1,7 +1,7 @@
1
1
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import ItemFoundation, { ItemProps, SelectedItemProps, ItemAdapter } from '@douyinfe/semi-foundation/lib/cjs/navigation/itemFoundation';
4
+ import ItemFoundation, { ItemAdapter, ItemProps, SelectedItemProps } from '@douyinfe/semi-foundation/lib/cjs/navigation/itemFoundation';
5
5
  export interface NavItemProps extends ItemProps, BaseProps {
6
6
  children?: React.ReactNode;
7
7
  disabled?: boolean;
@@ -63,7 +63,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
63
63
  constructor(props: NavItemProps);
64
64
  _invokeContextFunc(funcName: string, ...args: any[]): any;
65
65
  get adapter(): ItemAdapter<NavItemProps, NavItemState>;
66
- renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean): JSX.Element;
66
+ renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean, key?: number | string): JSX.Element;
67
67
  setItemRef: (ref: HTMLLIElement) => void;
68
68
  wrapTooltip: (node: React.ReactNode) => JSX.Element;
69
69
  handleClick: (e: React.MouseEvent) => void;
@@ -16,10 +16,10 @@ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-s
16
16
 
17
17
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
18
18
 
19
- var _noop2 = _interopRequireDefault(require("lodash/noop"));
20
-
21
19
  var _times2 = _interopRequireDefault(require("lodash/times"));
22
20
 
21
+ var _noop2 = _interopRequireDefault(require("lodash/noop"));
22
+
23
23
  var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
24
24
 
25
25
  var _react = _interopRequireDefault(require("react"));
@@ -146,6 +146,7 @@ class NavItem extends _baseComponent.default {
146
146
  var _context3;
147
147
 
148
148
  let isToggleIcon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
149
+ let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
149
150
 
150
151
  if (this.props.isSubNav) {
151
152
  return null;
@@ -166,7 +167,8 @@ class NavItem extends _baseComponent.default {
166
167
  ["".concat(clsPrefix, "-icon-info")]: !isToggleIcon
167
168
  });
168
169
  return /*#__PURE__*/_react.default.createElement("i", {
169
- className: className
170
+ className: className,
171
+ key: key
170
172
  }, (0, _utils.isSemiIcon)(icon) ? /*#__PURE__*/_react.default.cloneElement(icon, {
171
173
  size: icon.props.size || iconSize
172
174
  }) : icon);
@@ -206,12 +208,12 @@ class NavItem extends _baseComponent.default {
206
208
 
207
209
  if (mode === _constants.strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
208
210
  const iconAmount = icon && !indent ? level : level - 1;
209
- placeholderIcons = (0, _times2.default)(iconAmount, () => this.renderIcon(null, _constants.strings.ICON_POS_RIGHT, false));
211
+ placeholderIcons = (0, _times2.default)(iconAmount, index => this.renderIcon(null, _constants.strings.ICON_POS_RIGHT, false, index));
210
212
  }
211
213
 
212
- itemChildren = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, placeholderIcons, this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, _constants.strings.ICON_POS_RIGHT, true), icon || indent || isInSubNav ? this.renderIcon(icon, _constants.strings.ICON_POS_LEFT) : null, !(0, _isNullOrUndefined.default)(text) ? /*#__PURE__*/_react.default.createElement("span", {
214
+ itemChildren = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, placeholderIcons, this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, _constants.strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'), icon || indent || isInSubNav ? this.renderIcon(icon, _constants.strings.ICON_POS_LEFT, false, 'key-position-left') : null, !(0, _isNullOrUndefined.default)(text) ? /*#__PURE__*/_react.default.createElement("span", {
213
215
  className: "".concat(_constants.cssClasses.PREFIX, "-item-text")
214
- }, text) : '', this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, _constants.strings.ICON_POS_RIGHT, true));
216
+ }, text) : '', this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, _constants.strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'));
215
217
  }
216
218
 
217
219
  if (typeof link === 'string') {
@@ -233,7 +233,7 @@ class SubNav extends _baseComponent.default {
233
233
  if (mode === _constants.strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
234
234
  /* Different icons' amount means different indents.*/
235
235
  const iconAmount = icon && !indent ? level : level - 1;
236
- placeholderIcons = (0, _times2.default)(iconAmount, index => this.renderIcon(null, _constants.strings.ICON_POS_RIGHT, false, undefined, index));
236
+ placeholderIcons = (0, _times2.default)(iconAmount, index => this.renderIcon(null, _constants.strings.ICON_POS_RIGHT, false, false, index));
237
237
  }
238
238
 
239
239
  const titleDiv = /*#__PURE__*/_react.default.createElement("div", {
@@ -245,7 +245,7 @@ class SubNav extends _baseComponent.default {
245
245
  onKeyPress: this.handleKeyPress
246
246
  }, /*#__PURE__*/_react.default.createElement("div", {
247
247
  className: "".concat(prefixCls, "-item-inner")
248
- }, placeholderIcons, this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, _constants.strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== _constants.strings.MODE_HORIZONTAL ? this.renderIcon(icon, _constants.strings.ICON_POS_LEFT, undefined, undefined, 'key-inSubNav-position-left') : null, /*#__PURE__*/_react.default.createElement("span", {
248
+ }, placeholderIcons, this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, _constants.strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== _constants.strings.MODE_HORIZONTAL ? this.renderIcon(icon, _constants.strings.ICON_POS_LEFT, false, false, 'key-inSubNav-position-left') : null, /*#__PURE__*/_react.default.createElement("span", {
249
249
  className: "".concat(prefixCls, "-item-text")
250
250
  }, text), this.context.toggleIconPosition === _constants.strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, _constants.strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')));
251
251
 
@@ -43,6 +43,8 @@ export interface BodyState {
43
43
  }
44
44
  export interface BodyContext {
45
45
  getVirtualizedListRef: GetVirtualizedListRef;
46
+ flattenedColumns: ColumnProps[];
47
+ getCellWidths: (flattenedColumns: ColumnProps[]) => number[];
46
48
  }
47
49
  declare const _default: React.ForwardRefExoticComponent<Omit<BodyProps, "forwardedRef"> & React.RefAttributes<HTMLDivElement>>;
48
50
  export default _default;
@@ -418,8 +418,13 @@ class Body extends _baseComponent.default {
418
418
  const {
419
419
  flattenedColumns,
420
420
  getCellWidths
421
- } = _this.context;
422
- const cellWidths = getCellWidths(flattenedColumns);
421
+ } = _this.context; // we use memoized cellWidths to avoid re-render expanded row (fix #686)
422
+
423
+ if (flattenedColumns !== _this.flattenedColumns) {
424
+ _this.flattenedColumns = flattenedColumns;
425
+ _this.cellWidths = getCellWidths(flattenedColumns);
426
+ }
427
+
423
428
  return /*#__PURE__*/_react.default.createElement(_ExpandedRow.default, {
424
429
  style: style,
425
430
  components: components,
@@ -431,7 +436,7 @@ class Body extends _baseComponent.default {
431
436
  index: index,
432
437
  virtualized: virtualized,
433
438
  key: (0, _utils.genExpandedRowKey)(key),
434
- cellWidths: cellWidths
439
+ cellWidths: _this.cellWidths
435
440
  });
436
441
  };
437
442
  /**
@@ -601,7 +606,9 @@ class Body extends _baseComponent.default {
601
606
  };
602
607
  this.listRef = /*#__PURE__*/_react.default.createRef();
603
608
  const {
604
- getVirtualizedListRef
609
+ getVirtualizedListRef,
610
+ flattenedColumns,
611
+ getCellWidths
605
612
  } = context;
606
613
 
607
614
  if (getVirtualizedListRef) {
@@ -613,6 +620,8 @@ class Body extends _baseComponent.default {
613
620
  }
614
621
 
615
622
  this.foundation = new _bodyFoundation.default(this.adapter);
623
+ this.flattenedColumns = flattenedColumns;
624
+ this.cellWidths = getCellWidths(flattenedColumns);
616
625
  this.observer = null;
617
626
  }
618
627
 
@@ -229,7 +229,9 @@ class Tooltip extends _baseComponent.default {
229
229
  } = _ref;
230
230
  return /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
231
231
  className: (0, _classnames.default)(className, animateCls),
232
- style: (0, _assign.default)((0, _assign.default)((0, _assign.default)({}, animateStyle), {
232
+ style: (0, _assign.default)((0, _assign.default)((0, _assign.default)({
233
+ visibility: 'visible'
234
+ }, animateStyle), {
233
235
  transformOrigin
234
236
  }), style)
235
237
  }, portalEventSet, animateEvents, {
@@ -241,7 +243,9 @@ class Tooltip extends _baseComponent.default {
241
243
  className: className
242
244
  }, portalEventSet, {
243
245
  "x-placement": placement,
244
- style: style
246
+ style: (0, _assign.default)({
247
+ visibility: motion ? undefined : 'visible'
248
+ }, style)
245
249
  }), content, icon);
246
250
  return /*#__PURE__*/_react.default.createElement(_index.default, {
247
251
  getPopupContainer: this.props.getPopupContainer,
@@ -46,15 +46,15 @@ export default class Button extends PureComponent<ButtonProps> {
46
46
  disabled: PropTypes.Requireable<boolean>;
47
47
  prefixCls: PropTypes.Requireable<string>;
48
48
  style: PropTypes.Requireable<object>;
49
- size: PropTypes.Requireable<unknown>;
50
- type: PropTypes.Requireable<unknown>;
49
+ size: PropTypes.Requireable<"default" | "small" | "large">;
50
+ type: PropTypes.Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
51
51
  block: PropTypes.Requireable<boolean>;
52
52
  onClick: PropTypes.Requireable<(...args: any[]) => any>;
53
53
  onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
54
54
  circle: PropTypes.Requireable<boolean>;
55
55
  loading: PropTypes.Requireable<boolean>;
56
- htmlType: PropTypes.Requireable<unknown>;
57
- theme: PropTypes.Requireable<unknown>;
56
+ htmlType: PropTypes.Requireable<"button" | "reset" | "submit">;
57
+ theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
58
58
  className: PropTypes.Requireable<string>;
59
59
  onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
60
60
  onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
@@ -16,8 +16,8 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
16
16
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
17
17
  disabled: PropTypes.Requireable<boolean>;
18
18
  type: PropTypes.Requireable<string>;
19
- size: PropTypes.Requireable<unknown>;
20
- theme: PropTypes.Requireable<unknown>;
19
+ size: PropTypes.Requireable<"default" | "small" | "large">;
20
+ theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
21
21
  'aria-label': PropTypes.Requireable<string>;
22
22
  };
23
23
  static defaultProps: {
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
- import { ButtonProps as BaseButtonProps } from './Button';
3
2
  import { IconButtonProps } from '../iconButton';
4
3
  export { ButtonProps as BaseButtonProps, HtmlType, Size, Theme, Type } from './Button';
5
4
  export { HorizontalPaddingType } from '../iconButton';
6
5
  export { ButtonGroupProps } from './buttonGroup';
7
6
  export { SplitButtonGroupProps } from './splitButtonGroup';
8
- export interface ButtonProps extends IconButtonProps, BaseButtonProps {
7
+ export interface ButtonProps extends IconButtonProps {
9
8
  }
10
9
  declare class Button extends React.PureComponent<ButtonProps> {
11
10
  static propTypes: {
@@ -18,18 +17,18 @@ declare class Button extends React.PureComponent<ButtonProps> {
18
17
  noHorizontalPadding: import("prop-types").Requireable<string | boolean | any[]>;
19
18
  children: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
20
19
  theme: import("prop-types").Requireable<string>;
21
- iconPosition: import("prop-types").Requireable<unknown>;
20
+ iconPosition: import("prop-types").Requireable<"left" | "right">;
22
21
  className: import("prop-types").Requireable<string>;
23
22
  onMouseEnter: import("prop-types").Requireable<(...args: any[]) => any>;
24
23
  onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
25
24
  disabled: import("prop-types").Requireable<boolean>;
26
- size: import("prop-types").Requireable<unknown>;
27
- type: import("prop-types").Requireable<unknown>;
25
+ size: import("prop-types").Requireable<"default" | "small" | "large">;
26
+ type: import("prop-types").Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
28
27
  block: import("prop-types").Requireable<boolean>;
29
28
  onClick: import("prop-types").Requireable<(...args: any[]) => any>;
30
29
  onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
31
30
  circle: import("prop-types").Requireable<boolean>;
32
- htmlType: import("prop-types").Requireable<unknown>;
31
+ htmlType: import("prop-types").Requireable<"button" | "reset" | "submit">;
33
32
  'aria-label': import("prop-types").Requireable<string>;
34
33
  };
35
34
  constructor(props?: {});
@@ -19,7 +19,7 @@ export interface IconButtonProps extends ButtonProps {
19
19
  }
20
20
  declare class IconButton extends PureComponent<IconButtonProps> {
21
21
  static defaultProps: {
22
- iconPosition: any;
22
+ iconPosition: "left";
23
23
  prefixCls: string;
24
24
  loading: boolean;
25
25
  noHorizontalPadding: boolean;
@@ -36,7 +36,7 @@ declare class IconButton extends PureComponent<IconButtonProps> {
36
36
  noHorizontalPadding: PropTypes.Requireable<string | boolean | any[]>;
37
37
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
38
38
  theme: PropTypes.Requireable<string>;
39
- iconPosition: PropTypes.Requireable<unknown>;
39
+ iconPosition: PropTypes.Requireable<"left" | "right">;
40
40
  className: PropTypes.Requireable<string>;
41
41
  onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
42
42
  onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
@@ -1,7 +1,7 @@
1
1
  import BaseComponent, { BaseProps } from '../_base/baseComponent';
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import ItemFoundation, { ItemProps, SelectedItemProps, ItemAdapter } from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
4
+ import ItemFoundation, { ItemAdapter, ItemProps, SelectedItemProps } from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
5
5
  export interface NavItemProps extends ItemProps, BaseProps {
6
6
  children?: React.ReactNode;
7
7
  disabled?: boolean;
@@ -63,7 +63,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
63
63
  constructor(props: NavItemProps);
64
64
  _invokeContextFunc(funcName: string, ...args: any[]): any;
65
65
  get adapter(): ItemAdapter<NavItemProps, NavItemState>;
66
- renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean): JSX.Element;
66
+ renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean, key?: number | string): JSX.Element;
67
67
  setItemRef: (ref: HTMLLIElement) => void;
68
68
  wrapTooltip: (node: React.ReactNode) => JSX.Element;
69
69
  handleClick: (e: React.MouseEvent) => void;
@@ -1,5 +1,5 @@
1
- import _noop from "lodash/noop";
2
1
  import _times from "lodash/times";
2
+ import _noop from "lodash/noop";
3
3
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
4
4
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
5
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
@@ -14,7 +14,7 @@ import cls from 'classnames';
14
14
  import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
15
15
  import { cloneDeep, isSemiIcon } from '../_utils';
16
16
  import ItemFoundation from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
17
- import { strings, cssClasses } from '@douyinfe/semi-foundation/lib/es/navigation/constants';
17
+ import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/navigation/constants';
18
18
  import Tooltip from '../tooltip';
19
19
  import NavContext from './nav-context';
20
20
  import Dropdown from '../dropdown';
@@ -118,6 +118,7 @@ export default class NavItem extends BaseComponent {
118
118
  var _context3;
119
119
 
120
120
  let isToggleIcon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
121
+ let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
121
122
 
122
123
  if (this.props.isSubNav) {
123
124
  return null;
@@ -138,7 +139,8 @@ export default class NavItem extends BaseComponent {
138
139
  ["".concat(clsPrefix, "-icon-info")]: !isToggleIcon
139
140
  });
140
141
  return /*#__PURE__*/React.createElement("i", {
141
- className: className
142
+ className: className,
143
+ key: key
142
144
  }, isSemiIcon(icon) ? /*#__PURE__*/React.cloneElement(icon, {
143
145
  size: icon.props.size || iconSize
144
146
  }) : icon);
@@ -178,12 +180,12 @@ export default class NavItem extends BaseComponent {
178
180
 
179
181
  if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
180
182
  const iconAmount = icon && !indent ? level : level - 1;
181
- placeholderIcons = _times(iconAmount, () => this.renderIcon(null, strings.ICON_POS_RIGHT, false));
183
+ placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, index));
182
184
  }
183
185
 
184
- itemChildren = /*#__PURE__*/React.createElement(React.Fragment, null, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true), icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT) : null, !isNullOrUndefined(text) ? /*#__PURE__*/React.createElement("span", {
186
+ itemChildren = /*#__PURE__*/React.createElement(React.Fragment, null, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'), icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, 'key-position-left') : null, !isNullOrUndefined(text) ? /*#__PURE__*/React.createElement("span", {
185
187
  className: "".concat(cssClasses.PREFIX, "-item-text")
186
- }, text) : '', this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true));
188
+ }, text) : '', this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'));
187
189
  }
188
190
 
189
191
  if (typeof link === 'string') {
@@ -203,7 +203,7 @@ export default class SubNav extends BaseComponent {
203
203
  if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
204
204
  /* Different icons' amount means different indents.*/
205
205
  const iconAmount = icon && !indent ? level : level - 1;
206
- placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, undefined, index));
206
+ placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, false, index));
207
207
  }
208
208
 
209
209
  const titleDiv = /*#__PURE__*/React.createElement("div", {
@@ -215,7 +215,7 @@ export default class SubNav extends BaseComponent {
215
215
  onKeyPress: this.handleKeyPress
216
216
  }, /*#__PURE__*/React.createElement("div", {
217
217
  className: "".concat(prefixCls, "-item-inner")
218
- }, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== strings.MODE_HORIZONTAL ? this.renderIcon(icon, strings.ICON_POS_LEFT, undefined, undefined, 'key-inSubNav-position-left') : null, /*#__PURE__*/React.createElement("span", {
218
+ }, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left'), icon || indent || isInSubNav && mode !== strings.MODE_HORIZONTAL ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, false, 'key-inSubNav-position-left') : null, /*#__PURE__*/React.createElement("span", {
219
219
  className: "".concat(prefixCls, "-item-text")
220
220
  }, text), this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')));
221
221
  return titleDiv;
@@ -43,6 +43,8 @@ export interface BodyState {
43
43
  }
44
44
  export interface BodyContext {
45
45
  getVirtualizedListRef: GetVirtualizedListRef;
46
+ flattenedColumns: ColumnProps[];
47
+ getCellWidths: (flattenedColumns: ColumnProps[]) => number[];
46
48
  }
47
49
  declare const _default: React.ForwardRefExoticComponent<Omit<BodyProps, "forwardedRef"> & React.RefAttributes<HTMLDivElement>>;
48
50
  export default _default;
@@ -389,8 +389,13 @@ class Body extends BaseComponent {
389
389
  const {
390
390
  flattenedColumns,
391
391
  getCellWidths
392
- } = _this.context;
393
- const cellWidths = getCellWidths(flattenedColumns);
392
+ } = _this.context; // we use memoized cellWidths to avoid re-render expanded row (fix #686)
393
+
394
+ if (flattenedColumns !== _this.flattenedColumns) {
395
+ _this.flattenedColumns = flattenedColumns;
396
+ _this.cellWidths = getCellWidths(flattenedColumns);
397
+ }
398
+
394
399
  return /*#__PURE__*/React.createElement(ExpandedRow, {
395
400
  style: style,
396
401
  components: components,
@@ -402,7 +407,7 @@ class Body extends BaseComponent {
402
407
  index: index,
403
408
  virtualized: virtualized,
404
409
  key: genExpandedRowKey(key),
405
- cellWidths: cellWidths
410
+ cellWidths: _this.cellWidths
406
411
  });
407
412
  };
408
413
  /**
@@ -580,7 +585,9 @@ class Body extends BaseComponent {
580
585
  };
581
586
  this.listRef = /*#__PURE__*/React.createRef();
582
587
  const {
583
- getVirtualizedListRef
588
+ getVirtualizedListRef,
589
+ flattenedColumns,
590
+ getCellWidths
584
591
  } = context;
585
592
 
586
593
  if (getVirtualizedListRef) {
@@ -592,6 +599,8 @@ class Body extends BaseComponent {
592
599
  }
593
600
 
594
601
  this.foundation = new BodyFoundation(this.adapter);
602
+ this.flattenedColumns = flattenedColumns;
603
+ this.cellWidths = getCellWidths(flattenedColumns);
595
604
  this.observer = null;
596
605
  }
597
606
 
@@ -184,7 +184,9 @@ export default class Tooltip extends BaseComponent {
184
184
  } = _ref;
185
185
  return /*#__PURE__*/React.createElement("div", _Object$assign({
186
186
  className: classNames(className, animateCls),
187
- style: _Object$assign(_Object$assign(_Object$assign({}, animateStyle), {
187
+ style: _Object$assign(_Object$assign(_Object$assign({
188
+ visibility: 'visible'
189
+ }, animateStyle), {
188
190
  transformOrigin
189
191
  }), style)
190
192
  }, portalEventSet, animateEvents, {
@@ -196,7 +198,9 @@ export default class Tooltip extends BaseComponent {
196
198
  className: className
197
199
  }, portalEventSet, {
198
200
  "x-placement": placement,
199
- style: style
201
+ style: _Object$assign({
202
+ visibility: motion ? undefined : 'visible'
203
+ }, style)
200
204
  }), content, icon);
201
205
  return /*#__PURE__*/React.createElement(Portal, {
202
206
  getPopupContainer: this.props.getPopupContainer,
@@ -4,12 +4,16 @@ import BaseComponent, { BaseProps } from '../_base/baseComponent';
4
4
  import React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import cls from 'classnames';
7
- import { times, noop } from 'lodash';
7
+ import { noop, times } from 'lodash';
8
8
 
9
9
  import isNullOrUndefined from '@douyinfe/semi-foundation/utils/isNullOrUndefined';
10
10
  import { cloneDeep, isSemiIcon } from '../_utils';
11
- import ItemFoundation, { ItemProps, SelectedItemProps, ItemAdapter } from '@douyinfe/semi-foundation/navigation/itemFoundation';
12
- import { strings, cssClasses } from '@douyinfe/semi-foundation/navigation/constants';
11
+ import ItemFoundation, {
12
+ ItemAdapter,
13
+ ItemProps,
14
+ SelectedItemProps
15
+ } from '@douyinfe/semi-foundation/navigation/itemFoundation';
16
+ import { cssClasses, strings } from '@douyinfe/semi-foundation/navigation/constants';
13
17
 
14
18
  import Tooltip from '../tooltip';
15
19
  import NavContext from './nav-context';
@@ -114,7 +118,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
114
118
  };
115
119
  }
116
120
 
117
- renderIcon(icon: React.ReactNode, pos: string, isToggleIcon = false) {
121
+ renderIcon(icon: React.ReactNode, pos: string, isToggleIcon = false, key: number | string = 0) {
118
122
  if (this.props.isSubNav) {
119
123
  return null;
120
124
  }
@@ -134,8 +138,8 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
134
138
  });
135
139
 
136
140
  return (
137
- <i className={className}>
138
- {isSemiIcon(icon) ? React.cloneElement((icon as React.ReactElement), {size: (icon as React.ReactElement).props.size || iconSize}) : icon}
141
+ <i className={className} key={key}>
142
+ {isSemiIcon(icon) ? React.cloneElement((icon as React.ReactElement), { size: (icon as React.ReactElement).props.size || iconSize }) : icon}
139
143
  </i>
140
144
  );
141
145
  }
@@ -189,7 +193,6 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
189
193
  const selected = this.adapter.getSelected();
190
194
 
191
195
 
192
-
193
196
  let itemChildren = null;
194
197
  if (!isNullOrUndefined(children)) {
195
198
  itemChildren = children;
@@ -197,15 +200,15 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
197
200
  let placeholderIcons = null;
198
201
  if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
199
202
  const iconAmount = (icon && !indent) ? level : level - 1;
200
- placeholderIcons = times(iconAmount, () => this.renderIcon(null, strings.ICON_POS_RIGHT, false));
203
+ placeholderIcons = times(iconAmount, (index) => this.renderIcon(null, strings.ICON_POS_RIGHT, false, index));
201
204
  }
202
205
  itemChildren = (
203
206
  <>
204
207
  {placeholderIcons}
205
- {this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true)}
206
- {icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT) : null}
208
+ {this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right')}
209
+ {icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, 'key-position-left') : null}
207
210
  {!isNullOrUndefined(text) ? <span className={`${cssClasses.PREFIX}-item-text`}>{text}</span> : ''}
208
- {this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true)}
211
+ {this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right')}
209
212
  </>
210
213
  );
211
214
  }
@@ -246,7 +249,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
246
249
  );
247
250
  } else {
248
251
  // Items are divided into normal and sub-wrap
249
- const popoverItemCls = cls(`${className || `${clsPrefix }-normal`}`, {
252
+ const popoverItemCls = cls(`${className || `${clsPrefix}-normal`}`, {
250
253
  [clsPrefix]: true,
251
254
  [`${clsPrefix}-sub`]: isSubNav,
252
255
  [`${clsPrefix}-selected`]: selected && !isSubNav,
@@ -240,15 +240,15 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
240
240
  if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
241
241
  /* Different icons' amount means different indents.*/
242
242
  const iconAmount = (icon && !indent) ? level : level - 1;
243
- placeholderIcons = times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, undefined, index));
243
+ placeholderIcons = times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, false, index));
244
244
  }
245
245
 
246
246
  const titleDiv = (
247
247
  <div
248
248
  role="menuitem"
249
249
  tabIndex={-1}
250
- ref={this.setTitleRef as any}
251
- className={titleCls}
250
+ ref={this.setTitleRef as any}
251
+ className={titleCls}
252
252
  onClick={this.handleClick}
253
253
  onKeyPress={this.handleKeyPress}
254
254
  >
@@ -256,7 +256,7 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
256
256
  {placeholderIcons}
257
257
  {this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left')}
258
258
  {icon || indent || (isInSubNav && mode !== strings.MODE_HORIZONTAL)
259
- ? this.renderIcon(icon, strings.ICON_POS_LEFT, undefined, undefined, 'key-inSubNav-position-left')
259
+ ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, false, 'key-inSubNav-position-left')
260
260
  : null}
261
261
  <span className={`${prefixCls}-item-text`}>{text}</span>
262
262
  {this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')}