@auth0/quantum-charts 0.0.4 → 0.1.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 (37) hide show
  1. package/README.md +1 -1
  2. package/bar-chart/index.js +46 -21
  3. package/chart-summary/data-table-chart.d.ts +2 -2
  4. package/chart-summary/data-table-chart.js +46 -4
  5. package/chart-summary/index.d.ts +1 -1
  6. package/common/chart.d.ts +6 -0
  7. package/common/chart.js +30 -0
  8. package/common/custom-legend.d.ts +2 -0
  9. package/common/custom-legend.js +69 -0
  10. package/common/custom-tooltip.d.ts +4 -0
  11. package/common/custom-tooltip.js +54 -0
  12. package/donut-chart/decoupled-legend.d.ts +1 -0
  13. package/donut-chart/decoupled-legend.js +24 -22
  14. package/donut-chart/index.d.ts +2 -0
  15. package/donut-chart/index.js +25 -9
  16. package/esm/bar-chart/index.js +47 -22
  17. package/esm/chart-summary/data-table-chart.js +47 -5
  18. package/esm/common/chart.js +28 -1
  19. package/esm/common/custom-legend.js +42 -0
  20. package/esm/common/custom-tooltip.js +26 -0
  21. package/esm/donut-chart/decoupled-legend.js +26 -21
  22. package/esm/donut-chart/index.js +27 -11
  23. package/esm/line-chart/index.js +56 -18
  24. package/esm/styles.js +11 -11
  25. package/esm/theme.js +37 -21
  26. package/line-chart/index.js +55 -17
  27. package/package.json +14 -12
  28. package/styles.d.ts +3 -4
  29. package/styles.js +11 -14
  30. package/theme.d.ts +10 -2
  31. package/theme.js +39 -24
  32. package/esm/line-chart/custom-tooltip.js +0 -20
  33. package/line-chart/custom-tooltip.d.ts +0 -6
  34. package/line-chart/custom-tooltip.js +0 -48
  35. /package/{custom-color-status-dot.d.ts → common/custom-color-status-dot.d.ts} +0 -0
  36. /package/{custom-color-status-dot.js → common/custom-color-status-dot.js} +0 -0
  37. /package/esm/{custom-color-status-dot.js → common/custom-color-status-dot.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth0/quantum-charts",
3
- "version": "0.0.4",
3
+ "version": "0.1.0",
4
4
  "sideEffects": false,
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -29,22 +29,24 @@
29
29
  "build": "yarn clean && yarn build:cjs && yarn build:esm && yarn copy:files",
30
30
  "clean": "rm -rf ./build",
31
31
  "watch": "tsc --watch --project ./tsconfig.publish.esm.json & tsc --watch --project ./tsconfig.publish.json",
32
- "build:cjs": "tsc --project ./tsconfig.publish.json",
33
- "build:esm": "tsc --project ./tsconfig.publish.esm.json",
32
+ "build:cjs": "node --max-old-space-size=4096 ../../node_modules/.bin/tsc --project ./tsconfig.publish.json",
33
+ "build:esm": "node --max-old-space-size=4096 ../../node_modules/.bin/tsc --project ./tsconfig.publish.esm.json",
34
34
  "copy:files": "node scripts/copy-files.js",
35
35
  "artifactory": "cd ./build && npm publish",
36
- "storybook": "start-storybook -p 6006"
36
+ "storybook": "storybook dev -p 6006"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "^7.14.6",
40
- "@storybook/addon-actions": "6.5.10",
41
- "@storybook/addon-essentials": "6.5.10",
42
- "@storybook/addon-links": "6.5.10",
43
- "@storybook/react": "6.5.10",
44
- "@storybook/theming": "6.5.10",
39
+ "@babel/core": "^7.22.10",
40
+ "@storybook/addon-actions": "^7.3.2",
41
+ "@storybook/addon-essentials": "^7.3.2",
42
+ "@storybook/addon-links": "^7.3.2",
43
+ "@storybook/react": "^7.3.2",
44
+ "@storybook/react-webpack5": "7.3.2",
45
+ "@storybook/theming": "^7.3.2",
45
46
  "@types/md5": "^2.3.2",
46
- "@types/node": "12.12.47",
47
- "babel-loader": "^8.2.2"
47
+ "@types/node": "^18.16.19",
48
+ "babel-loader": "^9.1.3",
49
+ "storybook": "7.3.2"
48
50
  },
49
51
  "module": "./esm/index.js"
50
52
  }
package/styles.d.ts CHANGED
@@ -2,7 +2,6 @@ export declare type IChartContainerProps = {
2
2
  height?: number | 'initial';
3
3
  marginTop?: number;
4
4
  };
5
- export declare const ChartContainer: import("styled-components").StyledComponent<"div", any, IChartContainerProps, never>;
6
- export declare const CustomTooltip: import("styled-components").StyledComponent<"div", any, {}, never>;
7
- export declare const CustomTooltipLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
8
- export declare const DefaultCursorBox: import("styled-components").StyledComponent<import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").BoxTypeMap<{}, "div">>, any, {}, never>;
5
+ export declare const ChartContainer: import("styled-components").StyledComponent<"div", import("@auth0/quantum-product").ITheme, import("@mui/system").MUIStyledCommonProps<import("@auth0/quantum-product").ITheme> & IChartContainerProps, never>;
6
+ export declare const CustomTooltip: import("styled-components").StyledComponent<"div", import("@auth0/quantum-product").ITheme, import("@mui/system").MUIStyledCommonProps<import("@auth0/quantum-product").ITheme>, never>;
7
+ export declare const DefaultCursorBox: import("styled-components").StyledComponent<import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").BoxTypeMap<{}, "div">>, import("@auth0/quantum-product").ITheme, import("@mui/system").MUIStyledCommonProps<import("@auth0/quantum-product").ITheme>, never>;
package/styles.js CHANGED
@@ -3,14 +3,10 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
4
  return cooked;
5
5
  };
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
6
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.DefaultCursorBox = exports.CustomTooltipLabel = exports.CustomTooltip = exports.ChartContainer = void 0;
11
- var styled_components_1 = __importDefault(require("styled-components"));
7
+ exports.DefaultCursorBox = exports.CustomTooltip = exports.ChartContainer = void 0;
12
8
  var quantum_product_1 = require("@auth0/quantum-product");
13
- exports.ChartContainer = styled_components_1.default.div(function (_a) {
9
+ exports.ChartContainer = (0, quantum_product_1.styled)('div')(function (_a) {
14
10
  var theme = _a.theme, height = _a.height, marginTop = _a.marginTop;
15
11
  var props = {
16
12
  marginTop: theme.spacing(3),
@@ -24,20 +20,21 @@ exports.ChartContainer = styled_components_1.default.div(function (_a) {
24
20
  }
25
21
  return props;
26
22
  });
27
- exports.CustomTooltip = styled_components_1.default.div(function (_a) {
23
+ exports.CustomTooltip = (0, quantum_product_1.styled)('div')(function (_a) {
28
24
  var theme = _a.theme;
29
25
  return ({
30
- backgroundColor: theme.tokens.color_bg_layer_boldest,
26
+ display: 'grid',
27
+ gap: theme.spacing(1),
28
+ backgroundColor: theme.tokens.color_bg_layer_elevated,
29
+ border: "1px solid ".concat(theme.tokens.color_border_bold),
31
30
  borderRadius: theme.shape.borderRadius,
32
- padding: theme.spacing(1, 3),
33
- color: theme.tokens.color_fg_inverse,
31
+ padding: theme.spacing(1, 2),
32
+ color: theme.tokens.color_fg_bold,
34
33
  fontSize: theme.typography.caption.fontSize,
35
34
  fontWeight: theme.typography.caption.fontWeight,
36
35
  lineHeight: theme.typography.caption.lineHeight,
37
36
  letterSpacing: theme.typography.caption.letterSpacing,
38
37
  });
39
38
  });
40
- // `textSecondary` doesn't have enough contrast for the black background of the tooltip
41
- exports.CustomTooltipLabel = styled_components_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: lightgrey;\n"], ["\n color: lightgrey;\n"])));
42
- exports.DefaultCursorBox = (0, styled_components_1.default)(quantum_product_1.Box)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n cursor: default;\n"], ["\n cursor: default;\n"])));
43
- var templateObject_1, templateObject_2;
39
+ exports.DefaultCursorBox = (0, quantum_product_1.styled)(quantum_product_1.Box)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n cursor: default;\n"], ["\n cursor: default;\n"])));
40
+ var templateObject_1;
package/theme.d.ts CHANGED
@@ -1,3 +1,11 @@
1
1
  import { ITheme } from '@auth0/quantum-product';
2
- export declare const getBaseColorScale: ({ palette }: ITheme) => string[];
3
- export declare const getBaseColorScaleMuted: ({ palette }: ITheme) => string[];
2
+ export declare const getColorScale: ({ tokens }: ITheme) => {
3
+ categorical: {
4
+ base: string[];
5
+ muted: string[];
6
+ };
7
+ sequential: {
8
+ base: string[];
9
+ muted: string[];
10
+ };
11
+ };
package/theme.js CHANGED
@@ -1,27 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBaseColorScaleMuted = exports.getBaseColorScale = void 0;
4
- var getBaseColorScale = function (_a) {
5
- var palette = _a.palette;
6
- return [
7
- palette.purple[500],
8
- palette.magenta[500],
9
- palette.green[500],
10
- palette.yellow[500],
11
- palette.red[500],
12
- palette.neutral[500],
13
- ];
3
+ exports.getColorScale = void 0;
4
+ var quantum_product_1 = require("@auth0/quantum-product");
5
+ var getColorScale = function (_a) {
6
+ var tokens = _a.tokens;
7
+ return {
8
+ categorical: {
9
+ base: [
10
+ tokens.color_chart_categorical_1,
11
+ tokens.color_chart_categorical_2,
12
+ tokens.color_chart_categorical_3,
13
+ tokens.color_chart_categorical_4,
14
+ tokens.color_chart_categorical_5,
15
+ tokens.color_chart_categorical_6,
16
+ ],
17
+ muted: [
18
+ (0, quantum_product_1.alpha)(tokens.color_chart_categorical_1, 0.35),
19
+ (0, quantum_product_1.alpha)(tokens.color_chart_categorical_2, 0.35),
20
+ (0, quantum_product_1.alpha)(tokens.color_chart_categorical_3, 0.35),
21
+ (0, quantum_product_1.alpha)(tokens.color_chart_categorical_4, 0.35),
22
+ (0, quantum_product_1.alpha)(tokens.color_chart_categorical_5, 0.35),
23
+ (0, quantum_product_1.alpha)(tokens.color_chart_categorical_6, 0.35),
24
+ ],
25
+ },
26
+ sequential: {
27
+ base: [
28
+ tokens.color_chart_sequential_1,
29
+ tokens.color_chart_sequential_2,
30
+ tokens.color_chart_sequential_3,
31
+ tokens.color_chart_sequential_4,
32
+ ],
33
+ muted: [
34
+ (0, quantum_product_1.alpha)(tokens.color_chart_sequential_1, 0.35),
35
+ (0, quantum_product_1.alpha)(tokens.color_chart_sequential_2, 0.35),
36
+ (0, quantum_product_1.alpha)(tokens.color_chart_sequential_3, 0.35),
37
+ (0, quantum_product_1.alpha)(tokens.color_chart_sequential_4, 0.35),
38
+ ],
39
+ },
40
+ };
14
41
  };
15
- exports.getBaseColorScale = getBaseColorScale;
16
- var getBaseColorScaleMuted = function (_a) {
17
- var palette = _a.palette;
18
- return [
19
- palette.purple[300],
20
- palette.yellow[300],
21
- palette.green[300],
22
- palette.red[300],
23
- palette.neutral[300],
24
- palette.magenta[300],
25
- ];
26
- };
27
- exports.getBaseColorScaleMuted = getBaseColorScaleMuted;
42
+ exports.getColorScale = getColorScale;
@@ -1,20 +0,0 @@
1
- import * as React from 'react';
2
- import { Box, RowLayout } from '@auth0/quantum-product';
3
- import StatusDot from '../custom-color-status-dot';
4
- import { format } from 'date-fns';
5
- import { CustomTooltip as CustomTooltipStyled, CustomTooltipLabel } from '../styles';
6
- // -------------------------------- Component --------------------------------
7
- var CustomTooltip = function (_a) {
8
- var _b;
9
- var active = _a.active, payload = _a.payload;
10
- if (!active || !payload.length) {
11
- return null;
12
- }
13
- return (React.createElement(CustomTooltipStyled, null,
14
- React.createElement(CustomTooltipLabel, null, "".concat(format(new Date(payload && ((_b = payload[0].payload) === null || _b === void 0 ? void 0 : _b.date)), 'LLL d p'))),
15
- React.createElement(Box, null,
16
- React.createElement(RowLayout, { gutter: 1 }, payload.map(function (x, index) {
17
- return React.createElement(StatusDot, { key: index, dotColor: 'grey', label: "".concat(x.name, ": ").concat(x.payload[x.name]) });
18
- })))));
19
- };
20
- export default CustomTooltip;
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- declare const CustomTooltip: ({ active, payload }: {
3
- active: any;
4
- payload: any;
5
- }) => JSX.Element | null;
6
- export default CustomTooltip;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- var React = __importStar(require("react"));
30
- var quantum_product_1 = require("@auth0/quantum-product");
31
- var custom_color_status_dot_1 = __importDefault(require("../custom-color-status-dot"));
32
- var date_fns_1 = require("date-fns");
33
- var styles_1 = require("../styles");
34
- // -------------------------------- Component --------------------------------
35
- var CustomTooltip = function (_a) {
36
- var _b;
37
- var active = _a.active, payload = _a.payload;
38
- if (!active || !payload.length) {
39
- return null;
40
- }
41
- return (React.createElement(styles_1.CustomTooltip, null,
42
- React.createElement(styles_1.CustomTooltipLabel, null, "".concat((0, date_fns_1.format)(new Date(payload && ((_b = payload[0].payload) === null || _b === void 0 ? void 0 : _b.date)), 'LLL d p'))),
43
- React.createElement(quantum_product_1.Box, null,
44
- React.createElement(quantum_product_1.RowLayout, { gutter: 1 }, payload.map(function (x, index) {
45
- return React.createElement(custom_color_status_dot_1.default, { key: index, dotColor: 'grey', label: "".concat(x.name, ": ").concat(x.payload[x.name]) });
46
- })))));
47
- };
48
- exports.default = CustomTooltip;