@mittwald/flow-react-components 0.1.0-alpha.412 → 0.1.0-alpha.416

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,46 @@
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.416](https://github.com/mittwald/flow/compare/0.1.0-alpha.415...0.1.0-alpha.416) (2025-02-04)
7
+
8
+ **Note:** Version bump only for package @mittwald/flow-react-components
9
+
10
+ # Change Log
11
+
12
+ All notable changes to this project will be documented in this file. See
13
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
14
+
15
+ # [0.1.0-alpha.415](https://github.com/mittwald/flow/compare/0.1.0-alpha.414...0.1.0-alpha.415) (2025-02-04)
16
+
17
+ **Note:** Version bump only for package @mittwald/flow-react-components
18
+
19
+ # Change Log
20
+
21
+ All notable changes to this project will be documented in this file. See
22
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
23
+
24
+ # [0.1.0-alpha.414](https://github.com/mittwald/flow/compare/0.1.0-alpha.413...0.1.0-alpha.414) (2025-02-04)
25
+
26
+ **Note:** Version bump only for package @mittwald/flow-react-components
27
+
28
+ # Change Log
29
+
30
+ All notable changes to this project will be documented in this file. See
31
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
32
+
33
+ # [0.1.0-alpha.413](https://github.com/mittwald/flow/compare/0.1.0-alpha.412...0.1.0-alpha.413) (2025-01-31)
34
+
35
+ ### Features
36
+
37
+ - **Form:** add auto reset functionality when modal closes
38
+ ([#1144](https://github.com/mittwald/flow/issues/1144))
39
+ ([207e3dc](https://github.com/mittwald/flow/commit/207e3dcd2f35ddb06556bcc4fd68b88eca384c76))
40
+
41
+ # Change Log
42
+
43
+ All notable changes to this project will be documented in this file. See
44
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
45
+
6
46
  # [0.1.0-alpha.412](https://github.com/mittwald/flow/compare/0.1.0-alpha.411...0.1.0-alpha.412) (2025-01-31)
7
47
 
8
48
  **Note:** Version bump only for package @mittwald/flow-react-components
@@ -1,37 +1,39 @@
1
1
  "use client"
2
2
  /* */
3
- import n, { createContext as x, useContext as v, useEffect as S, useRef as k } from "react";
3
+ import n, { createContext as E, 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 b } from "./PropsContextProvider.js";
6
+ import { PropsContextProvider as C } from "./PropsContextProvider.js";
7
7
  import "@react-aria/utils";
8
8
  import "remeda";
9
- import { d as F } from "./dynamic-ClpUSmEt.js";
9
+ import { d as b } 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
- 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;
12
+ import "mobx";
13
+ import { u as V } from "./useOverlayController-BwSJj4Ly.js";
14
+ const F = E({}), D = F.Provider, p = () => v(F);
15
+ function I(r) {
16
+ var s;
17
+ const { children: t, control: o, ...i } = r, c = (s = p().form) == null ? void 0 : s.control;
16
18
  return /* @__PURE__ */ n.createElement(
17
19
  g,
18
20
  {
19
- ...s,
20
- control: o ?? l,
21
+ ...i,
22
+ control: o ?? c,
21
23
  render: (a) => {
22
- var p;
24
+ var d;
23
25
  const {
24
- field: c,
25
- fieldState: { error: u, invalid: m }
26
+ field: u,
27
+ fieldState: { error: l, invalid: m }
26
28
  } = a, e = {
27
- ...c,
28
- isRequired: !!((p = s.rules) != null && p.required),
29
+ ...u,
30
+ isRequired: !!((d = i.rules) != null && d.required),
29
31
  isInvalid: m,
30
32
  validationBehavior: "aria",
31
- children: F((E) => /* @__PURE__ */ n.createElement(n.Fragment, null, E.children, /* @__PURE__ */ n.createElement(A, null, u == null ? void 0 : u.message))),
33
+ children: b((x) => /* @__PURE__ */ n.createElement(n.Fragment, null, x.children, /* @__PURE__ */ n.createElement(A, null, l == null ? void 0 : l.message))),
32
34
  ref: void 0,
33
- refProp: c.ref
34
- }, d = {
35
+ refProp: u.ref
36
+ }, f = {
35
37
  Checkbox: e,
36
38
  CheckboxGroup: e,
37
39
  CheckboxButton: e,
@@ -52,44 +54,44 @@ function D(t) {
52
54
  SegmentedControl: e
53
55
  };
54
56
  return /* @__PURE__ */ n.createElement(
55
- b,
57
+ C,
56
58
  {
57
- props: d,
59
+ props: f,
58
60
  dependencies: [a]
59
61
  },
60
- r
62
+ t
61
63
  );
62
64
  }
63
65
  }
64
66
  );
65
67
  }
66
- const _ = (t) => D, I = (t) => {
67
- const { isStarted: r, hasFailedWithError: o, hasSucceeded: s, children: l } = t, i = P.useNew({});
68
+ const J = (r) => I, R = (r) => {
69
+ const { isStarted: t, hasFailedWithError: o, hasSucceeded: i, children: c } = r, s = P.useNew({});
68
70
  return S(() => {
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;
71
+ i ? s.state.onSucceeded() : o ? s.state.onFailed(o) : t && s.state.onAsyncStart();
72
+ }, [t, o, i]), /* @__PURE__ */ n.createElement(y, { actionModel: s }, c);
73
+ }, M = (r) => {
74
+ const { children: t, isAsyncSubmit: o } = r, i = p().form, { isSubmitted: c, isSubmitting: s, isSubmitSuccessful: a, errors: u } = h(i), l = c && u && Object.entries(u).length > 0 ? u : void 0, m = c && a;
73
75
  return /* @__PURE__ */ n.createElement(
74
- I,
76
+ R,
75
77
  {
76
- isStarted: i && o.current,
77
- hasFailedWithError: u,
78
+ isStarted: s && o.current,
79
+ hasFailedWithError: l,
78
80
  hasSucceeded: m
79
81
  },
80
- r
82
+ t
81
83
  );
82
- }, T = (t) => {
83
- const { children: r, isAsyncSubmit: o } = t, s = {
84
+ }, O = (r) => {
85
+ const { children: t, isAsyncSubmit: o } = r, i = {
84
86
  ActionGroup: {
85
- children: F((l) => /* @__PURE__ */ n.createElement(R, { isAsyncSubmit: o }, l.children))
87
+ children: b((c) => /* @__PURE__ */ n.createElement(M, { isAsyncSubmit: o }, c.children))
86
88
  }
87
89
  };
88
- return /* @__PURE__ */ n.createElement(b, { props: s, mergeInParentContext: !0 }, r);
89
- }, B = () => {
90
- const t = f().form, { isValid: r, isSubmitted: o } = h(t);
90
+ return /* @__PURE__ */ n.createElement(C, { props: i, mergeInParentContext: !0 }, t);
91
+ }, T = () => {
92
+ const r = p().form, { isValid: t, isSubmitted: o } = h(r);
91
93
  return S(() => {
92
- o && r && t && t.reset(void 0, {
94
+ o && t && r && r.reset(void 0, {
93
95
  keepIsSubmitted: !1,
94
96
  keepIsSubmitSuccessful: !1,
95
97
  keepDefaultValues: !0,
@@ -102,25 +104,38 @@ const _ = (t) => D, I = (t) => {
102
104
  keepIsValidating: !0,
103
105
  keepSubmitCount: !0
104
106
  });
105
- }, [o, r, t]), null;
107
+ }, [o, t, r]), null;
106
108
  };
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();
109
+ function L(r) {
110
+ const {
111
+ form: t,
112
+ children: o,
113
+ onSubmit: i,
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();
112
127
  return;
113
128
  }
114
- r.handleSubmit((e) => {
115
- const d = s(e, c);
116
- return i.current = d instanceof Promise, d;
117
- })(c);
129
+ t.handleSubmit((f) => {
130
+ const d = i(f, l);
131
+ return a.current = d instanceof Promise, d;
132
+ })(l);
118
133
  };
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)));
134
+ return /* @__PURE__ */ n.createElement(D, { value: { form: t } }, /* @__PURE__ */ n.createElement(O, { isAsyncSubmit: a }, /* @__PURE__ */ n.createElement("form", { ...s, onSubmit: u }, o), /* @__PURE__ */ n.createElement(T, null)));
120
135
  }
121
136
  export {
122
- D as Field,
123
- z as Form,
124
- _ as typedField,
125
- f as useFormContext
137
+ I as Field,
138
+ L as Form,
139
+ J as typedField,
140
+ p as useFormContext
126
141
  };
@@ -4,6 +4,7 @@ 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;
7
8
  }
8
9
  export declare function Form<F extends FieldValues>(props: Props<F>): React.JSX.Element;
9
10
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "0.1.0-alpha.412",
3
+ "version": "0.1.0-alpha.416",
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.412",
443
+ "@mittwald/react-tunnel": "^0.1.0-alpha.416",
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.412",
474
+ "@mittwald/flow-design-tokens": "^0.1.0-alpha.416",
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": "42a102d5aa42025b578b2eed1c3a5d743b3bc79b"
569
+ "gitHead": "a8697ac00d550b22508258e89347a2ba68f1755b"
570
570
  }