@arim-aisdc/public-components 2.3.72 → 2.3.73

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.
@@ -33,6 +33,7 @@ export interface ConfigConsumerProps {
33
33
  openMemo?: boolean;
34
34
  canSelectionUseShift?: boolean;
35
35
  openNullValueFilter?: boolean;
36
+ openIndexColumn?: boolean;
36
37
  };
37
38
  keepAliveActivateKey?: number;
38
39
  keepAliveUnactivateKey?: number;
@@ -5,7 +5,8 @@ export declare enum ColumnType {
5
5
  Selection = "selection-column",
6
6
  Darg = "darg-column",
7
7
  PlaceHolder = "placeholder-column",
8
- Expander = "expander"
8
+ Expander = "expander",
9
+ Index = "inner-index"
9
10
  }
10
11
  export type ColumnSizing = Record<string, number>;
11
12
  export declare const CACHE_MAX_AGE: number;
@@ -47,6 +47,7 @@ export var ColumnType = /*#__PURE__*/function (ColumnType) {
47
47
  ColumnType["Darg"] = "darg-column";
48
48
  ColumnType["PlaceHolder"] = "placeholder-column";
49
49
  ColumnType["Expander"] = "expander";
50
+ ColumnType["Index"] = "inner-index";
50
51
  return ColumnType;
51
52
  }({});
52
53
  export var CACHE_MAX_AGE = 1 * 60 * 60 * 1000;
@@ -66,6 +67,15 @@ var defaultColumnPinningConfig = {
66
67
  };
67
68
  var initSelectedRowIds = [];
68
69
  var initColumnFilters = [];
70
+ var defaultOnSelectAllChange = function defaultOnSelectAllChange() {
71
+ return false;
72
+ };
73
+ var defaultGetRowCanExpand = function defaultGetRowCanExpand() {
74
+ return false;
75
+ };
76
+ var defaultDragBeforeEnd = function defaultDragBeforeEnd() {
77
+ return false;
78
+ };
69
79
  var TableMax = function TableMax(_ref) {
70
80
  var _JSON$parse;
71
81
  var tableId = _ref.tableId,
@@ -158,15 +168,11 @@ var TableMax = function TableMax(_ref) {
158
168
  getColumnFiltersData = _ref.getColumnFiltersData,
159
169
  saveEditing = _ref.saveEditing,
160
170
  _ref$getRowCanExpand = _ref.getRowCanExpand,
161
- getRowCanExpand = _ref$getRowCanExpand === void 0 ? function () {
162
- return false;
163
- } : _ref$getRowCanExpand,
171
+ getRowCanExpand = _ref$getRowCanExpand === void 0 ? defaultGetRowCanExpand : _ref$getRowCanExpand,
164
172
  renderSubComponent = _ref.renderSubComponent,
165
173
  refInstance = _ref.refInstance,
166
174
  _ref$onSelectAllChang = _ref.onSelectAllChange,
167
- onSelectAllChange = _ref$onSelectAllChang === void 0 ? function () {
168
- return false;
169
- } : _ref$onSelectAllChang,
175
+ onSelectAllChange = _ref$onSelectAllChang === void 0 ? defaultOnSelectAllChange : _ref$onSelectAllChang,
170
176
  _ref$enableRowSelecti = _ref.enableRowSelection,
171
177
  enableRowSelection = _ref$enableRowSelecti === void 0 ? true : _ref$enableRowSelecti,
172
178
  onRowMouseEnter = _ref.onRowMouseEnter,
@@ -182,9 +188,7 @@ var TableMax = function TableMax(_ref) {
182
188
  _ref$autoHeight = _ref.autoHeight,
183
189
  autoHeight = _ref$autoHeight === void 0 ? false : _ref$autoHeight,
184
190
  _ref$dragBeforeEnd = _ref.dragBeforeEnd,
185
- dragBeforeEnd = _ref$dragBeforeEnd === void 0 ? function () {
186
- return true;
187
- } : _ref$dragBeforeEnd,
191
+ dragBeforeEnd = _ref$dragBeforeEnd === void 0 ? defaultDragBeforeEnd : _ref$dragBeforeEnd,
188
192
  dragBeforeStart = _ref.dragBeforeStart,
189
193
  getContextMenu = _ref.getContextMenu,
190
194
  onClickContextMenu = _ref.onClickContextMenu,
@@ -208,7 +212,8 @@ var TableMax = function TableMax(_ref) {
208
212
  openVirtualColumns = _ref$openVirtualColum === void 0 ? false : _ref$openVirtualColum,
209
213
  _ref$openVirtualRows = _ref.openVirtualRows,
210
214
  openVirtualRows = _ref$openVirtualRows === void 0 ? false : _ref$openVirtualRows,
211
- openNullValueFilter = _ref.openNullValueFilter;
215
+ openNullValueFilter = _ref.openNullValueFilter,
216
+ openIndexColumn = _ref.openIndexColumn;
212
217
  var tableMaxRef = useRef(null);
213
218
  // 表格元素
214
219
  var tableContentRef = useRef(null);
@@ -234,14 +239,16 @@ var TableMax = function TableMax(_ref) {
234
239
  openMemo = _ref2.openMemo,
235
240
  globalCanExport = _ref2.canExport,
236
241
  canSelectionUseShift = _ref2.canSelectionUseShift,
237
- openNullValueFilter = _ref2.openNullValueFilter;
242
+ openNullValueFilter = _ref2.openNullValueFilter,
243
+ openIndexColumn = _ref2.openIndexColumn;
238
244
  return {
239
245
  globalCanExport: globalCanExport,
240
246
  globalPageSizeOptions: globalPageSizeOptions,
241
247
  canSelectionUseShift: canSelectionUseShift,
242
248
  cacheMaxAge: cacheMaxAge,
243
249
  openMemo: openMemo,
244
- openNullValueFilter: openNullValueFilter
250
+ openNullValueFilter: openNullValueFilter,
251
+ openIndexColumn: openIndexColumn
245
252
  };
246
253
  }, [JSON.stringify(tableMax)]);
247
254
 
@@ -596,6 +603,21 @@ var TableMax = function TableMax(_ref) {
596
603
  var recentlyCheckedRow = useRef(null);
597
604
  var setColumnsByProps = useCallback(function () {
598
605
  var extraColumns = [];
606
+ if (openIndexColumn !== null && openIndexColumn !== void 0 ? openIndexColumn : tableMaxConfig === null || tableMaxConfig === void 0 ? void 0 : tableMaxConfig.openIndexColumn) {
607
+ extraColumns.unshift({
608
+ id: ColumnType.Index,
609
+ tooltip: false,
610
+ accessorKey: ColumnType.Index,
611
+ header: '序号',
612
+ cell: function cell(_ref6) {
613
+ var row = _ref6.row;
614
+ return row.index + 1;
615
+ },
616
+ size: 60,
617
+ enableSorting: false,
618
+ enableColumnFilter: false
619
+ });
620
+ }
599
621
  if (getRowCanExpand() && columns.findIndex(function (column) {
600
622
  return column.id === 'expander';
601
623
  }) === -1) {
@@ -605,8 +627,8 @@ var TableMax = function TableMax(_ref) {
605
627
  size: 40,
606
628
  tooltip: false,
607
629
  enableResizing: false,
608
- cell: function cell(_ref6) {
609
- var row = _ref6.row;
630
+ cell: function cell(_ref7) {
631
+ var row = _ref7.row;
610
632
  return row.getCanExpand() ? /*#__PURE__*/_jsx("div", {
611
633
  onClick: function onClick(evt) {
612
634
  evt.stopPropagation();
@@ -627,8 +649,8 @@ var TableMax = function TableMax(_ref) {
627
649
  id: ColumnType.Selection,
628
650
  tooltip: false,
629
651
  enableResizing: false,
630
- header: function header(_ref7) {
631
- var table = _ref7.table;
652
+ header: function header(_ref8) {
653
+ var table = _ref8.table;
632
654
  return /*#__PURE__*/_jsx(Checkbox, {
633
655
  checked: table.getIsAllRowsSelected(),
634
656
  indeterminate: table.getIsSomePageRowsSelected(),
@@ -639,9 +661,9 @@ var TableMax = function TableMax(_ref) {
639
661
  }
640
662
  });
641
663
  },
642
- cell: function cell(_ref8) {
643
- var row = _ref8.row,
644
- table = _ref8.table;
664
+ cell: function cell(_ref9) {
665
+ var row = _ref9.row,
666
+ table = _ref9.table;
645
667
  return /*#__PURE__*/_jsx(Checkbox, {
646
668
  checked: row.getIsSelected(),
647
669
  disabled: !row.getCanSelect(),
@@ -967,7 +989,7 @@ var TableMax = function TableMax(_ref) {
967
989
 
968
990
  // 保存编辑内容
969
991
  var save = /*#__PURE__*/function () {
970
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
992
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
971
993
  var _tableRows$find2;
972
994
  var newRow, _table$getRowModel4, tableRows, originRow;
973
995
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -990,7 +1012,7 @@ var TableMax = function TableMax(_ref) {
990
1012
  }, _callee);
991
1013
  }));
992
1014
  return function save() {
993
- return _ref9.apply(this, arguments);
1015
+ return _ref10.apply(this, arguments);
994
1016
  };
995
1017
  }();
996
1018
  var triggerSave = function triggerSave(e) {
@@ -1231,31 +1253,6 @@ var TableMax = function TableMax(_ref) {
1231
1253
  return refreshFun === null || refreshFun === void 0 ? void 0 : refreshFun();
1232
1254
  }
1233
1255
  })
1234
- }), canEditting && /*#__PURE__*/_jsx("span", {
1235
- className: canClickEditIcon ? undefined : 'disableBtn',
1236
- children: /*#__PURE__*/_jsx(Tooltip, {
1237
- placement: "top",
1238
- title: '编辑',
1239
- children: /*#__PURE__*/_jsx("i", {
1240
- className: "iconfont-other icon-other-bianji handleRightItem",
1241
- style: {
1242
- fontSize: '16px',
1243
- marginRight: 0
1244
- },
1245
- onClick: editFun
1246
- })
1247
- })
1248
- }), canDelete && /*#__PURE__*/_jsx(Tooltip, {
1249
- placement: "top",
1250
- title: '删除',
1251
- children: /*#__PURE__*/_jsx("i", {
1252
- className: "iconfont-table icon-table-delete handleRightItem",
1253
- style: {
1254
- fontSize: '16px',
1255
- marginRight: 0
1256
- },
1257
- onClick: handleClickDelete
1258
- })
1259
1256
  }), canFilter && /*#__PURE__*/_jsx(Tooltip, {
1260
1257
  placement: "top",
1261
1258
  title: '重置筛选',
@@ -1288,6 +1285,31 @@ var TableMax = function TableMax(_ref) {
1288
1285
  },
1289
1286
  onClick: changeCompactMode
1290
1287
  })
1288
+ }), canEditting && /*#__PURE__*/_jsx("span", {
1289
+ className: canClickEditIcon ? undefined : 'disableBtn',
1290
+ children: /*#__PURE__*/_jsx(Tooltip, {
1291
+ placement: "top",
1292
+ title: '编辑',
1293
+ children: /*#__PURE__*/_jsx("i", {
1294
+ className: "iconfont-other icon-other-bianji handleRightItem",
1295
+ style: {
1296
+ fontSize: '16px',
1297
+ marginRight: 0
1298
+ },
1299
+ onClick: editFun
1300
+ })
1301
+ })
1302
+ }), canDelete && /*#__PURE__*/_jsx(Tooltip, {
1303
+ placement: "top",
1304
+ title: '删除',
1305
+ children: /*#__PURE__*/_jsx("i", {
1306
+ className: "iconfont-table icon-table-delete handleRightItem",
1307
+ style: {
1308
+ fontSize: '16px',
1309
+ marginRight: 0
1310
+ },
1311
+ onClick: handleClickDelete
1312
+ })
1291
1313
  }), canSetting && /*#__PURE__*/_jsx(ColumnSetting, {
1292
1314
  table: table,
1293
1315
  tableId: tableId,
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
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;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
6
6
  declare const customSortFns: {
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;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | -1 | 0;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
@@ -73,7 +73,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
73
73
  */
74
74
  var getAdjustableColumns = useCallback(function (columns) {
75
75
  return Object.keys(columns).filter(function (key) {
76
- return !['expander', 'selection-column'].includes(key);
76
+ return !['expander', 'selection-column', 'inner-index'].includes(key);
77
77
  });
78
78
  }, []);
79
79
 
@@ -335,6 +335,7 @@ export type TableMaxProps = {
335
335
  openVirtualRows?: boolean;
336
336
  /**开启空值过滤 */
337
337
  openNullValueFilter?: boolean;
338
+ openIndexColumn?: boolean;
338
339
  };
339
340
  export interface TableMaxColumnType {
340
341
  /**每一列的id是唯一的 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.3.72",
3
+ "version": "2.3.73",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",