@xds/react 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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,176 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ejected from `@xds/react` 0.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
|
+
* Menu: Zag's menu machine. The list stays in the body, hidden while closed once it has
|
|
7
|
+
* animated out.
|
|
8
|
+
*
|
|
9
|
+
* Parts: `.{{prefix}}-menu__trigger` (added to the Button or IconButton that opens it),
|
|
10
|
+
* `.{{prefix}}-menu__underlay` (over the page while the menu is open), `.{{prefix}}-menu__positioner` (placed by
|
|
11
|
+
* Zag), `.{{prefix}}-menu` (the surface, role="menu"), `.{{prefix}}-menu__item` with `.{{prefix}}-menu__item--danger`,
|
|
12
|
+
* `.{{prefix}}-menu__item-icon`, `.{{prefix}}-menu__separator`.
|
|
13
|
+
* States: `[aria-expanded="true"]` on the trigger while open, `[data-highlighted]` on the row
|
|
14
|
+
* the arrow keys or the pointer are on (focus stays on the menu, so it is the only sign of it),
|
|
15
|
+
* `:active` while pressed, `[data-disabled]`, `[data-side]` on the surface for the side it
|
|
16
|
+
* opened on, and `[data-state="closed"]` on it while it animates out.
|
|
17
|
+
*/
|
|
18
|
+
@layer components {
|
|
19
|
+
/* The trigger stays pressed while its menu is open, which ties the menu to the control it
|
|
20
|
+
came from. The underlay is over it, so the pointer does not turn it back to its hover
|
|
21
|
+
fill. */
|
|
22
|
+
.{{prefix}}-menu__trigger[aria-expanded="true"] {
|
|
23
|
+
background-color: var(--button-bg-pressed);
|
|
24
|
+
transform: scale(var(--xds-motion-press-scale));
|
|
25
|
+
will-change: transform;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@media (prefers-reduced-motion: reduce) {
|
|
29
|
+
.{{prefix}}-menu__trigger[aria-expanded="true"] {
|
|
30
|
+
transform: none;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Over the page and under the open menu: a press outside lands here and only closes the
|
|
35
|
+
menu, and nothing on the page reacts to the pointer meanwhile. Rendered before the
|
|
36
|
+
positioner, it is under it at the same level. Inside a dialog it is above the dialog,
|
|
37
|
+
which was rendered earlier. */
|
|
38
|
+
.{{prefix}}-menu__underlay {
|
|
39
|
+
position: fixed;
|
|
40
|
+
inset: 0;
|
|
41
|
+
z-index: var(--xds-layer-overlay);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.{{prefix}}-menu__positioner {
|
|
45
|
+
z-index: calc(var(--xds-layer-overlay) + var(--layer-index, 0));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.{{prefix}}-menu {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
/* Four times `space.12`: wide enough that a menu of short words does not look like a
|
|
52
|
+
stack of chips. Beyond that it is as wide as its longest row. */
|
|
53
|
+
min-width: calc(4 * var(--xds-space-12));
|
|
54
|
+
max-width: calc(100svw - 2 * var(--xds-space-4));
|
|
55
|
+
max-height: var(--available-height);
|
|
56
|
+
padding: var(--xds-space-1);
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
overscroll-behavior: contain;
|
|
59
|
+
scroll-padding-block: var(--xds-space-1);
|
|
60
|
+
scrollbar-width: thin;
|
|
61
|
+
border: var(--xds-border-width-thin) solid var(--xds-color-menu-border);
|
|
62
|
+
border-radius: var(--xds-radius-md);
|
|
63
|
+
background: var(--xds-color-menu-background);
|
|
64
|
+
box-shadow: var(--xds-shadow-raised);
|
|
65
|
+
outline: none;
|
|
66
|
+
transform-origin: var(--transform-origin);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* It grows in from the trigger's side. */
|
|
70
|
+
.{{prefix}}-menu[data-side="bottom"] {
|
|
71
|
+
animation: {{prefix}}-menu-enter-down var(--xds-motion-duration-fast) var(--xds-motion-easing-enter);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.{{prefix}}-menu[data-side="top"] {
|
|
75
|
+
animation: {{prefix}}-menu-enter-up var(--xds-motion-duration-fast) var(--xds-motion-easing-enter);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* After the rules above, which it replaces. A closing menu takes no more presses. */
|
|
79
|
+
.{{prefix}}-menu[data-state="closed"] {
|
|
80
|
+
animation: xds-overlay-exit var(--xds-motion-duration-fast) var(--xds-motion-easing-exit)
|
|
81
|
+
forwards;
|
|
82
|
+
pointer-events: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@media (prefers-reduced-motion: reduce) {
|
|
86
|
+
.{{prefix}}-menu[data-side],
|
|
87
|
+
.{{prefix}}-menu[data-state="closed"] {
|
|
88
|
+
animation: none;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* A row of a menu looks like a compact list row. A compact row is shorter than a finger
|
|
93
|
+
needs, so on a touch screen it grows to the smallest pressable size. The padding above and
|
|
94
|
+
below only shows on a row of two lines. */
|
|
95
|
+
.{{prefix}}-menu__item {
|
|
96
|
+
position: relative;
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: flex-start;
|
|
100
|
+
gap: var(--xds-space-2);
|
|
101
|
+
width: 100%;
|
|
102
|
+
min-height: max(var(--xds-size-list-row-compact), var(--xds-size-target-min));
|
|
103
|
+
padding: var(--xds-space-1) var(--xds-space-2);
|
|
104
|
+
border-radius: var(--xds-radius-sm);
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
font-size: var(--xds-typography-detail-size);
|
|
107
|
+
font-weight: var(--xds-typography-detail-weight);
|
|
108
|
+
line-height: var(--xds-typography-detail-line-height);
|
|
109
|
+
color: var(--xds-color-menu-text);
|
|
110
|
+
outline: none;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
touch-action: manipulation;
|
|
113
|
+
-webkit-tap-highlight-color: transparent;
|
|
114
|
+
transition: background-color var(--xds-motion-duration-fast) var(--xds-motion-easing-standard);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.{{prefix}}-menu__item-icon {
|
|
118
|
+
color: var(--xds-color-menu-icon);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* The pointer moves the same highlight as the arrow keys, so one rule draws both. The
|
|
122
|
+
highlight is a fill, which shows inside the menu where a focus ring would be clipped. */
|
|
123
|
+
.{{prefix}}-menu__item[data-highlighted] {
|
|
124
|
+
background: var(--xds-color-menu-item-background-hover);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* A press that drags does not select the row's text. */
|
|
128
|
+
.{{prefix}}-menu__item:active {
|
|
129
|
+
background: var(--xds-color-menu-item-background-pressed);
|
|
130
|
+
user-select: none;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.{{prefix}}-menu__item--danger,
|
|
134
|
+
.{{prefix}}-menu__item--danger .{{prefix}}-menu__item-icon {
|
|
135
|
+
color: var(--xds-color-menu-danger-text);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.{{prefix}}-menu__item--danger[data-highlighted],
|
|
139
|
+
.{{prefix}}-menu__item--danger:active {
|
|
140
|
+
background: var(--xds-color-menu-danger-background-hover);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* Recolored, not faded, like a disabled button. */
|
|
144
|
+
.{{prefix}}-menu__item[data-disabled],
|
|
145
|
+
.{{prefix}}-menu__item[data-disabled] .{{prefix}}-menu__item-icon {
|
|
146
|
+
color: var(--xds-color-menu-text-disabled);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.{{prefix}}-menu__item[data-disabled] {
|
|
150
|
+
cursor: not-allowed;
|
|
151
|
+
pointer-events: none;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.{{prefix}}-menu__separator {
|
|
155
|
+
flex-shrink: 0;
|
|
156
|
+
height: var(--xds-border-width-thin);
|
|
157
|
+
margin-block: var(--xds-space-1);
|
|
158
|
+
background: var(--xds-color-menu-border);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* Literal offsets and scales: a custom property inside a keyframe keeps WebKit from running the
|
|
163
|
+
animation on the compositor. */
|
|
164
|
+
@keyframes {{prefix}}-menu-enter-down {
|
|
165
|
+
from {
|
|
166
|
+
opacity: 0;
|
|
167
|
+
transform: translate3d(0, -0.25rem, 0) scale(0.9);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@keyframes {{prefix}}-menu-enter-up {
|
|
172
|
+
from {
|
|
173
|
+
opacity: 0;
|
|
174
|
+
transform: translate3d(0, 0.25rem, 0) scale(0.9);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 0.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/react/base";
|
|
5
|
+
|
|
6
|
+
export type MenuItem =
|
|
7
|
+
| "separator"
|
|
8
|
+
| {
|
|
9
|
+
label: string;
|
|
10
|
+
icon?: IconName;
|
|
11
|
+
onSelect: () => void;
|
|
12
|
+
/** An action that destroys something. Drawn in the danger color. */
|
|
13
|
+
danger?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** The current choice among its neighbours. Marked with a check at the end of the row. */
|
|
16
|
+
selected?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Menu's props in every framework, short of its trigger. */
|
|
20
|
+
export type MenuBaseProps = {
|
|
21
|
+
/** Names the menu for assistive technology. */
|
|
22
|
+
label: string;
|
|
23
|
+
items: readonly MenuItem[];
|
|
24
|
+
/** The edge of the trigger the menu lines up with. */
|
|
25
|
+
align?: "start" | "end";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** The class of a row of the menu. The highlight and the disabled look come from attributes. */
|
|
29
|
+
export function menuItemClass(danger = false): string {
|
|
30
|
+
return danger ? "{{prefix}}-menu__item {{prefix}}-menu__item--danger" : "{{prefix}}-menu__item";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The box to place a menu against: its trigger's box before the transform that scales the
|
|
35
|
+
* trigger about its center while the menu is open, so the menu stays where it opened.
|
|
36
|
+
*/
|
|
37
|
+
export function layoutRect(element: HTMLElement): {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
} {
|
|
43
|
+
const box = element.getBoundingClientRect();
|
|
44
|
+
const style = getComputedStyle(element);
|
|
45
|
+
const width = Number.parseFloat(style.width);
|
|
46
|
+
const height = Number.parseFloat(style.height);
|
|
47
|
+
return {
|
|
48
|
+
x: box.x + (box.width - width) / 2,
|
|
49
|
+
y: box.y + (box.height - height) / 2,
|
|
50
|
+
width,
|
|
51
|
+
height,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether a press on a menu's trigger opens the menu as the button goes down rather than on
|
|
57
|
+
* the click: the main button of a mouse, without Control (which asks for the context menu on a
|
|
58
|
+
* Mac), on an enabled trigger. The pressed trigger then takes the focus, so the focus that
|
|
59
|
+
* comes back to it when the menu closes shows no keyboard ring. Touch and pen open it on the
|
|
60
|
+
* click, as Zag does.
|
|
61
|
+
*/
|
|
62
|
+
export function opensOnPress(event: {
|
|
63
|
+
pointerType: string;
|
|
64
|
+
button: number;
|
|
65
|
+
ctrlKey: boolean;
|
|
66
|
+
currentTarget: EventTarget | null;
|
|
67
|
+
}): boolean {
|
|
68
|
+
return (
|
|
69
|
+
event.pointerType === "mouse" &&
|
|
70
|
+
event.button === 0 &&
|
|
71
|
+
!event.ctrlKey &&
|
|
72
|
+
!(event.currentTarget instanceof Element && event.currentTarget.matches(":disabled"))
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The value of the first item that can be chosen, by position as the rows are: where the
|
|
78
|
+
* highlight goes when a screen reader or a script opens the menu with a click, as the keyboard
|
|
79
|
+
* puts it there, so the next key works the list at once.
|
|
80
|
+
*/
|
|
81
|
+
export function firstMenuValue(items: readonly MenuItem[]): string | undefined {
|
|
82
|
+
const first = items.findIndex((item) => item !== "separator" && !item.disabled);
|
|
83
|
+
return first >= 0 ? String(first) : undefined;
|
|
84
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 0.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
|
+
/**
|
|
5
|
+
* The class on the root element of every web component, `{{prefix}}-` and its name in kebab case
|
|
6
|
+
* (`{{prefix}}-icon-button`). It is the component's stable handle for an app's own styles, beside the
|
|
7
|
+
* part classes of the components drawn with a stylesheet (`{{prefix}}-dialog__title`) and the state
|
|
8
|
+
* attributes (`aria-*`, `data-state`). A published library names it after itself.
|
|
9
|
+
*/
|
|
10
|
+
export function rootPart(component: string): string {
|
|
11
|
+
return `{{prefix}}-${component.replace(/[A-Z]/g, (letter, index: number) => `${index ? "-" : ""}${letter.toLowerCase()}`)}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Joins the classes that are given, skipping those that are not. */
|
|
15
|
+
export function classes(...names: (string | false | null | undefined)[]): string {
|
|
16
|
+
return names.filter(Boolean).join(" ");
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 0.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
|
+
/** ProgressBar's props in every framework. */
|
|
5
|
+
export type ProgressBarBaseProps = {
|
|
6
|
+
/** How far along, from 0 to 1. Values outside are clamped. */
|
|
7
|
+
value: number;
|
|
8
|
+
/** Says what is progressing; a screen reader reads it with the percentage. */
|
|
9
|
+
label: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/** The whole percentage a value from 0 to 1 stands for, clamped to 0 to 100. */
|
|
13
|
+
export function progressPercent(value: number): number {
|
|
14
|
+
return Math.round(Math.min(1, Math.max(0, value)) * 100);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The track. It has the progress bar role and holds the fill. */
|
|
18
|
+
export const progressBarClass =
|
|
19
|
+
"h-xds-progress w-full overflow-hidden rounded-full bg-xds-progress-track";
|
|
20
|
+
|
|
21
|
+
/** The fill, whose width is the percentage. */
|
|
22
|
+
export const progressBarFillClass =
|
|
23
|
+
"h-full rounded-full bg-xds-progress-fill transition-[width] duration-(--xds-motion-duration-normal) motion-reduce:transition-none";
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ejected from `@xds/react` 0.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
|
+
* RadioGroup: native radio buttons, hidden and drawn beside, in a group named by its legend.
|
|
7
|
+
*
|
|
8
|
+
* Parts: `.{{prefix}}-radio-group` (the column), `__label` (the legend), `__options`, `__option` (the
|
|
9
|
+
* pressable row, a <label>), `__input` (the hidden radio), `__row`, `__circle-line`, `__circle`,
|
|
10
|
+
* `__dot`, `__words`, `__text`, `__description`, `__error`.
|
|
11
|
+
* States: `:checked`, `:focus-visible` and `:disabled` on the input; the row and the legend
|
|
12
|
+
* follow it through `:has()`.
|
|
13
|
+
*/
|
|
14
|
+
@layer components {
|
|
15
|
+
.{{prefix}}-radio-group {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.{{prefix}}-radio-group__label {
|
|
21
|
+
margin-bottom: var(--xds-space-1);
|
|
22
|
+
font-size: var(--xds-typography-label-size);
|
|
23
|
+
font-weight: var(--xds-typography-label-weight);
|
|
24
|
+
line-height: var(--xds-typography-label-line-height);
|
|
25
|
+
color: var(--xds-color-text-primary);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.{{prefix}}-radio-group__options {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: var(--xds-space-2);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.{{prefix}}-radio-group__option {
|
|
35
|
+
position: relative;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
width: fit-content;
|
|
39
|
+
min-height: var(--xds-size-target-min);
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
user-select: none;
|
|
42
|
+
touch-action: manipulation;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.{{prefix}}-radio-group__row {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: flex-start;
|
|
48
|
+
gap: var(--xds-space-2);
|
|
49
|
+
font-size: var(--xds-typography-body-size);
|
|
50
|
+
font-weight: var(--xds-typography-body-weight);
|
|
51
|
+
line-height: var(--xds-typography-body-line-height);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* The circle sits on the first line of the label, however many lines the label wraps to.
|
|
55
|
+
`1lh` is the height of that line; on a touch screen the circle may be the taller of the
|
|
56
|
+
two. */
|
|
57
|
+
.{{prefix}}-radio-group__circle-line {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-shrink: 0;
|
|
60
|
+
align-items: center;
|
|
61
|
+
height: max(1lh, var(--xds-size-radio));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.{{prefix}}-radio-group__circle {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
width: var(--xds-size-radio);
|
|
69
|
+
height: var(--xds-size-radio);
|
|
70
|
+
border-radius: calc(infinity * 1px);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Half of the whole circle, ring included, not of the space inside it. */
|
|
74
|
+
.{{prefix}}-radio-group__dot {
|
|
75
|
+
display: none;
|
|
76
|
+
width: calc(var(--xds-size-radio) / 2);
|
|
77
|
+
height: calc(var(--xds-size-radio) / 2);
|
|
78
|
+
border-radius: calc(infinity * 1px);
|
|
79
|
+
background-color: var(--xds-color-radio-dot);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:checked) .{{prefix}}-radio-group__dot {
|
|
83
|
+
display: block;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Around the circle, as around a checkbox's box. */
|
|
87
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:focus-visible)
|
|
88
|
+
.{{prefix}}-radio-group__circle {
|
|
89
|
+
outline: var(--xds-focus-width) solid var(--xds-color-border-focus);
|
|
90
|
+
outline-offset: var(--xds-focus-offset);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* The whole group is enabled or disabled, so the circle has one look or the other. Enabled,
|
|
94
|
+
a thin ring at rest and a thick one around a dot when chosen, so the choice does not
|
|
95
|
+
depend on color; disabled, filled instead of outlined, like a disabled checkbox. */
|
|
96
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:disabled) .{{prefix}}-radio-group__circle {
|
|
97
|
+
background-color: var(--xds-color-radio-disabled-background);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:enabled) .{{prefix}}-radio-group__circle {
|
|
101
|
+
border: var(--xds-border-width-thin) solid var(--xds-color-radio-border);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:enabled:checked)
|
|
105
|
+
.{{prefix}}-radio-group__circle {
|
|
106
|
+
border-width: var(--xds-border-width-thick);
|
|
107
|
+
border-color: var(--xds-color-radio-border-checked);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* The label and the description under it. */
|
|
111
|
+
.{{prefix}}-radio-group__words {
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
min-width: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.{{prefix}}-radio-group__text {
|
|
118
|
+
color: var(--xds-color-text-primary);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.{{prefix}}-radio-group__description {
|
|
122
|
+
font-size: var(--xds-typography-detail-size);
|
|
123
|
+
line-height: var(--xds-typography-detail-line-height);
|
|
124
|
+
overflow-wrap: break-word;
|
|
125
|
+
color: var(--xds-color-text-secondary);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* An inline run in its live region, which is as tall as a line of the group's text. */
|
|
129
|
+
.{{prefix}}-radio-group__error {
|
|
130
|
+
margin-top: var(--xds-space-1);
|
|
131
|
+
font-size: var(--xds-typography-detail-size);
|
|
132
|
+
line-height: var(--xds-typography-detail-line-height);
|
|
133
|
+
overflow-wrap: break-word;
|
|
134
|
+
color: var(--xds-color-status-danger);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* ------------------------------------------------------------ disabled */
|
|
138
|
+
|
|
139
|
+
/* The text is recolored rather than faded. */
|
|
140
|
+
.{{prefix}}-radio-group:has(.{{prefix}}-radio-group__input:disabled) .{{prefix}}-radio-group__label {
|
|
141
|
+
color: var(--xds-color-text-disabled);
|
|
142
|
+
cursor: not-allowed;
|
|
143
|
+
pointer-events: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:disabled) {
|
|
147
|
+
cursor: not-allowed;
|
|
148
|
+
pointer-events: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:disabled) .{{prefix}}-radio-group__dot {
|
|
152
|
+
background-color: var(--xds-color-radio-disabled-dot);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:disabled) .{{prefix}}-radio-group__text,
|
|
156
|
+
.{{prefix}}-radio-group__option:has(> .{{prefix}}-radio-group__input:disabled)
|
|
157
|
+
.{{prefix}}-radio-group__description {
|
|
158
|
+
color: var(--xds-color-text-disabled);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 0.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
|
+
export type RadioOption<Value extends string = string> = {
|
|
5
|
+
value: Value;
|
|
6
|
+
label: string;
|
|
7
|
+
/** A line of help under the label. */
|
|
8
|
+
description?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** RadioGroup's props in every framework, short of `onChange`. */
|
|
12
|
+
export type RadioGroupBaseProps<Value extends string = string> = {
|
|
13
|
+
/** The group's visible legend, which also names it for assistive technology. */
|
|
14
|
+
label: string;
|
|
15
|
+
options: readonly RadioOption<Value>[];
|
|
16
|
+
/** The chosen option. Leave it out while nothing is chosen. */
|
|
17
|
+
value?: Value | undefined;
|
|
18
|
+
/** Disables the whole group. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** What is wrong and how to fix it, under the options. 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
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 0.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/react/base";
|
|
5
|
+
|
|
6
|
+
/** SectionHeader's props in every framework, short of its action. */
|
|
7
|
+
export type SectionHeaderBaseProps = {
|
|
8
|
+
title: string;
|
|
9
|
+
/** A line under the title. */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Before the title. */
|
|
12
|
+
icon?: IconName;
|
|
13
|
+
/** The heading level in the document outline. Defaults to 2. */
|
|
14
|
+
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// What sits beside the title is centered on the title's first line, not on the whole block,
|
|
18
|
+
// so it stays put when a description is added. `1lh` in the heading's type is that line.
|
|
19
|
+
const TITLE_LINE = "flex h-lh shrink-0 items-center text-xds-heading";
|
|
20
|
+
|
|
21
|
+
export const SECTION_HEADER_PARTS = {
|
|
22
|
+
root: "flex items-start gap-4",
|
|
23
|
+
/** The icon and the text. */
|
|
24
|
+
lead: "flex min-w-0 flex-1 items-start gap-2",
|
|
25
|
+
icon: `${TITLE_LINE} text-xds-text-secondary`,
|
|
26
|
+
text: "flex min-w-0 flex-col gap-0.5",
|
|
27
|
+
title: "text-xds-heading text-xds-text-primary",
|
|
28
|
+
description: "text-xds-detail text-xds-text-secondary",
|
|
29
|
+
action: TITLE_LINE,
|
|
30
|
+
// Button's own `iconEnd` does not mirror; this one has to, as it points onward.
|
|
31
|
+
chevron: "rtl:-scale-x-100",
|
|
32
|
+
} as const;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Ejected from `@xds/react` 0.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/react/base";
|
|
5
|
+
|
|
6
|
+
/** SegmentedControl's props in every framework, short of `onChange`. */
|
|
7
|
+
export type SegmentedControlBaseProps<Value extends string> = {
|
|
8
|
+
options: readonly { value: Value; label: string }[];
|
|
9
|
+
value: Value;
|
|
10
|
+
/** Says what is being chosen, for assistive technology. */
|
|
11
|
+
"aria-label": string;
|
|
12
|
+
/** Stretches to the width of its container. */
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** The track the segments sit in. */
|
|
17
|
+
export function segmentedControlClass(fullWidth = false): string {
|
|
18
|
+
return `h-xds-control-md rounded-xds-md bg-xds-segmented-track p-0.5 ${fullWidth ? "flex w-full" : "inline-flex w-fit"}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The label around each segment's hidden radio button. */
|
|
22
|
+
export function segmentedControlOptionClass(fullWidth = false): string {
|
|
23
|
+
return `relative flex cursor-pointer ${fullWidth ? "flex-1" : ""}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The segment drawn beside the hidden radio button. The border is there on every segment,
|
|
28
|
+
* transparent until selected, so selecting does not move the text.
|
|
29
|
+
*/
|
|
30
|
+
export const segmentedControlSegmentClass = `flex w-full items-center justify-center whitespace-nowrap rounded-[calc(var(--xds-radius-md)-2px)] border border-transparent px-4 text-xds-label text-xds-segmented-text peer-checked:border-xds-segmented-selected-border peer-checked:bg-xds-segmented-selected-background peer-checked:text-xds-segmented-selected-text peer-checked:shadow-xds-subtle ${PEER_FOCUS}`;
|