@automattic/charts 4.7.0 → 4.8.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/TOKENS.md +6 -3
- package/dist/index.cjs +212 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +10 -9
- package/dist/index.d.cts +60 -20
- package/dist/index.d.ts +60 -20
- package/dist/index.js +212 -97
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/charts/area-chart/area-chart.tsx +2 -2
- package/src/charts/area-chart/test/area-chart.test.tsx +1 -1
- package/src/charts/area-chart/test/tooltip-resolution-branches.test.tsx +1 -1
- package/src/charts/bar-chart/bar-chart.module.scss +7 -0
- package/src/charts/bar-chart/bar-chart.tsx +20 -14
- package/src/charts/bar-chart/private/comparison-bars.tsx +1 -0
- package/src/charts/bar-chart/test/bar-chart.test.tsx +25 -0
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +1 -1
- package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +9 -0
- package/src/charts/heatmap-chart/heatmap-chart.module.scss +6 -4
- package/src/charts/heatmap-chart/heatmap-chart.tsx +39 -29
- package/src/charts/heatmap-chart/private/heatmap-context.ts +2 -2
- package/src/charts/heatmap-chart/private/heatmap-legend.tsx +2 -2
- package/src/charts/heatmap-chart/private/heatmap-scale.ts +74 -0
- package/src/charts/heatmap-chart/private/index.ts +2 -1
- package/src/charts/heatmap-chart/private/use-heatmap-colors.ts +24 -6
- package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +99 -7
- package/src/charts/heatmap-chart/test/heatmap-scale.test.ts +78 -0
- package/src/charts/heatmap-chart/test/use-heatmap-colors.test.ts +18 -6
- package/src/charts/heatmap-chart/types.ts +4 -3
- package/src/charts/line-chart/line-chart.tsx +2 -2
- package/src/charts/pie-chart/pie-chart.tsx +4 -4
- package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.tsx +4 -4
- package/src/charts/pie-semi-circle-chart/test/pie-semi-circle-chart.test.tsx +1 -1
- package/src/charts/private/test/label-text-color.test.ts +6 -8
- package/src/components/tooltip/base-tooltip.tsx +31 -32
- package/src/components/tooltip/index.ts +3 -1
- package/src/components/tooltip/private/bounded-tooltip.tsx +15 -15
- package/src/components/tooltip/private/label-value-content.tsx +8 -0
- package/src/components/tooltip/private/xy-chart-tooltip-overlay.tsx +336 -0
- package/src/components/tooltip/test/tool-tip.test.tsx +8 -6
- package/src/components/tooltip/test/tooltip-box.test.tsx +53 -0
- package/src/components/tooltip/test/xy-chart-tooltip-overlay.test.tsx +445 -0
- package/src/components/tooltip/test/xy-chart-tooltip.test.tsx +282 -365
- package/src/components/tooltip/{base-tooltip.module.scss → tooltip-box.module.scss} +5 -8
- package/src/components/tooltip/tooltip-box.tsx +43 -0
- package/src/components/tooltip/types.ts +7 -1
- package/src/components/tooltip/xy-chart-tooltip.tsx +410 -300
- package/src/hooks/test/use-chart-margin.test.tsx +8 -4
- package/src/hooks/use-chart-margin.tsx +21 -18
- package/src/index.ts +8 -3
- package/src/providers/chart-context/global-charts-provider.tsx +5 -14
- package/src/providers/chart-context/hooks/use-default-hidden-series.ts +1 -1
- package/src/providers/chart-context/private/catalog-pointers.ts +1 -0
- package/src/providers/chart-context/private/resolve-opaque-hex.ts +16 -0
- package/src/providers/chart-context/test/use-default-hidden-series.test.tsx +1 -1
- package/src/styles/chart-scope.scss +1 -0
- package/src/test-utils/zoned-parsing-suite.ts +0 -10
- package/src/utils/test/date-formatting.test.ts +0 -10
- package/src/components/tooltip/accessible-tooltip.tsx +0 -433
- package/src/components/tooltip/test/accessible-tooltip.test.tsx +0 -331
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// `.surface` is the look alone, for a chart that positions the box itself.
|
|
2
|
-
// The box carries the
|
|
2
|
+
// The box carries the tooltip scope class inside TooltipTheme, so these roles
|
|
3
3
|
// resolve for the dark tooltip theme, as in @wordpress/ui's Tooltip popup.
|
|
4
|
-
.surface
|
|
5
|
-
.tooltip {
|
|
4
|
+
.surface {
|
|
6
5
|
padding: var(--wpds-dimension-padding-xs) var(--wpds-dimension-padding-sm);
|
|
7
6
|
background-color: var(--a8c-charts-color-surface);
|
|
8
7
|
color: var(--a8c-charts-color-label);
|
|
@@ -12,13 +11,11 @@
|
|
|
12
11
|
line-height: 1.4;
|
|
13
12
|
box-shadow: var(--a8c-charts-elevation-sm, 0 1px 2px 0 #0000000d, 0 2px 3px 0 #0000000a, 0 6px 6px 0 #00000008, 0 8px 8px 0 #00000005);
|
|
14
13
|
pointer-events: none;
|
|
14
|
+
// Beats a host `max-width` on `.visx-tooltip`, even an `!important`
|
|
15
|
+
// one: WordPress.com's Help Center caps it at 150px.
|
|
16
|
+
min-width: fit-content;
|
|
15
17
|
|
|
16
18
|
@media (forced-colors: active) {
|
|
17
19
|
border: var(--wpds-border-width-xs) solid CanvasText;
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
.tooltip {
|
|
22
|
-
position: absolute;
|
|
23
|
-
transform: translate(-50%, -100%);
|
|
24
|
-
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { TOOLTIP_SCOPE_CLASS } from '../../styles/chart-scope-class';
|
|
4
|
+
import { TooltipTheme } from './private/tooltip-theme';
|
|
5
|
+
import styles from './tooltip-box.module.scss';
|
|
6
|
+
import type { HTMLAttributes } from 'react';
|
|
7
|
+
|
|
8
|
+
type TooltipBoxProps = HTMLAttributes< HTMLDivElement > & {
|
|
9
|
+
/** Drop the chart surface, scope class and dark theme, leaving a bare box. */
|
|
10
|
+
unstyled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The chart tooltip box: the dark surface every chart tooltip draws. It does not position itself; place it with `style` or a wrapper.
|
|
15
|
+
*
|
|
16
|
+
* @param props - Div attributes, plus `unstyled`.
|
|
17
|
+
* @param props.unstyled - Drop the surface, scope class and theme.
|
|
18
|
+
* @param ref - Forwarded to the box element.
|
|
19
|
+
* @return The tooltip box.
|
|
20
|
+
*/
|
|
21
|
+
export const TooltipBox = forwardRef< HTMLDivElement, TooltipBoxProps >(
|
|
22
|
+
( { unstyled = false, role = 'tooltip', className, children, ...rest }, ref ) => {
|
|
23
|
+
const box = (
|
|
24
|
+
<div
|
|
25
|
+
ref={ ref }
|
|
26
|
+
role={ role }
|
|
27
|
+
className={ clsx(
|
|
28
|
+
'visx-tooltip',
|
|
29
|
+
! unstyled && [ TOOLTIP_SCOPE_CLASS, styles.surface ],
|
|
30
|
+
className
|
|
31
|
+
) }
|
|
32
|
+
{ ...rest }
|
|
33
|
+
>
|
|
34
|
+
{ children }
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
return unstyled ? box : <TooltipTheme>{ box }</TooltipTheme>;
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
TooltipBox.displayName = 'TooltipBox';
|
|
42
|
+
|
|
43
|
+
export type { TooltipBoxProps };
|