@mittwald/flow-react-components 0.1.0-alpha.127 → 0.1.0-alpha.129
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-BPEu-X47.js +322 -0
- package/dist/Action.js +1 -1
- package/dist/ActionStateContext-B4ZIqu_K.js +55 -0
- package/dist/CopyButton.js +1 -1
- package/dist/Modal.js +8 -7
- package/dist/OffCanvas.js +1 -1
- package/dist/OverlayTrigger.js +9 -9
- package/dist/types/components/Action/components/ActionGroup.d.ts +4 -0
- package/dist/types/components/Action/components/{ConfirmationModal.d.ts → ActionModal.d.ts} +1 -1
- package/dist/types/components/Action/context.d.ts +3 -14
- package/dist/types/components/Action/lib/ariaLive.d.ts +1 -1
- package/dist/types/components/Action/models/ActionExecution.d.ts +8 -0
- package/dist/types/components/Action/models/ActionExecutionBatch.d.ts +9 -0
- package/dist/types/components/Action/models/ActionModel.d.ts +27 -0
- package/dist/types/components/Action/models/ActionState.d.ts +23 -0
- package/dist/types/components/Action/models/ActionStateContext.d.ts +15 -0
- package/dist/types/components/Action/models/getExecutionFunction.d.ts +4 -0
- package/dist/types/components/Action/types.d.ts +1 -0
- package/package.json +4 -4
- package/dist/Action-BLnSsHE1.js +0 -233
- package/dist/context-D3hdrTHO.js +0 -58
- package/dist/types/components/Action/lib/execution/ActionExecution.d.ts +0 -26
- package/dist/types/components/Action/lib/execution/ActionState.d.ts +0 -8
- package/dist/types/components/Action/lib/execution/context.d.ts +0 -4
- package/dist/types/components/Action/lib/execution/useActionController.d.ts +0 -9
- package/dist/types/components/Action/lib/execution/useActionController.test.d.ts +0 -1
- /package/dist/types/components/Action/{lib/execution/ActionExecution.test.d.ts → models/ActionExecutionBatch.test.d.ts} +0 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
var F = Object.defineProperty;
|
|
4
|
+
var P = (o, t, e) => t in o ? F(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
5
|
+
var a = (o, t, e) => (P(o, typeof t != "symbol" ? t + "" : t, e), e);
|
|
6
|
+
import r, { useRef as S, useContext as p } from "react";
|
|
7
|
+
import { makeObservable as k, observable as O, action as I, computed as M } from "mobx";
|
|
8
|
+
import { u as C } from "./useOverlayController-CGKumeGL.js";
|
|
9
|
+
import D from "invariant";
|
|
10
|
+
import { A as T, a as A, u as N, b as w, c as R } from "./ActionStateContext-B4ZIqu_K.js";
|
|
11
|
+
import { u as y } from "./useSelector-DpU7_HMO.js";
|
|
12
|
+
import "./propsContext-CauylOgH.js";
|
|
13
|
+
import { P as h } from "./PropsContextProvider-ChpH8eF2.js";
|
|
14
|
+
import "@react-aria/utils";
|
|
15
|
+
import "remeda";
|
|
16
|
+
import { W as v } from "./Wrap-DGT1h1o3.js";
|
|
17
|
+
const x = (o) => new Promise((t) => setTimeout(t, o)), m = {
|
|
18
|
+
pending: 1e3,
|
|
19
|
+
succeeded: 1500,
|
|
20
|
+
failed: 2e3
|
|
21
|
+
};
|
|
22
|
+
class f {
|
|
23
|
+
constructor() {
|
|
24
|
+
a(this, "showFeedback");
|
|
25
|
+
a(this, "state", "isIdle");
|
|
26
|
+
a(this, "setPendingTimeout");
|
|
27
|
+
a(this, "error");
|
|
28
|
+
a(this, "isAsync", !1);
|
|
29
|
+
k(this, {
|
|
30
|
+
state: O,
|
|
31
|
+
updateState: I,
|
|
32
|
+
isBusy: M
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
static useNew() {
|
|
36
|
+
const t = S(new f()).current;
|
|
37
|
+
return T.useRegisterState(t), t;
|
|
38
|
+
}
|
|
39
|
+
updateState(t) {
|
|
40
|
+
this.state = t;
|
|
41
|
+
}
|
|
42
|
+
useValue() {
|
|
43
|
+
return y(() => this.state, [this]);
|
|
44
|
+
}
|
|
45
|
+
useIsBusy() {
|
|
46
|
+
return y(() => this.isBusy, [this]);
|
|
47
|
+
}
|
|
48
|
+
get isBusy() {
|
|
49
|
+
return this.state === "isExecuting" || this.state === "isPending";
|
|
50
|
+
}
|
|
51
|
+
onAsyncStart() {
|
|
52
|
+
this.isAsync = !0, this.updateState("isExecuting"), this.setPendingTimeout = window.setTimeout(
|
|
53
|
+
() => this.startPending(),
|
|
54
|
+
m.pending
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
async onSucceeded() {
|
|
58
|
+
await this.onDone();
|
|
59
|
+
}
|
|
60
|
+
async onFailed(t) {
|
|
61
|
+
this.error = t ?? new Error("Unknown error"), await this.onDone();
|
|
62
|
+
}
|
|
63
|
+
withFeedback(t) {
|
|
64
|
+
return this.showFeedback = t, this;
|
|
65
|
+
}
|
|
66
|
+
async startFailedFeedback() {
|
|
67
|
+
this.updateState("isFailed"), await x(m.failed), this.resetAfterDone();
|
|
68
|
+
}
|
|
69
|
+
async startSucceededFeedback() {
|
|
70
|
+
this.updateState("isSucceeded"), await x(m.succeeded), this.resetAfterDone();
|
|
71
|
+
}
|
|
72
|
+
resetAfterDone() {
|
|
73
|
+
this.updateState("isIdle"), this.isAsync = !1, this.error = void 0;
|
|
74
|
+
}
|
|
75
|
+
async onDone() {
|
|
76
|
+
this.setPendingTimeout && window.clearTimeout(this.setPendingTimeout), this.error ? await this.startFailedFeedback() : this.showFeedback !== !1 && (this.showFeedback || this.isAsync) ? await this.startSucceededFeedback() : this.resetAfterDone();
|
|
77
|
+
}
|
|
78
|
+
startPending() {
|
|
79
|
+
this.updateState("isPending");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const E = (o) => (...t) => {
|
|
83
|
+
const e = [...o], n = e.shift();
|
|
84
|
+
if (n) {
|
|
85
|
+
const s = n(...t), i = () => e.length === 0 ? s : E(e)(...t);
|
|
86
|
+
return s instanceof Promise ? s.then(i) : i();
|
|
87
|
+
}
|
|
88
|
+
}, d = () => {
|
|
89
|
+
}, G = (o, t = {}) => {
|
|
90
|
+
const {
|
|
91
|
+
onSync: e = d,
|
|
92
|
+
onAsync: n = d,
|
|
93
|
+
then: s = d,
|
|
94
|
+
catch: i = d,
|
|
95
|
+
finally: l = d
|
|
96
|
+
} = t;
|
|
97
|
+
try {
|
|
98
|
+
const c = o();
|
|
99
|
+
return c instanceof Promise ? (n(), c.then(s).catch(i).finally(l)) : (e(), s(c), l(), c);
|
|
100
|
+
} catch (c) {
|
|
101
|
+
e(), i(c), l();
|
|
102
|
+
}
|
|
103
|
+
}, V = () => {
|
|
104
|
+
};
|
|
105
|
+
function $(o) {
|
|
106
|
+
if (o.needsConfirmation)
|
|
107
|
+
return o.confirmationModalController.open;
|
|
108
|
+
const t = o.getOverlayController(), {
|
|
109
|
+
action: e,
|
|
110
|
+
toggleOverlay: n,
|
|
111
|
+
closeOverlay: s,
|
|
112
|
+
openOverlay: i
|
|
113
|
+
} = o.actionProps;
|
|
114
|
+
return e || (i && t ? t.open : s && t || n && t ? t.close : V);
|
|
115
|
+
}
|
|
116
|
+
class b {
|
|
117
|
+
constructor(t) {
|
|
118
|
+
a(this, "actions", []);
|
|
119
|
+
a(this, "baseAction");
|
|
120
|
+
this.baseAction = t;
|
|
121
|
+
}
|
|
122
|
+
addAction(t) {
|
|
123
|
+
this.actions.push(t);
|
|
124
|
+
}
|
|
125
|
+
async executeBatch(t) {
|
|
126
|
+
if (this.actions.length === 0)
|
|
127
|
+
return;
|
|
128
|
+
const e = this.actions[this.actions.length - 1].actionProps.showFeedback, n = this.baseAction.state.withFeedback(
|
|
129
|
+
this.baseAction.needsConfirmation ? !1 : e
|
|
130
|
+
), s = this.actions.map((c) => $(c)), i = E(s);
|
|
131
|
+
let l;
|
|
132
|
+
if (await G(() => i(...t), {
|
|
133
|
+
onAsync: () => n.onAsyncStart(),
|
|
134
|
+
then: () => n.onSucceeded(),
|
|
135
|
+
catch: (c) => {
|
|
136
|
+
n.onFailed(c), l = c;
|
|
137
|
+
}
|
|
138
|
+
}), l)
|
|
139
|
+
throw l;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class W {
|
|
143
|
+
constructor(t) {
|
|
144
|
+
a(this, "action");
|
|
145
|
+
a(this, "execute", (...t) => {
|
|
146
|
+
const e = this.getBatchedActions();
|
|
147
|
+
(async () => {
|
|
148
|
+
for (const s of e)
|
|
149
|
+
await s.executeBatch(t);
|
|
150
|
+
})().catch((s) => console.error(s));
|
|
151
|
+
});
|
|
152
|
+
a(this, "getBatchedActions", () => {
|
|
153
|
+
let t = this.action;
|
|
154
|
+
const e = [];
|
|
155
|
+
let n = new b(
|
|
156
|
+
this.action
|
|
157
|
+
), s = 0;
|
|
158
|
+
for (; t; ) {
|
|
159
|
+
const { action: i, break: l, skip: c } = t.actionProps;
|
|
160
|
+
if (t.needsConfirmation) {
|
|
161
|
+
n.addAction(t);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (c) {
|
|
165
|
+
s = c === !0 ? 1 : c, t = t.parentAction;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (s > 0) {
|
|
169
|
+
t = t.parentAction, s--;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (l)
|
|
173
|
+
break;
|
|
174
|
+
i || (e.push(n), n = new b(this.action)), n.addAction(t), t = t.parentAction;
|
|
175
|
+
}
|
|
176
|
+
return e.push(n), e;
|
|
177
|
+
});
|
|
178
|
+
this.action = t;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
class u {
|
|
182
|
+
constructor(t) {
|
|
183
|
+
a(this, "state");
|
|
184
|
+
a(this, "needsConfirmation");
|
|
185
|
+
a(this, "actionProps");
|
|
186
|
+
a(this, "parentAction");
|
|
187
|
+
a(this, "confirmationModalController");
|
|
188
|
+
a(this, "overlayController");
|
|
189
|
+
a(this, "execute", (...t) => {
|
|
190
|
+
new W(this).execute(...t);
|
|
191
|
+
});
|
|
192
|
+
const {
|
|
193
|
+
actionProps: e,
|
|
194
|
+
needsConfirmation: n,
|
|
195
|
+
parentAction: s,
|
|
196
|
+
overlayController: i,
|
|
197
|
+
confirmationModalController: l,
|
|
198
|
+
state: c
|
|
199
|
+
} = t;
|
|
200
|
+
this.actionProps = e, this.parentAction = s, this.confirmationModalController = l, this.needsConfirmation = n, this.overlayController = i, this.state = c;
|
|
201
|
+
}
|
|
202
|
+
static useNew(t, e = {}) {
|
|
203
|
+
const n = p(A), s = C(), i = C(), l = f.useNew();
|
|
204
|
+
return new u({
|
|
205
|
+
parentAction: n,
|
|
206
|
+
overlayController: s,
|
|
207
|
+
confirmationModalController: i,
|
|
208
|
+
needsConfirmation: !1,
|
|
209
|
+
actionProps: t,
|
|
210
|
+
state: l,
|
|
211
|
+
...e
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
static use() {
|
|
215
|
+
const t = p(A);
|
|
216
|
+
return D(!!t, "Action context is not defined"), t;
|
|
217
|
+
}
|
|
218
|
+
static useConfirmationAction() {
|
|
219
|
+
const t = u.use();
|
|
220
|
+
return new u({
|
|
221
|
+
actionProps: t.actionProps,
|
|
222
|
+
confirmationModalController: t.confirmationModalController,
|
|
223
|
+
overlayController: t.overlayController,
|
|
224
|
+
state: t.state,
|
|
225
|
+
needsConfirmation: !1,
|
|
226
|
+
parentAction: u.useNew(
|
|
227
|
+
{
|
|
228
|
+
closeOverlay: !0
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
parentAction: t.parentAction
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
getOverlayController() {
|
|
237
|
+
const t = (e) => e === void 0 ? void 0 : e === !0 ? this.overlayController : e === !1 ? void 0 : e;
|
|
238
|
+
return t(this.actionProps.openOverlay) ?? t(this.actionProps.closeOverlay) ?? t(this.actionProps.toggleOverlay);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const B = (o, t) => {
|
|
242
|
+
const e = u.use(), n = e.state.useValue(), s = N().useIsBusy();
|
|
243
|
+
return e.confirmationModalController.useIsOpen() && e.needsConfirmation ? /* @__PURE__ */ r.createElement(o, { ...t, onPress: e.execute }) : /* @__PURE__ */ r.createElement(
|
|
244
|
+
o,
|
|
245
|
+
{
|
|
246
|
+
onPress: e.execute,
|
|
247
|
+
isPending: n === "isPending",
|
|
248
|
+
"aria-disabled": n === "isExecuting" || s,
|
|
249
|
+
isSucceeded: n === "isSucceeded",
|
|
250
|
+
isFailed: n === "isFailed",
|
|
251
|
+
...t
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
}, L = (o, t) => {
|
|
255
|
+
const e = u.use(), n = e.state.useValue();
|
|
256
|
+
return e.needsConfirmation ? /* @__PURE__ */ r.createElement(o, { ...t, onPress: e.execute }) : /* @__PURE__ */ r.createElement(
|
|
257
|
+
o,
|
|
258
|
+
{
|
|
259
|
+
...t,
|
|
260
|
+
onPress: e.execute,
|
|
261
|
+
"aria-disabled": n !== "isIdle"
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}, U = (o, t) => {
|
|
265
|
+
const e = u.useConfirmationAction(), n = t.color === "secondary";
|
|
266
|
+
if (!(t.color === "primary" || t.color === "danger" || t.color === "accent") && !n)
|
|
267
|
+
return /* @__PURE__ */ r.createElement(o, { ...t });
|
|
268
|
+
const i = { Button: { render: B } };
|
|
269
|
+
return n ? /* @__PURE__ */ r.createElement(h, { props: i, mergeInParentContext: !0 }, /* @__PURE__ */ r.createElement(g, { break: !0 }, /* @__PURE__ */ r.createElement(g, { closeOverlay: !0 }, /* @__PURE__ */ r.createElement(o, { ...t })))) : /* @__PURE__ */ r.createElement(h, { props: i, mergeInParentContext: !0 }, /* @__PURE__ */ r.createElement(w, { value: e }, /* @__PURE__ */ r.createElement(o, { ...t })));
|
|
270
|
+
}, j = (o, t) => {
|
|
271
|
+
const e = u.use();
|
|
272
|
+
e.needsConfirmation = t.slot === "actionConfirm";
|
|
273
|
+
const n = e.state.useIsBusy(), s = e.needsConfirmation ? e.confirmationModalController : e.getOverlayController(), i = n ? !1 : t.isDismissable;
|
|
274
|
+
return /* @__PURE__ */ r.createElement(
|
|
275
|
+
o,
|
|
276
|
+
{
|
|
277
|
+
...t,
|
|
278
|
+
isDismissable: i,
|
|
279
|
+
controller: s ?? t.controller
|
|
280
|
+
},
|
|
281
|
+
/* @__PURE__ */ r.createElement(v, { if: e.needsConfirmation }, /* @__PURE__ */ r.createElement(
|
|
282
|
+
h,
|
|
283
|
+
{
|
|
284
|
+
props: {
|
|
285
|
+
ButtonGroup: {
|
|
286
|
+
Button: {
|
|
287
|
+
render: U
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
t.children
|
|
293
|
+
))
|
|
294
|
+
);
|
|
295
|
+
}, q = (o, t) => /* @__PURE__ */ r.createElement(o, { ...t }, /* @__PURE__ */ r.createElement(R, null, t.children)), g = (o) => {
|
|
296
|
+
const { children: t, ...e } = o, n = u.useNew(e), s = !n.parentAction, i = {
|
|
297
|
+
Modal: {
|
|
298
|
+
render: j
|
|
299
|
+
},
|
|
300
|
+
ButtonGroup: {
|
|
301
|
+
render: q
|
|
302
|
+
},
|
|
303
|
+
Button: {
|
|
304
|
+
render: B
|
|
305
|
+
},
|
|
306
|
+
Link: {
|
|
307
|
+
render: L
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
return /* @__PURE__ */ r.createElement(w, { value: n }, /* @__PURE__ */ r.createElement(v, { if: s }, /* @__PURE__ */ r.createElement(
|
|
311
|
+
h,
|
|
312
|
+
{
|
|
313
|
+
props: i,
|
|
314
|
+
dependencies: [n],
|
|
315
|
+
mergeInParentContext: !0
|
|
316
|
+
},
|
|
317
|
+
t
|
|
318
|
+
)));
|
|
319
|
+
};
|
|
320
|
+
export {
|
|
321
|
+
g as A
|
|
322
|
+
};
|
package/dist/Action.js
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
var i = Object.defineProperty;
|
|
4
|
+
var u = (s, t, e) => t in s ? i(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
5
|
+
var r = (s, t, e) => (u(s, typeof t != "symbol" ? t + "" : t, e), e);
|
|
6
|
+
import d, { createContext as n, useRef as m, useEffect as v, useContext as S } from "react";
|
|
7
|
+
import { makeObservable as f, observable as x, action as a, computed as l } from "mobx";
|
|
8
|
+
import { u as h } from "./useSelector-DpU7_HMO.js";
|
|
9
|
+
const C = n(void 0), A = C.Provider;
|
|
10
|
+
class o {
|
|
11
|
+
constructor() {
|
|
12
|
+
r(this, "states", /* @__PURE__ */ new Set());
|
|
13
|
+
f(this, {
|
|
14
|
+
states: x,
|
|
15
|
+
addState: a,
|
|
16
|
+
removeState: a,
|
|
17
|
+
isBusy: l
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
static useNew() {
|
|
21
|
+
return m(new o()).current;
|
|
22
|
+
}
|
|
23
|
+
static useRegisterState(t) {
|
|
24
|
+
const e = b();
|
|
25
|
+
v(() => (e.addState(t), () => {
|
|
26
|
+
e.removeState(t);
|
|
27
|
+
}), [e, t]);
|
|
28
|
+
}
|
|
29
|
+
addState(t) {
|
|
30
|
+
this.states.add(t);
|
|
31
|
+
}
|
|
32
|
+
removeState(t) {
|
|
33
|
+
this.states.delete(t);
|
|
34
|
+
}
|
|
35
|
+
useIsBusy() {
|
|
36
|
+
return h(() => this.isBusy, [this]);
|
|
37
|
+
}
|
|
38
|
+
get isBusy() {
|
|
39
|
+
for (const t of this.states)
|
|
40
|
+
if (t.isBusy)
|
|
41
|
+
return !0;
|
|
42
|
+
return !1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const c = n(new o()), P = (s) => {
|
|
46
|
+
const { children: t } = s, e = o.useNew();
|
|
47
|
+
return /* @__PURE__ */ d.createElement(c.Provider, { value: e }, t);
|
|
48
|
+
}, b = () => S(c);
|
|
49
|
+
export {
|
|
50
|
+
o as A,
|
|
51
|
+
C as a,
|
|
52
|
+
A as b,
|
|
53
|
+
P as c,
|
|
54
|
+
b as u
|
|
55
|
+
};
|
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-DHBRxUvd.js";
|
|
18
|
-
import { A as E } from "./Action-
|
|
18
|
+
import { A as E } from "./Action-BPEu-X47.js";
|
|
19
19
|
const B = {
|
|
20
20
|
"de-DE": {
|
|
21
21
|
"copyButton.copy": "Kopieren"
|
package/dist/Modal.js
CHANGED
|
@@ -11,7 +11,8 @@ import { f as u } from "./flowComponent-DHBRxUvd.js";
|
|
|
11
11
|
import { O as w } from "./Overlay-BWA78Wvu.js";
|
|
12
12
|
import "mobx";
|
|
13
13
|
import "./useOverlayController-CGKumeGL.js";
|
|
14
|
-
import "
|
|
14
|
+
import "invariant";
|
|
15
|
+
import "./ActionStateContext-B4ZIqu_K.js";
|
|
15
16
|
const v = "flow--modal", z = "flow--modal--button-group", C = "flow--modal--content", b = "flow--modal--off-canvas", t = {
|
|
16
17
|
modal: v,
|
|
17
18
|
"modal-zoom": "flow--modal--modal-zoom",
|
|
@@ -23,12 +24,12 @@ const v = "flow--modal", z = "flow--modal--button-group", C = "flow--modal--cont
|
|
|
23
24
|
offCanvas: b,
|
|
24
25
|
"modal-slide-in": "flow--modal--modal-slide-in",
|
|
25
26
|
"modal-slide-up": "flow--modal--modal-slide-up"
|
|
26
|
-
},
|
|
27
|
+
}, H = u("Modal", (e) => {
|
|
27
28
|
const {
|
|
28
29
|
size: l = "s",
|
|
29
30
|
offCanvas: n,
|
|
30
|
-
controller:
|
|
31
|
-
children:
|
|
31
|
+
controller: m,
|
|
32
|
+
children: a,
|
|
32
33
|
refProp: E,
|
|
33
34
|
...s
|
|
34
35
|
} = e, r = d(
|
|
@@ -48,9 +49,9 @@ const v = "flow--modal", z = "flow--modal--button-group", C = "flow--modal--cont
|
|
|
48
49
|
tunnelId: "buttons"
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
|
-
return /* @__PURE__ */ o.createElement(w, { className: r, controller:
|
|
52
|
+
return /* @__PURE__ */ o.createElement(w, { className: r, controller: m, ...s }, /* @__PURE__ */ o.createElement(f, { props: i }, /* @__PURE__ */ o.createElement(p, null, /* @__PURE__ */ o.createElement("div", { className: t.content }, a), /* @__PURE__ */ o.createElement(c, { id: "buttons" }))));
|
|
52
53
|
});
|
|
53
54
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
H as Modal,
|
|
56
|
+
H as default
|
|
56
57
|
};
|
package/dist/OffCanvas.js
CHANGED
|
@@ -6,7 +6,7 @@ import { B as f } from "./Button-54Eoq_9o.js";
|
|
|
6
6
|
import "@tabler/icons-react";
|
|
7
7
|
import "./Icon-BwDd2GzD.js";
|
|
8
8
|
import { I as m } from "./IconClose-D5lPIOIs.js";
|
|
9
|
-
import { A as i } from "./Action-
|
|
9
|
+
import { A as i } from "./Action-BPEu-X47.js";
|
|
10
10
|
import { O as p } from "./Overlay-BWA78Wvu.js";
|
|
11
11
|
import "mobx";
|
|
12
12
|
import "./useOverlayController-CGKumeGL.js";
|
package/dist/OverlayTrigger.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import
|
|
3
|
+
import e from "react";
|
|
4
4
|
import "mobx";
|
|
5
|
-
import { u as
|
|
6
|
-
import { A as p } from "./Action-
|
|
5
|
+
import { u as m, a as l } from "./useOverlayController-CGKumeGL.js";
|
|
6
|
+
import { A as p } from "./Action-BPEu-X47.js";
|
|
7
7
|
import "./propsContext-CauylOgH.js";
|
|
8
8
|
import { P as i } from "./PropsContextProvider-ChpH8eF2.js";
|
|
9
9
|
import "@react-aria/utils";
|
|
10
10
|
import "remeda";
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const y = (t) => {
|
|
12
|
+
const r = m(), o = {
|
|
13
13
|
Button: {
|
|
14
|
-
render: (
|
|
14
|
+
render: (n, a) => /* @__PURE__ */ e.createElement(p, { openOverlay: r }, /* @__PURE__ */ e.createElement(n, { ...a }))
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
return /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ e.createElement(l, { value: r }, /* @__PURE__ */ e.createElement(i, { props: o, mergeInParentContext: !0 }, t.children));
|
|
18
18
|
};
|
|
19
19
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
y as OverlayTrigger,
|
|
21
|
+
y as default
|
|
22
22
|
};
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OverlayController } from '../../lib/controller';
|
|
3
|
-
import { ActionState } from './lib/execution/ActionState';
|
|
1
|
+
import { ActionModel } from './models/ActionModel';
|
|
4
2
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
parentContext?: ActionContextValue;
|
|
8
|
-
confirmationModalController: OverlayController;
|
|
9
|
-
needsConfirmation: boolean;
|
|
10
|
-
overlayController: OverlayController;
|
|
11
|
-
state: ActionState;
|
|
12
|
-
}
|
|
13
|
-
export declare const ActionContextProvider: import('react').Provider<ActionContextValue>;
|
|
14
|
-
export declare const useActionContext: () => ActionContextValue;
|
|
15
|
-
export declare const useNewActionContext: (props: ActionProps) => ActionContextValue;
|
|
3
|
+
export declare const actionContext: import('react').Context<ActionModel | undefined>;
|
|
4
|
+
export declare const ActionContextProvider: import('react').Provider<ActionModel | undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionModel } from './ActionModel';
|
|
2
|
+
|
|
3
|
+
export declare class ActionExecutionBatch {
|
|
4
|
+
private readonly actions;
|
|
5
|
+
readonly baseAction: ActionModel;
|
|
6
|
+
constructor(baseAction: ActionModel);
|
|
7
|
+
addAction(action: ActionModel): void;
|
|
8
|
+
executeBatch(args: unknown[]): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OverlayController } from '../../../lib/controller';
|
|
2
|
+
import { ActionProps } from '../types';
|
|
3
|
+
import { ActionState } from './ActionState';
|
|
4
|
+
|
|
5
|
+
interface InitObject {
|
|
6
|
+
actionProps: ActionProps;
|
|
7
|
+
parentAction?: ActionModel;
|
|
8
|
+
confirmationModalController: OverlayController;
|
|
9
|
+
needsConfirmation: boolean;
|
|
10
|
+
overlayController: OverlayController;
|
|
11
|
+
state: ActionState;
|
|
12
|
+
}
|
|
13
|
+
export declare class ActionModel {
|
|
14
|
+
state: ActionState;
|
|
15
|
+
needsConfirmation: boolean;
|
|
16
|
+
readonly actionProps: ActionProps;
|
|
17
|
+
readonly parentAction?: ActionModel;
|
|
18
|
+
readonly confirmationModalController: OverlayController;
|
|
19
|
+
readonly overlayController: OverlayController;
|
|
20
|
+
private constructor();
|
|
21
|
+
static useNew(actionProps: ActionProps, init?: Partial<InitObject>): ActionModel;
|
|
22
|
+
static use(): ActionModel;
|
|
23
|
+
static useConfirmationAction(): ActionModel;
|
|
24
|
+
getOverlayController(): OverlayController | undefined;
|
|
25
|
+
execute: (...args: unknown[]) => void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ActionStateValue = "isIdle" | "isSucceeded" | "isPending" | "isExecuting" | "isFailed";
|
|
2
|
+
export declare class ActionState {
|
|
3
|
+
private showFeedback?;
|
|
4
|
+
state: ActionStateValue;
|
|
5
|
+
private setPendingTimeout;
|
|
6
|
+
error: unknown;
|
|
7
|
+
private isAsync;
|
|
8
|
+
constructor();
|
|
9
|
+
static useNew(): ActionState;
|
|
10
|
+
updateState(newState: ActionStateValue): void;
|
|
11
|
+
useValue(): ActionStateValue;
|
|
12
|
+
useIsBusy(): boolean;
|
|
13
|
+
get isBusy(): boolean;
|
|
14
|
+
onAsyncStart(): void;
|
|
15
|
+
onSucceeded(): Promise<void>;
|
|
16
|
+
onFailed(error: unknown): Promise<void>;
|
|
17
|
+
withFeedback(feedback?: boolean): ActionState;
|
|
18
|
+
private startFailedFeedback;
|
|
19
|
+
private startSucceededFeedback;
|
|
20
|
+
private resetAfterDone;
|
|
21
|
+
private onDone;
|
|
22
|
+
private startPending;
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { ActionState } from './ActionState';
|
|
3
|
+
|
|
4
|
+
export declare class ActionStateContext {
|
|
5
|
+
states: Set<ActionState>;
|
|
6
|
+
constructor();
|
|
7
|
+
static useNew(): ActionStateContext;
|
|
8
|
+
static useRegisterState(state: ActionState): void;
|
|
9
|
+
addState(state: ActionState): void;
|
|
10
|
+
removeState(state: ActionState): void;
|
|
11
|
+
useIsBusy(): boolean;
|
|
12
|
+
get isBusy(): boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const ActionStateContextProvider: FC<PropsWithChildren>;
|
|
15
|
+
export declare const useActionStateContext: () => ActionStateContext;
|
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.129",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
},
|
|
260
260
|
"dependencies": {
|
|
261
261
|
"@chakra-ui/live-region": "^2.1.0",
|
|
262
|
-
"@mittwald/react-tunnel": "^0.1.0-alpha.
|
|
262
|
+
"@mittwald/react-tunnel": "^0.1.0-alpha.129",
|
|
263
263
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
264
264
|
"@react-aria/utils": "^3.24.1",
|
|
265
265
|
"@react-types/shared": "^3.23.1",
|
|
@@ -283,7 +283,7 @@
|
|
|
283
283
|
},
|
|
284
284
|
"devDependencies": {
|
|
285
285
|
"@faker-js/faker": "^8.4.1",
|
|
286
|
-
"@mittwald/flow-design-tokens": "^0.1.0-alpha.
|
|
286
|
+
"@mittwald/flow-design-tokens": "^0.1.0-alpha.129",
|
|
287
287
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
288
288
|
"@nx/storybook": "^19.0.5",
|
|
289
289
|
"@storybook/addon-a11y": "^8.1.2",
|
|
@@ -359,5 +359,5 @@
|
|
|
359
359
|
"optional": true
|
|
360
360
|
}
|
|
361
361
|
},
|
|
362
|
-
"gitHead": "
|
|
362
|
+
"gitHead": "62d13d6425d7321541323b3cea292d2c518ec9c6"
|
|
363
363
|
}
|
package/dist/Action-BLnSsHE1.js
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
/* */
|
|
3
|
-
var $ = Object.defineProperty;
|
|
4
|
-
var N = (t, e, n) => e in t ? $(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
5
|
-
var l = (t, e, n) => (N(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
6
|
-
import r, { useEffect as W } from "react";
|
|
7
|
-
import { u as h, a as G, A as L } from "./context-D3hdrTHO.js";
|
|
8
|
-
import "./propsContext-CauylOgH.js";
|
|
9
|
-
import { P as M } from "./PropsContextProvider-ChpH8eF2.js";
|
|
10
|
-
import "@react-aria/utils";
|
|
11
|
-
import "remeda";
|
|
12
|
-
import { W as U } from "./Wrap-DGT1h1o3.js";
|
|
13
|
-
const u = () => {
|
|
14
|
-
}, j = (t, e = {}) => {
|
|
15
|
-
const {
|
|
16
|
-
onSync: n = u,
|
|
17
|
-
onAsync: o = u,
|
|
18
|
-
then: s = u,
|
|
19
|
-
catch: i = u,
|
|
20
|
-
finally: c = u
|
|
21
|
-
} = e;
|
|
22
|
-
try {
|
|
23
|
-
const a = t();
|
|
24
|
-
return a instanceof Promise ? (o(), a.then(s).catch(i).finally(c)) : (n(), s(a), c(), a);
|
|
25
|
-
} catch (a) {
|
|
26
|
-
n(), i(a), c();
|
|
27
|
-
}
|
|
28
|
-
}, P = (t) => new Promise((e) => setTimeout(e, t)), x = {
|
|
29
|
-
pending: 1e3,
|
|
30
|
-
succeeded: 1500,
|
|
31
|
-
failed: 2e3
|
|
32
|
-
};
|
|
33
|
-
class q {
|
|
34
|
-
constructor(e, n, o = {}) {
|
|
35
|
-
l(this, "options");
|
|
36
|
-
l(this, "state");
|
|
37
|
-
l(this, "args");
|
|
38
|
-
l(this, "isDone", !1);
|
|
39
|
-
l(this, "error");
|
|
40
|
-
const {
|
|
41
|
-
resetAfterDone: s = !0,
|
|
42
|
-
onFeedbackDone: i = () => {
|
|
43
|
-
},
|
|
44
|
-
showFeedback: c = !1,
|
|
45
|
-
resetDelayMs: a = 0
|
|
46
|
-
} = o;
|
|
47
|
-
this.state = e, this.args = n, this.options = {
|
|
48
|
-
resetAfterDone: s,
|
|
49
|
-
onFeedbackDone: i,
|
|
50
|
-
showFeedback: c,
|
|
51
|
-
resetDelayMs: a
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
onAsyncStart() {
|
|
55
|
-
this.options.showFeedback = !0, this.state.updateState("isExecuting"), setTimeout(() => this.startPending(), x.pending);
|
|
56
|
-
}
|
|
57
|
-
onSucceeded() {
|
|
58
|
-
return this.onDone();
|
|
59
|
-
}
|
|
60
|
-
async onFailed(e) {
|
|
61
|
-
this.error = e ?? new Error("Unknown error"), console.error(e), await this.onDone();
|
|
62
|
-
}
|
|
63
|
-
setResetDelay(e) {
|
|
64
|
-
this.options.resetDelayMs = e;
|
|
65
|
-
}
|
|
66
|
-
async startFailedFeedback() {
|
|
67
|
-
this.state.updateState("isFailed"), await P(x.failed), this.resetAfterDone();
|
|
68
|
-
}
|
|
69
|
-
async startSucceededFeedback() {
|
|
70
|
-
this.state.updateState("isSucceeded"), await P(x.succeeded), this.resetAfterDone();
|
|
71
|
-
}
|
|
72
|
-
resetAfterDone() {
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
this.options.resetAfterDone && this.state.updateState("isIdle"), this.error || this.options.onFeedbackDone(...this.args);
|
|
75
|
-
}, this.options.resetDelayMs);
|
|
76
|
-
}
|
|
77
|
-
async onDone() {
|
|
78
|
-
this.isDone = !0, this.options.showFeedback ? this.error ? await this.startFailedFeedback() : await this.startSucceededFeedback() : this.resetAfterDone();
|
|
79
|
-
}
|
|
80
|
-
startPending() {
|
|
81
|
-
this.isDone || this.state.updateState("isPending");
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const v = (t) => (...e) => {
|
|
85
|
-
const n = [...t], o = n.shift();
|
|
86
|
-
if (o) {
|
|
87
|
-
const s = o(...e), i = () => n.length === 0 ? s : v(n)(...e);
|
|
88
|
-
return s instanceof Promise ? s.then(i) : i();
|
|
89
|
-
}
|
|
90
|
-
}, z = () => {
|
|
91
|
-
}, b = () => {
|
|
92
|
-
var n;
|
|
93
|
-
const t = h(), e = t.actionProps.confirm || t.actionProps.abort ? ((n = t.parentContext) == null ? void 0 : n.state) ?? t.state : t.state;
|
|
94
|
-
return {
|
|
95
|
-
state: e,
|
|
96
|
-
execute: async (...o) => {
|
|
97
|
-
var D;
|
|
98
|
-
const {
|
|
99
|
-
actionProps: s,
|
|
100
|
-
confirmationModalController: i,
|
|
101
|
-
needsConfirmation: c,
|
|
102
|
-
parentContext: a
|
|
103
|
-
} = t;
|
|
104
|
-
if (s.abort) {
|
|
105
|
-
(D = a == null ? void 0 : a.confirmationModalController) == null || D.close();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (c && !i.isOpen) {
|
|
109
|
-
i.open();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const f = new q(e, o, s), A = [];
|
|
113
|
-
let d, p, m = t;
|
|
114
|
-
for (; m; ) {
|
|
115
|
-
const {
|
|
116
|
-
actionProps: C,
|
|
117
|
-
overlayController: B,
|
|
118
|
-
confirmationModalController: E,
|
|
119
|
-
needsConfirmation: R
|
|
120
|
-
} = m, {
|
|
121
|
-
action: S,
|
|
122
|
-
toggleOverlay: g,
|
|
123
|
-
openOverlay: F,
|
|
124
|
-
closeOverlay: w,
|
|
125
|
-
break: T
|
|
126
|
-
} = C;
|
|
127
|
-
if (T)
|
|
128
|
-
break;
|
|
129
|
-
if (R)
|
|
130
|
-
if (d) {
|
|
131
|
-
p = E;
|
|
132
|
-
break;
|
|
133
|
-
} else
|
|
134
|
-
d = E;
|
|
135
|
-
const y = (k) => typeof k == "boolean" ? B : k;
|
|
136
|
-
A.push(
|
|
137
|
-
S || (g ? y(g).toggle : F ? y(F).open : w ? y(w).close : z)
|
|
138
|
-
), m = m.parentContext;
|
|
139
|
-
}
|
|
140
|
-
const O = v(A);
|
|
141
|
-
f.setResetDelay(
|
|
142
|
-
d ? 500 : 0
|
|
143
|
-
), await j(() => O(o), {
|
|
144
|
-
onAsync: () => f.onAsyncStart(),
|
|
145
|
-
then: async () => {
|
|
146
|
-
await f.onSucceeded(), p && p.open(), d && d.close();
|
|
147
|
-
},
|
|
148
|
-
catch: (C) => f.onFailed(C)
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}, I = (t, e) => {
|
|
153
|
-
const { actionProps: n, needsConfirmation: o } = h(), s = b(), i = s.state.useState();
|
|
154
|
-
return o ? /* @__PURE__ */ r.createElement(t, { ...e, onPress: s.execute }) : n.abort ? /* @__PURE__ */ r.createElement(
|
|
155
|
-
t,
|
|
156
|
-
{
|
|
157
|
-
...e,
|
|
158
|
-
onPress: s.execute,
|
|
159
|
-
"aria-disabled": i !== "isIdle"
|
|
160
|
-
}
|
|
161
|
-
) : /* @__PURE__ */ r.createElement(
|
|
162
|
-
t,
|
|
163
|
-
{
|
|
164
|
-
...e,
|
|
165
|
-
onPress: s.execute,
|
|
166
|
-
isPending: i === "isPending",
|
|
167
|
-
"aria-disabled": i === "isExecuting",
|
|
168
|
-
isSucceeded: i === "isSucceeded",
|
|
169
|
-
isFailed: i === "isFailed"
|
|
170
|
-
}
|
|
171
|
-
);
|
|
172
|
-
}, H = (t, e) => {
|
|
173
|
-
const { needsConfirmation: n } = h(), o = b(), s = o.state.useState();
|
|
174
|
-
return n ? /* @__PURE__ */ r.createElement(t, { ...e, onPress: o.execute }) : /* @__PURE__ */ r.createElement(
|
|
175
|
-
t,
|
|
176
|
-
{
|
|
177
|
-
...e,
|
|
178
|
-
onPress: o.execute,
|
|
179
|
-
"aria-disabled": s !== "isIdle"
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}, J = (t, e) => {
|
|
183
|
-
const n = e.color === "secondary", o = e.color === "primary" || e.color === "danger" || e.color === "accent";
|
|
184
|
-
if (!o && !n)
|
|
185
|
-
return /* @__PURE__ */ r.createElement(t, { ...e });
|
|
186
|
-
const s = { Button: { render: I } };
|
|
187
|
-
return /* @__PURE__ */ r.createElement(M, { props: s }, /* @__PURE__ */ r.createElement(Q, { abort: n, confirm: o }, /* @__PURE__ */ r.createElement(t, { ...e })));
|
|
188
|
-
}, K = (t, e) => {
|
|
189
|
-
if (e.slot !== "actionConfirm")
|
|
190
|
-
return /* @__PURE__ */ r.createElement(t, { ...e });
|
|
191
|
-
const n = h(), o = b().state.useState();
|
|
192
|
-
W(() => (n.needsConfirmation = !0, () => {
|
|
193
|
-
n.needsConfirmation = !1;
|
|
194
|
-
}), [n]);
|
|
195
|
-
const s = o === "isIdle" ? e.isDismissable : !1;
|
|
196
|
-
return /* @__PURE__ */ r.createElement(
|
|
197
|
-
t,
|
|
198
|
-
{
|
|
199
|
-
...e,
|
|
200
|
-
controller: n.confirmationModalController,
|
|
201
|
-
isDismissable: s
|
|
202
|
-
}
|
|
203
|
-
);
|
|
204
|
-
}, Q = (t) => {
|
|
205
|
-
const { children: e, ...n } = t, o = G(n), s = !!o.parentContext && !!o.parentContext.parentContext, i = {
|
|
206
|
-
Modal: {
|
|
207
|
-
render: K,
|
|
208
|
-
ButtonGroup: {
|
|
209
|
-
Button: {
|
|
210
|
-
render: J
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
Button: {
|
|
215
|
-
render: I
|
|
216
|
-
},
|
|
217
|
-
Link: {
|
|
218
|
-
render: H
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
return /* @__PURE__ */ r.createElement(L, { value: o }, /* @__PURE__ */ r.createElement(U, { if: !s }, /* @__PURE__ */ r.createElement(
|
|
222
|
-
M,
|
|
223
|
-
{
|
|
224
|
-
props: i,
|
|
225
|
-
dependencies: [o],
|
|
226
|
-
mergeInParentContext: !0
|
|
227
|
-
},
|
|
228
|
-
e
|
|
229
|
-
)));
|
|
230
|
-
};
|
|
231
|
-
export {
|
|
232
|
-
Q as A
|
|
233
|
-
};
|
package/dist/context-D3hdrTHO.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
/* */
|
|
3
|
-
var u = Object.defineProperty;
|
|
4
|
-
var m = (e, t, o) => t in e ? u(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
5
|
-
var a = (e, t, o) => (m(e, typeof t != "symbol" ? t + "" : t, o), o);
|
|
6
|
-
import { useRef as C, createContext as f, useMemo as d, useContext as p } from "react";
|
|
7
|
-
import { O as i, u as l } from "./useOverlayController-CGKumeGL.js";
|
|
8
|
-
import { makeObservable as v, observable as x, action as w } from "mobx";
|
|
9
|
-
import { u as b } from "./useSelector-DpU7_HMO.js";
|
|
10
|
-
class r {
|
|
11
|
-
constructor() {
|
|
12
|
-
a(this, "state", "isIdle");
|
|
13
|
-
v(this, {
|
|
14
|
-
state: x,
|
|
15
|
-
updateState: w
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
static useNew() {
|
|
19
|
-
return C(new r()).current;
|
|
20
|
-
}
|
|
21
|
-
updateState(t) {
|
|
22
|
-
this.state = t;
|
|
23
|
-
}
|
|
24
|
-
useState() {
|
|
25
|
-
return b(() => this.state, [this]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const c = f({
|
|
29
|
-
actionProps: {},
|
|
30
|
-
state: new r(),
|
|
31
|
-
overlayController: new i(),
|
|
32
|
-
confirmationModalController: new i(),
|
|
33
|
-
needsConfirmation: !1
|
|
34
|
-
}), M = c.Provider, h = () => p(c), N = (e) => {
|
|
35
|
-
const t = h(), o = l(), n = r.useNew(), s = l();
|
|
36
|
-
return d(
|
|
37
|
-
() => ({
|
|
38
|
-
actionProps: e,
|
|
39
|
-
parentContext: t,
|
|
40
|
-
overlayController: o,
|
|
41
|
-
state: n,
|
|
42
|
-
confirmationModalController: s,
|
|
43
|
-
needsConfirmation: !1
|
|
44
|
-
}),
|
|
45
|
-
[
|
|
46
|
-
e,
|
|
47
|
-
t,
|
|
48
|
-
o,
|
|
49
|
-
n,
|
|
50
|
-
s
|
|
51
|
-
]
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
export {
|
|
55
|
-
M as A,
|
|
56
|
-
N as a,
|
|
57
|
-
h as u
|
|
58
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ActionState } from './ActionState';
|
|
2
|
-
|
|
3
|
-
interface ActionExecutionOptions {
|
|
4
|
-
showFeedback?: boolean;
|
|
5
|
-
resetAfterDone?: boolean;
|
|
6
|
-
resetDelayMs?: number;
|
|
7
|
-
onFeedbackDone?: (...args: unknown[]) => void;
|
|
8
|
-
}
|
|
9
|
-
export declare class ActionExecution {
|
|
10
|
-
private readonly options;
|
|
11
|
-
private readonly state;
|
|
12
|
-
private readonly args;
|
|
13
|
-
private isDone;
|
|
14
|
-
error: unknown;
|
|
15
|
-
constructor(state: ActionState, args: unknown[], options?: ActionExecutionOptions);
|
|
16
|
-
onAsyncStart(): void;
|
|
17
|
-
onSucceeded(): Promise<void>;
|
|
18
|
-
onFailed(error: unknown): Promise<void>;
|
|
19
|
-
setResetDelay(ms: number): void;
|
|
20
|
-
private startFailedFeedback;
|
|
21
|
-
private startSucceededFeedback;
|
|
22
|
-
private resetAfterDone;
|
|
23
|
-
private onDone;
|
|
24
|
-
private startPending;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type ActionStateValue = "isIdle" | "isSucceeded" | "isPending" | "isExecuting" | "isFailed";
|
|
2
|
-
export declare class ActionState {
|
|
3
|
-
state: ActionStateValue;
|
|
4
|
-
constructor();
|
|
5
|
-
static useNew(): ActionState;
|
|
6
|
-
updateState(newState: ActionStateValue): void;
|
|
7
|
-
useState(): ActionStateValue;
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|