@mittwald/flow-react-components 0.1.0-alpha.418 → 0.1.0-alpha.419
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.1.0-alpha.419](https://github.com/mittwald/flow/compare/0.1.0-alpha.418...0.1.0-alpha.419) (2025-02-06)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **Form:** remove form reset on modal close
|
|
11
|
+
([#1160](https://github.com/mittwald/flow/issues/1160))
|
|
12
|
+
([0ddce97](https://github.com/mittwald/flow/commit/0ddce97b493a2e5dfe996f0ac9bd0dbff4718fe8))
|
|
13
|
+
|
|
14
|
+
# Change Log
|
|
15
|
+
|
|
16
|
+
All notable changes to this project will be documented in this file. See
|
|
17
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
18
|
+
|
|
6
19
|
# [0.1.0-alpha.418](https://github.com/mittwald/flow/compare/0.1.0-alpha.417...0.1.0-alpha.418) (2025-02-05)
|
|
7
20
|
|
|
8
21
|
### Features
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import n, { createContext as
|
|
3
|
+
import n, { createContext as x, useContext as v, useEffect as S, useRef as k } from "react";
|
|
4
4
|
import { Controller as g, useFormState as h } from "react-hook-form";
|
|
5
5
|
import "./propsContext-DzAKlmhS.js";
|
|
6
|
-
import { PropsContextProvider as
|
|
6
|
+
import { PropsContextProvider as b } from "./PropsContextProvider.js";
|
|
7
7
|
import "@react-aria/utils";
|
|
8
8
|
import "remeda";
|
|
9
|
-
import { d as
|
|
9
|
+
import { d as F } from "./dynamic-ClpUSmEt.js";
|
|
10
10
|
import { F as A } from "./FieldError-C-_2QNam.js";
|
|
11
11
|
import { a as P, A as y } from "./Action-C6RX6wSX.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var s;
|
|
17
|
-
const { children: t, control: o, ...i } = r, c = (s = p().form) == null ? void 0 : s.control;
|
|
12
|
+
const C = x({}), V = C.Provider, f = () => v(C);
|
|
13
|
+
function D(t) {
|
|
14
|
+
var i;
|
|
15
|
+
const { children: r, control: o, ...s } = t, l = (i = f().form) == null ? void 0 : i.control;
|
|
18
16
|
return /* @__PURE__ */ n.createElement(
|
|
19
17
|
g,
|
|
20
18
|
{
|
|
21
|
-
...
|
|
22
|
-
control: o ??
|
|
19
|
+
...s,
|
|
20
|
+
control: o ?? l,
|
|
23
21
|
render: (a) => {
|
|
24
|
-
var
|
|
22
|
+
var p;
|
|
25
23
|
const {
|
|
26
|
-
field:
|
|
27
|
-
fieldState: { error:
|
|
24
|
+
field: c,
|
|
25
|
+
fieldState: { error: u, invalid: m }
|
|
28
26
|
} = a, e = {
|
|
29
|
-
...
|
|
30
|
-
isRequired: !!((
|
|
27
|
+
...c,
|
|
28
|
+
isRequired: !!((p = s.rules) != null && p.required),
|
|
31
29
|
isInvalid: m,
|
|
32
30
|
validationBehavior: "aria",
|
|
33
|
-
children:
|
|
31
|
+
children: F((E) => /* @__PURE__ */ n.createElement(n.Fragment, null, E.children, /* @__PURE__ */ n.createElement(A, null, u == null ? void 0 : u.message))),
|
|
34
32
|
ref: void 0,
|
|
35
|
-
refProp:
|
|
36
|
-
},
|
|
33
|
+
refProp: c.ref
|
|
34
|
+
}, d = {
|
|
37
35
|
Checkbox: e,
|
|
38
36
|
CheckboxGroup: e,
|
|
39
37
|
CheckboxButton: e,
|
|
@@ -54,44 +52,44 @@ function I(r) {
|
|
|
54
52
|
SegmentedControl: e
|
|
55
53
|
};
|
|
56
54
|
return /* @__PURE__ */ n.createElement(
|
|
57
|
-
|
|
55
|
+
b,
|
|
58
56
|
{
|
|
59
|
-
props:
|
|
57
|
+
props: d,
|
|
60
58
|
dependencies: [a]
|
|
61
59
|
},
|
|
62
|
-
|
|
60
|
+
r
|
|
63
61
|
);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
);
|
|
67
65
|
}
|
|
68
|
-
const
|
|
69
|
-
const { isStarted:
|
|
66
|
+
const _ = (t) => D, I = (t) => {
|
|
67
|
+
const { isStarted: r, hasFailedWithError: o, hasSucceeded: s, children: l } = t, i = P.useNew({});
|
|
70
68
|
return S(() => {
|
|
71
|
-
|
|
72
|
-
}, [
|
|
73
|
-
},
|
|
74
|
-
const { children:
|
|
69
|
+
s ? i.state.onSucceeded() : o ? i.state.onFailed(o) : r && i.state.onAsyncStart();
|
|
70
|
+
}, [r, o, s]), /* @__PURE__ */ n.createElement(y, { actionModel: i }, l);
|
|
71
|
+
}, R = (t) => {
|
|
72
|
+
const { children: r, isAsyncSubmit: o } = t, s = f().form, { isSubmitted: l, isSubmitting: i, isSubmitSuccessful: a, errors: c } = h(s), u = l && c && Object.entries(c).length > 0 ? c : void 0, m = l && a;
|
|
75
73
|
return /* @__PURE__ */ n.createElement(
|
|
76
|
-
|
|
74
|
+
I,
|
|
77
75
|
{
|
|
78
|
-
isStarted:
|
|
79
|
-
hasFailedWithError:
|
|
76
|
+
isStarted: i && o.current,
|
|
77
|
+
hasFailedWithError: u,
|
|
80
78
|
hasSucceeded: m
|
|
81
79
|
},
|
|
82
|
-
|
|
80
|
+
r
|
|
83
81
|
);
|
|
84
|
-
},
|
|
85
|
-
const { children:
|
|
82
|
+
}, T = (t) => {
|
|
83
|
+
const { children: r, isAsyncSubmit: o } = t, s = {
|
|
86
84
|
ActionGroup: {
|
|
87
|
-
children:
|
|
85
|
+
children: F((l) => /* @__PURE__ */ n.createElement(R, { isAsyncSubmit: o }, l.children))
|
|
88
86
|
}
|
|
89
87
|
};
|
|
90
|
-
return /* @__PURE__ */ n.createElement(
|
|
91
|
-
},
|
|
92
|
-
const
|
|
88
|
+
return /* @__PURE__ */ n.createElement(b, { props: s, mergeInParentContext: !0 }, r);
|
|
89
|
+
}, B = () => {
|
|
90
|
+
const t = f().form, { isValid: r, isSubmitted: o } = h(t);
|
|
93
91
|
return S(() => {
|
|
94
|
-
o &&
|
|
92
|
+
o && r && t && t.reset(void 0, {
|
|
95
93
|
keepIsSubmitted: !1,
|
|
96
94
|
keepIsSubmitSuccessful: !1,
|
|
97
95
|
keepDefaultValues: !0,
|
|
@@ -104,38 +102,25 @@ const J = (r) => I, R = (r) => {
|
|
|
104
102
|
keepIsValidating: !0,
|
|
105
103
|
keepSubmitCount: !0
|
|
106
104
|
});
|
|
107
|
-
}, [o,
|
|
105
|
+
}, [o, r, t]), null;
|
|
108
106
|
};
|
|
109
|
-
function
|
|
110
|
-
const {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
resetFormOnCloseModal: c = !0,
|
|
115
|
-
...s
|
|
116
|
-
} = r, a = k(!1);
|
|
117
|
-
V("Modal", {
|
|
118
|
-
reuseControllerFromContext: !0,
|
|
119
|
-
onClose: () => {
|
|
120
|
-
c && t.reset();
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
const u = (l) => {
|
|
124
|
-
const { isSubmitting: m, isValidating: e } = t.control._formState;
|
|
125
|
-
if (l.stopPropagation(), m || e) {
|
|
126
|
-
l.preventDefault();
|
|
107
|
+
function z(t) {
|
|
108
|
+
const { form: r, children: o, onSubmit: s, ...l } = t, i = k(!1), a = (c) => {
|
|
109
|
+
const { isSubmitting: u, isValidating: m } = r.control._formState;
|
|
110
|
+
if (c.stopPropagation(), u || m) {
|
|
111
|
+
c.preventDefault();
|
|
127
112
|
return;
|
|
128
113
|
}
|
|
129
|
-
|
|
130
|
-
const d =
|
|
131
|
-
return
|
|
132
|
-
})(
|
|
114
|
+
r.handleSubmit((e) => {
|
|
115
|
+
const d = s(e, c);
|
|
116
|
+
return i.current = d instanceof Promise, d;
|
|
117
|
+
})(c);
|
|
133
118
|
};
|
|
134
|
-
return /* @__PURE__ */ n.createElement(
|
|
119
|
+
return /* @__PURE__ */ n.createElement(V, { value: { form: r } }, /* @__PURE__ */ n.createElement(T, { isAsyncSubmit: i }, /* @__PURE__ */ n.createElement("form", { ...l, onSubmit: a }, o), /* @__PURE__ */ n.createElement(B, null)));
|
|
135
120
|
}
|
|
136
121
|
export {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
122
|
+
D as Field,
|
|
123
|
+
z as Form,
|
|
124
|
+
_ as typedField,
|
|
125
|
+
f as useFormContext
|
|
141
126
|
};
|
|
@@ -4,7 +4,6 @@ export type FormOnSubmitHandler<F extends FieldValues> = Parameters<UseFormRetur
|
|
|
4
4
|
interface Props<F extends FieldValues> extends Omit<ComponentProps<"form">, "onSubmit">, PropsWithChildren {
|
|
5
5
|
form: UseFormReturn<F>;
|
|
6
6
|
onSubmit: FormOnSubmitHandler<F>;
|
|
7
|
-
resetFormOnCloseModal?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export declare function Form<F extends FieldValues>(props: Props<F>): React.JSX.Element;
|
|
10
9
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.419",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
"@chakra-ui/live-region": "^2.1.0",
|
|
441
441
|
"@internationalized/date": "^3.6.0",
|
|
442
442
|
"@internationalized/string-compiler": "^3.2.6",
|
|
443
|
-
"@mittwald/react-tunnel": "^0.1.0-alpha.
|
|
443
|
+
"@mittwald/react-tunnel": "^0.1.0-alpha.419",
|
|
444
444
|
"@mittwald/react-use-promise": "^2.6.0",
|
|
445
445
|
"@react-aria/form": "^3.0.11",
|
|
446
446
|
"@react-aria/utils": "^3.26.0",
|
|
@@ -471,7 +471,7 @@
|
|
|
471
471
|
},
|
|
472
472
|
"devDependencies": {
|
|
473
473
|
"@faker-js/faker": "^9.2.0",
|
|
474
|
-
"@mittwald/flow-design-tokens": "^0.1.0-alpha.
|
|
474
|
+
"@mittwald/flow-design-tokens": "^0.1.0-alpha.419",
|
|
475
475
|
"@mittwald/react-use-promise": "^2.6.0",
|
|
476
476
|
"@nx/storybook": "^20.1.3",
|
|
477
477
|
"@storybook/addon-a11y": "^8.4.5",
|
|
@@ -566,5 +566,5 @@
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
},
|
|
569
|
-
"gitHead": "
|
|
569
|
+
"gitHead": "713e6c7986991cdbc7a36f2ce001cee08463243f"
|
|
570
570
|
}
|