@automattic/charts 1.8.1 → 1.9.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 +16 -0
- package/dist/index.cjs +530 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +122 -34
- package/dist/index.d.cts +97 -7
- package/dist/index.d.ts +97 -7
- package/dist/index.js +527 -54
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/charts/area-chart/area-chart.module.scss +3 -1
- package/src/charts/area-chart/area-chart.tsx +5 -2
- package/src/charts/bar-chart/bar-chart.module.scss +6 -2
- package/src/charts/bar-chart/private/comparison-bars.tsx +6 -0
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +15 -12
- package/src/charts/geo-chart/geo-chart.tsx +6 -1
- package/src/charts/geo-chart/test/geo-chart.test.tsx +11 -1
- package/src/charts/heatmap-chart/heatmap-chart.module.scss +103 -0
- package/src/charts/heatmap-chart/heatmap-chart.tsx +422 -0
- package/src/charts/heatmap-chart/index.ts +4 -0
- package/src/charts/heatmap-chart/private/build-calendar-data.ts +81 -0
- package/src/charts/heatmap-chart/private/heatmap-legend.tsx +53 -0
- package/src/charts/heatmap-chart/private/index.ts +5 -0
- package/src/charts/heatmap-chart/private/use-heatmap-colors.ts +45 -0
- package/src/charts/heatmap-chart/test/build-calendar-data.test.ts +88 -0
- package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +301 -0
- package/src/charts/heatmap-chart/test/use-heatmap-colors.test.ts +34 -0
- package/src/charts/heatmap-chart/types.ts +42 -0
- package/src/charts/index.ts +1 -0
- package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +18 -6
- package/src/charts/line-chart/line-chart.module.scss +6 -4
- package/src/charts/line-chart/line-chart.tsx +6 -2
- package/src/charts/line-chart/private/line-chart-annotation.tsx +16 -3
- package/src/charts/private/grid-control/grid-control.module.scss +1 -4
- package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +1 -1
- package/src/charts/private/with-responsive/test/with-responsive.test.tsx +14 -0
- package/src/charts/private/with-responsive/with-responsive.tsx +12 -0
- package/src/charts/private/x-zoom.module.scss +6 -3
- package/src/components/legend/private/base-legend.module.scss +3 -1
- package/src/components/tooltip/base-tooltip.module.scss +4 -1
- package/src/components/trend-indicator/trend-indicator.module.scss +5 -3
- package/src/hooks/use-xychart-theme.ts +24 -0
- package/src/index.ts +12 -0
- package/src/providers/chart-context/themes.ts +29 -16
- package/src/types.ts +19 -2
- package/src/utils/color-utils.ts +36 -0
- package/src/utils/test/color-utils.test.ts +33 -0
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import clsx from "clsx";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { Children, Fragment, Fragment as Fragment$2, createContext, createContext as createContext$1, createElement, forwardRef, forwardRef as forwardRef$1, forwardRef as forwardRef$2, isValidElement, memo, useCallback, useCallback as useCallback$1, useContext, useContext as useContext$1, useEffect, useEffect as useEffect$1, useId, useImperativeHandle, useLayoutEffect, useMemo, useMemo as useMemo$1, useRef, useRef as useRef$1, useState, useState as useState$1 } from "react";
|
|
8
8
|
import { color, hsl } from "@visx/vendor/d3-color";
|
|
9
|
-
import { differenceInHours, differenceInYears, isValid, parse, parseISO } from "date-fns";
|
|
9
|
+
import { addDays, differenceInCalendarWeeks, differenceInHours, differenceInYears, format, isValid, parse, parseISO, startOfWeek } from "date-fns";
|
|
10
10
|
import { Text, getStringWidth } from "@visx/text";
|
|
11
11
|
import deepmerge from "deepmerge";
|
|
12
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -444,6 +444,35 @@ const lightenHexColor = (hex, blend) => {
|
|
|
444
444
|
const newB = Math.round(b + (255 - b) * blend);
|
|
445
445
|
return `#${newR.toString(16).padStart(2, "0")}${newG.toString(16).padStart(2, "0")}${newB.toString(16).padStart(2, "0")}`;
|
|
446
446
|
};
|
|
447
|
+
/**
|
|
448
|
+
* WCAG relative luminance of a hex color (0 = black, 1 = white).
|
|
449
|
+
*
|
|
450
|
+
* @param hex - Hex color string (e.g., '#98C8DF')
|
|
451
|
+
* @return Relative luminance in the range [0, 1]
|
|
452
|
+
* @throws {Error} if hex string is malformed
|
|
453
|
+
*/
|
|
454
|
+
const relativeLuminance = (hex) => {
|
|
455
|
+
validateHexColor(hex);
|
|
456
|
+
const toLinear = (value) => {
|
|
457
|
+
const channel = value / 255;
|
|
458
|
+
return channel <= .03928 ? channel / 12.92 : Math.pow((channel + .055) / 1.055, 2.4);
|
|
459
|
+
};
|
|
460
|
+
const r = toLinear(parseInt(hex.slice(1, 3), 16));
|
|
461
|
+
const g = toLinear(parseInt(hex.slice(3, 5), 16));
|
|
462
|
+
const b = toLinear(parseInt(hex.slice(5, 7), 16));
|
|
463
|
+
return .2126 * r + .7152 * g + .0722 * b;
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* Whether light text reads better than dark text on the given background, using the W3C
|
|
467
|
+
* luminance threshold (0.179) that maximizes contrast against black vs white.
|
|
468
|
+
*
|
|
469
|
+
* @param backgroundHex - Hex background color
|
|
470
|
+
* @return true if light text should be used; false (dark text) for malformed colors
|
|
471
|
+
*/
|
|
472
|
+
const prefersLightText = (backgroundHex) => {
|
|
473
|
+
if (!isValidHexColor(backgroundHex)) return false;
|
|
474
|
+
return relativeLuminance(backgroundHex) <= .179;
|
|
475
|
+
};
|
|
447
476
|
//#endregion
|
|
448
477
|
//#region src/utils/resolve-css-var.ts
|
|
449
478
|
/**
|
|
@@ -677,7 +706,7 @@ const getChartColor = (index, colorCache) => {
|
|
|
677
706
|
* Default theme configuration
|
|
678
707
|
*/
|
|
679
708
|
const defaultTheme = {
|
|
680
|
-
backgroundColor: "#
|
|
709
|
+
backgroundColor: "var(--wpds-color-bg-surface-neutral-strong, #fff)",
|
|
681
710
|
labelBackgroundColor: "transparent",
|
|
682
711
|
labelTextColor: "#FFFFFF",
|
|
683
712
|
colors: [
|
|
@@ -688,56 +717,59 @@ const defaultTheme = {
|
|
|
688
717
|
"#FF8C8F"
|
|
689
718
|
],
|
|
690
719
|
gridStyles: {
|
|
691
|
-
stroke: "#
|
|
720
|
+
stroke: "var(--wpds-color-stroke-surface-neutral, #dbdbdb)",
|
|
692
721
|
strokeWidth: 1
|
|
693
722
|
},
|
|
694
723
|
tickLength: 4,
|
|
695
724
|
gridColor: "",
|
|
696
725
|
gridColorDark: "",
|
|
697
|
-
xTickLineStyles: {
|
|
726
|
+
xTickLineStyles: {
|
|
727
|
+
stroke: "var(--wpds-color-stroke-surface-neutral, #dbdbdb)",
|
|
728
|
+
strokeWidth: 1
|
|
729
|
+
},
|
|
698
730
|
xAxisLineStyles: {
|
|
699
|
-
stroke: "#
|
|
731
|
+
stroke: "var(--wpds-color-stroke-surface-neutral, #dbdbdb)",
|
|
700
732
|
strokeWidth: 1
|
|
701
733
|
},
|
|
702
734
|
legend: {
|
|
703
|
-
labelStyles: { color: "var(--
|
|
735
|
+
labelStyles: { color: "var(--wpds-color-fg-content-neutral, #1e1e1e)" },
|
|
704
736
|
containerStyles: {},
|
|
705
737
|
shapeStyles: []
|
|
706
738
|
},
|
|
707
739
|
seriesLineStyles: [],
|
|
708
740
|
glyphs: [],
|
|
709
741
|
svgLabelSmall: {
|
|
710
|
-
fill: "var(--
|
|
742
|
+
fill: "var(--wpds-color-fg-content-neutral, #1e1e1e)",
|
|
711
743
|
fontFamily: "inherit"
|
|
712
744
|
},
|
|
713
745
|
svgLabelBig: { fontFamily: "inherit" },
|
|
714
746
|
annotationStyles: {
|
|
715
747
|
label: {
|
|
716
|
-
anchorLineStroke: "var(--
|
|
717
|
-
backgroundFill: "#fff"
|
|
748
|
+
anchorLineStroke: "var(--wpds-color-fg-content-neutral, #1e1e1e)",
|
|
749
|
+
backgroundFill: "var(--wpds-color-bg-surface-neutral-strong, #fff)"
|
|
718
750
|
},
|
|
719
|
-
connector: { stroke: "var(--
|
|
751
|
+
connector: { stroke: "var(--wpds-color-fg-content-neutral, #1e1e1e)" },
|
|
720
752
|
circleSubject: {
|
|
721
753
|
stroke: "transparent",
|
|
722
|
-
fill: "var(--
|
|
754
|
+
fill: "var(--wpds-color-fg-content-neutral, #1e1e1e)",
|
|
723
755
|
radius: 5
|
|
724
756
|
}
|
|
725
757
|
},
|
|
726
|
-
geoChart: { featureFillColor: "var(--
|
|
758
|
+
geoChart: { featureFillColor: "var(--wpds-color-bg-surface-neutral-weak, #f4f4f4)" },
|
|
727
759
|
leaderboardChart: {
|
|
728
760
|
rowGap: 12,
|
|
729
761
|
columnGap: 4,
|
|
730
762
|
labelSpacing: "xs",
|
|
731
763
|
deltaColors: [
|
|
732
|
-
"#
|
|
733
|
-
"#
|
|
734
|
-
"#
|
|
764
|
+
"var(--wpds-color-fg-content-error-weak, #cc1818)",
|
|
765
|
+
"var(--wpds-color-fg-content-neutral-weak, #707070)",
|
|
766
|
+
"var(--wpds-color-fg-content-success-weak, #008030)"
|
|
735
767
|
]
|
|
736
768
|
},
|
|
737
769
|
conversionFunnelChart: {
|
|
738
|
-
backgroundColor: "#
|
|
739
|
-
positiveChangeColor: "#
|
|
740
|
-
negativeChangeColor: "#
|
|
770
|
+
backgroundColor: "var(--wpds-color-bg-surface-neutral-weak, #f4f4f4)",
|
|
771
|
+
positiveChangeColor: "var(--wpds-color-fg-content-success-weak, #008030)",
|
|
772
|
+
negativeChangeColor: "var(--wpds-color-fg-content-error-weak, #cc1818)"
|
|
741
773
|
},
|
|
742
774
|
lineChart: { lineStyles: { comparison: {
|
|
743
775
|
strokeDasharray: "4 4",
|
|
@@ -755,6 +787,10 @@ const defaultTheme = {
|
|
|
755
787
|
left: 2
|
|
756
788
|
},
|
|
757
789
|
strokeWidth: 1.5
|
|
790
|
+
},
|
|
791
|
+
heatmapChart: {
|
|
792
|
+
compactCellGap: 2,
|
|
793
|
+
compactCellSize: 11
|
|
758
794
|
}
|
|
759
795
|
};
|
|
760
796
|
//#endregion
|
|
@@ -967,13 +1003,31 @@ const useDeepMemo = (value) => {
|
|
|
967
1003
|
};
|
|
968
1004
|
//#endregion
|
|
969
1005
|
//#region src/hooks/use-xychart-theme.ts
|
|
1006
|
+
const resolveColor = (value) => value ? resolveCssVariable(value) ?? value : value;
|
|
970
1007
|
const useXYChartTheme = (data) => {
|
|
971
1008
|
const theme = useGlobalChartsTheme();
|
|
972
1009
|
return useMemo(() => {
|
|
973
1010
|
const seriesColors = (data ?? []).map((series) => series.options?.stroke).filter((color) => Boolean(color));
|
|
974
1011
|
return buildChartTheme({
|
|
975
1012
|
...theme,
|
|
976
|
-
colors: [...seriesColors, ...theme.colors ?? []]
|
|
1013
|
+
colors: [...seriesColors, ...theme.colors ?? []],
|
|
1014
|
+
backgroundColor: resolveColor(theme.backgroundColor),
|
|
1015
|
+
gridStyles: theme.gridStyles && {
|
|
1016
|
+
...theme.gridStyles,
|
|
1017
|
+
stroke: resolveColor(theme.gridStyles.stroke)
|
|
1018
|
+
},
|
|
1019
|
+
xAxisLineStyles: theme.xAxisLineStyles && {
|
|
1020
|
+
...theme.xAxisLineStyles,
|
|
1021
|
+
stroke: resolveColor(theme.xAxisLineStyles.stroke)
|
|
1022
|
+
},
|
|
1023
|
+
xTickLineStyles: theme.xTickLineStyles && {
|
|
1024
|
+
...theme.xTickLineStyles,
|
|
1025
|
+
stroke: resolveColor(theme.xTickLineStyles.stroke)
|
|
1026
|
+
},
|
|
1027
|
+
svgLabelSmall: theme.svgLabelSmall && {
|
|
1028
|
+
...theme.svgLabelSmall,
|
|
1029
|
+
fill: resolveColor(theme.svgLabelSmall.fill)
|
|
1030
|
+
}
|
|
977
1031
|
});
|
|
978
1032
|
}, [theme, data]);
|
|
979
1033
|
};
|
|
@@ -2802,12 +2856,17 @@ function withResponsive(WrappedComponent) {
|
|
|
2802
2856
|
const effectiveWidth = measuredWidth || width || 0;
|
|
2803
2857
|
const effectiveHeight = measuredHeight || height || 0;
|
|
2804
2858
|
const defaultHeight = hasAspectRatio ? "auto" : "100%";
|
|
2859
|
+
const aspectRatioStyle = hasAspectRatio && aspectRatio ? {
|
|
2860
|
+
aspectRatio: `${1 / aspectRatio}`,
|
|
2861
|
+
maxWidth: width === void 0 ? maxWidth : void 0
|
|
2862
|
+
} : null;
|
|
2805
2863
|
return /* @__PURE__ */ jsx("div", {
|
|
2806
2864
|
ref: parentRef,
|
|
2807
2865
|
className: with_responsive_module_default.container,
|
|
2808
2866
|
style: {
|
|
2809
2867
|
width: width ?? "100%",
|
|
2810
|
-
height: height ?? defaultHeight
|
|
2868
|
+
height: height ?? defaultHeight,
|
|
2869
|
+
...aspectRatioStyle
|
|
2811
2870
|
},
|
|
2812
2871
|
children: /* @__PURE__ */ jsx(WrappedComponent, {
|
|
2813
2872
|
width: effectiveWidth,
|
|
@@ -3248,6 +3307,7 @@ const LineChartAnnotation = ({ datum, title, subtitle, subjectType = "circle", s
|
|
|
3248
3307
|
const labelRef = useRef(null);
|
|
3249
3308
|
const [height, setHeight] = useState(null);
|
|
3250
3309
|
const styles = deepmerge(providerTheme.annotationStyles ?? {}, datumStyles ?? {});
|
|
3310
|
+
const resolveColor = (value) => value ? resolveCssVariable(value) ?? value : value;
|
|
3251
3311
|
useEffect(() => {
|
|
3252
3312
|
if (labelRef.current?.getBBox) setHeight(labelRef.current.getBBox().height);
|
|
3253
3313
|
}, []);
|
|
@@ -3330,8 +3390,15 @@ const LineChartAnnotation = ({ datum, title, subtitle, subjectType = "circle", s
|
|
|
3330
3390
|
dx,
|
|
3331
3391
|
dy,
|
|
3332
3392
|
children: [
|
|
3333
|
-
/* @__PURE__ */ jsx(Connector, {
|
|
3334
|
-
|
|
3393
|
+
/* @__PURE__ */ jsx(Connector, {
|
|
3394
|
+
...styles?.connector,
|
|
3395
|
+
stroke: resolveColor(styles?.connector?.stroke)
|
|
3396
|
+
}),
|
|
3397
|
+
subjectType === "circle" && /* @__PURE__ */ jsx(CircleSubject, {
|
|
3398
|
+
...styles?.circleSubject,
|
|
3399
|
+
fill: resolveColor(styles?.circleSubject?.fill),
|
|
3400
|
+
stroke: resolveColor(styles?.circleSubject?.stroke)
|
|
3401
|
+
}),
|
|
3335
3402
|
subjectType === "line-vertical" && /* @__PURE__ */ jsx(LineSubject, {
|
|
3336
3403
|
min: yMax,
|
|
3337
3404
|
max: yMin,
|
|
@@ -3365,6 +3432,8 @@ const LineChartAnnotation = ({ datum, title, subtitle, subjectType = "circle", s
|
|
|
3365
3432
|
title,
|
|
3366
3433
|
subtitle,
|
|
3367
3434
|
...styles?.label,
|
|
3435
|
+
anchorLineStroke: resolveColor(styles?.label?.anchorLineStroke),
|
|
3436
|
+
backgroundFill: resolveColor(styles?.label?.backgroundFill),
|
|
3368
3437
|
...labelPosition,
|
|
3369
3438
|
horizontalAnchor: getHorizontalAnchor(subjectType, isFlippedHorizontally),
|
|
3370
3439
|
verticalAnchor: getVerticalAnchor(subjectType, isFlippedVertically, y, yMax, height ?? ANNOTATION_INIT_HEIGHT)
|
|
@@ -3481,6 +3550,7 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
|
|
|
3481
3550
|
const legendShape = legend.shape ?? "line";
|
|
3482
3551
|
const legendPosition = legend.position ?? "bottom";
|
|
3483
3552
|
const providerTheme = useGlobalChartsTheme();
|
|
3553
|
+
const resolvedBackgroundColor = resolveCssVariable(providerTheme.backgroundColor) ?? providerTheme.backgroundColor;
|
|
3484
3554
|
const theme = useXYChartTheme(data);
|
|
3485
3555
|
const chartId = useChartId(providedChartId);
|
|
3486
3556
|
const chartRef = useRef(null);
|
|
@@ -3728,7 +3798,7 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
|
|
|
3728
3798
|
from: color,
|
|
3729
3799
|
fromOpacity: .4,
|
|
3730
3800
|
toOpacity: .1,
|
|
3731
|
-
to:
|
|
3801
|
+
to: resolvedBackgroundColor,
|
|
3732
3802
|
...seriesData.options?.gradient,
|
|
3733
3803
|
children: seriesData.options?.gradient?.stops?.map((stop, stopIndex) => /* @__PURE__ */ jsx("stop", {
|
|
3734
3804
|
offset: stop.offset,
|
|
@@ -4232,7 +4302,7 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
|
|
|
4232
4302
|
stacked,
|
|
4233
4303
|
stackOffset,
|
|
4234
4304
|
getElementStyles,
|
|
4235
|
-
strokeColor: providerTheme.backgroundColor
|
|
4305
|
+
strokeColor: resolveCssVariable(providerTheme.backgroundColor) ?? providerTheme.backgroundColor
|
|
4236
4306
|
})] }),
|
|
4237
4307
|
/* @__PURE__ */ jsx(AreaChartScalesRef, {
|
|
4238
4308
|
chartRef: internalChartRef,
|
|
@@ -5596,6 +5666,11 @@ var geo_chart_module_default = { "container": "a8ccharts-8hS2IW-container" };
|
|
|
5596
5666
|
*/
|
|
5597
5667
|
const DEFAULT_FEATURE_FILL_COLOR = "#ffffff";
|
|
5598
5668
|
const DEFAULT_BACKGROUND_COLOR = "#ffffff";
|
|
5669
|
+
const GEO_CHART_PACKAGES = [
|
|
5670
|
+
"corechart",
|
|
5671
|
+
"controls",
|
|
5672
|
+
"geochart"
|
|
5673
|
+
];
|
|
5599
5674
|
/**
|
|
5600
5675
|
* Renders a geographical chart using Google Charts GeoChart to visualize data.
|
|
5601
5676
|
*
|
|
@@ -5684,6 +5759,7 @@ const GeoChartInternal = ({ className, data, width, height, region = "world", re
|
|
|
5684
5759
|
},
|
|
5685
5760
|
children: /* @__PURE__ */ jsx(Chart, {
|
|
5686
5761
|
chartType: "GeoChart",
|
|
5762
|
+
chartPackages: GEO_CHART_PACKAGES,
|
|
5687
5763
|
width,
|
|
5688
5764
|
height,
|
|
5689
5765
|
data: sanitizedData.data,
|
|
@@ -5699,10 +5775,407 @@ const GeoChartWithProvider = (props) => {
|
|
|
5699
5775
|
GeoChartWithProvider.displayName = "GeoChart";
|
|
5700
5776
|
const GeoChartResponsive = withResponsive(GeoChartWithProvider);
|
|
5701
5777
|
//#endregion
|
|
5702
|
-
//#region
|
|
5778
|
+
//#region src/charts/heatmap-chart/heatmap-chart.module.scss
|
|
5779
|
+
var heatmap_chart_module_default = {
|
|
5780
|
+
"heatmap-chart": "a8ccharts-O3YMOW-heatmap-chart",
|
|
5781
|
+
"heatmap-chart__cell": "a8ccharts-O3YMOW-heatmap-chart__cell",
|
|
5782
|
+
"heatmap-chart__cell--filled": "a8ccharts-O3YMOW-heatmap-chart__cell--filled",
|
|
5783
|
+
"heatmap-chart__cell--selected": "a8ccharts-O3YMOW-heatmap-chart__cell--selected",
|
|
5784
|
+
"heatmap-chart__cell--strong": "a8ccharts-O3YMOW-heatmap-chart__cell--strong",
|
|
5785
|
+
"heatmap-chart__cell-value": "a8ccharts-O3YMOW-heatmap-chart__cell-value",
|
|
5786
|
+
"heatmap-chart__col-label": "a8ccharts-O3YMOW-heatmap-chart__col-label",
|
|
5787
|
+
"heatmap-chart__empty": "a8ccharts-O3YMOW-heatmap-chart__empty",
|
|
5788
|
+
"heatmap-chart__grid": "a8ccharts-O3YMOW-heatmap-chart__grid",
|
|
5789
|
+
"heatmap-chart__grid--compact": "a8ccharts-O3YMOW-heatmap-chart__grid--compact",
|
|
5790
|
+
"heatmap-chart__legend-swatch": "a8ccharts-O3YMOW-heatmap-chart__legend-swatch",
|
|
5791
|
+
"heatmap-chart__row": "a8ccharts-O3YMOW-heatmap-chart__row",
|
|
5792
|
+
"heatmap-chart__row-label": "a8ccharts-O3YMOW-heatmap-chart__row-label"
|
|
5793
|
+
};
|
|
5794
|
+
//#endregion
|
|
5795
|
+
//#region src/charts/heatmap-chart/private/use-heatmap-colors.ts
|
|
5796
|
+
const isPresent = (value) => value !== null && value !== void 0 && !isNaN(value);
|
|
5797
|
+
/**
|
|
5798
|
+
* Get the min and max values from heatmap data, ignoring null/NaN.
|
|
5799
|
+
* @param data - The heatmap columns
|
|
5800
|
+
* @return Tuple of [min, max] values
|
|
5801
|
+
*/
|
|
5802
|
+
const getValueExtent = (data) => {
|
|
5803
|
+
let min = Infinity;
|
|
5804
|
+
let max = -Infinity;
|
|
5805
|
+
for (const column of data) for (const cell of column.data) {
|
|
5806
|
+
if (!isPresent(cell.value)) continue;
|
|
5807
|
+
if (cell.value < min) min = cell.value;
|
|
5808
|
+
if (cell.value > max) max = cell.value;
|
|
5809
|
+
}
|
|
5810
|
+
if (min === Infinity) return [0, 0];
|
|
5811
|
+
return [min, max];
|
|
5812
|
+
};
|
|
5813
|
+
/**
|
|
5814
|
+
* Normalize a value to 0–1 within the extent. A flat extent (min === max) maps to 1.
|
|
5815
|
+
* @param value - The value to normalize
|
|
5816
|
+
* @param extent - Tuple of [min, max] values for the normalization range
|
|
5817
|
+
* @return Normalized value between 0 and 1
|
|
5818
|
+
*/
|
|
5819
|
+
const getNormalizedValue = (value, extent) => {
|
|
5820
|
+
const [min, max] = extent;
|
|
5821
|
+
if (min === max) return 1;
|
|
5822
|
+
return Math.min(1, Math.max(0, (value - min) / (max - min)));
|
|
5823
|
+
};
|
|
5824
|
+
//#endregion
|
|
5825
|
+
//#region src/charts/heatmap-chart/private/build-calendar-data.ts
|
|
5826
|
+
/** Rows that get a weekday label (Mon, Wed, Fri with a Monday week start). */
|
|
5827
|
+
const LABELLED_ROWS = [
|
|
5828
|
+
0,
|
|
5829
|
+
2,
|
|
5830
|
+
4
|
|
5831
|
+
];
|
|
5832
|
+
const toDate = (point) => {
|
|
5833
|
+
if (point.date instanceof Date && !isNaN(point.date.getTime())) return point.date;
|
|
5834
|
+
if (point.dateString) {
|
|
5835
|
+
const parsed = parseISO(point.dateString);
|
|
5836
|
+
if (!isNaN(parsed.getTime())) return parsed;
|
|
5837
|
+
}
|
|
5838
|
+
return null;
|
|
5839
|
+
};
|
|
5840
|
+
const buildCalendarHeatmapData = (series, options = {}) => {
|
|
5841
|
+
const weekStartsOn = options.weekStartsOn ?? 1;
|
|
5842
|
+
const entries = series.map((point) => ({
|
|
5843
|
+
date: toDate(point),
|
|
5844
|
+
value: point.value
|
|
5845
|
+
})).filter((entry) => entry.date !== null);
|
|
5846
|
+
if (!entries.length) return {
|
|
5847
|
+
data: [],
|
|
5848
|
+
rowLabels: []
|
|
5849
|
+
};
|
|
5850
|
+
const valueByDay = /* @__PURE__ */ new Map();
|
|
5851
|
+
let minDate = entries[0].date;
|
|
5852
|
+
let maxDate = entries[0].date;
|
|
5853
|
+
for (const { date, value } of entries) {
|
|
5854
|
+
valueByDay.set(format(date, "yyyy-MM-dd"), value);
|
|
5855
|
+
if (date < minDate) minDate = date;
|
|
5856
|
+
if (date > maxDate) maxDate = date;
|
|
5857
|
+
}
|
|
5858
|
+
const gridStart = startOfWeek(minDate, { weekStartsOn });
|
|
5859
|
+
const weekCount = differenceInCalendarWeeks(maxDate, gridStart, { weekStartsOn }) + 1;
|
|
5860
|
+
const rowLabels = Array.from({ length: 7 }, (_, row) => LABELLED_ROWS.includes(row) ? format(addDays(gridStart, row), "EEE") : "");
|
|
5861
|
+
const data = [];
|
|
5862
|
+
let previousMonth = -1;
|
|
5863
|
+
for (let week = 0; week < weekCount; week++) {
|
|
5864
|
+
const columnStart = addDays(gridStart, week * 7);
|
|
5865
|
+
const month = columnStart.getMonth();
|
|
5866
|
+
const label = month !== previousMonth ? format(columnStart, "MMM") : "";
|
|
5867
|
+
previousMonth = month;
|
|
5868
|
+
const cells = [];
|
|
5869
|
+
for (let row = 0; row < 7; row++) {
|
|
5870
|
+
const day = addDays(gridStart, week * 7 + row);
|
|
5871
|
+
const key = format(day, "yyyy-MM-dd");
|
|
5872
|
+
cells.push({
|
|
5873
|
+
label: format(day, "EEE, MMM d, yyyy"),
|
|
5874
|
+
value: valueByDay.has(key) ? valueByDay.get(key) : null
|
|
5875
|
+
});
|
|
5876
|
+
}
|
|
5877
|
+
data.push({
|
|
5878
|
+
label,
|
|
5879
|
+
data: cells
|
|
5880
|
+
});
|
|
5881
|
+
}
|
|
5882
|
+
return {
|
|
5883
|
+
data,
|
|
5884
|
+
rowLabels
|
|
5885
|
+
};
|
|
5886
|
+
};
|
|
5887
|
+
//#endregion
|
|
5888
|
+
//#region src/charts/heatmap-chart/private/heatmap-legend.tsx
|
|
5889
|
+
const HeatmapLegend = ({ steps = 5, lessLabel, moreLabel }) => {
|
|
5890
|
+
const context = useContext(HeatmapContext);
|
|
5891
|
+
const { legend } = useGlobalChartsTheme();
|
|
5892
|
+
if (!context) return null;
|
|
5893
|
+
const { primaryColorHex } = context;
|
|
5894
|
+
const labelStyle = legend.labelStyles;
|
|
5895
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
5896
|
+
direction: "row",
|
|
5897
|
+
gap: "xs",
|
|
5898
|
+
align: "center",
|
|
5899
|
+
children: [
|
|
5900
|
+
/* @__PURE__ */ jsx(Text$1, {
|
|
5901
|
+
variant: "body-sm",
|
|
5902
|
+
style: labelStyle,
|
|
5903
|
+
children: lessLabel ?? __("Less", "jetpack-charts")
|
|
5904
|
+
}),
|
|
5905
|
+
/* @__PURE__ */ jsx(Stack, {
|
|
5906
|
+
direction: "row",
|
|
5907
|
+
gap: "xs",
|
|
5908
|
+
children: Array.from({ length: steps }, (_, index) => {
|
|
5909
|
+
const intensity = steps <= 1 ? 1 : index / (steps - 1);
|
|
5910
|
+
return /* @__PURE__ */ jsx("span", {
|
|
5911
|
+
"aria-hidden": "true",
|
|
5912
|
+
className: heatmap_chart_module_default["heatmap-chart__legend-swatch"],
|
|
5913
|
+
style: {
|
|
5914
|
+
"--heatmap-primary": primaryColorHex,
|
|
5915
|
+
"--intensity": intensity
|
|
5916
|
+
}
|
|
5917
|
+
}, index);
|
|
5918
|
+
})
|
|
5919
|
+
}),
|
|
5920
|
+
/* @__PURE__ */ jsx(Text$1, {
|
|
5921
|
+
variant: "body-sm",
|
|
5922
|
+
style: labelStyle,
|
|
5923
|
+
children: moreLabel ?? __("More", "jetpack-charts")
|
|
5924
|
+
})
|
|
5925
|
+
]
|
|
5926
|
+
});
|
|
5927
|
+
};
|
|
5928
|
+
//#endregion
|
|
5929
|
+
//#region src/charts/heatmap-chart/heatmap-chart.tsx
|
|
5930
|
+
const HeatmapContext = createContext(null);
|
|
5931
|
+
const CELL_MIX_FLOOR = .15;
|
|
5932
|
+
const HeatmapChartInternal = ({ data, chartId: providedChartId, width = 0, height = 0, className, compact = false, showValues, rowLabels = [], primaryColor, gap = "md", withTooltips = false, renderTooltip, children }) => {
|
|
5933
|
+
const chartId = useChartId(providedChartId);
|
|
5934
|
+
const { getElementStyles, theme } = useGlobalChartsContext();
|
|
5935
|
+
const { heatmapChart: heatmapChartSettings } = theme;
|
|
5936
|
+
const { nonLegendChildren } = useChartChildren(children, "HeatmapChart");
|
|
5937
|
+
const [selectedIndex, setSelectedIndex] = useState();
|
|
5938
|
+
const { tooltipOpen, tooltipLeft, tooltipTop, tooltipData, showTooltip, hideTooltip } = useTooltip();
|
|
5939
|
+
const { containerRef, containerBounds, TooltipInPortal } = useTooltipInPortal({
|
|
5940
|
+
detectBounds: true,
|
|
5941
|
+
scroll: true
|
|
5942
|
+
});
|
|
5943
|
+
const containerBoundsRef = useRef(containerBounds);
|
|
5944
|
+
containerBoundsRef.current = containerBounds;
|
|
5945
|
+
const { color: primaryColorHex } = getElementStyles({
|
|
5946
|
+
index: 0,
|
|
5947
|
+
overrideColor: primaryColor || heatmapChartSettings.primaryColor
|
|
5948
|
+
});
|
|
5949
|
+
const primaryHex = normalizeColorToHex(primaryColorHex);
|
|
5950
|
+
const cellHasLightText = (intensity) => isValidHexColor(primaryHex) && prefersLightText(lightenHexColor(primaryHex, 1 - (CELL_MIX_FLOOR + (1 - CELL_MIX_FLOOR) * intensity)));
|
|
5951
|
+
const extent = useMemo(() => getValueExtent(data), [data]);
|
|
5952
|
+
const heatmapContext = useMemo(() => ({
|
|
5953
|
+
extent,
|
|
5954
|
+
primaryColorHex
|
|
5955
|
+
}), [extent, primaryColorHex]);
|
|
5956
|
+
const columns = data.length;
|
|
5957
|
+
const rows = Math.max(0, ...data.map((column) => column.data.length));
|
|
5958
|
+
const { compactCellGap, compactCellSize } = heatmapChartSettings;
|
|
5959
|
+
const drawValues = showValues ?? !compact;
|
|
5960
|
+
const buildTooltipData = useCallback((columnIndex, rowIndex) => {
|
|
5961
|
+
const cell = data[columnIndex]?.data[rowIndex];
|
|
5962
|
+
return {
|
|
5963
|
+
value: cell?.value ?? null,
|
|
5964
|
+
rowLabel: rowLabels[rowIndex],
|
|
5965
|
+
columnLabel: data[columnIndex]?.label,
|
|
5966
|
+
cellLabel: cell?.label,
|
|
5967
|
+
row: rowIndex,
|
|
5968
|
+
column: columnIndex
|
|
5969
|
+
};
|
|
5970
|
+
}, [data, rowLabels]);
|
|
5971
|
+
const onChartBlur = useCallback(() => {
|
|
5972
|
+
setSelectedIndex(void 0);
|
|
5973
|
+
hideTooltip();
|
|
5974
|
+
}, [hideTooltip]);
|
|
5975
|
+
const onChartKeyDown = useCallback((event) => {
|
|
5976
|
+
if (![
|
|
5977
|
+
"ArrowLeft",
|
|
5978
|
+
"ArrowRight",
|
|
5979
|
+
"ArrowUp",
|
|
5980
|
+
"ArrowDown",
|
|
5981
|
+
"Escape",
|
|
5982
|
+
"Tab"
|
|
5983
|
+
].includes(event.key)) return;
|
|
5984
|
+
if (event.key === "Tab" || event.key === "Escape") {
|
|
5985
|
+
setSelectedIndex(void 0);
|
|
5986
|
+
hideTooltip();
|
|
5987
|
+
return;
|
|
5988
|
+
}
|
|
5989
|
+
event.preventDefault();
|
|
5990
|
+
if (selectedIndex === void 0) {
|
|
5991
|
+
setSelectedIndex(0);
|
|
5992
|
+
return;
|
|
5993
|
+
}
|
|
5994
|
+
let col = Math.floor(selectedIndex / rows);
|
|
5995
|
+
let row = selectedIndex % rows;
|
|
5996
|
+
if (event.key === "ArrowRight") col = Math.min(col + 1, columns - 1);
|
|
5997
|
+
else if (event.key === "ArrowLeft") col = Math.max(col - 1, 0);
|
|
5998
|
+
else if (event.key === "ArrowDown") row = Math.min(row + 1, rows - 1);
|
|
5999
|
+
else if (event.key === "ArrowUp") row = Math.max(row - 1, 0);
|
|
6000
|
+
setSelectedIndex(col * rows + row);
|
|
6001
|
+
}, [
|
|
6002
|
+
rows,
|
|
6003
|
+
columns,
|
|
6004
|
+
selectedIndex,
|
|
6005
|
+
hideTooltip
|
|
6006
|
+
]);
|
|
6007
|
+
const handleCellMouseMove = useCallback((event) => {
|
|
6008
|
+
if (!withTooltips) return;
|
|
6009
|
+
const target = event.currentTarget;
|
|
6010
|
+
const columnIndex = Number(target.dataset.column);
|
|
6011
|
+
const rowIndex = Number(target.dataset.row);
|
|
6012
|
+
const bounds = containerBoundsRef.current;
|
|
6013
|
+
showTooltip({
|
|
6014
|
+
tooltipLeft: event.clientX - bounds.left,
|
|
6015
|
+
tooltipTop: event.clientY - bounds.top,
|
|
6016
|
+
tooltipData: buildTooltipData(columnIndex, rowIndex)
|
|
6017
|
+
});
|
|
6018
|
+
}, [
|
|
6019
|
+
withTooltips,
|
|
6020
|
+
showTooltip,
|
|
6021
|
+
buildTooltipData
|
|
6022
|
+
]);
|
|
6023
|
+
const handleCellMouseLeave = useCallback(() => {
|
|
6024
|
+
if (withTooltips && selectedIndex === void 0) hideTooltip();
|
|
6025
|
+
}, [
|
|
6026
|
+
withTooltips,
|
|
6027
|
+
selectedIndex,
|
|
6028
|
+
hideTooltip
|
|
6029
|
+
]);
|
|
6030
|
+
useEffect(() => {
|
|
6031
|
+
if (!withTooltips || selectedIndex === void 0) return;
|
|
6032
|
+
const col = Math.floor(selectedIndex / rows);
|
|
6033
|
+
const row = selectedIndex % rows;
|
|
6034
|
+
const rect = (typeof document !== "undefined" ? document.getElementById(`${chartId}-cell-${col}-${row}`) : null)?.getBoundingClientRect();
|
|
6035
|
+
const bounds = containerBoundsRef.current;
|
|
6036
|
+
showTooltip({
|
|
6037
|
+
tooltipLeft: rect ? rect.left + rect.width / 2 - bounds.left : 0,
|
|
6038
|
+
tooltipTop: rect ? rect.top + rect.height / 2 - bounds.top : 0,
|
|
6039
|
+
tooltipData: buildTooltipData(col, row)
|
|
6040
|
+
});
|
|
6041
|
+
}, [
|
|
6042
|
+
selectedIndex,
|
|
6043
|
+
withTooltips,
|
|
6044
|
+
rows,
|
|
6045
|
+
chartId,
|
|
6046
|
+
buildTooltipData,
|
|
6047
|
+
showTooltip
|
|
6048
|
+
]);
|
|
6049
|
+
const defaultRenderTooltip = useCallback((info) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", { children: info.cellLabel || `${info.columnLabel ?? ""} ${info.rowLabel ?? ""}`.trim() }), /* @__PURE__ */ jsx("div", { children: info.value === null ? __("No data", "jetpack-charts") : formatNumber(info.value) })] }), []);
|
|
6050
|
+
if (!columns || !rows) return /* @__PURE__ */ jsx(Center, {
|
|
6051
|
+
className: clsx("heatmap-chart", heatmap_chart_module_default["heatmap-chart"], className),
|
|
6052
|
+
style: {
|
|
6053
|
+
width: width || void 0,
|
|
6054
|
+
height: height || void 0
|
|
6055
|
+
},
|
|
6056
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
6057
|
+
className: heatmap_chart_module_default["heatmap-chart__empty"],
|
|
6058
|
+
children: __("No data available", "jetpack-charts")
|
|
6059
|
+
})
|
|
6060
|
+
});
|
|
6061
|
+
const trackSize = compact ? "var(--heatmap-cell-size)" : "minmax(0, 1fr)";
|
|
6062
|
+
const gridStyle = {
|
|
6063
|
+
"--heatmap-primary": primaryColorHex,
|
|
6064
|
+
gridTemplateColumns: `auto repeat(${columns}, ${trackSize})`,
|
|
6065
|
+
gridTemplateRows: `auto repeat(${rows}, ${trackSize})`
|
|
6066
|
+
};
|
|
6067
|
+
if (compact) {
|
|
6068
|
+
gridStyle["--heatmap-cell-gap"] = `${compactCellGap}px`;
|
|
6069
|
+
gridStyle["--heatmap-cell-size"] = `${compactCellSize}px`;
|
|
6070
|
+
}
|
|
6071
|
+
const activeDescendant = selectedIndex !== void 0 ? `${chartId}-cell-${Math.floor(selectedIndex / rows)}-${selectedIndex % rows}` : void 0;
|
|
6072
|
+
return /* @__PURE__ */ jsx(HeatmapContext.Provider, {
|
|
6073
|
+
value: heatmapContext,
|
|
6074
|
+
children: /* @__PURE__ */ jsx(SingleChartContext.Provider, {
|
|
6075
|
+
value: { chartId },
|
|
6076
|
+
children: /* @__PURE__ */ jsxs(ChartLayout, {
|
|
6077
|
+
legendPosition: "bottom",
|
|
6078
|
+
legendChildren: [],
|
|
6079
|
+
trailingContent: nonLegendChildren,
|
|
6080
|
+
gap,
|
|
6081
|
+
className: clsx("heatmap-chart", heatmap_chart_module_default["heatmap-chart"], className),
|
|
6082
|
+
style: {
|
|
6083
|
+
width: width || void 0,
|
|
6084
|
+
height: height || void 0
|
|
6085
|
+
},
|
|
6086
|
+
"data-chart-id": `heatmap-chart-${chartId}`,
|
|
6087
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
6088
|
+
ref: containerRef,
|
|
6089
|
+
role: "grid",
|
|
6090
|
+
"aria-label": __("Heatmap chart", "jetpack-charts"),
|
|
6091
|
+
"aria-rowcount": rows,
|
|
6092
|
+
"aria-colcount": columns,
|
|
6093
|
+
"aria-activedescendant": activeDescendant,
|
|
6094
|
+
tabIndex: 0,
|
|
6095
|
+
onBlur: onChartBlur,
|
|
6096
|
+
onKeyDown: onChartKeyDown,
|
|
6097
|
+
className: clsx(heatmap_chart_module_default["heatmap-chart__grid"], { [heatmap_chart_module_default["heatmap-chart__grid--compact"]]: compact }),
|
|
6098
|
+
style: gridStyle,
|
|
6099
|
+
children: [
|
|
6100
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true" }),
|
|
6101
|
+
data.map((column, columnIndex) => /* @__PURE__ */ jsx("span", {
|
|
6102
|
+
"aria-hidden": "true",
|
|
6103
|
+
className: heatmap_chart_module_default["heatmap-chart__col-label"],
|
|
6104
|
+
children: column.label
|
|
6105
|
+
}, `col-${columnIndex}`)),
|
|
6106
|
+
Array.from({ length: rows }).map((_row, rowIndex) => {
|
|
6107
|
+
const labelVisible = !compact || rowIndex % 2 === 0;
|
|
6108
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
6109
|
+
role: "row",
|
|
6110
|
+
"aria-rowindex": rowIndex + 1,
|
|
6111
|
+
className: heatmap_chart_module_default["heatmap-chart__row"],
|
|
6112
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
6113
|
+
"aria-hidden": "true",
|
|
6114
|
+
className: heatmap_chart_module_default["heatmap-chart__row-label"],
|
|
6115
|
+
children: labelVisible ? rowLabels[rowIndex] ?? "" : ""
|
|
6116
|
+
}), data.map((column, columnIndex) => {
|
|
6117
|
+
const value = column.data[rowIndex]?.value ?? null;
|
|
6118
|
+
const present = isPresent(value);
|
|
6119
|
+
const normalized = present ? getNormalizedValue(value, extent) : 0;
|
|
6120
|
+
const flatIndex = columnIndex * rows + rowIndex;
|
|
6121
|
+
const info = buildTooltipData(columnIndex, rowIndex);
|
|
6122
|
+
const accessibleLabel = `${info.cellLabel || `${info.columnLabel ?? ""} ${info.rowLabel ?? ""}`.trim()}: ${info.value === null ? __("No data", "jetpack-charts") : formatNumber(info.value)}`;
|
|
6123
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6124
|
+
id: `${chartId}-cell-${columnIndex}-${rowIndex}`,
|
|
6125
|
+
role: "gridcell",
|
|
6126
|
+
tabIndex: -1,
|
|
6127
|
+
"aria-colindex": columnIndex + 1,
|
|
6128
|
+
"aria-label": accessibleLabel,
|
|
6129
|
+
"data-column": columnIndex,
|
|
6130
|
+
"data-row": rowIndex,
|
|
6131
|
+
className: clsx(heatmap_chart_module_default["heatmap-chart__cell"], {
|
|
6132
|
+
[heatmap_chart_module_default["heatmap-chart__cell--filled"]]: present,
|
|
6133
|
+
[heatmap_chart_module_default["heatmap-chart__cell--strong"]]: present && cellHasLightText(normalized),
|
|
6134
|
+
[heatmap_chart_module_default["heatmap-chart__cell--selected"]]: selectedIndex === flatIndex
|
|
6135
|
+
}),
|
|
6136
|
+
style: present ? { "--intensity": normalized } : void 0,
|
|
6137
|
+
onMouseMove: handleCellMouseMove,
|
|
6138
|
+
onMouseLeave: handleCellMouseLeave,
|
|
6139
|
+
children: drawValues && present && /* @__PURE__ */ jsx("span", {
|
|
6140
|
+
className: heatmap_chart_module_default["heatmap-chart__cell-value"],
|
|
6141
|
+
children: formatNumberCompact(value)
|
|
6142
|
+
})
|
|
6143
|
+
}, `cell-${columnIndex}-${rowIndex}`);
|
|
6144
|
+
})]
|
|
6145
|
+
}, `row-${rowIndex}`);
|
|
6146
|
+
})
|
|
6147
|
+
]
|
|
6148
|
+
}), withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ jsx(TooltipInPortal, {
|
|
6149
|
+
top: tooltipTop,
|
|
6150
|
+
left: tooltipLeft,
|
|
6151
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
6152
|
+
role: "tooltip",
|
|
6153
|
+
tabIndex: -1,
|
|
6154
|
+
children: (renderTooltip ?? defaultRenderTooltip)(tooltipData)
|
|
6155
|
+
})
|
|
6156
|
+
})]
|
|
6157
|
+
})
|
|
6158
|
+
})
|
|
6159
|
+
});
|
|
6160
|
+
};
|
|
6161
|
+
const HeatmapChartWithProvider = (props) => {
|
|
6162
|
+
if (useContext(GlobalChartsContext)) return /* @__PURE__ */ jsx(HeatmapChartInternal, { ...props });
|
|
6163
|
+
return /* @__PURE__ */ jsx(GlobalChartsProvider, { children: /* @__PURE__ */ jsx(HeatmapChartInternal, { ...props }) });
|
|
6164
|
+
};
|
|
6165
|
+
HeatmapChartWithProvider.displayName = "HeatmapChart";
|
|
6166
|
+
const HeatmapChart = attachSubComponents(HeatmapChartWithProvider, { Legend: HeatmapLegend });
|
|
6167
|
+
const HeatmapChartResponsiveInner = (props) => /* @__PURE__ */ jsx(HeatmapChartWithProvider, {
|
|
6168
|
+
...props,
|
|
6169
|
+
width: void 0,
|
|
6170
|
+
height: void 0
|
|
6171
|
+
});
|
|
6172
|
+
HeatmapChartResponsiveInner.displayName = "HeatmapChart";
|
|
6173
|
+
const HeatmapChartResponsive = attachSubComponents(withResponsive(HeatmapChartResponsiveInner), { Legend: HeatmapLegend });
|
|
6174
|
+
//#endregion
|
|
6175
|
+
//#region ../../../node_modules/.pnpm/@wordpress+warning@3.50.0/node_modules/@wordpress/warning/build-module/utils.mjs
|
|
5703
6176
|
var logged = /* @__PURE__ */ new Set();
|
|
5704
6177
|
//#endregion
|
|
5705
|
-
//#region ../../../node_modules/.pnpm/@wordpress+warning@3.
|
|
6178
|
+
//#region ../../../node_modules/.pnpm/@wordpress+warning@3.50.0/node_modules/@wordpress/warning/build-module/index.mjs
|
|
5706
6179
|
function isDev() {
|
|
5707
6180
|
return globalThis.SCRIPT_DEBUG === true;
|
|
5708
6181
|
}
|
|
@@ -5716,7 +6189,7 @@ function warning(message) {
|
|
|
5716
6189
|
logged.add(message);
|
|
5717
6190
|
}
|
|
5718
6191
|
//#endregion
|
|
5719
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
6192
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/constants.mjs
|
|
5720
6193
|
var COMPONENT_NAMESPACE = "data-wp-component";
|
|
5721
6194
|
var CONNECTED_NAMESPACE = "data-wp-c16t";
|
|
5722
6195
|
var CONNECT_STATIC_NAMESPACE = "__contextSystemKey__";
|
|
@@ -5858,13 +6331,13 @@ function memize(fn, options) {
|
|
|
5858
6331
|
return memoized;
|
|
5859
6332
|
}
|
|
5860
6333
|
//#endregion
|
|
5861
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
6334
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/get-styled-class-name-from-key.mjs
|
|
5862
6335
|
function getStyledClassName(namespace) {
|
|
5863
6336
|
return `components-${paramCase(namespace)}`;
|
|
5864
6337
|
}
|
|
5865
6338
|
var getStyledClassNameFromKey = memize(getStyledClassName);
|
|
5866
6339
|
//#endregion
|
|
5867
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
6340
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/context-connect.mjs
|
|
5868
6341
|
function contextConnect(Component, namespace) {
|
|
5869
6342
|
return _contextConnect(Component, namespace, { forwardsRef: true });
|
|
5870
6343
|
}
|
|
@@ -5949,7 +6422,7 @@ function isPlainObject(o) {
|
|
|
5949
6422
|
return true;
|
|
5950
6423
|
}
|
|
5951
6424
|
//#endregion
|
|
5952
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
6425
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/hooks/use-update-effect.mjs
|
|
5953
6426
|
function useUpdateEffect(effect, deps) {
|
|
5954
6427
|
const mountedRef = useRef$1(false);
|
|
5955
6428
|
useEffect$1(() => {
|
|
@@ -5962,7 +6435,7 @@ function useUpdateEffect(effect, deps) {
|
|
|
5962
6435
|
}
|
|
5963
6436
|
var use_update_effect_default = useUpdateEffect;
|
|
5964
6437
|
//#endregion
|
|
5965
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
6438
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/context-system-provider.mjs
|
|
5966
6439
|
var import_es6 = /* @__PURE__ */ __toESM(require_es6(), 1);
|
|
5967
6440
|
var ComponentsContext = createContext$1(
|
|
5968
6441
|
/** @type {Record<string, any>} */
|
|
@@ -5989,7 +6462,7 @@ var BaseContextSystemProvider = ({ children, value }) => {
|
|
|
5989
6462
|
};
|
|
5990
6463
|
memo(BaseContextSystemProvider);
|
|
5991
6464
|
//#endregion
|
|
5992
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
6465
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/utils.mjs
|
|
5993
6466
|
function getNamespace(componentName) {
|
|
5994
6467
|
return { [COMPONENT_NAMESPACE]: componentName };
|
|
5995
6468
|
}
|
|
@@ -7540,7 +8013,7 @@ _createEmotion.css;
|
|
|
7540
8013
|
_createEmotion.sheet;
|
|
7541
8014
|
_createEmotion.cache;
|
|
7542
8015
|
//#endregion
|
|
7543
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8016
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/hooks/use-cx.mjs
|
|
7544
8017
|
var isSerializedStyles = (o) => typeof o !== "undefined" && o !== null && ["name", "styles"].every((p) => typeof o[p] !== "undefined");
|
|
7545
8018
|
var useCx = () => {
|
|
7546
8019
|
const cache = __unsafe_useEmotionCache();
|
|
@@ -7556,7 +8029,7 @@ var useCx = () => {
|
|
|
7556
8029
|
}, [cache]);
|
|
7557
8030
|
};
|
|
7558
8031
|
//#endregion
|
|
7559
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8032
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/context/use-context-system.mjs
|
|
7560
8033
|
function useContextSystem(props, namespace) {
|
|
7561
8034
|
const contextSystemProps = useComponentsContext();
|
|
7562
8035
|
if (typeof namespace === "undefined") globalThis.SCRIPT_DEBUG === true && warning("useContextSystem: Please provide a namespace");
|
|
@@ -7611,7 +8084,7 @@ var Insertion = function Insertion(_ref) {
|
|
|
7611
8084
|
return null;
|
|
7612
8085
|
};
|
|
7613
8086
|
//#endregion
|
|
7614
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8087
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/view/component.mjs
|
|
7615
8088
|
var PolymorphicDiv = /* @__PURE__ */ function createStyled(tag, options) {
|
|
7616
8089
|
var isReal = tag.__emotion_real === tag;
|
|
7617
8090
|
var baseTag = isReal && tag.__emotion_base || tag;
|
|
@@ -7693,7 +8166,7 @@ function UnforwardedView({ as, ...restProps }, ref) {
|
|
|
7693
8166
|
}
|
|
7694
8167
|
var component_default$1 = Object.assign(forwardRef$1(UnforwardedView), { selector: ".components-view" });
|
|
7695
8168
|
//#endregion
|
|
7696
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8169
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/grid/utils.mjs
|
|
7697
8170
|
var ALIGNMENTS = {
|
|
7698
8171
|
bottom: {
|
|
7699
8172
|
alignItems: "flex-end",
|
|
@@ -7741,7 +8214,7 @@ function getAlignmentProps(alignment) {
|
|
|
7741
8214
|
return alignment ? ALIGNMENTS[alignment] : {};
|
|
7742
8215
|
}
|
|
7743
8216
|
//#endregion
|
|
7744
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8217
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/use-responsive-value.mjs
|
|
7745
8218
|
var breakpoints = [
|
|
7746
8219
|
"40em",
|
|
7747
8220
|
"52em",
|
|
@@ -7775,7 +8248,7 @@ function useResponsiveValue(values, options = {}) {
|
|
|
7775
8248
|
return array[index >= array.length ? array.length - 1 : index];
|
|
7776
8249
|
}
|
|
7777
8250
|
//#endregion
|
|
7778
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8251
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/colors-values.mjs
|
|
7779
8252
|
var white = "#fff";
|
|
7780
8253
|
var GRAY = {
|
|
7781
8254
|
900: "#1e1e1e",
|
|
@@ -7802,21 +8275,21 @@ var THEME = {
|
|
|
7802
8275
|
accentDarker10: `var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6))`,
|
|
7803
8276
|
accentDarker20: `var(--wp-components-color-accent-darker-20, var(--wp-admin-theme-color-darker-20, #183ad6))`,
|
|
7804
8277
|
/** Used when placing text on the accent color. */
|
|
7805
|
-
accentInverted: `var(--wp-components-color-accent-inverted,
|
|
7806
|
-
background: `var(--wp-components-color-background,
|
|
7807
|
-
foreground: `var(--wp-components-color-foreground,
|
|
8278
|
+
accentInverted: `var(--wp-components-color-accent-inverted, var(--wpds-color-foreground-interactive-brand-strong, #fff))`,
|
|
8279
|
+
background: `var(--wp-components-color-background, var(--wpds-color-background-surface-neutral-strong, #fff))`,
|
|
8280
|
+
foreground: `var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,
|
|
7808
8281
|
/** Used when placing text on the foreground color. */
|
|
7809
|
-
foregroundInverted: `var(--wp-components-color-foreground-inverted,
|
|
8282
|
+
foregroundInverted: `var(--wp-components-color-foreground-inverted, var(--wpds-color-background-surface-neutral, #fcfcfc))`,
|
|
7810
8283
|
gray: {
|
|
7811
8284
|
/** @deprecated Use `COLORS.theme.foreground` instead. */
|
|
7812
|
-
900: `var(--wp-components-color-foreground,
|
|
7813
|
-
800: `var(--wp-components-color-gray-800,
|
|
7814
|
-
700: `var(--wp-components-color-gray-700,
|
|
7815
|
-
600: `var(--wp-components-color-gray-600,
|
|
7816
|
-
400: `var(--wp-components-color-gray-400,
|
|
7817
|
-
300: `var(--wp-components-color-gray-300,
|
|
7818
|
-
200: `var(--wp-components-color-gray-200,
|
|
7819
|
-
100: `var(--wp-components-color-gray-100,
|
|
8285
|
+
900: `var(--wp-components-color-foreground, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,
|
|
8286
|
+
800: `var(--wp-components-color-gray-800, var(--wpds-color-foreground-content-neutral, #1e1e1e))`,
|
|
8287
|
+
700: `var(--wp-components-color-gray-700, var(--wpds-color-foreground-content-neutral-weak, #707070))`,
|
|
8288
|
+
600: `var(--wp-components-color-gray-600, var(--wpds-color-stroke-interactive-neutral, #8d8d8d))`,
|
|
8289
|
+
400: `var(--wp-components-color-gray-400, var(--wpds-color-stroke-interactive-neutral, #8d8d8d))`,
|
|
8290
|
+
300: `var(--wp-components-color-gray-300, var(--wpds-color-stroke-surface-neutral, #dbdbdb))`,
|
|
8291
|
+
200: `var(--wp-components-color-gray-200, var(--wpds-color-stroke-surface-neutral, #dbdbdb))`,
|
|
8292
|
+
100: `var(--wp-components-color-gray-100, var(--wpds-color-background-surface-neutral, #fcfcfc))`
|
|
7820
8293
|
}
|
|
7821
8294
|
};
|
|
7822
8295
|
var UI = {
|
|
@@ -7854,7 +8327,7 @@ var COLORS = Object.freeze({
|
|
|
7854
8327
|
ui: UI
|
|
7855
8328
|
});
|
|
7856
8329
|
//#endregion
|
|
7857
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8330
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/config-values.mjs
|
|
7858
8331
|
var CONTROL_HEIGHT = "36px";
|
|
7859
8332
|
var CONTROL_PROPS = {
|
|
7860
8333
|
controlPaddingX: 12,
|
|
@@ -7919,7 +8392,7 @@ var config_values_default = Object.assign({}, CONTROL_PROPS, {
|
|
|
7919
8392
|
transitionTimingFunctionControl: "cubic-bezier(0.12, 0.8, 0.32, 1)"
|
|
7920
8393
|
});
|
|
7921
8394
|
//#endregion
|
|
7922
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8395
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/grid/hook.mjs
|
|
7923
8396
|
function useGrid(props) {
|
|
7924
8397
|
const { align, alignment, className, columnGap, columns = 2, gap = 3, isInline = false, justify, rowGap, rows, templateColumns, templateRows, ...otherProps } = useContextSystem(props, "Grid");
|
|
7925
8398
|
const column = useResponsiveValue(Array.isArray(columns) ? columns : [columns]);
|
|
@@ -7960,7 +8433,7 @@ function useGrid(props) {
|
|
|
7960
8433
|
};
|
|
7961
8434
|
}
|
|
7962
8435
|
//#endregion
|
|
7963
|
-
//#region ../../../node_modules/.pnpm/@wordpress+components@
|
|
8436
|
+
//#region ../../../node_modules/.pnpm/@wordpress+components@36.1.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/grid/component.mjs
|
|
7964
8437
|
function UnconnectedGrid(props, forwardedRef) {
|
|
7965
8438
|
return /* @__PURE__ */ jsx(component_default$1, {
|
|
7966
8439
|
...useGrid(props),
|
|
@@ -9087,6 +9560,6 @@ function TrendIndicator({ direction, value, className, style, showIcon = true })
|
|
|
9087
9560
|
});
|
|
9088
9561
|
}
|
|
9089
9562
|
//#endregion
|
|
9090
|
-
export { AccessibleTooltip, AreaChartResponsive as AreaChart, AreaChart as AreaChartUnresponsive, BarChartResponsive as BarChart, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, BarListChart as BarListChartUnresponsive, BaseTooltip, ConversionFunnelChartWithProvider as ConversionFunnelChart, GeoChartResponsive as GeoChart, GeoChartWithProvider as GeoChartUnresponsive, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, LeaderboardChartResponsive as LeaderboardChart, LeaderboardChart as LeaderboardChartUnresponsive, Legend, LineChartResponsive as LineChart, LineChart as LineChartUnresponsive, PieChartResponsive as PieChart, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, PieSemiCircleChart as PieSemiCircleChartUnresponsive, Sparkline, SparklineUnresponsive, TrendIndicator, defaultTheme, formatMetricValue, formatPercentage, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, normalizeColorToHex, parseAsLocalDate, parseHslString, parseRgbString, useChartLegendItems, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, validateHexColor };
|
|
9563
|
+
export { AccessibleTooltip, AreaChartResponsive as AreaChart, AreaChart as AreaChartUnresponsive, BarChartResponsive as BarChart, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, BarListChart as BarListChartUnresponsive, BaseTooltip, ConversionFunnelChartWithProvider as ConversionFunnelChart, GeoChartResponsive as GeoChart, GeoChartWithProvider as GeoChartUnresponsive, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, HeatmapChartResponsive as HeatmapChart, HeatmapChart as HeatmapChartUnresponsive, LeaderboardChartResponsive as LeaderboardChart, LeaderboardChart as LeaderboardChartUnresponsive, Legend, LineChartResponsive as LineChart, LineChart as LineChartUnresponsive, PieChartResponsive as PieChart, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, PieSemiCircleChart as PieSemiCircleChartUnresponsive, Sparkline, SparklineUnresponsive, TrendIndicator, buildCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, normalizeColorToHex, parseAsLocalDate, parseHslString, parseRgbString, prefersLightText, relativeLuminance, useChartLegendItems, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, validateHexColor };
|
|
9091
9564
|
|
|
9092
9565
|
//# sourceMappingURL=index.js.map
|