@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.
Files changed (92) hide show
  1. package/FieldForm/component.json +22 -1
  2. package/FormItemGroup/component.json +72 -0
  3. package/Menu/component.json +9 -2
  4. package/es/Checkbox/index.js +26 -24
  5. package/es/CheckboxGroup/index.css +1 -1
  6. package/es/CheckboxGroup/style/index.css +1 -1
  7. package/es/ExpressionInput/Popup.js +11 -4
  8. package/es/FieldForm/ErrorList.js +9 -8
  9. package/es/FieldForm/FieldFormItem/ItemHolder.d.ts +2 -0
  10. package/es/FieldForm/FieldFormItem/ItemHolder.js +78 -68
  11. package/es/FieldForm/FieldFormItem/index.d.ts +3 -0
  12. package/es/FieldForm/FieldFormItem/index.js +131 -120
  13. package/es/FieldForm/Form.d.ts +3 -1
  14. package/es/FieldForm/Form.js +54 -50
  15. package/es/FieldForm/compactControlMarker.d.ts +18 -0
  16. package/es/FieldForm/compactControlMarker.js +5 -0
  17. package/es/FieldForm/component.json +22 -1
  18. package/es/FieldForm/context.d.ts +3 -1
  19. package/es/FieldForm/context.js +6 -5
  20. package/es/FieldForm/index.css +1 -1
  21. package/es/FieldForm/index.d.ts +2 -0
  22. package/es/FieldForm/index.js +13 -9
  23. package/es/FieldForm/interface.d.ts +9 -0
  24. package/es/FieldForm/style/index.css +1 -1
  25. package/es/FieldForm/util.d.ts +14 -0
  26. package/es/FieldForm/util.js +41 -17
  27. package/es/FormItemGroup/component.json +72 -0
  28. package/es/FormItemGroup/index.css +1 -0
  29. package/es/FormItemGroup/index.d.ts +14 -0
  30. package/es/FormItemGroup/index.js +27 -0
  31. package/es/FormItemGroup/style/css.js +1 -0
  32. package/es/FormItemGroup/style/index.css +1 -0
  33. package/es/FormItemGroup/style/index.js +1 -0
  34. package/es/HelperText/index.js +15 -13
  35. package/es/Menu/component.json +9 -2
  36. package/es/Menu/index.css +1 -1
  37. package/es/Menu/interface.d.ts +2 -0
  38. package/es/Menu/style/index.css +1 -1
  39. package/es/Menu/verticalMenuList.js +378 -361
  40. package/es/RadioGroup/index.css +1 -1
  41. package/es/RadioGroup/style/index.css +1 -1
  42. package/es/RangeInput/index.js +60 -60
  43. package/es/Switch/index.js +30 -28
  44. package/es/Tag/TagGroup.js +29 -32
  45. package/es/Tag/index.js +5 -5
  46. package/es/index.d.ts +2 -0
  47. package/es/index.js +175 -169
  48. package/lib/Checkbox/index.js +1 -1
  49. package/lib/CheckboxGroup/index.css +1 -1
  50. package/lib/CheckboxGroup/style/index.css +1 -1
  51. package/lib/ExpressionInput/Popup.js +1 -1
  52. package/lib/FieldForm/ErrorList.js +1 -1
  53. package/lib/FieldForm/FieldFormItem/ItemHolder.d.ts +2 -0
  54. package/lib/FieldForm/FieldFormItem/ItemHolder.js +1 -1
  55. package/lib/FieldForm/FieldFormItem/index.d.ts +3 -0
  56. package/lib/FieldForm/FieldFormItem/index.js +1 -1
  57. package/lib/FieldForm/Form.d.ts +3 -1
  58. package/lib/FieldForm/Form.js +1 -1
  59. package/lib/FieldForm/compactControlMarker.d.ts +18 -0
  60. package/lib/FieldForm/compactControlMarker.js +2 -0
  61. package/lib/FieldForm/component.json +22 -1
  62. package/lib/FieldForm/context.d.ts +3 -1
  63. package/lib/FieldForm/context.js +1 -1
  64. package/lib/FieldForm/index.css +1 -1
  65. package/lib/FieldForm/index.d.ts +2 -0
  66. package/lib/FieldForm/index.js +1 -1
  67. package/lib/FieldForm/interface.d.ts +9 -0
  68. package/lib/FieldForm/style/index.css +1 -1
  69. package/lib/FieldForm/util.d.ts +14 -0
  70. package/lib/FieldForm/util.js +1 -1
  71. package/lib/FormItemGroup/component.json +72 -0
  72. package/lib/FormItemGroup/index.css +1 -0
  73. package/lib/FormItemGroup/index.d.ts +14 -0
  74. package/lib/FormItemGroup/index.js +2 -0
  75. package/lib/FormItemGroup/style/css.js +1 -0
  76. package/lib/FormItemGroup/style/index.css +1 -0
  77. package/lib/FormItemGroup/style/index.js +1 -0
  78. package/lib/HelperText/index.js +1 -1
  79. package/lib/Menu/component.json +9 -2
  80. package/lib/Menu/index.css +1 -1
  81. package/lib/Menu/interface.d.ts +2 -0
  82. package/lib/Menu/style/index.css +1 -1
  83. package/lib/Menu/verticalMenuList.js +1 -1
  84. package/lib/RadioGroup/index.css +1 -1
  85. package/lib/RadioGroup/style/index.css +1 -1
  86. package/lib/RangeInput/index.js +1 -1
  87. package/lib/Switch/index.js +1 -1
  88. package/lib/Tag/TagGroup.js +1 -1
  89. package/lib/Tag/index.js +1 -1
  90. package/lib/index.d.ts +2 -0
  91. package/lib/index.js +1 -1
  92. package/package.json +14 -1
@@ -1,16 +1,16 @@
1
- import { j as g } from "../../_virtual/jsx-runtime.js";
2
- import { useContext as h, useRef as ae, useMemo as U, isValidElement as W, Children as $, cloneElement as P } from "react";
3
- import { FieldContext as de, ListContext as le, Field as me } from "rc-field-form";
4
- import fe from "rc-util/lib/hooks/useState";
5
- import { supportRef as ue } from "rc-util/lib/ref";
6
- import ge from "./MemoInput.js";
7
- import { FormContext as ce, NoStyleItemContext as pe } from "../context.js";
8
- import he from "../hooks/useChildren.js";
9
- import ye from "../hooks/useFormItemStatus.js";
10
- import be from "../hooks/useFrameState.js";
11
- import Ce from "../hooks/useItemRef.js";
12
- import { getStatus as Se, toArray as j, getFieldId as Ie, isReactComponent as B } from "../util.js";
13
- import we from "./ItemHolder.js";
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 ve = "__SPLIT__";
25
- function Fe(y) {
24
+ const je = "__SPLIT__", Ne = { namePath: [], path: "" };
25
+ function xe(b) {
26
26
  const {
27
- noStyle: E,
27
+ noStyle: x,
28
28
  shouldUpdate: J,
29
- dependencies: x,
30
- messageVariables: R,
31
- trigger: N = "onChange",
32
- validateTrigger: T,
33
- children: M,
34
- required: b,
35
- hidden: Q,
36
- rules: X,
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: q,
39
- disabled: C,
38
+ label: A,
39
+ disabled: I,
40
40
  helperText: S,
41
- hasFeedback: z,
42
- validateStatus: L,
43
- size: I
44
- } = y, { name: Y, disabled: w, size: v } = h(ce), n = he(M), V = typeof n == "function", _ = h(pe), { validateTrigger: Z } = h(de), A = T !== void 0 ? T : Z, F = l != null, ee = h(le), K = ae(), [O, re] = be({}), [a, te] = fe(() => G()), ne = (r) => {
45
- const i = ee?.getKey(r.name);
46
- if (te(r.destroy ? G() : r, !0), E && S !== !1 && _) {
47
- let t = r.name;
48
- if (r.destroy)
49
- t = K.current || t;
50
- else if (i !== void 0) {
51
- const [s, e] = i;
52
- t = [s, ...e], K.current = t;
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
- _(r, t);
58
+ M(e, n);
55
59
  }
56
- }, ie = (r, i) => {
57
- re((t) => {
60
+ }, ae = (e, o) => {
61
+ ie((n) => {
58
62
  const s = {
59
- ...t
60
- }, f = [...r.name.slice(0, -1), ...i].join(ve);
61
- return r.destroy ? delete s[f] : s[f] = r, s;
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
- }, [c, k] = U(() => {
64
- const r = [...a.errors], i = [...a.warnings];
65
- return Object.values(O).forEach((t) => {
66
- r.push(...t.errors || []), i.push(...t.warnings || []);
67
- }), [r, i];
68
- }, [O, a.errors, a.warnings]), m = U(
69
- () => Se(a.errors, a.warnings, a, "", !!z, L),
70
- [a, z, L]
71
- ), D = (r, i, t, s) => E && !Q ? /* @__PURE__ */ g.jsx(g.Fragment, { children: $.map(r, (e) => B(e) ? P(e, {
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: C ?? w,
75
- error: m === "error" || m === "warning",
76
- size: I ?? v,
77
- ...e.props
78
- }) : e) }) : /* @__PURE__ */ g.jsx(
79
- we,
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
- ...y,
82
- fieldId: i,
83
- required: b ?? t,
84
- errors: c,
85
- warnings: k,
86
- status: m,
85
+ ...b,
86
+ fieldId: o,
87
+ required: C ?? n,
88
+ errors: p,
89
+ warnings: Y,
90
+ status: c,
87
91
  meta: a,
88
- onSubItemMetaChange: ie,
89
- children: $.map(r, (e) => B(e) ? P(e, {
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: C ?? w,
93
- error: m === "error" || m === "warning",
94
- size: I ?? v,
95
- ...e.props
96
- }) : e)
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 && !V && !x)
100
- return D(n);
101
- let u = {};
102
- typeof q == "string" ? u.label = q : l && (u.label = String(l)), R && (u = { ...u, ...R });
103
- const se = Ce(), oe = ({ control: r, fieldId: i, isRequired: t, mergedName: s }) => {
104
- if (!W(n)) return null;
105
- const e = {
106
- ...n.props,
107
- ...r,
108
- disabled: C ?? w,
109
- error: m === "error" || m === "warning",
110
- size: n.props?.size ?? I ?? v
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 (e.fieldId || (e["data-field-id"] = i), S || c.length > 0 || k.length > 0) {
113
- const o = [];
114
- (S || c.length > 0) && o.push(`${i}_help`), e["aria-describedby"] = o.join(" ");
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
- c.length > 0 && (e["aria-invalid"] = "true"), t && (e["aria-required"] = "true"), ue(n) && (e.ref = se(s, n)), (/* @__PURE__ */ new Set([...j(N), ...j(A)])).forEach((o) => {
117
- e[o] = (...d) => {
118
- r[o]?.(...d), n.props[o]?.(...d);
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 p = [
122
- e["aria-required"],
123
- e["aria-invalid"],
124
- e["aria-describedby"]
132
+ const h = [
133
+ r["aria-required"],
134
+ r["aria-invalid"],
135
+ r["aria-describedby"]
125
136
  ];
126
- return /* @__PURE__ */ g.jsx(
127
- ge,
137
+ return /* @__PURE__ */ u.jsx(
138
+ he,
128
139
  {
129
- control: r,
130
- update: n,
131
- childProps: p,
132
- children: P(n, e)
140
+ control: e,
141
+ update: t,
142
+ childProps: h,
143
+ children: j(t, r)
133
144
  }
134
145
  );
135
146
  };
136
- return /* @__PURE__ */ g.jsx(
137
- me,
147
+ return /* @__PURE__ */ u.jsx(
148
+ ge,
138
149
  {
139
- ...y,
140
- messageVariables: u,
141
- trigger: N,
142
- validateTrigger: A,
143
- onMetaChange: ne,
144
- children: (r, i, t) => {
145
- const s = j(l).length && i ? i.name : [], e = Ie(s, Y), f = b !== void 0 ? b : !!X?.some((d) => {
146
- if (d && typeof d == "object" && d.required && !d.warningOnly)
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 d == "function") {
149
- const H = d(t);
150
- return H?.required && !H?.warningOnly;
159
+ if (typeof f == "function") {
160
+ const U = f(n);
161
+ return U?.required && !U?.warningOnly;
151
162
  }
152
163
  return !1;
153
- }), p = {
154
- ...r
164
+ }), d = {
165
+ ...e
155
166
  };
156
- let o = null;
157
- return Array.isArray(n) && F ? o = n : W(n) ? o = oe({ control: p, fieldId: e, isRequired: f, mergedName: s }) : V && (J || x) && !F ? o = n(t) : o = n, D(o, e, f, p);
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 Pe = Fe;
163
- Pe.useStatus = ye;
173
+ const Re = xe;
174
+ Re.useStatus = Ie;
164
175
  export {
165
- Pe as default
176
+ Re as default
166
177
  };
167
178
  //# sourceMappingURL=index.js.map
@@ -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 };
@@ -1,92 +1,96 @@
1
1
  import { j as i } from "../_virtual/jsx-runtime.js";
2
- import { forwardRef as P, useState as S, useContext as T, useMemo as F, useRef as q, useImperativeHandle as w, useEffect as z } from "react";
3
- import V from "../_virtual/index.js";
4
- import G from "rc-field-form";
5
- import { useWatch as ie } from "rc-field-form";
6
- import { $prefixCls as H } from "../GlobalContext/constant.js";
7
- import k from "./hooks/useForm.js";
8
- import { FormProvider as B, FormContext as D } from "./context.js";
9
- import { defaultValidateMessages as J } from "./lang/index.js";
10
- import K from "../GlobalContext/index.js";
11
- const n = `${H}-field-form`, O = (b, W) => {
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: v,
13
+ className: R,
14
14
  disabled: m,
15
- form: E,
15
+ form: g,
16
16
  colon: c,
17
17
  labelAlign: f,
18
18
  labelWidth: r,
19
- labelWrap: R,
19
+ labelWrap: M,
20
20
  layout: d = "vertical",
21
- onFinishFailed: M,
21
+ onFinishFailed: C,
22
22
  name: t,
23
- style: g,
23
+ style: L,
24
24
  size: u,
25
- ...C
26
- } = b, [l, L] = S(0), { language: p } = T(K), j = F(
27
- () => J[p || "zh"],
28
- [p]
29
- ), [o] = k(E), { __INTERNAL__: x } = o;
30
- x.name = t;
31
- const a = q(null);
32
- w(W, () => ({
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 y = (e) => {
37
- M?.(e);
38
- }, I = (e) => {
38
+ const N = (e) => {
39
+ C?.(e);
40
+ }, _ = (e) => {
39
41
  if (!e) return;
40
- const _ = e.querySelectorAll(`.${n}-item`);
42
+ const A = e.querySelectorAll(`.${n}-item`);
41
43
  let s = 0;
42
- _?.forEach(($) => {
43
- const h = $.querySelector("label");
44
- if (h) {
45
- const A = h.offsetWidth;
46
- s = Math.max(s, A);
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
- }), L(s);
50
+ }), y(s);
49
51
  };
50
- z(() => {
52
+ D(() => {
51
53
  const e = setTimeout(() => {
52
- I(a.current?.nativeElement);
54
+ _(a.current?.nativeElement);
53
55
  }, 0);
54
56
  return () => clearTimeout(e);
55
57
  }, []);
56
- const N = F(
58
+ const $ = W(
57
59
  () => ({
58
60
  name: t,
59
61
  labelAlign: f,
60
- labelWrap: r ? R : !1,
62
+ labelWrap: r ? M : !1,
61
63
  labelWidth: r || l,
62
64
  labelMaxWidth: l,
63
65
  layout: d,
64
66
  colon: c,
65
- itemRef: x.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(B, { validateMessages: j, children: /* @__PURE__ */ i.jsx(D.Provider, { value: N, children: /* @__PURE__ */ i.jsx(
74
- G,
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
- ...C,
81
+ ...j,
78
82
  name: t,
79
- onFinishFailed: y,
83
+ onFinishFailed: N,
80
84
  form: o,
81
85
  ref: a,
82
- className: V(v, n),
83
- style: { ...g }
86
+ className: G(R, n),
87
+ style: { ...L }
84
88
  }
85
89
  ) }) });
86
- }, le = P(O);
90
+ }, se = T(U);
87
91
  export {
88
- le as default,
89
- k as useForm,
90
- ie as useWatch
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__";
@@ -0,0 +1,5 @@
1
+ const _ = "__paraUiCompactControl__";
2
+ export {
3
+ _ as PARA_UI_COMPACT_CONTROL_MARKER
4
+ };
5
+ //# sourceMappingURL=compactControlMarker.js.map
@@ -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 类型未声明此字段) */
@@ -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
- }, c = o({
8
+ }, a = o({
9
9
  labelAlign: "left",
10
10
  layout: "vertical",
11
+ spacing: "normal",
11
12
  itemRef: () => () => {
12
13
  }
13
- }), f = o(null), a = o({});
14
+ }), c = o(null), f = o({});
14
15
  export {
15
- c as FormContext,
16
- a as FormItemInputContext,
16
+ a as FormContext,
17
+ f as FormItemInputContext,
17
18
  x as FormProvider,
18
- f as NoStyleItemContext
19
+ c as NoStyleItemContext
19
20
  };
20
21
  //# sourceMappingURL=context.js.map
@@ -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{margin-right:8px;padding:0;flex-shrink:0;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{width:100%;display:inline-flex;align-items:center;margin:0;max-width:100%;min-height:32px}.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{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}
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}
@@ -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';
@@ -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 i from "./FieldFormItem/index.js";
5
- import e from "./FormList.js";
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 F from "./hooks/useForm.js";
9
- import { useWatch as p } from "rc-field-form";
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 = i;
12
- r.List = e;
13
+ r.Item = e;
14
+ r.List = i;
13
15
  r.ErrorList = t;
14
- r.useForm = F;
16
+ r.useForm = p;
15
17
  r.useFormInstance = s;
16
- r.useWatch = p;
18
+ r.useWatch = F;
17
19
  r.Provider = o;
18
20
  export {
19
- r as default
21
+ h as PARA_UI_COMPACT_CONTROL_MARKER,
22
+ r as default,
23
+ R as joinNamePath
20
24
  };
21
25
  //# sourceMappingURL=index.js.map