@42-central/ui-react 0.25.0 → 0.27.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.
- package/dist/{chunk-YZJUPYPO.js → chunk-2W7H43WL.js} +3 -3
- package/dist/{chunk-YZJUPYPO.js.map → chunk-2W7H43WL.js.map} +1 -1
- package/dist/{chunk-NLSJ6T7V.js → chunk-4D2V4JE4.js} +3 -3
- package/dist/{chunk-NLSJ6T7V.js.map → chunk-4D2V4JE4.js.map} +1 -1
- package/dist/{chunk-QZ4N5LYG.js → chunk-5H5YOPCF.js} +3 -3
- package/dist/{chunk-QZ4N5LYG.js.map → chunk-5H5YOPCF.js.map} +1 -1
- package/dist/{chunk-6II2DVYR.js → chunk-7KFUFAVP.js} +4 -4
- package/dist/{chunk-6II2DVYR.js.map → chunk-7KFUFAVP.js.map} +1 -1
- package/dist/{chunk-XUFCI262.js → chunk-7OGZT7U2.js} +12 -4
- package/dist/chunk-7OGZT7U2.js.map +1 -0
- package/dist/{chunk-PI7X5YFJ.js → chunk-BGDVUC3B.js} +5 -5
- package/dist/{chunk-PI7X5YFJ.js.map → chunk-BGDVUC3B.js.map} +1 -1
- package/dist/{chunk-7247WBTV.js → chunk-DJ72KP32.js} +3 -3
- package/dist/{chunk-7247WBTV.js.map → chunk-DJ72KP32.js.map} +1 -1
- package/dist/{chunk-FZSLSUSX.js → chunk-HCHGERDB.js} +3 -3
- package/dist/{chunk-FZSLSUSX.js.map → chunk-HCHGERDB.js.map} +1 -1
- package/dist/{chunk-H7WOMZXO.js → chunk-HWBFRDX7.js} +16 -8
- package/dist/chunk-HWBFRDX7.js.map +1 -0
- package/dist/{chunk-HQPU73WV.js → chunk-I4IJOLNA.js} +4 -4
- package/dist/{chunk-HQPU73WV.js.map → chunk-I4IJOLNA.js.map} +1 -1
- package/dist/{chunk-UDCCOUWR.js → chunk-IA6DCC3N.js} +6 -6
- package/dist/{chunk-UDCCOUWR.js.map → chunk-IA6DCC3N.js.map} +1 -1
- package/dist/{chunk-36NWC4GV.js → chunk-ISX3AM32.js} +3 -3
- package/dist/{chunk-36NWC4GV.js.map → chunk-ISX3AM32.js.map} +1 -1
- package/dist/{chunk-LMCUGYHT.js → chunk-L24N5EON.js} +6 -6
- package/dist/chunk-L24N5EON.js.map +1 -0
- package/dist/{chunk-HRNWWL3Y.js → chunk-L5GH7LLD.js} +61 -29
- package/dist/chunk-L5GH7LLD.js.map +1 -0
- package/dist/chunk-LJVIZNPE.js +9 -0
- package/dist/chunk-LJVIZNPE.js.map +1 -0
- package/dist/{chunk-AHKMN3YQ.js → chunk-MCRTAUSZ.js} +6 -6
- package/dist/chunk-MCRTAUSZ.js.map +1 -0
- package/dist/{chunk-LHUWOA2U.js → chunk-MNYY7UU2.js} +6 -6
- package/dist/{chunk-LHUWOA2U.js.map → chunk-MNYY7UU2.js.map} +1 -1
- package/dist/{chunk-7HZBD4YZ.js → chunk-NF2PBGD3.js} +36 -23
- package/dist/chunk-NF2PBGD3.js.map +1 -0
- package/dist/{chunk-54W6VAI3.js → chunk-NNPSBC7O.js} +5 -5
- package/dist/{chunk-54W6VAI3.js.map → chunk-NNPSBC7O.js.map} +1 -1
- package/dist/{chunk-MW42XVPD.js → chunk-PBSVX5DB.js} +15 -5
- package/dist/chunk-PBSVX5DB.js.map +1 -0
- package/dist/{chunk-2CL3FKEY.js → chunk-QEMXXQQO.js} +3 -3
- package/dist/{chunk-2CL3FKEY.js.map → chunk-QEMXXQQO.js.map} +1 -1
- package/dist/{chunk-6UIQJJNJ.js → chunk-QRNQQIQM.js} +5 -5
- package/dist/{chunk-6UIQJJNJ.js.map → chunk-QRNQQIQM.js.map} +1 -1
- package/dist/{chunk-N66NC6QK.js → chunk-RKCUXOU2.js} +4 -4
- package/dist/{chunk-N66NC6QK.js.map → chunk-RKCUXOU2.js.map} +1 -1
- package/dist/{chunk-N5M4PDBK.js → chunk-SBZJGFZ6.js} +3 -3
- package/dist/{chunk-N5M4PDBK.js.map → chunk-SBZJGFZ6.js.map} +1 -1
- package/dist/{chunk-7P32XCEU.js → chunk-SLUOF7XW.js} +2 -2
- package/dist/chunk-SLUOF7XW.js.map +1 -0
- package/dist/{chunk-SAXWCGWR.js → chunk-SOUDKESO.js} +14 -7
- package/dist/chunk-SOUDKESO.js.map +1 -0
- package/dist/{chunk-T44RW5DW.js → chunk-ULF5LOBS.js} +4 -4
- package/dist/{chunk-T44RW5DW.js.map → chunk-ULF5LOBS.js.map} +1 -1
- package/dist/components/ambient-background/index.js +9 -23
- package/dist/components/ambient-background/index.js.map +1 -1
- package/dist/components/ambient-background/starfield.d.ts.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +55 -10
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +1 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +299 -38
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/index.js +4 -4
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/index.js +10 -1
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/button-group/button-group.d.ts +10 -2
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/button-multi-select/index.js +2 -2
- package/dist/components/button-select/button-select-control.d.ts +4 -1
- package/dist/components/button-select/button-select-control.d.ts.map +1 -1
- package/dist/components/button-select/button-select.d.ts +4 -1
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +2 -2
- package/dist/components/calendar-heatmap/index.js +2 -2
- package/dist/components/camera/index.js +6 -6
- package/dist/components/code-block/chrome.js +5 -5
- package/dist/components/code-block/index.js +6 -6
- package/dist/components/combobox/index.js +4 -4
- package/dist/components/combobox-list/index.js +6 -6
- package/dist/components/data-table/data-table-features.d.ts +8 -0
- package/dist/components/data-table/data-table-features.d.ts.map +1 -1
- package/dist/components/data-table/data-table-group.d.ts +128 -0
- package/dist/components/data-table/data-table-group.d.ts.map +1 -0
- package/dist/components/data-table/data-table-grouping.d.ts +72 -0
- package/dist/components/data-table/data-table-grouping.d.ts.map +1 -0
- package/dist/components/data-table/data-table-icons.d.ts +4 -2
- package/dist/components/data-table/data-table-icons.d.ts.map +1 -1
- package/dist/components/data-table/data-table-meta.d.ts +9 -0
- package/dist/components/data-table/data-table-meta.d.ts.map +1 -1
- package/dist/components/data-table/data-table-pagination.d.ts +4 -1
- package/dist/components/data-table/data-table-pagination.d.ts.map +1 -1
- package/dist/components/data-table/data-table-schema.d.ts +4 -0
- package/dist/components/data-table/data-table-schema.d.ts.map +1 -1
- package/dist/components/data-table/data-table-stack.d.ts +16 -3
- package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
- package/dist/components/data-table/data-table-toolbar.d.ts +33 -2
- package/dist/components/data-table/data-table-toolbar.d.ts.map +1 -1
- package/dist/components/data-table/data-table-translations.d.ts +35 -0
- package/dist/components/data-table/data-table-translations.d.ts.map +1 -1
- package/dist/components/data-table/data-table.d.ts +55 -3
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/index.d.ts +3 -1
- package/dist/components/data-table/index.d.ts.map +1 -1
- package/dist/components/data-table/index.js +878 -230
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/index.js +8 -8
- package/dist/components/drawer/index.js +4 -4
- package/dist/components/geodesic/a11y.d.ts +3 -3
- package/dist/components/geodesic/a11y.d.ts.map +1 -1
- package/dist/components/geodesic/badge-frame.d.ts +13 -1
- package/dist/components/geodesic/badge-frame.d.ts.map +1 -1
- package/dist/components/geodesic/exam-badge.d.ts +4 -1
- package/dist/components/geodesic/exam-badge.d.ts.map +1 -1
- package/dist/components/geodesic/geometry.d.ts +14 -9
- package/dist/components/geodesic/geometry.d.ts.map +1 -1
- package/dist/components/geodesic/index.js +62 -23
- package/dist/components/geodesic/index.js.map +1 -1
- package/dist/components/geodesic/status.d.ts +8 -6
- package/dist/components/geodesic/status.d.ts.map +1 -1
- package/dist/components/geodesic/styles.css +15 -2
- package/dist/components/hover-card/index.js +3 -3
- package/dist/components/indicator/index.js +23 -8
- package/dist/components/indicator/index.js.map +1 -1
- package/dist/components/indicator/indicator.d.ts +15 -6
- package/dist/components/indicator/indicator.d.ts.map +1 -1
- package/dist/components/kbd/index.js +3 -3
- package/dist/components/lightbox/index.js +4 -4
- package/dist/components/menu/index.js +4 -4
- package/dist/components/modal/index.js +4 -4
- package/dist/components/multi-combobox-list/index.js +6 -6
- package/dist/components/multi-select/index.js +4 -4
- package/dist/components/nav-link/index.js +5 -1
- package/dist/components/nav-link/nav-link.d.ts.map +1 -1
- package/dist/components/nav-link/tanstack.js +5 -1
- package/dist/components/nav-link/tanstack.js.map +1 -1
- package/dist/components/notification/create-notifier.d.ts.map +1 -1
- package/dist/components/notification/index.js +15 -3
- package/dist/components/notification/index.js.map +1 -1
- package/dist/components/notification/types.d.ts +5 -0
- package/dist/components/notification/types.d.ts.map +1 -1
- package/dist/components/number-input/index.js +4 -4
- package/dist/components/overlays/index.js +5 -5
- package/dist/components/photo-capture/index.js +6 -6
- package/dist/components/popover/index.js +3 -3
- package/dist/components/schedule/index.js +4 -4
- package/dist/components/segment-group/index.js +1 -1
- package/dist/components/segment-group/segment-group.d.ts +6 -1
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +5 -5
- package/dist/components/spotlight/index.js +8 -8
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/tabs/tabs-data.d.ts +4 -1
- package/dist/components/tabs/tabs-data.d.ts.map +1 -1
- package/dist/components/tabs/tabs.d.ts +4 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +3 -3
- package/dist/components/time-input/index.js +6 -6
- package/dist/components/tooltip/index.js +2 -2
- package/dist/components/tree-multi-select/index.js +4 -4
- package/dist/components/tree-select/index.js +4 -4
- package/dist/index.js +2 -2
- package/dist/lib/overlay-container.d.ts.map +1 -1
- package/dist/lib/overlay-layer.d.ts +10 -3
- package/dist/lib/overlay-layer.d.ts.map +1 -1
- package/dist/lib/sidebar-rail.d.ts +21 -0
- package/dist/lib/sidebar-rail.d.ts.map +1 -0
- package/dist/theme.css +21 -18
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +6 -0
- package/src/components/ambient-background/starfield.tsx +14 -41
- package/src/components/app-shell/app-shell.test.tsx +430 -5
- package/src/components/app-shell/app-shell.tsx +484 -24
- package/src/components/app-shell/index.ts +2 -0
- package/src/components/avatar/avatar.test.tsx +12 -0
- package/src/components/avatar/avatar.tsx +9 -0
- package/src/components/button-group/button-group.test.tsx +24 -0
- package/src/components/button-group/button-group.tsx +21 -4
- package/src/components/button-multi-select/button-multi-select.test.tsx +15 -0
- package/src/components/button-select/button-select-control.tsx +5 -0
- package/src/components/button-select/button-select.test.tsx +25 -0
- package/src/components/button-select/button-select.tsx +13 -2
- package/src/components/data-table/data-table-features.ts +11 -0
- package/src/components/data-table/data-table-group.test.tsx +1007 -0
- package/src/components/data-table/data-table-group.tsx +474 -0
- package/src/components/data-table/data-table-grouping.ts +160 -0
- package/src/components/data-table/data-table-icons.tsx +8 -1
- package/src/components/data-table/data-table-meta.ts +9 -0
- package/src/components/data-table/data-table-pagination.tsx +5 -1
- package/src/components/data-table/data-table-stack.tsx +165 -43
- package/src/components/data-table/data-table-toolbar.tsx +110 -2
- package/src/components/data-table/data-table-translations.ts +44 -0
- package/src/components/data-table/data-table.tsx +420 -150
- package/src/components/data-table/index.ts +4 -0
- package/src/components/drawer/drawer.tsx +1 -1
- package/src/components/geodesic/badge-frame.tsx +67 -13
- package/src/components/geodesic/exam-badge.tsx +8 -4
- package/src/components/geodesic/geometry.ts +8 -6
- package/src/components/geodesic/status.test.ts +11 -2
- package/src/components/geodesic/status.ts +11 -7
- package/src/components/geodesic/styles.css +15 -2
- package/src/components/indicator/indicator.test.tsx +45 -0
- package/src/components/indicator/indicator.tsx +40 -13
- package/src/components/modal/modal.tsx +1 -1
- package/src/components/nav-link/nav-link.test.tsx +121 -1
- package/src/components/nav-link/nav-link.tsx +78 -29
- package/src/components/notification/create-notifier.tsx +18 -2
- package/src/components/notification/notify-in-modal.test.tsx +128 -0
- package/src/components/notification/types.ts +5 -0
- package/src/components/segment-group/segment-group.test.tsx +22 -0
- package/src/components/segment-group/segment-group.tsx +35 -19
- package/src/components/tabs/tabs-data.tsx +5 -1
- package/src/components/tabs/tabs.test.tsx +28 -0
- package/src/components/tabs/tabs.tsx +14 -4
- package/src/lib/overlay-container.tsx +2 -1
- package/src/lib/overlay-layer.test.tsx +63 -1
- package/src/lib/overlay-layer.tsx +29 -6
- package/src/lib/sidebar-rail.ts +24 -0
- package/src/theme.css +21 -18
- package/src/theme.test.ts +14 -11
- package/dist/chunk-7HZBD4YZ.js.map +0 -1
- package/dist/chunk-7P32XCEU.js.map +0 -1
- package/dist/chunk-AHKMN3YQ.js.map +0 -1
- package/dist/chunk-H7WOMZXO.js.map +0 -1
- package/dist/chunk-HRNWWL3Y.js.map +0 -1
- package/dist/chunk-LMCUGYHT.js.map +0 -1
- package/dist/chunk-MW42XVPD.js.map +0 -1
- package/dist/chunk-SAXWCGWR.js.map +0 -1
- package/dist/chunk-XUFCI262.js.map +0 -1
|
@@ -71,6 +71,9 @@ export type TabsProps<Data extends TabsData = TabsData> = Omit<
|
|
|
71
71
|
/** Palette for the underline bar + active-trigger text. Scoped to the
|
|
72
72
|
* strip (it lands on the `List`), so it never tints the panel content. */
|
|
73
73
|
color?: Color
|
|
74
|
+
/** Give every tab an even share of the strip, like a tab bar. Lands on the
|
|
75
|
+
* `List`. */
|
|
76
|
+
grow?: boolean
|
|
74
77
|
/** Fires with the selected value (narrowed to the data value union). */
|
|
75
78
|
onChange?: (value: TabsValue<Data>) => void
|
|
76
79
|
}
|
|
@@ -80,6 +83,7 @@ const TabsComponent = <const Data extends TabsData>({
|
|
|
80
83
|
variant,
|
|
81
84
|
size,
|
|
82
85
|
color,
|
|
86
|
+
grow,
|
|
83
87
|
value,
|
|
84
88
|
defaultValue,
|
|
85
89
|
onChange,
|
|
@@ -92,7 +96,7 @@ const TabsComponent = <const Data extends TabsData>({
|
|
|
92
96
|
onValueChange={onChange ? (d) => onChange(d.value as TabsValue<Data>) : undefined}
|
|
93
97
|
{...root}
|
|
94
98
|
>
|
|
95
|
-
<List variant={variant} size={size} color={color}>
|
|
99
|
+
<List variant={variant} size={size} color={color} grow={grow}>
|
|
96
100
|
<Indicator />
|
|
97
101
|
{data.map((item) => (
|
|
98
102
|
<Trigger
|
|
@@ -341,4 +341,32 @@ describe("Tabs", () => {
|
|
|
341
341
|
const indicator = container.querySelector('[data-part="indicator"]') as HTMLElement
|
|
342
342
|
expect(indicator.className).not.toMatch(/(^|\s)z-0(\s|$)/)
|
|
343
343
|
})
|
|
344
|
+
|
|
345
|
+
it("gives every trigger an even share under `List`'s `grow`", () => {
|
|
346
|
+
render(
|
|
347
|
+
<Root defaultValue="a">
|
|
348
|
+
<List grow>
|
|
349
|
+
<Trigger value="a">A</Trigger>
|
|
350
|
+
<Trigger value="b">B</Trigger>
|
|
351
|
+
</List>
|
|
352
|
+
</Root>,
|
|
353
|
+
)
|
|
354
|
+
for (const tab of screen.getAllByRole("tab")) {
|
|
355
|
+
expect(tab.className).toMatch(/(^|\s)flex-1(\s|$)/)
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
|
|
359
|
+
it("passes `grow` through the data-driven Tabs to its List", () => {
|
|
360
|
+
render(<Tabs data={ITEMS} grow />)
|
|
361
|
+
for (const tab of screen.getAllByRole("tab")) {
|
|
362
|
+
expect(tab.className).toMatch(/(^|\s)flex-1(\s|$)/)
|
|
363
|
+
}
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
it("keeps the triggers hugging their labels without `grow`", () => {
|
|
367
|
+
render(<Tabs data={ITEMS} />)
|
|
368
|
+
for (const tab of screen.getAllByRole("tab")) {
|
|
369
|
+
expect(tab.className).not.toMatch(/(^|\s)flex-1(\s|$)/)
|
|
370
|
+
}
|
|
371
|
+
})
|
|
344
372
|
})
|
|
@@ -171,6 +171,10 @@ const tabsTrigger = cva(
|
|
|
171
171
|
true: "data-selected:text-(--c-text)",
|
|
172
172
|
false: "data-selected:text-brand-950 dark:data-selected:text-white",
|
|
173
173
|
},
|
|
174
|
+
// An even share of the list per trigger, like a tab bar. Read from
|
|
175
|
+
// `TabsStyleContext` (set by `List`'s `grow`), not a child selector on
|
|
176
|
+
// the list, so a custom element in the list never grows by accident.
|
|
177
|
+
grow: { true: "flex-1" },
|
|
174
178
|
size: {
|
|
175
179
|
xs: "px-2 py-0.5 text-xs",
|
|
176
180
|
sm: "px-2.5 py-1 text-sm",
|
|
@@ -307,6 +311,7 @@ export type TabsVariant = NonNullable<VariantProps<typeof tabsList>["variant"]>
|
|
|
307
311
|
type TabsStyle = {
|
|
308
312
|
variant: TabsVariant
|
|
309
313
|
size: Size
|
|
314
|
+
grow: boolean
|
|
310
315
|
color: Color | undefined
|
|
311
316
|
colors: Readonly<Record<string, Color>>
|
|
312
317
|
setTriggerColor: (value: string, color: Color | undefined) => void
|
|
@@ -315,6 +320,7 @@ type TabsStyle = {
|
|
|
315
320
|
const TabsStyleContext = createContext<TabsStyle>({
|
|
316
321
|
variant: "underline",
|
|
317
322
|
size: "md",
|
|
323
|
+
grow: false,
|
|
318
324
|
color: undefined,
|
|
319
325
|
colors: {},
|
|
320
326
|
setTriggerColor: () => {},
|
|
@@ -356,11 +362,15 @@ export type TabsListProps = Omit<Ark.ListProps, "color"> &
|
|
|
356
362
|
* on the list, so the `--c-*` slots reach the triggers and the indicator
|
|
357
363
|
* without reaching the `Content` panels. */
|
|
358
364
|
color?: Color
|
|
365
|
+
/** Give every trigger an even share of the list's width (its height when
|
|
366
|
+
* vertical), like a tab bar. Without it the triggers hug their labels. */
|
|
367
|
+
grow?: boolean
|
|
359
368
|
}
|
|
360
369
|
|
|
361
370
|
const List = ({
|
|
362
371
|
variant = "underline",
|
|
363
372
|
size = "md",
|
|
373
|
+
grow = false,
|
|
364
374
|
color,
|
|
365
375
|
className,
|
|
366
376
|
testId,
|
|
@@ -375,8 +385,8 @@ const List = ({
|
|
|
375
385
|
})
|
|
376
386
|
}, [])
|
|
377
387
|
const style = useMemo(
|
|
378
|
-
() => ({ variant, size, color, colors, setTriggerColor }),
|
|
379
|
-
[variant, size, color, colors, setTriggerColor],
|
|
388
|
+
() => ({ variant, size, grow, color, colors, setTriggerColor }),
|
|
389
|
+
[variant, size, grow, color, colors, setTriggerColor],
|
|
380
390
|
)
|
|
381
391
|
return (
|
|
382
392
|
<TabsStyleContext.Provider value={style}>
|
|
@@ -401,7 +411,7 @@ export type TabsTriggerProps = Omit<Ark.TriggerProps, "color"> &
|
|
|
401
411
|
}
|
|
402
412
|
|
|
403
413
|
const Trigger = ({ color, className, testId, ...rest }: TabsTriggerProps) => {
|
|
404
|
-
const { variant, size, color: listColor, setTriggerColor } = useContext(TabsStyleContext)
|
|
414
|
+
const { variant, size, grow, color: listColor, setTriggerColor } = useContext(TabsStyleContext)
|
|
405
415
|
const { value } = rest
|
|
406
416
|
useEffect(() => {
|
|
407
417
|
setTriggerColor(value, color)
|
|
@@ -410,7 +420,7 @@ const Trigger = ({ color, className, testId, ...rest }: TabsTriggerProps) => {
|
|
|
410
420
|
return (
|
|
411
421
|
<Ark.Trigger
|
|
412
422
|
className={cn(
|
|
413
|
-
tabsTrigger({ variant, size, colored: (color ?? listColor) !== undefined }),
|
|
423
|
+
tabsTrigger({ variant, size, grow, colored: (color ?? listColor) !== undefined }),
|
|
414
424
|
className,
|
|
415
425
|
)}
|
|
416
426
|
data-color={color}
|
|
@@ -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
|
|
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
|
-
|
|
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
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from "react"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Whether the content is sitting in a sidebar collapsed to an icon rail —
|
|
7
|
+
* provided by `AppShell.Sidebar collapse="icons"`, read by anything that has to
|
|
8
|
+
* change *behaviour* there (not just appearance): `NavLink` turns its label
|
|
9
|
+
* into a tooltip on the icon.
|
|
10
|
+
*
|
|
11
|
+
* Kept in `lib` rather than exported from AppShell so a nav component can
|
|
12
|
+
* react to a rail without depending on the shell that draws it. Appearance
|
|
13
|
+
* alone needs no JS: the rail carries `data-sidebar-rail`, and the
|
|
14
|
+
* `sidebar-rail:` variant (theme.css) styles anything inside it.
|
|
15
|
+
*
|
|
16
|
+
* `null` outside a rail-capable sidebar; `{ active: false }` inside one that is
|
|
17
|
+
* expanded (or peeking, labels visible); `{ active: true }` while it shows
|
|
18
|
+
* icons only.
|
|
19
|
+
*/
|
|
20
|
+
export type SidebarRailState = { active: boolean }
|
|
21
|
+
|
|
22
|
+
export const SidebarRailContext = createContext<SidebarRailState | null>(null)
|
|
23
|
+
|
|
24
|
+
export const useSidebarRail = (): SidebarRailState | null => useContext(SidebarRailContext)
|
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
|
|
1299
|
-
--toast-z
|
|
1300
|
-
--modal-z
|
|
1301
|
-
--
|
|
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
|
-
--
|
|
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,
|
|
1365
|
+
z-index: var(--tooltip-z, 250);
|
|
1358
1366
|
}
|
|
1359
1367
|
|
|
1360
1368
|
/* ==========================================
|
|
@@ -1434,10 +1442,6 @@ body {
|
|
|
1434
1442
|
--animate-ambient-star-twinkle: ambient-star-twinkle 8s ease-in-out infinite;
|
|
1435
1443
|
/* The dust dims the same way, deeper and slower, one group per layer. */
|
|
1436
1444
|
--animate-ambient-star-dim: ambient-star-dim 17s ease-in-out infinite;
|
|
1437
|
-
/* The nebula's clouds swing slowly away and back, each by its own drift
|
|
1438
|
-
(`--drift-*`, set per cloud): moved, swollen a little and thinned out at
|
|
1439
|
-
the far end, eased at both. */
|
|
1440
|
-
--animate-ambient-nebula-drift: ambient-nebula-drift 90s ease-in-out infinite alternate;
|
|
1441
1445
|
/* A meteor's whole cycle is mostly waiting: it streaks across in the first
|
|
1442
1446
|
2% (about a second of its long cycle), its tail growing behind the head
|
|
1443
1447
|
as it fades in and burning out before it stops, then nothing until the
|
|
@@ -1465,13 +1469,6 @@ body {
|
|
|
1465
1469
|
}
|
|
1466
1470
|
}
|
|
1467
1471
|
|
|
1468
|
-
@keyframes ambient-nebula-drift {
|
|
1469
|
-
to {
|
|
1470
|
-
transform: translate3d(var(--drift-x), var(--drift-y), 0) scale(var(--drift-scale));
|
|
1471
|
-
opacity: var(--drift-fade);
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
1472
|
@keyframes ambient-meteor {
|
|
1476
1473
|
0% {
|
|
1477
1474
|
opacity: 0;
|
|
@@ -1489,7 +1486,7 @@ body {
|
|
|
1489
1486
|
|
|
1490
1487
|
/* `motion-safe:` reads only the OS setting; apps that let people choose
|
|
1491
1488
|
in-app set `data-motion="reduced"` on `<html>`, and the sky stills for that
|
|
1492
|
-
too: no
|
|
1489
|
+
too: no dimming, no twinkle, no meteors. */
|
|
1493
1490
|
:where(:root[data-motion="reduced"]) {
|
|
1494
1491
|
.ambient-starfield,
|
|
1495
1492
|
.ambient-starfield * {
|
|
@@ -1514,5 +1511,11 @@ body {
|
|
|
1514
1511
|
> &
|
|
1515
1512
|
);
|
|
1516
1513
|
|
|
1514
|
+
/* Inside an `AppShell.Sidebar collapse="icons"` while it shows icons only:
|
|
1515
|
+
hide what doesn't fit a 68px rail (`sidebar-rail:hidden` on a logo's
|
|
1516
|
+
wordmark, a footer's user name). Matches the rail itself too. NavLink uses it
|
|
1517
|
+
for its label, endSlot, chevron. */
|
|
1518
|
+
@custom-variant sidebar-rail (&:where([data-sidebar-rail], [data-sidebar-rail] *));
|
|
1519
|
+
|
|
1517
1520
|
/* Variants to use with slider's values */
|
|
1518
1521
|
@custom-variant state-under-or-at (&:is([data-state="under-value"], [data-state="at-value"]));
|
package/src/theme.test.ts
CHANGED
|
@@ -20,7 +20,6 @@ const EXEMPT_FROM_GLOBAL_OVERRIDE = new Set([
|
|
|
20
20
|
"rating-pop",
|
|
21
21
|
"ambient-star-twinkle",
|
|
22
22
|
"ambient-star-dim",
|
|
23
|
-
"ambient-nebula-drift",
|
|
24
23
|
"ambient-meteor",
|
|
25
24
|
])
|
|
26
25
|
|
|
@@ -150,12 +149,12 @@ describe("exit animations are always state-driven", () => {
|
|
|
150
149
|
describe("theme.css overlay stacking", () => {
|
|
151
150
|
const rootBlock = themeCss.match(/:root \{[\s\S]*?\n\}/g)?.join("\n") ?? ""
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
)
|
|
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
|
+
})
|
|
159
158
|
|
|
160
159
|
/** Every scope whose panel has to be ranked against another portal. Adding a
|
|
161
160
|
* floating component means adding it here *and* to the rule in theme.css —
|
|
@@ -197,12 +196,16 @@ describe("theme.css overlay stacking", () => {
|
|
|
197
196
|
expect(offenders).toEqual([])
|
|
198
197
|
})
|
|
199
198
|
|
|
200
|
-
|
|
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", () => {
|
|
201
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))
|
|
202
207
|
|
|
203
|
-
expect(
|
|
204
|
-
expect(band("--toast-z")).toBeLessThan(band("--modal-z"))
|
|
205
|
-
expect(band("--modal-z")).toBeLessThan(band("--tooltip-z"))
|
|
208
|
+
expect(tooClose).toEqual([])
|
|
206
209
|
})
|
|
207
210
|
})
|
|
208
211
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/segment-group/segment-group.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;AAsEA,IAAM,OAAA,GAAU,GAAA;AAAA,EACd;AAAA,IACE,aAAA;AAAA,IACA,wEAAA;AAAA,IACA,kBAAA,CAAmB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKnB,8FAAA;AAAA,IACA,mBAAA;AAAA,IACA,2DAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,MAAA,EAAQ,0CAAA;AAAA,QACR,KAAA,EAAO,sCAAA;AAAA,QACP,OAAA,EAAS,sCAAA;AAAA,QACT,MAAA,EAAQ,sCAAA;AAAA,QACR,OAAA,EAAS;AAAA,OACX;AAAA,MACA,IAAA,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI,iDAAA;AAAA,QACJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI;AAAA;AACN,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,SAAA,EAAW,MAAM,IAAA;AAAK;AAEtD,CAAA;AAWA,IAAM,cAAc,GAAA,CAAI;AAAA,EACtB,0BAAA;AAAA,EACA,oFAAA;AAAA,EACA,yCAAA;AAAA,EACA,+CAAA;AAAA;AAAA;AAAA;AAAA,EAIA,mGAAA;AAAA;AAAA;AAAA,EAGA,+NAAA;AAAA;AAAA,EAEA,qBAAA;AAAA,EACA;AACF,CAAC,CAAA;AAWD,IAAM,YAAA,GAAe,GAAA;AAAA,EACnB;AAAA,IACE,KAAA;AAAA;AAAA;AAAA,IAGA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,E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AU,IAAA,CAAK,QAAA;AAAA,gBACf,eAAa,IAAA,CAAK,MAAA;AAAA,gBAClB,SAAA,EAAW,EAAA,CAAG,WAAA,EAAY,EAAG,YAAY,IAAI,CAAA;AAAA,gBAE7C,QAAA,EAAA;AAAA,kCAAA,GAAA;AAAA,oBAACA,cAAA,CAAI,QAAA;AAAA,oBAAJ;AAAA,sBACC,cAAY,IAAA,CAAK,KAAA;AAAA,sBACjB,SAAA,EAAW,GAAG,OAAA,CAAQ,EAAE,MAAM,OAAA,EAAS,CAAA,EAAG,UAAA,EAAY,QAAQ,CAAA;AAAA,sBAI7D,QAAA,EAAA,UAAA,uBACEA,cAAA,CAAI,WAAA,EAAJ,EACE,QAAA,EAAA,CAAC,GAAA,KACA,WAAW,IAAA,EAA4C;AAAA,wBACrD,SAAS,GAAA,CAAI,OAAA;AAAA,wBACb,UAAU,GAAA,CAAI;AAAA,uBACf,CAAA,EAEL,CAAA,GAEA,IAAA,CAAK;AAAA;AAAA,mBAET;AAAA,kCACA,GAAA,CAACA,cAAA,CAAI,WAAA,EAAJ,EAAgB,CAAA;AAAA,kCACjB,GAAA,CAACA,cAAA,CAAI,eAAA,EAAJ,EAAoB;AAAA;AAAA,eAAA;AAAA,cA1BhB,IAAA,CAAK;AAAA,aA4Bb;AAAA;AAAA,SAAA;AAAA,QA/EI;AAAA;AAgFP;AAAA,GACF;AAEJ","file":"chunk-7HZBD4YZ.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { SegmentGroup as Ark } from \"@ark-ui/react/segment-group\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { FocusEvent, ReactNode, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { useDirectionCheck } from \"../../lib/intl\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport { type FieldProps, FieldShell, fieldA11yProps } from \"../field/field\"\n\n/**\n * SegmentGroup — a segmented single-choice control on Ark UI's SegmentGroup\n * machine (the radio-group model under the hood). It renders a row (or column)\n * of mutually exclusive segments with a sliding pill that animates to the\n * selected item. Use it as a compact, always-visible alternative to a `Select`\n * when the option set is small (2–5 items): view toggles, filters, billing\n * cadence, and the like.\n *\n * - Value is a single `string | null`; `onChange` hands it to you directly,\n * matching the kit's value-based `FormControlProps` contract.\n * - `data` accepts bare strings (`value === label`) or\n * `{ value, label?, disabled?, color?, payload? }` objects, mixed freely.\n * The component is generic over `data` (a `const` type parameter), so\n * `value` / `onChange` narrow to the literal value union and an item's\n * `payload` flows—typed—into `renderItem` (the same contract as `Select`).\n * - Label / description / error / required come from the built-in `Field`\n * wrapper, so a `SegmentGroup` is accessible and complete on its own.\n * - `name` renders a hidden radio input per item, so the selected value rides\n * a native `<form>` submission.\n *\n * `variant` mirrors the `Button` family (`filled` / `light` / `outline` /\n * `subtle` / `default`): the tray, the sliding pill, and the checked label all\n * adopt the variant's treatment off the shared `--c-*` slots. Palette rides on\n * `data-color`, so every kit color tints for free, `default` included — its pill\n * falls back to solid black/white with no color set, because `:root` defines\n * `--c-solid`/`--c-on-solid` as black/white (white/brand-950 under dark). A\n * per-item `color` overrides the group palette for whichever segment is\n * selected: it re-stamps `data-color` on that item and on the pill, so both\n * the fill and the checked label resolve from the same block.\n *\n * The moving pill is the Ark `Indicator`: Ark positions it absolutely via the\n * CSS vars `--left` / `--top` / `--width` / `--height` (the selected segment's\n * measured rect), so it sits *behind* the labels (`z-0`). Ark only re-measures\n * that rect on mount and on value change — not when `orientation` flips — so we\n * remount the root with `key={orientation}` to force a fresh measure on the new\n * axis. The value is held in `useUncontrolled` so the selection survives that\n * remount.\n */\n\n/**\n * Per-segment label: size sets the padding / text, `variant` sets the *checked*\n * text color so it reads against that variant's pill. The unchecked color is a\n * neutral gray applied at the call site.\n *\n * The checked label must come from the same source as the pill under it.\n * `default` and `filled` both paint `bg-(--c-solid)`, so both take\n * `--c-on-solid` — which resolves per-item, since each `ItemText` carries its\n * own `data-color`. Pairing a hard-coded neutral foreground with a `--c-solid`\n * fill is what broke `default` at any group `color` (#140): the pill moved with\n * the palette and the label stayed put, reaching 3.27:1 on brand. There is\n * deliberately no hover shift on the checked label — `Button`'s `filled` moves\n * only the background and keeps `--c-on-solid`, and no `--c-on-solid-hover`\n * slot exists in `colors.css`.\n */\nconst segItem = cva(\n [\n \"font-medium\",\n \"cursor-pointer rounded-input text-center whitespace-nowrap select-none\",\n TEXT_COLOR_CLASSES.secondary,\n // Only unchecked segments get the hover lift, as in Tabs. An\n // unscoped `hover:` ties on specificity with the checked foreground and\n // won on source order in dark theme, washing the checked label to\n // near-white over a colored pill.\n \"not-data-[state=checked]:hover:text-brand-950 dark:not-data-[state=checked]:hover:text-white\",\n \"transition-colors\",\n \"data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n \"group-data-invalid:text-red-900 dark:group-data-invalid:text-red-500\",\n ],\n {\n variants: {\n variant: {\n filled: \"data-[state=checked]:text-(--c-on-solid)\",\n light: \"data-[state=checked]:text-(--c-text)\",\n outline: \"data-[state=checked]:text-(--c-text)\",\n subtle: \"data-[state=checked]:text-(--c-text)\",\n default: \"data-[state=checked]:text-(--c-on-solid)\",\n },\n size: {\n // No vertical padding of its own — the tray's `min-h` (below) sets the\n // box height and this item stretches to fill it (the tray's default\n // `align-items: stretch` propagates all the way down), so the label\n // just needs to center itself inside that taller box. This matches an\n // `Input` / `NumberInput`'s exact box height at the same size.\n xs: \"flex items-center justify-center px-1 text-xs\",\n sm: \"flex items-center justify-center px-1.5 text-sm\",\n md: \"flex items-center justify-center px-2 text-md\",\n lg: \"flex items-center justify-center px-3 text-lg\",\n xl: \"flex items-center justify-center px-4 text-xl\",\n },\n },\n defaultVariants: { variant: \"default\", size: \"md\" },\n },\n)\n\n/**\n * Per-segment wrapper. Beyond positioning the label above the pill (`z-1`), it\n * draws a hairline separator in the gap to its leading edge (a `::before`) so\n * inactive neighbours read as divided. That rule fades out next to the active\n * pill — on the checked segment and the one right after it — and is suppressed\n * before the first segment (the indicator is child 1, so the first segment is\n * `:nth-child(2)`). It flips from a vertical rule to a horizontal one when the\n * group is laid out vertically.\n */\nconst segItemWrap = cva([\n \"relative z-1 inline-flex\",\n \"before:absolute before:rounded-full before:bg-brand-900/30 dark:before:bg-white/35\",\n \"group-data-invalid:before:bg-red-500/30\",\n \"before:transition-opacity before:duration-200\",\n // Horizontal: a vertical rule centered on the leading edge, sitting in the gap. Logical\n // (`start`, `-ms-[0.5px]` to center the 1px rule), so under `dir=\"rtl\"` the rule still lands\n // between a segment and the one before it instead of on the far side.\n \"before:top-1/2 before:start-0 before:-ms-[0.5px] before:h-1/2 before:w-px before:-translate-y-1/2\",\n // Vertical: a horizontal rule centered on the top edge instead (`start-1/4` + `w-1/2` is\n // centered in either direction).\n \"in-data-[orientation=vertical]:before:top-0 in-data-[orientation=vertical]:before:start-1/4 in-data-[orientation=vertical]:before:ms-0 in-data-[orientation=vertical]:before:h-px in-data-[orientation=vertical]:before:w-1/2\",\n // No separator before the first segment, or flanking the active pill.\n \"nth-2:before:hidden\",\n \"data-[state=checked]:before:opacity-0 data-[state=checked]:[&+*]:before:opacity-0\",\n])\n\n/**\n * The sliding pill, mirroring each `Button` surface. Its slide + color transition\n * is driven by Ark (see the `--transition-*` overrides on the element); `default`\n * follows `--c-solid` like every other variant, which falls back to solid\n * black/white with no `data-color` set. Filled/soft-fill pills (`filled`, `light`,\n * `default`) use a tighter `rounded-xxs` than the tray's own `rounded-input`, for a\n * nested-corner look inside the tray's padding; bordered/transparent pills\n * (`outline`, `subtle`) keep `rounded-input`.\n */\nconst segIndicator = cva(\n [\n \"z-0\",\n // The slide's duration, read by the inline `transition-duration` (see the\n // pill below); reduced motion zeroes it, so the pill jumps instead.\n \"[--indicator-duration:var(--duration-normal)] motion-reduce:[--indicator-duration:0s]\",\n ],\n {\n variants: {\n variant: {\n filled: \"bg-(--c-solid) rounded-xxs\",\n light: \"bg-(--c-soft) border border-(--c-soft-hover) rounded-xxs\",\n outline: \"bg-transparent border border-(--c-solid) rounded-input\",\n subtle: \"bg-(--c-soft-hover) rounded-input\",\n default: \"bg-(--c-solid) rounded-xxs\",\n },\n },\n defaultVariants: { variant: \"default\" },\n },\n)\n\n/**\n * The tray. Mirrors the `Button` variants: `filled` is a borderless neutral fill\n * so the colored pill pops (the kit's quiet `bg-black/3 dark:bg-white/4`; light\n * mode darkens because a bare `bg-white/4` vanishes on a near-white page), `light` / `default` frame the pill with the same\n * translucent surface as `Input`'s own `default` shell (`bg-white/4` + the\n * hairline `border-brand-900/20 dark:border-white/15`) rather than an opaque\n * gray step, so the tray reads correctly on any host background, `subtle` /\n * `outline` are chromeless.\n */\nconst segTray = cva(\n [\n \"relative inline-flex rounded-input border p-0.5 transition-colors max-w-fit group\",\n \"data-[orientation=vertical]:flex-col\",\n \"data-disabled:cursor-not-allowed data-disabled:opacity-60\",\n // Focus halo + accent border, driven by the active palette's `--c-solid`. Keyed\n // off Zag's `data-focus-visible` (set only when the focus came from the keyboard,\n // never a mouse click) via `:has()`, so the ring stays off when you click a segment.\n //\n // Deliberately NOT `focusStyles`. This is the *shell* idiom, not the ring\n // idiom: an accent border plus a soft `/15` halo on a wrapper whose focus\n // lives on a descendant, with a red invalid twin on the identical selector.\n // That is `input.tsx`'s `shellChrome`, not `Button`'s ring — folding it into\n // `focusStyles` would make that helper grow an alpha, a border half and a\n // concept of invalid, for one call site. The two shells are worth sharing\n // with each other instead; see the follow-up issue.\n \"has-data-focus-visible:border-(--c-solid) has-data-focus-visible:ring-2 has-data-focus-visible:ring-(--c-solid)/15\",\n // Invalid wins over the palette: red border + red halo.\n \"data-invalid:border-red-500 data-invalid:has-data-focus-visible:border-red-500 data-invalid:has-data-focus-visible:ring-red-500/15\",\n // Disabled affordances on the shell.\n ],\n {\n variants: {\n variant: {\n filled: [\"bg-black/3 dark:bg-white/4\", \"border-transparent\"],\n light: [\"bg-white/4\", \"border-brand-900/20 dark:border-white/15\"],\n outline: [\"bg-transparent border-transparent\"],\n subtle: [\"bg-transparent border-transparent\"],\n default: [\"bg-white/4\", \"border-brand-900/20 dark:border-white/15\"],\n },\n size: {\n // The exact `min-h` `inputShell` (input.tsx) uses at the same size —\n // so a `SegmentGroup` sits flush with an `Input` / `NumberInput` of\n // the same size in a row (see `TimeRow`, which composes both).\n xs: \"gap-0 min-h-7\",\n sm: \"gap-0 min-h-8\",\n md: \"gap-0 min-h-9\",\n lg: \"gap-0 min-h-10\",\n xl: \"gap-0 min-h-12\",\n },\n },\n defaultVariants: { variant: \"default\" },\n },\n)\n\nexport type SegmentGroupSize = NonNullable<VariantProps<typeof segItem>[\"size\"]>\nexport type SegmentGroupVariant = VariantProps<typeof segTray>[\"variant\"]\n\n/**\n * A single segment: a bare value-as-label string, or a labelled object. Objects\n * may carry a `payload` of arbitrary data (the machine ignores it; it flows\n * through to `renderItem`, typed off the `data` shape — the same contract as\n * `Select`'s `SelectItem`).\n */\nexport type SegmentGroupItem<P = unknown> =\n | string\n | {\n value: string\n label?: ReactNode\n disabled?: boolean\n /** Overrides the group palette for the pill + label when this item is selected. */\n color?: Color\n /** Arbitrary extra data, surfaced to `renderItem`. */\n payload?: P\n /** `data-testid` on the rendered segment. Defaults to `` `item-${value}` ``. */\n testId?: string\n }\n\n/** The `data` array the component is generic over. */\nexport type SegmentGroupData<P = unknown> = ReadonlyArray<SegmentGroupItem<P>>\n\n/**\n * Extract the value-string union from a `SegmentGroupData` shape — bare strings\n * and item `.value`s both contribute. A `const` type parameter narrows it to the\n * literal union, so `value` / `onChange` are typed off the data (like `Select`).\n */\nexport type SegmentGroupValue<Data extends SegmentGroupData> = ItemValue<Data[number]>\ntype ItemValue<E> = E extends string ? E : E extends { value: infer V extends string } ? V : never\n\n/**\n * Extract the `payload` type carried by a `SegmentGroupData` shape, read\n * structurally off the data's `payload` property. Bare strings contribute\n * `never`; a homogeneous payload resolves precisely, a mixed one to the union.\n */\nexport type SegmentGroupPayload<Data extends SegmentGroupData> = PayloadOf<Data[number]>\ntype PayloadOf<T> = T extends string ? never : T extends { payload?: infer P } ? P : never\n\n/**\n * The segment handed to `renderItem`: `value` narrowed to the data's value union\n * and `payload` to the data's payload type, so a `const`-typed `data` yields\n * literal values and a precise payload in the callback.\n */\nexport type RenderableSegment<Data extends SegmentGroupData> = {\n value: SegmentGroupValue<Data>\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: SegmentGroupPayload<Data> | undefined\n}\n\n/** Live segment state passed alongside the item to `renderItem`. */\nexport type SegmentRenderState = {\n checked: boolean\n disabled: boolean\n}\n\n/**\n * Render a segment's label content yourself. Receives the (value-narrowed) item —\n * including its typed `payload` — and its live `{ checked, disabled }` state. The\n * segment keeps its sizing, pill, and selection wiring; you fill the label. In an\n * RSC tree the function must live in a `\"use client\"` module so the boundary\n * serializes it as a client reference.\n */\nexport type RenderSegment<Data extends SegmentGroupData> = (\n item: RenderableSegment<Data>,\n state: SegmentRenderState,\n) => ReactNode\n\ntype SegmentGroupClassNames = {\n field?: string\n /** The label element itself — e.g. `\"sr-only\"` to keep the accessible name\n * without showing it. */\n label?: string\n root?: string\n indicator?: string\n item?: string\n itemText?: string\n}\n\nexport type SegmentGroupProps<Data extends SegmentGroupData = SegmentGroupData> = Pick<\n FieldProps,\n \"label\" | \"description\" | \"error\" | \"required\"\n> &\n WithTestId & {\n /** Segments: bare strings (`value === label`) or `{ value, label?, disabled?, color?, payload? }`. */\n data: Data\n /** Controlled value. `null` clears the selection. */\n value?: SegmentGroupValue<Data> | null\n /** Uncontrolled initial value. */\n defaultValue?: SegmentGroupValue<Data> | null\n /** Fires with the selected value. */\n onChange?: (value: SegmentGroupValue<Data>) => void\n /** Render each segment's label content yourself, with its typed `payload`. */\n renderItem?: RenderSegment<Data>\n /** Lay the segments in a row (default) or a column. */\n orientation?: \"horizontal\" | \"vertical\"\n /** Red invalid state, independent of (and OR'd with) `error`. */\n invalid?: boolean\n /** Dims and blocks interaction. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n /** `xs`–`xl` match the exact box height of an `Input` / `NumberInput` at\n * that size, so a `SegmentGroup` composes flush inline next to one (see\n * `TimeInput`'s AM/PM toggle). */\n size?: SegmentGroupSize\n variant?: SegmentGroupVariant\n color?: Color\n /** Wires the hidden radio inputs into native form submission. */\n name?: string\n /** Explicit id for label association. */\n id?: string\n /** Lands on the root for focus-on-error. */\n ref?: Ref<HTMLDivElement>\n /** Forwarded to the root; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n className?: string\n classNames?: SegmentGroupClassNames\n }\n\n/** A fully resolved segment — every field present (`label` falls back to `value`). */\ntype NormalizedItem = {\n value: string\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: unknown\n testId: string\n}\n\n/** Normalize a bare string / object into the resolved `NormalizedItem` form. */\nconst normalizeItem = (item: SegmentGroupItem): NormalizedItem =>\n typeof item === \"string\"\n ? {\n value: item,\n label: item,\n disabled: false,\n color: undefined,\n payload: undefined,\n testId: `item-${item}`,\n }\n : {\n value: item.value,\n label: item.label ?? item.value,\n disabled: item.disabled ?? false,\n color: item.color,\n payload: item.payload,\n testId: item.testId ?? `item-${item.value}`,\n }\n\n/**\n * The real `role=\"radiogroup\"` root (and, through it, each item's hidden\n * radio input), split out so it reads the `Field` context from *inside* the\n * wrapping `FieldShell` — `SegmentGroup` itself renders that shell, so\n * calling `useFieldContext()` at its own top level would run too early.\n * Takes plain `string` values rather than the outer component's `Data`-typed\n * union: it only forwards them, so no generic type parameter is needed here.\n */\nconst SegmentGroupRoot = ({\n value,\n onValueChange,\n disabled,\n readOnly,\n required,\n invalid,\n orientation,\n name,\n id,\n ref,\n onBlur,\n color,\n className,\n testId,\n children,\n}: {\n value: string | null\n onValueChange: (value: string | null) => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n invalid: boolean\n orientation: \"horizontal\" | \"vertical\"\n name?: string\n id?: string\n ref?: Ref<HTMLDivElement>\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n color?: Color\n className?: string\n children: ReactNode\n} & WithTestId) => {\n const field = useFieldContext()\n const checkDirection = useDirectionCheck()\n const rootRef = useMergedRefs(ref, checkDirection)\n return (\n <Ark.Root\n value={value}\n onValueChange={(d) => onValueChange(d.value)}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={invalid}\n orientation={orientation}\n name={name}\n id={id}\n ref={rootRef}\n onBlur={onBlur}\n data-color={color}\n {...props({ \"data-invalid\": invalid, \"data-testid\": testId })}\n {...fieldA11yProps(field)}\n className={className}\n >\n {children}\n </Ark.Root>\n )\n}\n\nexport const SegmentGroup = <const Data extends SegmentGroupData = SegmentGroupData>({\n data,\n value,\n defaultValue,\n onChange,\n renderItem,\n orientation = \"horizontal\",\n invalid,\n disabled,\n readOnly,\n required,\n size = \"md\",\n variant = \"default\",\n color,\n name,\n id,\n ref,\n onBlur,\n label,\n description,\n error,\n className,\n classNames,\n testId,\n}: SegmentGroupProps<Data>) => {\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n\n // Own the value so the pill can read which item is selected (per-item color)\n // and so the `key={orientation}` remount below preserves the selection.\n const [selectedValue, setSelectedValue] = useUncontrolled<SegmentGroupValue<Data> | null>({\n value,\n defaultValue,\n finalValue: null,\n onChange: (v) => v != null && onChange?.(v),\n })\n\n const normalized = (data as SegmentGroupData).map(normalizeItem)\n const selected = normalized.find((item) => item.value === selectedValue)\n\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n classNames={{ label: classNames?.label }}\n // A radio group: nothing carries the label's `for` id; the root's `aria-labelledby` names it.\n composite\n >\n {/* `key={orientation}` remounts the root on an axis flip so Ark re-measures\n the indicator rect for the new layout (it only measures on mount + value\n change). `useUncontrolled` keeps the selection across that remount. */}\n <SegmentGroupRoot\n key={orientation}\n value={selectedValue}\n // Ark's value is typed by the collection (`string`); the runtime value\n // always originates from `data`, so narrow it back to the caller's union.\n onValueChange={(v) => setSelectedValue(v as SegmentGroupValue<Data> | null)}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={isInvalid}\n orientation={orientation}\n name={name}\n id={id}\n ref={ref}\n onBlur={onBlur}\n color={color}\n testId={testId}\n className={cn(segTray({ variant, size }), className, classNames?.root)}\n >\n {/* The sliding pill. Ark sets `position: absolute` + `--left`/`--top`/\n `--width`/`--height` (the selected segment's rect) inline, so it\n sits behind the labels (`z-0`). It adopts the selected item's `color`\n (falling back to the group `color`), which is the same `data-color`\n that item's own label carries — so the fill and the `--c-on-solid`\n text on top of it always resolve from one block.\n\n We drive the slide ourselves rather than via Ark's gated transition.\n Ark sets `transition-property: none` whenever its `animateIndicator`\n flag is false — including the instant it receives the `transitionend`\n of ANY animated property. With several properties of differing\n end-times (a `left` redirected by an interrupting click vs. a color or\n width that already settled), that early end would null the transition\n and snap the pill mid-slide. Overriding the real `transition-*` props\n (our `style` wins via Ark's `mergeProps`) keeps the transition always\n on, so the flag is irrelevant and interruptions re-target smoothly. The\n first paint stays instant because Ark renders the pill `hidden` until\n its rect is measured, and `display:none` can't transition. The\n duration comes from `--indicator-duration` (set by a class) rather\n than an inline value, so reduced motion can zero it. */}\n <Ark.Indicator\n style={{\n width: \"var(--width)\",\n height: \"var(--height)\",\n transitionProperty: \"left, top, width, height, background-color, border-color\",\n transitionDuration: \"var(--indicator-duration)\",\n transitionTimingFunction: \"var(--ease-emphasized)\",\n }}\n {...props({ \"data-color\": selected?.color ?? color })}\n className={cn(segIndicator({ variant }), classNames?.indicator)}\n />\n {normalized.map((item) => (\n <Ark.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n data-testid={item.testId}\n className={cn(segItemWrap(), classNames?.item)}\n >\n <Ark.ItemText\n data-color={item.color}\n className={cn(segItem({ size, variant }), classNames?.itemText)}\n >\n {/* `renderItem` owns the label content (with the item's typed payload);\n the ItemText keeps its sizing, checked color, and pill wiring. */}\n {renderItem ? (\n <Ark.ItemContext>\n {(ctx) =>\n renderItem(item as unknown as RenderableSegment<Data>, {\n checked: ctx.checked,\n disabled: ctx.disabled,\n })\n }\n </Ark.ItemContext>\n ) : (\n item.label\n )}\n </Ark.ItemText>\n <Ark.ItemControl />\n <Ark.ItemHiddenInput />\n </Ark.Item>\n ))}\n </SegmentGroupRoot>\n </FieldShell>\n )\n}\n"]}
|
|
@@ -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}\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cAAY,YAAA,EAAc,iBAAA;AAAA,wBAC1B,WAAW,UAAA,EAAY;AAAA;AAAA;AACzB,mBAAA,EAEJ,CAAA;AAAA,kCAEF,GAAA;AAAA,oBAAC,SAAA;AAAA,oBAAA;AAAA,sBACC,SAAA,EAAW,EAAA;AAAA,wBACT,CAAC,SAAA,IAAa,yBAAA;AAAA,wBACd,yBAAA;AAAA,wBACA,UAAA,EAAY;AAAA,uBACd;AAAA,sBAEC;AAAA;AAAA;AACH;AAAA;AAAA;AACF;AAAA;AACF,OAAA,EACF;AAAA;AAAA,GACF;AAEJ,CAAA;AAEO,IAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,cAAA,EAAgB;AAAA,EACjD,IAAA,EAAM,SAAA;AAAA,EACN,OAAA,EAAS,YAAA;AAAA,EACT,OAAA,EAAS,YAAA;AAAA,EACT,QAAA,EAAU,aAAA;AAAA,EACV,UAAA,EAAY,eAAA;AAAA,EACZ,OAAA,EAAS,YAAA;AAAA,EACT,KAAA,EAAO,UAAA;AAAA,EACP,WAAA,EAAa,gBAAA;AAAA,EACb,YAAA,EAAc,iBAAA;AAAA,EACd,MAAA,EAAQ,WAAA;AAAA,EACR,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ;AACV,CAAC","file":"chunk-AHKMN3YQ.js","sourcesContent":["\"use client\"\n\nimport { Dialog as Ark } from \"@ark-ui/react/dialog\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { type ComponentPropsWithoutRef, type ReactNode, useRef } from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { OverlayContainerProvider } from \"../../lib/overlay-container\"\nimport { NestedLayer, useLayerGuard } from \"../../lib/overlay-layer\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport {\n createDialogParts,\n DIALOG_PADDING,\n type DialogCloseTriggerProps,\n type DialogIconSlot,\n type DialogIcons,\n DialogRootProviders,\n type DialogSectionProps,\n useDialogNameCheck,\n} from \"../overlays/dialog-parts\"\n\n/**\n * Modal — centered overlay dialog on top of Ark UI's Dialog state machine.\n * Ark owns focus-trap, scroll-lock, RTL, the `Esc` / click-outside behaviour\n * and the `data-state=\"open|closed\"` attribute that drives our enter/exit\n * animations (keyframes live in `theme.css`). This wrapper provides the styled\n * parts and a flatter props API.\n *\n * - High-level form: `<Modal open title size … >children</Modal>` renders the\n * full Portal → Backdrop → Positioner → Content → Header + Body scaffold.\n * This is what the imperative overlays manager mounts.\n * - Low-level parts (`Modal.Root`, `Modal.Content`, `Modal.Title`, …) are\n * exposed for full control / trigger-based composition.\n *\n * Surface padding flows through the `--modal-px` CSS var set on the content, so\n * `Modal.Header` / `Modal.Body` / `Modal.Footer` stay in rhythm without prop\n * plumbing — and keep a sensible fallback when used standalone.\n */\n\nconst modalBackdrop = cva([\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] bg-black/50 backdrop-blur-lg pointer-events-auto select-none\",\n \"data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out\",\n])\n\nconst modalPositioner = cva(\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] flex flex-col items-center overflow-y-auto p-4\",\n {\n variants: {\n position: {\n center: \"justify-center\",\n top: \"justify-start mt-[8vh]\",\n bottom: \"justify-end mb-[8vh]\",\n },\n },\n defaultVariants: { position: \"center\" },\n },\n)\n\nconst modalContent = cva(\n [\n \"relative flex w-full flex-col\",\n \"max-h-[calc(100dvh-2rem)]\",\n \"bg-brand-50 text-brand-950 border border-brand-900/20 shadow-2xl\",\n \"dark:bg-brand-950 dark:text-white dark:border-white/15\",\n \"focus:outline-none\",\n \"data-[state=open]:animate-modal-in data-[state=closed]:animate-modal-out\",\n ],\n {\n variants: {\n size: {\n xs: \"max-w-(--width-xs)\", // 24rem\n sm: \"max-w-(--width-sm)\", // 30rem\n md: \"max-w-(--width-md)\", // 35rem\n lg: \"max-w-(--width-lg)\", // 40rem\n xl: \"max-w-(--width-xl)\", // 48rem\n full: \"max-w-[calc(100vw-2rem)] min-h-[calc(100dvh-2rem)]\",\n },\n radius: {\n none: \"rounded-none\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-xl\",\n xl: \"rounded-2xl\",\n },\n },\n defaultVariants: { size: \"md\", radius: \"sm\" },\n },\n)\n\n// ---------------------------------------------------------------------------\n// Low-level parts (styled Ark parts + kit conveniences)\n// ---------------------------------------------------------------------------\n\nexport type ModalIconSlot = DialogIconSlot\nexport type ModalIcons = DialogIcons\n\nexport type ModalRootProps = ComponentPropsWithoutRef<typeof Ark.Root> & {\n /** Replaces the default icons: `close`. `Modal.CloseTrigger`'s `children` win over it. */\n icons?: ModalIcons\n}\n\n/** Ark's root, plus the nested-layer guard: while a picker opened inside the\n * dialog is open, an outside click closes the picker only, not the dialog\n * under it. It is also a layer of its own while open, so a hotkey on the page\n * (or in an enclosing overlay) yields to it. See `lib/overlay-layer.tsx`. */\nconst ModalRoot = ({ onPointerDownOutside, icons, children, ...rest }: ModalRootProps) => {\n const guard = useLayerGuard(onPointerDownOutside)\n return (\n <Ark.Root onPointerDownOutside={guard.onPointerDownOutside} {...rest}>\n {/* A layer itself, registered with whatever it opened from (the page,\n or an enclosing overlay), so what's under it knows it's covered. */}\n <Ark.Context>{(api) => <NestedLayer open={api.open} />}</Ark.Context>\n <DialogRootProviders icons={icons} layers={guard.layers}>\n {children}\n </DialogRootProviders>\n </Ark.Root>\n )\n}\nconst ModalTrigger = Ark.Trigger\nconst ModalContext = Ark.Context\n\nexport type ModalBackdropProps = ComponentPropsWithoutRef<typeof Ark.Backdrop> & WithTestId\n\nconst ModalBackdrop = ({ className, testId, ...rest }: ModalBackdropProps) => (\n <Ark.Backdrop\n className={cn(modalBackdrop(), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalPosition = VariantProps<typeof modalPositioner>[\"position\"]\nexport type ModalPositionerProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Positioner>> &\n WithTestId & {\n position?: ModalPosition\n }\n\nconst ModalPositioner = ({\n className,\n position,\n testId,\n children,\n asChild: _asChild,\n ...rest\n}: ModalPositionerProps) => {\n // A ref, not state: overlays read it when they portal, so nothing has to\n // re-render once it attaches (see `lib/overlay-container.tsx`).\n const positioner = useRef<HTMLDivElement>(null)\n return (\n <Ark.Positioner\n ref={positioner}\n className={cn(modalPositioner({ position }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <OverlayContainerProvider value={positioner}>{children}</OverlayContainerProvider>\n </Ark.Positioner>\n )\n}\n\nexport type ModalContentProps = ComponentPropsWithoutRef<typeof Ark.Content> &\n VariantProps<typeof modalContent> &\n WithTestId\n\nconst ModalContent = ({ className, size, radius, testId, ...rest }: ModalContentProps) => {\n const nameCheck = useDialogNameCheck(\"Modal\")\n return (\n <Ark.Content\n ref={nameCheck}\n className={cn(modalContent({ size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n )\n}\n\nexport type ModalTitleProps = ComponentPropsWithoutRef<typeof Ark.Title> & WithTestId\n\nconst ModalTitle = ({ className, testId, ...rest }: ModalTitleProps) => (\n <Ark.Title\n className={cn(\"text-xl font-semibold leading-tight\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalDescriptionProps = ComponentPropsWithoutRef<typeof Ark.Description> & WithTestId\n\nconst ModalDescription = ({ className, testId, ...rest }: ModalDescriptionProps) => (\n <Ark.Description\n className={cn(\"text-sm\", TEXT_COLOR_CLASSES.muted, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type ModalCloseTriggerProps = DialogCloseTriggerProps\nexport type ModalHeaderProps = DialogSectionProps\nexport type ModalBodyProps = DialogSectionProps\nexport type ModalFooterProps = DialogSectionProps\n\nconst {\n CloseTrigger: ModalCloseTrigger,\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n} = createDialogParts(\"modal\", Ark.CloseTrigger)\n\n// ---------------------------------------------------------------------------\n// High-level props-driven Modal\n// ---------------------------------------------------------------------------\n\ntype ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>\n\nexport type ModalSize = NonNullable<VariantProps<typeof modalContent>[\"size\"]>\nexport type ModalRadius = NonNullable<VariantProps<typeof modalContent>[\"radius\"]>\n\nexport type ModalClassNames = Partial<\n Record<\n | \"backdrop\"\n | \"positioner\"\n | \"content\"\n | \"header\"\n | \"title\"\n | \"description\"\n | \"body\"\n | \"closeButton\",\n string\n >\n>\n\nexport type ModalProps = Omit<\n ArkRootProps,\n \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"children\" | \"role\"\n> &\n WithTestId & {\n /** Controlled open state. */\n open?: boolean\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean\n /** Fires with the next open state. Flattened from Ark's `{ open }`. */\n onOpenChange?: (open: boolean) => void\n /** Header title; renders the header when set, and names the dialog. */\n title?: ReactNode\n /** Id of an element inside the modal that names it, when there is no `title`. For a\n * plain string, use `aria-label`. */\n \"aria-labelledby\"?: string\n /** Optional subtitle under the title. */\n description?: ReactNode\n size?: ModalSize\n radius?: ModalRadius\n /** Vertically center the modal (vs. anchored near the top). */\n position?: ModalPosition\n /** Render the default close button in the header. @default true */\n withCloseButton?: boolean\n /**\n * Render the dimming backdrop. Set `false` when an ancestor (e.g. the modals\n * manager) draws a single shared backdrop for the whole overlay stack.\n * @default true\n */\n withBackdrop?: boolean\n /** Inner padding token; sets `--modal-px`. @default \"md\" */\n padding?: Size\n closeOnEscape?: boolean\n closeOnInteractOutside?: boolean\n /** Use `alertdialog` semantics (confirm flows). @default \"dialog\" */\n role?: \"dialog\" | \"alertdialog\"\n /** Fires after the exit animation completes; the manager unmounts on this. */\n onExitComplete?: () => void\n /** Fires on close (any source) */\n onClose?: () => void\n /** Portal target. Defaults to `document.body`. */\n container?: HTMLElement | null\n children?: ReactNode\n className?: string\n classNames?: ModalClassNames\n /** Overrides the default close button's accessible name (`closeTriggerLabel`, default\n * `\"Close\"`). The compound `ModalCloseTrigger` part takes a plain `aria-label` instead. */\n translations?: ModalTranslations\n /** Replaces the default icons: `close`, the header's close button. */\n icons?: ModalIcons\n }\n\n/** The ready-made modal's wording — `closeTriggerLabel` follows Ark's naming for the\n * same control. */\nexport type ModalTranslations = { closeTriggerLabel?: string }\n\nconst ModalComponent = ({\n open,\n defaultOpen,\n onOpenChange,\n onClose,\n title,\n description,\n \"aria-labelledby\": ariaLabelledby,\n size,\n radius,\n position,\n withCloseButton = true,\n withBackdrop = true,\n padding = \"md\",\n closeOnEscape,\n closeOnInteractOutside,\n role,\n onExitComplete,\n container,\n children,\n className,\n classNames,\n testId,\n translations,\n icons,\n ...rest\n}: ModalProps) => {\n const hasHeader = title != null || description != null || withCloseButton\n\n return (\n <ModalRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={({ open: next }) => {\n onOpenChange?.(next)\n if (!next) onClose?.()\n }}\n closeOnEscape={closeOnEscape}\n // Decoupled from `modal` on purpose: Ark's dialog derives this default\n // from `modal` (`modal && !alertdialog`), so when the overlays manager\n // draws its own shared backdrop and passes `withBackdrop={false}` —\n // forcing `modal={false}` below — outside-click would silently stop\n // dismissing. Default to Ark's intended behaviour instead: dismiss for\n // regular dialogs, keep `alertdialog`s sticky (explicit choice required).\n closeOnInteractOutside={closeOnInteractOutside ?? role !== \"alertdialog\"}\n role={role}\n // Unmount the whole content tree (incl. the `fixed inset-0` positioner)\n // on close — otherwise the positioner lingers as a transparent overlay\n // that swallows page clicks. `lazyMount` keeps it out of the DOM until\n // first open. Both flow to the parts' presence via Ark's Root context.\n lazyMount\n unmountOnExit\n modal={withBackdrop}\n onExitComplete={onExitComplete}\n icons={icons}\n {...rest}\n >\n <Portal container={container ? { current: container } : undefined}>\n {withBackdrop && <ModalBackdrop className={classNames?.backdrop} />}\n <ModalPositioner\n position={position}\n className={cn(\"overflow-clip\", classNames?.positioner)}\n >\n <ModalContent\n size={size}\n radius={radius}\n style={{ [\"--modal-px\" as string]: DIALOG_PADDING[padding] }}\n className={cn(className, classNames?.content)}\n testId={testId}\n aria-labelledby={ariaLabelledby}\n >\n {hasHeader && (\n <ModalHeader className={classNames?.header}>\n <div className=\"flex flex-col gap-1\">\n {title != null && <ModalTitle className={classNames?.title}>{title}</ModalTitle>}\n {description != null && (\n <ModalDescription className={classNames?.description}>\n {description}\n </ModalDescription>\n )}\n </div>\n {withCloseButton && (\n <ModalCloseTrigger\n aria-label={translations?.closeTriggerLabel}\n className={classNames?.closeButton}\n />\n )}\n </ModalHeader>\n )}\n <ModalBody\n className={cn(\n !hasHeader && \"pt-(--modal-px,1.25rem)\",\n \"pb-(--modal-px,1.25rem)\",\n classNames?.body,\n )}\n >\n {children}\n </ModalBody>\n </ModalContent>\n </ModalPositioner>\n </Portal>\n </ModalRoot>\n )\n}\n\nexport const Modal = Object.assign(ModalComponent, {\n Root: ModalRoot,\n Trigger: ModalTrigger,\n Context: ModalContext,\n Backdrop: ModalBackdrop,\n Positioner: ModalPositioner,\n Content: ModalContent,\n Title: ModalTitle,\n Description: ModalDescription,\n CloseTrigger: ModalCloseTrigger,\n Header: ModalHeader,\n Body: ModalBody,\n Footer: ModalFooter,\n})\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/overlay-layer.tsx"],"names":[],"mappings":";;;;AA0CA,IAAM,WAAA,uBAAiC,GAAA,EAAI;AAE3C,IAAM,mBAAA,GAAsB,cAA6B,WAAW,CAAA;AAM7D,IAAM,aAAA,GAAgB,CAAkB,oBAAA,KAA8C;AAC3F,EAAA,MAAM,MAAA,GAAS,MAAA,iBAAsB,IAAI,GAAA,EAAK,CAAA,CAAE,OAAA;AAChD,EAAA,MAAM,KAAA,GAAQ,WAAA;AAAA,IACZ,CAAC,KAAA,KAAa;AACZ,MAAA,oBAAA,GAAuB,KAAK,CAAA;AAC5B,MAAA,IAAI,MAAA,CAAO,IAAA,GAAO,CAAA,EAAG,KAAA,CAAM,cAAA,EAAe;AAAA,IAC5C,CAAA;AAAA,IACA,CAAC,QAAQ,oBAAoB;AAAA,GAC/B;AACA,EAAA,OAAO,EAAE,MAAA,EAAQ,oBAAA,EAAsB,KAAA,EAAM;AAC/C;AAEO,IAAM,uBAAuB,CAAC;AAAA,EACnC,KAAA;AAAA,EACA;AACF,CAAA,qBAGM,GAAA,CAAC,mBAAA,CAAoB,QAAA,EAApB,EAA6B,OAAe,QAAA,EAAS;AAOrD,IAAM,cAAA,GAAiB,CAAC,IAAA,KAAkB;AAC/C,EAAA,MAAM,MAAA,GAAS,WAAW,mBAAmB,CAAA;AAC7C,EAAA,yBAAA,CAA0B,MAAM;AAC9B,IAAA,IAAI,CAAC,IAAA,EAAM;AACX,IAAA,MAAM,wBAAQ,MAAA,EAAO;AACrB,IAAA,MAAA,CAAO,IAAI,KAAK,CAAA;AAChB,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,OAAO,KAAK,CAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,IAAA,EAAM,MAAM,CAAC,CAAA;AACnB;AAIO,IAAM,WAAA,GAAc,CAAC,EAAE,IAAA,EAAK,KAAyB;AAC1D,EAAA,cAAA,CAAe,IAAI,CAAA;AACnB,EAAA,OAAO,IAAA;AACT;AAOO,IAAM,kBAAkB,MAAuB;AACpD,EAAA,MAAM,MAAA,GAAS,WAAW,mBAAmB,CAAA;AAC7C,EAAA,OAAO,YAAY,MAAM,MAAA,CAAO,OAAO,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AACpD","file":"chunk-H7WOMZXO.js","sourcesContent":["\"use client\"\n\nimport { createContext, type ReactNode, useCallback, useContext, useRef } from \"react\"\nimport { useIsomorphicLayoutEffect } from \"./use-isomorphic-layout-effect\"\n\n/**\n * One outside click dismisses one layer.\n *\n * Every dismissable surface (zag's `trackDismissableElement`) listens for\n * pointerdown on the whole document and closes itself when the target falls\n * outside it. Nested layers don't coordinate: a click on a Modal's backdrop\n * while a DatePicker inside it is open lands outside *both*, so both close —\n * the picker and the dialog the user was filling in. Zag only spares the\n * parent when the child is pointer-blocking (pickers aren't) or was removed a\n * tick earlier (the parent's listener runs first, so it never is), and its\n * `layerStack` isn't exported for us to ask.\n *\n * So the kit tracks it itself. A parent (`Modal`, `Drawer`, `Popover`) owns a\n * set of open children and vetoes its own outside-dismiss while that set is\n * non-empty; every floating panel registers with its nearest parent while\n * open. The click that would have cascaded closes the innermost layer only,\n * and the next one closes the parent.\n *\n * Context rather than DOM queries because context crosses portals: the\n * registration reaches the right parent wherever the panel was portaled to —\n * the parent's positioner, `document.body`, a custom `container`, or nowhere\n * (`withinPortal={false}`).\n *\n * Pointer-down only. Escape is already top-most-only in zag, and focus can't\n * leave a modal for a sibling layer it doesn't own.\n *\n * The same sets answer a second question: is anything open above me? A\n * component reads its nearest set with `useLayerCovered` (that is how\n * `useHotkey` yields to an overlay). Outside every overlay, the nearest set is\n * the page's own: `Modal` and `Drawer` register into it while open just like a\n * picker does, so a page-level reader sees them, and a reader inside a Modal\n * sees only what opened from that Modal.\n */\nexport type OverlayLayers = Set<symbol>\n\n/** The page's set: what a layer registers into when no overlay encloses it.\n * Nothing guards it (the page has no outside to dismiss), it only counts. */\nconst PAGE_LAYERS: OverlayLayers = new Set()\n\nconst OverlayLayerContext = createContext<OverlayLayers>(PAGE_LAYERS)\n\n/** For a parent layer. Spread `onPointerDownOutside` onto the Ark root\n * (composed with the caller's own) and wrap the children that may open nested\n * layers in `OverlayLayerProvider`. A ref'd set, not state: it's read synchronously while\n * zag dispatches the outside event, and changing it must not re-render. */\nexport const useLayerGuard = <E extends Event>(onPointerDownOutside?: (event: E) => void) => {\n const layers = useRef<OverlayLayers>(new Set()).current\n const guard = useCallback(\n (event: E) => {\n onPointerDownOutside?.(event)\n if (layers.size > 0) event.preventDefault()\n },\n [layers, onPointerDownOutside],\n )\n return { layers, onPointerDownOutside: guard }\n}\n\nexport const OverlayLayerProvider = ({\n value,\n children,\n}: {\n value: OverlayLayers\n children?: ReactNode\n}) => <OverlayLayerContext.Provider value={value}>{children}</OverlayLayerContext.Provider>\n\n/** For a child layer: registers with the nearest parent (the page's set when\n * none encloses it) while `open`. Keyed on\n * `open`, not presence, so a panel playing its exit animation no longer holds\n * the parent's next click. A layout effect so the registration is in place\n * before the browser can deliver the next pointerdown. */\nexport const useNestedLayer = (open: boolean) => {\n const parent = useContext(OverlayLayerContext)\n useIsomorphicLayoutEffect(() => {\n if (!open) return\n const token = Symbol()\n parent.add(token)\n return () => {\n parent.delete(token)\n }\n }, [open, parent])\n}\n\n/** `useNestedLayer` as an element, for call sites that only have the machine's\n * `open` inside a render prop (`<Ark.Context>{(api) => …}</Ark.Context>`). */\nexport const NestedLayer = ({ open }: { open: boolean }) => {\n useNestedLayer(open)\n return null\n}\n\n/** Whether a layer is open above the component calling this, right now: a\n * Modal, Drawer, Popover or picker that opened from the same layer (from the\n * page, for a component outside every overlay). Returns a reader, not a\n * value, so it is checked when it matters (a key press) and opening a layer\n * never re-renders the caller. */\nexport const useLayerCovered = (): (() => boolean) => {\n const layers = useContext(OverlayLayerContext)\n return useCallback(() => layers.size > 0, [layers])\n}\n"]}
|