@fluentui/react-charts 9.3.7 → 9.3.9
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/CHANGELOG.md +60 -2
- package/dist/index.d.ts +433 -7
- package/lib/PolarChart.js +1 -0
- package/lib/PolarChart.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -1
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
- package/lib/components/AreaChart/AreaChart.js +1 -28
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +1 -2
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +27 -8
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +24 -3
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +14 -2
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +111 -69
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +54 -4
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +31 -18
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +81 -44
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +5 -5
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -3
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +33 -29
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +643 -366
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +24 -9
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +25 -5
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +16 -5
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +33 -8
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +26 -4
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +15 -3
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +1 -1
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +13 -9
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +31 -19
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +23 -18
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +18 -18
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +1 -2
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +5 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +60 -10
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +18 -3
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +13 -2
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js +3 -4
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js +9 -2
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +65 -64
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +1 -2
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/PolarChart/PolarChart.js +577 -0
- package/lib/components/PolarChart/PolarChart.js.map +1 -0
- package/lib/components/PolarChart/PolarChart.types.js +1 -0
- package/lib/components/PolarChart/PolarChart.types.js.map +1 -0
- package/lib/components/PolarChart/PolarChart.utils.js +174 -0
- package/lib/components/PolarChart/PolarChart.utils.js.map +1 -0
- package/lib/components/PolarChart/index.js +2 -0
- package/lib/components/PolarChart/index.js.map +1 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.js +72 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.js.map +1 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.raw.js +61 -0
- package/lib/components/PolarChart/usePolarChartStyles.styles.raw.js.map +1 -0
- package/lib/components/SankeyChart/SankeyChart.js +15 -5
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +24 -8
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +15 -5
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +13 -25
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +1 -2
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +13 -78
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +1 -2
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +48 -68
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +1 -2
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/ChartAnnotation.js.map +1 -1
- package/lib/types/DataPoint.js +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/ChartTitle.js +45 -0
- package/lib/utilities/ChartTitle.js.map +1 -0
- package/lib/utilities/Common.styles.js +73 -2
- package/lib/utilities/Common.styles.js.map +1 -1
- package/lib/utilities/Common.styles.raw.js +70 -1
- package/lib/utilities/Common.styles.raw.js.map +1 -1
- package/lib/utilities/image-export-utils.js +4 -4
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/index.js +1 -0
- package/lib/utilities/index.js.map +1 -1
- package/lib/utilities/utilities.js +219 -77
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/PolarChart.js +6 -0
- package/lib-commonjs/PolarChart.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -1
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +0 -26
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +0 -2
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +27 -8
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +34 -3
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +14 -2
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +111 -69
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +65 -5
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +31 -18
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +80 -43
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +3 -4
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +3 -2
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +59 -56
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +649 -368
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +22 -7
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +31 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +15 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +31 -6
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +36 -4
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +15 -3
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +11 -7
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +39 -18
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +23 -18
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +16 -16
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +5 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +59 -9
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +26 -3
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +13 -2
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +3 -4
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js +9 -2
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +64 -63
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +0 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/PolarChart/PolarChart.js +587 -0
- package/lib-commonjs/components/PolarChart/PolarChart.js.map +1 -0
- package/lib-commonjs/components/PolarChart/PolarChart.types.js +6 -0
- package/lib-commonjs/components/PolarChart/PolarChart.types.js.map +1 -0
- package/lib-commonjs/components/PolarChart/PolarChart.utils.js +204 -0
- package/lib-commonjs/components/PolarChart/PolarChart.utils.js.map +1 -0
- package/lib-commonjs/components/PolarChart/index.js +7 -0
- package/lib-commonjs/components/PolarChart/index.js.map +1 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.js +107 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.raw.js +75 -0
- package/lib-commonjs/components/PolarChart/usePolarChartStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +15 -5
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +28 -6
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +14 -3
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +12 -24
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +0 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +12 -77
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +47 -67
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +0 -2
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/ChartAnnotation.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/ChartTitle.js +53 -0
- package/lib-commonjs/utilities/ChartTitle.js.map +1 -0
- package/lib-commonjs/utilities/Common.styles.js +69 -1
- package/lib-commonjs/utilities/Common.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.raw.js +69 -1
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +3 -3
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/index.js +1 -0
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +235 -78
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +11 -17
- package/lib/components/DeclarativeChart/imageExporter.js +0 -223
- package/lib/components/DeclarativeChart/imageExporter.js.map +0 -1
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js +0 -233
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +0 -1
|
@@ -16,7 +16,9 @@ const _reacttheme = require("@fluentui/react-theme");
|
|
|
16
16
|
const _d3color = /*#__PURE__*/ _interop_require_wildcard._(require("d3-color"));
|
|
17
17
|
const _colors = require("../../utilities/colors");
|
|
18
18
|
const _utilities = require("../../utilities/utilities");
|
|
19
|
+
const _index = require("../../utilities/index");
|
|
19
20
|
const _hooks = require("../../utilities/hooks");
|
|
21
|
+
const _reacttabster = require("@fluentui/react-tabster");
|
|
20
22
|
function invertHexColor(hex) {
|
|
21
23
|
const color = _d3color.color(hex);
|
|
22
24
|
if (!color) {
|
|
@@ -47,9 +49,12 @@ function getSafeBackgroundColor(chartContainer, foreground, background) {
|
|
|
47
49
|
return invertedContrast >= 3 ? invertedBg : fallbackBg;
|
|
48
50
|
}
|
|
49
51
|
const ChartTable = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
50
|
-
const { headers, rows, width, height } = props;
|
|
52
|
+
const { headers, rows, width, height, chartTitle } = props;
|
|
51
53
|
const { chartContainerRef: _rootElem } = (0, _hooks.useImageExport)(props.componentRef, true, false);
|
|
52
54
|
const classes = (0, _useChartTableStylesstyles.useChartTableStyles)(props);
|
|
55
|
+
const arrowAttributes = (0, _reacttabster.useArrowNavigationGroup)({
|
|
56
|
+
axis: 'grid'
|
|
57
|
+
});
|
|
53
58
|
if (!headers || headers.length === 0) {
|
|
54
59
|
return /*#__PURE__*/ _react.createElement("div", null, "No data available");
|
|
55
60
|
}
|
|
@@ -85,23 +90,36 @@ const ChartTable = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
}
|
|
93
|
+
const titleHeight = chartTitle ? 30 : 0;
|
|
94
|
+
const totalHeight = typeof height === 'number' ? height : 650;
|
|
95
|
+
const tableHeight = `${totalHeight - titleHeight}px`;
|
|
96
|
+
const svgWidth = typeof width === 'number' ? width : '100%';
|
|
97
|
+
const titleMaxWidth = typeof width === 'number' ? width - 20 : undefined;
|
|
98
|
+
const titleX = typeof width === 'number' ? width / 2 : 0;
|
|
88
99
|
return /*#__PURE__*/ _react.createElement("div", {
|
|
89
100
|
ref: (el)=>{
|
|
90
101
|
_rootElem.current = el;
|
|
91
102
|
},
|
|
92
103
|
className: classes.root,
|
|
93
104
|
style: {
|
|
94
|
-
height:
|
|
105
|
+
height: `${totalHeight}px`,
|
|
95
106
|
overflow: 'hidden'
|
|
96
107
|
}
|
|
97
108
|
}, /*#__PURE__*/ _react.createElement("svg", {
|
|
98
|
-
width:
|
|
99
|
-
height:
|
|
100
|
-
}, /*#__PURE__*/ _react.createElement(
|
|
109
|
+
width: svgWidth,
|
|
110
|
+
height: `${totalHeight}px`
|
|
111
|
+
}, chartTitle && /*#__PURE__*/ _react.createElement(_index.ChartTitle, {
|
|
112
|
+
title: chartTitle,
|
|
113
|
+
x: titleX,
|
|
114
|
+
maxWidth: titleMaxWidth,
|
|
115
|
+
className: classes.chartTitle,
|
|
116
|
+
titleStyles: props.titleStyles,
|
|
117
|
+
tooltipClassName: classes.svgTooltip
|
|
118
|
+
}), /*#__PURE__*/ _react.createElement("foreignObject", {
|
|
101
119
|
x: "0",
|
|
102
|
-
y:
|
|
120
|
+
y: titleHeight,
|
|
103
121
|
width: "100%",
|
|
104
|
-
height:
|
|
122
|
+
height: tableHeight
|
|
105
123
|
}, /*#__PURE__*/ _react.createElement("div", {
|
|
106
124
|
style: {
|
|
107
125
|
maxHeight: height ? `${height}px` : '650px',
|
|
@@ -112,7 +130,8 @@ const ChartTable = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
|
|
|
112
130
|
className: classes.table,
|
|
113
131
|
style: {
|
|
114
132
|
width: width ? `${width}px` : '100%'
|
|
115
|
-
}
|
|
133
|
+
},
|
|
134
|
+
...arrowAttributes
|
|
116
135
|
}, /*#__PURE__*/ _react.createElement("thead", null, /*#__PURE__*/ _react.createElement("tr", null, headers.map((header, idx)=>{
|
|
117
136
|
const style = {
|
|
118
137
|
...header === null || header === void 0 ? void 0 : header.style
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ChartTable/ChartTable.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChartTableProps } from './ChartTable.types';\nimport { useChartTableStyles } from './useChartTableStyles.styles';\nimport { tokens } from '@fluentui/react-theme';\nimport * as d3 from 'd3-color';\nimport { getColorContrast } from '../../utilities/colors';\nimport { resolveCSSVariables } from '../../utilities/utilities';\nimport { useImageExport } from '../../utilities/hooks';\n\nfunction invertHexColor(hex: string): string {\n const color = d3.color(hex);\n if (!color) {\n return tokens.colorNeutralForeground1!;\n }\n const rgb = color.rgb();\n return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();\n}\n\nfunction getSafeBackgroundColor(chartContainer: HTMLElement, foreground?: string, background?: string): string {\n const fallbackFg = tokens.colorNeutralForeground1;\n const fallbackBg = tokens.colorNeutralBackground1;\n if (!chartContainer) {\n return fallbackBg;\n }\n\n const resolvedFg = resolveCSSVariables(chartContainer, foreground || fallbackFg);\n const resolvedBg = resolveCSSVariables(chartContainer, background || fallbackBg);\n\n const fg = d3.color(resolvedFg);\n const bg = d3.color(resolvedBg);\n\n if (!fg || !bg) {\n return resolvedBg;\n }\n const contrast = getColorContrast(fg.formatHex(), bg.formatHex());\n if (contrast >= 3) {\n return bg.formatHex();\n }\n\n const invertedBg = invertHexColor(bg.formatHex());\n const invertedContrast = getColorContrast(fg.formatHex(), invertedBg);\n return invertedContrast >= 3 ? invertedBg : fallbackBg;\n}\n\nexport const ChartTable: React.FunctionComponent<ChartTableProps> = React.forwardRef<HTMLDivElement, ChartTableProps>(\n (props, forwardedRef) => {\n const { headers, rows, width, height } = props;\n const { chartContainerRef: _rootElem } = useImageExport(props.componentRef, true, false);\n const classes = useChartTableStyles(props);\n\n if (!headers || headers.length === 0) {\n return <div>No data available</div>;\n }\n\n const bgColorSet = new Set<string>();\n headers.forEach(header => {\n const bg = header?.style?.backgroundColor;\n const normalized = d3.color(bg || '')?.formatHex();\n if (normalized) {\n bgColorSet.add(normalized);\n }\n });\n let sharedBackgroundColor: string | undefined;\n let useSharedBackground = false;\n\n /*\n If we have only one or two unique background colors, we can consider using a shared background color\n for the table headers. This is to ensure better contrast with the foreground text.\n For size 1, we will consider that as default color if it satisfies the contrast ratio.\n There could also be a scenario where backgroundcolor array is of size 2, for eg: [\"dimsgray\", \"gray\"],\n which will assign 1st column header bg color to dimsgray and rest to gray. so our logic of shared background\n color won't run here. So will consider for size 2 as well.\n For size greater than this, we will consider that user wants different colors and will let color contrast fail\n if any.\n */\n if (bgColorSet.size === 1 || bgColorSet.size === 2) {\n const candidateBg = bgColorSet.size === 1 ? Array.from(bgColorSet)[0] : Array.from(bgColorSet)[1];\n for (const header of headers) {\n const fg = header?.style?.color;\n if (fg && getColorContrast(fg, candidateBg) >= 3) {\n sharedBackgroundColor = candidateBg;\n useSharedBackground = true;\n break;\n }\n }\n }\n\n return (\n <div\n ref={el => {\n _rootElem.current = el;\n }}\n className={classes.root as string}\n style={{ height: height ? `${height}px` : '650px', overflow: 'hidden' }}\n >\n <svg width={width ?? '100%'} height={height ?? '650px'}>\n <foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">\n <div\n style={{\n maxHeight: height ? `${height}px` : '650px',\n overflowY: 'auto',\n overflowX: 'auto',\n }}\n >\n <table\n className={classes.table}\n style={{\n width: width ? `${width}px` : '100%',\n }}\n >\n <thead>\n <tr>\n {headers.map((header, idx) => {\n const style = { ...header?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n\n if (useSharedBackground) {\n style.backgroundColor = sharedBackgroundColor;\n } else if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(_rootElem.current!, fg, bg);\n }\n return (\n <th key={idx} className={classes.headerCell} style={style} tabIndex={0}>\n {header.value}\n </th>\n );\n })}\n </tr>\n </thead>\n {rows && rows.length > 0 && (\n <tbody>\n {rows.map((row, rowIdx) => (\n <tr key={rowIdx}>\n {row.map((cell, colIdx) => {\n const style = { ...cell?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(_rootElem.current!, fg, bg);\n }\n return (\n <td key={colIdx} className={classes.bodyCell} style={style} tabIndex={0}>\n {cell.value}\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n },\n);\n\nChartTable.displayName = 'ChartTable';\n"],"names":["React","useChartTableStyles","tokens","d3","getColorContrast","resolveCSSVariables","useImageExport","invertHexColor","hex","color","colorNeutralForeground1","rgb","r","g","b","formatHex","getSafeBackgroundColor","chartContainer","foreground","background","fallbackFg","fallbackBg","colorNeutralBackground1","resolvedFg","resolvedBg","fg","bg","contrast","invertedBg","invertedContrast","ChartTable","forwardRef","props","forwardedRef","headers","rows","width","height","chartContainerRef","_rootElem","componentRef","classes","length","div","bgColorSet","Set","forEach","header","style","backgroundColor","normalized","add","sharedBackgroundColor","useSharedBackground","size","candidateBg","Array","from","ref","el","current","className","root","overflow","svg","foreignObject","x","y","maxHeight","overflowY","overflowX","table","thead","tr","map","idx","th","key","headerCell","tabIndex","value","tbody","row","rowIdx","cell","colIdx","td","bodyCell","displayName"],"mappings":"AAAA;;;;;;;;eA8Ca8B;;;;iEA5CU,QAAQ;2CAEK,+BAA+B;4BAC5C,wBAAwB;mEAC3B,WAAW;wBACE,yBAAyB;2BACtB,4BAA4B;uBACjC,wBAAwB;AAEvD,SAASvB,eA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+B,UAAU;WAClEhC,OAAOiC,KAAK;IAGnB,MAGH7C,QAAQA,KAAKO,MAAM,GAAG,KAAA,WAAA,GACrB,OAAA,aAAA,CAACuC,SAAAA,MACE9C,KAAKuC,GAAG,CAAC,CAACQ,KAAKC,SAAAA,WAAAA,GACd,OAAA,aAAA,CAACV,MAAAA;YAAGI,KAAKM;WACND,IAAIR,GAAG,CAAC,CAACU,MAAMC;YACd,MAAMrC,QAAQ;mBAAKoC,SAAAA,QAAAA,SAAAA,KAAAA,IAAAA,KAAAA,IAAAA,KAAMpC,KAAT;YAAe;YAC/B,MAAMvB,KAAKuB,MAAMvC,KAAK;YACtB,MAAMiB,KAAKsB,MAAMC,eAAe;YAChC,IAAIxB,MAAMC,IAAI;gBACZsB,MAAMC,eAAe,GAAGjC,uBAAuBuB,UAAUqB,OAAO,EAAGnC,IAAIC;YACzE;YACA,OAAA,WAAA,GACE,OAAA,aAAA,CAAC4D,MAAAA;gBAAGT,KAAKQ;gBAAQxB,WAAWpB,QAAQ8C,QAAQ;gBAAEvC,OAAOA;gBAAO+B,UAAU;eACnEK,KAAKJ,KAAK;QAGjB;AAWtB,GACA;AAEFlD,WAAW0D,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../src/components/ChartTable/ChartTable.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChartTableProps } from './ChartTable.types';\nimport { useChartTableStyles } from './useChartTableStyles.styles';\nimport { tokens } from '@fluentui/react-theme';\nimport * as d3 from 'd3-color';\nimport { getColorContrast } from '../../utilities/colors';\nimport { resolveCSSVariables } from '../../utilities/utilities';\nimport { ChartTitle } from '../../utilities/index';\nimport { useImageExport } from '../../utilities/hooks';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\n\nfunction invertHexColor(hex: string): string {\n const color = d3.color(hex);\n if (!color) {\n return tokens.colorNeutralForeground1!;\n }\n const rgb = color.rgb();\n return d3.rgb(255 - rgb.r, 255 - rgb.g, 255 - rgb.b).formatHex();\n}\n\nfunction getSafeBackgroundColor(chartContainer: HTMLElement, foreground?: string, background?: string): string {\n const fallbackFg = tokens.colorNeutralForeground1;\n const fallbackBg = tokens.colorNeutralBackground1;\n if (!chartContainer) {\n return fallbackBg;\n }\n\n const resolvedFg = resolveCSSVariables(chartContainer, foreground || fallbackFg);\n const resolvedBg = resolveCSSVariables(chartContainer, background || fallbackBg);\n\n const fg = d3.color(resolvedFg);\n const bg = d3.color(resolvedBg);\n\n if (!fg || !bg) {\n return resolvedBg;\n }\n const contrast = getColorContrast(fg.formatHex(), bg.formatHex());\n if (contrast >= 3) {\n return bg.formatHex();\n }\n\n const invertedBg = invertHexColor(bg.formatHex());\n const invertedContrast = getColorContrast(fg.formatHex(), invertedBg);\n return invertedContrast >= 3 ? invertedBg : fallbackBg;\n}\n\nexport const ChartTable: React.FunctionComponent<ChartTableProps> = React.forwardRef<HTMLDivElement, ChartTableProps>(\n (props, forwardedRef) => {\n const { headers, rows, width, height, chartTitle } = props;\n const { chartContainerRef: _rootElem } = useImageExport(props.componentRef, true, false);\n const classes = useChartTableStyles(props);\n const arrowAttributes = useArrowNavigationGroup({ axis: 'grid' });\n\n if (!headers || headers.length === 0) {\n return <div>No data available</div>;\n }\n\n const bgColorSet = new Set<string>();\n headers.forEach(header => {\n const bg = header?.style?.backgroundColor;\n const normalized = d3.color(bg || '')?.formatHex();\n if (normalized) {\n bgColorSet.add(normalized);\n }\n });\n let sharedBackgroundColor: string | undefined;\n let useSharedBackground = false;\n\n /*\n If we have only one or two unique background colors, we can consider using a shared background color\n for the table headers. This is to ensure better contrast with the foreground text.\n For size 1, we will consider that as default color if it satisfies the contrast ratio.\n There could also be a scenario where backgroundcolor array is of size 2, for eg: [\"dimsgray\", \"gray\"],\n which will assign 1st column header bg color to dimsgray and rest to gray. so our logic of shared background\n color won't run here. So will consider for size 2 as well.\n For size greater than this, we will consider that user wants different colors and will let color contrast fail\n if any.\n */\n if (bgColorSet.size === 1 || bgColorSet.size === 2) {\n const candidateBg = bgColorSet.size === 1 ? Array.from(bgColorSet)[0] : Array.from(bgColorSet)[1];\n for (const header of headers) {\n const fg = header?.style?.color;\n if (fg && getColorContrast(fg, candidateBg) >= 3) {\n sharedBackgroundColor = candidateBg;\n useSharedBackground = true;\n break;\n }\n }\n }\n\n const titleHeight = chartTitle ? 30 : 0;\n const totalHeight = typeof height === 'number' ? height : 650;\n const tableHeight = `${totalHeight - titleHeight}px`;\n const svgWidth = typeof width === 'number' ? width : '100%';\n const titleMaxWidth = typeof width === 'number' ? width - 20 : undefined;\n const titleX = typeof width === 'number' ? width / 2 : 0;\n\n return (\n <div\n ref={el => {\n _rootElem.current = el;\n }}\n className={classes.root as string}\n style={{ height: `${totalHeight}px`, overflow: 'hidden' }}\n >\n <svg width={svgWidth} height={`${totalHeight}px`}>\n {chartTitle && (\n <ChartTitle\n title={chartTitle}\n x={titleX}\n maxWidth={titleMaxWidth}\n className={classes.chartTitle}\n titleStyles={props.titleStyles}\n tooltipClassName={classes.svgTooltip}\n />\n )}\n <foreignObject x=\"0\" y={titleHeight} width=\"100%\" height={tableHeight}>\n <div\n style={{\n maxHeight: height ? `${height}px` : '650px',\n overflowY: 'auto',\n overflowX: 'auto',\n }}\n >\n <table\n className={classes.table}\n style={{\n width: width ? `${width}px` : '100%',\n }}\n {...arrowAttributes}\n >\n <thead>\n <tr>\n {headers.map((header, idx) => {\n const style = { ...header?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n\n if (useSharedBackground) {\n style.backgroundColor = sharedBackgroundColor;\n } else if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(_rootElem.current!, fg, bg);\n }\n return (\n <th key={idx} className={classes.headerCell} style={style} tabIndex={0}>\n {header.value}\n </th>\n );\n })}\n </tr>\n </thead>\n {rows && rows.length > 0 && (\n <tbody>\n {rows.map((row, rowIdx) => (\n <tr key={rowIdx}>\n {row.map((cell, colIdx) => {\n const style = { ...cell?.style };\n const fg = style.color;\n const bg = style.backgroundColor;\n if (fg || bg) {\n style.backgroundColor = getSafeBackgroundColor(_rootElem.current!, fg, bg);\n }\n return (\n <td key={colIdx} className={classes.bodyCell} style={style} tabIndex={0}>\n {cell.value}\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n )}\n </table>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n },\n);\n\nChartTable.displayName = 'ChartTable';\n"],"names":["React","useChartTableStyles","tokens","d3","getColorContrast","resolveCSSVariables","ChartTitle","useImageExport","useArrowNavigationGroup","invertHexColor","hex","color","colorNeutralForeground1","rgb","r","g","b","formatHex","getSafeBackgroundColor","chartContainer","foreground","background","fallbackFg","fallbackBg","colorNeutralBackground1","resolvedFg","resolvedBg","fg","bg","contrast","invertedBg","invertedContrast","ChartTable","forwardRef","props","forwardedRef","headers","rows","width","height","chartTitle","chartContainerRef","_rootElem","componentRef","classes","arrowAttributes","axis","length","div","bgColorSet","Set","forEach","header","style","backgroundColor","normalized","add","sharedBackgroundColor","useSharedBackground","size","candidateBg","Array","from","titleHeight","totalHeight","tableHeight","svgWidth","titleMaxWidth","undefined","titleX","ref","el","current","className","root","overflow","svg","title","x","maxWidth","titleStyles","tooltipClassName","svgTooltip","foreignObject","y","maxHeight","overflowY","overflowX","table","thead","tr","map","idx","th","key","headerCell","tabIndex","value","tbody","row","rowIdx","cell","colIdx","td","bodyCell","displayName"],"mappings":"AAAA;;;;;;;;eAgDagC;;;;iEA9CU,QAAQ;2CAEK,+BAA+B;4BAC5C,wBAAwB;mEAC3B,WAAW;wBACE,yBAAyB;2BACtB,4BAA4B;uBACrC,wBAAwB;uBACpB,wBAAwB;8BACf,0BAA0B;AAElE,SAASvB,eAAeC,GAAW;IACjC,MAAMC,QAAQR,SAAGQ,KAAK,CAACD;IACvB,IAAI,CAACC,OAAO;QACV,OAAOT,kBAAAA,CAAOU,uBAAuB;IACvC;IACA,MAAMC,MAAMF,MAAME,GAAG;IACrB,OAAOV,SAAGU,GAAG,CAAC,MAAMA,IAAIC,CAAC,EAAE,MAAM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KAAK;QACtB,MAAMiB,KAAKyB,MAAMC,eAAe;QAEhC,IAAII,qBAAqB;YACvBL,MAAMC,eAAe,GAAGG;QAC1B,OAAO,IAAI9B,MAAMC,IAAI;YACnByB,MAAMC,eAAe,GAAGpC,uBAAuBwB,UAAU8B,OAAO,EAAG7C,IAAIC;QACzE;QACA,OAAA,WAAA,GACE,OAAA,aAAA,CAACiE,MAAAA;YAAGC,KAAKF;YAAKnB,WAAW7B,QAAQmD,UAAU;YAAE1C,OAAOA;YAAO2C,UAAU;WAClE5C,OAAO6C,KAAK;IAGnB,MAGH5D,QAAQA,KAAKU,MAAM,GAAG,KAAA,WAAA,GACrB,OAAA,aAAA,CAACmD,SAAAA,MACE7D,KAAKsD,GAAG,CAAC,CAACQ,KAAKC,SAAAA,WAAAA,GACd,OAAA,aAAA,CAACV,MAAAA;YAAGI,KAAKM;WACND,IAAIR,GAAG,CAAC,CAACU,MAAMC;YACd,MAAMjD,QAAQ;mBAAKgD,SAAAA,QAAAA,SAAAA,KAAAA,IAAAA,KAAAA,IAAAA,KAAMhD,KAAT;YAAe;YAC/B,MAAM1B,KAAK0B,MAAM1C,KAAK;YACtB,MAAMiB,KAAKyB,MAAMC,eAAe;YAChC,IAAI3B,MAAMC,IAAI;gBACZyB,MAAMC,eAAe,GAAGpC,uBAAuBwB,UAAU8B,OAAO,EAAG7C,IAAIC;YACzE;YACA,OAAA,WAAA,GACE,OAAA,aAAA,CAAC2E,MAAAA;gBAAGT,KAAKQ;gBAAQ7B,WAAW7B,QAAQ4D,QAAQ;gBAAEnD,OAAOA;gBAAO2C,UAAU;eACnEK,KAAKJ,KAAK;QAGjB;AAWtB,GACA;AAEFjE,WAAWyE,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ChartTable/ChartTable.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { Chart } from './index';\n\n/**\n * Chart Table properties\n * {@docCategory ChartTable}\n */\nexport interface ChartTableProps {\n /**\n * 1d or 2d Array of header values.\n */\n headers: { value: string | number | boolean | null; style?: React.CSSProperties }[];\n\n /**\n * Array of rows. Each row corresponds to one data entry under each column.\n */\n rows: { value: string | number | boolean | null; style?: React.CSSProperties }[][];\n\n /**\n * Optional width for the table\n * @default '100%'\n */\n width?: string | number;\n\n /**\n * Optional height for the table\n * @default '650px'\n */\n height?: string | number;\n\n /**\n * Additional class name(s) to apply to the table chart\n */\n className?: string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: ChartTableStyles;\n\n /**\n * Optional callback to access the Chart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.Ref<Chart>;\n}\n\n/**\n * Table Chart styles\n * {@docCategory ChartTable}\n */\nexport interface ChartTableStyles {\n root?: string | React.CSSProperties;\n table?: string;\n headerCell?: string;\n bodyCell?: string;\n chart?: string;\n}\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
|
|
1
|
+
{"version":3,"sources":["../src/components/ChartTable/ChartTable.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TitleStyles } from '../../utilities/Common.styles';\nimport { Chart } from './index';\n\n/**\n * Chart Table properties\n * {@docCategory ChartTable}\n */\nexport interface ChartTableProps {\n /**\n * Title styles configuration for the chart title\n */\n titleStyles?: TitleStyles;\n\n /**\n * 1d or 2d Array of header values.\n */\n headers: { value: string | number | boolean | null; style?: React.CSSProperties }[];\n\n /**\n * Array of rows. Each row corresponds to one data entry under each column.\n */\n rows: { value: string | number | boolean | null; style?: React.CSSProperties }[][];\n\n /**\n * Optional width for the table\n * @default '100%'\n */\n width?: string | number;\n\n /**\n * Optional height for the table\n * @default '650px'\n */\n height?: string | number;\n\n /**\n * Chart title to display above the table\n */\n chartTitle?: string;\n\n /**\n * Additional class name(s) to apply to the table chart\n */\n className?: string;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: ChartTableStyles;\n\n /**\n * Optional callback to access the Chart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.Ref<Chart>;\n}\n\n/**\n * Table Chart styles\n * {@docCategory ChartTable}\n */\nexport interface ChartTableStyles {\n root?: string | React.CSSProperties;\n table?: string;\n headerCell?: string;\n bodyCell?: string;\n chart?: string;\n chartTitle?: string;\n svgTooltip?: string;\n}\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
|
|
@@ -23,7 +23,9 @@ const chartTableClassNames = {
|
|
|
23
23
|
table: 'fui-ChartTable__table',
|
|
24
24
|
headerCell: 'fui-ChartTable__headerCell',
|
|
25
25
|
bodyCell: 'fui-ChartTable__bodyCell',
|
|
26
|
-
chart: 'fui-ChartTable__chart'
|
|
26
|
+
chart: 'fui-ChartTable__chart',
|
|
27
|
+
chartTitle: 'fui-ChartTable__chartTitle',
|
|
28
|
+
svgTooltip: 'fui-ChartTable__svgTooltip'
|
|
27
29
|
};
|
|
28
30
|
const useStyles = /*#__PURE__*/ (0, _react.__styles)({
|
|
29
31
|
root: {
|
|
@@ -102,6 +104,20 @@ const useStyles = /*#__PURE__*/ (0, _react.__styles)({
|
|
|
102
104
|
"fes3tcz"
|
|
103
105
|
],
|
|
104
106
|
B7iucu3: "fhs7xo9"
|
|
107
|
+
},
|
|
108
|
+
chartTitle: {
|
|
109
|
+
Bahqtrf: "fk6fouc",
|
|
110
|
+
Be2twd7: "f13mqy1h",
|
|
111
|
+
Bhrd7zp: "fl43uef",
|
|
112
|
+
Bg96gwp: "fcpl73t",
|
|
113
|
+
Bkfmm31: "fhuob2q",
|
|
114
|
+
Bvjb7m6: "fhv2zbx",
|
|
115
|
+
fsow6f: "f17mccla",
|
|
116
|
+
jrapky: "fqcjy3b"
|
|
117
|
+
},
|
|
118
|
+
svgTooltip: {
|
|
119
|
+
Bkfmm31: "f5q6cfr",
|
|
120
|
+
Bxms50k: "f1bgda6t"
|
|
105
121
|
}
|
|
106
122
|
}, {
|
|
107
123
|
d: [
|
|
@@ -140,7 +156,14 @@ const useStyles = /*#__PURE__*/ (0, _react.__styles)({
|
|
|
140
156
|
{
|
|
141
157
|
p: -2
|
|
142
158
|
}
|
|
143
|
-
]
|
|
159
|
+
],
|
|
160
|
+
".f13mqy1h{font-size:var(--fontSizeBase100);}",
|
|
161
|
+
".fcpl73t{line-height:var(--lineHeightBase100);}",
|
|
162
|
+
".fhuob2q{fill:var(--colorNeutralForeground1);}",
|
|
163
|
+
".fhv2zbx{forced-color-adjust:auto;}",
|
|
164
|
+
".f17mccla{text-align:center;}",
|
|
165
|
+
".fqcjy3b{margin-bottom:var(--spacingVerticalS);}",
|
|
166
|
+
".f5q6cfr{fill:var(--colorNeutralBackground1);}"
|
|
144
167
|
],
|
|
145
168
|
m: [
|
|
146
169
|
[
|
|
@@ -154,6 +177,12 @@ const useStyles = /*#__PURE__*/ (0, _react.__styles)({
|
|
|
154
177
|
{
|
|
155
178
|
m: "(forced-colors: active)"
|
|
156
179
|
}
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
"@media screen and (-ms-high-contrast: active),screen and (forced-colors: active){.f1bgda6t{fill:Canvas;}}",
|
|
183
|
+
{
|
|
184
|
+
m: "screen and (-ms-high-contrast: active), screen and (forced-colors: active)"
|
|
185
|
+
}
|
|
157
186
|
]
|
|
158
187
|
]
|
|
159
188
|
});
|
|
@@ -164,6 +193,8 @@ const useChartTableStyles = (props)=>{
|
|
|
164
193
|
table: (0, _react.mergeClasses)(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/ ),
|
|
165
194
|
headerCell: (0, _react.mergeClasses)(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/ ),
|
|
166
195
|
bodyCell: (0, _react.mergeClasses)(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/ ),
|
|
167
|
-
chart: (0, _react.mergeClasses)(chartTableClassNames.chart /*props.styles?.chart*/ )
|
|
196
|
+
chart: (0, _react.mergeClasses)(chartTableClassNames.chart /*props.styles?.chart*/ ),
|
|
197
|
+
chartTitle: (0, _react.mergeClasses)(chartTableClassNames.chartTitle, baseStyles.chartTitle /*props.styles?.chartTitle*/ ),
|
|
198
|
+
svgTooltip: (0, _react.mergeClasses)(chartTableClassNames.svgTooltip, baseStyles.svgTooltip /*props.styles?.svgTooltip*/ )
|
|
168
199
|
};
|
|
169
200
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useChartTableStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\n/**\n * @internal\n */ export const chartTableClassNames = {\n root: 'fui-ChartTable__root',\n table: 'fui-ChartTable__table',\n headerCell: 'fui-ChartTable__headerCell',\n bodyCell: 'fui-ChartTable__bodyCell',\n chart: 'fui-ChartTable__chart'\n};\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n overflowX: 'auto'\n },\n table: {\n borderCollapse: 'collapse'\n },\n headerCell: {\n ...typographyStyles.caption1,\n fontWeight: tokens.fontWeightSemibold,\n backgroundColor: tokens.colorNeutralBackground3,\n color: tokens.colorNeutralForeground1,\n padding: tokens.spacingHorizontalS,\n textAlign: 'left',\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n '@media (forced-colors: active)': {\n backgroundColor: 'Window',\n color: 'WindowText'\n }\n },\n bodyCell: {\n ...typographyStyles.caption1,\n padding: tokens.spacingHorizontalS,\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n color: tokens.colorNeutralForeground1,\n textAlign: 'left',\n '@media (forced-colors: active)': {\n color: 'WindowText'\n }\n }\n});\n/**\n * Apply styling to the ChartTable slots based on the state\n */ export const useChartTableStyles = (props)=>{\n const baseStyles = useStyles();\n return {\n root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/ ),\n table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/ ),\n headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/ ),\n bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/ ),\n chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/ )\n };\n};\n"],"names":["__styles","mergeClasses","tokens","typographyStyles","chartTableClassNames","root","table","headerCell","bodyCell","chart","useStyles","a9b677","B68tc82","po53p8","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","De3pzq","sj55zd","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","fsow6f","Bgfg5da","B9xav0g","oivjwe","Bn0qgzm","B4g9neb","zhjwy3","wvpqe5","ibv6hh","u1mtju","h3c5rm","vrafjx","Bekrc4i","i8vvqc","g2u3we","icvyot","B4j52fo","irswps","By8wz76","B7iucu3","d","p","m","useChartTableStyles","props","baseStyles"],"mappings":"AAAA,YAAY;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["useChartTableStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { getChartTitleStyles, HighContrastSelector } from '../../utilities/index';\n/**\n * @internal\n */ export const chartTableClassNames = {\n root: 'fui-ChartTable__root',\n table: 'fui-ChartTable__table',\n headerCell: 'fui-ChartTable__headerCell',\n bodyCell: 'fui-ChartTable__bodyCell',\n chart: 'fui-ChartTable__chart',\n chartTitle: 'fui-ChartTable__chartTitle',\n svgTooltip: 'fui-ChartTable__svgTooltip'\n};\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n overflowX: 'auto'\n },\n table: {\n borderCollapse: 'collapse'\n },\n headerCell: {\n ...typographyStyles.caption1,\n fontWeight: tokens.fontWeightSemibold,\n backgroundColor: tokens.colorNeutralBackground3,\n color: tokens.colorNeutralForeground1,\n padding: tokens.spacingHorizontalS,\n textAlign: 'left',\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n '@media (forced-colors: active)': {\n backgroundColor: 'Window',\n color: 'WindowText'\n }\n },\n bodyCell: {\n ...typographyStyles.caption1,\n padding: tokens.spacingHorizontalS,\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n color: tokens.colorNeutralForeground1,\n textAlign: 'left',\n '@media (forced-colors: active)': {\n color: 'WindowText'\n }\n },\n chartTitle: getChartTitleStyles(),\n svgTooltip: {\n fill: tokens.colorNeutralBackground1,\n [HighContrastSelector]: {\n fill: 'Canvas'\n }\n }\n});\n/**\n * Apply styling to the ChartTable slots based on the state\n */ export const useChartTableStyles = (props)=>{\n const baseStyles = useStyles();\n return {\n root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/ ),\n table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/ ),\n headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/ ),\n bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/ ),\n chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/ ),\n chartTitle: mergeClasses(chartTableClassNames.chartTitle, baseStyles.chartTitle /*props.styles?.chartTitle*/ ),\n svgTooltip: mergeClasses(chartTableClassNames.svgTooltip, baseStyles.svgTooltip /*props.styles?.svgTooltip*/ )\n };\n};\n"],"names":["__styles","mergeClasses","tokens","typographyStyles","getChartTitleStyles","HighContrastSelector","chartTableClassNames","root","table","headerCell","bodyCell","chart","chartTitle","svgTooltip","useStyles","a9b677","B68tc82","po53p8","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","De3pzq","sj55zd","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","fsow6f","Bgfg5da","B9xav0g","oivjwe","Bn0qgzm","B4g9neb","zhjwy3","wvpqe5","ibv6hh","u1mtju","h3c5rm","vrafjx","Bekrc4i","i8vvqc","g2u3we","icvyot","B4j52fo","irswps","By8wz76","B7iucu3","Bk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YAAA;YAAA;gBAAAA,CAAA,EAAA;YAAA;SAAA;QAAA;YAAA;YAAA;gBAAAA,CAAA,EAAA;YAAA;SAAA;KAAA;AAAA,CAsCjB,CAAC;AAGS,MAAMC,uBAAuBC,KAAK,IAAG;IAC5C,MAAMC,UAAU,GAAG5C,SAAS,CAAC,CAAC;IAC9B,OAAO;QACHP,IAAI,MAAEN,mBAAY,EAACK,oBAAoB,CAACC,IAAI,EAAEmD,UAAU,CAACnD,IAAI,CAAC,oBAAA,EAAuB,CAAC;QACtFC,KAAK,MAAEP,mBAAY,EAACK,oBAAoB,CAACE,KAAK,EAAEkD,UAAU,CAAClD,KAAK,CAAC,qBAAA,EAAwB,CAAC;QAC1FC,UAAU,EAAER,uBAAY,EAACK,oBAAoB,CAACG,UAAU,EAAEiD,UAAU,CAACjD,UAAU,CAAC,0BAAA,EAA6B,CAAC;QAC9GC,QAAQ,MAAET,mBAAY,EAACK,oBAAoB,CAACI,QAAQ,EAAEgD,UAAU,CAAChD,QAAQ,CAAC,wBAAA,EAA2B,CAAC;QACtGC,KAAK,MAAEV,mBAAY,EAACK,oBAAoB,CAACK,KAAK,CAAC,qBAAA,EAAwB,CAAC;QACxEC,UAAU,MAAEX,mBAAY,EAACK,oBAAoB,CAACM,UAAU,EAAE8C,UAAU,CAAC9C,UAAU,CAAC,0BAAA,EAA6B,CAAC;QAC9GC,UAAU,MAAEZ,mBAAY,EAACK,oBAAoB,CAACO,UAAU,EAAE6C,UAAU,CAAC7C,UAAU,CAAC,0BAAA,EAA6B;IACjH,CAAC;AACL,CAAC"}
|
|
@@ -19,12 +19,15 @@ _export(exports, {
|
|
|
19
19
|
});
|
|
20
20
|
const _react = require("@griffel/react");
|
|
21
21
|
const _reacttheme = require("@fluentui/react-theme");
|
|
22
|
+
const _index = require("../../utilities/index");
|
|
22
23
|
const chartTableClassNames = {
|
|
23
24
|
root: 'fui-ChartTable__root',
|
|
24
25
|
table: 'fui-ChartTable__table',
|
|
25
26
|
headerCell: 'fui-ChartTable__headerCell',
|
|
26
27
|
bodyCell: 'fui-ChartTable__bodyCell',
|
|
27
|
-
chart: 'fui-ChartTable__chart'
|
|
28
|
+
chart: 'fui-ChartTable__chart',
|
|
29
|
+
chartTitle: 'fui-ChartTable__chartTitle',
|
|
30
|
+
svgTooltip: 'fui-ChartTable__svgTooltip'
|
|
28
31
|
};
|
|
29
32
|
const useStyles = (0, _react.makeStyles)({
|
|
30
33
|
root: {
|
|
@@ -56,6 +59,13 @@ const useStyles = (0, _react.makeStyles)({
|
|
|
56
59
|
'@media (forced-colors: active)': {
|
|
57
60
|
color: 'WindowText'
|
|
58
61
|
}
|
|
62
|
+
},
|
|
63
|
+
chartTitle: (0, _index.getChartTitleStyles)(),
|
|
64
|
+
svgTooltip: {
|
|
65
|
+
fill: _reacttheme.tokens.colorNeutralBackground1,
|
|
66
|
+
[_index.HighContrastSelector]: {
|
|
67
|
+
fill: 'Canvas'
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
});
|
|
61
71
|
const useChartTableStyles = (props)=>{
|
|
@@ -65,6 +75,8 @@ const useChartTableStyles = (props)=>{
|
|
|
65
75
|
table: (0, _react.mergeClasses)(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/ ),
|
|
66
76
|
headerCell: (0, _react.mergeClasses)(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/ ),
|
|
67
77
|
bodyCell: (0, _react.mergeClasses)(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/ ),
|
|
68
|
-
chart: (0, _react.mergeClasses)(chartTableClassNames.chart /*props.styles?.chart*/ )
|
|
78
|
+
chart: (0, _react.mergeClasses)(chartTableClassNames.chart /*props.styles?.chart*/ ),
|
|
79
|
+
chartTitle: (0, _react.mergeClasses)(chartTableClassNames.chartTitle, baseStyles.chartTitle /*props.styles?.chartTitle*/ ),
|
|
80
|
+
svgTooltip: (0, _react.mergeClasses)(chartTableClassNames.svgTooltip, baseStyles.svgTooltip /*props.styles?.svgTooltip*/ )
|
|
69
81
|
};
|
|
70
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ChartTable/useChartTableStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { ChartTableProps, ChartTableStyles } from './ChartTable.types';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\n\n/**\n * @internal\n */\nexport const chartTableClassNames: SlotClassNames<ChartTableStyles> = {\n root: 'fui-ChartTable__root',\n table: 'fui-ChartTable__table',\n headerCell: 'fui-ChartTable__headerCell',\n bodyCell: 'fui-ChartTable__bodyCell',\n chart: 'fui-ChartTable__chart',\n};\n\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n overflowX: 'auto',\n },\n table: {\n borderCollapse: 'collapse',\n },\n headerCell: {\n ...typographyStyles.caption1,\n fontWeight: tokens.fontWeightSemibold,\n backgroundColor: tokens.colorNeutralBackground3,\n color: tokens.colorNeutralForeground1,\n padding: tokens.spacingHorizontalS,\n textAlign: 'left',\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n '@media (forced-colors: active)': {\n backgroundColor: 'Window',\n color: 'WindowText',\n },\n },\n bodyCell: {\n ...typographyStyles.caption1,\n padding: tokens.spacingHorizontalS,\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n color: tokens.colorNeutralForeground1,\n textAlign: 'left',\n '@media (forced-colors: active)': {\n color: 'WindowText',\n },\n },\n});\n\n/**\n * Apply styling to the ChartTable slots based on the state\n */\nexport const useChartTableStyles = (props: ChartTableProps): ChartTableStyles => {\n const baseStyles = useStyles();\n\n return {\n root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/),\n table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/),\n headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/),\n bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/),\n chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/),\n };\n};\n"],"names":["makeStyles","mergeClasses","tokens","typographyStyles","chartTableClassNames","root","table","headerCell","bodyCell","chart","useStyles","width","overflowX","borderCollapse","caption1","fontWeight","fontWeightSemibold","backgroundColor","colorNeutralBackground3","color","colorNeutralForeground1","padding","spacingHorizontalS","textAlign","border","strokeWidthThick","colorNeutralStroke2","useChartTableStyles","props","baseStyles"],"mappings":"AAAA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/components/ChartTable/useChartTableStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { GriffelStyle, makeStyles, mergeClasses } from '@griffel/react';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { ChartTableProps, ChartTableStyles } from './ChartTable.types';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { getChartTitleStyles, HighContrastSelector } from '../../utilities/index';\n\n/**\n * @internal\n */\nexport const chartTableClassNames: SlotClassNames<ChartTableStyles> = {\n root: 'fui-ChartTable__root',\n table: 'fui-ChartTable__table',\n headerCell: 'fui-ChartTable__headerCell',\n bodyCell: 'fui-ChartTable__bodyCell',\n chart: 'fui-ChartTable__chart',\n chartTitle: 'fui-ChartTable__chartTitle',\n svgTooltip: 'fui-ChartTable__svgTooltip',\n};\n\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n overflowX: 'auto',\n },\n table: {\n borderCollapse: 'collapse',\n },\n headerCell: {\n ...typographyStyles.caption1,\n fontWeight: tokens.fontWeightSemibold,\n backgroundColor: tokens.colorNeutralBackground3,\n color: tokens.colorNeutralForeground1,\n padding: tokens.spacingHorizontalS,\n textAlign: 'left',\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n '@media (forced-colors: active)': {\n backgroundColor: 'Window',\n color: 'WindowText',\n },\n },\n bodyCell: {\n ...typographyStyles.caption1,\n padding: tokens.spacingHorizontalS,\n border: `${tokens.strokeWidthThick} solid ${tokens.colorNeutralStroke2}`,\n color: tokens.colorNeutralForeground1,\n textAlign: 'left',\n '@media (forced-colors: active)': {\n color: 'WindowText',\n },\n },\n chartTitle: getChartTitleStyles() as GriffelStyle,\n svgTooltip: {\n fill: tokens.colorNeutralBackground1,\n [HighContrastSelector]: {\n fill: 'Canvas',\n },\n },\n});\n\n/**\n * Apply styling to the ChartTable slots based on the state\n */\nexport const useChartTableStyles = (props: ChartTableProps): ChartTableStyles => {\n const baseStyles = useStyles();\n\n return {\n root: mergeClasses(chartTableClassNames.root, baseStyles.root /*props.styles?.root*/),\n table: mergeClasses(chartTableClassNames.table, baseStyles.table /*props.styles?.table*/),\n headerCell: mergeClasses(chartTableClassNames.headerCell, baseStyles.headerCell /*props.styles?.headerCell*/),\n bodyCell: mergeClasses(chartTableClassNames.bodyCell, baseStyles.bodyCell /*props.styles?.bodyCell*/),\n chart: mergeClasses(chartTableClassNames.chart /*props.styles?.chart*/),\n chartTitle: mergeClasses(chartTableClassNames.chartTitle, baseStyles.chartTitle /*props.styles?.chartTitle*/),\n svgTooltip: mergeClasses(chartTableClassNames.svgTooltip, baseStyles.svgTooltip /*props.styles?.svgTooltip*/),\n };\n};\n"],"names":["makeStyles","mergeClasses","tokens","typographyStyles","getChartTitleStyles","HighContrastSelector","chartTableClassNames","root","table","headerCell","bodyCell","chart","chartTitle","svgTooltip","useStyles","width","overflowX","borderCollapse","caption1","fontWeight","fontWeightSemibold","backgroundColor","colorNeutralBackground3","color","colorNeutralForeground1","padding","spacingHorizontalS","textAlign","border","strokeWidthThick","colorNeutralStroke2","fill","colorNeutralBackground1","useChartTableStyles","props","baseStyles"],"mappings":"AAAA;;;;;;;;;;;;IAWaM,oBAAAA;;;IAqDA2B,mBAAAA;;;;uBA9D0C,iBAAiB;4BAG/B,wBAAwB;uBACP,wBAAwB;AAK3E,6BAA+D;IACpE1B,MAAM;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BAAAA,EAAaK,qBAAqBG,UAAU,EAAE0B,WAAW1B,UAAU,CAAC,0BAA0B;QAC1GC,cAAUT,mBAAAA,EAAaK,qBAAqBI,QAAQ,EAAEyB,WAAWzB,QAAQ,CAAC,wBAAwB;QAClGC,WAAOV,mBAAAA,EAAaK,qBAAqBK,KAAK,CAAC,qBAAqB;QACpEC,gBAAYX,mBAAAA,EAAaK,qBAAqBM,UAAU,EAAEuB,WAAWvB,UAAU,CAAC,0BAA0B;QAC1GC,gBAAYZ,mBAAAA,EAAaK,qBAAqBO,UAAU,EAAEsB,WAAWtB,UAAU,CAAC,0BAA0B;IAC5G;AACF,EAAE"}
|
|
@@ -25,10 +25,6 @@ const ARROW_SIZE_SCALE = 0.35;
|
|
|
25
25
|
const MAX_SIMPLE_MARKUP_DEPTH = 5;
|
|
26
26
|
const CHAR_CODE_LESS_THAN = '<'.codePointAt(0);
|
|
27
27
|
const CHAR_CODE_GREATER_THAN = '>'.codePointAt(0);
|
|
28
|
-
const getAnnotationKey = (annotation, index)=>{
|
|
29
|
-
var _annotation_id, _ref;
|
|
30
|
-
return (_ref = (_annotation_id = annotation.id) !== null && _annotation_id !== void 0 ? _annotation_id : typeof annotation.text === 'string' || typeof annotation.text === 'number' ? String(annotation.text) : undefined) !== null && _ref !== void 0 ? _ref : `annotation-${index}`;
|
|
31
|
-
};
|
|
32
28
|
const decodeSimpleMarkupInput = (input)=>{
|
|
33
29
|
const namedEntities = {
|
|
34
30
|
amp: '&',
|
|
@@ -227,6 +223,40 @@ const normalizeBandOffset = (scale, value)=>{
|
|
|
227
223
|
return position;
|
|
228
224
|
};
|
|
229
225
|
const clamp = (value, min, max)=>Math.max(min, Math.min(max, value));
|
|
226
|
+
const resolveDataCoordinate = (axis, value, context, yAxis = 'primary')=>{
|
|
227
|
+
if (axis === 'x') {
|
|
228
|
+
const xScale = context.xScale;
|
|
229
|
+
if (!xScale) {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
const parsedValue = value instanceof Date ? value.getTime() : value;
|
|
233
|
+
return normalizeBandOffset(xScale, parsedValue);
|
|
234
|
+
}
|
|
235
|
+
const yScale = yAxis === 'secondary' ? context.yScaleSecondary : context.yScalePrimary;
|
|
236
|
+
if (!yScale) {
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
const parsedValue = value instanceof Date ? value.getTime() : value;
|
|
240
|
+
return normalizeBandOffset(yScale, parsedValue);
|
|
241
|
+
};
|
|
242
|
+
const resolveAxisCoordinate = (axis, coordinateType, value, context, options = {})=>{
|
|
243
|
+
switch(coordinateType){
|
|
244
|
+
case 'data':
|
|
245
|
+
return resolveDataCoordinate(axis, value, context, options.yAxis);
|
|
246
|
+
case 'relative':
|
|
247
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
return axis === 'x' ? context.plotRect.x + context.plotRect.width * value : context.plotRect.y + context.plotRect.height * value;
|
|
251
|
+
case 'pixel':
|
|
252
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
return axis === 'x' ? context.plotRect.x + value : context.plotRect.y + value;
|
|
256
|
+
default:
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
230
260
|
const createMeasurementSignature = (annotationContentSignature, containerStyle, contentStyle, layoutClassName, styleClassName)=>JSON.stringify({
|
|
231
261
|
annotationContentSignature,
|
|
232
262
|
containerStyle,
|
|
@@ -234,58 +264,58 @@ const createMeasurementSignature = (annotationContentSignature, containerStyle,
|
|
|
234
264
|
layoutClassName: layoutClassName !== null && layoutClassName !== void 0 ? layoutClassName : '',
|
|
235
265
|
styleClassName: styleClassName !== null && styleClassName !== void 0 ? styleClassName : ''
|
|
236
266
|
});
|
|
267
|
+
const getCoordinateDescriptor = (coordinates)=>{
|
|
268
|
+
switch(coordinates.type){
|
|
269
|
+
case 'data':
|
|
270
|
+
return {
|
|
271
|
+
xType: 'data',
|
|
272
|
+
yType: 'data',
|
|
273
|
+
yAxis: coordinates.yAxis
|
|
274
|
+
};
|
|
275
|
+
case 'relative':
|
|
276
|
+
return {
|
|
277
|
+
xType: 'relative',
|
|
278
|
+
yType: 'relative'
|
|
279
|
+
};
|
|
280
|
+
case 'pixel':
|
|
281
|
+
return {
|
|
282
|
+
xType: 'pixel',
|
|
283
|
+
yType: 'pixel'
|
|
284
|
+
};
|
|
285
|
+
case 'mixed':
|
|
286
|
+
return {
|
|
287
|
+
xType: coordinates.xCoordinateType,
|
|
288
|
+
yType: coordinates.yCoordinateType,
|
|
289
|
+
yAxis: coordinates.yAxis
|
|
290
|
+
};
|
|
291
|
+
default:
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
237
295
|
const resolveCoordinates = (annotation, context)=>{
|
|
238
296
|
const { coordinates, layout } = annotation;
|
|
239
297
|
if (!coordinates) {
|
|
240
298
|
return undefined;
|
|
241
299
|
}
|
|
300
|
+
const descriptor = getCoordinateDescriptor(coordinates);
|
|
301
|
+
if (!descriptor) {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
242
304
|
var _layout_offsetX;
|
|
243
305
|
const offsetX = (_layout_offsetX = layout === null || layout === void 0 ? void 0 : layout.offsetX) !== null && _layout_offsetX !== void 0 ? _layout_offsetX : 0;
|
|
244
306
|
var _layout_offsetY;
|
|
245
307
|
const offsetY = (_layout_offsetY = layout === null || layout === void 0 ? void 0 : layout.offsetY) !== null && _layout_offsetY !== void 0 ? _layout_offsetY : 0;
|
|
308
|
+
const anchorX = resolveAxisCoordinate('x', descriptor.xType, coordinates.x, context);
|
|
309
|
+
const anchorY = resolveAxisCoordinate('y', descriptor.yType, coordinates.y, context, {
|
|
310
|
+
yAxis: descriptor.yAxis
|
|
311
|
+
});
|
|
312
|
+
if (anchorX === undefined || anchorY === undefined) {
|
|
313
|
+
return undefined;
|
|
314
|
+
}
|
|
246
315
|
const anchor = {
|
|
247
|
-
x:
|
|
248
|
-
y:
|
|
316
|
+
x: anchorX,
|
|
317
|
+
y: anchorY
|
|
249
318
|
};
|
|
250
|
-
switch(coordinates.type){
|
|
251
|
-
case 'data':
|
|
252
|
-
{
|
|
253
|
-
const { x, y, yAxis = 'primary' } = coordinates;
|
|
254
|
-
const xScale = context.xScale;
|
|
255
|
-
const yScale = yAxis === 'secondary' ? context.yScaleSecondary : context.yScalePrimary;
|
|
256
|
-
if (!xScale || !yScale) {
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
const xValue = normalizeBandOffset(xScale, x instanceof Date ? x.getTime() : x);
|
|
260
|
-
const yValue = normalizeBandOffset(yScale, y instanceof Date ? y.getTime() : y);
|
|
261
|
-
if (typeof xValue !== 'number' || typeof yValue !== 'number') {
|
|
262
|
-
return undefined;
|
|
263
|
-
}
|
|
264
|
-
anchor.x = xValue;
|
|
265
|
-
anchor.y = yValue;
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
case 'relative':
|
|
269
|
-
{
|
|
270
|
-
if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
|
|
271
|
-
return undefined;
|
|
272
|
-
}
|
|
273
|
-
anchor.x = context.plotRect.x + context.plotRect.width * coordinates.x;
|
|
274
|
-
anchor.y = context.plotRect.y + context.plotRect.height * coordinates.y;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
case 'pixel':
|
|
278
|
-
{
|
|
279
|
-
if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
|
|
280
|
-
return undefined;
|
|
281
|
-
}
|
|
282
|
-
anchor.x = context.plotRect.x + coordinates.x;
|
|
283
|
-
anchor.y = context.plotRect.y + coordinates.y;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
default:
|
|
287
|
-
return undefined;
|
|
288
|
-
}
|
|
289
319
|
let left = anchor.x + offsetX;
|
|
290
320
|
let top = anchor.y + offsetY;
|
|
291
321
|
if (layout === null || layout === void 0 ? void 0 : layout.clipToBounds) {
|
|
@@ -301,15 +331,23 @@ const resolveCoordinates = (annotation, context)=>{
|
|
|
301
331
|
};
|
|
302
332
|
};
|
|
303
333
|
const ChartAnnotationLayer = /*#__PURE__*/ _react.memo((props)=>{
|
|
304
|
-
const { annotations: annotationsProp, context } = props;
|
|
334
|
+
const { annotations: annotationsProp, context, hideDefaultStyles } = props;
|
|
305
335
|
const classes = (0, _useChartAnnotationLayerstyles.useChartAnnotationLayerStyles)(props);
|
|
306
336
|
const idPrefix = (0, _reactutilities.useId)('chart-annotation');
|
|
337
|
+
const autoKeyPrefix = (0, _reactutilities.useId)('chart-annotation-item');
|
|
307
338
|
const [measurements, setMeasurements] = _react.useState({});
|
|
308
|
-
const resolvedAnnotations = _react.useMemo(()=>
|
|
339
|
+
const resolvedAnnotations = _react.useMemo(()=>{
|
|
340
|
+
let fallbackIndex = 0;
|
|
341
|
+
return (annotationsProp !== null && annotationsProp !== void 0 ? annotationsProp : []).map((annotation)=>{
|
|
342
|
+
var _annotation_id;
|
|
343
|
+
return {
|
|
309
344
|
annotation,
|
|
310
|
-
key:
|
|
311
|
-
}
|
|
312
|
-
|
|
345
|
+
key: (_annotation_id = annotation.id) !== null && _annotation_id !== void 0 ? _annotation_id : `${autoKeyPrefix}-${fallbackIndex++}`
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
}, [
|
|
349
|
+
annotationsProp,
|
|
350
|
+
autoKeyPrefix
|
|
313
351
|
]);
|
|
314
352
|
_react.useEffect(()=>{
|
|
315
353
|
setMeasurements((prev)=>{
|
|
@@ -365,7 +403,7 @@ const ChartAnnotationLayer = /*#__PURE__*/ _react.memo((props)=>{
|
|
|
365
403
|
const measurementElements = [];
|
|
366
404
|
const connectors = [];
|
|
367
405
|
resolvedAnnotations.forEach(({ annotation, key })=>{
|
|
368
|
-
var _annotation_style, _annotation_style1, _annotation_style2, _annotation_style3, _annotation_style4, _annotation_style5, _annotation_style6, _annotation_style7, _annotation_style8, _annotation_style9, _annotation_style10, _annotation_style11, _annotation_style12, _annotation_style13, _annotation_style14, _annotation_style15, _annotation_style16, _annotation_style17, _annotation_accessibility, _annotation_accessibility1, _annotation_accessibility2;
|
|
406
|
+
var _annotation_style, _annotation_style1, _annotation_style2, _annotation_style3, _annotation_style4, _annotation_style5, _annotation_style6, _annotation_style7, _annotation_style8, _annotation_style9, _annotation_style10, _annotation_style11, _annotation_style12, _annotation_style13, _annotation_style14, _annotation_style15, _annotation_style16, _annotation_style17, _annotation_style18, _annotation_accessibility, _annotation_accessibility1, _annotation_accessibility2;
|
|
369
407
|
const resolved = resolveCoordinates(annotation, context);
|
|
370
408
|
if (!resolved) {
|
|
371
409
|
return;
|
|
@@ -387,28 +425,30 @@ const ChartAnnotationLayer = /*#__PURE__*/ _react.memo((props)=>{
|
|
|
387
425
|
const containerStyle = {
|
|
388
426
|
maxWidth: layout === null || layout === void 0 ? void 0 : layout.maxWidth,
|
|
389
427
|
...hasCustomBackground ? {
|
|
390
|
-
backgroundColor: (0, _useChartAnnotationLayerstyles.applyOpacityToColor)(baseBackgroundColor, backgroundOpacity
|
|
391
|
-
|
|
428
|
+
backgroundColor: (0, _useChartAnnotationLayerstyles.applyOpacityToColor)(baseBackgroundColor, backgroundOpacity, {
|
|
429
|
+
preserveOriginalOpacity: ((_annotation_style4 = annotation.style) === null || _annotation_style4 === void 0 ? void 0 : _annotation_style4.opacity) === undefined
|
|
430
|
+
})
|
|
431
|
+
} : hideDefaultStyles ? {} : {
|
|
392
432
|
backgroundColor: (0, _useChartAnnotationLayerstyles.applyOpacityToColor)(_reacttheme.tokens.colorNeutralBackground1, _useChartAnnotationLayerstyles.DEFAULT_ANNOTATION_BACKGROUND_OPACITY)
|
|
393
433
|
},
|
|
394
|
-
borderColor: (
|
|
395
|
-
borderWidth: (
|
|
396
|
-
borderStyle: (_annotation_style_borderStyle = (
|
|
397
|
-
borderRadius: (
|
|
398
|
-
padding: (
|
|
399
|
-
boxShadow: (
|
|
434
|
+
borderColor: (_annotation_style5 = annotation.style) === null || _annotation_style5 === void 0 ? void 0 : _annotation_style5.borderColor,
|
|
435
|
+
borderWidth: (_annotation_style6 = annotation.style) === null || _annotation_style6 === void 0 ? void 0 : _annotation_style6.borderWidth,
|
|
436
|
+
borderStyle: (_annotation_style_borderStyle = (_annotation_style7 = annotation.style) === null || _annotation_style7 === void 0 ? void 0 : _annotation_style7.borderStyle) !== null && _annotation_style_borderStyle !== void 0 ? _annotation_style_borderStyle : ((_annotation_style8 = annotation.style) === null || _annotation_style8 === void 0 ? void 0 : _annotation_style8.borderColor) ? 'solid' : undefined,
|
|
437
|
+
borderRadius: (_annotation_style9 = annotation.style) === null || _annotation_style9 === void 0 ? void 0 : _annotation_style9.borderRadius,
|
|
438
|
+
padding: (_annotation_style10 = annotation.style) === null || _annotation_style10 === void 0 ? void 0 : _annotation_style10.padding,
|
|
439
|
+
boxShadow: (_annotation_style11 = annotation.style) === null || _annotation_style11 === void 0 ? void 0 : _annotation_style11.boxShadow
|
|
400
440
|
};
|
|
401
441
|
const contentStyle = {
|
|
402
|
-
color: (
|
|
403
|
-
fontSize: (
|
|
404
|
-
fontWeight: (
|
|
442
|
+
color: (_annotation_style12 = annotation.style) === null || _annotation_style12 === void 0 ? void 0 : _annotation_style12.textColor,
|
|
443
|
+
fontSize: (_annotation_style13 = annotation.style) === null || _annotation_style13 === void 0 ? void 0 : _annotation_style13.fontSize,
|
|
444
|
+
fontWeight: (_annotation_style14 = annotation.style) === null || _annotation_style14 === void 0 ? void 0 : _annotation_style14.fontWeight,
|
|
405
445
|
opacity: 1
|
|
406
446
|
};
|
|
407
|
-
if (typeof ((
|
|
447
|
+
if (typeof ((_annotation_style15 = annotation.style) === null || _annotation_style15 === void 0 ? void 0 : _annotation_style15.rotation) === 'number' && !Number.isNaN(annotation.style.rotation)) {
|
|
408
448
|
containerStyle.transform = `rotate(${annotation.style.rotation}deg)`;
|
|
409
449
|
containerStyle.transformOrigin = '50% 50%';
|
|
410
450
|
}
|
|
411
|
-
const measurementSignature = createMeasurementSignature(annotationMarkupSignature, containerStyle, contentStyle, layout === null || layout === void 0 ? void 0 : layout.className, (
|
|
451
|
+
const measurementSignature = createMeasurementSignature(annotationMarkupSignature, containerStyle, contentStyle, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style16 = annotation.style) === null || _annotation_style16 === void 0 ? void 0 : _annotation_style16.className);
|
|
412
452
|
const measurementEntry = measurements[key];
|
|
413
453
|
const isMeasurementValid = (measurementEntry === null || measurementEntry === void 0 ? void 0 : measurementEntry.signature) === measurementSignature;
|
|
414
454
|
const measuredSize = isMeasurementValid ? measurementEntry : undefined;
|
|
@@ -474,8 +514,9 @@ const ChartAnnotationLayer = /*#__PURE__*/ _react.memo((props)=>{
|
|
|
474
514
|
visibility: 'hidden',
|
|
475
515
|
...containerStyle
|
|
476
516
|
};
|
|
517
|
+
const annotationClass = hideDefaultStyles ? classes.annotationNoDefaults : classes.annotation;
|
|
477
518
|
if (!isMeasurementValid) {
|
|
478
|
-
var
|
|
519
|
+
var _annotation_style19, _annotation_style20;
|
|
479
520
|
measurementElements.push(/*#__PURE__*/ _react.createElement("div", {
|
|
480
521
|
key: `${key}-measurement`,
|
|
481
522
|
ref: (node)=>{
|
|
@@ -486,13 +527,13 @@ const ChartAnnotationLayer = /*#__PURE__*/ _react.memo((props)=>{
|
|
|
486
527
|
}
|
|
487
528
|
}
|
|
488
529
|
},
|
|
489
|
-
className: (0, _react1.mergeClasses)(
|
|
530
|
+
className: (0, _react1.mergeClasses)(annotationClass, classes.measurement, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style19 = annotation.style) === null || _annotation_style19 === void 0 ? void 0 : _annotation_style19.className),
|
|
490
531
|
style: measurementStyle,
|
|
491
532
|
"aria-hidden": true,
|
|
492
533
|
"data-annotation-key": key,
|
|
493
534
|
"data-chart-annotation-measurement": "true"
|
|
494
535
|
}, /*#__PURE__*/ _react.createElement("div", {
|
|
495
|
-
className: (0, _react1.mergeClasses)(classes.annotationContent, layout === null || layout === void 0 ? void 0 : layout.className, (
|
|
536
|
+
className: (0, _react1.mergeClasses)(classes.annotationContent, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style20 = annotation.style) === null || _annotation_style20 === void 0 ? void 0 : _annotation_style20.className),
|
|
496
537
|
style: contentStyle
|
|
497
538
|
}, renderSimpleMarkup(annotationMarkupNodes, `${key}-measurement`))));
|
|
498
539
|
}
|
|
@@ -506,15 +547,16 @@ const ChartAnnotationLayer = /*#__PURE__*/ _react.memo((props)=>{
|
|
|
506
547
|
className: (0, _react1.mergeClasses)(classes.annotationForeignObject),
|
|
507
548
|
"data-annotation-key": key
|
|
508
549
|
}, /*#__PURE__*/ _react.createElement("div", {
|
|
509
|
-
className: (0, _react1.mergeClasses)(
|
|
550
|
+
className: (0, _react1.mergeClasses)(annotationClass, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style17 = annotation.style) === null || _annotation_style17 === void 0 ? void 0 : _annotation_style17.className),
|
|
510
551
|
style: containerStyle,
|
|
511
552
|
"data-annotation-key": key
|
|
512
553
|
}, /*#__PURE__*/ _react.createElement("div", {
|
|
513
|
-
className: (0, _react1.mergeClasses)(classes.annotationContent, (
|
|
554
|
+
className: (0, _react1.mergeClasses)(classes.annotationContent, classes.annotationContentInteractive, (_annotation_style18 = annotation.style) === null || _annotation_style18 === void 0 ? void 0 : _annotation_style18.className),
|
|
514
555
|
style: contentStyle,
|
|
515
556
|
role: (_annotation_accessibility_role = (_annotation_accessibility = annotation.accessibility) === null || _annotation_accessibility === void 0 ? void 0 : _annotation_accessibility.role) !== null && _annotation_accessibility_role !== void 0 ? _annotation_accessibility_role : 'note',
|
|
516
557
|
"aria-label": (_annotation_accessibility_ariaLabel = (_annotation_accessibility1 = annotation.accessibility) === null || _annotation_accessibility1 === void 0 ? void 0 : _annotation_accessibility1.ariaLabel) !== null && _annotation_accessibility_ariaLabel !== void 0 ? _annotation_accessibility_ariaLabel : annotationPlainText ? annotationPlainText : undefined,
|
|
517
558
|
"aria-describedby": (_annotation_accessibility2 = annotation.accessibility) === null || _annotation_accessibility2 === void 0 ? void 0 : _annotation_accessibility2.ariaDescribedBy,
|
|
559
|
+
tabIndex: 0,
|
|
518
560
|
"data-chart-annotation": "true",
|
|
519
561
|
"data-annotation-key": key
|
|
520
562
|
}, renderSimpleMarkup(annotationMarkupNodes, `${key}-content`)))));
|