@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.
Files changed (42) hide show
  1. package/dist/index.esm.css +8 -0
  2. package/dist/less.esm.css +8 -0
  3. package/es/ProEditTable/components/RcTable/BaseTable.js +13 -2
  4. package/es/ProEditTable/components/RcTable/VirtualTable.d.ts +2 -5
  5. package/es/ProEditTable/components/RcTable/VirtualTable.js +5 -163
  6. package/es/ProEditTable/components/RcTable/index.d.ts +1 -1
  7. package/es/ProEditTable/components/RcTable/index.js +1 -1
  8. package/es/ProEditTable/index.js +20 -4
  9. package/es/ProEditTable/propsType.d.ts +1 -0
  10. package/es/ProEditTable/style/index.less +8 -0
  11. package/es/ProEditTable/utils/tools.d.ts +9 -0
  12. package/es/ProEditTable/utils/tools.js +277 -2
  13. package/es/ProForm/components/base/InputNumber/index.js +2 -1
  14. package/es/ProForm/utils/useForm.js +12 -6
  15. package/es/ProStep/components/Item/index.d.ts +3 -3
  16. package/es/ProStep/components/Item/index.js +51 -16
  17. package/es/ProStep/components/Listener/index.js +13 -4
  18. package/es/ProStep/index.d.ts +1 -1
  19. package/es/ProStep/index.js +20 -8
  20. package/es/ProStep/propsType.d.ts +12 -1
  21. package/es/ProStep/utils/index.d.ts +3 -0
  22. package/es/ProStep/utils/index.js +14 -1
  23. package/lib/ProEditTable/components/RcTable/BaseTable.js +11 -2
  24. package/lib/ProEditTable/components/RcTable/VirtualTable.d.ts +2 -5
  25. package/lib/ProEditTable/components/RcTable/VirtualTable.js +3 -161
  26. package/lib/ProEditTable/components/RcTable/index.d.ts +1 -1
  27. package/lib/ProEditTable/index.js +19 -3
  28. package/lib/ProEditTable/propsType.d.ts +1 -0
  29. package/lib/ProEditTable/style/index.less +8 -0
  30. package/lib/ProEditTable/utils/tools.d.ts +9 -0
  31. package/lib/ProEditTable/utils/tools.js +278 -2
  32. package/lib/ProForm/components/base/InputNumber/index.js +2 -1
  33. package/lib/ProForm/utils/useForm.js +12 -6
  34. package/lib/ProStep/components/Item/index.d.ts +3 -3
  35. package/lib/ProStep/components/Item/index.js +51 -16
  36. package/lib/ProStep/components/Listener/index.js +13 -4
  37. package/lib/ProStep/index.d.ts +1 -1
  38. package/lib/ProStep/index.js +20 -8
  39. package/lib/ProStep/propsType.d.ts +12 -1
  40. package/lib/ProStep/utils/index.d.ts +3 -0
  41. package/lib/ProStep/utils/index.js +15 -1
  42. package/package.json +7 -6
@@ -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
+ }();
@@ -52,12 +52,13 @@ var InputNumber = function InputNumber(props) {
52
52
  var _ref2 = _ProForm.default.useFieldProps() || {},
53
53
  isViewCon = _ref2.isView,
54
54
  viewEmpty = _ref2.viewEmpty,
55
- valueType = _ref2.valueType,
55
+ valueTypeCon = _ref2.valueType,
56
56
  viewType = _ref2.viewType,
57
57
  label = _ref2.label;
58
58
  var initialConfig = (0, _ProConfigProvider.useProConfig)('InputNumber');
59
59
  var activateRef = (0, _react.useRef)(false);
60
60
  var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
61
+ var valueType = 'valueType' in props ? props.valueType : valueTypeCon; // 组件可直接接收valueType参数, 优先级高
61
62
  var valueProps = {};
62
63
  var formatter = function formatter(value) {
63
64
  var _props$precision;
@@ -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
- 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, lazyLoad: stepLazyLoad, ...restProps }: ProStepItemPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default ProStepItem;
@@ -9,40 +9,75 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  var _react = require("react");
12
+ var _reactLazyload = _interopRequireDefault(require("react-lazyload"));
13
+ var _lodash = require("lodash");
12
14
  var _index = require("../../index");
15
+ var _utils = require("../../utils");
13
16
  var _ProCollapse = _interopRequireDefault(require("../../../ProLayout/components/ProCollapse"));
14
- var _excluded = ["id", "title", "collapse", "children"];
15
- var _default = exports.default = function _default(_ref) {
17
+ var _excluded = ["id", "title", "collapse", "children", "lazyLoad"];
18
+ var defaultLazyLoadConfig = {
19
+ height: 100,
20
+ offset: 100,
21
+ once: true // Load only once upon first entry into the viewport
22
+ };
23
+ var ProStepItem = function ProStepItem(_ref) {
16
24
  var id = _ref.id,
17
25
  title = _ref.title,
18
26
  _ref$collapse = _ref.collapse,
19
27
  collapseItem = _ref$collapse === void 0 ? true : _ref$collapse,
20
28
  children = _ref.children,
29
+ stepLazyLoad = _ref.lazyLoad,
21
30
  restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
22
31
  var _useStep = (0, _index.useStep)(),
23
32
  register = _useStep.register,
24
- collapse = _useStep.collapse;
33
+ collapse = _useStep.collapse,
34
+ globalLazyLoad = _useStep.lazyLoad,
35
+ registerMap = _useStep.registerMap;
36
+ var lazyLoad = stepLazyLoad || globalLazyLoad;
37
+ var loadedMap = (0, _utils.getLoadedMap)(registerMap);
25
38
  (0, _react.useEffect)(function () {
26
- // 子组件更新父组件 延迟状态更新,避免重渲染
39
+ // Schedule registration to avoid re-render issues
27
40
  var timeoutId = setTimeout(function () {
28
- register === null || register === void 0 ? void 0 : register((0, _objectSpread2.default)((0, _objectSpread2.default)({}, restProps), {}, {
41
+ register === null || register === void 0 ? void 0 : register((0, _objectSpread2.default)({
42
+ id: id,
29
43
  title: title,
30
- id: id
31
- }));
44
+ lazyLoad: lazyLoad
45
+ }, restProps));
32
46
  }, 0);
33
47
  return function () {
34
48
  return clearTimeout(timeoutId);
35
49
  };
36
- }, [register]);
50
+ }, [id, title, lazyLoad, restProps, register]);
51
+ var renderChildren = function renderChildren() {
52
+ var _loadedMap$;
53
+ // 第一个step不设置lasyload,防止懒加载不生效
54
+ 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) {
55
+ var lazyLoadProps = (0, _lodash.isBoolean)(lazyLoad) ? defaultLazyLoadConfig : lazyLoad;
56
+ return (0, _jsxRuntime.jsx)(_reactLazyload.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, lazyLoadProps), {}, {
57
+ classNamePrefix: id,
58
+ children: children
59
+ }));
60
+ }
61
+ return children;
62
+ };
63
+ // If there's no `register` function or if collapsing is enabled, wrap in ProCollapse
64
+ if (!register || collapse && collapseItem && title) {
65
+ return (0, _jsxRuntime.jsx)("div", {
66
+ className: "pro-step-item",
67
+ id: id,
68
+ children: (0, _jsxRuntime.jsx)(_ProCollapse.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
69
+ title: title,
70
+ icon: true
71
+ }, restProps), {}, {
72
+ children: renderChildren()
73
+ }))
74
+ });
75
+ }
76
+ // Otherwise, just render children
37
77
  return (0, _jsxRuntime.jsx)("div", {
38
78
  className: "pro-step-item",
39
79
  id: id,
40
- children: !register || collapse && collapseItem && title ? (0, _jsxRuntime.jsx)(_ProCollapse.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
41
- id: id,
42
- title: title,
43
- icon: true
44
- }, restProps), {}, {
45
- children: children
46
- })) : children
80
+ children: renderChildren()
47
81
  });
48
- };
82
+ };
83
+ var _default = exports.default = ProStepItem;
@@ -12,6 +12,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
12
12
  var _lodash = require("lodash");
13
13
  var _react = _interopRequireDefault(require("react"));
14
14
  var _index = require("../../index");
15
+ var _utils = require("../../utils");
15
16
  var _excluded = ["children", "delayTime", "excludes"];
16
17
  var checkErrorList = function checkErrorList(arr) {
17
18
  for (var i = 0; i < arr.length; i++) {
@@ -33,16 +34,23 @@ var findFirstErrorDom = function findFirstErrorDom() {
33
34
  }
34
35
  return null;
35
36
  };
37
+ // Function to check if all modules are loaded
38
+ var areAllModulesLoaded = function areAllModulesLoaded(data) {
39
+ return data.every(function (item) {
40
+ return (item === null || item === void 0 ? void 0 : item.loaded) === true;
41
+ });
42
+ };
36
43
  var _default = exports.default = function _default(_ref) {
37
44
  var children = _ref.children,
38
45
  delayTime = _ref.delayTime,
39
46
  excludes = _ref.excludes,
40
47
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
41
48
  var _useStep = (0, _index.useStep)(),
42
- notify = _useStep.notify;
49
+ notify = _useStep.notify,
50
+ registerMap = _useStep.registerMap;
43
51
  return /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
44
52
  onClick: (0, _lodash.throttle)(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
45
- var values;
53
+ var values, loadedMap;
46
54
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
47
55
  while (1) switch (_context.prev = _context.next) {
48
56
  case 0:
@@ -53,6 +61,7 @@ var _default = exports.default = function _default(_ref) {
53
61
  });
54
62
  case 3:
55
63
  values = _context.sent;
64
+ loadedMap = (0, _utils.getLoadedMap)(registerMap);
56
65
  setTimeout(function () {
57
66
  var localData = localStorage.getItem('cache-pro-step');
58
67
  var _ref3 = findFirstErrorDom() || {},
@@ -62,10 +71,10 @@ var _default = exports.default = function _default(_ref) {
62
71
  }
63
72
  if (localData !== 'false') {
64
73
  var _children$props, _children$props$onCli;
65
- 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);
74
+ 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);
66
75
  }
67
76
  }, delayTime !== null && delayTime !== void 0 ? delayTime : 0);
68
- case 5:
77
+ case 6:
69
78
  case "end":
70
79
  return _context.stop();
71
80
  }
@@ -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, 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;
@@ -30,10 +30,12 @@ var ProStep = function ProStep(_ref) {
30
30
  var _useState = (0, _react.useState)({}),
31
31
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
32
32
  reRender = _useState2[1];
33
- var _useSetState = (0, _ahooks.useSetState)({}),
33
+ var _useSetState = (0, _ahooks.useSetState)({
34
+ errorCollection: {}
35
+ }),
34
36
  _useSetState2 = (0, _slicedToArray2.default)(_useSetState, 2),
35
- errorCollection = _useSetState2[0],
36
- setErrorCollection = _useSetState2[1];
37
+ errorCollection = _useSetState2[0].errorCollection,
38
+ setState = _useSetState2[1];
37
39
  // 注册子节点id与title映射的集合
38
40
  var registerMap = (0, _react.useRef)({});
39
41
  var _useLocalStorageState = (0, _ahooks.useLocalStorageState)('cache-pro-step'),
@@ -44,7 +46,9 @@ var ProStep = function ProStep(_ref) {
44
46
  _resetProps$collapse = resetProps.collapse,
45
47
  collapse = _resetProps$collapse === void 0 ? false : _resetProps$collapse,
46
48
  _resetProps$scrollToE = resetProps.scrollToError,
47
- scrollToError = _resetProps$scrollToE === void 0 ? true : _resetProps$scrollToE;
49
+ scrollToError = _resetProps$scrollToE === void 0 ? true : _resetProps$scrollToE,
50
+ _resetProps$lazyLoad = resetProps.lazyLoad,
51
+ lazyLoad = _resetProps$lazyLoad === void 0 ? false : _resetProps$lazyLoad;
48
52
  var dataSource = (0, _react.useMemo)(function () {
49
53
  var _Object$entries, _Object$entries$map;
50
54
  if (resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource) {
@@ -78,8 +82,10 @@ var ProStep = function ProStep(_ref) {
78
82
  title = _ref4.title,
79
83
  validator = _ref4.validator,
80
84
  order = _ref4.order,
81
- disabled = _ref4.disabled;
85
+ disabled = _ref4.disabled,
86
+ lazyLoad = _ref4.lazyLoad;
82
87
  var record = {};
88
+ record.id = id;
83
89
  record.title = title;
84
90
  record.order = order;
85
91
  if (!registerMap.current[id]) {
@@ -162,7 +168,9 @@ var ProStep = function ProStep(_ref) {
162
168
  errorFields = _ref8.errorFields;
163
169
  nextErrorCollection[id] = (errorFields === null || errorFields === void 0 ? void 0 : errorFields.length) || 0;
164
170
  });
165
- setErrorCollection(nextErrorCollection);
171
+ setState({
172
+ errorCollection: nextErrorCollection
173
+ });
166
174
  return _context2.abrupt("return", res);
167
175
  case 11:
168
176
  case "end":
@@ -197,7 +205,9 @@ var ProStep = function ProStep(_ref) {
197
205
  nextErrorCollection[keys[index]] = item === null || item === void 0 ? void 0 : (_item$errorFields2 = item.errorFields) === null || _item$errorFields2 === void 0 ? void 0 : _item$errorFields2.length;
198
206
  }
199
207
  });
200
- setErrorCollection(nextErrorCollection);
208
+ setState({
209
+ errorCollection: nextErrorCollection
210
+ });
201
211
  return _context3.abrupt("return", result);
202
212
  case 9:
203
213
  case "end":
@@ -227,11 +237,13 @@ var ProStep = function ProStep(_ref) {
227
237
  }, [errorCollection, dataSource]);
228
238
  return (0, _jsxRuntime.jsx)(ProStepContext.Provider, {
229
239
  value: {
240
+ registerMap: registerMap,
230
241
  collapse: collapse,
231
242
  register: register,
232
243
  notify: notify,
233
244
  triggerTo: triggerTo,
234
- handleScroll: _utils.handleScroll
245
+ handleScroll: _utils.handleScroll,
246
+ lazyLoad: lazyLoad
235
247
  },
236
248
  children: (0, _jsxRuntime.jsxs)("div", {
237
249
  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 ProStepItem {
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,2 +1,5 @@
1
+ import type { LoadedMapPropsType } from '../propsType';
1
2
  export declare const handleScroll: (id: any, options: any) => void;
3
+ /** 获取加载模块数据信息 */
4
+ export declare const getLoadedMap: (registerMap: any) => LoadedMapPropsType[];
2
5
  export default handleScroll;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.handleScroll = exports.default = void 0;
7
+ exports.handleScroll = exports.getLoadedMap = exports.default = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
7
9
  var _lodash = require("lodash");
8
10
  var handleScroll = exports.handleScroll = function handleScroll(id, options) {
9
11
  var _ref = options || {},
@@ -21,4 +23,16 @@ var handleScroll = exports.handleScroll = function handleScroll(id, options) {
21
23
  }, 100), 0);
22
24
  }
23
25
  };
26
+ /** 获取加载模块数据信息 */
27
+ var getLoadedMap = exports.getLoadedMap = function getLoadedMap(registerMap) {
28
+ if (!(registerMap === null || registerMap === void 0 ? void 0 : registerMap.current)) {
29
+ return undefined;
30
+ }
31
+ var stepList = Object.values(registerMap === null || registerMap === void 0 ? void 0 : registerMap.current).map(function (item) {
32
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.pick)(item, ['id', 'order', 'title'])), {}, {
33
+ loaded: !document.querySelector(".".concat(item === null || item === void 0 ? void 0 : item.id, "-placeholder"))
34
+ });
35
+ });
36
+ return stepList;
37
+ };
24
38
  var _default = exports.default = handleScroll;