@nswds/ui 8.3.1 → 8.3.2
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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nswds/ui",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"description": "UI components for NSW Government digital products, providing reusable design elements and patterns for consistent user interfaces.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/digitalnsw/nswds-ui#readme",
|