@zat-design/sisyphus-react 3.10.4 → 3.11.1
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/dist/index.esm.css +8 -0
- package/dist/less.esm.css +8 -0
- package/es/ProEditTable/components/RcTable/BaseTable.js +13 -2
- package/es/ProEditTable/components/RcTable/VirtualTable.d.ts +2 -5
- package/es/ProEditTable/components/RcTable/VirtualTable.js +5 -163
- package/es/ProEditTable/components/RcTable/index.d.ts +1 -1
- package/es/ProEditTable/components/RcTable/index.js +1 -1
- package/es/ProEditTable/index.js +20 -4
- package/es/ProEditTable/propsType.d.ts +1 -0
- package/es/ProEditTable/style/index.less +8 -0
- package/es/ProEditTable/utils/tools.d.ts +9 -0
- package/es/ProEditTable/utils/tools.js +277 -2
- package/es/ProForm/components/base/InputNumber/index.js +2 -1
- package/es/ProForm/utils/useForm.js +12 -6
- package/es/ProStep/components/Item/index.d.ts +3 -3
- package/es/ProStep/components/Item/index.js +51 -16
- package/es/ProStep/components/Listener/index.js +13 -4
- package/es/ProStep/index.d.ts +1 -1
- package/es/ProStep/index.js +20 -8
- package/es/ProStep/propsType.d.ts +12 -1
- package/es/ProStep/utils/index.d.ts +3 -0
- package/es/ProStep/utils/index.js +14 -1
- package/lib/ProEditTable/components/RcTable/BaseTable.js +11 -2
- package/lib/ProEditTable/components/RcTable/VirtualTable.d.ts +2 -5
- package/lib/ProEditTable/components/RcTable/VirtualTable.js +3 -161
- package/lib/ProEditTable/components/RcTable/index.d.ts +1 -1
- package/lib/ProEditTable/index.js +19 -3
- package/lib/ProEditTable/propsType.d.ts +1 -0
- package/lib/ProEditTable/style/index.less +8 -0
- package/lib/ProEditTable/utils/tools.d.ts +9 -0
- package/lib/ProEditTable/utils/tools.js +278 -2
- package/lib/ProForm/components/base/InputNumber/index.js +2 -1
- package/lib/ProForm/utils/useForm.js +12 -6
- package/lib/ProStep/components/Item/index.d.ts +3 -3
- package/lib/ProStep/components/Item/index.js +51 -16
- package/lib/ProStep/components/Listener/index.js +13 -4
- package/lib/ProStep/index.d.ts +1 -1
- package/lib/ProStep/index.js +20 -8
- package/lib/ProStep/propsType.d.ts +12 -1
- package/lib/ProStep/utils/index.d.ts +3 -0
- package/lib/ProStep/utils/index.js +15 -1
- package/package.json +7 -6
@@ -57,6 +57,8 @@ export var useForm = function useForm(originForm, options) {
|
|
57
57
|
_form$getInternalHook,
|
58
58
|
getFields,
|
59
59
|
fieldsList,
|
60
|
+
tablePagination,
|
61
|
+
_tablePagination$clic,
|
60
62
|
_error$errorFields,
|
61
63
|
_error$errorFields$,
|
62
64
|
_args = arguments;
|
@@ -95,14 +97,18 @@ export var useForm = function useForm(originForm, options) {
|
|
95
97
|
case 11:
|
96
98
|
return _context.abrupt("return", _context.sent);
|
97
99
|
case 12:
|
98
|
-
|
100
|
+
tablePagination = document.querySelector('#pro-edit-table-pagination');
|
101
|
+
if (tablePagination) {
|
102
|
+
tablePagination === null || tablePagination === void 0 ? void 0 : (_tablePagination$clic = tablePagination.click) === null || _tablePagination$clic === void 0 ? void 0 : _tablePagination$clic.call(tablePagination);
|
103
|
+
}
|
104
|
+
_context.next = 16;
|
99
105
|
return validateFields.apply(void 0, [nameList].concat(rest)).then(function (values) {
|
100
106
|
return nameList ? values : _getFieldsValue();
|
101
107
|
});
|
102
|
-
case
|
108
|
+
case 16:
|
103
109
|
return _context.abrupt("return", _context.sent);
|
104
|
-
case
|
105
|
-
_context.prev =
|
110
|
+
case 19:
|
111
|
+
_context.prev = 19;
|
106
112
|
_context.t0 = _context["catch"](0);
|
107
113
|
if (scrollToError && (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length)) {
|
108
114
|
form.scrollToField((_error$errorFields$ = _context.t0.errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name, {
|
@@ -112,11 +118,11 @@ export var useForm = function useForm(originForm, options) {
|
|
112
118
|
}
|
113
119
|
handleScrollToError();
|
114
120
|
throw _context.t0;
|
115
|
-
case
|
121
|
+
case 24:
|
116
122
|
case "end":
|
117
123
|
return _context.stop();
|
118
124
|
}
|
119
|
-
}, _callee, null, [[0,
|
125
|
+
}, _callee, null, [[0, 19]]);
|
120
126
|
}));
|
121
127
|
return function _validateFields(_x) {
|
122
128
|
return _ref2.apply(this, arguments);
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
declare const
|
3
|
-
export default
|
1
|
+
import { ProStepItemPropsType } from '../../propsType';
|
2
|
+
declare const ProStepItem: ({ id, title, collapse: collapseItem, children, lazyLoad: stepLazyLoad, ...restProps }: ProStepItemPropsType) => import("react/jsx-runtime").JSX.Element;
|
3
|
+
export default ProStepItem;
|
@@ -1,41 +1,76 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
|
-
var _excluded = ["id", "title", "collapse", "children"];
|
3
|
+
var _excluded = ["id", "title", "collapse", "children", "lazyLoad"];
|
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';
|
9
|
+
import { getLoadedMap } from '../../utils';
|
7
10
|
import ProCollapse from '../../../ProLayout/components/ProCollapse';
|
8
|
-
|
11
|
+
var defaultLazyLoadConfig = {
|
12
|
+
height: 100,
|
13
|
+
offset: 100,
|
14
|
+
once: true // Load only once upon first entry into the viewport
|
15
|
+
};
|
16
|
+
var ProStepItem = function ProStepItem(_ref) {
|
9
17
|
var id = _ref.id,
|
10
18
|
title = _ref.title,
|
11
19
|
_ref$collapse = _ref.collapse,
|
12
20
|
collapseItem = _ref$collapse === void 0 ? true : _ref$collapse,
|
13
21
|
children = _ref.children,
|
22
|
+
stepLazyLoad = _ref.lazyLoad,
|
14
23
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
15
24
|
var _useStep = useStep(),
|
16
25
|
register = _useStep.register,
|
17
|
-
collapse = _useStep.collapse
|
26
|
+
collapse = _useStep.collapse,
|
27
|
+
globalLazyLoad = _useStep.lazyLoad,
|
28
|
+
registerMap = _useStep.registerMap;
|
29
|
+
var lazyLoad = stepLazyLoad || globalLazyLoad;
|
30
|
+
var loadedMap = getLoadedMap(registerMap);
|
18
31
|
useEffect(function () {
|
19
|
-
//
|
32
|
+
// Schedule registration to avoid re-render issues
|
20
33
|
var timeoutId = setTimeout(function () {
|
21
|
-
register === null || register === void 0 ? void 0 : register(_objectSpread(
|
34
|
+
register === null || register === void 0 ? void 0 : register(_objectSpread({
|
35
|
+
id: id,
|
22
36
|
title: title,
|
23
|
-
|
24
|
-
}));
|
37
|
+
lazyLoad: lazyLoad
|
38
|
+
}, restProps));
|
25
39
|
}, 0);
|
26
40
|
return function () {
|
27
41
|
return clearTimeout(timeoutId);
|
28
42
|
};
|
29
|
-
}, [register]);
|
43
|
+
}, [id, title, lazyLoad, restProps, register]);
|
44
|
+
var renderChildren = function renderChildren() {
|
45
|
+
var _loadedMap$;
|
46
|
+
// 第一个step不设置lasyload,防止懒加载不生效
|
47
|
+
if (lazyLoad && (loadedMap === null || loadedMap === void 0 ? void 0 : loadedMap.length) && (loadedMap === null || loadedMap === void 0 ? void 0 : (_loadedMap$ = loadedMap[0]) === null || _loadedMap$ === void 0 ? void 0 : _loadedMap$.id) !== id) {
|
48
|
+
var lazyLoadProps = isBoolean(lazyLoad) ? defaultLazyLoadConfig : lazyLoad;
|
49
|
+
return _jsx(LazyLoad, _objectSpread(_objectSpread({}, lazyLoadProps), {}, {
|
50
|
+
classNamePrefix: id,
|
51
|
+
children: children
|
52
|
+
}));
|
53
|
+
}
|
54
|
+
return children;
|
55
|
+
};
|
56
|
+
// If there's no `register` function or if collapsing is enabled, wrap in ProCollapse
|
57
|
+
if (!register || collapse && collapseItem && title) {
|
58
|
+
return _jsx("div", {
|
59
|
+
className: "pro-step-item",
|
60
|
+
id: id,
|
61
|
+
children: _jsx(ProCollapse, _objectSpread(_objectSpread({
|
62
|
+
title: title,
|
63
|
+
icon: true
|
64
|
+
}, restProps), {}, {
|
65
|
+
children: renderChildren()
|
66
|
+
}))
|
67
|
+
});
|
68
|
+
}
|
69
|
+
// Otherwise, just render children
|
30
70
|
return _jsx("div", {
|
31
71
|
className: "pro-step-item",
|
32
72
|
id: id,
|
33
|
-
children:
|
34
|
-
id: id,
|
35
|
-
title: title,
|
36
|
-
icon: true
|
37
|
-
}, restProps), {}, {
|
38
|
-
children: children
|
39
|
-
})) : children
|
73
|
+
children: renderChildren()
|
40
74
|
});
|
41
|
-
}
|
75
|
+
};
|
76
|
+
export default ProStepItem;
|
@@ -6,6 +6,7 @@ var _excluded = ["children", "delayTime", "excludes"];
|
|
6
6
|
import { throttle } from 'lodash';
|
7
7
|
import React from 'react';
|
8
8
|
import { useStep } from '../../index';
|
9
|
+
import { getLoadedMap } from '../../utils';
|
9
10
|
var checkErrorList = function checkErrorList(arr) {
|
10
11
|
for (var i = 0; i < arr.length; i++) {
|
11
12
|
if (arr[i].className.includes('errored')) {
|
@@ -26,16 +27,23 @@ var findFirstErrorDom = function findFirstErrorDom() {
|
|
26
27
|
}
|
27
28
|
return null;
|
28
29
|
};
|
30
|
+
// Function to check if all modules are loaded
|
31
|
+
var areAllModulesLoaded = function areAllModulesLoaded(data) {
|
32
|
+
return data.every(function (item) {
|
33
|
+
return (item === null || item === void 0 ? void 0 : item.loaded) === true;
|
34
|
+
});
|
35
|
+
};
|
29
36
|
export default (function (_ref) {
|
30
37
|
var children = _ref.children,
|
31
38
|
delayTime = _ref.delayTime,
|
32
39
|
excludes = _ref.excludes,
|
33
40
|
props = _objectWithoutProperties(_ref, _excluded);
|
34
41
|
var _useStep = useStep(),
|
35
|
-
notify = _useStep.notify
|
42
|
+
notify = _useStep.notify,
|
43
|
+
registerMap = _useStep.registerMap;
|
36
44
|
return /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, props), {}, {
|
37
45
|
onClick: throttle(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
38
|
-
var values;
|
46
|
+
var values, loadedMap;
|
39
47
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
40
48
|
while (1) switch (_context.prev = _context.next) {
|
41
49
|
case 0:
|
@@ -46,6 +54,7 @@ export default (function (_ref) {
|
|
46
54
|
});
|
47
55
|
case 3:
|
48
56
|
values = _context.sent;
|
57
|
+
loadedMap = getLoadedMap(registerMap);
|
49
58
|
setTimeout(function () {
|
50
59
|
var localData = localStorage.getItem('cache-pro-step');
|
51
60
|
var _ref3 = findFirstErrorDom() || {},
|
@@ -55,10 +64,10 @@ export default (function (_ref) {
|
|
55
64
|
}
|
56
65
|
if (localData !== 'false') {
|
57
66
|
var _children$props, _children$props$onCli;
|
58
|
-
children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : (_children$props$onCli = _children$props.onClick) === null || _children$props$onCli === void 0 ? void 0 : _children$props$onCli.call(_children$props, values);
|
67
|
+
children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : (_children$props$onCli = _children$props.onClick) === null || _children$props$onCli === void 0 ? void 0 : _children$props$onCli.call(_children$props, values, areAllModulesLoaded(loadedMap), loadedMap);
|
59
68
|
}
|
60
69
|
}, delayTime !== null && delayTime !== void 0 ? delayTime : 0);
|
61
|
-
case
|
70
|
+
case 6:
|
62
71
|
case "end":
|
63
72
|
return _context.stop();
|
64
73
|
}
|
package/es/ProStep/index.d.ts
CHANGED
@@ -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").
|
9
|
+
Item: ({ id, title, collapse: collapseItem, children, lazyLoad: stepLazyLoad, ...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;
|
package/es/ProStep/index.js
CHANGED
@@ -23,10 +23,12 @@ var ProStep = function ProStep(_ref) {
|
|
23
23
|
var _useState = useState({}),
|
24
24
|
_useState2 = _slicedToArray(_useState, 2),
|
25
25
|
reRender = _useState2[1];
|
26
|
-
var _useSetState = useSetState({
|
26
|
+
var _useSetState = useSetState({
|
27
|
+
errorCollection: {}
|
28
|
+
}),
|
27
29
|
_useSetState2 = _slicedToArray(_useSetState, 2),
|
28
|
-
errorCollection = _useSetState2[0],
|
29
|
-
|
30
|
+
errorCollection = _useSetState2[0].errorCollection,
|
31
|
+
setState = _useSetState2[1];
|
30
32
|
// 注册子节点id与title映射的集合
|
31
33
|
var registerMap = useRef({});
|
32
34
|
var _useLocalStorageState = useLocalStorageState('cache-pro-step'),
|
@@ -37,7 +39,9 @@ var ProStep = function ProStep(_ref) {
|
|
37
39
|
_resetProps$collapse = resetProps.collapse,
|
38
40
|
collapse = _resetProps$collapse === void 0 ? false : _resetProps$collapse,
|
39
41
|
_resetProps$scrollToE = resetProps.scrollToError,
|
40
|
-
scrollToError = _resetProps$scrollToE === void 0 ? true : _resetProps$scrollToE
|
42
|
+
scrollToError = _resetProps$scrollToE === void 0 ? true : _resetProps$scrollToE,
|
43
|
+
_resetProps$lazyLoad = resetProps.lazyLoad,
|
44
|
+
lazyLoad = _resetProps$lazyLoad === void 0 ? false : _resetProps$lazyLoad;
|
41
45
|
var dataSource = useMemo(function () {
|
42
46
|
var _Object$entries, _Object$entries$map;
|
43
47
|
if (resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource) {
|
@@ -71,8 +75,10 @@ var ProStep = function ProStep(_ref) {
|
|
71
75
|
title = _ref4.title,
|
72
76
|
validator = _ref4.validator,
|
73
77
|
order = _ref4.order,
|
74
|
-
disabled = _ref4.disabled
|
78
|
+
disabled = _ref4.disabled,
|
79
|
+
lazyLoad = _ref4.lazyLoad;
|
75
80
|
var record = {};
|
81
|
+
record.id = id;
|
76
82
|
record.title = title;
|
77
83
|
record.order = order;
|
78
84
|
if (!registerMap.current[id]) {
|
@@ -155,7 +161,9 @@ var ProStep = function ProStep(_ref) {
|
|
155
161
|
errorFields = _ref8.errorFields;
|
156
162
|
nextErrorCollection[id] = (errorFields === null || errorFields === void 0 ? void 0 : errorFields.length) || 0;
|
157
163
|
});
|
158
|
-
|
164
|
+
setState({
|
165
|
+
errorCollection: nextErrorCollection
|
166
|
+
});
|
159
167
|
return _context2.abrupt("return", res);
|
160
168
|
case 11:
|
161
169
|
case "end":
|
@@ -190,7 +198,9 @@ var ProStep = function ProStep(_ref) {
|
|
190
198
|
nextErrorCollection[keys[index]] = item === null || item === void 0 ? void 0 : (_item$errorFields2 = item.errorFields) === null || _item$errorFields2 === void 0 ? void 0 : _item$errorFields2.length;
|
191
199
|
}
|
192
200
|
});
|
193
|
-
|
201
|
+
setState({
|
202
|
+
errorCollection: nextErrorCollection
|
203
|
+
});
|
194
204
|
return _context3.abrupt("return", result);
|
195
205
|
case 9:
|
196
206
|
case "end":
|
@@ -220,11 +230,13 @@ var ProStep = function ProStep(_ref) {
|
|
220
230
|
}, [errorCollection, dataSource]);
|
221
231
|
return _jsx(ProStepContext.Provider, {
|
222
232
|
value: {
|
233
|
+
registerMap: registerMap,
|
223
234
|
collapse: collapse,
|
224
235
|
register: register,
|
225
236
|
notify: notify,
|
226
237
|
triggerTo: triggerTo,
|
227
|
-
handleScroll: handleScroll
|
238
|
+
handleScroll: handleScroll,
|
239
|
+
lazyLoad: lazyLoad
|
228
240
|
},
|
229
241
|
children: _jsxs("div", {
|
230
242
|
className: "pro-step-wrapper",
|
@@ -1,9 +1,16 @@
|
|
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;
|
5
6
|
order?: number;
|
6
7
|
}
|
8
|
+
export interface LoadedMapPropsType {
|
9
|
+
id: string;
|
10
|
+
order: number;
|
11
|
+
title: string;
|
12
|
+
loaded: boolean;
|
13
|
+
}
|
7
14
|
export interface ProStepPropsType {
|
8
15
|
/** @name 步骤条配置项 */
|
9
16
|
dataSource?: ItemType[];
|
@@ -21,11 +28,15 @@ export interface ProStepPropsType {
|
|
21
28
|
collapse?: boolean;
|
22
29
|
/** @name 是否滚动到第一个报错 */
|
23
30
|
scrollToError?: boolean;
|
31
|
+
/** 模块可视区域懒加载 */
|
32
|
+
lazyLoad?: boolean | LazyLoadProps;
|
24
33
|
}
|
25
|
-
export interface
|
34
|
+
export interface ProStepItemPropsType {
|
26
35
|
id: string;
|
27
36
|
title?: string;
|
28
37
|
collapse?: boolean;
|
29
38
|
order?: number;
|
39
|
+
/** 模块可视区域懒加载 */
|
40
|
+
lazyLoad?: boolean | LazyLoadProps;
|
30
41
|
[key: string]: any;
|
31
42
|
}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import { debounce, pick } from 'lodash';
|
2
3
|
export var handleScroll = function handleScroll(id, options) {
|
3
4
|
var _ref = options || {},
|
4
5
|
_ref$targetOffset = _ref.targetOffset,
|
@@ -15,4 +16,16 @@ export var handleScroll = function handleScroll(id, options) {
|
|
15
16
|
}, 100), 0);
|
16
17
|
}
|
17
18
|
};
|
19
|
+
/** 获取加载模块数据信息 */
|
20
|
+
export var getLoadedMap = function getLoadedMap(registerMap) {
|
21
|
+
if (!(registerMap === null || registerMap === void 0 ? void 0 : registerMap.current)) {
|
22
|
+
return undefined;
|
23
|
+
}
|
24
|
+
var stepList = Object.values(registerMap === null || registerMap === void 0 ? void 0 : registerMap.current).map(function (item) {
|
25
|
+
return _objectSpread(_objectSpread({}, pick(item, ['id', 'order', 'title'])), {}, {
|
26
|
+
loaded: !document.querySelector(".".concat(item === null || item === void 0 ? void 0 : item.id, "-placeholder"))
|
27
|
+
});
|
28
|
+
});
|
29
|
+
return stepList;
|
30
|
+
};
|
18
31
|
export default handleScroll;
|
@@ -8,8 +8,8 @@ exports.default = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
11
|
-
var _antd = require("antd");
|
12
11
|
var _react = require("react");
|
12
|
+
var _antd = require("antd");
|
13
13
|
var _excluded = ["tableProps"];
|
14
14
|
var BaseTable = function BaseTable(_ref) {
|
15
15
|
var _value$;
|
@@ -33,7 +33,8 @@ var BaseTable = function BaseTable(_ref) {
|
|
33
33
|
page = tableProps.page,
|
34
34
|
formatMessage = tableProps.formatMessage,
|
35
35
|
locale = tableProps.locale,
|
36
|
-
handlePageChange = tableProps.handlePageChange
|
36
|
+
handlePageChange = tableProps.handlePageChange,
|
37
|
+
pageErrorNum = tableProps.pageErrorNum;
|
37
38
|
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
38
39
|
children: [headerRender ? (0, _jsxRuntime.jsx)("div", {
|
39
40
|
className: "pro-edit-table-header",
|
@@ -67,6 +68,14 @@ var BaseTable = function BaseTable(_ref) {
|
|
67
68
|
total: total
|
68
69
|
});
|
69
70
|
},
|
71
|
+
itemRender: function itemRender(index, type, originalElement) {
|
72
|
+
return type === 'page' && page.pageNum === index && pageErrorNum ? (0, _jsxRuntime.jsxs)("div", {
|
73
|
+
className: "pro-edit-table-pagination-item-badge",
|
74
|
+
children: [(0, _jsxRuntime.jsx)(_antd.Badge, {
|
75
|
+
count: pageErrorNum
|
76
|
+
}), originalElement]
|
77
|
+
}) : originalElement;
|
78
|
+
},
|
70
79
|
onChange: handlePageChange
|
71
80
|
}, pagination) : false,
|
72
81
|
rowKey: "rowKey",
|
@@ -1,6 +1,3 @@
|
|
1
|
-
|
2
|
-
declare const _default:
|
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
|
15
|
-
|
16
|
-
|
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);
|
@@ -101,8 +101,9 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
101
101
|
virtualKey: type === 'single' || mode === 'single' ? (0, _tools.getRandom)() : '',
|
102
102
|
page: {
|
103
103
|
pageNum: 1,
|
104
|
-
pageSize: 10
|
105
|
-
}
|
104
|
+
pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10
|
105
|
+
},
|
106
|
+
pageErrorNum: 0
|
106
107
|
}),
|
107
108
|
_useSetState2 = (0, _slicedToArray2.default)(_useSetState, 2),
|
108
109
|
state = _useSetState2[0],
|
@@ -113,7 +114,8 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
113
114
|
virtualKey = state.virtualKey,
|
114
115
|
selectedRowKeys = state.selectedRowKeys,
|
115
116
|
selectedRows = state.selectedRows,
|
116
|
-
page = state.page
|
117
|
+
page = state.page,
|
118
|
+
pageErrorNum = state.pageErrorNum;
|
117
119
|
var virtualRowName = (0, _tools.getNamePath)((0, _lodash.isArray)(name) ? name : [name], virtualKey);
|
118
120
|
// 样式处理
|
119
121
|
var _className = (0, _classnames.default)({
|
@@ -414,6 +416,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
414
416
|
page: page,
|
415
417
|
formatMessage: _locale.formatMessage,
|
416
418
|
locale: _locale.default,
|
419
|
+
pageErrorNum: pageErrorNum,
|
417
420
|
handlePageChange: handlePageChange
|
418
421
|
}
|
419
422
|
})), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? (0, _jsxRuntime.jsx)(_antd.Affix, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
@@ -429,6 +432,19 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
429
432
|
}) : null, footerRender ? (0, _jsxRuntime.jsx)("div", {
|
430
433
|
className: "pro-edit-table-footer",
|
431
434
|
children: footerRender
|
435
|
+
}) : null, pagination ? (0, _jsxRuntime.jsx)("div", {
|
436
|
+
id: "pro-edit-table-pagination",
|
437
|
+
onClick: function onClick() {
|
438
|
+
(0, _tools.onPageCheck)({
|
439
|
+
form: form,
|
440
|
+
name: name,
|
441
|
+
value: value,
|
442
|
+
columns: columns,
|
443
|
+
page: page,
|
444
|
+
pagination: pagination,
|
445
|
+
setState: setState
|
446
|
+
});
|
447
|
+
}
|
432
448
|
}) : null]
|
433
449
|
}), (0, _jsxRuntime.jsx)(_components.Validator, {
|
434
450
|
name: name,
|
@@ -14,6 +14,14 @@
|
|
14
14
|
}
|
15
15
|
}
|
16
16
|
|
17
|
+
.@{ant-prefix}-pagination .@{ant-prefix}-pagination-item .pro-edit-table-pagination-item-badge {
|
18
|
+
position: relative;
|
19
|
+
.@{ant-prefix}-badge {
|
20
|
+
position: absolute;
|
21
|
+
top: -10px;
|
22
|
+
right: -10px;
|
23
|
+
}
|
24
|
+
}
|
17
25
|
|
18
26
|
.pro-edit-table-tooltip {
|
19
27
|
display : inline-flex;
|
@@ -35,3 +35,12 @@ export declare const handleScrollToError: () => void;
|
|
35
35
|
* @returns 深拷贝后的对象,其中的React节点会被保留
|
36
36
|
*/
|
37
37
|
export declare function cloneDeepFilterNode(value: any): any;
|
38
|
+
export declare const onPageCheck: ({ form, name, value, columns, page, pagination, setState, }: {
|
39
|
+
form: any;
|
40
|
+
name: any;
|
41
|
+
value: any;
|
42
|
+
columns: any;
|
43
|
+
page: any;
|
44
|
+
pagination: any;
|
45
|
+
setState: any;
|
46
|
+
}) => Promise<void>;
|