@xds/svelte 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.
- .diffend-unextracted-0 +2 -1
- package/dist/Accordion.svelte +7 -2
- package/dist/Avatar.svelte +10 -2
- package/dist/AvatarStack.svelte +11 -1
- package/dist/Badge.svelte +14 -3
- package/dist/Banner.svelte +6 -1
- package/dist/Breadcrumb.svelte +53 -0
- package/dist/Breadcrumb.svelte.d.ts +11 -0
- package/dist/Button.svelte +30 -2
- package/dist/Button.svelte.d.ts +10 -1
- package/dist/Card.svelte +16 -2
- package/dist/Checkbox.svelte +62 -10
- package/dist/Checkbox.svelte.d.ts +14 -3
- package/dist/Chip.svelte +3 -1
- package/dist/ChipBar.svelte +3 -2
- package/dist/Combobox.svelte +194 -0
- package/dist/Combobox.svelte.d.ts +37 -0
- package/dist/CountBadge.svelte +4 -2
- package/dist/DatePicker.svelte +16 -5
- package/dist/DateRangePicker.svelte +6 -1
- package/dist/Dialog.svelte +9 -2
- package/dist/Divider.svelte +7 -3
- package/dist/EmptyState.svelte +15 -3
- package/dist/Icon.svelte +11 -2
- package/dist/IconButton.svelte +30 -2
- package/dist/IconButton.svelte.d.ts +10 -1
- package/dist/Labels.svelte +29 -0
- package/dist/Labels.svelte.d.ts +17 -0
- package/dist/Link.svelte +86 -0
- package/dist/Link.svelte.d.ts +26 -0
- package/dist/MediaCard.svelte +4 -1
- package/dist/Menu.svelte +21 -2
- package/dist/Pagination.svelte +108 -0
- package/dist/Pagination.svelte.d.ts +14 -0
- package/dist/PlaceRow.svelte +6 -1
- package/dist/Popover.svelte +91 -0
- package/dist/Popover.svelte.d.ts +21 -0
- package/dist/PopoverSurface.svelte +77 -0
- package/dist/PopoverSurface.svelte.d.ts +21 -0
- package/dist/ProgressBar.svelte +3 -1
- package/dist/RadioGroup.svelte +23 -8
- package/dist/RadioGroup.svelte.d.ts +4 -2
- package/dist/SearchField.svelte +65 -18
- package/dist/SearchField.svelte.d.ts +14 -4
- package/dist/SectionHeader.svelte +7 -2
- package/dist/SegmentedControl.svelte +21 -7
- package/dist/SegmentedControl.svelte.d.ts +3 -2
- package/dist/Select.svelte +64 -12
- package/dist/Select.svelte.d.ts +9 -2
- package/dist/Sidebar.svelte +3 -0
- package/dist/Skeleton.svelte +10 -2
- package/dist/Slider.svelte +23 -7
- package/dist/Slider.svelte.d.ts +2 -2
- package/dist/Spinner.svelte +3 -2
- package/dist/Switch.svelte +53 -9
- package/dist/Switch.svelte.d.ts +13 -3
- package/dist/Table.svelte +92 -0
- package/dist/Table.svelte.d.ts +17 -0
- package/dist/Tabs.svelte +21 -6
- package/dist/Tabs.svelte.d.ts +2 -1
- package/dist/Text.svelte +3 -1
- package/dist/TextField.svelte +59 -14
- package/dist/TextField.svelte.d.ts +13 -3
- package/dist/Thumbnail.svelte +7 -1
- package/dist/TimePicker.svelte +222 -0
- package/dist/TimePicker.svelte.d.ts +20 -0
- package/dist/Toast.svelte +12 -2
- package/dist/ToastQueue.svelte +57 -0
- package/dist/ToastQueue.svelte.d.ts +20 -0
- package/dist/Tooltip.svelte +9 -2
- package/dist/TooltipOverlay.svelte +9 -2
- package/dist/base.d.ts +14 -0
- package/dist/base.js +27 -0
- package/dist/controllable.svelte.d.ts +28 -0
- package/dist/controllable.svelte.js +41 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +12 -0
- package/dist/labels.svelte.d.ts +13 -0
- package/dist/labels.svelte.js +24 -0
- package/dist/modal-popover.svelte.js +5 -1
- package/dist/presence.svelte.js +5 -2
- package/dist/preview/Component.svelte +8 -3
- package/dist/preview/Preview.svelte +8 -2
- package/dist/preview/Preview.svelte.d.ts +2 -0
- package/dist/preview/components.d.ts +9 -2
- package/dist/preview/components.js +18 -1
- package/dist/preview/index.d.ts +1 -0
- package/dist/root.d.ts +4 -2
- package/eject/files/Accordion.svelte +100 -0
- package/eject/files/AccordionPanel.svelte +48 -0
- package/eject/files/Avatar.svelte +51 -0
- package/eject/files/AvatarStack.svelte +61 -0
- package/eject/files/Badge.svelte +52 -0
- package/eject/files/Banner.svelte +94 -0
- package/eject/files/Breadcrumb.svelte +52 -0
- package/eject/files/Button.svelte +126 -0
- package/eject/files/Card.svelte +112 -0
- package/eject/files/Checkbox.svelte +121 -0
- package/eject/files/Chip.svelte +51 -0
- package/eject/files/ChipBar.svelte +39 -0
- package/eject/files/Combobox.svelte +198 -0
- package/eject/files/CountBadge.svelte +51 -0
- package/eject/files/DatePicker.svelte +213 -0
- package/eject/files/DateRangePicker.svelte +294 -0
- package/eject/files/Dialog.svelte +119 -0
- package/eject/files/Divider.svelte +27 -0
- package/eject/files/EmptyState.svelte +52 -0
- package/eject/files/Icon.svelte +51 -0
- package/eject/files/IconButton.svelte +99 -0
- package/eject/files/Link.svelte +85 -0
- package/eject/files/ListRow.svelte +33 -0
- package/eject/files/MediaCard.svelte +117 -0
- package/eject/files/Menu.svelte +183 -0
- package/eject/files/Pagination.svelte +109 -0
- package/eject/files/PlaceRow.svelte +75 -0
- package/eject/files/Popover.svelte +100 -0
- package/eject/files/PopoverSurface.svelte +85 -0
- package/eject/files/ProgressBar.svelte +38 -0
- package/eject/files/RadioGroup.svelte +133 -0
- package/eject/files/SearchField.svelte +154 -0
- package/eject/files/SectionHeader.svelte +67 -0
- package/eject/files/SegmentedControl.svelte +85 -0
- package/eject/files/Select.svelte +276 -0
- package/eject/files/Sidebar.svelte +130 -0
- package/eject/files/SidebarRailButton.svelte +32 -0
- package/eject/files/Skeleton.svelte +55 -0
- package/eject/files/Slider.svelte +136 -0
- package/eject/files/Spinner.svelte +41 -0
- package/eject/files/Switch.svelte +105 -0
- package/eject/files/Table.svelte +90 -0
- package/eject/files/Tabs.svelte +85 -0
- package/eject/files/Text.svelte +43 -0
- package/eject/files/TextField.svelte +222 -0
- package/eject/files/Thumbnail.svelte +88 -0
- package/eject/files/TimePicker.svelte +237 -0
- package/eject/files/Toast.svelte +98 -0
- package/eject/files/ToastQueue.svelte +61 -0
- package/eject/files/Tooltip.svelte +51 -0
- package/eject/files/TooltipOverlay.svelte +88 -0
- package/eject/files/accordion.css +89 -0
- package/eject/files/accordion.ts +67 -0
- package/eject/files/avatar-stack.ts +57 -0
- package/eject/files/avatar.ts +42 -0
- package/eject/files/badge.ts +30 -0
- package/eject/files/banner.ts +71 -0
- package/eject/files/base.css +38 -0
- package/eject/files/breadcrumb.css +51 -0
- package/eject/files/breadcrumb.ts +42 -0
- package/eject/files/button.css +241 -0
- package/eject/files/button.ts +106 -0
- package/eject/files/card.ts +58 -0
- package/eject/files/checkbox.ts +52 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/combobox.css +269 -0
- package/eject/files/combobox.ts +85 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +375 -0
- package/eject/files/date-picker.ts +280 -0
- package/eject/files/date-range-picker.ts +338 -0
- package/eject/files/dialog.css +139 -0
- package/eject/files/dialog.ts +15 -0
- package/eject/files/divider.ts +5 -0
- package/eject/files/empty-state.ts +22 -0
- package/eject/files/icon.ts +36 -0
- package/eject/files/link.css +64 -0
- package/eject/files/link.ts +63 -0
- package/eject/files/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +192 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/overlay.css +40 -0
- package/eject/files/pagination.css +106 -0
- package/eject/files/pagination.ts +68 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/popover.css +101 -0
- package/eject/files/popover.ts +37 -0
- package/eject/files/progress-bar.ts +26 -0
- package/eject/files/radio-group.css +184 -0
- package/eject/files/radio-group.ts +30 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +33 -0
- package/eject/files/select.css +347 -0
- package/eject/files/select.ts +77 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +160 -0
- package/eject/files/slider.ts +80 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +45 -0
- package/eject/files/table.css +107 -0
- package/eject/files/table.ts +84 -0
- package/eject/files/tabs.css +120 -0
- package/eject/files/tabs.ts +37 -0
- package/eject/files/text-field.css +225 -0
- package/eject/files/text-field.ts +64 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/time-picker.ts +113 -0
- package/eject/files/toast-queue.ts +64 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +111 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +1053 -0
- package/package.json +12 -4
- package/styles.css +1064 -169
- package/tailwind.css +1295 -218
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
/** Card's props in every framework, short of `onPress`, its content, `actions` and `media`. */
|
|
5
|
+
export type CardBaseProps = {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
/** No padding and no gaps: for a card that holds a list, whose rows run edge to edge. */
|
|
9
|
+
flush?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Outlines the card as the current choice. Given at all on a pressable card, it also makes
|
|
12
|
+
* the card a toggle that reports its state to assistive technology.
|
|
13
|
+
*/
|
|
14
|
+
selected?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// The selected outline is thicker than the hairline, so the state does not depend on its
|
|
18
|
+
// color. It is a layer over the hairline and over the content: a thicker border would move the
|
|
19
|
+
// content, an outline is what the focus ring uses, and anything under the content would be
|
|
20
|
+
// covered by `media`.
|
|
21
|
+
const SELECTED =
|
|
22
|
+
"border-xds-card-border-selected after:pointer-events-none after:absolute after:-inset-(--xds-border-width-thin) after:rounded-xds-lg after:border-(length:--xds-border-width-thick) after:border-xds-card-border-selected";
|
|
23
|
+
|
|
24
|
+
// What runs to the edges is clipped to the inside of the hairline. The card itself clips
|
|
25
|
+
// nothing, or it would cut off the selected outline and the focus rings of what it holds.
|
|
26
|
+
const CLIP = "overflow-hidden rounded-[calc(var(--xds-radius-lg)-var(--xds-border-width-thin))]";
|
|
27
|
+
const CLIP_TOP =
|
|
28
|
+
"overflow-hidden rounded-t-[calc(var(--xds-radius-lg)-var(--xds-border-width-thin))]";
|
|
29
|
+
|
|
30
|
+
// A button is only as wide as its content unless told otherwise; a card fills its place.
|
|
31
|
+
const PRESSABLE =
|
|
32
|
+
"w-full cursor-pointer text-start transition-colors duration-(--xds-motion-duration-fast) hover:bg-xds-card-background-hover active:bg-xds-card-background-pressed focus-visible:outline-solid focus-visible:outline-(length:--xds-focus-width) focus-visible:outline-offset-(--xds-focus-offset) focus-visible:outline-xds-border-focus";
|
|
33
|
+
|
|
34
|
+
/** The surface: a `section`, or a `button` with `pressable`. */
|
|
35
|
+
export function cardClass(options: {
|
|
36
|
+
selected?: boolean | undefined;
|
|
37
|
+
flush?: boolean | undefined;
|
|
38
|
+
pressable?: boolean | undefined;
|
|
39
|
+
}): string {
|
|
40
|
+
const { selected = false, flush = false, pressable = false } = options;
|
|
41
|
+
const surface = `relative flex flex-col rounded-xds-lg border bg-xds-background-surface shadow-xds-subtle ${selected ? SELECTED : "border-xds-border-default"}${flush ? "" : " gap-4 p-4"}`;
|
|
42
|
+
return pressable ? `${PRESSABLE} ${surface}` : surface;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The box of `media`, pulled out through the padding to the edges. */
|
|
46
|
+
export function cardMediaClass(flush = false): string {
|
|
47
|
+
return flush ? `flex flex-col ${CLIP_TOP}` : `flex flex-col ${CLIP_TOP} -mx-4 -mt-4`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const CARD_PARTS = {
|
|
51
|
+
/** Around everything in a `flush` card. */
|
|
52
|
+
flush: `flex flex-1 flex-col ${CLIP}`,
|
|
53
|
+
header: "flex items-start justify-between gap-3",
|
|
54
|
+
heading: "flex min-w-0 flex-col gap-0.5",
|
|
55
|
+
title: "text-xds-heading text-xds-text-primary",
|
|
56
|
+
description: "text-xds-detail text-xds-text-secondary",
|
|
57
|
+
actions: "flex shrink-0 items-center gap-2",
|
|
58
|
+
} as const;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import { PEER_FOCUS } from "@xds/svelte/base";
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
switchClass as checkboxClass,
|
|
8
|
+
switchLabelClass as checkboxLabelClass,
|
|
9
|
+
} from "@xds/svelte/base";
|
|
10
|
+
|
|
11
|
+
/** Checkbox's props in every framework, short of `onChange`. */
|
|
12
|
+
export type CheckboxBaseProps = {
|
|
13
|
+
/** Leave it out for a checkbox that keeps its own state, from `defaultChecked`. */
|
|
14
|
+
checked?: boolean;
|
|
15
|
+
/** Whether a checkbox that keeps its own state starts checked. */
|
|
16
|
+
defaultChecked?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Shows a dash in place of the check and reports the checkbox as mixed, whatever `checked`
|
|
19
|
+
* is: a checkbox for a group of which some are checked. The app keeps it: a press still
|
|
20
|
+
* reports the opposite of `checked`, and the app clears it in `onChange`. Leave `checked`
|
|
21
|
+
* false with it, so that a press checks the whole group.
|
|
22
|
+
*/
|
|
23
|
+
indeterminate?: boolean;
|
|
24
|
+
/** Shown beside the box. Pressing it toggles too. */
|
|
25
|
+
label?: string;
|
|
26
|
+
/** Names the checkbox for assistive technology when there is no visible label. */
|
|
27
|
+
"aria-label"?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The box, drawn beside the hidden input. The outline is what makes an empty box visible; a
|
|
34
|
+
* filled one does not need it.
|
|
35
|
+
*/
|
|
36
|
+
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}`;
|
|
37
|
+
|
|
38
|
+
/** The mark inside the box: a 16 by 16 path, `checkboxMark()`. */
|
|
39
|
+
export const checkboxMarkClass = "size-3/4";
|
|
40
|
+
|
|
41
|
+
/** The path of the check mark, in a `0 0 16 16` view box. */
|
|
42
|
+
export const CHECKBOX_MARK = "m3.5 8.5 3 3 6-7";
|
|
43
|
+
|
|
44
|
+
/** The path of the dash of an indeterminate checkbox, in the check mark's view box. */
|
|
45
|
+
export const CHECKBOX_DASH = "M4 8h8";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The path a checkbox draws: the dash while it is indeterminate, the check otherwise. The box
|
|
49
|
+
* shows it while the native input is checked or indeterminate.
|
|
50
|
+
*/
|
|
51
|
+
export const checkboxMark = (indeterminate: boolean | undefined) =>
|
|
52
|
+
indeterminate ? CHECKBOX_DASH : CHECKBOX_MARK;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
/** ChipBar's props in every framework, short of the chips. */
|
|
5
|
+
export type ChipBarBaseProps = {
|
|
6
|
+
/** Says what the chips filter, for assistive technology. */
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The scrolling row. It is as tall as the chips' pressable area, which would otherwise be cut
|
|
12
|
+
* off by the scrolling box. The padding leaves room for a focus ring for the same reason, and
|
|
13
|
+
* the margin takes that room back so the first chip lines up with the content around the bar.
|
|
14
|
+
*/
|
|
15
|
+
export const chipBarClass =
|
|
16
|
+
"-m-1 flex min-h-[calc(var(--xds-size-target-min)+var(--xds-space-2))] items-center gap-2 overflow-x-auto p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import type { IconName } from "@xds/svelte/base";
|
|
5
|
+
|
|
6
|
+
/** Chip's props in every framework, short of `onPress`. */
|
|
7
|
+
export type ChipBaseProps = {
|
|
8
|
+
label: string;
|
|
9
|
+
/** Whether the chip's filter is on. The app holds this state. */
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
/** An icon in front of the label. A selected chip shows a check mark in its place. */
|
|
12
|
+
iconStart?: IconName;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The classes of a Chip, a native toggle button. The border is there on every chip,
|
|
18
|
+
* transparent until selected, so selecting does not change the size. The `before` box is the
|
|
19
|
+
* pressable area, which is taller than the chip where fingers need it to be.
|
|
20
|
+
*/
|
|
21
|
+
export function chipClass(selected = false): string {
|
|
22
|
+
return `relative inline-flex h-xds-chip shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-xds-full border px-3 text-xds-label transition-colors duration-(--xds-motion-duration-fast) before:absolute before:inset-x-0 before:top-1/2 before:h-[max(100%,var(--xds-size-target-min))] before:-translate-y-1/2 focus-visible:outline-solid focus-visible:outline-(length:--xds-focus-width) focus-visible:outline-offset-(--xds-focus-offset) focus-visible:outline-xds-border-focus disabled:cursor-not-allowed disabled:border-transparent disabled:bg-xds-chip-disabled-background disabled:text-xds-chip-disabled-text ${
|
|
23
|
+
selected
|
|
24
|
+
? "border-xds-chip-selected-border bg-xds-chip-selected-background text-xds-chip-selected-text enabled:hover:bg-xds-chip-selected-background-hover enabled:active:bg-xds-chip-selected-background-pressed"
|
|
25
|
+
: "border-transparent bg-xds-chip-background text-xds-chip-text enabled:hover:bg-xds-chip-background-hover enabled:active:bg-xds-chip-background-pressed"
|
|
26
|
+
}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The icon in front of the label: a check while selected, so the state is not color alone. */
|
|
30
|
+
export function chipIcon(options: {
|
|
31
|
+
selected?: boolean | undefined;
|
|
32
|
+
iconStart?: IconName | undefined;
|
|
33
|
+
}): IconName | undefined {
|
|
34
|
+
return options.selected ? "check" : options.iconStart;
|
|
35
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
3
|
+
* as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Combobox: Zag's combobox machine. A text field whose list of options, narrowed down by what is
|
|
7
|
+
* typed, opens under it with a Menu's surface; the list is rendered into the body.
|
|
8
|
+
*
|
|
9
|
+
* Parts: `.{{prefix}}-combobox` (the column), `__label`, `__control` (the box), `__input`, `__icon`,
|
|
10
|
+
* `__footer`, `__description`, `__error`; in the list, `__positioner`, `__content` (the surface,
|
|
11
|
+
* which scrolls), `__list` (the list box), `__item`, `__item-words`, `__item-label`,
|
|
12
|
+
* `__item-description`, and `__empty`, said when nothing matches.
|
|
13
|
+
* States: `:focus`, `:disabled` and `[aria-invalid="true"]` on the input, which the box follows
|
|
14
|
+
* through `:has()`; `[data-highlighted]` and `:active` on an item; `[data-side]` on the content.
|
|
15
|
+
* The positioner stacks by `--{{prefix}}-layer-overlay` and Zag's `--layer-index`.
|
|
16
|
+
*/
|
|
17
|
+
@layer components {
|
|
18
|
+
.{{prefix}}-combobox {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: var(--xds-space-1);
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.{{prefix}}-combobox__label {
|
|
26
|
+
width: fit-content;
|
|
27
|
+
font-size: var(--xds-typography-label-size);
|
|
28
|
+
font-weight: var(--xds-typography-label-weight);
|
|
29
|
+
line-height: var(--xds-typography-label-line-height);
|
|
30
|
+
color: var(--xds-color-text-primary);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.{{prefix}}-combobox:has(.{{prefix}}-combobox__input:disabled) .{{prefix}}-combobox__label {
|
|
34
|
+
opacity: 0.5;
|
|
35
|
+
cursor: not-allowed;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* ------------------------------------------------------------ the field */
|
|
40
|
+
|
|
41
|
+
/* A text field's box, with the chevrons at the end that say a list opens from it. */
|
|
42
|
+
.{{prefix}}-combobox__control {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: var(--xds-space-2);
|
|
46
|
+
min-height: var(--xds-size-control-md);
|
|
47
|
+
padding-inline-end: var(--xds-space-3);
|
|
48
|
+
border: var(--xds-border-width-thin) solid var(--xds-color-field-border);
|
|
49
|
+
border-radius: var(--xds-radius-md);
|
|
50
|
+
background-color: var(--xds-color-field-background);
|
|
51
|
+
color: var(--xds-color-field-text);
|
|
52
|
+
transition-property: background-color, border-color, box-shadow;
|
|
53
|
+
transition-duration: var(--xds-motion-duration-fast);
|
|
54
|
+
transition-timing-function: var(--xds-motion-easing-standard);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.{{prefix}}-combobox__control:has(> .{{prefix}}-combobox__input:focus) {
|
|
58
|
+
border-color: var(--xds-color-field-border-focus);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Thicker as well as red, so the state does not depend on telling colors apart. Focused, it
|
|
62
|
+
keeps the red border and outline and drops the inner line. */
|
|
63
|
+
.{{prefix}}-combobox__control:has(> .{{prefix}}-combobox__input[aria-invalid="true"]) {
|
|
64
|
+
border-color: var(--xds-color-field-border-invalid);
|
|
65
|
+
box-shadow: inset 0 0 0 var(--xds-border-width-thin) var(--xds-color-field-border-invalid);
|
|
66
|
+
outline: var(--xds-border-width-thin) solid var(--xds-color-danger-default);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.{{prefix}}-combobox__control:has(> .{{prefix}}-combobox__input[aria-invalid="true"]:focus) {
|
|
70
|
+
box-shadow: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* After the error, which it outranks. */
|
|
74
|
+
@media (hover: hover) {
|
|
75
|
+
.{{prefix}}-combobox__control:hover:not(:has(:focus)) {
|
|
76
|
+
border-color: var(--xds-color-text-primary);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.{{prefix}}-combobox__control:has(> .{{prefix}}-combobox__input:disabled) {
|
|
81
|
+
opacity: 0.5;
|
|
82
|
+
cursor: not-allowed;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.{{prefix}}-combobox__input {
|
|
87
|
+
flex: 1 1 0%;
|
|
88
|
+
min-width: 0;
|
|
89
|
+
align-self: stretch;
|
|
90
|
+
padding-block: 0;
|
|
91
|
+
padding-inline: var(--xds-space-3) 0;
|
|
92
|
+
border: none;
|
|
93
|
+
background: transparent;
|
|
94
|
+
color: inherit;
|
|
95
|
+
/* 16px on every screen: below that, iOS zooms the page when the field takes focus. */
|
|
96
|
+
font-size: var(--xds-typography-body-size);
|
|
97
|
+
line-height: var(--xds-typography-body-line-height);
|
|
98
|
+
outline-style: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.{{prefix}}-combobox__input::placeholder {
|
|
102
|
+
color: var(--xds-color-field-placeholder);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.{{prefix}}-combobox__icon {
|
|
106
|
+
flex: none;
|
|
107
|
+
color: var(--xds-color-field-placeholder);
|
|
108
|
+
pointer-events: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* One line under the box, as under a TextField: the help or the error. Empty, it takes no
|
|
112
|
+
room, and the error stays mounted as a live region. */
|
|
113
|
+
.{{prefix}}-combobox__footer {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: baseline;
|
|
116
|
+
gap: var(--xds-space-3);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.{{prefix}}-combobox__footer:not(:has(> :not(:empty))) {
|
|
120
|
+
position: absolute;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.{{prefix}}-combobox__description,
|
|
124
|
+
.{{prefix}}-combobox__error {
|
|
125
|
+
font-size: var(--xds-typography-detail-size);
|
|
126
|
+
line-height: var(--xds-typography-detail-line-height);
|
|
127
|
+
overflow-wrap: break-word;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.{{prefix}}-combobox__description {
|
|
131
|
+
color: var(--xds-color-text-secondary);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.{{prefix}}-combobox__error {
|
|
135
|
+
color: var(--xds-color-status-danger);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.{{prefix}}-combobox__error:empty {
|
|
139
|
+
position: absolute;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* ------------------------------------------------------------ the list */
|
|
143
|
+
|
|
144
|
+
/* Zag sets the position, and the width: the field's. */
|
|
145
|
+
.{{prefix}}-combobox__positioner {
|
|
146
|
+
z-index: calc(var(--{{prefix}}-layer-overlay) + var(--layer-index, 0));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* A menu's surface. It scrolls when the window has no room for all of it. */
|
|
150
|
+
.{{prefix}}-combobox__content {
|
|
151
|
+
max-height: min(var(--available-height), 20rem);
|
|
152
|
+
overflow-y: auto;
|
|
153
|
+
overscroll-behavior: contain;
|
|
154
|
+
scroll-padding-block: var(--xds-space-1);
|
|
155
|
+
scrollbar-width: thin;
|
|
156
|
+
scrollbar-color: color-mix(in oklab, var(--xds-color-text-primary) 15%, transparent)
|
|
157
|
+
transparent;
|
|
158
|
+
padding: var(--xds-space-1);
|
|
159
|
+
border: var(--xds-border-width-thin) solid var(--xds-color-menu-border);
|
|
160
|
+
border-radius: var(--xds-radius-md);
|
|
161
|
+
background: var(--xds-color-menu-background);
|
|
162
|
+
box-shadow: var(--xds-shadow-raised);
|
|
163
|
+
outline: none;
|
|
164
|
+
transform-origin: var(--transform-origin);
|
|
165
|
+
animation: {{prefix}}-combobox-enter var(--xds-motion-duration-fast) var(--xds-motion-easing-enter);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.{{prefix}}-combobox__content[data-side="top"] {
|
|
169
|
+
animation-name: {{prefix}}-combobox-enter-above;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@media (prefers-reduced-motion: reduce) {
|
|
173
|
+
.{{prefix}}-combobox__content {
|
|
174
|
+
animation: none;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.{{prefix}}-combobox__list {
|
|
179
|
+
outline: none;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* A compact list row, at least the smallest pressable size on a touch screen. */
|
|
183
|
+
.{{prefix}}-combobox__item {
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
gap: var(--xds-space-2);
|
|
187
|
+
min-height: max(var(--xds-size-list-row-compact), var(--xds-size-target-min));
|
|
188
|
+
padding: var(--xds-space-1) var(--xds-space-2);
|
|
189
|
+
border-radius: var(--xds-radius-sm);
|
|
190
|
+
white-space: nowrap;
|
|
191
|
+
font-size: var(--xds-typography-detail-size);
|
|
192
|
+
font-weight: var(--xds-typography-detail-weight);
|
|
193
|
+
line-height: var(--xds-typography-detail-line-height);
|
|
194
|
+
color: var(--xds-color-menu-text);
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
touch-action: manipulation;
|
|
197
|
+
transition: background-color var(--xds-motion-duration-fast) var(--xds-motion-easing-standard);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* The keys and the pointer move one highlight, which the focus does not: it stays in the
|
|
201
|
+
field, where the person types. */
|
|
202
|
+
.{{prefix}}-combobox__item[data-highlighted] {
|
|
203
|
+
background: var(--xds-color-menu-item-background-hover);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.{{prefix}}-combobox__item:active {
|
|
207
|
+
background: var(--xds-color-menu-item-background-pressed);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.{{prefix}}-combobox__item-words {
|
|
211
|
+
display: flex;
|
|
212
|
+
flex: 1 1 0%;
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
min-width: 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.{{prefix}}-combobox__item-label,
|
|
218
|
+
.{{prefix}}-combobox__item-description {
|
|
219
|
+
overflow: hidden;
|
|
220
|
+
text-overflow: ellipsis;
|
|
221
|
+
white-space: nowrap;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.{{prefix}}-combobox__item-description {
|
|
225
|
+
font-size: var(--xds-typography-footnote-size);
|
|
226
|
+
font-weight: var(--xds-typography-footnote-weight);
|
|
227
|
+
line-height: var(--xds-typography-footnote-line-height);
|
|
228
|
+
color: var(--xds-color-text-secondary);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* In the place of the rows, as quiet as a row's help line. */
|
|
232
|
+
.{{prefix}}-combobox__empty {
|
|
233
|
+
padding: var(--xds-space-2);
|
|
234
|
+
font-size: var(--xds-typography-detail-size);
|
|
235
|
+
line-height: var(--xds-typography-detail-line-height);
|
|
236
|
+
color: var(--xds-color-text-secondary);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* Forced colors draw every fill in the page's color, so the highlighted row takes the system's
|
|
240
|
+
highlight, as a Select's does. The browser draws a backplate in the page's color behind text in
|
|
241
|
+
forced colors, which would hide the highlight's text, so these keep their colors, which are the
|
|
242
|
+
system's. */
|
|
243
|
+
@media (forced-colors: active) {
|
|
244
|
+
.{{prefix}}-combobox__item[data-highlighted] {
|
|
245
|
+
forced-color-adjust: none;
|
|
246
|
+
background-color: Highlight;
|
|
247
|
+
color: HighlightText;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.{{prefix}}-combobox__item[data-highlighted] * {
|
|
251
|
+
color: inherit;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* As a Select's list, from the side of the field it opens on. */
|
|
257
|
+
@keyframes {{prefix}}-combobox-enter {
|
|
258
|
+
from {
|
|
259
|
+
opacity: 0;
|
|
260
|
+
transform: translate3d(0, -0.25rem, 0) scale(0.95);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
@keyframes {{prefix}}-combobox-enter-above {
|
|
265
|
+
from {
|
|
266
|
+
opacity: 0;
|
|
267
|
+
transform: translate3d(0, 0.25rem, 0) scale(0.95);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
import type { SelectOption } from "@xds/svelte/base";
|
|
5
|
+
|
|
6
|
+
/** Combobox's props in every framework, short of `onChange`. */
|
|
7
|
+
export type ComboboxBaseProps<Value extends string = string> = {
|
|
8
|
+
/** Always visible, like a TextField's. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** The options to choose from, which what the person types narrows down. */
|
|
11
|
+
options: readonly SelectOption<Value>[];
|
|
12
|
+
/**
|
|
13
|
+
* The chosen option, `undefined` while nothing is chosen. Leave it out for a combobox that
|
|
14
|
+
* keeps its own choice, from `defaultValue`: it is controlled whenever `value` is given, even
|
|
15
|
+
* as `undefined`.
|
|
16
|
+
*/
|
|
17
|
+
value?: Value | undefined;
|
|
18
|
+
/** The first choice of a combobox that keeps its own, without `value`. */
|
|
19
|
+
defaultValue?: Value | undefined;
|
|
20
|
+
/** Shown in the field while it is empty. */
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
/** Help shown under the field. Replaced by `error` while there is one. */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** What is wrong and how to fix it. Clear it when the choice changes. */
|
|
25
|
+
error?: string | undefined;
|
|
26
|
+
/** The name the choice is submitted under with a form. */
|
|
27
|
+
name?: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Said in the list when no option matches what was typed, in place of `noMatches` from the
|
|
31
|
+
* closest Labels.
|
|
32
|
+
*/
|
|
33
|
+
emptyLabel?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const COMBOBOX_PARTS = {
|
|
37
|
+
label: "{{prefix}}-combobox__label",
|
|
38
|
+
control: "{{prefix}}-combobox__control",
|
|
39
|
+
input: "{{prefix}}-combobox__input",
|
|
40
|
+
icon: "{{prefix}}-combobox__icon",
|
|
41
|
+
footer: "{{prefix}}-combobox__footer",
|
|
42
|
+
description: "{{prefix}}-combobox__description",
|
|
43
|
+
error: "{{prefix}}-combobox__error",
|
|
44
|
+
positioner: "{{prefix}}-combobox__positioner",
|
|
45
|
+
content: "{{prefix}}-combobox__content",
|
|
46
|
+
list: "{{prefix}}-combobox__list",
|
|
47
|
+
item: "{{prefix}}-combobox__item",
|
|
48
|
+
itemWords: "{{prefix}}-combobox__item-words",
|
|
49
|
+
itemLabel: "{{prefix}}-combobox__item-label",
|
|
50
|
+
itemDescription: "{{prefix}}-combobox__item-description",
|
|
51
|
+
empty: "{{prefix}}-combobox__empty",
|
|
52
|
+
} as const;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Text as a combobox compares it: in lower case, without accents and with runs of white space
|
|
56
|
+
* as one, so that "sao paulo" finds "São Paulo".
|
|
57
|
+
*/
|
|
58
|
+
export function foldText(text: string): string {
|
|
59
|
+
return text
|
|
60
|
+
.normalize("NFD")
|
|
61
|
+
.replace(/\p{Diacritic}/gu, "")
|
|
62
|
+
.toLocaleLowerCase()
|
|
63
|
+
.replace(/\s+/g, " ")
|
|
64
|
+
.trim();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The options whose label holds what was typed, in their own order, those whose label starts
|
|
69
|
+
* with it first. With nothing typed, every option.
|
|
70
|
+
*/
|
|
71
|
+
export function matchOptions<Option extends { label: string }>(
|
|
72
|
+
options: readonly Option[],
|
|
73
|
+
query: string,
|
|
74
|
+
): Option[] {
|
|
75
|
+
const wanted = foldText(query);
|
|
76
|
+
if (wanted === "") return [...options];
|
|
77
|
+
const starting: Option[] = [];
|
|
78
|
+
const holding: Option[] = [];
|
|
79
|
+
for (const option of options) {
|
|
80
|
+
const label = foldText(option.label);
|
|
81
|
+
if (label.startsWith(wanted)) starting.push(option);
|
|
82
|
+
else if (label.includes(wanted)) holding.push(option);
|
|
83
|
+
}
|
|
84
|
+
return [...starting, ...holding];
|
|
85
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Ejected from `@xds/svelte` 1.2.0 by `xds eject`. This copy is the app's own: change it
|
|
2
|
+
// as you need. `xds eject --list` says which ejected files differ from what was copied.
|
|
3
|
+
|
|
4
|
+
/** CountBadge's props in every framework, short of the child it sits on. */
|
|
5
|
+
export type CountBadgeBaseProps = {
|
|
6
|
+
/** Zero or less draws no badge. */
|
|
7
|
+
count: number;
|
|
8
|
+
/** The largest number shown. A larger count reads "99+". */
|
|
9
|
+
max?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Says what is counted, such as "3 unread notifications". Without it assistive technology
|
|
12
|
+
* reads the number alone.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** The badge, laid out inline or, with `onChild`, on the top end corner of a child. */
|
|
18
|
+
export function countBadgeClass(onChild: boolean): string {
|
|
19
|
+
// Pushed out from the corner by a quarter of its own height, so it overlaps the corner
|
|
20
|
+
// instead of covering the child. `end` follows the layout direction.
|
|
21
|
+
return onChild
|
|
22
|
+
? "absolute end-[calc(var(--xds-size-count-badge)/-4)] top-[calc(var(--xds-size-count-badge)/-4)] inline-flex h-xds-count-badge min-w-xds-count-badge shrink-0 select-none items-center justify-center whitespace-nowrap rounded-full bg-xds-badge-count-background px-1 text-xds-badge-count-text text-xds-footnote"
|
|
23
|
+
: "inline-flex h-xds-count-badge min-w-xds-count-badge shrink-0 select-none items-center justify-center whitespace-nowrap rounded-full bg-xds-badge-count-background px-1 text-xds-badge-count-text text-xds-footnote";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The box around a child that a badge sits on. */
|
|
27
|
+
export const countBadgeAnchorClass = "relative inline-flex w-fit shrink-0";
|
|
28
|
+
|
|
29
|
+
/** What the badge reads: the count, or "99+" past `max`. */
|
|
30
|
+
export function countBadgeText(count: number, max = 99): string {
|
|
31
|
+
return count > max ? `${max}+` : String(count);
|
|
32
|
+
}
|