@nswds/ui 9.5.0 → 9.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/components/alert-dialog.js +2 -2
  2. package/dist/components/alert-dialog.js.map +1 -1
  3. package/dist/components/button-group.d.ts +2 -2
  4. package/dist/components/button-group.js.map +1 -1
  5. package/dist/components/combobox.js +2 -2
  6. package/dist/components/combobox.js.map +1 -1
  7. package/dist/components/component-preview.d.ts +7 -5
  8. package/dist/components/component-preview.js +53 -7
  9. package/dist/components/component-preview.js.map +1 -1
  10. package/dist/components/dialog.js +2 -2
  11. package/dist/components/dialog.js.map +1 -1
  12. package/dist/components/drawer.js +2 -2
  13. package/dist/components/drawer.js.map +1 -1
  14. package/dist/components/dropdown-menu.js +2 -2
  15. package/dist/components/dropdown-menu.js.map +1 -1
  16. package/dist/components/hover-card.js +2 -2
  17. package/dist/components/hover-card.js.map +1 -1
  18. package/dist/components/input-otp.js +4 -1
  19. package/dist/components/input-otp.js.map +1 -1
  20. package/dist/components/native-select.js +10 -2
  21. package/dist/components/native-select.js.map +1 -1
  22. package/dist/components/navigation-menu.js +2 -1
  23. package/dist/components/navigation-menu.js.map +1 -1
  24. package/dist/components/popover.js +2 -2
  25. package/dist/components/popover.js.map +1 -1
  26. package/dist/components/select.js +12 -4
  27. package/dist/components/select.js.map +1 -1
  28. package/dist/components/sheet.js +2 -2
  29. package/dist/components/sheet.js.map +1 -1
  30. package/dist/components/site-search.js +2 -2
  31. package/dist/components/site-search.js.map +1 -1
  32. package/dist/components/toggle.js +12 -2
  33. package/dist/components/toggle.js.map +1 -1
  34. package/dist/components/tooltip.js +2 -2
  35. package/dist/components/tooltip.js.map +1 -1
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/lib/portal-boundary.d.ts +47 -0
  39. package/dist/lib/portal-boundary.js +24 -0
  40. package/dist/lib/portal-boundary.js.map +1 -0
  41. package/dist/styles.css +1 -1
  42. package/package.json +1 -1
@@ -3,8 +3,8 @@ import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { AlertDialog as AlertDialog$1 } from '@base-ui/react/alert-dialog';
4
4
  import { cva } from 'class-variance-authority';
5
5
  import { Button } from '../components/button.js';
6
- import { ButtonGroupBoundary } from '../lib/button-group-context.js';
7
6
  import { overlayScrim, overlayDanger, overlayInk } from '../lib/overlay.js';
7
+ import { PortalBoundary } from '../lib/portal-boundary.js';
8
8
  import { cn } from '../lib/utils.js';
9
9
 
10
10
  function AlertDialog({ ...props }) {
@@ -14,7 +14,7 @@ function AlertDialogTrigger({ ...props }) {
14
14
  return /* @__PURE__ */ jsx(AlertDialog$1.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
15
15
  }
16
16
  function AlertDialogPortal({ children, ...props }) {
17
- return /* @__PURE__ */ jsx(AlertDialog$1.Portal, { "data-slot": "alert-dialog-portal", ...props, children: /* @__PURE__ */ jsx(ButtonGroupBoundary, { children }) });
17
+ return /* @__PURE__ */ jsx(AlertDialog$1.Portal, { "data-slot": "alert-dialog-portal", ...props, children: /* @__PURE__ */ jsx(PortalBoundary, { children }) });
18
18
  }
19
19
  const alertDialogContentVariants = cva(
20
20
  "group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] -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",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/alert-dialog.tsx"],"names":["AlertDialogPrimitive"],"mappings":";;;;;;;;AAkBA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAoC;AAClE,EAAA,2BAAQA,aAAA,CAAqB,IAAA,EAArB,EAA0B,WAAA,EAAU,cAA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E,EAAA,uBACE,GAAA;AAAA,IAACA,aAAA,CAAqB,KAAA;AAAA,IAArB;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,MAAA,kBAAQ,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAkB,MAAY,KAAA,EAAc,CAAA;AAAA,MAC3D,GAAG;AAAA;AAAA,GACN;AAEJ","file":"alert-dialog.js","sourcesContent":["'use client'\n\nimport { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { overlayDanger, overlayInk, overlayScrim } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * A modal that interrupts the user to confirm or cancel a consequential\n * action. Unlike `Dialog` it has no close button and does not dismiss on an\n * outside click, and Base UI gives the popup `role=\"alertdialog\"`. Escape\n * still closes it, so treat Escape as Cancel: never make closing the dialog\n * perform the action.\n */\nfunction AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {\n return <AlertDialogPrimitive.Root data-slot='alert-dialog' {...props} />\n}\n\nfunction AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {\n return <AlertDialogPrimitive.Trigger data-slot='alert-dialog-trigger' {...props} />\n}\n\nfunction AlertDialogPortal({ children, ...props }: AlertDialogPrimitive.Portal.Props) {\n return (\n <AlertDialogPrimitive.Portal data-slot='alert-dialog-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </AlertDialogPrimitive.Portal>\n )\n}\n\n/**\n * The same three looks as `DialogVariant` (design-shotgun, overlays-20260923):\n * `default` (Hairline), `band` and `rule`. Under `band` and `rule` the colour\n * follows the decision: a destructive confirm takes the danger ramp (a red\n * band, a red rule), any other takes the action colour — so a \"Sign out?\"\n * never borrows the alarm of a \"Delete?\". A confirm counts as destructive when\n * its `AlertDialogAction` is `color='danger'`, which is detected; if the danger\n * button is anything else (a plain `Button`, a `ButtonLink`), say so with\n * `tone='danger'` on `AlertDialogContent`.\n * No shadow, no backdrop blur — depth is drawn (DESIGN.md, The Hairline Rule).\n */\ntype AlertDialogVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes, its size and its look. The parts read the look\n * from `data-variant` (and the size from `data-size`) through `group-data-*`:\n * cva sees only its own props, not an ancestor's. Radius sits in every branch,\n * not the base, so rule's square top never ties with a base `rounded-md`.\n */\nconst alertDialogContentVariants = cva(\n 'group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] -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 size: {\n default: 'max-w-lg',\n sm: 'max-w-sm',\n },\n variant: {\n default: 'rounded-md',\n band: 'rounded-md',\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--alert-dialog-ink)',\n },\n },\n defaultVariants: { size: 'default', variant: 'default' },\n },\n)\n\nfunction AlertDialogOverlay({ className, ...props }: AlertDialogPrimitive.Backdrop.Props) {\n return (\n <AlertDialogPrimitive.Backdrop\n data-slot='alert-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 AlertDialogContent({\n className,\n size = 'default',\n variant = 'default',\n tone,\n ...props\n}: AlertDialogPrimitive.Popup.Props & {\n /** `sm` narrows the popup and splits the footer into two equal buttons. */\n size?: 'default' | 'sm'\n variant?: AlertDialogVariant\n /**\n * Marks the confirm destructive for the `band` and `rule` looks. Only needed\n * when the danger button is not an `AlertDialogAction color='danger'`,\n * which is detected on its own.\n */\n tone?: 'default' | 'danger'\n}) {\n return (\n <AlertDialogPortal>\n <AlertDialogOverlay />\n <AlertDialogPrimitive.Popup\n data-slot='alert-dialog-content'\n data-size={size}\n data-variant={variant}\n data-tone={tone}\n className={cn(\n alertDialogContentVariants({ variant, size }),\n // The decision's colour, read by the band and the rule: the action\n // colour, or danger when the confirming action is a danger button.\n // Danger bands use the shared danger pairing (see overlayDanger) —\n // the same red as the danger action beside it.\n overlayDanger,\n '[--alert-dialog-band-text:var(--text-inverse)] [--alert-dialog-band:var(--action-default)] has-[[data-slot=alert-dialog-action][data-color=danger]]:[--alert-dialog-band-text:var(--overlay-danger-text)] has-[[data-slot=alert-dialog-action][data-color=danger]]:[--alert-dialog-band:var(--overlay-danger)] data-[tone=danger]:[--alert-dialog-band-text:var(--overlay-danger-text)] data-[tone=danger]:[--alert-dialog-band:var(--overlay-danger)]',\n overlayInk,\n '[--alert-dialog-ink:var(--overlay-ink)] has-[[data-slot=alert-dialog-action][data-color=danger]]:[--alert-dialog-ink:var(--danger-solid)] data-[tone=danger]:[--alert-dialog-ink:var(--danger-solid)]',\n className,\n )}\n {...props}\n />\n </AlertDialogPortal>\n )\n}\n\nfunction AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='alert-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 items-start gap-2 border-b border-border px-6 pt-6 pb-5',\n // band: the same bleed, painted in the decision's colour.\n 'group-data-[variant=band]/alert-dialog-content:border-b-0 group-data-[variant=band]/alert-dialog-content:bg-(--alert-dialog-band) group-data-[variant=band]/alert-dialog-content:pb-6 group-data-[variant=band]/alert-dialog-content:text-(--alert-dialog-band-text)',\n // rule: no bleed; a media glyph sits beside the title, not above it.\n 'group-data-[variant=rule]/alert-dialog-content:mx-0 group-data-[variant=rule]/alert-dialog-content:mt-0 group-data-[variant=rule]/alert-dialog-content:grid-cols-[auto_1fr] group-data-[variant=rule]/alert-dialog-content:gap-x-3 group-data-[variant=rule]/alert-dialog-content:border-b-0 group-data-[variant=rule]/alert-dialog-content:px-0 group-data-[variant=rule]/alert-dialog-content:pt-0 group-data-[variant=rule]/alert-dialog-content:pb-0 group-data-[variant=rule]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='alert-dialog-footer'\n className={cn(\n // `max-sm:` rather than a bare `flex-col-reverse` keeps the pair\n // cascade-safe (see check:cascade). The `sm` size is always a\n // two-column grid, at every width.\n 'flex gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 max-sm:flex-col-reverse sm:flex-row sm:justify-end',\n '-mx-6 -mb-6 border-t border-border px-6 py-4',\n 'group-data-[variant=band]/alert-dialog-content:border-t-0 group-data-[variant=band]/alert-dialog-content:bg-muted',\n 'group-data-[variant=rule]/alert-dialog-content:mx-0 group-data-[variant=rule]/alert-dialog-content:mb-0 group-data-[variant=rule]/alert-dialog-content:border-t-0 group-data-[variant=rule]/alert-dialog-content:px-0 group-data-[variant=rule]/alert-dialog-content:py-0 group-data-[variant=rule]/alert-dialog-content:sm:justify-start',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** An icon tile above the title — for a warning glyph on a destructive confirm, say. */\nfunction AlertDialogMedia({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='alert-dialog-media'\n className={cn(\n \"mb-2 inline-flex size-12 items-center justify-center rounded-md bg-foreground/10 text-foreground [&_svg:not([class*='size-'])]:size-6\",\n // band: the bare glyph in the band's inverse ink.\n 'group-data-[variant=band]/alert-dialog-content:mb-0 group-data-[variant=band]/alert-dialog-content:size-auto group-data-[variant=band]/alert-dialog-content:bg-transparent group-data-[variant=band]/alert-dialog-content:text-(--alert-dialog-band-text)',\n // rule: the bare glyph, in the decision's ink, beside the title.\n 'group-data-[variant=rule]/alert-dialog-content:mt-1 group-data-[variant=rule]/alert-dialog-content:mb-0 group-data-[variant=rule]/alert-dialog-content:size-auto group-data-[variant=rule]/alert-dialog-content:bg-transparent group-data-[variant=rule]/alert-dialog-content:text-(--alert-dialog-ink)',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogTitle({ className, ...props }: AlertDialogPrimitive.Title.Props) {\n return (\n <AlertDialogPrimitive.Title\n data-slot='alert-dialog-title'\n className={cn(\n 'font-heading text-2xl font-medium text-foreground',\n 'group-data-[variant=band]/alert-dialog-content:in-data-[slot=alert-dialog-header]:text-(--alert-dialog-band-text)',\n // rule: the title's hairline is the text colour, or danger on a\n // destructive confirm — the cap above carries the ink.\n 'group-data-[variant=rule]/alert-dialog-content:col-start-2 group-data-[variant=rule]/alert-dialog-content:self-stretch group-data-[variant=rule]/alert-dialog-content:border-b group-data-[variant=rule]/alert-dialog-content:border-foreground group-data-[variant=rule]/alert-dialog-content:pb-3 group-data-[variant=rule]/alert-dialog-content:group-has-[[data-slot=alert-dialog-action][data-color=danger]]/alert-dialog-content:border-destructive group-data-[variant=rule]/alert-dialog-content:group-data-[tone=danger]/alert-dialog-content:border-destructive',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogDescription({ className, ...props }: AlertDialogPrimitive.Description.Props) {\n return (\n <AlertDialogPrimitive.Description\n data-slot='alert-dialog-description'\n className={cn(\n 'text-base/relaxed text-muted-foreground',\n 'group-data-[variant=band]/alert-dialog-content:in-data-[slot=alert-dialog-header]:text-(--alert-dialog-band-text)',\n 'group-data-[variant=rule]/alert-dialog-content:col-start-2',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * The confirming action. A plain `Button` — it does NOT close the dialog on\n * its own, so the handler can run (and fail) first; close the dialog by\n * controlling `open` once it succeeds.\n *\n * It stamps its `color` as `data-color`, which is how the `band` and `rule`\n * variants know a confirm is destructive.\n */\nfunction AlertDialogAction(props: React.ComponentProps<typeof Button>) {\n return <Button data-slot='alert-dialog-action' data-color={props.color} {...props} />\n}\n\n/**\n * Closes the dialog without acting. Takes Button's `variant`, `size` and\n * `color` so it can match `AlertDialogAction`; `variant` defaults to outline.\n */\nfunction AlertDialogCancel({\n variant = 'outline',\n size,\n color,\n ...props\n}: Omit<AlertDialogPrimitive.Close.Props, 'color'> &\n Pick<React.ComponentProps<typeof Button>, 'variant' | 'size' | 'color'>) {\n return (\n <AlertDialogPrimitive.Close\n data-slot='alert-dialog-cancel'\n render={<Button variant={variant} size={size} color={color} />}\n {...props}\n />\n )\n}\n\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n alertDialogContentVariants,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogMedia,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger,\n}\nexport type { AlertDialogVariant }\n"]}
1
+ {"version":3,"sources":["../../src/components/alert-dialog.tsx"],"names":["AlertDialogPrimitive"],"mappings":";;;;;;;;AAkBA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAoC;AAClE,EAAA,2BAAQA,aAAA,CAAqB,IAAA,EAArB,EAA0B,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,kBAAA,CAAmB,EAAE,GAAG,KAAA,EAAM,EAAuC;AAC5E,EAAA,2BAAQA,aAAA,CAAqB,OAAA,EAArB,EAA6B,WAAA,EAAU,sBAAA,EAAwB,GAAG,KAAA,EAAO,CAAA;AACnF;AAEA,SAAS,iBAAA,CAAkB,EAAE,QAAA,EAAU,GAAG,OAAM,EAAsC;AACpF,EAAA,uBACE,GAAA,CAACA,aAAA,CAAqB,MAAA,EAArB,EAA4B,WAAA,EAAU,qBAAA,EAAuB,GAAG,KAAA,EAE/D,QAAA,kBAAA,GAAA,CAAC,cAAA,EAAA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AAA,CAAqB,KAAA;AAAA,IAArB;AAAA,MACC,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,mDAAA;AAAA,QACA,mHAAA;AAAA;AAAA;AAAA,QAGA,2iBAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,sBAAA,CAAuB,EAAE,SAAA,EAAW,GAAG,OAAM,EAA2C;AAC/F,EAAA,uBACE,GAAA;AAAA,IAACA,aAAA,CAAqB,WAAA;AAAA,IAArB;AAAA,MACC,WAAA,EAAU,0BAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,yCAAA;AAAA,QACA,mHAAA;AAAA,QACA,4DAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAUA,SAAS,kBAAkB,KAAA,EAA4C;AACrE,EAAA,uBAAO,GAAA,CAAC,UAAO,WAAA,EAAU,qBAAA,EAAsB,cAAY,KAAA,CAAM,KAAA,EAAQ,GAAG,KAAA,EAAO,CAAA;AACrF;AAMA,SAAS,iBAAA,CAAkB;AAAA,EACzB,OAAA,GAAU,SAAA;AAAA,EACV,IAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAG;AACL,CAAA,EAC2E;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,aAAA,CAAqB,KAAA;AAAA,IAArB;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,MAAA,kBAAQ,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAkB,MAAY,KAAA,EAAc,CAAA;AAAA,MAC3D,GAAG;AAAA;AAAA,GACN;AAEJ","file":"alert-dialog.js","sourcesContent":["'use client'\n\nimport { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { overlayDanger, overlayInk, overlayScrim } from '../lib/overlay.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * A modal that interrupts the user to confirm or cancel a consequential\n * action. Unlike `Dialog` it has no close button and does not dismiss on an\n * outside click, and Base UI gives the popup `role=\"alertdialog\"`. Escape\n * still closes it, so treat Escape as Cancel: never make closing the dialog\n * perform the action.\n */\nfunction AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {\n return <AlertDialogPrimitive.Root data-slot='alert-dialog' {...props} />\n}\n\nfunction AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {\n return <AlertDialogPrimitive.Trigger data-slot='alert-dialog-trigger' {...props} />\n}\n\nfunction AlertDialogPortal({ children, ...props }: AlertDialogPrimitive.Portal.Props) {\n return (\n <AlertDialogPrimitive.Portal data-slot='alert-dialog-portal' {...props}>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>{children}</PortalBoundary>\n </AlertDialogPrimitive.Portal>\n )\n}\n\n/**\n * The same three looks as `DialogVariant` (design-shotgun, overlays-20260923):\n * `default` (Hairline), `band` and `rule`. Under `band` and `rule` the colour\n * follows the decision: a destructive confirm takes the danger ramp (a red\n * band, a red rule), any other takes the action colour — so a \"Sign out?\"\n * never borrows the alarm of a \"Delete?\". A confirm counts as destructive when\n * its `AlertDialogAction` is `color='danger'`, which is detected; if the danger\n * button is anything else (a plain `Button`, a `ButtonLink`), say so with\n * `tone='danger'` on `AlertDialogContent`.\n * No shadow, no backdrop blur — depth is drawn (DESIGN.md, The Hairline Rule).\n */\ntype AlertDialogVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes, its size and its look. The parts read the look\n * from `data-variant` (and the size from `data-size`) through `group-data-*`:\n * cva sees only its own props, not an ancestor's. Radius sits in every branch,\n * not the base, so rule's square top never ties with a base `rounded-md`.\n */\nconst alertDialogContentVariants = cva(\n 'group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] -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 size: {\n default: 'max-w-lg',\n sm: 'max-w-sm',\n },\n variant: {\n default: 'rounded-md',\n band: 'rounded-md',\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--alert-dialog-ink)',\n },\n },\n defaultVariants: { size: 'default', variant: 'default' },\n },\n)\n\nfunction AlertDialogOverlay({ className, ...props }: AlertDialogPrimitive.Backdrop.Props) {\n return (\n <AlertDialogPrimitive.Backdrop\n data-slot='alert-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 AlertDialogContent({\n className,\n size = 'default',\n variant = 'default',\n tone,\n ...props\n}: AlertDialogPrimitive.Popup.Props & {\n /** `sm` narrows the popup and splits the footer into two equal buttons. */\n size?: 'default' | 'sm'\n variant?: AlertDialogVariant\n /**\n * Marks the confirm destructive for the `band` and `rule` looks. Only needed\n * when the danger button is not an `AlertDialogAction color='danger'`,\n * which is detected on its own.\n */\n tone?: 'default' | 'danger'\n}) {\n return (\n <AlertDialogPortal>\n <AlertDialogOverlay />\n <AlertDialogPrimitive.Popup\n data-slot='alert-dialog-content'\n data-size={size}\n data-variant={variant}\n data-tone={tone}\n className={cn(\n alertDialogContentVariants({ variant, size }),\n // The decision's colour, read by the band and the rule: the action\n // colour, or danger when the confirming action is a danger button.\n // Danger bands use the shared danger pairing (see overlayDanger) —\n // the same red as the danger action beside it.\n overlayDanger,\n '[--alert-dialog-band-text:var(--text-inverse)] [--alert-dialog-band:var(--action-default)] has-[[data-slot=alert-dialog-action][data-color=danger]]:[--alert-dialog-band-text:var(--overlay-danger-text)] has-[[data-slot=alert-dialog-action][data-color=danger]]:[--alert-dialog-band:var(--overlay-danger)] data-[tone=danger]:[--alert-dialog-band-text:var(--overlay-danger-text)] data-[tone=danger]:[--alert-dialog-band:var(--overlay-danger)]',\n overlayInk,\n '[--alert-dialog-ink:var(--overlay-ink)] has-[[data-slot=alert-dialog-action][data-color=danger]]:[--alert-dialog-ink:var(--danger-solid)] data-[tone=danger]:[--alert-dialog-ink:var(--danger-solid)]',\n className,\n )}\n {...props}\n />\n </AlertDialogPortal>\n )\n}\n\nfunction AlertDialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='alert-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 items-start gap-2 border-b border-border px-6 pt-6 pb-5',\n // band: the same bleed, painted in the decision's colour.\n 'group-data-[variant=band]/alert-dialog-content:border-b-0 group-data-[variant=band]/alert-dialog-content:bg-(--alert-dialog-band) group-data-[variant=band]/alert-dialog-content:pb-6 group-data-[variant=band]/alert-dialog-content:text-(--alert-dialog-band-text)',\n // rule: no bleed; a media glyph sits beside the title, not above it.\n 'group-data-[variant=rule]/alert-dialog-content:mx-0 group-data-[variant=rule]/alert-dialog-content:mt-0 group-data-[variant=rule]/alert-dialog-content:grid-cols-[auto_1fr] group-data-[variant=rule]/alert-dialog-content:gap-x-3 group-data-[variant=rule]/alert-dialog-content:border-b-0 group-data-[variant=rule]/alert-dialog-content:px-0 group-data-[variant=rule]/alert-dialog-content:pt-0 group-data-[variant=rule]/alert-dialog-content:pb-0 group-data-[variant=rule]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='alert-dialog-footer'\n className={cn(\n // `max-sm:` rather than a bare `flex-col-reverse` keeps the pair\n // cascade-safe (see check:cascade). The `sm` size is always a\n // two-column grid, at every width.\n 'flex gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 max-sm:flex-col-reverse sm:flex-row sm:justify-end',\n '-mx-6 -mb-6 border-t border-border px-6 py-4',\n 'group-data-[variant=band]/alert-dialog-content:border-t-0 group-data-[variant=band]/alert-dialog-content:bg-muted',\n 'group-data-[variant=rule]/alert-dialog-content:mx-0 group-data-[variant=rule]/alert-dialog-content:mb-0 group-data-[variant=rule]/alert-dialog-content:border-t-0 group-data-[variant=rule]/alert-dialog-content:px-0 group-data-[variant=rule]/alert-dialog-content:py-0 group-data-[variant=rule]/alert-dialog-content:sm:justify-start',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** An icon tile above the title — for a warning glyph on a destructive confirm, say. */\nfunction AlertDialogMedia({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='alert-dialog-media'\n className={cn(\n \"mb-2 inline-flex size-12 items-center justify-center rounded-md bg-foreground/10 text-foreground [&_svg:not([class*='size-'])]:size-6\",\n // band: the bare glyph in the band's inverse ink.\n 'group-data-[variant=band]/alert-dialog-content:mb-0 group-data-[variant=band]/alert-dialog-content:size-auto group-data-[variant=band]/alert-dialog-content:bg-transparent group-data-[variant=band]/alert-dialog-content:text-(--alert-dialog-band-text)',\n // rule: the bare glyph, in the decision's ink, beside the title.\n 'group-data-[variant=rule]/alert-dialog-content:mt-1 group-data-[variant=rule]/alert-dialog-content:mb-0 group-data-[variant=rule]/alert-dialog-content:size-auto group-data-[variant=rule]/alert-dialog-content:bg-transparent group-data-[variant=rule]/alert-dialog-content:text-(--alert-dialog-ink)',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogTitle({ className, ...props }: AlertDialogPrimitive.Title.Props) {\n return (\n <AlertDialogPrimitive.Title\n data-slot='alert-dialog-title'\n className={cn(\n 'font-heading text-2xl font-medium text-foreground',\n 'group-data-[variant=band]/alert-dialog-content:in-data-[slot=alert-dialog-header]:text-(--alert-dialog-band-text)',\n // rule: the title's hairline is the text colour, or danger on a\n // destructive confirm — the cap above carries the ink.\n 'group-data-[variant=rule]/alert-dialog-content:col-start-2 group-data-[variant=rule]/alert-dialog-content:self-stretch group-data-[variant=rule]/alert-dialog-content:border-b group-data-[variant=rule]/alert-dialog-content:border-foreground group-data-[variant=rule]/alert-dialog-content:pb-3 group-data-[variant=rule]/alert-dialog-content:group-has-[[data-slot=alert-dialog-action][data-color=danger]]/alert-dialog-content:border-destructive group-data-[variant=rule]/alert-dialog-content:group-data-[tone=danger]/alert-dialog-content:border-destructive',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AlertDialogDescription({ className, ...props }: AlertDialogPrimitive.Description.Props) {\n return (\n <AlertDialogPrimitive.Description\n data-slot='alert-dialog-description'\n className={cn(\n 'text-base/relaxed text-muted-foreground',\n 'group-data-[variant=band]/alert-dialog-content:in-data-[slot=alert-dialog-header]:text-(--alert-dialog-band-text)',\n 'group-data-[variant=rule]/alert-dialog-content:col-start-2',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * The confirming action. A plain `Button` — it does NOT close the dialog on\n * its own, so the handler can run (and fail) first; close the dialog by\n * controlling `open` once it succeeds.\n *\n * It stamps its `color` as `data-color`, which is how the `band` and `rule`\n * variants know a confirm is destructive.\n */\nfunction AlertDialogAction(props: React.ComponentProps<typeof Button>) {\n return <Button data-slot='alert-dialog-action' data-color={props.color} {...props} />\n}\n\n/**\n * Closes the dialog without acting. Takes Button's `variant`, `size` and\n * `color` so it can match `AlertDialogAction`; `variant` defaults to outline.\n */\nfunction AlertDialogCancel({\n variant = 'outline',\n size,\n color,\n ...props\n}: Omit<AlertDialogPrimitive.Close.Props, 'color'> &\n Pick<React.ComponentProps<typeof Button>, 'variant' | 'size' | 'color'>) {\n return (\n <AlertDialogPrimitive.Close\n data-slot='alert-dialog-cancel'\n render={<Button variant={variant} size={size} color={color} />}\n {...props}\n />\n )\n}\n\nexport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n alertDialogContentVariants,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogMedia,\n AlertDialogOverlay,\n AlertDialogPortal,\n AlertDialogTitle,\n AlertDialogTrigger,\n}\nexport type { AlertDialogVariant }\n"]}
@@ -87,8 +87,8 @@ type ButtonGroupProps = Omit<React.ComponentProps<'div'>, 'color'> & VariantProp
87
87
  * A popup opened from a segment (a split button's menu) renders through a
88
88
  * portal, which React context follows. Every popup in this package resets the
89
89
  * group context at its portal, so the Buttons inside render normally; wrap
90
- * the contents of an overlay from another library in `ButtonGroupBoundary`
91
- * to get the same. Without that reset a Button inside the popup renders as a
90
+ * the contents of an overlay from another library in `PortalBoundary` (or in
91
+ * `ButtonGroupBoundary`, which does only this reset) to get the same. Without that reset a Button inside the popup renders as a
92
92
  * segment of the group it was opened from, and on a solid band that means its
93
93
  * label takes the band's colour — white on the popup's own surface.
94
94
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/button-group.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAiBA,MAAM,qBAAA,GAAwB,SAAA;AAC9B,MAAM,yBAAA,GAA4B,YAAA;AAqClC,MAAM,mBAAA,GAAsB,GAAA;AAAA,EAC1B;AAAA,IACE,oEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAoBA,sEAAA;AAAA,IACA,oEAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,iCAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmCA,qGAAA;AAAA,I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oBAAA,CAAqB;AAAA,EAC5B,SAAA;AAAA,EACA,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA2C;AACzC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,UAAA,CAAW,kBAAkB,CAAA;AACjD,EAAA,MAAM,mBAAA,GACJ,WAAA,KAAgB,KAAA,EAAO,WAAA,KAAgB,aAAa,YAAA,GAAe,UAAA,CAAA;AAErE,EAAA,uBACE,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,WAAA,EAAa,mBAAA;AAAA,MACb,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA,QAIT,+FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"button-group.js","sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport {\n ButtonGroupBoundary,\n ButtonGroupContext,\n type ButtonGroupContextValue,\n} from '../lib/button-group-context.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\nimport { buttonColorVariants, type ButtonProps } from './button.js'\nimport { Separator } from './separator.js'\n\nconst DEFAULT_GROUP_VARIANT = 'outline' as const\nconst DEFAULT_GROUP_ORIENTATION = 'horizontal' as const\n\n/**\n * The group owns the boundary. It draws the frame or the band, the hairline\n * between segments and the 4px corners, and it clips its children to that\n * radius — so a segment never computes a corner of its own. The segments are\n * ordinary Buttons: they read `ButtonGroupContext` and give up the chrome the\n * group now draws (see `styles.segment` in button.tsx).\n *\n * This replaces a wrapper that collapsed borders through `[data-slot]` child\n * selectors copied from shadcn. Button never emitted `data-slot`, so none of\n * those rules matched: every Button kept its own 2px outline and 4px corners,\n * and neighbours met with a 4px doubled border.\n *\n * Every colour is Button's own `--btn-fill` / `--btn-bg` / `--btn-text` pair,\n * applied to the group by `buttonColorVariants`, so a group's `color` means\n * what a Button's does: the ink flips for dark mode the same way, and on a\n * soft or surface band it steps to the darker ink those tints need the same\n * way (`styles.tintInk` in button.tsx). The segments learn they sit on that\n * tint from the `band` the context carries, and step their own colour's ink,\n * so a segment naming another colour keeps it. Hairlines take the text\n * colour, per the masterbrand's line system. These classes therefore only\n * paint on an element that also carries `buttonColorVariants` —\n * `ring-(--btn-bg)` is invalid without it — so a consumer extending the\n * group's styling applies the two together, as `ButtonGroup` does.\n *\n * Two kinds of rule reach a segment. What depends on the segment's\n * NEIGHBOURS — dividers, seams, the text cell — lives here and uses the CHILD\n * combinator (`&>`) and sibling combinators, so it needs the segments to be\n * direct children. What depends only on the BAND — the re-ink on a solid\n * band, the frame-revealing `bg-clip-padding` — lives on the segment itself,\n * keyed on the `data-band` the group tells it through context, so it holds\n * for a segment rendered through a trigger's `render` prop or wrapped in a\n * span. Never a descendant rule: a group is not meant to nest, but if one\n * ever does, a descendant rule from the outer band would re-ink the inner\n * group's segments.\n */\nconst buttonGroupVariants = cva(\n [\n 'isolate inline-flex w-fit items-stretch overflow-hidden rounded-sm',\n // `items-stretch` above is what makes every segment the same size across\n // the group's cross axis — except an icon-only one, which `styles.iconOnly`\n // squares with `size-(--btn-h)`. A definite cross size is precisely the\n // case flexbox does NOT stretch (CSS Flexbox §9.4: stretch applies only\n // when the cross-size property computes to `auto`), so the square holds its\n // 52px whatever the segments beside it do. In a column that is every mixed\n // group: a 52px square in a 135px band, with a void beside it and the\n // hairline above it stopping a third of the way across. In a row it needs a\n // label to wrap first, which `min-h-(--btn-h)` on the button explicitly\n // allows — a floor, not a fixed height — and then the square sits at the\n // top of a 136px row.\n //\n // So the group releases the cross dimension and lets `items-stretch` do its\n // work, keeping the main one: the square stays a square whenever its\n // neighbours are one line tall, and grows with them when they are not.\n // Keyed on the group's own orientation, so neither rule is a bare utility\n // the other has to override, and reached through the child combinator, so\n // a nested icon button (inside a popup opened from a segment, say) is not\n // touched. (0,3,0) against `size-(--btn-h)`'s (0,1,0).\n 'data-[orientation=horizontal]:[&>[data-slot][data-icon-only]]:h-auto',\n 'data-[orientation=vertical]:[&>[data-slot][data-icon-only]]:w-auto',\n // The band's label colour, resolved HERE from the group's own colour\n // token and inherited by every segment as a computed value. A segment on\n // a solid band re-points its ink to this (see `styles.segment` in\n // button.tsx); publishing it from the group is what stops a segment that\n // names its own `color` from reading its own `--btn-text` instead.\n '[--group-label:var(--btn-text)]',\n // Dividers. A Button or ButtonGroupText carries `data-slot` and a 1px\n // transparent border, so the divider is that border recoloured on the\n // shared edge: no extra pixel, and the group's outer box stays exactly\n // one button tall. (ButtonGroupSeparator carries `data-slot` too but no\n // border and no size, so the hairline beside it is drawn by the segment\n // after it.) Keyed on orientation both ways so neither rule is a bare\n // utility the other overrides, and written as `[data-slot]~[data-slot]`\n // for specificity: Button's `dark:border-white/5` is a border-color\n // SHORTHAND at (0,2,0), and this longhand only beats it by specificity,\n // never by emission order (AGENTS.md §4, the two-build cascade).\n //\n // `loading` reaches these rules as well as `disabled`: Button derives\n // `disabled` from either, so a busy segment is a disabled one here. The\n // boundary therefore moves by a pixel when a request starts, which is the\n // contract holding rather than breaking — the alternative is a\n // half-strength hairline beside an enabled control for as long as the\n // request runs. `Segment Props` pins it.\n //\n // A disabled segment fades itself with `opacity-50`, and a divider drawn\n // on its own leading edge would fade with it — leaving one weak hairline\n // in an otherwise full-strength row, right where the eye reads the join.\n // So the boundary before a disabled segment is drawn on the trailing edge\n // of the segment BEFORE it instead, and the disabled segment's own\n // leading edge stays transparent. A separator between the two has no edge\n // to paint, so the rule also looks through one.\n //\n // The one hairline this does NOT lift out of the fade is the one BETWEEN\n // two adjacent disabled segments: its only available edge belongs to a\n // disabled element either way, so it renders at 50% like the pair it\n // divides. That is the coherent reading — the whole run is unavailable,\n // and a full-strength line inside it would draw more attention than the\n // controls do — and lifting it would mean moving dividers off the\n // segments entirely, onto a layer the group owns. `Disabled` renders the\n // case and pins where each edge lands.\n 'data-[orientation=horizontal]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-s-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-t-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-b-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-b-(--divider)',\n // Two solid segments side by side (a split button): the ink divider would\n // vanish on the fill, so the seam is a reversed hairline in the label\n // colour. Above the general divider on specificity, with the same\n // disabled handling, and again looking through a separator.\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n ],\n {\n variants: {\n variant: {\n // A 1px hairline frame in the ink, drawn as an inset ring so it adds\n // no height: the group is exactly as tall as a lone Button beside it.\n // No fill of its own, like Button's outline: the surface shows\n // through, so a `white` outline group on a dark panel stays a frame.\n // Forced-colours mode discards box shadows, so the frame is restated\n // there as an outline, which that mode keeps and recolours. The text\n // cell stops its background at the padding box so the frame shows\n // through its transparent border.\n outline: [\n 'ring-1 ring-(--btn-bg) [--divider:var(--btn-bg)] ring-inset',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-clip-padding',\n ],\n // The band. Segments re-ink themselves on it (see `styles.segment` in\n // button.tsx); the text cell sits on the band in its label colour, at\n // the label weight so it reads as a label rather than as another\n // button.\n solid: [\n 'bg-(--btn-fill) [--divider:color-mix(in_oklab,var(--btn-text)_30%,transparent)]',\n '[&>[data-slot=button-group-text]]:bg-transparent [&>[data-slot=button-group-text]]:font-medium [&>[data-slot=button-group-text]]:text-(--btn-text)',\n ],\n // Button's soft pair — ink at 10%, 20% in dark — as a band. The text\n // cell sits on the band.\n soft: 'bg-(--btn-bg)/10 [--divider:color-mix(in_oklab,var(--btn-bg)_30%,transparent)] dark:bg-(--btn-bg)/20 [&>[data-slot=button-group-text]]:bg-transparent',\n // Button's surface pair: ink at 5% inside an ink/50 hairline, restated\n // as an outline for forced colours like the outline frame.\n surface: [\n 'bg-(--btn-bg)/5 ring-1 ring-(--btn-bg)/50 [--divider:color-mix(in_oklab,var(--btn-bg)_50%,transparent)] ring-inset dark:bg-(--btn-bg)/30',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-transparent',\n ],\n // No frame, no fill: only the hairlines between segments remain.\n ghost: '[--divider:var(--btn-bg)]',\n },\n orientation: {\n horizontal: 'flex-row',\n vertical: 'flex-col',\n },\n },\n defaultVariants: {\n variant: DEFAULT_GROUP_VARIANT,\n orientation: DEFAULT_GROUP_ORIENTATION,\n },\n },\n)\n\n/** The group variants a ButtonGroup can paint. `link` has no group form. */\ntype ButtonGroupVariant = NonNullable<VariantProps<typeof buttonGroupVariants>['variant']>\n\ntype ButtonGroupProps = Omit<React.ComponentProps<'div'>, 'color'> &\n VariantProps<typeof buttonGroupVariants> & {\n /**\n * Colour token, with Button's meaning: `primary` by default. Sets the\n * ink the frame, band and dividers are drawn in, and the default colour\n * of every segment.\n */\n color?: ButtonProps['color']\n /**\n * Scale step, with Button's meaning. The default size of every segment.\n * `icon` is not offered: it is a 40px chrome square, and the group clips\n * to its own box, so the 44px touch expansion Button adds on a coarse\n * pointer would be cut off. A segment that asks for `icon` anyway renders\n * as `iconOnly` at the group's own step, so it lines up with the segments\n * beside it.\n */\n size?: Exclude<ButtonProps['size'], 'icon'>\n }\n\n/**\n * Joins a row (or column) of Buttons into one control. Takes Button's variant\n * family — `outline` (the default), `solid`, `soft`, `surface`, `ghost` — and\n * its colour tokens and size steps, and hands them to its segments as\n * defaults. A segment may name its own emphasis: a `solid` Save inside an\n * outline group is the primary action of that row.\n *\n * Children are Buttons (or ButtonLinks), `ButtonGroupText` for an inline\n * label, and `ButtonGroupSeparator` for a semantic boundary, as DIRECT\n * children: the hairlines between segments are drawn on the segments' shared\n * edges, so a segment wrapped in another element (a span holding a tooltip\n * on a disabled segment, say) keeps its label and its band treatment but\n * loses the hairlines it shares with its neighbours — the one before it, and\n * the one after it too when the wrapped segment is the first child. It is a group of buttons, not a general\n * control frame — an input or select with an attached action is InputGroup's\n * job — and groups do not nest.\n *\n * A popup opened from a segment (a split button's menu) renders through a\n * portal, which React context follows. Every popup in this package resets the\n * group context at its portal, so the Buttons inside render normally; wrap\n * the contents of an overlay from another library in `ButtonGroupBoundary`\n * to get the same. Without that reset a Button inside the popup renders as a\n * segment of the group it was opened from, and on a solid band that means its\n * label takes the band's colour — white on the popup's own surface.\n */\nfunction ButtonGroup({\n className,\n variant,\n orientation,\n color,\n size,\n children,\n ...props\n}: ButtonGroupProps) {\n const resolvedVariant = resolveVariant(variant, DEFAULT_GROUP_VARIANT)\n const resolvedOrientation = resolveVariant(orientation, DEFAULT_GROUP_ORIENTATION)\n // `null` is admitted by both prop types (they borrow Button's, which allow\n // it) and is the idiomatic way to thread an optional prop through a\n // wrapper. cva reads it as \"no variant\" rather than \"unspecified\", so an\n // unnormalised `null` would emit no size or colour classes AT ALL — and\n // because a segment resolves `color ?? group.color`, one `null` on the\n // group would turn every child's own `undefined` into an explicit `null`\n // and un-style the whole row: no padding, no height, and a frame still\n // pointing at a `--btn-bg` nothing defines. Normalising here means the\n // group and its segments both fall back to the same cva defaults a lone\n // Button gets.\n const resolvedColor = color ?? undefined\n const resolvedSize = size ?? undefined\n const context = React.useMemo<ButtonGroupContextValue>(\n () => ({\n band: resolvedVariant,\n color: resolvedColor,\n size: resolvedSize,\n orientation: resolvedOrientation,\n }),\n [resolvedVariant, resolvedColor, resolvedSize, resolvedOrientation],\n )\n\n return (\n <div\n role='group'\n data-slot='button-group'\n className={cn(\n buttonColorVariants({ color: resolvedColor, variant: resolvedVariant }),\n buttonGroupVariants({ variant: resolvedVariant, orientation: resolvedOrientation }),\n className,\n )}\n {...props}\n // AFTER the spread, so that no prop can override these two — unlike\n // `data-slot` above, and unlike Button, which puts its own stamps first\n // so InputGroupButton can relabel them. `data-orientation` is what every\n // divider rule keys on, while the flex direction comes from the cva\n // variant and the separator's axis from the context — neither of which\n // a prop can reach. If a prop could override it, a row handed\n // `data-orientation='vertical'` would paint column dividers across\n // itself. Nothing in the package keys on `data-variant` (the band\n // treatment reaches the segments through `data-band` instead), but it is\n // the group's public description of itself, and stamped last it cannot\n // be made to contradict the variant the group actually paints. The\n // Segment Props play pins both. `data-slot` stays first because\n // relabelling a group is the same escape hatch Button offers.\n data-variant={resolvedVariant}\n data-orientation={resolvedOrientation}\n >\n <ButtonGroupContext.Provider value={context}>{children}</ButtonGroupContext.Provider>\n </div>\n )\n}\n\n/**\n * An inline label between segments — a unit, a count, a mode. Sits at the\n * body size (16px), never smaller: it shares a line with 16px button labels,\n * so anything below that reads as fine print. Semibold, the weight the\n * InputGroup addon uses for the same job. On a framed or ghost group it sits\n * on the sunken surface so it reads as chrome rather than as a button; on a\n * band it sits on the band, and a solid band gives it the band's label colour\n * at the label weight (see `buttonGroupVariants`).\n */\nfunction ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>) {\n return useRender({\n defaultTagName: 'div',\n props: mergeProps<'div'>(\n {\n className: cn(\n // The transparent border is what the group's divider recolours.\n 'flex items-center gap-2 border border-transparent bg-(--surface-sunken) px-4 text-base font-semibold text-muted-foreground select-none',\n // A glyph beside the text matches Button's 24px label glyph.\n \"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6\",\n className,\n ),\n },\n props,\n ),\n render,\n state: {\n slot: 'button-group-text',\n },\n })\n}\n\n/**\n * A semantic boundary between segments. Every segment is already divided by\n * a hairline, so the separator draws nothing of its own — it exists for\n * assistive technology, which hears it as a region boundary, and it follows\n * the group's orientation unless told otherwise.\n */\nfunction ButtonGroupSeparator({\n className,\n orientation,\n ...props\n}: React.ComponentProps<typeof Separator>) {\n const group = React.useContext(ButtonGroupContext)\n const resolvedOrientation =\n orientation ?? (group?.orientation === 'vertical' ? 'horizontal' : 'vertical')\n\n return (\n <Separator\n data-slot='button-group-separator'\n orientation={resolvedOrientation}\n className={cn(\n // Zero-size on its own axis and transparent: the hairline beside it\n // is the group's divider, not this element. Same variant keys as the\n // primitive's own sizing so tailwind-merge resolves them here.\n 'self-stretch bg-transparent data-[orientation=horizontal]:h-0 data-[orientation=vertical]:w-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n ButtonGroup,\n ButtonGroupBoundary,\n ButtonGroupSeparator,\n ButtonGroupText,\n buttonGroupVariants,\n}\nexport type { ButtonGroupProps, ButtonGroupVariant }\n"]}
1
+ {"version":3,"sources":["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AClF;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAcJ,cAAA,EAAc,eAAA;AAAA,MACd,kBAAA,EAAkB,mBAAA;AAAA,MAElB,8BAAC,kBAAA,CAAmB,QAAA,EAAnB,EAA4B,KAAA,EAAO,SAAU,QAAA,EAAS;AAAA;AAAA,GACzD;AAEJ;AAWA,SAAS,gBAAgB,EAAE,SAAA,EAAW,MAAA,EAAQ,GAAG,OAAM,EAAoC;AACzF,EAAA,OAAO,SAAA,CAAU;AAAA,IACf,cAAA,EAAgB,KAAA;AAAA,IAChB,KAAA,EAAO,UAAA;AAAA,MACL;AAAA,QACE,SAAA,EAAW,EAAA;AAAA;AAAA,UAET,wIAAA;AAAA;AAAA,UAEA,kEAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA,MACA;AAAA,KACF;AAAA,IACA,MAAA;AAAA,IACA,KAAA,EAAO;AAAA,MACL,IAAA,EAAM;AAAA;AACR,GACD,CAAA;AACH;AAQA,SAAS,oBAAA,CAAqB;AAAA,EAC5B,SAAA;AAAA,EACA,WAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA2C;AACzC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,UAAA,CAAW,kBAAkB,CAAA;AACjD,EAAA,MAAM,mBAAA,GACJ,WAAA,KAAgB,KAAA,EAAO,WAAA,KAAgB,aAAa,YAAA,GAAe,UAAA,CAAA;AAErE,EAAA,uBACE,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,WAAA,EAAa,mBAAA;AAAA,MACb,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA,QAIT,+FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"button-group.js","sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport {\n ButtonGroupBoundary,\n ButtonGroupContext,\n type ButtonGroupContextValue,\n} from '../lib/button-group-context.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\nimport { buttonColorVariants, type ButtonProps } from './button.js'\nimport { Separator } from './separator.js'\n\nconst DEFAULT_GROUP_VARIANT = 'outline' as const\nconst DEFAULT_GROUP_ORIENTATION = 'horizontal' as const\n\n/**\n * The group owns the boundary. It draws the frame or the band, the hairline\n * between segments and the 4px corners, and it clips its children to that\n * radius — so a segment never computes a corner of its own. The segments are\n * ordinary Buttons: they read `ButtonGroupContext` and give up the chrome the\n * group now draws (see `styles.segment` in button.tsx).\n *\n * This replaces a wrapper that collapsed borders through `[data-slot]` child\n * selectors copied from shadcn. Button never emitted `data-slot`, so none of\n * those rules matched: every Button kept its own 2px outline and 4px corners,\n * and neighbours met with a 4px doubled border.\n *\n * Every colour is Button's own `--btn-fill` / `--btn-bg` / `--btn-text` pair,\n * applied to the group by `buttonColorVariants`, so a group's `color` means\n * what a Button's does: the ink flips for dark mode the same way, and on a\n * soft or surface band it steps to the darker ink those tints need the same\n * way (`styles.tintInk` in button.tsx). The segments learn they sit on that\n * tint from the `band` the context carries, and step their own colour's ink,\n * so a segment naming another colour keeps it. Hairlines take the text\n * colour, per the masterbrand's line system. These classes therefore only\n * paint on an element that also carries `buttonColorVariants` —\n * `ring-(--btn-bg)` is invalid without it — so a consumer extending the\n * group's styling applies the two together, as `ButtonGroup` does.\n *\n * Two kinds of rule reach a segment. What depends on the segment's\n * NEIGHBOURS — dividers, seams, the text cell — lives here and uses the CHILD\n * combinator (`&>`) and sibling combinators, so it needs the segments to be\n * direct children. What depends only on the BAND — the re-ink on a solid\n * band, the frame-revealing `bg-clip-padding` — lives on the segment itself,\n * keyed on the `data-band` the group tells it through context, so it holds\n * for a segment rendered through a trigger's `render` prop or wrapped in a\n * span. Never a descendant rule: a group is not meant to nest, but if one\n * ever does, a descendant rule from the outer band would re-ink the inner\n * group's segments.\n */\nconst buttonGroupVariants = cva(\n [\n 'isolate inline-flex w-fit items-stretch overflow-hidden rounded-sm',\n // `items-stretch` above is what makes every segment the same size across\n // the group's cross axis — except an icon-only one, which `styles.iconOnly`\n // squares with `size-(--btn-h)`. A definite cross size is precisely the\n // case flexbox does NOT stretch (CSS Flexbox §9.4: stretch applies only\n // when the cross-size property computes to `auto`), so the square holds its\n // 52px whatever the segments beside it do. In a column that is every mixed\n // group: a 52px square in a 135px band, with a void beside it and the\n // hairline above it stopping a third of the way across. In a row it needs a\n // label to wrap first, which `min-h-(--btn-h)` on the button explicitly\n // allows — a floor, not a fixed height — and then the square sits at the\n // top of a 136px row.\n //\n // So the group releases the cross dimension and lets `items-stretch` do its\n // work, keeping the main one: the square stays a square whenever its\n // neighbours are one line tall, and grows with them when they are not.\n // Keyed on the group's own orientation, so neither rule is a bare utility\n // the other has to override, and reached through the child combinator, so\n // a nested icon button (inside a popup opened from a segment, say) is not\n // touched. (0,3,0) against `size-(--btn-h)`'s (0,1,0).\n 'data-[orientation=horizontal]:[&>[data-slot][data-icon-only]]:h-auto',\n 'data-[orientation=vertical]:[&>[data-slot][data-icon-only]]:w-auto',\n // The band's label colour, resolved HERE from the group's own colour\n // token and inherited by every segment as a computed value. A segment on\n // a solid band re-points its ink to this (see `styles.segment` in\n // button.tsx); publishing it from the group is what stops a segment that\n // names its own `color` from reading its own `--btn-text` instead.\n '[--group-label:var(--btn-text)]',\n // Dividers. A Button or ButtonGroupText carries `data-slot` and a 1px\n // transparent border, so the divider is that border recoloured on the\n // shared edge: no extra pixel, and the group's outer box stays exactly\n // one button tall. (ButtonGroupSeparator carries `data-slot` too but no\n // border and no size, so the hairline beside it is drawn by the segment\n // after it.) Keyed on orientation both ways so neither rule is a bare\n // utility the other overrides, and written as `[data-slot]~[data-slot]`\n // for specificity: Button's `dark:border-white/5` is a border-color\n // SHORTHAND at (0,2,0), and this longhand only beats it by specificity,\n // never by emission order (AGENTS.md §4, the two-build cascade).\n //\n // `loading` reaches these rules as well as `disabled`: Button derives\n // `disabled` from either, so a busy segment is a disabled one here. The\n // boundary therefore moves by a pixel when a request starts, which is the\n // contract holding rather than breaking — the alternative is a\n // half-strength hairline beside an enabled control for as long as the\n // request runs. `Segment Props` pins it.\n //\n // A disabled segment fades itself with `opacity-50`, and a divider drawn\n // on its own leading edge would fade with it — leaving one weak hairline\n // in an otherwise full-strength row, right where the eye reads the join.\n // So the boundary before a disabled segment is drawn on the trailing edge\n // of the segment BEFORE it instead, and the disabled segment's own\n // leading edge stays transparent. A separator between the two has no edge\n // to paint, so the rule also looks through one.\n //\n // The one hairline this does NOT lift out of the fade is the one BETWEEN\n // two adjacent disabled segments: its only available edge belongs to a\n // disabled element either way, so it renders at 50% like the pair it\n // divides. That is the coherent reading — the whole run is unavailable,\n // and a full-strength line inside it would draw more attention than the\n // controls do — and lifting it would mean moving dividers off the\n // segments entirely, onto a layer the group owns. `Disabled` renders the\n // case and pins where each edge lands.\n 'data-[orientation=horizontal]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-s-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=horizontal]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-e-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]~[data-slot]:not([data-disabled])]:border-t-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot][data-disabled])]:border-b-(--divider)',\n 'data-[orientation=vertical]:[&>[data-slot]:has(+[data-slot=button-group-separator]+[data-slot][data-disabled])]:border-b-(--divider)',\n // Two solid segments side by side (a split button): the ink divider would\n // vanish on the fill, so the seam is a reversed hairline in the label\n // colour. Above the general divider on specificity, with the same\n // disabled handling, and again looking through a separator.\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-s-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=horizontal]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-e-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]+[data-slot=button-group-separator]+[data-slot][data-variant=solid]:not([data-disabled])]:border-t-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n 'data-[orientation=vertical]:[&>[data-slot][data-variant=solid]:has(+[data-slot=button-group-separator]+[data-slot][data-variant=solid][data-disabled])]:border-b-(--btn-text)/30',\n ],\n {\n variants: {\n variant: {\n // A 1px hairline frame in the ink, drawn as an inset ring so it adds\n // no height: the group is exactly as tall as a lone Button beside it.\n // No fill of its own, like Button's outline: the surface shows\n // through, so a `white` outline group on a dark panel stays a frame.\n // Forced-colours mode discards box shadows, so the frame is restated\n // there as an outline, which that mode keeps and recolours. The text\n // cell stops its background at the padding box so the frame shows\n // through its transparent border.\n outline: [\n 'ring-1 ring-(--btn-bg) [--divider:var(--btn-bg)] ring-inset',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-clip-padding',\n ],\n // The band. Segments re-ink themselves on it (see `styles.segment` in\n // button.tsx); the text cell sits on the band in its label colour, at\n // the label weight so it reads as a label rather than as another\n // button.\n solid: [\n 'bg-(--btn-fill) [--divider:color-mix(in_oklab,var(--btn-text)_30%,transparent)]',\n '[&>[data-slot=button-group-text]]:bg-transparent [&>[data-slot=button-group-text]]:font-medium [&>[data-slot=button-group-text]]:text-(--btn-text)',\n ],\n // Button's soft pair — ink at 10%, 20% in dark — as a band. The text\n // cell sits on the band.\n soft: 'bg-(--btn-bg)/10 [--divider:color-mix(in_oklab,var(--btn-bg)_30%,transparent)] dark:bg-(--btn-bg)/20 [&>[data-slot=button-group-text]]:bg-transparent',\n // Button's surface pair: ink at 5% inside an ink/50 hairline, restated\n // as an outline for forced colours like the outline frame.\n surface: [\n 'bg-(--btn-bg)/5 ring-1 ring-(--btn-bg)/50 [--divider:color-mix(in_oklab,var(--btn-bg)_50%,transparent)] ring-inset dark:bg-(--btn-bg)/30',\n 'forced-colors:outline forced-colors:outline-1 forced-colors:-outline-offset-1',\n '[&>[data-slot=button-group-text]]:bg-transparent',\n ],\n // No frame, no fill: only the hairlines between segments remain.\n ghost: '[--divider:var(--btn-bg)]',\n },\n orientation: {\n horizontal: 'flex-row',\n vertical: 'flex-col',\n },\n },\n defaultVariants: {\n variant: DEFAULT_GROUP_VARIANT,\n orientation: DEFAULT_GROUP_ORIENTATION,\n },\n },\n)\n\n/** The group variants a ButtonGroup can paint. `link` has no group form. */\ntype ButtonGroupVariant = NonNullable<VariantProps<typeof buttonGroupVariants>['variant']>\n\ntype ButtonGroupProps = Omit<React.ComponentProps<'div'>, 'color'> &\n VariantProps<typeof buttonGroupVariants> & {\n /**\n * Colour token, with Button's meaning: `primary` by default. Sets the\n * ink the frame, band and dividers are drawn in, and the default colour\n * of every segment.\n */\n color?: ButtonProps['color']\n /**\n * Scale step, with Button's meaning. The default size of every segment.\n * `icon` is not offered: it is a 40px chrome square, and the group clips\n * to its own box, so the 44px touch expansion Button adds on a coarse\n * pointer would be cut off. A segment that asks for `icon` anyway renders\n * as `iconOnly` at the group's own step, so it lines up with the segments\n * beside it.\n */\n size?: Exclude<ButtonProps['size'], 'icon'>\n }\n\n/**\n * Joins a row (or column) of Buttons into one control. Takes Button's variant\n * family — `outline` (the default), `solid`, `soft`, `surface`, `ghost` — and\n * its colour tokens and size steps, and hands them to its segments as\n * defaults. A segment may name its own emphasis: a `solid` Save inside an\n * outline group is the primary action of that row.\n *\n * Children are Buttons (or ButtonLinks), `ButtonGroupText` for an inline\n * label, and `ButtonGroupSeparator` for a semantic boundary, as DIRECT\n * children: the hairlines between segments are drawn on the segments' shared\n * edges, so a segment wrapped in another element (a span holding a tooltip\n * on a disabled segment, say) keeps its label and its band treatment but\n * loses the hairlines it shares with its neighbours — the one before it, and\n * the one after it too when the wrapped segment is the first child. It is a group of buttons, not a general\n * control frame — an input or select with an attached action is InputGroup's\n * job — and groups do not nest.\n *\n * A popup opened from a segment (a split button's menu) renders through a\n * portal, which React context follows. Every popup in this package resets the\n * group context at its portal, so the Buttons inside render normally; wrap\n * the contents of an overlay from another library in `PortalBoundary` (or in\n * `ButtonGroupBoundary`, which does only this reset) to get the same. Without that reset a Button inside the popup renders as a\n * segment of the group it was opened from, and on a solid band that means its\n * label takes the band's colour — white on the popup's own surface.\n */\nfunction ButtonGroup({\n className,\n variant,\n orientation,\n color,\n size,\n children,\n ...props\n}: ButtonGroupProps) {\n const resolvedVariant = resolveVariant(variant, DEFAULT_GROUP_VARIANT)\n const resolvedOrientation = resolveVariant(orientation, DEFAULT_GROUP_ORIENTATION)\n // `null` is admitted by both prop types (they borrow Button's, which allow\n // it) and is the idiomatic way to thread an optional prop through a\n // wrapper. cva reads it as \"no variant\" rather than \"unspecified\", so an\n // unnormalised `null` would emit no size or colour classes AT ALL — and\n // because a segment resolves `color ?? group.color`, one `null` on the\n // group would turn every child's own `undefined` into an explicit `null`\n // and un-style the whole row: no padding, no height, and a frame still\n // pointing at a `--btn-bg` nothing defines. Normalising here means the\n // group and its segments both fall back to the same cva defaults a lone\n // Button gets.\n const resolvedColor = color ?? undefined\n const resolvedSize = size ?? undefined\n const context = React.useMemo<ButtonGroupContextValue>(\n () => ({\n band: resolvedVariant,\n color: resolvedColor,\n size: resolvedSize,\n orientation: resolvedOrientation,\n }),\n [resolvedVariant, resolvedColor, resolvedSize, resolvedOrientation],\n )\n\n return (\n <div\n role='group'\n data-slot='button-group'\n className={cn(\n buttonColorVariants({ color: resolvedColor, variant: resolvedVariant }),\n buttonGroupVariants({ variant: resolvedVariant, orientation: resolvedOrientation }),\n className,\n )}\n {...props}\n // AFTER the spread, so that no prop can override these two — unlike\n // `data-slot` above, and unlike Button, which puts its own stamps first\n // so InputGroupButton can relabel them. `data-orientation` is what every\n // divider rule keys on, while the flex direction comes from the cva\n // variant and the separator's axis from the context — neither of which\n // a prop can reach. If a prop could override it, a row handed\n // `data-orientation='vertical'` would paint column dividers across\n // itself. Nothing in the package keys on `data-variant` (the band\n // treatment reaches the segments through `data-band` instead), but it is\n // the group's public description of itself, and stamped last it cannot\n // be made to contradict the variant the group actually paints. The\n // Segment Props play pins both. `data-slot` stays first because\n // relabelling a group is the same escape hatch Button offers.\n data-variant={resolvedVariant}\n data-orientation={resolvedOrientation}\n >\n <ButtonGroupContext.Provider value={context}>{children}</ButtonGroupContext.Provider>\n </div>\n )\n}\n\n/**\n * An inline label between segments — a unit, a count, a mode. Sits at the\n * body size (16px), never smaller: it shares a line with 16px button labels,\n * so anything below that reads as fine print. Semibold, the weight the\n * InputGroup addon uses for the same job. On a framed or ghost group it sits\n * on the sunken surface so it reads as chrome rather than as a button; on a\n * band it sits on the band, and a solid band gives it the band's label colour\n * at the label weight (see `buttonGroupVariants`).\n */\nfunction ButtonGroupText({ className, render, ...props }: useRender.ComponentProps<'div'>) {\n return useRender({\n defaultTagName: 'div',\n props: mergeProps<'div'>(\n {\n className: cn(\n // The transparent border is what the group's divider recolours.\n 'flex items-center gap-2 border border-transparent bg-(--surface-sunken) px-4 text-base font-semibold text-muted-foreground select-none',\n // A glyph beside the text matches Button's 24px label glyph.\n \"[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-6\",\n className,\n ),\n },\n props,\n ),\n render,\n state: {\n slot: 'button-group-text',\n },\n })\n}\n\n/**\n * A semantic boundary between segments. Every segment is already divided by\n * a hairline, so the separator draws nothing of its own — it exists for\n * assistive technology, which hears it as a region boundary, and it follows\n * the group's orientation unless told otherwise.\n */\nfunction ButtonGroupSeparator({\n className,\n orientation,\n ...props\n}: React.ComponentProps<typeof Separator>) {\n const group = React.useContext(ButtonGroupContext)\n const resolvedOrientation =\n orientation ?? (group?.orientation === 'vertical' ? 'horizontal' : 'vertical')\n\n return (\n <Separator\n data-slot='button-group-separator'\n orientation={resolvedOrientation}\n className={cn(\n // Zero-size on its own axis and transparent: the hairline beside it\n // is the group's divider, not this element. Same variant keys as the\n // primitive's own sizing so tailwind-merge resolves them here.\n 'self-stretch bg-transparent data-[orientation=horizontal]:h-0 data-[orientation=vertical]:w-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n ButtonGroup,\n ButtonGroupBoundary,\n ButtonGroupSeparator,\n ButtonGroupText,\n buttonGroupVariants,\n}\nexport type { ButtonGroupProps, ButtonGroupVariant }\n"]}
@@ -5,7 +5,7 @@ import * as React from 'react';
5
5
  import { IconCheck } from '../icons/check.js';
6
6
  import { IconClose } from '../icons/close.js';
7
7
  import { IconExpandMore } from '../icons/expand-more.js';
8
- import { ButtonGroupBoundary } from '../lib/button-group-context.js';
8
+ import { PortalBoundary } from '../lib/portal-boundary.js';
9
9
  import { cn } from '../lib/utils.js';
10
10
  import { Button } from './button.js';
11
11
  import { InputGroup, InputGroupInput, InputGroupAddon, InputGroupButton } from './input-group.js';
@@ -78,7 +78,7 @@ function ComboboxContent({
78
78
  anchor,
79
79
  ...props
80
80
  }) {
81
- return /* @__PURE__ */ jsx(Combobox$1.Portal, { children: /* @__PURE__ */ jsx(ButtonGroupBoundary, { children: /* @__PURE__ */ jsx(
81
+ return /* @__PURE__ */ jsx(Combobox$1.Portal, { children: /* @__PURE__ */ jsx(PortalBoundary, { children: /* @__PURE__ */ jsx(
82
82
  Combobox$1.Positioner,
83
83
  {
84
84
  side,
@@ -1 +1 @@
1
- {"version":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GACN;AAEJ;AAEA,SAAS,iBAAA,GAAoB;AAC3B,EAAA,OAAO,KAAA,CAAM,OAA8B,IAAI,CAAA;AACjD","file":"combobox.js","sourcesContent":["'use client'\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconClose } from '../icons/close.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { cn } from '../lib/utils.js'\nimport { Button } from './button.js'\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from './input-group.js'\n\nconst Combobox = ComboboxPrimitive.Root\n\nfunction ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {\n return <ComboboxPrimitive.Value data-slot='combobox-value' {...props} />\n}\n\nfunction ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {\n return (\n <ComboboxPrimitive.Trigger\n data-slot='combobox-trigger'\n aria-label='Show suggestions'\n className={cn(\"[&_svg:not([class*='size-'])]:size-3.5\", className)}\n {...props}\n >\n {children}\n <IconExpandMore className='pointer-events-none size-3.5 text-muted-foreground' />\n </ComboboxPrimitive.Trigger>\n )\n}\n\nfunction ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {\n return (\n <ComboboxPrimitive.Clear\n data-slot='combobox-clear'\n aria-label='Clear'\n render={<InputGroupButton variant='ghost' size='icon-xs' />}\n className={cn(className)}\n {...props}\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.Clear>\n )\n}\n\nfunction ComboboxInput({\n className,\n children,\n disabled = false,\n showTrigger = true,\n showClear = false,\n ...props\n}: ComboboxPrimitive.Input.Props & {\n showTrigger?: boolean\n showClear?: boolean\n}) {\n return (\n <InputGroup className={cn('w-auto', className)}>\n <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />\n <InputGroupAddon align='inline-end'>\n {showTrigger && (\n <InputGroupButton\n size='icon-xs'\n variant='ghost'\n render={<ComboboxTrigger />}\n data-slot='input-group-button'\n className='group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent'\n disabled={disabled}\n />\n )}\n {showClear && <ComboboxClear disabled={disabled} />}\n </InputGroupAddon>\n {children}\n </InputGroup>\n )\n}\n\nfunction ComboboxContent({\n className,\n side = 'bottom',\n sideOffset = 6,\n align = 'start',\n alignOffset = 0,\n anchor,\n ...props\n}: ComboboxPrimitive.Popup.Props &\n Pick<\n ComboboxPrimitive.Positioner.Props,\n 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'\n >) {\n return (\n <ComboboxPrimitive.Portal>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>\n <ComboboxPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n anchor={anchor}\n className='isolate z-50'\n >\n <ComboboxPrimitive.Popup\n data-slot='combobox-content'\n data-chips={!!anchor}\n className={cn(\n 'group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:bg-input/20 *:data-[slot=input-group]:shadow-none dark:bg-popover data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n className,\n )}\n {...props}\n />\n </ComboboxPrimitive.Positioner>\n </ButtonGroupBoundary>\n </ComboboxPrimitive.Portal>\n )\n}\n\nfunction ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {\n return (\n <ComboboxPrimitive.List\n data-slot='combobox-list'\n className={cn(\n 'no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {\n return (\n <ComboboxPrimitive.Item\n data-slot='combobox-item'\n className={cn(\n \"relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-sm px-2 py-1 text-xs/relaxed outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n {children}\n <ComboboxPrimitive.ItemIndicator\n render={\n <span className='pointer-events-none absolute end-2 flex items-center justify-center' />\n }\n >\n <IconCheck className='pointer-events-none' />\n </ComboboxPrimitive.ItemIndicator>\n </ComboboxPrimitive.Item>\n )\n}\n\nfunction ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {\n return <ComboboxPrimitive.Group data-slot='combobox-group' className={cn(className)} {...props} />\n}\n\nfunction ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {\n return (\n <ComboboxPrimitive.GroupLabel\n data-slot='combobox-label'\n className={cn('px-2 py-1.5 text-xs text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {\n return <ComboboxPrimitive.Collection data-slot='combobox-collection' {...props} />\n}\n\nfunction ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {\n return (\n <ComboboxPrimitive.Empty\n data-slot='combobox-empty'\n className={cn(\n 'hidden w-full justify-center py-2 text-center text-xs/relaxed text-muted-foreground group-data-empty/combobox-content:flex',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {\n return (\n <ComboboxPrimitive.Separator\n data-slot='combobox-separator'\n className={cn('-mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxChips({\n className,\n ...props\n}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {\n return (\n <ComboboxPrimitive.Chips\n data-slot='combobox-chips'\n className={cn(\n 'flex min-h-7 flex-wrap items-center gap-1 rounded-sm border border-input bg-input/20 bg-clip-padding px-2 py-0.5 text-xs/relaxed transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30 has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxChip({\n className,\n children,\n showRemove = true,\n removeLabel = 'Remove',\n ...props\n}: ComboboxPrimitive.Chip.Props & {\n showRemove?: boolean\n /**\n * Screen-reader name for the chip's remove button. Override to translate it\n * — the button is icon-only, so this string is the only name AT ever hears.\n * Include the chip's own text where a bare \"Remove\" would be ambiguous in a\n * list of chips.\n */\n removeLabel?: string\n}) {\n return (\n <ComboboxPrimitive.Chip\n data-slot='combobox-chip'\n className={cn(\n 'flex h-[calc(--spacing(4.75))] w-fit items-center justify-center gap-1 rounded-[calc(var(--radius-sm)-2px)] bg-muted-foreground/10 px-1.5 text-xs/relaxed font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-0',\n className,\n )}\n {...props}\n >\n {children}\n {showRemove && (\n <ComboboxPrimitive.ChipRemove\n render={<Button variant='ghost' size='icon' />}\n aria-label={removeLabel}\n className='-ms-1 opacity-50 hover:opacity-100'\n data-slot='combobox-chip-remove'\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.ChipRemove>\n )}\n </ComboboxPrimitive.Chip>\n )\n}\n\nfunction ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props) {\n return (\n <ComboboxPrimitive.Input\n data-slot='combobox-chip-input'\n className={cn('min-w-16 flex-1 outline-none', className)}\n {...props}\n />\n )\n}\n\nfunction useComboboxAnchor() {\n return React.useRef<HTMLDivElement | null>(null)\n}\n\nexport {\n Combobox,\n ComboboxChip,\n ComboboxChips,\n ComboboxChipsInput,\n ComboboxCollection,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxInput,\n ComboboxItem,\n ComboboxLabel,\n ComboboxList,\n ComboboxSeparator,\n ComboboxTrigger,\n ComboboxValue,\n useComboboxAnchor,\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/combobox.tsx"],"names":["ComboboxPrimitive"],"mappings":";;;;;;;;;;;AAaA,MAAM,WAAWA,UAAA,CAAkB;AAEnC,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAkC;AAClE,EAAA,2BAAQA,UAAA,CAAkB,KAAA,EAAlB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,gBAAgB,EAAE,SAAA,EAAW,QAAA,EAAU,GAAG,OAAM,EAAoC;AAC3F,EAAA,uBACE,IAAA;AAAA,IAACA,UAAA,CAAkB,OAAA;AAAA,IAAlB;AAAA,MACC,WAAA,EAAU,kBAAA;AAAA,MACV,YAAA,EAAW,kBAAA;AAAA,MACX,SAAA,EAAW,EAAA,CAAG,wCAAA,EAA0C,SAAS,CAAA;AAAA,MAChE,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,wBACD,GAAA,CAAC,cAAA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ACA,UAAA,CAAkB,UAAA;AAAA,UAAlB;AAAA,YACC,wBAAQ,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAQ,OAAA,EAAQ,MAAK,MAAA,EAAO,CAAA;AAAA,YAC5C,YAAA,EAAY,WAAA;AAAA,YACZ,SAAA,EAAU,oCAAA;AAAA,YACV,WAAA,EAAU,sBAAA;AAAA,YAEV,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,qBAAA,EAAsB;AAAA;AAAA;AAC7C;AAAA;AAAA,GAEJ;AAEJ;AAEA,SAAS,kBAAA,CAAmB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AAClF,EAAA,uBACE,GAAA;AAAA,IAACA,UAAA,CAAkB,KAAA;AAAA,IAAlB;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,8BAAA,EAAgC,SAAS,CAAA;AAAA,MACtD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,iBAAA,GAAoB;AAC3B,EAAA,OAAO,KAAA,CAAM,OAA8B,IAAI,CAAA;AACjD","file":"combobox.js","sourcesContent":["'use client'\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconClose } from '../icons/close.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\nimport { Button } from './button.js'\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from './input-group.js'\n\nconst Combobox = ComboboxPrimitive.Root\n\nfunction ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {\n return <ComboboxPrimitive.Value data-slot='combobox-value' {...props} />\n}\n\nfunction ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {\n return (\n <ComboboxPrimitive.Trigger\n data-slot='combobox-trigger'\n aria-label='Show suggestions'\n className={cn(\"[&_svg:not([class*='size-'])]:size-3.5\", className)}\n {...props}\n >\n {children}\n <IconExpandMore className='pointer-events-none size-3.5 text-muted-foreground' />\n </ComboboxPrimitive.Trigger>\n )\n}\n\nfunction ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {\n return (\n <ComboboxPrimitive.Clear\n data-slot='combobox-clear'\n aria-label='Clear'\n render={<InputGroupButton variant='ghost' size='icon-xs' />}\n className={cn(className)}\n {...props}\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.Clear>\n )\n}\n\nfunction ComboboxInput({\n className,\n children,\n disabled = false,\n showTrigger = true,\n showClear = false,\n ...props\n}: ComboboxPrimitive.Input.Props & {\n showTrigger?: boolean\n showClear?: boolean\n}) {\n return (\n <InputGroup className={cn('w-auto', className)}>\n <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />\n <InputGroupAddon align='inline-end'>\n {showTrigger && (\n <InputGroupButton\n size='icon-xs'\n variant='ghost'\n render={<ComboboxTrigger />}\n data-slot='input-group-button'\n className='group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent'\n disabled={disabled}\n />\n )}\n {showClear && <ComboboxClear disabled={disabled} />}\n </InputGroupAddon>\n {children}\n </InputGroup>\n )\n}\n\nfunction ComboboxContent({\n className,\n side = 'bottom',\n sideOffset = 6,\n align = 'start',\n alignOffset = 0,\n anchor,\n ...props\n}: ComboboxPrimitive.Popup.Props &\n Pick<\n ComboboxPrimitive.Positioner.Props,\n 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'\n >) {\n return (\n <ComboboxPrimitive.Portal>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>\n <ComboboxPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n anchor={anchor}\n className='isolate z-50'\n >\n <ComboboxPrimitive.Popup\n data-slot='combobox-content'\n data-chips={!!anchor}\n className={cn(\n 'group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:bg-input/20 *:data-[slot=input-group]:shadow-none dark:bg-popover data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n className,\n )}\n {...props}\n />\n </ComboboxPrimitive.Positioner>\n </PortalBoundary>\n </ComboboxPrimitive.Portal>\n )\n}\n\nfunction ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {\n return (\n <ComboboxPrimitive.List\n data-slot='combobox-list'\n className={cn(\n 'no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {\n return (\n <ComboboxPrimitive.Item\n data-slot='combobox-item'\n className={cn(\n \"relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-sm px-2 py-1 text-xs/relaxed outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n {children}\n <ComboboxPrimitive.ItemIndicator\n render={\n <span className='pointer-events-none absolute end-2 flex items-center justify-center' />\n }\n >\n <IconCheck className='pointer-events-none' />\n </ComboboxPrimitive.ItemIndicator>\n </ComboboxPrimitive.Item>\n )\n}\n\nfunction ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {\n return <ComboboxPrimitive.Group data-slot='combobox-group' className={cn(className)} {...props} />\n}\n\nfunction ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {\n return (\n <ComboboxPrimitive.GroupLabel\n data-slot='combobox-label'\n className={cn('px-2 py-1.5 text-xs text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {\n return <ComboboxPrimitive.Collection data-slot='combobox-collection' {...props} />\n}\n\nfunction ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {\n return (\n <ComboboxPrimitive.Empty\n data-slot='combobox-empty'\n className={cn(\n 'hidden w-full justify-center py-2 text-center text-xs/relaxed text-muted-foreground group-data-empty/combobox-content:flex',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {\n return (\n <ComboboxPrimitive.Separator\n data-slot='combobox-separator'\n className={cn('-mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxChips({\n className,\n ...props\n}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {\n return (\n <ComboboxPrimitive.Chips\n data-slot='combobox-chips'\n className={cn(\n 'flex min-h-7 flex-wrap items-center gap-1 rounded-sm border border-input bg-input/20 bg-clip-padding px-2 py-0.5 text-xs/relaxed transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30 has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxChip({\n className,\n children,\n showRemove = true,\n removeLabel = 'Remove',\n ...props\n}: ComboboxPrimitive.Chip.Props & {\n showRemove?: boolean\n /**\n * Screen-reader name for the chip's remove button. Override to translate it\n * — the button is icon-only, so this string is the only name AT ever hears.\n * Include the chip's own text where a bare \"Remove\" would be ambiguous in a\n * list of chips.\n */\n removeLabel?: string\n}) {\n return (\n <ComboboxPrimitive.Chip\n data-slot='combobox-chip'\n className={cn(\n 'flex h-[calc(--spacing(4.75))] w-fit items-center justify-center gap-1 rounded-[calc(var(--radius-sm)-2px)] bg-muted-foreground/10 px-1.5 text-xs/relaxed font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-0',\n className,\n )}\n {...props}\n >\n {children}\n {showRemove && (\n <ComboboxPrimitive.ChipRemove\n render={<Button variant='ghost' size='icon' />}\n aria-label={removeLabel}\n className='-ms-1 opacity-50 hover:opacity-100'\n data-slot='combobox-chip-remove'\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.ChipRemove>\n )}\n </ComboboxPrimitive.Chip>\n )\n}\n\nfunction ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props) {\n return (\n <ComboboxPrimitive.Input\n data-slot='combobox-chip-input'\n className={cn('min-w-16 flex-1 outline-none', className)}\n {...props}\n />\n )\n}\n\nfunction useComboboxAnchor() {\n return React.useRef<HTMLDivElement | null>(null)\n}\n\nexport {\n Combobox,\n ComboboxChip,\n ComboboxChips,\n ComboboxChipsInput,\n ComboboxCollection,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxInput,\n ComboboxItem,\n ComboboxLabel,\n ComboboxList,\n ComboboxSeparator,\n ComboboxTrigger,\n ComboboxValue,\n useComboboxAnchor,\n}\n"]}
@@ -115,11 +115,13 @@ type ComponentPreviewStageProps = React.ComponentProps<'div'> & {
115
115
  * Each stage is a container, so a component can respond to the stage's width
116
116
  * with a container query; a media query still reads the viewport.
117
117
  *
118
- * The scheme and colours reach only what renders inside the stage. A popup
119
- * that portals out of it (Dialog, Popover, Select, Tooltip and the like)
120
- * renders at the end of the page, so it takes the page's scheme and colours,
121
- * not the stage's. Preview such a component with the page set to the scheme
122
- * you want to check.
118
+ * A popup from this package that portals out of the stage (Dialog, Popover,
119
+ * Select, Tooltip and the like) keeps the stage's scheme, colours and
120
+ * direction: the stage hands them over through `PortalScopeContext`, and each
121
+ * popup applies them at its portal with `PortalBoundary`. A portal from
122
+ * elsewhere takes the page's, unless its contents are wrapped in
123
+ * `PortalBoundary` too. So do toasts, which render in the page's `Toaster`,
124
+ * not in the stage.
123
125
  */
124
126
  declare function ComponentPreviewStage({ className, children, lightLabel, darkLabel, resizeLabel, ...props }: ComponentPreviewStageProps): React.JSX.Element;
125
127
  /** One tab of the code area. */
@@ -22,7 +22,8 @@ import { IconLightMode } from '../icons/light-mode.js';
22
22
  import { IconPalette } from '../icons/palette.js';
23
23
  import { IconSmartphone } from '../icons/smartphone.js';
24
24
  import { IconTabletMac } from '../icons/tablet-mac.js';
25
- import { ABORIGINAL_PALETTES, BRAND_PALETTES, previewThemeStyle } from '../lib/preview-theme.js';
25
+ import { PortalScopeContext } from '../lib/portal-boundary.js';
26
+ import { ABORIGINAL_PALETTES, BRAND_PALETTES, previewThemeStyle, PALETTE_STEPS } from '../lib/preview-theme.js';
26
27
  import { cn } from '../lib/utils.js';
27
28
 
28
29
  const MIN_WIDTH = 280;
@@ -424,6 +425,11 @@ function ComponentPreviewColorPicker({
424
425
  )
425
426
  ] });
426
427
  }
428
+ const NO_VALUES = {};
429
+ const sameValues = (a, b) => {
430
+ const keys = Object.keys(a);
431
+ return keys.length === Object.keys(b).length && keys.every((key) => a[key] === b[key]);
432
+ };
427
433
  function StagePane({
428
434
  scheme,
429
435
  label,
@@ -456,18 +462,58 @@ function StagePane({
456
462
  () => previewThemeStyle({ scheme, primary, accent }),
457
463
  [scheme, primary, accent]
458
464
  );
465
+ const scope = React.useMemo(
466
+ () => ({
467
+ className: scheme === "dark" ? "dark scheme-dark" : "scheme-light",
468
+ style,
469
+ dir: direction,
470
+ attributes: {
471
+ "data-theme": scheme,
472
+ "data-theme-island": scheme === "light" ? "light" : void 0
473
+ }
474
+ }),
475
+ [scheme, style, direction]
476
+ );
477
+ const paneRef = React.useRef(null);
478
+ const [inherited, setInherited] = React.useState(NO_VALUES);
479
+ const readInherited = React.useCallback(() => {
480
+ const pane = paneRef.current;
481
+ if (!pane) return;
482
+ const computed = getComputedStyle(pane);
483
+ const next = {};
484
+ for (const [ramp, chosen] of [
485
+ ["primary", primary],
486
+ ["accent", accent]
487
+ ]) {
488
+ if (chosen) continue;
489
+ for (const step of PALETTE_STEPS) {
490
+ for (const name of [`--${ramp}-${step}`, `--color-${ramp}-${step}`]) {
491
+ const value = computed.getPropertyValue(name).trim();
492
+ if (value) next[name] = value;
493
+ }
494
+ }
495
+ }
496
+ setInherited((current) => sameValues(current, next) ? current : next);
497
+ }, [primary, accent]);
498
+ React.useLayoutEffect(readInherited, [readInherited]);
499
+ const portalScope = React.useMemo(
500
+ () => ({ ...scope, style: { ...scope.style, ...inherited } }),
501
+ [scope, inherited]
502
+ );
459
503
  const resizable = available > MIN_WIDTH;
460
504
  return /* @__PURE__ */ jsxs(
461
505
  "div",
462
506
  {
507
+ ref: paneRef,
463
508
  "data-slot": "component-preview-pane",
509
+ onPointerEnter: readInherited,
510
+ onFocusCapture: readInherited,
464
511
  className: cn(
465
512
  "min-w-0 flex-1 bg-muted text-foreground @max-3xl/component-preview:py-4 @max-3xl/component-preview:ps-4 @max-3xl/component-preview:pe-9 @3xl/component-preview:py-6 @3xl/component-preview:ps-6 @3xl/component-preview:pe-10",
466
- scheme === "dark" ? "dark scheme-dark" : "scheme-light"
513
+ scope.className
467
514
  ),
468
- "data-theme": scheme,
469
- "data-theme-island": scheme === "light" ? "light" : void 0,
470
- style,
515
+ ...scope.attributes,
516
+ style: scope.style,
471
517
  children: [
472
518
  label ? /* @__PURE__ */ jsx(
473
519
  "div",
@@ -483,10 +529,10 @@ function StagePane({
483
529
  {
484
530
  ref: frameRef,
485
531
  "data-slot": "component-preview-frame",
486
- dir: direction,
532
+ dir: scope.dir,
487
533
  style: { maxWidth: width ?? void 0 },
488
534
  className: "@container/component-preview-frame min-w-0 border border-border bg-background text-foreground @max-3xl/component-preview:p-4 @3xl/component-preview:p-8",
489
- children
535
+ children: /* @__PURE__ */ jsx(PortalScopeContext.Provider, { value: portalScope, children })
490
536
  }
491
537
  ),
492
538
  resizable ? /* @__PURE__ */ jsx(