@zat-design/sisyphus-react 3.10.4-beta.2 → 3.11.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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "recommendations": [
3
+ "kisstkondoros.vscode-codemetrics"
4
+ ]
5
+ }
@@ -4516,6 +4516,14 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
4516
4516
  padding: 0;
4517
4517
  border-radius: 0;
4518
4518
  }
4519
+ .pro-edit-table .ant-pagination .ant-pagination-item .pro-edit-table-pagination-item-badge {
4520
+ position: relative;
4521
+ }
4522
+ .pro-edit-table .ant-pagination .ant-pagination-item .pro-edit-table-pagination-item-badge .ant-badge {
4523
+ position: absolute;
4524
+ top: -10px;
4525
+ right: -10px;
4526
+ }
4519
4527
  .pro-edit-table .pro-edit-table-tooltip {
4520
4528
  display: -webkit-inline-box;
4521
4529
  display: -webkit-inline-flex;
package/dist/less.esm.css CHANGED
@@ -4516,6 +4516,14 @@ span.ant-input-group-compact.pro-range-limit .forever-checkbox {
4516
4516
  padding: 0;
4517
4517
  border-radius: 0;
4518
4518
  }
4519
+ .pro-edit-table .ant-pagination .ant-pagination-item .pro-edit-table-pagination-item-badge {
4520
+ position: relative;
4521
+ }
4522
+ .pro-edit-table .ant-pagination .ant-pagination-item .pro-edit-table-pagination-item-badge .ant-badge {
4523
+ position: absolute;
4524
+ top: -10px;
4525
+ right: -10px;
4526
+ }
4519
4527
  .pro-edit-table .pro-edit-table-tooltip {
4520
4528
  display: -webkit-inline-box;
4521
4529
  display: -webkit-inline-flex;
@@ -1,9 +1,11 @@
1
+ import "antd/es/badge/style";
2
+ import _Badge from "antd/es/badge";
1
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
4
  import "antd/es/table/style";
3
5
  import _Table from "antd/es/table";
4
6
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
7
  var _excluded = ["tableProps"];
6
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
7
9
  import { memo } from 'react';
8
10
  var BaseTable = function BaseTable(_ref) {
9
11
  var _value$;
@@ -27,7 +29,8 @@ var BaseTable = function BaseTable(_ref) {
27
29
  page = tableProps.page,
28
30
  formatMessage = tableProps.formatMessage,
29
31
  locale = tableProps.locale,
30
- handlePageChange = tableProps.handlePageChange;
32
+ handlePageChange = tableProps.handlePageChange,
33
+ pageErrorNum = tableProps.pageErrorNum;
31
34
  return _jsxs(_Fragment, {
32
35
  children: [headerRender ? _jsx("div", {
33
36
  className: "pro-edit-table-header",
@@ -61,6 +64,14 @@ var BaseTable = function BaseTable(_ref) {
61
64
  total: total
62
65
  });
63
66
  },
67
+ itemRender: function itemRender(index, type, originalElement) {
68
+ return type === 'page' && page.pageNum === index && pageErrorNum ? _jsxs("div", {
69
+ className: "pro-edit-table-pagination-item-badge",
70
+ children: [_jsx(_Badge, {
71
+ count: pageErrorNum
72
+ }), originalElement]
73
+ }) : originalElement;
74
+ },
64
75
  onChange: handlePageChange
65
76
  }, pagination) : false,
66
77
  rowKey: "rowKey",
@@ -18,7 +18,7 @@ import { get, isArray, isBoolean, set } from 'lodash';
18
18
  import { useDeepCompareEffect, useLocalStorageState, useSetState } from 'ahooks';
19
19
  import classnames from 'classnames';
20
20
  import { transformColumns } from './utils';
21
- import { getRandom, getNamePath, handleScrollToError } from './utils/tools';
21
+ import { getRandom, getNamePath, handleScrollToError, onPageCheck } from './utils/tools';
22
22
  import { Validator, Summary, RenderToolbar } from './components';
23
23
  import ProForm from '../ProForm';
24
24
  import Empty from '../assets/empty.png';
@@ -98,8 +98,9 @@ var ProEditTable = function ProEditTable(_ref, ref) {
98
98
  virtualKey: type === 'single' || mode === 'single' ? getRandom() : '',
99
99
  page: {
100
100
  pageNum: 1,
101
- pageSize: 10
102
- }
101
+ pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || 10
102
+ },
103
+ pageErrorNum: 0
103
104
  }),
104
105
  _useSetState2 = _slicedToArray(_useSetState, 2),
105
106
  state = _useSetState2[0],
@@ -110,7 +111,8 @@ var ProEditTable = function ProEditTable(_ref, ref) {
110
111
  virtualKey = state.virtualKey,
111
112
  selectedRowKeys = state.selectedRowKeys,
112
113
  selectedRows = state.selectedRows,
113
- page = state.page;
114
+ page = state.page,
115
+ pageErrorNum = state.pageErrorNum;
114
116
  var virtualRowName = getNamePath(isArray(name) ? name : [name], virtualKey);
115
117
  // 样式处理
116
118
  var _className = classnames({
@@ -411,6 +413,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
411
413
  page: page,
412
414
  formatMessage: formatMessage,
413
415
  locale: locale,
416
+ pageErrorNum: pageErrorNum,
414
417
  handlePageChange: handlePageChange
415
418
  }
416
419
  })), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? _jsx(_Affix, _objectSpread(_objectSpread({
@@ -426,6 +429,19 @@ var ProEditTable = function ProEditTable(_ref, ref) {
426
429
  }) : null, footerRender ? _jsx("div", {
427
430
  className: "pro-edit-table-footer",
428
431
  children: footerRender
432
+ }) : null, pagination ? _jsx("div", {
433
+ id: "pro-edit-table-pagination",
434
+ onClick: function onClick() {
435
+ onPageCheck({
436
+ form: form,
437
+ name: name,
438
+ value: value,
439
+ columns: columns,
440
+ page: page,
441
+ pagination: pagination,
442
+ setState: setState
443
+ });
444
+ }
429
445
  }) : null]
430
446
  }), _jsx(Validator, {
431
447
  name: name,
@@ -124,6 +124,7 @@ export interface State {
124
124
  pageNum: number;
125
125
  pageSize: number;
126
126
  };
127
+ pageErrorNum: number;
127
128
  }
128
129
  export interface ProEditTableRefProps {
129
130
  getInternalState: () => State;
@@ -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>;
@@ -1,6 +1,12 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
4
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
5
+ /* eslint-disable no-await-in-loop */
6
+ /* eslint-disable no-restricted-syntax */
2
7
  import React from 'react';
3
- import { cloneDeep, cloneDeepWith, isString, isObject, isEqual, transform, isFunction, isBoolean } from 'lodash';
8
+ import { tools, validate } from '@zat-design/utils';
9
+ import { cloneDeep, cloneDeepWith, isString, isObject, isEqual, transform, isFunction, isBoolean, get } from 'lodash';
4
10
  export var getRandom = function getRandom() {
5
11
  return Math.random().toString(36).slice(-6);
6
12
  };
@@ -210,4 +216,273 @@ export function cloneDeepFilterNode(value) {
210
216
  return val;
211
217
  }
212
218
  });
213
- }
219
+ }
220
+ var _isNull = function isNull(value) {
221
+ if (Array.isArray(value) && value.length) {
222
+ return value.some(function (item) {
223
+ return _isNull(item);
224
+ });
225
+ }
226
+ return value === '' || value === undefined || value === null || Array.isArray(value) && value.length === 0;
227
+ };
228
+ var handleCheckCellValue = /*#__PURE__*/function () {
229
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(column, record) {
230
+ var _column$names, _column$names2, _rules2;
231
+ var value, _required, _rules, _labelRequired, res, _iterator, _step, rule;
232
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
233
+ while (1) switch (_context.prev = _context.next) {
234
+ case 0:
235
+ value = null;
236
+ if (column.name) {
237
+ value = get(record, column.name);
238
+ }
239
+ if ((_column$names = column.names) === null || _column$names === void 0 ? void 0 : _column$names.length) {
240
+ value = column.names.map(function (key) {
241
+ return get(record, key);
242
+ });
243
+ }
244
+ _required = column.required;
245
+ _rules = column.rules;
246
+ _labelRequired = column.labelRequired;
247
+ if (isFunction(column.required)) {
248
+ _required = column.required(value, record);
249
+ }
250
+ if (isFunction(column.rules)) {
251
+ _rules = column.rules(value, record);
252
+ }
253
+ if (isFunction(column.labelRequired)) {
254
+ _labelRequired = column.labelRequired(value, record);
255
+ }
256
+ if (!(((_column$names2 = column.names) === null || _column$names2 === void 0 ? void 0 : _column$names2.length) && _labelRequired !== null && _labelRequired !== undefined && _isNull(value))) {
257
+ _context.next = 11;
258
+ break;
259
+ }
260
+ return _context.abrupt("return", false);
261
+ case 11:
262
+ if (!(_required && _isNull(value))) {
263
+ _context.next = 13;
264
+ break;
265
+ }
266
+ return _context.abrupt("return", false);
267
+ case 13:
268
+ if (!((_rules2 = _rules) === null || _rules2 === void 0 ? void 0 : _rules2.length)) {
269
+ _context.next = 44;
270
+ break;
271
+ }
272
+ res = true;
273
+ _iterator = _createForOfIteratorHelper(_rules);
274
+ _context.prev = 16;
275
+ _iterator.s();
276
+ case 18:
277
+ if ((_step = _iterator.n()).done) {
278
+ _context.next = 35;
279
+ break;
280
+ }
281
+ rule = _step.value;
282
+ if (res) {
283
+ _context.next = 22;
284
+ break;
285
+ }
286
+ return _context.abrupt("break", 35);
287
+ case 22:
288
+ if (rule.required && _isNull(value)) {
289
+ res = false;
290
+ }
291
+ if (!isFunction(rule.validator)) {
292
+ _context.next = 32;
293
+ break;
294
+ }
295
+ _context.prev = 24;
296
+ _context.next = 27;
297
+ return rule.validator('', value);
298
+ case 27:
299
+ _context.next = 32;
300
+ break;
301
+ case 29:
302
+ _context.prev = 29;
303
+ _context.t0 = _context["catch"](24);
304
+ res = false;
305
+ case 32:
306
+ if (rule.type && !validate[rule.type](value)) {
307
+ res = false;
308
+ }
309
+ case 33:
310
+ _context.next = 18;
311
+ break;
312
+ case 35:
313
+ _context.next = 40;
314
+ break;
315
+ case 37:
316
+ _context.prev = 37;
317
+ _context.t1 = _context["catch"](16);
318
+ _iterator.e(_context.t1);
319
+ case 40:
320
+ _context.prev = 40;
321
+ _iterator.f();
322
+ return _context.finish(40);
323
+ case 43:
324
+ return _context.abrupt("return", res);
325
+ case 44:
326
+ return _context.abrupt("return", true);
327
+ case 45:
328
+ case "end":
329
+ return _context.stop();
330
+ }
331
+ }, _callee, null, [[16, 37, 40, 43], [24, 29]]);
332
+ }));
333
+ return function handleCheckCellValue(_x, _x2) {
334
+ return _ref6.apply(this, arguments);
335
+ };
336
+ }();
337
+ export var onPageCheck = /*#__PURE__*/function () {
338
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref7) {
339
+ var form, name, value, columns, page, pagination, setState, pageNum, pageSize, pageArr, flag, errorNum, errorPageNum, _i, _pageArr, item, start, end, nextValues, _iterator2, _step2, record, _iterator3, _step3, column, result, nextState;
340
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
341
+ while (1) switch (_context2.prev = _context2.next) {
342
+ case 0:
343
+ form = _ref7.form, name = _ref7.name, value = _ref7.value, columns = _ref7.columns, page = _ref7.page, pagination = _ref7.pagination, setState = _ref7.setState;
344
+ if (!pagination) {
345
+ _context2.next = 75;
346
+ break;
347
+ }
348
+ pageNum = page.pageNum, pageSize = page.pageSize;
349
+ pageArr = Array.from({
350
+ length: Math.ceil(tools.calc(value.length, '/', pageSize))
351
+ }, function (_, i) {
352
+ return i + 1;
353
+ });
354
+ flag = false;
355
+ errorNum = 0;
356
+ errorPageNum = 0;
357
+ _i = 0, _pageArr = pageArr;
358
+ case 8:
359
+ if (!(_i < _pageArr.length)) {
360
+ _context2.next = 60;
361
+ break;
362
+ }
363
+ item = _pageArr[_i];
364
+ if (!flag) {
365
+ _context2.next = 12;
366
+ break;
367
+ }
368
+ return _context2.abrupt("break", 60);
369
+ case 12:
370
+ errorNum = 0;
371
+ // 实现思路:截取每一页数据,手动触发每一行数据的校验,通过column配置的rule规则,
372
+ // 依次校验每一页数据,有错误就跳出循环,跳转到错误页数,并展示错误单元格数量
373
+ start = tools.calc(item - 1, '*', pageSize);
374
+ end = tools.calc(start, '+', pageSize);
375
+ nextValues = value === null || value === void 0 ? void 0 : value.slice(start, end);
376
+ _iterator2 = _createForOfIteratorHelper(nextValues);
377
+ _context2.prev = 17;
378
+ _iterator2.s();
379
+ case 19:
380
+ if ((_step2 = _iterator2.n()).done) {
381
+ _context2.next = 48;
382
+ break;
383
+ }
384
+ record = _step2.value;
385
+ _iterator3 = _createForOfIteratorHelper(columns);
386
+ _context2.prev = 22;
387
+ _iterator3.s();
388
+ case 24:
389
+ if ((_step3 = _iterator3.n()).done) {
390
+ _context2.next = 38;
391
+ break;
392
+ }
393
+ column = _step3.value;
394
+ _context2.prev = 26;
395
+ _context2.next = 29;
396
+ return handleCheckCellValue(column, record);
397
+ case 29:
398
+ result = _context2.sent;
399
+ if (!result) {
400
+ errorNum += 1;
401
+ }
402
+ _context2.next = 36;
403
+ break;
404
+ case 33:
405
+ _context2.prev = 33;
406
+ _context2.t0 = _context2["catch"](26);
407
+ errorNum += 1;
408
+ case 36:
409
+ _context2.next = 24;
410
+ break;
411
+ case 38:
412
+ _context2.next = 43;
413
+ break;
414
+ case 40:
415
+ _context2.prev = 40;
416
+ _context2.t1 = _context2["catch"](22);
417
+ _iterator3.e(_context2.t1);
418
+ case 43:
419
+ _context2.prev = 43;
420
+ _iterator3.f();
421
+ return _context2.finish(43);
422
+ case 46:
423
+ _context2.next = 19;
424
+ break;
425
+ case 48:
426
+ _context2.next = 53;
427
+ break;
428
+ case 50:
429
+ _context2.prev = 50;
430
+ _context2.t2 = _context2["catch"](17);
431
+ _iterator2.e(_context2.t2);
432
+ case 53:
433
+ _context2.prev = 53;
434
+ _iterator2.f();
435
+ return _context2.finish(53);
436
+ case 56:
437
+ if (errorNum > 0) {
438
+ flag = true;
439
+ errorPageNum = item;
440
+ }
441
+ case 57:
442
+ _i++;
443
+ _context2.next = 8;
444
+ break;
445
+ case 60:
446
+ if (!(flag && errorNum > 0)) {
447
+ _context2.next = 74;
448
+ break;
449
+ }
450
+ nextState = {
451
+ pageErrorNum: errorNum > 0 ? errorNum : 0
452
+ };
453
+ if (pageNum !== errorPageNum) {
454
+ nextState.page = {
455
+ pageNum: errorPageNum,
456
+ pageSize: pageSize
457
+ };
458
+ }
459
+ setState(nextState);
460
+ _context2.prev = 64;
461
+ _context2.next = 67;
462
+ return form.validateFields([name], {
463
+ recursive: true
464
+ });
465
+ case 67:
466
+ _context2.next = 72;
467
+ break;
468
+ case 69:
469
+ _context2.prev = 69;
470
+ _context2.t3 = _context2["catch"](64);
471
+ handleScrollToError();
472
+ case 72:
473
+ _context2.next = 75;
474
+ break;
475
+ case 74:
476
+ setState({
477
+ pageErrorNum: 0
478
+ });
479
+ case 75:
480
+ case "end":
481
+ return _context2.stop();
482
+ }
483
+ }, _callee2, null, [[17, 50, 53, 56], [22, 40, 43, 46], [26, 33], [64, 69]]);
484
+ }));
485
+ return function onPageCheck(_x3) {
486
+ return _ref8.apply(this, arguments);
487
+ };
488
+ }();
@@ -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
- _context.next = 14;
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 14:
108
+ case 16:
103
109
  return _context.abrupt("return", _context.sent);
104
- case 17:
105
- _context.prev = 17;
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 22:
121
+ case 24:
116
122
  case "end":
117
123
  return _context.stop();
118
124
  }
119
- }, _callee, null, [[0, 17]]);
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
1
  import { ProStepItemPropsType } from '../../propsType';
2
- declare const ProStepItem: ({ id, title, collapse: collapseItem, children, ...restProps }: ProStepItemPropsType) => import("react/jsx-runtime").JSX.Element;
2
+ declare function ProStepItem({ id, title, collapse: collapseItem, children, lazyLoad, ...restProps }: ProStepItemPropsType): import("react/jsx-runtime").JSX.Element;
3
3
  export default ProStepItem;
@@ -1,6 +1,6 @@
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
6
  import LazyLoad from 'react-lazyload';
@@ -10,48 +10,60 @@ import ProCollapse from '../../../ProLayout/components/ProCollapse';
10
10
  var defaultLazyLoadConfig = {
11
11
  height: 100,
12
12
  offset: 100,
13
- once: true // 保证只在首次进入视口时触发懒加载
13
+ once: true // Load only once upon first entry into the viewport
14
14
  };
15
- var ProStepItem = function ProStepItem(_ref) {
15
+ function ProStepItem(_ref) {
16
16
  var id = _ref.id,
17
17
  title = _ref.title,
18
18
  _ref$collapse = _ref.collapse,
19
19
  collapseItem = _ref$collapse === void 0 ? true : _ref$collapse,
20
20
  children = _ref.children,
21
+ lazyLoad = _ref.lazyLoad,
21
22
  restProps = _objectWithoutProperties(_ref, _excluded);
22
23
  var _useStep = useStep(),
23
24
  register = _useStep.register,
24
25
  collapse = _useStep.collapse;
25
26
  useEffect(function () {
26
- // 延迟更新父组件状态,避免重渲染
27
+ // Schedule registration to avoid re-render issues
27
28
  var timeoutId = setTimeout(function () {
28
- register === null || register === void 0 ? void 0 : register(_objectSpread(_objectSpread({}, restProps), {}, {
29
+ register === null || register === void 0 ? void 0 : register(_objectSpread({
30
+ id: id,
29
31
  title: title,
30
- id: id
31
- }));
32
+ lazyLoad: lazyLoad
33
+ }, restProps));
32
34
  }, 0);
33
35
  return function () {
34
36
  return clearTimeout(timeoutId);
35
37
  };
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;
38
+ }, [id, title, lazyLoad, restProps, register]);
39
+ var renderChildren = function renderChildren() {
40
+ if (lazyLoad) {
41
+ var lazyLoadProps = isBoolean(lazyLoad) ? defaultLazyLoadConfig : lazyLoad;
40
42
  return _jsx(LazyLoad, _objectSpread(_objectSpread({}, lazyLoadProps), {}, {
43
+ classNamePrefix: id,
41
44
  children: children
42
45
  }));
43
46
  }
44
47
  return children;
45
48
  };
49
+ // If there's no `register` function or if collapsing is enabled, wrap in ProCollapse
50
+ if (!register || collapse && collapseItem && title) {
51
+ return _jsx("div", {
52
+ className: "pro-step-item",
53
+ id: id,
54
+ children: _jsx(ProCollapse, _objectSpread(_objectSpread({
55
+ title: title,
56
+ icon: true
57
+ }, restProps), {}, {
58
+ children: renderChildren()
59
+ }))
60
+ });
61
+ }
62
+ // Otherwise, just render children
46
63
  return _jsx("div", {
47
64
  className: "pro-step-item",
48
65
  id: id,
49
- children: !register || collapse && collapseItem && title ? _jsx(ProCollapse, _objectSpread(_objectSpread({
50
- title: title,
51
- icon: true
52
- }, restProps), {}, {
53
- children: childrenRender()
54
- })) : childrenRender()
66
+ children: renderChildren()
55
67
  });
56
- };
68
+ }
57
69
  export default ProStepItem;
@@ -1,9 +1,9 @@
1
1
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
5
  var _excluded = ["children", "delayTime", "excludes"];
6
- import { throttle } from 'lodash';
6
+ import { throttle, pick } from 'lodash';
7
7
  import React from 'react';
8
8
  import { useStep } from '../../index';
9
9
  var checkErrorList = function checkErrorList(arr) {
@@ -26,16 +26,34 @@ var findFirstErrorDom = function findFirstErrorDom() {
26
26
  }
27
27
  return null;
28
28
  };
29
+ var getLoadedMap = function getLoadedMap(registerMap) {
30
+ if (!(registerMap === null || registerMap === void 0 ? void 0 : registerMap.current)) {
31
+ return undefined;
32
+ }
33
+ var stepList = Object.values(registerMap === null || registerMap === void 0 ? void 0 : registerMap.current).map(function (item) {
34
+ return _objectSpread(_objectSpread({}, pick(item, ['id', 'order', 'title'])), {}, {
35
+ loaded: !document.querySelector(".".concat(item === null || item === void 0 ? void 0 : item.id, "-placeholder"))
36
+ });
37
+ });
38
+ return stepList;
39
+ };
40
+ // Function to check if all modules are loaded
41
+ var areAllModulesLoaded = function areAllModulesLoaded(data) {
42
+ return data.every(function (item) {
43
+ return (item === null || item === void 0 ? void 0 : item.loaded) === true;
44
+ });
45
+ };
29
46
  export default (function (_ref) {
30
47
  var children = _ref.children,
31
48
  delayTime = _ref.delayTime,
32
49
  excludes = _ref.excludes,
33
50
  props = _objectWithoutProperties(_ref, _excluded);
34
51
  var _useStep = useStep(),
35
- notify = _useStep.notify;
52
+ notify = _useStep.notify,
53
+ registerMap = _useStep.registerMap;
36
54
  return /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, props), {}, {
37
55
  onClick: throttle(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
38
- var values;
56
+ var values, loadedMap;
39
57
  return _regeneratorRuntime().wrap(function _callee$(_context) {
40
58
  while (1) switch (_context.prev = _context.next) {
41
59
  case 0:
@@ -46,6 +64,7 @@ export default (function (_ref) {
46
64
  });
47
65
  case 3:
48
66
  values = _context.sent;
67
+ loadedMap = getLoadedMap(registerMap);
49
68
  setTimeout(function () {
50
69
  var localData = localStorage.getItem('cache-pro-step');
51
70
  var _ref3 = findFirstErrorDom() || {},
@@ -55,10 +74,10 @@ export default (function (_ref) {
55
74
  }
56
75
  if (localData !== 'false') {
57
76
  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);
77
+ 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
78
  }
60
79
  }, delayTime !== null && delayTime !== void 0 ? delayTime : 0);
61
- case 5:
80
+ case 6:
62
81
  case "end":
63
82
  return _context.stop();
64
83
  }