@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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import Item from './components/Item';
2
3
  import { ProStepPropsType } from './propsType';
3
4
  import './style/index.less';
4
5
  export declare const ProStepContext: import("react").Context<any>;
@@ -6,7 +7,7 @@ export declare const useStep: () => any;
6
7
  declare const ProStep: {
7
8
  ({ children, ...resetProps }: ProStepPropsType): import("react/jsx-runtime").JSX.Element;
8
9
  useStep: () => any;
9
- Item: ({ id, title, collapse: collapseItem, children, ...restProps }: import("./propsType").ProStepItemPropsType) => import("react/jsx-runtime").JSX.Element;
10
+ Item: typeof Item;
10
11
  Listener: ({ children, delayTime, excludes, ...props }: any) => import("react").DetailedReactHTMLElement<any, HTMLElement>;
11
12
  };
12
13
  export default ProStep;
@@ -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
- setErrorCollection = _useSetState2[1];
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'),
@@ -71,8 +73,10 @@ var ProStep = function ProStep(_ref) {
71
73
  title = _ref4.title,
72
74
  validator = _ref4.validator,
73
75
  order = _ref4.order,
74
- disabled = _ref4.disabled;
76
+ disabled = _ref4.disabled,
77
+ lazyLoad = _ref4.lazyLoad;
75
78
  var record = {};
79
+ record.id = id;
76
80
  record.title = title;
77
81
  record.order = order;
78
82
  if (!registerMap.current[id]) {
@@ -155,7 +159,9 @@ var ProStep = function ProStep(_ref) {
155
159
  errorFields = _ref8.errorFields;
156
160
  nextErrorCollection[id] = (errorFields === null || errorFields === void 0 ? void 0 : errorFields.length) || 0;
157
161
  });
158
- setErrorCollection(nextErrorCollection);
162
+ setState({
163
+ errorCollection: nextErrorCollection
164
+ });
159
165
  return _context2.abrupt("return", res);
160
166
  case 11:
161
167
  case "end":
@@ -190,7 +196,9 @@ var ProStep = function ProStep(_ref) {
190
196
  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
197
  }
192
198
  });
193
- setErrorCollection(nextErrorCollection);
199
+ setState({
200
+ errorCollection: nextErrorCollection
201
+ });
194
202
  return _context3.abrupt("return", result);
195
203
  case 9:
196
204
  case "end":
@@ -220,6 +228,7 @@ var ProStep = function ProStep(_ref) {
220
228
  }, [errorCollection, dataSource]);
221
229
  return _jsx(ProStepContext.Provider, {
222
230
  value: {
231
+ registerMap: registerMap,
223
232
  collapse: collapse,
224
233
  register: register,
225
234
  notify: notify,
@@ -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",
@@ -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,
@@ -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>;
@@ -5,10 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.cloneDeepFilterNode = cloneDeepFilterNode;
8
- exports.splitNames = exports.onDelete = exports.handleScrollToError = exports.getRandom = exports.getNamePath = exports.getDisabled = exports.difference = exports.customValidate = void 0;
8
+ exports.splitNames = exports.onPageCheck = exports.onDelete = exports.handleScrollToError = exports.getRandom = exports.getNamePath = exports.getDisabled = exports.difference = exports.customValidate = void 0;
9
+ var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
10
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
11
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
13
  var _react = _interopRequireDefault(require("react"));
14
+ var _utils = require("@zat-design/utils");
11
15
  var _lodash = require("lodash");
16
+ /* eslint-disable no-await-in-loop */
17
+ /* eslint-disable no-restricted-syntax */
18
+
12
19
  var getRandom = exports.getRandom = function getRandom() {
13
20
  return Math.random().toString(36).slice(-6);
14
21
  };
@@ -218,4 +225,273 @@ function cloneDeepFilterNode(value) {
218
225
  return val;
219
226
  }
220
227
  });
221
- }
228
+ }
229
+ var _isNull = function isNull(value) {
230
+ if (Array.isArray(value) && value.length) {
231
+ return value.some(function (item) {
232
+ return _isNull(item);
233
+ });
234
+ }
235
+ return value === '' || value === undefined || value === null || Array.isArray(value) && value.length === 0;
236
+ };
237
+ var handleCheckCellValue = /*#__PURE__*/function () {
238
+ var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(column, record) {
239
+ var _column$names, _column$names2, _rules2;
240
+ var value, _required, _rules, _labelRequired, res, _iterator, _step, rule;
241
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
242
+ while (1) switch (_context.prev = _context.next) {
243
+ case 0:
244
+ value = null;
245
+ if (column.name) {
246
+ value = (0, _lodash.get)(record, column.name);
247
+ }
248
+ if ((_column$names = column.names) === null || _column$names === void 0 ? void 0 : _column$names.length) {
249
+ value = column.names.map(function (key) {
250
+ return (0, _lodash.get)(record, key);
251
+ });
252
+ }
253
+ _required = column.required;
254
+ _rules = column.rules;
255
+ _labelRequired = column.labelRequired;
256
+ if ((0, _lodash.isFunction)(column.required)) {
257
+ _required = column.required(value, record);
258
+ }
259
+ if ((0, _lodash.isFunction)(column.rules)) {
260
+ _rules = column.rules(value, record);
261
+ }
262
+ if ((0, _lodash.isFunction)(column.labelRequired)) {
263
+ _labelRequired = column.labelRequired(value, record);
264
+ }
265
+ if (!(((_column$names2 = column.names) === null || _column$names2 === void 0 ? void 0 : _column$names2.length) && _labelRequired !== null && _labelRequired !== undefined && _isNull(value))) {
266
+ _context.next = 11;
267
+ break;
268
+ }
269
+ return _context.abrupt("return", false);
270
+ case 11:
271
+ if (!(_required && _isNull(value))) {
272
+ _context.next = 13;
273
+ break;
274
+ }
275
+ return _context.abrupt("return", false);
276
+ case 13:
277
+ if (!((_rules2 = _rules) === null || _rules2 === void 0 ? void 0 : _rules2.length)) {
278
+ _context.next = 44;
279
+ break;
280
+ }
281
+ res = true;
282
+ _iterator = (0, _createForOfIteratorHelper2.default)(_rules);
283
+ _context.prev = 16;
284
+ _iterator.s();
285
+ case 18:
286
+ if ((_step = _iterator.n()).done) {
287
+ _context.next = 35;
288
+ break;
289
+ }
290
+ rule = _step.value;
291
+ if (res) {
292
+ _context.next = 22;
293
+ break;
294
+ }
295
+ return _context.abrupt("break", 35);
296
+ case 22:
297
+ if (rule.required && _isNull(value)) {
298
+ res = false;
299
+ }
300
+ if (!(0, _lodash.isFunction)(rule.validator)) {
301
+ _context.next = 32;
302
+ break;
303
+ }
304
+ _context.prev = 24;
305
+ _context.next = 27;
306
+ return rule.validator('', value);
307
+ case 27:
308
+ _context.next = 32;
309
+ break;
310
+ case 29:
311
+ _context.prev = 29;
312
+ _context.t0 = _context["catch"](24);
313
+ res = false;
314
+ case 32:
315
+ if (rule.type && !_utils.validate[rule.type](value)) {
316
+ res = false;
317
+ }
318
+ case 33:
319
+ _context.next = 18;
320
+ break;
321
+ case 35:
322
+ _context.next = 40;
323
+ break;
324
+ case 37:
325
+ _context.prev = 37;
326
+ _context.t1 = _context["catch"](16);
327
+ _iterator.e(_context.t1);
328
+ case 40:
329
+ _context.prev = 40;
330
+ _iterator.f();
331
+ return _context.finish(40);
332
+ case 43:
333
+ return _context.abrupt("return", res);
334
+ case 44:
335
+ return _context.abrupt("return", true);
336
+ case 45:
337
+ case "end":
338
+ return _context.stop();
339
+ }
340
+ }, _callee, null, [[16, 37, 40, 43], [24, 29]]);
341
+ }));
342
+ return function handleCheckCellValue(_x, _x2) {
343
+ return _ref6.apply(this, arguments);
344
+ };
345
+ }();
346
+ var onPageCheck = exports.onPageCheck = /*#__PURE__*/function () {
347
+ var _ref8 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(_ref7) {
348
+ 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;
349
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
350
+ while (1) switch (_context2.prev = _context2.next) {
351
+ case 0:
352
+ form = _ref7.form, name = _ref7.name, value = _ref7.value, columns = _ref7.columns, page = _ref7.page, pagination = _ref7.pagination, setState = _ref7.setState;
353
+ if (!pagination) {
354
+ _context2.next = 75;
355
+ break;
356
+ }
357
+ pageNum = page.pageNum, pageSize = page.pageSize;
358
+ pageArr = Array.from({
359
+ length: Math.ceil(_utils.tools.calc(value.length, '/', pageSize))
360
+ }, function (_, i) {
361
+ return i + 1;
362
+ });
363
+ flag = false;
364
+ errorNum = 0;
365
+ errorPageNum = 0;
366
+ _i = 0, _pageArr = pageArr;
367
+ case 8:
368
+ if (!(_i < _pageArr.length)) {
369
+ _context2.next = 60;
370
+ break;
371
+ }
372
+ item = _pageArr[_i];
373
+ if (!flag) {
374
+ _context2.next = 12;
375
+ break;
376
+ }
377
+ return _context2.abrupt("break", 60);
378
+ case 12:
379
+ errorNum = 0;
380
+ // 实现思路:截取每一页数据,手动触发每一行数据的校验,通过column配置的rule规则,
381
+ // 依次校验每一页数据,有错误就跳出循环,跳转到错误页数,并展示错误单元格数量
382
+ start = _utils.tools.calc(item - 1, '*', pageSize);
383
+ end = _utils.tools.calc(start, '+', pageSize);
384
+ nextValues = value === null || value === void 0 ? void 0 : value.slice(start, end);
385
+ _iterator2 = (0, _createForOfIteratorHelper2.default)(nextValues);
386
+ _context2.prev = 17;
387
+ _iterator2.s();
388
+ case 19:
389
+ if ((_step2 = _iterator2.n()).done) {
390
+ _context2.next = 48;
391
+ break;
392
+ }
393
+ record = _step2.value;
394
+ _iterator3 = (0, _createForOfIteratorHelper2.default)(columns);
395
+ _context2.prev = 22;
396
+ _iterator3.s();
397
+ case 24:
398
+ if ((_step3 = _iterator3.n()).done) {
399
+ _context2.next = 38;
400
+ break;
401
+ }
402
+ column = _step3.value;
403
+ _context2.prev = 26;
404
+ _context2.next = 29;
405
+ return handleCheckCellValue(column, record);
406
+ case 29:
407
+ result = _context2.sent;
408
+ if (!result) {
409
+ errorNum += 1;
410
+ }
411
+ _context2.next = 36;
412
+ break;
413
+ case 33:
414
+ _context2.prev = 33;
415
+ _context2.t0 = _context2["catch"](26);
416
+ errorNum += 1;
417
+ case 36:
418
+ _context2.next = 24;
419
+ break;
420
+ case 38:
421
+ _context2.next = 43;
422
+ break;
423
+ case 40:
424
+ _context2.prev = 40;
425
+ _context2.t1 = _context2["catch"](22);
426
+ _iterator3.e(_context2.t1);
427
+ case 43:
428
+ _context2.prev = 43;
429
+ _iterator3.f();
430
+ return _context2.finish(43);
431
+ case 46:
432
+ _context2.next = 19;
433
+ break;
434
+ case 48:
435
+ _context2.next = 53;
436
+ break;
437
+ case 50:
438
+ _context2.prev = 50;
439
+ _context2.t2 = _context2["catch"](17);
440
+ _iterator2.e(_context2.t2);
441
+ case 53:
442
+ _context2.prev = 53;
443
+ _iterator2.f();
444
+ return _context2.finish(53);
445
+ case 56:
446
+ if (errorNum > 0) {
447
+ flag = true;
448
+ errorPageNum = item;
449
+ }
450
+ case 57:
451
+ _i++;
452
+ _context2.next = 8;
453
+ break;
454
+ case 60:
455
+ if (!(flag && errorNum > 0)) {
456
+ _context2.next = 74;
457
+ break;
458
+ }
459
+ nextState = {
460
+ pageErrorNum: errorNum > 0 ? errorNum : 0
461
+ };
462
+ if (pageNum !== errorPageNum) {
463
+ nextState.page = {
464
+ pageNum: errorPageNum,
465
+ pageSize: pageSize
466
+ };
467
+ }
468
+ setState(nextState);
469
+ _context2.prev = 64;
470
+ _context2.next = 67;
471
+ return form.validateFields([name], {
472
+ recursive: true
473
+ });
474
+ case 67:
475
+ _context2.next = 72;
476
+ break;
477
+ case 69:
478
+ _context2.prev = 69;
479
+ _context2.t3 = _context2["catch"](64);
480
+ handleScrollToError();
481
+ case 72:
482
+ _context2.next = 75;
483
+ break;
484
+ case 74:
485
+ setState({
486
+ pageErrorNum: 0
487
+ });
488
+ case 75:
489
+ case "end":
490
+ return _context2.stop();
491
+ }
492
+ }, _callee2, null, [[17, 50, 53, 56], [22, 40, 43, 46], [26, 33], [64, 69]]);
493
+ }));
494
+ return function onPageCheck(_x3) {
495
+ return _ref8.apply(this, arguments);
496
+ };
497
+ }();
@@ -63,6 +63,8 @@ var useForm = exports.useForm = function useForm(originForm, options) {
63
63
  _form$getInternalHook,
64
64
  getFields,
65
65
  fieldsList,
66
+ tablePagination,
67
+ _tablePagination$clic,
66
68
  _error$errorFields,
67
69
  _error$errorFields$,
68
70
  _args = arguments;
@@ -101,14 +103,18 @@ var useForm = exports.useForm = function useForm(originForm, options) {
101
103
  case 11:
102
104
  return _context.abrupt("return", _context.sent);
103
105
  case 12:
104
- _context.next = 14;
106
+ tablePagination = document.querySelector('#pro-edit-table-pagination');
107
+ if (tablePagination) {
108
+ tablePagination === null || tablePagination === void 0 ? void 0 : (_tablePagination$clic = tablePagination.click) === null || _tablePagination$clic === void 0 ? void 0 : _tablePagination$clic.call(tablePagination);
109
+ }
110
+ _context.next = 16;
105
111
  return validateFields.apply(void 0, [nameList].concat(rest)).then(function (values) {
106
112
  return nameList ? values : _getFieldsValue();
107
113
  });
108
- case 14:
114
+ case 16:
109
115
  return _context.abrupt("return", _context.sent);
110
- case 17:
111
- _context.prev = 17;
116
+ case 19:
117
+ _context.prev = 19;
112
118
  _context.t0 = _context["catch"](0);
113
119
  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)) {
114
120
  form.scrollToField((_error$errorFields$ = _context.t0.errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name, {
@@ -118,11 +124,11 @@ var useForm = exports.useForm = function useForm(originForm, options) {
118
124
  }
119
125
  (0, _tools.handleScrollToError)();
120
126
  throw _context.t0;
121
- case 22:
127
+ case 24:
122
128
  case "end":
123
129
  return _context.stop();
124
130
  }
125
- }, _callee, null, [[0, 17]]);
131
+ }, _callee, null, [[0, 19]]);
126
132
  }));
127
133
  return function _validateFields(_x) {
128
134
  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;
@@ -13,52 +13,64 @@ var _reactLazyload = _interopRequireDefault(require("react-lazyload"));
13
13
  var _lodash = require("lodash");
14
14
  var _index = require("../../index");
15
15
  var _ProCollapse = _interopRequireDefault(require("../../../ProLayout/components/ProCollapse"));
16
- var _excluded = ["id", "title", "collapse", "children"];
16
+ var _excluded = ["id", "title", "collapse", "children", "lazyLoad"];
17
17
  var defaultLazyLoadConfig = {
18
18
  height: 100,
19
19
  offset: 100,
20
- once: true // 保证只在首次进入视口时触发懒加载
20
+ once: true // Load only once upon first entry into the viewport
21
21
  };
22
- var ProStepItem = function ProStepItem(_ref) {
22
+ function ProStepItem(_ref) {
23
23
  var id = _ref.id,
24
24
  title = _ref.title,
25
25
  _ref$collapse = _ref.collapse,
26
26
  collapseItem = _ref$collapse === void 0 ? true : _ref$collapse,
27
27
  children = _ref.children,
28
+ lazyLoad = _ref.lazyLoad,
28
29
  restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
29
30
  var _useStep = (0, _index.useStep)(),
30
31
  register = _useStep.register,
31
32
  collapse = _useStep.collapse;
32
33
  (0, _react.useEffect)(function () {
33
- // 延迟更新父组件状态,避免重渲染
34
+ // Schedule registration to avoid re-render issues
34
35
  var timeoutId = setTimeout(function () {
35
- register === null || register === void 0 ? void 0 : register((0, _objectSpread2.default)((0, _objectSpread2.default)({}, restProps), {}, {
36
+ register === null || register === void 0 ? void 0 : register((0, _objectSpread2.default)({
37
+ id: id,
36
38
  title: title,
37
- id: id
38
- }));
39
+ lazyLoad: lazyLoad
40
+ }, restProps));
39
41
  }, 0);
40
42
  return function () {
41
43
  return clearTimeout(timeoutId);
42
44
  };
43
- }, [register]);
44
- var childrenRender = function childrenRender() {
45
- if (restProps === null || restProps === void 0 ? void 0 : restProps.lazyLoad) {
46
- var lazyLoadProps = (0, _lodash.isBoolean)(restProps === null || restProps === void 0 ? void 0 : restProps.lazyLoad) ? defaultLazyLoadConfig : restProps.lazyLoad;
45
+ }, [id, title, lazyLoad, restProps, register]);
46
+ var renderChildren = function renderChildren() {
47
+ if (lazyLoad) {
48
+ var lazyLoadProps = (0, _lodash.isBoolean)(lazyLoad) ? defaultLazyLoadConfig : lazyLoad;
47
49
  return (0, _jsxRuntime.jsx)(_reactLazyload.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, lazyLoadProps), {}, {
50
+ classNamePrefix: id,
48
51
  children: children
49
52
  }));
50
53
  }
51
54
  return children;
52
55
  };
56
+ // If there's no `register` function or if collapsing is enabled, wrap in ProCollapse
57
+ if (!register || collapse && collapseItem && title) {
58
+ return (0, _jsxRuntime.jsx)("div", {
59
+ className: "pro-step-item",
60
+ id: id,
61
+ children: (0, _jsxRuntime.jsx)(_ProCollapse.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
62
+ title: title,
63
+ icon: true
64
+ }, restProps), {}, {
65
+ children: renderChildren()
66
+ }))
67
+ });
68
+ }
69
+ // Otherwise, just render children
53
70
  return (0, _jsxRuntime.jsx)("div", {
54
71
  className: "pro-step-item",
55
72
  id: id,
56
- children: !register || collapse && collapseItem && title ? (0, _jsxRuntime.jsx)(_ProCollapse.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
57
- title: title,
58
- icon: true
59
- }, restProps), {}, {
60
- children: childrenRender()
61
- })) : childrenRender()
73
+ children: renderChildren()
62
74
  });
63
- };
75
+ }
64
76
  var _default = exports.default = ProStepItem;