@teamias/rex-design 0.0.36 → 0.0.37
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/components/base-descriptions/base-descriptions.js +1 -0
- package/dist/components/base-form/core/{base-form.d.ts → core.d.ts} +1 -1
- package/dist/components/base-form/core/{base-form.js → core.js} +1 -1
- package/dist/components/base-form/core/descriptions-model.js +2 -2
- package/dist/components/base-form/core/index.d.ts +2 -2
- package/dist/components/base-form/core/index.js +2 -2
- package/dist/components/base-form/demo/BaseFormDescriptions.js +59 -2
- package/dist/components/base-form/index.d.ts +1 -0
- package/dist/components/base-form/index.js +2 -1
- package/dist/components/base-form/modules/renderComponentNode.js +2 -2
- package/dist/components/base-form/utils/index.d.ts +47 -0
- package/dist/components/base-form/utils/index.js +56 -0
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ import { BaseFormStyle } from "../style";
|
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
-
export var
|
|
22
|
+
export var Core = function Core(props) {
|
|
23
23
|
var rawAllProps = props;
|
|
24
24
|
var outFields = props.fields,
|
|
25
25
|
outFieldProps = props.fieldProps,
|
|
@@ -13,7 +13,7 @@ import { Descriptions, Form } from 'antd';
|
|
|
13
13
|
import { merge } from 'lodash';
|
|
14
14
|
import { useMemo } from 'react';
|
|
15
15
|
import { DescriptionsStyle } from "../style";
|
|
16
|
-
import {
|
|
16
|
+
import { Core } from "./core";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
export var DescriptionsModel = function DescriptionsModel(_ref) {
|
|
19
19
|
var _ref$descriptionsProp = _ref.descriptionsProps,
|
|
@@ -73,7 +73,7 @@ export var DescriptionsModel = function DescriptionsModel(_ref) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}),
|
|
76
|
-
children: /*#__PURE__*/_jsx(
|
|
76
|
+
children: /*#__PURE__*/_jsx(Core, _objectSpread(_objectSpread({}, baseFormProps), {}, {
|
|
77
77
|
itemMarginBottom: 0,
|
|
78
78
|
fields: [_objectSpread(_objectSpread({}, otherData), {}, {
|
|
79
79
|
rules: rules,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Core } from './core';
|
|
2
2
|
import { DescriptionsModel as BaseDescriptionsForm } from './descriptions-model';
|
|
3
|
-
declare const BaseForm: typeof
|
|
3
|
+
declare const BaseForm: typeof Core;
|
|
4
4
|
export { BaseDescriptionsForm, BaseForm };
|
|
@@ -4,13 +4,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
import {
|
|
7
|
+
import { Core } from "./core";
|
|
8
8
|
import { DescriptionsModel as BaseDescriptionsForm } from "./descriptions-model";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
var BaseForm = function BaseForm(props) {
|
|
11
11
|
if (props.type === 'descriptions') {
|
|
12
12
|
return /*#__PURE__*/_jsx(BaseDescriptionsForm, _objectSpread({}, props));
|
|
13
13
|
}
|
|
14
|
-
return /*#__PURE__*/_jsx(
|
|
14
|
+
return /*#__PURE__*/_jsx(Core, _objectSpread({}, props));
|
|
15
15
|
};
|
|
16
16
|
export { BaseDescriptionsForm, BaseForm };
|
|
@@ -4,16 +4,25 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
13
|
import enUS from "../../../locales/en-US.json";
|
|
8
14
|
import { UserOutlined } from '@ant-design/icons';
|
|
9
15
|
import { ProForm } from '@ant-design/pro-components';
|
|
10
|
-
import { RexProConfigProvider } from "../../..";
|
|
16
|
+
import { resetFormTouched, RexProConfigProvider } from "../../..";
|
|
11
17
|
import { crush } from 'radash';
|
|
12
18
|
import { createIntl } from 'react-intl';
|
|
13
19
|
import { BaseForm } from "../core";
|
|
14
20
|
import { getFieldsDefaultValues } from "../modules/handlerData";
|
|
15
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
22
|
export default (function () {
|
|
23
|
+
var _ProForm$useForm = ProForm.useForm(),
|
|
24
|
+
_ProForm$useForm2 = _slicedToArray(_ProForm$useForm, 1),
|
|
25
|
+
form = _ProForm$useForm2[0];
|
|
17
26
|
var fields = [{
|
|
18
27
|
label: '成本区间',
|
|
19
28
|
valueType: 'multipleComponents',
|
|
@@ -70,7 +79,11 @@ export default (function () {
|
|
|
70
79
|
}, {
|
|
71
80
|
valueType: 'datePicker',
|
|
72
81
|
field: 'multipleComponents-datePicker',
|
|
73
|
-
defaultValue: '2025-05-05'
|
|
82
|
+
defaultValue: '2025-05-05',
|
|
83
|
+
dependenciesV2: [{
|
|
84
|
+
action: 'clear',
|
|
85
|
+
field: 'multipleComponents-treeSelect'
|
|
86
|
+
}]
|
|
74
87
|
}, {
|
|
75
88
|
valueType: 'treeSelect',
|
|
76
89
|
field: 'multipleComponents-treeSelect2',
|
|
@@ -237,6 +250,47 @@ export default (function () {
|
|
|
237
250
|
// target: true,
|
|
238
251
|
// }
|
|
239
252
|
// ],
|
|
253
|
+
}, {
|
|
254
|
+
valueType: 'select',
|
|
255
|
+
field: 'org_id',
|
|
256
|
+
label: '部门',
|
|
257
|
+
itemWidth: '200px',
|
|
258
|
+
options: [{
|
|
259
|
+
label: '1',
|
|
260
|
+
value: '1'
|
|
261
|
+
}, {
|
|
262
|
+
label: '2',
|
|
263
|
+
value: '2'
|
|
264
|
+
}, {
|
|
265
|
+
label: '3',
|
|
266
|
+
value: '3'
|
|
267
|
+
}]
|
|
268
|
+
}, {
|
|
269
|
+
valueType: 'select',
|
|
270
|
+
field: 'job_id',
|
|
271
|
+
label: '岗位',
|
|
272
|
+
itemWidth: '200px',
|
|
273
|
+
options: [{
|
|
274
|
+
label: '1',
|
|
275
|
+
value: '1'
|
|
276
|
+
}, {
|
|
277
|
+
label: '2',
|
|
278
|
+
value: '2'
|
|
279
|
+
}, {
|
|
280
|
+
label: '3',
|
|
281
|
+
value: '3'
|
|
282
|
+
}],
|
|
283
|
+
dependenciesV2: [{
|
|
284
|
+
field: 'org_id',
|
|
285
|
+
action: 'show',
|
|
286
|
+
op: 'notEmpty'
|
|
287
|
+
}, {
|
|
288
|
+
field: 'org_id',
|
|
289
|
+
action: 'updateData'
|
|
290
|
+
}, {
|
|
291
|
+
field: 'org_id',
|
|
292
|
+
action: 'clear'
|
|
293
|
+
}]
|
|
240
294
|
}];
|
|
241
295
|
var initialValues = getFieldsDefaultValues(fields);
|
|
242
296
|
// console.log(initialValues);
|
|
@@ -251,9 +305,12 @@ export default (function () {
|
|
|
251
305
|
children: /*#__PURE__*/_jsx(ProForm, {
|
|
252
306
|
initialValues: initialValues
|
|
253
307
|
// size="small"
|
|
308
|
+
,
|
|
309
|
+
form: form
|
|
254
310
|
// readonly
|
|
255
311
|
,
|
|
256
312
|
onFinish: function onFinish(values) {
|
|
313
|
+
resetFormTouched(values, form);
|
|
257
314
|
console.log(values);
|
|
258
315
|
},
|
|
259
316
|
children: /*#__PURE__*/_jsx(BaseForm, {
|
|
@@ -22,7 +22,7 @@ import classNames from 'classnames';
|
|
|
22
22
|
import dayjs from 'dayjs';
|
|
23
23
|
import { ProFormDateRangePickerV2 } from "../components/ProFormDateRangePickerV2";
|
|
24
24
|
import { ProFormDigitRangeV2 } from "../components/ProFormDigitRangeV2";
|
|
25
|
-
import {
|
|
25
|
+
import { Core } from "../core/core";
|
|
26
26
|
import { getFieldsDefaultValues } from "./handlerData";
|
|
27
27
|
import { createElement as _createElement } from "react";
|
|
28
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -167,7 +167,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
|
|
|
167
167
|
className: classNames('base-form-field-multiple-group', {
|
|
168
168
|
compact: inlineItem.compact
|
|
169
169
|
}),
|
|
170
|
-
children: /*#__PURE__*/_jsx(
|
|
170
|
+
children: /*#__PURE__*/_jsx(Core, _objectSpread(_objectSpread({}, outConfig.rawAllProps), {}, {
|
|
171
171
|
itemWidth: "".concat(100 / ((_inlineItem$subItems$ = (_inlineItem$subItems = inlineItem.subItems) === null || _inlineItem$subItems === void 0 ? void 0 : _inlineItem$subItems.length) !== null && _inlineItem$subItems$ !== void 0 ? _inlineItem$subItems$ : 1), "%"),
|
|
172
172
|
fields: inlineItem.subItems,
|
|
173
173
|
itemMarginBottom: 0
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { FormInstance } from 'antd';
|
|
2
|
+
/**
|
|
3
|
+
* @desc 重置表单的 touched 状态
|
|
4
|
+
* @example 解决场景:表单提交后,某些字段依赖其他字段变化触发清空,导致表单项的 touched 状态异常,从而影响表单提交后自动清空值。
|
|
5
|
+
* - 使用该函数可以在表单提交后,重置所有字段的 touched 状态,确保表单能够正确显示。
|
|
6
|
+
* @example 使用示例:
|
|
7
|
+
```tsx
|
|
8
|
+
const fields: GetProps<typeof BaseForm>['fields'] = [
|
|
9
|
+
{
|
|
10
|
+
valueType: 'select',
|
|
11
|
+
field: 'org_id',
|
|
12
|
+
label: '部门',
|
|
13
|
+
options: [
|
|
14
|
+
{ label: '1', value: '1' },
|
|
15
|
+
{ label: '2', value: '2' },
|
|
16
|
+
{ label: '3', value: '3' },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
valueType: 'select',
|
|
21
|
+
field: 'job_id',
|
|
22
|
+
label: '岗位',
|
|
23
|
+
options: [
|
|
24
|
+
{ label: '1', value: '1' },
|
|
25
|
+
{ label: '2', value: '2' },
|
|
26
|
+
{ label: '3', value: '3' },
|
|
27
|
+
],
|
|
28
|
+
dependenciesV2: [
|
|
29
|
+
{
|
|
30
|
+
field: 'org_id',
|
|
31
|
+
action: 'show',
|
|
32
|
+
op: 'notEmpty',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
field: 'org_id',
|
|
36
|
+
action: 'updateData',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
field: 'org_id',
|
|
40
|
+
action: 'clear',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
```
|
|
46
|
+
*/
|
|
47
|
+
export declare const resetFormTouched: (data: Record<string, any>, form: FormInstance) => void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { crush } from 'radash';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @desc 重置表单的 touched 状态
|
|
5
|
+
* @example 解决场景:表单提交后,某些字段依赖其他字段变化触发清空,导致表单项的 touched 状态异常,从而影响表单提交后自动清空值。
|
|
6
|
+
* - 使用该函数可以在表单提交后,重置所有字段的 touched 状态,确保表单能够正确显示。
|
|
7
|
+
* @example 使用示例:
|
|
8
|
+
```tsx
|
|
9
|
+
const fields: GetProps<typeof BaseForm>['fields'] = [
|
|
10
|
+
{
|
|
11
|
+
valueType: 'select',
|
|
12
|
+
field: 'org_id',
|
|
13
|
+
label: '部门',
|
|
14
|
+
options: [
|
|
15
|
+
{ label: '1', value: '1' },
|
|
16
|
+
{ label: '2', value: '2' },
|
|
17
|
+
{ label: '3', value: '3' },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
valueType: 'select',
|
|
22
|
+
field: 'job_id',
|
|
23
|
+
label: '岗位',
|
|
24
|
+
options: [
|
|
25
|
+
{ label: '1', value: '1' },
|
|
26
|
+
{ label: '2', value: '2' },
|
|
27
|
+
{ label: '3', value: '3' },
|
|
28
|
+
],
|
|
29
|
+
dependenciesV2: [
|
|
30
|
+
{
|
|
31
|
+
field: 'org_id',
|
|
32
|
+
action: 'show',
|
|
33
|
+
op: 'notEmpty',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
field: 'org_id',
|
|
37
|
+
action: 'updateData',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
field: 'org_id',
|
|
41
|
+
action: 'clear',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
```
|
|
47
|
+
*/
|
|
48
|
+
export var resetFormTouched = function resetFormTouched(data, form) {
|
|
49
|
+
var keys = Object.keys(crush(data));
|
|
50
|
+
form.setFields(keys.map(function (key) {
|
|
51
|
+
return {
|
|
52
|
+
name: key.split('.'),
|
|
53
|
+
touched: false
|
|
54
|
+
};
|
|
55
|
+
}));
|
|
56
|
+
};
|