@xds/core 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/banner.d.ts +4 -1
  2. package/dist/breadcrumb.d.ts +39 -0
  3. package/dist/breadcrumb.js +7 -0
  4. package/dist/checkbox.d.ts +20 -3
  5. package/dist/checkbox.js +3 -1
  6. package/dist/combobox.d.ts +59 -0
  7. package/dist/combobox.js +40 -0
  8. package/dist/date-picker.d.ts +10 -4
  9. package/dist/date-picker.js +5 -4
  10. package/dist/date-range-picker.d.ts +10 -4
  11. package/dist/date-range-picker.js +9 -8
  12. package/dist/index.d.ts +17 -6
  13. package/dist/index.js +16 -5
  14. package/dist/labels.d.ts +34 -0
  15. package/dist/labels.js +26 -0
  16. package/dist/link.d.ts +49 -0
  17. package/dist/link.js +12 -0
  18. package/dist/pagination.d.ts +51 -0
  19. package/dist/pagination.js +25 -0
  20. package/dist/popover.d.ts +33 -0
  21. package/dist/popover.js +8 -0
  22. package/dist/preview/components.d.ts +71 -17
  23. package/dist/preview/components.js +1 -0
  24. package/dist/preview/design.d.ts +22 -3
  25. package/dist/preview/design.js +65 -34
  26. package/dist/preview/fixtures.d.ts +0 -76
  27. package/dist/preview/fixtures.js +0 -126
  28. package/dist/preview/kit.d.ts +48 -32
  29. package/dist/preview/kit.js +3 -0
  30. package/dist/preview/page.d.ts +1 -1
  31. package/dist/preview/page.js +1 -0
  32. package/dist/preview/sections/accordion.d.ts +1 -0
  33. package/dist/preview/sections/accordion.js +40 -0
  34. package/dist/preview/sections/badges.d.ts +1 -0
  35. package/dist/preview/sections/badges.js +13 -0
  36. package/dist/preview/sections/banners.d.ts +1 -0
  37. package/dist/preview/sections/banners.js +13 -0
  38. package/dist/preview/sections/buttons.d.ts +2 -0
  39. package/dist/preview/sections/buttons.js +30 -0
  40. package/dist/preview/sections/card.d.ts +1 -0
  41. package/dist/preview/sections/card.js +33 -0
  42. package/dist/preview/sections/chips.d.ts +1 -0
  43. package/dist/preview/sections/chips.js +23 -0
  44. package/dist/preview/sections/controls.d.ts +1 -0
  45. package/dist/preview/sections/controls.js +143 -0
  46. package/dist/preview/sections/dialog.d.ts +1 -0
  47. package/dist/preview/sections/dialog.js +25 -0
  48. package/dist/preview/sections/empty-state.d.ts +1 -0
  49. package/dist/preview/sections/empty-state.js +13 -0
  50. package/dist/preview/sections/links.d.ts +1 -0
  51. package/dist/preview/sections/links.js +8 -0
  52. package/dist/preview/sections/list.d.ts +1 -0
  53. package/dist/preview/sections/list.js +119 -0
  54. package/dist/preview/sections/media.d.ts +1 -0
  55. package/dist/preview/sections/media.js +90 -0
  56. package/dist/preview/sections/menu.d.ts +1 -0
  57. package/dist/preview/sections/menu.js +46 -0
  58. package/dist/preview/sections/navigation.d.ts +1 -0
  59. package/dist/preview/sections/navigation.js +20 -0
  60. package/dist/preview/sections/selection.d.ts +1 -0
  61. package/dist/preview/sections/selection.js +33 -0
  62. package/dist/preview/sections/sidebar.d.ts +1 -0
  63. package/dist/preview/sections/sidebar.js +45 -0
  64. package/dist/preview/sections/skeleton.d.ts +1 -0
  65. package/dist/preview/sections/skeleton.js +5 -0
  66. package/dist/preview/sections/tabs.d.ts +1 -0
  67. package/dist/preview/sections/tabs.js +24 -0
  68. package/dist/preview/sections/text-fields.d.ts +1 -0
  69. package/dist/preview/sections/text-fields.js +75 -0
  70. package/dist/preview/sections/toast.d.ts +2 -0
  71. package/dist/preview/sections/toast.js +28 -0
  72. package/dist/preview/specimens.js +1 -1
  73. package/dist/progress-bar.d.ts +7 -4
  74. package/dist/progress-bar.js +2 -2
  75. package/dist/radio-group.d.ts +7 -1
  76. package/dist/root.d.ts +25 -0
  77. package/dist/root.js +25 -0
  78. package/dist/rows.d.ts +23 -0
  79. package/dist/rows.js +67 -0
  80. package/dist/segmented-control.d.ts +5 -2
  81. package/dist/segmented-control.js +1 -1
  82. package/dist/select.d.ts +29 -1
  83. package/dist/select.js +7 -0
  84. package/dist/slider.d.ts +4 -1
  85. package/dist/switch.d.ts +5 -2
  86. package/dist/switch.js +2 -1
  87. package/dist/table.d.ts +62 -0
  88. package/dist/table.js +25 -0
  89. package/dist/tabs.d.ts +4 -2
  90. package/dist/text-field.d.ts +19 -3
  91. package/dist/theme-scope.d.ts +6 -4
  92. package/dist/theme-scope.js +21 -15
  93. package/dist/time-picker.d.ts +57 -0
  94. package/dist/time-picker.js +53 -0
  95. package/dist/toast-queue.d.ts +40 -0
  96. package/dist/toast-queue.js +17 -0
  97. package/dist/toast.d.ts +1 -1
  98. package/dist/toast.js +1 -1
  99. package/package.json +2 -2
  100. package/dist/preview/sections.d.ts +0 -20
  101. package/dist/preview/sections.js +0 -517
package/dist/toast.d.ts CHANGED
@@ -15,7 +15,7 @@ export type ToastBaseProps = {
15
15
  };
16
16
  export declare const TOAST_PARTS: {
17
17
  readonly region: "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";
18
- readonly toast: "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";
18
+ readonly toast: "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 forced-colors:outline forced-colors:outline-(length:--xds-border-width-thin) forced-colors:outline-[CanvasText]";
19
19
  readonly message: "min-w-0 text-xds-detail";
20
20
  readonly action: "-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";
21
21
  };
package/dist/toast.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export const TOAST_PARTS = {
2
2
  region: "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",
3
- toast: "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",
3
+ toast: "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 forced-colors:outline forced-colors:outline-(length:--xds-border-width-thin) forced-colors:outline-[CanvasText]",
4
4
  message: "min-w-0 text-xds-detail",
5
5
  action: "-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",
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xds/core",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "What the xds web component libraries share: prop types, class recipes and DOM helpers. Install a framework's package instead.",
5
5
  "keywords": [
6
6
  "design-system",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@xds/tokens": "1.0.1",
37
+ "@xds/tokens": "1.2.0",
38
38
  "@internationalized/date": "3.12.4",
39
39
  "@zag-js/date-picker": "2.0.0-next.4"
40
40
  },
@@ -1,20 +0,0 @@
1
- import { type DesignState } from "./kit.ts";
2
- import type { Overlay } from "./page.ts";
3
- export declare const buttons: (open: Overlay | undefined) => import("./model.ts").PreviewNode<DesignState>[];
4
- export declare const textFields: () => import("./model.ts").PreviewNode<DesignState>[];
5
- export declare const selection: () => import("./model.ts").PreviewNode<DesignState>[];
6
- export declare const controls: () => import("./model.ts").PreviewNode<DesignState>[];
7
- export declare const chips: () => import("./model.ts").PreviewNode<DesignState>[];
8
- export declare const tabs: () => import("./model.ts").PreviewNode<DesignState>[];
9
- export declare const badges: () => import("./model.ts").PreviewNode<DesignState>[];
10
- export declare const banners: () => import("./model.ts").PreviewNode<DesignState>[];
11
- export declare const card: () => import("./model.ts").PreviewNode<DesignState>[];
12
- export declare const media: () => import("./model.ts").PreviewNode<DesignState>[];
13
- export declare const list: () => import("./model.ts").PreviewNode<DesignState>[];
14
- export declare const sidebar: () => import("./model.ts").PreviewNode<DesignState>[];
15
- export declare const accordion: () => import("./model.ts").PreviewNode<DesignState>[];
16
- export declare const menu: () => import("./model.ts").PreviewNode<DesignState>[];
17
- export declare const dialog: () => import("./model.ts").PreviewNode<DesignState>[];
18
- export declare const toast: (open: Overlay | undefined) => import("./model.ts").PreviewNode<DesignState>[];
19
- export declare const skeleton: () => import("./model.ts").PreviewNode<DesignState>[];
20
- export declare const emptyState: () => import("./model.ts").PreviewNode<DesignState>[];
@@ -1,517 +0,0 @@
1
- import { BROKEN, COUNTRIES, CURRENCIES, DAY, DELIVERY, FILTERS, NIGHT, PAGES, PEOPLE, PLACES, PLANS, PORTRAIT, PREFERENCES, QUESTIONS, SIZES_OF_SHIRT, TIME_ZONES, VIEWS, } from "./fixtures.js";
2
- import { bind, el, keep, row, show, ui } from "./kit.js";
3
- const VARIANTS = ["primary", "secondary", "ghost", "danger"];
4
- const SIZES = ["sm", "md", "lg"];
5
- const BADGE_TONES = ["neutral", "accent", "success", "warning", "danger"];
6
- const BANNER_TONES = ["info", "success", "warning", "danger"];
7
- const RATIOS = [
8
- { ratio: "16:9", width: "w-48" },
9
- { ratio: "4:3", width: "w-36" },
10
- { ratio: "1:1", width: "w-28" },
11
- { ratio: "9:16", width: "w-16" },
12
- ];
13
- const toggle = (key) => (state) => ({
14
- [key]: !state[key],
15
- });
16
- const tooltips = () => row("tooltip", el("span", { class: "flex" }, ui.Tooltip({ label: "Search", shortcut: "⌘K" }, ui.IconButton({ icon: "search", label: "Search" }))), ui.Tooltip({ label: "Share", placement: "bottom" }, ui.IconButton({ icon: "share-2", label: "Share", variant: "secondary" })), ui.Tooltip({ label: "Export as a spreadsheet" }, ui.Button({ iconStart: "download" }, "Export")), ui.Text({ variant: "detail", tone: "secondary", as: "span" }, "Rest the pointer on a control, or focus it with the keyboard."));
17
- export const buttons = (open) => [
18
- ...(open === "tooltip" ? [tooltips()] : []),
19
- ...VARIANTS.map((variant) => row(variant, ...SIZES.map((size) => ui.Button({ variant, size }, "Save")), ui.Button({ variant, disabled: true }, "Disabled"), ui.Button({ variant, loading: true }, "Saving"))),
20
- row("icons", ui.Button({ variant: "primary", iconStart: "plus" }, "New"), ui.Button({ iconEnd: "chevron-down" }, "Options"), ui.Button({ variant: "ghost", size: "sm", iconStart: "download" }, "Export"), ui.Button({ variant: "primary", size: "lg", iconStart: "upload", iconEnd: "arrow-right" }, "Publish"), ui.Button({ variant: "ghost", iconStart: "settings", "aria-label": "Settings" }), ui.Button({ size: "sm", iconStart: "ellipsis", "aria-label": "More" })),
21
- row("icon, loading", ui.Button({ iconStart: "download" }, "Export"), ui.Button({ iconStart: "download", loading: true }, "Export"), ui.Button({ size: "lg", iconStart: "download" }, "Export"), ui.Button({ size: "lg", iconStart: "download", loading: true }, "Export")),
22
- row("selected", ui.Button({ iconStart: "heart", selected: (state) => state.liked, onPress: toggle("liked") }, "Like"), ui.Button({ iconStart: "heart", selected: false }, "Like"), ui.Button({
23
- variant: "ghost",
24
- iconStart: "bookmark",
25
- selected: (state) => state.saved,
26
- onPress: toggle("saved"),
27
- }, "Save"), ui.Button({ variant: "ghost", iconStart: "bookmark", selected: false }, "Save"), ui.Button({
28
- variant: "ghost",
29
- size: "sm",
30
- iconStart: "star",
31
- selected: true,
32
- "aria-label": "Starred",
33
- }), ui.Button({ iconStart: "heart", selected: true, disabled: true }, "Disabled"), ui.Button({ variant: "primary", iconStart: "bell", selected: true }, "Primary")),
34
- ...VARIANTS.map((variant) => row(`icon, ${variant}`, ...SIZES.map((size) => ui.IconButton({ icon: "settings", label: `Settings, ${size}`, variant, size })), ui.IconButton({ icon: "settings", label: "Disabled", variant, disabled: true }), ui.IconButton({ icon: "settings", label: "Loading", variant, loading: true }))),
35
- row("icon, selected", ui.IconButton({
36
- icon: "pin",
37
- label: "Pin",
38
- selected: (state) => state.pinned,
39
- onPress: toggle("pinned"),
40
- }), ui.IconButton({ icon: "pin", label: "Pin", selected: false }), ui.IconButton({ icon: "star", label: "Star", variant: "secondary", selected: true }), ui.IconButton({ icon: "star", label: "Star", variant: "secondary", selected: false }), ui.IconButton({ icon: "heart", label: "Like", size: "sm", selected: true }), ui.IconButton({ icon: "heart", label: "Like", size: "lg", selected: true }), ui.IconButton({ icon: "bookmark", label: "Save", selected: true, disabled: true }), ui.IconButton({ icon: "bell", label: "Notify", variant: "primary", selected: true })),
41
- ...(open === "tooltip" ? [] : [tooltips()]),
42
- ];
43
- export const textFields = () => [
44
- el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.TextField({
45
- label: "Email",
46
- placeholder: "name@example.com",
47
- description: "We send the sign-in code to this address.",
48
- ...bind("email"),
49
- }), ui.TextField({ label: "Project name", value: "Weekly report", onChange: keep, required: true }), ui.TextField({
50
- label: "Sign-in code",
51
- value: "12345",
52
- onChange: keep,
53
- error: "That code is wrong or has expired.",
54
- }), ui.TextField({ label: "Organization", value: "Xds Inc.", onChange: keep, disabled: true }), ui.TextField({
55
- label: "Search",
56
- placeholder: "Projects, people, files",
57
- leading: ui.Icon({ name: "search", size: "sm" }),
58
- ...bind("query"),
59
- }), ui.TextField({
60
- label: "Weight",
61
- inputMode: "decimal",
62
- value: "72.5",
63
- onChange: keep,
64
- trailing: ui.Text({ variant: "detail", tone: "inherit", as: "span" }, "kg"),
65
- }), ui.TextField({
66
- label: "Password",
67
- type: (state) => (state.revealed ? "text" : "password"),
68
- leading: ui.Icon({ name: "lock", size: "sm" }),
69
- trailing: ui.Button({
70
- variant: "ghost",
71
- size: "sm",
72
- iconStart: (state) => (state.revealed ? "eye-off" : "eye"),
73
- "aria-label": (state) => (state.revealed ? "Hide the password" : "Show the password"),
74
- onPress: toggle("revealed"),
75
- }),
76
- ...bind("secret"),
77
- }), ui.TextField({
78
- label: "Promo code",
79
- leading: ui.Icon({ name: "tag", size: "sm" }),
80
- value: "SPRING",
81
- onChange: keep,
82
- error: "That code has expired.",
83
- }), ui.TextField({ label: "Notes", multiline: true, ...bind("notes") }), ui.TextField({
84
- label: "Bio",
85
- description: "Shown on your profile.",
86
- multiline: true,
87
- maxLength: 80,
88
- ...bind("bio"),
89
- }), ui.TextField({
90
- label: "Message",
91
- placeholder: "Write a reply",
92
- multiline: true,
93
- rows: 2,
94
- leading: ui.Icon({ name: "message-square", size: "sm" }),
95
- value: "",
96
- onChange: keep,
97
- }), ui.TextField({
98
- label: "Display name",
99
- maxLength: 12,
100
- value: "Ada Lovelace",
101
- onChange: keep,
102
- error: "Use 12 characters or fewer, without spaces.",
103
- })),
104
- el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.SearchField({
105
- label: "Search projects",
106
- placeholder: "Search projects",
107
- ...bind("search"),
108
- onSubmit: (_, submitted) => ({ submitted }),
109
- }), ui.SearchField({ label: "Search people", value: "Ada Lovelace", onChange: keep }), ui.SearchField({
110
- label: "Search files",
111
- placeholder: "Unavailable offline",
112
- value: "",
113
- onChange: keep,
114
- disabled: true,
115
- }), ui.Text({ variant: "detail", tone: "secondary", as: "span", class: "self-center" }, (state) => state.submitted ? `Searched for “${state.submitted}”.` : "Enter searches, Escape clears.")),
116
- ];
117
- export const selection = () => [
118
- row("switch", ui.Switch({ label: "Notifications", ...bind("notifications", "checked") }), ui.Switch({ checked: false, onChange: keep, label: "Off" }), ui.Switch({ checked: true, onChange: keep, label: "Locked", disabled: true })),
119
- row("checkbox", ui.Checkbox({ label: "Remember me", ...bind("agreed", "checked") }), ui.Checkbox({ checked: false, onChange: keep, label: "Unchecked" }), ui.Checkbox({ checked: true, onChange: keep, label: "Locked", disabled: true })),
120
- row("segmented", ui.SegmentedControl({ options: VIEWS, "aria-label": "Calendar view", ...bind("view") })),
121
- el("div", { class: "grid gap-6 sm:grid-cols-3" }, ui.RadioGroup({ label: "Delivery", options: DELIVERY, ...bind("delivery") }), ui.RadioGroup({
122
- label: "Size",
123
- options: SIZES_OF_SHIRT,
124
- ...bind("shirt"),
125
- error: (state) => (state.shirt === undefined ? "Choose a size to continue." : undefined),
126
- }), ui.RadioGroup({
127
- label: "Region, locked",
128
- options: DELIVERY,
129
- value: "express",
130
- onChange: keep,
131
- disabled: true,
132
- })),
133
- ];
134
- export const controls = () => [
135
- el("div", { class: "grid gap-4 sm:grid-cols-2" }, el("div", {}, ui.Select({
136
- label: "Plan",
137
- options: PLANS,
138
- ...bind("plan"),
139
- description: "Change it at any time.",
140
- })), ui.Select({
141
- label: "Country",
142
- placeholder: "Choose a country",
143
- options: COUNTRIES,
144
- ...bind("country"),
145
- }), ui.Select({
146
- label: "Time zone",
147
- placeholder: "Choose a time zone",
148
- options: TIME_ZONES,
149
- ...bind("timeZone"),
150
- error: (state) => state.timeZone === undefined ? "Choose a time zone for the reminders." : undefined,
151
- }), ui.Select({
152
- label: "Currency",
153
- options: CURRENCIES,
154
- value: "eur",
155
- onChange: keep,
156
- disabled: true,
157
- })),
158
- el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.DatePicker({
159
- label: "Due date",
160
- ...bind("dueDate"),
161
- min: "2026-03-05",
162
- max: "2026-04-20",
163
- description: "Within the current sprint.",
164
- }), ui.DatePicker({
165
- label: "Start date",
166
- placeholder: "Choose a day",
167
- ...bind("startDate"),
168
- error: (state) => state.startDate === undefined ? "Choose when the project starts." : undefined,
169
- }), ui.DatePicker({ label: "Locked", value: "2026-03-10", onChange: keep, disabled: true })),
170
- el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.DateRangePicker({
171
- label: "Stay",
172
- ...bind("stay"),
173
- min: "2026-03-05",
174
- max: "2026-04-20",
175
- minLength: 2,
176
- maxLength: 14,
177
- startLabel: "Check-in",
178
- endLabel: "Check-out",
179
- description: "Two nights at least.",
180
- }), ui.DateRangePicker({
181
- label: "Leave",
182
- placeholder: "Choose the days",
183
- ...bind("leave"),
184
- error: (state) => (state.leave === undefined ? "Choose the days of your leave." : undefined),
185
- }), ui.DateRangePicker({
186
- label: "Locked range",
187
- value: { start: "2026-03-10", end: "2026-03-14" },
188
- onChange: keep,
189
- disabled: true,
190
- })),
191
- el("div", { class: "grid gap-x-8 gap-y-6 sm:grid-cols-2" }, ui.Slider({ label: "Volume", ...bind("volume"), showValue: true }), ui.Slider({
192
- label: "Font size",
193
- min: 12,
194
- max: 24,
195
- step: 2,
196
- ...bind("fontSize"),
197
- showValue: true,
198
- }), ui.Slider({ label: "Brightness", ...bind("volume") }), ui.Slider({
199
- label: "Balance, locked",
200
- value: 30,
201
- onChange: keep,
202
- disabled: true,
203
- showValue: true,
204
- })),
205
- ];
206
- export const chips = () => [
207
- row("state", ui.Chip({ label: "Unselected" }), ui.Chip({ label: "Selected", selected: true }), ui.Chip({ label: "Icon", iconStart: "tag" }), ui.Chip({ label: "Icon, selected", iconStart: "tag", selected: true }), ui.Chip({ label: "Disabled", disabled: true }), ui.Chip({ label: "Disabled, selected", selected: true, disabled: true })),
208
- row("bar", el("div", { class: "max-w-md min-w-0 flex-1" }, ui.ChipBar({ label: "Filter the tasks" }, ...FILTERS.map((filter) => ui.Chip({
209
- label: filter.label,
210
- iconStart: filter.icon,
211
- selected: (state) => state.filters.includes(filter.value),
212
- onPress: (state) => ({
213
- filters: state.filters.includes(filter.value)
214
- ? state.filters.filter((other) => other !== filter.value)
215
- : [...state.filters, filter.value],
216
- }),
217
- }))))),
218
- ];
219
- export const tabs = () => [
220
- ui.Tabs({ items: PAGES, label: "Workspace pages", ...bind("page") }),
221
- ui.Tabs({
222
- items: PAGES.map(({ value, label }) => ({ value, label })),
223
- label: "Workspace pages, without icons",
224
- ...bind("page"),
225
- }),
226
- ui.Tabs({
227
- items: PAGES.slice(0, 3),
228
- label: "Workspace pages, full width",
229
- ...bind("page"),
230
- value: (state) => state.page === "billing" || state.page === "settings" ? "overview" : state.page,
231
- fullWidth: true,
232
- }),
233
- el("div", { class: "max-w-xs" }, ui.Tabs({ items: PAGES, label: "Workspace pages, scrolling", ...bind("page") })),
234
- ];
235
- export const badges = () => [
236
- row("tone", ...BADGE_TONES.map((tone) => ui.Badge({ tone }, tone))),
237
- row("dot", ui.Badge({ tone: "success", dot: true }, "Online"), ui.Badge({ tone: "warning", dot: true }, "Connecting"), ui.Badge({ tone: "danger", dot: true }, "Offline")),
238
- row("icon", ui.Badge({ tone: "success", icon: "check" }, "Verified"), ui.Badge({ tone: "warning", icon: "clock" }, "Pending"), ui.Badge({ icon: "lock" }, "Private"), ui.Badge({ tone: "accent", dot: true, icon: "sparkles" }, "New")),
239
- row("overlay", ...[
240
- { name: "dark", src: NIGHT },
241
- { name: "light", src: DAY },
242
- ].map((block) => el("span", { class: "relative inline-flex overflow-hidden rounded-xds-md" }, el("img", { src: block.src, alt: "", class: "h-24 w-48 object-cover" }), el("span", { class: "absolute start-2 top-2" }, ui.Badge({ tone: "overlay", icon: "play" }, "2:45")), el("span", { class: "absolute end-2 bottom-2" }, ui.Badge({ tone: "overlay" }, "On a ", block.name, " picture"))))),
243
- row("count", ui.CountBadge({ count: 3 }), ui.CountBadge({ count: 120 }), ui.CountBadge({ count: 7, max: 5 }), el("span", { class: "flex items-center gap-6 ps-3 text-xds-text-primary" }, ui.CountBadge({ count: 3, label: "3 unread notifications" }, ui.Icon({ name: "bell", size: "lg" })), ui.CountBadge({ count: 120, label: "More than 99 unread messages" }, ui.Icon({ name: "mail", size: "lg" })), ui.CountBadge({ count: 2, label: "2 new messages from Ada Lovelace" }, ui.Avatar({ name: "Ada Lovelace", size: "lg" })), ui.CountBadge({ count: 12, label: "12 items in the cart" }, ui.Button({ variant: "ghost", iconStart: "shopping-cart", "aria-label": "Cart" })), ui.CountBadge({ count: 0 }, ui.Icon({ name: "message-square", size: "lg", label: "Messages, none unread" })))),
244
- ];
245
- export const banners = () => [
246
- ...BANNER_TONES.map((tone) => ui.Banner({ tone, title: tone }, "Your changes are saved on this device. They sync when you are back online.")),
247
- show((state) => !state.dismissed, ui.Banner({
248
- tone: "warning",
249
- title: "Your trial ends in three days",
250
- action: { label: "Choose a plan", onPress: keep },
251
- onDismiss: () => ({ dismissed: true }),
252
- }, "After that the workspace becomes read-only until a plan is chosen."), ui.Button({ size: "sm", onPress: () => ({ dismissed: false }) }, "Show the dismissed banner again")),
253
- ui.Banner({ tone: "info", onDismiss: keep, dismissLabel: "Dismiss the update notice" }, "A new version is available."),
254
- ui.Banner({ tone: "danger", action: { label: "Try again", onPress: keep } }, "The report could not be sent."),
255
- ];
256
- export const card = () => [
257
- ui.Card({
258
- title: "Weekly report",
259
- description: "Updated a few minutes ago.",
260
- actions: ui.Badge({ tone: "success", dot: true }, "Online"),
261
- }, ui.Text({ tone: "secondary" }, "A card groups related content."), ui.Divider({}), row("spinner", ui.Spinner({ size: "sm" }), ui.Spinner({ size: "md" }), ui.Spinner({ size: "lg", label: "Loading" })), row("avatar", ui.Avatar({ name: "Ada Lovelace", size: "sm" }), ui.Avatar({ name: "Ada Lovelace" }), ui.Avatar({ name: "Grace Hopper", size: "lg" }), ui.Avatar({ name: "Alan Turing", size: "xl" })), row("picture", ui.Avatar({ name: "Ada Lovelace", src: PORTRAIT, size: "sm" }), ui.Avatar({ name: "Ada Lovelace", src: PORTRAIT }), ui.Avatar({ name: "Ada Lovelace", src: PORTRAIT, size: "lg" }), ui.Avatar({ name: "Ada Lovelace", src: PORTRAIT, size: "xl" }), ui.Avatar({ name: "Grace Hopper", src: BROKEN, size: "xl" }), ui.Text({ variant: "detail", tone: "secondary", as: "span" }, "The last picture fails to load.")), row("stack", ui.AvatarStack({ people: PEOPLE.slice(0, 3) }), ui.AvatarStack({ people: PEOPLE }), ui.AvatarStack({ people: PEOPLE, max: 3, size: "sm" }), ui.AvatarStack({ people: PEOPLE, max: 2, size: "lg", label: "The design team, 7 people" }), ui.AvatarStack({ people: PEOPLE, max: 3, size: "xl" })), row("progress", el("div", { class: "max-w-xs flex-1" }, ui.ProgressBar({ value: 0.6, label: "Upload" })))),
262
- el("div", { class: "grid items-start gap-4 sm:grid-cols-3" }, ui.Card({
263
- title: "Night hike",
264
- description: "Media runs edge to edge.",
265
- media: el("img", { src: NIGHT, alt: "", class: "h-28 object-cover" }),
266
- }, ui.Text({ variant: "detail", tone: "secondary" }, "12 km, 4 hours.")), ui.Card({ title: "Team plan", description: "Press anywhere on the card.", onPress: keep }, ui.Text({ variant: "detail", tone: "secondary", as: "span" }, "Up to 20 people.")), ui.Card({
267
- title: "Yearly billing",
268
- description: (state) => (state.picked ? "Selected. Press to clear." : "Press to select."),
269
- selected: (state) => state.picked,
270
- onPress: toggle("picked"),
271
- }, ui.Text({ variant: "detail", tone: "secondary", as: "span" }, "Two months free.")), ui.Card({
272
- title: "Morning walk",
273
- description: "Selected, with media.",
274
- selected: true,
275
- media: el("img", { src: DAY, alt: "", class: "h-28 object-cover" }),
276
- }), ui.Card({ title: "Monthly billing", description: "Not selected.", selected: false }, ui.Text({ variant: "detail", tone: "secondary" }, "Cancel at any time.")), ui.Card({ title: "Selected", description: "A card that is not pressable.", selected: true }, ui.Text({ variant: "detail", tone: "secondary" }, "The same size as the one beside it."))),
277
- ];
278
- const videoActions = (title) => ui.Menu({
279
- label: `Actions for ${title}`,
280
- align: "end",
281
- trigger: ui.IconButton({ icon: "ellipsis-vertical", label: "More actions" }),
282
- items: [
283
- {
284
- label: "Save to watch later",
285
- icon: "clock",
286
- onSelect: () => ({ opened: `Saved ${title}.` }),
287
- },
288
- { label: "Share", icon: "share-2", onSelect: () => ({ opened: `Shared ${title}.` }) },
289
- ],
290
- });
291
- const opens = (opened) => () => ({ opened });
292
- export const media = () => [
293
- ui.SectionHeader({
294
- title: "Continue watching",
295
- description: "Pick up where you left off.",
296
- action: { label: "See all", onPress: opens("See all.") },
297
- }),
298
- el("div", { class: "flex flex-wrap items-end gap-3" }, ...RATIOS.map(({ ratio, width }) => el("div", { class: `flex flex-col gap-1 ${width}` }, ui.Thumbnail({ src: ratio === "1:1" ? PORTRAIT : NIGHT, alt: "", ratio }), ui.Text({ variant: "footnote", tone: "secondary", as: "span" }, ratio)))),
299
- el("div", { class: "grid grid-cols-2 gap-3 sm:grid-cols-5" }, ...[
300
- {
301
- caption: "Fails to load",
302
- thumbnail: ui.Thumbnail({ src: BROKEN, alt: "A picture that fails to load" }),
303
- },
304
- { caption: "No picture, badge", thumbnail: ui.Thumbnail({ alt: "", badge: "Live" }) },
305
- { caption: "Badge", thumbnail: ui.Thumbnail({ src: DAY, alt: "", badge: "12:04" }) },
306
- { caption: "Progress", thumbnail: ui.Thumbnail({ src: NIGHT, alt: "", progress: 0.35 }) },
307
- {
308
- caption: "Badge and progress",
309
- thumbnail: ui.Thumbnail({ src: DAY, alt: "", badge: "3:27", progress: 0.8 }),
310
- },
311
- ].map(({ caption, thumbnail }) => el("div", { class: "flex flex-col gap-1" }, thumbnail, ui.Text({ variant: "footnote", tone: "secondary", as: "span" }, caption)))),
312
- el("div", { class: "grid items-start gap-2 sm:grid-cols-3" }, ui.MediaCard({
313
- src: NIGHT,
314
- title: "Night hike above the city: four hours, twelve kilometres and one long staircase",
315
- meta: ["Ada Lovelace", "12K views · 3 days ago"],
316
- badge: "12:04",
317
- progress: 0.35,
318
- leading: ui.Avatar({ name: "Ada Lovelace", src: PORTRAIT }),
319
- action: videoActions("Night hike"),
320
- onPress: opens("Opened Night hike."),
321
- }), ui.MediaCard({
322
- src: DAY,
323
- title: "Morning walk",
324
- meta: ["Grace Hopper", "840 views · 1 week ago"],
325
- badge: "3:27",
326
- leading: ui.Avatar({ name: "Grace Hopper" }),
327
- action: videoActions("Morning walk"),
328
- onPress: opens("Opened Morning walk."),
329
- }), ui.MediaCard({
330
- src: BROKEN,
331
- title: "Not pressable, and its picture fails to load",
332
- meta: ["Alan Turing"],
333
- })),
334
- el("div", { class: "grid items-start gap-2 sm:grid-cols-2" }, ui.MediaCard({
335
- layout: "horizontal",
336
- src: DAY,
337
- title: "Ten small changes that make a report easier to read",
338
- meta: ["Katherine Johnson", "5 min read"],
339
- badge: "5:12",
340
- progress: 0.6,
341
- action: videoActions("Ten small changes"),
342
- onPress: opens("Opened Ten small changes."),
343
- }), ui.MediaCard({
344
- layout: "horizontal",
345
- src: NIGHT,
346
- ratio: "1:1",
347
- title: "Square, without an action",
348
- meta: ["Margaret Hamilton", "2 days ago"],
349
- onPress: opens("Opened Square."),
350
- })),
351
- ui.Text({ variant: "detail", tone: "secondary" }, (state) => state.opened),
352
- ui.SectionHeader({
353
- icon: "history",
354
- title: "On its own",
355
- description: "An icon, a description and an action, at heading level 3.",
356
- action: { label: "Clear history", onPress: opens("Cleared the history.") },
357
- level: 3,
358
- }),
359
- ];
360
- const listIcon = (name) => ui.Icon({ name, size: "sm", class: "text-xds-text-secondary" });
361
- export const list = () => [
362
- ui.Card({ flush: true }, ui.ListRow({
363
- leading: ui.Avatar({ name: "Ada Lovelace" }),
364
- title: "Ada Lovelace",
365
- description: "ada@example.com",
366
- trailing: ui.Badge({ tone: "accent" }, "Owner"),
367
- }), ui.Divider({}), ui.ListRow({
368
- title: "Notifications",
369
- description: "Mentions and replies",
370
- trailing: ui.Switch({ "aria-label": "Notifications", ...bind("notifications", "checked") }),
371
- }), ui.Divider({}), ui.ListRow({
372
- title: "Language",
373
- trailing: ui.Text({ tone: "secondary", as: "span" }, "English"),
374
- chevron: true,
375
- onPress: keep,
376
- }), ui.Divider({}), ui.ListRow({
377
- title: "Storage",
378
- description: "Unavailable offline",
379
- chevron: true,
380
- onPress: keep,
381
- disabled: true,
382
- }), ui.Divider({}), ui.ListRow({
383
- leading: ui.Avatar({ name: "Grace Hopper" }),
384
- title: "Grace Hopper",
385
- description: "The selected row",
386
- trailing: ui.CountBadge({ count: 3, label: "3 unread messages" }),
387
- selected: true,
388
- onPress: keep,
389
- }), ui.Divider({}), ui.ListRow({ title: "Selected, without an action", description: "Read-only", selected: true })),
390
- ui.Card({ flush: true, class: "max-w-xs" }, ui.ListRow({
391
- compact: true,
392
- leading: listIcon("mail"),
393
- title: "Inbox",
394
- trailing: ui.CountBadge({ count: 12, label: "12 unread" }),
395
- selected: true,
396
- onPress: keep,
397
- }), ui.ListRow({ compact: true, leading: listIcon("file-text"), title: "Drafts", onPress: keep }), ui.ListRow({
398
- compact: true,
399
- leading: listIcon("clock"),
400
- title: "Scheduled",
401
- description: "Compact, with a description",
402
- onPress: keep,
403
- }), ui.ListRow({
404
- compact: true,
405
- leading: listIcon("trash"),
406
- title: "Trash",
407
- onPress: keep,
408
- disabled: true,
409
- })),
410
- ];
411
- const placeLabel = (place) => PLACES.flatMap((section) => section.items).find((item) => item.value === place)?.label ?? place;
412
- export const sidebar = () => [
413
- el("div", { class: "grid gap-4 sm:grid-cols-2" }, ...[false, true].map((collapsed) => el("div", {
414
- class: "flex h-[28rem] overflow-hidden rounded-xds-md border border-xds-border-default",
415
- }, ui.Sidebar({
416
- label: collapsed ? "Workspace, collapsed" : "Workspace",
417
- sections: PLACES,
418
- ...bind("place"),
419
- collapsed,
420
- header: el("div", {
421
- class: `flex h-xds-control-md items-center gap-2 ${collapsed ? "justify-center" : "px-2"}`,
422
- }, el("span", {
423
- class: "flex size-xds-avatar-md items-center justify-center rounded-xds-md bg-xds-accent-default text-xds-text-on-accent",
424
- }, ui.Icon({ name: "sparkles", size: "sm" })), ...(collapsed ? [] : [ui.Text({ variant: "label", as: "span" }, "Xds")])),
425
- footer: el("div", { class: `flex items-center gap-2 py-1 ${collapsed ? "justify-center" : "px-2"}` }, ui.Avatar({ name: "Ada Lovelace", src: PORTRAIT, size: "sm" }), ...(collapsed ? [] : [ui.Text({ variant: "detail", as: "span" }, "Ada Lovelace")])),
426
- }), el("div", { class: "flex min-w-0 flex-1 flex-col gap-1 p-4" }, ui.Text({ variant: "heading", as: "span" }, (state) => placeLabel(state.place)), ui.Text({ variant: "detail", tone: "secondary", as: "span" }, collapsed
427
- ? "Rest the pointer on an icon, or focus it, for its name."
428
- : "The page of the current place."))))),
429
- ];
430
- export const accordion = () => [
431
- el("div", { class: "grid items-start gap-8 sm:grid-cols-2" }, el("div", { class: "flex flex-col gap-2" }, ui.Text({ variant: "label", tone: "secondary" }, "One at a time"), ui.Accordion({ items: QUESTIONS, ...bind("question", "expanded") })), el("div", { class: "flex flex-col gap-2" }, ui.Text({ variant: "label", tone: "secondary" }, "Several at once"), ui.Accordion({ items: PREFERENCES, ...bind("preferences", "expanded"), multiple: true }))),
432
- ];
433
- const chooses = (chosen) => () => ({ chosen });
434
- export const menu = () => [
435
- row("menu", el("span", { class: "flex" }, ui.Menu({
436
- label: "Report actions",
437
- trigger: ui.Button({ iconEnd: "chevron-down" }, "Actions"),
438
- items: [
439
- { label: "Rename", icon: "pencil", onSelect: chooses("Rename") },
440
- { label: "Duplicate", icon: "copy", onSelect: chooses("Duplicate") },
441
- { label: "Share", icon: "share-2", onSelect: keep, disabled: true },
442
- "separator",
443
- {
444
- label: "Comfortable",
445
- icon: "list",
446
- selected: (state) => state.density === "comfortable",
447
- onSelect: () => ({ density: "comfortable" }),
448
- },
449
- {
450
- label: "Compact",
451
- icon: "layout-grid",
452
- selected: (state) => state.density === "compact",
453
- onSelect: () => ({ density: "compact" }),
454
- },
455
- "separator",
456
- { label: "Delete", icon: "trash", danger: true, onSelect: chooses("Delete") },
457
- ],
458
- })), ui.Menu({
459
- label: "More actions",
460
- align: "end",
461
- trigger: ui.IconButton({ icon: "ellipsis", label: "More actions", variant: "secondary" }),
462
- items: [
463
- { label: "Copy the link", onSelect: chooses("Copy the link") },
464
- { label: "Open in a new window", onSelect: chooses("Open in a new window") },
465
- ],
466
- }), ui.Text({ variant: "detail", tone: "secondary", as: "span" }, (state) => state.chosen, " Density: ", (state) => state.density, ".")),
467
- ];
468
- export const dialog = () => [
469
- row("dialog", ui.Button({ variant: "danger", onPress: () => ({ confirming: true }) }, "Delete the report"), ui.Button({ onPress: () => ({ asking: true }) }, "A question that must be answered")),
470
- ui.Dialog({
471
- open: (state) => state.confirming,
472
- onClose: () => ({ confirming: false }),
473
- title: "Delete the weekly report?",
474
- description: "The report and its 12 comments are removed for everyone. This cannot be undone.",
475
- actions: [
476
- ui.Button({ onPress: () => ({ confirming: false }) }, "Cancel"),
477
- ui.Button({ variant: "danger", onPress: () => ({ confirming: false }) }, "Delete"),
478
- ],
479
- }),
480
- ui.Dialog({
481
- open: (state) => state.asking,
482
- onClose: () => ({ asking: false }),
483
- dismissible: false,
484
- title: "Keep the changes?",
485
- description: "You edited the report in another window.",
486
- actions: [
487
- ui.Button({ onPress: () => ({ asking: false }) }, "Discard"),
488
- ui.Button({ variant: "primary", onPress: () => ({ asking: false }) }, "Keep"),
489
- ],
490
- }, ui.TextField({ label: "Name of the copy", ...bind("copyName") })),
491
- ];
492
- export const toast = (open) => [
493
- row("toast", ui.Button({ onPress: () => ({ deleted: true, toast: true }) }, "Delete a draft"), ui.Text({ variant: "detail", tone: "secondary", as: "span" }, (state) => state.deleted ? "The draft is deleted." : "The draft is there.")),
494
- ui.Toast({
495
- open: (state) => state.toast,
496
- onClose: () => ({ toast: false }),
497
- message: "The draft was deleted.",
498
- action: { label: "Undo", onPress: () => ({ deleted: false }) },
499
- ...(open === "toast" ? { duration: 0 } : {}),
500
- }),
501
- ];
502
- export const skeleton = () => [
503
- row("shape", el("div", { class: "flex w-48 flex-col gap-2" }, ui.Skeleton({}), ui.Skeleton({ width: "60%" })), ui.Skeleton({ shape: "rect", width: 96, height: 64 }), ui.Skeleton({ shape: "circle", width: 40 })),
504
- ui.Card({ class: "max-w-sm", flush: true }, el("div", { role: "status", "aria-label": "Loading the report", class: "flex flex-col" }, ui.Skeleton({ shape: "rect", height: 128 }), el("div", { class: "flex items-center gap-3 p-4" }, ui.Skeleton({ shape: "circle", width: 40 }), el("div", { class: "flex flex-1 flex-col gap-2" }, ui.Skeleton({ width: "70%" }), ui.Skeleton({ width: "40%" }))))),
505
- ];
506
- export const emptyState = () => [
507
- el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.Card({}, ui.EmptyState({
508
- icon: "mail",
509
- title: "No messages yet",
510
- description: "When someone writes to you, the conversation shows up here.",
511
- action: ui.Button({ variant: "primary", iconStart: "plus" }, "New message"),
512
- })), ui.Card({}, ui.EmptyState({
513
- icon: "search",
514
- title: "No results",
515
- description: "Try fewer words, or check the spelling.",
516
- }))),
517
- ];