@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.
- package/dist/components/alert-dialog.js +2 -2
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/button-group.d.ts +2 -2
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/combobox.js +2 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/component-preview.d.ts +7 -5
- package/dist/components/component-preview.js +53 -7
- package/dist/components/component-preview.js.map +1 -1
- package/dist/components/dialog.js +2 -2
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/drawer.js +2 -2
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.js +2 -2
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/hover-card.js +2 -2
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/input-otp.js +4 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/native-select.js +10 -2
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/navigation-menu.js +2 -1
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/popover.js +2 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/select.js +12 -4
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.js +2 -2
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/site-search.js +2 -2
- package/dist/components/site-search.js.map +1 -1
- package/dist/components/toggle.js +12 -2
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/tooltip.js +2 -2
- package/dist/components/tooltip.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/portal-boundary.d.ts +47 -0
- package/dist/lib/portal-boundary.js +24 -0
- package/dist/lib/portal-boundary.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { PreviewCard } from '@base-ui/react/preview-card';
|
|
4
|
-
import {
|
|
4
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
5
5
|
import { cn } from '../lib/utils.js';
|
|
6
6
|
|
|
7
7
|
function HoverCard({ ...props }) {
|
|
@@ -18,7 +18,7 @@ function HoverCardContent({
|
|
|
18
18
|
alignOffset = 4,
|
|
19
19
|
...props
|
|
20
20
|
}) {
|
|
21
|
-
return /* @__PURE__ */ jsx(PreviewCard.Portal, { "data-slot": "hover-card-portal", children: /* @__PURE__ */ jsx(
|
|
21
|
+
return /* @__PURE__ */ jsx(PreviewCard.Portal, { "data-slot": "hover-card-portal", children: /* @__PURE__ */ jsx(PortalBoundary, { children: /* @__PURE__ */ jsx(
|
|
22
22
|
PreviewCard.Positioner,
|
|
23
23
|
{
|
|
24
24
|
align,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/hover-card.tsx"],"names":["PreviewCardPrimitive"],"mappings":";;;;;AAOA,SAAS,SAAA,CAAU,EAAE,GAAG,KAAA,EAAM,EAAoC;AAChE,EAAA,2BAAQA,WAAA,CAAqB,IAAA,EAArB,EAA0B,WAAA,EAAU,YAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AACtE;AAEA,SAAS,gBAAA,CAAiB,EAAE,GAAG,KAAA,EAAM,EAAuC;AAC1E,EAAA,2BAAQA,WAAA,CAAqB,OAAA,EAArB,EAA6B,WAAA,EAAU,oBAAA,EAAsB,GAAG,KAAA,EAAO,CAAA;AACjF;AAEA,SAAS,gBAAA,CAAiB;AAAA,EACxB,SAAA;AAAA,EACA,IAAA,GAAO,QAAA;AAAA,EACP,UAAA,GAAa,CAAA;AAAA,EACb,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc,CAAA;AAAA,EACd,GAAG;AACL,CAAA,EACgG;AAC9F,EAAA,2BACGA,WAAA,CAAqB,MAAA,EAArB,EAA4B,WAAA,EAAU,mBAAA,EAErC,8BAAC,
|
|
1
|
+
{"version":3,"sources":["../../src/components/hover-card.tsx"],"names":["PreviewCardPrimitive"],"mappings":";;;;;AAOA,SAAS,SAAA,CAAU,EAAE,GAAG,KAAA,EAAM,EAAoC;AAChE,EAAA,2BAAQA,WAAA,CAAqB,IAAA,EAArB,EAA0B,WAAA,EAAU,YAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AACtE;AAEA,SAAS,gBAAA,CAAiB,EAAE,GAAG,KAAA,EAAM,EAAuC;AAC1E,EAAA,2BAAQA,WAAA,CAAqB,OAAA,EAArB,EAA6B,WAAA,EAAU,oBAAA,EAAsB,GAAG,KAAA,EAAO,CAAA;AACjF;AAEA,SAAS,gBAAA,CAAiB;AAAA,EACxB,SAAA;AAAA,EACA,IAAA,GAAO,QAAA;AAAA,EACP,UAAA,GAAa,CAAA;AAAA,EACb,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc,CAAA;AAAA,EACd,GAAG;AACL,CAAA,EACgG;AAC9F,EAAA,2BACGA,WAAA,CAAqB,MAAA,EAArB,EAA4B,WAAA,EAAU,mBAAA,EAErC,8BAAC,cAAA,EAAA,EACC,QAAA,kBAAA,GAAA;AAAA,IAACA,WAAA,CAAqB,UAAA;AAAA,IAArB;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,SAAA,EAAU,cAAA;AAAA,MAEV,QAAA,kBAAA,GAAA;AAAA,QAACA,WAAA,CAAqB,KAAA;AAAA,QAArB;AAAA,UACC,WAAA,EAAU,oBAAA;AAAA,UACV,SAAA,EAAW,EAAA;AAAA,YACT,4hBAAA;AAAA,YACA;AAAA,WACF;AAAA,UACC,GAAG;AAAA;AAAA;AACN;AAAA,KAEJ,CAAA,EACF,CAAA;AAEJ","file":"hover-card.js","sourcesContent":["'use client'\n\nimport { PreviewCard as PreviewCardPrimitive } from '@base-ui/react/preview-card'\n\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\nfunction HoverCard({ ...props }: PreviewCardPrimitive.Root.Props) {\n return <PreviewCardPrimitive.Root data-slot='hover-card' {...props} />\n}\n\nfunction HoverCardTrigger({ ...props }: PreviewCardPrimitive.Trigger.Props) {\n return <PreviewCardPrimitive.Trigger data-slot='hover-card-trigger' {...props} />\n}\n\nfunction HoverCardContent({\n className,\n side = 'bottom',\n sideOffset = 4,\n align = 'center',\n alignOffset = 4,\n ...props\n}: PreviewCardPrimitive.Popup.Props &\n Pick<PreviewCardPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {\n return (\n <PreviewCardPrimitive.Portal data-slot='hover-card-portal'>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>\n <PreviewCardPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className='isolate z-50'\n >\n <PreviewCardPrimitive.Popup\n data-slot='hover-card-content'\n className={cn(\n 'z-50 w-72 origin-(--transform-origin) rounded-md bg-popover p-2.5 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 outline-hidden duration-100 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-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 </PreviewCardPrimitive.Positioner>\n </PortalBoundary>\n </PreviewCardPrimitive.Portal>\n )\n}\n\nexport { HoverCard, HoverCardContent, HoverCardTrigger }\n"]}
|
|
@@ -50,7 +50,10 @@ function InputOTPSlot({
|
|
|
50
50
|
"data-slot": "input-otp-slot",
|
|
51
51
|
"data-active": isActive,
|
|
52
52
|
className: cn(
|
|
53
|
-
|
|
53
|
+
// The slot borders are the field's only edge, so they use Input's
|
|
54
|
+
// border and surface tokens, which clear 3:1 in both modes;
|
|
55
|
+
// `border-input` was 1.34:1 light / 1.67:1 dark (#255, WCAG 1.4.11).
|
|
56
|
+
"relative flex size-7 items-center justify-center border-y border-e border-(--input-border) bg-(--input-surface) text-xs/relaxed transition-all outline-none first:rounded-s-sm first:border-s last:rounded-e-sm aria-invalid:border-destructive data-[active=true]:z-10 data-[active=true]:border-ring data-[active=true]:ring-2 data-[active=true]:ring-ring/30 data-[active=true]:aria-invalid:border-destructive data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40",
|
|
54
57
|
className
|
|
55
58
|
),
|
|
56
59
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/input-otp.tsx"],"names":[],"mappings":";;;;;;AAQA,SAAS,QAAA,CAAS;AAAA,EAChB,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,GAAG;AACL,CAAA,EAEG;AACD,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,WAAA;AAAA,MACV,kBAAA,EAAoB,EAAA;AAAA,QAClB,wDAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,UAAA,EAAY,KAAA;AAAA,MACZ,SAAA,EAAW,EAAA,CAAG,6BAAA,EAA+B,SAAS,CAAA;AAAA,MACrD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,aAAA,CAAc,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,yKAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,YAAA,CAAa;AAAA,EACpB,KAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAG;AACL,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c,QAAA,KAAa,eAAA,EAAiB,KAAA,CAAM,KAAK,CAAA,IAAK,EAAC;AAE3E,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,gBAAA;AAAA,MACV,aAAA,EAAa,QAAA;AAAA,MACb,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA,QAIT,kgBAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,IAAA;AAAA,QACA,YAAA,wBACE,KAAA,EAAA,EAAI,SAAA,EAAU,yEACb,QAAA,kBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,0DAAA,EAA2D,CAAA,EAC5E;AAAA;AAAA;AAAA,GAEJ;AAEJ;AAEA,SAAS,iBAAA,CAAkB,EAAE,GAAG,KAAA,EAAM,EAAgC;AACpE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,SAAA,EAAU,wDAAA;AAAA,MACV,IAAA,EAAK,WAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MAEJ,8BAAC,UAAA,EAAA,EAAW;AAAA;AAAA,GACd;AAEJ","file":"input-otp.js","sourcesContent":["'use client'\n\nimport { OTPInput, OTPInputContext } from 'input-otp'\nimport * as React from 'react'\n\nimport { IconRemove } from '../icons/remove.js'\nimport { cn } from '../lib/utils.js'\n\nfunction InputOTP({\n className,\n containerClassName,\n ...props\n}: React.ComponentProps<typeof OTPInput> & {\n containerClassName?: string\n}) {\n return (\n <OTPInput\n data-slot='input-otp'\n containerClassName={cn(\n 'cn-input-otp flex items-center has-disabled:opacity-50',\n containerClassName,\n )}\n spellCheck={false}\n className={cn('disabled:cursor-not-allowed', className)}\n {...props}\n />\n )\n}\n\nfunction InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='input-otp-group'\n className={cn(\n 'flex items-center rounded-sm has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction InputOTPSlot({\n index,\n className,\n ...props\n}: React.ComponentProps<'div'> & {\n index: number\n}) {\n const inputOTPContext = React.useContext(OTPInputContext)\n const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}\n\n return (\n <div\n data-slot='input-otp-slot'\n data-active={isActive}\n className={cn(\n // The slot borders are the field's only edge, so they use Input's\n // border and surface tokens, which clear 3:1 in both modes;\n // `border-input` was 1.34:1 light / 1.67:1 dark (#255, WCAG 1.4.11).\n 'relative flex size-7 items-center justify-center border-y border-e border-(--input-border) bg-(--input-surface) text-xs/relaxed transition-all outline-none first:rounded-s-sm first:border-s last:rounded-e-sm aria-invalid:border-destructive data-[active=true]:z-10 data-[active=true]:border-ring data-[active=true]:ring-2 data-[active=true]:ring-ring/30 data-[active=true]:aria-invalid:border-destructive data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n >\n {char}\n {hasFakeCaret && (\n <div className='pointer-events-none absolute inset-0 flex items-center justify-center'>\n <div className='h-4 w-px animate-caret-blink bg-foreground duration-1000' />\n </div>\n )}\n </div>\n )\n}\n\nfunction InputOTPSeparator({ ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='input-otp-separator'\n className=\"flex items-center [&_svg:not([class*='size-'])]:size-4\"\n role='separator'\n {...props}\n >\n <IconRemove />\n </div>\n )\n}\n\nexport { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot }\n"]}
|
|
@@ -16,8 +16,16 @@ const nativeSelectVariants = cva(
|
|
|
16
16
|
variant: {
|
|
17
17
|
// Crisp field — bordered white box; matches Input and Select's default.
|
|
18
18
|
default: "border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)",
|
|
19
|
-
// Filled band —
|
|
20
|
-
|
|
19
|
+
// Filled band — a tinted surface with an underline, revealing the full
|
|
20
|
+
// border on hover. The tint is barely distinguishable from the page
|
|
21
|
+
// (1.09:1), so the underline, in the field border colour, is what
|
|
22
|
+
// identifies the control at 3:1 (#255, WCAG 1.4.11).
|
|
23
|
+
//
|
|
24
|
+
// Each side's colour is set on its own, never the `border-transparent`
|
|
25
|
+
// shorthand beside the `border-b-` longhand: the two tie on
|
|
26
|
+
// specificity, so a consumer's own Tailwind build re-emitting
|
|
27
|
+
// `border-transparent` after ours would win and erase the underline.
|
|
28
|
+
filled: "border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)"
|
|
21
29
|
},
|
|
22
30
|
size: {
|
|
23
31
|
default: "h-12 ps-4 pe-10",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/native-select.tsx"],"names":[],"mappings":";;;;;;AAOA,MAAM,oBAAA,GAAuB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3B,8gBAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA;AAAA,QAEP,OAAA,EACE,sFAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/components/native-select.tsx"],"names":[],"mappings":";;;;;;AAOA,MAAM,oBAAA,GAAuB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3B,8gBAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA;AAAA,QAEP,OAAA,EACE,sFAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAUF,MAAA,EACE;AAAA,OACJ;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,OAAA,EAAS,iBAAA;AAAA,QACT,EAAA,EAAI;AAAA;AACN,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,SA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AAM,EAAqC;AACvF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACN;AAEJ","file":"native-select.js","sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nconst nativeSelectVariants = cva(\n // Field foundation shared with Input (input.tsx) and the Select trigger: the\n // same --input-* semantic tokens, 16px text, and an outline-based focus ring.\n // appearance-none hides the native arrow so our chevron shows; no outline-none\n // (it would suppress the focus-visible outline). Dark mode and brand themes\n // restyle via tokens, so there are no dark: variants.\n 'w-full min-w-0 appearance-none rounded-sm text-base text-(--input-foreground) select-none selection:bg-primary selection:text-primary-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--input-ring) disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus-visible:outline-(--input-invalid-ring) motion-safe:transition-colors',\n {\n variants: {\n variant: {\n // Crisp field — bordered white box; matches Input and Select's default.\n default:\n 'border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)',\n // Filled band — a tinted surface with an underline, revealing the full\n // border on hover. The tint is barely distinguishable from the page\n // (1.09:1), so the underline, in the field border colour, is what\n // identifies the control at 3:1 (#255, WCAG 1.4.11).\n //\n // Each side's colour is set on its own, never the `border-transparent`\n // shorthand beside the `border-b-` longhand: the two tie on\n // specificity, so a consumer's own Tailwind build re-emitting\n // `border-transparent` after ours would win and erase the underline.\n filled:\n 'border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)',\n },\n size: {\n default: 'h-12 ps-4 pe-10',\n sm: 'h-10 ps-3 pe-9',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\ntype NativeSelectProps = Omit<React.ComponentProps<'select'>, 'size'> &\n VariantProps<typeof nativeSelectVariants>\n\nfunction NativeSelect({ className, variant, size, ...props }: NativeSelectProps) {\n // Resolved once (see `resolveVariant`), so cva and the four data attributes\n // agree for `null` and `''` as well as the default spelling.\n const variantway = resolveVariant(variant, 'default')\n const sizeway = resolveVariant(size, 'default')\n return (\n <div\n className={cn(\n 'group/native-select relative w-fit has-[select:disabled]:opacity-50',\n className,\n )}\n data-slot='native-select-wrapper'\n data-size={sizeway}\n data-variant={variantway}\n >\n <select\n data-slot='native-select'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attributes from the classes both derive from the resolved values.\n data-size={sizeway}\n data-variant={variantway}\n className={cn(nativeSelectVariants({ variant: variantway, size: sizeway }))}\n />\n <IconExpandMore\n className='pointer-events-none absolute end-3 top-1/2 size-5 -translate-y-1/2 text-primary select-none'\n aria-hidden='true'\n data-slot='native-select-icon'\n />\n </div>\n )\n}\n\nfunction NativeSelectOption({ className, ...props }: React.ComponentProps<'option'>) {\n return (\n <option\n data-slot='native-select-option'\n className={cn('bg-[Canvas] text-[CanvasText]', className)}\n {...props}\n />\n )\n}\n\nfunction NativeSelectOptGroup({ className, ...props }: React.ComponentProps<'optgroup'>) {\n return (\n <optgroup\n data-slot='native-select-optgroup'\n className={cn('bg-[Canvas] text-[CanvasText]', className)}\n {...props}\n />\n )\n}\n\nexport { NativeSelect, NativeSelectOptGroup, NativeSelectOption, nativeSelectVariants }\n"]}
|
|
@@ -4,6 +4,7 @@ import { NavigationMenu as NavigationMenu$1 } from '@base-ui/react/navigation-me
|
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import { IconKeyboardArrowDown } from '../icons/keyboard-arrow-down.js';
|
|
6
6
|
import { ButtonGroupBoundary } from '../lib/button-group-context.js';
|
|
7
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
7
8
|
import { cn } from '../lib/utils.js';
|
|
8
9
|
import { Link } from '../components/link.js';
|
|
9
10
|
|
|
@@ -54,7 +55,7 @@ function NavigationMenu({
|
|
|
54
55
|
...props,
|
|
55
56
|
children: [
|
|
56
57
|
children,
|
|
57
|
-
/* @__PURE__ */ jsx(NavigationMenu$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
58
|
+
/* @__PURE__ */ jsx(NavigationMenu$1.Portal, { children: /* @__PURE__ */ jsx(PortalBoundary, { children: /* @__PURE__ */ jsx(
|
|
58
59
|
NavigationMenu$1.Positioner,
|
|
59
60
|
{
|
|
60
61
|
"data-slot": "navigation-menu-positioner",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/navigation-menu.tsx"],"names":["NavigationMenuPrimitive"],"mappings":";;;;;;;;AAkCA,MAAM,iBAAA,GAAoB;AAAA,EACxB,8EAAA;AAAA,EACA,2EAAA;AAAA,EACA;AACF,CAAA;AAgBA,MAAM,gCAAgC,GAAA,CAAI;AAAA,EACxC,GAAG,iBAAA;AAAA;AAAA;AAAA,EAGH,0JAAA;AAAA,EACA,gCAAA;AAAA,EACA,+BAAA;AAAA;AAAA;AAAA;AAAA,EAIA,0FAAA;AAAA;AAAA,EAEA,sCAAA;AAAA,EACA,kIAAA;AAAA,EACA;AACF,CAAC;AAyDD,SAAS,cAAA,CAAe;AAAA,EACtB,SAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA,GAAa,CAAA;AAAA,EACb,KAAA;AAAA,EACA,WAAA;AAAA;AAAA,EAEA,gBAAA,GAAmB,EAAA;AAAA;AAAA,EAEnB,kBAAA,GAAqB,EAAE,IAAA,EAAM,MAAA,EAAO;AAAA,EACpC,cAAA;AAAA,EACA,UAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAwB;AACtB,EAAA,uBACE,IAAA;AAAA,IAACA,gBAAA,CAAwB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,QACT,iDAAA;AAAA,QACA,4FAAA;AAAA,QACA,2DAAA;AAAA;AAAA,QAEA,uEAAA;AAAA,QACA,uEAAA;AAAA,QACA,oEAAA;AAAA,QACA,sEAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAgBJ,QAAA,kBAAA,GAAA,CAAC,uBAAqB,QAAA,EAAS;AAAA;AAAA,GACjC;AAEJ;AAmCA,SAAS,kBAAA,CAAmB;AAAA,EAC1B,SAAA;AAAA,EACA,IAAA;AAAA,EACA,YAAA,GAAe,IAAA;AAAA,EACf,GAAG;AACL,CAAA,EAA4B;AAC1B,EAAA,uBACE,GAAA;AAAA,IAACA,gBAAA,CAAwB,IAAA;AAAA,IAAxB;AAAA,MACC,WAAA,EAAU,sBAAA;AAAA,MACV,YAAA;AAAA,MACA,SAAA,EAAW,EAAA;AAAA,QACT,iBAAA;AAAA,QACA,4DAAA;AAAA,QACA,+BAAA;AAAA,QACA,0FAAA;AAAA;AAAA,QAEA,kCAAA;AAAA,QACA,kIAAA;AAAA;AAAA;AAAA,QAGA,0FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,MAAA,kBAAQ,GAAA,CAAC,IAAA,EAAA,EAAK,OAAA,EAAQ,YAAW,IAAA,EAAY,CAAA;AAAA,MAC5C,GAAG;AAAA;AAAA,GACN;AAEJ","file":"navigation-menu.js","sourcesContent":["'use client'\n\nimport { NavigationMenu as NavigationMenuPrimitive } from '@base-ui/react/navigation-menu'\nimport { cva } from 'class-variance-authority'\nimport type * as React from 'react'\n\nimport { IconKeyboardArrowDown } from '../icons/keyboard-arrow-down.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { cn } from '../lib/utils.js'\n\nimport { Link, type LinkProps } from '../components/link.js'\n\n// ─── Shared motion + ink tokens ───────────────────────────────────────────────\n\n// One easing curve — ease-[cubic-bezier(0.22,1,0.36,1)] — is written literally\n// on every animated part (positioner glide, popup resize, content cross-fade,\n// chevron flip) so the menu reads as a single surface in motion, not four\n// independent animations. It is Base UI's documented nav-menu curve: a strong\n// ease-out that settles without overshoot. Written out per-use rather than\n// composed from a shared const so every class stays a literal for Tailwind's\n// source-text scanner.\n\n// Every interactive tint in the menu derives from a single --nav-menu-ink\n// token via color-mix, mirroring the --footer-ink / --link-color pattern\n// (see footer.tsx, link.tsx): a restyle only has to swap the one ink value and\n// the resting/active halos follow. The derivations are written literally\n// (not template-built) because Tailwind scans source text for class names —\n// a computed string would never be emitted.\n//\n// Ink values use the RAW masterbrand tokens (--primary-800 / --primary-200)\n// rather than Tailwind's --color-* bridge aliases: Tailwind v4 tree-shakes\n// unreferenced @theme keys, and a reference from inside an arbitrary property\n// is not a usage signal. The raw tokens are plain :root declarations from\n// @nswds/tokens and always resolve.\nconst navigationMenuInk = [\n '[--nav-menu-ink:var(--primary-800)] dark:[--nav-menu-ink:var(--primary-200)]',\n '[--nav-menu-halo:color-mix(in_oklch,var(--nav-menu-ink)_10%,transparent)]',\n '[--nav-menu-halo-active:color-mix(in_oklch,var(--nav-menu-ink)_18%,transparent)]',\n]\n\n// ─── Trigger styling (exported for reuse) ─────────────────────────────────────\n\n/**\n * Trigger chrome, exported as a cva so siblings (e.g. a main-nav pattern) and\n * plain links that should sit visually beside triggers can reuse or extend it —\n * the app source's `Contact` item renders an `<a>` with exactly these classes.\n *\n * The 10% ink halo marks hover/open and the 18% mix marks pressed; both are\n * backgrounds behind unchanged text, so text contrast is untouched. The\n * keyboard focus indicator is a 2px outline in the ink colour itself\n * (primary-800 on light surfaces, primary-200 in dark mode) — well above the\n * 3:1 non-text contrast minimum of WCAG 2.2 SC 1.4.11 against the white/dark\n * popover surfaces, and offset so it is never obscured (SC 2.4.7, 2.4.11).\n */\nconst navigationMenuTriggerVariants = cva([\n ...navigationMenuInk,\n // Layout — h-9 keeps the row compact; the halo box is the pointer target.\n // mb-2 pairs with the list's bottom hairline, matching the app source.\n 'group mb-2 inline-flex h-9 w-max cursor-pointer items-center justify-center gap-1 rounded-sm px-4 py-2 text-sm font-medium whitespace-nowrap select-none',\n 'bg-transparent text-foreground',\n 'motion-safe:transition-colors',\n // Resting halo on hover/focus/open. `focus:` (not focus-visible) is\n // deliberate for the tint — like Button, triggers give click feedback —\n // while the *outline* below stays keyboard-only.\n 'hover:bg-(--nav-menu-halo) focus:bg-(--nav-menu-halo) active:bg-(--nav-menu-halo-active)',\n // Base UI marks the trigger whose popup is open with data-popup-open.\n 'data-popup-open:bg-(--nav-menu-halo)',\n 'outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--nav-menu-ink)',\n 'disabled:pointer-events-none disabled:opacity-50',\n])\n\n// ─── Root ─────────────────────────────────────────────────────────────────────\n\ntype NavigationMenuProps = Omit<NavigationMenuPrimitive.Root.Props, 'className'> &\n Pick<\n NavigationMenuPrimitive.Positioner.Props,\n 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'collisionPadding' | 'collisionAvoidance'\n > & {\n className?: string\n /** Extra classes for the shared popup surface (sizing, width caps, …). */\n popupClassName?: string\n /**\n * Inline styles for the shared popup surface. The popup normally sizes\n * itself from Base UI's `--popup-width`/`--popup-height`, which are\n * measured ONCE when a section activates — geometry that must track\n * something that can change while the menu is open (MainNav's\n * container-width panels, say) goes stale there. An inline style wins\n * over the measured vars and stays reactive to re-renders.\n */\n popupStyle?: React.CSSProperties\n }\n\n/**\n * Top-level navigation menu — a menubar of triggers whose panels open into one\n * shared, animated popup.\n *\n * INTERNAL to MainNav — not exported from the package barrel, not a registry\n * item, no stories. It began as a public generic wrapper but was pulled from\n * the public API: bare primitive wrappers are not the nswds-ui style (the\n * design system publishes NSW-branded components, not shadcn-alikes), and\n * MainNav is the supported way to get this behaviour. The file ships inside\n * the main-nav registry item, and the module remains reachable through the\n * package's undocumented `components/navigation-menu` export subpath purely\n * as a build artefact — treat that as private API with no stability promise.\n * (The package name is deliberately not written out here: this comment ships\n * in registry content, and the alias-leak guard rejects any occurrence of the\n * package-prefixed import form.)\n *\n * Consumers only write `List > Item > (Trigger + Content)` pairs; the popup\n * plumbing Base UI requires (Portal → Positioner → Popup → Viewport, rendered\n * once at root level, into which every `Content` teleports) is composed here so\n * it cannot be assembled wrong. Positioning knobs (`side`, `sideOffset`,\n * `align`, `collisionPadding`, `collisionAvoidance`) pass through to the\n * internal Positioner.\n *\n * Accessibility is inherited from Base UI: the root renders a `<nav>` landmark\n * (pass `aria-label` when a page has more than one), triggers are real buttons\n * wired with `aria-expanded`/`aria-controls`, ArrowDown/Enter open from the\n * keyboard, arrow keys move along the list, and Escape or focus-out closes\n * (WAI-ARIA disclosure navigation pattern). Do not add ARIA by hand.\n *\n * Departure from the nswds-app source: that wrapper was Radix-based with an\n * optional inline viewport (`viewport` prop); Base UI's model has exactly one\n * viewport, so the prop is gone. Radix's `delayDuration`/`skipDelayDuration`\n * map to Base UI's `delay`/`closeDelay` (both default 50ms).\n */\nfunction NavigationMenu({\n className,\n children,\n side,\n sideOffset = 8,\n align,\n alignOffset,\n // Keep a gutter between the popup and the viewport edge on small screens.\n collisionPadding = 20,\n // Nav panels should never flip beside their menubar — cap size instead.\n collisionAvoidance = { side: 'none' },\n popupClassName,\n popupStyle,\n ...props\n}: NavigationMenuProps) {\n return (\n <NavigationMenuPrimitive.Root\n data-slot='navigation-menu'\n className={cn(\n 'group/navigation-menu relative flex max-w-max flex-1 items-center justify-center',\n className,\n )}\n {...props}\n >\n {children}\n <NavigationMenuPrimitive.Portal>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>\n <NavigationMenuPrimitive.Positioner\n data-slot='navigation-menu-positioner'\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n collisionPadding={collisionPadding}\n collisionAvoidance={collisionAvoidance}\n className={cn(\n // Base UI reports its measured geometry through these vars; sizing\n // the box from them lets top/left glide between triggers.\n 'isolate z-50 box-border h-[var(--positioner-height)] w-[var(--positioner-width)] max-w-[var(--available-width)]',\n 'duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-safe:transition-[top,left,right,bottom]',\n // data-instant: Base UI disables the glide (e.g. keyboard re-anchor).\n 'data-instant:transition-none',\n )}\n >\n <NavigationMenuPrimitive.Popup\n data-slot='navigation-menu-popup'\n className={cn(\n // House popup surface (see popover.tsx / sheet.tsx).\n 'relative rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10',\n // Width/height track the active Content's size (Base UI measures\n // it into --popup-*), so switching sections morphs the surface\n // instead of jump-cutting.\n 'h-[var(--popup-height)] w-[var(--popup-width)] max-w-[var(--available-width)] origin-(--transform-origin)',\n 'duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-safe:transition-[opacity,transform,width,height,scale,translate]',\n // Open/close via Base UI transition attributes.\n 'data-starting-style:scale-95 data-starting-style:opacity-0',\n 'data-ending-style:scale-95 data-ending-style:opacity-0',\n popupClassName,\n )}\n style={popupStyle}\n >\n <NavigationMenuPrimitive.Viewport\n data-slot='navigation-menu-viewport'\n // Clips the outgoing/incoming Content pair during a section\n // switch; rounded to match the popup so corners don't leak.\n className='relative size-full overflow-hidden rounded-md'\n />\n </NavigationMenuPrimitive.Popup>\n </NavigationMenuPrimitive.Positioner>\n </ButtonGroupBoundary>\n </NavigationMenuPrimitive.Portal>\n </NavigationMenuPrimitive.Root>\n )\n}\n\n// ─── List / Item ──────────────────────────────────────────────────────────────\n\ntype NavigationMenuListProps = Omit<NavigationMenuPrimitive.List.Props, 'className'> & {\n className?: string\n}\n\n/**\n * The menubar row of triggers. Base UI renders a `<ul>` and manages roving\n * arrow-key focus between the items.\n *\n * Carries the app source's bottom hairline (tokenised from raw grey utilities\n * to the semantic `border-border`, which already flips for dark mode) and its\n * hidden-scrollbar overflow so a long menu can pan on narrow screens.\n *\n * `overflow-x-auto` is what makes that panning real. The scrollbar-HIDING\n * declarations beside it (`[scrollbar-width:none]`, the `::-webkit-scrollbar`\n * rule) are inert on their own: an `overflow: visible` box has no scrollbar to\n * hide, so without this the row simply overflowed its container and pushed a\n * horizontal scrollbar onto the page. `whitespace-nowrap` plus the `shrink-0`\n * items MainNav renders means a bar with more entries than fit is the normal\n * case on a phone, not an edge case.\n *\n * Two consequences of becoming a scroll container, both handled at the call\n * site rather than here:\n *\n * - Per CSS overflow, a non-visible `overflow-x` forces `overflow-y` to\n * compute to `auto`, so anything drawn OUTSIDE a row item's border box is\n * clipped. Items inside the list therefore use inset focus rings\n * (`-outline-offset-*`) — see `mainNavTriggerClassName` /\n * `mainNavTopLinkClassName`. Links inside a `NavigationMenuContent` panel\n * are portalled out of this box and keep the house outward-offset ring.\n * - `justify-center` (the default below) makes the leading overflow\n * unreachable in a scroll container — the well-known centred-flex overflow\n * trap. MainNav overrides it with `justify-start`; any future consumer that\n * keeps the centred default must not also rely on scrolling.\n */\nfunction NavigationMenuList({ className, ...props }: NavigationMenuListProps) {\n return (\n <NavigationMenuPrimitive.List\n data-slot='navigation-menu-list'\n className={cn(\n 'group flex flex-1 list-none items-center justify-center gap-1',\n '[scrollbar-width:none] overflow-x-auto border-b border-border whitespace-nowrap [&::-webkit-scrollbar]:hidden',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype NavigationMenuItemProps = Omit<NavigationMenuPrimitive.Item.Props, 'className'> & {\n className?: string\n}\n\n/**\n * One menubar entry (`<li>`), pairing a `NavigationMenuTrigger` with its\n * `NavigationMenuContent` — or holding a bare `NavigationMenuLink` for items\n * with no panel. Pass `value` when controlling the open item programmatically.\n */\nfunction NavigationMenuItem({ className, ...props }: NavigationMenuItemProps) {\n return (\n <NavigationMenuPrimitive.Item\n data-slot='navigation-menu-item'\n className={cn('relative', className)}\n {...props}\n />\n )\n}\n\n// ─── Trigger ──────────────────────────────────────────────────────────────────\n\ntype NavigationMenuTriggerProps = Omit<NavigationMenuPrimitive.Trigger.Props, 'className'> & {\n className?: string\n}\n\n/**\n * Opens the item's panel. Renders a real `<button>` (never an anchor — the\n * trigger discloses content, it doesn't navigate), which Base UI wires with\n * `aria-expanded`/`aria-controls` and hover/click/keyboard open behaviour.\n *\n * The trailing chevron rides Base UI's Icon part, which mirrors the trigger's\n * `data-popup-open` attribute — the 180° flip is pure CSS off that attribute\n * (no JS state), and is suppressed for reduced-motion users (WCAG 2.3.3).\n * The chevron is decorative, so the Icon part is `aria-hidden`: it never\n * enters the button's accessible name, and the open state it hints at is\n * already conveyed programmatically via `aria-expanded` (SC 4.1.2).\n */\nfunction NavigationMenuTrigger({ className, children, ...props }: NavigationMenuTriggerProps) {\n return (\n <NavigationMenuPrimitive.Trigger\n data-slot='navigation-menu-trigger'\n className={cn(navigationMenuTriggerVariants(), className)}\n {...props}\n >\n {children}\n <NavigationMenuPrimitive.Icon\n data-slot='navigation-menu-icon'\n aria-hidden='true'\n className='flex duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] data-popup-open:rotate-180 motion-safe:transition-transform'\n >\n <IconKeyboardArrowDown className='size-5' />\n </NavigationMenuPrimitive.Icon>\n </NavigationMenuPrimitive.Trigger>\n )\n}\n\n// ─── Content ──────────────────────────────────────────────────────────────────\n\ntype NavigationMenuContentProps = Omit<NavigationMenuPrimitive.Content.Props, 'className'> & {\n className?: string\n}\n\n/**\n * The panel for one item. Authored inline next to its Trigger, but rendered\n * (teleported by Base UI) into the shared root-level Viewport while active —\n * so panel-to-panel switches cross-fade inside one popup surface.\n *\n * The directional slide keys off `data-activation-direction` (which adjacent\n * trigger the user came from), matching the app source's from-start/from-end\n * motion. Set `keepMounted` to keep the panel in the DOM for SSR crawlers.\n */\nfunction NavigationMenuContent({ className, children, ...props }: NavigationMenuContentProps) {\n return (\n <NavigationMenuPrimitive.Content\n data-slot='navigation-menu-content'\n className={cn(\n 'h-full w-max max-w-[var(--available-width)] p-2',\n 'duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-safe:transition-[opacity,translate]',\n 'data-ending-style:opacity-0 data-starting-style:opacity-0',\n // Slide with the direction of travel between adjacent triggers.\n 'data-starting-style:data-[activation-direction=left]:-translate-x-1/2',\n 'data-starting-style:data-[activation-direction=right]:translate-x-1/2',\n 'data-ending-style:data-[activation-direction=left]:translate-x-1/2',\n 'data-ending-style:data-[activation-direction=right]:-translate-x-1/2',\n className,\n )}\n {...props}\n >\n {/* Reset the button group HERE, not only at the portal in the root.\n This element is declared by the consumer inside NavigationMenuItem,\n so React context reaches it from whatever encloses the menu — while\n Base UI hosts its DOM in the portalled viewport, where the group's\n own CSS cannot follow. Opened from inside a ButtonGroup, a control\n in this panel would otherwise get the JS half of the segment\n treatment and not the CSS half: squared corners and a ghost variant\n on the panel's own surface, and on a solid band a label re-inked to\n the band's colour. Verified in the browser: the link measured\n `data-segment=\"default\"`, `data-band=\"outline\"` and a 0px radius\n while sitting outside the group in the DOM.\n `check:portal-boundary` cannot see this one — it checks the portal,\n and this content is declared outside it — so the `In Overlays` play\n is what pins it. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </NavigationMenuPrimitive.Content>\n )\n}\n\n// ─── Link ─────────────────────────────────────────────────────────────────────\n\ntype NavigationMenuLinkProps = Omit<\n NavigationMenuPrimitive.Link.Props,\n 'className' | 'render' | 'href'\n> & {\n className?: string\n /**\n * Link target. Accepts the same string-or-UrlObject union as `Link`, since\n * the rendered element may be a framework link injected via `LinkProvider`.\n */\n href: LinkProps['href']\n}\n\n/**\n * A navigation link inside (or beside) the menu. Composes the design system's\n * `Link` through Base UI's `render` prop: Base UI keeps the behaviour —\n * roving focus, focus-out closing, `aria-current='page'` when `active`, close\n * on click — while `Link` supplies the element, so a `LinkProvider` framework\n * component (e.g. next/link) is injected automatically. `Link` renders with\n * `variant='unstyled'`; this component owns the visual treatment (same ink\n * halo/outline contract as the trigger — see `navigationMenuTriggerVariants`).\n *\n * Departure from Base UI's default: `closeOnClick` defaults to **true** here.\n * In an SPA a client-side navigation doesn't reload the document, so a menu\n * that stays open after choosing a destination reads as broken; pass\n * `closeOnClick={false}` for in-page links that should keep the panel open.\n *\n * Set `active` for the current page (the app source's `usePathname` check is\n * a framework API this package must not import — compare in the consumer and\n * pass the result down): it sets `aria-current='page'` (WCAG 2.4.8 support)\n * and the persistent halo via `data-active`.\n */\nfunction NavigationMenuLink({\n className,\n href,\n closeOnClick = true,\n ...props\n}: NavigationMenuLinkProps) {\n return (\n <NavigationMenuPrimitive.Link\n data-slot='navigation-menu-link'\n closeOnClick={closeOnClick}\n className={cn(\n navigationMenuInk,\n 'flex flex-col gap-1 rounded-sm p-2 text-sm text-foreground',\n 'motion-safe:transition-colors',\n 'hover:bg-(--nav-menu-halo) focus:bg-(--nav-menu-halo) active:bg-(--nav-menu-halo-active)',\n // Persistent tint for the current page (`active` prop → data-active).\n 'data-active:bg-(--nav-menu-halo)',\n 'outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--nav-menu-ink)',\n // Unsized inline icons default to text scale and muted ink; explicit\n // size-*/text-* classes on the icon win.\n \"[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground\",\n className,\n )}\n render={<Link variant='unstyled' href={href} />}\n {...props}\n />\n )\n}\n\nexport {\n NavigationMenu,\n NavigationMenuContent,\n NavigationMenuItem,\n NavigationMenuLink,\n NavigationMenuList,\n NavigationMenuTrigger,\n navigationMenuTriggerVariants,\n}\nexport type {\n NavigationMenuContentProps,\n NavigationMenuItemProps,\n NavigationMenuLinkProps,\n NavigationMenuListProps,\n NavigationMenuProps,\n NavigationMenuTriggerProps,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/navigation-menu.tsx"],"names":["NavigationMenuPrimitive"],"mappings":";;;;;;;;;AAmCA,MAAM,iBAAA,GAAoB;AAAA,EACxB,8EAAA;AAAA,EACA,2EAAA;AAAA,EACA;AACF,CAAA;AAgBA,MAAM,gCAAgC,GAAA,CAAI;AAAA,EACxC,GAAG,iBAAA;AAAA;AAAA;AAAA,EAGH,0JAAA;AAAA,EACA,gCAAA;AAAA,EACA,+BAAA;AAAA;AAAA;AA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AY,CAAA;AAAA,MAC5C,GAAG;AAAA;AAAA,GACN;AAEJ","file":"navigation-menu.js","sourcesContent":["'use client'\n\nimport { NavigationMenu as NavigationMenuPrimitive } from '@base-ui/react/navigation-menu'\nimport { cva } from 'class-variance-authority'\nimport type * as React from 'react'\n\nimport { IconKeyboardArrowDown } from '../icons/keyboard-arrow-down.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\nimport { Link, type LinkProps } from '../components/link.js'\n\n// ─── Shared motion + ink tokens ───────────────────────────────────────────────\n\n// One easing curve — ease-[cubic-bezier(0.22,1,0.36,1)] — is written literally\n// on every animated part (positioner glide, popup resize, content cross-fade,\n// chevron flip) so the menu reads as a single surface in motion, not four\n// independent animations. It is Base UI's documented nav-menu curve: a strong\n// ease-out that settles without overshoot. Written out per-use rather than\n// composed from a shared const so every class stays a literal for Tailwind's\n// source-text scanner.\n\n// Every interactive tint in the menu derives from a single --nav-menu-ink\n// token via color-mix, mirroring the --footer-ink / --link-color pattern\n// (see footer.tsx, link.tsx): a restyle only has to swap the one ink value and\n// the resting/active halos follow. The derivations are written literally\n// (not template-built) because Tailwind scans source text for class names —\n// a computed string would never be emitted.\n//\n// Ink values use the RAW masterbrand tokens (--primary-800 / --primary-200)\n// rather than Tailwind's --color-* bridge aliases: Tailwind v4 tree-shakes\n// unreferenced @theme keys, and a reference from inside an arbitrary property\n// is not a usage signal. The raw tokens are plain :root declarations from\n// @nswds/tokens and always resolve.\nconst navigationMenuInk = [\n '[--nav-menu-ink:var(--primary-800)] dark:[--nav-menu-ink:var(--primary-200)]',\n '[--nav-menu-halo:color-mix(in_oklch,var(--nav-menu-ink)_10%,transparent)]',\n '[--nav-menu-halo-active:color-mix(in_oklch,var(--nav-menu-ink)_18%,transparent)]',\n]\n\n// ─── Trigger styling (exported for reuse) ─────────────────────────────────────\n\n/**\n * Trigger chrome, exported as a cva so siblings (e.g. a main-nav pattern) and\n * plain links that should sit visually beside triggers can reuse or extend it —\n * the app source's `Contact` item renders an `<a>` with exactly these classes.\n *\n * The 10% ink halo marks hover/open and the 18% mix marks pressed; both are\n * backgrounds behind unchanged text, so text contrast is untouched. The\n * keyboard focus indicator is a 2px outline in the ink colour itself\n * (primary-800 on light surfaces, primary-200 in dark mode) — well above the\n * 3:1 non-text contrast minimum of WCAG 2.2 SC 1.4.11 against the white/dark\n * popover surfaces, and offset so it is never obscured (SC 2.4.7, 2.4.11).\n */\nconst navigationMenuTriggerVariants = cva([\n ...navigationMenuInk,\n // Layout — h-9 keeps the row compact; the halo box is the pointer target.\n // mb-2 pairs with the list's bottom hairline, matching the app source.\n 'group mb-2 inline-flex h-9 w-max cursor-pointer items-center justify-center gap-1 rounded-sm px-4 py-2 text-sm font-medium whitespace-nowrap select-none',\n 'bg-transparent text-foreground',\n 'motion-safe:transition-colors',\n // Resting halo on hover/focus/open. `focus:` (not focus-visible) is\n // deliberate for the tint — like Button, triggers give click feedback —\n // while the *outline* below stays keyboard-only.\n 'hover:bg-(--nav-menu-halo) focus:bg-(--nav-menu-halo) active:bg-(--nav-menu-halo-active)',\n // Base UI marks the trigger whose popup is open with data-popup-open.\n 'data-popup-open:bg-(--nav-menu-halo)',\n 'outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--nav-menu-ink)',\n 'disabled:pointer-events-none disabled:opacity-50',\n])\n\n// ─── Root ─────────────────────────────────────────────────────────────────────\n\ntype NavigationMenuProps = Omit<NavigationMenuPrimitive.Root.Props, 'className'> &\n Pick<\n NavigationMenuPrimitive.Positioner.Props,\n 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'collisionPadding' | 'collisionAvoidance'\n > & {\n className?: string\n /** Extra classes for the shared popup surface (sizing, width caps, …). */\n popupClassName?: string\n /**\n * Inline styles for the shared popup surface. The popup normally sizes\n * itself from Base UI's `--popup-width`/`--popup-height`, which are\n * measured ONCE when a section activates — geometry that must track\n * something that can change while the menu is open (MainNav's\n * container-width panels, say) goes stale there. An inline style wins\n * over the measured vars and stays reactive to re-renders.\n */\n popupStyle?: React.CSSProperties\n }\n\n/**\n * Top-level navigation menu — a menubar of triggers whose panels open into one\n * shared, animated popup.\n *\n * INTERNAL to MainNav — not exported from the package barrel, not a registry\n * item, no stories. It began as a public generic wrapper but was pulled from\n * the public API: bare primitive wrappers are not the nswds-ui style (the\n * design system publishes NSW-branded components, not shadcn-alikes), and\n * MainNav is the supported way to get this behaviour. The file ships inside\n * the main-nav registry item, and the module remains reachable through the\n * package's undocumented `components/navigation-menu` export subpath purely\n * as a build artefact — treat that as private API with no stability promise.\n * (The package name is deliberately not written out here: this comment ships\n * in registry content, and the alias-leak guard rejects any occurrence of the\n * package-prefixed import form.)\n *\n * Consumers only write `List > Item > (Trigger + Content)` pairs; the popup\n * plumbing Base UI requires (Portal → Positioner → Popup → Viewport, rendered\n * once at root level, into which every `Content` teleports) is composed here so\n * it cannot be assembled wrong. Positioning knobs (`side`, `sideOffset`,\n * `align`, `collisionPadding`, `collisionAvoidance`) pass through to the\n * internal Positioner.\n *\n * Accessibility is inherited from Base UI: the root renders a `<nav>` landmark\n * (pass `aria-label` when a page has more than one), triggers are real buttons\n * wired with `aria-expanded`/`aria-controls`, ArrowDown/Enter open from the\n * keyboard, arrow keys move along the list, and Escape or focus-out closes\n * (WAI-ARIA disclosure navigation pattern). Do not add ARIA by hand.\n *\n * Departure from the nswds-app source: that wrapper was Radix-based with an\n * optional inline viewport (`viewport` prop); Base UI's model has exactly one\n * viewport, so the prop is gone. Radix's `delayDuration`/`skipDelayDuration`\n * map to Base UI's `delay`/`closeDelay` (both default 50ms).\n */\nfunction NavigationMenu({\n className,\n children,\n side,\n sideOffset = 8,\n align,\n alignOffset,\n // Keep a gutter between the popup and the viewport edge on small screens.\n collisionPadding = 20,\n // Nav panels should never flip beside their menubar — cap size instead.\n collisionAvoidance = { side: 'none' },\n popupClassName,\n popupStyle,\n ...props\n}: NavigationMenuProps) {\n return (\n <NavigationMenuPrimitive.Root\n data-slot='navigation-menu'\n className={cn(\n 'group/navigation-menu relative flex max-w-max flex-1 items-center justify-center',\n className,\n )}\n {...props}\n >\n {children}\n <NavigationMenuPrimitive.Portal>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>\n <NavigationMenuPrimitive.Positioner\n data-slot='navigation-menu-positioner'\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n collisionPadding={collisionPadding}\n collisionAvoidance={collisionAvoidance}\n className={cn(\n // Base UI reports its measured geometry through these vars; sizing\n // the box from them lets top/left glide between triggers.\n 'isolate z-50 box-border h-[var(--positioner-height)] w-[var(--positioner-width)] max-w-[var(--available-width)]',\n 'duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-safe:transition-[top,left,right,bottom]',\n // data-instant: Base UI disables the glide (e.g. keyboard re-anchor).\n 'data-instant:transition-none',\n )}\n >\n <NavigationMenuPrimitive.Popup\n data-slot='navigation-menu-popup'\n className={cn(\n // House popup surface (see popover.tsx / sheet.tsx).\n 'relative rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10',\n // Width/height track the active Content's size (Base UI measures\n // it into --popup-*), so switching sections morphs the surface\n // instead of jump-cutting.\n 'h-[var(--popup-height)] w-[var(--popup-width)] max-w-[var(--available-width)] origin-(--transform-origin)',\n 'duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-safe:transition-[opacity,transform,width,height,scale,translate]',\n // Open/close via Base UI transition attributes.\n 'data-starting-style:scale-95 data-starting-style:opacity-0',\n 'data-ending-style:scale-95 data-ending-style:opacity-0',\n popupClassName,\n )}\n style={popupStyle}\n >\n <NavigationMenuPrimitive.Viewport\n data-slot='navigation-menu-viewport'\n // Clips the outgoing/incoming Content pair during a section\n // switch; rounded to match the popup so corners don't leak.\n className='relative size-full overflow-hidden rounded-md'\n />\n </NavigationMenuPrimitive.Popup>\n </NavigationMenuPrimitive.Positioner>\n </PortalBoundary>\n </NavigationMenuPrimitive.Portal>\n </NavigationMenuPrimitive.Root>\n )\n}\n\n// ─── List / Item ──────────────────────────────────────────────────────────────\n\ntype NavigationMenuListProps = Omit<NavigationMenuPrimitive.List.Props, 'className'> & {\n className?: string\n}\n\n/**\n * The menubar row of triggers. Base UI renders a `<ul>` and manages roving\n * arrow-key focus between the items.\n *\n * Carries the app source's bottom hairline (tokenised from raw grey utilities\n * to the semantic `border-border`, which already flips for dark mode) and its\n * hidden-scrollbar overflow so a long menu can pan on narrow screens.\n *\n * `overflow-x-auto` is what makes that panning real. The scrollbar-HIDING\n * declarations beside it (`[scrollbar-width:none]`, the `::-webkit-scrollbar`\n * rule) are inert on their own: an `overflow: visible` box has no scrollbar to\n * hide, so without this the row simply overflowed its container and pushed a\n * horizontal scrollbar onto the page. `whitespace-nowrap` plus the `shrink-0`\n * items MainNav renders means a bar with more entries than fit is the normal\n * case on a phone, not an edge case.\n *\n * Two consequences of becoming a scroll container, both handled at the call\n * site rather than here:\n *\n * - Per CSS overflow, a non-visible `overflow-x` forces `overflow-y` to\n * compute to `auto`, so anything drawn OUTSIDE a row item's border box is\n * clipped. Items inside the list therefore use inset focus rings\n * (`-outline-offset-*`) — see `mainNavTriggerClassName` /\n * `mainNavTopLinkClassName`. Links inside a `NavigationMenuContent` panel\n * are portalled out of this box and keep the house outward-offset ring.\n * - `justify-center` (the default below) makes the leading overflow\n * unreachable in a scroll container — the well-known centred-flex overflow\n * trap. MainNav overrides it with `justify-start`; any future consumer that\n * keeps the centred default must not also rely on scrolling.\n */\nfunction NavigationMenuList({ className, ...props }: NavigationMenuListProps) {\n return (\n <NavigationMenuPrimitive.List\n data-slot='navigation-menu-list'\n className={cn(\n 'group flex flex-1 list-none items-center justify-center gap-1',\n '[scrollbar-width:none] overflow-x-auto border-b border-border whitespace-nowrap [&::-webkit-scrollbar]:hidden',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype NavigationMenuItemProps = Omit<NavigationMenuPrimitive.Item.Props, 'className'> & {\n className?: string\n}\n\n/**\n * One menubar entry (`<li>`), pairing a `NavigationMenuTrigger` with its\n * `NavigationMenuContent` — or holding a bare `NavigationMenuLink` for items\n * with no panel. Pass `value` when controlling the open item programmatically.\n */\nfunction NavigationMenuItem({ className, ...props }: NavigationMenuItemProps) {\n return (\n <NavigationMenuPrimitive.Item\n data-slot='navigation-menu-item'\n className={cn('relative', className)}\n {...props}\n />\n )\n}\n\n// ─── Trigger ──────────────────────────────────────────────────────────────────\n\ntype NavigationMenuTriggerProps = Omit<NavigationMenuPrimitive.Trigger.Props, 'className'> & {\n className?: string\n}\n\n/**\n * Opens the item's panel. Renders a real `<button>` (never an anchor — the\n * trigger discloses content, it doesn't navigate), which Base UI wires with\n * `aria-expanded`/`aria-controls` and hover/click/keyboard open behaviour.\n *\n * The trailing chevron rides Base UI's Icon part, which mirrors the trigger's\n * `data-popup-open` attribute — the 180° flip is pure CSS off that attribute\n * (no JS state), and is suppressed for reduced-motion users (WCAG 2.3.3).\n * The chevron is decorative, so the Icon part is `aria-hidden`: it never\n * enters the button's accessible name, and the open state it hints at is\n * already conveyed programmatically via `aria-expanded` (SC 4.1.2).\n */\nfunction NavigationMenuTrigger({ className, children, ...props }: NavigationMenuTriggerProps) {\n return (\n <NavigationMenuPrimitive.Trigger\n data-slot='navigation-menu-trigger'\n className={cn(navigationMenuTriggerVariants(), className)}\n {...props}\n >\n {children}\n <NavigationMenuPrimitive.Icon\n data-slot='navigation-menu-icon'\n aria-hidden='true'\n className='flex duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] data-popup-open:rotate-180 motion-safe:transition-transform'\n >\n <IconKeyboardArrowDown className='size-5' />\n </NavigationMenuPrimitive.Icon>\n </NavigationMenuPrimitive.Trigger>\n )\n}\n\n// ─── Content ──────────────────────────────────────────────────────────────────\n\ntype NavigationMenuContentProps = Omit<NavigationMenuPrimitive.Content.Props, 'className'> & {\n className?: string\n}\n\n/**\n * The panel for one item. Authored inline next to its Trigger, but rendered\n * (teleported by Base UI) into the shared root-level Viewport while active —\n * so panel-to-panel switches cross-fade inside one popup surface.\n *\n * The directional slide keys off `data-activation-direction` (which adjacent\n * trigger the user came from), matching the app source's from-start/from-end\n * motion. Set `keepMounted` to keep the panel in the DOM for SSR crawlers.\n */\nfunction NavigationMenuContent({ className, children, ...props }: NavigationMenuContentProps) {\n return (\n <NavigationMenuPrimitive.Content\n data-slot='navigation-menu-content'\n className={cn(\n 'h-full w-max max-w-[var(--available-width)] p-2',\n 'duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-safe:transition-[opacity,translate]',\n 'data-ending-style:opacity-0 data-starting-style:opacity-0',\n // Slide with the direction of travel between adjacent triggers.\n 'data-starting-style:data-[activation-direction=left]:-translate-x-1/2',\n 'data-starting-style:data-[activation-direction=right]:translate-x-1/2',\n 'data-ending-style:data-[activation-direction=left]:translate-x-1/2',\n 'data-ending-style:data-[activation-direction=right]:-translate-x-1/2',\n className,\n )}\n {...props}\n >\n {/* Reset the button group HERE, not only at the portal in the root.\n This element is declared by the consumer inside NavigationMenuItem,\n so React context reaches it from whatever encloses the menu — while\n Base UI hosts its DOM in the portalled viewport, where the group's\n own CSS cannot follow. Opened from inside a ButtonGroup, a control\n in this panel would otherwise get the JS half of the segment\n treatment and not the CSS half: squared corners and a ghost variant\n on the panel's own surface, and on a solid band a label re-inked to\n the band's colour. Verified in the browser: the link measured\n `data-segment=\"default\"`, `data-band=\"outline\"` and a 0px radius\n while sitting outside the group in the DOM.\n `check:portal-boundary` cannot see this one — it checks the portal,\n and this content is declared outside it — so the `In Overlays` play\n is what pins it. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </NavigationMenuPrimitive.Content>\n )\n}\n\n// ─── Link ─────────────────────────────────────────────────────────────────────\n\ntype NavigationMenuLinkProps = Omit<\n NavigationMenuPrimitive.Link.Props,\n 'className' | 'render' | 'href'\n> & {\n className?: string\n /**\n * Link target. Accepts the same string-or-UrlObject union as `Link`, since\n * the rendered element may be a framework link injected via `LinkProvider`.\n */\n href: LinkProps['href']\n}\n\n/**\n * A navigation link inside (or beside) the menu. Composes the design system's\n * `Link` through Base UI's `render` prop: Base UI keeps the behaviour —\n * roving focus, focus-out closing, `aria-current='page'` when `active`, close\n * on click — while `Link` supplies the element, so a `LinkProvider` framework\n * component (e.g. next/link) is injected automatically. `Link` renders with\n * `variant='unstyled'`; this component owns the visual treatment (same ink\n * halo/outline contract as the trigger — see `navigationMenuTriggerVariants`).\n *\n * Departure from Base UI's default: `closeOnClick` defaults to **true** here.\n * In an SPA a client-side navigation doesn't reload the document, so a menu\n * that stays open after choosing a destination reads as broken; pass\n * `closeOnClick={false}` for in-page links that should keep the panel open.\n *\n * Set `active` for the current page (the app source's `usePathname` check is\n * a framework API this package must not import — compare in the consumer and\n * pass the result down): it sets `aria-current='page'` (WCAG 2.4.8 support)\n * and the persistent halo via `data-active`.\n */\nfunction NavigationMenuLink({\n className,\n href,\n closeOnClick = true,\n ...props\n}: NavigationMenuLinkProps) {\n return (\n <NavigationMenuPrimitive.Link\n data-slot='navigation-menu-link'\n closeOnClick={closeOnClick}\n className={cn(\n navigationMenuInk,\n 'flex flex-col gap-1 rounded-sm p-2 text-sm text-foreground',\n 'motion-safe:transition-colors',\n 'hover:bg-(--nav-menu-halo) focus:bg-(--nav-menu-halo) active:bg-(--nav-menu-halo-active)',\n // Persistent tint for the current page (`active` prop → data-active).\n 'data-active:bg-(--nav-menu-halo)',\n 'outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--nav-menu-ink)',\n // Unsized inline icons default to text scale and muted ink; explicit\n // size-*/text-* classes on the icon win.\n \"[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground\",\n className,\n )}\n render={<Link variant='unstyled' href={href} />}\n {...props}\n />\n )\n}\n\nexport {\n NavigationMenu,\n NavigationMenuContent,\n NavigationMenuItem,\n NavigationMenuLink,\n NavigationMenuList,\n NavigationMenuTrigger,\n navigationMenuTriggerVariants,\n}\nexport type {\n NavigationMenuContentProps,\n NavigationMenuItemProps,\n NavigationMenuLinkProps,\n NavigationMenuListProps,\n NavigationMenuProps,\n NavigationMenuTriggerProps,\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Popover as Popover$1 } from '@base-ui/react/popover';
|
|
4
|
-
import {
|
|
4
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
5
5
|
import { cn } from '../lib/utils.js';
|
|
6
6
|
|
|
7
7
|
function Popover({ ...props }) {
|
|
@@ -18,7 +18,7 @@ function PopoverContent({
|
|
|
18
18
|
sideOffset = 4,
|
|
19
19
|
...props
|
|
20
20
|
}) {
|
|
21
|
-
return /* @__PURE__ */ jsx(Popover$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
21
|
+
return /* @__PURE__ */ jsx(Popover$1.Portal, { children: /* @__PURE__ */ jsx(PortalBoundary, { children: /* @__PURE__ */ jsx(
|
|
22
22
|
Popover$1.Positioner,
|
|
23
23
|
{
|
|
24
24
|
align,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/popover.tsx"],"names":["PopoverPrimitive"],"mappings":";;;;;AAQA,SAAS,OAAA,CAAQ,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC1D,EAAA,2BAAQA,SAAA,CAAiB,IAAA,EAAjB,EAAsB,WAAA,EAAU,SAAA,EAAW,GAAG,KAAA,EAAO,CAAA;AAC/D;AAEA,SAAS,cAAA,CAAe,EAAE,GAAG,KAAA,EAAM,EAAmC;AACpE,EAAA,2BAAQA,SAAA,CAAiB,OAAA,EAAjB,EAAyB,WAAA,EAAU,iBAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAC1E;AAEA,SAAS,cAAA,CAAe;AAAA,EACtB,SAAA;AAAA,EACA,KAAA,GAAQ,QAAA;AA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AAAA;AAAA;AACN;AAAA,KAEJ,CAAA,EACF,CAAA;AAEJ;AAEA,SAAS,aAAA,CAAc,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,gBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,6BAAA,EAA+B,SAAS,CAAA;AAAA,MACrD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAAiC;AAC3E,EAAA,uBACE,GAAA;AAAA,IAACA,SAAA,CAAiB,KAAA;AAAA,IAAjB;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,qBAAA,EAAuB,SAAS,CAAA;AAAA,MAC7C,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,kBAAA,CAAmB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAuC;AACvF,EAAA,uBACE,GAAA;AAAA,IAACA,SAAA,CAAiB,WAAA;AAAA,IAAjB;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,uBAAA,EAAyB,SAAS,CAAA;AAAA,MAC/C,GAAG;AAAA;AAAA,GACN;AAEJ","file":"popover.js","sourcesContent":["'use client'\n\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover'\nimport * as React from 'react'\n\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Popover({ ...props }: PopoverPrimitive.Root.Props) {\n return <PopoverPrimitive.Root data-slot='popover' {...props} />\n}\n\nfunction PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {\n return <PopoverPrimitive.Trigger data-slot='popover-trigger' {...props} />\n}\n\nfunction PopoverContent({\n className,\n align = 'center',\n alignOffset = 0,\n side = 'bottom',\n sideOffset = 4,\n ...props\n}: PopoverPrimitive.Popup.Props &\n Pick<PopoverPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {\n return (\n <PopoverPrimitive.Portal>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>\n <PopoverPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className='isolate z-50'\n >\n <PopoverPrimitive.Popup\n data-slot='popover-content'\n className={cn(\n 'z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-2.5 text-xs text-popover-foreground ring-1 ring-foreground/10 outline-hidden duration-100 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-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 </PopoverPrimitive.Positioner>\n </PortalBoundary>\n </PopoverPrimitive.Portal>\n )\n}\n\nfunction PopoverHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='popover-header'\n className={cn('flex flex-col gap-1 text-xs', className)}\n {...props}\n />\n )\n}\n\nfunction PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {\n return (\n <PopoverPrimitive.Title\n data-slot='popover-title'\n className={cn('text-sm font-medium', className)}\n {...props}\n />\n )\n}\n\nfunction PopoverDescription({ className, ...props }: PopoverPrimitive.Description.Props) {\n return (\n <PopoverPrimitive.Description\n data-slot='popover-description'\n className={cn('text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger }\n"]}
|
|
@@ -5,7 +5,7 @@ import { cva } from 'class-variance-authority';
|
|
|
5
5
|
import { IconCheck } from '../icons/check.js';
|
|
6
6
|
import { IconExpandLess } from '../icons/expand-less.js';
|
|
7
7
|
import { IconExpandMore } from '../icons/expand-more.js';
|
|
8
|
-
import {
|
|
8
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
9
9
|
import { resolveVariant } from '../lib/resolve-variant.js';
|
|
10
10
|
import { cn } from '../lib/utils.js';
|
|
11
11
|
|
|
@@ -51,8 +51,16 @@ const selectTriggerVariants = cva(
|
|
|
51
51
|
variant: {
|
|
52
52
|
// Crisp field — bordered white box; the default, matches Input exactly.
|
|
53
53
|
default: "border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)",
|
|
54
|
-
// Filled band —
|
|
55
|
-
|
|
54
|
+
// Filled band — a tinted surface with an underline, revealing the full
|
|
55
|
+
// border on hover. The tint is barely distinguishable from the page
|
|
56
|
+
// (1.09:1), so the underline, in the field border colour, is what
|
|
57
|
+
// identifies the control at 3:1 (#255, WCAG 1.4.11).
|
|
58
|
+
//
|
|
59
|
+
// Each side's colour is set on its own, never the `border-transparent`
|
|
60
|
+
// shorthand beside the `border-b-` longhand: the two tie on
|
|
61
|
+
// specificity, so a consumer's own Tailwind build re-emitting
|
|
62
|
+
// `border-transparent` after ours would win and erase the underline.
|
|
63
|
+
filled: "border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)"
|
|
56
64
|
},
|
|
57
65
|
size: {
|
|
58
66
|
default: "h-12 px-4 py-2",
|
|
@@ -101,7 +109,7 @@ function SelectContent({
|
|
|
101
109
|
alignItemWithTrigger = true,
|
|
102
110
|
...props
|
|
103
111
|
}) {
|
|
104
|
-
return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
112
|
+
return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(PortalBoundary, { children: /* @__PURE__ */ jsx(
|
|
105
113
|
Select$1.Positioner,
|
|
106
114
|
{
|
|
107
115
|
side,
|
|
@@ -1 +1 @@
|
|
|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,EAAU,SAAA,EAAU,qBAAA,EAAsB;AAAA;AAAA;AAC7C;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,eAAA,CAAgB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAoC;AACjF,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,SAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,kDAAA,EAAoD,SAAS,CAAA;AAAA,MAC1E,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,oBAAA,CAAqB;AAAA,EAC5B,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA+D;AAC7D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,aAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,yBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,0HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ;AAEA,SAAS,sBAAA,CAAuB;AAAA,EAC9B,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiE;AAC/D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,eAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,2BAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,6HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ","file":"select.js","sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconExpandLess } from '../icons/expand-less.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {\n return (\n <SelectPrimitive.Group\n data-slot='select-group'\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {\n return (\n <SelectPrimitive.Value\n data-slot='select-value'\n className={cn('flex flex-1 text-start', className)}\n {...props}\n />\n )\n}\n\nconst selectTriggerVariants = cva(\n // Field foundation shared with Input (input.tsx): the same --input-* semantic\n // tokens, 16px text, and an outline-based focus ring. No `outline-none` here —\n // it sets --tw-outline-style:none on the element and would suppress the focus\n // outline below. Dark mode and brand themes restyle via tokens, so there are\n // no dark: variants.\n //\n // Focus is `focus:`, not the `focus-visible:` Input uses — like Button, and\n // for the same reason (see button.tsx). This trigger is a <button>, and a\n // button focused by MOUSE does not match :focus-visible, so on a pointer click\n // the ring never painted. A native <select> DOES match :focus-visible on click\n // (the browser's form-control heuristic), which is why NativeSelect keeps\n // focus-visible; this custom trigger cannot, so `focus:` rings on click too and\n // the control reads as focused like the rest of the field family. Do not\n // \"unify\" it back to focus-visible.\n \"flex w-fit items-center justify-between gap-2 rounded-sm text-base whitespace-nowrap text-(--input-foreground) focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--input-ring) disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus:outline-(--input-invalid-ring) data-placeholder:text-(--input-placeholder) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 motion-safe:transition-colors [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n // Crisp field — bordered white box; the default, matches Input exactly.\n default:\n 'border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)',\n // Filled band — borderless tinted surface that reveals its border on hover.\n filled: 'border border-transparent bg-secondary hover:border-(--input-border)',\n },\n size: {\n default: 'h-12 px-4 py-2',\n sm: 'h-10 px-3 py-1.5',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\nfunction SelectTrigger({\n className,\n variant,\n size,\n children,\n ...props\n}: SelectPrimitive.Trigger.Props & VariantProps<typeof selectTriggerVariants>) {\n // Resolved once (see `resolveVariant`), so cva and the data attributes\n // agree for `null` and `''` as well as the default spelling.\n const variantway = resolveVariant(variant, 'default')\n const sizeway = resolveVariant(size, 'default')\n return (\n <SelectPrimitive.Trigger\n data-slot='select-trigger'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-size={sizeway}\n data-variant={variantway}\n className={cn(selectTriggerVariants({ variant: variantway, size: sizeway, className }))}\n >\n {children}\n <SelectPrimitive.Icon\n render={<IconExpandMore className='pointer-events-none size-5 text-primary' />}\n />\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectContent({\n className,\n children,\n side = 'bottom',\n sideOffset = 4,\n align = 'center',\n alignOffset = 0,\n alignItemWithTrigger = true,\n ...props\n}: SelectPrimitive.Popup.Props &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n >) {\n return (\n <SelectPrimitive.Portal>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>\n <SelectPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n alignItemWithTrigger={alignItemWithTrigger}\n className='isolate z-50'\n >\n <SelectPrimitive.Popup\n data-slot='select-content'\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n 'relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none 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-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 <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </ButtonGroupBoundary>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot='select-label'\n className={cn('px-4 py-2 text-base font-semibold text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props) {\n return (\n <SelectPrimitive.Item\n data-slot='select-item'\n className={cn(\n \"relative flex min-h-11 w-full cursor-default items-center gap-2 rounded-sm py-2 ps-4 pe-9 text-base outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText className='flex flex-1 shrink-0 gap-2 whitespace-nowrap'>\n {children}\n </SelectPrimitive.ItemText>\n <SelectPrimitive.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 </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n )\n}\n\nfunction SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props) {\n return (\n <SelectPrimitive.Separator\n data-slot='select-separator'\n className={cn('pointer-events-none -mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot='select-scroll-up-button'\n className={cn(\n \"top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandLess />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot='select-scroll-down-button'\n className={cn(\n \"bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandMore />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n selectTriggerVariants,\n SelectValue,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/select.tsx"],"names":["SelectPrimitive"],"mappings":";;;;;;;;;;AAaA,MAAM,SAASA,QAAA,CAAgB;AAE/B,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,iBAAA,EAAmB,SAAS,CAAA;AAAA,MACzC,GAAG;AAAA;AAAA,GAC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,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,oBAAA,CAAqB;AAAA,EAC5B,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA+D;AAC7D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,aAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,yBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,0HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ;AAEA,SAAS,sBAAA,CAAuB;AAAA,EAC9B,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiE;AAC/D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,eAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,2BAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,6HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ","file":"select.js","sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconExpandLess } from '../icons/expand-less.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {\n return (\n <SelectPrimitive.Group\n data-slot='select-group'\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {\n return (\n <SelectPrimitive.Value\n data-slot='select-value'\n className={cn('flex flex-1 text-start', className)}\n {...props}\n />\n )\n}\n\nconst selectTriggerVariants = cva(\n // Field foundation shared with Input (input.tsx): the same --input-* semantic\n // tokens, 16px text, and an outline-based focus ring. No `outline-none` here —\n // it sets --tw-outline-style:none on the element and would suppress the focus\n // outline below. Dark mode and brand themes restyle via tokens, so there are\n // no dark: variants.\n //\n // Focus is `focus:`, not the `focus-visible:` Input uses — like Button, and\n // for the same reason (see button.tsx). This trigger is a <button>, and a\n // button focused by MOUSE does not match :focus-visible, so on a pointer click\n // the ring never painted. A native <select> DOES match :focus-visible on click\n // (the browser's form-control heuristic), which is why NativeSelect keeps\n // focus-visible; this custom trigger cannot, so `focus:` rings on click too and\n // the control reads as focused like the rest of the field family. Do not\n // \"unify\" it back to focus-visible.\n \"flex w-fit items-center justify-between gap-2 rounded-sm text-base whitespace-nowrap text-(--input-foreground) focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--input-ring) disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus:outline-(--input-invalid-ring) data-placeholder:text-(--input-placeholder) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 motion-safe:transition-colors [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n // Crisp field — bordered white box; the default, matches Input exactly.\n default:\n 'border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)',\n // Filled band — a tinted surface with an underline, revealing the full\n // border on hover. The tint is barely distinguishable from the page\n // (1.09:1), so the underline, in the field border colour, is what\n // identifies the control at 3:1 (#255, WCAG 1.4.11).\n //\n // Each side's colour is set on its own, never the `border-transparent`\n // shorthand beside the `border-b-` longhand: the two tie on\n // specificity, so a consumer's own Tailwind build re-emitting\n // `border-transparent` after ours would win and erase the underline.\n filled:\n 'border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)',\n },\n size: {\n default: 'h-12 px-4 py-2',\n sm: 'h-10 px-3 py-1.5',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\nfunction SelectTrigger({\n className,\n variant,\n size,\n children,\n ...props\n}: SelectPrimitive.Trigger.Props & VariantProps<typeof selectTriggerVariants>) {\n // Resolved once (see `resolveVariant`), so cva and the data attributes\n // agree for `null` and `''` as well as the default spelling.\n const variantway = resolveVariant(variant, 'default')\n const sizeway = resolveVariant(size, 'default')\n return (\n <SelectPrimitive.Trigger\n data-slot='select-trigger'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-size={sizeway}\n data-variant={variantway}\n className={cn(selectTriggerVariants({ variant: variantway, size: sizeway, className }))}\n >\n {children}\n <SelectPrimitive.Icon\n render={<IconExpandMore className='pointer-events-none size-5 text-primary' />}\n />\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectContent({\n className,\n children,\n side = 'bottom',\n sideOffset = 4,\n align = 'center',\n alignOffset = 0,\n alignItemWithTrigger = true,\n ...props\n}: SelectPrimitive.Popup.Props &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n >) {\n return (\n <SelectPrimitive.Portal>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>\n <SelectPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n alignItemWithTrigger={alignItemWithTrigger}\n className='isolate z-50'\n >\n <SelectPrimitive.Popup\n data-slot='select-content'\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n 'relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none 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-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 <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalBoundary>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot='select-label'\n className={cn('px-4 py-2 text-base font-semibold text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props) {\n return (\n <SelectPrimitive.Item\n data-slot='select-item'\n className={cn(\n \"relative flex min-h-11 w-full cursor-default items-center gap-2 rounded-sm py-2 ps-4 pe-9 text-base outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText className='flex flex-1 shrink-0 gap-2 whitespace-nowrap'>\n {children}\n </SelectPrimitive.ItemText>\n <SelectPrimitive.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 </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n )\n}\n\nfunction SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props) {\n return (\n <SelectPrimitive.Separator\n data-slot='select-separator'\n className={cn('pointer-events-none -mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot='select-scroll-up-button'\n className={cn(\n \"top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandLess />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot='select-scroll-down-button'\n className={cn(\n \"bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandMore />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n selectTriggerVariants,\n SelectValue,\n}\n"]}
|
package/dist/components/sheet.js
CHANGED
|
@@ -4,8 +4,8 @@ import { Dialog } from '@base-ui/react/dialog';
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { Button } from '../components/button.js';
|
|
6
6
|
import { IconClose } from '../icons/close.js';
|
|
7
|
-
import { ButtonGroupBoundary } from '../lib/button-group-context.js';
|
|
8
7
|
import { overlayScrim } from '../lib/overlay.js';
|
|
8
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
9
9
|
import { cn } from '../lib/utils.js';
|
|
10
10
|
|
|
11
11
|
function Sheet({ ...props }) {
|
|
@@ -18,7 +18,7 @@ function SheetClose({ ...props }) {
|
|
|
18
18
|
return /* @__PURE__ */ jsx(Dialog.Close, { "data-slot": "sheet-close", ...props });
|
|
19
19
|
}
|
|
20
20
|
function SheetPortal({ children, ...props }) {
|
|
21
|
-
return /* @__PURE__ */ jsx(Dialog.Portal, { "data-slot": "sheet-portal", ...props, children: /* @__PURE__ */ jsx(
|
|
21
|
+
return /* @__PURE__ */ jsx(Dialog.Portal, { "data-slot": "sheet-portal", ...props, children: /* @__PURE__ */ jsx(PortalBoundary, { children }) });
|
|
22
22
|
}
|
|
23
23
|
function SheetOverlay({ className, ...props }) {
|
|
24
24
|
return /* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/sheet.tsx"],"names":["SheetPrimitive"],"mappings":";;;;;;;;;AAWA,SAAS,KAAA,CAAM,EAAE,GAAG,KAAA,EAAM,EAA8B;AACtD,EAAA,2BAAQA,MAAA,CAAe,IAAA,EAAf,EAAoB,WAAA,EAAU,OAAA,EAAS,GAAG,KAAA,EAAO,CAAA;AAC3D;AAEA,SAAS,YAAA,CAAa,EAAE,GAAG,KAAA,EAAM,EAAiC;AAChE,EAAA,2BAAQA,MAAA,CAAe,OAAA,EAAf,EAAuB,WAAA,EAAU,eAAA,EAAiB,GAAG,KAAA,EAAO,CAAA;AACtE;AAEA,SAAS,UAAA,CAAW,EAAE,GAAG,KAAA,EAAM,EAA+B;AAC5D,EAAA,2BAAQA,MAAA,CAAe,KAAA,EAAf,EAAqB,WAAA,EAAU,aAAA,EAAe,GAAG,KAAA,EAAO,CAAA;AAClE;AAEA,SAAS,WAAA,CAAY,EAAE,QAAA,EAAU,GAAG,OAAM,EAAgC;AACxE,EAAA,uBACE,GAAA,CAACA,MAAA,CAAe,MAAA,EAAf,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAElD,QAAA,kBAAA,GAAA,CAAC,mBAAA,EAAA,EAAqB,QAAA,EAAS,CAAA,EACjC,CAAA;AAEJ;AAEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAA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S,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,iCAAA,EAAmC,SAAS,CAAA;AAAA,MACzD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,UAAA,CAAW,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AACvE,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA,CAAe,KAAA;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,qCAAA,EAAuC,SAAS,CAAA;AAAA,MAC7D,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,gBAAA,CAAiB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAqC;AACnF,EAAA,uBACE,GAAA;AAAA,IAACA,MAAA,CAAe,WAAA;AAAA,IAAf;AAAA,MACC,WAAA,EAAU,mBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,yCAAA,EAA2C,SAAS,CAAA;AAAA,MACjE,GAAG;AAAA;AAAA,GACN;AAEJ","file":"sheet.js","sourcesContent":["'use client'\n\nimport { Dialog as SheetPrimitive } from '@base-ui/react/dialog'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { IconClose } from '../icons/close.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { overlayScrim } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Sheet({ ...props }: SheetPrimitive.Root.Props) {\n return <SheetPrimitive.Root data-slot='sheet' {...props} />\n}\n\nfunction SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {\n return <SheetPrimitive.Trigger data-slot='sheet-trigger' {...props} />\n}\n\nfunction SheetClose({ ...props }: SheetPrimitive.Close.Props) {\n return <SheetPrimitive.Close data-slot='sheet-close' {...props} />\n}\n\nfunction SheetPortal({ children, ...props }: SheetPrimitive.Portal.Props) {\n return (\n <SheetPrimitive.Portal data-slot='sheet-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </SheetPrimitive.Portal>\n )\n}\n\nfunction SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {\n return (\n <SheetPrimitive.Backdrop\n data-slot='sheet-overlay'\n className={cn(\n 'fixed inset-0 z-50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * On open, keyboard and mouse users land on the close button, which is first\n * in the DOM, rather than on the first control in the content. With\n * `showCloseButton={false}` the sheet itself takes focus, so a long sheet\n * never opens scrolled to a footer action. Pass `initialFocus` to choose a\n * different target, such as a search field the sheet exists to fill in.\n *\n * With the close button shown, content in the button's corner reserves room\n * at the end edge so text cannot run under it: the SheetHeader, and also the\n * first visible child when that is not (and does not contain) the header —\n * with no header at all, or an intro placed before the header. Add\n * `data-sheet-bleed` to a padded element — a SheetHeader included — to opt\n * out, e.g. for a full-bleed banner or a wrapper whose rows should reach the\n * edge. \"Visible\" means not `sr-only` or `[hidden]`: a child hidden only\n * at some breakpoints (`hidden sm:block`, `sr-only sm:not-sr-only`) cannot be\n * told apart in CSS, so give that content its own end padding.\n */\nfunction SheetContent({\n className,\n children,\n side = 'right',\n showCloseButton = true,\n closeLabel = 'Close',\n initialFocus,\n ref,\n ...props\n}: SheetPrimitive.Popup.Props & {\n side?: 'top' | 'right' | 'bottom' | 'left'\n showCloseButton?: boolean\n /**\n * Screen-reader name for the close button. Override to translate it — the\n * button is icon-only, so this string is the only name AT ever hears.\n */\n closeLabel?: string\n}) {\n const popupRef = React.useRef<HTMLDivElement | null>(null)\n // Returns its own cleanup, so React 19 never calls this with null. That\n // cleanup must run the consumer's in turn: React keeps a callback ref's\n // return value as its teardown, and dropping it would skip that teardown.\n const mergedRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n popupRef.current = node\n if (typeof ref === 'function') {\n const cleanup = ref(node)\n return () => {\n popupRef.current = null\n if (typeof cleanup === 'function') cleanup()\n else ref(null)\n }\n }\n if (ref) ref.current = node\n return () => {\n popupRef.current = null\n if (ref) ref.current = null\n }\n },\n [ref],\n )\n\n return (\n <SheetPortal>\n <SheetOverlay />\n <SheetPrimitive.Popup\n ref={mergedRef}\n // Without a close button there is no known-safe first control, and the\n // first tabbable may be a footer action below the fold. The popup\n // itself is the one target Base UI focuses with preventScroll.\n initialFocus={initialFocus ?? (showCloseButton ? undefined : popupRef)}\n data-slot='sheet-content'\n data-side={side}\n className={cn(\n 'fixed z-50 flex max-h-dvh flex-col overflow-y-auto bg-popover bg-clip-padding text-base/relaxed text-popover-foreground transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm rtl:data-[side=left]:data-ending-style:-translate-x-[-2.5rem] rtl:data-[side=left]:data-starting-style:-translate-x-[-2.5rem] rtl:data-[side=right]:data-ending-style:-translate-x-[2.5rem] rtl:data-[side=right]:data-starting-style:-translate-x-[2.5rem]',\n // These rules anchor on `data-sheet-corner-close`, the built-in button\n // only: a consumer's own SheetClose shares its `data-slot` but is not\n // in the corner, and must not switch the reserved room on.\n //\n // Keep a long title clear of the absolutely placed close button: it\n // spans 1rem-3.5rem from the end edge, so pe-16 clears it. The header\n // matches at any depth (a form often wraps it), as Dialog's does.\n '[&:has(>[data-sheet-corner-close])_[data-slot=sheet-header]:not([data-sheet-bleed])]:pe-16',\n // Whatever sits beside the close button reserves the same room, so its\n // text cannot run under it: the first VISIBLE child (an sr-only title\n // or a [hidden] element is skipped), checked on that element only,\n // not the whole sheet — an intro placed before a header is the\n // content in the button's corner. A child that is or wraps the header\n // (at any depth) is left to the rule above, so a header is never\n // padded twice. If that child wraps the whole sheet with no header,\n // all of it is padded; `data-sheet-bleed` on it opts out, as it does\n // for full-bleed media meant to run under the button.\n '[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16',\n // One level into a first child that wraps the header (the usual\n // <form>): its own first visible child is the content in the corner,\n // e.g. an intro above the header, so it gets the same room.\n '[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):has([data-slot=sheet-header])>:nth-child(1_of_:not(.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16',\n className,\n )}\n {...props}\n >\n {/* The close button comes FIRST in the DOM (it is absolutely placed, so\n the visual order is unchanged). On a keyboard or mouse open, Base UI\n focuses the first tabbable element (on a touch open it focuses the\n popup, and DOM order does not matter); after the content, that is a\n footer button, and a long sheet opens scrolled to the bottom with\n the reader past everything above it. Being first also means it\n would paint UNDER any later positioned child in the corner (a\n Button is `relative`), so it carries z-20: above children up to\n and including the conventional sticky-header z-10. */}\n {showCloseButton && (\n <SheetPrimitive.Close\n data-slot='sheet-close'\n data-sheet-corner-close=''\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className='absolute end-4 top-4 z-20'\n />\n }\n >\n <IconClose />\n </SheetPrimitive.Close>\n )}\n {children}\n </SheetPrimitive.Popup>\n </SheetPortal>\n )\n}\n\nfunction SheetHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-header'\n className={cn('flex flex-col gap-1.5 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-footer'\n className={cn('mt-auto flex flex-col gap-2 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {\n return (\n <SheetPrimitive.Title\n data-slot='sheet-title'\n className={cn('text-lg font-medium text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SheetDescription({ className, ...props }: SheetPrimitive.Description.Props) {\n return (\n <SheetPrimitive.Description\n data-slot='sheet-description'\n className={cn('text-base/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport {\n Sheet,\n SheetClose,\n SheetContent,\n SheetDescription,\n SheetFooter,\n SheetHeader,\n SheetTitle,\n SheetTrigger,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/sheet.tsx"],"names":["SheetPrimitive"],"mappings":";;;;;;;;;AAWA,SAAS,KAAA,CAAM,EAAE,GAAG,KAAA,EAAM,EAA8B;AACtD,EAAA,2BAAQA,MAAA,CAAe,IAAA,EAAf,EAAoB,WAAA,EAAU,OAAA,EAAS,GAAG,KAAA,EAAO,CAAA;AAC3D;AAEA,SAAS,YAAA,CAAa,EAAE,GAAG,KAAA,EAAM,EAAiC;AAChE,EAAA,2BAAQA,MAAA,CAAe,OAAA,EAAf,EAAuB,WAAA,EAAU,eAAA,EAAiB,GAAG,KAAA,EAAO,CAAA;AACtE;AAEA,SA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js","sourcesContent":["'use client'\n\nimport { Dialog as SheetPrimitive } from '@base-ui/react/dialog'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { IconClose } from '../icons/close.js'\nimport { overlayScrim } from '../lib/overlay.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Sheet({ ...props }: SheetPrimitive.Root.Props) {\n return <SheetPrimitive.Root data-slot='sheet' {...props} />\n}\n\nfunction SheetTrigger({ ...props }: SheetPrimitive.Trigger.Props) {\n return <SheetPrimitive.Trigger data-slot='sheet-trigger' {...props} />\n}\n\nfunction SheetClose({ ...props }: SheetPrimitive.Close.Props) {\n return <SheetPrimitive.Close data-slot='sheet-close' {...props} />\n}\n\nfunction SheetPortal({ children, ...props }: SheetPrimitive.Portal.Props) {\n return (\n <SheetPrimitive.Portal data-slot='sheet-portal' {...props}>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>{children}</PortalBoundary>\n </SheetPrimitive.Portal>\n )\n}\n\nfunction SheetOverlay({ className, ...props }: SheetPrimitive.Backdrop.Props) {\n return (\n <SheetPrimitive.Backdrop\n data-slot='sheet-overlay'\n className={cn(\n 'fixed inset-0 z-50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * On open, keyboard and mouse users land on the close button, which is first\n * in the DOM, rather than on the first control in the content. With\n * `showCloseButton={false}` the sheet itself takes focus, so a long sheet\n * never opens scrolled to a footer action. Pass `initialFocus` to choose a\n * different target, such as a search field the sheet exists to fill in.\n *\n * With the close button shown, content in the button's corner reserves room\n * at the end edge so text cannot run under it: the SheetHeader, and also the\n * first visible child when that is not (and does not contain) the header —\n * with no header at all, or an intro placed before the header. Add\n * `data-sheet-bleed` to a padded element — a SheetHeader included — to opt\n * out, e.g. for a full-bleed banner or a wrapper whose rows should reach the\n * edge. \"Visible\" means not `sr-only` or `[hidden]`: a child hidden only\n * at some breakpoints (`hidden sm:block`, `sr-only sm:not-sr-only`) cannot be\n * told apart in CSS, so give that content its own end padding.\n */\nfunction SheetContent({\n className,\n children,\n side = 'right',\n showCloseButton = true,\n closeLabel = 'Close',\n initialFocus,\n ref,\n ...props\n}: SheetPrimitive.Popup.Props & {\n side?: 'top' | 'right' | 'bottom' | 'left'\n showCloseButton?: boolean\n /**\n * Screen-reader name for the close button. Override to translate it — the\n * button is icon-only, so this string is the only name AT ever hears.\n */\n closeLabel?: string\n}) {\n const popupRef = React.useRef<HTMLDivElement | null>(null)\n // Returns its own cleanup, so React 19 never calls this with null. That\n // cleanup must run the consumer's in turn: React keeps a callback ref's\n // return value as its teardown, and dropping it would skip that teardown.\n const mergedRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n popupRef.current = node\n if (typeof ref === 'function') {\n const cleanup = ref(node)\n return () => {\n popupRef.current = null\n if (typeof cleanup === 'function') cleanup()\n else ref(null)\n }\n }\n if (ref) ref.current = node\n return () => {\n popupRef.current = null\n if (ref) ref.current = null\n }\n },\n [ref],\n )\n\n return (\n <SheetPortal>\n <SheetOverlay />\n <SheetPrimitive.Popup\n ref={mergedRef}\n // Without a close button there is no known-safe first control, and the\n // first tabbable may be a footer action below the fold. The popup\n // itself is the one target Base UI focuses with preventScroll.\n initialFocus={initialFocus ?? (showCloseButton ? undefined : popupRef)}\n data-slot='sheet-content'\n data-side={side}\n className={cn(\n 'fixed z-50 flex max-h-dvh flex-col overflow-y-auto bg-popover bg-clip-padding text-base/relaxed text-popover-foreground transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-e data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-s data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm rtl:data-[side=left]:data-ending-style:-translate-x-[-2.5rem] rtl:data-[side=left]:data-starting-style:-translate-x-[-2.5rem] rtl:data-[side=right]:data-ending-style:-translate-x-[2.5rem] rtl:data-[side=right]:data-starting-style:-translate-x-[2.5rem]',\n // These rules anchor on `data-sheet-corner-close`, the built-in button\n // only: a consumer's own SheetClose shares its `data-slot` but is not\n // in the corner, and must not switch the reserved room on.\n //\n // Keep a long title clear of the absolutely placed close button: it\n // spans 1rem-3.5rem from the end edge, so pe-16 clears it. The header\n // matches at any depth (a form often wraps it), as Dialog's does.\n '[&:has(>[data-sheet-corner-close])_[data-slot=sheet-header]:not([data-sheet-bleed])]:pe-16',\n // Whatever sits beside the close button reserves the same room, so its\n // text cannot run under it: the first VISIBLE child (an sr-only title\n // or a [hidden] element is skipped), checked on that element only,\n // not the whole sheet — an intro placed before a header is the\n // content in the button's corner. A child that is or wraps the header\n // (at any depth) is left to the rule above, so a header is never\n // padded twice. If that child wraps the whole sheet with no header,\n // all of it is padded; `data-sheet-bleed` on it opts out, as it does\n // for full-bleed media meant to run under the button.\n '[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16',\n // One level into a first child that wraps the header (the usual\n // <form>): its own first visible child is the content in the corner,\n // e.g. an intro above the header, so it gets the same room.\n '[&:has(>[data-sheet-corner-close])>:nth-child(1_of_:not([data-sheet-corner-close],.sr-only,[hidden])):has([data-slot=sheet-header])>:nth-child(1_of_:not(.sr-only,[hidden])):not(:has([data-slot=sheet-header])):not([data-sheet-bleed])]:pe-16',\n className,\n )}\n {...props}\n >\n {/* The close button comes FIRST in the DOM (it is absolutely placed, so\n the visual order is unchanged). On a keyboard or mouse open, Base UI\n focuses the first tabbable element (on a touch open it focuses the\n popup, and DOM order does not matter); after the content, that is a\n footer button, and a long sheet opens scrolled to the bottom with\n the reader past everything above it. Being first also means it\n would paint UNDER any later positioned child in the corner (a\n Button is `relative`), so it carries z-20: above children up to\n and including the conventional sticky-header z-10. */}\n {showCloseButton && (\n <SheetPrimitive.Close\n data-slot='sheet-close'\n data-sheet-corner-close=''\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className='absolute end-4 top-4 z-20'\n />\n }\n >\n <IconClose />\n </SheetPrimitive.Close>\n )}\n {children}\n </SheetPrimitive.Popup>\n </SheetPortal>\n )\n}\n\nfunction SheetHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-header'\n className={cn('flex flex-col gap-1.5 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='sheet-footer'\n className={cn('mt-auto flex flex-col gap-2 p-6', className)}\n {...props}\n />\n )\n}\n\nfunction SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {\n return (\n <SheetPrimitive.Title\n data-slot='sheet-title'\n className={cn('text-lg font-medium text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SheetDescription({ className, ...props }: SheetPrimitive.Description.Props) {\n return (\n <SheetPrimitive.Description\n data-slot='sheet-description'\n className={cn('text-base/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport {\n Sheet,\n SheetClose,\n SheetContent,\n SheetDescription,\n SheetFooter,\n SheetHeader,\n SheetTitle,\n SheetTrigger,\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { Autocomplete } from '@base-ui/react/autocomplete';
|
|
|
4
4
|
import { Dialog } from '@base-ui/react/dialog';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { IconSearch } from '../icons/search.js';
|
|
7
|
-
import {
|
|
7
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
8
8
|
import { cn } from '../lib/utils.js';
|
|
9
9
|
import { Button } from '../components/button.js';
|
|
10
10
|
|
|
@@ -87,7 +87,7 @@ function SiteSearch({
|
|
|
87
87
|
);
|
|
88
88
|
return /* @__PURE__ */ jsxs(Dialog.Root, { open, onOpenChange: (next) => requestOpenChange(next), children: [
|
|
89
89
|
trigger === null ? null : /* @__PURE__ */ jsx(Dialog.Trigger, { "data-slot": "site-search-trigger", render: trigger ?? defaultTrigger }),
|
|
90
|
-
/* @__PURE__ */ jsx(Dialog.Portal, { children: /* @__PURE__ */ jsxs(
|
|
90
|
+
/* @__PURE__ */ jsx(Dialog.Portal, { children: /* @__PURE__ */ jsxs(PortalBoundary, { children: [
|
|
91
91
|
/* @__PURE__ */ jsx(
|
|
92
92
|
Dialog.Backdrop,
|
|
93
93
|
{
|