@human-kit/ui 1.0.0-beta.4 → 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 (209) 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 +6 -0
  186. package/dist/toggle-group/root/context.svelte.d.ts +1 -1
  187. package/dist/toggle-group/root/context.svelte.js +20 -11
  188. package/dist/toggle-group/root/toggle-group-root.svelte +20 -15
  189. package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte +13 -0
  190. package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte.d.ts +7 -0
  191. package/dist/toggle-group/types.d.ts +9 -9
  192. package/dist/transfer-list/README.md +6 -17
  193. package/dist/transfer-list/item/transfer-list-item.svelte +4 -4
  194. package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +4 -4
  195. package/dist/transfer-list/list/transfer-list-list.svelte +12 -12
  196. package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +12 -12
  197. package/dist/transfer-list/move/transfer-list-move-button.svelte +4 -4
  198. package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +4 -4
  199. package/dist/transfer-list/move/transfer-list-reorder-button.svelte +3 -3
  200. package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +3 -3
  201. package/dist/transfer-list/root/transfer-list-root.svelte +23 -20
  202. package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +23 -20
  203. package/dist/transfer-list/status/transfer-list-status.svelte +1 -1
  204. package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +1 -1
  205. package/dist/tree/README.md +3 -3
  206. package/dist/tree/checkbox-indicator/README.md +1 -1
  207. package/dist/tree/root/README.md +1 -1
  208. package/dist/tree/types.d.ts +19 -10
  209. package/package.json +1 -1
@@ -1,42 +1,47 @@
1
1
  import { type Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  type SwitchRootProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class' | 'id' | 'role' | 'aria-checked' | 'aria-disabled' | 'aria-readonly' | 'aria-required' | 'onclick' | 'onkeydown' | 'value'> & {
4
- /** Id applied to the hidden input so `label[for]` can target the switch. Auto-generated when omitted. */
4
+ /**
5
+ * The id of the hidden input, thus a `label[for]` element can point at the switch. If you give
6
+ * none, the component makes one.
7
+ */
5
8
  id?: string;
6
- /** Bindable reference to the rendered root element. */
9
+ /** A bindable reference to the root element. */
7
10
  element?: HTMLSpanElement | null;
8
- /** Name submitted with the form when the switch is checked. */
11
+ /** The name that the form submits while the switch is on. */
9
12
  name?: string;
10
- /** Value submitted with the form when the switch is checked. Does not affect the visual state. */
13
+ /**
14
+ * The value that the form submits while the switch is on. It does not change the visual state.
15
+ */
11
16
  value?: string;
12
- /** Associates the hidden input with a form by id. */
17
+ /** The id of the form of the hidden input. */
13
18
  form?: string;
14
- /** Checked state. Two-way by default — use `bind:checked`. */
19
+ /** The checked state. By default it goes in the two directions: use `bind:checked`. */
15
20
  checked?: boolean;
16
- /** Initial checked state, for when `checked` is not supplied. */
21
+ /** The checked state at the start, for when you give no `checked`. */
17
22
  defaultChecked?: boolean;
18
23
  /**
19
- * Opt into fully controlled state: the component stops writing back to `checked`
20
- * and only reports through `onCheckedChange`, so the parent can reject a change by
21
- * not flowing the new value back down. Off by default, because `bind:checked` —
22
- * the common case — needs the write-back to work at all.
24
+ * Give your own code full control of the state. The component stops to write back to `checked`,
25
+ * and it reports only through `onCheckedChange`. Thus the parent can refuse a change: the parent
26
+ * does not send the new value down. The default is off, because `bind:checked` is the usual case
27
+ * and it needs the write-back.
23
28
  */
24
29
  controlledChecked?: boolean;
25
- /** Called when the user toggles the switch. */
30
+ /** The component calls it when the user changes the switch. */
26
31
  onCheckedChange?: (checked: boolean) => void;
27
- /** Removes the switch from interaction and focus order. */
32
+ /** Stops the interaction with the switch and removes it from the focus order. */
28
33
  disabled?: boolean;
29
- /** Keeps the switch focusable while preventing state changes. */
34
+ /** Keeps the switch focusable, but stops the changes of the state. */
30
35
  readonly?: boolean;
31
- /** Marks the hidden input as required for form validation. */
36
+ /** Makes the hidden input required for the form validation. */
32
37
  required?: boolean;
33
38
  children?: Snippet;
34
39
  class?: string;
35
- /** Accessible label when no visible label is associated. */
40
+ /** The accessible name, for when the user sees no name. */
36
41
  'aria-label'?: string;
37
- /** Id of the element that labels the switch. */
42
+ /** The id of the element that gives the switch its name. */
38
43
  'aria-labelledby'?: string;
39
- /** Overrides the default tab order. */
44
+ /** Replaces the default position in the tab order. */
40
45
  tabindex?: number;
41
46
  onclick?: HTMLAttributes<HTMLSpanElement>['onclick'];
42
47
  onkeydown?: HTMLAttributes<HTMLSpanElement>['onkeydown'];
@@ -4,7 +4,7 @@
4
4
  import { useSwitchContext } from '../root/context';
5
5
 
6
6
  type SwitchThumbProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
7
- /** Optional content rendered inside the thumb. */
7
+ /** The content of the thumb. */
8
8
  children?: Snippet;
9
9
  class?: string;
10
10
  };
@@ -1,7 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  type SwitchThumbProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
4
- /** Optional content rendered inside the thumb. */
4
+ /** The content of the thumb. */
5
5
  children?: Snippet;
6
6
  class?: string;
7
7
  };
@@ -6,7 +6,12 @@
6
6
 
7
7
  `Table` is a headless interactive table primitive with grid-style keyboard navigation, row selection, explicit sortable header triggers, and a composable part-based API.
8
8
 
9
- All public Table part prop types are exported from the table barrel, including `TableRootProps`, `TableColumnProps`, `TableHeaderProps`, `TableBodyProps`, `TableFooterProps`, `TableRowProps`, `TableColumnHeaderCellProps`, `TableSortTriggerProps`, `TableColumnResizerProps`, `TableCellProps`, `TableEmptyStateProps`, `TableCheckboxProps`, and `TableCheckboxIndicatorProps`.
9
+ The table barrel exports the prop types of each public Table part.
10
+
11
+ These are `TableRootProps`, `TableColumnProps`, `TableHeaderProps`, `TableBodyProps`,
12
+ `TableFooterProps`, `TableRowProps`, `TableColumnHeaderCellProps`, `TableSortTriggerProps`,
13
+ `TableColumnResizerProps`, `TableCellProps`, `TableEmptyStateProps`, `TableCheckboxProps`,
14
+ and `TableCheckboxIndicatorProps`.
10
15
 
11
16
  ## Anatomy
12
17
 
@@ -88,8 +93,8 @@ All public Table part prop types are exported from the table barrel, including `
88
93
  ## Usage guidelines
89
94
 
90
95
  - Use `Table.Root` as the stateful container for focus, selection, and sorting state.
91
- - Use `keyboardNavigation` to choose how far the roving tab stop reaches into the body: `'grid'` (default) makes every body cell a focus target, `'row'` makes the row the only one, and `'none'` leaves the body inert. Cell navigation costs a focus registration plus focus-derived state per cell, which a virtualized table pays again on every row it mounts; drop to `'row'` when the body is a list rather than a working surface, and to `'none'` only when nothing in it is actionable. The header keeps its own navigation in every mode.
92
- - Use `selectionBehavior="toggle"` to allow deselecting an already selected row, or `selectionBehavior="replace"` to keep selected rows selected when pressed again.
96
+ - Use `keyboardNavigation` to choose how far the roving tab stop reaches into the body: `'grid'` (default) makes every body cell a focus target, `'row'` makes the row the only one, and `'none'` leaves the body inert. The cell navigation has a cost: one focus registration and one focus state for each cell. A virtualized table does this again for each row that it makes. Use `'row'` when the body is a list, and not a surface where the user works. Use `'none'` only when nothing in the body does an action. The header keeps its own navigation in every mode.
97
+ - Use `selectionBehavior="toggle"` to let the user remove the selection of a selected row. Use `selectionBehavior="replace"` to keep a selected row selected when the user presses it again.
93
98
  - `Table.Column` is a logical-only wrapper for column metadata; it does not render DOM by itself and should wrap a single `Table.ColumnHeaderCell`.
94
99
  - Wrap each header cell in `Table.Column` so the table can register stable column metadata.
95
100
  - Add `Table.ColumnResizer` inside `Table.ColumnHeaderCell` to make the owning `Table.Column` resizable.
@@ -102,16 +107,16 @@ All public Table part prop types are exported from the table barrel, including `
102
107
  - Use `defaultHiddenColumns` for uncontrolled initial column visibility.
103
108
  - Use `columnWidths` / `onColumnWidthsChange` for controlled column width state. Width specs can be px, `%`, or `fr`.
104
109
  - Use `defaultColumnWidths` and `Table.Column.defaultWidth` to seed uncontrolled initial widths that can still be resized by the user.
105
- - Use `Table.Column.width` when a column should stay fixed at an explicit width. Fixed-width columns ignore resize attempts even if a `Table.ColumnResizer` is composed.
106
- - In resizable tables, unspecified columns behave like an implicit `1fr` width before interaction. On the first real resize, visible columns are materialized to px; the trailing column absorbs the delta until its minimum width, and further growth overflows the table horizontally.
110
+ - Use `Table.Column.width` when a column must keep an exact width. A column with a fixed width does not change its width, also with a `Table.ColumnResizer` in it.
111
+ - In resizable tables, unspecified columns behave like an implicit `1fr` width before interaction. At the first width change, the component sets each visible column in px. The last column takes the difference, down to its minimum width. After that, the table becomes wider than its container.
107
112
  - Setting `sortDescriptor` back to `undefined` clears the controlled sort state, matching React Aria Table semantics.
108
113
  - Set `Table.Column.textValue` when the spoken column label should differ from the column id; `Table.Root` uses it for polite sort announcements.
109
114
  - Use `Table.EmptyState` inside `Table.Body` instead of conditionally rendering freeform body content.
110
115
  - Use `Table.Checkbox` when you need explicit selection UI inside cells instead of relying only on row or cell presses.
111
- - Use `Table.CheckboxIndicator` to compose your own visual affordance for checked and indeterminate states.
112
- - Use `Table.InteractiveCell` for body cells that contain their own focusable controls. When focus is on the cell itself it keeps the same grid keyboard navigation as `Table.Cell`; when focus is inside a descendant control, the descendant owns its keyboard and pointer interactions.
116
+ - Use `Table.CheckboxIndicator` to make your own marks for the checked state and the indeterminate state.
117
+ - Use `Table.InteractiveCell` for a body cell that has its own controls. While the focus is on the cell, the grid keyboard operation is the same as in `Table.Cell`. While the focus is on a control in the cell, that control gets the keys and the pointer.
113
118
  - `Table.Checkbox` auto-hides in header cells unless `selectionMode="multiple"`, and auto-hides everywhere when `selectionMode="none"`.
114
- - Hidden columns are excluded from grid navigation, visible column counts, and active resize behavior, but their registered widths are preserved so they can be restored when shown again.
119
+ - A hidden column is not in the grid navigation, not in the column count, and not in the width changes. It keeps its width, thus you can show it again with that width.
115
120
  - Dedicated utility columns like selection checkboxes should usually set an explicit `width`, `minWidth`, and `maxWidth` on `Table.Column` so sibling resizes do not redistribute their space.
116
121
  - When `selectionMode` changes to `none`, the component clears any existing row selection internally.
117
122
  - v1 leaves text selection and `Ctrl+C` behavior browser-native; the table does not implement custom copy handling or force a text-selection policy.
@@ -134,10 +139,10 @@ All public Table part prop types are exported from the table barrel, including `
134
139
  - `Table.Root` renders an interactive `grid` over native table markup.
135
140
  - Keyboard navigation uses roving `tabindex` across header and body cells.
136
141
  - Under `keyboardNavigation="row"` the body's roving tab stop sits on the rows: arrows walk rows, `Enter` presses one and `Space` toggles its selection. Focusable content inside body cells becomes a regular tab stop instead, since no roving focus reaches it there.
137
- - Body rows can also become the active focus target when horizontal navigation moves past the start or end of a row, and repeated left/right navigation loops back into the opposite edge cell.
142
+ - A body row can also take the focus when the horizontal navigation goes past the start or the end of the row. If the user continues to push the left key or the right key, the focus goes to the cell at the opposite edge.
138
143
  - `Table.Checkbox` can receive DOM focus directly while still participating in the table's roving-focus grid.
139
144
  - First-column body cells become `rowheader` when their associated column has `rowHeader`.
140
145
  - Disabled rows remain rendered and non-selectable, but are skipped by focus navigation.
141
146
  - `Table.SortTrigger` renders the trigger button, while the header cell remains the roving-focus target for arrow-key grid navigation.
142
147
  - Sort changes are mirrored into a polite live region so screen readers announce direction changes more reliably than `aria-sort` alone.
143
- - Column resize handles are keyboard accessible separators. Press `Enter` to enter resize mode, use the horizontal arrow keys to resize, `Home` to jump to the minimum width, `End` to auto-fit to content width, and press `Enter` again to exit resize mode while keeping focus on the handle.
148
+ - Column resize handles are keyboard accessible separators. Push `Enter` to start the resize mode. Use the horizontal arrow keys to change the width. Push `Home` for the minimum width, and `End` for the width of the content. Push `Enter` again to leave the resize mode. The focus stays on the handle.
@@ -13,7 +13,7 @@ Public prop type: `TableCheckboxIndicatorProps`
13
13
  | -------------- | --------------------------------- | ----------- | ------------------------------------------------------------------------------- |
14
14
  | `forceMount` | `boolean` | `false` | Keeps the indicator mounted while hidden when the checkbox is unchecked. |
15
15
  | `children` | `Snippet` | `undefined` | Rendered indicator content, such as a check icon or dash icon. |
16
- | `class` | `string` | `''` | CSS class names for the indicator wrapper. |
16
+ | `class` | `string` | `''` | The CSS class names of the indicator container. |
17
17
  | `...restProps` | `HTMLAttributes<HTMLSpanElement>` | `-` | Additional native attributes forwarded to the composed checkbox indicator span. |
18
18
 
19
19
  ## Usage notes
@@ -7,7 +7,7 @@
7
7
  ### Table.ColumnResizer
8
8
 
9
9
  Name: `Table.ColumnResizer`
10
- Description: Interactive resize handle for the current `Table.Column`. It must be composed inside `Table.ColumnHeaderCell`, and it resizes the column that owns the surrounding `Table.Column` context.
10
+ Description: The handle that changes the width of the current `Table.Column`. Put it in a `Table.ColumnHeaderCell`. It changes the width of the column of the `Table.Column` context around it.
11
11
 
12
12
  Public prop type: `TableColumnResizerProps`
13
13
 
@@ -25,7 +25,7 @@ Public prop type: `TableColumnResizerProps`
25
25
  - The handle resolves the active column from `Table.Column` context. It does not accept a separate `columnId` prop.
26
26
  - Width state lives in `Table.Root` through `columnWidths` / `defaultColumnWidths`.
27
27
  - Pointer resizing uses Pointer Events, so mouse, touch, and pen interactions share the same behavior.
28
- - Keyboard resizing uses an explicit resize mode: focus the handle, press `Enter` to capture resize, use `ArrowLeft` / `ArrowRight` (plus `Shift`) to adjust the width, `Home` to jump to the minimum width, and `End` to auto-fit the column to its content width, then press `Enter` again to commit the width and keep focus on the handle.
28
+ - The keyboard changes the width in a resize mode. Move the focus to the handle and push `Enter` to start that mode. Use the `ArrowLeft` key and the `ArrowRight` key, with `Shift` for a larger step, to change the width. Push `Home` for the minimum width, and `End` for the width of the content. Push `Enter` again to keep the width. The focus stays on the handle.
29
29
  - While keyboard resize mode is active, pressing `Escape` restores the starting width, exits resize mode, and returns focus to the owning header cell.
30
30
  - Keyboard resizing uses the same resize lifecycle callbacks as pointer resizing and announces committed widths through a polite live region.
31
31
  - During pointer drag, pressing `Escape` restores the starting width and cancels the resize interaction.
@@ -37,7 +37,7 @@ Public prop type: `TableRootProps`
37
37
  | `aria-labelledby` | `string` | `undefined` | Id reference for an external label. |
38
38
  | `class` | `string` | `''` | Class names for the root table element. |
39
39
  | `context` | `TableContext` | `undefined` | Bindable reference to the active internal table context instance. |
40
- | `element` | `HTMLTableElement` | `undefined` | Bindable reference to the rendered table element. |
40
+ | `element` | `HTMLTableElement` | `undefined` | A bindable reference to the table element. |
41
41
  | `children` | `Snippet` | `undefined` | Composed table parts. |
42
42
 
43
43
  ### Behavior notes
@@ -13,7 +13,7 @@ Public prop type: `TableSortTriggerProps`
13
13
 
14
14
  | Prop | Type | Default | Description |
15
15
  | -------------- | --------------------------------------------------- | ----------- | --------------------------------------------------------------------------------- |
16
- | `children` | `Snippet<[TableSortTriggerRenderState]> \| Snippet` | `undefined` | Button content. The snippet receives the current `sortDirection`. |
16
+ | `children` | `Snippet<[TableSortTriggerRenderState]> \| Snippet` | `undefined` | The content of the button. The snippet receives the current `sortDirection`. |
17
17
  | `class` | `string` | `''` | CSS class names for the button. |
18
18
  | `...restProps` | `HTMLButtonAttributes` | `-` | Additional native button attributes, excluding reserved trigger button semantics. |
19
19
 
@@ -11,10 +11,10 @@ export type TableColumnProps = {
11
11
  minWidth?: number;
12
12
  maxWidth?: number;
13
13
  /**
14
- * Freezes the column against the horizontal scroll edge: `'left'` sticks it to
15
- * the start, `'right'` to the end. Multiple columns can pin to the same side —
16
- * they stack in document order and the table computes each one's offset from
17
- * the resolved widths of the columns already pinned ahead of it.
14
+ * Keeps the column at an edge of the horizontal scroll: `'left'` at the start, and `'right'` at
15
+ * the end. More than one column can go to the same side. They go in the sequence of the document.
16
+ * The table calculates the position of each one from the widths of the columns already at that
17
+ * side.
18
18
  */
19
19
  pin?: TableColumnPin;
20
20
  children?: Snippet;
@@ -90,14 +90,16 @@ export type TableFooterProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'ch
90
90
  export type TableRootProps = Omit<HTMLAttributes<HTMLTableElement>, 'children'> & {
91
91
  selectionMode?: TableSelectionMode;
92
92
  /**
93
- * How far the roving tab stop reaches into the body, defaulting to `'grid'`.
93
+ * How far the roving tab stop goes into the body. The default is `'grid'`.
94
94
  *
95
- * Cell navigation is not free: every body cell registers itself and derives
96
- * its own focus state, and a virtualized table pays that again on every
97
- * scroll block. `'row'` keeps the body keyboard-reachable at one focus
98
- * target per row; `'none'` drops body focus altogether and should only be
99
- * used when nothing in the body is actionable. The header keeps its own
100
- * navigation — and with it sorting and resizing — in every mode.
95
+ * The cell navigation has a cost. Each body cell registers itself and calculates its own focus
96
+ * state. A virtualized table does this again for each block of rows that it makes while the user
97
+ * scrolls.
98
+ *
99
+ * With `'row'`, the keyboard still reaches the body, at one focus target for each row. With
100
+ * `'none'`, the body takes no focus. Use `'none'` only when nothing in the body does an action.
101
+ * In each mode, the header keeps its own navigation, and with it the sort control and the width
102
+ * control.
101
103
  */
102
104
  keyboardNavigation?: TableKeyboardNavigation;
103
105
  selectionBehavior?: TableSelectionBehavior;
@@ -112,16 +114,15 @@ export type TableRootProps = Omit<HTMLAttributes<HTMLTableElement>, 'children'>
112
114
  columnWidths?: Map<string, TableColumnWidth>;
113
115
  defaultColumnWidths?: Iterable<readonly [string, TableColumnWidth]>;
114
116
  /**
115
- * Width (in px) the table reserves through `min-width` during server
116
- * rendering, before its columns have registered their own widths.
117
+ * The width that the table keeps with `min-width` on the server, in px, before the columns
118
+ * register their own widths.
119
+ *
120
+ * On the server, the `<table>` element goes to the output before the column children register.
121
+ * Thus the table does not know its own minimum width, and it takes the width of its container. At
122
+ * the hydration, the column widths can make the table wider, and the layout moves.
117
123
  *
118
- * On the server the `<table>` element is serialized before the column
119
- * children run their registration, so the table cannot know its own
120
- * minimum width yet and renders at the container width. On hydration the
121
- * resolved column widths can push the table wider, producing a layout
122
- * shift. Set this to the sum of the columns' resolved widths to reserve
123
- * that space up-front and avoid the jump. Ignored once the real columns
124
- * register on the client.
124
+ * Set this prop to the sum of the column widths to keep that space from the start. On the client,
125
+ * the component ignores it after the columns register.
125
126
  */
126
127
  ssrMinTableWidth?: number;
127
128
  disabledKeys?: Iterable<TableSelectionKey>;
@@ -6,15 +6,15 @@ export type TabsRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'c
6
6
  keyboardActivation?: TabsKeyboardActivation;
7
7
  orientation?: TabsOrientation;
8
8
  disabled?: boolean;
9
- /** Selected tab value. Two-way by default — use `bind:value`. */
9
+ /** The value of the selected tab. By default it goes in the two directions: use `bind:value`. */
10
10
  value?: TabsValue | null;
11
- /** Initially selected value, for when `value` is not supplied. */
11
+ /** The selected value at the start, for when you give no `value`. */
12
12
  defaultValue?: TabsValue | null;
13
13
  /**
14
- * Opt into fully controlled state: the component stops writing back to `value` and
15
- * only reports through `onChange`, so the parent can reject a change by not flowing
16
- * the new value back down. Off by default, because `bind:value` — the common case —
17
- * needs the write-back to work at all.
14
+ * Give your own code full control of the state. The component stops to write back to `value`, and
15
+ * it reports only through `onChange`. Thus the parent can refuse a change: the parent does not
16
+ * send the new value down. The default is off, because `bind:value` is the usual case and it
17
+ * needs the write-back.
18
18
  */
19
19
  controlledValue?: boolean;
20
20
  disabledKeys?: Iterable<TabsValue>;
@@ -63,7 +63,8 @@
63
63
  - `defaultOpen?: boolean`
64
64
  - `onOpenChange?: (open: boolean, details: { reason, event?, cancel(), isCanceled }) => void`
65
65
  - Null-first empty contract: when `value` and `defaultValue` are omitted, the empty state is `null`.
66
- - `TimePicker.Input` exposes `aria-invalid` and `data-invalid` when the current segment draft is not committeable.
66
+ - `TimePicker.Input` exposes `aria-invalid` and `data-invalid` when the current segment draft is not committeable, or when the consumer passes `aria-invalid`.
67
+ - `TimePicker.Input` accepts `id` and `name`. Either one renders a hidden but focusable proxy input that carries them. Thus a `<label for>` reaches the segments, and a native form submit reads the committed value. The group keeps `${id}-group`. Autofill is not supported on the proxy (`autocomplete="off"`).
67
68
 
68
69
  ## Popover API
69
70
 
@@ -83,7 +84,7 @@
83
84
 
84
85
  - `TimePicker.Clock` resolves visible wheel columns from root state (`granularity`, `hourCycle`) in stable order: `hour → minute? → second? → dayPeriod?`.
85
86
  - `class?: string` uses default layout (`flex gap-2`) when omitted.
86
- - `column?: Snippet<[ClockColumnInfo]>` allows custom per-column rendering.
87
+ - `column?: Snippet<[ClockColumnInfo]>` lets you make your own content for each column.
87
88
  - `ClockColumnInfo` shape:
88
89
  - `type: 'hour' | 'minute' | 'second' | 'dayPeriod'`
89
90
  - `label?: string`
@@ -11,5 +11,5 @@ Description: Group wrapper for rendered time segments; manages focus entry and s
11
11
  | -------------- | ---------------------------------- | ----------- | ----------------------------------------------------- |
12
12
  | `children` | `Snippet<[TimePickerSegmentPart]>` | `undefined` | Optional custom renderer for each segment part. |
13
13
  | `class` | `string` | `''` | CSS class names for the group element. |
14
- | `aria-label` | `string` | `undefined` | Accessible label for the input group. |
14
+ | `aria-label` | `string` | `undefined` | The accessible name of the input. group. |
15
15
  | `...restProps` | `HTMLAttributes<HTMLDivElement>` | `-` | Additional attributes forwarded to the group element. |
@@ -12,17 +12,29 @@
12
12
 
13
13
  type TimePickerInputProps = Omit<
14
14
  HTMLAttributes<HTMLDivElement>,
15
- 'children' | 'class' | 'id' | 'role' | 'tabindex'
15
+ 'children' | 'class' | 'id' | 'role' | 'tabindex' | 'aria-invalid'
16
16
  > & {
17
+ id?: string;
18
+ /**
19
+ * Name of the hidden proxy input used for form submission. The proxy only
20
+ * mirrors the committed value: autofill is NOT supported (it renders with
21
+ * `autocomplete="off"` so browsers and password managers do not write
22
+ * into it) — times are entered through the editable segments.
23
+ */
24
+ name?: string;
17
25
  children?: Snippet<[TimePickerSegmentPart]>;
18
26
  class?: string;
19
27
  'aria-label'?: string;
28
+ 'aria-invalid'?: HTMLAttributes<HTMLDivElement>['aria-invalid'];
20
29
  };
21
30
 
22
31
  let {
32
+ id,
33
+ name,
23
34
  children,
24
35
  class: className = '',
25
36
  'aria-label': ariaLabel,
37
+ 'aria-invalid': ariaInvalid,
26
38
  onmousedown: onMouseDownExternal,
27
39
  onfocus: onFocusExternal,
28
40
  onblur: onBlurExternal,
@@ -32,7 +44,28 @@
32
44
 
33
45
  const timePicker = useTimePickerContext();
34
46
  const segments = $derived(timePicker.getSegments());
35
- const inputId = $derived(`${timePicker.id}-input`);
47
+ // With an `id` the group keeps a derived one: the id itself belongs to the proxy input, so
48
+ // a `<label for>` points at something focusable. Mirrors `DatePicker.Input`.
49
+ const groupId = $derived(id ? `${id}-group` : `${timePicker.id}-input`);
50
+ const proxyValue = $derived(timePicker.value ?? '');
51
+ // Invalid is either half: the consumer's (a form rule) or an uncommittable segment draft.
52
+ const isInvalid = $derived(
53
+ ariaInvalid === true || ariaInvalid === 'true' || timePicker.isInvalidDraft
54
+ );
55
+ const shouldRenderProxyInput = $derived(Boolean(id || name));
56
+ const proxyInputStyle =
57
+ 'position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;';
58
+
59
+ function handleProxyFocus(event: FocusEvent) {
60
+ if (timePicker.isDisabled) {
61
+ (event.currentTarget as HTMLElement | null)?.blur();
62
+ timePicker.syncFocusWithin();
63
+ timePicker.setFocusVisible(false);
64
+ return;
65
+ }
66
+ timePicker.setFocusVisible(shouldShowFocusVisible(event.currentTarget as HTMLElement));
67
+ timePicker.focusNextPlaceholderOrLastSegment();
68
+ }
36
69
 
37
70
  function handleMouseDown(event: MouseEvent) {
38
71
  if (timePicker.isDisabled) return;
@@ -83,15 +116,35 @@
83
116
  }
84
117
  </script>
85
118
 
119
+ {#if shouldRenderProxyInput}
120
+ <!--
121
+ A focusable stand-in for the segmented group: it carries the `id` a `<label for>` points
122
+ at and the `name` a native form submit reads, and hands focus straight to the segments.
123
+ -->
124
+ <input
125
+ {id}
126
+ {name}
127
+ value={proxyValue}
128
+ readonly
129
+ tabindex="-1"
130
+ autocomplete="off"
131
+ disabled={timePicker.isDisabled || undefined}
132
+ aria-hidden="true"
133
+ aria-invalid={ariaInvalid}
134
+ style={proxyInputStyle}
135
+ onfocus={handleProxyFocus}
136
+ />
137
+ {/if}
138
+
86
139
  <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
87
140
  <!-- svelte-ignore a11y_role_supports_aria_props -->
88
141
  <div
89
- id={inputId}
142
+ id={groupId}
90
143
  class={className}
91
144
  {...restProps}
92
145
  role="group"
93
146
  aria-label={ariaLabel}
94
- aria-invalid={timePicker.isInvalidDraft || undefined}
147
+ aria-invalid={isInvalid || undefined}
95
148
  aria-required={timePicker.isRequired || undefined}
96
149
  tabindex={timePicker.isDisabled || timePicker.focusWithin ? -1 : 0}
97
150
  data-disabled={timePicker.isDisabled || undefined}
@@ -99,7 +152,7 @@
99
152
  data-open={timePicker.open || undefined}
100
153
  data-focus-visible={timePicker.focusVisible || undefined}
101
154
  data-focus-within={timePicker.focusWithin || undefined}
102
- data-invalid={timePicker.isInvalidDraft || undefined}
155
+ data-invalid={isInvalid || undefined}
103
156
  onmousedown={composeEventHandlers(handleMouseDown, onMouseDownExternal ?? undefined)}
104
157
  onfocus={composeEventHandlers(handleFocus, onFocusExternal ?? undefined)}
105
158
  onblur={composeEventHandlers(handleBlur, onBlurExternal ?? undefined)}
@@ -1,10 +1,19 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type TimePickerSegmentPart } from '../root/context';
4
- type TimePickerInputProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id' | 'role' | 'tabindex'> & {
4
+ type TimePickerInputProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id' | 'role' | 'tabindex' | 'aria-invalid'> & {
5
+ id?: string;
6
+ /**
7
+ * Name of the hidden proxy input used for form submission. The proxy only
8
+ * mirrors the committed value: autofill is NOT supported (it renders with
9
+ * `autocomplete="off"` so browsers and password managers do not write
10
+ * into it) — times are entered through the editable segments.
11
+ */
12
+ name?: string;
5
13
  children?: Snippet<[TimePickerSegmentPart]>;
6
14
  class?: string;
7
15
  'aria-label'?: string;
16
+ 'aria-invalid'?: HTMLAttributes<HTMLDivElement>['aria-invalid'];
8
17
  };
9
18
  declare const TimePickerInput: import("svelte").Component<TimePickerInputProps, {}, "">;
10
19
  type TimePickerInput = ReturnType<typeof TimePickerInput>;
@@ -26,7 +26,7 @@ Description: State container for segmented time input, popover lifecycle, wheel
26
26
  | `readonly` | `boolean` | `false` | Prevents value changes while keeping focus/navigation. |
27
27
  | `required` | `boolean` | `false` | Propagates required state to input accessibility attributes. |
28
28
  | `children` | `Snippet` | `undefined` | Composed `TimePicker` parts. |
29
- | `class` | `string` | `''` | CSS class names for the root element. |
29
+ | `class` | `string` | `''` | The CSS class names of the root element. |
30
30
  | `element` | `HTMLDivElement \| null` | `bindable` | Reference to the root DOM element. |
31
31
  | `aria-label` | `string` | `undefined` | Accessible label for the root wrapper. |
32
32
 
@@ -10,5 +10,5 @@ Description: Button part that toggles `TimePicker.Popover` and synchronizes focu
10
10
  | Prop | Type | Default | Description |
11
11
  | -------------- | ---------------------- | ----------- | ------------------------------------------------------ |
12
12
  | `children` | `Snippet` | `undefined` | Optional trigger content. |
13
- | `class` | `string` | `''` | CSS class names for the trigger button. |
13
+ | `class` | `string` | `''` | The CSS class names of the trigger button. |
14
14
  | `...restProps` | `HTMLButtonAttributes` | `-` | Additional button attributes forwarded to the trigger. |
@@ -36,7 +36,7 @@
36
36
  ## Accessibility
37
37
 
38
38
  - `Toggle.Root` renders a native `<button type="button">`.
39
- - The selected state is exposed to assistive technology with `aria-pressed="true" | "false"`.
39
+ - The component gives the selected state to assistive technology with `aria-pressed="true" | "false"`.
40
40
  - Native keyboard activation is supported with `Enter` and `Space`.
41
41
  - `data-focus-visible` follows the shared modality contract and is only exposed for keyboard or virtual focus.
42
42
 
@@ -19,6 +19,10 @@
19
19
  ## Usage guidelines
20
20
 
21
21
  - Use `value` / `defaultValue` arrays for both single and multiple selection.
22
+ - Use `bind:value` to hand the group your state, or plain `value` + `onChange` to own it
23
+ yourself. There is no flag to declare which: supplying `value` makes it the source of
24
+ truth either way, and `onChange` always reports.
25
+ - A parent that holds `value` and refuses a change — it sends no new value down — still sees the group move. The group then goes back to the value of the parent at the next render. Refuse a change with a render, and not with silence.
22
26
  - Use `selectionMode="single"` when only one toggle can be selected.
23
27
  - Use `selectionMode="multiple"` when several toggles can be selected.
24
28
  - Use `disallowEmptySelection` when at least one enabled toggle must remain selected.
@@ -48,4 +52,6 @@
48
52
  ## Notes
49
53
 
50
54
  - Grouped toggles ignore their standalone `selected` and `defaultSelected` props.
55
+ - Removing one `Toggle.Root` from a mounted group is a real selection change: with
56
+ `disallowEmptySelection` the group picks a fallback and fires `onChange`. The removal of the full group is not a change, and it reports nothing. Without this rule, a move to a different screen would look like a press on the last toggle.
51
57
  - Form serialization is out of scope for this primitive.
@@ -3,7 +3,6 @@ export type ToggleGroupSelectionMode = 'single' | 'multiple';
3
3
  export type ToggleGroupOrientation = 'horizontal' | 'vertical';
4
4
  export type CreateToggleGroupContextOptions = {
5
5
  initialValue?: ToggleGroupValue[];
6
- isControlled?: boolean;
7
6
  selectionMode?: ToggleGroupSelectionMode;
8
7
  isDisabled?: boolean;
9
8
  orientation?: ToggleGroupOrientation;
@@ -23,6 +22,7 @@ export type ToggleGroupContext = {
23
22
  owner?: symbol;
24
23
  }) => void;
25
24
  unregisterToggle: (value: ToggleGroupValue) => void;
25
+ setLive: (live: boolean) => void;
26
26
  setSelectionMode: (mode: ToggleGroupSelectionMode) => void;
27
27
  setDisabled: (disabled: boolean) => void;
28
28
  setOrientation: (orientation: ToggleGroupOrientation) => void;
@@ -29,7 +29,6 @@ export function valuesToArray(values, order) {
29
29
  return [...orderedValues, ...unknownValues];
30
30
  }
31
31
  export function createToggleGroupContext(options) {
32
- const isControlled = options.isControlled ?? false;
33
32
  let selectionMode = $state(options.selectionMode ?? 'single');
34
33
  let isDisabled = $state(options.isDisabled ?? false);
35
34
  let orientation = $state(options.orientation ?? 'horizontal');
@@ -39,6 +38,10 @@ export function createToggleGroupContext(options) {
39
38
  let selectedValues = $state(normalizeValues(options.initialValue, options.selectionMode ?? 'single'));
40
39
  let focusedValue = $state(null);
41
40
  let focusVisible = $state(false);
41
+ // Whether the group is mounted and interactive. Plain `let`, not `$state`: nothing renders
42
+ // from it, and the reads happen while toggles register and unregister, where a reactive
43
+ // read would only add a dependency.
44
+ let isLive = false;
42
45
  const toggles = new SvelteMap();
43
46
  const toggleOrder = $state([]);
44
47
  function getOrderedValues() {
@@ -115,13 +118,6 @@ export function createToggleGroupContext(options) {
115
118
  previousValue.some((value, index) => !valuesMatch(value, nextValue[index]));
116
119
  if (!didChange)
117
120
  return false;
118
- if (isControlled && changeOptions?.notify !== false) {
119
- // Controlled mode: request the change and let the parent apply it via props.
120
- // Mirrors Accordion's identical `setOpen`, which had this guard while this one
121
- // silently fell through and applied the change the parent might have rejected.
122
- options.onValueChange?.(nextValue);
123
- return true;
124
- }
125
121
  selectedValues = normalizedValues;
126
122
  if (changeOptions?.notify !== false) {
127
123
  options.onValueChange?.(nextValue);
@@ -129,8 +125,6 @@ export function createToggleGroupContext(options) {
129
125
  return true;
130
126
  }
131
127
  function reconcileSelection(changedValue, changeOptions) {
132
- if (isControlled)
133
- return;
134
128
  const nextValues = new SvelteSet(selectedValues);
135
129
  let removedSelectedValue;
136
130
  for (const selectedValue of selectedValues) {
@@ -175,6 +169,13 @@ export function createToggleGroupContext(options) {
175
169
  }
176
170
  reconcileSelection(value, { notify: isExisting });
177
171
  }
172
+ // Turned on by the root as it renders and off as it goes away, which is the only way to
173
+ // tell the two unregistrations apart: a toggle removed from a live group leaves a group
174
+ // behind that still has to show something, while a group on its way out has no one left
175
+ // to show anything to.
176
+ function setLive(live) {
177
+ isLive = live;
178
+ }
178
179
  function unregisterToggle(value) {
179
180
  if (!toggles.has(value))
180
181
  return;
@@ -186,13 +187,20 @@ export function createToggleGroupContext(options) {
186
187
  if (focusedValue !== null && valuesMatch(focusedValue, value)) {
187
188
  focusedValue = null;
188
189
  }
190
+ // Only a live group can lose a toggle from under it. Outside that window the toggle is
191
+ // leaving because the group is — on the client while it unmounts, on the server as the
192
+ // markup closes — and picking a fallback would report a selection the user never made,
193
+ // to a consumer already on its way out. Bound to a URL, that fake change navigated
194
+ // straight back to the screen being left.
195
+ if (!isLive)
196
+ return;
189
197
  reconcileSelection(value);
190
198
  }
191
199
  function setSelectionMode(mode) {
192
200
  if (selectionMode === mode)
193
201
  return;
194
202
  selectionMode = mode;
195
- setSelection(selectedValues, { notify: !isControlled });
203
+ setSelection(selectedValues);
196
204
  reconcileSelection();
197
205
  }
198
206
  function setDisabled(disabled) {
@@ -307,6 +315,7 @@ export function createToggleGroupContext(options) {
307
315
  },
308
316
  registerToggle: asCommand(registerToggle),
309
317
  unregisterToggle: asCommand(unregisterToggle),
318
+ setLive: asCommand(setLive),
310
319
  setSelectionMode: asCommand(setSelectionMode),
311
320
  setDisabled: asCommand(setDisabled),
312
321
  setOrientation: asCommand(setOrientation),