@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
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
interface Options {
|
|
2
2
|
feedback?: boolean;
|
|
3
3
|
}
|
|
4
|
-
export type
|
|
4
|
+
export type ActionStateValue = "isIdle" | "isSucceeded" | "isPending" | "isExecuting" | "isFailed";
|
|
5
5
|
export declare class ActionState {
|
|
6
|
-
isPending: boolean;
|
|
7
|
-
isExecuting: boolean;
|
|
8
|
-
isSucceeded: boolean;
|
|
9
|
-
isFailed: boolean;
|
|
10
6
|
private readonly feedback;
|
|
11
7
|
private executionCount;
|
|
8
|
+
state: ActionStateValue;
|
|
12
9
|
private constructor();
|
|
13
10
|
static useNew(opts?: Options): ActionState;
|
|
14
|
-
|
|
11
|
+
onStart(): void;
|
|
12
|
+
onSucceeded(): void;
|
|
13
|
+
onFailed(): void;
|
|
14
|
+
private updateState;
|
|
15
15
|
private startFailedFeedback;
|
|
16
16
|
private startSucceededFeedback;
|
|
17
17
|
private onDone;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
startPending(forExecutionCount: number): void;
|
|
21
|
-
onStart(): void;
|
|
22
|
-
useObserve(): ObservedActionState;
|
|
18
|
+
private startPending;
|
|
19
|
+
useState(): ActionStateValue;
|
|
23
20
|
}
|
|
24
21
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionStateValue } from './ActionState';
|
|
2
|
+
|
|
3
|
+
interface Options {
|
|
4
|
+
isPendingText?: string;
|
|
5
|
+
isSucceededText?: string;
|
|
6
|
+
isFailedText?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const useAriaAnnounceActionState: (actionState: ActionStateValue, options?: Options) => void;
|
|
9
|
+
export {};
|
|
@@ -6,6 +6,8 @@ export default meta;
|
|
|
6
6
|
type Story = StoryObj<typeof Action>;
|
|
7
7
|
export declare const Default: Story;
|
|
8
8
|
export declare const Async: Story;
|
|
9
|
+
export declare const AsyncLong: Story;
|
|
9
10
|
export declare const AsyncWithFeedback: Story;
|
|
11
|
+
export declare const AsyncLongWithFeedback: Story;
|
|
10
12
|
export declare const Nested: Story;
|
|
11
13
|
export declare const NestedAsync: Story;
|
|
@@ -9,6 +9,7 @@ export interface ButtonProps extends PropsWithChildren<Omit<Aria.ButtonProps, "s
|
|
|
9
9
|
style?: "plain" | "solid" | "soft";
|
|
10
10
|
/** @default "m" */
|
|
11
11
|
size?: "m" | "s";
|
|
12
|
+
"aria-disabled"?: boolean;
|
|
12
13
|
isPending?: boolean;
|
|
13
14
|
isSucceeded?: boolean;
|
|
14
15
|
isFailed?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const syncFunction: import('@storybook/addon-actions').HandlerFunction;
|
|
4
4
|
export declare const asyncFunction: (...args: unknown[]) => Promise<void>;
|
|
5
|
+
export declare const asyncLongFunction: (...args: unknown[]) => Promise<void>;
|
|
5
6
|
export declare const button: React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useOverlayState } from '../controller';
|
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.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -202,6 +202,10 @@
|
|
|
202
202
|
"types": "./dist/types/components/Tooltip/index.d.ts",
|
|
203
203
|
"import": "./dist/Tooltip.js"
|
|
204
204
|
},
|
|
205
|
+
"./hooks": {
|
|
206
|
+
"types": "./dist/types/lib/hooks/index.d.ts",
|
|
207
|
+
"import": "./dist/hooks.js"
|
|
208
|
+
},
|
|
205
209
|
"./nextjs": {
|
|
206
210
|
"types": "./dist/types/integrations/nextjs/index.d.ts",
|
|
207
211
|
"import": "./dist/nextjs.js"
|
|
@@ -230,7 +234,8 @@
|
|
|
230
234
|
"test:unit": "run vitest run"
|
|
231
235
|
},
|
|
232
236
|
"dependencies": {
|
|
233
|
-
"@
|
|
237
|
+
"@chakra-ui/live-region": "^2.1.0",
|
|
238
|
+
"@mittwald/react-tunnel": "^0.1.0-alpha.73",
|
|
234
239
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
235
240
|
"@react-aria/utils": "^3.23.2",
|
|
236
241
|
"@react-types/shared": "^3.22.1",
|
|
@@ -254,7 +259,7 @@
|
|
|
254
259
|
},
|
|
255
260
|
"devDependencies": {
|
|
256
261
|
"@faker-js/faker": "^8.4.1",
|
|
257
|
-
"@mittwald/flow-design-tokens": "^0.1.0-alpha.
|
|
262
|
+
"@mittwald/flow-design-tokens": "^0.1.0-alpha.73",
|
|
258
263
|
"@mittwald/react-use-promise": "^2.3.13",
|
|
259
264
|
"@nx/storybook": "^18.3.1",
|
|
260
265
|
"@storybook/addon-a11y": "^8.0.8",
|
|
@@ -329,5 +334,5 @@
|
|
|
329
334
|
"optional": true
|
|
330
335
|
}
|
|
331
336
|
},
|
|
332
|
-
"gitHead": "
|
|
337
|
+
"gitHead": "c0214f8aa933b331a088bf27b8d753142e778f5e"
|
|
333
338
|
}
|
package/dist/Action-B9PIFbjG.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
/* */
|
|
3
|
-
var S = Object.defineProperty;
|
|
4
|
-
var P = (e, t, s) => t in e ? S(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
5
|
-
var i = (e, t, s) => (P(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
6
|
-
import M, { useState as k } 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 "dot-prop";
|
|
12
|
-
import { u as A } from "./useProps-Dx3m8kCJ.js";
|
|
13
|
-
import { u as C } from "./useOverlayState-BnPe_CrX.js";
|
|
14
|
-
import { makeObservable as y, observable as r, action as l } from "mobx";
|
|
15
|
-
import { u as v } from "./useSelector-DpU7_HMO.js";
|
|
16
|
-
const E = () => {
|
|
17
|
-
}, O = (e) => {
|
|
18
|
-
const t = C();
|
|
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 : E;
|
|
20
|
-
}, m = (e, t) => {
|
|
21
|
-
const s = [...t];
|
|
22
|
-
let n;
|
|
23
|
-
for (; s.length > 0; )
|
|
24
|
-
if (n = s.shift(), n) {
|
|
25
|
-
const o = n(...e);
|
|
26
|
-
if (o instanceof Promise)
|
|
27
|
-
return o.then(() => m(e, s));
|
|
28
|
-
}
|
|
29
|
-
}, p = {
|
|
30
|
-
pending: 1e3,
|
|
31
|
-
succeeded: 1500,
|
|
32
|
-
failed: 2e3
|
|
33
|
-
};
|
|
34
|
-
class b {
|
|
35
|
-
constructor(t = {}) {
|
|
36
|
-
i(this, "isPending", !1);
|
|
37
|
-
i(this, "isExecuting", !1);
|
|
38
|
-
i(this, "isSucceeded", !1);
|
|
39
|
-
i(this, "isFailed", !1);
|
|
40
|
-
i(this, "feedback");
|
|
41
|
-
i(this, "executionCount", 0);
|
|
42
|
-
const { feedback: s = !1 } = t;
|
|
43
|
-
y(this, {
|
|
44
|
-
isPending: r,
|
|
45
|
-
isExecuting: r,
|
|
46
|
-
isSucceeded: r,
|
|
47
|
-
isFailed: r,
|
|
48
|
-
onStart: l.bound,
|
|
49
|
-
onSucceeded: l.bound,
|
|
50
|
-
onFailed: l.bound,
|
|
51
|
-
resetFeedback: l.bound,
|
|
52
|
-
startPending: l.bound
|
|
53
|
-
}), this.feedback = s;
|
|
54
|
-
}
|
|
55
|
-
static useNew(t) {
|
|
56
|
-
return k(new b(t))[0];
|
|
57
|
-
}
|
|
58
|
-
resetFeedback() {
|
|
59
|
-
this.isFailed = !1, this.isSucceeded = !1;
|
|
60
|
-
}
|
|
61
|
-
startFailedFeedback() {
|
|
62
|
-
this.feedback && (this.isFailed = !0, setTimeout(this.resetFeedback, p.failed));
|
|
63
|
-
}
|
|
64
|
-
startSucceededFeedback() {
|
|
65
|
-
this.feedback && (this.isSucceeded = !0, setTimeout(this.resetFeedback, p.succeeded));
|
|
66
|
-
}
|
|
67
|
-
onDone(t) {
|
|
68
|
-
this.isExecuting = !1, this.isPending = !1, t ? this.startSucceededFeedback() : this.startFailedFeedback();
|
|
69
|
-
}
|
|
70
|
-
onFailed() {
|
|
71
|
-
this.onDone(!1);
|
|
72
|
-
}
|
|
73
|
-
onSucceeded() {
|
|
74
|
-
this.onDone(!0);
|
|
75
|
-
}
|
|
76
|
-
startPending(t) {
|
|
77
|
-
this.isExecuting && t === this.executionCount && (this.isPending = !0);
|
|
78
|
-
}
|
|
79
|
-
onStart() {
|
|
80
|
-
const t = ++this.executionCount;
|
|
81
|
-
this.isExecuting = !0, setTimeout(() => this.startPending(t), p.pending);
|
|
82
|
-
}
|
|
83
|
-
useObserve() {
|
|
84
|
-
return v(
|
|
85
|
-
() => ({
|
|
86
|
-
isPending: this.isPending,
|
|
87
|
-
isFailed: this.isFailed,
|
|
88
|
-
isExecuting: this.isExecuting,
|
|
89
|
-
isSucceeded: this.isSucceeded
|
|
90
|
-
}),
|
|
91
|
-
[this]
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const w = (e, t) => {
|
|
96
|
-
const { action: s } = A("Action", {}), n = O(e), o = b.useNew(t);
|
|
97
|
-
return {
|
|
98
|
-
callAction: (...a) => {
|
|
99
|
-
try {
|
|
100
|
-
o.onStart();
|
|
101
|
-
const c = m(a, [n, s]);
|
|
102
|
-
if (c instanceof Promise)
|
|
103
|
-
return c.then(o.onSucceeded).catch(o.onFailed);
|
|
104
|
-
o.onSucceeded();
|
|
105
|
-
} catch {
|
|
106
|
-
o.onFailed();
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
state: o
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
function g(e) {
|
|
113
|
-
return typeof e == "boolean" ? void 0 : e;
|
|
114
|
-
}
|
|
115
|
-
const u = {
|
|
116
|
-
fn: (e) => ({
|
|
117
|
-
type: "function",
|
|
118
|
-
fn: e
|
|
119
|
-
}),
|
|
120
|
-
openModal: (e) => ({
|
|
121
|
-
type: "openModal",
|
|
122
|
-
controller: g(e)
|
|
123
|
-
}),
|
|
124
|
-
closeModal: (e) => ({
|
|
125
|
-
type: "closeModal",
|
|
126
|
-
controller: g(e)
|
|
127
|
-
}),
|
|
128
|
-
toggleModal: (e) => ({
|
|
129
|
-
type: "toggleModal",
|
|
130
|
-
controller: g(e)
|
|
131
|
-
})
|
|
132
|
-
}, G = (e) => {
|
|
133
|
-
const {
|
|
134
|
-
children: t,
|
|
135
|
-
feedback: s,
|
|
136
|
-
action: n,
|
|
137
|
-
toggleModal: o,
|
|
138
|
-
openModal: f,
|
|
139
|
-
closeModal: a
|
|
140
|
-
} = e, c = n ? u.fn(n) : o ? u.toggleModal(o) : f ? u.openModal(f) : a ? u.closeModal(a) : void 0, h = w(c, { feedback: s }), d = h.state.useObserve(), F = {
|
|
141
|
-
Button: {
|
|
142
|
-
onPress: h.callAction,
|
|
143
|
-
isPending: d.isPending,
|
|
144
|
-
isDisabled: d.isExecuting,
|
|
145
|
-
isSucceeded: d.isSucceeded,
|
|
146
|
-
isFailed: d.isFailed
|
|
147
|
-
},
|
|
148
|
-
Action: {
|
|
149
|
-
action: h.callAction
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
return /* @__PURE__ */ M.createElement(
|
|
153
|
-
x,
|
|
154
|
-
{
|
|
155
|
-
mergeInParentContext: !0,
|
|
156
|
-
props: F,
|
|
157
|
-
dependencies: Object.values(d)
|
|
158
|
-
},
|
|
159
|
-
t
|
|
160
|
-
);
|
|
161
|
-
};
|
|
162
|
-
export {
|
|
163
|
-
G as A
|
|
164
|
-
};
|
package/dist/Button-B2GKVrxY.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
/* */
|
|
3
|
-
import o from "react";
|
|
4
|
-
import * as E from "react-aria-components";
|
|
5
|
-
import x from "clsx";
|
|
6
|
-
import { C } from "./ClearPropsContext-CeCMjUK9.js";
|
|
7
|
-
import { P as I } 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 N, a as h } from "./IconSucceeded-BM7cipIv.js";
|
|
14
|
-
import { W as d } from "./Wrap-DGT1h1o3.js";
|
|
15
|
-
import { T as z } from "./Text-CBzyk1oM.js";
|
|
16
|
-
import { f as L } from "./flowComponent-BuF0s2uG.js";
|
|
17
|
-
import { useLocalizedStringFormatter as B } from "react-aria";
|
|
18
|
-
import { L as A } from "./LoadingSpinner-DqsZ7IDL.js";
|
|
19
|
-
const D = "flow--button", T = "flow--button--avatar", K = "flow--button--icon", U = "flow--button--text", W = "flow--button--content", $ = "flow--button--state-icon", R = "flow--button--is-succeeded", j = "flow--button--is-failed", k = "flow--button--is-pending", q = "flow--button--plain", G = "flow--button--primary", H = "flow--button--solid", J = "flow--button--accent", M = "flow--button--danger", O = "flow--button--secondary", Q = "flow--button--soft", e = {
|
|
20
|
-
button: D,
|
|
21
|
-
avatar: T,
|
|
22
|
-
icon: K,
|
|
23
|
-
text: U,
|
|
24
|
-
content: W,
|
|
25
|
-
stateIcon: $,
|
|
26
|
-
"size-s": "flow--button--size-s",
|
|
27
|
-
isSucceeded: R,
|
|
28
|
-
isFailed: j,
|
|
29
|
-
isPending: k,
|
|
30
|
-
plain: q,
|
|
31
|
-
primary: G,
|
|
32
|
-
solid: H,
|
|
33
|
-
accent: J,
|
|
34
|
-
danger: M,
|
|
35
|
-
secondary: O,
|
|
36
|
-
soft: Q
|
|
37
|
-
}, V = {
|
|
38
|
-
"de-DE": {
|
|
39
|
-
"button.isFailed": "Fehlgeschlagen",
|
|
40
|
-
"button.isPending": "Ausstehend",
|
|
41
|
-
"button.isSucceeded": "Erfolgreich"
|
|
42
|
-
},
|
|
43
|
-
"en-EN": {
|
|
44
|
-
"button.isFailed": "Failed",
|
|
45
|
-
"button.isPending": "Pending",
|
|
46
|
-
"button.isSucceeded": "Succeeded"
|
|
47
|
-
}
|
|
48
|
-
}, X = (t) => ((t.isPending || t.isSucceeded || t.isFailed) && (t = { ...t }, t.onPress = void 0, t.onPressStart = void 0, t.onPressEnd = void 0, t.onPressChange = void 0, t.onPressUp = void 0, t.onKeyDown = void 0, t.onKeyUp = void 0), t), ut = L("Button", (t) => {
|
|
49
|
-
t = X(t);
|
|
50
|
-
const {
|
|
51
|
-
variant: m = "primary",
|
|
52
|
-
style: u = "solid",
|
|
53
|
-
children: c,
|
|
54
|
-
className: f,
|
|
55
|
-
size: i = "m",
|
|
56
|
-
isPending: a,
|
|
57
|
-
isDisabled: b,
|
|
58
|
-
isSucceeded: n,
|
|
59
|
-
isFailed: s,
|
|
60
|
-
"aria-label": g,
|
|
61
|
-
ref: P,
|
|
62
|
-
...w
|
|
63
|
-
} = t, v = x(
|
|
64
|
-
e.button,
|
|
65
|
-
a && e.isPending,
|
|
66
|
-
n && e.isSucceeded,
|
|
67
|
-
s && e.isFailed,
|
|
68
|
-
e[`size-${i}`],
|
|
69
|
-
e[m],
|
|
70
|
-
e[u],
|
|
71
|
-
f
|
|
72
|
-
), S = {
|
|
73
|
-
Icon: {
|
|
74
|
-
className: e.icon,
|
|
75
|
-
"aria-hidden": !0,
|
|
76
|
-
size: i
|
|
77
|
-
},
|
|
78
|
-
Text: {
|
|
79
|
-
className: e.text
|
|
80
|
-
},
|
|
81
|
-
Avatar: {
|
|
82
|
-
className: e.avatar
|
|
83
|
-
}
|
|
84
|
-
}, p = B(V), F = n || s || a ? p.format(
|
|
85
|
-
`button.${n ? "isSucceeded" : s ? "isFailed" : "isPending"}`
|
|
86
|
-
) : void 0, r = n ? N : s ? h : a ? A : void 0, l = r && /* @__PURE__ */ o.createElement(r, { size: i, className: e.stateIcon }), y = typeof c == "string";
|
|
87
|
-
return /* @__PURE__ */ o.createElement(C, null, /* @__PURE__ */ o.createElement(
|
|
88
|
-
E.Button,
|
|
89
|
-
{
|
|
90
|
-
className: v,
|
|
91
|
-
isDisabled: b,
|
|
92
|
-
"aria-label": F ?? g,
|
|
93
|
-
ref: P,
|
|
94
|
-
...w
|
|
95
|
-
},
|
|
96
|
-
/* @__PURE__ */ o.createElement(I, { props: S }, /* @__PURE__ */ o.createElement(d, { if: l }, /* @__PURE__ */ o.createElement("span", { className: e.content }, /* @__PURE__ */ o.createElement(d, { if: y }, /* @__PURE__ */ o.createElement(z, null, c))))),
|
|
97
|
-
l
|
|
98
|
-
));
|
|
99
|
-
});
|
|
100
|
-
export {
|
|
101
|
-
ut as B
|
|
102
|
-
};
|