@auth0/quantum-charts 0.2.1 → 0.3.2

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.
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { IBaseChartProps } from '../common/chart';
3
3
  export interface IBarChartProps<DataType = unknown> extends IBaseChartProps<DataType> {
4
4
  layout?: 'horizontal' | 'vertical';
5
5
  isStacked?: boolean;
6
6
  }
7
- export declare function BarChart<DataType = unknown>(props: IBarChartProps<DataType>): JSX.Element;
7
+ export declare function BarChart<DataType = unknown>(props: IBarChartProps<DataType>): React.JSX.Element;
@@ -4,4 +4,4 @@ export interface IChartCardProps extends IChartSummaryProps {
4
4
  children?: React.ReactChild;
5
5
  height?: number | string;
6
6
  }
7
- export declare function ChartCard(props: IChartCardProps): JSX.Element;
7
+ export declare function ChartCard(props: IChartCardProps): React.JSX.Element;
@@ -28,9 +28,9 @@ var quantum_product_1 = require("@auth0/quantum-product");
28
28
  var React = __importStar(require("react"));
29
29
  var chart_summary_1 = require("../chart-summary");
30
30
  function ChartCard(props) {
31
- var children = props.children, title = props.title, value = props.value, dataTable = props.dataTable, helperText = props.helperText, label = props.label, height = props.height;
31
+ var children = props.children, title = props.title, value = props.value, dataTable = props.dataTable, helperText = props.helperText, label = props.label, height = props.height, headerAction = props.headerAction;
32
32
  return (React.createElement(quantum_product_1.Card, { sx: { height: height, padding: 3 } },
33
- React.createElement(chart_summary_1.ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label }),
33
+ React.createElement(chart_summary_1.ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label, headerAction: headerAction }),
34
34
  children));
35
35
  }
36
36
  exports.ChartCard = ChartCard;
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  export interface IDataTableChartProps {
3
3
  title?: string;
4
4
  isOpen: boolean;
5
5
  toggleIsOpen: () => void;
6
6
  data: any;
7
7
  }
8
- export declare function DataTableChart(props: IDataTableChartProps): JSX.Element;
8
+ export declare function DataTableChart(props: IDataTableChartProps): React.JSX.Element;
@@ -102,16 +102,18 @@ function DataTableChart(props) {
102
102
  React.createElement(quantum_product_1.Box, null, isDonut ? (React.createElement(quantum_product_1.DataTable, { items: data, columns: [
103
103
  { field: 'name', title: 'Group' },
104
104
  { title: 'value', render: function (_a) {
105
+ var _b;
105
106
  var item = _a.item;
106
- return item.value || 'N/A';
107
+ return (_b = item.value) !== null && _b !== void 0 ? _b : 'N/A';
107
108
  } },
108
109
  ] })) : (Object.values(groups).map(function (item, index) {
109
- return (React.createElement(quantum_product_1.TabPanel, { key: index, value: item[index].group },
110
+ return (React.createElement(quantum_product_1.TabPanel, { key: index, value: item[0].group },
110
111
  React.createElement(quantum_product_1.DataTable, { items: item, columns: [
111
112
  { field: 'group', title: 'Group' },
112
113
  { title: 'value', render: function (_a) {
114
+ var _b;
113
115
  var item = _a.item;
114
- return item.value || 'N/A';
116
+ return (_b = item.value) !== null && _b !== void 0 ? _b : 'N/A';
115
117
  } },
116
118
  {
117
119
  title: hasKey ? 'key' : 'date',
@@ -6,5 +6,6 @@ export interface IChartSummaryProps {
6
6
  /** Renders help icon with tooltip as passed value **/
7
7
  helperText?: React.ReactNode;
8
8
  dataTable?: any;
9
+ headerAction?: React.ReactElement;
9
10
  }
10
- export declare function ChartSummary(props: IChartSummaryProps): JSX.Element;
11
+ export declare function ChartSummary(props: IChartSummaryProps): React.JSX.Element;
@@ -55,7 +55,7 @@ var Aggregate = (0, quantum_product_1.styled)('h4')(templateObject_1 || (templat
55
55
  return theme.typography.h4.fontSize;
56
56
  });
57
57
  function ChartSummary(props) {
58
- var title = props.title, value = props.value, helperText = props.helperText, label = props.label, dataTable = props.dataTable;
58
+ var title = props.title, value = props.value, helperText = props.helperText, label = props.label, dataTable = props.dataTable, headerAction = props.headerAction;
59
59
  var _a = __read(React.useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];
60
60
  var toggleIsOpen = function () {
61
61
  setIsOpen(function (prev) { return !prev; });
@@ -73,8 +73,11 @@ function ChartSummary(props) {
73
73
  color: 'textSecondary',
74
74
  } },
75
75
  React.createElement(quantum_product_1.HelpCircleIcon, { size: "16" })))))),
76
- dataTable && dataTable[0] && (React.createElement(quantum_product_1.IconButton, { label: "List button", onClick: function () { return setIsOpen(true); } },
77
- React.createElement(quantum_product_1.ListIcon, null)))), labelTypographyProps: { variant: 'subtitle1' }, description: React.createElement(quantum_product_1.StackLayout, { gutter: 1 },
76
+ React.createElement(quantum_product_1.StackLayout, { gutter: 1 },
77
+ dataTable && dataTable[0] && (React.createElement(quantum_product_1.StackLayoutItem, null,
78
+ React.createElement(quantum_product_1.IconButton, { label: "List button", onClick: function () { return setIsOpen(true); } },
79
+ React.createElement(quantum_product_1.ListIcon, null)))),
80
+ headerAction && (React.createElement(quantum_product_1.StackLayoutItem, { sx: { justifyContent: 'flex-end', display: 'flex', width: '100', flex: 1 } }, headerAction)))), labelTypographyProps: { variant: 'subtitle1' }, description: React.createElement(quantum_product_1.StackLayout, { gutter: 1 },
78
81
  React.createElement(Aggregate, null, value),
79
82
  label) }),
80
83
  dataTable && dataTable[0] && (React.createElement(data_table_chart_1.DataTableChart, { title: title, isOpen: isOpen, toggleIsOpen: toggleIsOpen, data: dataTable }))));
package/common/chart.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  import { TooltipProps } from 'recharts';
3
3
  import { IChartCardProps } from '../chart-card';
4
- export declare type ScaleType = 'date' | 'datetime' | 'label' | 'number';
4
+ export type ScaleType = 'date' | 'datetime' | 'label' | 'number';
5
5
  export interface ICustomTooltipProps extends TooltipProps<number, string> {
6
6
  scaleType?: 'datetime' | 'date';
7
7
  }
8
8
  export interface ILegendOptions {
9
9
  enabled?: boolean;
10
10
  }
11
- export declare type IChartDataPoint<DataType = unknown> = {
11
+ export type IChartDataPoint<DataType = unknown> = {
12
12
  group: string;
13
13
  value?: number;
14
14
  key?: string;
@@ -27,7 +27,7 @@ export interface IBaseChartProps<DataType = unknown> extends IChartCardProps {
27
27
  legend?: ILegendOptions;
28
28
  color?: 'categorical' | 'sequential';
29
29
  }
30
- export declare type IDonutChartDataPoint<DataType = unknown> = {
30
+ export type IDonutChartDataPoint<DataType = unknown> = {
31
31
  name: string;
32
32
  value?: number;
33
33
  } & DataType;
@@ -1,2 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const CustomLegend: (props: any) => JSX.Element;
1
+ import * as React from 'react';
2
+ export declare const CustomLegend: (props: any) => React.JSX.Element;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { ICustomTooltipProps } from './chart';
3
- declare const CustomTooltip: (props: ICustomTooltipProps) => JSX.Element | null;
3
+ declare const CustomTooltip: (props: ICustomTooltipProps) => React.JSX.Element | null;
4
4
  export default CustomTooltip;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { DeltaDirection, DeltaDisplayType } from '../delta';
3
3
  export interface ICompareAggregateProps {
4
4
  /** Current Value **/
@@ -16,4 +16,4 @@ export interface ICompareAggregateProps {
16
16
  **/
17
17
  direction?: DeltaDirection;
18
18
  }
19
- export declare function CompareAggregate(props: ICompareAggregateProps): JSX.Element;
19
+ export declare function CompareAggregate(props: ICompareAggregateProps): React.JSX.Element;
package/delta/delta.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- export declare type DeltaDirection = 'upIsGood' | 'upIsBad' | 'neutral';
3
- export declare type DeltaDisplayType = 'percent' | 'number';
4
- export declare type DeltaEmphasis = 'bad' | 'good' | 'neutral';
2
+ export type DeltaDirection = 'upIsGood' | 'upIsBad' | 'neutral';
3
+ export type DeltaDisplayType = 'percent' | 'number';
4
+ export type DeltaEmphasis = 'bad' | 'good' | 'neutral';
5
5
  export interface IDeltaProps {
6
6
  value: number;
7
7
  comparedValue: number;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- declare type CenterProps = {
2
+ type CenterProps = {
3
3
  data: any;
4
4
  activeIndex?: number;
5
5
  displayType: 'absolute' | 'percent';
@@ -1,10 +1,10 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { IDonutChartDataPoint } from '../common/chart';
3
- export declare type IDecoupledLegendProps<DataType = unknown> = {
3
+ export type IDecoupledLegendProps<DataType = unknown> = {
4
4
  data: IDonutChartDataPoint<DataType>[];
5
5
  activeIndex?: number;
6
6
  setActiveIndex: (index: number | undefined) => void;
7
7
  color?: 'categorical' | 'sequential';
8
8
  };
9
- declare function DecoupledLegend<DataType = unknown>(props: IDecoupledLegendProps<DataType>): JSX.Element;
9
+ declare function DecoupledLegend<DataType = unknown>(props: IDecoupledLegendProps<DataType>): React.JSX.Element;
10
10
  export default DecoupledLegend;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { IChartCardProps } from '../chart-card';
3
3
  import { IDonutChartDataPoint } from '../common/chart';
4
4
  interface IDonutChartProps<DataType = unknown> extends IChartCardProps {
@@ -8,5 +8,5 @@ interface IDonutChartProps<DataType = unknown> extends IChartCardProps {
8
8
  color?: 'categorical' | 'sequential';
9
9
  height?: number | string;
10
10
  }
11
- export declare function DonutChart(props: IDonutChartProps): JSX.Element;
11
+ export declare function DonutChart(props: IDonutChartProps): React.JSX.Element;
12
12
  export {};
@@ -2,8 +2,8 @@ import { Card } from '@auth0/quantum-product';
2
2
  import * as React from 'react';
3
3
  import { ChartSummary } from '../chart-summary';
4
4
  export function ChartCard(props) {
5
- var children = props.children, title = props.title, value = props.value, dataTable = props.dataTable, helperText = props.helperText, label = props.label, height = props.height;
5
+ var children = props.children, title = props.title, value = props.value, dataTable = props.dataTable, helperText = props.helperText, label = props.label, height = props.height, headerAction = props.headerAction;
6
6
  return (React.createElement(Card, { sx: { height: height, padding: 3 } },
7
- React.createElement(ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label }),
7
+ React.createElement(ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label, headerAction: headerAction }),
8
8
  children));
9
9
  }
@@ -73,16 +73,18 @@ export function DataTableChart(props) {
73
73
  React.createElement(Box, null, isDonut ? (React.createElement(DataTable, { items: data, columns: [
74
74
  { field: 'name', title: 'Group' },
75
75
  { title: 'value', render: function (_a) {
76
+ var _b;
76
77
  var item = _a.item;
77
- return item.value || 'N/A';
78
+ return (_b = item.value) !== null && _b !== void 0 ? _b : 'N/A';
78
79
  } },
79
80
  ] })) : (Object.values(groups).map(function (item, index) {
80
- return (React.createElement(TabPanel, { key: index, value: item[index].group },
81
+ return (React.createElement(TabPanel, { key: index, value: item[0].group },
81
82
  React.createElement(DataTable, { items: item, columns: [
82
83
  { field: 'group', title: 'Group' },
83
84
  { title: 'value', render: function (_a) {
85
+ var _b;
84
86
  var item = _a.item;
85
- return item.value || 'N/A';
87
+ return (_b = item.value) !== null && _b !== void 0 ? _b : 'N/A';
86
88
  } },
87
89
  {
88
90
  title: hasKey ? 'key' : 'date',
@@ -29,7 +29,7 @@ var Aggregate = styled('h4')(templateObject_1 || (templateObject_1 = __makeTempl
29
29
  return theme.typography.h4.fontSize;
30
30
  });
31
31
  export function ChartSummary(props) {
32
- var title = props.title, value = props.value, helperText = props.helperText, label = props.label, dataTable = props.dataTable;
32
+ var title = props.title, value = props.value, helperText = props.helperText, label = props.label, dataTable = props.dataTable, headerAction = props.headerAction;
33
33
  var _a = __read(React.useState(false), 2), isOpen = _a[0], setIsOpen = _a[1];
34
34
  var toggleIsOpen = function () {
35
35
  setIsOpen(function (prev) { return !prev; });
@@ -47,8 +47,11 @@ export function ChartSummary(props) {
47
47
  color: 'textSecondary',
48
48
  } },
49
49
  React.createElement(HelpCircleIcon, { size: "16" })))))),
50
- dataTable && dataTable[0] && (React.createElement(IconButton, { label: "List button", onClick: function () { return setIsOpen(true); } },
51
- React.createElement(ListIcon, null)))), labelTypographyProps: { variant: 'subtitle1' }, description: React.createElement(StackLayout, { gutter: 1 },
50
+ React.createElement(StackLayout, { gutter: 1 },
51
+ dataTable && dataTable[0] && (React.createElement(StackLayoutItem, null,
52
+ React.createElement(IconButton, { label: "List button", onClick: function () { return setIsOpen(true); } },
53
+ React.createElement(ListIcon, null)))),
54
+ headerAction && (React.createElement(StackLayoutItem, { sx: { justifyContent: 'flex-end', display: 'flex', width: '100', flex: 1 } }, headerAction)))), labelTypographyProps: { variant: 'subtitle1' }, description: React.createElement(StackLayout, { gutter: 1 },
52
55
  React.createElement(Aggregate, null, value),
53
56
  label) }),
54
57
  dataTable && dataTable[0] && (React.createElement(DataTableChart, { title: title, isOpen: isOpen, toggleIsOpen: toggleIsOpen, data: dataTable }))));
@@ -36,7 +36,7 @@ import { ChartCard } from '../chart-card';
36
36
  import { tickFormatter } from '../common/chart';
37
37
  import { CustomLegend } from '../common/custom-legend';
38
38
  export function LineChart(props) {
39
- var _a = props, data = _a.data, leftAxis = _a.leftAxis, bottomAxis = _a.bottomAxis, _b = _a.height, height = _b === void 0 ? 300 : _b, title = _a.title, value = _a.value, label = _a.label, helperText = _a.helperText, _c = _a.legend, legend = _c === void 0 ? true : _c, syncId = _a.syncId, _d = _a.color, color = _d === void 0 ? 'categorical' : _d;
39
+ var _a = props, data = _a.data, leftAxis = _a.leftAxis, bottomAxis = _a.bottomAxis, _b = _a.height, height = _b === void 0 ? 300 : _b, title = _a.title, value = _a.value, label = _a.label, helperText = _a.helperText, _c = _a.legend, legend = _c === void 0 ? true : _c, syncId = _a.syncId, _d = _a.color, color = _d === void 0 ? 'categorical' : _d, headerAction = _a.headerAction;
40
40
  var theme = useTheme();
41
41
  // Function to know how many lines we need based of how much different group values are.
42
42
  var groups = _.uniqBy(data, 'group').map(function (item) { return item.group; });
@@ -77,7 +77,7 @@ export function LineChart(props) {
77
77
  _b[entry.group] = entry[leftAxisDataKey],
78
78
  _b;
79
79
  });
80
- return (React.createElement(ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText },
80
+ return (React.createElement(ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText, headerAction: headerAction },
81
81
  React.createElement(ResponsiveContainer, { width: '100%', height: height }, data.length ? (React.createElement(RechartsLineChart, { data: Object.values(entries), height: height, width: 500, syncId: syncId, margin: {
82
82
  top: 24,
83
83
  right: 10,
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { DotProps } from 'recharts';
3
- declare const CustomActiveDot: (onMouseOver?: DotProps['onMouseOver']) => (props: Omit<DotProps, 'ref'>) => JSX.Element;
3
+ declare const CustomActiveDot: (onMouseOver?: DotProps['onMouseOver']) => (props: Omit<DotProps, 'ref'>) => React.JSX.Element;
4
4
  export default CustomActiveDot;
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { IBaseChartProps } from '../common/chart';
3
3
  export interface ILineChartProps<DataType = unknown> extends IBaseChartProps<DataType> {
4
4
  syncId?: number | string;
5
5
  }
6
- export declare function LineChart<DataType = unknown>(props: ILineChartProps<DataType>): JSX.Element;
6
+ export declare function LineChart<DataType = unknown>(props: ILineChartProps<DataType>): React.JSX.Element;
@@ -65,7 +65,7 @@ var chart_card_1 = require("../chart-card");
65
65
  var chart_1 = require("../common/chart");
66
66
  var custom_legend_1 = require("../common/custom-legend");
67
67
  function LineChart(props) {
68
- var _a = props, data = _a.data, leftAxis = _a.leftAxis, bottomAxis = _a.bottomAxis, _b = _a.height, height = _b === void 0 ? 300 : _b, title = _a.title, value = _a.value, label = _a.label, helperText = _a.helperText, _c = _a.legend, legend = _c === void 0 ? true : _c, syncId = _a.syncId, _d = _a.color, color = _d === void 0 ? 'categorical' : _d;
68
+ var _a = props, data = _a.data, leftAxis = _a.leftAxis, bottomAxis = _a.bottomAxis, _b = _a.height, height = _b === void 0 ? 300 : _b, title = _a.title, value = _a.value, label = _a.label, helperText = _a.helperText, _c = _a.legend, legend = _c === void 0 ? true : _c, syncId = _a.syncId, _d = _a.color, color = _d === void 0 ? 'categorical' : _d, headerAction = _a.headerAction;
69
69
  var theme = (0, quantum_product_1.useTheme)();
70
70
  // Function to know how many lines we need based of how much different group values are.
71
71
  var groups = lodash_1.default.uniqBy(data, 'group').map(function (item) { return item.group; });
@@ -106,7 +106,7 @@ function LineChart(props) {
106
106
  _b[entry.group] = entry[leftAxisDataKey],
107
107
  _b;
108
108
  });
109
- return (React.createElement(chart_card_1.ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText },
109
+ return (React.createElement(chart_card_1.ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText, headerAction: headerAction },
110
110
  React.createElement(recharts_1.ResponsiveContainer, { width: '100%', height: height }, data.length ? (React.createElement(recharts_1.LineChart, { data: Object.values(entries), height: height, width: 500, syncId: syncId, margin: {
111
111
  top: 24,
112
112
  right: 10,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth0/quantum-charts",
3
- "version": "0.2.1",
3
+ "version": "0.3.2",
4
4
  "sideEffects": false,
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "registry": "https://registry.npmjs.org/"
17
17
  },
18
18
  "dependencies": {
19
- "@auth0/quantum-product": "^1.10.1",
19
+ "@auth0/quantum-product": "^2.0.0",
20
20
  "@formatjs/intl": "^2.5.1",
21
21
  "date-fns": "^2.29.3",
22
22
  "recharts": "^2.0.7"
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { IChartSummaryProps } from '../chart-summary';
3
3
  interface IScoreCardProps {
4
4
  data: IChartSummaryProps[];
5
5
  }
6
- export declare function ScoreCard(props: IScoreCardProps): JSX.Element;
6
+ export declare function ScoreCard(props: IScoreCardProps): React.JSX.Element;
7
7
  export {};
package/styles.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare type IChartContainerProps = {
1
+ export type IChartContainerProps = {
2
2
  height?: number | 'initial';
3
3
  marginTop?: number;
4
4
  };