@douyinfe/semi-ui 2.31.0-beta.0 → 2.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,6 @@ import Spin from '../spin';
35
35
  import Trigger from '../trigger';
36
36
  import { IconChevronDown, IconClear } from '@douyinfe/semi-icons';
37
37
  import { isSemiIcon, getFocusableElements, getActiveElement } from '../_utils';
38
- import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
39
38
  import { getUuidShort } from '@douyinfe/semi-foundation/lib/es/utils/uuid';
40
39
  import '@douyinfe/semi-foundation/lib/es/select/select.css';
41
40
  const prefixcls = cssClasses.PREFIX;
@@ -49,7 +48,7 @@ class Select extends BaseComponent {
49
48
  current: node
50
49
  };
51
50
 
52
- this.handleInputChange = value => this.foundation.handleInputChange(value);
51
+ this.handleInputChange = (value, event) => this.foundation.handleInputChange(value, event);
53
52
 
54
53
  this.getTagItem = (item, i, renderSelectedItem) => {
55
54
  const {
@@ -136,8 +135,6 @@ class Select extends BaseComponent {
136
135
  this.onKeyPress = this.onKeyPress.bind(this);
137
136
  this.eventManager = new Event();
138
137
  this.foundation = new SelectFoundation(this.adapter);
139
- warning('optionLabelProp' in this.props, '[Semi Select] \'optionLabelProp\' has already been deprecated, please use \'renderSelectedItem\' instead.');
140
- warning('labelInValue' in this.props, '[Semi Select] \'labelInValue\' has already been deprecated, please use \'onChangeWithObject\' instead.');
141
138
  }
142
139
 
143
140
  get adapter() {
@@ -306,8 +303,8 @@ class Select extends BaseComponent {
306
303
  notifyDropdownVisibleChange: visible => {
307
304
  this.props.onDropdownVisibleChange(visible);
308
305
  },
309
- notifySearch: input => {
310
- this.props.onSearch(input);
306
+ notifySearch: (input, event) => {
307
+ this.props.onSearch(input, event);
311
308
  },
312
309
  notifyCreate: input => {
313
310
  this.props.onCreate(input);
@@ -5,10 +5,11 @@ const VirtualRow = _ref => {
5
5
  style
6
6
  } = _ref;
7
7
  const {
8
- visibleOptions
8
+ visibleOptions,
9
+ renderOption
9
10
  } = data;
10
11
  const option = visibleOptions[index];
11
- return data.renderOption(option, index, style);
12
+ return renderOption(option, index, style);
12
13
  };
13
14
 
14
15
  export 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/es/table/tableSelectionCellFoundation';
4
+ import TableSelectionCellFoundation, { TableSelectionCellAdapter, TableSelectionCellEvent } from '@douyinfe/semi-foundation/lib/es/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
@@ -298,7 +298,7 @@ class Table extends BaseComponent {
298
298
  let inHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
299
299
  const {
300
300
  rowSelection,
301
- disabledRowKeysSet
301
+ allDisabledRowKeysSet
302
302
  } = _this.state;
303
303
 
304
304
  if (rowSelection && typeof rowSelection === 'object') {
@@ -315,7 +315,7 @@ class Table extends BaseComponent {
315
315
  const allRowKeys = _this.cachedFilteredSortedRowKeys;
316
316
  const allRowKeysSet = _this.cachedFilteredSortedRowKeysSet;
317
317
 
318
- const allIsSelected = _this.foundation.allIsSelected(selectedRowKeysSet, disabledRowKeysSet, allRowKeys);
318
+ const allIsSelected = _this.foundation.allIsSelected(selectedRowKeysSet, allDisabledRowKeysSet, allRowKeys);
319
319
 
320
320
  const hasRowSelected = _this.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
321
321
 
@@ -325,8 +325,8 @@ class Table extends BaseComponent {
325
325
  key: columnKey,
326
326
  selected: allIsSelected,
327
327
  indeterminate: hasRowSelected && !allIsSelected,
328
- onChange: (status, e) => {
329
- _this.toggleSelectAllRow(status, e);
328
+ onChange: (selected, e) => {
329
+ _this.toggleSelectAllRow(selected, e);
330
330
  }
331
331
  });
332
332
  } else {
@@ -529,8 +529,8 @@ class Table extends BaseComponent {
529
529
  this.foundation.handleSelectRow(realKey, selected, e);
530
530
  };
531
531
 
532
- this.toggleSelectAllRow = (status, e) => {
533
- this.foundation.handleSelectAllRow(status, e);
532
+ this.toggleSelectAllRow = (selected, e) => {
533
+ this.foundation.handleSelectAllRow(selected, e);
534
534
  };
535
535
  /**
536
536
  * render pagination
@@ -848,6 +848,8 @@ class Table extends BaseComponent {
848
848
  allRowKeys: [],
849
849
  disabledRowKeys: [],
850
850
  disabledRowKeysSet: new Set(),
851
+ allDisabledRowKeys: [],
852
+ allDisabledRowKeysSet: new Set(),
851
853
  headWidths: [],
852
854
  bodyHasScrollBar: false,
853
855
  prePropRowSelection: undefined,
@@ -952,11 +954,20 @@ class Table extends BaseComponent {
952
954
  this.cachedFilteredSortedRowKeys = filteredSortedRowKeys;
953
955
  this.cachedFilteredSortedRowKeysSet = new Set(filteredSortedRowKeys);
954
956
  },
957
+ setAllDisabledRowKeys: allDisabledRowKeys => {
958
+ const allDisabledRowKeysSet = new Set(allDisabledRowKeys);
959
+ this.setState({
960
+ allDisabledRowKeys,
961
+ allDisabledRowKeysSet
962
+ });
963
+ },
955
964
  getCurrentPage: () => _get(this.state, 'pagination.currentPage', 1),
956
965
  getCurrentPageSize: () => _get(this.state, 'pagination.pageSize', numbers.DEFAULT_PAGE_SIZE),
957
966
  getCachedFilteredSortedDataSource: () => this.cachedFilteredSortedDataSource,
958
967
  getCachedFilteredSortedRowKeys: () => this.cachedFilteredSortedRowKeys,
959
968
  getCachedFilteredSortedRowKeysSet: () => this.cachedFilteredSortedRowKeysSet,
969
+ getAllDisabledRowKeys: () => this.state.allDisabledRowKeys,
970
+ getAllDisabledRowKeysSet: () => this.state.allDisabledRowKeysSet,
960
971
  notifyFilterDropdownVisibleChange: (visible, dataIndex) => this._invokeColumnFn(dataIndex, 'onFilterDropdownVisibleChange', visible),
961
972
  notifyChange: function () {
962
973
  return _this2.props.onChange(...arguments);
@@ -1160,8 +1171,11 @@ class Table extends BaseComponent {
1160
1171
  childrenRecordName,
1161
1172
  rowKey
1162
1173
  });
1174
+ const disabledRowKeysSet = new Set(disabledRowKeys);
1163
1175
  willUpdateStates.disabledRowKeys = disabledRowKeys;
1164
- willUpdateStates.disabledRowKeysSet = new Set(disabledRowKeys);
1176
+ willUpdateStates.disabledRowKeysSet = disabledRowKeysSet;
1177
+ willUpdateStates.allDisabledRowKeys = disabledRowKeys;
1178
+ willUpdateStates.allDisabledRowKeysSet = disabledRowKeysSet;
1165
1179
  }
1166
1180
 
1167
1181
  willUpdateStates.rowSelection = newSelectionStates;
@@ -1265,7 +1279,9 @@ class Table extends BaseComponent {
1265
1279
  // Temporarily use _dataSource=[...dataSource] for processing
1266
1280
  const _dataSource = [...dataSource];
1267
1281
  const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
1282
+ const allDataDisabledRowKeys = this.foundation.getAllDisabledRowKeys(filteredSortedDataSource);
1268
1283
  this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
1284
+ this.foundation.setAllDisabledRowKeys(allDataDisabledRowKeys);
1269
1285
  states.dataSource = filteredSortedDataSource;
1270
1286
 
1271
1287
  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;
@@ -34,6 +34,7 @@ import { isSemiIcon } from '../_utils';
34
34
  import { IconChevronDown, IconClear, IconSearch } from '@douyinfe/semi-icons';
35
35
  import CheckboxGroup from '../checkbox/checkboxGroup';
36
36
  import Popover from '../popover/index';
37
+ import VirtualRow from '../select/virtualRow';
37
38
  const prefixcls = cssClasses.PREFIX;
38
39
  const prefixTree = cssClasses.PREFIX_TREE;
39
40
  const key = 0;
@@ -766,8 +767,11 @@ class TreeSelect extends BaseComponent {
766
767
  };
767
768
 
768
769
  this.itemKey = (index, data) => {
769
- // Find the item at the specified index.
770
- const item = data[index]; // Return a value that uniquely identifies this item.
770
+ const {
771
+ visibleOptions
772
+ } = data; // Find the item at the specified index.
773
+
774
+ const item = visibleOptions[index]; // Return a value that uniquely identifies this item.
771
775
 
772
776
  return item.key;
773
777
  };
@@ -801,23 +805,18 @@ class TreeSelect extends BaseComponent {
801
805
  });
802
806
  }
803
807
 
804
- const option = _ref => {
805
- let {
806
- index,
807
- style,
808
- data
809
- } = _ref;
810
- return this.renderTreeNode(data[index], index, style);
808
+ const data = {
809
+ visibleOptions: flattenNodes,
810
+ renderOption: this.renderTreeNode
811
811
  };
812
-
813
812
  return /*#__PURE__*/React.createElement(AutoSizer, {
814
813
  defaultHeight: virtualize.height,
815
814
  defaultWidth: virtualize.width
816
- }, _ref2 => {
815
+ }, _ref => {
817
816
  let {
818
817
  height,
819
818
  width
820
- } = _ref2;
819
+ } = _ref;
821
820
  return /*#__PURE__*/React.createElement(VirtualList, {
822
821
  itemCount: flattenNodes.length,
823
822
  itemSize: virtualize.itemSize,
@@ -825,12 +824,12 @@ class TreeSelect extends BaseComponent {
825
824
  width: width,
826
825
  // @ts-ignore avoid strict check of itemKey
827
826
  itemKey: this.itemKey,
828
- itemData: flattenNodes,
827
+ itemData: data,
829
828
  className: `${prefixTree}-virtual-list`,
830
829
  style: {
831
830
  direction
832
831
  }
833
- }, option);
832
+ }, VirtualRow);
834
833
  });
835
834
  };
836
835
 
@@ -1140,11 +1139,11 @@ class TreeSelect extends BaseComponent {
1140
1139
  };
1141
1140
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, super.adapter), filterAdapter), treeSelectAdapter), treeAdapter), {
1142
1141
  updateLoadKeys: (data, resolve) => {
1143
- this.setState(_ref3 => {
1142
+ this.setState(_ref2 => {
1144
1143
  let {
1145
1144
  loadedKeys,
1146
1145
  loadingKeys
1147
- } = _ref3;
1146
+ } = _ref2;
1148
1147
  return this.foundation.handleNodeLoad(loadedKeys, loadingKeys, data, resolve);
1149
1148
  });
1150
1149
  },
@@ -1181,11 +1180,11 @@ class TreeSelect extends BaseComponent {
1181
1180
  notifyChangeWithObject: (node, e) => {
1182
1181
  this.props.onChange && this.props.onChange(node, e);
1183
1182
  },
1184
- notifyExpand: (expandedKeys, _ref4) => {
1183
+ notifyExpand: (expandedKeys, _ref3) => {
1185
1184
  let {
1186
1185
  expanded: bool,
1187
1186
  node
1188
- } = _ref4;
1187
+ } = _ref3;
1189
1188
  this.props.onExpand && this.props.onExpand([...expandedKeys], {
1190
1189
  expanded: bool,
1191
1190
  node
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.31.0-beta.0",
3
+ "version": "2.31.1",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.31.0-beta.0",
21
- "@douyinfe/semi-animation-react": "2.31.0-beta.0",
22
- "@douyinfe/semi-foundation": "2.31.0-beta.0",
23
- "@douyinfe/semi-icons": "2.31.0-beta.0",
24
- "@douyinfe/semi-illustrations": "2.31.0-beta.0",
25
- "@douyinfe/semi-theme-default": "2.31.0-beta.0",
20
+ "@douyinfe/semi-animation": "2.31.1",
21
+ "@douyinfe/semi-animation-react": "2.31.1",
22
+ "@douyinfe/semi-foundation": "2.31.1",
23
+ "@douyinfe/semi-icons": "2.31.1",
24
+ "@douyinfe/semi-illustrations": "2.31.1",
25
+ "@douyinfe/semi-theme-default": "2.31.1",
26
26
  "async-validator": "^3.5.0",
27
27
  "classnames": "^2.2.6",
28
28
  "copy-text-to-clipboard": "^2.1.1",
@@ -69,7 +69,7 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "8b378259f169ca3bfb9af17118e962d717efa685",
72
+ "gitHead": "00ded133e899ea816cbefe20eebcdb60fd983ecc",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",