@automattic/charts 4.14.0 → 4.15.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 +10 -0
- package/TOKENS.md +1 -1
- package/dist/index.cjs +1249 -325
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +31 -0
- package/dist/index.d.cts +41 -7
- package/dist/index.d.ts +41 -7
- package/dist/index.js +964 -325
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/charts/area-chart/area-chart.tsx +29 -20
- package/src/charts/area-chart/types.ts +3 -1
- package/src/charts/bar-chart/bar-chart.module.scss +38 -0
- package/src/charts/bar-chart/bar-chart.tsx +159 -56
- package/src/charts/bar-chart/private/band-tooltip.tsx +40 -5
- package/src/charts/bar-chart/private/bar-layer.tsx +66 -13
- package/src/charts/bar-chart/private/category.ts +25 -0
- package/src/charts/bar-chart/private/comparison-bars-geometry.ts +13 -1
- package/src/charts/bar-chart/private/index.ts +3 -1
- package/src/charts/bar-chart/private/selected-bar-ring.tsx +17 -6
- package/src/charts/bar-chart/private/stack-layout.ts +99 -0
- package/src/charts/bar-chart/private/stacked-bar-series.tsx +145 -0
- package/src/charts/bar-chart/private/test/stack-layout.test.ts +81 -0
- package/src/charts/bar-chart/private/test/value-domain.test.ts +10 -0
- package/src/charts/bar-chart/private/use-bar-chart-options.ts +35 -11
- package/src/charts/bar-chart/private/{use-overlap-slots.ts → use-bar-slots.ts} +36 -38
- package/src/charts/bar-chart/private/use-bar-stops.ts +19 -19
- package/src/charts/bar-chart/private/value-domain.ts +10 -8
- package/src/charts/bar-chart/test/bar-chart-stacked.test.tsx +546 -0
- package/src/charts/bar-chart/test/bar-chart.test.tsx +75 -0
- package/src/charts/bar-chart/test/use-bar-legend-items.test.tsx +18 -0
- package/src/charts/bar-chart/types.ts +3 -1
- package/src/charts/bar-chart/use-bar-colors.ts +12 -0
- package/src/charts/bar-chart/use-bar-legend-items.ts +4 -2
- package/src/charts/bar-list-chart/bar-list-chart.tsx +2 -0
- package/src/charts/line-chart/line-chart.tsx +55 -26
- package/src/charts/line-chart/test/line-chart.test.tsx +86 -0
- package/src/charts/line-chart/types.ts +3 -1
- package/src/charts/private/test/compact-when-short.test.tsx +170 -0
- package/src/charts/private/test/tick-decimals.test.tsx +95 -0
- package/src/charts/private/tick-decimals.tsx +132 -0
- package/src/charts/private/use-compact-when-short.ts +18 -0
- package/src/providers/chart-context/themes.ts +4 -0
- package/src/types.ts +35 -2
- package/src/charts/private/test/whole-number-ticks.test.tsx +0 -57
- package/src/charts/private/whole-number-ticks.tsx +0 -79
package/dist/index.cjs
CHANGED
|
@@ -1283,6 +1283,15 @@ const defaultTheme = {
|
|
|
1283
1283
|
},
|
|
1284
1284
|
strokeWidth: 1.5
|
|
1285
1285
|
},
|
|
1286
|
+
compactWhenShort: {
|
|
1287
|
+
below: 140,
|
|
1288
|
+
margin: {
|
|
1289
|
+
top: 2,
|
|
1290
|
+
right: 2,
|
|
1291
|
+
bottom: 2,
|
|
1292
|
+
left: 2
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1286
1295
|
heatmapChart: {
|
|
1287
1296
|
compactCellGap: 2,
|
|
1288
1297
|
compactCellSize: 11,
|
|
@@ -3558,6 +3567,89 @@ const getAllHiddenMessage = (interactive, itemType) => {
|
|
|
3558
3567
|
if (interactive) return (0, _wordpress_i18n._x)("All series are hidden. Click legend items to show data.", "chart empty state: interactive series", "jetpack-charts");
|
|
3559
3568
|
return (0, _wordpress_i18n._x)("All series are hidden.", "chart empty state: series", "jetpack-charts");
|
|
3560
3569
|
};
|
|
3570
|
+
// src/charts/private/tick-decimals.tsx
|
|
3571
|
+
/**
|
|
3572
|
+
* Whether every reading in the series is a whole number.
|
|
3573
|
+
*
|
|
3574
|
+
* @param series - The series visx renders.
|
|
3575
|
+
* @return True when at least one reading exists and none has a fraction.
|
|
3576
|
+
*/
|
|
3577
|
+
const hasOnlyWholeNumbers = (series) => {
|
|
3578
|
+
let sawReading = false;
|
|
3579
|
+
for (const { data } of series) for (const point of data) {
|
|
3580
|
+
const value = point?.value;
|
|
3581
|
+
if (!isReading(value)) continue;
|
|
3582
|
+
if (!Number.isInteger(value)) return false;
|
|
3583
|
+
sawReading = true;
|
|
3584
|
+
}
|
|
3585
|
+
return sawReading;
|
|
3586
|
+
};
|
|
3587
|
+
const EPSILON = 1e-12;
|
|
3588
|
+
const tolerance = (scaled) => EPSILON * Math.max(1, Math.abs(scaled));
|
|
3589
|
+
const isValidDecimals = (decimals) => Number.isInteger(decimals) && decimals >= 0;
|
|
3590
|
+
const isOnDecimals = (value, decimals) => {
|
|
3591
|
+
const scaled = value * 10 ** decimals;
|
|
3592
|
+
return Math.abs(scaled - Math.round(scaled)) < tolerance(scaled);
|
|
3593
|
+
};
|
|
3594
|
+
/**
|
|
3595
|
+
* The scale's ticks with those finer than `decimals` places dropped.
|
|
3596
|
+
*
|
|
3597
|
+
* d3 steps by 1, 2 or 5 times a power of ten, so every multiple of 10^-decimals inside the domain is one of its ticks.
|
|
3598
|
+
*
|
|
3599
|
+
* @param scale - The value scale visx built.
|
|
3600
|
+
* @param count - Ticks to ask the scale for; undefined uses the scale's own default, as visx does.
|
|
3601
|
+
* @param decimals - Decimal places a tick may carry; 0 keeps whole numbers.
|
|
3602
|
+
* @return The kept ticks, or undefined when visx's own ticks need no change.
|
|
3603
|
+
*/
|
|
3604
|
+
const getTickDecimalValues = (scale, count, decimals = 0) => {
|
|
3605
|
+
const ticks = scale?.ticks?.(count);
|
|
3606
|
+
if (!ticks?.every((tick) => typeof tick === "number")) return;
|
|
3607
|
+
const kept = ticks.filter((tick) => isOnDecimals(tick, decimals));
|
|
3608
|
+
return kept.length > 1 && kept.length < ticks.length ? kept : void 0;
|
|
3609
|
+
};
|
|
3610
|
+
/**
|
|
3611
|
+
* A value domain widened to the nearest `decimals` steps when fewer than two fit inside it, so the axis shows at least two ticks.
|
|
3612
|
+
*
|
|
3613
|
+
* @param domain - The domain the chart would scale to.
|
|
3614
|
+
* @param decimals - The axis's `tickDecimals`.
|
|
3615
|
+
* @return The widened domain, or undefined when `domain` needs no change.
|
|
3616
|
+
*/
|
|
3617
|
+
const getTickDecimalsDomain = (domain, decimals) => {
|
|
3618
|
+
if (!domain || !isValidDecimals(decimals)) return;
|
|
3619
|
+
const scale = 10 ** decimals;
|
|
3620
|
+
const low = domain[0] * scale;
|
|
3621
|
+
const high = domain[1] * scale;
|
|
3622
|
+
if (Math.floor(high + tolerance(high)) - Math.ceil(low - tolerance(low)) >= 1) return;
|
|
3623
|
+
const floor = Math.floor(low + tolerance(low));
|
|
3624
|
+
const ceil = Math.max(Math.ceil(high - tolerance(high)), floor + 1);
|
|
3625
|
+
return [floor / scale, ceil / scale];
|
|
3626
|
+
};
|
|
3627
|
+
/**
|
|
3628
|
+
* The decimals a value axis's ticks are held to: 0 for whole-number data, else the caller's `tickDecimals`.
|
|
3629
|
+
*
|
|
3630
|
+
* @param hasWholeNumberValues - Whether every plotted value is a whole number.
|
|
3631
|
+
* @param tickDecimals - The axis's `tickDecimals`.
|
|
3632
|
+
* @return Decimal places, or undefined to keep visx's ticks.
|
|
3633
|
+
*/
|
|
3634
|
+
const getTickDecimals = (hasWholeNumberValues, tickDecimals) => {
|
|
3635
|
+
if (hasWholeNumberValues) return 0;
|
|
3636
|
+
return isValidDecimals(tickDecimals) ? tickDecimals : void 0;
|
|
3637
|
+
};
|
|
3638
|
+
/**
|
|
3639
|
+
* Hands its children the chart's value-scale ticks, held to `decimals` places.
|
|
3640
|
+
*
|
|
3641
|
+
* @param props - Component props.
|
|
3642
|
+
* @param props.axis - Which scale carries the values.
|
|
3643
|
+
* @param props.numTicks - Ticks to ask the scale for.
|
|
3644
|
+
* @param props.decimals - Decimal places a tick may carry, or undefined to keep visx's ticks.
|
|
3645
|
+
* @param props.children - Renders the axis and grid with the tick values.
|
|
3646
|
+
* @return The rendered children.
|
|
3647
|
+
*/
|
|
3648
|
+
const TickDecimals = ({ axis, numTicks, decimals, children }) => {
|
|
3649
|
+
const { xScale, yScale } = (0, react.useContext)(_visx_xychart.DataContext);
|
|
3650
|
+
const tickValues = decimals === void 0 ? void 0 : getTickDecimalValues(axis === "x" ? xScale : yScale, numTicks, decimals);
|
|
3651
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: children(tickValues) });
|
|
3652
|
+
};
|
|
3561
3653
|
// src/charts/private/time-axis.ts
|
|
3562
3654
|
const X_TICK_WIDTH = 60;
|
|
3563
3655
|
const getCurveType = (type, smoothing) => {
|
|
@@ -3850,52 +3942,24 @@ const buildTimeAxisOptions = ({ dataSorted, width, axisOptions, scaleDomain, zoo
|
|
|
3850
3942
|
...numTicks === void 0 ? {} : { numTicks }
|
|
3851
3943
|
};
|
|
3852
3944
|
};
|
|
3853
|
-
// src/charts/private/
|
|
3854
|
-
/**
|
|
3855
|
-
* Whether every reading in the series is a whole number.
|
|
3856
|
-
*
|
|
3857
|
-
* @param series - The series visx renders.
|
|
3858
|
-
* @return True when at least one reading exists and none has a fraction.
|
|
3859
|
-
*/
|
|
3860
|
-
const hasOnlyWholeNumbers = (series) => {
|
|
3861
|
-
let sawReading = false;
|
|
3862
|
-
for (const { data } of series) for (const point of data) {
|
|
3863
|
-
const value = point?.value;
|
|
3864
|
-
if (!isReading(value)) continue;
|
|
3865
|
-
if (!Number.isInteger(value)) return false;
|
|
3866
|
-
sawReading = true;
|
|
3867
|
-
}
|
|
3868
|
-
return sawReading;
|
|
3869
|
-
};
|
|
3945
|
+
// src/charts/private/use-compact-when-short.ts
|
|
3870
3946
|
/**
|
|
3871
|
-
*
|
|
3947
|
+
* Whether a `compactWhenShort` chart is compact, and the margin it then defaults to.
|
|
3872
3948
|
*
|
|
3873
|
-
*
|
|
3874
|
-
*
|
|
3875
|
-
* @param scale - The value scale visx built.
|
|
3876
|
-
* @param count - Ticks to ask the scale for; undefined uses the scale's own default, as visx does.
|
|
3877
|
-
* @return Whole-number ticks, or undefined when visx's own ticks need no change.
|
|
3878
|
-
*/
|
|
3879
|
-
const getWholeNumberTickValues = (scale, count) => {
|
|
3880
|
-
const ticks = scale?.ticks?.(count);
|
|
3881
|
-
if (!ticks?.every((tick) => typeof tick === "number")) return;
|
|
3882
|
-
const whole = ticks.filter((tick) => Number.isInteger(tick));
|
|
3883
|
-
return whole.length > 1 && whole.length < ticks.length ? whole : void 0;
|
|
3884
|
-
};
|
|
3885
|
-
/**
|
|
3886
|
-
* Hands its children the whole-number ticks of the chart's value scale.
|
|
3949
|
+
* Reads the height the chart was given, not the measured plot area: that grows once the legend
|
|
3950
|
+
* is hidden and would flip the chart straight back. A zero height is unmeasured, not short.
|
|
3887
3951
|
*
|
|
3888
|
-
* @param
|
|
3889
|
-
* @param
|
|
3890
|
-
* @
|
|
3891
|
-
* @param props.enabled - Whether the plotted values are all whole numbers and the caller pinned neither the ticks nor the value domain.
|
|
3892
|
-
* @param props.children - Renders the axis and grid with the tick values.
|
|
3893
|
-
* @return The rendered children.
|
|
3952
|
+
* @param enabled - The chart's `compactWhenShort` prop.
|
|
3953
|
+
* @param height - The height the chart was given.
|
|
3954
|
+
* @return Whether the chart is compact, and the compact margin when it is.
|
|
3894
3955
|
*/
|
|
3895
|
-
const
|
|
3896
|
-
const {
|
|
3897
|
-
const
|
|
3898
|
-
return
|
|
3956
|
+
const useCompactWhenShort = (enabled, height) => {
|
|
3957
|
+
const { compactWhenShort } = useGlobalChartsTheme();
|
|
3958
|
+
const isCompact = enabled && (height ?? 0) > 0 && height < compactWhenShort.below;
|
|
3959
|
+
return {
|
|
3960
|
+
isCompact,
|
|
3961
|
+
compactMargin: isCompact ? compactWhenShort.margin : void 0
|
|
3962
|
+
};
|
|
3899
3963
|
};
|
|
3900
3964
|
// src/charts/private/with-responsive/with-responsive.module.scss
|
|
3901
3965
|
var with_responsive_module_default = {
|
|
@@ -4782,7 +4846,7 @@ const LineChartScalesRef = ({ chartRef, width, height, margin }) => {
|
|
|
4782
4846
|
]);
|
|
4783
4847
|
return null;
|
|
4784
4848
|
};
|
|
4785
|
-
const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, renderGlyph = defaultRenderGlyph, glyphStyle = {}, withLegendGlyph = false, withGradientFill = false, smoothing = true, curveType, renderTooltip = renderDefaultTooltip, tooltipPlacement, tooltipStyle, withStartGlyphs = false, withEndGlyphs = false, animation, options = {}, onPointerDown = void 0, onPointerUp = void 0, onPointerMove = void 0, onPointerOut = void 0, onDatumActivate = void 0, zoomable = false, rescaleYOnVisibilityChange = true, defaultHiddenSeries, children, gridVisibility, gap = "md" }, ref) => {
|
|
4849
|
+
const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, renderGlyph = defaultRenderGlyph, glyphStyle = {}, withLegendGlyph = false, withGradientFill = false, smoothing = true, curveType, renderTooltip = renderDefaultTooltip, tooltipPlacement, tooltipStyle, withStartGlyphs = false, withEndGlyphs = false, animation, options = {}, onPointerDown = void 0, onPointerUp = void 0, onPointerMove = void 0, onPointerOut = void 0, onDatumActivate = void 0, zoomable = false, rescaleYOnVisibilityChange = true, defaultHiddenSeries, children, gridVisibility, gap = "md", compactWhenShort = false }, ref) => {
|
|
4786
4850
|
const legendInteractive = legend.interactive ?? false;
|
|
4787
4851
|
const legendCollapseGroups = legend.collapseGroups ?? false;
|
|
4788
4852
|
const legendComparisonItem = legend.comparisonItem ?? false;
|
|
@@ -4809,6 +4873,7 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
4809
4873
|
}
|
|
4810
4874
|
});
|
|
4811
4875
|
const { legendChildren, nonLegendChildren } = useChartChildren(children, "LineChart");
|
|
4876
|
+
const { isCompact, compactMargin } = useCompactWhenShort(compactWhenShort, height);
|
|
4812
4877
|
const [measuredChartHeight, setMeasuredChartHeight] = (0, react.useState)();
|
|
4813
4878
|
const handleContentHeightChange = (0, react.useCallback)((contentHeight) => {
|
|
4814
4879
|
setMeasuredChartHeight(contentHeight > 0 ? contentHeight : height);
|
|
@@ -4897,25 +4962,34 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
4897
4962
|
return min <= max ? [min, max] : void 0;
|
|
4898
4963
|
}, [dataSorted, isSeriesVisible]);
|
|
4899
4964
|
const hasWholeNumberValues = (0, react.useMemo)(() => hasOnlyWholeNumbers(visibleSeries), [visibleSeries]);
|
|
4965
|
+
const isLogScale = options?.yScale?.type === "log";
|
|
4966
|
+
const callerTickDecimals = isLogScale ? void 0 : options?.axis?.y?.tickDecimals;
|
|
4967
|
+
const yTickDecimals = getTickDecimals(hasWholeNumberValues, callerTickDecimals);
|
|
4900
4968
|
const chartOptions = (0, react.useMemo)(() => {
|
|
4901
|
-
const fallbackYDomain = getFallbackYDomain(visibleReadingExtent,
|
|
4969
|
+
const fallbackYDomain = getFallbackYDomain(visibleReadingExtent, isLogScale);
|
|
4970
|
+
const { tickDecimals, ...yAxisOptions } = options?.axis?.y ?? {};
|
|
4971
|
+
const tickDecimalsDomain = isLogScale || tickDecimals === void 0 || options?.yScale?.domain || yAxisOptions.tickValues ? void 0 : getTickDecimalsDomain(yDomain ?? fallbackYDomain ?? visibleReadingExtent, yTickDecimals);
|
|
4902
4972
|
return {
|
|
4903
4973
|
axis: {
|
|
4904
|
-
x:
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4974
|
+
x: {
|
|
4975
|
+
...buildTimeAxisOptions({
|
|
4976
|
+
dataSorted,
|
|
4977
|
+
width,
|
|
4978
|
+
axisOptions: options?.axis?.x,
|
|
4979
|
+
scaleDomain: options?.xScale?.domain,
|
|
4980
|
+
zoomDomain: zoom.domain,
|
|
4981
|
+
formatting,
|
|
4982
|
+
isSeriesRendered: (series) => isSeriesVisible(series.label)
|
|
4983
|
+
}),
|
|
4984
|
+
...isCompact && { display: false }
|
|
4985
|
+
},
|
|
4913
4986
|
y: {
|
|
4914
4987
|
orientation: "left",
|
|
4915
4988
|
numTicks: 4,
|
|
4916
4989
|
tickFormat: _automattic_number_formatters.formatNumberCompact,
|
|
4917
4990
|
display: true,
|
|
4918
|
-
...
|
|
4991
|
+
...yAxisOptions,
|
|
4992
|
+
...isCompact && { display: false }
|
|
4919
4993
|
}
|
|
4920
4994
|
},
|
|
4921
4995
|
xScale: {
|
|
@@ -4929,6 +5003,7 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
4929
5003
|
zero: false,
|
|
4930
5004
|
...fallbackYDomain ? { domain: fallbackYDomain } : {},
|
|
4931
5005
|
...yDomain ? { domain: yDomain } : {},
|
|
5006
|
+
...tickDecimalsDomain ? { domain: tickDecimalsDomain } : {},
|
|
4932
5007
|
...options?.yScale
|
|
4933
5008
|
}
|
|
4934
5009
|
};
|
|
@@ -4939,8 +5014,11 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
4939
5014
|
zoom.domain,
|
|
4940
5015
|
yDomain,
|
|
4941
5016
|
visibleReadingExtent,
|
|
5017
|
+
isLogScale,
|
|
5018
|
+
yTickDecimals,
|
|
4942
5019
|
formatting,
|
|
4943
|
-
isSeriesVisible
|
|
5020
|
+
isSeriesVisible,
|
|
5021
|
+
isCompact
|
|
4944
5022
|
]);
|
|
4945
5023
|
const bucketInfo = (0, react.useMemo)(() => getBucketInfo(visibleSeries, options?.axis?.x?.tickResolution), [visibleSeries, options?.axis?.x?.tickResolution]);
|
|
4946
5024
|
const tooltipRenderGlyph = (0, react.useMemo)(() => {
|
|
@@ -5015,7 +5093,7 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5015
5093
|
className: (0, clsx.default)("line-chart", line_chart_module_default["line-chart"]),
|
|
5016
5094
|
children: error
|
|
5017
5095
|
});
|
|
5018
|
-
const legendElement = showLegend && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Legend, {
|
|
5096
|
+
const legendElement = showLegend && !isCompact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Legend, {
|
|
5019
5097
|
orientation: legend.orientation ?? "horizontal",
|
|
5020
5098
|
alignment: legend.alignment ?? "center",
|
|
5021
5099
|
position: legendPosition,
|
|
@@ -5039,7 +5117,7 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5039
5117
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChartLayout, {
|
|
5040
5118
|
legendPosition,
|
|
5041
5119
|
legendElement,
|
|
5042
|
-
legendChildren,
|
|
5120
|
+
legendChildren: isCompact ? [] : legendChildren,
|
|
5043
5121
|
gap,
|
|
5044
5122
|
className: (0, clsx.default)("line-chart", line_chart_module_default["line-chart"], { [line_chart_module_default["line-chart--animated"]]: animation && !prefersReducedMotion }, className),
|
|
5045
5123
|
style: {
|
|
@@ -5067,6 +5145,7 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5067
5145
|
height: chartHeight,
|
|
5068
5146
|
margin: {
|
|
5069
5147
|
...defaultMargin,
|
|
5148
|
+
...compactMargin,
|
|
5070
5149
|
...margin
|
|
5071
5150
|
},
|
|
5072
5151
|
xScale: chartOptions.xScale,
|
|
@@ -5074,12 +5153,12 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5074
5153
|
onPointerOut,
|
|
5075
5154
|
children: [
|
|
5076
5155
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(NearestPointerEvents, { ...zoom.handlers }),
|
|
5077
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
5156
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TickDecimals, {
|
|
5078
5157
|
axis: "y",
|
|
5079
5158
|
numTicks: chartOptions.axis.y.numTicks,
|
|
5080
|
-
|
|
5159
|
+
decimals: !chartOptions.axis.y.tickValues && !options?.yScale?.domain ? yTickDecimals : void 0,
|
|
5081
5160
|
children: (tickValues) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
5082
|
-
!allSeriesHidden && gridVisibility !== "none" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_visx_xychart.Grid, {
|
|
5161
|
+
!allSeriesHidden && gridVisibility !== "none" && !isCompact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_visx_xychart.Grid, {
|
|
5083
5162
|
columns: false,
|
|
5084
5163
|
numTicks: chartOptions.axis.y.numTicks,
|
|
5085
5164
|
tickValues: tickValues ?? chartOptions.axis.y.tickValues
|
|
@@ -5096,7 +5175,7 @@ const LineChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5096
5175
|
y: chartHeight / 2,
|
|
5097
5176
|
width,
|
|
5098
5177
|
height: chartHeight,
|
|
5099
|
-
children: getAllHiddenMessage(legendInteractive, "series")
|
|
5178
|
+
children: getAllHiddenMessage(legendInteractive && !isCompact, "series")
|
|
5100
5179
|
}) : null,
|
|
5101
5180
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ZoomClip, {
|
|
5102
5181
|
active: zoomable && !!zoom.domain,
|
|
@@ -5298,7 +5377,7 @@ const HoverGlyphs = ({ visibleSeries, stacked, stackOffset, getElementStyles, st
|
|
|
5298
5377
|
});
|
|
5299
5378
|
};
|
|
5300
5379
|
// src/charts/area-chart/area-chart.tsx
|
|
5301
|
-
const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, stacked = true, stackOffset = "none", smoothing = true, curveType, fillOpacity, withStroke, renderTooltip = renderDefaultTooltip, animation, options = {}, onPointerDown, onPointerUp, onPointerMove, onPointerOut, zoomable = false, rescaleYOnVisibilityChange = true, defaultHiddenSeries, children, gridVisibility, gap = "md" }, ref) => {
|
|
5380
|
+
const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, stacked = true, stackOffset = "none", smoothing = true, curveType, fillOpacity, withStroke, renderTooltip = renderDefaultTooltip, animation, options = {}, onPointerDown, onPointerUp, onPointerMove, onPointerOut, zoomable = false, rescaleYOnVisibilityChange = true, defaultHiddenSeries, children, gridVisibility, gap = "md", compactWhenShort = false }, ref) => {
|
|
5302
5381
|
const legendInteractive = legend.interactive ?? false;
|
|
5303
5382
|
const legendShape = legend.shape ?? "rect";
|
|
5304
5383
|
const legendPosition = legend.position ?? "bottom";
|
|
@@ -5321,6 +5400,7 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5321
5400
|
}
|
|
5322
5401
|
});
|
|
5323
5402
|
const { legendChildren, nonLegendChildren } = useChartChildren(children, "AreaChart");
|
|
5403
|
+
const { isCompact, compactMargin } = useCompactWhenShort(compactWhenShort, height);
|
|
5324
5404
|
const [measuredChartHeight, setMeasuredChartHeight] = (0, react.useState)();
|
|
5325
5405
|
const handleContentHeightChange = (0, react.useCallback)((contentHeight) => {
|
|
5326
5406
|
setMeasuredChartHeight(contentHeight > 0 ? contentHeight : height);
|
|
@@ -5400,20 +5480,24 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5400
5480
|
const chartOptions = (0, react.useMemo)(() => {
|
|
5401
5481
|
return {
|
|
5402
5482
|
axis: {
|
|
5403
|
-
x:
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5483
|
+
x: {
|
|
5484
|
+
...buildTimeAxisOptions({
|
|
5485
|
+
dataSorted,
|
|
5486
|
+
width,
|
|
5487
|
+
axisOptions: options?.axis?.x,
|
|
5488
|
+
scaleDomain: options?.xScale?.domain,
|
|
5489
|
+
zoomDomain: zoom.domain,
|
|
5490
|
+
formatting
|
|
5491
|
+
}),
|
|
5492
|
+
...isCompact && { display: false }
|
|
5493
|
+
},
|
|
5411
5494
|
y: {
|
|
5412
5495
|
orientation: "left",
|
|
5413
5496
|
numTicks: 4,
|
|
5414
5497
|
tickFormat: _automattic_number_formatters.formatNumberCompact,
|
|
5415
5498
|
display: true,
|
|
5416
|
-
...options?.axis?.y
|
|
5499
|
+
...options?.axis?.y,
|
|
5500
|
+
...isCompact && { display: false }
|
|
5417
5501
|
}
|
|
5418
5502
|
},
|
|
5419
5503
|
xScale: {
|
|
@@ -5436,7 +5520,8 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5436
5520
|
stacked,
|
|
5437
5521
|
fixedYDomain,
|
|
5438
5522
|
zoom.domain,
|
|
5439
|
-
formatting
|
|
5523
|
+
formatting,
|
|
5524
|
+
isCompact
|
|
5440
5525
|
]);
|
|
5441
5526
|
const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme);
|
|
5442
5527
|
const error = validateData$3(dataSorted);
|
|
@@ -5516,7 +5601,7 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5516
5601
|
className: (0, clsx.default)("area-chart", area_chart_module_default["area-chart"]),
|
|
5517
5602
|
children: error
|
|
5518
5603
|
});
|
|
5519
|
-
const legendElement = showLegend && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Legend, {
|
|
5604
|
+
const legendElement = showLegend && !isCompact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Legend, {
|
|
5520
5605
|
orientation: legend.orientation ?? "horizontal",
|
|
5521
5606
|
alignment: legend.alignment ?? "center",
|
|
5522
5607
|
position: legendPosition,
|
|
@@ -5564,7 +5649,7 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5564
5649
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChartLayout, {
|
|
5565
5650
|
legendPosition,
|
|
5566
5651
|
legendElement,
|
|
5567
|
-
legendChildren,
|
|
5652
|
+
legendChildren: isCompact ? [] : legendChildren,
|
|
5568
5653
|
gap,
|
|
5569
5654
|
className: (0, clsx.default)("area-chart", area_chart_module_default["area-chart"], { [area_chart_module_default["area-chart--animated"]]: animationEnabled }, className),
|
|
5570
5655
|
style: {
|
|
@@ -5592,6 +5677,7 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5592
5677
|
height: chartHeight,
|
|
5593
5678
|
margin: {
|
|
5594
5679
|
...defaultMargin,
|
|
5680
|
+
...compactMargin,
|
|
5595
5681
|
...margin
|
|
5596
5682
|
},
|
|
5597
5683
|
xScale: chartOptions.xScale,
|
|
@@ -5602,12 +5688,12 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5602
5688
|
onPointerOut,
|
|
5603
5689
|
pointerEventsDataKey: "nearest",
|
|
5604
5690
|
children: [
|
|
5605
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
5691
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TickDecimals, {
|
|
5606
5692
|
axis: "y",
|
|
5607
5693
|
numTicks: chartOptions.axis.y.numTicks,
|
|
5608
|
-
|
|
5694
|
+
decimals: hasWholeNumberValues && !chartOptions.axis.y.tickValues && !options?.yScale?.domain ? 0 : void 0,
|
|
5609
5695
|
children: (tickValues) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
5610
|
-
!allSeriesHidden && gridVisibility !== "none" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_visx_xychart.Grid, {
|
|
5696
|
+
!allSeriesHidden && gridVisibility !== "none" && !isCompact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_visx_xychart.Grid, {
|
|
5611
5697
|
columns: false,
|
|
5612
5698
|
numTicks: chartOptions.axis.y.numTicks,
|
|
5613
5699
|
tickValues: tickValues ?? chartOptions.axis.y.tickValues
|
|
@@ -5624,7 +5710,7 @@ const AreaChartInternal = (0, react.forwardRef)(({ data, ariaLabel, chartId: pro
|
|
|
5624
5710
|
y: chartHeight / 2,
|
|
5625
5711
|
width,
|
|
5626
5712
|
height: chartHeight,
|
|
5627
|
-
children: getAllHiddenMessage(legendInteractive, "series")
|
|
5713
|
+
children: getAllHiddenMessage(legendInteractive && !isCompact, "series")
|
|
5628
5714
|
}) : null,
|
|
5629
5715
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ZoomClip, {
|
|
5630
5716
|
active: zoomable,
|
|
@@ -5687,9 +5773,145 @@ var bar_chart_module_default = {
|
|
|
5687
5773
|
"bar-chart": "a8ccharts-97yN9W-bar-chart",
|
|
5688
5774
|
"bar-chart--animated": "a8ccharts-97yN9W-bar-chart--animated",
|
|
5689
5775
|
"bar-chart--animated-horizontal": "a8ccharts-97yN9W-bar-chart--animated-horizontal",
|
|
5776
|
+
"bar-chart--stacked": "a8ccharts-97yN9W-bar-chart--stacked",
|
|
5690
5777
|
"rise": "a8ccharts-97yN9W-rise",
|
|
5691
5778
|
"stretch": "a8ccharts-97yN9W-stretch"
|
|
5692
5779
|
};
|
|
5780
|
+
// src/charts/bar-chart/private/category.ts
|
|
5781
|
+
/**
|
|
5782
|
+
* Whether two data points sit at the same category: the same label, or the same date.
|
|
5783
|
+
*
|
|
5784
|
+
* @param point - A data point.
|
|
5785
|
+
* @param category - The data point naming the category.
|
|
5786
|
+
* @return Whether `point` is at `category`.
|
|
5787
|
+
*/
|
|
5788
|
+
function isSameCategory(point, category) {
|
|
5789
|
+
return category.label ? point.label === category.label : !!category.date && !!point.date && point.date.getTime() === category.date.getTime();
|
|
5790
|
+
}
|
|
5791
|
+
/**
|
|
5792
|
+
* The category a data point sits at, as a key two points share when `isSameCategory` holds.
|
|
5793
|
+
*
|
|
5794
|
+
* @param point - A data point.
|
|
5795
|
+
* @return The category key.
|
|
5796
|
+
*/
|
|
5797
|
+
function categoryKey(point) {
|
|
5798
|
+
return point.label ? `label:${point.label}` : `date:${point.date?.getTime()}`;
|
|
5799
|
+
}
|
|
5800
|
+
// src/charts/bar-chart/private/value-domain.ts
|
|
5801
|
+
/** Domain for a value axis that has nothing to scale, so its ticks still read 0 to 1. */
|
|
5802
|
+
const EMPTY_DOMAIN = [0, 1];
|
|
5803
|
+
/**
|
|
5804
|
+
* The value a bar is drawn at, preferring `visualValue` so a zero still shows a sliver.
|
|
5805
|
+
*
|
|
5806
|
+
* A missing reading is NaN, not null: `ComparisonBars` coerces the value with `Number()`,
|
|
5807
|
+
* which turns null into 0 and would draw a comparison shadow at the baseline.
|
|
5808
|
+
*
|
|
5809
|
+
* @param point - A data point handed to visx.
|
|
5810
|
+
* @return The bar value, or NaN when the bucket has no reading.
|
|
5811
|
+
*/
|
|
5812
|
+
const getBarValue = (point) => {
|
|
5813
|
+
const enhanced = point;
|
|
5814
|
+
return (enhanced?.visualValue !== void 0 ? enhanced.visualValue : point?.value) ?? NaN;
|
|
5815
|
+
};
|
|
5816
|
+
/**
|
|
5817
|
+
* Whether visx renders a bar for a point.
|
|
5818
|
+
*
|
|
5819
|
+
* @param point - A data point handed to visx.
|
|
5820
|
+
* @return True when the point has a finite bar value.
|
|
5821
|
+
*/
|
|
5822
|
+
const isBarRendered = (point) => Number.isFinite(getBarValue(point));
|
|
5823
|
+
/**
|
|
5824
|
+
* An explicit domain for the value scale, or null to let visx fit one to the data.
|
|
5825
|
+
*
|
|
5826
|
+
* Zero goes into the domain here rather than through the scale's `zero` flag: visx applies
|
|
5827
|
+
* `nice` before `zero`, which would leave the axis topping out at a raw maximum.
|
|
5828
|
+
*
|
|
5829
|
+
* @param data - Every series handed to the chart.
|
|
5830
|
+
* @param includeZero - Whether the domain must span zero.
|
|
5831
|
+
* @param isSeriesRendered - Whether visx mounts a series, i.e. the legend shows it.
|
|
5832
|
+
* @param tickDecimals - The value axis's `tickDecimals`.
|
|
5833
|
+
* @return Value domain, or null when visx should fit its own.
|
|
5834
|
+
*/
|
|
5835
|
+
const getValueScaleDomain = (data, includeZero, isSeriesRendered, tickDecimals) => {
|
|
5836
|
+
let min = Infinity;
|
|
5837
|
+
let max = -Infinity;
|
|
5838
|
+
for (const series of data) {
|
|
5839
|
+
if (!isSeriesRendered(series)) continue;
|
|
5840
|
+
for (const point of series.data) {
|
|
5841
|
+
const value = getBarValue(point);
|
|
5842
|
+
if (!Number.isFinite(value)) continue;
|
|
5843
|
+
min = Math.min(min, value);
|
|
5844
|
+
max = Math.max(max, value);
|
|
5845
|
+
}
|
|
5846
|
+
}
|
|
5847
|
+
if (min === Infinity) return [...EMPTY_DOMAIN];
|
|
5848
|
+
let domain = null;
|
|
5849
|
+
if (min === max) domain = min === 0 ? [...EMPTY_DOMAIN] : [Math.min(0, min), Math.max(0, max)];
|
|
5850
|
+
else if (includeZero) domain = [Math.min(0, min), Math.max(0, max)];
|
|
5851
|
+
return getTickDecimalsDomain(domain ?? [min, max], tickDecimals) ?? domain;
|
|
5852
|
+
};
|
|
5853
|
+
// src/charts/bar-chart/private/stack-layout.ts
|
|
5854
|
+
/**
|
|
5855
|
+
* The series a layout draws: a stacked layout leaves comparison series out for now.
|
|
5856
|
+
*
|
|
5857
|
+
* @param series - The chart's series.
|
|
5858
|
+
* @param layout - The layout the bars are drawn in.
|
|
5859
|
+
* @return The drawn series.
|
|
5860
|
+
*/
|
|
5861
|
+
function getDrawnSeries(series, layout) {
|
|
5862
|
+
return layout === "stacked" ? series.filter((item) => item.options?.type !== "comparison") : series;
|
|
5863
|
+
}
|
|
5864
|
+
/**
|
|
5865
|
+
* Stacks the series in order at each category: positives upward and negatives downward from zero.
|
|
5866
|
+
*
|
|
5867
|
+
* @param series - The series to stack, bottom first.
|
|
5868
|
+
* @return The stack layout.
|
|
5869
|
+
*/
|
|
5870
|
+
function getStackLayout(series) {
|
|
5871
|
+
const segments = /* @__PURE__ */ new Map();
|
|
5872
|
+
const extents = /* @__PURE__ */ new Map();
|
|
5873
|
+
for (const { label, data } of series) {
|
|
5874
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
5875
|
+
segments.set(label, byCategory);
|
|
5876
|
+
for (const point of data) {
|
|
5877
|
+
const value = getBarValue(point);
|
|
5878
|
+
if (!Number.isFinite(value)) continue;
|
|
5879
|
+
const key = categoryKey(point);
|
|
5880
|
+
if (byCategory.has(key)) continue;
|
|
5881
|
+
const extent = extents.get(key) ?? [0, 0];
|
|
5882
|
+
const side = value < 0 ? 0 : 1;
|
|
5883
|
+
const start = extent[side];
|
|
5884
|
+
extent[side] = start + value;
|
|
5885
|
+
extents.set(key, extent);
|
|
5886
|
+
byCategory.set(key, {
|
|
5887
|
+
start,
|
|
5888
|
+
end: start + value
|
|
5889
|
+
});
|
|
5890
|
+
}
|
|
5891
|
+
}
|
|
5892
|
+
let extent = null;
|
|
5893
|
+
for (const [low, high] of extents.values()) extent = extent ? [Math.min(extent[0], low), Math.max(extent[1], high)] : [low, high];
|
|
5894
|
+
return {
|
|
5895
|
+
segmentOf: (key, datum) => segments.get(key)?.get(categoryKey(datum)),
|
|
5896
|
+
extentAt: (category) => {
|
|
5897
|
+
const [low, high] = extents.get(categoryKey(category)) ?? [0, 0];
|
|
5898
|
+
return [low, high];
|
|
5899
|
+
},
|
|
5900
|
+
extent
|
|
5901
|
+
};
|
|
5902
|
+
}
|
|
5903
|
+
/**
|
|
5904
|
+
* The value domain of a computed stack, falling back to an empty chart's domain.
|
|
5905
|
+
*
|
|
5906
|
+
* @param stack - The precomputed stack.
|
|
5907
|
+
* @param tickDecimals - The value axis precision, when set.
|
|
5908
|
+
* @return The extent widened for tick precision, or the empty chart domain.
|
|
5909
|
+
*/
|
|
5910
|
+
function getStackedValueDomain(stack, tickDecimals) {
|
|
5911
|
+
const { extent } = stack;
|
|
5912
|
+
const domain = !extent || extent[0] === extent[1] ? [...EMPTY_DOMAIN] : extent;
|
|
5913
|
+
return getTickDecimalsDomain(domain, tickDecimals) ?? domain;
|
|
5914
|
+
}
|
|
5693
5915
|
// src/charts/bar-chart/private/truncated-tick-component.tsx
|
|
5694
5916
|
/**
|
|
5695
5917
|
* Get the bandwidth of a scale
|
|
@@ -5804,57 +6026,6 @@ const createTruncatedTickComponent = (axis) => (props) => {
|
|
|
5804
6026
|
*/
|
|
5805
6027
|
const TruncatedXTickComponent = createTruncatedTickComponent("x");
|
|
5806
6028
|
const TruncatedYTickComponent = createTruncatedTickComponent("y");
|
|
5807
|
-
// src/charts/bar-chart/private/value-domain.ts
|
|
5808
|
-
/** Domain for a value axis that has nothing to scale, so its ticks still read 0 to 1. */
|
|
5809
|
-
const EMPTY_DOMAIN = [0, 1];
|
|
5810
|
-
/**
|
|
5811
|
-
* The value a bar is drawn at, preferring `visualValue` so a zero still shows a sliver.
|
|
5812
|
-
*
|
|
5813
|
-
* A missing reading is NaN, not null: `ComparisonBars` coerces the value with `Number()`,
|
|
5814
|
-
* which turns null into 0 and would draw a comparison shadow at the baseline.
|
|
5815
|
-
*
|
|
5816
|
-
* @param point - A data point handed to visx.
|
|
5817
|
-
* @return The bar value, or NaN when the bucket has no reading.
|
|
5818
|
-
*/
|
|
5819
|
-
const getBarValue = (point) => {
|
|
5820
|
-
const enhanced = point;
|
|
5821
|
-
return (enhanced?.visualValue !== void 0 ? enhanced.visualValue : point?.value) ?? NaN;
|
|
5822
|
-
};
|
|
5823
|
-
/**
|
|
5824
|
-
* Whether visx renders a bar for a point.
|
|
5825
|
-
*
|
|
5826
|
-
* @param point - A data point handed to visx.
|
|
5827
|
-
* @return True when the point has a finite bar value.
|
|
5828
|
-
*/
|
|
5829
|
-
const isBarRendered = (point) => Number.isFinite(getBarValue(point));
|
|
5830
|
-
/**
|
|
5831
|
-
* An explicit domain for the value scale, or null to let visx fit one to the data.
|
|
5832
|
-
*
|
|
5833
|
-
* Zero goes into the domain here rather than through the scale's `zero` flag: visx applies
|
|
5834
|
-
* `nice` before `zero`, which would leave the axis topping out at a raw maximum.
|
|
5835
|
-
*
|
|
5836
|
-
* @param data - Every series handed to the chart.
|
|
5837
|
-
* @param includeZero - Whether the domain must span zero.
|
|
5838
|
-
* @param isSeriesRendered - Whether visx mounts a series, i.e. the legend shows it.
|
|
5839
|
-
* @return Value domain, or null when visx should fit its own.
|
|
5840
|
-
*/
|
|
5841
|
-
const getValueScaleDomain = (data, includeZero, isSeriesRendered) => {
|
|
5842
|
-
let min = Infinity;
|
|
5843
|
-
let max = -Infinity;
|
|
5844
|
-
for (const series of data) {
|
|
5845
|
-
if (!isSeriesRendered(series)) continue;
|
|
5846
|
-
for (const point of series.data) {
|
|
5847
|
-
const value = getBarValue(point);
|
|
5848
|
-
if (!Number.isFinite(value)) continue;
|
|
5849
|
-
min = Math.min(min, value);
|
|
5850
|
-
max = Math.max(max, value);
|
|
5851
|
-
}
|
|
5852
|
-
}
|
|
5853
|
-
if (min === Infinity) return [...EMPTY_DOMAIN];
|
|
5854
|
-
if (min === max) return min === 0 ? [...EMPTY_DOMAIN] : [Math.min(0, min), Math.max(0, max)];
|
|
5855
|
-
if (includeZero) return [Math.min(0, min), Math.max(0, max)];
|
|
5856
|
-
return null;
|
|
5857
|
-
};
|
|
5858
6029
|
// src/charts/bar-chart/private/use-bar-chart-options.ts
|
|
5859
6030
|
/** Outer padding of the category band scale (space at the chart edges). */
|
|
5860
6031
|
const BASE_BAND_PADDING = .2;
|
|
@@ -5943,14 +6114,18 @@ const getGroupPadding = (scale) => {
|
|
|
5943
6114
|
* @param horizontal - Whether the chart is horizontal or vertical.
|
|
5944
6115
|
* @param options - The options for the chart.
|
|
5945
6116
|
* @param isSeriesRendered - Whether visx mounts a series, i.e. the legend shows it.
|
|
6117
|
+
* @param stack - The precomputed stack, when series share one bar.
|
|
5946
6118
|
* @return The merged options for the chart.
|
|
5947
6119
|
*/
|
|
5948
|
-
function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = ALL_RENDERED) {
|
|
6120
|
+
function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = ALL_RENDERED, stack) {
|
|
5949
6121
|
const stableOptions = useDeepMemo(options);
|
|
5950
6122
|
const formatting = useChartFormatting();
|
|
6123
|
+
const isStacked = !!stack;
|
|
5951
6124
|
const axisConfig = (0, react.useMemo)(() => {
|
|
5952
|
-
const { labelOverflow: xLabelOverflow, tickResolution: xTickResolution, tickFormat: xTickFormat, ...xAxisOptions } = stableOptions.axis?.x || {};
|
|
5953
|
-
const { labelOverflow: yLabelOverflow, tickResolution: yTickResolution, tickFormat: yTickFormat, ...yAxisOptions } = stableOptions.axis?.y || {};
|
|
6125
|
+
const { labelOverflow: xLabelOverflow, tickResolution: xTickResolution, tickFormat: xTickFormat, tickDecimals: xTickDecimals, ...xAxisOptions } = stableOptions.axis?.x || {};
|
|
6126
|
+
const { labelOverflow: yLabelOverflow, tickResolution: yTickResolution, tickFormat: yTickFormat, tickDecimals: yTickDecimals, ...yAxisOptions } = stableOptions.axis?.y || {};
|
|
6127
|
+
const [valueAxisOptions, valueTickDecimals] = horizontal ? [xAxisOptions, xTickDecimals] : [yAxisOptions, yTickDecimals];
|
|
6128
|
+
const valueScaleType = isStacked ? "linear" : (horizontal ? stableOptions.xScale : stableOptions.yScale)?.type;
|
|
5954
6129
|
return {
|
|
5955
6130
|
xLabelOverflow,
|
|
5956
6131
|
yLabelOverflow,
|
|
@@ -5958,9 +6133,14 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
|
|
|
5958
6133
|
yTickFormat,
|
|
5959
6134
|
xAxisOptions,
|
|
5960
6135
|
yAxisOptions,
|
|
5961
|
-
tickResolution: horizontal ? yTickResolution : xTickResolution
|
|
6136
|
+
tickResolution: horizontal ? yTickResolution : xTickResolution,
|
|
6137
|
+
valueTickDecimals: valueAxisOptions.tickValues || valueScaleType === "log" ? void 0 : valueTickDecimals
|
|
5962
6138
|
};
|
|
5963
|
-
}, [
|
|
6139
|
+
}, [
|
|
6140
|
+
stableOptions,
|
|
6141
|
+
horizontal,
|
|
6142
|
+
isStacked
|
|
6143
|
+
]);
|
|
5964
6144
|
const { tickResolution } = axisConfig;
|
|
5965
6145
|
const defaultOptions = (0, react.useMemo)(() => {
|
|
5966
6146
|
const bandScale = {
|
|
@@ -6015,17 +6195,21 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
|
|
|
6015
6195
|
const { xTickFormat: defaultXTickFormat, yTickFormat: defaultYTickFormat, tooltipLabelFormatter: defaultTooltipLabelFormatter, xAccessor, yAccessor, gridVisibility, xScale: baseXScale, yScale: baseYScale } = defaultOptions[horizontal ? "horizontal" : "vertical"];
|
|
6016
6196
|
const valueScaleOptions = horizontal ? stableOptions.xScale : stableOptions.yScale;
|
|
6017
6197
|
const includeZero = data.some((s) => s.options?.type === "comparison") || valueScaleOptions?.zero !== false;
|
|
6018
|
-
|
|
6019
|
-
|
|
6198
|
+
let domain = null;
|
|
6199
|
+
if (!valueScaleOptions?.domain) domain = stack ? getStackedValueDomain(stack, axisConfig.valueTickDecimals) : getValueScaleDomain(data, includeZero, isSeriesRendered, axisConfig.valueTickDecimals);
|
|
6200
|
+
const valueScaleOverride = {
|
|
6201
|
+
...domain && { domain },
|
|
6202
|
+
...stack && { type: "linear" }
|
|
6203
|
+
};
|
|
6020
6204
|
const xScale = {
|
|
6021
6205
|
...baseXScale,
|
|
6022
6206
|
...stableOptions.xScale || {},
|
|
6023
|
-
...horizontal ?
|
|
6207
|
+
...horizontal ? valueScaleOverride : {}
|
|
6024
6208
|
};
|
|
6025
6209
|
const yScale = {
|
|
6026
6210
|
...baseYScale,
|
|
6027
6211
|
...stableOptions.yScale || {},
|
|
6028
|
-
...!horizontal ?
|
|
6212
|
+
...!horizontal ? valueScaleOverride : {}
|
|
6029
6213
|
};
|
|
6030
6214
|
const { xLabelOverflow, yLabelOverflow, xTickFormat, yTickFormat, xAxisOptions, yAxisOptions } = axisConfig;
|
|
6031
6215
|
const dateAxisTickFormat = horizontal ? yTickFormat : xTickFormat;
|
|
@@ -6060,7 +6244,8 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
|
|
|
6060
6244
|
}
|
|
6061
6245
|
},
|
|
6062
6246
|
barGroup: { padding: getGroupPadding(horizontal ? yScale : xScale) },
|
|
6063
|
-
tooltip: { labelFormatter: dateAxisTickFormat || defaultTooltipLabelFormatter }
|
|
6247
|
+
tooltip: { labelFormatter: dateAxisTickFormat || defaultTooltipLabelFormatter },
|
|
6248
|
+
valueTickDecimals: axisConfig.valueTickDecimals
|
|
6064
6249
|
};
|
|
6065
6250
|
}, [
|
|
6066
6251
|
defaultOptions,
|
|
@@ -6068,7 +6253,8 @@ function useBarChartOptions(data, horizontal, options = {}, isSeriesRendered = A
|
|
|
6068
6253
|
stableOptions,
|
|
6069
6254
|
horizontal,
|
|
6070
6255
|
data,
|
|
6071
|
-
isSeriesRendered
|
|
6256
|
+
isSeriesRendered,
|
|
6257
|
+
stack
|
|
6072
6258
|
]);
|
|
6073
6259
|
}
|
|
6074
6260
|
// src/charts/bar-chart/private/band-scale.ts
|
|
@@ -6100,6 +6286,17 @@ function getValueScaleBaseline(scale) {
|
|
|
6100
6286
|
return Number.isFinite(maybeZero) ? Math.max(maybeZero, minOutput) : minOutput;
|
|
6101
6287
|
}
|
|
6102
6288
|
/**
|
|
6289
|
+
* A value's position on a continuous scale, held inside its range so a domain that leaves the value out cannot push a bar off the plot.
|
|
6290
|
+
*
|
|
6291
|
+
* @param {ValueScale} scale - The continuous value scale.
|
|
6292
|
+
* @param {number} value - The value to place.
|
|
6293
|
+
* @return {number} The position in pixels.
|
|
6294
|
+
*/
|
|
6295
|
+
function getValueScalePosition(scale, value) {
|
|
6296
|
+
const [a, b] = scale.range().map((r) => Number(r) || 0);
|
|
6297
|
+
return Math.min(Math.max(scale(value), Math.min(a, b)), Math.max(a, b));
|
|
6298
|
+
}
|
|
6299
|
+
/**
|
|
6103
6300
|
* Compute the rect that spans `valuePositions` along the value axis, centered on a slot and scaled by `widthFactor` across it.
|
|
6104
6301
|
*
|
|
6105
6302
|
* @param {object} params - Geometry inputs.
|
|
@@ -6296,13 +6493,13 @@ const SelectedBarRing = ({ chartId, selected, slotKeys, groupPadding, horizontal
|
|
|
6296
6493
|
const slotOffset = groupScale(selected.slotKey);
|
|
6297
6494
|
const bandPosition = Number(bandScale((horizontal ? yAccessor : xAccessor)(category)));
|
|
6298
6495
|
if (slotOffset == null || !Number.isFinite(bandPosition)) return null;
|
|
6299
|
-
const valuePositions = selected.data.map((datum) => Number(valueScale(Number((horizontal ? xAccessor : yAccessor)(datum)))));
|
|
6496
|
+
const valuePositions = selected.valueExtent ? selected.valueExtent.map((value) => getValueScalePosition(valueScale, value)) : [getValueScaleBaseline(valueScale), ...selected.data.map((datum) => Number(valueScale(Number((horizontal ? xAccessor : yAccessor)(datum)))))];
|
|
6300
6497
|
const rect = computeSlotRect({
|
|
6301
6498
|
horizontal,
|
|
6302
6499
|
bandPosition,
|
|
6303
6500
|
slotOffset,
|
|
6304
6501
|
slotThickness: groupScale.bandwidth(),
|
|
6305
|
-
valuePositions
|
|
6502
|
+
valuePositions,
|
|
6306
6503
|
widthFactor: selected.thickness
|
|
6307
6504
|
});
|
|
6308
6505
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectedRing, {
|
|
@@ -6312,13 +6509,107 @@ const SelectedBarRing = ({ chartId, selected, slotKeys, groupPadding, horizontal
|
|
|
6312
6509
|
testId: "bar-chart-selected-ring"
|
|
6313
6510
|
});
|
|
6314
6511
|
};
|
|
6512
|
+
// src/charts/bar-chart/private/stacked-bar-series.tsx
|
|
6513
|
+
/**
|
|
6514
|
+
* The side a segment rounds when it ends its drawn stack: the far end of the positives or of the negatives.
|
|
6515
|
+
*
|
|
6516
|
+
* @param stack - The stack layout.
|
|
6517
|
+
* @param segment - The segment.
|
|
6518
|
+
* @param category - A datum at the segment's category.
|
|
6519
|
+
* @param horizontal - Whether the bars run horizontally.
|
|
6520
|
+
* @param clamp - Holds a value inside the value domain, where the bars are cut off.
|
|
6521
|
+
* @return The side to round, or undefined for a segment inside its stack or drawn with no length.
|
|
6522
|
+
*/
|
|
6523
|
+
function getStackEnd(stack, segment, category, horizontal, clamp) {
|
|
6524
|
+
const [start, end] = [segment.start, segment.end].map(clamp);
|
|
6525
|
+
if (start === end) return;
|
|
6526
|
+
const extent = stack.extentAt(category).map(clamp);
|
|
6527
|
+
if (segment.end > 0 && end === extent[1]) return horizontal ? "right" : "top";
|
|
6528
|
+
if (segment.end < 0 && end === extent[0]) return horizontal ? "left" : "bottom";
|
|
6529
|
+
}
|
|
6530
|
+
const StackedBarSeries = ({ barClassName, slotKeys, slotKey, groupPadding, stack, ...props }) => {
|
|
6531
|
+
const { xScale, yScale, horizontal } = (0, react.useContext)(_visx_xychart.DataContext);
|
|
6532
|
+
const bandScale = horizontal ? yScale : xScale;
|
|
6533
|
+
const valueScale = horizontal ? xScale : yScale;
|
|
6534
|
+
const groupScale = (0, react.useMemo)(() => createGroupScale(slotKeys, bandScale?.bandwidth?.() ?? 0, groupPadding), [
|
|
6535
|
+
slotKeys,
|
|
6536
|
+
bandScale,
|
|
6537
|
+
groupPadding
|
|
6538
|
+
]);
|
|
6539
|
+
const { dataKey, xAccessor, yAccessor } = props;
|
|
6540
|
+
const [domainStart, domainEnd] = (horizontal ? xScale : yScale)?.domain() ?? [-Infinity, Infinity];
|
|
6541
|
+
const domainMin = Math.min(Number(domainStart), Number(domainEnd));
|
|
6542
|
+
const domainMax = Math.max(Number(domainStart), Number(domainEnd));
|
|
6543
|
+
const clamp = (0, react.useCallback)((value) => Math.min(domainMax, Math.max(domainMin, value)), [domainMin, domainMax]);
|
|
6544
|
+
const stackEnd = (0, react.useCallback)((datum) => {
|
|
6545
|
+
const [low, high] = stack.extentAt(datum);
|
|
6546
|
+
return clamp(high > 0 ? high : low);
|
|
6547
|
+
}, [stack, clamp]);
|
|
6548
|
+
const renderGlyph = (0, react.useCallback)(({ datum, color }) => {
|
|
6549
|
+
const segment = stack.segmentOf(dataKey, datum);
|
|
6550
|
+
if (!segment || !bandScale?.bandwidth || !valueScale) return null;
|
|
6551
|
+
const rect = computeSlotRect({
|
|
6552
|
+
horizontal: !!horizontal,
|
|
6553
|
+
bandPosition: Number(bandScale((horizontal ? yAccessor : xAccessor)(datum))),
|
|
6554
|
+
slotOffset: groupScale(slotKey) ?? 0,
|
|
6555
|
+
slotThickness: groupScale.bandwidth(),
|
|
6556
|
+
valuePositions: [segment.start, segment.end].map((value) => getValueScalePosition(valueScale, value)),
|
|
6557
|
+
widthFactor: 1
|
|
6558
|
+
});
|
|
6559
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
6560
|
+
...rect,
|
|
6561
|
+
"data-stack-end": getStackEnd(stack, segment, datum, !!horizontal, clamp),
|
|
6562
|
+
className: (0, clsx.default)("visx-bar", barClassName?.(datum)),
|
|
6563
|
+
fill: color
|
|
6564
|
+
});
|
|
6565
|
+
}, [
|
|
6566
|
+
stack,
|
|
6567
|
+
clamp,
|
|
6568
|
+
dataKey,
|
|
6569
|
+
bandScale,
|
|
6570
|
+
valueScale,
|
|
6571
|
+
horizontal,
|
|
6572
|
+
groupScale,
|
|
6573
|
+
slotKey,
|
|
6574
|
+
xAccessor,
|
|
6575
|
+
yAccessor,
|
|
6576
|
+
barClassName
|
|
6577
|
+
]);
|
|
6578
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_visx_xychart.GlyphSeries, {
|
|
6579
|
+
...props,
|
|
6580
|
+
xAccessor: horizontal ? stackEnd : xAccessor,
|
|
6581
|
+
yAccessor: horizontal ? yAccessor : stackEnd,
|
|
6582
|
+
enableEvents: false,
|
|
6583
|
+
renderGlyph
|
|
6584
|
+
});
|
|
6585
|
+
};
|
|
6315
6586
|
// src/charts/bar-chart/private/bar-layer.tsx
|
|
6316
6587
|
/**
|
|
6317
|
-
*
|
|
6588
|
+
* Wraps the stacked bars so the entrance animation grows them from the zero line.
|
|
6589
|
+
*
|
|
6590
|
+
* Reading the scales here, not in `BarLayer`, keeps the series' own data registration from re-rendering it in a loop.
|
|
6591
|
+
*
|
|
6592
|
+
* @param props - Component props.
|
|
6593
|
+
* @param props.horizontal - Whether the bars run horizontally.
|
|
6594
|
+
* @param props.children - The stacked series.
|
|
6595
|
+
* @return The group.
|
|
6596
|
+
*/
|
|
6597
|
+
const StackedBarGroup = ({ horizontal, children }) => {
|
|
6598
|
+
const { xScale, yScale } = (0, react.useContext)(_visx_xychart.DataContext);
|
|
6599
|
+
const valueScale = horizontal ? xScale : yScale;
|
|
6600
|
+
const zero = valueScale ? getValueScalePosition(valueScale, 0) : 0;
|
|
6601
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("g", {
|
|
6602
|
+
className: "visx-bar-group",
|
|
6603
|
+
style: { transformOrigin: horizontal ? `${zero}px 0` : `0 ${zero}px` },
|
|
6604
|
+
children
|
|
6605
|
+
});
|
|
6606
|
+
};
|
|
6607
|
+
/**
|
|
6608
|
+
* Draws the bars in front of any comparison shadows, stacked or slotted in the layout's slots and grouped by visx otherwise, then the selected bar's ring.
|
|
6318
6609
|
*
|
|
6319
6610
|
* @param props - Component props.
|
|
6320
6611
|
* @param props.chartId - The chart's id, which keeps the ring's clip path unique on a page with several charts.
|
|
6321
|
-
* @param props.
|
|
6612
|
+
* @param props.barSlots - The overlap or stacked slots, or undefined for a grouped layout.
|
|
6322
6613
|
* @param props.selectedBar - The bar or slot the keyboard has selected.
|
|
6323
6614
|
* @param props.primaryEntries - The visible primary series, for a grouped layout.
|
|
6324
6615
|
* @param props.primaryKeys - Their labels, in group order.
|
|
@@ -6330,20 +6621,35 @@ const SelectedBarRing = ({ chartId, selected, slotKeys, groupPadding, horizontal
|
|
|
6330
6621
|
* @param props.yAccessor - Reads a datum's y value.
|
|
6331
6622
|
* @return The bars.
|
|
6332
6623
|
*/
|
|
6333
|
-
const BarLayer = ({ chartId,
|
|
6624
|
+
const BarLayer = ({ chartId, barSlots, selectedBar, primaryEntries, primaryKeys, getBarBackground, barClassName, groupPadding, horizontal, xAccessor, yAccessor }) => {
|
|
6334
6625
|
let bars;
|
|
6335
|
-
if (
|
|
6626
|
+
if (barSlots?.kind === "stacked") bars = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StackedBarGroup, {
|
|
6627
|
+
horizontal,
|
|
6628
|
+
children: barSlots.entries.map(({ series, index }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StackedBarSeries, {
|
|
6629
|
+
dataKey: series.label,
|
|
6630
|
+
data: series.data,
|
|
6631
|
+
xAccessor,
|
|
6632
|
+
yAccessor,
|
|
6633
|
+
colorAccessor: getBarBackground(index),
|
|
6634
|
+
barClassName,
|
|
6635
|
+
slotKeys: barSlots.slotKeys,
|
|
6636
|
+
slotKey: barSlots.slotOf(series.label),
|
|
6637
|
+
groupPadding,
|
|
6638
|
+
stack: barSlots.stack
|
|
6639
|
+
}, series.label))
|
|
6640
|
+
});
|
|
6641
|
+
else if (barSlots) bars = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("g", {
|
|
6336
6642
|
className: "visx-bar-group",
|
|
6337
|
-
children:
|
|
6643
|
+
children: barSlots.entries.map(({ series, index }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SlottedBarSeries, {
|
|
6338
6644
|
dataKey: series.label,
|
|
6339
6645
|
data: series.data,
|
|
6340
6646
|
xAccessor,
|
|
6341
6647
|
yAccessor,
|
|
6342
6648
|
colorAccessor: getBarBackground(index),
|
|
6343
6649
|
barClassName,
|
|
6344
|
-
slotKeys:
|
|
6345
|
-
slotKey:
|
|
6346
|
-
thickness:
|
|
6650
|
+
slotKeys: barSlots.slotKeys,
|
|
6651
|
+
slotKey: barSlots.slotOf(series.label),
|
|
6652
|
+
thickness: barSlots.thicknessOf(series.label),
|
|
6347
6653
|
groupPadding
|
|
6348
6654
|
}, series.label))
|
|
6349
6655
|
});
|
|
@@ -6373,7 +6679,7 @@ const BarLayer = ({ chartId, overlapSlots, selectedBar, primaryEntries, primaryK
|
|
|
6373
6679
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [bars, selectedBar && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectedBarRing, {
|
|
6374
6680
|
chartId,
|
|
6375
6681
|
selected: selectedBar,
|
|
6376
|
-
slotKeys:
|
|
6682
|
+
slotKeys: barSlots?.slotKeys ?? primaryKeys,
|
|
6377
6683
|
groupPadding,
|
|
6378
6684
|
horizontal,
|
|
6379
6685
|
xAccessor,
|
|
@@ -6509,28 +6815,36 @@ function getOverlapBarColors(series, colors, slotColors, background) {
|
|
|
6509
6815
|
});
|
|
6510
6816
|
return barColors;
|
|
6511
6817
|
}
|
|
6512
|
-
// src/charts/bar-chart/private/use-
|
|
6818
|
+
// src/charts/bar-chart/private/use-bar-slots.ts
|
|
6513
6819
|
/**
|
|
6514
|
-
*
|
|
6515
|
-
*
|
|
6516
|
-
* @param point - A data point.
|
|
6517
|
-
* @param category - The data point naming the category.
|
|
6518
|
-
* @return Whether `point` is at `category`.
|
|
6519
|
-
*/
|
|
6520
|
-
function isSameCategory(point, category) {
|
|
6521
|
-
return category.label ? point.label === category.label : !!category.date && !!point.date && point.date.getTime() === category.date.getTime();
|
|
6522
|
-
}
|
|
6523
|
-
/**
|
|
6524
|
-
* Lays out the visible series of an overlap layout in slots and layers.
|
|
6820
|
+
* Lays out the visible series in slots: overlap layers primaries and comparisons in two, stacked puts every primary in one.
|
|
6525
6821
|
*
|
|
6526
|
-
* @param
|
|
6822
|
+
* @param layout - How the chart places its series in a category.
|
|
6527
6823
|
* @param seriesWithVisibility - Every series, with its index and whether it is visible.
|
|
6528
|
-
* @return The
|
|
6824
|
+
* @return The slots, or undefined for a grouped layout.
|
|
6529
6825
|
*/
|
|
6530
|
-
function
|
|
6826
|
+
function useBarSlots(layout, seriesWithVisibility) {
|
|
6531
6827
|
return (0, react.useMemo)(() => {
|
|
6532
|
-
if (
|
|
6828
|
+
if (layout === "grouped") return;
|
|
6533
6829
|
const visible = seriesWithVisibility.filter(({ isVisible }) => isVisible);
|
|
6830
|
+
if (layout === "stacked") {
|
|
6831
|
+
const entries = visible.map(({ series, index }) => ({
|
|
6832
|
+
series,
|
|
6833
|
+
index
|
|
6834
|
+
}));
|
|
6835
|
+
const slotKeys = [PRIMARY_SLOT];
|
|
6836
|
+
const slotOf = () => PRIMARY_SLOT;
|
|
6837
|
+
return {
|
|
6838
|
+
kind: "stacked",
|
|
6839
|
+
stack: getStackLayout(entries.map(({ series }) => series)),
|
|
6840
|
+
entries,
|
|
6841
|
+
keys: entries.map(({ series }) => series.label),
|
|
6842
|
+
slotKeys,
|
|
6843
|
+
slotOf,
|
|
6844
|
+
thicknessOf: () => 1,
|
|
6845
|
+
positions: getStopPositions(entries, slotKeys, slotOf)
|
|
6846
|
+
};
|
|
6847
|
+
}
|
|
6534
6848
|
const placements = getOverlapPlacements(visible.map(({ series }) => series));
|
|
6535
6849
|
const placed = visible.map(({ series, index }, position) => ({
|
|
6536
6850
|
entry: {
|
|
@@ -6547,6 +6861,7 @@ function useOverlapSlots(enabled, seriesWithVisibility) {
|
|
|
6547
6861
|
const showsComparisons = entries.some(({ series }) => slotOf(series.label) === COMPARISON_SLOT);
|
|
6548
6862
|
const slotKeys = [...hasPrimaries ? [PRIMARY_SLOT] : [], ...showsComparisons ? [COMPARISON_SLOT] : []];
|
|
6549
6863
|
return {
|
|
6864
|
+
kind: "overlap",
|
|
6550
6865
|
entries,
|
|
6551
6866
|
keys: entries.map(({ series }) => series.label),
|
|
6552
6867
|
slotKeys,
|
|
@@ -6554,16 +6869,7 @@ function useOverlapSlots(enabled, seriesWithVisibility) {
|
|
|
6554
6869
|
thicknessOf,
|
|
6555
6870
|
positions: getStopPositions(entries, slotKeys, slotOf)
|
|
6556
6871
|
};
|
|
6557
|
-
}, [
|
|
6558
|
-
}
|
|
6559
|
-
/**
|
|
6560
|
-
* The category a data point sits at, as a key two points share when `isSameCategory` holds.
|
|
6561
|
-
*
|
|
6562
|
-
* @param point - A data point.
|
|
6563
|
-
* @return The category key.
|
|
6564
|
-
*/
|
|
6565
|
-
function categoryKey(point) {
|
|
6566
|
-
return point.label ? `label:${point.label}` : `date:${point.date?.getTime()}`;
|
|
6872
|
+
}, [layout, seriesWithVisibility]);
|
|
6567
6873
|
}
|
|
6568
6874
|
/**
|
|
6569
6875
|
* Lists a stop for every slot at every category that slot draws a bar at, category by category.
|
|
@@ -6622,7 +6928,7 @@ function membersAt(entries, category, stopKey) {
|
|
|
6622
6928
|
/**
|
|
6623
6929
|
* The slot a keyboard index selects, and every bar at its category.
|
|
6624
6930
|
*
|
|
6625
|
-
* @param slots - The overlap
|
|
6931
|
+
* @param slots - The overlap or stacked slots.
|
|
6626
6932
|
* @param selectedIndex - The keyboard index into `slots.positions`.
|
|
6627
6933
|
* @return The selected slot, or undefined when nothing is selected or drawn there.
|
|
6628
6934
|
*/
|
|
@@ -6636,25 +6942,26 @@ function getSelectedSlot(slots, selectedIndex) {
|
|
|
6636
6942
|
data: slotBars.map(({ datum }) => datum),
|
|
6637
6943
|
slotKey,
|
|
6638
6944
|
thickness: Math.max(...slotBars.map(({ key }) => slots.thicknessOf(key))),
|
|
6639
|
-
members
|
|
6945
|
+
members,
|
|
6946
|
+
...slots.kind === "stacked" && { valueExtent: slots.stack.extentAt(category) }
|
|
6640
6947
|
};
|
|
6641
6948
|
}
|
|
6642
6949
|
// src/charts/bar-chart/private/use-bar-stops.ts
|
|
6643
6950
|
/**
|
|
6644
|
-
* Lays out the keyboard stops: one per slot and category in
|
|
6951
|
+
* Lays out the keyboard stops: one per slot and category in a slotted layout, else one per primary bar, series-major within each category.
|
|
6645
6952
|
*
|
|
6646
|
-
* @param
|
|
6953
|
+
* @param barSlots - The overlap or stacked slots, or undefined for a grouped layout.
|
|
6647
6954
|
* @param primaryEntries - The visible primary series.
|
|
6648
6955
|
* @return The stops.
|
|
6649
6956
|
*/
|
|
6650
|
-
function useBarStops(
|
|
6651
|
-
const series = (0, react.useMemo)(() =>
|
|
6957
|
+
function useBarStops(barSlots, primaryEntries) {
|
|
6958
|
+
const series = (0, react.useMemo)(() => barSlots ? [] : primaryEntries.map((entry) => entry.series), [barSlots, primaryEntries]);
|
|
6652
6959
|
return {
|
|
6653
|
-
count:
|
|
6654
|
-
key: (0, react.useMemo)(() => JSON.stringify(
|
|
6960
|
+
count: barSlots?.positions.length ?? Math.max(0, ...series.map((item) => item.data.length)) * series.length,
|
|
6961
|
+
key: (0, react.useMemo)(() => JSON.stringify(barSlots?.keys ?? series.map((item) => item.label)), [barSlots, series]),
|
|
6655
6962
|
barAt: (0, react.useCallback)((stop) => {
|
|
6656
|
-
if (
|
|
6657
|
-
const position =
|
|
6963
|
+
if (barSlots) {
|
|
6964
|
+
const position = barSlots.positions[stop];
|
|
6658
6965
|
return position && {
|
|
6659
6966
|
datum: position.datum,
|
|
6660
6967
|
index: position.dataPointIndex,
|
|
@@ -6670,17 +6977,17 @@ function useBarStops(overlapSlots, primaryEntries) {
|
|
|
6670
6977
|
index,
|
|
6671
6978
|
key: item.label
|
|
6672
6979
|
} : void 0;
|
|
6673
|
-
}, [
|
|
6980
|
+
}, [barSlots, series]),
|
|
6674
6981
|
stopOf: (0, react.useCallback)((seriesKey, dataPointIndex) => {
|
|
6675
|
-
if (
|
|
6676
|
-
const hovered =
|
|
6677
|
-
const slotKey =
|
|
6678
|
-
const stop = hovered ?
|
|
6982
|
+
if (barSlots) {
|
|
6983
|
+
const hovered = barSlots.entries.find((entry) => entry.series.label === seriesKey)?.series.data[dataPointIndex];
|
|
6984
|
+
const slotKey = barSlots.slotOf(seriesKey);
|
|
6985
|
+
const stop = hovered ? barSlots.positions.findIndex((position) => position.slotKey === slotKey && isSameCategory(position.datum, hovered)) : -1;
|
|
6679
6986
|
return stop >= 0 ? stop : void 0;
|
|
6680
6987
|
}
|
|
6681
6988
|
const seriesIndex = series.findIndex((item) => item.label === seriesKey);
|
|
6682
6989
|
return seriesIndex >= 0 ? dataPointIndex * series.length + seriesIndex : void 0;
|
|
6683
|
-
}, [
|
|
6990
|
+
}, [barSlots, series])
|
|
6684
6991
|
};
|
|
6685
6992
|
}
|
|
6686
6993
|
/**
|
|
@@ -6835,10 +7142,23 @@ function nearestBandIndex(data, accessor, scale, position) {
|
|
|
6835
7142
|
return nearest;
|
|
6836
7143
|
}
|
|
6837
7144
|
/**
|
|
7145
|
+
* How far a pointer sits from a stacked segment along the value axis.
|
|
7146
|
+
*
|
|
7147
|
+
* @param segment - The segment, or undefined when its series has no reading there.
|
|
7148
|
+
* @param scale - The value scale.
|
|
7149
|
+
* @param position - Pointer coordinate on the value axis.
|
|
7150
|
+
* @return 0 inside the segment, Infinity without one, otherwise the gap to its nearer end.
|
|
7151
|
+
*/
|
|
7152
|
+
function distanceToSegment(segment, scale, position) {
|
|
7153
|
+
if (!segment) return Infinity;
|
|
7154
|
+
const [low, high] = [segment.start, segment.end].map((value) => getValueScalePosition(scale, value)).sort((a, b) => a - b);
|
|
7155
|
+
return Math.max(low - position, 0, position - high);
|
|
7156
|
+
}
|
|
7157
|
+
/**
|
|
6838
7158
|
* Correct visx's range-based band inversion, which omits outer padding.
|
|
6839
7159
|
* @param root0 - Registered series selection.
|
|
6840
7160
|
* @param root0.keys - Visible series keys, back to front where bars overlap.
|
|
6841
|
-
* @param root0.slots - Where series share slots: the slots of a category, in the order the band lays them out,
|
|
7161
|
+
* @param root0.slots - Where series share slots: the slots of a category, in the order the band lays them out, the slot each series sits in, and for a stack where each segment runs.
|
|
6842
7162
|
* @param root0.groupPadding - Padding between grouped bars.
|
|
6843
7163
|
* @param root0.withTooltips - Whether pointer events update the tooltip.
|
|
6844
7164
|
* @param root0.onPointerDown - Receives the corrected pointer-down datum.
|
|
@@ -6850,6 +7170,7 @@ function BandTooltip({ keys, slots, groupPadding, withTooltips, onPointerDown, o
|
|
|
6850
7170
|
const { xScale, yScale, dataRegistry, horizontal } = (0, react.useContext)(_visx_xychart.DataContext);
|
|
6851
7171
|
const { showTooltip, hideTooltip, updateTooltip } = (0, react.useContext)(_visx_xychart.TooltipContext);
|
|
6852
7172
|
const scale = horizontal ? yScale : xScale;
|
|
7173
|
+
const valueScale = horizontal ? xScale : yScale;
|
|
6853
7174
|
const bandwidth = scale?.bandwidth?.() ?? 0;
|
|
6854
7175
|
const groupScale = (0, react.useMemo)(() => createGroupScale(slots?.keys ?? keys, bandwidth, groupPadding), [
|
|
6855
7176
|
slots,
|
|
@@ -6874,6 +7195,7 @@ function BandTooltip({ keys, slots, groupPadding, withTooltips, onPointerDown, o
|
|
|
6874
7195
|
const start = band + Number(groupScale(slots ? slots.slotOf(key) : key));
|
|
6875
7196
|
const end = start + groupScale.step();
|
|
6876
7197
|
const distance = position >= start && position <= end ? 0 : Math.abs(position - (start + end) / 2);
|
|
7198
|
+
const valueDistance = slots?.stack && valueScale ? distanceToSegment(slots.stack.segmentOf(key, datum), valueScale, horizontal ? point.x : point.y) : 0;
|
|
6877
7199
|
bands.push(band);
|
|
6878
7200
|
selections.push({
|
|
6879
7201
|
event: params.event,
|
|
@@ -6881,8 +7203,8 @@ function BandTooltip({ keys, slots, groupPadding, withTooltips, onPointerDown, o
|
|
|
6881
7203
|
datum,
|
|
6882
7204
|
index,
|
|
6883
7205
|
svgPoint: point,
|
|
6884
|
-
distanceX: horizontal ?
|
|
6885
|
-
distanceY: horizontal ? distance :
|
|
7206
|
+
distanceX: horizontal ? valueDistance : distance,
|
|
7207
|
+
distanceY: horizontal ? distance : valueDistance
|
|
6886
7208
|
});
|
|
6887
7209
|
}
|
|
6888
7210
|
if (!slots) return selections;
|
|
@@ -6891,6 +7213,7 @@ function BandTooltip({ keys, slots, groupPadding, withTooltips, onPointerDown, o
|
|
|
6891
7213
|
return selections.filter((_, index) => bands[index] === hoveredBand);
|
|
6892
7214
|
}, [
|
|
6893
7215
|
scale,
|
|
7216
|
+
valueScale,
|
|
6894
7217
|
dataRegistry,
|
|
6895
7218
|
horizontal,
|
|
6896
7219
|
keys,
|
|
@@ -6984,6 +7307,16 @@ function useBarColors() {
|
|
|
6984
7307
|
data,
|
|
6985
7308
|
index
|
|
6986
7309
|
}).color);
|
|
7310
|
+
if (layout === "stacked") {
|
|
7311
|
+
const drawn = getDrawnSeries(series, layout);
|
|
7312
|
+
return series.map((data, index) => {
|
|
7313
|
+
const drawnIndex = drawn.indexOf(data);
|
|
7314
|
+
return drawnIndex === -1 ? colors[index] : getElementStyles({
|
|
7315
|
+
data,
|
|
7316
|
+
index: drawnIndex
|
|
7317
|
+
}).color;
|
|
7318
|
+
});
|
|
7319
|
+
}
|
|
6987
7320
|
if (layout !== "overlap") return comparisonOpacity === void 0 ? getGroupedBarColors(series, colors, backgroundColor) : colors;
|
|
6988
7321
|
return getOverlapBarColors(series, colors, [getElementStyles({ index: 0 }).color, getElementStyles({ index: 1 }).color], backgroundColor);
|
|
6989
7322
|
}, [
|
|
@@ -7032,13 +7365,14 @@ function forBarLayout(data, items, layout, seriesColors) {
|
|
|
7032
7365
|
/**
|
|
7033
7366
|
* Builds legend items that match `BarChart`'s bars in a layout, for a custom legend or a chart's own.
|
|
7034
7367
|
*
|
|
7035
|
-
* @param
|
|
7368
|
+
* @param allData - The chart's series; those the layout does not draw get no item.
|
|
7036
7369
|
* @param options - The legend options, and the layout the bars are drawn in.
|
|
7037
7370
|
* @param legendShape - The shape of the legend swatches.
|
|
7038
7371
|
* @return The legend items.
|
|
7039
7372
|
*/
|
|
7040
|
-
function useBarLegendItems(
|
|
7373
|
+
function useBarLegendItems(allData, options = {}, legendShape) {
|
|
7041
7374
|
const { layout } = options;
|
|
7375
|
+
const data = (0, react.useMemo)(() => getDrawnSeries(allData, layout), [allData, layout]);
|
|
7042
7376
|
const getBarColors = useBarColors();
|
|
7043
7377
|
const seriesColors = (0, react.useMemo)(() => layout ? getBarColors(data, { layout }) : void 0, [
|
|
7044
7378
|
data,
|
|
@@ -7067,7 +7401,12 @@ const renderTooltipRow = (label, value) => /* @__PURE__ */ (0, react_jsx_runtime
|
|
|
7067
7401
|
className: bar_chart_module_default["bar-chart__tooltip-row"],
|
|
7068
7402
|
children: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("%1$s: %2$s", "jetpack-charts"), label, value)
|
|
7069
7403
|
});
|
|
7070
|
-
const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, height, className, margin, withTooltips = false, showLegend = false, legend = {}, gridVisibility: gridVisibilityProp, renderTooltip, tooltipPlacement, tooltipAnchorTop, tooltipStyle, barClassName, options = {}, orientation = "vertical", layout = "grouped", withPatterns = false, showZeroValues = false, withBandHighlight = false, onBandHighlightChange, defaultHiddenSeries, animation, children, gap = "md", onPointerDown, onPointerUp, onDatumActivate }) => {
|
|
7404
|
+
const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, height, className, margin, withTooltips = false, showLegend = false, legend = {}, gridVisibility: gridVisibilityProp, renderTooltip, tooltipPlacement, tooltipAnchorTop, tooltipStyle, barClassName, options = {}, orientation = "vertical", layout = "grouped", withPatterns = false, showZeroValues = false, withBandHighlight = false, onBandHighlightChange, defaultHiddenSeries, animation, children, gap = "md", compactWhenShort = false, onPointerDown, onPointerUp, onDatumActivate }) => {
|
|
7405
|
+
if (layout === "stacked" && showZeroValues) warnOnce("bar-chart-stacked-zero-values", "BarChart: showZeroValues has no effect in a stacked layout.");
|
|
7406
|
+
if (layout === "stacked" && data?.some((series) => series.options?.type === "comparison")) warnOnce("bar-chart-stacked-comparison", "BarChart: a stacked layout does not draw comparison series yet.");
|
|
7407
|
+
const valueScaleOptions = orientation === "horizontal" ? options.xScale : options.yScale;
|
|
7408
|
+
if (layout === "stacked" && valueScaleOptions?.type && valueScaleOptions.type !== "linear") warnOnce(`bar-chart-stacked-${valueScaleOptions.type}-scale`, `BarChart: a stacked layout draws on a linear value scale, so the ${valueScaleOptions.type} scale is ignored.`);
|
|
7409
|
+
if (layout === "stacked" && valueScaleOptions?.zero === false && !valueScaleOptions.domain) warnOnce("bar-chart-stacked-zero", "BarChart: every stack starts at zero, so zero: false has no effect in a stacked layout.");
|
|
7071
7410
|
if (!withTooltips && (withBandHighlight || onBandHighlightChange)) warnOnce("bar-chart-band-highlight-without-tooltips", "BarChart: withBandHighlight and onBandHighlightChange require withTooltips.");
|
|
7072
7411
|
const legendInteractive = legend.interactive ?? false;
|
|
7073
7412
|
const legendCollapseGroups = legend.collapseGroups ?? false;
|
|
@@ -7075,13 +7414,15 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7075
7414
|
const legendComparisonSeriesItems = legend.comparisonSeriesItems;
|
|
7076
7415
|
const horizontal = orientation === "horizontal";
|
|
7077
7416
|
const isOverlap = layout === "overlap";
|
|
7417
|
+
const isStacked = layout === "stacked";
|
|
7078
7418
|
const chartId = useChartId(providedChartId);
|
|
7079
7419
|
const hiddenSeries = useDefaultHiddenSeries(chartId, defaultHiddenSeries);
|
|
7080
7420
|
const isSeriesVisible = (0, react.useCallback)((seriesLabel) => !hiddenSeries.has(seriesLabel), [hiddenSeries]);
|
|
7081
7421
|
const theme = useXYChartTheme(data);
|
|
7082
|
-
const
|
|
7422
|
+
const transformedData = useChartDataTransform(data);
|
|
7423
|
+
const dataSorted = (0, react.useMemo)(() => getDrawnSeries(transformedData, layout), [layout, transformedData]);
|
|
7083
7424
|
const dataWithVisibleZeros = useZeroValueDisplay(dataSorted, {
|
|
7084
|
-
enabled: showZeroValues,
|
|
7425
|
+
enabled: showZeroValues && !isStacked,
|
|
7085
7426
|
valueAxisLength: horizontal ? width : height
|
|
7086
7427
|
});
|
|
7087
7428
|
const legendItems = useBarLegendItems(dataSorted, (0, react.useMemo)(() => ({
|
|
@@ -7105,13 +7446,39 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7105
7446
|
if (providerTheme.barChart?.barStyles?.comparison?.opacity !== void 0) warnOnce("bar-chart-comparison-opacity", "BarChart: theme.barChart.barStyles.comparison.opacity is deprecated. Comparison bars are opaque; leave it unset.");
|
|
7106
7447
|
const isSeriesRendered = (0, react.useCallback)((series) => isSeriesVisible(series.label), [isSeriesVisible]);
|
|
7107
7448
|
const hasWholeNumberValues = (0, react.useMemo)(() => hasOnlyWholeNumbers(dataSorted.filter(isSeriesRendered)), [dataSorted, isSeriesRendered]);
|
|
7108
|
-
const
|
|
7449
|
+
const { isCompact, compactMargin } = useCompactWhenShort(compactWhenShort && !horizontal, height);
|
|
7450
|
+
const resolvedOptions = (0, react.useMemo)(() => isCompact ? {
|
|
7451
|
+
...options,
|
|
7452
|
+
axis: {
|
|
7453
|
+
...options.axis,
|
|
7454
|
+
x: {
|
|
7455
|
+
...options.axis?.x,
|
|
7456
|
+
display: false
|
|
7457
|
+
},
|
|
7458
|
+
y: {
|
|
7459
|
+
...options.axis?.y,
|
|
7460
|
+
display: false
|
|
7461
|
+
}
|
|
7462
|
+
}
|
|
7463
|
+
} : options, [isCompact, options]);
|
|
7464
|
+
const seriesWithVisibility = (0, react.useMemo)(() => dataWithVisibleZeros.map((series, index) => ({
|
|
7465
|
+
series,
|
|
7466
|
+
index,
|
|
7467
|
+
isVisible: isSeriesRendered(series)
|
|
7468
|
+
})), [dataWithVisibleZeros, isSeriesRendered]);
|
|
7469
|
+
const allSeriesHidden = (0, react.useMemo)(() => {
|
|
7470
|
+
return seriesWithVisibility.every(({ isVisible }) => !isVisible);
|
|
7471
|
+
}, [seriesWithVisibility]);
|
|
7472
|
+
const primaryEntries = (0, react.useMemo)(() => seriesWithVisibility.filter(({ isVisible, series }) => isVisible && series.options?.type !== "comparison"), [seriesWithVisibility]);
|
|
7473
|
+
const barSlots = useBarSlots(layout, seriesWithVisibility);
|
|
7474
|
+
const chartOptions = useBarChartOptions(dataWithVisibleZeros, horizontal, resolvedOptions, isSeriesRendered, barSlots?.kind === "stacked" ? barSlots.stack : void 0);
|
|
7109
7475
|
const valueAxis = horizontal ? chartOptions.axis.x : chartOptions.axis.y;
|
|
7110
7476
|
const callerValueDomain = horizontal ? options.xScale?.domain : options.yScale?.domain;
|
|
7111
|
-
const
|
|
7477
|
+
const valueTickDecimals = getTickDecimals(hasWholeNumberValues, chartOptions.valueTickDecimals);
|
|
7478
|
+
const tickDecimalsProps = {
|
|
7112
7479
|
axis: horizontal ? "x" : "y",
|
|
7113
7480
|
numTicks: valueAxis.numTicks,
|
|
7114
|
-
|
|
7481
|
+
decimals: !valueAxis.tickValues && !callerValueDomain ? valueTickDecimals : void 0
|
|
7115
7482
|
};
|
|
7116
7483
|
const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme, horizontal);
|
|
7117
7484
|
const chartRef = (0, react.useRef)(null);
|
|
@@ -7122,18 +7489,8 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7122
7489
|
}, [height]);
|
|
7123
7490
|
const [selectedIndex, setSelectedIndex] = (0, react.useState)(void 0);
|
|
7124
7491
|
const [isNavigating, setIsNavigating] = (0, react.useState)(false);
|
|
7125
|
-
const seriesWithVisibility = (0, react.useMemo)(() => dataWithVisibleZeros.map((series, index) => ({
|
|
7126
|
-
series,
|
|
7127
|
-
index,
|
|
7128
|
-
isVisible: isSeriesRendered(series)
|
|
7129
|
-
})), [dataWithVisibleZeros, isSeriesRendered]);
|
|
7130
|
-
const allSeriesHidden = (0, react.useMemo)(() => {
|
|
7131
|
-
return seriesWithVisibility.every(({ isVisible }) => !isVisible);
|
|
7132
|
-
}, [seriesWithVisibility]);
|
|
7133
|
-
const primaryEntries = (0, react.useMemo)(() => seriesWithVisibility.filter(({ isVisible, series }) => isVisible && series.options?.type !== "comparison"), [seriesWithVisibility]);
|
|
7134
|
-
const overlapSlots = useOverlapSlots(isOverlap, seriesWithVisibility);
|
|
7135
7492
|
const primaryKeys = (0, react.useMemo)(() => primaryEntries.map(({ series }) => series.label), [primaryEntries]);
|
|
7136
|
-
const stops = useBarStops(
|
|
7493
|
+
const stops = useBarStops(barSlots, primaryEntries);
|
|
7137
7494
|
const { barAt, stopOf } = stops;
|
|
7138
7495
|
const activateSelectedBar = (0, react.useCallback)((stop) => {
|
|
7139
7496
|
const bar = barAt(stop);
|
|
@@ -7154,7 +7511,7 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7154
7511
|
if (stop !== void 0) onChartPointerMove(stop);
|
|
7155
7512
|
}, [stopOf, onChartPointerMove]);
|
|
7156
7513
|
const comparisonEntries = (0, react.useMemo)(() => {
|
|
7157
|
-
if (
|
|
7514
|
+
if (barSlots) return [];
|
|
7158
7515
|
const primaryByGroup = new Map(primaryEntries.map(({ series, index }) => [series.group, {
|
|
7159
7516
|
label: series.label,
|
|
7160
7517
|
index
|
|
@@ -7175,7 +7532,7 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7175
7532
|
});
|
|
7176
7533
|
return entries;
|
|
7177
7534
|
}, [
|
|
7178
|
-
|
|
7535
|
+
barSlots,
|
|
7179
7536
|
seriesWithVisibility,
|
|
7180
7537
|
primaryEntries,
|
|
7181
7538
|
primaryKeys
|
|
@@ -7241,6 +7598,32 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7241
7598
|
})]
|
|
7242
7599
|
});
|
|
7243
7600
|
}, [chartOptions.tooltip, dataSorted]);
|
|
7601
|
+
const renderStackedTooltip = (0, react.useCallback)(({ tooltipData }) => {
|
|
7602
|
+
const nearestDatum = tooltipData?.nearestDatum?.datum;
|
|
7603
|
+
if (!nearestDatum || barSlots?.kind !== "stacked") return null;
|
|
7604
|
+
const datumByKey = tooltipData?.datumByKey ?? {};
|
|
7605
|
+
const categoryLabel = chartOptions.tooltip.labelFormatter(nearestDatum.label || (nearestDatum.date ? nearestDatum.date.getTime() : 0), 0, []);
|
|
7606
|
+
const rows = [...barSlots.entries].reverse().flatMap(({ series }) => {
|
|
7607
|
+
const datum = datumByKey[series.label]?.datum;
|
|
7608
|
+
return datum ? [{
|
|
7609
|
+
label: series.label,
|
|
7610
|
+
datum
|
|
7611
|
+
}] : [];
|
|
7612
|
+
});
|
|
7613
|
+
const readings = rows.filter(({ datum }) => isBarRendered(datum)).length;
|
|
7614
|
+
const [negative, positive] = barSlots.stack.extentAt(nearestDatum);
|
|
7615
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
7616
|
+
className: bar_chart_module_default["bar-chart__tooltip"],
|
|
7617
|
+
children: [
|
|
7618
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
7619
|
+
className: bar_chart_module_default["bar-chart__tooltip-header"],
|
|
7620
|
+
children: categoryLabel
|
|
7621
|
+
}),
|
|
7622
|
+
rows.map(({ label, datum }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderTooltipRow(label, formatReading(datum.value)) }, label)),
|
|
7623
|
+
readings > 1 && renderTooltipRow((0, _wordpress_i18n.__)("Total", "jetpack-charts"), formatReading(negative + positive))
|
|
7624
|
+
]
|
|
7625
|
+
});
|
|
7626
|
+
}, [chartOptions.tooltip, barSlots]);
|
|
7244
7627
|
const renderDefaultTooltip = (0, react.useCallback)(({ tooltipData }) => {
|
|
7245
7628
|
const nearestDatum = tooltipData?.nearestDatum?.datum;
|
|
7246
7629
|
if (!nearestDatum) return null;
|
|
@@ -7312,24 +7695,25 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7312
7695
|
}
|
|
7313
7696
|
`;
|
|
7314
7697
|
}, [chartId]);
|
|
7315
|
-
const
|
|
7316
|
-
keys:
|
|
7317
|
-
slotOf:
|
|
7318
|
-
|
|
7319
|
-
|
|
7698
|
+
const barBandSlots = (0, react.useMemo)(() => barSlots && {
|
|
7699
|
+
keys: barSlots.slotKeys,
|
|
7700
|
+
slotOf: barSlots.slotOf,
|
|
7701
|
+
stack: barSlots.kind === "stacked" ? barSlots.stack : void 0
|
|
7702
|
+
}, [barSlots]);
|
|
7703
|
+
const selectedSlot = (0, react.useMemo)(() => getSelectedSlot(barSlots, selectedIndex), [barSlots, selectedIndex]);
|
|
7320
7704
|
const selectedGroup = (0, react.useMemo)(() => {
|
|
7321
|
-
const stop =
|
|
7705
|
+
const stop = barSlots || selectedIndex === void 0 ? void 0 : barAt(selectedIndex);
|
|
7322
7706
|
if (!stop) return;
|
|
7323
7707
|
return membersAt(primaryEntries, stop.datum, stop.key);
|
|
7324
7708
|
}, [
|
|
7325
|
-
|
|
7709
|
+
barSlots,
|
|
7326
7710
|
selectedIndex,
|
|
7327
7711
|
barAt,
|
|
7328
7712
|
primaryEntries
|
|
7329
7713
|
]);
|
|
7330
7714
|
const selectedMembers = selectedSlot?.members ?? selectedGroup;
|
|
7331
7715
|
const selectedBar = (0, react.useMemo)(() => {
|
|
7332
|
-
if (
|
|
7716
|
+
if (barSlots) return selectedSlot;
|
|
7333
7717
|
const bar = selectedIndex === void 0 ? void 0 : barAt(selectedIndex);
|
|
7334
7718
|
return bar && isBarRendered(bar.datum) ? {
|
|
7335
7719
|
data: [bar.datum],
|
|
@@ -7337,7 +7721,7 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7337
7721
|
thickness: 1
|
|
7338
7722
|
} : void 0;
|
|
7339
7723
|
}, [
|
|
7340
|
-
|
|
7724
|
+
barSlots,
|
|
7341
7725
|
selectedSlot,
|
|
7342
7726
|
selectedIndex,
|
|
7343
7727
|
barAt
|
|
@@ -7360,9 +7744,9 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7360
7744
|
className: (0, clsx.default)("bar-chart", bar_chart_module_default["bar-chart"]),
|
|
7361
7745
|
children: error
|
|
7362
7746
|
});
|
|
7363
|
-
const gridVisibility = gridVisibilityProp ?? chartOptions.gridVisibility;
|
|
7747
|
+
const gridVisibility = isCompact ? "none" : gridVisibilityProp ?? chartOptions.gridVisibility;
|
|
7364
7748
|
const legendPosition = legend.position ?? "bottom";
|
|
7365
|
-
const legendElement = showLegend && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Legend, {
|
|
7749
|
+
const legendElement = showLegend && !isCompact && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Legend, {
|
|
7366
7750
|
orientation: legend.orientation ?? "horizontal",
|
|
7367
7751
|
position: legendPosition,
|
|
7368
7752
|
alignment: legend.alignment ?? "center",
|
|
@@ -7385,9 +7769,12 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7385
7769
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChartLayout, {
|
|
7386
7770
|
legendPosition,
|
|
7387
7771
|
legendElement,
|
|
7388
|
-
legendChildren,
|
|
7772
|
+
legendChildren: isCompact ? [] : legendChildren,
|
|
7389
7773
|
gap,
|
|
7390
|
-
className: (0, clsx.default)("bar-chart", bar_chart_module_default["bar-chart"], {
|
|
7774
|
+
className: (0, clsx.default)("bar-chart", bar_chart_module_default["bar-chart"], {
|
|
7775
|
+
[bar_chart_module_default["bar-chart--stacked"]]: isStacked,
|
|
7776
|
+
[bar_chart_module_default[`bar-chart--animated${horizontal ? "-horizontal" : ""}`]]: animation && !prefersReducedMotion
|
|
7777
|
+
}, className),
|
|
7391
7778
|
style: {
|
|
7392
7779
|
width,
|
|
7393
7780
|
height
|
|
@@ -7414,6 +7801,7 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7414
7801
|
height: chartHeight,
|
|
7415
7802
|
margin: {
|
|
7416
7803
|
...defaultMargin,
|
|
7804
|
+
...compactMargin,
|
|
7417
7805
|
...margin
|
|
7418
7806
|
},
|
|
7419
7807
|
xScale,
|
|
@@ -7426,8 +7814,8 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7426
7814
|
horizontal,
|
|
7427
7815
|
onChange: onBandHighlightChange
|
|
7428
7816
|
}),
|
|
7429
|
-
!allSeriesHidden && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
7430
|
-
...
|
|
7817
|
+
!allSeriesHidden && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TickDecimals, {
|
|
7818
|
+
...tickDecimalsProps,
|
|
7431
7819
|
children: (valueTicks) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_visx_xychart.Grid, {
|
|
7432
7820
|
columns: gridVisibility.includes("y"),
|
|
7433
7821
|
rows: false,
|
|
@@ -7446,7 +7834,7 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7446
7834
|
y: chartHeight / 2,
|
|
7447
7835
|
width,
|
|
7448
7836
|
height: chartHeight,
|
|
7449
|
-
children: getAllHiddenMessage(legendInteractive, "series")
|
|
7837
|
+
children: getAllHiddenMessage(legendInteractive && !isCompact, "series")
|
|
7450
7838
|
}) : null,
|
|
7451
7839
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComparisonBars, {
|
|
7452
7840
|
comparisonEntries,
|
|
@@ -7460,7 +7848,7 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7460
7848
|
}),
|
|
7461
7849
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BarLayer, {
|
|
7462
7850
|
chartId,
|
|
7463
|
-
|
|
7851
|
+
barSlots,
|
|
7464
7852
|
selectedBar,
|
|
7465
7853
|
primaryEntries,
|
|
7466
7854
|
primaryKeys,
|
|
@@ -7472,16 +7860,16 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7472
7860
|
yAccessor: chartOptions.accessors.yAccessor
|
|
7473
7861
|
}),
|
|
7474
7862
|
(withTooltips || onPointerDown || onPointerUp) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BandTooltip, {
|
|
7475
|
-
keys:
|
|
7476
|
-
slots:
|
|
7863
|
+
keys: barSlots?.keys ?? primaryKeys,
|
|
7864
|
+
slots: barBandSlots,
|
|
7477
7865
|
groupPadding,
|
|
7478
7866
|
withTooltips,
|
|
7479
7867
|
onPointerDown,
|
|
7480
7868
|
onPointerUp,
|
|
7481
7869
|
onPointerMove: handlePointerMove
|
|
7482
7870
|
}),
|
|
7483
|
-
!allSeriesHidden && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
7484
|
-
...
|
|
7871
|
+
!allSeriesHidden && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TickDecimals, {
|
|
7872
|
+
...tickDecimalsProps,
|
|
7485
7873
|
children: (valueTicks) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [chartOptions.axis.x.display !== false && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_visx_xychart.Axis, {
|
|
7486
7874
|
...chartOptions.axis.x,
|
|
7487
7875
|
...horizontal && valueTicks ? { tickValues: valueTicks } : {}
|
|
@@ -7498,7 +7886,7 @@ const BarChartInternal = ({ data, ariaLabel, chartId: providedChartId, width, he
|
|
|
7498
7886
|
detectBounds: true,
|
|
7499
7887
|
snapTooltipToDatumX: true,
|
|
7500
7888
|
snapTooltipToDatumY: true,
|
|
7501
|
-
renderTooltip: renderTooltip || (isOverlap ? renderOverlapTooltip : renderDefaultTooltip),
|
|
7889
|
+
renderTooltip: renderTooltip || isStacked && renderStackedTooltip || (isOverlap ? renderOverlapTooltip : renderDefaultTooltip),
|
|
7502
7890
|
selectedIndex,
|
|
7503
7891
|
tooltipRef,
|
|
7504
7892
|
keyboardFocusedClassName: bar_chart_module_default["bar-chart__tooltip--keyboard-focused"],
|
|
@@ -9853,12 +10241,360 @@ function isPlainObject(o) {
|
|
|
9853
10241
|
if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
|
|
9854
10242
|
return true;
|
|
9855
10243
|
}
|
|
9856
|
-
// ../../../node_modules/.pnpm
|
|
9857
|
-
var
|
|
9858
|
-
|
|
10244
|
+
// ../../../node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist/index.js
|
|
10245
|
+
var require_dist$14 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10246
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10247
|
+
exports.lowerCase = exports.localeLowerCase = void 0;
|
|
10248
|
+
/**
|
|
10249
|
+
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
|
|
10250
|
+
*/
|
|
10251
|
+
var SUPPORTED_LOCALE = {
|
|
10252
|
+
tr: {
|
|
10253
|
+
regexp: /\u0130|\u0049|\u0049\u0307/g,
|
|
10254
|
+
map: {
|
|
10255
|
+
İ: "i",
|
|
10256
|
+
I: "ı",
|
|
10257
|
+
İ: "i"
|
|
10258
|
+
}
|
|
10259
|
+
},
|
|
10260
|
+
az: {
|
|
10261
|
+
regexp: /\u0130/g,
|
|
10262
|
+
map: {
|
|
10263
|
+
İ: "i",
|
|
10264
|
+
I: "ı",
|
|
10265
|
+
İ: "i"
|
|
10266
|
+
}
|
|
10267
|
+
},
|
|
10268
|
+
lt: {
|
|
10269
|
+
regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
|
|
10270
|
+
map: {
|
|
10271
|
+
I: "i̇",
|
|
10272
|
+
J: "j̇",
|
|
10273
|
+
Į: "į̇",
|
|
10274
|
+
Ì: "i̇̀",
|
|
10275
|
+
Í: "i̇́",
|
|
10276
|
+
Ĩ: "i̇̃"
|
|
10277
|
+
}
|
|
10278
|
+
}
|
|
10279
|
+
};
|
|
10280
|
+
/**
|
|
10281
|
+
* Localized lower case.
|
|
10282
|
+
*/
|
|
10283
|
+
function localeLowerCase(str, locale) {
|
|
10284
|
+
var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
|
|
10285
|
+
if (lang) return lowerCase(str.replace(lang.regexp, function(m) {
|
|
10286
|
+
return lang.map[m];
|
|
10287
|
+
}));
|
|
10288
|
+
return lowerCase(str);
|
|
10289
|
+
}
|
|
10290
|
+
exports.localeLowerCase = localeLowerCase;
|
|
10291
|
+
/**
|
|
10292
|
+
* Lower case as a function.
|
|
10293
|
+
*/
|
|
10294
|
+
function lowerCase(str) {
|
|
10295
|
+
return str.toLowerCase();
|
|
10296
|
+
}
|
|
10297
|
+
exports.lowerCase = lowerCase;
|
|
10298
|
+
}));
|
|
10299
|
+
// ../../../node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist/index.js
|
|
10300
|
+
var require_dist$13 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10301
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10302
|
+
exports.noCase = void 0;
|
|
10303
|
+
var lower_case_1 = require_dist$14();
|
|
10304
|
+
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
10305
|
+
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
10306
|
+
/**
|
|
10307
|
+
* Normalize the string into something other libraries can manipulate easier.
|
|
10308
|
+
*/
|
|
10309
|
+
function noCase(input, options) {
|
|
10310
|
+
if (options === void 0) options = {};
|
|
10311
|
+
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lower_case_1.lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
|
|
10312
|
+
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
|
10313
|
+
var start = 0;
|
|
10314
|
+
var end = result.length;
|
|
10315
|
+
while (result.charAt(start) === "\0") start++;
|
|
10316
|
+
while (result.charAt(end - 1) === "\0") end--;
|
|
10317
|
+
return result.slice(start, end).split("\0").map(transform).join(delimiter);
|
|
10318
|
+
}
|
|
10319
|
+
exports.noCase = noCase;
|
|
10320
|
+
/**
|
|
10321
|
+
* Replace `re` in the input string with the replacement value.
|
|
10322
|
+
*/
|
|
10323
|
+
function replace(input, re, value) {
|
|
10324
|
+
if (re instanceof RegExp) return input.replace(re, value);
|
|
10325
|
+
return re.reduce(function(input, re) {
|
|
10326
|
+
return input.replace(re, value);
|
|
10327
|
+
}, input);
|
|
10328
|
+
}
|
|
10329
|
+
}));
|
|
10330
|
+
// ../../../node_modules/.pnpm/pascal-case@3.1.2/node_modules/pascal-case/dist/index.js
|
|
10331
|
+
var require_dist$12 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10332
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10333
|
+
exports.pascalCase = exports.pascalCaseTransformMerge = exports.pascalCaseTransform = void 0;
|
|
10334
|
+
var tslib_1 = require("tslib");
|
|
10335
|
+
var no_case_1 = require_dist$13();
|
|
10336
|
+
function pascalCaseTransform(input, index) {
|
|
10337
|
+
var firstChar = input.charAt(0);
|
|
10338
|
+
var lowerChars = input.substr(1).toLowerCase();
|
|
10339
|
+
if (index > 0 && firstChar >= "0" && firstChar <= "9") return "_" + firstChar + lowerChars;
|
|
10340
|
+
return "" + firstChar.toUpperCase() + lowerChars;
|
|
10341
|
+
}
|
|
10342
|
+
exports.pascalCaseTransform = pascalCaseTransform;
|
|
10343
|
+
function pascalCaseTransformMerge(input) {
|
|
10344
|
+
return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
|
|
10345
|
+
}
|
|
10346
|
+
exports.pascalCaseTransformMerge = pascalCaseTransformMerge;
|
|
10347
|
+
function pascalCase(input, options) {
|
|
10348
|
+
if (options === void 0) options = {};
|
|
10349
|
+
return no_case_1.noCase(input, tslib_1.__assign({
|
|
10350
|
+
delimiter: "",
|
|
10351
|
+
transform: pascalCaseTransform
|
|
10352
|
+
}, options));
|
|
10353
|
+
}
|
|
10354
|
+
exports.pascalCase = pascalCase;
|
|
10355
|
+
}));
|
|
10356
|
+
// ../../../node_modules/.pnpm/camel-case@4.1.2/node_modules/camel-case/dist/index.js
|
|
10357
|
+
var require_dist$11 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10358
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10359
|
+
exports.camelCase = exports.camelCaseTransformMerge = exports.camelCaseTransform = void 0;
|
|
10360
|
+
var tslib_1 = require("tslib");
|
|
10361
|
+
var pascal_case_1 = require_dist$12();
|
|
10362
|
+
function camelCaseTransform(input, index) {
|
|
10363
|
+
if (index === 0) return input.toLowerCase();
|
|
10364
|
+
return pascal_case_1.pascalCaseTransform(input, index);
|
|
10365
|
+
}
|
|
10366
|
+
exports.camelCaseTransform = camelCaseTransform;
|
|
10367
|
+
function camelCaseTransformMerge(input, index) {
|
|
10368
|
+
if (index === 0) return input.toLowerCase();
|
|
10369
|
+
return pascal_case_1.pascalCaseTransformMerge(input);
|
|
10370
|
+
}
|
|
10371
|
+
exports.camelCaseTransformMerge = camelCaseTransformMerge;
|
|
10372
|
+
function camelCase(input, options) {
|
|
10373
|
+
if (options === void 0) options = {};
|
|
10374
|
+
return pascal_case_1.pascalCase(input, tslib_1.__assign({ transform: camelCaseTransform }, options));
|
|
10375
|
+
}
|
|
10376
|
+
exports.camelCase = camelCase;
|
|
10377
|
+
}));
|
|
10378
|
+
// ../../../node_modules/.pnpm/upper-case-first@2.0.2/node_modules/upper-case-first/dist/index.js
|
|
10379
|
+
var require_dist$10 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10380
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10381
|
+
exports.upperCaseFirst = void 0;
|
|
10382
|
+
/**
|
|
10383
|
+
* Upper case the first character of an input string.
|
|
10384
|
+
*/
|
|
10385
|
+
function upperCaseFirst(input) {
|
|
10386
|
+
return input.charAt(0).toUpperCase() + input.substr(1);
|
|
10387
|
+
}
|
|
10388
|
+
exports.upperCaseFirst = upperCaseFirst;
|
|
10389
|
+
}));
|
|
10390
|
+
// ../../../node_modules/.pnpm/capital-case@1.0.4/node_modules/capital-case/dist/index.js
|
|
10391
|
+
var require_dist$9 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10392
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10393
|
+
exports.capitalCase = exports.capitalCaseTransform = void 0;
|
|
10394
|
+
var tslib_1 = require("tslib");
|
|
10395
|
+
var no_case_1 = require_dist$13();
|
|
10396
|
+
var upper_case_first_1 = require_dist$10();
|
|
10397
|
+
function capitalCaseTransform(input) {
|
|
10398
|
+
return upper_case_first_1.upperCaseFirst(input.toLowerCase());
|
|
10399
|
+
}
|
|
10400
|
+
exports.capitalCaseTransform = capitalCaseTransform;
|
|
10401
|
+
function capitalCase(input, options) {
|
|
10402
|
+
if (options === void 0) options = {};
|
|
10403
|
+
return no_case_1.noCase(input, tslib_1.__assign({
|
|
10404
|
+
delimiter: " ",
|
|
10405
|
+
transform: capitalCaseTransform
|
|
10406
|
+
}, options));
|
|
10407
|
+
}
|
|
10408
|
+
exports.capitalCase = capitalCase;
|
|
10409
|
+
}));
|
|
10410
|
+
// ../../../node_modules/.pnpm/upper-case@2.0.2/node_modules/upper-case/dist/index.js
|
|
10411
|
+
var require_dist$8 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10412
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10413
|
+
exports.upperCase = exports.localeUpperCase = void 0;
|
|
10414
|
+
/**
|
|
10415
|
+
* Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
|
|
10416
|
+
*/
|
|
10417
|
+
var SUPPORTED_LOCALE = {
|
|
10418
|
+
tr: {
|
|
10419
|
+
regexp: /[\u0069]/g,
|
|
10420
|
+
map: { i: "İ" }
|
|
10421
|
+
},
|
|
10422
|
+
az: {
|
|
10423
|
+
regexp: /[\u0069]/g,
|
|
10424
|
+
map: { i: "İ" }
|
|
10425
|
+
},
|
|
10426
|
+
lt: {
|
|
10427
|
+
regexp: /[\u0069\u006A\u012F]\u0307|\u0069\u0307[\u0300\u0301\u0303]/g,
|
|
10428
|
+
map: {
|
|
10429
|
+
i̇: "I",
|
|
10430
|
+
j̇: "J",
|
|
10431
|
+
į̇: "Į",
|
|
10432
|
+
i̇̀: "Ì",
|
|
10433
|
+
i̇́: "Í",
|
|
10434
|
+
i̇̃: "Ĩ"
|
|
10435
|
+
}
|
|
10436
|
+
}
|
|
10437
|
+
};
|
|
10438
|
+
/**
|
|
10439
|
+
* Localized upper case.
|
|
10440
|
+
*/
|
|
10441
|
+
function localeUpperCase(str, locale) {
|
|
10442
|
+
var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
|
|
10443
|
+
if (lang) return upperCase(str.replace(lang.regexp, function(m) {
|
|
10444
|
+
return lang.map[m];
|
|
10445
|
+
}));
|
|
10446
|
+
return upperCase(str);
|
|
10447
|
+
}
|
|
10448
|
+
exports.localeUpperCase = localeUpperCase;
|
|
10449
|
+
/**
|
|
10450
|
+
* Upper case as a function.
|
|
10451
|
+
*/
|
|
10452
|
+
function upperCase(str) {
|
|
10453
|
+
return str.toUpperCase();
|
|
10454
|
+
}
|
|
10455
|
+
exports.upperCase = upperCase;
|
|
10456
|
+
}));
|
|
10457
|
+
// ../../../node_modules/.pnpm/constant-case@3.0.4/node_modules/constant-case/dist/index.js
|
|
10458
|
+
var require_dist$7 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10459
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10460
|
+
exports.constantCase = void 0;
|
|
10461
|
+
var tslib_1 = require("tslib");
|
|
10462
|
+
var no_case_1 = require_dist$13();
|
|
10463
|
+
var upper_case_1 = require_dist$8();
|
|
10464
|
+
function constantCase(input, options) {
|
|
10465
|
+
if (options === void 0) options = {};
|
|
10466
|
+
return no_case_1.noCase(input, tslib_1.__assign({
|
|
10467
|
+
delimiter: "_",
|
|
10468
|
+
transform: upper_case_1.upperCase
|
|
10469
|
+
}, options));
|
|
10470
|
+
}
|
|
10471
|
+
exports.constantCase = constantCase;
|
|
10472
|
+
}));
|
|
10473
|
+
// ../../../node_modules/.pnpm/dot-case@3.0.4/node_modules/dot-case/dist/index.js
|
|
10474
|
+
var require_dist$6 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10475
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10476
|
+
exports.dotCase = void 0;
|
|
10477
|
+
var tslib_1 = require("tslib");
|
|
10478
|
+
var no_case_1 = require_dist$13();
|
|
10479
|
+
function dotCase(input, options) {
|
|
10480
|
+
if (options === void 0) options = {};
|
|
10481
|
+
return no_case_1.noCase(input, tslib_1.__assign({ delimiter: "." }, options));
|
|
10482
|
+
}
|
|
10483
|
+
exports.dotCase = dotCase;
|
|
10484
|
+
}));
|
|
10485
|
+
// ../../../node_modules/.pnpm/header-case@2.0.4/node_modules/header-case/dist/index.js
|
|
10486
|
+
var require_dist$5 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10487
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10488
|
+
exports.headerCase = void 0;
|
|
10489
|
+
var tslib_1 = require("tslib");
|
|
10490
|
+
var capital_case_1 = require_dist$9();
|
|
10491
|
+
function headerCase(input, options) {
|
|
10492
|
+
if (options === void 0) options = {};
|
|
10493
|
+
return capital_case_1.capitalCase(input, tslib_1.__assign({ delimiter: "-" }, options));
|
|
10494
|
+
}
|
|
10495
|
+
exports.headerCase = headerCase;
|
|
10496
|
+
}));
|
|
10497
|
+
// ../../../node_modules/.pnpm/param-case@3.0.4/node_modules/param-case/dist/index.js
|
|
10498
|
+
var require_dist$4 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10499
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10500
|
+
exports.paramCase = void 0;
|
|
10501
|
+
var tslib_1 = require("tslib");
|
|
10502
|
+
var dot_case_1 = require_dist$6();
|
|
10503
|
+
function paramCase(input, options) {
|
|
10504
|
+
if (options === void 0) options = {};
|
|
10505
|
+
return dot_case_1.dotCase(input, tslib_1.__assign({ delimiter: "-" }, options));
|
|
10506
|
+
}
|
|
10507
|
+
exports.paramCase = paramCase;
|
|
10508
|
+
}));
|
|
10509
|
+
// ../../../node_modules/.pnpm/path-case@3.0.4/node_modules/path-case/dist/index.js
|
|
10510
|
+
var require_dist$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10511
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10512
|
+
exports.pathCase = void 0;
|
|
10513
|
+
var tslib_1 = require("tslib");
|
|
10514
|
+
var dot_case_1 = require_dist$6();
|
|
10515
|
+
function pathCase(input, options) {
|
|
10516
|
+
if (options === void 0) options = {};
|
|
10517
|
+
return dot_case_1.dotCase(input, tslib_1.__assign({ delimiter: "/" }, options));
|
|
10518
|
+
}
|
|
10519
|
+
exports.pathCase = pathCase;
|
|
10520
|
+
}));
|
|
10521
|
+
// ../../../node_modules/.pnpm/sentence-case@3.0.4/node_modules/sentence-case/dist/index.js
|
|
10522
|
+
var require_dist$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10523
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10524
|
+
exports.sentenceCase = exports.sentenceCaseTransform = void 0;
|
|
10525
|
+
var tslib_1 = require("tslib");
|
|
10526
|
+
var no_case_1 = require_dist$13();
|
|
10527
|
+
var upper_case_first_1 = require_dist$10();
|
|
10528
|
+
function sentenceCaseTransform(input, index) {
|
|
10529
|
+
var result = input.toLowerCase();
|
|
10530
|
+
if (index === 0) return upper_case_first_1.upperCaseFirst(result);
|
|
10531
|
+
return result;
|
|
10532
|
+
}
|
|
10533
|
+
exports.sentenceCaseTransform = sentenceCaseTransform;
|
|
10534
|
+
function sentenceCase(input, options) {
|
|
10535
|
+
if (options === void 0) options = {};
|
|
10536
|
+
return no_case_1.noCase(input, tslib_1.__assign({
|
|
10537
|
+
delimiter: " ",
|
|
10538
|
+
transform: sentenceCaseTransform
|
|
10539
|
+
}, options));
|
|
10540
|
+
}
|
|
10541
|
+
exports.sentenceCase = sentenceCase;
|
|
10542
|
+
}));
|
|
10543
|
+
// ../../../node_modules/.pnpm/snake-case@3.0.4/node_modules/snake-case/dist/index.js
|
|
10544
|
+
var require_dist$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10545
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10546
|
+
exports.snakeCase = void 0;
|
|
10547
|
+
var tslib_1 = require("tslib");
|
|
10548
|
+
var dot_case_1 = require_dist$6();
|
|
10549
|
+
function snakeCase(input, options) {
|
|
10550
|
+
if (options === void 0) options = {};
|
|
10551
|
+
return dot_case_1.dotCase(input, tslib_1.__assign({ delimiter: "_" }, options));
|
|
10552
|
+
}
|
|
10553
|
+
exports.snakeCase = snakeCase;
|
|
10554
|
+
}));
|
|
10555
|
+
// ../../../node_modules/.pnpm/change-case@4.1.2/node_modules/change-case/dist/index.js
|
|
10556
|
+
var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10557
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10558
|
+
var tslib_1 = require("tslib");
|
|
10559
|
+
tslib_1.__exportStar(require_dist$11(), exports);
|
|
10560
|
+
tslib_1.__exportStar(require_dist$9(), exports);
|
|
10561
|
+
tslib_1.__exportStar(require_dist$7(), exports);
|
|
10562
|
+
tslib_1.__exportStar(require_dist$6(), exports);
|
|
10563
|
+
tslib_1.__exportStar(require_dist$5(), exports);
|
|
10564
|
+
tslib_1.__exportStar(require_dist$13(), exports);
|
|
10565
|
+
tslib_1.__exportStar(require_dist$4(), exports);
|
|
10566
|
+
tslib_1.__exportStar(require_dist$12(), exports);
|
|
10567
|
+
tslib_1.__exportStar(require_dist$3(), exports);
|
|
10568
|
+
tslib_1.__exportStar(require_dist$2(), exports);
|
|
10569
|
+
tslib_1.__exportStar(require_dist$1(), exports);
|
|
10570
|
+
}));
|
|
10571
|
+
// ../../../node_modules/.pnpm/@wordpress+warning@4.1.0/node_modules/@wordpress/warning/build-module/utils.mjs
|
|
10572
|
+
/**
|
|
10573
|
+
* Object map tracking messages which have been logged, for use in ensuring a
|
|
10574
|
+
* message is only logged once.
|
|
10575
|
+
*/
|
|
10576
|
+
const logged = /* @__PURE__ */ new Set();
|
|
10577
|
+
// ../../../node_modules/.pnpm/@wordpress+warning@4.1.0/node_modules/@wordpress/warning/build-module/index.mjs
|
|
9859
10578
|
function isDev() {
|
|
9860
10579
|
return globalThis.SCRIPT_DEBUG === true;
|
|
9861
10580
|
}
|
|
10581
|
+
/**
|
|
10582
|
+
* Shows a warning with `message` if environment is not `production`.
|
|
10583
|
+
*
|
|
10584
|
+
* @param message Message to show in the warning.
|
|
10585
|
+
*
|
|
10586
|
+
* @example
|
|
10587
|
+
* ```js
|
|
10588
|
+
* import warning from '@wordpress/warning';
|
|
10589
|
+
*
|
|
10590
|
+
* function MyComponent( props ) {
|
|
10591
|
+
* if ( ! props.title ) {
|
|
10592
|
+
* warning( '`props.title` was not passed' );
|
|
10593
|
+
* }
|
|
10594
|
+
* ...
|
|
10595
|
+
* }
|
|
10596
|
+
* ```
|
|
10597
|
+
*/
|
|
9862
10598
|
function warning(message) {
|
|
9863
10599
|
if (!isDev()) return;
|
|
9864
10600
|
if (logged.has(message)) return;
|
|
@@ -9914,7 +10650,15 @@ var require_es6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9914
10650
|
return a !== a && b !== b;
|
|
9915
10651
|
};
|
|
9916
10652
|
}));
|
|
9917
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10653
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/utils/hooks/use-update-effect.mjs
|
|
10654
|
+
/**
|
|
10655
|
+
* A `React.useEffect` that will not run on the first render.
|
|
10656
|
+
* Source:
|
|
10657
|
+
* https://github.com/ariakit/ariakit/blob/main/packages/ariakit-react-core/src/utils/hooks.ts
|
|
10658
|
+
*
|
|
10659
|
+
* @param effect
|
|
10660
|
+
* @param deps
|
|
10661
|
+
*/
|
|
9918
10662
|
function useUpdateEffect(effect, deps) {
|
|
9919
10663
|
const mountedRef = (0, react.useRef)(false);
|
|
9920
10664
|
(0, react.useEffect)(() => {
|
|
@@ -9925,23 +10669,48 @@ function useUpdateEffect(effect, deps) {
|
|
|
9925
10669
|
mountedRef.current = false;
|
|
9926
10670
|
}, []);
|
|
9927
10671
|
}
|
|
9928
|
-
|
|
9929
|
-
// ../../../node_modules/.pnpm/@wordpress+components@43.0.0_@date-fns+tz@1.5.0_@types+react-dom@19.3.0_@types+react@19_401cb4bad47bd1f7b56615ff574f0485/node_modules/@wordpress/components/build-module/context/context-system-provider.mjs
|
|
10672
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/context/context-system-provider.mjs
|
|
9930
10673
|
var import_es6 = /* @__PURE__ */ __toESM(require_es6(), 1);
|
|
9931
|
-
|
|
10674
|
+
const ComponentsContext = (0, react.createContext)({});
|
|
9932
10675
|
ComponentsContext.displayName = "ComponentsContext";
|
|
9933
|
-
|
|
10676
|
+
const useComponentsContext = () => (0, react.useContext)(ComponentsContext);
|
|
10677
|
+
/**
|
|
10678
|
+
* Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.
|
|
10679
|
+
*
|
|
10680
|
+
* Note: This function will warn if it detects an un-memoized `value`
|
|
10681
|
+
*
|
|
10682
|
+
* @param {Object} props
|
|
10683
|
+
* @param {Record<string, any>} props.value
|
|
10684
|
+
* @return {Record<string, any>} The consolidated value.
|
|
10685
|
+
*/
|
|
9934
10686
|
function useContextSystemBridge({ value }) {
|
|
9935
10687
|
const parentContext = useComponentsContext();
|
|
9936
10688
|
const valueRef = (0, react.useRef)(value);
|
|
9937
|
-
|
|
10689
|
+
useUpdateEffect(() => {
|
|
9938
10690
|
if ((0, import_es6.default)(valueRef.current, value) && valueRef.current !== value) warning(`Please memoize your context: ${JSON.stringify(value)}`);
|
|
9939
10691
|
}, [value]);
|
|
9940
10692
|
return (0, react.useMemo)(() => {
|
|
9941
10693
|
return (0, deepmerge.default)(parentContext ?? {}, value ?? {}, { isMergeableObject: isPlainObject });
|
|
9942
10694
|
}, [parentContext, value]);
|
|
9943
10695
|
}
|
|
9944
|
-
|
|
10696
|
+
/**
|
|
10697
|
+
* A Provider component that can modify props for connected components within
|
|
10698
|
+
* the Context system.
|
|
10699
|
+
*
|
|
10700
|
+
* @example
|
|
10701
|
+
* ```jsx
|
|
10702
|
+
* <ContextSystemProvider value={{ Button: { size: 'small' }}}>
|
|
10703
|
+
* <Button>...</Button>
|
|
10704
|
+
* </ContextSystemProvider>
|
|
10705
|
+
* ```
|
|
10706
|
+
*
|
|
10707
|
+
* @template {Record<string, any>} T
|
|
10708
|
+
* @param {Object} options
|
|
10709
|
+
* @param {React.ReactNode} options.children Children to render.
|
|
10710
|
+
* @param {T} options.value Props to render into connected components.
|
|
10711
|
+
* @return {React.JSX.Element} A Provider wrapped component.
|
|
10712
|
+
*/
|
|
10713
|
+
const BaseContextSystemProvider = ({ children, value }) => {
|
|
9945
10714
|
const contextValue = useContextSystemBridge({ value });
|
|
9946
10715
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentsContext.Provider, {
|
|
9947
10716
|
value: contextValue,
|
|
@@ -9949,10 +10718,14 @@ var BaseContextSystemProvider = ({ children, value }) => {
|
|
|
9949
10718
|
});
|
|
9950
10719
|
};
|
|
9951
10720
|
(0, react.memo)(BaseContextSystemProvider);
|
|
9952
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
10721
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/context/constants.mjs
|
|
10722
|
+
const COMPONENT_NAMESPACE = "data-wp-component";
|
|
10723
|
+
const CONNECTED_NAMESPACE = "data-wp-c16t";
|
|
10724
|
+
/**
|
|
10725
|
+
* Special key where the connected namespaces are stored.
|
|
10726
|
+
* This is attached to Context connected components as a static property.
|
|
10727
|
+
*/
|
|
10728
|
+
const CONNECT_STATIC_NAMESPACE = "__contextSystemKey__";
|
|
9956
10729
|
// ../../../node_modules/.pnpm/memize@2.1.1/node_modules/memize/dist/index.js
|
|
9957
10730
|
/**
|
|
9958
10731
|
* Memize options object.
|
|
@@ -10043,12 +10816,27 @@ function memize(fn, options) {
|
|
|
10043
10816
|
};
|
|
10044
10817
|
return memoized;
|
|
10045
10818
|
}
|
|
10046
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10819
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/context/get-styled-class-name-from-key.mjs
|
|
10820
|
+
var import_dist = require_dist();
|
|
10821
|
+
/**
|
|
10822
|
+
* Generates the connected component CSS className based on the namespace.
|
|
10823
|
+
*
|
|
10824
|
+
* @param namespace The name of the connected component.
|
|
10825
|
+
* @return The generated CSS className.
|
|
10826
|
+
*/
|
|
10047
10827
|
function getStyledClassName(namespace) {
|
|
10048
|
-
return `components-${
|
|
10828
|
+
return `components-${(0, import_dist.paramCase)(namespace)}`;
|
|
10049
10829
|
}
|
|
10050
|
-
|
|
10051
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10830
|
+
const getStyledClassNameFromKey = memize(getStyledClassName);
|
|
10831
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/context/context-connect.mjs
|
|
10832
|
+
/**
|
|
10833
|
+
* Forwards ref (React.ForwardRef) and "Connects" (or registers) a component
|
|
10834
|
+
* within the Context system under a specified namespace.
|
|
10835
|
+
*
|
|
10836
|
+
* @param Component The component to register into the Context system.
|
|
10837
|
+
* @param namespace The namespace to register the component under.
|
|
10838
|
+
* @return The connected WordPressComponent
|
|
10839
|
+
*/
|
|
10052
10840
|
function contextConnect(Component, namespace) {
|
|
10053
10841
|
return _contextConnect(Component, namespace, { forwardsRef: true });
|
|
10054
10842
|
}
|
|
@@ -10056,6 +10844,9 @@ function _contextConnect(Component, namespace, options) {
|
|
|
10056
10844
|
const WrappedComponent = options?.forwardsRef ? (0, react.forwardRef)(Component) : Component;
|
|
10057
10845
|
if (typeof namespace === "undefined") warning("contextConnect: Please provide a namespace");
|
|
10058
10846
|
let mergedNamespace = WrappedComponent["__contextSystemKey__"] || [namespace];
|
|
10847
|
+
/**
|
|
10848
|
+
* Consolidate (merge) namespaces before attaching it to the WrappedComponent.
|
|
10849
|
+
*/
|
|
10059
10850
|
if (Array.isArray(namespace)) mergedNamespace = [...mergedNamespace, ...namespace];
|
|
10060
10851
|
if (typeof namespace === "string") mergedNamespace = [...mergedNamespace, namespace];
|
|
10061
10852
|
return Object.assign(WrappedComponent, {
|
|
@@ -10064,14 +10855,45 @@ function _contextConnect(Component, namespace, options) {
|
|
|
10064
10855
|
selector: `.${getStyledClassNameFromKey(namespace)}`
|
|
10065
10856
|
});
|
|
10066
10857
|
}
|
|
10067
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10858
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/context/utils.mjs
|
|
10859
|
+
/**
|
|
10860
|
+
* Creates a dedicated context namespace HTML attribute for components.
|
|
10861
|
+
* ns is short for "namespace"
|
|
10862
|
+
*
|
|
10863
|
+
* @example
|
|
10864
|
+
* ```jsx
|
|
10865
|
+
* <div {...ns('Container')} />
|
|
10866
|
+
* ```
|
|
10867
|
+
*
|
|
10868
|
+
* @param componentName The name for the component.
|
|
10869
|
+
* @return A props object with the namespaced HTML attribute.
|
|
10870
|
+
*/
|
|
10068
10871
|
function getNamespace(componentName) {
|
|
10069
10872
|
return { [COMPONENT_NAMESPACE]: componentName };
|
|
10070
10873
|
}
|
|
10874
|
+
/**
|
|
10875
|
+
* Creates a dedicated connected context namespace HTML attribute for components.
|
|
10876
|
+
* ns is short for "namespace"
|
|
10877
|
+
*
|
|
10878
|
+
* @example
|
|
10879
|
+
* ```jsx
|
|
10880
|
+
* <div {...cns()} />
|
|
10881
|
+
* ```
|
|
10882
|
+
*
|
|
10883
|
+
* @return A props object with the namespaced HTML attribute.
|
|
10884
|
+
*/
|
|
10071
10885
|
function getConnectedNamespace() {
|
|
10072
10886
|
return { [CONNECTED_NAMESPACE]: true };
|
|
10073
10887
|
}
|
|
10074
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10888
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/context/use-context-system.mjs
|
|
10889
|
+
/**
|
|
10890
|
+
* Custom hook that derives registered props from the Context system.
|
|
10891
|
+
* These derived props are then consolidated with incoming component props.
|
|
10892
|
+
*
|
|
10893
|
+
* @param props Incoming props from the component.
|
|
10894
|
+
* @param namespace The namespace to register and to derive context props from.
|
|
10895
|
+
* @return The connected props.
|
|
10896
|
+
*/
|
|
10075
10897
|
function useContextSystem(props, namespace) {
|
|
10076
10898
|
const contextSystemProps = useComponentsContext();
|
|
10077
10899
|
if (typeof namespace === "undefined") warning("useContextSystem: Please provide a namespace");
|
|
@@ -10092,8 +10914,8 @@ function useContextSystem(props, namespace) {
|
|
|
10092
10914
|
finalComponentProps.className = classes;
|
|
10093
10915
|
return finalComponentProps;
|
|
10094
10916
|
}
|
|
10095
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10096
|
-
|
|
10917
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/visually-hidden/styles.mjs
|
|
10918
|
+
const visuallyHidden = {
|
|
10097
10919
|
border: 0,
|
|
10098
10920
|
clip: "rect(1px, 1px, 1px, 1px)",
|
|
10099
10921
|
WebkitClipPath: "inset( 50% )",
|
|
@@ -10107,10 +10929,10 @@ var visuallyHidden = {
|
|
|
10107
10929
|
wordWrap: "normal",
|
|
10108
10930
|
wordBreak: "normal"
|
|
10109
10931
|
};
|
|
10110
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10932
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/utils/polymorphic-element.mjs
|
|
10933
|
+
const customAttributeRegExp = /^(data|aria|x)-/i;
|
|
10934
|
+
const eventHandlerRegExp = /^on[A-Z]/;
|
|
10935
|
+
const svgElementNames = new Set(`animate animateMotion animateTransform circle clipPath defs desc ellipse
|
|
10114
10936
|
feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix
|
|
10115
10937
|
feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood
|
|
10116
10938
|
feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode
|
|
@@ -10118,7 +10940,7 @@ var svgElementNames = new Set(`animate animateMotion animateTransform circle cli
|
|
|
10118
10940
|
feTurbulence filter foreignObject g image line linearGradient marker mask
|
|
10119
10941
|
metadata mpath path pattern polygon polyline radialGradient rect set stop svg
|
|
10120
10942
|
switch symbol text textPath tspan use view`.split(/\s+/));
|
|
10121
|
-
|
|
10943
|
+
const baseElementProps = new Set(`children dangerouslySetInnerHTML key autoFocus defaultValue defaultChecked
|
|
10122
10944
|
innerHTML suppressContentEditableWarning suppressHydrationWarning valueLink
|
|
10123
10945
|
abbr accept acceptCharset accessKey action allow allowUserMedia
|
|
10124
10946
|
allowPaymentRequest allowFullScreen allowTransparency alt async autoComplete
|
|
@@ -10139,7 +10961,7 @@ var baseElementProps = new Set(`children dangerouslySetInnerHTML key autoFocus d
|
|
|
10139
10961
|
datatype inlist prefix property resource typeof vocab autoCapitalize
|
|
10140
10962
|
autoCorrect autoSave color incremental fallback inert itemProp itemScope
|
|
10141
10963
|
itemType itemID itemRef on option results security unselectable`.split(/\s+/));
|
|
10142
|
-
|
|
10964
|
+
const svgElementProps = new Set(`accentHeight accumulate additive alignmentBaseline allowReorder alphabetic
|
|
10143
10965
|
amplitude arabicForm ascent attributeName attributeType autoReverse azimuth
|
|
10144
10966
|
baseFrequency baselineShift baseProfile bbox begin bias by calcMode capHeight
|
|
10145
10967
|
clip clipPathUnits clipPath clipRule colorInterpolation
|
|
@@ -10174,7 +10996,7 @@ var svgElementProps = new Set(`accentHeight accumulate additive alignmentBaselin
|
|
|
10174
10996
|
xlinkActuate xlinkArcrole xlinkHref xlinkRole xlinkShow xlinkTitle xlinkType
|
|
10175
10997
|
xmlBase xmlns xmlnsXlink xmlLang xmlSpace y y1 y2 yChannelSelector z
|
|
10176
10998
|
zoomAndPan`.split(/\s+/));
|
|
10177
|
-
|
|
10999
|
+
const compatElementProps = /* @__PURE__ */ new Set([
|
|
10178
11000
|
"autofocus",
|
|
10179
11001
|
"class",
|
|
10180
11002
|
"for"
|
|
@@ -10195,19 +11017,39 @@ function UnforwardedPolymorphicElement({ as, ...props }, ref) {
|
|
|
10195
11017
|
...forwardedProps
|
|
10196
11018
|
});
|
|
10197
11019
|
}
|
|
10198
|
-
|
|
10199
|
-
|
|
11020
|
+
/**
|
|
11021
|
+
* Internal utility for components that need Emotion-compatible `as` behavior
|
|
11022
|
+
* while rendering with plain React elements.
|
|
11023
|
+
*/
|
|
11024
|
+
const PolymorphicElement = (0, react.forwardRef)(UnforwardedPolymorphicElement);
|
|
11025
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/view/component.mjs
|
|
10200
11026
|
function UnforwardedView({ css, ...restProps }, ref) {
|
|
10201
11027
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PolymorphicElement, {
|
|
10202
11028
|
ref,
|
|
10203
11029
|
...restProps
|
|
10204
11030
|
});
|
|
10205
11031
|
}
|
|
10206
|
-
|
|
10207
|
-
|
|
11032
|
+
/**
|
|
11033
|
+
* `View` is a core component that renders everything in the library.
|
|
11034
|
+
* It is the principle component in the entire library.
|
|
11035
|
+
*
|
|
11036
|
+
* ```jsx
|
|
11037
|
+
* import { View } from `@wordpress/components`;
|
|
11038
|
+
*
|
|
11039
|
+
* function Example() {
|
|
11040
|
+
* return (
|
|
11041
|
+
* <View>
|
|
11042
|
+
* Code is Poetry
|
|
11043
|
+
* </View>
|
|
11044
|
+
* );
|
|
11045
|
+
* }
|
|
11046
|
+
* ```
|
|
11047
|
+
*/
|
|
11048
|
+
const View = Object.assign((0, react.forwardRef)(UnforwardedView), { selector: ".components-view" });
|
|
11049
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/visually-hidden/component.mjs
|
|
10208
11050
|
function UnconnectedVisuallyHidden(props, forwardedRef) {
|
|
10209
11051
|
const { style: styleProp, ...contextProps } = useContextSystem(props, "VisuallyHidden");
|
|
10210
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11052
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
|
|
10211
11053
|
ref: forwardedRef,
|
|
10212
11054
|
...contextProps,
|
|
10213
11055
|
"data-visually-hidden": "",
|
|
@@ -10217,14 +11059,30 @@ function UnconnectedVisuallyHidden(props, forwardedRef) {
|
|
|
10217
11059
|
}
|
|
10218
11060
|
});
|
|
10219
11061
|
}
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
11062
|
+
/**
|
|
11063
|
+
* `VisuallyHidden` is a component used to render text intended to be visually
|
|
11064
|
+
* hidden, but will show for alternate devices, for example a screen reader.
|
|
11065
|
+
*
|
|
11066
|
+
* ```jsx
|
|
11067
|
+
* import { VisuallyHidden } from `@wordpress/components`;
|
|
11068
|
+
*
|
|
11069
|
+
* function Example() {
|
|
11070
|
+
* return (
|
|
11071
|
+
* <VisuallyHidden>
|
|
11072
|
+
* <label>Code is Poetry</label>
|
|
11073
|
+
* </VisuallyHidden>
|
|
11074
|
+
* );
|
|
11075
|
+
* }
|
|
11076
|
+
* ```
|
|
11077
|
+
*/
|
|
11078
|
+
const VisuallyHidden$1 = contextConnect(UnconnectedVisuallyHidden, "VisuallyHidden");
|
|
11079
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/utils/use-responsive-value.mjs
|
|
11080
|
+
const breakpoints = [
|
|
10223
11081
|
"40em",
|
|
10224
11082
|
"52em",
|
|
10225
11083
|
"64em"
|
|
10226
11084
|
];
|
|
10227
|
-
|
|
11085
|
+
const useBreakpointIndex = (options = {}) => {
|
|
10228
11086
|
const { defaultIndex = 0, enabled = true } = options;
|
|
10229
11087
|
if (typeof defaultIndex !== "number") throw new TypeError(`Default breakpoint index should be a number. Got: ${defaultIndex}, ${typeof defaultIndex}`);
|
|
10230
11088
|
else if (defaultIndex < 0 || defaultIndex > breakpoints.length - 1) throw new RangeError(`Default breakpoint index out of range. Theme has ${breakpoints.length} breakpoints, got index ${defaultIndex}`);
|
|
@@ -10256,8 +11114,8 @@ function useResponsiveValue(values, options = {}) {
|
|
|
10256
11114
|
const array = values || [];
|
|
10257
11115
|
return array[index >= array.length ? array.length - 1 : index];
|
|
10258
11116
|
}
|
|
10259
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10260
|
-
|
|
11117
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/grid/utils.mjs
|
|
11118
|
+
const ALIGNMENTS = {
|
|
10261
11119
|
bottom: {
|
|
10262
11120
|
alignItems: "flex-end",
|
|
10263
11121
|
justifyContent: "center"
|
|
@@ -10303,8 +11161,16 @@ var ALIGNMENTS = {
|
|
|
10303
11161
|
function getAlignmentProps(alignment) {
|
|
10304
11162
|
return alignment ? ALIGNMENTS[alignment] ?? {} : {};
|
|
10305
11163
|
}
|
|
10306
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
10307
|
-
|
|
11164
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/grid/hook.mjs
|
|
11165
|
+
const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
11166
|
+
/**
|
|
11167
|
+
* Returns the shared style runtime registry.
|
|
11168
|
+
*
|
|
11169
|
+
* The registry is stored on `globalThis` so separately bundled copies of this
|
|
11170
|
+
* package can coordinate through the same document and style maps.
|
|
11171
|
+
*
|
|
11172
|
+
* @return The shared runtime registry.
|
|
11173
|
+
*/
|
|
10308
11174
|
function getRuntime() {
|
|
10309
11175
|
const globalScope = globalThis;
|
|
10310
11176
|
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
@@ -10316,11 +11182,27 @@ function getRuntime() {
|
|
|
10316
11182
|
if (typeof document !== "undefined") registerDocument(document);
|
|
10317
11183
|
return globalScope.__wpStyleRuntime;
|
|
10318
11184
|
}
|
|
11185
|
+
/**
|
|
11186
|
+
* Checks whether a document already contains a style tag for a hash.
|
|
11187
|
+
*
|
|
11188
|
+
* @param targetDocument Document to inspect.
|
|
11189
|
+
* @param hash Stable hash for the transformed CSS.
|
|
11190
|
+
*
|
|
11191
|
+
* @return Whether the style hash already exists in the document.
|
|
11192
|
+
*/
|
|
10319
11193
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
10320
11194
|
if (!targetDocument.head) return false;
|
|
10321
11195
|
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
10322
11196
|
return false;
|
|
10323
11197
|
}
|
|
11198
|
+
/**
|
|
11199
|
+
* Injects a registered style into a document, unless that document already
|
|
11200
|
+
* contains a style tag for the same hash.
|
|
11201
|
+
*
|
|
11202
|
+
* @param targetDocument Document to inject the style into.
|
|
11203
|
+
* @param hash Stable hash for the transformed CSS.
|
|
11204
|
+
* @param css CSS text to inject.
|
|
11205
|
+
*/
|
|
10324
11206
|
function injectStyle(targetDocument, hash, css) {
|
|
10325
11207
|
if (!targetDocument.head) return;
|
|
10326
11208
|
const runtime = getRuntime();
|
|
@@ -10340,6 +11222,17 @@ function injectStyle(targetDocument, hash, css) {
|
|
|
10340
11222
|
targetDocument.head.appendChild(style);
|
|
10341
11223
|
injectedStyles.add(hash);
|
|
10342
11224
|
}
|
|
11225
|
+
/**
|
|
11226
|
+
* Registers a document as a style injection target.
|
|
11227
|
+
*
|
|
11228
|
+
* Existing registered styles are replayed into the document immediately.
|
|
11229
|
+
* Documents are reference-counted so multiple providers can safely register the
|
|
11230
|
+
* same document without one cleanup removing it while another registration is
|
|
11231
|
+
* still active.
|
|
11232
|
+
*
|
|
11233
|
+
* @param targetDocument Document to receive registered styles.
|
|
11234
|
+
* @return Cleanup function that unregisters this document registration.
|
|
11235
|
+
*/
|
|
10343
11236
|
function registerDocument(targetDocument) {
|
|
10344
11237
|
const runtime = getRuntime();
|
|
10345
11238
|
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
@@ -10354,51 +11247,62 @@ function registerDocument(targetDocument) {
|
|
|
10354
11247
|
runtime.documents.set(targetDocument, count - 1);
|
|
10355
11248
|
};
|
|
10356
11249
|
}
|
|
11250
|
+
/**
|
|
11251
|
+
* Registers a style and injects it into all registered documents.
|
|
11252
|
+
*
|
|
11253
|
+
* The hash is used as the deduplication key, so calling this repeatedly with
|
|
11254
|
+
* the same hash will not add duplicate style tags to a document.
|
|
11255
|
+
* Registered styles are retained for the lifetime of the page so they can be
|
|
11256
|
+
* replayed into documents that are registered later.
|
|
11257
|
+
*
|
|
11258
|
+
* @param hash Stable hash for the transformed CSS.
|
|
11259
|
+
* @param css CSS text to inject.
|
|
11260
|
+
*/
|
|
10357
11261
|
function registerStyle(hash, css) {
|
|
10358
11262
|
const runtime = getRuntime();
|
|
10359
11263
|
runtime.styles.set(hash, css);
|
|
10360
11264
|
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
10361
11265
|
}
|
|
10362
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("
|
|
11266
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("b1a8e206b7", ".ad3e2e48d7abbecd__grid{--wp-components-grid-align:initial;--wp-components-grid-justify:initial;--wp-components-grid-gap:initial;--wp-components-grid-template-columns:initial;--wp-components-grid-template-rows:initial;--wp-components-grid-row-gap:initial;--wp-components-grid-column-gap:initial;display:grid}.ad3e2e48d7abbecd__grid:not(:where(._519ed3f6107b2f0e__row-gap-inherit,.cd62b95f8b7a55ca__row-gap-initial,._226744df7703790b__row-gap-unset,._372e9fe7fa60a162__row-gap-revert,.a788bb6771f557d4__row-gap-revert-layer)){row-gap:var(--wp-components-grid-row-gap,calc(4px*var(--wp-components-grid-gap)))}.ad3e2e48d7abbecd__grid:not(:where(.c811e15146756906__column-gap-inherit,._17d3c2ea7daf9367__column-gap-initial,._595e6195481b9016__column-gap-unset,.a3ecb3e47731c19e__column-gap-revert,._7c87cfbf3c22f476__column-gap-revert-layer)){column-gap:var(--wp-components-grid-column-gap,calc(4px*var(--wp-components-grid-gap)))}._25a972dc3223dff3__has-align:not(:where(._3cda38ca04ad4eb9__align-inherit,.f1d7342c52a8cb04__align-initial,._0d1a6c7ee990f351__align-unset,._57c7b85e7abf618b__align-revert,._82cb0c4950962787__align-revert-layer)){align-items:var(--wp-components-grid-align)}._801d1214723237b8__has-justify:not(:where(.b83c5dbf3264515b__justify-inherit,._5b7394b39d69670e__justify-initial,._3e7f0418752602e5__justify-unset,._5f937df46d7b2259__justify-revert,.bf2a4718a1ddba5c__justify-revert-layer)){justify-content:var(--wp-components-grid-justify)}._3c6ac9820776f1cb__has-template-columns:not(:where(._35faa4d32eedef32__template-columns-inherit,._8150cadb3f438833__template-columns-initial,.bcd5f2b096dec164__template-columns-unset,._48d047bc6fb687b8__template-columns-revert,._93f250669aa1a5a7__template-columns-revert-layer)){grid-template-columns:var(--wp-components-grid-template-columns)}.c2703b6b15e69b82__has-template-rows:not(:where(._3e9d5ffc53e4afc0__template-rows-inherit,._64bb5fbdf6d1038a__template-rows-initial,.f8f5df7043222325__template-rows-unset,._408aaf58100e60d5__template-rows-revert,.e0730d6abf0f3d2a__template-rows-revert-layer)){grid-template-rows:var(--wp-components-grid-template-rows)}._43af1cbfad3e73dd__is-inline{display:inline-grid;vertical-align:middle}._3cda38ca04ad4eb9__align-inherit{align-items:inherit}.f1d7342c52a8cb04__align-initial{align-items:normal}._0d1a6c7ee990f351__align-unset{align-items:unset}._57c7b85e7abf618b__align-revert{align-items:revert}._82cb0c4950962787__align-revert-layer{align-items:revert-layer}.b83c5dbf3264515b__justify-inherit{justify-content:inherit}._5b7394b39d69670e__justify-initial{justify-content:normal}._3e7f0418752602e5__justify-unset{justify-content:unset}._5f937df46d7b2259__justify-revert{justify-content:revert}.bf2a4718a1ddba5c__justify-revert-layer{justify-content:revert-layer}._35faa4d32eedef32__template-columns-inherit{grid-template-columns:inherit}._8150cadb3f438833__template-columns-initial{grid-template-columns:none}.bcd5f2b096dec164__template-columns-unset{grid-template-columns:unset}._48d047bc6fb687b8__template-columns-revert{grid-template-columns:revert}._93f250669aa1a5a7__template-columns-revert-layer{grid-template-columns:revert-layer}._3e9d5ffc53e4afc0__template-rows-inherit{grid-template-rows:inherit}._64bb5fbdf6d1038a__template-rows-initial{grid-template-rows:none}.f8f5df7043222325__template-rows-unset{grid-template-rows:unset}._408aaf58100e60d5__template-rows-revert{grid-template-rows:revert}.e0730d6abf0f3d2a__template-rows-revert-layer{grid-template-rows:revert-layer}._519ed3f6107b2f0e__row-gap-inherit{row-gap:inherit}.cd62b95f8b7a55ca__row-gap-initial{row-gap:normal}._226744df7703790b__row-gap-unset{row-gap:unset}._372e9fe7fa60a162__row-gap-revert{row-gap:revert}.a788bb6771f557d4__row-gap-revert-layer{row-gap:revert-layer}.c811e15146756906__column-gap-inherit{column-gap:inherit}._17d3c2ea7daf9367__column-gap-initial{column-gap:normal}._595e6195481b9016__column-gap-unset{column-gap:unset}.a3ecb3e47731c19e__column-gap-revert{column-gap:revert}._7c87cfbf3c22f476__column-gap-revert-layer{column-gap:revert-layer}");
|
|
10363
11267
|
var style_module_default = {
|
|
10364
|
-
"grid": "
|
|
10365
|
-
"row-gap-inherit": "
|
|
10366
|
-
"row-gap-initial": "
|
|
10367
|
-
"row-gap-unset": "
|
|
10368
|
-
"row-gap-revert": "
|
|
10369
|
-
"row-gap-revert-layer": "
|
|
10370
|
-
"column-gap-inherit": "
|
|
10371
|
-
"column-gap-initial": "
|
|
10372
|
-
"column-gap-unset": "
|
|
10373
|
-
"column-gap-revert": "
|
|
10374
|
-
"column-gap-revert-layer": "
|
|
10375
|
-
"has-align": "
|
|
10376
|
-
"align-inherit": "
|
|
10377
|
-
"align-initial": "
|
|
10378
|
-
"align-unset": "
|
|
10379
|
-
"align-revert": "
|
|
10380
|
-
"align-revert-layer": "
|
|
10381
|
-
"has-justify": "
|
|
10382
|
-
"justify-inherit": "
|
|
10383
|
-
"justify-initial": "
|
|
10384
|
-
"justify-unset": "
|
|
10385
|
-
"justify-revert": "
|
|
10386
|
-
"justify-revert-layer": "
|
|
10387
|
-
"has-template-columns": "
|
|
10388
|
-
"template-columns-inherit": "
|
|
10389
|
-
"template-columns-initial": "
|
|
10390
|
-
"template-columns-unset": "
|
|
10391
|
-
"template-columns-revert": "
|
|
10392
|
-
"template-columns-revert-layer": "
|
|
10393
|
-
"has-template-rows": "
|
|
10394
|
-
"template-rows-inherit": "
|
|
10395
|
-
"template-rows-initial": "
|
|
10396
|
-
"template-rows-unset": "
|
|
10397
|
-
"template-rows-revert": "
|
|
10398
|
-
"template-rows-revert-layer": "
|
|
10399
|
-
"is-inline": "
|
|
10400
|
-
};
|
|
10401
|
-
|
|
11268
|
+
"grid": "ad3e2e48d7abbecd__grid",
|
|
11269
|
+
"row-gap-inherit": "_519ed3f6107b2f0e__row-gap-inherit",
|
|
11270
|
+
"row-gap-initial": "cd62b95f8b7a55ca__row-gap-initial",
|
|
11271
|
+
"row-gap-unset": "_226744df7703790b__row-gap-unset",
|
|
11272
|
+
"row-gap-revert": "_372e9fe7fa60a162__row-gap-revert",
|
|
11273
|
+
"row-gap-revert-layer": "a788bb6771f557d4__row-gap-revert-layer",
|
|
11274
|
+
"column-gap-inherit": "c811e15146756906__column-gap-inherit",
|
|
11275
|
+
"column-gap-initial": "_17d3c2ea7daf9367__column-gap-initial",
|
|
11276
|
+
"column-gap-unset": "_595e6195481b9016__column-gap-unset",
|
|
11277
|
+
"column-gap-revert": "a3ecb3e47731c19e__column-gap-revert",
|
|
11278
|
+
"column-gap-revert-layer": "_7c87cfbf3c22f476__column-gap-revert-layer",
|
|
11279
|
+
"has-align": "_25a972dc3223dff3__has-align",
|
|
11280
|
+
"align-inherit": "_3cda38ca04ad4eb9__align-inherit",
|
|
11281
|
+
"align-initial": "f1d7342c52a8cb04__align-initial",
|
|
11282
|
+
"align-unset": "_0d1a6c7ee990f351__align-unset",
|
|
11283
|
+
"align-revert": "_57c7b85e7abf618b__align-revert",
|
|
11284
|
+
"align-revert-layer": "_82cb0c4950962787__align-revert-layer",
|
|
11285
|
+
"has-justify": "_801d1214723237b8__has-justify",
|
|
11286
|
+
"justify-inherit": "b83c5dbf3264515b__justify-inherit",
|
|
11287
|
+
"justify-initial": "_5b7394b39d69670e__justify-initial",
|
|
11288
|
+
"justify-unset": "_3e7f0418752602e5__justify-unset",
|
|
11289
|
+
"justify-revert": "_5f937df46d7b2259__justify-revert",
|
|
11290
|
+
"justify-revert-layer": "bf2a4718a1ddba5c__justify-revert-layer",
|
|
11291
|
+
"has-template-columns": "_3c6ac9820776f1cb__has-template-columns",
|
|
11292
|
+
"template-columns-inherit": "_35faa4d32eedef32__template-columns-inherit",
|
|
11293
|
+
"template-columns-initial": "_8150cadb3f438833__template-columns-initial",
|
|
11294
|
+
"template-columns-unset": "bcd5f2b096dec164__template-columns-unset",
|
|
11295
|
+
"template-columns-revert": "_48d047bc6fb687b8__template-columns-revert",
|
|
11296
|
+
"template-columns-revert-layer": "_93f250669aa1a5a7__template-columns-revert-layer",
|
|
11297
|
+
"has-template-rows": "c2703b6b15e69b82__has-template-rows",
|
|
11298
|
+
"template-rows-inherit": "_3e9d5ffc53e4afc0__template-rows-inherit",
|
|
11299
|
+
"template-rows-initial": "_64bb5fbdf6d1038a__template-rows-initial",
|
|
11300
|
+
"template-rows-unset": "f8f5df7043222325__template-rows-unset",
|
|
11301
|
+
"template-rows-revert": "_408aaf58100e60d5__template-rows-revert",
|
|
11302
|
+
"template-rows-revert-layer": "e0730d6abf0f3d2a__template-rows-revert-layer",
|
|
11303
|
+
"is-inline": "_43af1cbfad3e73dd__is-inline"
|
|
11304
|
+
};
|
|
11305
|
+
const CSS_WIDE_KEYWORDS = /* @__PURE__ */ new Set([
|
|
10402
11306
|
"inherit",
|
|
10403
11307
|
"initial",
|
|
10404
11308
|
"unset",
|
|
@@ -10447,15 +11351,35 @@ function useGrid(props) {
|
|
|
10447
11351
|
}
|
|
10448
11352
|
};
|
|
10449
11353
|
}
|
|
10450
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
11354
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/grid/component.mjs
|
|
10451
11355
|
function UnconnectedGrid(props, forwardedRef) {
|
|
10452
11356
|
const gridProps = useGrid(props);
|
|
10453
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11357
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
|
|
10454
11358
|
...gridProps,
|
|
10455
11359
|
ref: forwardedRef
|
|
10456
11360
|
});
|
|
10457
11361
|
}
|
|
10458
|
-
|
|
11362
|
+
/**
|
|
11363
|
+
* `Grid` is a primitive layout component that can arrange content in a grid configuration.
|
|
11364
|
+
*
|
|
11365
|
+
* ```jsx
|
|
11366
|
+
* import {
|
|
11367
|
+
* __experimentalGrid as Grid,
|
|
11368
|
+
* __experimentalText as Text
|
|
11369
|
+
* } from `@wordpress/components`;
|
|
11370
|
+
*
|
|
11371
|
+
* function Example() {
|
|
11372
|
+
* return (
|
|
11373
|
+
* <Grid columns={ 3 }>
|
|
11374
|
+
* <Text>Code</Text>
|
|
11375
|
+
* <Text>is</Text>
|
|
11376
|
+
* <Text>Poetry</Text>
|
|
11377
|
+
* </Grid>
|
|
11378
|
+
* );
|
|
11379
|
+
* }
|
|
11380
|
+
* ```
|
|
11381
|
+
*/
|
|
11382
|
+
const Grid = contextConnect(UnconnectedGrid, "Grid");
|
|
10459
11383
|
// src/charts/leaderboard-chart/hooks/use-fitted-row-count.ts
|
|
10460
11384
|
/**
|
|
10461
11385
|
* Fractional layout rounding can put a row's bottom a hair past the container's
|
|
@@ -10938,7 +11862,7 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
|
|
|
10938
11862
|
}), allSeriesHidden ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
10939
11863
|
className: leaderboard_chart_module_default.emptyState,
|
|
10940
11864
|
children: getAllHiddenMessage(legendInteractive, "series")
|
|
10941
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11865
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Grid, {
|
|
10942
11866
|
role: "list",
|
|
10943
11867
|
"aria-label": ariaLabel ?? (0, _wordpress_i18n.__)("Leaderboard chart", "jetpack-charts"),
|
|
10944
11868
|
templateColumns,
|
|
@@ -10979,7 +11903,7 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
|
|
|
10979
11903
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
10980
11904
|
"aria-hidden": "true",
|
|
10981
11905
|
children: "—"
|
|
10982
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11906
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VisuallyHidden$1, {
|
|
10983
11907
|
as: "span",
|
|
10984
11908
|
children: hasPreviousPeriodValue ? (0, _wordpress_i18n.__)("Percentage change unavailable", "jetpack-charts") : (0, _wordpress_i18n.__)("No comparison data", "jetpack-charts")
|
|
10985
11909
|
})]
|