@xds/core 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/banner.d.ts +4 -1
- package/dist/breadcrumb.d.ts +39 -0
- package/dist/breadcrumb.js +7 -0
- package/dist/checkbox.d.ts +20 -3
- package/dist/checkbox.js +3 -1
- package/dist/combobox.d.ts +59 -0
- package/dist/combobox.js +40 -0
- package/dist/date-picker.d.ts +10 -4
- package/dist/date-picker.js +5 -4
- package/dist/date-range-picker.d.ts +10 -4
- package/dist/date-range-picker.js +9 -8
- package/dist/index.d.ts +17 -6
- package/dist/index.js +16 -5
- package/dist/labels.d.ts +34 -0
- package/dist/labels.js +26 -0
- package/dist/link.d.ts +49 -0
- package/dist/link.js +12 -0
- package/dist/pagination.d.ts +51 -0
- package/dist/pagination.js +25 -0
- package/dist/popover.d.ts +33 -0
- package/dist/popover.js +8 -0
- package/dist/preview/components.d.ts +71 -17
- package/dist/preview/components.js +1 -0
- package/dist/preview/design.d.ts +22 -3
- package/dist/preview/design.js +65 -34
- package/dist/preview/fixtures.d.ts +0 -76
- package/dist/preview/fixtures.js +0 -126
- package/dist/preview/kit.d.ts +48 -32
- package/dist/preview/kit.js +3 -0
- package/dist/preview/page.d.ts +1 -1
- package/dist/preview/page.js +1 -0
- package/dist/preview/sections/accordion.d.ts +1 -0
- package/dist/preview/sections/accordion.js +40 -0
- package/dist/preview/sections/badges.d.ts +1 -0
- package/dist/preview/sections/badges.js +13 -0
- package/dist/preview/sections/banners.d.ts +1 -0
- package/dist/preview/sections/banners.js +13 -0
- package/dist/preview/sections/buttons.d.ts +2 -0
- package/dist/preview/sections/buttons.js +30 -0
- package/dist/preview/sections/card.d.ts +1 -0
- package/dist/preview/sections/card.js +33 -0
- package/dist/preview/sections/chips.d.ts +1 -0
- package/dist/preview/sections/chips.js +23 -0
- package/dist/preview/sections/controls.d.ts +1 -0
- package/dist/preview/sections/controls.js +143 -0
- package/dist/preview/sections/dialog.d.ts +1 -0
- package/dist/preview/sections/dialog.js +25 -0
- package/dist/preview/sections/empty-state.d.ts +1 -0
- package/dist/preview/sections/empty-state.js +13 -0
- package/dist/preview/sections/links.d.ts +1 -0
- package/dist/preview/sections/links.js +8 -0
- package/dist/preview/sections/list.d.ts +1 -0
- package/dist/preview/sections/list.js +119 -0
- package/dist/preview/sections/media.d.ts +1 -0
- package/dist/preview/sections/media.js +90 -0
- package/dist/preview/sections/menu.d.ts +1 -0
- package/dist/preview/sections/menu.js +46 -0
- package/dist/preview/sections/navigation.d.ts +1 -0
- package/dist/preview/sections/navigation.js +20 -0
- package/dist/preview/sections/selection.d.ts +1 -0
- package/dist/preview/sections/selection.js +33 -0
- package/dist/preview/sections/sidebar.d.ts +1 -0
- package/dist/preview/sections/sidebar.js +45 -0
- package/dist/preview/sections/skeleton.d.ts +1 -0
- package/dist/preview/sections/skeleton.js +5 -0
- package/dist/preview/sections/tabs.d.ts +1 -0
- package/dist/preview/sections/tabs.js +24 -0
- package/dist/preview/sections/text-fields.d.ts +1 -0
- package/dist/preview/sections/text-fields.js +75 -0
- package/dist/preview/sections/toast.d.ts +2 -0
- package/dist/preview/sections/toast.js +28 -0
- package/dist/preview/specimens.js +1 -1
- package/dist/progress-bar.d.ts +7 -4
- package/dist/progress-bar.js +2 -2
- package/dist/radio-group.d.ts +7 -1
- package/dist/root.d.ts +25 -0
- package/dist/root.js +25 -0
- package/dist/rows.d.ts +23 -0
- package/dist/rows.js +67 -0
- package/dist/segmented-control.d.ts +5 -2
- package/dist/segmented-control.js +1 -1
- package/dist/select.d.ts +29 -1
- package/dist/select.js +7 -0
- package/dist/slider.d.ts +4 -1
- package/dist/switch.d.ts +5 -2
- package/dist/switch.js +2 -1
- package/dist/table.d.ts +62 -0
- package/dist/table.js +25 -0
- package/dist/tabs.d.ts +4 -2
- package/dist/text-field.d.ts +19 -3
- package/dist/theme-scope.d.ts +6 -4
- package/dist/theme-scope.js +21 -15
- package/dist/time-picker.d.ts +57 -0
- package/dist/time-picker.js +53 -0
- package/dist/toast-queue.d.ts +40 -0
- package/dist/toast-queue.js +17 -0
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +1 -1
- package/package.json +2 -2
- package/dist/preview/sections.d.ts +0 -20
- package/dist/preview/sections.js +0 -517
package/dist/banner.d.ts
CHANGED
|
@@ -25,7 +25,10 @@ export type BannerTone = keyof typeof TONE;
|
|
|
25
25
|
export type BannerBaseProps = {
|
|
26
26
|
tone?: BannerTone;
|
|
27
27
|
title?: string;
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Names the close control for assistive technology. The `dismiss` label of a `Labels` provider
|
|
30
|
+
* unless set.
|
|
31
|
+
*/
|
|
29
32
|
dismissLabel?: string;
|
|
30
33
|
};
|
|
31
34
|
export declare function bannerClass(tone?: BannerTone): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** One place of a Breadcrumb's trail. */
|
|
2
|
+
export type BreadcrumbItem = {
|
|
3
|
+
label: string;
|
|
4
|
+
/** The address the place's link opens. Leave it out for one that only calls `onPress`. */
|
|
5
|
+
href?: string;
|
|
6
|
+
/** Called when the place's link is pressed, before the browser follows `href`. */
|
|
7
|
+
onPress?: () => void;
|
|
8
|
+
};
|
|
9
|
+
/** Breadcrumb's props in every framework. */
|
|
10
|
+
export type BreadcrumbBaseProps = {
|
|
11
|
+
/**
|
|
12
|
+
* The places from the top of the app down to the current one, which is the last. Every place
|
|
13
|
+
* but the last is a link; the last is where the person is, and is not.
|
|
14
|
+
*/
|
|
15
|
+
items: readonly BreadcrumbItem[];
|
|
16
|
+
/**
|
|
17
|
+
* Names the trail's navigation landmark for assistive technology: `breadcrumb` from the
|
|
18
|
+
* closest `Labels`, "Breadcrumb" in English, unless it is given.
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The classes of a Breadcrumb's parts beside its root, `xds-breadcrumb`, a `<nav>`: the list,
|
|
24
|
+
* one item per place, the chevron between two places, and the current place.
|
|
25
|
+
*/
|
|
26
|
+
export declare const BREADCRUMB_PARTS: {
|
|
27
|
+
readonly list: "xds-breadcrumb__list";
|
|
28
|
+
readonly item: "xds-breadcrumb__item";
|
|
29
|
+
readonly separator: "xds-breadcrumb__separator";
|
|
30
|
+
readonly current: "xds-breadcrumb__current";
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The chevron between two places. `xs` sits on the line of detail text, the trail's type, and
|
|
34
|
+
* the chevron points onward, so it mirrors in a right-to-left layout.
|
|
35
|
+
*/
|
|
36
|
+
export declare const BREADCRUMB_SEPARATOR: {
|
|
37
|
+
readonly name: "chevron-right";
|
|
38
|
+
readonly size: "xs";
|
|
39
|
+
};
|
package/dist/checkbox.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
export { switchClass as checkboxClass, switchLabelClass as checkboxLabelClass } from "./switch.ts";
|
|
2
2
|
/** Checkbox's props in every framework, short of `onChange`. */
|
|
3
3
|
export type CheckboxBaseProps = {
|
|
4
|
-
|
|
4
|
+
/** Leave it out for a checkbox that keeps its own state, from `defaultChecked`. */
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
/** Whether a checkbox that keeps its own state starts checked. */
|
|
7
|
+
defaultChecked?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Shows a dash in place of the check and reports the checkbox as mixed, whatever `checked`
|
|
10
|
+
* is: a checkbox for a group of which some are checked. The app keeps it: a press still
|
|
11
|
+
* reports the opposite of `checked`, and the app clears it in `onChange`. Leave `checked`
|
|
12
|
+
* false with it, so that a press checks the whole group.
|
|
13
|
+
*/
|
|
14
|
+
indeterminate?: boolean;
|
|
5
15
|
/** Shown beside the box. Pressing it toggles too. */
|
|
6
16
|
label?: string;
|
|
7
17
|
/** Names the checkbox for assistive technology when there is no visible label. */
|
|
@@ -13,8 +23,15 @@ export type CheckboxBaseProps = {
|
|
|
13
23
|
* The box, drawn beside the hidden input. The outline is what makes an empty box visible; a
|
|
14
24
|
* filled one does not need it.
|
|
15
25
|
*/
|
|
16
|
-
export declare const checkboxBoxClass = "flex size-xds-checkbox shrink-0 items-center justify-center rounded-xds-sm border-2 border-xds-checkbox-border text-xds-checkbox-mark peer-checked:border-0 peer-checked:bg-xds-checkbox-background-checked peer-disabled:border-0 peer-disabled:bg-xds-checkbox-disabled-background peer-disabled:text-xds-checkbox-disabled-mark *:opacity-0 peer-checked:*:opacity-100 peer-focus-visible:outline-solid peer-focus-visible:outline-(length:--xds-focus-width) peer-focus-visible:outline-offset-(--xds-focus-offset) peer-focus-visible:outline-xds-border-focus";
|
|
17
|
-
/** The
|
|
26
|
+
export declare const checkboxBoxClass = "flex size-xds-checkbox shrink-0 items-center justify-center rounded-xds-sm border-2 border-xds-checkbox-border text-xds-checkbox-mark peer-checked:border-0 peer-checked:bg-xds-checkbox-background-checked peer-indeterminate:border-0 peer-indeterminate:bg-xds-checkbox-background-checked peer-disabled:border-0 peer-disabled:bg-xds-checkbox-disabled-background peer-disabled:text-xds-checkbox-disabled-mark *:opacity-0 peer-checked:*:opacity-100 peer-indeterminate:*:opacity-100 forced-colors:peer-checked:bg-[Highlight] forced-colors:peer-checked:text-[HighlightText] forced-colors:peer-indeterminate:bg-[Highlight] forced-colors:peer-indeterminate:text-[HighlightText] forced-colors:peer-disabled:border-2 forced-colors:peer-disabled:border-[GrayText] forced-colors:peer-disabled:text-[GrayText] peer-focus-visible:outline-solid peer-focus-visible:outline-(length:--xds-focus-width) peer-focus-visible:outline-offset-(--xds-focus-offset) peer-focus-visible:outline-xds-border-focus";
|
|
27
|
+
/** The mark inside the box: a 16 by 16 path, `checkboxMark()`. */
|
|
18
28
|
export declare const checkboxMarkClass = "size-3/4";
|
|
19
29
|
/** The path of the check mark, in a `0 0 16 16` view box. */
|
|
20
30
|
export declare const CHECKBOX_MARK = "m3.5 8.5 3 3 6-7";
|
|
31
|
+
/** The path of the dash of an indeterminate checkbox, in the check mark's view box. */
|
|
32
|
+
export declare const CHECKBOX_DASH = "M4 8h8";
|
|
33
|
+
/**
|
|
34
|
+
* The path a checkbox draws: the dash while it is indeterminate, the check otherwise. The box
|
|
35
|
+
* shows it while the native input is checked or indeterminate.
|
|
36
|
+
*/
|
|
37
|
+
export declare const checkboxMark: (indeterminate: boolean | undefined) => "M4 8h8" | "m3.5 8.5 3 3 6-7";
|
package/dist/checkbox.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PEER_FOCUS } from "./switch.js";
|
|
2
2
|
export { switchClass as checkboxClass, switchLabelClass as checkboxLabelClass } from "./switch.js";
|
|
3
|
-
export const checkboxBoxClass = `flex size-xds-checkbox shrink-0 items-center justify-center rounded-xds-sm border-2 border-xds-checkbox-border text-xds-checkbox-mark peer-checked:border-0 peer-checked:bg-xds-checkbox-background-checked peer-disabled:border-0 peer-disabled:bg-xds-checkbox-disabled-background peer-disabled:text-xds-checkbox-disabled-mark *:opacity-0 peer-checked:*:opacity-100 ${PEER_FOCUS}`;
|
|
3
|
+
export const checkboxBoxClass = `flex size-xds-checkbox shrink-0 items-center justify-center rounded-xds-sm border-2 border-xds-checkbox-border text-xds-checkbox-mark peer-checked:border-0 peer-checked:bg-xds-checkbox-background-checked peer-indeterminate:border-0 peer-indeterminate:bg-xds-checkbox-background-checked peer-disabled:border-0 peer-disabled:bg-xds-checkbox-disabled-background peer-disabled:text-xds-checkbox-disabled-mark *:opacity-0 peer-checked:*:opacity-100 peer-indeterminate:*:opacity-100 forced-colors:peer-checked:bg-[Highlight] forced-colors:peer-checked:text-[HighlightText] forced-colors:peer-indeterminate:bg-[Highlight] forced-colors:peer-indeterminate:text-[HighlightText] forced-colors:peer-disabled:border-2 forced-colors:peer-disabled:border-[GrayText] forced-colors:peer-disabled:text-[GrayText] ${PEER_FOCUS}`;
|
|
4
4
|
export const checkboxMarkClass = "size-3/4";
|
|
5
5
|
export const CHECKBOX_MARK = "m3.5 8.5 3 3 6-7";
|
|
6
|
+
export const CHECKBOX_DASH = "M4 8h8";
|
|
7
|
+
export const checkboxMark = (indeterminate) => indeterminate ? CHECKBOX_DASH : CHECKBOX_MARK;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { SelectOption } from "./select.ts";
|
|
2
|
+
/** Combobox's props in every framework, short of `onChange`. */
|
|
3
|
+
export type ComboboxBaseProps<Value extends string = string> = {
|
|
4
|
+
/** Always visible, like a TextField's. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The options to choose from, which what the person types narrows down. */
|
|
7
|
+
options: readonly SelectOption<Value>[];
|
|
8
|
+
/**
|
|
9
|
+
* The chosen option, `undefined` while nothing is chosen. Leave it out for a combobox that
|
|
10
|
+
* keeps its own choice, from `defaultValue`: it is controlled whenever `value` is given, even
|
|
11
|
+
* as `undefined`.
|
|
12
|
+
*/
|
|
13
|
+
value?: Value | undefined;
|
|
14
|
+
/** The first choice of a combobox that keeps its own, without `value`. */
|
|
15
|
+
defaultValue?: Value | undefined;
|
|
16
|
+
/** Shown in the field while it is empty. */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/** Help shown under the field. Replaced by `error` while there is one. */
|
|
19
|
+
description?: string;
|
|
20
|
+
/** What is wrong and how to fix it. Clear it when the choice changes. */
|
|
21
|
+
error?: string | undefined;
|
|
22
|
+
/** The name the choice is submitted under with a form. */
|
|
23
|
+
name?: string;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Said in the list when no option matches what was typed, in place of `noMatches` from the
|
|
27
|
+
* closest Labels.
|
|
28
|
+
*/
|
|
29
|
+
emptyLabel?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const COMBOBOX_PARTS: {
|
|
32
|
+
readonly label: "xds-combobox__label";
|
|
33
|
+
readonly control: "xds-combobox__control";
|
|
34
|
+
readonly input: "xds-combobox__input";
|
|
35
|
+
readonly icon: "xds-combobox__icon";
|
|
36
|
+
readonly footer: "xds-combobox__footer";
|
|
37
|
+
readonly description: "xds-combobox__description";
|
|
38
|
+
readonly error: "xds-combobox__error";
|
|
39
|
+
readonly positioner: "xds-combobox__positioner";
|
|
40
|
+
readonly content: "xds-combobox__content";
|
|
41
|
+
readonly list: "xds-combobox__list";
|
|
42
|
+
readonly item: "xds-combobox__item";
|
|
43
|
+
readonly itemWords: "xds-combobox__item-words";
|
|
44
|
+
readonly itemLabel: "xds-combobox__item-label";
|
|
45
|
+
readonly itemDescription: "xds-combobox__item-description";
|
|
46
|
+
readonly empty: "xds-combobox__empty";
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Text as a combobox compares it: in lower case, without accents and with runs of white space
|
|
50
|
+
* as one, so that "sao paulo" finds "São Paulo".
|
|
51
|
+
*/
|
|
52
|
+
export declare function foldText(text: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* The options whose label holds what was typed, in their own order, those whose label starts
|
|
55
|
+
* with it first. With nothing typed, every option.
|
|
56
|
+
*/
|
|
57
|
+
export declare function matchOptions<Option extends {
|
|
58
|
+
label: string;
|
|
59
|
+
}>(options: readonly Option[], query: string): Option[];
|
package/dist/combobox.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const COMBOBOX_PARTS = {
|
|
2
|
+
label: "xds-combobox__label",
|
|
3
|
+
control: "xds-combobox__control",
|
|
4
|
+
input: "xds-combobox__input",
|
|
5
|
+
icon: "xds-combobox__icon",
|
|
6
|
+
footer: "xds-combobox__footer",
|
|
7
|
+
description: "xds-combobox__description",
|
|
8
|
+
error: "xds-combobox__error",
|
|
9
|
+
positioner: "xds-combobox__positioner",
|
|
10
|
+
content: "xds-combobox__content",
|
|
11
|
+
list: "xds-combobox__list",
|
|
12
|
+
item: "xds-combobox__item",
|
|
13
|
+
itemWords: "xds-combobox__item-words",
|
|
14
|
+
itemLabel: "xds-combobox__item-label",
|
|
15
|
+
itemDescription: "xds-combobox__item-description",
|
|
16
|
+
empty: "xds-combobox__empty",
|
|
17
|
+
};
|
|
18
|
+
export function foldText(text) {
|
|
19
|
+
return text
|
|
20
|
+
.normalize("NFD")
|
|
21
|
+
.replace(/\p{Diacritic}/gu, "")
|
|
22
|
+
.toLocaleLowerCase()
|
|
23
|
+
.replace(/\s+/g, " ")
|
|
24
|
+
.trim();
|
|
25
|
+
}
|
|
26
|
+
export function matchOptions(options, query) {
|
|
27
|
+
const wanted = foldText(query);
|
|
28
|
+
if (wanted === "")
|
|
29
|
+
return [...options];
|
|
30
|
+
const starting = [];
|
|
31
|
+
const holding = [];
|
|
32
|
+
for (const option of options) {
|
|
33
|
+
const label = foldText(option.label);
|
|
34
|
+
if (label.startsWith(wanted))
|
|
35
|
+
starting.push(option);
|
|
36
|
+
else if (label.includes(wanted))
|
|
37
|
+
holding.push(option);
|
|
38
|
+
}
|
|
39
|
+
return [...starting, ...holding];
|
|
40
|
+
}
|
package/dist/date-picker.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DateValue } from "@internationalized/date";
|
|
2
2
|
import type * as datePicker from "@zag-js/date-picker";
|
|
3
|
+
import { type ComponentLabels } from "./labels.ts";
|
|
3
4
|
/** A day of the calendar without a time or a time zone, as `YYYY-MM-DD`. */
|
|
4
5
|
export type IsoDate = string;
|
|
5
6
|
/** DatePicker's props in every framework, short of `onChange`. */
|
|
@@ -21,9 +22,12 @@ export type DatePickerBaseProps = {
|
|
|
21
22
|
/** The name the day is submitted under with a form, as `YYYY-MM-DD`. */
|
|
22
23
|
name?: string;
|
|
23
24
|
disabled?: boolean;
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Names the calendar's button to the month before, for assistive technology. The
|
|
27
|
+
* `previousMonth` label of a `Labels` provider unless set.
|
|
28
|
+
*/
|
|
25
29
|
previousLabel?: string;
|
|
26
|
-
/** Names the
|
|
30
|
+
/** Names the button to the month after, as `previousLabel` does, from `nextMonth`. */
|
|
27
31
|
nextLabel?: string;
|
|
28
32
|
/** Formats dates and calendar headings in a fixed locale (avoids SSR locale mismatches). */
|
|
29
33
|
locale?: string;
|
|
@@ -67,15 +71,17 @@ export declare function datePickerMachineProps(props: DatePickerBaseProps, optio
|
|
|
67
71
|
locale: string;
|
|
68
72
|
onChange: (value: IsoDate) => void;
|
|
69
73
|
gutter?: number;
|
|
74
|
+
/** The labels of the closest `Labels` provider, for those the props leave out. */
|
|
75
|
+
labels?: ComponentLabels;
|
|
70
76
|
}): datePicker.Props;
|
|
71
77
|
/**
|
|
72
78
|
* Zag's strings that the calendar shows assistive technology. A day is named by its long
|
|
73
79
|
* localized name alone ("Tuesday, March 10, 2026"): its grid cell says whether it is selected
|
|
74
80
|
* and whether it is today, where Zag would add English words for both. The month buttons take
|
|
75
|
-
* `previousLabel` and `nextLabel
|
|
81
|
+
* `previousLabel` and `nextLabel`, or else the `labels` of a provider. Zag's other strings name parts that are not drawn, or whose
|
|
76
82
|
* names `datePickerTriggerAttrs` and `datePickerContentAttrs` replace.
|
|
77
83
|
*/
|
|
78
|
-
export declare function datePickerTranslations(props: Pick<DatePickerBaseProps, "previousLabel" | "nextLabel"
|
|
84
|
+
export declare function datePickerTranslations(props: Pick<DatePickerBaseProps, "previousLabel" | "nextLabel">, labels?: ComponentLabels): datePicker.IntlTranslations;
|
|
79
85
|
/**
|
|
80
86
|
* Spread over Zag's props of the field, the trigger, after them: a button that says it opens a
|
|
81
87
|
* dialog, the calendar, named by the chosen day (or the placeholder) and then the label, as a
|
package/dist/date-picker.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { space } from "@xds/tokens";
|
|
2
2
|
import { getLocalTimeZone, parseDate, today } from "@internationalized/date";
|
|
3
3
|
import { buttonClass } from "./button.js";
|
|
4
|
+
import { DEFAULT_LABELS } from "./labels.js";
|
|
4
5
|
export function parseIsoDate(value) {
|
|
5
6
|
if (value === undefined || !/^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
6
7
|
return undefined;
|
|
@@ -67,14 +68,14 @@ export function datePickerMachineProps(props, options) {
|
|
|
67
68
|
minView: "day",
|
|
68
69
|
maxView: "day",
|
|
69
70
|
positioning: { placement: "bottom-start", gutter: options.gutter ?? space[1] },
|
|
70
|
-
translations: datePickerTranslations(props),
|
|
71
|
+
translations: datePickerTranslations(props, options.labels),
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
export function datePickerTranslations(props) {
|
|
74
|
+
export function datePickerTranslations(props, labels = DEFAULT_LABELS) {
|
|
74
75
|
return {
|
|
75
76
|
dayCell: (state) => state.valueText,
|
|
76
|
-
previousTrigger: () => props.previousLabel ??
|
|
77
|
-
nextTrigger: () => props.nextLabel ??
|
|
77
|
+
previousTrigger: () => props.previousLabel ?? labels.previousMonth,
|
|
78
|
+
nextTrigger: () => props.nextLabel ?? labels.nextMonth,
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
81
|
export function datePickerTriggerAttrs(props, ids) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DateValue } from "@internationalized/date";
|
|
2
2
|
import type * as datePicker from "@zag-js/date-picker";
|
|
3
3
|
import { type DatePickerBaseProps, type IsoDate } from "./date-picker.ts";
|
|
4
|
+
import { type ComponentLabels } from "./labels.ts";
|
|
4
5
|
/** The first and the last day of a range, both chosen, `start` no later than `end`. */
|
|
5
6
|
export type DateRange = {
|
|
6
7
|
start: IsoDate;
|
|
@@ -21,9 +22,12 @@ export type DateRangePickerBaseProps = Omit<DatePickerBaseProps, "value" | "name
|
|
|
21
22
|
startName?: string;
|
|
22
23
|
/** The name the last day is submitted under with a form, as `YYYY-MM-DD`. */
|
|
23
24
|
endName?: string;
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Names the first day in the calendar's summary and for assistive technology. The `start`
|
|
27
|
+
* label of a `Labels` provider unless set.
|
|
28
|
+
*/
|
|
25
29
|
startLabel?: string;
|
|
26
|
-
/** Names the last day, as `startLabel` does the first
|
|
30
|
+
/** Names the last day, as `startLabel` does the first, from `end`. */
|
|
27
31
|
endLabel?: string;
|
|
28
32
|
};
|
|
29
33
|
/**
|
|
@@ -68,17 +72,19 @@ export declare function dateRangeMachineProps(props: DateRangePickerBaseProps, s
|
|
|
68
72
|
onDraft: (draft: RangeDraft | null) => void;
|
|
69
73
|
onChange: (value: DateRange) => void;
|
|
70
74
|
gutter?: number;
|
|
75
|
+
/** The labels of the closest `Labels` provider, for those the props leave out. */
|
|
76
|
+
labels?: ComponentLabels;
|
|
71
77
|
}): datePicker.Props;
|
|
72
78
|
/**
|
|
73
79
|
* DatePicker's strings, with the two ends named by `startLabel` and `endLabel` ahead of the
|
|
74
80
|
* day: "Check-in, Tuesday, March 10, 2026". A range of one day is both.
|
|
75
81
|
*/
|
|
76
|
-
export declare function dateRangeTranslations(props: Pick<DateRangePickerBaseProps, "previousLabel" | "nextLabel" | "startLabel" | "endLabel"
|
|
82
|
+
export declare function dateRangeTranslations(props: Pick<DateRangePickerBaseProps, "previousLabel" | "nextLabel" | "startLabel" | "endLabel">, labels?: ComponentLabels): datePicker.IntlTranslations;
|
|
77
83
|
/**
|
|
78
84
|
* The summary above the months: each end after its label, or a dash until it is chosen.
|
|
79
85
|
* "Check-in: Mar 20, 2026", "Check-out: –".
|
|
80
86
|
*/
|
|
81
|
-
export declare function rangeSummary(shown: RangeDraft, props: Pick<DateRangePickerBaseProps, "startLabel" | "endLabel">, locale: string): {
|
|
87
|
+
export declare function rangeSummary(shown: RangeDraft, props: Pick<DateRangePickerBaseProps, "startLabel" | "endLabel">, locale: string, labels?: ComponentLabels): {
|
|
82
88
|
start: string;
|
|
83
89
|
end: string;
|
|
84
90
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { space } from "@xds/tokens";
|
|
2
2
|
import { getLocalTimeZone, parseDate } from "@internationalized/date";
|
|
3
3
|
import { datePickerTranslations, formatDay, openingDay, parseIsoDate, } from "./date-picker.js";
|
|
4
|
+
import { DEFAULT_LABELS } from "./labels.js";
|
|
4
5
|
export function daysBetween(from, to) {
|
|
5
6
|
return Math.round((Date.parse(`${to}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`)) / 86_400_000);
|
|
6
7
|
}
|
|
@@ -67,25 +68,25 @@ export function dateRangeMachineProps(props, shown, options) {
|
|
|
67
68
|
minView: "day",
|
|
68
69
|
maxView: "day",
|
|
69
70
|
positioning: { placement: "bottom-start", gutter: options.gutter ?? space[1] },
|
|
70
|
-
translations: dateRangeTranslations(props),
|
|
71
|
+
translations: dateRangeTranslations(props, options.labels),
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
export function dateRangeTranslations(props) {
|
|
74
|
-
const start = props.startLabel ??
|
|
75
|
-
const end = props.endLabel ??
|
|
74
|
+
export function dateRangeTranslations(props, labels = DEFAULT_LABELS) {
|
|
75
|
+
const start = props.startLabel ?? labels.start;
|
|
76
|
+
const end = props.endLabel ?? labels.end;
|
|
76
77
|
return {
|
|
77
|
-
...datePickerTranslations(props),
|
|
78
|
+
...datePickerTranslations(props, labels),
|
|
78
79
|
dayCell: (state) => [state.firstInRange && start, state.lastInRange && end, state.valueText]
|
|
79
80
|
.filter(Boolean)
|
|
80
81
|
.join(", "),
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
|
-
export function rangeSummary(shown, props, locale) {
|
|
84
|
+
export function rangeSummary(shown, props, locale, labels = DEFAULT_LABELS) {
|
|
84
85
|
const [start, end] = shown;
|
|
85
86
|
const day = (value) => value === undefined ? "–" : formatDay(value, locale);
|
|
86
87
|
return {
|
|
87
|
-
start: `${props.startLabel ??
|
|
88
|
-
end: `${props.endLabel ??
|
|
88
|
+
start: `${props.startLabel ?? labels.start}: ${day(start)}`,
|
|
89
|
+
end: `${props.endLabel ?? labels.end}: ${day(end)}`,
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
92
|
export function rangeMonthViews(api, months) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export { ACCORDION_PARTS, type AccordionBaseProps, type AccordionItemBase, focusTitleOnClick, setPanelOpen, } from "./accordion.ts";
|
|
2
2
|
export { afterAnimations } from "./animation.ts";
|
|
3
|
-
export { AVATAR_SIZE, type AvatarBaseProps, type AvatarSize, avatarClass, avatarInitials, pictureClass, } from "./avatar.ts";
|
|
4
3
|
export { type AvatarStackBaseProps, avatarStack, avatarStackClass, avatarStackItemClass, avatarStackRestClass, } from "./avatar-stack.ts";
|
|
4
|
+
export { AVATAR_SIZE, type AvatarBaseProps, type AvatarSize, avatarClass, avatarInitials, pictureClass, } from "./avatar.ts";
|
|
5
5
|
export { type BadgeBaseProps, type BadgeTone, badgeClass, badgeDotClass } from "./badge.ts";
|
|
6
6
|
export { BANNER_PARTS, type BannerBaseProps, type BannerTone, bannerClass, bannerIconClass, bannerIconPath, bannerRole, } from "./banner.ts";
|
|
7
|
+
export { BREADCRUMB_PARTS, BREADCRUMB_SEPARATOR, type BreadcrumbBaseProps, type BreadcrumbItem, } from "./breadcrumb.ts";
|
|
7
8
|
export { BUTTON_ICON, type ButtonBaseProps, type ButtonVariant, buttonClass, type ControlSize, ICON_BUTTON_BOX, type IconButtonBaseProps, isHeld, } from "./button.ts";
|
|
8
9
|
export { CARD_PARTS, type CardBaseProps, cardClass, cardMediaClass } from "./card.ts";
|
|
9
|
-
export { CHECKBOX_MARK, type CheckboxBaseProps, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMarkClass, } from "./checkbox.ts";
|
|
10
|
-
export { type ChipBaseProps, chipClass, chipIcon } from "./chip.ts";
|
|
10
|
+
export { CHECKBOX_DASH, CHECKBOX_MARK, type CheckboxBaseProps, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMark, checkboxMarkClass, } from "./checkbox.ts";
|
|
11
11
|
export { type ChipBarBaseProps, chipBarClass } from "./chip-bar.ts";
|
|
12
|
+
export { type ChipBaseProps, chipClass, chipIcon } from "./chip.ts";
|
|
13
|
+
export { COMBOBOX_PARTS, type ComboboxBaseProps, foldText, matchOptions } from "./combobox.ts";
|
|
12
14
|
export { type CountBadgeBaseProps, countBadgeAnchorClass, countBadgeClass, countBadgeText, } from "./count-badge.ts";
|
|
13
15
|
export { clampDay, DATE_PICKER_NAV_CLASS, type DatePickerBaseProps, datePickerContentAttrs, datePickerIds, datePickerLocale, datePickerMachineProps, datePickerTranslations, datePickerTriggerAttrs, focusOpeningDay, formatDay, type IsoDate, keepCalendarFocus, keepDayFocused, openingDay, parseIsoDate, todayIso, } from "./date-picker.ts";
|
|
14
16
|
export { type DateRange, type DateRangePickerBaseProps, dateRangeMachineProps, dateRangeTranslations, daysBetween, endRangeChoiceOnClose, formatRange, keepRangePreview, type RangeDraft, type RangeMonth, rangeDayChoice, rangeDayClick, rangeGridKeyDown, rangeMonths, rangeMonthViews, rangeSummary, restartRange, shownRange, } from "./date-range-picker.ts";
|
|
@@ -20,25 +22,34 @@ export { leaveEscapeToFields } from "./escape.ts";
|
|
|
20
22
|
export { focusWithoutRing } from "./focus.ts";
|
|
21
23
|
export { type IconBaseProps, type IconName, type IconSize, iconClass } from "./icon.ts";
|
|
22
24
|
export { initials } from "./initials.ts";
|
|
25
|
+
export { type ComponentLabels, DEFAULT_LABELS, mergeLabels } from "./labels.ts";
|
|
26
|
+
export { LINK_ICON, LINK_PARTS, type LinkBaseProps, type LinkElement, linkElement, } from "./link.ts";
|
|
23
27
|
export { LIST_ROW_PARTS, type ListRowBaseProps, listRowClass, listRowDescriptionClass, listRowTitleClass, PRESSABLE_ROW, } from "./list-row.ts";
|
|
24
28
|
export { MEDIA_CARD_PARTS, type MediaCardBaseProps, type MediaCardLayout, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, } from "./media-card.ts";
|
|
25
29
|
export { firstMenuValue, layoutRect, type MenuBaseProps, type MenuItem, menuItemClass, opensOnPress, } from "./menu.ts";
|
|
26
30
|
export { keepListKeys, pageTarget } from "./page-keys.ts";
|
|
31
|
+
export { clampPage, PAGINATION_PARTS, PAGINATION_STEPS, type PaginationBaseProps, type PaginationEntry, paginationEntries, } from "./pagination.ts";
|
|
32
|
+
export { classes, rootPart } from "./parts.ts";
|
|
33
|
+
export { POPOVER_PARTS, type PopoverBaseProps } from "./popover.ts";
|
|
27
34
|
export { type ProgressBarBaseProps, progressBarClass, progressBarFillClass, progressPercent, } from "./progress-bar.ts";
|
|
28
35
|
export type { RadioGroupBaseProps, RadioOption } from "./radio-group.ts";
|
|
36
|
+
export { isControlled, onFormReset, type RootAttributes, rootAttributes } from "./root.ts";
|
|
37
|
+
export { createItemPropsCache, sameItemProps, sameRowProps } from "./rows.ts";
|
|
29
38
|
export { SECTION_HEADER_PARTS, type SectionHeaderBaseProps } from "./section-header.ts";
|
|
30
39
|
export { type SegmentedControlBaseProps, segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass, } from "./segmented-control.ts";
|
|
31
|
-
export { type SelectBaseProps, type SelectOption, selectOptionIds } from "./select.ts";
|
|
40
|
+
export { orderedValues, type SelectBaseProps, type SelectOption, selectedLabels, selectOptionIds, } from "./select.ts";
|
|
32
41
|
export { SIDEBAR_PARTS, type SidebarBaseProps, type SidebarItem, type SidebarSection, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass, } from "./sidebar.ts";
|
|
33
42
|
export { type SkeletonBaseProps, type SkeletonShape, skeletonClass, skeletonSize, } from "./skeleton.ts";
|
|
34
43
|
export { focusThumbOnPress, type SliderBaseProps, sliderArrowValue, sliderPageSize, sliderValueText, } from "./slider.ts";
|
|
35
44
|
export { type SpinnerBaseProps, type SpinnerSize, spinnerClass } from "./spinner.ts";
|
|
36
45
|
export { PEER_FOCUS, type SwitchBaseProps, switchClass, switchLabelClass, switchThumbClass, switchTrackClass, } from "./switch.ts";
|
|
46
|
+
export { columnSort, nextSort, type SortDirection, sortIcon, TABLE_PARTS, type TableBaseProps, type TableColumn, type TableRow, type TableSort, } from "./table.ts";
|
|
37
47
|
export { type TabsBaseProps, tabStopIndex, tabsClass } from "./tabs.ts";
|
|
38
|
-
export { type TextBaseProps, type TextTone, type TextVariant, textClass } from "./text.ts";
|
|
39
48
|
export type { SearchFieldBaseProps, TextFieldBaseProps, TextFieldType } from "./text-field.ts";
|
|
49
|
+
export { type TextBaseProps, type TextTone, type TextVariant, textClass } from "./text.ts";
|
|
40
50
|
export { readCssMs, readCssPx, readThemeScope, syncThemeScope, type ThemeScope, underlayLayerStyle, } from "./theme-scope.ts";
|
|
41
51
|
export { THUMBNAIL_PARTS, type ThumbnailBaseProps, type ThumbnailRatio, thumbnailBadgeClass, thumbnailClass, thumbnailWatched, } from "./thumbnail.ts";
|
|
42
|
-
export {
|
|
52
|
+
export { formatTime, type IsoTime, isoTime, parseIsoTime, TIME_PICKER_DEFAULT_STEP, type TimePickerBaseProps, timeOptions, timePickerIds, timePickerLocale, } from "./time-picker.ts";
|
|
53
|
+
export { type QueuedToast, queueToast, TOAST_QUEUE_WAITING, type ToastQueueBaseProps, toastQueueStep, } from "./toast-queue.ts";
|
|
43
54
|
export { TOAST_PARTS, type ToastAction, type ToastBaseProps } from "./toast.ts";
|
|
44
55
|
export { type TooltipBaseProps, tooltipEndSide } from "./tooltip.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export { ACCORDION_PARTS, focusTitleOnClick, setPanelOpen, } from "./accordion.js";
|
|
2
2
|
export { afterAnimations } from "./animation.js";
|
|
3
|
-
export { AVATAR_SIZE, avatarClass, avatarInitials, pictureClass, } from "./avatar.js";
|
|
4
3
|
export { avatarStack, avatarStackClass, avatarStackItemClass, avatarStackRestClass, } from "./avatar-stack.js";
|
|
4
|
+
export { AVATAR_SIZE, avatarClass, avatarInitials, pictureClass, } from "./avatar.js";
|
|
5
5
|
export { badgeClass, badgeDotClass } from "./badge.js";
|
|
6
6
|
export { BANNER_PARTS, bannerClass, bannerIconClass, bannerIconPath, bannerRole, } from "./banner.js";
|
|
7
|
+
export { BREADCRUMB_PARTS, BREADCRUMB_SEPARATOR, } from "./breadcrumb.js";
|
|
7
8
|
export { BUTTON_ICON, buttonClass, ICON_BUTTON_BOX, isHeld, } from "./button.js";
|
|
8
9
|
export { CARD_PARTS, cardClass, cardMediaClass } from "./card.js";
|
|
9
|
-
export { CHECKBOX_MARK, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMarkClass, } from "./checkbox.js";
|
|
10
|
-
export { chipClass, chipIcon } from "./chip.js";
|
|
10
|
+
export { CHECKBOX_DASH, CHECKBOX_MARK, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMark, checkboxMarkClass, } from "./checkbox.js";
|
|
11
11
|
export { chipBarClass } from "./chip-bar.js";
|
|
12
|
+
export { chipClass, chipIcon } from "./chip.js";
|
|
13
|
+
export { COMBOBOX_PARTS, foldText, matchOptions } from "./combobox.js";
|
|
12
14
|
export { countBadgeAnchorClass, countBadgeClass, countBadgeText, } from "./count-badge.js";
|
|
13
15
|
export { clampDay, DATE_PICKER_NAV_CLASS, datePickerContentAttrs, datePickerIds, datePickerLocale, datePickerMachineProps, datePickerTranslations, datePickerTriggerAttrs, focusOpeningDay, formatDay, keepCalendarFocus, keepDayFocused, openingDay, parseIsoDate, todayIso, } from "./date-picker.js";
|
|
14
16
|
export { dateRangeMachineProps, dateRangeTranslations, daysBetween, endRangeChoiceOnClose, formatRange, keepRangePreview, rangeDayChoice, rangeDayClick, rangeGridKeyDown, rangeMonths, rangeMonthViews, rangeSummary, restartRange, shownRange, } from "./date-range-picker.js";
|
|
@@ -19,23 +21,32 @@ export { leaveEscapeToFields } from "./escape.js";
|
|
|
19
21
|
export { focusWithoutRing } from "./focus.js";
|
|
20
22
|
export { iconClass } from "./icon.js";
|
|
21
23
|
export { initials } from "./initials.js";
|
|
24
|
+
export { DEFAULT_LABELS, mergeLabels } from "./labels.js";
|
|
25
|
+
export { LINK_ICON, LINK_PARTS, linkElement, } from "./link.js";
|
|
22
26
|
export { LIST_ROW_PARTS, listRowClass, listRowDescriptionClass, listRowTitleClass, PRESSABLE_ROW, } from "./list-row.js";
|
|
23
27
|
export { MEDIA_CARD_PARTS, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, } from "./media-card.js";
|
|
24
28
|
export { firstMenuValue, layoutRect, menuItemClass, opensOnPress, } from "./menu.js";
|
|
25
29
|
export { keepListKeys, pageTarget } from "./page-keys.js";
|
|
30
|
+
export { clampPage, PAGINATION_PARTS, PAGINATION_STEPS, paginationEntries, } from "./pagination.js";
|
|
31
|
+
export { classes, rootPart } from "./parts.js";
|
|
32
|
+
export { POPOVER_PARTS } from "./popover.js";
|
|
26
33
|
export { progressBarClass, progressBarFillClass, progressPercent, } from "./progress-bar.js";
|
|
34
|
+
export { isControlled, onFormReset, rootAttributes } from "./root.js";
|
|
35
|
+
export { createItemPropsCache, sameItemProps, sameRowProps } from "./rows.js";
|
|
27
36
|
export { SECTION_HEADER_PARTS } from "./section-header.js";
|
|
28
37
|
export { segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass, } from "./segmented-control.js";
|
|
29
|
-
export { selectOptionIds } from "./select.js";
|
|
38
|
+
export { orderedValues, selectedLabels, selectOptionIds, } from "./select.js";
|
|
30
39
|
export { SIDEBAR_PARTS, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass, } from "./sidebar.js";
|
|
31
40
|
export { skeletonClass, skeletonSize, } from "./skeleton.js";
|
|
32
41
|
export { focusThumbOnPress, sliderArrowValue, sliderPageSize, sliderValueText, } from "./slider.js";
|
|
33
42
|
export { spinnerClass } from "./spinner.js";
|
|
34
43
|
export { PEER_FOCUS, switchClass, switchLabelClass, switchThumbClass, switchTrackClass, } from "./switch.js";
|
|
44
|
+
export { columnSort, nextSort, sortIcon, TABLE_PARTS, } from "./table.js";
|
|
35
45
|
export { tabStopIndex, tabsClass } from "./tabs.js";
|
|
36
46
|
export { textClass } from "./text.js";
|
|
37
47
|
export { readCssMs, readCssPx, readThemeScope, syncThemeScope, underlayLayerStyle, } from "./theme-scope.js";
|
|
38
48
|
export { THUMBNAIL_PARTS, thumbnailBadgeClass, thumbnailClass, thumbnailWatched, } from "./thumbnail.js";
|
|
39
|
-
export {
|
|
49
|
+
export { formatTime, isoTime, parseIsoTime, TIME_PICKER_DEFAULT_STEP, timeOptions, timePickerIds, timePickerLocale, } from "./time-picker.js";
|
|
50
|
+
export { queueToast, TOAST_QUEUE_WAITING, toastQueueStep, } from "./toast-queue.js";
|
|
40
51
|
export { TOAST_PARTS } from "./toast.js";
|
|
41
52
|
export { tooltipEndSide } from "./tooltip.js";
|
package/dist/labels.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names the components give their own parts, in English, by key: a banner's dismiss control,
|
|
3
|
+
* a search field's clear control, a calendar's month buttons, the ends of a range. Every client
|
|
4
|
+
* has the same keys and defaults, which `labels` in design/components.json lists;
|
|
5
|
+
* `labels.test.ts` holds this to it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_LABELS: {
|
|
8
|
+
readonly back: "Back";
|
|
9
|
+
readonly breadcrumb: "Breadcrumb";
|
|
10
|
+
readonly clear: "Clear";
|
|
11
|
+
readonly close: "Close";
|
|
12
|
+
readonly dismiss: "Dismiss";
|
|
13
|
+
readonly done: "Done";
|
|
14
|
+
readonly end: "End";
|
|
15
|
+
readonly nextMonth: "Next month";
|
|
16
|
+
readonly nextPage: "Next page";
|
|
17
|
+
readonly noMatches: "No matches";
|
|
18
|
+
readonly pagination: "Pagination";
|
|
19
|
+
readonly previousMonth: "Previous month";
|
|
20
|
+
readonly previousPage: "Previous page";
|
|
21
|
+
readonly sortedAscending: "Sorted ascending";
|
|
22
|
+
readonly sortedDescending: "Sorted descending";
|
|
23
|
+
readonly start: "Start";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The built-in labels in effect, by key. A library's `Labels` provider gives the components
|
|
27
|
+
* inside it the ones it names, in the app's language, over those of the providers around it; a
|
|
28
|
+
* label the app passes to a component wins over both.
|
|
29
|
+
*/
|
|
30
|
+
export type ComponentLabels = {
|
|
31
|
+
-readonly [K in keyof typeof DEFAULT_LABELS]: string;
|
|
32
|
+
};
|
|
33
|
+
/** The labels inside a provider: the outer ones, with those the inner one names replaced. */
|
|
34
|
+
export declare function mergeLabels(outer: ComponentLabels | undefined, inner: Partial<ComponentLabels> | undefined): ComponentLabels;
|
package/dist/labels.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const DEFAULT_LABELS = {
|
|
2
|
+
back: "Back",
|
|
3
|
+
breadcrumb: "Breadcrumb",
|
|
4
|
+
clear: "Clear",
|
|
5
|
+
close: "Close",
|
|
6
|
+
dismiss: "Dismiss",
|
|
7
|
+
done: "Done",
|
|
8
|
+
end: "End",
|
|
9
|
+
nextMonth: "Next month",
|
|
10
|
+
nextPage: "Next page",
|
|
11
|
+
noMatches: "No matches",
|
|
12
|
+
pagination: "Pagination",
|
|
13
|
+
previousMonth: "Previous month",
|
|
14
|
+
previousPage: "Previous page",
|
|
15
|
+
sortedAscending: "Sorted ascending",
|
|
16
|
+
sortedDescending: "Sorted descending",
|
|
17
|
+
start: "Start",
|
|
18
|
+
};
|
|
19
|
+
export function mergeLabels(outer, inner) {
|
|
20
|
+
const merged = { ...(outer ?? DEFAULT_LABELS) };
|
|
21
|
+
for (const [key, value] of Object.entries(inner ?? {})) {
|
|
22
|
+
if (value !== undefined && key in DEFAULT_LABELS)
|
|
23
|
+
merged[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return merged;
|
|
26
|
+
}
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Link's props in every framework, short of its text and its press handler. */
|
|
2
|
+
export type LinkBaseProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The address the link opens, which the browser follows. Leave it out for a link that only
|
|
5
|
+
* calls `onPress`, such as one that moves to another view of the app.
|
|
6
|
+
*/
|
|
7
|
+
href?: string;
|
|
8
|
+
/** Opens outside the app, in a new tab, and shows the external-link icon after the text. */
|
|
9
|
+
external?: boolean;
|
|
10
|
+
/** Neither focusable nor pressable, and reported as unavailable. */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The classes of a Link's parts beside its root, `xds-link`: the external-link icon after the
|
|
15
|
+
* text, which a library draws as its Icon with this class.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LINK_PARTS: {
|
|
18
|
+
readonly icon: "xds-link__icon";
|
|
19
|
+
};
|
|
20
|
+
/** The icon of an external link. `sm` is as tall as body text, which the link usually sits in. */
|
|
21
|
+
export declare const LINK_ICON: {
|
|
22
|
+
readonly name: "external-link";
|
|
23
|
+
readonly size: "sm";
|
|
24
|
+
};
|
|
25
|
+
/** The element a Link is drawn as, and its attributes, short of the class, style and handler. */
|
|
26
|
+
export type LinkElement = {
|
|
27
|
+
tag: "a";
|
|
28
|
+
attributes: {
|
|
29
|
+
href?: string;
|
|
30
|
+
target?: "_blank";
|
|
31
|
+
rel?: string;
|
|
32
|
+
role?: "link";
|
|
33
|
+
"aria-disabled"?: "true";
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
tag: "button";
|
|
37
|
+
attributes: {
|
|
38
|
+
type: "button";
|
|
39
|
+
role: "link";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* What a Link draws. With an `href` it is an `<a>`, which the browser follows, and an external
|
|
44
|
+
* one opens in a new tab that cannot reach back to this page. Without one it is a button, since
|
|
45
|
+
* an `<a>` without `href` takes no focus; it keeps the link role, so it is announced as what it
|
|
46
|
+
* looks like. A disabled link is an `<a>` without `href`, whichever it would be: it goes nowhere
|
|
47
|
+
* and takes no focus, and `aria-disabled` reports why.
|
|
48
|
+
*/
|
|
49
|
+
export declare function linkElement({ href, external, disabled, }: LinkBaseProps): LinkElement;
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const LINK_PARTS = { icon: "xds-link__icon" };
|
|
2
|
+
export const LINK_ICON = { name: "external-link", size: "sm" };
|
|
3
|
+
export function linkElement({ href, external = false, disabled = false, }) {
|
|
4
|
+
if (disabled)
|
|
5
|
+
return { tag: "a", attributes: { role: "link", "aria-disabled": "true" } };
|
|
6
|
+
if (href === undefined)
|
|
7
|
+
return { tag: "button", attributes: { type: "button", role: "link" } };
|
|
8
|
+
return {
|
|
9
|
+
tag: "a",
|
|
10
|
+
attributes: external ? { href, target: "_blank", rel: "noopener noreferrer" } : { href },
|
|
11
|
+
};
|
|
12
|
+
}
|