@automattic/charts 4.13.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 +34 -29
- package/TOKENS.md +4 -1
- package/dist/index.cjs +1069 -1620
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +33 -1
- package/dist/index.d.cts +60 -15
- package/dist/index.d.ts +60 -15
- package/dist/index.js +1072 -1575
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
- 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/leaderboard-chart/leaderboard-chart.module.scss +1 -1
- package/src/charts/leaderboard-chart/leaderboard-chart.tsx +26 -9
- package/src/charts/leaderboard-chart/private/resolve-leaderboard-entries.ts +53 -0
- package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +41 -0
- package/src/charts/leaderboard-chart/test/resolve-leaderboard-entries.test.ts +146 -0
- package/src/charts/leaderboard-chart/types.ts +6 -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/components/legend/private/base-legend.tsx +13 -8
- package/src/components/legend/test/legend.test.tsx +125 -0
- package/src/components/legend/types.ts +9 -1
- package/src/providers/chart-context/themes.ts +4 -0
- package/src/styles/chart-scope.scss +1 -0
- package/src/types.ts +40 -9
- 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
|
@@ -27,7 +27,6 @@ let _wordpress_i18n = require("@wordpress/i18n");
|
|
|
27
27
|
let clsx = require("clsx");
|
|
28
28
|
clsx = __toESM(clsx, 1);
|
|
29
29
|
let react = require("react");
|
|
30
|
-
react = __toESM(react);
|
|
31
30
|
let date_fns = require("date-fns");
|
|
32
31
|
let _date_fns_tz = require("@date-fns/tz");
|
|
33
32
|
let _visx_text = require("@visx/text");
|
|
@@ -51,7 +50,6 @@ let _visx_pattern = require("@visx/pattern");
|
|
|
51
50
|
let react_google_charts = require("react-google-charts");
|
|
52
51
|
let dompurify = require("dompurify");
|
|
53
52
|
dompurify = __toESM(dompurify, 1);
|
|
54
|
-
require("@babel/runtime/helpers/esm/extends");
|
|
55
53
|
let _wordpress_icons = require("@wordpress/icons");
|
|
56
54
|
let _visx_shape = require("@visx/shape");
|
|
57
55
|
// src/charts/private/chart-instance-context/chart-instance-context.ts
|
|
@@ -1285,6 +1283,15 @@ const defaultTheme = {
|
|
|
1285
1283
|
},
|
|
1286
1284
|
strokeWidth: 1.5
|
|
1287
1285
|
},
|
|
1286
|
+
compactWhenShort: {
|
|
1287
|
+
below: 140,
|
|
1288
|
+
margin: {
|
|
1289
|
+
top: 2,
|
|
1290
|
+
right: 2,
|
|
1291
|
+
bottom: 2,
|
|
1292
|
+
left: 2
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1288
1295
|
heatmapChart: {
|
|
1289
1296
|
compactCellGap: 2,
|
|
1290
1297
|
compactCellSize: 11,
|
|
@@ -2127,16 +2134,17 @@ const BaseLegend = (0, react.forwardRef)(({ items: allItems, className, orientat
|
|
|
2127
2134
|
chartId,
|
|
2128
2135
|
context
|
|
2129
2136
|
]);
|
|
2130
|
-
const createClickHandler = (0, react.useCallback)((seriesLabels, itemInteractive) => {
|
|
2137
|
+
const createClickHandler = (0, react.useCallback)((seriesLabels, itemInteractive, onToggle) => {
|
|
2131
2138
|
if (!itemInteractive) return;
|
|
2132
|
-
return () => handleLegendClick(seriesLabels);
|
|
2139
|
+
return onToggle ? () => onToggle() : () => handleLegendClick(seriesLabels);
|
|
2133
2140
|
}, [handleLegendClick]);
|
|
2134
|
-
const createKeyDownHandler = (0, react.useCallback)((seriesLabels, itemInteractive) => {
|
|
2141
|
+
const createKeyDownHandler = (0, react.useCallback)((seriesLabels, itemInteractive, onToggle) => {
|
|
2135
2142
|
if (!itemInteractive) return;
|
|
2143
|
+
const toggle = onToggle ?? (() => handleLegendClick(seriesLabels));
|
|
2136
2144
|
return (event) => {
|
|
2137
2145
|
if (event.key === "Enter" || event.key === " ") {
|
|
2138
2146
|
event.preventDefault();
|
|
2139
|
-
|
|
2147
|
+
if (!event.repeat) toggle();
|
|
2140
2148
|
}
|
|
2141
2149
|
};
|
|
2142
2150
|
}, [handleLegendClick]);
|
|
@@ -2160,10 +2168,11 @@ const BaseLegend = (0, react.forwardRef)(({ items: allItems, className, orientat
|
|
|
2160
2168
|
children: labels.map((label, i) => {
|
|
2161
2169
|
const matchedItem = items[i];
|
|
2162
2170
|
const seriesLabels = matchedItem?.seriesLabels?.length ? matchedItem.seriesLabels : [label.text];
|
|
2163
|
-
const visible = matchedItem?.interactive === false || isSeriesVisible(seriesLabels[0]);
|
|
2164
2171
|
const itemInteractive = interactive && matchedItem?.interactive !== false;
|
|
2165
|
-
const
|
|
2166
|
-
const
|
|
2172
|
+
const onToggle = itemInteractive ? matchedItem?.onToggle : void 0;
|
|
2173
|
+
const visible = matchedItem?.onToggle ? matchedItem.pressed : matchedItem?.interactive === false || isSeriesVisible(seriesLabels[0]);
|
|
2174
|
+
const handleClick = createClickHandler(seriesLabels, itemInteractive, onToggle);
|
|
2175
|
+
const handleKeyDown = createKeyDownHandler(seriesLabels, itemInteractive, onToggle);
|
|
2167
2176
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_visx_legend.LegendItem, {
|
|
2168
2177
|
className: (0, clsx.default)("visx-legend-item", base_legend_module_default["legend-item"], itemInteractive && base_legend_module_default["legend-item--interactive"], !visible && base_legend_module_default["legend-item--inactive"], itemClassName),
|
|
2169
2178
|
margin: itemMargin,
|
|
@@ -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,38 +6509,147 @@ const SelectedBarRing = ({ chartId, selected, slotKeys, groupPadding, horizontal
|
|
|
6312
6509
|
testId: "bar-chart-selected-ring"
|
|
6313
6510
|
});
|
|
6314
6511
|
};
|
|
6315
|
-
// src/charts/bar-chart/private/bar-
|
|
6512
|
+
// src/charts/bar-chart/private/stacked-bar-series.tsx
|
|
6316
6513
|
/**
|
|
6317
|
-
*
|
|
6514
|
+
* The side a segment rounds when it ends its drawn stack: the far end of the positives or of the negatives.
|
|
6318
6515
|
*
|
|
6319
|
-
* @param
|
|
6320
|
-
* @param
|
|
6321
|
-
* @param
|
|
6322
|
-
* @param
|
|
6323
|
-
* @param
|
|
6324
|
-
* @
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
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
|
+
};
|
|
6586
|
+
// src/charts/bar-chart/private/bar-layer.tsx
|
|
6587
|
+
/**
|
|
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.
|
|
6609
|
+
*
|
|
6610
|
+
* @param props - Component props.
|
|
6611
|
+
* @param props.chartId - The chart's id, which keeps the ring's clip path unique on a page with several charts.
|
|
6612
|
+
* @param props.barSlots - The overlap or stacked slots, or undefined for a grouped layout.
|
|
6613
|
+
* @param props.selectedBar - The bar or slot the keyboard has selected.
|
|
6614
|
+
* @param props.primaryEntries - The visible primary series, for a grouped layout.
|
|
6615
|
+
* @param props.primaryKeys - Their labels, in group order.
|
|
6616
|
+
* @param props.getBarBackground - Reads a series' bar fill.
|
|
6617
|
+
* @param props.barClassName - Adds classes to a bar.
|
|
6618
|
+
* @param props.groupPadding - The padding between the bars of a category.
|
|
6328
6619
|
* @param props.horizontal - Whether the bars run horizontally.
|
|
6329
6620
|
* @param props.xAccessor - Reads a datum's x value.
|
|
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-
|
|
6513
|
-
/**
|
|
6514
|
-
* Whether two data points sit at the same category: the same label, or the same date.
|
|
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
|
-
}
|
|
6818
|
+
// src/charts/bar-chart/private/use-bar-slots.ts
|
|
6523
6819
|
/**
|
|
6524
|
-
* Lays out the visible series
|
|
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"],
|
|
@@ -10180,12 +10568,33 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
10180
10568
|
tslib_1.__exportStar(require_dist$2(), exports);
|
|
10181
10569
|
tslib_1.__exportStar(require_dist$1(), exports);
|
|
10182
10570
|
}));
|
|
10183
|
-
// ../../../node_modules/.pnpm/@wordpress+warning@
|
|
10184
|
-
|
|
10185
|
-
|
|
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
|
|
10186
10578
|
function isDev() {
|
|
10187
10579
|
return globalThis.SCRIPT_DEBUG === true;
|
|
10188
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
|
+
*/
|
|
10189
10598
|
function warning(message) {
|
|
10190
10599
|
if (!isDev()) return;
|
|
10191
10600
|
if (logged.has(message)) return;
|
|
@@ -10195,7 +10604,61 @@ function warning(message) {
|
|
|
10195
10604
|
} catch {}
|
|
10196
10605
|
logged.add(message);
|
|
10197
10606
|
}
|
|
10198
|
-
// ../../../node_modules/.pnpm
|
|
10607
|
+
// ../../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/es6/index.js
|
|
10608
|
+
var require_es6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10609
|
+
module.exports = function equal(a, b) {
|
|
10610
|
+
if (a === b) return true;
|
|
10611
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
10612
|
+
if (a.constructor !== b.constructor) return false;
|
|
10613
|
+
var length, i, keys;
|
|
10614
|
+
if (Array.isArray(a)) {
|
|
10615
|
+
length = a.length;
|
|
10616
|
+
if (length != b.length) return false;
|
|
10617
|
+
for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;
|
|
10618
|
+
return true;
|
|
10619
|
+
}
|
|
10620
|
+
if (a instanceof Map && b instanceof Map) {
|
|
10621
|
+
if (a.size !== b.size) return false;
|
|
10622
|
+
for (i of a.entries()) if (!b.has(i[0])) return false;
|
|
10623
|
+
for (i of a.entries()) if (!equal(i[1], b.get(i[0]))) return false;
|
|
10624
|
+
return true;
|
|
10625
|
+
}
|
|
10626
|
+
if (a instanceof Set && b instanceof Set) {
|
|
10627
|
+
if (a.size !== b.size) return false;
|
|
10628
|
+
for (i of a.entries()) if (!b.has(i[0])) return false;
|
|
10629
|
+
return true;
|
|
10630
|
+
}
|
|
10631
|
+
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
10632
|
+
length = a.length;
|
|
10633
|
+
if (length != b.length) return false;
|
|
10634
|
+
for (i = length; i-- !== 0;) if (a[i] !== b[i]) return false;
|
|
10635
|
+
return true;
|
|
10636
|
+
}
|
|
10637
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
10638
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
10639
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
10640
|
+
keys = Object.keys(a);
|
|
10641
|
+
length = keys.length;
|
|
10642
|
+
if (length !== Object.keys(b).length) return false;
|
|
10643
|
+
for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
10644
|
+
for (i = length; i-- !== 0;) {
|
|
10645
|
+
var key = keys[i];
|
|
10646
|
+
if (!equal(a[key], b[key])) return false;
|
|
10647
|
+
}
|
|
10648
|
+
return true;
|
|
10649
|
+
}
|
|
10650
|
+
return a !== a && b !== b;
|
|
10651
|
+
};
|
|
10652
|
+
}));
|
|
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
|
+
*/
|
|
10199
10662
|
function useUpdateEffect(effect, deps) {
|
|
10200
10663
|
const mountedRef = (0, react.useRef)(false);
|
|
10201
10664
|
(0, react.useEffect)(() => {
|
|
@@ -10206,1221 +10669,88 @@ function useUpdateEffect(effect, deps) {
|
|
|
10206
10669
|
mountedRef.current = false;
|
|
10207
10670
|
}, []);
|
|
10208
10671
|
}
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
for (var i = 0; i < document.styleSheets.length; i++) if (document.styleSheets[i].ownerNode === tag) return document.styleSheets[i];
|
|
10215
|
-
}
|
|
10216
|
-
function createStyleElement(options) {
|
|
10217
|
-
var tag = document.createElement("style");
|
|
10218
|
-
tag.setAttribute("data-emotion", options.key);
|
|
10219
|
-
if (options.nonce !== void 0) tag.setAttribute("nonce", options.nonce);
|
|
10220
|
-
tag.appendChild(document.createTextNode(""));
|
|
10221
|
-
tag.setAttribute("data-s", "");
|
|
10222
|
-
return tag;
|
|
10223
|
-
}
|
|
10224
|
-
var StyleSheet = /*#__PURE__*/ function() {
|
|
10225
|
-
function StyleSheet(options) {
|
|
10226
|
-
var _this = this;
|
|
10227
|
-
this._insertTag = function(tag) {
|
|
10228
|
-
var before;
|
|
10229
|
-
if (_this.tags.length === 0) {
|
|
10230
|
-
if (_this.insertionPoint) before = _this.insertionPoint.nextSibling;
|
|
10231
|
-
else if (_this.prepend) before = _this.container.firstChild;
|
|
10232
|
-
else before = _this.before;
|
|
10233
|
-
} else before = _this.tags[_this.tags.length - 1].nextSibling;
|
|
10234
|
-
_this.container.insertBefore(tag, before);
|
|
10235
|
-
_this.tags.push(tag);
|
|
10236
|
-
};
|
|
10237
|
-
this.isSpeedy = options.speedy === void 0 ? true : options.speedy;
|
|
10238
|
-
this.tags = [];
|
|
10239
|
-
this.ctr = 0;
|
|
10240
|
-
this.nonce = options.nonce;
|
|
10241
|
-
this.key = options.key;
|
|
10242
|
-
this.container = options.container;
|
|
10243
|
-
this.prepend = options.prepend;
|
|
10244
|
-
this.insertionPoint = options.insertionPoint;
|
|
10245
|
-
this.before = null;
|
|
10246
|
-
}
|
|
10247
|
-
var _proto = StyleSheet.prototype;
|
|
10248
|
-
_proto.hydrate = function hydrate(nodes) {
|
|
10249
|
-
nodes.forEach(this._insertTag);
|
|
10250
|
-
};
|
|
10251
|
-
_proto.insert = function insert(rule) {
|
|
10252
|
-
if (this.ctr % (this.isSpeedy ? 65e3 : 1) === 0) this._insertTag(createStyleElement(this));
|
|
10253
|
-
var tag = this.tags[this.tags.length - 1];
|
|
10254
|
-
if (this.isSpeedy) {
|
|
10255
|
-
var sheet = sheetForTag(tag);
|
|
10256
|
-
try {
|
|
10257
|
-
sheet.insertRule(rule, sheet.cssRules.length);
|
|
10258
|
-
} catch (e) {}
|
|
10259
|
-
} else tag.appendChild(document.createTextNode(rule));
|
|
10260
|
-
this.ctr++;
|
|
10261
|
-
};
|
|
10262
|
-
_proto.flush = function flush() {
|
|
10263
|
-
this.tags.forEach(function(tag) {
|
|
10264
|
-
var _tag$parentNode;
|
|
10265
|
-
return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag);
|
|
10266
|
-
});
|
|
10267
|
-
this.tags = [];
|
|
10268
|
-
this.ctr = 0;
|
|
10269
|
-
};
|
|
10270
|
-
return StyleSheet;
|
|
10271
|
-
}();
|
|
10272
|
-
// ../../../node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Enum.js
|
|
10273
|
-
var MS = "-ms-";
|
|
10274
|
-
var MOZ = "-moz-";
|
|
10275
|
-
var WEBKIT = "-webkit-";
|
|
10276
|
-
var COMMENT = "comm";
|
|
10277
|
-
var RULESET = "rule";
|
|
10278
|
-
var DECLARATION = "decl";
|
|
10279
|
-
var IMPORT = "@import";
|
|
10280
|
-
var KEYFRAMES = "@keyframes";
|
|
10281
|
-
var LAYER = "@layer";
|
|
10282
|
-
// ../../../node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Utility.js
|
|
10283
|
-
/**
|
|
10284
|
-
* @param {number}
|
|
10285
|
-
* @return {number}
|
|
10286
|
-
*/
|
|
10287
|
-
var abs = Math.abs;
|
|
10288
|
-
/**
|
|
10289
|
-
* @param {number}
|
|
10290
|
-
* @return {string}
|
|
10291
|
-
*/
|
|
10292
|
-
var from = String.fromCharCode;
|
|
10293
|
-
/**
|
|
10294
|
-
* @param {object}
|
|
10295
|
-
* @return {object}
|
|
10296
|
-
*/
|
|
10297
|
-
var assign = Object.assign;
|
|
10672
|
+
// ../../../node_modules/.pnpm/@wordpress+components@44.0.0_patch_hash=dd89cc780626599c6721f4e05e7091dd7b0aed577d8a667_94a1a77c56d75249398bc99af3f14fa5/node_modules/@wordpress/components/build-module/context/context-system-provider.mjs
|
|
10673
|
+
var import_es6 = /* @__PURE__ */ __toESM(require_es6(), 1);
|
|
10674
|
+
const ComponentsContext = (0, react.createContext)({});
|
|
10675
|
+
ComponentsContext.displayName = "ComponentsContext";
|
|
10676
|
+
const useComponentsContext = () => (0, react.useContext)(ComponentsContext);
|
|
10298
10677
|
/**
|
|
10299
|
-
*
|
|
10300
|
-
*
|
|
10301
|
-
*
|
|
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.
|
|
10302
10685
|
*/
|
|
10303
|
-
function
|
|
10304
|
-
|
|
10686
|
+
function useContextSystemBridge({ value }) {
|
|
10687
|
+
const parentContext = useComponentsContext();
|
|
10688
|
+
const valueRef = (0, react.useRef)(value);
|
|
10689
|
+
useUpdateEffect(() => {
|
|
10690
|
+
if ((0, import_es6.default)(valueRef.current, value) && valueRef.current !== value) warning(`Please memoize your context: ${JSON.stringify(value)}`);
|
|
10691
|
+
}, [value]);
|
|
10692
|
+
return (0, react.useMemo)(() => {
|
|
10693
|
+
return (0, deepmerge.default)(parentContext ?? {}, value ?? {}, { isMergeableObject: isPlainObject });
|
|
10694
|
+
}, [parentContext, value]);
|
|
10305
10695
|
}
|
|
10306
10696
|
/**
|
|
10307
|
-
*
|
|
10308
|
-
*
|
|
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.
|
|
10309
10712
|
*/
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10713
|
+
const BaseContextSystemProvider = ({ children, value }) => {
|
|
10714
|
+
const contextValue = useContextSystemBridge({ value });
|
|
10715
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentsContext.Provider, {
|
|
10716
|
+
value: contextValue,
|
|
10717
|
+
children
|
|
10718
|
+
});
|
|
10719
|
+
};
|
|
10720
|
+
(0, react.memo)(BaseContextSystemProvider);
|
|
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";
|
|
10313
10724
|
/**
|
|
10314
|
-
*
|
|
10315
|
-
*
|
|
10316
|
-
* @return {string?}
|
|
10725
|
+
* Special key where the connected namespaces are stored.
|
|
10726
|
+
* This is attached to Context connected components as a static property.
|
|
10317
10727
|
*/
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
}
|
|
10728
|
+
const CONNECT_STATIC_NAMESPACE = "__contextSystemKey__";
|
|
10729
|
+
// ../../../node_modules/.pnpm/memize@2.1.1/node_modules/memize/dist/index.js
|
|
10321
10730
|
/**
|
|
10322
|
-
*
|
|
10323
|
-
*
|
|
10324
|
-
* @
|
|
10325
|
-
*
|
|
10731
|
+
* Memize options object.
|
|
10732
|
+
*
|
|
10733
|
+
* @typedef MemizeOptions
|
|
10734
|
+
*
|
|
10735
|
+
* @property {number} [maxSize] Maximum size of the cache.
|
|
10326
10736
|
*/
|
|
10327
|
-
function replace(value, pattern, replacement) {
|
|
10328
|
-
return value.replace(pattern, replacement);
|
|
10329
|
-
}
|
|
10330
10737
|
/**
|
|
10331
|
-
*
|
|
10332
|
-
*
|
|
10333
|
-
* @
|
|
10738
|
+
* Internal cache entry.
|
|
10739
|
+
*
|
|
10740
|
+
* @typedef MemizeCacheNode
|
|
10741
|
+
*
|
|
10742
|
+
* @property {?MemizeCacheNode|undefined} [prev] Previous node.
|
|
10743
|
+
* @property {?MemizeCacheNode|undefined} [next] Next node.
|
|
10744
|
+
* @property {Array<*>} args Function arguments for cache
|
|
10745
|
+
* entry.
|
|
10746
|
+
* @property {*} val Function result.
|
|
10334
10747
|
*/
|
|
10335
|
-
function indexof(value, search) {
|
|
10336
|
-
return value.indexOf(search);
|
|
10337
|
-
}
|
|
10338
10748
|
/**
|
|
10339
|
-
*
|
|
10340
|
-
*
|
|
10341
|
-
* @
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
return value.charCodeAt(index) | 0;
|
|
10345
|
-
}
|
|
10346
|
-
/**
|
|
10347
|
-
* @param {string} value
|
|
10348
|
-
* @param {number} begin
|
|
10349
|
-
* @param {number} end
|
|
10350
|
-
* @return {string}
|
|
10351
|
-
*/
|
|
10352
|
-
function substr(value, begin, end) {
|
|
10353
|
-
return value.slice(begin, end);
|
|
10354
|
-
}
|
|
10355
|
-
/**
|
|
10356
|
-
* @param {string} value
|
|
10357
|
-
* @return {number}
|
|
10358
|
-
*/
|
|
10359
|
-
function strlen(value) {
|
|
10360
|
-
return value.length;
|
|
10361
|
-
}
|
|
10362
|
-
/**
|
|
10363
|
-
* @param {any[]} value
|
|
10364
|
-
* @return {number}
|
|
10365
|
-
*/
|
|
10366
|
-
function sizeof(value) {
|
|
10367
|
-
return value.length;
|
|
10368
|
-
}
|
|
10369
|
-
/**
|
|
10370
|
-
* @param {any} value
|
|
10371
|
-
* @param {any[]} array
|
|
10372
|
-
* @return {any}
|
|
10373
|
-
*/
|
|
10374
|
-
function append(value, array) {
|
|
10375
|
-
return array.push(value), value;
|
|
10376
|
-
}
|
|
10377
|
-
/**
|
|
10378
|
-
* @param {string[]} array
|
|
10379
|
-
* @param {function} callback
|
|
10380
|
-
* @return {string}
|
|
10381
|
-
*/
|
|
10382
|
-
function combine(array, callback) {
|
|
10383
|
-
return array.map(callback).join("");
|
|
10384
|
-
}
|
|
10385
|
-
// ../../../node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Tokenizer.js
|
|
10386
|
-
var line = 1;
|
|
10387
|
-
var column = 1;
|
|
10388
|
-
var length = 0;
|
|
10389
|
-
var position = 0;
|
|
10390
|
-
var character = 0;
|
|
10391
|
-
var characters = "";
|
|
10392
|
-
/**
|
|
10393
|
-
* @param {string} value
|
|
10394
|
-
* @param {object | null} root
|
|
10395
|
-
* @param {object | null} parent
|
|
10396
|
-
* @param {string} type
|
|
10397
|
-
* @param {string[] | string} props
|
|
10398
|
-
* @param {object[] | string} children
|
|
10399
|
-
* @param {number} length
|
|
10400
|
-
*/
|
|
10401
|
-
function node(value, root, parent, type, props, children, length) {
|
|
10402
|
-
return {
|
|
10403
|
-
value,
|
|
10404
|
-
root,
|
|
10405
|
-
parent,
|
|
10406
|
-
type,
|
|
10407
|
-
props,
|
|
10408
|
-
children,
|
|
10409
|
-
line,
|
|
10410
|
-
column,
|
|
10411
|
-
length,
|
|
10412
|
-
return: ""
|
|
10413
|
-
};
|
|
10414
|
-
}
|
|
10415
|
-
/**
|
|
10416
|
-
* @param {object} root
|
|
10417
|
-
* @param {object} props
|
|
10418
|
-
* @return {object}
|
|
10419
|
-
*/
|
|
10420
|
-
function copy(root, props) {
|
|
10421
|
-
return assign(node("", null, null, "", null, null, 0), root, { length: -root.length }, props);
|
|
10422
|
-
}
|
|
10423
|
-
/**
|
|
10424
|
-
* @return {number}
|
|
10425
|
-
*/
|
|
10426
|
-
function char() {
|
|
10427
|
-
return character;
|
|
10428
|
-
}
|
|
10429
|
-
/**
|
|
10430
|
-
* @return {number}
|
|
10431
|
-
*/
|
|
10432
|
-
function prev() {
|
|
10433
|
-
character = position > 0 ? charat(characters, --position) : 0;
|
|
10434
|
-
if (column--, character === 10) column = 1, line--;
|
|
10435
|
-
return character;
|
|
10436
|
-
}
|
|
10437
|
-
/**
|
|
10438
|
-
* @return {number}
|
|
10439
|
-
*/
|
|
10440
|
-
function next() {
|
|
10441
|
-
character = position < length ? charat(characters, position++) : 0;
|
|
10442
|
-
if (column++, character === 10) column = 1, line++;
|
|
10443
|
-
return character;
|
|
10444
|
-
}
|
|
10445
|
-
/**
|
|
10446
|
-
* @return {number}
|
|
10447
|
-
*/
|
|
10448
|
-
function peek() {
|
|
10449
|
-
return charat(characters, position);
|
|
10450
|
-
}
|
|
10451
|
-
/**
|
|
10452
|
-
* @return {number}
|
|
10453
|
-
*/
|
|
10454
|
-
function caret() {
|
|
10455
|
-
return position;
|
|
10456
|
-
}
|
|
10457
|
-
/**
|
|
10458
|
-
* @param {number} begin
|
|
10459
|
-
* @param {number} end
|
|
10460
|
-
* @return {string}
|
|
10461
|
-
*/
|
|
10462
|
-
function slice(begin, end) {
|
|
10463
|
-
return substr(characters, begin, end);
|
|
10464
|
-
}
|
|
10465
|
-
/**
|
|
10466
|
-
* @param {number} type
|
|
10467
|
-
* @return {number}
|
|
10468
|
-
*/
|
|
10469
|
-
function token(type) {
|
|
10470
|
-
switch (type) {
|
|
10471
|
-
case 0:
|
|
10472
|
-
case 9:
|
|
10473
|
-
case 10:
|
|
10474
|
-
case 13:
|
|
10475
|
-
case 32: return 5;
|
|
10476
|
-
case 33:
|
|
10477
|
-
case 43:
|
|
10478
|
-
case 44:
|
|
10479
|
-
case 47:
|
|
10480
|
-
case 62:
|
|
10481
|
-
case 64:
|
|
10482
|
-
case 126:
|
|
10483
|
-
case 59:
|
|
10484
|
-
case 123:
|
|
10485
|
-
case 125: return 4;
|
|
10486
|
-
case 58: return 3;
|
|
10487
|
-
case 34:
|
|
10488
|
-
case 39:
|
|
10489
|
-
case 40:
|
|
10490
|
-
case 91: return 2;
|
|
10491
|
-
case 41:
|
|
10492
|
-
case 93: return 1;
|
|
10493
|
-
}
|
|
10494
|
-
return 0;
|
|
10495
|
-
}
|
|
10496
|
-
/**
|
|
10497
|
-
* @param {string} value
|
|
10498
|
-
* @return {any[]}
|
|
10499
|
-
*/
|
|
10500
|
-
function alloc(value) {
|
|
10501
|
-
return line = column = 1, length = strlen(characters = value), position = 0, [];
|
|
10502
|
-
}
|
|
10503
|
-
/**
|
|
10504
|
-
* @param {any} value
|
|
10505
|
-
* @return {any}
|
|
10506
|
-
*/
|
|
10507
|
-
function dealloc(value) {
|
|
10508
|
-
return characters = "", value;
|
|
10509
|
-
}
|
|
10510
|
-
/**
|
|
10511
|
-
* @param {number} type
|
|
10512
|
-
* @return {string}
|
|
10513
|
-
*/
|
|
10514
|
-
function delimit(type) {
|
|
10515
|
-
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
|
|
10516
|
-
}
|
|
10517
|
-
/**
|
|
10518
|
-
* @param {number} type
|
|
10519
|
-
* @return {string}
|
|
10520
|
-
*/
|
|
10521
|
-
function whitespace(type) {
|
|
10522
|
-
while (character = peek()) if (character < 33) next();
|
|
10523
|
-
else break;
|
|
10524
|
-
return token(type) > 2 || token(character) > 3 ? "" : " ";
|
|
10525
|
-
}
|
|
10526
|
-
/**
|
|
10527
|
-
* @param {number} index
|
|
10528
|
-
* @param {number} count
|
|
10529
|
-
* @return {string}
|
|
10530
|
-
*/
|
|
10531
|
-
function escaping(index, count) {
|
|
10532
|
-
while (--count && next()) if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97) break;
|
|
10533
|
-
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
|
|
10534
|
-
}
|
|
10535
|
-
/**
|
|
10536
|
-
* @param {number} type
|
|
10537
|
-
* @return {number}
|
|
10538
|
-
*/
|
|
10539
|
-
function delimiter(type) {
|
|
10540
|
-
while (next()) switch (character) {
|
|
10541
|
-
case type: return position;
|
|
10542
|
-
case 34:
|
|
10543
|
-
case 39:
|
|
10544
|
-
if (type !== 34 && type !== 39) delimiter(character);
|
|
10545
|
-
break;
|
|
10546
|
-
case 40:
|
|
10547
|
-
if (type === 41) delimiter(type);
|
|
10548
|
-
break;
|
|
10549
|
-
case 92: next();
|
|
10550
|
-
}
|
|
10551
|
-
return position;
|
|
10552
|
-
}
|
|
10553
|
-
/**
|
|
10554
|
-
* @param {number} type
|
|
10555
|
-
* @param {number} index
|
|
10556
|
-
* @return {number}
|
|
10557
|
-
*/
|
|
10558
|
-
function commenter(type, index) {
|
|
10559
|
-
while (next()) if (type + character === 57) break;
|
|
10560
|
-
else if (type + character === 84 && peek() === 47) break;
|
|
10561
|
-
return "/*" + slice(index, position - 1) + "*" + from(type === 47 ? type : next());
|
|
10562
|
-
}
|
|
10563
|
-
/**
|
|
10564
|
-
* @param {number} index
|
|
10565
|
-
* @return {string}
|
|
10566
|
-
*/
|
|
10567
|
-
function identifier(index) {
|
|
10568
|
-
while (!token(peek())) next();
|
|
10569
|
-
return slice(index, position);
|
|
10570
|
-
}
|
|
10571
|
-
// ../../../node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Parser.js
|
|
10572
|
-
/**
|
|
10573
|
-
* @param {string} value
|
|
10574
|
-
* @return {object[]}
|
|
10575
|
-
*/
|
|
10576
|
-
function compile(value) {
|
|
10577
|
-
return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value));
|
|
10578
|
-
}
|
|
10579
|
-
/**
|
|
10580
|
-
* @param {string} value
|
|
10581
|
-
* @param {object} root
|
|
10582
|
-
* @param {object?} parent
|
|
10583
|
-
* @param {string[]} rule
|
|
10584
|
-
* @param {string[]} rules
|
|
10585
|
-
* @param {string[]} rulesets
|
|
10586
|
-
* @param {number[]} pseudo
|
|
10587
|
-
* @param {number[]} points
|
|
10588
|
-
* @param {string[]} declarations
|
|
10589
|
-
* @return {object}
|
|
10590
|
-
*/
|
|
10591
|
-
function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
|
|
10592
|
-
var index = 0;
|
|
10593
|
-
var offset = 0;
|
|
10594
|
-
var length = pseudo;
|
|
10595
|
-
var atrule = 0;
|
|
10596
|
-
var property = 0;
|
|
10597
|
-
var previous = 0;
|
|
10598
|
-
var variable = 1;
|
|
10599
|
-
var scanning = 1;
|
|
10600
|
-
var ampersand = 1;
|
|
10601
|
-
var character = 0;
|
|
10602
|
-
var type = "";
|
|
10603
|
-
var props = rules;
|
|
10604
|
-
var children = rulesets;
|
|
10605
|
-
var reference = rule;
|
|
10606
|
-
var characters = type;
|
|
10607
|
-
while (scanning) switch (previous = character, character = next()) {
|
|
10608
|
-
case 40: if (previous != 108 && charat(characters, length - 1) == 58) {
|
|
10609
|
-
if (indexof(characters += replace(delimit(character), "&", "&\f"), "&\f") != -1) ampersand = -1;
|
|
10610
|
-
break;
|
|
10611
|
-
}
|
|
10612
|
-
case 34:
|
|
10613
|
-
case 39:
|
|
10614
|
-
case 91:
|
|
10615
|
-
characters += delimit(character);
|
|
10616
|
-
break;
|
|
10617
|
-
case 9:
|
|
10618
|
-
case 10:
|
|
10619
|
-
case 13:
|
|
10620
|
-
case 32:
|
|
10621
|
-
characters += whitespace(previous);
|
|
10622
|
-
break;
|
|
10623
|
-
case 92:
|
|
10624
|
-
characters += escaping(caret() - 1, 7);
|
|
10625
|
-
continue;
|
|
10626
|
-
case 47:
|
|
10627
|
-
switch (peek()) {
|
|
10628
|
-
case 42:
|
|
10629
|
-
case 47:
|
|
10630
|
-
append(comment(commenter(next(), caret()), root, parent), declarations);
|
|
10631
|
-
break;
|
|
10632
|
-
default: characters += "/";
|
|
10633
|
-
}
|
|
10634
|
-
break;
|
|
10635
|
-
case 123 * variable: points[index++] = strlen(characters) * ampersand;
|
|
10636
|
-
case 125 * variable:
|
|
10637
|
-
case 59:
|
|
10638
|
-
case 0:
|
|
10639
|
-
switch (character) {
|
|
10640
|
-
case 0:
|
|
10641
|
-
case 125: scanning = 0;
|
|
10642
|
-
case 59 + offset:
|
|
10643
|
-
if (ampersand == -1) characters = replace(characters, /\f/g, "");
|
|
10644
|
-
if (property > 0 && strlen(characters) - length) append(property > 32 ? declaration(characters + ";", rule, parent, length - 1) : declaration(replace(characters, " ", "") + ";", rule, parent, length - 2), declarations);
|
|
10645
|
-
break;
|
|
10646
|
-
case 59: characters += ";";
|
|
10647
|
-
default:
|
|
10648
|
-
append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length), rulesets);
|
|
10649
|
-
if (character === 123) if (offset === 0) parse(characters, root, reference, reference, props, rulesets, length, points, children);
|
|
10650
|
-
else switch (atrule === 99 && charat(characters, 3) === 110 ? 100 : atrule) {
|
|
10651
|
-
case 100:
|
|
10652
|
-
case 108:
|
|
10653
|
-
case 109:
|
|
10654
|
-
case 115:
|
|
10655
|
-
parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length), children), rules, children, length, points, rule ? props : children);
|
|
10656
|
-
break;
|
|
10657
|
-
default: parse(characters, reference, reference, reference, [""], children, 0, points, children);
|
|
10658
|
-
}
|
|
10659
|
-
}
|
|
10660
|
-
index = offset = property = 0, variable = ampersand = 1, type = characters = "", length = pseudo;
|
|
10661
|
-
break;
|
|
10662
|
-
case 58: length = 1 + strlen(characters), property = previous;
|
|
10663
|
-
default:
|
|
10664
|
-
if (variable < 1) {
|
|
10665
|
-
if (character == 123) --variable;
|
|
10666
|
-
else if (character == 125 && variable++ == 0 && prev() == 125) continue;
|
|
10667
|
-
}
|
|
10668
|
-
switch (characters += from(character), character * variable) {
|
|
10669
|
-
case 38:
|
|
10670
|
-
ampersand = offset > 0 ? 1 : (characters += "\f", -1);
|
|
10671
|
-
break;
|
|
10672
|
-
case 44:
|
|
10673
|
-
points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1;
|
|
10674
|
-
break;
|
|
10675
|
-
case 64:
|
|
10676
|
-
if (peek() === 45) characters += delimit(next());
|
|
10677
|
-
atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
|
|
10678
|
-
break;
|
|
10679
|
-
case 45: if (previous === 45 && strlen(characters) == 2) variable = 0;
|
|
10680
|
-
}
|
|
10681
|
-
}
|
|
10682
|
-
return rulesets;
|
|
10683
|
-
}
|
|
10684
|
-
/**
|
|
10685
|
-
* @param {string} value
|
|
10686
|
-
* @param {object} root
|
|
10687
|
-
* @param {object?} parent
|
|
10688
|
-
* @param {number} index
|
|
10689
|
-
* @param {number} offset
|
|
10690
|
-
* @param {string[]} rules
|
|
10691
|
-
* @param {number[]} points
|
|
10692
|
-
* @param {string} type
|
|
10693
|
-
* @param {string[]} props
|
|
10694
|
-
* @param {string[]} children
|
|
10695
|
-
* @param {number} length
|
|
10696
|
-
* @return {object}
|
|
10697
|
-
*/
|
|
10698
|
-
function ruleset(value, root, parent, index, offset, rules, points, type, props, children, length) {
|
|
10699
|
-
var post = offset - 1;
|
|
10700
|
-
var rule = offset === 0 ? rules : [""];
|
|
10701
|
-
var size = sizeof(rule);
|
|
10702
|
-
for (var i = 0, j = 0, k = 0; i < index; ++i) for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x) if (z = trim(j > 0 ? rule[x] + " " + y : replace(y, /&\f/g, rule[x]))) props[k++] = z;
|
|
10703
|
-
return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length);
|
|
10704
|
-
}
|
|
10705
|
-
/**
|
|
10706
|
-
* @param {number} value
|
|
10707
|
-
* @param {object} root
|
|
10708
|
-
* @param {object?} parent
|
|
10709
|
-
* @return {object}
|
|
10710
|
-
*/
|
|
10711
|
-
function comment(value, root, parent) {
|
|
10712
|
-
return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0);
|
|
10713
|
-
}
|
|
10714
|
-
/**
|
|
10715
|
-
* @param {string} value
|
|
10716
|
-
* @param {object} root
|
|
10717
|
-
* @param {object?} parent
|
|
10718
|
-
* @param {number} length
|
|
10719
|
-
* @return {object}
|
|
10720
|
-
*/
|
|
10721
|
-
function declaration(value, root, parent, length) {
|
|
10722
|
-
return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length);
|
|
10723
|
-
}
|
|
10724
|
-
// ../../../node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Serializer.js
|
|
10725
|
-
/**
|
|
10726
|
-
* @param {object[]} children
|
|
10727
|
-
* @param {function} callback
|
|
10728
|
-
* @return {string}
|
|
10729
|
-
*/
|
|
10730
|
-
function serialize(children, callback) {
|
|
10731
|
-
var output = "";
|
|
10732
|
-
var length = sizeof(children);
|
|
10733
|
-
for (var i = 0; i < length; i++) output += callback(children[i], i, children, callback) || "";
|
|
10734
|
-
return output;
|
|
10735
|
-
}
|
|
10736
|
-
/**
|
|
10737
|
-
* @param {object} element
|
|
10738
|
-
* @param {number} index
|
|
10739
|
-
* @param {object[]} children
|
|
10740
|
-
* @param {function} callback
|
|
10741
|
-
* @return {string}
|
|
10742
|
-
*/
|
|
10743
|
-
function stringify(element, index, children, callback) {
|
|
10744
|
-
switch (element.type) {
|
|
10745
|
-
case LAYER: if (element.children.length) break;
|
|
10746
|
-
case IMPORT:
|
|
10747
|
-
case DECLARATION: return element.return = element.return || element.value;
|
|
10748
|
-
case COMMENT: return "";
|
|
10749
|
-
case KEYFRAMES: return element.return = element.value + "{" + serialize(element.children, callback) + "}";
|
|
10750
|
-
case RULESET: element.value = element.props.join(",");
|
|
10751
|
-
}
|
|
10752
|
-
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
|
|
10753
|
-
}
|
|
10754
|
-
// ../../../node_modules/.pnpm/stylis@4.2.0/node_modules/stylis/src/Middleware.js
|
|
10755
|
-
/**
|
|
10756
|
-
* @param {function[]} collection
|
|
10757
|
-
* @return {function}
|
|
10758
|
-
*/
|
|
10759
|
-
function middleware(collection) {
|
|
10760
|
-
var length = sizeof(collection);
|
|
10761
|
-
return function(element, index, children, callback) {
|
|
10762
|
-
var output = "";
|
|
10763
|
-
for (var i = 0; i < length; i++) output += collection[i](element, index, children, callback) || "";
|
|
10764
|
-
return output;
|
|
10765
|
-
};
|
|
10766
|
-
}
|
|
10767
|
-
/**
|
|
10768
|
-
* @param {function} callback
|
|
10769
|
-
* @return {function}
|
|
10770
|
-
*/
|
|
10771
|
-
function rulesheet(callback) {
|
|
10772
|
-
return function(element) {
|
|
10773
|
-
if (!element.root) {
|
|
10774
|
-
if (element = element.return) callback(element);
|
|
10775
|
-
}
|
|
10776
|
-
};
|
|
10777
|
-
}
|
|
10778
|
-
// ../../../node_modules/.pnpm/@emotion+weak-memoize@0.4.0/node_modules/@emotion/weak-memoize/dist/emotion-weak-memoize.esm.js
|
|
10779
|
-
var weakMemoize = function weakMemoize(func) {
|
|
10780
|
-
var cache = /* @__PURE__ */ new WeakMap();
|
|
10781
|
-
return function(arg) {
|
|
10782
|
-
if (cache.has(arg)) return cache.get(arg);
|
|
10783
|
-
var ret = func(arg);
|
|
10784
|
-
cache.set(arg, ret);
|
|
10785
|
-
return ret;
|
|
10786
|
-
};
|
|
10787
|
-
};
|
|
10788
|
-
// ../../../node_modules/.pnpm/@emotion+memoize@0.9.0/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js
|
|
10789
|
-
function memoize(fn) {
|
|
10790
|
-
var cache = Object.create(null);
|
|
10791
|
-
return function(arg) {
|
|
10792
|
-
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
|
10793
|
-
return cache[arg];
|
|
10794
|
-
};
|
|
10795
|
-
}
|
|
10796
|
-
// ../../../node_modules/.pnpm/@emotion+cache@11.14.0/node_modules/@emotion/cache/dist/emotion-cache.esm.js
|
|
10797
|
-
var isBrowser$2 = typeof document !== "undefined";
|
|
10798
|
-
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
|
|
10799
|
-
var previous = 0;
|
|
10800
|
-
var character = 0;
|
|
10801
|
-
while (true) {
|
|
10802
|
-
previous = character;
|
|
10803
|
-
character = peek();
|
|
10804
|
-
if (previous === 38 && character === 12) points[index] = 1;
|
|
10805
|
-
if (token(character)) break;
|
|
10806
|
-
next();
|
|
10807
|
-
}
|
|
10808
|
-
return slice(begin, position);
|
|
10809
|
-
};
|
|
10810
|
-
var toRules = function toRules(parsed, points) {
|
|
10811
|
-
var index = -1;
|
|
10812
|
-
var character = 44;
|
|
10813
|
-
do
|
|
10814
|
-
switch (token(character)) {
|
|
10815
|
-
case 0:
|
|
10816
|
-
if (character === 38 && peek() === 12) points[index] = 1;
|
|
10817
|
-
parsed[index] += identifierWithPointTracking(position - 1, points, index);
|
|
10818
|
-
break;
|
|
10819
|
-
case 2:
|
|
10820
|
-
parsed[index] += delimit(character);
|
|
10821
|
-
break;
|
|
10822
|
-
case 4: if (character === 44) {
|
|
10823
|
-
parsed[++index] = peek() === 58 ? "&\f" : "";
|
|
10824
|
-
points[index] = parsed[index].length;
|
|
10825
|
-
break;
|
|
10826
|
-
}
|
|
10827
|
-
default: parsed[index] += from(character);
|
|
10828
|
-
}
|
|
10829
|
-
while (character = next());
|
|
10830
|
-
return parsed;
|
|
10831
|
-
};
|
|
10832
|
-
var getRules = function getRules(value, points) {
|
|
10833
|
-
return dealloc(toRules(alloc(value), points));
|
|
10834
|
-
};
|
|
10835
|
-
var fixedElements = /* #__PURE__ */ new WeakMap();
|
|
10836
|
-
var compat = function compat(element) {
|
|
10837
|
-
if (element.type !== "rule" || !element.parent || element.length < 1) return;
|
|
10838
|
-
var value = element.value;
|
|
10839
|
-
var parent = element.parent;
|
|
10840
|
-
var isImplicitRule = element.column === parent.column && element.line === parent.line;
|
|
10841
|
-
while (parent.type !== "rule") {
|
|
10842
|
-
parent = parent.parent;
|
|
10843
|
-
if (!parent) return;
|
|
10844
|
-
}
|
|
10845
|
-
if (element.props.length === 1 && value.charCodeAt(0) !== 58 && !fixedElements.get(parent)) return;
|
|
10846
|
-
if (isImplicitRule) return;
|
|
10847
|
-
fixedElements.set(element, true);
|
|
10848
|
-
var points = [];
|
|
10849
|
-
var rules = getRules(value, points);
|
|
10850
|
-
var parentRules = parent.props;
|
|
10851
|
-
for (var i = 0, k = 0; i < rules.length; i++) for (var j = 0; j < parentRules.length; j++, k++) element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
|
|
10852
|
-
};
|
|
10853
|
-
var removeLabel = function removeLabel(element) {
|
|
10854
|
-
if (element.type === "decl") {
|
|
10855
|
-
var value = element.value;
|
|
10856
|
-
if (value.charCodeAt(0) === 108 && value.charCodeAt(2) === 98) {
|
|
10857
|
-
element["return"] = "";
|
|
10858
|
-
element.value = "";
|
|
10859
|
-
}
|
|
10860
|
-
}
|
|
10861
|
-
};
|
|
10862
|
-
function prefix(value, length) {
|
|
10863
|
-
switch (hash(value, length)) {
|
|
10864
|
-
case 5103: return WEBKIT + "print-" + value + value;
|
|
10865
|
-
case 5737:
|
|
10866
|
-
case 4201:
|
|
10867
|
-
case 3177:
|
|
10868
|
-
case 3433:
|
|
10869
|
-
case 1641:
|
|
10870
|
-
case 4457:
|
|
10871
|
-
case 2921:
|
|
10872
|
-
case 5572:
|
|
10873
|
-
case 6356:
|
|
10874
|
-
case 5844:
|
|
10875
|
-
case 3191:
|
|
10876
|
-
case 6645:
|
|
10877
|
-
case 3005:
|
|
10878
|
-
case 6391:
|
|
10879
|
-
case 5879:
|
|
10880
|
-
case 5623:
|
|
10881
|
-
case 6135:
|
|
10882
|
-
case 4599:
|
|
10883
|
-
case 4855:
|
|
10884
|
-
case 4215:
|
|
10885
|
-
case 6389:
|
|
10886
|
-
case 5109:
|
|
10887
|
-
case 5365:
|
|
10888
|
-
case 5621:
|
|
10889
|
-
case 3829: return WEBKIT + value + value;
|
|
10890
|
-
case 5349:
|
|
10891
|
-
case 4246:
|
|
10892
|
-
case 4810:
|
|
10893
|
-
case 6968:
|
|
10894
|
-
case 2756: return WEBKIT + value + MOZ + value + MS + value + value;
|
|
10895
|
-
case 6828:
|
|
10896
|
-
case 4268: return WEBKIT + value + MS + value + value;
|
|
10897
|
-
case 6165: return WEBKIT + value + MS + "flex-" + value + value;
|
|
10898
|
-
case 5187: return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value;
|
|
10899
|
-
case 5443: return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value;
|
|
10900
|
-
case 4675: return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value;
|
|
10901
|
-
case 5548: return WEBKIT + value + MS + replace(value, "shrink", "negative") + value;
|
|
10902
|
-
case 5292: return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value;
|
|
10903
|
-
case 6060: return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value;
|
|
10904
|
-
case 4554: return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value;
|
|
10905
|
-
case 6187: return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value;
|
|
10906
|
-
case 5495:
|
|
10907
|
-
case 3959: return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1");
|
|
10908
|
-
case 4968: return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value;
|
|
10909
|
-
case 4095:
|
|
10910
|
-
case 3583:
|
|
10911
|
-
case 4068:
|
|
10912
|
-
case 2532: return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value;
|
|
10913
|
-
case 8116:
|
|
10914
|
-
case 7059:
|
|
10915
|
-
case 5753:
|
|
10916
|
-
case 5535:
|
|
10917
|
-
case 5445:
|
|
10918
|
-
case 5701:
|
|
10919
|
-
case 4933:
|
|
10920
|
-
case 4677:
|
|
10921
|
-
case 5533:
|
|
10922
|
-
case 5789:
|
|
10923
|
-
case 5021:
|
|
10924
|
-
case 4765:
|
|
10925
|
-
if (strlen(value) - 1 - length > 6) switch (charat(value, length + 1)) {
|
|
10926
|
-
case 109: if (charat(value, length + 4) !== 45) break;
|
|
10927
|
-
case 102: return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (charat(value, length + 3) == 108 ? "$3" : "$2-$3")) + value;
|
|
10928
|
-
case 115: return ~indexof(value, "stretch") ? prefix(replace(value, "stretch", "fill-available"), length) + value : value;
|
|
10929
|
-
}
|
|
10930
|
-
break;
|
|
10931
|
-
case 4949: if (charat(value, length + 1) !== 115) break;
|
|
10932
|
-
case 6444:
|
|
10933
|
-
switch (charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))) {
|
|
10934
|
-
case 107: return replace(value, ":", ":" + WEBKIT) + value;
|
|
10935
|
-
case 101: return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value;
|
|
10936
|
-
}
|
|
10937
|
-
break;
|
|
10938
|
-
case 5936:
|
|
10939
|
-
switch (charat(value, length + 11)) {
|
|
10940
|
-
case 114: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value;
|
|
10941
|
-
case 108: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value;
|
|
10942
|
-
case 45: return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value;
|
|
10943
|
-
}
|
|
10944
|
-
return WEBKIT + value + MS + value + value;
|
|
10945
|
-
}
|
|
10946
|
-
return value;
|
|
10947
|
-
}
|
|
10948
|
-
var prefixer = function prefixer(element, index, children, callback) {
|
|
10949
|
-
if (element.length > -1) {
|
|
10950
|
-
if (!element["return"]) switch (element.type) {
|
|
10951
|
-
case DECLARATION:
|
|
10952
|
-
element["return"] = prefix(element.value, element.length);
|
|
10953
|
-
break;
|
|
10954
|
-
case KEYFRAMES: return serialize([copy(element, { value: replace(element.value, "@", "@" + WEBKIT) })], callback);
|
|
10955
|
-
case RULESET: if (element.length) return combine(element.props, function(value) {
|
|
10956
|
-
switch (match(value, /(::plac\w+|:read-\w+)/)) {
|
|
10957
|
-
case ":read-only":
|
|
10958
|
-
case ":read-write": return serialize([copy(element, { props: [replace(value, /:(read-\w+)/, ":" + MOZ + "$1")] })], callback);
|
|
10959
|
-
case "::placeholder": return serialize([
|
|
10960
|
-
copy(element, { props: [replace(value, /:(plac\w+)/, ":" + WEBKIT + "input-$1")] }),
|
|
10961
|
-
copy(element, { props: [replace(value, /:(plac\w+)/, ":" + MOZ + "$1")] }),
|
|
10962
|
-
copy(element, { props: [replace(value, /:(plac\w+)/, MS + "input-$1")] })
|
|
10963
|
-
], callback);
|
|
10964
|
-
}
|
|
10965
|
-
return "";
|
|
10966
|
-
});
|
|
10967
|
-
}
|
|
10968
|
-
}
|
|
10969
|
-
};
|
|
10970
|
-
var getServerStylisCache = isBrowser$2 ? void 0 : weakMemoize(function() {
|
|
10971
|
-
return memoize(function() {
|
|
10972
|
-
return {};
|
|
10973
|
-
});
|
|
10974
|
-
});
|
|
10975
|
-
var defaultStylisPlugins = [prefixer];
|
|
10976
|
-
var createCache = function createCache(options) {
|
|
10977
|
-
var key = options.key;
|
|
10978
|
-
if (isBrowser$2 && key === "css") {
|
|
10979
|
-
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])");
|
|
10980
|
-
Array.prototype.forEach.call(ssrStyles, function(node) {
|
|
10981
|
-
if (node.getAttribute("data-emotion").indexOf(" ") === -1) return;
|
|
10982
|
-
document.head.appendChild(node);
|
|
10983
|
-
node.setAttribute("data-s", "");
|
|
10984
|
-
});
|
|
10985
|
-
}
|
|
10986
|
-
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
|
|
10987
|
-
var inserted = {};
|
|
10988
|
-
var container;
|
|
10989
|
-
var nodesToHydrate = [];
|
|
10990
|
-
if (isBrowser$2) {
|
|
10991
|
-
container = options.container || document.head;
|
|
10992
|
-
Array.prototype.forEach.call(document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function(node) {
|
|
10993
|
-
var attrib = node.getAttribute("data-emotion").split(" ");
|
|
10994
|
-
for (var i = 1; i < attrib.length; i++) inserted[attrib[i]] = true;
|
|
10995
|
-
nodesToHydrate.push(node);
|
|
10996
|
-
});
|
|
10997
|
-
}
|
|
10998
|
-
var _insert;
|
|
10999
|
-
var omnipresentPlugins = [compat, removeLabel];
|
|
11000
|
-
if (!getServerStylisCache) {
|
|
11001
|
-
var currentSheet;
|
|
11002
|
-
var finalizingPlugins = [stringify, rulesheet(function(rule) {
|
|
11003
|
-
currentSheet.insert(rule);
|
|
11004
|
-
})];
|
|
11005
|
-
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
|
|
11006
|
-
var stylis = function stylis(styles) {
|
|
11007
|
-
return serialize(compile(styles), serializer);
|
|
11008
|
-
};
|
|
11009
|
-
_insert = function insert(selector, serialized, sheet, shouldCache) {
|
|
11010
|
-
currentSheet = sheet;
|
|
11011
|
-
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
|
11012
|
-
if (shouldCache) cache.inserted[serialized.name] = true;
|
|
11013
|
-
};
|
|
11014
|
-
} else {
|
|
11015
|
-
var _finalizingPlugins = [stringify];
|
|
11016
|
-
var _serializer = middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
|
|
11017
|
-
var _stylis = function _stylis(styles) {
|
|
11018
|
-
return serialize(compile(styles), _serializer);
|
|
11019
|
-
};
|
|
11020
|
-
var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
|
|
11021
|
-
var getRules = function getRules(selector, serialized) {
|
|
11022
|
-
var name = serialized.name;
|
|
11023
|
-
if (serverStylisCache[name] === void 0) serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
|
11024
|
-
return serverStylisCache[name];
|
|
11025
|
-
};
|
|
11026
|
-
_insert = function _insert(selector, serialized, sheet, shouldCache) {
|
|
11027
|
-
var name = serialized.name;
|
|
11028
|
-
var rules = getRules(selector, serialized);
|
|
11029
|
-
if (cache.compat === void 0) {
|
|
11030
|
-
if (shouldCache) cache.inserted[name] = true;
|
|
11031
|
-
return rules;
|
|
11032
|
-
} else if (shouldCache) cache.inserted[name] = rules;
|
|
11033
|
-
else return rules;
|
|
11034
|
-
};
|
|
11035
|
-
}
|
|
11036
|
-
var cache = {
|
|
11037
|
-
key,
|
|
11038
|
-
sheet: new StyleSheet({
|
|
11039
|
-
key,
|
|
11040
|
-
container,
|
|
11041
|
-
nonce: options.nonce,
|
|
11042
|
-
speedy: options.speedy,
|
|
11043
|
-
prepend: options.prepend,
|
|
11044
|
-
insertionPoint: options.insertionPoint
|
|
11045
|
-
}),
|
|
11046
|
-
nonce: options.nonce,
|
|
11047
|
-
inserted,
|
|
11048
|
-
registered: {},
|
|
11049
|
-
insert: _insert
|
|
11050
|
-
};
|
|
11051
|
-
cache.sheet.hydrate(nodesToHydrate);
|
|
11052
|
-
return cache;
|
|
11053
|
-
};
|
|
11054
|
-
// ../../../node_modules/.pnpm/@emotion+utils@1.4.2/node_modules/@emotion/utils/dist/emotion-utils.esm.js
|
|
11055
|
-
var isBrowser$1 = typeof document !== "undefined";
|
|
11056
|
-
function getRegisteredStyles$1(registered, registeredStyles, classNames) {
|
|
11057
|
-
var rawClassName = "";
|
|
11058
|
-
classNames.split(" ").forEach(function(className) {
|
|
11059
|
-
if (registered[className] !== void 0) registeredStyles.push(registered[className] + ";");
|
|
11060
|
-
else if (className) rawClassName += className + " ";
|
|
11061
|
-
});
|
|
11062
|
-
return rawClassName;
|
|
11063
|
-
}
|
|
11064
|
-
var registerStyles = function registerStyles(cache, serialized, isStringTag) {
|
|
11065
|
-
var className = cache.key + "-" + serialized.name;
|
|
11066
|
-
if ((isStringTag === false || isBrowser$1 === false && cache.compat !== void 0) && cache.registered[className] === void 0) cache.registered[className] = serialized.styles;
|
|
11067
|
-
};
|
|
11068
|
-
var insertStyles = function insertStyles(cache, serialized, isStringTag) {
|
|
11069
|
-
registerStyles(cache, serialized, isStringTag);
|
|
11070
|
-
var className = cache.key + "-" + serialized.name;
|
|
11071
|
-
if (cache.inserted[serialized.name] === void 0) {
|
|
11072
|
-
var stylesForSSR = "";
|
|
11073
|
-
var current = serialized;
|
|
11074
|
-
do {
|
|
11075
|
-
var maybeStyles = cache.insert(serialized === current ? "." + className : "", current, cache.sheet, true);
|
|
11076
|
-
if (!isBrowser$1 && maybeStyles !== void 0) stylesForSSR += maybeStyles;
|
|
11077
|
-
current = current.next;
|
|
11078
|
-
} while (current !== void 0);
|
|
11079
|
-
if (!isBrowser$1 && stylesForSSR.length !== 0) return stylesForSSR;
|
|
11080
|
-
}
|
|
11081
|
-
};
|
|
11082
|
-
// ../../../node_modules/.pnpm/@emotion+hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js
|
|
11083
|
-
function murmur2(str) {
|
|
11084
|
-
var h = 0;
|
|
11085
|
-
var k, i = 0, len = str.length;
|
|
11086
|
-
for (; len >= 4; ++i, len -= 4) {
|
|
11087
|
-
k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
|
|
11088
|
-
k = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16);
|
|
11089
|
-
k ^= k >>> 24;
|
|
11090
|
-
h = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16) ^ (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
|
11091
|
-
}
|
|
11092
|
-
switch (len) {
|
|
11093
|
-
case 3: h ^= (str.charCodeAt(i + 2) & 255) << 16;
|
|
11094
|
-
case 2: h ^= (str.charCodeAt(i + 1) & 255) << 8;
|
|
11095
|
-
case 1:
|
|
11096
|
-
h ^= str.charCodeAt(i) & 255;
|
|
11097
|
-
h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
|
11098
|
-
}
|
|
11099
|
-
h ^= h >>> 13;
|
|
11100
|
-
h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
|
11101
|
-
return ((h ^ h >>> 15) >>> 0).toString(36);
|
|
11102
|
-
}
|
|
11103
|
-
// ../../../node_modules/.pnpm/@emotion+unitless@0.10.0/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js
|
|
11104
|
-
var unitlessKeys = {
|
|
11105
|
-
animationIterationCount: 1,
|
|
11106
|
-
aspectRatio: 1,
|
|
11107
|
-
borderImageOutset: 1,
|
|
11108
|
-
borderImageSlice: 1,
|
|
11109
|
-
borderImageWidth: 1,
|
|
11110
|
-
boxFlex: 1,
|
|
11111
|
-
boxFlexGroup: 1,
|
|
11112
|
-
boxOrdinalGroup: 1,
|
|
11113
|
-
columnCount: 1,
|
|
11114
|
-
columns: 1,
|
|
11115
|
-
flex: 1,
|
|
11116
|
-
flexGrow: 1,
|
|
11117
|
-
flexPositive: 1,
|
|
11118
|
-
flexShrink: 1,
|
|
11119
|
-
flexNegative: 1,
|
|
11120
|
-
flexOrder: 1,
|
|
11121
|
-
gridRow: 1,
|
|
11122
|
-
gridRowEnd: 1,
|
|
11123
|
-
gridRowSpan: 1,
|
|
11124
|
-
gridRowStart: 1,
|
|
11125
|
-
gridColumn: 1,
|
|
11126
|
-
gridColumnEnd: 1,
|
|
11127
|
-
gridColumnSpan: 1,
|
|
11128
|
-
gridColumnStart: 1,
|
|
11129
|
-
msGridRow: 1,
|
|
11130
|
-
msGridRowSpan: 1,
|
|
11131
|
-
msGridColumn: 1,
|
|
11132
|
-
msGridColumnSpan: 1,
|
|
11133
|
-
fontWeight: 1,
|
|
11134
|
-
lineHeight: 1,
|
|
11135
|
-
opacity: 1,
|
|
11136
|
-
order: 1,
|
|
11137
|
-
orphans: 1,
|
|
11138
|
-
scale: 1,
|
|
11139
|
-
tabSize: 1,
|
|
11140
|
-
widows: 1,
|
|
11141
|
-
zIndex: 1,
|
|
11142
|
-
zoom: 1,
|
|
11143
|
-
WebkitLineClamp: 1,
|
|
11144
|
-
fillOpacity: 1,
|
|
11145
|
-
floodOpacity: 1,
|
|
11146
|
-
stopOpacity: 1,
|
|
11147
|
-
strokeDasharray: 1,
|
|
11148
|
-
strokeDashoffset: 1,
|
|
11149
|
-
strokeMiterlimit: 1,
|
|
11150
|
-
strokeOpacity: 1,
|
|
11151
|
-
strokeWidth: 1
|
|
11152
|
-
};
|
|
11153
|
-
// ../../../node_modules/.pnpm/@emotion+serialize@1.3.3/node_modules/@emotion/serialize/dist/emotion-serialize.esm.js
|
|
11154
|
-
var isDevelopment = false;
|
|
11155
|
-
var hyphenateRegex = /[A-Z]|^ms/g;
|
|
11156
|
-
var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
|
|
11157
|
-
var isCustomProperty = function isCustomProperty(property) {
|
|
11158
|
-
return property.charCodeAt(1) === 45;
|
|
11159
|
-
};
|
|
11160
|
-
var isProcessableValue = function isProcessableValue(value) {
|
|
11161
|
-
return value != null && typeof value !== "boolean";
|
|
11162
|
-
};
|
|
11163
|
-
var processStyleName = /* #__PURE__ */ memoize(function(styleName) {
|
|
11164
|
-
return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase();
|
|
11165
|
-
});
|
|
11166
|
-
var processStyleValue = function processStyleValue(key, value) {
|
|
11167
|
-
switch (key) {
|
|
11168
|
-
case "animation":
|
|
11169
|
-
case "animationName": if (typeof value === "string") return value.replace(animationRegex, function(match, p1, p2) {
|
|
11170
|
-
cursor = {
|
|
11171
|
-
name: p1,
|
|
11172
|
-
styles: p2,
|
|
11173
|
-
next: cursor
|
|
11174
|
-
};
|
|
11175
|
-
return p1;
|
|
11176
|
-
});
|
|
11177
|
-
}
|
|
11178
|
-
if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === "number" && value !== 0) return value + "px";
|
|
11179
|
-
return value;
|
|
11180
|
-
};
|
|
11181
|
-
var noComponentSelectorMessage = "Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";
|
|
11182
|
-
function handleInterpolation(mergedProps, registered, interpolation) {
|
|
11183
|
-
if (interpolation == null) return "";
|
|
11184
|
-
var componentSelector = interpolation;
|
|
11185
|
-
if (componentSelector.__emotion_styles !== void 0) return componentSelector;
|
|
11186
|
-
switch (typeof interpolation) {
|
|
11187
|
-
case "boolean": return "";
|
|
11188
|
-
case "object":
|
|
11189
|
-
var keyframes = interpolation;
|
|
11190
|
-
if (keyframes.anim === 1) {
|
|
11191
|
-
cursor = {
|
|
11192
|
-
name: keyframes.name,
|
|
11193
|
-
styles: keyframes.styles,
|
|
11194
|
-
next: cursor
|
|
11195
|
-
};
|
|
11196
|
-
return keyframes.name;
|
|
11197
|
-
}
|
|
11198
|
-
var serializedStyles = interpolation;
|
|
11199
|
-
if (serializedStyles.styles !== void 0) {
|
|
11200
|
-
var next = serializedStyles.next;
|
|
11201
|
-
if (next !== void 0) while (next !== void 0) {
|
|
11202
|
-
cursor = {
|
|
11203
|
-
name: next.name,
|
|
11204
|
-
styles: next.styles,
|
|
11205
|
-
next: cursor
|
|
11206
|
-
};
|
|
11207
|
-
next = next.next;
|
|
11208
|
-
}
|
|
11209
|
-
return serializedStyles.styles + ";";
|
|
11210
|
-
}
|
|
11211
|
-
return createStringFromObject(mergedProps, registered, interpolation);
|
|
11212
|
-
case "function": if (mergedProps !== void 0) {
|
|
11213
|
-
var previousCursor = cursor;
|
|
11214
|
-
var result = interpolation(mergedProps);
|
|
11215
|
-
cursor = previousCursor;
|
|
11216
|
-
return handleInterpolation(mergedProps, registered, result);
|
|
11217
|
-
}
|
|
11218
|
-
}
|
|
11219
|
-
var asString = interpolation;
|
|
11220
|
-
if (registered == null) return asString;
|
|
11221
|
-
var cached = registered[asString];
|
|
11222
|
-
return cached !== void 0 ? cached : asString;
|
|
11223
|
-
}
|
|
11224
|
-
function createStringFromObject(mergedProps, registered, obj) {
|
|
11225
|
-
var string = "";
|
|
11226
|
-
if (Array.isArray(obj)) for (var i = 0; i < obj.length; i++) string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
|
|
11227
|
-
else for (var key in obj) {
|
|
11228
|
-
var value = obj[key];
|
|
11229
|
-
if (typeof value !== "object") {
|
|
11230
|
-
var asString = value;
|
|
11231
|
-
if (registered != null && registered[asString] !== void 0) string += key + "{" + registered[asString] + "}";
|
|
11232
|
-
else if (isProcessableValue(asString)) string += processStyleName(key) + ":" + processStyleValue(key, asString) + ";";
|
|
11233
|
-
} else {
|
|
11234
|
-
if (key === "NO_COMPONENT_SELECTOR" && isDevelopment) throw new Error(noComponentSelectorMessage);
|
|
11235
|
-
if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) {
|
|
11236
|
-
for (var _i = 0; _i < value.length; _i++) if (isProcessableValue(value[_i])) string += processStyleName(key) + ":" + processStyleValue(key, value[_i]) + ";";
|
|
11237
|
-
} else {
|
|
11238
|
-
var interpolated = handleInterpolation(mergedProps, registered, value);
|
|
11239
|
-
switch (key) {
|
|
11240
|
-
case "animation":
|
|
11241
|
-
case "animationName":
|
|
11242
|
-
string += processStyleName(key) + ":" + interpolated + ";";
|
|
11243
|
-
break;
|
|
11244
|
-
default: string += key + "{" + interpolated + "}";
|
|
11245
|
-
}
|
|
11246
|
-
}
|
|
11247
|
-
}
|
|
11248
|
-
}
|
|
11249
|
-
return string;
|
|
11250
|
-
}
|
|
11251
|
-
var labelPattern = /label:\s*([^\s;{]+)\s*(;|$)/g;
|
|
11252
|
-
var cursor;
|
|
11253
|
-
function serializeStyles(args, registered, mergedProps) {
|
|
11254
|
-
if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) return args[0];
|
|
11255
|
-
var stringMode = true;
|
|
11256
|
-
var styles = "";
|
|
11257
|
-
cursor = void 0;
|
|
11258
|
-
var strings = args[0];
|
|
11259
|
-
if (strings == null || strings.raw === void 0) {
|
|
11260
|
-
stringMode = false;
|
|
11261
|
-
styles += handleInterpolation(mergedProps, registered, strings);
|
|
11262
|
-
} else styles += strings[0];
|
|
11263
|
-
for (var i = 1; i < args.length; i++) {
|
|
11264
|
-
styles += handleInterpolation(mergedProps, registered, args[i]);
|
|
11265
|
-
if (stringMode) styles += strings[i];
|
|
11266
|
-
}
|
|
11267
|
-
labelPattern.lastIndex = 0;
|
|
11268
|
-
var identifierName = "";
|
|
11269
|
-
var match;
|
|
11270
|
-
while ((match = labelPattern.exec(styles)) !== null) identifierName += "-" + match[1];
|
|
11271
|
-
return {
|
|
11272
|
-
name: murmur2(styles) + identifierName,
|
|
11273
|
-
styles,
|
|
11274
|
-
next: cursor
|
|
11275
|
-
};
|
|
11276
|
-
}
|
|
11277
|
-
react["useInsertionEffect"] && react["useInsertionEffect"] || react.useLayoutEffect;
|
|
11278
|
-
// ../../../node_modules/.pnpm/@emotion+react@11.14.0_@types+react@19.3.0_react@19.3.0/node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js
|
|
11279
|
-
var isBrowser = typeof document !== "undefined";
|
|
11280
|
-
var EmotionCacheContext = /* #__PURE__ */ react.createContext(typeof HTMLElement !== "undefined" ? /* #__PURE__ */ createCache({ key: "css" }) : null);
|
|
11281
|
-
EmotionCacheContext.Provider;
|
|
11282
|
-
var __unsafe_useEmotionCache = function useEmotionCache() {
|
|
11283
|
-
return (0, react.useContext)(EmotionCacheContext);
|
|
11284
|
-
};
|
|
11285
|
-
if (!isBrowser);
|
|
11286
|
-
({}).hasOwnProperty;
|
|
11287
|
-
// ../../../node_modules/.pnpm/@emotion+css@11.13.5/node_modules/@emotion/css/create-instance/dist/emotion-css-create-instance.esm.js
|
|
11288
|
-
function insertWithoutScoping(cache, serialized) {
|
|
11289
|
-
if (cache.inserted[serialized.name] === void 0) return cache.insert("", serialized, cache.sheet, true);
|
|
11290
|
-
}
|
|
11291
|
-
function merge$1(registered, css, className) {
|
|
11292
|
-
var registeredStyles = [];
|
|
11293
|
-
var rawClassName = getRegisteredStyles$1(registered, registeredStyles, className);
|
|
11294
|
-
if (registeredStyles.length < 2) return className;
|
|
11295
|
-
return rawClassName + css(registeredStyles);
|
|
11296
|
-
}
|
|
11297
|
-
var createEmotion = function createEmotion(options) {
|
|
11298
|
-
var cache = createCache(options);
|
|
11299
|
-
cache.sheet.speedy = function(value) {
|
|
11300
|
-
this.isSpeedy = value;
|
|
11301
|
-
};
|
|
11302
|
-
cache.compat = true;
|
|
11303
|
-
var css = function css() {
|
|
11304
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
|
|
11305
|
-
var serialized = serializeStyles(args, cache.registered, void 0);
|
|
11306
|
-
insertStyles(cache, serialized, false);
|
|
11307
|
-
return cache.key + "-" + serialized.name;
|
|
11308
|
-
};
|
|
11309
|
-
return {
|
|
11310
|
-
css,
|
|
11311
|
-
cx: function cx() {
|
|
11312
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
|
|
11313
|
-
return merge$1(cache.registered, css, classnames(args));
|
|
11314
|
-
},
|
|
11315
|
-
injectGlobal: function injectGlobal() {
|
|
11316
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) args[_key3] = arguments[_key3];
|
|
11317
|
-
insertWithoutScoping(cache, serializeStyles(args, cache.registered));
|
|
11318
|
-
},
|
|
11319
|
-
keyframes: function keyframes() {
|
|
11320
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) args[_key2] = arguments[_key2];
|
|
11321
|
-
var serialized = serializeStyles(args, cache.registered);
|
|
11322
|
-
var animation = "animation-" + serialized.name;
|
|
11323
|
-
insertWithoutScoping(cache, {
|
|
11324
|
-
name: serialized.name,
|
|
11325
|
-
styles: "@keyframes " + animation + "{" + serialized.styles + "}"
|
|
11326
|
-
});
|
|
11327
|
-
return animation;
|
|
11328
|
-
},
|
|
11329
|
-
hydrate: function hydrate(ids) {
|
|
11330
|
-
ids.forEach(function(key) {
|
|
11331
|
-
cache.inserted[key] = true;
|
|
11332
|
-
});
|
|
11333
|
-
},
|
|
11334
|
-
flush: function flush() {
|
|
11335
|
-
cache.registered = {};
|
|
11336
|
-
cache.inserted = {};
|
|
11337
|
-
cache.sheet.flush();
|
|
11338
|
-
},
|
|
11339
|
-
sheet: cache.sheet,
|
|
11340
|
-
cache,
|
|
11341
|
-
getRegisteredStyles: getRegisteredStyles$1.bind(null, cache.registered),
|
|
11342
|
-
merge: merge$1.bind(null, cache.registered, css)
|
|
11343
|
-
};
|
|
11344
|
-
};
|
|
11345
|
-
var classnames = function classnames(args) {
|
|
11346
|
-
var cls = "";
|
|
11347
|
-
for (var i = 0; i < args.length; i++) {
|
|
11348
|
-
var arg = args[i];
|
|
11349
|
-
if (arg == null) continue;
|
|
11350
|
-
var toAdd = void 0;
|
|
11351
|
-
switch (typeof arg) {
|
|
11352
|
-
case "boolean": break;
|
|
11353
|
-
case "object":
|
|
11354
|
-
if (Array.isArray(arg)) toAdd = classnames(arg);
|
|
11355
|
-
else {
|
|
11356
|
-
toAdd = "";
|
|
11357
|
-
for (var k in arg) if (arg[k] && k) {
|
|
11358
|
-
toAdd && (toAdd += " ");
|
|
11359
|
-
toAdd += k;
|
|
11360
|
-
}
|
|
11361
|
-
}
|
|
11362
|
-
break;
|
|
11363
|
-
default: toAdd = arg;
|
|
11364
|
-
}
|
|
11365
|
-
if (toAdd) {
|
|
11366
|
-
cls && (cls += " ");
|
|
11367
|
-
cls += toAdd;
|
|
11368
|
-
}
|
|
11369
|
-
}
|
|
11370
|
-
return cls;
|
|
11371
|
-
};
|
|
11372
|
-
// ../../../node_modules/.pnpm/@emotion+css@11.13.5/node_modules/@emotion/css/dist/emotion-css.esm.js
|
|
11373
|
-
var _createEmotion = createEmotion({ key: "css" });
|
|
11374
|
-
_createEmotion.flush;
|
|
11375
|
-
_createEmotion.hydrate;
|
|
11376
|
-
var cx = _createEmotion.cx;
|
|
11377
|
-
_createEmotion.merge;
|
|
11378
|
-
_createEmotion.getRegisteredStyles;
|
|
11379
|
-
_createEmotion.injectGlobal;
|
|
11380
|
-
_createEmotion.keyframes;
|
|
11381
|
-
_createEmotion.css;
|
|
11382
|
-
_createEmotion.sheet;
|
|
11383
|
-
_createEmotion.cache;
|
|
11384
|
-
// ../../../node_modules/.pnpm/@wordpress+components@42.0.0_@date-fns+tz@1.5.0_@types+react-dom@19.3.0_@types+react@19_6d0393a58a031b78f608040e2ecbe6e0/node_modules/@wordpress/components/build-module/utils/hooks/use-cx.mjs
|
|
11385
|
-
var isSerializedStyles = (o) => typeof o !== "undefined" && o !== null && ["name", "styles"].every((p) => typeof o[p] !== "undefined");
|
|
11386
|
-
var useCx = () => {
|
|
11387
|
-
const cache = __unsafe_useEmotionCache();
|
|
11388
|
-
return (0, react.useCallback)((...classNames) => {
|
|
11389
|
-
if (cache === null) throw new Error("The `useCx` hook should be only used within a valid Emotion Cache Context");
|
|
11390
|
-
return cx(...classNames.map((arg) => {
|
|
11391
|
-
if (isSerializedStyles(arg)) {
|
|
11392
|
-
insertStyles(cache, arg, false);
|
|
11393
|
-
return `${cache.key}-${arg.name}`;
|
|
11394
|
-
}
|
|
11395
|
-
return arg;
|
|
11396
|
-
}));
|
|
11397
|
-
}, [cache]);
|
|
11398
|
-
};
|
|
11399
|
-
// ../../../node_modules/.pnpm/memize@2.1.1/node_modules/memize/dist/index.js
|
|
11400
|
-
/**
|
|
11401
|
-
* Memize options object.
|
|
11402
|
-
*
|
|
11403
|
-
* @typedef MemizeOptions
|
|
11404
|
-
*
|
|
11405
|
-
* @property {number} [maxSize] Maximum size of the cache.
|
|
11406
|
-
*/
|
|
11407
|
-
/**
|
|
11408
|
-
* Internal cache entry.
|
|
11409
|
-
*
|
|
11410
|
-
* @typedef MemizeCacheNode
|
|
11411
|
-
*
|
|
11412
|
-
* @property {?MemizeCacheNode|undefined} [prev] Previous node.
|
|
11413
|
-
* @property {?MemizeCacheNode|undefined} [next] Next node.
|
|
11414
|
-
* @property {Array<*>} args Function arguments for cache
|
|
11415
|
-
* entry.
|
|
11416
|
-
* @property {*} val Function result.
|
|
11417
|
-
*/
|
|
11418
|
-
/**
|
|
11419
|
-
* Properties of the enhanced function for controlling cache.
|
|
11420
|
-
*
|
|
11421
|
-
* @typedef MemizeMemoizedFunction
|
|
11422
|
-
*
|
|
11423
|
-
* @property {()=>void} clear Clear the cache.
|
|
10749
|
+
* Properties of the enhanced function for controlling cache.
|
|
10750
|
+
*
|
|
10751
|
+
* @typedef MemizeMemoizedFunction
|
|
10752
|
+
*
|
|
10753
|
+
* @property {()=>void} clear Clear the cache.
|
|
11424
10754
|
*/
|
|
11425
10755
|
/**
|
|
11426
10756
|
* Accepts a function to be memoized, and returns a new memoized function, with
|
|
@@ -11486,91 +10816,37 @@ function memize(fn, options) {
|
|
|
11486
10816
|
};
|
|
11487
10817
|
return memoized;
|
|
11488
10818
|
}
|
|
11489
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
11490
|
-
var import_es6 = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11491
|
-
module.exports = function equal(a, b) {
|
|
11492
|
-
if (a === b) return true;
|
|
11493
|
-
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
11494
|
-
if (a.constructor !== b.constructor) return false;
|
|
11495
|
-
var length, i, keys;
|
|
11496
|
-
if (Array.isArray(a)) {
|
|
11497
|
-
length = a.length;
|
|
11498
|
-
if (length != b.length) return false;
|
|
11499
|
-
for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;
|
|
11500
|
-
return true;
|
|
11501
|
-
}
|
|
11502
|
-
if (a instanceof Map && b instanceof Map) {
|
|
11503
|
-
if (a.size !== b.size) return false;
|
|
11504
|
-
for (i of a.entries()) if (!b.has(i[0])) return false;
|
|
11505
|
-
for (i of a.entries()) if (!equal(i[1], b.get(i[0]))) return false;
|
|
11506
|
-
return true;
|
|
11507
|
-
}
|
|
11508
|
-
if (a instanceof Set && b instanceof Set) {
|
|
11509
|
-
if (a.size !== b.size) return false;
|
|
11510
|
-
for (i of a.entries()) if (!b.has(i[0])) return false;
|
|
11511
|
-
return true;
|
|
11512
|
-
}
|
|
11513
|
-
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
11514
|
-
length = a.length;
|
|
11515
|
-
if (length != b.length) return false;
|
|
11516
|
-
for (i = length; i-- !== 0;) if (a[i] !== b[i]) return false;
|
|
11517
|
-
return true;
|
|
11518
|
-
}
|
|
11519
|
-
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
11520
|
-
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
11521
|
-
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
11522
|
-
keys = Object.keys(a);
|
|
11523
|
-
length = keys.length;
|
|
11524
|
-
if (length !== Object.keys(b).length) return false;
|
|
11525
|
-
for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
11526
|
-
for (i = length; i-- !== 0;) {
|
|
11527
|
-
var key = keys[i];
|
|
11528
|
-
if (!equal(a[key], b[key])) return false;
|
|
11529
|
-
}
|
|
11530
|
-
return true;
|
|
11531
|
-
}
|
|
11532
|
-
return a !== a && b !== b;
|
|
11533
|
-
};
|
|
11534
|
-
})))(), 1);
|
|
11535
|
-
var ComponentsContext = (0, react.createContext)({});
|
|
11536
|
-
ComponentsContext.displayName = "ComponentsContext";
|
|
11537
|
-
var useComponentsContext = () => (0, react.useContext)(ComponentsContext);
|
|
11538
|
-
function useContextSystemBridge({ value }) {
|
|
11539
|
-
const parentContext = useComponentsContext();
|
|
11540
|
-
const valueRef = (0, react.useRef)(value);
|
|
11541
|
-
use_update_effect_default(() => {
|
|
11542
|
-
if ((0, import_es6.default)(valueRef.current, value) && valueRef.current !== value) globalThis.SCRIPT_DEBUG === true && warning(`Please memoize your context: ${JSON.stringify(value)}`);
|
|
11543
|
-
}, [value]);
|
|
11544
|
-
return (0, react.useMemo)(() => {
|
|
11545
|
-
return (0, deepmerge.default)(parentContext ?? {}, value ?? {}, { isMergeableObject: isPlainObject });
|
|
11546
|
-
}, [parentContext, value]);
|
|
11547
|
-
}
|
|
11548
|
-
var BaseContextSystemProvider = ({ children, value }) => {
|
|
11549
|
-
const contextValue = useContextSystemBridge({ value });
|
|
11550
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentsContext.Provider, {
|
|
11551
|
-
value: contextValue,
|
|
11552
|
-
children
|
|
11553
|
-
});
|
|
11554
|
-
};
|
|
11555
|
-
(0, react.memo)(BaseContextSystemProvider);
|
|
11556
|
-
// ../../../node_modules/.pnpm/@wordpress+components@42.0.0_@date-fns+tz@1.5.0_@types+react-dom@19.3.0_@types+react@19_6d0393a58a031b78f608040e2ecbe6e0/node_modules/@wordpress/components/build-module/context/constants.mjs
|
|
11557
|
-
var COMPONENT_NAMESPACE = "data-wp-component";
|
|
11558
|
-
var CONNECTED_NAMESPACE = "data-wp-c16t";
|
|
11559
|
-
var CONNECT_STATIC_NAMESPACE = "__contextSystemKey__";
|
|
11560
|
-
// ../../../node_modules/.pnpm/@wordpress+components@42.0.0_@date-fns+tz@1.5.0_@types+react-dom@19.3.0_@types+react@19_6d0393a58a031b78f608040e2ecbe6e0/node_modules/@wordpress/components/build-module/context/get-styled-class-name-from-key.mjs
|
|
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
|
|
11561
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
|
+
*/
|
|
11562
10827
|
function getStyledClassName(namespace) {
|
|
11563
10828
|
return `components-${(0, import_dist.paramCase)(namespace)}`;
|
|
11564
10829
|
}
|
|
11565
|
-
|
|
11566
|
-
// ../../../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
|
+
*/
|
|
11567
10840
|
function contextConnect(Component, namespace) {
|
|
11568
10841
|
return _contextConnect(Component, namespace, { forwardsRef: true });
|
|
11569
10842
|
}
|
|
11570
10843
|
function _contextConnect(Component, namespace, options) {
|
|
11571
10844
|
const WrappedComponent = options?.forwardsRef ? (0, react.forwardRef)(Component) : Component;
|
|
11572
|
-
if (typeof namespace === "undefined")
|
|
10845
|
+
if (typeof namespace === "undefined") warning("contextConnect: Please provide a namespace");
|
|
11573
10846
|
let mergedNamespace = WrappedComponent["__contextSystemKey__"] || [namespace];
|
|
10847
|
+
/**
|
|
10848
|
+
* Consolidate (merge) namespaces before attaching it to the WrappedComponent.
|
|
10849
|
+
*/
|
|
11574
10850
|
if (Array.isArray(namespace)) mergedNamespace = [...mergedNamespace, ...namespace];
|
|
11575
10851
|
if (typeof namespace === "string") mergedNamespace = [...mergedNamespace, namespace];
|
|
11576
10852
|
return Object.assign(WrappedComponent, {
|
|
@@ -11579,17 +10855,48 @@ function _contextConnect(Component, namespace, options) {
|
|
|
11579
10855
|
selector: `.${getStyledClassNameFromKey(namespace)}`
|
|
11580
10856
|
});
|
|
11581
10857
|
}
|
|
11582
|
-
// ../../../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
|
+
*/
|
|
11583
10871
|
function getNamespace(componentName) {
|
|
11584
10872
|
return { [COMPONENT_NAMESPACE]: componentName };
|
|
11585
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
|
+
*/
|
|
11586
10885
|
function getConnectedNamespace() {
|
|
11587
10886
|
return { [CONNECTED_NAMESPACE]: true };
|
|
11588
10887
|
}
|
|
11589
|
-
// ../../../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
|
+
*/
|
|
11590
10897
|
function useContextSystem(props, namespace) {
|
|
11591
10898
|
const contextSystemProps = useComponentsContext();
|
|
11592
|
-
if (typeof namespace === "undefined")
|
|
10899
|
+
if (typeof namespace === "undefined") warning("useContextSystem: Please provide a namespace");
|
|
11593
10900
|
const contextProps = contextSystemProps?.[namespace] || {};
|
|
11594
10901
|
const finalComponentProps = {
|
|
11595
10902
|
...getConnectedNamespace(),
|
|
@@ -11599,7 +10906,7 @@ function useContextSystem(props, namespace) {
|
|
|
11599
10906
|
const overrideProps = _overrides;
|
|
11600
10907
|
const initialMergedProps = Object.entries(otherContextProps).length ? Object.assign({}, otherContextProps, props) : props;
|
|
11601
10908
|
const propsWithChildren = initialMergedProps;
|
|
11602
|
-
const classes =
|
|
10909
|
+
const classes = (0, clsx.default)(getStyledClassNameFromKey(namespace), props.className);
|
|
11603
10910
|
const rendered = typeof propsWithChildren.renderChildren === "function" ? propsWithChildren.renderChildren(initialMergedProps) : propsWithChildren.children;
|
|
11604
10911
|
for (const key in initialMergedProps) finalComponentProps[key] = initialMergedProps[key];
|
|
11605
10912
|
for (const key in overrideProps) finalComponentProps[key] = overrideProps[key];
|
|
@@ -11607,8 +10914,8 @@ function useContextSystem(props, namespace) {
|
|
|
11607
10914
|
finalComponentProps.className = classes;
|
|
11608
10915
|
return finalComponentProps;
|
|
11609
10916
|
}
|
|
11610
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
11611
|
-
|
|
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 = {
|
|
11612
10919
|
border: 0,
|
|
11613
10920
|
clip: "rect(1px, 1px, 1px, 1px)",
|
|
11614
10921
|
WebkitClipPath: "inset( 50% )",
|
|
@@ -11622,10 +10929,10 @@ var visuallyHidden = {
|
|
|
11622
10929
|
wordWrap: "normal",
|
|
11623
10930
|
wordBreak: "normal"
|
|
11624
10931
|
};
|
|
11625
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
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
|
|
11629
10936
|
feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix
|
|
11630
10937
|
feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood
|
|
11631
10938
|
feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode
|
|
@@ -11633,7 +10940,7 @@ var svgElementNames = new Set(`animate animateMotion animateTransform circle cli
|
|
|
11633
10940
|
feTurbulence filter foreignObject g image line linearGradient marker mask
|
|
11634
10941
|
metadata mpath path pattern polygon polyline radialGradient rect set stop svg
|
|
11635
10942
|
switch symbol text textPath tspan use view`.split(/\s+/));
|
|
11636
|
-
|
|
10943
|
+
const baseElementProps = new Set(`children dangerouslySetInnerHTML key autoFocus defaultValue defaultChecked
|
|
11637
10944
|
innerHTML suppressContentEditableWarning suppressHydrationWarning valueLink
|
|
11638
10945
|
abbr accept acceptCharset accessKey action allow allowUserMedia
|
|
11639
10946
|
allowPaymentRequest allowFullScreen allowTransparency alt async autoComplete
|
|
@@ -11654,7 +10961,7 @@ var baseElementProps = new Set(`children dangerouslySetInnerHTML key autoFocus d
|
|
|
11654
10961
|
datatype inlist prefix property resource typeof vocab autoCapitalize
|
|
11655
10962
|
autoCorrect autoSave color incremental fallback inert itemProp itemScope
|
|
11656
10963
|
itemType itemID itemRef on option results security unselectable`.split(/\s+/));
|
|
11657
|
-
|
|
10964
|
+
const svgElementProps = new Set(`accentHeight accumulate additive alignmentBaseline allowReorder alphabetic
|
|
11658
10965
|
amplitude arabicForm ascent attributeName attributeType autoReverse azimuth
|
|
11659
10966
|
baseFrequency baselineShift baseProfile bbox begin bias by calcMode capHeight
|
|
11660
10967
|
clip clipPathUnits clipPath clipRule colorInterpolation
|
|
@@ -11689,7 +10996,7 @@ var svgElementProps = new Set(`accentHeight accumulate additive alignmentBaselin
|
|
|
11689
10996
|
xlinkActuate xlinkArcrole xlinkHref xlinkRole xlinkShow xlinkTitle xlinkType
|
|
11690
10997
|
xmlBase xmlns xmlnsXlink xmlLang xmlSpace y y1 y2 yChannelSelector z
|
|
11691
10998
|
zoomAndPan`.split(/\s+/));
|
|
11692
|
-
|
|
10999
|
+
const compatElementProps = /* @__PURE__ */ new Set([
|
|
11693
11000
|
"autofocus",
|
|
11694
11001
|
"class",
|
|
11695
11002
|
"for"
|
|
@@ -11710,19 +11017,39 @@ function UnforwardedPolymorphicElement({ as, ...props }, ref) {
|
|
|
11710
11017
|
...forwardedProps
|
|
11711
11018
|
});
|
|
11712
11019
|
}
|
|
11713
|
-
|
|
11714
|
-
|
|
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
|
|
11715
11026
|
function UnforwardedView({ css, ...restProps }, ref) {
|
|
11716
11027
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PolymorphicElement, {
|
|
11717
11028
|
ref,
|
|
11718
11029
|
...restProps
|
|
11719
11030
|
});
|
|
11720
11031
|
}
|
|
11721
|
-
|
|
11722
|
-
|
|
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
|
|
11723
11050
|
function UnconnectedVisuallyHidden(props, forwardedRef) {
|
|
11724
11051
|
const { style: styleProp, ...contextProps } = useContextSystem(props, "VisuallyHidden");
|
|
11725
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11052
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
|
|
11726
11053
|
ref: forwardedRef,
|
|
11727
11054
|
...contextProps,
|
|
11728
11055
|
"data-visually-hidden": "",
|
|
@@ -11732,14 +11059,30 @@ function UnconnectedVisuallyHidden(props, forwardedRef) {
|
|
|
11732
11059
|
}
|
|
11733
11060
|
});
|
|
11734
11061
|
}
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
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 = [
|
|
11738
11081
|
"40em",
|
|
11739
11082
|
"52em",
|
|
11740
11083
|
"64em"
|
|
11741
11084
|
];
|
|
11742
|
-
|
|
11085
|
+
const useBreakpointIndex = (options = {}) => {
|
|
11743
11086
|
const { defaultIndex = 0, enabled = true } = options;
|
|
11744
11087
|
if (typeof defaultIndex !== "number") throw new TypeError(`Default breakpoint index should be a number. Got: ${defaultIndex}, ${typeof defaultIndex}`);
|
|
11745
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}`);
|
|
@@ -11771,15 +11114,15 @@ function useResponsiveValue(values, options = {}) {
|
|
|
11771
11114
|
const array = values || [];
|
|
11772
11115
|
return array[index >= array.length ? array.length - 1 : index];
|
|
11773
11116
|
}
|
|
11774
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
11775
|
-
|
|
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 = {
|
|
11776
11119
|
bottom: {
|
|
11777
11120
|
alignItems: "flex-end",
|
|
11778
11121
|
justifyContent: "center"
|
|
11779
11122
|
},
|
|
11780
11123
|
bottomLeft: {
|
|
11781
|
-
alignItems: "flex-
|
|
11782
|
-
justifyContent: "flex-
|
|
11124
|
+
alignItems: "flex-end",
|
|
11125
|
+
justifyContent: "flex-start"
|
|
11783
11126
|
},
|
|
11784
11127
|
bottomRight: {
|
|
11785
11128
|
alignItems: "flex-end",
|
|
@@ -11818,8 +11161,16 @@ var ALIGNMENTS = {
|
|
|
11818
11161
|
function getAlignmentProps(alignment) {
|
|
11819
11162
|
return alignment ? ALIGNMENTS[alignment] ?? {} : {};
|
|
11820
11163
|
}
|
|
11821
|
-
// ../../../node_modules/.pnpm/@wordpress+components@
|
|
11822
|
-
|
|
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
|
+
*/
|
|
11823
11174
|
function getRuntime() {
|
|
11824
11175
|
const globalScope = globalThis;
|
|
11825
11176
|
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
@@ -11831,11 +11182,27 @@ function getRuntime() {
|
|
|
11831
11182
|
if (typeof document !== "undefined") registerDocument(document);
|
|
11832
11183
|
return globalScope.__wpStyleRuntime;
|
|
11833
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
|
+
*/
|
|
11834
11193
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
11835
11194
|
if (!targetDocument.head) return false;
|
|
11836
11195
|
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
11837
11196
|
return false;
|
|
11838
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
|
+
*/
|
|
11839
11206
|
function injectStyle(targetDocument, hash, css) {
|
|
11840
11207
|
if (!targetDocument.head) return;
|
|
11841
11208
|
const runtime = getRuntime();
|
|
@@ -11855,6 +11222,17 @@ function injectStyle(targetDocument, hash, css) {
|
|
|
11855
11222
|
targetDocument.head.appendChild(style);
|
|
11856
11223
|
injectedStyles.add(hash);
|
|
11857
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
|
+
*/
|
|
11858
11236
|
function registerDocument(targetDocument) {
|
|
11859
11237
|
const runtime = getRuntime();
|
|
11860
11238
|
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
@@ -11869,51 +11247,62 @@ function registerDocument(targetDocument) {
|
|
|
11869
11247
|
runtime.documents.set(targetDocument, count - 1);
|
|
11870
11248
|
};
|
|
11871
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
|
+
*/
|
|
11872
11261
|
function registerStyle(hash, css) {
|
|
11873
11262
|
const runtime = getRuntime();
|
|
11874
11263
|
runtime.styles.set(hash, css);
|
|
11875
11264
|
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
11876
11265
|
}
|
|
11877
|
-
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}");
|
|
11878
11267
|
var style_module_default = {
|
|
11879
|
-
"grid": "
|
|
11880
|
-
"row-gap-inherit": "
|
|
11881
|
-
"row-gap-initial": "
|
|
11882
|
-
"row-gap-unset": "
|
|
11883
|
-
"row-gap-revert": "
|
|
11884
|
-
"row-gap-revert-layer": "
|
|
11885
|
-
"column-gap-inherit": "
|
|
11886
|
-
"column-gap-initial": "
|
|
11887
|
-
"column-gap-unset": "
|
|
11888
|
-
"column-gap-revert": "
|
|
11889
|
-
"column-gap-revert-layer": "
|
|
11890
|
-
"has-align": "
|
|
11891
|
-
"align-inherit": "
|
|
11892
|
-
"align-initial": "
|
|
11893
|
-
"align-unset": "
|
|
11894
|
-
"align-revert": "
|
|
11895
|
-
"align-revert-layer": "
|
|
11896
|
-
"has-justify": "
|
|
11897
|
-
"justify-inherit": "
|
|
11898
|
-
"justify-initial": "
|
|
11899
|
-
"justify-unset": "
|
|
11900
|
-
"justify-revert": "
|
|
11901
|
-
"justify-revert-layer": "
|
|
11902
|
-
"has-template-columns": "
|
|
11903
|
-
"template-columns-inherit": "
|
|
11904
|
-
"template-columns-initial": "
|
|
11905
|
-
"template-columns-unset": "
|
|
11906
|
-
"template-columns-revert": "
|
|
11907
|
-
"template-columns-revert-layer": "
|
|
11908
|
-
"has-template-rows": "
|
|
11909
|
-
"template-rows-inherit": "
|
|
11910
|
-
"template-rows-initial": "
|
|
11911
|
-
"template-rows-unset": "
|
|
11912
|
-
"template-rows-revert": "
|
|
11913
|
-
"template-rows-revert-layer": "
|
|
11914
|
-
"is-inline": "
|
|
11915
|
-
};
|
|
11916
|
-
|
|
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([
|
|
11917
11306
|
"inherit",
|
|
11918
11307
|
"initial",
|
|
11919
11308
|
"unset",
|
|
@@ -11962,15 +11351,35 @@ function useGrid(props) {
|
|
|
11962
11351
|
}
|
|
11963
11352
|
};
|
|
11964
11353
|
}
|
|
11965
|
-
// ../../../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
|
|
11966
11355
|
function UnconnectedGrid(props, forwardedRef) {
|
|
11967
11356
|
const gridProps = useGrid(props);
|
|
11968
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11357
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(View, {
|
|
11969
11358
|
...gridProps,
|
|
11970
11359
|
ref: forwardedRef
|
|
11971
11360
|
});
|
|
11972
11361
|
}
|
|
11973
|
-
|
|
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");
|
|
11974
11383
|
// src/charts/leaderboard-chart/hooks/use-fitted-row-count.ts
|
|
11975
11384
|
/**
|
|
11976
11385
|
* Fractional layout rounding can put a row's bottom a hair past the container's
|
|
@@ -12134,6 +11543,41 @@ var leaderboard_chart_module_default = {
|
|
|
12134
11543
|
"stretch": "a8ccharts-GovfoW-stretch",
|
|
12135
11544
|
"valueContainer": "a8ccharts-GovfoW-valueContainer"
|
|
12136
11545
|
};
|
|
11546
|
+
// src/charts/leaderboard-chart/private/resolve-leaderboard-entries.ts
|
|
11547
|
+
const toShare = (value, max) => max === 0 ? 0 : value / max * 100;
|
|
11548
|
+
const toDelta = (currentValue, previousValue) => {
|
|
11549
|
+
if (previousValue == null) return;
|
|
11550
|
+
if (previousValue === 0) return currentValue === 0 ? 0 : void 0;
|
|
11551
|
+
return (currentValue - previousValue) / Math.abs(previousValue) * 100;
|
|
11552
|
+
};
|
|
11553
|
+
/**
|
|
11554
|
+
* Fills in the shares and delta an entry omits, derived from its values.
|
|
11555
|
+
*
|
|
11556
|
+
* @param data - Leaderboard entries; passed shares and delta win over derived ones.
|
|
11557
|
+
* @param options - Resolver options.
|
|
11558
|
+
* @param options.includePrevious - Whether previous values count toward the shared max.
|
|
11559
|
+
* @param options.clampNegative - Whether a negative share draws as an empty bar instead of below zero.
|
|
11560
|
+
* @return Entries with `currentShare` always set.
|
|
11561
|
+
*/
|
|
11562
|
+
function resolveLeaderboardEntries(data, { includePrevious, clampNegative = false }) {
|
|
11563
|
+
const magnitude = clampNegative ? (value) => Math.max(value, 0) : Math.abs;
|
|
11564
|
+
const clamp = (share) => clampNegative ? Math.max(share, 0) : share;
|
|
11565
|
+
const max = data.reduce((largest, { currentValue, previousValue }) => {
|
|
11566
|
+
const previous = includePrevious && previousValue != null ? magnitude(previousValue) : 0;
|
|
11567
|
+
return Math.max(largest, magnitude(currentValue), previous);
|
|
11568
|
+
}, 0);
|
|
11569
|
+
return data.map((entry) => {
|
|
11570
|
+
const passedOrDerivedPrevious = entry.previousShare ?? (entry.previousValue != null ? toShare(entry.previousValue, max) : void 0);
|
|
11571
|
+
const previousShare = passedOrDerivedPrevious !== void 0 ? clamp(passedOrDerivedPrevious) : void 0;
|
|
11572
|
+
const delta = entry.delta ?? toDelta(entry.currentValue, entry.previousValue);
|
|
11573
|
+
return {
|
|
11574
|
+
...entry,
|
|
11575
|
+
currentShare: clamp(entry.currentShare ?? toShare(entry.currentValue, max)),
|
|
11576
|
+
...previousShare !== void 0 && { previousShare },
|
|
11577
|
+
...delta !== void 0 && { delta }
|
|
11578
|
+
};
|
|
11579
|
+
});
|
|
11580
|
+
}
|
|
12137
11581
|
// src/charts/leaderboard-chart/leaderboard-chart.tsx
|
|
12138
11582
|
const ROW_GAP = "var(--a8c-charts-dimension-leaderboard-row-gap, 12px)";
|
|
12139
11583
|
const COLUMN_GAP = "var(--a8c-charts-dimension-leaderboard-column-gap, 4px)";
|
|
@@ -12244,6 +11688,7 @@ const BarWithLabel = ({ entry, withComparison, withOverlayLabel, primaryColor, s
|
|
|
12244
11688
|
* @param props.height - Optional height of the chart container in pixels
|
|
12245
11689
|
* @param props.withComparison - Whether to show comparison data
|
|
12246
11690
|
* @param props.withOverlayLabel - Whether to overlay the label on top of the bar
|
|
11691
|
+
* @param props.negativeBars - How a negative value draws: from a shared zero point, or as an empty bar
|
|
12247
11692
|
* @param props.primaryColor - Primary color for current period bars
|
|
12248
11693
|
* @param props.secondaryColor - Secondary color for comparison period bars
|
|
12249
11694
|
* @param props.valueFormatter - Custom formatter for values
|
|
@@ -12261,7 +11706,7 @@ const BarWithLabel = ({ entry, withComparison, withOverlayLabel, primaryColor, s
|
|
|
12261
11706
|
* @param props.ariaLabel - Accessible name for the list, defaulting to "Leaderboard chart"
|
|
12262
11707
|
* @return JSX element representing the leaderboard chart
|
|
12263
11708
|
*/
|
|
12264
|
-
const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propWidth, height: propHeight, withComparison = false, withOverlayLabel = false, primaryColor, secondaryColor, valueFormatter = defaultValueFormatter, deltaFormatter = defaultDeltaFormatter, animation, loading = false, fitRows = false, showLegend = false, legend = {}, legendLabels, gap = "md", ariaLabel, className, style, children }) => {
|
|
11709
|
+
const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propWidth, height: propHeight, withComparison = false, withOverlayLabel = false, negativeBars = "diverge", primaryColor, secondaryColor, valueFormatter = defaultValueFormatter, deltaFormatter = defaultDeltaFormatter, animation, loading = false, fitRows = false, showLegend = false, legend = {}, legendLabels, gap = "md", ariaLabel, className, style, children }) => {
|
|
12265
11710
|
const legendInteractive = legend.interactive ?? false;
|
|
12266
11711
|
const legendPosition = legend.position ?? "bottom";
|
|
12267
11712
|
const chartId = useChartId(providedChartId);
|
|
@@ -12315,13 +11760,21 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
|
|
|
12315
11760
|
withComparison,
|
|
12316
11761
|
withOverlayLabel
|
|
12317
11762
|
]);
|
|
11763
|
+
const withComparisonBars = withComparison && !withOverlayLabel;
|
|
11764
|
+
const resolvedData = (0, react.useMemo)(() => resolveLeaderboardEntries(data ?? [], {
|
|
11765
|
+
includePrevious: withComparisonBars,
|
|
11766
|
+
clampNegative: negativeBars === "clamp"
|
|
11767
|
+
}), [
|
|
11768
|
+
data,
|
|
11769
|
+
withComparisonBars,
|
|
11770
|
+
negativeBars
|
|
11771
|
+
]);
|
|
12318
11772
|
const divergingScale = (0, react.useMemo)(() => {
|
|
12319
|
-
const withComparisonBars = withComparison && !withOverlayLabel;
|
|
12320
11773
|
const scale = {
|
|
12321
11774
|
negative: 0,
|
|
12322
11775
|
positive: 0
|
|
12323
11776
|
};
|
|
12324
|
-
for (const entry of
|
|
11777
|
+
for (const entry of resolvedData) {
|
|
12325
11778
|
const shares = [entry.currentShare];
|
|
12326
11779
|
if (withComparisonBars && hasPreviousValue(entry)) shares.push(entry.previousShare);
|
|
12327
11780
|
for (const share of shares) {
|
|
@@ -12330,11 +11783,7 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
|
|
|
12330
11783
|
}
|
|
12331
11784
|
}
|
|
12332
11785
|
return scale.negative > 0 ? scale : void 0;
|
|
12333
|
-
}, [
|
|
12334
|
-
data,
|
|
12335
|
-
withComparison,
|
|
12336
|
-
withOverlayLabel
|
|
12337
|
-
]);
|
|
11786
|
+
}, [resolvedData, withComparisonBars]);
|
|
12338
11787
|
const isDataValid = Boolean(data && data.length > 0);
|
|
12339
11788
|
const chartMetadata = (0, react.useMemo)(() => ({
|
|
12340
11789
|
withComparison,
|
|
@@ -12413,14 +11862,14 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
|
|
|
12413
11862
|
}), allSeriesHidden ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12414
11863
|
className: leaderboard_chart_module_default.emptyState,
|
|
12415
11864
|
children: getAllHiddenMessage(legendInteractive, "series")
|
|
12416
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11865
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Grid, {
|
|
12417
11866
|
role: "list",
|
|
12418
11867
|
"aria-label": ariaLabel ?? (0, _wordpress_i18n.__)("Leaderboard chart", "jetpack-charts"),
|
|
12419
11868
|
templateColumns,
|
|
12420
11869
|
rowGap: ROW_GAP,
|
|
12421
11870
|
columnGap: COLUMN_GAP,
|
|
12422
11871
|
"data-leaderboard-grid": true,
|
|
12423
|
-
children:
|
|
11872
|
+
children: resolvedData.map((entry, rowIndex) => {
|
|
12424
11873
|
const rowStyle = shouldFitRows && rowIndex >= fittedCount ? { visibility: "hidden" } : void 0;
|
|
12425
11874
|
const hasPreviousPeriodValue = hasPreviousValue(entry);
|
|
12426
11875
|
const hasDelta = hasDeltaValue(entry);
|
|
@@ -12454,7 +11903,7 @@ const LeaderboardChartInternal = ({ data, chartId: providedChartId, width: propW
|
|
|
12454
11903
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12455
11904
|
"aria-hidden": "true",
|
|
12456
11905
|
children: "—"
|
|
12457
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11906
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VisuallyHidden$1, {
|
|
12458
11907
|
as: "span",
|
|
12459
11908
|
children: hasPreviousPeriodValue ? (0, _wordpress_i18n.__)("Percentage change unavailable", "jetpack-charts") : (0, _wordpress_i18n.__)("No comparison data", "jetpack-charts")
|
|
12460
11909
|
})]
|