@zat-design/sisyphus-react 3.6.7 → 3.6.8-beta.2
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.
- package/es/ProEditTable/components/ActionButton/index.js +6 -6
- package/es/ProEditTable/components/RcTable/BaseTable.js +2 -2
- package/es/ProEditTable/components/RcTable/DraggableTable.d.ts +2 -2
- package/es/ProEditTable/components/RcTable/DraggableTable.js +109 -11
- package/es/ProEditTable/components/RcTable/VirtualTable.js +2 -2
- package/es/ProEditTable/components/RenderField/index.js +2 -2
- package/es/ProEditTable/components/index.d.ts +0 -1
- package/es/ProEditTable/components/index.js +0 -1
- package/es/ProForm/components/combination/ProModalSelect/index.js +7 -1
- package/es/ProSelect/index.js +16 -38
- package/es/ProSelect/index.less +2 -2
- package/es/ProTable/{utils.d.ts → components/FormatColumn/index.d.ts} +1 -11
- package/es/ProTable/{utils.js → components/FormatColumn/index.js} +7 -57
- package/es/ProTable/components/RcTable/components/BaseTable/index.d.ts +11 -0
- package/es/ProTable/components/RcTable/components/BaseTable/index.js +43 -0
- package/es/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/index.js +1 -4
- package/es/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/index.js +2 -2
- package/es/ProTable/components/RcTable/components/DraggableTable/index.d.ts +11 -0
- package/es/ProTable/components/RcTable/components/DraggableTable/index.js +52 -0
- package/es/ProTable/components/RcTable/index.d.ts +4 -0
- package/es/ProTable/components/RcTable/index.js +4 -0
- package/es/ProTable/components/RenderEmptyText/index.d.ts +3 -0
- package/es/ProTable/components/RenderEmptyText/index.js +22 -0
- package/es/ProTable/components/RenderFooter/index.d.ts +2 -0
- package/es/ProTable/components/RenderFooter/index.js +12 -0
- package/es/ProTable/components/RenderSummary/index.d.ts +3 -0
- package/es/ProTable/components/RenderSummary/index.js +55 -0
- package/es/ProTable/components/RenderTableHeader/index.d.ts +2 -0
- package/es/ProTable/components/RenderTableHeader/index.js +61 -0
- package/es/ProTable/components/TableResizable/index.js +1 -9
- package/es/ProTable/components/index.d.ts +4 -2
- package/es/ProTable/components/index.js +4 -2
- package/{lib/ProTable → es/ProTable/hooks}/useAntdTable.d.ts +2 -1
- package/es/ProTable/{useAntdTable.js → hooks/useAntdTable.js} +15 -4
- package/es/ProTable/index.d.ts +1 -1
- package/es/ProTable/index.js +114 -174
- package/es/ProTable/propsType.d.ts +3 -1
- package/es/ProTable/utils/index.d.ts +26 -0
- package/es/ProTable/utils/index.js +51 -0
- package/es/global.less +2 -2
- package/lib/ProEditTable/components/ActionButton/index.js +6 -6
- package/lib/ProEditTable/components/RcTable/BaseTable.js +2 -2
- package/lib/ProEditTable/components/RcTable/DraggableTable.d.ts +2 -2
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +111 -12
- package/lib/ProEditTable/components/RcTable/VirtualTable.js +2 -2
- package/lib/ProEditTable/components/RenderField/index.js +2 -2
- package/lib/ProEditTable/components/index.d.ts +0 -1
- package/lib/ProEditTable/components/index.js +0 -14
- package/lib/ProForm/components/combination/ProModalSelect/index.js +5 -1
- package/lib/ProSelect/index.js +14 -38
- package/lib/ProSelect/index.less +2 -2
- package/lib/ProTable/{utils.d.ts → components/FormatColumn/index.d.ts} +1 -11
- package/lib/ProTable/{utils.js → components/FormatColumn/index.js} +17 -68
- package/lib/ProTable/components/RcTable/components/BaseTable/index.d.ts +11 -0
- package/lib/ProTable/components/RcTable/components/BaseTable/index.js +49 -0
- package/lib/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/index.js +1 -4
- package/lib/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/index.js +2 -2
- package/lib/ProTable/components/RcTable/components/DraggableTable/index.d.ts +11 -0
- package/lib/ProTable/components/RcTable/components/DraggableTable/index.js +59 -0
- package/lib/ProTable/components/RcTable/index.d.ts +4 -0
- package/lib/ProTable/components/RcTable/index.js +20 -0
- package/lib/ProTable/components/RenderEmptyText/index.d.ts +3 -0
- package/lib/ProTable/components/RenderEmptyText/index.js +28 -0
- package/lib/ProTable/components/RenderFooter/index.d.ts +2 -0
- package/lib/ProTable/components/RenderFooter/index.js +18 -0
- package/lib/ProTable/components/RenderSummary/index.d.ts +3 -0
- package/lib/ProTable/components/RenderSummary/index.js +61 -0
- package/lib/ProTable/components/RenderTableHeader/index.d.ts +2 -0
- package/lib/ProTable/components/RenderTableHeader/index.js +66 -0
- package/lib/ProTable/components/TableResizable/index.js +3 -11
- package/lib/ProTable/components/index.d.ts +4 -2
- package/lib/ProTable/components/index.js +16 -9
- package/{es/ProTable → lib/ProTable/hooks}/useAntdTable.d.ts +2 -1
- package/lib/ProTable/{useAntdTable.js → hooks/useAntdTable.js} +15 -4
- package/lib/ProTable/index.d.ts +1 -1
- package/lib/ProTable/index.js +118 -175
- package/lib/ProTable/propsType.d.ts +3 -1
- package/lib/ProTable/utils/index.d.ts +26 -0
- package/lib/ProTable/utils/index.js +57 -0
- package/lib/global.less +2 -2
- package/package.json +1 -1
- package/es/ProEditTable/components/DndWrapper/index.d.ts +0 -17
- package/es/ProEditTable/components/DndWrapper/index.js +0 -104
- package/es/ProTable/components/ResizableLine/index.d.ts +0 -2
- package/es/ProTable/components/ResizableLine/index.js +0 -10
- package/lib/ProEditTable/components/DndWrapper/index.d.ts +0 -17
- package/lib/ProEditTable/components/DndWrapper/index.js +0 -111
- package/lib/ProTable/components/ResizableLine/index.d.ts +0 -2
- package/lib/ProTable/components/ResizableLine/index.js +0 -16
- /package/es/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/index.d.ts +0 -0
- /package/es/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/index.d.ts +0 -0
- /package/es/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/propsType.d.ts +0 -0
- /package/es/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/propsType.js +0 -0
- /package/lib/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/index.d.ts +0 -0
- /package/lib/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/index.d.ts +0 -0
- /package/lib/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/propsType.d.ts +0 -0
- /package/lib/ProTable/components/{DndWrapper → RcTable/components/DraggableTable/components/DndWrapper}/utils/propsType.js +0 -0
package/es/ProTable/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
-
import "antd/es/button/style";
|
|
3
|
-
import _Button from "antd/es/button";
|
|
4
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
5
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
6
|
-
import "antd/es/table/style";
|
|
7
|
-
import _Table from "antd/es/table";
|
|
8
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
9
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
@@ -12,21 +7,20 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
12
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
13
8
|
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "originalDataSource"],
|
|
14
9
|
_excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
|
|
15
|
-
import {
|
|
10
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
11
|
import { useEffect, useMemo, useState, createContext } from 'react';
|
|
17
|
-
import { get, keyBy, assign } from 'lodash';
|
|
12
|
+
import { get, keyBy, assign, isObject } from 'lodash';
|
|
18
13
|
import { useDebounceEffect, useDeepCompareEffect, useSetState } from 'ahooks';
|
|
19
|
-
import { ReactSVG } from 'react-svg';
|
|
20
14
|
import classnames from 'classnames';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
15
|
+
import { useProConfig } from '../index';
|
|
16
|
+
import { RenderTableHeader, RenderFooter } from './components';
|
|
17
|
+
import useAntdTable from './hooks/useAntdTable';
|
|
18
|
+
import { BaseTable, DraggableTable } from './components/RcTable';
|
|
19
|
+
import { formatColumn } from './components/FormatColumn';
|
|
26
20
|
import empty from '../assets/empty.png';
|
|
27
21
|
import resetSvg from '../assets/reset.svg';
|
|
28
22
|
import customColumnSvg from '../assets/customColumn.svg';
|
|
29
|
-
import {
|
|
23
|
+
import { getColumnDataIndex, getRowKey } from './utils';
|
|
30
24
|
import locale from '../locale';
|
|
31
25
|
var defaultCacheTime = 1; // columns 配置保存时间为一天
|
|
32
26
|
// 全局上下文
|
|
@@ -36,7 +30,7 @@ export var defaultPage = {
|
|
|
36
30
|
pageSize: 10
|
|
37
31
|
};
|
|
38
32
|
function ProTable(props) {
|
|
39
|
-
var _locale$ProTable, _curTableConfig$pathK
|
|
33
|
+
var _locale$ProTable, _curTableConfig$pathK;
|
|
40
34
|
var _ref = useProConfig('globalConfig') || {},
|
|
41
35
|
configStorage = _ref.storage; // 获取全局缓存位置配置
|
|
42
36
|
var _ref2 = useProConfig('ProTable') || {},
|
|
@@ -61,7 +55,6 @@ function ProTable(props) {
|
|
|
61
55
|
originalDataSource = props.originalDataSource,
|
|
62
56
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
63
57
|
var quickTableConfig = quickConfig ? _objectSpread({
|
|
64
|
-
// resizeColumn: true,
|
|
65
58
|
columnConfig: true,
|
|
66
59
|
cacheTime: true
|
|
67
60
|
}, restProps) : (restProps === null || restProps === void 0 ? void 0 : restProps.columnConfig) ? _objectSpread({
|
|
@@ -197,17 +190,46 @@ function ProTable(props) {
|
|
|
197
190
|
});
|
|
198
191
|
return newColumns;
|
|
199
192
|
}, [curColumns, handleResize]);
|
|
200
|
-
var handleColumnConfig = function
|
|
201
|
-
var
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
193
|
+
var handleColumnConfig = /*#__PURE__*/function () {
|
|
194
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(checkList) {
|
|
195
|
+
var newColumns, _columnConfig$onColum, catchColumns;
|
|
196
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
197
|
+
while (1) switch (_context.prev = _context.next) {
|
|
198
|
+
case 0:
|
|
199
|
+
newColumns = [];
|
|
200
|
+
if (checkList === 'all') {
|
|
201
|
+
newColumns = propsColumns;
|
|
202
|
+
} else {
|
|
203
|
+
newColumns = checkList === null || checkList === void 0 ? void 0 : checkList.map(function (item) {
|
|
204
|
+
return _objectSpread({}, propsColumnObj === null || propsColumnObj === void 0 ? void 0 : propsColumnObj[item]);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (!isObject(columnConfig)) {
|
|
208
|
+
_context.next = 6;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
catchColumns = _defineProperty({}, pathKey, {
|
|
212
|
+
columns: newColumns.map(function (item) {
|
|
213
|
+
return {
|
|
214
|
+
dataIndex: item.dataIndex,
|
|
215
|
+
width: typeof item.width === 'number' ? Math.round(Number(item.width)) : item.width
|
|
216
|
+
};
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
_context.next = 6;
|
|
220
|
+
return columnConfig === null || columnConfig === void 0 ? void 0 : (_columnConfig$onColum = columnConfig.onColumnOk) === null || _columnConfig$onColum === void 0 ? void 0 : _columnConfig$onColum.call(columnConfig, catchColumns, newColumns);
|
|
221
|
+
case 6:
|
|
222
|
+
setCurColumns(newColumns);
|
|
223
|
+
case 7:
|
|
224
|
+
case "end":
|
|
225
|
+
return _context.stop();
|
|
226
|
+
}
|
|
227
|
+
}, _callee);
|
|
228
|
+
}));
|
|
229
|
+
return function handleColumnConfig(_x) {
|
|
230
|
+
return _ref5.apply(this, arguments);
|
|
231
|
+
};
|
|
232
|
+
}();
|
|
211
233
|
useDebounceEffect(function () {
|
|
212
234
|
if (cacheTime) {
|
|
213
235
|
var newTableConfig = _objectSpread(_objectSpread({}, curTableConfig), {}, _defineProperty({}, pathKey, {
|
|
@@ -215,7 +237,7 @@ function ProTable(props) {
|
|
|
215
237
|
columns: curColumns.map(function (item) {
|
|
216
238
|
return {
|
|
217
239
|
dataIndex: item.dataIndex,
|
|
218
|
-
width: Math.round(Number(item.width))
|
|
240
|
+
width: typeof item.width === 'number' ? Math.round(Number(item.width)) : item.width
|
|
219
241
|
};
|
|
220
242
|
})
|
|
221
243
|
}));
|
|
@@ -239,53 +261,6 @@ function ProTable(props) {
|
|
|
239
261
|
return item === null || item === void 0 ? void 0 : item.dataIndex;
|
|
240
262
|
});
|
|
241
263
|
}, [curColumns]);
|
|
242
|
-
var renderSummary = function renderSummary() {
|
|
243
|
-
var _ref5 = summary || {},
|
|
244
|
-
columns = _ref5.columns,
|
|
245
|
-
_ref5$total = _ref5.total,
|
|
246
|
-
total = _ref5$total === void 0 ? true : _ref5$total,
|
|
247
|
-
_ref5$fixed = _ref5.fixed,
|
|
248
|
-
fixed = _ref5$fixed === void 0 ? true : _ref5$fixed;
|
|
249
|
-
var _ref6 = tableProps || {},
|
|
250
|
-
dataSource = _ref6.dataSource;
|
|
251
|
-
// 没有数据时,不展示合计栏
|
|
252
|
-
if (!(_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.length)) {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
return _jsx(_Table.Summary, {
|
|
256
|
-
fixed: fixed,
|
|
257
|
-
children: _jsx(_Table.Summary.Row, {
|
|
258
|
-
children: columns === null || columns === void 0 ? void 0 : columns.map(function (_ref7) {
|
|
259
|
-
var key = _ref7.key,
|
|
260
|
-
index = _ref7.index,
|
|
261
|
-
colSpan = _ref7.colSpan,
|
|
262
|
-
prefix = _ref7.prefix,
|
|
263
|
-
suffix = _ref7.suffix,
|
|
264
|
-
title = _ref7.title,
|
|
265
|
-
precision = _ref7.precision,
|
|
266
|
-
valueType = _ref7.valueType;
|
|
267
|
-
var text = null;
|
|
268
|
-
if (title) {
|
|
269
|
-
text = title;
|
|
270
|
-
} else if (total && key) {
|
|
271
|
-
var _dataSource$reduce;
|
|
272
|
-
var format = valueTypeRender === null || valueTypeRender === void 0 ? void 0 : valueTypeRender[valueType];
|
|
273
|
-
var sum = _dataSource === null || _dataSource === void 0 ? void 0 : (_dataSource$reduce = _dataSource.reduce) === null || _dataSource$reduce === void 0 ? void 0 : _dataSource$reduce.call(_dataSource, function (pre, cur) {
|
|
274
|
-
var _get;
|
|
275
|
-
return tools.calc(pre, '+', (_get = get(cur, key)) !== null && _get !== void 0 ? _get : 0);
|
|
276
|
-
}, 0);
|
|
277
|
-
text = format ? format(sum, precision !== null && precision !== void 0 ? precision : 2) : sum;
|
|
278
|
-
}
|
|
279
|
-
var _key = key;
|
|
280
|
-
return _jsxs(_Table.Summary.Cell, {
|
|
281
|
-
index: index,
|
|
282
|
-
colSpan: colSpan,
|
|
283
|
-
children: [prefix, text, suffix]
|
|
284
|
-
}, _key);
|
|
285
|
-
})
|
|
286
|
-
})
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
264
|
var cls = classnames(_defineProperty({
|
|
290
265
|
'pro-table': true,
|
|
291
266
|
'pro-table-no-stripe': !stripe,
|
|
@@ -325,9 +300,9 @@ function ProTable(props) {
|
|
|
325
300
|
return _rowSelection;
|
|
326
301
|
};
|
|
327
302
|
var onDataSourceChange = /*#__PURE__*/function () {
|
|
328
|
-
var
|
|
329
|
-
return _regeneratorRuntime().wrap(function
|
|
330
|
-
while (1) switch (
|
|
303
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(nextDataSource) {
|
|
304
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
305
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
331
306
|
case 0:
|
|
332
307
|
setState({
|
|
333
308
|
dataSource: nextDataSource
|
|
@@ -336,116 +311,81 @@ function ProTable(props) {
|
|
|
336
311
|
assign(dataSource, nextDataSource);
|
|
337
312
|
case 2:
|
|
338
313
|
case "end":
|
|
339
|
-
return
|
|
314
|
+
return _context2.stop();
|
|
340
315
|
}
|
|
341
|
-
},
|
|
316
|
+
}, _callee2);
|
|
342
317
|
}));
|
|
343
|
-
return function onDataSourceChange(
|
|
344
|
-
return
|
|
318
|
+
return function onDataSourceChange(_x2) {
|
|
319
|
+
return _ref6.apply(this, arguments);
|
|
345
320
|
};
|
|
346
321
|
}();
|
|
347
|
-
var
|
|
348
|
-
if (
|
|
349
|
-
return
|
|
350
|
-
body: {
|
|
351
|
-
row: Row
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
if (resizeColumn) {
|
|
356
|
-
return TableResizable.components;
|
|
322
|
+
var _rowClassName = function _rowClassName(record, index) {
|
|
323
|
+
if (originalDataSource && !originalObj.hasOwnProperty(get(record, 'rowKey'))) {
|
|
324
|
+
return 'new-cell';
|
|
357
325
|
}
|
|
358
|
-
return null;
|
|
359
326
|
};
|
|
327
|
+
var TableComponent = draggable ? DraggableTable : BaseTable;
|
|
360
328
|
return _jsx(TableContext.Provider, {
|
|
361
329
|
value: {
|
|
362
330
|
pathKey: pathKey,
|
|
363
331
|
tableConfig: tableConfig,
|
|
364
332
|
Storage: Storage
|
|
365
333
|
},
|
|
366
|
-
children:
|
|
334
|
+
children: _jsxs("div", {
|
|
367
335
|
className: cls,
|
|
368
|
-
children:
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
mode: "list",
|
|
393
|
-
draggable: true,
|
|
394
|
-
dataSource: customColumns,
|
|
395
|
-
value: checkColumns,
|
|
396
|
-
allValue: "all",
|
|
397
|
-
onChange: handleColumnConfig,
|
|
398
|
-
trigger: _jsx(_Button, {
|
|
399
|
-
className: "custom-column-btn",
|
|
400
|
-
icon: _jsx(ReactSVG, {
|
|
401
|
-
className: "anticon",
|
|
402
|
-
wrapper: "span",
|
|
403
|
-
src: customColumnSvg
|
|
404
|
-
}),
|
|
405
|
-
children: locale === null || locale === void 0 ? void 0 : (_locale$ProTable4 = locale.ProTable) === null || _locale$ProTable4 === void 0 ? void 0 : _locale$ProTable4.customColumns
|
|
406
|
-
})
|
|
407
|
-
})]
|
|
408
|
-
})]
|
|
409
|
-
}), _jsxs("div", {
|
|
410
|
-
className: "pro-table-container",
|
|
411
|
-
children: [_jsx(_Table, _objectSpread(_objectSpread({
|
|
412
|
-
className: draggable ? 'pro-edit-table-drag' : '',
|
|
413
|
-
// components={resizeColumn ? TableResizable.components : undefined}
|
|
414
|
-
components: renderComponents(),
|
|
415
|
-
// @ts-ignore
|
|
336
|
+
children: [_jsx(RenderTableHeader, {
|
|
337
|
+
dataSource: {
|
|
338
|
+
headerRender: headerRender,
|
|
339
|
+
columnConfig: columnConfig,
|
|
340
|
+
resizeColumn: resizeColumn,
|
|
341
|
+
resetSvg: resetSvg,
|
|
342
|
+
resetColumnWidth: resetColumnWidth,
|
|
343
|
+
locale: locale,
|
|
344
|
+
customColumns: customColumns,
|
|
345
|
+
checkColumns: checkColumns,
|
|
346
|
+
handleColumnConfig: handleColumnConfig,
|
|
347
|
+
customColumnSvg: customColumnSvg
|
|
348
|
+
}
|
|
349
|
+
}), _jsxs("div", {
|
|
350
|
+
className: "pro-table-container",
|
|
351
|
+
children: [_jsx(TableComponent, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
352
|
+
draggableProps: {
|
|
353
|
+
onChange: onDataSourceChange,
|
|
354
|
+
draggable: draggable,
|
|
355
|
+
rowKey: rowKey
|
|
356
|
+
},
|
|
357
|
+
tableProps: {
|
|
358
|
+
value: _dataSource,
|
|
359
|
+
headerRender: headerRender,
|
|
416
360
|
columns: columns,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
className: "pro-table-footer ".concat(pagination && !!(_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.length) ? 'has-page' : 'no-page'),
|
|
446
|
-
children: typeof footerRender === 'function' ? footerRender() : footerRender
|
|
447
|
-
}) : null]
|
|
448
|
-
})
|
|
361
|
+
renderRowSelection: renderRowSelection,
|
|
362
|
+
rowClassName: _rowClassName,
|
|
363
|
+
disabled: disabled,
|
|
364
|
+
resizeColumn: resizeColumn
|
|
365
|
+
},
|
|
366
|
+
emptyTextProps: {
|
|
367
|
+
empty: empty,
|
|
368
|
+
locale: locale,
|
|
369
|
+
emptyText: emptyText
|
|
370
|
+
},
|
|
371
|
+
summaryProps: {
|
|
372
|
+
summary: summary,
|
|
373
|
+
dataSource: _dataSource
|
|
374
|
+
},
|
|
375
|
+
dataSource: _dataSource
|
|
376
|
+
})), _jsx("span", {
|
|
377
|
+
className: "pro-table-resizable-line",
|
|
378
|
+
style: {
|
|
379
|
+
display: 'none'
|
|
380
|
+
}
|
|
381
|
+
})]
|
|
382
|
+
}), _jsx(RenderFooter, {
|
|
383
|
+
dataSource: {
|
|
384
|
+
footerRender: footerRender,
|
|
385
|
+
pagination: pagination,
|
|
386
|
+
_dataSource: _dataSource
|
|
387
|
+
}
|
|
388
|
+
})]
|
|
449
389
|
})
|
|
450
390
|
});
|
|
451
391
|
}
|
|
@@ -44,7 +44,9 @@ export interface ProTableProps<T = any> extends Omit<TableProps<any>, 'summary'
|
|
|
44
44
|
quickConfig?: boolean;
|
|
45
45
|
resizeColumn?: boolean;
|
|
46
46
|
sortRow?: boolean | 'drag' | 'move';
|
|
47
|
-
columnConfig?: boolean
|
|
47
|
+
columnConfig?: boolean | {
|
|
48
|
+
onColumnOk: (cacheColumns: any, columns: ProTableColumn[]) => Promise<void>;
|
|
49
|
+
};
|
|
48
50
|
cacheTime?: number | boolean;
|
|
49
51
|
sortColumnText?: string;
|
|
50
52
|
storage?: 'localStorage' | 'sessionStorage';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取小数点后的位数
|
|
3
|
+
* @param num 数字
|
|
4
|
+
* @returns 位数
|
|
5
|
+
*/
|
|
6
|
+
export declare const getDecimalDigits: (num?: number) => number;
|
|
7
|
+
/**
|
|
8
|
+
* @description: 获取初始值
|
|
9
|
+
* @author: xiangchengli
|
|
10
|
+
* @param {any} rowKey
|
|
11
|
+
* @param any value
|
|
12
|
+
* @param any originalObj
|
|
13
|
+
* @param {any} dataIndex
|
|
14
|
+
* @return {any}
|
|
15
|
+
*/
|
|
16
|
+
export declare const getOriginalValue: (value: any, record: any, originalObj: any, rowKey: any, dataIndex: any) => any;
|
|
17
|
+
export declare const getColumnDataIndex: (dataIndex: string | string[]) => string;
|
|
18
|
+
/**
|
|
19
|
+
* 判断数据是否为Response<List<any>>结构
|
|
20
|
+
* @param data { [key: string]: any } 需要判断数据
|
|
21
|
+
* @returns boolean 是否
|
|
22
|
+
*/
|
|
23
|
+
export declare const isListResult: (data: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}) => boolean;
|
|
26
|
+
export declare const getRowKey: (rowKey: any, record: any) => any;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { get, isEqual } from 'lodash';
|
|
2
|
+
/**
|
|
3
|
+
* 获取小数点后的位数
|
|
4
|
+
* @param num 数字
|
|
5
|
+
* @returns 位数
|
|
6
|
+
*/
|
|
7
|
+
export var getDecimalDigits = function getDecimalDigits() {
|
|
8
|
+
var num = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
9
|
+
var match = Number(num).toString().match(/\.(\d+)/);
|
|
10
|
+
return match ? match[1].length : 0;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @description: 获取初始值
|
|
14
|
+
* @author: xiangchengli
|
|
15
|
+
* @param {any} rowKey
|
|
16
|
+
* @param any value
|
|
17
|
+
* @param any originalObj
|
|
18
|
+
* @param {any} dataIndex
|
|
19
|
+
* @return {any}
|
|
20
|
+
*/
|
|
21
|
+
export var getOriginalValue = function getOriginalValue(value, record, originalObj, rowKey, dataIndex) {
|
|
22
|
+
if (!originalObj) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
var originalRecord = get(originalObj, get(record, rowKey));
|
|
26
|
+
var originalValue = get(originalRecord, dataIndex);
|
|
27
|
+
if (!isEqual(originalValue, value)) {
|
|
28
|
+
return originalValue;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
};
|
|
32
|
+
export var getColumnDataIndex = function getColumnDataIndex(dataIndex) {
|
|
33
|
+
return typeof dataIndex === 'string' ? dataIndex : dataIndex === null || dataIndex === void 0 ? void 0 : dataIndex.join('-');
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 判断数据是否为Response<List<any>>结构
|
|
37
|
+
* @param data { [key: string]: any } 需要判断数据
|
|
38
|
+
* @returns boolean 是否
|
|
39
|
+
*/
|
|
40
|
+
export var isListResult = function isListResult(data) {
|
|
41
|
+
return data.hasOwnProperty('total') && data.hasOwnProperty('list');
|
|
42
|
+
};
|
|
43
|
+
export var getRowKey = function getRowKey(rowKey, record) {
|
|
44
|
+
// 默认取id
|
|
45
|
+
var key = record.rowKey || 'id';
|
|
46
|
+
if (rowKey) {
|
|
47
|
+
var _ref;
|
|
48
|
+
key = (_ref = typeof rowKey === 'function' ? rowKey(record) : record[rowKey]) !== null && _ref !== void 0 ? _ref : key;
|
|
49
|
+
}
|
|
50
|
+
return key;
|
|
51
|
+
};
|
package/es/global.less
CHANGED
|
@@ -17,7 +17,7 @@ pre {
|
|
|
17
17
|
|
|
18
18
|
// 轨道
|
|
19
19
|
::-webkit-scrollbar-track {
|
|
20
|
-
background
|
|
20
|
+
background: transparent;
|
|
21
21
|
border-radius: 10px;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -51,6 +51,6 @@ pre {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
:hover::-webkit-scrollbar-track {
|
|
54
|
-
background
|
|
54
|
+
background: transparent;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -86,24 +86,24 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
86
86
|
disabled: isDisabled,
|
|
87
87
|
okText: _locale.default.ProEditTable.confirm,
|
|
88
88
|
cancelText: _locale.default.ProEditTable.cancel,
|
|
89
|
-
children: /*#__PURE__*/_react.default.isValidElement(btnConfig.label) ? ( /*#__PURE__*/_react.default.cloneElement(btnConfig.label, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable'])), {}, {
|
|
89
|
+
children: /*#__PURE__*/_react.default.isValidElement(btnConfig.label) ? ( /*#__PURE__*/_react.default.cloneElement(btnConfig.label, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
|
|
90
90
|
record: record,
|
|
91
91
|
index: index,
|
|
92
92
|
disabled: isDisabled
|
|
93
|
-
}))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable'])), {}, {
|
|
93
|
+
}))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
|
|
94
94
|
disabled: isDisabled,
|
|
95
95
|
type: "link",
|
|
96
96
|
children: btnConfig.label
|
|
97
97
|
}))
|
|
98
98
|
}) : (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
99
|
-
children: /*#__PURE__*/_react.default.isValidElement(btnConfig.label) ? ( /*#__PURE__*/_react.default.cloneElement(btnConfig.label, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable'])), {}, {
|
|
99
|
+
children: /*#__PURE__*/_react.default.isValidElement(btnConfig.label) ? ( /*#__PURE__*/_react.default.cloneElement(btnConfig.label, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
|
|
100
100
|
record: record,
|
|
101
101
|
index: index,
|
|
102
102
|
disabled: isDisabled,
|
|
103
103
|
onClick: function onClick() {
|
|
104
104
|
btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.onEvent(record, index);
|
|
105
105
|
}
|
|
106
|
-
}))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable'])), {}, {
|
|
106
|
+
}))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(delBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
|
|
107
107
|
disabled: isDisabled,
|
|
108
108
|
type: "link",
|
|
109
109
|
onClick: function onClick() {
|
|
@@ -113,12 +113,12 @@ var ActionButton = function ActionButton(_ref) {
|
|
|
113
113
|
}))
|
|
114
114
|
})
|
|
115
115
|
}) : (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
116
|
-
children: /*#__PURE__*/_react.default.isValidElement(btnConfig.label) ? ( /*#__PURE__*/_react.default.cloneElement(btnConfig.label, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(actionBtnProps, ['buttonProps', 'isEditable'])), {}, {
|
|
116
|
+
children: /*#__PURE__*/_react.default.isValidElement(btnConfig.label) ? ( /*#__PURE__*/_react.default.cloneElement(btnConfig.label, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(actionBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
|
|
117
117
|
record: record,
|
|
118
118
|
index: index
|
|
119
119
|
}))) : (0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
120
120
|
className: "action-button"
|
|
121
|
-
}, (0, _lodash.omit)(actionBtnProps, ['buttonProps', 'isEditable'])), {}, {
|
|
121
|
+
}, (0, _lodash.omit)(actionBtnProps, ['buttonProps', 'isEditable', 'onEvent'])), {}, {
|
|
122
122
|
type: "link",
|
|
123
123
|
icon: (_btnConfig$icon = btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.icon) !== null && _btnConfig$icon !== void 0 ? _btnConfig$icon : _config.iconMap[btnConfig.type],
|
|
124
124
|
children: btnConfig.label
|
|
@@ -49,8 +49,8 @@ var BaseTable = function BaseTable(_ref) {
|
|
|
49
49
|
return {
|
|
50
50
|
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
51
51
|
'data-hide': isHideCheckBox,
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
'data-row-draggable': rowDraggable,
|
|
53
|
+
onClick: function onClick() {}
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
}, resetProps), {}, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
declare const _default:
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: React.MemoExoticComponent<({ tableProps, draggableProps, ...resetProps }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
tableProps: any;
|
|
5
5
|
draggableProps: any;
|