@human-kit/ui 1.0.0-beta.5 → 1.0.0-beta.6

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 (204) hide show
  1. package/README.md +19 -17
  2. package/dist/accordion/README.md +3 -3
  3. package/dist/accordion/types.d.ts +37 -23
  4. package/dist/autocomplete/README.md +6 -7
  5. package/dist/autocomplete/empty/autocomplete-empty.svelte +1 -1
  6. package/dist/autocomplete/empty/autocomplete-empty.svelte.d.ts +1 -1
  7. package/dist/autocomplete/input/autocomplete-input.svelte +3 -3
  8. package/dist/autocomplete/input/autocomplete-input.svelte.d.ts +3 -3
  9. package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte +2 -2
  10. package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte.d.ts +2 -2
  11. package/dist/autocomplete/list/autocomplete-list.svelte +2 -2
  12. package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +2 -2
  13. package/dist/autocomplete/root/autocomplete.svelte +7 -7
  14. package/dist/autocomplete/root/autocomplete.svelte.d.ts +7 -7
  15. package/dist/autocomplete/status/autocomplete-status.svelte +1 -1
  16. package/dist/autocomplete/status/autocomplete-status.svelte.d.ts +1 -1
  17. package/dist/button/README.md +1 -1
  18. package/dist/button/root/button-root.svelte +15 -10
  19. package/dist/button/root/button-root.svelte.d.ts +15 -10
  20. package/dist/calendar/README.md +3 -3
  21. package/dist/calendar/grid-header/calendar-grid-header.svelte +3 -4
  22. package/dist/calendar/grid-header/calendar-grid-header.svelte.d.ts +3 -4
  23. package/dist/calendar/root/calendar-root.svelte +8 -2
  24. package/dist/calendar/root/calendar-root.svelte.d.ts +8 -2
  25. package/dist/calendar/trigger-next/README.md +1 -1
  26. package/dist/calendar/trigger-previous/README.md +1 -1
  27. package/dist/checkbox/README.md +1 -1
  28. package/dist/checkbox/indicator/README.md +1 -1
  29. package/dist/checkbox/root/README.md +2 -2
  30. package/dist/checkbox/root/checkbox-root.svelte +12 -10
  31. package/dist/checkbox/root/checkbox-root.svelte.d.ts +12 -10
  32. package/dist/clock/README.md +3 -3
  33. package/dist/clock/axis/README.md +1 -1
  34. package/dist/clock/root/README.md +1 -1
  35. package/dist/clock/wheel-column/clock-wheel-column.svelte +1 -1
  36. package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +1 -1
  37. package/dist/collapsible/README.md +3 -3
  38. package/dist/collapsible/types.d.ts +10 -7
  39. package/dist/combobox/README.md +2 -2
  40. package/dist/combobox/button/README.md +6 -6
  41. package/dist/combobox/input/README.md +1 -1
  42. package/dist/combobox/input/combobox-input.svelte +3 -3
  43. package/dist/combobox/input/combobox-input.svelte.d.ts +3 -3
  44. package/dist/combobox/item/combobox-listboxitem.svelte +4 -2
  45. package/dist/combobox/item/combobox-listboxitem.svelte.d.ts +4 -2
  46. package/dist/combobox/item-indicator/README.md +1 -1
  47. package/dist/combobox/item-indicator/combobox-item-indicator.svelte +2 -2
  48. package/dist/combobox/item-indicator/combobox-item-indicator.svelte.d.ts +2 -2
  49. package/dist/combobox/list/combobox-listbox.svelte +11 -8
  50. package/dist/combobox/list/combobox-listbox.svelte.d.ts +11 -8
  51. package/dist/combobox/popover/README.md +1 -1
  52. package/dist/combobox/root/README.md +24 -24
  53. package/dist/combobox/root/combobox.svelte +26 -17
  54. package/dist/combobox/root/combobox.svelte.d.ts +26 -17
  55. package/dist/combobox/status/README.md +1 -1
  56. package/dist/combobox/status/combobox-status.svelte +1 -1
  57. package/dist/combobox/status/combobox-status.svelte.d.ts +1 -1
  58. package/dist/combobox/tag/README.md +1 -1
  59. package/dist/combobox/tag/combobox-tag.svelte +1 -1
  60. package/dist/combobox/tag/combobox-tag.svelte.d.ts +1 -1
  61. package/dist/combobox/tag-remove/README.md +1 -1
  62. package/dist/combobox/tag-remove/combobox-tag-remove.svelte +4 -5
  63. package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +4 -5
  64. package/dist/combobox/tags/README.md +1 -1
  65. package/dist/combobox/tags/combobox-tags.svelte +11 -11
  66. package/dist/combobox/tags/combobox-tags.svelte.d.ts +11 -11
  67. package/dist/combobox/trigger/README.md +7 -7
  68. package/dist/datepicker/README.md +4 -4
  69. package/dist/datepicker/input/date-picker-input.svelte +3 -4
  70. package/dist/datepicker/input/date-picker-input.svelte.d.ts +3 -4
  71. package/dist/datepicker/root/date-picker-root.svelte +1 -1
  72. package/dist/datepicker/trigger/README.md +1 -1
  73. package/dist/daterangepicker/README.md +3 -3
  74. package/dist/daterangepicker/input/date-range-picker-input.svelte +3 -4
  75. package/dist/daterangepicker/input/date-range-picker-input.svelte.d.ts +3 -4
  76. package/dist/dialog/README.md +1 -1
  77. package/dist/dialog/close/dialog-close.svelte +3 -3
  78. package/dist/dialog/close/dialog-close.svelte.d.ts +3 -3
  79. package/dist/dialog/content/dialog-content.svelte +4 -4
  80. package/dist/dialog/content/dialog-content.svelte.d.ts +4 -4
  81. package/dist/dialog/description/dialog-description.svelte +3 -3
  82. package/dist/dialog/description/dialog-description.svelte.d.ts +3 -3
  83. package/dist/dialog/overlay/dialog-overlay.svelte +1 -1
  84. package/dist/dialog/overlay/dialog-overlay.svelte.d.ts +1 -1
  85. package/dist/dialog/portal/dialog-portal.svelte +1 -1
  86. package/dist/dialog/portal/dialog-portal.svelte.d.ts +1 -1
  87. package/dist/dialog/root/README.md +1 -1
  88. package/dist/dialog/root/dialog-root.svelte +36 -11
  89. package/dist/dialog/root/dialog-root.svelte.d.ts +11 -9
  90. package/dist/dialog/title/dialog-title.svelte +3 -3
  91. package/dist/dialog/title/dialog-title.svelte.d.ts +3 -3
  92. package/dist/dialog/trigger/README.md +1 -1
  93. package/dist/drawer/README.md +3 -3
  94. package/dist/drawer/body/drawer-body.svelte +2 -2
  95. package/dist/drawer/body/drawer-body.svelte.d.ts +2 -2
  96. package/dist/drawer/close/drawer-close.svelte +3 -3
  97. package/dist/drawer/close/drawer-close.svelte.d.ts +3 -3
  98. package/dist/drawer/content/drawer-content.svelte +12 -9
  99. package/dist/drawer/content/drawer-content.svelte.d.ts +12 -9
  100. package/dist/drawer/description/drawer-description.svelte +3 -3
  101. package/dist/drawer/description/drawer-description.svelte.d.ts +3 -3
  102. package/dist/drawer/indent/drawer-indent-background.svelte +1 -1
  103. package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +1 -1
  104. package/dist/drawer/indent/drawer-indent.svelte +2 -2
  105. package/dist/drawer/indent/drawer-indent.svelte.d.ts +2 -2
  106. package/dist/drawer/overlay/drawer-overlay.svelte +1 -1
  107. package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +1 -1
  108. package/dist/drawer/portal/drawer-portal.svelte +1 -1
  109. package/dist/drawer/portal/drawer-portal.svelte.d.ts +1 -1
  110. package/dist/drawer/root/context.d.ts +1 -1
  111. package/dist/drawer/root/drawer-root.svelte +25 -23
  112. package/dist/drawer/root/drawer-root.svelte.d.ts +25 -23
  113. package/dist/drawer/swipe-area/drawer-swipe-area.svelte +3 -3
  114. package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +3 -3
  115. package/dist/drawer/title/drawer-title.svelte +3 -3
  116. package/dist/drawer/title/drawer-title.svelte.d.ts +3 -3
  117. package/dist/drawer/trigger/drawer-trigger.svelte +6 -6
  118. package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +6 -6
  119. package/dist/drawer/viewport/drawer-viewport.svelte +2 -2
  120. package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +2 -2
  121. package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +1 -1
  122. package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +1 -1
  123. package/dist/dropzone/README.md +4 -6
  124. package/dist/input/input.svelte +6 -6
  125. package/dist/input/input.svelte.d.ts +6 -6
  126. package/dist/listbox/README.md +3 -10
  127. package/dist/listbox/item/listbox-item.svelte +24 -15
  128. package/dist/listbox/item/listbox-item.svelte.d.ts +24 -15
  129. package/dist/listbox/root/README.md +1 -1
  130. package/dist/listbox/root/context.d.ts +1 -1
  131. package/dist/listbox/root/listbox.svelte +50 -38
  132. package/dist/listbox/root/listbox.svelte.d.ts +50 -38
  133. package/dist/locale-provider/README.md +1 -6
  134. package/dist/menu/README.md +6 -15
  135. package/dist/menu/content/menu-content.svelte +14 -10
  136. package/dist/menu/content/menu-content.svelte.d.ts +14 -10
  137. package/dist/menu/context-trigger/menu-context-trigger.svelte +8 -9
  138. package/dist/menu/context-trigger/menu-context-trigger.svelte.d.ts +8 -9
  139. package/dist/menu/group/menu-group-label.svelte +1 -1
  140. package/dist/menu/group/menu-group-label.svelte.d.ts +1 -1
  141. package/dist/menu/item/menu-item.svelte +11 -8
  142. package/dist/menu/item/menu-item.svelte.d.ts +11 -8
  143. package/dist/menu/overlay/menu-overlay.svelte +1 -1
  144. package/dist/menu/overlay/menu-overlay.svelte.d.ts +1 -1
  145. package/dist/menu/root/context.d.ts +6 -3
  146. package/dist/menu/root/menu-root.svelte +14 -8
  147. package/dist/menu/root/menu-root.svelte.d.ts +14 -8
  148. package/dist/menu/root/menu-state.svelte.d.ts +1 -1
  149. package/dist/menu/separator/menu-separator.svelte +1 -1
  150. package/dist/menu/separator/menu-separator.svelte.d.ts +1 -1
  151. package/dist/menu/submenu/menu-submenu-root.svelte +10 -7
  152. package/dist/menu/submenu/menu-submenu-root.svelte.d.ts +10 -7
  153. package/dist/numberfield/root/README.md +1 -1
  154. package/dist/numberfield/scrub-area-cursor/README.md +1 -1
  155. package/dist/popover/README.md +1 -1
  156. package/dist/popover/content/popover-content.svelte +19 -14
  157. package/dist/popover/content/popover-content.svelte.d.ts +19 -14
  158. package/dist/popover/overlay/popover-overlay.svelte +1 -1
  159. package/dist/popover/overlay/popover-overlay.svelte.d.ts +1 -1
  160. package/dist/popover/root/README.md +1 -1
  161. package/dist/popover/root/popover-root.svelte +13 -10
  162. package/dist/popover/root/popover-root.svelte.d.ts +13 -10
  163. package/dist/popover/trigger/README.md +1 -1
  164. package/dist/primitives/floating.d.ts +3 -3
  165. package/dist/primitives/scroll-lock.js +37 -8
  166. package/dist/switch/root/README.md +2 -2
  167. package/dist/switch/root/switch-root.svelte +23 -18
  168. package/dist/switch/root/switch-root.svelte.d.ts +23 -18
  169. package/dist/switch/thumb/switch-thumb.svelte +1 -1
  170. package/dist/switch/thumb/switch-thumb.svelte.d.ts +1 -1
  171. package/dist/table/README.md +15 -10
  172. package/dist/table/checkbox-indicator/README.md +1 -1
  173. package/dist/table/column-resizer/README.md +2 -2
  174. package/dist/table/root/README.md +1 -1
  175. package/dist/table/sort-trigger/README.md +1 -1
  176. package/dist/table/types.d.ts +21 -20
  177. package/dist/tabs/types.d.ts +6 -6
  178. package/dist/timepicker/README.md +3 -2
  179. package/dist/timepicker/input/README.md +1 -1
  180. package/dist/timepicker/input/time-picker-input.svelte +58 -5
  181. package/dist/timepicker/input/time-picker-input.svelte.d.ts +10 -1
  182. package/dist/timepicker/root/README.md +1 -1
  183. package/dist/timepicker/trigger/README.md +1 -1
  184. package/dist/toggle/README.md +1 -1
  185. package/dist/toggle-group/README.md +2 -6
  186. package/dist/toggle-group/types.d.ts +7 -6
  187. package/dist/transfer-list/README.md +6 -17
  188. package/dist/transfer-list/item/transfer-list-item.svelte +4 -4
  189. package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +4 -4
  190. package/dist/transfer-list/list/transfer-list-list.svelte +12 -12
  191. package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +12 -12
  192. package/dist/transfer-list/move/transfer-list-move-button.svelte +4 -4
  193. package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +4 -4
  194. package/dist/transfer-list/move/transfer-list-reorder-button.svelte +3 -3
  195. package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +3 -3
  196. package/dist/transfer-list/root/transfer-list-root.svelte +23 -20
  197. package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +23 -20
  198. package/dist/transfer-list/status/transfer-list-status.svelte +1 -1
  199. package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +1 -1
  200. package/dist/tree/README.md +3 -3
  201. package/dist/tree/checkbox-indicator/README.md +1 -1
  202. package/dist/tree/root/README.md +1 -1
  203. package/dist/tree/types.d.ts +19 -10
  204. package/package.json +1 -1
@@ -11,75 +11,87 @@
11
11
  * @template T - The type of items when using dynamic rendering with the `items` prop.
12
12
  */
13
13
  type ListBoxProps = {
14
- /** How selection behaves: 'toggle' allows deselection, 'replace' always selects. */
14
+ /**
15
+ * The behavior of the selection: 'toggle' lets the user remove a selection, and 'replace' always
16
+ * selects.
17
+ */
15
18
  selectionBehavior?: 'toggle' | 'replace';
16
- /** Content shown when the list is empty. Can be a string or a Snippet. */
19
+ /** The content while the list is empty. It can be a string or a Snippet. */
17
20
  emptyPlaceholder?: string | Snippet;
18
- /** Iterable of items for dynamic rendering. Used with a snippet that receives each item. */
21
+ /**
22
+ * The items, for a list that the component makes from an array. Use it with a snippet that
23
+ * receives one item.
24
+ */
19
25
  items?: Iterable<T>;
20
26
  /**
21
- * Reads an item's key — the same value passed as `ListBox.Item`'s `id`.
27
+ * Reads the key of an item. This is the same value as the `id` of `ListBox.Item`.
22
28
  *
23
- * Only needed together with `virtualizer`: a Shift range is otherwise measured over
24
- * the options in the DOM, which for a virtualized list is just the rendered window,
25
- * so the range stops wherever the user happened to have scrolled.
29
+ * You need it only with `virtualizer`. Without it, a Shift range is measured over the options in
30
+ * the DOM. In a virtualized list, those are only the rows near the viewport, thus the range
31
+ * stops at the scroll position of the user.
26
32
  */
27
33
  getItemKey?: (item: T) => string | number;
28
- /** Keys of items that should be disabled and non-selectable. */
34
+ /** The keys of the items that must be disabled. The user cannot select them. */
29
35
  disabledKeys?: Iterable<string | number>;
30
- /** Selection mode: 'single' allows one selection, 'multiple' allows many. */
36
+ /** The selection mode: 'single' permits one selection, and 'multiple' permits more than one. */
31
37
  selectionMode?: 'single' | 'multiple';
32
- /** Selected keys. Two-way by default — use `bind:value`. */
38
+ /** The selected keys. By default it goes in the two directions: use `bind:value`. */
33
39
  value?: Iterable<string | number>;
34
- /** Initial selection, for when `value` is not supplied. */
40
+ /** The selection at the start, for when you give no `value`. */
35
41
  defaultValue?: Iterable<string | number>;
36
42
  /**
37
- * Opt into fully controlled state: the component stops writing back to `value` and
38
- * only reports through `onChange`, so the parent can reject a change by not flowing
39
- * the new selection back down. Off by default, because `bind:value` — the common
40
- * case — needs the write-back to work at all.
43
+ * Give your own code full control of the selection. The component stops to write back to
44
+ * `value`, and it reports only through `onChange`. Thus the parent can refuse a change: the
45
+ * parent does not send the new selection down. The default is off, because `bind:value` is the
46
+ * usual case and it needs the write-back.
41
47
  */
42
48
  controlledValue?: boolean;
43
- /** Content of the listbox. Can be static children or a snippet receiving items. */
49
+ /** The content of the listbox. It can be static children, or a snippet that receives one item. */
44
50
  children?: Snippet | Snippet<[T]>;
45
51
  /**
46
- * Rows rendered inside the listbox above the items — an action row such as
47
- * "Create …". Kept out of `children` because in dynamic mode that snippet is called
48
- * once per item.
52
+ * The rows in the listbox above the items, for example an action row such as "Create …". They
53
+ * are not in `children`, because from an array of items the component calls that snippet one
54
+ * time for each item.
49
55
  *
50
- * A virtualized list does not navigate into it: navigation there walks the item
51
- * array, which this is not part of.
56
+ * In a virtualized list, the keyboard does not go into these rows. There, the keys move through
57
+ * the array of the items, and these rows are not in it.
52
58
  */
53
59
  header?: Snippet;
54
- /** CSS class to apply to the listbox container. */
60
+ /** The CSS class names of the listbox container. */
55
61
  class?: string;
56
- /** HTML id attribute for the listbox element. */
62
+ /** The id of the listbox element. */
57
63
  id?: string;
58
- /** Accessible label for the listbox. Announced by screen readers. */
64
+ /** The accessible name of the listbox. A screen reader announces it. */
59
65
  'aria-label'?: string;
60
- /** Id of a visible element that labels the listbox. Use instead of `aria-label`
61
- * when the list already has a heading on screen. */
66
+ /**
67
+ * The id of an element that the user sees, and that gives the listbox its name. Use it in place
68
+ * of `aria-label` when the list already has a heading.
69
+ */
62
70
  'aria-labelledby'?: string;
63
- /** Callback fired when the selection changes. */
71
+ /** The component calls it when the selection changes. */
64
72
  onChange?: (value: Set<string | number>) => void;
65
- /** Disable DOM focus handling on the root container for virtual-focus compositions. */
73
+ /** Stops the DOM focus control on the root container, for a composition with a virtual focus. */
66
74
  disableFocusHandling?: boolean;
67
- /** Whether arrow-key navigation wraps from the last item to the first (and back). */
75
+ /**
76
+ * At the last item, the arrow keys move the focus to the first item, and at the first item, to
77
+ * the last one.
78
+ */
68
79
  loop?: boolean;
69
- /** Whether typing characters moves focus to the option whose text matches. */
80
+ /** When the user types a character, the focus moves to the option whose text agrees with it. */
70
81
  typeahead?: boolean;
71
82
  /**
72
- * Renders only the rows near the viewport instead of all of them.
83
+ * Makes only the rows near the viewport, and not all of the rows.
73
84
  *
74
- * Only honoured together with `items`: the listbox has to own the loop to be able to
75
- * slice it, so a list written as static children is never virtualized.
85
+ * The component obeys it only with `items`. The listbox must control the loop to cut it, thus a
86
+ * list written as static children is never virtualized.
76
87
  *
77
- * Rows must all be the same height — that assumption is what lets the scrollbar be
78
- * sized without measuring every row. The height is measured from the first rendered
79
- * row unless `rowHeight` says otherwise, so a themed list needs no magic number.
88
+ * All of the rows must have the same height. This is what lets the component calculate the
89
+ * scrollbar without a measurement of each row. The component measures the height from the first
90
+ * row, but `rowHeight` replaces that measurement. Thus a list with your own styles needs no
91
+ * fixed number.
80
92
  *
81
- * The listbox element itself is the scroller: give it a max height and
82
- * `overflow-y: auto`, as an unvirtualized long list would need anyway.
93
+ * The listbox element is the element that scrolls. Give it a maximum height and `overflow-y:
94
+ * auto`. A long list without a virtualizer needs the same.
83
95
  */
84
96
  virtualizer?: { rowHeight?: number; overscan?: number };
85
97
  } & Omit<
@@ -3,75 +3,87 @@ import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type ListBoxContext } from './context';
4
4
  declare function $$render<T extends object = object>(): {
5
5
  props: {
6
- /** How selection behaves: 'toggle' allows deselection, 'replace' always selects. */
6
+ /**
7
+ * The behavior of the selection: 'toggle' lets the user remove a selection, and 'replace' always
8
+ * selects.
9
+ */
7
10
  selectionBehavior?: "toggle" | "replace";
8
- /** Content shown when the list is empty. Can be a string or a Snippet. */
11
+ /** The content while the list is empty. It can be a string or a Snippet. */
9
12
  emptyPlaceholder?: string | Snippet;
10
- /** Iterable of items for dynamic rendering. Used with a snippet that receives each item. */
13
+ /**
14
+ * The items, for a list that the component makes from an array. Use it with a snippet that
15
+ * receives one item.
16
+ */
11
17
  items?: Iterable<T>;
12
18
  /**
13
- * Reads an item's key — the same value passed as `ListBox.Item`'s `id`.
19
+ * Reads the key of an item. This is the same value as the `id` of `ListBox.Item`.
14
20
  *
15
- * Only needed together with `virtualizer`: a Shift range is otherwise measured over
16
- * the options in the DOM, which for a virtualized list is just the rendered window,
17
- * so the range stops wherever the user happened to have scrolled.
21
+ * You need it only with `virtualizer`. Without it, a Shift range is measured over the options in
22
+ * the DOM. In a virtualized list, those are only the rows near the viewport, thus the range
23
+ * stops at the scroll position of the user.
18
24
  */
19
25
  getItemKey?: (item: T) => string | number;
20
- /** Keys of items that should be disabled and non-selectable. */
26
+ /** The keys of the items that must be disabled. The user cannot select them. */
21
27
  disabledKeys?: Iterable<string | number>;
22
- /** Selection mode: 'single' allows one selection, 'multiple' allows many. */
28
+ /** The selection mode: 'single' permits one selection, and 'multiple' permits more than one. */
23
29
  selectionMode?: "single" | "multiple";
24
- /** Selected keys. Two-way by default — use `bind:value`. */
30
+ /** The selected keys. By default it goes in the two directions: use `bind:value`. */
25
31
  value?: Iterable<string | number>;
26
- /** Initial selection, for when `value` is not supplied. */
32
+ /** The selection at the start, for when you give no `value`. */
27
33
  defaultValue?: Iterable<string | number>;
28
34
  /**
29
- * Opt into fully controlled state: the component stops writing back to `value` and
30
- * only reports through `onChange`, so the parent can reject a change by not flowing
31
- * the new selection back down. Off by default, because `bind:value` — the common
32
- * case — needs the write-back to work at all.
35
+ * Give your own code full control of the selection. The component stops to write back to
36
+ * `value`, and it reports only through `onChange`. Thus the parent can refuse a change: the
37
+ * parent does not send the new selection down. The default is off, because `bind:value` is the
38
+ * usual case and it needs the write-back.
33
39
  */
34
40
  controlledValue?: boolean;
35
- /** Content of the listbox. Can be static children or a snippet receiving items. */
41
+ /** The content of the listbox. It can be static children, or a snippet that receives one item. */
36
42
  children?: Snippet | Snippet<[T]>;
37
43
  /**
38
- * Rows rendered inside the listbox above the items — an action row such as
39
- * "Create …". Kept out of `children` because in dynamic mode that snippet is called
40
- * once per item.
44
+ * The rows in the listbox above the items, for example an action row such as "Create …". They
45
+ * are not in `children`, because from an array of items the component calls that snippet one
46
+ * time for each item.
41
47
  *
42
- * A virtualized list does not navigate into it: navigation there walks the item
43
- * array, which this is not part of.
48
+ * In a virtualized list, the keyboard does not go into these rows. There, the keys move through
49
+ * the array of the items, and these rows are not in it.
44
50
  */
45
51
  header?: Snippet;
46
- /** CSS class to apply to the listbox container. */
52
+ /** The CSS class names of the listbox container. */
47
53
  class?: string;
48
- /** HTML id attribute for the listbox element. */
54
+ /** The id of the listbox element. */
49
55
  id?: string;
50
- /** Accessible label for the listbox. Announced by screen readers. */
56
+ /** The accessible name of the listbox. A screen reader announces it. */
51
57
  'aria-label'?: string;
52
- /** Id of a visible element that labels the listbox. Use instead of `aria-label`
53
- * when the list already has a heading on screen. */
58
+ /**
59
+ * The id of an element that the user sees, and that gives the listbox its name. Use it in place
60
+ * of `aria-label` when the list already has a heading.
61
+ */
54
62
  'aria-labelledby'?: string;
55
- /** Callback fired when the selection changes. */
63
+ /** The component calls it when the selection changes. */
56
64
  onChange?: (value: Set<string | number>) => void;
57
- /** Disable DOM focus handling on the root container for virtual-focus compositions. */
65
+ /** Stops the DOM focus control on the root container, for a composition with a virtual focus. */
58
66
  disableFocusHandling?: boolean;
59
- /** Whether arrow-key navigation wraps from the last item to the first (and back). */
67
+ /**
68
+ * At the last item, the arrow keys move the focus to the first item, and at the first item, to
69
+ * the last one.
70
+ */
60
71
  loop?: boolean;
61
- /** Whether typing characters moves focus to the option whose text matches. */
72
+ /** When the user types a character, the focus moves to the option whose text agrees with it. */
62
73
  typeahead?: boolean;
63
74
  /**
64
- * Renders only the rows near the viewport instead of all of them.
75
+ * Makes only the rows near the viewport, and not all of the rows.
65
76
  *
66
- * Only honoured together with `items`: the listbox has to own the loop to be able to
67
- * slice it, so a list written as static children is never virtualized.
77
+ * The component obeys it only with `items`. The listbox must control the loop to cut it, thus a
78
+ * list written as static children is never virtualized.
68
79
  *
69
- * Rows must all be the same height — that assumption is what lets the scrollbar be
70
- * sized without measuring every row. The height is measured from the first rendered
71
- * row unless `rowHeight` says otherwise, so a themed list needs no magic number.
80
+ * All of the rows must have the same height. This is what lets the component calculate the
81
+ * scrollbar without a measurement of each row. The component measures the height from the first
82
+ * row, but `rowHeight` replaces that measurement. Thus a list with your own styles needs no
83
+ * fixed number.
72
84
  *
73
- * The listbox element itself is the scroller: give it a max height and
74
- * `overflow-y: auto`, as an unvirtualized long list would need anyway.
85
+ * The listbox element is the element that scrolls. Give it a maximum height and `overflow-y:
86
+ * auto`. A long list without a virtualizer needs the same.
75
87
  */
76
88
  virtualizer?: {
77
89
  rowHeight?: number;
@@ -30,12 +30,7 @@ renders no markup of its own.
30
30
 
31
31
  ## SSR and hydration
32
32
 
33
- In server-rendered apps an explicit `locale` is effectively **required**. Without it, the
34
- server formats with the Node process locale while the client formats with the visitor's
35
- `navigator.language`; when they differ, the server HTML and the first client render
36
- disagree — date segment order (`dd/MM` vs `MM/dd`), hour cycle (12h vs 24h) and number
37
- formats (decimal/group separators) all shift — which produces hydration mismatches and
38
- visible content flicker.
33
+ In server-rendered apps an explicit `locale` is effectively **required**. Without it, the server uses the locale of the Node process and the client uses `navigator.language`. When the two are different, the HTML of the server and the first render of the client do not agree. The sequence of the date segments changes (`dd/MM` or `MM/dd`), and so do the hour cycle (12h or 24h) and the number format. The result is a hydration error and a flash of different content.
39
34
 
40
35
  Resolve the locale on the server (typically from the `Accept-Language` request header, or
41
36
  the user's saved preference) and pass it explicitly so both passes agree:
@@ -12,8 +12,7 @@ primitives as `Popover`.
12
12
  - Use `Menu.Root` to share open state and the trigger reference.
13
13
  - Use `Menu.Trigger` as the opener button. `ArrowDown`/`Enter`/`Space` open the menu and focus the
14
14
  first item; `ArrowUp` opens and focuses the last item.
15
- - Use `Menu.ContextTrigger` instead of `Menu.Trigger` to open the menu from a surface rather than
16
- a button: right click, long press on touch, or `Shift+F10` / the `ContextMenu` key.
15
+ - Use `Menu.ContextTrigger` in place of `Menu.Trigger` to open the menu from a surface, and not from a button. It opens from a right click, a long press, the `Shift+F10` keys, or the `ContextMenu` key.
17
16
  - Use `Menu.Content` inside `Menu.Root`. It renders the `role="menu"` panel in a portal and
18
17
  positions it against the trigger (default placement `bottom-start`).
19
18
  - Use `Menu.Item` for actions. Provide `onAction`, and optionally `disabled`, `closeOnSelect`, or
@@ -31,9 +30,7 @@ primitives as `Popover`.
31
30
  typed text.
32
31
  - Escape closes the current (topmost) menu and returns focus to its trigger. `Tab` and outside
33
32
  interaction close the whole menu chain. Within a submenu, `ArrowLeft` closes just that level.
34
- - Submenus use a "safe triangle" pointer intent: while the pointer is moving diagonally toward an
35
- open submenu, hovering the sibling items it passes over does not close the submenu for a short
36
- grace period, so the user can reach it without the submenu collapsing mid-path.
33
+ - A submenu uses a safe triangle for the pointer. While the pointer moves at an angle to the open submenu, the items that the pointer goes over do not close it. This continues for a short time. Thus the user gets to the submenu, and the submenu stays open.
37
34
 
38
35
  ## Context menus
39
36
 
@@ -41,14 +38,10 @@ primitives as `Popover`.
41
38
  arbitrary — sometimes interactive — content. It opens the menu three ways, and each anchors the
42
39
  panel differently:
43
40
 
44
- - **Right click** — anchored at the pointer, flush against it (`Menu.Content` drops its default
45
- `offset` to `0` for a context menu), unfolding down and to the right like a native one. Right
41
+ - A right click puts the menu at the pointer, against it. For a context menu, `Menu.Content` makes its default `offset` `0`. The panel opens down and to the right, like a native menu. Right
46
42
  clicking again re-anchors the open menu instead of closing and reopening it.
47
43
  - **Long press** on touch or pen — anchored at the finger. It is what makes the menu reachable at
48
- all on a phone, where `contextmenu` is unreliable. The action suppresses the `click` and
49
- `contextmenu` the platform emits for the same gesture, and the surface sets
50
- `-webkit-touch-callout: none; user-select: none` inline so iOS raises the menu instead of the
51
- text callout. Turn either off with `longPress={false}` / `preventTouchCallout={false}`.
44
+ all on a phone, where `contextmenu` is unreliable. The action stops the `click` event and the `contextmenu` event of the same gesture. The surface also sets `-webkit-touch-callout: none; user-select: none` in its style attribute. Thus iOS shows the menu and not the text callout. Turn either off with `longPress={false}` / `preventTouchCallout={false}`.
52
45
  - **`Shift+F10` or the `ContextMenu` key** — anchored to the surface itself, with the first item
53
46
  focused. There is no pointer involved, so reusing the last cursor position would put the panel
54
47
  somewhere the keyboard user never pointed at.
@@ -57,9 +50,7 @@ A left press anywhere — including on the surface itself — dismisses it, like
57
50
 
58
51
  ### Accessibility
59
52
 
60
- The surface is a tab stop by default (`tabindex={0}`) so a keyboard user can reach it; pass
61
- `tabindex={-1}` when it lives inside a composite that already manages focus with a roving
62
- tabindex, such as a table or a tree.
53
+ By default, the surface is a tab stop (`tabindex={0}`), thus a keyboard user can go to it. Give `tabindex={-1}` when the surface is in a component that already controls the focus with a roving tabindex, for example a table or a tree.
63
54
 
64
55
  It carries `aria-keyshortcuts="Shift+F10"` and nothing else. `aria-haspopup` and `aria-expanded`
65
56
  are **not** global ARIA properties: on a generic element they would be invalid, so the component
@@ -74,7 +65,7 @@ actions elsewhere in the UI.
74
65
  - `onOpenChange(open, details)`
75
66
  - `details.reason`: `trigger-press | imperative-action | none | escape-key | outside-press | focus-out | item-select`
76
67
  - `details.event?`: native event that triggered the change when available
77
- - `details.cancel()`: prevents the open-state transition
68
+ - `details.cancel()`: stops the change of the open state
78
69
  - `details.isCanceled`: reflects cancellation state inside the callback
79
70
 
80
71
  ## Anatomy
@@ -18,23 +18,27 @@
18
18
  * Rendered in a Portal, positioned against the trigger.
19
19
  */
20
20
  type MenuContentProps = {
21
- /** Offset along the main axis from the trigger element. Defaults to `4`, or to `0`
22
- * for a context menu, which sits at the pointer like a native one. */
21
+ /**
22
+ * The distance from the trigger element, on the main axis. The default is `4`. For a context
23
+ * menu it is `0`, because that menu goes at the pointer, like a native one.
24
+ */
23
25
  offset?: number;
24
- /** Placement relative to the trigger element. Defaults to `bottom-start`
25
- * for a root menu and `right-start` for a submenu. */
26
+ /**
27
+ * The position against the trigger element. The default is `bottom-start` for a root menu, and
28
+ * `right-start` for a submenu.
29
+ */
26
30
  placement?: ExtendedPlacement;
27
- /** Whether to flip when there's insufficient space. */
31
+ /** Moves the panel to the opposite side when the space is not sufficient. */
28
32
  shouldFlip?: boolean;
29
- /** Boundary element for positioning constraints. */
33
+ /** The element that gives the limits of the position. */
30
34
  boundaryElement?: Element | null;
31
- /** Whether pressing Escape should close the menu. */
35
+ /** Closes the menu when the user pushes the `Escape` key. */
32
36
  shouldCloseOnEscape?: boolean;
33
- /** Whether interacting outside the menu should close it. */
37
+ /** Closes the menu when the user interacts outside it. */
34
38
  shouldCloseOnInteractOutside?: boolean;
35
- /** Content of the menu. */
39
+ /** The content of the menu. */
36
40
  children?: Snippet;
37
- /** CSS class for the menu container. */
41
+ /** The CSS class names of the menu container. */
38
42
  class?: string;
39
43
  } & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children' | 'role'>;
40
44
 
@@ -6,23 +6,27 @@ import { type ExtendedPlacement } from '../../primitives/floating';
6
6
  * Rendered in a Portal, positioned against the trigger.
7
7
  */
8
8
  type MenuContentProps = {
9
- /** Offset along the main axis from the trigger element. Defaults to `4`, or to `0`
10
- * for a context menu, which sits at the pointer like a native one. */
9
+ /**
10
+ * The distance from the trigger element, on the main axis. The default is `4`. For a context
11
+ * menu it is `0`, because that menu goes at the pointer, like a native one.
12
+ */
11
13
  offset?: number;
12
- /** Placement relative to the trigger element. Defaults to `bottom-start`
13
- * for a root menu and `right-start` for a submenu. */
14
+ /**
15
+ * The position against the trigger element. The default is `bottom-start` for a root menu, and
16
+ * `right-start` for a submenu.
17
+ */
14
18
  placement?: ExtendedPlacement;
15
- /** Whether to flip when there's insufficient space. */
19
+ /** Moves the panel to the opposite side when the space is not sufficient. */
16
20
  shouldFlip?: boolean;
17
- /** Boundary element for positioning constraints. */
21
+ /** The element that gives the limits of the position. */
18
22
  boundaryElement?: Element | null;
19
- /** Whether pressing Escape should close the menu. */
23
+ /** Closes the menu when the user pushes the `Escape` key. */
20
24
  shouldCloseOnEscape?: boolean;
21
- /** Whether interacting outside the menu should close it. */
25
+ /** Closes the menu when the user interacts outside it. */
22
26
  shouldCloseOnInteractOutside?: boolean;
23
- /** Content of the menu. */
27
+ /** The content of the menu. */
24
28
  children?: Snippet;
25
- /** CSS class for the menu container. */
29
+ /** The CSS class names of the menu container. */
26
30
  class?: string;
27
31
  } & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children' | 'role'>;
28
32
  declare const MenuContent: import("svelte").Component<MenuContentProps, {}, "">;
@@ -14,22 +14,21 @@
14
14
  * semantics.
15
15
  */
16
16
  export type MenuContextTriggerProps = {
17
- /** Whether the surface is disabled. The browser's own context menu is left alone. */
17
+ /** Disables the surface. The browser then shows its own context menu. */
18
18
  disabled?: boolean;
19
- /** Whether a long press opens the menu on touch and pen. */
19
+ /** Opens the menu from a long press with a finger or a pen. */
20
20
  longPress?: boolean;
21
- /** How long a touch has to be held, in ms. */
21
+ /** The time of the long press, in ms. */
22
22
  longPressDelay?: number;
23
23
  /**
24
- * Whether to suppress the iOS text callout / selection on the surface. Long press
25
- * is unusable there without it; turn it off if the surface contains text the user
26
- * is meant to select.
24
+ * Stops the iOS text callout and the text selection on the surface. Without it, the long press
25
+ * does not work there. Set it to `false` when the surface has text that the user must select.
27
26
  */
28
27
  preventTouchCallout?: boolean;
29
28
  /**
30
- * Tab order position. Defaults to `0` so keyboard users can reach the surface and
31
- * open the menu with Shift+F10. Pass `-1` when the surface lives inside a composite
32
- * that already manages focus with a roving tabindex (a table, a tree).
29
+ * The position in the tab order. The default is `0`, thus a keyboard user can go to the surface
30
+ * and open the menu with the Shift+F10 keys. Give `-1` when the surface is in a component that
31
+ * already controls the focus with a roving tabindex, for example a table or a tree.
33
32
  */
34
33
  tabindex?: number;
35
34
  children?: Snippet;
@@ -9,22 +9,21 @@ import type { HTMLAttributes } from 'svelte/elements';
9
9
  * semantics.
10
10
  */
11
11
  export type MenuContextTriggerProps = {
12
- /** Whether the surface is disabled. The browser's own context menu is left alone. */
12
+ /** Disables the surface. The browser then shows its own context menu. */
13
13
  disabled?: boolean;
14
- /** Whether a long press opens the menu on touch and pen. */
14
+ /** Opens the menu from a long press with a finger or a pen. */
15
15
  longPress?: boolean;
16
- /** How long a touch has to be held, in ms. */
16
+ /** The time of the long press, in ms. */
17
17
  longPressDelay?: number;
18
18
  /**
19
- * Whether to suppress the iOS text callout / selection on the surface. Long press
20
- * is unusable there without it; turn it off if the surface contains text the user
21
- * is meant to select.
19
+ * Stops the iOS text callout and the text selection on the surface. Without it, the long press
20
+ * does not work there. Set it to `false` when the surface has text that the user must select.
22
21
  */
23
22
  preventTouchCallout?: boolean;
24
23
  /**
25
- * Tab order position. Defaults to `0` so keyboard users can reach the surface and
26
- * open the menu with Shift+F10. Pass `-1` when the surface lives inside a composite
27
- * that already manages focus with a roving tabindex (a table, a tree).
24
+ * The position in the tab order. The default is `0`, thus a keyboard user can go to the surface
25
+ * and open the menu with the Shift+F10 keys. Give `-1` when the surface is in a component that
26
+ * already controls the focus with a roving tabindex, for example a table or a tree.
28
27
  */
29
28
  tabindex?: number;
30
29
  children?: Snippet;
@@ -7,7 +7,7 @@
7
7
  * Menu.GroupLabel - Accessible label for a Menu.Group. Non-interactive.
8
8
  */
9
9
  type MenuGroupLabelProps = {
10
- /** Optional explicit id (auto-generated otherwise). */
10
+ /** The id. If you give none, the component makes one. */
11
11
  id?: string;
12
12
  children?: Snippet;
13
13
  class?: string;
@@ -4,7 +4,7 @@ import type { HTMLAttributes } from 'svelte/elements';
4
4
  * Menu.GroupLabel - Accessible label for a Menu.Group. Non-interactive.
5
5
  */
6
6
  type MenuGroupLabelProps = {
7
- /** Optional explicit id (auto-generated otherwise). */
7
+ /** The id. If you give none, the component makes one. */
8
8
  id?: string;
9
9
  children?: Snippet;
10
10
  class?: string;
@@ -51,21 +51,24 @@
51
51
  * Menu.Item - An interactive menu item (role="menuitem").
52
52
  */
53
53
  type MenuItemProps = {
54
- /** Stable identifier (used for typeahead/navigation). Auto-generated if omitted. */
54
+ /**
55
+ * The stable identifier, for the typeahead and the keyboard. If you give none, the component
56
+ * makes one.
57
+ */
55
58
  value?: string | number;
56
- /** Handler invoked when the item is activated. */
59
+ /** The component calls it when the user activates the item. */
57
60
  onAction?: (event?: Event) => void;
58
- /** Whether the item is disabled. */
61
+ /** Disables the item. */
59
62
  disabled?: boolean;
60
- /** Override the Root `closeOnSelect` default for this item. */
63
+ /** Replaces the `closeOnSelect` value of the Root, for this item. */
61
64
  closeOnSelect?: boolean;
62
- /** Text used for typeahead matching. Falls back to the item's text content. */
65
+ /** The text for the typeahead. Without it, the component uses the text content of the item. */
63
66
  textValue?: string;
64
- /** Item content. */
67
+ /** The content of the item. */
65
68
  children?: Snippet;
66
- /** CSS class for the item. */
69
+ /** The CSS class names of the item. */
67
70
  class?: string;
68
- /** Bindable reference to the item element. */
71
+ /** A bindable reference to the item element. */
69
72
  element?: HTMLElement | null;
70
73
  } & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children' | 'role'>;
71
74
 
@@ -4,21 +4,24 @@ import type { HTMLAttributes } from 'svelte/elements';
4
4
  * Menu.Item - An interactive menu item (role="menuitem").
5
5
  */
6
6
  type MenuItemProps = {
7
- /** Stable identifier (used for typeahead/navigation). Auto-generated if omitted. */
7
+ /**
8
+ * The stable identifier, for the typeahead and the keyboard. If you give none, the component
9
+ * makes one.
10
+ */
8
11
  value?: string | number;
9
- /** Handler invoked when the item is activated. */
12
+ /** The component calls it when the user activates the item. */
10
13
  onAction?: (event?: Event) => void;
11
- /** Whether the item is disabled. */
14
+ /** Disables the item. */
12
15
  disabled?: boolean;
13
- /** Override the Root `closeOnSelect` default for this item. */
16
+ /** Replaces the `closeOnSelect` value of the Root, for this item. */
14
17
  closeOnSelect?: boolean;
15
- /** Text used for typeahead matching. Falls back to the item's text content. */
18
+ /** The text for the typeahead. Without it, the component uses the text content of the item. */
16
19
  textValue?: string;
17
- /** Item content. */
20
+ /** The content of the item. */
18
21
  children?: Snippet;
19
- /** CSS class for the item. */
22
+ /** The CSS class names of the item. */
20
23
  class?: string;
21
- /** Bindable reference to the item element. */
24
+ /** A bindable reference to the item element. */
22
25
  element?: HTMLElement | null;
23
26
  } & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children' | 'role'>;
24
27
  declare const MenuItem: import("svelte").Component<MenuItemProps, {}, "element">;
@@ -15,7 +15,7 @@
15
15
  * a nested overlay would just stack a second dim layer, so callers place it at the root level.
16
16
  */
17
17
  type MenuOverlayProps = {
18
- /** CSS class for the overlay. */
18
+ /** The CSS class names of the overlay. */
19
19
  class?: string;
20
20
  } & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
21
21
 
@@ -9,7 +9,7 @@ import type { HTMLAttributes } from 'svelte/elements';
9
9
  * a nested overlay would just stack a second dim layer, so callers place it at the root level.
10
10
  */
11
11
  type MenuOverlayProps = {
12
- /** CSS class for the overlay. */
12
+ /** The CSS class names of the overlay. */
13
13
  class?: string;
14
14
  } & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
15
15
  declare const MenuOverlay: import("svelte").Component<MenuOverlayProps, {}, "">;
@@ -32,9 +32,9 @@ export type MenuItemData = {
32
32
  textValue?: string;
33
33
  /** The item's DOM element. */
34
34
  element?: HTMLElement;
35
- /** Whether the item is disabled. */
35
+ /** Disables the item. */
36
36
  disabled?: boolean;
37
- /** Handler invoked when the item is activated. */
37
+ /** The component calls it when the user activates the item. */
38
38
  onSelect?: (event?: Event) => void;
39
39
  /** Per-item override for the Root `closeOnSelect` default. */
40
40
  closeOnSelect?: boolean;
@@ -61,7 +61,10 @@ export type MenuContext = {
61
61
  anchorPoint: MenuAnchorPoint | null;
62
62
  /** Whether this menu is opened as a context menu (right click / long press). */
63
63
  isContextMenu: boolean;
64
- /** Whether arrow navigation wraps around the ends. */
64
+ /**
65
+ * At the last item, the arrow keys move the focus to the first item, and at the first item, to
66
+ * the last one.
67
+ */
65
68
  loop: boolean;
66
69
  /** Whether typeahead is enabled. */
67
70
  typeahead: boolean;