@galaxy-io/dls 1.2.6 → 1.3.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 (297) hide show
  1. package/README.md +2 -0
  2. package/dist/avatar/Avatar.d.ts +2 -1
  3. package/dist/avatar/Avatar.js +103 -14
  4. package/dist/buttons/Button.d.ts +6 -1
  5. package/dist/buttons/Button.js +8 -4
  6. package/dist/charts/BarChart.d.ts +30 -20
  7. package/dist/charts/BarChart.js +216 -250
  8. package/dist/charts/ChartAxis.d.ts +47 -22
  9. package/dist/charts/ChartAxis.js +81 -60
  10. package/dist/charts/ChartEmptyState.d.ts +17 -0
  11. package/dist/charts/ChartEmptyState.js +29 -0
  12. package/dist/charts/ChartFrame.d.ts +82 -0
  13. package/dist/charts/ChartFrame.js +86 -0
  14. package/dist/charts/ChartLegend.d.ts +27 -4
  15. package/dist/charts/ChartLegend.js +46 -23
  16. package/dist/charts/ChartPrimitives.d.ts +195 -0
  17. package/dist/charts/ChartPrimitives.js +268 -0
  18. package/dist/charts/ChartTooltip.d.ts +27 -6
  19. package/dist/charts/ChartTooltip.js +56 -50
  20. package/dist/charts/LineChart.d.ts +42 -20
  21. package/dist/charts/LineChart.js +186 -237
  22. package/dist/charts/PieChart.d.ts +48 -32
  23. package/dist/charts/PieChart.js +159 -171
  24. package/dist/charts/barChartGeometry.d.ts +87 -0
  25. package/dist/charts/barChartGeometry.js +218 -0
  26. package/dist/charts/chartFormat.d.ts +19 -0
  27. package/dist/charts/chartFormat.js +59 -0
  28. package/dist/charts/chartScales.d.ts +84 -0
  29. package/dist/charts/chartScales.js +111 -0
  30. package/dist/charts/chartTheme.d.ts +18 -0
  31. package/dist/charts/chartTheme.js +26 -0
  32. package/dist/charts/constants.d.ts +225 -18
  33. package/dist/charts/constants.js +240 -32
  34. package/dist/charts/lineChartGeometry.d.ts +54 -0
  35. package/dist/charts/lineChartGeometry.js +143 -0
  36. package/dist/charts/pieChartGeometry.d.ts +48 -0
  37. package/dist/charts/pieChartGeometry.js +89 -0
  38. package/dist/charts/types.d.ts +522 -54
  39. package/dist/charts/types.js +136 -0
  40. package/dist/charts/useChartDimensions.d.ts +40 -0
  41. package/dist/charts/useChartDimensions.js +53 -0
  42. package/dist/charts/useChartFormatters.d.ts +19 -0
  43. package/dist/charts/useChartFormatters.js +20 -0
  44. package/dist/charts/useChartInteraction.d.ts +71 -0
  45. package/dist/charts/useChartInteraction.js +130 -0
  46. package/dist/charts/useChartTooltipPosition.d.ts +53 -0
  47. package/dist/charts/useChartTooltipPosition.js +39 -0
  48. package/dist/hooks/useElementClientSize.d.ts +20 -0
  49. package/dist/hooks/useElementClientSize.js +43 -0
  50. package/dist/inputs/CheckboxInput.d.ts +7 -2
  51. package/dist/inputs/CheckboxInput.js +30 -14
  52. package/dist/inputs/Input.d.ts +5 -2
  53. package/dist/inputs/Input.js +20 -17
  54. package/dist/inputs/MultiSelectInput.js +1 -1
  55. package/dist/inputs/RadioInput.js +7 -2
  56. package/dist/styles.css +68 -75
  57. package/dist/table/InfiniteSpreadsheet.d.ts +6 -0
  58. package/dist/table/InfiniteSpreadsheet.js +235 -0
  59. package/dist/table/InfiniteTable.d.ts +7 -88
  60. package/dist/table/InfiniteTable.js +366 -577
  61. package/dist/{spreadsheet → table}/SpreadsheetCell.d.ts +6 -4
  62. package/dist/table/SpreadsheetCell.js +71 -0
  63. package/dist/{spreadsheet → table}/SpreadsheetCellEditor.js +27 -21
  64. package/dist/table/SpreadsheetHeaderCell.d.ts +23 -0
  65. package/dist/table/SpreadsheetHeaderCell.js +91 -0
  66. package/dist/table/SpreadsheetMenuItem.d.ts +14 -0
  67. package/dist/table/SpreadsheetMenuItem.js +33 -0
  68. package/dist/table/SpreadsheetPrimitives.d.ts +172 -0
  69. package/dist/table/SpreadsheetPrimitives.js +105 -0
  70. package/dist/table/SpreadsheetRow.d.ts +33 -0
  71. package/dist/table/SpreadsheetRow.js +73 -0
  72. package/dist/{spreadsheet → table}/SpreadsheetRowActionCell.d.ts +5 -7
  73. package/dist/table/SpreadsheetRowActionCell.js +51 -0
  74. package/dist/table/TableExpandCell.d.ts +11 -0
  75. package/dist/table/TableExpandCell.js +24 -0
  76. package/dist/table/TableExpandedRow.d.ts +16 -0
  77. package/dist/table/TableExpandedRow.js +77 -0
  78. package/dist/table/TableHeaderCellContent.d.ts +30 -0
  79. package/dist/table/TableHeaderCellContent.js +48 -0
  80. package/dist/table/TablePrimitives.d.ts +307 -0
  81. package/dist/table/TablePrimitives.js +298 -0
  82. package/dist/table/TableSelectCell.d.ts +18 -0
  83. package/dist/table/TableSelectCell.js +26 -0
  84. package/dist/table/TableStatusRow.d.ts +18 -0
  85. package/dist/table/TableStatusRow.js +50 -0
  86. package/dist/table/VirtualizedInfiniteTable.d.ts +11 -27
  87. package/dist/table/VirtualizedInfiniteTable.js +182 -317
  88. package/dist/table/types.d.ts +249 -0
  89. package/dist/table/types.js +51 -0
  90. package/dist/table/useInfiniteScrollSentinel.d.ts +24 -0
  91. package/dist/table/useInfiniteScrollSentinel.js +53 -0
  92. package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.d.ts +1 -1
  93. package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.js +1 -1
  94. package/dist/table/useTableColumnLayout.d.ts +28 -0
  95. package/dist/table/useTableColumnLayout.js +63 -0
  96. package/dist/table/useTableColumnResize.d.ts +38 -0
  97. package/dist/table/useTableColumnResize.js +155 -0
  98. package/dist/table/useTableKeyboardNavigation.d.ts +25 -0
  99. package/dist/table/useTableKeyboardNavigation.js +83 -0
  100. package/dist/table/useTableRowExpansion.d.ts +24 -0
  101. package/dist/table/useTableRowExpansion.js +62 -0
  102. package/dist/table/useTableRowSelection.d.ts +27 -0
  103. package/dist/table/useTableRowSelection.js +94 -0
  104. package/dist/table/utils.d.ts +50 -0
  105. package/dist/table/utils.js +78 -0
  106. package/dist/text/MarkdownText.js +45 -27
  107. package/dist/theme/variants/dark.js +1 -1
  108. package/dist/widget/Widget.d.ts +2 -0
  109. package/dist/widget/Widget.js +14 -7
  110. package/package.json +1 -5
  111. package/dist/assets/components/enrichment/PerplexityIcon.d.ts +0 -3
  112. package/dist/assets/components/enrichment/PerplexityIcon.js +0 -35
  113. package/dist/assets/components/enrichment/TavilyIcon.d.ts +0 -3
  114. package/dist/assets/components/enrichment/TavilyIcon.js +0 -15
  115. package/dist/assets/components/onboarding/TenantSetupDark.d.ts +0 -3
  116. package/dist/assets/components/onboarding/TenantSetupDark.js +0 -498
  117. package/dist/assets/components/onboarding/TenantSetupLight.d.ts +0 -3
  118. package/dist/assets/components/onboarding/TenantSetupLight.js +0 -482
  119. package/dist/assets/components/onboarding/UserSetupDark.d.ts +0 -3
  120. package/dist/assets/components/onboarding/UserSetupDark.js +0 -1086
  121. package/dist/assets/components/onboarding/UserSetupLight.d.ts +0 -3
  122. package/dist/assets/components/onboarding/UserSetupLight.js +0 -1024
  123. package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.d.ts +0 -3
  124. package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.js +0 -466
  125. package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.d.ts +0 -3
  126. package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.js +0 -460
  127. package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.d.ts +0 -3
  128. package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.js +0 -336
  129. package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.d.ts +0 -3
  130. package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.js +0 -336
  131. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.d.ts +0 -3
  132. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.js +0 -153
  133. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.d.ts +0 -3
  134. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.js +0 -153
  135. package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.d.ts +0 -3
  136. package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.js +0 -117
  137. package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.d.ts +0 -3
  138. package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.js +0 -117
  139. package/dist/assets/components/projects/MappingMethodBlankDark.d.ts +0 -3
  140. package/dist/assets/components/projects/MappingMethodBlankDark.js +0 -150
  141. package/dist/assets/components/projects/MappingMethodBlankDarkHovered.d.ts +0 -3
  142. package/dist/assets/components/projects/MappingMethodBlankDarkHovered.js +0 -150
  143. package/dist/assets/components/projects/MappingMethodBlankLight.d.ts +0 -3
  144. package/dist/assets/components/projects/MappingMethodBlankLight.js +0 -150
  145. package/dist/assets/components/projects/MappingMethodBlankLightHovered.d.ts +0 -3
  146. package/dist/assets/components/projects/MappingMethodBlankLightHovered.js +0 -150
  147. package/dist/assets/components/projects/MappingMethodJsonDark.d.ts +0 -3
  148. package/dist/assets/components/projects/MappingMethodJsonDark.js +0 -90
  149. package/dist/assets/components/projects/MappingMethodJsonDarkHovered.d.ts +0 -3
  150. package/dist/assets/components/projects/MappingMethodJsonDarkHovered.js +0 -90
  151. package/dist/assets/components/projects/MappingMethodJsonLight.d.ts +0 -3
  152. package/dist/assets/components/projects/MappingMethodJsonLight.js +0 -90
  153. package/dist/assets/components/projects/MappingMethodJsonLightHovered.d.ts +0 -3
  154. package/dist/assets/components/projects/MappingMethodJsonLightHovered.js +0 -90
  155. package/dist/assets/components/projects/ProjectsEmptyStateDark.d.ts +0 -3
  156. package/dist/assets/components/projects/ProjectsEmptyStateDark.js +0 -454
  157. package/dist/assets/components/projects/ProjectsEmptyStateLight.d.ts +0 -3
  158. package/dist/assets/components/projects/ProjectsEmptyStateLight.js +0 -456
  159. package/dist/assets/components/root/CreateProjectActionCardDark.d.ts +0 -3
  160. package/dist/assets/components/root/CreateProjectActionCardDark.js +0 -1796
  161. package/dist/assets/components/root/CreateProjectActionCardDarkHovered.d.ts +0 -3
  162. package/dist/assets/components/root/CreateProjectActionCardDarkHovered.js +0 -1796
  163. package/dist/assets/components/root/CreateProjectActionCardLight.d.ts +0 -3
  164. package/dist/assets/components/root/CreateProjectActionCardLight.js +0 -1786
  165. package/dist/assets/components/root/CreateProjectActionCardLightHovered.d.ts +0 -3
  166. package/dist/assets/components/root/CreateProjectActionCardLightHovered.js +0 -1786
  167. package/dist/assets/components/root/CreateSourceActionCardDark.d.ts +0 -3
  168. package/dist/assets/components/root/CreateSourceActionCardDark.js +0 -879
  169. package/dist/assets/components/root/CreateSourceActionCardDarkHovered.d.ts +0 -3
  170. package/dist/assets/components/root/CreateSourceActionCardDarkHovered.js +0 -879
  171. package/dist/assets/components/root/CreateSourceActionCardLight.d.ts +0 -3
  172. package/dist/assets/components/root/CreateSourceActionCardLight.js +0 -889
  173. package/dist/assets/components/root/CreateSourceActionCardLightHovered.d.ts +0 -3
  174. package/dist/assets/components/root/CreateSourceActionCardLightHovered.js +0 -889
  175. package/dist/assets/components/sources/AttioIcon.d.ts +0 -3
  176. package/dist/assets/components/sources/AttioIcon.js +0 -11
  177. package/dist/assets/components/sources/BigquerySourceIcon.d.ts +0 -3
  178. package/dist/assets/components/sources/BigquerySourceIcon.js +0 -39
  179. package/dist/assets/components/sources/BrowserbaseSourceIcon.d.ts +0 -3
  180. package/dist/assets/components/sources/BrowserbaseSourceIcon.js +0 -35
  181. package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.d.ts +0 -3
  182. package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.js +0 -13
  183. package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.d.ts +0 -3
  184. package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.js +0 -13
  185. package/dist/assets/components/sources/ConfluenceSourceIcon.d.ts +0 -3
  186. package/dist/assets/components/sources/ConfluenceSourceIcon.js +0 -30
  187. package/dist/assets/components/sources/GithubSourceIcon.d.ts +0 -3
  188. package/dist/assets/components/sources/GithubSourceIcon.js +0 -27
  189. package/dist/assets/components/sources/GoogleDriveIcon.d.ts +0 -3
  190. package/dist/assets/components/sources/GoogleDriveIcon.js +0 -45
  191. package/dist/assets/components/sources/HubspotSourceIcon.d.ts +0 -3
  192. package/dist/assets/components/sources/HubspotSourceIcon.js +0 -14
  193. package/dist/assets/components/sources/JiraSourceIcon.d.ts +0 -3
  194. package/dist/assets/components/sources/JiraSourceIcon.js +0 -54
  195. package/dist/assets/components/sources/LinearSourceIcon.d.ts +0 -3
  196. package/dist/assets/components/sources/LinearSourceIcon.js +0 -14
  197. package/dist/assets/components/sources/MysqlLogoSourceIconDark.d.ts +0 -3
  198. package/dist/assets/components/sources/MysqlLogoSourceIconDark.js +0 -17
  199. package/dist/assets/components/sources/NetsuiteSourceIcon.d.ts +0 -3
  200. package/dist/assets/components/sources/NetsuiteSourceIcon.js +0 -32
  201. package/dist/assets/components/sources/NotionIcon.d.ts +0 -3
  202. package/dist/assets/components/sources/NotionIcon.js +0 -20
  203. package/dist/assets/components/sources/PostgresqlIcon.d.ts +0 -3
  204. package/dist/assets/components/sources/PostgresqlIcon.js +0 -61
  205. package/dist/assets/components/sources/S3Icon.d.ts +0 -3
  206. package/dist/assets/components/sources/S3Icon.js +0 -76
  207. package/dist/assets/components/sources/SalesforceSourceIcon.d.ts +0 -3
  208. package/dist/assets/components/sources/SalesforceSourceIcon.js +0 -23
  209. package/dist/assets/components/sources/SlackIcon.d.ts +0 -3
  210. package/dist/assets/components/sources/SlackIcon.js +0 -32
  211. package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.d.ts +0 -3
  212. package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.js +0 -14
  213. package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.d.ts +0 -3
  214. package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.js +0 -14
  215. package/dist/assets/components/sources/WikipediaSourceIcon.d.ts +0 -3
  216. package/dist/assets/components/sources/WikipediaSourceIcon.js +0 -1490
  217. package/dist/avatar/AvatarEmpty.d.ts +0 -7
  218. package/dist/avatar/AvatarEmpty.js +0 -99
  219. package/dist/avatar/types.d.ts +0 -5
  220. package/dist/avatar/types.js +0 -9
  221. package/dist/charts/utils.d.ts +0 -29
  222. package/dist/charts/utils.js +0 -62
  223. package/dist/icons/BackIcon.d.ts +0 -3
  224. package/dist/icons/BackIcon.js +0 -13
  225. package/dist/icons/CloseIcon.d.ts +0 -3
  226. package/dist/icons/CloseIcon.js +0 -13
  227. package/dist/icons/CreateIcon.d.ts +0 -3
  228. package/dist/icons/CreateIcon.js +0 -13
  229. package/dist/icons/ForwardIcon.d.ts +0 -3
  230. package/dist/icons/ForwardIcon.js +0 -13
  231. package/dist/icons/HelpIcon.d.ts +0 -3
  232. package/dist/icons/HelpIcon.js +0 -14
  233. package/dist/icons/ProjectsIcon.d.ts +0 -3
  234. package/dist/icons/ProjectsIcon.js +0 -12
  235. package/dist/icons/SearchIcon.d.ts +0 -3
  236. package/dist/icons/SearchIcon.js +0 -12
  237. package/dist/icons/SourcesIcon.d.ts +0 -3
  238. package/dist/icons/SourcesIcon.js +0 -12
  239. package/dist/icons/TextIcon.d.ts +0 -4
  240. package/dist/icons/TextIcon.js +0 -22
  241. package/dist/icons/WebScrapeIcon.d.ts +0 -4
  242. package/dist/icons/WebScrapeIcon.js +0 -22
  243. package/dist/icons/WebhookIcon.d.ts +0 -4
  244. package/dist/icons/WebhookIcon.js +0 -22
  245. package/dist/icons/sources/AttioLogomark.d.ts +0 -4
  246. package/dist/icons/sources/AttioLogomark.js +0 -8
  247. package/dist/icons/sources/BrowserbaseLogomark.d.ts +0 -4
  248. package/dist/icons/sources/BrowserbaseLogomark.js +0 -8
  249. package/dist/icons/sources/ClickhouseLogomark.d.ts +0 -4
  250. package/dist/icons/sources/ClickhouseLogomark.js +0 -16
  251. package/dist/icons/sources/ConfluenceLogomark.d.ts +0 -4
  252. package/dist/icons/sources/ConfluenceLogomark.js +0 -8
  253. package/dist/icons/sources/GithubLogomark.d.ts +0 -4
  254. package/dist/icons/sources/GithubLogomark.js +0 -8
  255. package/dist/icons/sources/GoogleBigqueryLogomark.d.ts +0 -4
  256. package/dist/icons/sources/GoogleBigqueryLogomark.js +0 -8
  257. package/dist/icons/sources/GoogleDriveLogomark.d.ts +0 -4
  258. package/dist/icons/sources/GoogleDriveLogomark.js +0 -8
  259. package/dist/icons/sources/HubspotLogomark.d.ts +0 -4
  260. package/dist/icons/sources/HubspotLogomark.js +0 -8
  261. package/dist/icons/sources/JiraLogomark.d.ts +0 -4
  262. package/dist/icons/sources/JiraLogomark.js +0 -8
  263. package/dist/icons/sources/LinearLogomark.d.ts +0 -4
  264. package/dist/icons/sources/LinearLogomark.js +0 -8
  265. package/dist/icons/sources/MySQLLogomark.d.ts +0 -4
  266. package/dist/icons/sources/MySQLLogomark.js +0 -8
  267. package/dist/icons/sources/NetsuiteLogomark.d.ts +0 -4
  268. package/dist/icons/sources/NetsuiteLogomark.js +0 -8
  269. package/dist/icons/sources/NotionLogomark.d.ts +0 -4
  270. package/dist/icons/sources/NotionLogomark.js +0 -8
  271. package/dist/icons/sources/PostgresLogomark.d.ts +0 -4
  272. package/dist/icons/sources/PostgresLogomark.js +0 -8
  273. package/dist/icons/sources/S3Logomark.d.ts +0 -4
  274. package/dist/icons/sources/S3Logomark.js +0 -8
  275. package/dist/icons/sources/SalesforceLogomark.d.ts +0 -4
  276. package/dist/icons/sources/SalesforceLogomark.js +0 -8
  277. package/dist/icons/sources/SlackLogoIconmark.d.ts +0 -4
  278. package/dist/icons/sources/SlackLogoIconmark.js +0 -8
  279. package/dist/icons/sources/SnowflakeLogomark.d.ts +0 -4
  280. package/dist/icons/sources/SnowflakeLogomark.js +0 -16
  281. package/dist/icons/sources/WikipediaLogomark.d.ts +0 -4
  282. package/dist/icons/sources/WikipediaLogomark.js +0 -8
  283. package/dist/spreadsheet/InfiniteSpreadsheet.d.ts +0 -3
  284. package/dist/spreadsheet/InfiniteSpreadsheet.js +0 -265
  285. package/dist/spreadsheet/SpreadsheetAddColumnButton.d.ts +0 -6
  286. package/dist/spreadsheet/SpreadsheetAddColumnButton.js +0 -32
  287. package/dist/spreadsheet/SpreadsheetCell.js +0 -115
  288. package/dist/spreadsheet/SpreadsheetHeaderCell.d.ts +0 -18
  289. package/dist/spreadsheet/SpreadsheetHeaderCell.js +0 -141
  290. package/dist/spreadsheet/SpreadsheetRow.d.ts +0 -21
  291. package/dist/spreadsheet/SpreadsheetRow.js +0 -68
  292. package/dist/spreadsheet/SpreadsheetRowActionCell.js +0 -78
  293. package/dist/spreadsheet/hooks/useColumnResize.d.ts +0 -6
  294. package/dist/spreadsheet/hooks/useColumnResize.js +0 -46
  295. package/dist/spreadsheet/types.d.ts +0 -92
  296. package/dist/spreadsheet/types.js +0 -21
  297. /package/dist/{spreadsheet → table}/SpreadsheetCellEditor.d.ts +0 -0
@@ -0,0 +1,136 @@
1
+ //#region src/charts/types.ts
2
+ /**
3
+ * Shared types for the chart components (`BarChart`, `LineChart`, `PieChart`).
4
+ *
5
+ * Every data type is generic over its key unions, and the inference is
6
+ * deliberately one-directional: `TMetric` comes from the keys of the `series`
7
+ * record and from nowhere else, with {@link NoInfer} applied to every
8
+ * data-shaped prop.
9
+ *
10
+ * That asymmetry is what makes the guarantees real. Were `TMetric` also
11
+ * inferred from the data, an inline `{ metric: "revenue" }` would widen to
12
+ * `string`, TypeScript would pick the supertype, and every check below would
13
+ * quietly become a no-op — type safety that looks present but is not.
14
+ *
15
+ * ```ts
16
+ * <BarChart
17
+ * series={{
18
+ * revenue: { label: "Revenue" },
19
+ * cost: { label: "Cost" },
20
+ * }}
21
+ * groups={[
22
+ * { label: "Q1", bars: [{ metric: "revenu", components: [] }] },
23
+ * // ^ Type '"revenu"' is not assignable to
24
+ * // type '"revenue" | "cost"'.
25
+ * ]}
26
+ * />
27
+ * ```
28
+ *
29
+ * The same union then makes aggregates exhaustive, spell-checks legend and
30
+ * ordering props, and narrows callback parameters for `ts-pattern`.
31
+ */
32
+ /**
33
+ * Semantic color slot for a series, resolved against the active theme at render
34
+ * time by `resolveChartPaletteColor` in `chartTheme.ts`.
35
+ *
36
+ * Deliberately an enum of slots rather than a hex string: consumer data should
37
+ * never carry raw color, and every rendered color has to come from
38
+ * `theme.color.*` so both themes stay correct.
39
+ */
40
+ var ChartPalette = /* @__PURE__ */ function(ChartPalette) {
41
+ ChartPalette["PURPLE"] = "PURPLE";
42
+ ChartPalette["PINK"] = "PINK";
43
+ ChartPalette["BLUE"] = "BLUE";
44
+ ChartPalette["TEAL"] = "TEAL";
45
+ ChartPalette["LIME"] = "LIME";
46
+ ChartPalette["ORANGE"] = "ORANGE";
47
+ ChartPalette["YELLOW"] = "YELLOW";
48
+ ChartPalette["GREEN"] = "GREEN";
49
+ ChartPalette["RED"] = "RED";
50
+ return ChartPalette;
51
+ }({});
52
+ /**
53
+ * Built-in value formats. Supplies an `Intl`-based default for axis ticks,
54
+ * value labels and tooltip rows so callers don't have to write the same
55
+ * formatter three times.
56
+ *
57
+ * A `valueFormatter` prop always wins over this when both are given.
58
+ */
59
+ var ChartValueUnit = /* @__PURE__ */ function(ChartValueUnit) {
60
+ /** Locale-grouped integer, e.g. `1,250`. */
61
+ ChartValueUnit["PLAIN"] = "PLAIN";
62
+ /** Locale currency with no decimals, e.g. `$1,250`. */
63
+ ChartValueUnit["CURRENCY"] = "CURRENCY";
64
+ /** Percentage of a 0–100 value, e.g. `42%`. */
65
+ ChartValueUnit["PERCENT"] = "PERCENT";
66
+ /** Abbreviated magnitude, e.g. `1.3K`, `4.2M`. */
67
+ ChartValueUnit["COMPACT"] = "COMPACT";
68
+ return ChartValueUnit;
69
+ }({});
70
+ /** How the category axis copes when labels outgrow their slots. */
71
+ var ChartCategoryLabelMode = /* @__PURE__ */ function(ChartCategoryLabelMode) {
72
+ /** Render every label that fits; otherwise show every nth. The default. */
73
+ ChartCategoryLabelMode["AUTO"] = "AUTO";
74
+ /** Render every label, ellipsizing any that overflow its slot. */
75
+ ChartCategoryLabelMode["TRUNCATE"] = "TRUNCATE";
76
+ /** Render every label unconditionally, overlap included. */
77
+ ChartCategoryLabelMode["ALL"] = "ALL";
78
+ return ChartCategoryLabelMode;
79
+ }({});
80
+ /**
81
+ * Emphasis level of a rendered mark.
82
+ *
83
+ * Travels to the DOM as a `data-state` attribute rather than a styled-component
84
+ * prop: `@linaria/react` skips prop filtering entirely for SVG tags (its
85
+ * `allTagsSet` is built with a missing spread, so `has('rect')` is false and
86
+ * `propsAsIs` turns on), which would forward a `$`-prefixed prop straight to the
87
+ * DOM and trigger a React warning.
88
+ */
89
+ var ChartMarkState = /* @__PURE__ */ function(ChartMarkState) {
90
+ /** Full strength — the default, and the hovered or pinned category. */
91
+ ChartMarkState["ACTIVE"] = "active";
92
+ /** Softened, for categories other than the hovered one. */
93
+ ChartMarkState["MUTED"] = "muted";
94
+ /** Furthest back, for categories outside a pinned one. */
95
+ ChartMarkState["FADED"] = "faded";
96
+ return ChartMarkState;
97
+ }({});
98
+ /** Which pair of a rectangle's corners carries the radius. */
99
+ var BarCorners = /* @__PURE__ */ function(BarCorners) {
100
+ /** Cap for a bar growing up from the baseline. */
101
+ BarCorners["TOP"] = "TOP";
102
+ /** Cap for a bar growing down from the baseline. */
103
+ BarCorners["BOTTOM"] = "BOTTOM";
104
+ /** Interior stack segment — square on both ends. */
105
+ BarCorners["NONE"] = "NONE";
106
+ return BarCorners;
107
+ }({});
108
+ /**
109
+ * How bar values are scaled before rendering.
110
+ *
111
+ * Note there is no grouped-vs-stacked mode: with the group → bar → component
112
+ * hierarchy, several `bars` in a group render side by side and several
113
+ * `components` in a bar render on top of each other, so a chart can be grouped
114
+ * and stacked at the same time.
115
+ */
116
+ var BarChartNormalization = /* @__PURE__ */ function(BarChartNormalization) {
117
+ /** Plot raw values. */
118
+ BarChartNormalization["NONE"] = "NONE";
119
+ /** Scale each bar's components to fill the axis — a 100% stacked chart. */
120
+ BarChartNormalization["PERCENT"] = "PERCENT";
121
+ return BarChartNormalization;
122
+ }({});
123
+ /** How the segments between points are interpolated. */
124
+ var LineChartCurve = /* @__PURE__ */ function(LineChartCurve) {
125
+ /** Straight segments. */
126
+ LineChartCurve["LINEAR"] = "LINEAR";
127
+ /** Monotone cubic — smooth without overshooting the data. */
128
+ LineChartCurve["SMOOTH"] = "SMOOTH";
129
+ /** Right-angled steps. */
130
+ LineChartCurve["STEP"] = "STEP";
131
+ return LineChartCurve;
132
+ }({});
133
+ /** React key used for the bucket that absorbs slices below the fold threshold. */
134
+ var AGGREGATED_SLICE_KEY = "__other__";
135
+ //#endregion
136
+ export { AGGREGATED_SLICE_KEY, BarChartNormalization, BarCorners, ChartCategoryLabelMode, ChartMarkState, ChartPalette, ChartValueUnit, LineChartCurve };
@@ -0,0 +1,40 @@
1
+ import type { ChartMargin } from "./types";
2
+ interface UseChartDimensionsOptions {
3
+ /**
4
+ * The element to measure.
5
+ *
6
+ * Owned by the caller rather than returned from here: a hook that hands back
7
+ * a ref inside its result object reads as a ref access during render, both to
8
+ * the `react-hooks/refs` lint rule and to anyone reviewing the call site.
9
+ */
10
+ containerRef: React.RefObject<HTMLElement | null>;
11
+ width?: number;
12
+ height?: number;
13
+ fillWidth?: boolean;
14
+ /**
15
+ * Take the height from the measured box rather than a prop.
16
+ *
17
+ * Requires an ancestor with a definite height — see {@link ChartSize}. The
18
+ * measured element is the *plot box*, not the chart root, so the legend is
19
+ * already excluded by flexbox and nothing here has to subtract it.
20
+ */
21
+ fillHeight?: boolean;
22
+ aspectRatio?: number;
23
+ margin?: Partial<ChartMargin>;
24
+ }
25
+ export interface ChartDimensions {
26
+ width: number;
27
+ height: number;
28
+ plotWidth: number;
29
+ plotHeight: number;
30
+ margin: ChartMargin;
31
+ /** False until the box has usable dimensions; guard mark rendering on it. */
32
+ isMeasured: boolean;
33
+ /** Handed to the plot box so it reserves space before measurement lands. */
34
+ reservedHeight?: number;
35
+ reservedAspectRatio?: number;
36
+ /** Makes the plot box claim the flex track instead of reserving a height. */
37
+ fillHeight?: boolean;
38
+ }
39
+ export declare function useChartDimensions({ containerRef, width, height, fillWidth, fillHeight, aspectRatio, margin: marginOverride, }: UseChartDimensionsOptions): ChartDimensions;
40
+ export {};
@@ -0,0 +1,53 @@
1
+ import { useElementClientSize } from "../hooks/useElementClientSize.js";
2
+ import { getPlotDimensions, resolveMargin } from "./chartScales.js";
3
+ import { useEffect, useMemo } from "react";
4
+ //#region src/charts/useChartDimensions.ts
5
+ function useChartDimensions({ containerRef, width, height, fillWidth = false, fillHeight = false, aspectRatio, margin: marginOverride }) {
6
+ const { width: measuredWidth, height: measuredHeight } = useElementClientSize(containerRef);
7
+ const resolvedWidth = fillWidth ? measuredWidth ?? 0 : width ?? 0;
8
+ const resolvedHeight = fillHeight ? measuredHeight ?? 0 : aspectRatio ? resolvedWidth / aspectRatio : height ?? 0;
9
+ const { top: marginTop, right: marginRight, bottom: marginBottom, left: marginLeft } = marginOverride ?? {};
10
+ const margin = useMemo(() => resolveMargin({
11
+ top: marginTop,
12
+ right: marginRight,
13
+ bottom: marginBottom,
14
+ left: marginLeft
15
+ }), [
16
+ marginTop,
17
+ marginRight,
18
+ marginBottom,
19
+ marginLeft
20
+ ]);
21
+ const { plotWidth, plotHeight } = useMemo(() => getPlotDimensions(resolvedWidth, resolvedHeight, margin), [
22
+ resolvedWidth,
23
+ resolvedHeight,
24
+ margin
25
+ ]);
26
+ useEffect(() => {
27
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "production") return;
28
+ if (!fillHeight || measuredHeight === void 0 || measuredHeight > 0) return;
29
+ console.warn("[@galaxy-io/dls] A chart with `fillHeight` measured 0px tall and will not render. `fillHeight` takes its height from the container, so an ancestor needs a definite height — an explicit height, a flex or grid track, or absolute positioning. Use `height` or `aspectRatio` instead if the container is sized by its content.");
30
+ }, [fillHeight, measuredHeight]);
31
+ return useMemo(() => ({
32
+ width: resolvedWidth,
33
+ height: resolvedHeight,
34
+ plotWidth,
35
+ plotHeight,
36
+ margin,
37
+ isMeasured: resolvedWidth > 0 && resolvedHeight > 0,
38
+ reservedHeight: fillHeight || aspectRatio ? void 0 : height,
39
+ reservedAspectRatio: fillHeight ? void 0 : aspectRatio,
40
+ fillHeight
41
+ }), [
42
+ resolvedWidth,
43
+ resolvedHeight,
44
+ plotWidth,
45
+ plotHeight,
46
+ margin,
47
+ aspectRatio,
48
+ height,
49
+ fillHeight
50
+ ]);
51
+ }
52
+ //#endregion
53
+ export { useChartDimensions };
@@ -0,0 +1,19 @@
1
+ import type { ChartLabelFormatter, ChartValueFormatter, ChartValueUnit } from "./types";
2
+ interface UseChartFormattersOptions {
3
+ valueFormatter?: ChartValueFormatter;
4
+ valueUnit?: ChartValueUnit;
5
+ labelFormatter?: ChartLabelFormatter;
6
+ }
7
+ export interface ChartFormatters {
8
+ formatValue: ChartValueFormatter;
9
+ formatLabel: ChartLabelFormatter;
10
+ }
11
+ /**
12
+ * Resolves the value and label formatters once per chart.
13
+ *
14
+ * Doing this centrally is what keeps axis ticks, value labels and tooltip rows
15
+ * from drifting apart — the recurring failure when each call site formats for
16
+ * itself.
17
+ */
18
+ export declare function useChartFormatters({ valueFormatter, valueUnit, labelFormatter, }: UseChartFormattersOptions): ChartFormatters;
19
+ export {};
@@ -0,0 +1,20 @@
1
+ import { resolveLabelFormatter, resolveValueFormatter } from "./chartFormat.js";
2
+ import { useMemo } from "react";
3
+ //#region src/charts/useChartFormatters.ts
4
+ /**
5
+ * Resolves the value and label formatters once per chart.
6
+ *
7
+ * Doing this centrally is what keeps axis ticks, value labels and tooltip rows
8
+ * from drifting apart — the recurring failure when each call site formats for
9
+ * itself.
10
+ */
11
+ function useChartFormatters({ valueFormatter, valueUnit, labelFormatter }) {
12
+ const formatValue = useMemo(() => resolveValueFormatter(valueFormatter, valueUnit), [valueFormatter, valueUnit]);
13
+ const formatLabel = useMemo(() => resolveLabelFormatter(labelFormatter), [labelFormatter]);
14
+ return useMemo(() => ({
15
+ formatValue,
16
+ formatLabel
17
+ }), [formatValue, formatLabel]);
18
+ }
19
+ //#endregion
20
+ export { useChartFormatters };
@@ -0,0 +1,71 @@
1
+ import { ChartMarkState } from "./types";
2
+ /**
3
+ * Hover and pin interaction shared by every chart.
4
+ *
5
+ * Two independent axes:
6
+ *
7
+ * - **Category** — a numeric index along the plot. Hovering previews, clicking
8
+ * pins so the tooltip survives the pointer leaving.
9
+ * - **Series** — a legend key. Hovering isolates that series, clicking pins the
10
+ * isolation.
11
+ *
12
+ * Both live here rather than one of them in the charts, so there is a single
13
+ * `isEngaged` boolean. That matters more than it looks: `ChartPlotGroup` uses it
14
+ * to cancel a 300ms restore delay, and a second hover source that didn't feed it
15
+ * would sit through that delay before muting anything and feel broken.
16
+ *
17
+ * Escape or a click on the plot background clears both pins.
18
+ */
19
+ interface UseChartInteractionOptions {
20
+ /** Number of hoverable categories. A shrinking count clears stale indices. */
21
+ categoryCount: number;
22
+ /** Legend keys currently rendered. A key that disappears clears a stale pin. */
23
+ seriesKeys?: string[];
24
+ /** Suppress all interaction — used while loading and when the tooltip is off. */
25
+ disabled?: boolean;
26
+ /** Notified when the pinned category changes. */
27
+ onPinnedChange?: (index: number | null) => void;
28
+ /** Notified when the pinned series changes. */
29
+ onPinnedSeriesChange?: (seriesKey: string | null) => void;
30
+ }
31
+ interface MarkStateArgs {
32
+ /** Omit for marks that belong to no particular category, such as a line. */
33
+ categoryIndex?: number;
34
+ /** Omit for marks that belong to no particular series. */
35
+ seriesKey?: string;
36
+ }
37
+ export interface ChartInteraction {
38
+ hoveredIndex: number | null;
39
+ pinnedIndex: number | null;
40
+ /** Pinned wins over hovered — this is what the tooltip follows. */
41
+ activeIndex: number | null;
42
+ hoveredSeriesKey: string | null;
43
+ pinnedSeriesKey: string | null;
44
+ /** Pinned wins over hovered, matching the category axis. */
45
+ activeSeriesKey: string | null;
46
+ /** True while *either* axis is engaged; cancels the mark restore delay. */
47
+ isEngaged: boolean;
48
+ /**
49
+ * Emphasis for one mark, composed from both axes.
50
+ *
51
+ * The grammar is inherited from the reference and is the opposite of the
52
+ * obvious one: engaging something does not brighten it, it softens everything
53
+ * else. With something pinned, the unrelated marks recede further still, so
54
+ * the pinned mark and the one under the pointer stay legible against them.
55
+ *
56
+ * A mark has to survive *both* filters to stay active — the two axes
57
+ * intersect rather than override, so pinning a series and then hovering a
58
+ * category leaves only their overlap lit.
59
+ */
60
+ getMarkState: (args: MarkStateArgs) => ChartMarkState;
61
+ onCategoryEnter: (categoryIndex: number) => void;
62
+ onCategoryLeave: () => void;
63
+ onCategoryClick: (categoryIndex: number) => void;
64
+ onSeriesEnter: (seriesKey: string) => void;
65
+ onSeriesLeave: () => void;
66
+ onSeriesClick: (seriesKey: string) => void;
67
+ /** Attach to the plot backdrop; clears both pins. */
68
+ onBackdropClick: () => void;
69
+ }
70
+ export declare function useChartInteraction({ categoryCount, seriesKeys, disabled, onPinnedChange, onPinnedSeriesChange, }: UseChartInteractionOptions): ChartInteraction;
71
+ export {};
@@ -0,0 +1,130 @@
1
+ import { ChartMarkState } from "./types.js";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ //#region src/charts/useChartInteraction.ts
4
+ /** How far back a state sits, so two axes can be compared and the worse taken. */
5
+ var severity = (state) => {
6
+ if (state === ChartMarkState.ACTIVE) return 0;
7
+ return state === ChartMarkState.MUTED ? 1 : 2;
8
+ };
9
+ function useChartInteraction({ categoryCount, seriesKeys, disabled = false, onPinnedChange, onPinnedSeriesChange }) {
10
+ const [hoveredIndex, setHoveredIndex] = useState(null);
11
+ const [pinnedIndex, setPinnedIndex] = useState(null);
12
+ const [hoveredSeriesKey, setHoveredSeriesKey] = useState(null);
13
+ const [pinnedSeriesKey, setPinnedSeriesKey] = useState(null);
14
+ const onPinnedChangeRef = useRef(onPinnedChange);
15
+ const onPinnedSeriesChangeRef = useRef(onPinnedSeriesChange);
16
+ useEffect(() => {
17
+ onPinnedChangeRef.current = onPinnedChange;
18
+ onPinnedSeriesChangeRef.current = onPinnedSeriesChange;
19
+ });
20
+ const safeHovered = hoveredIndex !== null && hoveredIndex < categoryCount ? hoveredIndex : null;
21
+ const safePinned = pinnedIndex !== null && pinnedIndex < categoryCount ? pinnedIndex : null;
22
+ const isKnownSeries = (key) => key !== null && (seriesKeys === void 0 || seriesKeys.includes(key));
23
+ const safeHoveredSeries = isKnownSeries(hoveredSeriesKey) ? hoveredSeriesKey : null;
24
+ const safePinnedSeries = isKnownSeries(pinnedSeriesKey) ? pinnedSeriesKey : null;
25
+ const clearPins = useCallback(() => {
26
+ setPinnedIndex(null);
27
+ setPinnedSeriesKey(null);
28
+ onPinnedChangeRef.current?.(null);
29
+ onPinnedSeriesChangeRef.current?.(null);
30
+ }, []);
31
+ const hasPin = safePinned !== null || safePinnedSeries !== null;
32
+ useEffect(() => {
33
+ if (disabled || !hasPin) return;
34
+ const onKeyDown = (event) => {
35
+ if (event.key === "Escape") clearPins();
36
+ };
37
+ window.addEventListener("keydown", onKeyDown);
38
+ return () => window.removeEventListener("keydown", onKeyDown);
39
+ }, [
40
+ disabled,
41
+ hasPin,
42
+ clearPins
43
+ ]);
44
+ const onCategoryEnter = useCallback((categoryIndex) => {
45
+ if (disabled) return;
46
+ setHoveredIndex(categoryIndex);
47
+ }, [disabled]);
48
+ const onCategoryLeave = useCallback(() => {
49
+ if (disabled) return;
50
+ setHoveredIndex(null);
51
+ }, [disabled]);
52
+ const onCategoryClick = useCallback((categoryIndex) => {
53
+ if (disabled) return;
54
+ const next = pinnedIndex === categoryIndex ? null : categoryIndex;
55
+ setPinnedIndex(next);
56
+ onPinnedChangeRef.current?.(next);
57
+ }, [disabled, pinnedIndex]);
58
+ const onSeriesEnter = useCallback((seriesKey) => {
59
+ setHoveredSeriesKey(seriesKey);
60
+ }, []);
61
+ const onSeriesLeave = useCallback(() => {
62
+ setHoveredSeriesKey(null);
63
+ }, []);
64
+ const onSeriesClick = useCallback((seriesKey) => {
65
+ const next = pinnedSeriesKey === seriesKey ? null : seriesKey;
66
+ setPinnedSeriesKey(next);
67
+ if (next === null) setHoveredSeriesKey(null);
68
+ onPinnedSeriesChangeRef.current?.(next);
69
+ }, [pinnedSeriesKey]);
70
+ const getMarkState = useCallback(({ categoryIndex, seriesKey }) => {
71
+ const categoryState = (() => {
72
+ if (categoryIndex === void 0) return ChartMarkState.ACTIVE;
73
+ if (safePinned !== null) {
74
+ if (categoryIndex === safePinned) return ChartMarkState.ACTIVE;
75
+ if (categoryIndex === safeHovered) return ChartMarkState.MUTED;
76
+ return ChartMarkState.FADED;
77
+ }
78
+ if (safeHovered !== null) return categoryIndex === safeHovered ? ChartMarkState.ACTIVE : ChartMarkState.MUTED;
79
+ return ChartMarkState.ACTIVE;
80
+ })();
81
+ const seriesState = (() => {
82
+ if (seriesKey === void 0) return ChartMarkState.ACTIVE;
83
+ if (safePinnedSeries !== null) {
84
+ if (seriesKey === safePinnedSeries) return ChartMarkState.ACTIVE;
85
+ if (seriesKey === safeHoveredSeries) return ChartMarkState.MUTED;
86
+ return ChartMarkState.FADED;
87
+ }
88
+ if (safeHoveredSeries !== null) return seriesKey === safeHoveredSeries ? ChartMarkState.ACTIVE : ChartMarkState.MUTED;
89
+ return ChartMarkState.ACTIVE;
90
+ })();
91
+ return severity(categoryState) >= severity(seriesState) ? categoryState : seriesState;
92
+ }, [
93
+ safePinned,
94
+ safeHovered,
95
+ safePinnedSeries,
96
+ safeHoveredSeries
97
+ ]);
98
+ return useMemo(() => ({
99
+ hoveredIndex: safeHovered,
100
+ pinnedIndex: safePinned,
101
+ activeIndex: safePinned ?? safeHovered,
102
+ hoveredSeriesKey: safeHoveredSeries,
103
+ pinnedSeriesKey: safePinnedSeries,
104
+ activeSeriesKey: safePinnedSeries ?? safeHoveredSeries,
105
+ isEngaged: safePinned !== null || safeHovered !== null || safePinnedSeries !== null || safeHoveredSeries !== null,
106
+ getMarkState,
107
+ onCategoryEnter,
108
+ onCategoryLeave,
109
+ onCategoryClick,
110
+ onSeriesEnter,
111
+ onSeriesLeave,
112
+ onSeriesClick,
113
+ onBackdropClick: clearPins
114
+ }), [
115
+ safeHovered,
116
+ safePinned,
117
+ safeHoveredSeries,
118
+ safePinnedSeries,
119
+ getMarkState,
120
+ onCategoryEnter,
121
+ onCategoryLeave,
122
+ onCategoryClick,
123
+ onSeriesEnter,
124
+ onSeriesLeave,
125
+ onSeriesClick,
126
+ clearPins
127
+ ]);
128
+ }
129
+ //#endregion
130
+ export { useChartInteraction };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Tooltip placement with edge collision handling.
3
+ *
4
+ * Computed in JS rather than CSS because clamping needs a percentage of the
5
+ * tooltip's own size measured against a percentage of the container's, and
6
+ * `min()`/`max()` cannot resolve two different percentage bases in one
7
+ * expression. Any CSS-only attempt works until the first long label.
8
+ */
9
+ interface UseChartTooltipPositionOptions {
10
+ /** Anchor in container coordinates. */
11
+ anchorX: number;
12
+ anchorY: number;
13
+ /** The box to stay inside. */
14
+ containerWidth: number;
15
+ containerHeight: number;
16
+ /** Half-width of the anchored category, so the tooltip can sit beside it. */
17
+ anchorHalfWidth?: number;
18
+ /**
19
+ * An x coordinate to move away from, instead of flipping on the container's
20
+ * midline.
21
+ *
22
+ * Radial charts need this. Their anchor already sits on the arc's outer edge,
23
+ * so "which half of the container am I in" points the tooltip back over the
24
+ * middle of the chart — across the very slices it describes, and across any
25
+ * donut-hole content. Passing the centre pushes it outward instead.
26
+ */
27
+ placeAwayFromX?: number;
28
+ /**
29
+ * Where the tooltip sits vertically relative to its anchor.
30
+ *
31
+ * `ABOVE` suits an anchor that marks the top of something (a bar, the highest
32
+ * point in a column). `CENTERED` suits an anchor that marks a position rather
33
+ * than a top, such as a point on an arc.
34
+ */
35
+ verticalAlign?: ChartTooltipVerticalAlign;
36
+ }
37
+ export declare enum ChartTooltipVerticalAlign {
38
+ ABOVE = "ABOVE",
39
+ CENTERED = "CENTERED"
40
+ }
41
+ export interface ChartTooltipPosition {
42
+ /** Attach to the tooltip element so it can be measured. */
43
+ tooltipRef: React.RefObject<HTMLDivElement>;
44
+ x: number;
45
+ y: number;
46
+ /**
47
+ * False for the first frame after the content changes, while the measured
48
+ * size is still stale. Gating visibility on it hides the reflow.
49
+ */
50
+ isMeasured: boolean;
51
+ }
52
+ export declare function useChartTooltipPosition({ anchorX, anchorY, containerWidth, containerHeight, anchorHalfWidth, placeAwayFromX, verticalAlign, }: UseChartTooltipPositionOptions): ChartTooltipPosition;
53
+ export {};
@@ -0,0 +1,39 @@
1
+ import { useElementClientSize } from "../hooks/useElementClientSize.js";
2
+ import "./constants.js";
3
+ import { clamp } from "./chartScales.js";
4
+ import { useMemo, useRef } from "react";
5
+ //#region src/charts/useChartTooltipPosition.ts
6
+ var ChartTooltipVerticalAlign = /* @__PURE__ */ function(ChartTooltipVerticalAlign) {
7
+ ChartTooltipVerticalAlign["ABOVE"] = "ABOVE";
8
+ ChartTooltipVerticalAlign["CENTERED"] = "CENTERED";
9
+ return ChartTooltipVerticalAlign;
10
+ }({});
11
+ function useChartTooltipPosition({ anchorX, anchorY, containerWidth, containerHeight, anchorHalfWidth = 0, placeAwayFromX, verticalAlign = "ABOVE" }) {
12
+ const tooltipRef = useRef(null);
13
+ const { width: tooltipWidth, height: tooltipHeight } = useElementClientSize(tooltipRef);
14
+ return useMemo(() => {
15
+ const isMeasured = tooltipWidth !== void 0 && tooltipHeight !== void 0;
16
+ const w = tooltipWidth ?? 0;
17
+ const h = tooltipHeight ?? 0;
18
+ const rawX = (placeAwayFromX !== void 0 ? anchorX < placeAwayFromX : anchorX > containerWidth / 2) ? anchorX - anchorHalfWidth - 10 - w : anchorX + anchorHalfWidth + 10;
19
+ const rawY = verticalAlign === "CENTERED" ? anchorY - h / 2 : Math.min(anchorY, containerHeight / 2);
20
+ return {
21
+ tooltipRef,
22
+ x: clamp(rawX, 0, Math.max(0, containerWidth - w)),
23
+ y: clamp(rawY, 0, Math.max(0, containerHeight - h)),
24
+ isMeasured
25
+ };
26
+ }, [
27
+ anchorX,
28
+ anchorY,
29
+ containerWidth,
30
+ containerHeight,
31
+ anchorHalfWidth,
32
+ placeAwayFromX,
33
+ verticalAlign,
34
+ tooltipWidth,
35
+ tooltipHeight
36
+ ]);
37
+ }
38
+ //#endregion
39
+ export { ChartTooltipVerticalAlign, useChartTooltipPosition };
@@ -0,0 +1,20 @@
1
+ interface ElementClientSize {
2
+ width: number | undefined;
3
+ height: number | undefined;
4
+ }
5
+ /**
6
+ * Hook that tracks an element's *client* size — the padding box, excluding
7
+ * scrollbars and borders.
8
+ *
9
+ * Use this instead of {@link useElementWidth} when the measurement drives
10
+ * something that must line up with the scrollport (a sticky overlay, a
11
+ * viewport-width panel). `useElementWidth` measures the border box via
12
+ * `getBoundingClientRect`, which includes the scrollbar gutter and would make
13
+ * such an element overhang.
14
+ *
15
+ * @param ref - A ref to the element to measure
16
+ * @returns The current client width/height in pixels, or undefined before the
17
+ * first measurement
18
+ */
19
+ export declare const useElementClientSize: (ref: React.RefObject<HTMLElement | null>) => ElementClientSize;
20
+ export {};
@@ -0,0 +1,43 @@
1
+ import { useEffect, useState } from "react";
2
+ //#region src/hooks/useElementClientSize.ts
3
+ /**
4
+ * Hook that tracks an element's *client* size — the padding box, excluding
5
+ * scrollbars and borders.
6
+ *
7
+ * Use this instead of {@link useElementWidth} when the measurement drives
8
+ * something that must line up with the scrollport (a sticky overlay, a
9
+ * viewport-width panel). `useElementWidth` measures the border box via
10
+ * `getBoundingClientRect`, which includes the scrollbar gutter and would make
11
+ * such an element overhang.
12
+ *
13
+ * @param ref - A ref to the element to measure
14
+ * @returns The current client width/height in pixels, or undefined before the
15
+ * first measurement
16
+ */
17
+ var useElementClientSize = (ref) => {
18
+ const [size, setSize] = useState({
19
+ width: void 0,
20
+ height: void 0
21
+ });
22
+ useEffect(() => {
23
+ const element = ref.current;
24
+ if (!element) return;
25
+ const update = () => {
26
+ setSize((current) => current.width === element.clientWidth && current.height === element.clientHeight ? current : {
27
+ width: element.clientWidth,
28
+ height: element.clientHeight
29
+ });
30
+ };
31
+ update();
32
+ if (typeof ResizeObserver === "undefined") {
33
+ window.addEventListener("resize", update);
34
+ return () => window.removeEventListener("resize", update);
35
+ }
36
+ const observer = new ResizeObserver(update);
37
+ observer.observe(element);
38
+ return () => observer.disconnect();
39
+ }, [ref]);
40
+ return size;
41
+ };
42
+ //#endregion
43
+ export { useElementClientSize };
@@ -14,7 +14,12 @@ export interface CheckboxInputProps {
14
14
  label?: string;
15
15
  isRequired?: boolean;
16
16
  isDisabled?: boolean;
17
- onChange: (checked: boolean) => void;
17
+ /** The originating event is passed through so callers can read modifiers. */
18
+ onChange: (checked: boolean, event?: React.MouseEvent | React.KeyboardEvent) => void;
19
+ /** Accessible name — required when the checkbox renders without a `label`. */
20
+ ariaLabel?: string;
21
+ /** Stops the click from bubbling, e.g. into a clickable table row. */
22
+ stopClickPropagation?: boolean;
18
23
  }
19
- declare const CheckboxInput: ({ variant, size, isChecked, isIndeterminate, label, isRequired, isDisabled, onChange, }: CheckboxInputProps) => import("react").JSX.Element;
24
+ declare const CheckboxInput: ({ variant, size, isChecked, isIndeterminate, label, isRequired, isDisabled, onChange, ariaLabel, stopClickPropagation, }: CheckboxInputProps) => import("react").JSX.Element;
20
25
  export default CheckboxInput;