@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.
- package/README.md +2 -0
- package/dist/avatar/Avatar.d.ts +2 -1
- package/dist/avatar/Avatar.js +103 -14
- package/dist/buttons/Button.d.ts +6 -1
- package/dist/buttons/Button.js +8 -4
- package/dist/charts/BarChart.d.ts +30 -20
- package/dist/charts/BarChart.js +216 -250
- package/dist/charts/ChartAxis.d.ts +47 -22
- package/dist/charts/ChartAxis.js +81 -60
- package/dist/charts/ChartEmptyState.d.ts +17 -0
- package/dist/charts/ChartEmptyState.js +29 -0
- package/dist/charts/ChartFrame.d.ts +82 -0
- package/dist/charts/ChartFrame.js +86 -0
- package/dist/charts/ChartLegend.d.ts +27 -4
- package/dist/charts/ChartLegend.js +46 -23
- package/dist/charts/ChartPrimitives.d.ts +195 -0
- package/dist/charts/ChartPrimitives.js +268 -0
- package/dist/charts/ChartTooltip.d.ts +27 -6
- package/dist/charts/ChartTooltip.js +56 -50
- package/dist/charts/LineChart.d.ts +42 -20
- package/dist/charts/LineChart.js +186 -237
- package/dist/charts/PieChart.d.ts +48 -32
- package/dist/charts/PieChart.js +159 -171
- package/dist/charts/barChartGeometry.d.ts +87 -0
- package/dist/charts/barChartGeometry.js +218 -0
- package/dist/charts/chartFormat.d.ts +19 -0
- package/dist/charts/chartFormat.js +59 -0
- package/dist/charts/chartScales.d.ts +84 -0
- package/dist/charts/chartScales.js +111 -0
- package/dist/charts/chartTheme.d.ts +18 -0
- package/dist/charts/chartTheme.js +26 -0
- package/dist/charts/constants.d.ts +225 -18
- package/dist/charts/constants.js +240 -32
- package/dist/charts/lineChartGeometry.d.ts +54 -0
- package/dist/charts/lineChartGeometry.js +143 -0
- package/dist/charts/pieChartGeometry.d.ts +48 -0
- package/dist/charts/pieChartGeometry.js +89 -0
- package/dist/charts/types.d.ts +522 -54
- package/dist/charts/types.js +136 -0
- package/dist/charts/useChartDimensions.d.ts +40 -0
- package/dist/charts/useChartDimensions.js +53 -0
- package/dist/charts/useChartFormatters.d.ts +19 -0
- package/dist/charts/useChartFormatters.js +20 -0
- package/dist/charts/useChartInteraction.d.ts +71 -0
- package/dist/charts/useChartInteraction.js +130 -0
- package/dist/charts/useChartTooltipPosition.d.ts +53 -0
- package/dist/charts/useChartTooltipPosition.js +39 -0
- package/dist/hooks/useElementClientSize.d.ts +20 -0
- package/dist/hooks/useElementClientSize.js +43 -0
- package/dist/inputs/CheckboxInput.d.ts +7 -2
- package/dist/inputs/CheckboxInput.js +30 -14
- package/dist/inputs/Input.d.ts +5 -2
- package/dist/inputs/Input.js +20 -17
- package/dist/inputs/MultiSelectInput.js +1 -1
- package/dist/inputs/RadioInput.js +7 -2
- package/dist/styles.css +68 -75
- package/dist/table/InfiniteSpreadsheet.d.ts +6 -0
- package/dist/table/InfiniteSpreadsheet.js +235 -0
- package/dist/table/InfiniteTable.d.ts +7 -88
- package/dist/table/InfiniteTable.js +366 -577
- package/dist/{spreadsheet → table}/SpreadsheetCell.d.ts +6 -4
- package/dist/table/SpreadsheetCell.js +71 -0
- package/dist/{spreadsheet → table}/SpreadsheetCellEditor.js +27 -21
- package/dist/table/SpreadsheetHeaderCell.d.ts +23 -0
- package/dist/table/SpreadsheetHeaderCell.js +91 -0
- package/dist/table/SpreadsheetMenuItem.d.ts +14 -0
- package/dist/table/SpreadsheetMenuItem.js +33 -0
- package/dist/table/SpreadsheetPrimitives.d.ts +172 -0
- package/dist/table/SpreadsheetPrimitives.js +105 -0
- package/dist/table/SpreadsheetRow.d.ts +33 -0
- package/dist/table/SpreadsheetRow.js +73 -0
- package/dist/{spreadsheet → table}/SpreadsheetRowActionCell.d.ts +5 -7
- package/dist/table/SpreadsheetRowActionCell.js +51 -0
- package/dist/table/TableExpandCell.d.ts +11 -0
- package/dist/table/TableExpandCell.js +24 -0
- package/dist/table/TableExpandedRow.d.ts +16 -0
- package/dist/table/TableExpandedRow.js +77 -0
- package/dist/table/TableHeaderCellContent.d.ts +30 -0
- package/dist/table/TableHeaderCellContent.js +48 -0
- package/dist/table/TablePrimitives.d.ts +307 -0
- package/dist/table/TablePrimitives.js +298 -0
- package/dist/table/TableSelectCell.d.ts +18 -0
- package/dist/table/TableSelectCell.js +26 -0
- package/dist/table/TableStatusRow.d.ts +18 -0
- package/dist/table/TableStatusRow.js +50 -0
- package/dist/table/VirtualizedInfiniteTable.d.ts +11 -27
- package/dist/table/VirtualizedInfiniteTable.js +182 -317
- package/dist/table/types.d.ts +249 -0
- package/dist/table/types.js +51 -0
- package/dist/table/useInfiniteScrollSentinel.d.ts +24 -0
- package/dist/table/useInfiniteScrollSentinel.js +53 -0
- package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.d.ts +1 -1
- package/dist/{spreadsheet/hooks → table}/useSpreadsheetEditing.js +1 -1
- package/dist/table/useTableColumnLayout.d.ts +28 -0
- package/dist/table/useTableColumnLayout.js +63 -0
- package/dist/table/useTableColumnResize.d.ts +38 -0
- package/dist/table/useTableColumnResize.js +155 -0
- package/dist/table/useTableKeyboardNavigation.d.ts +25 -0
- package/dist/table/useTableKeyboardNavigation.js +83 -0
- package/dist/table/useTableRowExpansion.d.ts +24 -0
- package/dist/table/useTableRowExpansion.js +62 -0
- package/dist/table/useTableRowSelection.d.ts +27 -0
- package/dist/table/useTableRowSelection.js +94 -0
- package/dist/table/utils.d.ts +50 -0
- package/dist/table/utils.js +78 -0
- package/dist/text/MarkdownText.js +45 -27
- package/dist/theme/variants/dark.js +1 -1
- package/dist/widget/Widget.d.ts +2 -0
- package/dist/widget/Widget.js +14 -7
- package/package.json +1 -5
- package/dist/assets/components/enrichment/PerplexityIcon.d.ts +0 -3
- package/dist/assets/components/enrichment/PerplexityIcon.js +0 -35
- package/dist/assets/components/enrichment/TavilyIcon.d.ts +0 -3
- package/dist/assets/components/enrichment/TavilyIcon.js +0 -15
- package/dist/assets/components/onboarding/TenantSetupDark.d.ts +0 -3
- package/dist/assets/components/onboarding/TenantSetupDark.js +0 -498
- package/dist/assets/components/onboarding/TenantSetupLight.d.ts +0 -3
- package/dist/assets/components/onboarding/TenantSetupLight.js +0 -482
- package/dist/assets/components/onboarding/UserSetupDark.d.ts +0 -3
- package/dist/assets/components/onboarding/UserSetupDark.js +0 -1086
- package/dist/assets/components/onboarding/UserSetupLight.d.ts +0 -3
- package/dist/assets/components/onboarding/UserSetupLight.js +0 -1024
- package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupBuildDark.js +0 -466
- package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupBuildLight.js +0 -460
- package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupConnectDark.js +0 -336
- package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupConnectLight.js +0 -336
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateDark.js +0 -153
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.d.ts +0 -3
- package/dist/assets/components/onboarding/WorkspaceSetupIntegrateLight.js +0 -153
- package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodAutoIntrospectDark.js +0 -117
- package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodAutoIntrospectLight.js +0 -117
- package/dist/assets/components/projects/MappingMethodBlankDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankDark.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankDarkHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankDarkHovered.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankLight.js +0 -150
- package/dist/assets/components/projects/MappingMethodBlankLightHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodBlankLightHovered.js +0 -150
- package/dist/assets/components/projects/MappingMethodJsonDark.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonDark.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonDarkHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonDarkHovered.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonLight.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonLight.js +0 -90
- package/dist/assets/components/projects/MappingMethodJsonLightHovered.d.ts +0 -3
- package/dist/assets/components/projects/MappingMethodJsonLightHovered.js +0 -90
- package/dist/assets/components/projects/ProjectsEmptyStateDark.d.ts +0 -3
- package/dist/assets/components/projects/ProjectsEmptyStateDark.js +0 -454
- package/dist/assets/components/projects/ProjectsEmptyStateLight.d.ts +0 -3
- package/dist/assets/components/projects/ProjectsEmptyStateLight.js +0 -456
- package/dist/assets/components/root/CreateProjectActionCardDark.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardDark.js +0 -1796
- package/dist/assets/components/root/CreateProjectActionCardDarkHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardDarkHovered.js +0 -1796
- package/dist/assets/components/root/CreateProjectActionCardLight.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardLight.js +0 -1786
- package/dist/assets/components/root/CreateProjectActionCardLightHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateProjectActionCardLightHovered.js +0 -1786
- package/dist/assets/components/root/CreateSourceActionCardDark.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardDark.js +0 -879
- package/dist/assets/components/root/CreateSourceActionCardDarkHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardDarkHovered.js +0 -879
- package/dist/assets/components/root/CreateSourceActionCardLight.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardLight.js +0 -889
- package/dist/assets/components/root/CreateSourceActionCardLightHovered.d.ts +0 -3
- package/dist/assets/components/root/CreateSourceActionCardLightHovered.js +0 -889
- package/dist/assets/components/sources/AttioIcon.d.ts +0 -3
- package/dist/assets/components/sources/AttioIcon.js +0 -11
- package/dist/assets/components/sources/BigquerySourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/BigquerySourceIcon.js +0 -39
- package/dist/assets/components/sources/BrowserbaseSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/BrowserbaseSourceIcon.js +0 -35
- package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/ClickhouseLogoSourceIconDark.js +0 -13
- package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.d.ts +0 -3
- package/dist/assets/components/sources/ClickhouseLogoSourceIconLight.js +0 -13
- package/dist/assets/components/sources/ConfluenceSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/ConfluenceSourceIcon.js +0 -30
- package/dist/assets/components/sources/GithubSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/GithubSourceIcon.js +0 -27
- package/dist/assets/components/sources/GoogleDriveIcon.d.ts +0 -3
- package/dist/assets/components/sources/GoogleDriveIcon.js +0 -45
- package/dist/assets/components/sources/HubspotSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/HubspotSourceIcon.js +0 -14
- package/dist/assets/components/sources/JiraSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/JiraSourceIcon.js +0 -54
- package/dist/assets/components/sources/LinearSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/LinearSourceIcon.js +0 -14
- package/dist/assets/components/sources/MysqlLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/MysqlLogoSourceIconDark.js +0 -17
- package/dist/assets/components/sources/NetsuiteSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/NetsuiteSourceIcon.js +0 -32
- package/dist/assets/components/sources/NotionIcon.d.ts +0 -3
- package/dist/assets/components/sources/NotionIcon.js +0 -20
- package/dist/assets/components/sources/PostgresqlIcon.d.ts +0 -3
- package/dist/assets/components/sources/PostgresqlIcon.js +0 -61
- package/dist/assets/components/sources/S3Icon.d.ts +0 -3
- package/dist/assets/components/sources/S3Icon.js +0 -76
- package/dist/assets/components/sources/SalesforceSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/SalesforceSourceIcon.js +0 -23
- package/dist/assets/components/sources/SlackIcon.d.ts +0 -3
- package/dist/assets/components/sources/SlackIcon.js +0 -32
- package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.d.ts +0 -3
- package/dist/assets/components/sources/SnowflakeLogoSourceIconDark.js +0 -14
- package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.d.ts +0 -3
- package/dist/assets/components/sources/SnowflakeLogoSourceIconLight.js +0 -14
- package/dist/assets/components/sources/WikipediaSourceIcon.d.ts +0 -3
- package/dist/assets/components/sources/WikipediaSourceIcon.js +0 -1490
- package/dist/avatar/AvatarEmpty.d.ts +0 -7
- package/dist/avatar/AvatarEmpty.js +0 -99
- package/dist/avatar/types.d.ts +0 -5
- package/dist/avatar/types.js +0 -9
- package/dist/charts/utils.d.ts +0 -29
- package/dist/charts/utils.js +0 -62
- package/dist/icons/BackIcon.d.ts +0 -3
- package/dist/icons/BackIcon.js +0 -13
- package/dist/icons/CloseIcon.d.ts +0 -3
- package/dist/icons/CloseIcon.js +0 -13
- package/dist/icons/CreateIcon.d.ts +0 -3
- package/dist/icons/CreateIcon.js +0 -13
- package/dist/icons/ForwardIcon.d.ts +0 -3
- package/dist/icons/ForwardIcon.js +0 -13
- package/dist/icons/HelpIcon.d.ts +0 -3
- package/dist/icons/HelpIcon.js +0 -14
- package/dist/icons/ProjectsIcon.d.ts +0 -3
- package/dist/icons/ProjectsIcon.js +0 -12
- package/dist/icons/SearchIcon.d.ts +0 -3
- package/dist/icons/SearchIcon.js +0 -12
- package/dist/icons/SourcesIcon.d.ts +0 -3
- package/dist/icons/SourcesIcon.js +0 -12
- package/dist/icons/TextIcon.d.ts +0 -4
- package/dist/icons/TextIcon.js +0 -22
- package/dist/icons/WebScrapeIcon.d.ts +0 -4
- package/dist/icons/WebScrapeIcon.js +0 -22
- package/dist/icons/WebhookIcon.d.ts +0 -4
- package/dist/icons/WebhookIcon.js +0 -22
- package/dist/icons/sources/AttioLogomark.d.ts +0 -4
- package/dist/icons/sources/AttioLogomark.js +0 -8
- package/dist/icons/sources/BrowserbaseLogomark.d.ts +0 -4
- package/dist/icons/sources/BrowserbaseLogomark.js +0 -8
- package/dist/icons/sources/ClickhouseLogomark.d.ts +0 -4
- package/dist/icons/sources/ClickhouseLogomark.js +0 -16
- package/dist/icons/sources/ConfluenceLogomark.d.ts +0 -4
- package/dist/icons/sources/ConfluenceLogomark.js +0 -8
- package/dist/icons/sources/GithubLogomark.d.ts +0 -4
- package/dist/icons/sources/GithubLogomark.js +0 -8
- package/dist/icons/sources/GoogleBigqueryLogomark.d.ts +0 -4
- package/dist/icons/sources/GoogleBigqueryLogomark.js +0 -8
- package/dist/icons/sources/GoogleDriveLogomark.d.ts +0 -4
- package/dist/icons/sources/GoogleDriveLogomark.js +0 -8
- package/dist/icons/sources/HubspotLogomark.d.ts +0 -4
- package/dist/icons/sources/HubspotLogomark.js +0 -8
- package/dist/icons/sources/JiraLogomark.d.ts +0 -4
- package/dist/icons/sources/JiraLogomark.js +0 -8
- package/dist/icons/sources/LinearLogomark.d.ts +0 -4
- package/dist/icons/sources/LinearLogomark.js +0 -8
- package/dist/icons/sources/MySQLLogomark.d.ts +0 -4
- package/dist/icons/sources/MySQLLogomark.js +0 -8
- package/dist/icons/sources/NetsuiteLogomark.d.ts +0 -4
- package/dist/icons/sources/NetsuiteLogomark.js +0 -8
- package/dist/icons/sources/NotionLogomark.d.ts +0 -4
- package/dist/icons/sources/NotionLogomark.js +0 -8
- package/dist/icons/sources/PostgresLogomark.d.ts +0 -4
- package/dist/icons/sources/PostgresLogomark.js +0 -8
- package/dist/icons/sources/S3Logomark.d.ts +0 -4
- package/dist/icons/sources/S3Logomark.js +0 -8
- package/dist/icons/sources/SalesforceLogomark.d.ts +0 -4
- package/dist/icons/sources/SalesforceLogomark.js +0 -8
- package/dist/icons/sources/SlackLogoIconmark.d.ts +0 -4
- package/dist/icons/sources/SlackLogoIconmark.js +0 -8
- package/dist/icons/sources/SnowflakeLogomark.d.ts +0 -4
- package/dist/icons/sources/SnowflakeLogomark.js +0 -16
- package/dist/icons/sources/WikipediaLogomark.d.ts +0 -4
- package/dist/icons/sources/WikipediaLogomark.js +0 -8
- package/dist/spreadsheet/InfiniteSpreadsheet.d.ts +0 -3
- package/dist/spreadsheet/InfiniteSpreadsheet.js +0 -265
- package/dist/spreadsheet/SpreadsheetAddColumnButton.d.ts +0 -6
- package/dist/spreadsheet/SpreadsheetAddColumnButton.js +0 -32
- package/dist/spreadsheet/SpreadsheetCell.js +0 -115
- package/dist/spreadsheet/SpreadsheetHeaderCell.d.ts +0 -18
- package/dist/spreadsheet/SpreadsheetHeaderCell.js +0 -141
- package/dist/spreadsheet/SpreadsheetRow.d.ts +0 -21
- package/dist/spreadsheet/SpreadsheetRow.js +0 -68
- package/dist/spreadsheet/SpreadsheetRowActionCell.js +0 -78
- package/dist/spreadsheet/hooks/useColumnResize.d.ts +0 -6
- package/dist/spreadsheet/hooks/useColumnResize.js +0 -46
- package/dist/spreadsheet/types.d.ts +0 -92
- package/dist/spreadsheet/types.js +0 -21
- /package/dist/{spreadsheet → table}/SpreadsheetCellEditor.d.ts +0 -0
package/dist/charts/ChartAxis.js
CHANGED
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
2
2
|
import FlexWrapper, { AlignItems, JustifyContent } from "../containers/FlexWrapper.js";
|
|
3
|
+
import { ChartCategoryLabelMode } from "./types.js";
|
|
3
4
|
import "./constants.js";
|
|
4
|
-
import {
|
|
5
|
+
import { getCategoryLabelStride } from "./chartScales.js";
|
|
6
|
+
import { ChartAxisLabelBox, ChartGridLine } from "./ChartPrimitives.js";
|
|
5
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
8
|
//#region src/charts/ChartAxis.tsx
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
var ChartValueAxis = ({ ticks, scale, plotWidth, plotHeight, marginLeft, formatter, showGrid = true, title }) => {
|
|
10
|
+
const titleBand = title ? 26 : 0;
|
|
11
|
+
const labelWidth = Math.max(0, marginLeft - titleBand - 12);
|
|
12
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
13
|
+
"aria-hidden": true,
|
|
14
|
+
children: [ticks.map((tick) => /* @__PURE__ */ jsxs("g", {
|
|
15
|
+
transform: `translate(0, ${scale(tick)})`,
|
|
16
|
+
children: [showGrid && /* @__PURE__ */ jsx(ChartGridLine, {
|
|
17
|
+
x1: -12,
|
|
18
|
+
x2: plotWidth + 12,
|
|
19
|
+
y1: 0,
|
|
20
|
+
y2: 0
|
|
21
|
+
}), labelWidth > 0 && /* @__PURE__ */ jsx(ChartAxisLabelBox, {
|
|
22
|
+
x: -marginLeft + titleBand,
|
|
23
|
+
y: -20 / 2,
|
|
24
|
+
width: labelWidth,
|
|
25
|
+
height: 20,
|
|
26
|
+
children: /* @__PURE__ */ jsx(FlexWrapper, {
|
|
27
|
+
justifyContent: JustifyContent.END,
|
|
28
|
+
alignItems: AlignItems.CENTER,
|
|
29
|
+
fillWidth: true,
|
|
30
|
+
fillHeight: true,
|
|
31
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
32
|
+
size: TextSize.CAPTION,
|
|
33
|
+
variant: TextVariant.TERTIARY,
|
|
34
|
+
align: "right",
|
|
35
|
+
isEllipsis: true,
|
|
36
|
+
children: formatter(tick)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})]
|
|
40
|
+
}, tick)), title && /* @__PURE__ */ jsx("g", {
|
|
41
|
+
transform: `translate(${-marginLeft + 18 / 2}, ${plotHeight / 2}) rotate(-90)`,
|
|
42
|
+
children: /* @__PURE__ */ jsx(ChartAxisLabelBox, {
|
|
43
|
+
x: -plotHeight / 2,
|
|
44
|
+
y: -18 / 2,
|
|
45
|
+
width: plotHeight,
|
|
46
|
+
height: 18,
|
|
16
47
|
children: /* @__PURE__ */ jsx(FlexWrapper, {
|
|
17
48
|
justifyContent: JustifyContent.CENTER,
|
|
18
49
|
alignItems: AlignItems.CENTER,
|
|
@@ -22,22 +53,28 @@ var XAxis = ({ scale, transform, formatter = defaultLabelFormatter }) => {
|
|
|
22
53
|
size: TextSize.CAPTION,
|
|
23
54
|
variant: TextVariant.TERTIARY,
|
|
24
55
|
align: "center",
|
|
25
|
-
|
|
56
|
+
isEllipsis: true,
|
|
57
|
+
children: title
|
|
26
58
|
})
|
|
27
59
|
})
|
|
28
|
-
}
|
|
29
|
-
})
|
|
60
|
+
})
|
|
61
|
+
})]
|
|
30
62
|
});
|
|
31
63
|
};
|
|
32
|
-
var
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
64
|
+
var ChartCategoryAxis = ({ labels, positions, step, plotWidth, plotHeight, formatter, mode = ChartCategoryLabelMode.AUTO, title }) => {
|
|
65
|
+
const formatted = labels.map(formatter);
|
|
66
|
+
const stride = mode === ChartCategoryLabelMode.AUTO ? getCategoryLabelStride(formatted, step) : 1;
|
|
67
|
+
const labelWidth = step * stride;
|
|
68
|
+
const labelInset = (labelWidth - step) / 2;
|
|
69
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
70
|
+
transform: `translate(0, ${plotHeight})`,
|
|
71
|
+
"aria-hidden": true,
|
|
72
|
+
children: [formatted.map((label, index) => {
|
|
73
|
+
if (index % stride !== 0) return null;
|
|
74
|
+
return /* @__PURE__ */ jsx(ChartAxisLabelBox, {
|
|
75
|
+
x: positions[index] - labelInset,
|
|
39
76
|
y: 8,
|
|
40
|
-
width:
|
|
77
|
+
width: labelWidth,
|
|
41
78
|
height: 24,
|
|
42
79
|
children: /* @__PURE__ */ jsx(FlexWrapper, {
|
|
43
80
|
justifyContent: JustifyContent.CENTER,
|
|
@@ -48,47 +85,31 @@ var XAxisPoint = ({ scale, transform, formatter = defaultLabelFormatter }) => {
|
|
|
48
85
|
size: TextSize.CAPTION,
|
|
49
86
|
variant: TextVariant.TERTIARY,
|
|
50
87
|
align: "center",
|
|
51
|
-
|
|
88
|
+
isEllipsis: mode !== ChartCategoryLabelMode.ALL,
|
|
89
|
+
children: label
|
|
52
90
|
})
|
|
53
91
|
})
|
|
54
|
-
}, label);
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
75
|
-
size: TextSize.CAPTION,
|
|
76
|
-
variant: TextVariant.TERTIARY,
|
|
77
|
-
children: formatter(tick)
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
}), showGrid && /* @__PURE__ */ jsx("line", {
|
|
81
|
-
x1: 0,
|
|
82
|
-
x2: plotWidth,
|
|
83
|
-
y1: 0,
|
|
84
|
-
y2: 0,
|
|
85
|
-
stroke: theme.color.border.primary,
|
|
86
|
-
strokeOpacity: .5,
|
|
87
|
-
strokeDasharray: "2,2"
|
|
88
|
-
})]
|
|
89
|
-
}, tick);
|
|
90
|
-
})
|
|
92
|
+
}, `${index}:${label}`);
|
|
93
|
+
}), title && /* @__PURE__ */ jsx(ChartAxisLabelBox, {
|
|
94
|
+
x: 0,
|
|
95
|
+
y: 32,
|
|
96
|
+
width: plotWidth,
|
|
97
|
+
height: 18,
|
|
98
|
+
children: /* @__PURE__ */ jsx(FlexWrapper, {
|
|
99
|
+
justifyContent: JustifyContent.CENTER,
|
|
100
|
+
alignItems: AlignItems.CENTER,
|
|
101
|
+
fillWidth: true,
|
|
102
|
+
fillHeight: true,
|
|
103
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
104
|
+
size: TextSize.CAPTION,
|
|
105
|
+
variant: TextVariant.TERTIARY,
|
|
106
|
+
align: "center",
|
|
107
|
+
isEllipsis: true,
|
|
108
|
+
children: title
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
})]
|
|
91
112
|
});
|
|
92
113
|
};
|
|
93
114
|
//#endregion
|
|
94
|
-
export {
|
|
115
|
+
export { ChartCategoryAxis, ChartValueAxis };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface ChartEmptyStateProps {
|
|
3
|
+
/** Caller-supplied content. Falls back to a centred "No data". */
|
|
4
|
+
content?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Overlay shown when a chart has nothing to plot.
|
|
8
|
+
*
|
|
9
|
+
* Rendered over the reserved plot box rather than in place of it, so the axes
|
|
10
|
+
* stay at full size and the chart does not resize when data arrives.
|
|
11
|
+
*
|
|
12
|
+
* What counts as empty is each chart's own call and deliberately inconsistent:
|
|
13
|
+
* a bar chart of all zeros is a flat chart with real data, while a pie of all
|
|
14
|
+
* zeros has no whole to apportion.
|
|
15
|
+
*/
|
|
16
|
+
declare const ChartEmptyState: ({ content }: ChartEmptyStateProps) => import("react").JSX.Element;
|
|
17
|
+
export default ChartEmptyState;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Text, { TextSize, TextVariant } from "../text/Text.js";
|
|
2
|
+
import FlexWrapper, { AlignItems, JustifyContent } from "../containers/FlexWrapper.js";
|
|
3
|
+
import { ChartEmptyOverlay } from "./ChartPrimitives.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/charts/ChartEmptyState.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Overlay shown when a chart has nothing to plot.
|
|
8
|
+
*
|
|
9
|
+
* Rendered over the reserved plot box rather than in place of it, so the axes
|
|
10
|
+
* stay at full size and the chart does not resize when data arrives.
|
|
11
|
+
*
|
|
12
|
+
* What counts as empty is each chart's own call and deliberately inconsistent:
|
|
13
|
+
* a bar chart of all zeros is a flat chart with real data, while a pie of all
|
|
14
|
+
* zeros has no whole to apportion.
|
|
15
|
+
*/
|
|
16
|
+
var ChartEmptyState = ({ content }) => /* @__PURE__ */ jsx(ChartEmptyOverlay, {
|
|
17
|
+
role: "status",
|
|
18
|
+
children: content ?? /* @__PURE__ */ jsx(FlexWrapper, {
|
|
19
|
+
justifyContent: JustifyContent.CENTER,
|
|
20
|
+
alignItems: AlignItems.CENTER,
|
|
21
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
22
|
+
size: TextSize.CAPTION,
|
|
23
|
+
variant: TextVariant.TERTIARY,
|
|
24
|
+
children: "No data"
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ChartEmptyState as default };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ChartLegendItem, ChartPlotTooltipModel, ChartTooltipRenderer } from "./types";
|
|
3
|
+
import type { ChartDimensions } from "./useChartDimensions";
|
|
4
|
+
import type { ChartInteraction } from "./useChartInteraction";
|
|
5
|
+
import type { ChartTooltipVerticalAlign } from "./useChartTooltipPosition";
|
|
6
|
+
/**
|
|
7
|
+
* The shell every chart renders into: measured root, reserved plot box, SVG and
|
|
8
|
+
* its margin translate, the interactive plot group, the backdrop, the tooltip,
|
|
9
|
+
* the empty state and the legend.
|
|
10
|
+
*
|
|
11
|
+
* **The frame owns the plot translate.** Marks are drawn inside a
|
|
12
|
+
* `translate(margin.left, margin.top)` group, and every coordinate handed to
|
|
13
|
+
* this component — including the tooltip anchor and `placeAwayFromX` — is in
|
|
14
|
+
* that same plot space. Charts never add the margin themselves; three
|
|
15
|
+
* hand-written copies of `+ margin.left` is precisely what drifts silently.
|
|
16
|
+
*
|
|
17
|
+
* Knows nothing about scales, marks or geometry — all of that arrives through
|
|
18
|
+
* `axes` and `children`.
|
|
19
|
+
*
|
|
20
|
+
* @internal Published as a subpath only because this package has no barrel
|
|
21
|
+
* files, not because charts are meant to be composed out of it.
|
|
22
|
+
*/
|
|
23
|
+
export interface ChartFrameProps {
|
|
24
|
+
/**
|
|
25
|
+
* The element `useChartDimensions` measures — the *plot box*, not the root.
|
|
26
|
+
*
|
|
27
|
+
* Measuring the plot box is what keeps `fillHeight` honest: the legend is a
|
|
28
|
+
* sibling in the root's flex column, so the box's height is already the space
|
|
29
|
+
* left over for the plot and no one has to subtract a wrapped legend. Width is
|
|
30
|
+
* unaffected, the box being `width: 100%` of the root either way.
|
|
31
|
+
*
|
|
32
|
+
* Created by the chart, not here: the chart needs the resulting dimensions
|
|
33
|
+
* during its own render — to size the geometry and to feed
|
|
34
|
+
* `useChartInteraction` — so the ref has to exist before this component does.
|
|
35
|
+
* A named prop rather than `ref` because ref-as-a-prop needs React 19 and this
|
|
36
|
+
* package still supports 18.
|
|
37
|
+
*/
|
|
38
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
39
|
+
dimensions: ChartDimensions;
|
|
40
|
+
fillWidth?: boolean;
|
|
41
|
+
fillHeight?: boolean;
|
|
42
|
+
interaction: ChartInteraction;
|
|
43
|
+
/** Already resolved — pass `ariaLabel ?? <chart-specific default>`. */
|
|
44
|
+
ariaLabel: string;
|
|
45
|
+
/** Long description, associated with the SVG via `aria-describedby`. */
|
|
46
|
+
ariaDescription?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Axes, drawn inside the plot translate group *before* {@link children}, so
|
|
49
|
+
* grid lines paint under the marks. Radial charts pass nothing.
|
|
50
|
+
*/
|
|
51
|
+
axes?: ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* Marks, drawn inside the plot group above the backdrop.
|
|
54
|
+
*
|
|
55
|
+
* Rendered only once measured, so no caller writes that guard. Note it is
|
|
56
|
+
* still *evaluated* on the unmeasured pass — as is the geometry it maps over,
|
|
57
|
+
* which each chart's `useMemo` already runs at a 0×0 plot. Geometry builders
|
|
58
|
+
* must stay total at zero; they already are.
|
|
59
|
+
*/
|
|
60
|
+
children?: ReactNode;
|
|
61
|
+
/** HTML painted over the plot and under the tooltip — the donut centre. */
|
|
62
|
+
plotOverlay?: ReactNode;
|
|
63
|
+
noTooltip?: boolean;
|
|
64
|
+
/** Anchor in plot coordinates; the frame applies the margin translate. */
|
|
65
|
+
tooltipModel: ChartPlotTooltipModel | null;
|
|
66
|
+
tooltipRenderer?: ChartTooltipRenderer;
|
|
67
|
+
/** Half a category's width, so the tooltip sits beside the marks. */
|
|
68
|
+
anchorHalfWidth?: number;
|
|
69
|
+
/** Radial charts pass their centre, in plot coordinates. */
|
|
70
|
+
placeAwayFromX?: number;
|
|
71
|
+
verticalAlign?: ChartTooltipVerticalAlign;
|
|
72
|
+
/** Each chart defines "empty" for itself; the frame only renders the result. */
|
|
73
|
+
isEmpty: boolean;
|
|
74
|
+
isLoading?: boolean;
|
|
75
|
+
contentWhenEmpty?: ReactNode;
|
|
76
|
+
showLegend?: boolean;
|
|
77
|
+
legendItems: ChartLegendItem[];
|
|
78
|
+
/** Defaults to the left margin, aligning the legend with the plot, not the gutter. */
|
|
79
|
+
legendInset?: number;
|
|
80
|
+
}
|
|
81
|
+
declare const ChartFrame: ({ containerRef, dimensions, fillWidth, fillHeight, interaction, ariaLabel, ariaDescription, axes, children, plotOverlay, noTooltip, tooltipModel, tooltipRenderer, anchorHalfWidth, placeAwayFromX, verticalAlign, isEmpty, isLoading, contentWhenEmpty, showLegend, legendItems, legendInset, }: ChartFrameProps) => import("react").JSX.Element;
|
|
82
|
+
export default ChartFrame;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ChartBackdrop, ChartPlotBox, ChartPlotGroup, ChartRoot, ChartSvg } from "./ChartPrimitives.js";
|
|
2
|
+
import ChartEmptyState from "./ChartEmptyState.js";
|
|
3
|
+
import ChartLegend from "./ChartLegend.js";
|
|
4
|
+
import ChartHoverTooltip from "./ChartTooltip.js";
|
|
5
|
+
import { useId, useMemo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/charts/ChartFrame.tsx
|
|
8
|
+
var ChartFrame = ({ containerRef, dimensions, fillWidth, fillHeight, interaction, ariaLabel, ariaDescription, axes, children, plotOverlay, noTooltip = false, tooltipModel, tooltipRenderer, anchorHalfWidth, placeAwayFromX, verticalAlign, isEmpty, isLoading = false, contentWhenEmpty, showLegend = false, legendItems, legendInset }) => {
|
|
9
|
+
const { width, height, plotWidth, plotHeight, margin, isMeasured, reservedHeight, reservedAspectRatio } = dimensions;
|
|
10
|
+
const generatedId = useId();
|
|
11
|
+
const descriptionId = ariaDescription ? `${generatedId}-desc` : void 0;
|
|
12
|
+
/**
|
|
13
|
+
* Plot space → container space, applied once, here.
|
|
14
|
+
*
|
|
15
|
+
* Memoized for correctness, not arithmetic cost. `ChartTooltip` retains the
|
|
16
|
+
* last model by *identity* so it can keep its content while fading out, and
|
|
17
|
+
* adjusts that state during render when the identity changes. A fresh object
|
|
18
|
+
* on every parent render would therefore trigger an extra render pass on
|
|
19
|
+
* every render — including every pointer move — without ever looping or
|
|
20
|
+
* visibly breaking.
|
|
21
|
+
*/
|
|
22
|
+
const positionedTooltip = useMemo(() => tooltipModel === null ? null : {
|
|
23
|
+
...tooltipModel,
|
|
24
|
+
anchorX: tooltipModel.anchorX + margin.left,
|
|
25
|
+
anchorY: tooltipModel.anchorY + margin.top
|
|
26
|
+
}, [
|
|
27
|
+
tooltipModel,
|
|
28
|
+
margin.left,
|
|
29
|
+
margin.top
|
|
30
|
+
]);
|
|
31
|
+
return /* @__PURE__ */ jsxs(ChartRoot, {
|
|
32
|
+
$fillWidth: fillWidth,
|
|
33
|
+
$fillHeight: fillHeight,
|
|
34
|
+
children: [/* @__PURE__ */ jsxs(ChartPlotBox, {
|
|
35
|
+
ref: containerRef,
|
|
36
|
+
$reservedHeight: reservedHeight,
|
|
37
|
+
$reservedAspectRatio: reservedAspectRatio,
|
|
38
|
+
$fillHeight: fillHeight,
|
|
39
|
+
children: [
|
|
40
|
+
isMeasured && /* @__PURE__ */ jsxs(ChartSvg, {
|
|
41
|
+
width,
|
|
42
|
+
height,
|
|
43
|
+
role: "img",
|
|
44
|
+
"aria-label": ariaLabel,
|
|
45
|
+
"aria-describedby": descriptionId,
|
|
46
|
+
children: [ariaDescription && /* @__PURE__ */ jsx("desc", {
|
|
47
|
+
id: descriptionId,
|
|
48
|
+
children: ariaDescription
|
|
49
|
+
}), /* @__PURE__ */ jsxs("g", {
|
|
50
|
+
transform: `translate(${margin.left}, ${margin.top})`,
|
|
51
|
+
children: [axes, /* @__PURE__ */ jsxs(ChartPlotGroup, {
|
|
52
|
+
"data-active": interaction.isEngaged ? "true" : "false",
|
|
53
|
+
children: [/* @__PURE__ */ jsx(ChartBackdrop, {
|
|
54
|
+
width: plotWidth,
|
|
55
|
+
height: plotHeight,
|
|
56
|
+
"data-interactive": interaction.pinnedIndex !== null ? "true" : "false",
|
|
57
|
+
onClick: interaction.onBackdropClick
|
|
58
|
+
}), children]
|
|
59
|
+
})]
|
|
60
|
+
})]
|
|
61
|
+
}),
|
|
62
|
+
isMeasured && plotOverlay,
|
|
63
|
+
isMeasured && !noTooltip && /* @__PURE__ */ jsx(ChartHoverTooltip, {
|
|
64
|
+
model: positionedTooltip,
|
|
65
|
+
containerWidth: width,
|
|
66
|
+
containerHeight: height,
|
|
67
|
+
anchorHalfWidth,
|
|
68
|
+
placeAwayFromX: placeAwayFromX === void 0 ? void 0 : placeAwayFromX + margin.left,
|
|
69
|
+
verticalAlign,
|
|
70
|
+
renderer: tooltipRenderer
|
|
71
|
+
}),
|
|
72
|
+
isMeasured && isEmpty && !isLoading && /* @__PURE__ */ jsx(ChartEmptyState, { content: contentWhenEmpty })
|
|
73
|
+
]
|
|
74
|
+
}), showLegend && /* @__PURE__ */ jsx(ChartLegend, {
|
|
75
|
+
items: legendItems,
|
|
76
|
+
inset: legendInset ?? margin.left,
|
|
77
|
+
hoveredKey: interaction.hoveredSeriesKey,
|
|
78
|
+
pinnedKey: interaction.pinnedSeriesKey,
|
|
79
|
+
onItemEnter: interaction.onSeriesEnter,
|
|
80
|
+
onItemLeave: interaction.onSeriesLeave,
|
|
81
|
+
onItemClick: interaction.onSeriesClick
|
|
82
|
+
})]
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { ChartFrame as default };
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChartLegendItem } from "./types";
|
|
2
2
|
interface ChartLegendProps {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
items: ChartLegendItem[];
|
|
4
|
+
/** Left padding aligning the legend with the plot, not the axis gutter. */
|
|
5
|
+
inset: number;
|
|
6
|
+
/** Series key currently hovered anywhere in the chart. */
|
|
7
|
+
hoveredKey?: string | null;
|
|
8
|
+
/** Series key currently pinned. Drives `aria-pressed`. */
|
|
9
|
+
pinnedKey?: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Supplying these makes the legend interactive. Omit them and it renders as
|
|
12
|
+
* inert text, with no button semantics for a screen reader to announce.
|
|
13
|
+
*/
|
|
14
|
+
onItemEnter?: (key: string) => void;
|
|
15
|
+
onItemLeave?: () => void;
|
|
16
|
+
onItemClick?: (key: string) => void;
|
|
5
17
|
}
|
|
6
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Legend for the chart components.
|
|
20
|
+
*
|
|
21
|
+
* Hovering an entry isolates its series and clicking pins that isolation.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately *not* a visibility toggle: hiding a series would have to rescale
|
|
24
|
+
* the value axis to stay honest — otherwise the remaining bars sit mysteriously
|
|
25
|
+
* short — and that belongs with the geometry layer rather than bolted on here.
|
|
26
|
+
* Isolation only changes opacity, so the domain is untouched and the numbers
|
|
27
|
+
* keep meaning what they did.
|
|
28
|
+
*/
|
|
29
|
+
declare const ChartLegend: ({ items, inset, hoveredKey, pinnedKey, onItemEnter, onItemLeave, onItemClick, }: ChartLegendProps) => import("react").JSX.Element | null;
|
|
7
30
|
export default ChartLegend;
|
|
@@ -1,28 +1,51 @@
|
|
|
1
|
-
import Text, { TextSize
|
|
2
|
-
import FlexWrapper, { AlignItems, FlexDirection } from "../containers/FlexWrapper.js";
|
|
1
|
+
import Text, { TextSize } from "../text/Text.js";
|
|
3
2
|
import Circle from "../shapes/Circle.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { ChartMarkState } from "./types.js";
|
|
4
|
+
import { ChartLegendItemButton, ChartLegendItemStatic, ChartLegendRow } from "./ChartPrimitives.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/charts/ChartLegend.tsx
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Legend for the chart components.
|
|
9
|
+
*
|
|
10
|
+
* Hovering an entry isolates its series and clicking pins that isolation.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately *not* a visibility toggle: hiding a series would have to rescale
|
|
13
|
+
* the value axis to stay honest — otherwise the remaining bars sit mysteriously
|
|
14
|
+
* short — and that belongs with the geometry layer rather than bolted on here.
|
|
15
|
+
* Isolation only changes opacity, so the domain is untouched and the numbers
|
|
16
|
+
* keep meaning what they did.
|
|
17
|
+
*/
|
|
18
|
+
var ChartLegend = ({ items, inset, hoveredKey = null, pinnedKey = null, onItemEnter, onItemLeave, onItemClick }) => {
|
|
19
|
+
if (items.length === 0) return null;
|
|
20
|
+
const isInteractive = Boolean(onItemEnter ?? onItemClick);
|
|
21
|
+
const activeKey = pinnedKey ?? hoveredKey;
|
|
22
|
+
return /* @__PURE__ */ jsx(ChartLegendRow, {
|
|
23
|
+
$inset: inset,
|
|
24
|
+
"data-active": activeKey !== null ? "true" : "false",
|
|
25
|
+
children: items.map((item) => {
|
|
26
|
+
const state = activeKey === null || item.key === activeKey ? ChartMarkState.ACTIVE : ChartMarkState.MUTED;
|
|
27
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Circle, {
|
|
28
|
+
size: 8,
|
|
29
|
+
hex: item.color
|
|
30
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
31
|
+
size: TextSize.BODY_SM,
|
|
32
|
+
children: item.label
|
|
33
|
+
})] });
|
|
34
|
+
if (!isInteractive) return /* @__PURE__ */ jsx(ChartLegendItemStatic, {
|
|
35
|
+
"data-state": state,
|
|
36
|
+
children: content
|
|
37
|
+
}, item.key);
|
|
38
|
+
return /* @__PURE__ */ jsx(ChartLegendItemButton, {
|
|
39
|
+
type: "button",
|
|
40
|
+
"data-state": state,
|
|
41
|
+
"aria-pressed": pinnedKey === item.key,
|
|
42
|
+
onMouseEnter: () => onItemEnter?.(item.key),
|
|
43
|
+
onMouseLeave: () => onItemLeave?.(),
|
|
44
|
+
onFocus: () => onItemEnter?.(item.key),
|
|
45
|
+
onBlur: () => onItemLeave?.(),
|
|
46
|
+
onClick: () => onItemClick?.(item.key),
|
|
47
|
+
children: content
|
|
48
|
+
}, item.key);
|
|
26
49
|
})
|
|
27
50
|
});
|
|
28
51
|
};
|