@galaxy-io/dls 1.2.7 → 1.3.1

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 (305) 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 +183 -253
  8. package/dist/charts/ChartAxis.d.ts +47 -22
  9. package/dist/charts/ChartAxis.js +81 -60
  10. package/dist/charts/ChartCategoryTargets.d.ts +27 -0
  11. package/dist/charts/ChartCategoryTargets.js +75 -0
  12. package/dist/charts/ChartEmptyState.d.ts +17 -0
  13. package/dist/charts/ChartEmptyState.js +29 -0
  14. package/dist/charts/ChartFrame.d.ts +110 -0
  15. package/dist/charts/ChartFrame.js +143 -0
  16. package/dist/charts/ChartLegend.d.ts +27 -4
  17. package/dist/charts/ChartLegend.js +46 -23
  18. package/dist/charts/ChartPrimitives.d.ts +230 -0
  19. package/dist/charts/ChartPrimitives.js +305 -0
  20. package/dist/charts/ChartTooltip.d.ts +25 -4
  21. package/dist/charts/ChartTooltip.js +55 -49
  22. package/dist/charts/LineChart.d.ts +42 -20
  23. package/dist/charts/LineChart.js +175 -241
  24. package/dist/charts/PieChart.d.ts +48 -32
  25. package/dist/charts/PieChart.js +180 -170
  26. package/dist/charts/barChartGeometry.d.ts +120 -0
  27. package/dist/charts/barChartGeometry.js +210 -0
  28. package/dist/charts/barChartLegend.d.ts +25 -0
  29. package/dist/charts/barChartLegend.js +23 -0
  30. package/dist/charts/chartFormat.d.ts +27 -0
  31. package/dist/charts/chartFormat.js +71 -0
  32. package/dist/charts/chartScales.d.ts +120 -0
  33. package/dist/charts/chartScales.js +165 -0
  34. package/dist/charts/chartTheme.d.ts +18 -0
  35. package/dist/charts/chartTheme.js +26 -0
  36. package/dist/charts/constants.d.ts +241 -18
  37. package/dist/charts/constants.js +261 -32
  38. package/dist/charts/lineChartGeometry.d.ts +92 -0
  39. package/dist/charts/lineChartGeometry.js +134 -0
  40. package/dist/charts/pieChartGeometry.d.ts +60 -0
  41. package/dist/charts/pieChartGeometry.js +79 -0
  42. package/dist/charts/types.d.ts +428 -54
  43. package/dist/charts/types.js +155 -0
  44. package/dist/charts/useCartesianChartLayout.d.ts +70 -0
  45. package/dist/charts/useCartesianChartLayout.js +56 -0
  46. package/dist/charts/useChartDimensions.d.ts +47 -0
  47. package/dist/charts/useChartDimensions.js +63 -0
  48. package/dist/charts/useChartFormatters.d.ts +19 -0
  49. package/dist/charts/useChartFormatters.js +20 -0
  50. package/dist/charts/useChartInteraction.d.ts +76 -0
  51. package/dist/charts/useChartInteraction.js +126 -0
  52. package/dist/charts/useChartTooltipPosition.d.ts +53 -0
  53. package/dist/charts/useChartTooltipPosition.js +39 -0
  54. package/dist/charts/useSeriesColorResolver.d.ts +37 -0
  55. package/dist/charts/useSeriesColorResolver.js +27 -0
  56. package/dist/hooks/useElementClientSize.d.ts +20 -0
  57. package/dist/hooks/useElementClientSize.js +43 -0
  58. package/dist/inputs/CheckboxInput.d.ts +7 -2
  59. package/dist/inputs/CheckboxInput.js +30 -14
  60. package/dist/inputs/Input.d.ts +1 -1
  61. package/dist/inputs/Input.js +6 -2
  62. package/dist/inputs/MultiSelectInput.js +1 -1
  63. package/dist/inputs/RadioInput.js +7 -2
  64. package/dist/styles.css +69 -74
  65. package/dist/table/InfiniteSpreadsheet.d.ts +6 -0
  66. package/dist/table/InfiniteSpreadsheet.js +235 -0
  67. package/dist/table/InfiniteTable.d.ts +7 -88
  68. package/dist/table/InfiniteTable.js +366 -577
  69. package/dist/{spreadsheet → table}/SpreadsheetCell.d.ts +6 -4
  70. package/dist/table/SpreadsheetCell.js +71 -0
  71. package/dist/{spreadsheet → table}/SpreadsheetCellEditor.js +27 -21
  72. package/dist/table/SpreadsheetHeaderCell.d.ts +23 -0
  73. package/dist/table/SpreadsheetHeaderCell.js +91 -0
  74. package/dist/table/SpreadsheetMenuItem.d.ts +14 -0
  75. package/dist/table/SpreadsheetMenuItem.js +33 -0
  76. package/dist/table/SpreadsheetPrimitives.d.ts +172 -0
  77. package/dist/table/SpreadsheetPrimitives.js +105 -0
  78. package/dist/table/SpreadsheetRow.d.ts +33 -0
  79. package/dist/table/SpreadsheetRow.js +73 -0
  80. package/dist/{spreadsheet → table}/SpreadsheetRowActionCell.d.ts +5 -7
  81. package/dist/table/SpreadsheetRowActionCell.js +51 -0
  82. package/dist/table/TableExpandCell.d.ts +11 -0
  83. package/dist/table/TableExpandCell.js +24 -0
  84. package/dist/table/TableExpandedRow.d.ts +16 -0
  85. package/dist/table/TableExpandedRow.js +77 -0
  86. package/dist/table/TableHeaderCellContent.d.ts +30 -0
  87. package/dist/table/TableHeaderCellContent.js +48 -0
  88. package/dist/table/TablePrimitives.d.ts +307 -0
  89. package/dist/table/TablePrimitives.js +298 -0
  90. package/dist/table/TableSelectCell.d.ts +18 -0
  91. package/dist/table/TableSelectCell.js +26 -0
  92. package/dist/table/TableStatusRow.d.ts +18 -0
  93. package/dist/table/TableStatusRow.js +50 -0
  94. package/dist/table/VirtualizedInfiniteTable.d.ts +11 -27
  95. package/dist/table/VirtualizedInfiniteTable.js +182 -317
  96. package/dist/table/types.d.ts +249 -0
  97. package/dist/table/types.js +51 -0
  98. package/dist/table/useInfiniteScrollSentinel.d.ts +24 -0
  99. package/dist/table/useInfiniteScrollSentinel.js +53 -0
  100. package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.d.ts +1 -1
  101. package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.js +1 -1
  102. package/dist/table/useTableColumnLayout.d.ts +28 -0
  103. package/dist/table/useTableColumnLayout.js +63 -0
  104. package/dist/table/useTableColumnResize.d.ts +38 -0
  105. package/dist/table/useTableColumnResize.js +155 -0
  106. package/dist/table/useTableKeyboardNavigation.d.ts +25 -0
  107. package/dist/table/useTableKeyboardNavigation.js +83 -0
  108. package/dist/table/useTableRowExpansion.d.ts +24 -0
  109. package/dist/table/useTableRowExpansion.js +62 -0
  110. package/dist/table/useTableRowSelection.d.ts +27 -0
  111. package/dist/table/useTableRowSelection.js +94 -0
  112. package/dist/table/utils.d.ts +50 -0
  113. package/dist/table/utils.js +78 -0
  114. package/dist/text/MarkdownText.js +45 -27
  115. package/dist/theme/variants/dark.js +1 -1
  116. package/dist/widget/Widget.d.ts +2 -0
  117. package/dist/widget/Widget.js +14 -7
  118. package/package.json +1 -5
  119. package/dist/assets/components/enrichment/PerplexityIcon.d.ts +0 -3
  120. package/dist/assets/components/enrichment/PerplexityIcon.js +0 -35
  121. package/dist/assets/components/enrichment/TavilyIcon.d.ts +0 -3
  122. package/dist/assets/components/enrichment/TavilyIcon.js +0 -15
  123. package/dist/assets/components/onboarding/TenantSetupDark.d.ts +0 -3
  124. package/dist/assets/components/onboarding/TenantSetupDark.js +0 -498
  125. package/dist/assets/components/onboarding/TenantSetupLight.d.ts +0 -3
  126. package/dist/assets/components/onboarding/TenantSetupLight.js +0 -482
  127. package/dist/assets/components/onboarding/UserSetupDark.d.ts +0 -3
  128. package/dist/assets/components/onboarding/UserSetupDark.js +0 -1086
  129. package/dist/assets/components/onboarding/UserSetupLight.d.ts +0 -3
  130. package/dist/assets/components/onboarding/UserSetupLight.js +0 -1024
  131. package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.d.ts +0 -3
  132. package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.js +0 -466
  133. package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.d.ts +0 -3
  134. package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.js +0 -460
  135. package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.d.ts +0 -3
  136. package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.js +0 -336
  137. package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.d.ts +0 -3
  138. package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.js +0 -336
  139. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.d.ts +0 -3
  140. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.js +0 -153
  141. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.d.ts +0 -3
  142. package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.js +0 -153
  143. package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.d.ts +0 -3
  144. package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.js +0 -117
  145. package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.d.ts +0 -3
  146. package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.js +0 -117
  147. package/dist/assets/components/projects/MappingMethodBlankDark.d.ts +0 -3
  148. package/dist/assets/components/projects/MappingMethodBlankDark.js +0 -150
  149. package/dist/assets/components/projects/MappingMethodBlankDarkHovered.d.ts +0 -3
  150. package/dist/assets/components/projects/MappingMethodBlankDarkHovered.js +0 -150
  151. package/dist/assets/components/projects/MappingMethodBlankLight.d.ts +0 -3
  152. package/dist/assets/components/projects/MappingMethodBlankLight.js +0 -150
  153. package/dist/assets/components/projects/MappingMethodBlankLightHovered.d.ts +0 -3
  154. package/dist/assets/components/projects/MappingMethodBlankLightHovered.js +0 -150
  155. package/dist/assets/components/projects/MappingMethodJsonDark.d.ts +0 -3
  156. package/dist/assets/components/projects/MappingMethodJsonDark.js +0 -90
  157. package/dist/assets/components/projects/MappingMethodJsonDarkHovered.d.ts +0 -3
  158. package/dist/assets/components/projects/MappingMethodJsonDarkHovered.js +0 -90
  159. package/dist/assets/components/projects/MappingMethodJsonLight.d.ts +0 -3
  160. package/dist/assets/components/projects/MappingMethodJsonLight.js +0 -90
  161. package/dist/assets/components/projects/MappingMethodJsonLightHovered.d.ts +0 -3
  162. package/dist/assets/components/projects/MappingMethodJsonLightHovered.js +0 -90
  163. package/dist/assets/components/projects/ProjectsEmptyStateDark.d.ts +0 -3
  164. package/dist/assets/components/projects/ProjectsEmptyStateDark.js +0 -454
  165. package/dist/assets/components/projects/ProjectsEmptyStateLight.d.ts +0 -3
  166. package/dist/assets/components/projects/ProjectsEmptyStateLight.js +0 -456
  167. package/dist/assets/components/root/CreateProjectActionCardDark.d.ts +0 -3
  168. package/dist/assets/components/root/CreateProjectActionCardDark.js +0 -1796
  169. package/dist/assets/components/root/CreateProjectActionCardDarkHovered.d.ts +0 -3
  170. package/dist/assets/components/root/CreateProjectActionCardDarkHovered.js +0 -1796
  171. package/dist/assets/components/root/CreateProjectActionCardLight.d.ts +0 -3
  172. package/dist/assets/components/root/CreateProjectActionCardLight.js +0 -1786
  173. package/dist/assets/components/root/CreateProjectActionCardLightHovered.d.ts +0 -3
  174. package/dist/assets/components/root/CreateProjectActionCardLightHovered.js +0 -1786
  175. package/dist/assets/components/root/CreateSourceActionCardDark.d.ts +0 -3
  176. package/dist/assets/components/root/CreateSourceActionCardDark.js +0 -879
  177. package/dist/assets/components/root/CreateSourceActionCardDarkHovered.d.ts +0 -3
  178. package/dist/assets/components/root/CreateSourceActionCardDarkHovered.js +0 -879
  179. package/dist/assets/components/root/CreateSourceActionCardLight.d.ts +0 -3
  180. package/dist/assets/components/root/CreateSourceActionCardLight.js +0 -889
  181. package/dist/assets/components/root/CreateSourceActionCardLightHovered.d.ts +0 -3
  182. package/dist/assets/components/root/CreateSourceActionCardLightHovered.js +0 -889
  183. package/dist/assets/components/sources/AttioIcon.d.ts +0 -3
  184. package/dist/assets/components/sources/AttioIcon.js +0 -11
  185. package/dist/assets/components/sources/BigquerySourceIcon.d.ts +0 -3
  186. package/dist/assets/components/sources/BigquerySourceIcon.js +0 -39
  187. package/dist/assets/components/sources/BrowserbaseSourceIcon.d.ts +0 -3
  188. package/dist/assets/components/sources/BrowserbaseSourceIcon.js +0 -35
  189. package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.d.ts +0 -3
  190. package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.js +0 -13
  191. package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.d.ts +0 -3
  192. package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.js +0 -13
  193. package/dist/assets/components/sources/ConfluenceSourceIcon.d.ts +0 -3
  194. package/dist/assets/components/sources/ConfluenceSourceIcon.js +0 -30
  195. package/dist/assets/components/sources/GithubSourceIcon.d.ts +0 -3
  196. package/dist/assets/components/sources/GithubSourceIcon.js +0 -27
  197. package/dist/assets/components/sources/GoogleDriveIcon.d.ts +0 -3
  198. package/dist/assets/components/sources/GoogleDriveIcon.js +0 -45
  199. package/dist/assets/components/sources/HubspotSourceIcon.d.ts +0 -3
  200. package/dist/assets/components/sources/HubspotSourceIcon.js +0 -14
  201. package/dist/assets/components/sources/JiraSourceIcon.d.ts +0 -3
  202. package/dist/assets/components/sources/JiraSourceIcon.js +0 -54
  203. package/dist/assets/components/sources/LinearSourceIcon.d.ts +0 -3
  204. package/dist/assets/components/sources/LinearSourceIcon.js +0 -14
  205. package/dist/assets/components/sources/MysqlLogoSourceIconDark.d.ts +0 -3
  206. package/dist/assets/components/sources/MysqlLogoSourceIconDark.js +0 -17
  207. package/dist/assets/components/sources/NetsuiteSourceIcon.d.ts +0 -3
  208. package/dist/assets/components/sources/NetsuiteSourceIcon.js +0 -32
  209. package/dist/assets/components/sources/NotionIcon.d.ts +0 -3
  210. package/dist/assets/components/sources/NotionIcon.js +0 -20
  211. package/dist/assets/components/sources/PostgresqlIcon.d.ts +0 -3
  212. package/dist/assets/components/sources/PostgresqlIcon.js +0 -61
  213. package/dist/assets/components/sources/S3Icon.d.ts +0 -3
  214. package/dist/assets/components/sources/S3Icon.js +0 -76
  215. package/dist/assets/components/sources/SalesforceSourceIcon.d.ts +0 -3
  216. package/dist/assets/components/sources/SalesforceSourceIcon.js +0 -23
  217. package/dist/assets/components/sources/SlackIcon.d.ts +0 -3
  218. package/dist/assets/components/sources/SlackIcon.js +0 -32
  219. package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.d.ts +0 -3
  220. package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.js +0 -14
  221. package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.d.ts +0 -3
  222. package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.js +0 -14
  223. package/dist/assets/components/sources/WikipediaSourceIcon.d.ts +0 -3
  224. package/dist/assets/components/sources/WikipediaSourceIcon.js +0 -1490
  225. package/dist/avatar/AvatarEmpty.d.ts +0 -7
  226. package/dist/avatar/AvatarEmpty.js +0 -99
  227. package/dist/avatar/types.d.ts +0 -5
  228. package/dist/avatar/types.js +0 -9
  229. package/dist/charts/utils.d.ts +0 -29
  230. package/dist/charts/utils.js +0 -62
  231. package/dist/icons/BackIcon.d.ts +0 -3
  232. package/dist/icons/BackIcon.js +0 -13
  233. package/dist/icons/CloseIcon.d.ts +0 -3
  234. package/dist/icons/CloseIcon.js +0 -13
  235. package/dist/icons/CreateIcon.d.ts +0 -3
  236. package/dist/icons/CreateIcon.js +0 -13
  237. package/dist/icons/ForwardIcon.d.ts +0 -3
  238. package/dist/icons/ForwardIcon.js +0 -13
  239. package/dist/icons/HelpIcon.d.ts +0 -3
  240. package/dist/icons/HelpIcon.js +0 -14
  241. package/dist/icons/ProjectsIcon.d.ts +0 -3
  242. package/dist/icons/ProjectsIcon.js +0 -12
  243. package/dist/icons/SearchIcon.d.ts +0 -3
  244. package/dist/icons/SearchIcon.js +0 -12
  245. package/dist/icons/SourcesIcon.d.ts +0 -3
  246. package/dist/icons/SourcesIcon.js +0 -12
  247. package/dist/icons/TextIcon.d.ts +0 -4
  248. package/dist/icons/TextIcon.js +0 -22
  249. package/dist/icons/WebScrapeIcon.d.ts +0 -4
  250. package/dist/icons/WebScrapeIcon.js +0 -22
  251. package/dist/icons/WebhookIcon.d.ts +0 -4
  252. package/dist/icons/WebhookIcon.js +0 -22
  253. package/dist/icons/sources/AttioLogomark.d.ts +0 -4
  254. package/dist/icons/sources/AttioLogomark.js +0 -8
  255. package/dist/icons/sources/BrowserbaseLogomark.d.ts +0 -4
  256. package/dist/icons/sources/BrowserbaseLogomark.js +0 -8
  257. package/dist/icons/sources/ClickhouseLogomark.d.ts +0 -4
  258. package/dist/icons/sources/ClickhouseLogomark.js +0 -16
  259. package/dist/icons/sources/ConfluenceLogomark.d.ts +0 -4
  260. package/dist/icons/sources/ConfluenceLogomark.js +0 -8
  261. package/dist/icons/sources/GithubLogomark.d.ts +0 -4
  262. package/dist/icons/sources/GithubLogomark.js +0 -8
  263. package/dist/icons/sources/GoogleBigqueryLogomark.d.ts +0 -4
  264. package/dist/icons/sources/GoogleBigqueryLogomark.js +0 -8
  265. package/dist/icons/sources/GoogleDriveLogomark.d.ts +0 -4
  266. package/dist/icons/sources/GoogleDriveLogomark.js +0 -8
  267. package/dist/icons/sources/HubspotLogomark.d.ts +0 -4
  268. package/dist/icons/sources/HubspotLogomark.js +0 -8
  269. package/dist/icons/sources/JiraLogomark.d.ts +0 -4
  270. package/dist/icons/sources/JiraLogomark.js +0 -8
  271. package/dist/icons/sources/LinearLogomark.d.ts +0 -4
  272. package/dist/icons/sources/LinearLogomark.js +0 -8
  273. package/dist/icons/sources/MySQLLogomark.d.ts +0 -4
  274. package/dist/icons/sources/MySQLLogomark.js +0 -8
  275. package/dist/icons/sources/NetsuiteLogomark.d.ts +0 -4
  276. package/dist/icons/sources/NetsuiteLogomark.js +0 -8
  277. package/dist/icons/sources/NotionLogomark.d.ts +0 -4
  278. package/dist/icons/sources/NotionLogomark.js +0 -8
  279. package/dist/icons/sources/PostgresLogomark.d.ts +0 -4
  280. package/dist/icons/sources/PostgresLogomark.js +0 -8
  281. package/dist/icons/sources/S3Logomark.d.ts +0 -4
  282. package/dist/icons/sources/S3Logomark.js +0 -8
  283. package/dist/icons/sources/SalesforceLogomark.d.ts +0 -4
  284. package/dist/icons/sources/SalesforceLogomark.js +0 -8
  285. package/dist/icons/sources/SlackLogoIconmark.d.ts +0 -4
  286. package/dist/icons/sources/SlackLogoIconmark.js +0 -8
  287. package/dist/icons/sources/SnowflakeLogomark.d.ts +0 -4
  288. package/dist/icons/sources/SnowflakeLogomark.js +0 -16
  289. package/dist/icons/sources/WikipediaLogomark.d.ts +0 -4
  290. package/dist/icons/sources/WikipediaLogomark.js +0 -8
  291. package/dist/spreadsheet/InfiniteSpreadsheet.d.ts +0 -3
  292. package/dist/spreadsheet/InfiniteSpreadsheet.js +0 -265
  293. package/dist/spreadsheet/SpreadsheetAddColumnButton.d.ts +0 -6
  294. package/dist/spreadsheet/SpreadsheetAddColumnButton.js +0 -32
  295. package/dist/spreadsheet/SpreadsheetCell.js +0 -115
  296. package/dist/spreadsheet/SpreadsheetHeaderCell.d.ts +0 -18
  297. package/dist/spreadsheet/SpreadsheetHeaderCell.js +0 -141
  298. package/dist/spreadsheet/SpreadsheetRow.d.ts +0 -21
  299. package/dist/spreadsheet/SpreadsheetRow.js +0 -68
  300. package/dist/spreadsheet/SpreadsheetRowActionCell.js +0 -78
  301. package/dist/spreadsheet/hooks/useColumnResize.d.ts +0 -6
  302. package/dist/spreadsheet/hooks/useColumnResize.js +0 -46
  303. package/dist/spreadsheet/types.d.ts +0 -92
  304. package/dist/spreadsheet/types.js +0 -21
  305. /package/dist/{spreadsheet → table}/SpreadsheetCellEditor.d.ts +0 -0
@@ -1,264 +1,194 @@
1
- import { useGalaxyTheme, withTheme } from "../theme/GalaxyTheme.js";
2
- import Text, { TextSize, TextWeight } from "../text/Text.js";
3
- import FlexWrapper, { AlignItems, FlexDirection, JustifyContent } from "../containers/FlexWrapper.js";
4
- import { useElementWidth } from "../hooks/useElementWidth.js";
5
- import Wrapper from "../containers/Wrapper.js";
6
- import { DEFAULT_BAR_PADDING_INNER, DEFAULT_BAR_PADDING_OUTER, getChartPalette } from "./constants.js";
7
- import { buildBandScale, buildLinearScale, defaultLabelFormatter, defaultValueFormatter, getGroupedMax, getPlotDimensions, getStackedMax, resolveMargin, resolveSeriesColor, roundedTopRectPath } from "./utils.js";
8
- import ChartLegend from "./ChartLegend.js";
9
- import ChartTooltip from "./ChartTooltip.js";
10
- import { XAxis, YAxis } from "./ChartAxis.js";
11
- /* empty css */
12
- import { styled } from "@linaria/react";
13
- import { useCallback, useMemo, useRef, useState } from "react";
14
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { BarChartNormalization, ChartKind, ChartTargetShape } from "./types.js";
2
+ import { useSeriesColorResolver } from "./useSeriesColorResolver.js";
3
+ import { useChartInteraction } from "./useChartInteraction.js";
4
+ import { useCartesianChartLayout } from "./useCartesianChartLayout.js";
5
+ import { getBarLegendItems } from "./barChartLegend.js";
6
+ import { buildBarChartGeometry, getBarValueDomain, roundedRectPath } from "./barChartGeometry.js";
7
+ import { ChartBarPath } from "./ChartPrimitives.js";
8
+ import ChartFrame from "./ChartFrame.js";
9
+ import { ChartCategoryAxis, ChartValueAxis } from "./ChartAxis.js";
10
+ import { useCallback, useMemo, useRef } from "react";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
12
  //#region src/charts/BarChart.tsx
16
- var BarChartMode = /* @__PURE__ */ function(BarChartMode) {
17
- BarChartMode["GROUPED"] = "GROUPED";
18
- BarChartMode["STACKED"] = "STACKED";
19
- return BarChartMode;
20
- }({});
21
- var _exp = () => ({ $fillWidth }) => $fillWidth ? "flex" : "inline-flex";
22
- var _exp2 = () => ({ $fillWidth }) => $fillWidth ? "100%" : "auto";
23
- var ChartWrapper = withTheme(/*#__PURE__*/ styled("div")({
24
- name: "ChartWrapper",
25
- class: "c16zjhoz",
26
- propsAsIs: false,
27
- vars: {
28
- "c16zjhoz-0": [_exp()],
29
- "c16zjhoz-1": [_exp2()]
30
- }
31
- }));
32
- var BarChart = ({ data, series, width, height, margin: marginOverride, fillWidth = false, aspectRatio, mode = "STACKED", barRadius = 4, barPaddingInner = DEFAULT_BAR_PADDING_INNER, barPaddingOuter = DEFAULT_BAR_PADDING_OUTER, valueFormatter = defaultValueFormatter, labelFormatter = defaultLabelFormatter, tooltipRenderer, noTooltip = false, showLegend = true, showValues = false, showGrid = true, ariaLabel }) => {
33
- const { theme } = useGalaxyTheme();
13
+ /**
14
+ * Bar chart with a three-level data model.
15
+ *
16
+ * Grouping and stacking are properties of the data rather than a mode: several
17
+ * `bars` in a group render side by side, several `components` in a bar stack,
18
+ * and a chart doing both at once needs no extra configuration.
19
+ */
20
+ var BarChart = ({ series, groups, width, height, fillWidth, fillHeight, aspectRatio, margin, normalization = BarChartNormalization.NONE, valueUnit, valueFormatter, labelFormatter, valueDomain, categoryLabelMode, categoryAxisTitle, valueAxisTitle, showGrid = true, showLegend = true, noTooltip = false, tooltipRenderer, isLoading = false, contentWhenEmpty, ariaLabel, ariaDescription, onPinnedChange }) => {
34
21
  const containerRef = useRef(null);
35
- const svgRef = useRef(null);
36
- const [tooltip, setTooltip] = useState(null);
37
- const [hoveredDatumIndex, setHoveredDatumIndex] = useState(null);
38
- const measuredWidth = useElementWidth(containerRef);
39
- const resolvedWidth = fillWidth ? measuredWidth ?? 0 : width ?? 0;
40
- const resolvedHeight = aspectRatio ? resolvedWidth / aspectRatio : height ?? 0;
41
- const palette = useMemo(() => getChartPalette(theme), [theme]);
42
- const margin = useMemo(() => resolveMargin(marginOverride), [marginOverride]);
43
- const { plotWidth, plotHeight } = useMemo(() => getPlotDimensions(resolvedWidth, resolvedHeight, margin), [
44
- resolvedWidth,
45
- resolvedHeight,
46
- margin
22
+ const colors = useSeriesColorResolver(series);
23
+ /**
24
+ * Axis-only formatting for a percent-normalized chart.
25
+ *
26
+ * Normalization rescales the *axis* into 0–1, so the caller's formatter —
27
+ * which describes their real units would label it `0.2`, `0.4`. Unless they
28
+ * asked for something specific, show shares as percentages.
29
+ *
30
+ * Deliberately not used for the tooltip. `stackComponents` normalizes each
31
+ * segment's extent but leaves its `value` raw, so a tooltip row still carries
32
+ * the real number: the axis reports the share, the tooltip reports what the
33
+ * share is made of. Running a row through this would multiply a raw 200 into
34
+ * `20000%`.
35
+ */
36
+ const deriveAxisFormatter = useCallback((formatValue) => {
37
+ if (normalization !== BarChartNormalization.PERCENT) return formatValue;
38
+ if (valueFormatter || valueUnit) return formatValue;
39
+ return (value) => `${Math.round(value * 100)}%`;
40
+ }, [
41
+ normalization,
42
+ valueFormatter,
43
+ valueUnit
47
44
  ]);
48
- const seriesKeys = useMemo(() => series.map((s) => s.key), [series]);
49
- const labels = useMemo(() => data.map((d) => d.label), [data]);
50
- const xScale = useMemo(() => buildBandScale(labels, [0, plotWidth], barPaddingInner, barPaddingOuter), [
51
- labels,
45
+ const { dimensions, domain, valueTicks, formatValue, formatLabel, formatAxisValue } = useCartesianChartLayout({
46
+ containerRef,
47
+ rawDomain: useMemo(() => getBarValueDomain(groups, normalization), [groups, normalization]),
48
+ valueDomain,
49
+ width,
50
+ height,
51
+ fillWidth,
52
+ fillHeight,
53
+ aspectRatio,
54
+ margin,
55
+ valueUnit,
56
+ valueFormatter,
57
+ labelFormatter,
58
+ deriveAxisFormatter,
59
+ valueAxisTitle,
60
+ categoryAxisTitle
61
+ });
62
+ const { plotWidth, plotHeight } = dimensions;
63
+ /**
64
+ * True when any bar carries more than one component.
65
+ *
66
+ * This is what decides the colour grammar. In a stacked chart the segments
67
+ * are the thing being compared, so they take the palette and every stack
68
+ * repeats the same ramp; in an unstacked one the metrics are, so each bar
69
+ * takes its metric's colour. Applying the metric colour to a stack would
70
+ * paint every segment identically.
71
+ */
72
+ const isStacked = useMemo(() => groups.some((group) => group.bars.some((bar) => bar.components.length > 1)), [groups]);
73
+ const resolveColor = useCallback(({ metric, componentIndex, isStacked: barIsStacked, explicit }) => barIsStacked ? colors.resolveByIndex(componentIndex, explicit) : colors.resolve(metric, explicit), [colors]);
74
+ const geometry = useMemo(() => buildBarChartGeometry({
75
+ groups,
52
76
  plotWidth,
53
- barPaddingInner,
54
- barPaddingOuter
55
- ]);
56
- const yMax = useMemo(() => mode === "STACKED" ? getStackedMax(data, seriesKeys) : getGroupedMax(data, seriesKeys), [
57
- data,
58
- seriesKeys,
59
- mode
60
- ]);
61
- const yScale = useMemo(() => buildLinearScale(yMax, [plotHeight, 0]), [yMax, plotHeight]);
62
- const innerScale = useMemo(() => {
63
- if (mode !== "GROUPED") return null;
64
- return buildBandScale(seriesKeys, [0, xScale.bandwidth()], .05, 0);
65
- }, [
66
- mode,
67
- seriesKeys,
68
- xScale
77
+ plotHeight,
78
+ normalization,
79
+ isStacked,
80
+ domain,
81
+ resolveColor
82
+ }), [
83
+ groups,
84
+ plotWidth,
85
+ plotHeight,
86
+ normalization,
87
+ isStacked,
88
+ domain,
89
+ resolveColor
69
90
  ]);
70
- const handleBarMouseEnter = useCallback((datumIndex, x, y) => {
71
- const datum = data[datumIndex];
72
- if (!datum) return;
73
- setHoveredDatumIndex(datumIndex);
74
- setTooltip({
75
- label: datum.label,
76
- items: series.map((s, i) => ({
77
- seriesKey: s.key,
78
- seriesName: s.name,
79
- value: datum.values[s.key] ?? 0,
80
- color: resolveSeriesColor(s, i, palette)
81
- })),
82
- x: x + margin.left,
83
- y: y + margin.top
84
- });
85
- }, [
86
- data,
91
+ const isEmpty = groups.length === 0;
92
+ const legendItems = useMemo(() => getBarLegendItems({
93
+ isStacked,
94
+ series,
95
+ groups,
96
+ colors
97
+ }), [
98
+ isStacked,
87
99
  series,
88
- palette,
89
- margin
100
+ groups,
101
+ colors
90
102
  ]);
91
- const handleBarMouseLeave = useCallback(() => {
92
- setHoveredDatumIndex(null);
93
- setTooltip(null);
94
- }, []);
95
- const handleBarFocus = useCallback((datumIndex, x, y) => {
96
- handleBarMouseEnter(datumIndex, x, y);
97
- }, [handleBarMouseEnter]);
98
- const handleBarBlur = useCallback(() => {
99
- handleBarMouseLeave();
100
- }, [handleBarMouseLeave]);
101
- if (resolvedWidth === 0 || resolvedHeight === 0) return /* @__PURE__ */ jsx(ChartWrapper, {
102
- ref: containerRef,
103
- $fillWidth: fillWidth
103
+ const legendKeys = useMemo(() => legendItems.map((item) => item.key), [legendItems]);
104
+ const interaction = useChartInteraction({
105
+ categoryCount: geometry.bands.length,
106
+ seriesKeys: legendKeys,
107
+ disabled: noTooltip || isLoading || isEmpty,
108
+ isLoading,
109
+ onPinnedChange
104
110
  });
105
- const renderStackedBars = () => {
106
- return data.map((datum, datumIndex) => {
107
- const x = xScale(datum.label) ?? 0;
108
- const bandWidth = xScale.bandwidth();
109
- let cumulativeY = plotHeight;
110
- return /* @__PURE__ */ jsx("g", { children: series.map((s, seriesIndex) => {
111
- const value = datum.values[s.key] ?? 0;
112
- if (value === 0) return null;
113
- const barHeight = plotHeight - yScale(value);
114
- const barY = cumulativeY - barHeight;
115
- cumulativeY = barY;
116
- const color = resolveSeriesColor(s, seriesIndex, palette);
117
- const isTopSegment = seriesIndex === series.length - 1 || series.slice(seriesIndex + 1).every((next) => (datum.values[next.key] ?? 0) === 0);
118
- const isDimmed = hoveredDatumIndex !== null && hoveredDatumIndex !== datumIndex;
119
- return /* @__PURE__ */ jsxs("g", { children: [isTopSegment ? /* @__PURE__ */ jsx("path", {
120
- d: roundedTopRectPath(x, barY, bandWidth, barHeight, barRadius),
121
- fill: color,
122
- opacity: isDimmed ? .3 : 1,
123
- style: { transition: `opacity 150ms ease-in-out` },
124
- onMouseEnter: () => handleBarMouseEnter(datumIndex, x + bandWidth / 2, barY),
125
- onMouseLeave: handleBarMouseLeave,
126
- onFocus: () => handleBarFocus(datumIndex, x + bandWidth / 2, barY),
127
- onBlur: handleBarBlur,
128
- tabIndex: 0,
129
- role: "graphics-symbol",
130
- "aria-roledescription": "bar",
131
- "aria-label": `${s.name} for ${datum.label}: ${valueFormatter(value)}`
132
- }) : /* @__PURE__ */ jsx("rect", {
133
- x,
134
- y: barY,
135
- width: bandWidth,
136
- height: barHeight,
137
- fill: color,
138
- opacity: isDimmed ? .3 : 1,
139
- style: { transition: `opacity 150ms ease-in-out` },
140
- onMouseEnter: () => handleBarMouseEnter(datumIndex, x + bandWidth / 2, barY),
141
- onMouseLeave: handleBarMouseLeave,
142
- onFocus: () => handleBarFocus(datumIndex, x + bandWidth / 2, barY),
143
- onBlur: handleBarBlur,
144
- tabIndex: 0,
145
- role: "graphics-symbol",
146
- "aria-roledescription": "bar",
147
- "aria-label": `${s.name} for ${datum.label}: ${valueFormatter(value)}`
148
- }), showValues && isTopSegment && /* @__PURE__ */ jsx("foreignObject", {
149
- x,
150
- y: barY - 20,
151
- width: bandWidth,
152
- height: 20,
153
- children: /* @__PURE__ */ jsx(FlexWrapper, {
154
- justifyContent: JustifyContent.CENTER,
155
- alignItems: AlignItems.END,
156
- fillWidth: true,
157
- fillHeight: true,
158
- children: /* @__PURE__ */ jsx(Text, {
159
- size: TextSize.CAPTION,
160
- weight: TextWeight.MEDIUM,
161
- children: valueFormatter(value)
162
- })
163
- })
164
- })] }, s.key);
165
- }) }, datum.label);
166
- });
167
- };
168
- const renderGroupedBars = () => {
169
- if (!innerScale) return null;
170
- return data.map((datum, datumIndex) => {
171
- const groupX = xScale(datum.label) ?? 0;
172
- const isDimmed = hoveredDatumIndex !== null && hoveredDatumIndex !== datumIndex;
173
- return /* @__PURE__ */ jsx("g", {
174
- transform: `translate(${groupX}, 0)`,
175
- children: series.map((s, seriesIndex) => {
176
- const value = datum.values[s.key] ?? 0;
177
- if (value === 0) return null;
178
- const barX = innerScale(s.key) ?? 0;
179
- const barWidth = innerScale.bandwidth();
180
- const barHeight = plotHeight - yScale(value);
181
- const barY = yScale(value);
182
- const color = resolveSeriesColor(s, seriesIndex, palette);
183
- return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("path", {
184
- d: roundedTopRectPath(barX, barY, barWidth, barHeight, barRadius),
185
- fill: color,
186
- opacity: isDimmed ? .3 : 1,
187
- style: { transition: `opacity 150ms ease-in-out` },
188
- onMouseEnter: () => handleBarMouseEnter(datumIndex, groupX + barX + barWidth / 2, barY),
189
- onMouseLeave: handleBarMouseLeave,
190
- onFocus: () => handleBarFocus(datumIndex, groupX + barX + barWidth / 2, barY),
191
- onBlur: handleBarBlur,
192
- tabIndex: 0,
193
- role: "graphics-symbol",
194
- "aria-roledescription": "bar",
195
- "aria-label": `${s.name} for ${datum.label}: ${valueFormatter(value)}`
196
- }), showValues && /* @__PURE__ */ jsx("foreignObject", {
197
- x: barX,
198
- y: barY - 20,
199
- width: barWidth,
200
- height: 20,
201
- children: /* @__PURE__ */ jsx(FlexWrapper, {
202
- justifyContent: JustifyContent.CENTER,
203
- alignItems: AlignItems.END,
204
- fillWidth: true,
205
- fillHeight: true,
206
- children: /* @__PURE__ */ jsx(Text, {
207
- size: TextSize.CAPTION,
208
- weight: TextWeight.MEDIUM,
209
- children: valueFormatter(value)
210
- })
211
- })
212
- })] }, s.key);
213
- })
214
- }, datum.label);
215
- });
216
- };
217
- const defaultAriaLabel = `Bar chart with ${data.length} categories and ${series.length} series`;
218
- return /* @__PURE__ */ jsxs(ChartWrapper, {
219
- ref: containerRef,
220
- $fillWidth: fillWidth,
221
- children: [/* @__PURE__ */ jsxs(Wrapper, {
222
- position: "relative",
223
- children: [/* @__PURE__ */ jsx("svg", {
224
- ref: svgRef,
225
- width: resolvedWidth,
226
- height: resolvedHeight,
227
- role: "img",
228
- "aria-label": ariaLabel ?? defaultAriaLabel,
229
- children: /* @__PURE__ */ jsxs("g", {
230
- transform: `translate(${margin.left}, ${margin.top})`,
231
- children: [
232
- /* @__PURE__ */ jsx(YAxis, {
233
- scale: yScale,
234
- transform: "translate(0, 0)",
235
- plotWidth,
236
- formatter: valueFormatter,
237
- showGrid,
238
- theme
239
- }),
240
- /* @__PURE__ */ jsx(XAxis, {
241
- scale: xScale,
242
- transform: `translate(0, ${plotHeight})`,
243
- plotWidth,
244
- formatter: labelFormatter
245
- }),
246
- mode === "STACKED" ? renderStackedBars() : renderGroupedBars()
247
- ]
248
- })
249
- }), !noTooltip && (tooltipRenderer ? tooltip && tooltipRenderer(tooltip) : /* @__PURE__ */ jsx(ChartTooltip, {
250
- data: tooltip,
251
- valueFormatter
252
- }))]
253
- }), showLegend && /* @__PURE__ */ jsxs(FlexWrapper, {
254
- direction: FlexDirection.ROW,
255
- gap: 0,
256
- children: [/* @__PURE__ */ jsx(Wrapper, { minWidth: margin.left }), /* @__PURE__ */ jsx(ChartLegend, {
257
- series,
258
- palette
259
- })]
260
- })]
111
+ const buildCategoryTooltip = useCallback((index) => {
112
+ const band = geometry.bands[index];
113
+ const group = groups[index];
114
+ if (!band || !group) return null;
115
+ const rows = geometry.rects.filter((rect) => rect.groupIndex === index).map((rect) => ({
116
+ key: rect.id,
117
+ label: rect.label,
118
+ value: rect.value,
119
+ formattedValue: formatValue(rect.value),
120
+ color: rect.color
121
+ }));
122
+ return {
123
+ label: formatLabel(group.label),
124
+ rows,
125
+ anchorX: band.anchorX,
126
+ anchorY: band.anchorY
127
+ };
128
+ }, [
129
+ geometry,
130
+ groups,
131
+ formatValue,
132
+ formatLabel
133
+ ]);
134
+ const categoryPositions = useMemo(() => geometry.bands.map((band) => band.x), [geometry.bands]);
135
+ const categoryStep = geometry.bands[0]?.width ?? 0;
136
+ const categoryTargets = useMemo(() => geometry.bands.map((band) => ({
137
+ key: String(band.groupIndex),
138
+ shape: ChartTargetShape.RECT,
139
+ x: band.x,
140
+ y: band.y,
141
+ width: band.width,
142
+ height: band.height
143
+ })), [geometry.bands]);
144
+ return /* @__PURE__ */ jsx(ChartFrame, {
145
+ containerRef,
146
+ dimensions,
147
+ fillWidth,
148
+ fillHeight,
149
+ interaction,
150
+ kind: ChartKind.BAR,
151
+ categoryCount: groups.length,
152
+ ariaLabel,
153
+ ariaDescription,
154
+ axes: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ChartValueAxis, {
155
+ ticks: valueTicks,
156
+ scale: geometry.valueScale,
157
+ plotWidth,
158
+ plotHeight,
159
+ marginLeft: dimensions.margin.left,
160
+ formatter: formatAxisValue,
161
+ showGrid,
162
+ title: valueAxisTitle
163
+ }), /* @__PURE__ */ jsx(ChartCategoryAxis, {
164
+ labels: groups.map((group) => group.label),
165
+ positions: categoryPositions,
166
+ step: categoryStep,
167
+ plotWidth,
168
+ plotHeight,
169
+ formatter: formatLabel,
170
+ mode: categoryLabelMode,
171
+ title: categoryAxisTitle
172
+ })] }),
173
+ noTooltip,
174
+ buildCategoryTooltip,
175
+ tooltipRenderer,
176
+ categoryTargets,
177
+ anchorHalfWidth: categoryStep / 2,
178
+ isEmpty,
179
+ isLoading,
180
+ contentWhenEmpty,
181
+ showLegend,
182
+ legendItems,
183
+ children: geometry.rects.map((rect) => /* @__PURE__ */ jsx(ChartBarPath, {
184
+ d: roundedRectPath(rect.x, rect.y, rect.width, rect.height, rect.radius, rect.corners),
185
+ fill: rect.color,
186
+ "data-state": interaction.getMarkState({
187
+ categoryIndex: rect.groupIndex,
188
+ seriesKey: isStacked ? rect.componentKey : rect.metric
189
+ })
190
+ }, rect.id))
261
191
  });
262
192
  };
263
193
  //#endregion
264
- export { BarChartMode, BarChart as default };
194
+ export { BarChart as default };
@@ -1,28 +1,53 @@
1
- import type { ScaleBand, ScaleLinear, ScalePoint } from "d3-scale";
2
- import type { Theme } from "../theme/types";
1
+ import { ChartCategoryLabelMode } from "./types";
3
2
  import type { ChartLabelFormatter, ChartValueFormatter } from "./types";
4
- interface XAxisProps {
5
- scale: ScaleBand<string>;
6
- transform: string;
3
+ /**
4
+ * Axes for the cartesian charts.
5
+ *
6
+ * Neither axis draws a domain line or tick marks — the grid lines carry the
7
+ * structure, and the one at zero is what makes bars read as resting on a
8
+ * baseline rather than floating.
9
+ */
10
+ interface ChartValueAxisProps {
11
+ ticks: number[];
12
+ /** Maps a tick value to its y position in plot coordinates. */
13
+ scale: (value: number) => number;
7
14
  plotWidth: number;
8
- formatter?: ChartLabelFormatter;
9
- }
10
- export declare const XAxis: ({ scale, transform, formatter }: XAxisProps) => import("react").JSX.Element;
11
- interface XAxisPointProps {
12
- scale: ScalePoint<string>;
13
- transform: string;
14
- plotWidth: number;
15
- formatter?: ChartLabelFormatter;
15
+ /**
16
+ * The chart's left margin. The label box is this minus the tick gap, so the
17
+ * axis follows the margin instead of hardcoding an offset a custom margin
18
+ * used to push these labels outside the viewport.
19
+ */
20
+ marginLeft: number;
21
+ /** Needed to centre a rotated axis title along the gutter. */
22
+ plotHeight: number;
23
+ formatter: ChartValueFormatter;
24
+ showGrid?: boolean;
25
+ /**
26
+ * Rotated title in the left gutter.
27
+ *
28
+ * Space for it must already be reserved by `addAxisTitleSpace`, since the
29
+ * margin is resolved before this renders.
30
+ */
31
+ title?: string;
16
32
  }
17
- export declare const XAxisPoint: ({ scale, transform, formatter, }: XAxisPointProps) => import("react").JSX.Element;
18
- interface YAxisProps {
19
- scale: ScaleLinear<number, number>;
20
- transform: string;
33
+ export declare const ChartValueAxis: ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatter, showGrid, title, }: ChartValueAxisProps) => import("react").JSX.Element;
34
+ interface ChartCategoryAxisProps {
35
+ labels: string[];
36
+ /** Left edge of each category's slot, in plot coordinates. */
37
+ positions: number[];
38
+ /** Width of one category slot. */
39
+ step: number;
40
+ /** Needed to span an axis title across the full plot. */
21
41
  plotWidth: number;
22
- tickCount?: number;
23
- formatter?: ChartValueFormatter;
24
- showGrid?: boolean;
25
- theme: Theme;
42
+ plotHeight: number;
43
+ formatter: ChartLabelFormatter;
44
+ mode?: ChartCategoryLabelMode;
45
+ /**
46
+ * Title below the tick labels.
47
+ *
48
+ * Space for it must already be reserved by `addAxisTitleSpace`.
49
+ */
50
+ title?: string;
26
51
  }
27
- export declare const YAxis: ({ scale, transform, plotWidth, tickCount, formatter, showGrid, theme, }: YAxisProps) => import("react").JSX.Element;
52
+ export declare const ChartCategoryAxis: ({ labels, positions, step, plotWidth, plotHeight, formatter, mode, title, }: ChartCategoryAxisProps) => import("react").JSX.Element;
28
53
  export {};