@auth0/quantum-charts 0.1.0 → 0.1.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.
@@ -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 }),
@@ -124,11 +124,7 @@ function BarChart(props) {
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 } },
33
33
  React.createElement(chart_summary_1.ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label }),
34
34
  children));
35
35
  }
@@ -5,6 +5,7 @@ export declare type IDecoupledLegendProps<DataType = unknown> = {
5
5
  activeIndex?: number;
6
6
  setActiveIndex: (index: number | undefined) => void;
7
7
  color?: 'categorical' | 'sequential';
8
+ layout?: 'horizontal' | 'vertical';
8
9
  };
9
10
  declare function DecoupledLegend<DataType = unknown>(props: IDecoupledLegendProps<DataType>): JSX.Element;
10
11
  export default DecoupledLegend;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
14
  if (k2 === undefined) k2 = k;
4
15
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,12 +37,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
37
  var React = __importStar(require("react"));
27
38
  var quantum_product_1 = require("@auth0/quantum-product");
28
39
  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',
40
+ var Root = (0, quantum_product_1.styled)('div')(function (_a) {
41
+ var _b;
42
+ var theme = _a.theme, ownerState = _a.ownerState;
43
+ return (__assign((_b = { display: 'flex', flexDirection: 'column' }, _b[theme.breakpoints.down('sm')] = {
44
+ flexDirection: 'row',
45
+ justifyContent: 'center',
46
+ gap: theme.spacing(2),
47
+ maxWidth: '300px',
48
+ flexWrap: 'wrap',
49
+ }, _b), (ownerState.layout === 'vertical' && {
50
+ flexDirection: 'row',
51
+ justifyContent: 'center',
52
+ gap: theme.spacing(2),
53
+ maxWidth: '300px',
54
+ flexWrap: 'wrap',
55
+ })));
35
56
  });
36
57
  var LegendDot = (0, quantum_product_1.styled)('div')({
37
58
  height: '14px',
@@ -45,11 +66,11 @@ var LegendText = (0, quantum_product_1.styled)('span')({
45
66
  cursor: 'default',
46
67
  });
47
68
  function DecoupledLegend(props) {
48
- var data = props.data, activeIndex = props.activeIndex, setActiveIndex = props.setActiveIndex, _a = props.color, color = _a === void 0 ? 'categorical' : _a;
69
+ var data = props.data, activeIndex = props.activeIndex, setActiveIndex = props.setActiveIndex, _a = props.color, color = _a === void 0 ? 'categorical' : _a, _b = props.layout, layout = _b === void 0 ? 'horizontal' : _b;
49
70
  var theme = (0, quantum_product_1.useTheme)();
50
71
  var BASE_COLORS = (0, theme_1.getColorScale)(theme)[color]['base'];
51
72
  var MUTED_COLORS = (0, theme_1.getColorScale)(theme)[color]['muted'];
52
- return (React.createElement(Root, null, data.map(function (datum, index) {
73
+ return (React.createElement(Root, { ownerState: { layout: layout } }, data.map(function (datum, index) {
53
74
  var isActive = activeIndex !== undefined && activeIndex === index;
54
75
  var color = BASE_COLORS[index % BASE_COLORS.length];
55
76
  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.paddingTop = theme.spacing(3), _b.paddingBottom = theme.spacing(4), _b.height = 'calc(100% - 44px)', _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) {
@@ -93,6 +93,6 @@ function DonutChart(props) {
93
93
  return (React.createElement(recharts_1.Cell, { key: "cell-".concat(index), fill: BASE_COLORS[index % BASE_COLORS.length], opacity: activeIndex === undefined ? 1 : activeIndex === index ? 1 : 0.5 }));
94
94
  }))))),
95
95
  React.createElement(quantum_product_1.StackLayoutItem, null,
96
- React.createElement(decoupled_legend_1.default, { activeIndex: activeIndex, setActiveIndex: setActiveIndex, data: data, color: color })))));
96
+ React.createElement(decoupled_legend_1.default, { activeIndex: activeIndex, setActiveIndex: setActiveIndex, data: data, color: color, layout: layout })))));
97
97
  }
98
98
  exports.DonutChart = DonutChart;
@@ -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 }),
@@ -95,11 +95,7 @@ export function BarChart(props) {
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 } },
7
7
  React.createElement(ChartSummary, { title: title, value: value, dataTable: dataTable, helperText: helperText, label: label }),
8
8
  children));
9
9
  }
@@ -1,12 +1,33 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import * as React from 'react';
2
13
  import { StackLayout, StackLayoutItem, styled, useTheme } from '@auth0/quantum-product';
3
14
  import { getColorScale } from '../theme';
4
- var Root = styled('div')({
5
- display: 'flex',
6
- flexDirection: 'column',
7
- gap: '8px',
8
- height: '150px',
9
- flexWrap: 'wrap',
15
+ var Root = styled('div')(function (_a) {
16
+ var _b;
17
+ var theme = _a.theme, ownerState = _a.ownerState;
18
+ return (__assign((_b = { display: 'flex', flexDirection: 'column' }, _b[theme.breakpoints.down('sm')] = {
19
+ flexDirection: 'row',
20
+ justifyContent: 'center',
21
+ gap: theme.spacing(2),
22
+ maxWidth: '300px',
23
+ flexWrap: 'wrap',
24
+ }, _b), (ownerState.layout === 'vertical' && {
25
+ flexDirection: 'row',
26
+ justifyContent: 'center',
27
+ gap: theme.spacing(2),
28
+ maxWidth: '300px',
29
+ flexWrap: 'wrap',
30
+ })));
10
31
  });
11
32
  var LegendDot = styled('div')({
12
33
  height: '14px',
@@ -20,11 +41,11 @@ var LegendText = styled('span')({
20
41
  cursor: 'default',
21
42
  });
22
43
  function DecoupledLegend(props) {
23
- var data = props.data, activeIndex = props.activeIndex, setActiveIndex = props.setActiveIndex, _a = props.color, color = _a === void 0 ? 'categorical' : _a;
44
+ var data = props.data, activeIndex = props.activeIndex, setActiveIndex = props.setActiveIndex, _a = props.color, color = _a === void 0 ? 'categorical' : _a, _b = props.layout, layout = _b === void 0 ? 'horizontal' : _b;
24
45
  var theme = useTheme();
25
46
  var BASE_COLORS = getColorScale(theme)[color]['base'];
26
47
  var MUTED_COLORS = getColorScale(theme)[color]['muted'];
27
- return (React.createElement(Root, null, data.map(function (datum, index) {
48
+ return (React.createElement(Root, { ownerState: { layout: layout } }, data.map(function (datum, index) {
28
49
  var isActive = activeIndex !== undefined && activeIndex === index;
29
50
  var color = BASE_COLORS[index % BASE_COLORS.length];
30
51
  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.paddingTop = theme.spacing(3), _b.paddingBottom = theme.spacing(4), _b.height = 'calc(100% - 44px)', _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) {
@@ -64,5 +64,5 @@ export function DonutChart(props) {
64
64
  return (React.createElement(Cell, { key: "cell-".concat(index), fill: BASE_COLORS[index % BASE_COLORS.length], opacity: activeIndex === undefined ? 1 : activeIndex === index ? 1 : 0.5 }));
65
65
  }))))),
66
66
  React.createElement(StackLayoutItem, null,
67
- React.createElement(DecoupledLegend, { activeIndex: activeIndex, setActiveIndex: setActiveIndex, data: data, color: color })))));
67
+ React.createElement(DecoupledLegend, { activeIndex: activeIndex, setActiveIndex: setActiveIndex, data: data, color: color, layout: layout })))));
68
68
  }
@@ -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.1",
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
  }