@chipmobilesdk/rn-chart 0.4.0 → 0.5.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/CHANGELOG.md +111 -0
- package/README.md +1 -1
- package/lib/commonjs/a11y/summary.js +190 -0
- package/lib/commonjs/a11y/summary.js.map +1 -0
- package/lib/commonjs/contract/datasource.js +64 -0
- package/lib/commonjs/contract/datasource.js.map +1 -0
- package/lib/commonjs/contract/distribution.js +45 -0
- package/lib/commonjs/contract/distribution.js.map +1 -0
- package/lib/commonjs/contract/errors.js +88 -0
- package/lib/commonjs/contract/errors.js.map +1 -0
- package/lib/commonjs/contract/format.js +133 -0
- package/lib/commonjs/contract/format.js.map +1 -0
- package/lib/commonjs/contract/interaction.js +24 -0
- package/lib/commonjs/contract/interaction.js.map +1 -0
- package/lib/commonjs/contract/marker.js +55 -0
- package/lib/commonjs/contract/marker.js.map +1 -0
- package/lib/commonjs/contract/props.js +6 -0
- package/lib/commonjs/contract/props.js.map +1 -0
- package/lib/commonjs/contract/state.js +68 -0
- package/lib/commonjs/contract/state.js.map +1 -0
- package/lib/commonjs/contract/strings.js +54 -0
- package/lib/commonjs/contract/strings.js.map +1 -0
- package/lib/commonjs/contract/theme.js +116 -0
- package/lib/commonjs/contract/theme.js.map +1 -0
- package/lib/commonjs/contract/value.js +112 -0
- package/lib/commonjs/contract/value.js.map +1 -0
- package/lib/commonjs/geometry/bar.js +257 -0
- package/lib/commonjs/geometry/bar.js.map +1 -0
- package/lib/commonjs/geometry/distribution.js +197 -0
- package/lib/commonjs/geometry/distribution.js.map +1 -0
- package/lib/commonjs/geometry/heatmap.js +186 -0
- package/lib/commonjs/geometry/heatmap.js.map +1 -0
- package/lib/commonjs/geometry/hitTest.js +117 -0
- package/lib/commonjs/geometry/hitTest.js.map +1 -0
- package/lib/commonjs/geometry/layout.js +134 -0
- package/lib/commonjs/geometry/layout.js.map +1 -0
- package/lib/commonjs/geometry/markers.js +59 -0
- package/lib/commonjs/geometry/markers.js.map +1 -0
- package/lib/commonjs/geometry/path.js +166 -0
- package/lib/commonjs/geometry/path.js.map +1 -0
- package/lib/commonjs/geometry/progress.js +203 -0
- package/lib/commonjs/geometry/progress.js.map +1 -0
- package/lib/commonjs/geometry/scale.js +127 -0
- package/lib/commonjs/geometry/scale.js.map +1 -0
- package/lib/commonjs/geometry/ticks.js +120 -0
- package/lib/commonjs/geometry/ticks.js.map +1 -0
- package/lib/commonjs/geometry/timeSeries.js +157 -0
- package/lib/commonjs/geometry/timeSeries.js.map +1 -0
- package/lib/commonjs/geometry/types.js +43 -0
- package/lib/commonjs/geometry/types.js.map +1 -0
- package/lib/commonjs/index.js +284 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/react/ChartBoundary.js +82 -0
- package/lib/commonjs/react/ChartBoundary.js.map +1 -0
- package/lib/commonjs/react/ChartFrame.js +270 -0
- package/lib/commonjs/react/ChartFrame.js.map +1 -0
- package/lib/commonjs/react/ChartLegend.js +242 -0
- package/lib/commonjs/react/ChartLegend.js.map +1 -0
- package/lib/commonjs/react/ChartPlot.js +62 -0
- package/lib/commonjs/react/ChartPlot.js.map +1 -0
- package/lib/commonjs/react/ChartStateOverlay.js +89 -0
- package/lib/commonjs/react/ChartStateOverlay.js.map +1 -0
- package/lib/commonjs/react/ChartThemeProvider.js +51 -0
- package/lib/commonjs/react/ChartThemeProvider.js.map +1 -0
- package/lib/commonjs/react/charts.js +108 -0
- package/lib/commonjs/react/charts.js.map +1 -0
- package/lib/commonjs/react/pointEvent.js +35 -0
- package/lib/commonjs/react/pointEvent.js.map +1 -0
- package/lib/commonjs/react/useChartA11y.js +97 -0
- package/lib/commonjs/react/useChartA11y.js.map +1 -0
- package/lib/commonjs/react/useChartFormatters.js +66 -0
- package/lib/commonjs/react/useChartFormatters.js.map +1 -0
- package/lib/commonjs/react/useChartLayout.js +100 -0
- package/lib/commonjs/react/useChartLayout.js.map +1 -0
- package/lib/commonjs/react/useChartSelection.js +131 -0
- package/lib/commonjs/react/useChartSelection.js.map +1 -0
- package/lib/commonjs/react/useChartStatus.js +74 -0
- package/lib/commonjs/react/useChartStatus.js.map +1 -0
- package/lib/commonjs/render/Axis.js +88 -0
- package/lib/commonjs/render/Axis.js.map +1 -0
- package/lib/commonjs/render/Marks.js +184 -0
- package/lib/commonjs/render/Marks.js.map +1 -0
- package/lib/commonjs/validation/budgets.js +106 -0
- package/lib/commonjs/validation/budgets.js.map +1 -0
- package/lib/commonjs/validation/validateDatasource.js +189 -0
- package/lib/commonjs/validation/validateDatasource.js.map +1 -0
- package/lib/module/a11y/summary.js +184 -0
- package/lib/module/a11y/summary.js.map +1 -0
- package/lib/module/contract/datasource.js +57 -0
- package/lib/module/contract/datasource.js.map +1 -0
- package/lib/module/contract/distribution.js +40 -0
- package/lib/module/contract/distribution.js.map +1 -0
- package/lib/module/contract/errors.js +80 -0
- package/lib/module/contract/errors.js.map +1 -0
- package/lib/module/contract/format.js +123 -0
- package/lib/module/contract/format.js.map +1 -0
- package/lib/module/contract/interaction.js +20 -0
- package/lib/module/contract/interaction.js.map +1 -0
- package/lib/module/contract/marker.js +49 -0
- package/lib/module/contract/marker.js.map +1 -0
- package/lib/module/contract/props.js +4 -0
- package/lib/module/contract/props.js.map +1 -0
- package/lib/module/contract/state.js +61 -0
- package/lib/module/contract/state.js.map +1 -0
- package/lib/module/contract/strings.js +49 -0
- package/lib/module/contract/strings.js.map +1 -0
- package/lib/module/contract/theme.js +109 -0
- package/lib/module/contract/theme.js.map +1 -0
- package/lib/module/contract/value.js +101 -0
- package/lib/module/contract/value.js.map +1 -0
- package/lib/module/geometry/bar.js +253 -0
- package/lib/module/geometry/bar.js.map +1 -0
- package/lib/module/geometry/distribution.js +193 -0
- package/lib/module/geometry/distribution.js.map +1 -0
- package/lib/module/geometry/heatmap.js +182 -0
- package/lib/module/geometry/heatmap.js.map +1 -0
- package/lib/module/geometry/hitTest.js +110 -0
- package/lib/module/geometry/hitTest.js.map +1 -0
- package/lib/module/geometry/layout.js +122 -0
- package/lib/module/geometry/layout.js.map +1 -0
- package/lib/module/geometry/markers.js +53 -0
- package/lib/module/geometry/markers.js.map +1 -0
- package/lib/module/geometry/path.js +157 -0
- package/lib/module/geometry/path.js.map +1 -0
- package/lib/module/geometry/progress.js +199 -0
- package/lib/module/geometry/progress.js.map +1 -0
- package/lib/module/geometry/scale.js +119 -0
- package/lib/module/geometry/scale.js.map +1 -0
- package/lib/module/geometry/ticks.js +112 -0
- package/lib/module/geometry/ticks.js.map +1 -0
- package/lib/module/geometry/timeSeries.js +153 -0
- package/lib/module/geometry/timeSeries.js.map +1 -0
- package/lib/module/geometry/types.js +39 -0
- package/lib/module/geometry/types.js.map +1 -0
- package/lib/module/index.js +85 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/react/ChartBoundary.js +75 -0
- package/lib/module/react/ChartBoundary.js.map +1 -0
- package/lib/module/react/ChartFrame.js +263 -0
- package/lib/module/react/ChartFrame.js.map +1 -0
- package/lib/module/react/ChartLegend.js +234 -0
- package/lib/module/react/ChartLegend.js.map +1 -0
- package/lib/module/react/ChartPlot.js +56 -0
- package/lib/module/react/ChartPlot.js.map +1 -0
- package/lib/module/react/ChartStateOverlay.js +82 -0
- package/lib/module/react/ChartStateOverlay.js.map +1 -0
- package/lib/module/react/ChartThemeProvider.js +44 -0
- package/lib/module/react/ChartThemeProvider.js.map +1 -0
- package/lib/module/react/charts.js +102 -0
- package/lib/module/react/charts.js.map +1 -0
- package/lib/module/react/pointEvent.js +30 -0
- package/lib/module/react/pointEvent.js.map +1 -0
- package/lib/module/react/useChartA11y.js +92 -0
- package/lib/module/react/useChartA11y.js.map +1 -0
- package/lib/module/react/useChartFormatters.js +61 -0
- package/lib/module/react/useChartFormatters.js.map +1 -0
- package/lib/module/react/useChartLayout.js +95 -0
- package/lib/module/react/useChartLayout.js.map +1 -0
- package/lib/module/react/useChartSelection.js +125 -0
- package/lib/module/react/useChartSelection.js.map +1 -0
- package/lib/module/react/useChartStatus.js +69 -0
- package/lib/module/react/useChartStatus.js.map +1 -0
- package/lib/module/render/Axis.js +80 -0
- package/lib/module/render/Axis.js.map +1 -0
- package/lib/module/render/Marks.js +173 -0
- package/lib/module/render/Marks.js.map +1 -0
- package/lib/module/validation/budgets.js +97 -0
- package/lib/module/validation/budgets.js.map +1 -0
- package/lib/module/validation/validateDatasource.js +184 -0
- package/lib/module/validation/validateDatasource.js.map +1 -0
- package/lib/typescript/commonjs/a11y/summary.d.ts +38 -0
- package/lib/typescript/commonjs/a11y/summary.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/datasource.d.ts +94 -0
- package/lib/typescript/commonjs/contract/datasource.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/distribution.d.ts +17 -0
- package/lib/typescript/commonjs/contract/distribution.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/errors.d.ts +53 -0
- package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/format.d.ts +63 -0
- package/lib/typescript/commonjs/contract/format.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/marker.d.ts +39 -0
- package/lib/typescript/commonjs/contract/marker.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/props.d.ts +58 -0
- package/lib/typescript/commonjs/contract/props.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/state.d.ts +45 -0
- package/lib/typescript/commonjs/contract/state.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/strings.d.ts +39 -0
- package/lib/typescript/commonjs/contract/strings.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/theme.d.ts +85 -0
- package/lib/typescript/commonjs/contract/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/value.d.ts +69 -0
- package/lib/typescript/commonjs/contract/value.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/bar.d.ts +18 -0
- package/lib/typescript/commonjs/geometry/bar.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/distribution.d.ts +23 -0
- package/lib/typescript/commonjs/geometry/distribution.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/heatmap.d.ts +24 -0
- package/lib/typescript/commonjs/geometry/heatmap.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/hitTest.d.ts +68 -0
- package/lib/typescript/commonjs/geometry/hitTest.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/layout.d.ts +67 -0
- package/lib/typescript/commonjs/geometry/layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/markers.d.ts +29 -0
- package/lib/typescript/commonjs/geometry/markers.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/path.d.ts +66 -0
- package/lib/typescript/commonjs/geometry/path.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/progress.d.ts +17 -0
- package/lib/typescript/commonjs/geometry/progress.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/scale.d.ts +55 -0
- package/lib/typescript/commonjs/geometry/scale.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/ticks.d.ts +48 -0
- package/lib/typescript/commonjs/geometry/ticks.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/timeSeries.d.ts +20 -0
- package/lib/typescript/commonjs/geometry/timeSeries.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/types.d.ts +91 -0
- package/lib/typescript/commonjs/geometry/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +47 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/react/ChartBoundary.d.ts +47 -0
- package/lib/typescript/commonjs/react/ChartBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartFrame.d.ts +31 -0
- package/lib/typescript/commonjs/react/ChartFrame.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartLegend.d.ts +31 -0
- package/lib/typescript/commonjs/react/ChartLegend.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartPlot.d.ts +19 -0
- package/lib/typescript/commonjs/react/ChartPlot.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartStateOverlay.d.ts +25 -0
- package/lib/typescript/commonjs/react/ChartStateOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/ChartThemeProvider.d.ts +21 -0
- package/lib/typescript/commonjs/react/ChartThemeProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/charts.d.ts +51 -0
- package/lib/typescript/commonjs/react/charts.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/pointEvent.d.ts +13 -0
- package/lib/typescript/commonjs/react/pointEvent.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartA11y.d.ts +37 -0
- package/lib/typescript/commonjs/react/useChartA11y.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartFormatters.d.ts +21 -0
- package/lib/typescript/commonjs/react/useChartFormatters.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartLayout.d.ts +27 -0
- package/lib/typescript/commonjs/react/useChartLayout.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartSelection.d.ts +52 -0
- package/lib/typescript/commonjs/react/useChartSelection.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/useChartStatus.d.ts +22 -0
- package/lib/typescript/commonjs/react/useChartStatus.d.ts.map +1 -0
- package/lib/typescript/commonjs/render/Axis.d.ts +31 -0
- package/lib/typescript/commonjs/render/Axis.d.ts.map +1 -0
- package/lib/typescript/commonjs/render/Marks.d.ts +44 -0
- package/lib/typescript/commonjs/render/Marks.d.ts.map +1 -0
- package/lib/typescript/commonjs/validation/budgets.d.ts +24 -0
- package/lib/typescript/commonjs/validation/budgets.d.ts.map +1 -0
- package/lib/typescript/commonjs/validation/validateDatasource.d.ts +26 -0
- package/lib/typescript/commonjs/validation/validateDatasource.d.ts.map +1 -0
- package/lib/typescript/module/a11y/summary.d.ts +38 -0
- package/lib/typescript/module/a11y/summary.d.ts.map +1 -0
- package/lib/typescript/module/contract/datasource.d.ts +94 -0
- package/lib/typescript/module/contract/datasource.d.ts.map +1 -0
- package/lib/typescript/module/contract/distribution.d.ts +17 -0
- package/lib/typescript/module/contract/distribution.d.ts.map +1 -0
- package/lib/typescript/module/contract/errors.d.ts +53 -0
- package/lib/typescript/module/contract/errors.d.ts.map +1 -0
- package/lib/typescript/module/contract/format.d.ts +63 -0
- package/lib/typescript/module/contract/format.d.ts.map +1 -0
- package/lib/typescript/module/contract/interaction.d.ts +53 -0
- package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/module/contract/marker.d.ts +39 -0
- package/lib/typescript/module/contract/marker.d.ts.map +1 -0
- package/lib/typescript/module/contract/props.d.ts +58 -0
- package/lib/typescript/module/contract/props.d.ts.map +1 -0
- package/lib/typescript/module/contract/state.d.ts +45 -0
- package/lib/typescript/module/contract/state.d.ts.map +1 -0
- package/lib/typescript/module/contract/strings.d.ts +39 -0
- package/lib/typescript/module/contract/strings.d.ts.map +1 -0
- package/lib/typescript/module/contract/theme.d.ts +85 -0
- package/lib/typescript/module/contract/theme.d.ts.map +1 -0
- package/lib/typescript/module/contract/value.d.ts +69 -0
- package/lib/typescript/module/contract/value.d.ts.map +1 -0
- package/lib/typescript/module/geometry/bar.d.ts +18 -0
- package/lib/typescript/module/geometry/bar.d.ts.map +1 -0
- package/lib/typescript/module/geometry/distribution.d.ts +23 -0
- package/lib/typescript/module/geometry/distribution.d.ts.map +1 -0
- package/lib/typescript/module/geometry/heatmap.d.ts +24 -0
- package/lib/typescript/module/geometry/heatmap.d.ts.map +1 -0
- package/lib/typescript/module/geometry/hitTest.d.ts +68 -0
- package/lib/typescript/module/geometry/hitTest.d.ts.map +1 -0
- package/lib/typescript/module/geometry/layout.d.ts +67 -0
- package/lib/typescript/module/geometry/layout.d.ts.map +1 -0
- package/lib/typescript/module/geometry/markers.d.ts +29 -0
- package/lib/typescript/module/geometry/markers.d.ts.map +1 -0
- package/lib/typescript/module/geometry/path.d.ts +66 -0
- package/lib/typescript/module/geometry/path.d.ts.map +1 -0
- package/lib/typescript/module/geometry/progress.d.ts +17 -0
- package/lib/typescript/module/geometry/progress.d.ts.map +1 -0
- package/lib/typescript/module/geometry/scale.d.ts +55 -0
- package/lib/typescript/module/geometry/scale.d.ts.map +1 -0
- package/lib/typescript/module/geometry/ticks.d.ts +48 -0
- package/lib/typescript/module/geometry/ticks.d.ts.map +1 -0
- package/lib/typescript/module/geometry/timeSeries.d.ts +20 -0
- package/lib/typescript/module/geometry/timeSeries.d.ts.map +1 -0
- package/lib/typescript/module/geometry/types.d.ts +91 -0
- package/lib/typescript/module/geometry/types.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +47 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/react/ChartBoundary.d.ts +47 -0
- package/lib/typescript/module/react/ChartBoundary.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartFrame.d.ts +31 -0
- package/lib/typescript/module/react/ChartFrame.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartLegend.d.ts +31 -0
- package/lib/typescript/module/react/ChartLegend.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartPlot.d.ts +19 -0
- package/lib/typescript/module/react/ChartPlot.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartStateOverlay.d.ts +25 -0
- package/lib/typescript/module/react/ChartStateOverlay.d.ts.map +1 -0
- package/lib/typescript/module/react/ChartThemeProvider.d.ts +21 -0
- package/lib/typescript/module/react/ChartThemeProvider.d.ts.map +1 -0
- package/lib/typescript/module/react/charts.d.ts +51 -0
- package/lib/typescript/module/react/charts.d.ts.map +1 -0
- package/lib/typescript/module/react/pointEvent.d.ts +13 -0
- package/lib/typescript/module/react/pointEvent.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartA11y.d.ts +37 -0
- package/lib/typescript/module/react/useChartA11y.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartFormatters.d.ts +21 -0
- package/lib/typescript/module/react/useChartFormatters.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartLayout.d.ts +27 -0
- package/lib/typescript/module/react/useChartLayout.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartSelection.d.ts +52 -0
- package/lib/typescript/module/react/useChartSelection.d.ts.map +1 -0
- package/lib/typescript/module/react/useChartStatus.d.ts +22 -0
- package/lib/typescript/module/react/useChartStatus.d.ts.map +1 -0
- package/lib/typescript/module/render/Axis.d.ts +31 -0
- package/lib/typescript/module/render/Axis.d.ts.map +1 -0
- package/lib/typescript/module/render/Marks.d.ts +44 -0
- package/lib/typescript/module/render/Marks.d.ts.map +1 -0
- package/lib/typescript/module/validation/budgets.d.ts +24 -0
- package/lib/typescript/module/validation/budgets.d.ts.map +1 -0
- package/lib/typescript/module/validation/validateDatasource.d.ts +26 -0
- package/lib/typescript/module/validation/validateDatasource.d.ts.map +1 -0
- package/package.json +40 -15
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findPoint = findPoint;
|
|
7
|
+
exports.pointEventFor = pointEventFor;
|
|
8
|
+
/**
|
|
9
|
+
* The event a selected point is reported with. One place builds it, for a tap
|
|
10
|
+
* and for a screen-reader step alike.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function findPoint(datasource, seriesId, pointId) {
|
|
14
|
+
const series = datasource.series.find(s => s.id === seriesId);
|
|
15
|
+
const point = series?.points.find(p => p.id === pointId);
|
|
16
|
+
return series && point ? {
|
|
17
|
+
series,
|
|
18
|
+
point
|
|
19
|
+
} : undefined;
|
|
20
|
+
}
|
|
21
|
+
function pointEventFor(datasource, seriesId, pointId) {
|
|
22
|
+
const found = findPoint(datasource, seriesId, pointId);
|
|
23
|
+
if (!found) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
type: 'pointSelect',
|
|
28
|
+
seriesId: found.series.id,
|
|
29
|
+
pointId: found.point.id,
|
|
30
|
+
value: found.point.value,
|
|
31
|
+
position: found.point.position,
|
|
32
|
+
metadata: found.point.metadata
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pointEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["findPoint","datasource","seriesId","pointId","series","find","s","id","point","points","p","undefined","pointEventFor","found","type","value","position","metadata"],"sourceRoot":"../../../src","sources":["react/pointEvent.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;;AASO,SAASA,SAASA,CACxBC,UAA8B,EAC9BC,QAAgB,EAChBC,OAA2B,EACI;EAC/B,MAAMC,MAAM,GAAGH,UAAU,CAACG,MAAM,CAACC,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,EAAE,KAAKL,QAAQ,CAAC;EAC7D,MAAMM,KAAK,GAAGJ,MAAM,EAAEK,MAAM,CAACJ,IAAI,CAACK,CAAC,IAAIA,CAAC,CAACH,EAAE,KAAKJ,OAAO,CAAC;EACxD,OAAOC,MAAM,IAAII,KAAK,GAAG;IAAEJ,MAAM;IAAEI;EAAM,CAAC,GAAGG,SAAS;AACvD;AAEO,SAASC,aAAaA,CAC5BX,UAA8B,EAC9BC,QAAgB,EAChBC,OAAe,EACwB;EACvC,MAAMU,KAAK,GAAGb,SAAS,CAACC,UAAU,EAAEC,QAAQ,EAAEC,OAAO,CAAC;EACtD,IAAI,CAACU,KAAK,EAAE;IACX,OAAOF,SAAS;EACjB;EACA,OAAO;IACNG,IAAI,EAAE,aAAa;IACnBZ,QAAQ,EAAEW,KAAK,CAACT,MAAM,CAACG,EAAE;IACzBJ,OAAO,EAAEU,KAAK,CAACL,KAAK,CAACD,EAAE;IACvBQ,KAAK,EAAEF,KAAK,CAACL,KAAK,CAACO,KAAK;IACxBC,QAAQ,EAAEH,KAAK,CAACL,KAAK,CAACQ,QAAQ;IAC9BC,QAAQ,EAAEJ,KAAK,CAACL,KAAK,CAACS;EACvB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChartA11y = useChartA11y;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _summary = require("../a11y/summary.js");
|
|
9
|
+
var _pointEvent = require("./pointEvent.js");
|
|
10
|
+
/**
|
|
11
|
+
* What a screen reader gets: the composed summary, the announcement for the
|
|
12
|
+
* selected point, and increment/decrement to walk the points (FR-052, FR-067,
|
|
13
|
+
* FR-072).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function useChartA11y(args) {
|
|
17
|
+
const {
|
|
18
|
+
datasource,
|
|
19
|
+
family,
|
|
20
|
+
status,
|
|
21
|
+
title,
|
|
22
|
+
incomplete,
|
|
23
|
+
formatters,
|
|
24
|
+
strings,
|
|
25
|
+
selection
|
|
26
|
+
} = args;
|
|
27
|
+
const label = args.accessibility?.label;
|
|
28
|
+
const summaryFormatter = args.accessibility?.summaryFormatter;
|
|
29
|
+
const summary = (0, _react.useMemo)(() => {
|
|
30
|
+
if (label) {
|
|
31
|
+
return label;
|
|
32
|
+
}
|
|
33
|
+
// The app's own composer, when given.
|
|
34
|
+
if (summaryFormatter) {
|
|
35
|
+
return summaryFormatter(datasource, {
|
|
36
|
+
slot: 'summary',
|
|
37
|
+
hint: datasource.format
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return (0, _summary.buildChartSummary)({
|
|
41
|
+
datasource,
|
|
42
|
+
family,
|
|
43
|
+
status,
|
|
44
|
+
title,
|
|
45
|
+
formatValue: formatters.formatSummaryValue,
|
|
46
|
+
formatPosition: formatters.formatPosition,
|
|
47
|
+
incomplete,
|
|
48
|
+
strings
|
|
49
|
+
});
|
|
50
|
+
}, [label, summaryFormatter, datasource, family, status, title, formatters, incomplete, strings]);
|
|
51
|
+
if (!args.interactive) {
|
|
52
|
+
return {
|
|
53
|
+
summary,
|
|
54
|
+
value: undefined,
|
|
55
|
+
actions: undefined,
|
|
56
|
+
onAction: undefined
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const selected = selection.resolved ? (0, _pointEvent.findPoint)(datasource, selection.resolved.seriesId, selection.resolved.pointId) : undefined;
|
|
60
|
+
return {
|
|
61
|
+
summary,
|
|
62
|
+
value: selected ? {
|
|
63
|
+
text: (0, _summary.buildPointAnnouncement)(selected.series.label,
|
|
64
|
+
// The app's own wording for a position: a raw epoch number is
|
|
65
|
+
// not something to read aloud (CHT-07).
|
|
66
|
+
formatters.formatPosition(selected.point.position), selected.point.value, formatters.formatSummaryValue, strings)
|
|
67
|
+
} : undefined,
|
|
68
|
+
actions: [{
|
|
69
|
+
name: 'increment',
|
|
70
|
+
label: strings['chart.action.next']
|
|
71
|
+
}, {
|
|
72
|
+
name: 'decrement',
|
|
73
|
+
label: strings['chart.action.previous']
|
|
74
|
+
}],
|
|
75
|
+
onAction: event => {
|
|
76
|
+
const regions = args.hitRegions.filter(r => r.selectable);
|
|
77
|
+
if (regions.length === 0) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const step = event.nativeEvent.actionName === 'increment' ? 1 : -1;
|
|
81
|
+
const current = regions.findIndex(r => r.seriesId === selection.selection?.seriesId && r.pointId === selection.selection?.pointId);
|
|
82
|
+
const next = regions[current < 0 ? 0 : (current + step + regions.length) % regions.length];
|
|
83
|
+
const pointEvent = (0, _pointEvent.pointEventFor)(datasource, next.seriesId, next.pointId);
|
|
84
|
+
if (!pointEvent) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// Stepping moves the selection; it never clears it.
|
|
88
|
+
selection.select({
|
|
89
|
+
seriesId: next.seriesId,
|
|
90
|
+
pointId: next.pointId
|
|
91
|
+
}, pointEvent, {
|
|
92
|
+
toggle: false
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=useChartA11y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_summary","_pointEvent","useChartA11y","args","datasource","family","status","title","incomplete","formatters","strings","selection","label","accessibility","summaryFormatter","summary","useMemo","slot","hint","format","buildChartSummary","formatValue","formatSummaryValue","formatPosition","interactive","value","undefined","actions","onAction","selected","resolved","findPoint","seriesId","pointId","text","buildPointAnnouncement","series","point","position","name","event","regions","hitRegions","filter","r","selectable","length","step","nativeEvent","actionName","current","findIndex","next","pointEvent","pointEventFor","select","toggle"],"sourceRoot":"../../../src","sources":["react/useChartA11y.ts"],"mappings":";;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,WAAA,GAAAF,OAAA;AAbA;AACA;AACA;AACA;AACA;;AAkCO,SAASG,YAAYA,CAAIC,IAAyB,EAAa;EACrE,MAAM;IAAEC,UAAU;IAAEC,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC,UAAU;IAAEC,OAAO;IAAEC;EAAU,CAAC,GAAGR,IAAI;EAC9F,MAAMS,KAAK,GAAGT,IAAI,CAACU,aAAa,EAAED,KAAK;EACvC,MAAME,gBAAgB,GAAGX,IAAI,CAACU,aAAa,EAAEC,gBAAgB;EAE7D,MAAMC,OAAO,GAAG,IAAAC,cAAO,EAAC,MAAM;IAC7B,IAAIJ,KAAK,EAAE;MACV,OAAOA,KAAK;IACb;IACA;IACA,IAAIE,gBAAgB,EAAE;MACrB,OAAOA,gBAAgB,CAACV,UAAU,EAAE;QAAEa,IAAI,EAAE,SAAS;QAAEC,IAAI,EAAEd,UAAU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AAC,CAC9D;IACDkB,QAAQ,EAAEY,KAAK,IAAI;MAClB,MAAMC,OAAO,GAAGtC,IAAI,CAACuC,UAAU,CAACC,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACC,UAAU,CAAC;MACzD,IAAIJ,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;QACzB;MACD;MACA,MAAMC,IAAI,GAAGP,KAAK,CAACQ,WAAW,CAACC,UAAU,KAAK,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC;MAClE,MAAMC,OAAO,GAAGT,OAAO,CAACU,SAAS,CAChCP,CAAC,IACAA,CAAC,CAACZ,QAAQ,KAAKrB,SAAS,CAACA,SAAS,EAAEqB,QAAQ,IAC5CY,CAAC,CAACX,OAAO,KAAKtB,SAAS,CAACA,SAAS,EAAEsB,OACrC,CAAC;MACD,MAAMmB,IAAI,GAAGX,OAAO,CAACS,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAACA,OAAO,GAAGH,IAAI,GAAGN,OAAO,CAACK,MAAM,IAAIL,OAAO,CAACK,MAAM,CAAC;MAC1F,MAAMO,UAAU,GAAG,IAAAC,yBAAa,EAAClD,UAAU,EAAEgD,IAAI,CAACpB,QAAQ,EAAEoB,IAAI,CAACnB,OAAO,CAAC;MACzE,IAAI,CAACoB,UAAU,EAAE;QAChB;MACD;MACA;MACA1C,SAAS,CAAC4C,MAAM,CAAC;QAAEvB,QAAQ,EAAEoB,IAAI,CAACpB,QAAQ;QAAEC,OAAO,EAAEmB,IAAI,CAACnB;MAAQ,CAAC,EAAEoB,UAAU,EAAE;QAChFG,MAAM,EAAE;MACT,CAAC,CAAC;IACH;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChartFormatters = useChartFormatters;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _format = require("../contract/format.js");
|
|
9
|
+
/**
|
|
10
|
+
* The app's formatters, resolved once into the functions the chart calls.
|
|
11
|
+
*
|
|
12
|
+
* The memo depends on each formatter **function**, not on the `formatters`
|
|
13
|
+
* object that carries them. `formatters={{ value: formatMoney }}` written
|
|
14
|
+
* inline is a new object every render; depending on it rebuilt every scale and
|
|
15
|
+
* path each time the parent rendered (CHT-08, PERF-11). A formatter function
|
|
16
|
+
* that is itself created inline still counts as a change — it may format
|
|
17
|
+
* differently — so keep those stable (module scope, or `useCallback`).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function useChartFormatters(formatters, hint, instanceKey) {
|
|
21
|
+
const value = formatters?.value;
|
|
22
|
+
const axisLabel = formatters?.axisLabel;
|
|
23
|
+
const legend = formatters?.legendLabel;
|
|
24
|
+
const summary = formatters?.summary;
|
|
25
|
+
return (0, _react.useMemo)(() => {
|
|
26
|
+
const formatValue = v => value ? (0, _format.safeFormat)(() => value(v, {
|
|
27
|
+
slot: 'value',
|
|
28
|
+
hint
|
|
29
|
+
}), () => (0, _format.formatValueDefault)(v, {
|
|
30
|
+
slot: 'value',
|
|
31
|
+
hint
|
|
32
|
+
}), 'value', instanceKey) : (0, _format.formatValueDefault)(v, {
|
|
33
|
+
slot: 'value',
|
|
34
|
+
hint
|
|
35
|
+
});
|
|
36
|
+
const formatSummaryValue = v => summary ? (0, _format.safeFormat)(() => summary(v, {
|
|
37
|
+
slot: 'summary',
|
|
38
|
+
hint
|
|
39
|
+
}), () => formatValue(v), 'summary', instanceKey) : formatValue(v);
|
|
40
|
+
const formatPosition = position => axisLabel ? (0, _format.safeFormat)(() => axisLabel(position, {
|
|
41
|
+
slot: 'axis'
|
|
42
|
+
}), () => (0, _format.formatPositionDefault)(position), 'axis', instanceKey) : (0, _format.formatPositionDefault)(position);
|
|
43
|
+
return {
|
|
44
|
+
formatValue,
|
|
45
|
+
formatSummaryValue,
|
|
46
|
+
formatPosition,
|
|
47
|
+
...(legend ? {
|
|
48
|
+
legendLabel: series => (0, _format.safeFormat)(() => legend(series, {
|
|
49
|
+
slot: 'legend'
|
|
50
|
+
}), () => series.label, 'legend', instanceKey)
|
|
51
|
+
} : {}),
|
|
52
|
+
geometry: {
|
|
53
|
+
formatValue: n => formatValue({
|
|
54
|
+
kind: 'known',
|
|
55
|
+
value: n
|
|
56
|
+
}),
|
|
57
|
+
formatCategory: raw => raw,
|
|
58
|
+
formatInstant: at => formatPosition({
|
|
59
|
+
kind: 'instant',
|
|
60
|
+
at
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}, [value, axisLabel, legend, summary, hint, instanceKey]);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=useChartFormatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_format","useChartFormatters","formatters","hint","instanceKey","value","axisLabel","legend","legendLabel","summary","useMemo","formatValue","v","safeFormat","slot","formatValueDefault","formatSummaryValue","formatPosition","position","formatPositionDefault","series","label","geometry","n","kind","formatCategory","raw","formatInstant","at"],"sourceRoot":"../../../src","sources":["react/useChartFormatters.ts"],"mappings":";;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgCO,SAASE,kBAAkBA,CACjCC,UAAuC,EACvCC,IAA4B,EAC5BC,WAAmB,EACE;EACrB,MAAMC,KAAK,GAAGH,UAAU,EAAEG,KAAK;EAC/B,MAAMC,SAAS,GAAGJ,UAAU,EAAEI,SAAS;EACvC,MAAMC,MAAM,GAAGL,UAAU,EAAEM,WAAW;EACtC,MAAMC,OAAO,GAAGP,UAAU,EAAEO,OAAO;EAEnC,OAAO,IAAAC,cAAO,EAAC,MAAM;IACpB,MAAMC,WAAW,GAAIC,CAAa,IACjCP,KAAK,GACF,IAAAQ,kBAAU,EACV,MAAMR,KAAK,CAAC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GC,GAAW,IAAKA,GAAG;QACpCC,aAAa,EAAGC,EAAU,IAAKX,cAAc,CAAC;UAAEO,IAAI,EAAE,SAAS;UAAEI;QAAG,CAAC;MACtE;IACD,CAAC;EACF,CAAC,EAAE,CAACvB,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEE,OAAO,EAAEN,IAAI,EAAEC,WAAW,CAAC,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChartLayout = useChartLayout;
|
|
7
|
+
exports.useGeometryInput = useGeometryInput;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _theme = require("../contract/theme.js");
|
|
11
|
+
var _layout = require("../geometry/layout.js");
|
|
12
|
+
/**
|
|
13
|
+
* Container measurement and the geometry memo.
|
|
14
|
+
*
|
|
15
|
+
* `ResolvedGeometry` is memoized on datasource identity, plot rectangle, theme
|
|
16
|
+
* identity, and formatter identity — and deliberately **not** on selection, so
|
|
17
|
+
* highlighting a point repaints the highlight without recomputing scales or
|
|
18
|
+
* path strings (FR-073, SC-017).
|
|
19
|
+
*
|
|
20
|
+
* A consequence worth documenting for consumers: rebuilding the datasource
|
|
21
|
+
* object inline on every render defeats this. The README says so, and the demo
|
|
22
|
+
* app models the correct pattern.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function useChartLayout(theme, options = {}) {
|
|
26
|
+
const [size, setSize] = (0, _react.useState)({
|
|
27
|
+
width: 0,
|
|
28
|
+
height: 0
|
|
29
|
+
});
|
|
30
|
+
const onLayout = (0, _react.useCallback)(event => {
|
|
31
|
+
const {
|
|
32
|
+
width,
|
|
33
|
+
height
|
|
34
|
+
} = event.nativeEvent.layout;
|
|
35
|
+
setSize(prev =>
|
|
36
|
+
// Avoid a state churn loop on sub-pixel layout jitter.
|
|
37
|
+
Math.abs(prev.width - width) < 0.5 && Math.abs(prev.height - height) < 0.5 ? prev : {
|
|
38
|
+
width,
|
|
39
|
+
height
|
|
40
|
+
});
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
// Reactive: a change of the system text size re-renders the chart. A value
|
|
44
|
+
// read once from PixelRatio kept the old size until something else rendered.
|
|
45
|
+
const {
|
|
46
|
+
fontScale
|
|
47
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
48
|
+
const fontSize = (0, _layout.effectiveFontSize)(theme.typography.axisLabel.fontSize, fontScale);
|
|
49
|
+
const measured = (0, _layout.isMeasurable)(size);
|
|
50
|
+
const plot = (0, _react.useMemo)(() => {
|
|
51
|
+
if (!measured) {
|
|
52
|
+
// Wait for a real measurement rather than computing a broken layout
|
|
53
|
+
// or throwing (FR-078).
|
|
54
|
+
return _layout.EMPTY_PLOT;
|
|
55
|
+
}
|
|
56
|
+
return (0, _layout.resolvePlotRect)({
|
|
57
|
+
container: size,
|
|
58
|
+
xLabels: options.xLabels,
|
|
59
|
+
yLabels: options.yLabels,
|
|
60
|
+
baseFontSize: theme.typography.axisLabel.fontSize,
|
|
61
|
+
fontScale,
|
|
62
|
+
padding: theme.spacing.xs
|
|
63
|
+
});
|
|
64
|
+
}, [measured, size, options.xLabels, options.yLabels, theme.typography.axisLabel.fontSize, theme.spacing.xs, fontScale]);
|
|
65
|
+
return {
|
|
66
|
+
onLayout,
|
|
67
|
+
size,
|
|
68
|
+
measured,
|
|
69
|
+
plot,
|
|
70
|
+
fontSize
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Builds the geometry input, resolving per-series colours once so geometry
|
|
76
|
+
* modules never reach into the theme themselves.
|
|
77
|
+
*/
|
|
78
|
+
function useGeometryInput(datasource, theme, layout, formatters, family) {
|
|
79
|
+
return (0, _react.useMemo)(() => {
|
|
80
|
+
const seriesColors = {};
|
|
81
|
+
datasource.series.forEach((series, index) => {
|
|
82
|
+
seriesColors[series.id] = (0, _theme.resolveSeriesColor)(theme, index, series.color);
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
plot: layout.plot,
|
|
86
|
+
fontSize: layout.fontSize,
|
|
87
|
+
seriesColors,
|
|
88
|
+
// Per point only where segments exist; resolving one per point for
|
|
89
|
+
// every family cost a colour per data point at the time-series budget.
|
|
90
|
+
segmentColors: family === 'distribution' ? (0, _theme.resolveSegmentColors)(datasource, theme) : undefined,
|
|
91
|
+
nonValueTextures: theme.nonValue,
|
|
92
|
+
heatmapRamp: theme.heatmapRamp,
|
|
93
|
+
radius: theme.radius,
|
|
94
|
+
formatValue: formatters.formatValue,
|
|
95
|
+
formatCategory: formatters.formatCategory,
|
|
96
|
+
formatInstant: formatters.formatInstant
|
|
97
|
+
};
|
|
98
|
+
}, [datasource, theme, layout.plot, layout.fontSize, formatters, family]);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=useChartLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_theme","_layout","useChartLayout","theme","options","size","setSize","useState","width","height","onLayout","useCallback","event","nativeEvent","layout","prev","Math","abs","fontScale","useWindowDimensions","fontSize","effectiveFontSize","typography","axisLabel","measured","isMeasurable","plot","useMemo","EMPTY_PLOT","resolvePlotRect","container","xLabels","yLabels","baseFontSize","padding","spacing","xs","useGeometryInput","datasource","formatters","family","seriesColors","series","forEach","index","id","resolveSeriesColor","color","segmentColors","resolveSegmentColors","undefined","nonValueTextures","nonValue","heatmapRamp","radius","formatValue","formatCategory","formatInstant"],"sourceRoot":"../../../src","sources":["react/useChartLayout.ts"],"mappings":";;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AAC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,cAAc;MACzCC,aAAa,EAAElB,UAAU,CAACkB;IAC3B,CAAC;EACF,CAAC,EAAE,CAACnB,UAAU,EAAEnC,KAAK,EAAEW,MAAM,CAACY,IAAI,EAAEZ,MAAM,CAACM,QAAQ,EAAEmB,UAAU,EAAEC,MAAM,CAAC,CAAC;AAC1E","ignoreList":[]}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChartSelection = useChartSelection;
|
|
7
|
+
exports.useSeriesVisibility = useSeriesVisibility;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _interaction = require("../contract/interaction.js");
|
|
10
|
+
var _hitTest = require("../geometry/hitTest.js");
|
|
11
|
+
/**
|
|
12
|
+
* Selection ownership: uncontrolled by default, controlled when the app
|
|
13
|
+
* supplies a value (FR-054a).
|
|
14
|
+
*
|
|
15
|
+
* Three properties matter and all are load-bearing:
|
|
16
|
+
*
|
|
17
|
+
* - The selection is **resolved against the current datasource on every
|
|
18
|
+
* render** rather than stored resolved. A reference to a point that no
|
|
19
|
+
* longer exists therefore draws nothing, in either mode (FR-054).
|
|
20
|
+
* - Selection state lives outside the geometry memo, so highlighting repaints
|
|
21
|
+
* the highlight without recomputing scales or path strings (FR-073).
|
|
22
|
+
* - `select` and `toggle` keep one identity for the life of the chart. They
|
|
23
|
+
* read the app's callbacks through a ref, so an inline callback does not
|
|
24
|
+
* make every render look like a change (CHT-08).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function useChartSelection(args) {
|
|
28
|
+
const isControlled = args.controlled !== undefined;
|
|
29
|
+
const [internal, setInternal] = (0, _react.useState)(null);
|
|
30
|
+
const selection = isControlled ? args.controlled ?? null : internal;
|
|
31
|
+
|
|
32
|
+
// Resolve fresh every render. A stale reference resolves to `undefined` and
|
|
33
|
+
// simply is not drawn.
|
|
34
|
+
const resolved = selection && !args.interactionSuppressed ? (0, _hitTest.findRegion)(args.hitRegions, selection.seriesId, selection.pointId) : undefined;
|
|
35
|
+
const latest = (0, _react.useRef)({
|
|
36
|
+
args,
|
|
37
|
+
selection,
|
|
38
|
+
isControlled
|
|
39
|
+
});
|
|
40
|
+
latest.current = {
|
|
41
|
+
args,
|
|
42
|
+
selection,
|
|
43
|
+
isControlled
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Tell a controlling app when its selection stopped resolving, rather than
|
|
47
|
+
// silently ignoring it. Uncontrolled selections are cleared instead. Keyed
|
|
48
|
+
// on what the selection is, not on object identity, so an app passing
|
|
49
|
+
// `selection={{…}}` inline does not re-run this every render.
|
|
50
|
+
const selectionKey = selection ? `${selection.seriesId}:${selection.pointId ?? ''}` : null;
|
|
51
|
+
const unresolved = selectionKey !== null && !resolved && !args.interactionSuppressed && args.geometryReady;
|
|
52
|
+
const reportedRef = (0, _react.useRef)(null);
|
|
53
|
+
(0, _react.useEffect)(() => {
|
|
54
|
+
if (!unresolved) {
|
|
55
|
+
reportedRef.current = null;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (reportedRef.current === selectionKey) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
reportedRef.current = selectionKey;
|
|
62
|
+
const current = latest.current;
|
|
63
|
+
if (current.isControlled) {
|
|
64
|
+
if (current.selection) {
|
|
65
|
+
current.args.onSelectionUnresolvable?.(current.selection);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
setInternal(null);
|
|
69
|
+
}
|
|
70
|
+
}, [unresolved, selectionKey]);
|
|
71
|
+
const select = (0, _react.useCallback)((ref, event, options) => {
|
|
72
|
+
const current = latest.current;
|
|
73
|
+
if (current.args.interactionSuppressed) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Decided once, then used for the state and for the report: the app
|
|
77
|
+
// used to be told a point was selected at the very moment the chart
|
|
78
|
+
// dropped its highlight (CHT-06).
|
|
79
|
+
const next = options?.toggle !== false && (0, _interaction.sameSelection)(current.selection, ref) ? null : ref;
|
|
80
|
+
if (!current.isControlled) {
|
|
81
|
+
setInternal(next);
|
|
82
|
+
}
|
|
83
|
+
current.args.onSelectionChange?.(next, next ? event : null);
|
|
84
|
+
}, []);
|
|
85
|
+
return {
|
|
86
|
+
resolved,
|
|
87
|
+
selection,
|
|
88
|
+
select
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Cannot occur in a series id that came from JSON or a database key. */
|
|
92
|
+
const SEPARATOR = '\u0000';
|
|
93
|
+
function useSeriesVisibility(args) {
|
|
94
|
+
const isControlled = args.controlled !== undefined;
|
|
95
|
+
const [internal, setInternal] = (0, _react.useState)(args.initiallyHidden);
|
|
96
|
+
const hiddenList = isControlled ? args.controlled ?? [] : internal;
|
|
97
|
+
const hiddenKey = [...hiddenList].sort((a, b) => a.localeCompare(b)).join(SEPARATOR);
|
|
98
|
+
const hidden = (0, _react.useMemo)(() => new Set(hiddenKey === '' ? [] : hiddenKey.split(SEPARATOR)), [hiddenKey]);
|
|
99
|
+
const latest = (0, _react.useRef)({
|
|
100
|
+
args,
|
|
101
|
+
hidden,
|
|
102
|
+
isControlled
|
|
103
|
+
});
|
|
104
|
+
latest.current = {
|
|
105
|
+
args,
|
|
106
|
+
hidden,
|
|
107
|
+
isControlled
|
|
108
|
+
};
|
|
109
|
+
const toggle = (0, _react.useCallback)((seriesId, metadata) => {
|
|
110
|
+
const current = latest.current;
|
|
111
|
+
if (!current.args.enabled) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const willBeVisible = current.hidden.has(seriesId);
|
|
115
|
+
if (!current.isControlled) {
|
|
116
|
+
setInternal(prev => prev.includes(seriesId) ? prev.filter(id => id !== seriesId) : [...prev, seriesId]);
|
|
117
|
+
}
|
|
118
|
+
current.args.onVisibilityChange?.({
|
|
119
|
+
type: 'visibilityChange',
|
|
120
|
+
seriesId,
|
|
121
|
+
visible: willBeVisible,
|
|
122
|
+
metadata: metadata
|
|
123
|
+
});
|
|
124
|
+
}, []);
|
|
125
|
+
return {
|
|
126
|
+
hidden,
|
|
127
|
+
toggle,
|
|
128
|
+
enabled: args.enabled
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=useChartSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_interaction","_hitTest","useChartSelection","args","isControlled","controlled","undefined","internal","setInternal","useState","selection","resolved","interactionSuppressed","findRegion","hitRegions","seriesId","pointId","latest","useRef","current","selectionKey","unresolved","geometryReady","reportedRef","useEffect","onSelectionUnresolvable","select","useCallback","ref","event","options","next","toggle","sameSelection","onSelectionChange","SEPARATOR","useSeriesVisibility","initiallyHidden","hiddenList","hiddenKey","sort","a","b","localeCompare","join","hidden","useMemo","Set","split","metadata","enabled","willBeVisible","has","prev","includes","filter","id","onVisibilityChange","type","visible"],"sourceRoot":"../../../src","sources":["react/useChartSelection.ts"],"mappings":";;;;;;;AAeA,IAAAA,MAAA,GAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAvBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqDO,SAASG,iBAAiBA,CAAIC,IAA8B,EAAwB;EAC1F,MAAMC,YAAY,GAAGD,IAAI,CAACE,UAAU,KAAKC,SAAS;EAClD,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAG,IAAAC,eAAQ,EAAsB,IAAI,CAAC;EAEnE,MAAMC,SAAS,GAAGN,YAAY,GAAID,IAAI,CAACE,UAAU,IAAI,IAAI,GAAIE,QAAQ;;EAErE;EACA;EACA,MAAMI,QAAQ,GACbD,SAAS,IAAI,CAACP,IAAI,CAACS,qBAAqB,GACrC,IAAAC,mBAAU,EAACV,IAAI,CAACW,UAAU,EAAEJ,SAAS,CAACK,QAAQ,E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EAAa,CAAC,CAAC;EACrDa,MAAM,CAACE,OAAO,GAAG;IAAEhB,IAAI;IAAE0C,MAAM;IAAEzC;EAAa,CAAC;EAE/C,MAAM4B,MAAM,GAAG,IAAAL,kBAAW,EAAC,CAACZ,QAAgB,EAAEkC,QAAkB,KAAK;IACpE,MAAM9B,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC9B,IAAI,CAACA,OAAO,CAAChB,IAAI,CAAC+C,OAAO,EAAE;MAC1B;IACD;IACA,MAAMC,aAAa,GAAGhC,OAAO,CAAC0B,MAAM,CAACO,GAAG,CAACrC,QAAQ,CAAC;IAElD,IAAI,CAACI,OAAO,CAACf,YAAY,EAAE;MAC1BI,WAAW,CAAC6C,IAAI,IACfA,IAAI,CAACC,QAAQ,CAACvC,QAAQ,CAAC,GAAGsC,IAAI,CAACE,MAAM,CAACC,EAAE,IAAIA,EAAE,KAAKzC,QAAQ,CAAC,GAAG,CAAC,GAAGsC,IAAI,EAAEtC,QAAQ,CAClF,CAAC;IACF;IAEAI,OAAO,CAAChB,IAAI,CAACsD,kBAAkB,GAAG;MACjCC,IAAI,EAAE,kBAAkB;MACxB3C,QAAQ;MACR4C,OAAO,EAAER,aAAa;MACtBF,QAAQ,EAAEA;IACX,CAAC,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEJ,MAAM;IAAEb,MAAM;IAAEkB,OAAO,EAAE/C,IAAI,CAAC+C;EAAQ,CAAC;AACjD","ignoreList":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChartStatus = useChartStatus;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _errors = require("../contract/errors.js");
|
|
9
|
+
var _state = require("../contract/state.js");
|
|
10
|
+
var _budgets = require("../validation/budgets.js");
|
|
11
|
+
var _validateDatasource = require("../validation/validateDatasource.js");
|
|
12
|
+
/**
|
|
13
|
+
* What state the chart is in: validation, the app's declared status, and the
|
|
14
|
+
* one report a validation failure gets.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
function useChartStatus(args) {
|
|
18
|
+
const {
|
|
19
|
+
datasource,
|
|
20
|
+
family,
|
|
21
|
+
chartId,
|
|
22
|
+
instanceKey,
|
|
23
|
+
distributionValues
|
|
24
|
+
} = args;
|
|
25
|
+
const validation = (0, _react.useMemo)(() => (0, _validateDatasource.validateDatasource)(datasource, family, chartId, distributionValues), [datasource, family, chartId, distributionValues]);
|
|
26
|
+
|
|
27
|
+
// Warn once per chart instance, dev only, and release the key on unmount so
|
|
28
|
+
// a remount warns again. An effect, not a memo: a warning is a side effect,
|
|
29
|
+
// and React may run a memo's function more than once or discard its result.
|
|
30
|
+
(0, _react.useEffect)(() => {
|
|
31
|
+
(0, _budgets.warnIfOverBudget)(datasource, family, instanceKey);
|
|
32
|
+
}, [datasource, family, instanceKey]);
|
|
33
|
+
(0, _react.useEffect)(() => () => (0, _budgets.releaseBudgetWarning)(instanceKey), [instanceKey]);
|
|
34
|
+
const declaredError = args.declared === 'error' ? (0, _errors.chartError)('declared', 'declaredByApp', {
|
|
35
|
+
chartId,
|
|
36
|
+
family
|
|
37
|
+
}) : undefined;
|
|
38
|
+
const error = validation.error ?? declaredError;
|
|
39
|
+
const status = (0, _state.resolveStatus)({
|
|
40
|
+
declared: args.declared,
|
|
41
|
+
isEmpty: validation.isEmpty,
|
|
42
|
+
isPartial: validation.isPartial,
|
|
43
|
+
error
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// A validation failure is reported through the same channel as a contained
|
|
47
|
+
// render exception, so consumers have one place to watch. `onFailure` is
|
|
48
|
+
// read through a ref: an inline callback would otherwise re-fire the report
|
|
49
|
+
// on every render.
|
|
50
|
+
const reportedRef = (0, _react.useRef)(undefined);
|
|
51
|
+
const onFailureRef = (0, _react.useRef)(args.onFailure);
|
|
52
|
+
onFailureRef.current = args.onFailure;
|
|
53
|
+
(0, _react.useEffect)(() => {
|
|
54
|
+
if (!validation.error) {
|
|
55
|
+
reportedRef.current = undefined;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (reportedRef.current === validation.error.code) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
reportedRef.current = validation.error.code;
|
|
62
|
+
onFailureRef.current?.({
|
|
63
|
+
chartId: validation.error.chartId,
|
|
64
|
+
family: validation.error.family ?? family,
|
|
65
|
+
error: validation.error
|
|
66
|
+
});
|
|
67
|
+
}, [validation.error, family]);
|
|
68
|
+
return {
|
|
69
|
+
validation,
|
|
70
|
+
error,
|
|
71
|
+
status
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=useChartStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_errors","_state","_budgets","_validateDatasource","useChartStatus","args","datasource","family","chartId","instanceKey","distributionValues","validation","useMemo","validateDatasource","useEffect","warnIfOverBudget","releaseBudgetWarning","declaredError","declared","chartError","undefined","error","status","resolveStatus","isEmpty","isPartial","reportedRef","useRef","onFailureRef","onFailure","current","code"],"sourceRoot":"../../../src","sources":["react/useChartStatus.ts"],"mappings":";;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AAXA;AACA;AACA;AACA;;AA2BO,SAASK,cAAcA,CAAIC,IAA2B,EAAqB;EACjF,MAAM;IAAEC,UAAU;IAAEC,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC;EAAmB,CAAC,GAAGL,IAAI;EAE7E,MAAMM,UAAU,GAAG,IAAAC,cAAO,EACzB,MAAM,IAAAC,sCAAkB,EAACP,UAAU,EAAEC,MAAM,EAAEC,OAAO,EAAEE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B,UAAU,CAACU,KAAK,CAACU,IAAI;IAC3CH,YAAY,CAACE,OAAO,GAAG;MACtBtB,OAAO,EAAEG,UAAU,CAACU,KAAK,CAACb,OAAO;MACjCD,MAAM,EAAEI,UAAU,CAACU,KAAK,CAACd,MAAM,IAAIA,MAAM;MACzCc,KAAK,EAAEV,UAAU,CAACU;IACnB,CAAC,CAAC;EACH,CAAC,EAAE,CAACV,UAAU,CAACU,KAAK,EAAEd,MAAM,CAAC,CAAC;EAE9B,OAAO;IAAEI,UAAU;IAAEU,KAAK;IAAEC;EAAO,CAAC;AACrC","ignoreList":[]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Grid = Grid;
|
|
7
|
+
exports.XAxis = XAxis;
|
|
8
|
+
exports.YAxis = YAxis;
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _reactNativeSvg = require("react-native-svg");
|
|
11
|
+
var _layout = require("../geometry/layout.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
/**
|
|
15
|
+
* Axis and grid rendering. Private SVG adapter.
|
|
16
|
+
*
|
|
17
|
+
* Ticks arrive already thinned by `geometry/ticks.ts`, so nothing here decides
|
|
18
|
+
* what fits — this module only draws what the geometry chose.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
function Grid({
|
|
22
|
+
plot,
|
|
23
|
+
yTicks,
|
|
24
|
+
theme
|
|
25
|
+
}) {
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.G, {
|
|
27
|
+
children: yTicks.map(tick => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
|
|
28
|
+
x1: plot.x,
|
|
29
|
+
y1: tick.position,
|
|
30
|
+
x2: (0, _layout.plotRight)(plot),
|
|
31
|
+
y2: tick.position,
|
|
32
|
+
stroke: theme.grid,
|
|
33
|
+
strokeWidth: 1
|
|
34
|
+
}, `grid-${tick.value}`))
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function XAxis({
|
|
38
|
+
plot,
|
|
39
|
+
ticks,
|
|
40
|
+
theme,
|
|
41
|
+
fontSize,
|
|
42
|
+
line = true
|
|
43
|
+
}) {
|
|
44
|
+
const baseline = (0, _layout.plotBottom)(plot);
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.G, {
|
|
46
|
+
children: [line ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
|
|
47
|
+
x1: plot.x,
|
|
48
|
+
y1: baseline,
|
|
49
|
+
x2: (0, _layout.plotRight)(plot),
|
|
50
|
+
y2: baseline,
|
|
51
|
+
stroke: theme.axis,
|
|
52
|
+
strokeWidth: 1
|
|
53
|
+
}) : null, ticks.map(tick => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
|
|
54
|
+
x: tick.position,
|
|
55
|
+
y: baseline + fontSize + 4,
|
|
56
|
+
fill: theme.typography.axisLabel.color,
|
|
57
|
+
fontSize: fontSize,
|
|
58
|
+
textAnchor: "middle",
|
|
59
|
+
children: tick.label
|
|
60
|
+
}, `x-${tick.position}-${tick.label}`))]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function YAxis({
|
|
64
|
+
plot,
|
|
65
|
+
ticks,
|
|
66
|
+
theme,
|
|
67
|
+
fontSize,
|
|
68
|
+
line = true
|
|
69
|
+
}) {
|
|
70
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.G, {
|
|
71
|
+
children: [line ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Line, {
|
|
72
|
+
x1: plot.x,
|
|
73
|
+
y1: plot.y,
|
|
74
|
+
x2: plot.x,
|
|
75
|
+
y2: (0, _layout.plotBottom)(plot),
|
|
76
|
+
stroke: theme.axis,
|
|
77
|
+
strokeWidth: 1
|
|
78
|
+
}) : null, ticks.map(tick => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Text, {
|
|
79
|
+
x: plot.x - 6,
|
|
80
|
+
y: tick.position + fontSize / 3,
|
|
81
|
+
fill: theme.typography.axisLabel.color,
|
|
82
|
+
fontSize: fontSize,
|
|
83
|
+
textAnchor: "end",
|
|
84
|
+
children: tick.label
|
|
85
|
+
}, `y-${tick.position}-${tick.label}`))]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=Axis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNativeSvg","_layout","_jsxRuntime","e","__esModule","default","Grid","plot","yTicks","theme","jsx","G","children","map","tick","Line","x1","x","y1","position","x2","plotRight","y2","stroke","grid","strokeWidth","value","XAxis","ticks","fontSize","line","baseline","plotBottom","jsxs","axis","Text","y","fill","typography","axisLabel","color","textAnchor","label","YAxis"],"sourceRoot":"../../../src","sources":["render/Axis.tsx"],"mappings":";;;;;;;;AAMA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAIA,IAAAE,OAAA,GAAAF,OAAA;AAA2D,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAX3D;AACA;AACA;AACA;AACA;AACA;;AASO,SAASG,IAAIA,CAAC;EACpBC,IAAI;EACJC,MAAM;EACNC;AAKD,CAAC,EAAE;EACF,oBACC,IAAAP,WAAA,CAAAQ,GAAA,EAACV,eAAA,CAAAW,CAAC;IAAAC,QAAA,EACAJ,MAAM,CAACK,GAAG,CA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