@nswds/ui 7.0.1 → 8.0.0
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/badge.d.ts +1 -1
- package/dist/components/button-group.d.ts +104 -5
- package/dist/components/button-group.js +166 -11
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.d.ts +45 -6
- package/dist/components/button.js +271 -25
- package/dist/components/button.js.map +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/combobox.js +3 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/drawer.d.ts +1 -1
- package/dist/components/drawer.js +3 -2
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/hover-card.js +3 -2
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/navigation-menu.d.ts +1 -1
- package/dist/components/navigation-menu.js +6 -4
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/popover.js +3 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/select.js +3 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.js +3 -2
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/site-search.js +3 -2
- package/dist/components/site-search.js.map +1 -1
- package/dist/components/table.d.ts +30 -2
- package/dist/components/table.js +65 -7
- package/dist/components/table.js.map +1 -1
- package/dist/components/tooltip.js +3 -2
- package/dist/components/tooltip.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/lib/button-group-context.d.ts +46 -0
- package/dist/lib/button-group-context.js +12 -0
- package/dist/lib/button-group-context.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/table.tsx"],"names":[],"mappings":";;;AAMA,SAAS,KAAA,CAAM,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AACrE,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,WAAA,EAAU,iBAAA,EAAkB,WAAU,iCAAA,EAC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AAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,YAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,+GAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,SAAA,CAAU,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AACtE,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,YAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,kEAAA,EAAoE,SAAS,CAAA;AAAA,MAC1F,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,YAAA,CAAa,EAAE,SAAA,EAAW,GAAG,OAAM,EAAoC;AAC9E,EAAA,uBACE,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,oCAAA,EAAsC,SAAS,CAAA;AAAA,MAC5D,GAAG;AAAA;AAAA,GACN;AAEJ","file":"table.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nfunction Table({ className, ...props }: React.ComponentProps<'table'>) {\n return (\n <div data-slot='table-container' className='relative w-full overflow-x-auto'>\n <table\n data-slot='table'\n className={cn('w-full caption-bottom text-xs', className)}\n {...props}\n />\n </div>\n )\n}\n\nfunction TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {\n return <thead data-slot='table-header' className={cn('[&_tr]:border-b', className)} {...props} />\n}\n\nfunction TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {\n return (\n <tbody\n data-slot='table-body'\n className={cn('[&_tr:last-child]:border-0', className)}\n {...props}\n />\n )\n}\n\nfunction TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {\n return (\n <tfoot\n data-slot='table-footer'\n className={cn('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0', className)}\n {...props}\n />\n )\n}\n\nfunction TableRow({ className, ...props }: React.ComponentProps<'tr'>) {\n return (\n <tr\n data-slot='table-row'\n className={cn(\n 'border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction TableHead({ className, ...props }: React.ComponentProps<'th'>) {\n return (\n <th\n data-slot='table-head'\n className={cn(\n 'h-10 px-2 text-start align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pe-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction TableCell({ className, ...props }: React.ComponentProps<'td'>) {\n return (\n <td\n data-slot='table-cell'\n className={cn('p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pe-0', className)}\n {...props}\n />\n )\n}\n\nfunction TableCaption({ className, ...props }: React.ComponentProps<'caption'>) {\n return (\n <caption\n data-slot='table-caption'\n className={cn('mt-4 text-xs text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/table.tsx"],"names":[],"mappings":";;;;AAUA,MAAM,2BAAA,GAA8B,kBAAA;AASpC,MAAM,YAAA,GAAe,KAAA,CAAM,aAAA,CAAwC,IAAI,CAAA;AAwBvE,SAAS,KAAA,CAAM;AAAA,EACb,SAAA;AAAA,EACA,YAAA,EAAc,SAAA;AAAA,EACd,iBAAA,EAAmB,cAAA;AAAA,EACnB,GAAG;AACL,CAAA,EAAkC;AAChC,EAAA,MAAM,YAAA,GAAe,KAAA,CAAM,MAAA,CAAuB,IAAI,CAAA;AACtD,EAAA,MAAM,kBAAA,GAAqB,MAAM,KAAA,EAAM;AACvC,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,KAAA,CAAM,SAAwB,IAAI,CAAA;AACpE,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAA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WAAA,EAAU,eAAA;AAAA,MACV,EAAA;AAAA,MACA,SAAA,EAAW,EAAA,CAAG,oCAAA,EAAsC,SAAS,CAAA;AAAA,MAC5D,GAAG;AAAA;AAAA,GACN;AAEJ","file":"table.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n/**\n * Accessible name of the scroll region when nothing else names the table —\n * no TableCaption, and no `aria-label` / `aria-labelledby` on the table.\n */\nconst DEFAULT_SCROLL_REGION_LABEL = 'Scrollable table'\n\ntype TableContextValue = {\n /** The id a TableCaption takes when the consumer has not given it one. */\n captionId: string\n /** Called by TableCaption with its live id on mount, and `null` on unmount. */\n registerCaption: (id: string | null) => void\n}\n\nconst TableContext = React.createContext<TableContextValue | null>(null)\n\n/**\n * A data table inside a horizontally scrolling container.\n *\n * The container scrolls whenever the table is wider than the space it has —\n * TableHead and TableCell are `whitespace-nowrap`, so a wide table cannot\n * shrink to fit. A region that scrolls but cannot take focus is unreachable\n * from the keyboard (WCAG 2.1.1; axe reports `scrollable-region-focusable`),\n * so **while the table overflows** the container becomes a named, focusable\n * region: `tabIndex={0}` so the arrow keys scroll it, `role=\"region\"` so the\n * stop is announced, and an accessible name taken from the table's own\n * `aria-labelledby` / `aria-label`, else the TableCaption (linked by id), else\n * \"Scrollable table\". The `aria-label` / `aria-labelledby` stay on the\n * `<table>` too — the region borrows the name, it does not take it.\n *\n * **While the table fits, the container is a plain `<div>`** — no tab stop,\n * no landmark — so a page of fitting tables gains nothing to tab past. Both\n * states follow the layout live: a ResizeObserver watches the container (the\n * column changing width) and the table (its content changing width, which a\n * `w-full` container does not itself report). The measurement happens on the\n * client, so a server render has no tab stop until hydration; that is the\n * cost of not giving every table one.\n */\nfunction Table({\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n}: React.ComponentProps<'table'>) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const generatedCaptionId = React.useId()\n const [captionId, setCaptionId] = React.useState<string | null>(null)\n const [overflows, setOverflows] = React.useState(false)\n\n React.useEffect(() => {\n const container = containerRef.current\n if (!container) {\n return\n }\n // The observer delivers an initial entry after `observe()`, so the first\n // measurement needs no synchronous read here.\n const observer = new ResizeObserver(() => {\n setOverflows(container.scrollWidth > container.clientWidth)\n })\n observer.observe(container)\n // The container is `w-full`, so it does not resize when its table grows\n // past it — observe the table as well to catch content changes.\n const table = container.firstElementChild\n if (table) {\n observer.observe(table)\n }\n return () => observer.disconnect()\n }, [])\n\n const context = React.useMemo<TableContextValue>(\n () => ({ captionId: generatedCaptionId, registerCaption: setCaptionId }),\n [generatedCaptionId],\n )\n\n // The name is only applied together with the role: `aria-label` on a plain\n // <div> is a prohibited attribute (the generic role cannot be named).\n const explicitLabel = ariaLabel?.trim() ? ariaLabel : undefined\n const regionLabelledBy = ariaLabelledBy?.trim()\n ? ariaLabelledBy\n : explicitLabel\n ? undefined\n : (captionId ?? undefined)\n const regionLabel = regionLabelledBy ? undefined : (explicitLabel ?? DEFAULT_SCROLL_REGION_LABEL)\n\n return (\n <TableContext.Provider value={context}>\n <div\n ref={containerRef}\n data-slot='table-container'\n className='relative w-full overflow-x-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring'\n role={overflows ? 'region' : undefined}\n tabIndex={overflows ? 0 : undefined}\n aria-labelledby={overflows ? regionLabelledBy : undefined}\n aria-label={overflows ? regionLabel : undefined}\n >\n <table\n data-slot='table'\n className={cn('w-full caption-bottom text-xs', className)}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n {...props}\n />\n </div>\n </TableContext.Provider>\n )\n}\n\nfunction TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {\n return <thead data-slot='table-header' className={cn('[&_tr]:border-b', className)} {...props} />\n}\n\nfunction TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {\n return (\n <tbody\n data-slot='table-body'\n className={cn('[&_tr:last-child]:border-0', className)}\n {...props}\n />\n )\n}\n\nfunction TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {\n return (\n <tfoot\n data-slot='table-footer'\n className={cn('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0', className)}\n {...props}\n />\n )\n}\n\nfunction TableRow({ className, ...props }: React.ComponentProps<'tr'>) {\n return (\n <tr\n data-slot='table-row'\n className={cn(\n 'border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction TableHead({ className, ...props }: React.ComponentProps<'th'>) {\n return (\n <th\n data-slot='table-head'\n className={cn(\n 'h-10 px-2 text-start align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pe-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction TableCell({ className, ...props }: React.ComponentProps<'td'>) {\n return (\n <td\n data-slot='table-cell'\n className={cn('p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pe-0', className)}\n {...props}\n />\n )\n}\n\n/**\n * The table's caption. Besides naming the table for everyone, it names the\n * scroll region when no explicit ARIA name is supplied: the caption takes an\n * id (the one given, else a generated one) and reports it to the Table, which\n * points `aria-labelledby` at it.\n */\nfunction TableCaption({ className, id: idProp, ...props }: React.ComponentProps<'caption'>) {\n const context = React.useContext(TableContext)\n const id = idProp ?? context?.captionId\n\n React.useEffect(() => {\n if (!context || !id) {\n return\n }\n context.registerCaption(id)\n return () => context.registerCaption(null)\n }, [context, id])\n\n return (\n <caption\n data-slot='table-caption'\n id={id}\n className={cn('mt-4 text-xs text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow }\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
|
|
4
|
+
import { ButtonGroupBoundary } from '../lib/button-group-context.js';
|
|
4
5
|
import { cn } from '../lib/utils.js';
|
|
5
6
|
|
|
6
7
|
function TooltipProvider({ delay = 0, ...props }) {
|
|
@@ -21,7 +22,7 @@ function TooltipContent({
|
|
|
21
22
|
children,
|
|
22
23
|
...props
|
|
23
24
|
}) {
|
|
24
|
-
return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsx(
|
|
25
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsx(ButtonGroupBoundary, { children: /* @__PURE__ */ jsx(
|
|
25
26
|
Tooltip$1.Positioner,
|
|
26
27
|
{
|
|
27
28
|
align,
|
|
@@ -45,7 +46,7 @@ function TooltipContent({
|
|
|
45
46
|
}
|
|
46
47
|
)
|
|
47
48
|
}
|
|
48
|
-
) });
|
|
49
|
+
) }) });
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/tooltip.tsx"],"names":["TooltipPrimitive"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/tooltip.tsx"],"names":["TooltipPrimitive"],"mappings":";;;;;AAOA,SAAS,gBAAgB,EAAE,KAAA,GAAQ,CAAA,EAAG,GAAG,OAAM,EAAoC;AACjF,EAAA,uBAAO,GAAA,CAACA,UAAiB,QAAA,EAAjB,EAA0B,aAAU,kBAAA,EAAmB,KAAA,EAAe,GAAG,KAAA,EAAO,CAAA;AAC1F;AAEA,SAAS,OAAA,CAAQ,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC1D,EAAA,2BAAQA,SAAA,CAAiB,IAAA,EAAjB,EAAsB,WAAA,EAAU,SAAA,EAAW,GAAG,KAAA,EAAO,CAAA;AAC/D;AAEA,SAAS,cAAA,CAAe,EAAE,GAAG,KAAA,EAAM,EAAmC;AACpE,EAAA,2BAAQA,SAAA,CAAiB,OAAA,EAAjB,EAAyB,WAAA,EAAU,iBAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAC1E;AAEA,SAAS,cAAA,CAAe;AAAA,EACtB,SAAA;AAAA,EACA,IAAA,GAAO,KAAA;AAAA,EACP,UAAA,GAAa,CAAA;AAAA,EACb,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc,CAAA;AAAA,EACd,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAC4F;AAC1F,EAAA,uBACE,GAAA,CAACA,SAAA,CAAiB,MAAA,EAAjB,EAEC,8BAAC,mBAAA,EAAA,EACC,QAAA,kBAAA,GAAA;AAAA,IAACA,SAAA,CAAiB,UAAA;AAAA,IAAjB;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,SAAA,EAAU,cAAA;AAAA,MAEV,QAAA,kBAAA,IAAA;AAAA,QAACA,SAAA,CAAiB,KAAA;AAAA,QAAjB;AAAA,UACC,WAAA,EAAU,iBAAA;AAAA,UACV,SAAA,EAAW,EAAA;AAAA,YACT,gwBAAA;AAAA,YACA;AAAA,WACF;AAAA,UACC,GAAG,KAAA;AAAA,UAEH,QAAA,EAAA;AAAA,YAAA,QAAA;AAAA,4BACD,GAAA,CAACA,SAAA,CAAiB,KAAA,EAAjB,EAAuB,WAAU,yhBAAA,EAA0hB;AAAA;AAAA;AAAA;AAC9jB;AAAA,KAEJ,CAAA,EACF,CAAA;AAEJ","file":"tooltip.js","sourcesContent":["'use client'\n\nimport { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip'\n\nimport { ButtonGroupBoundary } from '../lib/button-group-context.js'\nimport { cn } from '../lib/utils.js'\n\nfunction TooltipProvider({ delay = 0, ...props }: TooltipPrimitive.Provider.Props) {\n return <TooltipPrimitive.Provider data-slot='tooltip-provider' delay={delay} {...props} />\n}\n\nfunction Tooltip({ ...props }: TooltipPrimitive.Root.Props) {\n return <TooltipPrimitive.Root data-slot='tooltip' {...props} />\n}\n\nfunction TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props) {\n return <TooltipPrimitive.Trigger data-slot='tooltip-trigger' {...props} />\n}\n\nfunction TooltipContent({\n className,\n side = 'top',\n sideOffset = 4,\n align = 'center',\n alignOffset = 0,\n children,\n ...props\n}: TooltipPrimitive.Popup.Props &\n Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {\n return (\n <TooltipPrimitive.Portal>\n {/* Stops a ButtonGroup's context at the portal — see ButtonGroupBoundary. */}\n <ButtonGroupBoundary>\n <TooltipPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className='isolate z-50'\n >\n <TooltipPrimitive.Popup\n data-slot='tooltip-content'\n className={cn(\n 'z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-sm bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n className,\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className='z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:-start-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:-end-1 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5' />\n </TooltipPrimitive.Popup>\n </TooltipPrimitive.Positioner>\n </ButtonGroupBoundary>\n </TooltipPrimitive.Portal>\n )\n}\n\nexport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { AspectRatio } from './components/aspect-ratio.js';
|
|
|
3
3
|
export { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage } from './components/avatar.js';
|
|
4
4
|
export { Badge, BadgeButton, BadgeButtonProps, BadgeLink, BadgeLinkProps, BadgeProps, badgeVariants } from './components/badge.js';
|
|
5
5
|
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from './components/breadcrumb.js';
|
|
6
|
-
export { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants } from './components/button-group.js';
|
|
7
|
-
export { Button, ButtonLink, ButtonLinkProps, ButtonProps, IconSlot, TouchTarget, buttonVariants } from './components/button.js';
|
|
6
|
+
export { ButtonGroup, ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, ButtonGroupVariant, buttonGroupVariants } from './components/button-group.js';
|
|
7
|
+
export { Button, ButtonLink, ButtonLinkProps, ButtonProps, IconSlot, TouchTarget, buttonColorVariants, buttonVariants } from './components/button.js';
|
|
8
8
|
export { Callout, CalloutProps, CalloutStatus, calloutVariants } from './components/callout.js';
|
|
9
9
|
export { Card, CardAction, CardActionProps, CardContent, CardContentProps, CardDescription, CardDescriptionProps, CardFooter, CardFooterProps, CardHeader, CardHeaderProps, CardProps, CardTitle, CardTitleProps } from './components/card.js';
|
|
10
10
|
export { Carousel, CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, useCarousel } from './components/carousel.js';
|
|
@@ -62,6 +62,7 @@ export { Toggle, toggleVariants } from './components/toggle.js';
|
|
|
62
62
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './components/tooltip.js';
|
|
63
63
|
export { UseChromeHeightOptions, UseChromeHeightResult, useChromeHeight } from './hooks/use-chrome-height.js';
|
|
64
64
|
export { cn } from './lib/utils.js';
|
|
65
|
+
export { ButtonGroupBoundary } from './lib/button-group-context.js';
|
|
65
66
|
import 'react';
|
|
66
67
|
import '@base-ui/react/accordion';
|
|
67
68
|
import '@base-ui/react/avatar';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type ButtonGroupOrientation = 'horizontal' | 'vertical';
|
|
4
|
+
/**
|
|
5
|
+
* What a ButtonGroup hands its segments: its `color` and `size` as their
|
|
6
|
+
* defaults, its variant as the `band` a segment sits on — so the segment can
|
|
7
|
+
* re-ink itself on a solid band, and can tell that it sits on a soft or
|
|
8
|
+
* surface tint, without depending on DOM ancestry — and its orientation for
|
|
9
|
+
* the separator.
|
|
10
|
+
*
|
|
11
|
+
* `band`, `color` and `size` are typed as plain strings here, deliberately.
|
|
12
|
+
* This module ships as a supporting file of every popup in the package (each
|
|
13
|
+
* one resets the context at its portal — see `ButtonGroupBoundary`), and even
|
|
14
|
+
* a type-only import of Button or ButtonGroup from here would make them a
|
|
15
|
+
* registry dependency of Tooltip, Select and the rest. button.tsx narrows the
|
|
16
|
+
* fields to its own unions at the one place it reads them.
|
|
17
|
+
*/
|
|
18
|
+
type ButtonGroupContextValue<Color = string, Size = string> = {
|
|
19
|
+
band: string;
|
|
20
|
+
color?: Color | null;
|
|
21
|
+
size?: Size | null;
|
|
22
|
+
variant?: string | null;
|
|
23
|
+
orientation: ButtonGroupOrientation;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Provided by ButtonGroup and read by Button and ButtonLink, which render as
|
|
27
|
+
* segments while it is set. `null` outside a group, and again inside a
|
|
28
|
+
* `ButtonGroupBoundary`.
|
|
29
|
+
*/
|
|
30
|
+
declare const ButtonGroupContext: React.Context<ButtonGroupContextValue<string, string> | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Stops a ButtonGroup's context at a portal.
|
|
33
|
+
*
|
|
34
|
+
* React context follows the component tree, not the DOM. A Popover, Sheet,
|
|
35
|
+
* Tooltip or Drawer opened from a segment renders its contents through a
|
|
36
|
+
* portal, so without this its own Buttons would render as segments too:
|
|
37
|
+
* squared, shadowless, ghost, and under a solid group inked in the band's
|
|
38
|
+
* label colour on whatever surface the popup has. Every popup in this package
|
|
39
|
+
* wraps its portal contents in this boundary; an overlay from another
|
|
40
|
+
* library, opened from inside a group, should do the same.
|
|
41
|
+
*/
|
|
42
|
+
declare function ButtonGroupBoundary({ children }: {
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
}): React.JSX.Element;
|
|
45
|
+
|
|
46
|
+
export { ButtonGroupBoundary, ButtonGroupContext, type ButtonGroupContextValue, type ButtonGroupOrientation };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
const ButtonGroupContext = React.createContext(null);
|
|
6
|
+
function ButtonGroupBoundary({ children }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(ButtonGroupContext.Provider, { value: null, children });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { ButtonGroupBoundary, ButtonGroupContext };
|
|
11
|
+
//# sourceMappingURL=button-group-context.js.map
|
|
12
|
+
//# sourceMappingURL=button-group-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/button-group-context.tsx"],"names":[],"mappings":";;;AAiCA,MAAM,kBAAA,GAAqB,KAAA,CAAM,aAAA,CAA8C,IAAI;AAanF,SAAS,mBAAA,CAAoB,EAAE,QAAA,EAAS,EAAkC;AACxE,EAAA,2BAAQ,kBAAA,CAAmB,QAAA,EAAnB,EAA4B,KAAA,EAAO,MAAO,QAAA,EAAS,CAAA;AAC7D","file":"button-group-context.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\n\ntype ButtonGroupOrientation = 'horizontal' | 'vertical'\n\n/**\n * What a ButtonGroup hands its segments: its `color` and `size` as their\n * defaults, its variant as the `band` a segment sits on — so the segment can\n * re-ink itself on a solid band, and can tell that it sits on a soft or\n * surface tint, without depending on DOM ancestry — and its orientation for\n * the separator.\n *\n * `band`, `color` and `size` are typed as plain strings here, deliberately.\n * This module ships as a supporting file of every popup in the package (each\n * one resets the context at its portal — see `ButtonGroupBoundary`), and even\n * a type-only import of Button or ButtonGroup from here would make them a\n * registry dependency of Tooltip, Select and the rest. button.tsx narrows the\n * fields to its own unions at the one place it reads them.\n */\ntype ButtonGroupContextValue<Color = string, Size = string> = {\n band: string\n color?: Color | null\n size?: Size | null\n variant?: string | null\n orientation: ButtonGroupOrientation\n}\n\n/**\n * Provided by ButtonGroup and read by Button and ButtonLink, which render as\n * segments while it is set. `null` outside a group, and again inside a\n * `ButtonGroupBoundary`.\n */\nconst ButtonGroupContext = React.createContext<ButtonGroupContextValue | null>(null)\n\n/**\n * Stops a ButtonGroup's context at a portal.\n *\n * React context follows the component tree, not the DOM. A Popover, Sheet,\n * Tooltip or Drawer opened from a segment renders its contents through a\n * portal, so without this its own Buttons would render as segments too:\n * squared, shadowless, ghost, and under a solid group inked in the band's\n * label colour on whatever surface the popup has. Every popup in this package\n * wraps its portal contents in this boundary; an overlay from another\n * library, opened from inside a group, should do the same.\n */\nfunction ButtonGroupBoundary({ children }: { children: React.ReactNode }) {\n return <ButtonGroupContext.Provider value={null}>{children}</ButtonGroupContext.Provider>\n}\n\nexport { ButtonGroupBoundary, ButtonGroupContext }\nexport type { ButtonGroupContextValue, ButtonGroupOrientation }\n"]}
|