@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
@@ -0,0 +1,8 @@
1
+ import { row, ui } from "../kit.js";
2
+ export const links = () => [
3
+ row("link", ui.Link({ href: "#buttons" }, "Go to the buttons")),
4
+ row("external", ui.Link({ href: "https://example.com", external: true }, "example.com")),
5
+ row("disabled", ui.Link({ href: "#buttons", disabled: true }, "Not available yet")),
6
+ row("in text", ui.Text({ class: "min-w-0 flex-1" }, "By signing up you agree to the ", ui.Link({ onPress: () => ({ linked: "Opened the terms." }) }, "terms of service"), " and the ", ui.Link({ href: "https://example.com/privacy", external: true }, "privacy policy"), ".")),
7
+ ui.Text({ variant: "detail", tone: "secondary" }, (state) => state.linked),
8
+ ];
@@ -0,0 +1 @@
1
+ export declare const list: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,119 @@
1
+ import { bind, keep, ui } from "../kit.js";
2
+ const listIcon = (name) => ui.Icon({ name, size: "sm", class: "text-xds-text-secondary" });
3
+ const FILES = [
4
+ {
5
+ id: "brief",
6
+ name: "Project brief.pdf",
7
+ owner: "Ada Lovelace",
8
+ size: 2_400_000,
9
+ shownSize: "2.4 MB",
10
+ modified: "2026-03-10",
11
+ shownModified: "Mar 10, 2026",
12
+ },
13
+ {
14
+ id: "budget",
15
+ name: "Budget 2026.xlsx",
16
+ owner: "Grace Hopper",
17
+ size: 860_000,
18
+ shownSize: "860 KB",
19
+ modified: "2026-03-12",
20
+ shownModified: "Mar 12, 2026",
21
+ },
22
+ {
23
+ id: "logo",
24
+ name: "Logo.svg",
25
+ owner: "Ada Lovelace",
26
+ size: 48_000,
27
+ shownSize: "48 KB",
28
+ modified: "2026-02-27",
29
+ shownModified: "Feb 27, 2026",
30
+ },
31
+ {
32
+ id: "notes",
33
+ name: "Meeting notes.md",
34
+ owner: "Alan Turing",
35
+ size: 12_000,
36
+ shownSize: "12 KB",
37
+ modified: "2026-03-14",
38
+ shownModified: "Mar 14, 2026",
39
+ },
40
+ ];
41
+ const FILE_COLUMNS = [
42
+ { key: "name", label: "Name", sortable: true },
43
+ { key: "owner", label: "Owner" },
44
+ { key: "size", label: "Size", align: "end", sortable: true },
45
+ { key: "modified", label: "Modified", sortable: true },
46
+ ];
47
+ function fileRows(sort) {
48
+ const key = sort.column;
49
+ const sorted = [...FILES].sort((a, b) => (a[key] < b[key] ? -1 : a[key] > b[key] ? 1 : 0));
50
+ if (sort.direction === "descending")
51
+ sorted.reverse();
52
+ return sorted.map((file) => ({
53
+ id: file.id,
54
+ cells: [file.name, file.owner, file.shownSize, file.shownModified],
55
+ }));
56
+ }
57
+ export const list = () => [
58
+ ui.Table({
59
+ label: "Files",
60
+ columns: FILE_COLUMNS,
61
+ rows: (state) => fileRows(state.fileSort),
62
+ sort: (state) => state.fileSort,
63
+ onSortChange: (_, sort) => ({ fileSort: sort }),
64
+ }),
65
+ ui.Table({
66
+ label: "Shared files",
67
+ columns: FILE_COLUMNS.map(({ key, label }) => ({ key, label })),
68
+ rows: [],
69
+ empty: "Nothing has been shared with you yet.",
70
+ }),
71
+ ui.Card({ flush: true }, ui.ListRow({
72
+ leading: ui.Avatar({ name: "Ada Lovelace" }),
73
+ title: "Ada Lovelace",
74
+ description: "ada@example.com",
75
+ trailing: ui.Badge({ tone: "accent" }, "Owner"),
76
+ }), ui.Divider({}), ui.ListRow({
77
+ title: "Notifications",
78
+ description: "Mentions and replies",
79
+ trailing: ui.Switch({ "aria-label": "Notifications", ...bind("notifications", "checked") }),
80
+ }), ui.Divider({}), ui.ListRow({
81
+ title: "Language",
82
+ trailing: ui.Text({ tone: "secondary", as: "span" }, "English"),
83
+ chevron: true,
84
+ onPress: keep,
85
+ }), ui.Divider({}), ui.ListRow({
86
+ title: "Storage",
87
+ description: "Unavailable offline",
88
+ chevron: true,
89
+ onPress: keep,
90
+ disabled: true,
91
+ }), ui.Divider({}), ui.ListRow({
92
+ leading: ui.Avatar({ name: "Grace Hopper" }),
93
+ title: "Grace Hopper",
94
+ description: "The selected row",
95
+ trailing: ui.CountBadge({ count: 3, label: "3 unread messages" }),
96
+ selected: true,
97
+ onPress: keep,
98
+ }), ui.Divider({}), ui.ListRow({ title: "Selected, without an action", description: "Read-only", selected: true })),
99
+ ui.Card({ flush: true, class: "max-w-xs" }, ui.ListRow({
100
+ compact: true,
101
+ leading: listIcon("mail"),
102
+ title: "Inbox",
103
+ trailing: ui.CountBadge({ count: 12, label: "12 unread" }),
104
+ selected: true,
105
+ onPress: keep,
106
+ }), ui.ListRow({ compact: true, leading: listIcon("file-text"), title: "Drafts", onPress: keep }), ui.ListRow({
107
+ compact: true,
108
+ leading: listIcon("clock"),
109
+ title: "Scheduled",
110
+ description: "Compact, with a description",
111
+ onPress: keep,
112
+ }), ui.ListRow({
113
+ compact: true,
114
+ leading: listIcon("trash"),
115
+ title: "Trash",
116
+ onPress: keep,
117
+ disabled: true,
118
+ })),
119
+ ];
@@ -0,0 +1 @@
1
+ export declare const media: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,90 @@
1
+ import { BROKEN, DAY, NIGHT, PORTRAIT } from "../fixtures.js";
2
+ import { el, ui } from "../kit.js";
3
+ const RATIOS = [
4
+ { ratio: "16:9", width: "w-48" },
5
+ { ratio: "4:3", width: "w-36" },
6
+ { ratio: "1:1", width: "w-28" },
7
+ { ratio: "9:16", width: "w-16" },
8
+ ];
9
+ const videoActions = (title) => ui.Menu({
10
+ label: `Actions for ${title}`,
11
+ align: "end",
12
+ trigger: ui.IconButton({ icon: "ellipsis-vertical", label: "More actions" }),
13
+ items: [
14
+ {
15
+ label: "Save to watch later",
16
+ icon: "clock",
17
+ onSelect: () => ({ opened: `Saved ${title}.` }),
18
+ },
19
+ { label: "Share", icon: "share-2", onSelect: () => ({ opened: `Shared ${title}.` }) },
20
+ ],
21
+ });
22
+ const opens = (opened) => () => ({ opened });
23
+ export const media = () => [
24
+ ui.SectionHeader({
25
+ title: "Continue watching",
26
+ description: "Pick up where you left off.",
27
+ action: { label: "See all", onPress: opens("See all.") },
28
+ }),
29
+ 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)))),
30
+ el("div", { class: "grid grid-cols-2 gap-3 sm:grid-cols-5" }, ...[
31
+ {
32
+ caption: "Fails to load",
33
+ thumbnail: ui.Thumbnail({ src: BROKEN, alt: "A picture that fails to load" }),
34
+ },
35
+ { caption: "No picture, badge", thumbnail: ui.Thumbnail({ alt: "", badge: "Live" }) },
36
+ { caption: "Badge", thumbnail: ui.Thumbnail({ src: DAY, alt: "", badge: "12:04" }) },
37
+ { caption: "Progress", thumbnail: ui.Thumbnail({ src: NIGHT, alt: "", progress: 0.35 }) },
38
+ {
39
+ caption: "Badge and progress",
40
+ thumbnail: ui.Thumbnail({ src: DAY, alt: "", badge: "3:27", progress: 0.8 }),
41
+ },
42
+ ].map(({ caption, thumbnail }) => el("div", { class: "flex flex-col gap-1" }, thumbnail, ui.Text({ variant: "footnote", tone: "secondary", as: "span" }, caption)))),
43
+ el("div", { class: "grid items-start gap-2 sm:grid-cols-3" }, ui.MediaCard({
44
+ src: NIGHT,
45
+ title: "Night hike above the city: four hours, twelve kilometres and one long staircase",
46
+ meta: ["Ada Lovelace", "12K views · 3 days ago"],
47
+ badge: "12:04",
48
+ progress: 0.35,
49
+ leading: ui.Avatar({ name: "Ada Lovelace", src: PORTRAIT }),
50
+ action: videoActions("Night hike"),
51
+ onPress: opens("Opened Night hike."),
52
+ }), ui.MediaCard({
53
+ src: DAY,
54
+ title: "Morning walk",
55
+ meta: ["Grace Hopper", "840 views · 1 week ago"],
56
+ badge: "3:27",
57
+ leading: ui.Avatar({ name: "Grace Hopper" }),
58
+ action: videoActions("Morning walk"),
59
+ onPress: opens("Opened Morning walk."),
60
+ }), ui.MediaCard({
61
+ src: BROKEN,
62
+ title: "Not pressable, and its picture fails to load",
63
+ meta: ["Alan Turing"],
64
+ })),
65
+ el("div", { class: "grid items-start gap-2 sm:grid-cols-2" }, ui.MediaCard({
66
+ layout: "horizontal",
67
+ src: DAY,
68
+ title: "Ten small changes that make a report easier to read",
69
+ meta: ["Katherine Johnson", "5 min read"],
70
+ badge: "5:12",
71
+ progress: 0.6,
72
+ action: videoActions("Ten small changes"),
73
+ onPress: opens("Opened Ten small changes."),
74
+ }), ui.MediaCard({
75
+ layout: "horizontal",
76
+ src: NIGHT,
77
+ ratio: "1:1",
78
+ title: "Square, without an action",
79
+ meta: ["Margaret Hamilton", "2 days ago"],
80
+ onPress: opens("Opened Square."),
81
+ })),
82
+ ui.Text({ variant: "detail", tone: "secondary" }, (state) => state.opened),
83
+ ui.SectionHeader({
84
+ icon: "history",
85
+ title: "On its own",
86
+ description: "An icon, a description and an action, at heading level 3.",
87
+ action: { label: "Clear history", onPress: opens("Cleared the history.") },
88
+ level: 3,
89
+ }),
90
+ ];
@@ -0,0 +1 @@
1
+ export declare const menu: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,46 @@
1
+ import { el, keep, row, ui } from "../kit.js";
2
+ const chooses = (chosen) => () => ({ chosen });
3
+ export const menu = () => [
4
+ row("menu", el("span", { class: "flex" }, ui.Menu({
5
+ label: "Report actions",
6
+ trigger: ui.Button({ iconEnd: "chevron-down" }, "Actions"),
7
+ items: [
8
+ { label: "Rename", icon: "pencil", onSelect: chooses("Rename") },
9
+ { label: "Duplicate", icon: "copy", onSelect: chooses("Duplicate") },
10
+ { label: "Share", icon: "share-2", onSelect: keep, disabled: true },
11
+ "separator",
12
+ {
13
+ label: "Comfortable",
14
+ icon: "list",
15
+ selected: (state) => state.density === "comfortable",
16
+ onSelect: () => ({ density: "comfortable" }),
17
+ },
18
+ {
19
+ label: "Compact",
20
+ icon: "layout-grid",
21
+ selected: (state) => state.density === "compact",
22
+ onSelect: () => ({ density: "compact" }),
23
+ },
24
+ "separator",
25
+ { label: "Delete", icon: "trash", danger: true, onSelect: chooses("Delete") },
26
+ ],
27
+ })), ui.Menu({
28
+ label: "More actions",
29
+ align: "end",
30
+ trigger: ui.IconButton({ icon: "ellipsis", label: "More actions", variant: "secondary" }),
31
+ items: [
32
+ { label: "Copy the link", onSelect: chooses("Copy the link") },
33
+ { label: "Open in a new window", onSelect: chooses("Open in a new window") },
34
+ ],
35
+ }), ui.Text({ variant: "detail", tone: "secondary", as: "span" }, (state) => state.chosen, " Density: ", (state) => state.density, ".")),
36
+ row("popover", ui.Popover({
37
+ title: "Share the report",
38
+ trigger: ui.Button({ iconStart: "share-2" }, "Share"),
39
+ open: (state) => state.sharing,
40
+ onOpenChange: (_, open) => ({ sharing: open }),
41
+ }, ui.Text({ variant: "detail", tone: "secondary" }, "Everyone with the link can read the report. No one can change it."), ui.Button({ variant: "primary", onPress: () => ({ sharing: false, chosen: "The link is copied." }) }, "Copy the link")), ui.Popover({
42
+ title: "Due dates",
43
+ placement: "top",
44
+ trigger: ui.IconButton({ icon: "info", label: "About due dates", variant: "secondary" }),
45
+ }, ui.Text({ variant: "detail", tone: "secondary" }, "A report is due at the end of the Friday it is for."))),
46
+ ];
@@ -0,0 +1 @@
1
+ export declare const navigation: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,20 @@
1
+ import { bind, el, keep, row, ui } from "../kit.js";
2
+ const TRAIL = [
3
+ { label: "Home", href: "#navigation" },
4
+ { label: "Projects", href: "#navigation" },
5
+ { label: "Website redesign" },
6
+ ];
7
+ export const navigation = () => [
8
+ row("breadcrumb", ui.Breadcrumb({ items: TRAIL })),
9
+ row("wrapping", el("div", { class: "max-w-56" }, ui.Breadcrumb({
10
+ items: [
11
+ { label: "Home", href: "#navigation" },
12
+ { label: "Settings", href: "#navigation" },
13
+ { label: "Notifications", href: "#navigation" },
14
+ { label: "Email and messages" },
15
+ ],
16
+ }))),
17
+ row("pagination", ui.Pagination({ count: 12, ...bind("results") })),
18
+ row("near the end", ui.Pagination({ count: 12, value: 11, onChange: keep })),
19
+ row("few pages", ui.Pagination({ count: 3, value: 1, onChange: keep })),
20
+ ];
@@ -0,0 +1 @@
1
+ export declare const selection: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,33 @@
1
+ import { bind, el, keep, row, ui } from "../kit.js";
2
+ const VIEWS = [
3
+ { value: "day", label: "Day" },
4
+ { value: "week", label: "Week" },
5
+ { value: "month", label: "Month" },
6
+ ];
7
+ const DELIVERY = [
8
+ { value: "standard", label: "Standard", description: "Three to five working days. Free." },
9
+ { value: "express", label: "Express", description: "The next working day. 9 euros." },
10
+ { value: "pickup", label: "Pick up in a store" },
11
+ ];
12
+ const SIZES_OF_SHIRT = [
13
+ { value: "s", label: "Small" },
14
+ { value: "m", label: "Medium" },
15
+ { value: "l", label: "Large" },
16
+ ];
17
+ export const selection = () => [
18
+ 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 })),
19
+ row("checkbox", ui.Checkbox({ label: "Remember me", ...bind("agreed", "checked") }), ui.Checkbox({ checked: false, onChange: keep, label: "Unchecked" }), ui.Checkbox({ checked: false, indeterminate: true, onChange: keep, label: "Some selected" }), ui.Checkbox({ checked: true, onChange: keep, label: "Locked", disabled: true })),
20
+ row("segmented", ui.SegmentedControl({ options: VIEWS, "aria-label": "Calendar view", ...bind("view") })),
21
+ el("div", { class: "grid gap-6 sm:grid-cols-3" }, ui.RadioGroup({ label: "Delivery", options: DELIVERY, ...bind("delivery") }), ui.RadioGroup({
22
+ label: "Size",
23
+ options: SIZES_OF_SHIRT,
24
+ ...bind("shirt"),
25
+ error: (state) => (state.shirt === undefined ? "Choose a size to continue." : undefined),
26
+ }), ui.RadioGroup({
27
+ label: "Region, locked",
28
+ options: DELIVERY,
29
+ value: "express",
30
+ onChange: keep,
31
+ disabled: true,
32
+ })),
33
+ ];
@@ -0,0 +1 @@
1
+ export declare const sidebar: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,45 @@
1
+ import { PORTRAIT } from "../fixtures.js";
2
+ import { bind, el, ui } from "../kit.js";
3
+ const PLACES = [
4
+ {
5
+ items: [
6
+ { value: "home", label: "Home", icon: "house" },
7
+ { value: "messages", label: "Messages", icon: "message-square", count: 12 },
8
+ { value: "activity", label: "Activity", icon: "bell", count: 3 },
9
+ ],
10
+ },
11
+ {
12
+ title: "Library",
13
+ items: [
14
+ { value: "saved", label: "Saved", icon: "bookmark", count: 128 },
15
+ { value: "starred", label: "Starred", icon: "star" },
16
+ { value: "liked", label: "Liked", icon: "heart" },
17
+ ],
18
+ },
19
+ {
20
+ title: "Workspace",
21
+ items: [
22
+ { value: "members", label: "Members", icon: "users" },
23
+ { value: "settings", label: "Settings", icon: "settings" },
24
+ ],
25
+ },
26
+ ];
27
+ const placeLabel = (place) => PLACES.flatMap((section) => section.items).find((item) => item.value === place)?.label ?? place;
28
+ export const sidebar = () => [
29
+ el("div", { class: "grid gap-4 sm:grid-cols-2" }, ...[false, true].map((collapsed) => el("div", {
30
+ class: "flex h-[28rem] overflow-hidden rounded-xds-md border border-xds-border-default",
31
+ }, ui.Sidebar({
32
+ label: collapsed ? "Workspace, collapsed" : "Workspace",
33
+ sections: PLACES,
34
+ ...bind("place"),
35
+ collapsed,
36
+ header: el("div", {
37
+ class: `flex h-xds-control-md items-center gap-2 ${collapsed ? "justify-center" : "px-2"}`,
38
+ }, el("span", {
39
+ class: "flex size-xds-avatar-md items-center justify-center rounded-xds-md bg-xds-accent-default text-xds-text-on-accent",
40
+ }, ui.Icon({ name: "sparkles", size: "sm" })), ...(collapsed ? [] : [ui.Text({ variant: "label", as: "span" }, "Xds")])),
41
+ 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")])),
42
+ }), 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
43
+ ? "Rest the pointer on an icon, or focus it, for its name."
44
+ : "The page of the current place."))))),
45
+ ];
@@ -0,0 +1 @@
1
+ export declare const skeleton: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,5 @@
1
+ import { el, row, ui } from "../kit.js";
2
+ export const skeleton = () => [
3
+ 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 })),
4
+ 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%" }))))),
5
+ ];
@@ -0,0 +1 @@
1
+ export declare const tabs: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,24 @@
1
+ import { bind, el, ui } from "../kit.js";
2
+ const PAGES = [
3
+ { value: "overview", label: "Overview", icon: "house" },
4
+ { value: "activity", label: "Activity", icon: "bell" },
5
+ { value: "members", label: "Members", icon: "users" },
6
+ { value: "billing", label: "Billing", icon: "credit-card" },
7
+ { value: "settings", label: "Settings", icon: "settings" },
8
+ ];
9
+ export const tabs = () => [
10
+ ui.Tabs({ items: PAGES, label: "Workspace pages", ...bind("page") }),
11
+ ui.Tabs({
12
+ items: PAGES.map(({ value, label }) => ({ value, label })),
13
+ label: "Workspace pages, without icons",
14
+ ...bind("page"),
15
+ }),
16
+ ui.Tabs({
17
+ items: PAGES.slice(0, 3),
18
+ label: "Workspace pages, full width",
19
+ ...bind("page"),
20
+ value: (state) => state.page === "billing" || state.page === "settings" ? "overview" : state.page,
21
+ fullWidth: true,
22
+ }),
23
+ el("div", { class: "max-w-xs" }, ui.Tabs({ items: PAGES, label: "Workspace pages, scrolling", ...bind("page") })),
24
+ ];
@@ -0,0 +1 @@
1
+ export declare const textFields: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,75 @@
1
+ import { bind, el, keep, toggle, ui } from "../kit.js";
2
+ export const textFields = () => [
3
+ el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.TextField({
4
+ label: "Email",
5
+ placeholder: "name@example.com",
6
+ description: "We send the sign-in code to this address.",
7
+ ...bind("email"),
8
+ }), ui.TextField({ label: "Project name", value: "Weekly report", onChange: keep, required: true }), ui.TextField({
9
+ label: "Sign-in code",
10
+ value: "12345",
11
+ onChange: keep,
12
+ error: "That code is wrong or has expired.",
13
+ }), ui.TextField({ label: "Organization", value: "Xds Inc.", onChange: keep, disabled: true }), ui.TextField({
14
+ label: "Search",
15
+ placeholder: "Projects, people, files",
16
+ leading: ui.Icon({ name: "search", size: "sm" }),
17
+ ...bind("query"),
18
+ }), ui.TextField({
19
+ label: "Weight",
20
+ inputMode: "decimal",
21
+ value: "72.5",
22
+ onChange: keep,
23
+ trailing: ui.Text({ variant: "detail", tone: "inherit", as: "span" }, "kg"),
24
+ }), ui.TextField({
25
+ label: "Password",
26
+ type: (state) => (state.revealed ? "text" : "password"),
27
+ leading: ui.Icon({ name: "lock", size: "sm" }),
28
+ trailing: ui.Button({
29
+ variant: "ghost",
30
+ size: "sm",
31
+ iconStart: (state) => (state.revealed ? "eye-off" : "eye"),
32
+ "aria-label": (state) => (state.revealed ? "Hide the password" : "Show the password"),
33
+ onPress: toggle("revealed"),
34
+ }),
35
+ ...bind("secret"),
36
+ }), ui.TextField({
37
+ label: "Promo code",
38
+ leading: ui.Icon({ name: "tag", size: "sm" }),
39
+ value: "SPRING",
40
+ onChange: keep,
41
+ error: "That code has expired.",
42
+ }), ui.TextField({ label: "Notes", multiline: true, ...bind("notes") }), ui.TextField({
43
+ label: "Bio",
44
+ description: "Shown on your profile.",
45
+ multiline: true,
46
+ maxLength: 80,
47
+ ...bind("bio"),
48
+ }), ui.TextField({
49
+ label: "Message",
50
+ placeholder: "Write a reply",
51
+ multiline: true,
52
+ rows: 2,
53
+ leading: ui.Icon({ name: "message-square", size: "sm" }),
54
+ value: "",
55
+ onChange: keep,
56
+ }), ui.TextField({
57
+ label: "Display name",
58
+ maxLength: 12,
59
+ value: "Ada Lovelace",
60
+ onChange: keep,
61
+ error: "Use 12 characters or fewer, without spaces.",
62
+ })),
63
+ el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.SearchField({
64
+ label: "Search projects",
65
+ placeholder: "Search projects",
66
+ ...bind("search"),
67
+ onSubmit: (_, submitted) => ({ submitted }),
68
+ }), ui.SearchField({ label: "Search people", value: "Ada Lovelace", onChange: keep }), ui.SearchField({
69
+ label: "Search files",
70
+ placeholder: "Unavailable offline",
71
+ value: "",
72
+ onChange: keep,
73
+ disabled: true,
74
+ }), ui.Text({ variant: "detail", tone: "secondary", as: "span", class: "self-center" }, (state) => state.submitted ? `Searched for “${state.submitted}”.` : "Enter searches, Escape clears.")),
75
+ ];
@@ -0,0 +1,2 @@
1
+ import type { Overlay } from "../page.ts";
2
+ export declare const toast: (open: Overlay | undefined) => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
@@ -0,0 +1,28 @@
1
+ import { queueToast } from "../../toast-queue.js";
2
+ import { row, ui } from "../kit.js";
3
+ const REPORTS = ["weekly", "monthly", "yearly"];
4
+ export const toast = (open) => [
5
+ 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.")),
6
+ ui.Toast({
7
+ open: (state) => state.toast,
8
+ onClose: () => ({ toast: false }),
9
+ message: "The draft was deleted.",
10
+ action: { label: "Undo", onPress: () => ({ deleted: false }) },
11
+ ...(open === "toast" ? { duration: 0 } : {}),
12
+ }),
13
+ row("queue", ui.Button({
14
+ onPress: (state) => ({
15
+ queued: REPORTS.reduce((queued, report, index) => queueToast(queued, {
16
+ id: state.archived + index,
17
+ message: `The ${report} report is archived.`,
18
+ }), state.queued),
19
+ archived: state.archived + REPORTS.length,
20
+ }),
21
+ }, "Archive three reports"), ui.Text({ variant: "detail", tone: "secondary", as: "span" }, (state) => state.queued.length === 0
22
+ ? "Nothing to show."
23
+ : `${state.queued.length} to show, one at a time.`)),
24
+ ui.ToastQueue({
25
+ toasts: (state) => state.queued,
26
+ onClose: (state, id) => ({ queued: state.queued.filter((toast) => toast.id !== id) }),
27
+ }),
28
+ ];
@@ -1,6 +1,6 @@
1
1
  import { colors, icons, radius, size, space, typography } from "@xds/tokens";
2
2
  import { el, kebab, row, ui } from "./kit.js";
3
- const COMPONENT_COLORS = /^(button|field|badge|banner|card|switch|checkbox|radio|segmented|avatar|progress|slider|listRow|topBar|tabBar|sheet|chip|tabs|menu|datePicker|dialog|toast|tooltip|skeleton|thumbnail|sidebar|emptyState|accordion)/;
3
+ const COMPONENT_COLORS = /^(breadcrumb|button|field|badge|banner|card|switch|checkbox|radio|segmented|avatar|progress|slider|listRow|topBar|tabBar|sheet|chip|link|tabs|menu|datePicker|dialog|toast|tooltip|skeleton|thumbnail|sidebar|emptyState|accordion)/;
4
4
  const COLOR_GROUPS = Object.entries(Object.groupBy(Object.keys(colors.light).filter((name) => !COMPONENT_COLORS.test(name)), (name) => kebab(name).split("-")[0] ?? name));
5
5
  const ICON_SIZES = ["xs", "sm", "md", "lg", "xl"];
6
6
  const FILLABLE_ICONS = ["heart", "star", "bookmark", "thumbs-up", "bell"];
@@ -7,7 +7,10 @@ export type ProgressBarBaseProps = {
7
7
  };
8
8
  /** The whole percentage a value from 0 to 1 stands for, clamped to 0 to 100. */
9
9
  export declare function progressPercent(value: number): number;
10
- /** The track. It has the progress bar role and holds the fill. */
11
- export declare const progressBarClass = "h-xds-progress w-full overflow-hidden rounded-full bg-xds-progress-track";
12
- /** The fill, whose width is the percentage. */
13
- export declare const progressBarFillClass = "h-full rounded-full bg-xds-progress-fill transition-[width] duration-(--xds-motion-duration-normal) motion-reduce:transition-none";
10
+ /**
11
+ * The track. It has the progress bar role and holds the fill. Forced colors fill it in the page's
12
+ * color, so it takes an edge in the text's.
13
+ */
14
+ export declare const progressBarClass = "h-xds-progress w-full overflow-hidden rounded-full bg-xds-progress-track forced-colors:border forced-colors:border-[CanvasText]";
15
+ /** The fill, whose width is the percentage: the system's highlight in forced colors. */
16
+ export declare const progressBarFillClass = "h-full rounded-full bg-xds-progress-fill transition-[width] duration-(--xds-motion-duration-normal) motion-reduce:transition-none forced-colors:bg-[Highlight]";
@@ -1,5 +1,5 @@
1
1
  export function progressPercent(value) {
2
2
  return Math.round(Math.min(1, Math.max(0, value)) * 100);
3
3
  }
4
- export const progressBarClass = "h-xds-progress w-full overflow-hidden rounded-full bg-xds-progress-track";
5
- export const progressBarFillClass = "h-full rounded-full bg-xds-progress-fill transition-[width] duration-(--xds-motion-duration-normal) motion-reduce:transition-none";
4
+ export const progressBarClass = "h-xds-progress w-full overflow-hidden rounded-full bg-xds-progress-track forced-colors:border forced-colors:border-[CanvasText]";
5
+ export const progressBarFillClass = "h-full rounded-full bg-xds-progress-fill transition-[width] duration-(--xds-motion-duration-normal) motion-reduce:transition-none forced-colors:bg-[Highlight]";
@@ -9,8 +9,14 @@ export type RadioGroupBaseProps<Value extends string = string> = {
9
9
  /** The group's visible legend, which also names it for assistive technology. */
10
10
  label: string;
11
11
  options: readonly RadioOption<Value>[];
12
- /** The chosen option. Leave it out while nothing is chosen. */
12
+ /**
13
+ * The chosen option, `undefined` while nothing is chosen. Leave it out for a group that keeps
14
+ * its own choice, from `defaultValue`: the group is controlled whenever `value` is given, even
15
+ * as `undefined`.
16
+ */
13
17
  value?: Value | undefined;
18
+ /** The first choice of a group that keeps its own, without `value`. */
19
+ defaultValue?: Value | undefined;
14
20
  /** Disables the whole group. */
15
21
  disabled?: boolean;
16
22
  /** What is wrong and how to fix it, under the options. Clear it when the choice changes. */
package/dist/root.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * What every web component puts on its root element, beside the app's class and style: an `id`,
3
+ * and `data-*` attributes, such as the `data-testid` a test finds it by. The root is the
4
+ * component's outermost element, or the surface of an overlay: the panel of a Dialog, a Menu, a
5
+ * Tooltip or a Toast.
6
+ */
7
+ export type RootAttributes = {
8
+ id?: string | undefined;
9
+ } & {
10
+ [name: `data-${string}`]: string | number | boolean | undefined;
11
+ };
12
+ /** The `id` and `data-*` attributes among a component's props, to spread on its root element. */
13
+ export declare function rootAttributes(props: object): RootAttributes;
14
+ /**
15
+ * Whether a component is controlled: whether the app gives it the prop that holds its state,
16
+ * even as `undefined`. A component left without it keeps its own state, from its default, and
17
+ * still reports each change.
18
+ */
19
+ export declare function isControlled(props: object, name: string): boolean;
20
+ /**
21
+ * Calls `reset` each time the form that `element` is in is reset, once the form has put its
22
+ * fields back to their defaults: the event comes before it does. A control that keeps its own
23
+ * value sets it back to its default there, as the native field has. Returns what stops it.
24
+ */
25
+ export declare function onFormReset(element: Element | null | undefined, reset: () => void): () => void;