@mittwald/flow-react-components 0.1.0-alpha.87 → 0.1.0-alpha.89
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-CC0yBUVp.js +188 -0
- package/dist/Action.js +1 -1
- package/dist/CopyButton.js +1 -1
- package/dist/Modal.js +40 -46
- package/dist/controller.js +1 -1
- package/dist/hooks.js +1 -1
- package/dist/{index-Cb88QILt.js → index-D8fboLvc.js} +8 -8
- package/dist/types/components/Modal/components/ModalTrigger.d.ts +6 -0
- package/dist/types/components/Modal/index.d.ts +1 -1
- package/dist/types/components/Modal/stories/Default.stories.d.ts +1 -1
- package/dist/types/lib/controller/overlay/context.d.ts +2 -2
- package/package.json +4 -4
- package/dist/Action-Bu-hapYW.js +0 -176
- package/dist/types/components/Modal/hooks/useSyncTriggerState.d.ts +0 -3
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
var F = Object.defineProperty;
|
|
4
|
+
var v = (t, e, n) => e in t ? F(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
5
|
+
var f = (t, e, n) => (v(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
6
|
+
import i, { createContext as D, useContext as g, useRef as M, useState as P, useEffect as w } from "react";
|
|
7
|
+
import "./propsContext-CauylOgH.js";
|
|
8
|
+
import { P as x } from "./PropsContextProvider-DZvwqHLP.js";
|
|
9
|
+
import "@react-aria/utils";
|
|
10
|
+
import "remeda";
|
|
11
|
+
import { u as y, O as R } from "./index-D8fboLvc.js";
|
|
12
|
+
import { TunnelProvider as B, TunnelExit as I } from "@mittwald/react-tunnel";
|
|
13
|
+
import { makeObservable as O, observable as T, action as N } from "mobx";
|
|
14
|
+
import { u as $ } from "./useSelector-DpU7_HMO.js";
|
|
15
|
+
const b = D(void 0), G = () => g(b), H = b.Provider, C = (t) => (...e) => {
|
|
16
|
+
const n = [...t], s = n.shift();
|
|
17
|
+
if (s) {
|
|
18
|
+
const o = s(...e), r = () => n.length === 0 ? o : C(n)(...e);
|
|
19
|
+
return o instanceof Promise ? o.then(r) : r();
|
|
20
|
+
}
|
|
21
|
+
}, S = "flowBreakActionMarker";
|
|
22
|
+
function U(t) {
|
|
23
|
+
return !!t && t instanceof Error && t.message === S;
|
|
24
|
+
}
|
|
25
|
+
const j = () => {
|
|
26
|
+
throw new Error(S);
|
|
27
|
+
}, p = {
|
|
28
|
+
pending: 1e3,
|
|
29
|
+
succeeded: 1500,
|
|
30
|
+
failed: 2e3
|
|
31
|
+
};
|
|
32
|
+
class q {
|
|
33
|
+
constructor(e, n, s = {}) {
|
|
34
|
+
f(this, "options");
|
|
35
|
+
f(this, "state");
|
|
36
|
+
f(this, "args");
|
|
37
|
+
f(this, "isDone", !1);
|
|
38
|
+
f(this, "error");
|
|
39
|
+
const {
|
|
40
|
+
resetAfterDone: o = !0,
|
|
41
|
+
onFeedbackDone: r = () => {
|
|
42
|
+
},
|
|
43
|
+
showFeedback: c = !1
|
|
44
|
+
} = s;
|
|
45
|
+
this.state = e, this.args = n, this.options = { resetAfterDone: o, onFeedbackDone: r, showFeedback: c };
|
|
46
|
+
}
|
|
47
|
+
onAsyncStart() {
|
|
48
|
+
this.options.showFeedback = !0, this.state.updateState("isExecuting"), setTimeout(() => this.startPending(), p.pending);
|
|
49
|
+
}
|
|
50
|
+
onSucceeded() {
|
|
51
|
+
this.onDone();
|
|
52
|
+
}
|
|
53
|
+
onFailed(e) {
|
|
54
|
+
this.error = e ?? new Error("Unknown error"), console.error(e), this.onDone();
|
|
55
|
+
}
|
|
56
|
+
startFailedFeedback() {
|
|
57
|
+
U(this.error) ? this.resetAfterDone() : (this.state.updateState("isFailed"), setTimeout(() => this.resetAfterDone(), p.failed));
|
|
58
|
+
}
|
|
59
|
+
startSucceededFeedback() {
|
|
60
|
+
this.state.updateState("isSucceeded"), setTimeout(() => this.resetAfterDone(), p.succeeded);
|
|
61
|
+
}
|
|
62
|
+
resetAfterDone() {
|
|
63
|
+
this.options.resetAfterDone && this.state.updateState("isIdle"), this.error || this.options.onFeedbackDone(...this.args);
|
|
64
|
+
}
|
|
65
|
+
onDone() {
|
|
66
|
+
this.isDone = !0, this.options.showFeedback ? this.error ? this.startFailedFeedback() : this.startSucceededFeedback() : this.resetAfterDone();
|
|
67
|
+
}
|
|
68
|
+
startPending() {
|
|
69
|
+
this.isDone || this.state.updateState("isPending");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class k {
|
|
73
|
+
constructor() {
|
|
74
|
+
f(this, "state", "isIdle");
|
|
75
|
+
O(this, {
|
|
76
|
+
state: T,
|
|
77
|
+
updateState: N
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
static useNew() {
|
|
81
|
+
return M(new k()).current;
|
|
82
|
+
}
|
|
83
|
+
updateState(e) {
|
|
84
|
+
this.state = e;
|
|
85
|
+
}
|
|
86
|
+
useState() {
|
|
87
|
+
return $(() => this.state, [this]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const z = () => {
|
|
91
|
+
}, J = (t) => {
|
|
92
|
+
const {
|
|
93
|
+
action: e,
|
|
94
|
+
toggleModal: n,
|
|
95
|
+
openModal: s,
|
|
96
|
+
closeModal: o,
|
|
97
|
+
break: r
|
|
98
|
+
} = t, c = y();
|
|
99
|
+
return e || (n ? c.toggle : s ? c.open : o ? c.close : r ? j : z);
|
|
100
|
+
}, K = (t, e = {}) => {
|
|
101
|
+
const {
|
|
102
|
+
onSync: n = () => {
|
|
103
|
+
},
|
|
104
|
+
onAsync: s = () => {
|
|
105
|
+
},
|
|
106
|
+
then: o = () => {
|
|
107
|
+
},
|
|
108
|
+
catch: r = () => {
|
|
109
|
+
},
|
|
110
|
+
finally: c = () => {
|
|
111
|
+
}
|
|
112
|
+
} = e;
|
|
113
|
+
try {
|
|
114
|
+
const d = t();
|
|
115
|
+
return d instanceof Promise ? (s(), d.then(o).catch(r).finally(c)) : (n(), o(d), c(), d);
|
|
116
|
+
} catch (d) {
|
|
117
|
+
n(), r(d), c();
|
|
118
|
+
}
|
|
119
|
+
}, L = (t) => {
|
|
120
|
+
const { isConfirmationAction: e, showFeedback: n } = t, s = J(t), o = G(), r = k.useNew(), c = !e, d = e ? void 0 : o, m = e ? o : void 0, u = C([s, d]);
|
|
121
|
+
return {
|
|
122
|
+
callAction: (...a) => {
|
|
123
|
+
const A = new q(r, a, {
|
|
124
|
+
onFeedbackDone: m,
|
|
125
|
+
resetAfterDone: c,
|
|
126
|
+
showFeedback: n
|
|
127
|
+
});
|
|
128
|
+
return K(u, {
|
|
129
|
+
onAsync: () => A.onAsyncStart(),
|
|
130
|
+
then: () => A.onSucceeded(),
|
|
131
|
+
catch: (E) => A.onFailed(E)
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
state: r
|
|
135
|
+
};
|
|
136
|
+
}, h = (t) => {
|
|
137
|
+
const [e, n] = P(!1), s = R.useNew(), o = L(t), r = e ? s.open : o.callAction, m = {
|
|
138
|
+
Button: {
|
|
139
|
+
onPress: r,
|
|
140
|
+
render: (u, l) => {
|
|
141
|
+
const a = o.state.useState();
|
|
142
|
+
return /* @__PURE__ */ i.createElement(
|
|
143
|
+
u,
|
|
144
|
+
{
|
|
145
|
+
...l,
|
|
146
|
+
isPending: a === "isPending" ? !0 : void 0,
|
|
147
|
+
"aria-disabled": a !== "isIdle" ? !0 : void 0,
|
|
148
|
+
isSucceeded: a === "isSucceeded" ? !0 : void 0,
|
|
149
|
+
isFailed: a === "isFailed" ? !0 : void 0
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
Modal: {
|
|
155
|
+
tunnelId: "outsideActionProvider",
|
|
156
|
+
render: (u, l) => {
|
|
157
|
+
const a = l.slot === "actionConfirm";
|
|
158
|
+
return w(() => {
|
|
159
|
+
if (a)
|
|
160
|
+
return n(!0), () => {
|
|
161
|
+
n(!1);
|
|
162
|
+
};
|
|
163
|
+
}, [a]), a ? /* @__PURE__ */ i.createElement(u, { controller: s, ...l }) : /* @__PURE__ */ i.createElement(u, { ...l });
|
|
164
|
+
},
|
|
165
|
+
ButtonGroup: {
|
|
166
|
+
Button: {
|
|
167
|
+
render: (u, l) => {
|
|
168
|
+
const { variant: a } = l;
|
|
169
|
+
return a === "secondary" ? /* @__PURE__ */ i.createElement(h, { break: !0 }, /* @__PURE__ */ i.createElement(h, { closeModal: !0 }, /* @__PURE__ */ i.createElement(u, { ...l }))) : /* @__PURE__ */ i.createElement(h, { closeModal: !0 }, /* @__PURE__ */ i.createElement(h, { ...t, isConfirmationAction: !0 }, /* @__PURE__ */ i.createElement(u, { ...l })));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return /* @__PURE__ */ i.createElement(B, null, /* @__PURE__ */ i.createElement(
|
|
176
|
+
x,
|
|
177
|
+
{
|
|
178
|
+
props: m,
|
|
179
|
+
dependencies: [e],
|
|
180
|
+
mergeInParentContext: !0
|
|
181
|
+
},
|
|
182
|
+
/* @__PURE__ */ i.createElement(H, { value: r }, t.children),
|
|
183
|
+
/* @__PURE__ */ i.createElement(I, { id: "outsideActionProvider" })
|
|
184
|
+
));
|
|
185
|
+
};
|
|
186
|
+
export {
|
|
187
|
+
h as A
|
|
188
|
+
};
|
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-C4FfRbD8.js";
|
|
18
|
-
import { A as E } from "./Action-
|
|
18
|
+
import { A as E } from "./Action-CC0yBUVp.js";
|
|
19
19
|
const B = {
|
|
20
20
|
"de-DE": {
|
|
21
21
|
"copyButton.copy": "Kopieren"
|
package/dist/Modal.js
CHANGED
|
@@ -1,82 +1,76 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
import * as n from "react-aria-components";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import O from "clsx";
|
|
4
|
+
import o from "react";
|
|
5
|
+
import g from "clsx";
|
|
7
6
|
import "./propsContext-CauylOgH.js";
|
|
8
|
-
import { P as
|
|
7
|
+
import { P as E } from "./PropsContextProvider-DZvwqHLP.js";
|
|
9
8
|
import "@react-aria/utils";
|
|
10
9
|
import "remeda";
|
|
11
|
-
import { TunnelProvider as
|
|
12
|
-
import { u as
|
|
13
|
-
import { f as
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
import { TunnelProvider as y, TunnelExit as z } from "@mittwald/react-tunnel";
|
|
11
|
+
import { u as r, a as s } from "./index-D8fboLvc.js";
|
|
12
|
+
import { f as x } from "./flowComponent-C4FfRbD8.js";
|
|
13
|
+
import { A as O } from "./Action-CC0yBUVp.js";
|
|
14
|
+
import "mobx";
|
|
15
|
+
const b = "flow--modal--overlay", M = "flow--modal", N = "flow--modal--dialog", P = "flow--modal--button-group", F = "flow--modal--content", G = "flow--modal--off-canvas", e = {
|
|
16
|
+
overlay: b,
|
|
16
17
|
"modal-fade": "flow--modal--modal-fade",
|
|
17
|
-
modal:
|
|
18
|
+
modal: M,
|
|
18
19
|
"modal-zoom": "flow--modal--modal-zoom",
|
|
19
|
-
dialog:
|
|
20
|
-
buttonGroup:
|
|
21
|
-
content:
|
|
20
|
+
dialog: N,
|
|
21
|
+
buttonGroup: P,
|
|
22
|
+
content: F,
|
|
22
23
|
"size-s": "flow--modal--size-s",
|
|
23
24
|
"size-m": "flow--modal--size-m",
|
|
24
25
|
"size-l": "flow--modal--size-l",
|
|
25
|
-
offCanvas:
|
|
26
|
+
offCanvas: G,
|
|
26
27
|
"modal-slide-in": "flow--modal--modal-slide-in",
|
|
27
28
|
"modal-slide-up": "flow--modal--modal-slide-up"
|
|
28
|
-
},
|
|
29
|
-
const o = w(n.OverlayTriggerStateContext), a = l.useIsOpen();
|
|
30
|
-
r(() => {
|
|
31
|
-
o && l.setOpen(o.isOpen);
|
|
32
|
-
}, [o == null ? void 0 : o.isOpen]), r(() => {
|
|
33
|
-
o && o.setOpen(a);
|
|
34
|
-
}, [a]);
|
|
35
|
-
}, q = T("Modal", (l) => {
|
|
29
|
+
}, q = x("Modal", (t) => {
|
|
36
30
|
const {
|
|
37
|
-
size:
|
|
38
|
-
offCanvas:
|
|
39
|
-
controller:
|
|
31
|
+
size: l = "s",
|
|
32
|
+
offCanvas: m,
|
|
33
|
+
controller: d,
|
|
40
34
|
defaultOpen: i,
|
|
41
|
-
children:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
reuseControllerFromContext: f,
|
|
35
|
+
children: c,
|
|
36
|
+
...f
|
|
37
|
+
} = t, p = r({
|
|
38
|
+
reuseControllerFromContext: !0,
|
|
46
39
|
defaultOpen: i
|
|
47
|
-
}),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
a && t.offCanvas
|
|
53
|
-
), g = {
|
|
40
|
+
}), a = d ?? p, u = a.useIsOpen(), v = g(
|
|
41
|
+
e.modal,
|
|
42
|
+
e[`size-${l}`],
|
|
43
|
+
m && e.offCanvas
|
|
44
|
+
), C = {
|
|
54
45
|
Content: {
|
|
55
|
-
elementType:
|
|
46
|
+
elementType: o.Fragment
|
|
56
47
|
},
|
|
57
48
|
Heading: {
|
|
58
49
|
level: 2,
|
|
59
50
|
slot: "title"
|
|
60
51
|
},
|
|
61
52
|
ButtonGroup: {
|
|
62
|
-
className:
|
|
53
|
+
className: e.buttonGroup,
|
|
63
54
|
tunnelId: "buttons"
|
|
64
55
|
}
|
|
65
56
|
};
|
|
66
|
-
return /* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ o.createElement(
|
|
67
58
|
n.ModalOverlay,
|
|
68
59
|
{
|
|
69
|
-
className:
|
|
70
|
-
...
|
|
60
|
+
className: e.overlay,
|
|
61
|
+
...f,
|
|
71
62
|
isDismissable: !0,
|
|
72
63
|
isOpen: u,
|
|
73
|
-
onOpenChange: (
|
|
64
|
+
onOpenChange: (w) => a.setOpen(w)
|
|
74
65
|
},
|
|
75
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ o.createElement(n.Modal, { className: v }, /* @__PURE__ */ o.createElement(n.Dialog, { className: e.dialog }, /* @__PURE__ */ o.createElement(s, { value: a }, /* @__PURE__ */ o.createElement(E, { props: C }, /* @__PURE__ */ o.createElement(y, null, /* @__PURE__ */ o.createElement("div", { className: e.content }, c), /* @__PURE__ */ o.createElement(z, { id: "buttons" }))))))
|
|
76
67
|
);
|
|
77
|
-
})
|
|
68
|
+
}), J = (t) => {
|
|
69
|
+
const l = r();
|
|
70
|
+
return /* @__PURE__ */ o.createElement(s, { value: l }, /* @__PURE__ */ o.createElement(O, { openModal: l }, t.children));
|
|
71
|
+
};
|
|
78
72
|
export {
|
|
79
73
|
q as Modal,
|
|
80
|
-
|
|
74
|
+
J as ModalTrigger,
|
|
81
75
|
q as default
|
|
82
76
|
};
|
package/dist/controller.js
CHANGED
package/dist/hooks.js
CHANGED
|
@@ -4,8 +4,8 @@ var p = Object.defineProperty;
|
|
|
4
4
|
var l = (t, e, s) => e in t ? p(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
5
5
|
var i = (t, e, s) => (l(t, typeof e != "symbol" ? e + "" : e, s), s);
|
|
6
6
|
import { makeObservable as O, observable as c, action as o } from "mobx";
|
|
7
|
-
import { useState as m, createContext as b, useContext as
|
|
8
|
-
import { u as
|
|
7
|
+
import { useState as m, createContext as b, useContext as d } from "react";
|
|
8
|
+
import { u as h } from "./useSelector-DpU7_HMO.js";
|
|
9
9
|
class n {
|
|
10
10
|
constructor(e = !1) {
|
|
11
11
|
i(this, "isOpen");
|
|
@@ -33,17 +33,17 @@ class n {
|
|
|
33
33
|
this.isOpen = e;
|
|
34
34
|
}
|
|
35
35
|
useIsOpen() {
|
|
36
|
-
return
|
|
36
|
+
return h(() => this.isOpen);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
const a = b(
|
|
40
|
-
|
|
41
|
-
),
|
|
42
|
-
const { reuseControllerFromContext: e = !0, defaultOpen: s } = t, u = n.useNew(s), r =
|
|
40
|
+
void 0
|
|
41
|
+
), g = a.Provider, w = (t = {}) => {
|
|
42
|
+
const { reuseControllerFromContext: e = !0, defaultOpen: s } = t, u = n.useNew(s), r = d(a);
|
|
43
43
|
return e && r ? r : u;
|
|
44
44
|
};
|
|
45
45
|
export {
|
|
46
46
|
n as O,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
g as a,
|
|
48
|
+
w as u
|
|
49
49
|
};
|
|
@@ -6,6 +6,6 @@ export default meta;
|
|
|
6
6
|
type Story = StoryObj<typeof Modal>;
|
|
7
7
|
export declare const Default: Story;
|
|
8
8
|
export declare const WithController: Story;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const WithTrigger: Story;
|
|
10
10
|
export declare const Mobile: Story;
|
|
11
11
|
export declare const OffCanvas: Story;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { OverlayController } from './OverlayController';
|
|
2
2
|
|
|
3
|
-
export declare const overlayContext: import('react').Context<OverlayController>;
|
|
4
|
-
export declare const OverlayContextProvider: import('react').Provider<OverlayController>;
|
|
3
|
+
export declare const overlayContext: import('react').Context<OverlayController | undefined>;
|
|
4
|
+
export declare const OverlayContextProvider: import('react').Provider<OverlayController | undefined>;
|
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.89",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
},
|
|
236
236
|
"dependencies": {
|
|
237
237
|
"@chakra-ui/live-region": "^2.1.0",
|
|
238
|
-
"@mittwald/react-tunnel": "^0.1.0-alpha.
|
|
238
|
+
"@mittwald/react-tunnel": "^0.1.0-alpha.89",
|
|
239
239
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
240
240
|
"@react-aria/utils": "^3.23.2",
|
|
241
241
|
"@react-types/shared": "^3.22.1",
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
},
|
|
260
260
|
"devDependencies": {
|
|
261
261
|
"@faker-js/faker": "^8.4.1",
|
|
262
|
-
"@mittwald/flow-design-tokens": "^0.1.0-alpha.
|
|
262
|
+
"@mittwald/flow-design-tokens": "^0.1.0-alpha.89",
|
|
263
263
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
264
264
|
"@nx/storybook": "^18.3.4",
|
|
265
265
|
"@storybook/addon-a11y": "^8.0.9",
|
|
@@ -334,5 +334,5 @@
|
|
|
334
334
|
"optional": true
|
|
335
335
|
}
|
|
336
336
|
},
|
|
337
|
-
"gitHead": "
|
|
337
|
+
"gitHead": "f9ca3988883c7f56ba9dea9641029b8c7d73667b"
|
|
338
338
|
}
|
package/dist/Action-Bu-hapYW.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
/* */
|
|
3
|
-
var v = Object.defineProperty;
|
|
4
|
-
var E = (t, e, n) => e in t ? v(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
5
|
-
var d = (t, e, n) => (E(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
6
|
-
import c, { createContext as D, useContext as g, useRef as M, useState as P, useEffect as w } from "react";
|
|
7
|
-
import "./propsContext-CauylOgH.js";
|
|
8
|
-
import { P as x } from "./PropsContextProvider-DZvwqHLP.js";
|
|
9
|
-
import "@react-aria/utils";
|
|
10
|
-
import "remeda";
|
|
11
|
-
import { u as y, O as R } from "./index-Cb88QILt.js";
|
|
12
|
-
import { TunnelProvider as B, TunnelExit as I } from "@mittwald/react-tunnel";
|
|
13
|
-
import { makeObservable as O, observable as T, action as N } from "mobx";
|
|
14
|
-
import { u as $ } from "./useSelector-DpU7_HMO.js";
|
|
15
|
-
const b = D(void 0), G = () => g(b), H = b.Provider, S = (t) => (...e) => {
|
|
16
|
-
const n = [...t], i = n.shift();
|
|
17
|
-
if (i) {
|
|
18
|
-
const r = i(...e), s = () => n.length === 0 ? r : S(n)(...e);
|
|
19
|
-
return r instanceof Promise ? r.then(s) : s();
|
|
20
|
-
}
|
|
21
|
-
}, C = "flowBreakActionMarker";
|
|
22
|
-
function U(t) {
|
|
23
|
-
return !!t && t instanceof Error && t.message === C;
|
|
24
|
-
}
|
|
25
|
-
const j = () => {
|
|
26
|
-
throw new Error(C);
|
|
27
|
-
}, A = {
|
|
28
|
-
pending: 1e3,
|
|
29
|
-
succeeded: 1500,
|
|
30
|
-
failed: 2e3
|
|
31
|
-
};
|
|
32
|
-
class q {
|
|
33
|
-
constructor(e, n, i = {}) {
|
|
34
|
-
d(this, "options");
|
|
35
|
-
d(this, "state");
|
|
36
|
-
d(this, "args");
|
|
37
|
-
d(this, "isDone", !1);
|
|
38
|
-
d(this, "error");
|
|
39
|
-
const {
|
|
40
|
-
resetAfterDone: r = !0,
|
|
41
|
-
onFeedbackDone: s = () => {
|
|
42
|
-
},
|
|
43
|
-
showFeedback: o = !1
|
|
44
|
-
} = i;
|
|
45
|
-
this.state = e, this.args = n, this.options = { resetAfterDone: r, onFeedbackDone: s, showFeedback: o };
|
|
46
|
-
}
|
|
47
|
-
onAsyncStart() {
|
|
48
|
-
this.options.showFeedback = !0, this.state.updateState("isExecuting"), setTimeout(() => this.startPending(), A.pending);
|
|
49
|
-
}
|
|
50
|
-
onSucceeded() {
|
|
51
|
-
this.onDone();
|
|
52
|
-
}
|
|
53
|
-
onFailed(e) {
|
|
54
|
-
this.error = e ?? new Error("Unknown error"), console.error(e), this.onDone();
|
|
55
|
-
}
|
|
56
|
-
startFailedFeedback() {
|
|
57
|
-
U(this.error) ? this.resetAfterDone() : (this.state.updateState("isFailed"), setTimeout(() => this.resetAfterDone(), A.failed));
|
|
58
|
-
}
|
|
59
|
-
startSucceededFeedback() {
|
|
60
|
-
this.state.updateState("isSucceeded"), setTimeout(() => this.resetAfterDone(), A.succeeded);
|
|
61
|
-
}
|
|
62
|
-
resetAfterDone() {
|
|
63
|
-
this.options.resetAfterDone && this.state.updateState("isIdle"), this.error || this.options.onFeedbackDone(...this.args);
|
|
64
|
-
}
|
|
65
|
-
onDone() {
|
|
66
|
-
this.isDone = !0, this.options.showFeedback ? this.error ? this.startFailedFeedback() : this.startSucceededFeedback() : this.resetAfterDone();
|
|
67
|
-
}
|
|
68
|
-
startPending() {
|
|
69
|
-
this.isDone || this.state.updateState("isPending");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
class p {
|
|
73
|
-
constructor() {
|
|
74
|
-
d(this, "state", "isIdle");
|
|
75
|
-
O(this, {
|
|
76
|
-
state: T,
|
|
77
|
-
updateState: N
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
static useNew() {
|
|
81
|
-
return M(new p()).current;
|
|
82
|
-
}
|
|
83
|
-
updateState(e) {
|
|
84
|
-
this.state = e;
|
|
85
|
-
}
|
|
86
|
-
useState() {
|
|
87
|
-
return $(() => this.state, [this]);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const z = () => {
|
|
91
|
-
}, J = (t) => {
|
|
92
|
-
const {
|
|
93
|
-
action: e,
|
|
94
|
-
toggleModal: n,
|
|
95
|
-
openModal: i,
|
|
96
|
-
closeModal: r,
|
|
97
|
-
break: s
|
|
98
|
-
} = t, o = y();
|
|
99
|
-
return e || (n ? o.toggle : i ? o.open : r ? o.close : s ? j : z);
|
|
100
|
-
}, K = (t, e = {}) => {
|
|
101
|
-
const {
|
|
102
|
-
onSync: n = () => {
|
|
103
|
-
},
|
|
104
|
-
onAsync: i = () => {
|
|
105
|
-
},
|
|
106
|
-
then: r = () => {
|
|
107
|
-
},
|
|
108
|
-
catch: s = () => {
|
|
109
|
-
},
|
|
110
|
-
finally: o = () => {
|
|
111
|
-
}
|
|
112
|
-
} = e;
|
|
113
|
-
try {
|
|
114
|
-
const a = t();
|
|
115
|
-
return a instanceof Promise ? (i(), a.then(r).catch(s).finally(o)) : (n(), r(a), o(), a);
|
|
116
|
-
} catch (a) {
|
|
117
|
-
n(), s(a), o();
|
|
118
|
-
}
|
|
119
|
-
}, L = (t) => {
|
|
120
|
-
const { isConfirmationAction: e, showFeedback: n } = t, i = J(t), r = G(), s = p.useNew(), o = !e, a = e ? void 0 : r, k = e ? r : void 0, m = S([i, a]);
|
|
121
|
-
return {
|
|
122
|
-
callAction: (...l) => {
|
|
123
|
-
const f = new q(s, l, {
|
|
124
|
-
onFeedbackDone: k,
|
|
125
|
-
resetAfterDone: o,
|
|
126
|
-
showFeedback: n
|
|
127
|
-
});
|
|
128
|
-
return K(m, {
|
|
129
|
-
onAsync: () => f.onAsyncStart(),
|
|
130
|
-
then: () => f.onSucceeded(),
|
|
131
|
-
catch: (F) => f.onFailed(F)
|
|
132
|
-
});
|
|
133
|
-
},
|
|
134
|
-
state: s
|
|
135
|
-
};
|
|
136
|
-
}, h = (t) => {
|
|
137
|
-
const [e, n] = P(!1), i = R.useNew(), r = L(t), s = e ? i.open : r.callAction, o = r.state.useState(), m = {
|
|
138
|
-
Button: {
|
|
139
|
-
onPress: s,
|
|
140
|
-
isPending: o === "isPending" ? !0 : void 0,
|
|
141
|
-
"aria-disabled": o !== "isIdle" ? !0 : void 0,
|
|
142
|
-
isSucceeded: o === "isSucceeded" ? !0 : void 0,
|
|
143
|
-
isFailed: o === "isFailed" ? !0 : void 0
|
|
144
|
-
},
|
|
145
|
-
Modal: {
|
|
146
|
-
tunnelId: "outsideActionProvider",
|
|
147
|
-
render: (u, l) => (w(() => {
|
|
148
|
-
if (l.slot === "actionConfirm")
|
|
149
|
-
return n(!0), () => {
|
|
150
|
-
n(!1);
|
|
151
|
-
};
|
|
152
|
-
}, []), /* @__PURE__ */ c.createElement(u, { controller: i, ...l })),
|
|
153
|
-
ButtonGroup: {
|
|
154
|
-
Button: {
|
|
155
|
-
render: (u, l) => {
|
|
156
|
-
const { variant: f } = l;
|
|
157
|
-
return f === "secondary" ? /* @__PURE__ */ c.createElement(h, { break: !0 }, /* @__PURE__ */ c.createElement(h, { closeModal: !0 }, /* @__PURE__ */ c.createElement(u, { ...l }))) : /* @__PURE__ */ c.createElement(h, { closeModal: !0 }, /* @__PURE__ */ c.createElement(h, { ...t, isConfirmationAction: !0 }, /* @__PURE__ */ c.createElement(u, { ...l })));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
return /* @__PURE__ */ c.createElement(B, null, /* @__PURE__ */ c.createElement(
|
|
164
|
-
x,
|
|
165
|
-
{
|
|
166
|
-
props: m,
|
|
167
|
-
dependencies: [e, o],
|
|
168
|
-
mergeInParentContext: !0
|
|
169
|
-
},
|
|
170
|
-
/* @__PURE__ */ c.createElement(H, { value: s }, t.children),
|
|
171
|
-
/* @__PURE__ */ c.createElement(I, { id: "outsideActionProvider" })
|
|
172
|
-
));
|
|
173
|
-
};
|
|
174
|
-
export {
|
|
175
|
-
h as A
|
|
176
|
-
};
|