@zat-design/sisyphus-react 3.6.7-beta.1 → 3.6.7-beta.3

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.
@@ -1,10 +1,10 @@
1
1
  import _typeof from "@babel/runtime/helpers/esm/typeof";
2
2
  import "antd/es/button/style";
3
3
  import _Button from "antd/es/button";
4
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
5
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
4
  import "antd/es/table/style";
7
5
  import _Table from "antd/es/table";
6
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
7
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
8
8
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
@@ -14,7 +14,7 @@ var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stri
14
14
  _excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
15
15
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
16
16
  import { useEffect, useMemo, useState, createContext } from 'react';
17
- import { get, keyBy, assign } from 'lodash';
17
+ import { get, keyBy, assign, isObject } from 'lodash';
18
18
  import { useDebounceEffect, useDeepCompareEffect, useSetState } from 'ahooks';
19
19
  import { ReactSVG } from 'react-svg';
20
20
  import classnames from 'classnames';
@@ -197,17 +197,38 @@ function ProTable(props) {
197
197
  });
198
198
  return newColumns;
199
199
  }, [curColumns, handleResize]);
200
- var handleColumnConfig = function handleColumnConfig(checkList) {
201
- var newColumns = [];
202
- if (checkList === 'all') {
203
- newColumns = propsColumns;
204
- } else {
205
- newColumns = checkList === null || checkList === void 0 ? void 0 : checkList.map(function (item) {
206
- return _objectSpread({}, propsColumnObj === null || propsColumnObj === void 0 ? void 0 : propsColumnObj[item]);
207
- });
208
- }
209
- setCurColumns(newColumns);
210
- };
200
+ var handleColumnConfig = /*#__PURE__*/function () {
201
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(checkList) {
202
+ var newColumns, _columnConfig$onColum;
203
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
204
+ while (1) switch (_context.prev = _context.next) {
205
+ case 0:
206
+ newColumns = [];
207
+ if (checkList === 'all') {
208
+ newColumns = propsColumns;
209
+ } else {
210
+ newColumns = checkList === null || checkList === void 0 ? void 0 : checkList.map(function (item) {
211
+ return _objectSpread({}, propsColumnObj === null || propsColumnObj === void 0 ? void 0 : propsColumnObj[item]);
212
+ });
213
+ }
214
+ if (!isObject(columnConfig)) {
215
+ _context.next = 5;
216
+ break;
217
+ }
218
+ _context.next = 5;
219
+ return columnConfig === null || columnConfig === void 0 ? void 0 : (_columnConfig$onColum = columnConfig.onColumnChange) === null || _columnConfig$onColum === void 0 ? void 0 : _columnConfig$onColum.call(columnConfig, newColumns);
220
+ case 5:
221
+ setCurColumns(newColumns);
222
+ case 6:
223
+ case "end":
224
+ return _context.stop();
225
+ }
226
+ }, _callee);
227
+ }));
228
+ return function handleColumnConfig(_x) {
229
+ return _ref5.apply(this, arguments);
230
+ };
231
+ }();
211
232
  useDebounceEffect(function () {
212
233
  if (cacheTime) {
213
234
  var newTableConfig = _objectSpread(_objectSpread({}, curTableConfig), {}, _defineProperty({}, pathKey, {
@@ -240,14 +261,14 @@ function ProTable(props) {
240
261
  });
241
262
  }, [curColumns]);
242
263
  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;
264
+ var _ref6 = summary || {},
265
+ columns = _ref6.columns,
266
+ _ref6$total = _ref6.total,
267
+ total = _ref6$total === void 0 ? true : _ref6$total,
268
+ _ref6$fixed = _ref6.fixed,
269
+ fixed = _ref6$fixed === void 0 ? true : _ref6$fixed;
270
+ var _ref7 = tableProps || {},
271
+ dataSource = _ref7.dataSource;
251
272
  // 没有数据时,不展示合计栏
252
273
  if (!(_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.length)) {
253
274
  return null;
@@ -255,15 +276,15 @@ function ProTable(props) {
255
276
  return _jsx(_Table.Summary, {
256
277
  fixed: fixed,
257
278
  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;
279
+ children: columns === null || columns === void 0 ? void 0 : columns.map(function (_ref8) {
280
+ var key = _ref8.key,
281
+ index = _ref8.index,
282
+ colSpan = _ref8.colSpan,
283
+ prefix = _ref8.prefix,
284
+ suffix = _ref8.suffix,
285
+ title = _ref8.title,
286
+ precision = _ref8.precision,
287
+ valueType = _ref8.valueType;
267
288
  var text = null;
268
289
  if (title) {
269
290
  text = title;
@@ -325,9 +346,9 @@ function ProTable(props) {
325
346
  return _rowSelection;
326
347
  };
327
348
  var onDataSourceChange = /*#__PURE__*/function () {
328
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(nextDataSource) {
329
- return _regeneratorRuntime().wrap(function _callee$(_context) {
330
- while (1) switch (_context.prev = _context.next) {
349
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(nextDataSource) {
350
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
351
+ while (1) switch (_context2.prev = _context2.next) {
331
352
  case 0:
332
353
  setState({
333
354
  dataSource: nextDataSource
@@ -336,12 +357,12 @@ function ProTable(props) {
336
357
  assign(dataSource, nextDataSource);
337
358
  case 2:
338
359
  case "end":
339
- return _context.stop();
360
+ return _context2.stop();
340
361
  }
341
- }, _callee);
362
+ }, _callee2);
342
363
  }));
343
- return function onDataSourceChange(_x) {
344
- return _ref8.apply(this, arguments);
364
+ return function onDataSourceChange(_x2) {
365
+ return _ref9.apply(this, arguments);
345
366
  };
346
367
  }();
347
368
  var renderComponents = function renderComponents() {
@@ -366,7 +387,7 @@ function ProTable(props) {
366
387
  children: _jsx("div", {
367
388
  className: cls,
368
389
  children: _jsxs(DndWrapper, {
369
- value: _dataSource,
390
+ value: _dataSource !== null && _dataSource !== void 0 ? _dataSource : [],
370
391
  onChange: onDataSourceChange,
371
392
  disabled: false,
372
393
  draggable: draggable,
@@ -83,6 +83,7 @@ declare function useAntdTable<I, R extends Record<string, any>, S extends Servic
83
83
  };
84
84
  onChange: (pagination: any, filters: any, sorter: any, extra: any) => void;
85
85
  };
86
+ handleSetStateCallback: (values: any) => void;
86
87
  loading: boolean;
87
88
  error?: Error;
88
89
  cancel: () => void;
@@ -89,6 +89,16 @@ function useAntdTable(service, options, useRequestOptions) {
89
89
  }
90
90
  return requestParams;
91
91
  }, [defaultParam, extraParams]);
92
+ // 仅清数据源相关,查询相关
93
+ var handleSetStateCallback = function handleSetStateCallback(values) {
94
+ setState(_objectSpread({
95
+ data: [],
96
+ total: 0,
97
+ selectedRecords: [],
98
+ selectedRowKeys: [],
99
+ allSelected: false
100
+ }, values));
101
+ };
92
102
  var params = useMemo(function () {
93
103
  var newQueryBean = _objectSpread(_objectSpread({}, searchValues), extraFilter);
94
104
  return getTransformParams(_objectSpread({
@@ -489,7 +499,8 @@ function useAntdTable(service, options, useRequestOptions) {
489
499
  rowSelection: returnRowSelection || rowSelections ? rowSelection : undefined,
490
500
  pagination: pagination,
491
501
  onChange: handleTableChange
492
- }
502
+ },
503
+ handleSetStateCallback: handleSetStateCallback
493
504
  });
494
505
  }
495
506
  export default useAntdTable;
@@ -201,17 +201,38 @@ function ProTable(props) {
201
201
  });
202
202
  return newColumns;
203
203
  }, [curColumns, handleResize]);
204
- var handleColumnConfig = function handleColumnConfig(checkList) {
205
- var newColumns = [];
206
- if (checkList === 'all') {
207
- newColumns = propsColumns;
208
- } else {
209
- newColumns = checkList === null || checkList === void 0 ? void 0 : checkList.map(function (item) {
210
- return (0, _objectSpread4.default)({}, propsColumnObj === null || propsColumnObj === void 0 ? void 0 : propsColumnObj[item]);
211
- });
212
- }
213
- setCurColumns(newColumns);
214
- };
204
+ var handleColumnConfig = /*#__PURE__*/function () {
205
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(checkList) {
206
+ var newColumns, _columnConfig$onColum;
207
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
208
+ while (1) switch (_context.prev = _context.next) {
209
+ case 0:
210
+ newColumns = [];
211
+ if (checkList === 'all') {
212
+ newColumns = propsColumns;
213
+ } else {
214
+ newColumns = checkList === null || checkList === void 0 ? void 0 : checkList.map(function (item) {
215
+ return (0, _objectSpread4.default)({}, propsColumnObj === null || propsColumnObj === void 0 ? void 0 : propsColumnObj[item]);
216
+ });
217
+ }
218
+ if (!(0, _lodash.isObject)(columnConfig)) {
219
+ _context.next = 5;
220
+ break;
221
+ }
222
+ _context.next = 5;
223
+ return columnConfig === null || columnConfig === void 0 ? void 0 : (_columnConfig$onColum = columnConfig.onColumnChange) === null || _columnConfig$onColum === void 0 ? void 0 : _columnConfig$onColum.call(columnConfig, newColumns);
224
+ case 5:
225
+ setCurColumns(newColumns);
226
+ case 6:
227
+ case "end":
228
+ return _context.stop();
229
+ }
230
+ }, _callee);
231
+ }));
232
+ return function handleColumnConfig(_x) {
233
+ return _ref5.apply(this, arguments);
234
+ };
235
+ }();
215
236
  (0, _ahooks.useDebounceEffect)(function () {
216
237
  if (cacheTime) {
217
238
  var newTableConfig = (0, _objectSpread4.default)((0, _objectSpread4.default)({}, curTableConfig), {}, (0, _defineProperty2.default)({}, pathKey, {
@@ -244,14 +265,14 @@ function ProTable(props) {
244
265
  });
245
266
  }, [curColumns]);
246
267
  var renderSummary = function renderSummary() {
247
- var _ref5 = summary || {},
248
- columns = _ref5.columns,
249
- _ref5$total = _ref5.total,
250
- total = _ref5$total === void 0 ? true : _ref5$total,
251
- _ref5$fixed = _ref5.fixed,
252
- fixed = _ref5$fixed === void 0 ? true : _ref5$fixed;
253
- var _ref6 = tableProps || {},
254
- dataSource = _ref6.dataSource;
268
+ var _ref6 = summary || {},
269
+ columns = _ref6.columns,
270
+ _ref6$total = _ref6.total,
271
+ total = _ref6$total === void 0 ? true : _ref6$total,
272
+ _ref6$fixed = _ref6.fixed,
273
+ fixed = _ref6$fixed === void 0 ? true : _ref6$fixed;
274
+ var _ref7 = tableProps || {},
275
+ dataSource = _ref7.dataSource;
255
276
  // 没有数据时,不展示合计栏
256
277
  if (!(_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.length)) {
257
278
  return null;
@@ -259,15 +280,15 @@ function ProTable(props) {
259
280
  return (0, _jsxRuntime.jsx)(_antd.Table.Summary, {
260
281
  fixed: fixed,
261
282
  children: (0, _jsxRuntime.jsx)(_antd.Table.Summary.Row, {
262
- children: columns === null || columns === void 0 ? void 0 : columns.map(function (_ref7) {
263
- var key = _ref7.key,
264
- index = _ref7.index,
265
- colSpan = _ref7.colSpan,
266
- prefix = _ref7.prefix,
267
- suffix = _ref7.suffix,
268
- title = _ref7.title,
269
- precision = _ref7.precision,
270
- valueType = _ref7.valueType;
283
+ children: columns === null || columns === void 0 ? void 0 : columns.map(function (_ref8) {
284
+ var key = _ref8.key,
285
+ index = _ref8.index,
286
+ colSpan = _ref8.colSpan,
287
+ prefix = _ref8.prefix,
288
+ suffix = _ref8.suffix,
289
+ title = _ref8.title,
290
+ precision = _ref8.precision,
291
+ valueType = _ref8.valueType;
271
292
  var text = null;
272
293
  if (title) {
273
294
  text = title;
@@ -329,9 +350,9 @@ function ProTable(props) {
329
350
  return _rowSelection;
330
351
  };
331
352
  var onDataSourceChange = /*#__PURE__*/function () {
332
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(nextDataSource) {
333
- return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
334
- while (1) switch (_context.prev = _context.next) {
353
+ var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(nextDataSource) {
354
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
355
+ while (1) switch (_context2.prev = _context2.next) {
335
356
  case 0:
336
357
  setState({
337
358
  dataSource: nextDataSource
@@ -340,12 +361,12 @@ function ProTable(props) {
340
361
  (0, _lodash.assign)(dataSource, nextDataSource);
341
362
  case 2:
342
363
  case "end":
343
- return _context.stop();
364
+ return _context2.stop();
344
365
  }
345
- }, _callee);
366
+ }, _callee2);
346
367
  }));
347
- return function onDataSourceChange(_x) {
348
- return _ref8.apply(this, arguments);
368
+ return function onDataSourceChange(_x2) {
369
+ return _ref9.apply(this, arguments);
349
370
  };
350
371
  }();
351
372
  var renderComponents = function renderComponents() {
@@ -370,7 +391,7 @@ function ProTable(props) {
370
391
  children: (0, _jsxRuntime.jsx)("div", {
371
392
  className: cls,
372
393
  children: (0, _jsxRuntime.jsxs)(_components.DndWrapper, {
373
- value: _dataSource,
394
+ value: _dataSource !== null && _dataSource !== void 0 ? _dataSource : [],
374
395
  onChange: onDataSourceChange,
375
396
  disabled: false,
376
397
  draggable: draggable,
@@ -83,6 +83,7 @@ declare function useAntdTable<I, R extends Record<string, any>, S extends Servic
83
83
  };
84
84
  onChange: (pagination: any, filters: any, sorter: any, extra: any) => void;
85
85
  };
86
+ handleSetStateCallback: (values: any) => void;
86
87
  loading: boolean;
87
88
  error?: Error;
88
89
  cancel: () => void;
@@ -96,6 +96,16 @@ function useAntdTable(service, options, useRequestOptions) {
96
96
  }
97
97
  return requestParams;
98
98
  }, [defaultParam, extraParams]);
99
+ // 仅清数据源相关,查询相关
100
+ var handleSetStateCallback = function handleSetStateCallback(values) {
101
+ setState((0, _objectSpread2.default)({
102
+ data: [],
103
+ total: 0,
104
+ selectedRecords: [],
105
+ selectedRowKeys: [],
106
+ allSelected: false
107
+ }, values));
108
+ };
99
109
  var params = (0, _react.useMemo)(function () {
100
110
  var newQueryBean = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, searchValues), extraFilter);
101
111
  return getTransformParams((0, _objectSpread2.default)({
@@ -496,7 +506,8 @@ function useAntdTable(service, options, useRequestOptions) {
496
506
  rowSelection: returnRowSelection || rowSelections ? rowSelection : undefined,
497
507
  pagination: pagination,
498
508
  onChange: handleTableChange
499
- }
509
+ },
510
+ handleSetStateCallback: handleSetStateCallback
500
511
  });
501
512
  }
502
513
  var _default = exports.default = useAntdTable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.6.7-beta.1",
3
+ "version": "3.6.7-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",