@rinzai/zen 0.6.0 → 0.7.0

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.
Files changed (173) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +12 -4
  3. package/dist/alert/index.d.ts +21 -0
  4. package/dist/alert/index.d.ts.map +1 -0
  5. package/dist/alert/index.js +49 -0
  6. package/dist/button/index.d.ts +2 -1
  7. package/dist/button/index.d.ts.map +1 -1
  8. package/dist/button/index.js +43 -12
  9. package/dist/calendar/index.d.ts.map +1 -1
  10. package/dist/calendar/index.js +86 -85
  11. package/dist/chart/donut.d.ts +4 -1
  12. package/dist/chart/donut.d.ts.map +1 -1
  13. package/dist/chart/donut.js +81 -60
  14. package/dist/chart/index.d.ts +8 -2
  15. package/dist/chart/index.d.ts.map +1 -1
  16. package/dist/chart/index.js +151 -139
  17. package/dist/chart/palette.d.ts +11 -0
  18. package/dist/chart/palette.d.ts.map +1 -0
  19. package/dist/chart/palette.js +9 -0
  20. package/dist/chart/tooltip.d.ts +6 -2
  21. package/dist/chart/tooltip.d.ts.map +1 -1
  22. package/dist/chart/tooltip.js +6 -6
  23. package/dist/checkbox/index.d.ts.map +1 -1
  24. package/dist/checkbox/index.js +28 -44
  25. package/dist/chip/index.js +1 -1
  26. package/dist/code-block/index.js +1 -1
  27. package/dist/combobox/index.d.ts.map +1 -1
  28. package/dist/combobox/index.js +93 -91
  29. package/dist/date-picker/index.d.ts.map +1 -1
  30. package/dist/date-picker/index.js +24 -38
  31. package/dist/disclosure/index.js +1 -1
  32. package/dist/editable-cell/index.js +1 -1
  33. package/dist/field/index.d.ts +1 -1
  34. package/dist/field/index.d.ts.map +1 -1
  35. package/dist/field/index.js +33 -32
  36. package/dist/header/index.d.ts +9 -1
  37. package/dist/header/index.d.ts.map +1 -1
  38. package/dist/header/index.js +17 -9
  39. package/dist/icons/arrow-left.d.ts +3 -0
  40. package/dist/icons/arrow-left.d.ts.map +1 -0
  41. package/dist/icons/arrow-right.d.ts +3 -0
  42. package/dist/icons/arrow-right.d.ts.map +1 -0
  43. package/dist/icons/bars.d.ts +3 -0
  44. package/dist/icons/bars.d.ts.map +1 -0
  45. package/dist/icons/calendar.d.ts +3 -0
  46. package/dist/icons/calendar.d.ts.map +1 -0
  47. package/dist/icons/chart-bar.d.ts +3 -0
  48. package/dist/icons/chart-bar.d.ts.map +1 -0
  49. package/dist/icons/chevron-down.d.ts.map +1 -1
  50. package/dist/icons/chevron-down.js +4 -2
  51. package/dist/icons/chevron-left.d.ts.map +1 -1
  52. package/dist/icons/chevron-left.js +4 -2
  53. package/dist/icons/chevron-right.d.ts.map +1 -1
  54. package/dist/icons/chevron-right.js +4 -2
  55. package/dist/icons/chevron-up.d.ts.map +1 -1
  56. package/dist/icons/chevron-up.js +4 -2
  57. package/dist/icons/ellipsis.d.ts +0 -1
  58. package/dist/icons/ellipsis.d.ts.map +1 -1
  59. package/dist/icons/flag.d.ts +3 -0
  60. package/dist/icons/flag.d.ts.map +1 -0
  61. package/dist/icons/list-bullet.d.ts +3 -0
  62. package/dist/icons/list-bullet.d.ts.map +1 -0
  63. package/dist/icons/lock.d.ts +3 -0
  64. package/dist/icons/lock.d.ts.map +1 -0
  65. package/dist/icons/logout.d.ts +3 -0
  66. package/dist/icons/logout.d.ts.map +1 -0
  67. package/dist/icons/micro/calendar.d.ts +3 -0
  68. package/dist/icons/micro/calendar.d.ts.map +1 -0
  69. package/dist/icons/micro/calendar.js +21 -0
  70. package/dist/icons/micro/check.d.ts +3 -0
  71. package/dist/icons/micro/check.d.ts.map +1 -0
  72. package/dist/icons/micro/check.js +21 -0
  73. package/dist/icons/micro/chevron-down.d.ts +3 -0
  74. package/dist/icons/micro/chevron-down.d.ts.map +1 -0
  75. package/dist/icons/micro/chevron-down.js +21 -0
  76. package/dist/icons/micro/chevron-right.d.ts +3 -0
  77. package/dist/icons/micro/chevron-right.d.ts.map +1 -0
  78. package/dist/icons/micro/chevron-right.js +21 -0
  79. package/dist/icons/micro/exclamation-triangle.d.ts +3 -0
  80. package/dist/icons/micro/exclamation-triangle.d.ts.map +1 -0
  81. package/dist/icons/micro/exclamation-triangle.js +21 -0
  82. package/dist/icons/micro/information-circle.d.ts +3 -0
  83. package/dist/icons/micro/information-circle.d.ts.map +1 -0
  84. package/dist/icons/micro/information-circle.js +21 -0
  85. package/dist/icons/micro/minus.d.ts +3 -0
  86. package/dist/icons/micro/minus.d.ts.map +1 -0
  87. package/dist/icons/micro/minus.js +17 -0
  88. package/dist/icons/micro/moon.d.ts +3 -0
  89. package/dist/icons/micro/moon.d.ts.map +1 -0
  90. package/dist/icons/micro/moon.js +17 -0
  91. package/dist/icons/micro/sun.d.ts +3 -0
  92. package/dist/icons/micro/sun.d.ts.map +1 -0
  93. package/dist/icons/micro/sun.js +17 -0
  94. package/dist/icons/micro/x-mark.d.ts +3 -0
  95. package/dist/icons/micro/x-mark.d.ts.map +1 -0
  96. package/dist/icons/micro/x-mark.js +17 -0
  97. package/dist/icons/search.d.ts.map +1 -1
  98. package/dist/icons/search.js +4 -2
  99. package/dist/icons/settings.d.ts +3 -0
  100. package/dist/icons/settings.d.ts.map +1 -0
  101. package/dist/icons/squares.d.ts +3 -0
  102. package/dist/icons/squares.d.ts.map +1 -0
  103. package/dist/icons/table.d.ts +3 -0
  104. package/dist/icons/table.d.ts.map +1 -0
  105. package/dist/icons/x-mark.d.ts.map +1 -1
  106. package/dist/icons/x-mark.js +4 -2
  107. package/dist/index.d.ts +6 -4
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/lib.js +56 -61
  110. package/dist/menu/index.d.ts.map +1 -1
  111. package/dist/menu/index.js +67 -60
  112. package/dist/meter/index.d.ts +4 -3
  113. package/dist/meter/index.d.ts.map +1 -1
  114. package/dist/meter/index.js +9 -8
  115. package/dist/money-input/index.d.ts +7 -8
  116. package/dist/money-input/index.d.ts.map +1 -1
  117. package/dist/money-input/index.js +37 -19
  118. package/dist/month-picker/index.d.ts.map +1 -1
  119. package/dist/month-picker/index.js +55 -55
  120. package/dist/pills/index.d.ts +1 -1
  121. package/dist/pills/index.d.ts.map +1 -1
  122. package/dist/pills/index.js +6 -2
  123. package/dist/popover/index.d.ts.map +1 -1
  124. package/dist/popover/index.js +15 -13
  125. package/dist/select/index.d.ts.map +1 -1
  126. package/dist/select/index.js +96 -102
  127. package/dist/slider/index.d.ts.map +1 -1
  128. package/dist/slider/index.js +1 -1
  129. package/dist/status-pill/index.d.ts +18 -0
  130. package/dist/status-pill/index.d.ts.map +1 -0
  131. package/dist/status-pill/index.js +25 -0
  132. package/dist/tab-bar/index.js +1 -1
  133. package/dist/table/index.js +1 -1
  134. package/dist/tabs/index.d.ts.map +1 -1
  135. package/dist/tabs/index.js +9 -5
  136. package/dist/theme-toggle/index.d.ts +2 -1
  137. package/dist/theme-toggle/index.d.ts.map +1 -1
  138. package/dist/theme-toggle/index.js +35 -32
  139. package/dist/theme.css +81 -19
  140. package/dist/toast/index.d.ts.map +1 -1
  141. package/dist/toast/index.js +119 -106
  142. package/dist/tooltip/index.d.ts.map +1 -1
  143. package/dist/tooltip/index.js +45 -43
  144. package/dist/tree/index.d.ts +22 -3
  145. package/dist/tree/index.d.ts.map +1 -1
  146. package/dist/tree/index.js +76 -56
  147. package/dist/utils/date.d.ts +6 -4
  148. package/dist/utils/date.d.ts.map +1 -1
  149. package/dist/utils/date.js +18 -16
  150. package/dist/utils/field-chevron.d.ts.map +1 -1
  151. package/dist/utils/field-chevron.js +5 -14
  152. package/dist/utils/status-icons.d.ts +1 -1
  153. package/dist/utils/status-icons.d.ts.map +1 -1
  154. package/dist/utils/status-icons.js +11 -41
  155. package/dist/utils/styles.d.ts +9 -3
  156. package/dist/utils/styles.d.ts.map +1 -1
  157. package/dist/utils/styles.js +2 -2
  158. package/dist/utils/theme-wave.d.ts +24 -0
  159. package/dist/utils/theme-wave.d.ts.map +1 -0
  160. package/dist/utils/theme-wave.js +219 -0
  161. package/dist/utils/typeahead.d.ts +12 -0
  162. package/dist/utils/typeahead.d.ts.map +1 -0
  163. package/dist/utils/typeahead.js +19 -0
  164. package/dist/utils/useAnchoredPopup.d.ts +23 -7
  165. package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
  166. package/dist/utils/useAnchoredPopup.js +86 -30
  167. package/dist/zen.css +1 -1
  168. package/package.json +2 -1
  169. package/dist/icons/ellipsis.js +0 -31
  170. package/dist/icons/index.d.ts +0 -9
  171. package/dist/icons/index.d.ts.map +0 -1
  172. package/dist/icons/status.d.ts +0 -2
  173. package/dist/icons/status.d.ts.map +0 -1
package/dist/theme.css CHANGED
@@ -205,14 +205,25 @@
205
205
 
206
206
  /*
207
207
  * Built from Tailwind's backdrop utilities, which emit the standard and -webkit-
208
- * properties correctly. Phones: a live blur over scrolling content is the main
209
- * cause of jank, so touch screens get a solid tint instead.
208
+ * properties correctly. Where there's no live blur, the surface is solid: a
209
+ * translucent one lets sharp text behind show through (the blur is what hides
210
+ * it). No blur on touch screens (a live blur over scrolling content is the main
211
+ * cause of jank), without a GPU (lite graphics) and with the OS's "reduce
212
+ * transparency". The fallbacks live here, in the utilities layer, where a
213
+ * surface's own `!` background (a Dialog's) is: an unlayered !important rule
214
+ * loses to a layered one.
210
215
  */
211
216
  @utility glass-blur {
212
217
  @apply backdrop-blur-[18px] backdrop-saturate-140;
213
- /* !: glass's `background` shorthand would otherwise reset the colour. */
214
- @apply pointer-coarse:bg-card/96! pointer-coarse:backdrop-filter-none;
215
- @apply [@media(hover:none)]:bg-card/96! [@media(hover:none)]:backdrop-filter-none;
218
+ /*
219
+ * !: glass's `background` shorthand would otherwise reset the colour. [:root_&]
220
+ * adds specificity, so each fallback beats a surface's own `!` background (a
221
+ * Dialog's bg-card/90!) whatever order the rules come in.
222
+ */
223
+ @apply pointer-coarse:[:root_&]:bg-card! pointer-coarse:backdrop-filter-none;
224
+ @apply [@media(hover:none)]:[:root_&]:bg-card! [@media(hover:none)]:backdrop-filter-none;
225
+ @apply [@media(prefers-reduced-transparency:reduce)]:[:root_&]:bg-card! [@media(prefers-reduced-transparency:reduce)]:backdrop-filter-none;
226
+ @apply [html[data-zen-graphics='lite']_&]:bg-card! [html[data-zen-graphics='lite']_&]:backdrop-filter-none;
216
227
  }
217
228
 
218
229
  @utility text-glow {
@@ -225,6 +236,13 @@
225
236
  -webkit-background-clip: text;
226
237
  background-clip: text;
227
238
  color: transparent;
239
+ /*
240
+ * The gradient only paints within the box, and at a tight line height
241
+ * descenders (g, y) and accents hang outside it and would be cut off. The
242
+ * box reaches past them; the margins take that back, so layout is unchanged.
243
+ */
244
+ padding-block: 0.2em;
245
+ margin-block: -0.2em;
228
246
  /* Light theme: start from the ink colour, since near-white would vanish. */
229
247
  &:where(.light *, [data-theme='light'] *) {
230
248
  background-image: linear-gradient(100deg, oklch(var(--foreground)), oklch(var(--primary)) 85%);
@@ -250,15 +268,10 @@
250
268
  /*
251
269
  * Without hardware acceleration (html[data-zen-graphics='lite'], set by
252
270
  * utils/graphics.ts) every blur, full-screen mask and animation is drawn on the
253
- * CPU each frame. Keep the look, drop the cost: solid tints instead of live
254
- * blur (as on phones), a still backdrop, no pointer light. The OS "reduce
255
- * transparency" setting gets the same tints.
271
+ * CPU each frame. Keep the look, drop the cost: solid surfaces instead of live
272
+ * blur (as on phones; see glass-blur), a still backdrop, no pointer light. The
273
+ * OS "reduce transparency" setting gets the same.
256
274
  */
257
- html[data-zen-graphics='lite'] .glass-blur {
258
- -webkit-backdrop-filter: none !important;
259
- backdrop-filter: none !important;
260
- background: oklch(var(--card) / 0.96) !important;
261
- }
262
275
  html[data-zen-graphics='lite'] .zen__header {
263
276
  -webkit-backdrop-filter: none;
264
277
  backdrop-filter: none;
@@ -276,11 +289,6 @@ html[data-zen-graphics='lite'] :is(.zen-topo--lit, .zen-dots--lit) {
276
289
  display: none;
277
290
  }
278
291
  @media (prefers-reduced-transparency: reduce) {
279
- .glass-blur {
280
- -webkit-backdrop-filter: none !important;
281
- backdrop-filter: none !important;
282
- background: oklch(var(--card) / 0.96) !important;
283
- }
284
292
  .zen__header {
285
293
  -webkit-backdrop-filter: none;
286
294
  backdrop-filter: none;
@@ -438,6 +446,47 @@ html[data-zen-graphics='lite'] .zen__table-container[data-under-bottom] .zen__st
438
446
  zen-aurora-c 52s steps(26) infinite alternate;
439
447
  }
440
448
 
449
+ /*
450
+ * A track's sliding indicator is placed by measuring, which can't happen until
451
+ * the page's script runs. Until then (server HTML, before hydration) the active
452
+ * item wears the indicator's look itself, in the same place, so it shows at
453
+ * once: the pill of Pills (and TabList variant="pills"), the bar of underline tabs.
454
+ */
455
+ :has(> .zen__pill-indicator[data-pending]) :is([aria-current='page'], [aria-selected='true']) {
456
+ background-color: color-mix(in oklab, var(--color-primary) 15%, transparent);
457
+ box-shadow:
458
+ inset 0 0 0 1px oklch(var(--glow) / 0.35),
459
+ 0 0 24px -4px oklch(var(--glow) / 0.6);
460
+ }
461
+ :has(> .zen__tab-bar[data-pending]) > [role='tab'][aria-selected='true'] {
462
+ /* The bar straddles the track's bottom border: 1px above its edge, 1px below. */
463
+ box-shadow:
464
+ inset 0 -1px 0 var(--color-primary),
465
+ 0 1px 0 var(--color-primary);
466
+ }
467
+
468
+ /* The page's <main>, focused by Header's skip link: no ring round the whole page. */
469
+ main[data-zen-skip-target]:focus {
470
+ outline: none;
471
+ }
472
+
473
+ /*
474
+ * themeWave() (utils/theme-wave.ts): the new theme spreads over the old one,
475
+ * which holds still, through a clip on the new page (or, into a dark theme,
476
+ * the old one closes in over the new). The water is a canvas
477
+ * drawn over both, in a layer of its own that shows as it is (no fade).
478
+ */
479
+ html.zen-theme-waving::view-transition-old(root),
480
+ html.zen-theme-waving::view-transition-new(root),
481
+ html.zen-theme-waving::view-transition-new(zen-theme-water) {
482
+ animation: none;
483
+ mix-blend-mode: normal;
484
+ }
485
+ /* Into a dark theme, the old one closes in over the new. */
486
+ html.zen-theme-closing::view-transition-old(root) {
487
+ z-index: 1;
488
+ }
489
+
441
490
  /*
442
491
  * Contour lines (image from <Backdrop topoSrc>), faint everywhere… The image
443
492
  * is used as a mask over the tint, so its strokes are white on dark and ink
@@ -774,7 +823,17 @@ html[data-zen-graphics='lite'] .zen__table-container[data-under-bottom] .zen__st
774
823
  }
775
824
  }
776
825
 
777
- /* Popovers scale and fade in from their top-layer entry, and back out. */
826
+ /*
827
+ * Popovers scale and fade in from their top-layer entry, and back out. They
828
+ * stay on a GPU layer of their own after too: while animating they're drawn as
829
+ * one, and a popup at a fractional position (under a trigger that is) would
830
+ * otherwise be repainted when the animation ends, its icons snapping a pixel
831
+ * away from the text.
832
+ */
833
+ .zen__popover,
834
+ .zen__dialog {
835
+ will-change: scale;
836
+ }
778
837
  .zen__popover {
779
838
  transition:
780
839
  opacity 150ms,
@@ -818,6 +877,9 @@ html[data-zen-graphics='lite'] .zen__table-container[data-under-bottom] .zen__st
818
877
  overlay 320ms allow-discrete,
819
878
  display 320ms allow-discrete;
820
879
  }
880
+ .zen__dialog[data-side] {
881
+ will-change: translate;
882
+ }
821
883
  .zen__dialog[data-side]:not([open]) {
822
884
  scale: none;
823
885
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/toast/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIH,SAAS,EACT,SAAS,EAMZ,MAAM,OAAO,CAAC;AAKf,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAErD,MAAM,WAAW,YAAY;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,sCAAsC;IACtC,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IAChD,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AA4BD,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAA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C,WAAW,GAAG,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,QAO/E;AAYD,+EAA+E;AAC/E,wBAAgB,QAAQ,YA/MoB,MAAM,YAAY,YAAY,KAAK,MAAM,CAmNpF"}
@@ -2,86 +2,97 @@
2
2
  import { cx as e } from "../utils/cx.js";
3
3
  import { useGraphicsMode as t } from "../utils/graphics.js";
4
4
  import { AlertIcon as n, CheckIcon as r, InfoIcon as i } from "../utils/status-icons.js";
5
- import { createContext as a, useCallback as o, useContext as s, useEffect as c, useRef as l, useState as u } from "react";
6
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
7
- import { createPortal as p } from "react-dom";
5
+ import a from "../icons/micro/x-mark.js";
6
+ import { createContext as o, useCallback as s, useContext as c, useEffect as l, useRef as u, useState as d } from "react";
7
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { createPortal as h } from "react-dom";
8
9
  //#region packages/toast/index.tsx
9
- var m = 5e3, h = 3, g = 300, _ = 14, v = .05, y = 10, b = 60, x = .45, S = a(null), C = a(null);
10
- function w({ children: n, offset: r, viewportClassName: i }) {
10
+ var g = 5e3, _ = 3, v = 300, y = 14, b = .05, x = 10, S = 60, C = .45, w = o(null), T = o(null);
11
+ function E({ children: n, offset: r, viewportClassName: i }) {
11
12
  t();
12
- let [a, s] = u([]), b = l(0), x = l(/* @__PURE__ */ new Map()), w = l(/* @__PURE__ */ new Set()), [T, D] = u([]), [O, A] = u(!1);
13
- c(() => A(!0), []);
14
- let j = o((e) => (D((t) => [...t, e]), () => D((t) => t.filter((t) => t !== e))), []), M = T.at(-1) ?? (O ? document.body : null), [N, P] = u({}), F = o((e, t) => P((n) => n[e] === t ? n : {
13
+ let [a, o] = d([]), c = u(0), f = u(/* @__PURE__ */ new Map()), S = u(/* @__PURE__ */ new Set()), [C, E] = d([]), [D, k] = d(!1);
14
+ l(() => k(!0), []);
15
+ let A = s((e) => (E((t) => [...t, e]), () => E((t) => t.filter((t) => t !== e))), []), M = C.at(-1) ?? (D ? document.body : null), [N, P] = d({}), F = s((e, t) => P((n) => n[e] === t ? n : {
15
16
  ...n,
16
17
  [e]: t
17
- }), []), [I, L] = u(!1), [R, z] = u(!1), B = o((e, t = "fade") => {
18
- s((n) => n.map((n) => n.id === e ? {
18
+ }), []), [I, L] = d(!1), [R, z] = d(!1), B = u(null), V = s((e) => {
19
+ B.current = e, O(e);
20
+ }, []);
21
+ l(() => {
22
+ let e = (e) => {
23
+ e.key === "F8" && B.current?.querySelector(".zen__toast:not([inert])") && (e.preventDefault(), B.current.focus());
24
+ };
25
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
26
+ }, []);
27
+ let H = s((e, t = "fade") => {
28
+ o((n) => n.map((n) => n.id === e ? {
19
29
  ...n,
20
30
  leaving: t
21
31
  } : n)), setTimeout(() => {
22
- s((t) => {
32
+ o((t) => {
23
33
  let n = t.filter((t) => t.id !== e);
24
34
  return n.length || L(!1), n;
25
- }), P(({ [e]: t, ...n }) => n), x.current.delete(e), w.current.delete(e);
26
- }, g);
27
- }, []), V = o((e, { description: t, tone: n = "info", action: r, timeout: i } = {}) => {
28
- let a = b.current++, o = {
35
+ }), P(({ [e]: t, ...n }) => n), f.current.delete(e), S.current.delete(e);
36
+ }, v);
37
+ }, []), U = s((e, { description: t, tone: n = "info", action: r, timeout: i } = {}) => {
38
+ let a = c.current++, s = {
29
39
  id: a,
30
40
  title: e,
31
41
  description: t,
32
42
  tone: n,
33
43
  action: r,
34
- timeout: i ?? (r ? 1e4 : m)
44
+ timeout: i ?? (r ? 1e4 : g)
35
45
  };
36
- return s((e) => [...e, o]), a;
37
- }, []), H = a.filter((e) => !e.leaving), U = (I || R) && H.length > 0, W = H.at(-1), G = W ? N[W.id] : void 0, K = H.slice(-3), q = U ? K.reduce((e, t) => e + (N[t.id] ?? 0), 0) + y * (K.length - 1) : (G ?? 0) + _ * (K.length - 1), J = (e) => {
38
- let t = H.filter((t) => t.id > e.id), n = t.length;
46
+ return o((e) => [...e, s]), a;
47
+ }, []), W = a.filter((e) => !e.leaving), G = (I || R) && W.length > 0, K = W.at(-1), q = K ? N[K.id] : void 0, J = W.slice(-3), Y = G ? J.reduce((e, t) => e + (N[t.id] ?? 0), 0) + x * (J.length - 1) : (q ?? 0) + y * (J.length - 1), X = (e) => {
48
+ let t = W.filter((t) => t.id > e.id), n = t.length;
39
49
  return {
40
50
  index: n,
41
51
  front: n === 0,
42
- hidden: n >= h,
43
- y: U ? -(t.reduce((e, t) => e + (N[t.id] ?? 0), 0) + y * n) : -14 * Math.min(n, 2),
44
- scale: U ? 1 : 1 - v * Math.min(n, 2),
45
- height: !U && n > 0 ? G : void 0
52
+ hidden: n >= _,
53
+ y: G ? -(t.reduce((e, t) => e + (N[t.id] ?? 0), 0) + x * n) : -14 * Math.min(n, 2),
54
+ scale: G ? 1 : 1 - b * Math.min(n, 2),
55
+ height: !G && n > 0 ? q : void 0
46
56
  };
47
57
  };
48
- return /* @__PURE__ */ f(S.Provider, {
49
- value: V,
50
- children: [/* @__PURE__ */ d(C.Provider, {
51
- value: j,
58
+ return /* @__PURE__ */ m(w.Provider, {
59
+ value: U,
60
+ children: [/* @__PURE__ */ p(T.Provider, {
61
+ value: A,
52
62
  children: n
53
- }), M && p(/* @__PURE__ */ d("section", {
54
- ref: E,
63
+ }), M && h(/* @__PURE__ */ p("section", {
64
+ ref: V,
55
65
  popover: "manual",
56
- "aria-label": "Notifications",
57
- "data-expanded": U || void 0,
66
+ tabIndex: -1,
67
+ "aria-label": "Notifications (F8)",
68
+ "data-expanded": G || void 0,
58
69
  onMouseEnter: () => L(!0),
59
70
  onMouseLeave: () => L(!1),
60
71
  onFocus: () => z(!0),
61
72
  onBlur: (e) => {
62
73
  e.currentTarget.contains(e.relatedTarget) || z(!1);
63
74
  },
64
- className: e("zen__toast-viewport fixed top-auto right-4 bottom-[calc(var(--zen-toast-offset,1rem)+env(safe-area-inset-bottom))] left-auto z-50 m-0 w-[calc(100vw-2rem)] overflow-visible border-0 bg-transparent p-0 text-inherit md:bottom-5 md:w-[24rem]", "transition-[height] duration-300 ease-[cubic-bezier(0.2,0.8,0.2,1)]", i),
75
+ className: e("zen__toast-viewport fixed top-auto right-4 bottom-[calc(var(--zen-toast-offset,1rem)+env(safe-area-inset-bottom))] left-auto z-50 m-0 w-[calc(100vw-2rem)] overflow-visible border-0 bg-transparent p-0 text-inherit outline-hidden md:bottom-5 md:w-[24rem]", "transition-[height] duration-300 ease-[cubic-bezier(0.2,0.8,0.2,1)]", i),
65
76
  style: {
66
- height: q,
77
+ height: Y,
67
78
  ...r && { "--zen-toast-offset": r }
68
79
  },
69
- children: a.map((e, t) => /* @__PURE__ */ d(k, {
80
+ children: a.map((e, t) => /* @__PURE__ */ p(j, {
70
81
  toast: e,
71
- layout: J(e),
82
+ layout: X(e),
72
83
  z: t + 1,
73
- paused: U,
74
- onDismiss: B,
84
+ paused: G,
85
+ onDismiss: H,
75
86
  onHeight: F,
76
- clocks: x.current,
77
- entered: w.current
87
+ clocks: f.current,
88
+ entered: S.current
78
89
  }, e.id))
79
90
  }), M)]
80
91
  });
81
92
  }
82
- function T(e, t) {
83
- let n = s(C);
84
- c(() => {
93
+ function D(e, t) {
94
+ let n = c(T);
95
+ l(() => {
85
96
  let r = e.current;
86
97
  if (n && t && r) return n(r);
87
98
  }, [
@@ -90,17 +101,17 @@ function T(e, t) {
90
101
  e
91
102
  ]);
92
103
  }
93
- function E(e) {
104
+ function O(e) {
94
105
  if (e?.showPopover) try {
95
106
  e.showPopover();
96
107
  } catch {}
97
108
  }
98
- function D() {
99
- let e = s(S);
109
+ function k() {
110
+ let e = c(w);
100
111
  if (!e) throw Error("useToast() needs a <ToastProvider> above it");
101
112
  return e;
102
113
  }
103
- var O = {
114
+ var A = {
104
115
  success: {
105
116
  icon: r,
106
117
  ring: "border-primary/30",
@@ -123,126 +134,128 @@ var O = {
123
134
  glow: "shadow-[var(--toast-shadow)]"
124
135
  }
125
136
  };
126
- function k({ toast: t, layout: n, z: r, paused: i, onDismiss: a, onHeight: o, clocks: s, entered: p }) {
127
- let m = O[t.tone] ?? O.info, h = m.icon, g = l(null), _ = l(null), [v] = u(() => !p.has(t.id));
128
- c(() => {
129
- g.current?.isConnected && p.add(t.id);
130
- }, [p, t.id]), s.has(t.id) || s.set(t.id, {
137
+ function j({ toast: t, layout: n, z: r, paused: i, onDismiss: o, onHeight: s, clocks: c, entered: h }) {
138
+ let g = A[t.tone] ?? A.info, _ = g.icon, v = u(null), y = u(null), [b] = d(() => !h.has(t.id));
139
+ l(() => {
140
+ v.current?.isConnected && h.add(t.id);
141
+ }, [h, t.id]);
142
+ let [x, w] = d(!1);
143
+ l(() => {
144
+ if (!b) return;
145
+ let e = requestAnimationFrame(() => e = requestAnimationFrame(() => w(!0)));
146
+ return () => cancelAnimationFrame(e);
147
+ }, [b]), c.has(t.id) || c.set(t.id, {
131
148
  spent: 0,
132
149
  since: null
133
150
  });
134
- let y = s.get(t.id), [S] = u(() => y.spent + (y.since === null ? 0 : Date.now() - y.since));
135
- c(() => {
136
- let e = _.current;
151
+ let T = c.get(t.id), [E] = d(() => T.spent + (T.since === null ? 0 : Date.now() - T.since));
152
+ l(() => {
153
+ let e = y.current;
137
154
  if (!e) return;
138
- let n = () => o(t.id, e.offsetHeight);
155
+ let n = () => s(t.id, e.offsetHeight);
139
156
  n();
140
157
  let r = new ResizeObserver(n);
141
158
  return r.observe(e), () => r.disconnect();
142
- }, [o, t.id]), c(() => {
159
+ }, [s, t.id]), l(() => {
143
160
  if (!t.timeout || i || t.leaving) return;
144
- y.since = Date.now();
145
- let e = setTimeout(() => a(t.id), Math.max(0, t.timeout - y.spent));
161
+ T.since = Date.now();
162
+ let e = setTimeout(() => o(t.id), Math.max(0, t.timeout - T.spent));
146
163
  return () => {
147
- clearTimeout(e), y.since !== null && (y.spent += Date.now() - y.since), y.since = null;
164
+ clearTimeout(e), T.since !== null && (T.spent += Date.now() - T.since), T.since = null;
148
165
  };
149
166
  }, [
150
167
  i,
151
168
  t.id,
152
169
  t.timeout,
153
170
  t.leaving,
154
- a,
155
- y
171
+ o,
172
+ T
156
173
  ]);
157
- let C = l(null), w = (e) => {
158
- t.leaving || e.button !== 0 || e.target.closest("button") || (C.current = {
174
+ let D = u(null), O = (e) => {
175
+ t.leaving || e.button !== 0 || e.target.closest("button") || (D.current = {
159
176
  x: e.clientX,
160
177
  dx: 0,
161
178
  t: e.timeStamp,
162
179
  speed: 0
163
180
  }, e.currentTarget.setPointerCapture(e.pointerId), e.currentTarget.dataset.swiping = "");
164
- }, T = (e) => {
165
- if (!C.current) return;
166
- let t = C.current, n = e.clientX - t.x;
181
+ }, k = (e) => {
182
+ if (!D.current) return;
183
+ let t = D.current, n = e.clientX - t.x;
167
184
  t.speed = (n - t.dx) / Math.max(1, e.timeStamp - t.t), t.dx = n, t.t = e.timeStamp, e.currentTarget.style.setProperty("--zen-swipe", `${n > 0 ? n : n / 6}px`);
168
- }, E = (e) => {
169
- let n = C.current;
170
- n && (C.current = null, delete e.currentTarget.dataset.swiping, n.dx > b || n.dx > 0 && n.speed > x ? a(t.id, "swipe") : e.currentTarget.style.setProperty("--zen-swipe", "0px"));
185
+ }, j = (e) => {
186
+ let n = D.current;
187
+ n && (D.current = null, delete e.currentTarget.dataset.swiping, n.dx > S || n.dx > 0 && n.speed > C ? o(t.id, "swipe") : e.currentTarget.style.setProperty("--zen-swipe", "0px"));
171
188
  };
172
- return /* @__PURE__ */ f("div", {
173
- ref: g,
189
+ return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("div", {
190
+ ref: v,
174
191
  role: t.tone === "error" ? "alert" : "status",
175
- "aria-atomic": "true",
192
+ "aria-live": "off",
176
193
  "data-front": n.front || void 0,
177
194
  "data-behind": !n.front && n.height !== void 0 || void 0,
178
195
  inert: n.hidden || !!t.leaving,
179
- onPointerDown: w,
180
- onPointerMove: T,
181
- onPointerUp: E,
182
- onPointerCancel: E,
183
- className: e("zen__toast group glass glass-blur glow-edge text-card-foreground absolute! inset-x-0 bottom-0 origin-bottom touch-pan-y overflow-hidden rounded-2xl border select-none", "transition-[transform,translate,opacity,height] duration-400 ease-[cubic-bezier(0.2,0.8,0.2,1)] data-swiping:transition-none", v && "starting:translate-y-full starting:opacity-0", n.hidden && "opacity-0", t.leaving === "fade" && "translate-y-[35%] opacity-0", t.leaving === "swipe" && "translate-x-full opacity-0", m.ring, m.glow),
196
+ onPointerDown: O,
197
+ onPointerMove: k,
198
+ onPointerUp: j,
199
+ onPointerCancel: j,
200
+ className: e("zen__toast group glass glass-blur glow-edge text-card-foreground absolute! inset-x-0 bottom-0 origin-bottom touch-pan-y overflow-hidden rounded-2xl border select-none", "transition-[transform,translate,opacity,height] duration-400 ease-[cubic-bezier(0.2,0.8,0.2,1)] data-swiping:transition-none", b && "starting:translate-y-full starting:opacity-0", n.hidden && "opacity-0", t.leaving === "fade" && "translate-y-[35%] opacity-0", t.leaving === "swipe" && "translate-x-full opacity-0", g.ring, g.glow),
184
201
  style: {
185
202
  zIndex: r,
186
203
  height: n.height,
187
204
  transform: `translateX(var(--zen-swipe, 0px)) translateY(${n.y}px) scale(${n.scale})`
188
205
  },
189
- children: [/* @__PURE__ */ f("div", {
190
- ref: _,
206
+ children: [/* @__PURE__ */ m("div", {
207
+ ref: y,
191
208
  className: "flex items-start gap-3 p-3.5 pr-10 transition-opacity duration-300 group-data-behind:opacity-0",
192
209
  children: [
193
- /* @__PURE__ */ d("span", {
194
- className: e("mt-0.5 grid size-8 shrink-0 place-items-center rounded-full", m.badge),
210
+ /* @__PURE__ */ p("span", {
211
+ className: e("mt-0.5 grid size-8 shrink-0 place-items-center rounded-full", g.badge),
195
212
  "aria-hidden": !0,
196
- children: /* @__PURE__ */ d(h, { className: "size-4" })
213
+ children: /* @__PURE__ */ p(_, { className: "size-4" })
197
214
  }),
198
- /* @__PURE__ */ f("div", {
215
+ /* @__PURE__ */ m("div", {
199
216
  className: "flex min-w-0 flex-1 flex-col gap-0.5 pt-0.5",
200
217
  children: [
201
- /* @__PURE__ */ d("div", {
218
+ /* @__PURE__ */ p("div", {
202
219
  className: "text-sm font-semibold",
203
220
  children: t.title
204
221
  }),
205
- t.description && /* @__PURE__ */ d("div", {
222
+ t.description && /* @__PURE__ */ p("div", {
206
223
  className: "text-muted-foreground text-sm leading-5",
207
224
  children: t.description
208
225
  }),
209
- t.action && /* @__PURE__ */ d("button", {
226
+ t.action && /* @__PURE__ */ p("button", {
210
227
  type: "button",
211
228
  onClick: () => {
212
- t.action?.onClick(), a(t.id);
229
+ t.action?.onClick(), o(t.id);
213
230
  },
214
- className: "border-tint/10 bg-tint/[0.06] hover:bg-tint/[0.12] focus-visible:ring-ring/50 mt-2 self-start rounded-lg border px-3 py-1 text-xs font-medium outline-hidden transition-colors focus-visible:ring-2",
231
+ className: "border-tint/10 bg-tint/[0.06] hover:bg-tint/[0.12] focus-visible:ring-ring/50 mt-2 cursor-pointer self-start rounded-lg border px-3 py-1 text-xs font-medium outline-hidden transition-colors focus-visible:ring-2",
215
232
  children: t.action.label
216
233
  })
217
234
  ]
218
235
  }),
219
- /* @__PURE__ */ d("button", {
236
+ /* @__PURE__ */ p("button", {
220
237
  type: "button",
221
238
  "aria-label": "Dismiss",
222
- onClick: () => a(t.id),
223
- className: "text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-visible:ring-ring/50 absolute top-2.5 right-2.5 grid size-7 place-items-center rounded-lg outline-hidden transition-colors focus-visible:ring-2",
224
- children: /* @__PURE__ */ d("svg", {
225
- viewBox: "0 0 16 16",
226
- fill: "none",
227
- stroke: "currentColor",
228
- strokeWidth: "1.8",
229
- strokeLinecap: "round",
230
- className: "size-3.5",
231
- "aria-hidden": !0,
232
- children: /* @__PURE__ */ d("path", { d: "m4 4 8 8M12 4l-8 8" })
233
- })
239
+ onClick: () => o(t.id),
240
+ className: "text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-visible:ring-ring/50 absolute top-2.5 right-2.5 grid size-7 cursor-pointer place-items-center rounded-lg outline-hidden transition-colors focus-visible:ring-2",
241
+ children: /* @__PURE__ */ p(a, { className: "size-3.5" })
234
242
  })
235
243
  ]
236
- }), t.timeout > 0 && /* @__PURE__ */ d("span", {
244
+ }), t.timeout > 0 && /* @__PURE__ */ p("span", {
237
245
  "aria-hidden": !0,
238
- className: e("zen__toast-timer absolute bottom-0 left-0 h-0.5 w-full origin-left opacity-60 transition-opacity group-data-behind:opacity-0", m.bar),
246
+ className: e("zen__toast-timer absolute bottom-0 left-0 h-0.5 w-full origin-left opacity-60 transition-opacity group-data-behind:opacity-0", g.bar),
239
247
  style: {
240
248
  animationDuration: `${t.timeout}ms`,
241
- animationDelay: `${-S}ms`,
249
+ animationDelay: `${-E}ms`,
242
250
  animationPlayState: i ? "paused" : void 0
243
251
  }
244
252
  })]
245
- });
253
+ }), /* @__PURE__ */ p("span", {
254
+ className: "sr-only",
255
+ "aria-live": t.tone === "error" ? "assertive" : "polite",
256
+ "aria-atomic": "true",
257
+ children: x && [t.title, t.description].filter(Boolean).join(". ")
258
+ })] });
246
259
  }
247
260
  //#endregion
248
- export { w as default, D as useToast, T as useToastHost };
261
+ export { E as default, k as useToast, D as useToastHost };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tooltip/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EACH,cAAc,EAGd,SAAS,EAQZ,MAAM,OAAO,CAAC;AAmBf;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,+BA8BrE;AAED,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,cAAc,EACd,cAAc,EACd,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,mBAAmB,+BAkCrB;AAED,kGAAkG;AAClG,wBAAgB,cAAc,CAAC,EAC3B,KA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