@nswds/ui 8.3.1 → 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.
|
@@ -97,9 +97,12 @@ function DialogContent({
|
|
|
97
97
|
size: "icon",
|
|
98
98
|
"aria-label": closeLabel,
|
|
99
99
|
className: cn(
|
|
100
|
-
// z-
|
|
101
|
-
//
|
|
102
|
-
|
|
100
|
+
// z-20, as Sheet's: the button comes first in the DOM, and
|
|
101
|
+
// equal z-indexes paint in DOM order, so any later positioned
|
|
102
|
+
// child in the corner (a Button is `relative`) would paint
|
|
103
|
+
// over it and take its clicks. z-20 clears children up to and
|
|
104
|
+
// including the conventional sticky-header z-10.
|
|
105
|
+
"absolute end-4 top-4 z-20",
|
|
103
106
|
// On the band the button takes the band's inverse ink — only
|
|
104
107
|
// when a header is there to paint the band. The extra
|
|
105
108
|
// data-slot keeps this above Button's own dark ink at any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/dialog.tsx"],"names":["DialogPrimitive"],"mappings":";;;;;;;;;AAYA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAA+B;AACxD,EAAA,2BAAQA,QAAA,CAAgB,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC7D;AAEA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAkC;AAClE,EAAA,2BAAQA,QAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC9D,EAAA,2BAAQA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AACpE;AAEA,SAAS,YAAA,CAAa,EAAE,QAAA,EAAU,GAAG,OAAM,EAAiC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IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA,QAIT,+DAAA;AAAA;AAAA,QAEA,8CAAA;AAAA;AAAA,QAEA,uGAAA;AAAA;AAAA,QAEA,uSAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QACA,eAAA,oBACC,GAAA,CAACA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,MAAA,kBAAQ,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAQ,SAAA,EAAU,CAAA,EACtD,QAAA,EAAA,UAAA,EACH;AAAA;AAAA;AAAA,GAEJ;AAEJ;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,mDAAA;AAAA;AAAA;AAAA,QAGA,+FAAA;AAAA,QACA,4JAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,iBAAA,CAAkB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAsC;AACrF,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,yCAAA;AAAA,QACA,+FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"dialog.js","sourcesContent":["'use client'\n\nimport { Dialog as DialogPrimitive } from '@base-ui/react/dialog'\nimport { cva } from 'class-variance-authority'\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 { overlayInk, overlayScrim } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Dialog({ ...props }: DialogPrimitive.Root.Props) {\n return <DialogPrimitive.Root data-slot='dialog' {...props} />\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n return <DialogPrimitive.Trigger data-slot='dialog-trigger' {...props} />\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n return <DialogPrimitive.Close data-slot='dialog-close' {...props} />\n}\n\nfunction DialogPortal({ children, ...props }: DialogPrimitive.Portal.Props) {\n return (\n <DialogPrimitive.Portal data-slot='dialog-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </DialogPrimitive.Portal>\n )\n}\n\n/**\n * The three approved looks (design-shotgun, overlays-20260923):\n *\n * - `default` (Hairline): a flat raised surface drawn with a 1px ring; the\n * header and footer bleed to the edges and are divided off by hairlines.\n * - `band`: the header is a solid band in the action colour with an inverse\n * title; the footer sits on a subtle band.\n * - `rule`: a 4px rule in the ink colour caps the top edge, the title sits on\n * a hairline in the text colour, and the actions align to the start.\n *\n * None casts a shadow and none blurs the page behind — depth is drawn, per\n * DESIGN.md's Hairline Rule. Parts read the variant from `data-variant` on\n * the popup through `group-data-*`, so there is no context to thread.\n */\ntype DialogVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes and its look. The parts (header, footer, title,\n * description, close button) read the look from `data-variant` through\n * `group-data-*` instead: cva sees only its own props, not an ancestor's.\n * Radius sits in every branch, not the base, so rule's square top never\n * competes with a base `rounded-md` at equal specificity.\n */\nconst dialogContentVariants = cva(\n // `w-[calc(100%-2rem)]` + `max-w-lg` rather than shadcn's\n // `max-w-[calc(100%-2rem)] sm:max-w-sm`: two different properties, so there\n // is no bare/responsive pair for a consumer's build to reorder (see\n // check:cascade).\n 'group/dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-6 overflow-y-auto bg-popover p-6 text-base/relaxed text-popover-foreground ring-1 ring-foreground/10 outline-hidden transition-[opacity,scale] duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0',\n {\n variants: {\n variant: {\n default: 'rounded-md',\n band: 'rounded-md',\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--overlay-ink)',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n)\n\nfunction DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {\n return (\n <DialogPrimitive.Backdrop\n data-slot='dialog-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\nfunction DialogContent({\n className,\n children,\n variant = 'default',\n showCloseButton = true,\n closeLabel = 'Close',\n ...props\n}: DialogPrimitive.Popup.Props & {\n variant?: DialogVariant\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 return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Popup\n data-slot='dialog-content'\n data-variant={variant}\n className={cn(\n dialogContentVariants({ variant }),\n // The ink rule's cap is drawn in (see overlayInk).\n overlayInk,\n // The header rules below match it at any depth, not only as a direct\n // child: an edit dialog usually wraps its content in a <form>.\n // A header with nothing below it draws no divider over empty space.\n '[&_[data-slot=dialog-header]:last-child]:border-b-0',\n // Keep a long title clear of the absolutely-positioned close button:\n // 72px where the header bleeds to the edge (24px gutter + the 48px\n // the button needs), 48px under `rule`, whose header does not bleed.\n '[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-18 data-[variant=rule]:[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-12',\n // With no header at all, the first content after the close button\n // reserves the button's 48px instead, so its text cannot run under it.\n '[&>[data-slot=dialog-close]+:not([data-slot=dialog-header]):not(:has([data-slot=dialog-header]))]:pe-12',\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). Base UI focuses the first tabbable\n element on open; after the content, that is a footer button, and a\n long dialog opens scrolled to the bottom with the reader past\n everything above it. */}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot='dialog-close'\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className={cn(\n // z-10, as Sheet's: the button comes first in the DOM, so any\n // positioned content after it would otherwise paint over it.\n 'absolute end-4 top-4 z-10',\n // On the band the button takes the band's inverse ink — only\n // when a header is there to paint the band. The extra\n // data-slot keeps this above Button's own dark ink at any\n // emission order.\n 'group-data-[variant=band]/dialog-content:group-has-[[data-slot=dialog-header]]/dialog-content:data-[slot=dialog-close]:[--btn-bg:var(--text-inverse)]',\n )}\n />\n }\n >\n <IconClose />\n </DialogPrimitive.Close>\n )}\n {children}\n </DialogPrimitive.Popup>\n </DialogPortal>\n )\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='dialog-header'\n className={cn(\n // default: bleeds to the popup's edges and is divided off by a hairline.\n '-mx-6 -mt-6 flex flex-col gap-2 border-b border-border px-6 pt-6 pb-5',\n // band: the same bleed, painted as a solid band instead of divided.\n 'group-data-[variant=band]/dialog-content:border-b-0 group-data-[variant=band]/dialog-content:bg-primary group-data-[variant=band]/dialog-content:pb-6 group-data-[variant=band]/dialog-content:text-primary-foreground',\n // rule: no bleed — the title carries its own hairline instead.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mt-0 group-data-[variant=rule]/dialog-content:border-b-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:pt-0 group-data-[variant=rule]/dialog-content:pb-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogFooter({\n className,\n showCloseButton = false,\n closeLabel = 'Close',\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n /** Appends an outline Close button after the footer's own actions. */\n showCloseButton?: boolean\n /** Visible label of that Close button. Override to translate it. */\n closeLabel?: string\n}) {\n return (\n <div\n data-slot='dialog-footer'\n className={cn(\n // Stacked with the primary action on top below `sm`, a row aligned to\n // the end from `sm` up. `max-sm:` rather than a bare `flex-col-reverse`\n // keeps the pair cascade-safe (see check:cascade).\n 'flex gap-2 max-sm:flex-col-reverse sm:flex-row sm:justify-end',\n // default: bleeds to the popup's edges above a hairline.\n '-mx-6 -mb-6 border-t border-border px-6 py-4',\n // band: the same bleed on a subtle band instead of a hairline.\n 'group-data-[variant=band]/dialog-content:border-t-0 group-data-[variant=band]/dialog-content:bg-muted',\n // rule: no bleed, actions aligned to the start.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mb-0 group-data-[variant=rule]/dialog-content:border-t-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:py-0 group-data-[variant=rule]/dialog-content:sm:justify-start',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close render={<Button variant='outline' />}>\n {closeLabel}\n </DialogPrimitive.Close>\n )}\n </div>\n )\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n return (\n <DialogPrimitive.Title\n data-slot='dialog-title'\n className={cn(\n 'font-heading text-2xl font-medium text-foreground',\n // Inverse ink only inside the band — a title placed in the body stays\n // on the popover and must keep the default ink.\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n 'group-data-[variant=rule]/dialog-content:border-b group-data-[variant=rule]/dialog-content:border-foreground group-data-[variant=rule]/dialog-content:pb-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {\n return (\n <DialogPrimitive.Description\n data-slot='dialog-description'\n className={cn(\n 'text-base/relaxed text-muted-foreground',\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n dialogContentVariants,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n}\nexport type { DialogVariant }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/dialog.tsx"],"names":["DialogPrimitive"],"mappings":";;;;;;;;;AAYA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAA+B;AACxD,EAAA,2BAAQA,QAAA,CAAgB,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC7D;AAEA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAkC;AAClE,EAAA,2BAAQA,QAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC9D,EAAA,2BAAQA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AACpE;AAEA,SAAS,YAAA,CAAa,EAAE,QAAA,EAAU,GAAG,OAAM,EAAiC;AAC1E,EAAA,uBACE,GAAA,CAACA,QAAA,CAAgB,MAAA,EAAhB,EAAuB,WAAA,EAAU,eAAA,EAAiB,GAAG,KAAA,EAEpD,QAAA,kBAAA,GAAA,CAAC,mBAAA,EAAA,EAAqB,QAAA,EAAS,CAAA,EACjC,CAAA;AAEJ;AAyBA,MAAM,qBAAA,GAAwB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QACA,eAAA,oBACC,GAAA,CAACA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,MAAA,kBAAQ,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAQ,SAAA,EAAU,CAAA,EACtD,QAAA,EAAA,UAAA,EACH;AAAA;AAAA;AAAA,GAEJ;AAEJ;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,mDAAA;AAAA;AAAA;AAAA,QAGA,+FAAA;AAAA,QACA,4JAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,iBAAA,CAAkB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAsC;AACrF,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,yCAAA;AAAA,QACA,+FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"dialog.js","sourcesContent":["'use client'\n\nimport { Dialog as DialogPrimitive } from '@base-ui/react/dialog'\nimport { cva } from 'class-variance-authority'\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 { overlayInk, overlayScrim } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Dialog({ ...props }: DialogPrimitive.Root.Props) {\n return <DialogPrimitive.Root data-slot='dialog' {...props} />\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n return <DialogPrimitive.Trigger data-slot='dialog-trigger' {...props} />\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n return <DialogPrimitive.Close data-slot='dialog-close' {...props} />\n}\n\nfunction DialogPortal({ children, ...props }: DialogPrimitive.Portal.Props) {\n return (\n <DialogPrimitive.Portal data-slot='dialog-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </DialogPrimitive.Portal>\n )\n}\n\n/**\n * The three approved looks (design-shotgun, overlays-20260923):\n *\n * - `default` (Hairline): a flat raised surface drawn with a 1px ring; the\n * header and footer bleed to the edges and are divided off by hairlines.\n * - `band`: the header is a solid band in the action colour with an inverse\n * title; the footer sits on a subtle band.\n * - `rule`: a 4px rule in the ink colour caps the top edge, the title sits on\n * a hairline in the text colour, and the actions align to the start.\n *\n * None casts a shadow and none blurs the page behind — depth is drawn, per\n * DESIGN.md's Hairline Rule. Parts read the variant from `data-variant` on\n * the popup through `group-data-*`, so there is no context to thread.\n */\ntype DialogVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes and its look. The parts (header, footer, title,\n * description, close button) read the look from `data-variant` through\n * `group-data-*` instead: cva sees only its own props, not an ancestor's.\n * Radius sits in every branch, not the base, so rule's square top never\n * competes with a base `rounded-md` at equal specificity.\n */\nconst dialogContentVariants = cva(\n // `w-[calc(100%-2rem)]` + `max-w-lg` rather than shadcn's\n // `max-w-[calc(100%-2rem)] sm:max-w-sm`: two different properties, so there\n // is no bare/responsive pair for a consumer's build to reorder (see\n // check:cascade).\n 'group/dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-6 overflow-y-auto bg-popover p-6 text-base/relaxed text-popover-foreground ring-1 ring-foreground/10 outline-hidden transition-[opacity,scale] duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0',\n {\n variants: {\n variant: {\n default: 'rounded-md',\n band: 'rounded-md',\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--overlay-ink)',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n)\n\nfunction DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {\n return (\n <DialogPrimitive.Backdrop\n data-slot='dialog-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\nfunction DialogContent({\n className,\n children,\n variant = 'default',\n showCloseButton = true,\n closeLabel = 'Close',\n ...props\n}: DialogPrimitive.Popup.Props & {\n variant?: DialogVariant\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 return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Popup\n data-slot='dialog-content'\n data-variant={variant}\n className={cn(\n dialogContentVariants({ variant }),\n // The ink rule's cap is drawn in (see overlayInk).\n overlayInk,\n // The header rules below match it at any depth, not only as a direct\n // child: an edit dialog usually wraps its content in a <form>.\n // A header with nothing below it draws no divider over empty space.\n '[&_[data-slot=dialog-header]:last-child]:border-b-0',\n // Keep a long title clear of the absolutely-positioned close button:\n // 72px where the header bleeds to the edge (24px gutter + the 48px\n // the button needs), 48px under `rule`, whose header does not bleed.\n '[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-18 data-[variant=rule]:[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-12',\n // With no header at all, the first content after the close button\n // reserves the button's 48px instead, so its text cannot run under it.\n '[&>[data-slot=dialog-close]+:not([data-slot=dialog-header]):not(:has([data-slot=dialog-header]))]:pe-12',\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). Base UI focuses the first tabbable\n element on open; after the content, that is a footer button, and a\n long dialog opens scrolled to the bottom with the reader past\n everything above it. */}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot='dialog-close'\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className={cn(\n // z-20, as Sheet's: the button comes first in the DOM, and\n // equal z-indexes paint in DOM order, so any later positioned\n // child in the corner (a Button is `relative`) would paint\n // over it and take its clicks. z-20 clears children up to and\n // including the conventional sticky-header z-10.\n 'absolute end-4 top-4 z-20',\n // On the band the button takes the band's inverse ink — only\n // when a header is there to paint the band. The extra\n // data-slot keeps this above Button's own dark ink at any\n // emission order.\n 'group-data-[variant=band]/dialog-content:group-has-[[data-slot=dialog-header]]/dialog-content:data-[slot=dialog-close]:[--btn-bg:var(--text-inverse)]',\n )}\n />\n }\n >\n <IconClose />\n </DialogPrimitive.Close>\n )}\n {children}\n </DialogPrimitive.Popup>\n </DialogPortal>\n )\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='dialog-header'\n className={cn(\n // default: bleeds to the popup's edges and is divided off by a hairline.\n '-mx-6 -mt-6 flex flex-col gap-2 border-b border-border px-6 pt-6 pb-5',\n // band: the same bleed, painted as a solid band instead of divided.\n 'group-data-[variant=band]/dialog-content:border-b-0 group-data-[variant=band]/dialog-content:bg-primary group-data-[variant=band]/dialog-content:pb-6 group-data-[variant=band]/dialog-content:text-primary-foreground',\n // rule: no bleed — the title carries its own hairline instead.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mt-0 group-data-[variant=rule]/dialog-content:border-b-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:pt-0 group-data-[variant=rule]/dialog-content:pb-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogFooter({\n className,\n showCloseButton = false,\n closeLabel = 'Close',\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n /** Appends an outline Close button after the footer's own actions. */\n showCloseButton?: boolean\n /** Visible label of that Close button. Override to translate it. */\n closeLabel?: string\n}) {\n return (\n <div\n data-slot='dialog-footer'\n className={cn(\n // Stacked with the primary action on top below `sm`, a row aligned to\n // the end from `sm` up. `max-sm:` rather than a bare `flex-col-reverse`\n // keeps the pair cascade-safe (see check:cascade).\n 'flex gap-2 max-sm:flex-col-reverse sm:flex-row sm:justify-end',\n // default: bleeds to the popup's edges above a hairline.\n '-mx-6 -mb-6 border-t border-border px-6 py-4',\n // band: the same bleed on a subtle band instead of a hairline.\n 'group-data-[variant=band]/dialog-content:border-t-0 group-data-[variant=band]/dialog-content:bg-muted',\n // rule: no bleed, actions aligned to the start.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mb-0 group-data-[variant=rule]/dialog-content:border-t-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:py-0 group-data-[variant=rule]/dialog-content:sm:justify-start',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close render={<Button variant='outline' />}>\n {closeLabel}\n </DialogPrimitive.Close>\n )}\n </div>\n )\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n return (\n <DialogPrimitive.Title\n data-slot='dialog-title'\n className={cn(\n 'font-heading text-2xl font-medium text-foreground',\n // Inverse ink only inside the band — a title placed in the body stays\n // on the popover and must keep the default ink.\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n 'group-data-[variant=rule]/dialog-content:border-b group-data-[variant=rule]/dialog-content:border-foreground group-data-[variant=rule]/dialog-content:pb-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {\n return (\n <DialogPrimitive.Description\n data-slot='dialog-description'\n className={cn(\n 'text-base/relaxed text-muted-foreground',\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n dialogContentVariants,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n}\nexport type { DialogVariant }\n"]}
|
|
@@ -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;A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AAAA;AAAA;AAAA;AACH,GAAA,EACF,CAAA;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,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 SheetTrigger,\n}\n"]}
|
|
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,EAAA,2BAAQA,MAAA,CAAe,KAAA,EAAf,EAAqB,WAAA,EAAU,aAAA,EAAe,GAAG,KAAA,EAAO,CAAA;AAClE;AAEA,SAAS,WAAA,CAAY,EAAE,QAAA,EAAU,GAAG,OAAM,EAAgC;AACxE,EAAA,uBACE,GAAA,CAACA,MAAA,CAAe,MAAA,EAAf,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAElD,QAAA,kBAAA,GAAA,CAAC,mBAAA,EAAA,EAAqB,QAAA,EAAS,CAAA,EACjC,CAAA;AAEJ;AAEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AAC5E,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA,CAAe,QAAA;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,8GAAA;AAAA,QACA,YAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAmBA,SAAS,YAAA,CAAa;AAAA,EACpB,SAAA;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AAA,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 *\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"]}
|