@nswds/ui 8.3.2 → 8.3.3
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.
|
@@ -10,6 +10,16 @@ declare function SheetClose({ ...props }: Dialog.Close.Props): React.JSX.Element
|
|
|
10
10
|
* `showCloseButton={false}` the sheet itself takes focus, so a long sheet
|
|
11
11
|
* never opens scrolled to a footer action. Pass `initialFocus` to choose a
|
|
12
12
|
* different target, such as a search field the sheet exists to fill in.
|
|
13
|
+
*
|
|
14
|
+
* With the close button shown, content in the button's corner reserves room
|
|
15
|
+
* at the end edge so text cannot run under it: the SheetHeader, and also the
|
|
16
|
+
* first visible child when that is not (and does not contain) the header —
|
|
17
|
+
* with no header at all, or an intro placed before the header. Add
|
|
18
|
+
* `data-sheet-bleed` to a padded element — a SheetHeader included — to opt
|
|
19
|
+
* out, e.g. for a full-bleed banner or a wrapper whose rows should reach the
|
|
20
|
+
* edge. "Visible" means not `sr-only` or `[hidden]`: a child hidden only
|
|
21
|
+
* at some breakpoints (`hidden sm:block`, `sr-only sm:not-sr-only`) cannot be
|
|
22
|
+
* told apart in CSS, so give that content its own end padding.
|
|
13
23
|
*/
|
|
14
24
|
declare function SheetContent({ className, children, side, showCloseButton, closeLabel, initialFocus, ref, ...props }: Dialog.Popup.Props & {
|
|
15
25
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
package/dist/components/sheet.js
CHANGED
|
@@ -75,10 +75,28 @@ function SheetContent({
|
|
|
75
75
|
"data-side": side,
|
|
76
76
|
className: cn(
|
|
77
77
|
"fixed z-50 flex max-h-dvh flex-col overflow-y-auto bg-popover bg-clip-padding text-base/relaxed text-popover-foreground transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm rtl:data-[side=left]:data-ending-style:-translate-x-[-2.5rem] rtl:data-[side=left]:data-starting-style:-translate-x-[-2.5rem] rtl:data-[side=right]:data-ending-style:-translate-x-[2.5rem] rtl:data-[side=right]:data-starting-style:-translate-x-[2.5rem]",
|
|
78
|
+
// These rules anchor on `data-sheet-corner-close`, the built-in button
|
|
79
|
+
// only: a consumer's own SheetClose shares its `data-slot` but is not
|
|
80
|
+
// in the corner, and must not switch the reserved room on.
|
|
81
|
+
//
|
|
78
82
|
// Keep a long title clear of the absolutely placed close button: it
|
|
79
83
|
// spans 1rem-3.5rem from the end edge, so pe-16 clears it. The header
|
|
80
84
|
// matches at any depth (a form often wraps it), as Dialog's does.
|
|
81
|
-
"[&:has(>[data-
|
|
85
|
+
"[&:has(>[data-sheet-corner-close])_[data-slot=sheet-header]:not([data-sheet-bleed])]:pe-16",
|
|
86
|
+
// Whatever sits beside the close button reserves the same room, so its
|
|
87
|
+
// text cannot run under it: the first VISIBLE child (an sr-only title
|
|
88
|
+
// or a [hidden] element is skipped), checked on that element only,
|
|
89
|
+
// not the whole sheet — an intro placed before a header is the
|
|
90
|
+
// content in the button's corner. A child that is or wraps the header
|
|
91
|
+
// (at any depth) is left to the rule above, so a header is never
|
|
92
|
+
// padded twice. If that child wraps the whole sheet with no header,
|
|
93
|
+
// all of it is padded; `data-sheet-bleed` on it opts out, as it does
|
|
94
|
+
// for full-bleed media meant to run under the button.
|
|
95
|
+
"[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16",
|
|
96
|
+
// One level into a first child that wraps the header (the usual
|
|
97
|
+
// <form>): its own first visible child is the content in the corner,
|
|
98
|
+
// e.g. an intro above the header, so it gets the same room.
|
|
99
|
+
"[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):has([data-slot=sheet-header])>:nth-child(1_of_:not(.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16",
|
|
82
100
|
className
|
|
83
101
|
),
|
|
84
102
|
...props,
|
|
@@ -87,6 +105,7 @@ function SheetContent({
|
|
|
87
105
|
Dialog.Close,
|
|
88
106
|
{
|
|
89
107
|
"data-slot": "sheet-close",
|
|
108
|
+
"data-sheet-corner-close": "",
|
|
90
109
|
render: /* @__PURE__ */ jsx(
|
|
91
110
|
Button,
|
|
92
111
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/sheet.tsx"],"names":["SheetPrimitive"],"mappings":";;;;;;;;;AAWA,SAAS,KAAA,CAAM,EAAE,GAAG,KAAA,EAAM,EAA8B;AACtD,EAAA,2BAAQA,MAAA,CAAe,IAAA,EAAf,EAAoB,WAAA,EAAU,OAAA,EAAS,GAAG,KAAA,EAAO,CAAA;AAC3D;AAEA,SAAS,YAAA,CAAa,EAAE,GAAG,KAAA,EAAM,EAAiC;AAChE,EAAA,2BAAQA,MAAA,CAAe,OAAA,EAAf,EAAuB,WAAA,EAAU,eAAA,EAAiB,GAAG,KAAA,EAAO,CAAA;AACtE;AAEA,SAAS,UAAA,CAAW,EAAE,GAAG,KAAA,EAAM,EAA+B;AAC5D,EAA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EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,2BAAA,EAA6B,SAAS,CAAA;AAAA,MACnD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,iCAAA,EAAmC,SAAS,CAAA;AAAA,MACzD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AACvE,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA,CAAe,KAAA;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,qCAAA,EAAuC,SAAS,CAAA;AAAA,MAC7D,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,gBAAA,CAAiB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAqC;AACnF,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA,CAAe,WAAA;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,mBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,yCAAA,EAA2C,SAAS,CAAA;AAAA,MACjE,GAAG;AAAA;AAAA,GACN;AAEJ","file":"sheet.js","sourcesContent":["'use client'\n\nimport { Dialog as SheetPrimitive } from '@base-ui/react/dialog'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { IconClose } from '../icons/close.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { overlayScrim } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Sheet({ ...props }: SheetPrimitive.Root.Props) {\n return <SheetPrimitive.Root data-slot='sheet' {...props} />\n}\n\nfunction SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {\n return <SheetPrimitive.Trigger data-slot='sheet-trigger' {...props} />\n}\n\nfunction SheetClose({ ...props }: SheetPrimitive.Close.Props) {\n return <SheetPrimitive.Close data-slot='sheet-close' {...props} />\n}\n\nfunction SheetPortal({ children, ...props }: SheetPrimitive.Portal.Props) {\n return (\n <SheetPrimitive.Portal data-slot='sheet-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </SheetPrimitive.Portal>\n )\n}\n\nfunction SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {\n return (\n <SheetPrimitive.Backdrop\n data-slot='sheet-overlay'\n className={cn(\n 'fixed inset-0 z-50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * On open, keyboard and mouse users land on the close button, which is first\n * in the DOM, rather than on the first control in the content. With\n * `showCloseButton={false}` the sheet itself takes focus, so a long sheet\n * never opens scrolled to a footer action. Pass `initialFocus` to choose a\n * different target, such as a search field the sheet exists to fill in.\n */\nfunction SheetContent({\n className,\n children,\n side = 'right',\n showCloseButton = true,\n closeLabel = 'Close',\n initialFocus,\n ref,\n ...props\n}: SheetPrimitive.Popup.Props & {\n side?: 'top' | 'right' | 'bottom' | 'left'\n showCloseButton?: boolean\n /**\n * Screen-reader name for the close button. Override to translate it — the\n * button is icon-only, so this string is the only name AT ever hears.\n */\n closeLabel?: string\n}) {\n const popupRef = React.useRef<HTMLDivElement | null>(null)\n // Returns its own cleanup, so React 19 never calls this with null. That\n // cleanup must run the consumer's in turn: React keeps a callback ref's\n // return value as its teardown, and dropping it would skip that teardown.\n const mergedRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n popupRef.current = node\n if (typeof ref === 'function') {\n const cleanup = ref(node)\n return () => {\n popupRef.current = null\n if (typeof cleanup === 'function') cleanup()\n else ref(null)\n }\n }\n if (ref) ref.current = node\n return () => {\n popupRef.current = null\n if (ref) ref.current = null\n }\n },\n [ref],\n )\n\n return (\n <SheetPortal>\n <SheetOverlay />\n <SheetPrimitive.Popup\n ref={mergedRef}\n // Without a close button there is no known-safe first control, and the\n // first tabbable may be a footer action below the fold. The popup\n // itself is the one target Base UI focuses with preventScroll.\n initialFocus={initialFocus ?? (showCloseButton ? undefined : popupRef)}\n data-slot='sheet-content'\n data-side={side}\n className={cn(\n 'fixed z-50 flex max-h-dvh flex-col overflow-y-auto bg-popover bg-clip-padding text-base/relaxed text-popover-foreground transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm rtl:data-[side=left]:data-ending-style:-translate-x-[-2.5rem] rtl:data-[side=left]:data-starting-style:-translate-x-[-2.5rem] rtl:data-[side=right]:data-ending-style:-translate-x-[2.5rem] rtl:data-[side=right]:data-starting-style:-translate-x-[2.5rem]',\n // Keep a long title clear of the absolutely placed close button: it\n // spans 1rem-3.5rem from the end edge, so pe-16 clears it. The header\n // matches at any depth (a form often wraps it), as Dialog's does.\n '[&:has(>[data-slot=sheet-close])_[data-slot=sheet-header]]:pe-16',\n className,\n )}\n {...props}\n >\n {/* The close button comes FIRST in the DOM (it is absolutely placed, so\n the visual order is unchanged). On a keyboard or mouse open, Base UI\n focuses the first tabbable element (on a touch open it focuses the\n popup, and DOM order does not matter); after the content, that is a\n footer button, and a long sheet opens scrolled to the bottom with\n the reader past everything above it. Being first also means it\n would paint UNDER any later positioned child in the corner (a\n Button is `relative`), so it carries z-20: above children up to\n and including the conventional sticky-header z-10. */}\n {showCloseButton && (\n <SheetPrimitive.Close\n data-slot='sheet-close'\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className='absolute end-4 top-4 z-20'\n />\n }\n >\n <IconClose />\n </SheetPrimitive.Close>\n )}\n {children}\n </SheetPrimitive.Popup>\n </SheetPortal>\n )\n}\n\nfunction SheetHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-header'\n className={cn('flex flex-col gap-1.5 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-footer'\n className={cn('mt-auto flex flex-col gap-2 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {\n return (\n <SheetPrimitive.Title\n data-slot='sheet-title'\n className={cn('text-lg font-medium text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SheetDescription({ className, ...props }: SheetPrimitive.Description.Props) {\n return (\n <SheetPrimitive.Description\n data-slot='sheet-description'\n className={cn('text-base/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport {\n Sheet,\n SheetClose,\n SheetContent,\n SheetDescription,\n SheetFooter,\n SheetHeader,\n SheetTitle,\n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,CAAe,KAAA;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,qCAAA,EAAuC,SAAS,CAAA;AAAA,MAC7D,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,gBAAA,CAAiB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAqC;AACnF,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA,CAAe,WAAA;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,mBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,yCAAA,EAA2C,SAAS,CAAA;AAAA,MACjE,GAAG;AAAA;AAAA,GACN;AAEJ","file":"sheet.js","sourcesContent":["'use client'\n\nimport { Dialog as SheetPrimitive } from '@base-ui/react/dialog'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { IconClose } from '../icons/close.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { overlayScrim } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Sheet({ ...props }: SheetPrimitive.Root.Props) {\n return <SheetPrimitive.Root data-slot='sheet' {...props} />\n}\n\nfunction SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {\n return <SheetPrimitive.Trigger data-slot='sheet-trigger' {...props} />\n}\n\nfunction SheetClose({ ...props }: SheetPrimitive.Close.Props) {\n return <SheetPrimitive.Close data-slot='sheet-close' {...props} />\n}\n\nfunction SheetPortal({ children, ...props }: SheetPrimitive.Portal.Props) {\n return (\n <SheetPrimitive.Portal data-slot='sheet-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </SheetPrimitive.Portal>\n )\n}\n\nfunction SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {\n return (\n <SheetPrimitive.Backdrop\n data-slot='sheet-overlay'\n className={cn(\n 'fixed inset-0 z-50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * On open, keyboard and mouse users land on the close button, which is first\n * in the DOM, rather than on the first control in the content. With\n * `showCloseButton={false}` the sheet itself takes focus, so a long sheet\n * never opens scrolled to a footer action. Pass `initialFocus` to choose a\n * different target, such as a search field the sheet exists to fill in.\n *\n * With the close button shown, content in the button's corner reserves room\n * at the end edge so text cannot run under it: the SheetHeader, and also the\n * first visible child when that is not (and does not contain) the header —\n * with no header at all, or an intro placed before the header. Add\n * `data-sheet-bleed` to a padded element — a SheetHeader included — to opt\n * out, e.g. for a full-bleed banner or a wrapper whose rows should reach the\n * edge. \"Visible\" means not `sr-only` or `[hidden]`: a child hidden only\n * at some breakpoints (`hidden sm:block`, `sr-only sm:not-sr-only`) cannot be\n * told apart in CSS, so give that content its own end padding.\n */\nfunction SheetContent({\n className,\n children,\n side = 'right',\n showCloseButton = true,\n closeLabel = 'Close',\n initialFocus,\n ref,\n ...props\n}: SheetPrimitive.Popup.Props & {\n side?: 'top' | 'right' | 'bottom' | 'left'\n showCloseButton?: boolean\n /**\n * Screen-reader name for the close button. Override to translate it — the\n * button is icon-only, so this string is the only name AT ever hears.\n */\n closeLabel?: string\n}) {\n const popupRef = React.useRef<HTMLDivElement | null>(null)\n // Returns its own cleanup, so React 19 never calls this with null. That\n // cleanup must run the consumer's in turn: React keeps a callback ref's\n // return value as its teardown, and dropping it would skip that teardown.\n const mergedRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n popupRef.current = node\n if (typeof ref === 'function') {\n const cleanup = ref(node)\n return () => {\n popupRef.current = null\n if (typeof cleanup === 'function') cleanup()\n else ref(null)\n }\n }\n if (ref) ref.current = node\n return () => {\n popupRef.current = null\n if (ref) ref.current = null\n }\n },\n [ref],\n )\n\n return (\n <SheetPortal>\n <SheetOverlay />\n <SheetPrimitive.Popup\n ref={mergedRef}\n // Without a close button there is no known-safe first control, and the\n // first tabbable may be a footer action below the fold. The popup\n // itself is the one target Base UI focuses with preventScroll.\n initialFocus={initialFocus ?? (showCloseButton ? undefined : popupRef)}\n data-slot='sheet-content'\n data-side={side}\n className={cn(\n 'fixed z-50 flex max-h-dvh flex-col overflow-y-auto bg-popover bg-clip-padding text-base/relaxed text-popover-foreground transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm rtl:data-[side=left]:data-ending-style:-translate-x-[-2.5rem] rtl:data-[side=left]:data-starting-style:-translate-x-[-2.5rem] rtl:data-[side=right]:data-ending-style:-translate-x-[2.5rem] rtl:data-[side=right]:data-starting-style:-translate-x-[2.5rem]',\n // These rules anchor on `data-sheet-corner-close`, the built-in button\n // only: a consumer's own SheetClose shares its `data-slot` but is not\n // in the corner, and must not switch the reserved room on.\n //\n // Keep a long title clear of the absolutely placed close button: it\n // spans 1rem-3.5rem from the end edge, so pe-16 clears it. The header\n // matches at any depth (a form often wraps it), as Dialog's does.\n '[&:has(>[data-sheet-corner-close])_[data-slot=sheet-header]:not([data-sheet-bleed])]:pe-16',\n // Whatever sits beside the close button reserves the same room, so its\n // text cannot run under it: the first VISIBLE child (an sr-only title\n // or a [hidden] element is skipped), checked on that element only,\n // not the whole sheet — an intro placed before a header is the\n // content in the button's corner. A child that is or wraps the header\n // (at any depth) is left to the rule above, so a header is never\n // padded twice. If that child wraps the whole sheet with no header,\n // all of it is padded; `data-sheet-bleed` on it opts out, as it does\n // for full-bleed media meant to run under the button.\n '[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16',\n // One level into a first child that wraps the header (the usual\n // <form>): its own first visible child is the content in the corner,\n // e.g. an intro above the header, so it gets the same room.\n '[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):has([data-slot=sheet-header])>:nth-child(1_of_:not(.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16',\n className,\n )}\n {...props}\n >\n {/* The close button comes FIRST in the DOM (it is absolutely placed, so\n the visual order is unchanged). On a keyboard or mouse open, Base UI\n focuses the first tabbable element (on a touch open it focuses the\n popup, and DOM order does not matter); after the content, that is a\n footer button, and a long sheet opens scrolled to the bottom with\n the reader past everything above it. Being first also means it\n would paint UNDER any later positioned child in the corner (a\n Button is `relative`), so it carries z-20: above children up to\n and including the conventional sticky-header z-10. */}\n {showCloseButton && (\n <SheetPrimitive.Close\n data-slot='sheet-close'\n data-sheet-corner-close=''\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className='absolute end-4 top-4 z-20'\n />\n }\n >\n <IconClose />\n </SheetPrimitive.Close>\n )}\n {children}\n </SheetPrimitive.Popup>\n </SheetPortal>\n )\n}\n\nfunction SheetHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-header'\n className={cn('flex flex-col gap-1.5 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-footer'\n className={cn('mt-auto flex flex-col gap-2 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {\n return (\n <SheetPrimitive.Title\n data-slot='sheet-title'\n className={cn('text-lg font-medium text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SheetDescription({ className, ...props }: SheetPrimitive.Description.Props) {\n return (\n <SheetPrimitive.Description\n data-slot='sheet-description'\n className={cn('text-base/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport {\n Sheet,\n SheetClose,\n SheetContent,\n SheetDescription,\n SheetFooter,\n SheetHeader,\n SheetTitle,\n SheetTrigger,\n}\n"]}
|