sag_components 1.0.249 → 1.0.251
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.
- package/.eslintrc.js +30 -0
- package/.history/.env_20231001120549 +0 -0
- package/.history/.env_20231001120613 +1 -0
- package/.history/.env_20231003143620 +1 -0
- package/.history/.eslintrc_20230928112617.js +26 -0
- package/.history/.eslintrc_20230928130534.js +27 -0
- package/.history/.eslintrc_20230928133400.js +28 -0
- package/.history/.eslintrc_20230928133404.js +28 -0
- package/.history/.eslintrc_20230928133416.js +28 -0
- package/.history/.eslintrc_20230928133419.js +28 -0
- package/.history/.eslintrc_20230928133432.js +28 -0
- package/.history/.eslintrc_20230928133439.js +28 -0
- package/.history/.eslintrc_20230928133458.js +29 -0
- package/.history/.eslintrc_20230928133500.js +28 -0
- package/.history/.eslintrc_20230928134009.js +28 -0
- package/.history/.eslintrc_20230928135318.js +34 -0
- package/.history/.eslintrc_20230928135321.js +34 -0
- package/.history/.eslintrc_20230928135323.js +34 -0
- package/.history/.eslintrc_20230928135332.js +34 -0
- package/.history/.eslintrc_20230928135333.js +34 -0
- package/.history/.eslintrc_20230928135352.js +29 -0
- package/.history/.eslintrc_20230928135353.js +29 -0
- package/.history/.eslintrc_20230928135355.js +29 -0
- package/.history/.eslintrc_20230928135408.js +29 -0
- package/.history/.eslintrc_20230928135538.js +30 -0
- package/.history/.eslintrc_20230928135539.js +30 -0
- package/.history/.eslintrc_20230928135543.js +30 -0
- package/.history/.gitignore_20230921093332 +119 -0
- package/.history/.gitignore_20230921111638 +120 -0
- package/.history/.gitignore_20230921111650 +120 -0
- package/.history/.gitignore_20230921111810 +121 -0
- package/.history/package_20230928095230.json +74 -0
- package/.history/package_20230928112303.json +75 -0
- package/.history/package_20230928131946.json +80 -0
- package/.history/package_20230928131950.json +81 -0
- package/.history/package_20230928131953.json +80 -0
- package/.history/package_20230928131956.json +81 -0
- package/.history/package_20230928131959.json +80 -0
- package/.history/package_20230928132003.json +81 -0
- package/.history/package_20230928132004.json +81 -0
- package/.history/package_20230928134639.json +80 -0
- package/.history/package_20230928134643.json +81 -0
- package/.history/package_20230928134645.json +81 -0
- package/.history/package_20230928134650.json +81 -0
- package/.history/package_20230928134912.json +81 -0
- package/.history/package_20230928174159.json +81 -0
- package/.history/package_20230928174200.json +81 -0
- package/.history/package_20230928174202.json +81 -0
- package/.history/package_20230928174226.json +81 -0
- package/.history/package_20230928174227.json +81 -0
- package/.history/package_20230928174228.json +81 -0
- package/.history/package_20230928174318.json +81 -0
- package/.history/package_20230928174320.json +81 -0
- package/.history/package_20231001121933.json +82 -0
- package/.history/package_20231001131144.json +82 -0
- package/.history/package_20231001134252.json +81 -0
- package/.history/package_20231004111340.json +82 -0
- package/.history/package_20231004111550.json +82 -0
- package/dist/stories/components/CommonFunctions.js +14 -14
- package/dist/stories/components/TotalDoughnutChart.js +99 -81
- package/dist/stories/components/TotalDoughnutChart.style.js +20 -22
- package/package.json +26 -18
- package/dist/stories/components/InfoIcon.js +0 -38
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sag_components",
|
|
3
|
+
"version": "1.0.251",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "react-scripts start",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"build": "cross-env BABEL_ENV=production babel src -d dist ",
|
|
10
|
+
"storybook": "storybook dev -p 6006",
|
|
11
|
+
"build-storybook": "storybook build"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "SAG",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@babel/cli": "^7.21.5",
|
|
18
|
+
"@babel/preset-env": "^7.21.4",
|
|
19
|
+
"@babel/preset-react": "^7.18.6",
|
|
20
|
+
"@babel/preset-typescript": "^7.21.4",
|
|
21
|
+
"@storybook/addon-a11y": "^7.4.5",
|
|
22
|
+
"@storybook/addon-essentials": "^7.4.5",
|
|
23
|
+
"@storybook/addon-interactions": "^7.4.5",
|
|
24
|
+
"@storybook/addon-links": "^7.4.5",
|
|
25
|
+
"@storybook/addon-storysource": "^7.4.5",
|
|
26
|
+
"@storybook/blocks": "^7.4.5",
|
|
27
|
+
"@storybook/preset-scss": "^1.0.3",
|
|
28
|
+
"@storybook/react": "^7.4.5",
|
|
29
|
+
"@storybook/react-webpack5": "^7.4.5",
|
|
30
|
+
"@storybook/testing-library": "^0.2.1",
|
|
31
|
+
"cross-env": "^7.0.3",
|
|
32
|
+
"css-loader": "^5.2.7",
|
|
33
|
+
"eslint": "^8.50.0",
|
|
34
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
35
|
+
"eslint-plugin-import": "^2.28.1",
|
|
36
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
37
|
+
"eslint-plugin-react": "^7.33.2",
|
|
38
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
39
|
+
"react-dom": "^18.2.0",
|
|
40
|
+
"sass": "^1.68.0",
|
|
41
|
+
"sass-loader": "^13.3.2",
|
|
42
|
+
"style-loader": "^3.3.3"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@dnd-kit/core": "^6.0.8",
|
|
46
|
+
"@emotion/react": "^11.11.0",
|
|
47
|
+
"@emotion/styled": "^11.11.0",
|
|
48
|
+
"@fontsource/roboto": "^4.5.8",
|
|
49
|
+
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
50
|
+
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
|
51
|
+
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
52
|
+
"@mui/icons-material": "^5.11.16",
|
|
53
|
+
"@mui/material": "^5.13.0",
|
|
54
|
+
"@mui/styled-engine-sc": "^5.12.0",
|
|
55
|
+
"@mui/x-date-pickers": "^6.11.1",
|
|
56
|
+
"@storybook/addon-designs": "^7.0.5",
|
|
57
|
+
"babel-plugin-react-css-modules": "^5.2.6",
|
|
58
|
+
"classnames": "^2.3.2",
|
|
59
|
+
"dayjs": "^1.11.9",
|
|
60
|
+
"hoopy": "^0.1.4",
|
|
61
|
+
"prop-types": "^15.8.1",
|
|
62
|
+
"react": "^18.2.0",
|
|
63
|
+
"react-css-modules": "^4.7.11",
|
|
64
|
+
"react-loading-skeleton": "^3.3.1",
|
|
65
|
+
"react-scripts": "5.0.1",
|
|
66
|
+
"recharts": "^2.6.2",
|
|
67
|
+
"storybook": "^7.4.5",
|
|
68
|
+
"styled-components": "^5.3.11"
|
|
69
|
+
},
|
|
70
|
+
"browserslist": {
|
|
71
|
+
"production": [
|
|
72
|
+
">0.2%",
|
|
73
|
+
"not dead",
|
|
74
|
+
"not op_mini all"
|
|
75
|
+
],
|
|
76
|
+
"development": [
|
|
77
|
+
"last 1 chrome version",
|
|
78
|
+
"last 1 firefox version",
|
|
79
|
+
"last 1 safari version"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getNumberWithCommas = exports.getFormattedValue = exports.getFormattedUnits = exports.getCurrencySign = void 0;
|
|
7
7
|
var getCurrencySign = function getCurrencySign(currencyTypeToConvert, value) {
|
|
8
|
-
if (!currencyTypeToConvert) return
|
|
9
|
-
var currencySign =
|
|
10
|
-
var currencyFormatter = new Intl.NumberFormat(
|
|
11
|
-
style:
|
|
8
|
+
if (!currencyTypeToConvert) return '';
|
|
9
|
+
var currencySign = '';
|
|
10
|
+
var currencyFormatter = new Intl.NumberFormat('en-US', {
|
|
11
|
+
style: 'currency',
|
|
12
12
|
currency: currencyTypeToConvert
|
|
13
13
|
});
|
|
14
14
|
currencySign = currencyFormatter.format(Math.abs(value)).substring(0, 1);
|
|
@@ -17,34 +17,34 @@ var getCurrencySign = function getCurrencySign(currencyTypeToConvert, value) {
|
|
|
17
17
|
exports.getCurrencySign = getCurrencySign;
|
|
18
18
|
var getFormattedUnits = function getFormattedUnits(num) {
|
|
19
19
|
if (Math.abs(num) >= 1000000000) {
|
|
20
|
-
return
|
|
20
|
+
return 'B';
|
|
21
21
|
}
|
|
22
22
|
if (Math.abs(num) >= 1000000) {
|
|
23
|
-
return
|
|
23
|
+
return 'M';
|
|
24
24
|
}
|
|
25
25
|
if (Math.abs(num) >= 1000) {
|
|
26
|
-
return
|
|
26
|
+
return 'K';
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return '';
|
|
29
29
|
};
|
|
30
30
|
exports.getFormattedUnits = getFormattedUnits;
|
|
31
31
|
var getFormattedValue = function getFormattedValue(num) {
|
|
32
32
|
if (Math.abs(num) >= 1000000000) {
|
|
33
|
-
return (num / 1000000000).toFixed(1).replace(/\.0$/,
|
|
33
|
+
return (num / 1000000000).toFixed(1).replace(/\.0$/, '');
|
|
34
34
|
}
|
|
35
35
|
if (Math.abs(num) >= 1000000) {
|
|
36
|
-
return (num / 1000000).toFixed(1).replace(/\.0$/,
|
|
36
|
+
return (num / 1000000).toFixed(1).replace(/\.0$/, '');
|
|
37
37
|
}
|
|
38
38
|
if (Math.abs(num) >= 1000) {
|
|
39
|
-
return (num / 1000).toFixed(1).replace(/\.0$/,
|
|
39
|
+
return (num / 1000).toFixed(1).replace(/\.0$/, '');
|
|
40
40
|
}
|
|
41
41
|
return num;
|
|
42
42
|
};
|
|
43
43
|
exports.getFormattedValue = getFormattedValue;
|
|
44
44
|
var getNumberWithCommas = function getNumberWithCommas(x) {
|
|
45
|
-
|
|
45
|
+
var param = x.toString();
|
|
46
46
|
var pattern = /(-?\d+)(\d{3})/;
|
|
47
|
-
while (pattern.test(
|
|
48
|
-
return
|
|
47
|
+
while (pattern.test(param)) param = param.replace(pattern, '$1,$2');
|
|
48
|
+
return param;
|
|
49
49
|
};
|
|
50
50
|
exports.getNumberWithCommas = getNumberWithCommas;
|
|
@@ -1,136 +1,154 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.TotalDoughnutChart = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
10
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
11
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _recharts = require("recharts");
|
|
12
12
|
var _NoDataFoundMessage = require("./NoDataFoundMessage");
|
|
13
13
|
var _CommonFunctions = require("./CommonFunctions");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
height = _ref$height === void 0 ? "280px" : _ref$height,
|
|
34
|
-
_ref$textColor = _ref.textColor,
|
|
35
|
-
textColor = _ref$textColor === void 0 ? "#212121" : _ref$textColor,
|
|
36
|
-
_ref$noDataText = _ref.noDataText,
|
|
37
|
-
noDataText = _ref$noDataText === void 0 ? "" : _ref$noDataText,
|
|
38
|
-
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
39
|
-
var DEFAULT_ROOT_FONT = 16;
|
|
14
|
+
var _TotalDoughnutChart = require("./TotalDoughnutChart.style");
|
|
15
|
+
var _Benchmark = require("./Benchmark");
|
|
16
|
+
/* TotalDoughnutChart */
|
|
17
|
+
var TotalDoughnutChart = function TotalDoughnutChart(props) {
|
|
18
|
+
var title = props.title,
|
|
19
|
+
value = props.value,
|
|
20
|
+
addingBenchmark = props.addingBenchmark,
|
|
21
|
+
dotCut = props.dotCut,
|
|
22
|
+
currencySign = props.currencySign,
|
|
23
|
+
currencyType = props.currencyType,
|
|
24
|
+
legendData = props.legendData,
|
|
25
|
+
itemsPercentagesValueAside = props.itemsPercentagesValueAside,
|
|
26
|
+
itemsBoldedValues = props.itemsBoldedValues,
|
|
27
|
+
itemsValuesSeparateLine = props.itemsValuesSeparateLine,
|
|
28
|
+
width = props.width,
|
|
29
|
+
height = props.height,
|
|
30
|
+
textColor = props.textColor,
|
|
31
|
+
noDataText = props.noDataText;
|
|
32
|
+
var DEFAULT_ROOT_FONT = 18;
|
|
40
33
|
var DEFAULT_COMPONENT_WIDTH = 250;
|
|
41
|
-
var _useState = (0, _react.useState)(DEFAULT_ROOT_FONT.toString().concat(
|
|
34
|
+
var _useState = (0, _react.useState)(DEFAULT_ROOT_FONT.toString().concat('', 'px')),
|
|
42
35
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
43
36
|
rootFont = _useState2[0],
|
|
44
37
|
setRootFont = _useState2[1];
|
|
45
38
|
var controlsContainerRef = (0, _react.useRef)();
|
|
39
|
+
var getRootFont = function getRootFont(scopeWidth) {
|
|
40
|
+
var relation = scopeWidth.toString().replace('px', '').replace('%', '') / DEFAULT_COMPONENT_WIDTH;
|
|
41
|
+
var fontRoot = (DEFAULT_ROOT_FONT * relation).toString().concat('', 'px');
|
|
42
|
+
return fontRoot;
|
|
43
|
+
};
|
|
44
|
+
var dotCutTrenty = function dotCutTrenty(row) {
|
|
45
|
+
return dotCut ? (0, _CommonFunctions.getFormattedValue)(row.value) : (0, _CommonFunctions.getNumberWithCommas)(row.value);
|
|
46
|
+
};
|
|
46
47
|
(0, _react.useEffect)(function () {
|
|
47
48
|
var offsetWidth = controlsContainerRef.current.offsetWidth;
|
|
48
49
|
setRootFont(getRootFont(offsetWidth));
|
|
49
50
|
}, [width]);
|
|
50
|
-
|
|
51
|
-
var relation = width.toString().replace("px", "").replace("%", "") / DEFAULT_COMPONENT_WIDTH;
|
|
52
|
-
var fontRoot = (DEFAULT_ROOT_FONT * relation).toString().concat("", "px");
|
|
53
|
-
return fontRoot;
|
|
54
|
-
};
|
|
55
|
-
var CustomTooltip = function CustomTooltip(_ref2) {
|
|
56
|
-
var active = _ref2.active,
|
|
57
|
-
payload = _ref2.payload,
|
|
58
|
-
label = _ref2.label;
|
|
59
|
-
if (active && payload && payload.length) {
|
|
60
|
-
console.log(active, payload, label);
|
|
61
|
-
var percent = value && value != 0 ? (payload[0].value / value * 100).toFixed(0) : 0;
|
|
62
|
-
return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.TooltipDiv, null, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.TooltipLabel, null, "".concat(payload[0].name, " ").concat(percent, "%")));
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
};
|
|
66
|
-
var onPieEnterHandler = function onPieEnterHandler() {};
|
|
67
|
-
return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.ControlsContainer, {
|
|
51
|
+
return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.ControlsContainer, {
|
|
68
52
|
id: "ControlsContainer",
|
|
69
53
|
height: height,
|
|
70
54
|
width: width,
|
|
71
55
|
textColor: textColor,
|
|
72
56
|
ref: controlsContainerRef,
|
|
73
57
|
rootFont: rootFont
|
|
74
|
-
}, (legendData === null || legendData === void 0 ? void 0 : legendData.length) > 0 ? /*#__PURE__*/_react.default.createElement(
|
|
58
|
+
}, (legendData === null || legendData === void 0 ? void 0 : legendData.length) > 0 ? /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.Controls, {
|
|
75
59
|
id: "Controls",
|
|
76
60
|
height: height,
|
|
77
61
|
width: width
|
|
78
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.TitleAndValueContainer, {
|
|
79
63
|
id: "TitleAndValueContainer"
|
|
80
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.Title, {
|
|
81
65
|
id: "Title",
|
|
82
66
|
width: width
|
|
83
|
-
}, title), /*#__PURE__*/_react.default.createElement(
|
|
67
|
+
}, title), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.CurrencySignAndFormattedValueContainer, {
|
|
84
68
|
id: "CurrencySignAndFormattedValueContainer"
|
|
85
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
86
|
-
id: "CurrencySign"
|
|
87
|
-
}, currency ? (0, _CommonFunctions.getCurrencySign)(currencyType, value) : ""), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.FormattedValue, {
|
|
69
|
+
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.FormattedValue, {
|
|
88
70
|
id: "FormattedValue",
|
|
89
71
|
width: width
|
|
90
|
-
},
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.CurrencySign, {
|
|
73
|
+
id: "CurrencySign"
|
|
74
|
+
}, currencySign ? (0, _CommonFunctions.getCurrencySign)(currencyType, value) : ''), dotCut ? (0, _CommonFunctions.getFormattedValue)(value) : (0, _CommonFunctions.getNumberWithCommas)(value), dotCut ? (0, _CommonFunctions.getFormattedUnits)(value) : ''), addingBenchmark && /*#__PURE__*/_react.default.createElement(_Benchmark.Benchmark, null))), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.DoughnutChartAndLegendContainer, {
|
|
91
75
|
id: "DoughnutChartAndLegendContainer"
|
|
92
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
76
|
+
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.DoughnutChart, {
|
|
93
77
|
id: "DoughnutChart",
|
|
94
78
|
width: width,
|
|
95
79
|
height: height
|
|
96
|
-
}, /*#__PURE__*/_react.default.createElement(_recharts.ResponsiveContainer, null, /*#__PURE__*/_react.default.createElement(_recharts.PieChart, {
|
|
97
|
-
onMouseEnter: onPieEnterHandler
|
|
98
|
-
}, /*#__PURE__*/_react.default.createElement(_recharts.Pie, {
|
|
99
|
-
data: legendData,
|
|
100
|
-
outerRadius: 37 * (rootFont.toString().replace("px", "") / DEFAULT_ROOT_FONT),
|
|
101
|
-
innerRadius: 26 * (rootFont.toString().replace("px", "") / DEFAULT_ROOT_FONT),
|
|
80
|
+
}, /*#__PURE__*/_react.default.createElement(_recharts.ResponsiveContainer, null, /*#__PURE__*/_react.default.createElement(_recharts.PieChart, null, /*#__PURE__*/_react.default.createElement(_recharts.Pie, {
|
|
102
81
|
fill: "#8884d8",
|
|
103
|
-
dataKey: "value"
|
|
104
|
-
|
|
82
|
+
dataKey: "value",
|
|
83
|
+
blendStroke: true,
|
|
84
|
+
startAngle: -270,
|
|
85
|
+
data: legendData,
|
|
86
|
+
outerRadius: rootFont.toString().replace('px', '') * 2,
|
|
87
|
+
innerRadius: rootFont.toString().replace('px', '') * 1.5
|
|
88
|
+
}, legendData.map(function (row) {
|
|
105
89
|
return /*#__PURE__*/_react.default.createElement(_recharts.Cell, {
|
|
106
|
-
key: "cell-".concat(
|
|
90
|
+
key: "cell-".concat(row.name),
|
|
107
91
|
fill: row.color
|
|
108
92
|
});
|
|
109
93
|
})), /*#__PURE__*/_react.default.createElement(_recharts.Tooltip, {
|
|
110
|
-
content: /*#__PURE__*/_react.default.createElement(CustomTooltip,
|
|
111
|
-
|
|
94
|
+
content: /*#__PURE__*/_react.default.createElement(CustomTooltip, {
|
|
95
|
+
value: value
|
|
96
|
+
})
|
|
97
|
+
}), /*#__PURE__*/_react.default.createElement(_recharts.Tooltip, null)))), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.LegendContainer, {
|
|
112
98
|
id: "LegendContainer"
|
|
113
|
-
}, legendData.map(function (row
|
|
114
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
99
|
+
}, legendData.map(function (row) {
|
|
100
|
+
return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.LegendControlsContainer, {
|
|
115
101
|
id: "LegendControlsContainer"
|
|
116
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.LegendColorRectangle, {
|
|
117
103
|
id: "LegendColorRectangle",
|
|
118
104
|
color: row.color
|
|
119
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
105
|
+
}), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.LegendTitleAndFormatedValueContainer, {
|
|
120
106
|
id: "LegendTitleAndFormatedValueContainer"
|
|
121
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
122
|
-
id: "LegendTitle"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
107
|
+
}, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.LegendTitle, {
|
|
108
|
+
id: "LegendTitle",
|
|
109
|
+
style: {
|
|
110
|
+
flexWrap: itemsValuesSeparateLine ? 'wrap' : 'nowrap'
|
|
111
|
+
}
|
|
112
|
+
}, row.name, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.LegendFormattedValue, {
|
|
113
|
+
id: "LegendFormattedValue",
|
|
114
|
+
style: {
|
|
115
|
+
fontWeight: itemsBoldedValues ? '700' : '500'
|
|
116
|
+
}
|
|
117
|
+
}, row.value !== undefined && row.value !== null ? dotCutTrenty(row) : 'No Data', row.value !== undefined && row.value !== null && dotCut ? (0, _CommonFunctions.getFormattedUnits)(row.value) : '', itemsPercentagesValueAside && " (".concat(Math.round(row.value / value * 100), "%)")))));
|
|
130
118
|
})))) : /*#__PURE__*/_react.default.createElement(_NoDataFoundMessage.NoDataFoundMessage, {
|
|
131
119
|
noDataText: noDataText
|
|
132
120
|
}));
|
|
133
121
|
};
|
|
134
122
|
exports.TotalDoughnutChart = TotalDoughnutChart;
|
|
135
123
|
var _default = TotalDoughnutChart;
|
|
136
|
-
exports.default = _default;
|
|
124
|
+
exports.default = _default;
|
|
125
|
+
TotalDoughnutChart.defaultProps = {
|
|
126
|
+
title: 'Total Cost',
|
|
127
|
+
value: 0,
|
|
128
|
+
addingBenchmark: true,
|
|
129
|
+
dotCut: false,
|
|
130
|
+
currencySign: false,
|
|
131
|
+
currencyType: 'USD',
|
|
132
|
+
legendData: [],
|
|
133
|
+
itemsPercentagesValueAside: false,
|
|
134
|
+
itemsBoldedValues: true,
|
|
135
|
+
itemsValuesSeparateLine: false,
|
|
136
|
+
width: '300px',
|
|
137
|
+
height: '280px',
|
|
138
|
+
textColor: '#212121',
|
|
139
|
+
noDataText: ''
|
|
140
|
+
};
|
|
141
|
+
function CustomTooltip(_ref) {
|
|
142
|
+
var active = _ref.active,
|
|
143
|
+
payload = _ref.payload,
|
|
144
|
+
value = _ref.value;
|
|
145
|
+
if (active && payload && payload.length) {
|
|
146
|
+
var percent = value && value !== 0 ? (payload[0].value / value * 100).toFixed(0) : 0;
|
|
147
|
+
return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.TooltipDiv, null, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChart.TooltipLabel, null, "".concat(payload[0].name, " ").concat(percent, "%")));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
CustomTooltip.defaultProps = {
|
|
151
|
+
active: '',
|
|
152
|
+
payload: '',
|
|
153
|
+
value: ''
|
|
154
|
+
};
|
|
@@ -4,11 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.TooltipLabel = exports.TooltipDiv = exports.TitleAndValueContainer = exports.Title = exports.LegendTitleAndFormatedValueContainer = exports.LegendTitle = exports.LegendFormattedValue = exports.LegendFormatedValueContainer = exports.
|
|
7
|
+
exports.TooltipLabel = exports.TooltipDiv = exports.TitleAndValueContainer = exports.Title = exports.LegendTitleAndFormatedValueContainer = exports.LegendTitle = exports.LegendFormattedValue = exports.LegendFormatedValueContainer = exports.LegendControlsContainer = exports.LegendContainer = exports.LegendColorRectangle = exports.FormattedValue = exports.DoughnutChartAndLegendContainer = exports.DoughnutChart = exports.CurrencySignAndFormattedValueContainer = exports.CurrencySign = exports.ControlsContainer = exports.Controls = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
9
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18
|
|
11
|
-
var ControlsContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
|
|
11
|
+
var ControlsContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n font-family: \"Poppins\", sans-serif;\n font-style: normal;\n font-size: ", ";\n color: ", ";\n width: ", ";\n height: ", ";\n border-radius: 12px;\n align-self: center;\n\n > * {\n box-sizing: border-box;\n }\n"])), function (props) {
|
|
12
12
|
return props.rootFont;
|
|
13
13
|
}, function (props) {
|
|
14
14
|
return props.textColor;
|
|
@@ -18,41 +18,39 @@ var ControlsContainer = _styledComponents.default.div(_templateObject || (_templ
|
|
|
18
18
|
return props.height;
|
|
19
19
|
});
|
|
20
20
|
exports.ControlsContainer = ControlsContainer;
|
|
21
|
-
var Controls = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n border-radius: 12px;\n width: 100%;\n height: 100%;\n background: #ffffff;\n
|
|
21
|
+
var Controls = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n border-radius: 12px;\n width: 100%;\n height: 100%;\n background: #ffffff;\n padding: 1rem;\n"])));
|
|
22
22
|
exports.Controls = Controls;
|
|
23
|
-
var TooltipDiv = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.2);\n border-radius: 5px;\n background: #fff;\n padding: 6px 10px;\n display: flex;\n
|
|
23
|
+
var TooltipDiv = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.2);\n border-radius: 5px;\n background: #fff;\n padding: 6px 10px;\n display: flex;\n margin:0;\n"])));
|
|
24
24
|
exports.TooltipDiv = TooltipDiv;
|
|
25
|
-
var TooltipLabel = _styledComponents.default.p(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n color: #212121;\n font-family: \"Poppins\", sans-serif;\n font-size: 12px;\n font-weight: 400;\n font-style: normal;\n width: max-content; // fit-content; \n line-height: normal;\n margin:0;\n"])));
|
|
25
|
+
var TooltipLabel = _styledComponents.default.p(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n color: #212121;\n font-family: \"Poppins\", sans-serif;\n font-size: 12px;\n font-weight: 400;\n font-style: normal;\n width: max-content; // fit-content; \n line-height: normal;\n margin: 0;\n"])));
|
|
26
26
|
exports.TooltipLabel = TooltipLabel;
|
|
27
|
-
var TitleAndValueContainer = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n width:
|
|
27
|
+
var TitleAndValueContainer = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n width: 100%;\n"])));
|
|
28
28
|
exports.TitleAndValueContainer = TitleAndValueContainer;
|
|
29
|
-
var Title = _styledComponents.default.
|
|
29
|
+
var Title = _styledComponents.default.h4(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 1rem;\n margin: 0;\n"])));
|
|
30
30
|
exports.Title = Title;
|
|
31
|
-
var CurrencySignAndFormattedValueContainer = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n
|
|
31
|
+
var CurrencySignAndFormattedValueContainer = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n gap: 1.7rem;\n"])));
|
|
32
32
|
exports.CurrencySignAndFormattedValueContainer = CurrencySignAndFormattedValueContainer;
|
|
33
|
-
var CurrencySign = _styledComponents.default.
|
|
33
|
+
var CurrencySign = _styledComponents.default.span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 1rem;\n"])));
|
|
34
34
|
exports.CurrencySign = CurrencySign;
|
|
35
|
-
var FormattedValue = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 2.
|
|
35
|
+
var FormattedValue = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n font-size: 2.225rem;\n"])));
|
|
36
36
|
exports.FormattedValue = FormattedValue;
|
|
37
|
-
var DoughnutChartAndLegendContainer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n display: flex
|
|
37
|
+
var DoughnutChartAndLegendContainer = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n display: flex; \n margin-top: auto;\n"])));
|
|
38
38
|
exports.DoughnutChartAndLegendContainer = DoughnutChartAndLegendContainer;
|
|
39
|
-
var DoughnutChart = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n width:
|
|
39
|
+
var DoughnutChart = _styledComponents.default.div(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2.default)(["\n min-width: 40%;\n flex-basis: 40%;\n min-height: 6rem;\n"])));
|
|
40
40
|
exports.DoughnutChart = DoughnutChart;
|
|
41
|
-
var LegendContainer = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
41
|
+
var LegendContainer = _styledComponents.default.div(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2.default)(["\n flex-grow: 1;\n padding-left: .300rem;\n display: flex;\n flex-direction: column;\n justify-content: space-evenly;\n"])));
|
|
42
42
|
exports.LegendContainer = LegendContainer;
|
|
43
|
-
var LegendControlsContainer = _styledComponents.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n margin-bottom:
|
|
43
|
+
var LegendControlsContainer = _styledComponents.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n gap: 0.5rem;\n align-items: center;\n margin-bottom: 0.375rem;\n"])));
|
|
44
44
|
exports.LegendControlsContainer = LegendControlsContainer;
|
|
45
|
-
var LegendTitleAndFormatedValueContainer = _styledComponents.default.div(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
45
|
+
var LegendTitleAndFormatedValueContainer = _styledComponents.default.div(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2.default)(["\n flex-grow: 1;\n"])));
|
|
46
46
|
exports.LegendTitleAndFormatedValueContainer = LegendTitleAndFormatedValueContainer;
|
|
47
|
-
var LegendFormatedValueContainer = _styledComponents.default.div(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2.default)(["\n
|
|
47
|
+
var LegendFormatedValueContainer = _styledComponents.default.div(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2.default)(["\n font-size: .875rem;\n"])));
|
|
48
48
|
exports.LegendFormatedValueContainer = LegendFormatedValueContainer;
|
|
49
|
-
var LegendColorRectangle = _styledComponents.default.div(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n width: 0.
|
|
49
|
+
var LegendColorRectangle = _styledComponents.default.div(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2.default)(["\n width: 0.875rem;\n min-width: 0.875rem;\n height: 0.875rem;\n border-radius: 2px;\n background: ", ";\n"])), function (props) {
|
|
50
50
|
return props.color;
|
|
51
51
|
});
|
|
52
52
|
exports.LegendColorRectangle = LegendColorRectangle;
|
|
53
|
-
var LegendTitle = _styledComponents.default.
|
|
53
|
+
var LegendTitle = _styledComponents.default.h5(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 400;\n font-size: 0.875rem;\n margin: 0;\n display: flex;\n align-items: center;\n justify-content: space-between;\n"])));
|
|
54
54
|
exports.LegendTitle = LegendTitle;
|
|
55
|
-
var
|
|
56
|
-
exports.LegendCurrencySign = LegendCurrencySign;
|
|
57
|
-
var LegendFormattedValue = _styledComponents.default.div(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2.default)(["\n\n"])));
|
|
55
|
+
var LegendFormattedValue = _styledComponents.default.span(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2.default)(["\n font-weight: 500;\n white-space: nowrap;\n"])));
|
|
58
56
|
exports.LegendFormattedValue = LegendFormattedValue;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sag_components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.251",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "react-scripts start",
|
|
8
|
+
"lint": "eslint .",
|
|
8
9
|
"build": "cross-env BABEL_ENV=production babel src -d dist ",
|
|
9
10
|
"storybook": "storybook dev -p 6006",
|
|
10
11
|
"build-storybook": "storybook build"
|
|
@@ -17,26 +18,28 @@
|
|
|
17
18
|
"@babel/preset-env": "^7.21.4",
|
|
18
19
|
"@babel/preset-react": "^7.18.6",
|
|
19
20
|
"@babel/preset-typescript": "^7.21.4",
|
|
20
|
-
"@storybook/addon-a11y": "^7.
|
|
21
|
-
"@storybook/addon-essentials": "^7.
|
|
22
|
-
"@storybook/addon-interactions": "^7.
|
|
23
|
-
"@storybook/addon-links": "^7.
|
|
24
|
-
"@storybook/addon-storysource": "^7.
|
|
25
|
-
"@storybook/blocks": "^7.
|
|
21
|
+
"@storybook/addon-a11y": "^7.4.5",
|
|
22
|
+
"@storybook/addon-essentials": "^7.4.5",
|
|
23
|
+
"@storybook/addon-interactions": "^7.4.5",
|
|
24
|
+
"@storybook/addon-links": "^7.4.5",
|
|
25
|
+
"@storybook/addon-storysource": "^7.4.5",
|
|
26
|
+
"@storybook/blocks": "^7.4.5",
|
|
26
27
|
"@storybook/preset-scss": "^1.0.3",
|
|
27
|
-
"@storybook/react": "^7.
|
|
28
|
-
"@storybook/react-webpack5": "^7.
|
|
29
|
-
"@storybook/testing-library": "^0.
|
|
28
|
+
"@storybook/react": "^7.4.5",
|
|
29
|
+
"@storybook/react-webpack5": "^7.4.5",
|
|
30
|
+
"@storybook/testing-library": "^0.2.1",
|
|
30
31
|
"cross-env": "^7.0.3",
|
|
31
32
|
"css-loader": "^5.2.7",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
33
|
+
"eslint": "^8.50.0",
|
|
34
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
35
|
+
"eslint-plugin-import": "^2.28.1",
|
|
36
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
37
|
+
"eslint-plugin-react": "^7.33.2",
|
|
38
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
34
39
|
"react-dom": "^18.2.0",
|
|
35
|
-
"sass": "^1.
|
|
36
|
-
"sass-loader": "^
|
|
37
|
-
"
|
|
38
|
-
"style-loader": "^2.0.0",
|
|
39
|
-
"styled-components": "^5.3.10"
|
|
40
|
+
"sass": "^1.68.0",
|
|
41
|
+
"sass-loader": "^13.3.2",
|
|
42
|
+
"style-loader": "^3.3.3"
|
|
40
43
|
},
|
|
41
44
|
"dependencies": {
|
|
42
45
|
"@dnd-kit/core": "^6.0.8",
|
|
@@ -50,14 +53,19 @@
|
|
|
50
53
|
"@mui/material": "^5.13.0",
|
|
51
54
|
"@mui/styled-engine-sc": "^5.12.0",
|
|
52
55
|
"@mui/x-date-pickers": "^6.11.1",
|
|
56
|
+
"@storybook/addon-designs": "^7.0.5",
|
|
53
57
|
"babel-plugin-react-css-modules": "^5.2.6",
|
|
54
58
|
"classnames": "^2.3.2",
|
|
55
59
|
"dayjs": "^1.11.9",
|
|
56
60
|
"hoopy": "^0.1.4",
|
|
61
|
+
"prop-types": "^15.8.1",
|
|
62
|
+
"react": "^18.2.0",
|
|
57
63
|
"react-css-modules": "^4.7.11",
|
|
58
64
|
"react-loading-skeleton": "^3.3.1",
|
|
59
65
|
"react-scripts": "5.0.1",
|
|
60
|
-
"recharts": "^2.6.2"
|
|
66
|
+
"recharts": "^2.6.2",
|
|
67
|
+
"storybook": "^7.4.5",
|
|
68
|
+
"styled-components": "^5.3.11"
|
|
61
69
|
},
|
|
62
70
|
"browserslist": {
|
|
63
71
|
"production": [
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.InfoIcon = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var InfoIcon = function InfoIcon(_ref) {
|
|
10
|
-
var clicked = _ref.clicked;
|
|
11
|
-
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
12
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
13
|
-
viewBox: "0 0 24 24",
|
|
14
|
-
fill: "none",
|
|
15
|
-
stroke: clicked ? "white" : "black",
|
|
16
|
-
strokeWidth: "2",
|
|
17
|
-
strokeLinecap: "round",
|
|
18
|
-
strokeLinejoin: "round",
|
|
19
|
-
className: "feather feather-info"
|
|
20
|
-
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
21
|
-
cx: "12",
|
|
22
|
-
cy: "12",
|
|
23
|
-
r: "10"
|
|
24
|
-
}), /*#__PURE__*/_react.default.createElement("line", {
|
|
25
|
-
x1: "12",
|
|
26
|
-
y1: "16",
|
|
27
|
-
x2: "12",
|
|
28
|
-
y2: "12"
|
|
29
|
-
}), /*#__PURE__*/_react.default.createElement("line", {
|
|
30
|
-
x1: "12",
|
|
31
|
-
y1: "8",
|
|
32
|
-
x2: "12",
|
|
33
|
-
y2: "8"
|
|
34
|
-
}));
|
|
35
|
-
};
|
|
36
|
-
exports.InfoIcon = InfoIcon;
|
|
37
|
-
var _default = InfoIcon;
|
|
38
|
-
exports.default = _default;
|