oolib 2.155.0 → 2.155.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.
Files changed (30) hide show
  1. package/dist/components/ActionMenu/index.js +11 -4
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.js +7 -4
  4. package/dist/stories/v2/components/Accordion.stories.d.ts +7 -0
  5. package/dist/stories/{Oolib/components/BarChart.stories.js → v2/components/Accordion.stories.js} +19 -12
  6. package/dist/stories/v2/components/BarChart.stories.js +265 -0
  7. package/dist/stories/v2/components/DataVizAccordion.stories.d.ts +7 -0
  8. package/dist/stories/v2/components/DataVizAccordion.stories.js +141 -0
  9. package/dist/stories/v2/components/PieChart.stories.d.ts +7 -0
  10. package/dist/stories/v2/components/PieChart.stories.js +76 -0
  11. package/dist/v2/components/Accordion/index.d.ts +14 -0
  12. package/dist/v2/components/Accordion/index.js +105 -0
  13. package/dist/v2/components/BarChart/comps/CustomizedLabel/index.d.ts +32 -0
  14. package/dist/v2/components/BarChart/comps/CustomizedLabel/index.js +50 -0
  15. package/dist/v2/components/BarChart/index.d.ts +29 -0
  16. package/dist/v2/components/BarChart/index.js +261 -0
  17. package/dist/v2/components/BlockLabel/index.styled.js +1 -1
  18. package/dist/v2/components/DataVizAccordion/index.d.ts +6 -0
  19. package/dist/v2/components/DataVizAccordion/index.js +63 -0
  20. package/dist/v2/components/PieChart/index.d.ts +13 -0
  21. package/dist/v2/components/PieChart/index.js +116 -0
  22. package/dist/v2/themes/colors.d.ts +1 -0
  23. package/dist/v2/themes/colors.js +35 -1
  24. package/dist/v2/themes/typo.js +7 -7
  25. package/package.json +1 -1
  26. package/dist/components/dataViz/comps/BarChart/index.d.ts +0 -2
  27. package/dist/components/dataViz/comps/BarChart/index.js +0 -184
  28. package/dist/components/dataViz/utils/index.d.ts +0 -24
  29. package/dist/components/dataViz/utils/index.js +0 -50
  30. /package/dist/stories/{Oolib → v2}/components/BarChart.stories.d.ts +0 -0
@@ -0,0 +1,116 @@
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
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
37
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
38
+ if (ar || !(i in from)) {
39
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
40
+ ar[i] = from[i];
41
+ }
42
+ }
43
+ return to.concat(ar || Array.prototype.slice.call(from));
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.PieChart = void 0;
47
+ var react_1 = __importStar(require("react"));
48
+ var recharts_1 = require("recharts");
49
+ var _EXPORTS_1 = require("../../../utils/_EXPORTS");
50
+ var getTotalCount_1 = require("../../../utils/getTotalCount");
51
+ var chartColors = [
52
+ "#5C80FF",
53
+ "#FFA800",
54
+ "#00BC8F",
55
+ "#FF51CE",
56
+ "rgb(173, 89, 108)",
57
+ "rgb(114, 190, 244)",
58
+ "rgb(255, 178, 122)",
59
+ "rgb(14, 126, 161)",
60
+ "rgb(60, 169, 116)",
61
+ "rgb(254, 187, 178)",
62
+ "rgb(204, 128, 217)",
63
+ "rgb(91, 184, 175)",
64
+ ];
65
+ var usePrepareData = function (_a) {
66
+ var _data = _a._data, labelPath = _a.labelPath, valuePath = _a.valuePath, plotDataPoint = _a.plotDataPoint;
67
+ return (0, react_1.useMemo)(function () {
68
+ var finalData = __spreadArray([], _data, true);
69
+ var totalCount = (0, getTotalCount_1.getTotalCount)({ data: finalData, countPath: valuePath });
70
+ finalData = finalData.map(function (d) { return ({
71
+ labels: __assign(__assign({}, (plotDataPoint === "percentage"
72
+ ? { percentage: (0, _EXPORTS_1.getPercentage)((0, _EXPORTS_1.getVal)(d, valuePath), totalCount) }
73
+ : {})), { count: (0, _EXPORTS_1.getVal)(d, valuePath), name: (0, _EXPORTS_1.getVal)(d, labelPath) }),
74
+ }); });
75
+ // Sort by value
76
+ finalData.sort(function (a, b) { return b.labels.count - a.labels.count; });
77
+ return finalData;
78
+ }, [_data, labelPath, valuePath, plotDataPoint]);
79
+ };
80
+ var CustomLabel = function (_a) {
81
+ var viewBox = _a.viewBox, value = _a.value;
82
+ var cx = viewBox.cx, cy = viewBox.cy;
83
+ return (react_1.default.createElement("text", { x: cx, y: cy, textAnchor: "middle", dominantBaseline: "central", className: "text-sm font-medium" }, value));
84
+ };
85
+ var renderActiveShape = function (props) {
86
+ var cx = props.cx, cy = props.cy, innerRadius = props.innerRadius, outerRadius = props.outerRadius, startAngle = props.startAngle, endAngle = props.endAngle, fill = props.fill, payload = props.payload;
87
+ return (react_1.default.createElement("g", null,
88
+ react_1.default.createElement(recharts_1.Sector, { cx: cx, cy: cy, innerRadius: innerRadius, outerRadius: outerRadius + 8, startAngle: startAngle, endAngle: endAngle, fill: fill }),
89
+ react_1.default.createElement(recharts_1.Sector, { cx: cx, cy: cy, startAngle: startAngle, endAngle: endAngle, innerRadius: innerRadius - 4, outerRadius: innerRadius - 2, fill: fill })));
90
+ };
91
+ var PieChart = function (_a) {
92
+ var _data = _a.data, valuePath = _a.valuePath, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.colors, colors = _c === void 0 ? chartColors : _c, _d = _a.colorIdx, colorIdx = _d === void 0 ? 0 : _d, _e = _a.plotDataPoint, plotDataPoint = _e === void 0 ? "percentage" : _e, innerLabel = _a.innerLabel;
93
+ var data = usePrepareData({
94
+ _data: _data,
95
+ labelPath: labelPath,
96
+ valuePath: valuePath,
97
+ plotDataPoint: plotDataPoint,
98
+ });
99
+ var _f = (0, react_1.useState)(), activeIndex = _f[0], setActiveIndex = _f[1];
100
+ var onPieEnter = function (_, index) {
101
+ setActiveIndex(index);
102
+ };
103
+ var onPieLeave = function () {
104
+ setActiveIndex(undefined);
105
+ };
106
+ var onPieClick = function (_, index) {
107
+ if (onClick) {
108
+ onClick(data[index].labels.name);
109
+ }
110
+ };
111
+ return (react_1.default.createElement("div", { className: "w-full", style: { height: "300px" } },
112
+ react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: "100%" },
113
+ react_1.default.createElement(recharts_1.PieChart, null,
114
+ react_1.default.createElement(recharts_1.Pie, { data: data, dataKey: "labels.count", nameKey: "labels.name", cx: "50%", cy: "50%", innerRadius: 60, outerRadius: 80, paddingAngle: 1, activeIndex: activeIndex, activeShape: renderActiveShape, onMouseEnter: onPieEnter, onMouseLeave: onPieLeave, onClick: onClick ? onPieClick : undefined, style: onClick ? { cursor: "pointer" } : {} }, data.map(function (entry, index) { return (react_1.default.createElement(recharts_1.Cell, { key: "cell-".concat(index), fill: colors[(index + colorIdx) % colors.length], opacity: activeIndex !== undefined && activeIndex !== index ? 0.4 : 1 })); }))))));
115
+ };
116
+ exports.PieChart = PieChart;
@@ -1,3 +1,4 @@
1
+ export declare const dataVizColors: string[];
1
2
  export declare const colors: {
2
3
  primary: string;
3
4
  secondary: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.colors = void 0;
3
+ exports.colors = exports.dataVizColors = void 0;
4
4
  var primary = "#006686";
5
5
  var secondary = "#456272";
6
6
  var tertiary = "#764F8B";
@@ -41,6 +41,40 @@ var hint = "#B77222";
41
41
  var green = '#53AC00';
42
42
  var greenBG = '#E8F6DA';
43
43
  var greenStroke = '#C4DAAF';
44
+ var greyColor100 = '#383838';
45
+ var greyColor90 = '#4c4c4c';
46
+ var greyColor80 = '#606060';
47
+ var greyColor70 = '#747474';
48
+ var greyColor50 = '#9B9B9B';
49
+ var greyColor40 = '#afafaf';
50
+ var greyColor15 = '#e1e1e1';
51
+ var greyColor10 = '#EBEBEB';
52
+ var greyColor5 = '#f5f5f5';
53
+ var greyColor3 = '#f9f9f9';
54
+ exports.dataVizColors = [
55
+ "#FF665D",
56
+ "#4DBC5D",
57
+ "#F89700",
58
+ "#49A3FF",
59
+ "#E5BF01",
60
+ "#2ABBB5",
61
+ "#AC8E68",
62
+ "#CF8AF2",
63
+ ];
64
+ // export const dataVizColors = [
65
+ // "#5C80FF",
66
+ // "#FFA800",
67
+ // "#00BC8F",
68
+ // "#FF51CE",
69
+ // "rgb(173, 89, 108)",
70
+ // "rgb(114, 190, 244)",
71
+ // "rgb(255, 178, 122)",
72
+ // "rgb(14, 126, 161)",
73
+ // "rgb(60, 169, 116)",
74
+ // "rgb(254, 187, 178)",
75
+ // "rgb(204, 128, 217)",
76
+ // "rgb(91, 184, 175)",
77
+ // ]
44
78
  exports.colors = {
45
79
  primary: primary,
46
80
  secondary: secondary,
@@ -25,12 +25,12 @@ var UI_HEADLINE = (0, styled_components_1.css)(templateObject_5 || (templateObje
25
25
  var UI_HEADLINE_SM = (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n ", ";;\n font-size: 28px;\n line-height: 36px;\n font-weight: 600;\n"], ["\n ", ";\n ", ";;\n font-size: 28px;\n line-height: 36px;\n font-weight: 600;\n"])), uiFont, fontCss);
26
26
  var UI_TITLE = (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n font-size: 20px;\n line-height: 26px;\n font-weight: 700;\n letter-spacing: 0.2px;\n ", ";\n ", ";\n"], ["\n font-size: 20px;\n line-height: 26px;\n font-weight: 700;\n letter-spacing: 0.2px;\n ", ";\n ", ";\n"])), uiFont, fontCss);
27
27
  var UI_TITLE_SM = (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n font-size: 16px;\n line-height: 21px;\n font-weight: 700;\n ", ";\n ", ";\n"], ["\n font-size: 16px;\n line-height: 21px;\n font-weight: 700;\n ", ";\n ", ";\n"])), uiFont, fontCss);
28
- var UI_BODY = (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n font-weight: 400;\n ", ";\n ", ";\n \n font-size: 18px;\n line-height: 23px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"], ["\n font-weight: 400;\n ", ";\n ", ";\n \n font-size: 18px;\n line-height: 23px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
29
- var UI_BODY_SM = (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n \n font-weight: 400;\n ", ";\n ", ";\n\n font-size: 16px;\n line-height: 21px;\n \n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"], ["\n \n font-weight: 400;\n ", ";\n ", ";\n\n font-size: 16px;\n line-height: 21px;\n \n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
30
- var UI_BODY_SEMIBOLD = (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-weight: 500;\n ", "\n ", "\n \n font-size: 18px;\n line-height: 23px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n \n"], ["\n font-weight: 500;\n ", "\n ", "\n \n font-size: 18px;\n line-height: 23px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n \n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
31
- var UI_BODY_SEMIBOLD_SM = (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-weight: 500;\n ", "\n ", "\n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"], ["\n font-weight: 500;\n ", "\n ", "\n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
32
- var UI_BODY_BOLD = (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 18px;\n line-height: 23px;\n\n ", "{\n line-height: 21px;\n font-size: 16px;\n }\n"], ["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 18px;\n line-height: 23px;\n\n ", "{\n line-height: 21px;\n font-size: 16px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
33
- var UI_BODY_BOLD_SM = (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 16px;\n line-height: 20px;\n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n\n"], ["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 16px;\n line-height: 20px;\n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
28
+ var UI_BODY_SM = (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n font-weight: 400;\n ", ";\n ", ";\n\n font-size: 14px;\n line-height: 18px;\n \n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"], ["\n font-weight: 400;\n ", ";\n ", ";\n\n font-size: 14px;\n line-height: 18px;\n \n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
29
+ var UI_BODY_SEMIBOLD_SM = (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n font-weight: 500;\n ", "\n ", "\n\n font-size: 14px;\n line-height: 18px;\n\n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"], ["\n font-weight: 500;\n ", "\n ", "\n\n font-size: 14px;\n line-height: 18px;\n\n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
30
+ var UI_BODY_BOLD_SM = (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 14px;\n line-height: 18px;\n \n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"], ["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 14px;\n line-height: 18px;\n \n ", "{\n font-size: 14px;\n line-height: 18px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
31
+ var UI_BODY = (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-weight: 400;\n ", ";\n ", ";\n \n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"], ["\n font-weight: 400;\n ", ";\n ", ";\n \n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
32
+ var UI_BODY_SEMIBOLD = (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n font-weight: 500;\n ", "\n ", "\n \n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"], ["\n font-weight: 500;\n ", "\n ", "\n \n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
33
+ var UI_BODY_BOLD = (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"], ["\n font-weight: 700;\n ", ";\n ", ";\n \n font-size: 16px;\n line-height: 21px;\n\n ", "{\n font-size: 16px;\n line-height: 21px;\n }\n"])), uiFont, fontCss, (0, mixins_1.mediaQuery)("md"));
34
34
  var UI_PARAGRAPH = (0, styled_components_1.css)(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n font-size: 14px;\n line-height: 130%;\n font-weight: 400;\n ", ";\n ", ";\n"], ["\n font-size: 14px;\n line-height: 130%;\n font-weight: 400;\n ", ";\n ", ";\n"])), uiFont, fontCss);
35
35
  var UI_PARAGRAPH_BOLD = (0, styled_components_1.css)(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n font-size: 14px;\n line-height: 130%;\n font-weight: 500;\n ", ";\n ", ";\n"], ["\n font-size: 14px;\n line-height: 130%;\n font-weight: 500;\n ", ";\n ", ";\n"])), uiFont, fontCss);
36
36
  var UI_CAPTION = (0, styled_components_1.css)(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n font-size: 12px;\n line-height: 16px;\n font-weight: 400;\n ", ";\n ", ";\n"], ["\n font-size: 12px;\n line-height: 16px;\n font-weight: 400;\n ", ";\n ", ";\n"])), uiFont, fontCss);
@@ -41,7 +41,7 @@ var UI_STAT_LG = (0, styled_components_1.css)(templateObject_21 || (templateObje
41
41
  var UI_STAT_SM = (0, styled_components_1.css)(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n font-size: 14px;\n line-height: 18px;\n font-weight: 700;\n ", ";\n ", ";\n"], ["\n font-size: 14px;\n line-height: 18px;\n font-weight: 700;\n ", ";\n ", ";\n"])), uiFont, fontCss);
42
42
  var CONTENT_H1 = (0, styled_components_1.css)(templateObject_23 || (templateObject_23 = __makeTemplateObject(["\n font-size: 36px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n "], ["\n font-size: 36px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n "])), contentFont, fontCss);
43
43
  var CONTENT_H2 = (0, styled_components_1.css)(templateObject_24 || (templateObject_24 = __makeTemplateObject(["\n font-size: 25px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n "], ["\n font-size: 25px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n "])), contentFont, fontCss);
44
- var CONTENT_H3 = (0, styled_components_1.css)(templateObject_25 || (templateObject_25 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n"], ["\n font-size: 18px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n"])), contentFont, fontCss);
44
+ var CONTENT_H3 = (0, styled_components_1.css)(templateObject_25 || (templateObject_25 = __makeTemplateObject(["\n font-size: 18px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n "], ["\n font-size: 18px;\n line-height: 140%;\n font-weight: 700;\n ", ";\n ", ";\n "])), contentFont, fontCss);
45
45
  var CONTENT_BODY = (0, styled_components_1.css)(templateObject_26 || (templateObject_26 = __makeTemplateObject(["\n font-size: 15px;\n line-height: 140%;\n font-weight: 400;\n ", ";\n ", ";\n"], ["\n font-size: 15px;\n line-height: 140%;\n font-weight: 400;\n ", ";\n ", ";\n"])), contentFont, fontCss);
46
46
  var CONTENT_BODY_BOLD = (0, styled_components_1.css)(templateObject_27 || (templateObject_27 = __makeTemplateObject(["\n font-size: 17px;\n line-height: 140%;\n font-weight: 600;\n ", ";\n ", ";\n"], ["\n font-size: 17px;\n line-height: 140%;\n font-weight: 600;\n ", ";\n ", ";\n"])), contentFont, fontCss);
47
47
  var CONTENT_BODY_ITALIC = (0, styled_components_1.css)(templateObject_28 || (templateObject_28 = __makeTemplateObject(["\n font-size: 17px;\n line-height: 140%;\n font-weight: 400;\n font-style: italic;\n ", ";\n ", ";\n"], ["\n font-size: 17px;\n line-height: 140%;\n font-weight: 400;\n font-style: italic;\n ", ";\n ", ";\n"])), contentFont, fontCss);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.155.0",
3
+ "version": "2.155.2",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- export function BarChart(props: any): React.JSX.Element;
2
- import React from "react";
@@ -1,184 +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
- exports.BarChart = void 0;
30
- var react_1 = __importStar(require("react"));
31
- var d3Modules_1 = __importDefault(require("../../../../d3Modules"));
32
- var utils_1 = require("../../utils");
33
- var testJSON_1 = require("../../../../utils/testJSON");
34
- var getVal_1 = require("../../../../utils/getterSetterDeleter/getVal");
35
- var themes_1 = require("../../../../themes");
36
- var styled_components_1 = require("styled-components");
37
- var utilsOolib_1 = require("../../../../utilsOolib");
38
- var BarChart = function (props) {
39
- var config = {
40
- width: 550,
41
- height: 100,
42
- margin: { top: 50, right: 120, bottom: 120, left: 100 },
43
- };
44
- var theme = (0, styled_components_1.useTheme)();
45
- var width = props.width || config.width;
46
- var height = props.height || config.height;
47
- var marginProp = (0, testJSON_1.testJSON)(JSON.stringify(props.margin))
48
- ? props.margin
49
- : undefined;
50
- var margin = marginProp
51
- ? {
52
- top: marginProp.top || config.margin.top,
53
- bottom: marginProp.bottom || config.margin.bottom,
54
- left: marginProp.left || config.margin.left,
55
- right: marginProp.right || config.margin.right,
56
- }
57
- : config.margin;
58
- var data = props.data, id = props.id, className = props.className, numValuePath = props.numValuePath, numLabelPath = props.numLabelPath, categoryValuePath = props.categoryValuePath, _a = props.categoryAxis, categoryAxis = _a === void 0 ? 'y' : _a, _b = props.barWidth, barWidth = _b === void 0 ? 20 : _b, numberAxisLabel = props.numberAxisLabel, _c = props.highlight
59
- /**
60
- * can be 'max' or 'min' or undefined. if undefined,
61
- * all bars will be painted the same color. if defined,
62
- * only the max/min will be painted a color.
63
- * rest of bars will be grey
64
- */
65
- , highlight = _c === void 0 ? 'max' : _c
66
- /**
67
- * can be 'max' or 'min' or undefined. if undefined,
68
- * all bars will be painted the same color. if defined,
69
- * only the max/min will be painted a color.
70
- * rest of bars will be grey
71
- */
72
- ;
73
- var wrapperId = "OKE_PiChart".concat(id ? "_" + id : "");
74
- var wrapperClass = "OKE-PiChart ".concat(className || "");
75
- (0, react_1.useEffect)(function () { return drawChart(data); }, [data]);
76
- var drawChart = function (data) {
77
- // console.log({DATA : data})
78
- //first clear the div
79
- d3Modules_1.default.select("#" + wrapperId + ">svg").remove();
80
- //then draw
81
- var svg = (0, utils_1.genResponsiveSvgCanvas)({
82
- width: width,
83
- height: height,
84
- wrapperId: wrapperId,
85
- margin: margin,
86
- translate: "".concat(margin.left, ",").concat(margin.right)
87
- });
88
- // X axis
89
- var categoryAxisGenerator = d3Modules_1.default
90
- .scaleBand()
91
- // .range([0, width]) alt
92
- .range([0, height])
93
- .domain(data.map(function (d) {
94
- return (0, getVal_1.getVal)(d, categoryValuePath);
95
- }))
96
- .padding(0.2);
97
- var categoryAxis = svg
98
- .append("g")
99
- //.attr("transform", "translate(0," + height + ")") //alt
100
- .attr("transform", "translate(0, 0)")
101
- //.call(d3.axisBottom(categoryAxis)) //alt
102
- .call(d3Modules_1.default.axisLeft(categoryAxisGenerator));
103
- categoryAxis.selectAll("text")
104
- // .attr("transform", "translate(-5,0)")
105
- .style("text-anchor", "end")
106
- .attr("color", themes_1.colors.greyColor100);
107
- categoryAxis.select('.domain').remove();
108
- categoryAxis.selectAll('.tick line').remove();
109
- // Add Y axis
110
- var numbersAxisGenerator = d3Modules_1.default
111
- .scaleLinear()
112
- .domain([0, (0, utils_1.getMax)({ data: data, valuePath: numValuePath })])
113
- // .range([height, 0]) // alt
114
- .range([0, width]);
115
- var numberAxisG = svg.append("g");
116
- var numberAxis = numberAxisG
117
- //.attr("transform", "translate(0, 0)") alt
118
- .attr("transform", "translate(0," + height + ")") //alt
119
- //.call(d3.axisLeft(numbersAxis)); //alt
120
- .call(d3Modules_1.default.axisBottom(numbersAxisGenerator));
121
- numberAxis.select('.domain').attr('stroke', themes_1.colors.greyColor40);
122
- numberAxis.selectAll('.tick text').attr('color', themes_1.colors.greyColor70);
123
- numberAxis.selectAll('.tick line').attr('stroke', themes_1.colors.greyColor40);
124
- if (numberAxisLabel) {
125
- svg.append('text')
126
- .text(numberAxisLabel)
127
- .attr("x", 0)
128
- .attr("y", height + 35)
129
- .attr('fill', themes_1.colors.greyColor100);
130
- }
131
- // Bars
132
- svg
133
- .selectAll("mybar")
134
- .data(data)
135
- .enter()
136
- .append("rect")
137
- // .attr("x", function (d) {
138
- // return categoryAxis(getVal(d, categoryValuePath)) + 10;
139
- // }) //alt
140
- .attr("y", function (d) {
141
- return categoryAxisGenerator((0, getVal_1.getVal)(d, categoryValuePath)) + (categoryAxisGenerator.bandwidth() / 2) - (barWidth / 2);
142
- })
143
- // .attr("y", function (d) {
144
- // return numbersAxis(getVal(d, numValuePath));
145
- // }) //alt
146
- .attr("x", 0)
147
- //.attr("width", barWidth) //alt
148
- .attr("height", barWidth)
149
- // .attr("height", function (d) {
150
- // return height - numbersAxis(getVal(d, numValuePath));
151
- // }) //alt
152
- .attr("width", function (d) {
153
- return numbersAxisGenerator((0, getVal_1.getVal)(d, numValuePath));
154
- })
155
- .attr('rx', 5)
156
- .attr("transform", 'translateX(50%)')
157
- .attr("fill", function (d) {
158
- return !highlight
159
- ? (0, utilsOolib_1.getPrimaryColor40)(theme === null || theme === void 0 ? void 0 : theme.colors)
160
- : highlight === 'max'
161
- ? (0, utils_1.getMax)({ data: data, valuePath: numValuePath }) === (0, getVal_1.getVal)(d, numValuePath)
162
- ? (0, utilsOolib_1.getPrimaryColor40)(theme === null || theme === void 0 ? void 0 : theme.colors)
163
- : themes_1.colors.greyColor15
164
- : (0, utils_1.getMin)({ data: data, valuePath: numValuePath }) === (0, getVal_1.getVal)(d, numValuePath)
165
- ? (0, utilsOolib_1.getPrimaryColor40)(theme === null || theme === void 0 ? void 0 : theme.colors)
166
- : themes_1.colors.greyColor15;
167
- });
168
- //Bar Number Labels
169
- svg
170
- .selectAll("barnumlabels")
171
- .data(data)
172
- .enter()
173
- .append("text")
174
- .text(function (d) { return (0, getVal_1.getVal)(d, numLabelPath || numValuePath); })
175
- .attr("y", function (d) {
176
- return categoryAxisGenerator((0, getVal_1.getVal)(d, categoryValuePath)) + (categoryAxisGenerator.bandwidth() / 2) + 4;
177
- })
178
- .attr("x", function (d) {
179
- return numbersAxisGenerator((0, getVal_1.getVal)(d, numValuePath)) + 5;
180
- });
181
- };
182
- return react_1.default.createElement("div", { id: wrapperId, className: wrapperClass });
183
- };
184
- exports.BarChart = BarChart;
@@ -1,24 +0,0 @@
1
- export function genResponsiveSvgCanvas({ margin, width, height, wrapperId, translate }: {
2
- margin: any;
3
- width: any;
4
- height: any;
5
- wrapperId: any;
6
- translate: any;
7
- }): any;
8
- export function getMinMax({ data, valuePath }: {
9
- data: any;
10
- valuePath: any;
11
- }): number[];
12
- export function getMax({ data, valuePath }: {
13
- data: any;
14
- valuePath: any;
15
- }): number;
16
- export function getMin({ data, valuePath }: {
17
- data: any;
18
- valuePath: any;
19
- }): number;
20
- export function calcSvgElemScaleFactor({ setWidth, actualWidth, setValueToScale, }: {
21
- setWidth: any;
22
- actualWidth: any;
23
- setValueToScale: any;
24
- }): number;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.calcSvgElemScaleFactor = exports.getMin = exports.getMax = exports.getMinMax = exports.genResponsiveSvgCanvas = void 0;
7
- var d3Modules_1 = __importDefault(require("../../../d3Modules"));
8
- var getVal_1 = require("../../../utils/getterSetterDeleter/getVal");
9
- var genResponsiveSvgCanvas = function (_a) {
10
- var margin = _a.margin, width = _a.width, height = _a.height, wrapperId = _a.wrapperId, translate = _a.translate;
11
- return d3Modules_1.default
12
- .select("#" + wrapperId)
13
- .append("svg")
14
- // Responsive SVG needs these 2 attributes and no width and height attr.
15
- .attr("preserveAspectRatio", "xMinYMin meet")
16
- .attr("viewBox", "0 0 ".concat(width + margin.left + margin.right, " ").concat(height + margin.top + margin.bottom))
17
- .append("g")
18
- .classed("vizCanvas", true)
19
- .attr("transform", "translate(".concat(translate || "".concat(width / 2, ",").concat(height / 2), ")"))
20
- .attr("font-family", "'noto_sans', 'noto_sans_devanagari', 'noto_sans_gu','noto_sans_te', 'noto_sans_kn', 'noto_sans_or', sans-serif");
21
- };
22
- exports.genResponsiveSvgCanvas = genResponsiveSvgCanvas;
23
- var getOnlyNumbersAry = function (_a) {
24
- var data = _a.data, valuePath = _a.valuePath;
25
- return data.map(function (d) { return parseFloat((0, getVal_1.getVal)(d, valuePath)); });
26
- };
27
- var getMinMax = function (_a) {
28
- var data = _a.data, valuePath = _a.valuePath;
29
- var onlyNumbers = getOnlyNumbersAry({ data: data, valuePath: valuePath });
30
- return [Math.min.apply(Math, onlyNumbers), Math.max.apply(Math, onlyNumbers)];
31
- };
32
- exports.getMinMax = getMinMax;
33
- var getMax = function (_a) {
34
- var data = _a.data, valuePath = _a.valuePath;
35
- var onlyNumbers = getOnlyNumbersAry({ data: data, valuePath: valuePath });
36
- return Math.max.apply(Math, onlyNumbers);
37
- };
38
- exports.getMax = getMax;
39
- var getMin = function (_a) {
40
- var data = _a.data, valuePath = _a.valuePath;
41
- var onlyNumbers = getOnlyNumbersAry({ data: data, valuePath: valuePath });
42
- return Math.min.apply(Math, onlyNumbers);
43
- };
44
- exports.getMin = getMin;
45
- var calcSvgElemScaleFactor = function (_a) {
46
- var setWidth = _a.setWidth, actualWidth = _a.actualWidth, setValueToScale = _a.setValueToScale;
47
- var scaleFactor = actualWidth / setWidth;
48
- return setValueToScale * (1 / scaleFactor);
49
- };
50
- exports.calcSvgElemScaleFactor = calcSvgElemScaleFactor;