@mittwald/flow-react-components 0.1.0-alpha.140 → 0.1.0-alpha.141

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,37 +1,37 @@
1
1
  "use client"
2
2
  /* */
3
- import o, { createContext as F, useContext as v, useEffect as h } from "react";
4
- import { Controller as x, useFormState as C } from "react-hook-form";
3
+ import o, { createContext as C, useContext as k, useEffect as b, useRef as E } from "react";
4
+ import { Controller as P, useFormState as g } from "react-hook-form";
5
5
  import "./propsContext-DzAKlmhS.js";
6
- import { P as k } from "./PropsContextProvider-C6Z4XGp6.js";
6
+ import { P as A } from "./PropsContextProvider-C6Z4XGp6.js";
7
7
  import "@react-aria/utils";
8
8
  import "remeda";
9
- import { d as E } from "./dynamic-ClpUSmEt.js";
10
- import { F as g } from "./FieldError-D_VRyiJG.js";
11
- import { a as P, A as V } from "./Action-C4Ncwjzf.js";
12
- const b = F({}), A = b.Provider, y = () => v(b);
13
- function I(c) {
9
+ import { d as V } from "./dynamic-ClpUSmEt.js";
10
+ import { F as y } from "./FieldError-D_VRyiJG.js";
11
+ import { a as I, A as D } from "./Action-C4Ncwjzf.js";
12
+ const F = C({}), R = F.Provider, w = () => k(F);
13
+ function T(c) {
14
14
  var r;
15
- const { children: t, control: i, ...n } = c, a = (r = y().form) == null ? void 0 : r.control;
15
+ const { children: t, control: i, ...n } = c, a = (r = w().form) == null ? void 0 : r.control;
16
16
  return /* @__PURE__ */ o.createElement(
17
- x,
17
+ P,
18
18
  {
19
19
  ...n,
20
20
  control: i ?? a,
21
21
  render: (s) => {
22
- var u;
22
+ var m;
23
23
  const {
24
- field: d,
25
- fieldState: { error: l, invalid: m }
24
+ field: l,
25
+ fieldState: { error: u, invalid: f }
26
26
  } = s, e = {
27
- ...d,
28
- isRequired: !!((u = n.rules) != null && u.required),
29
- isInvalid: m,
27
+ ...l,
28
+ isRequired: !!((m = n.rules) != null && m.required),
29
+ isInvalid: f,
30
30
  validationBehavior: "aria",
31
- children: E((p) => /* @__PURE__ */ o.createElement(o.Fragment, null, p.children, /* @__PURE__ */ o.createElement(g, null, l == null ? void 0 : l.message))),
31
+ children: V((p) => /* @__PURE__ */ o.createElement(o.Fragment, null, p.children, /* @__PURE__ */ o.createElement(y, null, u == null ? void 0 : u.message))),
32
32
  ref: void 0,
33
- refProp: d.ref
34
- }, f = {
33
+ refProp: l.ref
34
+ }, d = {
35
35
  Checkbox: e,
36
36
  CheckboxGroup: e,
37
37
  CheckboxButton: e,
@@ -44,9 +44,9 @@ function I(c) {
44
44
  Slider: e
45
45
  };
46
46
  return /* @__PURE__ */ o.createElement(
47
- k,
47
+ A,
48
48
  {
49
- props: f,
49
+ props: d,
50
50
  dependencies: [s]
51
51
  },
52
52
  t
@@ -55,15 +55,15 @@ function I(c) {
55
55
  }
56
56
  );
57
57
  }
58
- const O = (c) => I, D = (c) => {
59
- const { isStarted: t, hasFailedWithError: i, hasSucceeded: n, children: a } = c, r = P.useNew({});
60
- return h(() => {
58
+ const H = (c) => T, q = (c) => {
59
+ const { isStarted: t, hasFailedWithError: i, hasSucceeded: n, children: a } = c, r = I.useNew({});
60
+ return b(() => {
61
61
  n ? r.state.onSucceeded() : i ? r.state.onFailed(i) : t && r.state.onAsyncStart();
62
- }, [t, i, n]), /* @__PURE__ */ o.createElement(V, { actionModel: r }, a);
62
+ }, [t, i, n]), /* @__PURE__ */ o.createElement(D, { actionModel: r }, a);
63
63
  };
64
- function _(c) {
65
- const { form: t, children: i, onSubmit: n, ...a } = c, { isValid: r, isSubmitted: s, isSubmitting: d, isSubmitSuccessful: l, errors: m } = C(t), e = t.control._formState;
66
- h(() => {
64
+ function J(c) {
65
+ const { form: t, children: i, onSubmit: n, ...a } = c, { isValid: r, isSubmitted: s, isSubmitting: l, isSubmitSuccessful: u, errors: f } = g(t), e = t.control._formState, d = E(!1);
66
+ b(() => {
67
67
  s && r && t.reset(void 0, {
68
68
  keepIsSubmitted: !1,
69
69
  keepIsSubmitSuccessful: !1,
@@ -78,21 +78,24 @@ function _(c) {
78
78
  keepSubmitCount: !0
79
79
  });
80
80
  }, [s, r]);
81
- const f = (S) => {
82
- e.isSubmitting || e.isValidating ? S.preventDefault() : t.handleSubmit(n)(S);
83
- }, u = s ? m : void 0, p = s && l;
84
- return /* @__PURE__ */ o.createElement(A, { value: { form: t } }, /* @__PURE__ */ o.createElement("form", { ...a, onSubmit: f }, /* @__PURE__ */ o.createElement(
85
- D,
81
+ const m = (S) => {
82
+ e.isSubmitting || e.isValidating ? S.preventDefault() : t.handleSubmit((x) => {
83
+ const h = n(x);
84
+ return d.current = h instanceof Promise, h;
85
+ })(S);
86
+ }, p = s ? f : void 0, v = s && u;
87
+ return /* @__PURE__ */ o.createElement(R, { value: { form: t } }, /* @__PURE__ */ o.createElement("form", { ...a, onSubmit: m }, /* @__PURE__ */ o.createElement(
88
+ q,
86
89
  {
87
- isStarted: d,
88
- hasFailedWithError: u,
89
- hasSucceeded: p
90
+ isStarted: l && d.current,
91
+ hasFailedWithError: p,
92
+ hasSucceeded: v
90
93
  },
91
94
  i
92
95
  )));
93
96
  }
94
97
  export {
95
- I as Field,
96
- _ as Form,
97
- O as typedField
98
+ T as Field,
99
+ J as Form,
100
+ H as typedField
98
101
  };