@redsift/charts 7.0.2 → 7.1.1-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 (4) hide show
  1. package/index.d.ts +126 -17
  2. package/index.js +734 -201
  3. package/index.js.map +1 -1
  4. package/package.json +7 -8
package/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { PieArcDatum as PieArcDatum$1 } from 'd3-shape';
2
- import { ScaleOrdinal } from 'd3';
2
+ import { ScaleOrdinal, ScaleLinear } from 'd3';
3
3
  import { ValueOf as ValueOf$1, Comp } from '@redsift/design-system';
4
4
  import { ComponentProps } from 'react';
5
5
  import * as styled_components from 'styled-components';
6
6
 
7
7
  /** Get types of the values of a record. */
8
- declare type ValueOf<T extends Record<any, any>> = T[keyof T];
8
+ type ValueOf<T extends Record<any, any>> = T[keyof T];
9
9
 
10
- declare type ChartDimensions = {
10
+ type ChartDimensions = {
11
11
  width: number;
12
12
  height: number;
13
13
  marginTop?: number;
@@ -15,19 +15,19 @@ declare type ChartDimensions = {
15
15
  marginBottom?: number;
16
16
  marginLeft?: number;
17
17
  };
18
- declare type Datum = {
18
+ type Datum = {
19
19
  name: string;
20
20
  value: number;
21
21
  };
22
- declare type PieArcDatum = PieArcDatum$1<Datum>;
22
+ type PieArcDatum = PieArcDatum$1<Datum>;
23
23
  declare const ColorTheme: {
24
24
  readonly default: "default";
25
25
  readonly dark: "dark";
26
26
  readonly darker: "darker";
27
27
  readonly monochrome: "monochrome";
28
28
  };
29
- declare type ColorTheme = ValueOf<typeof ColorTheme>;
30
- declare type SuccessDangerColorTheme = {
29
+ type ColorTheme = ValueOf<typeof ColorTheme>;
30
+ type SuccessDangerColorTheme = {
31
31
  success: string;
32
32
  warning: string;
33
33
  danger: string;
@@ -52,6 +52,111 @@ declare const successDangerScheme: {
52
52
  };
53
53
  declare const getColorScale: (theme: ColorTheme | SuccessDangerColorTheme, isEmpty?: boolean) => ScaleOrdinal<string, string>;
54
54
 
55
+ /**
56
+ * Component size.
57
+ */
58
+ declare const HorizontalBarChartSize: {
59
+ readonly small: "small";
60
+ readonly medium: "medium";
61
+ readonly large: "large";
62
+ };
63
+ type HorizontalBarChartSize = ValueOf$1<typeof HorizontalBarChartSize>;
64
+ /**
65
+ * Component theme.
66
+ */
67
+ declare const HorizontalBarChartTheme: {
68
+ readonly default: "default";
69
+ readonly dark: "dark";
70
+ readonly darker: "darker";
71
+ readonly monochrome: "monochrome";
72
+ };
73
+ type HorizontalBarChartTheme = ValueOf$1<typeof HorizontalBarChartTheme>;
74
+ /**
75
+ * Tooltip label variant.
76
+ */
77
+ declare const HorizontalBarChartTooltipVariant: {
78
+ none: string;
79
+ label: string;
80
+ value: string;
81
+ percent: string;
82
+ };
83
+ type HorizontalBarChartTooltipVariant = ValueOf$1<typeof HorizontalBarChartTooltipVariant>;
84
+ interface LocaleText$1 {
85
+ emptyChartText: string;
86
+ }
87
+ /**
88
+ * Component props.
89
+ */
90
+ interface HorizontalBarChartProps extends ComponentProps<'div'> {
91
+ /** Whether the x axis labels are rotated or not. */
92
+ areXLabelsRotated?: boolean;
93
+ /** Number of categories to use, the rest being put into a new category called "Others". */
94
+ caping?: number;
95
+ /** Caption. */
96
+ caption?: string;
97
+ /** Dataset to use to generate the chart, should be a list of objects containing a name and a value. */
98
+ data: Datum[];
99
+ /** Labels and texts. */
100
+ localeText?: LocaleText$1;
101
+ /** Method to be called on a click on a bar. */
102
+ onBarClick?: (data: Datum) => void;
103
+ /** 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. */
104
+ others?: boolean | string;
105
+ /** HorizontalBarChart size. */
106
+ size?: HorizontalBarChartSize;
107
+ /** Bar role. Used to indicate that bars are to be considered buttons or links. If an onClick is provided, the bars will have the role `button` unless specifically set to `link` with this prop. */
108
+ barRole?: 'button' | 'link';
109
+ /** 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. */
110
+ theme?: HorizontalBarChartTheme | SuccessDangerColorTheme;
111
+ /** Title. */
112
+ title?: string;
113
+ /** Tooltip variant. */
114
+ tooltipVariant?: HorizontalBarChartTooltipVariant;
115
+ }
116
+ type StyledHorizontalBarChartProps = Omit<HorizontalBarChartProps, 'data'> & {};
117
+ interface HorizontalBarChartBarProps extends ComponentProps<'g'> {
118
+ chartId: string;
119
+ color: string;
120
+ data: Datum;
121
+ gap: number;
122
+ height: number;
123
+ index: number;
124
+ isEmpty: boolean;
125
+ onClick?: () => void;
126
+ role?: HorizontalBarChartProps['barRole'];
127
+ showTooltip: boolean;
128
+ tooltipLabelOnly: boolean;
129
+ tooltipPercent: string | null;
130
+ width: number;
131
+ }
132
+ type StyledHorizontalBarChartBarProps = Omit<HorizontalBarChartBarProps, 'chartId' | 'color' | 'data' | 'gap' | 'height' | 'index' | 'isEmpty' | 'showTooltip' | 'tooltipPercent' | 'tooltipLabelOnly' | 'width'> & {
133
+ $clickable: boolean;
134
+ };
135
+ interface HorizontalBarChartAxisBottomProps extends ComponentProps<'g'> {
136
+ areXLabelsRotated: boolean;
137
+ chartHeight: number;
138
+ d3scale: ScaleLinear<number, number>;
139
+ }
140
+ type StyledHorizontalBarChartAxisBottomProps = Omit<HorizontalBarChartAxisBottomProps, 'areXLabelsRotated' | 'chartHeight' | 'd3scale'> & {};
141
+
142
+ declare const HorizontalBarChart: Comp<HorizontalBarChartProps, HTMLDivElement>;
143
+
144
+ /**
145
+ * Component style.
146
+ */
147
+ declare const StyledHorizontalBarChart: styled_components.StyledComponent<"div", any, Omit<HorizontalBarChartProps, "data">, never>;
148
+ declare const StyledHorizontalBarChartTitle: styled_components.StyledComponent<"div", any, Omit<HorizontalBarChartProps, "data">, never>;
149
+ declare const StyledHorizontalBarChartCaption: styled_components.StyledComponent<"p", any, Omit<HorizontalBarChartProps, "data">, never>;
150
+ declare const StyledHorizontalBarChartEmptyText: styled_components.StyledComponent<"div", any, {
151
+ $maxWidth: number;
152
+ $textSize: number;
153
+ }, never>;
154
+ declare const StyledHorizontalBarChartBar: styled_components.StyledComponent<"g", any, Omit<HorizontalBarChartBarProps, "data" | "color" | "height" | "width" | "chartId" | "gap" | "index" | "isEmpty" | "showTooltip" | "tooltipPercent" | "tooltipLabelOnly"> & {
155
+ $clickable: boolean;
156
+ }, never>;
157
+ declare const StyledHorizontalBarChartTooltip: styled_components.StyledComponent<"div", any, {}, never>;
158
+ declare const StyledHorizontalBarChartAxisBottom: styled_components.StyledComponent<"g", any, {}, never>;
159
+
55
160
  /**
56
161
  * Component size.
57
162
  */
@@ -60,7 +165,7 @@ declare const PieChartSize: {
60
165
  readonly medium: "medium";
61
166
  readonly large: "large";
62
167
  };
63
- declare type PieChartSize = ValueOf$1<typeof PieChartSize>;
168
+ type PieChartSize = ValueOf$1<typeof PieChartSize>;
64
169
  /**
65
170
  * Component variant.
66
171
  */
@@ -70,7 +175,7 @@ declare const PieChartVariant: {
70
175
  readonly donut: "donut";
71
176
  readonly spacedDonut: "spacedDonut";
72
177
  };
73
- declare type PieChartVariant = ValueOf$1<typeof PieChartVariant>;
178
+ type PieChartVariant = ValueOf$1<typeof PieChartVariant>;
74
179
  /**
75
180
  * Component's labels variant.
76
181
  */
@@ -81,7 +186,7 @@ declare const PieChartLabelVariant: {
81
186
  readonly externalLabelValue: "externalLabelValue";
82
187
  readonly externalLabelPercent: "externalLabelPercent";
83
188
  };
84
- declare type PieChartLabelVariant = ValueOf$1<typeof PieChartLabelVariant>;
189
+ type PieChartLabelVariant = ValueOf$1<typeof PieChartLabelVariant>;
85
190
  /**
86
191
  * Component theme.
87
192
  */
@@ -91,7 +196,7 @@ declare const PieChartTheme: {
91
196
  readonly darker: "darker";
92
197
  readonly monochrome: "monochrome";
93
198
  };
94
- declare type PieChartTheme = ValueOf$1<typeof PieChartTheme>;
199
+ type PieChartTheme = ValueOf$1<typeof PieChartTheme>;
95
200
  /**
96
201
  * Tooltip label variant.
97
202
  */
@@ -101,7 +206,7 @@ declare const PieChartTooltipVariant: {
101
206
  value: string;
102
207
  percent: string;
103
208
  };
104
- declare type PieChartTooltipVariant = ValueOf$1<typeof PieChartTooltipVariant>;
209
+ type PieChartTooltipVariant = ValueOf$1<typeof PieChartTooltipVariant>;
105
210
  interface LocaleText {
106
211
  emptyChartText: string;
107
212
  }
@@ -125,6 +230,8 @@ interface PieChartProps extends ComponentProps<'div'> {
125
230
  others?: boolean | string;
126
231
  /** PieChart size. */
127
232
  size?: PieChartSize;
233
+ /** Slice role. Used to indicate that slices are to be considered buttons or links. If an onClick is provided, the slices will have the role `button` unless specifically set to `link` with this prop. */
234
+ sliceRole?: 'button' | 'link';
128
235
  /** Secondary text to be displayed in the middle of the chart, between the main text and subtext. Recommended to be used with donut variants only. */
129
236
  middleText?: string;
130
237
  /** Secondary text to be displayed in the middle of the chart, above the main text. Recommended to be used with `donut` variants only. */
@@ -140,20 +247,22 @@ interface PieChartProps extends ComponentProps<'div'> {
140
247
  /** Tooltip variant. */
141
248
  tooltipVariant?: PieChartTooltipVariant;
142
249
  }
143
- declare type StyledPieChartProps = Omit<PieChartProps, 'data'> & {};
250
+ type StyledPieChartProps = Omit<PieChartProps, 'data'> & {};
144
251
  interface PieChartArcProps extends ComponentProps<'g'> {
252
+ chartId: string;
145
253
  color: string;
146
254
  data: Datum;
147
255
  index: number;
148
256
  onClick?: () => void;
149
257
  path: string;
258
+ role?: PieChartProps['sliceRole'];
150
259
  spaced?: boolean;
151
260
  showTooltip: boolean;
152
261
  tooltipPercent: string | null;
153
262
  tooltipLabelOnly: boolean;
154
263
  isEmpty: boolean;
155
264
  }
156
- declare type StyledPieChartArcProps = Omit<PieChartArcProps, 'color' | 'data' | 'index' | 'path' | 'spaced' | 'showTooltip' | 'tooltipPercent' | 'tooltipLabelOnly' | 'isEmpty'> & {
265
+ type StyledPieChartArcProps = Omit<PieChartArcProps, 'chartId' | 'color' | 'data' | 'index' | 'path' | 'spaced' | 'showTooltip' | 'tooltipPercent' | 'tooltipLabelOnly' | 'isEmpty'> & {
157
266
  $spaced: boolean;
158
267
  $clickable: boolean;
159
268
  };
@@ -179,10 +288,10 @@ declare const StyledPieChartEmptyText: styled_components.StyledComponent<"div",
179
288
  declare const StyledPieChartLabel: styled_components.StyledComponent<"li", any, {
180
289
  $color: string;
181
290
  }, never>;
182
- declare const StyledPieChartArc: styled_components.StyledComponent<"g", any, Omit<PieChartArcProps, "data" | "path" | "color" | "spaced" | "index" | "showTooltip" | "tooltipPercent" | "tooltipLabelOnly" | "isEmpty"> & {
291
+ declare const StyledPieChartArc: styled_components.StyledComponent<"g", any, Omit<PieChartArcProps, "data" | "path" | "color" | "chartId" | "index" | "isEmpty" | "showTooltip" | "tooltipPercent" | "tooltipLabelOnly" | "spaced"> & {
183
292
  $spaced: boolean;
184
293
  $clickable: boolean;
185
294
  }, never>;
186
- declare const Tooltip: styled_components.StyledComponent<"div", any, {}, never>;
295
+ declare const StyledPieChartTooltip: styled_components.StyledComponent<"div", any, {}, never>;
187
296
 
188
- export { ChartDimensions, ColorTheme, Datum, PieArcDatum, PieChart, PieChartArcProps, PieChartLabelVariant, PieChartProps, PieChartSize, PieChartTheme, PieChartTooltipVariant, PieChartVariant, StyledPieChart, StyledPieChartArc, StyledPieChartArcProps, StyledPieChartCaption, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartLabel, StyledPieChartProps, StyledPieChartTitle, SuccessDangerColorTheme, Tooltip, getColorScale, monochrome, scheme, successDangerScheme };
297
+ export { ChartDimensions, ColorTheme, Datum, HorizontalBarChart, HorizontalBarChartAxisBottomProps, HorizontalBarChartBarProps, HorizontalBarChartProps, HorizontalBarChartSize, HorizontalBarChartTheme, HorizontalBarChartTooltipVariant, PieArcDatum, PieChart, PieChartArcProps, PieChartLabelVariant, PieChartProps, PieChartSize, PieChartTheme, PieChartTooltipVariant, PieChartVariant, StyledHorizontalBarChart, StyledHorizontalBarChartAxisBottom, StyledHorizontalBarChartAxisBottomProps, StyledHorizontalBarChartBar, StyledHorizontalBarChartBarProps, StyledHorizontalBarChartCaption, StyledHorizontalBarChartEmptyText, StyledHorizontalBarChartProps, StyledHorizontalBarChartTitle, StyledHorizontalBarChartTooltip, StyledPieChart, StyledPieChartArc, StyledPieChartArcProps, StyledPieChartCaption, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartLabel, StyledPieChartProps, StyledPieChartTitle, StyledPieChartTooltip, SuccessDangerColorTheme, getColorScale, monochrome, scheme, successDangerScheme };