@mittwald/flow-react-components 0.1.0-alpha.139 → 0.1.0-alpha.140
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/{Action-BGsLXvb9.js → Action-C4Ncwjzf.js} +92 -91
- package/dist/Action.js +1 -1
- package/dist/CopyButton.js +1 -1
- package/dist/OffCanvas.js +1 -1
- package/dist/RadioGroup.js +23 -10
- package/dist/Section.js +3 -3
- package/dist/react-hook-form.js +69 -35
- package/dist/types/components/Action/ActionStateContext.d.ts +9 -0
- package/dist/types/components/Action/types.d.ts +2 -0
- package/dist/types/integrations/react-hook-form/components/{Controller/Controller.d.ts → Field/Field.d.ts} +2 -2
- package/dist/types/integrations/react-hook-form/components/Field/index.d.ts +4 -0
- package/dist/types/integrations/react-hook-form/components/Field/stories/Default.stories.d.ts +7 -0
- package/dist/types/integrations/react-hook-form/components/Form/Form.d.ts +4 -2
- package/dist/types/integrations/react-hook-form/index.d.ts +1 -1
- package/package.json +4 -4
- package/dist/types/integrations/react-hook-form/components/Controller/index.d.ts +0 -4
- package/dist/types/integrations/react-hook-form/components/Controller/stories/Default.stories.d.ts +0 -7
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import
|
|
7
|
-
import { makeObservable as
|
|
8
|
-
import { u as
|
|
9
|
-
import
|
|
10
|
-
import { u as
|
|
11
|
-
import { a as
|
|
3
|
+
var B = Object.defineProperty;
|
|
4
|
+
var k = (o, t, e) => t in o ? B(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
5
|
+
var r = (o, t, e) => (k(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
6
|
+
import w, { createContext as M, useRef as O, useContext as b } from "react";
|
|
7
|
+
import { makeObservable as I, observable as E, action as D, computed as T } from "mobx";
|
|
8
|
+
import { u as g } from "./useOverlayController-CGKumeGL.js";
|
|
9
|
+
import N from "invariant";
|
|
10
|
+
import { u as v } from "./useSelector-DpU7_HMO.js";
|
|
11
|
+
import { a as R, g as V, u as $ } from "./getActionGroupSlot-Do-bk4GU.js";
|
|
12
12
|
import "./propsContext-DzAKlmhS.js";
|
|
13
|
-
import { P as
|
|
13
|
+
import { P as G } from "./PropsContextProvider-C6Z4XGp6.js";
|
|
14
14
|
import "@react-aria/utils";
|
|
15
15
|
import "remeda";
|
|
16
16
|
import { d as u } from "./dynamic-ClpUSmEt.js";
|
|
17
|
-
import { u as
|
|
18
|
-
const
|
|
17
|
+
import { u as L } from "./slotContext-DoCFkzCA.js";
|
|
18
|
+
const C = M(void 0), U = C.Provider, x = (o) => new Promise((t) => setTimeout(t, o)), p = {
|
|
19
19
|
pending: 1e3,
|
|
20
20
|
succeeded: 1500,
|
|
21
21
|
failed: 2e3
|
|
22
22
|
};
|
|
23
|
-
class
|
|
23
|
+
class y {
|
|
24
24
|
constructor() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
state:
|
|
32
|
-
updateState:
|
|
33
|
-
isBusy:
|
|
25
|
+
r(this, "showFeedback");
|
|
26
|
+
r(this, "state", "isIdle");
|
|
27
|
+
r(this, "setPendingTimeout");
|
|
28
|
+
r(this, "error");
|
|
29
|
+
r(this, "isAsync", !1);
|
|
30
|
+
I(this, {
|
|
31
|
+
state: E,
|
|
32
|
+
updateState: D,
|
|
33
|
+
isBusy: T
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
static useNew() {
|
|
37
|
-
return
|
|
37
|
+
return O(new y()).current;
|
|
38
38
|
}
|
|
39
39
|
updateState(t) {
|
|
40
40
|
this.state = t;
|
|
41
41
|
}
|
|
42
42
|
useValue() {
|
|
43
|
-
return
|
|
43
|
+
return v(() => this.state, [this]);
|
|
44
44
|
}
|
|
45
45
|
useIsBusy() {
|
|
46
|
-
return
|
|
46
|
+
return v(() => this.isBusy, [this]);
|
|
47
47
|
}
|
|
48
48
|
get isBusy() {
|
|
49
49
|
return this.state !== "isIdle";
|
|
@@ -51,7 +51,7 @@ class C {
|
|
|
51
51
|
onAsyncStart() {
|
|
52
52
|
this.isAsync = !0, this.updateState("isExecuting"), this.setPendingTimeout = window.setTimeout(
|
|
53
53
|
() => this.startPending(),
|
|
54
|
-
|
|
54
|
+
p.pending
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
async onSucceeded() {
|
|
@@ -64,10 +64,10 @@ class C {
|
|
|
64
64
|
return this.showFeedback = t, this;
|
|
65
65
|
}
|
|
66
66
|
async startFailedFeedback() {
|
|
67
|
-
this.updateState("isFailed"), await
|
|
67
|
+
this.updateState("isFailed"), await x(p.failed), this.resetAfterDone();
|
|
68
68
|
}
|
|
69
69
|
async startSucceededFeedback() {
|
|
70
|
-
this.updateState("isSucceeded"), await
|
|
70
|
+
this.updateState("isSucceeded"), await x(p.succeeded), this.resetAfterDone();
|
|
71
71
|
}
|
|
72
72
|
resetAfterDone() {
|
|
73
73
|
this.updateState("isIdle"), this.isAsync = !1, this.error = void 0;
|
|
@@ -79,44 +79,44 @@ class C {
|
|
|
79
79
|
this.updateState("isPending");
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const F = (o) => (...t) => {
|
|
83
83
|
const e = [...o], n = e.shift();
|
|
84
84
|
if (n) {
|
|
85
|
-
const s = n(...t),
|
|
86
|
-
return s instanceof Promise ? s.then(
|
|
85
|
+
const s = n(...t), a = () => e.length === 0 ? s : F(e)(...t);
|
|
86
|
+
return s instanceof Promise ? s.then(a) : a();
|
|
87
87
|
}
|
|
88
88
|
}, d = () => {
|
|
89
|
-
},
|
|
89
|
+
}, j = (o, t = {}) => {
|
|
90
90
|
const {
|
|
91
91
|
onSync: e = d,
|
|
92
92
|
onAsync: n = d,
|
|
93
93
|
then: s = d,
|
|
94
|
-
catch:
|
|
94
|
+
catch: a = d,
|
|
95
95
|
finally: c = d
|
|
96
96
|
} = t;
|
|
97
97
|
try {
|
|
98
|
-
const
|
|
99
|
-
return
|
|
100
|
-
} catch (
|
|
101
|
-
e(), i
|
|
98
|
+
const i = o();
|
|
99
|
+
return i instanceof Promise ? (n(), i.then(s).catch(a).finally(c)) : (e(), s(i), c(), i);
|
|
100
|
+
} catch (i) {
|
|
101
|
+
e(), a(i), c();
|
|
102
102
|
}
|
|
103
|
-
},
|
|
103
|
+
}, q = () => {
|
|
104
104
|
};
|
|
105
|
-
function
|
|
105
|
+
function z(o) {
|
|
106
106
|
if (o.needsConfirmation)
|
|
107
107
|
return o.confirmationModalController.open;
|
|
108
108
|
const t = o.getOverlayController(), {
|
|
109
109
|
action: e,
|
|
110
110
|
toggleOverlay: n,
|
|
111
111
|
closeOverlay: s,
|
|
112
|
-
openOverlay:
|
|
112
|
+
openOverlay: a
|
|
113
113
|
} = o.actionProps;
|
|
114
|
-
return e || (
|
|
114
|
+
return e || (a && t ? t.open : s && t || n && t ? t.close : q);
|
|
115
115
|
}
|
|
116
|
-
class
|
|
116
|
+
class P {
|
|
117
117
|
constructor(t) {
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
r(this, "actions", []);
|
|
119
|
+
r(this, "baseAction");
|
|
120
120
|
this.baseAction = t;
|
|
121
121
|
}
|
|
122
122
|
addAction(t) {
|
|
@@ -127,42 +127,42 @@ class v {
|
|
|
127
127
|
return;
|
|
128
128
|
const e = this.actions[this.actions.length - 1].actionProps.showFeedback, n = this.baseAction.state.withFeedback(
|
|
129
129
|
this.baseAction.needsConfirmation ? !1 : e
|
|
130
|
-
), s = this.actions.map((
|
|
130
|
+
), s = this.actions.map((i) => z(i)), a = F(s);
|
|
131
131
|
let c;
|
|
132
|
-
if (await
|
|
132
|
+
if (await j(() => a(...t), {
|
|
133
133
|
onAsync: () => n.onAsyncStart(),
|
|
134
134
|
then: () => n.onSucceeded(),
|
|
135
|
-
catch: (
|
|
136
|
-
n.onFailed(
|
|
135
|
+
catch: (i) => {
|
|
136
|
+
n.onFailed(i), c = i;
|
|
137
137
|
}
|
|
138
138
|
}), c)
|
|
139
139
|
throw c;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
class
|
|
142
|
+
class H {
|
|
143
143
|
constructor(t) {
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
r(this, "action");
|
|
145
|
+
r(this, "execute", (...t) => {
|
|
146
146
|
const e = this.getBatchedActions();
|
|
147
147
|
(async () => {
|
|
148
148
|
for (const s of e)
|
|
149
149
|
await s.executeBatch(t);
|
|
150
150
|
})().catch((s) => console.error(s));
|
|
151
151
|
});
|
|
152
|
-
|
|
152
|
+
r(this, "getBatchedActions", () => {
|
|
153
153
|
let t = this.action;
|
|
154
154
|
const e = [];
|
|
155
|
-
let n = new
|
|
155
|
+
let n = new P(
|
|
156
156
|
this.action
|
|
157
157
|
), s = 0;
|
|
158
158
|
for (; t; ) {
|
|
159
|
-
const { action:
|
|
159
|
+
const { action: a, break: c, skip: i } = t.actionProps;
|
|
160
160
|
if (t.needsConfirmation) {
|
|
161
161
|
n.addAction(t);
|
|
162
162
|
break;
|
|
163
163
|
}
|
|
164
|
-
if (
|
|
165
|
-
s =
|
|
164
|
+
if (i) {
|
|
165
|
+
s = i === !0 ? 1 : i, t = t.parentAction;
|
|
166
166
|
continue;
|
|
167
167
|
}
|
|
168
168
|
if (s > 0) {
|
|
@@ -171,7 +171,7 @@ class q {
|
|
|
171
171
|
}
|
|
172
172
|
if (c)
|
|
173
173
|
break;
|
|
174
|
-
|
|
174
|
+
a || (e.push(n), n = new P(this.action)), n.addAction(t), t = t.parentAction;
|
|
175
175
|
}
|
|
176
176
|
return e.push(n), e;
|
|
177
177
|
});
|
|
@@ -180,31 +180,31 @@ class q {
|
|
|
180
180
|
}
|
|
181
181
|
class l {
|
|
182
182
|
constructor(t) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
new
|
|
183
|
+
r(this, "state");
|
|
184
|
+
r(this, "needsConfirmation");
|
|
185
|
+
r(this, "actionProps");
|
|
186
|
+
r(this, "parentAction");
|
|
187
|
+
r(this, "confirmationModalController");
|
|
188
|
+
r(this, "overlayController");
|
|
189
|
+
r(this, "execute", (...t) => {
|
|
190
|
+
new H(this).execute(...t);
|
|
191
191
|
});
|
|
192
192
|
const {
|
|
193
193
|
actionProps: e,
|
|
194
194
|
needsConfirmation: n,
|
|
195
195
|
parentAction: s,
|
|
196
|
-
overlayController:
|
|
196
|
+
overlayController: a,
|
|
197
197
|
confirmationModalController: c,
|
|
198
|
-
state:
|
|
198
|
+
state: i
|
|
199
199
|
} = t;
|
|
200
|
-
this.actionProps = e, this.parentAction = s, this.confirmationModalController = c, this.needsConfirmation = n, this.overlayController =
|
|
200
|
+
this.actionProps = e, this.parentAction = s, this.confirmationModalController = c, this.needsConfirmation = n, this.overlayController = a, this.state = i;
|
|
201
201
|
}
|
|
202
202
|
static useNew(t, e = {}) {
|
|
203
|
-
const n =
|
|
203
|
+
const n = b(C), s = g(), a = g(), c = y.useNew();
|
|
204
204
|
return new l({
|
|
205
205
|
parentAction: n,
|
|
206
206
|
overlayController: s,
|
|
207
|
-
confirmationModalController:
|
|
207
|
+
confirmationModalController: a,
|
|
208
208
|
needsConfirmation: !1,
|
|
209
209
|
actionProps: t,
|
|
210
210
|
state: c,
|
|
@@ -212,8 +212,8 @@ class l {
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
static use() {
|
|
215
|
-
const t =
|
|
216
|
-
return
|
|
215
|
+
const t = b(C);
|
|
216
|
+
return N(!!t, "Action context is not defined"), R.useRegisterState(t.state), t;
|
|
217
217
|
}
|
|
218
218
|
static useConfirmationAction() {
|
|
219
219
|
const t = l.use();
|
|
@@ -238,49 +238,50 @@ class l {
|
|
|
238
238
|
return t(this.actionProps.openOverlay) ?? t(this.actionProps.closeOverlay) ?? t(this.actionProps.toggleOverlay);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
const
|
|
242
|
-
const t = l.use(), e = t.state.useValue(), n =
|
|
241
|
+
const J = (o) => L()[o], A = (o) => J("Modal") === "actionConfirm" ? V(o) : void 0, f = (o) => {
|
|
242
|
+
const t = l.use(), e = t.state.useValue(), n = A(o) === "primary", s = t.confirmationModalController.useIsOpen();
|
|
243
243
|
return t.needsConfirmation && s && !n ? "isIdle" : e;
|
|
244
|
-
},
|
|
244
|
+
}, S = {
|
|
245
245
|
onPress: u((o) => {
|
|
246
|
-
const t = l.use(), e = l.useConfirmationAction(), n =
|
|
247
|
-
return
|
|
246
|
+
const t = l.use(), e = l.useConfirmationAction(), n = A(o) === "primary";
|
|
247
|
+
return A(o) === "abort" ? t.confirmationModalController.close : n ? e.execute : t.execute;
|
|
248
248
|
}),
|
|
249
|
-
isPending: u((o) =>
|
|
249
|
+
isPending: u((o) => f(o) === "isPending"),
|
|
250
250
|
isSucceeded: u(
|
|
251
|
-
(o) =>
|
|
251
|
+
(o) => f(o) === "isSucceeded"
|
|
252
252
|
),
|
|
253
|
-
isFailed: u((o) =>
|
|
253
|
+
isFailed: u((o) => f(o) === "isFailed"),
|
|
254
254
|
"aria-disabled": u((o) => {
|
|
255
|
-
const t =
|
|
255
|
+
const t = f(o), e = $().useIsBusy();
|
|
256
256
|
return t === "isExecuting" || e;
|
|
257
257
|
})
|
|
258
|
-
},
|
|
259
|
-
const { children: t,
|
|
260
|
-
Button:
|
|
258
|
+
}, rt = (o) => {
|
|
259
|
+
const { children: t, actionModel: e, ...n } = o, s = l.useNew(n), a = e ?? s, c = {
|
|
260
|
+
Button: S,
|
|
261
261
|
Link: {
|
|
262
262
|
onPress: u(() => l.use().execute)
|
|
263
263
|
},
|
|
264
264
|
Modal: {
|
|
265
265
|
slot: u((i) => {
|
|
266
|
-
const { slot:
|
|
267
|
-
return
|
|
266
|
+
const { slot: m } = i, h = l.use();
|
|
267
|
+
return h.needsConfirmation = m === "actionConfirm", m;
|
|
268
268
|
}),
|
|
269
269
|
isDismissable: u((i) => {
|
|
270
|
-
const
|
|
271
|
-
return
|
|
270
|
+
const h = l.use().state.useValue();
|
|
271
|
+
return h === "isExecuting" || h === "isPending" ? !1 : i.isDismissable;
|
|
272
272
|
}),
|
|
273
273
|
controller: u(() => {
|
|
274
274
|
const i = l.use();
|
|
275
275
|
return i.needsConfirmation ? i.confirmationModalController : i.getOverlayController();
|
|
276
276
|
}),
|
|
277
277
|
ActionGroup: {
|
|
278
|
-
Button:
|
|
278
|
+
Button: S
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
};
|
|
282
|
-
return /* @__PURE__ */
|
|
282
|
+
return /* @__PURE__ */ w.createElement(U, { value: a }, /* @__PURE__ */ w.createElement(G, { props: c, mergeInParentContext: !0 }, t));
|
|
283
283
|
};
|
|
284
284
|
export {
|
|
285
|
-
|
|
285
|
+
rt as A,
|
|
286
|
+
l as a
|
|
286
287
|
};
|
package/dist/Action.js
CHANGED
package/dist/CopyButton.js
CHANGED
|
@@ -15,7 +15,7 @@ import "@react-aria/utils";
|
|
|
15
15
|
import "remeda";
|
|
16
16
|
import "dot-prop";
|
|
17
17
|
import { f as C } from "./flowComponent-CPKCCJEg.js";
|
|
18
|
-
import { A as E } from "./Action-
|
|
18
|
+
import { A as E } from "./Action-C4Ncwjzf.js";
|
|
19
19
|
const B = {
|
|
20
20
|
"de-DE": {
|
|
21
21
|
"copyButton.copy": "Kopieren"
|
package/dist/OffCanvas.js
CHANGED
|
@@ -6,7 +6,7 @@ import { B as f } from "./Button-BPAhEOTg.js";
|
|
|
6
6
|
import "@tabler/icons-react";
|
|
7
7
|
import "./Icon-D4bkU_pz.js";
|
|
8
8
|
import { I as m } from "./IconClose-FTrJdf_N.js";
|
|
9
|
-
import { A as i } from "./Action-
|
|
9
|
+
import { A as i } from "./Action-C4Ncwjzf.js";
|
|
10
10
|
import { M as p } from "./ModalOverlay-BSu4UEnW.js";
|
|
11
11
|
import "./propsContext-DzAKlmhS.js";
|
|
12
12
|
import { P as v } from "./PropsContextProvider-C6Z4XGp6.js";
|
package/dist/RadioGroup.js
CHANGED
|
@@ -4,15 +4,15 @@ import e from "react";
|
|
|
4
4
|
import * as R from "react-aria-components";
|
|
5
5
|
import E from "clsx";
|
|
6
6
|
import "./propsContext-DzAKlmhS.js";
|
|
7
|
-
import { P as C, m as
|
|
7
|
+
import { P as C, m as I } from "./PropsContextProvider-C6Z4XGp6.js";
|
|
8
8
|
import "@react-aria/utils";
|
|
9
9
|
import "remeda";
|
|
10
|
-
import { d as
|
|
11
|
-
import { F as
|
|
12
|
-
import { C as
|
|
13
|
-
import { TunnelProvider as
|
|
10
|
+
import { d as P } from "./dynamic-ClpUSmEt.js";
|
|
11
|
+
import { F as b } from "./FieldError-D_VRyiJG.js";
|
|
12
|
+
import { C as k } from "./ColumnLayout-FMONjI17.js";
|
|
13
|
+
import { TunnelProvider as y, TunnelExit as m } from "@mittwald/react-tunnel";
|
|
14
14
|
import { s as c } from "./FormField.module-DHK6nIcD.js";
|
|
15
|
-
import { d as
|
|
15
|
+
import { d as F } from "./deepFindOfType-6pG0fH7S.js";
|
|
16
16
|
import { C as w } from "./ClearPropsContext-CUvsbMn8.js";
|
|
17
17
|
import "@tabler/icons-react";
|
|
18
18
|
import "./Icon-D4bkU_pz.js";
|
|
@@ -70,17 +70,30 @@ const T = "flow--radio-group", O = "flow--radio-group--segmented-group", $ = "fl
|
|
|
70
70
|
tunnelId: "radios"
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
-
o === "segmented" && (p =
|
|
73
|
+
o === "segmented" && (p = I(p, {
|
|
74
74
|
Radio: {
|
|
75
75
|
className: a.segment,
|
|
76
76
|
unstyled: !0,
|
|
77
|
-
children:
|
|
77
|
+
children: P((x) => /* @__PURE__ */ e.createElement(e.Fragment, null, x.children, /* @__PURE__ */ e.createElement(D, { className: a.checkmark })))
|
|
78
78
|
}
|
|
79
79
|
}));
|
|
80
|
-
const u = !!
|
|
80
|
+
const u = !!F(t, H);
|
|
81
81
|
return o === "segmented" && u && console.warn(
|
|
82
82
|
"<RadioButton/> is not supported in 'segmented' variant of <RadioGroup />"
|
|
83
|
-
), /* @__PURE__ */ e.createElement(R.RadioGroup, { ...h, className: G, ref: d }, /* @__PURE__ */ e.createElement(
|
|
83
|
+
), /* @__PURE__ */ e.createElement(R.RadioGroup, { ...h, className: G, ref: d }, /* @__PURE__ */ e.createElement(y, null, /* @__PURE__ */ e.createElement(
|
|
84
|
+
C,
|
|
85
|
+
{
|
|
86
|
+
props: p,
|
|
87
|
+
dependencies: [o],
|
|
88
|
+
mergeInParentContext: !0
|
|
89
|
+
},
|
|
90
|
+
t,
|
|
91
|
+
o === "segmented" && /* @__PURE__ */ e.createElement("div", { className: a.segmentedGroup }, /* @__PURE__ */ e.createElement("div", { className: a.segments }, /* @__PURE__ */ e.createElement(m, { id: "radios" }))),
|
|
92
|
+
o === "default" && u && /* @__PURE__ */ e.createElement(k, { s, m: l, l: i, className: a.radioGroup }, /* @__PURE__ */ e.createElement(m, { id: "radios" })),
|
|
93
|
+
o === "default" && !u && /* @__PURE__ */ e.createElement("div", { className: a.radioGroup }, /* @__PURE__ */ e.createElement(m, { id: "radios" })),
|
|
94
|
+
/* @__PURE__ */ e.createElement(m, { id: "fieldDescription" }),
|
|
95
|
+
/* @__PURE__ */ e.createElement(m, { id: "fieldError" })
|
|
96
|
+
)), /* @__PURE__ */ e.createElement(b, { className: c.fieldError }));
|
|
84
97
|
}), J = "flow--radio-group--radio", K = "flow--radio-group--radio--icon", g = {
|
|
85
98
|
radio: J,
|
|
86
99
|
icon: K
|
package/dist/Section.js
CHANGED
|
@@ -14,10 +14,10 @@ const u = "flow--section", h = "flow--section--header", w = "flow--section--stat
|
|
|
14
14
|
switch: "flow--section--switch",
|
|
15
15
|
statusBadge: w
|
|
16
16
|
}, A = d("Section", (o) => {
|
|
17
|
-
const { children: s, className:
|
|
17
|
+
const { children: s, className: r, isActive: a = !0, refProp: c, ...n } = o;
|
|
18
18
|
if (!s)
|
|
19
19
|
return null;
|
|
20
|
-
const
|
|
20
|
+
const i = m(e.section, r), l = {
|
|
21
21
|
Heading: {
|
|
22
22
|
level: 2
|
|
23
23
|
},
|
|
@@ -32,7 +32,7 @@ const u = "flow--section", h = "flow--section--header", w = "flow--section--stat
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
return /* @__PURE__ */ t.createElement(f, { isActive:
|
|
35
|
+
return /* @__PURE__ */ t.createElement(f, { isActive: a }, /* @__PURE__ */ t.createElement("section", { ...n, className: i, ref: c }, /* @__PURE__ */ t.createElement(p, { props: l, mergeInParentContext: !0 }, s)));
|
|
36
36
|
});
|
|
37
37
|
export {
|
|
38
38
|
A as Section,
|
package/dist/react-hook-form.js
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import
|
|
4
|
-
import { Controller as
|
|
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";
|
|
5
5
|
import "./propsContext-DzAKlmhS.js";
|
|
6
|
-
import { P as
|
|
6
|
+
import { P as k } from "./PropsContextProvider-C6Z4XGp6.js";
|
|
7
7
|
import "@react-aria/utils";
|
|
8
8
|
import "remeda";
|
|
9
9
|
import { d as E } from "./dynamic-ClpUSmEt.js";
|
|
10
|
-
import { F as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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) {
|
|
14
|
+
var r;
|
|
15
|
+
const { children: t, control: i, ...n } = c, a = (r = y().form) == null ? void 0 : r.control;
|
|
16
|
+
return /* @__PURE__ */ o.createElement(
|
|
17
|
+
x,
|
|
17
18
|
{
|
|
18
|
-
...
|
|
19
|
-
control: i ??
|
|
20
|
-
render: (
|
|
21
|
-
var
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
...n,
|
|
20
|
+
control: i ?? a,
|
|
21
|
+
render: (s) => {
|
|
22
|
+
var u;
|
|
23
|
+
const {
|
|
24
|
+
field: d,
|
|
25
|
+
fieldState: { error: l, invalid: m }
|
|
26
|
+
} = s, e = {
|
|
27
|
+
...d,
|
|
28
|
+
isRequired: !!((u = n.rules) != null && u.required),
|
|
29
|
+
isInvalid: m,
|
|
26
30
|
validationBehavior: "aria",
|
|
27
|
-
children: E((
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, C = {
|
|
31
|
+
children: E((p) => /* @__PURE__ */ o.createElement(o.Fragment, null, p.children, /* @__PURE__ */ o.createElement(g, null, l == null ? void 0 : l.message))),
|
|
32
|
+
ref: void 0,
|
|
33
|
+
refProp: d.ref
|
|
34
|
+
}, f = {
|
|
32
35
|
Checkbox: e,
|
|
33
36
|
CheckboxGroup: e,
|
|
34
37
|
CheckboxButton: e,
|
|
@@ -40,25 +43,56 @@ function g(o) {
|
|
|
40
43
|
Select: e,
|
|
41
44
|
Slider: e
|
|
42
45
|
};
|
|
43
|
-
return /* @__PURE__ */
|
|
44
|
-
|
|
46
|
+
return /* @__PURE__ */ o.createElement(
|
|
47
|
+
k,
|
|
45
48
|
{
|
|
46
|
-
props:
|
|
47
|
-
dependencies: [
|
|
49
|
+
props: f,
|
|
50
|
+
dependencies: [s]
|
|
48
51
|
},
|
|
49
|
-
|
|
52
|
+
t
|
|
50
53
|
);
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
);
|
|
54
57
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const O = (c) => I, D = (c) => {
|
|
59
|
+
const { isStarted: t, hasFailedWithError: i, hasSucceeded: n, children: a } = c, r = P.useNew({});
|
|
60
|
+
return h(() => {
|
|
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);
|
|
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(() => {
|
|
67
|
+
s && r && t.reset(void 0, {
|
|
68
|
+
keepIsSubmitted: !1,
|
|
69
|
+
keepIsSubmitSuccessful: !1,
|
|
70
|
+
keepDefaultValues: !0,
|
|
71
|
+
keepValues: !0,
|
|
72
|
+
keepDirtyValues: !0,
|
|
73
|
+
keepIsValid: !0,
|
|
74
|
+
keepDirty: !0,
|
|
75
|
+
keepErrors: !0,
|
|
76
|
+
keepTouched: !0,
|
|
77
|
+
keepIsValidating: !0,
|
|
78
|
+
keepSubmitCount: !0
|
|
79
|
+
});
|
|
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,
|
|
86
|
+
{
|
|
87
|
+
isStarted: d,
|
|
88
|
+
hasFailedWithError: u,
|
|
89
|
+
hasSucceeded: p
|
|
90
|
+
},
|
|
91
|
+
i
|
|
92
|
+
)));
|
|
59
93
|
}
|
|
60
94
|
export {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
95
|
+
I as Field,
|
|
96
|
+
_ as Form,
|
|
97
|
+
O as typedField
|
|
64
98
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { OverlayController } from '../../lib/controller';
|
|
3
|
+
import { ActionModel } from './models/ActionModel';
|
|
3
4
|
|
|
4
5
|
export type ActionFn = (...args: unknown[]) => unknown;
|
|
5
6
|
export interface ActionProps extends PropsWithChildren {
|
|
6
7
|
action?: ActionFn;
|
|
8
|
+
actionModel?: ActionModel;
|
|
7
9
|
closeOverlay?: boolean | OverlayController;
|
|
8
10
|
openOverlay?: boolean | OverlayController;
|
|
9
11
|
toggleOverlay?: boolean | OverlayController;
|
|
@@ -3,6 +3,6 @@ import { ControllerProps, FieldValues, UseFormReturn } from 'react-hook-form';
|
|
|
3
3
|
|
|
4
4
|
interface Props<T extends FieldValues> extends Omit<ControllerProps<T>, "render">, PropsWithChildren {
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
7
|
-
export declare const
|
|
6
|
+
export declare function Field<T extends FieldValues>(props: Props<T>): React.JSX.Element;
|
|
7
|
+
export declare const typedField: <T extends FieldValues>(ignoredForm: UseFormReturn<T>) => typeof Field<T>;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ComponentProps, PropsWithChildren, default as React } from 'react';
|
|
2
2
|
import { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export type FormOnSubmitHandler<F extends FieldValues> = Parameters<UseFormReturn<F>["handleSubmit"]>[0];
|
|
5
|
+
interface Props<F extends FieldValues> extends Omit<ComponentProps<"form">, "onSubmit">, PropsWithChildren {
|
|
6
|
+
form: UseFormReturn<F>;
|
|
7
|
+
onSubmit: FormOnSubmitHandler<F>;
|
|
6
8
|
}
|
|
7
9
|
export declare function Form<F extends FieldValues>(props: Props<F>): React.JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './components/
|
|
1
|
+
export * from './components/Field';
|
|
2
2
|
export * from './components/Form';
|
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.140",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
},
|
|
276
276
|
"dependencies": {
|
|
277
277
|
"@chakra-ui/live-region": "^2.1.0",
|
|
278
|
-
"@mittwald/react-tunnel": "^0.1.0-alpha.
|
|
278
|
+
"@mittwald/react-tunnel": "^0.1.0-alpha.140",
|
|
279
279
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
280
280
|
"@react-aria/utils": "^3.24.1",
|
|
281
281
|
"@react-types/shared": "^3.23.1",
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
},
|
|
303
303
|
"devDependencies": {
|
|
304
304
|
"@faker-js/faker": "^8.4.1",
|
|
305
|
-
"@mittwald/flow-design-tokens": "^0.1.0-alpha.
|
|
305
|
+
"@mittwald/flow-design-tokens": "^0.1.0-alpha.140",
|
|
306
306
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
307
307
|
"@nx/storybook": "^19.1.2",
|
|
308
308
|
"@storybook/addon-a11y": "^8.1.5",
|
|
@@ -378,5 +378,5 @@
|
|
|
378
378
|
"optional": true
|
|
379
379
|
}
|
|
380
380
|
},
|
|
381
|
-
"gitHead": "
|
|
381
|
+
"gitHead": "e617717a9569b093c1f19f0923ebf6dce8157c4b"
|
|
382
382
|
}
|