@arim-aisdc/public-components 2.3.25 → 2.3.26

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.
@@ -25,6 +25,11 @@ export interface ConfigConsumerProps {
25
25
  locale?: Locale;
26
26
  /**tablemax dateFormat */
27
27
  dateFormat?: string;
28
+ /**tablemax pageSizeOptions */
29
+ tableMax?: {
30
+ pageSizeOptions?: number[];
31
+ cacheMaxAge?: number;
32
+ };
28
33
  }
29
34
  export declare const DEFAULT_CONTEXT: {
30
35
  theme: string;
@@ -187,7 +187,8 @@ var TableMax = function TableMax(_ref) {
187
187
  request = _ref.request,
188
188
  onEditValueChange = _ref.onEditValueChange,
189
189
  hasTotalRow = _ref.hasTotalRow,
190
- totalDatas = _ref.totalDatas;
190
+ totalDatas = _ref.totalDatas,
191
+ pageSizeOptions = _ref.pageSizeOptions;
191
192
  var tableMaxRef = useRef(null);
192
193
  // 表格元素
193
194
  var tableContentRef = useRef(null);
@@ -204,7 +205,11 @@ var TableMax = function TableMax(_ref) {
204
205
  userId = _useConfig.userId,
205
206
  theme = _useConfig.theme,
206
207
  tableKeyPrefixCls = _useConfig.tableKeyPrefixCls,
207
- tableMaxNewPagination = _useConfig.tableMaxNewPagination;
208
+ tableMaxNewPagination = _useConfig.tableMaxNewPagination,
209
+ tableMax = _useConfig.tableMax;
210
+ var _ref2 = tableMax || {},
211
+ globalPageSizeOptions = _ref2.pageSizeOptions,
212
+ cacheMaxAge = _ref2.cacheMaxAge;
208
213
  // 多选场景下,点击行时是否选中改行。在不展示多选框(selectionWithoutChecked=true)时,会一直为true
209
214
  var selectRowWhenClick = useMemo(function () {
210
215
  return originSelectRowWhenClick || selectionWithoutChecked;
@@ -293,7 +298,8 @@ var TableMax = function TableMax(_ref) {
293
298
  tableId: tableId,
294
299
  tableKeyPrefixCls: tableKeyPrefixCls,
295
300
  columnVisibleConfig: columnVisibleConfig,
296
- tableKey: tableKey
301
+ tableKey: tableKey,
302
+ cacheMaxAge: cacheMaxAge
297
303
  }),
298
304
  columnSizing = _useColumnWidth.columnSizing,
299
305
  initializeColumnSizing = _useColumnWidth.initializeColumnSizing,
@@ -478,7 +484,8 @@ var TableMax = function TableMax(_ref) {
478
484
  var setColumnInfoFromCache = function setColumnInfoFromCache(tableColumns) {
479
485
  var _localStorage$getItem;
480
486
  var cache = JSON.parse((_localStorage$getItem = localStorage.getItem(tableKey)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '{}');
481
- if (cache && cache !== null && cache !== void 0 && cache.editTime && +new Date() - cache.editTime > CACHE_MAX_AGE) {
487
+ console.log(+cache.editTime, 'cache.editTime');
488
+ if (cache && cache !== null && cache !== void 0 && cache.editTime && +new Date() - cache.editTime > (cacheMaxAge !== null && cacheMaxAge !== void 0 ? cacheMaxAge : CACHE_MAX_AGE)) {
482
489
  return;
483
490
  }
484
491
  var cacheColumnVisibility = cache.columnVisibility,
@@ -545,8 +552,8 @@ var TableMax = function TableMax(_ref) {
545
552
  size: 40,
546
553
  tooltip: false,
547
554
  enableResizing: false,
548
- cell: function cell(_ref2) {
549
- var row = _ref2.row;
555
+ cell: function cell(_ref3) {
556
+ var row = _ref3.row;
550
557
  return row.getCanExpand() ? /*#__PURE__*/_jsx("div", {
551
558
  onClick: function onClick(evt) {
552
559
  evt.stopPropagation();
@@ -567,8 +574,8 @@ var TableMax = function TableMax(_ref) {
567
574
  id: ColumnType.Selection,
568
575
  tooltip: false,
569
576
  enableResizing: false,
570
- header: function header(_ref3) {
571
- var table = _ref3.table;
577
+ header: function header(_ref4) {
578
+ var table = _ref4.table;
572
579
  return /*#__PURE__*/_jsx(Checkbox, {
573
580
  checked: table.getIsAllRowsSelected(),
574
581
  indeterminate: table.getIsSomePageRowsSelected(),
@@ -579,9 +586,9 @@ var TableMax = function TableMax(_ref) {
579
586
  }
580
587
  });
581
588
  },
582
- cell: function cell(_ref4) {
583
- var row = _ref4.row,
584
- table = _ref4.table;
589
+ cell: function cell(_ref5) {
590
+ var row = _ref5.row,
591
+ table = _ref5.table;
585
592
  return /*#__PURE__*/_jsx(Checkbox, {
586
593
  checked: row.getIsSelected(),
587
594
  disabled: !row.getCanSelect(),
@@ -715,6 +722,7 @@ var TableMax = function TableMax(_ref) {
715
722
  /**缓存table数据 */
716
723
  useUpdateEffect(function () {
717
724
  var tableState = table.getState();
725
+ console.log(new Date(), 'new Date()');
718
726
  localStorage.setItem(tableKey, JSON.stringify({
719
727
  enableFilters: enableFilters,
720
728
  headerRowNum: headerRowNum,
@@ -725,7 +733,8 @@ var TableMax = function TableMax(_ref) {
725
733
  columnFilters: tableState.columnFilters,
726
734
  columnSorting: tableState.sorting,
727
735
  columnSizing: columnSizing,
728
- editTime: new Date()
736
+ editTime: +new Date(),
737
+ editTimeCh: dayjs().format('YYYY-MM-DD HH:mm:ss')
729
738
  }));
730
739
  }, [table.getState().columnVisibility, table.getState().columnPinning, table.getState().columnOrder, table.getState().columnFilters, table.getState().sorting, enableFilters, headerRowNum, compactMode, columnSizing]);
731
740
  var reorderRow = useCallback(function (fromDatas, toDatas) {
@@ -872,7 +881,7 @@ var TableMax = function TableMax(_ref) {
872
881
 
873
882
  // 保存编辑内容
874
883
  var save = /*#__PURE__*/function () {
875
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
884
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
876
885
  var _tableRows$find2;
877
886
  var newRow, _table$getRowModel3, tableRows, originRow;
878
887
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -895,7 +904,7 @@ var TableMax = function TableMax(_ref) {
895
904
  }, _callee);
896
905
  }));
897
906
  return function save() {
898
- return _ref5.apply(this, arguments);
907
+ return _ref6.apply(this, arguments);
899
908
  };
900
909
  }();
901
910
  var triggerSave = function triggerSave(e) {
@@ -1206,6 +1215,7 @@ var TableMax = function TableMax(_ref) {
1206
1215
  children: tableMaxNewPagination ? /*#__PURE__*/_jsx(PaginationV2, {
1207
1216
  total: totalCount,
1208
1217
  pageSize: pageSize,
1218
+ pageSizeOptions: pageSizeOptions !== null && pageSizeOptions !== void 0 ? pageSizeOptions : globalPageSizeOptions,
1209
1219
  showLessItems: showLessItems,
1210
1220
  showSizeChanger: showSizeChanger,
1211
1221
  curPageDataNum: tableDatas.length,
@@ -1224,6 +1234,7 @@ var TableMax = function TableMax(_ref) {
1224
1234
  }
1225
1235
  }) : /*#__PURE__*/_jsx(Pagination, {
1226
1236
  pageSize: pageSize,
1237
+ pageSizeOptions: pageSizeOptions !== null && pageSizeOptions !== void 0 ? pageSizeOptions : globalPageSizeOptions,
1227
1238
  total: totalCount,
1228
1239
  defaultPageSize: pageSize,
1229
1240
  current: (skipCount || skipCount === 0) && pageSize ? skipCount / pageSize + 1 : 0,
@@ -10,7 +10,7 @@
10
10
 
11
11
  .filter-panel-wrapper {
12
12
  position: fixed;
13
- // z-index: 9999;
13
+ z-index: 9999;
14
14
  border-radius: 2px;
15
15
  width: fit-content;
16
16
  height: fit-content;
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
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;
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) => 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;
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;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["showSizeChanger", "curPageDataNum"];
2
+ var _excluded = ["showSizeChanger", "curPageDataNum", "pageSizeOptions"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -16,26 +16,35 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
16
  import { Pagination, Select } from 'antd';
17
17
  import "./index.less";
18
18
  import { useTranslation } from "../../../../hooks/useTranslation";
19
+ import { useMemo } from 'react';
19
20
  import { jsx as _jsx } from "react/jsx-runtime";
20
21
  import { jsxs as _jsxs } from "react/jsx-runtime";
21
22
  var defaultPageSizeOptions = [10, 20, 50, 100];
22
- var pageSizeOptions = defaultPageSizeOptions.map(function (size) {
23
- return {
24
- value: size,
25
- label: size
26
- };
27
- });
23
+ // const pageSizeOptions = defaultPageSizeOptions.map(size => ({
24
+ // value: size,
25
+ // label: size,
26
+ // }));
27
+
28
28
  var PaginationV2 = function PaginationV2(props) {
29
29
  var _useTranslation = useTranslation(),
30
30
  _useTranslation2 = _slicedToArray(_useTranslation, 1),
31
31
  t = _useTranslation2[0];
32
32
  var showSizeChanger = props.showSizeChanger,
33
33
  curPageDataNum = props.curPageDataNum,
34
+ globalPageSizeOptions = props.pageSizeOptions,
34
35
  rest = _objectWithoutProperties(props, _excluded);
35
36
  var handleChangePageSize = function handleChangePageSize(size) {
36
37
  // console.log('object :>> ', size, rest.current);
37
38
  rest.onChange(rest.current, size);
38
39
  };
40
+ var pageSizeOptions = useMemo(function () {
41
+ return (globalPageSizeOptions !== null && globalPageSizeOptions !== void 0 ? globalPageSizeOptions : defaultPageSizeOptions).map(function (size) {
42
+ return {
43
+ value: size,
44
+ label: size
45
+ };
46
+ });
47
+ }, [globalPageSizeOptions, defaultPageSizeOptions]);
39
48
  return /*#__PURE__*/_jsxs("div", {
40
49
  className: "table-max-pagination-wrapper",
41
50
  children: [/*#__PURE__*/_jsx("div", {
@@ -202,7 +202,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
202
202
  allCount = _getSizeInfo.allCount,
203
203
  columnSizeMap = _getSizeInfo.columnSizeMap;
204
204
  var cache = JSON.parse((_localStorage$getItem = localStorage.getItem(tableKey)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '{}');
205
- var now = Date.now();
205
+ var now = +Date.now();
206
206
  setState(produce(function (prevState) {
207
207
  // 初始化列宽映射
208
208
  var initColumnsSizeMap = _objectSpread({}, columnSizeMap);
@@ -316,6 +316,8 @@ export type TableMaxProps = {
316
316
  hasTotalRow?: boolean;
317
317
  /**总计行数据 { '列id': '数据' }*/
318
318
  totalDatas?: any[];
319
+ /**分页,每页多少条可选值 */
320
+ pageSizeOptions?: number[];
319
321
  };
320
322
  export interface TableMaxColumnType {
321
323
  /**每一列的id是唯一的 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.3.25",
3
+ "version": "2.3.26",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -94,7 +94,7 @@
94
94
  "stylelint": "^14.9.1"
95
95
  },
96
96
  "peerDependencies": {
97
- "antd": "^5.21.0",
97
+ "antd": "^5.27.3",
98
98
  "react": ">=17.0.1",
99
99
  "react-dom": ">=17.0.1",
100
100
  "umi-request": "^1.4.0"