@douyinfe/semi-ui 2.31.0-beta.0 → 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.
@@ -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
  }
@@ -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,
@@ -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);
@@ -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;
@@ -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
@@ -346,7 +346,7 @@ class Table extends _baseComponent.default {
346
346
  let inHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
347
347
  const {
348
348
  rowSelection,
349
- disabledRowKeysSet
349
+ allDisabledRowKeysSet
350
350
  } = _this.state;
351
351
 
352
352
  if (rowSelection && typeof rowSelection === 'object') {
@@ -362,7 +362,7 @@ class Table extends _baseComponent.default {
362
362
  const allRowKeys = _this.cachedFilteredSortedRowKeys;
363
363
  const allRowKeysSet = _this.cachedFilteredSortedRowKeysSet;
364
364
 
365
- const allIsSelected = _this.foundation.allIsSelected(selectedRowKeysSet, disabledRowKeysSet, allRowKeys);
365
+ const allIsSelected = _this.foundation.allIsSelected(selectedRowKeysSet, allDisabledRowKeysSet, allRowKeys);
366
366
 
367
367
  const hasRowSelected = _this.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
368
368
 
@@ -372,8 +372,8 @@ class Table extends _baseComponent.default {
372
372
  key: columnKey,
373
373
  selected: allIsSelected,
374
374
  indeterminate: hasRowSelected && !allIsSelected,
375
- onChange: (status, e) => {
376
- _this.toggleSelectAllRow(status, e);
375
+ onChange: (selected, e) => {
376
+ _this.toggleSelectAllRow(selected, e);
377
377
  }
378
378
  });
379
379
  } else {
@@ -575,8 +575,8 @@ class Table extends _baseComponent.default {
575
575
  this.foundation.handleSelectRow(realKey, selected, e);
576
576
  };
577
577
 
578
- this.toggleSelectAllRow = (status, e) => {
579
- this.foundation.handleSelectAllRow(status, e);
578
+ this.toggleSelectAllRow = (selected, e) => {
579
+ this.foundation.handleSelectAllRow(selected, e);
580
580
  };
581
581
  /**
582
582
  * render pagination
@@ -894,6 +894,8 @@ class Table extends _baseComponent.default {
894
894
  allRowKeys: [],
895
895
  disabledRowKeys: [],
896
896
  disabledRowKeysSet: new Set(),
897
+ allDisabledRowKeys: [],
898
+ allDisabledRowKeysSet: new Set(),
897
899
  headWidths: [],
898
900
  bodyHasScrollBar: false,
899
901
  prePropRowSelection: undefined,
@@ -998,11 +1000,20 @@ class Table extends _baseComponent.default {
998
1000
  this.cachedFilteredSortedRowKeys = filteredSortedRowKeys;
999
1001
  this.cachedFilteredSortedRowKeysSet = new Set(filteredSortedRowKeys);
1000
1002
  },
1003
+ setAllDisabledRowKeys: allDisabledRowKeys => {
1004
+ const allDisabledRowKeysSet = new Set(allDisabledRowKeys);
1005
+ this.setState({
1006
+ allDisabledRowKeys,
1007
+ allDisabledRowKeysSet
1008
+ });
1009
+ },
1001
1010
  getCurrentPage: () => (0, _get2.default)(this.state, 'pagination.currentPage', 1),
1002
1011
  getCurrentPageSize: () => (0, _get2.default)(this.state, 'pagination.pageSize', _constants.numbers.DEFAULT_PAGE_SIZE),
1003
1012
  getCachedFilteredSortedDataSource: () => this.cachedFilteredSortedDataSource,
1004
1013
  getCachedFilteredSortedRowKeys: () => this.cachedFilteredSortedRowKeys,
1005
1014
  getCachedFilteredSortedRowKeysSet: () => this.cachedFilteredSortedRowKeysSet,
1015
+ getAllDisabledRowKeys: () => this.state.allDisabledRowKeys,
1016
+ getAllDisabledRowKeysSet: () => this.state.allDisabledRowKeysSet,
1006
1017
  notifyFilterDropdownVisibleChange: (visible, dataIndex) => this._invokeColumnFn(dataIndex, 'onFilterDropdownVisibleChange', visible),
1007
1018
  notifyChange: function () {
1008
1019
  return _this2.props.onChange(...arguments);
@@ -1203,8 +1214,11 @@ class Table extends _baseComponent.default {
1203
1214
  childrenRecordName,
1204
1215
  rowKey
1205
1216
  });
1217
+ const disabledRowKeysSet = new Set(disabledRowKeys);
1206
1218
  willUpdateStates.disabledRowKeys = disabledRowKeys;
1207
- willUpdateStates.disabledRowKeysSet = new Set(disabledRowKeys);
1219
+ willUpdateStates.disabledRowKeysSet = disabledRowKeysSet;
1220
+ willUpdateStates.allDisabledRowKeys = disabledRowKeys;
1221
+ willUpdateStates.allDisabledRowKeysSet = disabledRowKeysSet;
1208
1222
  }
1209
1223
 
1210
1224
  willUpdateStates.rowSelection = newSelectionStates;
@@ -1308,7 +1322,9 @@ class Table extends _baseComponent.default {
1308
1322
  // Temporarily use _dataSource=[...dataSource] for processing
1309
1323
  const _dataSource = [...dataSource];
1310
1324
  const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
1325
+ const allDataDisabledRowKeys = this.foundation.getAllDisabledRowKeys(filteredSortedDataSource);
1311
1326
  this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
1327
+ this.foundation.setAllDisabledRowKeys(allDataDisabledRowKeys);
1312
1328
  states.dataSource = filteredSortedDataSource;
1313
1329
 
1314
1330
  if (this.props.groupBy) {
@@ -245,7 +245,7 @@ declare class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState>
245
245
  getTreeNodeKey: (treeNode: TreeNodeData) => string;
246
246
  handlePopoverClose: (isVisible: any) => void;
247
247
  renderTreeNode: (treeNode: FlattenNode, ind: number, style: React.CSSProperties) => JSX.Element;
248
- itemKey: (index: number, data: TreeNodeData) => any;
248
+ itemKey: (index: number, data: Record<string, any>) => any;
249
249
  renderNodeList: () => JSX.Element;
250
250
  renderTree: () => JSX.Element;
251
251
  render(): JSX.Element;
@@ -77,6 +77,8 @@ var _checkboxGroup = _interopRequireDefault(require("../checkbox/checkboxGroup")
77
77
 
78
78
  var _index3 = _interopRequireDefault(require("../popover/index"));
79
79
 
80
+ var _virtualRow = _interopRequireDefault(require("../select/virtualRow"));
81
+
80
82
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
81
83
 
82
84
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -813,8 +815,11 @@ class TreeSelect extends _baseComponent.default {
813
815
  };
814
816
 
815
817
  this.itemKey = (index, data) => {
816
- // Find the item at the specified index.
817
- const item = data[index]; // Return a value that uniquely identifies this item.
818
+ const {
819
+ visibleOptions
820
+ } = data; // Find the item at the specified index.
821
+
822
+ const item = visibleOptions[index]; // Return a value that uniquely identifies this item.
818
823
 
819
824
  return item.key;
820
825
  };
@@ -848,23 +853,18 @@ class TreeSelect extends _baseComponent.default {
848
853
  });
849
854
  }
850
855
 
851
- const option = _ref => {
852
- let {
853
- index,
854
- style,
855
- data
856
- } = _ref;
857
- return this.renderTreeNode(data[index], index, style);
856
+ const data = {
857
+ visibleOptions: flattenNodes,
858
+ renderOption: this.renderTreeNode
858
859
  };
859
-
860
860
  return /*#__PURE__*/_react.default.createElement(_autoSizer.default, {
861
861
  defaultHeight: virtualize.height,
862
862
  defaultWidth: virtualize.width
863
- }, _ref2 => {
863
+ }, _ref => {
864
864
  let {
865
865
  height,
866
866
  width
867
- } = _ref2;
867
+ } = _ref;
868
868
  return /*#__PURE__*/_react.default.createElement(_reactWindow.FixedSizeList, {
869
869
  itemCount: flattenNodes.length,
870
870
  itemSize: virtualize.itemSize,
@@ -872,12 +872,12 @@ class TreeSelect extends _baseComponent.default {
872
872
  width: width,
873
873
  // @ts-ignore avoid strict check of itemKey
874
874
  itemKey: this.itemKey,
875
- itemData: flattenNodes,
875
+ itemData: data,
876
876
  className: `${prefixTree}-virtual-list`,
877
877
  style: {
878
878
  direction
879
879
  }
880
- }, option);
880
+ }, _virtualRow.default);
881
881
  });
882
882
  };
883
883
 
@@ -1188,11 +1188,11 @@ class TreeSelect extends _baseComponent.default {
1188
1188
  };
1189
1189
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, super.adapter), filterAdapter), treeSelectAdapter), treeAdapter), {
1190
1190
  updateLoadKeys: (data, resolve) => {
1191
- this.setState(_ref3 => {
1191
+ this.setState(_ref2 => {
1192
1192
  let {
1193
1193
  loadedKeys,
1194
1194
  loadingKeys
1195
- } = _ref3;
1195
+ } = _ref2;
1196
1196
  return this.foundation.handleNodeLoad(loadedKeys, loadingKeys, data, resolve);
1197
1197
  });
1198
1198
  },
@@ -1229,11 +1229,11 @@ class TreeSelect extends _baseComponent.default {
1229
1229
  notifyChangeWithObject: (node, e) => {
1230
1230
  this.props.onChange && this.props.onChange(node, e);
1231
1231
  },
1232
- notifyExpand: (expandedKeys, _ref4) => {
1232
+ notifyExpand: (expandedKeys, _ref3) => {
1233
1233
  let {
1234
1234
  expanded: bool,
1235
1235
  node
1236
- } = _ref4;
1236
+ } = _ref3;
1237
1237
  this.props.onExpand && this.props.onExpand([...expandedKeys], {
1238
1238
  expanded: bool,
1239
1239
  node
@@ -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;
@@ -1,7 +1,8 @@
1
+ import _isEqual from "lodash/isEqual";
1
2
  import _debounce from "lodash/debounce";
2
3
 
3
4
  /* eslint-disable jsx-a11y/no-static-element-interactions */
4
- import React, { Children } from 'react';
5
+ import React, { Children, isValidElement } from 'react';
5
6
  import cls from 'classnames';
6
7
  import PropTypes from 'prop-types';
7
8
  import BaseComponent from "../_base/baseComponent";
@@ -17,10 +18,12 @@ class Carousel extends BaseComponent {
17
18
  super(props);
18
19
 
19
20
  this.play = () => {
21
+ this.foundation.setForcePlay(true);
20
22
  return this.foundation.handleAutoPlay();
21
23
  };
22
24
 
23
25
  this.stop = () => {
26
+ this.foundation.setForcePlay(false);
24
27
  return this.foundation.stop();
25
28
  };
26
29
 
@@ -47,7 +50,7 @@ class Carousel extends BaseComponent {
47
50
  autoPlay
48
51
  } = this.props;
49
52
 
50
- if (typeof autoPlay !== 'object' || autoPlay.hoverToPause) {
53
+ if (autoPlay === true || typeof autoPlay === 'object' && autoPlay.hoverToPause) {
51
54
  this.foundation.stop();
52
55
  }
53
56
  };
@@ -227,6 +230,17 @@ class Carousel extends BaseComponent {
227
230
  this.handleAutoPlay();
228
231
  }
229
232
 
233
+ componentDidUpdate(prevProps, prevState, snapshot) {
234
+ const prevChildrenKeys = React.Children.toArray(prevProps.children).map(child => /*#__PURE__*/isValidElement(child) ? child.key : null);
235
+ const nowChildrenKeys = React.Children.toArray(this.props.children).map(child => /*#__PURE__*/isValidElement(child) ? child.key : null);
236
+
237
+ if (!_isEqual(prevChildrenKeys, nowChildrenKeys)) {
238
+ this.setState({
239
+ children: this.getChildren()
240
+ });
241
+ }
242
+ }
243
+
230
244
  componentWillUnmount() {
231
245
  this.foundation.destroy();
232
246
  }
@@ -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/es/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
  }
@@ -83,10 +83,6 @@ export default class PreviewInner extends BaseComponent {
83
83
  this.foundation.handleMouseDown(e);
84
84
  };
85
85
 
86
- this.handleRatio = type => {
87
- this.foundation.handleRatio(type);
88
- };
89
-
90
86
  this.state = {
91
87
  imgSrc: [],
92
88
  imgLoadStatus: new Map(),
@@ -237,7 +233,10 @@ export default class PreviewInner extends BaseComponent {
237
233
  }
238
234
 
239
235
  if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
240
- willUpdateStates.currentIndex = props.currentIndex;
236
+ willUpdateStates.currentIndex = props.currentIndex; // ratio will set to adaptation when change picture,
237
+ // attention: If the ratio is controlled, the ratio should not change as the index changes
238
+
239
+ willUpdateStates.ratio = 'adaptation';
241
240
  }
242
241
 
243
242
  return willUpdateStates;
@@ -359,7 +358,7 @@ export default class PreviewInner extends BaseComponent {
359
358
  src: imgSrc[currentIndex],
360
359
  onZoom: this.handleZoomImage,
361
360
  disableDownload: disableDownload,
362
- setRatio: this.handleRatio,
361
+ setRatio: this.handleAdjustRatio,
363
362
  zoom: zoom,
364
363
  ratio: ratio,
365
364
  zoomStep: zoomStep,
@@ -231,7 +231,16 @@ export default class Popconfirm extends BaseComponent {
231
231
  return /*#__PURE__*/React.createElement(Popover, Object.assign({
232
232
  ref: this.popoverRef
233
233
  }, attrs, {
234
- content: this.renderConfirmPopCard,
234
+ // A arrow function needs to be passed here, otherwise the content will not be updated after the Popconfirm state is updated
235
+ // Popover is a PureComponent, same props will not trigger update
236
+ content: _ref2 => {
237
+ let {
238
+ initialFocusRef
239
+ } = _ref2;
240
+ return this.renderConfirmPopCard({
241
+ initialFocusRef
242
+ });
243
+ },
235
244
  visible: visible,
236
245
  position: position
237
246
  }, popProps), children);
@@ -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;