@zat-design/sisyphus-react 3.5.5-beta.9 → 3.6.0

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.
@@ -4481,6 +4481,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
4481
4481
  position: absolute;
4482
4482
  bottom: var(--zaui-space-size-md, 16px);
4483
4483
  }
4484
+ .pro-edit-table-toolbar {
4485
+ background-color: #fff;
4486
+ }
4484
4487
  .pro-edit-table-toolbar .ant-space {
4485
4488
  gap: var(--zaui-space-size-sm, 8px);
4486
4489
  }
package/dist/less.esm.css CHANGED
@@ -4481,6 +4481,9 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
4481
4481
  position: absolute;
4482
4482
  bottom: var(--zaui-space-size-md, 16px);
4483
4483
  }
4484
+ .pro-edit-table-toolbar {
4485
+ background-color: #fff;
4486
+ }
4484
4487
  .pro-edit-table-toolbar .ant-space {
4485
4488
  gap: var(--zaui-space-size-sm, 8px);
4486
4489
  }
@@ -1,3 +1,5 @@
1
+ import "antd/es/affix/style";
2
+ import _Affix from "antd/es/affix";
1
3
  import "antd/es/table/style";
2
4
  import _Table from "antd/es/table";
3
5
  import _typeof from "@babel/runtime/helpers/esm/typeof";
@@ -9,11 +11,11 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
11
  import "antd/es/form/style";
10
12
  import _Form from "antd/es/form";
11
13
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
12
- var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
14
+ var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
13
15
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
14
16
  import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
15
- import { get, isArray } from 'lodash';
16
- import { useLocalStorageState, useSetState } from 'ahooks';
17
+ import { get, isArray, isBoolean } from 'lodash';
18
+ import { useDeepCompareEffect, useLocalStorageState, useSetState } from 'ahooks';
17
19
  import classnames from 'classnames';
18
20
  import { transformColumns } from './utils';
19
21
  import { getRandom, getNamePath } from './utils/tools';
@@ -38,6 +40,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
38
40
  actionWidth = _ref.actionWidth,
39
41
  actionProps = _ref.actionProps,
40
42
  toolbarProps = _ref.toolbarProps,
43
+ toolbarSticky = _ref.toolbarSticky,
41
44
  rowSelection = _ref.rowSelection,
42
45
  onlyOneLineMsg = _ref.onlyOneLineMsg,
43
46
  deletePoConfirmMsg = _ref.deletePoConfirmMsg,
@@ -59,6 +62,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
59
62
  // 上下文form
60
63
  var contentForm = _Form.useFormInstance();
61
64
  var formFieldProps = ProForm.useFieldProps() || {};
65
+ var affixRef = useRef(null);
62
66
  var form = contentForm || (formFieldProps === null || formFieldProps === void 0 ? void 0 : formFieldProps.form) || (resetProps === null || resetProps === void 0 ? void 0 : resetProps.form);
63
67
  var name = (formFieldProps === null || formFieldProps === void 0 ? void 0 : formFieldProps.name) || (resetProps === null || resetProps === void 0 ? void 0 : resetProps.name) || (resetProps === null || resetProps === void 0 ? void 0 : (_resetProps$id = resetProps.id) === null || _resetProps$id === void 0 ? void 0 : (_resetProps$id$split = _resetProps$id.split) === null || _resetProps$id$split === void 0 ? void 0 : _resetProps$id$split.call(_resetProps$id, '_'));
64
68
  var _formFieldProps$isVie = formFieldProps.isView,
@@ -72,6 +76,8 @@ var ProEditTable = function ProEditTable(_ref, ref) {
72
76
  disabled = (formFieldProps === null || formFieldProps === void 0 ? void 0 : formFieldProps.disabled) || disabled; // formFieldProps?.disabled可能是函数??
73
77
  }
74
78
  var tableRef = useRef(null);
79
+ var valueChangeRef = useRef(null);
80
+ valueChangeRef.current = 0;
75
81
  var _React$useContext = React.useContext(_ConfigProvider.ConfigContext),
76
82
  getPrefixCls = _React$useContext.getPrefixCls;
77
83
  var prefixCls = getPrefixCls();
@@ -262,24 +268,13 @@ var ProEditTable = function ProEditTable(_ref, ref) {
262
268
  }
263
269
  return null;
264
270
  };
271
+ useDeepCompareEffect(function () {
272
+ valueChangeRef.current += 1;
273
+ // 在这里根据需要计算新的数组
274
+ }, [value, config.name]);
265
275
  var _columns = useMemo(function () {
266
276
  return transformColumns(columns, config);
267
- }, [value, cellNamePath, forceUpdate, editingKeys, disabled, actionProps, columns, page, config.name]);
268
- // const setColumns = async () => {
269
- // const nextColumns = transformColumns(columns, config);
270
- // setState({
271
- // _columns: nextColumns,
272
- // });
273
- // };
274
- // useDebounceEffect(
275
- // () => {
276
- // setColumns();
277
- // },
278
- // [value, cellNamePath, forceUpdate, editingKeys, disabled, actionProps, columns, page], // columns更新修复外部表单无法控制内部表单的问题
279
- // {
280
- // wait: 60,
281
- // },
282
- // );
277
+ }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
283
278
  useEffect(function () {
284
279
  var isAllHasKey = value.every(function (item) {
285
280
  return item.rowKey;
@@ -310,6 +305,19 @@ var ProEditTable = function ProEditTable(_ref, ref) {
310
305
  setInternalState: setState
311
306
  };
312
307
  });
308
+ useEffect(function () {
309
+ if (toolbarSticky) {
310
+ var updatePos = function updatePos() {
311
+ var _affixRef$current;
312
+ affixRef === null || affixRef === void 0 ? void 0 : (_affixRef$current = affixRef.current) === null || _affixRef$current === void 0 ? void 0 : _affixRef$current.updatePosition();
313
+ };
314
+ window.addEventListener('scroll', updatePos, true);
315
+ return function () {
316
+ window.removeEventListener('scroll', updatePos, true);
317
+ };
318
+ }
319
+ }, [toolbarSticky]);
320
+ var _toolbarSticky = isBoolean(toolbarSticky) ? {} : toolbarSticky;
313
321
  var _summary = _typeof(summary) === 'object' ? function (data) {
314
322
  return _jsx(Summary, {
315
323
  data: data,
@@ -372,7 +380,14 @@ var ProEditTable = function ProEditTable(_ref, ref) {
372
380
  },
373
381
  summary: _summary
374
382
  }))]
375
- }), !isView && (value === null || value === void 0 ? void 0 : value.length) ? _jsx("div", {
383
+ }), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? _jsx(_Affix, _objectSpread(_objectSpread({
384
+ ref: affixRef
385
+ }, _toolbarSticky), {}, {
386
+ children: _jsx("div", {
387
+ className: "pro-edit-table-toolbar".concat(pagination ? ' pro-edit-table-toolbar-fixed' : ''),
388
+ children: _jsx(RenderToolbar, _objectSpread({}, config))
389
+ })
390
+ })) : _jsx("div", {
376
391
  className: "pro-edit-table-toolbar".concat(pagination ? ' pro-edit-table-toolbar-fixed' : ''),
377
392
  children: _jsx(RenderToolbar, _objectSpread({}, config))
378
393
  }) : null, footerRender ? _jsx("div", {
@@ -1,4 +1,4 @@
1
- import { ModalFuncProps } from 'antd';
1
+ import { AffixProps, ModalFuncProps } from 'antd';
2
2
  import { Key, ReactNode } from 'react';
3
3
  import { DragEndEvent } from '@dnd-kit/core';
4
4
  import type { ButtonProps } from 'antd/es/button';
@@ -231,6 +231,11 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
231
231
  * @default -
232
232
  */
233
233
  toolbarProps?: BaseActionProps<T>[] | boolean;
234
+ /**
235
+ * @description 自定义底部操作栏跟随页面滚动
236
+ * @default -
237
+ */
238
+ toolbarSticky?: boolean | Omit<AffixProps, 'children'>;
234
239
  /**
235
240
  * @description 最大可添加数量
236
241
  * @default -
@@ -303,6 +303,7 @@
303
303
  }
304
304
 
305
305
  .pro-edit-table-toolbar {
306
+ background-color: #fff;
306
307
  .@{ant-prefix}-space {
307
308
  gap: var(--zaui-space-size-sm, 8px);
308
309
 
@@ -256,6 +256,7 @@ export var transformColumns = function transformColumns() {
256
256
  var columnName = (item === null || item === void 0 ? void 0 : item.name) || dataIndex || key;
257
257
  item.dataIndex = columnName;
258
258
  item.key = columnName;
259
+ // item.shouldCellUpdate = item.shouldCellUpdate || ((record, perRecord) => !isEqual(record, perRecord));
259
260
  var required = isBoolean(item.required) ? item.required : false;
260
261
  if (typeof item.required === 'function') {
261
262
  var namePath = getNamePath(name, virtualKey);
@@ -23,7 +23,7 @@ var _components = require("./components");
23
23
  var _ProForm = _interopRequireDefault(require("../ProForm"));
24
24
  var _empty = _interopRequireDefault(require("../assets/empty.png"));
25
25
  var _locale = _interopRequireWildcard(require("../locale"));
26
- var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
26
+ var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
27
27
  var ProEditTable = function ProEditTable(_ref, ref) {
28
28
  var _resetProps$id, _resetProps$id$split, _themeConfig$data2, _value$;
29
29
  var value = _ref.value,
@@ -41,6 +41,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
41
41
  actionWidth = _ref.actionWidth,
42
42
  actionProps = _ref.actionProps,
43
43
  toolbarProps = _ref.toolbarProps,
44
+ toolbarSticky = _ref.toolbarSticky,
44
45
  rowSelection = _ref.rowSelection,
45
46
  onlyOneLineMsg = _ref.onlyOneLineMsg,
46
47
  deletePoConfirmMsg = _ref.deletePoConfirmMsg,
@@ -62,6 +63,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
62
63
  // 上下文form
63
64
  var contentForm = _antd.Form.useFormInstance();
64
65
  var formFieldProps = _ProForm.default.useFieldProps() || {};
66
+ var affixRef = (0, _react.useRef)(null);
65
67
  var form = contentForm || (formFieldProps === null || formFieldProps === void 0 ? void 0 : formFieldProps.form) || (resetProps === null || resetProps === void 0 ? void 0 : resetProps.form);
66
68
  var name = (formFieldProps === null || formFieldProps === void 0 ? void 0 : formFieldProps.name) || (resetProps === null || resetProps === void 0 ? void 0 : resetProps.name) || (resetProps === null || resetProps === void 0 ? void 0 : (_resetProps$id = resetProps.id) === null || _resetProps$id === void 0 ? void 0 : (_resetProps$id$split = _resetProps$id.split) === null || _resetProps$id$split === void 0 ? void 0 : _resetProps$id$split.call(_resetProps$id, '_'));
67
69
  var _formFieldProps$isVie = formFieldProps.isView,
@@ -75,6 +77,8 @@ var ProEditTable = function ProEditTable(_ref, ref) {
75
77
  disabled = (formFieldProps === null || formFieldProps === void 0 ? void 0 : formFieldProps.disabled) || disabled; // formFieldProps?.disabled可能是函数??
76
78
  }
77
79
  var tableRef = (0, _react.useRef)(null);
80
+ var valueChangeRef = (0, _react.useRef)(null);
81
+ valueChangeRef.current = 0;
78
82
  var _React$useContext = _react.default.useContext(_antd.ConfigProvider.ConfigContext),
79
83
  getPrefixCls = _React$useContext.getPrefixCls;
80
84
  var prefixCls = getPrefixCls();
@@ -265,24 +269,13 @@ var ProEditTable = function ProEditTable(_ref, ref) {
265
269
  }
266
270
  return null;
267
271
  };
272
+ (0, _ahooks.useDeepCompareEffect)(function () {
273
+ valueChangeRef.current += 1;
274
+ // 在这里根据需要计算新的数组
275
+ }, [value, config.name]);
268
276
  var _columns = (0, _react.useMemo)(function () {
269
277
  return (0, _utils.transformColumns)(columns, config);
270
- }, [value, cellNamePath, forceUpdate, editingKeys, disabled, actionProps, columns, page, config.name]);
271
- // const setColumns = async () => {
272
- // const nextColumns = transformColumns(columns, config);
273
- // setState({
274
- // _columns: nextColumns,
275
- // });
276
- // };
277
- // useDebounceEffect(
278
- // () => {
279
- // setColumns();
280
- // },
281
- // [value, cellNamePath, forceUpdate, editingKeys, disabled, actionProps, columns, page], // columns更新修复外部表单无法控制内部表单的问题
282
- // {
283
- // wait: 60,
284
- // },
285
- // );
278
+ }, [valueChangeRef.current, disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
286
279
  (0, _react.useEffect)(function () {
287
280
  var isAllHasKey = value.every(function (item) {
288
281
  return item.rowKey;
@@ -313,6 +306,19 @@ var ProEditTable = function ProEditTable(_ref, ref) {
313
306
  setInternalState: setState
314
307
  };
315
308
  });
309
+ (0, _react.useEffect)(function () {
310
+ if (toolbarSticky) {
311
+ var updatePos = function updatePos() {
312
+ var _affixRef$current;
313
+ affixRef === null || affixRef === void 0 ? void 0 : (_affixRef$current = affixRef.current) === null || _affixRef$current === void 0 ? void 0 : _affixRef$current.updatePosition();
314
+ };
315
+ window.addEventListener('scroll', updatePos, true);
316
+ return function () {
317
+ window.removeEventListener('scroll', updatePos, true);
318
+ };
319
+ }
320
+ }, [toolbarSticky]);
321
+ var _toolbarSticky = (0, _lodash.isBoolean)(toolbarSticky) ? {} : toolbarSticky;
316
322
  var _summary = (0, _typeof2.default)(summary) === 'object' ? function (data) {
317
323
  return (0, _jsxRuntime.jsx)(_components.Summary, {
318
324
  data: data,
@@ -375,7 +381,14 @@ var ProEditTable = function ProEditTable(_ref, ref) {
375
381
  },
376
382
  summary: _summary
377
383
  }))]
378
- }), !isView && (value === null || value === void 0 ? void 0 : value.length) ? (0, _jsxRuntime.jsx)("div", {
384
+ }), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? (0, _jsxRuntime.jsx)(_antd.Affix, (0, _objectSpread2.default)((0, _objectSpread2.default)({
385
+ ref: affixRef
386
+ }, _toolbarSticky), {}, {
387
+ children: (0, _jsxRuntime.jsx)("div", {
388
+ className: "pro-edit-table-toolbar".concat(pagination ? ' pro-edit-table-toolbar-fixed' : ''),
389
+ children: (0, _jsxRuntime.jsx)(_components.RenderToolbar, (0, _objectSpread2.default)({}, config))
390
+ })
391
+ })) : (0, _jsxRuntime.jsx)("div", {
379
392
  className: "pro-edit-table-toolbar".concat(pagination ? ' pro-edit-table-toolbar-fixed' : ''),
380
393
  children: (0, _jsxRuntime.jsx)(_components.RenderToolbar, (0, _objectSpread2.default)({}, config))
381
394
  }) : null, footerRender ? (0, _jsxRuntime.jsx)("div", {
@@ -1,4 +1,4 @@
1
- import { ModalFuncProps } from 'antd';
1
+ import { AffixProps, ModalFuncProps } from 'antd';
2
2
  import { Key, ReactNode } from 'react';
3
3
  import { DragEndEvent } from '@dnd-kit/core';
4
4
  import type { ButtonProps } from 'antd/es/button';
@@ -231,6 +231,11 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
231
231
  * @default -
232
232
  */
233
233
  toolbarProps?: BaseActionProps<T>[] | boolean;
234
+ /**
235
+ * @description 自定义底部操作栏跟随页面滚动
236
+ * @default -
237
+ */
238
+ toolbarSticky?: boolean | Omit<AffixProps, 'children'>;
234
239
  /**
235
240
  * @description 最大可添加数量
236
241
  * @default -
@@ -303,6 +303,7 @@
303
303
  }
304
304
 
305
305
  .pro-edit-table-toolbar {
306
+ background-color: #fff;
306
307
  .@{ant-prefix}-space {
307
308
  gap: var(--zaui-space-size-sm, 8px);
308
309
 
@@ -260,6 +260,7 @@ var transformColumns = exports.transformColumns = function transformColumns() {
260
260
  var columnName = (item === null || item === void 0 ? void 0 : item.name) || dataIndex || key;
261
261
  item.dataIndex = columnName;
262
262
  item.key = columnName;
263
+ // item.shouldCellUpdate = item.shouldCellUpdate || ((record, perRecord) => !isEqual(record, perRecord));
263
264
  var required = (0, _lodash.isBoolean)(item.required) ? item.required : false;
264
265
  if (typeof item.required === 'function') {
265
266
  var namePath = (0, _tools.getNamePath)(name, virtualKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.5.5-beta.9",
3
+ "version": "3.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",