@42-central/ui-react 0.26.0 → 0.28.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 (220) hide show
  1. package/dist/{chunk-YZJUPYPO.js → chunk-2W7H43WL.js} +3 -3
  2. package/dist/{chunk-YZJUPYPO.js.map → chunk-2W7H43WL.js.map} +1 -1
  3. package/dist/{chunk-OVT2KZHY.js → chunk-3KARNPW4.js} +3 -3
  4. package/dist/{chunk-OVT2KZHY.js.map → chunk-3KARNPW4.js.map} +1 -1
  5. package/dist/chunk-6B2GNPJP.js +43 -0
  6. package/dist/chunk-6B2GNPJP.js.map +1 -0
  7. package/dist/{chunk-E52Z2FKU.js → chunk-7BY5I2RB.js} +3 -3
  8. package/dist/{chunk-E52Z2FKU.js.map → chunk-7BY5I2RB.js.map} +1 -1
  9. package/dist/{chunk-JFB6O7IY.js → chunk-7KFUFAVP.js} +4 -4
  10. package/dist/{chunk-JFB6O7IY.js.map → chunk-7KFUFAVP.js.map} +1 -1
  11. package/dist/{chunk-X3YIHN2U.js → chunk-ASKQ6N5V.js} +3 -3
  12. package/dist/{chunk-X3YIHN2U.js.map → chunk-ASKQ6N5V.js.map} +1 -1
  13. package/dist/{chunk-6IRMKF5T.js → chunk-B4GNSSHU.js} +4 -4
  14. package/dist/{chunk-6IRMKF5T.js.map → chunk-B4GNSSHU.js.map} +1 -1
  15. package/dist/{chunk-BMEJBY6H.js → chunk-B5YHYI7E.js} +22 -27
  16. package/dist/chunk-B5YHYI7E.js.map +1 -0
  17. package/dist/{chunk-PT22KEVD.js → chunk-BGDVUC3B.js} +5 -5
  18. package/dist/{chunk-PT22KEVD.js.map → chunk-BGDVUC3B.js.map} +1 -1
  19. package/dist/{chunk-7247WBTV.js → chunk-DJ72KP32.js} +3 -3
  20. package/dist/{chunk-7247WBTV.js.map → chunk-DJ72KP32.js.map} +1 -1
  21. package/dist/{chunk-7OGZT7U2.js → chunk-G3AD3NJG.js} +3 -3
  22. package/dist/{chunk-7OGZT7U2.js.map → chunk-G3AD3NJG.js.map} +1 -1
  23. package/dist/{chunk-276RL7FX.js → chunk-GJFCIG34.js} +8 -8
  24. package/dist/{chunk-276RL7FX.js.map → chunk-GJFCIG34.js.map} +1 -1
  25. package/dist/{chunk-JDPVD2YE.js → chunk-HCHGERDB.js} +3 -3
  26. package/dist/{chunk-JDPVD2YE.js.map → chunk-HCHGERDB.js.map} +1 -1
  27. package/dist/{chunk-H7WOMZXO.js → chunk-HWBFRDX7.js} +16 -8
  28. package/dist/chunk-HWBFRDX7.js.map +1 -0
  29. package/dist/{chunk-LYGOFMXJ.js → chunk-I4IJOLNA.js} +4 -4
  30. package/dist/{chunk-LYGOFMXJ.js.map → chunk-I4IJOLNA.js.map} +1 -1
  31. package/dist/{chunk-7B44J3CF.js → chunk-I53TMAV2.js} +6 -6
  32. package/dist/{chunk-7B44J3CF.js.map → chunk-I53TMAV2.js.map} +1 -1
  33. package/dist/{chunk-DSZF2TW6.js → chunk-IA6DCC3N.js} +6 -6
  34. package/dist/{chunk-DSZF2TW6.js.map → chunk-IA6DCC3N.js.map} +1 -1
  35. package/dist/{chunk-QEAF57ZQ.js → chunk-ISX3AM32.js} +3 -3
  36. package/dist/{chunk-QEAF57ZQ.js.map → chunk-ISX3AM32.js.map} +1 -1
  37. package/dist/{chunk-N42EFOML.js → chunk-K3FZHYJL.js} +6 -6
  38. package/dist/chunk-K3FZHYJL.js.map +1 -0
  39. package/dist/{chunk-ZVECQBGG.js → chunk-KNGSO7A3.js} +41 -13
  40. package/dist/chunk-KNGSO7A3.js.map +1 -0
  41. package/dist/{chunk-NLSJ6T7V.js → chunk-KYVXPSNW.js} +4 -4
  42. package/dist/{chunk-NLSJ6T7V.js.map → chunk-KYVXPSNW.js.map} +1 -1
  43. package/dist/{chunk-J2NW7JID.js → chunk-L5GH7LLD.js} +3 -3
  44. package/dist/{chunk-J2NW7JID.js.map → chunk-L5GH7LLD.js.map} +1 -1
  45. package/dist/{chunk-THGJLR5S.js → chunk-NNPSBC7O.js} +5 -5
  46. package/dist/{chunk-THGJLR5S.js.map → chunk-NNPSBC7O.js.map} +1 -1
  47. package/dist/{chunk-YMVUQ2L7.js → chunk-P7SH3XWY.js} +6 -6
  48. package/dist/chunk-P7SH3XWY.js.map +1 -0
  49. package/dist/{chunk-2CL3FKEY.js → chunk-QEMXXQQO.js} +3 -3
  50. package/dist/{chunk-2CL3FKEY.js.map → chunk-QEMXXQQO.js.map} +1 -1
  51. package/dist/{chunk-2NTCQIRP.js → chunk-QRNQQIQM.js} +5 -5
  52. package/dist/{chunk-2NTCQIRP.js.map → chunk-QRNQQIQM.js.map} +1 -1
  53. package/dist/{chunk-LKFHUDEW.js → chunk-QVOBLRCM.js} +3 -3
  54. package/dist/{chunk-LKFHUDEW.js.map → chunk-QVOBLRCM.js.map} +1 -1
  55. package/dist/{chunk-E3XLWMEB.js → chunk-RKCUXOU2.js} +4 -4
  56. package/dist/{chunk-E3XLWMEB.js.map → chunk-RKCUXOU2.js.map} +1 -1
  57. package/dist/{chunk-DMI4KS32.js → chunk-SBZJGFZ6.js} +3 -3
  58. package/dist/{chunk-DMI4KS32.js.map → chunk-SBZJGFZ6.js.map} +1 -1
  59. package/dist/{chunk-7P32XCEU.js → chunk-SLUOF7XW.js} +2 -2
  60. package/dist/chunk-SLUOF7XW.js.map +1 -0
  61. package/dist/{chunk-SCXXJDKQ.js → chunk-SP6LCCTZ.js} +21 -28
  62. package/dist/chunk-SP6LCCTZ.js.map +1 -0
  63. package/dist/{chunk-Y2G47ARQ.js → chunk-TGGNSSOJ.js} +3 -3
  64. package/dist/{chunk-Y2G47ARQ.js.map → chunk-TGGNSSOJ.js.map} +1 -1
  65. package/dist/{chunk-2TZU4LSX.js → chunk-ULF5LOBS.js} +3 -3
  66. package/dist/{chunk-2TZU4LSX.js.map → chunk-ULF5LOBS.js.map} +1 -1
  67. package/dist/{chunk-D2QIPQ74.js → chunk-W3XX7BYT.js} +2 -2
  68. package/dist/chunk-W3XX7BYT.js.map +1 -0
  69. package/dist/{chunk-F374BNL4.js → chunk-YVTM2KRR.js} +12 -8
  70. package/dist/chunk-YVTM2KRR.js.map +1 -0
  71. package/dist/colors.css +328 -0
  72. package/dist/components/action-icon/action-icon.d.ts +6 -5
  73. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  74. package/dist/components/action-icon/index.js +3 -2
  75. package/dist/components/alert/index.js +2 -2
  76. package/dist/components/app-shell/index.js +7 -6
  77. package/dist/components/app-shell/index.js.map +1 -1
  78. package/dist/components/autocomplete/index.js +4 -4
  79. package/dist/components/badge/badge.d.ts +1 -1
  80. package/dist/components/badge/badge.d.ts.map +1 -1
  81. package/dist/components/badge/index.js +2 -1
  82. package/dist/components/button/button.d.ts +11 -9
  83. package/dist/components/button/button.d.ts.map +1 -1
  84. package/dist/components/button/index.js +3 -2
  85. package/dist/components/button-multi-select/index.js +4 -3
  86. package/dist/components/button-multi-select/index.js.map +1 -1
  87. package/dist/components/button-select/index.js +4 -3
  88. package/dist/components/button-select/index.js.map +1 -1
  89. package/dist/components/calendar/index.js +4 -3
  90. package/dist/components/calendar-heatmap/index.js +2 -2
  91. package/dist/components/camera/index.js +11 -10
  92. package/dist/components/clipboard/index.js +3 -2
  93. package/dist/components/clipboard/index.js.map +1 -1
  94. package/dist/components/code-block/chrome.js +5 -5
  95. package/dist/components/code-block/index.js +6 -6
  96. package/dist/components/combobox/index.js +4 -4
  97. package/dist/components/combobox-list/index.js +6 -6
  98. package/dist/components/data-table/data-table-features.d.ts +8 -0
  99. package/dist/components/data-table/data-table-features.d.ts.map +1 -1
  100. package/dist/components/data-table/data-table-group.d.ts +128 -0
  101. package/dist/components/data-table/data-table-group.d.ts.map +1 -0
  102. package/dist/components/data-table/data-table-grouping.d.ts +72 -0
  103. package/dist/components/data-table/data-table-grouping.d.ts.map +1 -0
  104. package/dist/components/data-table/data-table-icons.d.ts +4 -2
  105. package/dist/components/data-table/data-table-icons.d.ts.map +1 -1
  106. package/dist/components/data-table/data-table-meta.d.ts +9 -0
  107. package/dist/components/data-table/data-table-meta.d.ts.map +1 -1
  108. package/dist/components/data-table/data-table-pagination.d.ts +4 -1
  109. package/dist/components/data-table/data-table-pagination.d.ts.map +1 -1
  110. package/dist/components/data-table/data-table-schema.d.ts +4 -0
  111. package/dist/components/data-table/data-table-schema.d.ts.map +1 -1
  112. package/dist/components/data-table/data-table-stack.d.ts +16 -3
  113. package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
  114. package/dist/components/data-table/data-table-toolbar.d.ts +33 -2
  115. package/dist/components/data-table/data-table-toolbar.d.ts.map +1 -1
  116. package/dist/components/data-table/data-table-translations.d.ts +35 -0
  117. package/dist/components/data-table/data-table-translations.d.ts.map +1 -1
  118. package/dist/components/data-table/data-table.d.ts +55 -3
  119. package/dist/components/data-table/data-table.d.ts.map +1 -1
  120. package/dist/components/data-table/index.d.ts +3 -1
  121. package/dist/components/data-table/index.d.ts.map +1 -1
  122. package/dist/components/data-table/index.js +883 -234
  123. package/dist/components/data-table/index.js.map +1 -1
  124. package/dist/components/date-picker/index.js +12 -11
  125. package/dist/components/date-picker/index.js.map +1 -1
  126. package/dist/components/download-button/index.js +4 -3
  127. package/dist/components/drawer/index.js +7 -6
  128. package/dist/components/file-item/index.js +4 -3
  129. package/dist/components/file-preview/index.js +4 -3
  130. package/dist/components/file-preview/index.js.map +1 -1
  131. package/dist/components/file-trigger/index.js +4 -3
  132. package/dist/components/file-upload/index.js +4 -3
  133. package/dist/components/file-upload/index.js.map +1 -1
  134. package/dist/components/hover-card/index.js +3 -3
  135. package/dist/components/image-cropper/index.js +4 -3
  136. package/dist/components/kbd/index.js +3 -3
  137. package/dist/components/lightbox/index.js +9 -8
  138. package/dist/components/lightbox/index.js.map +1 -1
  139. package/dist/components/menu/index.js +4 -4
  140. package/dist/components/modal/index.js +7 -6
  141. package/dist/components/multi-combobox-list/index.js +6 -6
  142. package/dist/components/multi-select/index.js +4 -4
  143. package/dist/components/nav-link/index.js +3 -3
  144. package/dist/components/nav-link/tanstack.js +3 -3
  145. package/dist/components/notification/create-notifier.d.ts.map +1 -1
  146. package/dist/components/notification/index.js +18 -6
  147. package/dist/components/notification/index.js.map +1 -1
  148. package/dist/components/notification/types.d.ts +5 -0
  149. package/dist/components/notification/types.d.ts.map +1 -1
  150. package/dist/components/number-input/index.js +4 -4
  151. package/dist/components/overlays/index.js +9 -8
  152. package/dist/components/overlays/index.js.map +1 -1
  153. package/dist/components/photo-capture/index.js +13 -12
  154. package/dist/components/photo-capture/index.js.map +1 -1
  155. package/dist/components/popover/index.js +3 -3
  156. package/dist/components/schedule/index.js +7 -6
  157. package/dist/components/schedule/index.js.map +1 -1
  158. package/dist/components/select/index.js +5 -5
  159. package/dist/components/spinner/index.js +1 -1
  160. package/dist/components/spinner/spinner.d.ts +1 -1
  161. package/dist/components/spinner/spinner.d.ts.map +1 -1
  162. package/dist/components/spotlight/index.js +11 -10
  163. package/dist/components/spotlight/index.js.map +1 -1
  164. package/dist/components/tags-input/index.js +3 -3
  165. package/dist/components/theme-icon/index.js +1 -1
  166. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  167. package/dist/components/time-input/index.js +5 -5
  168. package/dist/components/tooltip/index.js +2 -2
  169. package/dist/components/tree-multi-select/index.js +4 -4
  170. package/dist/components/tree-select/index.js +4 -4
  171. package/dist/index.js +2 -2
  172. package/dist/lib/button-colors.d.ts +25 -0
  173. package/dist/lib/button-colors.d.ts.map +1 -0
  174. package/dist/lib/overlay-container.d.ts.map +1 -1
  175. package/dist/lib/overlay-layer.d.ts +10 -3
  176. package/dist/lib/overlay-layer.d.ts.map +1 -1
  177. package/dist/theme.css +14 -6
  178. package/package.json +1 -1
  179. package/src/colors.css +328 -0
  180. package/src/components/action-icon/action-icon.test.tsx +22 -0
  181. package/src/components/action-icon/action-icon.tsx +24 -28
  182. package/src/components/badge/badge.test.tsx +53 -10
  183. package/src/components/badge/badge.tsx +64 -11
  184. package/src/components/button/button.test.tsx +41 -5
  185. package/src/components/button/button.tsx +28 -33
  186. package/src/components/data-table/data-table-features.ts +11 -0
  187. package/src/components/data-table/data-table-group.test.tsx +1007 -0
  188. package/src/components/data-table/data-table-group.tsx +474 -0
  189. package/src/components/data-table/data-table-grouping.ts +160 -0
  190. package/src/components/data-table/data-table-icons.tsx +8 -1
  191. package/src/components/data-table/data-table-meta.ts +9 -0
  192. package/src/components/data-table/data-table-pagination.tsx +5 -1
  193. package/src/components/data-table/data-table-stack.tsx +165 -43
  194. package/src/components/data-table/data-table-toolbar.tsx +110 -2
  195. package/src/components/data-table/data-table-translations.ts +44 -0
  196. package/src/components/data-table/data-table.tsx +420 -150
  197. package/src/components/data-table/index.ts +4 -0
  198. package/src/components/drawer/drawer.tsx +1 -1
  199. package/src/components/modal/modal.tsx +1 -1
  200. package/src/components/notification/create-notifier.tsx +18 -2
  201. package/src/components/notification/notify-in-modal.test.tsx +128 -0
  202. package/src/components/notification/types.ts +5 -0
  203. package/src/components/spinner/spinner.tsx +3 -3
  204. package/src/components/theme-icon/theme-icon.test.tsx +7 -0
  205. package/src/components/theme-icon/theme-icon.tsx +10 -6
  206. package/src/lib/button-colors.ts +55 -0
  207. package/src/lib/overlay-container.tsx +2 -1
  208. package/src/lib/overlay-layer.test.tsx +63 -1
  209. package/src/lib/overlay-layer.tsx +29 -6
  210. package/src/theme.css +14 -6
  211. package/src/theme.test.ts +14 -10
  212. package/dist/chunk-7P32XCEU.js.map +0 -1
  213. package/dist/chunk-BMEJBY6H.js.map +0 -1
  214. package/dist/chunk-D2QIPQ74.js.map +0 -1
  215. package/dist/chunk-F374BNL4.js.map +0 -1
  216. package/dist/chunk-H7WOMZXO.js.map +0 -1
  217. package/dist/chunk-N42EFOML.js.map +0 -1
  218. package/dist/chunk-SCXXJDKQ.js.map +0 -1
  219. package/dist/chunk-YMVUQ2L7.js.map +0 -1
  220. package/dist/chunk-ZVECQBGG.js.map +0 -1
@@ -8,6 +8,8 @@ export type {
8
8
  ColumnFiltersState,
9
9
  ColumnSizingState,
10
10
  ColumnVisibilityState,
11
+ ExpandedState,
12
+ GroupingState,
11
13
  OnChangeFn,
12
14
  PaginationState,
13
15
  RowSelectionState,
@@ -40,6 +42,8 @@ export {
40
42
  type HeaderContext,
41
43
  type Row,
42
44
  } from "./data-table-features"
45
+ export type { DataTableGroupHeaderContext, DataTableGroupShowMore } from "./data-table-group"
46
+ export type { DataTableGroup } from "./data-table-grouping"
43
47
  export type {
44
48
  DataTableIconSlot,
45
49
  DataTableIcons,
@@ -201,7 +201,7 @@ const DrawerRoot = ({
201
201
  >
202
202
  {/* A layer itself, registered with whatever it opened from (the page,
203
203
  or an enclosing overlay), so what's under it knows it's covered. */}
204
- <Ark.Context>{(api) => <NestedLayer open={api.open} />}</Ark.Context>
204
+ <Ark.Context>{(api) => <NestedLayer open={api.open} modal />}</Ark.Context>
205
205
  <DrawerPlacementContext value={placement}>
206
206
  <DialogRootProviders icons={icons} layers={guard.layers}>
207
207
  {children}
@@ -113,7 +113,7 @@ const ModalRoot = ({ onPointerDownOutside, icons, children, ...rest }: ModalRoot
113
113
  <Ark.Root onPointerDownOutside={guard.onPointerDownOutside} {...rest}>
114
114
  {/* A layer itself, registered with whatever it opened from (the page,
115
115
  or an enclosing overlay), so what's under it knows it's covered. */}
116
- <Ark.Context>{(api) => <NestedLayer open={api.open} />}</Ark.Context>
116
+ <Ark.Context>{(api) => <NestedLayer open={api.open} modal />}</Ark.Context>
117
117
  <DialogRootProviders icons={icons} layers={guard.layers}>
118
118
  {children}
119
119
  </DialogRootProviders>
@@ -17,6 +17,7 @@ import type { UnavailableProps } from "../../lib/available-if"
17
17
  import { cn } from "../../lib/cn"
18
18
  import type { Color } from "../../lib/colors"
19
19
  import { useMergedRefs } from "../../lib/merge-refs"
20
+ import { isModalOpen } from "../../lib/overlay-layer"
20
21
  import { useDocumentVisibility } from "../../lib/use-document-visibility"
21
22
  import {
22
23
  NOTIFICATION_DEFAULT_TRANSLATIONS,
@@ -266,7 +267,8 @@ function ToasterItem({
266
267
  const { id } = toast
267
268
  // The store keeps `type` and `color` side by side; the card takes one or the
268
269
  // other. At most one is ever set (see `toData`), so pick whichever is.
269
- const { type, color, ...fields } = toast
270
+ // `raised` is the region's business, not the card's.
271
+ const { type, color, raised: _raised, ...fields } = toast
270
272
  const hue: ToastHue = type ? { type } : { color }
271
273
 
272
274
  const presence = usePresence({
@@ -392,6 +394,11 @@ export function createNotifier(options: CreateNotifierOptions = {}): Notifier {
392
394
  icon: o.icon,
393
395
  duration: o.duration ?? (type === "loading" ? Number.POSITIVE_INFINITY : defaultDuration),
394
396
  withCloseButton: o.withCloseButton ?? true,
397
+ // A toast is feedback on what the user just did, so if they did it in a
398
+ // modal it must show over the modal. Only ever set, never cleared: the
399
+ // store merges a re-create by id, so a promise settling after the modal
400
+ // closed keeps its place. See `--toast-raised-z` in theme.css.
401
+ ...(isModalOpen() && { raised: true }),
395
402
  }
396
403
  }
397
404
 
@@ -527,17 +534,26 @@ export function createNotifier(options: CreateNotifierOptions = {}): Notifier {
527
534
  const maxHeight = toasts.reduce((max, toast) => Math.max(max, heightOf(toast)), 0)
528
535
  const stackOverflow = placement.startsWith("bottom") ? Math.max(0, maxHeight - frontHeight) : 0
529
536
 
537
+ const raised = toasts.some((toast) => toast.raised)
538
+
530
539
  const region = (
531
540
  <section
532
541
  aria-label={translations.regionLabel}
533
542
  data-scope="notifications"
534
543
  data-placement={placement}
535
544
  data-expand={expand ? "" : undefined}
545
+ data-raised={raised ? "" : undefined}
546
+ // zag's modal dialog aria-hides everything outside it, which would
547
+ // silence a toast raised from inside it. It skips live announcers.
548
+ data-live-announcer=""
536
549
  // Slide direction for the enter/exit keyframes: from below for bottom
537
550
  // placements, from above for top.
538
551
  style={{ ["--toast-from" as string]: placement.startsWith("top") ? "-100%" : "100%" }}
539
552
  className={cn(
540
- "pointer-events-none fixed z-(--toast-z,100) justify-center flex",
553
+ "pointer-events-none fixed justify-center flex",
554
+ // Under modals by default; above them while it holds a toast created
555
+ // from inside one (theme.css, OVERLAY STACKING).
556
+ raised ? "z-(--toast-raised-z,200)" : "z-(--toast-z,100)",
541
557
  REGION_POSITION[placement],
542
558
  // Phones (< xs): pin to the bottom, full-bleed, above the safe area.
543
559
  "max-xs:inset-x-0! max-xs:bottom-[calc(1rem+env(safe-area-inset-bottom))]! max-xs:top-auto! max-xs:translate-x-0!",
@@ -0,0 +1,128 @@
1
+ /** biome-ignore-all lint/style/noNonNullAssertion: a missing node fails the test anyway */
2
+
3
+ import { act, render, screen } from "@testing-library/react"
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
5
+ import { Drawer } from "../drawer/drawer"
6
+ import { Modal } from "../modal/modal"
7
+ import { createNotifier } from "./create-notifier"
8
+
9
+ /**
10
+ * #440: a toast created from inside a modal is feedback on what was done in
11
+ * it, so it has to reach the user over the modal: painted above it, announced,
12
+ * and dismissable without taking the modal along. Toasts that were on screen
13
+ * before the modal opened stay under it.
14
+ *
15
+ * Fake timers for the same reason as `lib/overlay-layer.test.tsx`: zag arms its
16
+ * outside listeners (and its aria-hiding) a few frames after the layer mounts.
17
+ */
18
+ beforeEach(() => {
19
+ vi.useFakeTimers({
20
+ toFake: [
21
+ "setTimeout",
22
+ "clearTimeout",
23
+ "requestAnimationFrame",
24
+ "cancelAnimationFrame",
25
+ "performance",
26
+ ],
27
+ })
28
+ })
29
+ afterEach(() => {
30
+ vi.useRealTimers()
31
+ })
32
+
33
+ const settle = () => act(() => vi.advanceTimersByTimeAsync(150))
34
+
35
+ const region = () => document.querySelector<HTMLElement>('[data-scope="notifications"]')!
36
+
37
+ const setup = (Surface: "modal" | "drawer" = "modal") => {
38
+ const { notify, Notifications } = createNotifier({ duration: Number.POSITIVE_INFINITY })
39
+ const onOpenChange = vi.fn()
40
+ const view = (open: boolean) =>
41
+ Surface === "modal" ? (
42
+ <>
43
+ <Modal open={open} onOpenChange={onOpenChange} title="Edit slot">
44
+ body
45
+ </Modal>
46
+ <Notifications />
47
+ </>
48
+ ) : (
49
+ <>
50
+ <Drawer open={open} onOpenChange={onOpenChange} title="Edit slot">
51
+ body
52
+ </Drawer>
53
+ <Notifications />
54
+ </>
55
+ )
56
+ const utils = render(view(false))
57
+ return {
58
+ notify,
59
+ open: async () => {
60
+ utils.rerender(view(true))
61
+ await settle()
62
+ },
63
+ close: async () => {
64
+ utils.rerender(view(false))
65
+ await settle()
66
+ },
67
+ }
68
+ }
69
+
70
+ describe("notify while a modal is open", () => {
71
+ it("leaves the region in its own band with no modal open", async () => {
72
+ const { notify } = setup()
73
+ act(() => void notify.error("Failed"))
74
+ await settle()
75
+ expect(region().hasAttribute("data-raised")).toBe(false)
76
+ })
77
+
78
+ it.each(["modal", "drawer"] as const)("raises a toast created from a %s", async (surface) => {
79
+ const { notify, open } = setup(surface)
80
+ await open()
81
+ act(() => void notify.error("Failed"))
82
+ await settle()
83
+ expect(region().hasAttribute("data-raised")).toBe(true)
84
+ })
85
+
86
+ it("leaves a toast that was already on screen under the modal", async () => {
87
+ const { notify, open } = setup()
88
+ act(() => void notify.success("Saved earlier"))
89
+ await open()
90
+ await settle()
91
+ expect(region().hasAttribute("data-raised")).toBe(false)
92
+ })
93
+
94
+ it("keeps a raised toast raised after the modal closes", async () => {
95
+ const { notify, open, close } = setup()
96
+ await open()
97
+ act(() => void notify.error("Failed"))
98
+ await close()
99
+ expect(region().hasAttribute("data-raised")).toBe(true)
100
+ })
101
+
102
+ it("keeps the raise when a promise toast settles after the modal closed", async () => {
103
+ const { notify, open, close } = setup()
104
+ await open()
105
+ let reject!: (reason: unknown) => void
106
+ act(() => {
107
+ notify.promise(new Promise((_, r) => (reject = r)), { loading: "Saving…", error: "Failed" })
108
+ })
109
+ await close()
110
+ await act(async () => reject(new Error("409")))
111
+ await settle()
112
+ expect(screen.getByText("Failed")).toBeTruthy()
113
+ expect(region().hasAttribute("data-raised")).toBe(true)
114
+ })
115
+
116
+ it("is not aria-hidden by the modal, so the error is announced", async () => {
117
+ const { notify, open } = setup()
118
+ await open()
119
+ act(() => void notify.error("Failed"))
120
+ await settle()
121
+ expect(region().closest("[aria-hidden='true']")).toBeNull()
122
+ expect(screen.getByRole("alert").textContent).toContain("Failed")
123
+ })
124
+
125
+ // A press on a toast not dismissing the modal is tested against the guard
126
+ // itself in `lib/overlay-layer.test.tsx`: jsdom doesn't reproduce zag's
127
+ // outside dismissal from a press on a portaled sibling reliably.
128
+ })
@@ -64,4 +64,9 @@ export type ToastFields = {
64
64
  /** Render the close (×) button. Takes precedence over `withCollapse` (on the
65
65
  * ready-made `Notification`). */
66
66
  withCloseButton?: boolean
67
+ /** Created while a Modal, Drawer or Lightbox was open: the region paints
68
+ * above modals (`--toast-raised-z`) while this toast is on screen. Set by the
69
+ * notifier, never by the caller, and kept once set, so a toast that was
70
+ * above a modal never drops under it mid-life. */
71
+ raised?: boolean
67
72
  }
@@ -24,7 +24,7 @@ import { TEXT_COLOR_CLASSES } from "../../lib/typography-size"
24
24
  * paints the primitives behind Figma's `Text/text-primary` (`brand-950` / `white`).
25
25
  *
26
26
  * Sizing follows the same logic: omit `size` to inherit from a parent's
27
- * `[&_svg]:size-*` rule (Button does this), or set it explicitly for
27
+ * svg size rule (Button's `[:where(&)_svg]:size-*`), or set it explicitly for
28
28
  * standalone use.
29
29
  *
30
30
  * Accessibility: a standalone spinner is a `role="status"` live region holding
@@ -59,7 +59,7 @@ export type SpinnerColor = Color | "currentColor" | "default"
59
59
 
60
60
  export type SpinnerProps = Omit<ComponentPropsWithoutRef<"span">, "color" | "children"> &
61
61
  WithTestId & {
62
- /** Explicit size; omit to inherit from a parent's `[&_svg]:size-*` rule. */
62
+ /** Explicit size; omit to inherit from a parent's svg size rule. */
63
63
  size?: SpinnerSize
64
64
  /**
65
65
  * Stroke color. Omit (or pass `"currentColor"`) to inherit the surrounding
@@ -122,7 +122,7 @@ export const Spinner = ({
122
122
  strokeLinejoin="round"
123
123
  aria-hidden
124
124
  // Sized: fill the root. Unsized: keep the 24px intrinsic size, or a parent's
125
- // `[&_svg]:size-*` rule (Button's), which the root then hugs.
125
+ // svg size rule (Button's), which the root then hugs.
126
126
  className={cn("block", size && "size-full")}
127
127
  >
128
128
  {withTrack && <circle cx="12" cy="12" r="10" strokeWidth={1} className="opacity-20" />}
@@ -17,4 +17,11 @@ describe("ThemeIcon", () => {
17
17
  const link = screen.getByRole("link", { name: "settings" })
18
18
  expect(link.className).toContain("focus-visible:ring-brand-500")
19
19
  })
20
+
21
+ it("sizes its icon through a zero-specificity rule, so a class on the icon wins", () => {
22
+ render(<ThemeIcon testId="icon" size="md" />)
23
+ const classes = [...screen.getByTestId("icon").classList]
24
+ expect(classes).toContain("[:where(&)_svg]:size-4")
25
+ expect(classes.some((c) => c.startsWith("[&_svg]"))).toBe(false)
26
+ })
20
27
  })
@@ -26,7 +26,11 @@ const themeIconVariants = cva(
26
26
  "inline-flex items-center justify-center",
27
27
  "aspect-square shrink-0 select-none",
28
28
  "rounded-lg border",
29
- "[&_svg]:shrink-0 [&_svg]:pointer-events-none",
29
+ // Every svg rule is `[:where(&)_svg]`: zero class specificity, so a size
30
+ // class on the icon itself (`<Star className="size-5" />`) or a nested
31
+ // component's own svg rule wins whatever the CSS order. Lucide's `size`
32
+ // prop is only an HTML attribute and still loses. Same fix as Input (#427).
33
+ "[:where(&)_svg]:shrink-0 [:where(&)_svg]:pointer-events-none",
30
34
  // Inert on the default non-focusable <div>; applies once `asChild`
31
35
  // renders ThemeIcon onto a real <a>/<button>. See `focusStyles`.
32
36
  focusStyles(),
@@ -98,11 +102,11 @@ const themeIconVariants = cva(
98
102
  // a 28/32/36/40/48px tile — under half the tile, so the tile reads as a
99
103
  // frame around the icon, not as the icon's own padding.
100
104
  size: {
101
- xs: "h-7 [&_svg]:size-3",
102
- sm: "h-8 [&_svg]:size-3.5",
103
- md: "h-9 [&_svg]:size-4",
104
- lg: "h-10 [&_svg]:size-4.5",
105
- xl: "h-12 [&_svg]:size-5.5",
105
+ xs: "h-7 [:where(&)_svg]:size-3",
106
+ sm: "h-8 [:where(&)_svg]:size-3.5",
107
+ md: "h-9 [:where(&)_svg]:size-4",
108
+ lg: "h-10 [:where(&)_svg]:size-4.5",
109
+ xl: "h-12 [:where(&)_svg]:size-5.5",
106
110
  },
107
111
  radius: {
108
112
  xs: "rounded-xs",
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Colour classes shared by Button and ActionIcon, one entry per variant.
3
+ *
4
+ * Every value comes from the `--btn-*` slots in `colors.css`, which copy the
5
+ * 42 UI Kit V3 Figma `Buttons/Button` set (Figma's ActionIcon is an instance
6
+ * of it). Shape, size and layout stay in each component's own `cva`.
7
+ *
8
+ * Hovers are gated on `not-data-loading:` so a loading control keeps its
9
+ * resting colours. Disabled colours are keyed twice: `:disabled` for a real
10
+ * `<button>` (scoped off while loading, which also sets native `disabled`)
11
+ * and `data-disabled` for an `asChild` element, where `:disabled` never
12
+ * matches.
13
+ *
14
+ * Every class is written out in full: Tailwind only generates CSS for class
15
+ * names it finds literally in the source, so composing the prefixes with a
16
+ * template string would silently drop every hover and disabled rule.
17
+ */
18
+ export const buttonColorVariants = {
19
+ filled: [
20
+ "bg-(--btn-solid) text-(--btn-on-solid)",
21
+ "not-data-loading:hover:bg-(--btn-solid-hover)",
22
+ "disabled:not-data-loading:bg-(--btn-disabled-bg) data-disabled:bg-(--btn-disabled-bg)",
23
+ "disabled:not-data-loading:border-(--btn-disabled-border) data-disabled:border-(--btn-disabled-border)",
24
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
25
+ ],
26
+ light: [
27
+ "bg-(--btn-light-bg) border-(--btn-light-border) text-(--btn-light-text)",
28
+ "not-data-loading:hover:bg-(--btn-light-hover-bg)",
29
+ "not-data-loading:hover:border-(--btn-light-hover-border)",
30
+ "not-data-loading:hover:text-(--btn-light-hover-text)",
31
+ "disabled:not-data-loading:bg-(--btn-light-disabled-bg) data-disabled:bg-(--btn-light-disabled-bg)",
32
+ "disabled:not-data-loading:border-(--btn-light-disabled-border) data-disabled:border-(--btn-light-disabled-border)",
33
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
34
+ ],
35
+ outline: [
36
+ "bg-transparent border-(--btn-outline-border) text-(--btn-outline-text)",
37
+ "not-data-loading:hover:bg-(--btn-outline-hover-bg)",
38
+ "not-data-loading:hover:border-(--btn-outline-hover-border)",
39
+ "not-data-loading:hover:text-(--btn-outline-hover-text)",
40
+ "disabled:not-data-loading:bg-(--btn-disabled-bg) data-disabled:bg-(--btn-disabled-bg)",
41
+ "disabled:not-data-loading:border-(--btn-disabled-border) data-disabled:border-(--btn-disabled-border)",
42
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
43
+ ],
44
+ subtle: [
45
+ "bg-transparent text-(--btn-subtle-text)",
46
+ "not-data-loading:hover:bg-(--btn-subtle-hover-bg)",
47
+ "not-data-loading:hover:text-(--btn-subtle-hover-text)",
48
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
49
+ ],
50
+ link: [
51
+ "bg-transparent text-(--btn-link-text) underline underline-offset-2",
52
+ "not-data-loading:hover:text-(--btn-link-hover)",
53
+ "disabled:not-data-loading:text-(--btn-disabled-text) data-disabled:text-(--btn-disabled-text)",
54
+ ],
55
+ }
@@ -17,7 +17,8 @@ import { createContext, type ReactNode, type RefObject, useContext, useMemo } fr
17
17
  * Being a descendant of a surface that already outranks the page, the panel
18
18
  * stays above it structurally, whatever its own z-index band says — which is
19
19
  * also what frees `--toast-z` to sit between the overlay and modal bands
20
- * instead of above both (see `theme.css`).
20
+ * instead of above both. A toast created while a modal is open moves up to
21
+ * `--toast-raised-z` instead (see `theme.css`).
21
22
  *
22
23
  * `Schedule` publishes its scroller the same way, for a different reason: its
23
24
  * popovers should scroll and clip with the grid, not float over the page.
@@ -1,9 +1,10 @@
1
- import { act, fireEvent, render, screen } from "@testing-library/react"
1
+ import { act, fireEvent, render, renderHook, screen } from "@testing-library/react"
2
2
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
3
3
  import { Drawer } from "../components/drawer/drawer"
4
4
  import { Menu } from "../components/menu"
5
5
  import { Modal } from "../components/modal/modal"
6
6
  import { Popover } from "../components/popover/popover"
7
+ import { isModalOpen, useLayerGuard } from "./overlay-layer"
7
8
 
8
9
  // Zag arms its outside-pointer listeners a few hops after the layer mounts (a
9
10
  // microtask, an animation frame, then a timer) and dispatches the outside event
@@ -156,3 +157,64 @@ describe("nested overlay layers", () => {
156
157
  expect(screen.getByRole("dialog")).toBeTruthy()
157
158
  })
158
159
  })
160
+
161
+ /** zag's outside event as it really arrives: dispatched on the layer's own
162
+ * content node, with the pressed node only in `detail.originalEvent`. */
163
+ const outsideEvent = (pressed: Element) => {
164
+ const originalEvent = new Event("pointerdown")
165
+ Object.defineProperty(originalEvent, "target", { value: pressed })
166
+ return new CustomEvent("pointerdown.outside", { cancelable: true, detail: { originalEvent } })
167
+ }
168
+
169
+ const getButton = () => {
170
+ const button = document.querySelector("button")
171
+ if (!button) throw new Error("no button")
172
+ return button
173
+ }
174
+
175
+ describe("toasts are never outside a layer (#440)", () => {
176
+ it("vetoes the dismiss when the press lands on a toast", () => {
177
+ document.body.innerHTML =
178
+ '<section data-scope="notifications"><div><button>×</button></div></section>'
179
+ const { result } = renderHook(() => useLayerGuard())
180
+ const event = outsideEvent(getButton())
181
+ result.current.onPointerDownOutside(event)
182
+ expect(event.defaultPrevented).toBe(true)
183
+ })
184
+
185
+ it("lets any other outside press through", () => {
186
+ document.body.innerHTML = "<main><button>page</button></main>"
187
+ const { result } = renderHook(() => useLayerGuard())
188
+ const event = outsideEvent(getButton())
189
+ result.current.onPointerDownOutside(event)
190
+ expect(event.defaultPrevented).toBe(false)
191
+ })
192
+ })
193
+
194
+ describe("isModalOpen", () => {
195
+ it.each([
196
+ ["Modal", (open: boolean) => <Modal open={open} onOpenChange={() => {}} title="T" />],
197
+ ["Drawer", (open: boolean) => <Drawer open={open} onOpenChange={() => {}} title="T" />],
198
+ ] as const)("is true exactly while a %s is open", async (_, view) => {
199
+ const { rerender, unmount } = render(view(false))
200
+ expect(isModalOpen()).toBe(false)
201
+ rerender(view(true))
202
+ await settle()
203
+ expect(isModalOpen()).toBe(true)
204
+ rerender(view(false))
205
+ await settle()
206
+ expect(isModalOpen()).toBe(false)
207
+ unmount()
208
+ })
209
+
210
+ it("ignores page-level pickers", async () => {
211
+ render(
212
+ <Popover.Root defaultOpen>
213
+ <Popover.Trigger>open</Popover.Trigger>
214
+ <Popover.Content>panel</Popover.Content>
215
+ </Popover.Root>,
216
+ )
217
+ await settle()
218
+ expect(isModalOpen()).toBe(false)
219
+ })
220
+ })
@@ -44,6 +44,26 @@ const PAGE_LAYERS: OverlayLayers = new Set()
44
44
 
45
45
  const OverlayLayerContext = createContext<OverlayLayers>(PAGE_LAYERS)
46
46
 
47
+ /** The modal layers open right now, anywhere on the page: every open
48
+ * `Modal`, `Drawer` and `Lightbox`, however deeply nested. Module scope, not
49
+ * context, because its one reader (`notify()`) runs outside React. Not
50
+ * derivable from `PAGE_LAYERS`: a Drawer opened from a page Popover
51
+ * registers into the popover's set, not the page's. */
52
+ const OPEN_MODALS = new Set<symbol>()
53
+
54
+ /** Whether a Modal, Drawer or Lightbox is open right now. The notifier asks
55
+ * when a toast is created, to raise it above the modal (`--toast-raised-z`). */
56
+ export const isModalOpen = () => OPEN_MODALS.size > 0
57
+
58
+ /** A press on a toast is never "outside" a layer. Toasts raised from a modal
59
+ * paint above it, and dismissing one must not take the modal (and the form
60
+ * in it) along. zag dispatches its outside event on the layer's own content
61
+ * node, so the pressed node is the original event's target, in `detail`. */
62
+ const isToastEvent = (event: Event) => {
63
+ const target = (event as CustomEvent<{ originalEvent?: Event }>).detail?.originalEvent?.target
64
+ return target instanceof Element && target.closest('[data-scope="notifications"]') != null
65
+ }
66
+
47
67
  /** For a parent layer. Spread `onPointerDownOutside` onto the Ark root
48
68
  * (composed with the caller's own) and wrap the children that may open nested
49
69
  * layers in `OverlayLayerProvider`. A ref'd set, not state: it's read synchronously while
@@ -53,7 +73,7 @@ export const useLayerGuard = <E extends Event>(onPointerDownOutside?: (event: E)
53
73
  const guard = useCallback(
54
74
  (event: E) => {
55
75
  onPointerDownOutside?.(event)
56
- if (layers.size > 0) event.preventDefault()
76
+ if (layers.size > 0 || isToastEvent(event)) event.preventDefault()
57
77
  },
58
78
  [layers, onPointerDownOutside],
59
79
  )
@@ -72,23 +92,26 @@ export const OverlayLayerProvider = ({
72
92
  * none encloses it) while `open`. Keyed on
73
93
  * `open`, not presence, so a panel playing its exit animation no longer holds
74
94
  * the parent's next click. A layout effect so the registration is in place
75
- * before the browser can deliver the next pointerdown. */
76
- export const useNestedLayer = (open: boolean) => {
95
+ * before the browser can deliver the next pointerdown. `modal` marks a
96
+ * Modal, Drawer or Lightbox, which `isModalOpen` counts. */
97
+ export const useNestedLayer = (open: boolean, { modal = false }: { modal?: boolean } = {}) => {
77
98
  const parent = useContext(OverlayLayerContext)
78
99
  useIsomorphicLayoutEffect(() => {
79
100
  if (!open) return
80
101
  const token = Symbol()
81
102
  parent.add(token)
103
+ if (modal) OPEN_MODALS.add(token)
82
104
  return () => {
83
105
  parent.delete(token)
106
+ OPEN_MODALS.delete(token)
84
107
  }
85
- }, [open, parent])
108
+ }, [open, modal, parent])
86
109
  }
87
110
 
88
111
  /** `useNestedLayer` as an element, for call sites that only have the machine's
89
112
  * `open` inside a render prop (`<Ark.Context>{(api) => …}</Ark.Context>`). */
90
- export const NestedLayer = ({ open }: { open: boolean }) => {
91
- useNestedLayer(open)
113
+ export const NestedLayer = ({ open, modal }: { open: boolean; modal?: boolean }) => {
114
+ useNestedLayer(open, { modal })
92
115
  return null
93
116
  }
94
117
 
package/src/theme.css CHANGED
@@ -1295,10 +1295,17 @@ body {
1295
1295
  ==========================================
1296
1296
  One scale for every floating surface, in the order they need to paint:
1297
1297
 
1298
- --overlay-z popover, menu, hover-card, select, combobox, date-picker
1299
- --toast-z the notifier region
1300
- --modal-z modal + drawer (backdrop and positioner)
1301
- --tooltip-z tooltip
1298
+ --overlay-z popover, menu, hover-card, select, combobox, date-picker
1299
+ --toast-z the notifier region
1300
+ --modal-z modal + drawer + lightbox (backdrop and positioner)
1301
+ --toast-raised-z the notifier region, while it holds a toast created
1302
+ with a modal open (feedback on what was done in it)
1303
+ --tooltip-z tooltip
1304
+
1305
+ Bands are 50 apart, and stay that way: each one adds zag's `--layer-index`
1306
+ (nesting depth) on top of its base, so the gap is how deep a band can nest
1307
+ before it collides with the next. Insert a new band by moving the ones
1308
+ above it up, not by halving a gap. `theme.test.ts` holds the spacing.
1302
1309
 
1303
1310
  Two facts about `@zag-js/popper` decide *where* these values have to be
1304
1311
  declared, and both are easy to get wrong:
@@ -1339,7 +1346,8 @@ body {
1339
1346
  --overlay-z: 50;
1340
1347
  --toast-z: 100;
1341
1348
  --modal-z: 150;
1342
- --tooltip-z: 200;
1349
+ --toast-raised-z: 200;
1350
+ --tooltip-z: 250;
1343
1351
  }
1344
1352
 
1345
1353
  [data-scope="popover"][data-part="content"],
@@ -1354,7 +1362,7 @@ body {
1354
1362
  /* A tooltip can show up over anything hoverable, an open picker included. It
1355
1363
  isn't a dismissable layer, so there's no `--layer-index` to add. */
1356
1364
  [data-scope="tooltip"][data-part="content"] {
1357
- z-index: var(--tooltip-z, 200);
1365
+ z-index: var(--tooltip-z, 250);
1358
1366
  }
1359
1367
 
1360
1368
  /* ==========================================
package/src/theme.test.ts CHANGED
@@ -149,12 +149,12 @@ describe("exit animations are always state-driven", () => {
149
149
  describe("theme.css overlay stacking", () => {
150
150
  const rootBlock = themeCss.match(/:root \{[\s\S]*?\n\}/g)?.join("\n") ?? ""
151
151
 
152
- it.each(["--overlay-z", "--toast-z", "--modal-z", "--tooltip-z"])(
153
- "declares %s on :root so consumers can retune the band",
154
- (token) => {
155
- expect(rootBlock).toMatch(new RegExp(`${token}:\\s*\\d+;`))
156
- },
157
- )
152
+ /** The scale, bottom to top. */
153
+ const BANDS = ["--overlay-z", "--toast-z", "--modal-z", "--toast-raised-z", "--tooltip-z"]
154
+
155
+ it.each(BANDS)("declares %s on :root so consumers can retune the band", (token) => {
156
+ expect(rootBlock).toMatch(new RegExp(`${token}:\\s*\\d+;`))
157
+ })
158
158
 
159
159
  /** Every scope whose panel has to be ranked against another portal. Adding a
160
160
  * floating component means adding it here *and* to the rule in theme.css —
@@ -196,12 +196,16 @@ describe("theme.css overlay stacking", () => {
196
196
  expect(offenders).toEqual([])
197
197
  })
198
198
 
199
- it("keeps the toast band between page overlays and dialogs", () => {
199
+ /** Each band adds zag's `--layer-index` (nesting depth) to its base, so the
200
+ * gap to the next band is how deep it can nest before the two collide. */
201
+ it("keeps the bands in order, at least 50 apart", () => {
200
202
  const band = (token: string) => Number(rootBlock.match(new RegExp(`${token}:\\s*(\\d+);`))?.[1])
203
+ const tooClose = BANDS.slice(1)
204
+ .map((above, i) => ({ below: BANDS[i] ?? "", above }))
205
+ .map(({ below, above }) => ({ below, above, gap: band(above) - band(below) }))
206
+ .filter(({ gap }) => !(gap >= 50))
201
207
 
202
- expect(band("--overlay-z")).toBeLessThan(band("--toast-z"))
203
- expect(band("--toast-z")).toBeLessThan(band("--modal-z"))
204
- expect(band("--modal-z")).toBeLessThan(band("--tooltip-z"))
208
+ expect(tooClose).toEqual([])
205
209
  })
206
210
  })
207
211
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/overlay-container.tsx"],"names":[],"mappings":";;;;AAsCA,IAAM,uBAAA,GAA0B,cAAoD,IAAI,CAAA;AAUjF,IAAM,wBAAA,GAA2B,CAAC,EAAE,KAAA,EAAO,QAAA,EAAS,qBACzD,GAAA,CAAC,uBAAA,CAAwB,QAAA,EAAxB,EAAiC,KAAA,EAAe,QAAA,EAAS;AAMrD,IAAM,mBAAA,GAAsB,CACjC,QAAA,KAC8C;AAC9C,EAAA,MAAM,SAAA,GAAY,WAAW,uBAAuB,CAAA;AAGpD,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,MAAO,QAAA,GAAW,EAAE,OAAA,EAAS,QAAA,EAAS,GAAI,IAAA,EAAO,CAAC,QAAQ,CAAC,CAAA;AAC/E,EAAA,OAAO,OAAO,SAAA,IAAa,MAAA;AAC7B","file":"chunk-7P32XCEU.js","sourcesContent":["\"use client\"\n\nimport { createContext, type ReactNode, type RefObject, useContext, useMemo } from \"react\"\n\n/**\n * Shared \"where do nested overlays portal to\" context.\n *\n * Every floating surface in this kit portals to `document.body` by default so\n * it escapes clipping ancestors. That's right at page level, but it breaks down\n * inside a Modal/Drawer: the panel becomes a *sibling* of the dialog rather\n * than a descendant, so the only thing keeping it visible is a z-index tall\n * enough to clear `--modal-z` — and any number picked for that is wrong the\n * moment dialogs and overlays nest the other way around.\n *\n * So `Modal`/`Drawer` publish their own positioner here (see their\n * `Positioner` parts), and every overlay opened inside one portals *into* it.\n * Being a descendant of a surface that already outranks the page, the panel\n * stays above it structurally, whatever its own z-index band says — which is\n * also what frees `--toast-z` to sit between the overlay and modal bands\n * instead of above both (see `theme.css`).\n *\n * `Schedule` publishes its scroller the same way, for a different reason: its\n * popovers should scroll and clip with the grid, not float over the page.\n *\n * Modal and Drawer deliberately don't *consume* this: dialog-on-dialog order\n * is already handled by `--modal-z` plus zag's `--layer-index`, and nesting one\n * fixed, scroll-locking container inside another buys nothing.\n */\n/**\n * A ref, not the element. The element only exists after its first commit, so\n * publishing it as state costs every provider a second render of its whole\n * subtree just to hand the node down — and each portal a third, to move there.\n * Ark's `Portal` reads `container.current` itself when it first renders, so a\n * ref is enough: an overlay that mounts once the container is attached (a\n * lazily mounted panel, opened later) lands in the right place on its first\n * render, and one mounted in the same commit as the container is moved there\n * by `Portal`'s own mount effect, by which time the ref is set.\n */\nconst OverlayContainerContext = createContext<RefObject<HTMLElement | null> | null>(null)\n\nexport type OverlayContainerProviderProps = {\n /** A ref to the element nested overlays should portal into — a\n * Modal/Drawer positioner, a Schedule scroller. Still `null` (not yet\n * attached) reads as \"no container\", i.e. `document.body`. */\n value: RefObject<HTMLElement | null>\n children?: ReactNode\n}\n\nexport const OverlayContainerProvider = ({ value, children }: OverlayContainerProviderProps) => (\n <OverlayContainerContext.Provider value={value}>{children}</OverlayContainerContext.Provider>\n)\n\n/** Resolves an overlay's portal target, shaped for Ark's `<Portal container>`:\n * `override` (a per-instance `container` prop) wins; else the enclosing\n * provider's ref; else `undefined` — Ark falls back to `document.body`. */\nexport const useOverlayContainer = (\n override?: HTMLElement | null,\n): RefObject<HTMLElement | null> | undefined => {\n const inherited = useContext(OverlayContainerContext)\n // Ark's `Portal` keys its container effect on this object's identity, so\n // keep it stable while the element is.\n const own = useMemo(() => (override ? { current: override } : null), [override])\n return own ?? inherited ?? undefined\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/action-icon/action-icon.tsx"],"names":[],"mappings":"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","file":"chunk-BMEJBY6H.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { MouseEvent } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * ActionIcon — square, icon-only sibling of `Button`.\n *\n * Same (variant × color) model as `Button`:\n * - `variant` picks the shape (filled / light / outline / subtle / default)\n * - `color` picks the palette (brand / gray / red / …)\n * - Color is delivered via `data-color` + the slot vars in `colors.css`,\n * so dark mode shade-shifts happen at the CSS layer.\n *\n * What's specific to ActionIcon:\n * - Forced 1:1 aspect ratio.\n * - Own `radius` scale (incl. `full` for circular FABs / like-buttons).\n * - Wider size scale (xs..xl) than Button — toolbar density matters here.\n *\n * The accessible name MUST come from `aria-label` (or `aria-labelledby`); the\n * icon children are decoration.\n *\n * `asChild` renders the single child with ActionIcon's styling. Ark's\n * factory clones exactly one element, so `loading`'s spinner replaces\n * *that* element's own children (`withAsChildContent`, `lib/as-child.ts`)\n * rather than the element itself. The `onClick` guard (`preventWhileLoading`)\n * goes on the same clone, since `disabled` doesn't do anything on an\n * arbitrary `asChild` element (e.g. an `<a>`) — same reason the `opacity-50`\n * dimming and `pointer-events-none` blocking are keyed off `data-loading`\n * rather than `:disabled` (see `Button`'s note on this).\n */\nconst actionIconVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"aspect-square shrink-0 select-none\",\n \"font-medium uppercase tracking-wide\",\n \"no-underline\",\n \"rounded-action-icon border border-transparent\",\n \"transition-colors-radius\",\n focusStyles(),\n \"disabled:not-data-loading:pointer-events-none disabled:opacity-50\",\n \"data-disabled:pointer-events-none data-disabled:opacity-50\",\n \"not-data-loading:hover:cursor-pointer\",\n \"data-loading:cursor-progress data-loading:opacity-50\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n ],\n {\n variants: {\n variant: {\n filled: [\n \"bg-(--c-solid) text-(--c-on-solid)\",\n \"not-data-loading:hover:bg-(--c-solid-hover)\",\n ],\n light: [\n \"bg-(--c-soft) text-(--c-text) border-(--c-soft-hover)\",\n \"not-data-loading:hover:bg-(--c-soft-hover) not-data-loading:hover:border-(--c-solid)\",\n ],\n // Button's outline edge (the colour at 35%), so the two read as one\n // stroke weight side by side in a toolbar.\n outline: [\n \"bg-transparent text-(--c-text) border-(--c-solid)/35\",\n \"not-data-loading:hover:bg-(--c-soft)\",\n ],\n subtle: [\"bg-transparent text-(--c-text)\", \"not-data-loading:hover:bg-(--c-soft)\"],\n default: [\n \"bg-brand-950 text-white border-brand-800 not-data-loading:hover:bg-brand-800\",\n \"dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80\",\n ],\n },\n size: {\n xs: \"h-7 text-xs [&_svg]:size-5\",\n sm: \"h-8 text-sm [&_svg]:size-5.5\",\n md: \"h-9 text-md [&_svg]:size-6\",\n lg: \"h-10 text-lg [&_svg]:size-7\",\n xl: \"h-12 text-xl [&_svg]:size-8\",\n },\n radius: {\n xs: \"rounded-xs\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-lg\",\n xl: \"rounded-xl\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n)\n\nexport type ActionIconVariant = NonNullable<VariantProps<typeof actionIconVariants>[\"variant\"]>\nexport type ActionIconSize = NonNullable<VariantProps<typeof actionIconVariants>[\"size\"]>\nexport type ActionIconRadius = NonNullable<VariantProps<typeof actionIconVariants>[\"radius\"]>\n\nexport type ActionIconProps = Omit<HTMLArkProps<\"button\">, \"color\"> &\n VariantProps<typeof actionIconVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n /**\n * Replace the icon with a spinner, mark the element as busy, and suppress\n * pointer interactions. Mirrors `Button`'s `loading`.\n */\n loading?: boolean\n }\n\n/** Mirrors `Button`'s `preventWhileLoading` — see the note there. */\nconst preventWhileLoading = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n}\n\nexport const ActionIcon = ({\n className,\n variant,\n size,\n radius,\n color,\n loading = false,\n children,\n disabled,\n type,\n asChild,\n testId,\n onClick,\n ...rest\n}: ActionIconProps) => {\n const resolvedDisabled = disabled || loading\n const resolvedOnClick = loading ? preventWhileLoading : onClick\n\n return (\n <ark.button\n asChild={asChild}\n type={asChild ? type : (type ?? \"button\")}\n disabled={resolvedDisabled}\n data-color={color}\n data-variant={variant ?? \"default\"}\n className={cn(actionIconVariants({ variant, size, radius }), className)}\n onClick={resolvedOnClick}\n {...props({\n \"aria-busy\": loading,\n \"aria-disabled\": resolvedDisabled,\n \"data-loading\": loading,\n \"data-testid\": testId,\n })}\n {...rest}\n >\n {asChild && loading ? (\n withAsChildContent(children, () => <Spinner label={null} />, {\n onClick: preventWhileLoading,\n })\n ) : loading ? (\n <Spinner label={null} />\n ) : (\n children\n )}\n </ark.button>\n )\n}\n"]}