@zat-design/sisyphus-react 3.12.1 → 3.13.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.
- package/README.md +0 -2
- package/dist/index.esm.css +4 -0
- package/dist/less.esm.css +4 -0
- package/es/ProForm/components/combination/FormList/style/index.less +4 -0
- package/es/ProForm/index.js +8 -3
- package/es/ProForm/utils/useForm.js +2 -2
- package/es/ProSelect/utils/index.js +15 -3
- package/es/ProStep/components/Listener/index.js +1 -35
- package/es/ProStep/index.js +6 -24
- package/es/ProStep/propsType.d.ts +2 -10
- package/es/ProStep/utils/index.d.ts +5 -1
- package/es/ProStep/utils/index.js +29 -7
- package/es/ProStepTab/index.d.ts +22 -0
- package/es/ProStepTab/index.js +341 -0
- package/es/ProStepTab/propsType.d.ts +114 -0
- package/es/ProStepTab/propsType.js +1 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/lib/ProForm/components/combination/FormList/style/index.less +4 -0
- package/lib/ProForm/index.js +8 -3
- package/lib/ProSelect/utils/index.js +16 -3
- package/lib/ProStep/components/Listener/index.js +1 -35
- package/lib/ProStep/index.js +5 -23
- package/lib/ProStep/propsType.d.ts +2 -10
- package/lib/ProStep/utils/index.d.ts +5 -1
- package/lib/ProStep/utils/index.js +30 -8
- package/lib/ProStepTab/index.d.ts +22 -0
- package/lib/ProStepTab/index.js +351 -0
- package/lib/ProStepTab/propsType.d.ts +114 -0
- package/lib/ProStepTab/propsType.js +5 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/package.json +1 -1
@@ -0,0 +1,341 @@
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
5
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
7
|
+
var _excluded = ["children"];
|
8
|
+
import React, { useState, useCallback, useEffect, createContext, useContext } from 'react';
|
9
|
+
import { isNaN } from 'lodash';
|
10
|
+
// 存储当前的 StepTab 实例
|
11
|
+
var StepTabInstanceContext = /*#__PURE__*/createContext(null);
|
12
|
+
/**
|
13
|
+
* 使用原生 JS 获取 URL 搜索参数
|
14
|
+
* @returns 当前 URL 的搜索参数和路径
|
15
|
+
*/
|
16
|
+
var useNativeLocation = function useNativeLocation() {
|
17
|
+
var _useState = useState({
|
18
|
+
search: window.location.search,
|
19
|
+
pathname: window.location.pathname
|
20
|
+
}),
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
22
|
+
location = _useState2[0],
|
23
|
+
setLocation = _useState2[1];
|
24
|
+
// 监听 popstate 事件,更新 location 状态
|
25
|
+
useEffect(function () {
|
26
|
+
var handleLocationChange = function handleLocationChange() {
|
27
|
+
setLocation({
|
28
|
+
search: window.location.search,
|
29
|
+
pathname: window.location.pathname
|
30
|
+
});
|
31
|
+
};
|
32
|
+
window.addEventListener('popstate', handleLocationChange);
|
33
|
+
return function () {
|
34
|
+
window.removeEventListener('popstate', handleLocationChange);
|
35
|
+
};
|
36
|
+
}, []);
|
37
|
+
return location;
|
38
|
+
};
|
39
|
+
/**
|
40
|
+
* 步骤化Tab管理钩子,用于管理多步骤表单或流程的切换和验证
|
41
|
+
*
|
42
|
+
* @param {ProStepTabType} props 配置参数
|
43
|
+
* @returns {ProStepTabResultType} 返回步骤Tab相关方法和状态
|
44
|
+
*/
|
45
|
+
export function useStepTab() {
|
46
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
47
|
+
var _props$routerKeep = props.routerKeep,
|
48
|
+
routerKeep = _props$routerKeep === void 0 ? false : _props$routerKeep,
|
49
|
+
_props$routerSearchKe = props.routerSearchKey,
|
50
|
+
routerSearchKey = _props$routerSearchKe === void 0 ? 'tab' : _props$routerSearchKe,
|
51
|
+
_props$validate = props.validate,
|
52
|
+
validate = _props$validate === void 0 ? true : _props$validate,
|
53
|
+
onBeforeChange = props.onBeforeChange,
|
54
|
+
onAfterChange = props.onAfterChange,
|
55
|
+
defaultActiveKey = props.defaultActiveKey,
|
56
|
+
_props$defaultStep = props.defaultStep,
|
57
|
+
defaultStep = _props$defaultStep === void 0 ? 1 : _props$defaultStep,
|
58
|
+
queueSteps = props.queueSteps,
|
59
|
+
_props$autoNext = props.autoNext,
|
60
|
+
autoNext = _props$autoNext === void 0 ? false : _props$autoNext;
|
61
|
+
// 内部状态,避免全局污染
|
62
|
+
var _useState3 = useState({}),
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
64
|
+
handlesState = _useState4[0],
|
65
|
+
setHandlesState = _useState4[1];
|
66
|
+
var location = useNativeLocation();
|
67
|
+
// 获取初始激活的tab key
|
68
|
+
var getInitialActiveKey = useCallback(function () {
|
69
|
+
if (routerKeep) {
|
70
|
+
var urlSearchParams = new URLSearchParams(location.search);
|
71
|
+
var tabValue = urlSearchParams.get(routerSearchKey);
|
72
|
+
if (tabValue) {
|
73
|
+
return tabValue;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return defaultActiveKey || '1';
|
77
|
+
}, [routerKeep, routerSearchKey, location.search, defaultActiveKey]);
|
78
|
+
// 获取初始激活的步骤
|
79
|
+
var getInitialStep = useCallback(function () {
|
80
|
+
if (routerKeep) {
|
81
|
+
var urlSearchParams = new URLSearchParams(location.search);
|
82
|
+
var stepValue = urlSearchParams.get(routerSearchKey);
|
83
|
+
// 如果stepValue是数字,则返回数字
|
84
|
+
if (stepValue && !isNaN(Number(stepValue))) {
|
85
|
+
return Number(stepValue);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
return defaultStep;
|
89
|
+
}, [routerKeep, routerSearchKey, location.search, defaultStep]);
|
90
|
+
var _useState5 = useState(getInitialActiveKey()),
|
91
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
92
|
+
activeKey = _useState6[0],
|
93
|
+
setActiveKeyState = _useState6[1];
|
94
|
+
var _useState7 = useState(getInitialStep()),
|
95
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
96
|
+
step = _useState8[0],
|
97
|
+
setStepState = _useState8[1]; // 当前已激活步骤
|
98
|
+
var _useState9 = useState(false),
|
99
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
100
|
+
loading = _useState10[0],
|
101
|
+
setLoading = _useState10[1];
|
102
|
+
// 同步URL参数
|
103
|
+
useEffect(function () {
|
104
|
+
if (routerKeep && activeKey) {
|
105
|
+
// 更新URL参数
|
106
|
+
var urlSearchParams = new URLSearchParams(location.search);
|
107
|
+
urlSearchParams.set(routerSearchKey, activeKey);
|
108
|
+
// 使用原生 history API 更新 URL
|
109
|
+
var newUrl = "".concat(location.pathname, "?").concat(urlSearchParams.toString());
|
110
|
+
window.history.replaceState(null, '', newUrl);
|
111
|
+
}
|
112
|
+
}, [activeKey, routerKeep, routerSearchKey, location]);
|
113
|
+
// 创建一个包装函数,自动处理loading状态
|
114
|
+
var wrapHandleWithLoading = useCallback(function (fn) {
|
115
|
+
return /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
116
|
+
var result;
|
117
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
118
|
+
while (1) switch (_context.prev = _context.next) {
|
119
|
+
case 0:
|
120
|
+
setLoading(true);
|
121
|
+
_context.prev = 1;
|
122
|
+
_context.next = 4;
|
123
|
+
return fn();
|
124
|
+
case 4:
|
125
|
+
result = _context.sent;
|
126
|
+
setLoading(false);
|
127
|
+
return _context.abrupt("return", result);
|
128
|
+
case 9:
|
129
|
+
_context.prev = 9;
|
130
|
+
_context.t0 = _context["catch"](1);
|
131
|
+
setLoading(false);
|
132
|
+
return _context.abrupt("return", false);
|
133
|
+
case 13:
|
134
|
+
_context.prev = 13;
|
135
|
+
setLoading(false);
|
136
|
+
return _context.finish(13);
|
137
|
+
case 16:
|
138
|
+
case "end":
|
139
|
+
return _context.stop();
|
140
|
+
}
|
141
|
+
}, _callee, null, [[1, 9, 13, 16]]);
|
142
|
+
}));
|
143
|
+
}, []);
|
144
|
+
// 注册步骤处理函数
|
145
|
+
var registerHandle = useCallback(function (key, handler) {
|
146
|
+
// 使用wrapHandleWithLoading包装处理函数
|
147
|
+
setHandlesState(function (prev) {
|
148
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, wrapHandleWithLoading(handler)));
|
149
|
+
});
|
150
|
+
}, [wrapHandleWithLoading]);
|
151
|
+
// 获取步骤处理函数
|
152
|
+
var getHandle = useCallback(function (key) {
|
153
|
+
return handlesState[key];
|
154
|
+
}, [handlesState]);
|
155
|
+
// 处理表单验证和切换(内部使用)
|
156
|
+
var validateAndChange = useCallback(/*#__PURE__*/function () {
|
157
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(targetKey) {
|
158
|
+
var currentHandler, handleResult, beforeResult;
|
159
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
160
|
+
while (1) switch (_context2.prev = _context2.next) {
|
161
|
+
case 0:
|
162
|
+
if (!(targetKey === activeKey)) {
|
163
|
+
_context2.next = 2;
|
164
|
+
break;
|
165
|
+
}
|
166
|
+
return _context2.abrupt("return", true);
|
167
|
+
case 2:
|
168
|
+
_context2.prev = 2;
|
169
|
+
// 执行当前步骤的保存处理, 如果validate为true,则执行验证
|
170
|
+
currentHandler = handlesState[activeKey];
|
171
|
+
if (!(currentHandler && validate)) {
|
172
|
+
_context2.next = 10;
|
173
|
+
break;
|
174
|
+
}
|
175
|
+
_context2.next = 7;
|
176
|
+
return currentHandler();
|
177
|
+
case 7:
|
178
|
+
handleResult = _context2.sent;
|
179
|
+
if (handleResult) {
|
180
|
+
_context2.next = 10;
|
181
|
+
break;
|
182
|
+
}
|
183
|
+
return _context2.abrupt("return", false);
|
184
|
+
case 10:
|
185
|
+
if (!onBeforeChange) {
|
186
|
+
_context2.next = 16;
|
187
|
+
break;
|
188
|
+
}
|
189
|
+
_context2.next = 13;
|
190
|
+
return onBeforeChange(activeKey, targetKey);
|
191
|
+
case 13:
|
192
|
+
beforeResult = _context2.sent;
|
193
|
+
if (!(beforeResult === false)) {
|
194
|
+
_context2.next = 16;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
return _context2.abrupt("return", false);
|
198
|
+
case 16:
|
199
|
+
// 更新激活的key
|
200
|
+
setActiveKeyState(targetKey);
|
201
|
+
// 执行切换后回调
|
202
|
+
if (onAfterChange) {
|
203
|
+
onAfterChange(targetKey);
|
204
|
+
}
|
205
|
+
return _context2.abrupt("return", true);
|
206
|
+
case 21:
|
207
|
+
_context2.prev = 21;
|
208
|
+
_context2.t0 = _context2["catch"](2);
|
209
|
+
// 验证失败
|
210
|
+
console.error('Tab切换验证失败:', _context2.t0);
|
211
|
+
return _context2.abrupt("return", false);
|
212
|
+
case 25:
|
213
|
+
case "end":
|
214
|
+
return _context2.stop();
|
215
|
+
}
|
216
|
+
}, _callee2, null, [[2, 21]]);
|
217
|
+
}));
|
218
|
+
return function (_x) {
|
219
|
+
return _ref2.apply(this, arguments);
|
220
|
+
};
|
221
|
+
}(), [activeKey, validate, onBeforeChange, onAfterChange, handlesState]);
|
222
|
+
// 设置激活的key
|
223
|
+
var setCheckActiveKey = useCallback(/*#__PURE__*/function () {
|
224
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(targetKey, validate) {
|
225
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
226
|
+
while (1) switch (_context3.prev = _context3.next) {
|
227
|
+
case 0:
|
228
|
+
if (!(validate === false)) {
|
229
|
+
_context3.next = 3;
|
230
|
+
break;
|
231
|
+
}
|
232
|
+
setActiveKeyState(targetKey);
|
233
|
+
return _context3.abrupt("return", true);
|
234
|
+
case 3:
|
235
|
+
return _context3.abrupt("return", validateAndChange(targetKey));
|
236
|
+
case 4:
|
237
|
+
case "end":
|
238
|
+
return _context3.stop();
|
239
|
+
}
|
240
|
+
}, _callee3);
|
241
|
+
}));
|
242
|
+
return function (_x2, _x3) {
|
243
|
+
return _ref3.apply(this, arguments);
|
244
|
+
};
|
245
|
+
}(), [validateAndChange]);
|
246
|
+
// 执行当前步骤处理函数
|
247
|
+
var saveHandle = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
248
|
+
var handler, result, currentKeyNum, nextKey;
|
249
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
250
|
+
while (1) switch (_context4.prev = _context4.next) {
|
251
|
+
case 0:
|
252
|
+
handler = handlesState[activeKey];
|
253
|
+
if (!handler) {
|
254
|
+
_context4.next = 14;
|
255
|
+
break;
|
256
|
+
}
|
257
|
+
_context4.next = 4;
|
258
|
+
return handler();
|
259
|
+
case 4:
|
260
|
+
result = _context4.sent;
|
261
|
+
if (!(result && autoNext)) {
|
262
|
+
_context4.next = 11;
|
263
|
+
break;
|
264
|
+
}
|
265
|
+
// 只有当activeKey能转换为数字时才执行自动跳转
|
266
|
+
currentKeyNum = Number(activeKey);
|
267
|
+
if (isNaN(currentKeyNum)) {
|
268
|
+
_context4.next = 11;
|
269
|
+
break;
|
270
|
+
}
|
271
|
+
nextKey = String(currentKeyNum + 1); // 自动跳转到下一个tab
|
272
|
+
_context4.next = 11;
|
273
|
+
return setCheckActiveKey(nextKey);
|
274
|
+
case 11:
|
275
|
+
if (!(result === false)) {
|
276
|
+
_context4.next = 13;
|
277
|
+
break;
|
278
|
+
}
|
279
|
+
return _context4.abrupt("return", Promise.reject());
|
280
|
+
case 13:
|
281
|
+
return _context4.abrupt("return", result);
|
282
|
+
case 14:
|
283
|
+
return _context4.abrupt("return", Promise.resolve(true));
|
284
|
+
case 15:
|
285
|
+
case "end":
|
286
|
+
return _context4.stop();
|
287
|
+
}
|
288
|
+
}, _callee4);
|
289
|
+
})), [activeKey, handlesState, autoNext, queueSteps, setCheckActiveKey]);
|
290
|
+
// 拦截setStep, 最大值是queueSteps
|
291
|
+
var setStep = useCallback(function (step) {
|
292
|
+
if (step > queueSteps) {
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
setStepState(step);
|
296
|
+
}, [queueSteps]);
|
297
|
+
// 重置handles,用于清空或组件卸载时调用
|
298
|
+
var resetHandles = useCallback(function () {
|
299
|
+
setHandlesState({});
|
300
|
+
}, []);
|
301
|
+
var stepTabInstance = {
|
302
|
+
activeKey: activeKey,
|
303
|
+
setCheckActiveKey: setCheckActiveKey,
|
304
|
+
loading: loading,
|
305
|
+
registerHandle: registerHandle,
|
306
|
+
getHandle: getHandle,
|
307
|
+
saveHandle: saveHandle,
|
308
|
+
resetHandles: resetHandles,
|
309
|
+
handles: handlesState,
|
310
|
+
step: step,
|
311
|
+
setStep: setStep,
|
312
|
+
queueSteps: queueSteps
|
313
|
+
};
|
314
|
+
return stepTabInstance;
|
315
|
+
}
|
316
|
+
/**
|
317
|
+
* 在子组件中获取父级 StepTab 实例的钩子
|
318
|
+
* @returns {ProStepTabResultType} 步骤Tab实例
|
319
|
+
*/
|
320
|
+
export function useStepTabInstance() {
|
321
|
+
var context = useContext(StepTabInstanceContext);
|
322
|
+
if (context === null) {
|
323
|
+
throw new Error('useStepTabInstance must be used inside a ProStepTab component');
|
324
|
+
}
|
325
|
+
return context;
|
326
|
+
}
|
327
|
+
/**
|
328
|
+
* ProStepTab 组件
|
329
|
+
*/
|
330
|
+
var ProStepTab = function ProStepTab(_ref5) {
|
331
|
+
var children = _ref5.children,
|
332
|
+
rest = _objectWithoutProperties(_ref5, _excluded);
|
333
|
+
var stepTabInstance = useStepTab(rest);
|
334
|
+
return /*#__PURE__*/React.createElement(StepTabInstanceContext.Provider, {
|
335
|
+
value: stepTabInstance
|
336
|
+
}, children);
|
337
|
+
};
|
338
|
+
// 将 useStepTabInstance 挂载到 ProStepTab 上作为静态方法
|
339
|
+
ProStepTab.useStepTabInstance = useStepTabInstance;
|
340
|
+
// 导出默认组件
|
341
|
+
export 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 @@
|
|
1
|
+
export {};
|
package/es/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/es/index.js
CHANGED
@@ -11,6 +11,7 @@ export { default as ProViewer } from './ProViewer';
|
|
11
11
|
export { default as ProEditTable } from './ProEditTable';
|
12
12
|
export { default as ProDrawerForm } from './ProDrawerForm';
|
13
13
|
export { default as ProEditLabel } from './ProEditLabel';
|
14
|
+
export { default as ProStepTab } from './ProStepTab';
|
14
15
|
// 表单
|
15
16
|
export { default as ProForm } from './ProForm';
|
16
17
|
export { ProFormProvider } from './ProForm';
|
package/lib/ProForm/index.js
CHANGED
@@ -27,9 +27,10 @@ var _useFieldProps = require("./utils/useFieldProps");
|
|
27
27
|
var _locale = _interopRequireDefault(require("../locale"));
|
28
28
|
var _useWatch = _interopRequireDefault(require("./utils/useWatch"));
|
29
29
|
var _FormsProvider = _interopRequireWildcard(require("../FormsProvider"));
|
30
|
+
var _ProStep = require("../ProStep");
|
30
31
|
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "diffConfig", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "formKey", "globalControl", "scrollToError", "optimize", "desensitizationKey"];
|
31
32
|
var ProForm = function ProForm(props, ref) {
|
32
|
-
var _localStorage,
|
33
|
+
var _localStorage, _ref3;
|
33
34
|
var _props$mode = props.mode,
|
34
35
|
mode = _props$mode === void 0 ? 'search' : _props$mode,
|
35
36
|
span = props.span,
|
@@ -79,11 +80,15 @@ var ProForm = function ProForm(props, ref) {
|
|
79
80
|
var _ref = (0, _ProDrawerForm.useProDrawerFormContext)() || {},
|
80
81
|
_ref$source = _ref.source,
|
81
82
|
source = _ref$source === void 0 ? '' : _ref$source;
|
83
|
+
// stepSource: 用于区分是哪个组件调用,用于错误提示
|
84
|
+
var _ref2 = (0, _ProStep.useStep)() || {},
|
85
|
+
_ref2$source = _ref2.source,
|
86
|
+
stepSource = _ref2$source === void 0 ? '' : _ref2$source;
|
82
87
|
var _useForm = (0, _useForm3.useForm)(originForm, {
|
83
88
|
scrollToError: scrollToError,
|
84
89
|
optimize: optimize,
|
85
90
|
formKey: formKey,
|
86
|
-
source: source || 'ProForm'
|
91
|
+
source: source || stepSource || 'ProForm'
|
87
92
|
}),
|
88
93
|
_useForm2 = (0, _slicedToArray2.default)(_useForm, 1),
|
89
94
|
form = _useForm2[0];
|
@@ -221,7 +226,7 @@ var ProForm = function ProForm(props, ref) {
|
|
221
226
|
className: cls,
|
222
227
|
form: form
|
223
228
|
}, formProps), (0, _lodash.omit)(config, ['isDiffAll'])), otherProps), {}, {
|
224
|
-
labelAlign: (
|
229
|
+
labelAlign: (_ref3 = labelAlign !== null && labelAlign !== void 0 ? labelAlign : config.labelAlign) !== null && _ref3 !== void 0 ? _ref3 : 'left',
|
225
230
|
onValuesChange: handleValuesChange,
|
226
231
|
onFinish: handleFinish,
|
227
232
|
initialValues: _initialValues,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
3
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
@@ -7,9 +8,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
8
|
exports.getSelectList = void 0;
|
8
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
9
10
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
10
|
-
var _lodash =
|
11
|
+
var _lodash = _interopRequireWildcard(require("lodash"));
|
11
12
|
/* eslint-disable no-restricted-syntax */
|
12
13
|
|
14
|
+
/**
|
15
|
+
* 查找选择器名称的值
|
16
|
+
* @param list 表单列表
|
17
|
+
* @param selectName 选择器名称
|
18
|
+
* @param value 选择器值
|
19
|
+
* @param dataSource 数据源
|
20
|
+
* @param labelInValue 是否为labelInValue模式
|
21
|
+
* @param fieldNames 字段名
|
22
|
+
* @param mode 模式
|
23
|
+
*/
|
13
24
|
var findSelectNameValues = function findSelectNameValues(_ref) {
|
14
25
|
var _ref$list = _ref.list,
|
15
26
|
list = _ref$list === void 0 ? [] : _ref$list,
|
@@ -64,11 +75,13 @@ var getSelectList = exports.getSelectList = function getSelectList(_ref2) {
|
|
64
75
|
var name = otherProps.name,
|
65
76
|
listName = otherProps.listName,
|
66
77
|
form = otherProps.form;
|
78
|
+
// 修复formlist无法过滤的问题
|
79
|
+
var _name = Array.isArray(name) && (0, _lodash.isNumber)(name[0]) ? listName : name;
|
67
80
|
var firstNumberIndex = listName.lastIndexOf(listName.findLast(function (item) {
|
68
81
|
return typeof item === 'number';
|
69
82
|
}));
|
70
|
-
var fatherName = (
|
71
|
-
var selectName = (
|
83
|
+
var fatherName = (_name || listName).slice(0, firstNumberIndex);
|
84
|
+
var selectName = (_name || listName).slice(firstNumberIndex + 1);
|
72
85
|
return findSelectNameValues({
|
73
86
|
list: form.getFieldValue(fatherName) || [],
|
74
87
|
selectName: selectName,
|
@@ -15,35 +15,6 @@ var _reactLazyload = require("react-lazyload");
|
|
15
15
|
var _index = require("../../index");
|
16
16
|
var _utils = require("../../utils");
|
17
17
|
var _excluded = ["children", "delayTime", "excludes"];
|
18
|
-
/**
|
19
|
-
* 检查错误列表并返回第一个错误项
|
20
|
-
* @param arr DOM元素数组
|
21
|
-
* @returns 错误元素信息
|
22
|
-
*/
|
23
|
-
var checkErrorList = function checkErrorList(arr) {
|
24
|
-
for (var i = 0; i < arr.length; i++) {
|
25
|
-
if (arr[i].className.includes('errored')) {
|
26
|
-
return {
|
27
|
-
errorDom: arr[i],
|
28
|
-
index: i
|
29
|
-
};
|
30
|
-
}
|
31
|
-
}
|
32
|
-
return null;
|
33
|
-
};
|
34
|
-
/**
|
35
|
-
* 查找第一个错误的DOM元素
|
36
|
-
* @returns 错误元素信息
|
37
|
-
*/
|
38
|
-
var findFirstErrorDom = function findFirstErrorDom() {
|
39
|
-
var errorList = document.querySelectorAll('.pro-step-com-menu-item');
|
40
|
-
var hasErrorItem = document.querySelectorAll('.pro-step-com-menu-item .errored');
|
41
|
-
var hasFormError = document.querySelector('.ant-form-item-explain-error');
|
42
|
-
if ((hasErrorItem === null || hasErrorItem === void 0 ? void 0 : hasErrorItem.length) && !hasFormError) {
|
43
|
-
return checkErrorList(errorList);
|
44
|
-
}
|
45
|
-
return null;
|
46
|
-
};
|
47
18
|
/**
|
48
19
|
* 检查所有模块是否已加载完成
|
49
20
|
* @param data 模块加载数据
|
@@ -90,11 +61,6 @@ var Listener = function Listener(_ref) {
|
|
90
61
|
values = _context.sent;
|
91
62
|
setTimeout(function () {
|
92
63
|
var localData = localStorage.getItem('cache-pro-step');
|
93
|
-
var _ref3 = findFirstErrorDom() || {},
|
94
|
-
errorDom = _ref3.errorDom;
|
95
|
-
if (errorDom) {
|
96
|
-
errorDom.click();
|
97
|
-
}
|
98
64
|
if (localData !== 'false') {
|
99
65
|
var _children$props, _children$props$onCli;
|
100
66
|
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);
|
@@ -106,7 +72,7 @@ var Listener = function Listener(_ref) {
|
|
106
72
|
return _context.stop();
|
107
73
|
}
|
108
74
|
}, _callee);
|
109
|
-
})),
|
75
|
+
})), 1000)
|
110
76
|
}));
|
111
77
|
};
|
112
78
|
var _default = exports.default = Listener;
|