@mittwald/flow-react-components 0.1.0-alpha.135 → 0.1.0-alpha.136

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.
@@ -7,8 +7,8 @@ import { P as L } from "./PropsContextProvider-C6Z4XGp6.js";
7
7
  import "@react-aria/utils";
8
8
  import "./propsContext-DzAKlmhS.js";
9
9
  import "remeda";
10
- import g from "clsx";
11
- import { f as h } from "./flowComponent-CPKCCJEg.js";
10
+ import h from "clsx";
11
+ import { f as g } from "./flowComponent-CPKCCJEg.js";
12
12
  import { l as y } from "./context-BlNV7smK.js";
13
13
  const N = "flow--link", E = "flow--link--inline", F = "flow--link--icon", v = "flow--link--dark", z = "flow--link--light", n = {
14
14
  link: N,
@@ -16,34 +16,34 @@ const N = "flow--link", E = "flow--link--inline", F = "flow--link--icon", v = "f
16
16
  icon: F,
17
17
  dark: v,
18
18
  light: z
19
- }, G = h("Link", (r) => {
19
+ }, G = g("Link", (t) => {
20
20
  const {
21
- children: i,
22
- className: t,
23
- inline: e,
24
- linkComponent: l,
25
- color: s = "primary",
26
- unstyled: m = !1,
27
- "aria-current": a,
28
- refProp: c,
29
- ...p
30
- } = r, { linkComponent: k } = d(y), f = l ?? k ?? P.Link, C = m ? t : g(n.link, e && n.inline, n[s], t), u = {
21
+ children: l,
22
+ className: r,
23
+ inline: s,
24
+ linkComponent: i,
25
+ color: m = "primary",
26
+ unstyled: a = !1,
27
+ "aria-current": c,
28
+ refProp: p,
29
+ ...k
30
+ } = t, { linkComponent: e } = d(y), f = i || (t.href && e ? e : P.Link), C = a ? r : h(n.link, s && n.inline, n[m], r), u = {
31
31
  Icon: {
32
32
  className: n.icon,
33
33
  size: "s"
34
34
  }
35
35
  }, x = {
36
- "aria-current": a
36
+ "aria-current": c
37
37
  };
38
38
  return /* @__PURE__ */ o.createElement(w, null, /* @__PURE__ */ o.createElement(
39
39
  f,
40
40
  {
41
- ...p,
41
+ ...k,
42
42
  ...x,
43
43
  className: C,
44
- ref: c
44
+ ref: p
45
45
  },
46
- /* @__PURE__ */ o.createElement(L, { props: u }, i)
46
+ /* @__PURE__ */ o.createElement(L, { props: u }, l)
47
47
  ));
48
48
  });
49
49
  export {
package/dist/Link.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
  /* */
3
- import { L as o } from "./Link-TcBL3IVI.js";
3
+ import { L as o } from "./Link-CcYCy_KC.js";
4
4
  export {
5
5
  o as Link,
6
6
  o as default
package/dist/List.js CHANGED
@@ -35,7 +35,7 @@ import { P as Tt } from "./PropsContextProvider-C6Z4XGp6.js";
35
35
  import { d as Lt } from "./dynamic-ClpUSmEt.js";
36
36
  import { I as wt } from "./IconContextMenu-Bmk1_j_0.js";
37
37
  import { TunnelProvider as Bt, TunnelExit as z } from "@mittwald/react-tunnel";
38
- import { L as At } from "./Link-TcBL3IVI.js";
38
+ import { L as At } from "./Link-CcYCy_KC.js";
39
39
  import { d as E, a as O } from "./deepFindOfType-6pG0fH7S.js";
40
40
  import { ListLoaderAsyncResource as kt } from "./List/ListLoaderAsyncResource.js";
41
41
  import { I as Dt } from "./InlineCode-BT-PKxVv.js";
@@ -0,0 +1,67 @@
1
+ "use client"
2
+ /* */
3
+ import t from "react";
4
+ import d from "clsx";
5
+ import "./propsContext-DzAKlmhS.js";
6
+ import { P as w } from "./PropsContextProvider-C6Z4XGp6.js";
7
+ import "@react-aria/utils";
8
+ import "remeda";
9
+ import { S as g } from "./StatusIcon-Dj5p-iL1.js";
10
+ import { L as h } from "./Link-CcYCy_KC.js";
11
+ import { B as k } from "./Button-BPAhEOTg.js";
12
+ import "@tabler/icons-react";
13
+ import "./Icon-D4bkU_pz.js";
14
+ import { I as x } from "./IconClose-FTrJdf_N.js";
15
+ const N = "flow--notification", C = "flow--notification--link", E = "flow--notification--status-icon", I = "flow--notification--heading", L = "flow--notification--text", P = "flow--notification--close", v = "flow--notification--info", y = "flow--notification--has-link", B = "flow--notification--warning", S = "flow--notification--danger", z = "flow--notification--success", o = {
16
+ notification: N,
17
+ link: C,
18
+ statusIcon: E,
19
+ heading: I,
20
+ text: L,
21
+ close: P,
22
+ info: v,
23
+ hasLink: y,
24
+ warning: B,
25
+ danger: S,
26
+ success: z
27
+ }, O = (a) => {
28
+ const {
29
+ children: c,
30
+ className: l,
31
+ status: i = "info",
32
+ role: r = "alert",
33
+ href: s,
34
+ onClick: e,
35
+ onClose: n,
36
+ autoClose: A,
37
+ ...f
38
+ } = a, m = d(
39
+ o.notification,
40
+ o[i],
41
+ (e || n || s) && o.hasLink,
42
+ l
43
+ ), p = {
44
+ Heading: {
45
+ className: o.heading,
46
+ level: 4
47
+ },
48
+ Text: {
49
+ className: o.text
50
+ }
51
+ }, u = n && /* @__PURE__ */ t.createElement(
52
+ k,
53
+ {
54
+ size: "s",
55
+ className: o.close,
56
+ variant: "plain",
57
+ color: "secondary",
58
+ onPress: n
59
+ },
60
+ /* @__PURE__ */ t.createElement(x, null)
61
+ );
62
+ return /* @__PURE__ */ t.createElement("div", { ...f, className: m, role: r }, /* @__PURE__ */ t.createElement(h, { unstyled: !0, href: s, className: o.link, onPress: e }, /* @__PURE__ */ t.createElement(g, { className: o.statusIcon, status: i }), /* @__PURE__ */ t.createElement(w, { props: p }, c)), u);
63
+ };
64
+ export {
65
+ O as Notification,
66
+ O as default
67
+ };
@@ -0,0 +1,140 @@
1
+ "use client"
2
+ /* */
3
+ var w = Object.defineProperty;
4
+ var A = (i, t, e) => t in i ? w(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
5
+ var o = (i, t, e) => (A(i, typeof t != "symbol" ? t + "" : t, e), e);
6
+ import s, { useRef as v, cloneElement as D, createContext as C, useContext as N } from "react";
7
+ import { u as E } from "./useSelector-DpU7_HMO.js";
8
+ import { makeObservable as g, observable as x, action as c } from "mobx";
9
+ import { Duration as u, DateTime as m } from "luxon";
10
+ import y from "react-dom";
11
+ import b from "clsx";
12
+ import { LazyMotion as I, domAnimation as M, AnimatePresence as P, m as k } from "framer-motion";
13
+ import { useIsSSR as L } from "react-aria";
14
+ class R {
15
+ constructor() {
16
+ o(this, "duration", u.fromDurationLike(0));
17
+ o(this, "onDone");
18
+ o(this, "startedAt");
19
+ o(this, "pausedAt");
20
+ o(this, "runningTimeoutId");
21
+ }
22
+ start(t, e) {
23
+ if (this.startedAt)
24
+ throw new Error("Timer already started");
25
+ this.duration = u.fromDurationLike(t), this.onDone = e, this.startTimeout(this.duration);
26
+ }
27
+ restart() {
28
+ this.stop(), this.startTimeout(this.duration);
29
+ }
30
+ pause() {
31
+ this.clearTimeout();
32
+ const t = m.now();
33
+ this.pausedAt = t, this.startedAt || (this.startedAt = t);
34
+ }
35
+ resume() {
36
+ if (this.startedAt) {
37
+ if (this.pausedAt) {
38
+ const t = this.pausedAt.diff(this.startedAt), e = this.duration.minus(t);
39
+ this.startTimeout(e);
40
+ }
41
+ } else
42
+ throw new Error("Timer not paused");
43
+ }
44
+ stop() {
45
+ this.clearTimeout(), this.startedAt = void 0, this.pausedAt = void 0;
46
+ }
47
+ get state() {
48
+ return this.pausedAt ? "paused" : this.startedAt ? "running" : "idle";
49
+ }
50
+ clearTimeout() {
51
+ this.runningTimeoutId && window.clearTimeout(this.runningTimeoutId), this.runningTimeoutId = void 0;
52
+ }
53
+ startTimeout(t) {
54
+ this.startedAt = m.now(), this.pausedAt = void 0, this.runningTimeoutId = window.setTimeout(() => {
55
+ this.stop(), this.onDone && this.onDone();
56
+ }, t.toMillis());
57
+ }
58
+ }
59
+ class a {
60
+ constructor() {
61
+ o(this, "notificationsData", /* @__PURE__ */ new Map());
62
+ o(this, "id", 0);
63
+ g(this, {
64
+ notificationsData: x.shallow,
65
+ add: c.bound,
66
+ remove: c.bound
67
+ });
68
+ }
69
+ static useNew() {
70
+ return v(new a()).current;
71
+ }
72
+ useNotifications() {
73
+ return E(() => Array.from(this.notificationsData.values()));
74
+ }
75
+ add(t) {
76
+ const e = this.id++, n = {
77
+ id: e,
78
+ createdAt: Date.now(),
79
+ autoCloseTimer: new R()
80
+ };
81
+ this.notificationsData.set(e, {
82
+ element: t,
83
+ meta: n
84
+ }), t.props.autoClose && n.autoCloseTimer.start({ seconds: 10 }, () => {
85
+ this.remove(e);
86
+ });
87
+ }
88
+ remove(t) {
89
+ this.notificationsData.delete(t);
90
+ }
91
+ }
92
+ const S = "flow--notification-provider--notification-container", O = "flow--notification-provider--notification", d = {
93
+ notificationContainer: S,
94
+ notification: O
95
+ }, z = (i) => {
96
+ const { notification: t, controller: e } = i;
97
+ return D(t.element, {
98
+ onMouseEnter: () => {
99
+ t.meta.autoCloseTimer.pause();
100
+ },
101
+ onMouseLeave: () => {
102
+ t.meta.autoCloseTimer.resume();
103
+ },
104
+ onClose: () => {
105
+ e.remove(t.meta.id);
106
+ }
107
+ });
108
+ }, B = (i) => {
109
+ const { className: t, controller: e, ...n } = i, f = b(d.notificationContainer, t), h = e.useNotifications(), p = L(), T = /* @__PURE__ */ s.createElement(I, { features: M }, /* @__PURE__ */ s.createElement("div", { className: f, ...n }, /* @__PURE__ */ s.createElement(P, null, h.map((r) => /* @__PURE__ */ s.createElement(
110
+ k.div,
111
+ {
112
+ className: d.notification,
113
+ key: r.meta.id,
114
+ initial: { opacity: 0, x: 200 },
115
+ animate: { opacity: 1, x: 0 },
116
+ exit: { opacity: 0, x: 200, height: 0, paddingBottom: 0 },
117
+ transition: {
118
+ bounce: 0
119
+ }
120
+ },
121
+ /* @__PURE__ */ s.createElement(
122
+ z,
123
+ {
124
+ notification: r,
125
+ controller: e
126
+ }
127
+ )
128
+ )))));
129
+ return p ? null : y.createPortal(T, document.body);
130
+ }, l = C(
131
+ new a()
132
+ ), V = () => N(l), W = (i) => {
133
+ const { children: t, ...e } = i, n = a.useNew();
134
+ return /* @__PURE__ */ s.createElement(l.Provider, { value: n }, /* @__PURE__ */ s.createElement(B, { controller: n, ...e }), t);
135
+ };
136
+ export {
137
+ W as NotificationProvider,
138
+ W as default,
139
+ V as useNotificationController
140
+ };
package/dist/nextjs.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use client"
2
2
  /* */
3
- import n, { forwardRef as o } from "react";
4
- import i from "next/link";
5
- import { L as m } from "./context-BlNV7smK.js";
6
- const f = o(function(r, t) {
7
- return /* @__PURE__ */ n.createElement(i, { href: r.href ?? "#", ...r, ref: t });
8
- }), L = (e) => /* @__PURE__ */ n.createElement(m, { value: { linkComponent: f } }, e.children);
3
+ import r, { forwardRef as m } from "react";
4
+ import c from "next/link";
5
+ import { L as f } from "./context-BlNV7smK.js";
6
+ const a = m(function(t, n) {
7
+ const { href: o, ...i } = t;
8
+ return /* @__PURE__ */ r.createElement(c, { href: o ?? "#", ...i, ref: n });
9
+ }), p = (e) => /* @__PURE__ */ r.createElement(f, { value: { linkComponent: a } }, e.children);
9
10
  export {
10
- f as Link,
11
- L as LinkProvider
11
+ a as Link,
12
+ p as LinkProvider
12
13
  };