@redsift/charts 11.5.0-muiv5 → 11.6.0-muiv5-alpha.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/_virtual/_rollupPluginBabelHelpers.js +93 -0
- package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/components/Arc/Arc.d.ts +6 -0
- package/components/Arc/Arc.js +74 -0
- package/components/Arc/Arc.js.map +1 -0
- package/components/Arc/styles.d.ts +17 -0
- package/components/Arc/styles.js +49 -0
- package/components/Arc/styles.js.map +1 -0
- package/components/Arc/types.d.ts +20 -0
- package/components/Arcs/Arcs.d.ts +6 -0
- package/components/Arcs/Arcs.js +90 -0
- package/components/Arcs/Arcs.js.map +1 -0
- package/components/Arcs/styles.d.ts +9 -0
- package/components/Arcs/styles.js +9 -0
- package/components/Arcs/styles.js.map +1 -0
- package/components/Arcs/types.d.ts +17 -0
- package/components/Axis/Axis.d.ts +7 -0
- package/components/Axis/Axis.js +211 -0
- package/components/Axis/Axis.js.map +1 -0
- package/components/Axis/computeTicks.js +117 -0
- package/components/Axis/computeTicks.js.map +1 -0
- package/components/Axis/styles.d.ts +14 -0
- package/components/Axis/styles.js +51 -0
- package/components/Axis/styles.js.map +1 -0
- package/components/Axis/types.d.ts +89 -0
- package/components/Axis/types.js +24 -0
- package/components/Axis/types.js.map +1 -0
- package/components/Bar/Bar.d.ts +6 -0
- package/components/Bar/Bar.js +95 -0
- package/components/Bar/Bar.js.map +1 -0
- package/components/Bar/styles.d.ts +16 -0
- package/components/Bar/styles.js +66 -0
- package/components/Bar/styles.js.map +1 -0
- package/components/Bar/types.d.ts +46 -0
- package/components/Bar/types.js +18 -0
- package/components/Bar/types.js.map +1 -0
- package/components/BarChart/BarChart.d.ts +29 -0
- package/components/BarChart/BarChart.js +141 -0
- package/components/BarChart/BarChart.js.map +1 -0
- package/components/BarChart/BarChartBars.js +168 -0
- package/components/BarChart/BarChartBars.js.map +1 -0
- package/components/BarChart/BarChartSection.js +139 -0
- package/components/BarChart/BarChartSection.js.map +1 -0
- package/components/BarChart/EmptyBarChart.js +57 -0
- package/components/BarChart/EmptyBarChart.js.map +1 -0
- package/components/BarChart/LoadingBarChart.js +18 -0
- package/components/BarChart/LoadingBarChart.js.map +1 -0
- package/components/BarChart/RenderedLinearBarChart.js +549 -0
- package/components/BarChart/RenderedLinearBarChart.js.map +1 -0
- package/components/BarChart/RenderedOrdinalBarChart.js +236 -0
- package/components/BarChart/RenderedOrdinalBarChart.js.map +1 -0
- package/components/BarChart/context.js +13 -0
- package/components/BarChart/context.js.map +1 -0
- package/components/BarChart/intl/en-US.json.js +17 -0
- package/components/BarChart/intl/en-US.json.js.map +1 -0
- package/components/BarChart/intl/fr-FR.json.js +17 -0
- package/components/BarChart/intl/fr-FR.json.js.map +1 -0
- package/components/BarChart/intl/index.js +10 -0
- package/components/BarChart/intl/index.js.map +1 -0
- package/components/BarChart/styles.d.ts +19 -0
- package/components/BarChart/styles.js +71 -0
- package/components/BarChart/styles.js.map +1 -0
- package/components/BarChart/types.d.ts +177 -0
- package/components/BarChart/types.js +17 -0
- package/components/BarChart/types.js.map +1 -0
- package/components/BarChart/utils.js +69 -0
- package/components/BarChart/utils.js.map +1 -0
- package/components/ChartContainer/ChartContainer.d.ts +9 -0
- package/components/ChartContainer/ChartContainer.js +167 -0
- package/components/ChartContainer/ChartContainer.js.map +1 -0
- package/components/ChartContainer/context.js +6 -0
- package/components/ChartContainer/context.js.map +1 -0
- package/components/ChartContainer/intl/en-US.json.js +14 -0
- package/components/ChartContainer/intl/en-US.json.js.map +1 -0
- package/components/ChartContainer/intl/fr-FR.json.js +14 -0
- package/components/ChartContainer/intl/fr-FR.json.js.map +1 -0
- package/components/ChartContainer/intl/index.js +10 -0
- package/components/ChartContainer/intl/index.js.map +1 -0
- package/components/ChartContainer/styles.d.ts +17 -0
- package/components/ChartContainer/styles.js +76 -0
- package/components/ChartContainer/styles.js.map +1 -0
- package/components/ChartContainer/types.d.ts +48 -0
- package/components/DataPoint/DataPoint.d.ts +6 -0
- package/components/DataPoint/DataPoint.js +104 -0
- package/components/DataPoint/DataPoint.js.map +1 -0
- package/components/DataPoint/styles.d.ts +12 -0
- package/components/DataPoint/styles.js +10 -0
- package/components/DataPoint/styles.js.map +1 -0
- package/components/DataPoint/types.d.ts +60 -0
- package/components/Dot/Dot.d.ts +6 -0
- package/components/Dot/Dot.js +55 -0
- package/components/Dot/Dot.js.map +1 -0
- package/components/Dot/styles.d.ts +16 -0
- package/components/Dot/styles.js +49 -0
- package/components/Dot/styles.js.map +1 -0
- package/components/Dot/types.d.ts +30 -0
- package/components/Dot/types.js +14 -0
- package/components/Dot/types.js.map +1 -0
- package/components/Legend/Legend.d.ts +6 -0
- package/components/Legend/Legend.js +73 -0
- package/components/Legend/Legend.js.map +1 -0
- package/components/Legend/styles.d.ts +11 -0
- package/components/Legend/styles.js +15 -0
- package/components/Legend/styles.js.map +1 -0
- package/components/Legend/types.d.ts +44 -0
- package/components/LegendItem/LegendItem.js +96 -0
- package/components/LegendItem/LegendItem.js.map +1 -0
- package/components/LegendItem/styles.js +63 -0
- package/components/LegendItem/styles.js.map +1 -0
- package/components/LegendItem/types.d.ts +20 -0
- package/components/Line/Line.d.ts +6 -0
- package/components/Line/Line.js +55 -0
- package/components/Line/Line.js.map +1 -0
- package/components/Line/styles.d.ts +9 -0
- package/components/Line/styles.js +9 -0
- package/components/Line/styles.js.map +1 -0
- package/components/Line/types.d.ts +21 -0
- package/components/LineChart/EmptyLineChart.js +58 -0
- package/components/LineChart/EmptyLineChart.js.map +1 -0
- package/components/LineChart/LineChart.d.ts +6 -0
- package/components/LineChart/LineChart.js +96 -0
- package/components/LineChart/LineChart.js.map +1 -0
- package/components/LineChart/LoadingLineChart.js +18 -0
- package/components/LineChart/LoadingLineChart.js.map +1 -0
- package/components/LineChart/RenderedLineChart.js +372 -0
- package/components/LineChart/RenderedLineChart.js.map +1 -0
- package/components/LineChart/intl/en-US.json.js +17 -0
- package/components/LineChart/intl/en-US.json.js.map +1 -0
- package/components/LineChart/intl/fr-FR.json.js +17 -0
- package/components/LineChart/intl/fr-FR.json.js.map +1 -0
- package/components/LineChart/intl/index.js +10 -0
- package/components/LineChart/intl/index.js.map +1 -0
- package/components/LineChart/styles.d.ts +17 -0
- package/components/LineChart/styles.js +53 -0
- package/components/LineChart/styles.js.map +1 -0
- package/components/LineChart/types.d.ts +90 -0
- package/components/LineChart/types.js +17 -0
- package/components/LineChart/types.js.map +1 -0
- package/components/LineChart/utils.js +67 -0
- package/components/LineChart/utils.js.map +1 -0
- package/components/PieChart/EmptyPieChart.js +85 -0
- package/components/PieChart/EmptyPieChart.js.map +1 -0
- package/components/PieChart/LoadingPieChart.js +18 -0
- package/components/PieChart/LoadingPieChart.js.map +1 -0
- package/components/PieChart/PieChart.d.ts +6 -0
- package/components/PieChart/PieChart.js +98 -0
- package/components/PieChart/PieChart.js.map +1 -0
- package/components/PieChart/RenderedPieChart.js +198 -0
- package/components/PieChart/RenderedPieChart.js.map +1 -0
- package/components/PieChart/intl/en-US.json.js +9 -0
- package/components/PieChart/intl/en-US.json.js.map +1 -0
- package/components/PieChart/intl/fr-FR.json.js +9 -0
- package/components/PieChart/intl/fr-FR.json.js.map +1 -0
- package/components/PieChart/intl/index.js +10 -0
- package/components/PieChart/intl/index.js.map +1 -0
- package/components/PieChart/styles.d.ts +24 -0
- package/components/PieChart/styles.js +168 -0
- package/components/PieChart/styles.js.map +1 -0
- package/components/PieChart/types.d.ts +115 -0
- package/components/PieChart/types.js +27 -0
- package/components/PieChart/types.js.map +1 -0
- package/components/PieChart/utils.js +37 -0
- package/components/PieChart/utils.js.map +1 -0
- package/components/ScatterPlot/EmptyScatterPlot.js +58 -0
- package/components/ScatterPlot/EmptyScatterPlot.js.map +1 -0
- package/components/ScatterPlot/LoadingScatterPlot.js +18 -0
- package/components/ScatterPlot/LoadingScatterPlot.js.map +1 -0
- package/components/ScatterPlot/RenderedScatterPlot.js +352 -0
- package/components/ScatterPlot/RenderedScatterPlot.js.map +1 -0
- package/components/ScatterPlot/ScatterPlot.d.ts +6 -0
- package/components/ScatterPlot/ScatterPlot.js +105 -0
- package/components/ScatterPlot/ScatterPlot.js.map +1 -0
- package/components/ScatterPlot/intl/en-US.json.js +12 -0
- package/components/ScatterPlot/intl/en-US.json.js.map +1 -0
- package/components/ScatterPlot/intl/fr-FR.json.js +17 -0
- package/components/ScatterPlot/intl/fr-FR.json.js.map +1 -0
- package/components/ScatterPlot/intl/index.js +10 -0
- package/components/ScatterPlot/intl/index.js.map +1 -0
- package/components/ScatterPlot/styles.d.ts +17 -0
- package/components/ScatterPlot/styles.js +53 -0
- package/components/ScatterPlot/styles.js.map +1 -0
- package/components/ScatterPlot/types.d.ts +109 -0
- package/components/ScatterPlot/types.js +24 -0
- package/components/ScatterPlot/types.js.map +1 -0
- package/components/ScatterPlot/utils.js +70 -0
- package/components/ScatterPlot/utils.js.map +1 -0
- package/config.js +15 -0
- package/config.js.map +1 -0
- package/design-system/src/react-aria/react-aria/i18n/useMessageFormatter.d.ts +5 -0
- package/hooks/useBrush.d.ts +17 -0
- package/hooks/useBrush.js +48 -0
- package/hooks/useBrush.js.map +1 -0
- package/hooks/useColor.d.ts +18 -0
- package/hooks/useColor.js +20 -0
- package/hooks/useColor.js.map +1 -0
- package/hooks/useFormatCategoricalData.d.ts +26 -0
- package/hooks/useFormatCategoricalData.js +57 -0
- package/hooks/useFormatCategoricalData.js.map +1 -0
- package/hooks/useZoom.d.ts +26 -0
- package/hooks/useZoom.js +39 -0
- package/hooks/useZoom.js.map +1 -0
- package/index.d.ts +51 -1277
- package/index.js +42 -5118
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/scheme.d.ts +32 -0
- package/scheme.js +47 -0
- package/scheme.js.map +1 -0
- package/types/axis.d.ts +48 -0
- package/types/data.d.ts +72 -0
- package/types/legend.d.ts +30 -0
- package/types/legend.js +21 -0
- package/types/legend.js.map +1 -0
- package/types/scale.d.ts +48 -0
- package/types/size.d.ts +20 -0
- package/types/size.js +8 -0
- package/types/size.js.map +1 -0
- package/types/theme.d.ts +23 -0
- package/types/theme.js +13 -0
- package/types/theme.js.map +1 -0
- package/utils/index.d.ts +11 -0
- package/utils/index.js +44 -0
- package/utils/index.js.map +1 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { baseStyling, baseContainer, focusRing, Theme, Flexbox } from '@redsift/design-system';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component style.
|
|
6
|
+
*/
|
|
7
|
+
const StyledChartContainer = styled.div`
|
|
8
|
+
${baseStyling}
|
|
9
|
+
|
|
10
|
+
.redsift-chart-container__content {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: 16px;
|
|
14
|
+
font-family: var(--redsift-typography-font-family-poppins);
|
|
15
|
+
font-size: 11px;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
position: relative;
|
|
18
|
+
|
|
19
|
+
${baseContainer}
|
|
20
|
+
|
|
21
|
+
${focusRing}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
svg {
|
|
25
|
+
display: block;
|
|
26
|
+
user-select: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
text {
|
|
30
|
+
${_ref => {
|
|
31
|
+
let {
|
|
32
|
+
$theme
|
|
33
|
+
} = _ref;
|
|
34
|
+
return css`
|
|
35
|
+
fill: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});
|
|
36
|
+
`;
|
|
37
|
+
}}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
table {
|
|
41
|
+
border-collapse: collapse;
|
|
42
|
+
border: 1px solid #ebebeb;
|
|
43
|
+
margin: 10px auto;
|
|
44
|
+
text-align: center;
|
|
45
|
+
width: 100%;
|
|
46
|
+
max-width: 500px;
|
|
47
|
+
|
|
48
|
+
td, th, caption {
|
|
49
|
+
padding: 0.5em;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
caption {
|
|
53
|
+
padding: 1em 0;
|
|
54
|
+
font-size: 1.2em;
|
|
55
|
+
color: #555;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
thead tr, tr:nth-child(even) {
|
|
59
|
+
background: #f8f8f8;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
th {
|
|
63
|
+
font-weight: 600;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
const StyledChartContainerTitle = styled(Flexbox)``;
|
|
67
|
+
const StyledChartContainerCaption = styled.p`
|
|
68
|
+
font-family: var(--redsift-typography-caption-font-family);
|
|
69
|
+
font-size: var(--redsift-typography-caption-font-size);
|
|
70
|
+
font-weight: var(--redsift-typography-caption-font-weight);
|
|
71
|
+
line-height: var(--redsift-typography-caption-line-height);
|
|
72
|
+
margin: 8px 0;
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
export { StyledChartContainer, StyledChartContainerCaption, StyledChartContainerTitle };
|
|
76
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../src/components/ChartContainer/styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { Flexbox, Theme, baseContainer, baseStyling, focusRing } from '@redsift/design-system';\nimport { StyledChartContainerProps } from './types';\n\n/**\n * Component style.\n */\nexport const StyledChartContainer = styled.div<StyledChartContainerProps>`\n ${baseStyling}\n\n .redsift-chart-container__content {\n display: flex;\n align-items: center;\n gap: 16px;\n font-family: var(--redsift-typography-font-family-poppins);\n font-size: 11px;\n justify-content: center;\n position: relative;\n\n ${baseContainer}\n\n ${focusRing}\n }\n\n svg {\n display: block;\n user-select: none;\n }\n\n text {\n ${({ $theme }) => css`\n fill: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});\n `}\n }\n\n table {\n border-collapse: collapse;\n border: 1px solid #ebebeb;\n margin: 10px auto;\n text-align: center;\n width: 100%;\n max-width: 500px;\n\n td, th, caption {\n padding: 0.5em;\n }\n\n caption {\n padding: 1em 0;\n font-size: 1.2em;\n color: #555;\n }\n\n thead tr, tr:nth-child(even) {\n background: #f8f8f8;\n }\n\n th {\n font-weight: 600; \n }\n`;\n\nexport const StyledChartContainerTitle = styled(Flexbox)<StyledChartContainerProps>``;\n\nexport const StyledChartContainerCaption = styled.p<Omit<StyledChartContainerProps, 'onReset'>>`\n font-family: var(--redsift-typography-caption-font-family);\n font-size: var(--redsift-typography-caption-font-size);\n font-weight: var(--redsift-typography-caption-font-weight);\n line-height: var(--redsift-typography-caption-line-height);\n margin: 8px 0;\n`;\n"],"names":["StyledChartContainer","styled","div","baseStyling","baseContainer","focusRing","_ref","$theme","css","Theme","dark","StyledChartContainerTitle","Flexbox","StyledChartContainerCaption","p"],"mappings":";;;AAIA;AACA;AACA;AACaA,MAAAA,oBAAoB,GAAGC,MAAM,CAACC,GAA+B,CAAA;AAC1E,EAAA,EAAIC,WAAY,CAAA;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,EAAMC,aAAc,CAAA;AACpB;AACA,IAAA,EAAMC,SAAU,CAAA;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAA,EAAMC,IAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,MAAAA;AAAO,GAAC,GAAAD,IAAA,CAAA;AAAA,EAAA,OAAKE,GAAI,CAAA;AAC1B,wCAA0CD,EAAAA,MAAM,KAAKE,KAAK,CAACC,IAAI,GAAG,OAAO,GAAG,aAAc,CAAA;AAC1F,IAAK,CAAA,CAAA;AAAA,CAAC,CAAA;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;MAEYC,yBAAyB,GAAGV,MAAM,CAACW,OAAO,CAA6B,CAAC,EAAA;AAExEC,MAAAA,2BAA2B,GAAGZ,MAAM,CAACa,CAA8C,CAAA;AAChG;AACA;AACA;AACA;AACA;AACA;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ContainerProps, Theme } from '@redsift/design-system';
|
|
2
|
+
import { ComponentProps, RefObject, ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component props.
|
|
6
|
+
*/
|
|
7
|
+
interface ChartContainerProps extends Omit<ComponentProps<'div'>, 'title'>, ContainerProps {
|
|
8
|
+
/** Native HTML props to pass to the chart. */
|
|
9
|
+
chartProps?: ComponentProps<'div'>;
|
|
10
|
+
/** Ref to the chart. */
|
|
11
|
+
chartRef?: RefObject<HTMLDivElement>;
|
|
12
|
+
/** Description. */
|
|
13
|
+
description?: string | ReactElement;
|
|
14
|
+
/** Whether the description should be placed below the title or below the chart. */
|
|
15
|
+
descriptionPosition?: 'belowTitle' | 'belowChart';
|
|
16
|
+
/** Disable animations. */
|
|
17
|
+
disableAnimations?: boolean;
|
|
18
|
+
/** Id. */
|
|
19
|
+
id?: string;
|
|
20
|
+
/** Method called when the Reset button is displayed (defines whether or not the button should be displayed). */
|
|
21
|
+
onReset?: () => void;
|
|
22
|
+
/** Title. */
|
|
23
|
+
title?: string | ReactElement;
|
|
24
|
+
/** Theme. */
|
|
25
|
+
theme?: Theme;
|
|
26
|
+
/** Description that won't be visually displayed but will be used for assistive technology. If you want to display the description, use `description` instead. */
|
|
27
|
+
descriptionForAssistiveTechnology?: string;
|
|
28
|
+
/** Whether the chart is static or interactive. */
|
|
29
|
+
mode?: string;
|
|
30
|
+
/** Small text explaining which kind of chart is presenting and what's its basic composition. */
|
|
31
|
+
definition?: string;
|
|
32
|
+
/** Small text explaining the basic composition of the x-axis, if any. */
|
|
33
|
+
xAxisDefinition?: string;
|
|
34
|
+
/** Small text explaining the basic composition of the y-axis, if any. */
|
|
35
|
+
yAxisDefinition?: string;
|
|
36
|
+
/** Small text explaining how the chart is interactive, if any. */
|
|
37
|
+
interactionExplanation?: string;
|
|
38
|
+
/** Table representation of the chart. */
|
|
39
|
+
dataTableRepresentation?: {
|
|
40
|
+
header: ReactElement;
|
|
41
|
+
body: ReactElement;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
type StyledChartContainerProps = Omit<ChartContainerProps, 'theme'> & {
|
|
45
|
+
$theme: Theme;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { ChartContainerProps, StyledChartContainerProps };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React__default, { forwardRef } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { useId, useTheme, Text, Number } from '@redsift/design-system';
|
|
5
|
+
import { Tooltip } from '@redsift/popovers';
|
|
6
|
+
import { StyledDataPoint } from './styles.js';
|
|
7
|
+
import { TooltipVariant } from '../../types/legend.js';
|
|
8
|
+
|
|
9
|
+
const _excluded = ["as", "href"],
|
|
10
|
+
_excluded2 = ["anchorProps", "children", "className", "data", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipDecorator", "tooltipVariant", "theme", "tooltipProps", "dataset", "groupedData"];
|
|
11
|
+
const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
12
|
+
const {
|
|
13
|
+
anchorProps: {
|
|
14
|
+
as,
|
|
15
|
+
href
|
|
16
|
+
} = {},
|
|
17
|
+
children,
|
|
18
|
+
className,
|
|
19
|
+
data,
|
|
20
|
+
id: propsId,
|
|
21
|
+
index,
|
|
22
|
+
isSelected: propsIsSelected,
|
|
23
|
+
labelDecorator,
|
|
24
|
+
onClick,
|
|
25
|
+
role,
|
|
26
|
+
tooltipDecorator,
|
|
27
|
+
tooltipVariant,
|
|
28
|
+
theme: propsTheme,
|
|
29
|
+
tooltipProps,
|
|
30
|
+
dataset,
|
|
31
|
+
groupedData
|
|
32
|
+
} = props,
|
|
33
|
+
anchorProps = _objectWithoutProperties(props.anchorProps, _excluded),
|
|
34
|
+
forwardedProps = _objectWithoutProperties(props, _excluded2);
|
|
35
|
+
const [_id] = useId();
|
|
36
|
+
const id = propsId !== null && propsId !== void 0 ? propsId : _id;
|
|
37
|
+
const theme = useTheme(propsTheme);
|
|
38
|
+
const isTooltipCustom = tooltipVariant === TooltipVariant.custom && tooltipDecorator;
|
|
39
|
+
const text = labelDecorator ? labelDecorator(data, {
|
|
40
|
+
index,
|
|
41
|
+
isSelected: propsIsSelected,
|
|
42
|
+
color: props.color
|
|
43
|
+
}) : data.data.key;
|
|
44
|
+
const hasText = text && tooltipVariant !== TooltipVariant.none;
|
|
45
|
+
const tooltipValue = tooltipVariant === TooltipVariant.value ? data.data.value : tooltipVariant === TooltipVariant.percent && data.data.percent ? data.data.percent : undefined;
|
|
46
|
+
const hasValue = tooltipValue && [TooltipVariant.value, TooltipVariant.percent].includes(tooltipVariant);
|
|
47
|
+
const showTooltip = tooltipVariant !== TooltipVariant.none && (hasText || hasValue);
|
|
48
|
+
const isEmpty = data.data.value === 0;
|
|
49
|
+
const isSelectable = role === 'option';
|
|
50
|
+
const isSelected = isSelectable && propsIsSelected === true;
|
|
51
|
+
const isDeselected = isSelectable && propsIsSelected === false;
|
|
52
|
+
const onKeyDown = event => {
|
|
53
|
+
if (onClick) {
|
|
54
|
+
event.stopPropagation();
|
|
55
|
+
if (event.code === 'Enter' || event.code === 'Space') {
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
onClick(data, dataset);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const DataPointComponent = /*#__PURE__*/React__default.createElement(StyledDataPoint, _extends({
|
|
62
|
+
tabIndex: onClick ? 0 : undefined,
|
|
63
|
+
"aria-label": showTooltip && !isEmpty ? labelDecorator ? text : `${data.data.key}, ${data.data.value}` : undefined,
|
|
64
|
+
"aria-labelledby": !showTooltip && !isEmpty ? `${id}-title` : undefined,
|
|
65
|
+
"aria-selected": isSelected ? true : isDeselected ? false : undefined,
|
|
66
|
+
onClick: onClick ? () => onClick(data, dataset) : undefined,
|
|
67
|
+
onKeyDown: onClick ? e => onKeyDown(e) : undefined,
|
|
68
|
+
role: role ? role : onClick ? 'button' : href ? undefined : 'img'
|
|
69
|
+
}, forwardedProps, {
|
|
70
|
+
className: classNames(className, `_${index}`, {
|
|
71
|
+
selected: isSelected,
|
|
72
|
+
deselected: isDeselected
|
|
73
|
+
}),
|
|
74
|
+
ref: ref,
|
|
75
|
+
id: id,
|
|
76
|
+
$clickable: Boolean(onClick)
|
|
77
|
+
}), children, !showTooltip && !isEmpty ? /*#__PURE__*/React__default.createElement("title", {
|
|
78
|
+
id: `${id}-title`
|
|
79
|
+
}, `${text}: ${data.data.value}`) : null);
|
|
80
|
+
if (showTooltip) {
|
|
81
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
82
|
+
placement: "right",
|
|
83
|
+
theme: theme,
|
|
84
|
+
delay: 50
|
|
85
|
+
}, tooltipProps), /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, href !== undefined ? /*#__PURE__*/React__default.createElement(as || 'a', _objectSpread2({
|
|
86
|
+
href
|
|
87
|
+
}, anchorProps), DataPointComponent) : DataPointComponent), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, isTooltipCustom ? tooltipDecorator(data, {
|
|
88
|
+
index,
|
|
89
|
+
isSelected: propsIsSelected,
|
|
90
|
+
color: props.color
|
|
91
|
+
}, dataset, groupedData) : /*#__PURE__*/React__default.createElement(Text, {
|
|
92
|
+
variant: "caption"
|
|
93
|
+
}, text, hasText && hasValue ? ' - ' : null, hasValue ? /*#__PURE__*/React__default.createElement(Number, {
|
|
94
|
+
value: tooltipValue,
|
|
95
|
+
type: tooltipVariant === TooltipVariant.percent ? 'percent' : 'decimal',
|
|
96
|
+
variant: "caption",
|
|
97
|
+
maximumFractionDigits: 2
|
|
98
|
+
}) : null)));
|
|
99
|
+
}
|
|
100
|
+
return DataPointComponent;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export { DataPoint };
|
|
104
|
+
//# sourceMappingURL=DataPoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataPoint.js","sources":["../../../src/components/DataPoint/DataPoint.tsx"],"sourcesContent":["import React, { forwardRef, KeyboardEventHandler, RefObject } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp, Number, Text, useId, useTheme } from '@redsift/design-system';\nimport { Tooltip } from '@redsift/popovers';\n\nimport { DataPointProps } from './types';\nimport { StyledDataPoint } from './styles';\nimport { TooltipVariant } from '../../types';\n\nexport const DataPoint: Comp<DataPointProps<any>, SVGGElement> = forwardRef((props, ref) => {\n const {\n anchorProps: { as, href, ...anchorProps } = {},\n children,\n className,\n data,\n id: propsId,\n index,\n isSelected: propsIsSelected,\n labelDecorator,\n onClick,\n role,\n tooltipDecorator,\n tooltipVariant,\n theme: propsTheme,\n tooltipProps,\n dataset,\n groupedData,\n ...forwardedProps\n } = props;\n\n const [_id] = useId();\n const id = propsId ?? _id;\n\n const theme = useTheme(propsTheme);\n\n const isTooltipCustom = tooltipVariant === TooltipVariant.custom && tooltipDecorator;\n const text = labelDecorator\n ? labelDecorator(data, { index, isSelected: propsIsSelected, color: props.color })\n : data.data.key;\n const hasText = text && tooltipVariant !== TooltipVariant.none;\n const tooltipValue =\n tooltipVariant === TooltipVariant.value\n ? data.data.value\n : tooltipVariant === TooltipVariant.percent && data.data.percent\n ? data.data.percent\n : undefined;\n const hasValue = tooltipValue && [TooltipVariant.value, TooltipVariant.percent].includes(tooltipVariant!);\n const showTooltip = tooltipVariant !== TooltipVariant.none && (hasText || hasValue);\n\n const isEmpty = data.data.value === 0;\n\n const isSelectable = role === 'option';\n const isSelected = isSelectable && propsIsSelected === true;\n const isDeselected = isSelectable && propsIsSelected === false;\n\n const onKeyDown: KeyboardEventHandler<SVGElement> = (event) => {\n if (onClick) {\n event.stopPropagation();\n\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n onClick(data, dataset);\n }\n }\n };\n\n const DataPointComponent = (\n <StyledDataPoint\n tabIndex={onClick ? 0 : undefined}\n aria-label={\n showTooltip && !isEmpty ? (labelDecorator ? text : `${data.data.key}, ${data.data.value}`) : undefined\n }\n aria-labelledby={!showTooltip && !isEmpty ? `${id}-title` : undefined}\n aria-selected={isSelected ? true : isDeselected ? false : undefined}\n onClick={onClick ? () => onClick(data, dataset) : undefined}\n onKeyDown={onClick ? (e) => onKeyDown(e) : undefined}\n role={role ? role : onClick ? 'button' : href ? undefined : 'img'}\n {...forwardedProps}\n className={classNames(className, `_${index}`, {\n selected: isSelected,\n deselected: isDeselected,\n })}\n ref={ref as RefObject<SVGGElement>}\n id={id}\n $clickable={Boolean(onClick)}\n >\n {children}\n {!showTooltip && !isEmpty ? <title id={`${id}-title`}>{`${text}: ${data.data.value}`}</title> : null}\n </StyledDataPoint>\n );\n\n if (showTooltip) {\n return (\n <Tooltip placement=\"right\" theme={theme} delay={50} {...tooltipProps}>\n <Tooltip.Trigger>\n {href !== undefined\n ? React.createElement(as || 'a', { href, ...anchorProps }, DataPointComponent)\n : DataPointComponent}\n </Tooltip.Trigger>\n <Tooltip.Content>\n {isTooltipCustom ? (\n tooltipDecorator(data, { index, isSelected: propsIsSelected, color: props.color }, dataset, groupedData)\n ) : (\n <Text variant=\"caption\">\n {text}\n {hasText && hasValue ? ' - ' : null}\n {hasValue ? (\n <Number\n value={tooltipValue!}\n type={tooltipVariant === TooltipVariant.percent ? 'percent' : 'decimal'}\n variant=\"caption\"\n maximumFractionDigits={2}\n />\n ) : null}\n </Text>\n )}\n </Tooltip.Content>\n </Tooltip>\n );\n }\n\n return DataPointComponent;\n});\n"],"names":["DataPoint","forwardRef","props","ref","anchorProps","as","href","children","className","data","id","propsId","index","isSelected","propsIsSelected","labelDecorator","onClick","role","tooltipDecorator","tooltipVariant","theme","propsTheme","tooltipProps","dataset","groupedData","_objectWithoutProperties","_excluded","forwardedProps","_excluded2","_id","useId","useTheme","isTooltipCustom","TooltipVariant","custom","text","color","key","hasText","none","tooltipValue","value","percent","undefined","hasValue","includes","showTooltip","isEmpty","isSelectable","isDeselected","onKeyDown","event","stopPropagation","code","preventDefault","DataPointComponent","React","createElement","StyledDataPoint","_extends","tabIndex","e","classNames","selected","deselected","$clickable","Boolean","Tooltip","placement","delay","Trigger","_objectSpread","Content","Text","variant","Number","type","maximumFractionDigits"],"mappings":";;;;;;;;;;AAUO,MAAMA,SAAiD,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC1F,MAAM;AACJC,MAAAA,WAAW,EAAE;QAAEC,EAAE;AAAEC,QAAAA,IAAAA;OAAsB,GAAG,EAAE;MAC9CC,QAAQ;MACRC,SAAS;MACTC,IAAI;AACJC,MAAAA,EAAE,EAAEC,OAAO;MACXC,KAAK;AACLC,MAAAA,UAAU,EAAEC,eAAe;MAC3BC,cAAc;MACdC,OAAO;MACPC,IAAI;MACJC,gBAAgB;MAChBC,cAAc;AACdC,MAAAA,KAAK,EAAEC,UAAU;MACjBC,YAAY;MACZC,OAAO;AACPC,MAAAA,WAAAA;AAEF,KAAC,GAAGtB,KAAK;AAjBqBE,IAAAA,WAAW,GAAAqB,wBAAA,CAiBrCvB,KAAK,CAjBPE,WAAW,EAAAsB,SAAA,CAAA;AAgBRC,IAAAA,cAAc,GAAAF,wBAAA,CACfvB,KAAK,EAAA0B,UAAA,CAAA,CAAA;AAET,EAAA,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK,EAAE,CAAA;EACrB,MAAMpB,EAAE,GAAGC,OAAO,KAAA,IAAA,IAAPA,OAAO,KAAPA,KAAAA,CAAAA,GAAAA,OAAO,GAAIkB,GAAG,CAAA;AAEzB,EAAA,MAAMT,KAAK,GAAGW,QAAQ,CAACV,UAAU,CAAC,CAAA;EAElC,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,OAAO,EAAC,SAAA;AAAS,KAAA,EACpBvC,IAAI,EACJG,OAAO,IAAIM,QAAQ,GAAG,KAAK,GAAG,IAAI,EAClCA,QAAQ,gBACPY,cAAA,CAAAC,aAAA,CAACkB,MAAM,EAAA;AACLlC,MAAAA,KAAK,EAAED,YAAc;MACrBoC,IAAI,EAAEzD,cAAc,KAAKc,cAAc,CAACS,OAAO,GAAG,SAAS,GAAG,SAAU;AACxEgC,MAAAA,OAAO,EAAC,SAAS;AACjBG,MAAAA,qBAAqB,EAAE,CAAA;AAAE,KAC1B,CAAC,GACA,IACA,CAEO,CACV,CAAC,CAAA;AAEd,GAAA;AAEA,EAAA,OAAOtB,kBAAkB,CAAA;AAC3B,CAAC;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as styled_components from 'styled-components';
|
|
2
|
+
import { DataPointProps } from './types.js';
|
|
3
|
+
import * as _react_spring_web from '@react-spring/web';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Component style.
|
|
7
|
+
*/
|
|
8
|
+
declare const StyledDataPoint: styled_components.StyledComponent<_react_spring_web.AnimatedComponent<"g">, any, Omit<DataPointProps<any>, "data" | "dataset"> & {
|
|
9
|
+
$clickable: boolean;
|
|
10
|
+
}, never>;
|
|
11
|
+
|
|
12
|
+
export { StyledDataPoint };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { a as it } from '../../node_modules/@react-spring/web/dist/esm/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Component style.
|
|
6
|
+
*/
|
|
7
|
+
const StyledDataPoint = styled(it.g)``;
|
|
8
|
+
|
|
9
|
+
export { StyledDataPoint };
|
|
10
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../src/components/DataPoint/styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { animated } from '@react-spring/web';\nimport { StyledDataPointProps } from './types';\n\n/**\n * Component style.\n */\nexport const StyledDataPoint = styled(animated.g)<StyledDataPointProps>``;\n"],"names":["StyledDataPoint","styled","animated","g"],"mappings":";;;AAIA;AACA;AACA;AACO,MAAMA,eAAe,GAAGC,MAAM,CAACC,EAAQ,CAACC,CAAC,CAAwB,CAAC;;;;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement } from 'react';
|
|
2
|
+
import { Theme } from '@redsift/design-system';
|
|
3
|
+
import { TooltipProps } from '@redsift/popovers';
|
|
4
|
+
import { TooltipVariant } from '../../types/legend.js';
|
|
5
|
+
|
|
6
|
+
type AnchorProps = ComponentProps<'a'> & {
|
|
7
|
+
as?: any;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Component props.
|
|
11
|
+
*/
|
|
12
|
+
interface DataPointProps<T> extends Omit<ComponentProps<'g'>, 'onClick' | 'scale'> {
|
|
13
|
+
/** Anchor props to use when the component is a navigation link. */
|
|
14
|
+
anchorProps?: AnchorProps;
|
|
15
|
+
/** Color of the DataPoint. */
|
|
16
|
+
color?: string;
|
|
17
|
+
/** Data. Also state to which the component should end the animation, if any. */
|
|
18
|
+
data: T;
|
|
19
|
+
/** Entire dataset in which the data point is a part of. */
|
|
20
|
+
dataset: any[];
|
|
21
|
+
/** Disable animations. */
|
|
22
|
+
disableAnimations?: boolean;
|
|
23
|
+
/** Group of data in which the data point is a part of. */
|
|
24
|
+
groupedData?: any[];
|
|
25
|
+
/** Id. Used for accessibility. */
|
|
26
|
+
id?: string;
|
|
27
|
+
/** Position in the list of siblings. Used for placement and selection. */
|
|
28
|
+
index?: number;
|
|
29
|
+
/** Whether the component is selected or not. Used only if the component is selectable. Set to `undefined` to make nor selected nor unselected. */
|
|
30
|
+
isSelected?: boolean;
|
|
31
|
+
/** Method modifying the label before displaying it. */
|
|
32
|
+
labelDecorator?: (data: T, props?: {
|
|
33
|
+
index?: number;
|
|
34
|
+
isSelected?: boolean;
|
|
35
|
+
color?: string;
|
|
36
|
+
}) => string | ReactElement;
|
|
37
|
+
/** Method called when a click or keydown occurs on the component. */
|
|
38
|
+
onClick?: (data: T, dataset: any[]) => void;
|
|
39
|
+
/** State from which the component should start the animation, if any. */
|
|
40
|
+
previousData?: T;
|
|
41
|
+
/** Role. Will be set to 'button' if onClick is provided. If 'option', then the component becomes selectable. */
|
|
42
|
+
role?: 'img' | 'button' | 'link' | 'option';
|
|
43
|
+
/** Theme. */
|
|
44
|
+
theme?: Theme;
|
|
45
|
+
/** Tooltip variant. */
|
|
46
|
+
tooltipVariant?: TooltipVariant;
|
|
47
|
+
/** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
|
|
48
|
+
tooltipDecorator?: (data: T, props?: {
|
|
49
|
+
index?: number;
|
|
50
|
+
isSelected?: boolean;
|
|
51
|
+
color?: string;
|
|
52
|
+
}, dataset?: any[], groupedData?: any[]) => string | ReactElement;
|
|
53
|
+
/** Default placement of the tooltip. */
|
|
54
|
+
tooltipProps?: Partial<Omit<TooltipProps, 'ref'>>;
|
|
55
|
+
}
|
|
56
|
+
type StyledDataPointProps = Omit<DataPointProps<any>, 'data' | 'dataset'> & {
|
|
57
|
+
$clickable: boolean;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { AnchorProps, DataPointProps, StyledDataPointProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React__default, { forwardRef } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { useTheme, Theme } from '@redsift/design-system';
|
|
5
|
+
import { DotVariant } from './types.js';
|
|
6
|
+
import { StyledDot } from './styles.js';
|
|
7
|
+
import { monochrome } from '../../scheme.js';
|
|
8
|
+
|
|
9
|
+
const _excluded = ["className", "labelDecorator", "scaleX", "scaleY", "variant", "children"];
|
|
10
|
+
const COMPONENT_NAME = 'Dot';
|
|
11
|
+
const CLASSNAME = 'redsift-dot';
|
|
12
|
+
const Dot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
13
|
+
const {
|
|
14
|
+
color = monochrome,
|
|
15
|
+
data,
|
|
16
|
+
isSelected: propsIsSelected,
|
|
17
|
+
onClick,
|
|
18
|
+
role
|
|
19
|
+
} = props;
|
|
20
|
+
const {
|
|
21
|
+
className,
|
|
22
|
+
labelDecorator = datum => {
|
|
23
|
+
return datum.data.key[2] !== undefined && datum.data.key[2] !== null ? datum.data.key[2] : `${datum.data.key[0]},${datum.data.key[1]}`;
|
|
24
|
+
},
|
|
25
|
+
scaleX,
|
|
26
|
+
scaleY,
|
|
27
|
+
variant = DotVariant.plain,
|
|
28
|
+
children
|
|
29
|
+
} = props,
|
|
30
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
31
|
+
const theme = useTheme();
|
|
32
|
+
const isSelectable = role === 'option';
|
|
33
|
+
const isDeselected = isSelectable && propsIsSelected === false;
|
|
34
|
+
return /*#__PURE__*/React__default.createElement(StyledDot, _extends({
|
|
35
|
+
labelDecorator: labelDecorator
|
|
36
|
+
}, forwardedProps, {
|
|
37
|
+
ref: ref,
|
|
38
|
+
className: classNames(Dot.className, className),
|
|
39
|
+
$clickable: Boolean(onClick),
|
|
40
|
+
$variant: variant,
|
|
41
|
+
$theme: theme
|
|
42
|
+
}), /*#__PURE__*/React__default.createElement("circle", {
|
|
43
|
+
cx: scaleX(data.x),
|
|
44
|
+
cy: scaleY(data.y),
|
|
45
|
+
r: data.r,
|
|
46
|
+
fill: variant === DotVariant.hollow ? `var(--redsift-color-neutral-${theme === Theme.light ? 'white' : 'x-dark-grey'})` : isDeselected ? 'var(--redsift-color-neutral-light-grey)' : color,
|
|
47
|
+
stroke: isDeselected ? 'var(--redsift-color-neutral-light-grey)' : color,
|
|
48
|
+
strokeWidth: variant === DotVariant.hollow ? '2' : '0'
|
|
49
|
+
}), children);
|
|
50
|
+
});
|
|
51
|
+
Dot.className = CLASSNAME;
|
|
52
|
+
Dot.displayName = COMPONENT_NAME;
|
|
53
|
+
|
|
54
|
+
export { Dot };
|
|
55
|
+
//# sourceMappingURL=Dot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dot.js","sources":["../../../src/components/Dot/Dot.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp, Theme, useTheme } from '@redsift/design-system';\n\nimport { DotProps, DotVariant } from './types';\nimport { StyledDot } from './styles';\nimport { monochrome } from '../../scheme';\nimport { DotDatum } from '../../types';\n\nconst COMPONENT_NAME = 'Dot';\nconst CLASSNAME = 'redsift-dot';\n\nexport const Dot: Comp<DotProps, SVGGElement> = forwardRef((props, ref) => {\n const { color = monochrome, data, isSelected: propsIsSelected, onClick, role } = props;\n\n const {\n className,\n labelDecorator = (datum: DotDatum) => {\n return datum.data.key[2] !== undefined && datum.data.key[2] !== null\n ? datum.data.key[2]\n : `${datum.data.key[0]},${datum.data.key[1]}`;\n },\n scaleX,\n scaleY,\n variant = DotVariant.plain,\n children,\n ...forwardedProps\n } = props;\n\n const theme = useTheme();\n\n const isSelectable = role === 'option';\n const isDeselected = isSelectable && propsIsSelected === false;\n\n return (\n <StyledDot\n labelDecorator={labelDecorator}\n {...forwardedProps}\n ref={ref}\n className={classNames(Dot.className, className)}\n $clickable={Boolean(onClick)}\n $variant={variant}\n $theme={theme}\n >\n <circle\n cx={scaleX(data.x as any)}\n cy={scaleY(data.y as any)}\n r={data.r}\n fill={\n variant === DotVariant.hollow\n ? `var(--redsift-color-neutral-${theme === Theme.light ? 'white' : 'x-dark-grey'})`\n : isDeselected\n ? 'var(--redsift-color-neutral-light-grey)'\n : color\n }\n stroke={isDeselected ? 'var(--redsift-color-neutral-light-grey)' : color}\n strokeWidth={variant === DotVariant.hollow ? '2' : '0'}\n />\n {children}\n </StyledDot>\n );\n});\nDot.className = CLASSNAME;\nDot.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Dot","forwardRef","props","ref","color","monochrome","data","isSelected","propsIsSelected","onClick","role","className","labelDecorator","datum","key","undefined","scaleX","scaleY","variant","DotVariant","plain","children","forwardedProps","_objectWithoutProperties","_excluded","theme","useTheme","isSelectable","isDeselected","React","createElement","StyledDot","_extends","classNames","$clickable","Boolean","$variant","$theme","cx","x","cy","y","r","fill","hollow","Theme","light","stroke","strokeWidth","displayName"],"mappings":";;;;;;;;;AAUA,MAAMA,cAAc,GAAG,KAAK,CAAA;AAC5B,MAAMC,SAAS,GAAG,aAAa,CAAA;AAExB,MAAMC,GAAgC,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACzE,MAAM;AAAEC,IAAAA,KAAK,GAAGC,UAAU;IAAEC,IAAI;AAAEC,IAAAA,UAAU,EAAEC,eAAe;IAAEC,OAAO;AAAEC,IAAAA,IAAAA;AAAK,GAAC,GAAGR,KAAK,CAAA;EAEtF,MAAM;MACJS,SAAS;MACTC,cAAc,GAAIC,KAAe,IAAK;QACpC,OAAOA,KAAK,CAACP,IAAI,CAACQ,GAAG,CAAC,CAAC,CAAC,KAAKC,SAAS,IAAIF,KAAK,CAACP,IAAI,CAACQ,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,GAChED,KAAK,CAACP,IAAI,CAACQ,GAAG,CAAC,CAAC,CAAC,GAChB,CAAED,EAAAA,KAAK,CAACP,IAAI,CAACQ,GAAG,CAAC,CAAC,CAAE,CAAGD,CAAAA,EAAAA,KAAK,CAACP,IAAI,CAACQ,GAAG,CAAC,CAAC,CAAE,CAAC,CAAA,CAAA;OAChD;MACDE,MAAM;MACNC,MAAM;MACNC,OAAO,GAAGC,UAAU,CAACC,KAAK;AAC1BC,MAAAA,QAAAA;AAEF,KAAC,GAAGnB,KAAK;AADJoB,IAAAA,cAAc,GAAAC,wBAAA,CACfrB,KAAK,EAAAsB,SAAA,CAAA,CAAA;AAET,EAAA,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BC,GAAG,CAACiD,WAAW,GAAGnD,cAAc;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as styled_components from 'styled-components';
|
|
2
|
+
import { DotProps, DotVariant } from './types.js';
|
|
3
|
+
import * as _redsift_design_system from '@redsift/design-system';
|
|
4
|
+
import { DataPointProps } from '../DataPoint/types.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Component style.
|
|
8
|
+
*/
|
|
9
|
+
declare const StyledDot: styled_components.StyledComponent<_redsift_design_system.Comp<DataPointProps<any>, SVGGElement>, any, Omit<DataPointProps<any>, "data" | "dataset"> & {
|
|
10
|
+
$clickable: boolean;
|
|
11
|
+
} & Omit<DotProps, "scaleX" | "scaleY"> & {
|
|
12
|
+
$variant: DotVariant | undefined;
|
|
13
|
+
$theme: _redsift_design_system.Theme;
|
|
14
|
+
}, never>;
|
|
15
|
+
|
|
16
|
+
export { StyledDot };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { DotVariant } from './types.js';
|
|
3
|
+
import { DataPoint } from '../DataPoint/DataPoint.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Component style.
|
|
7
|
+
*/
|
|
8
|
+
const StyledDot = styled(DataPoint)`
|
|
9
|
+
text {
|
|
10
|
+
user-select: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
${_ref => {
|
|
14
|
+
let {
|
|
15
|
+
$variant
|
|
16
|
+
} = _ref;
|
|
17
|
+
return css`
|
|
18
|
+
circle {
|
|
19
|
+
fill-opacity: ${$variant === DotVariant.hollow ? 1 : 0.7};
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
}}
|
|
23
|
+
|
|
24
|
+
${_ref2 => {
|
|
25
|
+
let {
|
|
26
|
+
$clickable
|
|
27
|
+
} = _ref2;
|
|
28
|
+
return $clickable ? css`
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
|
|
31
|
+
&:hover,
|
|
32
|
+
&:focus {
|
|
33
|
+
opacity: 0.5;
|
|
34
|
+
outline: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&:focus-visible {
|
|
38
|
+
circle {
|
|
39
|
+
stroke: var(--redsift-color-primary-n);
|
|
40
|
+
stroke-width: 4px;
|
|
41
|
+
paint-order: stroke;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
` : '';
|
|
45
|
+
}}}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
export { StyledDot };
|
|
49
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../src/components/Dot/styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { DotVariant, StyledDotProps } from './types';\nimport { DataPoint } from '../DataPoint';\n\n/**\n * Component style.\n */\nexport const StyledDot = styled(DataPoint)<StyledDotProps>`\n text {\n user-select: none;\n }\n\n ${({ $variant }) => css`\n circle {\n fill-opacity: ${$variant === DotVariant.hollow ? 1 : 0.7};\n }\n `}\n\n ${({ $clickable }) =>\n $clickable\n ? css`\n cursor: pointer;\n\n &:hover,\n &:focus {\n opacity: 0.5;\n outline: none;\n }\n\n &:focus-visible {\n circle {\n stroke: var(--redsift-color-primary-n);\n stroke-width: 4px;\n paint-order: stroke;\n }\n }\n `\n : ''}}\n`;\n"],"names":["StyledDot","styled","DataPoint","_ref","$variant","css","DotVariant","hollow","_ref2","$clickable"],"mappings":";;;;AAIA;AACA;AACA;MACaA,SAAS,GAAGC,MAAM,CAACC,SAAS,CAAkB,CAAA;AAC3D;AACA;AACA;AACA;AACA,EAAA,EAAIC,IAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,QAAAA;AAAS,GAAC,GAAAD,IAAA,CAAA;AAAA,EAAA,OAAKE,GAAI,CAAA;AAC1B;AACA,oBAAsBD,EAAAA,QAAQ,KAAKE,UAAU,CAACC,MAAM,GAAG,CAAC,GAAG,GAAI,CAAA;AAC/D;AACA,EAAG,CAAA,CAAA;AAAA,CAAC,CAAA;AACJ;AACA,EAAA,EAAIC,KAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,UAAAA;AAAW,GAAC,GAAAD,KAAA,CAAA;EAAA,OACfC,UAAU,GACNJ,GAAI,CAAA;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAA,CAAS,GACD,EAAE,CAAA;AAAA,CAAC,CAAA;AACX;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ScaleLinear, ScaleTime, ScalePoint } from 'd3';
|
|
2
|
+
import { ValueOf, Theme } from '@redsift/design-system';
|
|
3
|
+
import { DotDatum } from '../../types/data.js';
|
|
4
|
+
import { DataPointProps, StyledDataPointProps } from '../DataPoint/types.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Component's variant.
|
|
8
|
+
*/
|
|
9
|
+
declare const DotVariant: {
|
|
10
|
+
readonly plain: "plain";
|
|
11
|
+
readonly hollow: "hollow";
|
|
12
|
+
};
|
|
13
|
+
type DotVariant = ValueOf<typeof DotVariant>;
|
|
14
|
+
/**
|
|
15
|
+
* Component props.
|
|
16
|
+
*/
|
|
17
|
+
interface DotProps extends DataPointProps<DotDatum> {
|
|
18
|
+
/** A scale defined over a numeric/time/ordinal domain used to determine the x position based on the coordinates. */
|
|
19
|
+
scaleX: ScaleLinear<number, number, never> | ScaleTime<number, number, never> | ScalePoint<string>;
|
|
20
|
+
/** A linear continuous scale defined over a numeric domain used to determine the y position based on the coordinates. */
|
|
21
|
+
scaleY: ScaleLinear<number, number, never>;
|
|
22
|
+
/** Variant. */
|
|
23
|
+
variant?: DotVariant;
|
|
24
|
+
}
|
|
25
|
+
type StyledDotProps = StyledDataPointProps & Omit<DotProps, 'scaleX' | 'scaleY'> & {
|
|
26
|
+
$variant: DotProps['variant'];
|
|
27
|
+
$theme: Theme;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { DotProps, DotVariant, StyledDotProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/components/Dot/types.ts"],"sourcesContent":["import { ScaleLinear as d3ScaleLinear, ScaleTime as d3ScaleTime, ScalePoint as d3ScalePoint } from 'd3';\nimport { DotDatum } from '../../types';\nimport { DataPointProps, StyledDataPointProps } from '../DataPoint';\nimport { Theme, ValueOf } from '@redsift/design-system';\n\n/**\n * Component's variant.\n */\nexport const DotVariant = {\n plain: 'plain',\n hollow: 'hollow',\n} as const;\nexport type DotVariant = ValueOf<typeof DotVariant>;\n\n/**\n * Component props.\n */\nexport interface DotProps extends DataPointProps<DotDatum> {\n /** A scale defined over a numeric/time/ordinal domain used to determine the x position based on the coordinates. */\n scaleX: d3ScaleLinear<number, number, never> | d3ScaleTime<number, number, never> | d3ScalePoint<string>;\n /** A linear continuous scale defined over a numeric domain used to determine the y position based on the coordinates. */\n scaleY: d3ScaleLinear<number, number, never>;\n /** Variant. */\n variant?: DotVariant;\n}\n\nexport type StyledDotProps = StyledDataPointProps &\n Omit<DotProps, 'scaleX' | 'scaleY'> & {\n $variant: DotProps['variant'];\n $theme: Theme;\n };\n"],"names":["DotVariant","plain","hollow"],"mappings":"AAKA;AACA;AACA;AACO,MAAMA,UAAU,GAAG;AACxBC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,MAAM,EAAE,QAAA;AACV,EAAU;;AAGV;AACA;AACA;;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React__default, { forwardRef } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { sum } from 'd3';
|
|
5
|
+
import { StyledLegend } from './styles.js';
|
|
6
|
+
import { LegendItem } from '../LegendItem/LegendItem.js';
|
|
7
|
+
import { LegendVariant } from '../../types/legend.js';
|
|
8
|
+
|
|
9
|
+
const _excluded = ["children", "className", "data", "isLegendItemSelected", "labelDecorator", "legendDecorator", "legendItemRole", "onLegendItemClick", "variant", "width"],
|
|
10
|
+
_excluded2 = ["color"];
|
|
11
|
+
const COMPONENT_NAME = 'Legend';
|
|
12
|
+
const CLASSNAME = 'redsift-chart-legend';
|
|
13
|
+
const Legend = /*#__PURE__*/forwardRef((props, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
data,
|
|
18
|
+
isLegendItemSelected = () => true,
|
|
19
|
+
labelDecorator,
|
|
20
|
+
legendDecorator,
|
|
21
|
+
legendItemRole,
|
|
22
|
+
onLegendItemClick,
|
|
23
|
+
variant = LegendVariant.label,
|
|
24
|
+
width
|
|
25
|
+
} = props,
|
|
26
|
+
forwardedProps = _objectWithoutProperties(props, _excluded);
|
|
27
|
+
if (!data || data.length === 0) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const total = sum(data, d => d.value);
|
|
31
|
+
if (children) {
|
|
32
|
+
const renderedChildren = typeof children === 'function' ? children(data, total) : children;
|
|
33
|
+
return /*#__PURE__*/React__default.createElement(StyledLegend, _extends({}, forwardedProps, {
|
|
34
|
+
className: classNames(Legend.className, className),
|
|
35
|
+
ref: ref
|
|
36
|
+
}), renderedChildren);
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/React__default.createElement(StyledLegend, _extends({}, forwardedProps, {
|
|
39
|
+
className: classNames(Legend.className, className),
|
|
40
|
+
ref: ref,
|
|
41
|
+
$width: width
|
|
42
|
+
}), data.map((_ref, index) => {
|
|
43
|
+
var _datum$percent;
|
|
44
|
+
let {
|
|
45
|
+
color
|
|
46
|
+
} = _ref,
|
|
47
|
+
datum = _objectWithoutProperties(_ref, _excluded2);
|
|
48
|
+
return /*#__PURE__*/React__default.createElement(LegendItem, {
|
|
49
|
+
data: {
|
|
50
|
+
data: _objectSpread2(_objectSpread2({}, datum), {}, {
|
|
51
|
+
percent: (_datum$percent = datum.percent) !== null && _datum$percent !== void 0 ? _datum$percent : datum.value / total
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
dataset: data,
|
|
55
|
+
color: color,
|
|
56
|
+
variant: variant,
|
|
57
|
+
index: index,
|
|
58
|
+
isSelected: Boolean(isLegendItemSelected({
|
|
59
|
+
data: datum
|
|
60
|
+
})),
|
|
61
|
+
key: `legend-item _${index}`,
|
|
62
|
+
labelDecorator: labelDecorator,
|
|
63
|
+
legendDecorator: legendDecorator,
|
|
64
|
+
onClick: onLegendItemClick,
|
|
65
|
+
role: legendItemRole
|
|
66
|
+
});
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
Legend.className = CLASSNAME;
|
|
70
|
+
Legend.displayName = COMPONENT_NAME;
|
|
71
|
+
|
|
72
|
+
export { Legend };
|
|
73
|
+
//# sourceMappingURL=Legend.js.map
|