@redsift/charts 11.5.0 → 11.6.0-muiv5-alpha.1

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 @@
1
+ {"version":3,"file":"Legend.js","sources":["../../../src/components/Legend/Legend.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classNames from 'classnames';\nimport { sum as d3sum } from 'd3';\n\nimport { Comp } from '@redsift/design-system';\n\nimport { LegendProps } from './types';\nimport { StyledLegend } from './styles';\nimport { LegendVariant } from '../../types';\nimport { LegendItem } from '../LegendItem';\n\nconst COMPONENT_NAME = 'Legend';\nconst CLASSNAME = 'redsift-chart-legend';\n\nexport const Legend: Comp<LegendProps, HTMLUListElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n data,\n isLegendItemSelected = () => true,\n labelDecorator,\n legendDecorator,\n legendItemRole,\n onLegendItemClick,\n variant = LegendVariant.label,\n width,\n ...forwardedProps\n } = props;\n\n if (!data || data.length === 0) {\n return null;\n }\n\n const total = d3sum(data, (d) => d.value);\n\n if (children) {\n const renderedChildren = typeof children === 'function' ? children(data, total) : children;\n\n return (\n <StyledLegend {...forwardedProps} className={classNames(Legend.className, className)} ref={ref}>\n {renderedChildren}\n </StyledLegend>\n );\n }\n\n return (\n <StyledLegend {...forwardedProps} className={classNames(Legend.className, className)} ref={ref} $width={width}>\n {data.map(({ color, ...datum }, index) => (\n <LegendItem\n data={{ data: { ...datum, percent: datum.percent ?? datum.value / total } }}\n dataset={data}\n color={color}\n variant={variant}\n index={index}\n isSelected={Boolean(isLegendItemSelected!({ data: datum }))}\n key={`legend-item _${index}`}\n labelDecorator={labelDecorator}\n legendDecorator={legendDecorator}\n onClick={onLegendItemClick}\n role={legendItemRole}\n />\n ))}\n </StyledLegend>\n );\n});\nLegend.className = CLASSNAME;\nLegend.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Legend","forwardRef","props","ref","children","className","data","isLegendItemSelected","labelDecorator","legendDecorator","legendItemRole","onLegendItemClick","variant","LegendVariant","label","width","forwardedProps","_objectWithoutProperties","_excluded","length","total","d3sum","d","value","renderedChildren","React","createElement","StyledLegend","_extends","classNames","$width","map","_ref","index","_datum$percent","color","datum","_excluded2","LegendItem","_objectSpread","percent","dataset","isSelected","Boolean","key","onClick","role","displayName"],"mappings":";;;;;;;;;;AAWA,MAAMA,cAAc,GAAG,QAAQ,CAAA;AAC/B,MAAMC,SAAS,GAAG,sBAAsB,CAAA;AAEjC,MAAMC,MAA2C,gBAAGC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACpF,MAAM;MACJC,QAAQ;MACRC,SAAS;MACTC,IAAI;MACJC,oBAAoB,GAAGA,MAAM,IAAI;MACjCC,cAAc;MACdC,eAAe;MACfC,cAAc;MACdC,iBAAiB;MACjBC,OAAO,GAAGC,aAAa,CAACC,KAAK;AAC7BC,MAAAA,KAAAA;AAEF,KAAC,GAAGb,KAAK;AADJc,IAAAA,cAAc,GA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AAAA,IAAI,EAAAiC,cAAA,CAAAA,cAAA,KAAOH,KAAK,CAAA,EAAA,EAAA,EAAA;AAAEI,UAAAA,OAAO,EAAAN,CAAAA,cAAA,GAAEE,KAAK,CAACI,OAAO,MAAA,IAAA,IAAAN,cAAA,KAAA,KAAA,CAAA,GAAAA,cAAA,GAAIE,KAAK,CAACb,KAAK,GAAGH,KAAAA;AAAK,SAAA,CAAA;OAAK;AAC5EqB,MAAAA,OAAO,EAAEnC,IAAK;AACd6B,MAAAA,KAAK,EAAEA,KAAM;AACbvB,MAAAA,OAAO,EAAEA,OAAQ;AACjBqB,MAAAA,KAAK,EAAEA,KAAM;AACbS,MAAAA,UAAU,EAAEC,OAAO,CAACpC,oBAAoB,CAAE;AAAED,QAAAA,IAAI,EAAE8B,KAAAA;AAAM,OAAC,CAAC,CAAE;MAC5DQ,GAAG,EAAG,CAAeX,aAAAA,EAAAA,KAAM,CAAE,CAAA;AAC7BzB,MAAAA,cAAc,EAAEA,cAAe;AAC/BC,MAAAA,eAAe,EAAEA,eAAgB;AACjCoC,MAAAA,OAAO,EAAElC,iBAAkB;AAC3BmC,MAAAA,IAAI,EAAEpC,cAAAA;AAAe,KACtB,CAAC,CAAA;AAAA,GACH,CACW,CAAC,CAAA;AAEnB,CAAC,EAAC;AACFV,MAAM,CAACK,SAAS,GAAGN,SAAS,CAAA;AAC5BC,MAAM,CAAC+C,WAAW,GAAGjD,cAAc;;;;"}
@@ -0,0 +1,11 @@
1
+ import * as styled_components from 'styled-components';
2
+ import { LegendProps } from './types.js';
3
+
4
+ /**
5
+ * Component style.
6
+ */
7
+ declare const StyledLegend: styled_components.StyledComponent<"ul", any, Omit<LegendProps, "data"> & {
8
+ $width?: string | number | undefined;
9
+ }, never>;
10
+
11
+ export { StyledLegend };
@@ -0,0 +1,15 @@
1
+ import styled from 'styled-components';
2
+ import { baseContainer } from '@redsift/design-system';
3
+
4
+ /**
5
+ * Component style.
6
+ */
7
+ const StyledLegend = styled.ul`
8
+ display: flex;
9
+ flex-direction: column;
10
+
11
+ ${baseContainer}
12
+ `;
13
+
14
+ export { StyledLegend };
15
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../src/components/Legend/styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { StyledLegendProps } from './types';\nimport { baseContainer } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledLegend = styled.ul<StyledLegendProps>`\n display: flex;\n flex-direction: column;\n\n ${baseContainer}\n`;\n"],"names":["StyledLegend","styled","ul","baseContainer"],"mappings":";;;AAIA;AACA;AACA;AACaA,MAAAA,YAAY,GAAGC,MAAM,CAACC,EAAsB,CAAA;AACzD;AACA;AACA;AACA,EAAA,EAAIC,aAAc,CAAA;AAClB;;;;"}
@@ -0,0 +1,44 @@
1
+ import { ComponentProps, ReactElement } from 'react';
2
+ import { ContainerProps } from '@redsift/design-system';
3
+ import { Statistic, LegendItemDatum } from '../../types/data.js';
4
+ import { LegendItemProps } from '../LegendItem/types.js';
5
+ import { LegendVariant } from '../../types/legend.js';
6
+
7
+ /**
8
+ * Component props.
9
+ */
10
+ interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick' | 'children'>, ContainerProps {
11
+ /** Children */
12
+ children?: ReactElement | ReactElement[] | ((data: (Statistic & {
13
+ color: string;
14
+ })[], total?: number) => ReactElement);
15
+ /** Data. */
16
+ data?: (Statistic & {
17
+ color: string;
18
+ })[];
19
+ /** Method to determine whether a legend is selected or not. */
20
+ isLegendItemSelected?: (datum: LegendItemDatum) => void;
21
+ /** Method to override the data labels. */
22
+ labelDecorator?: (datum: LegendItemDatum, props?: {
23
+ index?: number;
24
+ isSelected?: boolean;
25
+ color?: string;
26
+ }) => string | ReactElement;
27
+ /** Method modifying what's displayed within the legend when the variant is "custom". */
28
+ legendDecorator?: (datum: LegendItemDatum, props?: {
29
+ index?: number;
30
+ isSelected?: boolean;
31
+ color?: string;
32
+ }) => string | ReactElement;
33
+ /** Method to be called on a click on a legend item. */
34
+ onLegendItemClick?: (datum: LegendItemDatum, data: LegendItemDatum[]) => void;
35
+ /** LegendItem role. Used to indicate that legend items are to be considered buttons or links. If an onClick is provided, the legend items will have the role `button` unless specifically set to `link` with this prop. */
36
+ legendItemRole?: LegendItemProps['role'];
37
+ /** Variant. */
38
+ variant?: LegendVariant;
39
+ }
40
+ type StyledLegendProps = Omit<LegendProps, 'data'> & {
41
+ $width?: LegendProps['width'];
42
+ };
43
+
44
+ export { LegendProps, StyledLegendProps };
@@ -0,0 +1,96 @@
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, useId, Number, Text } from '@redsift/design-system';
5
+ import { StyledLegendItem } from './styles.js';
6
+ import { monochrome } from '../../scheme.js';
7
+ import { LegendVariant } from '../../types/legend.js';
8
+
9
+ const _excluded = ["className", "color", "data", "dataset", "id", "variant"];
10
+ const COMPONENT_NAME = 'LegendItem';
11
+ const CLASSNAME = 'redsift-legend-item';
12
+ const LegendItem = /*#__PURE__*/forwardRef((props, ref) => {
13
+ const {
14
+ index = 0,
15
+ isSelected: propsIsSelected,
16
+ labelDecorator,
17
+ legendDecorator,
18
+ onClick,
19
+ role
20
+ } = props;
21
+ const {
22
+ className,
23
+ color = monochrome,
24
+ data,
25
+ dataset,
26
+ id: propsId,
27
+ variant
28
+ } = props,
29
+ forwardedProps = _objectWithoutProperties(props, _excluded);
30
+ const theme = useTheme();
31
+ const [_id] = useId();
32
+ const id = propsId !== null && propsId !== void 0 ? propsId : _id;
33
+ const isLegendCustom = variant === LegendVariant.custom && legendDecorator;
34
+ const text = labelDecorator ? labelDecorator(data, {
35
+ index,
36
+ isSelected: propsIsSelected,
37
+ color
38
+ }) : data.data.key;
39
+ const isEmpty = data.data.value === 0;
40
+ const isSelectable = role === 'option';
41
+ const isSelected = isSelectable && propsIsSelected === true;
42
+ const isDeselected = isSelectable && propsIsSelected === false;
43
+ const onKeyDown = event => {
44
+ if (onClick) {
45
+ event.stopPropagation();
46
+ if (event.code === 'Enter' || event.code === 'Space') {
47
+ event.preventDefault();
48
+ onClick(data, dataset);
49
+ }
50
+ }
51
+ };
52
+ return /*#__PURE__*/React__default.createElement(StyledLegendItem, _extends({}, forwardedProps, {
53
+ className: classNames(LegendItem.className, className, `_${index}`, {
54
+ selected: isSelected,
55
+ deselected: isDeselected
56
+ }),
57
+ color: isDeselected ? 'var(--redsift-color-neutral-light-grey)' : color,
58
+ ref: ref,
59
+ "aria-labelledby": !isEmpty ? `${id}-title` : undefined,
60
+ "aria-selected": isSelected ? true : isDeselected ? false : undefined,
61
+ id: id,
62
+ onClick: onClick ? () => onClick(data, dataset) : undefined,
63
+ onKeyDown: onClick ? e => onKeyDown(e) : undefined,
64
+ role: role ? role : onClick ? 'button' : undefined,
65
+ tabIndex: onClick ? 0 : undefined,
66
+ $clickable: Boolean(onClick),
67
+ $variant: variant,
68
+ $theme: theme
69
+ }), isLegendCustom ? legendDecorator(data, {
70
+ index,
71
+ isSelected: propsIsSelected,
72
+ color: props.color
73
+ }) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", null), typeof text === 'string' ? variant === LegendVariant.value ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number, {
74
+ as: "b",
75
+ maximumFractionDigits: 2,
76
+ value: data.data.value,
77
+ variant: "inherit"
78
+ }), /*#__PURE__*/React__default.createElement(Text, {
79
+ variant: "caption"
80
+ }, text)) : variant === LegendVariant.percent && data.data.percent ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number, {
81
+ as: "b",
82
+ maximumFractionDigits: 2,
83
+ type: "percent",
84
+ value: data.data.percent,
85
+ variant: "inherit"
86
+ }), /*#__PURE__*/React__default.createElement(Text, {
87
+ variant: "caption"
88
+ }, text)) : /*#__PURE__*/React__default.createElement(Text, {
89
+ variant: "caption"
90
+ }, text) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, text)));
91
+ });
92
+ LegendItem.className = CLASSNAME;
93
+ LegendItem.displayName = COMPONENT_NAME;
94
+
95
+ export { LegendItem };
96
+ //# sourceMappingURL=LegendItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendItem.js","sources":["../../../src/components/LegendItem/LegendItem.tsx"],"sourcesContent":["import React, { KeyboardEventHandler, forwardRef } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp, Number, Text, useId, useTheme } from '@redsift/design-system';\n\nimport { LegendItemProps } from './types';\nimport { StyledLegendItem } from './styles';\nimport { monochrome } from '../../scheme';\nimport { LegendVariant } from '../../types';\n\nconst COMPONENT_NAME = 'LegendItem';\nconst CLASSNAME = 'redsift-legend-item';\n\nexport const LegendItem: Comp<LegendItemProps, HTMLLIElement> = forwardRef((props, ref) => {\n const { index = 0, isSelected: propsIsSelected, labelDecorator, legendDecorator, onClick, role } = props;\n\n const { className, color = monochrome, data, dataset, id: propsId, variant, ...forwardedProps } = props;\n\n const theme = useTheme();\n\n const [_id] = useId();\n const id = propsId ?? _id;\n\n const isLegendCustom = variant === LegendVariant.custom && legendDecorator;\n const text = labelDecorator ? labelDecorator(data, { index, isSelected: propsIsSelected, color }) : data.data.key;\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<HTMLLIElement> = (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 return (\n <StyledLegendItem\n {...forwardedProps}\n className={classNames(LegendItem.className, className, `_${index}`, {\n selected: isSelected,\n deselected: isDeselected,\n })}\n color={isDeselected ? 'var(--redsift-color-neutral-light-grey)' : color}\n ref={ref}\n aria-labelledby={!isEmpty ? `${id}-title` : undefined}\n aria-selected={isSelected ? true : isDeselected ? false : undefined}\n id={id}\n onClick={onClick ? () => onClick(data, dataset) : undefined}\n onKeyDown={onClick ? (e) => onKeyDown(e) : undefined}\n role={role ? role : onClick ? 'button' : undefined}\n tabIndex={onClick ? 0 : undefined}\n $clickable={Boolean(onClick)}\n $variant={variant}\n $theme={theme}\n >\n {isLegendCustom ? (\n legendDecorator(data, { index, isSelected: propsIsSelected, color: props.color })\n ) : (\n <>\n <div />\n {typeof text === 'string' ? (\n variant === LegendVariant.value ? (\n <>\n <Number as=\"b\" maximumFractionDigits={2} value={data.data.value} variant=\"inherit\" />\n <Text variant=\"caption\">{text}</Text>\n </>\n ) : variant === LegendVariant.percent && data.data.percent ? (\n <>\n <Number as=\"b\" maximumFractionDigits={2} type=\"percent\" value={data.data.percent} variant=\"inherit\" />\n <Text variant=\"caption\">{text}</Text>\n </>\n ) : (\n <Text variant=\"caption\">{text}</Text>\n )\n ) : (\n <>{text}</>\n )}\n </>\n )}\n </StyledLegendItem>\n );\n});\nLegendItem.className = CLASSNAME;\nLegendItem.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","LegendItem","forwardRef","props","ref","index","isSelected","propsIsSelected","labelDecorator","legendDecorator","onClick","role","className","color","monochrome","data","dataset","id","propsId","variant","forwardedProps","_objectWithoutProperties","_excluded","theme","useTheme","_id","useId","isLegendCustom","LegendVariant","custom","text","key","isEmpty","value","isSelectable","isDeselected","onKeyDown","event","stopPropagation","code","preventDefault","React","createElement","StyledLegendItem","_extends","classNames","selected","deselected","undefined","e","tabIndex","$clickable","Boolean","$variant","$theme","Fragment","Number","as","maximumFractionDigits","Text","percent","type","displayName"],"mappings":";;;;;;;;;AAUA,MAAMA,cAAc,GAAG,YAAY,CAAA;AACnC,MAAMC,SAAS,GAAG,qBAAqB,CAAA;AAEhC,MAAMC,UAAgD,gBAAGC,UAAU,CAAC,CAACC,KAAK,E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zC,IAAAA,OAAO,EAAC,SAAA;AAAS,GAAE,CAAC,eACtGsB,cAAA,CAAAC,aAAA,CAACiB,IAAI,EAAA;AAACxC,IAAAA,OAAO,EAAC,SAAA;GAAWW,EAAAA,IAAW,CACpC,CAAC,gBAEHW,cAAA,CAAAC,aAAA,CAACiB,IAAI,EAAA;AAACxC,IAAAA,OAAO,EAAC,SAAA;AAAS,GAAA,EAAEW,IAAW,CACrC,gBAEDW,cAAA,CAAAC,aAAA,CAAAD,cAAA,CAAAc,QAAA,EAAA,IAAA,EAAGzB,IAAO,CAEZ,CAEY,CAAC,CAAA;AAEvB,CAAC,EAAC;AACF7B,UAAU,CAACW,SAAS,GAAGZ,SAAS,CAAA;AAChCC,UAAU,CAAC6D,WAAW,GAAG/D,cAAc;;;;"}
@@ -0,0 +1,63 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { Theme } from '@redsift/design-system';
3
+ import { LegendVariant } from '../../types/legend.js';
4
+
5
+ /**
6
+ * Component style.
7
+ */
8
+ const StyledLegendItem = styled.li`
9
+ display: flex;
10
+ align-items: center;
11
+ gap: 8px;
12
+ font-size: var(--redsift-typography-caption-font-size);
13
+
14
+ ${_ref => {
15
+ let {
16
+ $theme
17
+ } = _ref;
18
+ return css`
19
+ color: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});
20
+ `;
21
+ }}
22
+
23
+ ${_ref2 => {
24
+ let {
25
+ $variant,
26
+ color
27
+ } = _ref2;
28
+ return $variant !== LegendVariant.custom ? css`
29
+ > div {
30
+ height: 16px;
31
+ width: 16px;
32
+ min-width: 16px;
33
+ background-color: ${color};
34
+ }
35
+ ` : '';
36
+ }}}
37
+
38
+ ${_ref3 => {
39
+ let {
40
+ $clickable
41
+ } = _ref3;
42
+ return $clickable ? css`
43
+ cursor: pointer;
44
+
45
+ &:hover,
46
+ &:focus {
47
+ outline: none;
48
+ > div {
49
+ opacity: 0.7;
50
+ }
51
+ }
52
+
53
+ &:focus-visible {
54
+ > div {
55
+ outline: 4px solid var(--redsift-color-primary-n);
56
+ }
57
+ }
58
+ ` : '';
59
+ }}}
60
+ `;
61
+
62
+ export { StyledLegendItem };
63
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../src/components/LegendItem/styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { StyledLegendItemProps } from './types';\nimport { LegendVariant } from '@redsift/charts/types';\nimport { Theme } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledLegendItem = styled.li<StyledLegendItemProps>`\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--redsift-typography-caption-font-size);\n\n ${({ $theme }) => css`\n color: var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'});\n `}\n\n ${({ $variant, color }) =>\n $variant !== LegendVariant.custom\n ? css`\n > div {\n height: 16px;\n width: 16px;\n min-width: 16px;\n background-color: ${color};\n }\n `\n : ''}}\n\n ${({ $clickable }) =>\n $clickable\n ? css`\n cursor: pointer;\n\n &:hover,\n &:focus {\n outline: none;\n > div {\n opacity: 0.7;\n }\n }\n\n &:focus-visible {\n > div {\n outline: 4px solid var(--redsift-color-primary-n);\n }\n }\n `\n : ''}}\n`;\n"],"names":["StyledLegendItem","styled","li","_ref","$theme","css","Theme","dark","_ref2","$variant","color","LegendVariant","custom","_ref3","$clickable"],"mappings":";;;;AAKA;AACA;AACA;AACaA,MAAAA,gBAAgB,GAAGC,MAAM,CAACC,EAA0B,CAAA;AACjE;AACA;AACA;AACA;AACA;AACA,EAAA,EAAIC,IAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,MAAAA;AAAO,GAAC,GAAAD,IAAA,CAAA;AAAA,EAAA,OAAKE,GAAI,CAAA;AACxB,uCAAyCD,EAAAA,MAAM,KAAKE,KAAK,CAACC,IAAI,GAAG,OAAO,GAAG,aAAc,CAAA;AACzF,EAAG,CAAA,CAAA;AAAA,CAAC,CAAA;AACJ;AACA,EAAA,EAAIC,KAAA,IAAA;EAAA,IAAC;IAAEC,QAAQ;AAAEC,IAAAA,KAAAA;AAAM,GAAC,GAAAF,KAAA,CAAA;AAAA,EAAA,OACpBC,QAAQ,KAAKE,aAAa,CAACC,MAAM,GAC7BP,GAAI,CAAA;AACZ;AACA;AACA;AACA;AACA,8BAAA,EAAgCK,KAAM,CAAA;AACtC;AACA,QAAA,CAAS,GACD,EAAE,CAAA;AAAA,CAAC,CAAA;AACX;AACA,EAAA,EAAIG,KAAA,IAAA;EAAA,IAAC;AAAEC,IAAAA,UAAAA;AAAW,GAAC,GAAAD,KAAA,CAAA;EAAA,OACfC,UAAU,GACNT,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,20 @@
1
+ import { ComponentProps, ReactElement } from 'react';
2
+ import { LegendItemDatum } from '../../types/data.js';
3
+ import { LegendVariant } from '../../types/legend.js';
4
+ import { DataPointProps } from '../DataPoint/types.js';
5
+
6
+ /**
7
+ * Component props.
8
+ */
9
+ interface LegendItemProps extends Pick<DataPointProps<LegendItemDatum>, 'color' | 'data' | 'dataset' | 'id' | 'index' | 'isSelected' | 'labelDecorator' | 'onClick' | 'previousData' | 'role' | 'tooltipVariant'>, Omit<ComponentProps<'li'>, 'onClick' | 'role'> {
10
+ /** Method modifying what's displayed within the legend when the variant is "custom". */
11
+ legendDecorator?: (datum: LegendItemDatum, props?: {
12
+ index?: number;
13
+ isSelected?: boolean;
14
+ color?: string;
15
+ }) => string | ReactElement;
16
+ /** Variant. */
17
+ variant?: LegendVariant;
18
+ }
19
+
20
+ export { LegendItemProps };
@@ -0,0 +1,6 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { LineProps } from './types.js';
3
+
4
+ declare const Line: Comp<LineProps, SVGGElement>;
5
+
6
+ export { Line };
@@ -0,0 +1,55 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import classNames from 'classnames';
4
+ import { a as it } from '../../node_modules/@react-spring/web/dist/esm/index.js';
5
+ import { interpolate } from 'd3';
6
+ import { StyledLine } from './styles.js';
7
+ import { monochrome } from '../../scheme.js';
8
+ import { config } from '../../config.js';
9
+ import { useSpring as J } from '../../node_modules/@react-spring/core/dist/esm/index.js';
10
+
11
+ const _excluded = ["className", "createLine", "disableAnimations", "previousData"];
12
+ const COMPONENT_NAME = 'Line';
13
+ const CLASSNAME = 'redsift-line';
14
+ const Line = /*#__PURE__*/forwardRef((props, ref) => {
15
+ const {
16
+ color = monochrome,
17
+ data,
18
+ isSelected: propsIsSelected,
19
+ role
20
+ } = props;
21
+ const {
22
+ className,
23
+ createLine,
24
+ disableAnimations,
25
+ previousData = []
26
+ } = props,
27
+ forwardedProps = _objectWithoutProperties(props, _excluded);
28
+ const interpolator = interpolate(previousData, data);
29
+ const isSelectable = role === 'option';
30
+ const isDeselected = isSelectable && propsIsSelected === false;
31
+ const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
32
+ to: async next => {
33
+ await next({
34
+ t: 1
35
+ });
36
+ },
37
+ from: {
38
+ t: 0
39
+ }
40
+ }));
41
+ return /*#__PURE__*/React__default.createElement(StyledLine, _extends({}, forwardedProps, {
42
+ ref: ref,
43
+ className: classNames(Line.className, className)
44
+ }), /*#__PURE__*/React__default.createElement(it.path, {
45
+ d: config.immediate || disableAnimations ? createLine(data) : animatedProps.t.to(t => createLine(interpolator(t))),
46
+ fill: "none",
47
+ stroke: isDeselected ? 'var(--redsift-color-neutral-light-grey)' : color,
48
+ strokeWidth: 2
49
+ }));
50
+ });
51
+ Line.className = CLASSNAME;
52
+ Line.displayName = COMPONENT_NAME;
53
+
54
+ export { Line };
55
+ //# sourceMappingURL=Line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Line.js","sources":["../../../src/components/Line/Line.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classNames from 'classnames';\nimport { animated, useSpring } from '@react-spring/web';\nimport { interpolate as d3interpolate } from 'd3';\n\nimport { Comp } from '@redsift/design-system';\n\nimport { LineProps } from './types';\nimport { StyledLine } from './styles';\nimport { monochrome } from '../../scheme';\nimport { config } from '../../config';\n\nconst COMPONENT_NAME = 'Line';\nconst CLASSNAME = 'redsift-line';\n\nexport const Line: Comp<LineProps, SVGGElement> = forwardRef((props, ref) => {\n const { color = monochrome, data, isSelected: propsIsSelected, role } = props;\n\n const { className, createLine, disableAnimations, previousData = [], ...forwardedProps } = props;\n\n const interpolator = d3interpolate(previousData, data);\n\n const isSelectable = role === 'option';\n const isDeselected = isSelectable && propsIsSelected === false;\n\n const animatedProps = useSpring({\n ...config,\n to: async (next: (props?: object) => Promise<void>) => {\n await next({ t: 1 });\n },\n from: { t: 0 },\n });\n\n return (\n <StyledLine {...forwardedProps} ref={ref} className={classNames(Line.className, className)}>\n <animated.path\n d={\n config.immediate || disableAnimations\n ? (createLine(data) as unknown as string)\n : (animatedProps.t.to((t) => createLine(interpolator(t))) as unknown as string)\n }\n fill=\"none\"\n stroke={isDeselected ? 'var(--redsift-color-neutral-light-grey)' : color}\n strokeWidth={2}\n />\n </StyledLine>\n );\n});\nLine.className = CLASSNAME;\nLine.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","Line","forwardRef","props","ref","color","monochrome","data","isSelected","propsIsSelected","role","className","createLine","disableAnimations","previousData","forwardedProps","_objectWithoutProperties","_excluded","interpolator","d3interpolate","isSelectable","isDeselected","animatedProps","useSpring","_objectSpread","config","to","next","t","from","React","createElement","StyledLine","_extends","classNames","animated","path","d","immediate","fill","stroke","strokeWidth","displayName"],"mappings":";;;;;;;;;;;AAYA,MAAMA,cAAc,GAAG,MAAM,CAAA;AAC7B,M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AI,EAAA;IACZC,CAAC,EACCZ,MAAM,CAACa,SAAS,IAAIzB,iBAAiB,GAChCD,UAAU,CAACL,IAAI,CAAC,GAChBe,aAAa,CAACM,CAAC,CAACF,EAAE,CAAEE,CAAC,IAAKhB,UAAU,CAACM,YAAY,CAACU,CAAC,CAAC,CAAC,CAC3D;AACDW,IAAAA,IAAI,EAAC,MAAM;AACXC,IAAAA,MAAM,EAAEnB,YAAY,GAAG,yCAAyC,GAAGhB,KAAM;AACzEoC,IAAAA,WAAW,EAAE,CAAA;AAAE,GAChB,CACS,CAAC,CAAA;AAEjB,CAAC,EAAC;AACFxC,IAAI,CAACU,SAAS,GAAGX,SAAS,CAAA;AAC1BC,IAAI,CAACyC,WAAW,GAAG3C,cAAc;;;;"}
@@ -0,0 +1,9 @@
1
+ import * as styled_components from 'styled-components';
2
+ import { StyledLineProps } from './types.js';
3
+
4
+ /**
5
+ * Component style.
6
+ */
7
+ declare const StyledLine: styled_components.StyledComponent<"g", any, StyledLineProps, never>;
8
+
9
+ export { StyledLine };
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components';
2
+
3
+ /**
4
+ * Component style.
5
+ */
6
+ const StyledLine = styled('g')``;
7
+
8
+ export { StyledLine };
9
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sources":["../../../src/components/Line/styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { StyledLineProps } from './types';\n\n/**\n * Component style.\n */\nexport const StyledLine = styled('g')<StyledLineProps>``;\n"],"names":["StyledLine","styled"],"mappings":";;AAGA;AACA;AACA;MACaA,UAAU,GAAGC,MAAM,CAAC,GAAG,CAAmB,CAAC;;;;"}
@@ -0,0 +1,21 @@
1
+ import { Line } from 'd3';
2
+ import { ComponentProps } from 'react';
3
+ import { DotProps } from '../Dot/types.js';
4
+ import { LinePointDatum } from '../../types/data.js';
5
+
6
+ /**
7
+ * Component props.
8
+ */
9
+ interface LineProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'>, Pick<DotProps, 'id' | 'isSelected' | 'role'> {
10
+ /** Line generator used to determine the path of the line. */
11
+ createLine: Line<LinePointDatum>;
12
+ /** Points used to compute the line path. */
13
+ data: LinePointDatum[];
14
+ /** Disable animations. */
15
+ disableAnimations?: boolean;
16
+ /** Previous data used for animation. */
17
+ previousData?: LinePointDatum[];
18
+ }
19
+ type StyledLineProps = Omit<LineProps, 'createLine' | 'data'>;
20
+
21
+ export { LineProps, StyledLineProps };
@@ -0,0 +1,58 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef, useRef, useEffect } from 'react';
3
+ import { scaleLinear } from 'd3';
4
+ import { StyledLineChart, StyledLineChartEmptyText } from './styles.js';
5
+ import { sizeToDimension } from './utils.js';
6
+ import { useTheme } from '@redsift/design-system';
7
+ import { Axis } from '../Axis/Axis.js';
8
+
9
+ const _excluded = ["className", "data", "emptyComponent", "localeText", "size"];
10
+ const EmptyLineChart = /*#__PURE__*/forwardRef((props, ref) => {
11
+ const {
12
+ className,
13
+ data: propsData,
14
+ emptyComponent,
15
+ localeText,
16
+ size
17
+ } = props,
18
+ forwardedProps = _objectWithoutProperties(props, _excluded);
19
+ const theme = useTheme();
20
+ const cache = useRef();
21
+ const data = propsData;
22
+ useEffect(() => {
23
+ cache.current = data;
24
+ });
25
+ const chartDimensions = sizeToDimension(size);
26
+ const width = chartDimensions.width;
27
+ const height = chartDimensions.height;
28
+ const margins = {
29
+ top: 16,
30
+ left: 48,
31
+ right: 16,
32
+ bottom: 48
33
+ };
34
+ const chartWidth = width - margins.left - margins.right;
35
+ return /*#__PURE__*/React__default.createElement(StyledLineChart, _extends({}, forwardedProps, {
36
+ className: className,
37
+ ref: ref
38
+ }), emptyComponent !== null && emptyComponent !== void 0 ? emptyComponent : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(StyledLineChartEmptyText, {
39
+ $maxWidth: width,
40
+ $textSize: chartDimensions.fontSize / 2,
41
+ $theme: theme
42
+ }, /*#__PURE__*/React__default.createElement("span", null, localeText === null || localeText === void 0 ? void 0 : localeText.emptyChartText)), /*#__PURE__*/React__default.createElement("svg", {
43
+ width: width,
44
+ height: height
45
+ }, /*#__PURE__*/React__default.createElement("g", {
46
+ transform: `translate(${margins.left},${margins.top})`
47
+ }, /*#__PURE__*/React__default.createElement(Axis, {
48
+ position: "bottom",
49
+ length: width - 32,
50
+ scale: scaleLinear().domain([]).range([0, chartWidth]),
51
+ x: 0,
52
+ y: height,
53
+ tickValues: 4
54
+ })))));
55
+ });
56
+
57
+ export { EmptyLineChart };
58
+ //# sourceMappingURL=EmptyLineChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmptyLineChart.js","sources":["../../../src/components/LineChart/EmptyLineChart.tsx"],"sourcesContent":["import React, { forwardRef, RefObject, useEffect, useRef } from 'react';\nimport { scaleLinear as d3scaleLinear } from 'd3';\n\nimport { AnyScale, JSONArray } from '../../types';\nimport { LineChartProps } from './types';\nimport { StyledLineChart, StyledLineChartEmptyText } from './styles';\nimport { Axis } from '../Axis';\nimport { sizeToDimension } from './utils';\nimport { useTheme } from '@redsift/design-system';\n\nexport const EmptyLineChart = forwardRef<HTMLDivElement, LineChartProps>((props, ref) => {\n const { className, data: propsData, emptyComponent, localeText, size, ...forwardedProps } = props;\n const theme = useTheme();\n\n const cache = useRef<JSONArray>();\n\n const data = propsData;\n\n useEffect(() => {\n cache.current = data;\n });\n\n const chartDimensions = sizeToDimension(size!);\n const width = chartDimensions.width;\n const height = chartDimensions.height;\n const margins = { top: 16, left: 48, right: 16, bottom: 48 };\n const chartWidth = width - margins.left - margins.right;\n\n return (\n <StyledLineChart {...forwardedProps} className={className} ref={ref as RefObject<HTMLDivElement>}>\n {emptyComponent ?? (\n <>\n <StyledLineChartEmptyText $maxWidth={width} $textSize={chartDimensions.fontSize / 2} $theme={theme}>\n <span>{localeText?.emptyChartText}</span>\n </StyledLineChartEmptyText>\n <svg width={width} height={height}>\n <g transform={`translate(${margins.left},${margins.top})`}>\n <Axis\n position=\"bottom\"\n length={width - 32}\n scale={d3scaleLinear().domain([]).range([0, chartWidth]) as AnyScale}\n x={0}\n y={height}\n tickValues={4}\n />\n </g>\n </svg>\n </>\n )}\n </StyledLineChart>\n );\n});\n"],"names":["EmptyLineChart","forwardRef","props","ref","className","data","propsData","emptyComponent","localeText","size","forwardedProps","_objectWithoutProperties","_excluded","theme","useTheme","cache","useRef","useEffect","current","chartDimensions","sizeToDimension","width","height","margins","top","left","right","bottom","chartWidth","React","createElement","StyledLineChart","_extends","Fragment","StyledLineChartEmptyText","$maxWidth","$textSize","fontSize","$theme","emptyChartText","transform","Axis","position","length","scale","d3scaleLinear","domain","range","x","y","tickValues"],"mappings":";;;;;;;;;AAUO,MAAMA,cAAc,gBAAGC,UAAU,CAAiC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACvF,MAAM;MAAEC,SAAS;AAAEC,MAAAA,IAAI,EAAEC,SAAS;MAAEC,cAAc;MAAEC,UAAU;AAAEC,MAAAA,IAAAA;AAAwB,KAAC,GAAGP,KAAK;AAAxBQ,IAAAA,cAAc,GAAAC,wBAAA,CAAKT,KAAK,EAAAU,SAAA,CAAA,CAAA;AACjG,EAAA,MAAMC,KAAK,GAAGC,QAAQ,EAAE,CAAA;AAExB,EAAA,MAAMC,KAAK,GAAGC,MAAM,EAAa,CAAA;EAEjC,MAAMX,IAAI,GAAGC,SAAS,CAAA;AAEtBW,EAAAA,SAAS,CAAC,MAAM;IACdF,KAAK,CAACG,OAAO,GAAGb,IAAI,CAAA;AACtB,GAAC,CAAC,CAAA;AAEF,EAAA,MAAMc,eAAe,GAAGC,eAAe,CAACX,IAAK,CAAC,CAAA;AAC9C,EAAA,MAAMY,KAAK,GAAGF,eAAe,CAACE,KAAK,CAAA;AACnC,EAAA,MAAMC,MAAM,GAAGH,eAAe,CAACG,MAAM,CAAA;A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AA,QAAQ,EAAC,QAAQ;IACjBC,MAAM,EAAEtB,KAAK,GAAG,EAAG;AACnBuB,IAAAA,KAAK,EAAEC,WAAa,EAAE,CAACC,MAAM,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,EAAEnB,UAAU,CAAC,CAAc;AACrEoB,IAAAA,CAAC,EAAE,CAAE;AACLC,IAAAA,CAAC,EAAE3B,MAAO;AACV4B,IAAAA,UAAU,EAAE,CAAA;AAAE,GACf,CACA,CACA,CACL,CAEW,CAAC,CAAA;AAEtB,CAAC;;;;"}
@@ -0,0 +1,6 @@
1
+ import { Comp } from '@redsift/design-system';
2
+ import { LineChartProps } from './types.js';
3
+
4
+ declare const LineChart: Comp<LineChartProps, HTMLDivElement>;
5
+
6
+ export { LineChart };
@@ -0,0 +1,96 @@
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 { useId } from '@redsift/design-system';
5
+ import { LineChartLegendVariant } from './types.js';
6
+ import { LoadingLineChart } from './LoadingLineChart.js';
7
+ import { EmptyLineChart } from './EmptyLineChart.js';
8
+ import { RenderedLineChart } from './RenderedLineChart.js';
9
+ import { ColorTheme } from '../../types/theme.js';
10
+ import { ChartSize } from '../../types/size.js';
11
+ import { TooltipVariant } from '../../types/legend.js';
12
+ import { AxisVariant } from '../Axis/types.js';
13
+
14
+ const _excluded = ["className", "colorTheme", "data", "dotRole", "emptyComponent", "id", "isDotSelected", "labelDecorator", "legendDecorator", "legendVariant", "localeText", "onDotClick", "size", "sortingMethod", "tooltipDecorator", "tooltipVariant", "xAxisPlacement", "xAxisVariant", "yAxisPlacement", "yAxisVariant"];
15
+ const COMPONENT_NAME = 'LineChart';
16
+ const CLASSNAME = 'redsift-line-chart';
17
+ const LineChart = /*#__PURE__*/forwardRef((props, ref) => {
18
+ const {
19
+ className,
20
+ colorTheme = ColorTheme.dark,
21
+ data: propsData,
22
+ dotRole,
23
+ emptyComponent,
24
+ id: propsId,
25
+ isDotSelected,
26
+ labelDecorator,
27
+ legendDecorator,
28
+ legendVariant: propsLegendVariant,
29
+ localeText = {
30
+ emptyChartText: 'No Data'
31
+ },
32
+ onDotClick,
33
+ size = ChartSize.medium,
34
+ sortingMethod = 'desc-value',
35
+ tooltipDecorator,
36
+ tooltipVariant = TooltipVariant.none,
37
+ xAxisPlacement = 'bottom',
38
+ xAxisVariant = AxisVariant.default,
39
+ yAxisPlacement = 'left',
40
+ yAxisVariant = AxisVariant.default
41
+ } = props,
42
+ forwardedProps = _objectWithoutProperties(props, _excluded);
43
+ const [_id] = useId();
44
+ const id = propsId !== null && propsId !== void 0 ? propsId : _id;
45
+ const legendVariant = propsLegendVariant !== null && propsLegendVariant !== void 0 ? propsLegendVariant : LineChartLegendVariant.externalLabel;
46
+ if (propsData === undefined || propsData === null) {
47
+ return /*#__PURE__*/React__default.createElement(LoadingLineChart, _extends({
48
+ id: id
49
+ }, forwardedProps, {
50
+ ref: ref
51
+ }));
52
+ }
53
+ if (propsData.length === 0) {
54
+ return /*#__PURE__*/React__default.createElement(EmptyLineChart, _extends({
55
+ data: propsData,
56
+ emptyComponent: emptyComponent,
57
+ localeText: localeText,
58
+ size: size,
59
+ sortingMethod: sortingMethod,
60
+ xAxisPlacement: xAxisPlacement,
61
+ xAxisVariant: xAxisVariant,
62
+ yAxisPlacement: yAxisPlacement,
63
+ yAxisVariant: yAxisVariant
64
+ }, forwardedProps, {
65
+ ref: ref
66
+ }));
67
+ }
68
+ return /*#__PURE__*/React__default.createElement(RenderedLineChart, _extends({
69
+ className: classNames(LineChart.className, className),
70
+ colorTheme: colorTheme,
71
+ data: propsData,
72
+ dotRole: dotRole,
73
+ id: id,
74
+ isDotSelected: isDotSelected,
75
+ labelDecorator: labelDecorator,
76
+ legendDecorator: legendDecorator,
77
+ legendVariant: legendVariant,
78
+ localeText: localeText,
79
+ onDotClick: onDotClick,
80
+ size: size,
81
+ sortingMethod: sortingMethod,
82
+ tooltipDecorator: tooltipDecorator,
83
+ tooltipVariant: tooltipVariant,
84
+ xAxisPlacement: xAxisPlacement,
85
+ xAxisVariant: xAxisVariant,
86
+ yAxisPlacement: yAxisPlacement,
87
+ yAxisVariant: yAxisVariant
88
+ }, forwardedProps, {
89
+ ref: ref
90
+ }));
91
+ });
92
+ LineChart.className = CLASSNAME;
93
+ LineChart.displayName = COMPONENT_NAME;
94
+
95
+ export { LineChart };
96
+ //# sourceMappingURL=LineChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineChart.js","sources":["../../../src/components/LineChart/LineChart.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport classNames from 'classnames';\n\nimport { Comp, useId } from '@redsift/design-system';\n\nimport { ChartSize, ColorTheme, TooltipVariant } from '../../types';\nimport { LineChartLegendVariant, LineChartProps } from './types';\nimport { LoadingLineChart } from './LoadingLineChart';\nimport { EmptyLineChart } from './EmptyLineChart';\nimport { RenderedLineChart } from './RenderedLineChart';\nimport { AxisVariant } from '../Axis';\n\nconst COMPONENT_NAME = 'LineChart';\nconst CLASSNAME = 'redsift-line-chart';\n\nexport const LineChart: Comp<LineChartProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n className,\n colorTheme = ColorTheme.dark,\n data: propsData,\n dotRole,\n emptyComponent,\n id: propsId,\n isDotSelected,\n labelDecorator,\n legendDecorator,\n legendVariant: propsLegendVariant,\n localeText = { emptyChartText: 'No Data' },\n onDotClick,\n size = ChartSize.medium,\n sortingMethod = 'desc-value',\n tooltipDecorator,\n tooltipVariant = TooltipVariant.none,\n xAxisPlacement = 'bottom',\n xAxisVariant = AxisVariant.default,\n yAxisPlacement = 'left',\n yAxisVariant = AxisVariant.default,\n ...forwardedProps\n } = props;\n const [_id] = useId();\n const id = propsId ?? _id;\n\n const legendVariant = propsLegendVariant ?? LineChartLegendVariant.externalLabel;\n\n if (propsData === undefined || propsData === null) {\n return <LoadingLineChart id={id} {...forwardedProps} ref={ref} />;\n }\n\n if (propsData.length === 0) {\n return (\n <EmptyLineChart\n data={propsData}\n emptyComponent={emptyComponent}\n localeText={localeText}\n size={size}\n sortingMethod={sortingMethod}\n xAxisPlacement={xAxisPlacement}\n xAxisVariant={xAxisVariant}\n yAxisPlacement={yAxisPlacement}\n yAxisVariant={yAxisVariant}\n {...forwardedProps}\n ref={ref}\n />\n );\n }\n\n return (\n <RenderedLineChart\n className={classNames(LineChart.className, className)}\n colorTheme={colorTheme}\n data={propsData}\n dotRole={dotRole}\n id={id}\n isDotSelected={isDotSelected}\n labelDecorator={labelDecorator}\n legendDecorator={legendDecorator}\n legendVariant={legendVariant}\n localeText={localeText}\n onDotClick={onDotClick}\n size={size}\n sortingMethod={sortingMethod}\n tooltipDecorator={tooltipDecorator}\n tooltipVariant={tooltipVariant}\n xAxisPlacement={xAxisPlacement}\n xAxisVariant={xAxisVariant}\n yAxisPlacement={yAxisPlacement}\n yAxisVariant={yAxisVariant}\n {...forwardedProps}\n ref={ref}\n />\n );\n});\nLineChart.className = CLASSNAME;\nLineChart.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","LineChart","forwardRef","props","ref","className","colorTheme","ColorTheme","dark","data","propsData","dotRole","emptyComponent","id","propsId","isDotSelected","labelDecorator","legendDecorator","legendVariant","propsLegendVariant","localeText","emptyChartText","onDotClick","size","ChartSize","medium","sortingMethod","tooltipDecorator","tooltipVariant","TooltipVariant","none","xAxisPlacement","xAxisVariant","AxisVariant","default","yAxisPlacement","yAxisVariant","forwardedProps","_objectWithoutProperties","_excluded","_id","useId","LineChartLegendVariant","externalLabel","undefined","React","createElement","LoadingLineChart","_extends","length","EmptyLineChart","RenderedLineChart","classNames","displayName"],"mappings":";;;;;;;;;;;;;;AAYA,MAAMA,cAAc,GAAG,WAAW,CAAA;AAClC,MAAMC,SAAS,GAAG,oBAAoB,CAAA;AAE/B,MAAMC,SAA+C,gBAAGC,UAAU,CAAC,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,cAAe;AAC/BG,IAAAA,cAAc,EAAEA,cAAe;AAC/BC,IAAAA,YAAY,EAAEA,YAAa;AAC3BG,IAAAA,cAAc,EAAEA,cAAe;AAC/BC,IAAAA,YAAY,EAAEA,YAAAA;AAAa,GAAA,EACvBC,cAAc,EAAA;AAClBjC,IAAAA,GAAG,EAAEA,GAAAA;AAAI,GAAA,CACV,CAAC,CAAA;AAEN,CAAC,EAAC;AACFH,SAAS,CAACI,SAAS,GAAGL,SAAS,CAAA;AAC/BC,SAAS,CAACoD,WAAW,GAAGtD,cAAc;;;;"}
@@ -0,0 +1,18 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import { StyledLineChart } from './styles.js';
4
+
5
+ const _excluded = ["className"];
6
+ const LoadingLineChart = /*#__PURE__*/forwardRef((props, ref) => {
7
+ const {
8
+ className
9
+ } = props,
10
+ forwardedProps = _objectWithoutProperties(props, _excluded);
11
+ return /*#__PURE__*/React__default.createElement(StyledLineChart, _extends({}, forwardedProps, {
12
+ className: className,
13
+ ref: ref
14
+ }), "Loading...");
15
+ });
16
+
17
+ export { LoadingLineChart };
18
+ //# sourceMappingURL=LoadingLineChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadingLineChart.js","sources":["../../../src/components/LineChart/LoadingLineChart.tsx"],"sourcesContent":["import React, { forwardRef, RefObject } from 'react';\n\nimport { LineChartProps } from './types';\nimport { StyledLineChart } from './styles';\n\nexport const LoadingLineChart = forwardRef<HTMLDivElement, LineChartProps>((props, ref) => {\n const { className, ...forwardedProps } = props;\n\n return (\n <StyledLineChart {...forwardedProps} className={className} ref={ref as RefObject<HTMLDivElement>}>\n Loading...\n </StyledLineChart>\n );\n});\n"],"names":["LoadingLineChart","forwardRef","props","ref","className","forwardedProps","_objectWithoutProperties","_excluded","React","createElement","StyledLineChart","_extends"],"mappings":";;;;;AAKO,MAAMA,gBAAgB,gBAAGC,UAAU,CAAiC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACzF,MAAM;AAAEC,MAAAA,SAAAA;AAA6B,KAAC,GAAGF,KAAK;AAAxBG,IAAAA,cAAc,GAAAC,wBAAA,CAAKJ,KAAK,EAAAK,SAAA,CAAA,CAAA;EAE9C,oBACEC,cAAA,CAAAC,aAAA,CAACC,eAAe,EAAAC,QAAA,KAAKN,cAAc,EAAA;AAAED,IAAAA,SAAS,EAAEA,SAAU;AAACD,IAAAA,GAAG,EAAEA,GAAAA;AAAiC,GAAA,CAAA,EAAC,YAEjF,CAAC,CAAA;AAEtB,CAAC;;;;"}