@jonmilner/ui 0.5.4 → 0.5.5

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.
@@ -11,10 +11,10 @@ import { CircleCheckIcon as c } from "../icons/CircleCheckIcon.mjs";
11
11
  import { InfoIcon as l } from "../icons/InfoIcon.mjs";
12
12
  import { announcer as u, close as d, content as f, list as p, root as m, toast as h, viewport as g } from "./Toast.css.mjs";
13
13
  import { jsx as _, jsxs as v } from "react/jsx-runtime";
14
- import { createContext as y, use as b, useCallback as x, useLayoutEffect as S, useMemo as C, useRef as w, useState as T } from "react";
15
- import { Toast as E } from "@base-ui/react/toast";
14
+ import { createContext as y, use as b, useCallback as x, useEffect as S, useLayoutEffect as C, useMemo as w, useRef as T, useState as E } from "react";
15
+ import { Toast as D } from "@base-ui/react/toast";
16
16
  //#region src/Toast/client.tsx
17
- var D = {
17
+ var O = {
18
18
  info: {
19
19
  Icon: l,
20
20
  color: "fgMuted"
@@ -27,13 +27,13 @@ var D = {
27
27
  Icon: o,
28
28
  color: "danger"
29
29
  }
30
- }, O = y(null), k = y(null), A = (e) => e !== void 0 && Object.hasOwn(D, e);
31
- function j({ limit: e = 3, closeLabel: n = "Dismiss", regionLabel: r = "Notifications", className: i, style: o, children: s }) {
32
- let { container: c, ref: l } = a(), [u] = T(E.createToastManager);
33
- return /* @__PURE__ */ _(E.Provider, {
30
+ }, k = y(null), A = y(null), j = (e) => e !== void 0 && Object.hasOwn(O, e);
31
+ function M({ limit: e = 3, closeLabel: n = "Dismiss", regionLabel: r = "Notifications", className: i, style: o, children: s }) {
32
+ let { container: c, ref: l } = a(), [u] = E(D.createToastManager);
33
+ return /* @__PURE__ */ _(D.Provider, {
34
34
  limit: e,
35
35
  toastManager: u,
36
- children: /* @__PURE__ */ v(O, {
36
+ children: /* @__PURE__ */ v(k, {
37
37
  value: u,
38
38
  children: [
39
39
  /* @__PURE__ */ _(t, {
@@ -42,23 +42,38 @@ function j({ limit: e = 3, closeLabel: n = "Dismiss", regionLabel: r = "Notifica
42
42
  ref: l
43
43
  }),
44
44
  s,
45
- /* @__PURE__ */ _(N, {}),
46
- /* @__PURE__ */ _(E.Portal, {
45
+ /* @__PURE__ */ _(P, {}),
46
+ /* @__PURE__ */ _(D.Portal, {
47
47
  container: c,
48
- children: /* @__PURE__ */ _(M, {
48
+ children: /* @__PURE__ */ _(N, {
49
49
  className: i,
50
50
  regionLabel: r,
51
51
  style: o,
52
- children: /* @__PURE__ */ _(P, { closeLabel: n })
52
+ children: /* @__PURE__ */ _(F, { closeLabel: n })
53
53
  })
54
54
  })
55
55
  ]
56
56
  })
57
57
  });
58
58
  }
59
- function M({ regionLabel: n, className: r, style: i, children: a }) {
60
- let o = w(null);
61
- return /* @__PURE__ */ _(E.Viewport, {
59
+ function N({ regionLabel: n, className: r, style: i, children: a }) {
60
+ let o = T(null), s = T(null);
61
+ return S(() => {
62
+ let e = s.current;
63
+ if (!e) return;
64
+ let t = e.ownerDocument, n = !1, r = (t) => {
65
+ e.contains(t.target) ? n = !0 : n && (n = !1, e.dispatchEvent(new MouseEvent("mouseout", {
66
+ bubbles: !0,
67
+ relatedTarget: e.parentElement
68
+ })));
69
+ }, i = (t) => {
70
+ let r = t.relatedTarget;
71
+ (!r || !e.contains(r)) && (n = !1);
72
+ };
73
+ return t.addEventListener("mouseover", r), t.addEventListener("mouseout", i), () => {
74
+ t.removeEventListener("mouseover", r), t.removeEventListener("mouseout", i);
75
+ };
76
+ }, []), /* @__PURE__ */ _(D.Viewport, {
62
77
  "aria-atomic": void 0,
63
78
  "aria-label": n,
64
79
  "aria-live": "off",
@@ -67,6 +82,7 @@ function M({ regionLabel: n, className: r, style: i, children: a }) {
67
82
  let t = e.relatedTarget;
68
83
  t && !e.currentTarget.contains(t) && (o.current = t);
69
84
  },
85
+ ref: s,
70
86
  render: /* @__PURE__ */ _(t, {
71
87
  className: e(g, r),
72
88
  position: "fixed",
@@ -75,15 +91,15 @@ function M({ regionLabel: n, className: r, style: i, children: a }) {
75
91
  }),
76
92
  children: /* @__PURE__ */ _("div", {
77
93
  className: p,
78
- children: /* @__PURE__ */ _(k, {
94
+ children: /* @__PURE__ */ _(A, {
79
95
  value: o,
80
96
  children: a
81
97
  })
82
98
  })
83
99
  });
84
100
  }
85
- function N() {
86
- let { toasts: e } = E.useToastManager(), t = (t) => e.filter((e) => e.type === "error" === t).map((e) => /* @__PURE__ */ v("div", { children: [
101
+ function P() {
102
+ let { toasts: e } = D.useToastManager(), t = (t) => e.filter((e) => e.type === "error" === t).map((e) => /* @__PURE__ */ v("div", { children: [
87
103
  e.title,
88
104
  " ",
89
105
  e.description
@@ -103,18 +119,18 @@ function N() {
103
119
  })]
104
120
  });
105
121
  }
106
- function P({ closeLabel: e }) {
107
- let { toasts: t } = E.useToastManager();
108
- return t.map((t) => /* @__PURE__ */ _(F, {
122
+ function F({ closeLabel: e }) {
123
+ let { toasts: t } = D.useToastManager();
124
+ return t.map((t) => /* @__PURE__ */ _(I, {
109
125
  closeLabel: e,
110
126
  toast: t
111
127
  }, t.id));
112
128
  }
113
- function F({ toast: a, closeLabel: o }) {
114
- let c = A(a.type) ? a.type : "info", { Icon: l, color: u } = D[c], p = b(O), g = b(k), [y, C] = T(!1), j = x((e) => {
115
- e && C(getComputedStyle(e).direction === "rtl");
116
- }, []), M = w(!1), N = a.transitionStatus === "ending";
117
- return S(() => {
129
+ function I({ toast: a, closeLabel: o }) {
130
+ let c = j(a.type) ? a.type : "info", { Icon: l, color: u } = O[c], p = b(k), g = b(A), [y, S] = E(!1), w = x((e) => {
131
+ e && S(getComputedStyle(e).direction === "rtl");
132
+ }, []), M = T(!1), N = a.transitionStatus === "ending";
133
+ return C(() => {
118
134
  let e = a.ref?.current, t = e?.ownerDocument.activeElement;
119
135
  if (!N || M.current || !t || !e.contains(t)) return;
120
136
  let n = g?.current;
@@ -123,9 +139,9 @@ function F({ toast: a, closeLabel: o }) {
123
139
  N,
124
140
  g,
125
141
  a.ref
126
- ]), /* @__PURE__ */ v(E.Root, {
142
+ ]), /* @__PURE__ */ v(D.Root, {
127
143
  "aria-modal": void 0,
128
- ref: j,
144
+ ref: w,
129
145
  render: /* @__PURE__ */ _(t, {
130
146
  alignItems: "start",
131
147
  backgroundColor: "bgRaised",
@@ -154,27 +170,27 @@ function F({ toast: a, closeLabel: o }) {
154
170
  flexGrow: 1,
155
171
  gap: "8",
156
172
  children: [
157
- /* @__PURE__ */ _(E.Title, { render: /* @__PURE__ */ _(r, {
173
+ /* @__PURE__ */ _(D.Title, { render: /* @__PURE__ */ _(r, {
158
174
  as: "div",
159
175
  weight: "medium"
160
176
  }) }),
161
- /* @__PURE__ */ _(E.Description, { render: /* @__PURE__ */ _(r, {
177
+ /* @__PURE__ */ _(D.Description, { render: /* @__PURE__ */ _(r, {
162
178
  as: "div",
163
179
  color: "fgMuted",
164
180
  size: "sm"
165
181
  }) }),
166
- /* @__PURE__ */ _(E.Action, { render: /* @__PURE__ */ _(i, {
182
+ /* @__PURE__ */ _(D.Action, { render: /* @__PURE__ */ _(i, {
167
183
  size: "sm",
168
184
  variant: "secondary"
169
185
  }) })
170
186
  ]
171
187
  }),
172
- /* @__PURE__ */ _(E.Close, {
188
+ /* @__PURE__ */ _(D.Close, {
173
189
  "aria-hidden": !1,
174
190
  "aria-label": o,
175
191
  onClick: (e) => {
176
192
  if (e.detail !== 0 || !p) return;
177
- let t = a.ref?.current, n = (t && I(t)) ?? g?.current;
193
+ let t = a.ref?.current, n = (t && L(t)) ?? g?.current;
178
194
  n instanceof HTMLElement && (e.preventBaseUIHandler(), M.current = !0, p.close(a.id), requestAnimationFrame(() => {
179
195
  n.isConnected && n.focus();
180
196
  }));
@@ -190,14 +206,14 @@ function F({ toast: a, closeLabel: o }) {
190
206
  ]
191
207
  });
192
208
  }
193
- function I(e) {
209
+ function L(e) {
194
210
  let t = (e, n) => !e || !e.matches("[data-ending-style]") ? e : t(n ? e.nextElementSibling : e.previousElementSibling, n);
195
211
  return (t(e.nextElementSibling, !0) ?? t(e.previousElementSibling, !1))?.querySelector(`.${d}`);
196
212
  }
197
- function L() {
198
- let e = b(O);
213
+ function R() {
214
+ let e = b(k);
199
215
  if (!e) throw Error("useToast must be called under Toast.Provider.");
200
- return C(() => {
216
+ return w(() => {
201
217
  let t = (t) => e.close(t);
202
218
  return {
203
219
  add: ({ title: n, description: r, variant: i = "info", duration: a = i === "error" ? 0 : 5e3, action: o }) => {
@@ -225,4 +241,4 @@ function L() {
225
241
  }, [e]);
226
242
  }
227
243
  //#endregion
228
- export { N as ToastAnnouncer, F as ToastItem, j as ToastProvider, M as ToastStack, L as useToast };
244
+ export { P as ToastAnnouncer, I as ToastItem, M as ToastProvider, N as ToastStack, R as useToast };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "./manifest.schema.json",
3
3
  "package": "@jonmilner/ui",
4
- "version": "0.5.4",
4
+ "version": "0.5.5",
5
5
  "components": [
6
6
  {
7
7
  "name": "AlertDialog",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jonmilner/ui",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "files": [
5
5
  "dist",
6
6
  "THIRD_PARTY_NOTICES.md"