@xds/react 0.1.0 → 1.0.0-rc.1
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/Accordion.js +191 -33
- package/dist/Avatar.js +65 -6
- package/dist/AvatarStack.js +101 -6
- package/dist/Badge.js +61 -4
- package/dist/Banner.js +161 -5
- package/dist/Button.js +152 -24
- package/dist/Card.js +171 -12
- package/dist/Checkbox.js +138 -3
- package/dist/Chip.js +71 -4
- package/dist/ChipBar.js +36 -3
- package/dist/CountBadge.js +62 -9
- package/dist/DatePicker.js +421 -25
- package/dist/DateRangePicker.js +362 -40
- package/dist/Defaults.js +42 -7
- package/dist/Dialog.js +128 -24
- package/dist/Divider.js +29 -3
- package/dist/EmptyState.js +83 -3
- package/dist/Icon.js +74 -4
- package/dist/IconButton.js +113 -18
- package/dist/ListRow.js +180 -10
- package/dist/MediaCard.js +273 -11
- package/dist/Menu.js +234 -58
- package/dist/ProgressBar.js +63 -4
- package/dist/RadioGroup.js +173 -12
- package/dist/SearchField.js +148 -16
- package/dist/SectionHeader.js +121 -5
- package/dist/SegmentedControl.js +104 -5
- package/dist/Select.js +307 -55
- package/dist/Sidebar.js +212 -19
- package/dist/Skeleton.js +61 -5
- package/dist/Slider.js +142 -35
- package/dist/Spinner.js +93 -4
- package/dist/Switch.js +114 -3
- package/dist/Tabs.js +130 -14
- package/dist/Text.js +42 -4
- package/dist/TextField.js +209 -26
- package/dist/Thumbnail.js +146 -7
- package/dist/Toast.js +118 -30
- package/dist/Tooltip.js +154 -20
- package/dist/base.d.ts +11 -0
- package/dist/base.js +10 -0
- package/dist/modal-popover.js +32 -10
- package/dist/picture.d.ts +6 -4
- package/dist/picture.js +72 -17
- package/dist/portal.js +24 -4
- package/dist/presence.js +30 -9
- package/dist/preview.d.ts +14 -3
- package/dist/preview.js +118 -74
- package/dist/root.js +1 -0
- package/dist/trigger.d.ts +7 -0
- package/dist/trigger.js +41 -8
- package/eject/files/Accordion.tsx +157 -0
- package/eject/files/Avatar.tsx +41 -0
- package/eject/files/AvatarStack.tsx +47 -0
- package/eject/files/Badge.tsx +33 -0
- package/eject/files/Banner.tsx +70 -0
- package/eject/files/Button.tsx +88 -0
- package/eject/files/Card.tsx +85 -0
- package/eject/files/Checkbox.tsx +59 -0
- package/eject/files/Chip.tsx +43 -0
- package/eject/files/ChipBar.tsx +31 -0
- package/eject/files/CountBadge.tsx +50 -0
- package/eject/files/DatePicker.tsx +192 -0
- package/eject/files/DateRangePicker.tsx +271 -0
- package/eject/files/Dialog.tsx +108 -0
- package/eject/files/Divider.tsx +13 -0
- package/eject/files/EmptyState.tsx +39 -0
- package/eject/files/Icon.tsx +38 -0
- package/eject/files/IconButton.tsx +62 -0
- package/eject/files/ListRow.tsx +86 -0
- package/eject/files/MediaCard.tsx +111 -0
- package/eject/files/Menu.tsx +168 -0
- package/eject/files/ProgressBar.tsx +34 -0
- package/eject/files/RadioGroup.tsx +112 -0
- package/eject/files/SearchField.tsx +88 -0
- package/eject/files/SectionHeader.tsx +56 -0
- package/eject/files/SegmentedControl.tsx +57 -0
- package/eject/files/Select.tsx +228 -0
- package/eject/files/Sidebar.tsx +149 -0
- package/eject/files/Skeleton.tsx +28 -0
- package/eject/files/Slider.tsx +109 -0
- package/eject/files/Spinner.tsx +36 -0
- package/eject/files/Switch.tsx +53 -0
- package/eject/files/Tabs.tsx +71 -0
- package/eject/files/Text.tsx +31 -0
- package/eject/files/TextField.tsx +122 -0
- package/eject/files/Thumbnail.tsx +66 -0
- package/eject/files/Toast.tsx +88 -0
- package/eject/files/Tooltip.tsx +120 -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 +68 -0
- package/eject/files/base.css +38 -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 +32 -0
- package/eject/files/chip-bar.ts +16 -0
- package/eject/files/chip.ts +35 -0
- package/eject/files/count-badge.ts +32 -0
- package/eject/files/date-picker.css +352 -0
- package/eject/files/date-picker.ts +250 -0
- package/eject/files/date-range-picker.ts +323 -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/list-row.ts +66 -0
- package/eject/files/media-card.ts +66 -0
- package/eject/files/menu.css +176 -0
- package/eject/files/menu.ts +84 -0
- package/eject/files/parts.ts +17 -0
- package/eject/files/progress-bar.ts +23 -0
- package/eject/files/radio-group.css +160 -0
- package/eject/files/radio-group.ts +24 -0
- package/eject/files/section-header.ts +32 -0
- package/eject/files/segmented-control.ts +30 -0
- package/eject/files/select.css +285 -0
- package/eject/files/select.ts +36 -0
- package/eject/files/sidebar.ts +75 -0
- package/eject/files/skeleton.ts +51 -0
- package/eject/files/slider.css +136 -0
- package/eject/files/slider.ts +65 -0
- package/eject/files/spinner.ts +22 -0
- package/eject/files/switch.ts +34 -0
- package/eject/files/tabs.css +112 -0
- package/eject/files/tabs.ts +35 -0
- package/eject/files/text-field.css +229 -0
- package/eject/files/text-field.ts +48 -0
- package/eject/files/text.ts +38 -0
- package/eject/files/thumbnail.ts +51 -0
- package/eject/files/toast.ts +31 -0
- package/eject/files/tooltip.css +104 -0
- package/eject/files/tooltip.ts +21 -0
- package/eject/manifest.json +814 -0
- package/package.json +9 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
/** Switch's props in every framework, short of `onChange`. */
|
|
5
|
+
export type SwitchBaseProps = {
|
|
6
|
+
checked: boolean;
|
|
7
|
+
/** Shown beside the switch. Pressing it toggles too. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Names the switch for assistive technology when there is no visible label. */
|
|
10
|
+
"aria-label"?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// The focus ring of a control that is drawn next to a visually hidden native input.
|
|
15
|
+
export const PEER_FOCUS =
|
|
16
|
+
"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
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The label around a Switch's input, which is also a Checkbox's: pressing any of it toggles.
|
|
20
|
+
* The input inside is `peer sr-only`, and the parts after it follow its state.
|
|
21
|
+
*/
|
|
22
|
+
export const switchClass =
|
|
23
|
+
"relative inline-flex min-h-xds-target-min w-fit cursor-pointer items-center gap-2 has-disabled:cursor-not-allowed";
|
|
24
|
+
|
|
25
|
+
/** The track, drawn beside the hidden input. */
|
|
26
|
+
export const switchTrackClass = `flex h-xds-switch-height w-xds-switch-width shrink-0 rounded-full bg-xds-switch-track p-0.5 transition-colors duration-(--xds-motion-duration-fast) peer-checked:bg-xds-switch-track-on peer-disabled:bg-xds-switch-disabled-track peer-checked:*:translate-x-[calc(var(--xds-size-switch-width)-var(--xds-size-switch-height))] peer-disabled:*:bg-xds-switch-disabled-thumb ${PEER_FOCUS}`;
|
|
27
|
+
|
|
28
|
+
/** The thumb inside the track. */
|
|
29
|
+
export const switchThumbClass =
|
|
30
|
+
"aspect-square h-full rounded-full bg-xds-switch-thumb transition-transform duration-(--xds-motion-duration-fast) ease-(--xds-motion-easing-standard) motion-reduce:transition-none";
|
|
31
|
+
|
|
32
|
+
/** The visible label after the track, which is also a Checkbox's. */
|
|
33
|
+
export const switchLabelClass =
|
|
34
|
+
"text-xds-body text-xds-text-primary peer-disabled:text-xds-text-secondary";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
* Tabs: Zag's tabs machine, the row alone (the app shows the view).
|
|
7
|
+
*
|
|
8
|
+
* Parts: `.{{prefix}}-tabs` (the root, which scrolls), `__list`, `__tab`, `__indicator`. `.{{prefix}}-tabs--full-width`
|
|
9
|
+
* shares the width between the tabs.
|
|
10
|
+
* States: `[aria-selected="true"]`, `:hover` and `:focus-visible` on a tab; `[data-instant]` and
|
|
11
|
+
* `[hidden]` on the indicator, which Zag places with `--left` and `--width`.
|
|
12
|
+
*/
|
|
13
|
+
@layer components {
|
|
14
|
+
/* The root is what scrolls, so the hairline under the row stays put while the tabs move.
|
|
15
|
+
It is drawn as a shadow inside the box, which lets the selected tab's bar cover it. */
|
|
16
|
+
.{{prefix}}-tabs {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
overflow-x: auto;
|
|
20
|
+
scrollbar-width: none;
|
|
21
|
+
box-shadow: inset 0 calc(-1 * var(--xds-border-width-thin)) 0 var(--xds-color-tabs-border);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.{{prefix}}-tabs::-webkit-scrollbar {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* As wide as its tabs, and never narrower than the row. */
|
|
29
|
+
.{{prefix}}-tabs__list {
|
|
30
|
+
position: relative;
|
|
31
|
+
display: flex;
|
|
32
|
+
width: max-content;
|
|
33
|
+
min-width: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.{{prefix}}-tabs--full-width .{{prefix}}-tabs__list {
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.{{prefix}}-tabs__tab {
|
|
41
|
+
position: relative;
|
|
42
|
+
z-index: 1;
|
|
43
|
+
display: flex;
|
|
44
|
+
flex: none;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
gap: var(--xds-space-2);
|
|
48
|
+
height: var(--xds-size-tab);
|
|
49
|
+
padding-inline: var(--xds-space-4);
|
|
50
|
+
white-space: nowrap;
|
|
51
|
+
text-align: center;
|
|
52
|
+
font-size: var(--xds-typography-label-size);
|
|
53
|
+
font-weight: var(--xds-typography-label-weight);
|
|
54
|
+
line-height: var(--xds-typography-label-line-height);
|
|
55
|
+
color: var(--xds-color-tabs-text);
|
|
56
|
+
outline: none;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
touch-action: manipulation;
|
|
59
|
+
-webkit-tap-highlight-color: transparent;
|
|
60
|
+
transition: color var(--xds-motion-duration-fast) var(--xds-motion-easing-standard);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.{{prefix}}-tabs--full-width .{{prefix}}-tabs__tab {
|
|
64
|
+
flex: 1 1 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Under the pointer a tab takes a color of its own. */
|
|
68
|
+
@media (hover: hover) {
|
|
69
|
+
.{{prefix}}-tabs__tab:not([aria-selected="true"]):hover {
|
|
70
|
+
color: var(--xds-color-tabs-text-hover);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.{{prefix}}-tabs__tab[aria-selected="true"] {
|
|
75
|
+
color: var(--xds-color-tabs-text-selected);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Inside the tab, because the row clips whatever is drawn outside it. */
|
|
79
|
+
.{{prefix}}-tabs__tab:focus-visible {
|
|
80
|
+
outline: var(--xds-focus-width) solid var(--xds-color-border-focus);
|
|
81
|
+
outline-offset: calc(-1 * var(--xds-focus-offset));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* A bar across the bottom edge of the selected tab, over the hairline and under the tabs'
|
|
85
|
+
focus rings. It slides to the tab that is selected next; Zag marks the moves that should
|
|
86
|
+
not slide, such as the first placing. */
|
|
87
|
+
.{{prefix}}-tabs__indicator {
|
|
88
|
+
bottom: 0;
|
|
89
|
+
width: var(--width);
|
|
90
|
+
height: var(--xds-border-width-thick);
|
|
91
|
+
background: var(--xds-color-tabs-indicator);
|
|
92
|
+
transition-property: left, width;
|
|
93
|
+
transition-duration: var(--xds-motion-duration-normal);
|
|
94
|
+
transition-timing-function: var(--xds-motion-easing-standard);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.{{prefix}}-tabs__indicator[data-instant] {
|
|
98
|
+
transition: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Zag hides the bar until it has measured the selected tab, which a page rendered on the
|
|
102
|
+
server shows first: the tab draws the same bar inside itself until then. */
|
|
103
|
+
.{{prefix}}-tabs__list:has(> .{{prefix}}-tabs__indicator[hidden]) > .{{prefix}}-tabs__tab[aria-selected="true"] {
|
|
104
|
+
box-shadow: inset 0 calc(-1 * var(--xds-border-width-thick)) 0 var(--xds-color-tabs-indicator);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (prefers-reduced-motion: reduce) {
|
|
108
|
+
.{{prefix}}-tabs__indicator {
|
|
109
|
+
transition: none;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0-rc.1 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/react/base";
|
|
5
|
+
|
|
6
|
+
/** Tabs' props in every framework, short of `onChange`. */
|
|
7
|
+
export type TabsBaseProps<Value extends string> = {
|
|
8
|
+
items: readonly { value: Value; label: string; icon?: IconName }[];
|
|
9
|
+
/** The selected tab. */
|
|
10
|
+
value: Value;
|
|
11
|
+
/** Says what the tabs switch between, for assistive technology. */
|
|
12
|
+
label: string;
|
|
13
|
+
/** The tabs share the width equally instead of being as wide as their labels. */
|
|
14
|
+
fullWidth?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** The classes of the row's root, which is what scrolls. */
|
|
18
|
+
export function tabsClass(fullWidth = false): string {
|
|
19
|
+
return fullWidth ? "{{prefix}}-tabs {{prefix}}-tabs--full-width" : "{{prefix}}-tabs";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A tab's tabindex. Zag makes the selected tab the row's one stop for Tab and Shift+Tab. A tab
|
|
24
|
+
* can have the focus without being selected, after a press that ended off it or from a script,
|
|
25
|
+
* and the stop would then be another tab of the same row. While a tab has the focus it is the
|
|
26
|
+
* stop, so that Tab and Shift+Tab leave the row from it.
|
|
27
|
+
*/
|
|
28
|
+
export function tabStopIndex<ZagTabIndex>(
|
|
29
|
+
focusedValue: string | null,
|
|
30
|
+
value: string,
|
|
31
|
+
zagTabIndex: ZagTabIndex,
|
|
32
|
+
): ZagTabIndex | 0 | -1 {
|
|
33
|
+
if (focusedValue === null) return zagTabIndex;
|
|
34
|
+
return focusedValue === value ? 0 : -1;
|
|
35
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
* TextField and SearchField: a native <input> or <textarea>.
|
|
7
|
+
*
|
|
8
|
+
* Parts: `.{{prefix}}-text-field` (the column), `__label`, `__control` (what draws the box), `__group` (a
|
|
9
|
+
* control that holds the input and its slots), `__input`, `__slot` with `--leading` or
|
|
10
|
+
* `--trailing`, `__footer`, `__description`, `__error`. `.{{prefix}}-text-field__control--pill` rounds
|
|
11
|
+
* the box fully.
|
|
12
|
+
* States: `:hover`, `:focus`, `:disabled`, `:required` and `[aria-invalid="true"]` on the input;
|
|
13
|
+
* the box and the label follow the input through `:has()`.
|
|
14
|
+
*/
|
|
15
|
+
@layer components {
|
|
16
|
+
.{{prefix}}-text-field {
|
|
17
|
+
/* What a line of text has above and below it inside the box of a one-line field. A text
|
|
18
|
+
area uses it too, so its first line sits where a one-line field has its text and one
|
|
19
|
+
row is exactly as tall as a one-line field. */
|
|
20
|
+
--text-field-inset-block: calc(
|
|
21
|
+
(
|
|
22
|
+
var(--xds-size-control-md) - var(--xds-typography-body-size) *
|
|
23
|
+
var(--xds-typography-body-line-height)
|
|
24
|
+
) /
|
|
25
|
+
2 - var(--xds-border-width-thin)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
gap: var(--xds-space-1);
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.{{prefix}}-text-field__label {
|
|
35
|
+
font-size: var(--xds-typography-label-size);
|
|
36
|
+
font-weight: var(--xds-typography-label-weight);
|
|
37
|
+
line-height: var(--xds-typography-label-line-height);
|
|
38
|
+
color: var(--xds-color-text-primary);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.{{prefix}}-text-field:has(.{{prefix}}-text-field__input:required) .{{prefix}}-text-field__label::after {
|
|
42
|
+
content: "*";
|
|
43
|
+
margin-inline-start: var(--xds-space-0-5);
|
|
44
|
+
color: var(--xds-color-danger-default);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.{{prefix}}-text-field:has(.{{prefix}}-text-field__input:disabled) .{{prefix}}-text-field__label {
|
|
48
|
+
opacity: 0.5;
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ------------------------------------------------------------ the box */
|
|
54
|
+
|
|
55
|
+
/* Drawn by the input itself until something has to sit inside it beside the text; then a
|
|
56
|
+
group draws it and the input inside has none. */
|
|
57
|
+
.{{prefix}}-text-field__control {
|
|
58
|
+
min-height: var(--xds-size-control-md);
|
|
59
|
+
border: var(--xds-border-width-thin) solid var(--xds-color-field-border);
|
|
60
|
+
border-radius: var(--xds-radius-md);
|
|
61
|
+
background-color: var(--xds-color-field-background);
|
|
62
|
+
color: var(--xds-color-field-text);
|
|
63
|
+
outline-style: none;
|
|
64
|
+
transition-property: background-color, border-color, box-shadow;
|
|
65
|
+
transition-duration: var(--xds-motion-duration-fast);
|
|
66
|
+
transition-timing-function: var(--xds-motion-easing-standard);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.{{prefix}}-text-field__control--pill {
|
|
70
|
+
border-radius: var(--xds-radius-full);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.{{prefix}}-text-field__control:focus,
|
|
74
|
+
.{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input:focus) {
|
|
75
|
+
border-color: var(--xds-color-field-border-focus);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Thicker as well as red, so the state does not depend on telling colors apart. */
|
|
79
|
+
.{{prefix}}-text-field__control[aria-invalid="true"],
|
|
80
|
+
.{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input[aria-invalid="true"]) {
|
|
81
|
+
border-color: var(--xds-color-field-border-invalid);
|
|
82
|
+
box-shadow: inset 0 0 0 var(--xds-border-width-thin) var(--xds-color-field-border-invalid);
|
|
83
|
+
outline: var(--xds-border-width-thin) solid var(--xds-color-danger-default);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Focused, an invalid field keeps its red border; a group shows focus instead. */
|
|
87
|
+
.{{prefix}}-text-field__control[aria-invalid="true"]:focus {
|
|
88
|
+
box-shadow: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input[aria-invalid="true"]:focus) {
|
|
92
|
+
border-color: var(--xds-color-field-border-focus);
|
|
93
|
+
box-shadow: none;
|
|
94
|
+
outline-style: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* After the error, which it outranks. */
|
|
98
|
+
@media (hover: hover) {
|
|
99
|
+
.{{prefix}}-text-field__control:hover:not(:focus, :has(:focus)) {
|
|
100
|
+
border-color: var(--xds-color-text-primary);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.{{prefix}}-text-field__control:disabled,
|
|
105
|
+
.{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input:disabled) {
|
|
106
|
+
opacity: 0.5;
|
|
107
|
+
cursor: not-allowed;
|
|
108
|
+
pointer-events: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* ------------------------------------------------------------ the text */
|
|
112
|
+
|
|
113
|
+
.{{prefix}}-text-field__input {
|
|
114
|
+
width: 100%;
|
|
115
|
+
padding-block: 0;
|
|
116
|
+
padding-inline: var(--xds-space-3);
|
|
117
|
+
/* 16px on every screen: below that, iOS zooms the page when the field takes focus. */
|
|
118
|
+
font-size: var(--xds-typography-body-size);
|
|
119
|
+
line-height: var(--xds-typography-body-line-height);
|
|
120
|
+
outline-style: none;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.{{prefix}}-text-field__input::placeholder {
|
|
124
|
+
color: var(--xds-color-field-placeholder);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* `rows` is the height. Longer text scrolls; a handle would let the layout be dragged apart. */
|
|
128
|
+
textarea.{{prefix}}-text-field__input {
|
|
129
|
+
min-height: 0;
|
|
130
|
+
padding-block: var(--text-field-inset-block);
|
|
131
|
+
resize: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.{{prefix}}-text-field__group {
|
|
135
|
+
display: flex;
|
|
136
|
+
align-items: stretch;
|
|
137
|
+
/* For text put straight into a slot. The input has its own size. */
|
|
138
|
+
font-size: var(--xds-font-size-sm);
|
|
139
|
+
line-height: var(--xds-font-line-height-snug);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.{{prefix}}-text-field__group:has(> textarea) {
|
|
143
|
+
align-items: flex-start;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Rounded where it meets the box, so the paint of an autofilled value stays inside it. */
|
|
147
|
+
.{{prefix}}-text-field__group > .{{prefix}}-text-field__input {
|
|
148
|
+
flex: 1;
|
|
149
|
+
min-width: 0;
|
|
150
|
+
border-width: 0;
|
|
151
|
+
border-radius: var(--xds-radius-md);
|
|
152
|
+
background-color: transparent;
|
|
153
|
+
color: inherit;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.{{prefix}}-text-field__slot--leading + .{{prefix}}-text-field__input {
|
|
157
|
+
border-start-start-radius: 0;
|
|
158
|
+
border-end-start-radius: 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.{{prefix}}-text-field__input:has(+ .{{prefix}}-text-field__slot--trailing) {
|
|
162
|
+
border-start-end-radius: 0;
|
|
163
|
+
border-end-end-radius: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* A slot is a full inset away from the edge of the box and a smaller one from the text. */
|
|
167
|
+
.{{prefix}}-text-field__slot--leading + .{{prefix}}-text-field__input {
|
|
168
|
+
padding-inline-start: var(--xds-space-2);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.{{prefix}}-text-field__input:has(+ .{{prefix}}-text-field__slot--trailing) {
|
|
172
|
+
padding-inline-end: var(--xds-space-2);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* As tall as the inside of a one-line field and at the top of the box, which centers a slot
|
|
176
|
+
in a one-line field and lines it up with the first line of a text area. */
|
|
177
|
+
.{{prefix}}-text-field__slot {
|
|
178
|
+
display: flex;
|
|
179
|
+
align-self: flex-start;
|
|
180
|
+
align-items: center;
|
|
181
|
+
justify-content: center;
|
|
182
|
+
height: calc(var(--xds-size-control-md) - 2 * var(--xds-border-width-thin));
|
|
183
|
+
border: 0;
|
|
184
|
+
color: var(--xds-color-field-placeholder);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.{{prefix}}-text-field__slot--leading {
|
|
188
|
+
padding-inline-start: var(--xds-space-3);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.{{prefix}}-text-field__slot--trailing {
|
|
192
|
+
padding-inline-end: var(--xds-space-3);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* ------------------------------------------------------------ under the box */
|
|
196
|
+
|
|
197
|
+
/* The help or the error at the start edge, the count at the end. */
|
|
198
|
+
.{{prefix}}-text-field__footer {
|
|
199
|
+
display: flex;
|
|
200
|
+
align-items: baseline;
|
|
201
|
+
gap: var(--xds-space-3);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* With nothing to show, the line takes no room but stays in the page: the error inside it
|
|
205
|
+
is a live region, which has to be there before a message is put in it for the message to
|
|
206
|
+
be announced. */
|
|
207
|
+
.{{prefix}}-text-field__footer:not(:has(> :not(:empty))) {
|
|
208
|
+
position: absolute;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.{{prefix}}-text-field__description,
|
|
212
|
+
.{{prefix}}-text-field__error {
|
|
213
|
+
font-size: var(--xds-typography-detail-size);
|
|
214
|
+
line-height: var(--xds-typography-detail-line-height);
|
|
215
|
+
overflow-wrap: break-word;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.{{prefix}}-text-field__description {
|
|
219
|
+
color: var(--xds-color-text-secondary);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.{{prefix}}-text-field__error {
|
|
223
|
+
color: var(--xds-color-status-danger);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.{{prefix}}-text-field__error:empty {
|
|
227
|
+
position: absolute;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
/** TextField's props in every framework, short of `onChange` and the `leading` and `trailing` slots. */
|
|
5
|
+
export type TextFieldBaseProps = {
|
|
6
|
+
/** Always visible. A placeholder is not a label: it disappears as soon as the person types. */
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
/** Help shown under the field. Replaced by `error` while there is one. */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** What is wrong and how to fix it. Clear it when the value changes. */
|
|
12
|
+
error?: string | undefined;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
/** A text area of `rows` lines, which scrolls beyond that. `type` does not apply to it. */
|
|
15
|
+
multiline?: boolean;
|
|
16
|
+
rows?: number;
|
|
17
|
+
/** The field takes no more characters than this, and counts them under its end edge. */
|
|
18
|
+
maxLength?: number;
|
|
19
|
+
name?: string;
|
|
20
|
+
type?: TextFieldType;
|
|
21
|
+
inputMode?: "text" | "numeric" | "decimal" | "tel" | "email" | "url" | "search";
|
|
22
|
+
autoComplete?: AutoFill | (string & {});
|
|
23
|
+
autoFocus?: boolean;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** The `type` of a one-line field: the input types that take typed text, and any other. */
|
|
29
|
+
export type TextFieldType =
|
|
30
|
+
| "text"
|
|
31
|
+
| "email"
|
|
32
|
+
| "password"
|
|
33
|
+
| "search"
|
|
34
|
+
| "tel"
|
|
35
|
+
| "url"
|
|
36
|
+
| "number"
|
|
37
|
+
| (string & {});
|
|
38
|
+
|
|
39
|
+
/** SearchField's props in every framework, short of `onChange` and `onSubmit`. */
|
|
40
|
+
export type SearchFieldBaseProps = {
|
|
41
|
+
value: string;
|
|
42
|
+
/** The accessible name. It is not shown: the search icon says what the field is for. */
|
|
43
|
+
label: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/** Names the control that empties the field, for assistive technology. */
|
|
47
|
+
clearLabel?: string;
|
|
48
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
// Written out in full: Tailwind only generates the classes it can find as whole strings.
|
|
5
|
+
const VARIANT = {
|
|
6
|
+
display: "text-xds-display",
|
|
7
|
+
title: "text-xds-title",
|
|
8
|
+
heading: "text-xds-heading",
|
|
9
|
+
body: "text-xds-body",
|
|
10
|
+
"body-strong": "text-xds-body-strong",
|
|
11
|
+
label: "text-xds-label",
|
|
12
|
+
detail: "text-xds-detail",
|
|
13
|
+
footnote: "text-xds-footnote",
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
const TONE = {
|
|
17
|
+
primary: "text-xds-text-primary",
|
|
18
|
+
secondary: "text-xds-text-secondary",
|
|
19
|
+
accent: "text-xds-text-accent",
|
|
20
|
+
danger: "text-xds-status-danger",
|
|
21
|
+
success: "text-xds-status-success",
|
|
22
|
+
warning: "text-xds-status-warning",
|
|
23
|
+
/** Takes the color of the surrounding text. */
|
|
24
|
+
inherit: "",
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
export type TextVariant = keyof typeof VARIANT;
|
|
28
|
+
export type TextTone = keyof typeof TONE;
|
|
29
|
+
|
|
30
|
+
export type TextBaseProps = {
|
|
31
|
+
/** What the text is for. Sets size, weight, line height and tracking together. */
|
|
32
|
+
variant?: TextVariant;
|
|
33
|
+
tone?: TextTone;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function textClass({ variant = "body", tone = "primary" }: TextBaseProps = {}): string {
|
|
37
|
+
return `${VARIANT[variant]} ${TONE[tone]}`;
|
|
38
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
// Written out in full: Tailwind only generates the classes it can find as whole strings.
|
|
5
|
+
const RATIO = {
|
|
6
|
+
"16:9": "aspect-video",
|
|
7
|
+
"1:1": "aspect-square",
|
|
8
|
+
"4:3": "aspect-[4/3]",
|
|
9
|
+
"9:16": "aspect-[9/16]",
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export type ThumbnailRatio = keyof typeof RATIO;
|
|
13
|
+
|
|
14
|
+
/** Thumbnail's props in every framework. */
|
|
15
|
+
export type ThumbnailBaseProps = {
|
|
16
|
+
/** The URL of the picture. While it loads, when it fails and without one, a placeholder shows. */
|
|
17
|
+
src?: string | undefined;
|
|
18
|
+
/** Describes the picture. An empty string makes it decoration, skipped by screen readers. */
|
|
19
|
+
alt: string;
|
|
20
|
+
/** Width to height. Defaults to `16:9`. */
|
|
21
|
+
ratio?: ThumbnailRatio;
|
|
22
|
+
/** Short text on the bottom end corner, such as a duration. */
|
|
23
|
+
badge?: string;
|
|
24
|
+
/** How much was watched, from 0 to 1, as a bar across the bottom edge. 0 draws none. */
|
|
25
|
+
progress?: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function thumbnailClass(ratio: ThumbnailRatio = "16:9"): string {
|
|
29
|
+
return `relative block w-full overflow-hidden rounded-xds-md bg-xds-thumbnail-background ${RATIO[ratio]}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The share of the progress bar that is filled, from 0 to 1. */
|
|
33
|
+
export function thumbnailWatched(progress = 0): number {
|
|
34
|
+
return Math.min(1, Math.max(0, progress));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Where the badge sits: above the progress bar when there is one. */
|
|
38
|
+
export function thumbnailBadgeClass(watched: number): string {
|
|
39
|
+
// With the same space between the badge and the bar as between the badge and the edges.
|
|
40
|
+
return watched > 0
|
|
41
|
+
? "absolute end-2 bottom-[calc(var(--xds-space-1)+var(--xds-space-2))]"
|
|
42
|
+
: "absolute end-2 bottom-2";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const THUMBNAIL_PARTS = {
|
|
46
|
+
/** The box that always shows: the icon, and the picture over it. */
|
|
47
|
+
placeholder: "absolute inset-0 flex items-center justify-center text-xds-thumbnail-icon",
|
|
48
|
+
track: "absolute inset-x-0 bottom-0 h-(--xds-space-1) bg-xds-overlay-background",
|
|
49
|
+
/** Takes its width from the progress, as a percentage. */
|
|
50
|
+
fill: "block h-full bg-xds-overlay-accent",
|
|
51
|
+
} as const;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
/** One thing the person can do about a toast's message, such as undoing it. */
|
|
5
|
+
export type ToastAction = { label: string; onPress: () => void };
|
|
6
|
+
|
|
7
|
+
/** Toast's props in every framework, short of `onClose`. */
|
|
8
|
+
export type ToastBaseProps = {
|
|
9
|
+
/** Whether the toast is shown. It never closes itself: this decides. */
|
|
10
|
+
open: boolean;
|
|
11
|
+
message: string;
|
|
12
|
+
/** One thing the person can do about the message, such as undoing it. */
|
|
13
|
+
action?: ToastAction;
|
|
14
|
+
/** How long it stays, in milliseconds. 0 keeps it until it is closed. */
|
|
15
|
+
duration?: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const TOAST_PARTS = {
|
|
19
|
+
// `manual` popover: nothing but the component shows or hides it, and it does not close other
|
|
20
|
+
// popovers. The region itself is see-through to the pointer; only the toast is not. On a
|
|
21
|
+
// phone the bottom inset keeps it clear of the home indicator.
|
|
22
|
+
region:
|
|
23
|
+
"pointer-events-none fixed inset-x-0 top-auto bottom-0 m-0 w-full max-w-none justify-center overflow-visible border-0 bg-transparent p-4 pb-[calc(var(--xds-space-4)+env(safe-area-inset-bottom))] [&:popover-open]:flex",
|
|
24
|
+
toast:
|
|
25
|
+
"pointer-events-auto flex max-w-xds-toast animate-[xds-toast-enter_var(--xds-motion-duration-normal)_var(--xds-motion-easing-enter)] items-center gap-4 rounded-xds-md bg-xds-toast-background px-4 py-3 text-xds-toast-text shadow-xds-raised motion-reduce:animate-none",
|
|
26
|
+
message: "min-w-0 text-xds-detail",
|
|
27
|
+
// Pulled into the toast's padding, so a pressable area of the minimum size does not make a
|
|
28
|
+
// one-line toast taller.
|
|
29
|
+
action:
|
|
30
|
+
"-my-2 min-h-xds-target-min min-w-xds-target-min shrink-0 cursor-pointer rounded-xds-sm text-xds-label text-xds-toast-action hover:underline focus-visible:outline-solid focus-visible:outline-(length:--xds-focus-width) focus-visible:outline-offset-(--xds-focus-offset) focus-visible:outline-current",
|
|
31
|
+
} as const;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ejected from `@xds/react` 1.0.0-rc.1 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
|
+
* Tooltip: Zag's tooltip machine, rendered into the body only while open or animating out.
|
|
7
|
+
*
|
|
8
|
+
* Parts: `.{{prefix}}-tooltip__positioner` (placed by Zag), `.{{prefix}}-tooltip` (role="tooltip"),
|
|
9
|
+
* `.{{prefix}}-tooltip__shortcut` (a key hint after the label).
|
|
10
|
+
* States: `[data-side]` on the tooltip for the side of the control it is on, and
|
|
11
|
+
* `[data-state="closed"]` while it animates out.
|
|
12
|
+
*/
|
|
13
|
+
@layer components {
|
|
14
|
+
.{{prefix}}-tooltip__positioner {
|
|
15
|
+
z-index: calc(var(--xds-layer-overlay) + var(--layer-index, 0));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.{{prefix}}-tooltip {
|
|
19
|
+
/* The widest a tooltip gets; a longer label wraps. */
|
|
20
|
+
max-width: 20rem;
|
|
21
|
+
padding: var(--xds-space-1) var(--xds-space-2);
|
|
22
|
+
border-radius: var(--xds-radius-sm);
|
|
23
|
+
background: var(--xds-color-tooltip-background);
|
|
24
|
+
font-size: var(--xds-typography-footnote-size);
|
|
25
|
+
font-weight: var(--xds-typography-footnote-weight);
|
|
26
|
+
line-height: var(--xds-typography-footnote-line-height);
|
|
27
|
+
color: var(--xds-color-tooltip-text);
|
|
28
|
+
transform-origin: var(--transform-origin);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* It grows in from the control's side. */
|
|
32
|
+
.{{prefix}}-tooltip[data-side="top"] {
|
|
33
|
+
animation: {{prefix}}-tooltip-enter-up var(--xds-motion-duration-fast)
|
|
34
|
+
var(--xds-motion-easing-enter);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.{{prefix}}-tooltip[data-side="bottom"] {
|
|
38
|
+
animation: {{prefix}}-tooltip-enter-down var(--xds-motion-duration-fast)
|
|
39
|
+
var(--xds-motion-easing-enter);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.{{prefix}}-tooltip[data-side="left"] {
|
|
43
|
+
animation: {{prefix}}-tooltip-enter-left var(--xds-motion-duration-fast)
|
|
44
|
+
var(--xds-motion-easing-enter);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.{{prefix}}-tooltip[data-side="right"] {
|
|
48
|
+
animation: {{prefix}}-tooltip-enter-right var(--xds-motion-duration-fast)
|
|
49
|
+
var(--xds-motion-easing-enter);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* After the rules above, which it replaces. */
|
|
53
|
+
.{{prefix}}-tooltip[data-state="closed"] {
|
|
54
|
+
animation: xds-overlay-exit var(--xds-motion-duration-fast) var(--xds-motion-easing-exit)
|
|
55
|
+
forwards;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (prefers-reduced-motion: reduce) {
|
|
59
|
+
.{{prefix}}-tooltip[data-side],
|
|
60
|
+
.{{prefix}}-tooltip[data-state="closed"] {
|
|
61
|
+
animation: none;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* A key hint: the same text in a hairline box of its own, in the text's color, which is
|
|
66
|
+
the one color known to stand out from the tooltip. */
|
|
67
|
+
.{{prefix}}-tooltip__shortcut {
|
|
68
|
+
margin-inline-start: var(--xds-space-2);
|
|
69
|
+
padding-inline: var(--xds-space-1);
|
|
70
|
+
border: var(--xds-border-width-thin) solid currentColor;
|
|
71
|
+
border-radius: calc(var(--xds-radius-sm) - var(--xds-space-0-5));
|
|
72
|
+
font: inherit;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Literal offsets and scales: a custom property inside a keyframe keeps WebKit from running the
|
|
77
|
+
animation on the compositor. */
|
|
78
|
+
@keyframes {{prefix}}-tooltip-enter-up {
|
|
79
|
+
from {
|
|
80
|
+
opacity: 0;
|
|
81
|
+
transform: translate3d(0, 0.25rem, 0) scale(0.9);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@keyframes {{prefix}}-tooltip-enter-down {
|
|
86
|
+
from {
|
|
87
|
+
opacity: 0;
|
|
88
|
+
transform: translate3d(0, -0.25rem, 0) scale(0.9);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@keyframes {{prefix}}-tooltip-enter-left {
|
|
93
|
+
from {
|
|
94
|
+
opacity: 0;
|
|
95
|
+
transform: translate3d(0.25rem, 0, 0) scale(0.9);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@keyframes {{prefix}}-tooltip-enter-right {
|
|
100
|
+
from {
|
|
101
|
+
opacity: 0;
|
|
102
|
+
transform: translate3d(-0.25rem, 0, 0) scale(0.9);
|
|
103
|
+
}
|
|
104
|
+
}
|