@auth0/quantum-charts 0.1.0 → 0.1.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.
@@ -109,7 +109,7 @@ function BarChart(props) {
109
109
  React.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: height }, data.length ? (React.createElement(recharts_1.BarChart, { width: 500, layout: layout === 'horizontal' ? 'vertical' : 'horizontal', height: height, data: Object.values(entries), margin: {
110
110
  top: 24,
111
111
  right: 10,
112
- left: layout === 'vertical' ? -24 : 16,
112
+ left: layout === 'vertical' ? -24 : 36,
113
113
  bottom: 0,
114
114
  } },
115
115
  React.createElement(recharts_1.CartesianGrid, { vertical: false, stroke: theme.tokens.color_border_default }),
@@ -120,15 +120,11 @@ function BarChart(props) {
120
120
  dataKey: bottomAxisDataKey,
121
121
  }), { domain: ['auto', 'auto'], axisLine: { stroke: theme.tokens.color_border_bold }, tickLine: { stroke: theme.tokens.color_border_bold } })),
122
122
  React.createElement(recharts_1.Tooltip, { wrapperStyle: { outline: 'none' }, content: React.createElement(custom_tooltip_1.default, { active: undefined, payload: undefined, scaleType: bottomAxis.scaleType }) }),
123
- React.createElement(recharts_1.Legend, { align: "center", iconType: "square", iconSize: 14, wrapperStyle: { paddingTop: 16 }, content: React.createElement(custom_legend_1.CustomLegend, { selectData: selectBar, handleLegendMouseEnter: handleLegendMouseEnter, handleLegendMouseLeave: handleLegendMouseLeave, dataVisibility: barVisibility }) }),
123
+ React.createElement(recharts_1.Legend, { align: "center", content: React.createElement(custom_legend_1.CustomLegend, { selectData: selectBar, handleLegendMouseEnter: handleLegendMouseEnter, handleLegendMouseLeave: handleLegendMouseLeave, dataVisibility: barVisibility }) }),
124
124
  groups.map(function (group, index) {
125
125
  return (React.createElement(recharts_1.Bar, __assign({ key: group, dataKey: group }, (isStacked && { stackId: 'stack' }), { name: group, maxBarSize: 70, hide: barVisibility[group] === true, fill: barVisibility.hover === group || !barVisibility.hover
126
126
  ? (0, theme_1.getColorScale)(theme)[color]['base'][index]
127
- : (0, theme_1.getColorScale)(theme)[color]['muted'][index], radius: !isStacked || index == groups.length - 1
128
- ? layout === 'vertical'
129
- ? [4, 4, 0, 0]
130
- : [0, 4, 4, 0]
131
- : [0, 0, 0, 0] })));
127
+ : (0, theme_1.getColorScale)(theme)[color]['muted'][index] })));
132
128
  }))) : (React.createElement("div", { style: {
133
129
  display: 'grid',
134
130
  placeItems: 'center',
@@ -2,5 +2,6 @@ import * as React from 'react';
2
2
  import { IChartSummaryProps } from '../chart-summary';
3
3
  export interface IChartCardProps extends IChartSummaryProps {
4
4
  children?: React.ReactChild;
5
+ height?: number | string;
5
6
  }
6
7
  export declare function ChartCard(props: IChartCardProps): JSX.Element;
@@ -28,8 +28,8 @@ 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;
32
- return (React.createElement(quantum_product_1.Card, null,
31
+ var children = props.children, title = props.title, value = props.value, dataTable = props.dataTable, helperText = props.helperText, label = props.label, height = props.height;
32
+ return (React.createElement(quantum_product_1.Card, { sx: { height: height, padding: 3 } },
33
33
  React.createElement(chart_summary_1.ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label }),
34
34
  children));
35
35
  }
@@ -93,13 +93,13 @@ function DataTableChart(props) {
93
93
  };
94
94
  return (React.createElement(quantum_product_1.Dialog, { open: isOpen, fullWidth: true, title: title, onClose: toggleIsOpen, actions: React.createElement(React.Fragment, null,
95
95
  React.createElement(quantum_product_1.Button, { color: "primary", variant: "contained", startIcon: React.createElement(quantum_product_1.DownloadIcon, null), onClick: function () { return downloadCSV(title); } }, "Download")) },
96
- React.createElement(quantum_product_1.Box, { p: 2 },
96
+ React.createElement(quantum_product_1.Box, null,
97
97
  React.createElement(quantum_product_1.Tabs, { baseId: 'example', onChange: setSelectedTab, value: selectedTab },
98
- React.createElement(quantum_product_1.TabList, { classes: { indicator: 'chromatic-ignore' } }, !isDonut &&
98
+ React.createElement(quantum_product_1.TabList, { classes: { indicator: 'chromatic-ignore' }, style: isDonut ? { display: 'none' } : { display: 'block' } }, !isDonut &&
99
99
  Object.keys(groups).map(function (group, index) {
100
100
  return React.createElement(quantum_product_1.Tab, { key: index, label: group, value: group });
101
101
  })),
102
- React.createElement(quantum_product_1.Box, { paddingY: 2 }, isDonut ? (React.createElement(quantum_product_1.DataTable, { items: data, columns: [
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
105
  var item = _a.item;
@@ -37,12 +37,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.CustomLegend = void 0;
38
38
  var quantum_product_1 = require("@auth0/quantum-product");
39
39
  var React = __importStar(require("react"));
40
- var Root = (0, quantum_product_1.styled)(quantum_product_1.StackLayout)(function (_a) {
41
- var theme = _a.theme;
42
- return ({
43
- justifyContent: 'center',
44
- marginTop: theme.spacing(3),
45
- });
40
+ var Root = (0, quantum_product_1.styled)(quantum_product_1.StackLayout)({
41
+ justifyContent: 'center',
46
42
  });
47
43
  var LegendIcon = (0, quantum_product_1.styled)('div')(function (_a) {
48
44
  var theme = _a.theme, ownerState = _a.ownerState;
@@ -26,13 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  var React = __importStar(require("react"));
27
27
  var quantum_product_1 = require("@auth0/quantum-product");
28
28
  var theme_1 = require("../theme");
29
- var Root = (0, quantum_product_1.styled)('div')({
30
- display: 'flex',
31
- flexDirection: 'column',
32
- gap: '8px',
33
- height: '150px',
34
- flexWrap: 'wrap',
35
- });
36
29
  var LegendDot = (0, quantum_product_1.styled)('div')({
37
30
  height: '14px',
38
31
  width: '14px',
@@ -49,7 +42,7 @@ function DecoupledLegend(props) {
49
42
  var theme = (0, quantum_product_1.useTheme)();
50
43
  var BASE_COLORS = (0, theme_1.getColorScale)(theme)[color]['base'];
51
44
  var MUTED_COLORS = (0, theme_1.getColorScale)(theme)[color]['muted'];
52
- return (React.createElement(Root, null, data.map(function (datum, index) {
45
+ return (React.createElement(quantum_product_1.RowLayout, { gutter: 1 }, data.map(function (datum, index) {
53
46
  var isActive = activeIndex !== undefined && activeIndex === index;
54
47
  var color = BASE_COLORS[index % BASE_COLORS.length];
55
48
  var mutedColor = MUTED_COLORS[index % MUTED_COLORS.length];
@@ -9,6 +9,7 @@ interface IDonutChartProps<DataType = unknown> extends IChartCardProps {
9
9
  displayType: 'absolute' | 'percent';
10
10
  layout?: 'horizontal' | 'vertical';
11
11
  color?: 'categorical' | 'sequential';
12
+ height?: number | string;
12
13
  }
13
14
  export declare function DonutChart(props: IDonutChartProps): JSX.Element;
14
15
  export {};
@@ -66,23 +66,23 @@ var ResponsiveChartCard = (0, quantum_product_1.styled)(quantum_product_1.StackL
66
66
  var theme = _a.theme, ownerState = _a.ownerState;
67
67
  return (__assign((_b = {}, _b[theme.breakpoints.down('sm')] = {
68
68
  flexDirection: 'column',
69
- }, _b.flexWrap = 'nowrap', _b.marginTop = theme.spacing(3), _b), (ownerState.layout === 'vertical' && {
69
+ }, _b.flexWrap = 'nowrap', _b.justifyContent = 'space-around', _b.height = 'calc(100% - 40px)', _b), (ownerState.layout === 'vertical' && {
70
70
  flexDirection: 'column',
71
71
  })));
72
72
  });
73
73
  function DonutChart(props) {
74
- var data = props.data, displayType = props.displayType, title = props.title, value = props.value, label = props.label, helperText = props.helperText, _a = props.layout, layout = _a === void 0 ? 'horizontal' : _a, _b = props.color, color = _b === void 0 ? 'categorical' : _b;
75
- var _c = __read(React.useState(undefined), 2), activeIndex = _c[0], setActiveIndex = _c[1];
74
+ var data = props.data, displayType = props.displayType, title = props.title, value = props.value, label = props.label, helperText = props.helperText, _a = props.layout, layout = _a === void 0 ? 'horizontal' : _a, _b = props.color, color = _b === void 0 ? 'categorical' : _b, _c = props.height, height = _c === void 0 ? '100%' : _c;
75
+ var _d = __read(React.useState(undefined), 2), activeIndex = _d[0], setActiveIndex = _d[1];
76
76
  var theme = (0, quantum_product_1.useTheme)();
77
77
  var BASE_COLORS = (0, theme_1.getColorScale)(theme)[color]['base'];
78
- return (React.createElement(chart_card_1.ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText },
78
+ return (React.createElement(chart_card_1.ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText, height: height },
79
79
  React.createElement(ResponsiveChartCard, { ownerState: { layout: layout } },
80
80
  React.createElement(quantum_product_1.StackLayoutItem, { sx: {
81
81
  height: '150px',
82
82
  width: '150px',
83
83
  } },
84
84
  React.createElement(recharts_1.ResponsiveContainer, { width: '100%', height: 150 },
85
- React.createElement(recharts_1.PieChart, { height: 150, width: 150 },
85
+ React.createElement(recharts_1.PieChart, { style: { minWidth: '150px', minHeight: '150px' } },
86
86
  React.createElement("foreignObject", { x: 0, y: 0, width: '100%', height: '100%' },
87
87
  React.createElement(center_1.default, { activeIndex: activeIndex, data: data, displayType: displayType })),
88
88
  React.createElement(recharts_1.Pie, { dataKey: 'value', data: data, innerRadius: 55, outerRadius: 75, paddingAngle: 2, animationDuration: 750, animationBegin: 0, activeIndex: activeIndex, onMouseEnter: function (_, index) {
@@ -80,7 +80,7 @@ export function BarChart(props) {
80
80
  React.createElement(ResponsiveContainer, { width: "100%", height: height }, data.length ? (React.createElement(RechartsBarChart, { width: 500, layout: layout === 'horizontal' ? 'vertical' : 'horizontal', height: height, data: Object.values(entries), margin: {
81
81
  top: 24,
82
82
  right: 10,
83
- left: layout === 'vertical' ? -24 : 16,
83
+ left: layout === 'vertical' ? -24 : 36,
84
84
  bottom: 0,
85
85
  } },
86
86
  React.createElement(CartesianGrid, { vertical: false, stroke: theme.tokens.color_border_default }),
@@ -91,15 +91,11 @@ export function BarChart(props) {
91
91
  dataKey: bottomAxisDataKey,
92
92
  }), { domain: ['auto', 'auto'], axisLine: { stroke: theme.tokens.color_border_bold }, tickLine: { stroke: theme.tokens.color_border_bold } })),
93
93
  React.createElement(Tooltip, { wrapperStyle: { outline: 'none' }, content: React.createElement(CustomTooltip, { active: undefined, payload: undefined, scaleType: bottomAxis.scaleType }) }),
94
- React.createElement(Legend, { align: "center", iconType: "square", iconSize: 14, wrapperStyle: { paddingTop: 16 }, content: React.createElement(CustomLegend, { selectData: selectBar, handleLegendMouseEnter: handleLegendMouseEnter, handleLegendMouseLeave: handleLegendMouseLeave, dataVisibility: barVisibility }) }),
94
+ React.createElement(Legend, { align: "center", content: React.createElement(CustomLegend, { selectData: selectBar, handleLegendMouseEnter: handleLegendMouseEnter, handleLegendMouseLeave: handleLegendMouseLeave, dataVisibility: barVisibility }) }),
95
95
  groups.map(function (group, index) {
96
96
  return (React.createElement(Bar, __assign({ key: group, dataKey: group }, (isStacked && { stackId: 'stack' }), { name: group, maxBarSize: 70, hide: barVisibility[group] === true, fill: barVisibility.hover === group || !barVisibility.hover
97
97
  ? getColorScale(theme)[color]['base'][index]
98
- : getColorScale(theme)[color]['muted'][index], radius: !isStacked || index == groups.length - 1
99
- ? layout === 'vertical'
100
- ? [4, 4, 0, 0]
101
- : [0, 4, 4, 0]
102
- : [0, 0, 0, 0] })));
98
+ : getColorScale(theme)[color]['muted'][index] })));
103
99
  }))) : (React.createElement("div", { style: {
104
100
  display: 'grid',
105
101
  placeItems: 'center',
@@ -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;
6
- return (React.createElement(Card, null,
5
+ var children = props.children, title = props.title, value = props.value, dataTable = props.dataTable, helperText = props.helperText, label = props.label, height = props.height;
6
+ return (React.createElement(Card, { sx: { height: height, padding: 3 } },
7
7
  React.createElement(ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label }),
8
8
  children));
9
9
  }
@@ -64,13 +64,13 @@ export function DataTableChart(props) {
64
64
  };
65
65
  return (React.createElement(Dialog, { open: isOpen, fullWidth: true, title: title, onClose: toggleIsOpen, actions: React.createElement(React.Fragment, null,
66
66
  React.createElement(Button, { color: "primary", variant: "contained", startIcon: React.createElement(DownloadIcon, null), onClick: function () { return downloadCSV(title); } }, "Download")) },
67
- React.createElement(Box, { p: 2 },
67
+ React.createElement(Box, null,
68
68
  React.createElement(Tabs, { baseId: 'example', onChange: setSelectedTab, value: selectedTab },
69
- React.createElement(TabList, { classes: { indicator: 'chromatic-ignore' } }, !isDonut &&
69
+ React.createElement(TabList, { classes: { indicator: 'chromatic-ignore' }, style: isDonut ? { display: 'none' } : { display: 'block' } }, !isDonut &&
70
70
  Object.keys(groups).map(function (group, index) {
71
71
  return React.createElement(Tab, { key: index, label: group, value: group });
72
72
  })),
73
- React.createElement(Box, { paddingY: 2 }, isDonut ? (React.createElement(DataTable, { items: data, columns: [
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
76
  var item = _a.item;
@@ -11,12 +11,8 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { StackLayout, Text, styled } from '@auth0/quantum-product';
13
13
  import * as React from 'react';
14
- var Root = styled(StackLayout)(function (_a) {
15
- var theme = _a.theme;
16
- return ({
17
- justifyContent: 'center',
18
- marginTop: theme.spacing(3),
19
- });
14
+ var Root = styled(StackLayout)({
15
+ justifyContent: 'center',
20
16
  });
21
17
  var LegendIcon = styled('div')(function (_a) {
22
18
  var theme = _a.theme, ownerState = _a.ownerState;
@@ -1,13 +1,6 @@
1
1
  import * as React from 'react';
2
- import { StackLayout, StackLayoutItem, styled, useTheme } from '@auth0/quantum-product';
2
+ import { StackLayout, StackLayoutItem, RowLayout, styled, useTheme } from '@auth0/quantum-product';
3
3
  import { getColorScale } from '../theme';
4
- var Root = styled('div')({
5
- display: 'flex',
6
- flexDirection: 'column',
7
- gap: '8px',
8
- height: '150px',
9
- flexWrap: 'wrap',
10
- });
11
4
  var LegendDot = styled('div')({
12
5
  height: '14px',
13
6
  width: '14px',
@@ -24,7 +17,7 @@ function DecoupledLegend(props) {
24
17
  var theme = useTheme();
25
18
  var BASE_COLORS = getColorScale(theme)[color]['base'];
26
19
  var MUTED_COLORS = getColorScale(theme)[color]['muted'];
27
- return (React.createElement(Root, null, data.map(function (datum, index) {
20
+ return (React.createElement(RowLayout, { gutter: 1 }, data.map(function (datum, index) {
28
21
  var isActive = activeIndex !== undefined && activeIndex === index;
29
22
  var color = BASE_COLORS[index % BASE_COLORS.length];
30
23
  var mutedColor = MUTED_COLORS[index % MUTED_COLORS.length];
@@ -37,23 +37,23 @@ var ResponsiveChartCard = styled(StackLayout)(function (_a) {
37
37
  var theme = _a.theme, ownerState = _a.ownerState;
38
38
  return (__assign((_b = {}, _b[theme.breakpoints.down('sm')] = {
39
39
  flexDirection: 'column',
40
- }, _b.flexWrap = 'nowrap', _b.marginTop = theme.spacing(3), _b), (ownerState.layout === 'vertical' && {
40
+ }, _b.flexWrap = 'nowrap', _b.justifyContent = 'space-around', _b.height = 'calc(100% - 40px)', _b), (ownerState.layout === 'vertical' && {
41
41
  flexDirection: 'column',
42
42
  })));
43
43
  });
44
44
  export function DonutChart(props) {
45
- var data = props.data, displayType = props.displayType, title = props.title, value = props.value, label = props.label, helperText = props.helperText, _a = props.layout, layout = _a === void 0 ? 'horizontal' : _a, _b = props.color, color = _b === void 0 ? 'categorical' : _b;
46
- var _c = __read(React.useState(undefined), 2), activeIndex = _c[0], setActiveIndex = _c[1];
45
+ var data = props.data, displayType = props.displayType, title = props.title, value = props.value, label = props.label, helperText = props.helperText, _a = props.layout, layout = _a === void 0 ? 'horizontal' : _a, _b = props.color, color = _b === void 0 ? 'categorical' : _b, _c = props.height, height = _c === void 0 ? '100%' : _c;
46
+ var _d = __read(React.useState(undefined), 2), activeIndex = _d[0], setActiveIndex = _d[1];
47
47
  var theme = useTheme();
48
48
  var BASE_COLORS = getColorScale(theme)[color]['base'];
49
- return (React.createElement(ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText },
49
+ return (React.createElement(ChartCard, { title: title, value: value, dataTable: data, label: label, helperText: helperText, height: height },
50
50
  React.createElement(ResponsiveChartCard, { ownerState: { layout: layout } },
51
51
  React.createElement(StackLayoutItem, { sx: {
52
52
  height: '150px',
53
53
  width: '150px',
54
54
  } },
55
55
  React.createElement(ResponsiveContainer, { width: '100%', height: 150 },
56
- React.createElement(RechartsPieChart, { height: 150, width: 150 },
56
+ React.createElement(RechartsPieChart, { style: { minWidth: '150px', minHeight: '150px' } },
57
57
  React.createElement("foreignObject", { x: 0, y: 0, width: '100%', height: '100%' },
58
58
  React.createElement(Center, { activeIndex: activeIndex, data: data, displayType: displayType })),
59
59
  React.createElement(Pie, { dataKey: 'value', data: data, innerRadius: 55, outerRadius: 75, paddingAngle: 2, animationDuration: 750, animationBegin: 0, activeIndex: activeIndex, onMouseEnter: function (_, index) {
@@ -1,12 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import { ChartSummary } from '../chart-summary';
3
3
  import { ChartCard } from '../chart-card';
4
- import { GalleryLayout, GalleryLayoutItem } from '@auth0/quantum-product';
4
+ import { StackLayout, StackLayoutItem } from '@auth0/quantum-product';
5
5
  export function ScoreCard(props) {
6
6
  var data = props.data;
7
7
  return (React.createElement(ChartCard, null,
8
- React.createElement(GalleryLayout, null, data.map(function (summary, index) {
9
- return (React.createElement(GalleryLayoutItem, { key: index },
8
+ React.createElement(StackLayout, { sx: {
9
+ justifyContent: 'space-between',
10
+ alignContent: ['initial', 'center'],
11
+ alignItems: ['initial', 'center'],
12
+ flexWrap: 'wrap',
13
+ flexDirection: ['column', 'row'],
14
+ } }, data.map(function (summary, index) {
15
+ return (React.createElement(StackLayoutItem, { key: index, sx: { flex: 1, mr: 2 } },
10
16
  React.createElement(ChartSummary, { title: summary.title, value: summary.value, helperText: summary.helperText, label: summary.label })));
11
17
  }))));
12
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth0/quantum-charts",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "sideEffects": false,
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -31,8 +31,14 @@ var quantum_product_1 = require("@auth0/quantum-product");
31
31
  function ScoreCard(props) {
32
32
  var data = props.data;
33
33
  return (React.createElement(chart_card_1.ChartCard, null,
34
- React.createElement(quantum_product_1.GalleryLayout, null, data.map(function (summary, index) {
35
- return (React.createElement(quantum_product_1.GalleryLayoutItem, { key: index },
34
+ React.createElement(quantum_product_1.StackLayout, { sx: {
35
+ justifyContent: 'space-between',
36
+ alignContent: ['initial', 'center'],
37
+ alignItems: ['initial', 'center'],
38
+ flexWrap: 'wrap',
39
+ flexDirection: ['column', 'row'],
40
+ } }, data.map(function (summary, index) {
41
+ return (React.createElement(quantum_product_1.StackLayoutItem, { key: index, sx: { flex: 1, mr: 2 } },
36
42
  React.createElement(chart_summary_1.ChartSummary, { title: summary.title, value: summary.value, helperText: summary.helperText, label: summary.label })));
37
43
  }))));
38
44
  }