@arim-aisdc/public-components 2.3.47 → 2.3.49

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.
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
17
17
  value: any;
18
18
  field: string;
19
19
  label?: string;
20
- text: string | Element | JSX.Element;
20
+ text: string | JSX.Element | Element;
21
21
  units?: string;
22
22
  width?: string;
23
23
  labelWidth?: string;
@@ -31,6 +31,7 @@ export interface ConfigConsumerProps {
31
31
  pageSizeOptions?: number[];
32
32
  cacheMaxAge?: number;
33
33
  openMemo?: boolean;
34
+ canSelectionUseShift?: boolean;
34
35
  };
35
36
  }
36
37
  export declare const DEFAULT_CONTEXT: {
@@ -114,7 +114,7 @@ var UploadImg = function UploadImg(_ref) {
114
114
  url = "".concat(item === null || item === void 0 ? void 0 : item.baseUrl, "/api/file-management/file-descriptor/content");
115
115
  _context2.prev = 3;
116
116
  _context2.next = 6;
117
- return fetch("".concat(url, "?id=").concat(id), {
117
+ return fetch("".concat(url, "?fileId=").concat(id), {
118
118
  method: 'GET',
119
119
  headers: {
120
120
  Authorization: "Bearer ".concat(item === null || item === void 0 ? void 0 : item.token)
@@ -116,6 +116,7 @@ var TableMax = function TableMax(_ref) {
116
116
  defaultCompactMode = _ref$defaultCompactMo === void 0 ? false : _ref$defaultCompactMo,
117
117
  _ref$canSelection = _ref.canSelection,
118
118
  canSelection = _ref$canSelection === void 0 ? false : _ref$canSelection,
119
+ canSelectionUseShift = _ref.canSelectionUseShift,
119
120
  _ref$selectionWithout = _ref.selectionWithoutChecked,
120
121
  selectionWithoutChecked = _ref$selectionWithout === void 0 ? false : _ref$selectionWithout,
121
122
  _ref$canRowDrag = _ref.canRowDrag,
@@ -223,10 +224,12 @@ var TableMax = function TableMax(_ref) {
223
224
  globalPageSizeOptions = _ref2.pageSizeOptions,
224
225
  cacheMaxAge = _ref2.cacheMaxAge,
225
226
  openMemo = _ref2.openMemo,
226
- globalCanExport = _ref2.canExport;
227
+ globalCanExport = _ref2.canExport,
228
+ canSelectionUseShift = _ref2.canSelectionUseShift;
227
229
  return {
228
230
  globalCanExport: globalCanExport,
229
231
  globalPageSizeOptions: globalPageSizeOptions,
232
+ canSelectionUseShift: canSelectionUseShift,
230
233
  cacheMaxAge: cacheMaxAge,
231
234
  openMemo: openMemo
232
235
  };
@@ -554,6 +557,8 @@ var TableMax = function TableMax(_ref) {
554
557
  }
555
558
  setColumnOrder(arr);
556
559
  };
560
+ var recentlyCheckedRow = useRef(null);
561
+ var allCheckedRow = useRef(null);
557
562
  var setColumnsByProps = useCallback(function () {
558
563
  var extraColumns = [];
559
564
  if (getRowCanExpand() && columns.findIndex(function (column) {
@@ -606,16 +611,65 @@ var TableMax = function TableMax(_ref) {
606
611
  checked: row.getIsSelected(),
607
612
  disabled: !row.getCanSelect(),
608
613
  indeterminate: row.getIsSomeSelected(),
609
- onChange: row.getToggleSelectedHandler(),
610
- onClick: function onClick(e) {
611
- var _table$getRowModel;
612
- var curSelectedRows = (_table$getRowModel = table.getRowModel()) === null || _table$getRowModel === void 0 ? void 0 : _table$getRowModel.rows.filter(function (item) {
613
- if (item.id === row.id) {
614
- return !row.getIsSelected();
615
- }
616
- return item.getIsSelected();
617
- });
618
- onRowCheckboxClick === null || onRowCheckboxClick === void 0 || onRowCheckboxClick(row, row.original, !row.getIsSelected(), curSelectedRows);
614
+ // onChange: row.getToggleSelectedHandler(),
615
+ onChange: function onChange(e) {
616
+ var _e$nativeEvent;
617
+ var currentRowIsSelected,
618
+ currentSelectedRows = [],
619
+ allSelectedRows = [];
620
+ var isCanShiftControl = canSelectionUseShift !== null && canSelectionUseShift !== void 0 ? canSelectionUseShift : tableMaxConfig === null || tableMaxConfig === void 0 ? void 0 : tableMaxConfig.canSelectionUseShift;
621
+ if (!isCanShiftControl) {
622
+ var _table$getRowModel;
623
+ row.toggleSelected();
624
+ currentRowIsSelected = !row.getIsSelected();
625
+ allSelectedRows = (_table$getRowModel = table.getRowModel()) === null || _table$getRowModel === void 0 ? void 0 : _table$getRowModel.rows.filter(function (item) {
626
+ if (item.id === row.id) {
627
+ return !row.getIsSelected();
628
+ }
629
+ return item.getIsSelected();
630
+ });
631
+ // 为了兼容之前的逻辑,currentSelectedRows在不使用shift时是对象,使用shift时是数组
632
+ onRowCheckboxClick === null || onRowCheckboxClick === void 0 || onRowCheckboxClick(row, row.original, currentRowIsSelected, allSelectedRows);
633
+ e.stopPropagation();
634
+ return;
635
+ }
636
+ if (e !== null && e !== void 0 && (_e$nativeEvent = e.nativeEvent) !== null && _e$nativeEvent !== void 0 && _e$nativeEvent.shiftKey) {
637
+ var selectionConfig = {};
638
+ var initselectedIndex = recentlyCheckedRow.current;
639
+ var min = Math.min(initselectedIndex || 0, row.index);
640
+ var max = Math.max(initselectedIndex || 0, row.index);
641
+ table.getRowModel().rows.map(function (row) {
642
+ var isInRange = row.index >= min && row.index <= max;
643
+ if (isInRange) {
644
+ var insertMethod = initselectedIndex < row.index ? 'push' : 'unshift';
645
+ currentSelectedRows[insertMethod](row);
646
+ }
647
+ if (row.getIsSelected() || isInRange) {
648
+ selectionConfig[row.id] = true;
649
+ allSelectedRows.push(row);
650
+ }
651
+ });
652
+ setRowSelection(function (prev) {
653
+ return _objectSpread(_objectSpread({}, prev), selectionConfig);
654
+ });
655
+ currentRowIsSelected = true;
656
+ } else {
657
+ var _table$getRowModel2;
658
+ row.toggleSelected();
659
+ currentRowIsSelected = !row.getIsSelected();
660
+ currentSelectedRows = [row];
661
+ allSelectedRows = (_table$getRowModel2 = table.getRowModel()) === null || _table$getRowModel2 === void 0 ? void 0 : _table$getRowModel2.rows.filter(function (item) {
662
+ if (item.id === row.id) {
663
+ return !row.getIsSelected();
664
+ }
665
+ return item.getIsSelected();
666
+ });
667
+ }
668
+ recentlyCheckedRow.current = currentRowIsSelected ? row.index : recentlyCheckedRow.current;
669
+ // currentSelectedRows是数组
670
+ onRowCheckboxClick === null || onRowCheckboxClick === void 0 || onRowCheckboxClick(currentSelectedRows, currentSelectedRows.map(function (row) {
671
+ return row.original;
672
+ }), currentRowIsSelected, allSelectedRows);
619
673
  // 阻止点击事件冒泡,监听行双击事件时,点击这里会有问题
620
674
  e.stopPropagation();
621
675
  }
@@ -625,7 +679,7 @@ var TableMax = function TableMax(_ref) {
625
679
  });
626
680
  }
627
681
  return extraColumns;
628
- }, [canSelection, selectionWithoutChecked, getRowCanExpand, columns]);
682
+ }, [canSelection, canSelectionUseShift, tableMaxConfig === null || tableMaxConfig === void 0 ? void 0 : tableMaxConfig.canSelectionUseShift, selectionWithoutChecked, getRowCanExpand, columns, rowKey]);
629
683
 
630
684
  // 初始化列
631
685
  useEffect(function () {
@@ -664,6 +718,7 @@ var TableMax = function TableMax(_ref) {
664
718
 
665
719
  var _rowSelectionChange = useCallback(debounce(function (rowOriginal, row) {
666
720
  if (rowSelectionChange) {
721
+ console.log(rowOriginal, row, 'rowSelectionChange1');
667
722
  rowSelectionChange(rowOriginal, row);
668
723
  }
669
724
  }, 100), [rowSelectionChange]);
@@ -876,8 +931,8 @@ var TableMax = function TableMax(_ref) {
876
931
  if (!canClickEditIcon) return;
877
932
  var selectedTableRows = table.getSelectedRowModel().rows;
878
933
  var selectedTableRowsLength = selectedTableRows.length;
879
- var _table$getRowModel2 = table.getRowModel(),
880
- tableRows = _table$getRowModel2.rows;
934
+ var _table$getRowModel3 = table.getRowModel(),
935
+ tableRows = _table$getRowModel3.rows;
881
936
  var selectRow =
882
937
  // eslint-disable-next-line eqeqeq
883
938
  (canSelection ? (_selectedTableRows = selectedTableRows[selectedTableRowsLength - 1]) === null || _selectedTableRows === void 0 ? void 0 : _selectedTableRows.original : (_tableRows$find = tableRows.find(function (item) {
@@ -896,7 +951,7 @@ var TableMax = function TableMax(_ref) {
896
951
  var save = /*#__PURE__*/function () {
897
952
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
898
953
  var _tableRows$find2;
899
- var newRow, _table$getRowModel3, tableRows, originRow;
954
+ var newRow, _table$getRowModel4, tableRows, originRow;
900
955
  return _regeneratorRuntime().wrap(function _callee$(_context) {
901
956
  while (1) switch (_context.prev = _context.next) {
902
957
  case 0:
@@ -904,7 +959,7 @@ var TableMax = function TableMax(_ref) {
904
959
  return form.validateFields();
905
960
  case 2:
906
961
  newRow = _context.sent;
907
- _table$getRowModel3 = table.getRowModel(), tableRows = _table$getRowModel3.rows; // eslint-disable-next-line eqeqeq
962
+ _table$getRowModel4 = table.getRowModel(), tableRows = _table$getRowModel4.rows; // eslint-disable-next-line eqeqeq
908
963
  originRow = ((_tableRows$find2 = tableRows.find(function (item) {
909
964
  return item.id == editingRowId;
910
965
  })) === null || _tableRows$find2 === void 0 ? void 0 : _tableRows$find2.original) || {}; // eslint-disable-next-line @typescript-eslint/no-unused-expressions
@@ -957,8 +1012,8 @@ var TableMax = function TableMax(_ref) {
957
1012
  } else {
958
1013
  var _tableRows$find3;
959
1014
  // 单选
960
- var _table$getRowModel4 = table.getRowModel(),
961
- tableRows = _table$getRowModel4.rows;
1015
+ var _table$getRowModel5 = table.getRowModel(),
1016
+ tableRows = _table$getRowModel5.rows;
962
1017
  deleteFun === null || deleteFun === void 0 || deleteFun((_tableRows$find3 = tableRows.find(function (item) {
963
1018
  return item.id === rowSelectedId;
964
1019
  })) === null || _tableRows$find3 === void 0 ? void 0 : _tableRows$find3.original);
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
@@ -169,6 +169,8 @@ export type TableMaxProps = {
169
169
  defaultCompactMode?: boolean;
170
170
  /**是否支持多选,默认不支持 */
171
171
  canSelection?: boolean;
172
+ /**是否支持shift多选,无默认值,可以在 ConfigProvider配置 */
173
+ canSelectionUseShift?: boolean;
172
174
  /**多选不显示勾选框,ctrl shift进行多选 */
173
175
  selectionWithoutChecked?: boolean;
174
176
  /** 行是否可拖动,默认不支持 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.3.47",
3
+ "version": "2.3.49",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",