ztxkui 4.2.23 → 4.2.25

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.
@@ -2,6 +2,7 @@ export declare const dataSource: {
2
2
  id: string;
3
3
  test1: string;
4
4
  test2: number;
5
+ test111: number;
5
6
  test3: string;
6
7
  test4: string;
7
8
  test5: string;
@@ -3,6 +3,7 @@ export var dataSource = new Array(9).fill(1).map(function (item, index) {
3
3
  id: "test-" + index,
4
4
  test1: "test1-" + index,
5
5
  test2: index + 100,
6
+ test111: index + 1,
6
7
  test3: "test3-" + index,
7
8
  test4: "test4-" + index,
8
9
  test5: "test5-" + index,
@@ -37,6 +37,7 @@ interface IEditableCellProps {
37
37
  columns: any;
38
38
  onTableChange: any;
39
39
  currentpage: ICurrentPage;
40
+ [prop: string]: any;
40
41
  }
41
42
  declare const TableEnhanceCell: React.FC<IEditableCellProps>;
42
43
  export default TableEnhanceCell;
@@ -86,7 +86,7 @@ function transformData(data, config) {
86
86
  return newData;
87
87
  }
88
88
  var TableEnhanceCell = memo(function (_a) {
89
- var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, onTableChange = _a.onTableChange, columns = _a.columns, currentpage = _a.currentpage, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave", "onTableChange", "columns", "currentpage"]);
89
+ var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, onTableChange = _a.onTableChange, columns = _a.columns, currentpage = _a.currentpage, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave", "onTableChange", "columns", "currentpage", "onMouseEnter", "onMouseLeave"]);
90
90
  var form = useContext(EditableContext);
91
91
  var tdRef = useRef();
92
92
  useEffect(function () {
@@ -27,7 +27,7 @@ var __rest = (this && this.__rest) || function (s, e) {
27
27
  import React from 'react';
28
28
  import { Resizable } from 'react-resizable';
29
29
  var TableResizableTitle = function (props) {
30
- var onResize = props.onResize, width = props.width, restProps = __rest(props, ["onResize", "width"]);
30
+ var onResize = props.onResize, width = props.width, onMouseEnter = props.onMouseEnter, onMouseLeave = props.onMouseLeave, restProps = __rest(props, ["onResize", "width", "onMouseEnter", "onMouseLeave"]);
31
31
  if (!width) {
32
32
  return React.createElement("th", __assign({}, restProps));
33
33
  }
@@ -294,8 +294,14 @@ function Table(props) {
294
294
  },
295
295
  // eslint-disable-next-line react-hooks/exhaustive-deps
296
296
  [onMoveRow]);
297
+ var onRowHandle = useCallback(function (record, index) {
298
+ return ({
299
+ index: index,
300
+ moverow: moveRowHandle,
301
+ });
302
+ }, [moveRowHandle]);
297
303
  /** 伸缩列 */
298
- var handleResize = function (index) {
304
+ var handleResize = useCallback(function (index) {
299
305
  return function (_, _a) {
300
306
  var size = _a.size;
301
307
  var _newColumns = __spreadArray([], (newColumns || []));
@@ -327,24 +333,19 @@ function Table(props) {
327
333
  return __assign({}, item);
328
334
  });
329
335
  if (showColumnDynamicKey) {
330
- // let catchColumnsStr = '{}';
331
- // try {
332
- // catchColumnsStr = JSON.stringify(catchColumns);
333
- // } catch (err) {
334
- // console.log(err);
335
- // }
336
- // localStorage.setItem(showColumnDynamicKey, catchColumnsStr);
337
336
  setDynamicKey(showColumnDynamicKey, catchColumns);
338
337
  }
339
338
  setNewColumns(_newColumns);
340
339
  };
341
- };
342
- var mergeColumns = isResizableColumn
343
- ? (newColumns || []).map(function (col, index) { return (__assign(__assign({}, col), { onHeaderCell: function (column) { return ({
344
- width: column.width,
345
- onResize: handleResize(index),
346
- }); } })); })
347
- : newColumns;
340
+ }, [_columns, dynamicColumns, newColumns, setNewColumns, showColumnDynamicKey]);
341
+ var mergeColumns = useMemo(function () {
342
+ return isResizableColumn
343
+ ? (newColumns || []).map(function (col, index) { return (__assign(__assign({}, col), { onHeaderCell: function (column) { return ({
344
+ width: column.width,
345
+ onResize: handleResize(index),
346
+ }); } })); })
347
+ : newColumns;
348
+ }, [handleResize, isResizableColumn, newColumns]);
348
349
  if (isResizableColumn) {
349
350
  components.header = {
350
351
  cell: TableResizableTitle,
@@ -448,6 +449,63 @@ function Table(props) {
448
449
  },
449
450
  };
450
451
  }, []);
452
+ // 表格合计
453
+ var onSummaryHandle = useCallback(function (pageData) {
454
+ var _a = rowSelectionDataSource.current || {}, isChange = _a.isChange, selectedRowKeys = _a.selectedRowKeys, selectedRows = _a.selectedRows;
455
+ var rowKey = restProps.rowKey;
456
+ var resultDataSoure = typeof rowKey === 'string' && Array.isArray(selectedRowKeys)
457
+ ? pageData.filter(function (item) {
458
+ return selectedRowKeys.find(function (key) { return item[rowKey] === key; });
459
+ })
460
+ : selectedRows;
461
+ var summaryData = getSummaryData(summaryConfig, isChange && Array.isArray(resultDataSoure) && resultDataSoure.length > 0
462
+ ? resultDataSoure
463
+ : pageData, newColumns, {
464
+ hasRowSelection: props.rowSelection ? true : false,
465
+ hasExpandable: props.expandable ? true : false,
466
+ });
467
+ return (React.createElement(AntTable.Summary, { fixed: summaryFixed }, summaryData.map(function (summary) {
468
+ var title = summary.title, key = summary.key, titleIndex = summary.titleIndex, list = summary.list, columnList = summary.columnList, onClickHandle = summary.onClickHandle;
469
+ return (React.createElement(AntTable.Summary.Row, { key: key }, Array.isArray(list) &&
470
+ list.map(function (item, index) {
471
+ var data = {
472
+ index: index,
473
+ column: Array.isArray(columnList)
474
+ ? columnList[index]
475
+ : null,
476
+ num: item,
477
+ };
478
+ if (titleIndex === index) {
479
+ return (React.createElement(AntTable.Summary.Cell, { key: index, index: index }, onClickHandle ? (React.createElement("div", { onClick: function () { return onClickHandle === null || onClickHandle === void 0 ? void 0 : onClickHandle(data); } }, title)) : (title)));
480
+ }
481
+ else {
482
+ return (React.createElement(AntTable.Summary.Cell, { key: index, index: index },
483
+ React.createElement("div", { style: {
484
+ color: '#333',
485
+ }, onClick: function () {
486
+ return onClickHandle && (onClickHandle === null || onClickHandle === void 0 ? void 0 : onClickHandle(data));
487
+ } }, item)));
488
+ }
489
+ })));
490
+ })));
491
+ }, [
492
+ newColumns,
493
+ props === null || props === void 0 ? void 0 : props.expandable,
494
+ props === null || props === void 0 ? void 0 : props.rowSelection,
495
+ restProps === null || restProps === void 0 ? void 0 : restProps.rowKey,
496
+ summaryConfig,
497
+ summaryFixed,
498
+ ]);
499
+ // 多选
500
+ var rowSelectionObj = useMemo(function () { return (__assign(__assign({}, rowSelection), { onChange: function (selectedRowKeys, selectedRows) {
501
+ rowSelectionDataSource.current = {
502
+ selectedRows: selectedRows,
503
+ selectedRowKeys: selectedRowKeys,
504
+ isChange: true,
505
+ };
506
+ (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) &&
507
+ rowSelection.onChange(selectedRowKeys, selectedRows);
508
+ } })); }, [rowSelection]);
451
509
  return (React.createElement("div", { style: isFlex
452
510
  ? { position: 'relative', overflow: 'hidden', flex: 1 }
453
511
  : { position: 'relative', overflow: 'hidden' }, ref: tableRef },
@@ -460,65 +518,7 @@ function Table(props) {
460
518
  ? components
461
519
  : isResizableColumn
462
520
  ? tableResizableTitle
463
- : undefined, onRow: onMoveRow
464
- ? function (record, index) {
465
- return ({
466
- index: index,
467
- moverow: moveRowHandle,
468
- });
469
- }
470
- : undefined, summary: summaryConfig
471
- ? function (pageData) {
472
- var _a = rowSelectionDataSource.current || {}, isChange = _a.isChange, selectedRowKeys = _a.selectedRowKeys, selectedRows = _a.selectedRows;
473
- var rowKey = restProps.rowKey;
474
- var resultDataSoure = typeof rowKey === 'string' && Array.isArray(selectedRowKeys)
475
- ? pageData.filter(function (item) {
476
- return selectedRowKeys.find(function (key) { return item[rowKey] === key; });
477
- })
478
- : selectedRows;
479
- var summaryData = getSummaryData(summaryConfig, isChange &&
480
- Array.isArray(resultDataSoure) &&
481
- resultDataSoure.length > 0
482
- ? resultDataSoure
483
- : pageData, newColumns, {
484
- hasRowSelection: props.rowSelection ? true : false,
485
- hasExpandable: props.expandable ? true : false,
486
- });
487
- return (React.createElement(AntTable.Summary, { fixed: summaryFixed }, summaryData.map(function (summary) {
488
- var title = summary.title, key = summary.key, titleIndex = summary.titleIndex, list = summary.list, columnList = summary.columnList, onClickHandle = summary.onClickHandle;
489
- return (React.createElement(AntTable.Summary.Row, { key: key }, Array.isArray(list) &&
490
- list.map(function (item, index) {
491
- var data = {
492
- index: index,
493
- column: Array.isArray(columnList)
494
- ? columnList[index]
495
- : null,
496
- num: item,
497
- };
498
- if (titleIndex === index) {
499
- return (React.createElement(AntTable.Summary.Cell, { key: index, index: index }, onClickHandle ? (React.createElement("div", { onClick: function () { return onClickHandle === null || onClickHandle === void 0 ? void 0 : onClickHandle(data); } }, title)) : (title)));
500
- }
501
- else {
502
- return (React.createElement(AntTable.Summary.Cell, { key: index, index: index },
503
- React.createElement("div", { style: {
504
- color: '#333',
505
- }, onClick: function () {
506
- return onClickHandle && (onClickHandle === null || onClickHandle === void 0 ? void 0 : onClickHandle(data));
507
- } }, item)));
508
- }
509
- })));
510
- })));
511
- }
512
- : summary, rowSelection: rowSelection
513
- ? __assign(__assign({}, rowSelection), { onChange: function (selectedRowKeys, selectedRows) {
514
- rowSelectionDataSource.current = {
515
- selectedRows: selectedRows,
516
- selectedRowKeys: selectedRowKeys,
517
- isChange: true,
518
- };
519
- rowSelection.onChange &&
520
- rowSelection.onChange(selectedRowKeys, selectedRows);
521
- } }) : rowSelection }, restProps)),
521
+ : undefined, onRow: onMoveRow ? onRowHandle : undefined, summary: summaryConfig ? onSummaryHandle : summary, rowSelection: rowSelection ? rowSelectionObj : rowSelection }, restProps)),
522
522
  showColumnDynamic && (React.createElement(TableDynamic, { visible: dynamicVisible, onClose: hideDynamicHandle, onSave: saveDynamicHandle, onReset: resetDynamicHandle, columns: dynamicColumns })))));
523
523
  }
524
524
  export default memo(Table);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "4.2.23",
3
+ "version": "4.2.25",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",