@zat-design/sisyphus-react 3.6.2 → 3.6.3

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 (35) hide show
  1. package/dist/index.esm.css +3 -3
  2. package/dist/less.esm.css +3 -3
  3. package/es/ProEditTable/components/ActionButton/index.js +4 -4
  4. package/es/ProEditTable/components/RenderToolbar/index.js +12 -22
  5. package/es/ProEditTable/utils/index.js +14 -23
  6. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -4
  7. package/es/ProForm/components/combination/FormList/index.js +5 -0
  8. package/es/ProForm/components/combination/ProCascader/index.js +43 -15
  9. package/es/ProForm/components/combination/ProCascader/style/index.less +3 -3
  10. package/es/ProForm/components/render/Render.js +1 -1
  11. package/es/ProLayout/index.js +5 -2
  12. package/es/ProLayout/propTypes.d.ts +4 -0
  13. package/es/ProLayout/utils/index.d.ts +2 -2
  14. package/es/ProLayout/utils/index.js +6 -4
  15. package/es/ProSelect/utils/index.js +3 -2
  16. package/es/ProStep/components/Listener/index.js +3 -8
  17. package/es/ProStep/index.js +48 -73
  18. package/lib/ProEditTable/components/ActionButton/index.js +4 -4
  19. package/lib/ProEditTable/components/RenderToolbar/index.js +12 -22
  20. package/lib/ProEditTable/utils/index.js +14 -23
  21. package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +2 -4
  22. package/lib/ProForm/components/combination/FormList/index.js +5 -0
  23. package/lib/ProForm/components/combination/ProCascader/index.js +42 -14
  24. package/lib/ProForm/components/combination/ProCascader/style/index.less +3 -3
  25. package/lib/ProForm/components/render/Render.js +1 -1
  26. package/lib/ProLayout/index.js +5 -2
  27. package/lib/ProLayout/propTypes.d.ts +4 -0
  28. package/lib/ProLayout/utils/index.d.ts +2 -2
  29. package/lib/ProLayout/utils/index.js +6 -4
  30. package/lib/ProSelect/utils/index.js +3 -2
  31. package/lib/ProStep/components/Listener/index.js +3 -8
  32. package/lib/ProStep/index.js +46 -71
  33. package/package.json +1 -1
  34. package/es/ProWaterMark/__snapshots__/index.test.tsx.snap +0 -7
  35. package/lib/ProWaterMark/__snapshots__/index.test.tsx.snap +0 -7
@@ -10,7 +10,8 @@ var _lodash = _interopRequireDefault(require("lodash"));
10
10
  /* eslint-disable no-restricted-syntax */
11
11
 
12
12
  var findSelectNameValues = function findSelectNameValues(_ref) {
13
- var list = _ref.list,
13
+ var _ref$list = _ref.list,
14
+ list = _ref$list === void 0 ? [] : _ref$list,
14
15
  selectName = _ref.selectName,
15
16
  value = _ref.value,
16
17
  dataSource = _ref.dataSource,
@@ -61,7 +62,7 @@ var getSelectList = exports.getSelectList = function getSelectList(_ref2) {
61
62
  var fatherName = listName.slice(0, firstNumberIndex);
62
63
  var selectName = listName.slice(firstNumberIndex + 1);
63
64
  return findSelectNameValues({
64
- list: form.getFieldValue(fatherName),
65
+ list: form.getFieldValue(fatherName) || [],
65
66
  selectName: selectName,
66
67
  value: value,
67
68
  dataSource: dataSource,
@@ -14,16 +14,12 @@ var _react = _interopRequireDefault(require("react"));
14
14
  var _index = require("../../index");
15
15
  var _excluded = ["children", "delayTime"];
16
16
  var _default = exports.default = function _default(_ref) {
17
- var _children$props;
18
17
  var children = _ref.children,
19
18
  delayTime = _ref.delayTime,
20
19
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
21
20
  var _useStep = (0, _index.useStep)(),
22
- notify = _useStep.notify,
23
- loading = _useStep.loading,
24
- setLoading = _useStep.setLoading;
21
+ notify = _useStep.notify;
25
22
  return /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
26
- loading: loading || (children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.loading),
27
23
  onClick: (0, _lodash.throttle)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
28
24
  var values;
29
25
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
@@ -35,11 +31,10 @@ var _default = exports.default = function _default(_ref) {
35
31
  case 3:
36
32
  values = _context.sent;
37
33
  setTimeout(function () {
38
- setLoading(false);
39
34
  var localData = localStorage.getItem('cache-pro-step');
40
35
  if (localData !== 'false') {
41
- var _children$props2, _children$props2$onCl;
42
- children === null || children === void 0 ? void 0 : (_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : (_children$props2$onCl = _children$props2.onClick) === null || _children$props2$onCl === void 0 ? void 0 : _children$props2$onCl.call(_children$props2, values);
36
+ var _children$props, _children$props$onCli;
37
+ 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);
43
38
  }
44
39
  }, delayTime !== null && delayTime !== void 0 ? delayTime : 0);
45
40
  case 5:
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.useStep = exports.default = exports.ProStepContext = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
9
  var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
13
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
14
14
  var _jsxRuntime = require("react/jsx-runtime");
@@ -27,21 +27,16 @@ var useStep = exports.useStep = function useStep() {
27
27
  var ProStep = function ProStep(_ref) {
28
28
  var children = _ref.children,
29
29
  resetProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
30
- var emitter = (0, _ahooks.useEventEmitter)();
30
+ var _useState = (0, _react.useState)([]),
31
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
32
+ ids = _useState2[0],
33
+ setIds = _useState2[1];
31
34
  var _useSetState = (0, _ahooks.useSetState)({}),
32
35
  _useSetState2 = (0, _slicedToArray2.default)(_useSetState, 2),
33
36
  errorCollection = _useSetState2[0],
34
37
  setErrorCollection = _useSetState2[1];
35
38
  // 注册子节点id与title映射的集合
36
39
  var registerMap = (0, _react.useRef)({});
37
- var _useState = (0, _react.useState)([]),
38
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
39
- anchorIds = _useState2[0],
40
- setAnchorIds = _useState2[1];
41
- var _useState3 = (0, _react.useState)(false),
42
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
43
- loading = _useState4[0],
44
- setLoading = _useState4[1];
45
40
  var _useLocalStorageState = (0, _ahooks.useLocalStorageState)('cache-pro-step'),
46
41
  _useLocalStorageState2 = (0, _slicedToArray2.default)(_useLocalStorageState, 2),
47
42
  setLocalData = _useLocalStorageState2[1];
@@ -50,7 +45,6 @@ var ProStep = function ProStep(_ref) {
50
45
  collapse = _resetProps$collapse === void 0 ? false : _resetProps$collapse,
51
46
  _resetProps$scrollToE = resetProps.scrollToError,
52
47
  scrollToError = _resetProps$scrollToE === void 0 ? true : _resetProps$scrollToE;
53
- var values = {};
54
48
  var dataSource = (0, _react.useMemo)(function () {
55
49
  var _Object$entries, _Object$entries$map;
56
50
  if (resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource) {
@@ -68,14 +62,14 @@ var ProStep = function ProStep(_ref) {
68
62
  order: order
69
63
  };
70
64
  }).filter(function (item) {
71
- return anchorIds.includes(item.code);
65
+ var _ids$includes;
66
+ return ids === null || ids === void 0 ? void 0 : (_ids$includes = ids.includes) === null || _ids$includes === void 0 ? void 0 : _ids$includes.call(ids, item.code);
72
67
  }).sort(function (pre, next) {
73
68
  return pre.order - next.order;
74
69
  });
75
- }, [resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource, registerMap.current, anchorIds]);
70
+ }, [resetProps === null || resetProps === void 0 ? void 0 : resetProps.dataSource, registerMap.current, ids]);
76
71
  // 用来注册form匹配到对应的模块id
77
72
  var register = function register(_ref4) {
78
- var _registerMap$current;
79
73
  var id = _ref4.id,
80
74
  form = _ref4.form,
81
75
  title = _ref4.title,
@@ -85,18 +79,23 @@ var ProStep = function ProStep(_ref) {
85
79
  var record = {};
86
80
  record.title = title;
87
81
  record.order = order;
82
+ if (!ids.includes(id)) {
83
+ setIds(function (preState) {
84
+ return [].concat((0, _toConsumableArray2.default)(preState), [id]);
85
+ });
86
+ }
88
87
  if (disabled) {
89
88
  registerMap.current[id] = record;
90
89
  return null;
91
90
  }
92
91
  var subEvent = /*#__PURE__*/function () {
93
92
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
94
- var num, _form$validateFields, _errors$errorFields;
93
+ var value, _form$validateFields, _error$errorFields;
95
94
  return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
96
95
  while (1) switch (_context.prev = _context.next) {
97
96
  case 0:
98
- num = 0;
99
- _context.prev = 1;
97
+ _context.prev = 0;
98
+ value = null;
100
99
  if (!validator) {
101
100
  _context.next = 8;
102
101
  break;
@@ -104,58 +103,60 @@ var ProStep = function ProStep(_ref) {
104
103
  _context.next = 5;
105
104
  return validator === null || validator === void 0 ? void 0 : validator();
106
105
  case 5:
107
- values[id] = _context.sent;
106
+ value = _context.sent;
108
107
  _context.next = 11;
109
108
  break;
110
109
  case 8:
111
110
  _context.next = 10;
112
111
  return form === null || form === void 0 ? void 0 : (_form$validateFields = form.validateFields) === null || _form$validateFields === void 0 ? void 0 : _form$validateFields.call(form);
113
112
  case 10:
114
- values[id] = _context.sent;
113
+ value = _context.sent;
115
114
  case 11:
116
- setErrorCollection((0, _defineProperty2.default)({}, id, 0));
117
- _context.next = 21;
118
- break;
115
+ return _context.abrupt("return", value);
119
116
  case 14:
120
117
  _context.prev = 14;
121
- _context.t0 = _context["catch"](1);
122
- num = _context.t0 === null || _context.t0 === void 0 ? void 0 : (_errors$errorFields = _context.t0.errorFields) === null || _errors$errorFields === void 0 ? void 0 : _errors$errorFields.length;
123
- if (num) {
124
- setLocalData(false);
118
+ _context.t0 = _context["catch"](0);
119
+ if (_context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$errorFields = _context.t0.errorFields) === null || _error$errorFields === void 0 ? void 0 : _error$errorFields.length) {
125
120
  console.error(_context.t0);
121
+ setLocalData(false);
126
122
  }
127
- setErrorCollection((0, _defineProperty2.default)({}, id, num));
128
- setLoading(false);
129
123
  return _context.abrupt("return", _context.t0);
130
- case 21:
131
- return _context.abrupt("return", values[id]);
132
- case 22:
124
+ case 18:
133
125
  case "end":
134
126
  return _context.stop();
135
127
  }
136
- }, _callee, null, [[1, 14]]);
128
+ }, _callee, null, [[0, 14]]);
137
129
  }));
138
130
  return function subEvent() {
139
131
  return _ref5.apply(this, arguments);
140
132
  };
141
133
  }();
142
134
  record.subEvent = subEvent;
143
- if (title && !(registerMap === null || registerMap === void 0 ? void 0 : (_registerMap$current = registerMap.current) === null || _registerMap$current === void 0 ? void 0 : _registerMap$current[id])) {
144
- registerMap.current[id] = record;
145
- }
146
- emitter.useSubscription(subEvent);
135
+ registerMap.current[id] = record;
147
136
  };
148
137
  var notify = /*#__PURE__*/function () {
149
138
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
139
+ var events, res, nextErrorCollection;
150
140
  return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
151
141
  while (1) switch (_context2.prev = _context2.next) {
152
142
  case 0:
153
- setLoading(true);
143
+ events = Object.values(registerMap.current).map(function (item) {
144
+ var _item$subEvent;
145
+ return item === null || item === void 0 ? void 0 : (_item$subEvent = item.subEvent) === null || _item$subEvent === void 0 ? void 0 : _item$subEvent.call(item);
146
+ });
154
147
  _context2.next = 3;
155
- return emitter.emit();
148
+ return Promise.all(events);
156
149
  case 3:
157
- return _context2.abrupt("return", values);
158
- case 4:
150
+ res = _context2.sent;
151
+ nextErrorCollection = {};
152
+ Object.keys(registerMap.current).forEach(function (id, index) {
153
+ var _ref7 = (res === null || res === void 0 ? void 0 : res[index]) || {},
154
+ errorFields = _ref7.errorFields;
155
+ nextErrorCollection[id] = (errorFields === null || errorFields === void 0 ? void 0 : errorFields.length) || 0;
156
+ });
157
+ setErrorCollection(nextErrorCollection);
158
+ return _context2.abrupt("return", res);
159
+ case 8:
159
160
  case "end":
160
161
  return _context2.stop();
161
162
  }
@@ -165,37 +166,16 @@ var ProStep = function ProStep(_ref) {
165
166
  return _ref6.apply(this, arguments);
166
167
  };
167
168
  }();
168
- var handleListenerDom = function handleListenerDom() {
169
- var targetElement = document.getElementById('pro-step');
170
- var observer = new MutationObserver(function (mutations) {
171
- mutations.forEach(function (mutation) {
172
- // 处理 DOM 树变化的逻辑
173
- var Anchors = document.getElementsByClassName('pro-step-item') || [];
174
- // 当前页面所存在的所有折叠项
175
- var nextAnchorIds = [];
176
- Array.prototype.slice.call(Anchors).forEach(function (dom) {
177
- var id = dom.getAttribute('id');
178
- nextAnchorIds.push(id);
179
- });
180
- setAnchorIds(nextAnchorIds);
181
- });
182
- });
183
- var config = {
184
- subtree: true,
185
- childList: true // 是否观察子元素的添加或删除
186
- };
187
- observer.observe(targetElement, config);
188
- };
189
169
  var triggerTo = /*#__PURE__*/function () {
190
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(keys) {
170
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(keys) {
191
171
  var events, result, nextErrorCollection;
192
172
  return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
193
173
  while (1) switch (_context3.prev = _context3.next) {
194
174
  case 0:
195
175
  events = [];
196
176
  keys === null || keys === void 0 ? void 0 : keys.forEach(function (key) {
197
- var _registerMap$current2, _registerMap$current3, _registerMap$current4;
198
- events.push(registerMap === null || registerMap === void 0 ? void 0 : (_registerMap$current2 = registerMap.current) === null || _registerMap$current2 === void 0 ? void 0 : (_registerMap$current3 = _registerMap$current2[key]) === null || _registerMap$current3 === void 0 ? void 0 : (_registerMap$current4 = _registerMap$current3.subEvent) === null || _registerMap$current4 === void 0 ? void 0 : _registerMap$current4.call(_registerMap$current3));
177
+ var _registerMap$current, _registerMap$current$, _registerMap$current$2;
178
+ events.push(registerMap === null || registerMap === void 0 ? void 0 : (_registerMap$current = registerMap.current) === null || _registerMap$current === void 0 ? void 0 : (_registerMap$current$ = _registerMap$current[key]) === null || _registerMap$current$ === void 0 ? void 0 : (_registerMap$current$2 = _registerMap$current$.subEvent) === null || _registerMap$current$2 === void 0 ? void 0 : _registerMap$current$2.call(_registerMap$current$));
199
179
  });
200
180
  _context3.next = 4;
201
181
  return Promise.all(events);
@@ -218,7 +198,7 @@ var ProStep = function ProStep(_ref) {
218
198
  }, _callee3);
219
199
  }));
220
200
  return function triggerTo(_x) {
221
- return _ref7.apply(this, arguments);
201
+ return _ref8.apply(this, arguments);
222
202
  };
223
203
  }();
224
204
  (0, _ahooks.useDeepCompareEffect)(function () {
@@ -237,18 +217,13 @@ var ProStep = function ProStep(_ref) {
237
217
  });
238
218
  }
239
219
  }, [errorCollection, dataSource]);
240
- (0, _react.useEffect)(function () {
241
- handleListenerDom();
242
- }, []);
243
220
  return (0, _jsxRuntime.jsx)(ProStepContext.Provider, {
244
221
  value: {
245
222
  collapse: collapse,
246
223
  register: register,
247
224
  notify: notify,
248
225
  triggerTo: triggerTo,
249
- handleScroll: _utils.handleScroll,
250
- loading: loading,
251
- setLoading: setLoading
226
+ handleScroll: _utils.handleScroll
252
227
  },
253
228
  children: (0, _jsxRuntime.jsxs)("div", {
254
229
  className: "pro-step-wrapper",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.6.2",
3
+ "version": "3.6.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,7 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`render ProWaterMark with dumi 1`] = `
4
- <span>
5
- 123
6
- </span>
7
- `;
@@ -1,7 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`render ProWaterMark with dumi 1`] = `
4
- <span>
5
- 123
6
- </span>
7
- `;