@human-kit/ui 1.0.0-beta.1 → 1.0.0-beta.10

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 (495) hide show
  1. package/README.md +27 -16
  2. package/dist/FOCUS_STATE_CONTRACT.md +17 -4
  3. package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +8 -8
  4. package/dist/accordion/README.md +3 -3
  5. package/dist/accordion/types.d.ts +37 -23
  6. package/dist/autocomplete/README.md +6 -7
  7. package/dist/autocomplete/empty/autocomplete-empty.svelte +1 -1
  8. package/dist/autocomplete/empty/autocomplete-empty.svelte.d.ts +1 -1
  9. package/dist/autocomplete/input/autocomplete-input.svelte +3 -3
  10. package/dist/autocomplete/input/autocomplete-input.svelte.d.ts +3 -3
  11. package/dist/autocomplete/item/autocomplete-item.svelte +10 -0
  12. package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte +2 -2
  13. package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte.d.ts +2 -2
  14. package/dist/autocomplete/list/autocomplete-list.svelte +2 -2
  15. package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +5 -3
  16. package/dist/autocomplete/root/autocomplete.svelte +7 -7
  17. package/dist/autocomplete/root/autocomplete.svelte.d.ts +7 -7
  18. package/dist/autocomplete/status/autocomplete-status.svelte +1 -1
  19. package/dist/autocomplete/status/autocomplete-status.svelte.d.ts +1 -1
  20. package/dist/avatar/README.md +52 -0
  21. package/dist/avatar/count/avatar-count.svelte +56 -0
  22. package/dist/avatar/count/avatar-count.svelte.d.ts +4 -0
  23. package/dist/avatar/fallback/avatar-fallback.svelte +67 -0
  24. package/dist/avatar/fallback/avatar-fallback.svelte.d.ts +4 -0
  25. package/dist/avatar/group/avatar-group.svelte +65 -0
  26. package/dist/avatar/group/avatar-group.svelte.d.ts +4 -0
  27. package/dist/avatar/group/context.d.ts +15 -0
  28. package/dist/avatar/group/context.js +15 -0
  29. package/dist/avatar/image/avatar-image.svelte +104 -0
  30. package/dist/avatar/image/avatar-image.svelte.d.ts +4 -0
  31. package/dist/avatar/index.d.ts +22 -0
  32. package/dist/avatar/index.js +10 -0
  33. package/dist/avatar/index.parts.d.ts +5 -0
  34. package/dist/avatar/index.parts.js +5 -0
  35. package/dist/avatar/root/avatar-root.svelte +79 -0
  36. package/dist/avatar/root/avatar-root.svelte.d.ts +4 -0
  37. package/dist/avatar/root/context.d.ts +14 -0
  38. package/dist/avatar/root/context.js +15 -0
  39. package/dist/avatar/types.d.ts +84 -0
  40. package/dist/avatar/types.js +1 -0
  41. package/dist/breadcrumbs/README.md +65 -0
  42. package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte +62 -0
  43. package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte.d.ts +4 -0
  44. package/dist/breadcrumbs/index.d.ts +23 -0
  45. package/dist/breadcrumbs/index.js +10 -0
  46. package/dist/breadcrumbs/index.parts.d.ts +6 -0
  47. package/dist/breadcrumbs/index.parts.js +6 -0
  48. package/dist/breadcrumbs/item/breadcrumbs-item.svelte +42 -0
  49. package/dist/breadcrumbs/item/breadcrumbs-item.svelte.d.ts +4 -0
  50. package/dist/breadcrumbs/link/breadcrumbs-link.svelte +47 -0
  51. package/dist/breadcrumbs/link/breadcrumbs-link.svelte.d.ts +4 -0
  52. package/dist/breadcrumbs/list/breadcrumbs-list.svelte +31 -0
  53. package/dist/breadcrumbs/list/breadcrumbs-list.svelte.d.ts +4 -0
  54. package/dist/breadcrumbs/root/breadcrumbs-root.svelte +112 -0
  55. package/dist/breadcrumbs/root/breadcrumbs-root.svelte.d.ts +4 -0
  56. package/dist/breadcrumbs/root/context.d.ts +19 -0
  57. package/dist/breadcrumbs/root/context.js +15 -0
  58. package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte +35 -0
  59. package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte.d.ts +4 -0
  60. package/dist/breadcrumbs/types.d.ts +80 -0
  61. package/dist/breadcrumbs/types.js +1 -0
  62. package/dist/button/README.md +1 -1
  63. package/dist/button/root/button-root.svelte +37 -7
  64. package/dist/button/root/button-root.svelte.d.ts +19 -4
  65. package/dist/calendar/README.md +3 -3
  66. package/dist/calendar/body-cell/calendar-body-cell.svelte +7 -0
  67. package/dist/calendar/grid-header/calendar-grid-header.svelte +3 -4
  68. package/dist/calendar/grid-header/calendar-grid-header.svelte.d.ts +3 -4
  69. package/dist/calendar/root/calendar-root.svelte +8 -2
  70. package/dist/calendar/root/calendar-root.svelte.d.ts +8 -2
  71. package/dist/calendar/trigger-next/README.md +1 -1
  72. package/dist/calendar/trigger-previous/README.md +1 -1
  73. package/dist/checkbox/README.md +1 -1
  74. package/dist/checkbox/indicator/README.md +1 -1
  75. package/dist/checkbox/indicator/checkbox-indicator.svelte +1 -0
  76. package/dist/checkbox/indicator/checkbox-indicator.svelte.d.ts +1 -0
  77. package/dist/checkbox/root/README.md +2 -2
  78. package/dist/checkbox/root/checkbox-root.svelte +118 -40
  79. package/dist/checkbox/root/checkbox-root.svelte.d.ts +17 -10
  80. package/dist/checkbox-group/README.md +95 -0
  81. package/dist/checkbox-group/index.d.ts +15 -0
  82. package/dist/checkbox-group/index.js +6 -0
  83. package/dist/checkbox-group/index.parts.d.ts +4 -0
  84. package/dist/checkbox-group/index.parts.js +7 -0
  85. package/dist/checkbox-group/label/checkbox-group-label.svelte +36 -0
  86. package/dist/checkbox-group/label/checkbox-group-label.svelte.d.ts +4 -0
  87. package/dist/checkbox-group/root/checkbox-group-root.svelte +118 -0
  88. package/dist/checkbox-group/root/checkbox-group-root.svelte.d.ts +4 -0
  89. package/dist/checkbox-group/root/context.svelte.d.ts +52 -0
  90. package/dist/checkbox-group/root/context.svelte.js +251 -0
  91. package/dist/checkbox-group/types.d.ts +57 -0
  92. package/dist/checkbox-group/types.js +1 -0
  93. package/dist/clock/README.md +3 -3
  94. package/dist/clock/axis/README.md +1 -1
  95. package/dist/clock/root/README.md +1 -1
  96. package/dist/clock/wheel-column/clock-wheel-column.svelte +1 -1
  97. package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +1 -1
  98. package/dist/collapsible/README.md +3 -3
  99. package/dist/collapsible/types.d.ts +10 -7
  100. package/dist/combobox/README.md +2 -2
  101. package/dist/combobox/button/README.md +6 -6
  102. package/dist/combobox/input/README.md +1 -1
  103. package/dist/combobox/input/combobox-input.svelte +3 -3
  104. package/dist/combobox/input/combobox-input.svelte.d.ts +3 -3
  105. package/dist/combobox/item/combobox-listboxitem.svelte +4 -2
  106. package/dist/combobox/item/combobox-listboxitem.svelte.d.ts +4 -2
  107. package/dist/combobox/item-indicator/README.md +1 -1
  108. package/dist/combobox/item-indicator/combobox-item-indicator.svelte +2 -2
  109. package/dist/combobox/item-indicator/combobox-item-indicator.svelte.d.ts +2 -2
  110. package/dist/combobox/list/combobox-listbox.svelte +11 -8
  111. package/dist/combobox/list/combobox-listbox.svelte.d.ts +14 -9
  112. package/dist/combobox/popover/README.md +1 -1
  113. package/dist/combobox/popover/combobox-popover.svelte +4 -56
  114. package/dist/combobox/root/README.md +24 -24
  115. package/dist/combobox/root/combobox.svelte +26 -17
  116. package/dist/combobox/root/combobox.svelte.d.ts +26 -17
  117. package/dist/combobox/status/README.md +1 -1
  118. package/dist/combobox/status/combobox-status.svelte +1 -1
  119. package/dist/combobox/status/combobox-status.svelte.d.ts +1 -1
  120. package/dist/combobox/tag/README.md +1 -1
  121. package/dist/combobox/tag/combobox-tag.svelte +1 -1
  122. package/dist/combobox/tag/combobox-tag.svelte.d.ts +1 -1
  123. package/dist/combobox/tag-remove/README.md +1 -1
  124. package/dist/combobox/tag-remove/combobox-tag-remove.svelte +4 -5
  125. package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +4 -5
  126. package/dist/combobox/tags/README.md +1 -1
  127. package/dist/combobox/tags/combobox-tags.svelte +11 -11
  128. package/dist/combobox/tags/combobox-tags.svelte.d.ts +11 -11
  129. package/dist/combobox/trigger/README.md +7 -7
  130. package/dist/datepicker/README.md +4 -4
  131. package/dist/datepicker/input/date-picker-input.svelte +3 -4
  132. package/dist/datepicker/input/date-picker-input.svelte.d.ts +3 -4
  133. package/dist/datepicker/root/date-picker-root.svelte +1 -1
  134. package/dist/datepicker/trigger/README.md +1 -1
  135. package/dist/daterangepicker/README.md +3 -3
  136. package/dist/daterangepicker/input/date-range-picker-input.svelte +3 -4
  137. package/dist/daterangepicker/input/date-range-picker-input.svelte.d.ts +3 -4
  138. package/dist/dialog/README.md +1 -1
  139. package/dist/dialog/close/dialog-close.svelte +3 -3
  140. package/dist/dialog/close/dialog-close.svelte.d.ts +3 -3
  141. package/dist/dialog/content/dialog-content.svelte +4 -4
  142. package/dist/dialog/content/dialog-content.svelte.d.ts +4 -4
  143. package/dist/dialog/description/dialog-description.svelte +3 -3
  144. package/dist/dialog/description/dialog-description.svelte.d.ts +3 -3
  145. package/dist/dialog/overlay/dialog-overlay.svelte +1 -1
  146. package/dist/dialog/overlay/dialog-overlay.svelte.d.ts +1 -1
  147. package/dist/dialog/portal/dialog-portal.svelte +1 -1
  148. package/dist/dialog/portal/dialog-portal.svelte.d.ts +1 -1
  149. package/dist/dialog/root/README.md +1 -1
  150. package/dist/dialog/root/dialog-root.svelte +49 -11
  151. package/dist/dialog/root/dialog-root.svelte.d.ts +11 -9
  152. package/dist/dialog/title/dialog-title.svelte +3 -3
  153. package/dist/dialog/title/dialog-title.svelte.d.ts +3 -3
  154. package/dist/dialog/trigger/README.md +1 -1
  155. package/dist/drawer/README.md +3 -3
  156. package/dist/drawer/body/drawer-body.svelte +2 -2
  157. package/dist/drawer/body/drawer-body.svelte.d.ts +2 -2
  158. package/dist/drawer/close/drawer-close.svelte +3 -3
  159. package/dist/drawer/close/drawer-close.svelte.d.ts +3 -3
  160. package/dist/drawer/content/drawer-content.svelte +12 -9
  161. package/dist/drawer/content/drawer-content.svelte.d.ts +12 -9
  162. package/dist/drawer/description/drawer-description.svelte +3 -3
  163. package/dist/drawer/description/drawer-description.svelte.d.ts +3 -3
  164. package/dist/drawer/indent/drawer-indent-background.svelte +1 -1
  165. package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +1 -1
  166. package/dist/drawer/indent/drawer-indent.svelte +2 -2
  167. package/dist/drawer/indent/drawer-indent.svelte.d.ts +2 -2
  168. package/dist/drawer/overlay/drawer-overlay.svelte +1 -1
  169. package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +1 -1
  170. package/dist/drawer/portal/drawer-portal.svelte +1 -1
  171. package/dist/drawer/portal/drawer-portal.svelte.d.ts +1 -1
  172. package/dist/drawer/root/context.d.ts +1 -1
  173. package/dist/drawer/root/drawer-root.svelte +40 -25
  174. package/dist/drawer/root/drawer-root.svelte.d.ts +25 -23
  175. package/dist/drawer/swipe-area/drawer-swipe-area.svelte +3 -3
  176. package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +3 -3
  177. package/dist/drawer/title/drawer-title.svelte +3 -3
  178. package/dist/drawer/title/drawer-title.svelte.d.ts +3 -3
  179. package/dist/drawer/trigger/drawer-trigger.svelte +6 -6
  180. package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +6 -6
  181. package/dist/drawer/viewport/drawer-viewport.svelte +2 -2
  182. package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +2 -2
  183. package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +1 -1
  184. package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +1 -1
  185. package/dist/dropzone/README.md +4 -6
  186. package/dist/index.d.ts +22 -0
  187. package/dist/index.js +21 -0
  188. package/dist/input/input.svelte +6 -6
  189. package/dist/input/input.svelte.d.ts +6 -6
  190. package/dist/internal/environment.d.ts +11 -0
  191. package/dist/internal/environment.js +14 -0
  192. package/dist/internal/localized-strings.d.ts +152 -0
  193. package/dist/internal/localized-strings.js +152 -0
  194. package/dist/internal/number-precision.d.ts +9 -0
  195. package/dist/internal/number-precision.js +27 -0
  196. package/dist/listbox/README.md +20 -1
  197. package/dist/listbox/item/listbox-item.svelte +35 -17
  198. package/dist/listbox/item/listbox-item.svelte.d.ts +24 -15
  199. package/dist/listbox/root/README.md +1 -1
  200. package/dist/listbox/root/context.d.ts +26 -1
  201. package/dist/listbox/root/context.js +108 -1
  202. package/dist/listbox/root/listbox.svelte +129 -39
  203. package/dist/listbox/root/listbox.svelte.d.ts +57 -33
  204. package/dist/locale-provider/README.md +1 -6
  205. package/dist/menu/README.md +41 -4
  206. package/dist/menu/content/menu-content.svelte +28 -13
  207. package/dist/menu/content/menu-content.svelte.d.ts +14 -9
  208. package/dist/menu/context-trigger/menu-context-trigger.svelte +194 -0
  209. package/dist/menu/context-trigger/menu-context-trigger.svelte.d.ts +35 -0
  210. package/dist/menu/group/menu-group-label.svelte +1 -1
  211. package/dist/menu/group/menu-group-label.svelte.d.ts +1 -1
  212. package/dist/menu/index.d.ts +4 -1
  213. package/dist/menu/index.js +1 -0
  214. package/dist/menu/index.parts.d.ts +1 -0
  215. package/dist/menu/index.parts.js +1 -0
  216. package/dist/menu/item/menu-item.svelte +11 -8
  217. package/dist/menu/item/menu-item.svelte.d.ts +11 -8
  218. package/dist/menu/overlay/menu-overlay.svelte +1 -1
  219. package/dist/menu/overlay/menu-overlay.svelte.d.ts +1 -1
  220. package/dist/menu/root/context.d.ts +24 -3
  221. package/dist/menu/root/focus-state.d.ts +2 -2
  222. package/dist/menu/root/focus-state.js +8 -32
  223. package/dist/menu/root/menu-root.svelte +14 -8
  224. package/dist/menu/root/menu-root.svelte.d.ts +14 -8
  225. package/dist/menu/root/menu-state.svelte.d.ts +1 -1
  226. package/dist/menu/root/menu-state.svelte.js +24 -1
  227. package/dist/menu/separator/menu-separator.svelte +1 -1
  228. package/dist/menu/separator/menu-separator.svelte.d.ts +1 -1
  229. package/dist/menu/submenu/menu-submenu-root.svelte +10 -7
  230. package/dist/menu/submenu/menu-submenu-root.svelte.d.ts +10 -7
  231. package/dist/numberfield/root/README.md +1 -1
  232. package/dist/numberfield/root/number-utils.js +1 -20
  233. package/dist/numberfield/scrub-area-cursor/README.md +1 -1
  234. package/dist/popover/README.md +1 -1
  235. package/dist/popover/content/popover-content.svelte +21 -15
  236. package/dist/popover/content/popover-content.svelte.d.ts +19 -14
  237. package/dist/popover/overlay/popover-overlay.svelte +1 -1
  238. package/dist/popover/overlay/popover-overlay.svelte.d.ts +1 -1
  239. package/dist/popover/root/README.md +1 -1
  240. package/dist/popover/root/focus-state.d.ts +2 -2
  241. package/dist/popover/root/focus-state.js +7 -34
  242. package/dist/popover/root/popover-root.svelte +13 -10
  243. package/dist/popover/root/popover-root.svelte.d.ts +13 -10
  244. package/dist/popover/trigger/README.md +1 -1
  245. package/dist/primitives/aria-hide-outside.d.ts +13 -0
  246. package/dist/primitives/aria-hide-outside.js +7 -1
  247. package/dist/primitives/contain-wheel.d.ts +9 -0
  248. package/dist/primitives/contain-wheel.js +41 -0
  249. package/dist/primitives/floating.d.ts +42 -8
  250. package/dist/primitives/floating.js +70 -6
  251. package/dist/primitives/focus-trap.d.ts +2 -0
  252. package/dist/primitives/focus-trap.js +7 -1
  253. package/dist/primitives/focus-visible.svelte.d.ts +14 -0
  254. package/dist/primitives/focus-visible.svelte.js +19 -0
  255. package/dist/primitives/index.d.ts +2 -0
  256. package/dist/primitives/index.js +2 -0
  257. package/dist/primitives/input-modality.d.ts +7 -0
  258. package/dist/primitives/input-modality.js +32 -5
  259. package/dist/primitives/keyboard-navigation.d.ts +29 -5
  260. package/dist/primitives/keyboard-navigation.js +24 -16
  261. package/dist/primitives/long-press.d.ts +59 -0
  262. package/dist/primitives/long-press.js +142 -0
  263. package/dist/primitives/presence.svelte.js +6 -1
  264. package/dist/primitives/scroll-lock.d.ts +24 -0
  265. package/dist/primitives/scroll-lock.js +75 -6
  266. package/dist/primitives/trigger-focus-state.d.ts +29 -0
  267. package/dist/primitives/trigger-focus-state.js +57 -0
  268. package/dist/progress/README.md +54 -0
  269. package/dist/progress/index.d.ts +21 -0
  270. package/dist/progress/index.js +9 -0
  271. package/dist/progress/index.parts.d.ts +5 -0
  272. package/dist/progress/index.parts.js +5 -0
  273. package/dist/progress/indicator/progress-indicator.svelte +37 -0
  274. package/dist/progress/indicator/progress-indicator.svelte.d.ts +4 -0
  275. package/dist/progress/label/progress-label.svelte +34 -0
  276. package/dist/progress/label/progress-label.svelte.d.ts +4 -0
  277. package/dist/progress/root/context.d.ts +26 -0
  278. package/dist/progress/root/context.js +15 -0
  279. package/dist/progress/root/progress-root.svelte +136 -0
  280. package/dist/progress/root/progress-root.svelte.d.ts +4 -0
  281. package/dist/progress/root/progress-utils.d.ts +12 -0
  282. package/dist/progress/root/progress-utils.js +41 -0
  283. package/dist/progress/track/progress-track.svelte +27 -0
  284. package/dist/progress/track/progress-track.svelte.d.ts +4 -0
  285. package/dist/progress/types.d.ts +81 -0
  286. package/dist/progress/types.js +1 -0
  287. package/dist/progress/value/progress-value.svelte +36 -0
  288. package/dist/progress/value/progress-value.svelte.d.ts +4 -0
  289. package/dist/radio-group/README.md +103 -0
  290. package/dist/radio-group/index.d.ts +18 -0
  291. package/dist/radio-group/index.js +9 -0
  292. package/dist/radio-group/index.parts.d.ts +4 -0
  293. package/dist/radio-group/index.parts.js +4 -0
  294. package/dist/radio-group/indicator/radio-group-indicator.svelte +43 -0
  295. package/dist/radio-group/indicator/radio-group-indicator.svelte.d.ts +12 -0
  296. package/dist/radio-group/item/context.d.ts +18 -0
  297. package/dist/radio-group/item/context.js +15 -0
  298. package/dist/radio-group/item/radio-group-item.svelte +377 -0
  299. package/dist/radio-group/item/radio-group-item.svelte.d.ts +35 -0
  300. package/dist/radio-group/label/radio-group-label.svelte +37 -0
  301. package/dist/radio-group/label/radio-group-label.svelte.d.ts +4 -0
  302. package/dist/radio-group/root/context.svelte.d.ts +57 -0
  303. package/dist/radio-group/root/context.svelte.js +284 -0
  304. package/dist/radio-group/root/radio-group-root.svelte +193 -0
  305. package/dist/radio-group/root/radio-group-root.svelte.d.ts +4 -0
  306. package/dist/radio-group/types.d.ts +50 -0
  307. package/dist/radio-group/types.js +1 -0
  308. package/dist/select/README.md +129 -0
  309. package/dist/select/index.d.ts +30 -0
  310. package/dist/select/index.js +16 -0
  311. package/dist/select/index.parts.d.ts +8 -0
  312. package/dist/select/index.parts.js +9 -0
  313. package/dist/select/item/select-item.svelte +68 -0
  314. package/dist/select/item/select-item.svelte.d.ts +10 -0
  315. package/dist/select/item-indicator/select-item-indicator.svelte +55 -0
  316. package/dist/select/item-indicator/select-item-indicator.svelte.d.ts +4 -0
  317. package/dist/select/label/select-label.svelte +46 -0
  318. package/dist/select/label/select-label.svelte.d.ts +4 -0
  319. package/dist/select/list/select-list.svelte +241 -0
  320. package/dist/select/list/select-list.svelte.d.ts +62 -0
  321. package/dist/select/popover/select-popover.svelte +80 -0
  322. package/dist/select/popover/select-popover.svelte.d.ts +9 -0
  323. package/dist/select/root/context.d.ts +106 -0
  324. package/dist/select/root/context.js +22 -0
  325. package/dist/select/root/select-root.svelte +544 -0
  326. package/dist/select/root/select-root.svelte.d.ts +25 -0
  327. package/dist/select/trigger/select-trigger.svelte +192 -0
  328. package/dist/select/trigger/select-trigger.svelte.d.ts +4 -0
  329. package/dist/select/types.d.ts +133 -0
  330. package/dist/select/types.js +1 -0
  331. package/dist/select/value/select-value.svelte +61 -0
  332. package/dist/select/value/select-value.svelte.d.ts +4 -0
  333. package/dist/separator/README.md +35 -0
  334. package/dist/separator/index.d.ts +7 -0
  335. package/dist/separator/index.js +3 -0
  336. package/dist/separator/separator.svelte +254 -0
  337. package/dist/separator/separator.svelte.d.ts +45 -0
  338. package/dist/separator/types.d.ts +1 -0
  339. package/dist/separator/types.js +1 -0
  340. package/dist/slider/README.md +61 -0
  341. package/dist/slider/fill/slider-fill.svelte +40 -0
  342. package/dist/slider/fill/slider-fill.svelte.d.ts +4 -0
  343. package/dist/slider/index.d.ts +9 -0
  344. package/dist/slider/index.js +8 -0
  345. package/dist/slider/index.parts.d.ts +6 -0
  346. package/dist/slider/index.parts.js +6 -0
  347. package/dist/slider/label/slider-label.svelte +44 -0
  348. package/dist/slider/label/slider-label.svelte.d.ts +4 -0
  349. package/dist/slider/output/slider-output.svelte +46 -0
  350. package/dist/slider/output/slider-output.svelte.d.ts +4 -0
  351. package/dist/slider/root/context.d.ts +106 -0
  352. package/dist/slider/root/context.js +15 -0
  353. package/dist/slider/root/slider-root.svelte +545 -0
  354. package/dist/slider/root/slider-root.svelte.d.ts +4 -0
  355. package/dist/slider/root/slider-utils.d.ts +57 -0
  356. package/dist/slider/root/slider-utils.js +88 -0
  357. package/dist/slider/thumb/slider-thumb.svelte +276 -0
  358. package/dist/slider/thumb/slider-thumb.svelte.d.ts +4 -0
  359. package/dist/slider/track/slider-track.svelte +60 -0
  360. package/dist/slider/track/slider-track.svelte.d.ts +4 -0
  361. package/dist/slider/types.d.ts +144 -0
  362. package/dist/slider/types.js +1 -0
  363. package/dist/switch/root/README.md +2 -2
  364. package/dist/switch/root/switch-root.svelte +32 -18
  365. package/dist/switch/root/switch-root.svelte.d.ts +23 -18
  366. package/dist/switch/thumb/switch-thumb.svelte +1 -1
  367. package/dist/switch/thumb/switch-thumb.svelte.d.ts +1 -1
  368. package/dist/table/README.md +16 -9
  369. package/dist/table/cell/table-cell.svelte +27 -8
  370. package/dist/table/checkbox/table-checkbox.svelte +3 -0
  371. package/dist/table/checkbox-indicator/README.md +1 -1
  372. package/dist/table/column-header-cell/table-column-header-cell.svelte +24 -0
  373. package/dist/table/column-resizer/README.md +2 -2
  374. package/dist/table/index.d.ts +1 -1
  375. package/dist/table/index.js +1 -1
  376. package/dist/table/interactive-cell/table-interactive-cell.svelte +26 -8
  377. package/dist/table/root/README.md +1 -1
  378. package/dist/table/root/context.svelte.d.ts +17 -0
  379. package/dist/table/root/context.svelte.js +113 -17
  380. package/dist/table/root/table-root.svelte +36 -6
  381. package/dist/table/row/table-row.svelte +7 -7
  382. package/dist/table/sort-trigger/README.md +1 -1
  383. package/dist/table/types.d.ts +26 -14
  384. package/dist/tabs/types.d.ts +6 -6
  385. package/dist/timepicker/README.md +3 -2
  386. package/dist/timepicker/input/README.md +1 -1
  387. package/dist/timepicker/input/time-picker-input.svelte +66 -5
  388. package/dist/timepicker/input/time-picker-input.svelte.d.ts +18 -1
  389. package/dist/timepicker/root/README.md +1 -1
  390. package/dist/timepicker/trigger/README.md +1 -1
  391. package/dist/toast/README.md +75 -0
  392. package/dist/toast/action/toast-action.svelte +42 -0
  393. package/dist/toast/action/toast-action.svelte.d.ts +4 -0
  394. package/dist/toast/close/toast-close.svelte +41 -0
  395. package/dist/toast/close/toast-close.svelte.d.ts +4 -0
  396. package/dist/toast/content/toast-content.svelte +24 -0
  397. package/dist/toast/content/toast-content.svelte.d.ts +4 -0
  398. package/dist/toast/description/toast-description.svelte +41 -0
  399. package/dist/toast/description/toast-description.svelte.d.ts +4 -0
  400. package/dist/toast/index.d.ts +34 -0
  401. package/dist/toast/index.js +15 -0
  402. package/dist/toast/index.parts.d.ts +9 -0
  403. package/dist/toast/index.parts.js +9 -0
  404. package/dist/toast/positioner/toast-positioner.svelte +75 -0
  405. package/dist/toast/positioner/toast-positioner.svelte.d.ts +4 -0
  406. package/dist/toast/provider/context.d.ts +36 -0
  407. package/dist/toast/provider/context.js +22 -0
  408. package/dist/toast/provider/toast-manager.svelte.d.ts +113 -0
  409. package/dist/toast/provider/toast-manager.svelte.js +210 -0
  410. package/dist/toast/provider/toast-provider.svelte +98 -0
  411. package/dist/toast/provider/toast-provider.svelte.d.ts +4 -0
  412. package/dist/toast/root/context.d.ts +18 -0
  413. package/dist/toast/root/context.js +15 -0
  414. package/dist/toast/root/toast-root.svelte +296 -0
  415. package/dist/toast/root/toast-root.svelte.d.ts +4 -0
  416. package/dist/toast/title/toast-title.svelte +38 -0
  417. package/dist/toast/title/toast-title.svelte.d.ts +4 -0
  418. package/dist/toast/types.d.ts +100 -0
  419. package/dist/toast/types.js +1 -0
  420. package/dist/toast/viewport/toast-viewport.svelte +389 -0
  421. package/dist/toast/viewport/toast-viewport.svelte.d.ts +4 -0
  422. package/dist/toggle/README.md +1 -1
  423. package/dist/toggle/root/toggle-root.svelte +28 -0
  424. package/dist/toggle/root/toggle-root.svelte.d.ts +19 -0
  425. package/dist/toggle-group/README.md +12 -4
  426. package/dist/toggle-group/index.d.ts +2 -0
  427. package/dist/toggle-group/index.parts.d.ts +1 -0
  428. package/dist/toggle-group/index.parts.js +4 -0
  429. package/dist/toggle-group/root/context.svelte.d.ts +1 -1
  430. package/dist/toggle-group/root/context.svelte.js +20 -11
  431. package/dist/toggle-group/root/toggle-group-root.svelte +20 -15
  432. package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte +13 -0
  433. package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte.d.ts +7 -0
  434. package/dist/toggle-group/types.d.ts +9 -9
  435. package/dist/tooltip/README.md +53 -0
  436. package/dist/tooltip/arrow/tooltip-arrow.svelte +36 -0
  437. package/dist/tooltip/arrow/tooltip-arrow.svelte.d.ts +4 -0
  438. package/dist/tooltip/content/tooltip-content.svelte +148 -0
  439. package/dist/tooltip/content/tooltip-content.svelte.d.ts +4 -0
  440. package/dist/tooltip/index.d.ts +8 -0
  441. package/dist/tooltip/index.js +7 -0
  442. package/dist/tooltip/index.parts.d.ts +5 -0
  443. package/dist/tooltip/index.parts.js +5 -0
  444. package/dist/tooltip/provider/tooltip-provider.svelte +36 -0
  445. package/dist/tooltip/provider/tooltip-provider.svelte.d.ts +4 -0
  446. package/dist/tooltip/root/context.d.ts +46 -0
  447. package/dist/tooltip/root/context.js +22 -0
  448. package/dist/tooltip/root/safe-polygon.d.ts +26 -0
  449. package/dist/tooltip/root/safe-polygon.js +66 -0
  450. package/dist/tooltip/root/tooltip-group.d.ts +26 -0
  451. package/dist/tooltip/root/tooltip-group.js +41 -0
  452. package/dist/tooltip/root/tooltip-root.svelte +461 -0
  453. package/dist/tooltip/root/tooltip-root.svelte.d.ts +4 -0
  454. package/dist/tooltip/trigger/tooltip-trigger.svelte +52 -0
  455. package/dist/tooltip/trigger/tooltip-trigger.svelte.d.ts +4 -0
  456. package/dist/tooltip/types.d.ts +105 -0
  457. package/dist/tooltip/types.js +1 -0
  458. package/dist/transfer-list/README.md +110 -0
  459. package/dist/transfer-list/index.d.ts +33 -0
  460. package/dist/transfer-list/index.js +18 -0
  461. package/dist/transfer-list/index.parts.d.ts +9 -0
  462. package/dist/transfer-list/index.parts.js +10 -0
  463. package/dist/transfer-list/item/transfer-list-item.svelte +74 -0
  464. package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +35 -0
  465. package/dist/transfer-list/list/transfer-list-list.svelte +162 -0
  466. package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +56 -0
  467. package/dist/transfer-list/list/transfer-list-source.svelte +13 -0
  468. package/dist/transfer-list/list/transfer-list-source.svelte.d.ts +36 -0
  469. package/dist/transfer-list/list/transfer-list-target.svelte +14 -0
  470. package/dist/transfer-list/list/transfer-list-target.svelte.d.ts +36 -0
  471. package/dist/transfer-list/move/transfer-list-move-all.svelte +14 -0
  472. package/dist/transfer-list/move/transfer-list-move-all.svelte.d.ts +10 -0
  473. package/dist/transfer-list/move/transfer-list-move-button.svelte +103 -0
  474. package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +25 -0
  475. package/dist/transfer-list/move/transfer-list-move-down.svelte +14 -0
  476. package/dist/transfer-list/move/transfer-list-move-down.svelte.d.ts +10 -0
  477. package/dist/transfer-list/move/transfer-list-move-selected.svelte +14 -0
  478. package/dist/transfer-list/move/transfer-list-move-selected.svelte.d.ts +10 -0
  479. package/dist/transfer-list/move/transfer-list-move-up.svelte +14 -0
  480. package/dist/transfer-list/move/transfer-list-move-up.svelte.d.ts +10 -0
  481. package/dist/transfer-list/move/transfer-list-reorder-button.svelte +83 -0
  482. package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +21 -0
  483. package/dist/transfer-list/root/context.d.ts +70 -0
  484. package/dist/transfer-list/root/context.js +24 -0
  485. package/dist/transfer-list/root/transfer-list-root.svelte +345 -0
  486. package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +68 -0
  487. package/dist/transfer-list/root/types.d.ts +22 -0
  488. package/dist/transfer-list/root/types.js +4 -0
  489. package/dist/transfer-list/status/transfer-list-status.svelte +70 -0
  490. package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +15 -0
  491. package/dist/tree/README.md +3 -3
  492. package/dist/tree/checkbox-indicator/README.md +1 -1
  493. package/dist/tree/root/README.md +1 -1
  494. package/dist/tree/types.d.ts +19 -10
  495. package/package.json +56 -1
@@ -11,6 +11,10 @@ export function createListBoxContext(options = {}) {
11
11
  const disabledKeys = new SvelteSet(options.disabledKeys ?? []);
12
12
  const items = new Map();
13
13
  let selectedKeys = new Set(options.initialSelection ?? []);
14
+ /** Where a Shift range starts: the last item selected without modifiers. */
15
+ let anchorId = null;
16
+ /** Set by a virtualized ListBox so ranges can reach rows that were never rendered. */
17
+ let readOrderedKeys = null;
14
18
  const itemCallbacks = new Map();
15
19
  // Item count tracking with subscription
16
20
  const itemCountCallbacks = new Set();
@@ -28,8 +32,46 @@ export function createListBoxContext(options = {}) {
28
32
  function unregisterItem(id) {
29
33
  items.delete(id);
30
34
  itemCallbacks.delete(id);
35
+ // A range measured from an item that no longer exists would silently select nothing.
36
+ // In a virtualized list, though, unregistering is just scrolling away — the anchor is
37
+ // still part of the collection and has to survive, or a range made across a scroll
38
+ // collapses to the single option that ended it. The `anchorId` check comes first so
39
+ // the list order is only rebuilt for the one row that could matter.
40
+ if (anchorId === id && !getOrderedIds().includes(id)) {
41
+ anchorId = null;
42
+ }
31
43
  notifyItemCountChange();
32
44
  }
45
+ /**
46
+ * Ids in list order.
47
+ *
48
+ * A virtualized list registers the whole collection up front, because only its
49
+ * rendered window exists in the DOM and a range measured over that stops wherever the
50
+ * user happened to have scrolled.
51
+ *
52
+ * Otherwise: sorted by DOM position when every item has an element on the page,
53
+ * because registration order and render order diverge as soon as a keyed list is
54
+ * reordered. Falls back to registration order rather than sorting a partial set, which
55
+ * would interleave measured and unmeasured items into an order that matches neither.
56
+ */
57
+ function getOrderedIds() {
58
+ if (readOrderedKeys)
59
+ return readOrderedKeys();
60
+ const entries = Array.from(items.entries());
61
+ const positioned = entries.filter(([, meta]) => meta.element?.isConnected);
62
+ if (positioned.length !== entries.length) {
63
+ return entries.map(([id]) => id);
64
+ }
65
+ positioned.sort(([, a], [, b]) => {
66
+ const position = a.element.compareDocumentPosition(b.element);
67
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING)
68
+ return -1;
69
+ if (position & Node.DOCUMENT_POSITION_PRECEDING)
70
+ return 1;
71
+ return 0;
72
+ });
73
+ return positioned.map(([id]) => id);
74
+ }
33
75
  function getItemCount() {
34
76
  return items.size;
35
77
  }
@@ -179,8 +221,58 @@ export function createListBoxContext(options = {}) {
179
221
  function select(id) {
180
222
  if (isDisabled(id))
181
223
  return;
224
+ // Any unmodified selection re-anchors: the next Shift range is measured from here.
225
+ anchorId = id;
182
226
  commitSelection(computeNextSelection(id));
183
227
  }
228
+ function extendSelectionTo(id) {
229
+ if (getSelectionMode() !== 'multiple')
230
+ return;
231
+ const ordered = getOrderedIds();
232
+ const from = ordered.indexOf(anchorId ?? id);
233
+ const to = ordered.indexOf(id);
234
+ if (from === -1 || to === -1)
235
+ return;
236
+ const [start, end] = from <= to ? [from, to] : [to, from];
237
+ const next = new Set();
238
+ for (let index = start; index <= end; index += 1) {
239
+ const key = ordered[index];
240
+ if (!isDisabled(key))
241
+ next.add(key);
242
+ }
243
+ // The range REPLACES the selection rather than adding to it: dragging a Shift range
244
+ // back and forth has to shrink it again, which only works if each extension is
245
+ // recomputed from the anchor.
246
+ commitSelection(next);
247
+ }
248
+ function selectWithModifiers(id, modifiers) {
249
+ if (isDisabled(id))
250
+ return;
251
+ if (modifiers?.shift && getSelectionMode() === 'multiple') {
252
+ // First Shift press with nothing anchored yet: the item the user was on is the
253
+ // start of the range.
254
+ if (anchorId === null) {
255
+ anchorId = focusedId ?? id;
256
+ }
257
+ extendSelectionTo(id);
258
+ return;
259
+ }
260
+ if (modifiers?.ctrlOrMeta && getSelectionMode() === 'multiple') {
261
+ // Toggle regardless of `selectionBehavior`: with `'replace'` a plain click clears
262
+ // the rest, and Ctrl/Cmd+click is how you add one item without losing them.
263
+ anchorId = id;
264
+ const next = new Set(selectedKeys);
265
+ if (next.has(id)) {
266
+ next.delete(id);
267
+ }
268
+ else {
269
+ next.add(id);
270
+ }
271
+ commitSelection(next);
272
+ return;
273
+ }
274
+ select(id);
275
+ }
184
276
  function selectAll() {
185
277
  if (getSelectionMode() !== 'multiple')
186
278
  return;
@@ -201,8 +293,17 @@ export function createListBoxContext(options = {}) {
201
293
  onSelect: (id) => {
202
294
  select(id);
203
295
  },
204
- onFocusChange: (id) => {
296
+ onFocusChange: (id, _element, intent) => {
205
297
  setFocusedId(id);
298
+ if (!intent?.extend || id === null)
299
+ return;
300
+ // With nothing anchored, a Shift+Arrow starts its range at the item the user was
301
+ // standing on — which only `intent.from` still knows, since focusing the new item
302
+ // already moved `focusedId`.
303
+ if (anchorId === null) {
304
+ anchorId = intent.from ?? id;
305
+ }
306
+ extendSelectionTo(id);
206
307
  },
207
308
  // `selectAll` checks the selection mode at call time so runtime mode
208
309
  // changes are respected.
@@ -231,6 +332,12 @@ export function createListBoxContext(options = {}) {
231
332
  getItemCount,
232
333
  subscribeToItemCount,
233
334
  select,
335
+ selectWithModifiers,
336
+ extendSelectionTo,
337
+ getAnchorId: () => anchorId,
338
+ setOrderedKeys: (read) => {
339
+ readOrderedKeys = read;
340
+ },
234
341
  selectAll,
235
342
  setSelection,
236
343
  setFocusedId,
@@ -1,5 +1,6 @@
1
1
  <script lang="ts" generics="T extends object = object">
2
2
  import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
3
4
  import { onMount, tick, untrack } from 'svelte';
4
5
  import { createListBoxContext, type ListBoxContext } from './context';
5
6
  import { trackInteractionModality } from '../../primitives/input-modality';
@@ -10,72 +11,99 @@
10
11
  * @template T - The type of items when using dynamic rendering with the `items` prop.
11
12
  */
12
13
  type ListBoxProps = {
13
- /** 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
+ */
14
18
  selectionBehavior?: 'toggle' | 'replace';
15
- /** 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. */
16
20
  emptyPlaceholder?: string | Snippet;
17
- /** 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
+ */
18
25
  items?: Iterable<T>;
19
- /** Keys of items that should be disabled and non-selectable. */
26
+ /**
27
+ * Reads the key of an item. This is the same value as the `id` of `ListBox.Item`.
28
+ *
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.
32
+ */
33
+ getItemKey?: (item: T) => string | number;
34
+ /** The keys of the items that must be disabled. The user cannot select them. */
20
35
  disabledKeys?: Iterable<string | number>;
21
- /** Selection mode: 'single' allows one selection, 'multiple' allows many. */
36
+ /** The selection mode: 'single' permits one selection, and 'multiple' permits more than one. */
22
37
  selectionMode?: 'single' | 'multiple';
23
- /** Selected keys. Two-way by default — use `bind:value`. */
38
+ /** The selected keys. By default it goes in the two directions: use `bind:value`. */
24
39
  value?: Iterable<string | number>;
25
- /** Initial selection, for when `value` is not supplied. */
40
+ /** The selection at the start, for when you give no `value`. */
26
41
  defaultValue?: Iterable<string | number>;
27
42
  /**
28
- * Opt into fully controlled state: the component stops writing back to `value` and
29
- * only reports through `onChange`, so the parent can reject a change by not flowing
30
- * the new selection back down. Off by default, because `bind:value` — the common
31
- * 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.
32
47
  */
33
48
  controlledValue?: boolean;
34
- /** 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. */
35
50
  children?: Snippet | Snippet<[T]>;
36
51
  /**
37
- * Rows rendered inside the listbox above the items — an action row such as
38
- * "Create …". Kept out of `children` because in dynamic mode that snippet is called
39
- * 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.
40
55
  *
41
- * A virtualized list does not navigate into it: navigation there walks the item
42
- * 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.
43
58
  */
44
59
  header?: Snippet;
45
- /** CSS class to apply to the listbox container. */
60
+ /** The CSS class names of the listbox container. */
46
61
  class?: string;
47
- /** HTML id attribute for the listbox element. */
62
+ /** The id of the listbox element. */
48
63
  id?: string;
49
- /** Accessible label for the listbox. Announced by screen readers. */
64
+ /** The accessible name of the listbox. A screen reader announces it. */
50
65
  'aria-label'?: string;
51
- /** Callback fired when the selection changes. */
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
+ */
70
+ 'aria-labelledby'?: string;
71
+ /** The component calls it when the selection changes. */
52
72
  onChange?: (value: Set<string | number>) => void;
53
- /** 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. */
54
74
  disableFocusHandling?: boolean;
55
- /** 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
+ */
56
79
  loop?: boolean;
57
- /** 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. */
58
81
  typeahead?: boolean;
59
82
  /**
60
- * 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.
61
84
  *
62
- * Only honoured together with `items`: the listbox has to own the loop to be able to
63
- * 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.
64
87
  *
65
- * Rows must all be the same height — that assumption is what lets the scrollbar be
66
- * sized without measuring every row. The height is measured from the first rendered
67
- * 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.
68
92
  *
69
- * The listbox element itself is the scroller: give it a max height and
70
- * `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.
71
95
  */
72
96
  virtualizer?: { rowHeight?: number; overscan?: number };
73
- };
97
+ } & Omit<
98
+ HTMLAttributes<HTMLDivElement>,
99
+ 'class' | 'children' | 'role' | 'id' | 'aria-label' | 'aria-labelledby' | 'onchange'
100
+ >;
74
101
 
75
102
  let {
76
103
  selectionBehavior = 'toggle',
77
104
  emptyPlaceholder = 'No items selected',
78
105
  items,
106
+ getItemKey,
79
107
  disabledKeys,
80
108
  selectionMode = 'single',
81
109
  value = $bindable(),
@@ -86,13 +114,20 @@
86
114
  class: className = '',
87
115
  id,
88
116
  'aria-label': ariaLabel,
117
+ 'aria-labelledby': ariaLabelledBy,
89
118
  onChange,
90
119
  disableFocusHandling = false,
91
120
  loop = false,
92
121
  typeahead = false,
93
122
  virtualizer,
94
123
  context = $bindable(),
95
- element = $bindable()
124
+ element = $bindable(),
125
+ onkeydown: onKeyDownExternal,
126
+ onmousedown: onMouseDownExternal,
127
+ onfocusin: onFocusInExternal,
128
+ onfocusout: onFocusOutExternal,
129
+ onscroll: onScrollExternal,
130
+ ...restProps
96
131
  }: ListBoxProps & { context?: ListBoxContext; element?: HTMLElement } = $props();
97
132
 
98
133
  let listboxElement: HTMLElement;
@@ -312,6 +347,29 @@
312
347
  });
313
348
  }
314
349
 
350
+ /**
351
+ * Tells assistive technology how big the list really is.
352
+ *
353
+ * A virtualized listbox holds a handful of options, so the position and count a browser
354
+ * computes from the DOM describe the window rather than the collection — a screen reader
355
+ * announces "1 of 8" for a list of two thousand. ARIA has `aria-setsize` /
356
+ * `aria-posinset` for exactly this case, and only the list knows the real numbers.
357
+ *
358
+ * Written onto the rendered rows rather than passed down because the rows come from the
359
+ * consumer's snippet; it is the same set of nodes the measurement above already reads,
360
+ * and it re-runs whenever the window moves or the collection changes.
361
+ */
362
+ function labelPositions() {
363
+ if (!listboxElement || !isVirtual) return;
364
+ const rows = listboxElement.querySelectorAll<HTMLElement>('[data-listbox-window] > *');
365
+ const setSize = String(itemsArray.length);
366
+ const from = listWindow?.from ?? 0;
367
+ rows.forEach((row, offset) => {
368
+ row.setAttribute('aria-setsize', setSize);
369
+ row.setAttribute('aria-posinset', String(from + offset + 1));
370
+ });
371
+ }
372
+
315
373
  $effect(() => {
316
374
  if (!isVirtual || !listboxElement) return;
317
375
 
@@ -324,6 +382,7 @@
324
382
  const element = listboxElement;
325
383
 
326
384
  measureRows();
385
+ labelPositions();
327
386
 
328
387
  const observer = new ResizeObserver(() => {
329
388
  untrack(() => {
@@ -332,6 +391,7 @@
332
391
  }
333
392
  });
334
393
  measureRows();
394
+ labelPositions();
335
395
  });
336
396
 
337
397
  observer.observe(element);
@@ -400,6 +460,16 @@
400
460
  // on its input) can reach a row the window hasn't rendered yet.
401
461
  ctx.setScrollIndexIntoView(scrollIndexIntoView);
402
462
  ctx.setVirtualized(() => isVirtual);
463
+
464
+ // Only for a virtualized list: an unvirtualized one has every row on the page, and DOM
465
+ // order is the more truthful source there — it survives a keyed reorder that the items
466
+ // array has not caught up with.
467
+ $effect(() => {
468
+ const read = getItemKey;
469
+ if (!isVirtual || !read) return;
470
+ ctx.setOrderedKeys(() => itemsArray.map(read));
471
+ return () => ctx.setOrderedKeys(null);
472
+ });
403
473
  let hasMounted = $state(false);
404
474
  const registeredItemCount = $derived(hasMounted ? itemCount : ctx.getItemCount());
405
475
  const shouldShowEmptyPlaceholder = $derived(
@@ -441,6 +511,24 @@
441
511
  ctx.setFocusVisible(true);
442
512
  }
443
513
  }
514
+
515
+ /**
516
+ * Runs the listbox's own handler and then the consumer's.
517
+ *
518
+ * The rest props are spread last so a consumer can reach the element, but that also
519
+ * means an `onkeydown` of theirs would replace the one driving focus modality and
520
+ * keyboard navigation. Composing keeps both, with the consumer able to opt out of the
521
+ * rest by calling `stopImmediatePropagation`.
522
+ */
523
+ function compose<E extends Event>(
524
+ internal: (event: E) => void,
525
+ external: ((event: E) => void) | null | undefined
526
+ ) {
527
+ return (event: E) => {
528
+ internal(event);
529
+ external?.(event);
530
+ };
531
+ }
444
532
  </script>
445
533
 
446
534
  <div
@@ -449,15 +537,17 @@
449
537
  {id}
450
538
  aria-multiselectable={selectionMode === 'multiple'}
451
539
  aria-label={ariaLabel}
540
+ aria-labelledby={ariaLabelledBy}
452
541
  class={className}
453
542
  tabindex={disableFocusHandling ? undefined : focusWithin ? -1 : 0}
454
543
  data-focus-within={focusWithin || undefined}
455
544
  use:keyboardAction
456
- onfocusin={handleFocusIn}
457
- onfocusout={handleFocusOut}
458
- onmousedown={handleMouseDown}
459
- onkeydown={handleKeyDown}
460
- onscroll={handleScroll}
545
+ onfocusin={compose(handleFocusIn, onFocusInExternal)}
546
+ onfocusout={compose(handleFocusOut, onFocusOutExternal)}
547
+ onmousedown={compose(handleMouseDown, onMouseDownExternal)}
548
+ onkeydown={compose(handleKeyDown, onKeyDownExternal)}
549
+ onscroll={compose(handleScroll, onScrollExternal)}
550
+ {...restProps}
461
551
  >
462
552
  {#if header}
463
553
  {@render header()}
@@ -1,71 +1,95 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
2
3
  import { type ListBoxContext } from './context';
3
4
  declare function $$render<T extends object = object>(): {
4
5
  props: {
5
- /** 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
+ */
6
10
  selectionBehavior?: "toggle" | "replace";
7
- /** 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. */
8
12
  emptyPlaceholder?: string | Snippet;
9
- /** 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
+ */
10
17
  items?: Iterable<T>;
11
- /** Keys of items that should be disabled and non-selectable. */
18
+ /**
19
+ * Reads the key of an item. This is the same value as the `id` of `ListBox.Item`.
20
+ *
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.
24
+ */
25
+ getItemKey?: (item: T) => string | number;
26
+ /** The keys of the items that must be disabled. The user cannot select them. */
12
27
  disabledKeys?: Iterable<string | number>;
13
- /** Selection mode: 'single' allows one selection, 'multiple' allows many. */
28
+ /** The selection mode: 'single' permits one selection, and 'multiple' permits more than one. */
14
29
  selectionMode?: "single" | "multiple";
15
- /** Selected keys. Two-way by default — use `bind:value`. */
30
+ /** The selected keys. By default it goes in the two directions: use `bind:value`. */
16
31
  value?: Iterable<string | number>;
17
- /** Initial selection, for when `value` is not supplied. */
32
+ /** The selection at the start, for when you give no `value`. */
18
33
  defaultValue?: Iterable<string | number>;
19
34
  /**
20
- * Opt into fully controlled state: the component stops writing back to `value` and
21
- * only reports through `onChange`, so the parent can reject a change by not flowing
22
- * the new selection back down. Off by default, because `bind:value` — the common
23
- * 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.
24
39
  */
25
40
  controlledValue?: boolean;
26
- /** 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. */
27
42
  children?: Snippet | Snippet<[T]>;
28
43
  /**
29
- * Rows rendered inside the listbox above the items — an action row such as
30
- * "Create …". Kept out of `children` because in dynamic mode that snippet is called
31
- * 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.
32
47
  *
33
- * A virtualized list does not navigate into it: navigation there walks the item
34
- * 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.
35
50
  */
36
51
  header?: Snippet;
37
- /** CSS class to apply to the listbox container. */
52
+ /** The CSS class names of the listbox container. */
38
53
  class?: string;
39
- /** HTML id attribute for the listbox element. */
54
+ /** The id of the listbox element. */
40
55
  id?: string;
41
- /** Accessible label for the listbox. Announced by screen readers. */
56
+ /** The accessible name of the listbox. A screen reader announces it. */
42
57
  'aria-label'?: string;
43
- /** Callback fired when the selection changes. */
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
+ */
62
+ 'aria-labelledby'?: string;
63
+ /** The component calls it when the selection changes. */
44
64
  onChange?: (value: Set<string | number>) => void;
45
- /** 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. */
46
66
  disableFocusHandling?: boolean;
47
- /** 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
+ */
48
71
  loop?: boolean;
49
- /** 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. */
50
73
  typeahead?: boolean;
51
74
  /**
52
- * 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.
53
76
  *
54
- * Only honoured together with `items`: the listbox has to own the loop to be able to
55
- * 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.
56
79
  *
57
- * Rows must all be the same height — that assumption is what lets the scrollbar be
58
- * sized without measuring every row. The height is measured from the first rendered
59
- * 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.
60
84
  *
61
- * The listbox element itself is the scroller: give it a max height and
62
- * `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.
63
87
  */
64
88
  virtualizer?: {
65
89
  rowHeight?: number;
66
90
  overscan?: number;
67
91
  };
68
- } & {
92
+ } & Omit<HTMLAttributes<HTMLDivElement>, "children" | "class" | "id" | "role" | "aria-label" | "aria-labelledby" | "onchange"> & {
69
93
  context?: ListBoxContext;
70
94
  element?: HTMLElement;
71
95
  };
@@ -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,6 +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` 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.
15
16
  - Use `Menu.Content` inside `Menu.Root`. It renders the `role="menu"` panel in a portal and
16
17
  positions it against the trigger (default placement `bottom-start`).
17
18
  - Use `Menu.Item` for actions. Provide `onAction`, and optionally `disabled`, `closeOnSelect`, or
@@ -29,9 +30,33 @@ primitives as `Popover`.
29
30
  typed text.
30
31
  - Escape closes the current (topmost) menu and returns focus to its trigger. `Tab` and outside
31
32
  interaction close the whole menu chain. Within a submenu, `ArrowLeft` closes just that level.
32
- - Submenus use a "safe triangle" pointer intent: while the pointer is moving diagonally toward an
33
- open submenu, hovering the sibling items it passes over does not close the submenu for a short
34
- 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.
34
+
35
+ ## Context menus
36
+
37
+ `Menu.ContextTrigger` is a surface, not a button: it renders a plain element so it can wrap
38
+ arbitrary — sometimes interactive — content. It opens the menu three ways, and each anchors the
39
+ panel differently:
40
+
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
42
+ clicking again re-anchors the open menu instead of closing and reopening it.
43
+ - **Long press** on touch or pen — anchored at the finger. It is what makes the menu reachable at
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}`.
45
+ - **`Shift+F10` or the `ContextMenu` key** — anchored to the surface itself, with the first item
46
+ focused. There is no pointer involved, so reusing the last cursor position would put the panel
47
+ somewhere the keyboard user never pointed at.
48
+
49
+ A left press anywhere — including on the surface itself — dismisses it, like a native menu.
50
+
51
+ ### Accessibility
52
+
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.
54
+
55
+ It carries `aria-keyshortcuts="Shift+F10"` and nothing else. `aria-haspopup` and `aria-expanded`
56
+ are **not** global ARIA properties: on a generic element they would be invalid, so the component
57
+ does not claim them. That is a real limit, not an oversight — **a context menu must never be the
58
+ only route to an action.** Give the same `Menu.Root` a visible `Menu.Trigger`, or expose the same
59
+ actions elsewhere in the UI.
35
60
 
36
61
  ## onOpenChange details
37
62
 
@@ -40,13 +65,24 @@ primitives as `Popover`.
40
65
  - `onOpenChange(open, details)`
41
66
  - `details.reason`: `trigger-press | imperative-action | none | escape-key | outside-press | focus-out | item-select`
42
67
  - `details.event?`: native event that triggered the change when available
43
- - `details.cancel()`: prevents the open-state transition
68
+ - `details.cancel()`: stops the change of the open state
44
69
  - `details.isCanceled`: reflects cancellation state inside the callback
45
70
 
46
71
  ## Anatomy
47
72
 
48
73
  Import the component and compose its parts:
49
74
 
75
+ A context menu swaps the trigger and keeps everything else:
76
+
77
+ ```svelte
78
+ <Menu.Root>
79
+ <Menu.ContextTrigger>Right click anywhere in this card</Menu.ContextTrigger>
80
+ <Menu.Content>
81
+ <Menu.Item onAction={edit}>Edit</Menu.Item>
82
+ </Menu.Content>
83
+ </Menu.Root>
84
+ ```
85
+
50
86
  ```svelte
51
87
  <Menu.Root>
52
88
  <Menu.Trigger>Options</Menu.Trigger>
@@ -74,6 +110,7 @@ Import the component and compose its parts:
74
110
 
75
111
  - `Menu.Root`
76
112
  - `Menu.Trigger`
113
+ - `Menu.ContextTrigger`
77
114
  - `Menu.Content`
78
115
  - `Menu.Item`
79
116
  - `Menu.Separator`