@para-ui/core 5.0.2 → 5.0.3-beta.8
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/FieldForm/component.json +22 -1
- package/FormItemGroup/component.json +72 -0
- package/Menu/component.json +9 -2
- package/es/Checkbox/index.js +26 -24
- package/es/CheckboxGroup/index.css +1 -1
- package/es/CheckboxGroup/style/index.css +1 -1
- package/es/ExpressionInput/Popup.js +11 -4
- package/es/FieldForm/ErrorList.js +9 -8
- package/es/FieldForm/FieldFormItem/ItemHolder.d.ts +2 -0
- package/es/FieldForm/FieldFormItem/ItemHolder.js +78 -68
- package/es/FieldForm/FieldFormItem/index.d.ts +3 -0
- package/es/FieldForm/FieldFormItem/index.js +131 -120
- package/es/FieldForm/Form.d.ts +3 -1
- package/es/FieldForm/Form.js +54 -50
- package/es/FieldForm/compactControlMarker.d.ts +18 -0
- package/es/FieldForm/compactControlMarker.js +5 -0
- package/es/FieldForm/component.json +22 -1
- package/es/FieldForm/context.d.ts +3 -1
- package/es/FieldForm/context.js +6 -5
- package/es/FieldForm/index.css +1 -1
- package/es/FieldForm/index.d.ts +2 -0
- package/es/FieldForm/index.js +13 -9
- package/es/FieldForm/interface.d.ts +9 -0
- package/es/FieldForm/style/index.css +1 -1
- package/es/FieldForm/util.d.ts +14 -0
- package/es/FieldForm/util.js +41 -17
- package/es/FormItemGroup/component.json +72 -0
- package/es/FormItemGroup/index.css +1 -0
- package/es/FormItemGroup/index.d.ts +14 -0
- package/es/FormItemGroup/index.js +27 -0
- package/es/FormItemGroup/style/css.js +1 -0
- package/es/FormItemGroup/style/index.css +1 -0
- package/es/FormItemGroup/style/index.js +1 -0
- package/es/HelperText/index.js +15 -13
- package/es/Menu/component.json +9 -2
- package/es/Menu/index.css +1 -1
- package/es/Menu/interface.d.ts +2 -0
- package/es/Menu/style/index.css +1 -1
- package/es/Menu/verticalMenuList.js +378 -361
- package/es/RadioGroup/index.css +1 -1
- package/es/RadioGroup/style/index.css +1 -1
- package/es/RangeInput/index.js +60 -60
- package/es/Switch/index.js +30 -28
- package/es/Tag/TagGroup.js +29 -32
- package/es/Tag/index.js +5 -5
- package/es/index.d.ts +2 -0
- package/es/index.js +175 -169
- package/lib/Checkbox/index.js +1 -1
- package/lib/CheckboxGroup/index.css +1 -1
- package/lib/CheckboxGroup/style/index.css +1 -1
- package/lib/ExpressionInput/Popup.js +1 -1
- package/lib/FieldForm/ErrorList.js +1 -1
- package/lib/FieldForm/FieldFormItem/ItemHolder.d.ts +2 -0
- package/lib/FieldForm/FieldFormItem/ItemHolder.js +1 -1
- package/lib/FieldForm/FieldFormItem/index.d.ts +3 -0
- package/lib/FieldForm/FieldFormItem/index.js +1 -1
- package/lib/FieldForm/Form.d.ts +3 -1
- package/lib/FieldForm/Form.js +1 -1
- package/lib/FieldForm/compactControlMarker.d.ts +18 -0
- package/lib/FieldForm/compactControlMarker.js +2 -0
- package/lib/FieldForm/component.json +22 -1
- package/lib/FieldForm/context.d.ts +3 -1
- package/lib/FieldForm/context.js +1 -1
- package/lib/FieldForm/index.css +1 -1
- package/lib/FieldForm/index.d.ts +2 -0
- package/lib/FieldForm/index.js +1 -1
- package/lib/FieldForm/interface.d.ts +9 -0
- package/lib/FieldForm/style/index.css +1 -1
- package/lib/FieldForm/util.d.ts +14 -0
- package/lib/FieldForm/util.js +1 -1
- package/lib/FormItemGroup/component.json +72 -0
- package/lib/FormItemGroup/index.css +1 -0
- package/lib/FormItemGroup/index.d.ts +14 -0
- package/lib/FormItemGroup/index.js +2 -0
- package/lib/FormItemGroup/style/css.js +1 -0
- package/lib/FormItemGroup/style/index.css +1 -0
- package/lib/FormItemGroup/style/index.js +1 -0
- package/lib/HelperText/index.js +1 -1
- package/lib/Menu/component.json +9 -2
- package/lib/Menu/index.css +1 -1
- package/lib/Menu/interface.d.ts +2 -0
- package/lib/Menu/style/index.css +1 -1
- package/lib/Menu/verticalMenuList.js +1 -1
- package/lib/RadioGroup/index.css +1 -1
- package/lib/RadioGroup/style/index.css +1 -1
- package/lib/RangeInput/index.js +1 -1
- package/lib/Switch/index.js +1 -1
- package/lib/Tag/TagGroup.js +1 -1
- package/lib/Tag/index.js +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -1
- package/package.json +14 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useContext as
|
|
3
|
-
import { FieldContext as
|
|
4
|
-
import
|
|
5
|
-
import { supportRef as
|
|
6
|
-
import
|
|
7
|
-
import { FormContext as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { getStatus as
|
|
13
|
-
import
|
|
1
|
+
import { j as u } from "../../_virtual/jsx-runtime.js";
|
|
2
|
+
import { useContext as y, useMemo as T, useRef as le, isValidElement as W, Children as $, cloneElement as j } from "react";
|
|
3
|
+
import { FieldContext as ce, ListContext as fe, Field as ge } from "rc-field-form";
|
|
4
|
+
import ue from "rc-util/lib/hooks/useState";
|
|
5
|
+
import { supportRef as pe } from "rc-util/lib/ref";
|
|
6
|
+
import he from "./MemoInput.js";
|
|
7
|
+
import { FormContext as ye, NoStyleItemContext as be } from "../context.js";
|
|
8
|
+
import Ce from "../hooks/useChildren.js";
|
|
9
|
+
import Ie from "../hooks/useFormItemStatus.js";
|
|
10
|
+
import Se from "../hooks/useFrameState.js";
|
|
11
|
+
import Pe from "../hooks/useItemRef.js";
|
|
12
|
+
import { isCompactControlChild as ve, getStatus as we, toArray as N, joinNamePath as Ee, getFieldId as Fe, isReactComponent as B } from "../util.js";
|
|
13
|
+
import Te from "./ItemHolder.js";
|
|
14
14
|
function G() {
|
|
15
15
|
return {
|
|
16
16
|
errors: [],
|
|
@@ -21,147 +21,158 @@ function G() {
|
|
|
21
21
|
validated: !1
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
24
|
+
const je = "__SPLIT__", Ne = { namePath: [], path: "" };
|
|
25
|
+
function xe(b) {
|
|
26
26
|
const {
|
|
27
|
-
noStyle:
|
|
27
|
+
noStyle: x,
|
|
28
28
|
shouldUpdate: J,
|
|
29
|
-
dependencies:
|
|
30
|
-
messageVariables:
|
|
31
|
-
trigger:
|
|
32
|
-
validateTrigger:
|
|
33
|
-
children:
|
|
34
|
-
required:
|
|
35
|
-
hidden:
|
|
36
|
-
rules:
|
|
29
|
+
dependencies: R,
|
|
30
|
+
messageVariables: _,
|
|
31
|
+
trigger: q = "onChange",
|
|
32
|
+
validateTrigger: z,
|
|
33
|
+
children: Q,
|
|
34
|
+
required: C,
|
|
35
|
+
hidden: X,
|
|
36
|
+
rules: Z,
|
|
37
37
|
name: l,
|
|
38
|
-
label:
|
|
39
|
-
disabled:
|
|
38
|
+
label: A,
|
|
39
|
+
disabled: I,
|
|
40
40
|
helperText: S,
|
|
41
|
-
hasFeedback:
|
|
42
|
-
validateStatus:
|
|
43
|
-
size:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
hasFeedback: L,
|
|
42
|
+
validateStatus: V,
|
|
43
|
+
size: P,
|
|
44
|
+
spacing: v
|
|
45
|
+
} = b, { name: ee, disabled: w, size: E } = y(ye), t = Ce(Q), re = T(
|
|
46
|
+
() => v === void 0 && ve(t) ? "compact" : void 0,
|
|
47
|
+
[v, t]
|
|
48
|
+
), K = typeof t == "function", M = y(be), { validateTrigger: te } = y(ce), O = z !== void 0 ? z : te, F = l != null, ne = y(fe), k = le(), [D, ie] = Se({}), [a, oe] = ue(() => G()), se = (e) => {
|
|
49
|
+
const o = ne?.getKey(e.name);
|
|
50
|
+
if (oe(e.destroy ? G() : e, !0), x && S !== !1 && M) {
|
|
51
|
+
let n = e.name;
|
|
52
|
+
if (e.destroy)
|
|
53
|
+
n = k.current || n;
|
|
54
|
+
else if (o !== void 0) {
|
|
55
|
+
const [s, r] = o;
|
|
56
|
+
n = [s, ...r], k.current = n;
|
|
53
57
|
}
|
|
54
|
-
|
|
58
|
+
M(e, n);
|
|
55
59
|
}
|
|
56
|
-
},
|
|
57
|
-
|
|
60
|
+
}, ae = (e, o) => {
|
|
61
|
+
ie((n) => {
|
|
58
62
|
const s = {
|
|
59
|
-
...
|
|
60
|
-
},
|
|
61
|
-
return
|
|
63
|
+
...n
|
|
64
|
+
}, i = [...e.name.slice(0, -1), ...o].join(je);
|
|
65
|
+
return e.destroy ? delete s[i] : s[i] = e, s;
|
|
62
66
|
});
|
|
63
|
-
}, [
|
|
64
|
-
const
|
|
65
|
-
return Object.values(
|
|
66
|
-
|
|
67
|
-
}), [
|
|
68
|
-
}, [
|
|
69
|
-
() =>
|
|
70
|
-
[a,
|
|
71
|
-
),
|
|
67
|
+
}, [p, Y] = T(() => {
|
|
68
|
+
const e = [...a.errors], o = [...a.warnings];
|
|
69
|
+
return Object.values(D).forEach((n) => {
|
|
70
|
+
e.push(...n.errors || []), o.push(...n.warnings || []);
|
|
71
|
+
}), [e, o];
|
|
72
|
+
}, [D, a.errors, a.warnings]), c = T(
|
|
73
|
+
() => we(a.errors, a.warnings, a, "", !!L, V),
|
|
74
|
+
[a, L, V]
|
|
75
|
+
), H = (e, o, n, s, r = Ne) => x && !X ? /* @__PURE__ */ u.jsx(u.Fragment, { children: $.map(e, (i) => B(i) ? j(i, {
|
|
72
76
|
...s,
|
|
73
77
|
name: l,
|
|
74
|
-
disabled:
|
|
75
|
-
error:
|
|
76
|
-
size:
|
|
77
|
-
...
|
|
78
|
-
}) :
|
|
79
|
-
|
|
78
|
+
disabled: I ?? w,
|
|
79
|
+
error: c === "error" || c === "warning",
|
|
80
|
+
size: P ?? E,
|
|
81
|
+
...i.props
|
|
82
|
+
}) : i) }) : /* @__PURE__ */ u.jsx(
|
|
83
|
+
Te,
|
|
80
84
|
{
|
|
81
|
-
...
|
|
82
|
-
fieldId:
|
|
83
|
-
required:
|
|
84
|
-
errors:
|
|
85
|
-
warnings:
|
|
86
|
-
status:
|
|
85
|
+
...b,
|
|
86
|
+
fieldId: o,
|
|
87
|
+
required: C ?? n,
|
|
88
|
+
errors: p,
|
|
89
|
+
warnings: Y,
|
|
90
|
+
status: c,
|
|
87
91
|
meta: a,
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
identityMeta: r,
|
|
93
|
+
onSubItemMetaChange: ae,
|
|
94
|
+
spacing: v ?? re,
|
|
95
|
+
children: $.map(e, (i) => B(i) ? j(i, {
|
|
90
96
|
...s,
|
|
91
97
|
name: l,
|
|
92
|
-
disabled:
|
|
93
|
-
error:
|
|
94
|
-
size:
|
|
95
|
-
...
|
|
96
|
-
}) :
|
|
98
|
+
disabled: I ?? w,
|
|
99
|
+
error: c === "error" || c === "warning",
|
|
100
|
+
size: P ?? E,
|
|
101
|
+
...i.props
|
|
102
|
+
}) : i)
|
|
97
103
|
}
|
|
98
104
|
);
|
|
99
|
-
if (!F && !
|
|
100
|
-
return
|
|
101
|
-
let
|
|
102
|
-
typeof
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
if (!F && !K && !R)
|
|
106
|
+
return H(t);
|
|
107
|
+
let g = {};
|
|
108
|
+
typeof A == "string" ? g.label = A : l && (g.label = String(l)), _ && (g = { ...g, ..._ });
|
|
109
|
+
const de = Pe(), me = ({
|
|
110
|
+
control: e,
|
|
111
|
+
fieldId: o,
|
|
112
|
+
isRequired: n,
|
|
113
|
+
mergedName: s
|
|
114
|
+
}) => {
|
|
115
|
+
if (!W(t)) return null;
|
|
116
|
+
const r = {
|
|
117
|
+
...t.props,
|
|
118
|
+
...e,
|
|
119
|
+
disabled: I ?? w,
|
|
120
|
+
error: c === "error" || c === "warning",
|
|
121
|
+
size: t.props?.size ?? P ?? E
|
|
111
122
|
};
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
(S ||
|
|
123
|
+
if (r.fieldId || (r["data-field-id"] = o), S || p.length > 0 || Y.length > 0) {
|
|
124
|
+
const d = [];
|
|
125
|
+
(S || p.length > 0) && d.push(`${o}_help`), r["aria-describedby"] = d.join(" ");
|
|
115
126
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
p.length > 0 && (r["aria-invalid"] = "true"), n && (r["aria-required"] = "true"), pe(t) && (r.ref = de(s, t)), (/* @__PURE__ */ new Set([...N(q), ...N(O)])).forEach((d) => {
|
|
128
|
+
r[d] = (...m) => {
|
|
129
|
+
e[d]?.(...m), t.props[d]?.(...m);
|
|
119
130
|
};
|
|
120
131
|
});
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
const h = [
|
|
133
|
+
r["aria-required"],
|
|
134
|
+
r["aria-invalid"],
|
|
135
|
+
r["aria-describedby"]
|
|
125
136
|
];
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
|
|
137
|
+
return /* @__PURE__ */ u.jsx(
|
|
138
|
+
he,
|
|
128
139
|
{
|
|
129
|
-
control:
|
|
130
|
-
update:
|
|
131
|
-
childProps:
|
|
132
|
-
children:
|
|
140
|
+
control: e,
|
|
141
|
+
update: t,
|
|
142
|
+
childProps: h,
|
|
143
|
+
children: j(t, r)
|
|
133
144
|
}
|
|
134
145
|
);
|
|
135
146
|
};
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
|
|
147
|
+
return /* @__PURE__ */ u.jsx(
|
|
148
|
+
ge,
|
|
138
149
|
{
|
|
139
|
-
...
|
|
140
|
-
messageVariables:
|
|
141
|
-
trigger:
|
|
142
|
-
validateTrigger:
|
|
143
|
-
onMetaChange:
|
|
144
|
-
children: (
|
|
145
|
-
const s =
|
|
146
|
-
if (
|
|
150
|
+
...b,
|
|
151
|
+
messageVariables: g,
|
|
152
|
+
trigger: q,
|
|
153
|
+
validateTrigger: O,
|
|
154
|
+
onMetaChange: se,
|
|
155
|
+
children: (e, o, n) => {
|
|
156
|
+
const s = N(l).length && o ? o.name : [], r = { namePath: s, path: Ee(s) }, i = Fe(s, ee), h = C !== void 0 ? C : !!Z?.some((f) => {
|
|
157
|
+
if (f && typeof f == "object" && f.required && !f.warningOnly)
|
|
147
158
|
return !0;
|
|
148
|
-
if (typeof
|
|
149
|
-
const
|
|
150
|
-
return
|
|
159
|
+
if (typeof f == "function") {
|
|
160
|
+
const U = f(n);
|
|
161
|
+
return U?.required && !U?.warningOnly;
|
|
151
162
|
}
|
|
152
163
|
return !1;
|
|
153
|
-
}),
|
|
154
|
-
...
|
|
164
|
+
}), d = {
|
|
165
|
+
...e
|
|
155
166
|
};
|
|
156
|
-
let
|
|
157
|
-
return Array.isArray(
|
|
167
|
+
let m = null;
|
|
168
|
+
return Array.isArray(t) && F ? m = t : W(t) ? m = me({ control: d, fieldId: i, isRequired: h, mergedName: s }) : K && (J || R) && !F ? m = t(n) : m = t, H(m, i, h, d, r);
|
|
158
169
|
}
|
|
159
170
|
}
|
|
160
171
|
);
|
|
161
172
|
}
|
|
162
|
-
const
|
|
163
|
-
|
|
173
|
+
const Re = xe;
|
|
174
|
+
Re.useStatus = Ie;
|
|
164
175
|
export {
|
|
165
|
-
|
|
176
|
+
Re as default
|
|
166
177
|
};
|
|
167
178
|
//# sourceMappingURL=index.js.map
|
package/es/FieldForm/Form.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PropsWithChildren, RefAttributes, ReactElement, FC, ReactNode } from 'r
|
|
|
2
2
|
import { useWatch } from 'rc-field-form';
|
|
3
3
|
import { FormProps as RcFormProps } from 'rc-field-form/lib/Form';
|
|
4
4
|
import { FormRef } from 'rc-field-form/lib/interface';
|
|
5
|
-
import { FormLabelAlign } from './interface';
|
|
5
|
+
import { FormLabelAlign, ItemDecorator } from './interface';
|
|
6
6
|
import { FormInstance, default as useForm } from './hooks/useForm';
|
|
7
7
|
import { FeedbackIcons } from './FieldFormItem';
|
|
8
8
|
export type RequiredMark = boolean | 'optional' | ((labelNode: ReactNode, info: {
|
|
@@ -22,6 +22,8 @@ export interface FormProps<Values = unknown> extends Omit<RcFormProps<Values>, '
|
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
requiredMark?: RequiredMark;
|
|
24
24
|
size?: 'small' | 'medium' | 'large';
|
|
25
|
+
spacing?: 'normal' | 'compact';
|
|
26
|
+
itemDecorator?: ItemDecorator;
|
|
25
27
|
}
|
|
26
28
|
declare const FieldForm: (<Values = unknown>(props: PropsWithChildren<FormProps<Values>> & RefAttributes<FormRef<Values>>) => ReactElement) & Pick<FC, "displayName">;
|
|
27
29
|
export { useForm, useWatch, type FormInstance };
|
package/es/FieldForm/Form.js
CHANGED
|
@@ -1,92 +1,96 @@
|
|
|
1
1
|
import { j as i } from "../_virtual/jsx-runtime.js";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useWatch as
|
|
6
|
-
import { $prefixCls as
|
|
7
|
-
import
|
|
8
|
-
import { FormProvider as
|
|
9
|
-
import { defaultValidateMessages as
|
|
10
|
-
import
|
|
11
|
-
const n = `${
|
|
2
|
+
import { forwardRef as T, useState as q, useContext as w, useMemo as W, useRef as z, useImperativeHandle as V, useEffect as D } from "react";
|
|
3
|
+
import G from "../_virtual/index.js";
|
|
4
|
+
import H from "rc-field-form";
|
|
5
|
+
import { useWatch as me } from "rc-field-form";
|
|
6
|
+
import { $prefixCls as k } from "../GlobalContext/constant.js";
|
|
7
|
+
import B from "./hooks/useForm.js";
|
|
8
|
+
import { FormProvider as J, FormContext as K } from "./context.js";
|
|
9
|
+
import { defaultValidateMessages as O } from "./lang/index.js";
|
|
10
|
+
import Q from "../GlobalContext/index.js";
|
|
11
|
+
const n = `${k}-field-form`, U = (v, E) => {
|
|
12
12
|
const {
|
|
13
|
-
className:
|
|
13
|
+
className: R,
|
|
14
14
|
disabled: m,
|
|
15
|
-
form:
|
|
15
|
+
form: g,
|
|
16
16
|
colon: c,
|
|
17
17
|
labelAlign: f,
|
|
18
18
|
labelWidth: r,
|
|
19
|
-
labelWrap:
|
|
19
|
+
labelWrap: M,
|
|
20
20
|
layout: d = "vertical",
|
|
21
|
-
onFinishFailed:
|
|
21
|
+
onFinishFailed: C,
|
|
22
22
|
name: t,
|
|
23
|
-
style:
|
|
23
|
+
style: L,
|
|
24
24
|
size: u,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
spacing: p = "normal",
|
|
26
|
+
itemDecorator: x,
|
|
27
|
+
...j
|
|
28
|
+
} = v, [l, y] = q(0), { language: h } = w(Q), I = W(
|
|
29
|
+
() => O[h || "zh"],
|
|
30
|
+
[h]
|
|
31
|
+
), [o] = B(g), { __INTERNAL__: F } = o;
|
|
32
|
+
F.name = t;
|
|
33
|
+
const a = z(null);
|
|
34
|
+
V(E, () => ({
|
|
33
35
|
...o,
|
|
34
36
|
nativeElement: a.current?.nativeElement
|
|
35
37
|
}));
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
},
|
|
38
|
+
const N = (e) => {
|
|
39
|
+
C?.(e);
|
|
40
|
+
}, _ = (e) => {
|
|
39
41
|
if (!e) return;
|
|
40
|
-
const
|
|
42
|
+
const A = e.querySelectorAll(`.${n}-item`);
|
|
41
43
|
let s = 0;
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
s = Math.max(s,
|
|
44
|
+
A?.forEach((P) => {
|
|
45
|
+
const b = P.querySelector("label");
|
|
46
|
+
if (b) {
|
|
47
|
+
const S = b.offsetWidth;
|
|
48
|
+
s = Math.max(s, S);
|
|
47
49
|
}
|
|
48
|
-
}),
|
|
50
|
+
}), y(s);
|
|
49
51
|
};
|
|
50
|
-
|
|
52
|
+
D(() => {
|
|
51
53
|
const e = setTimeout(() => {
|
|
52
|
-
|
|
54
|
+
_(a.current?.nativeElement);
|
|
53
55
|
}, 0);
|
|
54
56
|
return () => clearTimeout(e);
|
|
55
57
|
}, []);
|
|
56
|
-
const
|
|
58
|
+
const $ = W(
|
|
57
59
|
() => ({
|
|
58
60
|
name: t,
|
|
59
61
|
labelAlign: f,
|
|
60
|
-
labelWrap: r ?
|
|
62
|
+
labelWrap: r ? M : !1,
|
|
61
63
|
labelWidth: r || l,
|
|
62
64
|
labelMaxWidth: l,
|
|
63
65
|
layout: d,
|
|
64
66
|
colon: c,
|
|
65
|
-
itemRef:
|
|
67
|
+
itemRef: F.itemRef,
|
|
66
68
|
form: o,
|
|
67
69
|
prefixCls: n,
|
|
68
70
|
disabled: m,
|
|
69
|
-
size: u
|
|
71
|
+
size: u,
|
|
72
|
+
spacing: p,
|
|
73
|
+
itemDecorator: x
|
|
70
74
|
}),
|
|
71
|
-
[t, f, d, c, o, m, l, r, u]
|
|
75
|
+
[t, f, d, c, o, m, l, r, u, p, x]
|
|
72
76
|
);
|
|
73
|
-
return /* @__PURE__ */ i.jsx(
|
|
74
|
-
|
|
77
|
+
return /* @__PURE__ */ i.jsx(J, { validateMessages: I, children: /* @__PURE__ */ i.jsx(K.Provider, { value: $, children: /* @__PURE__ */ i.jsx(
|
|
78
|
+
H,
|
|
75
79
|
{
|
|
76
80
|
id: t,
|
|
77
|
-
...
|
|
81
|
+
...j,
|
|
78
82
|
name: t,
|
|
79
|
-
onFinishFailed:
|
|
83
|
+
onFinishFailed: N,
|
|
80
84
|
form: o,
|
|
81
85
|
ref: a,
|
|
82
|
-
className:
|
|
83
|
-
style: { ...
|
|
86
|
+
className: G(R, n),
|
|
87
|
+
style: { ...L }
|
|
84
88
|
}
|
|
85
89
|
) }) });
|
|
86
|
-
},
|
|
90
|
+
}, se = T(U);
|
|
87
91
|
export {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
se as default,
|
|
93
|
+
B as useForm,
|
|
94
|
+
me as useWatch
|
|
91
95
|
};
|
|
92
96
|
//# sourceMappingURL=Form.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Switch/Checkbox 类矮控件的 compact 间距自动识别标记约定。
|
|
3
|
+
*
|
|
4
|
+
* `FieldForm.Item` 在未显式指定 `spacing` 时,会检查唯一直接子节点是否为矮控件,
|
|
5
|
+
* 自动落 compact 档(见 `util.ts` 的 `isCompactControlChild`)。原生 `Switch`/`Checkbox`
|
|
6
|
+
* 靠类型引用直接比对即可命中;但消费方常见做法是自己再包一层组件(如加 label 布局),
|
|
7
|
+
* 包完之后子节点的类型引用就不再等于 `@para-ui/core` 原生组件,直接比对会失效。
|
|
8
|
+
*
|
|
9
|
+
* 为此原生 `Switch`/`Checkbox` 会在自身函数上挂这个标记,消费方若对它们做二次封装,
|
|
10
|
+
* 只需把标记原样透传到自己的包装组件上(`WrapperComponent[PARA_UI_COMPACT_CONTROL_MARKER] = true`),
|
|
11
|
+
* 包装组件即可继续被识别为矮控件——不需要 `@para-ui/core` 反过来认识具体消费方的包装组件。
|
|
12
|
+
*
|
|
13
|
+
* 独立成文件是为了避免循环依赖:这个标记同时被 `Switch`/`Checkbox`(声明"我是矮控件")
|
|
14
|
+
* 和 `FieldForm/util.ts`(读取标记做判断,同时也直接引用 Switch/Checkbox 做引用相等比对)
|
|
15
|
+
* 引用,若把标记定义放进 `FieldForm/util.ts` 会形成 `Switch → FieldForm/util.ts → Switch`
|
|
16
|
+
* 的循环引用。
|
|
17
|
+
*/
|
|
18
|
+
export declare const PARA_UI_COMPACT_CONTROL_MARKER = "__paraUiCompactControl__";
|
|
@@ -61,6 +61,20 @@
|
|
|
61
61
|
"children": {
|
|
62
62
|
"type": "ReactNode",
|
|
63
63
|
"description": "FieldForm 接收任意 ReactNode(包括 FieldForm.Item / Button type=submit / 自定义包装);**但每个 Item 的 child 必须是支持 value/onChange/error/disabled 的自定义组件**(TextField / Select / Checkbox / Switch / DatePicker / InputNumber 等);**不可用原生 input/textarea/select/button — 会触发 React non-boolean-attribute warning**(因 cloneElement 注入 error={false} 给原生 DOM 元素时,React 视 error 为 DOM attr → 报错);见 childrenContract.FormItem"
|
|
64
|
+
},
|
|
65
|
+
"itemDecorator": {
|
|
66
|
+
"type": "ItemDecorator",
|
|
67
|
+
"objectShape": {
|
|
68
|
+
"getItemClassName": {
|
|
69
|
+
"type": "(meta: ItemDecoratorMeta) => string | undefined | false",
|
|
70
|
+
"description": "按字段 namePath/path 返回要合并到该 FieldForm.Item 根节点的 className;返回 undefined/''/false 时不追加,不影响其他状态 class(is-error/is-success 等)"
|
|
71
|
+
},
|
|
72
|
+
"renderItemExtra": {
|
|
73
|
+
"type": "(meta: ItemDecoratorMeta) => ReactNode",
|
|
74
|
+
"description": "按字段 namePath/path 在该 FieldForm.Item 根节点内追加渲染内容(如 diff 命中原因说明);渲染在根节点内、内部间距容器之外,不影响 has-spacing/has-helper-text 的 20px 间距机制"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"description": "Form 级一次注册、所有子孙 FieldForm.Item 自动生效的字段装饰扩展点;meta.namePath 来自 rc-field-form 的 renderMeta.name(真实的、经过 List 等上下文处理后的最终路径),meta.path 是预拼接字符串(数组下标用方括号,如 'ubr.list[0].x');未传 name 的 Item 固定拿到 { namePath: [], path: '' };典型用法:`<FieldForm itemDecorator={{ getItemClassName: (meta) => isHit(meta.path) ? 'is-hit' : undefined, renderItemExtra: (meta) => isHit(meta.path) ? <span>命中原因</span> : null }}>`"
|
|
64
78
|
}
|
|
65
79
|
},
|
|
66
80
|
"childrenContract": {
|
|
@@ -137,7 +151,9 @@
|
|
|
137
151
|
"把'仅使用 FieldForm 本身'解读为'整个文件不能 import TextField/Button'(见 interpretivePriority.resolution)",
|
|
138
152
|
"字段过多不分组",
|
|
139
153
|
"忽略异步校验",
|
|
140
|
-
"在 mount 后修改 initialValues prop(应用 form.setFieldsValue;initialValues 仅 mount 时灌入)"
|
|
154
|
+
"在 mount 后修改 initialValues prop(应用 form.setFieldsValue;initialValues 仅 mount 时灌入)",
|
|
155
|
+
"在 itemDecorator.getItemClassName/renderItemExtra 回调体内调用 useContext/useXxx 等 Hook(回调运行在 ItemHolder 渲染过程中,不在业务组件自身的渲染调用栈里,会违反 Hooks 规则;应在业务组件顶层用 Hook 取数后,用 useMemo 包成闭包再传入 itemDecorator)",
|
|
156
|
+
"期望 itemDecorator 对 noStyle 的 FieldForm.Item 生效(noStyle 不渲染独立 wrapper 节点,没有可挂载 className/额外内容的位置)"
|
|
141
157
|
],
|
|
142
158
|
"events": {
|
|
143
159
|
"onFinish": {
|
|
@@ -187,6 +203,11 @@
|
|
|
187
203
|
"issue": "rules 中的 validator 函数签名必须返回 Promise(rc-field-form 约定),不是同步返回",
|
|
188
204
|
"wrong": "rules={[{ validator: (_, val) => val > 0 ? true : false }]} // 同步返回 boolean 不被识别",
|
|
189
205
|
"right": "rules={[{ validator: (_, val) => val > 0 ? Promise.resolve() : Promise.reject('必须大于 0') }]}"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"issue": "itemDecorator 的 getItemClassName/renderItemExtra 回调不能在函数体内调用 React Hook",
|
|
209
|
+
"wrong": "itemDecorator={{ getItemClassName: (meta) => { const hit = useFieldHighlight(meta.path); return hit ? 'is-hit' : undefined; } }} // 在回调体内调用 Hook,违反 Hooks 规则",
|
|
210
|
+
"right": "const highlightMap = useFieldHighlightMap();\nconst itemDecorator = useMemo(() => ({ getItemClassName: (meta) => (highlightMap[meta.path] ? 'is-hit' : undefined) }), [highlightMap]);\n<FieldForm itemDecorator={itemDecorator}>"
|
|
190
211
|
}
|
|
191
212
|
],
|
|
192
213
|
"mapping": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React, FC, ReactElement, Key, ReactNode } from 'react';
|
|
2
2
|
import { FormProviderProps as RcFormProviderProps } from 'rc-field-form/lib/FormContext';
|
|
3
3
|
import { Meta } from 'rc-field-form/lib/interface';
|
|
4
|
-
import { FormLabelAlign } from './interface';
|
|
4
|
+
import { FormLabelAlign, ItemDecorator } from './interface';
|
|
5
5
|
import { FormInstance, FormLayout } from './Form';
|
|
6
6
|
import { ValidateStatus } from './FieldFormItem';
|
|
7
7
|
export declare const FormProvider: FC<RcFormProviderProps>;
|
|
@@ -18,6 +18,8 @@ export interface FormContextProps {
|
|
|
18
18
|
prefixCls?: string;
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
size?: 'small' | 'medium' | 'large';
|
|
21
|
+
spacing: 'normal' | 'compact';
|
|
22
|
+
itemDecorator?: ItemDecorator;
|
|
21
23
|
}
|
|
22
24
|
export declare const FormContext: React.Context<FormContextProps>;
|
|
23
25
|
/** rc-field-form 在销毁字段时会传入带 destroy 标记的 meta(官方 Meta 类型未声明此字段) */
|
package/es/FieldForm/context.js
CHANGED
|
@@ -5,16 +5,17 @@ import i from "rc-util/lib/omit";
|
|
|
5
5
|
const x = (t) => {
|
|
6
6
|
const r = i(t, ["prefixCls"]);
|
|
7
7
|
return /* @__PURE__ */ e.jsx(m, { ...r });
|
|
8
|
-
},
|
|
8
|
+
}, a = o({
|
|
9
9
|
labelAlign: "left",
|
|
10
10
|
layout: "vertical",
|
|
11
|
+
spacing: "normal",
|
|
11
12
|
itemRef: () => () => {
|
|
12
13
|
}
|
|
13
|
-
}),
|
|
14
|
+
}), c = o(null), f = o({});
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
a as FormContext,
|
|
17
|
+
f as FormItemInputContext,
|
|
17
18
|
x as FormProvider,
|
|
18
|
-
|
|
19
|
+
c as NoStyleItemContext
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=context.js.map
|
package/es/FieldForm/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";.paraui-v4-field-form-item{vertical-align:top}.paraui-v4-field-form-item.is-horizontal{display:flex}.paraui-v4-field-form-item.is-horizontal .paraui-v4-field-form-label{
|
|
1
|
+
@charset "UTF-8";.paraui-v4-field-form-item{vertical-align:top}.paraui-v4-field-form-item.is-horizontal{display:flex}.paraui-v4-field-form-item.is-horizontal .paraui-v4-field-form-label{flex-shrink:0;padding:0;margin-right:8px;text-align:end}.paraui-v4-field-form-item.is-horizontal .paraui-v4-field-form-label.is-left{text-align:start}.paraui-v4-field-form-item.is-horizontal .paraui-v4-field-form-label.is-multiline .paraui-v4-field-form-label-comp{display:inline-block}.paraui-v4-field-form-item.is-horizontal .paraui-v4-field-form-label-comp{display:inline-flex;align-items:center;width:100%;max-width:100%;min-height:32px;margin:0}.paraui-v4-field-form-item.is-spacing-compact .paraui-v4-field-form-content.has-spacing{margin-bottom:16px}.paraui-v4-field-form-item.is-spacing-compact .paraui-v4-field-form-content.has-spacing.has-helper-text{margin-bottom:0}.paraui-v4-field-form-item.is-spacing-compact .paraui-v4-field-form-control-input{min-height:24px}.paraui-v4-field-form-item.is-spacing-compact .paraui-v4-helper-text{min-height:16px;line-height:16px}.paraui-v4-field-form-content{flex:1}.paraui-v4-field-form-content.has-spacing{margin-bottom:20px}.paraui-v4-field-form-content.has-spacing.has-helper-text{margin-bottom:0}.paraui-v4-field-form-control-input{display:flex;align-items:center;min-height:32px}.paraui-v4-field-form-control-input-content{width:100%}.paraui-v4-field-form-control-input-content .paraui-v4-radio-group>.radio-group-content .radio-item-box{margin-bottom:0}.paraui-v4-field-form-control-input-content .text-field-error-text:not(.paraui-v4-helper-text-force-visible),.paraui-v4-field-form-control-input-content .select-error-text:not(.paraui-v4-helper-text-force-visible){display:none}.paraui-v4-field-form-helper-text{line-height:20px;word-break:break-all}.paraui-v4-field-form-helper-text .is-warning>.paraui-v4-helper-text.paraui-v4-helper-text-error{color:#ff9326}
|
package/es/FieldForm/index.d.ts
CHANGED
|
@@ -19,3 +19,5 @@ declare const FieldForm: CompoundedComponent;
|
|
|
19
19
|
export type { ErrorListProps, FieldFormInstance, FieldFormItemProps, FieldFormListFieldData, FieldFormListOperation, FieldFormListProps, FieldFormProps, Rule, RuleObject, RuleRender };
|
|
20
20
|
export default FieldForm;
|
|
21
21
|
export type * from './interface';
|
|
22
|
+
export { joinNamePath } from './util';
|
|
23
|
+
export { PARA_UI_COMPACT_CONTROL_MARKER } from './compactControlMarker';
|
package/es/FieldForm/index.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { FormProvider as o } from "./context.js";
|
|
2
2
|
import m from "./Form.js";
|
|
3
3
|
import t from "./ErrorList.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import e from "./FieldFormItem/index.js";
|
|
5
|
+
import i from "./FormList.js";
|
|
6
6
|
import s from "./hooks/useFormInstance.js";
|
|
7
7
|
import './index.css';/* empty css */
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
8
|
+
import { joinNamePath as R } from "./util.js";
|
|
9
|
+
import { PARA_UI_COMPACT_CONTROL_MARKER as h } from "./compactControlMarker.js";
|
|
10
|
+
import p from "./hooks/useForm.js";
|
|
11
|
+
import { useWatch as F } from "rc-field-form";
|
|
10
12
|
const r = m;
|
|
11
|
-
r.Item =
|
|
12
|
-
r.List =
|
|
13
|
+
r.Item = e;
|
|
14
|
+
r.List = i;
|
|
13
15
|
r.ErrorList = t;
|
|
14
|
-
r.useForm =
|
|
16
|
+
r.useForm = p;
|
|
15
17
|
r.useFormInstance = s;
|
|
16
|
-
r.useWatch =
|
|
18
|
+
r.useWatch = F;
|
|
17
19
|
r.Provider = o;
|
|
18
20
|
export {
|
|
19
|
-
|
|
21
|
+
h as PARA_UI_COMPACT_CONTROL_MARKER,
|
|
22
|
+
r as default,
|
|
23
|
+
R as joinNamePath
|
|
20
24
|
};
|
|
21
25
|
//# sourceMappingURL=index.js.map
|