@douyinfe/semi-ui 2.30.2 → 2.31.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.
Files changed (97) hide show
  1. package/dist/css/semi.css +66 -51
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +298 -132
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/_base/base.d.ts +3 -3
  8. package/lib/cjs/anchor/index.d.ts +1 -1
  9. package/lib/cjs/autoComplete/index.d.ts +1 -1
  10. package/lib/cjs/button/Button.d.ts +1 -1
  11. package/lib/cjs/carousel/index.d.ts +1 -0
  12. package/lib/cjs/carousel/index.js +17 -1
  13. package/lib/cjs/cascader/index.js +2 -1
  14. package/lib/cjs/checkbox/checkbox.d.ts +1 -1
  15. package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -1
  16. package/lib/cjs/descriptions/index.d.ts +1 -1
  17. package/lib/cjs/form/baseForm.d.ts +1 -1
  18. package/lib/cjs/form/field.d.ts +1 -1
  19. package/lib/cjs/image/previewInner.d.ts +1 -2
  20. package/lib/cjs/image/previewInner.js +5 -6
  21. package/lib/cjs/layout/index.d.ts +1 -1
  22. package/lib/cjs/modal/confirm.d.ts +1 -1
  23. package/lib/cjs/popconfirm/index.js +10 -1
  24. package/lib/cjs/popover/index.d.ts +1 -0
  25. package/lib/cjs/progress/index.d.ts +3 -3
  26. package/lib/cjs/radio/radio.d.ts +1 -1
  27. package/lib/cjs/select/index.d.ts +2 -2
  28. package/lib/cjs/select/index.js +3 -7
  29. package/lib/cjs/select/virtualRow.js +3 -2
  30. package/lib/cjs/table/Body/index.js +4 -8
  31. package/lib/cjs/table/ColumnSelection.d.ts +4 -3
  32. package/lib/cjs/table/Table.d.ts +9 -1
  33. package/lib/cjs/table/Table.js +30 -11
  34. package/lib/cjs/table/TableCell.js +30 -7
  35. package/lib/cjs/table/TableContextProvider.d.ts +1 -1
  36. package/lib/cjs/table/TableContextProvider.js +5 -3
  37. package/lib/cjs/table/TableHeaderRow.js +28 -9
  38. package/lib/cjs/table/index.d.ts +3 -0
  39. package/lib/cjs/table/index.js +11 -3
  40. package/lib/cjs/table/interface.d.ts +1 -0
  41. package/lib/cjs/table/table-context.d.ts +2 -0
  42. package/lib/cjs/tabs/interface.d.ts +1 -1
  43. package/lib/cjs/tag/index.js +4 -2
  44. package/lib/cjs/tagInput/index.d.ts +1 -1
  45. package/lib/cjs/tagInput/index.js +1 -3
  46. package/lib/cjs/tooltip/index.d.ts +4 -0
  47. package/lib/cjs/tooltip/index.js +21 -6
  48. package/lib/cjs/treeSelect/index.d.ts +1 -1
  49. package/lib/cjs/treeSelect/index.js +18 -18
  50. package/lib/cjs/typography/copyable.d.ts +3 -0
  51. package/lib/cjs/typography/copyable.js +30 -9
  52. package/lib/es/_base/base.d.ts +3 -3
  53. package/lib/es/anchor/index.d.ts +1 -1
  54. package/lib/es/autoComplete/index.d.ts +1 -1
  55. package/lib/es/button/Button.d.ts +1 -1
  56. package/lib/es/carousel/index.d.ts +1 -0
  57. package/lib/es/carousel/index.js +16 -2
  58. package/lib/es/cascader/index.js +2 -1
  59. package/lib/es/checkbox/checkbox.d.ts +1 -1
  60. package/lib/es/checkbox/checkboxGroup.d.ts +1 -1
  61. package/lib/es/descriptions/index.d.ts +1 -1
  62. package/lib/es/form/baseForm.d.ts +1 -1
  63. package/lib/es/form/field.d.ts +1 -1
  64. package/lib/es/image/previewInner.d.ts +1 -2
  65. package/lib/es/image/previewInner.js +5 -6
  66. package/lib/es/layout/index.d.ts +1 -1
  67. package/lib/es/modal/confirm.d.ts +1 -1
  68. package/lib/es/popconfirm/index.js +10 -1
  69. package/lib/es/popover/index.d.ts +1 -0
  70. package/lib/es/progress/index.d.ts +3 -3
  71. package/lib/es/radio/radio.d.ts +1 -1
  72. package/lib/es/select/index.d.ts +2 -2
  73. package/lib/es/select/index.js +3 -6
  74. package/lib/es/select/virtualRow.js +3 -2
  75. package/lib/es/table/Body/index.js +4 -7
  76. package/lib/es/table/ColumnSelection.d.ts +4 -3
  77. package/lib/es/table/Table.d.ts +9 -1
  78. package/lib/es/table/Table.js +30 -11
  79. package/lib/es/table/TableCell.js +31 -8
  80. package/lib/es/table/TableContextProvider.d.ts +1 -1
  81. package/lib/es/table/TableContextProvider.js +5 -3
  82. package/lib/es/table/TableHeaderRow.js +29 -10
  83. package/lib/es/table/index.d.ts +3 -0
  84. package/lib/es/table/index.js +10 -3
  85. package/lib/es/table/interface.d.ts +1 -0
  86. package/lib/es/table/table-context.d.ts +2 -0
  87. package/lib/es/tabs/interface.d.ts +1 -1
  88. package/lib/es/tag/index.js +7 -2
  89. package/lib/es/tagInput/index.d.ts +1 -1
  90. package/lib/es/tagInput/index.js +1 -3
  91. package/lib/es/tooltip/index.d.ts +4 -0
  92. package/lib/es/tooltip/index.js +21 -6
  93. package/lib/es/treeSelect/index.d.ts +1 -1
  94. package/lib/es/treeSelect/index.js +17 -18
  95. package/lib/es/typography/copyable.d.ts +3 -0
  96. package/lib/es/typography/copyable.js +28 -9
  97. package/package.json +8 -8
@@ -25,8 +25,8 @@ export interface MotionChildrenProps {
25
25
  animationFillMode?: string;
26
26
  };
27
27
  animateEvents?: {
28
- onAnimationIteration?: React.AnimationEventHandler<any> | undefined;
29
- onAnimationStart?: React.AnimationEventHandler<any> | undefined;
30
- onAnimationEnd?: React.AnimationEventHandler<any> | undefined;
28
+ onAnimationIteration?: React.AnimationEventHandler<any>;
29
+ onAnimationStart?: React.AnimationEventHandler<any>;
30
+ onAnimationEnd?: React.AnimationEventHandler<any>;
31
31
  };
32
32
  }
@@ -11,7 +11,7 @@ export type { LinkProps } from './link';
11
11
  export interface AnchorProps {
12
12
  autoCollapse?: boolean;
13
13
  className?: string;
14
- children?: ReactNode | undefined;
14
+ children?: ReactNode;
15
15
  defaultAnchor?: string;
16
16
  getContainer?: () => HTMLElement | Window;
17
17
  maxHeight?: string | number;
@@ -27,7 +27,7 @@ export interface AutoCompleteProps<T extends AutoCompleteItems> {
27
27
  autoFocus?: boolean;
28
28
  className?: string;
29
29
  clearIcon?: ReactNode;
30
- children?: ReactNode | undefined;
30
+ children?: ReactNode;
31
31
  data?: T[];
32
32
  disabled?: boolean;
33
33
  defaultOpen?: boolean;
@@ -10,7 +10,7 @@ export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonE
10
10
  id?: string;
11
11
  block?: boolean;
12
12
  circle?: boolean;
13
- children?: ReactNode | undefined;
13
+ children?: ReactNode;
14
14
  disabled?: boolean;
15
15
  className?: string;
16
16
  icon?: React.ReactNode;
@@ -38,6 +38,7 @@ declare class Carousel extends BaseComponent<CarouselProps, CarouselState> {
38
38
  get adapter(): CarouselAdapter<CarouselProps, CarouselState>;
39
39
  static getDerivedStateFromProps(props: CarouselProps, state: CarouselState): Partial<CarouselState>;
40
40
  componentDidMount(): void;
41
+ componentDidUpdate(prevProps: Readonly<CarouselProps>, prevState: Readonly<CarouselState>, snapshot?: any): void;
41
42
  componentWillUnmount(): void;
42
43
  play: () => void;
43
44
  stop: () => void;
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
9
+
8
10
  var _debounce2 = _interopRequireDefault(require("lodash/debounce"));
9
11
 
10
12
  var _react = _interopRequireWildcard(require("react"));
@@ -39,10 +41,12 @@ class Carousel extends _baseComponent.default {
39
41
  super(props);
40
42
 
41
43
  this.play = () => {
44
+ this.foundation.setForcePlay(true);
42
45
  return this.foundation.handleAutoPlay();
43
46
  };
44
47
 
45
48
  this.stop = () => {
49
+ this.foundation.setForcePlay(false);
46
50
  return this.foundation.stop();
47
51
  };
48
52
 
@@ -69,7 +73,7 @@ class Carousel extends _baseComponent.default {
69
73
  autoPlay
70
74
  } = this.props;
71
75
 
72
- if (typeof autoPlay !== 'object' || autoPlay.hoverToPause) {
76
+ if (autoPlay === true || typeof autoPlay === 'object' && autoPlay.hoverToPause) {
73
77
  this.foundation.stop();
74
78
  }
75
79
  };
@@ -249,6 +253,18 @@ class Carousel extends _baseComponent.default {
249
253
  this.handleAutoPlay();
250
254
  }
251
255
 
256
+ componentDidUpdate(prevProps, prevState, snapshot) {
257
+ const prevChildrenKeys = _react.default.Children.toArray(prevProps.children).map(child => /*#__PURE__*/(0, _react.isValidElement)(child) ? child.key : null);
258
+
259
+ const nowChildrenKeys = _react.default.Children.toArray(this.props.children).map(child => /*#__PURE__*/(0, _react.isValidElement)(child) ? child.key : null);
260
+
261
+ if (!(0, _isEqual2.default)(prevChildrenKeys, nowChildrenKeys)) {
262
+ this.setState({
263
+ children: this.getChildren()
264
+ });
265
+ }
266
+ }
267
+
252
268
  componentWillUnmount() {
253
269
  this.foundation.destroy();
254
270
  }
@@ -937,7 +937,8 @@ class Cascader extends _baseComponent.default {
937
937
  onChange: this.handleInputChange
938
938
  };
939
939
  const wrappercls = (0, _classnames.default)({
940
- [`${prefixcls}-search-wrapper`]: true
940
+ [`${prefixcls}-search-wrapper`]: true,
941
+ [`${prefixcls}-search-wrapper-${size}`]: size !== 'default'
941
942
  });
942
943
  const displayText = this.renderDisplayText();
943
944
  const spanCls = (0, _classnames.default)({
@@ -18,7 +18,7 @@ export interface CheckboxProps extends BaseCheckboxProps {
18
18
  'aria-invalid'?: React.AriaAttributes['aria-invalid'];
19
19
  'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
20
20
  'aria-required'?: React.AriaAttributes['aria-required'];
21
- children?: React.ReactNode | undefined;
21
+ children?: React.ReactNode;
22
22
  onChange?: (e: CheckboxEvent) => any;
23
23
  style?: React.CSSProperties;
24
24
  onMouseEnter?: React.MouseEventHandler<HTMLSpanElement>;
@@ -17,7 +17,7 @@ export declare type CheckboxGroupProps = {
17
17
  options?: any[];
18
18
  value?: any[];
19
19
  onChange?: (value: any[]) => void;
20
- children?: React.ReactNode | undefined;
20
+ children?: React.ReactNode;
21
21
  prefixCls?: string;
22
22
  direction?: CheckboxDirection;
23
23
  style?: React.CSSProperties;
@@ -16,7 +16,7 @@ export interface DescriptionsProps {
16
16
  size?: DescriptionsSize;
17
17
  style?: React.CSSProperties;
18
18
  className?: string;
19
- children?: React.ReactNode | undefined;
19
+ children?: React.ReactNode;
20
20
  data?: Data[];
21
21
  }
22
22
  declare class Descriptions extends PureComponent<DescriptionsProps> {
@@ -83,7 +83,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
83
83
  onDropdownVisibleChange?: (visible: boolean) => void;
84
84
  zIndex?: number;
85
85
  position?: "left" | "top" | "right" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
86
- onSearch?: (value: string) => void;
86
+ onSearch?: (value: string, event: React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent>) => void;
87
87
  dropdownClassName?: string;
88
88
  dropdownStyle?: React.CSSProperties;
89
89
  dropdownMargin?: number | {
@@ -31,7 +31,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
31
31
  onDropdownVisibleChange?: (visible: boolean) => void;
32
32
  zIndex?: number;
33
33
  position?: "left" | "top" | "right" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
34
- onSearch?: (value: string) => void;
34
+ onSearch?: (value: string, event: import("react").KeyboardEvent<Element> | import("react").MouseEvent<Element, MouseEvent>) => void;
35
35
  dropdownClassName?: string;
36
36
  dropdownStyle?: import("react").CSSProperties;
37
37
  dropdownMargin?: number | {
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import BaseComponent from "../_base/baseComponent";
3
- import { PreviewProps as PreviewInnerProps, PreviewInnerStates, RatioType } from "./interface";
3
+ import { PreviewProps as PreviewInnerProps, PreviewInnerStates } from "./interface";
4
4
  import PropTypes from "prop-types";
5
5
  import PreviewInnerFoundation, { PreviewInnerAdapter } from '@douyinfe/semi-foundation/lib/cjs/image/previewInnerFoundation';
6
6
  import { PreviewContextProps } from "./previewContext";
@@ -87,6 +87,5 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
87
87
  onImageError: () => void;
88
88
  onImageLoad: (src: any) => void;
89
89
  handleMouseDown: (e: any) => void;
90
- handleRatio: (type: RatioType) => void;
91
90
  render(): JSX.Element;
92
91
  }
@@ -105,10 +105,6 @@ class PreviewInner extends _baseComponent.default {
105
105
  this.foundation.handleMouseDown(e);
106
106
  };
107
107
 
108
- this.handleRatio = type => {
109
- this.foundation.handleRatio(type);
110
- };
111
-
112
108
  this.state = {
113
109
  imgSrc: [],
114
110
  imgLoadStatus: new Map(),
@@ -259,7 +255,10 @@ class PreviewInner extends _baseComponent.default {
259
255
  }
260
256
 
261
257
  if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
262
- willUpdateStates.currentIndex = props.currentIndex;
258
+ willUpdateStates.currentIndex = props.currentIndex; // ratio will set to adaptation when change picture,
259
+ // attention: If the ratio is controlled, the ratio should not change as the index changes
260
+
261
+ willUpdateStates.ratio = 'adaptation';
263
262
  }
264
263
 
265
264
  return willUpdateStates;
@@ -381,7 +380,7 @@ class PreviewInner extends _baseComponent.default {
381
380
  src: imgSrc[currentIndex],
382
381
  onZoom: this.handleZoomImage,
383
382
  disableDownload: disableDownload,
384
- setRatio: this.handleRatio,
383
+ setRatio: this.handleAdjustRatio,
385
384
  zoom: zoom,
386
385
  ratio: ratio,
387
386
  zoomStep: zoomStep,
@@ -16,7 +16,7 @@ export interface BasicLayoutProps {
16
16
  prefixCls?: string;
17
17
  style?: CSSProperties;
18
18
  className?: string;
19
- children?: React.ReactNode | undefined;
19
+ children?: React.ReactNode;
20
20
  hasSider?: boolean;
21
21
  tagName?: keyof HTMLElementTagNameMap;
22
22
  }
@@ -160,12 +160,12 @@ export declare function withError(props: ModalReactProps): {
160
160
  closeOnEsc?: boolean;
161
161
  preventScroll?: boolean;
162
162
  afterClose?: () => void;
163
+ keepDOM?: boolean;
163
164
  cancelText?: string;
164
165
  okText?: string;
165
166
  closeIcon?: React.ReactNode;
166
167
  bodyStyle?: React.CSSProperties;
167
168
  closable?: boolean;
168
- keepDOM?: boolean;
169
169
  onCancel?: (e: React.MouseEvent<Element, MouseEvent>) => void | Promise<any>;
170
170
  maskClosable?: boolean;
171
171
  cancelButtonProps?: import("../button").BaseButtonProps;
@@ -255,7 +255,16 @@ class Popconfirm extends _baseComponent.default {
255
255
  return /*#__PURE__*/_react.default.createElement(_popover.default, Object.assign({
256
256
  ref: this.popoverRef
257
257
  }, attrs, {
258
- content: this.renderConfirmPopCard,
258
+ // A arrow function needs to be passed here, otherwise the content will not be updated after the Popconfirm state is updated
259
+ // Popover is a PureComponent, same props will not trigger update
260
+ content: _ref2 => {
261
+ let {
262
+ initialFocusRef
263
+ } = _ref2;
264
+ return this.renderConfirmPopCard({
265
+ initialFocusRef
266
+ });
267
+ },
259
268
  visible: visible,
260
269
  position: position
261
270
  }, popProps), children);
@@ -42,6 +42,7 @@ export interface PopoverProps extends BaseProps {
42
42
  clickToHide?: TooltipProps['clickToHide'];
43
43
  disableFocusListener?: boolean;
44
44
  afterClose?: () => void;
45
+ keepDOM?: boolean;
45
46
  }
46
47
  export interface PopoverState {
47
48
  popConfirmVisible: boolean;
@@ -5,9 +5,9 @@ import { Animation } from '@douyinfe/semi-animation';
5
5
  import { Motion } from '../_base/base';
6
6
  import { StrokeArr } from '@douyinfe/semi-foundation/lib/cjs/progress/generates';
7
7
  export interface ProgressProps {
8
- 'aria-label'?: string | undefined;
9
- 'aria-labelledby'?: string | undefined;
10
- 'aria-valuetext'?: string | undefined;
8
+ 'aria-label'?: string;
9
+ 'aria-labelledby'?: string;
10
+ 'aria-valuetext'?: string;
11
11
  className?: string;
12
12
  direction?: 'horizontal' | 'vertical';
13
13
  format?: (percent: number) => React.ReactNode;
@@ -12,7 +12,7 @@ export declare type RadioType = typeof strings.TYPE_DEFAULT | typeof strings.TYP
12
12
  export declare type RadioProps = {
13
13
  autoFocus?: boolean;
14
14
  checked?: boolean;
15
- children?: React.ReactNode | undefined;
15
+ children?: React.ReactNode;
16
16
  defaultChecked?: boolean;
17
17
  value?: string | number;
18
18
  disabled?: boolean;
@@ -86,7 +86,7 @@ export declare type SelectProps = {
86
86
  onDropdownVisibleChange?: (visible: boolean) => void;
87
87
  zIndex?: number;
88
88
  position?: Position;
89
- onSearch?: (value: string) => void;
89
+ onSearch?: (value: string, event: React.KeyboardEvent | React.MouseEvent) => void;
90
90
  dropdownClassName?: string;
91
91
  dropdownStyle?: React.CSSProperties;
92
92
  dropdownMargin?: PopoverProps['margin'];
@@ -252,7 +252,7 @@ declare class Select extends BaseComponent<SelectProps, SelectState> {
252
252
  componentDidMount(): void;
253
253
  componentWillUnmount(): void;
254
254
  componentDidUpdate(prevProps: SelectProps, prevState: SelectState): void;
255
- handleInputChange: (value: string) => void;
255
+ handleInputChange: (value: string, event: React.KeyboardEvent) => void;
256
256
  renderInput(): JSX.Element;
257
257
  close(): void;
258
258
  open(): void;
@@ -71,8 +71,6 @@ var _semiIcons = require("@douyinfe/semi-icons");
71
71
 
72
72
  var _utils2 = require("../_utils");
73
73
 
74
- var _warning = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/utils/warning"));
75
-
76
74
  var _uuid = require("@douyinfe/semi-foundation/lib/cjs/utils/uuid");
77
75
 
78
76
  require("@douyinfe/semi-foundation/lib/cjs/select/select.css");
@@ -97,7 +95,7 @@ class Select extends _baseComponent.default {
97
95
  current: node
98
96
  };
99
97
 
100
- this.handleInputChange = value => this.foundation.handleInputChange(value);
98
+ this.handleInputChange = (value, event) => this.foundation.handleInputChange(value, event);
101
99
 
102
100
  this.getTagItem = (item, i, renderSelectedItem) => {
103
101
  const {
@@ -184,8 +182,6 @@ class Select extends _baseComponent.default {
184
182
  this.onKeyPress = this.onKeyPress.bind(this);
185
183
  this.eventManager = new _Event.default();
186
184
  this.foundation = new _foundation.default(this.adapter);
187
- (0, _warning.default)('optionLabelProp' in this.props, '[Semi Select] \'optionLabelProp\' has already been deprecated, please use \'renderSelectedItem\' instead.');
188
- (0, _warning.default)('labelInValue' in this.props, '[Semi Select] \'labelInValue\' has already been deprecated, please use \'onChangeWithObject\' instead.');
189
185
  }
190
186
 
191
187
  get adapter() {
@@ -355,8 +351,8 @@ class Select extends _baseComponent.default {
355
351
  notifyDropdownVisibleChange: visible => {
356
352
  this.props.onDropdownVisibleChange(visible);
357
353
  },
358
- notifySearch: input => {
359
- this.props.onSearch(input);
354
+ notifySearch: (input, event) => {
355
+ this.props.onSearch(input, event);
360
356
  },
361
357
  notifyCreate: input => {
362
358
  this.props.onCreate(input);
@@ -12,10 +12,11 @@ const VirtualRow = _ref => {
12
12
  style
13
13
  } = _ref;
14
14
  const {
15
- visibleOptions
15
+ visibleOptions,
16
+ renderOption
16
17
  } = data;
17
18
  const option = visibleOptions[index];
18
- return data.renderOption(option, index, style);
19
+ return renderOption(option, index, style);
19
20
  };
20
21
 
21
22
  var _default = VirtualRow;
@@ -49,8 +49,6 @@ var _SectionRow = _interopRequireDefault(require("./SectionRow"));
49
49
 
50
50
  var _TableHeader = _interopRequireDefault(require("../TableHeader"));
51
51
 
52
- var _context = _interopRequireDefault(require("../../configProvider/context"));
53
-
54
52
  var _tableContext = _interopRequireDefault(require("../table-context"));
55
53
 
56
54
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -814,12 +812,10 @@ class Body extends _baseComponent.default {
814
812
  const {
815
813
  virtualized
816
814
  } = this.props;
817
- return /*#__PURE__*/_react.default.createElement(_context.default.Consumer, null, _ref => {
818
- let {
819
- direction
820
- } = _ref;
821
- return virtualized ? this.renderVirtualizedBody(direction) : this.renderBody(direction);
822
- });
815
+ const {
816
+ direction
817
+ } = this.context;
818
+ return virtualized ? this.renderVirtualizedBody(direction) : this.renderBody(direction);
823
819
  }
824
820
 
825
821
  }
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import BaseComponent from '../_base/baseComponent';
3
3
  import PropTypes from 'prop-types';
4
- import { TableSelectionCellAdapter, TableSelectionCellEvent } from '@douyinfe/semi-foundation/lib/cjs/table/tableSelectionCellFoundation';
4
+ import TableSelectionCellFoundation, { TableSelectionCellAdapter, TableSelectionCellEvent } from '@douyinfe/semi-foundation/lib/cjs/table/tableSelectionCellFoundation';
5
5
  import { CheckboxEvent, CheckboxProps } from '../checkbox';
6
6
  export interface TableSelectionCellProps {
7
7
  columnTitle?: string;
8
8
  getCheckboxProps?: () => CheckboxProps;
9
9
  type?: string;
10
- onChange?: (value: any, e: TableSelectionCellEvent) => void;
10
+ onChange?: (checked: boolean, e: TableSelectionCellEvent) => void;
11
11
  selected?: boolean;
12
12
  disabled?: boolean;
13
13
  indeterminate?: boolean;
@@ -37,7 +37,8 @@ export default class TableSelectionCell extends BaseComponent<TableSelectionCell
37
37
  prefixCls: "semi-table";
38
38
  };
39
39
  get adapter(): TableSelectionCellAdapter;
40
+ foundation: TableSelectionCellFoundation;
40
41
  constructor(props: TableSelectionCellProps);
41
- handleChange: (e: CheckboxEvent) => any;
42
+ handleChange: (e: CheckboxEvent) => void;
42
43
  render(): JSX.Element;
43
44
  }
@@ -32,6 +32,14 @@ export interface NormalTableState<RecordType extends Record<string, any> = Data>
32
32
  prePropRowSelection?: TableStateRowSelection<RecordType>;
33
33
  tableWidth?: number;
34
34
  prePagination?: Pagination;
35
+ /**
36
+ * Disabled row keys in sorted and filtered data
37
+ */
38
+ allDisabledRowKeys?: BaseRowKeyType[];
39
+ /**
40
+ * Disabled row keys set in sorted and filtered data
41
+ */
42
+ allDisabledRowKeysSet?: Set<BaseRowKeyType>;
35
43
  }
36
44
  export declare type TableStateRowSelection<RecordType extends Record<string, any> = Data> = (RowSelectionProps<RecordType> & {
37
45
  selectedRowKeysSet?: Set<(string | number)>;
@@ -227,7 +235,7 @@ declare class Table<RecordType extends Record<string, any>> extends BaseComponen
227
235
  */
228
236
  addFnsInColumn: (column?: ColumnProps) => ColumnProps<any>;
229
237
  toggleSelectRow: (selected: boolean, realKey: string | number, e: TableSelectionCellEvent) => void;
230
- toggleSelectAllRow: (status: boolean, e: TableSelectionCellEvent) => void;
238
+ toggleSelectAllRow: (selected: boolean, e: TableSelectionCellEvent) => void;
231
239
  /**
232
240
  * render pagination
233
241
  * @param {object} pagination
@@ -317,8 +317,9 @@ class Table extends _baseComponent.default {
317
317
  const node = this.bodyWrapRef.current;
318
318
 
319
319
  if (node && node.children && node.children.length) {
320
- const scrollToLeft = node.scrollLeft === 0;
321
- const scrollToRight = node.scrollLeft + 1 >= node.children[0].getBoundingClientRect().width - node.getBoundingClientRect().width;
320
+ const scrollToLeft = node.scrollLeft === 0; // why use Math.abs? @see https://bugzilla.mozilla.org/show_bug.cgi?id=1447743
321
+
322
+ const scrollToRight = Math.abs(node.scrollLeft) + 1 >= node.children[0].getBoundingClientRect().width - node.getBoundingClientRect().width;
322
323
 
323
324
  if (scrollToLeft && scrollToRight) {
324
325
  this.setScrollPosition('both');
@@ -345,7 +346,7 @@ class Table extends _baseComponent.default {
345
346
  let inHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
346
347
  const {
347
348
  rowSelection,
348
- disabledRowKeysSet
349
+ allDisabledRowKeysSet
349
350
  } = _this.state;
350
351
 
351
352
  if (rowSelection && typeof rowSelection === 'object') {
@@ -361,7 +362,7 @@ class Table extends _baseComponent.default {
361
362
  const allRowKeys = _this.cachedFilteredSortedRowKeys;
362
363
  const allRowKeysSet = _this.cachedFilteredSortedRowKeysSet;
363
364
 
364
- const allIsSelected = _this.foundation.allIsSelected(selectedRowKeysSet, disabledRowKeysSet, allRowKeys);
365
+ const allIsSelected = _this.foundation.allIsSelected(selectedRowKeysSet, allDisabledRowKeysSet, allRowKeys);
365
366
 
366
367
  const hasRowSelected = _this.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
367
368
 
@@ -371,8 +372,8 @@ class Table extends _baseComponent.default {
371
372
  key: columnKey,
372
373
  selected: allIsSelected,
373
374
  indeterminate: hasRowSelected && !allIsSelected,
374
- onChange: (status, e) => {
375
- _this.toggleSelectAllRow(status, e);
375
+ onChange: (selected, e) => {
376
+ _this.toggleSelectAllRow(selected, e);
376
377
  }
377
378
  });
378
379
  } else {
@@ -574,8 +575,8 @@ class Table extends _baseComponent.default {
574
575
  this.foundation.handleSelectRow(realKey, selected, e);
575
576
  };
576
577
 
577
- this.toggleSelectAllRow = (status, e) => {
578
- this.foundation.handleSelectAllRow(status, e);
578
+ this.toggleSelectAllRow = (selected, e) => {
579
+ this.foundation.handleSelectAllRow(selected, e);
579
580
  };
580
581
  /**
581
582
  * render pagination
@@ -893,6 +894,8 @@ class Table extends _baseComponent.default {
893
894
  allRowKeys: [],
894
895
  disabledRowKeys: [],
895
896
  disabledRowKeysSet: new Set(),
897
+ allDisabledRowKeys: [],
898
+ allDisabledRowKeysSet: new Set(),
896
899
  headWidths: [],
897
900
  bodyHasScrollBar: false,
898
901
  prePropRowSelection: undefined,
@@ -997,11 +1000,20 @@ class Table extends _baseComponent.default {
997
1000
  this.cachedFilteredSortedRowKeys = filteredSortedRowKeys;
998
1001
  this.cachedFilteredSortedRowKeysSet = new Set(filteredSortedRowKeys);
999
1002
  },
1003
+ setAllDisabledRowKeys: allDisabledRowKeys => {
1004
+ const allDisabledRowKeysSet = new Set(allDisabledRowKeys);
1005
+ this.setState({
1006
+ allDisabledRowKeys,
1007
+ allDisabledRowKeysSet
1008
+ });
1009
+ },
1000
1010
  getCurrentPage: () => (0, _get2.default)(this.state, 'pagination.currentPage', 1),
1001
1011
  getCurrentPageSize: () => (0, _get2.default)(this.state, 'pagination.pageSize', _constants.numbers.DEFAULT_PAGE_SIZE),
1002
1012
  getCachedFilteredSortedDataSource: () => this.cachedFilteredSortedDataSource,
1003
1013
  getCachedFilteredSortedRowKeys: () => this.cachedFilteredSortedRowKeys,
1004
1014
  getCachedFilteredSortedRowKeysSet: () => this.cachedFilteredSortedRowKeysSet,
1015
+ getAllDisabledRowKeys: () => this.state.allDisabledRowKeys,
1016
+ getAllDisabledRowKeysSet: () => this.state.allDisabledRowKeysSet,
1005
1017
  notifyFilterDropdownVisibleChange: (visible, dataIndex) => this._invokeColumnFn(dataIndex, 'onFilterDropdownVisibleChange', visible),
1006
1018
  notifyChange: function () {
1007
1019
  return _this2.props.onChange(...arguments);
@@ -1202,8 +1214,11 @@ class Table extends _baseComponent.default {
1202
1214
  childrenRecordName,
1203
1215
  rowKey
1204
1216
  });
1217
+ const disabledRowKeysSet = new Set(disabledRowKeys);
1205
1218
  willUpdateStates.disabledRowKeys = disabledRowKeys;
1206
- willUpdateStates.disabledRowKeysSet = new Set(disabledRowKeys);
1219
+ willUpdateStates.disabledRowKeysSet = disabledRowKeysSet;
1220
+ willUpdateStates.allDisabledRowKeys = disabledRowKeys;
1221
+ willUpdateStates.allDisabledRowKeysSet = disabledRowKeysSet;
1207
1222
  }
1208
1223
 
1209
1224
  willUpdateStates.rowSelection = newSelectionStates;
@@ -1307,7 +1322,9 @@ class Table extends _baseComponent.default {
1307
1322
  // Temporarily use _dataSource=[...dataSource] for processing
1308
1323
  const _dataSource = [...dataSource];
1309
1324
  const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
1325
+ const allDataDisabledRowKeys = this.foundation.getAllDisabledRowKeys(filteredSortedDataSource);
1310
1326
  this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
1327
+ this.foundation.setAllDisabledRowKeys(allDataDisabledRowKeys);
1311
1328
  states.dataSource = filteredSortedDataSource;
1312
1329
 
1313
1330
  if (this.props.groupBy) {
@@ -1500,11 +1517,13 @@ class Table extends _baseComponent.default {
1500
1517
  });
1501
1518
  return /*#__PURE__*/_react.default.createElement("div", {
1502
1519
  ref: this.rootWrapRef,
1503
- className: (0, _classnames.default)(className, `${prefixCls}-wrapper`),
1520
+ className: (0, _classnames.default)(className, `${prefixCls}-wrapper`, `${prefixCls}-wrapper-${props.direction}`),
1504
1521
  "data-column-fixed": anyColumnFixed,
1505
1522
  style: wrapStyle,
1506
1523
  id: id
1507
- }, /*#__PURE__*/_react.default.createElement(_TableContextProvider.default, Object.assign({}, tableContextValue), /*#__PURE__*/_react.default.createElement(_spin.default, {
1524
+ }, /*#__PURE__*/_react.default.createElement(_TableContextProvider.default, Object.assign({}, tableContextValue, {
1525
+ direction: props.direction
1526
+ }), /*#__PURE__*/_react.default.createElement(_spin.default, {
1508
1527
  spinning: loading,
1509
1528
  size: "large"
1510
1529
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -145,13 +145,17 @@ class TableCell extends _baseComponent.default {
145
145
  } = this.props;
146
146
  let tdProps = {};
147
147
  let customCellProps = {};
148
+ const {
149
+ direction
150
+ } = this.context;
151
+ const isRTL = direction === 'rtl';
148
152
  const fixedLeftFlag = fixedLeft || typeof fixedLeft === 'number';
149
153
  const fixedRightFlag = fixedRight || typeof fixedRight === 'number';
150
154
 
151
155
  if (fixedLeftFlag) {
152
- (0, _set2.default)(tdProps, 'style.left', typeof fixedLeft === 'number' ? fixedLeft : 0);
156
+ (0, _set2.default)(tdProps, isRTL ? 'style.right' : 'style.left', typeof fixedLeft === 'number' ? fixedLeft : 0);
153
157
  } else if (fixedRightFlag) {
154
- (0, _set2.default)(tdProps, 'style.right', typeof fixedRight === 'number' ? fixedRight : 0);
158
+ (0, _set2.default)(tdProps, isRTL ? 'style.left' : 'style.right', typeof fixedRight === 'number' ? fixedRight : 0);
155
159
  }
156
160
 
157
161
  if (width != null) {
@@ -171,8 +175,9 @@ class TableCell extends _baseComponent.default {
171
175
  }
172
176
 
173
177
  if (column.align) {
178
+ const textAlign = (0, _utils.getRTLAlign)(column.align, direction);
174
179
  tdProps.style = Object.assign(Object.assign({}, tdProps.style), {
175
- textAlign: column.align
180
+ textAlign
176
181
  });
177
182
  }
178
183
 
@@ -310,6 +315,10 @@ class TableCell extends _baseComponent.default {
310
315
  firstFixedRight,
311
316
  colIndex
312
317
  } = this.props;
318
+ const {
319
+ direction
320
+ } = this.context;
321
+ const isRTL = direction === 'rtl';
313
322
  const {
314
323
  className
315
324
  } = column;
@@ -340,11 +349,25 @@ class TableCell extends _baseComponent.default {
340
349
  }
341
350
 
342
351
  const inner = this.renderInner(text, indentText, realExpandIcon);
352
+ let isFixedLeft, isFixedLeftLast, isFixedRight, isFixedRightFirst;
353
+
354
+ if (isRTL) {
355
+ isFixedLeft = fixedRightFlag;
356
+ isFixedLeftLast = firstFixedRight;
357
+ isFixedRight = fixedLeftFlag;
358
+ isFixedRightFirst = lastFixedLeft;
359
+ } else {
360
+ isFixedLeft = fixedLeftFlag;
361
+ isFixedLeftLast = lastFixedLeft;
362
+ isFixedRight = fixedRightFlag;
363
+ isFixedRightFirst = firstFixedRight;
364
+ }
365
+
343
366
  const columnCls = (0, _classnames.default)(className, `${prefixCls}-row-cell`, (0, _get2.default)(customCellProps, 'className'), {
344
- [`${prefixCls}-cell-fixed-left`]: fixedLeftFlag,
345
- [`${prefixCls}-cell-fixed-left-last`]: lastFixedLeft,
346
- [`${prefixCls}-cell-fixed-right`]: fixedRightFlag,
347
- [`${prefixCls}-cell-fixed-right-first`]: firstFixedRight
367
+ [`${prefixCls}-cell-fixed-left`]: isFixedLeft,
368
+ [`${prefixCls}-cell-fixed-left-last`]: isFixedLeftLast,
369
+ [`${prefixCls}-cell-fixed-right`]: isFixedRight,
370
+ [`${prefixCls}-cell-fixed-right-first`]: isFixedRightFirst
348
371
  });
349
372
  return /*#__PURE__*/_react.default.createElement(BodyCell, Object.assign({
350
373
  role: "gridcell",
@@ -1,3 +1,3 @@
1
1
  import { TableContextProps } from './table-context';
2
- declare const TableContextProvider: ({ children, anyColumnFixed, flattenedColumns, tableWidth, headWidths, setHeadWidths, getHeadWidths, getCellWidths, handleRowExpanded, renderExpandIcon, renderSelection, getVirtualizedListRef, setBodyHasScrollbar, }: TableContextProps) => JSX.Element;
2
+ declare const TableContextProvider: ({ children, anyColumnFixed, flattenedColumns, tableWidth, headWidths, setHeadWidths, getHeadWidths, getCellWidths, handleRowExpanded, renderExpandIcon, renderSelection, getVirtualizedListRef, setBodyHasScrollbar, direction }: TableContextProps) => JSX.Element;
3
3
  export default TableContextProvider;