@xds/a2ui-react 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cases.js ADDED
@@ -0,0 +1,958 @@
1
+ import { XDS_CATALOG_ID, XDS_POINTER_CATALOG_ID } from "./index.js";
2
+ const BASIC = "https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json";
3
+ const surface = (surfaceId, dataModel = {}) => ({
4
+ version: "1.0",
5
+ createSurface: { surfaceId, catalogId: XDS_CATALOG_ID, dataModel },
6
+ });
7
+ const components = (surfaceId, list) => ({
8
+ version: "1.0",
9
+ updateComponents: { surfaceId, components: list },
10
+ });
11
+ const column = (id, children) => ({
12
+ id,
13
+ component: "Column",
14
+ "@catalogId": BASIC,
15
+ children,
16
+ });
17
+ const row = (id, children) => ({
18
+ id,
19
+ component: "Row",
20
+ "@catalogId": BASIC,
21
+ children,
22
+ align: "center",
23
+ });
24
+ const path = (to) => ({ "@path": to });
25
+ const event = (name, context) => ({
26
+ event: { name, ...(context ? { context } : {}) },
27
+ });
28
+ const required = (to, message) => ({
29
+ condition: { "@call": "required", catalogId: BASIC, args: { value: path(to) } },
30
+ message,
31
+ });
32
+ const basicSurface = (surfaceId, dataModel = {}) => ({
33
+ version: "1.0",
34
+ createSurface: { surfaceId, catalogId: BASIC, dataModel },
35
+ });
36
+ const PICTURE = `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 9"><rect width="16" height="9" fill="#6d7fd6"/><rect width="8" height="9" fill="#3b4a9c"/></svg>')}`;
37
+ export const CASES = [
38
+ {
39
+ name: "booking",
40
+ title: "A form",
41
+ description: "Fields bound to the data model, a check that holds the button back until the name is given, and the form's values sent with the action.",
42
+ messages: [
43
+ surface("booking", { form: { name: "", room: "double", guests: 2, breakfast: false } }),
44
+ components("booking", [
45
+ column("root", ["heading", "name", "room", "guests", "breakfast", "book"]),
46
+ { id: "heading", component: "Text", text: "Book a room", variant: "title" },
47
+ {
48
+ id: "name",
49
+ component: "TextField",
50
+ label: "Name",
51
+ value: path("/form/name"),
52
+ description: "As it is on the guest's passport.",
53
+ "@checks": [required("/form/name", "Enter the guest's name.")],
54
+ },
55
+ {
56
+ id: "room",
57
+ component: "RadioGroup",
58
+ label: "Room",
59
+ options: [
60
+ { value: "single", label: "Single" },
61
+ { value: "double", label: "Double" },
62
+ { value: "suite", label: "Suite", description: "With a view of the sea" },
63
+ ],
64
+ value: path("/form/room"),
65
+ },
66
+ {
67
+ id: "guests",
68
+ component: "Slider",
69
+ label: "Guests",
70
+ value: path("/form/guests"),
71
+ min: 1,
72
+ max: 4,
73
+ showValue: true,
74
+ },
75
+ {
76
+ id: "breakfast",
77
+ component: "Checkbox",
78
+ label: "Breakfast",
79
+ checked: path("/form/breakfast"),
80
+ },
81
+ {
82
+ id: "book",
83
+ component: "Button",
84
+ label: "Book",
85
+ variant: "primary",
86
+ "@checks": [required("/form/name", "Enter the guest's name.")],
87
+ onPress: event("book", {
88
+ name: path("/form/name"),
89
+ room: path("/form/room"),
90
+ guests: path("/form/guests"),
91
+ breakfast: path("/form/breakfast"),
92
+ }),
93
+ },
94
+ ]),
95
+ ],
96
+ screen: [
97
+ { role: "textbox", name: "Name", value: "", invalid: true },
98
+ { role: "radio", name: "Double", checked: true },
99
+ { role: "slider", name: "Guests", value: "2" },
100
+ { role: "checkbox", name: "Breakfast", checked: false },
101
+ { role: "button", name: "Book", disabled: true },
102
+ ],
103
+ steps: [
104
+ { fill: { role: "textbox", name: "Name" }, text: "Ada Lovelace" },
105
+ { clickText: "Suite" },
106
+ { clickText: "Breakfast" },
107
+ { click: { role: "button", name: "Book" } },
108
+ ],
109
+ after: [
110
+ { role: "textbox", name: "Name", value: "Ada Lovelace", invalid: false },
111
+ { role: "radio", name: "Suite", checked: true },
112
+ { role: "checkbox", name: "Breakfast", checked: true },
113
+ ],
114
+ actions: [
115
+ {
116
+ name: "book",
117
+ context: { name: "Ada Lovelace", room: "suite", guests: 2, breakfast: true },
118
+ },
119
+ ],
120
+ data: { "/form/name": "Ada Lovelace", "/form/room": "suite", "/form/breakfast": true },
121
+ },
122
+ {
123
+ name: "order",
124
+ title: "A status",
125
+ description: "Text, a badge, a progress bar, a row with an avatar and a banner whose button and dismiss button send actions.",
126
+ messages: [
127
+ surface("order", { order: { id: "A-1024", progress: 0.6 } }),
128
+ components("order", [
129
+ column("root", ["banner", "card"]),
130
+ {
131
+ id: "banner",
132
+ component: "Banner",
133
+ tone: "warning",
134
+ title: "Delivery is late",
135
+ message: "The parcel left the depot a day after it was due.",
136
+ action: { label: "Track", onPress: event("track", { order: path("/order/id") }) },
137
+ onDismiss: event("dismiss"),
138
+ dismissLabel: "Dismiss",
139
+ },
140
+ {
141
+ id: "card",
142
+ component: "Card",
143
+ title: "Order A-1024",
144
+ description: "Two items, paid by card",
145
+ children: ["status", "progress", "divider", "courier", "watchers"],
146
+ },
147
+ row("status", ["state", "spinner"]),
148
+ { id: "state", component: "Badge", label: "On the way", tone: "accent", dot: true },
149
+ { id: "spinner", component: "Spinner", size: "sm", label: "Updating" },
150
+ {
151
+ id: "progress",
152
+ component: "ProgressBar",
153
+ label: "Shipping",
154
+ value: path("/order/progress"),
155
+ },
156
+ { id: "divider", component: "Divider" },
157
+ {
158
+ id: "courier",
159
+ component: "ListRow",
160
+ title: "Grace Hopper",
161
+ description: "Your courier",
162
+ leading: "courier_avatar",
163
+ trailing: "eta",
164
+ },
165
+ { id: "courier_avatar", component: "Avatar", name: "Grace Hopper", size: "md" },
166
+ { id: "eta", component: "Text", text: "14:30", variant: "detail", tone: "secondary" },
167
+ {
168
+ id: "watchers",
169
+ component: "AvatarStack",
170
+ label: "Following the order",
171
+ people: [
172
+ { name: "Ada Lovelace" },
173
+ { name: "Alan Turing" },
174
+ { name: "Katherine Johnson" },
175
+ ],
176
+ max: 2,
177
+ size: "sm",
178
+ },
179
+ ]),
180
+ ],
181
+ screen: [
182
+ { role: "alert", name: "" },
183
+ { role: "progressbar", name: "Shipping", value: "60" },
184
+ { role: "img", name: "Grace Hopper" },
185
+ { role: "status", name: "Updating" },
186
+ ],
187
+ steps: [
188
+ { click: { role: "button", name: "Track" } },
189
+ { click: { role: "button", name: "Dismiss" } },
190
+ ],
191
+ actions: [
192
+ { name: "track", context: { order: "A-1024" } },
193
+ { name: "dismiss", context: {} },
194
+ ],
195
+ },
196
+ {
197
+ name: "settings",
198
+ title: "Choices",
199
+ description: "Tabs, a segmented control, a switch, chips and an accordion that write what the person chooses, and a search field that sends its query.",
200
+ messages: [
201
+ surface("settings", {
202
+ tab: "general",
203
+ theme: "system",
204
+ sync: true,
205
+ filters: { unread: false, starred: true },
206
+ open: [],
207
+ query: "",
208
+ }),
209
+ components("settings", [
210
+ column("root", ["tabs", "theme", "sync", "filters", "more", "search"]),
211
+ {
212
+ id: "tabs",
213
+ component: "Tabs",
214
+ label: "Settings",
215
+ items: [
216
+ { value: "general", label: "General", icon: "settings" },
217
+ { value: "privacy", label: "Privacy", icon: "lock" },
218
+ ],
219
+ value: path("/tab"),
220
+ },
221
+ {
222
+ id: "theme",
223
+ component: "SegmentedControl",
224
+ label: "Appearance",
225
+ options: [
226
+ { value: "system", label: "System" },
227
+ { value: "light", label: "Light" },
228
+ { value: "dark", label: "Dark" },
229
+ ],
230
+ value: path("/theme"),
231
+ },
232
+ { id: "sync", component: "Switch", label: "Sync across devices", checked: path("/sync") },
233
+ { id: "filters", component: "ChipBar", label: "Filters", children: ["unread", "starred"] },
234
+ { id: "unread", component: "Chip", label: "Unread", selected: path("/filters/unread") },
235
+ {
236
+ id: "starred",
237
+ component: "Chip",
238
+ label: "Starred",
239
+ iconStart: "star",
240
+ selected: path("/filters/starred"),
241
+ },
242
+ {
243
+ id: "more",
244
+ component: "Accordion",
245
+ expanded: path("/open"),
246
+ items: [
247
+ {
248
+ value: "advanced",
249
+ title: "Advanced",
250
+ description: "For people who know what they are changing",
251
+ content: "advanced_text",
252
+ },
253
+ ],
254
+ },
255
+ {
256
+ id: "advanced_text",
257
+ component: "Text",
258
+ text: "Clearing the cache signs you out of every device.",
259
+ },
260
+ {
261
+ id: "search",
262
+ component: "SearchField",
263
+ label: "Search settings",
264
+ value: path("/query"),
265
+ placeholder: "Search",
266
+ onSubmit: event("search", { query: path("/query") }),
267
+ },
268
+ ]),
269
+ ],
270
+ screen: [
271
+ { role: "tab", name: "General", selected: true },
272
+ { role: "radio", name: "System", checked: true },
273
+ { role: "switch", name: "Sync across devices", checked: true },
274
+ { role: "button", name: "Unread", pressed: false },
275
+ { role: "button", name: "Starred", pressed: true },
276
+ { role: "button", name: "Advanced", exact: false, expanded: false },
277
+ ],
278
+ steps: [
279
+ { click: { role: "tab", name: "Privacy" } },
280
+ { clickText: "Dark" },
281
+ { clickText: "Sync across devices" },
282
+ { click: { role: "button", name: "Unread" } },
283
+ { click: { role: "button", name: "Advanced", exact: false } },
284
+ { fill: { role: "textbox", name: "Search settings" }, text: "fonts" },
285
+ { press: "Enter" },
286
+ ],
287
+ after: [
288
+ { role: "tab", name: "Privacy", selected: true },
289
+ { role: "radio", name: "Dark", checked: true },
290
+ { role: "switch", name: "Sync across devices", checked: false },
291
+ { role: "button", name: "Unread", pressed: true },
292
+ { role: "button", name: "Advanced", exact: false, expanded: true },
293
+ ],
294
+ actions: [{ name: "search", context: { query: "fonts" } }],
295
+ data: {
296
+ "/tab": "privacy",
297
+ "/theme": "dark",
298
+ "/sync": false,
299
+ "/filters/unread": true,
300
+ "/open": ["advanced"],
301
+ "/query": "fonts",
302
+ },
303
+ },
304
+ {
305
+ name: "toolbar",
306
+ title: "A menu and a tooltip",
307
+ description: "An icon button with a count, a toggle, a menu that opens from a button and sends the item chosen, and a tooltip from the pointer catalog.",
308
+ messages: [
309
+ surface("toolbar", { pinned: false, unread: 3 }),
310
+ components("toolbar", [
311
+ row("root", ["inbox", "pin", "share", "menu"]),
312
+ {
313
+ id: "inbox",
314
+ component: "CountBadge",
315
+ count: path("/unread"),
316
+ label: "unread messages",
317
+ children: "inbox_button",
318
+ },
319
+ {
320
+ id: "inbox_button",
321
+ component: "IconButton",
322
+ icon: "mail",
323
+ label: "Inbox",
324
+ onPress: event("inbox"),
325
+ },
326
+ {
327
+ id: "pin",
328
+ component: "IconButton",
329
+ icon: "pin",
330
+ label: "Pin",
331
+ variant: "secondary",
332
+ selected: path("/pinned"),
333
+ onPress: event("pin", { pinned: path("/pinned") }),
334
+ },
335
+ {
336
+ id: "share",
337
+ component: "Tooltip",
338
+ "@catalogId": XDS_POINTER_CATALOG_ID,
339
+ label: "Share",
340
+ shortcut: "⌘S",
341
+ children: "share_button",
342
+ },
343
+ {
344
+ id: "share_button",
345
+ component: "IconButton",
346
+ icon: "share-2",
347
+ label: "Share",
348
+ onPress: event("share"),
349
+ },
350
+ {
351
+ id: "menu",
352
+ component: "Menu",
353
+ label: "More",
354
+ align: "end",
355
+ trigger: "menu_button",
356
+ items: [
357
+ { label: "Rename", icon: "pencil", onSelect: event("rename") },
358
+ { label: "Copy link", icon: "link", onSelect: event("copy") },
359
+ { separator: true },
360
+ { label: "Delete", icon: "trash", danger: true, onSelect: event("delete") },
361
+ ],
362
+ },
363
+ {
364
+ id: "menu_button",
365
+ component: "IconButton",
366
+ icon: "ellipsis",
367
+ label: "More actions",
368
+ },
369
+ ]),
370
+ ],
371
+ screen: [
372
+ { role: "button", name: "Inbox" },
373
+ { role: "button", name: "Pin", pressed: false },
374
+ { role: "button", name: "More actions", expanded: false },
375
+ { role: "tooltip", name: "Share", absent: true },
376
+ ],
377
+ steps: [
378
+ { click: { role: "button", name: "Pin" } },
379
+ { click: { role: "button", name: "More actions" } },
380
+ { click: { role: "menuitem", name: "Delete" } },
381
+ { hover: { role: "button", name: "Share" } },
382
+ ],
383
+ after: [
384
+ { role: "button", name: "Pin", pressed: true },
385
+ { role: "tooltip", name: "Share", exact: false },
386
+ ],
387
+ actions: [
388
+ { name: "pin", context: { pinned: true } },
389
+ { name: "delete", context: {} },
390
+ ],
391
+ data: { "/pinned": true },
392
+ },
393
+ {
394
+ name: "confirm",
395
+ title: "A dialog",
396
+ description: "A dialog the agent opens with a bound flag, which the person closes with Escape: the flag is written back and the dialog's close action is sent.",
397
+ messages: [
398
+ surface("confirm", { dialog: { open: true } }),
399
+ components("confirm", [
400
+ {
401
+ id: "root",
402
+ component: "Dialog",
403
+ title: "Delete the album?",
404
+ description: "Its 24 photos go to the bin for 30 days.",
405
+ open: path("/dialog/open"),
406
+ onClose: event("closed"),
407
+ children: ["keep_copies"],
408
+ actions: ["cancel", "delete"],
409
+ },
410
+ {
411
+ id: "keep_copies",
412
+ component: "Checkbox",
413
+ label: "Keep copies on this device",
414
+ checked: false,
415
+ },
416
+ { id: "cancel", component: "Button", label: "Cancel", onPress: event("cancel") },
417
+ {
418
+ id: "delete",
419
+ component: "Button",
420
+ label: "Delete",
421
+ variant: "danger",
422
+ onPress: event("delete"),
423
+ },
424
+ ]),
425
+ ],
426
+ screen: [
427
+ { role: "dialog", name: "Delete the album?" },
428
+ { role: "button", name: "Delete" },
429
+ ],
430
+ steps: [{ press: "Escape" }],
431
+ after: [{ role: "dialog", name: "Delete the album?", absent: true }],
432
+ actions: [{ name: "closed", context: {} }],
433
+ data: { "/dialog/open": false },
434
+ },
435
+ {
436
+ name: "library",
437
+ title: "A list from the data model",
438
+ description: "A section header, a media card, a thumbnail, and rows drawn from a list in the data model, each reading its own item and sending it with its action.",
439
+ messages: [
440
+ surface("library", {
441
+ books: [
442
+ { id: "dune", title: "Dune", author: "Frank Herbert" },
443
+ { id: "solaris", title: "Solaris", author: "Stanisław Lem" },
444
+ ],
445
+ }),
446
+ components("library", [
447
+ column("root", ["header", "feature", "trailer", "books", "empty"]),
448
+ {
449
+ id: "header",
450
+ component: "SectionHeader",
451
+ title: "Reading",
452
+ description: "Two books on loan",
453
+ icon: "bookmark",
454
+ action: { label: "See all", onPress: event("all") },
455
+ },
456
+ {
457
+ id: "feature",
458
+ component: "MediaCard",
459
+ layout: "horizontal",
460
+ title: "The Left Hand of Darkness",
461
+ alt: "A snowfield under a pale sky",
462
+ ratio: "16:9",
463
+ badge: "New",
464
+ meta: ["Ursula K. Le Guin", "1969"],
465
+ onPress: event("open", { id: "left-hand" }),
466
+ },
467
+ {
468
+ id: "trailer",
469
+ component: "Thumbnail",
470
+ alt: "The trailer of Dune",
471
+ ratio: "16:9",
472
+ badge: "2:35",
473
+ progress: 0.4,
474
+ },
475
+ {
476
+ id: "books",
477
+ component: "List",
478
+ "@catalogId": BASIC,
479
+ children: { componentId: "book", path: "/books" },
480
+ },
481
+ {
482
+ id: "book",
483
+ component: "ListRow",
484
+ title: path("title"),
485
+ description: path("author"),
486
+ chevron: true,
487
+ leading: "book_icon",
488
+ onPress: event("open", { id: path("id") }),
489
+ },
490
+ { id: "book_icon", component: "Icon", name: "file-text", size: "md" },
491
+ {
492
+ id: "empty",
493
+ component: "EmptyState",
494
+ icon: "history",
495
+ title: "Nothing returned yet",
496
+ description: "Books you return show up here.",
497
+ action: "browse",
498
+ },
499
+ {
500
+ id: "browse",
501
+ component: "Button",
502
+ label: "Browse the shelves",
503
+ onPress: event("browse"),
504
+ },
505
+ ]),
506
+ ],
507
+ screen: [
508
+ { role: "heading", name: "Reading" },
509
+ { role: "img", name: "The trailer of Dune" },
510
+ { role: "button", name: "See all" },
511
+ { role: "button", name: "Dune", exact: false },
512
+ { role: "button", name: "Solaris", exact: false },
513
+ { role: "button", name: "Browse the shelves" },
514
+ ],
515
+ steps: [
516
+ { click: { role: "button", name: "Solaris", exact: false } },
517
+ { click: { role: "button", name: "See all" } },
518
+ ],
519
+ actions: [
520
+ { name: "open", context: { id: "solaris" } },
521
+ { name: "all", context: {} },
522
+ ],
523
+ },
524
+ {
525
+ name: "dates",
526
+ title: "Dates and a select",
527
+ description: "A date picker, a date range picker and a select, each writing what the person picks to the data model.",
528
+ messages: [
529
+ surface("dates", {
530
+ trip: { arrival: "2026-03-10", stay: { start: "2026-03-10", end: "2026-03-13" }, city: "" },
531
+ }),
532
+ components("dates", [
533
+ column("root", ["arrival", "stay", "city", "go"]),
534
+ {
535
+ id: "arrival",
536
+ component: "DatePicker",
537
+ label: "Arrival",
538
+ value: path("/trip/arrival"),
539
+ min: "2026-03-01",
540
+ max: "2026-03-31",
541
+ },
542
+ { id: "stay", component: "DateRangePicker", label: "Stay", value: path("/trip/stay") },
543
+ {
544
+ id: "city",
545
+ component: "Select",
546
+ label: "City",
547
+ placeholder: "Choose a city",
548
+ options: [
549
+ { value: "lisbon", label: "Lisbon" },
550
+ { value: "porto", label: "Porto", description: "In the north" },
551
+ ],
552
+ value: path("/trip/city"),
553
+ "@checks": [required("/trip/city", "Choose where you are going.")],
554
+ },
555
+ {
556
+ id: "go",
557
+ component: "Button",
558
+ label: "Continue",
559
+ variant: "primary",
560
+ onPress: event("continue", { arrival: path("/trip/arrival"), city: path("/trip/city") }),
561
+ },
562
+ ]),
563
+ ],
564
+ screen: [
565
+ { role: "button", name: "Arrival", exact: false },
566
+ { role: "button", name: "Stay", exact: false },
567
+ ],
568
+ steps: [
569
+ { click: { role: "button", name: "Arrival", exact: false } },
570
+ { click: { role: "button", name: "March 12, 2026", exact: false } },
571
+ { click: { role: "button", name: "City", exact: false } },
572
+ { click: { role: "option", name: "Porto", exact: false } },
573
+ { click: { role: "button", name: "Continue" } },
574
+ ],
575
+ actions: [{ name: "continue", context: { arrival: "2026-03-12", city: "porto" } }],
576
+ data: { "/trip/arrival": "2026-03-12", "/trip/city": "porto" },
577
+ },
578
+ {
579
+ name: "basic",
580
+ title: "The basic catalog in the app's theme",
581
+ description: "Components of A2UI's basic catalog beside xds ones: the extension's stylesheet gives them the app's colors, type and spacing.",
582
+ messages: [
583
+ {
584
+ version: "1.0",
585
+ createSurface: { surfaceId: "basic", catalogId: BASIC, dataModel: { note: "" } },
586
+ },
587
+ components("basic", [
588
+ { id: "root", component: "Column", children: ["title", "card", "xds"] },
589
+ { id: "title", component: "Text", text: "Leave a note" },
590
+ { id: "card", component: "Card", child: "form" },
591
+ { id: "form", component: "Column", children: ["note", "send"] },
592
+ { id: "note", component: "TextField", label: "Note", value: path("/note") },
593
+ {
594
+ id: "send",
595
+ component: "Button",
596
+ child: "send_label",
597
+ variant: "primary",
598
+ action: event("send", { note: path("/note") }),
599
+ },
600
+ { id: "send_label", component: "Text", text: "Send" },
601
+ {
602
+ id: "xds",
603
+ component: "Banner",
604
+ "@catalogId": XDS_CATALOG_ID,
605
+ message: "Notes are visible to everyone on the team.",
606
+ },
607
+ ]),
608
+ ],
609
+ screen: [
610
+ { role: "textbox", name: "Note" },
611
+ { role: "button", name: "Send" },
612
+ { role: "status", name: "" },
613
+ ],
614
+ steps: [
615
+ { fill: { role: "textbox", name: "Note" }, text: "Back at three" },
616
+ { click: { role: "button", name: "Send" } },
617
+ ],
618
+ actions: [{ name: "send", context: { note: "Back at three" } }],
619
+ data: { "/note": "Back at three" },
620
+ },
621
+ {
622
+ name: "basic-form",
623
+ title: "The basic catalog drawn with xds: a form",
624
+ description: "An agent that knows only A2UI's basic catalog asks for a booking. Its fields, choices, slider, dates, checkbox and button are drawn with the xds components, with their checks.",
625
+ xdsBasic: true,
626
+ messages: [
627
+ basicSurface("basic_form", {
628
+ stay: {
629
+ name: "",
630
+ code: "",
631
+ notes: "",
632
+ nights: 1,
633
+ room: ["double"],
634
+ extras: [],
635
+ guests: 2,
636
+ day: "2026-03-10",
637
+ arrival: "",
638
+ departure: "",
639
+ terms: false,
640
+ },
641
+ }),
642
+ {
643
+ version: "1.0",
644
+ updateComponents: {
645
+ surfaceId: "basic_form",
646
+ components: [
647
+ {
648
+ id: "root",
649
+ component: "Column",
650
+ children: [
651
+ "heading",
652
+ "name",
653
+ "code",
654
+ "nights",
655
+ "notes",
656
+ "room",
657
+ "extras",
658
+ "guests",
659
+ "day",
660
+ "arrival",
661
+ "departure",
662
+ "terms",
663
+ "book",
664
+ ],
665
+ },
666
+ { id: "heading", component: "Text", text: "Book a room" },
667
+ {
668
+ id: "name",
669
+ component: "TextField",
670
+ label: "Name",
671
+ value: path("/stay/name"),
672
+ placeholder: "As on your passport",
673
+ "@checks": [required("/stay/name", "Enter the guest's name.")],
674
+ },
675
+ {
676
+ id: "code",
677
+ component: "TextField",
678
+ label: "Door code",
679
+ value: path("/stay/code"),
680
+ variant: "obscured",
681
+ },
682
+ {
683
+ id: "nights",
684
+ component: "TextField",
685
+ label: "Nights",
686
+ value: path("/stay/nights"),
687
+ variant: "number",
688
+ },
689
+ {
690
+ id: "notes",
691
+ component: "TextField",
692
+ label: "Notes",
693
+ value: path("/stay/notes"),
694
+ variant: "longText",
695
+ },
696
+ {
697
+ id: "room",
698
+ component: "ChoicePicker",
699
+ label: "Room",
700
+ options: [
701
+ { value: "single", label: "Single" },
702
+ { value: "double", label: "Double" },
703
+ { value: "suite", label: "Suite" },
704
+ ],
705
+ value: path("/stay/room"),
706
+ },
707
+ {
708
+ id: "extras",
709
+ component: "ChoicePicker",
710
+ label: "Extras",
711
+ variant: "multipleSelection",
712
+ options: [
713
+ { value: "breakfast", label: "Breakfast" },
714
+ { value: "parking", label: "Parking" },
715
+ ],
716
+ value: path("/stay/extras"),
717
+ "@checks": [required("/stay/extras", "Choose at least one extra.")],
718
+ },
719
+ {
720
+ id: "guests",
721
+ component: "Slider",
722
+ label: "Guests",
723
+ min: 1,
724
+ max: 4,
725
+ steps: 3,
726
+ value: path("/stay/guests"),
727
+ },
728
+ {
729
+ id: "day",
730
+ component: "DateTimeInput",
731
+ label: "Day",
732
+ enableDate: true,
733
+ value: path("/stay/day"),
734
+ min: "2026-03-01",
735
+ max: "2026-03-31",
736
+ },
737
+ {
738
+ id: "arrival",
739
+ component: "DateTimeInput",
740
+ label: "Arrival",
741
+ enableTime: true,
742
+ value: path("/stay/arrival"),
743
+ },
744
+ {
745
+ id: "departure",
746
+ component: "DateTimeInput",
747
+ label: "Departure",
748
+ enableDate: true,
749
+ enableTime: true,
750
+ value: path("/stay/departure"),
751
+ },
752
+ {
753
+ id: "terms",
754
+ component: "CheckBox",
755
+ label: "I accept the terms",
756
+ value: path("/stay/terms"),
757
+ "@checks": [{ condition: path("/stay/terms"), message: "Accept the terms to book." }],
758
+ },
759
+ {
760
+ id: "book",
761
+ component: "Button",
762
+ child: "book_label",
763
+ variant: "primary",
764
+ action: event("book", {
765
+ name: path("/stay/name"),
766
+ room: path("/stay/room"),
767
+ extras: path("/stay/extras"),
768
+ guests: path("/stay/guests"),
769
+ day: path("/stay/day"),
770
+ }),
771
+ "@checks": [
772
+ required("/stay/name", "Enter the guest's name."),
773
+ required("/stay/extras", "Choose at least one extra."),
774
+ { condition: path("/stay/terms"), message: "Accept the terms to book." },
775
+ ],
776
+ },
777
+ { id: "book_label", component: "Text", text: "Book" },
778
+ ],
779
+ },
780
+ },
781
+ ],
782
+ screen: [
783
+ { role: "textbox", name: "Name", value: "", invalid: true },
784
+ { role: "spinbutton", name: "Nights", value: "1" },
785
+ { role: "textbox", name: "Notes", value: "" },
786
+ { role: "radio", name: "Double", checked: true },
787
+ { role: "group", name: "Extras", invalid: true },
788
+ { role: "checkbox", name: "Breakfast", checked: false },
789
+ { role: "slider", name: "Guests", value: "2" },
790
+ { role: "button", name: "Day", exact: false },
791
+ { role: "checkbox", name: "I accept the terms", checked: false },
792
+ { role: "button", name: "Book", disabled: true },
793
+ ],
794
+ steps: [
795
+ { fill: { role: "textbox", name: "Name" }, text: "Ada Lovelace" },
796
+ { clickText: "Suite" },
797
+ { clickText: "Breakfast" },
798
+ { click: { role: "button", name: "Day", exact: false } },
799
+ { click: { role: "button", name: "March 12, 2026", exact: false } },
800
+ { clickText: "I accept the terms" },
801
+ { click: { role: "button", name: "Book" } },
802
+ ],
803
+ after: [
804
+ { role: "textbox", name: "Name", value: "Ada Lovelace", invalid: false },
805
+ { role: "radio", name: "Suite", checked: true },
806
+ { role: "group", name: "Extras", invalid: false },
807
+ { role: "button", name: "Book", disabled: false },
808
+ ],
809
+ actions: [
810
+ {
811
+ name: "book",
812
+ context: {
813
+ name: "Ada Lovelace",
814
+ room: ["suite"],
815
+ extras: ["breakfast"],
816
+ guests: 2,
817
+ day: "2026-03-12",
818
+ },
819
+ },
820
+ ],
821
+ data: {
822
+ "/stay/room": ["suite"],
823
+ "/stay/extras": ["breakfast"],
824
+ "/stay/day": "2026-03-12",
825
+ "/stay/terms": true,
826
+ },
827
+ },
828
+ {
829
+ name: "basic-content",
830
+ title: "The basic catalog drawn with xds: content",
831
+ description: "Text, pictures, icons, a card, tabs, a modal, dividers and chips from the basic catalog, drawn with the xds components.",
832
+ xdsBasic: true,
833
+ messages: [
834
+ basicSurface("basic_content", { tags: ["quiet"] }),
835
+ {
836
+ version: "1.0",
837
+ updateComponents: {
838
+ surfaceId: "basic_content",
839
+ components: [
840
+ {
841
+ id: "root",
842
+ component: "Column",
843
+ children: ["host", "card", "tabs", "tags", "divider", "actions"],
844
+ },
845
+ {
846
+ id: "host",
847
+ component: "Row",
848
+ align: "center",
849
+ children: ["host_avatar", "host_words", "host_rule", "host_star"],
850
+ },
851
+ {
852
+ id: "host_avatar",
853
+ component: "Image",
854
+ url: PICTURE,
855
+ variant: "avatar",
856
+ description: "Grace Hopper",
857
+ },
858
+ { id: "host_words", component: "Column", children: ["host_name", "host_note"] },
859
+ { id: "host_name", component: "Text", text: "Grace Hopper" },
860
+ { id: "host_note", component: "Text", text: "Your host", variant: "caption" },
861
+ { id: "host_rule", component: "Divider", axis: "vertical" },
862
+ {
863
+ id: "host_star",
864
+ component: "Icon",
865
+ name: "star",
866
+ "@accessibility": { label: "Favorite host" },
867
+ },
868
+ { id: "card", component: "Card", child: "card_body" },
869
+ { id: "card_body", component: "Column", children: ["card_picture", "card_text"] },
870
+ {
871
+ id: "card_picture",
872
+ component: "Image",
873
+ url: PICTURE,
874
+ description: "The garden room",
875
+ variant: "mediumFeature",
876
+ },
877
+ { id: "card_text", component: "Text", text: "The garden room faces south." },
878
+ {
879
+ id: "tabs",
880
+ component: "Tabs",
881
+ tabs: [
882
+ { title: "Overview", child: "overview" },
883
+ { title: "Rules", child: "rules" },
884
+ ],
885
+ },
886
+ { id: "overview", component: "Text", text: "Check in from three." },
887
+ { id: "rules", component: "Text", text: "No parties after ten." },
888
+ {
889
+ id: "tags",
890
+ component: "ChoicePicker",
891
+ label: "Tags",
892
+ variant: "multipleSelection",
893
+ displayStyle: "chips",
894
+ filterable: true,
895
+ options: [
896
+ { value: "quiet", label: "Quiet" },
897
+ { value: "garden", label: "Garden" },
898
+ { value: "view", label: "Sea view" },
899
+ ],
900
+ value: path("/tags"),
901
+ },
902
+ { id: "divider", component: "Divider" },
903
+ { id: "actions", component: "Row", align: "center", children: ["details", "share"] },
904
+ {
905
+ id: "details",
906
+ component: "Modal",
907
+ trigger: "details_button",
908
+ content: "details_text",
909
+ },
910
+ {
911
+ id: "details_button",
912
+ component: "Button",
913
+ child: "details_label",
914
+ action: event("details"),
915
+ },
916
+ { id: "details_label", component: "Text", text: "House details" },
917
+ { id: "details_text", component: "Text", text: "Towels are in the hall cupboard." },
918
+ {
919
+ id: "share",
920
+ component: "Button",
921
+ child: "share_icon",
922
+ variant: "borderless",
923
+ action: event("share"),
924
+ "@accessibility": { label: "Share" },
925
+ },
926
+ { id: "share_icon", component: "Icon", name: "share" },
927
+ ],
928
+ },
929
+ },
930
+ ],
931
+ screen: [
932
+ { role: "img", name: "Grace Hopper" },
933
+ { role: "img", name: "Favorite host" },
934
+ { role: "img", name: "The garden room" },
935
+ { role: "heading", name: "Grace Hopper", absent: true },
936
+ { role: "tab", name: "Overview", selected: true },
937
+ { role: "button", name: "Quiet", pressed: true },
938
+ { role: "button", name: "Share" },
939
+ ],
940
+ steps: [
941
+ { click: { role: "button", name: "House details" } },
942
+ { see: { role: "dialog", name: "House details" } },
943
+ { press: "Escape" },
944
+ { click: { role: "tab", name: "Rules" } },
945
+ { fill: { role: "textbox", name: "Tags" }, text: "sea" },
946
+ { click: { role: "button", name: "Sea view" } },
947
+ { click: { role: "button", name: "Share" } },
948
+ ],
949
+ after: [
950
+ { role: "dialog", name: "House details", absent: true },
951
+ { role: "tab", name: "Rules", selected: true },
952
+ { role: "button", name: "Garden", absent: true },
953
+ { role: "button", name: "Sea view", pressed: true },
954
+ ],
955
+ actions: [{ name: "details" }, { name: "share" }],
956
+ data: { "/tags": ["quiet", "view"] },
957
+ },
958
+ ];