@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.
- package/dist/react-hook-form.js +42 -39
- package/dist/styles.css +1 -1
- package/package.json +30 -30
package/dist/react-hook-form.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import o, { createContext as
|
|
4
|
-
import { Controller as
|
|
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
|
|
6
|
+
import { P as A } from "./PropsContextProvider-C6Z4XGp6.js";
|
|
7
7
|
import "@react-aria/utils";
|
|
8
8
|
import "remeda";
|
|
9
|
-
import { d as
|
|
10
|
-
import { F as
|
|
11
|
-
import { a as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
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 =
|
|
15
|
+
const { children: t, control: i, ...n } = c, a = (r = w().form) == null ? void 0 : r.control;
|
|
16
16
|
return /* @__PURE__ */ o.createElement(
|
|
17
|
-
|
|
17
|
+
P,
|
|
18
18
|
{
|
|
19
19
|
...n,
|
|
20
20
|
control: i ?? a,
|
|
21
21
|
render: (s) => {
|
|
22
|
-
var
|
|
22
|
+
var m;
|
|
23
23
|
const {
|
|
24
|
-
field:
|
|
25
|
-
fieldState: { error:
|
|
24
|
+
field: l,
|
|
25
|
+
fieldState: { error: u, invalid: f }
|
|
26
26
|
} = s, e = {
|
|
27
|
-
...
|
|
28
|
-
isRequired: !!((
|
|
29
|
-
isInvalid:
|
|
27
|
+
...l,
|
|
28
|
+
isRequired: !!((m = n.rules) != null && m.required),
|
|
29
|
+
isInvalid: f,
|
|
30
30
|
validationBehavior: "aria",
|
|
31
|
-
children:
|
|
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:
|
|
34
|
-
},
|
|
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
|
-
|
|
47
|
+
A,
|
|
48
48
|
{
|
|
49
|
-
props:
|
|
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
|
|
59
|
-
const { isStarted: t, hasFailedWithError: i, hasSucceeded: n, children: a } = c, r =
|
|
60
|
-
return
|
|
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(
|
|
62
|
+
}, [t, i, n]), /* @__PURE__ */ o.createElement(D, { actionModel: r }, a);
|
|
63
63
|
};
|
|
64
|
-
function
|
|
65
|
-
const { form: t, children: i, onSubmit: n, ...a } = c, { isValid: r, isSubmitted: s, isSubmitting:
|
|
66
|
-
|
|
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
|
|
82
|
-
e.isSubmitting || e.isValidating ? S.preventDefault() : t.handleSubmit(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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:
|
|
89
|
-
hasSucceeded:
|
|
90
|
+
isStarted: l && d.current,
|
|
91
|
+
hasFailedWithError: p,
|
|
92
|
+
hasSucceeded: v
|
|
90
93
|
},
|
|
91
94
|
i
|
|
92
95
|
)));
|
|
93
96
|
}
|
|
94
97
|
export {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
T as Field,
|
|
99
|
+
J as Form,
|
|
100
|
+
H as typedField
|
|
98
101
|
};
|