@zat-design/sisyphus-react 3.12.1 → 3.13.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.
@@ -44,11 +44,8 @@ var ProStep = function ProStep(_ref) {
44
44
  _useLocalStorageState2 = (0, _slicedToArray2.default)(_useLocalStorageState, 2),
45
45
  setLocalData = _useLocalStorageState2[1];
46
46
  var ids = Object.keys(registerMap.current);
47
- var targetOffset = resetProps.targetOffset,
48
- _resetProps$collapse = resetProps.collapse,
47
+ var _resetProps$collapse = resetProps.collapse,
49
48
  collapse = _resetProps$collapse === void 0 ? false : _resetProps$collapse,
50
- _resetProps$scrollToE = resetProps.scrollToError,
51
- scrollToError = _resetProps$scrollToE === void 0 ? true : _resetProps$scrollToE,
52
49
  _resetProps$lazyLoad = resetProps.lazyLoad,
53
50
  lazyLoad = _resetProps$lazyLoad === void 0 ? false : _resetProps$lazyLoad;
54
51
  var dataSource = (0, _react.useMemo)(function () {
@@ -154,22 +151,6 @@ var ProStep = function ProStep(_ref) {
154
151
  });
155
152
  }
156
153
  };
157
- var handleScrollError = function handleScrollError(data) {
158
- var errorModuleKeys = Object.keys(data).reverse();
159
- if (errorModuleKeys === null || errorModuleKeys === void 0 ? void 0 : errorModuleKeys.length) {
160
- var _dataSource$find;
161
- var firstErrorModuleKey = (_dataSource$find = dataSource.find(function (item) {
162
- var moduleKey = errorModuleKeys.find(function (child) {
163
- return child === item.code;
164
- });
165
- return data[moduleKey];
166
- })) === null || _dataSource$find === void 0 ? void 0 : _dataSource$find.code;
167
- firstErrorModuleKey && (0, _utils.handleScroll)(firstErrorModuleKey, {
168
- targetOffset: targetOffset,
169
- scrollToError: scrollToError
170
- });
171
- }
172
- };
173
154
  var notify = /*#__PURE__*/function () {
174
155
  var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(params) {
175
156
  var _ref7, excludes, triggerIds, events, res, nextErrorCollection;
@@ -200,7 +181,7 @@ var ProStep = function ProStep(_ref) {
200
181
  setState({
201
182
  errorCollection: nextErrorCollection
202
183
  });
203
- handleScrollError(nextErrorCollection);
184
+ (0, _utils.handleScrollError)();
204
185
  return _context2.abrupt("return", res);
205
186
  case 12:
206
187
  case "end":
@@ -238,7 +219,7 @@ var ProStep = function ProStep(_ref) {
238
219
  setState({
239
220
  errorCollection: nextErrorCollection
240
221
  });
241
- handleScrollError(nextErrorCollection);
222
+ (0, _utils.handleScrollError)();
242
223
  return _context3.abrupt("return", result);
243
224
  case 10:
244
225
  case "end":
@@ -259,7 +240,8 @@ var ProStep = function ProStep(_ref) {
259
240
  triggerTo: triggerTo,
260
241
  handleScroll: _utils.handleScroll,
261
242
  lazyLoad: lazyLoad,
262
- unNotify: unNotify
243
+ unNotify: unNotify,
244
+ source: 'ProStep'
263
245
  },
264
246
  children: (0, _jsxRuntime.jsxs)("div", {
265
247
  className: "pro-step-wrapper",
@@ -104,6 +104,8 @@ export interface ProStepContextType {
104
104
  lazyLoad?: boolean | any;
105
105
  /** 取消注册函数 */
106
106
  unNotify: (keys: string | string[]) => void;
107
+ /** 来源 */
108
+ source?: string;
107
109
  }
108
110
  /**
109
111
  * 注册参数类型
@@ -175,16 +177,6 @@ export interface ListenerProps {
175
177
  /** 允许其他任意属性 */
176
178
  [key: string]: any;
177
179
  }
178
- /**
179
- * 错误结果类型
180
- * @interface ErrorResult
181
- */
182
- export interface ErrorResult {
183
- /** 错误DOM元素 */
184
- errorDom: HTMLElement | null;
185
- /** 索引 */
186
- index: number;
187
- }
188
180
  /**
189
181
  * 锚点SVG属性类型
190
182
  * @interface AnchorSvgProps
@@ -1,7 +1,11 @@
1
1
  import React from 'react';
2
2
  import type { LoadedMapType } from '../propsType';
3
3
  /**
4
- * 处理滚动到指定元素位置
4
+ * 滚动到错误位置, 延迟200ms解决ProForm错误还未生成
5
+ */
6
+ export declare const handleScrollError: (dom?: HTMLElement) => void;
7
+ /**
8
+ * 处理滚动到指定元素位置, 如发现有错误, 则优先滚动到错误位置
5
9
  * @param id 目标元素的ID
6
10
  * @param options 滚动选项
7
11
  */
@@ -4,11 +4,25 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.handleScroll = exports.getLoadedMap = exports.default = void 0;
7
+ exports.handleScrollError = exports.handleScroll = exports.getLoadedMap = exports.default = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
9
  var _lodash = require("lodash");
10
10
  /**
11
- * 处理滚动到指定元素位置
11
+ * 滚动到错误位置, 延迟200ms解决ProForm错误还未生成
12
+ */
13
+ var handleScrollError = exports.handleScrollError = function handleScrollError(dom) {
14
+ setTimeout(function () {
15
+ var errorDom = dom || document.querySelector('[class*="form-item-has-error"]');
16
+ if (errorDom) {
17
+ errorDom.scrollIntoView({
18
+ behavior: 'smooth',
19
+ block: 'center'
20
+ });
21
+ }
22
+ }, 200);
23
+ };
24
+ /**
25
+ * 处理滚动到指定元素位置, 如发现有错误, 则优先滚动到错误位置
12
26
  * @param id 目标元素的ID
13
27
  * @param options 滚动选项
14
28
  */
@@ -20,12 +34,20 @@ var handleScroll = exports.handleScroll = function handleScroll(id, options) {
20
34
  if (!scrollToError) return;
21
35
  var dom = document.querySelector("#".concat(id));
22
36
  if (dom) {
23
- setTimeout((0, _lodash.debounce)(function () {
24
- window.scrollTo({
25
- top: dom.offsetTop - targetOffset,
26
- behavior: 'smooth'
27
- });
28
- }, 100), 0);
37
+ // 查找指定id下的错误表单项
38
+ var errorDom = dom.querySelector('[class*="form-item-has-error"]');
39
+ if (errorDom && scrollToError) {
40
+ // 如果发现错误表单项,执行handleScrollError函数
41
+ handleScrollError(errorDom);
42
+ } else {
43
+ // 如果没有错误表单项,则滚动到指定元素位置
44
+ setTimeout((0, _lodash.debounce)(function () {
45
+ window.scrollTo({
46
+ top: dom.offsetTop - targetOffset,
47
+ behavior: 'smooth'
48
+ });
49
+ }, 100), 0);
50
+ }
29
51
  }
30
52
  };
31
53
  /**
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { ProStepTabType, ProStepTabResultType } from './propsType';
3
+ /**
4
+ * 步骤化Tab管理钩子,用于管理多步骤表单或流程的切换和验证
5
+ *
6
+ * @param {ProStepTabType} props 配置参数
7
+ * @returns {ProStepTabResultType} 返回步骤Tab相关方法和状态
8
+ */
9
+ export declare function useStepTab(props?: ProStepTabType): ProStepTabResultType;
10
+ /**
11
+ * 在子组件中获取父级 StepTab 实例的钩子
12
+ * @returns {ProStepTabResultType} 步骤Tab实例
13
+ */
14
+ export declare function useStepTabInstance(): ProStepTabResultType;
15
+ interface ProStepTabComponent extends React.FC<React.PropsWithChildren<ProStepTabType>> {
16
+ useStepTabInstance: typeof useStepTabInstance;
17
+ }
18
+ /**
19
+ * ProStepTab 组件
20
+ */
21
+ declare const ProStepTab: ProStepTabComponent;
22
+ export default ProStepTab;
@@ -0,0 +1,347 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ exports.useStepTab = useStepTab;
10
+ exports.useStepTabInstance = useStepTabInstance;
11
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
14
+ var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
15
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
+ var _react = _interopRequireWildcard(require("react"));
18
+ var _lodash = require("lodash");
19
+ var _excluded = ["children"];
20
+ // 存储当前的 StepTab 实例
21
+ var StepTabInstanceContext = /*#__PURE__*/(0, _react.createContext)(null);
22
+ /**
23
+ * 使用原生 JS 获取 URL 搜索参数
24
+ * @returns 当前 URL 的搜索参数和路径
25
+ */
26
+ var useNativeLocation = function useNativeLocation() {
27
+ var _useState = (0, _react.useState)({
28
+ search: window.location.search,
29
+ pathname: window.location.pathname
30
+ }),
31
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
32
+ location = _useState2[0],
33
+ setLocation = _useState2[1];
34
+ // 监听 popstate 事件,更新 location 状态
35
+ (0, _react.useEffect)(function () {
36
+ var handleLocationChange = function handleLocationChange() {
37
+ setLocation({
38
+ search: window.location.search,
39
+ pathname: window.location.pathname
40
+ });
41
+ };
42
+ window.addEventListener('popstate', handleLocationChange);
43
+ return function () {
44
+ window.removeEventListener('popstate', handleLocationChange);
45
+ };
46
+ }, []);
47
+ return location;
48
+ };
49
+ /**
50
+ * 步骤化Tab管理钩子,用于管理多步骤表单或流程的切换和验证
51
+ *
52
+ * @param {ProStepTabType} props 配置参数
53
+ * @returns {ProStepTabResultType} 返回步骤Tab相关方法和状态
54
+ */
55
+ function useStepTab() {
56
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
57
+ var _props$routerKeep = props.routerKeep,
58
+ routerKeep = _props$routerKeep === void 0 ? false : _props$routerKeep,
59
+ _props$routerSearchKe = props.routerSearchKey,
60
+ routerSearchKey = _props$routerSearchKe === void 0 ? 'tab' : _props$routerSearchKe,
61
+ _props$validate = props.validate,
62
+ validate = _props$validate === void 0 ? true : _props$validate,
63
+ onBeforeChange = props.onBeforeChange,
64
+ onAfterChange = props.onAfterChange,
65
+ defaultActiveKey = props.defaultActiveKey,
66
+ _props$defaultStep = props.defaultStep,
67
+ defaultStep = _props$defaultStep === void 0 ? 1 : _props$defaultStep,
68
+ queueSteps = props.queueSteps,
69
+ _props$autoNext = props.autoNext,
70
+ autoNext = _props$autoNext === void 0 ? false : _props$autoNext;
71
+ // 内部状态,避免全局污染
72
+ var _useState3 = (0, _react.useState)({}),
73
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
74
+ handlesState = _useState4[0],
75
+ setHandlesState = _useState4[1];
76
+ var location = useNativeLocation();
77
+ // 获取初始激活的tab key
78
+ var getInitialActiveKey = (0, _react.useCallback)(function () {
79
+ if (routerKeep) {
80
+ var urlSearchParams = new URLSearchParams(location.search);
81
+ var tabValue = urlSearchParams.get(routerSearchKey);
82
+ if (tabValue) {
83
+ return tabValue;
84
+ }
85
+ }
86
+ return defaultActiveKey || '1';
87
+ }, [routerKeep, routerSearchKey, location.search, defaultActiveKey]);
88
+ // 获取初始激活的步骤
89
+ var getInitialStep = (0, _react.useCallback)(function () {
90
+ if (routerKeep) {
91
+ var urlSearchParams = new URLSearchParams(location.search);
92
+ var stepValue = urlSearchParams.get(routerSearchKey);
93
+ // 如果stepValue是数字,则返回数字
94
+ if (stepValue && !(0, _lodash.isNaN)(Number(stepValue))) {
95
+ return Number(stepValue);
96
+ }
97
+ }
98
+ return defaultStep;
99
+ }, [routerKeep, routerSearchKey, location.search, defaultStep]);
100
+ var _useState5 = (0, _react.useState)(getInitialActiveKey()),
101
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
102
+ activeKey = _useState6[0],
103
+ setActiveKeyState = _useState6[1];
104
+ var _useState7 = (0, _react.useState)(getInitialStep()),
105
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
106
+ step = _useState8[0],
107
+ setStepState = _useState8[1]; // 当前已激活步骤
108
+ var _useState9 = (0, _react.useState)(false),
109
+ _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
110
+ loading = _useState10[0],
111
+ setLoading = _useState10[1];
112
+ // 同步URL参数
113
+ (0, _react.useEffect)(function () {
114
+ if (routerKeep && activeKey) {
115
+ // 更新URL参数
116
+ var urlSearchParams = new URLSearchParams(location.search);
117
+ urlSearchParams.set(routerSearchKey, activeKey);
118
+ // 使用原生 history API 更新 URL
119
+ var newUrl = "".concat(location.pathname, "?").concat(urlSearchParams.toString());
120
+ window.history.replaceState(null, '', newUrl);
121
+ }
122
+ }, [activeKey, routerKeep, routerSearchKey, location]);
123
+ // 创建一个包装函数,自动处理loading状态
124
+ var wrapHandleWithLoading = (0, _react.useCallback)(function (fn) {
125
+ return /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
126
+ var result;
127
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
128
+ while (1) switch (_context.prev = _context.next) {
129
+ case 0:
130
+ setLoading(true);
131
+ _context.prev = 1;
132
+ _context.next = 4;
133
+ return fn();
134
+ case 4:
135
+ result = _context.sent;
136
+ setLoading(false);
137
+ return _context.abrupt("return", result);
138
+ case 9:
139
+ _context.prev = 9;
140
+ _context.t0 = _context["catch"](1);
141
+ setLoading(false);
142
+ return _context.abrupt("return", false);
143
+ case 13:
144
+ case "end":
145
+ return _context.stop();
146
+ }
147
+ }, _callee, null, [[1, 9]]);
148
+ }));
149
+ }, []);
150
+ // 注册步骤处理函数
151
+ var registerHandle = (0, _react.useCallback)(function (key, handler) {
152
+ // 使用wrapHandleWithLoading包装处理函数
153
+ setHandlesState(function (prev) {
154
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, (0, _defineProperty2.default)({}, key, wrapHandleWithLoading(handler)));
155
+ });
156
+ }, [wrapHandleWithLoading]);
157
+ // 获取步骤处理函数
158
+ var getHandle = (0, _react.useCallback)(function (key) {
159
+ return handlesState[key];
160
+ }, [handlesState]);
161
+ // 处理表单验证和切换(内部使用)
162
+ var validateAndChange = (0, _react.useCallback)(/*#__PURE__*/function () {
163
+ var _ref2 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(targetKey) {
164
+ var currentHandler, handleResult, beforeResult;
165
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
166
+ while (1) switch (_context2.prev = _context2.next) {
167
+ case 0:
168
+ if (!(targetKey === activeKey)) {
169
+ _context2.next = 2;
170
+ break;
171
+ }
172
+ return _context2.abrupt("return", true);
173
+ case 2:
174
+ _context2.prev = 2;
175
+ // 执行当前步骤的保存处理, 如果validate为true,则执行验证
176
+ currentHandler = handlesState[activeKey];
177
+ if (!(currentHandler && validate)) {
178
+ _context2.next = 10;
179
+ break;
180
+ }
181
+ _context2.next = 7;
182
+ return currentHandler();
183
+ case 7:
184
+ handleResult = _context2.sent;
185
+ if (handleResult) {
186
+ _context2.next = 10;
187
+ break;
188
+ }
189
+ return _context2.abrupt("return", false);
190
+ case 10:
191
+ if (!onBeforeChange) {
192
+ _context2.next = 16;
193
+ break;
194
+ }
195
+ _context2.next = 13;
196
+ return onBeforeChange(activeKey, targetKey);
197
+ case 13:
198
+ beforeResult = _context2.sent;
199
+ if (!(beforeResult === false)) {
200
+ _context2.next = 16;
201
+ break;
202
+ }
203
+ return _context2.abrupt("return", false);
204
+ case 16:
205
+ // 更新激活的key
206
+ setActiveKeyState(targetKey);
207
+ // 执行切换后回调
208
+ if (onAfterChange) {
209
+ onAfterChange(targetKey);
210
+ }
211
+ return _context2.abrupt("return", true);
212
+ case 21:
213
+ _context2.prev = 21;
214
+ _context2.t0 = _context2["catch"](2);
215
+ // 验证失败
216
+ console.error('Tab切换验证失败:', _context2.t0);
217
+ return _context2.abrupt("return", false);
218
+ case 25:
219
+ case "end":
220
+ return _context2.stop();
221
+ }
222
+ }, _callee2, null, [[2, 21]]);
223
+ }));
224
+ return function (_x) {
225
+ return _ref2.apply(this, arguments);
226
+ };
227
+ }(), [activeKey, validate, onBeforeChange, onAfterChange, handlesState]);
228
+ // 设置激活的key
229
+ var setCheckActiveKey = (0, _react.useCallback)(/*#__PURE__*/function () {
230
+ var _ref3 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(targetKey, validate) {
231
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
232
+ while (1) switch (_context3.prev = _context3.next) {
233
+ case 0:
234
+ if (!(validate === false)) {
235
+ _context3.next = 3;
236
+ break;
237
+ }
238
+ setActiveKeyState(targetKey);
239
+ return _context3.abrupt("return", true);
240
+ case 3:
241
+ return _context3.abrupt("return", validateAndChange(targetKey));
242
+ case 4:
243
+ case "end":
244
+ return _context3.stop();
245
+ }
246
+ }, _callee3);
247
+ }));
248
+ return function (_x2, _x3) {
249
+ return _ref3.apply(this, arguments);
250
+ };
251
+ }(), [validateAndChange]);
252
+ // 执行当前步骤处理函数
253
+ var saveHandle = (0, _react.useCallback)(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee4() {
254
+ var handler, result, currentKeyNum, nextKey;
255
+ return (0, _regeneratorRuntime2.default)().wrap(function _callee4$(_context4) {
256
+ while (1) switch (_context4.prev = _context4.next) {
257
+ case 0:
258
+ handler = handlesState[activeKey];
259
+ if (!handler) {
260
+ _context4.next = 14;
261
+ break;
262
+ }
263
+ _context4.next = 4;
264
+ return handler();
265
+ case 4:
266
+ result = _context4.sent;
267
+ if (!(result && autoNext)) {
268
+ _context4.next = 11;
269
+ break;
270
+ }
271
+ // 只有当activeKey能转换为数字时才执行自动跳转
272
+ currentKeyNum = Number(activeKey);
273
+ if ((0, _lodash.isNaN)(currentKeyNum)) {
274
+ _context4.next = 11;
275
+ break;
276
+ }
277
+ nextKey = String(currentKeyNum + 1); // 自动跳转到下一个tab
278
+ _context4.next = 11;
279
+ return setCheckActiveKey(nextKey, false);
280
+ case 11:
281
+ if (!(result === false)) {
282
+ _context4.next = 13;
283
+ break;
284
+ }
285
+ return _context4.abrupt("return", Promise.reject());
286
+ case 13:
287
+ return _context4.abrupt("return", result);
288
+ case 14:
289
+ return _context4.abrupt("return", Promise.resolve(true));
290
+ case 15:
291
+ case "end":
292
+ return _context4.stop();
293
+ }
294
+ }, _callee4);
295
+ })), [activeKey, handlesState, autoNext, queueSteps, setCheckActiveKey]);
296
+ // 拦截setStep, 最大值是queueSteps
297
+ var setStep = (0, _react.useCallback)(function (step) {
298
+ if (step > queueSteps) {
299
+ return;
300
+ }
301
+ setStepState(step);
302
+ }, [queueSteps]);
303
+ // 重置handles,用于清空或组件卸载时调用
304
+ var resetHandles = (0, _react.useCallback)(function () {
305
+ setHandlesState({});
306
+ }, []);
307
+ var stepTabInstance = {
308
+ activeKey: activeKey,
309
+ setCheckActiveKey: setCheckActiveKey,
310
+ loading: loading,
311
+ registerHandle: registerHandle,
312
+ getHandle: getHandle,
313
+ saveHandle: saveHandle,
314
+ resetHandles: resetHandles,
315
+ handles: handlesState,
316
+ step: step,
317
+ setStep: setStep,
318
+ queueSteps: queueSteps
319
+ };
320
+ return stepTabInstance;
321
+ }
322
+ /**
323
+ * 在子组件中获取父级 StepTab 实例的钩子
324
+ * @returns {ProStepTabResultType} 步骤Tab实例
325
+ */
326
+ function useStepTabInstance() {
327
+ var context = (0, _react.useContext)(StepTabInstanceContext);
328
+ if (context === null) {
329
+ throw new Error('useStepTabInstance must be used inside a ProStepTab component');
330
+ }
331
+ return context;
332
+ }
333
+ /**
334
+ * ProStepTab 组件
335
+ */
336
+ var ProStepTab = function ProStepTab(_ref5) {
337
+ var children = _ref5.children,
338
+ rest = (0, _objectWithoutProperties2.default)(_ref5, _excluded);
339
+ var stepTabInstance = useStepTab(rest);
340
+ return /*#__PURE__*/_react.default.createElement(StepTabInstanceContext.Provider, {
341
+ value: stepTabInstance
342
+ }, children);
343
+ };
344
+ // 将 useStepTabInstance 挂载到 ProStepTab 上作为静态方法
345
+ ProStepTab.useStepTabInstance = useStepTabInstance;
346
+ // 导出默认组件
347
+ var _default = exports.default = ProStepTab;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * HandleFunction 类型定义 - 步骤处理函数
3
+ */
4
+ export type HandleFunctionType = () => Promise<boolean>;
5
+ /**
6
+ * ProStepTab钩子参数接口
7
+ */
8
+ export interface ProStepTabType {
9
+ /**
10
+ * 是否将当前tab状态保存在URL中
11
+ * @default false
12
+ */
13
+ routerKeep?: boolean;
14
+ /**
15
+ * URL参数名称
16
+ * @default 'tab'
17
+ */
18
+ routerSearchKey?: string;
19
+ /**
20
+ * 切换tab前是否需要验证
21
+ * @default false
22
+ */
23
+ validate?: boolean;
24
+ /**
25
+ * 切换tab前的回调
26
+ * @param current 当前tabKey
27
+ * @param target 目标tabKey
28
+ * @returns 是否允许切换
29
+ */
30
+ onBeforeChange?: (current: string, target: string) => Promise<boolean>;
31
+ /**
32
+ * 切换tab后的回调
33
+ * @param key 切换后的tabKey
34
+ */
35
+ onAfterChange?: (key: string) => void;
36
+ /**
37
+ * 默认选中的tab key
38
+ * @default '1'
39
+ */
40
+ defaultActiveKey?: string;
41
+ /**
42
+ * 需要按顺序完成的步骤数量
43
+ * 与defaultStep必须同时存在或同时不存在
44
+ * @default -
45
+ */
46
+ queueSteps?: number;
47
+ /**
48
+ * 当前初始激活步骤
49
+ * 与queueSteps必须同时存在或同时不存在
50
+ * @default 1
51
+ */
52
+ defaultStep?: number;
53
+ /**
54
+ * 是否自动跳转下一步
55
+ * @default false
56
+ */
57
+ autoNext?: boolean;
58
+ }
59
+ /**
60
+ * ProStepTab钩子返回值接口
61
+ */
62
+ export interface ProStepTabResultType {
63
+ /**
64
+ * 当前激活的tabKey
65
+ */
66
+ activeKey: string;
67
+ /**
68
+ * 设置激活的tabKey
69
+ * @param key 目标tabKey
70
+ * @param validate 是否需要验证
71
+ */
72
+ setCheckActiveKey: (key: string, validate?: boolean) => Promise<boolean>;
73
+ /**
74
+ * 加载状态
75
+ */
76
+ loading: boolean;
77
+ /**
78
+ * 注册步骤处理函数
79
+ * @param key 步骤Key
80
+ * @param handler 处理函数
81
+ */
82
+ registerHandle: (key: string, handler: HandleFunctionType) => void;
83
+ /**
84
+ * 获取步骤处理函数
85
+ * @param key 步骤Key
86
+ */
87
+ getHandle: (key: string) => HandleFunctionType | undefined;
88
+ /**
89
+ * 执行当前步骤处理函数
90
+ * @returns 处理结果
91
+ */
92
+ saveHandle: () => Promise<boolean>;
93
+ /**
94
+ * 所有步骤处理函数映射
95
+ */
96
+ handles: Record<string, HandleFunctionType>;
97
+ /**
98
+ * 重置所有步骤处理函数
99
+ */
100
+ resetHandles: () => void;
101
+ /**
102
+ * 最大步骤数
103
+ */
104
+ queueSteps?: number;
105
+ /**
106
+ * 当前已激活步骤,最大值为queueSteps
107
+ */
108
+ step?: number;
109
+ /**
110
+ * 设置当前顺序步骤
111
+ * @param step 顺序步骤
112
+ */
113
+ setStep?: (step: number) => void;
114
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/lib/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { default as ProViewer } from './ProViewer';
8
8
  export { default as ProEditTable } from './ProEditTable';
9
9
  export { default as ProDrawerForm } from './ProDrawerForm';
10
10
  export { default as ProEditLabel } from './ProEditLabel';
11
+ export { default as ProStepTab } from './ProStepTab';
11
12
  export { default as ProForm } from './ProForm';
12
13
  export { ProFormProvider } from './ProForm';
13
14
  export * from './ProForm/components';
@@ -40,4 +41,5 @@ export type { ProEditTableType, ProEditTableColumnType, ProEditTableSummaryColum
40
41
  export type { ProStepType, ProStepContextType, ProStepItemType, ProStepPropsType, ProStepItemPropsType } from './ProStep/propsType';
41
42
  export type { ProDrawerFormType, ProDrawerFormPropsType } from './ProDrawerForm/propsType';
42
43
  export type { ProModalSelectType, ProModalSelectConfigType, ProModalSelectPropsType } from './ProForm/components/combination/ProModalSelect/propsType';
44
+ export type { ProStepTabType, ProStepTabResultType } from './ProStepTab/propsType';
43
45
  export * from './tokens';
package/lib/index.js CHANGED
@@ -15,6 +15,7 @@ var _exportNames = {
15
15
  ProEditTable: true,
16
16
  ProDrawerForm: true,
17
17
  ProEditLabel: true,
18
+ ProStepTab: true,
18
19
  ProForm: true,
19
20
  ProFormProvider: true,
20
21
  ProSelect: true,
@@ -133,6 +134,12 @@ Object.defineProperty(exports, "ProStep", {
133
134
  return _ProStep.default;
134
135
  }
135
136
  });
137
+ Object.defineProperty(exports, "ProStepTab", {
138
+ enumerable: true,
139
+ get: function get() {
140
+ return _ProStepTab.default;
141
+ }
142
+ });
136
143
  Object.defineProperty(exports, "ProTable", {
137
144
  enumerable: true,
138
145
  get: function get() {
@@ -184,6 +191,7 @@ var _ProViewer = _interopRequireDefault(require("./ProViewer"));
184
191
  var _ProEditTable = _interopRequireDefault(require("./ProEditTable"));
185
192
  var _ProDrawerForm = _interopRequireDefault(require("./ProDrawerForm"));
186
193
  var _ProEditLabel = _interopRequireDefault(require("./ProEditLabel"));
194
+ var _ProStepTab = _interopRequireDefault(require("./ProStepTab"));
187
195
  var _ProForm = _interopRequireWildcard(require("./ProForm"));
188
196
  var _components = require("./ProForm/components");
189
197
  Object.keys(_components).forEach(function (key) {