@senvenli/react 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/chart-parts.d.ts +21 -5
- package/dist/charts/chart-parts.js +31 -15
- package/dist/charts/chart-parts.js.map +1 -1
- package/dist/charts/core-charts.d.ts +2 -2
- package/dist/charts/core-charts.js +2 -2
- package/dist/charts/core-charts.js.map +1 -1
- package/dist/charts/list-charts.d.ts +4 -4
- package/dist/charts/list-charts.js +8 -8
- package/dist/charts/list-charts.js.map +1 -1
- package/dist/charts/more-charts.d.ts +9 -7
- package/dist/charts/more-charts.js +12 -12
- package/dist/charts/more-charts.js.map +1 -1
- package/dist/charts/report-charts.d.ts +2 -2
- package/dist/charts/report-charts.js +4 -4
- package/dist/charts/report-charts.js.map +1 -1
- package/dist/collection/table.js +4 -1
- package/dist/collection/table.js.map +1 -1
- package/dist/navigation/accordion.js +1 -1
- package/dist/navigation/accordion.js.map +1 -1
- package/dist/navigation/navbar.js +4 -2
- package/dist/navigation/navbar.js.map +1 -1
- package/dist/navigation/pagination.js +1 -1
- package/dist/navigation/pagination.js.map +1 -1
- package/dist/navigation/tabs.js +2 -2
- package/dist/navigation/tabs.js.map +1 -1
- package/manifests/area-chart.json +46 -1
- package/manifests/bar-chart.json +46 -0
- package/manifests/bar-list.json +6 -0
- package/manifests/calendar-heatmap.json +6 -0
- package/manifests/chart-parts.json +48 -1
- package/manifests/composed-chart.json +46 -1
- package/manifests/donut-chart.json +46 -1
- package/manifests/funnel-chart.json +6 -0
- package/manifests/gauge-chart.json +46 -1
- package/manifests/heatmap.json +6 -0
- package/manifests/line-chart.json +46 -1
- package/manifests/radar-chart.json +46 -1
- package/manifests/radial-chart.json +46 -1
- package/manifests/scatter-chart.json +46 -1
- package/manifests/sparkline.json +6 -1
- package/manifests/tracker.json +6 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navbar.js","source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* as React from \"react\";\nimport { Link as AriaLink, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { BrandLinkContext } from \"./brand-link-context\";\nimport { Button } from \"../action/button\";\nimport { mainNavigationLabel, openMenuLabel } from \"../i18n\";\nimport { LAYER } from \"../layers\";\nimport { NavPanel } from \"./nav-panel\";\n\nexport type NavbarLink = {\n /** Unique; `currentKey` matches it. */\n id: string;\n /** A noun for the place (\"Pricing\"), never a verb. */\n label: string;\n /** A page or an in-page anchor (\"/#pricing\"); it goes through the host router. */\n href: string;\n};\n\nexport type NavbarProps = {\n /** The logo and wordmark (the site's logo). It links to `brandHref`. Or a `NavbarBrand` child. */\n brand?: React.ReactNode;\n /** Where the brand goes: the home page. */\n brandHref?: string;\n /** The brand link's name when the brand alone does not say where it goes (\"Acme home\"). */\n brandLabel?: string;\n /** Up to five destinations. Leave it out to compose `NavbarItem`s as children instead. */\n links?: readonly NavbarLink[];\n /**\n * With no `links`: `NavbarItem`s (the destinations), plus an optional `NavbarBrand` (instead of `brand`) and\n * `NavbarActions` (instead of `actions`).\n */\n children?: React.ReactNode;\n /** The link of the page (or section) in view: marked `aria-current=\"page\"`. */\n currentKey?: string;\n /**\n * At the end: a language switcher, sign-in (subtle), then the one primary action, the same on every page. On\n * phones they move into the menu panel, under the links. Or a `NavbarActions` child.\n */\n actions?: React.ReactNode;\n /** Pinned to the top while the page scrolls. */\n isSticky?: boolean;\n /**\n * The width of the bar's content (\"1280px\", 1280), centred, so the brand and the actions line up with the page's\n * own container; the bar's background and border still run the full width. Left out, the content spans it.\n */\n maxWidth?: number | string;\n /** `compact`: 48px instead of 56px, the bar after the hero. */\n density?: Density;\n /** Names the navigation landmark; \"Main menu\" by default. */\n \"aria-label\"?: string;\n};\n\nconst LINK =\n \"inline-flex h-8 items-center gap-ds-075 rounded-ds-control-medium px-ds-100 text-body font-[500] text-ds-text-subtle outline-hidden transition-colors duration-(--ds-duration-fast) motion-reduce:transition-none \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[hovered]:text-ds-text data-[pressed]:bg-ds-background-neutral-pressed \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused \" +\n \"aria-[current=page]:bg-ds-background-neutral aria-[current=page]:text-ds-text\";\n\n/**\n * The top bar of public sites. Brand at the start, up to\n * five links (the current one on `ds-background-neutral`), then the language switch and the actions.\n * Under 768px the links, language switch and actions move into a menu panel from the end edge.\n */\nexport function Navbar({\n brand: brandProp,\n brandHref = \"/\",\n brandLabel,\n links,\n children,\n currentKey,\n actions: actionsProp,\n isSticky,\n maxWidth,\n density = \"comfortable\",\n \"aria-label\": label,\n}: NavbarProps) {\n const { locale } = useLocale();\n const [open, setOpen] = React.useState(false);\n const name = label ?? mainNavigationLabel(locale);\n const { brand, actions: endActions, items } = splitSlots(children, brandProp, actionsProp);\n const renderLinks = () =>\n links ? (\n links.map((link) => (\n <NavbarItem key={link.id} id={link.id} href={link.href}>\n {link.label}\n </NavbarItem>\n ))\n ) : (\n items\n );\n const brandLink = (\n <AriaLink\n href={brandHref}\n aria-label={brandLabel}\n data-slot=\"navbar-brand\"\n className=\"flex min-w-0 items-center gap-ds-100 rounded-ds-medium text-body-strong text-ds-text outline-hidden data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\"\n >\n <BrandLinkContext.Provider value>{brand}</BrandLinkContext.Provider>\n </AriaLink>\n );\n return (\n <header\n data-slot=\"navbar\"\n data-density={density}\n className={cn(\n \"border-b border-ds-border bg-ds-surface-raised text-ds-text\",\n isSticky && cn(\"sticky top-0 pt-[env(safe-area-inset-top,0px)]\", LAYER.stickyBar),\n )}\n >\n <div\n data-slot=\"navbar-content\"\n style={maxWidth !== undefined ? { maxWidth } : undefined}\n className={cn(\n \"flex items-center gap-ds-300 transition-[height] duration-(--ds-duration-medium) motion-reduce:transition-none\",\n maxWidth !== undefined && \"mx-auto w-full\",\n // Safe-area insets are physical edges, so they pair with physical padding.\n \"[padding-left:max(var(--ds-space-200),env(safe-area-inset-left,0px))] [padding-right:max(var(--ds-space-200),env(safe-area-inset-right,0px))]\",\n \"md:[padding-left:max(var(--ds-space-300),env(safe-area-inset-left,0px))] md:[padding-right:max(var(--ds-space-300),env(safe-area-inset-right,0px))]\",\n density === \"compact\" ? \"h-12\" : \"h-14\",\n )}\n >\n {brandLink}\n <nav aria-label={name} data-slot=\"navbar-links\" className=\"hidden md:block\">\n <ul className=\"flex items-center gap-ds-100\">\n <NavbarContext.Provider value={{ currentKey, inPanel: false }}>{renderLinks()}</NavbarContext.Provider>\n </ul>\n </nav>\n <div data-slot=\"navbar-end\" className=\"ms-auto flex items-center gap-ds-100\">\n <div className=\"hidden items-center gap-ds-100 md:flex\">\n {endActions}\n </div>\n <div className=\"md:hidden\">\n <Button\n variant=\"subtle\"\n iconOnly\n iconBefore=\"menu\"\n aria-label={openMenuLabel(locale)}\n aria-expanded={open}\n onPress={() => setOpen(true)}\n data-slot=\"navbar-menu-button\"\n />\n </div>\n </div>\n </div>\n <NavPanel isOpen={open} onOpenChange={setOpen} label={name} side=\"end\" slot=\"navbar\" header={brand}>\n {/* The dialog already carries the name; a second landmark name would be read twice. */}\n <nav>\n <ul className=\"flex flex-col gap-ds-025\">\n <NavbarContext.Provider value={{ currentKey, inPanel: true }}>{renderLinks()}</NavbarContext.Provider>\n </ul>\n </nav>\n {endActions && (\n <div data-slot=\"navbar-panel-actions\" className=\"flex flex-col items-stretch gap-ds-100 border-t border-ds-border pt-ds-200\">\n {endActions}\n </div>\n )}\n </NavPanel>\n </header>\n );\n}\n\n// ---- Composed from parts ---------------------------------------------------------------------------------------\n\n/** Where a `NavbarItem` renders: the bar, or the phone menu panel (a full-width 44px row). */\nconst NavbarContext = React.createContext<{ currentKey?: string; inPanel: boolean } | null>(null);\n\nexport type NavbarItemProps = {\n /** Matches the Navbar's `currentKey`. */\n id: string;\n /** A page or an in-page anchor (\"/#pricing\"); it goes through the host router. */\n href: string;\n /** A noun for the place (\"Pricing\"), never a verb. */\n children: React.ReactNode;\n /** Marks this link as the page in view, instead of the Navbar's `currentKey`. */\n isCurrent?: boolean;\n};\n\n/** One destination. It shows in the bar from 768px up and in the menu panel below that. */\nexport function NavbarItem({ id, href, children, isCurrent }: NavbarItemProps) {\n const context = React.useContext(NavbarContext);\n if (!context) throw new Error(\"NavbarItem must be inside a Navbar.\");\n return (\n <li>\n <AriaLink\n href={href}\n data-slot={context.inPanel ? \"navbar-panel-link\" : \"navbar-link\"}\n aria-current={isCurrent || id === context.currentKey ? \"page\" : undefined}\n className={context.inPanel ? cn(LINK, \"flex h-11 w-full\") : LINK}\n >\n {children}\n </AriaLink>\n </li>\n );\n}\n\nexport type NavbarBrandProps = {\n /** The logo and wordmark; it links to the Navbar's `brandHref`. */\n children: React.ReactNode;\n};\n\n/** The brand at the start, as a child instead of the `brand` prop. */\nexport function NavbarBrand({ children }: NavbarBrandProps) {\n return <>{children}</>;\n}\n\nexport type NavbarActionsProps = {\n /** A language switcher, sign-in (subtle), then the one primary action. */\n children: React.ReactNode;\n};\n\n/** The actions at the end, as a child instead of the `actions` prop; on phones they move into the menu panel. */\nexport function NavbarActions({ children }: NavbarActionsProps) {\n return <>{children}</>;\n}\n\n/** Pulls `NavbarBrand` and `NavbarActions` out of the children; the rest are the items. Props win over children. */\nfunction splitSlots(children: React.ReactNode, brand: React.ReactNode, actions: React.ReactNode) {\n let brandSlot: React.ReactNode;\n let actionsSlot: React.ReactNode;\n const items: React.ReactNode[] = [];\n for (const child of React.Children.toArray(children)) {\n if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === NavbarBrand) brandSlot = child.props.children;\n else if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === NavbarActions) actionsSlot = child.props.children;\n else items.push(child);\n }\n return { brand: brand ?? brandSlot, actions: actions ?? actionsSlot, items };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"navbar.js","sourceRoot":"","sources":["../../src/navigation/navbar.tsx"],"names":[],"mappings":"AAA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AC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EACzE,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI,YAE/D,QAAQ,GACA,GACR,CACN,CAAC;AACJ,CAAC;AAOD,sEAAsE;AACtE,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAoB;IACxD,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC;AAOD,iHAAiH;AACjH,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAsB;IAC5D,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC;AAED,oHAAoH;AACpH,SAAS,UAAU,CAAC,QAAyB,EAAE,KAAsB,EAAE,OAAwB;IAC7F,IAAI,SAA0B,CAAC;IAC/B,IAAI,WAA4B,CAAC;IACjC,MAAM,KAAK,GAAsB,EAAE,CAAC;IACpC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,cAAc,CAAiC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;aAC3H,IAAI,KAAK,CAAC,cAAc,CAAiC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa;YAAE,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;;YACpI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,EAAE,CAAC;AAC/E,CAAC","sourcesContent":["\"use client\";\n\nimport type { Density } from \"../density\";\nimport * as React from \"react\";\nimport { Link as AriaLink, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { BrandLinkContext } from \"./brand-link-context\";\nimport { Button } from \"../action/button\";\nimport { mainNavigationLabel, openMenuLabel } from \"../i18n\";\nimport { LAYER } from \"../layers\";\nimport { NavPanel } from \"./nav-panel\";\n\nexport type NavbarLink = {\n /** Unique; `currentKey` matches it. */\n id: string;\n /** A noun for the place (\"Pricing\"), never a verb. */\n label: string;\n /** A page or an in-page anchor (\"/#pricing\"); it goes through the host router. */\n href: string;\n};\n\nexport type NavbarProps = {\n /** The logo and wordmark (the site's logo). It links to `brandHref`. Or a `NavbarBrand` child. */\n brand?: React.ReactNode;\n /** Where the brand goes: the home page. */\n brandHref?: string;\n /** The brand link's name when the brand alone does not say where it goes (\"Acme home\"). */\n brandLabel?: string;\n /** Up to five destinations. Leave it out to compose `NavbarItem`s as children instead. */\n links?: readonly NavbarLink[];\n /**\n * With no `links`: `NavbarItem`s (the destinations), plus an optional `NavbarBrand` (instead of `brand`) and\n * `NavbarActions` (instead of `actions`).\n */\n children?: React.ReactNode;\n /** The link of the page (or section) in view: marked `aria-current=\"page\"`. */\n currentKey?: string;\n /**\n * At the end: a language switcher, sign-in (subtle), then the one primary action, the same on every page. On\n * phones they move into the menu panel, under the links. Or a `NavbarActions` child.\n */\n actions?: React.ReactNode;\n /** Pinned to the top while the page scrolls. */\n isSticky?: boolean;\n /**\n * The width of the bar's content (\"1280px\", 1280), centred, so the brand and the actions line up with the page's\n * own container; the bar's background and border still run the full width. Left out, the content spans it.\n */\n maxWidth?: number | string;\n /** `compact`: 48px instead of 56px, the bar after the hero. */\n density?: Density;\n /** Names the navigation landmark; \"Main menu\" by default. */\n \"aria-label\"?: string;\n};\n\nconst LINK =\n \"inline-flex h-8 items-center gap-ds-075 whitespace-nowrap rounded-ds-control-medium px-ds-100 text-body font-[500] text-ds-text-subtle outline-hidden transition-colors duration-(--ds-duration-fast) motion-reduce:transition-none \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[hovered]:text-ds-text data-[pressed]:bg-ds-background-neutral-pressed \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused \" +\n \"aria-[current=page]:bg-ds-background-neutral aria-[current=page]:text-ds-text\";\n\n/**\n * The top bar of public sites. Brand at the start, up to\n * five links (the current one on `ds-background-neutral`), then the language switch and the actions.\n * Under 768px the links, language switch and actions move into a menu panel from the end edge.\n */\nexport function Navbar({\n brand: brandProp,\n brandHref = \"/\",\n brandLabel,\n links,\n children,\n currentKey,\n actions: actionsProp,\n isSticky,\n maxWidth,\n density = \"comfortable\",\n \"aria-label\": label,\n}: NavbarProps) {\n const { locale } = useLocale();\n const [open, setOpen] = React.useState(false);\n const name = label ?? mainNavigationLabel(locale);\n const { brand, actions: endActions, items } = splitSlots(children, brandProp, actionsProp);\n const renderLinks = () =>\n links ? (\n links.map((link) => (\n <NavbarItem key={link.id} id={link.id} href={link.href}>\n {link.label}\n </NavbarItem>\n ))\n ) : (\n items\n );\n const brandLink = (\n <AriaLink\n href={brandHref}\n aria-label={brandLabel}\n data-slot=\"navbar-brand\"\n // shrink-0: the brand keeps its size and the links give way, so a wide wordmark never runs under the first link.\n className=\"flex shrink-0 items-center gap-ds-100 rounded-ds-medium text-body-strong text-ds-text outline-hidden data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\"\n >\n <BrandLinkContext.Provider value>{brand}</BrandLinkContext.Provider>\n </AriaLink>\n );\n return (\n <header\n data-slot=\"navbar\"\n data-density={density}\n className={cn(\n \"border-b border-ds-border bg-ds-surface-raised text-ds-text\",\n isSticky && cn(\"sticky top-0 pt-[env(safe-area-inset-top,0px)]\", LAYER.stickyBar),\n )}\n >\n <div\n data-slot=\"navbar-content\"\n style={maxWidth !== undefined ? { maxWidth } : undefined}\n className={cn(\n \"flex items-center gap-ds-300 transition-[height] duration-(--ds-duration-medium) motion-reduce:transition-none\",\n maxWidth !== undefined && \"mx-auto w-full\",\n // Safe-area insets are physical edges, so they pair with physical padding.\n \"[padding-left:max(var(--ds-space-200),env(safe-area-inset-left,0px))] [padding-right:max(var(--ds-space-200),env(safe-area-inset-right,0px))]\",\n \"md:[padding-left:max(var(--ds-space-300),env(safe-area-inset-left,0px))] md:[padding-right:max(var(--ds-space-300),env(safe-area-inset-right,0px))]\",\n density === \"compact\" ? \"h-12\" : \"h-14\",\n )}\n >\n {brandLink}\n <nav aria-label={name} data-slot=\"navbar-links\" className=\"hidden md:block\">\n <ul className=\"flex items-center gap-ds-100\">\n <NavbarContext.Provider value={{ currentKey, inPanel: false }}>{renderLinks()}</NavbarContext.Provider>\n </ul>\n </nav>\n <div data-slot=\"navbar-end\" className=\"ms-auto flex items-center gap-ds-100\">\n <div className=\"hidden items-center gap-ds-100 md:flex\">\n {endActions}\n </div>\n <div className=\"md:hidden\">\n <Button\n variant=\"subtle\"\n iconOnly\n iconBefore=\"menu\"\n aria-label={openMenuLabel(locale)}\n aria-expanded={open}\n onPress={() => setOpen(true)}\n data-slot=\"navbar-menu-button\"\n />\n </div>\n </div>\n </div>\n <NavPanel isOpen={open} onOpenChange={setOpen} label={name} side=\"end\" slot=\"navbar\" header={brand}>\n {/* The dialog already carries the name; a second landmark name would be read twice. */}\n <nav>\n <ul className=\"flex flex-col gap-ds-025\">\n <NavbarContext.Provider value={{ currentKey, inPanel: true }}>{renderLinks()}</NavbarContext.Provider>\n </ul>\n </nav>\n {endActions && (\n <div data-slot=\"navbar-panel-actions\" className=\"flex flex-col items-stretch gap-ds-100 border-t border-ds-border pt-ds-200\">\n {endActions}\n </div>\n )}\n </NavPanel>\n </header>\n );\n}\n\n// ---- Composed from parts ---------------------------------------------------------------------------------------\n\n/** Where a `NavbarItem` renders: the bar, or the phone menu panel (a full-width 44px row). */\nconst NavbarContext = React.createContext<{ currentKey?: string; inPanel: boolean } | null>(null);\n\nexport type NavbarItemProps = {\n /** Matches the Navbar's `currentKey`. */\n id: string;\n /** A page or an in-page anchor (\"/#pricing\"); it goes through the host router. */\n href: string;\n /** A noun for the place (\"Pricing\"), never a verb. */\n children: React.ReactNode;\n /** Marks this link as the page in view, instead of the Navbar's `currentKey`. */\n isCurrent?: boolean;\n};\n\n/** One destination. It shows in the bar from 768px up and in the menu panel below that. */\nexport function NavbarItem({ id, href, children, isCurrent }: NavbarItemProps) {\n const context = React.useContext(NavbarContext);\n if (!context) throw new Error(\"NavbarItem must be inside a Navbar.\");\n return (\n <li>\n <AriaLink\n href={href}\n data-slot={context.inPanel ? \"navbar-panel-link\" : \"navbar-link\"}\n aria-current={isCurrent || id === context.currentKey ? \"page\" : undefined}\n className={context.inPanel ? cn(LINK, \"flex h-11 w-full\") : LINK}\n >\n {children}\n </AriaLink>\n </li>\n );\n}\n\nexport type NavbarBrandProps = {\n /** The logo and wordmark; it links to the Navbar's `brandHref`. */\n children: React.ReactNode;\n};\n\n/** The brand at the start, as a child instead of the `brand` prop. */\nexport function NavbarBrand({ children }: NavbarBrandProps) {\n return <>{children}</>;\n}\n\nexport type NavbarActionsProps = {\n /** A language switcher, sign-in (subtle), then the one primary action. */\n children: React.ReactNode;\n};\n\n/** The actions at the end, as a child instead of the `actions` prop; on phones they move into the menu panel. */\nexport function NavbarActions({ children }: NavbarActionsProps) {\n return <>{children}</>;\n}\n\n/** Pulls `NavbarBrand` and `NavbarActions` out of the children; the rest are the items. Props win over children. */\nfunction splitSlots(children: React.ReactNode, brand: React.ReactNode, actions: React.ReactNode) {\n let brandSlot: React.ReactNode;\n let actionsSlot: React.ReactNode;\n const items: React.ReactNode[] = [];\n for (const child of React.Children.toArray(children)) {\n if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === NavbarBrand) brandSlot = child.props.children;\n else if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === NavbarActions) actionsSlot = child.props.children;\n else items.push(child);\n }\n return { brand: brand ?? brandSlot, actions: actions ?? actionsSlot, items };\n}\n"]}
|
|
@@ -22,7 +22,7 @@ export function pageWindow(page, pages) {
|
|
|
22
22
|
});
|
|
23
23
|
return out;
|
|
24
24
|
}
|
|
25
|
-
const PAGE = "grid h-8 min-w-8 cursor-
|
|
25
|
+
const PAGE = "grid h-8 min-w-8 cursor-pointer data-[disabled]:cursor-not-allowed place-items-center rounded-ds-control-medium px-ds-075 text-body tabular-nums text-ds-text outline-hidden " +
|
|
26
26
|
"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[pressed]:bg-ds-background-neutral-pressed " +
|
|
27
27
|
"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused " +
|
|
28
28
|
// The current page: a soft neutral fill, the full text color and weight (not colour alone); no rim.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/navigation/pagination.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvI,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAmB3C,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,KAAa;IACpD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,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AI,CACnB,4BAAe,iBAAiB,EAAC,SAAS,EAAE,EAAE,CAAC,8BAA8B,CAAC,aAC5E,oCAAkB,SAAS,EAAC,qCAAqC,YAAE,YAAY,CAAC,MAAM,CAAC,GAAQ,EAC/F,KAAC,IAAI,kBACS,YAAY,CAAC,MAAM,CAAC,EAChC,aAAa,EAAC,QAAQ,EACtB,YAAY,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAChC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAChD,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAC9E,OAAO,EACL,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,cAAc,gBAAa,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,YAC/H,eAAM,SAAS,EAAC,cAAc,YAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAQ,GACxD,GAEX,IACE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Button as AriaButton, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { Button } from \"../action/button\";\nimport { IconGlyph } from \"../display/icon\";\nimport { intlLocale, nextPageLabel, pageLabel, pageOfLabel, pagesLabel, perPageLabel, previousPageLabel, rangeOfLabel } from \"../i18n\";\nimport { Menu } from \"../overlay/floating\";\n\nexport type PaginationProps = {\n /** 1-based. Keep it in the URL so back and refresh return to it. */\n page: number;\n pageSize: number;\n /** All items across pages. */\n total: number;\n onPageChange: (page: number) => void;\n onPageSizeChange?: (pageSize: number) => void;\n /** 20, 50 and 100 by default; the current size joins the list when it is not in it. */\n pageSizeOptions?: readonly number[];\n /**\n * The range sentence naming the items: (41, 60, 1204) → \"41–60 of 1,204 orders\". It gets the\n * raw numbers; format them for the locale yourself (Intl.NumberFormat).\n */\n formatRange?: (from: number, to: number, total: number) => string;\n};\n\n/** First, last, the current page and one neighbour each side; gaps of two or more become \"…\". */\nexport function pageWindow(page: number, pages: number): (number | \"gap\")[] {\n const keep = new Set([1, pages, page - 1, page, page + 1].filter((n) => n >= 1 && n <= pages));\n const sorted = [...keep].sort((a, b) => a - b);\n const out: (number | \"gap\")[] = [];\n sorted.forEach((n, i) => {\n const previous = sorted[i - 1];\n if (previous !== undefined && n - previous === 2) out.push(previous + 1);\n else if (previous !== undefined && n - previous > 2) out.push(\"gap\");\n out.push(n);\n });\n return out;\n}\n\nconst PAGE =\n \"grid h-8 min-w-8 cursor-default place-items-center rounded-ds-control-medium px-ds-075 text-body tabular-nums text-ds-text outline-hidden \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[pressed]:bg-ds-background-neutral-pressed \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused \" +\n // The current page: a soft neutral fill, the full text color and weight (not colour alone); no rim.\n \"aria-[current=page]:bg-ds-background-neutral-hovered aria-[current=page]:font-medium aria-[current=page]:text-ds-text\";\n\n/**\n * Moves through a long, server-paged list and says where the reader is: the range, the pages (first,\n * last, the current one and its neighbours) and the page size. On phones only previous and next stay,\n * with \"Sayfa 3 / 61\". For feeds and timelines, load more on scroll instead.\n */\nexport function Pagination({\n page,\n pageSize,\n total,\n onPageChange,\n onPageSizeChange,\n pageSizeOptions = [20, 50, 100],\n formatRange,\n}: PaginationProps) {\n const { locale } = useLocale();\n const number = new Intl.NumberFormat(intlLocale(locale));\n const pages = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));\n const current = Math.min(Math.max(1, page), pages);\n const from = total === 0 ? 0 : (current - 1) * pageSize + 1;\n const to = Math.min(total, current * pageSize);\n // A size the options do not list (a saved 25) joins them, so the control never shows nothing.\n const sizes = [...new Set([...pageSizeOptions, pageSize])].sort((a, b) => a - b);\n // An empty list has no range to state (\"0–0 of 0\" says nothing); the list's own empty state speaks.\n const range = total === 0 ? \"\" : formatRange ? formatRange(from, to, total) : rangeOfLabel(locale, from, to, total);\n // Previous points to the inline start: left in LTR, right in RTL. The chevron is named for LTR and IconGlyph\n // mirrors it on an RTL page, so it is never flipped twice.\n const step = (label: string, toward: \"previous\" | \"next\", target: number) => (\n <Button\n variant=\"subtle\"\n size=\"small\"\n iconOnly\n iconBefore={toward === \"previous\" ? \"chevron-left\" : \"chevron-right\"}\n aria-label={label}\n isDisabled={target < 1 || target > pages}\n onPress={() => onPageChange(target)}\n data-slot={`pagination-${toward}`}\n />\n );\n return (\n <div data-slot=\"pagination\" className=\"flex flex-wrap items-center justify-between gap-ds-200\">\n <span data-slot=\"pagination-range\" aria-live=\"polite\" className=\"text-body-small tabular-nums text-ds-text-subtle\">\n {range}\n </span>\n <nav aria-label={pagesLabel(locale)} data-slot=\"pagination-pages\" className=\"flex items-center gap-ds-050\">\n {step(previousPageLabel(locale), \"previous\", current - 1)}\n <ul className=\"hidden items-center gap-ds-050 sm:flex\">\n {pageWindow(current, pages).map((entry, index) =>\n entry === \"gap\" ? (\n <li key={`gap-${index}`} aria-hidden data-slot=\"pagination-gap\" className=\"grid h-8 min-w-8 place-items-center text-body text-ds-text-disabled\">\n …\n </li>\n ) : (\n <li key={entry}>\n <AriaButton\n data-slot=\"pagination-page\"\n aria-label={pageLabel(locale, entry)}\n aria-current={entry === current ? \"page\" : undefined}\n onPress={() => entry !== current && onPageChange(entry)}\n className={PAGE}\n >\n {number.format(entry)}\n </AriaButton>\n </li>\n ),\n )}\n </ul>\n <span data-slot=\"pagination-compact\" className=\"px-ds-100 text-body-small tabular-nums text-ds-text-subtle sm:hidden\">\n {pageOfLabel(locale, current, pages)}\n </span>\n {step(nextPageLabel(locale), \"next\", current + 1)}\n </nav>\n {onPageSizeChange && (\n <div data-slot=\"pagination-size\" className={cn(\"flex items-center gap-ds-100\")}>\n <span aria-hidden className=\"text-body-small text-ds-text-subtle\">{perPageLabel(locale)}</span>\n <Menu\n aria-label={perPageLabel(locale)}\n selectionMode=\"single\"\n selectedKeys={[String(pageSize)]}\n onAction={(key) => onPageSizeChange(Number(key))}\n items={sizes.map((size) => ({ id: String(size), label: number.format(size) }))}\n trigger={\n <Button variant=\"default\" size=\"small\" iconAfter=\"chevron-down\" aria-label={`${perPageLabel(locale)}: ${number.format(pageSize)}`}>\n <span className=\"tabular-nums\">{number.format(pageSize)}</span>\n </Button>\n }\n />\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/navigation/pagination.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvI,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAmB3C,iGAAiG;AACjG,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,KAAa;IACpD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,C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MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,IAC7C,EACL,gBAAgB,IAAI,CACnB,4BAAe,iBAAiB,EAAC,SAAS,EAAE,EAAE,CAAC,8BAA8B,CAAC,aAC5E,oCAAkB,SAAS,EAAC,qCAAqC,YAAE,YAAY,CAAC,MAAM,CAAC,GAAQ,EAC/F,KAAC,IAAI,kBACS,YAAY,CAAC,MAAM,CAAC,EAChC,aAAa,EAAC,QAAQ,EACtB,YAAY,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAChC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAChD,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAC9E,OAAO,EACL,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,cAAc,gBAAa,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,YAC/H,eAAM,SAAS,EAAC,cAAc,YAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAQ,GACxD,GAEX,IACE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Button as AriaButton, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { Button } from \"../action/button\";\nimport { IconGlyph } from \"../display/icon\";\nimport { intlLocale, nextPageLabel, pageLabel, pageOfLabel, pagesLabel, perPageLabel, previousPageLabel, rangeOfLabel } from \"../i18n\";\nimport { Menu } from \"../overlay/floating\";\n\nexport type PaginationProps = {\n /** 1-based. Keep it in the URL so back and refresh return to it. */\n page: number;\n pageSize: number;\n /** All items across pages. */\n total: number;\n onPageChange: (page: number) => void;\n onPageSizeChange?: (pageSize: number) => void;\n /** 20, 50 and 100 by default; the current size joins the list when it is not in it. */\n pageSizeOptions?: readonly number[];\n /**\n * The range sentence naming the items: (41, 60, 1204) → \"41–60 of 1,204 orders\". It gets the\n * raw numbers; format them for the locale yourself (Intl.NumberFormat).\n */\n formatRange?: (from: number, to: number, total: number) => string;\n};\n\n/** First, last, the current page and one neighbour each side; gaps of two or more become \"…\". */\nexport function pageWindow(page: number, pages: number): (number | \"gap\")[] {\n const keep = new Set([1, pages, page - 1, page, page + 1].filter((n) => n >= 1 && n <= pages));\n const sorted = [...keep].sort((a, b) => a - b);\n const out: (number | \"gap\")[] = [];\n sorted.forEach((n, i) => {\n const previous = sorted[i - 1];\n if (previous !== undefined && n - previous === 2) out.push(previous + 1);\n else if (previous !== undefined && n - previous > 2) out.push(\"gap\");\n out.push(n);\n });\n return out;\n}\n\nconst PAGE =\n \"grid h-8 min-w-8 cursor-pointer data-[disabled]:cursor-not-allowed place-items-center rounded-ds-control-medium px-ds-075 text-body tabular-nums text-ds-text outline-hidden \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[pressed]:bg-ds-background-neutral-pressed \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused \" +\n // The current page: a soft neutral fill, the full text color and weight (not colour alone); no rim.\n \"aria-[current=page]:bg-ds-background-neutral-hovered aria-[current=page]:font-medium aria-[current=page]:text-ds-text\";\n\n/**\n * Moves through a long, server-paged list and says where the reader is: the range, the pages (first,\n * last, the current one and its neighbours) and the page size. On phones only previous and next stay,\n * with \"Sayfa 3 / 61\". For feeds and timelines, load more on scroll instead.\n */\nexport function Pagination({\n page,\n pageSize,\n total,\n onPageChange,\n onPageSizeChange,\n pageSizeOptions = [20, 50, 100],\n formatRange,\n}: PaginationProps) {\n const { locale } = useLocale();\n const number = new Intl.NumberFormat(intlLocale(locale));\n const pages = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));\n const current = Math.min(Math.max(1, page), pages);\n const from = total === 0 ? 0 : (current - 1) * pageSize + 1;\n const to = Math.min(total, current * pageSize);\n // A size the options do not list (a saved 25) joins them, so the control never shows nothing.\n const sizes = [...new Set([...pageSizeOptions, pageSize])].sort((a, b) => a - b);\n // An empty list has no range to state (\"0–0 of 0\" says nothing); the list's own empty state speaks.\n const range = total === 0 ? \"\" : formatRange ? formatRange(from, to, total) : rangeOfLabel(locale, from, to, total);\n // Previous points to the inline start: left in LTR, right in RTL. The chevron is named for LTR and IconGlyph\n // mirrors it on an RTL page, so it is never flipped twice.\n const step = (label: string, toward: \"previous\" | \"next\", target: number) => (\n <Button\n variant=\"subtle\"\n size=\"small\"\n iconOnly\n iconBefore={toward === \"previous\" ? \"chevron-left\" : \"chevron-right\"}\n aria-label={label}\n isDisabled={target < 1 || target > pages}\n onPress={() => onPageChange(target)}\n data-slot={`pagination-${toward}`}\n />\n );\n return (\n <div data-slot=\"pagination\" className=\"flex flex-wrap items-center justify-between gap-ds-200\">\n <span data-slot=\"pagination-range\" aria-live=\"polite\" className=\"text-body-small tabular-nums text-ds-text-subtle\">\n {range}\n </span>\n <nav aria-label={pagesLabel(locale)} data-slot=\"pagination-pages\" className=\"flex items-center gap-ds-050\">\n {step(previousPageLabel(locale), \"previous\", current - 1)}\n <ul className=\"hidden items-center gap-ds-050 sm:flex\">\n {pageWindow(current, pages).map((entry, index) =>\n entry === \"gap\" ? (\n <li key={`gap-${index}`} aria-hidden data-slot=\"pagination-gap\" className=\"grid h-8 min-w-8 place-items-center text-body text-ds-text-disabled\">\n …\n </li>\n ) : (\n <li key={entry}>\n <AriaButton\n data-slot=\"pagination-page\"\n aria-label={pageLabel(locale, entry)}\n aria-current={entry === current ? \"page\" : undefined}\n onPress={() => entry !== current && onPageChange(entry)}\n className={PAGE}\n >\n {number.format(entry)}\n </AriaButton>\n </li>\n ),\n )}\n </ul>\n <span data-slot=\"pagination-compact\" className=\"px-ds-100 text-body-small tabular-nums text-ds-text-subtle sm:hidden\">\n {pageOfLabel(locale, current, pages)}\n </span>\n {step(nextPageLabel(locale), \"next\", current + 1)}\n </nav>\n {onPageSizeChange && (\n <div data-slot=\"pagination-size\" className={cn(\"flex items-center gap-ds-100\")}>\n <span aria-hidden className=\"text-body-small text-ds-text-subtle\">{perPageLabel(locale)}</span>\n <Menu\n aria-label={perPageLabel(locale)}\n selectionMode=\"single\"\n selectedKeys={[String(pageSize)]}\n onAction={(key) => onPageSizeChange(Number(key))}\n items={sizes.map((size) => ({ id: String(size), label: number.format(size) }))}\n trigger={\n <Button variant=\"default\" size=\"small\" iconAfter=\"chevron-down\" aria-label={`${perPageLabel(locale)}: ${number.format(pageSize)}`}>\n <span className=\"tabular-nums\">{number.format(pageSize)}</span>\n </Button>\n }\n />\n </div>\n )}\n </div>\n );\n}\n"]}
|
package/dist/navigation/tabs.js
CHANGED
|
@@ -36,7 +36,7 @@ const TabsLook = React.createContext({
|
|
|
36
36
|
orientation: "horizontal",
|
|
37
37
|
size: "medium",
|
|
38
38
|
});
|
|
39
|
-
const TAB = "relative isolate inline-flex h-10 shrink-0 cursor-
|
|
39
|
+
const TAB = "relative isolate inline-flex h-10 shrink-0 cursor-pointer data-[disabled]:cursor-not-allowed items-center gap-ds-075 rounded-ds-small text-body font-[500] whitespace-nowrap text-ds-text-subtle outline-hidden " +
|
|
40
40
|
"transition-colors duration-(--ds-duration-fast) motion-reduce:transition-none " +
|
|
41
41
|
"data-[hovered]:text-ds-text data-[selected]:text-ds-text " +
|
|
42
42
|
"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused data-[disabled]:text-ds-text-disabled";
|
|
@@ -90,7 +90,7 @@ function TabsBody({ items, children, selectedKey, defaultSelectedKey, onSelectio
|
|
|
90
90
|
*/
|
|
91
91
|
const SEGMENT_INDICATOR = "absolute inset-0 -z-10 rounded-[max(0px,calc(var(--ds-radius-control-medium,var(--ds-radius-medium))-2px))] bg-ds-background-segment-selected shadow-ds-raised " +
|
|
92
92
|
"transition-[translate,width] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none";
|
|
93
|
-
const SEGMENT = "inline-flex h-7 cursor-
|
|
93
|
+
const SEGMENT = "inline-flex h-7 cursor-pointer data-[disabled]:cursor-not-allowed items-center rounded-[max(0px,calc(var(--ds-radius-control-medium,var(--ds-radius-medium))-2px))] px-ds-150 text-body font-[500] whitespace-nowrap text-ds-text-subtle outline-hidden " +
|
|
94
94
|
"transition-[background-color,color,box-shadow] duration-(--ds-duration-fast) motion-reduce:transition-none " +
|
|
95
95
|
"data-[hovered]:text-ds-text " +
|
|
96
96
|
"relative isolate data-[selected]:text-ds-text " +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/navigation/tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,GAAG,IAAI,OAAO,EACd,OAAO,IAAI,WAAW,EACtB,mBAAmB,EACnB,QAAQ,IAAI,YAAY,EACxB,IAAI,IAAI,QAAQ,EAChB,YAAY,IAAI,gBAAgB,EAChC,iBAAiB,IAAI,qBAAqB,GAE3C,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAuC,MAAM,aAAa,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AA2DzC,mIAAmI;AACnI,MAAM,KAAK,GAAG,oHAAoH,CAAC;AACnI,MAAM,IAAI,GAAG,2EAA2E,CAAC;AACzF,MAAM,KAAK,GAAG,yFAAyF,CAAC;AAExG,kHAAkH;AAClH,MAAM,aAAa,GAAyD;IAC1E,SAAS,EAAE;QACT,U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X,CACpB,CAAC,GACoB,CACzB,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAA0B;IAC/D,OAAO,CACL,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,YACzB,KAAC,QAAQ,OAAM,KAAmB,GAAI,GAC1B,CACf,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n SelectionIndicator,\n Tab as AriaTab,\n TabList as AriaTabList,\n TabListStateContext,\n TabPanel as AriaTabPanel,\n Tabs as AriaTabs,\n ToggleButton as AriaToggleButton,\n ToggleButtonGroup as AriaToggleButtonGroup,\n type Key,\n} from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { MotionScope, useComponentDefaults, type ComponentSize, type WithMotion } from \"../defaults\";\nimport { Badge } from \"../display/badge\";\n\nexport type TabItem = {\n id: Key;\n /** A noun, one or two words (\"Orders\"). */\n label: string;\n /** A count after the label (a Badge), e.g. open damage records. */\n count?: number;\n isDisabled?: boolean;\n panel: React.ReactNode;\n};\n\nexport type TabsProps = {\n /**\n * Two to six tabs as data. Leave it out and compose `TabList`, `Tab` and `TabPanel` as children instead,\n * for a tab with an icon, a panel built elsewhere, or tabs rendered from your own components.\n */\n items?: readonly TabItem[];\n /** With no `items`: a `TabList` of `Tab`s followed by one `TabPanel` per tab, matched by `id`. */\n children?: React.ReactNode;\n selectedKey?: Key;\n defaultSelectedKey?: Key;\n onSelectionChange?: (key: Key) => void;\n /** Names the tab list when no heading above it does (with `items`; on `TabList` otherwise). */\n \"aria-label\"?: string;\n /** `underline` (default): a line under the selected tab; `pills`: a filled tab; `outline`: a framed tab. */\n variant?: TabsVariant;\n /** `horizontal` (default), or `vertical`: the tabs in a column beside the panels (settings pages). */\n orientation?: \"horizontal\" | \"vertical\";\n /** `small`, `medium` (default) or `large`; the provider default otherwise. */\n size?: ComponentSize;\n};\n\nexport type TabsVariant = \"underline\" | \"pills\" | \"outline\";\n\nexport type TabListProps = {\n /** `Tab` elements. */\n children: React.ReactNode;\n /** Names the tab list when no heading above it does. */\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n};\n\nexport type TabProps = {\n /** Matches the `TabPanel` with the same `id`. */\n id: Key;\n /** The label: a noun, one or two words, optionally with an Icon before it. */\n children: React.ReactNode;\n /** A count after the label (a Badge); hidden at 0. */\n count?: number;\n isDisabled?: boolean;\n};\n\nexport type TabPanelProps = {\n /** Matches the `Tab` with the same `id`. */\n id: Key;\n children: React.ReactNode;\n};\n\n/** The selected tab's 2px underline (never colour alone); React Aria slides it to the next tab (no slide under reduced motion). */\nconst SLIDE = \"transition-[translate,width,height] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none\";\nconst FILL = \"absolute inset-0 -z-10 rounded-ds-control-medium bg-ds-background-neutral\";\nconst FRAME = \"absolute inset-0 -z-10 rounded-ds-control-medium inset-ring-1 inset-ring-ds-border-bold\";\n\n/** The selected mark, which React Aria slides to the next tab: a line, a fill or a frame (never colour alone). */\nconst TAB_INDICATOR: Record<TabsVariant, Record<TabsOrientation, string>> = {\n underline: {\n horizontal: `absolute inset-x-0 -bottom-px h-0.5 rounded-t-ds-small bg-ds-border-selected ${SLIDE}`,\n vertical: `absolute inset-y-0 -end-px w-0.5 rounded-s-ds-small bg-ds-border-selected ${SLIDE}`,\n },\n pills: { horizontal: `${FILL} ${SLIDE}`, vertical: `${FILL} ${SLIDE}` },\n outline: { horizontal: `${FRAME} ${SLIDE}`, vertical: `${FRAME} ${SLIDE}` },\n};\n\n/** The row (or column) of tabs per variant: a rule along it for `underline`, nothing for the boxed ones. */\nconst TAB_LIST: Record<TabsVariant, Record<TabsOrientation, string>> = {\n underline: {\n horizontal: \"flex gap-ds-300 overflow-x-auto border-b border-ds-border\",\n vertical: \"flex w-48 shrink-0 flex-col gap-ds-050 border-e border-ds-border pe-ds-200\",\n },\n pills: { horizontal: \"flex gap-ds-050 overflow-x-auto\", vertical: \"flex w-48 shrink-0 flex-col gap-ds-050\" },\n outline: { horizontal: \"flex gap-ds-050 overflow-x-auto\", vertical: \"flex w-48 shrink-0 flex-col gap-ds-050\" },\n};\n\n/** Tab height and type per size; the boxed variants (pills, outline) add inline padding. */\nconst TAB_SIZE: Record<ComponentSize, string> = { small: \"h-8 text-body-small\", medium: \"h-10\", large: \"h-12 text-body-large\" };\nconst TAB_BOXED: Record<ComponentSize, string> = { small: \"px-ds-100\", medium: \"px-ds-150\", large: \"px-ds-200\" };\n\ntype TabsOrientation = \"horizontal\" | \"vertical\";\n\n/** What a TabList and its Tabs draw, from Tabs, so composed tabs look the same as `items`. */\nconst TabsLook = React.createContext<{ variant: TabsVariant; orientation: TabsOrientation; size: ComponentSize }>({\n variant: \"underline\",\n orientation: \"horizontal\",\n size: \"medium\",\n});\n\nconst TAB =\n \"relative isolate inline-flex h-10 shrink-0 cursor-default items-center gap-ds-075 rounded-ds-small text-body font-[500] whitespace-nowrap text-ds-text-subtle outline-hidden \" +\n \"transition-colors duration-(--ds-duration-fast) motion-reduce:transition-none \" +\n \"data-[hovered]:text-ds-text data-[selected]:text-ds-text \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused data-[disabled]:text-ds-text-disabled\";\n\n/**\n * The row of tabs. On a narrow screen it scrolls sideways and keeps the selected tab in view, by scrolling\n * the row alone, never the page (scrollIntoView would scroll every ancestor, the window included).\n */\nexport function TabList({ children, \"aria-label\": label, \"aria-labelledby\": labelledBy }: TabListProps) {\n const list = React.useRef<HTMLDivElement>(null);\n const selected = React.useContext(TabListStateContext)?.selectedKey;\n const look = React.useContext(TabsLook);\n React.useEffect(() => {\n const row = list.current;\n const tab = row?.querySelector<HTMLElement>(\"[data-selected]\");\n if (!row || !tab) return;\n // Rect deltas work the same in RTL.\n const outer = row.getBoundingClientRect();\n const inner = tab.getBoundingClientRect();\n if (inner.left < outer.left) row.scrollLeft -= outer.left - inner.left;\n else if (inner.right > outer.right) row.scrollLeft += inner.right - outer.right;\n }, [selected]);\n return (\n <AriaTabList\n ref={list}\n aria-label={label}\n aria-labelledby={labelledBy}\n data-slot=\"tabs-list\"\n className={cn(TAB_LIST[look.variant][look.orientation], \"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden\")}\n >\n {children}\n </AriaTabList>\n );\n}\n\n/** One tab: its label, an optional count, and the sliding underline when selected. */\nexport function Tab({ id, children, count, isDisabled }: TabProps) {\n const look = React.useContext(TabsLook);\n const boxed = look.variant !== \"underline\" && cn(\"rounded-ds-control-medium\", TAB_BOXED[look.size]);\n return (\n <AriaTab\n id={id}\n isDisabled={isDisabled}\n data-slot=\"tab\"\n className={cn(TAB, TAB_SIZE[look.size], boxed, look.orientation === \"vertical\" && \"w-full justify-start\")}\n >\n <SelectionIndicator data-slot=\"tab-indicator\" className={TAB_INDICATOR[look.variant][look.orientation]} />\n {children}\n {count !== undefined && count > 0 && (\n <span data-slot=\"tab-count\" className=\"flex\">\n <Badge variant=\"count\" value={count} />\n </span>\n )}\n </AriaTab>\n );\n}\n\n/** A tab's view. It stays mounted while hidden, so its state (a scroll position, a half-filled filter) survives switching. */\nexport function TabPanel({ id, children }: TabPanelProps) {\n return (\n <AriaTabPanel\n id={id}\n shouldForceMount\n data-slot=\"tab-panel\"\n className=\"outline-hidden data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused data-[inert]:hidden [&[inert]]:hidden\"\n >\n {children}\n </AriaTabPanel>\n );\n}\n\n/**\n * Switches between views of the same object without leaving the page. Arrow keys (mirrored in RTL),\n * Home and End move between tabs; the selected tab holds focus. Give `items`, or compose `TabList`,\n * `Tab` and `TabPanel` as children; both render the same parts.\n */\nfunction TabsBody({\n items, children, selectedKey, defaultSelectedKey, onSelectionChange, \"aria-label\": label, variant = \"underline\", orientation = \"horizontal\", size: ownSize,\n}: TabsProps) {\n const defaults = useComponentDefaults();\n const size = ownSize ?? defaults.size ?? \"medium\";\n const look = React.useMemo(() => ({ variant, orientation, size }), [variant, orientation, size]);\n return (\n <TabsLook.Provider value={look}>\n <AriaTabs\n selectedKey={selectedKey}\n defaultSelectedKey={defaultSelectedKey}\n onSelectionChange={onSelectionChange}\n orientation={orientation}\n data-slot=\"tabs\"\n data-variant={variant}\n className={orientation === \"vertical\" ? \"flex gap-ds-400\" : \"flex flex-col gap-ds-200\"}\n >\n {items ? (\n <>\n <TabList aria-label={label}>\n {items.map((item) => (\n <Tab key={item.id} id={item.id} count={item.count} isDisabled={item.isDisabled}>\n {item.label}\n </Tab>\n ))}\n </TabList>\n {items.map((item) => (\n <TabPanel key={item.id} id={item.id}>\n {item.panel}\n </TabPanel>\n ))}\n </>\n ) : (\n children\n )}\n </AriaTabs>\n </TabsLook.Provider>\n );\n}\n\nexport type SegmentedControlItem = { id: Key; label: string };\n\nexport type SegmentedControlProps = {\n /** Names the group for assistive tech (\"Period\"); it is not shown. */\n label: string;\n /** Two to five short options (\"Day\", \"Week\", \"Month\"). */\n items: readonly SegmentedControlItem[];\n value?: Key;\n defaultValue?: Key;\n onChange?: (value: Key) => void;\n isDisabled?: boolean;\n};\n\n/**\n * The selected segment's lifted surface (surface and shadow, not only colour); it slides to the next segment. Segments\n * sit in the 2px-padded track, so their corner is the track's minus that padding: concentric at every radius.\n */\nconst SEGMENT_INDICATOR =\n \"absolute inset-0 -z-10 rounded-[max(0px,calc(var(--ds-radius-control-medium,var(--ds-radius-medium))-2px))] bg-ds-background-segment-selected shadow-ds-raised \" +\n \"transition-[translate,width] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none\";\n\nconst SEGMENT =\n \"inline-flex h-7 cursor-default items-center rounded-[max(0px,calc(var(--ds-radius-control-medium,var(--ds-radius-medium))-2px))] px-ds-150 text-body font-[500] whitespace-nowrap text-ds-text-subtle outline-hidden \" +\n \"transition-[background-color,color,box-shadow] duration-(--ds-duration-fast) motion-reduce:transition-none \" +\n \"data-[hovered]:text-ds-text \" +\n \"relative isolate data-[selected]:text-ds-text \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused data-[disabled]:text-ds-text-disabled\";\n\n/**\n * Tabs' compact sibling for switching a filter or a scale (day · week · month), not for views. One\n * option is always chosen; arrow keys move between them.\n */\nexport function SegmentedControl({ label, items, value, defaultValue, onChange, isDisabled }: SegmentedControlProps) {\n const [own, setOwn] = React.useState<Key | undefined>(defaultValue ?? items[0]?.id);\n const current = value ?? own;\n return (\n <AriaToggleButtonGroup\n aria-label={label}\n selectionMode=\"single\"\n disallowEmptySelection\n selectedKeys={current === undefined ? [] : [current]}\n onSelectionChange={(keys) => {\n const next = [...keys][0];\n if (next === undefined) return;\n if (value === undefined) setOwn(next);\n onChange?.(next);\n }}\n isDisabled={isDisabled}\n data-slot=\"segmented-control\"\n className={cn(\"inline-flex w-fit max-w-full self-start gap-0.5 overflow-x-auto rounded-ds-control-medium bg-ds-background-neutral p-0.5\", \"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden\")}\n >\n {items.map((item) => (\n <AriaToggleButton key={item.id} id={item.id} data-slot=\"segment\" className={SEGMENT}>\n <SelectionIndicator data-slot=\"segment-indicator\" className={SEGMENT_INDICATOR} />\n {item.label}\n </AriaToggleButton>\n ))}\n </AriaToggleButtonGroup>\n );\n}\n\n/** Tabs with its own `motion` (auto, reduce or none); see TabsBody for the component itself. */\nexport function Tabs({ motion, ...props }: TabsProps & WithMotion) {\n return (\n <MotionScope motion={motion}>\n <TabsBody {...(props as TabsProps)} />\n </MotionScope>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/navigation/tabs.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,GAAG,IAAI,OAAO,EACd,OAAO,IAAI,WAAW,EACtB,mBAAmB,EACnB,QAAQ,IAAI,YAAY,EACxB,IAAI,IAAI,QAAQ,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IAAI,CAAC,CAAC;YACtC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC,EACD,UAAU,EAAE,UAAU,eACZ,mBAAmB,EAC7B,SAAS,EAAE,EAAE,CAAC,0HAA0H,EAAE,sDAAsD,CAAC,YAEhM,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,MAAC,gBAAgB,IAAe,EAAE,EAAE,IAAI,CAAC,EAAE,eAAY,SAAS,EAAC,SAAS,EAAE,OAAO,aACjF,KAAC,kBAAkB,iBAAW,mBAAmB,EAAC,SAAS,EAAE,iBAAiB,GAAI,EACjF,IAAI,CAAC,KAAK,KAFU,IAAI,CAAC,EAAE,CAGX,CACpB,CAAC,GACoB,CACzB,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAA0B;IAC/D,OAAO,CACL,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,YACzB,KAAC,QAAQ,OAAM,KAAmB,GAAI,GAC1B,CACf,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n SelectionIndicator,\n Tab as AriaTab,\n TabList as AriaTabList,\n TabListStateContext,\n TabPanel as AriaTabPanel,\n Tabs as AriaTabs,\n ToggleButton as AriaToggleButton,\n ToggleButtonGroup as AriaToggleButtonGroup,\n type Key,\n} from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { MotionScope, useComponentDefaults, type ComponentSize, type WithMotion } from \"../defaults\";\nimport { Badge } from \"../display/badge\";\n\nexport type TabItem = {\n id: Key;\n /** A noun, one or two words (\"Orders\"). */\n label: string;\n /** A count after the label (a Badge), e.g. open damage records. */\n count?: number;\n isDisabled?: boolean;\n panel: React.ReactNode;\n};\n\nexport type TabsProps = {\n /**\n * Two to six tabs as data. Leave it out and compose `TabList`, `Tab` and `TabPanel` as children instead,\n * for a tab with an icon, a panel built elsewhere, or tabs rendered from your own components.\n */\n items?: readonly TabItem[];\n /** With no `items`: a `TabList` of `Tab`s followed by one `TabPanel` per tab, matched by `id`. */\n children?: React.ReactNode;\n selectedKey?: Key;\n defaultSelectedKey?: Key;\n onSelectionChange?: (key: Key) => void;\n /** Names the tab list when no heading above it does (with `items`; on `TabList` otherwise). */\n \"aria-label\"?: string;\n /** `underline` (default): a line under the selected tab; `pills`: a filled tab; `outline`: a framed tab. */\n variant?: TabsVariant;\n /** `horizontal` (default), or `vertical`: the tabs in a column beside the panels (settings pages). */\n orientation?: \"horizontal\" | \"vertical\";\n /** `small`, `medium` (default) or `large`; the provider default otherwise. */\n size?: ComponentSize;\n};\n\nexport type TabsVariant = \"underline\" | \"pills\" | \"outline\";\n\nexport type TabListProps = {\n /** `Tab` elements. */\n children: React.ReactNode;\n /** Names the tab list when no heading above it does. */\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n};\n\nexport type TabProps = {\n /** Matches the `TabPanel` with the same `id`. */\n id: Key;\n /** The label: a noun, one or two words, optionally with an Icon before it. */\n children: React.ReactNode;\n /** A count after the label (a Badge); hidden at 0. */\n count?: number;\n isDisabled?: boolean;\n};\n\nexport type TabPanelProps = {\n /** Matches the `Tab` with the same `id`. */\n id: Key;\n children: React.ReactNode;\n};\n\n/** The selected tab's 2px underline (never colour alone); React Aria slides it to the next tab (no slide under reduced motion). */\nconst SLIDE = \"transition-[translate,width,height] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none\";\nconst FILL = \"absolute inset-0 -z-10 rounded-ds-control-medium bg-ds-background-neutral\";\nconst FRAME = \"absolute inset-0 -z-10 rounded-ds-control-medium inset-ring-1 inset-ring-ds-border-bold\";\n\n/** The selected mark, which React Aria slides to the next tab: a line, a fill or a frame (never colour alone). */\nconst TAB_INDICATOR: Record<TabsVariant, Record<TabsOrientation, string>> = {\n underline: {\n horizontal: `absolute inset-x-0 -bottom-px h-0.5 rounded-t-ds-small bg-ds-border-selected ${SLIDE}`,\n vertical: `absolute inset-y-0 -end-px w-0.5 rounded-s-ds-small bg-ds-border-selected ${SLIDE}`,\n },\n pills: { horizontal: `${FILL} ${SLIDE}`, vertical: `${FILL} ${SLIDE}` },\n outline: { horizontal: `${FRAME} ${SLIDE}`, vertical: `${FRAME} ${SLIDE}` },\n};\n\n/** The row (or column) of tabs per variant: a rule along it for `underline`, nothing for the boxed ones. */\nconst TAB_LIST: Record<TabsVariant, Record<TabsOrientation, string>> = {\n underline: {\n horizontal: \"flex gap-ds-300 overflow-x-auto border-b border-ds-border\",\n vertical: \"flex w-48 shrink-0 flex-col gap-ds-050 border-e border-ds-border pe-ds-200\",\n },\n pills: { horizontal: \"flex gap-ds-050 overflow-x-auto\", vertical: \"flex w-48 shrink-0 flex-col gap-ds-050\" },\n outline: { horizontal: \"flex gap-ds-050 overflow-x-auto\", vertical: \"flex w-48 shrink-0 flex-col gap-ds-050\" },\n};\n\n/** Tab height and type per size; the boxed variants (pills, outline) add inline padding. */\nconst TAB_SIZE: Record<ComponentSize, string> = { small: \"h-8 text-body-small\", medium: \"h-10\", large: \"h-12 text-body-large\" };\nconst TAB_BOXED: Record<ComponentSize, string> = { small: \"px-ds-100\", medium: \"px-ds-150\", large: \"px-ds-200\" };\n\ntype TabsOrientation = \"horizontal\" | \"vertical\";\n\n/** What a TabList and its Tabs draw, from Tabs, so composed tabs look the same as `items`. */\nconst TabsLook = React.createContext<{ variant: TabsVariant; orientation: TabsOrientation; size: ComponentSize }>({\n variant: \"underline\",\n orientation: \"horizontal\",\n size: \"medium\",\n});\n\nconst TAB =\n \"relative isolate inline-flex h-10 shrink-0 cursor-pointer data-[disabled]:cursor-not-allowed items-center gap-ds-075 rounded-ds-small text-body font-[500] whitespace-nowrap text-ds-text-subtle outline-hidden \" +\n \"transition-colors duration-(--ds-duration-fast) motion-reduce:transition-none \" +\n \"data-[hovered]:text-ds-text data-[selected]:text-ds-text \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused data-[disabled]:text-ds-text-disabled\";\n\n/**\n * The row of tabs. On a narrow screen it scrolls sideways and keeps the selected tab in view, by scrolling\n * the row alone, never the page (scrollIntoView would scroll every ancestor, the window included).\n */\nexport function TabList({ children, \"aria-label\": label, \"aria-labelledby\": labelledBy }: TabListProps) {\n const list = React.useRef<HTMLDivElement>(null);\n const selected = React.useContext(TabListStateContext)?.selectedKey;\n const look = React.useContext(TabsLook);\n React.useEffect(() => {\n const row = list.current;\n const tab = row?.querySelector<HTMLElement>(\"[data-selected]\");\n if (!row || !tab) return;\n // Rect deltas work the same in RTL.\n const outer = row.getBoundingClientRect();\n const inner = tab.getBoundingClientRect();\n if (inner.left < outer.left) row.scrollLeft -= outer.left - inner.left;\n else if (inner.right > outer.right) row.scrollLeft += inner.right - outer.right;\n }, [selected]);\n return (\n <AriaTabList\n ref={list}\n aria-label={label}\n aria-labelledby={labelledBy}\n data-slot=\"tabs-list\"\n className={cn(TAB_LIST[look.variant][look.orientation], \"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden\")}\n >\n {children}\n </AriaTabList>\n );\n}\n\n/** One tab: its label, an optional count, and the sliding underline when selected. */\nexport function Tab({ id, children, count, isDisabled }: TabProps) {\n const look = React.useContext(TabsLook);\n const boxed = look.variant !== \"underline\" && cn(\"rounded-ds-control-medium\", TAB_BOXED[look.size]);\n return (\n <AriaTab\n id={id}\n isDisabled={isDisabled}\n data-slot=\"tab\"\n className={cn(TAB, TAB_SIZE[look.size], boxed, look.orientation === \"vertical\" && \"w-full justify-start\")}\n >\n <SelectionIndicator data-slot=\"tab-indicator\" className={TAB_INDICATOR[look.variant][look.orientation]} />\n {children}\n {count !== undefined && count > 0 && (\n <span data-slot=\"tab-count\" className=\"flex\">\n <Badge variant=\"count\" value={count} />\n </span>\n )}\n </AriaTab>\n );\n}\n\n/** A tab's view. It stays mounted while hidden, so its state (a scroll position, a half-filled filter) survives switching. */\nexport function TabPanel({ id, children }: TabPanelProps) {\n return (\n <AriaTabPanel\n id={id}\n shouldForceMount\n data-slot=\"tab-panel\"\n className=\"outline-hidden data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused data-[inert]:hidden [&[inert]]:hidden\"\n >\n {children}\n </AriaTabPanel>\n );\n}\n\n/**\n * Switches between views of the same object without leaving the page. Arrow keys (mirrored in RTL),\n * Home and End move between tabs; the selected tab holds focus. Give `items`, or compose `TabList`,\n * `Tab` and `TabPanel` as children; both render the same parts.\n */\nfunction TabsBody({\n items, children, selectedKey, defaultSelectedKey, onSelectionChange, \"aria-label\": label, variant = \"underline\", orientation = \"horizontal\", size: ownSize,\n}: TabsProps) {\n const defaults = useComponentDefaults();\n const size = ownSize ?? defaults.size ?? \"medium\";\n const look = React.useMemo(() => ({ variant, orientation, size }), [variant, orientation, size]);\n return (\n <TabsLook.Provider value={look}>\n <AriaTabs\n selectedKey={selectedKey}\n defaultSelectedKey={defaultSelectedKey}\n onSelectionChange={onSelectionChange}\n orientation={orientation}\n data-slot=\"tabs\"\n data-variant={variant}\n className={orientation === \"vertical\" ? \"flex gap-ds-400\" : \"flex flex-col gap-ds-200\"}\n >\n {items ? (\n <>\n <TabList aria-label={label}>\n {items.map((item) => (\n <Tab key={item.id} id={item.id} count={item.count} isDisabled={item.isDisabled}>\n {item.label}\n </Tab>\n ))}\n </TabList>\n {items.map((item) => (\n <TabPanel key={item.id} id={item.id}>\n {item.panel}\n </TabPanel>\n ))}\n </>\n ) : (\n children\n )}\n </AriaTabs>\n </TabsLook.Provider>\n );\n}\n\nexport type SegmentedControlItem = { id: Key; label: string };\n\nexport type SegmentedControlProps = {\n /** Names the group for assistive tech (\"Period\"); it is not shown. */\n label: string;\n /** Two to five short options (\"Day\", \"Week\", \"Month\"). */\n items: readonly SegmentedControlItem[];\n value?: Key;\n defaultValue?: Key;\n onChange?: (value: Key) => void;\n isDisabled?: boolean;\n};\n\n/**\n * The selected segment's lifted surface (surface and shadow, not only colour); it slides to the next segment. Segments\n * sit in the 2px-padded track, so their corner is the track's minus that padding: concentric at every radius.\n */\nconst SEGMENT_INDICATOR =\n \"absolute inset-0 -z-10 rounded-[max(0px,calc(var(--ds-radius-control-medium,var(--ds-radius-medium))-2px))] bg-ds-background-segment-selected shadow-ds-raised \" +\n \"transition-[translate,width] duration-(--ds-duration-medium) ease-ds-standard motion-reduce:transition-none\";\n\nconst SEGMENT =\n \"inline-flex h-7 cursor-pointer data-[disabled]:cursor-not-allowed items-center rounded-[max(0px,calc(var(--ds-radius-control-medium,var(--ds-radius-medium))-2px))] px-ds-150 text-body font-[500] whitespace-nowrap text-ds-text-subtle outline-hidden \" +\n \"transition-[background-color,color,box-shadow] duration-(--ds-duration-fast) motion-reduce:transition-none \" +\n \"data-[hovered]:text-ds-text \" +\n \"relative isolate data-[selected]:text-ds-text \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused data-[disabled]:text-ds-text-disabled\";\n\n/**\n * Tabs' compact sibling for switching a filter or a scale (day · week · month), not for views. One\n * option is always chosen; arrow keys move between them.\n */\nexport function SegmentedControl({ label, items, value, defaultValue, onChange, isDisabled }: SegmentedControlProps) {\n const [own, setOwn] = React.useState<Key | undefined>(defaultValue ?? items[0]?.id);\n const current = value ?? own;\n return (\n <AriaToggleButtonGroup\n aria-label={label}\n selectionMode=\"single\"\n disallowEmptySelection\n selectedKeys={current === undefined ? [] : [current]}\n onSelectionChange={(keys) => {\n const next = [...keys][0];\n if (next === undefined) return;\n if (value === undefined) setOwn(next);\n onChange?.(next);\n }}\n isDisabled={isDisabled}\n data-slot=\"segmented-control\"\n className={cn(\"inline-flex w-fit max-w-full self-start gap-0.5 overflow-x-auto rounded-ds-control-medium bg-ds-background-neutral p-0.5\", \"[scrollbar-width:none] [&::-webkit-scrollbar]:hidden\")}\n >\n {items.map((item) => (\n <AriaToggleButton key={item.id} id={item.id} data-slot=\"segment\" className={SEGMENT}>\n <SelectionIndicator data-slot=\"segment-indicator\" className={SEGMENT_INDICATOR} />\n {item.label}\n </AriaToggleButton>\n ))}\n </AriaToggleButtonGroup>\n );\n}\n\n/** Tabs with its own `motion` (auto, reduce or none); see TabsBody for the component itself. */\nexport function Tabs({ motion, ...props }: TabsProps & WithMotion) {\n return (\n <MotionScope motion={motion}>\n <TabsBody {...(props as TabsProps)} />\n </MotionScope>\n );\n}\n"]}
|
|
@@ -111,6 +111,46 @@
|
|
|
111
111
|
],
|
|
112
112
|
"props": {
|
|
113
113
|
"AreaChart": [
|
|
114
|
+
{
|
|
115
|
+
"name": "tableView",
|
|
116
|
+
"type": "ChartTableView",
|
|
117
|
+
"required": false,
|
|
118
|
+
"origin": "own",
|
|
119
|
+
"description": "How the data is offered as a table. `swap` (default): a toggle at the end of the chart's top row turns the plot\ninto the table at the same height, scrolling inside, so the card never grows. `hidden`: no toggle; the table is\nthere for screen readers only. `none`: no table at all, for a chart that is already text (BarList).",
|
|
120
|
+
"schema": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"enum": [
|
|
123
|
+
"hidden",
|
|
124
|
+
"none",
|
|
125
|
+
"swap"
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "isTableOpen",
|
|
131
|
+
"type": "boolean",
|
|
132
|
+
"required": false,
|
|
133
|
+
"origin": "own",
|
|
134
|
+
"description": "The table is showing (`swap`), controlled; or `defaultTableOpen` + `onTableOpenChange`.",
|
|
135
|
+
"schema": {
|
|
136
|
+
"type": "boolean"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "defaultTableOpen",
|
|
141
|
+
"type": "boolean",
|
|
142
|
+
"required": false,
|
|
143
|
+
"origin": "own",
|
|
144
|
+
"schema": {
|
|
145
|
+
"type": "boolean"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "onTableOpenChange",
|
|
150
|
+
"type": "(isOpen: boolean) => void",
|
|
151
|
+
"required": false,
|
|
152
|
+
"origin": "own"
|
|
153
|
+
},
|
|
114
154
|
{
|
|
115
155
|
"name": "title",
|
|
116
156
|
"type": "string",
|
|
@@ -289,6 +329,8 @@
|
|
|
289
329
|
},
|
|
290
330
|
"tokens": [
|
|
291
331
|
"ds-background-neutral",
|
|
332
|
+
"ds-background-neutral-subtle-hovered",
|
|
333
|
+
"ds-background-selected",
|
|
292
334
|
"ds-border",
|
|
293
335
|
"ds-border-bold",
|
|
294
336
|
"ds-border-focused",
|
|
@@ -298,7 +340,10 @@
|
|
|
298
340
|
"ds-chart-4",
|
|
299
341
|
"ds-chart-5",
|
|
300
342
|
"ds-chart-neutral",
|
|
301
|
-
"ds-
|
|
343
|
+
"ds-icon",
|
|
344
|
+
"ds-icon-brand",
|
|
345
|
+
"ds-icon-subtle",
|
|
346
|
+
"ds-radius-control-small",
|
|
302
347
|
"ds-radius-medium",
|
|
303
348
|
"ds-radius-small",
|
|
304
349
|
"ds-radius-xsmall",
|
package/manifests/bar-chart.json
CHANGED
|
@@ -227,6 +227,46 @@
|
|
|
227
227
|
]
|
|
228
228
|
}
|
|
229
229
|
},
|
|
230
|
+
{
|
|
231
|
+
"name": "tableView",
|
|
232
|
+
"type": "ChartTableView",
|
|
233
|
+
"required": false,
|
|
234
|
+
"origin": "own",
|
|
235
|
+
"description": "How the data is offered as a table. `swap` (default): a toggle at the end of the chart's top row turns the plot\ninto the table at the same height, scrolling inside, so the card never grows. `hidden`: no toggle; the table is\nthere for screen readers only. `none`: no table at all, for a chart that is already text (BarList).",
|
|
236
|
+
"schema": {
|
|
237
|
+
"type": "string",
|
|
238
|
+
"enum": [
|
|
239
|
+
"hidden",
|
|
240
|
+
"none",
|
|
241
|
+
"swap"
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"name": "isTableOpen",
|
|
247
|
+
"type": "boolean",
|
|
248
|
+
"required": false,
|
|
249
|
+
"origin": "own",
|
|
250
|
+
"description": "The table is showing (`swap`), controlled; or `defaultTableOpen` + `onTableOpenChange`.",
|
|
251
|
+
"schema": {
|
|
252
|
+
"type": "boolean"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"name": "defaultTableOpen",
|
|
257
|
+
"type": "boolean",
|
|
258
|
+
"required": false,
|
|
259
|
+
"origin": "own",
|
|
260
|
+
"schema": {
|
|
261
|
+
"type": "boolean"
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "onTableOpenChange",
|
|
266
|
+
"type": "(isOpen: boolean) => void",
|
|
267
|
+
"required": false,
|
|
268
|
+
"origin": "own"
|
|
269
|
+
},
|
|
230
270
|
{
|
|
231
271
|
"name": "total",
|
|
232
272
|
"type": "React.ReactNode",
|
|
@@ -381,6 +421,8 @@
|
|
|
381
421
|
"ds-background-brand-subtle",
|
|
382
422
|
"ds-background-neutral",
|
|
383
423
|
"ds-background-neutral-pressed",
|
|
424
|
+
"ds-background-neutral-subtle-hovered",
|
|
425
|
+
"ds-background-selected",
|
|
384
426
|
"ds-background-selected-hovered",
|
|
385
427
|
"ds-background-selected-pressed",
|
|
386
428
|
"ds-border",
|
|
@@ -392,10 +434,14 @@
|
|
|
392
434
|
"ds-chart-4",
|
|
393
435
|
"ds-chart-5",
|
|
394
436
|
"ds-chart-neutral",
|
|
437
|
+
"ds-icon",
|
|
438
|
+
"ds-icon-brand",
|
|
395
439
|
"ds-icon-danger",
|
|
440
|
+
"ds-icon-subtle",
|
|
396
441
|
"ds-icon-success",
|
|
397
442
|
"ds-icon-warning",
|
|
398
443
|
"ds-link",
|
|
444
|
+
"ds-radius-control-small",
|
|
399
445
|
"ds-radius-medium",
|
|
400
446
|
"ds-radius-small",
|
|
401
447
|
"ds-radius-xsmall",
|
package/manifests/bar-list.json
CHANGED
|
@@ -194,6 +194,8 @@
|
|
|
194
194
|
"ds-background-brand-subtle",
|
|
195
195
|
"ds-background-neutral",
|
|
196
196
|
"ds-background-neutral-pressed",
|
|
197
|
+
"ds-background-neutral-subtle-hovered",
|
|
198
|
+
"ds-background-selected",
|
|
197
199
|
"ds-background-selected-hovered",
|
|
198
200
|
"ds-background-selected-pressed",
|
|
199
201
|
"ds-border",
|
|
@@ -205,10 +207,14 @@
|
|
|
205
207
|
"ds-chart-4",
|
|
206
208
|
"ds-chart-5",
|
|
207
209
|
"ds-chart-neutral",
|
|
210
|
+
"ds-icon",
|
|
211
|
+
"ds-icon-brand",
|
|
208
212
|
"ds-icon-danger",
|
|
213
|
+
"ds-icon-subtle",
|
|
209
214
|
"ds-icon-success",
|
|
210
215
|
"ds-icon-warning",
|
|
211
216
|
"ds-link",
|
|
217
|
+
"ds-radius-control-small",
|
|
212
218
|
"ds-radius-medium",
|
|
213
219
|
"ds-radius-small",
|
|
214
220
|
"ds-radius-xsmall",
|
|
@@ -150,6 +150,8 @@
|
|
|
150
150
|
"ds-background-brand-subtle",
|
|
151
151
|
"ds-background-neutral",
|
|
152
152
|
"ds-background-neutral-pressed",
|
|
153
|
+
"ds-background-neutral-subtle-hovered",
|
|
154
|
+
"ds-background-selected",
|
|
153
155
|
"ds-background-selected-hovered",
|
|
154
156
|
"ds-background-selected-pressed",
|
|
155
157
|
"ds-border",
|
|
@@ -161,10 +163,14 @@
|
|
|
161
163
|
"ds-chart-4",
|
|
162
164
|
"ds-chart-5",
|
|
163
165
|
"ds-chart-neutral",
|
|
166
|
+
"ds-icon",
|
|
167
|
+
"ds-icon-brand",
|
|
164
168
|
"ds-icon-danger",
|
|
169
|
+
"ds-icon-subtle",
|
|
165
170
|
"ds-icon-success",
|
|
166
171
|
"ds-icon-warning",
|
|
167
172
|
"ds-link",
|
|
173
|
+
"ds-radius-control-small",
|
|
168
174
|
"ds-radius-medium",
|
|
169
175
|
"ds-radius-small",
|
|
170
176
|
"ds-radius-xsmall",
|
|
@@ -55,6 +55,48 @@
|
|
|
55
55
|
],
|
|
56
56
|
"props": {
|
|
57
57
|
"ChartFrame": [
|
|
58
|
+
{
|
|
59
|
+
"name": "tableView",
|
|
60
|
+
"type": "ChartTableView",
|
|
61
|
+
"required": false,
|
|
62
|
+
"origin": "own",
|
|
63
|
+
"default": "\"swap\"",
|
|
64
|
+
"description": "How the data is offered as a table. `swap` (default): a toggle at the end of the chart's top row turns the plot\ninto the table at the same height, scrolling inside, so the card never grows. `hidden`: no toggle; the table is\nthere for screen readers only. `none`: no table at all, for a chart that is already text (BarList).",
|
|
65
|
+
"schema": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"enum": [
|
|
68
|
+
"hidden",
|
|
69
|
+
"none",
|
|
70
|
+
"swap"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "isTableOpen",
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"required": false,
|
|
78
|
+
"origin": "own",
|
|
79
|
+
"description": "The table is showing (`swap`), controlled; or `defaultTableOpen` + `onTableOpenChange`.",
|
|
80
|
+
"schema": {
|
|
81
|
+
"type": "boolean"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "defaultTableOpen",
|
|
86
|
+
"type": "boolean",
|
|
87
|
+
"required": false,
|
|
88
|
+
"origin": "own",
|
|
89
|
+
"default": "false",
|
|
90
|
+
"schema": {
|
|
91
|
+
"type": "boolean"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "onTableOpenChange",
|
|
96
|
+
"type": "(isOpen: boolean) => void",
|
|
97
|
+
"required": false,
|
|
98
|
+
"origin": "own"
|
|
99
|
+
},
|
|
58
100
|
{
|
|
59
101
|
"name": "height",
|
|
60
102
|
"type": "number",
|
|
@@ -268,6 +310,8 @@
|
|
|
268
310
|
]
|
|
269
311
|
},
|
|
270
312
|
"tokens": [
|
|
313
|
+
"ds-background-neutral-subtle-hovered",
|
|
314
|
+
"ds-background-selected",
|
|
271
315
|
"ds-border-focused",
|
|
272
316
|
"ds-chart-1",
|
|
273
317
|
"ds-chart-2",
|
|
@@ -275,7 +319,10 @@
|
|
|
275
319
|
"ds-chart-4",
|
|
276
320
|
"ds-chart-5",
|
|
277
321
|
"ds-chart-neutral",
|
|
278
|
-
"ds-
|
|
322
|
+
"ds-icon",
|
|
323
|
+
"ds-icon-brand",
|
|
324
|
+
"ds-icon-subtle",
|
|
325
|
+
"ds-radius-control-small",
|
|
279
326
|
"ds-radius-medium",
|
|
280
327
|
"ds-radius-small",
|
|
281
328
|
"ds-radius-xsmall",
|
|
@@ -70,6 +70,46 @@
|
|
|
70
70
|
"type": "string"
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
+
{
|
|
74
|
+
"name": "tableView",
|
|
75
|
+
"type": "ChartTableView",
|
|
76
|
+
"required": false,
|
|
77
|
+
"origin": "own",
|
|
78
|
+
"description": "How the data is offered as a table. `swap` (default): a toggle at the end of the chart's top row turns the plot\ninto the table at the same height, scrolling inside, so the card never grows. `hidden`: no toggle; the table is\nthere for screen readers only. `none`: no table at all, for a chart that is already text (BarList).",
|
|
79
|
+
"schema": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"enum": [
|
|
82
|
+
"hidden",
|
|
83
|
+
"none",
|
|
84
|
+
"swap"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "isTableOpen",
|
|
90
|
+
"type": "boolean",
|
|
91
|
+
"required": false,
|
|
92
|
+
"origin": "own",
|
|
93
|
+
"description": "The table is showing (`swap`), controlled; or `defaultTableOpen` + `onTableOpenChange`.",
|
|
94
|
+
"schema": {
|
|
95
|
+
"type": "boolean"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "defaultTableOpen",
|
|
100
|
+
"type": "boolean",
|
|
101
|
+
"required": false,
|
|
102
|
+
"origin": "own",
|
|
103
|
+
"schema": {
|
|
104
|
+
"type": "boolean"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "onTableOpenChange",
|
|
109
|
+
"type": "(isOpen: boolean) => void",
|
|
110
|
+
"required": false,
|
|
111
|
+
"origin": "own"
|
|
112
|
+
},
|
|
73
113
|
{
|
|
74
114
|
"name": "period",
|
|
75
115
|
"type": "string",
|
|
@@ -238,6 +278,8 @@
|
|
|
238
278
|
},
|
|
239
279
|
"tokens": [
|
|
240
280
|
"ds-background-neutral",
|
|
281
|
+
"ds-background-neutral-subtle-hovered",
|
|
282
|
+
"ds-background-selected",
|
|
241
283
|
"ds-border",
|
|
242
284
|
"ds-border-bold",
|
|
243
285
|
"ds-border-focused",
|
|
@@ -247,7 +289,10 @@
|
|
|
247
289
|
"ds-chart-4",
|
|
248
290
|
"ds-chart-5",
|
|
249
291
|
"ds-chart-neutral",
|
|
250
|
-
"ds-
|
|
292
|
+
"ds-icon",
|
|
293
|
+
"ds-icon-brand",
|
|
294
|
+
"ds-icon-subtle",
|
|
295
|
+
"ds-radius-control-small",
|
|
251
296
|
"ds-radius-medium",
|
|
252
297
|
"ds-radius-small",
|
|
253
298
|
"ds-radius-xsmall",
|