@chassis-ui/react 0.4.0 → 0.4.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/alert.js +1 -1
- package/dist/avatar.js +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/card.js +1 -1
- package/dist/chunks/Link-DyZyAQFj.js +2 -0
- package/dist/chunks/Link-DyZyAQFj.js.map +1 -0
- package/dist/chunks/{MenuToggle-BdQtF7FV.js → MenuToggle-7RQ0dmtZ.js} +2 -2
- package/dist/chunks/{MenuToggle-BdQtF7FV.js.map → MenuToggle-7RQ0dmtZ.js.map} +1 -1
- package/dist/chunks/alert-3kTBfWFw.js +2 -0
- package/dist/chunks/{alert-BXI-_qlt.js.map → alert-3kTBfWFw.js.map} +1 -1
- package/dist/chunks/{avatar-S3dGy6Qc.js → avatar-MklqAKcz.js} +2 -2
- package/dist/chunks/{avatar-S3dGy6Qc.js.map → avatar-MklqAKcz.js.map} +1 -1
- package/dist/chunks/{breadcrumb-s6J9itez.js → breadcrumb-CHxTiZLt.js} +2 -2
- package/dist/chunks/{breadcrumb-s6J9itez.js.map → breadcrumb-CHxTiZLt.js.map} +1 -1
- package/dist/chunks/{card-CobeDpf1.js → card-CTP9K8xG.js} +2 -2
- package/dist/chunks/{card-CobeDpf1.js.map → card-CTP9K8xG.js.map} +1 -1
- package/dist/chunks/colorClassNames-CEh5Yzfp.js +2 -0
- package/dist/chunks/colorClassNames-CEh5Yzfp.js.map +1 -0
- package/dist/chunks/datagrid-DOYxx0sF.js +3 -0
- package/dist/chunks/datagrid-DOYxx0sF.js.map +1 -0
- package/dist/chunks/{index-B5bF1JxF.d.ts → index-Dzga1f4w.d.ts} +2 -2
- package/dist/chunks/{list-BQCkwWjF.js → list-07e2a1Ym.js} +2 -2
- package/dist/chunks/{list-BQCkwWjF.js.map → list-07e2a1Ym.js.map} +1 -1
- package/dist/chunks/{menu-98EAD9nj.js → menu-Upf6P-2P.js} +2 -2
- package/dist/chunks/{menu-98EAD9nj.js.map → menu-Upf6P-2P.js.map} +1 -1
- package/dist/chunks/{nav-TiZuTHC6.js → nav-DI6oEULI.js} +2 -2
- package/dist/chunks/{nav-TiZuTHC6.js.map → nav-DI6oEULI.js.map} +1 -1
- package/dist/chunks/{nav-overflow-Ay5mM5Gc.js → nav-overflow-DlLer6EK.js} +2 -2
- package/dist/chunks/{nav-overflow-Ay5mM5Gc.js.map → nav-overflow-DlLer6EK.js.map} +1 -1
- package/dist/chunks/pagination-BREQp-ZC.js +2 -0
- package/dist/chunks/{pagination-BkOquk-x.js.map → pagination-BREQp-ZC.js.map} +1 -1
- package/dist/chunks/placeholder-DhNpUJqv.js +2 -0
- package/dist/chunks/placeholder-DhNpUJqv.js.map +1 -0
- package/dist/chunks/progress-BqgWezdG.js +2 -0
- package/dist/chunks/progress-BqgWezdG.js.map +1 -0
- package/dist/chunks/skeleton-Bjv9gGd3.js +2 -0
- package/dist/chunks/skeleton-Bjv9gGd3.js.map +1 -0
- package/dist/chunks/spinner-DBuvQvMR.js +2 -0
- package/dist/chunks/spinner-DBuvQvMR.js.map +1 -0
- package/dist/chunks/static-table-uu297Liz.js +2 -0
- package/dist/chunks/{static-table-D0M4oc_t.js.map → static-table-uu297Liz.js.map} +1 -1
- package/dist/chunks/{table-Cy6uEuEP.js → table-DPLOygg0.js} +2 -2
- package/dist/chunks/{table-Cy6uEuEP.js.map → table-DPLOygg0.js.map} +1 -1
- package/dist/chunks/tableClassName-DleBjOj2.js +2 -0
- package/dist/chunks/tableClassName-DleBjOj2.js.map +1 -0
- package/dist/datagrid.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/link.js +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.js +1 -1
- package/dist/nav-overflow.js +1 -1
- package/dist/nav.js +1 -1
- package/dist/pagination.js +1 -1
- package/dist/placeholder.js +1 -1
- package/dist/progress.js +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/spinner.d.ts +1 -1
- package/dist/spinner.js +1 -1
- package/dist/static-table.js +1 -1
- package/dist/table.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/Link-CZsWCnQb.js +0 -2
- package/dist/chunks/Link-CZsWCnQb.js.map +0 -1
- package/dist/chunks/alert-BXI-_qlt.js +0 -2
- package/dist/chunks/datagrid-CH3Cy-q7.js +0 -3
- package/dist/chunks/datagrid-CH3Cy-q7.js.map +0 -1
- package/dist/chunks/pagination-BkOquk-x.js +0 -2
- package/dist/chunks/placeholder-BCr83sUn.js +0 -2
- package/dist/chunks/placeholder-BCr83sUn.js.map +0 -1
- package/dist/chunks/progress-zWkTltor.js +0 -2
- package/dist/chunks/progress-zWkTltor.js.map +0 -1
- package/dist/chunks/skeleton-CmZBLJwp.js +0 -2
- package/dist/chunks/skeleton-CmZBLJwp.js.map +0 -1
- package/dist/chunks/spinner-DblhvrHL.js +0 -2
- package/dist/chunks/spinner-DblhvrHL.js.map +0 -1
- package/dist/chunks/static-table-D0M4oc_t.js +0 -2
- package/dist/chunks/tableClassName-CZA2Bse8.js +0 -2
- package/dist/chunks/tableClassName-CZA2Bse8.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card-CobeDpf1.js","names":[],"sources":["../../src/components/card/CardBody.tsx","../../src/components/card/CardFooter.tsx","../../src/components/card/CardImage.tsx","../../src/components/card/CardSubtitle.tsx","../../src/components/card/CardText.tsx","../../src/components/card/CardTitle.tsx","../../src/components/card/Card.tsx","../../src/components/card/CardGroup.tsx","../../src/components/card/CardHeader.tsx","../../src/components/card/CardImageOverlay.tsx","../../src/components/card/CardLink.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { Responsive, Spacing } from '../../types'\nimport {\n flexDirectionClassName,\n FlexDirection,\n responsiveClassNames,\n responsiveProp\n} from '../../utils/breakpoints'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { spacingClassName } from '../../utils/spacingClassName'\n\ntype CardBodyOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * Switches the body from its default stacked (column) layout to a side-by-side (row) layout —\n * for placing an image beside text within a single padded region. Give the image and the text\n * a width utility (`w-4/12`, `w-8/12`) to control each side's width, and nest another\n * `CardBody` (with `.p-0`) for the text side so it doesn't receive double padding. An object\n * sets the direction from a breakpoint up: `{ md: 'row' }`.\n */\n direction?: Responsive<FlexDirection>\n /**\n * Spacing between children, mapped to the `gap-*` utility classes. Overrides the card's default\n * gap between body children.\n *\n * @type { Spacing | 0 }\n */\n gap?: Spacing | 0\n}\n\nexport type CardBodyProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardBodyOwnProps<C>\n>\n\ntype CardBodyComponent = (<C extends ElementType = 'div'>(\n props: CardBodyProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardBodyRender<C extends ElementType = 'div'>(\n { children, className, component, direction, gap, ...rest }: CardBodyProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames(\n 'card-body',\n responsiveClassNames([responsiveProp(direction, flexDirectionClassName)]),\n spacingClassName('gap', gap),\n className\n )\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardBody = createPolymorphicComponent<CardBodyComponent>(\n CardBodyRender as ForwardRefRenderFunction<Element, CardBodyProps<ElementType>>,\n 'CardBody'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardFooterOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardFooterProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardFooterOwnProps<C>\n>\n\ntype CardFooterComponent = (<C extends ElementType = 'div'>(\n props: CardFooterProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardFooterRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardFooterProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-footer', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardFooter = createPolymorphicComponent<CardFooterComponent>(\n CardFooterRender as ForwardRefRenderFunction<Element, CardFooterProps<ElementType>>,\n 'CardFooter'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { Responsive } from '../../types'\nimport { baseValue, responsiveClassNames, responsiveProp } from '../../utils/breakpoints'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardImageOrientation = 'top' | 'bottom' | 'start' | 'end'\n\ntype CardImageOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component —\n * e.g. a framework's own `Image` component. Its own props (`src`, `fill`, `priority`, etc.)\n * are type-checked at the call site once passed here.\n */\n component?: C\n /**\n * Orientates the image to the top or bottom of the card as an \"image cap\", or to the start/end\n * for a horizontal layout. Omit to round all four corners for use inside `CardBody`. An object\n * sets the orientation from a breakpoint up — e.g. `{ base: 'top', lg: 'start' }` to switch an\n * image cap from `top` to `start` once the card lays out horizontally.\n */\n orientation?: Responsive<CardImageOrientation>\n}\n\nexport type CardImageProps<C extends ElementType = 'img'> = PolymorphicComponentProps<\n C,\n CardImageOwnProps<C>\n>\n\ntype CardImageComponent = (<C extends ElementType = 'img'>(\n props: CardImageProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nconst orientationClassName = (orientation: CardImageOrientation, prefix: string) =>\n `${prefix}card-image-${orientation}`\n\nfunction CardImageRender<C extends ElementType = 'img'>(\n { children, className, component, orientation, ...rest }: CardImageProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'img'\n const _className = classNames(\n // With no orientation at the base, the image is the plain one of `CardBody`.\n baseValue(orientation) === undefined && 'card-image',\n responsiveClassNames([responsiveProp(orientation, orientationClassName)]),\n className\n )\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardImage = createPolymorphicComponent<CardImageComponent>(\n CardImageRender as ForwardRefRenderFunction<Element, CardImageProps<ElementType>>,\n 'CardImage'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardSubtitleOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardSubtitleProps<C extends ElementType = 'h6'> = PolymorphicComponentProps<\n C,\n CardSubtitleOwnProps<C>\n>\n\ntype CardSubtitleComponent = (<C extends ElementType = 'h6'>(\n props: CardSubtitleProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardSubtitleRender<C extends ElementType = 'h6'>(\n { children, component, className, ...rest }: CardSubtitleProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'h6'\n const _className = classNames('card-subtitle', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardSubtitle = createPolymorphicComponent<CardSubtitleComponent>(\n CardSubtitleRender as ForwardRefRenderFunction<Element, CardSubtitleProps<ElementType>>,\n 'CardSubtitle'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardTextOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardTextProps<C extends ElementType = 'p'> = PolymorphicComponentProps<\n C,\n CardTextOwnProps<C>\n>\n\ntype CardTextComponent = (<C extends ElementType = 'p'>(\n props: CardTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardTextRender<C extends ElementType = 'p'>(\n { children, component, className, ...rest }: CardTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'p'\n const _className = classNames('card-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardText = createPolymorphicComponent<CardTextComponent>(\n CardTextRender as ForwardRefRenderFunction<Element, CardTextProps<ElementType>>,\n 'CardText'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardTitleOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardTitleProps<C extends ElementType = 'h5'> = PolymorphicComponentProps<\n C,\n CardTitleOwnProps<C>\n>\n\ntype CardTitleComponent = (<C extends ElementType = 'h5'>(\n props: CardTitleProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardTitleRender<C extends ElementType = 'h5'>(\n { children, component, className, ...rest }: CardTitleProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'h5'\n const _className = classNames('card-title', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardTitle = createPolymorphicComponent<CardTitleComponent>(\n CardTitleRender as ForwardRefRenderFunction<Element, CardTitleProps<ElementType>>,\n 'CardTitle'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement, ReactNode } from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor, ContextStyle, Responsive, Sizing } from '../../types'\nimport {\n flexDirectionClassName,\n FlexDirection,\n responsiveClassNames,\n responsiveProp\n} from '../../utils/breakpoints'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { CardBody } from './CardBody'\nimport { CardFooter } from './CardFooter'\nimport { CardImage } from './CardImage'\nimport { CardSubtitle } from './CardSubtitle'\nimport { CardText } from './CardText'\nimport { CardTitle } from './CardTitle'\n\ntype CardOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Switches the card from its default stacked (column) layout to a side-by-side (row) layout.\n * Give the image and the body a width utility (`w-4/12`, `w-8/12`) to control each side's\n * width. An object sets the direction from a breakpoint up — e.g. `{ lg: 'row' }` to lay the\n * card out horizontally from `lg` up while stacking below it.\n */\n direction?: Responsive<FlexDirection>\n /**\n * Shorthand for a `CardFooter`, rendered after the image/title/subtitle/text/`children` block.\n */\n footer?: ReactNode\n /**\n * Shorthand for a `CardImage` — pass either a `src` URL (combine with `imageAlt`/\n * `imageOrientation`) or a fully-formed element — a `<CardImage>`, `<Skeleton>`,\n * `<Placeholder>`, or anything else — rendered as-is in its place. `imageAlt`/`imageOrientation`\n * only apply to the `src` form; set them directly on your own element otherwise. For a\n * horizontal layout or an overlay, omit this and compose `CardImage` directly as a child\n * instead.\n */\n image?: ReactNode\n /**\n * Accessible alt text for `image`. Ignored unless `image` is set.\n */\n imageAlt?: string\n /**\n * Orientates `image` to the top (default) or bottom of the card.\n */\n imageOrientation?: 'top' | 'bottom'\n /**\n * Sets the size of the component to one of Chassis component sizes.\n */\n size?: Sizing\n /**\n * Shorthand for a `CardSubtitle`, rendered directly after `title`.\n */\n subtitle?: ReactNode\n /**\n * Shorthand for a `CardText`, rendered after `title`/`subtitle`.\n */\n text?: ReactNode\n /**\n * Shorthand for a `CardTitle`. Set alongside `subtitle`/`text` (or plain `children`, e.g. a\n * `Button`) to build a standard card without composing `CardBody`/`CardTitle` yourself — all\n * render together inside a single `CardBody`, in that order. Only takes effect when at least\n * one of `image`/`title`/`subtitle`/`text`/`footer` is set; otherwise `children` render as-is,\n * so full manual composition (`CardHeader`, lists, overlays, nav headers, …) keeps working\n * unchanged. Mixing shorthand props with a manually-composed `children` tree isn't supported —\n * pick one approach per card.\n */\n title?: ReactNode\n /**\n * Sets the context style of the component. `basic` (the default) renders with no extra class.\n */\n variant?: ContextStyle\n}\n\nexport type CardProps<C extends ElementType = 'div'> = PolymorphicComponentProps<C, CardOwnProps<C>>\n\ntype CardComponent = (<C extends ElementType = 'div'>(\n props: CardProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardRender<C extends ElementType = 'div'>(\n {\n children,\n className,\n color,\n component,\n direction,\n footer,\n image,\n imageAlt,\n imageOrientation = 'top',\n size,\n subtitle,\n text,\n title,\n variant,\n ...rest\n }: CardProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames(\n 'card',\n color,\n {\n context: !!color,\n solid: variant === 'solid',\n smooth: variant === 'smooth',\n outline: variant === 'outline',\n sm: size === 'sm',\n lg: size === 'lg'\n },\n responsiveClassNames([responsiveProp(direction, flexDirectionClassName)]),\n className\n )\n\n const hasShorthand =\n image != null || title != null || subtitle != null || footer != null || text != null\n const hasBodyContent = title != null || subtitle != null || text != null || children != null\n const renderedImage =\n typeof image === 'string' ? (\n <CardImage orientation={imageOrientation} src={image} alt={imageAlt ?? ''} />\n ) : (\n image\n )\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {hasShorthand ? (\n <>\n {image != null && imageOrientation === 'top' && renderedImage}\n {hasBodyContent && (\n <CardBody>\n {title != null && <CardTitle>{title}</CardTitle>}\n {subtitle != null && <CardSubtitle>{subtitle}</CardSubtitle>}\n {text != null && <CardText>{text}</CardText>}\n {children}\n </CardBody>\n )}\n {image != null && imageOrientation === 'bottom' && renderedImage}\n {footer != null && <CardFooter>{footer}</CardFooter>}\n </>\n ) : (\n children\n )}\n </Component>\n )\n}\n\nexport const Card = createPolymorphicComponent<CardComponent>(\n CardRender as ForwardRefRenderFunction<Element, CardProps<ElementType>>,\n 'Card'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardGroupOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardGroupProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardGroupOwnProps<C>\n>\n\ntype CardGroupComponent = (<C extends ElementType = 'div'>(\n props: CardGroupProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\n// Arranges direct-child Cards as an equal-width row, joined edge-to-edge, once its container\n// reaches the sm container breakpoint — below that, cards stack vertically. Requires a\n// `.contains-inline` ancestor (not applied by CardGroup itself, e.g. a wrapping\n// `<div className=\"contains-inline\">`) to establish the container query context.\nfunction CardGroupRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardGroupProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-group', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardGroup = createPolymorphicComponent<CardGroupComponent>(\n CardGroupRender as ForwardRefRenderFunction<Element, CardGroupProps<ElementType>>,\n 'CardGroup'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardHeaderOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardHeaderProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardHeaderOwnProps<C>\n>\n\ntype CardHeaderComponent = (<C extends ElementType = 'div'>(\n props: CardHeaderProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardHeaderRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardHeaderProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-header', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardHeader = createPolymorphicComponent<CardHeaderComponent>(\n CardHeaderRender as ForwardRefRenderFunction<Element, CardHeaderProps<ElementType>>,\n 'CardHeader'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardImageOverlayOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardImageOverlayProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardImageOverlayOwnProps<C>\n>\n\ntype CardImageOverlayComponent = (<C extends ElementType = 'div'>(\n props: CardImageOverlayProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardImageOverlayRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardImageOverlayProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-overlay', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardImageOverlay = createPolymorphicComponent<CardImageOverlayComponent>(\n CardImageOverlayRender as ForwardRefRenderFunction<Element, CardImageOverlayProps<ElementType>>,\n 'CardImageOverlay'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { createPolymorphicComponent, PolymorphicRef } from '../../utils/polymorphic'\nimport { Link, LinkProps } from '../link/Link'\n\ntype CardLinkOwnProps = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n}\n\nexport type CardLinkProps<C extends ElementType = 'a'> = LinkProps<C> & CardLinkOwnProps\n\ntype CardLinkComponent = (<C extends ElementType = 'a'>(\n props: CardLinkProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardLinkRender<C extends ElementType = 'a'>(\n { children, className, ...rest }: CardLinkProps<C>,\n ref: PolymorphicRef<C>\n) {\n const _className = classNames('card-link', className)\n\n return (\n <Link\n className={_className}\n {...(rest as Record<string, unknown>)}\n ref={ref as PolymorphicRef<ElementType>}\n >\n {children}\n </Link>\n )\n}\n\nexport const CardLink = createPolymorphicComponent<CardLinkComponent>(\n CardLinkRender as ForwardRefRenderFunction<Element, CardLinkProps<ElementType>>,\n 'CardLink'\n)\n"],"mappings":"sRAoDA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,YAAW,MAAK,GAAG,GACrD,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAa,EACjB,YACA,EAAqB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AY,CAAmB,CACnD,EAEF,CAEO,CAEf,CAEA,MAAa,EAAO,EAClB,EACA,MACF,ECxIA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,GAAG,GACrC,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAa,EAAW,aAAc,CAAS,EAErD,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAY,EACvB,EACA,WACF,ECrBA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,GAAG,GACrC,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAa,EAAW,cAAe,CAAS,EAEtD,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAa,EACxB,EACA,YACF,ECjBA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,GAAG,GACrC,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAa,EAAW,eAAgB,CAAS,EAEvD,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAmB,EAC9B,EACA,kBACF,EC3BA,SAAS,EACP,CAAE,WAAU,YAAW,GAAG,GAC1B,EACA,CACA,IAAM,EAAa,EAAW,YAAa,CAAS,EAEpD,OACE,EAAA,cAAC,EAAD,CACE,UAAW,EACX,GAAK,EACA,KAGD,EADH,CACG,CAEV,CAEA,MAAa,EAAW,EACtB,EACA,UACF"}
|
|
1
|
+
{"version":3,"file":"card-CTP9K8xG.js","names":[],"sources":["../../src/components/card/CardBody.tsx","../../src/components/card/CardFooter.tsx","../../src/components/card/CardImage.tsx","../../src/components/card/CardSubtitle.tsx","../../src/components/card/CardText.tsx","../../src/components/card/CardTitle.tsx","../../src/components/card/Card.tsx","../../src/components/card/CardGroup.tsx","../../src/components/card/CardHeader.tsx","../../src/components/card/CardImageOverlay.tsx","../../src/components/card/CardLink.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { Responsive, Spacing } from '../../types'\nimport {\n flexDirectionClassName,\n FlexDirection,\n responsiveClassNames,\n responsiveProp\n} from '../../utils/breakpoints'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { spacingClassName } from '../../utils/spacingClassName'\n\ntype CardBodyOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * Switches the body from its default stacked (column) layout to a side-by-side (row) layout —\n * for placing an image beside text within a single padded region. Give the image and the text\n * a width utility (`w-4/12`, `w-8/12`) to control each side's width, and nest another\n * `CardBody` (with `.p-0`) for the text side so it doesn't receive double padding. An object\n * sets the direction from a breakpoint up: `{ md: 'row' }`.\n */\n direction?: Responsive<FlexDirection>\n /**\n * Spacing between children, mapped to the `gap-*` utility classes. Overrides the card's default\n * gap between body children.\n *\n * @type { Spacing | 0 }\n */\n gap?: Spacing | 0\n}\n\nexport type CardBodyProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardBodyOwnProps<C>\n>\n\ntype CardBodyComponent = (<C extends ElementType = 'div'>(\n props: CardBodyProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardBodyRender<C extends ElementType = 'div'>(\n { children, className, component, direction, gap, ...rest }: CardBodyProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames(\n 'card-body',\n responsiveClassNames([responsiveProp(direction, flexDirectionClassName)]),\n spacingClassName('gap', gap),\n className\n )\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardBody = createPolymorphicComponent<CardBodyComponent>(\n CardBodyRender as ForwardRefRenderFunction<Element, CardBodyProps<ElementType>>,\n 'CardBody'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardFooterOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardFooterProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardFooterOwnProps<C>\n>\n\ntype CardFooterComponent = (<C extends ElementType = 'div'>(\n props: CardFooterProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardFooterRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardFooterProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-footer', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardFooter = createPolymorphicComponent<CardFooterComponent>(\n CardFooterRender as ForwardRefRenderFunction<Element, CardFooterProps<ElementType>>,\n 'CardFooter'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { Responsive } from '../../types'\nimport { baseValue, responsiveClassNames, responsiveProp } from '../../utils/breakpoints'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardImageOrientation = 'top' | 'bottom' | 'start' | 'end'\n\ntype CardImageOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component —\n * e.g. a framework's own `Image` component. Its own props (`src`, `fill`, `priority`, etc.)\n * are type-checked at the call site once passed here.\n */\n component?: C\n /**\n * Orientates the image to the top or bottom of the card as an \"image cap\", or to the start/end\n * for a horizontal layout. Omit to round all four corners for use inside `CardBody`. An object\n * sets the orientation from a breakpoint up — e.g. `{ base: 'top', lg: 'start' }` to switch an\n * image cap from `top` to `start` once the card lays out horizontally.\n */\n orientation?: Responsive<CardImageOrientation>\n}\n\nexport type CardImageProps<C extends ElementType = 'img'> = PolymorphicComponentProps<\n C,\n CardImageOwnProps<C>\n>\n\ntype CardImageComponent = (<C extends ElementType = 'img'>(\n props: CardImageProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nconst orientationClassName = (orientation: CardImageOrientation, prefix: string) =>\n `${prefix}card-image-${orientation}`\n\nfunction CardImageRender<C extends ElementType = 'img'>(\n { children, className, component, orientation, ...rest }: CardImageProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'img'\n const _className = classNames(\n // With no orientation at the base, the image is the plain one of `CardBody`.\n baseValue(orientation) === undefined && 'card-image',\n responsiveClassNames([responsiveProp(orientation, orientationClassName)]),\n className\n )\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardImage = createPolymorphicComponent<CardImageComponent>(\n CardImageRender as ForwardRefRenderFunction<Element, CardImageProps<ElementType>>,\n 'CardImage'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardSubtitleOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardSubtitleProps<C extends ElementType = 'h6'> = PolymorphicComponentProps<\n C,\n CardSubtitleOwnProps<C>\n>\n\ntype CardSubtitleComponent = (<C extends ElementType = 'h6'>(\n props: CardSubtitleProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardSubtitleRender<C extends ElementType = 'h6'>(\n { children, component, className, ...rest }: CardSubtitleProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'h6'\n const _className = classNames('card-subtitle', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardSubtitle = createPolymorphicComponent<CardSubtitleComponent>(\n CardSubtitleRender as ForwardRefRenderFunction<Element, CardSubtitleProps<ElementType>>,\n 'CardSubtitle'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardTextOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardTextProps<C extends ElementType = 'p'> = PolymorphicComponentProps<\n C,\n CardTextOwnProps<C>\n>\n\ntype CardTextComponent = (<C extends ElementType = 'p'>(\n props: CardTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardTextRender<C extends ElementType = 'p'>(\n { children, component, className, ...rest }: CardTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'p'\n const _className = classNames('card-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardText = createPolymorphicComponent<CardTextComponent>(\n CardTextRender as ForwardRefRenderFunction<Element, CardTextProps<ElementType>>,\n 'CardText'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardTitleOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardTitleProps<C extends ElementType = 'h5'> = PolymorphicComponentProps<\n C,\n CardTitleOwnProps<C>\n>\n\ntype CardTitleComponent = (<C extends ElementType = 'h5'>(\n props: CardTitleProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardTitleRender<C extends ElementType = 'h5'>(\n { children, component, className, ...rest }: CardTitleProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'h5'\n const _className = classNames('card-title', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardTitle = createPolymorphicComponent<CardTitleComponent>(\n CardTitleRender as ForwardRefRenderFunction<Element, CardTitleProps<ElementType>>,\n 'CardTitle'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement, ReactNode } from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor, ContextStyle, Responsive, Sizing } from '../../types'\nimport {\n flexDirectionClassName,\n FlexDirection,\n responsiveClassNames,\n responsiveProp\n} from '../../utils/breakpoints'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { CardBody } from './CardBody'\nimport { CardFooter } from './CardFooter'\nimport { CardImage } from './CardImage'\nimport { CardSubtitle } from './CardSubtitle'\nimport { CardText } from './CardText'\nimport { CardTitle } from './CardTitle'\n\ntype CardOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Switches the card from its default stacked (column) layout to a side-by-side (row) layout.\n * Give the image and the body a width utility (`w-4/12`, `w-8/12`) to control each side's\n * width. An object sets the direction from a breakpoint up — e.g. `{ lg: 'row' }` to lay the\n * card out horizontally from `lg` up while stacking below it.\n */\n direction?: Responsive<FlexDirection>\n /**\n * Shorthand for a `CardFooter`, rendered after the image/title/subtitle/text/`children` block.\n */\n footer?: ReactNode\n /**\n * Shorthand for a `CardImage` — pass either a `src` URL (combine with `imageAlt`/\n * `imageOrientation`) or a fully-formed element — a `<CardImage>`, `<Skeleton>`,\n * `<Placeholder>`, or anything else — rendered as-is in its place. `imageAlt`/`imageOrientation`\n * only apply to the `src` form; set them directly on your own element otherwise. For a\n * horizontal layout or an overlay, omit this and compose `CardImage` directly as a child\n * instead.\n */\n image?: ReactNode\n /**\n * Accessible alt text for `image`. Ignored unless `image` is set.\n */\n imageAlt?: string\n /**\n * Orientates `image` to the top (default) or bottom of the card.\n */\n imageOrientation?: 'top' | 'bottom'\n /**\n * Sets the size of the component to one of Chassis component sizes.\n */\n size?: Sizing\n /**\n * Shorthand for a `CardSubtitle`, rendered directly after `title`.\n */\n subtitle?: ReactNode\n /**\n * Shorthand for a `CardText`, rendered after `title`/`subtitle`.\n */\n text?: ReactNode\n /**\n * Shorthand for a `CardTitle`. Set alongside `subtitle`/`text` (or plain `children`, e.g. a\n * `Button`) to build a standard card without composing `CardBody`/`CardTitle` yourself — all\n * render together inside a single `CardBody`, in that order. Only takes effect when at least\n * one of `image`/`title`/`subtitle`/`text`/`footer` is set; otherwise `children` render as-is,\n * so full manual composition (`CardHeader`, lists, overlays, nav headers, …) keeps working\n * unchanged. Mixing shorthand props with a manually-composed `children` tree isn't supported —\n * pick one approach per card.\n */\n title?: ReactNode\n /**\n * Sets the context style of the component. `basic` (the default) renders with no extra class.\n */\n variant?: ContextStyle\n}\n\nexport type CardProps<C extends ElementType = 'div'> = PolymorphicComponentProps<C, CardOwnProps<C>>\n\ntype CardComponent = (<C extends ElementType = 'div'>(\n props: CardProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardRender<C extends ElementType = 'div'>(\n {\n children,\n className,\n color,\n component,\n direction,\n footer,\n image,\n imageAlt,\n imageOrientation = 'top',\n size,\n subtitle,\n text,\n title,\n variant,\n ...rest\n }: CardProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames(\n 'card',\n color,\n {\n context: !!color,\n solid: variant === 'solid',\n smooth: variant === 'smooth',\n outline: variant === 'outline',\n sm: size === 'sm',\n lg: size === 'lg'\n },\n responsiveClassNames([responsiveProp(direction, flexDirectionClassName)]),\n className\n )\n\n const hasShorthand =\n image != null || title != null || subtitle != null || footer != null || text != null\n const hasBodyContent = title != null || subtitle != null || text != null || children != null\n const renderedImage =\n typeof image === 'string' ? (\n <CardImage orientation={imageOrientation} src={image} alt={imageAlt ?? ''} />\n ) : (\n image\n )\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {hasShorthand ? (\n <>\n {image != null && imageOrientation === 'top' && renderedImage}\n {hasBodyContent && (\n <CardBody>\n {title != null && <CardTitle>{title}</CardTitle>}\n {subtitle != null && <CardSubtitle>{subtitle}</CardSubtitle>}\n {text != null && <CardText>{text}</CardText>}\n {children}\n </CardBody>\n )}\n {image != null && imageOrientation === 'bottom' && renderedImage}\n {footer != null && <CardFooter>{footer}</CardFooter>}\n </>\n ) : (\n children\n )}\n </Component>\n )\n}\n\nexport const Card = createPolymorphicComponent<CardComponent>(\n CardRender as ForwardRefRenderFunction<Element, CardProps<ElementType>>,\n 'Card'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardGroupOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardGroupProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardGroupOwnProps<C>\n>\n\ntype CardGroupComponent = (<C extends ElementType = 'div'>(\n props: CardGroupProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\n// Arranges direct-child Cards as an equal-width row, joined edge-to-edge, once its container\n// reaches the sm container breakpoint — below that, cards stack vertically. Requires a\n// `.contains-inline` ancestor (not applied by CardGroup itself, e.g. a wrapping\n// `<div className=\"contains-inline\">`) to establish the container query context.\nfunction CardGroupRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardGroupProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-group', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardGroup = createPolymorphicComponent<CardGroupComponent>(\n CardGroupRender as ForwardRefRenderFunction<Element, CardGroupProps<ElementType>>,\n 'CardGroup'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardHeaderOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardHeaderProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardHeaderOwnProps<C>\n>\n\ntype CardHeaderComponent = (<C extends ElementType = 'div'>(\n props: CardHeaderProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardHeaderRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardHeaderProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-header', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardHeader = createPolymorphicComponent<CardHeaderComponent>(\n CardHeaderRender as ForwardRefRenderFunction<Element, CardHeaderProps<ElementType>>,\n 'CardHeader'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype CardImageOverlayOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type CardImageOverlayProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardImageOverlayOwnProps<C>\n>\n\ntype CardImageOverlayComponent = (<C extends ElementType = 'div'>(\n props: CardImageOverlayProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardImageOverlayRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: CardImageOverlayProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('card-overlay', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const CardImageOverlay = createPolymorphicComponent<CardImageOverlayComponent>(\n CardImageOverlayRender as ForwardRefRenderFunction<Element, CardImageOverlayProps<ElementType>>,\n 'CardImageOverlay'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { createPolymorphicComponent, PolymorphicRef } from '../../utils/polymorphic'\nimport { Link, LinkProps } from '../link/Link'\n\ntype CardLinkOwnProps = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n}\n\nexport type CardLinkProps<C extends ElementType = 'a'> = LinkProps<C> & CardLinkOwnProps\n\ntype CardLinkComponent = (<C extends ElementType = 'a'>(\n props: CardLinkProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction CardLinkRender<C extends ElementType = 'a'>(\n { children, className, ...rest }: CardLinkProps<C>,\n ref: PolymorphicRef<C>\n) {\n const _className = classNames('card-link', className)\n\n return (\n <Link\n className={_className}\n {...(rest as Record<string, unknown>)}\n ref={ref as PolymorphicRef<ElementType>}\n >\n {children}\n </Link>\n )\n}\n\nexport const CardLink = createPolymorphicComponent<CardLinkComponent>(\n CardLinkRender as ForwardRefRenderFunction<Element, CardLinkProps<ElementType>>,\n 'CardLink'\n)\n"],"mappings":"sRAoDA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,YAAW,MAAK,GAAG,GACrD,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAa,EACjB,YACA,EAAqB,CAAC,EAAe,EAAW,CAAsB,CAAC,CAAC,EACxE,EAAiB,MAAO,CAAG,EAC3B,CACF,EAEA,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAW,EACtB,EACA,UACF,EC7CA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,GAAG,GACrC,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAa,EAAW,cAAe,CAAS,EAEtD,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAa,EACxB,EACA,YACF,ECJM,GAAwB,EAAmC,IAC/D,GAAG,EAAO,aAAa,IAEzB,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,cAAa,GAAG,GAClD,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAa,EAEjB,EAAU,CAAW,IAAM,IAAA,IAAa,aACxC,EAAqB,CAAC,EAAe,EAAa,CAAoB,CAAC,CAAC,EACxE,CACF,EAEA,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAY,EACvB,EACA,WACF,ECtCA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,GAAG,GACrC,EACA,CACA,IAAM,EAAY,GAAa,KACzB,EAAa,EAAW,gBAAiB,CAAS,EAExD,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAe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
|
+
const e={default:`bg-default`,alternate:`bg-alternate`,primary:`bg-primary`,secondary:`bg-secondary`,neutral:`bg-neutral`,success:`bg-success`,danger:`bg-danger`,warning:`bg-warning`,info:`bg-info`,black:`bg-black`,white:`bg-white`},t={default:`fg-default`,alternate:`fg-alternate`,primary:`fg-primary`,secondary:`fg-secondary`,neutral:`fg-neutral`,success:`fg-success`,danger:`fg-danger`,warning:`fg-warning`,info:`fg-info`,black:`fg-black`,white:`fg-white`},n={default:`icon-default`,alternate:`icon-alternate`,primary:`icon-primary`,secondary:`icon-secondary`,neutral:`icon-neutral`,success:`icon-success`,danger:`icon-danger`,warning:`icon-warning`,info:`icon-info`,black:`icon-black`,white:`icon-white`},r={default:`link-default`,alternate:`link-alternate`,primary:`link-primary`,secondary:`link-secondary`,neutral:`link-neutral`,success:`link-success`,danger:`link-danger`,warning:`link-warning`,info:`link-info`,black:`link-black`,white:`link-white`};export{r as i,t as n,n as r,e as t};
|
|
2
|
+
//# sourceMappingURL=colorClassNames-CEh5Yzfp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorClassNames-CEh5Yzfp.js","names":[],"sources":["../../src/utils/colorClassNames.ts"],"sourcesContent":["import { ContextColor } from '../types'\n\n// The class of a context color, per family, as whole names: never `bg-${color}`.\n//\n// In the Tailwind entry of chassis-css these are utilities, generated only where Tailwind's\n// scanner finds the full class name in a source file, and it cannot read a name joined at\n// runtime: the class would have no rule, with no warning. A whole name in `dist` is found once a\n// project registers the package with `@source`. `test/utils/tailwindClassNames.spec.tsx` fails on\n// a utility name built from parts anywhere in `src/`.\n//\n// `Record<ContextColor, string>` fails the type check when a color joins the type and not a table.\n\nexport const BG_COLOR_CLASS_NAMES: Record<ContextColor, string> = {\n default: 'bg-default',\n alternate: 'bg-alternate',\n primary: 'bg-primary',\n secondary: 'bg-secondary',\n neutral: 'bg-neutral',\n success: 'bg-success',\n danger: 'bg-danger',\n warning: 'bg-warning',\n info: 'bg-info',\n black: 'bg-black',\n white: 'bg-white'\n}\n\nexport const FG_COLOR_CLASS_NAMES: Record<ContextColor, string> = {\n default: 'fg-default',\n alternate: 'fg-alternate',\n primary: 'fg-primary',\n secondary: 'fg-secondary',\n neutral: 'fg-neutral',\n success: 'fg-success',\n danger: 'fg-danger',\n warning: 'fg-warning',\n info: 'fg-info',\n black: 'fg-black',\n white: 'fg-white'\n}\n\nexport const ICON_COLOR_CLASS_NAMES: Record<ContextColor, string> = {\n default: 'icon-default',\n alternate: 'icon-alternate',\n primary: 'icon-primary',\n secondary: 'icon-secondary',\n neutral: 'icon-neutral',\n success: 'icon-success',\n danger: 'icon-danger',\n warning: 'icon-warning',\n info: 'icon-info',\n black: 'icon-black',\n white: 'icon-white'\n}\n\nexport const LINK_COLOR_CLASS_NAMES: Record<ContextColor, string> = {\n default: 'link-default',\n alternate: 'link-alternate',\n primary: 'link-primary',\n secondary: 'link-secondary',\n neutral: 'link-neutral',\n success: 'link-success',\n danger: 'link-danger',\n warning: 'link-warning',\n info: 'link-info',\n black: 'link-black',\n white: 'link-white'\n}\n"],"mappings":"AAYA,MAAa,EAAqD,CAChE,QAAS,aACT,UAAW,eACX,QAAS,aACT,UAAW,eACX,QAAS,aACT,QAAS,aACT,OAAQ,YACR,QAAS,aACT,KAAM,UACN,MAAO,WACP,MAAO,UACT,EAEa,EAAqD,CAChE,QAAS,aACT,UAAW,eACX,QAAS,aACT,UAAW,eACX,QAAS,aACT,QAAS,aACT,OAAQ,YACR,QAAS,aACT,KAAM,UACN,MAAO,WACP,MAAO,UACT,EAEa,EAAuD,CAClE,QAAS,eACT,UAAW,iBACX,QAAS,eACT,UAAW,iBACX,QAAS,eACT,QAAS,eACT,OAAQ,cACR,QAAS,eACT,KAAM,YACN,MAAO,aACP,MAAO,YACT,EAEa,EAAuD,CAClE,QAAS,eACT,UAAW,iBACX,QAAS,eACT,UAAW,iBACX,QAAS,eACT,QAAS,eACT,OAAQ,cACR,QAAS,eACT,KAAM,YACN,MAAO,aACP,MAAO,YACT"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import"./focus-ring-SR_LwaN7.js";import{t as e}from"./useForkedRef-DVEfT-KI.js";import{n as t}from"./lazyElement-tfMG21pZ.js";import{t as n}from"./tableClassName-DleBjOj2.js";import r,{forwardRef as i,useEffect as a,useId as o,useMemo as s,useRef as c,useState as l}from"react";import u from"classnames";import{useCheckbox as d}from"react-aria";import{useToggleState as f}from"react-stately";import{Cell as p,CheckboxContext as m,Column as h,Row as g,Table as _,TableBody as v,TableHeader as y,TableLayout as b,TableLoadMoreItem as x,Virtualizer as S,useSlottedContext as C}from"react-aria-components";const w=/^\d+(\.\d+)?%?$/,T=e=>e!=null&&(typeof e==`number`||w.test(e)),E=(e,t)=>typeof e==`number`?e:e.endsWith(`%`)?parseFloat(e)/100*t:parseFloat(e);function D(e,t){let n=new Map,r=0,i=!0;for(let a of e){if(!i||!T(a.defaultWidth)){i=!1,n.set(a.id,null);continue}let e=E(a.defaultWidth,t);T(a.minWidth)&&(e=Math.max(e,E(a.minWidth,t))),T(a.maxWidth)&&(e=Math.min(e,E(a.maxWidth,t))),n.set(a.id,{id:a.id,offset:r,width:e}),r+=e}return n}const O=e=>{let t=new Map;return e.querySelectorAll(`[role="columnheader"]`).forEach(e=>{let n=Number(e.getAttribute(`aria-colindex`));!Number.isInteger(n)||n<1||t.set(n-1,{offset:e.offsetLeft,width:e.offsetWidth})}),t};function k(e,t){let[n,r]=l(0),[i,o]=l(()=>new Map);a(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=()=>{r(e.clientWidth),o(O(e))};n();let i=new ResizeObserver(n);return i.observe(e),()=>i.disconnect()},[t]);let c=s(()=>D(e,n),[e,n]);return s(()=>{let t=new Map;return e.forEach((e,n)=>{let r=c.get(e.id),a=i.get(n);r?t.set(e.id,r):a&&t.set(e.id,{id:e.id,...a})}),t},[e,c,i])}const A=e=>`[aria-colindex="${e+1}"]`,j=({header:e,instanceClassName:n,containerRef:i})=>{let o=t(e).props.children,c=s(()=>typeof o==`function`?[]:r.Children.toArray(o),[o]),l=c.map(e=>{if(!r.isValidElement(e))return``;let{defaultWidth:t,maxWidth:n,minWidth:i,pin:a}=e.props;return`${t??``}/${i??``}/${n??``}/${a??``}`}).join(`|`),{all:u,endIndices:d,startIndices:f}=s(()=>{let e={all:[],endIndices:[],startIndices:[]};return c.forEach((t,n)=>{if(!r.isValidElement(t))return;let{defaultWidth:i,maxWidth:a,minWidth:o,pin:s}=t.props;e.all.push({id:n,defaultWidth:i,maxWidth:a,minWidth:o}),s===`start`?e.startIndices.push(n):s===`end`&&e.endIndices.push(n)}),e},[l]),p=k(u,i),m=s(()=>{let e=new Map,t=0;for(let n=d.length-1;n>=0;n--){let r=d[n];if(r==null)continue;let i=p.get(r)?.width??0;e.set(r,{index:r,rightOffset:t}),t+=i}return e},[d,p]);if(a(()=>{let e=i.current;if(!e||m.size===0)return;let t=null,n=new Set,r=()=>{t=null;let r=e.clientWidth,i=e.scrollLeft;e.querySelectorAll(`[role="row"]`).forEach(e=>{m.forEach(({index:t,rightOffset:a})=>{let o=e.querySelector(A(t))?.parentElement;if(!o)return;let s=p.get(t);if(!s)return;let c=s.offset+s.width,l=r-a-c+i;o.style.transform=`translateX(${l}px)`,o.style.zIndex=`2`,n.add(o)})})},a=()=>{t??=requestAnimationFrame(r)};a(),e.addEventListener(`scroll`,a,{passive:!0});let o=typeof ResizeObserver>`u`?null:new ResizeObserver(a);o?.observe(e);let s=typeof MutationObserver>`u`?null:new MutationObserver(a);return s?.observe(e,{childList:!0,subtree:!0}),()=>{t!=null&&cancelAnimationFrame(t),e.removeEventListener(`scroll`,a),o?.disconnect(),s?.disconnect(),n.forEach(e=>{e.style.transform=``,e.style.zIndex=``})}},[i,m,p]),f.length===0&&d.length===0)return null;let h=[];if(f.length>0){let e=Math.max(...f);h.push(`.${n}.datagrid-scrolled-start ${A(e)} { box-shadow: var(--datagrid-pin-cue-shadow-start); }`)}if(d.length>0){let e=Math.min(...d);h.push(`.${n}.datagrid-scrolled-end ${A(e)} { box-shadow: var(--datagrid-pin-cue-shadow-end); }`)}return r.createElement(`style`,null,h.join(`
|
|
2
|
+
`))};var M=class extends b{isStickyColumn(e){let t=e.type===`column`?e.index:e.colIndex??e.index;return t!=null&&this.collection.columns[t]?.props?.pin===`start`}buildRowGroup(...e){let t=super.buildRowGroup(...e);return t.layoutInfo.rect.height=Math.max(0,t.layoutInfo.rect.height),t}};const N=i(({align:t,bordered:i,borderless:d,children:f,className:p,color:m,disabledKeys:h,estimatedRowHeight:g,footer:v,hover:y,onSelectionChange:b,onSortChange:x,rowHeight:C,selectedKeys:w,selectionMode:T=`none`,sm:E,sortDescriptor:D,...O},k)=>{let A=C===`auto`,N=s(()=>new M(A?{estimatedRowHeight:g,headingHeight:g}:{rowHeight:C}),[A,C,g]),P=c(null),F=e(k,P),I=`datagrid-${o().replace(/[^a-zA-Z0-9]/g,``)}`,[L,R]=l(!1),[z,B]=l(!1);a(()=>{let e=P.current;if(!e)return;let t=()=>{R(e.scrollLeft>0),B(Math.ceil(e.scrollLeft+e.clientWidth)<e.scrollWidth)};t(),e.addEventListener(`scroll`,t,{passive:!0});let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),()=>{e.removeEventListener(`scroll`,t),n?.disconnect()}},[]);let V=u(`datagrid`,I,m,t&&n[t],{bordered:i,borderless:d,hoverable:y,sm:E,"datagrid-scrolled-start":L,"datagrid-scrolled-end":z},p);return r.createElement(S,{layout:N,shouldObserveItemSize:A},r.createElement(_,{"aria-label":O[`aria-label`],"aria-labelledby":O[`aria-labelledby`],className:V||void 0,disabledKeys:h,onSelectionChange:b,onSortChange:x,ref:F,selectedKeys:w,selectionMode:T,sortDescriptor:D,render:e=>r.createElement(`div`,{...e,"aria-describedby":e[`aria-describedby`]||void 0})},f),v&&r.createElement(`div`,{className:u(`datagrid-footer`,{borderless:d})},v),r.createElement(j,{containerRef:P,header:f[0],instanceClassName:I}))});N.displayName=`DataGrid`;const P={id:`__datagrid-body-loader__`},F=({children:e,className:t,dependencies:n,isLoading:i,items:a,loadingContent:o,onLoadMore:c,renderEmptyState:l})=>{let d=c!=null&&a!=null,f=s(()=>d?[...a,P]:a,[d,a]),p=s(()=>d?[...n??[],i,c,o]:n,[n,d,i,c,o]),m=d?t=>t===P?r.createElement(x,{className:`datagrid-loader`,isLoading:i,onLoadMore:i?void 0:c},o):e(t):e;return r.createElement(v,{className:u(`datagrid-body`,t),dependencies:p,items:f,renderEmptyState:l},m)},I=({children:e,className:t,colSpan:n,id:i,textValue:a})=>r.createElement(p,{className:u(`datagrid-cell`,t),colSpan:n,id:i,textValue:a},e),L=({allowsSorting:e,children:t,className:n,defaultWidth:i,id:a,isRowHeader:o,maxWidth:s,minWidth:c,pin:l,textValue:d})=>r.createElement(h,{allowsSorting:e,className:u(`datagrid-col`,l&&`datagrid-col-pinned-${l}`,n),defaultWidth:i,id:a,isRowHeader:o,maxWidth:s,minWidth:c,textValue:d,pin:l},e?({sortDirection:e})=>r.createElement(r.Fragment,null,t,r.createElement(`span`,{"aria-hidden":`true`,className:`datagrid-sort-icon`},e===`ascending`?`▲`:e===`descending`?`▼`:`⇅`)):t),R=({children:e,className:t,columns:n,dependencies:i})=>r.createElement(y,{className:u(`datagrid-header`,t),columns:n,dependencies:i},e),z=({children:e,className:t,columns:n,id:i,textValue:a})=>r.createElement(g,{className:u(`datagrid-row`,t),columns:n,id:i,textValue:a},e),B=e=>{let t=C(m,`selection`);if(!t)throw Error(`${e} must be rendered inside a DataGrid with selection enabled.`);return t},V=({className:e})=>{let t=B(`DataGridSelectionCell`);return r.createElement(U,{checkboxProps:t,className:e})},H=({className:e})=>{let t=B(`DataGridSelectAllCell`);return r.createElement(U,{checkboxProps:t,className:e})},U=({checkboxProps:e,className:t})=>{let n=f(e),i=c(null),{inputProps:a}=d(e,n,i);return r.createElement(`input`,{...a,"aria-describedby":void 0,className:t??`check-input`,ref:i})};export{L as a,N as c,R as i,V as n,I as o,z as r,F as s,H as t};
|
|
3
|
+
//# sourceMappingURL=datagrid-DOYxx0sF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datagrid-DOYxx0sF.js","names":["AriaTable","AriaTableBody","AriaCell","AriaColumn","AriaTableHeader","AriaRow"],"sources":["../../src/components/datagrid/useColumnGeometry.ts","../../src/components/datagrid/DataGridPinBehavior.tsx","../../src/components/datagrid/DataGridTableLayout.ts","../../src/components/datagrid/DataGrid.tsx","../../src/components/datagrid/DataGridBody.tsx","../../src/components/datagrid/DataGridCell.tsx","../../src/components/datagrid/DataGridColumn.tsx","../../src/components/datagrid/DataGridHeader.tsx","../../src/components/datagrid/DataGridRow.tsx","../../src/components/datagrid/DataGridSelectionCell.tsx"],"sourcesContent":["import { RefObject, useEffect, useMemo, useState } from 'react'\nimport { Key } from 'react-aria-components'\nimport { ColumnSize, ColumnStaticSize } from 'react-stately'\n\nexport interface ColumnGeometryColumn {\n /**\n * The column's unique id — matches `DataGridColumn`'s `id`/collection key.\n */\n id: Key\n /**\n * Mirrors `DataGridColumn`'s prop of the same name.\n */\n defaultWidth?: ColumnSize | null\n /**\n * Mirrors `DataGridColumn`'s prop of the same name.\n */\n minWidth?: ColumnStaticSize | null\n /**\n * Mirrors `DataGridColumn`'s prop of the same name.\n */\n maxWidth?: ColumnStaticSize | null\n}\n\nexport interface ColumnOffset {\n id: Key\n /**\n * Cumulative distance in pixels from the start edge of the row to this column's start edge.\n */\n offset: number\n width: number\n}\n\nconst STATIC_SIZE_PATTERN = /^\\d+(\\.\\d+)?%?$/\n\n/**\n * Whether a `ColumnSize` resolves to a definite pixel value without waiting for layout: a plain\n * number, a numeric string (`'150'`), or a percentage string (`'50%'`) — resolvable as soon as\n * the container's own width is known. An `'<n>fr'` string is proportional — it only resolves to\n * pixels once the layout engine has distributed the container's remaining space among every\n * fractional column, so it's excluded here.\n */\nexport const isStaticColumnSize = (size: ColumnSize | null | undefined): size is ColumnStaticSize =>\n size != null && (typeof size === 'number' || STATIC_SIZE_PATTERN.test(size))\n\nconst resolveStaticWidth = (size: ColumnStaticSize, containerWidth: number): number => {\n if (typeof size === 'number') return size\n return size.endsWith('%') ? (parseFloat(size) / 100) * containerWidth : parseFloat(size)\n}\n\n/**\n * Computes cumulative left-edge offsets for a list of columns from their declared\n * `defaultWidth`/`minWidth`/`maxWidth` props, without reading the DOM. Only correct for a column\n * whose own width — and every preceding column's width — is statically resolvable (see\n * `isStaticColumnSize`): a column at or after the first `fr`-sized column has no offset that can\n * be known before layout runs, so it resolves to `null`. Callers should fall back to\n * `useColumnGeometry`'s DOM measurement for those.\n */\nexport function calculateStaticColumnOffsets(\n columns: readonly ColumnGeometryColumn[],\n containerWidth: number\n): Map<Key, ColumnOffset | null> {\n const offsets = new Map<Key, ColumnOffset | null>()\n let offset = 0\n let resolvable = true\n\n for (const column of columns) {\n if (!resolvable || !isStaticColumnSize(column.defaultWidth)) {\n resolvable = false\n offsets.set(column.id, null)\n continue\n }\n\n let width = resolveStaticWidth(column.defaultWidth, containerWidth)\n if (isStaticColumnSize(column.minWidth)) {\n width = Math.max(width, resolveStaticWidth(column.minWidth, containerWidth))\n }\n if (isStaticColumnSize(column.maxWidth)) {\n width = Math.min(width, resolveStaticWidth(column.maxWidth, containerWidth))\n }\n\n offsets.set(column.id, { id: column.id, offset, width })\n offset += width\n }\n\n return offsets\n}\n\ninterface MeasuredRect {\n offset: number\n width: number\n}\n\n/**\n * Measures the mounted column-header cells, keyed by their 0-based column position.\n *\n * Keyed off each cell's own `aria-colindex` (1-based, assigned from the column's position in the\n * resolved collection) rather than its position among the cells that happen to be in the DOM: the\n * layout engine windows columns horizontally as well as rows, so `querySelectorAll` returns only\n * the headers intersecting the horizontal viewport. Matching those positionally to the full column\n * list — as this used to — mapped every column past the first unmounted one onto the wrong rect.\n * A header without the attribute is skipped rather than guessed at.\n */\nconst measureColumnHeaders = (container: HTMLElement): Map<number, MeasuredRect> => {\n const measured = new Map<number, MeasuredRect>()\n container.querySelectorAll<HTMLElement>('[role=\"columnheader\"]').forEach((cell) => {\n const colIndex = Number(cell.getAttribute('aria-colindex'))\n if (!Number.isInteger(colIndex) || colIndex < 1) return\n measured.set(colIndex - 1, { offset: cell.offsetLeft, width: cell.offsetWidth })\n })\n return measured\n}\n\n/**\n * Resolves each column's rendered left-offset and width, independent of the virtualizer's\n * private layout internals. Statically-sized columns (see `isStaticColumnSize`) resolve\n * immediately from their declared props; `fr`-sized (proportional) columns fall back to\n * `ResizeObserver`-measured DOM rects of the mounted `[role=\"columnheader\"]` cells inside\n * `containerRef`, matched to `columns` by `aria-colindex` (see `measureColumnHeaders`), since\n * those only resolve to real pixels after the layout engine has actually distributed space.\n */\nexport function useColumnGeometry(\n columns: readonly ColumnGeometryColumn[],\n containerRef: RefObject<HTMLElement | null>\n): Map<Key, ColumnOffset> {\n const [containerWidth, setContainerWidth] = useState(0)\n const [measured, setMeasured] = useState<Map<number, MeasuredRect>>(() => new Map())\n\n useEffect(() => {\n const container = containerRef.current\n if (!container || typeof ResizeObserver === 'undefined') return\n\n const measure = () => {\n setContainerWidth(container.clientWidth)\n setMeasured(measureColumnHeaders(container))\n }\n\n measure()\n const observer = new ResizeObserver(measure)\n observer.observe(container)\n return () => observer.disconnect()\n }, [containerRef])\n\n const staticOffsets = useMemo(\n () => calculateStaticColumnOffsets(columns, containerWidth),\n [columns, containerWidth]\n )\n\n return useMemo(() => {\n const result = new Map<Key, ColumnOffset>()\n columns.forEach((column, index) => {\n const staticOffset = staticOffsets.get(column.id)\n const measuredRect = measured.get(index)\n if (staticOffset) {\n result.set(column.id, staticOffset)\n } else if (measuredRect) {\n result.set(column.id, { id: column.id, ...measuredRect })\n }\n })\n return result\n }, [columns, staticOffsets, measured])\n}\n","import React, { ReactElement, RefObject, useEffect, useMemo } from 'react'\n\nimport { resolveLazy } from '../../utils/lazyElement'\nimport { DataGridColumnProps } from './DataGridColumn'\nimport { DataGridHeaderProps } from './DataGridHeader'\nimport { ColumnGeometryColumn, useColumnGeometry } from './useColumnGeometry'\n\nexport interface DataGridPinBehaviorProps<T> {\n /**\n * The same header element passed as `DataGrid`'s first child. Read directly (rather than via\n * `TableStateContext`) because react-aria-components' virtualized `<Table>` only ever renders\n * DOM output for its own collection-derived tree — an arbitrary extra child (like this\n * component, if it were nested inside `<Table>`) never mounts, regardless of context\n * availability. Only the static-children form of `DataGridHeader` can be introspected this\n * way; the `columns`/render-function form gets no pinned-column behavior from here (`pin=\n * \"start\"`'s positioning still works either way — see `DataGridTableLayout`, which reads pin\n * state off the resolved collection instead, not off this introspection).\n */\n header: ReactElement<DataGridHeaderProps<T>>\n /**\n * A CSS class unique to this `DataGrid` instance, scoping the generated rules below so\n * multiple grids on the same page (with different pinned columns) don't collide.\n */\n instanceClassName: string\n /**\n * Ref to `DataGrid`'s own scrolling root — used both to measure `fr`-sized pinned columns via\n * `useColumnGeometry` and, for `pin=\"end\"`, to find and reposition its cells on scroll (see\n * below).\n */\n containerRef: RefObject<HTMLElement | null>\n}\n\ninterface PinnedColumnInfo {\n index: number\n /** Cumulative width of the end-pinned columns after this one — its distance from the edge. */\n rightOffset: number\n}\n\ninterface DeclaredColumns {\n all: ColumnGeometryColumn[]\n endIndices: number[]\n startIndices: number[]\n}\n\n/**\n * A cell's (1-based) `aria-colindex` for the (0-based) column position it was declared at.\n *\n * Every cell and column header react-aria-components renders carries `aria-colindex`, set from the\n * column's position in the resolved collection — which is the declaration order this component\n * reads off the header's JSX. That makes it the one stable handle from a declared column back to\n * its rendered DOM, and the reason nothing here counts DOM children: the layout engine windows\n * columns horizontally as well as rows (only the cells intersecting the horizontal viewport are\n * mounted, see `datagrid.mdx`'s Scope section), so a row's child count is the size of the mounted\n * window, not the column count. The `nth-child`/`nth-last-child` arithmetic this used to do was\n * therefore only correct while every column happened to be mounted, and silently moved and\n * shadowed the wrong cells in exactly the wide grids pinning exists for.\n */\nconst colIndexSelector = (index: number) => `[aria-colindex=\"${index + 1}\"]`\n\n/**\n * Handles the two things `DataGrid`'s own layout subclass (`DataGridTableLayout`) can't:\n *\n * - `pin=\"end\"`'s positioning. `DataGridTableLayout` reuses the layout engine's own sticky\n * mechanism for `pin=\"start\"`, but that mechanism is hardcoded to the leading edge — there's no\n * upstream hook for a trailing-edge pin. A pure-CSS `position: sticky; right: 0` equivalent\n * doesn't work either: for the *last* child of a horizontally-scrolling container, the browser's\n * own max-scroll bound is defined such that its gap to the viewport's trailing edge never goes\n * negative until the very last pixel of scroll — sticky has nothing to correct until then, so it\n * renders exactly like `position: absolute` for the entire scroll range up to that point (this is\n * a well-known, verified-here CSS limitation, not specific to this layout). So `pin=\"end\"` is\n * positioned imperatively instead: on every scroll (and on mount/resize), each `pin=\"end\"`\n * column's auto-generated wrapper div gets a `transform: translateX(...)` that keeps it flush\n * against the scroll viewport's trailing edge, computed from `useColumnGeometry`'s cumulative\n * offsets, plus the `z-index` that keeps it above the cells it now overlaps. This bypasses React\n * for those two styles, similar to how other virtualized grids (e.g. AG-Grid) handle right-pinned\n * columns — react-aria-components' own layout doesn't re-render an already-mounted cell's style on\n * a plain scroll (its `layoutInfo` doesn't depend on scroll position), so there's no fight between\n * this and React's own reconciliation; newly-mounted rows (from vertical scroll bringing fresh\n * cells into the virtualized window) are covered by the same scroll-driven sync running again.\n * - The scroll-cue box-shadow on the boundary column of each pinned group (the last `pin=\"start\"`\n * column, the first `pin=\"end\"` column) — shown only once the grid has actually scrolled far\n * enough to hide content under it, via the `datagrid-scrolled-start`/`datagrid-scrolled-end`\n * classes `DataGrid` toggles on scroll. This part stays pure CSS since box-shadow, unlike\n * sticky's position offsets, has no \"last child\" gotcha.\n *\n * Rendered as a plain sibling of `DataGrid`'s `<Table>`, not inside it.\n */\nexport const DataGridPinBehavior = <T extends object>({\n header,\n instanceClassName,\n containerRef\n}: DataGridPinBehaviorProps<T>) => {\n // A header written in a Server Component can arrive as a lazy node (see `utils/lazyElement`).\n const headerChildren = resolveLazy(header).props.children\n\n // Re-derived only when a column's own sizing/pin props actually change, not on every parent\n // render: `useColumnGeometry` keys its memoized result off this array's identity, and the\n // scroll-sync effect below keys off that result in turn — rebuilding it unconditionally tore\n // down and re-registered the effect's scroll listener and its two observers on every single\n // `DataGrid` render.\n const columnElements = useMemo(\n () => (typeof headerChildren === 'function' ? [] : React.Children.toArray(headerChildren)),\n [headerChildren]\n )\n const declaredKey = columnElements\n .map((element) => {\n if (!React.isValidElement<DataGridColumnProps>(element)) return ''\n const { defaultWidth, maxWidth, minWidth, pin } = element.props\n return `${defaultWidth ?? ''}/${minWidth ?? ''}/${maxWidth ?? ''}/${pin ?? ''}`\n })\n .join('|')\n\n const {\n all: allColumns,\n endIndices,\n startIndices\n } = useMemo<DeclaredColumns>(() => {\n const declared: DeclaredColumns = { all: [], endIndices: [], startIndices: [] }\n columnElements.forEach((element, index) => {\n if (!React.isValidElement<DataGridColumnProps>(element)) return\n const { defaultWidth, maxWidth, minWidth, pin } = element.props\n declared.all.push({ id: index, defaultWidth, maxWidth, minWidth })\n if (pin === 'start') declared.startIndices.push(index)\n else if (pin === 'end') declared.endIndices.push(index)\n })\n return declared\n // `declaredKey` is the value-based identity of `columnElements` — a fresh JSX array every\n // render, so its own reference can't be the dependency.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [declaredKey])\n\n const offsets = useColumnGeometry(allColumns, containerRef)\n\n // Cumulative width of the end-pinned columns after this one, keyed by column index — how far\n // from the viewport's trailing edge each one needs to sit so they stack correctly.\n const endPinnedInfo = useMemo(() => {\n const info = new Map<number, PinnedColumnInfo>()\n let right = 0\n for (let i = endIndices.length - 1; i >= 0; i--) {\n const index = endIndices[i]\n if (index == null) continue\n const width = offsets.get(index)?.width ?? 0\n info.set(index, { index, rightOffset: right })\n right += width\n }\n return info\n }, [endIndices, offsets])\n\n useEffect(() => {\n const container = containerRef.current\n if (!container || endPinnedInfo.size === 0) return\n\n let frame: number | null = null\n // The wrappers this effect has written inline styles onto, so they can be handed back\n // unstyled when it tears down — un-pinning a column at runtime (or unmounting this behavior\n // while the grid stays) otherwise left its cells stuck at their last scroll offset.\n const styled = new Set<HTMLElement>()\n\n const sync = () => {\n frame = null\n const clientWidth = container.clientWidth\n const scrollLeft = container.scrollLeft\n const rows = container.querySelectorAll<HTMLElement>('[role=\"row\"]')\n rows.forEach((row) => {\n endPinnedInfo.forEach(({ index, rightOffset }) => {\n const cell = row.querySelector<HTMLElement>(colIndexSelector(index))\n const wrapper = cell?.parentElement\n if (!wrapper) return\n const offset = offsets.get(index)\n if (!offset) return\n const rightEdge = offset.offset + offset.width\n const delta = clientWidth - rightOffset - rightEdge + scrollLeft\n wrapper.style.transform = `translateX(${delta}px)`\n // Above the unpinned cells it now overlaps. Set here rather than in the generated\n // stylesheet below because the virtualizer writes the wrapper's own `z-index` inline,\n // which no plain rule can outrank without `!important`.\n wrapper.style.zIndex = '2'\n styled.add(wrapper)\n })\n })\n }\n\n const scheduleSync = () => {\n if (frame == null) frame = requestAnimationFrame(sync)\n }\n\n scheduleSync()\n container.addEventListener('scroll', scheduleSync, { passive: true })\n const resizeObserver =\n typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(scheduleSync)\n resizeObserver?.observe(container)\n const mutationObserver =\n typeof MutationObserver === 'undefined' ? null : new MutationObserver(scheduleSync)\n mutationObserver?.observe(container, { childList: true, subtree: true })\n\n return () => {\n if (frame != null) cancelAnimationFrame(frame)\n container.removeEventListener('scroll', scheduleSync)\n resizeObserver?.disconnect()\n mutationObserver?.disconnect()\n styled.forEach((wrapper) => {\n wrapper.style.transform = ''\n wrapper.style.zIndex = ''\n })\n }\n }, [containerRef, endPinnedInfo, offsets])\n\n if (startIndices.length === 0 && endIndices.length === 0) return null\n\n const rules: string[] = []\n\n if (startIndices.length > 0) {\n const lastStartIndex = Math.max(...startIndices)\n rules.push(\n `.${instanceClassName}.datagrid-scrolled-start ${colIndexSelector(lastStartIndex)} { box-shadow: var(--datagrid-pin-cue-shadow-start); }`\n )\n }\n\n if (endIndices.length > 0) {\n const firstEndIndex = Math.min(...endIndices)\n rules.push(\n `.${instanceClassName}.datagrid-scrolled-end ${colIndexSelector(firstEndIndex)} { box-shadow: var(--datagrid-pin-cue-shadow-end); }`\n )\n }\n\n return <style>{rules.join('\\n')}</style>\n}\n","import { TableLayout } from 'react-aria-components'\n\ninterface StickyColumnNode {\n type: string\n index: number\n colIndex?: number | null\n}\n\n/**\n * `DataGrid`'s own subclass of react-aria-components' `TableLayout`, overriding the (protected,\n * hardcoded-`false` upstream) `isStickyColumn` hook so a `pin=\"start\"` `DataGridColumn` uses the\n * layout engine's own sticky-positioning machinery — the same mechanism that already makes the\n * header row pin to the top (`buildTableHeader` sets `layoutInfo.isSticky = true` unconditionally\n * there). The subclass exists instead of a pure-CSS `position: sticky` override because\n * react-aria-components' own `TableLayout` never overrides `isStickyColumn`, so no column becomes\n * visually sticky by default — and because the engine, not CSS, owns each cell wrapper's `left`.\n *\n * `pin=\"end\"` isn't handled here — the engine's sticky positioning is hardcoded to the leading\n * edge (`position: sticky; left: ...`, mirrored to `right` only for RTL *direction*, never per\n * column), so there's no upstream mechanism to reuse for a trailing pin in an LTR grid. See\n * `DataGrid.scss`'s `nth-last-child`-based rules for that half instead.\n */\nexport class DataGridTableLayout<T> extends TableLayout<T> {\n protected isStickyColumn(node: StickyColumnNode): boolean {\n const colIndex = node.type === 'column' ? node.index : (node.colIndex ?? node.index)\n if (colIndex == null) return false\n const column = this.collection.columns[colIndex]\n return (column?.props as { pin?: 'start' | 'end' } | undefined)?.pin === 'start'\n }\n\n // An empty body fills the viewport below the header. On the server the viewport has no size,\n // so the body came out as tall as minus the header (`height: -40px`), which CSS doesn't allow.\n protected buildRowGroup(...args: Parameters<TableLayout<T>['buildRowGroup']>) {\n const group = super.buildRowGroup(...args)\n group.layoutInfo.rect.height = Math.max(0, group.layoutInfo.rect.height)\n return group\n }\n}\n","import React, {\n ReactElement,\n ReactNode,\n Ref,\n forwardRef,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState\n} from 'react'\nimport classNames from 'classnames'\nimport {\n Key,\n Selection,\n SortDescriptor,\n Table as AriaTable,\n Virtualizer\n} from 'react-aria-components'\n\nimport { useForkedRef } from '../../hooks/useForkedRef'\nimport { ContextColor } from '../../types'\nimport { TABLE_ALIGN_CLASS_NAMES } from '../../utils/tableClassName'\nimport { DataGridBodyProps } from './DataGridBody'\nimport { DataGridHeaderProps } from './DataGridHeader'\nimport { DataGridPinBehavior } from './DataGridPinBehavior'\nimport { DataGridTableLayout } from './DataGridTableLayout'\nimport './DataGrid.scss'\n\n// No `striped`/`stacked` props: zebra-striping via CSS `:nth-of-type` (Table's approach) isn't\n// virtualization-safe — a windowed row's DOM siblings are only the currently-mounted rows, not\n// every logical row, so the stripe parity would flip as the mounted window's starting index\n// changes during scroll. A correct implementation needs the row's real index at render time, not\n// a pure-CSS trick; deferred rather than shipped broken.\ninterface DataGridOwnProps<T extends object> {\n /**\n * An accessible label for the grid, used when there's no visible heading.\n */\n 'aria-label'?: string\n /**\n * Identifies a visible heading element for the grid.\n */\n 'aria-labelledby'?: string\n /**\n * Set the vertical alignment of cell content. Mirrors `Table`'s prop of the same name for API\n * parity — same as `Table`, this awaits chassis-css adding the matching `.align-*` styles.\n */\n align?: 'bottom' | 'middle' | 'top'\n /**\n * Add borders on all sides of the grid and cells.\n */\n bordered?: boolean\n /**\n * Remove borders on all sides of the grid and cells.\n */\n borderless?: boolean\n /**\n * A `DataGridHeader` and a `DataGridBody`, each built from `DataGridColumn`/`DataGridRow`/\n * `DataGridCell`.\n */\n children: [ReactElement<DataGridHeaderProps<T>>, ReactElement<DataGridBodyProps<T>>]\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Sets the color of the component.\n */\n color?: ContextColor\n /**\n * A list of row keys to disable. Disabled rows cannot be selected, focused, or interacted with.\n */\n disabledKeys?: Iterable<Key>\n /**\n * Content shown below the grid, e.g. a totals row or a \"load more\" control. Rendered as plain\n * markup outside the grid's own scrollable/virtualized region — not part of the\n * keyboard-navigable grid, and never scrolls out of view along with the body rows. Mirrors\n * `Table`'s `footer` prop for API parity.\n */\n footer?: ReactNode\n /**\n * Enable a hover state on grid rows.\n */\n hover?: boolean\n /**\n * Handler that is called when the selection changes.\n */\n onSelectionChange?: (keys: Selection) => void\n /**\n * Handler that is called when a column is sorted.\n */\n onSortChange?: (descriptor: SortDescriptor) => void\n /**\n * The currently selected row keys (controlled).\n */\n selectedKeys?: Selection\n /**\n * The type of selection that is allowed.\n */\n selectionMode?: 'none' | 'single' | 'multiple'\n /**\n * Make the grid more compact by cutting all cell padding.\n */\n sm?: boolean\n /**\n * The current sort column and direction.\n */\n sortDescriptor?: SortDescriptor\n}\n\ntype DataGridRowHeightProps =\n | {\n /**\n * Row height in pixels, or `\"auto\"` to measure each row from its own rendered content\n * instead of a single fixed height shared by every row (pair it with a required\n * `estimatedRowHeight`, and see the docs site's \"Variable row height\" section for the\n * tradeoffs). A fixed number renders every row, including the header, at that exact\n * height; content taller than it visually overflows rather than growing the row.\n */\n rowHeight: number\n estimatedRowHeight?: never\n }\n | {\n rowHeight: 'auto'\n /**\n * Seeds the virtualizer's scroll-position math for rows that haven't been measured yet.\n * Required when `rowHeight=\"auto\"` — pick a value close to the typical row's real height\n * to minimize scroll-jump on first measurement. A row's real height can still turn out far\n * from this estimate once it renders, which can cause a visible scroll-jump for rows the\n * viewport hasn't reached yet.\n */\n estimatedRowHeight: number\n }\n\nexport type DataGridProps<T extends object> = DataGridOwnProps<T> & DataGridRowHeightProps\n\nconst DataGridInner = <T extends object>(\n {\n align,\n bordered,\n borderless,\n children,\n className,\n color,\n disabledKeys,\n estimatedRowHeight,\n footer,\n hover,\n onSelectionChange,\n onSortChange,\n rowHeight,\n selectedKeys,\n selectionMode = 'none',\n sm,\n sortDescriptor,\n ...rest\n }: DataGridProps<T>,\n forwardedRef: Ref<HTMLDivElement>\n) => {\n const isVariableRowHeight = rowHeight === 'auto'\n const layout = useMemo(\n () =>\n new DataGridTableLayout<T>(\n // `headingHeight` is pinned to `estimatedRowHeight` (fixed, not itself an estimate) in\n // variable-height mode — leaving it unset falls back to `estimatedRowHeight` as an\n // *estimate* for the header too, which sounds harmless but isn't: the header's own\n // sticky-positioned outer wrapper (built once in `buildTableHeader`, see\n // `DataGridTableLayout`'s doc comment for why the header is sticky at all) is never\n // recomputed when a column-header cell's later real measurement corrects its height, so\n // the outer wrapper's stale height desyncs from the cell's real one, spilling header\n // content into the body's first row instead of the header growing to fit it. Fixing the\n // header's height sidesteps that gap instead of shipping it.\n isVariableRowHeight\n ? { estimatedRowHeight, headingHeight: estimatedRowHeight }\n : { rowHeight }\n ),\n [isVariableRowHeight, rowHeight, estimatedRowHeight]\n )\n const gridRef = useRef<HTMLDivElement>(null)\n const ref = useForkedRef(forwardedRef, gridRef)\n\n // A stable per-instance class, scoping DataGridPinBehavior's generated CSS so multiple grids on\n // the same page (each with their own pinned columns) don't collide.\n const rawId = useId()\n const instanceClassName = `datagrid-${rawId.replace(/[^a-zA-Z0-9]/g, '')}`\n\n // Drives the pin=start/pin=end scroll-cue box-shadow — see DataGridPinBehavior — which should\n // only appear once there's actually hidden content under the pinned column to cue.\n const [scrolledStart, setScrolledStart] = useState(false)\n const [scrolledEnd, setScrolledEnd] = useState(false)\n\n useEffect(() => {\n const grid = gridRef.current\n if (!grid) return\n\n const updateScrollState = () => {\n setScrolledStart(grid.scrollLeft > 0)\n setScrolledEnd(Math.ceil(grid.scrollLeft + grid.clientWidth) < grid.scrollWidth)\n }\n\n updateScrollState()\n grid.addEventListener('scroll', updateScrollState, { passive: true })\n const observer =\n typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(updateScrollState)\n observer?.observe(grid)\n return () => {\n grid.removeEventListener('scroll', updateScrollState)\n observer?.disconnect()\n }\n }, [])\n\n const _className = classNames(\n 'datagrid',\n instanceClassName,\n color,\n align && TABLE_ALIGN_CLASS_NAMES[align],\n {\n bordered,\n borderless,\n hoverable: hover,\n sm,\n 'datagrid-scrolled-start': scrolledStart,\n 'datagrid-scrolled-end': scrolledEnd\n },\n className\n )\n\n return (\n <Virtualizer layout={layout} shouldObserveItemSize={isVariableRowHeight}>\n <AriaTable\n aria-label={rest['aria-label']}\n aria-labelledby={rest['aria-labelledby']}\n className={_className || undefined}\n disabledKeys={disabledKeys}\n onSelectionChange={onSelectionChange}\n onSortChange={onSortChange}\n ref={ref}\n selectedKeys={selectedKeys}\n selectionMode={selectionMode}\n sortDescriptor={sortDescriptor}\n // react-aria joins the grid's descriptions without dropping an empty result, so a grid\n // with none had `aria-describedby=\"\"`.\n render={(props) => (\n <div\n {...(props as React.ComponentProps<'div'>)}\n aria-describedby={props['aria-describedby'] || undefined}\n />\n )}\n >\n {children}\n </AriaTable>\n {footer && <div className={classNames('datagrid-footer', { borderless })}>{footer}</div>}\n <DataGridPinBehavior\n containerRef={gridRef}\n header={children[0]}\n instanceClassName={instanceClassName}\n />\n </Virtualizer>\n )\n}\n\n// `forwardRef` erases type parameters, so the generic component is cast back to a generic\n// signature for callers — same pattern `Table` uses.\nexport const DataGrid = forwardRef(DataGridInner) as <T extends object>(\n props: DataGridProps<T> & { ref?: Ref<HTMLDivElement> }\n) => ReactElement\n\n;(DataGrid as { displayName?: string }).displayName = 'DataGrid'\n","import React, { ReactElement, ReactNode, useMemo } from 'react'\nimport classNames from 'classnames'\nimport {\n TableBody as AriaTableBody,\n TableBodyRenderProps,\n TableLoadMoreItem\n} from 'react-aria-components'\n\n// A unique value appended to `items` internally to represent the trailing \"load more\" row in\n// react-aria-components' collection. `TableLoadMoreItem` has to be returned from the per-item\n// render function like any other row — react-aria-components' `useCachedChildren` only supports\n// EITHER `items` + a render function OR static `children`, never a mix of both in the same\n// `children` prop, so a `<TableLoadMoreItem>` placed as a plain JSX sibling inside `<TableBody>`\n// is silently dropped (or crashes, if `children` becomes an array mixing the render function in).\n// Checked by reference (`item === LOADER_ITEM`), so it can never collide with a real `T` the way a\n// `{ __loader: true }` marker object might if compared structurally. Its `id` matters too, not\n// just its identity: react-aria-components derives each rendered item's React key from\n// `rendered.props.id ?? item?.key ?? item?.id ?? <positional index>` (`useCachedChildren`) —\n// `TableLoadMoreItem` doesn't accept an `id` prop itself, so without this object's own `id` the\n// loader's key falls back to its position in the array, which collides with a real row whenever a\n// row's own `id` happens to equal that count (e.g. a 2-item list with a row literally id `\"2\"`).\nconst LOADER_ITEM = { id: '__datagrid-body-loader__' }\n\ninterface DataGridBodyOwnProps {\n /**\n * A string of all className you want applied to the body row group.\n */\n className?: string\n /**\n * Values that should invalidate the row cache when using the `items`/render-function form of\n * `children` — e.g. a value from outside `items` that the render function reads. Without this,\n * changing that outside value won't re-render already-cached rows, since dynamic rows are only\n * rebuilt when `items` or `dependencies` change by reference, not on every parent re-render.\n */\n dependencies?: ReadonlyArray<unknown>\n /**\n * Content shown in place of rows when `items` is empty.\n */\n renderEmptyState?: (props: TableBodyRenderProps) => React.ReactNode\n}\n\n/**\n * The `items` + render-function form. `isLoading`/`loadingContent`/`onLoadMore` live here rather\n * than alongside the static form because the loader row is generated by appending to `items` and\n * rendering through that same function — there's no growing dataset to load more of, and nothing\n * to render the loader with, in a hand-written list of `DataGridRow` elements.\n */\ninterface DataGridBodyDynamicProps<T> {\n /**\n * A render function called once per item in `items`, returning that row's `DataGridRow`.\n */\n children: (item: T) => ReactElement\n /**\n * Whether more items are currently being fetched. Shows `loadingContent` in the loader row while\n * true, and — until this goes back to `false` — suppresses further `onLoadMore` calls, so one\n * scroll-into-view doesn't fire the callback again before the in-flight fetch resolves.\n */\n isLoading?: boolean\n /**\n * A list of row data objects, rendered via the function form of `children`.\n */\n items: Iterable<T>\n /**\n * Content rendered inside the loader row while `isLoading` is true, e.g. a spinner. Only takes\n * effect alongside `onLoadMore`.\n */\n loadingContent?: ReactNode\n /**\n * Called when the grid scrolls near its last row, so more data can be fetched and appended to\n * `items`. Pair with `isLoading` so a fetch already in flight isn't triggered again before it\n * resolves.\n */\n onLoadMore?: () => void\n}\n\n/** The static form: `DataGridRow` elements written out directly. */\ninterface DataGridBodyStaticProps {\n /**\n * `DataGridRow` elements.\n */\n children: ReactElement | ReactElement[]\n isLoading?: never\n items?: never\n loadingContent?: never\n onLoadMore?: never\n}\n\n/**\n * Split into a static and a dynamic form so the two can't be mixed: the loader row is appended to\n * `items` and rendered through `children`, so `onLoadMore` alongside a static list of elements used\n * to type-check and then throw at render (\"children is not a function\") the moment the loader row\n * came up.\n */\nexport type DataGridBodyProps<T> = DataGridBodyOwnProps &\n (DataGridBodyDynamicProps<T> | DataGridBodyStaticProps)\n\n/**\n * Body row group for `DataGrid`, containing `DataGridRow`s. Unlike `Table`'s sub-parts, this\n * renders directly — it's a thin wrapper over react-aria-components' own `TableBody`.\n *\n * Always carries the `datagrid-body` class — see `DataGridHeader`'s equivalent note.\n */\nexport const DataGridBody = <T extends object>({\n children,\n className,\n dependencies,\n isLoading,\n items,\n loadingContent,\n onLoadMore,\n renderEmptyState\n}: DataGridBodyProps<T>) => {\n const hasLoader = onLoadMore != null && items != null\n\n const itemsWithLoader = useMemo(() => {\n if (!hasLoader) return items\n return [...(items as Iterable<T>), LOADER_ITEM] as Iterable<T>\n }, [hasLoader, items])\n\n // react-aria-components caches each rendered row by item identity (see `dependencies`'s own doc\n // comment above) — the loader branch below reads `isLoading`/`onLoadMore`/`loadingContent`, none\n // of which are part of `items`, so without surfacing them here the cached loader row would keep\n // whatever `isLoading` value (and stale `onLoadMore` closure) was in scope the first time it\n // rendered, never picking up a later change.\n const dependenciesWithLoader = useMemo(\n () =>\n hasLoader ? [...(dependencies ?? []), isLoading, onLoadMore, loadingContent] : dependencies,\n [dependencies, hasLoader, isLoading, onLoadMore, loadingContent]\n )\n\n const bodyChildren = hasLoader\n ? (item: T) =>\n (item as unknown) === LOADER_ITEM ? (\n <TableLoadMoreItem\n className=\"datagrid-loader\"\n isLoading={isLoading}\n // Suppresses re-triggering onLoadMore while a fetch is already in flight — the\n // underlying sentinel has no built-in debounce of its own and calls onLoadMore again\n // whenever it (re-)observes the sentinel still intersecting, e.g. after the collection\n // changes but the loader row hasn't yet scrolled out of view.\n onLoadMore={isLoading ? undefined : onLoadMore}\n >\n {loadingContent}\n </TableLoadMoreItem>\n ) : (\n // `hasLoader` implies the dynamic form of the props union, whose `children` is the\n // render function — `onLoadMore` isn't assignable alongside static children.\n (children as (item: T) => ReactElement)(item)\n )\n : children\n\n return (\n <AriaTableBody\n className={classNames('datagrid-body', className)}\n dependencies={dependenciesWithLoader}\n items={itemsWithLoader}\n renderEmptyState={renderEmptyState}\n >\n {bodyChildren}\n </AriaTableBody>\n )\n}\n","import React, { ReactNode } from 'react'\nimport { Key, Cell as AriaCell } from 'react-aria-components'\nimport classNames from 'classnames'\n\nexport interface DataGridCellProps {\n /**\n * The contents of the cell.\n */\n children: ReactNode\n /**\n * A string of all className you want applied to the cell.\n */\n className?: string\n /**\n * Indicates how many columns the cell spans.\n */\n colSpan?: number\n /**\n * The unique id of the cell.\n */\n id?: Key\n /**\n * A string representation of the cell's contents, used for typeahead.\n */\n textValue?: string\n}\n\n/**\n * A cell within a `DataGrid` row. Unlike `Table`'s sub-parts, this renders directly — it's a\n * thin wrapper over react-aria-components' own `Cell`.\n */\nexport const DataGridCell = ({\n children,\n className,\n colSpan,\n id,\n textValue\n}: DataGridCellProps) => (\n <AriaCell\n className={classNames('datagrid-cell', className)}\n colSpan={colSpan}\n id={id}\n textValue={textValue}\n >\n {children}\n </AriaCell>\n)\n","import React, { ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { Key, Column as AriaColumn } from 'react-aria-components'\nimport { ColumnSize, ColumnStaticSize } from 'react-stately'\n\nexport interface DataGridColumnProps {\n /**\n * Whether the column allows sorting. Adds a sort indicator and makes the header\n * clickable/keyboard-activatable.\n */\n allowsSorting?: boolean\n /**\n * Rendered contents of the column header.\n */\n children: ReactNode\n /**\n * A string of all className you want applied to the column header.\n */\n className?: string\n /**\n * The initial width of the column, e.g. for a narrow selection/icon column — a plain number or\n * `'<n>%'` for a fixed size, or `'<n>fr'` to share remaining space with other fractional\n * columns in proportion (columns default to `'1fr'`, so they split space evenly unless given\n * one of these). Unlike `Table`, which sizes a narrow column via `width: 1%` relying on native\n * `<table>` auto-layout, `DataGrid`'s virtualized layout computes every column's width itself —\n * a CSS `width` rule on the cell has no effect, so this prop is the only way to size a column.\n */\n defaultWidth?: ColumnSize | null\n /**\n * The unique id of the column, referenced by `sortDescriptor.column`.\n */\n id?: Key\n /**\n * Whether this column is a row header, announced by assistive technology during row\n * navigation.\n */\n isRowHeader?: boolean\n /**\n * The maximum width of the column, as a fixed pixel number or `'<n>%'`.\n */\n maxWidth?: ColumnStaticSize | null\n /**\n * The minimum width of the column, as a fixed pixel number or `'<n>%'`.\n */\n minWidth?: ColumnStaticSize | null\n /**\n * Pin the column so it stays visible while the grid scrolls horizontally: `'start'` pins it to\n * the leading edge, `'end'` to the trailing edge. Stacks correctly with other pinned columns on\n * the same side, in declaration order.\n */\n pin?: 'start' | 'end'\n /**\n * A string representation of the column header, used for accessibility announcements. Defaults\n * to `children` when it's a plain string — set this explicitly when the header contains\n * anything else (an icon, a `Tooltip`, etc.).\n */\n textValue?: string\n}\n\n/**\n * A column within `DataGrid`. Unlike `Table`'s sub-parts, this renders directly — it's a thin\n * wrapper over react-aria-components' own `Column`.\n *\n * When `allowsSorting` is set, renders a sort indicator after `children` — mirrors `Table`'s own\n * `TableColumnHeader`, but reads the active direction from react-aria-components' own\n * `ColumnRenderProps` (via the `children` render-prop form) instead of reaching into table state\n * directly, since this wrapper has no state of its own to read.\n */\nexport const DataGridColumn = ({\n allowsSorting,\n children,\n className,\n defaultWidth,\n id,\n isRowHeader,\n maxWidth,\n minWidth,\n pin,\n textValue\n}: DataGridColumnProps) => (\n <AriaColumn\n allowsSorting={allowsSorting}\n className={classNames('datagrid-col', pin && `datagrid-col-pinned-${pin}`, className)}\n defaultWidth={defaultWidth}\n id={id}\n isRowHeader={isRowHeader}\n maxWidth={maxWidth}\n minWidth={minWidth}\n textValue={textValue}\n // `pin` isn't a react-aria-components `Column` prop, but its collection builder preserves\n // the full props object it's given verbatim (see react-stately's `Column.getCollectionNode`)\n // — passing it through here is what makes it reach `column.props.pin` in\n // `DataGridTableLayout`'s `isStickyColumn` override, which is what positions `pin=\"start\"`.\n // `pin=\"end\"` is handled separately by `DataGridPinBehavior`, which reads the same prop off\n // the header's JSX rather than the resolved collection.\n {...({ pin } as Record<string, unknown>)}\n >\n {allowsSorting\n ? ({ sortDirection }) => (\n <>\n {children}\n <span aria-hidden=\"true\" className=\"datagrid-sort-icon\">\n {sortDirection === 'ascending' ? '▲' : sortDirection === 'descending' ? '▼' : '⇅'}\n </span>\n </>\n )\n : children}\n </AriaColumn>\n)\n","import React, { ReactElement, ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { TableHeader as AriaTableHeader } from 'react-aria-components'\n\nexport interface DataGridHeaderProps<T> {\n /**\n * `DataGridColumn` elements, or a render function paired with `columns` for dynamic column\n * generation.\n */\n children: ReactNode | ((column: T) => ReactElement)\n /**\n * A string of all className you want applied to the header row group.\n */\n className?: string\n /**\n * A list of column data objects, rendered via the function form of `children`.\n */\n columns?: Iterable<T>\n /**\n * Values that should invalidate the column cache when using the `columns`/render-function form\n * of `children` — see `DataGridBody`'s `dependencies` for why this matters.\n */\n dependencies?: ReadonlyArray<unknown>\n}\n\n/**\n * Header row group for `DataGrid`, containing `DataGridColumn`s. Unlike `Table`'s sub-parts,\n * this renders directly — it's a thin wrapper over react-aria-components' own `TableHeader`.\n *\n * Always carries the `datagrid-header` class (not just the caller's `className`) — `DataGrid.scss`\n * uses it to tell header cells from body cells, since react-aria-components renders both as plain\n * `[role=\"rowgroup\"]` divs with no structural difference to select on otherwise.\n */\nexport const DataGridHeader = <T extends object>({\n children,\n className,\n columns,\n dependencies\n}: DataGridHeaderProps<T>) => (\n <AriaTableHeader\n className={classNames('datagrid-header', className)}\n columns={columns}\n dependencies={dependencies}\n >\n {children}\n </AriaTableHeader>\n)\n","import React, { ReactElement, ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { Key, Row as AriaRow } from 'react-aria-components'\n\nexport interface DataGridRowProps<T> {\n /**\n * `DataGridCell` elements, or a render function called once per column with that column's\n * data — required when the row's parent `DataGridBody` uses the `items`/render-function form.\n */\n children: ReactNode | ((column: T) => ReactElement)\n /**\n * A string of all className you want applied to the row.\n */\n className?: string\n /**\n * A list of column data objects, rendered via the function form of `children`.\n */\n columns?: Iterable<T>\n /**\n * The unique id of the row, referenced by `selectedKeys`/`disabledKeys`.\n */\n id?: Key\n /**\n * A string representation of the row's contents, used for typeahead.\n */\n textValue?: string\n}\n\n/**\n * A row within `DataGrid`. Unlike `Table`'s sub-parts, this renders directly — it's a thin\n * wrapper over react-aria-components' own `Row`.\n */\nexport const DataGridRow = <T extends object>({\n children,\n className,\n columns,\n id,\n textValue\n}: DataGridRowProps<T>) => (\n <AriaRow\n className={classNames('datagrid-row', className)}\n columns={columns}\n id={id}\n textValue={textValue}\n >\n {children}\n </AriaRow>\n)\n","import React, { useRef } from 'react'\nimport { AriaCheckboxProps, useCheckbox } from 'react-aria'\nimport { useToggleState } from 'react-stately'\nimport { CheckboxContext, CheckboxProps, useSlottedContext } from 'react-aria-components'\n\nexport interface DataGridSelectionCellProps {\n /**\n * A string of all className you want applied to the checkbox, replacing the default\n * `check-input`.\n */\n className?: string\n}\n\n/**\n * Reads the selection checkbox props react-aria-components' own `Row`/`TableHeader` publish on\n * `CheckboxContext`'s `selection` slot — the same ones its `<Checkbox slot=\"selection\">` would\n * consume, already carrying the localized label, the row-header `aria-labelledby`, and the\n * selected/disabled/indeterminate state.\n *\n * Reading them off that context (rather than calling react-aria's `useTableSelectionCheckbox`/\n * `useTableSelectAllCheckbox` against `TableStateContext` ourselves, as this file used to) is what\n * keeps this working when more than one copy of `react-aria` is installed. Those hooks resolve the\n * grid's id through a module-scoped `WeakMap` that only `useTable` populates, in whichever copy\n * ran it — always the copy bundled inside `react-aria-components` here, since its `Table` is what\n * calls `useTable`. `react-aria-components` pins `react-aria` to an exact version, so a consumer\n * whose own `react-aria` resolves anywhere else in our `^` range gets a second copy and the lookup\n * throws `Error: Unknown grid` on every selection cell. Letting react-aria-components compute the\n * props in its own copy sidesteps that entirely, and drops the duplicated `rowKey` this component\n * used to need — the context is already scoped to the row it's rendered in, so a `rowKey` that\n * disagreed with the surrounding `DataGridRow` can no longer silently toggle a different row.\n */\nconst useSelectionCheckboxProps = (component: string): AriaCheckboxProps => {\n const props = useSlottedContext(CheckboxContext, 'selection') as CheckboxProps | null | undefined\n if (!props) {\n throw new Error(`${component} must be rendered inside a DataGrid with selection enabled.`)\n }\n return props as AriaCheckboxProps\n}\n\n/**\n * Selection checkbox for one `DataGrid` row — place inside a `DataGridCell`.\n *\n * react-aria-components' own `Checkbox` always visually hides its native `<input>` behind a custom\n * indicator the caller must supply. This renders a plain native `<input className=\"check-input\">`\n * instead, wired to the same state, so it picks up chassis-css's existing checkbox styling for\n * free with no new CSS of its own.\n */\nexport const DataGridSelectionCell = ({ className }: DataGridSelectionCellProps) => {\n const checkboxProps = useSelectionCheckboxProps('DataGridSelectionCell')\n return <DataGridCheckboxInput checkboxProps={checkboxProps} className={className} />\n}\n\n/**\n * \"Select all\" checkbox for `DataGrid`'s header row — place inside a `DataGridColumn`. See\n * `DataGridSelectionCell` for why this bypasses react-aria-components' own `Checkbox`.\n */\nexport const DataGridSelectAllCell = ({ className }: DataGridSelectionCellProps) => {\n const checkboxProps = useSelectionCheckboxProps('DataGridSelectAllCell')\n return <DataGridCheckboxInput checkboxProps={checkboxProps} className={className} />\n}\n\nconst DataGridCheckboxInput = ({\n checkboxProps,\n className\n}: {\n checkboxProps: AriaCheckboxProps\n className?: string\n}) => {\n const toggleState = useToggleState(checkboxProps)\n const ref = useRef<HTMLInputElement>(null)\n const { inputProps } = useCheckbox(checkboxProps, toggleState, ref)\n\n // `aria-describedby` after the spread: react-aria's own adds ids it never renders (FORMS.md,\n // gotcha 6).\n return (\n <input\n {...inputProps}\n aria-describedby={undefined}\n className={className ?? 'check-input'}\n ref={ref}\n />\n )\n}\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nC,CAAE,cAAe,EAAY,EAAe,EAAa,CAAG,EAIlE,OACE,EAAA,cAAC,QAAD,CACE,GAAI,EACJ,mBAAkB,IAAA,GAClB,UAAW,GAAa,cACnB,KACN,CAAA,CAEL"}
|
|
@@ -17,7 +17,7 @@ type SpinnerOwnProps<C extends ElementType> = {
|
|
|
17
17
|
*/
|
|
18
18
|
component?: C;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Renders a smaller spinner, with the `spinner-sm` class.
|
|
21
21
|
*/
|
|
22
22
|
size?: 'sm';
|
|
23
23
|
/**
|
|
@@ -38,4 +38,4 @@ type SpinnerComponent = (<C extends ElementType = 'div'>(props: SpinnerProps<C>
|
|
|
38
38
|
declare const Spinner: SpinnerComponent;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { SpinnerProps as n, Spinner as t };
|
|
41
|
-
//# sourceMappingURL=index-
|
|
41
|
+
//# sourceMappingURL=index-Dzga1f4w.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{d as e,f as t,g as n,h as r,m as i,p as a,u as o}from"./slot-CNhFZdHF.js";import{t as s}from"./lazyElement-tfMG21pZ.js";import{t as c}from"./polymorphic-BhGNZQja.js";import{t as l}from"./Link-
|
|
2
|
-
//# sourceMappingURL=list-
|
|
1
|
+
import"./focus-ring-SR_LwaN7.js";import{d as e,f as t,g as n,h as r,m as i,p as a,u as o}from"./slot-CNhFZdHF.js";import{t as s}from"./lazyElement-tfMG21pZ.js";import{t as c}from"./polymorphic-BhGNZQja.js";import{t as l}from"./Link-DyZyAQFj.js";import u,{Children as d}from"react";import f from"classnames";function p({children:r,active:i,className:o,disabled:s,color:c,component:d,href:p,...m},h){let g=a(d,p,`li`),_=n(g,p,m),v=t(_),y=e(_,p,`ListItem`),b=f(`list-item`,c&&`context`,c,{"list-action":v,active:i&&!v,disabled:s&&!v},o),x=v?l:g,S=v?{active:i,disabled:s,component:g,...y,...m}:{...i&&{"aria-current":`page`},...s&&{"aria-disabled":!0},...y,...m};return u.createElement(x,{className:b,...S,ref:h},r)}const m=c(p,`ListItem`);function h({children:e,className:n,component:c,color:l,variant:p,flush:h,items:g,layout:_,numbered:v,plain:y,...b},x){let S=g?g.some(e=>o(e.href)):d.toArray(e).some(e=>s(e,m)&&t(r(e.props))),C=c??(S?`div`:`ul`),w=i(C),T=w===`ul`||w===`ol`,E=f(`list`,l&&`context`,l,p,_,{flush:h,plain:y,numbered:v},n),D=(g?g.map((e,t)=>{let n=f(`list-item`,e.color&&`context`,e.color,{"list-action":o(e.href),active:e.active,disabled:e.disabled}),r=a(void 0,e.href,T?`li`:`div`);return u.createElement(r,{key:e.id??t,className:n,...o(e.href)&&{href:e.href},...e.active?{"aria-current":`page`}:{},...e.disabled?{"aria-disabled":!0}:{}},e.label)}):null)??(T?e:d.map(e,e=>s(e,m)&&r(e.props)===void 0?u.cloneElement(e,{component:`div`}):e));return u.createElement(C,{className:E,...b,ref:x},D)}const g=c(h,`List`);export{m as n,g as t};
|
|
2
|
+
//# sourceMappingURL=list-07e2a1Ym.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-BQCkwWjF.js","names":[],"sources":["../../src/components/list/ListItem.tsx","../../src/components/list/List.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor } from '../../types'\nimport { hrefProps, isInteractiveKind, linkElement, resolveLinkKind } from '../../utils/elementKind'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n PolymorphicRefWithFallback\n} from '../../utils/polymorphic'\nimport { Link } from '../link/Link'\n\ntype ListItemOwnProps<C extends ElementType> = {\n /**\n * Toggle the active state for the component.\n */\n active?: boolean\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Toggle the disabled state for the component.\n */\n disabled?: boolean\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * The href attribute specifies the URL of the page the link goes to. Renders an `<a>` in place\n * of the `<li>`, unless `component` or `asChild` chose the element. Inside a `List`, the list\n * renders a `<div>` around it in place of the `<ul>`.\n */\n href?: string\n}\n\nexport type ListItemProps<C extends ElementType = 'li'> = PolymorphicComponentProps<\n C,\n ListItemOwnProps<C>\n>\n\ntype ListItemComponent = (<C extends ElementType = 'li'>(\n props: ListItemProps<C> & {\n ref?: PolymorphicRefWithFallback<C, HTMLLIElement | HTMLAnchorElement>\n }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ListItemRender<C extends ElementType = 'li'>(\n { children, active, className, disabled, color, component, href, ...rest }: ListItemProps<C>,\n ref: PolymorphicRef<C>\n) {\n // `href` makes it an `<a>`, unless `component` or `asChild` chose the element (see\n // `linkElement`). It used to stay an `<li>` and carry `href` as an attribute.\n const tag = linkElement(component, href, 'li')\n // The kind rather than the tag, counting a router link with `href` or `to` as an anchor: under `asChild`, `tag` is a `Slot` standing in for the caller's\n // element, and a slotted `<a>` is as interactive as `component=\"a\"`.\n const kind = resolveLinkKind(tag, href, rest)\n const isInteractive = isInteractiveKind(kind)\n const linkProps = hrefProps(kind, href, 'ListItem')\n\n const _className = classNames(\n 'list-item',\n color && 'context',\n color,\n {\n 'list-action': isInteractive,\n // An interactive item renders through `Link`, which adds these classes and their ARIA\n // attributes itself.\n active: active && !isInteractive,\n disabled: disabled && !isInteractive\n },\n className\n )\n\n const Component = (isInteractive ? Link : tag) as ElementType\n\n const finalRest = isInteractive\n ? { active, disabled, component: tag, ...linkProps, ...rest }\n : {\n ...(active && { 'aria-current': 'page' }),\n ...(disabled && { 'aria-disabled': true }),\n ...linkProps,\n ...rest\n }\n\n return (\n <Component className={_className} {...finalRest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const ListItem = createPolymorphicComponent<ListItemComponent>(\n ListItemRender as ForwardRefRenderFunction<Element, ListItemProps<ElementType>>,\n 'ListItem'\n)\n","import React, {\n Children,\n ElementType,\n ForwardRefRenderFunction,\n ReactElement,\n ReactNode\n} from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor, ContextStyle } from '../../types'\nimport {\n hasHref,\n isInteractiveKind,\n linkElement,\n resolveElementTag,\n resolveKindFromProps\n} from '../../utils/elementKind'\nimport { isElementOfType } from '../../utils/lazyElement'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { ListItem } from './ListItem'\n\nexport interface ListItemDef {\n /**\n * Stable key for the rendered item. Falls back to the item's index in `items`.\n */\n id?: number | string\n /**\n * Item label content.\n */\n label: React.ReactNode\n /**\n * Makes the item a link.\n */\n href?: string\n /**\n * Sets the color of the item.\n */\n color?: ContextColor\n /**\n * Marks the item as active.\n */\n active?: boolean\n /**\n * Marks the item as disabled.\n */\n disabled?: boolean\n}\n\ntype ListOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n * Defaults to `'ul'`, unless an item (a data-driven item with `href`, or a `<ListItem>` child\n * rendering an `<a>`/`<button>` through `component` or `asChild`) is interactive — a bare\n * `<a>`/`<button>` isn't a valid direct child of `<ul>`/`<ol>`, so the default switches to\n * `'div'` instead. Pass `component` explicitly to opt out of this.\n */\n component?: C\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Remove outer borders and rounded corners to render list items edge-to-edge in a parent component (e.g., `<Card>`).\n */\n flush?: boolean\n /**\n * Array of item definitions for data-driven rendering. When provided, children are ignored.\n */\n items?: ListItemDef[]\n /**\n * Specify a layout type.\n */\n layout?:\n | 'horizontal'\n | 'sm:horizontal'\n | 'md:horizontal'\n | 'lg:horizontal'\n | 'xl:horizontal'\n | '2xl:horizontal'\n /**\n * Number list items sequentially using CSS counters. Pair with `component=\"ol\"` for semantic correctness.\n */\n numbered?: boolean\n /**\n * Remove outer borders, rounded corners, and horizontal padding for a minimal, edge-to-edge appearance.\n */\n plain?: boolean\n /**\n * Applies a `.solid`, `.outline`, or `.smooth` context style. Only meaningful together with `color`.\n */\n variant?: ContextStyle\n}\n\n// What `List` reads off a `<ListItem>` child to decide its own tag.\ntype ListItemChildProps = {\n asChild?: boolean\n children?: ReactNode\n component?: ElementType\n href?: string\n}\n\nexport type ListProps<C extends ElementType = 'ul'> = PolymorphicComponentProps<C, ListOwnProps<C>>\n\ntype ListComponent = (<C extends ElementType = 'ul'>(\n props: ListProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ListRender<C extends ElementType = 'ul'>(\n {\n children,\n className,\n component,\n color,\n variant,\n flush,\n items,\n layout,\n numbered,\n plain,\n ...rest\n }: ListProps<C>,\n ref: PolymorphicRef<C>\n) {\n // A linked item (data-driven `href`, or a `<ListItem>` child rendering an `<a>`/`<button>`,\n // whether through `component` or as its `asChild` element) can't render as a bare\n // `<a>`/`<button>` inside the default `<ul>`/`<ol>` root — only `<li>`/`script`/`template` are\n // valid children there. Default to `<div>` instead when that's the case (unless the caller\n // already chose their own `component`), matching the same `component=\"div\"` pattern already\n // documented for `Stepper`'s composed interactive usage.\n const hasInteractiveItem = items\n ? items.some((item) => hasHref(item.href))\n : Children.toArray(children).some(\n (child) =>\n isElementOfType<ListItemChildProps>(child, ListItem) &&\n isInteractiveKind(resolveKindFromProps(child.props))\n )\n const Component = (component ?? (hasInteractiveItem ? 'div' : 'ul')) as ElementType\n // The tag rather than `Component`, which under `asChild` is a `Slot` holding the caller's\n // `<ul>`/`<ol>`.\n const rootTag = resolveElementTag(Component)\n const isListSemantic = rootTag === 'ul' || rootTag === 'ol'\n\n const _className = classNames(\n 'list',\n color && 'context',\n color,\n variant,\n layout,\n {\n flush,\n plain,\n numbered\n },\n className\n )\n\n const autoContent = items\n ? items.map((item, idx) => {\n const itemClass = classNames('list-item', item.color && 'context', item.color, {\n 'list-action': hasHref(item.href),\n active: item.active,\n disabled: item.disabled\n })\n const Tag = linkElement(undefined, item.href, isListSemantic ? 'li' : 'div')\n return (\n <Tag\n key={item.id ?? idx}\n className={itemClass}\n {...(hasHref(item.href) && { href: item.href })}\n {...(item.active ? { 'aria-current': 'page' } : {})}\n {...(item.disabled ? { 'aria-disabled': true } : {})}\n >\n {item.label}\n </Tag>\n )\n })\n : null\n\n // When the root switched to `div` because of an interactive child, every plain `<ListItem>`\n // sibling defaulting to `<li>` would be just as invalid (only valid inside `<ul>`/`<ol>`/\n // `<menu>`) — so give each `ListItem` child the same `div` treatment the auto-generated items\n // above already get, unless it chose its own element: `component`, `href` or its `asChild`\n // element. Other child types are left untouched — this is only meaningful for `List`'s own list\n // items.\n const renderedChildren =\n autoContent ??\n (isListSemantic\n ? children\n : Children.map(children, (child) =>\n isElementOfType<ListItemChildProps>(child, ListItem) &&\n resolveKindFromProps(child.props) === undefined\n ? React.cloneElement(child, { component: 'div' })\n : child\n ))\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {renderedChildren}\n </Component>\n )\n}\n\nexport const List = createPolymorphicComponent<ListComponent>(\n ListRender as ForwardRefRenderFunction<Element, ListProps<ElementType>>,\n 'List'\n)\n"],"mappings":"mTAqDA,SAAS,EACP,CAAE,WAAU,SAAQ,YAAW,WAAU,QAAO,YAAW,OAAM,GAAG,GACpE,EACA,CAGA,IAAM,EAAM,EAAY,EAAW,EAAM,IAAI,EAGvC,EAAO,EAAgB,EAAK,EAAM,CAAI,EACtC,EAAgB,EAAkB,CAAI,EACtC,EAAY,EAAU,EAAM,EAAM,UAAU,EAE5C,EAAa,EACjB,YACA,GAAS,UACT,EACA,CACE,cAAe,EAGf,OAAQ,GAAU,CAAC,EACnB,SAAU,GAAY,CAAC,CACzB,EACA,CACF,EAEM,EAAa,EAAgB,EAAO,EAEpC,EAAY,EACd,CAAE,SAAQ,WAAU,UAAW,EAAK,GAAG,EAAW,GAAG,CAAK,EAC1D,CACE,GAAI,GAA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nD,EAAqB,EAAM,KAAK,IAAM,IAAA,GAClC,EAAM,aAAa,EAAO,CAAE,UAAW,KAAM,CAAC,EAC9C,CACN,GAEN,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAO,EAClB,EACA,MACF"}
|
|
1
|
+
{"version":3,"file":"list-07e2a1Ym.js","names":[],"sources":["../../src/components/list/ListItem.tsx","../../src/components/list/List.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor } from '../../types'\nimport { hrefProps, isInteractiveKind, linkElement, resolveLinkKind } from '../../utils/elementKind'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n PolymorphicRefWithFallback\n} from '../../utils/polymorphic'\nimport { Link } from '../link/Link'\n\ntype ListItemOwnProps<C extends ElementType> = {\n /**\n * Toggle the active state for the component.\n */\n active?: boolean\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Toggle the disabled state for the component.\n */\n disabled?: boolean\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * The href attribute specifies the URL of the page the link goes to. Renders an `<a>` in place\n * of the `<li>`, unless `component` or `asChild` chose the element. Inside a `List`, the list\n * renders a `<div>` around it in place of the `<ul>`.\n */\n href?: string\n}\n\nexport type ListItemProps<C extends ElementType = 'li'> = PolymorphicComponentProps<\n C,\n ListItemOwnProps<C>\n>\n\ntype ListItemComponent = (<C extends ElementType = 'li'>(\n props: ListItemProps<C> & {\n ref?: PolymorphicRefWithFallback<C, HTMLLIElement | HTMLAnchorElement>\n }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ListItemRender<C extends ElementType = 'li'>(\n { children, active, className, disabled, color, component, href, ...rest }: ListItemProps<C>,\n ref: PolymorphicRef<C>\n) {\n // `href` makes it an `<a>`, unless `component` or `asChild` chose the element (see\n // `linkElement`). It used to stay an `<li>` and carry `href` as an attribute.\n const tag = linkElement(component, href, 'li')\n // The kind rather than the tag, counting a router link with `href` or `to` as an anchor: under `asChild`, `tag` is a `Slot` standing in for the caller's\n // element, and a slotted `<a>` is as interactive as `component=\"a\"`.\n const kind = resolveLinkKind(tag, href, rest)\n const isInteractive = isInteractiveKind(kind)\n const linkProps = hrefProps(kind, href, 'ListItem')\n\n const _className = classNames(\n 'list-item',\n color && 'context',\n color,\n {\n 'list-action': isInteractive,\n // An interactive item renders through `Link`, which adds these classes and their ARIA\n // attributes itself.\n active: active && !isInteractive,\n disabled: disabled && !isInteractive\n },\n className\n )\n\n const Component = (isInteractive ? Link : tag) as ElementType\n\n const finalRest = isInteractive\n ? { active, disabled, component: tag, ...linkProps, ...rest }\n : {\n ...(active && { 'aria-current': 'page' }),\n ...(disabled && { 'aria-disabled': true }),\n ...linkProps,\n ...rest\n }\n\n return (\n <Component className={_className} {...finalRest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const ListItem = createPolymorphicComponent<ListItemComponent>(\n ListItemRender as ForwardRefRenderFunction<Element, ListItemProps<ElementType>>,\n 'ListItem'\n)\n","import React, {\n Children,\n ElementType,\n ForwardRefRenderFunction,\n ReactElement,\n ReactNode\n} from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor, ContextStyle } from '../../types'\nimport {\n hasHref,\n isInteractiveKind,\n linkElement,\n resolveElementTag,\n resolveKindFromProps\n} from '../../utils/elementKind'\nimport { isElementOfType } from '../../utils/lazyElement'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { ListItem } from './ListItem'\n\nexport interface ListItemDef {\n /**\n * Stable key for the rendered item. Falls back to the item's index in `items`.\n */\n id?: number | string\n /**\n * Item label content.\n */\n label: React.ReactNode\n /**\n * Makes the item a link.\n */\n href?: string\n /**\n * Sets the color of the item.\n */\n color?: ContextColor\n /**\n * Marks the item as active.\n */\n active?: boolean\n /**\n * Marks the item as disabled.\n */\n disabled?: boolean\n}\n\ntype ListOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n * Defaults to `'ul'`, unless an item (a data-driven item with `href`, or a `<ListItem>` child\n * rendering an `<a>`/`<button>` through `component` or `asChild`) is interactive — a bare\n * `<a>`/`<button>` isn't a valid direct child of `<ul>`/`<ol>`, so the default switches to\n * `'div'` instead. Pass `component` explicitly to opt out of this.\n */\n component?: C\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Remove outer borders and rounded corners to render list items edge-to-edge in a parent component (e.g., `<Card>`).\n */\n flush?: boolean\n /**\n * Array of item definitions for data-driven rendering. When provided, children are ignored.\n */\n items?: ListItemDef[]\n /**\n * Specify a layout type.\n */\n layout?:\n | 'horizontal'\n | 'sm:horizontal'\n | 'md:horizontal'\n | 'lg:horizontal'\n | 'xl:horizontal'\n | '2xl:horizontal'\n /**\n * Number list items sequentially using CSS counters. Pair with `component=\"ol\"` for semantic correctness.\n */\n numbered?: boolean\n /**\n * Remove outer borders, rounded corners, and horizontal padding for a minimal, edge-to-edge appearance.\n */\n plain?: boolean\n /**\n * Applies a `.solid`, `.outline`, or `.smooth` context style. Only meaningful together with `color`.\n */\n variant?: ContextStyle\n}\n\n// What `List` reads off a `<ListItem>` child to decide its own tag.\ntype ListItemChildProps = {\n asChild?: boolean\n children?: ReactNode\n component?: ElementType\n href?: string\n}\n\nexport type ListProps<C extends ElementType = 'ul'> = PolymorphicComponentProps<C, ListOwnProps<C>>\n\ntype ListComponent = (<C extends ElementType = 'ul'>(\n props: ListProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ListRender<C extends ElementType = 'ul'>(\n {\n children,\n className,\n component,\n color,\n variant,\n flush,\n items,\n layout,\n numbered,\n plain,\n ...rest\n }: ListProps<C>,\n ref: PolymorphicRef<C>\n) {\n // A linked item (data-driven `href`, or a `<ListItem>` child rendering an `<a>`/`<button>`,\n // whether through `component` or as its `asChild` element) can't render as a bare\n // `<a>`/`<button>` inside the default `<ul>`/`<ol>` root — only `<li>`/`script`/`template` are\n // valid children there. Default to `<div>` instead when that's the case (unless the caller\n // already chose their own `component`), matching the same `component=\"div\"` pattern already\n // documented for `Stepper`'s composed interactive usage.\n const hasInteractiveItem = items\n ? items.some((item) => hasHref(item.href))\n : Children.toArray(children).some(\n (child) =>\n isElementOfType<ListItemChildProps>(child, ListItem) &&\n isInteractiveKind(resolveKindFromProps(child.props))\n )\n const Component = (component ?? (hasInteractiveItem ? 'div' : 'ul')) as ElementType\n // The tag rather than `Component`, which under `asChild` is a `Slot` holding the caller's\n // `<ul>`/`<ol>`.\n const rootTag = resolveElementTag(Component)\n const isListSemantic = rootTag === 'ul' || rootTag === 'ol'\n\n const _className = classNames(\n 'list',\n color && 'context',\n color,\n variant,\n layout,\n {\n flush,\n plain,\n numbered\n },\n className\n )\n\n const autoContent = items\n ? items.map((item, idx) => {\n const itemClass = classNames('list-item', item.color && 'context', item.color, {\n 'list-action': hasHref(item.href),\n active: item.active,\n disabled: item.disabled\n })\n const Tag = linkElement(undefined, item.href, isListSemantic ? 'li' : 'div')\n return (\n <Tag\n key={item.id ?? idx}\n className={itemClass}\n {...(hasHref(item.href) && { href: item.href })}\n {...(item.active ? { 'aria-current': 'page' } : {})}\n {...(item.disabled ? { 'aria-disabled': true } : {})}\n >\n {item.label}\n </Tag>\n )\n })\n : null\n\n // When the root switched to `div` because of an interactive child, every plain `<ListItem>`\n // sibling defaulting to `<li>` would be just as invalid (only valid inside `<ul>`/`<ol>`/\n // `<menu>`) — so give each `ListItem` child the same `div` treatment the auto-generated items\n // above already get, unless it chose its own element: `component`, `href` or its `asChild`\n // element. Other child types are left untouched — this is only meaningful for `List`'s own list\n // items.\n const renderedChildren =\n autoContent ??\n (isListSemantic\n ? children\n : Children.map(children, (child) =>\n isElementOfType<ListItemChildProps>(child, ListItem) &&\n resolveKindFromProps(child.props) === undefined\n ? React.cloneElement(child, { component: 'div' })\n : child\n ))\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {renderedChildren}\n </Component>\n )\n}\n\nexport const List = createPolymorphicComponent<ListComponent>(\n ListRender as ForwardRefRenderFunction<Element, ListProps<ElementType>>,\n 'List'\n)\n"],"mappings":"mTAqDA,SAAS,EACP,CAAE,WAAU,SAAQ,YAAW,WAAU,QAAO,YAAW,OAAM,GAAG,GACpE,EACA,CAGA,IAAM,EAAM,EAAY,EAAW,EAAM,IAAI,EAGvC,EAAO,EAAgB,EAAK,EAAM,CAAI,EACtC,EAAgB,EAAkB,CAAI,EACtC,EAAY,EAAU,EAAM,EAAM,UAAU,EAE5C,EAAa,EACjB,YACA,GAAS,UACT,EACA,CACE,cAAe,EAGf,OAAQ,GAAU,CAAC,EACnB,SAAU,GAAY,CAAC,CACzB,EACA,CACF,EAEM,EAAa,EAAgB,EAAO,EAEpC,EAAY,EACd,CAAE,SAAQ,WAAU,UAAW,EAAK,GAAG,EAAW,GAAG,CAAK,EAC1D,CACE,GAAI,GAAU,CAAE,eAAgB,MAAO,EACvC,GAAI,GAAY,CAAE,gBAAiB,EAAK,EACxC,GAAG,EACH,GAAG,CACL,EAEJ,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAgB,KAE3C,EADR,CACQ,CAEf,CAEA,MAAa,EAAW,EACtB,EACA,UACF,ECcA,SAAS,EACP,CACE,WACA,YACA,YACA,QACA,UACA,QACA,QACA,SACA,WACA,QACA,GAAG,GAEL,EACA,CAOA,IAAM,EAAqB,EACvB,EAAM,KAAM,GAAS,EAAQ,EAAK,IAAI,CAAC,EACvC,EAAS,QAAQ,CAAQ,CAAC,CAAC,KACxB,GACC,EAAoC,EAAO,CAAQ,GACnD,EAAkB,EAAqB,EAAM,KAAK,CAAC,CACvD,EACE,EAAa,IAAc,EAAqB,MAAQ,MAGxD,EAAU,EAAkB,CAAS,EACrC,EAAiB,IAAY,MAAQ,IAAY,KAEjD,EAAa,EACjB,OACA,GAAS,UACT,EACA,EACA,EACA,CACE,QACA,QACA,UACF,EACA,CACF,EA8BM,GA5Bc,EAChB,EAAM,KAAK,EAAM,IAAQ,CACvB,IAAM,EAAY,EAAW,YAAa,EAAK,OAAS,UAAW,EAAK,MAAO,CAC7E,cAAe,EAAQ,EAAK,IAAI,EAChC,OAAQ,EAAK,OACb,SAAU,EAAK,QACjB,CAAC,EACK,EAAM,EAAY,IAAA,GAAW,EAAK,KAAM,EAAiB,KAAO,KAAK,EAC3E,OACE,EAAA,cAAC,EAAD,CACE,IAAK,EAAK,IAAM,EAChB,UAAW,EACX,GAAK,EAAQ,EAAK,IAAI,GAAK,CAAE,KAAM,EAAK,IAAK,EAC7C,GAAK,EAAK,OAAS,CAAE,eAAgB,MAAO,EAAI,CAAC,EACjD,GAAK,EAAK,SAAW,CAAE,gBAAiB,EAAK,EAAI,CAAC,CAG/C,EADF,EAAK,KACH,CAET,CAAC,EACD,QAUD,EACG,EACA,EAAS,IAAI,EAAW,GACtB,EAAoC,EAAO,CAAQ,GACnD,EAAqB,EAAM,KAAK,IAAM,IAAA,GAClC,EAAM,aAAa,EAAO,CAAE,UAAW,KAAM,CAAC,EAC9C,CACN,GAEN,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAO,EAClB,EACA,MACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{t as e}from"./polymorphic-BhGNZQja.js";import{t}from"./Portal-CgeR1WXV.js";import{i as n,r}from"./overlayPlacement-BtS90IVf.js";import{n as i}from"./Menu-CSBg2Zmc.js";import{a,c as o,i as s,o as ee,r as c,s as l}from"./MenuToggle-
|
|
2
|
-
//# sourceMappingURL=menu-
|
|
1
|
+
import"./focus-ring-SR_LwaN7.js";import{t as e}from"./polymorphic-BhGNZQja.js";import{t}from"./Portal-CgeR1WXV.js";import{i as n,r}from"./overlayPlacement-BtS90IVf.js";import{n as i}from"./Menu-CSBg2Zmc.js";import{a,c as o,i as s,o as ee,r as c,s as l}from"./MenuToggle-7RQ0dmtZ.js";import u,{forwardRef as d,useCallback as f,useContext as p,useEffect as m,useId as te,useRef as h,useState as ne}from"react";import g from"classnames";import{useLocale as _,useOverlayPosition as v}from"react-aria";function y({children:e,className:t,component:n,...r},i){let a=n??`span`,o=g(`menu-text`,t);return u.createElement(a,{className:o,...r,ref:i},e)}const b=e(y,`MenuText`),x=d(({children:e,activation:d=`both`,className:y,disabled:b,offset:x=[-4,0],placement:S,stacked:C,submenuDelay:w=100,trigger:T,...E},D)=>{let O=te(),k=`${O}-trigger`,A=`${O}-menu`,[j,M]=ne(!1),N=h(void 0),P=h(void 0),F=h(null),I=h(null),L=p(s),R=a(),{registerOverlay:z,visible:B}=p(i),{direction:V}=_(),H=V===`rtl`,U=S??(H?`left-start`:`right-start`),{overlayProps:W,placement:G}=v({targetRef:F,overlayRef:I,placement:n(U),offset:x[1],crossOffset:x[0],containerPadding:8,isOpen:j,onClose:null}),{menuStyle:re,placementAttr:ie}=r(W.style,U,G),K=f(()=>{N.current!==void 0&&(window.clearTimeout(N.current),N.current=void 0)},[]),q=f(()=>{P.current!==void 0&&(cancelAnimationFrame(P.current),P.current=void 0)},[]),J=f(()=>{K(),q(),M(!1)},[K,q]),Y=()=>{b||j||(K(),L?.notifyOpen(O),M(!0))},X=()=>{K(),N.current=window.setTimeout(J,w)};m(()=>L?.register(O,J),[L,O,J]),m(()=>K,[K]),m(()=>q,[q]),m(()=>{B||J()},[B,J]);let Z=typeof window<`u`&&!!window.matchMedia&&window.matchMedia(`(hover: hover)`).matches&&(d===`hover`||d===`both`),ae=d===`click`||d===`both`,Q=()=>{Y(),q(),P.current=requestAnimationFrame(()=>{P.current=void 0,ee(l(I.current),`first`)})},$=()=>{J(),F.current?.focus()},oe=e=>{ae&&!b&&(e.preventDefault(),e.stopPropagation(),j?J():Q())},se=H?`ArrowLeft`:`ArrowRight`,ce=e=>{b||(e.key===`Enter`||e.key===` `||e.key===se)&&(e.preventDefault(),e.stopPropagation(),Q())},le={close:$};return u.createElement(`div`,{className:g(`submenu`,{show:j},y),...E,ref:D},u.createElement(`button`,{type:`button`,id:k,role:`menuitem`,className:`menu-item`,"aria-expanded":j,"aria-haspopup":`true`,"aria-controls":j?A:void 0,disabled:b,onClick:oe,onKeyDown:ce,onMouseEnter:Z?Y:void 0,onMouseLeave:Z?X:void 0,ref:e=>{F.current=e}},T),(()=>{let n=u.createElement(`div`,{role:`menu`,id:A,"aria-labelledby":k,className:g(`menu`,{show:j,"submenu-stacked":C}),style:re,"data-cx-placement":ie,onKeyDown:e=>o(e,{onEscape:$,...H?{onArrowRight:$}:{onArrowLeft:$}}),onMouseEnter:Z?K:void 0,onMouseLeave:Z?X:void 0,ref:e=>{I.current=e,z(A,e)}},u.createElement(c.Provider,{value:le},u.createElement(s.Provider,{value:R},e)));return C?n:u.createElement(t,{fallback:n},n)})())});x.displayName=`MenuSubmenu`;const S=d(({children:e,className:t,onClick:n,type:r=`button`,...i},a)=>{let o=p(c),s=e=>{n?.(e),o?.close()};return u.createElement(`button`,{type:r,role:`menuitem`,className:g(`submenu-back`,`menu-item`,t),...i,onClick:s,ref:a},e)});S.displayName=`MenuSubmenuBack`;export{x as n,b as r,S as t};
|
|
2
|
+
//# sourceMappingURL=menu-Upf6P-2P.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-98EAD9nj.js","names":[],"sources":["../../src/components/menu/MenuText.tsx","../../src/components/menu/MenuSubmenu.tsx","../../src/components/menu/MenuSubmenuBack.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype MenuTextOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type MenuTextProps<C extends ElementType = 'span'> = PolymorphicComponentProps<\n C,\n MenuTextOwnProps<C>\n>\n\ntype MenuTextComponent = (<C extends ElementType = 'span'>(\n props: MenuTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction MenuTextRender<C extends ElementType = 'span'>(\n { children, className, component, ...rest }: MenuTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'span'\n const _className = classNames('menu-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const MenuText = createPolymorphicComponent<MenuTextComponent>(\n MenuTextRender as ForwardRefRenderFunction<Element, MenuTextProps<ElementType>>,\n 'MenuText'\n)\n","import React, {\n forwardRef,\n HTMLAttributes,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useRef,\n useState\n} from 'react'\nimport classNames from 'classnames'\nimport { useLocale, useOverlayPosition } from 'react-aria'\n\nimport { MenuContext } from './Menu'\nimport {\n Placement,\n resolveMenuOverlayPositioning,\n toAriaPlacement\n} from '../../utils/overlayPlacement'\nimport { Portal } from '../portal/Portal'\nimport { focusMenuItem, getMenuItems, handleMenuKeyDown } from './menuNavigation'\nimport { SubmenuActionsContext, SubmenuGroupContext, useSubmenuGroupProvider } from './submenuGroup'\n\nexport interface MenuSubmenuProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n /**\n * MenuSubmenu activation mode on hover-capable devices. `'click'` activates on click only.\n * `'hover'` activates on hover only. `'both'` (the default) activates on both. Touch\n * devices always use tap regardless of this setting.\n */\n activation?: 'click' | 'hover' | 'both'\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Prevents the submenu from opening.\n */\n disabled?: boolean\n /**\n * Distance between the nested menu and the trigger, as `[skidding, distance]` in pixels.\n */\n offset?: [number, number]\n /**\n * Placement of the nested menu relative to the trigger. Defaults to cascading in the reading\n * direction — `'right-start'` under LTR locales, `'left-start'` under RTL ones (see\n * `useLocale`) — matching native OS/browser submenu behavior. An explicit value always wins\n * over that locale-based default.\n */\n placement?: Placement\n /**\n * Switches to a view-replacement pattern below the `sm` breakpoint. Pair with a\n * `MenuSubmenuBack` as the first item of the nested menu.\n */\n stacked?: boolean\n /**\n * Milliseconds before closing the submenu when the pointer leaves it.\n */\n submenuDelay?: number\n /**\n * Content of the `.menu-item` trigger that opens the submenu.\n */\n trigger: ReactNode\n}\n\nexport const MenuSubmenu = forwardRef<HTMLDivElement, MenuSubmenuProps>(\n (\n {\n children,\n activation = 'both',\n className,\n disabled,\n offset: offsetProp = [-4, 0],\n placement,\n stacked,\n submenuDelay = 100,\n trigger,\n ...rest\n },\n ref\n ) => {\n const id = useId()\n const triggerId = `${id}-trigger`\n const menuId = `${id}-menu`\n const [visible, setVisible] = useState(false)\n const closeTimeoutRef = useRef<number | undefined>(undefined)\n const focusFirstRafRef = useRef<number | undefined>(undefined)\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const overlayRef = useRef<HTMLElement | null>(null)\n const parentGroup = useContext(SubmenuGroupContext)\n const ownGroup = useSubmenuGroupProvider()\n const { registerOverlay, visible: parentMenuVisible } = useContext(MenuContext)\n const { direction } = useLocale()\n const isRtl = direction === 'rtl'\n const effectivePlacement = placement ?? (isRtl ? 'left-start' : 'right-start')\n\n const { overlayProps, placement: resolvedPlacement } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n // Viewport-relative (matching the portal below): the trigger lives inside the parent\n // menu's own floated panel, and `useOverlayPosition` measures against the overlay's real\n // containing block — since the panel portals straight to `document.body`, that resolves\n // the same way a `fixed`-strategy engine would.\n placement: toAriaPlacement(effectivePlacement),\n offset: offsetProp[1],\n crossOffset: offsetProp[0],\n containerPadding: 8,\n isOpen: visible,\n // See `useOverlayPlacement`'s comment for why this needs to be explicit `null`, not left\n // unset — matches the same fix already applied to `Autocomplete`/`Combobox`/`Menu`/`Popover`.\n onClose: null\n })\n\n const { menuStyle, placementAttr } = resolveMenuOverlayPositioning(\n overlayProps.style,\n effectivePlacement,\n resolvedPlacement\n )\n\n const clearCloseTimeout = useCallback(() => {\n if (closeTimeoutRef.current !== undefined) {\n window.clearTimeout(closeTimeoutRef.current)\n closeTimeoutRef.current = undefined\n }\n }, [])\n\n const cancelFocusFirstRaf = useCallback(() => {\n if (focusFirstRafRef.current !== undefined) {\n cancelAnimationFrame(focusFirstRafRef.current)\n focusFirstRafRef.current = undefined\n }\n }, [])\n\n const close = useCallback(() => {\n clearCloseTimeout()\n cancelFocusFirstRaf()\n setVisible(false)\n }, [clearCloseTimeout, cancelFocusFirstRaf])\n\n const open = () => {\n if (disabled || visible) return\n clearCloseTimeout()\n parentGroup?.notifyOpen(id)\n setVisible(true)\n }\n\n const scheduleClose = () => {\n clearCloseTimeout()\n closeTimeoutRef.current = window.setTimeout(close, submenuDelay)\n }\n\n useEffect(() => parentGroup?.register(id, close), [parentGroup, id, close])\n useEffect(() => clearCloseTimeout, [clearCloseTimeout])\n useEffect(() => cancelFocusFirstRaf, [cancelFocusFirstRaf])\n\n // The submenu's own open state is local and doesn't otherwise hear about its ancestor\n // `Menu` closing (via Escape, outside click, etc.) — without this it's left open and\n // fully visible (it's portaled to `document.body`, so nothing hides it for free) even\n // after the menu it belongs to has disappeared.\n useEffect(() => {\n if (!parentMenuVisible) close()\n }, [parentMenuVisible, close])\n\n const supportsHover =\n typeof window !== 'undefined' &&\n !!window.matchMedia &&\n window.matchMedia('(hover: hover)').matches\n const hoverEnabled = supportsHover && (activation === 'hover' || activation === 'both')\n const clickEnabled = activation === 'click' || activation === 'both'\n\n const openAndFocusFirst = () => {\n open()\n cancelFocusFirstRaf()\n focusFirstRafRef.current = requestAnimationFrame(() => {\n focusFirstRafRef.current = undefined\n focusMenuItem(getMenuItems(overlayRef.current), 'first')\n })\n }\n\n const closeAndRefocusTrigger = () => {\n close()\n triggerRef.current?.focus()\n }\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (!clickEnabled || disabled) return\n event.preventDefault()\n event.stopPropagation()\n visible ? close() : openAndFocusFirst()\n }\n\n // A submenu cascades toward the reading direction, so the arrow key that opens it (and the\n // one its own item list closes on, below) mirror too: ArrowRight/ArrowLeft under LTR,\n // ArrowLeft/ArrowRight under RTL.\n const openKey = isRtl ? 'ArrowLeft' : 'ArrowRight'\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) return\n if (event.key === 'Enter' || event.key === ' ' || event.key === openKey) {\n event.preventDefault()\n event.stopPropagation()\n openAndFocusFirst()\n }\n }\n\n const actionsValue = { close: closeAndRefocusTrigger }\n\n return (\n <div className={classNames('submenu', { show: visible }, className)} {...rest} ref={ref}>\n <button\n type=\"button\"\n id={triggerId}\n role=\"menuitem\"\n className=\"menu-item\"\n aria-expanded={visible}\n aria-haspopup=\"true\"\n aria-controls={visible ? menuId : undefined}\n disabled={disabled}\n onClick={handleTriggerClick}\n onKeyDown={handleTriggerKeyDown}\n onMouseEnter={hoverEnabled ? open : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n ref={(node) => {\n triggerRef.current = node\n }}\n >\n {trigger}\n </button>\n {(() => {\n const panel = (\n <div\n role=\"menu\"\n id={menuId}\n aria-labelledby={triggerId}\n className={classNames('menu', { show: visible, 'submenu-stacked': stacked })}\n style={menuStyle}\n data-cx-placement={placementAttr}\n onKeyDown={(event) =>\n handleMenuKeyDown(event, {\n onEscape: closeAndRefocusTrigger,\n ...(isRtl\n ? { onArrowRight: closeAndRefocusTrigger }\n : { onArrowLeft: closeAndRefocusTrigger })\n })\n }\n onMouseEnter={hoverEnabled ? clearCloseTimeout : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n // Registers this panel with the ancestor `Menu` (see `MenuContext.registerOverlay`)\n // so its own click-dismiss logic recognizes clicks here as \"inside\" the menu — the\n // panel portals straight to `document.body` when not `stacked`, so plain DOM\n // containment against the top-level menu's own element wouldn't otherwise see it.\n ref={(node) => {\n overlayRef.current = node\n registerOverlay(menuId, node)\n }}\n >\n <SubmenuActionsContext.Provider value={actionsValue}>\n <SubmenuGroupContext.Provider value={ownGroup}>\n {children}\n </SubmenuGroupContext.Provider>\n </SubmenuActionsContext.Provider>\n </div>\n )\n\n // `stacked`'s sm-breakpoint CSS (`.menu:has(.submenu-stacked.show) ...`) needs the\n // panel to be a real DOM descendant of `.menu`/`.submenu` to match — portaling would\n // break that ancestor relationship, so it renders inline instead. Trade-off: above the\n // `sm` breakpoint a `stacked` submenu no longer escapes ancestor overflow/stacking-\n // context clipping the way a portaled one does; accepted since `stacked` targets mobile\n // nav/drawer usage, not floating dropdowns.\n // On the server and during hydration the panel renders inline next to its trigger, which\n // is what the server's HTML holds; `Portal` moves it to `document.body` afterwards.\n return stacked ? panel : <Portal fallback={panel}>{panel}</Portal>\n })()}\n </div>\n )\n }\n)\n\nMenuSubmenu.displayName = 'MenuSubmenu'\n","import React, { ButtonHTMLAttributes, forwardRef, useContext } from 'react'\nimport classNames from 'classnames'\n\nimport { SubmenuActionsContext } from './submenuGroup'\n\nexport interface MenuSubmenuBackProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n}\n\n// First item of a stacked submenu's nested menu (see `MenuSubmenu`'s `stacked` prop). Closes\n// the submenu and returns focus to its trigger — visible only below the `sm` breakpoint.\nexport const MenuSubmenuBack = forwardRef<HTMLButtonElement, MenuSubmenuBackProps>(\n ({ children, className, onClick, type = 'button', ...rest }, ref) => {\n const actions = useContext(SubmenuActionsContext)\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n actions?.close()\n }\n\n return (\n <button\n type={type}\n role=\"menuitem\"\n className={classNames('submenu-back', 'menu-item', className)}\n {...rest}\n onClick={handleClick}\n ref={ref}\n >\n {children}\n </button>\n )\n }\n)\n\nMenuSubmenuBack.displayName = 'MenuSubmenuBack'\n"],"mappings":"ifA6BA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,GAAG,GACrC,EACA,CACA,IAAM,EAAY,GAAa,OACzB,EAAa,EAAW,YAAa,CAAS,EAEpD,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAW,EACtB,EACA,UACF,ECmBa,EAAc,GAEvB,CACE,WACA,aAAa,OACb,YACA,WACA,OAAQ,EAAa,CAAC,GAAI,CAAC,EAC3B,YACA,UACA,eAAe,IACf,UACA,GAAG,GAEL,IACG,CACH,IAAM,EAAK,GAAM,EACX,EAAY,GAAG,EAAG,UAClB,EAAS,GAAG,EAAG,OACf,CAAC,EAAS,GAAc,GAAS,EAAK,EACtC,EAAkB,EAA2B,IAAA,EAAS,EACtD,EAAmB,EAA2B,IAAA,EAAS,EACvD,EAAa,EAAiC,IAAI,EAClD,EAAa,EAA2B,IAAI,EAC5C,EAAc,EAAW,CAAmB,EAC5C,EAAW,EAAwB,EACnC,CAAE,kBAAiB,QAAS,GAAsB,EAAW,CAAW,EACxE,CAAE,aAAc,EAAU,EAC1B,EAAQ,IAAc,MACtB,EAAqB,IAAc,EAAQ,aAAe,eAE1D,CAAE,eAAc,UAAW,GAAsB,EAAmB,CACxE,UAAW,EACX,aAKA,UAAW,EAAgB,CAAkB,EAC7C,OAAQ,EAAW,GACnB,YAAa,EAAW,GACxB,iBAAkB,EAClB,OAAQ,EAGR,QAAS,IACX,CAAC,EAEK,CAAE,aAAW,kBAAkB,EACnC,EAAa,MACb,EACA,CACF,EAEM,EAAoB,MAAkB,CACtC,EAAgB,UAAY,IAAA,KAC9B,OAAO,aAAa,EAAgB,OAAO,EAC3C,EAAgB,QAAU,IAAA,GAE9B,EAAG,CAAC,CAAC,EAEC,EA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AA+C,CAClE,IAAU,CAAK,EACf,GAAS,MAAM,CACjB,EAEA,OACE,EAAA,cAAC,SAAD,CACQ,OACN,KAAK,WACL,UAAW,EAAW,eAAgB,YAAa,CAAS,EAC5D,GAAI,EACJ,QAAS,EACJ,KAGC,EADL,CACK,CAEZ,CACF,EAEA,EAAgB,YAAc"}
|
|
1
|
+
{"version":3,"file":"menu-Upf6P-2P.js","names":[],"sources":["../../src/components/menu/MenuText.tsx","../../src/components/menu/MenuSubmenu.tsx","../../src/components/menu/MenuSubmenuBack.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype MenuTextOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type MenuTextProps<C extends ElementType = 'span'> = PolymorphicComponentProps<\n C,\n MenuTextOwnProps<C>\n>\n\ntype MenuTextComponent = (<C extends ElementType = 'span'>(\n props: MenuTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction MenuTextRender<C extends ElementType = 'span'>(\n { children, className, component, ...rest }: MenuTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'span'\n const _className = classNames('menu-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const MenuText = createPolymorphicComponent<MenuTextComponent>(\n MenuTextRender as ForwardRefRenderFunction<Element, MenuTextProps<ElementType>>,\n 'MenuText'\n)\n","import React, {\n forwardRef,\n HTMLAttributes,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useRef,\n useState\n} from 'react'\nimport classNames from 'classnames'\nimport { useLocale, useOverlayPosition } from 'react-aria'\n\nimport { MenuContext } from './Menu'\nimport {\n Placement,\n resolveMenuOverlayPositioning,\n toAriaPlacement\n} from '../../utils/overlayPlacement'\nimport { Portal } from '../portal/Portal'\nimport { focusMenuItem, getMenuItems, handleMenuKeyDown } from './menuNavigation'\nimport { SubmenuActionsContext, SubmenuGroupContext, useSubmenuGroupProvider } from './submenuGroup'\n\nexport interface MenuSubmenuProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n /**\n * MenuSubmenu activation mode on hover-capable devices. `'click'` activates on click only.\n * `'hover'` activates on hover only. `'both'` (the default) activates on both. Touch\n * devices always use tap regardless of this setting.\n */\n activation?: 'click' | 'hover' | 'both'\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Prevents the submenu from opening.\n */\n disabled?: boolean\n /**\n * Distance between the nested menu and the trigger, as `[skidding, distance]` in pixels.\n */\n offset?: [number, number]\n /**\n * Placement of the nested menu relative to the trigger. Defaults to cascading in the reading\n * direction — `'right-start'` under LTR locales, `'left-start'` under RTL ones (see\n * `useLocale`) — matching native OS/browser submenu behavior. An explicit value always wins\n * over that locale-based default.\n */\n placement?: Placement\n /**\n * Switches to a view-replacement pattern below the `sm` breakpoint. Pair with a\n * `MenuSubmenuBack` as the first item of the nested menu.\n */\n stacked?: boolean\n /**\n * Milliseconds before closing the submenu when the pointer leaves it.\n */\n submenuDelay?: number\n /**\n * Content of the `.menu-item` trigger that opens the submenu.\n */\n trigger: ReactNode\n}\n\nexport const MenuSubmenu = forwardRef<HTMLDivElement, MenuSubmenuProps>(\n (\n {\n children,\n activation = 'both',\n className,\n disabled,\n offset: offsetProp = [-4, 0],\n placement,\n stacked,\n submenuDelay = 100,\n trigger,\n ...rest\n },\n ref\n ) => {\n const id = useId()\n const triggerId = `${id}-trigger`\n const menuId = `${id}-menu`\n const [visible, setVisible] = useState(false)\n const closeTimeoutRef = useRef<number | undefined>(undefined)\n const focusFirstRafRef = useRef<number | undefined>(undefined)\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const overlayRef = useRef<HTMLElement | null>(null)\n const parentGroup = useContext(SubmenuGroupContext)\n const ownGroup = useSubmenuGroupProvider()\n const { registerOverlay, visible: parentMenuVisible } = useContext(MenuContext)\n const { direction } = useLocale()\n const isRtl = direction === 'rtl'\n const effectivePlacement = placement ?? (isRtl ? 'left-start' : 'right-start')\n\n const { overlayProps, placement: resolvedPlacement } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n // Viewport-relative (matching the portal below): the trigger lives inside the parent\n // menu's own floated panel, and `useOverlayPosition` measures against the overlay's real\n // containing block — since the panel portals straight to `document.body`, that resolves\n // the same way a `fixed`-strategy engine would.\n placement: toAriaPlacement(effectivePlacement),\n offset: offsetProp[1],\n crossOffset: offsetProp[0],\n containerPadding: 8,\n isOpen: visible,\n // See `useOverlayPlacement`'s comment for why this needs to be explicit `null`, not left\n // unset — matches the same fix already applied to `Autocomplete`/`Combobox`/`Menu`/`Popover`.\n onClose: null\n })\n\n const { menuStyle, placementAttr } = resolveMenuOverlayPositioning(\n overlayProps.style,\n effectivePlacement,\n resolvedPlacement\n )\n\n const clearCloseTimeout = useCallback(() => {\n if (closeTimeoutRef.current !== undefined) {\n window.clearTimeout(closeTimeoutRef.current)\n closeTimeoutRef.current = undefined\n }\n }, [])\n\n const cancelFocusFirstRaf = useCallback(() => {\n if (focusFirstRafRef.current !== undefined) {\n cancelAnimationFrame(focusFirstRafRef.current)\n focusFirstRafRef.current = undefined\n }\n }, [])\n\n const close = useCallback(() => {\n clearCloseTimeout()\n cancelFocusFirstRaf()\n setVisible(false)\n }, [clearCloseTimeout, cancelFocusFirstRaf])\n\n const open = () => {\n if (disabled || visible) return\n clearCloseTimeout()\n parentGroup?.notifyOpen(id)\n setVisible(true)\n }\n\n const scheduleClose = () => {\n clearCloseTimeout()\n closeTimeoutRef.current = window.setTimeout(close, submenuDelay)\n }\n\n useEffect(() => parentGroup?.register(id, close), [parentGroup, id, close])\n useEffect(() => clearCloseTimeout, [clearCloseTimeout])\n useEffect(() => cancelFocusFirstRaf, [cancelFocusFirstRaf])\n\n // The submenu's own open state is local and doesn't otherwise hear about its ancestor\n // `Menu` closing (via Escape, outside click, etc.) — without this it's left open and\n // fully visible (it's portaled to `document.body`, so nothing hides it for free) even\n // after the menu it belongs to has disappeared.\n useEffect(() => {\n if (!parentMenuVisible) close()\n }, [parentMenuVisible, close])\n\n const supportsHover =\n typeof window !== 'undefined' &&\n !!window.matchMedia &&\n window.matchMedia('(hover: hover)').matches\n const hoverEnabled = supportsHover && (activation === 'hover' || activation === 'both')\n const clickEnabled = activation === 'click' || activation === 'both'\n\n const openAndFocusFirst = () => {\n open()\n cancelFocusFirstRaf()\n focusFirstRafRef.current = requestAnimationFrame(() => {\n focusFirstRafRef.current = undefined\n focusMenuItem(getMenuItems(overlayRef.current), 'first')\n })\n }\n\n const closeAndRefocusTrigger = () => {\n close()\n triggerRef.current?.focus()\n }\n\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (!clickEnabled || disabled) return\n event.preventDefault()\n event.stopPropagation()\n visible ? close() : openAndFocusFirst()\n }\n\n // A submenu cascades toward the reading direction, so the arrow key that opens it (and the\n // one its own item list closes on, below) mirror too: ArrowRight/ArrowLeft under LTR,\n // ArrowLeft/ArrowRight under RTL.\n const openKey = isRtl ? 'ArrowLeft' : 'ArrowRight'\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) return\n if (event.key === 'Enter' || event.key === ' ' || event.key === openKey) {\n event.preventDefault()\n event.stopPropagation()\n openAndFocusFirst()\n }\n }\n\n const actionsValue = { close: closeAndRefocusTrigger }\n\n return (\n <div className={classNames('submenu', { show: visible }, className)} {...rest} ref={ref}>\n <button\n type=\"button\"\n id={triggerId}\n role=\"menuitem\"\n className=\"menu-item\"\n aria-expanded={visible}\n aria-haspopup=\"true\"\n aria-controls={visible ? menuId : undefined}\n disabled={disabled}\n onClick={handleTriggerClick}\n onKeyDown={handleTriggerKeyDown}\n onMouseEnter={hoverEnabled ? open : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n ref={(node) => {\n triggerRef.current = node\n }}\n >\n {trigger}\n </button>\n {(() => {\n const panel = (\n <div\n role=\"menu\"\n id={menuId}\n aria-labelledby={triggerId}\n className={classNames('menu', { show: visible, 'submenu-stacked': stacked })}\n style={menuStyle}\n data-cx-placement={placementAttr}\n onKeyDown={(event) =>\n handleMenuKeyDown(event, {\n onEscape: closeAndRefocusTrigger,\n ...(isRtl\n ? { onArrowRight: closeAndRefocusTrigger }\n : { onArrowLeft: closeAndRefocusTrigger })\n })\n }\n onMouseEnter={hoverEnabled ? clearCloseTimeout : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n // Registers this panel with the ancestor `Menu` (see `MenuContext.registerOverlay`)\n // so its own click-dismiss logic recognizes clicks here as \"inside\" the menu — the\n // panel portals straight to `document.body` when not `stacked`, so plain DOM\n // containment against the top-level menu's own element wouldn't otherwise see it.\n ref={(node) => {\n overlayRef.current = node\n registerOverlay(menuId, node)\n }}\n >\n <SubmenuActionsContext.Provider value={actionsValue}>\n <SubmenuGroupContext.Provider value={ownGroup}>\n {children}\n </SubmenuGroupContext.Provider>\n </SubmenuActionsContext.Provider>\n </div>\n )\n\n // `stacked`'s sm-breakpoint CSS (`.menu:has(.submenu-stacked.show) ...`) needs the\n // panel to be a real DOM descendant of `.menu`/`.submenu` to match — portaling would\n // break that ancestor relationship, so it renders inline instead. Trade-off: above the\n // `sm` breakpoint a `stacked` submenu no longer escapes ancestor overflow/stacking-\n // context clipping the way a portaled one does; accepted since `stacked` targets mobile\n // nav/drawer usage, not floating dropdowns.\n // On the server and during hydration the panel renders inline next to its trigger, which\n // is what the server's HTML holds; `Portal` moves it to `document.body` afterwards.\n return stacked ? panel : <Portal fallback={panel}>{panel}</Portal>\n })()}\n </div>\n )\n }\n)\n\nMenuSubmenu.displayName = 'MenuSubmenu'\n","import React, { ButtonHTMLAttributes, forwardRef, useContext } from 'react'\nimport classNames from 'classnames'\n\nimport { SubmenuActionsContext } from './submenuGroup'\n\nexport interface MenuSubmenuBackProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n}\n\n// First item of a stacked submenu's nested menu (see `MenuSubmenu`'s `stacked` prop). Closes\n// the submenu and returns focus to its trigger — visible only below the `sm` breakpoint.\nexport const MenuSubmenuBack = forwardRef<HTMLButtonElement, MenuSubmenuBackProps>(\n ({ children, className, onClick, type = 'button', ...rest }, ref) => {\n const actions = useContext(SubmenuActionsContext)\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n actions?.close()\n }\n\n return (\n <button\n type={type}\n role=\"menuitem\"\n className={classNames('submenu-back', 'menu-item', className)}\n {...rest}\n onClick={handleClick}\n ref={ref}\n >\n {children}\n </button>\n )\n }\n)\n\nMenuSubmenuBack.displayName = 'MenuSubmenuBack'\n"],"mappings":"ifA6BA,SAAS,EACP,CAAE,WAAU,YAAW,YAAW,GAAG,GACrC,EACA,CACA,IAAM,EAAY,GAAa,OACzB,EAAa,EAAW,YAAa,CAAS,EAEpD,OACE,EAAA,cAAC,EAAD,CAAW,UAAW,EAAY,GAAI,EAAW,KAEtC,EADR,CACQ,CAEf,CAEA,MAAa,EAAW,EACtB,EACA,UACF,ECmBa,EAAc,GAEvB,CACE,WACA,aAAa,OACb,YACA,WACA,OAAQ,EAAa,CAAC,GAAI,CAAC,EAC3B,YACA,UACA,eAAe,IACf,UACA,GAAG,GAEL,IACG,CACH,IAAM,EAAK,GAAM,EACX,EAAY,GAAG,EAAG,UAClB,EAAS,GAAG,EAAG,OACf,CAAC,EAAS,GAAc,GAAS,EAAK,EACtC,EAAkB,EAA2B,IAAA,EAAS,EACtD,EAAmB,EAA2B,IAAA,EAAS,EACvD,EAAa,EAAiC,IAAI,EAClD,EAAa,EAA2B,IAAI,EAC5C,EAAc,EAAW,CAAmB,EAC5C,EAAW,EAAwB,EACnC,CAAE,kBAAiB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AA,GAK7C,IAAM,GAAS,CACb,EAAW,QAAU,EACrB,EAAgB,EAAQ,CAAI,CAC9B,CAOG,EALH,EAAA,cAAC,EAAsB,SAAvB,CAAgC,MAAO,EAIP,EAH9B,EAAA,cAAC,EAAoB,SAArB,CAA8B,MAAO,CAEP,EAD3B,CAC2B,CACA,CAC7B,EAWP,OAAO,EAAU,EAAQ,EAAA,cAAC,EAAD,CAAQ,SAAU,CAAsB,EAAd,CAAc,CACnE,EAAA,CAAG,CACA,CAET,CACF,EAEA,EAAY,YAAc,cCzQ1B,MAAa,EAAkB,GAC5B,CAAE,WAAU,YAAW,UAAS,OAAO,SAAU,GAAG,GAAQ,IAAQ,CACnE,IAAM,EAAU,EAAW,CAAqB,EAE1C,EAAe,GAA+C,CAClE,IAAU,CAAK,EACf,GAAS,MAAM,CACjB,EAEA,OACE,EAAA,cAAC,SAAD,CACQ,OACN,KAAK,WACL,UAAW,EAAW,eAAgB,YAAa,CAAS,EAC5D,GAAI,EACJ,QAAS,EACJ,KAGC,EADL,CACK,CAEZ,CACF,EAEA,EAAgB,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{m as e,u as t,v as n}from"./slot-CNhFZdHF.js";import{t as r}from"./useForkedRef-DVEfT-KI.js";import{t as i}from"./polymorphic-BhGNZQja.js";import{t as a}from"./Link-
|
|
2
|
-
//# sourceMappingURL=nav-
|
|
1
|
+
import"./focus-ring-SR_LwaN7.js";import{m as e,u as t,v as n}from"./slot-CNhFZdHF.js";import{t as r}from"./useForkedRef-DVEfT-KI.js";import{t as i}from"./polymorphic-BhGNZQja.js";import{t as a}from"./Link-DyZyAQFj.js";import{a as o,i as s,o as c,r as l,s as u}from"./navOverflow-B5krZe6D.js";import{t as d}from"./navVariant-DeGTk9B7.js";import f,{forwardRef as p}from"react";import m from"classnames";function h({children:e,className:t,...n},r){let i=m(`nav-link`,t),s=c();return f.createElement(f.Fragment,null,f.createElement(a,{className:i,...n,ref:r},e),s&&f.createElement(o,{props:{...n,children:e}}))}const g=i(h,`NavLink`),_=new Set([`active`,`color`,`disabled`,`iconLink`,`reset`,`stretched`,`type`]);function v({children:e,className:i,keepVisible:a,...o},s){let c=m(`nav-item`,{"nav-overflow-keep":a},i),{asChild:d,component:p,href:h}=o,v=u(),y=r(s,v.ref),b=v.hidden?{"data-cx-nav-overflow":`true`}:void 0;if(t(h)||p!==void 0||d)return f.createElement(`li`,{className:c,...b,ref:y},f.createElement(l,{value:v.scope},f.createElement(g,o,e)));let{active:x,disabled:S}=o,C=Object.fromEntries(Object.entries(o).filter(([e])=>!_.has(e)));return n(!!x||!!S,"NavItem: `active` and `disabled` style its link, and without `href`, `component` or `asChild` it renders none. Put them on the link inside it."),f.createElement(`li`,{className:c,...C,...b,ref:y},f.createElement(l,{value:v.scope},e))}const y=p(v);y.displayName=`NavItem`;function b({children:t,className:n,component:r,items:i,layout:a,size:o,variant:c,...l},u){let p=r??`ul`,h=m(`nav`,o,{[`nav-${a}`]:a},d(c,`Nav`),n),g=i?i.map((e,t)=>f.createElement(y,{key:t,active:e.active,disabled:e.disabled,href:e.href},e.label)):null;return f.createElement(p,{className:h,...l,ref:u},f.createElement(s,{tag:e(p)},g??t))}const x=i(b,`Nav`),S=p(({children:e,className:t,...n},r)=>{let i=m(`nav-title`,t);return f.createElement(`li`,{className:i,...n,ref:r},e)});S.displayName=`NavTitle`;export{g as i,x as n,y as r,S as t};
|
|
2
|
+
//# sourceMappingURL=nav-DI6oEULI.js.map
|