@xds/core 1.1.0 → 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.
Files changed (90) hide show
  1. package/dist/breadcrumb.d.ts +39 -0
  2. package/dist/breadcrumb.js +7 -0
  3. package/dist/checkbox.d.ts +16 -2
  4. package/dist/checkbox.js +3 -1
  5. package/dist/combobox.d.ts +59 -0
  6. package/dist/combobox.js +40 -0
  7. package/dist/index.d.ts +16 -7
  8. package/dist/index.js +15 -6
  9. package/dist/labels.d.ts +12 -5
  10. package/dist/labels.js +12 -5
  11. package/dist/link.d.ts +49 -0
  12. package/dist/link.js +12 -0
  13. package/dist/pagination.d.ts +51 -0
  14. package/dist/pagination.js +25 -0
  15. package/dist/popover.d.ts +33 -0
  16. package/dist/popover.js +8 -0
  17. package/dist/preview/components.d.ts +36 -0
  18. package/dist/preview/components.js +1 -0
  19. package/dist/preview/design.d.ts +22 -3
  20. package/dist/preview/design.js +65 -34
  21. package/dist/preview/fixtures.d.ts +0 -76
  22. package/dist/preview/fixtures.js +0 -126
  23. package/dist/preview/kit.d.ts +48 -32
  24. package/dist/preview/kit.js +3 -0
  25. package/dist/preview/page.d.ts +1 -1
  26. package/dist/preview/page.js +1 -0
  27. package/dist/preview/sections/accordion.d.ts +1 -0
  28. package/dist/preview/sections/accordion.js +40 -0
  29. package/dist/preview/sections/badges.d.ts +1 -0
  30. package/dist/preview/sections/badges.js +13 -0
  31. package/dist/preview/sections/banners.d.ts +1 -0
  32. package/dist/preview/sections/banners.js +13 -0
  33. package/dist/preview/sections/buttons.d.ts +2 -0
  34. package/dist/preview/sections/buttons.js +30 -0
  35. package/dist/preview/sections/card.d.ts +1 -0
  36. package/dist/preview/sections/card.js +33 -0
  37. package/dist/preview/sections/chips.d.ts +1 -0
  38. package/dist/preview/sections/chips.js +23 -0
  39. package/dist/preview/sections/controls.d.ts +1 -0
  40. package/dist/preview/sections/controls.js +143 -0
  41. package/dist/preview/sections/dialog.d.ts +1 -0
  42. package/dist/preview/sections/dialog.js +25 -0
  43. package/dist/preview/sections/empty-state.d.ts +1 -0
  44. package/dist/preview/sections/empty-state.js +13 -0
  45. package/dist/preview/sections/links.d.ts +1 -0
  46. package/dist/preview/sections/links.js +8 -0
  47. package/dist/preview/sections/list.d.ts +1 -0
  48. package/dist/preview/sections/list.js +119 -0
  49. package/dist/preview/sections/media.d.ts +1 -0
  50. package/dist/preview/sections/media.js +90 -0
  51. package/dist/preview/sections/menu.d.ts +1 -0
  52. package/dist/preview/sections/menu.js +46 -0
  53. package/dist/preview/sections/navigation.d.ts +1 -0
  54. package/dist/preview/sections/navigation.js +20 -0
  55. package/dist/preview/sections/selection.d.ts +1 -0
  56. package/dist/preview/sections/selection.js +33 -0
  57. package/dist/preview/sections/sidebar.d.ts +1 -0
  58. package/dist/preview/sections/sidebar.js +45 -0
  59. package/dist/preview/sections/skeleton.d.ts +1 -0
  60. package/dist/preview/sections/skeleton.js +5 -0
  61. package/dist/preview/sections/tabs.d.ts +1 -0
  62. package/dist/preview/sections/tabs.js +24 -0
  63. package/dist/preview/sections/text-fields.d.ts +1 -0
  64. package/dist/preview/sections/text-fields.js +75 -0
  65. package/dist/preview/sections/toast.d.ts +2 -0
  66. package/dist/preview/sections/toast.js +28 -0
  67. package/dist/preview/specimens.js +1 -1
  68. package/dist/progress-bar.d.ts +7 -4
  69. package/dist/progress-bar.js +2 -2
  70. package/dist/rows.d.ts +23 -0
  71. package/dist/rows.js +67 -0
  72. package/dist/segmented-control.d.ts +1 -1
  73. package/dist/segmented-control.js +1 -1
  74. package/dist/select.d.ts +22 -0
  75. package/dist/select.js +7 -0
  76. package/dist/switch.d.ts +1 -1
  77. package/dist/switch.js +2 -1
  78. package/dist/table.d.ts +62 -0
  79. package/dist/table.js +25 -0
  80. package/dist/theme-scope.d.ts +6 -4
  81. package/dist/theme-scope.js +21 -15
  82. package/dist/time-picker.d.ts +57 -0
  83. package/dist/time-picker.js +53 -0
  84. package/dist/toast-queue.d.ts +40 -0
  85. package/dist/toast-queue.js +17 -0
  86. package/dist/toast.d.ts +1 -1
  87. package/dist/toast.js +1 -1
  88. package/package.json +2 -2
  89. package/dist/preview/sections.d.ts +0 -20
  90. package/dist/preview/sections.js +0 -517
@@ -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
+ };
@@ -0,0 +1,7 @@
1
+ export const BREADCRUMB_PARTS = {
2
+ list: "xds-breadcrumb__list",
3
+ item: "xds-breadcrumb__item",
4
+ separator: "xds-breadcrumb__separator",
5
+ current: "xds-breadcrumb__current",
6
+ };
7
+ export const BREADCRUMB_SEPARATOR = { name: "chevron-right", size: "xs" };
@@ -5,6 +5,13 @@ export type CheckboxBaseProps = {
5
5
  checked?: boolean;
6
6
  /** Whether a checkbox that keeps its own state starts checked. */
7
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;
8
15
  /** Shown beside the box. Pressing it toggles too. */
9
16
  label?: string;
10
17
  /** Names the checkbox for assistive technology when there is no visible label. */
@@ -16,8 +23,15 @@ export type CheckboxBaseProps = {
16
23
  * The box, drawn beside the hidden input. The outline is what makes an empty box visible; a
17
24
  * filled one does not need it.
18
25
  */
19
- 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";
20
- /** The check mark inside the box: a 16 by 16 path, `CHECKBOX_MARK`. */
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()`. */
21
28
  export declare const checkboxMarkClass = "size-3/4";
22
29
  /** The path of the check mark, in a `0 0 16 16` view box. */
23
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[];
@@ -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/index.d.ts CHANGED
@@ -1,15 +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";
5
- export { isControlled, onFormReset, type RootAttributes, rootAttributes } from "./root.ts";
4
+ export { AVATAR_SIZE, type AvatarBaseProps, type AvatarSize, avatarClass, avatarInitials, pictureClass, } from "./avatar.ts";
6
5
  export { type BadgeBaseProps, type BadgeTone, badgeClass, badgeDotClass } from "./badge.ts";
7
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";
8
8
  export { BUTTON_ICON, type ButtonBaseProps, type ButtonVariant, buttonClass, type ControlSize, ICON_BUTTON_BOX, type IconButtonBaseProps, isHeld, } from "./button.ts";
9
9
  export { CARD_PARTS, type CardBaseProps, cardClass, cardMediaClass } from "./card.ts";
10
- export { CHECKBOX_MARK, type CheckboxBaseProps, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMarkClass, } from "./checkbox.ts";
11
- export { type ChipBaseProps, chipClass, chipIcon } from "./chip.ts";
10
+ export { CHECKBOX_DASH, CHECKBOX_MARK, type CheckboxBaseProps, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMark, checkboxMarkClass, } from "./checkbox.ts";
12
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";
13
14
  export { type CountBadgeBaseProps, countBadgeAnchorClass, countBadgeClass, countBadgeText, } from "./count-badge.ts";
14
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";
15
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";
@@ -22,25 +23,33 @@ export { focusWithoutRing } from "./focus.ts";
22
23
  export { type IconBaseProps, type IconName, type IconSize, iconClass } from "./icon.ts";
23
24
  export { initials } from "./initials.ts";
24
25
  export { type ComponentLabels, DEFAULT_LABELS, mergeLabels } from "./labels.ts";
26
+ export { LINK_ICON, LINK_PARTS, type LinkBaseProps, type LinkElement, linkElement, } from "./link.ts";
25
27
  export { LIST_ROW_PARTS, type ListRowBaseProps, listRowClass, listRowDescriptionClass, listRowTitleClass, PRESSABLE_ROW, } from "./list-row.ts";
26
28
  export { MEDIA_CARD_PARTS, type MediaCardBaseProps, type MediaCardLayout, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, } from "./media-card.ts";
27
29
  export { firstMenuValue, layoutRect, type MenuBaseProps, type MenuItem, menuItemClass, opensOnPress, } from "./menu.ts";
28
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";
29
34
  export { type ProgressBarBaseProps, progressBarClass, progressBarFillClass, progressPercent, } from "./progress-bar.ts";
30
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";
31
38
  export { SECTION_HEADER_PARTS, type SectionHeaderBaseProps } from "./section-header.ts";
32
39
  export { type SegmentedControlBaseProps, segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass, } from "./segmented-control.ts";
33
- export { type SelectBaseProps, type SelectOption, selectOptionIds } from "./select.ts";
40
+ export { orderedValues, type SelectBaseProps, type SelectOption, selectedLabels, selectOptionIds, } from "./select.ts";
34
41
  export { SIDEBAR_PARTS, type SidebarBaseProps, type SidebarItem, type SidebarSection, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass, } from "./sidebar.ts";
35
42
  export { type SkeletonBaseProps, type SkeletonShape, skeletonClass, skeletonSize, } from "./skeleton.ts";
36
43
  export { focusThumbOnPress, type SliderBaseProps, sliderArrowValue, sliderPageSize, sliderValueText, } from "./slider.ts";
37
44
  export { type SpinnerBaseProps, type SpinnerSize, spinnerClass } from "./spinner.ts";
38
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";
39
47
  export { type TabsBaseProps, tabStopIndex, tabsClass } from "./tabs.ts";
40
- export { type TextBaseProps, type TextTone, type TextVariant, textClass } from "./text.ts";
41
48
  export type { SearchFieldBaseProps, TextFieldBaseProps, TextFieldType } from "./text-field.ts";
49
+ export { type TextBaseProps, type TextTone, type TextVariant, textClass } from "./text.ts";
42
50
  export { readCssMs, readCssPx, readThemeScope, syncThemeScope, type ThemeScope, underlayLayerStyle, } from "./theme-scope.ts";
43
51
  export { THUMBNAIL_PARTS, type ThumbnailBaseProps, type ThumbnailRatio, thumbnailBadgeClass, thumbnailClass, thumbnailWatched, } from "./thumbnail.ts";
44
- export { classes, rootPart } from "./parts.ts";
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";
45
54
  export { TOAST_PARTS, type ToastAction, type ToastBaseProps } from "./toast.ts";
46
55
  export { type TooltipBaseProps, tooltipEndSide } from "./tooltip.ts";
package/dist/index.js CHANGED
@@ -1,15 +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";
5
- export { isControlled, onFormReset, rootAttributes } from "./root.js";
4
+ export { AVATAR_SIZE, avatarClass, avatarInitials, pictureClass, } from "./avatar.js";
6
5
  export { badgeClass, badgeDotClass } from "./badge.js";
7
6
  export { BANNER_PARTS, bannerClass, bannerIconClass, bannerIconPath, bannerRole, } from "./banner.js";
7
+ export { BREADCRUMB_PARTS, BREADCRUMB_SEPARATOR, } from "./breadcrumb.js";
8
8
  export { BUTTON_ICON, buttonClass, ICON_BUTTON_BOX, isHeld, } from "./button.js";
9
9
  export { CARD_PARTS, cardClass, cardMediaClass } from "./card.js";
10
- export { CHECKBOX_MARK, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMarkClass, } from "./checkbox.js";
11
- export { chipClass, chipIcon } from "./chip.js";
10
+ export { CHECKBOX_DASH, CHECKBOX_MARK, checkboxBoxClass, checkboxClass, checkboxLabelClass, checkboxMark, checkboxMarkClass, } from "./checkbox.js";
12
11
  export { chipBarClass } from "./chip-bar.js";
12
+ export { chipClass, chipIcon } from "./chip.js";
13
+ export { COMBOBOX_PARTS, foldText, matchOptions } from "./combobox.js";
13
14
  export { countBadgeAnchorClass, countBadgeClass, countBadgeText, } from "./count-badge.js";
14
15
  export { clampDay, DATE_PICKER_NAV_CLASS, datePickerContentAttrs, datePickerIds, datePickerLocale, datePickerMachineProps, datePickerTranslations, datePickerTriggerAttrs, focusOpeningDay, formatDay, keepCalendarFocus, keepDayFocused, openingDay, parseIsoDate, todayIso, } from "./date-picker.js";
15
16
  export { dateRangeMachineProps, dateRangeTranslations, daysBetween, endRangeChoiceOnClose, formatRange, keepRangePreview, rangeDayChoice, rangeDayClick, rangeGridKeyDown, rangeMonths, rangeMonthViews, rangeSummary, restartRange, shownRange, } from "./date-range-picker.js";
@@ -21,23 +22,31 @@ export { focusWithoutRing } from "./focus.js";
21
22
  export { iconClass } from "./icon.js";
22
23
  export { initials } from "./initials.js";
23
24
  export { DEFAULT_LABELS, mergeLabels } from "./labels.js";
25
+ export { LINK_ICON, LINK_PARTS, linkElement, } from "./link.js";
24
26
  export { LIST_ROW_PARTS, listRowClass, listRowDescriptionClass, listRowTitleClass, PRESSABLE_ROW, } from "./list-row.js";
25
27
  export { MEDIA_CARD_PARTS, mediaCardContentClass, mediaCardIds, mediaCardThumbnailClass, } from "./media-card.js";
26
28
  export { firstMenuValue, layoutRect, menuItemClass, opensOnPress, } from "./menu.js";
27
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";
28
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";
29
36
  export { SECTION_HEADER_PARTS } from "./section-header.js";
30
37
  export { segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass, } from "./segmented-control.js";
31
- export { selectOptionIds } from "./select.js";
38
+ export { orderedValues, selectedLabels, selectOptionIds, } from "./select.js";
32
39
  export { SIDEBAR_PARTS, sidebarClass, sidebarCount, sidebarIconClass, sidebarRailButtonClass, sidebarSectionClass, sidebarTitleClass, } from "./sidebar.js";
33
40
  export { skeletonClass, skeletonSize, } from "./skeleton.js";
34
41
  export { focusThumbOnPress, sliderArrowValue, sliderPageSize, sliderValueText, } from "./slider.js";
35
42
  export { spinnerClass } from "./spinner.js";
36
43
  export { PEER_FOCUS, switchClass, switchLabelClass, switchThumbClass, switchTrackClass, } from "./switch.js";
44
+ export { columnSort, nextSort, sortIcon, TABLE_PARTS, } from "./table.js";
37
45
  export { tabStopIndex, tabsClass } from "./tabs.js";
38
46
  export { textClass } from "./text.js";
39
47
  export { readCssMs, readCssPx, readThemeScope, syncThemeScope, underlayLayerStyle, } from "./theme-scope.js";
40
48
  export { THUMBNAIL_PARTS, thumbnailBadgeClass, thumbnailClass, thumbnailWatched, } from "./thumbnail.js";
41
- export { classes, rootPart } from "./parts.js";
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";
42
51
  export { TOAST_PARTS } from "./toast.js";
43
52
  export { tooltipEndSide } from "./tooltip.js";
package/dist/labels.d.ts CHANGED
@@ -5,15 +5,22 @@
5
5
  * `labels.test.ts` holds this to it.
6
6
  */
7
7
  export declare const DEFAULT_LABELS: {
8
- readonly close: "Close";
9
8
  readonly back: "Back";
10
- readonly dismiss: "Dismiss";
9
+ readonly breadcrumb: "Breadcrumb";
11
10
  readonly clear: "Clear";
12
- readonly previousMonth: "Previous month";
11
+ readonly close: "Close";
12
+ readonly dismiss: "Dismiss";
13
+ readonly done: "Done";
14
+ readonly end: "End";
13
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";
14
23
  readonly start: "Start";
15
- readonly end: "End";
16
- readonly done: "Done";
17
24
  };
18
25
  /**
19
26
  * The built-in labels in effect, by key. A library's `Labels` provider gives the components
package/dist/labels.js CHANGED
@@ -1,13 +1,20 @@
1
1
  export const DEFAULT_LABELS = {
2
- close: "Close",
3
2
  back: "Back",
4
- dismiss: "Dismiss",
3
+ breadcrumb: "Breadcrumb",
5
4
  clear: "Clear",
6
- previousMonth: "Previous month",
5
+ close: "Close",
6
+ dismiss: "Dismiss",
7
+ done: "Done",
8
+ end: "End",
7
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",
8
17
  start: "Start",
9
- end: "End",
10
- done: "Done",
11
18
  };
12
19
  export function mergeLabels(outer, inner) {
13
20
  const merged = { ...(outer ?? DEFAULT_LABELS) };
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
+ }
@@ -0,0 +1,51 @@
1
+ /** Pagination's props in every framework, short of its change handler. */
2
+ export type PaginationBaseProps = {
3
+ /** How many pages there are. */
4
+ count: number;
5
+ /**
6
+ * The page shown, from 1. Given at all, even as `undefined`, the app keeps it and changes it
7
+ * in `onChange`; otherwise the pagination keeps its own, from `defaultValue`.
8
+ */
9
+ value?: number;
10
+ /** The page shown first when the pagination keeps its own. Defaults to 1. */
11
+ defaultValue?: number;
12
+ /**
13
+ * Names the pagination's navigation landmark for assistive technology: `pagination` from the
14
+ * closest `Labels`, "Pagination" in English, unless it is given.
15
+ */
16
+ label?: string;
17
+ /** Names the step back a page: `previousPage` from the closest `Labels` unless it is given. */
18
+ previousLabel?: string;
19
+ /** Names the step on a page: `nextPage` from the closest `Labels` unless it is given. */
20
+ nextLabel?: string;
21
+ };
22
+ /** A page, by its number from 1, or a gap that stands for the pages left out. */
23
+ export type PaginationEntry = number | "gap";
24
+ /**
25
+ * The pages a Pagination shows between its steps: the first, the last, and the one shown, with
26
+ * a gap for each run of pages left out. Never more than five, so the row keeps its width from
27
+ * page to page and fits a phone held upright with the steps beside it. Near either end the
28
+ * three pages there are shown, so a gap never stands for a single page beside the one shown.
29
+ */
30
+ export declare function paginationEntries(value: number, count: number): PaginationEntry[];
31
+ /** The page shown, kept between the first and the last: an app may give one past the end. */
32
+ export declare function clampPage(value: number, count: number): number;
33
+ /**
34
+ * The classes of a Pagination's parts beside its root, `xds-pagination`, a `<nav>`: the row,
35
+ * a page, a gap, and the steps back and on.
36
+ */
37
+ export declare const PAGINATION_PARTS: {
38
+ readonly list: "xds-pagination__list";
39
+ readonly page: "xds-pagination__page";
40
+ readonly gap: "xds-pagination__gap";
41
+ readonly step: "xds-pagination__step";
42
+ };
43
+ /**
44
+ * The steps' chevrons, which point back and on, so they mirror in a right-to-left layout. `sm`
45
+ * is the icon of a small control.
46
+ */
47
+ export declare const PAGINATION_STEPS: {
48
+ readonly previous: "chevron-left";
49
+ readonly next: "chevron-right";
50
+ readonly size: "sm";
51
+ };
@@ -0,0 +1,25 @@
1
+ export function paginationEntries(value, count) {
2
+ const last = Math.max(0, Math.floor(count));
3
+ if (last <= 5)
4
+ return Array.from({ length: last }, (_, index) => index + 1);
5
+ const page = clampPage(value, last);
6
+ if (page <= 3)
7
+ return [1, 2, 3, "gap", last];
8
+ if (page >= last - 2)
9
+ return [1, "gap", last - 2, last - 1, last];
10
+ return [1, "gap", page, "gap", last];
11
+ }
12
+ export function clampPage(value, count) {
13
+ return Math.min(Math.max(1, Math.floor(value)), Math.max(1, Math.floor(count)));
14
+ }
15
+ export const PAGINATION_PARTS = {
16
+ list: "xds-pagination__list",
17
+ page: "xds-pagination__page",
18
+ gap: "xds-pagination__gap",
19
+ step: "xds-pagination__step",
20
+ };
21
+ export const PAGINATION_STEPS = {
22
+ previous: "chevron-left",
23
+ next: "chevron-right",
24
+ size: "sm",
25
+ };
@@ -0,0 +1,33 @@
1
+ /** Popover's props in every framework, short of its trigger and its content. */
2
+ export type PopoverBaseProps = {
3
+ /** Names the popover, and stands at its top. */
4
+ title: string;
5
+ /**
6
+ * The side of the trigger it opens on, where it opens beside it: below unless there is no
7
+ * room. Where fingers are used it is a sheet across the bottom of the screen instead.
8
+ */
9
+ placement?: "bottom" | "top";
10
+ /** Names its close button: `close` from the closest `Labels` unless it is given. */
11
+ closeLabel?: string;
12
+ /**
13
+ * Whether it is open. Given at all, even as `undefined`, the app keeps it and changes it in
14
+ * `onOpenChange`; otherwise the popover keeps its own, from `defaultOpen`.
15
+ */
16
+ open?: boolean;
17
+ /** Whether it starts open when it keeps its own. */
18
+ defaultOpen?: boolean;
19
+ };
20
+ /**
21
+ * The classes of a Popover's parts: its trigger (added to the Button or IconButton that opens
22
+ * it), the positioner Zag places, the surface (the root part,
23
+ * `xds-popover`, which takes the app's class and attributes), its header, title, close button
24
+ * and body.
25
+ */
26
+ export declare const POPOVER_PARTS: {
27
+ readonly trigger: "xds-popover__trigger";
28
+ readonly positioner: "xds-popover__positioner";
29
+ readonly header: "xds-popover__header";
30
+ readonly title: "xds-popover__title";
31
+ readonly close: "xds-popover__close";
32
+ readonly body: "xds-popover__body";
33
+ };
@@ -0,0 +1,8 @@
1
+ export const POPOVER_PARTS = {
2
+ trigger: "xds-popover__trigger",
3
+ positioner: "xds-popover__positioner",
4
+ header: "xds-popover__header",
5
+ title: "xds-popover__title",
6
+ close: "xds-popover__close",
7
+ body: "xds-popover__body",
8
+ };