@mittwald/flow-react-components 0.1.0-alpha.339 → 0.1.0-alpha.340
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/CHANGELOG.md +13 -0
- package/dist/js/NotificationProvider.js +31 -30
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.1.0-alpha.340](https://github.com/mittwald/flow/compare/0.1.0-alpha.339...0.1.0-alpha.340) (2024-11-11)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **Notification:** Also call onClose handler from notification component props
|
|
11
|
+
if notification comes from an NotificationProvider
|
|
12
|
+
([29bc5f0](https://github.com/mittwald/flow/commit/29bc5f01f151a7889912e24e889ecb2efe3c210a))
|
|
13
|
+
|
|
14
|
+
# Change Log
|
|
15
|
+
|
|
16
|
+
All notable changes to this project will be documented in this file. See
|
|
17
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
18
|
+
|
|
6
19
|
# [0.1.0-alpha.339](https://github.com/mittwald/flow/compare/0.1.0-alpha.338...0.1.0-alpha.339) (2024-11-11)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package @mittwald/flow-react-components
|
|
@@ -2,34 +2,34 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
var w = Object.defineProperty;
|
|
4
4
|
var A = (o, t, e) => t in o ? w(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
5
|
-
var
|
|
5
|
+
var n = (o, t, e) => A(o, typeof t != "symbol" ? t + "" : t, e);
|
|
6
6
|
import s, { useRef as v, cloneElement as C, createContext as D, useContext as N } from "react";
|
|
7
7
|
import { u as E } from "./useSelector-DpU7_HMO.js";
|
|
8
|
-
import { makeObservable as g, observable as x, action as
|
|
9
|
-
import { Duration as
|
|
8
|
+
import { makeObservable as g, observable as x, action as u } from "mobx";
|
|
9
|
+
import { Duration as m, DateTime as l } from "luxon";
|
|
10
10
|
import y from "react-dom";
|
|
11
11
|
import b from "clsx";
|
|
12
12
|
import { LazyMotion as I, domAnimation as M, AnimatePresence as P, m as k } from "framer-motion";
|
|
13
13
|
import { useIsSSR as L } from "react-aria";
|
|
14
14
|
class R {
|
|
15
15
|
constructor() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
n(this, "duration", m.fromDurationLike(0));
|
|
17
|
+
n(this, "onDone");
|
|
18
|
+
n(this, "startedAt");
|
|
19
|
+
n(this, "pausedAt");
|
|
20
|
+
n(this, "runningTimeoutId");
|
|
21
21
|
}
|
|
22
22
|
start(t, e) {
|
|
23
23
|
if (this.startedAt)
|
|
24
24
|
throw new Error("Timer already started");
|
|
25
|
-
this.duration =
|
|
25
|
+
this.duration = m.fromDurationLike(t), this.onDone = e, this.startTimeout(this.duration);
|
|
26
26
|
}
|
|
27
27
|
restart() {
|
|
28
28
|
this.stop(), this.startTimeout(this.duration);
|
|
29
29
|
}
|
|
30
30
|
pause() {
|
|
31
31
|
this.clearTimeout();
|
|
32
|
-
const t =
|
|
32
|
+
const t = l.now();
|
|
33
33
|
this.pausedAt = t, this.startedAt || (this.startedAt = t);
|
|
34
34
|
}
|
|
35
35
|
resume() {
|
|
@@ -50,37 +50,37 @@ class R {
|
|
|
50
50
|
this.runningTimeoutId && window.clearTimeout(this.runningTimeoutId), this.runningTimeoutId = void 0;
|
|
51
51
|
}
|
|
52
52
|
startTimeout(t) {
|
|
53
|
-
this.startedAt =
|
|
53
|
+
this.startedAt = l.now(), this.pausedAt = void 0, this.runningTimeoutId = window.setTimeout(() => {
|
|
54
54
|
this.stop(), this.onDone && this.onDone();
|
|
55
55
|
}, t.toMillis());
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
class
|
|
58
|
+
class r {
|
|
59
59
|
constructor() {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
n(this, "notificationsData", /* @__PURE__ */ new Map());
|
|
61
|
+
n(this, "id", 0);
|
|
62
62
|
g(this, {
|
|
63
63
|
notificationsData: x.shallow,
|
|
64
|
-
add:
|
|
65
|
-
remove:
|
|
64
|
+
add: u.bound,
|
|
65
|
+
remove: u.bound
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
static useNew() {
|
|
69
|
-
return v(new
|
|
69
|
+
return v(new r()).current;
|
|
70
70
|
}
|
|
71
71
|
useNotifications() {
|
|
72
72
|
return E(() => Array.from(this.notificationsData.values()));
|
|
73
73
|
}
|
|
74
74
|
add(t) {
|
|
75
|
-
const e = this.id++,
|
|
75
|
+
const e = this.id++, i = {
|
|
76
76
|
id: e,
|
|
77
77
|
createdAt: Date.now(),
|
|
78
78
|
autoCloseTimer: new R()
|
|
79
79
|
};
|
|
80
80
|
this.notificationsData.set(e, {
|
|
81
81
|
element: t,
|
|
82
|
-
meta:
|
|
83
|
-
}), t.props.autoClose &&
|
|
82
|
+
meta: i
|
|
83
|
+
}), t.props.autoClose && i.autoCloseTimer.start({ seconds: 10 }, () => {
|
|
84
84
|
this.remove(e);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -101,7 +101,8 @@ const S = "flow--notification-provider--notification-container", B = "flow--noti
|
|
|
101
101
|
t.meta.autoCloseTimer.resume();
|
|
102
102
|
},
|
|
103
103
|
onClose: () => {
|
|
104
|
-
|
|
104
|
+
var i, a;
|
|
105
|
+
e.remove(t.meta.id), (a = (i = t.element.props).onClose) == null || a.call(i);
|
|
105
106
|
},
|
|
106
107
|
onFocus: () => {
|
|
107
108
|
t.meta.autoCloseTimer.pause();
|
|
@@ -111,11 +112,11 @@ const S = "flow--notification-provider--notification-container", B = "flow--noti
|
|
|
111
112
|
}
|
|
112
113
|
});
|
|
113
114
|
}, z = (o) => {
|
|
114
|
-
const { className: t, ...e } = o,
|
|
115
|
+
const { className: t, ...e } = o, i = F(), a = i.useNotifications(), h = L(), p = b(d.notificationContainer, t), T = /* @__PURE__ */ s.createElement(I, { features: M }, /* @__PURE__ */ s.createElement("div", { className: p, ...e }, /* @__PURE__ */ s.createElement(P, null, a.map((c) => /* @__PURE__ */ s.createElement(
|
|
115
116
|
k.div,
|
|
116
117
|
{
|
|
117
118
|
className: d.notification,
|
|
118
|
-
key:
|
|
119
|
+
key: c.meta.id,
|
|
119
120
|
initial: { opacity: 0, x: 200 },
|
|
120
121
|
animate: { opacity: 1, x: 0 },
|
|
121
122
|
exit: { opacity: 0, x: 200, height: 0, paddingBottom: 0 },
|
|
@@ -126,17 +127,17 @@ const S = "flow--notification-provider--notification-container", B = "flow--noti
|
|
|
126
127
|
/* @__PURE__ */ s.createElement(
|
|
127
128
|
O,
|
|
128
129
|
{
|
|
129
|
-
notification:
|
|
130
|
-
controller:
|
|
130
|
+
notification: c,
|
|
131
|
+
controller: i
|
|
131
132
|
}
|
|
132
133
|
)
|
|
133
134
|
)))));
|
|
134
135
|
return h ? null : y.createPortal(T, document.body);
|
|
135
|
-
},
|
|
136
|
-
new
|
|
137
|
-
), F = () => N(
|
|
138
|
-
const { children: t, ...e } = o,
|
|
139
|
-
return /* @__PURE__ */ s.createElement(
|
|
136
|
+
}, f = D(
|
|
137
|
+
new r()
|
|
138
|
+
), F = () => N(f), W = (o) => {
|
|
139
|
+
const { children: t, ...e } = o, i = r.useNew();
|
|
140
|
+
return /* @__PURE__ */ s.createElement(f.Provider, { value: i }, /* @__PURE__ */ s.createElement(z, { ...e }), t);
|
|
140
141
|
};
|
|
141
142
|
export {
|
|
142
143
|
W as NotificationProvider,
|
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.340",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
"@chakra-ui/live-region": "^2.1.0",
|
|
406
406
|
"@internationalized/date": "^3.5.6",
|
|
407
407
|
"@internationalized/string-compiler": "^3.2.5",
|
|
408
|
-
"@mittwald/react-tunnel": "^0.1.0-alpha.
|
|
408
|
+
"@mittwald/react-tunnel": "^0.1.0-alpha.340",
|
|
409
409
|
"@mittwald/react-use-promise": "^2.5.0",
|
|
410
410
|
"@react-aria/form": "^3.0.10",
|
|
411
411
|
"@react-aria/utils": "^3.25.3",
|
|
@@ -435,7 +435,7 @@
|
|
|
435
435
|
},
|
|
436
436
|
"devDependencies": {
|
|
437
437
|
"@faker-js/faker": "^9.0.3",
|
|
438
|
-
"@mittwald/flow-design-tokens": "^0.1.0-alpha.
|
|
438
|
+
"@mittwald/flow-design-tokens": "^0.1.0-alpha.340",
|
|
439
439
|
"@mittwald/react-use-promise": "^2.5.0",
|
|
440
440
|
"@nx/storybook": "^20.0.0",
|
|
441
441
|
"@storybook/addon-a11y": "^8.3.5",
|
|
@@ -530,5 +530,5 @@
|
|
|
530
530
|
}
|
|
531
531
|
}
|
|
532
532
|
},
|
|
533
|
-
"gitHead": "
|
|
533
|
+
"gitHead": "d0bfb757872d63bc641954e7321c54c41aa4655e"
|
|
534
534
|
}
|