@human-kit/ui 1.5.3 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (493) hide show
  1. package/README.md +1 -0
  2. package/dist/accordion/header/accordion-header.svelte +2 -2
  3. package/dist/accordion/index.d.ts +1 -1
  4. package/dist/accordion/index.js +1 -1
  5. package/dist/accordion/item/accordion-item.svelte +2 -2
  6. package/dist/accordion/item/context.d.ts +1 -1
  7. package/dist/accordion/panel/accordion-panel.svelte +3 -3
  8. package/dist/accordion/root/accordion-root.svelte +1 -1
  9. package/dist/accordion/trigger/accordion-trigger.svelte +4 -4
  10. package/dist/accordion/types.d.ts +2 -2
  11. package/dist/autocomplete/empty/autocomplete-empty.svelte +1 -1
  12. package/dist/autocomplete/input/autocomplete-input.svelte +3 -3
  13. package/dist/autocomplete/item/autocomplete-item.svelte +1 -1
  14. package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte +1 -1
  15. package/dist/autocomplete/list/autocomplete-list.svelte +2 -2
  16. package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +1 -1
  17. package/dist/autocomplete/root/autocomplete.svelte +3 -3
  18. package/dist/autocomplete/root/autocomplete.svelte.d.ts +1 -1
  19. package/dist/autocomplete/root/context.d.ts +1 -1
  20. package/dist/autocomplete/status/autocomplete-status.svelte +2 -2
  21. package/dist/avatar/count/avatar-count.svelte +3 -3
  22. package/dist/avatar/fallback/avatar-fallback.svelte +1 -1
  23. package/dist/avatar/group/avatar-group.svelte +1 -1
  24. package/dist/avatar/image/avatar-image.svelte +1 -1
  25. package/dist/avatar/root/avatar-root.svelte +2 -2
  26. package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte +3 -3
  27. package/dist/breadcrumbs/item/breadcrumbs-item.svelte +1 -1
  28. package/dist/breadcrumbs/root/breadcrumbs-root.svelte +3 -3
  29. package/dist/button/root/button-root.svelte +4 -4
  30. package/dist/calendar/body-cell/calendar-body-cell.svelte +5 -5
  31. package/dist/calendar/grid/calendar-grid-month-scope.svelte +1 -1
  32. package/dist/calendar/grid/calendar-grid.svelte +3 -3
  33. package/dist/calendar/grid/calendar-grid.svelte.d.ts +1 -1
  34. package/dist/calendar/grid/context.d.ts +1 -1
  35. package/dist/calendar/grid-body/calendar-grid-body.svelte +2 -2
  36. package/dist/calendar/grid-header/calendar-grid-header.svelte +2 -2
  37. package/dist/calendar/heading/calendar-heading.svelte +1 -1
  38. package/dist/calendar/index.d.ts +1 -1
  39. package/dist/calendar/index.js +1 -1
  40. package/dist/calendar/root/calendar-root.svelte +3 -3
  41. package/dist/calendar/root/calendar-root.svelte.d.ts +2 -2
  42. package/dist/calendar/root/context.svelte.d.ts +1 -1
  43. package/dist/calendar/root/context.svelte.js +1 -1
  44. package/dist/calendar/root/date-utils.js +1 -1
  45. package/dist/calendar/trigger-next/calendar-trigger-next.svelte +2 -2
  46. package/dist/calendar/trigger-previous/calendar-trigger-previous.svelte +2 -2
  47. package/dist/chart/README.md +51 -0
  48. package/dist/chart/arc/chart-arc.svelte +160 -0
  49. package/dist/chart/arc/chart-arc.svelte.d.ts +25 -0
  50. package/dist/chart/area/chart-area.svelte +106 -0
  51. package/dist/chart/area/chart-area.svelte.d.ts +25 -0
  52. package/dist/chart/axis/chart-axis.svelte +133 -0
  53. package/dist/chart/axis/chart-axis.svelte.d.ts +4 -0
  54. package/dist/chart/bar/chart-bar.svelte +271 -0
  55. package/dist/chart/bar/chart-bar.svelte.d.ts +25 -0
  56. package/dist/chart/data-table/chart-data-table.svelte +134 -0
  57. package/dist/chart/data-table/chart-data-table.svelte.d.ts +4 -0
  58. package/dist/chart/dot/chart-dot.svelte +93 -0
  59. package/dist/chart/dot/chart-dot.svelte.d.ts +25 -0
  60. package/dist/chart/grid/chart-grid.svelte +22 -0
  61. package/dist/chart/grid/chart-grid.svelte.d.ts +4 -0
  62. package/dist/chart/index.d.ts +17 -0
  63. package/dist/chart/index.js +16 -0
  64. package/dist/chart/index.parts.d.ts +14 -0
  65. package/dist/chart/index.parts.js +14 -0
  66. package/dist/chart/internal/arc.d.ts +13 -0
  67. package/dist/chart/internal/arc.js +32 -0
  68. package/dist/chart/internal/channel.d.ts +15 -0
  69. package/dist/chart/internal/channel.js +8 -0
  70. package/dist/chart/internal/modality.d.ts +11 -0
  71. package/dist/chart/internal/modality.js +44 -0
  72. package/dist/chart/internal/navigation.d.ts +16 -0
  73. package/dist/chart/internal/navigation.js +67 -0
  74. package/dist/chart/internal/path.d.ts +14 -0
  75. package/dist/chart/internal/path.js +36 -0
  76. package/dist/chart/internal/series.d.ts +19 -0
  77. package/dist/chart/internal/series.js +64 -0
  78. package/dist/chart/internal/stack.d.ts +14 -0
  79. package/dist/chart/internal/stack.js +29 -0
  80. package/dist/chart/internal/symbol.d.ts +8 -0
  81. package/dist/chart/internal/symbol.js +39 -0
  82. package/dist/chart/legend/chart-legend.svelte +50 -0
  83. package/dist/chart/legend/chart-legend.svelte.d.ts +4 -0
  84. package/dist/chart/line/chart-line.svelte +72 -0
  85. package/dist/chart/line/chart-line.svelte.d.ts +25 -0
  86. package/dist/chart/plot/chart-plot.svelte +39 -0
  87. package/dist/chart/plot/chart-plot.svelte.d.ts +4 -0
  88. package/dist/chart/root/chart-root.svelte +642 -0
  89. package/dist/chart/root/chart-root.svelte.d.ts +25 -0
  90. package/dist/chart/root/context.d.ts +246 -0
  91. package/dist/chart/root/context.js +17 -0
  92. package/dist/chart/rule/chart-rule.svelte +77 -0
  93. package/dist/chart/rule/chart-rule.svelte.d.ts +4 -0
  94. package/dist/chart/scales/band.d.ts +14 -0
  95. package/dist/chart/scales/band.js +30 -0
  96. package/dist/chart/scales/linear.d.ts +16 -0
  97. package/dist/chart/scales/linear.js +80 -0
  98. package/dist/chart/scales/time.d.ts +9 -0
  99. package/dist/chart/scales/time.js +155 -0
  100. package/dist/chart/scales/types.d.ts +43 -0
  101. package/dist/chart/scales/types.js +1 -0
  102. package/dist/chart/title/chart-title.svelte +17 -0
  103. package/dist/chart/title/chart-title.svelte.d.ts +4 -0
  104. package/dist/chart/tooltip/chart-tooltip.svelte +200 -0
  105. package/dist/chart/tooltip/chart-tooltip.svelte.d.ts +4 -0
  106. package/dist/chart/types.d.ts +332 -0
  107. package/dist/chart/types.js +1 -0
  108. package/dist/checkbox/indicator/checkbox-indicator.svelte +1 -1
  109. package/dist/checkbox/root/checkbox-root.svelte +4 -4
  110. package/dist/checkbox-group/index.d.ts +1 -1
  111. package/dist/checkbox-group/index.js +1 -1
  112. package/dist/checkbox-group/label/checkbox-group-label.svelte +1 -1
  113. package/dist/checkbox-group/root/checkbox-group-root.svelte +1 -1
  114. package/dist/clock/axis/clock-axis.svelte +1 -1
  115. package/dist/clock/root/clock-root.svelte +4 -4
  116. package/dist/clock/root/clock-root.svelte.d.ts +2 -2
  117. package/dist/clock/root/context.d.ts +1 -1
  118. package/dist/clock/root/create-time-selection-state.svelte.d.ts +1 -1
  119. package/dist/clock/root/create-time-selection-state.svelte.js +3 -3
  120. package/dist/clock/root/resolve-visible-columns.d.ts +2 -2
  121. package/dist/clock/root/wheel-options.d.ts +1 -1
  122. package/dist/clock/root/wheel-options.js +1 -1
  123. package/dist/clock/wheel-column/clock-wheel-column.svelte +5 -5
  124. package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +1 -1
  125. package/dist/clock/wheel-item/clock-wheel-item.svelte +1 -1
  126. package/dist/clock/wheel-item/clock-wheel-item.svelte.d.ts +1 -1
  127. package/dist/collapsible/panel/collapsible-panel.svelte +2 -2
  128. package/dist/collapsible/root/collapsible-root.svelte +1 -1
  129. package/dist/collapsible/trigger/collapsible-trigger.svelte +1 -1
  130. package/dist/color-picker/area/color-picker-area.svelte +4 -4
  131. package/dist/color-picker/area/color-picker-area.svelte.d.ts +1 -1
  132. package/dist/color-picker/area-thumb/color-picker-area-thumb.svelte +5 -5
  133. package/dist/color-picker/area-thumb/color-picker-area-thumb.svelte.d.ts +1 -1
  134. package/dist/color-picker/channel-field/color-picker-channel-field.svelte +2 -2
  135. package/dist/color-picker/channel-field/color-picker-channel-field.svelte.d.ts +1 -1
  136. package/dist/color-picker/eye-dropper/color-picker-eye-dropper.svelte +4 -4
  137. package/dist/color-picker/eye-dropper/color-picker-eye-dropper.svelte.d.ts +1 -1
  138. package/dist/color-picker/hex-field/color-picker-hex-field.svelte +5 -5
  139. package/dist/color-picker/hex-field/color-picker-hex-field.svelte.d.ts +1 -1
  140. package/dist/color-picker/label/color-picker-label.svelte +2 -2
  141. package/dist/color-picker/label/color-picker-label.svelte.d.ts +1 -1
  142. package/dist/color-picker/preview/color-picker-preview.svelte +2 -2
  143. package/dist/color-picker/preview/color-picker-preview.svelte.d.ts +1 -1
  144. package/dist/color-picker/root/color-picker-root.svelte +6 -6
  145. package/dist/color-picker/root/color-picker-root.svelte.d.ts +1 -1
  146. package/dist/color-picker/root/context.d.ts +1 -1
  147. package/dist/color-picker/slider/color-picker-slider.svelte +3 -3
  148. package/dist/color-picker/slider/color-picker-slider.svelte.d.ts +1 -1
  149. package/dist/color-picker/slider-thumb/color-picker-slider-thumb.svelte +5 -5
  150. package/dist/color-picker/slider-thumb/color-picker-slider-thumb.svelte.d.ts +1 -1
  151. package/dist/color-picker/swatch/color-picker-swatch.svelte +5 -5
  152. package/dist/color-picker/swatch/color-picker-swatch.svelte.d.ts +1 -1
  153. package/dist/color-picker/swatch-list/color-picker-swatch-list.svelte +7 -7
  154. package/dist/color-picker/swatch-list/color-picker-swatch-list.svelte.d.ts +1 -1
  155. package/dist/color-picker/types.d.ts +1 -1
  156. package/dist/combobox/clear/combobox-clear.svelte +1 -1
  157. package/dist/combobox/input/combobox-input.svelte +3 -3
  158. package/dist/combobox/item/combobox-listboxitem.svelte +1 -1
  159. package/dist/combobox/item/combobox-listboxitem.svelte.d.ts +1 -1
  160. package/dist/combobox/item-indicator/combobox-item-indicator.svelte +1 -1
  161. package/dist/combobox/list/combobox-listbox.svelte +3 -3
  162. package/dist/combobox/list/combobox-listbox.svelte.d.ts +1 -1
  163. package/dist/combobox/popover/combobox-popover.svelte +5 -5
  164. package/dist/combobox/popover/combobox-popover.svelte.d.ts +1 -1
  165. package/dist/combobox/root/combobox.svelte +6 -6
  166. package/dist/combobox/root/combobox.svelte.d.ts +1 -1
  167. package/dist/combobox/root/context.d.ts +1 -1
  168. package/dist/combobox/status/combobox-status.svelte +4 -4
  169. package/dist/combobox/tag/combobox-tag.svelte +1 -1
  170. package/dist/combobox/trigger/combobox-trigger.svelte +3 -3
  171. package/dist/datepicker/calendar/date-picker-calendar.svelte +3 -3
  172. package/dist/datepicker/calendar/date-picker-calendar.svelte.d.ts +1 -1
  173. package/dist/datepicker/input/date-picker-input.svelte +2 -2
  174. package/dist/datepicker/input/date-picker-input.svelte.d.ts +1 -1
  175. package/dist/datepicker/internal/strict-props.d.ts +1 -1
  176. package/dist/datepicker/internal/strict-props.js +2 -2
  177. package/dist/datepicker/popover/date-picker-popover.svelte +6 -6
  178. package/dist/datepicker/popover/date-picker-popover.svelte.d.ts +1 -1
  179. package/dist/datepicker/root/context.d.ts +2 -2
  180. package/dist/datepicker/root/date-picker-root.svelte +12 -12
  181. package/dist/datepicker/root/date-picker-root.svelte.d.ts +2 -2
  182. package/dist/datepicker/root/date-utils.js +1 -1
  183. package/dist/datepicker/root/draft-evaluation.d.ts +2 -2
  184. package/dist/datepicker/root/draft-evaluation.js +1 -1
  185. package/dist/datepicker/root/focus-controller.d.ts +1 -1
  186. package/dist/datepicker/root/focus-controller.js +1 -1
  187. package/dist/datepicker/root/open-change.d.ts +1 -1
  188. package/dist/datepicker/root/open-controller.d.ts +1 -1
  189. package/dist/datepicker/root/open-controller.js +1 -1
  190. package/dist/datepicker/root/segment-controller.d.ts +1 -1
  191. package/dist/datepicker/root/segment-engine.d.ts +2 -2
  192. package/dist/datepicker/root/segment-engine.js +1 -1
  193. package/dist/datepicker/root/segment-state.d.ts +1 -1
  194. package/dist/datepicker/root/segment-state.js +1 -1
  195. package/dist/datepicker/root/value-commit.d.ts +1 -1
  196. package/dist/datepicker/segment/date-picker-segment.svelte +5 -5
  197. package/dist/datepicker/segment/date-picker-segment.svelte.d.ts +1 -1
  198. package/dist/datepicker/trigger/date-picker-trigger.svelte +2 -2
  199. package/dist/daterangepicker/calendar/date-range-picker-calendar.svelte +4 -4
  200. package/dist/daterangepicker/calendar/date-range-picker-calendar.svelte.d.ts +1 -1
  201. package/dist/daterangepicker/index.d.ts +1 -1
  202. package/dist/daterangepicker/index.js +1 -1
  203. package/dist/daterangepicker/input/date-range-picker-input.svelte +2 -2
  204. package/dist/daterangepicker/input/date-range-picker-input.svelte.d.ts +1 -1
  205. package/dist/daterangepicker/internal/strict-props.d.ts +1 -1
  206. package/dist/daterangepicker/internal/strict-props.js +2 -2
  207. package/dist/daterangepicker/popover/date-range-picker-popover.svelte +6 -6
  208. package/dist/daterangepicker/popover/date-range-picker-popover.svelte.d.ts +1 -1
  209. package/dist/daterangepicker/root/context.d.ts +2 -2
  210. package/dist/daterangepicker/root/date-range-picker-root.svelte +13 -13
  211. package/dist/daterangepicker/root/date-range-picker-root.svelte.d.ts +2 -2
  212. package/dist/daterangepicker/root/value-commit.d.ts +1 -1
  213. package/dist/daterangepicker/root/value-commit.js +1 -1
  214. package/dist/daterangepicker/segment/date-range-picker-segment.svelte +5 -5
  215. package/dist/daterangepicker/segment/date-range-picker-segment.svelte.d.ts +1 -1
  216. package/dist/daterangepicker/trigger/date-range-picker-trigger.svelte +2 -2
  217. package/dist/dialog/close/dialog-close.svelte +1 -1
  218. package/dist/dialog/content/dialog-content.svelte +8 -8
  219. package/dist/dialog/description/dialog-description.svelte +1 -1
  220. package/dist/dialog/overlay/dialog-overlay.svelte +3 -3
  221. package/dist/dialog/portal/dialog-portal.svelte +4 -4
  222. package/dist/dialog/root/dialog-root.svelte +5 -5
  223. package/dist/dialog/root/dialog-root.svelte.d.ts +1 -1
  224. package/dist/dialog/root/dialog-stack.d.ts +1 -1
  225. package/dist/dialog/root/dialog-stack.js +2 -2
  226. package/dist/dialog/title/dialog-title.svelte +1 -1
  227. package/dist/dialog/trigger/dialog-trigger.svelte +1 -1
  228. package/dist/drawer/body/drawer-body.svelte +1 -1
  229. package/dist/drawer/close/drawer-close.svelte +1 -1
  230. package/dist/drawer/content/drawer-content.svelte +15 -15
  231. package/dist/drawer/description/drawer-description.svelte +1 -1
  232. package/dist/drawer/indent/drawer-indent-background.svelte +1 -1
  233. package/dist/drawer/indent/drawer-indent.svelte +1 -1
  234. package/dist/drawer/overlay/drawer-overlay.svelte +4 -4
  235. package/dist/drawer/portal/drawer-portal.svelte +4 -4
  236. package/dist/drawer/root/context.d.ts +1 -1
  237. package/dist/drawer/root/drawer-root.svelte +5 -5
  238. package/dist/drawer/root/drawer-root.svelte.d.ts +2 -2
  239. package/dist/drawer/root/snap-points.d.ts +1 -1
  240. package/dist/drawer/root/snap-points.js +1 -1
  241. package/dist/drawer/swipe-area/drawer-swipe-area.svelte +4 -4
  242. package/dist/drawer/title/drawer-title.svelte +1 -1
  243. package/dist/drawer/trigger/drawer-trigger.svelte +2 -2
  244. package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +1 -1
  245. package/dist/drawer/viewport/drawer-viewport.svelte +5 -5
  246. package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +2 -2
  247. package/dist/dropzone/dropzone.svelte +7 -4
  248. package/dist/dropzone/dropzone.svelte.d.ts +1 -1
  249. package/dist/index.d.ts +2 -0
  250. package/dist/index.js +2 -0
  251. package/dist/input/input.svelte +8 -5
  252. package/dist/input/input.svelte.d.ts +1 -1
  253. package/dist/internal/strict-props.d.ts +1 -1
  254. package/dist/internal/strict-props.js +2 -2
  255. package/dist/label/label.svelte +2 -2
  256. package/dist/label/label.svelte.d.ts +1 -1
  257. package/dist/listbox/item/listbox-item.svelte +2 -2
  258. package/dist/listbox/root/context.d.ts +1 -1
  259. package/dist/listbox/root/context.js +1 -1
  260. package/dist/listbox/root/listbox.svelte +3 -3
  261. package/dist/listbox/root/listbox.svelte.d.ts +1 -1
  262. package/dist/locale-provider/index.d.ts +1 -1
  263. package/dist/locale-provider/index.js +1 -1
  264. package/dist/locale-provider/locale-provider-value-probe.svelte +1 -1
  265. package/dist/locale-provider/locale-provider.svelte +1 -1
  266. package/dist/menu/content/menu-content.svelte +14 -10
  267. package/dist/menu/content/menu-content.svelte.d.ts +1 -1
  268. package/dist/menu/context-trigger/menu-context-trigger.svelte +2 -2
  269. package/dist/menu/group/menu-group-label.svelte +1 -1
  270. package/dist/menu/group/menu-group.svelte +1 -1
  271. package/dist/menu/item/menu-item.svelte +1 -1
  272. package/dist/menu/overlay/menu-overlay.svelte +4 -4
  273. package/dist/menu/root/context.d.ts +1 -1
  274. package/dist/menu/root/focus-state.d.ts +2 -2
  275. package/dist/menu/root/focus-state.js +1 -1
  276. package/dist/menu/root/menu-root.svelte +2 -2
  277. package/dist/menu/root/menu-root.svelte.d.ts +1 -1
  278. package/dist/menu/root/menu-stack.js +1 -1
  279. package/dist/menu/root/menu-state.svelte.d.ts +1 -1
  280. package/dist/menu/root/menu-state.svelte.js +3 -3
  281. package/dist/menu/root/submenu-intent.d.ts +1 -1
  282. package/dist/menu/submenu/menu-submenu-root.svelte +2 -2
  283. package/dist/menu/submenu/menu-submenu-root.svelte.d.ts +1 -1
  284. package/dist/menu/submenu/menu-submenu-trigger.svelte +1 -1
  285. package/dist/menu/trigger/menu-trigger.svelte +1 -1
  286. package/dist/numberfield/group/number-field-group.svelte +2 -2
  287. package/dist/numberfield/input/number-field-input.svelte +4 -4
  288. package/dist/numberfield/internal/number-field-stepper.svelte +1 -1
  289. package/dist/numberfield/root/context.d.ts +1 -1
  290. package/dist/numberfield/root/number-field-root.svelte +5 -5
  291. package/dist/numberfield/root/number-field-root.svelte.d.ts +1 -1
  292. package/dist/numberfield/root/number-utils.js +1 -1
  293. package/dist/numberfield/scrub-area/number-field-scrub-area.svelte +2 -2
  294. package/dist/numberfield/scrub-area-cursor/number-field-scrub-area-cursor.svelte +2 -2
  295. package/dist/overflow-row/overflow-row.svelte +1 -1
  296. package/dist/overflow-row/overflow-row.svelte.d.ts +1 -1
  297. package/dist/pin-input/cell/pin-input-cell.svelte +5 -5
  298. package/dist/pin-input/cell/pin-input-cell.svelte.d.ts +1 -1
  299. package/dist/pin-input/label/pin-input-label.svelte +2 -2
  300. package/dist/pin-input/label/pin-input-label.svelte.d.ts +1 -1
  301. package/dist/pin-input/root/context.d.ts +1 -1
  302. package/dist/pin-input/root/pin-input-root.svelte +11 -7
  303. package/dist/pin-input/root/pin-input-root.svelte.d.ts +1 -1
  304. package/dist/pin-input/types.d.ts +1 -1
  305. package/dist/popover/content/popover-content.svelte +13 -13
  306. package/dist/popover/content/popover-content.svelte.d.ts +3 -3
  307. package/dist/popover/overlay/popover-overlay.svelte +4 -4
  308. package/dist/popover/root/focus-state.d.ts +2 -2
  309. package/dist/popover/root/focus-state.js +1 -1
  310. package/dist/popover/root/popover-root.svelte +2 -2
  311. package/dist/popover/root/popover-root.svelte.d.ts +1 -1
  312. package/dist/popover/root/popover-stack.js +1 -1
  313. package/dist/popover/trigger/popover-trigger.svelte +1 -1
  314. package/dist/portal/portal.svelte +1 -1
  315. package/dist/primitives/aria-hide-outside.js +1 -1
  316. package/dist/primitives/collapse-transition.svelte.js +1 -1
  317. package/dist/primitives/focus-trap.js +2 -2
  318. package/dist/primitives/presence.svelte.js +1 -1
  319. package/dist/primitives/release-focused-descendant.js +1 -1
  320. package/dist/progress/indicator/progress-indicator.svelte +1 -1
  321. package/dist/progress/label/progress-label.svelte +1 -1
  322. package/dist/progress/root/context.d.ts +1 -1
  323. package/dist/progress/root/progress-root.svelte +3 -3
  324. package/dist/progress/track/progress-track.svelte +1 -1
  325. package/dist/progress/value/progress-value.svelte +1 -1
  326. package/dist/radio-group/index.d.ts +1 -1
  327. package/dist/radio-group/index.js +1 -1
  328. package/dist/radio-group/indicator/radio-group-indicator.svelte +1 -1
  329. package/dist/radio-group/item/radio-group-item.svelte +4 -4
  330. package/dist/radio-group/label/radio-group-label.svelte +1 -1
  331. package/dist/radio-group/root/radio-group-root.svelte +3 -3
  332. package/dist/rating/item/rating-item.svelte +5 -5
  333. package/dist/rating/item/rating-item.svelte.d.ts +1 -1
  334. package/dist/rating/label/rating-label.svelte +2 -2
  335. package/dist/rating/label/rating-label.svelte.d.ts +1 -1
  336. package/dist/rating/output/rating-output.svelte +2 -2
  337. package/dist/rating/output/rating-output.svelte.d.ts +1 -1
  338. package/dist/rating/root/rating-root.svelte +9 -9
  339. package/dist/rating/root/rating-root.svelte.d.ts +1 -1
  340. package/dist/rating/types.d.ts +1 -1
  341. package/dist/search-field/clear/search-field-clear.svelte +3 -3
  342. package/dist/search-field/input/search-field-input.svelte +5 -5
  343. package/dist/search-field/label/search-field-label.svelte +1 -1
  344. package/dist/search-field/root/search-field-root.svelte +5 -5
  345. package/dist/select/item/select-item.svelte +1 -1
  346. package/dist/select/item-indicator/select-item-indicator.svelte +2 -2
  347. package/dist/select/item-indicator/select-item-indicator.svelte.d.ts +1 -1
  348. package/dist/select/label/select-label.svelte +2 -2
  349. package/dist/select/label/select-label.svelte.d.ts +1 -1
  350. package/dist/select/list/select-list.svelte +2 -2
  351. package/dist/select/list/select-list.svelte.d.ts +1 -1
  352. package/dist/select/popover/select-popover.svelte +4 -4
  353. package/dist/select/popover/select-popover.svelte.d.ts +1 -1
  354. package/dist/select/root/context.d.ts +2 -2
  355. package/dist/select/root/select-root.svelte +7 -7
  356. package/dist/select/root/select-root.svelte.d.ts +1 -1
  357. package/dist/select/trigger/select-trigger.svelte +4 -4
  358. package/dist/select/trigger/select-trigger.svelte.d.ts +1 -1
  359. package/dist/select/types.d.ts +1 -1
  360. package/dist/select/value/select-value.svelte +3 -3
  361. package/dist/select/value/select-value.svelte.d.ts +1 -1
  362. package/dist/separator/separator.svelte +5 -2
  363. package/dist/slider/fill/slider-fill.svelte +2 -2
  364. package/dist/slider/fill/slider-fill.svelte.d.ts +1 -1
  365. package/dist/slider/label/slider-label.svelte +2 -2
  366. package/dist/slider/label/slider-label.svelte.d.ts +1 -1
  367. package/dist/slider/output/slider-output.svelte +3 -3
  368. package/dist/slider/output/slider-output.svelte.d.ts +1 -1
  369. package/dist/slider/root/slider-root.svelte +7 -7
  370. package/dist/slider/root/slider-root.svelte.d.ts +1 -1
  371. package/dist/slider/root/slider-utils.d.ts +1 -1
  372. package/dist/slider/root/slider-utils.js +1 -1
  373. package/dist/slider/thumb/slider-thumb.svelte +7 -7
  374. package/dist/slider/thumb/slider-thumb.svelte.d.ts +1 -1
  375. package/dist/slider/track/slider-track.svelte +2 -2
  376. package/dist/slider/track/slider-track.svelte.d.ts +1 -1
  377. package/dist/slider/types.d.ts +1 -1
  378. package/dist/switch/root/switch-root.svelte +3 -3
  379. package/dist/switch/thumb/switch-thumb.svelte +1 -1
  380. package/dist/table/body/table-body.svelte +1 -1
  381. package/dist/table/cell/table-cell.svelte +3 -3
  382. package/dist/table/checkbox/table-checkbox.svelte +5 -5
  383. package/dist/table/checkbox-indicator/table-checkbox-indicator.svelte +2 -2
  384. package/dist/table/column/table-column.svelte +1 -1
  385. package/dist/table/column-header-cell/table-column-header-cell.svelte +4 -4
  386. package/dist/table/column-resizer/table-column-resizer.svelte +6 -6
  387. package/dist/table/empty-state/table-empty-state.svelte +1 -1
  388. package/dist/table/footer/table-footer.svelte +1 -1
  389. package/dist/table/header/table-header.svelte +1 -1
  390. package/dist/table/index.d.ts +1 -1
  391. package/dist/table/index.js +1 -1
  392. package/dist/table/interactive-cell/table-interactive-cell.svelte +3 -3
  393. package/dist/table/root/context.svelte.js +1 -1
  394. package/dist/table/root/table-root.svelte +7 -7
  395. package/dist/table/root/table-ssr-wrapper-column.svelte +1 -1
  396. package/dist/table/root/table-ssr-wrapper-column.svelte.d.ts +1 -1
  397. package/dist/table/row/table-row.svelte +3 -3
  398. package/dist/table/section-row/table-section-row.svelte +3 -3
  399. package/dist/table/sort-trigger/table-sort-trigger.svelte +2 -2
  400. package/dist/table/types.d.ts +2 -2
  401. package/dist/table/utils/handle-body-keydown.d.ts +1 -1
  402. package/dist/table/utils/handle-body-keydown.js +1 -1
  403. package/dist/table/utils/ssr-min-width.d.ts +1 -1
  404. package/dist/table/utils/ssr-min-width.js +1 -1
  405. package/dist/tabs/index.d.ts +1 -1
  406. package/dist/tabs/index.js +1 -1
  407. package/dist/tabs/indicator/tabs-indicator.svelte +1 -1
  408. package/dist/tabs/list/tabs-list.svelte +3 -3
  409. package/dist/tabs/panel/tabs-panel.svelte +1 -1
  410. package/dist/tabs/root/tabs-root.svelte +1 -1
  411. package/dist/tabs/tab/tabs-tab.svelte +2 -2
  412. package/dist/tabs/types.d.ts +2 -2
  413. package/dist/textarea/textarea.svelte +8 -5
  414. package/dist/textarea/textarea.svelte.d.ts +1 -1
  415. package/dist/timepicker/clock/time-picker-clock.svelte +3 -3
  416. package/dist/timepicker/clock/time-picker-clock.svelte.d.ts +1 -1
  417. package/dist/timepicker/input/time-picker-input.svelte +3 -3
  418. package/dist/timepicker/input/time-picker-input.svelte.d.ts +1 -1
  419. package/dist/timepicker/internal/strict-props.d.ts +1 -1
  420. package/dist/timepicker/internal/strict-props.js +2 -2
  421. package/dist/timepicker/popover/time-picker-popover.svelte +5 -5
  422. package/dist/timepicker/popover/time-picker-popover.svelte.d.ts +1 -1
  423. package/dist/timepicker/root/context.d.ts +2 -2
  424. package/dist/timepicker/root/time-picker-root.svelte +4 -4
  425. package/dist/timepicker/root/time-picker-root.svelte.d.ts +2 -2
  426. package/dist/timepicker/root/time-utils.d.ts +1 -1
  427. package/dist/timepicker/root/time-utils.js +1 -1
  428. package/dist/timepicker/segment/time-picker-segment.svelte +5 -5
  429. package/dist/timepicker/segment/time-picker-segment.svelte.d.ts +1 -1
  430. package/dist/timepicker/trigger/time-picker-trigger.svelte +3 -3
  431. package/dist/toast/action/toast-action.svelte +2 -2
  432. package/dist/toast/close/toast-close.svelte +2 -2
  433. package/dist/toast/content/toast-content.svelte +1 -1
  434. package/dist/toast/description/toast-description.svelte +1 -1
  435. package/dist/toast/positioner/toast-positioner.svelte +3 -3
  436. package/dist/toast/provider/context.d.ts +1 -1
  437. package/dist/toast/provider/toast-manager.svelte.d.ts +1 -1
  438. package/dist/toast/provider/toast-provider.svelte +2 -2
  439. package/dist/toast/root/context.d.ts +1 -1
  440. package/dist/toast/root/toast-root.svelte +4 -4
  441. package/dist/toast/title/toast-title.svelte +1 -1
  442. package/dist/toast/viewport/toast-viewport.svelte +10 -10
  443. package/dist/toggle/root/toggle-root.svelte +3 -3
  444. package/dist/toggle/root/toggle-root.svelte.d.ts +1 -1
  445. package/dist/toggle/types.d.ts +1 -1
  446. package/dist/toggle-group/index.d.ts +1 -1
  447. package/dist/toggle-group/index.js +1 -1
  448. package/dist/toggle-group/root/toggle-group-root.svelte +3 -3
  449. package/dist/toggle-group/types.d.ts +2 -2
  450. package/dist/tooltip/arrow/tooltip-arrow.svelte +2 -2
  451. package/dist/tooltip/arrow/tooltip-arrow.svelte.d.ts +1 -1
  452. package/dist/tooltip/content/tooltip-content.svelte +6 -6
  453. package/dist/tooltip/content/tooltip-content.svelte.d.ts +1 -1
  454. package/dist/tooltip/provider/tooltip-provider.svelte +3 -3
  455. package/dist/tooltip/provider/tooltip-provider.svelte.d.ts +1 -1
  456. package/dist/tooltip/root/tooltip-root.svelte +7 -7
  457. package/dist/tooltip/root/tooltip-root.svelte.d.ts +1 -1
  458. package/dist/tooltip/trigger/tooltip-trigger.svelte +2 -2
  459. package/dist/tooltip/trigger/tooltip-trigger.svelte.d.ts +1 -1
  460. package/dist/tooltip/types.d.ts +2 -2
  461. package/dist/transfer-list/item/transfer-list-item.svelte +3 -3
  462. package/dist/transfer-list/list/transfer-list-list.svelte +4 -4
  463. package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +1 -1
  464. package/dist/transfer-list/move/transfer-list-move-button.svelte +5 -5
  465. package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +1 -1
  466. package/dist/transfer-list/move/transfer-list-reorder-button.svelte +4 -4
  467. package/dist/transfer-list/root/context.d.ts +2 -2
  468. package/dist/transfer-list/root/transfer-list-root.svelte +4 -4
  469. package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +1 -1
  470. package/dist/transfer-list/status/transfer-list-status.svelte +5 -5
  471. package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +1 -1
  472. package/dist/tree/checkbox/tree-checkbox.svelte +8 -8
  473. package/dist/tree/checkbox/tree-checkbox.svelte.d.ts +1 -1
  474. package/dist/tree/checkbox-indicator/tree-checkbox-indicator.svelte +3 -3
  475. package/dist/tree/checkbox-indicator/tree-checkbox-indicator.svelte.d.ts +1 -1
  476. package/dist/tree/children/tree-children.svelte +3 -3
  477. package/dist/tree/children/tree-children.svelte.d.ts +1 -1
  478. package/dist/tree/header/tree-header.svelte +3 -3
  479. package/dist/tree/header/tree-header.svelte.d.ts +1 -1
  480. package/dist/tree/item/context.d.ts +1 -1
  481. package/dist/tree/item/tree-item-renderer.svelte +5 -5
  482. package/dist/tree/item/tree-item-renderer.svelte.d.ts +2 -2
  483. package/dist/tree/item/tree-item.svelte +4 -4
  484. package/dist/tree/item/tree-item.svelte.d.ts +1 -1
  485. package/dist/tree/label/tree-label.svelte +3 -3
  486. package/dist/tree/label/tree-label.svelte.d.ts +1 -1
  487. package/dist/tree/root/tree-root.svelte +4 -4
  488. package/dist/tree/root/tree-root.svelte.d.ts +1 -1
  489. package/dist/tree/section/tree-section.svelte +3 -3
  490. package/dist/tree/section/tree-section.svelte.d.ts +1 -1
  491. package/dist/tree/trigger/tree-trigger.svelte +5 -5
  492. package/dist/tree/trigger/tree-trigger.svelte.d.ts +1 -1
  493. package/package.json +24 -3
@@ -0,0 +1,246 @@
1
+ import type { Channel } from '../internal/channel.js';
2
+ import type { ChartSymbol } from '../internal/symbol.js';
3
+ import type { Scale } from '../scales/types.js';
4
+ /** A value of a channel: a number, a date, or a category of a band scale. */
5
+ export type ChartValue = number | Date | string;
6
+ /** One point of the chart, as the focus state and `onSelect` give it. */
7
+ export type ChartPoint<T = unknown> = {
8
+ /** The row of the data. */
9
+ datum: T;
10
+ /** The index of the row in the data of its mark. */
11
+ index: number;
12
+ /**
13
+ * The value that identifies the point in its series across updates, from the `key` channel. A
14
+ * date is its time.
15
+ */
16
+ key: string | number;
17
+ /** The name of the series. It is empty when the chart has one series. */
18
+ series: string;
19
+ /** The value of the x channel. */
20
+ x: ChartValue;
21
+ /** The value of the y channel. */
22
+ y: ChartValue;
23
+ };
24
+ /** The values that a mark adds to the domains of the scales. */
25
+ export type ChartExtent = {
26
+ x?: ChartValue[];
27
+ y?: ChartValue[];
28
+ };
29
+ /** The state of the tooltip. */
30
+ export type ChartTooltipState<T = unknown> = {
31
+ point: ChartPoint<T>;
32
+ /** The position of the point in the plot, in pixels. */
33
+ x: number;
34
+ y: number;
35
+ /** The x value as text. */
36
+ xText: string;
37
+ /** The y value as text. */
38
+ yText: string;
39
+ /**
40
+ * Whether the categories of the mark are on the y axis, as in a horizontal bar chart. Then
41
+ * `yText` names the category and `xText` is the value.
42
+ */
43
+ horizontal: boolean;
44
+ };
45
+ /** The points of one series of a mark. */
46
+ export type ChartSeries<T = unknown> = {
47
+ name: string;
48
+ points: ChartPoint<T>[];
49
+ /** The indexes in `points` that come after a row without a valid value: a line breaks there. */
50
+ breaks: number[];
51
+ };
52
+ /** A mark, as it registers with the root. */
53
+ export type ChartMark = {
54
+ /** The series of the mark. */
55
+ read: () => ChartSeries[];
56
+ /**
57
+ * The values that the domains must include in addition to the data of the root: the data of a
58
+ * mark with data or channels of its own, or the tops of a stack.
59
+ */
60
+ extent?: () => ChartExtent;
61
+ /** The position in pixels where the tooltip of a point points. */
62
+ anchor: (series: number, index: number) => [number, number];
63
+ /**
64
+ * The squared distance in pixels from a position on the plot to the shape of a point, for a
65
+ * mark with points that have an area. Without it, the distance goes to the anchor.
66
+ */
67
+ distance?: (series: number, index: number, x: number, y: number) => number;
68
+ /**
69
+ * Whether the categories of the mark are on the y axis. Then the vertical arrows move in a
70
+ * series, and a name and a table row start with the y value.
71
+ */
72
+ horizontal?: () => boolean;
73
+ /**
74
+ * Whether the mark shows each point on its own, as the dot mark does. Then a name starts with the
75
+ * series, and the data table has one row per point.
76
+ */
77
+ list?: boolean;
78
+ /**
79
+ * The shape of the dots of a series, for the legend: its name, and the `d` attribute of a path
80
+ * with its center at 0,0 that fits in 12 pixels.
81
+ */
82
+ symbol?: (series: number) => {
83
+ name: ChartSymbol;
84
+ d: string;
85
+ };
86
+ /**
87
+ * The share of a point in the total of its series, as text, for a mark that shows parts of a
88
+ * whole, as the arc mark does. It is empty when the total is 0. Then the names and the data
89
+ * table add the share, the legend lists the x values, and all of the arrows move in the series.
90
+ */
91
+ share?: (point: ChartPoint) => string;
92
+ };
93
+ /**
94
+ * A rule, as it registers with the root. A rule is not a mark: it has no points, and the keyboard
95
+ * does not stop on it.
96
+ */
97
+ export type ChartRule = {
98
+ /** The id of the element with the description of the rule. */
99
+ readonly id: string;
100
+ /** The text of the rule, for example "Target". */
101
+ readonly label: string;
102
+ /** The value as text, in the format of its axis. It is empty when the rule makes no line. */
103
+ readonly text: string;
104
+ /** The value, when it goes into the domain of its axis: a number or a date. */
105
+ extent: () => ChartExtent;
106
+ /** The text that the rule adds to the name of a point. It can be empty. */
107
+ note: (point: ChartPoint) => string;
108
+ };
109
+ /** One series of a mark with points, in the order of the keyboard. */
110
+ export type ChartEntry = {
111
+ mark: string;
112
+ series: number;
113
+ points: ChartPoint[];
114
+ horizontal: boolean;
115
+ /** Whether the mark shows parts of a whole: all of the arrows move in the series. */
116
+ share: boolean;
117
+ };
118
+ /** A tick of an axis. */
119
+ export type ChartTick = {
120
+ /** The value, as a number. A date is its time in milliseconds. */
121
+ value: number;
122
+ /** The position on the axis, in pixels. */
123
+ position: number;
124
+ /** The text of the label. */
125
+ label: string;
126
+ };
127
+ /** The space around the plot, in pixels. */
128
+ export type ChartMargin = {
129
+ top: number;
130
+ right: number;
131
+ bottom: number;
132
+ left: number;
133
+ };
134
+ /** The attributes of the element of a point. A mark spreads them on the element. */
135
+ export type PointAttributes = {
136
+ id: string;
137
+ role: 'img';
138
+ tabindex: 0 | -1;
139
+ 'aria-label': string;
140
+ 'aria-current': 'true' | undefined;
141
+ 'data-focused': 'true' | undefined;
142
+ 'data-focus-visible': 'true' | undefined;
143
+ 'data-selected': 'true' | undefined;
144
+ };
145
+ export type ChartContext = {
146
+ /** The instance id. Every id of the parts is made from it. */
147
+ readonly instanceId: string;
148
+ readonly data: readonly any[];
149
+ readonly x: Channel<any, ChartValue> | undefined;
150
+ readonly y: Channel<any, ChartValue> | undefined;
151
+ readonly series: Channel<any, string> | undefined;
152
+ readonly key: Channel<any, ChartValue> | undefined;
153
+ /** The name of the x channel for a user, for example "Weight (lb)", or `undefined`. */
154
+ readonly xLabel: string | undefined;
155
+ /** The name of the y channel for a user, or `undefined`. */
156
+ readonly yLabel: string | undefined;
157
+ /** The locale of the values in names, ticks, the tooltip and the data table. */
158
+ readonly locale: string | undefined;
159
+ /** The size of the SVG, in pixels. */
160
+ readonly width: number;
161
+ /**
162
+ * Whether the width is not known yet: there is no `width` prop and no measure. On the server and
163
+ * before the first measure, the SVG fills its container and scales the default width.
164
+ */
165
+ readonly fluid: boolean;
166
+ readonly height: number;
167
+ readonly margin: ChartMargin;
168
+ readonly xScale: Scale;
169
+ readonly yScale: Scale;
170
+ /** The ticks of each axis. `Chart.Axis` and `Chart.Grid` share them. */
171
+ readonly xTicks: ChartTick[];
172
+ readonly yTicks: ChartTick[];
173
+ /**
174
+ * Asks for space around the plot, for the labels of an axis. The margin of a side is the
175
+ * largest space that a part asks for, unless the consumer gives the margin.
176
+ */
177
+ reserve(needs: Partial<ChartMargin>): {
178
+ update(needs: Partial<ChartMargin>): void;
179
+ unregister(): void;
180
+ };
181
+ /** The id of the `Chart.Title` element, when one is in the DOM. */
182
+ titleId: string | null;
183
+ /** An x value as a number for the x scale: a date is its time, and a category is its index. */
184
+ toX(value: ChartValue): number;
185
+ /** A y value as a number for the y scale. */
186
+ toY(value: ChartValue): number;
187
+ /** Adds a mark. The root reads its functions again each time the data changes. */
188
+ register(mark: ChartMark): {
189
+ id: string;
190
+ unregister(): void;
191
+ };
192
+ /** Adds a rule. It returns the function that removes it. */
193
+ rule(rule: ChartRule): () => void;
194
+ /** The rules that make a line, in mount order. The plot lists their ids in `aria-describedby`. */
195
+ readonly rules: ReadonlyArray<ChartRule>;
196
+ /** The marks, in mount order. A part reads their series, for example a legend. */
197
+ readonly marks: ReadonlyArray<ChartMark>;
198
+ /** The series of all of the marks with points, in the order of the keyboard. */
199
+ readonly entries: ReadonlyArray<ChartEntry>;
200
+ /** The id of the element of a point. */
201
+ pointId(mark: string, series: number, index: number): string;
202
+ /** The point with the id, or `null`. */
203
+ pointAt(id: string | null): ChartPoint | null;
204
+ /** The entry and the index of the point with the id, or `null`. */
205
+ locate(id: string | null): {
206
+ entry: ChartEntry;
207
+ index: number;
208
+ } | null;
209
+ /** The position in pixels where the tooltip of a point points, from its mark. */
210
+ anchor(mark: string, series: number, index: number): [number, number] | null;
211
+ /** The id of the point nearest to a position on the screen, within 40 pixels, or `null`. */
212
+ nearest(clientX: number, clientY: number): string | null;
213
+ /** An x value (as a number for the x scale) as text, in the format of the chart. */
214
+ formatX(value: number): string;
215
+ /** A y value (as a number for the y scale) as text, in the format of the chart. */
216
+ formatY(value: number): string;
217
+ /** The point that has the focus, and whether it shows the focus ring. */
218
+ readonly focus: {
219
+ id: string | null;
220
+ visible: boolean;
221
+ };
222
+ /** Whether the point is the selected point. */
223
+ isSelected(point: ChartPoint): boolean;
224
+ /** The SVG element of `Chart.Plot`. */
225
+ plotElement: SVGSVGElement | null;
226
+ /** The attributes of the element of a point. */
227
+ point(mark: string, series: number, index: number, point: ChartPoint): PointAttributes;
228
+ /** The accessible name and description of the chart, for the `Chart.Plot` element. */
229
+ readonly labels: {
230
+ 'aria-label': string | undefined;
231
+ 'aria-labelledby': string | undefined;
232
+ 'aria-describedby': string | undefined;
233
+ };
234
+ /** The handlers of the `Chart.Plot` element. */
235
+ readonly plotHandlers: {
236
+ onkeydown(event: KeyboardEvent): void;
237
+ onfocusin(event: FocusEvent): void;
238
+ onfocusout(event: FocusEvent): void;
239
+ onclick(event: MouseEvent): void;
240
+ };
241
+ };
242
+ export declare function setChartContext(context: ChartContext): void;
243
+ /** The context of the closest `Chart.Root`, or `undefined` outside one. */
244
+ export declare function getChartContext(): ChartContext | undefined;
245
+ /** The context of the closest `Chart.Root`. It throws outside one. */
246
+ export declare function useChartContext(part: string): ChartContext;
@@ -0,0 +1,17 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ /* eslint-enable @typescript-eslint/no-explicit-any */
3
+ const KEY = Symbol('human-kit-chart');
4
+ export function setChartContext(context) {
5
+ setContext(KEY, context);
6
+ }
7
+ /** The context of the closest `Chart.Root`, or `undefined` outside one. */
8
+ export function getChartContext() {
9
+ return getContext(KEY);
10
+ }
11
+ /** The context of the closest `Chart.Root`. It throws outside one. */
12
+ export function useChartContext(part) {
13
+ const context = getChartContext();
14
+ if (!context)
15
+ throw new Error(`${part} must be inside Chart.Root.`);
16
+ return context;
17
+ }
@@ -0,0 +1,77 @@
1
+ <script lang="ts">
2
+ import { dev } from '../../internal/environment.js';
3
+ import { round } from '../internal/path.js';
4
+ import { isValue } from '../internal/series.js';
5
+ import { useChartContext } from '../root/context.js';
6
+ import type { ChartRuleProps } from '../types.js';
7
+
8
+ let { value, axis = 'y', label, compare, class: className = '' }: ChartRuleProps = $props();
9
+
10
+ const uid = $props.id();
11
+ const ctx = useChartContext('Chart.Rule');
12
+ const id = `chart-${ctx.instanceId}-rule-${uid}`;
13
+ const vertical = $derived(axis === 'x');
14
+ const n = $derived(vertical ? ctx.toX(value) : ctx.toY(value));
15
+ // The position of the line. A category needs a band scale, and a band scale needs a category. A
16
+ // value out of the range has no position: a sighted user does not see it, thus the description
17
+ // does not give it. The product of the distances to the two ends is negative between them.
18
+ const position = $derived.by(() => {
19
+ const scale = vertical ? ctx.xScale : ctx.yScale;
20
+ const [a, b] = scale.range;
21
+ const p = scale(n);
22
+ return isValue(value) &&
23
+ (typeof value === 'string') === (scale.kind === 'band') &&
24
+ (p - a) * (p - b) < 1
25
+ ? round(p)
26
+ : NaN;
27
+ });
28
+ const text = $derived(isNaN(position) ? '' : vertical ? ctx.formatX(n) : ctx.formatY(n));
29
+ const channel = $derived(vertical ? ctx.xLabel : ctx.yLabel);
30
+ // The line goes across the plot: the range of the other axis. The label of a vertical line goes
31
+ // at the top.
32
+ const across = $derived(vertical ? ctx.yScale.range : ctx.xScale.range);
33
+ const top = $derived(Math.min(...across));
34
+
35
+ const unregister = ctx.rule({
36
+ id,
37
+ get label() {
38
+ return label;
39
+ },
40
+ get text() {
41
+ return text;
42
+ },
43
+ // A category does not go into the domain: a rule does not add a category.
44
+ extent: () => (isValue(value) && typeof value !== 'string' ? { [axis]: [value] } : {}),
45
+ note: (point) => (text && compare?.(point, value)) || ''
46
+ });
47
+ $effect(() => unregister);
48
+
49
+ $effect(() => {
50
+ if (dev && !text) console.warn(`Chart.Rule: "${label}" has no place on the ${axis} scale.`);
51
+ });
52
+ </script>
53
+
54
+ <!--
55
+ A rule is a reference for the values, not a value: it takes no focus, and it is hidden from
56
+ assistive technology. The plot gives its description, and the data table gives its row.
57
+ -->
58
+ <g class={className} data-rule="" data-axis={axis} aria-hidden="true">
59
+ {#if text}
60
+ <line
61
+ x1={vertical ? position : across[0]}
62
+ x2={vertical ? position : across[1]}
63
+ y1={vertical ? across[0] : position}
64
+ y2={vertical ? across[1] : position}
65
+ stroke="currentColor"
66
+ />
67
+ <text
68
+ x={vertical ? position : across[1]}
69
+ y={vertical ? top : position}
70
+ dx={vertical ? '0.32em' : undefined}
71
+ dy={vertical ? '0.71em' : '-0.32em'}
72
+ text-anchor={vertical ? undefined : 'end'}
73
+ fill="currentColor">{label}</text
74
+ >
75
+ <desc {id}>{label}, {channel ? `${channel} ${text}` : text}</desc>
76
+ {/if}
77
+ </g>
@@ -0,0 +1,4 @@
1
+ import type { ChartRuleProps } from '../types.js';
2
+ declare const ChartRule: import("svelte").Component<ChartRuleProps, {}, "">;
3
+ type ChartRule = ReturnType<typeof ChartRule>;
4
+ export default ChartRule;
@@ -0,0 +1,14 @@
1
+ import type { Scale, ScaleSettings } from './types.js';
2
+ /** A scale that divides the range into one band per category. */
3
+ export type BandScale = Scale & {
4
+ readonly kind: 'band';
5
+ /** The distance from the start of a band to the start of the next band, in pixels. */
6
+ readonly step: number;
7
+ readonly categories: readonly string[];
8
+ };
9
+ /**
10
+ * Makes a band scale. The values are the indexes of `settings.categories`; the domain is not
11
+ * used. `settings.padding` is the space between two bands, and half of it is at each end. The
12
+ * default is 0.2.
13
+ */
14
+ export declare function scaleBand(_domain: readonly [number, number], range: readonly [number, number], settings?: ScaleSettings): BandScale;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Makes a band scale. The values are the indexes of `settings.categories`; the domain is not
3
+ * used. `settings.padding` is the space between two bands, and half of it is at each end. The
4
+ * default is 0.2.
5
+ */
6
+ export function scaleBand(_domain, range, settings = { categories: [] }) {
7
+ const { categories, padding = 0.2 } = settings;
8
+ const n = categories.length;
9
+ const [r0, r1] = range;
10
+ // A step holds a band and one padding: n bands, n - 1 paddings between, and half at each end.
11
+ const step = (r1 - r0) / Math.max(1, n);
12
+ const bandwidth = Math.abs(step) * (1 - padding);
13
+ const scale = (index) => r0 + step * (index + 0.5);
14
+ const name = (index) => categories[index] ?? '';
15
+ const indexes = categories.map((_, i) => i);
16
+ return Object.assign(scale, {
17
+ kind: 'band',
18
+ domain: [0, Math.max(0, n - 1)],
19
+ range,
20
+ bandwidth,
21
+ step: Math.abs(step),
22
+ categories,
23
+ invert: (position) => Math.max(0, Math.min(n - 1, Math.floor((position - r0) / step))),
24
+ // Each category is a tick. An axis with more categories than room shows every k-th one.
25
+ ticks: (count = n) => indexes.filter((i) => i % Math.max(1, Math.ceil(n / count)) === 0),
26
+ tickFormat: () => name,
27
+ valueFormat: () => name,
28
+ nice: () => [0, Math.max(0, n - 1)]
29
+ });
30
+ }
@@ -0,0 +1,16 @@
1
+ import type { Scale } from './types.js';
2
+ /** A scale that maps numbers to positions in proportion. */
3
+ export type LinearScale = Scale & {
4
+ readonly kind: 'linear';
5
+ };
6
+ /**
7
+ * The distance between two ticks: 1, 2 or 5 times a power of ten, so that about `count` ticks
8
+ * cover the span.
9
+ */
10
+ export declare function tickStep(start: number, stop: number, count: number): number;
11
+ /** Round values from `start` to `stop`, about `count` of them. */
12
+ export declare function ticks(start: number, stop: number, count?: number): number[];
13
+ /** Extends the domain to round values, so that the first and the last tick are at the ends. */
14
+ export declare function nice(domain: readonly [number, number], count?: number): [number, number];
15
+ /** Makes a linear scale from `domain` to `range`. */
16
+ export declare function scaleLinear(domain: readonly [number, number], range: readonly [number, number]): LinearScale;
@@ -0,0 +1,80 @@
1
+ const E10 = Math.sqrt(50);
2
+ const E5 = Math.sqrt(10);
3
+ const E2 = Math.sqrt(2);
4
+ /**
5
+ * The distance between two ticks: 1, 2 or 5 times a power of ten, so that about `count` ticks
6
+ * cover the span.
7
+ */
8
+ export function tickStep(start, stop, count) {
9
+ const raw = Math.abs(stop - start) / Math.max(1, count);
10
+ const power = 10 ** Math.floor(Math.log10(raw));
11
+ const error = raw / power;
12
+ const factor = error >= E10 ? 10 : error >= E5 ? 5 : error >= E2 ? 2 : 1;
13
+ return factor * power;
14
+ }
15
+ /** Round values from `start` to `stop`, about `count` of them. */
16
+ export function ticks(start, stop, count = 10) {
17
+ if (!(count > 0) || !Number.isFinite(start) || !Number.isFinite(stop))
18
+ return [];
19
+ if (start === stop)
20
+ return [start];
21
+ const reverse = stop < start;
22
+ const [lo, hi] = reverse ? [stop, start] : [start, stop];
23
+ const step = tickStep(lo, hi, count);
24
+ // Integer multiples avoid the drift of repeated additions (0.1 + 0.2).
25
+ const first = Math.ceil(lo / step);
26
+ const last = Math.floor(hi / step);
27
+ // A step below 1 divides: 0.1 is exact as 1 / 10, not as 1 * 0.1.
28
+ const inverse = step < 1 ? Math.round(1 / step) : 0;
29
+ const out = [];
30
+ for (let i = first; i <= last; i++)
31
+ out.push(inverse ? i / inverse : i * step);
32
+ return reverse ? out.reverse() : out;
33
+ }
34
+ /** Extends the domain to round values, so that the first and the last tick are at the ends. */
35
+ export function nice(domain, count = 10) {
36
+ let [start, stop] = domain;
37
+ if (!Number.isFinite(start) || !Number.isFinite(stop) || start === stop)
38
+ return [start, stop];
39
+ const reverse = stop < start;
40
+ if (reverse)
41
+ [start, stop] = [stop, start];
42
+ // Two passes: the first extension can change the step.
43
+ for (let i = 0; i < 2; i++) {
44
+ const step = tickStep(start, stop, count);
45
+ start = Math.floor(start / step) * step;
46
+ stop = Math.ceil(stop / step) * step;
47
+ }
48
+ return reverse ? [stop, start] : [start, stop];
49
+ }
50
+ /** Makes a linear scale from `domain` to `range`. */
51
+ export function scaleLinear(domain, range) {
52
+ const [d0, d1] = domain;
53
+ const [r0, r1] = range;
54
+ // An empty domain puts every value in the middle of the range.
55
+ const span = d1 - d0;
56
+ const k = span ? (r1 - r0) / span : 0;
57
+ const scale = (value) => (span ? r0 + (value - d0) * k : (r0 + r1) / 2);
58
+ return Object.assign(scale, {
59
+ kind: 'linear',
60
+ domain,
61
+ range,
62
+ bandwidth: 0,
63
+ invert: (position) => (k ? d0 + (position - r0) / k : d0),
64
+ ticks: (count) => ticks(d0, d1, count),
65
+ tickFormat(count = 10, locale) {
66
+ // As many decimals as the step has, and not more: 0.5 shows as "0.5", 2 as "2".
67
+ const digits = Math.max(0, -Math.floor(Math.log10(tickStep(d0, d1, count) || 1)));
68
+ const format = new Intl.NumberFormat(locale, {
69
+ minimumFractionDigits: digits,
70
+ maximumFractionDigits: digits
71
+ });
72
+ return (value) => format.format(value);
73
+ },
74
+ valueFormat(_values, locale, options) {
75
+ const format = new Intl.NumberFormat(locale, options);
76
+ return (value) => format.format(value);
77
+ },
78
+ nice: (count) => nice(domain, count)
79
+ });
80
+ }
@@ -0,0 +1,9 @@
1
+ import type { Scale } from './types.js';
2
+ /** A scale that maps dates to positions in proportion, with ticks at calendar boundaries. */
3
+ export type TimeScale = Scale & {
4
+ readonly kind: 'time';
5
+ };
6
+ /** Dates at calendar boundaries from `start` to `stop`, about `count` of them. */
7
+ export declare function timeTicks(start: number, stop: number, count?: number): number[];
8
+ /** Makes a time scale from `domain` (times in milliseconds) to `range`. */
9
+ export declare function scaleTime(domain: readonly [number, number], range: readonly [number, number]): TimeScale;
@@ -0,0 +1,155 @@
1
+ import { scaleLinear, tickStep, ticks as linearTicks } from './linear.js';
2
+ const SECOND = 1e3;
3
+ const MINUTE = 6e4;
4
+ const HOUR = 36e5;
5
+ const DAY = 864e5;
6
+ const YEAR = 31536e6;
7
+ // The calendar fields, from the largest to the smallest. A day is stored from 0, as the others.
8
+ const FIELDS = ['FullYear', 'Month', 'Date', 'Hours', 'Minutes', 'Seconds'];
9
+ const WEEK = 6; // A pseudo field: seven days from a Sunday.
10
+ function get(date, field) {
11
+ return date[`get${FIELDS[field]}`]() - (field === 2 ? 1 : 0);
12
+ }
13
+ function set(date, field, value) {
14
+ date[`set${FIELDS[field]}`](value + (field === 2 ? 1 : 0));
15
+ }
16
+ /** The tick intervals: a field and a count of it, with the approximate length in milliseconds. */
17
+ const INTERVALS = [
18
+ [5, 1, SECOND],
19
+ [5, 5, 5 * SECOND],
20
+ [5, 15, 15 * SECOND],
21
+ [5, 30, 30 * SECOND],
22
+ [4, 1, MINUTE],
23
+ [4, 5, 5 * MINUTE],
24
+ [4, 15, 15 * MINUTE],
25
+ [4, 30, 30 * MINUTE],
26
+ [3, 1, HOUR],
27
+ [3, 3, 3 * HOUR],
28
+ [3, 6, 6 * HOUR],
29
+ [3, 12, 12 * HOUR],
30
+ [2, 1, DAY],
31
+ [2, 2, 2 * DAY],
32
+ [WEEK, 1, 7 * DAY],
33
+ [1, 1, YEAR / 12],
34
+ [1, 3, YEAR / 4],
35
+ [0, 1, YEAR]
36
+ ];
37
+ /** The interval with the length closest to `span / count`. */
38
+ function interval(span, count) {
39
+ const target = span / count;
40
+ if (target < SECOND)
41
+ return null;
42
+ if (target > YEAR)
43
+ return [0, Math.max(1, tickStep(0, span / YEAR, count))];
44
+ let i = INTERVALS.findIndex(([, , length]) => length >= target);
45
+ if (i < 0)
46
+ i = INTERVALS.length - 1;
47
+ if (i > 0 && target / INTERVALS[i - 1][2] < INTERVALS[i][2] / target)
48
+ i--;
49
+ return [INTERVALS[i][0], INTERVALS[i][1]];
50
+ }
51
+ /** The start of the interval that holds `time`. */
52
+ function floor(time, field, step) {
53
+ const date = new Date(time);
54
+ const unit = field === WEEK ? 2 : field;
55
+ date.setMilliseconds(0);
56
+ for (let f = unit + 1; f < FIELDS.length; f++)
57
+ set(date, f, 0);
58
+ const value = get(date, unit);
59
+ set(date, unit, field === WEEK ? value - date.getDay() : value - (((value % step) + step) % step));
60
+ return date;
61
+ }
62
+ /** Dates at calendar boundaries from `start` to `stop`, about `count` of them. */
63
+ export function timeTicks(start, stop, count = 10) {
64
+ if (!Number.isFinite(start) || !Number.isFinite(stop))
65
+ return [];
66
+ if (stop < start)
67
+ return timeTicks(stop, start, count).reverse();
68
+ const chosen = interval(stop - start, count);
69
+ if (!chosen)
70
+ return linearTicks(start, stop, count);
71
+ const [field, step] = chosen;
72
+ const unit = field === WEEK ? 2 : field;
73
+ const size = field === WEEK ? 7 : step;
74
+ const out = [];
75
+ const date = floor(start, field, step);
76
+ if (+date < start)
77
+ set(date, unit, get(date, unit) + size);
78
+ // The guard stops a loop on an invalid date.
79
+ while (+date <= stop && out.length < 1000) {
80
+ out.push(+date);
81
+ set(date, unit, get(date, unit) + size);
82
+ }
83
+ return out;
84
+ }
85
+ const formats = new Map();
86
+ function format(locale, options, value) {
87
+ const key = `${locale}|${JSON.stringify(options)}`;
88
+ let formatter = formats.get(key);
89
+ if (!formatter)
90
+ formats.set(key, (formatter = new Intl.DateTimeFormat(locale, options)));
91
+ return formatter.format(value);
92
+ }
93
+ /** The label of a tick: only the largest calendar field that changes at the tick. */
94
+ function tickLabel(value, locale) {
95
+ const d = new Date(value);
96
+ return format(locale, d.getSeconds()
97
+ ? { hour: 'numeric', minute: '2-digit', second: '2-digit' }
98
+ : d.getMinutes() || d.getHours()
99
+ ? { hour: 'numeric', minute: '2-digit' }
100
+ : d.getDate() !== 1
101
+ ? { month: 'short', day: 'numeric' }
102
+ : d.getMonth()
103
+ ? { month: 'short' }
104
+ : { year: 'numeric' }, value);
105
+ }
106
+ /**
107
+ * The format of a date in full: as precise as the most precise of `values`. Dates that are all
108
+ * on the first of January show only the year.
109
+ */
110
+ function fullFormat(values) {
111
+ let level = 0;
112
+ for (const value of values) {
113
+ const d = new Date(value);
114
+ level = Math.max(level, d.getSeconds()
115
+ ? 4
116
+ : d.getMinutes() || d.getHours()
117
+ ? 3
118
+ : d.getDate() !== 1
119
+ ? 2
120
+ : d.getMonth()
121
+ ? 1
122
+ : 0);
123
+ }
124
+ return [
125
+ { year: 'numeric' },
126
+ { month: 'long', year: 'numeric' },
127
+ { dateStyle: 'medium' },
128
+ { dateStyle: 'medium', timeStyle: 'short' },
129
+ { dateStyle: 'medium', timeStyle: 'medium' }
130
+ ][level];
131
+ }
132
+ /** Makes a time scale from `domain` (times in milliseconds) to `range`. */
133
+ export function scaleTime(domain, range) {
134
+ const linear = scaleLinear(domain, range);
135
+ return Object.assign((value) => linear(value), linear, {
136
+ kind: 'time',
137
+ ticks: (count) => timeTicks(domain[0], domain[1], count),
138
+ tickFormat: (_count, locale) => (value) => tickLabel(value, locale),
139
+ valueFormat(values, locale, options) {
140
+ const resolved = options ?? fullFormat(values);
141
+ return (value) => format(locale, resolved, value);
142
+ },
143
+ nice(count = 10) {
144
+ const chosen = interval(Math.abs(domain[1] - domain[0]), count);
145
+ if (!chosen)
146
+ return [domain[0], domain[1]];
147
+ const [field, step] = chosen;
148
+ const start = +floor(domain[0], field, step);
149
+ const end = floor(domain[1], field, step);
150
+ if (+end < domain[1])
151
+ set(end, field === WEEK ? 2 : field, get(end, field === WEEK ? 2 : field) + (field === WEEK ? 7 : step));
152
+ return [start, +end];
153
+ }
154
+ });
155
+ }