@xds/core 1.1.0 → 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.
- package/dist/breadcrumb.d.ts +39 -0
- package/dist/breadcrumb.js +7 -0
- package/dist/checkbox.d.ts +16 -2
- package/dist/checkbox.js +3 -1
- package/dist/combobox.d.ts +59 -0
- package/dist/combobox.js +40 -0
- package/dist/index.d.ts +16 -7
- package/dist/index.js +15 -6
- package/dist/labels.d.ts +12 -5
- package/dist/labels.js +12 -5
- package/dist/link.d.ts +49 -0
- package/dist/link.js +12 -0
- package/dist/pagination.d.ts +51 -0
- package/dist/pagination.js +25 -0
- package/dist/popover.d.ts +33 -0
- package/dist/popover.js +8 -0
- package/dist/preview/components.d.ts +36 -0
- package/dist/preview/components.js +1 -0
- package/dist/preview/design.d.ts +22 -3
- package/dist/preview/design.js +65 -34
- package/dist/preview/fixtures.d.ts +0 -76
- package/dist/preview/fixtures.js +0 -126
- package/dist/preview/kit.d.ts +48 -32
- package/dist/preview/kit.js +3 -0
- package/dist/preview/page.d.ts +1 -1
- package/dist/preview/page.js +1 -0
- package/dist/preview/sections/accordion.d.ts +1 -0
- package/dist/preview/sections/accordion.js +40 -0
- package/dist/preview/sections/badges.d.ts +1 -0
- package/dist/preview/sections/badges.js +13 -0
- package/dist/preview/sections/banners.d.ts +1 -0
- package/dist/preview/sections/banners.js +13 -0
- package/dist/preview/sections/buttons.d.ts +2 -0
- package/dist/preview/sections/buttons.js +30 -0
- package/dist/preview/sections/card.d.ts +1 -0
- package/dist/preview/sections/card.js +33 -0
- package/dist/preview/sections/chips.d.ts +1 -0
- package/dist/preview/sections/chips.js +23 -0
- package/dist/preview/sections/controls.d.ts +1 -0
- package/dist/preview/sections/controls.js +143 -0
- package/dist/preview/sections/dialog.d.ts +1 -0
- package/dist/preview/sections/dialog.js +25 -0
- package/dist/preview/sections/empty-state.d.ts +1 -0
- package/dist/preview/sections/empty-state.js +13 -0
- package/dist/preview/sections/links.d.ts +1 -0
- package/dist/preview/sections/links.js +8 -0
- package/dist/preview/sections/list.d.ts +1 -0
- package/dist/preview/sections/list.js +119 -0
- package/dist/preview/sections/media.d.ts +1 -0
- package/dist/preview/sections/media.js +90 -0
- package/dist/preview/sections/menu.d.ts +1 -0
- package/dist/preview/sections/menu.js +46 -0
- package/dist/preview/sections/navigation.d.ts +1 -0
- package/dist/preview/sections/navigation.js +20 -0
- package/dist/preview/sections/selection.d.ts +1 -0
- package/dist/preview/sections/selection.js +33 -0
- package/dist/preview/sections/sidebar.d.ts +1 -0
- package/dist/preview/sections/sidebar.js +45 -0
- package/dist/preview/sections/skeleton.d.ts +1 -0
- package/dist/preview/sections/skeleton.js +5 -0
- package/dist/preview/sections/tabs.d.ts +1 -0
- package/dist/preview/sections/tabs.js +24 -0
- package/dist/preview/sections/text-fields.d.ts +1 -0
- package/dist/preview/sections/text-fields.js +75 -0
- package/dist/preview/sections/toast.d.ts +2 -0
- package/dist/preview/sections/toast.js +28 -0
- package/dist/preview/specimens.js +1 -1
- package/dist/progress-bar.d.ts +7 -4
- package/dist/progress-bar.js +2 -2
- package/dist/rows.d.ts +23 -0
- package/dist/rows.js +67 -0
- package/dist/segmented-control.d.ts +1 -1
- package/dist/segmented-control.js +1 -1
- package/dist/select.d.ts +22 -0
- package/dist/select.js +7 -0
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +2 -1
- package/dist/table.d.ts +62 -0
- package/dist/table.js +25 -0
- package/dist/theme-scope.d.ts +6 -4
- package/dist/theme-scope.js +21 -15
- package/dist/time-picker.d.ts +57 -0
- package/dist/time-picker.js +53 -0
- package/dist/toast-queue.d.ts +40 -0
- package/dist/toast-queue.js +17 -0
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +1 -1
- package/package.json +2 -2
- package/dist/preview/sections.d.ts +0 -20
- package/dist/preview/sections.js +0 -517
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { bind, el, ui } from "../kit.js";
|
|
2
|
+
const QUESTIONS = [
|
|
3
|
+
{
|
|
4
|
+
value: "cancel",
|
|
5
|
+
title: "Can I cancel at any time?",
|
|
6
|
+
content: "Yes. The plan stays active until the end of the period you paid for.",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: "seats",
|
|
10
|
+
title: "How are seats counted?",
|
|
11
|
+
description: "Guests are free",
|
|
12
|
+
content: "Each person with an account in the workspace takes a seat. Guests do not.",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: "invoice",
|
|
16
|
+
title: "Where do I find my invoices?",
|
|
17
|
+
content: "Under Settings, then Billing. Each invoice can be downloaded as a PDF.",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
const PREFERENCES = [
|
|
21
|
+
{
|
|
22
|
+
value: "notifications",
|
|
23
|
+
title: "Notifications",
|
|
24
|
+
description: "Mentions, replies and reminders",
|
|
25
|
+
content: "Choose what you hear about, and whether by email or in the app.",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: "privacy",
|
|
29
|
+
title: "Privacy",
|
|
30
|
+
content: "Choose who can see your profile and your activity.",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: "language",
|
|
34
|
+
title: "Language and region",
|
|
35
|
+
content: "The language of the app, and how dates and numbers are written.",
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
export const accordion = () => [
|
|
39
|
+
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 }))),
|
|
40
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const badges: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DAY, NIGHT } from "../fixtures.js";
|
|
2
|
+
import { el, row, ui } from "../kit.js";
|
|
3
|
+
const BADGE_TONES = ["neutral", "accent", "success", "warning", "danger"];
|
|
4
|
+
export const badges = () => [
|
|
5
|
+
row("tone", ...BADGE_TONES.map((tone) => ui.Badge({ tone }, tone))),
|
|
6
|
+
row("dot", ui.Badge({ tone: "success", dot: true }, "Online"), ui.Badge({ tone: "warning", dot: true }, "Connecting"), ui.Badge({ tone: "danger", dot: true }, "Offline")),
|
|
7
|
+
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")),
|
|
8
|
+
row("overlay", ...[
|
|
9
|
+
{ name: "dark", src: NIGHT },
|
|
10
|
+
{ name: "light", src: DAY },
|
|
11
|
+
].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"))))),
|
|
12
|
+
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" })))),
|
|
13
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const banners: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { keep, show, ui } from "../kit.js";
|
|
2
|
+
const BANNER_TONES = ["info", "success", "warning", "danger"];
|
|
3
|
+
export const banners = () => [
|
|
4
|
+
...BANNER_TONES.map((tone) => ui.Banner({ tone, title: tone }, "Your changes are saved on this device. They sync when you are back online.")),
|
|
5
|
+
show((state) => !state.dismissed, ui.Banner({
|
|
6
|
+
tone: "warning",
|
|
7
|
+
title: "Your trial ends in three days",
|
|
8
|
+
action: { label: "Choose a plan", onPress: keep },
|
|
9
|
+
onDismiss: () => ({ dismissed: true }),
|
|
10
|
+
}, "After that the workspace becomes read-only until a plan is chosen."), ui.Button({ size: "sm", onPress: () => ({ dismissed: false }) }, "Show the dismissed banner again")),
|
|
11
|
+
ui.Banner({ tone: "info", onDismiss: keep, dismissLabel: "Dismiss the update notice" }, "A new version is available."),
|
|
12
|
+
ui.Banner({ tone: "danger", action: { label: "Try again", onPress: keep } }, "The report could not be sent."),
|
|
13
|
+
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { el, row, toggle, ui } from "../kit.js";
|
|
2
|
+
const VARIANTS = ["primary", "secondary", "ghost", "danger"];
|
|
3
|
+
const SIZES = ["sm", "md", "lg"];
|
|
4
|
+
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."));
|
|
5
|
+
export const buttons = (open) => [
|
|
6
|
+
...(open === "tooltip" ? [tooltips()] : []),
|
|
7
|
+
...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"))),
|
|
8
|
+
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" })),
|
|
9
|
+
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")),
|
|
10
|
+
row("selected", ui.Button({ iconStart: "heart", selected: (state) => state.liked, onPress: toggle("liked") }, "Like"), ui.Button({ iconStart: "heart", selected: false }, "Like"), ui.Button({
|
|
11
|
+
variant: "ghost",
|
|
12
|
+
iconStart: "bookmark",
|
|
13
|
+
selected: (state) => state.saved,
|
|
14
|
+
onPress: toggle("saved"),
|
|
15
|
+
}, "Save"), ui.Button({ variant: "ghost", iconStart: "bookmark", selected: false }, "Save"), ui.Button({
|
|
16
|
+
variant: "ghost",
|
|
17
|
+
size: "sm",
|
|
18
|
+
iconStart: "star",
|
|
19
|
+
selected: true,
|
|
20
|
+
"aria-label": "Starred",
|
|
21
|
+
}), ui.Button({ iconStart: "heart", selected: true, disabled: true }, "Disabled"), ui.Button({ variant: "primary", iconStart: "bell", selected: true }, "Primary")),
|
|
22
|
+
...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 }))),
|
|
23
|
+
row("icon, selected", ui.IconButton({
|
|
24
|
+
icon: "pin",
|
|
25
|
+
label: "Pin",
|
|
26
|
+
selected: (state) => state.pinned,
|
|
27
|
+
onPress: toggle("pinned"),
|
|
28
|
+
}), 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 })),
|
|
29
|
+
...(open === "tooltip" ? [] : [tooltips()]),
|
|
30
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const card: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BROKEN, DAY, NIGHT, PORTRAIT } from "../fixtures.js";
|
|
2
|
+
import { el, keep, row, toggle, ui } from "../kit.js";
|
|
3
|
+
const PEOPLE = [
|
|
4
|
+
{ name: "Ada Lovelace", src: PORTRAIT },
|
|
5
|
+
{ name: "Grace Hopper" },
|
|
6
|
+
{ name: "Alan Turing" },
|
|
7
|
+
{ name: "Katherine Johnson" },
|
|
8
|
+
{ name: "Margaret Hamilton" },
|
|
9
|
+
{ name: "Linus Torvalds" },
|
|
10
|
+
{ name: "Barbara Liskov" },
|
|
11
|
+
];
|
|
12
|
+
export const card = () => [
|
|
13
|
+
ui.Card({
|
|
14
|
+
title: "Weekly report",
|
|
15
|
+
description: "Updated a few minutes ago.",
|
|
16
|
+
actions: ui.Badge({ tone: "success", dot: true }, "Online"),
|
|
17
|
+
}, 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" })))),
|
|
18
|
+
el("div", { class: "grid items-start gap-4 sm:grid-cols-3" }, ui.Card({
|
|
19
|
+
title: "Night hike",
|
|
20
|
+
description: "Media runs edge to edge.",
|
|
21
|
+
media: el("img", { src: NIGHT, alt: "", class: "h-28 object-cover" }),
|
|
22
|
+
}, 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({
|
|
23
|
+
title: "Yearly billing",
|
|
24
|
+
description: (state) => (state.picked ? "Selected. Press to clear." : "Press to select."),
|
|
25
|
+
selected: (state) => state.picked,
|
|
26
|
+
onPress: toggle("picked"),
|
|
27
|
+
}, ui.Text({ variant: "detail", tone: "secondary", as: "span" }, "Two months free.")), ui.Card({
|
|
28
|
+
title: "Morning walk",
|
|
29
|
+
description: "Selected, with media.",
|
|
30
|
+
selected: true,
|
|
31
|
+
media: el("img", { src: DAY, alt: "", class: "h-28 object-cover" }),
|
|
32
|
+
}), 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."))),
|
|
33
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chips: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { el, row, ui } from "../kit.js";
|
|
2
|
+
const FILTERS = [
|
|
3
|
+
{ value: "open", label: "Open", icon: "flag" },
|
|
4
|
+
{ value: "mine", label: "Assigned to me", icon: "user" },
|
|
5
|
+
{ value: "mentions", label: "Mentions", icon: "message-square" },
|
|
6
|
+
{ value: "review", label: "Needs review", icon: "eye" },
|
|
7
|
+
{ value: "blocked", label: "Blocked", icon: "ban" },
|
|
8
|
+
{ value: "done", label: "Done this week", icon: "check-check" },
|
|
9
|
+
{ value: "archived", label: "Archived", icon: "history" },
|
|
10
|
+
];
|
|
11
|
+
export const chips = () => [
|
|
12
|
+
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 })),
|
|
13
|
+
row("bar", el("div", { class: "max-w-md min-w-0 flex-1" }, ui.ChipBar({ label: "Filter the tasks" }, ...FILTERS.map((filter) => ui.Chip({
|
|
14
|
+
label: filter.label,
|
|
15
|
+
iconStart: filter.icon,
|
|
16
|
+
selected: (state) => state.filters.includes(filter.value),
|
|
17
|
+
onPress: (state) => ({
|
|
18
|
+
filters: state.filters.includes(filter.value)
|
|
19
|
+
? state.filters.filter((other) => other !== filter.value)
|
|
20
|
+
: [...state.filters, filter.value],
|
|
21
|
+
}),
|
|
22
|
+
}))))),
|
|
23
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const controls: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { bind, el, keep, ui } from "../kit.js";
|
|
2
|
+
const PLANS = [
|
|
3
|
+
{ value: "free", label: "Free", description: "Up to 3 projects" },
|
|
4
|
+
{ value: "team", label: "Team", description: "Up to 20 people" },
|
|
5
|
+
{ value: "business", label: "Business", description: "Single sign-on and audit logs" },
|
|
6
|
+
{ value: "enterprise", label: "Enterprise", description: "A contract of your own" },
|
|
7
|
+
];
|
|
8
|
+
const COUNTRIES = [
|
|
9
|
+
"Argentina",
|
|
10
|
+
"Australia",
|
|
11
|
+
"Brazil",
|
|
12
|
+
"Canada",
|
|
13
|
+
"France",
|
|
14
|
+
"Germany",
|
|
15
|
+
"Japan",
|
|
16
|
+
"Korea",
|
|
17
|
+
"Mexico",
|
|
18
|
+
"Spain",
|
|
19
|
+
"United Kingdom",
|
|
20
|
+
"United States",
|
|
21
|
+
].map((name) => ({ value: name.toLowerCase().replace(/ /g, "-"), label: name }));
|
|
22
|
+
const TIME_ZONES = [
|
|
23
|
+
{ value: "utc", label: "Coordinated Universal Time" },
|
|
24
|
+
{ value: "seoul", label: "Seoul" },
|
|
25
|
+
{ value: "berlin", label: "Berlin" },
|
|
26
|
+
];
|
|
27
|
+
const CURRENCIES = [{ value: "eur", label: "Euro" }];
|
|
28
|
+
const CITIES = [
|
|
29
|
+
{ value: "berlin", label: "Berlin" },
|
|
30
|
+
{ value: "busan", label: "Busan" },
|
|
31
|
+
{ value: "lisbon", label: "Lisbon" },
|
|
32
|
+
{ value: "melbourne", label: "Melbourne" },
|
|
33
|
+
{ value: "osaka", label: "Osaka" },
|
|
34
|
+
{ value: "sao-paulo", label: "São Paulo" },
|
|
35
|
+
{ value: "seoul", label: "Seoul" },
|
|
36
|
+
{ value: "toronto", label: "Toronto" },
|
|
37
|
+
];
|
|
38
|
+
const WEEKDAYS = [
|
|
39
|
+
{ value: "mon", label: "Monday" },
|
|
40
|
+
{ value: "tue", label: "Tuesday" },
|
|
41
|
+
{ value: "wed", label: "Wednesday" },
|
|
42
|
+
{ value: "thu", label: "Thursday" },
|
|
43
|
+
{ value: "fri", label: "Friday" },
|
|
44
|
+
];
|
|
45
|
+
export const controls = () => [
|
|
46
|
+
el("div", { class: "grid gap-4 sm:grid-cols-2" }, el("div", {}, ui.Select({
|
|
47
|
+
label: "Plan",
|
|
48
|
+
options: PLANS,
|
|
49
|
+
...bind("plan"),
|
|
50
|
+
description: "Change it at any time.",
|
|
51
|
+
})), ui.Select({
|
|
52
|
+
label: "Country",
|
|
53
|
+
placeholder: "Choose a country",
|
|
54
|
+
options: COUNTRIES,
|
|
55
|
+
...bind("country"),
|
|
56
|
+
}), ui.Select({
|
|
57
|
+
label: "Time zone",
|
|
58
|
+
placeholder: "Choose a time zone",
|
|
59
|
+
options: TIME_ZONES,
|
|
60
|
+
...bind("timeZone"),
|
|
61
|
+
error: (state) => state.timeZone === undefined ? "Choose a time zone for the reminders." : undefined,
|
|
62
|
+
}), ui.Select({
|
|
63
|
+
label: "Reminder days",
|
|
64
|
+
placeholder: "Choose days",
|
|
65
|
+
options: WEEKDAYS,
|
|
66
|
+
multiple: true,
|
|
67
|
+
values: (state) => state.reminderDays,
|
|
68
|
+
onValuesChange: (_, values) => ({ reminderDays: values }),
|
|
69
|
+
description: "Choose as many as you like.",
|
|
70
|
+
}), ui.Combobox({
|
|
71
|
+
label: "City",
|
|
72
|
+
placeholder: "Search cities",
|
|
73
|
+
options: CITIES,
|
|
74
|
+
...bind("city"),
|
|
75
|
+
description: "Type a few letters to find it.",
|
|
76
|
+
}), ui.Select({
|
|
77
|
+
label: "Currency",
|
|
78
|
+
options: CURRENCIES,
|
|
79
|
+
value: "eur",
|
|
80
|
+
onChange: keep,
|
|
81
|
+
disabled: true,
|
|
82
|
+
})),
|
|
83
|
+
el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.DatePicker({
|
|
84
|
+
label: "Due date",
|
|
85
|
+
...bind("dueDate"),
|
|
86
|
+
min: "2026-03-05",
|
|
87
|
+
max: "2026-04-20",
|
|
88
|
+
description: "Within the current sprint.",
|
|
89
|
+
}), ui.DatePicker({
|
|
90
|
+
label: "Start date",
|
|
91
|
+
placeholder: "Choose a day",
|
|
92
|
+
...bind("startDate"),
|
|
93
|
+
error: (state) => state.startDate === undefined ? "Choose when the project starts." : undefined,
|
|
94
|
+
}), ui.DatePicker({ label: "Locked", value: "2026-03-10", onChange: keep, disabled: true })),
|
|
95
|
+
el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.TimePicker({
|
|
96
|
+
label: "Reminder time",
|
|
97
|
+
...bind("reminderTime"),
|
|
98
|
+
min: "08:00",
|
|
99
|
+
max: "20:00",
|
|
100
|
+
description: "Every half hour, through the working day.",
|
|
101
|
+
}), ui.TimePicker({
|
|
102
|
+
label: "Meeting time",
|
|
103
|
+
placeholder: "Choose a time",
|
|
104
|
+
step: 15,
|
|
105
|
+
...bind("meetingTime"),
|
|
106
|
+
error: (state) => state.meetingTime === undefined ? "Choose when the meeting starts." : undefined,
|
|
107
|
+
}), ui.TimePicker({ label: "Locked time", value: "09:00", onChange: keep, disabled: true })),
|
|
108
|
+
el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.DateRangePicker({
|
|
109
|
+
label: "Stay",
|
|
110
|
+
...bind("stay"),
|
|
111
|
+
min: "2026-03-05",
|
|
112
|
+
max: "2026-04-20",
|
|
113
|
+
minLength: 2,
|
|
114
|
+
maxLength: 14,
|
|
115
|
+
startLabel: "Check-in",
|
|
116
|
+
endLabel: "Check-out",
|
|
117
|
+
description: "Two nights at least.",
|
|
118
|
+
}), ui.DateRangePicker({
|
|
119
|
+
label: "Leave",
|
|
120
|
+
placeholder: "Choose the days",
|
|
121
|
+
...bind("leave"),
|
|
122
|
+
error: (state) => (state.leave === undefined ? "Choose the days of your leave." : undefined),
|
|
123
|
+
}), ui.DateRangePicker({
|
|
124
|
+
label: "Locked range",
|
|
125
|
+
value: { start: "2026-03-10", end: "2026-03-14" },
|
|
126
|
+
onChange: keep,
|
|
127
|
+
disabled: true,
|
|
128
|
+
})),
|
|
129
|
+
el("div", { class: "grid gap-x-8 gap-y-6 sm:grid-cols-2" }, ui.Slider({ label: "Volume", ...bind("volume"), showValue: true }), ui.Slider({
|
|
130
|
+
label: "Font size",
|
|
131
|
+
min: 12,
|
|
132
|
+
max: 24,
|
|
133
|
+
step: 2,
|
|
134
|
+
...bind("fontSize"),
|
|
135
|
+
showValue: true,
|
|
136
|
+
}), ui.Slider({ label: "Brightness", ...bind("volume") }), ui.Slider({
|
|
137
|
+
label: "Balance, locked",
|
|
138
|
+
value: 30,
|
|
139
|
+
onChange: keep,
|
|
140
|
+
disabled: true,
|
|
141
|
+
showValue: true,
|
|
142
|
+
})),
|
|
143
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const dialog: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { bind, row, ui } from "../kit.js";
|
|
2
|
+
export const dialog = () => [
|
|
3
|
+
row("dialog", ui.Button({ variant: "danger", onPress: () => ({ confirming: true }) }, "Delete the report"), ui.Button({ onPress: () => ({ asking: true }) }, "A question that must be answered")),
|
|
4
|
+
ui.Dialog({
|
|
5
|
+
open: (state) => state.confirming,
|
|
6
|
+
onClose: () => ({ confirming: false }),
|
|
7
|
+
title: "Delete the weekly report?",
|
|
8
|
+
description: "The report and its 12 comments are removed for everyone. This cannot be undone.",
|
|
9
|
+
actions: [
|
|
10
|
+
ui.Button({ onPress: () => ({ confirming: false }) }, "Cancel"),
|
|
11
|
+
ui.Button({ variant: "danger", onPress: () => ({ confirming: false }) }, "Delete"),
|
|
12
|
+
],
|
|
13
|
+
}),
|
|
14
|
+
ui.Dialog({
|
|
15
|
+
open: (state) => state.asking,
|
|
16
|
+
onClose: () => ({ asking: false }),
|
|
17
|
+
dismissible: false,
|
|
18
|
+
title: "Keep the changes?",
|
|
19
|
+
description: "You edited the report in another window.",
|
|
20
|
+
actions: [
|
|
21
|
+
ui.Button({ onPress: () => ({ asking: false }) }, "Discard"),
|
|
22
|
+
ui.Button({ variant: "primary", onPress: () => ({ asking: false }) }, "Keep"),
|
|
23
|
+
],
|
|
24
|
+
}, ui.TextField({ label: "Name of the copy", ...bind("copyName") })),
|
|
25
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const emptyState: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { el, ui } from "../kit.js";
|
|
2
|
+
export const emptyState = () => [
|
|
3
|
+
el("div", { class: "grid gap-4 sm:grid-cols-2" }, ui.Card({}, ui.EmptyState({
|
|
4
|
+
icon: "mail",
|
|
5
|
+
title: "No messages yet",
|
|
6
|
+
description: "When someone writes to you, the conversation shows up here.",
|
|
7
|
+
action: ui.Button({ variant: "primary", iconStart: "plus" }, "New message"),
|
|
8
|
+
})), ui.Card({}, ui.EmptyState({
|
|
9
|
+
icon: "search",
|
|
10
|
+
title: "No results",
|
|
11
|
+
description: "Try fewer words, or check the spelling.",
|
|
12
|
+
}))),
|
|
13
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const links: () => import("../model.ts").PreviewNode<import("../kit.ts").DesignState>[];
|
|
@@ -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>[];
|