@zat-design/sisyphus-react 3.10.3 → 3.10.4-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.
Files changed (47) hide show
  1. package/dist/index.esm.css +6 -0
  2. package/dist/less.esm.css +6 -0
  3. package/es/ProEditTable/components/RcTable/VirtualTable.d.ts +2 -5
  4. package/es/ProEditTable/components/RcTable/VirtualTable.js +5 -163
  5. package/es/ProEditTable/components/RcTable/index.d.ts +1 -1
  6. package/es/ProEditTable/components/RcTable/index.js +1 -1
  7. package/es/ProEditTable/components/RenderField/index.js +2 -2
  8. package/es/ProEditTable/index.js +44 -13
  9. package/es/ProEditTable/propsType.d.ts +0 -1
  10. package/es/ProEditTable/style/index.less +3 -1
  11. package/es/ProEditTable/utils/config.d.ts +1 -1
  12. package/es/ProEditTable/utils/config.js +11 -3
  13. package/es/ProEditTable/utils/index.js +0 -71
  14. package/es/ProForm/components/base/InputNumber/index.js +2 -1
  15. package/es/ProForm/components/render/ConfirmWrapper.js +41 -21
  16. package/es/ProSelect/index.js +31 -6
  17. package/es/ProStep/components/Item/index.d.ts +3 -3
  18. package/es/ProStep/components/Item/index.js +22 -6
  19. package/es/ProStep/index.d.ts +1 -1
  20. package/es/ProStep/propsType.d.ts +4 -1
  21. package/es/ProTable/hooks/useAntdTable.js +45 -46
  22. package/es/ProTable/style/index.less +3 -1
  23. package/es/ProTable/utils/index.d.ts +2 -0
  24. package/es/ProTable/utils/index.js +5 -0
  25. package/lib/ProEditTable/components/RcTable/VirtualTable.d.ts +2 -5
  26. package/lib/ProEditTable/components/RcTable/VirtualTable.js +3 -161
  27. package/lib/ProEditTable/components/RcTable/index.d.ts +1 -1
  28. package/lib/ProEditTable/components/RenderField/index.js +2 -2
  29. package/lib/ProEditTable/index.js +43 -12
  30. package/lib/ProEditTable/propsType.d.ts +0 -1
  31. package/lib/ProEditTable/style/index.less +3 -1
  32. package/lib/ProEditTable/utils/config.d.ts +1 -1
  33. package/lib/ProEditTable/utils/config.js +11 -3
  34. package/lib/ProEditTable/utils/index.js +0 -71
  35. package/lib/ProForm/components/base/InputNumber/index.js +2 -1
  36. package/lib/ProForm/components/render/ConfirmWrapper.js +41 -21
  37. package/lib/ProSelect/index.js +30 -5
  38. package/lib/ProStep/components/Item/index.d.ts +3 -3
  39. package/lib/ProStep/components/Item/index.js +22 -6
  40. package/lib/ProStep/index.d.ts +1 -1
  41. package/lib/ProStep/propsType.d.ts +4 -1
  42. package/lib/ProTable/hooks/useAntdTable.js +42 -43
  43. package/lib/ProTable/style/index.less +3 -1
  44. package/lib/ProTable/utils/index.d.ts +2 -0
  45. package/lib/ProTable/utils/index.js +6 -1
  46. package/package.json +7 -6
  47. package/.vscode/extensions.json +0 -5
@@ -12,7 +12,7 @@ import _Select from "antd/es/select";
12
12
  var _excluded = ["dataSource", "defaultDisableValue", "useRequest", "fieldNames", "tooltip", "otherProps", "labelInValue", "filterInList", "scrollFollowParent", "defaultOne", "onSearch", "optionRender", "onChange", "updateDataSource", "transformResponse", "getValueProps", "isView"];
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { useDeepCompareEffect, useRequest as useRequestFunc } from 'ahooks';
15
- import React, { useImperativeHandle, useState, forwardRef, isValidElement } from 'react';
15
+ import React, { useImperativeHandle, useState, forwardRef, isValidElement, useCallback } from 'react';
16
16
  import { isFunction, isObject, isString, omit, isNumber } from 'lodash';
17
17
  import { useProConfig } from '../ProConfigProvider';
18
18
  import Container from '../ProForm/components/Container';
@@ -23,7 +23,7 @@ import { getSelectList } from './utils';
23
23
  import './index.less';
24
24
  var Option = _Select.Option;
25
25
  export var ProSelect = function ProSelect(props, ref) {
26
- var _selectProps$showCode, _locale$ProSelect;
26
+ var _selectProps$showCode, _useRequest$options, _locale$ProSelect;
27
27
  var _ref = useProConfig('ProSelect') || {},
28
28
  _ref$fieldNames = _ref.fieldNames,
29
29
  proSelectFieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
@@ -87,6 +87,21 @@ export var ProSelect = function ProSelect(props, ref) {
87
87
  }
88
88
  setSelectList(data || []);
89
89
  };
90
+ var successTransformDataHandle = useCallback(function (res) {
91
+ if (transformResponse && typeof transformResponse === 'function') {
92
+ return transformResponse(res);
93
+ }
94
+ var _ref3 = res || {},
95
+ _ref3$status = _ref3.status,
96
+ status = _ref3$status === void 0 ? 200 : _ref3$status,
97
+ msg = _ref3.message,
98
+ data = _ref3.data;
99
+ if (status !== 200) {
100
+ _message.error(msg);
101
+ return;
102
+ }
103
+ return data;
104
+ }, []);
90
105
  var fetchFunction = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread({
91
106
  manual: true,
92
107
  onSuccess: function onSuccess(data) {
@@ -100,6 +115,7 @@ export var ProSelect = function ProSelect(props, ref) {
100
115
  },
101
116
  debounceWait: 300
102
117
  }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options));
118
+ var cacheList = (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options = useRequest.options) === null || _useRequest$options === void 0 ? void 0 : _useRequest$options.cacheKey) ? successTransformDataHandle(fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data) : [];
103
119
  var getValueObject = function getValueObject(input) {
104
120
  if (Array.isArray(input) && input.length) {
105
121
  var resArr = [];
@@ -124,15 +140,24 @@ export var ProSelect = function ProSelect(props, ref) {
124
140
  useDeepCompareEffect(function () {
125
141
  setSelectList(dataSource);
126
142
  }, [dataSource]);
143
+ useDeepCompareEffect(function () {
144
+ var _useRequest$options2;
145
+ // 设置cacheKey后使用缓存的数据
146
+ if (!(selectList === null || selectList === void 0 ? void 0 : selectList.length) && (useRequest === null || useRequest === void 0 ? void 0 : (_useRequest$options2 = useRequest.options) === null || _useRequest$options2 === void 0 ? void 0 : _useRequest$options2.cacheKey)) {
147
+ if (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length) {
148
+ setSelectList(cacheList);
149
+ }
150
+ }
151
+ }, [fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.data]);
127
152
  useDeepCompareEffect(function () {
128
153
  // 默认disable值时,不查询接口
129
154
  if (defaultDisableValue || !useRequest) {
130
155
  return;
131
156
  }
132
- var _ref3 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
133
- defaultParams = _ref3.defaultParams,
134
- manual = _ref3.manual;
135
- if (manual) {
157
+ var _ref4 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
158
+ defaultParams = _ref4.defaultParams,
159
+ manual = _ref4.manual;
160
+ if (manual || (cacheList === null || cacheList === void 0 ? void 0 : cacheList.length)) {
136
161
  return;
137
162
  }
138
163
  fetchFunction.run(defaultParams);
@@ -1,3 +1,3 @@
1
- import { ProStepItem } from '../../propsType';
2
- declare const _default: ({ id, title, collapse: collapseItem, children, ...restProps }: ProStepItem) => import("react/jsx-runtime").JSX.Element;
3
- export default _default;
1
+ import { ProStepItemPropsType } from '../../propsType';
2
+ declare const ProStepItem: ({ id, title, collapse: collapseItem, children, ...restProps }: ProStepItemPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default ProStepItem;
@@ -3,9 +3,16 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
3
3
  var _excluded = ["id", "title", "collapse", "children"];
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
5
  import { useEffect } from 'react';
6
+ import LazyLoad from 'react-lazyload';
7
+ import { isBoolean } from 'lodash';
6
8
  import { useStep } from '../../index';
7
9
  import ProCollapse from '../../../ProLayout/components/ProCollapse';
8
- export default (function (_ref) {
10
+ var defaultLazyLoadConfig = {
11
+ height: 100,
12
+ offset: 100,
13
+ once: true // 保证只在首次进入视口时触发懒加载
14
+ };
15
+ var ProStepItem = function ProStepItem(_ref) {
9
16
  var id = _ref.id,
10
17
  title = _ref.title,
11
18
  _ref$collapse = _ref.collapse,
@@ -16,7 +23,7 @@ export default (function (_ref) {
16
23
  register = _useStep.register,
17
24
  collapse = _useStep.collapse;
18
25
  useEffect(function () {
19
- // 子组件更新父组件 延迟状态更新,避免重渲染
26
+ // 延迟更新父组件状态,避免重渲染
20
27
  var timeoutId = setTimeout(function () {
21
28
  register === null || register === void 0 ? void 0 : register(_objectSpread(_objectSpread({}, restProps), {}, {
22
29
  title: title,
@@ -27,15 +34,24 @@ export default (function (_ref) {
27
34
  return clearTimeout(timeoutId);
28
35
  };
29
36
  }, [register]);
37
+ var childrenRender = function childrenRender() {
38
+ if (restProps === null || restProps === void 0 ? void 0 : restProps.lazyLoad) {
39
+ var lazyLoadProps = isBoolean(restProps === null || restProps === void 0 ? void 0 : restProps.lazyLoad) ? defaultLazyLoadConfig : restProps.lazyLoad;
40
+ return _jsx(LazyLoad, _objectSpread(_objectSpread({}, lazyLoadProps), {}, {
41
+ children: children
42
+ }));
43
+ }
44
+ return children;
45
+ };
30
46
  return _jsx("div", {
31
47
  className: "pro-step-item",
32
48
  id: id,
33
49
  children: !register || collapse && collapseItem && title ? _jsx(ProCollapse, _objectSpread(_objectSpread({
34
- id: id,
35
50
  title: title,
36
51
  icon: true
37
52
  }, restProps), {}, {
38
- children: children
39
- })) : children
53
+ children: childrenRender()
54
+ })) : childrenRender()
40
55
  });
41
- });
56
+ };
57
+ export default ProStepItem;
@@ -6,7 +6,7 @@ export declare const useStep: () => any;
6
6
  declare const ProStep: {
7
7
  ({ children, ...resetProps }: ProStepPropsType): import("react/jsx-runtime").JSX.Element;
8
8
  useStep: () => any;
9
- Item: ({ id, title, collapse: collapseItem, children, ...restProps }: import("./propsType").ProStepItem) => import("react/jsx-runtime").JSX.Element;
9
+ Item: ({ id, title, collapse: collapseItem, children, ...restProps }: import("./propsType").ProStepItemPropsType) => import("react/jsx-runtime").JSX.Element;
10
10
  Listener: ({ children, delayTime, excludes, ...props }: any) => import("react").DetailedReactHTMLElement<any, HTMLElement>;
11
11
  };
12
12
  export default ProStep;
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import { LazyLoadProps } from 'react-lazyload';
2
3
  export interface ItemType {
3
4
  name: string;
4
5
  code: string;
@@ -22,10 +23,12 @@ export interface ProStepPropsType {
22
23
  /** @name 是否滚动到第一个报错 */
23
24
  scrollToError?: boolean;
24
25
  }
25
- export interface ProStepItem {
26
+ export interface ProStepItemPropsType {
26
27
  id: string;
27
28
  title?: string;
28
29
  collapse?: boolean;
29
30
  order?: number;
31
+ /** 模块可视区域懒加载 */
32
+ lazyLoad?: boolean | LazyLoadProps;
30
33
  [key: string]: any;
31
34
  }
@@ -7,11 +7,11 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
7
7
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
8
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
9
  var _excluded = ["page", "filters", "sorter"];
10
- import { useCallback, useMemo, useState } from 'react';
11
- import { useRequest, useSetState, useDeepCompareEffect } from 'ahooks';
10
+ import { useCallback, useEffect, useMemo, useState } from 'react';
11
+ import { useRequest, useSetState, useDeepCompareEffect, usePrevious } from 'ahooks';
12
12
  import { pickBy, isObject, merge, set, isEqual } from 'lodash';
13
13
  import { defaultPage } from '../index';
14
- import { isListResult, removeEmptyKeys } from '../utils';
14
+ import { isListResult, removeEmptyKeys, isNonEmptyObject } from '../utils';
15
15
  import locale, { formatMessage } from '../../locale';
16
16
  var useDefaultOptions = function useDefaultOptions(options) {
17
17
  var _useState = useState((options === null || options === void 0 ? void 0 : options.page) || defaultPage),
@@ -24,6 +24,7 @@ var useDefaultOptions = function useDefaultOptions(options) {
24
24
  onPageChange: (options === null || options === void 0 ? void 0 : options.onPageChange) || onPageChange
25
25
  });
26
26
  };
27
+ var previousSearchValues = null;
27
28
  function useAntdTable(service, options, useRequestOptions) {
28
29
  var _locale$ProTable2, _locale$ProTable3, _locale$ProTable4, _locale$ProTable5;
29
30
  var _useSetState = useSetState({
@@ -32,7 +33,10 @@ function useAntdTable(service, options, useRequestOptions) {
32
33
  selectedRecords: [],
33
34
  selectedRowKeys: [],
34
35
  searchValues: undefined,
35
- extraFilter: undefined,
36
+ extraFilter: {
37
+ filters: undefined,
38
+ sorter: undefined
39
+ },
36
40
  allSelected: false
37
41
  }),
38
42
  _useSetState2 = _slicedToArray(_useSetState, 2),
@@ -63,10 +67,10 @@ function useAntdTable(service, options, useRequestOptions) {
63
67
  transformResponse = _useDefaultOptions.transformResponse,
64
68
  disabled = _useDefaultOptions.disabled;
65
69
  var _ref = useRequestOptions || {},
66
- defaultParams = _ref.defaultParams,
67
- manual = _ref.manual;
70
+ defaultParams = _ref.defaultParams;
68
71
  var defaultParam = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
69
72
  var initPage = (options === null || options === void 0 ? void 0 : options.page) || defaultPage;
73
+ var previousPage = usePrevious(page || defaultPage);
70
74
  var getTransformParams = useCallback(function (params) {
71
75
  var _pickBy;
72
76
  var realParams = _objectSpread(_objectSpread(_objectSpread({}, defaultParam), extraParams), params);
@@ -105,9 +109,17 @@ function useAntdTable(service, options, useRequestOptions) {
105
109
  page: page
106
110
  }, newQueryBean));
107
111
  }, [page, searchValues, extraFilter]);
112
+ var curService = useMemo(function () {
113
+ return service.toString();
114
+ }, [service]);
115
+ var curExtraParams = useMemo(function () {
116
+ return extraParams ? JSON.stringify(extraParams) : extraParams;
117
+ }, [extraParams]);
108
118
  // 调接口
109
- var result = useRequest(service, _objectSpread(_objectSpread({}, useRequestOptions), {}, {
110
- debounceWait: 50,
119
+ var result = useRequest(service, _objectSpread(_objectSpread({
120
+ debounceWait: 300,
121
+ refreshDeps: [curService, curExtraParams]
122
+ }, useRequestOptions), {}, {
111
123
  defaultParams: [getTransformParams()],
112
124
  onSuccess: function onSuccess(res, params) {
113
125
  var transformResult = transformResponse ? transformResponse(res) : res || {};
@@ -131,9 +143,6 @@ function useAntdTable(service, options, useRequestOptions) {
131
143
  }));
132
144
  var run = result.run,
133
145
  refreshAsync = result.refreshAsync;
134
- var curService = useMemo(function () {
135
- return service.toString();
136
- }, [service]);
137
146
  // service变化时触发 (禁止掉防止service变更时导致的死循环)
138
147
  var clearSelected = useCallback(function () {
139
148
  setState({
@@ -172,6 +181,12 @@ function useAntdTable(service, options, useRequestOptions) {
172
181
  setState(nextObject);
173
182
  }
174
183
  }, [allSelected, data]);
184
+ // 释放
185
+ useEffect(function () {
186
+ return function () {
187
+ previousSearchValues = null;
188
+ };
189
+ }, []);
175
190
  // 分页变更
176
191
  var handlePageChange = useCallback(function (current, pageSize) {
177
192
  var page = {
@@ -213,26 +228,32 @@ function useAntdTable(service, options, useRequestOptions) {
213
228
  filters: filters,
214
229
  sorter: sorter
215
230
  })));
216
- }, [allSelected, searchValues, run, getTransformParams]);
231
+ }, [allSelected, searchValues, getTransformParams]);
217
232
  var onSearch = useCallback(function (values) {
218
233
  var newPage = {
219
234
  pageNum: 1,
220
235
  pageSize: page.pageSize
221
236
  };
222
237
  var _values = removeEmptyKeys(values);
223
- onPageChange(newPage);
224
- setState({
225
- searchValues: _values,
226
- allSelected: false,
227
- selectedRecords: [],
228
- selectedRowKeys: []
229
- });
238
+ // 如果 previousPage 存在且与 page 不相等,则触发页面变化
239
+ if (previousPage && !isEqual(previousPage, page)) {
240
+ onPageChange(newPage);
241
+ }
242
+ // 减少查询按钮的渲染,只有需要重置值时才需要调用
243
+ if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) || isNonEmptyObject(_values) && !isEqual(previousSearchValues, _values)) {
244
+ previousSearchValues = _values;
245
+ setState({
246
+ searchValues: _values,
247
+ allSelected: false,
248
+ selectedRecords: [],
249
+ selectedRowKeys: []
250
+ });
251
+ }
230
252
  run(getTransformParams(_objectSpread(_objectSpread({
231
253
  page: newPage
232
254
  }, extraFilter), _values)));
233
- }, [extraFilter, page.pageSize, run, getTransformParams]);
234
- var resetParams = useCallback(function () {
235
- var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initPage;
255
+ }, [extraFilter, page.pageSize, previousPage, getTransformParams]);
256
+ var resetParams = useCallback(function (page) {
236
257
  setState({
237
258
  searchValues: undefined,
238
259
  allSelected: false,
@@ -302,28 +323,6 @@ function useAntdTable(service, options, useRequestOptions) {
302
323
  return _ref4.apply(this, arguments);
303
324
  };
304
325
  }();
305
- useDeepCompareEffect(function () {
306
- if (!manual && curService) {
307
- // service改变时重新请求
308
- resetParams();
309
- onPageChange(initPage);
310
- run(getTransformParams());
311
- }
312
- }, [curService]);
313
- useDeepCompareEffect(function () {
314
- // extraParams改变时重新请求
315
- if (!manual && extraParams) {
316
- var newPage = {
317
- pageNum: 1,
318
- pageSize: page.pageSize
319
- };
320
- onPageChange(newPage);
321
- resetParams(newPage);
322
- run(getTransformParams({
323
- page: newPage
324
- }));
325
- }
326
- }, [extraParams]);
327
326
  var _rowSelection = {
328
327
  fixed: true,
329
328
  type: rowSelectType,
@@ -449,8 +448,8 @@ function useAntdTable(service, options, useRequestOptions) {
449
448
  });
450
449
  }
451
450
  }
452
- var selectedTip = allSelected || selectedRowKeys.length ? formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProTable5 = locale.ProTable) === null || _locale$ProTable5 === void 0 ? void 0 : _locale$ProTable5.selectAll, {
453
- selectedNum: allSelected ? total : selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length
451
+ var selectedTip = allSelected && selectedRowKeys.length ? formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProTable5 = locale.ProTable) === null || _locale$ProTable5 === void 0 ? void 0 : _locale$ProTable5.selectAll, {
452
+ total: allSelected ? total : selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length
454
453
  }) : null;
455
454
  var pagination = {
456
455
  current: page.pageNum,
@@ -585,7 +585,9 @@
585
585
 
586
586
  .@{ant-prefix}-table-summary {
587
587
  background-color: var(--zaui-table-header-bg, #f2f3f5);
588
-
588
+ td{
589
+ padding:calc(4px + var(--zaui-size)* 8px);
590
+ }
589
591
  .@{ant-prefix}-table-cell {
590
592
  font-weight: 500;
591
593
  background-color: var(--zaui-table-header-bg, #f2f3f5);
@@ -39,3 +39,5 @@ export declare const getPadding: (el: HTMLElement) => {
39
39
  pTop: number;
40
40
  pBottom: number;
41
41
  };
42
+ /** 判断是有值的对象 */
43
+ export declare const isNonEmptyObject: (obj: any) => obj is Record<string, any>;
@@ -1,3 +1,4 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
1
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
3
  import { get, isEqual } from 'lodash';
3
4
  import { validate } from '@zat-design/utils';
@@ -99,4 +100,8 @@ export var getPadding = function getPadding(el) {
99
100
  pTop: paddingTop,
100
101
  pBottom: paddingBottom
101
102
  };
103
+ };
104
+ /** 判断是有值的对象 */
105
+ export var isNonEmptyObject = function isNonEmptyObject(obj) {
106
+ return obj !== null && _typeof(obj) === 'object' && !Array.isArray(obj) && Object.keys(obj).length > 0;
102
107
  };
@@ -1,6 +1,3 @@
1
- import React from 'react';
2
- declare const _default: React.MemoExoticComponent<({ tableProps, ...resetProps }: {
3
- [x: string]: any;
4
- tableProps: any;
5
- }) => import("react/jsx-runtime").JSX.Element>;
1
+ /// <reference types="react" />
2
+ declare const _default: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
6
3
  export default _default;
@@ -1,172 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
7
  var _jsxRuntime = require("react/jsx-runtime");
12
- var _antd = require("antd");
13
8
  var _react = require("react");
14
- var _classnames = _interopRequireDefault(require("classnames"));
15
- var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
16
- var _reactWindow = require("react-window");
17
- var _excluded = ["tableProps"];
18
- var VirtualTable = function VirtualTable(_ref) {
19
- var _value$;
20
- var tableProps = _ref.tableProps,
21
- resetProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
22
- var value = tableProps.value,
23
- headerRender = tableProps.headerRender,
24
- tableRef = tableProps.tableRef,
25
- className = tableProps.className,
26
- columns = tableProps.columns,
27
- renderRowSelection = tableProps.renderRowSelection,
28
- rowClassName = tableProps.rowClassName,
29
- disabled = tableProps.disabled,
30
- virtualKey = tableProps.virtualKey,
31
- editingKeys = tableProps.editingKeys,
32
- isHideCheckBox = tableProps.isHideCheckBox,
33
- rowDraggable = tableProps.rowDraggable,
34
- scroll = tableProps.scroll,
35
- summary = tableProps.summary;
36
- var _useState = (0, _react.useState)(0),
37
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
38
- tableWidth = _useState2[0],
39
- setTableWidth = _useState2[1];
40
- var widthColumnCount = columns.filter(function (_ref2) {
41
- var width = _ref2.width;
42
- return !width;
43
- }).length;
44
- var mergedColumns = columns.map(function (column) {
45
- if (column.width) {
46
- return column;
47
- }
48
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
49
- width: Math.floor(tableWidth / widthColumnCount)
50
- });
51
- });
52
- var gridRef = (0, _react.useRef)();
53
- var _useState3 = (0, _react.useState)(function () {
54
- var obj = {};
55
- Object.defineProperty(obj, 'scrollLeft', {
56
- get: function get() {
57
- if (gridRef.current) {
58
- var _gridRef$current, _gridRef$current$stat;
59
- return (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : (_gridRef$current$stat = _gridRef$current.state) === null || _gridRef$current$stat === void 0 ? void 0 : _gridRef$current$stat.scrollLeft;
60
- }
61
- return null;
62
- },
63
- set: function set(scrollLeft) {
64
- if (gridRef.current) {
65
- gridRef.current.scrollTo({
66
- scrollLeft: scrollLeft
67
- });
68
- }
69
- }
70
- });
71
- return obj;
72
- }),
73
- _useState4 = (0, _slicedToArray2.default)(_useState3, 1),
74
- connectObject = _useState4[0];
75
- var resetVirtualGrid = function resetVirtualGrid() {
76
- var _gridRef$current2;
77
- (_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.resetAfterIndices({
78
- columnIndex: 0,
79
- shouldForceUpdate: true
80
- });
81
- };
82
- (0, _react.useEffect)(function () {
83
- return resetVirtualGrid;
84
- }, [tableWidth]);
85
- var renderVirtualList = function renderVirtualList(rawData, _ref3) {
86
- var scrollbarSize = _ref3.scrollbarSize,
87
- ref = _ref3.ref,
88
- _onScroll = _ref3.onScroll;
89
- ref.current = connectObject;
90
- var totalHeight = rawData.length * 54;
91
- return (0, _jsxRuntime.jsx)(_reactWindow.VariableSizeGrid, {
92
- ref: gridRef,
93
- className: "virtual-grid",
94
- columnCount: mergedColumns.length,
95
- columnWidth: function columnWidth(index) {
96
- var _width2;
97
- var width = mergedColumns[index].width;
98
- var _width = width;
99
- if (typeof _width === 'string' && ((_width2 = _width) === null || _width2 === void 0 ? void 0 : _width2.includes('px'))) {
100
- _width = parseInt(width, 10);
101
- }
102
- return totalHeight > scroll.y && index === mergedColumns.length - 1 ? _width - scrollbarSize - 1 : _width;
103
- },
104
- height: scroll.y,
105
- rowCount: rawData.length,
106
- rowHeight: function rowHeight() {
107
- return 54;
108
- },
109
- width: tableWidth,
110
- onScroll: function onScroll(_ref4) {
111
- var scrollLeft = _ref4.scrollLeft;
112
- _onScroll({
113
- scrollLeft: scrollLeft
114
- });
115
- },
116
- children: function children(_ref5) {
117
- var columnIndex = _ref5.columnIndex,
118
- rowIndex = _ref5.rowIndex,
119
- style = _ref5.style;
120
- return (0, _jsxRuntime.jsx)("div", {
121
- className: (0, _classnames.default)('virtual-table-cell', {
122
- 'virtual-table-cell-last': columnIndex === mergedColumns.length - 1
123
- }),
124
- style: style,
125
- children: rawData[rowIndex][mergedColumns[columnIndex].dataIndex]
126
- });
127
- }
128
- });
129
- };
130
- return (0, _jsxRuntime.jsxs)(_rcResizeObserver.default, {
131
- onResize: function onResize(_ref6) {
132
- var _width3;
133
- var width = _ref6.width;
134
- var _width = width;
135
- if (typeof _width === 'string' && ((_width3 = _width) === null || _width3 === void 0 ? void 0 : _width3.includes('px'))) {
136
- _width = parseInt(width, 10);
137
- }
138
- setTableWidth(_width);
139
- },
140
- children: [headerRender ? (0, _jsxRuntime.jsx)("div", {
141
- className: "pro-edit-table-header",
142
- children: typeof headerRender === 'function' ? headerRender() : headerRender
143
- }) : null, (0, _jsxRuntime.jsx)(_antd.Table, (0, _objectSpread2.default)((0, _objectSpread2.default)({
144
- ref: tableRef,
145
- className: className,
146
- dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
147
- columns: mergedColumns,
148
- rowSelection: renderRowSelection(),
149
- rowClassName: rowClassName,
150
- components: {
151
- body: renderVirtualList
152
- },
153
- onRow: function onRow() {
154
- return {
155
- disabled: disabled || virtualKey && !!editingKeys.length,
156
- 'data-hide': isHideCheckBox,
157
- 'data-row-draggable': rowDraggable,
158
- onClick: function onClick() {}
159
- };
160
- }
161
- }, resetProps), {}, {
162
- pagination: false,
163
- rowKey: "rowKey",
164
- scroll: {
165
- x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
166
- y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
167
- },
168
- summary: summary
169
- }))]
9
+ var VirtualTable = function VirtualTable() {
10
+ return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
11
+ children: "\u6682\u65F6\u4E0D\u4F7F\u7528\uFF0C\u53EF\u4EE5\u7B49\u5347\u7EA7antd5\u4F7F\u7528\u5BF9\u5E94\u7684\u80FD\u529B"
170
12
  });
171
13
  };
172
14
  var _default = exports.default = /*#__PURE__*/(0, _react.memo)(VirtualTable);
@@ -2,5 +2,5 @@
2
2
  export { default as BaseTable } from './BaseTable';
3
3
  /** 拖拽表格 */
4
4
  export { default as DraggableTable } from './DraggableTable';
5
- /** 虚拟列表表格 */
5
+ /** 虚拟列表表格, 暂时移除 */
6
6
  export { default as VirtualTable } from './VirtualTable';
@@ -595,7 +595,7 @@ var RenderField = function RenderField(_ref) {
595
595
  }
596
596
  FormItem = TargetComponent ? (0, _jsxRuntime.jsx)(_antd.Form.Item, (0, _objectSpread2.default)((0, _objectSpread2.default)({
597
597
  validateFirst: true
598
- }, (0, _lodash.omit)(_formItemProps, ['render', 'cache', 'key', 'width', 'hiddenNames', 'name', 'onCell', _fieldProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
598
+ }, (0, _lodash.omit)(_formItemProps, ['render', 'key', 'width', 'hiddenNames', 'name', 'onCell', _fieldProps.shouldUpdate ? 'shouldUpdate' : null])), {}, {
599
599
  className: _className,
600
600
  name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName,
601
601
  children: FieldComponent
@@ -605,7 +605,7 @@ var RenderField = function RenderField(_ref) {
605
605
  if (type === 'FormList') {
606
606
  FormItem = (0, _jsxRuntime.jsx)(_antd.Form.List, (0, _objectSpread2.default)((0, _objectSpread2.default)({
607
607
  name: formNamePath ? cellName.slice((formNamePath === null || formNamePath === void 0 ? void 0 : formNamePath.length) - 1) : cellName
608
- }, (0, _lodash.omit)(_formItemProps, ['render', 'cache', 'key', 'width', 'hiddenNames', 'name'])), {}, {
608
+ }, (0, _lodash.omit)(_formItemProps, ['render', 'key', 'width', 'hiddenNames', 'name'])), {}, {
609
609
  children: function children(fields, operation, meta) {
610
610
  return (0, _jsxRuntime.jsx)(TargetComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, componentProps), {}, {
611
611
  otherProps: otherProps,