@mittwald/flow-react-components 0.1.0-alpha.71 → 0.1.0-alpha.73
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-DFbRza4T.js +150 -0
- package/dist/Action.js +1 -1
- package/dist/Button-BPCYuj3x.js +113 -0
- package/dist/Button.js +1 -1
- package/dist/CopyButton.js +2 -2
- package/dist/List.js +1 -1
- package/dist/Modal.js +1 -1
- package/dist/NumberField.js +1 -1
- package/dist/Tabs.js +1 -1
- package/dist/controller.js +1 -1
- package/dist/hooks.js +8 -0
- package/dist/{useOverlayState-BnPe_CrX.js → index-ViVxK7d1.js} +7 -7
- package/dist/styles.css +1 -1
- package/dist/types/components/Action/ActionState.d.ts +8 -11
- package/dist/types/components/Action/ariaLive.d.ts +9 -0
- package/dist/types/components/Action/hooks/useCallAction.d.ts +1 -0
- package/dist/types/components/Action/stories/Default.stories.d.ts +2 -0
- package/dist/types/components/Button/Button.d.ts +1 -0
- package/dist/types/components/Button/stories/lib.d.ts +2 -1
- package/dist/types/lib/hooks/index.d.ts +1 -0
- package/package.json +9 -4
- package/dist/Action-B9PIFbjG.js +0 -164
- package/dist/Button-B2GKVrxY.js +0 -102
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
var S = Object.defineProperty;
|
|
4
|
+
var b = (e, t, o) => t in e ? S(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
5
|
+
var r = (e, t, o) => (b(e, typeof t != "symbol" ? t + "" : t, o), o);
|
|
6
|
+
import A, { useRef as M } from "react";
|
|
7
|
+
import "./propsContext-CauylOgH.js";
|
|
8
|
+
import { P } from "./PropsContextProvider-DZvwqHLP.js";
|
|
9
|
+
import "@react-aria/utils";
|
|
10
|
+
import "remeda";
|
|
11
|
+
import "dot-prop";
|
|
12
|
+
import { u as C } from "./useProps-Dx3m8kCJ.js";
|
|
13
|
+
import { u as F } from "./index-ViVxK7d1.js";
|
|
14
|
+
import { makeObservable as k, observable as y, runInAction as x } from "mobx";
|
|
15
|
+
import { u as I } from "./useSelector-DpU7_HMO.js";
|
|
16
|
+
const v = () => {
|
|
17
|
+
}, w = (e) => {
|
|
18
|
+
const t = F();
|
|
19
|
+
return (e == null ? void 0 : e.type) === "function" ? e.fn : (e == null ? void 0 : e.type) === "toggleModal" ? t.toggle : (e == null ? void 0 : e.type) === "openModal" ? t.open : (e == null ? void 0 : e.type) === "closeModal" ? t.close : v;
|
|
20
|
+
}, m = (e, t) => {
|
|
21
|
+
const o = [...t];
|
|
22
|
+
let s;
|
|
23
|
+
for (; o.length > 0; )
|
|
24
|
+
if (s = o.shift(), s) {
|
|
25
|
+
const i = s(...e);
|
|
26
|
+
if (i instanceof Promise)
|
|
27
|
+
return i.then(() => m(e, o));
|
|
28
|
+
}
|
|
29
|
+
}, p = {
|
|
30
|
+
pending: 1e3,
|
|
31
|
+
succeeded: 1500,
|
|
32
|
+
failed: 2e3
|
|
33
|
+
};
|
|
34
|
+
class h {
|
|
35
|
+
constructor(t = {}) {
|
|
36
|
+
r(this, "feedback");
|
|
37
|
+
r(this, "executionCount", 0);
|
|
38
|
+
r(this, "state", "isIdle");
|
|
39
|
+
const { feedback: o = !1 } = t;
|
|
40
|
+
this.feedback = o, k(this, {
|
|
41
|
+
state: y
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
static useNew(t) {
|
|
45
|
+
return M(new h(t)).current;
|
|
46
|
+
}
|
|
47
|
+
onStart() {
|
|
48
|
+
const t = ++this.executionCount;
|
|
49
|
+
this.updateState("isExecuting"), setTimeout(() => this.startPending(t), p.pending);
|
|
50
|
+
}
|
|
51
|
+
onSucceeded() {
|
|
52
|
+
this.onDone(!0);
|
|
53
|
+
}
|
|
54
|
+
onFailed() {
|
|
55
|
+
this.onDone(!1);
|
|
56
|
+
}
|
|
57
|
+
updateState(t) {
|
|
58
|
+
x(() => {
|
|
59
|
+
this.state = t;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
startFailedFeedback() {
|
|
63
|
+
this.feedback && (this.updateState("isFailed"), setTimeout(() => this.updateState("isIdle"), p.failed));
|
|
64
|
+
}
|
|
65
|
+
startSucceededFeedback() {
|
|
66
|
+
this.feedback && (this.updateState("isSucceeded"), setTimeout(() => this.updateState("isIdle"), p.succeeded));
|
|
67
|
+
}
|
|
68
|
+
onDone(t) {
|
|
69
|
+
t ? this.startSucceededFeedback() : this.startFailedFeedback();
|
|
70
|
+
}
|
|
71
|
+
startPending(t) {
|
|
72
|
+
this.state !== "isIdle" && t === this.executionCount && this.updateState("isPending");
|
|
73
|
+
}
|
|
74
|
+
useState() {
|
|
75
|
+
return I(() => this.state, [this]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const W = (e, t) => {
|
|
79
|
+
const { action: o } = C("Action", {}), s = w(e), i = (...c) => m(c, [s, o]), n = h.useNew(t);
|
|
80
|
+
return {
|
|
81
|
+
callAction: i,
|
|
82
|
+
callActionWithStateHandling: (...c) => {
|
|
83
|
+
try {
|
|
84
|
+
n.onStart();
|
|
85
|
+
const a = i(...c);
|
|
86
|
+
if (a instanceof Promise)
|
|
87
|
+
return a.then(() => n.onSucceeded()).catch(() => n.onFailed());
|
|
88
|
+
n.onSucceeded();
|
|
89
|
+
} catch {
|
|
90
|
+
n.onFailed();
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
state: n
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
function f(e) {
|
|
97
|
+
return typeof e == "boolean" ? void 0 : e;
|
|
98
|
+
}
|
|
99
|
+
const d = {
|
|
100
|
+
fn: (e) => ({
|
|
101
|
+
type: "function",
|
|
102
|
+
fn: e
|
|
103
|
+
}),
|
|
104
|
+
openModal: (e) => ({
|
|
105
|
+
type: "openModal",
|
|
106
|
+
controller: f(e)
|
|
107
|
+
}),
|
|
108
|
+
closeModal: (e) => ({
|
|
109
|
+
type: "closeModal",
|
|
110
|
+
controller: f(e)
|
|
111
|
+
}),
|
|
112
|
+
toggleModal: (e) => ({
|
|
113
|
+
type: "toggleModal",
|
|
114
|
+
controller: f(e)
|
|
115
|
+
})
|
|
116
|
+
}, G = (e) => {
|
|
117
|
+
const {
|
|
118
|
+
children: t,
|
|
119
|
+
feedback: o,
|
|
120
|
+
action: s,
|
|
121
|
+
toggleModal: i,
|
|
122
|
+
openModal: n,
|
|
123
|
+
closeModal: u
|
|
124
|
+
} = e, c = s ? d.fn(s) : i ? d.toggleModal(i) : n ? d.openModal(n) : u ? d.closeModal(u) : void 0, a = W(c, {
|
|
125
|
+
feedback: o
|
|
126
|
+
}), l = a.state.useState(), g = {
|
|
127
|
+
Button: {
|
|
128
|
+
onPress: a.callActionWithStateHandling,
|
|
129
|
+
isPending: l === "isPending",
|
|
130
|
+
"aria-disabled": l !== "isIdle",
|
|
131
|
+
isSucceeded: l === "isSucceeded",
|
|
132
|
+
isFailed: l === "isFailed"
|
|
133
|
+
},
|
|
134
|
+
Action: {
|
|
135
|
+
action: a.callAction
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return /* @__PURE__ */ A.createElement(
|
|
139
|
+
P,
|
|
140
|
+
{
|
|
141
|
+
mergeInParentContext: !0,
|
|
142
|
+
props: g,
|
|
143
|
+
dependencies: [l]
|
|
144
|
+
},
|
|
145
|
+
t
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
export {
|
|
149
|
+
G as A
|
|
150
|
+
};
|
package/dist/Action.js
CHANGED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import o, { useEffect as p } from "react";
|
|
4
|
+
import * as S from "react-aria-components";
|
|
5
|
+
import x from "clsx";
|
|
6
|
+
import { C as F } from "./ClearPropsContext-CeCMjUK9.js";
|
|
7
|
+
import { P as y } from "./PropsContextProvider-DZvwqHLP.js";
|
|
8
|
+
import "@react-aria/utils";
|
|
9
|
+
import "./propsContext-CauylOgH.js";
|
|
10
|
+
import "remeda";
|
|
11
|
+
import "@tabler/icons-react";
|
|
12
|
+
import "./Icon-DdQwrIup.js";
|
|
13
|
+
import { I as E, a as C } from "./IconSucceeded-BM7cipIv.js";
|
|
14
|
+
import { W as I } from "./Wrap-DGT1h1o3.js";
|
|
15
|
+
import { T as N } from "./Text-CBzyk1oM.js";
|
|
16
|
+
import { f as h } from "./flowComponent-BuF0s2uG.js";
|
|
17
|
+
import { L as A } from "./LoadingSpinner-DqsZ7IDL.js";
|
|
18
|
+
import { useLocalizedStringFormatter as D } from "react-aria";
|
|
19
|
+
import { useLiveRegion as T } from "@chakra-ui/live-region";
|
|
20
|
+
const z = "flow--button", B = "flow--button--avatar", L = "flow--button--icon", k = "flow--button--text", R = "flow--button--content", K = "flow--button--state-icon", U = "flow--button--is-succeeded", W = "flow--button--is-failed", $ = "flow--button--is-pending", j = "flow--button--plain", q = "flow--button--primary", G = "flow--button--solid", H = "flow--button--aria-disabled", J = "flow--button--accent", M = "flow--button--danger", O = "flow--button--secondary", Q = "flow--button--soft", t = {
|
|
21
|
+
button: z,
|
|
22
|
+
avatar: B,
|
|
23
|
+
icon: L,
|
|
24
|
+
text: k,
|
|
25
|
+
content: R,
|
|
26
|
+
stateIcon: K,
|
|
27
|
+
"size-s": "flow--button--size-s",
|
|
28
|
+
isSucceeded: U,
|
|
29
|
+
isFailed: W,
|
|
30
|
+
isPending: $,
|
|
31
|
+
plain: j,
|
|
32
|
+
primary: q,
|
|
33
|
+
solid: G,
|
|
34
|
+
ariaDisabled: H,
|
|
35
|
+
accent: J,
|
|
36
|
+
danger: M,
|
|
37
|
+
secondary: O,
|
|
38
|
+
soft: Q
|
|
39
|
+
}, V = {
|
|
40
|
+
"de-DE": {
|
|
41
|
+
"action.isFailed": "Fehlgeschlagen",
|
|
42
|
+
"action.isPending": "Ausstehend...",
|
|
43
|
+
"action.isSucceeded": "Erfolgreich"
|
|
44
|
+
},
|
|
45
|
+
"en-EN": {
|
|
46
|
+
"action.isFailed": "Failed",
|
|
47
|
+
"action.isPending": "Pending...",
|
|
48
|
+
"action.isSucceeded": "Succeeded"
|
|
49
|
+
}
|
|
50
|
+
}, X = (e, c = {}) => {
|
|
51
|
+
const i = D(V), {
|
|
52
|
+
isPendingText: a = i.format("action.isPending"),
|
|
53
|
+
isSucceededText: d = i.format("action.isSucceeded"),
|
|
54
|
+
isFailedText: s = i.format("action.isFailed")
|
|
55
|
+
} = c, n = T({
|
|
56
|
+
"aria-live": "polite",
|
|
57
|
+
"aria-atomic": !1,
|
|
58
|
+
"aria-relevant": "text additions",
|
|
59
|
+
role: "status"
|
|
60
|
+
});
|
|
61
|
+
p(() => {
|
|
62
|
+
e === "isPending" ? n.speak(a) : e === "isSucceeded" ? n.speak(d) : e === "isFailed" && n.speak(s);
|
|
63
|
+
}, [e]);
|
|
64
|
+
}, Y = (e) => ((e.isPending || e.isSucceeded || e.isFailed || e["aria-disabled"]) && (e = { ...e }, e.onPress = void 0, e.onPressStart = void 0, e.onPressEnd = void 0, e.onPressChange = void 0, e.onPressUp = void 0, e.onKeyDown = void 0, e.onKeyUp = void 0), e), be = h("Button", (e) => {
|
|
65
|
+
e = Y(e);
|
|
66
|
+
const {
|
|
67
|
+
variant: c = "primary",
|
|
68
|
+
style: i = "solid",
|
|
69
|
+
children: a,
|
|
70
|
+
className: d,
|
|
71
|
+
size: s = "m",
|
|
72
|
+
isPending: n,
|
|
73
|
+
isSucceeded: r,
|
|
74
|
+
isFailed: l,
|
|
75
|
+
"aria-disabled": f,
|
|
76
|
+
ref: u,
|
|
77
|
+
...b
|
|
78
|
+
} = e, g = x(
|
|
79
|
+
t.button,
|
|
80
|
+
n && t.isPending,
|
|
81
|
+
r && t.isSucceeded,
|
|
82
|
+
l && t.isFailed,
|
|
83
|
+
t[`size-${s}`],
|
|
84
|
+
t[c],
|
|
85
|
+
t[i],
|
|
86
|
+
d,
|
|
87
|
+
/**
|
|
88
|
+
* Workaround warning: The Aria.Button does not support "aria-disabled" by
|
|
89
|
+
* now, so this Button will be visually disabled via CSS.
|
|
90
|
+
*/
|
|
91
|
+
f && t.ariaDisabled
|
|
92
|
+
);
|
|
93
|
+
X(
|
|
94
|
+
n ? "isPending" : r ? "isSucceeded" : l ? "isFailed" : "isIdle"
|
|
95
|
+
);
|
|
96
|
+
const P = {
|
|
97
|
+
Icon: {
|
|
98
|
+
className: t.icon,
|
|
99
|
+
"aria-hidden": !0,
|
|
100
|
+
size: s
|
|
101
|
+
},
|
|
102
|
+
Text: {
|
|
103
|
+
className: t.text
|
|
104
|
+
},
|
|
105
|
+
Avatar: {
|
|
106
|
+
className: t.avatar
|
|
107
|
+
}
|
|
108
|
+
}, m = r ? E : l ? C : n ? A : void 0, w = m && /* @__PURE__ */ o.createElement(m, { size: s, className: t.stateIcon }), v = typeof a == "string";
|
|
109
|
+
return /* @__PURE__ */ o.createElement(F, null, /* @__PURE__ */ o.createElement(S.Button, { className: g, ref: u, ...b }, /* @__PURE__ */ o.createElement(y, { props: P }, /* @__PURE__ */ o.createElement("span", { className: t.content }, /* @__PURE__ */ o.createElement(I, { if: v }, /* @__PURE__ */ o.createElement(N, null, a)))), w));
|
|
110
|
+
});
|
|
111
|
+
export {
|
|
112
|
+
be as B
|
|
113
|
+
};
|
package/dist/Button.js
CHANGED
package/dist/CopyButton.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
import o from "react";
|
|
4
4
|
import a from "copy-to-clipboard";
|
|
5
|
-
import { B as i } from "./Button-
|
|
5
|
+
import { B as i } from "./Button-BPCYuj3x.js";
|
|
6
6
|
import "@tabler/icons-react";
|
|
7
7
|
import "./Icon-DdQwrIup.js";
|
|
8
8
|
import { I as c } from "./IconCopy-D40P_nc1.js";
|
|
@@ -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-BuF0s2uG.js";
|
|
18
|
-
import { A as E } from "./Action-
|
|
18
|
+
import { A as E } from "./Action-DFbRza4T.js";
|
|
19
19
|
const B = {
|
|
20
20
|
"de-DE": {
|
|
21
21
|
"copyButton.copy": "Kopieren"
|
package/dist/List.js
CHANGED
|
@@ -12,7 +12,7 @@ import { T as b } from "./Text-CBzyk1oM.js";
|
|
|
12
12
|
import "@tabler/icons-react";
|
|
13
13
|
import "./Icon-DdQwrIup.js";
|
|
14
14
|
import { I as $ } from "./IconChevronDown-a_vSoTxH.js";
|
|
15
|
-
import { B as h } from "./Button-
|
|
15
|
+
import { B as h } from "./Button-BPCYuj3x.js";
|
|
16
16
|
import { useMessageFormatter as H, useLocalizedStringFormatter as q } from "react-aria";
|
|
17
17
|
import K from "clsx";
|
|
18
18
|
import { I as rt } from "./IconClose-BcM-VKmn.js";
|
package/dist/Modal.js
CHANGED
|
@@ -9,7 +9,7 @@ import { P as C } from "./PropsContextProvider-DZvwqHLP.js";
|
|
|
9
9
|
import "@react-aria/utils";
|
|
10
10
|
import "remeda";
|
|
11
11
|
import { TunnelProvider as y, TunnelExit as x } from "@mittwald/react-tunnel";
|
|
12
|
-
import { u as z, a as E } from "./
|
|
12
|
+
import { u as z, a as E } from "./index-ViVxK7d1.js";
|
|
13
13
|
const b = "flow--modal", T = "flow--modal--dialog", N = "flow--modal--overlay", P = "flow--modal--button-group", G = "flow--modal--content", I = "flow--modal--off-canvas", t = {
|
|
14
14
|
modal: b,
|
|
15
15
|
"modal-zoom": "flow--modal--modal-zoom",
|
package/dist/NumberField.js
CHANGED
|
@@ -10,7 +10,7 @@ import "@react-aria/utils";
|
|
|
10
10
|
import "./propsContext-CauylOgH.js";
|
|
11
11
|
import "remeda";
|
|
12
12
|
import { F as I } from "./FieldError-De8_olcs.js";
|
|
13
|
-
import { B as a } from "./Button-
|
|
13
|
+
import { B as a } from "./Button-BPCYuj3x.js";
|
|
14
14
|
import "@tabler/icons-react";
|
|
15
15
|
import "./Icon-DdQwrIup.js";
|
|
16
16
|
import { I as C } from "./IconChevronDown-a_vSoTxH.js";
|
package/dist/Tabs.js
CHANGED
|
@@ -9,7 +9,7 @@ import { f as S } from "./flowComponent-BuF0s2uG.js";
|
|
|
9
9
|
import { useCallbackRef as B } from "use-callback-ref";
|
|
10
10
|
import { C as K } from "./ContextMenu-DJ4VRDCG.js";
|
|
11
11
|
import { M as L } from "./MenuItem-DbXZNJo6.js";
|
|
12
|
-
import { B as F } from "./Button-
|
|
12
|
+
import { B as F } from "./Button-BPCYuj3x.js";
|
|
13
13
|
import "@tabler/icons-react";
|
|
14
14
|
import "./Icon-DdQwrIup.js";
|
|
15
15
|
import { I as A } from "./IconContextMenu-bD7n5nvt.js";
|
package/dist/controller.js
CHANGED
package/dist/hooks.js
ADDED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
var p = Object.defineProperty;
|
|
4
4
|
var O = (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) => (O(t, typeof e != "symbol" ? e + "" : e, s), s);
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { makeObservable as l, observable as c, action as o } from "mobx";
|
|
7
|
+
import { useState as m, createContext as b, useContext as h } from "react";
|
|
8
8
|
import { u as d } from "./useSelector-DpU7_HMO.js";
|
|
9
9
|
class n {
|
|
10
10
|
constructor(e = !1) {
|
|
11
11
|
i(this, "isOpen");
|
|
12
|
-
|
|
13
|
-
isOpen:
|
|
12
|
+
l(this, {
|
|
13
|
+
isOpen: c,
|
|
14
14
|
open: o.bound,
|
|
15
15
|
close: o.bound,
|
|
16
16
|
toggle: o.bound,
|
|
@@ -18,7 +18,7 @@ class n {
|
|
|
18
18
|
}), this.isOpen = e;
|
|
19
19
|
}
|
|
20
20
|
static useNew(e) {
|
|
21
|
-
return
|
|
21
|
+
return m(new n(e))[0];
|
|
22
22
|
}
|
|
23
23
|
open() {
|
|
24
24
|
this.isOpen = !0;
|
|
@@ -36,8 +36,8 @@ class n {
|
|
|
36
36
|
return d(() => this.isOpen);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
const a =
|
|
40
|
-
const { reuseControllerFromContext: e = !0, defaultOpen: s } = t, u = n.useNew(s), r =
|
|
39
|
+
const a = b(new n()), w = a.Provider, g = (t = {}) => {
|
|
40
|
+
const { reuseControllerFromContext: e = !0, defaultOpen: s } = t, u = n.useNew(s), r = h(a);
|
|
41
41
|
return e && r ? r : u;
|
|
42
42
|
};
|
|
43
43
|
export {
|