@zat-design/sisyphus-react 3.6.2-beta.3 → 3.6.2-beta.4

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
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
3
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
5
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
@@ -6,7 +7,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
7
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
7
8
  var _excluded = ["children"];
8
9
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
- import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
10
+ import { createContext, useContext, useMemo, useRef, useState } from 'react';
10
11
  import { useEventEmitter, useSetState, useLocalStorageState, useDeepCompareEffect } from 'ahooks';
11
12
  import { handleScroll } from './utils';
12
13
  import Step from './components/Step';
@@ -61,7 +62,8 @@ var ProStep = function ProStep(_ref) {
61
62
  order: order
62
63
  };
63
64
  }).filter(function (item) {
64
- return anchorIds.includes(item.code);
65
+ var _anchorIds$includes;
66
+ return anchorIds === null || anchorIds === void 0 ? void 0 : (_anchorIds$includes = anchorIds.includes) === null || _anchorIds$includes === void 0 ? void 0 : _anchorIds$includes.call(anchorIds, item.code);
65
67
  }).sort(function (pre, next) {
66
68
  return pre.order - next.order;
67
69
  });
@@ -75,6 +77,9 @@ var ProStep = function ProStep(_ref) {
75
77
  validator = _ref4.validator,
76
78
  order = _ref4.order,
77
79
  disabled = _ref4.disabled;
80
+ if (anchorIds.includes(id)) {
81
+ return null;
82
+ }
78
83
  var record = {};
79
84
  record.title = title;
80
85
  record.order = order;
@@ -136,6 +141,9 @@ var ProStep = function ProStep(_ref) {
136
141
  if (title && !(registerMap === null || registerMap === void 0 ? void 0 : (_registerMap$current = registerMap.current) === null || _registerMap$current === void 0 ? void 0 : _registerMap$current[id])) {
137
142
  registerMap.current[id] = record;
138
143
  }
144
+ setAnchorIds(function (preState) {
145
+ return _toConsumableArray(new Set([].concat(_toConsumableArray(preState), [id])));
146
+ });
139
147
  emitter.useSubscription(subEvent);
140
148
  };
141
149
  var notify = /*#__PURE__*/function () {
@@ -158,27 +166,6 @@ var ProStep = function ProStep(_ref) {
158
166
  return _ref6.apply(this, arguments);
159
167
  };
160
168
  }();
161
- var handleListenerDom = function handleListenerDom() {
162
- var targetElement = document.getElementById('pro-step');
163
- var observer = new MutationObserver(function (mutations) {
164
- mutations.forEach(function (mutation) {
165
- // 处理 DOM 树变化的逻辑
166
- var Anchors = document.getElementsByClassName('pro-step-item') || [];
167
- // 当前页面所存在的所有折叠项
168
- var nextAnchorIds = [];
169
- Array.prototype.slice.call(Anchors).forEach(function (dom) {
170
- var id = dom.getAttribute('id');
171
- nextAnchorIds.push(id);
172
- });
173
- setAnchorIds(nextAnchorIds);
174
- });
175
- });
176
- var config = {
177
- subtree: true,
178
- childList: true // 是否观察子元素的添加或删除
179
- };
180
- observer.observe(targetElement, config);
181
- };
182
169
  var triggerTo = /*#__PURE__*/function () {
183
170
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(keys) {
184
171
  var events, result, nextErrorCollection;
@@ -230,9 +217,6 @@ var ProStep = function ProStep(_ref) {
230
217
  });
231
218
  }
232
219
  }, [errorCollection, dataSource]);
233
- useEffect(function () {
234
- handleListenerDom();
235
- }, []);
236
220
  return _jsx(ProStepContext.Provider, {
237
221
  value: {
238
222
  collapse: collapse,
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.useStep = exports.default = exports.ProStepContext = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
10
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -68,7 +69,8 @@ var ProStep = function ProStep(_ref) {
68
69
  order: order
69
70
  };
70
71
  }).filter(function (item) {
71
- return anchorIds.includes(item.code);
72
+ var _anchorIds$includes;
73
+ return anchorIds === null || anchorIds === void 0 ? void 0 : (_anchorIds$includes = anchorIds.includes) === null || _anchorIds$includes === void 0 ? void 0 : _anchorIds$includes.call(anchorIds, item.code);
72
74
  }).sort(function (pre, next) {
73
75
  return pre.order - next.order;
74
76
  });
@@ -82,6 +84,9 @@ var ProStep = function ProStep(_ref) {
82
84
  validator = _ref4.validator,
83
85
  order = _ref4.order,
84
86
  disabled = _ref4.disabled;
87
+ if (anchorIds.includes(id)) {
88
+ return null;
89
+ }
85
90
  var record = {};
86
91
  record.title = title;
87
92
  record.order = order;
@@ -143,6 +148,9 @@ var ProStep = function ProStep(_ref) {
143
148
  if (title && !(registerMap === null || registerMap === void 0 ? void 0 : (_registerMap$current = registerMap.current) === null || _registerMap$current === void 0 ? void 0 : _registerMap$current[id])) {
144
149
  registerMap.current[id] = record;
145
150
  }
151
+ setAnchorIds(function (preState) {
152
+ return (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(preState), [id])));
153
+ });
146
154
  emitter.useSubscription(subEvent);
147
155
  };
148
156
  var notify = /*#__PURE__*/function () {
@@ -165,27 +173,6 @@ var ProStep = function ProStep(_ref) {
165
173
  return _ref6.apply(this, arguments);
166
174
  };
167
175
  }();
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
176
  var triggerTo = /*#__PURE__*/function () {
190
177
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(keys) {
191
178
  var events, result, nextErrorCollection;
@@ -237,9 +224,6 @@ var ProStep = function ProStep(_ref) {
237
224
  });
238
225
  }
239
226
  }, [errorCollection, dataSource]);
240
- (0, _react.useEffect)(function () {
241
- handleListenerDom();
242
- }, []);
243
227
  return (0, _jsxRuntime.jsx)(ProStepContext.Provider, {
244
228
  value: {
245
229
  collapse: collapse,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.6.2-beta.3",
3
+ "version": "3.6.2-beta.4",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",