@senvenli/react 0.3.3 → 0.3.4
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/action/fab.d.ts +7 -0
- package/dist/action/fab.js +22 -3
- package/dist/action/fab.js.map +1 -1
- package/dist/collection/data-table.d.ts +1 -1
- package/dist/collection/data-table.js +2 -2
- package/dist/collection/data-table.js.map +1 -1
- package/dist/collection/table.d.ts +7 -2
- package/dist/collection/table.js +17 -7
- package/dist/collection/table.js.map +1 -1
- package/dist/i18n.d.ts +8 -0
- package/dist/i18n.js +18 -1
- package/dist/i18n.js.map +1 -1
- package/dist/navigation/index.d.ts +2 -2
- package/dist/navigation/index.js +1 -1
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/sidebar.d.ts +18 -0
- package/dist/navigation/sidebar.js +26 -2
- package/dist/navigation/sidebar.js.map +1 -1
- package/dist/overlay/floating.js +4 -1
- package/dist/overlay/floating.js.map +1 -1
- package/dist/overlay/index.d.ts +2 -0
- package/dist/overlay/index.js +2 -1
- package/dist/overlay/index.js.map +1 -1
- package/dist/overlay/tour.d.ts +88 -0
- package/dist/overlay/tour.js +302 -0
- package/dist/overlay/tour.js.map +1 -0
- package/package.json +2 -2
- package/dist/action/files.d.ts +0 -70
- package/dist/action/files.js +0 -156
- package/dist/action/files.js.map +0 -1
- package/dist/action/theme-toggle.d.ts +0 -43
- package/dist/action/theme-toggle.js +0 -259
- package/dist/action/theme-toggle.js.map +0 -1
- package/dist/display/image-crop.d.ts +0 -106
- package/dist/display/image-crop.js +0 -117
- package/dist/display/image-crop.js.map +0 -1
- package/dist/display/image-cropper.d.ts +0 -68
- package/dist/display/image-cropper.js +0 -284
- package/dist/display/image-cropper.js.map +0 -1
- package/dist/display/lozenge.d.ts +0 -30
- package/dist/display/lozenge.js +0 -55
- package/dist/display/lozenge.js.map +0 -1
- package/dist/display/scroll-area.d.ts +0 -29
- package/dist/display/scroll-area.js +0 -95
- package/dist/display/scroll-area.js.map +0 -1
- package/dist/feedback/cooldown.d.ts +0 -17
- package/dist/feedback/cooldown.js +0 -59
- package/dist/feedback/cooldown.js.map +0 -1
- package/dist/feedback/status-dot.d.ts +0 -23
- package/dist/feedback/status-dot.js +0 -37
- package/dist/feedback/status-dot.js.map +0 -1
- package/dist/form/input-otp.d.ts +0 -35
- package/dist/form/input-otp.js +0 -83
- package/dist/form/input-otp.js.map +0 -1
- package/dist/layout/auth-form-layout.d.ts +0 -71
- package/dist/layout/auth-form-layout.js +0 -61
- package/dist/layout/auth-form-layout.js.map +0 -1
- package/dist/layout/auth-layout.d.ts +0 -59
- package/dist/layout/auth-layout.js +0 -26
- package/dist/layout/auth-layout.js.map +0 -1
- package/dist/layout/pressable.d.ts +0 -40
- package/dist/layout/pressable.js +0 -65
- package/dist/layout/pressable.js.map +0 -1
- package/dist/layout/reset-sent-card.d.ts +0 -39
- package/dist/layout/reset-sent-card.js +0 -22
- package/dist/layout/reset-sent-card.js.map +0 -1
- package/dist/navigation/dock.d.ts +0 -27
- package/dist/navigation/dock.js +0 -47
- package/dist/navigation/dock.js.map +0 -1
- package/dist/navigation/footer.d.ts +0 -43
- package/dist/navigation/footer.js +0 -43
- package/dist/navigation/footer.js.map +0 -1
- package/dist/navigation/language-names.d.ts +0 -19
- package/dist/navigation/language-names.js +0 -79
- package/dist/navigation/language-names.js.map +0 -1
- package/dist/navigation/language-switcher.d.ts +0 -55
- package/dist/navigation/language-switcher.js +0 -53
- package/dist/navigation/language-switcher.js.map +0 -1
- package/dist/navigation/panel-header.d.ts +0 -37
- package/dist/navigation/panel-header.js +0 -50
- package/dist/navigation/panel-header.js.map +0 -1
- package/dist/navigation/toolbar.d.ts +0 -37
- package/dist/navigation/toolbar.js +0 -334
- package/dist/navigation/toolbar.js.map +0 -1
- package/dist/overlay/command-palette.d.ts +0 -53
- package/dist/overlay/command-palette.js +0 -130
- package/dist/overlay/command-palette.js.map +0 -1
- package/dist/overlay/overlay.d.ts +0 -299
- package/dist/overlay/overlay.js +0 -558
- package/dist/overlay/overlay.js.map +0 -1
- package/dist/selection/radio-card.d.ts +0 -31
- package/dist/selection/radio-card.js +0 -29
- package/dist/selection/radio-card.js.map +0 -1
package/dist/navigation/dock.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { Link as AriaLink, useLocale } from "react-aria-components";
|
|
5
|
-
import { cn } from "../utils.js";
|
|
6
|
-
import { Badge } from "../display/badge.js";
|
|
7
|
-
import { IconGlyph } from "../display/icon.js";
|
|
8
|
-
import { mainNavigationLabel } from "../i18n.js";
|
|
9
|
-
import { LAYER } from "../layers.js";
|
|
10
|
-
/** True while the on-screen keyboard covers part of the layout viewport (a field has focus). */
|
|
11
|
-
function useKeyboardOpen() {
|
|
12
|
-
const [open, setOpen] = React.useState(false);
|
|
13
|
-
React.useEffect(() => {
|
|
14
|
-
const viewport = window.visualViewport;
|
|
15
|
-
if (!viewport)
|
|
16
|
-
return;
|
|
17
|
-
const update = () => {
|
|
18
|
-
const editing = document.activeElement instanceof HTMLElement && document.activeElement.matches("input, textarea, select, [contenteditable]:not([contenteditable='false'])");
|
|
19
|
-
// The keyboard takes a quarter of the height or more; a URL bar collapsing takes far less.
|
|
20
|
-
setOpen(editing && viewport.height < window.innerHeight * 0.75);
|
|
21
|
-
};
|
|
22
|
-
viewport.addEventListener("resize", update);
|
|
23
|
-
window.addEventListener("focusin", update);
|
|
24
|
-
window.addEventListener("focusout", update);
|
|
25
|
-
return () => {
|
|
26
|
-
viewport.removeEventListener("resize", update);
|
|
27
|
-
window.removeEventListener("focusin", update);
|
|
28
|
-
window.removeEventListener("focusout", update);
|
|
29
|
-
};
|
|
30
|
-
}, []);
|
|
31
|
-
return open;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The bottom tab bar on phones: four or five destinations, icon over label, padded for the home
|
|
35
|
-
* indicator. Hidden from 768px up and while the on-screen keyboard is open; leave it out of
|
|
36
|
-
* full-screen flows (checkout).
|
|
37
|
-
*/
|
|
38
|
-
export function Dock({ items, currentKey, "aria-label": label }) {
|
|
39
|
-
const { locale } = useLocale();
|
|
40
|
-
const keyboard = useKeyboardOpen();
|
|
41
|
-
return (_jsx("nav", { "aria-label": label ?? mainNavigationLabel(locale), "data-slot": "dock", hidden: keyboard || undefined, className: cn("fixed inset-x-0 bottom-0 border-t border-ds-border bg-ds-surface-overlay shadow-ds-overflow md:hidden",
|
|
42
|
-
// Safe-area insets are physical edges, so they pair with physical padding.
|
|
43
|
-
"[padding-left:max(var(--ds-space-100),env(safe-area-inset-left,0px))] [padding-right:max(var(--ds-space-100),env(safe-area-inset-right,0px))] pt-ds-075 pb-[max(var(--ds-space-150),env(safe-area-inset-bottom,0px))]", LAYER.stickyBar), children: _jsx("ul", { className: "mx-auto grid max-w-[24.375rem] auto-cols-fr grid-flow-col", children: items.map((item) => (_jsx("li", { className: "flex", children: _jsxs(AriaLink, { href: item.href, "data-slot": "dock-item", "aria-current": item.key === currentKey ? "page" : undefined, className: cn("group/dock flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-ds-medium py-ds-050 text-[11px] leading-[14px] font-[500] text-ds-text-subtle outline-hidden", "data-[pressed]:bg-ds-background-neutral-pressed data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused aria-[current=page]:text-ds-text"), children: [_jsxs("span", { className: "relative", children: [_jsx(IconGlyph, { name: item.icon, "data-slot": "dock-item-icon", className: "size-[22px] group-aria-[current=page]/dock:text-ds-icon-brand" }), item.badge && item.badge.value > 0 && (
|
|
44
|
-
// Drawn on the icon; read after the label ("Mesajlar, 2").
|
|
45
|
-
_jsx("span", { "data-slot": "dock-item-badge", "aria-hidden": true, className: "absolute -top-1 -end-2.5", children: _jsx(Badge, { value: item.badge.value, tone: item.badge.tone, isOnIcon: true }) }))] }), _jsx("span", { "data-slot": "dock-item-label", className: "max-w-full truncate px-ds-025", children: item.label }), item.badge && item.badge.value > 0 && _jsx("span", { className: "sr-only", children: `, ${item.badge.value}` })] }) }, item.key))) }) }));
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=dock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dock.js","sourceRoot":"","sources":["../../src/navigation/dock.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAkB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAmBlC,gGAAgG;AAChG,SAAS,eAAe;IACtB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC;QACvC,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,YAAY,WAAW,IAAI,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,2EAA2E,CAAC,CAAC;YAC7K,2FAA2F;YAC3F,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;QAClE,CAAC,CAAC;QACF,QAAQ,CAAC,gBA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C,UAAU,aACxB,KAAC,SAAS,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,eAAY,gBAAgB,EAAC,SAAS,EAAC,+DAA+D,GAAG,EAClI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI;gCACrC,2DAA2D;gCAC3D,4BAAgB,iBAAiB,uBAAa,SAAS,EAAC,0BAA0B,YAChF,KAAC,KAAK,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,SAAG,GAC7D,CACR,IACI,EACP,4BAAgB,iBAAiB,EAAC,SAAS,EAAC,+BAA+B,YAAE,IAAI,CAAC,KAAK,GAAQ,EAC9F,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,eAAM,SAAS,EAAC,SAAS,YAAE,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAQ,IACxF,IArBJ,IAAI,CAAC,GAAG,CAsBZ,CACN,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Link as AriaLink, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { Badge, type BadgeTone } from \"../display/badge\";\nimport { IconGlyph, type IconName } from \"../display/icon\";\nimport { mainNavigationLabel } from \"../i18n\";\nimport { LAYER } from \"../layers\";\n\nexport type DockItem = {\n key: string;\n /** Always shown under the icon (\"Orders\"); the last item is \"More\" when the app has more. */\n label: string;\n icon: IconName;\n href: string;\n badge?: { value: number; tone?: BadgeTone };\n};\n\nexport type DockProps = {\n /** Four or five top destinations. */\n items: readonly DockItem[];\n currentKey?: string;\n /** Names the navigation landmark; \"Main menu\" by default. */\n \"aria-label\"?: string;\n};\n\n/** True while the on-screen keyboard covers part of the layout viewport (a field has focus). */\nfunction useKeyboardOpen() {\n const [open, setOpen] = React.useState(false);\n React.useEffect(() => {\n const viewport = window.visualViewport;\n if (!viewport) return;\n const update = () => {\n const editing = document.activeElement instanceof HTMLElement && document.activeElement.matches(\"input, textarea, select, [contenteditable]:not([contenteditable='false'])\");\n // The keyboard takes a quarter of the height or more; a URL bar collapsing takes far less.\n setOpen(editing && viewport.height < window.innerHeight * 0.75);\n };\n viewport.addEventListener(\"resize\", update);\n window.addEventListener(\"focusin\", update);\n window.addEventListener(\"focusout\", update);\n return () => {\n viewport.removeEventListener(\"resize\", update);\n window.removeEventListener(\"focusin\", update);\n window.removeEventListener(\"focusout\", update);\n };\n }, []);\n return open;\n}\n\n/**\n * The bottom tab bar on phones: four or five destinations, icon over label, padded for the home\n * indicator. Hidden from 768px up and while the on-screen keyboard is open; leave it out of\n * full-screen flows (checkout).\n */\nexport function Dock({ items, currentKey, \"aria-label\": label }: DockProps) {\n const { locale } = useLocale();\n const keyboard = useKeyboardOpen();\n return (\n <nav\n aria-label={label ?? mainNavigationLabel(locale)}\n data-slot=\"dock\"\n hidden={keyboard || undefined}\n className={cn(\n \"fixed inset-x-0 bottom-0 border-t border-ds-border bg-ds-surface-overlay shadow-ds-overflow md:hidden\",\n // Safe-area insets are physical edges, so they pair with physical padding.\n \"[padding-left:max(var(--ds-space-100),env(safe-area-inset-left,0px))] [padding-right:max(var(--ds-space-100),env(safe-area-inset-right,0px))] pt-ds-075 pb-[max(var(--ds-space-150),env(safe-area-inset-bottom,0px))]\",\n LAYER.stickyBar,\n )}\n >\n <ul className=\"mx-auto grid max-w-[24.375rem] auto-cols-fr grid-flow-col\">\n {items.map((item) => (\n <li key={item.key} className=\"flex\">\n <AriaLink\n href={item.href}\n data-slot=\"dock-item\"\n aria-current={item.key === currentKey ? \"page\" : undefined}\n className={cn(\n \"group/dock flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-ds-medium py-ds-050 text-[11px] leading-[14px] font-[500] text-ds-text-subtle outline-hidden\",\n \"data-[pressed]:bg-ds-background-neutral-pressed data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused aria-[current=page]:text-ds-text\",\n )}\n >\n <span className=\"relative\">\n <IconGlyph name={item.icon} data-slot=\"dock-item-icon\" className=\"size-[22px] group-aria-[current=page]/dock:text-ds-icon-brand\" />\n {item.badge && item.badge.value > 0 && (\n // Drawn on the icon; read after the label (\"Mesajlar, 2\").\n <span data-slot=\"dock-item-badge\" aria-hidden className=\"absolute -top-1 -end-2.5\">\n <Badge value={item.badge.value} tone={item.badge.tone} isOnIcon />\n </span>\n )}\n </span>\n <span data-slot=\"dock-item-label\" className=\"max-w-full truncate px-ds-025\">{item.label}</span>\n {item.badge && item.badge.value > 0 && <span className=\"sr-only\">{`, ${item.badge.value}`}</span>}\n </AriaLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n"]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export type FooterLink = {
|
|
3
|
-
/** Names the destination ("Privacy policy"), never "Click here". */
|
|
4
|
-
label: string;
|
|
5
|
-
href: string;
|
|
6
|
-
/** Another site: opens in a new tab with the 12px `arrow-up-right`. */
|
|
7
|
-
isExternal?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type FooterColumn = {
|
|
10
|
-
/** The column's title ("Product"); it also names the column's navigation. */
|
|
11
|
-
title: string;
|
|
12
|
-
/** At most six. */
|
|
13
|
-
links: readonly FooterLink[];
|
|
14
|
-
};
|
|
15
|
-
export type FooterProps = {
|
|
16
|
-
/** The logo and wordmark (the site's logo and name). It links to `brandHref`. */
|
|
17
|
-
brand: React.ReactNode;
|
|
18
|
-
/** Where the brand goes: the home page. */
|
|
19
|
-
brandHref?: string;
|
|
20
|
-
/** The brand link's name when the brand alone does not say where it goes ("Acme home"). */
|
|
21
|
-
brandLabel?: string;
|
|
22
|
-
/** One line about the product, under the brand. */
|
|
23
|
-
about?: React.ReactNode;
|
|
24
|
-
/** A contact link under the about line (a subtle `Link` to the support address). */
|
|
25
|
-
contact?: React.ReactNode;
|
|
26
|
-
/** Two to four columns of links. */
|
|
27
|
-
columns: readonly FooterColumn[];
|
|
28
|
-
/** The copyright line ("© 2026 Acme"); a platform credit can go here too. */
|
|
29
|
-
legal: React.ReactNode;
|
|
30
|
-
/** The language switch at the end of the legal row (a subtle compact Button or Menu). */
|
|
31
|
-
languageSwitch?: React.ReactNode;
|
|
32
|
-
/** The column titles' heading level: 2 by default, a level below the page's h1. */
|
|
33
|
-
headingLevel?: 2 | 3 | 4;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Closes every public page: the brand block, two to four
|
|
37
|
-
* columns of subtle links, and the legal row with the copyright and the language switch. It holds no
|
|
38
|
-
* primary action; the page's one primary action lives in the Navbar and the CTA band. Narrower than
|
|
39
|
-
* 48rem (a phone) everything stacks in one column; it measures its own width, not the viewport's.
|
|
40
|
-
* Render it at the page root, outside `main`, `section` and `article`: only there is it the page's
|
|
41
|
-
* `contentinfo` landmark.
|
|
42
|
-
*/
|
|
43
|
-
export declare function Footer({ brand, brandHref, brandLabel, about, contact, columns, legal, languageSwitch, headingLevel }: FooterProps): React.JSX.Element;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { Link as AriaLink } from "react-aria-components";
|
|
5
|
-
import { cn } from "../utils.js";
|
|
6
|
-
import { BrandLinkContext } from "./brand-link-context.js";
|
|
7
|
-
import { Link } from "../action/link.js";
|
|
8
|
-
const MAX_COLUMNS = 4;
|
|
9
|
-
const MAX_LINKS = 6;
|
|
10
|
-
/** From 48rem: the brand block, then one track per column (static classes: no inline style to strip). */
|
|
11
|
-
const GRID = {
|
|
12
|
-
0: "",
|
|
13
|
-
1: "@min-[48rem]:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]",
|
|
14
|
-
2: "@min-[48rem]:grid-cols-[minmax(0,1.5fr)_repeat(2,minmax(0,1fr))]",
|
|
15
|
-
3: "@min-[48rem]:grid-cols-[minmax(0,1.5fr)_repeat(3,minmax(0,1fr))]",
|
|
16
|
-
4: "@min-[48rem]:grid-cols-[minmax(0,1.5fr)_repeat(4,minmax(0,1fr))]",
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Closes every public page: the brand block, two to four
|
|
20
|
-
* columns of subtle links, and the legal row with the copyright and the language switch. It holds no
|
|
21
|
-
* primary action; the page's one primary action lives in the Navbar and the CTA band. Narrower than
|
|
22
|
-
* 48rem (a phone) everything stacks in one column; it measures its own width, not the viewport's.
|
|
23
|
-
* Render it at the page root, outside `main`, `section` and `article`: only there is it the page's
|
|
24
|
-
* `contentinfo` landmark.
|
|
25
|
-
*/
|
|
26
|
-
export function Footer({ brand, brandHref = "/", brandLabel, about, contact, columns, legal, languageSwitch, headingLevel = 2 }) {
|
|
27
|
-
const Title = `h${headingLevel}`;
|
|
28
|
-
const id = React.useId();
|
|
29
|
-
const tooMany = columns.length > MAX_COLUMNS || columns.some((column) => column.links.length > MAX_LINKS);
|
|
30
|
-
// Once, not on every render, nor twice under StrictMode's re-run of effects.
|
|
31
|
-
const warned = React.useRef(false);
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
if (!tooMany || warned.current)
|
|
34
|
-
return;
|
|
35
|
-
warned.current = true;
|
|
36
|
-
console.warn(`Footer: at most ${MAX_COLUMNS} columns of at most ${MAX_LINKS} links each.`);
|
|
37
|
-
}, [tooMany]);
|
|
38
|
-
return (_jsx("footer", { "data-slot": "footer", className: "@container border-t border-ds-border bg-ds-surface-sunken text-ds-text", children: _jsxs("div", { className: "mx-auto flex max-w-[1200px] flex-col gap-ds-500 px-ds-200 pt-ds-500 pb-ds-200 @min-[48rem]:px-ds-300 @min-[48rem]:pt-ds-600 @min-[48rem]:pb-ds-300", children: [_jsxs("div", { "data-slot": "footer-top", className: cn("grid grid-cols-1 gap-ds-400 @min-[48rem]:gap-ds-300", GRID[Math.min(columns.length, MAX_COLUMNS)]), children: [_jsxs("div", { "data-slot": "footer-brand", className: "flex flex-col items-start gap-ds-100", children: [_jsx(AriaLink, { href: brandHref, "aria-label": brandLabel, "data-slot": "footer-brand-link", 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", children: _jsx(BrandLinkContext.Provider, { value: true, children: brand }) }), about && _jsx("p", { className: "m-0 max-w-[36ch] text-body text-ds-text-subtle", children: about }), contact && _jsx("div", { "data-slot": "footer-contact", className: "text-body", children: contact })] }), columns.map((column, index) => {
|
|
39
|
-
const titleId = `${id}-column-${index}`;
|
|
40
|
-
return (_jsxs("nav", { "aria-labelledby": titleId, "data-slot": "footer-column", className: "flex flex-col gap-ds-150", children: [_jsx(Title, { id: titleId, className: "m-0 heading-xxsmall text-ds-text", children: column.title }), _jsx("ul", { className: "m-0 flex list-none flex-col gap-ds-100 p-0", children: column.links.map((link, linkIndex) => (_jsx("li", { className: "text-body", children: _jsx(Link, { href: link.href, variant: "subtle", isExternal: link.isExternal, children: link.label }) }, `${linkIndex}-${link.href}`))) })] }, `${index}-${column.title}`));
|
|
41
|
-
})] }), _jsxs("div", { "data-slot": "footer-legal", className: "flex flex-wrap items-center justify-between gap-x-ds-300 gap-y-ds-100 border-t border-ds-border pt-ds-200", children: [_jsx("div", { className: "text-body-small text-ds-text-subtlest", children: legal }), languageSwitch && _jsx("div", { "data-slot": "footer-language", className: "ms-auto", children: languageSwitch })] })] }) }));
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=footer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/navigation/footer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAA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,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,CAI/B,CACN,CAAC,GACC,KAZG,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,EAAE,CAa9B,CACP,CAAC;wBACJ,CAAC,CAAC,IACE,EACN,4BACY,cAAc,EACxB,SAAS,EAAC,2GAA2G,aAErH,cAAK,SAAS,EAAC,uCAAuC,YAAE,KAAK,GAAO,EACnE,cAAc,IAAI,2BAAe,iBAAiB,EAAC,SAAS,EAAC,SAAS,YAAE,cAAc,GAAO,IAC1F,IACF,GACC,CACV,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Link as AriaLink } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { BrandLinkContext } from \"./brand-link-context\";\nimport { Link } from \"../action/link\";\n\nexport type FooterLink = {\n /** Names the destination (\"Privacy policy\"), never \"Click here\". */\n label: string;\n href: string;\n /** Another site: opens in a new tab with the 12px `arrow-up-right`. */\n isExternal?: boolean;\n};\n\nexport type FooterColumn = {\n /** The column's title (\"Product\"); it also names the column's navigation. */\n title: string;\n /** At most six. */\n links: readonly FooterLink[];\n};\n\nexport type FooterProps = {\n /** The logo and wordmark (the site's logo and name). It links to `brandHref`. */\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 /** One line about the product, under the brand. */\n about?: React.ReactNode;\n /** A contact link under the about line (a subtle `Link` to the support address). */\n contact?: React.ReactNode;\n /** Two to four columns of links. */\n columns: readonly FooterColumn[];\n /** The copyright line (\"© 2026 Acme\"); a platform credit can go here too. */\n legal: React.ReactNode;\n /** The language switch at the end of the legal row (a subtle compact Button or Menu). */\n languageSwitch?: React.ReactNode;\n /** The column titles' heading level: 2 by default, a level below the page's h1. */\n headingLevel?: 2 | 3 | 4;\n};\n\nconst MAX_COLUMNS = 4;\nconst MAX_LINKS = 6;\n\n/** From 48rem: the brand block, then one track per column (static classes: no inline style to strip). */\nconst GRID: Record<number, string> = {\n 0: \"\",\n 1: \"@min-[48rem]:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]\",\n 2: \"@min-[48rem]:grid-cols-[minmax(0,1.5fr)_repeat(2,minmax(0,1fr))]\",\n 3: \"@min-[48rem]:grid-cols-[minmax(0,1.5fr)_repeat(3,minmax(0,1fr))]\",\n 4: \"@min-[48rem]:grid-cols-[minmax(0,1.5fr)_repeat(4,minmax(0,1fr))]\",\n};\n\n/**\n * Closes every public page: the brand block, two to four\n * columns of subtle links, and the legal row with the copyright and the language switch. It holds no\n * primary action; the page's one primary action lives in the Navbar and the CTA band. Narrower than\n * 48rem (a phone) everything stacks in one column; it measures its own width, not the viewport's.\n * Render it at the page root, outside `main`, `section` and `article`: only there is it the page's\n * `contentinfo` landmark.\n */\nexport function Footer({ brand, brandHref = \"/\", brandLabel, about, contact, columns, legal, languageSwitch, headingLevel = 2 }: FooterProps) {\n const Title = `h${headingLevel}` as const;\n const id = React.useId();\n const tooMany = columns.length > MAX_COLUMNS || columns.some((column) => column.links.length > MAX_LINKS);\n // Once, not on every render, nor twice under StrictMode's re-run of effects.\n const warned = React.useRef(false);\n React.useEffect(() => {\n if (!tooMany || warned.current) return;\n warned.current = true;\n console.warn(`Footer: at most ${MAX_COLUMNS} columns of at most ${MAX_LINKS} links each.`);\n }, [tooMany]);\n return (\n <footer data-slot=\"footer\" className=\"@container border-t border-ds-border bg-ds-surface-sunken text-ds-text\">\n <div className=\"mx-auto flex max-w-[1200px] flex-col gap-ds-500 px-ds-200 pt-ds-500 pb-ds-200 @min-[48rem]:px-ds-300 @min-[48rem]:pt-ds-600 @min-[48rem]:pb-ds-300\">\n <div\n data-slot=\"footer-top\"\n className={cn(\"grid grid-cols-1 gap-ds-400 @min-[48rem]:gap-ds-300\", GRID[Math.min(columns.length, MAX_COLUMNS)])}\n >\n <div data-slot=\"footer-brand\" className=\"flex flex-col items-start gap-ds-100\">\n <AriaLink\n href={brandHref}\n aria-label={brandLabel}\n data-slot=\"footer-brand-link\"\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 {about && <p className=\"m-0 max-w-[36ch] text-body text-ds-text-subtle\">{about}</p>}\n {contact && <div data-slot=\"footer-contact\" className=\"text-body\">{contact}</div>}\n </div>\n {columns.map((column, index) => {\n const titleId = `${id}-column-${index}`;\n return (\n <nav key={`${index}-${column.title}`} aria-labelledby={titleId} data-slot=\"footer-column\" className=\"flex flex-col gap-ds-150\">\n <Title id={titleId} className=\"m-0 heading-xxsmall text-ds-text\">\n {column.title}\n </Title>\n <ul className=\"m-0 flex list-none flex-col gap-ds-100 p-0\">\n {column.links.map((link, linkIndex) => (\n <li key={`${linkIndex}-${link.href}`} className=\"text-body\">\n <Link href={link.href} variant=\"subtle\" isExternal={link.isExternal}>\n {link.label}\n </Link>\n </li>\n ))}\n </ul>\n </nav>\n );\n })}\n </div>\n <div\n data-slot=\"footer-legal\"\n className=\"flex flex-wrap items-center justify-between gap-x-ds-300 gap-y-ds-100 border-t border-ds-border pt-ds-200\"\n >\n <div className=\"text-body-small text-ds-text-subtlest\">{legal}</div>\n {languageSwitch && <div data-slot=\"footer-language\" className=\"ms-auto\">{languageSwitch}</div>}\n </div>\n </div>\n </footer>\n );\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Names for languages the runtime names wrongly or not at all, as the reader of `uiLocale` should see them:
|
|
3
|
-
* Montenegrin, which Intl calls Serbian (`registerLanguageNames("en", { me: "Montenegrin" })`), or every
|
|
4
|
-
* language in a UI language whose display names browsers do not ship (Albanian, Macedonian). `uiLocale` is a
|
|
5
|
-
* language ("sq") or a full tag ("pt-BR"); the full tag wins.
|
|
6
|
-
*/
|
|
7
|
-
export declare function registerLanguageNames(uiLocale: string, names: Readonly<Record<string, string>>): void;
|
|
8
|
-
/** Uppercase the first code point only, in the UI language ("İngilizce" in Turkish), leaving the rest as given. */
|
|
9
|
-
export declare function capitalizeLanguageName(name: string, uiLocale: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* A language's name in the UI language: the app's registered name, else Intl's (through `registerLocaleAliases`),
|
|
12
|
-
* else the language's own name (its endonym), never the host's language, else the tag itself.
|
|
13
|
-
*/
|
|
14
|
-
export declare function languageName(locale: string, uiLocale: string): string;
|
|
15
|
-
/** The locales with their names in the UI language, sorted by that name the way the UI language sorts. */
|
|
16
|
-
export declare function languageOptions<Locale extends string>(locales: readonly Locale[], uiLocale: string): Array<{
|
|
17
|
-
locale: Locale;
|
|
18
|
-
label: string;
|
|
19
|
-
}>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// No "use client": plain functions, usable on the server so both render the same names.
|
|
2
|
-
import { hasIntlData, intlLocale } from "../intl-locale.js";
|
|
3
|
-
/** App-registered names, by UI language then by language tag. */
|
|
4
|
-
const registered = new Map();
|
|
5
|
-
/**
|
|
6
|
-
* Names for languages the runtime names wrongly or not at all, as the reader of `uiLocale` should see them:
|
|
7
|
-
* Montenegrin, which Intl calls Serbian (`registerLanguageNames("en", { me: "Montenegrin" })`), or every
|
|
8
|
-
* language in a UI language whose display names browsers do not ship (Albanian, Macedonian). `uiLocale` is a
|
|
9
|
-
* language ("sq") or a full tag ("pt-BR"); the full tag wins.
|
|
10
|
-
*/
|
|
11
|
-
export function registerLanguageNames(uiLocale, names) {
|
|
12
|
-
const key = uiLocale.toLowerCase();
|
|
13
|
-
const table = registered.get(key) ?? new Map();
|
|
14
|
-
for (const [tag, name] of Object.entries(names))
|
|
15
|
-
table.set(tag.toLowerCase(), name);
|
|
16
|
-
registered.set(key, table);
|
|
17
|
-
}
|
|
18
|
-
function registeredName(locale, uiLocale) {
|
|
19
|
-
const tag = locale.toLowerCase();
|
|
20
|
-
const ui = uiLocale.toLowerCase();
|
|
21
|
-
return registered.get(ui)?.get(tag) ?? registered.get(ui.split(/[-_]/)[0] ?? ui)?.get(tag);
|
|
22
|
-
}
|
|
23
|
-
/** Uppercase the first code point only, in the UI language ("İngilizce" in Turkish), leaving the rest as given. */
|
|
24
|
-
export function capitalizeLanguageName(name, uiLocale) {
|
|
25
|
-
const first = [...name][0];
|
|
26
|
-
if (!first)
|
|
27
|
-
return name;
|
|
28
|
-
try {
|
|
29
|
-
return first.toLocaleUpperCase(intlLocale(uiLocale)) + name.slice(first.length);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return first.toUpperCase() + name.slice(first.length);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function displayName(locale, uiLocale) {
|
|
36
|
-
try {
|
|
37
|
-
// "standard" names a region in brackets ("Portuguese (Brazil)"), not "Brazilian Portuguese".
|
|
38
|
-
return new Intl.DisplayNames([uiLocale], { type: "language", fallback: "none", languageDisplay: "standard" }).of(locale) ?? undefined;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* A language's name in the UI language: the app's registered name, else Intl's (through `registerLocaleAliases`),
|
|
46
|
-
* else the language's own name (its endonym), never the host's language, else the tag itself.
|
|
47
|
-
*/
|
|
48
|
-
export function languageName(locale, uiLocale) {
|
|
49
|
-
const own = registeredName(locale, uiLocale);
|
|
50
|
-
if (own)
|
|
51
|
-
return own;
|
|
52
|
-
const ui = intlLocale(uiLocale);
|
|
53
|
-
const target = intlLocale(locale);
|
|
54
|
-
// A runtime with no data for the UI language would name languages in the host's language; the endonym is never that.
|
|
55
|
-
const name = hasIntlData(ui) ? displayName(target, ui) : undefined;
|
|
56
|
-
if (name)
|
|
57
|
-
return capitalizeLanguageName(name, uiLocale);
|
|
58
|
-
// The same rule for the endonym: a language with no data of its own would be named in the host's language.
|
|
59
|
-
const endonym = registeredName(locale, locale) ?? (hasIntlData(target) ? displayName(target, target) : undefined);
|
|
60
|
-
if (endonym)
|
|
61
|
-
return capitalizeLanguageName(endonym, locale);
|
|
62
|
-
// No name anywhere: the tag as given, not dressed up as a word.
|
|
63
|
-
return locale;
|
|
64
|
-
}
|
|
65
|
-
/** The locales with their names in the UI language, sorted by that name the way the UI language sorts. */
|
|
66
|
-
export function languageOptions(locales, uiLocale) {
|
|
67
|
-
let collator;
|
|
68
|
-
try {
|
|
69
|
-
collator = new Intl.Collator(intlLocale(uiLocale).replace(/_/g, "-"), { sensitivity: "base" });
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
// A tag Intl cannot read ("x-app") still gets a list, in the runtime's default order.
|
|
73
|
-
collator = new Intl.Collator(undefined, { sensitivity: "base" });
|
|
74
|
-
}
|
|
75
|
-
return locales
|
|
76
|
-
.map((locale) => ({ locale, label: languageName(locale, uiLocale) }))
|
|
77
|
-
.sort((a, b) => collator.compare(a.label, b.label) || (a.locale < b.locale ? -1 : a.locale > b.locale ? 1 : 0));
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=language-names.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"language-names.js","sourceRoot":"","sources":["../../src/navigation/language-names.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEzD,iEAAiE;AACjE,MAAM,UAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB,EAAE,KAAuC;IAC7F,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,EAAkB,CAAC;IAC/D,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,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AAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;IACjG,CAAC;IAAC,MAAM,CAAC;QACP,sFAAsF;QACtF,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;SACpE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpH,CAAC","sourcesContent":["// No \"use client\": plain functions, usable on the server so both render the same names.\nimport { hasIntlData, intlLocale } from \"../intl-locale\";\n\n/** App-registered names, by UI language then by language tag. */\nconst registered = new Map<string, Map<string, string>>();\n\n/**\n * Names for languages the runtime names wrongly or not at all, as the reader of `uiLocale` should see them:\n * Montenegrin, which Intl calls Serbian (`registerLanguageNames(\"en\", { me: \"Montenegrin\" })`), or every\n * language in a UI language whose display names browsers do not ship (Albanian, Macedonian). `uiLocale` is a\n * language (\"sq\") or a full tag (\"pt-BR\"); the full tag wins.\n */\nexport function registerLanguageNames(uiLocale: string, names: Readonly<Record<string, string>>): void {\n const key = uiLocale.toLowerCase();\n const table = registered.get(key) ?? new Map<string, string>();\n for (const [tag, name] of Object.entries(names)) table.set(tag.toLowerCase(), name);\n registered.set(key, table);\n}\n\nfunction registeredName(locale: string, uiLocale: string): string | undefined {\n const tag = locale.toLowerCase();\n const ui = uiLocale.toLowerCase();\n return registered.get(ui)?.get(tag) ?? registered.get(ui.split(/[-_]/)[0] ?? ui)?.get(tag);\n}\n\n/** Uppercase the first code point only, in the UI language (\"İngilizce\" in Turkish), leaving the rest as given. */\nexport function capitalizeLanguageName(name: string, uiLocale: string): string {\n const first = [...name][0];\n if (!first) return name;\n try {\n return first.toLocaleUpperCase(intlLocale(uiLocale)) + name.slice(first.length);\n } catch {\n return first.toUpperCase() + name.slice(first.length);\n }\n}\n\nfunction displayName(locale: string, uiLocale: string): string | undefined {\n try {\n // \"standard\" names a region in brackets (\"Portuguese (Brazil)\"), not \"Brazilian Portuguese\".\n return new Intl.DisplayNames([uiLocale], { type: \"language\", fallback: \"none\", languageDisplay: \"standard\" }).of(locale) ?? undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * A language's name in the UI language: the app's registered name, else Intl's (through `registerLocaleAliases`),\n * else the language's own name (its endonym), never the host's language, else the tag itself.\n */\nexport function languageName(locale: string, uiLocale: string): string {\n const own = registeredName(locale, uiLocale);\n if (own) return own;\n const ui = intlLocale(uiLocale);\n const target = intlLocale(locale);\n // A runtime with no data for the UI language would name languages in the host's language; the endonym is never that.\n const name = hasIntlData(ui) ? displayName(target, ui) : undefined;\n if (name) return capitalizeLanguageName(name, uiLocale);\n // The same rule for the endonym: a language with no data of its own would be named in the host's language.\n const endonym = registeredName(locale, locale) ?? (hasIntlData(target) ? displayName(target, target) : undefined);\n if (endonym) return capitalizeLanguageName(endonym, locale);\n // No name anywhere: the tag as given, not dressed up as a word.\n return locale;\n}\n\n/** The locales with their names in the UI language, sorted by that name the way the UI language sorts. */\nexport function languageOptions<Locale extends string>(locales: readonly Locale[], uiLocale: string): Array<{ locale: Locale; label: string }> {\n let collator: Intl.Collator;\n try {\n collator = new Intl.Collator(intlLocale(uiLocale).replace(/_/g, \"-\"), { sensitivity: \"base\" });\n } catch {\n // A tag Intl cannot read (\"x-app\") still gets a list, in the runtime's default order.\n collator = new Intl.Collator(undefined, { sensitivity: \"base\" });\n }\n return locales\n .map((locale) => ({ locale, label: languageName(locale, uiLocale) }))\n .sort((a, b) => collator.compare(a.label, b.label) || (a.locale < b.locale ? -1 : a.locale > b.locale ? 1 : 0));\n}\n"]}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
/**
|
|
3
|
-
* One language as the switcher shows it: the app's mark (a flag, a code chip), if any, and the name in the UI
|
|
4
|
-
* language. With the name hidden (a square trigger) the mark stands alone; the name stays for screen readers.
|
|
5
|
-
* The mark is decorative next to the name, so it is hidden from assistive technology, and the name always tells
|
|
6
|
-
* the options apart.
|
|
7
|
-
*/
|
|
8
|
-
export declare function LanguageLabel({ locale, uiLocale, hideName, mark, }: {
|
|
9
|
-
locale: string;
|
|
10
|
-
uiLocale: string;
|
|
11
|
-
hideName?: boolean;
|
|
12
|
-
mark?: React.ReactNode;
|
|
13
|
-
}): React.JSX.Element;
|
|
14
|
-
export interface LanguageSwitcherProps<Locale extends string> {
|
|
15
|
-
/** Locales to offer, already narrowed to what this product enables. */
|
|
16
|
-
locales: readonly Locale[];
|
|
17
|
-
current: Locale;
|
|
18
|
-
onSelect: (locale: Locale) => void;
|
|
19
|
-
/** The trigger's accessible name and tooltip; "Language" (the DS string) by default. */
|
|
20
|
-
label?: string;
|
|
21
|
-
/** Hold the disabled trigger while the product's locale list resolves. */
|
|
22
|
-
isLoading?: boolean;
|
|
23
|
-
/** `button` (default): a trigger in a bar. `sidebar`: a full-width row whose list opens upward, for a panel sidebar. */
|
|
24
|
-
variant?: "button" | "sidebar";
|
|
25
|
-
/** A collapsed rail: the mark alone (or the name, without one), kept for screen readers either way. */
|
|
26
|
-
isCollapsed?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* A mark before each language's name: a flag, an `IsoChip`, an icon. None by default: a language is not a
|
|
29
|
-
* country, and the name alone tells the options apart.
|
|
30
|
-
*/
|
|
31
|
-
renderMark?: (locale: Locale) => React.ReactNode;
|
|
32
|
-
/** Control height: `medium` (default) matches the DS controls, `small` is the compact step. */
|
|
33
|
-
size?: "small" | "medium";
|
|
34
|
-
/**
|
|
35
|
-
* Ids of elements that describe the trigger ("Changes the language of the whole panel"). It lands on the
|
|
36
|
-
* trigger button, the focusable control, also while it is disabled for `isLoading`; left out, nothing is
|
|
37
|
-
* added. While the trigger's tooltip is open it takes the place of the tooltip's id, which only
|
|
38
|
-
* repeats `label`.
|
|
39
|
-
*/
|
|
40
|
-
"aria-describedby"?: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The language choice every surface offers, on the DS.
|
|
44
|
-
*
|
|
45
|
-
* Presentation only: the app resolves the product's locale list and handles
|
|
46
|
-
* `onSelect` (routing, persistence). Names come from `Intl.DisplayNames` in
|
|
47
|
-
* the active UI locale (`current`), ordered by that visible name.
|
|
48
|
-
* Choosing a value is a Select, not a Menu, so the list is a listbox whose
|
|
49
|
-
* current option is selected for assistive technology and carries a check.
|
|
50
|
-
*
|
|
51
|
-
* The trigger stays disabled until the component has mounted *and* the
|
|
52
|
-
* caller reports the list resolved, so a product restricted to one language
|
|
53
|
-
* never flashes the full list on a cold cache.
|
|
54
|
-
*/
|
|
55
|
-
export declare function LanguageSwitcher<Locale extends string>({ locales, current, onSelect, label: labelProp, isLoading: loading, variant, isCollapsed: collapsed, size, renderMark, "aria-describedby": describedBy, }: LanguageSwitcherProps<Locale>): React.JSX.Element;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { Button as AriaButton, ListBox, ListBoxItem, Popover, Select as AriaSelect, } from "react-aria-components";
|
|
5
|
-
import { BUTTON_BASE, BUTTON_SIZE, buttonVariantClasses, ICON_ONLY_SIZE } from "../action/styles.js";
|
|
6
|
-
import { IconGlyph } from "../display/icon.js";
|
|
7
|
-
import { TooltipFor } from "../overlay/floating.js";
|
|
8
|
-
import { LISTBOX, OPTION } from "../selection/listbox.js";
|
|
9
|
-
import { languageLabel } from "../i18n.js";
|
|
10
|
-
import { cn } from "../utils.js";
|
|
11
|
-
import { languageOptions, languageName } from "./language-names.js";
|
|
12
|
-
/**
|
|
13
|
-
* One language as the switcher shows it: the app's mark (a flag, a code chip), if any, and the name in the UI
|
|
14
|
-
* language. With the name hidden (a square trigger) the mark stands alone; the name stays for screen readers.
|
|
15
|
-
* The mark is decorative next to the name, so it is hidden from assistive technology, and the name always tells
|
|
16
|
-
* the options apart.
|
|
17
|
-
*/
|
|
18
|
-
export function LanguageLabel({ locale, uiLocale, hideName = false, mark, }) {
|
|
19
|
-
return (_jsxs("span", { "data-slot": "language-label", className: "inline-flex min-w-0 items-center gap-ds-075", children: [mark != null && (_jsx("span", { "data-slot": "language-mark", "aria-hidden": "true", className: "inline-flex shrink-0 items-center", children: mark })), _jsx("span", { className: hideName ? "sr-only" : "truncate", children: languageName(locale, uiLocale) })] }));
|
|
20
|
-
}
|
|
21
|
-
const subscribeToClient = () => () => { };
|
|
22
|
-
/**
|
|
23
|
-
* The language choice every surface offers, on the DS.
|
|
24
|
-
*
|
|
25
|
-
* Presentation only: the app resolves the product's locale list and handles
|
|
26
|
-
* `onSelect` (routing, persistence). Names come from `Intl.DisplayNames` in
|
|
27
|
-
* the active UI locale (`current`), ordered by that visible name.
|
|
28
|
-
* Choosing a value is a Select, not a Menu, so the list is a listbox whose
|
|
29
|
-
* current option is selected for assistive technology and carries a check.
|
|
30
|
-
*
|
|
31
|
-
* The trigger stays disabled until the component has mounted *and* the
|
|
32
|
-
* caller reports the list resolved, so a product restricted to one language
|
|
33
|
-
* never flashes the full list on a cold cache.
|
|
34
|
-
*/
|
|
35
|
-
export function LanguageSwitcher({ locales, current, onSelect, label: labelProp, isLoading: loading = false, variant = "button", isCollapsed: collapsed = false, size = "medium", renderMark, "aria-describedby": describedBy, }) {
|
|
36
|
-
const sidebar = variant === "sidebar";
|
|
37
|
-
const label = labelProp ?? languageLabel(current);
|
|
38
|
-
// A collapsed trigger hides the name only behind a mark that is really there.
|
|
39
|
-
const currentMark = renderMark?.(current) ?? null;
|
|
40
|
-
const mounted = React.useSyncExternalStore(subscribeToClient, () => true, () => false);
|
|
41
|
-
const buttonSize = size;
|
|
42
|
-
const square = collapsed && !sidebar;
|
|
43
|
-
const trigger = cn(BUTTON_BASE, buttonVariantClasses("subtle"), BUTTON_SIZE[buttonSize], "font-normal", square && ICON_ONLY_SIZE[buttonSize], sidebar && (collapsed ? "w-full justify-center px-0" : "w-full justify-start"));
|
|
44
|
-
if (!mounted || loading) {
|
|
45
|
-
return (_jsx(AriaButton, { "data-slot": "language-switcher-trigger", "aria-label": label, "aria-describedby": describedBy, isDisabled: true, className: trigger, children: _jsx(LanguageLabel, { locale: current, uiLocale: current, hideName: collapsed && currentMark != null, mark: currentMark }) }));
|
|
46
|
-
}
|
|
47
|
-
const options = languageOptions(locales, current);
|
|
48
|
-
return (_jsxs(AriaSelect, { "aria-label": label, "aria-describedby": describedBy, value: current, onChange: (key) => {
|
|
49
|
-
if (key != null)
|
|
50
|
-
onSelect(String(key));
|
|
51
|
-
}, "data-slot": "language-switcher", className: cn(sidebar && "w-full"), children: [_jsx(TooltipFor, { content: label, placement: "bottom", children: _jsx(AriaButton, { "data-slot": "language-switcher-trigger", className: trigger, children: _jsx(LanguageLabel, { locale: current, uiLocale: current, hideName: collapsed && currentMark != null, mark: currentMark }) }) }), _jsx(Popover, { "data-slot": "language-switcher-popover", placement: sidebar ? "top start" : "bottom end", offset: 4, className: "flex min-w-44 flex-col overflow-hidden rounded-ds-large bg-ds-surface-overlay p-ds-050 text-ds-text shadow-ds-overlay outline-hidden", children: _jsx(ListBox, { "data-slot": "language-switcher-list", className: LISTBOX, children: options.map((option) => (_jsx(ListBoxItem, { id: option.locale, textValue: option.label, "data-slot": "language-switcher-option", className: cn(OPTION, "whitespace-nowrap"), children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-slot": "language-switcher-check", className: "flex size-4 shrink-0 items-center justify-center", children: isSelected && _jsx(IconGlyph, { name: "check" }) }), _jsx(LanguageLabel, { locale: option.locale, uiLocale: current, mark: renderMark?.(option.locale) })] })) }, option.locale))) }) })] }));
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=language-switcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"language-switcher.js","sourceRoot":"","sources":["../../src/navigation/language-switcher.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,IAAI,UAAU,GAErB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,IAAI,GACyC;IACjF,OAAO,CACL,6BAAgB,gBAAgB,EAAC,SAAS,EAAC,6CAA6C,aACrF,IAAI,IAAI,IAAI,IAAI,CACf,4BAAgB,eAAe,iBAAa,MAAM,EAAC,SAAS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C,MAAM,EAAE,EAAE,CAAC,CACvB,KAAC,WAAW,IAEV,EAAE,EAAE,MAAM,CAAC,MAAM,EACjB,SAAS,EAAE,MAAM,CAAC,KAAK,eACb,0BAA0B,EACpC,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC,YAEzC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CACnB,8BAGE,8BAAkB,MAAM,eAAW,yBAAyB,EAAC,SAAS,EAAC,kDAAkD,YACtH,UAAU,IAAI,KAAC,SAAS,IAAC,IAAI,EAAC,OAAO,GAAG,GACpC,EACP,KAAC,aAAa,IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAI,IAC7F,CACJ,IAfI,MAAM,CAAC,MAAM,CAgBN,CACf,CAAC,GACM,GACF,IACC,CACd,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Button as AriaButton,\n ListBox,\n ListBoxItem,\n Popover,\n Select as AriaSelect,\n type Key,\n} from \"react-aria-components\";\n\nimport { BUTTON_BASE, BUTTON_SIZE, buttonVariantClasses, ICON_ONLY_SIZE } from \"../action/styles\";\nimport { IconGlyph } from \"../display/icon\";\nimport { TooltipFor } from \"../overlay/floating\";\nimport { LISTBOX, OPTION } from \"../selection/listbox\";\nimport { languageLabel } from \"../i18n\";\nimport { cn } from \"../utils\";\nimport { languageOptions, languageName } from \"./language-names\";\n\n/**\n * One language as the switcher shows it: the app's mark (a flag, a code chip), if any, and the name in the UI\n * language. With the name hidden (a square trigger) the mark stands alone; the name stays for screen readers.\n * The mark is decorative next to the name, so it is hidden from assistive technology, and the name always tells\n * the options apart.\n */\nexport function LanguageLabel({\n locale, uiLocale, hideName = false, mark,\n}: { locale: string; uiLocale: string; hideName?: boolean; mark?: React.ReactNode }) {\n return (\n <span data-slot=\"language-label\" className=\"inline-flex min-w-0 items-center gap-ds-075\">\n {mark != null && (\n <span data-slot=\"language-mark\" aria-hidden=\"true\" className=\"inline-flex shrink-0 items-center\">\n {mark}\n </span>\n )}\n <span className={hideName ? \"sr-only\" : \"truncate\"}>{languageName(locale, uiLocale)}</span>\n </span>\n );\n}\n\nexport interface LanguageSwitcherProps<Locale extends string> {\n /** Locales to offer, already narrowed to what this product enables. */\n locales: readonly Locale[];\n current: Locale;\n onSelect: (locale: Locale) => void;\n /** The trigger's accessible name and tooltip; \"Language\" (the DS string) by default. */\n label?: string;\n /** Hold the disabled trigger while the product's locale list resolves. */\n isLoading?: boolean;\n /** `button` (default): a trigger in a bar. `sidebar`: a full-width row whose list opens upward, for a panel sidebar. */\n variant?: \"button\" | \"sidebar\";\n /** A collapsed rail: the mark alone (or the name, without one), kept for screen readers either way. */\n isCollapsed?: boolean;\n /**\n * A mark before each language's name: a flag, an `IsoChip`, an icon. None by default: a language is not a\n * country, and the name alone tells the options apart.\n */\n renderMark?: (locale: Locale) => React.ReactNode;\n /** Control height: `medium` (default) matches the DS controls, `small` is the compact step. */\n size?: \"small\" | \"medium\";\n /**\n * Ids of elements that describe the trigger (\"Changes the language of the whole panel\"). It lands on the\n * trigger button, the focusable control, also while it is disabled for `isLoading`; left out, nothing is\n * added. While the trigger's tooltip is open it takes the place of the tooltip's id, which only\n * repeats `label`.\n */\n \"aria-describedby\"?: string;\n}\n\nconst subscribeToClient = () => () => {};\n\n/**\n * The language choice every surface offers, on the DS.\n *\n * Presentation only: the app resolves the product's locale list and handles\n * `onSelect` (routing, persistence). Names come from `Intl.DisplayNames` in\n * the active UI locale (`current`), ordered by that visible name.\n * Choosing a value is a Select, not a Menu, so the list is a listbox whose\n * current option is selected for assistive technology and carries a check.\n *\n * The trigger stays disabled until the component has mounted *and* the\n * caller reports the list resolved, so a product restricted to one language\n * never flashes the full list on a cold cache.\n */\nexport function LanguageSwitcher<Locale extends string>({\n locales,\n current,\n onSelect,\n label: labelProp,\n isLoading: loading = false,\n variant = \"button\",\n isCollapsed: collapsed = false,\n size = \"medium\",\n renderMark,\n \"aria-describedby\": describedBy,\n}: LanguageSwitcherProps<Locale>) {\n const sidebar = variant === \"sidebar\";\n const label = labelProp ?? languageLabel(current);\n // A collapsed trigger hides the name only behind a mark that is really there.\n const currentMark = renderMark?.(current) ?? null;\n const mounted = React.useSyncExternalStore(subscribeToClient, () => true, () => false);\n const buttonSize = size;\n const square = collapsed && !sidebar;\n const trigger = cn(\n BUTTON_BASE,\n buttonVariantClasses(\"subtle\"),\n BUTTON_SIZE[buttonSize],\n \"font-normal\",\n square && ICON_ONLY_SIZE[buttonSize],\n sidebar && (collapsed ? \"w-full justify-center px-0\" : \"w-full justify-start\"),\n );\n\n if (!mounted || loading) {\n return (\n <AriaButton data-slot=\"language-switcher-trigger\" aria-label={label} aria-describedby={describedBy} isDisabled className={trigger}>\n <LanguageLabel locale={current} uiLocale={current} hideName={collapsed && currentMark != null} mark={currentMark} />\n </AriaButton>\n );\n }\n\n const options = languageOptions(locales, current);\n\n return (\n <AriaSelect\n aria-label={label}\n // React Aria's Select hands it to the trigger button (useSelect → useField → triggerProps), not the wrapper.\n aria-describedby={describedBy}\n value={current as Key}\n onChange={(key) => {\n if (key != null) onSelect(String(key) as Locale);\n }}\n data-slot=\"language-switcher\"\n className={cn(sidebar && \"w-full\")}\n >\n <TooltipFor content={label} placement=\"bottom\">\n <AriaButton data-slot=\"language-switcher-trigger\" className={trigger}>\n {/* No SelectValue: the trigger is named by the caller's label alone, as before, and shows the current\n language itself (it is always `current`). */}\n <LanguageLabel locale={current} uiLocale={current} hideName={collapsed && currentMark != null} mark={currentMark} />\n </AriaButton>\n </TooltipFor>\n <Popover\n data-slot=\"language-switcher-popover\"\n placement={sidebar ? \"top start\" : \"bottom end\"}\n offset={4}\n className=\"flex min-w-44 flex-col overflow-hidden rounded-ds-large bg-ds-surface-overlay p-ds-050 text-ds-text shadow-ds-overlay outline-hidden\"\n >\n <ListBox data-slot=\"language-switcher-list\" className={LISTBOX}>\n {options.map((option) => (\n <ListBoxItem\n key={option.locale}\n id={option.locale}\n textValue={option.label}\n data-slot=\"language-switcher-option\"\n className={cn(OPTION, \"whitespace-nowrap\")}\n >\n {({ isSelected }) => (\n <>\n {/* The slot holds its width whether or not it is filled, so switching never shifts the rows;\n the indicator stays at the inline start. */}\n <span aria-hidden=\"true\" data-slot=\"language-switcher-check\" className=\"flex size-4 shrink-0 items-center justify-center\">\n {isSelected && <IconGlyph name=\"check\" />}\n </span>\n <LanguageLabel locale={option.locale} uiLocale={current} mark={renderMark?.(option.locale)} />\n </>\n )}\n </ListBoxItem>\n ))}\n </ListBox>\n </Popover>\n </AriaSelect>\n );\n}\n"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { type BreadcrumbItem } from "./breadcrumbs.js";
|
|
3
|
-
/**
|
|
4
|
-
* Owns the bar's two regions. It sits above both the bar and the page, because the shell renders them as
|
|
5
|
-
* siblings: the bar outside the scrolling box (so content never runs under it) and the page inside it.
|
|
6
|
-
*/
|
|
7
|
-
export declare function PanelHeaderProvider({ children }: {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
}): React.JSX.Element;
|
|
10
|
-
export type PanelHeaderBarProps = {
|
|
11
|
-
/** The menu button's name ("Open menu"); it opens the Sidebar, which is a panel under 1024px. */
|
|
12
|
-
menuLabel: string;
|
|
13
|
-
onMenuPress: () => void;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* The panel's top bar (admin apps): the menu button under 1024px, then the page's title and its
|
|
17
|
-
* actions, which the page passes through `PanelHeader`. The shell renders it outside the box that scrolls.
|
|
18
|
-
* Below 640px the actions take their own row, so a search field and a primary button never squeeze the title.
|
|
19
|
-
*/
|
|
20
|
-
export declare function PanelHeaderBar({ menuLabel, onMenuPress }: PanelHeaderBarProps): React.JSX.Element;
|
|
21
|
-
export type PanelHeaderProps = {
|
|
22
|
-
/** The page's name; the page's one h1. */
|
|
23
|
-
title: React.ReactNode;
|
|
24
|
-
/** One line under the title. */
|
|
25
|
-
description?: React.ReactNode;
|
|
26
|
-
/** Where the page sits, above the title (a detail page under its list). */
|
|
27
|
-
breadcrumbs?: readonly BreadcrumbItem[];
|
|
28
|
-
/** The page's actions: filters, a search field, one primary button. */
|
|
29
|
-
actions?: React.ReactNode;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* A panel page's header: the page says what it is and what it can do, and the
|
|
33
|
-
* shell's `PanelHeaderBar` shows it, outside the scrolling content. Outside a `PanelHeaderProvider` (a page
|
|
34
|
-
* rendered on its own, a test), it renders in place, so such a page keeps its title. A provider must always
|
|
35
|
-
* render a bar.
|
|
36
|
-
*/
|
|
37
|
-
export declare function PanelHeader({ title, description, breadcrumbs, actions }: PanelHeaderProps): React.JSX.Element | null;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { createPortal } from "react-dom";
|
|
5
|
-
import { Button } from "../action/button.js";
|
|
6
|
-
import { Heading, Text } from "../display/typography.js";
|
|
7
|
-
import { Breadcrumbs } from "./breadcrumbs.js";
|
|
8
|
-
const PanelHeaderContext = React.createContext(null);
|
|
9
|
-
/**
|
|
10
|
-
* Owns the bar's two regions. It sits above both the bar and the page, because the shell renders them as
|
|
11
|
-
* siblings: the bar outside the scrolling box (so content never runs under it) and the page inside it.
|
|
12
|
-
*/
|
|
13
|
-
export function PanelHeaderProvider({ children }) {
|
|
14
|
-
const [titleNode, setTitleNode] = React.useState(null);
|
|
15
|
-
const [actionsNode, setActionsNode] = React.useState(null);
|
|
16
|
-
const value = React.useMemo(() => ({ titleNode, actionsNode, setTitleNode, setActionsNode }), [titleNode, actionsNode]);
|
|
17
|
-
return _jsx(PanelHeaderContext.Provider, { value: value, children: children });
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* The panel's top bar (admin apps): the menu button under 1024px, then the page's title and its
|
|
21
|
-
* actions, which the page passes through `PanelHeader`. The shell renders it outside the box that scrolls.
|
|
22
|
-
* Below 640px the actions take their own row, so a search field and a primary button never squeeze the title.
|
|
23
|
-
*/
|
|
24
|
-
export function PanelHeaderBar({ menuLabel, onMenuPress }) {
|
|
25
|
-
const slots = React.useContext(PanelHeaderContext);
|
|
26
|
-
return (_jsxs("header", { "data-slot": "panel-header-bar", className: "flex shrink-0 flex-col gap-ds-100 border-b border-ds-border bg-ds-surface px-ds-200 py-ds-100 sm:min-h-16 sm:flex-row sm:items-center sm:justify-between sm:gap-ds-150 sm:px-ds-400", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-ds-150", children: [_jsx("span", { "data-slot": "panel-header-menu", className: "flex lg:hidden", children: _jsx(Button, { variant: "subtle", iconOnly: true, iconBefore: "menu", "aria-label": menuLabel, onPress: onMenuPress }) }), _jsx("div", { ref: slots?.setTitleNode, "data-slot": "panel-header-title", className: "min-w-0 flex-1" })] }), _jsx("div", { ref: slots?.setActionsNode, "data-slot": "panel-header-actions", className: "flex shrink-0 flex-wrap items-center gap-ds-100 empty:hidden sm:flex-nowrap sm:justify-end" })] }));
|
|
27
|
-
}
|
|
28
|
-
function TitleBlock({ title, description, breadcrumbs }) {
|
|
29
|
-
return (_jsxs("div", { "data-slot": "panel-header-text", className: "flex min-w-0 flex-col gap-ds-025", children: [breadcrumbs && breadcrumbs.length > 0 && _jsx(Breadcrumbs, { items: breadcrumbs }), _jsx(Heading, { level: 1, size: "heading-medium", children: title }), description != null && (_jsx(Text, { size: "body-small", tone: "subtle", elementType: "p", children: description }))] }));
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* A panel page's header: the page says what it is and what it can do, and the
|
|
33
|
-
* shell's `PanelHeaderBar` shows it, outside the scrolling content. Outside a `PanelHeaderProvider` (a page
|
|
34
|
-
* rendered on its own, a test), it renders in place, so such a page keeps its title. A provider must always
|
|
35
|
-
* render a bar.
|
|
36
|
-
*/
|
|
37
|
-
export function PanelHeader({ title, description, breadcrumbs, actions }) {
|
|
38
|
-
const slots = React.useContext(PanelHeaderContext);
|
|
39
|
-
const text = _jsx(TitleBlock, { title: title, description: description, breadcrumbs: breadcrumbs });
|
|
40
|
-
if (slots?.titleNode) {
|
|
41
|
-
return (_jsxs(_Fragment, { children: [createPortal(text, slots.titleNode), actions != null && slots.actionsNode && createPortal(actions, slots.actionsNode)] }));
|
|
42
|
-
}
|
|
43
|
-
// Under a provider the header belongs in the bar: on the first commit the bar's regions are not set yet and
|
|
44
|
-
// they arrive in the same layout pass, so nothing paints without it. A provider must always render a
|
|
45
|
-
// PanelHeaderBar; without one the header shows nowhere, as with the old slots.
|
|
46
|
-
if (slots)
|
|
47
|
-
return null;
|
|
48
|
-
return (_jsxs("div", { "data-slot": "panel-header-inline", className: "mb-ds-300 flex flex-col gap-ds-150 sm:flex-row sm:items-center sm:justify-between", children: [text, actions != null && _jsx("div", { "data-slot": "panel-header-inline-actions", className: "flex shrink-0 flex-wrap items-center gap-ds-100", children: actions })] }));
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=panel-header.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"panel-header.js","sourceRoot":"","sources":["../../src/navigation/panel-header.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAC;AASjE,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAAe,IAAI,CAAC,CAAC;AAEnE;;;GAGG;AACH,MAAM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n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { Button } from \"../action/button\";\nimport { Heading, Text } from \"../display/typography\";\nimport { Breadcrumbs, type BreadcrumbItem } from \"./breadcrumbs\";\n\ntype Slots = {\n titleNode: HTMLElement | null;\n actionsNode: HTMLElement | null;\n setTitleNode: (node: HTMLElement | null) => void;\n setActionsNode: (node: HTMLElement | null) => void;\n};\n\nconst PanelHeaderContext = React.createContext<Slots | null>(null);\n\n/**\n * Owns the bar's two regions. It sits above both the bar and the page, because the shell renders them as\n * siblings: the bar outside the scrolling box (so content never runs under it) and the page inside it.\n */\nexport function PanelHeaderProvider({ children }: { children: React.ReactNode }) {\n const [titleNode, setTitleNode] = React.useState<HTMLElement | null>(null);\n const [actionsNode, setActionsNode] = React.useState<HTMLElement | null>(null);\n const value = React.useMemo(() => ({ titleNode, actionsNode, setTitleNode, setActionsNode }), [titleNode, actionsNode]);\n return <PanelHeaderContext.Provider value={value}>{children}</PanelHeaderContext.Provider>;\n}\n\nexport type PanelHeaderBarProps = {\n /** The menu button's name (\"Open menu\"); it opens the Sidebar, which is a panel under 1024px. */\n menuLabel: string;\n onMenuPress: () => void;\n};\n\n/**\n * The panel's top bar (admin apps): the menu button under 1024px, then the page's title and its\n * actions, which the page passes through `PanelHeader`. The shell renders it outside the box that scrolls.\n * Below 640px the actions take their own row, so a search field and a primary button never squeeze the title.\n */\nexport function PanelHeaderBar({ menuLabel, onMenuPress }: PanelHeaderBarProps) {\n const slots = React.useContext(PanelHeaderContext);\n return (\n <header\n data-slot=\"panel-header-bar\"\n className=\"flex shrink-0 flex-col gap-ds-100 border-b border-ds-border bg-ds-surface px-ds-200 py-ds-100 sm:min-h-16 sm:flex-row sm:items-center sm:justify-between sm:gap-ds-150 sm:px-ds-400\"\n >\n <div className=\"flex min-w-0 flex-1 items-center gap-ds-150\">\n <span data-slot=\"panel-header-menu\" className=\"flex lg:hidden\">\n <Button variant=\"subtle\" iconOnly iconBefore=\"menu\" aria-label={menuLabel} onPress={onMenuPress} />\n </span>\n <div ref={slots?.setTitleNode} data-slot=\"panel-header-title\" className=\"min-w-0 flex-1\" />\n </div>\n {/* Hidden while empty, so a page without actions pays no gap for them. */}\n <div\n ref={slots?.setActionsNode}\n data-slot=\"panel-header-actions\"\n className=\"flex shrink-0 flex-wrap items-center gap-ds-100 empty:hidden sm:flex-nowrap sm:justify-end\"\n />\n </header>\n );\n}\n\nexport type PanelHeaderProps = {\n /** The page's name; the page's one h1. */\n title: React.ReactNode;\n /** One line under the title. */\n description?: React.ReactNode;\n /** Where the page sits, above the title (a detail page under its list). */\n breadcrumbs?: readonly BreadcrumbItem[];\n /** The page's actions: filters, a search field, one primary button. */\n actions?: React.ReactNode;\n};\n\nfunction TitleBlock({ title, description, breadcrumbs }: Omit<PanelHeaderProps, \"actions\">) {\n return (\n <div data-slot=\"panel-header-text\" className=\"flex min-w-0 flex-col gap-ds-025\">\n {breadcrumbs && breadcrumbs.length > 0 && <Breadcrumbs items={breadcrumbs} />}\n <Heading level={1} size=\"heading-medium\">{title}</Heading>\n {description != null && (\n <Text size=\"body-small\" tone=\"subtle\" elementType=\"p\">{description}</Text>\n )}\n </div>\n );\n}\n\n/**\n * A panel page's header: the page says what it is and what it can do, and the\n * shell's `PanelHeaderBar` shows it, outside the scrolling content. Outside a `PanelHeaderProvider` (a page\n * rendered on its own, a test), it renders in place, so such a page keeps its title. A provider must always\n * render a bar.\n */\nexport function PanelHeader({ title, description, breadcrumbs, actions }: PanelHeaderProps) {\n const slots = React.useContext(PanelHeaderContext);\n const text = <TitleBlock title={title} description={description} breadcrumbs={breadcrumbs} />;\n if (slots?.titleNode) {\n return (\n <>\n {createPortal(text, slots.titleNode)}\n {actions != null && slots.actionsNode && createPortal(actions, slots.actionsNode)}\n </>\n );\n }\n // Under a provider the header belongs in the bar: on the first commit the bar's regions are not set yet and\n // they arrive in the same layout pass, so nothing paints without it. A provider must always render a\n // PanelHeaderBar; without one the header shows nowhere, as with the old slots.\n if (slots) return null;\n return (\n <div data-slot=\"panel-header-inline\" className=\"mb-ds-300 flex flex-col gap-ds-150 sm:flex-row sm:items-center sm:justify-between\">\n {text}\n {actions != null && <div data-slot=\"panel-header-inline-actions\" className=\"flex shrink-0 flex-wrap items-center gap-ds-100\">{actions}</div>}\n </div>\n );\n}\n"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export type ToolbarProps = {
|
|
3
|
-
/** Compact (32px) controls acting on the view below: search, filters, date range, view switch, export. */
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
/** Names the toolbar ("Order tools"). */
|
|
6
|
-
"aria-label": string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Controls that act on the view below it. One Tab stop: arrow keys move between the controls (mirrored
|
|
10
|
-
* in RTL). Put a `ToolbarSpacer` before the view and export controls to push them to the end.
|
|
11
|
-
* A text-editing control inside (a SearchField's input, a DateField's segments) keeps ←/→ for its caret
|
|
12
|
-
* and segments; at its edge (the caret at the start or end, the first or last segment) the arrow moves on
|
|
13
|
-
* to the next control, so every control stays reachable by the arrows. Arrowing into a date or time field
|
|
14
|
-
* lands on the segment nearest the way in: in RTL the visually nearest one, whatever the DOM order of its
|
|
15
|
-
* segments. A raw `type="number"` or
|
|
16
|
-
* `type="email"` input with a value has no readable caret and keeps ←/→ (Tab leaves it); prefer NumberField,
|
|
17
|
-
* or TextField with `inputMode`, inside a toolbar.
|
|
18
|
-
*/
|
|
19
|
-
export declare function Toolbar({ children, "aria-label": label }: ToolbarProps): React.JSX.Element;
|
|
20
|
-
/** Pushes the controls after it to the toolbar's end. */
|
|
21
|
-
export declare function ToolbarSpacer(): React.JSX.Element;
|
|
22
|
-
export type BulkBarProps = {
|
|
23
|
-
/** How many rows are selected; announced as it changes. */
|
|
24
|
-
selectedCount: number;
|
|
25
|
-
/** The bulk actions (compact Buttons): "Send reminder", "Export". */
|
|
26
|
-
actions: React.ReactNode;
|
|
27
|
-
/** Clears the selection; the bar goes with it. */
|
|
28
|
-
onClear: () => void;
|
|
29
|
-
/** Names the bar ("Selected orders"). */
|
|
30
|
-
"aria-label": string;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Replaces the toolbar while rows are selected: the count, the bulk actions and a clear button, on
|
|
34
|
-
* `ds-background-neutral-bold`. One Tab stop with arrow keys inside, like the toolbar. Buttons in the bar
|
|
35
|
-
* are drawn transparent with inverse text whatever their variant: pass default (not primary) actions.
|
|
36
|
-
*/
|
|
37
|
-
export declare function BulkBar({ selectedCount, actions, onClear, "aria-label": label }: BulkBarProps): React.JSX.Element;
|