@teamix/pro 1.3.9 → 1.3.12
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/dist/pro.js +224 -378
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog-form.js +1 -1
- package/es/actions/dialog.d.ts +1 -1
- package/es/actions/dialog.js +11 -6
- package/es/form/Filter/index.js +92 -172
- package/es/form/ProForm/index.js +32 -22
- package/es/form/typing.d.ts +1 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/info/components/baseInfo/index.js +6 -14
- package/es/info/typing.d.ts +0 -1
- package/lib/actions/dialog-form.js +1 -1
- package/lib/actions/dialog.d.ts +1 -1
- package/lib/actions/dialog.js +11 -6
- package/lib/form/Filter/index.js +91 -171
- package/lib/form/ProForm/index.js +30 -20
- package/lib/form/typing.d.ts +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/info/components/baseInfo/index.js +6 -14
- package/lib/info/typing.d.ts +0 -1
- package/package.json +1 -1
@@ -232,6 +232,6 @@ export function useDialogFormAction(action, context) {
|
|
232
232
|
|
233
233
|
_onFinish && _onFinish((_innerFormRef$current2 = innerFormRef.current) === null || _innerFormRef$current2 === void 0 ? void 0 : _innerFormRef$current2.values);
|
234
234
|
}
|
235
|
-
}, others), context);
|
235
|
+
}, others), context, true);
|
236
236
|
}
|
237
237
|
export default useDialogFormAction;
|
package/es/actions/dialog.d.ts
CHANGED
@@ -26,7 +26,7 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
|
|
26
26
|
/** 弹窗内容区的组件 */
|
27
27
|
component?: any;
|
28
28
|
}
|
29
|
-
export declare function useDialogAction(action: DialogAction, actionContext?: any): {
|
29
|
+
export declare function useDialogAction(action: DialogAction, actionContext?: any, hasForm?: boolean): {
|
30
30
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
31
31
|
};
|
32
32
|
export default useDialogAction;
|
package/es/actions/dialog.js
CHANGED
@@ -69,7 +69,7 @@ function getFooterAlignClass(isDrawer, align) {
|
|
69
69
|
} // 弹窗 -> 请求(点击确认,发送数据请求)
|
70
70
|
|
71
71
|
|
72
|
-
export function useDialogAction(action, actionContext) {
|
72
|
+
export function useDialogAction(action, actionContext, hasForm) {
|
73
73
|
var _useState = useState(false),
|
74
74
|
_useState2 = _slicedToArray(_useState, 2),
|
75
75
|
loading = _useState2[0],
|
@@ -174,22 +174,27 @@ export function useDialogAction(action, actionContext) {
|
|
174
174
|
case 6:
|
175
175
|
onFinish && onFinish();
|
176
176
|
resolve(true);
|
177
|
-
_context.next =
|
177
|
+
_context.next = 18;
|
178
178
|
break;
|
179
179
|
|
180
180
|
case 10:
|
181
181
|
_context.prev = 10;
|
182
182
|
_context.t0 = _context["catch"](2);
|
183
|
-
setLoading(false); // 如果 beforeRequest 中返回了 false,则直接关闭弹窗
|
183
|
+
setLoading(false); // 如果 beforeRequest 中返回了 false 并且不是 dialog-form,则直接关闭弹窗
|
184
184
|
|
185
|
-
if (beforeRequest) {
|
186
|
-
|
185
|
+
if (!(beforeRequest && !hasForm)) {
|
186
|
+
_context.next = 16;
|
187
|
+
break;
|
187
188
|
}
|
188
189
|
|
189
|
-
resolve(
|
190
|
+
resolve(true);
|
190
191
|
return _context.abrupt("return");
|
191
192
|
|
192
193
|
case 16:
|
194
|
+
resolve(false);
|
195
|
+
return _context.abrupt("return");
|
196
|
+
|
197
|
+
case 18:
|
193
198
|
case "end":
|
194
199
|
return _context.stop();
|
195
200
|
}
|
package/es/form/Filter/index.js
CHANGED
@@ -40,7 +40,7 @@ import debounce from 'lodash.debounce';
|
|
40
40
|
import { Tag } from '@alicloudfe/components';
|
41
41
|
import { createForm, onFormReact, onFormInputChange } from '@formily/core';
|
42
42
|
import { toJS } from '@formily/reactive';
|
43
|
-
import { usePrefixCls, isUsable, isNum
|
43
|
+
import { usePrefixCls, isUsable, isNum } from '@teamix/utils';
|
44
44
|
import ProField from '../../field/index';
|
45
45
|
import fieldTypeMap from '../fieldTypeMap';
|
46
46
|
import { getFormDisplayValues } from '../ProForm/useFormDisplayValues';
|
@@ -72,7 +72,6 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
72
72
|
otherProps = _objectWithoutProperties(props, _excluded);
|
73
73
|
|
74
74
|
var _useSpecialProps = useSpecialProps(props),
|
75
|
-
hasChangeDefault = _useSpecialProps.hasChangeDefault,
|
76
75
|
hasRequired = _useSpecialProps.hasRequired;
|
77
76
|
|
78
77
|
var _useState = useState(!!expand),
|
@@ -92,56 +91,66 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
92
91
|
var prefixCls = usePrefixCls('', {
|
93
92
|
prefix: 'teamix-pro-form-query-filter'
|
94
93
|
});
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
var debounceFun = debounce(function (fun, props) {
|
95
|
+
return fun(props);
|
96
|
+
}, filterDebounce); // onInit
|
98
97
|
|
98
|
+
var initialRequestRef = useRef(!!(props === null || props === void 0 ? void 0 : props.initialRequest));
|
99
99
|
var filterEnable = useRef('waiting');
|
100
100
|
|
101
|
-
var
|
102
|
-
var
|
103
|
-
|
101
|
+
var onFormInit = /*#__PURE__*/function () {
|
102
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(form) {
|
103
|
+
var loadingField;
|
104
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
105
|
+
while (1) {
|
106
|
+
switch (_context.prev = _context.next) {
|
107
|
+
case 0:
|
108
|
+
form.setState({
|
109
|
+
loading: initialRequestRef.current
|
110
|
+
}); // 借用 form.loading 触发 onFormReact
|
104
111
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
loading: !!initialRequest || !!initialValues
|
109
|
-
});
|
110
|
-
}
|
112
|
+
loadingField = Object.values(form.fields).filter(function (field) {
|
113
|
+
return !!field.loading;
|
114
|
+
}); // 等待mounted + 字段loading结束 + initialRequest结束 => 表单默认值初始化完成
|
111
115
|
|
112
|
-
|
113
|
-
|
114
|
-
|
116
|
+
if (!(form.mounted && !loadingField.length && !form.loading)) {
|
117
|
+
_context.next = 10;
|
118
|
+
break;
|
119
|
+
}
|
120
|
+
|
121
|
+
onFormInit = function onFormInit() {}; // init后销毁 isFormInit 方法
|
115
122
|
|
116
|
-
if (form.mounted && !loadingField.length && !form.loading) {
|
117
|
-
_onFormInit = function onFormInit() {}; // init后销毁 isFormInit 方法
|
118
123
|
|
124
|
+
filterEnable.current = 'filter';
|
125
|
+
|
126
|
+
if (!onInit) {
|
127
|
+
_context.next = 10;
|
128
|
+
break;
|
129
|
+
}
|
119
130
|
|
120
|
-
|
131
|
+
_context.next = 8;
|
132
|
+
return form.validate();
|
121
133
|
|
122
|
-
|
123
|
-
|
124
|
-
filterEnable.current = 'filter';
|
125
|
-
setTimeout(function () {
|
126
|
-
onInit === null || onInit === void 0 ? void 0 : onInit(toJS(form.values));
|
127
|
-
}, 0);
|
134
|
+
case 8:
|
135
|
+
onInit === null || onInit === void 0 ? void 0 : onInit(toJS(form.values)); // 设置Tag
|
128
136
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
137
|
+
if (mode === 'panel') {
|
138
|
+
configFilterItem(advancedForm);
|
139
|
+
!panelVisible && configTag();
|
140
|
+
}
|
133
141
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
}, 0);
|
142
|
+
case 10:
|
143
|
+
case "end":
|
144
|
+
return _context.stop();
|
138
145
|
}
|
139
146
|
}
|
140
|
-
}
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
147
|
+
}, _callee);
|
148
|
+
}));
|
149
|
+
|
150
|
+
return function onFormInit(_x) {
|
151
|
+
return _ref.apply(this, arguments);
|
152
|
+
};
|
153
|
+
}(); // 配置当前激活的form实例
|
145
154
|
|
146
155
|
|
147
156
|
var setCurrentForm = function setCurrentForm(formName) {
|
@@ -167,7 +176,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
167
176
|
effects: function effects() {
|
168
177
|
onFormReact(function (form) {
|
169
178
|
if (mode === 'inline') {
|
170
|
-
|
179
|
+
onFormInit(form);
|
171
180
|
}
|
172
181
|
});
|
173
182
|
}
|
@@ -191,7 +200,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
191
200
|
effects: function effects() {
|
192
201
|
onFormReact(function (form) {
|
193
202
|
if (mode === 'panel') {
|
194
|
-
|
203
|
+
onFormInit(form);
|
195
204
|
}
|
196
205
|
});
|
197
206
|
onFormInputChange(function (form) {
|
@@ -272,93 +281,62 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
272
281
|
}, [panelVisible, configTag]); // 简单搜索Filter
|
273
282
|
|
274
283
|
var onSimpleFilter = useCallback( /*#__PURE__*/function () {
|
275
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
276
|
-
return regeneratorRuntime.wrap(function
|
284
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) {
|
285
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
277
286
|
while (1) {
|
278
|
-
switch (
|
287
|
+
switch (_context2.prev = _context2.next) {
|
279
288
|
case 0:
|
280
|
-
|
281
|
-
_context.next = 14;
|
282
|
-
break;
|
283
|
-
}
|
284
|
-
|
285
|
-
if (!(filterEnable.current === 'initialized')) {
|
286
|
-
_context.next = 9;
|
287
|
-
break;
|
288
|
-
}
|
289
|
-
|
290
|
-
filterEnable.current = 'filter';
|
291
|
-
|
292
|
-
if (!hasRequired) {
|
293
|
-
_context.next = 6;
|
294
|
-
break;
|
295
|
-
}
|
296
|
-
|
297
|
-
_context.next = 6;
|
298
|
-
return simpleForm.validate();
|
299
|
-
|
300
|
-
case 6:
|
301
|
-
onInit === null || onInit === void 0 ? void 0 : onInit(values);
|
302
|
-
_context.next = 14;
|
303
|
-
break;
|
304
|
-
|
305
|
-
case 9:
|
306
|
-
if (!(filterEnable.current === 'filter')) {
|
307
|
-
_context.next = 14;
|
308
|
-
break;
|
309
|
-
}
|
310
|
-
|
311
|
-
if (!hasRequired) {
|
312
|
-
_context.next = 13;
|
313
|
-
break;
|
314
|
-
}
|
315
|
-
|
316
|
-
_context.next = 13;
|
289
|
+
_context2.next = 2;
|
317
290
|
return simpleForm.validate();
|
318
291
|
|
319
|
-
case
|
292
|
+
case 2:
|
320
293
|
onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
|
321
294
|
|
322
|
-
case
|
295
|
+
case 3:
|
323
296
|
case "end":
|
324
|
-
return
|
297
|
+
return _context2.stop();
|
325
298
|
}
|
326
299
|
}
|
327
|
-
},
|
300
|
+
}, _callee2);
|
328
301
|
}));
|
329
302
|
|
330
|
-
return function (
|
303
|
+
return function (_x2) {
|
331
304
|
return _ref4.apply(this, arguments);
|
332
305
|
};
|
333
|
-
}(), [onFilter
|
306
|
+
}(), [onFilter]); // 简单搜索Change
|
334
307
|
|
335
308
|
var onSimpleChange = useCallback(function (values, fieldValue, fieldName) {
|
336
309
|
if (currentForm.current === 'simple') {
|
337
310
|
onChange === null || onChange === void 0 ? void 0 : onChange(values, fieldValue, fieldName);
|
311
|
+
|
312
|
+
if (filterEnable.current === 'filter') {
|
313
|
+
debounceFun(onSimpleFilter, values);
|
314
|
+
}
|
338
315
|
}
|
339
316
|
}, [onChange]); // 轻量搜索Filter
|
340
317
|
|
341
318
|
var onLightFilter = useCallback(function (values) {
|
342
|
-
|
343
|
-
if (filterEnable.current === 'filter') {
|
344
|
-
var _Object$keys;
|
319
|
+
var _Object$keys;
|
345
320
|
|
346
|
-
|
321
|
+
onFilter === null || onFilter === void 0 ? void 0 : onFilter(values); // 清空advancedForm的值
|
347
322
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
}
|
323
|
+
var clearKeys = {};
|
324
|
+
(_Object$keys = Object.keys(advancedForm.values)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(function (key) {
|
325
|
+
clearKeys[key] = undefined;
|
326
|
+
});
|
327
|
+
advancedForm.setValues(clearKeys); // 配置Tag
|
328
|
+
|
329
|
+
configFilterItem(advancedForm);
|
330
|
+
configTag();
|
357
331
|
}, [onFilter]); // 轻量搜索Change
|
358
332
|
|
359
333
|
var onLightChange = useCallback(function (values, fieldValue, fieldName) {
|
360
334
|
if (currentForm.current === 'light') {
|
361
335
|
onChange === null || onChange === void 0 ? void 0 : onChange(values, fieldValue, fieldName);
|
336
|
+
|
337
|
+
if (filterEnable.current === 'filter') {
|
338
|
+
debounceFun(onLightFilter, values);
|
339
|
+
}
|
362
340
|
}
|
363
341
|
}, [onChange]); // 高级搜索Filter
|
364
342
|
|
@@ -380,54 +358,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
380
358
|
lightForm.reset('*', {
|
381
359
|
forceClear: true
|
382
360
|
});
|
383
|
-
}, [onReset]); // 高级搜索
|
384
|
-
|
385
|
-
var onAdvancedInit = useCallback( /*#__PURE__*/function () {
|
386
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) {
|
387
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
388
|
-
while (1) {
|
389
|
-
switch (_context2.prev = _context2.next) {
|
390
|
-
case 0:
|
391
|
-
if (!(currentForm.current === 'advanced')) {
|
392
|
-
_context2.next = 9;
|
393
|
-
break;
|
394
|
-
}
|
395
|
-
|
396
|
-
if (!(filterEnable.current === 'initialized')) {
|
397
|
-
_context2.next = 9;
|
398
|
-
break;
|
399
|
-
}
|
400
|
-
|
401
|
-
filterEnable.current = 'filter';
|
402
|
-
|
403
|
-
if (!hasRequired) {
|
404
|
-
_context2.next = 6;
|
405
|
-
break;
|
406
|
-
}
|
407
|
-
|
408
|
-
_context2.next = 6;
|
409
|
-
return advancedForm.validate();
|
410
|
-
|
411
|
-
case 6:
|
412
|
-
onInit === null || onInit === void 0 ? void 0 : onInit(values);
|
413
|
-
configFilterItem(advancedForm);
|
414
|
-
|
415
|
-
if (!panelVisible) {
|
416
|
-
configTag();
|
417
|
-
}
|
418
|
-
|
419
|
-
case 9:
|
420
|
-
case "end":
|
421
|
-
return _context2.stop();
|
422
|
-
}
|
423
|
-
}
|
424
|
-
}, _callee2);
|
425
|
-
}));
|
426
|
-
|
427
|
-
return function (_x2) {
|
428
|
-
return _ref5.apply(this, arguments);
|
429
|
-
};
|
430
|
-
}(), [hasRequired, onInit]); // 高级搜索Change
|
361
|
+
}, [onReset]); // 高级搜索Change
|
431
362
|
|
432
363
|
var onAdvancedChange = useCallback(function (values, fieldValue, fieldName) {
|
433
364
|
if (currentForm.current === 'advanced') {
|
@@ -447,16 +378,14 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
447
378
|
configFilterItem(advancedForm);
|
448
379
|
configTag();
|
449
380
|
onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(advancedForm.values));
|
450
|
-
}, [onFilter]); //
|
381
|
+
}, [onFilter]); // initialRequest 的回调
|
451
382
|
|
452
383
|
var onInitialComplete = useCallback(function (form) {
|
384
|
+
initialRequestRef.current = false;
|
453
385
|
form.setState({
|
454
|
-
loading:
|
386
|
+
loading: initialRequestRef.current
|
455
387
|
});
|
456
|
-
}, []);
|
457
|
-
var debounceFun = debounce(function (fun, props) {
|
458
|
-
return fun(props);
|
459
|
-
}, filterDebounce); // 组件挂载
|
388
|
+
}, []); // 组件挂载
|
460
389
|
|
461
390
|
useEffect(function () {
|
462
391
|
setCurrentForm(currentForm.current);
|
@@ -475,37 +404,28 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
|
|
475
404
|
filterValues: filterValues,
|
476
405
|
activeFilterValueRef: activeFilterValueRef,
|
477
406
|
form: lightForm,
|
478
|
-
onChange:
|
479
|
-
debounceFun(onLightFilter, values);
|
480
|
-
onLightChange(values, fieldValue, fieldName);
|
481
|
-
}
|
407
|
+
onChange: onLightChange
|
482
408
|
}))) : /*#__PURE__*/React.createElement("div", {
|
483
409
|
className: "".concat(prefixCls, "-inline")
|
484
410
|
}, /*#__PURE__*/React.createElement(SimpleFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
|
485
411
|
form: simpleForm,
|
486
|
-
onChange:
|
487
|
-
debounceFun(onSimpleFilter, values);
|
488
|
-
onSimpleChange(values, fieldValue, fieldName);
|
489
|
-
},
|
412
|
+
onChange: onSimpleChange,
|
490
413
|
onSubmit: onSimpleFilter,
|
491
414
|
onInitialComplete: onInitialComplete
|
492
415
|
}))),
|
493
416
|
panelContent: mode === 'panel' ? /*#__PURE__*/React.createElement(AdvancedFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
|
494
417
|
form: advancedForm,
|
495
|
-
onChange:
|
496
|
-
debounceFun(onAdvancedInit, values);
|
497
|
-
onAdvancedChange(values, fieldValue, fieldName);
|
498
|
-
},
|
418
|
+
onChange: onAdvancedChange,
|
499
419
|
onSubmit: onAdvancedFilter,
|
500
420
|
onReset: onAdvancedReset,
|
501
421
|
onInitialComplete: onInitialComplete
|
502
422
|
})) : null
|
503
|
-
}, mode === 'panel' && !panelVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (
|
504
|
-
var key =
|
505
|
-
label =
|
506
|
-
value =
|
507
|
-
type =
|
508
|
-
index =
|
423
|
+
}, mode === 'panel' && !panelVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref5) {
|
424
|
+
var key = _ref5.key,
|
425
|
+
label = _ref5.label,
|
426
|
+
value = _ref5.value,
|
427
|
+
type = _ref5.type,
|
428
|
+
index = _ref5.index;
|
509
429
|
return /*#__PURE__*/React.createElement(Tag.Closeable, {
|
510
430
|
key: isNum(index) ? key + label : key,
|
511
431
|
afterClose: function afterClose() {
|
package/es/form/ProForm/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
|
1
|
+
var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
|
2
2
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
4
|
|
@@ -10,9 +10,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
10
10
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
12
12
|
|
13
|
-
import React, { memo,
|
13
|
+
import React, { memo, useMemo } from 'react';
|
14
14
|
import cls from 'classnames';
|
15
|
-
import { createForm, onFieldValueChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
15
|
+
import { createForm, onFieldValueChange, onFormValuesChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
16
16
|
import { toJS } from '@formily/reactive';
|
17
17
|
import { Form } from '@teamix/formily';
|
18
18
|
import { usePrefixCls, getLanguage, getGlobalConfig } from '@teamix/utils';
|
@@ -39,6 +39,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
39
39
|
wrapperCol = _ref.wrapperCol,
|
40
40
|
breakpoints = _ref.breakpoints,
|
41
41
|
onChange = _ref.onChange,
|
42
|
+
onChangeType = _ref.onChangeType,
|
42
43
|
onSubmit = _ref.onSubmit,
|
43
44
|
onSubmitFailed = _ref.onSubmitFailed,
|
44
45
|
onInitialComplete = _ref.onInitialComplete,
|
@@ -85,35 +86,44 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
85
86
|
labelCol: mergeArrayValue([24], labelCol),
|
86
87
|
wrapperCol: mergeArrayValue([24], wrapperCol)
|
87
88
|
};
|
88
|
-
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
89
|
-
|
90
|
-
|
91
|
-
form.removeEffects('onFieldValueChange');
|
92
|
-
form.addEffects('onFieldValueChange', function () {
|
93
|
-
onFieldValueChange('*', function (field, form) {
|
94
|
-
var _field$props;
|
95
|
-
|
96
|
-
onChange && onChange(toJS(form.values), toJS(field.value), (_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.name);
|
97
|
-
});
|
98
|
-
});
|
99
|
-
}, [form, onChange]); // 配置表单默认值
|
100
|
-
|
101
|
-
useEffect(function () {
|
89
|
+
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
90
|
+
useMemo(function () {
|
91
|
+
// 配置表单默认值
|
102
92
|
if (initialValues) {
|
103
93
|
form.setInitialValues(initialValues);
|
104
|
-
onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
|
105
94
|
} else if (initialRequest) {
|
106
95
|
useInitialRequest(initialRequest).then(function (values) {
|
107
96
|
form.setInitialValues(values);
|
108
97
|
}).finally(function () {
|
109
98
|
onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
|
110
99
|
});
|
111
|
-
}
|
112
|
-
|
100
|
+
} // 配置国际化
|
101
|
+
|
113
102
|
|
114
|
-
useEffect(function () {
|
115
103
|
setValidateLanguage(getLanguage() || 'zh-cn');
|
116
|
-
}, []);
|
104
|
+
}, []); // 添加 onChange 事件
|
105
|
+
|
106
|
+
useMemo(function () {
|
107
|
+
if (onChangeType === 'form') {
|
108
|
+
// 使用 onFormValuesChange 无法监听具体变化字段
|
109
|
+
form.removeEffects('onChangeByFormValuesChange');
|
110
|
+
form.addEffects('onChangeByFormValuesChange', function () {
|
111
|
+
onFormValuesChange(function (form) {
|
112
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(toJS(form.values));
|
113
|
+
});
|
114
|
+
});
|
115
|
+
} else {
|
116
|
+
// 使用 onFieldValueChange 无法监听数组类型值的增删
|
117
|
+
form.removeEffects('onChangeByFieldValueChange');
|
118
|
+
form.addEffects('onChangeByFieldValueChange', function () {
|
119
|
+
onFieldValueChange('*', function (field, form) {
|
120
|
+
var _field$props;
|
121
|
+
|
122
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(toJS(form.values), toJS(field.value), (_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.name);
|
123
|
+
});
|
124
|
+
});
|
125
|
+
}
|
126
|
+
}, [onChange]);
|
117
127
|
return /*#__PURE__*/React.createElement(Form, _objectSpread(_objectSpread(_objectSpread({
|
118
128
|
className: cls(prefixCls, className)
|
119
129
|
}, otherProps), getTeamixLayout), {}, {
|
package/es/form/typing.d.ts
CHANGED
@@ -67,6 +67,7 @@ export interface ProFormProps extends IFormLayoutProps {
|
|
67
67
|
initialRequest?: ProFormRequestConfig;
|
68
68
|
previewTextPlaceholder?: ReactNode;
|
69
69
|
validateFirst?: boolean;
|
70
|
+
onChangeType?: 'form';
|
70
71
|
onChange?: (values: any, fieldValue?: any, fieldName?: any) => any;
|
71
72
|
onSubmit?: ((values: any) => any) | CommonRequestConfig;
|
72
73
|
onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
|
package/es/index.d.ts
CHANGED
@@ -26,5 +26,5 @@ export * from './table';
|
|
26
26
|
export * from './sidebar';
|
27
27
|
export * from './utils';
|
28
28
|
export * from './timeline';
|
29
|
-
declare const version = "1.3.
|
29
|
+
declare const version = "1.3.12";
|
30
30
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
@@ -31,6 +31,6 @@ export * from './sidebar';
|
|
31
31
|
export * from './utils'; // export * from './sidebar';
|
32
32
|
|
33
33
|
export * from './timeline';
|
34
|
-
var version = '1.3.
|
34
|
+
var version = '1.3.12';
|
35
35
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
|
36
36
|
ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils };
|
@@ -26,33 +26,23 @@ var ProBaseInfo = function ProBaseInfo(props) {
|
|
26
26
|
var formItemLayout = JSON.parse(JSON.stringify(defaultLayout.formItemLayout)); // 自定义布局
|
27
27
|
|
28
28
|
if (layout) {
|
29
|
-
var _layout$labelCol, _layout$wrapperCol
|
29
|
+
var _layout$labelCol, _layout$wrapperCol;
|
30
30
|
|
31
31
|
var labelCol = (_layout$labelCol = layout === null || layout === void 0 ? void 0 : layout.labelCol) !== null && _layout$labelCol !== void 0 ? _layout$labelCol : defaultLayout.formItemLayout.labelCol;
|
32
32
|
var wrapperCol = (_layout$wrapperCol = layout === null || layout === void 0 ? void 0 : layout.wrapperCol) !== null && _layout$wrapperCol !== void 0 ? _layout$wrapperCol : defaultLayout.formItemLayout.wrapperCol;
|
33
|
-
var span = (_layout$span = layout === null || layout === void 0 ? void 0 : layout.span) !== null && _layout$span !== void 0 ? _layout$span : defaultLayout.span;
|
34
|
-
|
35
|
-
if ((layout === null || layout === void 0 ? void 0 : layout.colNum) && layout.colNum > 0 && layout.colNum <= 4) {
|
36
|
-
span = 24 / layout.colNum;
|
37
|
-
}
|
38
|
-
|
39
|
-
formItemLayout.span = span;
|
40
33
|
formItemLayout.labelCol = labelCol;
|
41
34
|
formItemLayout.wrapperCol = wrapperCol;
|
42
35
|
}
|
43
36
|
|
44
|
-
var newSpan = formItemLayout.span;
|
45
37
|
var newLabelSpan = formItemLayout.labelCol.span;
|
46
38
|
var newWrapperSpan = formItemLayout.wrapperCol.span; // 计算合并列情况。label与wrapper需要重新计算
|
47
39
|
|
48
40
|
if (colspan) {
|
49
|
-
newSpan = newSpan * (colspan !== null && colspan !== void 0 ? colspan : 1);
|
50
41
|
newLabelSpan = newLabelSpan / colspan;
|
51
42
|
newWrapperSpan = newWrapperSpan + (formItemLayout.labelCol.span - newLabelSpan);
|
52
43
|
}
|
53
44
|
|
54
45
|
var newFormItemLayout = {
|
55
|
-
span: newSpan,
|
56
46
|
labelCol: {
|
57
47
|
span: newLabelSpan
|
58
48
|
},
|
@@ -65,10 +55,12 @@ var ProBaseInfo = function ProBaseInfo(props) {
|
|
65
55
|
|
66
56
|
var renderContent = function renderContent() {
|
67
57
|
return columns.map(function (item, index) {
|
68
|
-
var
|
58
|
+
var _layout$span, _layout$span2, _item$title, _item$valueType, _ref, _item$colSpan;
|
69
59
|
|
60
|
+
var span = item.colSpan ? defaultLayout.span * item.colSpan : defaultLayout.span;
|
61
|
+
var layoutSpan = item.colSpan ? ((_layout$span = layout === null || layout === void 0 ? void 0 : layout.span) !== null && _layout$span !== void 0 ? _layout$span : span) * item.colSpan : (_layout$span2 = layout === null || layout === void 0 ? void 0 : layout.span) !== null && _layout$span2 !== void 0 ? _layout$span2 : span;
|
70
62
|
return /*#__PURE__*/React.createElement(Col, {
|
71
|
-
span:
|
63
|
+
span: layoutSpan,
|
72
64
|
key: index
|
73
65
|
}, /*#__PURE__*/React.createElement(ProInfoItem, {
|
74
66
|
label: (_item$title = item === null || item === void 0 ? void 0 : item.title) !== null && _item$title !== void 0 ? _item$title : '',
|
@@ -84,7 +76,7 @@ var ProBaseInfo = function ProBaseInfo(props) {
|
|
84
76
|
context: context,
|
85
77
|
props: item.props
|
86
78
|
}),
|
87
|
-
baseInfoLayout: getFormItemLayout((_item$
|
79
|
+
baseInfoLayout: getFormItemLayout((_item$colSpan = item === null || item === void 0 ? void 0 : item.colSpan) !== null && _item$colSpan !== void 0 ? _item$colSpan : 0),
|
88
80
|
tooltip: item.tooltip,
|
89
81
|
tooltipIcon: item.tooltipIcon
|
90
82
|
}));
|
package/es/info/typing.d.ts
CHANGED
@@ -135,7 +135,6 @@ export declare type ProInfoProps = {
|
|
135
135
|
export declare type IProHeaderInfoItem = {};
|
136
136
|
export declare type BaseInfoLayoutProps = ProBaseInfoLayoutProps;
|
137
137
|
export declare type ProBaseInfoLayoutProps = {
|
138
|
-
colNum?: number;
|
139
138
|
span?: number;
|
140
139
|
labelCol?: {
|
141
140
|
span: number;
|
@@ -253,7 +253,7 @@ function useDialogFormAction(action, context) {
|
|
253
253
|
|
254
254
|
_onFinish && _onFinish((_innerFormRef$current2 = innerFormRef.current) === null || _innerFormRef$current2 === void 0 ? void 0 : _innerFormRef$current2.values);
|
255
255
|
}
|
256
|
-
}, others), context);
|
256
|
+
}, others), context, true);
|
257
257
|
}
|
258
258
|
|
259
259
|
var _default = useDialogFormAction;
|
package/lib/actions/dialog.d.ts
CHANGED
@@ -26,7 +26,7 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
|
|
26
26
|
/** 弹窗内容区的组件 */
|
27
27
|
component?: any;
|
28
28
|
}
|
29
|
-
export declare function useDialogAction(action: DialogAction, actionContext?: any): {
|
29
|
+
export declare function useDialogAction(action: DialogAction, actionContext?: any, hasForm?: boolean): {
|
30
30
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
31
31
|
};
|
32
32
|
export default useDialogAction;
|