@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.
Files changed (223) hide show
  1. package/_virtual/_rollupPluginBabelHelpers.js +93 -0
  2. package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  3. package/components/Arc/Arc.d.ts +6 -0
  4. package/components/Arc/Arc.js +74 -0
  5. package/components/Arc/Arc.js.map +1 -0
  6. package/components/Arc/styles.d.ts +17 -0
  7. package/components/Arc/styles.js +49 -0
  8. package/components/Arc/styles.js.map +1 -0
  9. package/components/Arc/types.d.ts +20 -0
  10. package/components/Arcs/Arcs.d.ts +6 -0
  11. package/components/Arcs/Arcs.js +90 -0
  12. package/components/Arcs/Arcs.js.map +1 -0
  13. package/components/Arcs/styles.d.ts +9 -0
  14. package/components/Arcs/styles.js +9 -0
  15. package/components/Arcs/styles.js.map +1 -0
  16. package/components/Arcs/types.d.ts +17 -0
  17. package/components/Axis/Axis.d.ts +7 -0
  18. package/components/Axis/Axis.js +211 -0
  19. package/components/Axis/Axis.js.map +1 -0
  20. package/components/Axis/computeTicks.js +117 -0
  21. package/components/Axis/computeTicks.js.map +1 -0
  22. package/components/Axis/styles.d.ts +14 -0
  23. package/components/Axis/styles.js +51 -0
  24. package/components/Axis/styles.js.map +1 -0
  25. package/components/Axis/types.d.ts +89 -0
  26. package/components/Axis/types.js +24 -0
  27. package/components/Axis/types.js.map +1 -0
  28. package/components/Bar/Bar.d.ts +6 -0
  29. package/components/Bar/Bar.js +95 -0
  30. package/components/Bar/Bar.js.map +1 -0
  31. package/components/Bar/styles.d.ts +16 -0
  32. package/components/Bar/styles.js +66 -0
  33. package/components/Bar/styles.js.map +1 -0
  34. package/components/Bar/types.d.ts +46 -0
  35. package/components/Bar/types.js +18 -0
  36. package/components/Bar/types.js.map +1 -0
  37. package/components/BarChart/BarChart.d.ts +29 -0
  38. package/components/BarChart/BarChart.js +141 -0
  39. package/components/BarChart/BarChart.js.map +1 -0
  40. package/components/BarChart/BarChartBars.js +168 -0
  41. package/components/BarChart/BarChartBars.js.map +1 -0
  42. package/components/BarChart/BarChartSection.js +139 -0
  43. package/components/BarChart/BarChartSection.js.map +1 -0
  44. package/components/BarChart/EmptyBarChart.js +57 -0
  45. package/components/BarChart/EmptyBarChart.js.map +1 -0
  46. package/components/BarChart/LoadingBarChart.js +18 -0
  47. package/components/BarChart/LoadingBarChart.js.map +1 -0
  48. package/components/BarChart/RenderedLinearBarChart.js +549 -0
  49. package/components/BarChart/RenderedLinearBarChart.js.map +1 -0
  50. package/components/BarChart/RenderedOrdinalBarChart.js +236 -0
  51. package/components/BarChart/RenderedOrdinalBarChart.js.map +1 -0
  52. package/components/BarChart/context.js +13 -0
  53. package/components/BarChart/context.js.map +1 -0
  54. package/components/BarChart/intl/en-US.json.js +17 -0
  55. package/components/BarChart/intl/en-US.json.js.map +1 -0
  56. package/components/BarChart/intl/fr-FR.json.js +17 -0
  57. package/components/BarChart/intl/fr-FR.json.js.map +1 -0
  58. package/components/BarChart/intl/index.js +10 -0
  59. package/components/BarChart/intl/index.js.map +1 -0
  60. package/components/BarChart/styles.d.ts +19 -0
  61. package/components/BarChart/styles.js +71 -0
  62. package/components/BarChart/styles.js.map +1 -0
  63. package/components/BarChart/types.d.ts +177 -0
  64. package/components/BarChart/types.js +17 -0
  65. package/components/BarChart/types.js.map +1 -0
  66. package/components/BarChart/utils.js +69 -0
  67. package/components/BarChart/utils.js.map +1 -0
  68. package/components/ChartContainer/ChartContainer.d.ts +9 -0
  69. package/components/ChartContainer/ChartContainer.js +167 -0
  70. package/components/ChartContainer/ChartContainer.js.map +1 -0
  71. package/components/ChartContainer/context.js +6 -0
  72. package/components/ChartContainer/context.js.map +1 -0
  73. package/components/ChartContainer/intl/en-US.json.js +14 -0
  74. package/components/ChartContainer/intl/en-US.json.js.map +1 -0
  75. package/components/ChartContainer/intl/fr-FR.json.js +14 -0
  76. package/components/ChartContainer/intl/fr-FR.json.js.map +1 -0
  77. package/components/ChartContainer/intl/index.js +10 -0
  78. package/components/ChartContainer/intl/index.js.map +1 -0
  79. package/components/ChartContainer/styles.d.ts +17 -0
  80. package/components/ChartContainer/styles.js +76 -0
  81. package/components/ChartContainer/styles.js.map +1 -0
  82. package/components/ChartContainer/types.d.ts +48 -0
  83. package/components/DataPoint/DataPoint.d.ts +6 -0
  84. package/components/DataPoint/DataPoint.js +104 -0
  85. package/components/DataPoint/DataPoint.js.map +1 -0
  86. package/components/DataPoint/styles.d.ts +12 -0
  87. package/components/DataPoint/styles.js +10 -0
  88. package/components/DataPoint/styles.js.map +1 -0
  89. package/components/DataPoint/types.d.ts +60 -0
  90. package/components/Dot/Dot.d.ts +6 -0
  91. package/components/Dot/Dot.js +55 -0
  92. package/components/Dot/Dot.js.map +1 -0
  93. package/components/Dot/styles.d.ts +16 -0
  94. package/components/Dot/styles.js +49 -0
  95. package/components/Dot/styles.js.map +1 -0
  96. package/components/Dot/types.d.ts +30 -0
  97. package/components/Dot/types.js +14 -0
  98. package/components/Dot/types.js.map +1 -0
  99. package/components/Legend/Legend.d.ts +6 -0
  100. package/components/Legend/Legend.js +73 -0
  101. package/components/Legend/Legend.js.map +1 -0
  102. package/components/Legend/styles.d.ts +11 -0
  103. package/components/Legend/styles.js +15 -0
  104. package/components/Legend/styles.js.map +1 -0
  105. package/components/Legend/types.d.ts +44 -0
  106. package/components/LegendItem/LegendItem.js +96 -0
  107. package/components/LegendItem/LegendItem.js.map +1 -0
  108. package/components/LegendItem/styles.js +63 -0
  109. package/components/LegendItem/styles.js.map +1 -0
  110. package/components/LegendItem/types.d.ts +20 -0
  111. package/components/Line/Line.d.ts +6 -0
  112. package/components/Line/Line.js +55 -0
  113. package/components/Line/Line.js.map +1 -0
  114. package/components/Line/styles.d.ts +9 -0
  115. package/components/Line/styles.js +9 -0
  116. package/components/Line/styles.js.map +1 -0
  117. package/components/Line/types.d.ts +21 -0
  118. package/components/LineChart/EmptyLineChart.js +58 -0
  119. package/components/LineChart/EmptyLineChart.js.map +1 -0
  120. package/components/LineChart/LineChart.d.ts +6 -0
  121. package/components/LineChart/LineChart.js +96 -0
  122. package/components/LineChart/LineChart.js.map +1 -0
  123. package/components/LineChart/LoadingLineChart.js +18 -0
  124. package/components/LineChart/LoadingLineChart.js.map +1 -0
  125. package/components/LineChart/RenderedLineChart.js +372 -0
  126. package/components/LineChart/RenderedLineChart.js.map +1 -0
  127. package/components/LineChart/intl/en-US.json.js +17 -0
  128. package/components/LineChart/intl/en-US.json.js.map +1 -0
  129. package/components/LineChart/intl/fr-FR.json.js +17 -0
  130. package/components/LineChart/intl/fr-FR.json.js.map +1 -0
  131. package/components/LineChart/intl/index.js +10 -0
  132. package/components/LineChart/intl/index.js.map +1 -0
  133. package/components/LineChart/styles.d.ts +17 -0
  134. package/components/LineChart/styles.js +53 -0
  135. package/components/LineChart/styles.js.map +1 -0
  136. package/components/LineChart/types.d.ts +90 -0
  137. package/components/LineChart/types.js +17 -0
  138. package/components/LineChart/types.js.map +1 -0
  139. package/components/LineChart/utils.js +67 -0
  140. package/components/LineChart/utils.js.map +1 -0
  141. package/components/PieChart/EmptyPieChart.js +85 -0
  142. package/components/PieChart/EmptyPieChart.js.map +1 -0
  143. package/components/PieChart/LoadingPieChart.js +18 -0
  144. package/components/PieChart/LoadingPieChart.js.map +1 -0
  145. package/components/PieChart/PieChart.d.ts +6 -0
  146. package/components/PieChart/PieChart.js +98 -0
  147. package/components/PieChart/PieChart.js.map +1 -0
  148. package/components/PieChart/RenderedPieChart.js +198 -0
  149. package/components/PieChart/RenderedPieChart.js.map +1 -0
  150. package/components/PieChart/intl/en-US.json.js +9 -0
  151. package/components/PieChart/intl/en-US.json.js.map +1 -0
  152. package/components/PieChart/intl/fr-FR.json.js +9 -0
  153. package/components/PieChart/intl/fr-FR.json.js.map +1 -0
  154. package/components/PieChart/intl/index.js +10 -0
  155. package/components/PieChart/intl/index.js.map +1 -0
  156. package/components/PieChart/styles.d.ts +24 -0
  157. package/components/PieChart/styles.js +168 -0
  158. package/components/PieChart/styles.js.map +1 -0
  159. package/components/PieChart/types.d.ts +115 -0
  160. package/components/PieChart/types.js +27 -0
  161. package/components/PieChart/types.js.map +1 -0
  162. package/components/PieChart/utils.js +37 -0
  163. package/components/PieChart/utils.js.map +1 -0
  164. package/components/ScatterPlot/EmptyScatterPlot.js +58 -0
  165. package/components/ScatterPlot/EmptyScatterPlot.js.map +1 -0
  166. package/components/ScatterPlot/LoadingScatterPlot.js +18 -0
  167. package/components/ScatterPlot/LoadingScatterPlot.js.map +1 -0
  168. package/components/ScatterPlot/RenderedScatterPlot.js +352 -0
  169. package/components/ScatterPlot/RenderedScatterPlot.js.map +1 -0
  170. package/components/ScatterPlot/ScatterPlot.d.ts +6 -0
  171. package/components/ScatterPlot/ScatterPlot.js +105 -0
  172. package/components/ScatterPlot/ScatterPlot.js.map +1 -0
  173. package/components/ScatterPlot/intl/en-US.json.js +12 -0
  174. package/components/ScatterPlot/intl/en-US.json.js.map +1 -0
  175. package/components/ScatterPlot/intl/fr-FR.json.js +17 -0
  176. package/components/ScatterPlot/intl/fr-FR.json.js.map +1 -0
  177. package/components/ScatterPlot/intl/index.js +10 -0
  178. package/components/ScatterPlot/intl/index.js.map +1 -0
  179. package/components/ScatterPlot/styles.d.ts +17 -0
  180. package/components/ScatterPlot/styles.js +53 -0
  181. package/components/ScatterPlot/styles.js.map +1 -0
  182. package/components/ScatterPlot/types.d.ts +109 -0
  183. package/components/ScatterPlot/types.js +24 -0
  184. package/components/ScatterPlot/types.js.map +1 -0
  185. package/components/ScatterPlot/utils.js +70 -0
  186. package/components/ScatterPlot/utils.js.map +1 -0
  187. package/config.js +15 -0
  188. package/config.js.map +1 -0
  189. package/design-system/src/react-aria/react-aria/i18n/useMessageFormatter.d.ts +5 -0
  190. package/hooks/useBrush.d.ts +17 -0
  191. package/hooks/useBrush.js +48 -0
  192. package/hooks/useBrush.js.map +1 -0
  193. package/hooks/useColor.d.ts +18 -0
  194. package/hooks/useColor.js +20 -0
  195. package/hooks/useColor.js.map +1 -0
  196. package/hooks/useFormatCategoricalData.d.ts +26 -0
  197. package/hooks/useFormatCategoricalData.js +57 -0
  198. package/hooks/useFormatCategoricalData.js.map +1 -0
  199. package/hooks/useZoom.d.ts +26 -0
  200. package/hooks/useZoom.js +39 -0
  201. package/hooks/useZoom.js.map +1 -0
  202. package/index.d.ts +51 -1277
  203. package/index.js +42 -5118
  204. package/index.js.map +1 -1
  205. package/package.json +4 -4
  206. package/scheme.d.ts +32 -0
  207. package/scheme.js +47 -0
  208. package/scheme.js.map +1 -0
  209. package/types/axis.d.ts +48 -0
  210. package/types/data.d.ts +72 -0
  211. package/types/legend.d.ts +30 -0
  212. package/types/legend.js +21 -0
  213. package/types/legend.js.map +1 -0
  214. package/types/scale.d.ts +48 -0
  215. package/types/size.d.ts +20 -0
  216. package/types/size.js +8 -0
  217. package/types/size.js.map +1 -0
  218. package/types/theme.d.ts +23 -0
  219. package/types/theme.js +13 -0
  220. package/types/theme.js.map +1 -0
  221. package/utils/index.d.ts +11 -0
  222. package/utils/index.js +44 -0
  223. package/utils/index.js.map +1 -0
@@ -0,0 +1,177 @@
1
+ import { ComponentProps, ReactNode, ReactElement } from 'react';
2
+ import { ScaleOrdinal, ScaleLinear, ScaleTime, ScalePoint } from 'd3';
3
+ import { SortingMethod } from '../../utils/index.js';
4
+ import { ValueOf, Theme } from '@redsift/design-system';
5
+ import { FormatMessage } from '../../design-system/src/react-aria/react-aria/i18n/useMessageFormatter.js';
6
+ import { ChartDimensions, MarginProps, ChartSize } from '../../types/size.js';
7
+ import { ChartContainerProps } from '../ChartContainer/types.js';
8
+ import { ChartAxesProps } from '../../types/axis.js';
9
+ import { BarProps, BarDirection, BarOrientation } from '../Bar/types.js';
10
+ import { CategoryData, LinearData, TwoCategoryData, BarDatum, Statistics, LinearDim } from '../../types/data.js';
11
+ import { AnchorProps } from '../DataPoint/types.js';
12
+ import { LegendProps } from '../Legend/types.js';
13
+ import { ChartTheme } from '../../types/theme.js';
14
+ import { TooltipVariant } from '../../types/legend.js';
15
+
16
+ /**
17
+ * Component's labels variant.
18
+ */
19
+ declare const BarChartLegendVariant: {
20
+ readonly none: "none";
21
+ readonly externalLabel: "externalLabel";
22
+ readonly externalLabelValue: "externalLabelValue";
23
+ readonly externalLabelPercent: "externalLabelPercent";
24
+ readonly custom: "custom";
25
+ };
26
+ type BarChartLegendVariant = ValueOf<typeof BarChartLegendVariant>;
27
+ interface LocaleText {
28
+ emptyChartText: string;
29
+ }
30
+ type BarChartDimensions = ChartDimensions & {
31
+ fontSize: number;
32
+ minWidth?: number;
33
+ maxWidth?: number;
34
+ };
35
+ type XScaleType = 'number' | 'Date' | 'dateString' | undefined;
36
+ /**
37
+ * Component props.
38
+ */
39
+ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
40
+ /** @deprecated: Use xAxisTickRotation instead. Whether the x axis labels are rotated or not. */
41
+ areXLabelsRotated?: boolean;
42
+ /** Native HTML props to forward to each bar. */
43
+ barProps?: Omit<ComponentProps<'g'>, 'onClick' | 'orientation' | 'ref' | 'scale' | 'direction'> & {
44
+ minWidth?: number;
45
+ };
46
+ /** Bar role. If an onClick is provided, the bars will have the role `button`. For a navigation link, please use `getBarAnchorProps` instead. */
47
+ barRole?: BarProps['role'];
48
+ /** Number of categories to use, the rest being put into a new category called "Others". */
49
+ caping?: number;
50
+ /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
51
+ colorTheme?: ChartTheme;
52
+ /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
53
+ data?: CategoryData | LinearData | TwoCategoryData;
54
+ /** Data type override to skip data type inferrence. */
55
+ dataType?: 'TwoCategoryData' | 'LinearData' | 'CategoryData';
56
+ /**
57
+ * Direction of the bars. Only applied when the orientation is vertical. By default bars go "up" but can go "down".
58
+ * They can also go both ways in which case you need to indicates which category go which direction. The concatenation of the two arrays will be used to determine the order of the categories instead of the sortingMethod prop.
59
+ */
60
+ direction?: BarDirection;
61
+ /** Component to use if the chart is empty (replacing the default one). */
62
+ emptyComponent?: ReactNode;
63
+ /** Method used to define the anchor props to use when the bar is a navigation link. */
64
+ getBarAnchorProps?: (datum: BarDatum) => AnchorProps;
65
+ /** Method to determine whether a bar is selected or not. */
66
+ isBarSelected?: (datum: BarDatum) => void;
67
+ /** Method to override the data labels. */
68
+ labelDecorator?: (datum: BarDatum, props?: {
69
+ index?: number;
70
+ isSelected?: boolean;
71
+ color?: string;
72
+ }) => string | ReactElement;
73
+ /** Method modifying what's displayed within the legend when the legendVariant is "custom". */
74
+ legendDecorator?: (datum: BarDatum, props?: {
75
+ index?: number;
76
+ isSelected?: boolean;
77
+ color?: string;
78
+ }) => string | ReactElement;
79
+ /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to "custom", use `legendDecorator` to customize it. */
80
+ legendVariant?: BarChartLegendVariant;
81
+ /** Props to forward to the Legend block. Can be used to make the legend selectable. */
82
+ legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'> & {
83
+ extraLegendItems?: Statistics;
84
+ };
85
+ /** Labels and texts. */
86
+ localeText?: LocaleText;
87
+ /** Custom margins, used to give more space for axes labels and legend for instance. */
88
+ margins?: MarginProps;
89
+ /** Method to be called on a click on a bar. For a navigation link, please use `getBarAnchorProps` instead. */
90
+ onBarClick?: (datum: BarDatum, data: BarDatum[]) => void;
91
+ /** Orientation of the bar. */
92
+ orientation?: BarOrientation;
93
+ /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */
94
+ others?: boolean | string;
95
+ /** BarChart size. */
96
+ size?: ChartSize | BarChartDimensions;
97
+ /** Define how to sort categories. */
98
+ sortingMethod?: SortingMethod;
99
+ /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
100
+ tooltipDecorator?: (data: BarDatum, props?: {
101
+ index?: number;
102
+ isSelected?: boolean;
103
+ color?: string;
104
+ }, dataset?: ComputedBarProps[], groupedData?: ComputedBarProps[]) => string | ReactElement;
105
+ /** Tooltip variant. */
106
+ tooltipVariant?: TooltipVariant | 'grouped';
107
+ /** Theme. */
108
+ theme?: Theme;
109
+ /** X-scale type override to skip x-scale type inferrence. */
110
+ xScaleType?: XScaleType;
111
+ /**
112
+ * In case of a datetime x-axis, if the xAxisTickValues prop is passed with a d3.js method having an offset function (for instance `timeDay`), the following prop will be used as argument.
113
+ * For reference, the line of code using it is: xAxisTickValues.offset(new Date(domain[0]), xAxisStartDateOffset)
114
+ */
115
+ xAxisStartDateOffset?: number;
116
+ /**
117
+ * In case of a datetime x-axis, if the xAxisTickValues prop is passed with a d3.js method having an offset function (for instance `timeDay`), the following prop will be used as argument.
118
+ * For reference, the line of code using it is: xAxisTickValues.offset(new Date(domain[1]), xAxisEndDateOffset)
119
+ */
120
+ xAxisEndDateOffset?: number;
121
+ /** If set, the Y axis will use a logarithmic scale using this base. Set this value to 10 to use a default logarithmic scale. */
122
+ yScaleLogBase?: number;
123
+ }
124
+ type StyledBarChartProps = BarChartProps & {};
125
+ interface RenderedLinearBarChartProps extends Omit<BarChartProps, 'data' | 'caping' | 'orientation' | 'others'> {
126
+ data: LinearData | TwoCategoryData;
127
+ }
128
+ interface ComputedBarProps {
129
+ category: string;
130
+ key: LinearDim;
131
+ value: number;
132
+ cumulativeValue: number;
133
+ }
134
+ interface BarChartState extends ChartAxesProps, Required<Pick<RenderedLinearBarChartProps, 'margins'>>, Pick<RenderedLinearBarChartProps, 'barProps' | 'barRole' | 'colorTheme' | 'direction' | 'disableAnimations' | 'getBarAnchorProps' | 'id' | 'isBarSelected' | 'labelDecorator' | 'onBarClick' | 'tooltipVariant' | 'tooltipDecorator'> {
135
+ bars: ComputedBarProps[];
136
+ barWidth: number;
137
+ cache: React.MutableRefObject<LinearData | TwoCategoryData | undefined>;
138
+ categories: string[];
139
+ chartHeight: number;
140
+ chartWidth: number;
141
+ colorScale?: ScaleOrdinal<string, string>;
142
+ format: FormatMessage;
143
+ gap: number;
144
+ hasCategory: boolean;
145
+ scaleX: ScaleLinear<number, number, never> | ScaleTime<number, number, never> | ScalePoint<string>;
146
+ scaleY: ScaleLinear<number, number>;
147
+ sectionHeight?: number;
148
+ xScaleType?: XScaleType;
149
+ }
150
+ interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role' | 'color'> {
151
+ /** Starting point in percentage of the chart height. */
152
+ from?: number;
153
+ /** Ending point in percentage of the chart height. */
154
+ to?: number;
155
+ /** Color. */
156
+ color?: 'red' | 'green' | {
157
+ textColor: string;
158
+ backgroundColor?: string;
159
+ };
160
+ /** Section title */
161
+ title?: string;
162
+ /** Title position relative to section */
163
+ titlePosition?: 'left' | 'center' | 'right';
164
+ scaleX?: ScaleLinear<number, number, never> | ScaleTime<number, number, never> | ScalePoint<string>;
165
+ scaleY?: ScaleLinear<number, number, never>;
166
+ direction?: BarDirection;
167
+ }
168
+ interface StyledBarChartSectionProps {
169
+ $theme: Theme;
170
+ $textColor: string;
171
+ }
172
+ interface BarChartBarsProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'> {
173
+ category?: string;
174
+ }
175
+ type StyledBarChartBarsProps = Omit<BarChartBarsProps, 'category'> & {};
176
+
177
+ export { BarChartBarsProps, BarChartDimensions, BarChartLegendVariant, BarChartProps, BarChartSectionProps, BarChartState, ComputedBarProps, RenderedLinearBarChartProps, StyledBarChartBarsProps, StyledBarChartProps, StyledBarChartSectionProps, XScaleType };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Component's labels variant.
3
+ */
4
+ const BarChartLegendVariant = {
5
+ none: 'none',
6
+ externalLabel: 'externalLabel',
7
+ externalLabelValue: 'externalLabelValue',
8
+ externalLabelPercent: 'externalLabelPercent',
9
+ custom: 'custom'
10
+ };
11
+
12
+ /**
13
+ * Component props.
14
+ */
15
+
16
+ export { BarChartLegendVariant };
17
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/components/BarChart/types.ts"],"sourcesContent":["import { ComponentProps, ReactElement, ReactNode } from 'react';\nimport {\n ChartDimensions,\n ChartSize,\n ChartTheme,\n BarDatum,\n TooltipVariant,\n CategoryData,\n ChartAxesProps,\n MarginProps,\n LinearData,\n TwoCategoryData,\n Statistics,\n LinearDim,\n} from '../../types';\nimport {\n ScaleTime as d3ScaleTime,\n ScaleLinear as d3ScaleLinear,\n ScaleOrdinal as d3ScaleOrdinal,\n ScalePoint as d3ScalePoint,\n} from 'd3';\nimport { ChartContainerProps } from '../ChartContainer';\nimport { BarDirection, BarOrientation, BarProps } from '../Bar';\nimport { SortingMethod } from '../../utils';\nimport { Theme, ValueOf } from '@redsift/design-system';\nimport { LegendProps } from '../Legend';\nimport { AnchorProps } from '../DataPoint';\nimport { FormatMessage } from '@redsift/design-system/react-aria/react-aria/i18n/useMessageFormatter';\n\n/**\n * Component's labels variant.\n */\nexport const BarChartLegendVariant = {\n none: 'none',\n externalLabel: 'externalLabel',\n externalLabelValue: 'externalLabelValue',\n externalLabelPercent: 'externalLabelPercent',\n custom: 'custom',\n} as const;\nexport type BarChartLegendVariant = ValueOf<typeof BarChartLegendVariant>;\n\ninterface LocaleText {\n emptyChartText: string;\n}\n\nexport type BarChartDimensions = ChartDimensions & {\n fontSize: number;\n minWidth?: number;\n maxWidth?: number;\n};\n\nexport type XScaleType = 'number' | 'Date' | 'dateString' | undefined;\n\n/**\n * Component props.\n */\nexport interface BarChartProps extends ChartContainerProps, ChartAxesProps {\n /** @deprecated: Use xAxisTickRotation instead. Whether the x axis labels are rotated or not. */\n areXLabelsRotated?: boolean;\n /** Native HTML props to forward to each bar. */\n barProps?: Omit<ComponentProps<'g'>, 'onClick' | 'orientation' | 'ref' | 'scale' | 'direction'> & {\n minWidth?: number;\n };\n /** Bar role. If an onClick is provided, the bars will have the role `button`. For a navigation link, please use `getBarAnchorProps` instead. */\n barRole?: BarProps['role'];\n /** Number of categories to use, the rest being put into a new category called \"Others\". */\n caping?: number;\n /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */\n colorTheme?: ChartTheme;\n /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */\n data?: CategoryData | LinearData | TwoCategoryData;\n /** Data type override to skip data type inferrence. */\n dataType?: 'TwoCategoryData' | 'LinearData' | 'CategoryData';\n /**\n * Direction of the bars. Only applied when the orientation is vertical. By default bars go \"up\" but can go \"down\".\n * They can also go both ways in which case you need to indicates which category go which direction. The concatenation of the two arrays will be used to determine the order of the categories instead of the sortingMethod prop.\n */\n direction?: BarDirection;\n /** Component to use if the chart is empty (replacing the default one). */\n emptyComponent?: ReactNode;\n /** Method used to define the anchor props to use when the bar is a navigation link. */\n getBarAnchorProps?: (datum: BarDatum) => AnchorProps;\n /** Method to determine whether a bar is selected or not. */\n isBarSelected?: (datum: BarDatum) => void;\n /** Method to override the data labels. */\n labelDecorator?: (\n datum: BarDatum,\n props?: { index?: number; isSelected?: boolean; color?: string }\n ) => string | ReactElement;\n /** Method modifying what's displayed within the legend when the legendVariant is \"custom\". */\n legendDecorator?: (\n datum: BarDatum,\n props?: { index?: number; isSelected?: boolean; color?: string }\n ) => string | ReactElement;\n /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to \"custom\", use `legendDecorator` to customize it. */\n legendVariant?: BarChartLegendVariant;\n /** Props to forward to the Legend block. Can be used to make the legend selectable. */\n legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'> & { extraLegendItems?: Statistics };\n /** Labels and texts. */\n localeText?: LocaleText;\n /** Custom margins, used to give more space for axes labels and legend for instance. */\n margins?: MarginProps;\n /** Method to be called on a click on a bar. For a navigation link, please use `getBarAnchorProps` instead. */\n onBarClick?: (datum: BarDatum, data: BarDatum[]) => void;\n /** Orientation of the bar. */\n orientation?: BarOrientation;\n /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */\n others?: boolean | string;\n /** BarChart size. */\n size?: ChartSize | BarChartDimensions;\n /** Define how to sort categories. */\n sortingMethod?: SortingMethod;\n /** Method modifying what's displayed within the tooltip when the tooltipVariant is \"custom\". */\n tooltipDecorator?: (\n data: BarDatum,\n props?: { index?: number; isSelected?: boolean; color?: string },\n dataset?: ComputedBarProps[],\n groupedData?: ComputedBarProps[]\n ) => string | ReactElement;\n /** Tooltip variant. */\n tooltipVariant?: TooltipVariant | 'grouped';\n /** Theme. */\n theme?: Theme;\n /** X-scale type override to skip x-scale type inferrence. */\n xScaleType?: XScaleType;\n /**\n * In case of a datetime x-axis, if the xAxisTickValues prop is passed with a d3.js method having an offset function (for instance `timeDay`), the following prop will be used as argument.\n * For reference, the line of code using it is: xAxisTickValues.offset(new Date(domain[0]), xAxisStartDateOffset)\n */\n xAxisStartDateOffset?: number;\n /**\n * In case of a datetime x-axis, if the xAxisTickValues prop is passed with a d3.js method having an offset function (for instance `timeDay`), the following prop will be used as argument.\n * For reference, the line of code using it is: xAxisTickValues.offset(new Date(domain[1]), xAxisEndDateOffset)\n */\n xAxisEndDateOffset?: number;\n /** If set, the Y axis will use a logarithmic scale using this base. Set this value to 10 to use a default logarithmic scale. */\n yScaleLogBase?: number;\n}\n\nexport type StyledBarChartProps = BarChartProps & {};\n\nexport interface RenderedLinearBarChartProps extends Omit<BarChartProps, 'data' | 'caping' | 'orientation' | 'others'> {\n data: LinearData | TwoCategoryData;\n}\nexport interface ComputedBarProps {\n category: string;\n key: LinearDim;\n value: number;\n cumulativeValue: number;\n}\n\nexport interface BarChartState\n extends ChartAxesProps,\n Required<Pick<RenderedLinearBarChartProps, 'margins'>>,\n Pick<\n RenderedLinearBarChartProps,\n | 'barProps'\n | 'barRole'\n | 'colorTheme'\n | 'direction'\n | 'disableAnimations'\n | 'getBarAnchorProps'\n | 'id'\n | 'isBarSelected'\n | 'labelDecorator'\n | 'onBarClick'\n | 'tooltipVariant'\n | 'tooltipDecorator'\n > {\n bars: ComputedBarProps[];\n barWidth: number;\n cache: React.MutableRefObject<LinearData | TwoCategoryData | undefined>;\n categories: string[];\n chartHeight: number;\n chartWidth: number;\n colorScale?: d3ScaleOrdinal<string, string>;\n format: FormatMessage;\n gap: number;\n hasCategory: boolean;\n scaleX: d3ScaleLinear<number, number, never> | d3ScaleTime<number, number, never> | d3ScalePoint<string>;\n scaleY: d3ScaleLinear<number, number>;\n sectionHeight?: number;\n xScaleType?: XScaleType;\n}\n\nexport interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role' | 'color'> {\n /** Starting point in percentage of the chart height. */\n from?: number;\n /** Ending point in percentage of the chart height. */\n to?: number;\n /** Color. */\n color?:\n | 'red'\n | 'green'\n | {\n textColor: string;\n backgroundColor?: string;\n };\n /** Section title */\n title?: string;\n /** Title position relative to section */\n titlePosition?: 'left' | 'center' | 'right';\n scaleX?: d3ScaleLinear<number, number, never> | d3ScaleTime<number, number, never> | d3ScalePoint<string>;\n scaleY?: d3ScaleLinear<number, number, never>;\n direction?: BarDirection;\n}\n\nexport interface StyledBarChartSectionProps {\n $theme: Theme;\n $textColor: string;\n}\n\nexport interface BarChartBarsProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'> {\n category?: string;\n}\n\nexport type StyledBarChartBarsProps = Omit<BarChartBarsProps, 'category'> & {};\n"],"names":["BarChartLegendVariant","none","externalLabel","externalLabelValue","externalLabelPercent","custom"],"mappings":"AA6BA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAG;AACnCC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,aAAa,EAAE,eAAe;AAC9BC,EAAAA,kBAAkB,EAAE,oBAAoB;AACxCC,EAAAA,oBAAoB,EAAE,sBAAsB;AAC5CC,EAAAA,MAAM,EAAE,QAAA;AACV,EAAU;;AAeV;AACA;AACA;;;;"}
@@ -0,0 +1,69 @@
1
+ import { getSortingMethod } from '../../utils/index.js';
2
+ import { ChartSize } from '../../types/size.js';
3
+
4
+ const sizeToDimension = size => {
5
+ if (typeof size !== 'string') {
6
+ return size;
7
+ }
8
+ switch (size) {
9
+ case ChartSize.small:
10
+ return {
11
+ width: 300,
12
+ height: 200,
13
+ fontSize: 30
14
+ };
15
+ case ChartSize.large:
16
+ return {
17
+ width: 500,
18
+ height: 400,
19
+ fontSize: 38
20
+ };
21
+ case ChartSize.medium:
22
+ default:
23
+ return {
24
+ width: 400,
25
+ height: 300,
26
+ fontSize: 34
27
+ };
28
+ }
29
+ };
30
+ const statsBy = (arr, sortingMethod) => {
31
+ const isKeyArray = Array.isArray(arr[0].key);
32
+ const counts = arr.reduce((prev, curr) => {
33
+ if (!curr.value) {
34
+ return prev;
35
+ }
36
+ const currentKey = isKeyArray ? curr.key[1] : 'default';
37
+ if (!prev[currentKey]) {
38
+ prev[currentKey] = {
39
+ value: curr.value,
40
+ min: curr.value,
41
+ max: curr.value,
42
+ values: [curr.value]
43
+ };
44
+ } else {
45
+ prev[currentKey] = {
46
+ value: prev[currentKey].value + curr.value,
47
+ min: Math.min(prev[currentKey].min, curr.value),
48
+ max: Math.max(prev[currentKey].max, curr.value),
49
+ values: [...prev[currentKey].values, curr.value]
50
+ };
51
+ }
52
+ return prev;
53
+ }, {});
54
+ return Object.keys(counts).map(key => ({
55
+ key: key,
56
+ value: counts[key].value,
57
+ min: counts[key].min,
58
+ max: counts[key].max,
59
+ values: counts[key].values,
60
+ first: counts[key].values[0],
61
+ last: counts[key].values[counts[key].values.length - 1],
62
+ trending: {
63
+ overall: (counts[key].values[counts[key].values.length - 1] - counts[key].values[0]) * 100 / counts[key].values[0]
64
+ }
65
+ })).sort(getSortingMethod(sortingMethod));
66
+ };
67
+
68
+ export { sizeToDimension, statsBy };
69
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../src/components/BarChart/utils.ts"],"sourcesContent":["import { SortingMethod, getSortingMethod } from '@redsift/charts/utils';\nimport { ChartSize, LinearData, LinearDatum, Statistics, TwoCategoryData, TwoCategoryDatum } from '../../types';\nimport { BarChartDimensions } from './types';\n\nexport const sizeToDimension = (size: ChartSize | BarChartDimensions): BarChartDimensions => {\n if (typeof size !== 'string') {\n return size;\n }\n\n switch (size) {\n case ChartSize.small:\n return { width: 300, height: 200, fontSize: 30 };\n case ChartSize.large:\n return { width: 500, height: 400, fontSize: 38 };\n case ChartSize.medium:\n default:\n return { width: 400, height: 300, fontSize: 34 };\n }\n};\n\nexport const statsBy: (arr: LinearData | TwoCategoryData, sortingMethod: SortingMethod) => Statistics = (\n arr,\n sortingMethod\n) => {\n const isKeyArray = Array.isArray(arr[0].key);\n\n const counts = (arr as (LinearDatum | TwoCategoryDatum)[]).reduce((prev, curr) => {\n if (!curr.value) {\n return prev;\n }\n const currentKey = isKeyArray ? ((curr as TwoCategoryDatum).key[1] as string) : 'default';\n if (!prev[currentKey as string]) {\n prev[currentKey as string] = {\n value: curr.value,\n min: curr.value,\n max: curr.value,\n values: [curr.value],\n };\n } else {\n prev[currentKey as string] = {\n value: prev[currentKey as string].value + curr.value,\n min: Math.min(prev[currentKey as string].min, curr.value),\n max: Math.max(prev[currentKey as string].max, curr.value),\n values: [...prev[currentKey as string].values, curr.value],\n };\n }\n return prev;\n }, {} as Record<string, { value: number; min: number; max: number; values: number[] }>);\n\n return Object.keys(counts)\n .map((key) => ({\n key: key,\n value: counts[key].value,\n min: counts[key].min,\n max: counts[key].max,\n values: counts[key].values,\n first: counts[key].values[0],\n last: counts[key].values[counts[key].values.length - 1],\n trending: {\n overall:\n ((counts[key].values[counts[key].values.length - 1] - counts[key].values[0]) * 100) / counts[key].values[0],\n },\n }))\n .sort(getSortingMethod(sortingMethod));\n};\n"],"names":["sizeToDimension","size","ChartSize","small","width","height","fontSize","large","medium","statsBy","arr","sortingMethod","isKeyArray","Array","isArray","key","counts","reduce","prev","curr","value","currentKey","min","max","values","Math","Object","keys","map","first","last","length","trending","overall","sort","getSortingMethod"],"mappings":";;;AAIaA,MAAAA,eAAe,GAAIC,IA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AACO,MAAM,GAAG,CAAC,CAAC;AACvDC,IAAAA,QAAQ,EAAE;AACRC,MAAAA,OAAO,EACJ,CAACjB,MAAM,CAACD,GAAG,CAAC,CAACS,MAAM,CAACR,MAAM,CAACD,GAAG,CAAC,CAACS,MAAM,CAACO,MAAM,GAAG,CAAC,CAAC,GAAGf,MAAM,CAACD,GAAG,CAAC,CAACS,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,GAAIR,MAAM,CAACD,GAAG,CAAC,CAACS,MAAM,CAAC,CAAC,CAAA;AAC9G,KAAA;GACD,CAAC,CAAC,CACFU,IAAI,CAACC,gBAAgB,CAACxB,aAAa,CAAC,CAAC,CAAA;AAC1C;;;;"}
@@ -0,0 +1,9 @@
1
+ import { ComponentProps } from 'react';
2
+ import { Comp } from '@redsift/design-system';
3
+ import { ChartContainerProps } from './types.js';
4
+
5
+ declare const ChartContainer: Comp<ChartContainerProps, HTMLDivElement>;
6
+ declare const ChartContainerTitle: Comp<Pick<ChartContainerProps, 'onReset'> & ComponentProps<'div'>, HTMLDivElement>;
7
+ declare const ChartContainerDescription: Comp<ComponentProps<'div'>, HTMLDivElement>;
8
+
9
+ export { ChartContainer, ChartContainerDescription, ChartContainerTitle };
@@ -0,0 +1,167 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useState } from 'react';
3
+ import classNames from 'classnames';
4
+ import { useId, useTheme, warnIfNoAccessibleLabelFound, useMessageFormatter, ThemeProvider, Flexbox, Heading, Button } from '@redsift/design-system';
5
+ import intlMessages from './intl/index.js';
6
+ import { StyledChartContainer, StyledChartContainerTitle, StyledChartContainerCaption } from './styles.js';
7
+
8
+ const _excluded = ["aria-label", "aria-labelledby", "description", "descriptionPosition", "chartProps", "chartRef", "children", "className", "id", "title", "onReset", "theme", "mode", "definition", "interactionExplanation", "descriptionForAssistiveTechnology", "dataTableRepresentation", "xAxisDefinition", "yAxisDefinition"],
9
+ _excluded2 = ["children", "className", "onReset", "id"],
10
+ _excluded3 = ["children", "className", "id"];
11
+ const COMPONENT_NAME = 'ChartContainer';
12
+ const CLASSNAME = 'redsift-chart-container';
13
+ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
14
+ const {
15
+ 'aria-label': propsAriaLabel,
16
+ 'aria-labelledby': propsAriaLabelledby,
17
+ description,
18
+ descriptionPosition = 'belowChart',
19
+ chartProps,
20
+ chartRef,
21
+ children,
22
+ className,
23
+ id: propsId,
24
+ title,
25
+ onReset,
26
+ theme: propsTheme,
27
+ mode = 'static',
28
+ definition,
29
+ interactionExplanation,
30
+ descriptionForAssistiveTechnology,
31
+ dataTableRepresentation,
32
+ xAxisDefinition,
33
+ yAxisDefinition
34
+ } = props,
35
+ forwardedProps = _objectWithoutProperties(props, _excluded);
36
+ const [_id] = useId();
37
+ const id = propsId !== null && propsId !== void 0 ? propsId : _id;
38
+ const theme = useTheme(propsTheme);
39
+ const [viewAsDataTable, setViewAsDataTable] = useState(false);
40
+ warnIfNoAccessibleLabelFound(props, [title]);
41
+ const format = useMessageFormatter(intlMessages);
42
+ const ariaLabel = propsAriaLabel ? propsAriaLabel : propsAriaLabelledby || title ? undefined : undefined;
43
+ const ariaLabelledby = propsAriaLabelledby ? propsAriaLabelledby : title ? `id${id}__title` : undefined;
44
+ return /*#__PURE__*/React__default.createElement(ThemeProvider, {
45
+ value: {
46
+ theme
47
+ }
48
+ }, /*#__PURE__*/React__default.createElement("figure", null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(StyledChartContainer, _extends({
49
+ $theme: theme,
50
+ role: "region",
51
+ "aria-hidden": "false"
52
+ }, ariaLabel ? {
53
+ 'aria-label': `${ariaLabel}. ${format(mode)}.`
54
+ } : {}, ariaLabelledby ? {
55
+ 'aria-labelledby': `${ariaLabelledby} id${id}__interactive-or-not`
56
+ } : {}, forwardedProps, {
57
+ ref: ref,
58
+ className: classNames(ChartContainer.className, className),
59
+ id: id
60
+ }), /*#__PURE__*/React__default.createElement("div", {
61
+ id: `id${id}__screen-reader-region-before`,
62
+ "aria-hidden": "false",
63
+ style: {
64
+ position: 'relative'
65
+ }
66
+ }, /*#__PURE__*/React__default.createElement("div", {
67
+ "aria-hidden": "false",
68
+ style: {
69
+ position: 'absolute',
70
+ width: '1px',
71
+ height: '1px',
72
+ overflow: 'hidden',
73
+ whiteSpace: 'nowrap',
74
+ clip: 'rect(1px, 1px, 1px, 1px)',
75
+ marginTop: '-3px',
76
+ opacity: '0.01'
77
+ }
78
+ }, /*#__PURE__*/React__default.createElement("p", {
79
+ id: `id${id}__interactive-or-not`,
80
+ "aria-hidden": "true",
81
+ style: {
82
+ display: 'none'
83
+ }
84
+ }, format(`${mode}-chart`)), ariaLabel ? /*#__PURE__*/React__default.createElement("p", null, `${ariaLabel}. ${format(`${mode}-chart`)}`) : /*#__PURE__*/React__default.createElement("p", {
85
+ "aria-labelledby": `${ariaLabelledby} id${id}__interactive-or-not`
86
+ }), /*#__PURE__*/React__default.createElement("div", null, descriptionForAssistiveTechnology !== null && descriptionForAssistiveTechnology !== void 0 ? descriptionForAssistiveTechnology : description), /*#__PURE__*/React__default.createElement("div", null, interactionExplanation), /*#__PURE__*/React__default.createElement("div", null, definition), dataTableRepresentation ? /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("button", {
87
+ tabIndex: -1,
88
+ "aria-expanded": viewAsDataTable,
89
+ onClick: () => setViewAsDataTable(!viewAsDataTable)
90
+ }, format('view-as-data-table'), ', ', ariaLabel ? /*#__PURE__*/React__default.createElement("span", null, ariaLabel) : /*#__PURE__*/React__default.createElement("span", {
91
+ "aria-labelledby": ariaLabelledby
92
+ }))) : null, /*#__PURE__*/React__default.createElement("div", null, xAxisDefinition), /*#__PURE__*/React__default.createElement("div", null, yAxisDefinition))), /*#__PURE__*/React__default.createElement(Flexbox, {
93
+ flexDirection: "column"
94
+ }, title || onReset ? /*#__PURE__*/React__default.createElement(ChartContainerTitle, {
95
+ onReset: onReset,
96
+ id: id
97
+ }, title) : null, descriptionPosition === 'belowTitle' ? /*#__PURE__*/React__default.createElement(ChartContainerDescription, {
98
+ id: id
99
+ }, description) : null), /*#__PURE__*/React__default.createElement(Flexbox, {
100
+ flexDirection: "column"
101
+ }, children ? /*#__PURE__*/React__default.createElement("div", _extends({
102
+ "aria-hidden": "false",
103
+ dir: "ltr"
104
+ }, chartProps, {
105
+ ref: chartRef,
106
+ className: `${ChartContainer.className}__content`
107
+ }), children) : null, descriptionPosition === 'belowChart' ? /*#__PURE__*/React__default.createElement(ChartContainerDescription, {
108
+ id: id
109
+ }, description) : null, viewAsDataTable && dataTableRepresentation ? /*#__PURE__*/React__default.createElement("table", {
110
+ tabIndex: -1,
111
+ summary: format('table-summary')
112
+ }, ariaLabel ? /*#__PURE__*/React__default.createElement("caption", null, ariaLabel) : /*#__PURE__*/React__default.createElement("caption", {
113
+ "aria-labelledby": ariaLabelledby
114
+ }), dataTableRepresentation.header, dataTableRepresentation.body) : null)))));
115
+ });
116
+ ChartContainer.className = CLASSNAME;
117
+ ChartContainer.displayName = COMPONENT_NAME;
118
+ const ChartContainerTitle = /*#__PURE__*/forwardRef((props, ref) => {
119
+ const {
120
+ children,
121
+ className,
122
+ onReset,
123
+ id
124
+ } = props,
125
+ forwardedProps = _objectWithoutProperties(props, _excluded2);
126
+ const theme = useTheme();
127
+ const format = useMessageFormatter(intlMessages);
128
+ return /*#__PURE__*/React__default.createElement(StyledChartContainerTitle, _extends({
129
+ "aria-hidden": "true",
130
+ $theme: theme,
131
+ alignItems: "center",
132
+ justifyContent: "space-between",
133
+ className: classNames(`${ChartContainer.className}__title`, className),
134
+ id: `id${id}__title`
135
+ }, forwardedProps, {
136
+ ref: ref
137
+ }), typeof children === 'string' ? /*#__PURE__*/React__default.createElement(Heading, {
138
+ as: "h3"
139
+ }, children) : children ? children : null, onReset ? /*#__PURE__*/React__default.createElement(Button, {
140
+ className: `${ChartContainer.className}-title__reset-button`,
141
+ color: "grey",
142
+ variant: "unstyled",
143
+ onClick: onReset
144
+ }, format('reset')) : null);
145
+ });
146
+ ChartContainerTitle.displayName = 'ChartContainerTitle';
147
+ const ChartContainerDescription = /*#__PURE__*/forwardRef((props, ref) => {
148
+ const {
149
+ children,
150
+ className,
151
+ id
152
+ } = props,
153
+ forwardedProps = _objectWithoutProperties(props, _excluded3);
154
+ const theme = useTheme();
155
+ return typeof children === 'string' ? /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, _extends({
156
+ "aria-hidden": "true",
157
+ $theme: theme,
158
+ className: classNames(`${ChartContainer.className}__description`, className),
159
+ id: `id${id}__description`
160
+ }, forwardedProps, {
161
+ ref: ref
162
+ }), children) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, children);
163
+ });
164
+ ChartContainerDescription.displayName = 'ChartContainerDescription';
165
+
166
+ export { ChartContainer, ChartContainerDescription, ChartContainerTitle };
167
+ //# sourceMappingURL=ChartContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartContainer.js","sources":["../../../src/components/ChartContainer/ChartContainer.tsx"],"sourcesContent":["import React, { ComponentProps, forwardRef, RefObject, useState } from 'react';\nimport classNames from 'classnames';\n\nimport { useMessageFormatter } from '@redsift/design-system';\nimport intlMessages from './intl';\n\nimport {\n Button,\n Comp,\n Flexbox,\n Heading,\n ThemeProvider,\n useId,\n useTheme,\n warnIfNoAccessibleLabelFound,\n} from '@redsift/design-system';\n\nimport { ChartContainerProps } from './types';\nimport { StyledChartContainer, StyledChartContainerCaption, StyledChartContainerTitle } from './styles';\n\nconst COMPONENT_NAME = 'ChartContainer';\nconst CLASSNAME = 'redsift-chart-container';\n\nexport const ChartContainer: Comp<ChartContainerProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n 'aria-label': propsAriaLabel,\n 'aria-labelledby': propsAriaLabelledby,\n description,\n descriptionPosition = 'belowChart',\n chartProps,\n chartRef,\n children,\n className,\n id: propsId,\n title,\n onReset,\n theme: propsTheme,\n mode = 'static',\n definition,\n interactionExplanation,\n descriptionForAssistiveTechnology,\n dataTableRepresentation,\n xAxisDefinition,\n yAxisDefinition,\n ...forwardedProps\n } = props;\n const [_id] = useId();\n const id = propsId ?? _id;\n\n const theme = useTheme(propsTheme);\n const [viewAsDataTable, setViewAsDataTable] = useState(false);\n\n warnIfNoAccessibleLabelFound(props as ComponentProps<keyof JSX.IntrinsicElements>, [title]);\n\n const format = useMessageFormatter(intlMessages);\n\n const ariaLabel = propsAriaLabel ? propsAriaLabel : propsAriaLabelledby || title ? undefined : undefined;\n const ariaLabelledby = propsAriaLabelledby ? propsAriaLabelledby : title ? `id${id}__title` : undefined;\n\n return (\n <ThemeProvider value={{ theme }}>\n <figure>\n <div>\n <StyledChartContainer\n $theme={theme}\n role=\"region\"\n aria-hidden=\"false\"\n {...(ariaLabel ? { 'aria-label': `${ariaLabel}. ${format(mode)}.` } : {})}\n {...(ariaLabelledby ? { 'aria-labelledby': `${ariaLabelledby} id${id}__interactive-or-not` } : {})}\n {...forwardedProps}\n ref={ref as RefObject<HTMLDivElement>}\n className={classNames(ChartContainer.className, className)}\n id={id}\n >\n <div id={`id${id}__screen-reader-region-before`} aria-hidden=\"false\" style={{ position: 'relative' }}>\n <div\n aria-hidden=\"false\"\n style={{\n position: 'absolute',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n clip: 'rect(1px, 1px, 1px, 1px)',\n marginTop: '-3px',\n opacity: '0.01',\n }}\n >\n <p id={`id${id}__interactive-or-not`} aria-hidden=\"true\" style={{ display: 'none' }}>\n {format(`${mode}-chart`)}\n </p>\n {ariaLabel ? (\n <p>{`${ariaLabel}. ${format(`${mode}-chart`)}`}</p>\n ) : (\n <p aria-labelledby={`${ariaLabelledby} id${id}__interactive-or-not`} />\n )}\n <div>{descriptionForAssistiveTechnology ?? description}</div>\n <div>{interactionExplanation}</div>\n <div>{definition}</div>\n {dataTableRepresentation ? (\n <div>\n <button\n tabIndex={-1}\n aria-expanded={viewAsDataTable}\n onClick={() => setViewAsDataTable(!viewAsDataTable)}\n >\n {format('view-as-data-table')}\n {', '}\n {ariaLabel ? <span>{ariaLabel}</span> : <span aria-labelledby={ariaLabelledby} />}\n </button>\n </div>\n ) : null}\n <div>{xAxisDefinition}</div>\n <div>{yAxisDefinition}</div>\n </div>\n </div>\n <Flexbox flexDirection=\"column\">\n {title || onReset ? (\n <ChartContainerTitle onReset={onReset} id={id}>\n {title}\n </ChartContainerTitle>\n ) : null}\n {descriptionPosition === 'belowTitle' ? (\n <ChartContainerDescription id={id}>{description}</ChartContainerDescription>\n ) : null}\n </Flexbox>\n\n <Flexbox flexDirection=\"column\">\n {children ? (\n <div\n aria-hidden=\"false\"\n dir=\"ltr\"\n {...chartProps}\n ref={chartRef}\n className={`${ChartContainer.className}__content`}\n >\n {children}\n </div>\n ) : null}\n {descriptionPosition === 'belowChart' ? (\n <ChartContainerDescription id={id}>{description}</ChartContainerDescription>\n ) : null}\n {viewAsDataTable && dataTableRepresentation ? (\n <table tabIndex={-1} summary={format('table-summary')}>\n {ariaLabel ? <caption>{ariaLabel}</caption> : <caption aria-labelledby={ariaLabelledby} />}\n {dataTableRepresentation.header}\n {dataTableRepresentation.body}\n </table>\n ) : null}\n </Flexbox>\n </StyledChartContainer>\n </div>\n </figure>\n </ThemeProvider>\n );\n});\nChartContainer.className = CLASSNAME;\nChartContainer.displayName = COMPONENT_NAME;\n\nexport const ChartContainerTitle: Comp<Pick<ChartContainerProps, 'onReset'> & ComponentProps<'div'>, HTMLDivElement> =\n forwardRef((props, ref) => {\n const { children, className, onReset, id, ...forwardedProps } = props;\n const theme = useTheme();\n const format = useMessageFormatter(intlMessages);\n\n return (\n <StyledChartContainerTitle\n aria-hidden=\"true\"\n $theme={theme}\n alignItems=\"center\"\n justifyContent=\"space-between\"\n className={classNames(`${ChartContainer.className}__title`, className)}\n id={`id${id}__title`}\n {...forwardedProps}\n ref={ref}\n >\n {typeof children === 'string' ? <Heading as=\"h3\">{children}</Heading> : children ? children : null}\n\n {onReset ? (\n <Button\n className={`${ChartContainer.className}-title__reset-button`}\n color=\"grey\"\n variant=\"unstyled\"\n onClick={onReset}\n >\n {format('reset')}\n </Button>\n ) : null}\n </StyledChartContainerTitle>\n );\n });\nChartContainerTitle.displayName = 'ChartContainerTitle';\n\nexport const ChartContainerDescription: Comp<ComponentProps<'div'>, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, id, ...forwardedProps } = props;\n const theme = useTheme();\n\n return typeof children === 'string' ? (\n <StyledChartContainerCaption\n aria-hidden=\"true\"\n $theme={theme}\n className={classNames(`${ChartContainer.className}__description`, className)}\n id={`id${id}__description`}\n {...forwardedProps}\n ref={ref}\n >\n {children}\n </StyledChartContainerCaption>\n ) : (\n <>{children}</>\n );\n});\nChartContainerDescription.displayName = 'ChartContainerDescription';\n"],"names":["COMPONENT_NAME","CLASSNAME","ChartContainer","forwardRef","props","ref","propsAriaLabel","propsAriaLabelledby","description","descriptionPosition","chartProps","chartRef","children","className","id","propsId","title","onReset","theme","propsTheme","mode","definition","interactionExplanation","descriptionForAssistiveTechnology","dataTableRepresentation","xAxisDefinition","yAxisDefinition","forwardedProps","_objectWithoutProperties","_excluded","_id","useId","useTheme","viewAsDataTable","setViewAsDataTable","useState","warnIfNoAccessibleLabelFound","format","useMessageFormatter","intlMessages","ariaLabel","undefined","ariaLabelledby","React","createElement","ThemeProvider","value","StyledChartContainer","_extends","$theme","role","classNames","style","position","width","height","overflow","whiteSpace","clip","marginTop","opacity","display","tabIndex","onClick","Flexbox","flexDirection","ChartContainerTitle","ChartContainerDescription","dir","summary","header","body","displayName","_excluded2","StyledChartContainerTitle","alignItems","justifyContent","Heading","as","Button","color","variant","_excluded3","StyledChartContainerCaption","Fragment"],"mappings":";;;;;;;;;;AAoBA,MAAMA,cAAc,GAAG,gBAAgB,CAAA;AACvC,MAAMC,SAAS,GAAG,yBAAyB,CAAA;AAEpC,MAAMC,cAAyD,gBAAGC,UA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AAAsB,KAAC,GAAGV,KAAK;AAAxBuB,IAAAA,cAAc,GAAAC,wBAAA,CAAKxB,KAAK,EAAA8E,UAAA,CAAA,CAAA;AAC5D,EAAA,MAAMhE,KAAK,GAAGc,QAAQ,EAAE,CAAA;EAExB,OAAO,OAAOpB,QAAQ,KAAK,QAAQ,gBACjC+B,cAAA,CAAAC,aAAA,CAACuC,2BAA2B,EAAAnC,QAAA,CAAA;AAC1B,IAAA,aAAA,EAAY,MAAM;AAClBC,IAAAA,MAAM,EAAE/B,KAAM;IACdL,SAAS,EAAEsC,UAAU,CAAE,CAAEjD,EAAAA,cAAc,CAACW,SAAU,CAAA,aAAA,CAAc,EAAEA,SAAS,CAAE;IAC7EC,EAAE,EAAG,KAAIA,EAAG,CAAA,aAAA,CAAA;AAAe,GAAA,EACvBa,cAAc,EAAA;AAClBtB,IAAAA,GAAG,EAAEA,GAAAA;AAAI,GAAA,CAAA,EAERO,QAC0B,CAAC,gBAE9B+B,cAAA,CAAAC,aAAA,CAAAD,cAAA,CAAAyC,QAAA,EAAGxE,IAAAA,EAAAA,QAAW,CACf,CAAA;AACH,CAAC,EAAC;AACFuD,yBAAyB,CAACK,WAAW,GAAG,2BAA2B;;;;"}
@@ -0,0 +1,6 @@
1
+ import React__default from 'react';
2
+
3
+ const ChartTypeContext = /*#__PURE__*/React__default.createContext(undefined);
4
+
5
+ export { ChartTypeContext };
6
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["../../../src/components/ChartContainer/context.ts"],"sourcesContent":["import React from 'react';\nimport { useBarChartContext } from '../BarChart/context';\n\nexport type ChartType = 'bar' | 'line' | 'area';\n\nexport const ChartTypeContext = React.createContext<ChartType | undefined>(undefined);\n\nexport const useChartType = (): ChartType | undefined => {\n return React.useContext(ChartTypeContext);\n};\n\nexport const useResolvedChartContext = () => {\n const chartType = useChartType();\n\n switch (chartType) {\n case 'bar':\n return useBarChartContext();\n default:\n return undefined;\n }\n};\n\nexport function useResolvedProp<T>(prop: T | undefined, contextValue: T | undefined, defaultValue?: T): T | undefined {\n if (prop !== undefined) return prop;\n if (contextValue !== undefined) return contextValue;\n return defaultValue;\n}\n"],"names":["ChartTypeContext","React","createContext","undefined"],"mappings":";;AAKO,MAAMA,gBAAgB,gBAAGC,cAAK,CAACC,aAAa,CAAwBC,SAAS;;;;"}
@@ -0,0 +1,14 @@
1
+ var interactive = "Interactive";
2
+ var reset = "Reset";
3
+ var enUS = {
4
+ interactive: interactive,
5
+ "static": "Static",
6
+ "static-chart": "Static chart.",
7
+ "interactive-chart": "Interactive chart.",
8
+ "view-as-data-table": "View as data table",
9
+ "table-summary": "Table representation of chart.",
10
+ reset: reset
11
+ };
12
+
13
+ export { enUS as default, interactive, reset };
14
+ //# sourceMappingURL=en-US.json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-US.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -0,0 +1,14 @@
1
+ var interactive = "Interactif";
2
+ var reset = "Réinitialiser";
3
+ var frFR = {
4
+ interactive: interactive,
5
+ "static": "Statique",
6
+ "static-chart": "Graphique statique.",
7
+ "interactive-chart": "Graphique intéractif.",
8
+ "view-as-data-table": "Voir au format table de données",
9
+ "table-summary": "Représentation du graphique sous forme de table de données.",
10
+ reset: reset
11
+ };
12
+
13
+ export { frFR as default, interactive, reset };
14
+ //# sourceMappingURL=fr-FR.json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fr-FR.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -0,0 +1,10 @@
1
+ import enUS from './en-US.json.js';
2
+ import frFR from './fr-FR.json.js';
3
+
4
+ var intlMessages = {
5
+ 'en-US': enUS,
6
+ 'fr-FR': frFR
7
+ };
8
+
9
+ export { intlMessages as default };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/ChartContainer/intl/index.ts"],"sourcesContent":["import enUS from './en-US.json';\nimport frFR from './fr-FR.json';\n\nexport default {\n 'en-US': enUS,\n 'fr-FR': frFR,\n};\n"],"names":["enUS","frFR"],"mappings":";;;AAGA,mBAAe;AACb,EAAA,OAAO,EAAEA,IAAI;AACb,EAAA,OAAO,EAAEC,IAAAA;AACX,CAAC;;;;"}
@@ -0,0 +1,17 @@
1
+ import * as _redsift_design_system from '@redsift/design-system';
2
+ import { Theme } from '@redsift/design-system';
3
+ import * as styled_components from 'styled-components';
4
+ import { ChartContainerProps, StyledChartContainerProps } from './types.js';
5
+
6
+ /**
7
+ * Component style.
8
+ */
9
+ declare const StyledChartContainer: styled_components.StyledComponent<"div", any, Omit<ChartContainerProps, "theme"> & {
10
+ $theme: Theme;
11
+ }, never>;
12
+ declare const StyledChartContainerTitle: styled_components.StyledComponent<_redsift_design_system.Comp<_redsift_design_system.FlexboxProps, HTMLDivElement>, any, Omit<ChartContainerProps, "theme"> & {
13
+ $theme: Theme;
14
+ }, never>;
15
+ declare const StyledChartContainerCaption: styled_components.StyledComponent<"p", any, Omit<StyledChartContainerProps, "onReset">, never>;
16
+
17
+ export { StyledChartContainer, StyledChartContainerCaption, StyledChartContainerTitle };