ztxkui 4.2.23-2 → 4.2.23-21

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.
Files changed (86) hide show
  1. package/dist/DemoCom/PrintContainerDemo.js +223 -70
  2. package/dist/TableDemo/data.js +1 -1
  3. package/dist/UI/Basic/index.d.ts +2 -0
  4. package/dist/UI/Basic/index.js +18 -0
  5. package/dist/UI/Form/index.d.ts +3 -0
  6. package/dist/UI/Form/index.js +187 -0
  7. package/dist/UI/Modal/hooks.d.ts +15 -0
  8. package/dist/UI/Modal/hooks.js +172 -0
  9. package/dist/UI/Modal/index.d.ts +3 -0
  10. package/dist/UI/Modal/index.js +46 -0
  11. package/dist/UI/Table/DefaultTable.d.ts +2 -0
  12. package/dist/UI/Table/DefaultTable.js +49 -0
  13. package/dist/UI/Table/EditTable.d.ts +2 -0
  14. package/dist/UI/Table/EditTable.js +259 -0
  15. package/dist/UI/Table/data.d.ts +10 -0
  16. package/dist/UI/Table/data.js +14 -0
  17. package/dist/UI/Table/index.d.ts +2 -0
  18. package/dist/UI/Table/index.js +5 -0
  19. package/dist/UI/index.d.ts +2 -0
  20. package/dist/UI/index.js +26 -0
  21. package/dist/components/EnhanceSelect/index.js +4 -0
  22. package/dist/components/Input/input.js +38 -13
  23. package/dist/components/PrintContainer/print-container.js +70 -30
  24. package/dist/components/ProForm/hooks.d.ts +23 -0
  25. package/dist/components/ProForm/hooks.js +209 -0
  26. package/dist/components/ProForm/index.d.ts +6 -0
  27. package/dist/components/ProForm/index.js +87 -0
  28. package/dist/components/ProForm/interface.d.ts +116 -0
  29. package/dist/components/ProForm/interface.js +1 -0
  30. package/dist/components/ProForm/items.d.ts +5 -0
  31. package/dist/components/ProForm/items.js +136 -0
  32. package/dist/components/ProForm/search-drawer.d.ts +11 -0
  33. package/dist/components/ProForm/search-drawer.js +76 -0
  34. package/dist/components/ProForm/setting.d.ts +5 -0
  35. package/dist/components/ProForm/setting.js +13 -0
  36. package/dist/components/ProFormList/index.d.ts +12 -0
  37. package/dist/components/ProFormList/index.js +34 -0
  38. package/dist/components/ProModal/ModalForm.d.ts +8 -0
  39. package/dist/components/ProModal/ModalForm.js +32 -0
  40. package/dist/components/ProModal/ModalTable.d.ts +8 -0
  41. package/dist/components/ProModal/ModalTable.js +32 -0
  42. package/dist/components/ProModal/hooks.d.ts +33 -0
  43. package/dist/components/ProModal/hooks.js +193 -0
  44. package/dist/components/ProModal/index.d.ts +17 -0
  45. package/dist/components/ProModal/index.js +80 -0
  46. package/dist/components/ProModal/interface.d.ts +47 -0
  47. package/dist/components/ProModal/interface.js +1 -0
  48. package/dist/components/ProTable/hooks.d.ts +28 -0
  49. package/dist/components/ProTable/hooks.js +272 -0
  50. package/dist/components/ProTable/index.d.ts +8 -0
  51. package/dist/components/ProTable/index.js +76 -0
  52. package/dist/components/ProTable/interface.d.ts +51 -0
  53. package/dist/components/ProTable/interface.js +1 -0
  54. package/dist/components/Table/hooks/useColumns.d.ts +4 -4
  55. package/dist/components/Table/hooks/useColumns.js +227 -169
  56. package/dist/components/Table/hooks/useInnerPagination.js +1 -0
  57. package/dist/components/Table/table-adddel-column.d.ts +2 -1
  58. package/dist/components/Table/table-adddel-column.js +5 -3
  59. package/dist/components/Table/table-enhance-cell.d.ts +6 -3
  60. package/dist/components/Table/table-enhance-cell.js +119 -110
  61. package/dist/components/Table/table-enhance-row.d.ts +3 -4
  62. package/dist/components/Table/table-enhance-row.js +6 -10
  63. package/dist/components/Table/table-resizable-title.d.ts +4 -5
  64. package/dist/components/Table/table-resizable-title.js +31 -6
  65. package/dist/components/Table/table.d.ts +2 -0
  66. package/dist/components/Table/table.js +154 -150
  67. package/dist/components/Table/utils/shallowEqual.d.ts +2 -0
  68. package/dist/components/Table/utils/shallowEqual.js +34 -0
  69. package/dist/components/Table/utils/validate.js +0 -3
  70. package/dist/components/Tabs/DraggableTabNode.d.ts +7 -0
  71. package/dist/components/Tabs/DraggableTabNode.js +33 -0
  72. package/dist/components/Tabs/hooks.d.ts +3 -0
  73. package/dist/components/Tabs/hooks.js +59 -0
  74. package/dist/components/Tabs/tabs.d.ts +3 -0
  75. package/dist/components/Tabs/tabs.js +8 -2
  76. package/dist/components/business/Footer/index.d.ts +1 -0
  77. package/dist/components/business/Footer/index.js +18 -4
  78. package/dist/components/business/Signatures/components/QunjSeal.js +3 -2
  79. package/dist/components/business/Signatures/index.js +13 -14
  80. package/dist/constants.d.ts +1 -1
  81. package/dist/constants.js +1 -1
  82. package/dist/index.css +327 -0
  83. package/dist/index.css.map +1 -1
  84. package/dist/index.d.ts +4 -0
  85. package/dist/index.js +9 -1
  86. package/package.json +4 -4
@@ -62,6 +62,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
62
62
  return to;
63
63
  };
64
64
  import React, { useCallback, memo, useState, useEffect, useRef, useMemo, useImperativeHandle, } from 'react';
65
+ import { unstable_batchedUpdates } from 'react-dom';
65
66
  import { Table as AntTable } from 'antd';
66
67
  import { message } from '../../index';
67
68
  import { ERROR_TD_CLASSNAME } from './';
@@ -74,6 +75,7 @@ import useColumns, { setDynamicKey } from './hooks/useColumns';
74
75
  import getSummaryData from './utils/getSummaryData';
75
76
  import { domFind } from './utils/dom';
76
77
  import { tableValidate } from './utils/validate';
78
+ // import { shallowEqual } from './utils/shallowEqual';
77
79
  import classNames from 'classnames';
78
80
  import { HTML5Backend } from 'react-dnd-html5-backend';
79
81
  import { DndProvider } from 'react-dnd';
@@ -104,18 +106,16 @@ var components = {
104
106
  */
105
107
  function Table(props) {
106
108
  var _this = this;
107
- var className = props.className, scroll = props.scroll, _a = props.pagination, pagination = _a === void 0 ? false : _a, _b = props.bordered, bordered = _b === void 0 ? true : _b, columns = props.columns, initColumns = props.initColumns, dataSource = props.dataSource, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, showDelAllBtn = props.showDelAllBtn, delAllChange = props.delAllChange, delIconText = props.delIconText, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, summaryConfig = props.summaryConfig, summaryFixed = props.summaryFixed, summary = props.summary, onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave, onDynamicChange = props.onDynamicChange, _c = props.isResizableColumn, isResizableColumn = _c === void 0 ? true : _c, configInfo = props.configInfo, tableHandleRef = props.tableHandleRef, tableName = props.tableName, isFlex = props.isFlex, onTableChange = props.onTableChange, rowSelection = props.rowSelection, showInnerPagination = props.showInnerPagination, defaultInnerPageSize = props.defaultInnerPageSize, restProps = __rest(props, ["className", "scroll", "pagination", "bordered", "columns", "initColumns", "dataSource", "onAddAndDelHandle", "hideAddIcon", "addIconText", "hideDelIcon", "showDelAllBtn", "delAllChange", "delIconText", "showColumnDynamic", "showColumnDynamicKey", "summaryConfig", "summaryFixed", "summary", "onMoveRow", "onEditableSave", "onDynamicChange", "isResizableColumn", "configInfo", "tableHandleRef", "tableName", "isFlex", "onTableChange", "rowSelection", "showInnerPagination", "defaultInnerPageSize"]);
108
- // console.log('table render');
109
+ var className = props.className, scroll = props.scroll, _a = props.pagination, pagination = _a === void 0 ? false : _a, _b = props.bordered, bordered = _b === void 0 ? true : _b, _columns = props.columns, initColumns = props.initColumns, dataSource = props.dataSource, onAddAndDelHandle = props.onAddAndDelHandle, hideAddIcon = props.hideAddIcon, addIconText = props.addIconText, hideDelIcon = props.hideDelIcon, showDelAllBtn = props.showDelAllBtn, delAllChange = props.delAllChange, delIconText = props.delIconText, hiddenColumnDynamicIcon = props.hiddenColumnDynamicIcon, showColumnDynamic = props.showColumnDynamic, showColumnDynamicKey = props.showColumnDynamicKey, summaryConfig = props.summaryConfig, summaryFixed = props.summaryFixed, summary = props.summary, onMoveRow = props.onMoveRow, onEditableSave = props.onEditableSave, onDynamicChange = props.onDynamicChange, _c = props.isResizableColumn, isResizableColumn = _c === void 0 ? true : _c, configInfo = props.configInfo, tableHandleRef = props.tableHandleRef, tableName = props.tableName, isFlex = props.isFlex, onTableChange = props.onTableChange, rowSelection = props.rowSelection, showInnerPagination = props.showInnerPagination, defaultInnerPageSize = props.defaultInnerPageSize, restProps = __rest(props, ["className", "scroll", "pagination", "bordered", "columns", "initColumns", "dataSource", "onAddAndDelHandle", "hideAddIcon", "addIconText", "hideDelIcon", "showDelAllBtn", "delAllChange", "delIconText", "hiddenColumnDynamicIcon", "showColumnDynamic", "showColumnDynamicKey", "summaryConfig", "summaryFixed", "summary", "onMoveRow", "onEditableSave", "onDynamicChange", "isResizableColumn", "configInfo", "tableHandleRef", "tableName", "isFlex", "onTableChange", "rowSelection", "showInnerPagination", "defaultInnerPageSize"]);
109
110
  var classes = classNames('zt-table', className, {
110
111
  'zt-table--flex': isFlex,
111
112
  });
112
113
  var _d = useState(false), dynamicVisible = _d[0], setDynamicVisible = _d[1];
113
- var _e = useState(columns), _columns = _e[0], setColumns = _e[1];
114
114
  var showDynamicHandle = useCallback(function () { return setDynamicVisible(true); }, []);
115
115
  var hideDynamicHandle = useCallback(function () { return setDynamicVisible(false); }, []);
116
116
  var dataSourceRef = useRef();
117
117
  // 内部分页相关配置
118
- var _f = useInnerPagination(showInnerPagination, defaultInnerPageSize), paginationConfig = _f.paginationConfig, currentPage = _f.currentPage, setCurrent = _f.setCurrent, pageSize = _f.pageSize;
118
+ var _e = useInnerPagination(showInnerPagination, defaultInnerPageSize), paginationConfig = _e.paginationConfig, currentPage = _e.currentPage, setCurrent = _e.setCurrent, pageSize = _e.pageSize;
119
119
  var rowSelectionDataSource = useRef({});
120
120
  var myScroll = useMemo(function () {
121
121
  if (scroll) {
@@ -124,9 +124,6 @@ function Table(props) {
124
124
  return isFlex ? __assign(__assign({}, _scroll), { y: 100 }) : _scroll;
125
125
  }, [scroll, isFlex]);
126
126
  /**columns更新,重新设置columns */
127
- useEffect(function () {
128
- setColumns(columns);
129
- }, [columns]);
130
127
  useEffect(function () {
131
128
  dataSourceRef.current = dataSource;
132
129
  }, [dataSource]);
@@ -161,12 +158,52 @@ function Table(props) {
161
158
  }
162
159
  }
163
160
  }, []);
161
+ var tableRef = useRef();
162
+ var getCurrentTable = useCallback(function () {
163
+ var _a;
164
+ var tableContent = domFind(tableRef.current, '.ant-table-content');
165
+ if (!tableContent) {
166
+ tableContent = domFind(tableRef.current, '.ant-table-container');
167
+ }
168
+ var tableBody = domFind(tableContent, '.ant-table-tbody');
169
+ var tr = tableBody === null || tableBody === void 0 ? void 0 : tableBody.children;
170
+ var arrTr = Array.prototype.slice.call(tr);
171
+ var resultTr = ((_a = arrTr === null || arrTr === void 0 ? void 0 : arrTr.filter) === null || _a === void 0 ? void 0 : _a.call(arrTr, function (item) { return item.className.includes('ant-table-row'); })) || [];
172
+ return { tableBody: tableBody, resultTr: resultTr };
173
+ }, []);
174
+ var clearErrorClass = useCallback(function (index) {
175
+ try {
176
+ var resultTr = getCurrentTable().resultTr;
177
+ if (typeof index === 'number') {
178
+ var tds = resultTr[index].querySelectorAll('td');
179
+ for (var i = 0; i < tds.length; i++) {
180
+ tds[i].classList.remove(ERROR_TD_CLASSNAME);
181
+ }
182
+ }
183
+ else {
184
+ for (var i = 0; i < resultTr.length; i++) {
185
+ var tds = resultTr[i].querySelectorAll('td');
186
+ for (var j = 0; j < tds.length; j++) {
187
+ tds[j].classList.remove(ERROR_TD_CLASSNAME);
188
+ }
189
+ }
190
+ }
191
+ }
192
+ catch (err) {
193
+ console.log(err);
194
+ }
195
+ }, [getCurrentTable]);
196
+ var onTableChangeHandle = useCallback(function (resultTextList, startIndex) {
197
+ clearErrorClass();
198
+ onTableChange && onTableChange(resultTextList, startIndex);
199
+ }, [clearErrorClass, onTableChange]);
164
200
  /**
165
201
  * @description 根据配置生成一个新的columns
166
202
  * 以及一个需要动态列配置的columns
167
203
  */
168
- var _g = useColumns({
204
+ var _f = useColumns({
169
205
  columns: _columns,
206
+ hiddenColumnDynamicIcon: hiddenColumnDynamicIcon,
170
207
  showColumnDynamic: showColumnDynamic,
171
208
  showColumnDynamicKey: showColumnDynamicKey,
172
209
  onAddAndDelHandle: onAddAndDelHandle,
@@ -180,14 +217,9 @@ function Table(props) {
180
217
  onEditableSave: onEditableSave,
181
218
  configInfo: configInfo,
182
219
  copyByKey: copyByKey,
183
- onTableChange: onTableChange
184
- ? function (resultTextList, startIndex) {
185
- clearErrorClass();
186
- onTableChange && onTableChange(resultTextList, startIndex);
187
- }
188
- : undefined,
220
+ onTableChange: onTableChange ? onTableChangeHandle : undefined,
189
221
  currentPage: currentPage,
190
- }), newColumns = _g.newColumns, dynamicColumns = _g.dynamicColumns, setNewColumns = _g.setNewColumns;
222
+ }), newColumns = _f.newColumns, dynamicColumns = _f.dynamicColumns, refreshColumnsHandle = _f.refreshColumnsHandle;
191
223
  /**
192
224
  * @description 保存列配置
193
225
  */
@@ -213,7 +245,6 @@ function Table(props) {
213
245
  return column && column.width
214
246
  ? __assign(__assign({}, item), { width: column.width }) : item;
215
247
  });
216
- setColumns(_newColumns);
217
248
  var catchColumns = _newColumns.map(function (item) {
218
249
  if (item.dataIndex || item.key) {
219
250
  return {
@@ -226,24 +257,23 @@ function Table(props) {
226
257
  return __assign({}, item);
227
258
  });
228
259
  if (showColumnDynamicKey) {
229
- // let catchColumnsStr = '{}';
230
- // try {
231
- // catchColumnsStr = JSON.stringify(catchColumns);
232
- // } catch (err) {
233
- // console.log(err);
234
- // }
235
- // localStorage.setItem(showColumnDynamicKey, catchColumnsStr);
236
260
  setDynamicKey(showColumnDynamicKey, catchColumns);
237
261
  }
262
+ refreshColumnsHandle();
238
263
  onDynamicChange && onDynamicChange(catchColumns);
239
264
  }
240
- }, [_columns, newColumns, onDynamicChange, showColumnDynamicKey]);
265
+ }, [
266
+ _columns,
267
+ newColumns,
268
+ onDynamicChange,
269
+ showColumnDynamicKey,
270
+ refreshColumnsHandle,
271
+ ]);
241
272
  /**
242
273
  * @description 动态列配置重置功能
243
274
  */
244
275
  var resetDynamicHandle = useCallback(function () {
245
- var _initColumns = initColumns || columns || [];
246
- setColumns(__spreadArray([], _initColumns));
276
+ var _initColumns = initColumns || _columns || [];
247
277
  var catchColumns = (_initColumns || []).map(function (item) {
248
278
  if (item.dataIndex || item.key) {
249
279
  return {
@@ -256,23 +286,18 @@ function Table(props) {
256
286
  return __assign({}, item);
257
287
  });
258
288
  if (showColumnDynamicKey) {
259
- // let catchColumnsStr = '{}';
260
- // try {
261
- // catchColumnsStr = JSON.stringify(catchColumns);
262
- // } catch (err) {
263
- // console.log(err);
264
- // }
265
- // localStorage.setItem(showColumnDynamicKey, catchColumnsStr);
266
289
  setDynamicKey(showColumnDynamicKey, catchColumns);
267
290
  }
291
+ refreshColumnsHandle();
268
292
  onDynamicChange && onDynamicChange(catchColumns);
269
293
  hideDynamicHandle();
270
294
  }, [
271
295
  initColumns,
272
- columns,
296
+ _columns,
273
297
  hideDynamicHandle,
274
298
  onDynamicChange,
275
299
  showColumnDynamicKey,
300
+ refreshColumnsHandle,
276
301
  ]);
277
302
  /**
278
303
  * @description 切换行位置
@@ -280,7 +305,12 @@ function Table(props) {
280
305
  var moveRowHandle = useCallback(function (dragIndex, hoverIndex) {
281
306
  var innerDragIndex = getInnerIndex(currentPage, dragIndex);
282
307
  var innerHoverIndex = getInnerIndex(currentPage, hoverIndex);
283
- onMoveRow && onMoveRow(innerDragIndex, innerHoverIndex);
308
+ if (innerDragIndex === innerHoverIndex) {
309
+ return;
310
+ }
311
+ unstable_batchedUpdates(function () {
312
+ onMoveRow && onMoveRow(innerDragIndex, innerHoverIndex);
313
+ });
284
314
  // if (dataSource) {
285
315
  // const dragRow = dataSource[dragIndex];
286
316
  // const newDataSource = update(dataSource, {
@@ -291,11 +321,15 @@ function Table(props) {
291
321
  // });
292
322
  // onMoveRow && onMoveRow(newDataSource);
293
323
  // }
294
- },
295
- // eslint-disable-next-line react-hooks/exhaustive-deps
296
- [onMoveRow]);
324
+ }, [currentPage, onMoveRow]);
325
+ var onRowHandle = useCallback(function (record, index) {
326
+ return ({
327
+ index: index,
328
+ moverow: moveRowHandle,
329
+ });
330
+ }, [moveRowHandle]);
297
331
  /** 伸缩列 */
298
- var handleResize = function (index) {
332
+ var handleResize = useCallback(function (index) {
299
333
  return function (_, _a) {
300
334
  var size = _a.size;
301
335
  var _newColumns = __spreadArray([], (newColumns || []));
@@ -327,24 +361,28 @@ function Table(props) {
327
361
  return __assign({}, item);
328
362
  });
329
363
  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
364
  setDynamicKey(showColumnDynamicKey, catchColumns);
365
+ refreshColumnsHandle();
366
+ }
367
+ else {
368
+ refreshColumnsHandle(catchColumns);
338
369
  }
339
- setNewColumns(_newColumns);
340
370
  };
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;
371
+ }, [
372
+ _columns,
373
+ dynamicColumns,
374
+ newColumns,
375
+ refreshColumnsHandle,
376
+ showColumnDynamicKey,
377
+ ]);
378
+ var mergeColumns = useMemo(function () {
379
+ return isResizableColumn
380
+ ? (newColumns || []).map(function (col, index) { return (__assign(__assign({}, col), { onHeaderCell: function (column) { return ({
381
+ width: column.width,
382
+ onResize: handleResize(index),
383
+ }); } })); })
384
+ : newColumns;
385
+ }, [handleResize, isResizableColumn, newColumns]);
348
386
  if (isResizableColumn) {
349
387
  components.header = {
350
388
  cell: TableResizableTitle,
@@ -353,42 +391,6 @@ function Table(props) {
353
391
  /**
354
392
  * 表格暴露方法给外部使用
355
393
  */
356
- var tableRef = useRef();
357
- function getCurrentTable() {
358
- var _a;
359
- // 获取表格元素
360
- var tableContent = domFind(tableRef.current, '.ant-table-content');
361
- if (!tableContent) {
362
- tableContent = domFind(tableRef.current, '.ant-table-container');
363
- }
364
- var tableBody = domFind(tableContent, '.ant-table-tbody');
365
- var tr = tableBody === null || tableBody === void 0 ? void 0 : tableBody.children;
366
- var arrTr = Array.prototype.slice.call(tr);
367
- var resultTr = ((_a = arrTr === null || arrTr === void 0 ? void 0 : arrTr.filter) === null || _a === void 0 ? void 0 : _a.call(arrTr, function (item) { return item.className.includes('ant-table-row'); })) || [];
368
- return { tableBody: tableBody, resultTr: resultTr };
369
- }
370
- function clearErrorClass(index) {
371
- try {
372
- var resultTr = getCurrentTable().resultTr;
373
- if (typeof index === 'number') {
374
- var tds = resultTr[index].querySelectorAll('td');
375
- for (var i = 0; i < tds.length; i++) {
376
- tds[i].classList.remove(ERROR_TD_CLASSNAME);
377
- }
378
- }
379
- else {
380
- for (var i = 0; i < resultTr.length; i++) {
381
- var tds = resultTr[i].querySelectorAll('td');
382
- for (var j = 0; j < tds.length; j++) {
383
- tds[j].classList.remove(ERROR_TD_CLASSNAME);
384
- }
385
- }
386
- }
387
- }
388
- catch (err) {
389
- console.log(err);
390
- }
391
- }
392
394
  useImperativeHandle(tableHandleRef, function () { return ({
393
395
  /** 错误提示 */
394
396
  validate: function () { return __awaiter(_this, void 0, void 0, function () {
@@ -448,6 +450,63 @@ function Table(props) {
448
450
  },
449
451
  };
450
452
  }, []);
453
+ // 表格合计
454
+ var onSummaryHandle = useCallback(function (pageData) {
455
+ var _a = rowSelectionDataSource.current || {}, isChange = _a.isChange, selectedRowKeys = _a.selectedRowKeys, selectedRows = _a.selectedRows;
456
+ var rowKey = restProps.rowKey;
457
+ var resultDataSoure = typeof rowKey === 'string' && Array.isArray(selectedRowKeys)
458
+ ? pageData.filter(function (item) {
459
+ return selectedRowKeys.find(function (key) { return item[rowKey] === key; });
460
+ })
461
+ : selectedRows;
462
+ var summaryData = getSummaryData(summaryConfig, isChange && Array.isArray(resultDataSoure) && resultDataSoure.length > 0
463
+ ? resultDataSoure
464
+ : pageData, newColumns, {
465
+ hasRowSelection: props.rowSelection ? true : false,
466
+ hasExpandable: props.expandable ? true : false,
467
+ });
468
+ return (React.createElement(AntTable.Summary, { fixed: summaryFixed }, summaryData.map(function (summary) {
469
+ var title = summary.title, key = summary.key, titleIndex = summary.titleIndex, list = summary.list, columnList = summary.columnList, onClickHandle = summary.onClickHandle;
470
+ return (React.createElement(AntTable.Summary.Row, { key: key }, Array.isArray(list) &&
471
+ list.map(function (item, index) {
472
+ var data = {
473
+ index: index,
474
+ column: Array.isArray(columnList)
475
+ ? columnList[index]
476
+ : null,
477
+ num: item,
478
+ };
479
+ if (titleIndex === index) {
480
+ 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)));
481
+ }
482
+ else {
483
+ return (React.createElement(AntTable.Summary.Cell, { key: index, index: index },
484
+ React.createElement("div", { style: {
485
+ color: '#333',
486
+ }, onClick: function () {
487
+ return onClickHandle && (onClickHandle === null || onClickHandle === void 0 ? void 0 : onClickHandle(data));
488
+ } }, item)));
489
+ }
490
+ })));
491
+ })));
492
+ }, [
493
+ newColumns,
494
+ props === null || props === void 0 ? void 0 : props.expandable,
495
+ props === null || props === void 0 ? void 0 : props.rowSelection,
496
+ restProps === null || restProps === void 0 ? void 0 : restProps.rowKey,
497
+ summaryConfig,
498
+ summaryFixed,
499
+ ]);
500
+ // 多选
501
+ var rowSelectionObj = useMemo(function () { return (__assign(__assign({}, rowSelection), { onChange: function (selectedRowKeys, selectedRows) {
502
+ rowSelectionDataSource.current = {
503
+ selectedRows: selectedRows,
504
+ selectedRowKeys: selectedRowKeys,
505
+ isChange: true,
506
+ };
507
+ (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) &&
508
+ rowSelection.onChange(selectedRowKeys, selectedRows);
509
+ } })); }, [rowSelection]);
451
510
  return (React.createElement("div", { style: isFlex
452
511
  ? { position: 'relative', overflow: 'hidden', flex: 1 }
453
512
  : { position: 'relative', overflow: 'hidden' }, ref: tableRef },
@@ -460,65 +519,10 @@ function Table(props) {
460
519
  ? components
461
520
  : isResizableColumn
462
521
  ? 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)),
522
- showColumnDynamic && (React.createElement(TableDynamic, { visible: dynamicVisible, onClose: hideDynamicHandle, onSave: saveDynamicHandle, onReset: resetDynamicHandle, columns: dynamicColumns })))));
522
+ : undefined, onRow: onMoveRow ? onRowHandle : undefined, summary: summaryConfig ? onSummaryHandle : summary, rowSelection: rowSelection ? rowSelectionObj : rowSelection }, restProps)),
523
+ showColumnDynamic && dynamicVisible && (React.createElement(TableDynamic, { visible: dynamicVisible, onClose: hideDynamicHandle, onSave: saveDynamicHandle, onReset: resetDynamicHandle, columns: dynamicColumns })))));
523
524
  }
525
+ // export default memo(Table, (prevProps, nextProps) => {
526
+ // return shallowEqual(prevProps, nextProps);
527
+ // });
524
528
  export default memo(Table);
@@ -0,0 +1,2 @@
1
+ export declare function is(x: any, y: any): boolean;
2
+ export declare function shallowEqual(objA: any, objB: any, deepKeys?: string[]): boolean;
@@ -0,0 +1,34 @@
1
+ import isEqual from 'lodash/isEqual';
2
+ export function is(x, y) {
3
+ return ((x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare
4
+ );
5
+ }
6
+ export function shallowEqual(objA, objB, deepKeys) {
7
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
8
+ if (is(objA, objB)) {
9
+ return true;
10
+ }
11
+ if (typeof objA !== 'object' ||
12
+ objA === null ||
13
+ typeof objB !== 'object' ||
14
+ objB === null) {
15
+ return false;
16
+ }
17
+ var keysA = Object.keys(objA);
18
+ var keysB = Object.keys(objB);
19
+ if (keysA.length !== keysB.length) {
20
+ return false;
21
+ }
22
+ // Test for A's keys different from B.
23
+ for (var i = 0; i < keysA.length; i++) {
24
+ var key = keysA[i];
25
+ if ((deepKeys === null || deepKeys === void 0 ? void 0 : deepKeys.includes(key)) && !isEqual(objA[key], objB[key])) {
26
+ return false;
27
+ }
28
+ else if (!hasOwnProperty.call(objB, key) || !is(objA[key], objB[key])) {
29
+ console.log('因为某个key渲染', key, objA[key], objB[key]);
30
+ return false;
31
+ }
32
+ }
33
+ return true;
34
+ }
@@ -83,9 +83,6 @@ export function tableValidate(dataSource, mergeColumns, restParams) {
83
83
  return [2 /*return*/, "break"];
84
84
  }
85
85
  value = item[dataIndex];
86
- if (dataIndex === 'test3') {
87
- console.log(value);
88
- }
89
86
  setElementState = function (i, index, className) {
90
87
  var _a, _b, _c;
91
88
  // 获取表格元素
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface DraggableTabPaneProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ index: React.Key;
4
+ moveNode: (dragIndex: React.Key, hoverIndex: React.Key) => void;
5
+ }
6
+ declare const DraggableTabNode: ({ index, children, moveNode, }: DraggableTabPaneProps) => JSX.Element;
7
+ export default DraggableTabNode;
@@ -0,0 +1,33 @@
1
+ import React, { useRef } from 'react';
2
+ import { useDrag, useDrop } from 'react-dnd';
3
+ var type = 'DraggableTabNode';
4
+ var DraggableTabNode = function (_a) {
5
+ var index = _a.index, children = _a.children, moveNode = _a.moveNode;
6
+ var ref = useRef(null);
7
+ var _b = useDrop({
8
+ accept: type,
9
+ collect: function (monitor) {
10
+ var dragIndex = (monitor.getItem() || {}).index;
11
+ if (dragIndex === index) {
12
+ return {};
13
+ }
14
+ return {
15
+ isOver: monitor.isOver(),
16
+ dropClassName: 'dropping',
17
+ };
18
+ },
19
+ drop: function (item) {
20
+ moveNode(item.index, index);
21
+ },
22
+ }), _c = _b[0], isOver = _c.isOver, dropClassName = _c.dropClassName, drop = _b[1];
23
+ var _d = useDrag({
24
+ type: type,
25
+ item: { index: index },
26
+ collect: function (monitor) { return ({
27
+ isDragging: monitor.isDragging(),
28
+ }); },
29
+ }), drag = _d[1];
30
+ drop(drag(ref));
31
+ return (React.createElement("div", { ref: ref, style: { marginRight: 2 }, className: isOver ? dropClassName : '' }, children));
32
+ };
33
+ export default DraggableTabNode;
@@ -0,0 +1,3 @@
1
+ export declare function useMoveTabNode(panes: any, onMoveChange: any): {
2
+ renderTabBar: import("rc-tabs/lib/interface").RenderTabBar;
3
+ };
@@ -0,0 +1,59 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
13
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
14
+ to[j] = from[i];
15
+ return to;
16
+ };
17
+ import React, { useState } from 'react';
18
+ import DraggableTabNode from './DraggableTabNode';
19
+ function createNewPanes(panes, order) {
20
+ var newPanes = __spreadArray([], panes).sort(function (a, b) {
21
+ var orderA = order.indexOf(a.key);
22
+ var orderB = order.indexOf(b.key);
23
+ if (orderA !== -1 && orderB !== -1) {
24
+ return orderA - orderB;
25
+ }
26
+ if (orderA !== -1) {
27
+ return -1;
28
+ }
29
+ if (orderB !== -1) {
30
+ return 1;
31
+ }
32
+ var ia = panes.indexOf(a);
33
+ var ib = panes.indexOf(b);
34
+ return ia - ib;
35
+ });
36
+ return newPanes;
37
+ }
38
+ export function useMoveTabNode(panes, onMoveChange) {
39
+ var _a = useState([]), order = _a[0], setOrder = _a[1];
40
+ var moveTabNode = function (dragKey, hoverKey) {
41
+ var newOrder = order.slice();
42
+ panes.forEach(function (item) {
43
+ if (item.key && newOrder.indexOf(item.key) === -1) {
44
+ newOrder.push(item.key);
45
+ }
46
+ });
47
+ var dragIndex = newOrder.indexOf(dragKey);
48
+ var hoverIndex = newOrder.indexOf(hoverKey);
49
+ newOrder.splice(dragIndex, 1);
50
+ newOrder.splice(hoverIndex, 0, dragKey);
51
+ setOrder(newOrder);
52
+ var newPanes = createNewPanes(panes, newOrder);
53
+ onMoveChange && onMoveChange(newPanes);
54
+ };
55
+ var renderTabBar = function (tabBarProps, DefaultTabBar) { return (React.createElement(DefaultTabBar, __assign({}, tabBarProps), function (node) { return (React.createElement(DraggableTabNode, { key: node.key, index: node.key, moveNode: moveTabNode }, node)); })); };
56
+ return {
57
+ renderTabBar: renderTabBar,
58
+ };
59
+ }
@@ -5,6 +5,9 @@ interface IProps extends TabsProps {
5
5
  isContent?: boolean;
6
6
  marginTop?: boolean;
7
7
  marginBottom?: boolean;
8
+ isMove?: boolean;
9
+ panes?: any[];
10
+ onMoveChange?: any;
8
11
  }
9
12
  declare function Tabs(props: IProps): JSX.Element;
10
13
  declare namespace Tabs {
@@ -22,16 +22,22 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  };
23
23
  import React from 'react';
24
24
  import { Tabs as AntTabs } from 'antd';
25
+ import { DndProvider } from 'react-dnd';
26
+ import { HTML5Backend } from 'react-dnd-html5-backend';
25
27
  import classNames from 'classnames';
28
+ import { useMoveTabNode } from './hooks';
29
+ var initPanes = [];
26
30
  function Tabs(props) {
27
- var children = props.children, className = props.className, isHeader = props.isHeader, isContent = props.isContent, _a = props.marginTop, marginTop = _a === void 0 ? false : _a, _b = props.marginBottom, marginBottom = _b === void 0 ? true : _b, restProps = __rest(props, ["children", "className", "isHeader", "isContent", "marginTop", "marginBottom"]);
31
+ var children = props.children, className = props.className, isHeader = props.isHeader, isContent = props.isContent, _a = props.marginTop, marginTop = _a === void 0 ? false : _a, _b = props.marginBottom, marginBottom = _b === void 0 ? true : _b, isMove = props.isMove, _c = props.panes, panes = _c === void 0 ? initPanes : _c, onMoveChange = props.onMoveChange, restProps = __rest(props, ["children", "className", "isHeader", "isContent", "marginTop", "marginBottom", "isMove", "panes", "onMoveChange"]);
32
+ var renderTabBar = useMoveTabNode(panes, onMoveChange).renderTabBar;
28
33
  var classes = classNames('zt-tab', className, {
29
34
  'zt-tab-header': isHeader,
30
35
  'zt-tab-content': isContent,
31
36
  'zt-tab--margin-top': marginTop,
32
37
  'zt-tab--margin-bottom': marginBottom,
33
38
  });
34
- return (React.createElement(AntTabs, __assign({ type: isHeader ? 'editable-card' : isContent ? 'card' : undefined, hideAdd: isHeader ? true : undefined, className: classes }, restProps), children));
39
+ return isMove ? (React.createElement(DndProvider, { backend: HTML5Backend },
40
+ React.createElement(AntTabs, __assign({ type: isHeader ? 'editable-card' : isContent ? 'card' : undefined, hideAdd: isHeader ? true : undefined, className: classes, renderTabBar: renderTabBar }, restProps), children))) : (React.createElement(AntTabs, __assign({ type: isHeader ? 'editable-card' : isContent ? 'card' : undefined, hideAdd: isHeader ? true : undefined, className: classes }, restProps), children));
35
41
  }
36
42
  Tabs.TabPane = AntTabs.TabPane;
37
43
  export default Tabs;
@@ -26,6 +26,7 @@ interface IProps {
26
26
  footerDom?: IFooterDom[] | null;
27
27
  style?: React.CSSProperties;
28
28
  className?: string;
29
+ align?: 'left' | 'center' | 'right';
29
30
  }
30
31
  declare const _default: React.NamedExoticComponent<IProps>;
31
32
  export default _default;