@iress-oss/ids-components 6.0.0-alpha.3 → 6.0.0-alpha.5

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.
@@ -1,13 +1,10 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as s } from "react";
3
- import { u as F, a, b as u, c as n } from "../../index.esm-B6vzbp0e.js";
4
- import { LongForm as i } from "./components/LongForm.js";
5
- import { ShortForm as f } from "./components/ShortForm.js";
6
- const c = ({ pattern: e, ...o }, m) => e === "long" ? /* @__PURE__ */ t(i, { ...o, ref: m }) : /* @__PURE__ */ t(f, { ...o, ref: m }), d = s(c), r = d;
7
- r.useFieldArray = F;
8
- r.useForm = a;
9
- r.useFormContext = u;
10
- r.useWatch = n;
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { forwardRef as i } from "react";
3
+ import { LongForm as n } from "./components/LongForm.js";
4
+ import { ShortForm as s } from "./components/ShortForm.js";
5
+ const t = ({ pattern: f, ...r }, o) => f === "long" ? /* @__PURE__ */ m(n, { ...r, ref: o }) : /* @__PURE__ */ m(s, { ...r, ref: o });
6
+ t.displayName = "IressForm";
7
+ const c = i(t);
11
8
  export {
12
- r as IressForm
9
+ c as IressForm
13
10
  };
@@ -1,17 +1,17 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { useContext as I, useRef as M, useMemo as m, useEffect as E } from "react";
3
- import { d as x } from "../../../index.esm-B6vzbp0e.js";
4
- import { getErrorTypeMessage as _ } from "./helpers/getErrorTypeMessage.js";
5
- import { FormContext as $ } from "../FormContext.js";
6
- import { transformCustomRulesToValidateRule as v } from "./helpers/transformCustomRulesToValidateRule.js";
7
- import { IressField as q } from "../../../components/Field/Field.js";
1
+ import { jsx as I } from "react/jsx-runtime";
2
+ import { useContext as M, useRef as E, useMemo as f, useEffect as x } from "react";
3
+ import { a as _ } from "../../../index.esm-BiUTGNH8.js";
4
+ import { getErrorTypeMessage as $ } from "./helpers/getErrorTypeMessage.js";
5
+ import { FormContext as v } from "../FormContext.js";
6
+ import { transformCustomRulesToValidateRule as q } from "./helpers/transformCustomRulesToValidateRule.js";
7
+ import { IressField as S } from "../../../components/Field/Field.js";
8
8
  import "../../../components/Field/Field.styles.js";
9
9
  import "../../../components/Icon/Icon.styles.js";
10
10
  import "../../../components/Field/FieldGroup/FieldGroup.styles.js";
11
11
  import "../../../components/Label/Label.styles.js";
12
12
  import { useFieldRenderProps as T } from "./hooks/useFieldRenderProps.js";
13
- const G = ({
14
- control: f,
13
+ const H = ({
14
+ control: d,
15
15
  defaultValue: p,
16
16
  name: r,
17
17
  render: n,
@@ -20,47 +20,53 @@ const G = ({
20
20
  readOnly: e,
21
21
  ...u
22
22
  }) => {
23
- const o = I($), F = M(null);
23
+ const o = M(v), F = E(null);
24
24
  if (!o)
25
25
  throw new Error(
26
26
  "IressFormField must be used inside an IressForm. If you need a standalone field, use IressField instead."
27
27
  );
28
- const d = m(() => {
28
+ const m = f(() => {
29
29
  if (!e)
30
- return s ? v(s) : void 0;
31
- }, [e, s]), { field: c, fieldState: t } = x({
32
- control: f,
30
+ return s ? q(s) : void 0;
31
+ }, [e, s]), { field: a, formState: c, fieldState: t } = _({
32
+ control: d,
33
33
  defaultValue: p,
34
34
  name: r,
35
- rules: d,
35
+ rules: m,
36
36
  shouldUnregister: l
37
- }), i = m(
38
- () => t.error ? _(
37
+ }), i = f(
38
+ () => t.error ? $(
39
39
  t.error?.message,
40
40
  t.error?.type,
41
41
  s
42
42
  ) : "",
43
43
  [t.error, s]
44
44
  );
45
- E(() => {
45
+ x(() => {
46
46
  e ? o.setErrorMessage(r, "") : o.setErrorMessage(r, i);
47
47
  }, [i, o, r, e]);
48
- const g = T(c, F);
49
- return /* @__PURE__ */ a(
50
- q,
48
+ const g = T(a, F);
49
+ return /* @__PURE__ */ I(
50
+ S,
51
51
  {
52
52
  errorMessages: i && !e ? [{ message: i }] : void 0,
53
53
  readOnly: e,
54
- required: !!d?.required,
54
+ required: !!m?.required,
55
55
  htmlFor: `${o.id}__${r}`,
56
56
  ...u,
57
- children: n({
58
- ...g,
59
- id: `${o.id}__${r}`
60
- })
57
+ children: n(
58
+ {
59
+ ...g,
60
+ id: `${o.id}__${r}`
61
+ },
62
+ {
63
+ formState: c,
64
+ fieldState: t
65
+ }
66
+ )
61
67
  }
62
68
  );
63
69
  };
64
70
  export {
65
- G as IressFormField
71
+ H as IressFormField
66
72
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as F } from "react/jsx-runtime";
2
2
  import { useContext as c, useRef as g, useMemo as I, useEffect as M } from "react";
3
- import { d as x } from "../../../index.esm-B6vzbp0e.js";
3
+ import { a as x } from "../../../index.esm-BiUTGNH8.js";
4
4
  import { getErrorTypeMessage as E } from "./helpers/getErrorTypeMessage.js";
5
5
  import "../../../components/Label/Label.styles.js";
6
6
  import "../../../components/Field/Field.styles.js";
@@ -12,8 +12,8 @@ import { FormContext as q } from "../FormContext.js";
12
12
  import { transformCustomRulesToValidateRule as v } from "./helpers/transformCustomRulesToValidateRule.js";
13
13
  import { useFieldRenderProps as G } from "./hooks/useFieldRenderProps.js";
14
14
  const B = ({
15
- control: d,
16
- defaultValue: m,
15
+ control: m,
16
+ defaultValue: d,
17
17
  name: r,
18
18
  render: f,
19
19
  rules: e,
@@ -26,8 +26,8 @@ const B = ({
26
26
  "IressFormFieldset must be used inside an IressForm. If you need a standalone field, use IressFieldGroup instead."
27
27
  );
28
28
  const i = e ? v(e) : void 0, { field: u, fieldState: s } = x({
29
- control: d,
30
- defaultValue: m,
29
+ control: m,
30
+ defaultValue: d,
31
31
  name: r,
32
32
  rules: i,
33
33
  shouldUnregister: n
@@ -1,59 +1,59 @@
1
- import { jsx as m, jsxs as D } from "react/jsx-runtime";
2
- import { forwardRef as E, useState as Q, useRef as f, useCallback as n, useImperativeHandle as J, useEffect as U, useMemo as K } from "react";
3
- import { u as L, a as X, b as Y, c as Z, F as $ } from "../../../index.esm-B6vzbp0e.js";
4
- import { useIdIfNeeded as y } from "../../../hooks/useIdIfNeeded.js";
5
- import { IressFormValidationSummary as O } from "../FormValidationSummary/FormValidationSummary.js";
6
- import { s as S } from "../../../factory-oPXoMw9H.js";
7
- import { FormContext as ee } from "../FormContext.js";
8
- import { c as se } from "../../../cx-DN21T1EH.js";
9
- import { GlobalCSSClass as re } from "../../../enums.js";
10
- import { propagateTestid as oe } from "../../../helpers/utility/propagateTestid.js";
11
- const te = ({
12
- alert: V,
13
- children: W,
14
- className: _,
1
+ import { jsx as f, jsxs as E } from "react/jsx-runtime";
2
+ import { forwardRef as J, useState as U, useRef as m, useCallback as n, useImperativeHandle as K, useEffect as V, useMemo as L } from "react";
3
+ import { F as W } from "../../../index.esm-BiUTGNH8.js";
4
+ import { useIdIfNeeded as X } from "../../../hooks/useIdIfNeeded.js";
5
+ import { IressFormValidationSummary as Y } from "../FormValidationSummary/FormValidationSummary.js";
6
+ import { s as Z } from "../../../factory-oPXoMw9H.js";
7
+ import { FormContext as $ } from "../FormContext.js";
8
+ import { c as y } from "../../../cx-DN21T1EH.js";
9
+ import { GlobalCSSClass as O } from "../../../enums.js";
10
+ import { propagateTestid as S } from "../../../helpers/utility/propagateTestid.js";
11
+ const _ = ({
12
+ alert: G,
13
+ children: T,
14
+ className: b,
15
15
  "data-testid": d,
16
16
  form: o,
17
- onSubmit: F,
17
+ onSubmit: u,
18
18
  onValidChange: p,
19
- onError: x,
19
+ onError: F,
20
20
  updateErrorSummaryOnSubmit: s,
21
21
  ...g
22
- }, b) => {
23
- const i = y({ id: g.id }), [r, u] = Q({}), c = f({}), v = f(null), M = f(null), { handleSubmit: C, reset: G, formState: T } = o, { isValid: H, isSubmitted: I } = T, [w, R] = Q(!1), h = n(
22
+ }, h) => {
23
+ const a = X({ id: g.id }), [r, i] = U({}), c = m({}), v = m(null), M = m(null), { handleSubmit: x, reset: q, formState: z } = o, { isValid: H, isSubmitted: I } = z, [C, N] = U(!1), R = n(
24
24
  (e) => {
25
- x?.(e), v.current?.focus(), s && R(!0);
25
+ F?.(e), v.current?.focus(), s && N(!0);
26
26
  },
27
- [x, s]
27
+ [F, s]
28
28
  ), j = n(
29
29
  (e) => {
30
- C((t) => {
31
- F?.(t), u({}), c.current = {};
32
- }, h)(e);
30
+ x((t) => {
31
+ u?.(t), i({}), c.current = {};
32
+ }, R)(e);
33
33
  },
34
- [h, C, F]
34
+ [R, x, u]
35
35
  ), k = n(
36
36
  (e) => {
37
37
  c.current = e();
38
38
  },
39
39
  []
40
- ), A = n(
40
+ ), w = n(
41
41
  (e) => {
42
42
  v.current = e;
43
43
  },
44
44
  []
45
- ), N = n(
45
+ ), P = n(
46
46
  (e, t) => {
47
47
  if (t === r[e] || !t && !r[e])
48
48
  return;
49
- const z = s ? c.current : r, P = [...o.control._names.mount.values()].reduce(
50
- (B, l) => ({
51
- ...B,
52
- [l]: l === e ? t : z[l]
49
+ const B = s ? c.current : r, Q = [...o.control._names.mount.values()].reduce(
50
+ (D, l) => ({
51
+ ...D,
52
+ [l]: l === e ? t : B[l]
53
53
  }),
54
54
  {}
55
55
  );
56
- s ? k(() => P) : u(() => P);
56
+ s ? k(() => Q) : i(() => Q);
57
57
  },
58
58
  [
59
59
  r,
@@ -62,52 +62,50 @@ const te = ({
62
62
  s
63
63
  ]
64
64
  );
65
- J(b, () => ({
65
+ K(h, () => ({
66
66
  element: M?.current ?? void 0,
67
67
  api: o,
68
68
  submit: () => j(),
69
- reset: (e) => G(e)
70
- })), U(() => {
69
+ reset: (e) => q(e)
70
+ })), V(() => {
71
71
  p?.(H);
72
- }, [H, p]), U(() => {
73
- s && w && I && (u(() => c.current), R(!1));
74
- }, [s, w, I]);
75
- const q = K(
72
+ }, [H, p]), V(() => {
73
+ s && C && I && (i(() => c.current), N(!1));
74
+ }, [s, C, I]);
75
+ const A = L(
76
76
  () => ({
77
- id: i,
77
+ id: a,
78
78
  errorMessages: r,
79
- setErrorMessage: N,
80
- setFocusOnError: A
79
+ setErrorMessage: P,
80
+ setFocusOnError: w
81
81
  }),
82
- [r, i, N, A]
82
+ [r, a, P, w]
83
83
  );
84
- return /* @__PURE__ */ m(ee.Provider, { value: q, children: /* @__PURE__ */ m($, { ...o, children: /* @__PURE__ */ D(
85
- S.form,
84
+ return /* @__PURE__ */ f($.Provider, { value: A, children: /* @__PURE__ */ f(W, { ...o, children: /* @__PURE__ */ E(
85
+ Z.form,
86
86
  {
87
87
  ...g,
88
- className: se(_, re.Form),
88
+ className: y(b, O.Form),
89
89
  "data-testid": d,
90
- id: i,
90
+ id: a,
91
91
  noValidate: !0,
92
92
  onSubmit: j,
93
93
  ref: M,
94
94
  children: [
95
- V ?? /* @__PURE__ */ m(
96
- O,
95
+ G ?? /* @__PURE__ */ f(
96
+ Y,
97
97
  {
98
- "data-testid": oe(d, "error-summary"),
98
+ "data-testid": S(d, "error-summary"),
99
99
  srOnly: !0
100
100
  }
101
101
  ),
102
- W
102
+ T
103
103
  ]
104
104
  }
105
105
  ) }) });
106
- }, ne = E(te), a = ne;
107
- a.useFieldArray = L;
108
- a.useForm = X;
109
- a.useFormContext = Y;
110
- a.useWatch = Z;
106
+ };
107
+ _.displayName = "IressHookForm";
108
+ const fe = J(_);
111
109
  export {
112
- a as IressHookForm
110
+ fe as IressHookForm
113
111
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { a as L } from "../../../index.esm-B6vzbp0e.js";
2
+ import { u as L } from "../../../index.esm-BiUTGNH8.js";
3
3
  import { forwardRef as y, useMemo as z } from "react";
4
4
  import { IressText as B } from "../../../components/Text/Text.js";
5
5
  import { form as C } from "../Form.styles.js";
@@ -20,9 +20,9 @@ const T = ({
20
20
  delayError: p,
21
21
  footer: t,
22
22
  heading: o,
23
- mode: g = "onBlur",
23
+ mode: u = "onBlur",
24
24
  panelStyle: n = { bg: "alt" },
25
- progressive: u,
25
+ progressive: g,
26
26
  resetOptions: F,
27
27
  resolver: N,
28
28
  reValidateMode: x = "onChange",
@@ -37,8 +37,8 @@ const T = ({
37
37
  context: d,
38
38
  defaultValues: h,
39
39
  delayError: p,
40
- mode: g,
41
- progressive: u,
40
+ mode: u,
41
+ progressive: g,
42
42
  resetOptions: F,
43
43
  resolver: N,
44
44
  reValidateMode: x,
@@ -1,5 +1,5 @@
1
1
  import { jsx as H, jsxs as I } from "react/jsx-runtime";
2
- import { a as b } from "../../../index.esm-B6vzbp0e.js";
2
+ import { u as b } from "../../../index.esm-BiUTGNH8.js";
3
3
  import { forwardRef as g, useMemo as w } from "react";
4
4
  import { form as C } from "../Form.styles.js";
5
5
  import { IressHookForm as E } from "../HookForm/HookForm.js";
@@ -16,8 +16,8 @@ const R = ({
16
16
  delayError: c,
17
17
  heading: o,
18
18
  mode: i = "onSubmit",
19
- progressive: a,
20
- resetOptions: u,
19
+ progressive: u,
20
+ resetOptions: a,
21
21
  resolver: h,
22
22
  reValidateMode: p = "onChange",
23
23
  shouldUseNativeValidation: F,
@@ -31,8 +31,8 @@ const R = ({
31
31
  defaultValues: f,
32
32
  delayError: c,
33
33
  mode: i,
34
- progressive: a,
35
- resetOptions: u,
34
+ progressive: u,
35
+ resetOptions: a,
36
36
  resolver: h,
37
37
  reValidateMode: p,
38
38
  shouldFocusError: !r,