@barqjs/aria 0.2.0-next.0 → 0.2.0-next.1

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 (78) hide show
  1. package/README.md +24 -13
  2. package/package.json +127 -37
  3. package/src/autocomplete.tsx +581 -0
  4. package/src/breadcrumbs.tsx +21 -20
  5. package/src/button.tsx +151 -25
  6. package/src/calendar.tsx +1019 -92
  7. package/src/checkbox.tsx +214 -52
  8. package/src/collections.ts +88 -5
  9. package/src/color.ts +1580 -23
  10. package/src/colorpicker.tsx +698 -153
  11. package/src/colorswatchpicker.tsx +240 -0
  12. package/src/combobox.tsx +635 -113
  13. package/src/command.tsx +78 -59
  14. package/src/date.ts +31 -9
  15. package/src/datefield.tsx +1451 -336
  16. package/src/datepicker.tsx +465 -114
  17. package/src/dialog.tsx +302 -115
  18. package/src/disclosure.tsx +81 -29
  19. package/src/dnd/clipboard.ts +125 -0
  20. package/src/dnd/collection.ts +1265 -0
  21. package/src/dnd/data.ts +409 -0
  22. package/src/dnd/drag-drop.ts +801 -0
  23. package/src/dnd/index.ts +133 -0
  24. package/src/dnd/manager.ts +639 -0
  25. package/src/dnd/strings.ts +1279 -0
  26. package/src/dnd/targets.ts +726 -0
  27. package/src/dnd/types.ts +212 -0
  28. package/src/dom.ts +3 -6
  29. package/src/drag-and-drop.tsx +669 -0
  30. package/src/dropzone.tsx +208 -0
  31. package/src/file-trigger.tsx +103 -0
  32. package/src/form.tsx +18 -18
  33. package/src/gridlist.tsx +912 -121
  34. package/src/group.tsx +146 -0
  35. package/src/index.ts +402 -0
  36. package/src/interactions/focus-events.ts +13 -5
  37. package/src/interactions/keyboard.ts +195 -2
  38. package/src/interactions/modality.ts +18 -6
  39. package/src/interactions/open-link.ts +46 -13
  40. package/src/interactions/press.ts +35 -18
  41. package/src/label.ts +18 -6
  42. package/src/link.tsx +146 -50
  43. package/src/listbox.tsx +615 -89
  44. package/src/live.ts +4 -0
  45. package/src/menu.tsx +182 -89
  46. package/src/menubar.tsx +21 -17
  47. package/src/navigation-tree.tsx +357 -0
  48. package/src/numberfield.tsx +164 -60
  49. package/src/overlay-arrow.tsx +157 -0
  50. package/src/overlays.ts +364 -62
  51. package/src/platform.ts +2 -1
  52. package/src/preview-trigger.tsx +582 -0
  53. package/src/progress-bar-context.ts +15 -0
  54. package/src/questionnaire.tsx +109 -104
  55. package/src/radio.tsx +101 -27
  56. package/src/select.tsx +225 -145
  57. package/src/selection-indicator.tsx +74 -0
  58. package/src/selection.ts +73 -16
  59. package/src/shared-element-transition.tsx +316 -0
  60. package/src/sheet.tsx +1461 -0
  61. package/src/slider.tsx +139 -44
  62. package/src/switch.tsx +47 -21
  63. package/src/table.tsx +0 -0
  64. package/src/tabs.tsx +198 -89
  65. package/src/tag.tsx +217 -32
  66. package/src/textarea.tsx +186 -0
  67. package/src/textfield.tsx +103 -37
  68. package/src/toast-components.tsx +589 -0
  69. package/src/toggle-button-group.tsx +175 -0
  70. package/src/toggle-input.tsx +38 -0
  71. package/src/toggle.ts +68 -5
  72. package/src/tokenfield.tsx +1673 -0
  73. package/src/toolbar.tsx +15 -10
  74. package/src/tooltip.tsx +46 -29
  75. package/src/tree.tsx +2075 -0
  76. package/src/utils.ts +30 -1
  77. package/src/validation.ts +79 -22
  78. package/src/virtualizer.tsx +186 -23
package/src/combobox.tsx CHANGED
@@ -25,6 +25,7 @@
25
25
  */
26
26
 
27
27
  import {
28
+ cells,
28
29
  type Accessor,
29
30
  type Child,
30
31
  For,
@@ -49,6 +50,7 @@ import { ref as makeRef, mergeRefs, type RefTarget } from "@barqjs/primitives/re
49
50
  import { button } from "./button.tsx";
50
51
  import {
51
52
  buildCollection,
53
+ getItemCount,
52
54
  listState,
53
55
  type FocusStrategy,
54
56
  type ItemAccessors,
@@ -60,7 +62,13 @@ import {
60
62
  } from "./collections.ts";
61
63
  import { Popover } from "./dialog.tsx";
62
64
  import { focusRing, focusScope } from "./focus.ts";
63
- import { declaredDirection, filter as makeFilter, useLocale } from "./i18n.ts";
65
+ import {
66
+ declaredDirection,
67
+ filter as makeFilter,
68
+ StringDictionary,
69
+ stringFormatter,
70
+ useLocale,
71
+ } from "./i18n.ts";
64
72
  import { hover } from "./interactions/hover.ts";
65
73
  import type { ElementRef, PressEvent } from "./interactions/press.ts";
66
74
  import { field, type FieldOptions } from "./label.ts";
@@ -76,10 +84,16 @@ import {
76
84
  Option,
77
85
  optionIdFor,
78
86
  provideItemNode,
87
+ provideItemRender,
79
88
  type ListBoxContextValue,
80
89
  } from "./listbox.tsx";
90
+ import { announce } from "./live.ts";
91
+ import { isAppleDevice } from "./platform.ts";
92
+ import { formReset } from "./toggle.ts";
81
93
  import {
82
94
  alignOf,
95
+ ariaHideOutside,
96
+ followOpen,
83
97
  overlay as dismissal,
84
98
  overlayPosition,
85
99
  overlayTriggerState,
@@ -176,6 +190,28 @@ export interface ComboBoxState<T>
176
190
  revert(): void;
177
191
  }
178
192
 
193
+ /**
194
+ * The nodes the typed text keeps, looking inside sections.
195
+ *
196
+ * A section stays while any of its items does, holding only those, and goes
197
+ * when it is left empty. Copies, because a collection links the nodes it is
198
+ * built from, and the unfiltered collection shares them.
199
+ */
200
+ function filterNodes<T>(nodes: Iterable<Node<T>>, keeps: (text: string) => boolean): Node<T>[] {
201
+ const kept: Node<T>[] = [];
202
+ for (const node of nodes) {
203
+ if (node.type === "section" && node.hasChildNodes) {
204
+ const children = filterNodes(node.childNodes, keeps);
205
+ if (children.some((child) => child.type === "item")) {
206
+ kept.push({ ...node, childNodes: children });
207
+ }
208
+ } else if (node.type !== "item" || keeps(node.textValue)) {
209
+ kept.push({ ...node });
210
+ }
211
+ }
212
+ return kept;
213
+ }
214
+
179
215
  export function comboBoxState<T>(options: ComboBoxStateOptions<T>): ComboBoxState<T> {
180
216
  const overlay = overlayTriggerState({
181
217
  ...(options as OverlayTriggerStateOptions),
@@ -224,11 +260,7 @@ export function comboBoxState<T>(options: ComboBoxStateOptions<T>): ComboBoxStat
224
260
  if (showAll()) return nodes;
225
261
  const query = inputValue();
226
262
  const keep = keeps();
227
- const kept: Node<T>[] = [];
228
- for (const node of nodes) {
229
- if (node.type !== "item" || keep(node.textValue, query)) kept.push(node);
230
- }
231
- return kept;
263
+ return filterNodes(nodes, (text) => keep(text, query));
232
264
  },
233
265
  onSelectionChange: (keys: SelectionValue) => {
234
266
  const key = keys === "all" ? null : (keys.values().next().value ?? null);
@@ -260,6 +292,7 @@ export function comboBoxState<T>(options: ComboBoxStateOptions<T>): ComboBoxStat
260
292
  const open = (focusStrategy: FocusStrategy | null = null, trigger?: MenuTriggerAction): void => {
261
293
  const all = displaysAll(trigger);
262
294
  if (!canShow(all)) return;
295
+ closedForEmpty = false;
263
296
  if (all) setShowAll(true);
264
297
  lastTrigger = trigger;
265
298
  setStrategy(focusStrategy);
@@ -286,12 +319,18 @@ export function comboBoxState<T>(options: ComboBoxStateOptions<T>): ComboBoxStat
286
319
  */
287
320
  let syncedKey: Key | null = untrack(selectedKey);
288
321
 
322
+ /** Closed by the effect below for having nothing to show, not by the user. */
323
+ let closedForEmpty = false;
324
+
289
325
  const resetInput = (): void => {
290
326
  syncedKey = selectedKey();
291
327
  setInputValueRaw(selectedText());
292
328
  };
293
329
 
294
330
  const commitValue = (): void => {
331
+ // Leaving the query, or settling it, is the end of the search that came
332
+ // back empty: an answer arriving after it must not open the list.
333
+ closedForEmpty = false;
295
334
  if (access(options.allowsCustomValue) === true && inputValue() !== selectedText()) {
296
335
  // Text matching nothing IS the value, so the selection goes away rather
297
336
  // than the text.
@@ -321,6 +360,7 @@ export function comboBoxState<T>(options: ComboBoxStateOptions<T>): ComboBoxStat
321
360
  };
322
361
 
323
362
  const revert = (): void => {
363
+ closedForEmpty = false;
324
364
  if (access(options.allowsCustomValue) === true && selectedKey() === null) {
325
365
  overlay.close();
326
366
  return;
@@ -379,7 +419,29 @@ export function comboBoxState<T>(options: ComboBoxStateOptions<T>): ComboBoxStat
379
419
  ? null
380
420
  : list.collection(),
381
421
  (collection) => {
382
- if (collection !== null && collection.size === 0) overlay.close();
422
+ if (collection !== null && collection.size === 0) {
423
+ closedForEmpty = true;
424
+ overlay.close();
425
+ }
426
+ },
427
+ );
428
+
429
+ // And one closed for being empty opens again when items arrive, which is
430
+ // what an asynchronous search answering after an empty answer looks like.
431
+ createEffect(
432
+ () =>
433
+ [
434
+ list.collection().size,
435
+ isFocused(),
436
+ overlay.isOpen(),
437
+ access(options.menuTrigger) === "manual",
438
+ ] as const,
439
+ ([size, focused, isOpen, isManual]) => {
440
+ if (!closedForEmpty || !focused || isOpen || isManual || size === 0) return;
441
+ closedForEmpty = false;
442
+ lastTrigger = "input";
443
+ setStrategy(null);
444
+ overlay.open();
383
445
  },
384
446
  );
385
447
 
@@ -438,6 +500,321 @@ export function comboBoxState<T>(options: ComboBoxStateOptions<T>): ComboBoxStat
438
500
  // Hooks
439
501
  // ---------------------------------------------------------------------------
440
502
 
503
+ const comboBoxStrings = new StringDictionary<
504
+ | "buttonLabel"
505
+ | "listboxLabel"
506
+ | "countAnnouncement"
507
+ | "focusAnnouncement"
508
+ | "selectedAnnouncement"
509
+ >({
510
+ "ar-AE": {
511
+ buttonLabel: "عرض المقترحات",
512
+ listboxLabel: "مقترحات",
513
+ countAnnouncement: (values, format) =>
514
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} خيار`, other: () => `${format.number(Number(values?.optionCount))} خيارات` })} متاحة.`,
515
+ focusAnnouncement: (values, format) =>
516
+ `${format.select({ true: () => `المجموعة المدخلة ${String(values?.groupTitle ?? "")}, مع ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} خيار`, other: () => `${format.number(Number(values?.groupCount))} خيارات` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", محدد", other: () => "" }, String(values?.isSelected))}`,
517
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}، محدد`,
518
+ },
519
+ "bg-BG": {
520
+ buttonLabel: "Покажи предложения",
521
+ listboxLabel: "Предложения",
522
+ countAnnouncement: (values, format) =>
523
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} опция`, other: () => `${format.number(Number(values?.optionCount))} опции` })} на разположение.`,
524
+ focusAnnouncement: (values, format) =>
525
+ `${format.select({ true: () => `Въведена група ${String(values?.groupTitle ?? "")}, с ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} опция`, other: () => `${format.number(Number(values?.groupCount))} опции` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", избрани", other: () => "" }, String(values?.isSelected))}`,
526
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, избрани`,
527
+ },
528
+ "cs-CZ": {
529
+ buttonLabel: "Zobrazit doporučení",
530
+ listboxLabel: "Návrhy",
531
+ countAnnouncement: (values, format) =>
532
+ `K dispozici ${format.plural(Number(values?.optionCount), { one: () => `je ${format.number(Number(values?.optionCount))} možnost`, other: () => `jsou/je ${format.number(Number(values?.optionCount))} možnosti/-í` })}.`,
533
+ focusAnnouncement: (values, format) =>
534
+ `${format.select({ true: () => `Zadaná skupina „${String(values?.groupTitle ?? "")}“ ${format.plural(Number(values?.groupCount), { one: () => `s ${format.number(Number(values?.groupCount))} možností`, other: () => `se ${format.number(Number(values?.groupCount))} možnostmi` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => " (vybráno)", other: () => "" }, String(values?.isSelected))}`,
535
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, vybráno`,
536
+ },
537
+ "da-DK": {
538
+ buttonLabel: "Vis forslag",
539
+ listboxLabel: "Forslag",
540
+ countAnnouncement: (values, format) =>
541
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} mulighed tilgængelig`, other: () => `${format.number(Number(values?.optionCount))} muligheder tilgængelige` })}.`,
542
+ focusAnnouncement: (values, format) =>
543
+ `${format.select({ true: () => `Angivet gruppe ${String(values?.groupTitle ?? "")}, med ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} mulighed`, other: () => `${format.number(Number(values?.groupCount))} muligheder` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", valgt", other: () => "" }, String(values?.isSelected))}`,
544
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, valgt`,
545
+ },
546
+ "de-DE": {
547
+ buttonLabel: "Empfehlungen anzeigen",
548
+ listboxLabel: "Empfehlungen",
549
+ countAnnouncement: (values, format) =>
550
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} Option`, other: () => `${format.number(Number(values?.optionCount))} Optionen` })} verfügbar.`,
551
+ focusAnnouncement: (values, format) =>
552
+ `${format.select({ true: () => `Eingetretene Gruppe ${String(values?.groupTitle ?? "")}, mit ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} Option`, other: () => `${format.number(Number(values?.groupCount))} Optionen` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", ausgewählt", other: () => "" }, String(values?.isSelected))}`,
553
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, ausgewählt`,
554
+ },
555
+ "el-GR": {
556
+ buttonLabel: "Προβολή προτάσεων",
557
+ listboxLabel: "Προτάσεις",
558
+ countAnnouncement: (values, format) =>
559
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} επιλογή`, other: () => `${format.number(Number(values?.optionCount))} επιλογές ` })} διαθέσιμες.`,
560
+ focusAnnouncement: (values, format) =>
561
+ `${format.select({ true: () => `Εισαγμένη ομάδα ${String(values?.groupTitle ?? "")}, με ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} επιλογή`, other: () => `${format.number(Number(values?.groupCount))} επιλογές` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", επιλεγμένο", other: () => "" }, String(values?.isSelected))}`,
562
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, επιλέχθηκε`,
563
+ },
564
+ "en-US": {
565
+ buttonLabel: "Show suggestions",
566
+ listboxLabel: "Suggestions",
567
+ countAnnouncement: (values, format) =>
568
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} option`, other: () => `${format.number(Number(values?.optionCount))} options` })} available.`,
569
+ focusAnnouncement: (values, format) =>
570
+ `${format.select({ true: () => `Entered group ${String(values?.groupTitle ?? "")}, with ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} option`, other: () => `${format.number(Number(values?.groupCount))} options` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", selected", other: () => "" }, String(values?.isSelected))}`,
571
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, selected`,
572
+ },
573
+ "es-ES": {
574
+ buttonLabel: "Mostrar sugerencias",
575
+ listboxLabel: "Sugerencias",
576
+ countAnnouncement: (values, format) =>
577
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opción`, other: () => `${format.number(Number(values?.optionCount))} opciones` })} disponible(s).`,
578
+ focusAnnouncement: (values, format) =>
579
+ `${format.select({ true: () => `Se ha unido al grupo ${String(values?.groupTitle ?? "")}, con ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opción`, other: () => `${format.number(Number(values?.groupCount))} opciones` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", seleccionado", other: () => "" }, String(values?.isSelected))}`,
580
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, seleccionado`,
581
+ },
582
+ "et-EE": {
583
+ buttonLabel: "Kuva soovitused",
584
+ listboxLabel: "Soovitused",
585
+ countAnnouncement: (values, format) =>
586
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} valik`, other: () => `${format.number(Number(values?.optionCount))} valikud` })} saadaval.`,
587
+ focusAnnouncement: (values, format) =>
588
+ `${format.select({ true: () => `Sisestatud rühm ${String(values?.groupTitle ?? "")}, valikuga ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} valik`, other: () => `${format.number(Number(values?.groupCount))} valikud` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", valitud", other: () => "" }, String(values?.isSelected))}`,
589
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, valitud`,
590
+ },
591
+ "fi-FI": {
592
+ buttonLabel: "Näytä ehdotukset",
593
+ listboxLabel: "Ehdotukset",
594
+ countAnnouncement: (values, format) =>
595
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} vaihtoehto`, other: () => `${format.number(Number(values?.optionCount))} vaihtoehtoa` })} saatavilla.`,
596
+ focusAnnouncement: (values, format) =>
597
+ `${format.select({ true: () => `Siirtyi ryhmään ${String(values?.groupTitle ?? "")}, jossa ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} vaihtoehto`, other: () => `${format.number(Number(values?.groupCount))} vaihtoehtoa` })}.`, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", valittu", other: () => "" }, String(values?.isSelected))}`,
598
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, valittu`,
599
+ },
600
+ "fr-FR": {
601
+ buttonLabel: "Afficher les suggestions",
602
+ listboxLabel: "Suggestions",
603
+ countAnnouncement: (values, format) =>
604
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} option`, other: () => `${format.number(Number(values?.optionCount))} options` })} disponible(s).`,
605
+ focusAnnouncement: (values, format) =>
606
+ `${format.select({ true: () => `Groupe ${String(values?.groupTitle ?? "")} rejoint, avec ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} option`, other: () => `${format.number(Number(values?.groupCount))} options` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", sélectionné(s)", other: () => "" }, String(values?.isSelected))}`,
607
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, sélectionné`,
608
+ },
609
+ "he-IL": {
610
+ buttonLabel: "הצג הצעות",
611
+ listboxLabel: "הצעות",
612
+ countAnnouncement: (values, format) =>
613
+ `${format.plural(Number(values?.optionCount), { one: () => `אפשרות ${format.number(Number(values?.optionCount))}`, other: () => `${format.number(Number(values?.optionCount))} אפשרויות` })} במצב זמין.`,
614
+ focusAnnouncement: (values, format) =>
615
+ `${format.select({ true: () => `נכנס לקבוצה ${String(values?.groupTitle ?? "")}, עם ${format.plural(Number(values?.groupCount), { one: () => `אפשרות ${format.number(Number(values?.groupCount))}`, other: () => `${format.number(Number(values?.groupCount))} אפשרויות` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", נבחר", other: () => "" }, String(values?.isSelected))}`,
616
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, נבחר`,
617
+ },
618
+ "hr-HR": {
619
+ buttonLabel: "Prikaži prijedloge",
620
+ listboxLabel: "Prijedlozi",
621
+ countAnnouncement: (values, format) =>
622
+ `Dostupno još: ${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opcija`, other: () => `${format.number(Number(values?.optionCount))} opcije/a` })}.`,
623
+ focusAnnouncement: (values, format) =>
624
+ `${format.select({ true: () => `Unesena skupina ${String(values?.groupTitle ?? "")}, s ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opcijom`, other: () => `${format.number(Number(values?.groupCount))} opcije/a` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", odabranih", other: () => "" }, String(values?.isSelected))}`,
625
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, odabrano`,
626
+ },
627
+ "hu-HU": {
628
+ buttonLabel: "Javaslatok megjelenítése",
629
+ listboxLabel: "Javaslatok",
630
+ countAnnouncement: (values, format) =>
631
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} lehetőség`, other: () => `${format.number(Number(values?.optionCount))} lehetőség` })} áll rendelkezésre.`,
632
+ focusAnnouncement: (values, format) =>
633
+ `${format.select({ true: () => `Belépett a(z) ${String(values?.groupTitle ?? "")} csoportba, amely ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} lehetőséget`, other: () => `${format.number(Number(values?.groupCount))} lehetőséget` })} tartalmaz. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", kijelölve", other: () => "" }, String(values?.isSelected))}`,
634
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, kijelölve`,
635
+ },
636
+ "it-IT": {
637
+ buttonLabel: "Mostra suggerimenti",
638
+ listboxLabel: "Suggerimenti",
639
+ countAnnouncement: (values, format) =>
640
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opzione disponibile`, other: () => `${format.number(Number(values?.optionCount))} opzioni disponibili` })}.`,
641
+ focusAnnouncement: (values, format) =>
642
+ `${format.select({ true: () => `Ingresso nel gruppo ${String(values?.groupTitle ?? "")}, con ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opzione`, other: () => `${format.number(Number(values?.groupCount))} opzioni` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", selezionato", other: () => "" }, String(values?.isSelected))}`,
643
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, selezionato`,
644
+ },
645
+ "ja-JP": {
646
+ buttonLabel: "候補を表示",
647
+ listboxLabel: "候補",
648
+ countAnnouncement: (values, format) =>
649
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} 個のオプション`, other: () => `${format.number(Number(values?.optionCount))} 個のオプション` })}を利用できます。`,
650
+ focusAnnouncement: (values, format) =>
651
+ `${format.select({ true: () => `入力されたグループ ${String(values?.groupTitle ?? "")}、${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} 個のオプション`, other: () => `${format.number(Number(values?.groupCount))} 個のオプション` })}を含む。`, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => "、選択済み", other: () => "" }, String(values?.isSelected))}`,
652
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}、選択済み`,
653
+ },
654
+ "ko-KR": {
655
+ buttonLabel: "제안 사항 표시",
656
+ listboxLabel: "제안",
657
+ countAnnouncement: (values, format) =>
658
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))}개 옵션`, other: () => `${format.number(Number(values?.optionCount))}개 옵션` })}을 사용할 수 있습니다.`,
659
+ focusAnnouncement: (values, format) =>
660
+ `${format.select({ true: () => `입력한 그룹 ${String(values?.groupTitle ?? "")}, ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))}개 옵션`, other: () => `${format.number(Number(values?.groupCount))}개 옵션` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", 선택됨", other: () => "" }, String(values?.isSelected))}`,
661
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, 선택됨`,
662
+ },
663
+ "lt-LT": {
664
+ buttonLabel: "Rodyti pasiūlymus",
665
+ listboxLabel: "Pasiūlymai",
666
+ countAnnouncement: (values, format) =>
667
+ `Yra ${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} parinktis`, other: () => `${format.number(Number(values?.optionCount))} parinktys (-ių)` })}.`,
668
+ focusAnnouncement: (values, format) =>
669
+ `${format.select({ true: () => `Įvesta grupė ${String(values?.groupTitle ?? "")}, su ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} parinktimi`, other: () => `${format.number(Number(values?.groupCount))} parinktimis (-ių)` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", pasirinkta", other: () => "" }, String(values?.isSelected))}`,
670
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, pasirinkta`,
671
+ },
672
+ "lv-LV": {
673
+ buttonLabel: "Rādīt ieteikumus",
674
+ listboxLabel: "Ieteikumi",
675
+ countAnnouncement: (values, format) =>
676
+ `Pieejamo opciju skaits: ${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opcija`, other: () => `${format.number(Number(values?.optionCount))} opcijas` })}.`,
677
+ focusAnnouncement: (values, format) =>
678
+ `${format.select({ true: () => `Ievadīta grupa ${String(values?.groupTitle ?? "")}, ar ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opciju`, other: () => `${format.number(Number(values?.groupCount))} opcijām` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", atlasīta", other: () => "" }, String(values?.isSelected))}`,
679
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, atlasīta`,
680
+ },
681
+ "nb-NO": {
682
+ buttonLabel: "Vis forslag",
683
+ listboxLabel: "Forslag",
684
+ countAnnouncement: (values, format) =>
685
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} alternativ`, other: () => `${format.number(Number(values?.optionCount))} alternativer` })} finnes.`,
686
+ focusAnnouncement: (values, format) =>
687
+ `${format.select({ true: () => `Angitt gruppe ${String(values?.groupTitle ?? "")}, med ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} alternativ`, other: () => `${format.number(Number(values?.groupCount))} alternativer` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", valgt", other: () => "" }, String(values?.isSelected))}`,
688
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, valgt`,
689
+ },
690
+ "nl-NL": {
691
+ buttonLabel: "Suggesties weergeven",
692
+ listboxLabel: "Suggesties",
693
+ countAnnouncement: (values, format) =>
694
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} optie`, other: () => `${format.number(Number(values?.optionCount))} opties` })} beschikbaar.`,
695
+ focusAnnouncement: (values, format) =>
696
+ `${format.select({ true: () => `Groep ${String(values?.groupTitle ?? "")} ingevoerd met ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} optie`, other: () => `${format.number(Number(values?.groupCount))} opties` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", geselecteerd", other: () => "" }, String(values?.isSelected))}`,
697
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, geselecteerd`,
698
+ },
699
+ "pl-PL": {
700
+ buttonLabel: "Wyświetlaj sugestie",
701
+ listboxLabel: "Sugestie",
702
+ countAnnouncement: (values, format) =>
703
+ `dostępna/dostępne(-nych) ${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opcja`, other: () => `${format.number(Number(values?.optionCount))} opcje(-i)` })}.`,
704
+ focusAnnouncement: (values, format) =>
705
+ `${format.select({ true: () => `Dołączono do grupy ${String(values?.groupTitle ?? "")}, z ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opcją`, other: () => `${format.number(Number(values?.groupCount))} opcjami` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", wybrano", other: () => "" }, String(values?.isSelected))}`,
706
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, wybrano`,
707
+ },
708
+ "pt-BR": {
709
+ buttonLabel: "Mostrar sugestões",
710
+ listboxLabel: "Sugestões",
711
+ countAnnouncement: (values, format) =>
712
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opção`, other: () => `${format.number(Number(values?.optionCount))} opções` })} disponível.`,
713
+ focusAnnouncement: (values, format) =>
714
+ `${format.select({ true: () => `Grupo inserido ${String(values?.groupTitle ?? "")}, com ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opção`, other: () => `${format.number(Number(values?.groupCount))} opções` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", selecionado", other: () => "" }, String(values?.isSelected))}`,
715
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, selecionado`,
716
+ },
717
+ "pt-PT": {
718
+ buttonLabel: "Apresentar sugestões",
719
+ listboxLabel: "Sugestões",
720
+ countAnnouncement: (values, format) =>
721
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opção`, other: () => `${format.number(Number(values?.optionCount))} opções` })} disponível.`,
722
+ focusAnnouncement: (values, format) =>
723
+ `${format.select({ true: () => `Grupo introduzido ${String(values?.groupTitle ?? "")}, com ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opção`, other: () => `${format.number(Number(values?.groupCount))} opções` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", selecionado", other: () => "" }, String(values?.isSelected))}`,
724
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, selecionado`,
725
+ },
726
+ "ro-RO": {
727
+ buttonLabel: "Afișare sugestii",
728
+ listboxLabel: "Sugestii",
729
+ countAnnouncement: (values, format) =>
730
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opțiune`, other: () => `${format.number(Number(values?.optionCount))} opțiuni` })} disponibile.`,
731
+ focusAnnouncement: (values, format) =>
732
+ `${format.select({ true: () => `Grup ${String(values?.groupTitle ?? "")} introdus, cu ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opțiune`, other: () => `${format.number(Number(values?.groupCount))} opțiuni` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", selectat", other: () => "" }, String(values?.isSelected))}`,
733
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, selectat`,
734
+ },
735
+ "ru-RU": {
736
+ buttonLabel: "Показать предложения",
737
+ listboxLabel: "Предложения",
738
+ countAnnouncement: (values, format) =>
739
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} параметр`, other: () => `${format.number(Number(values?.optionCount))} параметров` })} доступно.`,
740
+ focusAnnouncement: (values, format) =>
741
+ `${format.select({ true: () => `Введенная группа ${String(values?.groupTitle ?? "")}, с ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} параметром`, other: () => `${format.number(Number(values?.groupCount))} параметрами` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", выбранными", other: () => "" }, String(values?.isSelected))}`,
742
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, выбрано`,
743
+ },
744
+ "sk-SK": {
745
+ buttonLabel: "Zobraziť návrhy",
746
+ listboxLabel: "Návrhy",
747
+ countAnnouncement: (values, format) =>
748
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} možnosť`, other: () => `${format.number(Number(values?.optionCount))} možnosti/-í` })} k dispozícii.`,
749
+ focusAnnouncement: (values, format) =>
750
+ `${format.select({ true: () => `Zadaná skupina ${String(values?.groupTitle ?? "")}, s ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} možnosťou`, other: () => `${format.number(Number(values?.groupCount))} možnosťami` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", vybraté", other: () => "" }, String(values?.isSelected))}`,
751
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, vybraté`,
752
+ },
753
+ "sl-SI": {
754
+ buttonLabel: "Prikaži predloge",
755
+ listboxLabel: "Predlogi",
756
+ countAnnouncement: (values, format) =>
757
+ `Na voljo je ${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opcija`, other: () => `${format.number(Number(values?.optionCount))} opcije` })}.`,
758
+ focusAnnouncement: (values, format) =>
759
+ `${format.select({ true: () => `Vnesena skupina ${String(values?.groupTitle ?? "")}, z ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opcija`, other: () => `${format.number(Number(values?.groupCount))} opcije` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", izbrano", other: () => "" }, String(values?.isSelected))}`,
760
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, izbrano`,
761
+ },
762
+ "sr-SP": {
763
+ buttonLabel: "Prikaži predloge",
764
+ listboxLabel: "Predlozi",
765
+ countAnnouncement: (values, format) =>
766
+ `Dostupno još: ${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} opcija`, other: () => `${format.number(Number(values?.optionCount))} opcije/a` })}.`,
767
+ focusAnnouncement: (values, format) =>
768
+ `${format.select({ true: () => `Unesena grupa ${String(values?.groupTitle ?? "")}, s ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} opcijom`, other: () => `${format.number(Number(values?.groupCount))} optione/a` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", izabranih", other: () => "" }, String(values?.isSelected))}`,
769
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, izabrano`,
770
+ },
771
+ "sv-SE": {
772
+ buttonLabel: "Visa förslag",
773
+ listboxLabel: "Förslag",
774
+ countAnnouncement: (values, format) =>
775
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} alternativ`, other: () => `${format.number(Number(values?.optionCount))} alternativ` })} tillgängliga.`,
776
+ focusAnnouncement: (values, format) =>
777
+ `${format.select({ true: () => `Ingick i gruppen ${String(values?.groupTitle ?? "")} med ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} alternativ`, other: () => `${format.number(Number(values?.groupCount))} alternativ` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", valda", other: () => "" }, String(values?.isSelected))}`,
778
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, valda`,
779
+ },
780
+ "tr-TR": {
781
+ buttonLabel: "Önerileri göster",
782
+ listboxLabel: "Öneriler",
783
+ countAnnouncement: (values, format) =>
784
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} seçenek`, other: () => `${format.number(Number(values?.optionCount))} seçenekler` })} kullanılabilir.`,
785
+ focusAnnouncement: (values, format) =>
786
+ `${format.select({ true: () => `Girilen grup ${String(values?.groupTitle ?? "")}, ile ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} seçenek`, other: () => `${format.number(Number(values?.groupCount))} seçenekler` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", seçildi", other: () => "" }, String(values?.isSelected))}`,
787
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, seçildi`,
788
+ },
789
+ "uk-UA": {
790
+ buttonLabel: "Показати пропозиції",
791
+ listboxLabel: "Пропозиції",
792
+ countAnnouncement: (values, format) =>
793
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} параметр`, other: () => `${format.number(Number(values?.optionCount))} параметри(-ів)` })} доступно.`,
794
+ focusAnnouncement: (values, format) =>
795
+ `${format.select({ true: () => `Введена група ${String(values?.groupTitle ?? "")}, з ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} параметр`, other: () => `${format.number(Number(values?.groupCount))} параметри(-ів)` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", вибрано", other: () => "" }, String(values?.isSelected))}`,
796
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, вибрано`,
797
+ },
798
+ "zh-CN": {
799
+ buttonLabel: "显示建议",
800
+ listboxLabel: "建议",
801
+ countAnnouncement: (values, format) =>
802
+ `有 ${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} 个选项`, other: () => `${format.number(Number(values?.optionCount))} 个选项` })}可用。`,
803
+ focusAnnouncement: (values, format) =>
804
+ `${format.select({ true: () => `进入了 ${String(values?.groupTitle ?? "")} 组,其中有 ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} 个选项`, other: () => `${format.number(Number(values?.groupCount))} 个选项` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", 已选择", other: () => "" }, String(values?.isSelected))}`,
805
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, 已选择`,
806
+ },
807
+ "zh-TW": {
808
+ buttonLabel: "顯示建議",
809
+ listboxLabel: "建議",
810
+ countAnnouncement: (values, format) =>
811
+ `${format.plural(Number(values?.optionCount), { one: () => `${format.number(Number(values?.optionCount))} 選項`, other: () => `${format.number(Number(values?.optionCount))} 選項` })} 可用。`,
812
+ focusAnnouncement: (values, format) =>
813
+ `${format.select({ true: () => `輸入的群組 ${String(values?.groupTitle ?? "")}, 有 ${format.plural(Number(values?.groupCount), { one: () => `${format.number(Number(values?.groupCount))} 選項`, other: () => `${format.number(Number(values?.groupCount))} 選項` })}. `, other: () => "" }, String(values?.isGroupChange))}${String(values?.optionText ?? "")}${format.select({ true: () => ", 已選取", other: () => "" }, String(values?.isSelected))}`,
814
+ selectedAnnouncement: (values) => `${String(values?.optionText ?? "")}, 已選取`,
815
+ },
816
+ });
817
+
441
818
  export interface ComboBoxOptions extends FieldOptions {
442
819
  inputRef: ElementRef<HTMLInputElement>;
443
820
  listBoxRef: ElementRef;
@@ -449,6 +826,14 @@ export interface ComboBoxOptions extends FieldOptions {
449
826
  shouldFocusWrap?: MaybeAccessor<boolean | undefined>;
450
827
  name?: MaybeAccessor<string | undefined>;
451
828
  form?: MaybeAccessor<string | undefined>;
829
+ /**
830
+ * What the field's own `name` submits. With "key" the field carries no
831
+ * `name`, and the caller renders a hidden input holding the key; the name
832
+ * still matches the form's server errors to this field.
833
+ *
834
+ * @default "text"
835
+ */
836
+ formValue?: MaybeAccessor<"key" | "text" | undefined>;
452
837
  placeholder?: MaybeAccessor<string | undefined>;
453
838
  keyboardDelegate?: KeyboardDelegate;
454
839
  /** What the page thinks of the choice, checked as it changes. */
@@ -479,6 +864,7 @@ export function comboBox(options: ComboBoxOptions, state: ComboBoxState<unknown>
479
864
 
480
865
  const {
481
866
  state: validation,
867
+ behavior,
482
868
  isInvalid,
483
869
  errors,
484
870
  errorMessage,
@@ -568,6 +954,114 @@ export function comboBox(options: ComboBoxOptions, state: ComboBoxState<unknown>
568
954
  }
569
955
  };
570
956
 
957
+ const message = stringFormatter(comboBoxStrings);
958
+
959
+ // What a screen reader is told that it cannot see for itself. The input
960
+ // keeps focus throughout, so moving through the list, the list changing
961
+ // under the typing and a choice being made are all silent otherwise.
962
+ if (!isServer) {
963
+ let first = true;
964
+ let lastOpen = false;
965
+ let lastCount = 0;
966
+ createEffect(
967
+ () =>
968
+ [
969
+ state.isOpen(),
970
+ getItemCount(state.collection()),
971
+ state.selectionManager().focusedKey,
972
+ message(),
973
+ ] as const,
974
+ ([isOpen, count, focusedKey, format]) => {
975
+ // Only when the list opens with nothing highlighted: a highlighted
976
+ // option is read as "1 of 6" already. VoiceOver reads no such count.
977
+ const opened = isOpen && !lastOpen && (focusedKey === null || isAppleDevice());
978
+ if (!first && isOpen && (opened || count !== lastCount)) {
979
+ announce(format.format("countAnnouncement", { optionCount: count }));
980
+ }
981
+ first = false;
982
+ lastOpen = isOpen;
983
+ lastCount = count;
984
+ },
985
+ );
986
+
987
+ // VoiceOver reads each option on its own, but says nothing on entering a
988
+ // section, so the section is named the moment the highlight crosses into
989
+ // one.
990
+ let lastSection: Key | null = null;
991
+ let lastItem: Key | null = null;
992
+ createEffect(
993
+ () => {
994
+ const item = focusedItem();
995
+ const sectionKey = item?.parentKey ?? null;
996
+ return [
997
+ item,
998
+ sectionKey === null ? null : state.collection().getItem(sectionKey),
999
+ item === null ? false : state.selectionManager().isSelected(item.key),
1000
+ message(),
1001
+ ] as const;
1002
+ },
1003
+ ([item, section, isSelected, format]) => {
1004
+ const itemKey = item?.key ?? null;
1005
+ const sectionKey = section?.key ?? null;
1006
+ if (isAppleDevice() && item !== null && itemKey !== lastItem) {
1007
+ if (section !== null && sectionKey !== lastSection) {
1008
+ announce(
1009
+ format.format("focusAnnouncement", {
1010
+ isGroupChange: true,
1011
+ groupTitle: section["aria-label"] ?? section.textValue,
1012
+ groupCount: section.childNodes.filter((child) => child.type === "item").length,
1013
+ optionText: item["aria-label"] ?? item.textValue,
1014
+ isSelected,
1015
+ }),
1016
+ );
1017
+ }
1018
+ }
1019
+ lastSection = sectionKey;
1020
+ lastItem = itemKey;
1021
+ },
1022
+ );
1023
+
1024
+ // Other screen readers announce a selection themselves; VoiceOver does not.
1025
+ let lastSelected: Key | null = untrack(state.selectedKey);
1026
+ createEffect(
1027
+ () => [state.selectedKey(), state.selectedItem(), state.isFocused(), message()] as const,
1028
+ ([key, item, focused, format]) => {
1029
+ if (isAppleDevice() && focused && item !== null && key !== lastSelected) {
1030
+ announce(
1031
+ format.format("selectedAnnouncement", {
1032
+ optionText: item["aria-label"] ?? item.textValue,
1033
+ }),
1034
+ );
1035
+ }
1036
+ lastSelected = key;
1037
+ },
1038
+ );
1039
+ }
1040
+
1041
+ // While the list is open, nothing but the field and the list is there for a
1042
+ // screen reader: its virtual cursor would otherwise walk off the field into
1043
+ // the page with the list still open over it.
1044
+ followOpen(
1045
+ () =>
1046
+ state.isOpen()
1047
+ ? ([
1048
+ access(options.inputRef) as Element | null,
1049
+ access(options.popoverRef ?? options.listBoxRef) as Element | null,
1050
+ ] as const)
1051
+ : null,
1052
+ (targets) => {
1053
+ if (targets === null) return undefined;
1054
+ const present = targets.filter((target): target is Element => target !== null);
1055
+ return present.length === 0 ? undefined : ariaHideOutside(present);
1056
+ },
1057
+ );
1058
+
1059
+ // A form reset puts the selection back to where it started, and the text
1060
+ // with it: the browser resets only the text, which then names one option
1061
+ // while the selection is another.
1062
+ const initialKey = untrack(state.selectedKey);
1063
+ formReset(options.inputRef, initialKey, (key) => state.setSelectedKey(key));
1064
+
571
1065
  const onInput = (event: Event): void => {
572
1066
  const input = event.target as HTMLInputElement;
573
1067
  state.setInputValue(input.value);
@@ -605,8 +1099,9 @@ export function comboBox(options: ComboBoxOptions, state: ComboBoxState<unknown>
605
1099
  value: state.inputValue,
606
1100
  disabled: () => access(options.isDisabled) === true,
607
1101
  readOnly: () => access(options.isReadOnly) === true,
608
- required: () => access(options.isRequired) === true,
609
- name: () => access(options.name),
1102
+ // Only native validation blocks the submit; under "aria" the page decides.
1103
+ required: () => behavior() === "native" && access(options.isRequired) === true,
1104
+ name: () => (access(options.formValue) === "key" ? undefined : access(options.name)),
610
1105
  form: () => access(options.form),
611
1106
  placeholder: () => access(options.placeholder),
612
1107
  "aria-expanded": () => state.isOpen(),
@@ -658,7 +1153,7 @@ export function comboBox(options: ComboBoxOptions, state: ComboBoxState<unknown>
658
1153
  ]
659
1154
  .filter(Boolean)
660
1155
  .join(" "),
661
- "aria-label": "Show suggestions",
1156
+ "aria-label": () => message().format("buttonLabel"),
662
1157
  onPressStart: (event: { pointerType: string }) => {
663
1158
  if (event.pointerType === "touch") return;
664
1159
  (access(options.inputRef) as HTMLInputElement | null)?.focus();
@@ -735,6 +1230,13 @@ export interface ComboBoxComponentProps<T> extends StyleProps, ItemAccessors<T>
735
1230
  validationBehavior?: ValidationBehavior;
736
1231
  name?: string;
737
1232
  form?: string;
1233
+ /**
1234
+ * What `name` submits: the chosen option's key, or the text in the field.
1235
+ * With `allowsCustomValue` the text is the value, and it is always the text.
1236
+ *
1237
+ * @default "key"
1238
+ */
1239
+ formValue?: "key" | "text";
738
1240
  /** @default "bottom start" */
739
1241
  placement?: Placement;
740
1242
  "aria-label"?: string;
@@ -752,18 +1254,20 @@ export interface ComboBoxComponentProps<T> extends StyleProps, ItemAccessors<T>
752
1254
  * </ComboBox>
753
1255
  * ```
754
1256
  */
755
- export function ComboBox<T>(props: Incoming<ComboBoxComponentProps<T>>) {
1257
+ export function ComboBox<T>(props: ComboBoxComponentProps<T>) {
756
1258
  const inputRef = makeRef<HTMLInputElement>();
757
1259
  const listRef = makeRef<HTMLUListElement>();
758
1260
  const buttonRef = makeRef<HTMLButtonElement>();
759
- const options = fromProps(props as unknown as Incoming<Record<string, unknown>>);
1261
+ const popoverRef = makeRef<HTMLDivElement>();
1262
+ const options = fromProps(cells(props) as unknown as Incoming<Record<string, unknown>>);
1263
+ const submitsText = (): boolean => props.allowsCustomValue === true || props.formValue === "text";
760
1264
 
761
1265
  const state = comboBoxState<T>({
762
1266
  ...(options as ComboBoxStateOptions<T>),
763
- filterBy: callback<[string, string], boolean>(props.filterBy),
764
- onSelectionChange: (key) => props.onSelectionChange?.()?.(key),
765
- onInputChange: (value) => props.onInputChange?.()?.(value),
766
- onOpenChange: (isOpen) => props.onOpenChange?.()?.(isOpen),
1267
+ filterBy: callback<[string, string], boolean>(cells(props).filterBy),
1268
+ onSelectionChange: (key) => props.onSelectionChange?.(key),
1269
+ onInputChange: (value) => props.onInputChange?.(value),
1270
+ onOpenChange: (isOpen) => props.onOpenChange?.(isOpen),
767
1271
  });
768
1272
 
769
1273
  const {
@@ -781,27 +1285,29 @@ export function ComboBox<T>(props: Incoming<ComboBoxComponentProps<T>>) {
781
1285
  inputRef,
782
1286
  listBoxRef: listRef,
783
1287
  buttonRef,
784
- validate: callback(props.validate),
785
- validationBehavior: () => props.validationBehavior?.(),
1288
+ popoverRef,
1289
+ formValue: () => (submitsText() ? "text" : "key"),
1290
+ validate: callback(cells(props).validate),
1291
+ validationBehavior: () => props.validationBehavior,
786
1292
  },
787
1293
  state,
788
1294
  );
789
1295
 
790
1296
  const { buttonProps } = button(buttonOptions, buttonRef);
791
- const { hoverProps, isHovered } = hover({ isDisabled: () => props.isDisabled?.() });
1297
+ const { hoverProps, isHovered } = hover({ isDisabled: () => props.isDisabled });
792
1298
  const { focusProps, isFocusVisible } = focusRing();
793
1299
 
794
1300
  const inputElementProps = mergeProps(
795
1301
  inputProps,
796
1302
  focusProps,
797
1303
  filterDOMProps(options, { global: true }),
798
- styleProps(props),
1304
+ styleProps(cells(props)),
799
1305
  {
800
1306
  "data-focus-visible": isFocusVisible,
801
1307
  "data-open": state.isOpen,
802
- "data-disabled": () => props.isDisabled?.() === true,
1308
+ "data-disabled": () => props.isDisabled === true,
803
1309
  "data-invalid": isInvalid,
804
- "data-testid": () => props["data-testid"]?.(),
1310
+ "data-testid": () => props["data-testid"],
805
1311
  },
806
1312
  );
807
1313
 
@@ -825,7 +1331,15 @@ export function ComboBox<T>(props: Incoming<ComboBoxComponentProps<T>>) {
825
1331
  return (
826
1332
  <>
827
1333
  <span {...labelProps}>{props.label}</span>
828
- <input {...inputElementProps} ref={mergeRefs(inputRef.set, props.ref?.())} />
1334
+ <input {...inputElementProps} ref={mergeRefs(inputRef.set, props.ref)} />
1335
+ <Show when={props.name !== undefined && !submitsText()}>
1336
+ <input
1337
+ type="hidden"
1338
+ name={props.name}
1339
+ form={props.form}
1340
+ value={String(state.selectedKey() ?? "")}
1341
+ />
1342
+ </Show>
829
1343
  <button {...buttonElementProps} type="button" ref={buttonRef.set}>
830
1344
  <span aria-hidden="true">▾</span>
831
1345
  </button>
@@ -833,8 +1347,9 @@ export function ComboBox<T>(props: Incoming<ComboBoxComponentProps<T>>) {
833
1347
  triggerRef={inputRef}
834
1348
  isOpen={state.isOpen()}
835
1349
  onOpenChange={state.setOpen}
836
- placement={props.placement?.() ?? "bottom start"}
1350
+ placement={props.placement ?? "bottom start"}
837
1351
  isDismissable
1352
+ ref={popoverRef.set}
838
1353
  >
839
1354
  <ComboBoxList
840
1355
  options={listBoxProps}
@@ -846,7 +1361,7 @@ export function ComboBox<T>(props: Incoming<ComboBoxComponentProps<T>>) {
846
1361
  <span {...descriptionProps}>{props.description}</span>
847
1362
  <span {...errorMessageProps}>
848
1363
  {() => {
849
- const given = props.errorMessage?.();
1364
+ const given = props.errorMessage;
850
1365
  if (given !== undefined && given !== null && given !== "") return given;
851
1366
  const found = errors();
852
1367
  return found.length === 0 ? null : found.join(" ");
@@ -869,11 +1384,11 @@ interface ComboBoxListProps {
869
1384
  * Built only once the list is open, so its autofocus reads the focus strategy
870
1385
  * the opening keypress set rather than the one from before it.
871
1386
  */
872
- function ComboBoxList(props: Incoming<ComboBoxListProps>) {
873
- const state = props.state();
874
- const listRef = props.listRef();
875
- const render = props.render();
876
- const options = props.options();
1387
+ function ComboBoxList(props: ComboBoxListProps) {
1388
+ const state = props.state;
1389
+ const listRef = props.listRef;
1390
+ const render = props.render;
1391
+ const options = props.options;
877
1392
 
878
1393
  const { listBoxProps, baseId } = listBox(
879
1394
  { ...(options as unknown as Record<string, MaybeAccessor<never>>), ref: listRef },
@@ -892,6 +1407,9 @@ function ComboBoxList(props: Incoming<ComboBoxListProps>) {
892
1407
  shouldUseVirtualFocus: () => true,
893
1408
  };
894
1409
 
1410
+ // A section builds its options with the same callback.
1411
+ provideItemRender(render);
1412
+
895
1413
  return (
896
1414
  <ListBoxProvider value={value}>
897
1415
  <ul {...elementProps} ref={listRef.set}>
@@ -1551,10 +2069,10 @@ function createComboboxRoot<V>(props: Incoming<ComboboxRootProps<V>>): ComboboxR
1551
2069
  };
1552
2070
  }
1553
2071
 
1554
- function ComboboxRootProvider(props: Incoming<{ value: ComboboxRootValue; children?: Child }>) {
2072
+ function ComboboxRootProvider(props: { value: ComboboxRootValue; children?: Child }) {
1555
2073
  return provide(
1556
2074
  ComboboxRootContext,
1557
- () => props.value(),
2075
+ () => props.value,
1558
2076
  () => props.children as unknown,
1559
2077
  );
1560
2078
  }
@@ -1594,8 +2112,8 @@ function ComboboxFormValue() {
1594
2112
  *
1595
2113
  * Renders no element of its own: the parts are placed by whoever writes them.
1596
2114
  */
1597
- export function ComboboxRoot<V>(props: Incoming<ComboboxRootProps<V>>) {
1598
- const root = createComboboxRoot(props);
2115
+ export function ComboboxRoot<V>(props: ComboboxRootProps<V>) {
2116
+ const root = createComboboxRoot(cells(props));
1599
2117
  return (
1600
2118
  <ComboboxRootProvider value={root}>
1601
2119
  {props.children}
@@ -1634,17 +2152,17 @@ export interface ComboboxInputProps extends StyleProps {
1634
2152
  * search over a list a button opened, and inside {@link ComboboxChips} it also
1635
2153
  * walks the chips beside it.
1636
2154
  */
1637
- export function ComboboxInput(props: Incoming<ComboboxInputProps>) {
2155
+ export function ComboboxInput(props: ComboboxInputProps) {
1638
2156
  const root = useComboboxRoot();
1639
2157
  const chips = getContext(ComboboxChipsContext) ?? null;
1640
2158
  const isInside = getContext(ComboboxPopupContext);
1641
- const isDisabled = (): boolean => props.disabled?.() === true;
2159
+ const isDisabled = (): boolean => props.disabled === true;
1642
2160
 
1643
2161
  root.attachInput({
1644
2162
  isInside,
1645
2163
  isDisabled,
1646
- label: () => props["aria-label"]?.(),
1647
- labelledBy: () => props["aria-labelledby"]?.(),
2164
+ label: () => props["aria-label"],
2165
+ labelledBy: () => props["aria-labelledby"],
1648
2166
  });
1649
2167
 
1650
2168
  const { focusProps, isFocusVisible } = focusRing();
@@ -1652,20 +2170,27 @@ export function ComboboxInput(props: Incoming<ComboboxInputProps>) {
1652
2170
  const elementProps = mergeProps(
1653
2171
  root.inputProps(chips),
1654
2172
  focusProps,
1655
- filterDOMProps(fromProps(props), { global: true, labelable: true, propNames: INPUT_PROPS }),
1656
- styleProps(props),
2173
+ filterDOMProps(fromProps(cells(props)), {
2174
+ global: true,
2175
+ labelable: true,
2176
+ propNames: INPUT_PROPS,
2177
+ }),
2178
+ styleProps(cells(props)),
1657
2179
  {
1658
- placeholder: () => props.placeholder?.(),
2180
+ placeholder: () => props.placeholder,
1659
2181
  disabled: root.isDisabled,
2182
+ // With several values the field only ever holds a query, empty once
2183
+ // something is chosen, so it is required only while nothing is.
2184
+ required: () => props.required === true && (!root.isMultiple() || root.values().length === 0),
1660
2185
  "data-focus-visible": isFocusVisible,
1661
2186
  "data-open": root.isOpen,
1662
2187
  "data-state": () => (root.isOpen() ? "open" : "closed"),
1663
2188
  "data-disabled": root.isDisabled,
1664
- "data-testid": () => props["data-testid"]?.(),
2189
+ "data-testid": () => props["data-testid"],
1665
2190
  },
1666
2191
  );
1667
2192
 
1668
- return <input {...elementProps} ref={mergeRefs(root.inputRef.set, props.ref?.())} />;
2193
+ return <input {...elementProps} ref={mergeRefs(root.inputRef.set, props.ref)} />;
1669
2194
  }
1670
2195
 
1671
2196
  /** Nothing reads it. `provide` is what creates the scope a slot is installed in. */
@@ -1726,7 +2251,7 @@ export function ComboboxTrigger(props: Incoming<{ children?: Child }>) {
1726
2251
  );
1727
2252
  }
1728
2253
 
1729
- function ComboboxClearSlot(props: Incoming<{ children?: Child }>) {
2254
+ function ComboboxClearSlot(props: { children?: Child }) {
1730
2255
  const root = useComboboxRoot();
1731
2256
  return provide(
1732
2257
  SlotScope,
@@ -1750,7 +2275,7 @@ function ComboboxClearSlot(props: Incoming<{ children?: Child }>) {
1750
2275
  * Hands the clearing press to the button inside it, and renders that button
1751
2276
  * only while there is something to clear.
1752
2277
  */
1753
- export function ComboboxClear(props: Incoming<{ children?: Child }>) {
2278
+ export function ComboboxClear(props: { children?: Child }) {
1754
2279
  const root = useComboboxRoot();
1755
2280
  return (
1756
2281
  <Show when={root.values().length > 0 || root.inputValue() !== ""}>
@@ -1773,14 +2298,14 @@ export interface ComboboxValueProps {
1773
2298
  * place, so a `<For>` over it adds and removes chips without rebuilding the
1774
2299
  * input written beside them, which would take the caret with it.
1775
2300
  */
1776
- export function ComboboxValue(props: Incoming<ComboboxValueProps>) {
2301
+ export function ComboboxValue(props: ComboboxValueProps) {
1777
2302
  const root = useComboboxRoot();
1778
2303
  const render = renderCallback(props.children);
1779
2304
 
1780
2305
  if (render === null) {
1781
2306
  const text = (): string => {
1782
2307
  const chosen = root.values();
1783
- if (chosen.length === 0) return props.placeholder?.() ?? "";
2308
+ if (chosen.length === 0) return props.placeholder ?? "";
1784
2309
  return chosen.map(root.labelOf).join(", ");
1785
2310
  };
1786
2311
  return <>{props.children === undefined ? text() : (props.children as () => Child)()}</>;
@@ -1837,22 +2362,21 @@ export interface ComboboxPopupProps extends StyleProps {
1837
2362
  * one is the caller's to style. Animating the positioned element would move
1838
2363
  * the thing being measured.
1839
2364
  */
1840
- export function ComboboxPopup(props: Incoming<ComboboxPopupProps>) {
2365
+ export function ComboboxPopup(props: ComboboxPopupProps) {
1841
2366
  const root = useComboboxRoot();
1842
2367
  const locale = useLocale();
1843
2368
  const positionerRef = makeRef<HTMLDivElement>();
1844
2369
  const popupRef = root.popupRef;
1845
2370
  const close = (): void => root.setOpen(false);
1846
2371
 
1847
- const placement = (): Placement =>
1848
- placementFor(props.side?.() ?? "bottom", props.align?.() ?? "start");
2372
+ const placement = (): Placement => placementFor(props.side ?? "bottom", props.align ?? "start");
1849
2373
 
1850
2374
  const position = overlayPosition({
1851
- targetRef: () => anchorElement(props.anchor?.()) ?? root.anchor(),
2375
+ targetRef: () => anchorElement(props.anchor) ?? root.anchor(),
1852
2376
  overlayRef: positionerRef,
1853
2377
  placement,
1854
- offset: () => props.sideOffset?.() ?? 6,
1855
- crossOffset: () => props.alignOffset?.() ?? 0,
2378
+ offset: () => props.sideOffset ?? 6,
2379
+ crossOffset: () => props.alignOffset ?? 0,
1856
2380
  isOpen: root.isOpen,
1857
2381
  onClose: close,
1858
2382
  direction: () => locale().direction,
@@ -1875,12 +2399,12 @@ export function ComboboxPopup(props: Incoming<ComboboxPopupProps>) {
1875
2399
 
1876
2400
  const popupDirection = declaredDirection();
1877
2401
  const popupProps = mergeProps(
1878
- filterDOMProps(fromProps(props), { global: true, labelable: true }),
2402
+ filterDOMProps(fromProps(cells(props)), { global: true, labelable: true }),
1879
2403
  // Portalled out from under the element that carries `dir`.
1880
- { dir: () => props.dir?.() ?? popupDirection() },
1881
- styleProps(props),
2404
+ { dir: () => props.dir ?? popupDirection() },
2405
+ styleProps(cells(props)),
1882
2406
  {
1883
- role: () => props.role?.() ?? "presentation",
2407
+ role: () => props.role ?? "presentation",
1884
2408
  "data-open": () => !gate.isExiting(),
1885
2409
  "data-closed": gate.isExiting,
1886
2410
  "data-state": () => (gate.isExiting() ? "closed" : "open"),
@@ -1888,7 +2412,7 @@ export function ComboboxPopup(props: Incoming<ComboboxPopupProps>) {
1888
2412
  "data-align": () => alignOf(placement()),
1889
2413
  "data-placement": position.placement,
1890
2414
  "data-empty": root.isEmpty,
1891
- "data-testid": () => props["data-testid"]?.(),
2415
+ "data-testid": () => props["data-testid"],
1892
2416
  },
1893
2417
  );
1894
2418
 
@@ -1900,7 +2424,7 @@ export function ComboboxPopup(props: Incoming<ComboboxPopupProps>) {
1900
2424
  positionerRef={positionerRef}
1901
2425
  popupProps={popupProps}
1902
2426
  popupRef={popupRef}
1903
- forwardedRef={props.ref?.()}
2427
+ forwardedRef={props.ref}
1904
2428
  >
1905
2429
  {props.children}
1906
2430
  </ComboboxPopupBody>
@@ -1925,20 +2449,20 @@ interface ComboboxPopupBodyProps {
1925
2449
  * Only when there is no input outside: a list under a field the user is typing
1926
2450
  * in must not take the caret, and a scope would.
1927
2451
  */
1928
- function ComboboxPopupBody(props: Incoming<ComboboxPopupBodyProps>) {
2452
+ function ComboboxPopupBody(props: ComboboxPopupBodyProps) {
1929
2453
  const root = useComboboxRoot();
1930
2454
  const scope = untrack(root.hasOuterInput)
1931
2455
  ? null
1932
2456
  : focusScope({ contain: true, restoreFocus: true, autoFocus: true });
1933
- const positionerRef = props.positionerRef();
1934
- const setPopup = mergeRefs(props.popupRef().set, props.forwardedRef?.());
2457
+ const positionerRef = props.positionerRef;
2458
+ const setPopup = mergeRefs(props.popupRef.set, props.forwardedRef);
1935
2459
 
1936
2460
  return (
1937
2461
  <>
1938
2462
  <span hidden ref={scope?.startRef} />
1939
2463
  <ComboboxPopupScope>
1940
- <div {...props.positionerProps()} ref={positionerRef.set}>
1941
- <div {...props.popupProps()} ref={setPopup}>
2464
+ <div {...props.positionerProps} ref={positionerRef.set}>
2465
+ <div {...props.popupProps} ref={setPopup}>
1942
2466
  {props.children}
1943
2467
  </div>
1944
2468
  </div>
@@ -1948,7 +2472,7 @@ function ComboboxPopupBody(props: Incoming<ComboboxPopupBodyProps>) {
1948
2472
  );
1949
2473
  }
1950
2474
 
1951
- function ComboboxPopupScope(props: Incoming<{ children?: Child }>) {
2475
+ function ComboboxPopupScope(props: { children?: Child }) {
1952
2476
  return provide(
1953
2477
  ComboboxPopupContext,
1954
2478
  () => true,
@@ -1964,7 +2488,7 @@ export interface ComboboxListProps extends StyleProps {
1964
2488
  }
1965
2489
 
1966
2490
  /** The listbox. Its options are whatever its children render. */
1967
- export function ComboboxList(props: Incoming<ComboboxListProps>) {
2491
+ export function ComboboxList(props: ComboboxListProps) {
1968
2492
  const root = useComboboxRoot();
1969
2493
  const { children: _children, ...own } = props;
1970
2494
 
@@ -1982,19 +2506,19 @@ export function ComboboxList(props: Incoming<ComboboxListProps>) {
1982
2506
 
1983
2507
  const elementProps = mergeProps(
1984
2508
  listBoxProps,
1985
- filterDOMProps(fromProps(own), { global: true }),
1986
- styleProps(props),
2509
+ filterDOMProps(fromProps(cells(own)), { global: true }),
2510
+ styleProps(cells(props)),
1987
2511
  {
1988
2512
  id: root.listId,
1989
2513
  "aria-label": () =>
1990
- props["aria-label"]?.() ??
2514
+ props["aria-label"] ??
1991
2515
  root.listName().label ??
1992
- (root.listName().labelledBy === undefined && props["aria-labelledby"]?.() === undefined
2516
+ (root.listName().labelledBy === undefined && props["aria-labelledby"] === undefined
1993
2517
  ? "Suggestions"
1994
2518
  : undefined),
1995
- "aria-labelledby": () => props["aria-labelledby"]?.() ?? root.listName().labelledBy,
2519
+ "aria-labelledby": () => props["aria-labelledby"] ?? root.listName().labelledBy,
1996
2520
  "data-empty": root.isEmpty,
1997
- "data-testid": () => props["data-testid"]?.(),
2521
+ "data-testid": () => props["data-testid"],
1998
2522
  },
1999
2523
  );
2000
2524
 
@@ -2046,10 +2570,10 @@ export function useComboboxItem(): ComboboxItemValue {
2046
2570
  return value;
2047
2571
  }
2048
2572
 
2049
- function ComboboxItemProvider(props: Incoming<{ value: ComboboxItemValue; children?: Child }>) {
2573
+ function ComboboxItemProvider(props: { value: ComboboxItemValue; children?: Child }) {
2050
2574
  return provide(
2051
2575
  ComboboxItemContext,
2052
- () => props.value(),
2576
+ () => props.value,
2053
2577
  () => props.children as unknown,
2054
2578
  );
2055
2579
  }
@@ -2066,15 +2590,15 @@ export interface ComboboxItemProps extends StyleProps {
2066
2590
  }
2067
2591
 
2068
2592
  /** One option. It joins the list by rendering and leaves it by going away. */
2069
- export function ComboboxItem(props: Incoming<ComboboxItemProps>) {
2593
+ export function ComboboxItem(props: ComboboxItemProps) {
2070
2594
  const root = useComboboxRoot();
2071
2595
  // Read once: an option does not turn into a different one.
2072
- const item = untrack(props.value);
2596
+ const item = untrack(cells(props).value);
2073
2597
  const key = root.keyOf(item);
2074
2598
  root.attachItem(key, item);
2075
2599
 
2076
2600
  const manager = () => root.list.selectionManager();
2077
- const isDisabled = (): boolean => props.disabled?.() === true;
2601
+ const isDisabled = (): boolean => props.disabled === true;
2078
2602
  const state: ComboboxItemValue = {
2079
2603
  isSelected: () => manager().isSelected(key),
2080
2604
  isHighlighted: () => root.isOpen() && manager().focusedKey === key,
@@ -2085,7 +2609,7 @@ export function ComboboxItem(props: Incoming<ComboboxItemProps>) {
2085
2609
  untrack(() => {
2086
2610
  root.rememberLabel(
2087
2611
  key,
2088
- props.textValue?.() ??
2612
+ props.textValue ??
2089
2613
  root.ownLabelOf(item) ??
2090
2614
  root.registry.elementOf(key)?.textContent?.trim() ??
2091
2615
  "",
@@ -2100,7 +2624,7 @@ export function ComboboxItem(props: Incoming<ComboboxItemProps>) {
2100
2624
  <Option
2101
2625
  {...rest}
2102
2626
  value={key}
2103
- textValue={props.textValue?.() ?? root.ownLabelOf(item)}
2627
+ textValue={props.textValue ?? root.ownLabelOf(item)}
2104
2628
  isDisabled={isDisabled()}
2105
2629
  isHidden={!root.matches(item)}
2106
2630
  data-highlighted={state.isHighlighted() ? "" : undefined}
@@ -2126,13 +2650,11 @@ interface GroupValue {
2126
2650
 
2127
2651
  const ComboboxGroupContext = createContext<GroupValue | null>(null);
2128
2652
 
2129
- function ComboboxGroupProvider(
2130
- props: Incoming<{ value: GroupValue; section: Key; children?: Child }>,
2131
- ) {
2132
- return provideStaticSection(props.section(), () =>
2653
+ function ComboboxGroupProvider(props: { value: GroupValue; section: Key; children?: Child }) {
2654
+ return provideStaticSection(props.section, () =>
2133
2655
  provide(
2134
2656
  ComboboxGroupContext,
2135
- () => props.value(),
2657
+ () => props.value,
2136
2658
  () => props.children as unknown,
2137
2659
  ),
2138
2660
  ) as never;
@@ -2152,28 +2674,28 @@ export interface ComboboxGroupProps extends StyleProps {
2152
2674
  * accessibility tree and a `<li>` cannot hold another `<li>`: the outer one is
2153
2675
  * presentational and takes the caller's class, the inner one is the group.
2154
2676
  */
2155
- export function ComboboxGroup(props: Incoming<ComboboxGroupProps>) {
2677
+ export function ComboboxGroup(props: ComboboxGroupProps) {
2156
2678
  const root = useComboboxRoot();
2157
2679
  const section = staticItem(root.registry, { type: "section", textValue: "" });
2158
2680
  const headingId = id();
2159
2681
  const [isNamed, setNamed] = createSignal(false, { ownedWrite: true });
2160
2682
 
2161
2683
  const group: GroupValue = {
2162
- items: () => props.items?.() ?? [],
2684
+ items: () => props.items ?? [],
2163
2685
  headingId,
2164
2686
  name: setNamed,
2165
2687
  };
2166
2688
 
2167
2689
  const elementProps = mergeProps(
2168
- filterDOMProps(fromProps(props), { global: true }),
2169
- styleProps(props),
2690
+ filterDOMProps(fromProps(cells(props)), { global: true }),
2691
+ styleProps(cells(props)),
2170
2692
  {
2171
2693
  role: "presentation",
2172
2694
  // A group the query has emptied still holds its label, and a design
2173
2695
  // system hides the whole thing off this.
2174
2696
  "data-empty": () =>
2175
2697
  (root.list.collection().getItem(section.key)?.childNodes.length ?? 0) === 0,
2176
- "data-testid": () => props["data-testid"]?.(),
2698
+ "data-testid": () => props["data-testid"],
2177
2699
  },
2178
2700
  );
2179
2701
 
@@ -2182,7 +2704,7 @@ export function ComboboxGroup(props: Incoming<ComboboxGroupProps>) {
2182
2704
  <li {...elementProps} ref={section.ref}>
2183
2705
  <ul
2184
2706
  role="group"
2185
- aria-label={props["aria-label"]?.()}
2707
+ aria-label={props["aria-label"]}
2186
2708
  aria-labelledby={isNamed() ? headingId() : undefined}
2187
2709
  >
2188
2710
  {props.children}
@@ -2202,19 +2724,19 @@ export interface ComboboxGroupLabelProps extends StyleProps {
2202
2724
  * Rendering it is what makes the group point here, and leaving undoes that, so
2203
2725
  * a group never names an element that is not there.
2204
2726
  */
2205
- export function ComboboxGroupLabel(props: Incoming<ComboboxGroupLabelProps>) {
2727
+ export function ComboboxGroupLabel(props: ComboboxGroupLabelProps) {
2206
2728
  const group = getContext(ComboboxGroupContext) ?? null;
2207
2729
  group?.name(true);
2208
2730
  onCleanup(() => group?.name(false));
2209
2731
 
2210
2732
  const elementProps = mergeProps(
2211
- filterDOMProps(fromProps(props), { global: true }),
2212
- styleProps(props),
2733
+ filterDOMProps(fromProps(cells(props)), { global: true }),
2734
+ styleProps(cells(props)),
2213
2735
  {
2214
2736
  // Inside the group and not one of its options.
2215
2737
  role: "presentation",
2216
2738
  id: () => group?.headingId(),
2217
- "data-testid": () => props["data-testid"]?.(),
2739
+ "data-testid": () => props["data-testid"],
2218
2740
  },
2219
2741
  );
2220
2742
 
@@ -2227,7 +2749,7 @@ export interface ComboboxCollectionProps {
2227
2749
  }
2228
2750
 
2229
2751
  /** The enclosing {@link ComboboxGroup}'s items, less what the query rules out. */
2230
- export function ComboboxCollection(props: Incoming<ComboboxCollectionProps>) {
2752
+ export function ComboboxCollection(props: ComboboxCollectionProps) {
2231
2753
  const root = useComboboxRoot();
2232
2754
  const group = getContext(ComboboxGroupContext) ?? null;
2233
2755
  const render = renderCallback(props.children);
@@ -2253,17 +2775,17 @@ export interface ComboboxEmptyProps extends StyleProps {
2253
2775
  * region announces a change to what it holds, and one that arrives already
2254
2776
  * full announces nothing.
2255
2777
  */
2256
- export function ComboboxEmpty(props: Incoming<ComboboxEmptyProps>) {
2778
+ export function ComboboxEmpty(props: ComboboxEmptyProps) {
2257
2779
  const root = useComboboxRoot();
2258
2780
 
2259
2781
  const elementProps = mergeProps(
2260
- filterDOMProps(fromProps(props), { global: true }),
2261
- styleProps(props),
2782
+ filterDOMProps(fromProps(cells(props)), { global: true }),
2783
+ styleProps(cells(props)),
2262
2784
  {
2263
2785
  role: "status",
2264
2786
  "aria-live": "polite",
2265
2787
  "aria-atomic": "true",
2266
- "data-testid": () => props["data-testid"]?.(),
2788
+ "data-testid": () => props["data-testid"],
2267
2789
  },
2268
2790
  );
2269
2791
 
@@ -2274,10 +2796,10 @@ export function ComboboxEmpty(props: Incoming<ComboboxEmptyProps>) {
2274
2796
  );
2275
2797
  }
2276
2798
 
2277
- function ComboboxChipsProvider(props: Incoming<{ value: ChipsValue; children?: Child }>) {
2799
+ function ComboboxChipsProvider(props: { value: ChipsValue; children?: Child }) {
2278
2800
  return provide(
2279
2801
  ComboboxChipsContext,
2280
- () => props.value(),
2802
+ () => props.value,
2281
2803
  () => props.children as unknown,
2282
2804
  );
2283
2805
  }
@@ -2296,7 +2818,7 @@ export interface ComboboxChipsProps extends StyleProps {
2296
2818
  * A `<div>` that looks like a field: the chips inside carry remove buttons,
2297
2819
  * and a button inside an input is markup nothing can render.
2298
2820
  */
2299
- export function ComboboxChips(props: Incoming<ComboboxChipsProps>) {
2821
+ export function ComboboxChips(props: ComboboxChipsProps) {
2300
2822
  const root = useComboboxRoot();
2301
2823
  const registry = staticCollection();
2302
2824
  root.attachChips();
@@ -2312,14 +2834,14 @@ export function ComboboxChips(props: Incoming<ComboboxChipsProps>) {
2312
2834
  };
2313
2835
 
2314
2836
  const elementProps = mergeProps(
2315
- filterDOMProps(fromProps(props), { global: true, labelable: true }),
2316
- styleProps(props),
2837
+ filterDOMProps(fromProps(cells(props)), { global: true, labelable: true }),
2838
+ styleProps(cells(props)),
2317
2839
  {
2318
2840
  // A toolbar only while there are chips to move between: an input alone
2319
2841
  // in a toolbar is a toolbar of one.
2320
2842
  role: () => (chips.count() > 0 ? "toolbar" : undefined),
2321
2843
  "data-disabled": root.isDisabled,
2322
- "data-testid": () => props["data-testid"]?.(),
2844
+ "data-testid": () => props["data-testid"],
2323
2845
  onMouseDown: (event: MouseEvent) => {
2324
2846
  // The box is the field, so a press on its own padding is a press on
2325
2847
  // the input.
@@ -2332,7 +2854,7 @@ export function ComboboxChips(props: Incoming<ComboboxChipsProps>) {
2332
2854
 
2333
2855
  return (
2334
2856
  <ComboboxChipsProvider value={chips}>
2335
- <div {...elementProps} ref={mergeRefs(root.chipsRef.set, props.ref?.())}>
2857
+ <div {...elementProps} ref={mergeRefs(root.chipsRef.set, props.ref)}>
2336
2858
  {props.children}
2337
2859
  </div>
2338
2860
  </ComboboxChipsProvider>
@@ -2356,10 +2878,10 @@ export function useComboboxChip(): ComboboxChipValue {
2356
2878
  return value;
2357
2879
  }
2358
2880
 
2359
- function ComboboxChipProvider(props: Incoming<{ value: ComboboxChipValue; children?: Child }>) {
2881
+ function ComboboxChipProvider(props: { value: ComboboxChipValue; children?: Child }) {
2360
2882
  return provide(
2361
2883
  ComboboxChipContext,
2362
- () => props.value(),
2884
+ () => props.value,
2363
2885
  () => props.children as unknown,
2364
2886
  );
2365
2887
  }
@@ -2377,7 +2899,7 @@ export interface ComboboxChipProps extends StyleProps {
2377
2899
  * Reached with the arrows from the input rather than with Tab: a field holding
2378
2900
  * eight values would otherwise be eight stops before the next field.
2379
2901
  */
2380
- export function ComboboxChip(props: Incoming<ComboboxChipProps>) {
2902
+ export function ComboboxChip(props: ComboboxChipProps) {
2381
2903
  const root = useComboboxRoot();
2382
2904
  const locale = useLocale();
2383
2905
  const chips = getContext(ComboboxChipsContext);
@@ -2424,13 +2946,13 @@ export function ComboboxChip(props: Incoming<ComboboxChipProps>) {
2424
2946
  };
2425
2947
 
2426
2948
  const elementProps = mergeProps(
2427
- filterDOMProps(fromProps(props), { global: true, labelable: true }),
2428
- styleProps(props),
2949
+ filterDOMProps(fromProps(cells(props)), { global: true, labelable: true }),
2950
+ styleProps(cells(props)),
2429
2951
  {
2430
2952
  tabIndex: -1,
2431
2953
  "data-highlighted": isFocused,
2432
2954
  "data-disabled": root.isDisabled,
2433
- "data-testid": () => props["data-testid"]?.(),
2955
+ "data-testid": () => props["data-testid"],
2434
2956
  onKeyDown,
2435
2957
  onFocus: (event: FocusEvent) => {
2436
2958
  if (event.target === event.currentTarget) setFocused(true);
@@ -2444,7 +2966,7 @@ export function ComboboxChip(props: Incoming<ComboboxChipProps>) {
2444
2966
  // a hydrating page would claim the server's label as the button.
2445
2967
  return (
2446
2968
  <ComboboxChipProvider value={{ remove, label }}>
2447
- <div {...elementProps} ref={mergeRefs(chip.ref, props.ref?.())}>
2969
+ <div {...elementProps} ref={mergeRefs(chip.ref, props.ref)}>
2448
2970
  {props.children}
2449
2971
  </div>
2450
2972
  </ComboboxChipProvider>