@redsift/dashboard 6.1.0 → 6.3.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 +82 -28
  2. package/index.js +7030 -6843
  3. package/index.js.map +1 -1
  4. package/package.json +6 -5
package/index.d.ts CHANGED
@@ -1,9 +1,16 @@
1
+ import * as crossfilter2 from 'crossfilter2';
1
2
  import { Crossfilter, Group as Group$1, NaturallyOrderedValue, Dimension as Dimension$1, ComparableObject, OrderedValueSelector } from 'crossfilter2';
2
- import React, { Ref, ReactElement, Dispatch, ComponentProps } from 'react';
3
- import { GridFilterItem, DataGridProps as DataGridProps$1 } from '@redsift/table';
4
3
  import { PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartVariant } from '@redsift/charts';
5
- export { PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartVariant } from '@redsift/charts';
4
+ export { ColorTheme, PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartVariant } from '@redsift/charts';
5
+ import React, { Ref, ReactElement, ComponentProps, Dispatch } from 'react';
6
+ import { GridFilterItem, DataGridProps as DataGridProps$1 } from '@redsift/table';
6
7
 
8
+ declare type SuccessDangerColorTheme = {
9
+ success: string;
10
+ warning: string;
11
+ danger: string;
12
+ neutral?: string;
13
+ };
7
14
  declare type JSONValue = string | number | boolean | {
8
15
  [x: string]: JSONValue;
9
16
  } | Array<JSONValue> | undefined | null;
@@ -25,6 +32,11 @@ declare type ChartDimensions = {
25
32
  marginLeft?: number;
26
33
  };
27
34
 
35
+ declare const COUNT: (d: Dimension) => crossfilter2.Group<any, crossfilter2.NaturallyOrderedValue, unknown>;
36
+
37
+ declare const groupReduceSum: (field: string) => (d: Dimension) => crossfilter2.Group<any, crossfilter2.NaturallyOrderedValue, unknown>;
38
+ declare const SUM: (field: string) => (d: Dimension) => crossfilter2.Group<any, crossfilter2.NaturallyOrderedValue, unknown>;
39
+
28
40
  /** Component Type. */
29
41
  declare type Comp<P, T = HTMLElement> = {
30
42
  (props: P & {
@@ -42,6 +54,22 @@ declare type Comp<P, T = HTMLElement> = {
42
54
  /** Get types of the values of a record. */
43
55
  declare type ValueOf<T extends Record<any, any>> = T[keyof T];
44
56
 
57
+ /**
58
+ * Component props.
59
+ */
60
+ interface ChartEmptyStateProps extends ComponentProps<'div'> {
61
+ /** Method to call when the reset button is pressed. Also conditioned whether the button is displayed or not. */
62
+ onReset?: () => void;
63
+ /** Reset button label. */
64
+ resetLabel?: string;
65
+ /** Subtitle. */
66
+ subtitle?: string;
67
+ /** Title. */
68
+ title?: string;
69
+ }
70
+
71
+ declare const ChartEmptyState: Comp<ChartEmptyStateProps, HTMLDivElement>;
72
+
45
73
  /**
46
74
  * Context props.
47
75
  */
@@ -58,12 +86,14 @@ declare type DashboardReducerState = {
58
86
  tableFilters: GridFilterItem[];
59
87
  };
60
88
  declare enum DashboardReducerActionType {
89
+ ResetFilter = "reset-filter",
90
+ ResetFilters = "reset-filters",
61
91
  FilterTable = "filter-table",
62
92
  FilterTableBatch = "filter-table-batch"
63
93
  }
64
94
  declare type DashboardReducerAction = {
65
95
  type: DashboardReducerActionType;
66
- filter: GridFilterItem | GridFilterItem[];
96
+ filter?: GridFilterItem | GridFilterItem[];
67
97
  };
68
98
  /**
69
99
  * Component props.
@@ -103,12 +133,18 @@ declare type HorizontalBarChartSize = ValueOf<typeof HorizontalBarChartSize>;
103
133
  */
104
134
  declare const HorizontalBarChartTheme: {
105
135
  readonly default: "default";
136
+ /**
137
+ * Component theme.
138
+ */
106
139
  readonly dark: "dark";
107
140
  readonly darker: "darker";
108
141
  readonly monochrome: "monochrome";
109
142
  };
110
143
  declare type HorizontalBarChartTheme = ValueOf<typeof HorizontalBarChartTheme>;
111
144
  interface LocaleText$2 {
145
+ emptyChartTitle?: string;
146
+ emptyChartSubtitle?: string;
147
+ emptyChartResetLabel?: string;
112
148
  resetLabel?: string;
113
149
  }
114
150
  /**
@@ -121,30 +157,35 @@ interface HorizontalBarChartProps extends ComponentProps<'div'> {
121
157
  caption?: string;
122
158
  /** Whether the x axis labels are rotated or not. */
123
159
  areXLabelsRotated?: boolean;
124
- /** Field value of the DataGrid column to filter. */
125
- columnToFilter?: string;
126
160
  /** Dataset to use to generate the chart, if no context is provided. */
127
161
  data?: JSONArray;
162
+ /** Which datagrid column the chart is filtering and using which operation. */
163
+ datagridFilter?: {
164
+ field: string;
165
+ operator: 'containsAnyOf' | 'endsWithAnyOf' | 'isAnyOf';
166
+ };
128
167
  /** Method that will be used by crossfilter to compute the dimensions of the charts. */
129
168
  dimension: DimensionSelector;
130
169
  /** Reset function that is triggered when reset button is pressed in the empty state chart. */
131
170
  emptyChartResetFn?: () => void;
132
171
  /** Method that will be used by crossfilter to compute the groups of the charts. */
133
- group: GroupSelector;
172
+ group: (d: Dimension) => Group;
173
+ /** Whether the dimension field is an array or not. */
174
+ isDimensionArray?: boolean;
134
175
  /** Whether the reset button is hidden or not. */
135
176
  isResetable?: boolean;
136
177
  /** Overriden values for internal labels and texts. */
137
178
  localeText?: LocaleText$2;
179
+ /** Method to call when a filter occured on the chart. */
180
+ onFilter?: (filters?: string[]) => void;
138
181
  /** 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. */
139
182
  others?: boolean | string;
183
+ /** Method to override the data labels. */
184
+ setLabels?: (key: string) => string | undefined;
140
185
  /** HorizontalBarChart size. */
141
186
  size?: HorizontalBarChartSize;
142
187
  /** 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. */
143
- theme?: HorizontalBarChartTheme | {
144
- success: string;
145
- warning: string;
146
- danger: string;
147
- };
188
+ theme?: HorizontalBarChartTheme | SuccessDangerColorTheme;
148
189
  /** Title. */
149
190
  title?: string;
150
191
  }
@@ -166,34 +207,41 @@ interface PieChartProps extends ComponentProps<'div'> {
166
207
  caping?: number;
167
208
  /** Caption. */
168
209
  caption?: string;
169
- /** Field value of the DataGrid column to filter. */
170
- columnToFilter?: string;
171
210
  /** Dataset to use to generate the chart, if no context is provided. */
172
211
  data?: JSONArray;
212
+ /** Which datagrid column the chart is filtering and using which operation. */
213
+ datagridFilter?: {
214
+ field: string;
215
+ operator: 'containsAnyOf' | 'endsWithAnyOf' | 'isAnyOf';
216
+ };
173
217
  /** Method that will be used by crossfilter to compute the dimensions of the charts. */
174
218
  dimension: DimensionSelector;
175
219
  /** Method that will be used by crossfilter to compute the groups of the charts. */
176
- group: GroupSelector;
220
+ group: (d: Dimension) => Group;
221
+ /** Whether the dimension field is an array or not. */
222
+ isDimensionArray?: boolean;
177
223
  /** Whether the reset button is hidden or not. */
178
224
  isResetable?: boolean;
179
225
  /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. */
180
226
  labelVariant?: PieChartLabelVariant;
181
227
  /** Overriden values for internal labels and texts. */
182
228
  localeText?: LocaleText$1;
229
+ /** Method to call when a filter occured on the chart. */
230
+ onFilter?: (filters?: string[]) => void;
183
231
  /** 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. */
184
232
  others?: boolean | string;
233
+ /** Method to override the data labels. */
234
+ setLabels?: (key: string) => string | undefined;
185
235
  /** PieChart size. */
186
236
  size?: PieChartSize;
187
- /** Secondary text to be displayed in the middle of the chart, above the main text. Only for donut variant. */
188
- subtext?: string;
189
237
  /** Main text to be displayed in the middle of the chart. Only for donut variant. */
190
238
  text?: string;
239
+ /** 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. */
240
+ middleText?: string;
241
+ /** Secondary text to be displayed in the middle of the chart, above the main text. Only for donut variant. */
242
+ subtext?: string;
191
243
  /** 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. */
192
- theme?: PieChartTheme | {
193
- success: string;
194
- warning: string;
195
- danger: string;
196
- };
244
+ theme?: PieChartTheme | SuccessDangerColorTheme;
197
245
  /** Title. */
198
246
  title?: string;
199
247
  /** PieChart variant. */
@@ -219,6 +267,9 @@ declare type TimeSeriesBarChartSize = ValueOf<typeof TimeSeriesBarChartSize>;
219
267
  * Component theme.
220
268
  */
221
269
  declare const TimeSeriesBarChartTheme: {
270
+ /**
271
+ * Component theme.
272
+ */
222
273
  readonly default: "default";
223
274
  readonly dark: "dark";
224
275
  readonly darker: "darker";
@@ -227,6 +278,9 @@ declare const TimeSeriesBarChartTheme: {
227
278
  declare type TimeSeriesBarChartTheme = ValueOf<typeof TimeSeriesBarChartTheme>;
228
279
  declare type datetimeEnum = 'hour' | 'day' | 'week' | 'month' | 'year';
229
280
  interface LocaleText {
281
+ emptyChartTitle?: string;
282
+ emptyChartSubtitle?: string;
283
+ emptyChartResetLabel?: string;
230
284
  resetLabel?: string;
231
285
  }
232
286
  /**
@@ -253,18 +307,18 @@ interface TimeSeriesBarChartProps extends ComponentProps<'div'> {
253
307
  isResetable?: boolean;
254
308
  /** Overriden values for internal labels and texts. */
255
309
  localeText?: LocaleText;
310
+ /** Method to call when a filter occured on the chart. */
311
+ onFilter?: (filters?: string[], allFiltered?: JSONArray) => void;
256
312
  /** TimeSeriesChart size. */
257
313
  size?: TimeSeriesBarChartSize;
258
314
  /** 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. */
259
- theme?: TimeSeriesBarChartTheme | {
260
- success: string;
261
- warning: string;
262
- danger: string;
263
- };
315
+ theme?: TimeSeriesBarChartTheme | SuccessDangerColorTheme;
264
316
  /** Title. */
265
317
  title?: string;
266
318
  /** Dataset key to use to stack values. */
267
319
  stackedCategory?: string;
320
+ /** X Axis Label. */
321
+ xAxisLabel?: string;
268
322
  /** Y Axis Label. */
269
323
  yAxisLabel?: string;
270
324
  }
@@ -272,4 +326,4 @@ declare type StyledTimeSeriesBarChartProps = Omit<TimeSeriesBarChartProps, 'dime
272
326
 
273
327
  declare const TimeSeriesBarChart: Comp<TimeSeriesBarChartProps, HTMLDivElement>;
274
328
 
275
- export { ChartDimensions, Dashboard, DashboardContext, DashboardContextProps, DashboardProps, DashboardReducer, DashboardReducerAction, DashboardReducerActionType, DashboardReducerState, DataGrid, DataGridProps, Dimension, DimensionSelector, Group, GroupSelector, HorizontalBarChart, HorizontalBarChartProps, HorizontalBarChartSize, HorizontalBarChartTheme, JSONArray, JSONObject, JSONValue, PieChart, PieChartProps, StyledHorizontalBarChartProps, StyledPieChartProps, StyledTimeSeriesBarChartProps, TNdx, TimeSeriesBarChart, TimeSeriesBarChartProps, TimeSeriesBarChartSize, TimeSeriesBarChartTheme, datetimeEnum, initialState };
329
+ export { COUNT, ChartDimensions, ChartEmptyState, ChartEmptyStateProps, Dashboard, DashboardContext, DashboardContextProps, DashboardProps, DashboardReducer, DashboardReducerAction, DashboardReducerActionType, DashboardReducerState, DataGrid, DataGridProps, Dimension, DimensionSelector, Group, GroupSelector, HorizontalBarChart, HorizontalBarChartProps, HorizontalBarChartSize, HorizontalBarChartTheme, JSONArray, JSONObject, JSONValue, PieChart, PieChartProps, SUM, StyledHorizontalBarChartProps, StyledPieChartProps, StyledTimeSeriesBarChartProps, SuccessDangerColorTheme, TNdx, TimeSeriesBarChart, TimeSeriesBarChartProps, TimeSeriesBarChartSize, TimeSeriesBarChartTheme, datetimeEnum, groupReduceSum, initialState };