@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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/component-preview.tsx"],"names":["TogglePrimitive","Toggle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,kBAAY,CAAC,KAAA,KACX,IAAA,GACI,KAAA,CAAM,OAAO,CAAC,KAAA,KAAU,KAAA,KAAU,IAAA,CAAK,KAAK,CAAA,GAC5C,CAAC,GAAG,KAAA,EAAO,KAAK,KAAK;AAAA,iBAC3B;AAAA,gBAGD,QAAA,EAAA;AAAA,kBAAA,IAAA,GAAO,aAAA,GAAgB,aAAA;AAAA,kCACxB,GAAA;AAAA,oBAAC,cAAA;AAAA,oBAAA;AAAA,sBACC,aAAA,EAAY,MAAA;AAAA,sBACZ,SAAA,EAAW,EAAA,CAAG,kCAAA,EAAoC,IAAA,IAAQ,YAAY;AAAA;AAAA;AACxE;AAAA;AAAA,eAEJ,CAAA,GACE;AAAA,WAAA,EACN,CAAA,EAAA,EAvCgB,KAAK,KAwCvB,CAAA;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"component-preview.js","sourcesContent":["'use client'\n\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover'\nimport { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport { Slider as SliderPrimitive } from '@base-ui/react/slider'\nimport { Toggle as TogglePrimitive } from '@base-ui/react/toggle'\nimport { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group'\nimport * as React from 'react'\n\nimport { ButtonGroup } from '../components/button-group.js'\nimport { Button, type ButtonProps } from '../components/button.js'\nimport {\n CodeBlock,\n CodeBlockContent,\n CodeBlockCopyButton,\n CodeBlockFooter,\n} from '../components/code-block.js'\nimport { Popover, PopoverContent, PopoverTrigger } from '../components/popover.js'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '../components/tabs.js'\nimport { IconCheck } from '../icons/check.js'\nimport { IconContrast } from '../icons/contrast.js'\nimport { IconDarkMode } from '../icons/dark-mode.js'\nimport { IconDesktopWindows } from '../icons/desktop-windows.js'\nimport { IconDragIndicator } from '../icons/drag-indicator.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { IconLightMode } from '../icons/light-mode.js'\nimport { IconPalette } from '../icons/palette.js'\nimport { IconSmartphone } from '../icons/smartphone.js'\nimport { IconTabletMac } from '../icons/tablet-mac.js'\nimport {\n ABORIGINAL_PALETTES,\n BRAND_PALETTES,\n previewThemeStyle,\n type PreviewPalette,\n type PreviewScheme,\n} from '../lib/preview-theme.js'\nimport { cn } from '../lib/utils.js'\n\n/** Which colour schemes the stage shows: one, or both side by side. */\ntype ComponentPreviewTheme = PreviewScheme | 'both'\ntype ComponentPreviewDirection = 'ltr' | 'rtl'\ntype ComponentPreviewColorSet = 'brand' | 'aboriginal'\n\n/** The narrowest the stage can be dragged, in px. The spacing step 70 is the same 280px. */\nconst MIN_WIDTH = 280\nconst PHONE_WIDTH = 375\nconst TABLET_WIDTH = 768\n\nconst PALETTES: Record<ComponentPreviewColorSet, readonly PreviewPalette[]> = {\n brand: BRAND_PALETTES,\n aboriginal: ABORIGINAL_PALETTES,\n}\n\nconst setOf = (palette: PreviewPalette): ComponentPreviewColorSet =>\n palette.startsWith('aboriginal-') ? 'aboriginal' : 'brand'\n\n/**\n * The pair a stage starts with. Both unset is the page's own pair. Otherwise\n * the pair is completed within one colour set, the primary's if it is given:\n * the colour panel lists one set at a time, so a pair across two sets, or one\n * ramp without the other, would leave it with no checked choice. A missing or\n * unusable ramp takes the first palette of the set the other has not taken.\n */\nfunction colorPair(primary: PreviewPalette | undefined, accent: PreviewPalette | undefined) {\n const anchor = primary ?? accent\n if (!anchor) return { primary: undefined, accent: undefined }\n\n const palettes = PALETTES[setOf(anchor)]\n const first = (not?: PreviewPalette) => palettes.find((palette) => palette !== not)\n const resolvedPrimary = primary ?? first(accent)\n const fits = accent && palettes.includes(accent) && accent !== resolvedPrimary\n\n return { primary: resolvedPrimary, accent: fits ? accent : first(resolvedPrimary) }\n}\n\n/** `aboriginal-red` reads \"Red\": the set is named by the control above it. */\nconst paletteName = (palette: PreviewPalette) => {\n const name = palette.replace('aboriginal-', '')\n return name.charAt(0).toUpperCase() + name.slice(1)\n}\n\ntype ComponentPreviewContextValue = {\n theme: ComponentPreviewTheme\n setTheme: (theme: ComponentPreviewTheme) => void\n /** The stage's width in px, or `null` for the full width available. */\n width: number | null\n setWidth: (width: number | null) => void\n /** The first stage's rendered width, once it has been measured. */\n measuredWidth: number | null\n setMeasuredWidth: (width: number) => void\n direction: ComponentPreviewDirection\n setDirection: (direction: ComponentPreviewDirection) => void\n /** `undefined` keeps the page's own ramp. */\n primary: PreviewPalette | undefined\n accent: PreviewPalette | undefined\n setColors: (primary: PreviewPalette | undefined, accent: PreviewPalette | undefined) => void\n}\n\nconst ComponentPreviewContext = React.createContext<ComponentPreviewContextValue | null>(null)\n\nfunction useComponentPreview(part: string) {\n const context = React.useContext(ComponentPreviewContext)\n if (!context) throw new Error(`[nswds/ui] ${part} must be used inside a ComponentPreview.`)\n return context\n}\n\ntype ComponentPreviewProps = React.ComponentProps<'div'> & {\n /** The colour schemes shown at first. `both` puts light and dark side by side. */\n defaultTheme?: ComponentPreviewTheme\n /** The stage's width in px at first, 280 at the narrowest. Leave unset for the full width. */\n defaultWidth?: number\n /** The stage's text direction at first. */\n defaultDirection?: ComponentPreviewDirection\n /**\n * The palette used as the primary ramp at first. Leave both this and\n * `defaultAccent` unset for the page's own pair.\n */\n defaultPrimary?: PreviewPalette\n /**\n * The palette used as the accent ramp at first. It has to come from the\n * primary's colour set and differ from the primary; when it is unset or\n * does not, the first other palette of that set is used.\n */\n defaultAccent?: PreviewPalette\n}\n\n/**\n * A frame for showing a component: a header of controls, a stage that renders\n * the component in light, dark or both, and the code beneath. The controls\n * change the stage only, never the page around it.\n */\nfunction ComponentPreview({\n className,\n defaultTheme = 'both',\n defaultWidth,\n defaultDirection = 'ltr',\n defaultPrimary,\n defaultAccent,\n ...props\n}: ComponentPreviewProps) {\n const [theme, setTheme] = React.useState(defaultTheme)\n // The handle cannot go below MIN_WIDTH, so a narrower start is raised to it\n // and the frame and the handle agree from the first render.\n const [width, setWidth] = React.useState<number | null>(() =>\n typeof defaultWidth === 'number' && Number.isFinite(defaultWidth)\n ? Math.max(MIN_WIDTH, defaultWidth)\n : null,\n )\n const [measuredWidth, setMeasuredWidth] = React.useState<number | null>(null)\n const [direction, setDirection] = React.useState(defaultDirection)\n const [colors, setColorState] = React.useState(() => colorPair(defaultPrimary, defaultAccent))\n\n const setColors = React.useCallback(\n (primary: PreviewPalette | undefined, accent: PreviewPalette | undefined) =>\n setColorState({ primary, accent }),\n [],\n )\n\n const context = React.useMemo<ComponentPreviewContextValue>(\n () => ({\n theme,\n setTheme,\n width,\n setWidth,\n measuredWidth,\n setMeasuredWidth,\n direction,\n setDirection,\n primary: colors.primary,\n accent: colors.accent,\n setColors,\n }),\n [theme, width, measuredWidth, direction, colors, setColors],\n )\n\n return (\n <ComponentPreviewContext.Provider value={context}>\n <div\n data-slot='component-preview'\n className={cn(\n '@container/component-preview flex w-full min-w-0 flex-col overflow-hidden rounded-md border border-border bg-background text-base text-foreground',\n className,\n )}\n {...props}\n data-theme-mode={theme}\n />\n </ComponentPreviewContext.Provider>\n )\n}\n\n/**\n * The band across the top, for the title and the controls. It is the solid\n * brand band: white on the primary ramp's 800 step, deepening in dark.\n */\nfunction ComponentPreviewHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='component-preview-header'\n className={cn(\n 'flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 bg-primary-800 py-3 pe-4 text-white @max-3xl/component-preview:ps-4 @3xl/component-preview:ps-6 dark:bg-primary-950',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The name of the example. It truncates. */\nfunction ComponentPreviewTitle({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='component-preview-title'\n className={cn('min-w-0 truncate text-xl font-semibold', className)}\n {...props}\n />\n )\n}\n\n/** Holds the controls at the end of the header. They wrap when they run out of room. */\nfunction ComponentPreviewControls({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='component-preview-controls'\n className={cn('ms-auto flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2', className)}\n {...props}\n />\n )\n}\n\n/**\n * A toggle hands its render function the props of an HTML button, whose\n * `color` is the legacy attribute typed as any string. It is never set here,\n * and Button's own `color` is narrower, so the type alone is narrowed.\n */\nconst asButtonProps = (props: React.ComponentProps<'button'>) =>\n props as Omit<React.ComponentProps<'button'>, 'color'>\n\n/** One segment of a control on the band: solid while it is the chosen one. */\nfunction Segment({\n value,\n label,\n children,\n}: {\n value: string\n label: string\n children: React.ReactNode\n}) {\n return (\n <TogglePrimitive\n value={value}\n aria-label={label}\n title={label}\n render={(props, state) => (\n <Button {...asButtonProps(props)} iconOnly variant={state.pressed ? 'solid' : 'ghost'} />\n )}\n >\n {children}\n </TogglePrimitive>\n )\n}\n\ntype ComponentPreviewThemeToggleProps = Omit<\n React.ComponentProps<typeof ButtonGroup>,\n 'children'\n> & {\n /** Accessible names of the three choices. Override to translate them. */\n lightLabel?: string\n darkLabel?: string\n bothLabel?: string\n}\n\n/** Chooses the stage's colour scheme: light, dark, or both side by side. */\nfunction ComponentPreviewThemeToggle({\n lightLabel = 'Light',\n darkLabel = 'Dark',\n bothLabel = 'Light and dark',\n 'aria-label': ariaLabel = 'Colour scheme',\n ...props\n}: ComponentPreviewThemeToggleProps) {\n const { theme, setTheme } = useComponentPreview('ComponentPreviewThemeToggle')\n\n return (\n <ToggleGroupPrimitive\n value={[theme]}\n // A single-choice group lets the pressed item be released; one scheme\n // is always showing, so an empty value is ignored.\n onValueChange={(value) => {\n const next = value[0] as ComponentPreviewTheme | undefined\n if (next) setTheme(next)\n }}\n render={\n <ButtonGroup\n data-slot='component-preview-theme-toggle'\n color='white'\n size='sm'\n aria-label={ariaLabel}\n {...props}\n />\n }\n >\n <Segment value='light' label={lightLabel}>\n <IconLightMode aria-hidden='true' />\n </Segment>\n <Segment value='dark' label={darkLabel}>\n <IconDarkMode aria-hidden='true' />\n </Segment>\n <Segment value='both' label={bothLabel}>\n <IconContrast aria-hidden='true' />\n </Segment>\n </ToggleGroupPrimitive>\n )\n}\n\ntype ComponentPreviewWidthToggleProps = Omit<\n React.ComponentProps<typeof ButtonGroup>,\n 'children'\n> & {\n /** Accessible names of the three choices. Override to translate them. */\n phoneLabel?: string\n tabletLabel?: string\n fullLabel?: string\n}\n\n/**\n * Sets the stage to a phone's width, a tablet's, or all the room there is,\n * and reads out the width it ends up at.\n */\nfunction ComponentPreviewWidthToggle({\n phoneLabel = `Phone, ${PHONE_WIDTH}px`,\n tabletLabel = `Tablet, ${TABLET_WIDTH}px`,\n fullLabel = 'Full width',\n 'aria-label': ariaLabel = 'Width',\n ...props\n}: ComponentPreviewWidthToggleProps) {\n const { width, setWidth, measuredWidth } = useComponentPreview('ComponentPreviewWidthToggle')\n\n return (\n <div data-slot='component-preview-width' className='flex items-center gap-3'>\n <ToggleGroupPrimitive\n value={[width === null ? 'full' : String(width)]}\n onValueChange={(value) => {\n const next = value[0] as string | undefined\n if (next) setWidth(next === 'full' ? null : Number(next))\n }}\n render={\n <ButtonGroup\n data-slot='component-preview-width-toggle'\n color='white'\n size='sm'\n aria-label={ariaLabel}\n {...props}\n />\n }\n >\n <Segment value={String(PHONE_WIDTH)} label={phoneLabel}>\n <IconSmartphone aria-hidden='true' />\n </Segment>\n <Segment value={String(TABLET_WIDTH)} label={tabletLabel}>\n <IconTabletMac aria-hidden='true' />\n </Segment>\n <Segment value='full' label={fullLabel}>\n <IconDesktopWindows aria-hidden='true' />\n </Segment>\n </ToggleGroupPrimitive>\n {/* Empty until the stage has been measured, with its room held. */}\n <span\n data-slot='component-preview-width-readout'\n className='min-w-[6ch] text-end font-mono text-base tabular-nums'\n >\n {measuredWidth === null ? '' : `${measuredWidth}px`}\n </span>\n </div>\n )\n}\n\ntype ComponentPreviewDirectionToggleProps = ButtonProps & {\n /** What the toggle does, shown as its tooltip. Override to translate it. */\n title?: string\n}\n\n/**\n * Flips the stage to right-to-left, to prove a component uses logical\n * properties. Its visible label is its name, so pass translated `children`\n * rather than an `aria-label` that would disagree with them.\n */\nfunction ComponentPreviewDirectionToggle({\n children = 'RTL',\n title = 'Right to left',\n ...props\n}: ComponentPreviewDirectionToggleProps) {\n const { direction, setDirection } = useComponentPreview('ComponentPreviewDirectionToggle')\n\n return (\n <TogglePrimitive\n pressed={direction === 'rtl'}\n onPressedChange={(pressed) => setDirection(pressed ? 'rtl' : 'ltr')}\n title={title}\n render={(toggleProps, state) => (\n <Button\n data-slot='component-preview-direction-toggle'\n color='white'\n size='sm'\n {...props}\n {...asButtonProps(toggleProps)}\n variant={state.pressed ? 'solid' : 'outline'}\n />\n )}\n >\n {children}\n </TogglePrimitive>\n )\n}\n\nconst optionClassName =\n 'relative flex min-h-11 cursor-pointer items-center gap-2.5 rounded-sm border border-border bg-background px-3 py-2 text-start text-base font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring data-checked:border-foreground data-checked:ring-1 data-checked:ring-foreground'\n\n/** One group of the colour panel: a visible heading naming a radio group. */\nfunction PaletteGroup({\n label,\n step,\n value,\n options,\n onValueChange,\n format,\n}: {\n label: string\n step: 600 | 800\n /** The palette in use, or `null` when the ramp is the page's own. */\n value: PreviewPalette | null\n options: readonly PreviewPalette[]\n onValueChange: (palette: PreviewPalette) => void\n format: (palette: PreviewPalette) => string\n}) {\n const id = React.useId()\n\n return (\n <div className='flex flex-col gap-2'>\n <div id={id} className='text-base font-semibold'>\n {label}\n </div>\n <RadioGroupPrimitive\n aria-labelledby={id}\n value={value}\n onValueChange={(next) => onValueChange(next as PreviewPalette)}\n className='grid grid-cols-2 gap-2'\n >\n {options.map((palette) => (\n <RadioPrimitive.Root key={palette} value={palette} className={optionClassName}>\n <span\n aria-hidden='true'\n className='size-5 flex-none rounded-full'\n style={{ backgroundColor: `var(--nsw-${palette}-${step})` }}\n />\n {format(palette)}\n <RadioPrimitive.Indicator className='ms-auto'>\n <IconCheck aria-hidden='true' className='size-5' />\n </RadioPrimitive.Indicator>\n </RadioPrimitive.Root>\n ))}\n </RadioGroupPrimitive>\n </div>\n )\n}\n\ntype ComponentPreviewColorPickerProps = Omit<ButtonProps, 'children'> & {\n /** The button's label. */\n label?: string\n /** Headings and choices inside the panel. Override to translate them. */\n setLabel?: string\n brandLabel?: string\n aboriginalLabel?: string\n primaryLabel?: string\n accentLabel?: string\n resetLabel?: string\n /** Shown in the panel while the stage is using the page's own colours. */\n pageLabel?: string\n /** Names a palette. The default reads `aboriginal-red` as \"Red\". */\n formatPalette?: (palette: PreviewPalette) => string\n}\n\n/**\n * A button that opens a panel for choosing the stage's primary and accent\n * colours from the NSW brand set or the Aboriginal set. The two dots on the\n * button show the pair in use. An accent is never the same colour as the\n * primary, so the accent list leaves the primary out. Until a pair is chosen,\n * and after Reset, the stage uses the page's own colours: the panel then\n * checks nothing and says so, because those need not be a palette it lists.\n */\nfunction ComponentPreviewColorPicker({\n label = 'Theme',\n setLabel = 'Colour set',\n brandLabel = 'Brand',\n aboriginalLabel = 'Aboriginal',\n primaryLabel = 'Primary',\n accentLabel = 'Accent',\n resetLabel = 'Reset',\n pageLabel = 'Using this page’s colours',\n formatPalette = paletteName,\n ...props\n}: ComponentPreviewColorPickerProps) {\n const context = useComponentPreview('ComponentPreviewColorPicker')\n const setId = React.useId()\n // The pair is set together or not at all (see `colorPair`). Unset, the stage\n // is using the page's own colours, which need not be any palette listed\n // here, so the panel checks nothing and says so; the brand set is on show\n // to choose from.\n const { primary, accent } = context\n const set = primary ? setOf(primary) : null\n const palettes = PALETTES[set ?? 'brand']\n\n // The dots show the pair the stage is using. An unset ramp is the page's,\n // read through its bridge so a rebranded page shows its own colours.\n const primaryDot = primary ? `var(--nsw-${primary}-800)` : 'var(--color-primary-800)'\n const accentDot = accent ? `var(--nsw-${accent}-600)` : 'var(--color-accent-600)'\n\n // Choosing one ramp completes the pair, so neither is left as the page's.\n const choose = (\n nextPrimary: PreviewPalette | undefined,\n nextAccent: PreviewPalette | undefined,\n ) => {\n const pair = colorPair(nextPrimary, nextAccent)\n context.setColors(pair.primary, pair.accent)\n }\n\n return (\n <Popover>\n <PopoverTrigger\n render={\n <Button\n data-slot='component-preview-color-picker'\n variant='outline'\n color='white'\n size='sm'\n {...props}\n />\n }\n >\n <IconPalette aria-hidden='true' />\n {label}\n <span aria-hidden='true' className='flex gap-1'>\n <span\n className='size-4 rounded-full ring-1 ring-white'\n data-slot='component-preview-color-dot'\n style={{ backgroundColor: primaryDot }}\n />\n <span\n className='size-4 rounded-full ring-1 ring-white'\n data-slot='component-preview-color-dot'\n style={{ backgroundColor: accentDot }}\n />\n </span>\n </PopoverTrigger>\n <PopoverContent\n align='end'\n sideOffset={8}\n className='w-100 max-w-[calc(100vw-1rem)] gap-5 p-5 text-base'\n >\n <PopoverPrimitive.Title className='sr-only'>{label}</PopoverPrimitive.Title>\n <div className='flex flex-col gap-2'>\n <div id={setId} className='text-base font-semibold'>\n {setLabel}\n </div>\n <RadioGroupPrimitive\n aria-labelledby={setId}\n value={set}\n onValueChange={(next) => {\n const list = PALETTES[next as ComponentPreviewColorSet]\n context.setColors(list[0], list[1])\n }}\n className='grid grid-cols-2 gap-2'\n >\n <RadioPrimitive.Root value='brand' className={cn(optionClassName, 'justify-center')}>\n {brandLabel}\n </RadioPrimitive.Root>\n <RadioPrimitive.Root\n value='aboriginal'\n className={cn(optionClassName, 'justify-center')}\n >\n {aboriginalLabel}\n </RadioPrimitive.Root>\n </RadioGroupPrimitive>\n </div>\n <PaletteGroup\n label={primaryLabel}\n step={800}\n value={primary ?? null}\n options={palettes}\n onValueChange={(next) => choose(next, accent)}\n format={formatPalette}\n />\n <PaletteGroup\n label={accentLabel}\n step={600}\n value={accent ?? null}\n options={palettes.filter((palette) => palette !== primary)}\n onValueChange={(next) => choose(primary, next)}\n format={formatPalette}\n />\n <div className='-mx-2 -mb-2 flex items-center gap-3 border-t border-border pt-2'>\n <Button variant='ghost' size='sm' onClick={() => context.setColors(undefined, undefined)}>\n {resetLabel}\n </Button>\n {primary ? null : (\n <p\n data-slot='component-preview-color-status'\n className='ms-auto pe-2 text-base text-muted-foreground'\n >\n {pageLabel}\n </p>\n )}\n </div>\n </PopoverContent>\n </Popover>\n )\n}\n\n/** One rendering of the children, in one colour scheme, with its drag handle. */\nfunction StagePane({\n scheme,\n label,\n resizeLabel,\n reportsWidth,\n children,\n}: {\n scheme: PreviewScheme\n /** Shown above the stage when both schemes are on screen. */\n label: string | undefined\n resizeLabel: string\n reportsWidth: boolean\n children: React.ReactNode\n}) {\n const { width, setWidth, setMeasuredWidth, direction, primary, accent } =\n useComponentPreview('ComponentPreviewStage')\n const wellRef = React.useRef<HTMLDivElement>(null)\n const frameRef = React.useRef<HTMLDivElement>(null)\n // The room the stage has, in px. Zero until measured, and the handle waits for it.\n const [available, setAvailable] = React.useState(0)\n\n const measure = React.useCallback(() => {\n const well = wellRef.current\n const frame = frameRef.current\n if (!well || !frame) return\n setAvailable(Math.round(well.getBoundingClientRect().width))\n if (reportsWidth) setMeasuredWidth(Math.round(frame.getBoundingClientRect().width))\n }, [reportsWidth, setMeasuredWidth])\n\n // Measured here as well as by the observer below: on mount, and whenever a\n // control sets the width. A browser holds an observer's callbacks back while\n // the page is not being painted (a background tab), and the handle and the\n // readout would otherwise wait with them.\n React.useLayoutEffect(measure, [measure, width])\n\n React.useEffect(() => {\n const well = wellRef.current\n const frame = frameRef.current\n if (!well || !frame || typeof ResizeObserver === 'undefined') return\n\n const observer = new ResizeObserver(measure)\n observer.observe(well)\n observer.observe(frame)\n return () => observer.disconnect()\n }, [measure])\n\n const style = React.useMemo(\n () => previewThemeStyle({ scheme, primary, accent }) as React.CSSProperties,\n [scheme, primary, accent],\n )\n const resizable = available > MIN_WIDTH\n\n return (\n <div\n data-slot='component-preview-pane'\n // `dark` and `data-theme` are what the stylesheet's dark variant and the\n // dark role tokens key on; the island marker is what keeps `dark:`\n // utilities out of a light stage on a dark page.\n className={cn(\n 'min-w-0 flex-1 bg-muted text-foreground @max-3xl/component-preview:py-4 @max-3xl/component-preview:ps-4 @max-3xl/component-preview:pe-9 @3xl/component-preview:py-6 @3xl/component-preview:ps-6 @3xl/component-preview:pe-10',\n scheme === 'dark' ? 'dark scheme-dark' : 'scheme-light',\n )}\n data-theme={scheme}\n data-theme-island={scheme === 'light' ? 'light' : undefined}\n style={style}\n >\n {label ? (\n <div\n data-slot='component-preview-pane-label'\n className='mb-2 font-medium text-muted-foreground'\n >\n {label}\n </div>\n ) : null}\n <div ref={wellRef} className='relative'>\n <div\n ref={frameRef}\n data-slot='component-preview-frame'\n dir={direction}\n style={{ maxWidth: width ?? undefined }}\n className='@container/component-preview-frame min-w-0 border border-border bg-background text-foreground @max-3xl/component-preview:p-4 @3xl/component-preview:p-8'\n >\n {children}\n </div>\n {resizable ? (\n <SliderPrimitive.Root\n min={MIN_WIDTH}\n max={available}\n step={8}\n largeStep={64}\n value={Math.min(width ?? available, available)}\n // Dragged back to the end, the stage is full width again rather\n // than pinned to whatever that happened to measure.\n onValueChange={(value) => setWidth(value >= available ? null : value)}\n >\n <SliderPrimitive.Control className='pointer-events-none absolute inset-y-0 start-70 end-0'>\n <SliderPrimitive.Thumb\n data-slot='component-preview-resize-handle'\n aria-label={resizeLabel}\n getAriaValueText={(_, value) => `${value}px`}\n className='pointer-events-auto ms-4 flex h-full w-6 cursor-ew-resize touch-none items-center justify-center rounded-sm text-muted-foreground hover:bg-foreground/10 hover:text-foreground has-focus:outline-2 has-focus:outline-offset-2 has-focus:outline-ring data-dragging:bg-foreground/10 data-dragging:text-foreground'\n >\n <IconDragIndicator aria-hidden='true' className='size-5 flex-none' />\n </SliderPrimitive.Thumb>\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n ) : null}\n </div>\n </div>\n )\n}\n\ntype ComponentPreviewStageProps = React.ComponentProps<'div'> & {\n /** Captions over the two halves when both schemes show. Override to translate them. */\n lightLabel?: string\n darkLabel?: string\n /** Accessible name of the drag handle. Override to translate it. */\n resizeLabel?: string\n}\n\n/**\n * Where the component renders. With the `both` theme the children render\n * twice, once per scheme, so give any `id` inside them a value from `useId`.\n * Each stage is a container, so a component can respond to the stage's width\n * with a container query; a media query still reads the viewport.\n *\n * The scheme and colours reach only what renders inside the stage. A popup\n * that portals out of it (Dialog, Popover, Select, Tooltip and the like)\n * renders at the end of the page, so it takes the page's scheme and colours,\n * not the stage's. Preview such a component with the page set to the scheme\n * you want to check.\n */\nfunction ComponentPreviewStage({\n className,\n children,\n lightLabel = 'Light',\n darkLabel = 'Dark',\n resizeLabel = 'Preview width',\n ...props\n}: ComponentPreviewStageProps) {\n const { theme } = useComponentPreview('ComponentPreviewStage')\n const schemes: PreviewScheme[] = theme === 'both' ? ['light', 'dark'] : [theme]\n const labels = { light: lightLabel, dark: darkLabel }\n\n return (\n <div\n data-slot='component-preview-stage'\n className={cn(\n 'flex min-w-0 @max-3xl/component-preview:flex-col @3xl/component-preview:flex-row',\n className,\n )}\n {...props}\n >\n {schemes.map((scheme, index) => (\n <StagePane\n key={scheme}\n scheme={scheme}\n label={theme === 'both' ? labels[scheme] : undefined}\n resizeLabel={resizeLabel}\n reportsWidth={index === 0}\n >\n {children}\n </StagePane>\n ))}\n </div>\n )\n}\n\n/** One tab of the code area. */\ntype ComponentPreviewFile = {\n /** The tab's label, such as \"Code\" or \"npm\". Labels must be unique. */\n label: string\n /** The text shown, and copied by the copy button. */\n code: string\n}\n\ntype ComponentPreviewCodeProps = Omit<React.ComponentProps<'div'>, 'children'> & {\n /** The tabs, in order. The first is shown at first. */\n files: ComponentPreviewFile[]\n /** A file longer than this many lines is cut short behind a \"Show more\" button. */\n collapsedLines?: number\n /** Labels of the button that expands and collapses a long file. */\n showMoreLabel?: string\n showLessLabel?: string\n /** Accessible name of the copy button, and what it reports after a copy. */\n copyLabel?: string\n copiedLabel?: string\n}\n\n/**\n * The code under the stage: one tab per file, a copy button for the tab in\n * view, and a \"Show more\" button on a long file.\n */\nfunction ComponentPreviewCode({\n className,\n files,\n collapsedLines = 8,\n showMoreLabel = 'Show more',\n showLessLabel = 'Show less',\n copyLabel,\n copiedLabel,\n ...props\n}: ComponentPreviewCodeProps) {\n const [active, setActive] = React.useState(0)\n // Per file, by label: expanding one long file leaves the others cut short,\n // and the state stays with its file when `files` is reordered or changed.\n const [expanded, setExpanded] = React.useState<readonly string[]>([])\n const contentId = React.useId()\n // `files` may get shorter after a later tab was chosen; fall back to the first.\n const shown = active < files.length ? active : 0\n const current = files[shown]\n\n if (!current) return null\n\n return (\n <Tabs\n data-slot='component-preview-code'\n value={shown}\n onValueChange={(value) => setActive(value as number)}\n className={cn('min-w-0 gap-0 border-t border-border', className)}\n {...props}\n >\n <div className='flex min-w-0 items-center gap-2 border-b border-border ps-4 pe-2'>\n <TabsList variant='line' className='min-w-0 gap-5 overflow-x-auto border-b-0'>\n {files.map((file, index) => (\n <TabsTrigger\n key={file.label}\n value={index}\n className='text-base focus-visible:-outline-offset-2'\n >\n {file.label}\n </TabsTrigger>\n ))}\n </TabsList>\n <CodeBlockCopyButton\n className='ms-auto'\n value={current.code}\n aria-label={copyLabel}\n copiedLabel={copiedLabel}\n />\n </div>\n {files.map((file, index) => {\n const long = file.code.split('\\n').length > collapsedLines\n const open = expanded.includes(file.label)\n const collapsed = long && !open\n\n return (\n <TabsContent key={file.label} value={index} className='min-w-0 text-base'>\n <CodeBlock className='rounded-none border-0'>\n <CodeBlockContent\n id={`${contentId}-${index}`}\n style={\n collapsed\n ? { maxHeight: `calc(${collapsedLines}lh + var(--code-block-p))` }\n : undefined\n }\n className={cn(\n collapsed &&\n 'overflow-hidden [mask-image:linear-gradient(black_55%,transparent)]',\n )}\n >\n {file.code}\n </CodeBlockContent>\n {long ? (\n <CodeBlockFooter className='px-2 pb-2'>\n <Button\n variant='ghost'\n size='sm'\n aria-expanded={open}\n aria-controls={`${contentId}-${index}`}\n onClick={() =>\n setExpanded((state) =>\n open\n ? state.filter((label) => label !== file.label)\n : [...state, file.label],\n )\n }\n >\n {open ? showLessLabel : showMoreLabel}\n <IconExpandMore\n aria-hidden='true'\n className={cn('motion-safe:transition-transform', open && 'rotate-180')}\n />\n </Button>\n </CodeBlockFooter>\n ) : null}\n </CodeBlock>\n </TabsContent>\n )\n })}\n </Tabs>\n )\n}\n\nexport type { PreviewPalette as ComponentPreviewPalette } from '../lib/preview-theme.js'\nexport {\n ComponentPreview,\n ComponentPreviewCode,\n ComponentPreviewColorPicker,\n ComponentPreviewControls,\n ComponentPreviewDirectionToggle,\n ComponentPreviewHeader,\n ComponentPreviewStage,\n ComponentPreviewThemeToggle,\n ComponentPreviewTitle,\n ComponentPreviewWidthToggle,\n}\nexport type {\n ComponentPreviewCodeProps,\n ComponentPreviewColorPickerProps,\n ComponentPreviewColorSet,\n ComponentPreviewDirection,\n ComponentPreviewDirectionToggleProps,\n ComponentPreviewFile,\n ComponentPreviewProps,\n ComponentPreviewStageProps,\n ComponentPreviewTheme,\n ComponentPreviewThemeToggleProps,\n ComponentPreviewWidthToggleProps,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/component-preview.tsx"],"names":["TogglePrimitive","ToggleGroupPrimitive","RadioGroupPrimitive","RadioPrimitive","PopoverPrimitive","SliderPrimitive"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,SAAA,GAAY,GAAA;AAClB,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,YAAA,GAAe,GAAA;AAErB,MAAM,QAAA,GAAwE;AAAA,EAC5E,KAAA,EAAO,cAAA;AAAA,EACP,UAAA,EAAY;AACd,CAAA;AAEA,MAAM,QAAQ,CAAC,OAAA,KACb,QAAQ,UAAA,CAAW,aAAa,IAAI,YAAA,GAAe,OAAA;AASrD,SAAS,SAAA,CAAU,SAAqC,MAAA,EAAoC;AAC1F,EAAA,MAAM,SAAS,OAAA,IAAW,MAAA;AAC1B,EAAA,IAAI,CAAC,MAAA,EAAQ,OAAO,EAAE,OAAA,EAAS,MAAA,EAAW,QAAQ,MAAA,EAAU;AAE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,EAAW,EAAA;AAAA,kBACT,SAAA,IACE;AAAA,iBACJ;AAAA,gBAEC,QAAA,EAAA,IAAA,CAAK;AAAA;AAAA,aACR;AAAA,YACC,IAAA,mBACC,GAAA,CAAC,eAAA,EAAA,EAAgB,SAAA,EAAU,WAAA,EACzB,QAAA,kBAAA,IAAA;AAAA,cAAC,MAAA;AAAA,cAAA;AAAA,gBACC,OAAA,EAAQ,OAAA;AAAA,gBACR,IAAA,EAAK,IAAA;AAAA,gBACL,eAAA,EAAe,IAAA;AAAA,gBACf,eAAA,EAAe,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAAA,gBACpC,SAAS,MACP,WAAA;AAAA,kBAAY,CAAC,KAAA,KACX,IAAA,GACI,KAAA,CAAM,OAAO,CAAC,KAAA,KAAU,KAAA,KAAU,IAAA,CAAK,KAAK,CAAA,GAC5C,CAAC,GAAG,KAAA,EAAO,KAAK,KAAK;AAAA,iBAC3B;AAAA,gBAGD,QAAA,EAAA;AAAA,kBAAA,IAAA,GAAO,aAAA,GAAgB,aAAA;AAAA,kCACxB,GAAA;AAAA,oBAAC,cAAA;AAAA,oBAAA;AAAA,sBACC,aAAA,EAAY,MAAA;AAAA,sBACZ,SAAA,EAAW,EAAA,CAAG,kCAAA,EAAoC,IAAA,IAAQ,YAAY;AAAA;AAAA;AACxE;AAAA;AAAA,eAEJ,CAAA,GACE;AAAA,WAAA,EACN,CAAA,EAAA,EAvCgB,KAAK,KAwCvB,CAAA;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"component-preview.js","sourcesContent":["'use client'\n\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover'\nimport { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport { Slider as SliderPrimitive } from '@base-ui/react/slider'\nimport { Toggle as TogglePrimitive } from '@base-ui/react/toggle'\nimport { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group'\nimport * as React from 'react'\n\nimport { ButtonGroup } from '../components/button-group.js'\nimport { Button, type ButtonProps } from '../components/button.js'\nimport {\n CodeBlock,\n CodeBlockContent,\n CodeBlockCopyButton,\n CodeBlockFooter,\n} from '../components/code-block.js'\nimport { Popover, PopoverContent, PopoverTrigger } from '../components/popover.js'\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from '../components/tabs.js'\nimport { IconCheck } from '../icons/check.js'\nimport { IconContrast } from '../icons/contrast.js'\nimport { IconDarkMode } from '../icons/dark-mode.js'\nimport { IconDesktopWindows } from '../icons/desktop-windows.js'\nimport { IconDragIndicator } from '../icons/drag-indicator.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { IconLightMode } from '../icons/light-mode.js'\nimport { IconPalette } from '../icons/palette.js'\nimport { IconSmartphone } from '../icons/smartphone.js'\nimport { IconTabletMac } from '../icons/tablet-mac.js'\nimport { PortalScopeContext, type PortalScope } from '../lib/portal-boundary.js'\nimport {\n ABORIGINAL_PALETTES,\n BRAND_PALETTES,\n PALETTE_STEPS,\n previewThemeStyle,\n type PreviewPalette,\n type PreviewScheme,\n} from '../lib/preview-theme.js'\nimport { cn } from '../lib/utils.js'\n\n/** Which colour schemes the stage shows: one, or both side by side. */\ntype ComponentPreviewTheme = PreviewScheme | 'both'\ntype ComponentPreviewDirection = 'ltr' | 'rtl'\ntype ComponentPreviewColorSet = 'brand' | 'aboriginal'\n\n/** The narrowest the stage can be dragged, in px. The spacing step 70 is the same 280px. */\nconst MIN_WIDTH = 280\nconst PHONE_WIDTH = 375\nconst TABLET_WIDTH = 768\n\nconst PALETTES: Record<ComponentPreviewColorSet, readonly PreviewPalette[]> = {\n brand: BRAND_PALETTES,\n aboriginal: ABORIGINAL_PALETTES,\n}\n\nconst setOf = (palette: PreviewPalette): ComponentPreviewColorSet =>\n palette.startsWith('aboriginal-') ? 'aboriginal' : 'brand'\n\n/**\n * The pair a stage starts with. Both unset is the page's own pair. Otherwise\n * the pair is completed within one colour set, the primary's if it is given:\n * the colour panel lists one set at a time, so a pair across two sets, or one\n * ramp without the other, would leave it with no checked choice. A missing or\n * unusable ramp takes the first palette of the set the other has not taken.\n */\nfunction colorPair(primary: PreviewPalette | undefined, accent: PreviewPalette | undefined) {\n const anchor = primary ?? accent\n if (!anchor) return { primary: undefined, accent: undefined }\n\n const palettes = PALETTES[setOf(anchor)]\n const first = (not?: PreviewPalette) => palettes.find((palette) => palette !== not)\n const resolvedPrimary = primary ?? first(accent)\n const fits = accent && palettes.includes(accent) && accent !== resolvedPrimary\n\n return { primary: resolvedPrimary, accent: fits ? accent : first(resolvedPrimary) }\n}\n\n/** `aboriginal-red` reads \"Red\": the set is named by the control above it. */\nconst paletteName = (palette: PreviewPalette) => {\n const name = palette.replace('aboriginal-', '')\n return name.charAt(0).toUpperCase() + name.slice(1)\n}\n\ntype ComponentPreviewContextValue = {\n theme: ComponentPreviewTheme\n setTheme: (theme: ComponentPreviewTheme) => void\n /** The stage's width in px, or `null` for the full width available. */\n width: number | null\n setWidth: (width: number | null) => void\n /** The first stage's rendered width, once it has been measured. */\n measuredWidth: number | null\n setMeasuredWidth: (width: number) => void\n direction: ComponentPreviewDirection\n setDirection: (direction: ComponentPreviewDirection) => void\n /** `undefined` keeps the page's own ramp. */\n primary: PreviewPalette | undefined\n accent: PreviewPalette | undefined\n setColors: (primary: PreviewPalette | undefined, accent: PreviewPalette | undefined) => void\n}\n\nconst ComponentPreviewContext = React.createContext<ComponentPreviewContextValue | null>(null)\n\nfunction useComponentPreview(part: string) {\n const context = React.useContext(ComponentPreviewContext)\n if (!context) throw new Error(`[nswds/ui] ${part} must be used inside a ComponentPreview.`)\n return context\n}\n\ntype ComponentPreviewProps = React.ComponentProps<'div'> & {\n /** The colour schemes shown at first. `both` puts light and dark side by side. */\n defaultTheme?: ComponentPreviewTheme\n /** The stage's width in px at first, 280 at the narrowest. Leave unset for the full width. */\n defaultWidth?: number\n /** The stage's text direction at first. */\n defaultDirection?: ComponentPreviewDirection\n /**\n * The palette used as the primary ramp at first. Leave both this and\n * `defaultAccent` unset for the page's own pair.\n */\n defaultPrimary?: PreviewPalette\n /**\n * The palette used as the accent ramp at first. It has to come from the\n * primary's colour set and differ from the primary; when it is unset or\n * does not, the first other palette of that set is used.\n */\n defaultAccent?: PreviewPalette\n}\n\n/**\n * A frame for showing a component: a header of controls, a stage that renders\n * the component in light, dark or both, and the code beneath. The controls\n * change the stage only, never the page around it.\n */\nfunction ComponentPreview({\n className,\n defaultTheme = 'both',\n defaultWidth,\n defaultDirection = 'ltr',\n defaultPrimary,\n defaultAccent,\n ...props\n}: ComponentPreviewProps) {\n const [theme, setTheme] = React.useState(defaultTheme)\n // The handle cannot go below MIN_WIDTH, so a narrower start is raised to it\n // and the frame and the handle agree from the first render.\n const [width, setWidth] = React.useState<number | null>(() =>\n typeof defaultWidth === 'number' && Number.isFinite(defaultWidth)\n ? Math.max(MIN_WIDTH, defaultWidth)\n : null,\n )\n const [measuredWidth, setMeasuredWidth] = React.useState<number | null>(null)\n const [direction, setDirection] = React.useState(defaultDirection)\n const [colors, setColorState] = React.useState(() => colorPair(defaultPrimary, defaultAccent))\n\n const setColors = React.useCallback(\n (primary: PreviewPalette | undefined, accent: PreviewPalette | undefined) =>\n setColorState({ primary, accent }),\n [],\n )\n\n const context = React.useMemo<ComponentPreviewContextValue>(\n () => ({\n theme,\n setTheme,\n width,\n setWidth,\n measuredWidth,\n setMeasuredWidth,\n direction,\n setDirection,\n primary: colors.primary,\n accent: colors.accent,\n setColors,\n }),\n [theme, width, measuredWidth, direction, colors, setColors],\n )\n\n return (\n <ComponentPreviewContext.Provider value={context}>\n <div\n data-slot='component-preview'\n className={cn(\n '@container/component-preview flex w-full min-w-0 flex-col overflow-hidden rounded-md border border-border bg-background text-base text-foreground',\n className,\n )}\n {...props}\n data-theme-mode={theme}\n />\n </ComponentPreviewContext.Provider>\n )\n}\n\n/**\n * The band across the top, for the title and the controls. It is the solid\n * brand band: white on the primary ramp's 800 step, deepening in dark.\n */\nfunction ComponentPreviewHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='component-preview-header'\n className={cn(\n 'flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2 bg-primary-800 py-3 pe-4 text-white @max-3xl/component-preview:ps-4 @3xl/component-preview:ps-6 dark:bg-primary-950',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The name of the example. It truncates. */\nfunction ComponentPreviewTitle({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='component-preview-title'\n className={cn('min-w-0 truncate text-xl font-semibold', className)}\n {...props}\n />\n )\n}\n\n/** Holds the controls at the end of the header. They wrap when they run out of room. */\nfunction ComponentPreviewControls({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='component-preview-controls'\n className={cn('ms-auto flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2', className)}\n {...props}\n />\n )\n}\n\n/**\n * A toggle hands its render function the props of an HTML button, whose\n * `color` is the legacy attribute typed as any string. It is never set here,\n * and Button's own `color` is narrower, so the type alone is narrowed.\n */\nconst asButtonProps = (props: React.ComponentProps<'button'>) =>\n props as Omit<React.ComponentProps<'button'>, 'color'>\n\n/** One segment of a control on the band: solid while it is the chosen one. */\nfunction Segment({\n value,\n label,\n children,\n}: {\n value: string\n label: string\n children: React.ReactNode\n}) {\n return (\n <TogglePrimitive\n value={value}\n aria-label={label}\n title={label}\n render={(props, state) => (\n <Button {...asButtonProps(props)} iconOnly variant={state.pressed ? 'solid' : 'ghost'} />\n )}\n >\n {children}\n </TogglePrimitive>\n )\n}\n\ntype ComponentPreviewThemeToggleProps = Omit<\n React.ComponentProps<typeof ButtonGroup>,\n 'children'\n> & {\n /** Accessible names of the three choices. Override to translate them. */\n lightLabel?: string\n darkLabel?: string\n bothLabel?: string\n}\n\n/** Chooses the stage's colour scheme: light, dark, or both side by side. */\nfunction ComponentPreviewThemeToggle({\n lightLabel = 'Light',\n darkLabel = 'Dark',\n bothLabel = 'Light and dark',\n 'aria-label': ariaLabel = 'Colour scheme',\n ...props\n}: ComponentPreviewThemeToggleProps) {\n const { theme, setTheme } = useComponentPreview('ComponentPreviewThemeToggle')\n\n return (\n <ToggleGroupPrimitive\n value={[theme]}\n // A single-choice group lets the pressed item be released; one scheme\n // is always showing, so an empty value is ignored.\n onValueChange={(value) => {\n const next = value[0] as ComponentPreviewTheme | undefined\n if (next) setTheme(next)\n }}\n render={\n <ButtonGroup\n data-slot='component-preview-theme-toggle'\n color='white'\n size='sm'\n aria-label={ariaLabel}\n {...props}\n />\n }\n >\n <Segment value='light' label={lightLabel}>\n <IconLightMode aria-hidden='true' />\n </Segment>\n <Segment value='dark' label={darkLabel}>\n <IconDarkMode aria-hidden='true' />\n </Segment>\n <Segment value='both' label={bothLabel}>\n <IconContrast aria-hidden='true' />\n </Segment>\n </ToggleGroupPrimitive>\n )\n}\n\ntype ComponentPreviewWidthToggleProps = Omit<\n React.ComponentProps<typeof ButtonGroup>,\n 'children'\n> & {\n /** Accessible names of the three choices. Override to translate them. */\n phoneLabel?: string\n tabletLabel?: string\n fullLabel?: string\n}\n\n/**\n * Sets the stage to a phone's width, a tablet's, or all the room there is,\n * and reads out the width it ends up at.\n */\nfunction ComponentPreviewWidthToggle({\n phoneLabel = `Phone, ${PHONE_WIDTH}px`,\n tabletLabel = `Tablet, ${TABLET_WIDTH}px`,\n fullLabel = 'Full width',\n 'aria-label': ariaLabel = 'Width',\n ...props\n}: ComponentPreviewWidthToggleProps) {\n const { width, setWidth, measuredWidth } = useComponentPreview('ComponentPreviewWidthToggle')\n\n return (\n <div data-slot='component-preview-width' className='flex items-center gap-3'>\n <ToggleGroupPrimitive\n value={[width === null ? 'full' : String(width)]}\n onValueChange={(value) => {\n const next = value[0] as string | undefined\n if (next) setWidth(next === 'full' ? null : Number(next))\n }}\n render={\n <ButtonGroup\n data-slot='component-preview-width-toggle'\n color='white'\n size='sm'\n aria-label={ariaLabel}\n {...props}\n />\n }\n >\n <Segment value={String(PHONE_WIDTH)} label={phoneLabel}>\n <IconSmartphone aria-hidden='true' />\n </Segment>\n <Segment value={String(TABLET_WIDTH)} label={tabletLabel}>\n <IconTabletMac aria-hidden='true' />\n </Segment>\n <Segment value='full' label={fullLabel}>\n <IconDesktopWindows aria-hidden='true' />\n </Segment>\n </ToggleGroupPrimitive>\n {/* Empty until the stage has been measured, with its room held. */}\n <span\n data-slot='component-preview-width-readout'\n className='min-w-[6ch] text-end font-mono text-base tabular-nums'\n >\n {measuredWidth === null ? '' : `${measuredWidth}px`}\n </span>\n </div>\n )\n}\n\ntype ComponentPreviewDirectionToggleProps = ButtonProps & {\n /** What the toggle does, shown as its tooltip. Override to translate it. */\n title?: string\n}\n\n/**\n * Flips the stage to right-to-left, to prove a component uses logical\n * properties. Its visible label is its name, so pass translated `children`\n * rather than an `aria-label` that would disagree with them.\n */\nfunction ComponentPreviewDirectionToggle({\n children = 'RTL',\n title = 'Right to left',\n ...props\n}: ComponentPreviewDirectionToggleProps) {\n const { direction, setDirection } = useComponentPreview('ComponentPreviewDirectionToggle')\n\n return (\n <TogglePrimitive\n pressed={direction === 'rtl'}\n onPressedChange={(pressed) => setDirection(pressed ? 'rtl' : 'ltr')}\n title={title}\n render={(toggleProps, state) => (\n <Button\n data-slot='component-preview-direction-toggle'\n color='white'\n size='sm'\n {...props}\n {...asButtonProps(toggleProps)}\n variant={state.pressed ? 'solid' : 'outline'}\n />\n )}\n >\n {children}\n </TogglePrimitive>\n )\n}\n\nconst optionClassName =\n 'relative flex min-h-11 cursor-pointer items-center gap-2.5 rounded-sm border border-border bg-background px-3 py-2 text-start text-base font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring data-checked:border-foreground data-checked:ring-1 data-checked:ring-foreground'\n\n/** One group of the colour panel: a visible heading naming a radio group. */\nfunction PaletteGroup({\n label,\n step,\n value,\n options,\n onValueChange,\n format,\n}: {\n label: string\n step: 600 | 800\n /** The palette in use, or `null` when the ramp is the page's own. */\n value: PreviewPalette | null\n options: readonly PreviewPalette[]\n onValueChange: (palette: PreviewPalette) => void\n format: (palette: PreviewPalette) => string\n}) {\n const id = React.useId()\n\n return (\n <div className='flex flex-col gap-2'>\n <div id={id} className='text-base font-semibold'>\n {label}\n </div>\n <RadioGroupPrimitive\n aria-labelledby={id}\n value={value}\n onValueChange={(next) => onValueChange(next as PreviewPalette)}\n className='grid grid-cols-2 gap-2'\n >\n {options.map((palette) => (\n <RadioPrimitive.Root key={palette} value={palette} className={optionClassName}>\n <span\n aria-hidden='true'\n className='size-5 flex-none rounded-full'\n style={{ backgroundColor: `var(--nsw-${palette}-${step})` }}\n />\n {format(palette)}\n <RadioPrimitive.Indicator className='ms-auto'>\n <IconCheck aria-hidden='true' className='size-5' />\n </RadioPrimitive.Indicator>\n </RadioPrimitive.Root>\n ))}\n </RadioGroupPrimitive>\n </div>\n )\n}\n\ntype ComponentPreviewColorPickerProps = Omit<ButtonProps, 'children'> & {\n /** The button's label. */\n label?: string\n /** Headings and choices inside the panel. Override to translate them. */\n setLabel?: string\n brandLabel?: string\n aboriginalLabel?: string\n primaryLabel?: string\n accentLabel?: string\n resetLabel?: string\n /** Shown in the panel while the stage is using the page's own colours. */\n pageLabel?: string\n /** Names a palette. The default reads `aboriginal-red` as \"Red\". */\n formatPalette?: (palette: PreviewPalette) => string\n}\n\n/**\n * A button that opens a panel for choosing the stage's primary and accent\n * colours from the NSW brand set or the Aboriginal set. The two dots on the\n * button show the pair in use. An accent is never the same colour as the\n * primary, so the accent list leaves the primary out. Until a pair is chosen,\n * and after Reset, the stage uses the page's own colours: the panel then\n * checks nothing and says so, because those need not be a palette it lists.\n */\nfunction ComponentPreviewColorPicker({\n label = 'Theme',\n setLabel = 'Colour set',\n brandLabel = 'Brand',\n aboriginalLabel = 'Aboriginal',\n primaryLabel = 'Primary',\n accentLabel = 'Accent',\n resetLabel = 'Reset',\n pageLabel = 'Using this page’s colours',\n formatPalette = paletteName,\n ...props\n}: ComponentPreviewColorPickerProps) {\n const context = useComponentPreview('ComponentPreviewColorPicker')\n const setId = React.useId()\n // The pair is set together or not at all (see `colorPair`). Unset, the stage\n // is using the page's own colours, which need not be any palette listed\n // here, so the panel checks nothing and says so; the brand set is on show\n // to choose from.\n const { primary, accent } = context\n const set = primary ? setOf(primary) : null\n const palettes = PALETTES[set ?? 'brand']\n\n // The dots show the pair the stage is using. An unset ramp is the page's,\n // read through its bridge so a rebranded page shows its own colours.\n const primaryDot = primary ? `var(--nsw-${primary}-800)` : 'var(--color-primary-800)'\n const accentDot = accent ? `var(--nsw-${accent}-600)` : 'var(--color-accent-600)'\n\n // Choosing one ramp completes the pair, so neither is left as the page's.\n const choose = (\n nextPrimary: PreviewPalette | undefined,\n nextAccent: PreviewPalette | undefined,\n ) => {\n const pair = colorPair(nextPrimary, nextAccent)\n context.setColors(pair.primary, pair.accent)\n }\n\n return (\n <Popover>\n <PopoverTrigger\n render={\n <Button\n data-slot='component-preview-color-picker'\n variant='outline'\n color='white'\n size='sm'\n {...props}\n />\n }\n >\n <IconPalette aria-hidden='true' />\n {label}\n <span aria-hidden='true' className='flex gap-1'>\n <span\n className='size-4 rounded-full ring-1 ring-white'\n data-slot='component-preview-color-dot'\n style={{ backgroundColor: primaryDot }}\n />\n <span\n className='size-4 rounded-full ring-1 ring-white'\n data-slot='component-preview-color-dot'\n style={{ backgroundColor: accentDot }}\n />\n </span>\n </PopoverTrigger>\n <PopoverContent\n align='end'\n sideOffset={8}\n className='w-100 max-w-[calc(100vw-1rem)] gap-5 p-5 text-base'\n >\n <PopoverPrimitive.Title className='sr-only'>{label}</PopoverPrimitive.Title>\n <div className='flex flex-col gap-2'>\n <div id={setId} className='text-base font-semibold'>\n {setLabel}\n </div>\n <RadioGroupPrimitive\n aria-labelledby={setId}\n value={set}\n onValueChange={(next) => {\n const list = PALETTES[next as ComponentPreviewColorSet]\n context.setColors(list[0], list[1])\n }}\n className='grid grid-cols-2 gap-2'\n >\n <RadioPrimitive.Root value='brand' className={cn(optionClassName, 'justify-center')}>\n {brandLabel}\n </RadioPrimitive.Root>\n <RadioPrimitive.Root\n value='aboriginal'\n className={cn(optionClassName, 'justify-center')}\n >\n {aboriginalLabel}\n </RadioPrimitive.Root>\n </RadioGroupPrimitive>\n </div>\n <PaletteGroup\n label={primaryLabel}\n step={800}\n value={primary ?? null}\n options={palettes}\n onValueChange={(next) => choose(next, accent)}\n format={formatPalette}\n />\n <PaletteGroup\n label={accentLabel}\n step={600}\n value={accent ?? null}\n options={palettes.filter((palette) => palette !== primary)}\n onValueChange={(next) => choose(primary, next)}\n format={formatPalette}\n />\n <div className='-mx-2 -mb-2 flex items-center gap-3 border-t border-border pt-2'>\n <Button variant='ghost' size='sm' onClick={() => context.setColors(undefined, undefined)}>\n {resetLabel}\n </Button>\n {primary ? null : (\n <p\n data-slot='component-preview-color-status'\n className='ms-auto pe-2 text-base text-muted-foreground'\n >\n {pageLabel}\n </p>\n )}\n </div>\n </PopoverContent>\n </Popover>\n )\n}\n\nconst NO_VALUES: Record<string, string> = {}\n\nconst sameValues = (a: Record<string, string>, b: Record<string, string>) => {\n const keys = Object.keys(a)\n return keys.length === Object.keys(b).length && keys.every((key) => a[key] === b[key])\n}\n\n/** One rendering of the children, in one colour scheme, with its drag handle. */\nfunction StagePane({\n scheme,\n label,\n resizeLabel,\n reportsWidth,\n children,\n}: {\n scheme: PreviewScheme\n /** Shown above the stage when both schemes are on screen. */\n label: string | undefined\n resizeLabel: string\n reportsWidth: boolean\n children: React.ReactNode\n}) {\n const { width, setWidth, setMeasuredWidth, direction, primary, accent } =\n useComponentPreview('ComponentPreviewStage')\n const wellRef = React.useRef<HTMLDivElement>(null)\n const frameRef = React.useRef<HTMLDivElement>(null)\n // The room the stage has, in px. Zero until measured, and the handle waits for it.\n const [available, setAvailable] = React.useState(0)\n\n const measure = React.useCallback(() => {\n const well = wellRef.current\n const frame = frameRef.current\n if (!well || !frame) return\n setAvailable(Math.round(well.getBoundingClientRect().width))\n if (reportsWidth) setMeasuredWidth(Math.round(frame.getBoundingClientRect().width))\n }, [reportsWidth, setMeasuredWidth])\n\n // Measured here as well as by the observer below: on mount, and whenever a\n // control sets the width. A browser holds an observer's callbacks back while\n // the page is not being painted (a background tab), and the handle and the\n // readout would otherwise wait with them.\n React.useLayoutEffect(measure, [measure, width])\n\n React.useEffect(() => {\n const well = wellRef.current\n const frame = frameRef.current\n if (!well || !frame || typeof ResizeObserver === 'undefined') return\n\n const observer = new ResizeObserver(measure)\n observer.observe(well)\n observer.observe(frame)\n return () => observer.disconnect()\n }, [measure])\n\n const style = React.useMemo(\n () => previewThemeStyle({ scheme, primary, accent }) as React.CSSProperties,\n [scheme, primary, accent],\n )\n // What makes this half its scheme, stated once: the pane and the frame below\n // read it, and so does a popup opened from inside the stage, which portals\n // out of it and would otherwise take the page's (see `PortalBoundary`).\n // `dark` and `data-theme` are what the stylesheet's dark variant and the\n // dark role tokens key on; the island marker is what keeps `dark:`\n // utilities out of a light stage on a dark page.\n const scope = React.useMemo<PortalScope>(\n () => ({\n className: scheme === 'dark' ? 'dark scheme-dark' : 'scheme-light',\n style,\n dir: direction,\n attributes: {\n 'data-theme': scheme,\n 'data-theme-island': scheme === 'light' ? 'light' : undefined,\n },\n }),\n [scheme, style, direction],\n )\n // A ramp left as the page's own is inherited by the pane, but a popup is not\n // a descendant of the pane: it portals to the end of the page, outside any\n // rebrand set on a container around the preview. So the values the pane\n // actually inherits are read from it and handed to the popup with the rest.\n // Read on mount, when the choice changes, and again whenever the pointer or\n // focus enters the stage, which is always before a popup can open from it.\n const paneRef = React.useRef<HTMLDivElement>(null)\n const [inherited, setInherited] = React.useState<Record<string, string>>(NO_VALUES)\n const readInherited = React.useCallback(() => {\n const pane = paneRef.current\n if (!pane) return\n const computed = getComputedStyle(pane)\n const next: Record<string, string> = {}\n for (const [ramp, chosen] of [\n ['primary', primary],\n ['accent', accent],\n ] as const) {\n if (chosen) continue\n for (const step of PALETTE_STEPS) {\n for (const name of [`--${ramp}-${step}`, `--color-${ramp}-${step}`]) {\n const value = computed.getPropertyValue(name).trim()\n if (value) next[name] = value\n }\n }\n }\n setInherited((current) => (sameValues(current, next) ? current : next))\n }, [primary, accent])\n React.useLayoutEffect(readInherited, [readInherited])\n\n const portalScope = React.useMemo<PortalScope>(\n () => ({ ...scope, style: { ...scope.style, ...inherited } }),\n [scope, inherited],\n )\n const resizable = available > MIN_WIDTH\n\n return (\n <div\n ref={paneRef}\n data-slot='component-preview-pane'\n onPointerEnter={readInherited}\n onFocusCapture={readInherited}\n className={cn(\n 'min-w-0 flex-1 bg-muted text-foreground @max-3xl/component-preview:py-4 @max-3xl/component-preview:ps-4 @max-3xl/component-preview:pe-9 @3xl/component-preview:py-6 @3xl/component-preview:ps-6 @3xl/component-preview:pe-10',\n scope.className,\n )}\n {...scope.attributes}\n style={scope.style}\n >\n {label ? (\n <div\n data-slot='component-preview-pane-label'\n className='mb-2 font-medium text-muted-foreground'\n >\n {label}\n </div>\n ) : null}\n <div ref={wellRef} className='relative'>\n <div\n ref={frameRef}\n data-slot='component-preview-frame'\n dir={scope.dir}\n style={{ maxWidth: width ?? undefined }}\n className='@container/component-preview-frame min-w-0 border border-border bg-background text-foreground @max-3xl/component-preview:p-4 @3xl/component-preview:p-8'\n >\n <PortalScopeContext.Provider value={portalScope}>{children}</PortalScopeContext.Provider>\n </div>\n {resizable ? (\n <SliderPrimitive.Root\n min={MIN_WIDTH}\n max={available}\n step={8}\n largeStep={64}\n value={Math.min(width ?? available, available)}\n // Dragged back to the end, the stage is full width again rather\n // than pinned to whatever that happened to measure.\n onValueChange={(value) => setWidth(value >= available ? null : value)}\n >\n <SliderPrimitive.Control className='pointer-events-none absolute inset-y-0 start-70 end-0'>\n <SliderPrimitive.Thumb\n data-slot='component-preview-resize-handle'\n aria-label={resizeLabel}\n getAriaValueText={(_, value) => `${value}px`}\n className='pointer-events-auto ms-4 flex h-full w-6 cursor-ew-resize touch-none items-center justify-center rounded-sm text-muted-foreground hover:bg-foreground/10 hover:text-foreground has-focus:outline-2 has-focus:outline-offset-2 has-focus:outline-ring data-dragging:bg-foreground/10 data-dragging:text-foreground'\n >\n <IconDragIndicator aria-hidden='true' className='size-5 flex-none' />\n </SliderPrimitive.Thumb>\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n ) : null}\n </div>\n </div>\n )\n}\n\ntype ComponentPreviewStageProps = React.ComponentProps<'div'> & {\n /** Captions over the two halves when both schemes show. Override to translate them. */\n lightLabel?: string\n darkLabel?: string\n /** Accessible name of the drag handle. Override to translate it. */\n resizeLabel?: string\n}\n\n/**\n * Where the component renders. With the `both` theme the children render\n * twice, once per scheme, so give any `id` inside them a value from `useId`.\n * Each stage is a container, so a component can respond to the stage's width\n * with a container query; a media query still reads the viewport.\n *\n * A popup from this package that portals out of the stage (Dialog, Popover,\n * Select, Tooltip and the like) keeps the stage's scheme, colours and\n * direction: the stage hands them over through `PortalScopeContext`, and each\n * popup applies them at its portal with `PortalBoundary`. A portal from\n * elsewhere takes the page's, unless its contents are wrapped in\n * `PortalBoundary` too. So do toasts, which render in the page's `Toaster`,\n * not in the stage.\n */\nfunction ComponentPreviewStage({\n className,\n children,\n lightLabel = 'Light',\n darkLabel = 'Dark',\n resizeLabel = 'Preview width',\n ...props\n}: ComponentPreviewStageProps) {\n const { theme } = useComponentPreview('ComponentPreviewStage')\n const schemes: PreviewScheme[] = theme === 'both' ? ['light', 'dark'] : [theme]\n const labels = { light: lightLabel, dark: darkLabel }\n\n return (\n <div\n data-slot='component-preview-stage'\n className={cn(\n 'flex min-w-0 @max-3xl/component-preview:flex-col @3xl/component-preview:flex-row',\n className,\n )}\n {...props}\n >\n {schemes.map((scheme, index) => (\n <StagePane\n key={scheme}\n scheme={scheme}\n label={theme === 'both' ? labels[scheme] : undefined}\n resizeLabel={resizeLabel}\n reportsWidth={index === 0}\n >\n {children}\n </StagePane>\n ))}\n </div>\n )\n}\n\n/** One tab of the code area. */\ntype ComponentPreviewFile = {\n /** The tab's label, such as \"Code\" or \"npm\". Labels must be unique. */\n label: string\n /** The text shown, and copied by the copy button. */\n code: string\n}\n\ntype ComponentPreviewCodeProps = Omit<React.ComponentProps<'div'>, 'children'> & {\n /** The tabs, in order. The first is shown at first. */\n files: ComponentPreviewFile[]\n /** A file longer than this many lines is cut short behind a \"Show more\" button. */\n collapsedLines?: number\n /** Labels of the button that expands and collapses a long file. */\n showMoreLabel?: string\n showLessLabel?: string\n /** Accessible name of the copy button, and what it reports after a copy. */\n copyLabel?: string\n copiedLabel?: string\n}\n\n/**\n * The code under the stage: one tab per file, a copy button for the tab in\n * view, and a \"Show more\" button on a long file.\n */\nfunction ComponentPreviewCode({\n className,\n files,\n collapsedLines = 8,\n showMoreLabel = 'Show more',\n showLessLabel = 'Show less',\n copyLabel,\n copiedLabel,\n ...props\n}: ComponentPreviewCodeProps) {\n const [active, setActive] = React.useState(0)\n // Per file, by label: expanding one long file leaves the others cut short,\n // and the state stays with its file when `files` is reordered or changed.\n const [expanded, setExpanded] = React.useState<readonly string[]>([])\n const contentId = React.useId()\n // `files` may get shorter after a later tab was chosen; fall back to the first.\n const shown = active < files.length ? active : 0\n const current = files[shown]\n\n if (!current) return null\n\n return (\n <Tabs\n data-slot='component-preview-code'\n value={shown}\n onValueChange={(value) => setActive(value as number)}\n className={cn('min-w-0 gap-0 border-t border-border', className)}\n {...props}\n >\n <div className='flex min-w-0 items-center gap-2 border-b border-border ps-4 pe-2'>\n <TabsList variant='line' className='min-w-0 gap-5 overflow-x-auto border-b-0'>\n {files.map((file, index) => (\n <TabsTrigger\n key={file.label}\n value={index}\n className='text-base focus-visible:-outline-offset-2'\n >\n {file.label}\n </TabsTrigger>\n ))}\n </TabsList>\n <CodeBlockCopyButton\n className='ms-auto'\n value={current.code}\n aria-label={copyLabel}\n copiedLabel={copiedLabel}\n />\n </div>\n {files.map((file, index) => {\n const long = file.code.split('\\n').length > collapsedLines\n const open = expanded.includes(file.label)\n const collapsed = long && !open\n\n return (\n <TabsContent key={file.label} value={index} className='min-w-0 text-base'>\n <CodeBlock className='rounded-none border-0'>\n <CodeBlockContent\n id={`${contentId}-${index}`}\n style={\n collapsed\n ? { maxHeight: `calc(${collapsedLines}lh + var(--code-block-p))` }\n : undefined\n }\n className={cn(\n collapsed &&\n 'overflow-hidden [mask-image:linear-gradient(black_55%,transparent)]',\n )}\n >\n {file.code}\n </CodeBlockContent>\n {long ? (\n <CodeBlockFooter className='px-2 pb-2'>\n <Button\n variant='ghost'\n size='sm'\n aria-expanded={open}\n aria-controls={`${contentId}-${index}`}\n onClick={() =>\n setExpanded((state) =>\n open\n ? state.filter((label) => label !== file.label)\n : [...state, file.label],\n )\n }\n >\n {open ? showLessLabel : showMoreLabel}\n <IconExpandMore\n aria-hidden='true'\n className={cn('motion-safe:transition-transform', open && 'rotate-180')}\n />\n </Button>\n </CodeBlockFooter>\n ) : null}\n </CodeBlock>\n </TabsContent>\n )\n })}\n </Tabs>\n )\n}\n\nexport type { PreviewPalette as ComponentPreviewPalette } from '../lib/preview-theme.js'\nexport {\n ComponentPreview,\n ComponentPreviewCode,\n ComponentPreviewColorPicker,\n ComponentPreviewControls,\n ComponentPreviewDirectionToggle,\n ComponentPreviewHeader,\n ComponentPreviewStage,\n ComponentPreviewThemeToggle,\n ComponentPreviewTitle,\n ComponentPreviewWidthToggle,\n}\nexport type {\n ComponentPreviewCodeProps,\n ComponentPreviewColorPickerProps,\n ComponentPreviewColorSet,\n ComponentPreviewDirection,\n ComponentPreviewDirectionToggleProps,\n ComponentPreviewFile,\n ComponentPreviewProps,\n ComponentPreviewStageProps,\n ComponentPreviewTheme,\n ComponentPreviewThemeToggleProps,\n ComponentPreviewWidthToggleProps,\n}\n"]}
|
|
@@ -4,8 +4,8 @@ import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
|
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
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, overlayInk } 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 Dialog({ ...props }) {
|
|
@@ -18,7 +18,7 @@ function DialogClose({ ...props }) {
|
|
|
18
18
|
return /* @__PURE__ */ jsx(Dialog$1.Close, { "data-slot": "dialog-close", ...props });
|
|
19
19
|
}
|
|
20
20
|
function DialogPortal({ children, ...props }) {
|
|
21
|
-
return /* @__PURE__ */ jsx(Dialog$1.Portal, { "data-slot": "dialog-portal", ...props, children: /* @__PURE__ */ jsx(
|
|
21
|
+
return /* @__PURE__ */ jsx(Dialog$1.Portal, { "data-slot": "dialog-portal", ...props, children: /* @__PURE__ */ jsx(PortalBoundary, { children }) });
|
|
22
22
|
}
|
|
23
23
|
const dialogContentVariants = cva(
|
|
24
24
|
// `w-[calc(100%-2rem)]` + `max-w-lg` rather than shadcn's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/dialog.tsx"],"names":["DialogPrimitive"],"mappings":";;;;;;;;;AAYA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAA+B;AACxD,EAAA,2BAAQA,QAAA,CAAgB,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC7D;AAEA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAkC;AAClE,EAAA,2BAAQA,QAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC9D,EAAA,2BAAQA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAAO,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itive } from '@base-ui/react/dialog'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { IconClose } from '../icons/close.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { overlayInk, overlayScrim } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Dialog({ ...props }: DialogPrimitive.Root.Props) {\n return <DialogPrimitive.Root data-slot='dialog' {...props} />\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n return <DialogPrimitive.Trigger data-slot='dialog-trigger' {...props} />\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n return <DialogPrimitive.Close data-slot='dialog-close' {...props} />\n}\n\nfunction DialogPortal({ children, ...props }: DialogPrimitive.Portal.Props) {\n return (\n <DialogPrimitive.Portal data-slot='dialog-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </DialogPrimitive.Portal>\n )\n}\n\n/**\n * The three approved looks (design-shotgun, overlays-20260923):\n *\n * - `default` (Hairline): a flat raised surface drawn with a 1px ring; the\n * header and footer bleed to the edges and are divided off by hairlines.\n * - `band`: the header is a solid band in the action colour with an inverse\n * title; the footer sits on a subtle band.\n * - `rule`: a 4px rule in the ink colour caps the top edge, the title sits on\n * a hairline in the text colour, and the actions align to the start.\n *\n * None casts a shadow and none blurs the page behind — depth is drawn, per\n * DESIGN.md's Hairline Rule. Parts read the variant from `data-variant` on\n * the popup through `group-data-*`, so there is no context to thread.\n */\ntype DialogVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes and its look. The parts (header, footer, title,\n * description, close button) read the look from `data-variant` through\n * `group-data-*` instead: cva sees only its own props, not an ancestor's.\n * Radius sits in every branch, not the base, so rule's square top never\n * competes with a base `rounded-md` at equal specificity.\n */\nconst dialogContentVariants = cva(\n // `w-[calc(100%-2rem)]` + `max-w-lg` rather than shadcn's\n // `max-w-[calc(100%-2rem)] sm:max-w-sm`: two different properties, so there\n // is no bare/responsive pair for a consumer's build to reorder (see\n // check:cascade).\n 'group/dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-6 overflow-y-auto bg-popover p-6 text-base/relaxed text-popover-foreground ring-1 ring-foreground/10 outline-hidden transition-[opacity,scale] duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0',\n {\n variants: {\n variant: {\n default: 'rounded-md',\n band: 'rounded-md',\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--overlay-ink)',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n)\n\nfunction DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {\n return (\n <DialogPrimitive.Backdrop\n data-slot='dialog-overlay'\n className={cn(\n 'fixed inset-0 z-50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogContent({\n className,\n children,\n variant = 'default',\n showCloseButton = true,\n closeLabel = 'Close',\n ...props\n}: DialogPrimitive.Popup.Props & {\n variant?: DialogVariant\n showCloseButton?: boolean\n /**\n * Screen-reader name for the close button. Override to translate it — the\n * button is icon-only, so this string is the only name AT ever hears.\n */\n closeLabel?: string\n}) {\n return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Popup\n data-slot='dialog-content'\n data-variant={variant}\n className={cn(\n dialogContentVariants({ variant }),\n // The ink rule's cap is drawn in (see overlayInk).\n overlayInk,\n // The header rules below match it at any depth, not only as a direct\n // child: an edit dialog usually wraps its content in a <form>.\n // A header with nothing below it draws no divider over empty space.\n '[&_[data-slot=dialog-header]:last-child]:border-b-0',\n // Keep a long title clear of the absolutely-positioned close button:\n // 72px where the header bleeds to the edge (24px gutter + the 48px\n // the button needs), 48px under `rule`, whose header does not bleed.\n '[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-18 data-[variant=rule]:[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-12',\n // With no header at all, the first content after the close button\n // reserves the button's 48px instead, so its text cannot run under it.\n '[&>[data-slot=dialog-close]+:not([data-slot=dialog-header]):not(:has([data-slot=dialog-header]))]:pe-12',\n className,\n )}\n {...props}\n >\n {/* The close button comes FIRST in the DOM (it is absolutely placed, so\n the visual order is unchanged). Base UI focuses the first tabbable\n element on open; after the content, that is a footer button, and a\n long dialog opens scrolled to the bottom with the reader past\n everything above it. */}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot='dialog-close'\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className={cn(\n // z-20, as Sheet's: the button comes first in the DOM, and\n // equal z-indexes paint in DOM order, so any later positioned\n // child in the corner (a Button is `relative`) would paint\n // over it and take its clicks. z-20 clears children up to and\n // including the conventional sticky-header z-10.\n 'absolute end-4 top-4 z-20',\n // On the band the button takes the band's inverse ink — only\n // when a header is there to paint the band. The extra\n // data-slot keeps this above Button's own dark ink at any\n // emission order.\n 'group-data-[variant=band]/dialog-content:group-has-[[data-slot=dialog-header]]/dialog-content:data-[slot=dialog-close]:[--btn-bg:var(--text-inverse)]',\n )}\n />\n }\n >\n <IconClose />\n </DialogPrimitive.Close>\n )}\n {children}\n </DialogPrimitive.Popup>\n </DialogPortal>\n )\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='dialog-header'\n className={cn(\n // default: bleeds to the popup's edges and is divided off by a hairline.\n '-mx-6 -mt-6 flex flex-col gap-2 border-b border-border px-6 pt-6 pb-5',\n // band: the same bleed, painted as a solid band instead of divided.\n 'group-data-[variant=band]/dialog-content:border-b-0 group-data-[variant=band]/dialog-content:bg-primary group-data-[variant=band]/dialog-content:pb-6 group-data-[variant=band]/dialog-content:text-primary-foreground',\n // rule: no bleed — the title carries its own hairline instead.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mt-0 group-data-[variant=rule]/dialog-content:border-b-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:pt-0 group-data-[variant=rule]/dialog-content:pb-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogFooter({\n className,\n showCloseButton = false,\n closeLabel = 'Close',\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n /** Appends an outline Close button after the footer's own actions. */\n showCloseButton?: boolean\n /** Visible label of that Close button. Override to translate it. */\n closeLabel?: string\n}) {\n return (\n <div\n data-slot='dialog-footer'\n className={cn(\n // Stacked with the primary action on top below `sm`, a row aligned to\n // the end from `sm` up. `max-sm:` rather than a bare `flex-col-reverse`\n // keeps the pair cascade-safe (see check:cascade).\n 'flex gap-2 max-sm:flex-col-reverse sm:flex-row sm:justify-end',\n // default: bleeds to the popup's edges above a hairline.\n '-mx-6 -mb-6 border-t border-border px-6 py-4',\n // band: the same bleed on a subtle band instead of a hairline.\n 'group-data-[variant=band]/dialog-content:border-t-0 group-data-[variant=band]/dialog-content:bg-muted',\n // rule: no bleed, actions aligned to the start.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mb-0 group-data-[variant=rule]/dialog-content:border-t-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:py-0 group-data-[variant=rule]/dialog-content:sm:justify-start',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close render={<Button variant='outline' />}>\n {closeLabel}\n </DialogPrimitive.Close>\n )}\n </div>\n )\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n return (\n <DialogPrimitive.Title\n data-slot='dialog-title'\n className={cn(\n 'font-heading text-2xl font-medium text-foreground',\n // Inverse ink only inside the band — a title placed in the body stays\n // on the popover and must keep the default ink.\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n 'group-data-[variant=rule]/dialog-content:border-b group-data-[variant=rule]/dialog-content:border-foreground group-data-[variant=rule]/dialog-content:pb-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {\n return (\n <DialogPrimitive.Description\n data-slot='dialog-description'\n className={cn(\n 'text-base/relaxed text-muted-foreground',\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n dialogContentVariants,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n}\nexport type { DialogVariant }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/dialog.tsx"],"names":["DialogPrimitive"],"mappings":";;;;;;;;;AAYA,SAAS,MAAA,CAAO,EAAE,GAAG,KAAA,EAAM,EAA+B;AACxD,EAAA,2BAAQA,QAAA,CAAgB,IAAA,EAAhB,EAAqB,WAAA,EAAU,QAAA,EAAU,GAAG,KAAA,EAAO,CAAA;AAC7D;AAEA,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAkC;AAClE,EAAA,2BAAQA,QAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,WAAA,CAAY,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC9D,EAAA,2BAAQA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,WAAA,EAAU,cAAA,EAAgB,GAAG,KAAA,EAAO,CAAA;AACpE;AAEA,SAAS,YAAA,CAAa,EAAE,QAAA,EAAU,GAAG,OAAM,EAAiC;AAC1E,EAAA,uBACE,GAAA,CAACA,QAAA,CAAgB,MAAA,EAAhB,EAAuB,WAAA,EAAU,eAAA,EAAiB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AW,EAAA;AAAA;AAAA;AAAA;AAAA,QAIT,+DAAA;AAAA;AAAA,QAEA,8CAAA;AAAA;AAAA,QAEA,uGAAA;AAAA;AAAA,QAEA,uSAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QACA,eAAA,oBACC,GAAA,CAACA,QAAA,CAAgB,KAAA,EAAhB,EAAsB,MAAA,kBAAQ,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAQ,SAAA,EAAU,CAAA,EACtD,QAAA,EAAA,UAAA,EACH;AAAA;AAAA;AAAA,GAEJ;AAEJ;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,mDAAA;AAAA;AAAA;AAAA,QAGA,+FAAA;AAAA,QACA,4JAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,iBAAA,CAAkB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAsC;AACrF,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,yCAAA;AAAA,QACA,+FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"dialog.js","sourcesContent":["'use client'\n\nimport { Dialog as DialogPrimitive } from '@base-ui/react/dialog'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport { IconClose } from '../icons/close.js'\nimport { overlayInk, overlayScrim } from '../lib/overlay.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Dialog({ ...props }: DialogPrimitive.Root.Props) {\n return <DialogPrimitive.Root data-slot='dialog' {...props} />\n}\n\nfunction DialogTrigger({ ...props }: DialogPrimitive.Trigger.Props) {\n return <DialogPrimitive.Trigger data-slot='dialog-trigger' {...props} />\n}\n\nfunction DialogClose({ ...props }: DialogPrimitive.Close.Props) {\n return <DialogPrimitive.Close data-slot='dialog-close' {...props} />\n}\n\nfunction DialogPortal({ children, ...props }: DialogPrimitive.Portal.Props) {\n return (\n <DialogPrimitive.Portal data-slot='dialog-portal' {...props}>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>{children}</PortalBoundary>\n </DialogPrimitive.Portal>\n )\n}\n\n/**\n * The three approved looks (design-shotgun, overlays-20260923):\n *\n * - `default` (Hairline): a flat raised surface drawn with a 1px ring; the\n * header and footer bleed to the edges and are divided off by hairlines.\n * - `band`: the header is a solid band in the action colour with an inverse\n * title; the footer sits on a subtle band.\n * - `rule`: a 4px rule in the ink colour caps the top edge, the title sits on\n * a hairline in the text colour, and the actions align to the start.\n *\n * None casts a shadow and none blurs the page behind — depth is drawn, per\n * DESIGN.md's Hairline Rule. Parts read the variant from `data-variant` on\n * the popup through `group-data-*`, so there is no context to thread.\n */\ntype DialogVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes and its look. The parts (header, footer, title,\n * description, close button) read the look from `data-variant` through\n * `group-data-*` instead: cva sees only its own props, not an ancestor's.\n * Radius sits in every branch, not the base, so rule's square top never\n * competes with a base `rounded-md` at equal specificity.\n */\nconst dialogContentVariants = cva(\n // `w-[calc(100%-2rem)]` + `max-w-lg` rather than shadcn's\n // `max-w-[calc(100%-2rem)] sm:max-w-sm`: two different properties, so there\n // is no bare/responsive pair for a consumer's build to reorder (see\n // check:cascade).\n 'group/dialog-content fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-6 overflow-y-auto bg-popover p-6 text-base/relaxed text-popover-foreground ring-1 ring-foreground/10 outline-hidden transition-[opacity,scale] duration-150 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0',\n {\n variants: {\n variant: {\n default: 'rounded-md',\n band: 'rounded-md',\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--overlay-ink)',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n)\n\nfunction DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props) {\n return (\n <DialogPrimitive.Backdrop\n data-slot='dialog-overlay'\n className={cn(\n 'fixed inset-0 z-50 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogContent({\n className,\n children,\n variant = 'default',\n showCloseButton = true,\n closeLabel = 'Close',\n ...props\n}: DialogPrimitive.Popup.Props & {\n variant?: DialogVariant\n showCloseButton?: boolean\n /**\n * Screen-reader name for the close button. Override to translate it — the\n * button is icon-only, so this string is the only name AT ever hears.\n */\n closeLabel?: string\n}) {\n return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Popup\n data-slot='dialog-content'\n data-variant={variant}\n className={cn(\n dialogContentVariants({ variant }),\n // The ink rule's cap is drawn in (see overlayInk).\n overlayInk,\n // The header rules below match it at any depth, not only as a direct\n // child: an edit dialog usually wraps its content in a <form>.\n // A header with nothing below it draws no divider over empty space.\n '[&_[data-slot=dialog-header]:last-child]:border-b-0',\n // Keep a long title clear of the absolutely-positioned close button:\n // 72px where the header bleeds to the edge (24px gutter + the 48px\n // the button needs), 48px under `rule`, whose header does not bleed.\n '[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-18 data-[variant=rule]:[&:has(>[data-slot=dialog-close])_[data-slot=dialog-header]]:pe-12',\n // With no header at all, the first content after the close button\n // reserves the button's 48px instead, so its text cannot run under it.\n '[&>[data-slot=dialog-close]+:not([data-slot=dialog-header]):not(:has([data-slot=dialog-header]))]:pe-12',\n className,\n )}\n {...props}\n >\n {/* The close button comes FIRST in the DOM (it is absolutely placed, so\n the visual order is unchanged). Base UI focuses the first tabbable\n element on open; after the content, that is a footer button, and a\n long dialog opens scrolled to the bottom with the reader past\n everything above it. */}\n {showCloseButton && (\n <DialogPrimitive.Close\n data-slot='dialog-close'\n render={\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n className={cn(\n // z-20, as Sheet's: the button comes first in the DOM, and\n // equal z-indexes paint in DOM order, so any later positioned\n // child in the corner (a Button is `relative`) would paint\n // over it and take its clicks. z-20 clears children up to and\n // including the conventional sticky-header z-10.\n 'absolute end-4 top-4 z-20',\n // On the band the button takes the band's inverse ink — only\n // when a header is there to paint the band. The extra\n // data-slot keeps this above Button's own dark ink at any\n // emission order.\n 'group-data-[variant=band]/dialog-content:group-has-[[data-slot=dialog-header]]/dialog-content:data-[slot=dialog-close]:[--btn-bg:var(--text-inverse)]',\n )}\n />\n }\n >\n <IconClose />\n </DialogPrimitive.Close>\n )}\n {children}\n </DialogPrimitive.Popup>\n </DialogPortal>\n )\n}\n\nfunction DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='dialog-header'\n className={cn(\n // default: bleeds to the popup's edges and is divided off by a hairline.\n '-mx-6 -mt-6 flex flex-col gap-2 border-b border-border px-6 pt-6 pb-5',\n // band: the same bleed, painted as a solid band instead of divided.\n 'group-data-[variant=band]/dialog-content:border-b-0 group-data-[variant=band]/dialog-content:bg-primary group-data-[variant=band]/dialog-content:pb-6 group-data-[variant=band]/dialog-content:text-primary-foreground',\n // rule: no bleed — the title carries its own hairline instead.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mt-0 group-data-[variant=rule]/dialog-content:border-b-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:pt-0 group-data-[variant=rule]/dialog-content:pb-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogFooter({\n className,\n showCloseButton = false,\n closeLabel = 'Close',\n children,\n ...props\n}: React.ComponentProps<'div'> & {\n /** Appends an outline Close button after the footer's own actions. */\n showCloseButton?: boolean\n /** Visible label of that Close button. Override to translate it. */\n closeLabel?: string\n}) {\n return (\n <div\n data-slot='dialog-footer'\n className={cn(\n // Stacked with the primary action on top below `sm`, a row aligned to\n // the end from `sm` up. `max-sm:` rather than a bare `flex-col-reverse`\n // keeps the pair cascade-safe (see check:cascade).\n 'flex gap-2 max-sm:flex-col-reverse sm:flex-row sm:justify-end',\n // default: bleeds to the popup's edges above a hairline.\n '-mx-6 -mb-6 border-t border-border px-6 py-4',\n // band: the same bleed on a subtle band instead of a hairline.\n 'group-data-[variant=band]/dialog-content:border-t-0 group-data-[variant=band]/dialog-content:bg-muted',\n // rule: no bleed, actions aligned to the start.\n 'group-data-[variant=rule]/dialog-content:mx-0 group-data-[variant=rule]/dialog-content:mb-0 group-data-[variant=rule]/dialog-content:border-t-0 group-data-[variant=rule]/dialog-content:px-0 group-data-[variant=rule]/dialog-content:py-0 group-data-[variant=rule]/dialog-content:sm:justify-start',\n className,\n )}\n {...props}\n >\n {children}\n {showCloseButton && (\n <DialogPrimitive.Close render={<Button variant='outline' />}>\n {closeLabel}\n </DialogPrimitive.Close>\n )}\n </div>\n )\n}\n\nfunction DialogTitle({ className, ...props }: DialogPrimitive.Title.Props) {\n return (\n <DialogPrimitive.Title\n data-slot='dialog-title'\n className={cn(\n 'font-heading text-2xl font-medium text-foreground',\n // Inverse ink only inside the band — a title placed in the body stays\n // on the popover and must keep the default ink.\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n 'group-data-[variant=rule]/dialog-content:border-b group-data-[variant=rule]/dialog-content:border-foreground group-data-[variant=rule]/dialog-content:pb-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DialogDescription({ className, ...props }: DialogPrimitive.Description.Props) {\n return (\n <DialogPrimitive.Description\n data-slot='dialog-description'\n className={cn(\n 'text-base/relaxed text-muted-foreground',\n 'group-data-[variant=band]/dialog-content:in-data-[slot=dialog-header]:text-primary-foreground',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n dialogContentVariants,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n}\nexport type { DialogVariant }\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { Drawer as Drawer$1 } from 'vaul';
|
|
4
|
-
import { ButtonGroupBoundary } from '../lib/button-group-context.js';
|
|
5
4
|
import { overlayScrim } from '../lib/overlay.js';
|
|
5
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
6
6
|
import { cn } from '../lib/utils.js';
|
|
7
7
|
|
|
8
8
|
function Drawer({ ...props }) {
|
|
@@ -12,7 +12,7 @@ function DrawerTrigger({ ...props }) {
|
|
|
12
12
|
return /* @__PURE__ */ jsx(Drawer$1.Trigger, { "data-slot": "drawer-trigger", ...props });
|
|
13
13
|
}
|
|
14
14
|
function DrawerPortal({ children, ...props }) {
|
|
15
|
-
return /* @__PURE__ */ jsx(Drawer$1.Portal, { "data-slot": "drawer-portal", ...props, children: /* @__PURE__ */ jsx(
|
|
15
|
+
return /* @__PURE__ */ jsx(Drawer$1.Portal, { "data-slot": "drawer-portal", ...props, children: /* @__PURE__ */ jsx(PortalBoundary, { children }) });
|
|
16
16
|
}
|
|
17
17
|
function DrawerClose({ ...props }) {
|
|
18
18
|
return /* @__PURE__ */ jsx(Drawer$1.Close, { "data-slot": "drawer-close", ...props });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/drawer.tsx"],"names":["DrawerPrimitive"],"mappings":";;;;;;A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;AAEJ;AAEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AAC1E,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,iCAAA,EAAmC,SAAS,CAAA;AAAA,MACzD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAuD;AAChG,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,qCAAA,EAAuC,SAAS,CAAA;AAAA,MAC7D,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,iBAAA,CAAkB;AAAA,EACzB,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA6D;AAC3D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,WAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,oBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,uCAAA,EAAyC,SAAS,CAAA;AAAA,MAC/D,GAAG;AAAA;AAAA,GACN;AAEJ","file":"drawer.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Drawer as DrawerPrimitive } from 'vaul'\n\nimport { overlayScrim } from '../lib/overlay.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Drawer({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Root>) {\n return <DrawerPrimitive.Root data-slot='drawer' {...props} />\n}\n\nfunction DrawerTrigger({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Trigger>) {\n return <DrawerPrimitive.Trigger data-slot='drawer-trigger' {...props} />\n}\n\nfunction DrawerPortal({ children, ...props }: React.ComponentProps<typeof DrawerPrimitive.Portal>) {\n return (\n <DrawerPrimitive.Portal data-slot='drawer-portal' {...props}>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>{children}</PortalBoundary>\n </DrawerPrimitive.Portal>\n )\n}\n\nfunction DrawerClose({ ...props }: React.ComponentProps<typeof DrawerPrimitive.Close>) {\n return <DrawerPrimitive.Close data-slot='drawer-close' {...props} />\n}\n\nfunction DrawerOverlay({\n className,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Overlay>) {\n return (\n <DrawerPrimitive.Overlay\n data-slot='drawer-overlay'\n className={cn(\n 'fixed inset-0 z-50 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0',\n overlayScrim,\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DrawerContent({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Content>) {\n return (\n <DrawerPortal data-slot='drawer-portal'>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n data-slot='drawer-content'\n className={cn(\n 'group/drawer-content fixed z-50 flex h-auto flex-col bg-transparent p-2 text-xs/relaxed text-popover-foreground before:absolute before:inset-2 before:-z-10 before:rounded-md before:border before:border-border before:bg-popover data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:start-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:end-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm',\n className,\n )}\n {...props}\n >\n <div className='mx-auto mt-4 hidden h-1.5 w-[100px] shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block' />\n {children}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n )\n}\n\nfunction DrawerHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='drawer-header'\n className={cn(\n 'flex flex-col gap-1 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:text-start',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction DrawerFooter({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='drawer-footer'\n className={cn('mt-auto flex flex-col gap-2 p-4', className)}\n {...props}\n />\n )\n}\n\nfunction DrawerTitle({ className, ...props }: React.ComponentProps<typeof DrawerPrimitive.Title>) {\n return (\n <DrawerPrimitive.Title\n data-slot='drawer-title'\n className={cn('text-sm font-medium text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction DrawerDescription({\n className,\n ...props\n}: React.ComponentProps<typeof DrawerPrimitive.Description>) {\n return (\n <DrawerPrimitive.Description\n data-slot='drawer-description'\n className={cn('text-xs/relaxed text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport {\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerOverlay,\n DrawerPortal,\n DrawerTitle,\n DrawerTrigger,\n}\n"]}
|
|
@@ -7,8 +7,8 @@ import { cva } from 'class-variance-authority';
|
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import { IconCheck } from '../icons/check.js';
|
|
9
9
|
import { IconChevronRight } from '../icons/chevron-right.js';
|
|
10
|
-
import { ButtonGroupBoundary } from '../lib/button-group-context.js';
|
|
11
10
|
import { overlayInk, overlayDanger } from '../lib/overlay.js';
|
|
11
|
+
import { PortalBoundary } from '../lib/portal-boundary.js';
|
|
12
12
|
import { cn } from '../lib/utils.js';
|
|
13
13
|
|
|
14
14
|
const dropdownMenuContentVariants = cva(
|
|
@@ -41,7 +41,7 @@ function DropdownMenu({ ...props }) {
|
|
|
41
41
|
return /* @__PURE__ */ jsx(Menu.Root, { "data-slot": "dropdown-menu", ...props });
|
|
42
42
|
}
|
|
43
43
|
function DropdownMenuPortal({ children, ...props }) {
|
|
44
|
-
return /* @__PURE__ */ jsx(Menu.Portal, { "data-slot": "dropdown-menu-portal", ...props, children: /* @__PURE__ */ jsx(
|
|
44
|
+
return /* @__PURE__ */ jsx(Menu.Portal, { "data-slot": "dropdown-menu-portal", ...props, children: /* @__PURE__ */ jsx(PortalBoundary, { children }) });
|
|
45
45
|
}
|
|
46
46
|
function DropdownMenuTrigger({ ...props }) {
|
|
47
47
|
return /* @__PURE__ */ jsx(Menu.Trigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/dropdown-menu.tsx"],"names":["MenuPrimitive"],"mappings":";;;;;;;;;;;;AAsCA,MAAM,2BAAA,GAA8B,GAAA;AAAA,EAClC,krBAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,OAAA,EAAS,gBAAA;AAAA,QACT,IAAA,EAAM,gBAAA;AAAA;AAAA,QAEN,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,SAAA;AAAU;AAE1C;AAGA,MAAM,0BAAA,GAA6B,KAAA,CAAM,aAAA,CAAmC,SAAS,CAAA;AAcrF,MAAM,WAAA,GAAc;AAAA,EAClB,ucAAA;AAAA;AAAA;AAAA,EAGA,gTAAA;AAAA;AAAA;AAAA;AAAA,EAIA;AACF,CAAA,CAAE,KAAK,GAAG,CAAA;AAOV,MAAM,wBAAA,GAA2B,KAAA,CAAM,aAAA,CAAc,KAAK,CAAA;AAE1D,SAAS,YAAA,CAAa,EAAE,GAAG,KAAA,EAAM,EAA6B;AAC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,wBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,qEAAA;AAAA,YACV,WAAA,EAAU,oCAAA;AAAA,YAEV,8BAACA,IAAA,CAAc,kBAAA,EAAd,EACC,QAAA,kBAAA,GAAA,CAAC,aAAU,CAAA,EACb;AAAA;AAAA,SACF;AAAA,QACC;AAAA;AAAA;AAAA,GACH;AAEJ;AAEA,SAAS,qBAAA,CAAsB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AACrF,EAAA,uBACE,GAAA;AAAA,IAACA,IAAA,CAAc,SAAA;AAAA,IAAd;AAAA,MACC,WAAA,EAAU,yBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,0LAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAGA,SAAS,oBAAA,CAAqB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAiC;AACnF,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,8DAAA;AAAA;AAAA,QAEA,wGAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"dropdown-menu.js","sourcesContent":["'use client'\n\nimport { Menu as MenuPrimitive } from '@base-ui/react/menu'\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { overlayDanger, overlayInk } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * The three approved looks (design-shotgun, overlays-20260923), set on\n * `DropdownMenuContent` and read by every part through `group-data-*`:\n *\n * - `default` (Hairline): a flat surface drawn with a 1px ring. The\n * highlighted row takes an ink tint, and keyboard focus adds a 2px inset\n * ring — a tint alone is ~1.1:1 against the menu and is no focus cue.\n * - `band`: the highlighted row is a solid band in the action colour, the\n * group label sits on a subtle band, and rows run edge to edge.\n * - `rule`: a 4px ink rule caps the top edge and a 4px rail on the start edge\n * marks the highlighted row, like SideNav's current-page rail.\n *\n * No shadow — depth is drawn (DESIGN.md, The Hairline Rule).\n */\ntype DropdownMenuVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes and its look; the rows and labels read the look from\n * `data-variant` through `group-data-*`, since cva sees only its own props.\n * Radius and padding sit in every branch, not the base, so no branch competes\n * with a base value at equal specificity. The base is at least as wide as the\n * trigger and never narrower than 12rem — shadcn pins the menu to the\n * trigger's width, which squeezes a menu opened from an icon button to a sliver.\n */\nconst dropdownMenuContentVariants = cva(\n 'group/dropdown-menu-content z-50 max-h-(--available-height) w-max max-w-(--available-width) min-w-[max(var(--anchor-width),12rem)] origin-(--transform-origin) overflow-x-hidden overflow-y-auto bg-popover 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:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',\n {\n variants: {\n variant: {\n default: 'rounded-md p-1',\n band: 'rounded-md p-0',\n // rule: the rows run edge to edge under a 4px ink cap.\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--overlay-ink) pb-1',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n)\n\n/** Lets a submenu default to the variant of the menu it opens from. */\nconst DropdownMenuVariantContext = React.createContext<DropdownMenuVariant>('default')\n\n/**\n * Row geometry shared by every item kind, matching `SelectItem`: 44px minimum\n * target (WCAG 2.2 2.5.8 with room to spare), 16px text, `rounded-sm`. The\n * highlight keys on Base UI's `data-highlighted`, which tracks both pointer\n * hover and keyboard focus; the focus ring keys on `:focus-visible`, which\n * only the keyboard sets. `data-inset` lines an icon-less item up with\n * siblings that lead with a 16px icon (16px padding + 16px icon + 8px gap).\n *\n * The ring states `outline-solid` explicitly: `outline-hidden` sets\n * `--tw-outline-style: none`, which `outline-2` reads, so without it the\n * ring takes its width and colour and still never paints.\n */\nconst itemClasses = [\n \"group/dropdown-menu-item relative flex min-h-11 w-full cursor-default items-center gap-2 rounded-sm ps-4 pe-4 py-2 text-base outline-hidden select-none data-highlighted:bg-foreground/8 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:ps-10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n // band: edge-to-edge rows; the highlight is a solid action-colour band,\n // strong enough to be the focus cue on its own, so the ring stands down.\n 'group-data-[variant=band]/dropdown-menu-content:rounded-none group-data-[variant=band]/dropdown-menu-content:data-highlighted:bg-primary group-data-[variant=band]/dropdown-menu-content:data-highlighted:text-primary-foreground group-data-[variant=band]/dropdown-menu-content:focus-visible:outline-hidden',\n // rule: a 4px start-edge rail in the ink marks the highlight, and is the\n // focus cue too, so the ring stands down. 12px + the 4px rail keeps text on\n // the same 16px line as the other looks.\n 'group-data-[variant=rule]/dropdown-menu-content:rounded-none group-data-[variant=rule]/dropdown-menu-content:border-s-4 group-data-[variant=rule]/dropdown-menu-content:border-transparent group-data-[variant=rule]/dropdown-menu-content:ps-3 group-data-[variant=rule]/dropdown-menu-content:data-inset:ps-9 group-data-[variant=rule]/dropdown-menu-content:data-highlighted:border-s-(--overlay-ink) group-data-[variant=rule]/dropdown-menu-content:data-highlighted:bg-(--overlay-ink)/8 group-data-[variant=rule]/dropdown-menu-content:focus-visible:outline-hidden',\n].join(' ')\n\n/**\n * True inside a `DropdownMenuGroup` or `DropdownMenuRadioGroup`. Base UI's\n * group label THROWS when no group encloses it — on first open, not at render\n * — so `DropdownMenuLabel` reads this to supply a group of its own instead.\n */\nconst DropdownMenuGroupContext = React.createContext(false)\n\nfunction DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {\n return <MenuPrimitive.Root data-slot='dropdown-menu' {...props} />\n}\n\nfunction DropdownMenuPortal({ children, ...props }: MenuPrimitive.Portal.Props) {\n return (\n <MenuPrimitive.Portal data-slot='dropdown-menu-portal' {...props}>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>{children}</ButtonGroupBoundary>\n </MenuPrimitive.Portal>\n )\n}\n\nfunction DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {\n return <MenuPrimitive.Trigger data-slot='dropdown-menu-trigger' {...props} />\n}\n\nfunction DropdownMenuContent({\n align = 'start',\n alignOffset = 0,\n side = 'bottom',\n sideOffset = 4,\n variant = 'default',\n className,\n children,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> & {\n variant?: DropdownMenuVariant\n }) {\n return (\n <DropdownMenuPortal>\n <MenuPrimitive.Positioner\n className='isolate z-50 outline-hidden'\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <MenuPrimitive.Popup\n data-slot='dropdown-menu-content'\n data-variant={variant}\n className={cn(\n dropdownMenuContentVariants({ variant }),\n // The ink `rule` paints its cap and rail with (see overlayInk).\n overlayInk,\n // The fill and text of band's destructive row (see overlayDanger).\n overlayDanger,\n className,\n )}\n {...props}\n >\n <DropdownMenuVariantContext.Provider value={variant}>\n {children}\n </DropdownMenuVariantContext.Provider>\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </DropdownMenuPortal>\n )\n}\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return (\n <DropdownMenuGroupContext.Provider value>\n <MenuPrimitive.Group data-slot='dropdown-menu-group' {...props} />\n </DropdownMenuGroupContext.Provider>\n )\n}\n\n/**\n * A label outside any group, as plain text. Base UI's group label throws with\n * no group around it, and wrapping it in a group of its own would label an\n * empty group — so it renders as a styled element with no group semantics.\n */\nfunction DropdownMenuPlainLabel({\n className,\n style,\n render,\n ...props\n}: MenuPrimitive.GroupLabel.Props) {\n return useRender({\n defaultTagName: 'div',\n render,\n props: mergeProps<'div'>(\n {\n className: typeof className === 'function' ? className({}) : className,\n style: typeof style === 'function' ? style({}) : style,\n },\n props,\n ),\n })\n}\n\n/**\n * A heading for a `DropdownMenuGroup`, which it names for assistive tech.\n * Only a label inside a group can do that: outside one — the shadcn/Radix\n * habit of dropping a label straight into the content — it renders as plain\n * visible text, naming nothing. Wrap labelled actions in `DropdownMenuGroup`\n * when the label should name them.\n */\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: MenuPrimitive.GroupLabel.Props & {\n inset?: boolean\n}) {\n const inGroup = React.useContext(DropdownMenuGroupContext)\n const labelProps = {\n 'data-slot': 'dropdown-menu-label',\n 'data-inset': inset || undefined,\n className: cn(\n 'px-4 py-2 text-base font-semibold text-muted-foreground data-inset:ps-10',\n 'group-data-[variant=band]/dropdown-menu-content:bg-muted group-data-[variant=band]/dropdown-menu-content:py-2.5',\n // rule: the label sits on a hairline in the text colour; mx-4 + ps-6\n // puts an inset label's text on the inset items' 40px line.\n 'group-data-[variant=rule]/dropdown-menu-content:mx-4 group-data-[variant=rule]/dropdown-menu-content:mb-1 group-data-[variant=rule]/dropdown-menu-content:border-b group-data-[variant=rule]/dropdown-menu-content:border-foreground group-data-[variant=rule]/dropdown-menu-content:px-0 group-data-[variant=rule]/dropdown-menu-content:text-foreground group-data-[variant=rule]/dropdown-menu-content:data-inset:ps-6',\n typeof className === 'function' ? className({}) : className,\n ),\n ...props,\n }\n return inGroup ? (\n <MenuPrimitive.GroupLabel {...labelProps} />\n ) : (\n <DropdownMenuPlainLabel {...labelProps} />\n )\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = 'default',\n ...props\n}: MenuPrimitive.Item.Props & {\n inset?: boolean\n /**\n * `destructive` inks the item with the danger role tokens, which carry\n * their own dark values — so it needs no `dark:` variant.\n */\n variant?: 'default' | 'destructive'\n}) {\n return (\n <MenuPrimitive.Item\n data-slot='dropdown-menu-item'\n data-inset={inset || undefined}\n data-variant={variant}\n className={cn(\n itemClasses,\n 'data-[variant=destructive]:text-(--danger-text) data-[variant=destructive]:data-highlighted:bg-(--danger-surface) data-[variant=destructive]:data-highlighted:text-(--danger-text)',\n // A destructive row keeps the danger colour under each look. These\n // carry one more attribute than the look's own highlight, so they win\n // at any emission order.\n 'group-data-[variant=band]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:bg-(--overlay-danger) group-data-[variant=band]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:text-(--overlay-danger-text)',\n 'group-data-[variant=rule]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:border-s-destructive group-data-[variant=rule]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:bg-(--danger-surface)',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * An item that navigates. Renders a real `<a>`, so the browser's own link\n * behaviour (middle-click, open in new tab, status-bar URL) is kept — use it\n * instead of an `onClick` that sets `location`.\n *\n * `closeOnClick` defaults to `true` here, where Base UI's own default is\n * `false`: with client-side routing (`render={<Link />}`) the page never\n * reloads, so a menu that stayed open would sit over the new route.\n */\nfunction DropdownMenuLinkItem({\n className,\n inset,\n closeOnClick = true,\n ...props\n}: MenuPrimitive.LinkItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.LinkItem\n data-slot='dropdown-menu-link-item'\n data-inset={inset || undefined}\n closeOnClick={closeOnClick}\n className={cn(itemClasses, className)}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {\n return <MenuPrimitive.SubmenuRoot data-slot='dropdown-menu-sub' {...props} />\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: MenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.SubmenuTrigger\n data-slot='dropdown-menu-sub-trigger'\n data-inset={inset || undefined}\n className={cn(\n itemClasses,\n // The row whose submenu is open stays marked, in each look's highlight.\n 'data-popup-open:bg-foreground/8 group-data-[variant=band]/dropdown-menu-content:data-popup-open:bg-primary group-data-[variant=band]/dropdown-menu-content:data-popup-open:text-primary-foreground group-data-[variant=rule]/dropdown-menu-content:data-popup-open:border-s-(--overlay-ink) group-data-[variant=rule]/dropdown-menu-content:data-popup-open:bg-(--overlay-ink)/8',\n className,\n )}\n {...props}\n >\n {children}\n <IconChevronRight className='ms-auto rtl:rotate-180' />\n </MenuPrimitive.SubmenuTrigger>\n )\n}\n\n/**\n * A submenu's popup. It portals out of its parent menu, so it cannot read the\n * parent's `data-variant` from the DOM; `variant` defaults to the parent's\n * through context instead.\n */\nfunction DropdownMenuSubContent({\n align = 'start',\n alignOffset,\n side = 'inline-end',\n sideOffset = 0,\n variant,\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuContent>) {\n const parentVariant = React.useContext(DropdownMenuVariantContext)\n const resolved = variant ?? parentVariant\n return (\n <DropdownMenuContent\n data-slot='dropdown-menu-sub-content'\n variant={resolved}\n className={cn('min-w-48', className)}\n align={align}\n // Line the submenu's first row up with its trigger row: the submenu's\n // own first row sits 4px below its top edge (its p-1, or rule's 4px\n // cap), except under band, whose rows start flush.\n alignOffset={alignOffset ?? (resolved === 'band' ? 0 : -4)}\n side={side}\n sideOffset={sideOffset}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.CheckboxItem\n data-slot='dropdown-menu-checkbox-item'\n data-inset={inset || undefined}\n className={cn(itemClasses, 'pe-10', className)}\n {...props}\n >\n <span\n className='pointer-events-none absolute end-3 flex items-center justify-center'\n data-slot='dropdown-menu-checkbox-item-indicator'\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <IconCheck />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </MenuPrimitive.CheckboxItem>\n )\n}\n\nfunction DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {\n return (\n <DropdownMenuGroupContext.Provider value>\n <MenuPrimitive.RadioGroup data-slot='dropdown-menu-radio-group' {...props} />\n </DropdownMenuGroupContext.Provider>\n )\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.RadioItem\n data-slot='dropdown-menu-radio-item'\n data-inset={inset || undefined}\n className={cn(itemClasses, 'pe-10', className)}\n {...props}\n >\n <span\n className='pointer-events-none absolute end-3 flex items-center justify-center'\n data-slot='dropdown-menu-radio-item-indicator'\n >\n <MenuPrimitive.RadioItemIndicator>\n <IconCheck />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </MenuPrimitive.RadioItem>\n )\n}\n\nfunction DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot='dropdown-menu-separator'\n className={cn(\n '-mx-1 my-1 h-px bg-border group-data-[variant=band]/dropdown-menu-content:mx-0 group-data-[variant=band]/dropdown-menu-content:my-0 group-data-[variant=rule]/dropdown-menu-content:mx-4',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** A trailing hint such as a keyboard shortcut. Decorative — it binds nothing. */\nfunction DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='dropdown-menu-shortcut'\n className={cn(\n 'ms-auto ps-4 text-base tracking-widest text-muted-foreground',\n // On band's solid highlight, muted ink would sit on the action colour.\n 'group-data-[variant=band]/dropdown-menu-content:group-data-highlighted/dropdown-menu-item:text-current',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n dropdownMenuContentVariants,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuLinkItem,\n DropdownMenuPortal,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n}\nexport type { DropdownMenuVariant }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/dropdown-menu.tsx"],"names":["MenuPrimitive"],"mappings":";;;;;;;;;;;;AAsCA,MAAM,2BAAA,GAA8B,GAAA;AAAA,EAClC,krBAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,OAAA,EAAS,gBAAA;AAAA,QACT,IAAA,EAAM,gBAAA;AAAA;AAAA,QAEN,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,SAAA;AAAU;AAE1C;AAGA,MAAM,0BAAA,GAA6B,KAAA,CAAM,aAAA,CAAmC,SAAS,CAAA;AAcrF,MAAM,WAAA,GAAc;AAAA,EAClB,ucAAA;AAAA;AAAA;AAAA,EAGA,gTAAA;AAAA;AAAA;AAAA;AAAA,EAIA;AACF,CAAA,CAAE,KAAK,GAAG,CAAA;AAOV,MAAM,wBAAA,GAA2B,KAAA,CAAM,aAAA,CAAc,KAAK,CAAA;AAE1D,SAAS,YAAA,CAAa,EAAE,GAAG,KAAA,EAAM,EAA6B;AAC5D,EAAA,2BAAQA,IAAA,CAAc,IAAA,EAAd,EAAmB,WAAA,EAAU,eAAA,EAAiB,GAAG,KAAA,EAAO,CAAA;AAClE;AAEA,SAAS,kBAAA,CAAmB,EAAE,QAAA,EA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Ad,EACC,QAAA,kBAAA,GAAA,CAAC,aAAU,CAAA,EACb;AAAA;AAAA,SACF;AAAA,QACC;AAAA;AAAA;AAAA,GACH;AAEJ;AAEA,SAAS,qBAAA,CAAsB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AACrF,EAAA,uBACE,GAAA;AAAA,IAACA,IAAA,CAAc,SAAA;AAAA,IAAd;AAAA,MACC,WAAA,EAAU,yBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,0LAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAGA,SAAS,oBAAA,CAAqB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAiC;AACnF,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,8DAAA;AAAA;AAAA,QAEA,wGAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"dropdown-menu.js","sourcesContent":["'use client'\n\nimport { Menu as MenuPrimitive } from '@base-ui/react/menu'\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { overlayDanger, overlayInk } from '../lib/overlay.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * The three approved looks (design-shotgun, overlays-20260923), set on\n * `DropdownMenuContent` and read by every part through `group-data-*`:\n *\n * - `default` (Hairline): a flat surface drawn with a 1px ring. The\n * highlighted row takes an ink tint, and keyboard focus adds a 2px inset\n * ring — a tint alone is ~1.1:1 against the menu and is no focus cue.\n * - `band`: the highlighted row is a solid band in the action colour, the\n * group label sits on a subtle band, and rows run edge to edge.\n * - `rule`: a 4px ink rule caps the top edge and a 4px rail on the start edge\n * marks the highlighted row, like SideNav's current-page rail.\n *\n * No shadow — depth is drawn (DESIGN.md, The Hairline Rule).\n */\ntype DropdownMenuVariant = 'default' | 'band' | 'rule'\n\n/**\n * The popup's own classes and its look; the rows and labels read the look from\n * `data-variant` through `group-data-*`, since cva sees only its own props.\n * Radius and padding sit in every branch, not the base, so no branch competes\n * with a base value at equal specificity. The base is at least as wide as the\n * trigger and never narrower than 12rem — shadcn pins the menu to the\n * trigger's width, which squeezes a menu opened from an icon button to a sliver.\n */\nconst dropdownMenuContentVariants = cva(\n 'group/dropdown-menu-content z-50 max-h-(--available-height) w-max max-w-(--available-width) min-w-[max(var(--anchor-width),12rem)] origin-(--transform-origin) overflow-x-hidden overflow-y-auto bg-popover 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:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',\n {\n variants: {\n variant: {\n default: 'rounded-md p-1',\n band: 'rounded-md p-0',\n // rule: the rows run edge to edge under a 4px ink cap.\n rule: 'rounded-t-sm rounded-b-md border-t-4 border-t-(--overlay-ink) pb-1',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n)\n\n/** Lets a submenu default to the variant of the menu it opens from. */\nconst DropdownMenuVariantContext = React.createContext<DropdownMenuVariant>('default')\n\n/**\n * Row geometry shared by every item kind, matching `SelectItem`: 44px minimum\n * target (WCAG 2.2 2.5.8 with room to spare), 16px text, `rounded-sm`. The\n * highlight keys on Base UI's `data-highlighted`, which tracks both pointer\n * hover and keyboard focus; the focus ring keys on `:focus-visible`, which\n * only the keyboard sets. `data-inset` lines an icon-less item up with\n * siblings that lead with a 16px icon (16px padding + 16px icon + 8px gap).\n *\n * The ring states `outline-solid` explicitly: `outline-hidden` sets\n * `--tw-outline-style: none`, which `outline-2` reads, so without it the\n * ring takes its width and colour and still never paints.\n */\nconst itemClasses = [\n \"group/dropdown-menu-item relative flex min-h-11 w-full cursor-default items-center gap-2 rounded-sm ps-4 pe-4 py-2 text-base outline-hidden select-none data-highlighted:bg-foreground/8 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid data-disabled:pointer-events-none data-disabled:opacity-50 data-inset:ps-10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n // band: edge-to-edge rows; the highlight is a solid action-colour band,\n // strong enough to be the focus cue on its own, so the ring stands down.\n 'group-data-[variant=band]/dropdown-menu-content:rounded-none group-data-[variant=band]/dropdown-menu-content:data-highlighted:bg-primary group-data-[variant=band]/dropdown-menu-content:data-highlighted:text-primary-foreground group-data-[variant=band]/dropdown-menu-content:focus-visible:outline-hidden',\n // rule: a 4px start-edge rail in the ink marks the highlight, and is the\n // focus cue too, so the ring stands down. 12px + the 4px rail keeps text on\n // the same 16px line as the other looks.\n 'group-data-[variant=rule]/dropdown-menu-content:rounded-none group-data-[variant=rule]/dropdown-menu-content:border-s-4 group-data-[variant=rule]/dropdown-menu-content:border-transparent group-data-[variant=rule]/dropdown-menu-content:ps-3 group-data-[variant=rule]/dropdown-menu-content:data-inset:ps-9 group-data-[variant=rule]/dropdown-menu-content:data-highlighted:border-s-(--overlay-ink) group-data-[variant=rule]/dropdown-menu-content:data-highlighted:bg-(--overlay-ink)/8 group-data-[variant=rule]/dropdown-menu-content:focus-visible:outline-hidden',\n].join(' ')\n\n/**\n * True inside a `DropdownMenuGroup` or `DropdownMenuRadioGroup`. Base UI's\n * group label THROWS when no group encloses it — on first open, not at render\n * — so `DropdownMenuLabel` reads this to supply a group of its own instead.\n */\nconst DropdownMenuGroupContext = React.createContext(false)\n\nfunction DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {\n return <MenuPrimitive.Root data-slot='dropdown-menu' {...props} />\n}\n\nfunction DropdownMenuPortal({ children, ...props }: MenuPrimitive.Portal.Props) {\n return (\n <MenuPrimitive.Portal data-slot='dropdown-menu-portal' {...props}>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>{children}</PortalBoundary>\n </MenuPrimitive.Portal>\n )\n}\n\nfunction DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {\n return <MenuPrimitive.Trigger data-slot='dropdown-menu-trigger' {...props} />\n}\n\nfunction DropdownMenuContent({\n align = 'start',\n alignOffset = 0,\n side = 'bottom',\n sideOffset = 4,\n variant = 'default',\n className,\n children,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> & {\n variant?: DropdownMenuVariant\n }) {\n return (\n <DropdownMenuPortal>\n <MenuPrimitive.Positioner\n className='isolate z-50 outline-hidden'\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <MenuPrimitive.Popup\n data-slot='dropdown-menu-content'\n data-variant={variant}\n className={cn(\n dropdownMenuContentVariants({ variant }),\n // The ink `rule` paints its cap and rail with (see overlayInk).\n overlayInk,\n // The fill and text of band's destructive row (see overlayDanger).\n overlayDanger,\n className,\n )}\n {...props}\n >\n <DropdownMenuVariantContext.Provider value={variant}>\n {children}\n </DropdownMenuVariantContext.Provider>\n </MenuPrimitive.Popup>\n </MenuPrimitive.Positioner>\n </DropdownMenuPortal>\n )\n}\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return (\n <DropdownMenuGroupContext.Provider value>\n <MenuPrimitive.Group data-slot='dropdown-menu-group' {...props} />\n </DropdownMenuGroupContext.Provider>\n )\n}\n\n/**\n * A label outside any group, as plain text. Base UI's group label throws with\n * no group around it, and wrapping it in a group of its own would label an\n * empty group — so it renders as a styled element with no group semantics.\n */\nfunction DropdownMenuPlainLabel({\n className,\n style,\n render,\n ...props\n}: MenuPrimitive.GroupLabel.Props) {\n return useRender({\n defaultTagName: 'div',\n render,\n props: mergeProps<'div'>(\n {\n className: typeof className === 'function' ? className({}) : className,\n style: typeof style === 'function' ? style({}) : style,\n },\n props,\n ),\n })\n}\n\n/**\n * A heading for a `DropdownMenuGroup`, which it names for assistive tech.\n * Only a label inside a group can do that: outside one — the shadcn/Radix\n * habit of dropping a label straight into the content — it renders as plain\n * visible text, naming nothing. Wrap labelled actions in `DropdownMenuGroup`\n * when the label should name them.\n */\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: MenuPrimitive.GroupLabel.Props & {\n inset?: boolean\n}) {\n const inGroup = React.useContext(DropdownMenuGroupContext)\n const labelProps = {\n 'data-slot': 'dropdown-menu-label',\n 'data-inset': inset || undefined,\n className: cn(\n 'px-4 py-2 text-base font-semibold text-muted-foreground data-inset:ps-10',\n 'group-data-[variant=band]/dropdown-menu-content:bg-muted group-data-[variant=band]/dropdown-menu-content:py-2.5',\n // rule: the label sits on a hairline in the text colour; mx-4 + ps-6\n // puts an inset label's text on the inset items' 40px line.\n 'group-data-[variant=rule]/dropdown-menu-content:mx-4 group-data-[variant=rule]/dropdown-menu-content:mb-1 group-data-[variant=rule]/dropdown-menu-content:border-b group-data-[variant=rule]/dropdown-menu-content:border-foreground group-data-[variant=rule]/dropdown-menu-content:px-0 group-data-[variant=rule]/dropdown-menu-content:text-foreground group-data-[variant=rule]/dropdown-menu-content:data-inset:ps-6',\n typeof className === 'function' ? className({}) : className,\n ),\n ...props,\n }\n return inGroup ? (\n <MenuPrimitive.GroupLabel {...labelProps} />\n ) : (\n <DropdownMenuPlainLabel {...labelProps} />\n )\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = 'default',\n ...props\n}: MenuPrimitive.Item.Props & {\n inset?: boolean\n /**\n * `destructive` inks the item with the danger role tokens, which carry\n * their own dark values — so it needs no `dark:` variant.\n */\n variant?: 'default' | 'destructive'\n}) {\n return (\n <MenuPrimitive.Item\n data-slot='dropdown-menu-item'\n data-inset={inset || undefined}\n data-variant={variant}\n className={cn(\n itemClasses,\n 'data-[variant=destructive]:text-(--danger-text) data-[variant=destructive]:data-highlighted:bg-(--danger-surface) data-[variant=destructive]:data-highlighted:text-(--danger-text)',\n // A destructive row keeps the danger colour under each look. These\n // carry one more attribute than the look's own highlight, so they win\n // at any emission order.\n 'group-data-[variant=band]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:bg-(--overlay-danger) group-data-[variant=band]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:text-(--overlay-danger-text)',\n 'group-data-[variant=rule]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:border-s-destructive group-data-[variant=rule]/dropdown-menu-content:data-[variant=destructive]:data-highlighted:bg-(--danger-surface)',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * An item that navigates. Renders a real `<a>`, so the browser's own link\n * behaviour (middle-click, open in new tab, status-bar URL) is kept — use it\n * instead of an `onClick` that sets `location`.\n *\n * `closeOnClick` defaults to `true` here, where Base UI's own default is\n * `false`: with client-side routing (`render={<Link />}`) the page never\n * reloads, so a menu that stayed open would sit over the new route.\n */\nfunction DropdownMenuLinkItem({\n className,\n inset,\n closeOnClick = true,\n ...props\n}: MenuPrimitive.LinkItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.LinkItem\n data-slot='dropdown-menu-link-item'\n data-inset={inset || undefined}\n closeOnClick={closeOnClick}\n className={cn(itemClasses, className)}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {\n return <MenuPrimitive.SubmenuRoot data-slot='dropdown-menu-sub' {...props} />\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: MenuPrimitive.SubmenuTrigger.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.SubmenuTrigger\n data-slot='dropdown-menu-sub-trigger'\n data-inset={inset || undefined}\n className={cn(\n itemClasses,\n // The row whose submenu is open stays marked, in each look's highlight.\n 'data-popup-open:bg-foreground/8 group-data-[variant=band]/dropdown-menu-content:data-popup-open:bg-primary group-data-[variant=band]/dropdown-menu-content:data-popup-open:text-primary-foreground group-data-[variant=rule]/dropdown-menu-content:data-popup-open:border-s-(--overlay-ink) group-data-[variant=rule]/dropdown-menu-content:data-popup-open:bg-(--overlay-ink)/8',\n className,\n )}\n {...props}\n >\n {children}\n <IconChevronRight className='ms-auto rtl:rotate-180' />\n </MenuPrimitive.SubmenuTrigger>\n )\n}\n\n/**\n * A submenu's popup. It portals out of its parent menu, so it cannot read the\n * parent's `data-variant` from the DOM; `variant` defaults to the parent's\n * through context instead.\n */\nfunction DropdownMenuSubContent({\n align = 'start',\n alignOffset,\n side = 'inline-end',\n sideOffset = 0,\n variant,\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuContent>) {\n const parentVariant = React.useContext(DropdownMenuVariantContext)\n const resolved = variant ?? parentVariant\n return (\n <DropdownMenuContent\n data-slot='dropdown-menu-sub-content'\n variant={resolved}\n className={cn('min-w-48', className)}\n align={align}\n // Line the submenu's first row up with its trigger row: the submenu's\n // own first row sits 4px below its top edge (its p-1, or rule's 4px\n // cap), except under band, whose rows start flush.\n alignOffset={alignOffset ?? (resolved === 'band' ? 0 : -4)}\n side={side}\n sideOffset={sideOffset}\n {...props}\n />\n )\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.CheckboxItem\n data-slot='dropdown-menu-checkbox-item'\n data-inset={inset || undefined}\n className={cn(itemClasses, 'pe-10', className)}\n {...props}\n >\n <span\n className='pointer-events-none absolute end-3 flex items-center justify-center'\n data-slot='dropdown-menu-checkbox-item-indicator'\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <IconCheck />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n {children}\n </MenuPrimitive.CheckboxItem>\n )\n}\n\nfunction DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {\n return (\n <DropdownMenuGroupContext.Provider value>\n <MenuPrimitive.RadioGroup data-slot='dropdown-menu-radio-group' {...props} />\n </DropdownMenuGroupContext.Provider>\n )\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean\n}) {\n return (\n <MenuPrimitive.RadioItem\n data-slot='dropdown-menu-radio-item'\n data-inset={inset || undefined}\n className={cn(itemClasses, 'pe-10', className)}\n {...props}\n >\n <span\n className='pointer-events-none absolute end-3 flex items-center justify-center'\n data-slot='dropdown-menu-radio-item-indicator'\n >\n <MenuPrimitive.RadioItemIndicator>\n <IconCheck />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n {children}\n </MenuPrimitive.RadioItem>\n )\n}\n\nfunction DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot='dropdown-menu-separator'\n className={cn(\n '-mx-1 my-1 h-px bg-border group-data-[variant=band]/dropdown-menu-content:mx-0 group-data-[variant=band]/dropdown-menu-content:my-0 group-data-[variant=rule]/dropdown-menu-content:mx-4',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** A trailing hint such as a keyboard shortcut. Decorative — it binds nothing. */\nfunction DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='dropdown-menu-shortcut'\n className={cn(\n 'ms-auto ps-4 text-base tracking-widest text-muted-foreground',\n // On band's solid highlight, muted ink would sit on the action colour.\n 'group-data-[variant=band]/dropdown-menu-content:group-data-highlighted/dropdown-menu-item:text-current',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n dropdownMenuContentVariants,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuLinkItem,\n DropdownMenuPortal,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubContent,\n DropdownMenuSubTrigger,\n DropdownMenuTrigger,\n}\nexport type { DropdownMenuVariant }\n"]}
|