@senvenli/react 0.3.2 → 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/manifests/data-table.json +1 -1
- package/manifests/index.json +2 -1
- package/manifests/sidebar.json +55 -2
- package/manifests/table.json +2 -2
- 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
|
@@ -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,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC;IACpF,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,cAAc,CAAC,MAAc,EAAE,QAAgB;IACtD,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACjC,MAAM,EAAE,GAAG,Q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AY,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 @@
|
|
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,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,UAAU,mBAAmB,CAAC,EAAE,QAAQ,EAAiC;IAC7E,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,IAAI,CAAC,CAAC;IAC3E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,IAAI,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,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IAAI,EAAC,QAAQ,EAAC,WAAW,EAAC,GAAG,YAAE,WAAW,GAAQ,CAC3E,IACG,CACP,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAoB;IACxF,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,KAAC,UAAU,IAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAI,CAAC;IAC9F,IAAI,KAAK,EAAE,SAAS,EAAE,CAAC;QACrB,OAAO,CACL,8BACG,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,EACnC,OAAO,IAAI,IAAI,IAAI,KAAK,CAAC,WAAW,IAAI,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,IAChF,CACJ,CAAC;IACJ,CAAC;IACD,4GAA4G;IAC5G,qGAAqG;IACrG,+EAA+E;IAC/E,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACL,4BAAe,qBAAqB,EAAC,SAAS,EAAC,mFAAmF,aAC/H,IAAI,EACJ,OAAO,IAAI,IAAI,IAAI,2BAAe,6BAA6B,EAAC,SAAS,EAAC,iDAAiD,YAAE,OAAO,GAAO,IACxI,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\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;
|