oolib 2.175.0 → 2.175.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.
@@ -62,7 +62,11 @@ var BarChart = function (args) {
62
62
  };
63
63
  return (react_1.default.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "20px" } },
64
64
  react_1.default.createElement("div", null,
65
- react_1.default.createElement(BarChart_1.BarChart, { data: [
65
+ react_1.default.createElement(BarChart_1.BarChart
66
+ // showPercent={false}
67
+ , {
68
+ // showPercent={false}
69
+ data: [
66
70
  {
67
71
  display: "Logged In Once",
68
72
  // stack1: 60,
@@ -71,6 +75,7 @@ var BarChart = function (args) {
71
75
  stack4: 10,
72
76
  stack5: 40,
73
77
  stack6: 10,
78
+ stack2Display: 'Labels Path Stack 2 Display'
74
79
  },
75
80
  {
76
81
  display: "Registered Users",
@@ -3,6 +3,7 @@ interface AccordionProps {
3
3
  title: React.ReactNode;
4
4
  children: React.ReactNode;
5
5
  defaultExpanded?: boolean;
6
+ accordionOverflow?: string;
6
7
  onViewTypeChange?: (type: "grouped" | "stacked") => void;
7
8
  currentViewType?: "grouped" | "stacked";
8
9
  actionsConfig?: {
@@ -52,7 +52,7 @@ var StyledContainer = styled_components_1.default.div(templateObject_1 || (templ
52
52
  var StyledHeader = styled_components_1.default.button(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n padding: 1rem 1.6rem;\n text-align: left;\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n"], ["\n width: 100%;\n padding: 1rem 1.6rem;\n text-align: left;\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n"])));
53
53
  var StyledRightHeaderSection = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n"], ["\n display: flex;\n align-items: center;\n"])));
54
54
  var ArrowWrapper = styled_components_1.default.button(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border: none;\n background: none;\n cursor: pointer;\n width: 2rem;\n display: flex;\n align-items: center;\n justify-content: center;\n transform: rotate(", "deg);\n ", ";\n"], ["\n border: none;\n background: none;\n cursor: pointer;\n width: 2rem;\n display: flex;\n align-items: center;\n justify-content: center;\n transform: rotate(", "deg);\n ", ";\n"])), function (props) { return (props.isExpanded ? 0 : 180); }, (0, mixins_1.transition)("transform"));
55
- var StyledContentWrapper = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n align-items: flex-end;\n overflow: hidden;\n ", "\n height: ", ";\n"], ["\n display: flex;\n align-items: flex-end;\n overflow: hidden;\n ", "\n height: ", ";\n"])), (0, mixins_1.transition)("height"), function (_a) {
55
+ var StyledContentWrapper = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n align-items: flex-end;\n \n ", "\n height: ", ";\n"], ["\n display: flex;\n align-items: flex-end;\n \n ", "\n height: ", ";\n"])), (0, mixins_1.transition)("height"), function (_a) {
56
56
  var height = _a.height;
57
57
  return height;
58
58
  });
@@ -88,7 +88,9 @@ var useCalculateWrapperHeight = function (_a) {
88
88
  });
89
89
  };
90
90
  var Accordion = function (_a) {
91
- var title = _a.title, children = _a.children, _b = _a.defaultExpanded, defaultExpanded = _b === void 0 ? true : _b, _c = _a.actionsConfig, actionsConfig = _c === void 0 ? [
91
+ var title = _a.title, children = _a.children, _b = _a.defaultExpanded, defaultExpanded = _b === void 0 ? true : _b, _c = _a.accordionOverflow, accordionOverflow = _c === void 0 ? 'hidden' : _c, //in some cases we need to toggle the overflow to let a tooltip stick out and show for example (in DataVizAccordion)
92
+ _d = _a.actionsConfig, //in some cases we need to toggle the overflow to let a tooltip stick out and show for example (in DataVizAccordion)
93
+ actionsConfig = _d === void 0 ? [
92
94
  {
93
95
  display: "Grouped",
94
96
  onClick: function () { return console.log("grouped"); },
@@ -97,9 +99,9 @@ var Accordion = function (_a) {
97
99
  display: "Stacked",
98
100
  onClick: function () { return console.log("stacked"); },
99
101
  },
100
- ] : _c;
101
- var _d = (0, react_1.useState)(defaultExpanded), isExpanded = _d[0], setIsExpanded = _d[1];
102
- var _e = useCalculateWrapperHeight({ isExpanded: isExpanded }), wrapperRef = _e.wrapperRef, wrapperHeight = _e.wrapperHeight;
102
+ ] : _d;
103
+ var _e = (0, react_1.useState)(defaultExpanded), isExpanded = _e[0], setIsExpanded = _e[1];
104
+ var _f = useCalculateWrapperHeight({ isExpanded: isExpanded }), wrapperRef = _f.wrapperRef, wrapperHeight = _f.wrapperHeight;
103
105
  return (react_1.default.createElement(StyledContainer, null,
104
106
  react_1.default.createElement(StyledHeader, { onClick: function () { return setIsExpanded(!isExpanded); } },
105
107
  react_1.default.createElement("div", { style: { flex: "1 0 0" } },
@@ -108,7 +110,7 @@ var Accordion = function (_a) {
108
110
  react_1.default.createElement(ArrowWrapper, { isExpanded: isExpanded },
109
111
  react_1.default.createElement(phosphor_react_1.CaretDown, { size: 16 })),
110
112
  actionsConfig && (react_1.default.createElement(ActionMenu_1.ActionMenu, { CustomSelectComp: CustomActionMenuSelectButton, actions: actionsConfig })))),
111
- react_1.default.createElement(StyledContentWrapper, { height: wrapperHeight },
113
+ react_1.default.createElement(StyledContentWrapper, { height: wrapperHeight, style: { overflow: accordionOverflow } },
112
114
  react_1.default.createElement(StyledContentInnerWrapper, { ref: wrapperRef }, children))));
113
115
  };
114
116
  exports.Accordion = Accordion;
@@ -1,9 +1,10 @@
1
- import React from 'react';
1
+ import React, { Dispatch, SetStateAction } from 'react';
2
2
  import { TooltipProps } from 'recharts';
3
3
  import { LabelData } from '../CustomizedLabel';
4
4
  interface CustomTooltipProps extends TooltipProps<number, string> {
5
5
  value?: LabelData[];
6
6
  showPercent?: boolean;
7
+ setAccordionOverflow?: Dispatch<SetStateAction<string>>;
7
8
  }
8
9
  declare const CustomTooltip: React.FC<CustomTooltipProps>;
9
10
  export default CustomTooltip;
@@ -1,14 +1,44 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var react_1 = __importDefault(require("react"));
36
+ var react_1 = __importStar(require("react"));
7
37
  var Typo2_1 = require("../../../Typo2");
8
38
  var __1 = require("../../../../..");
9
39
  var CustomTooltip = function (props) {
10
40
  var _a, _b;
11
- var active = props.active, payload = props.payload, value = props.value, showPercent = props.showPercent;
41
+ var active = props.active, payload = props.payload, value = props.value, showPercent = props.showPercent, setAccordionOverflow = props.setAccordionOverflow;
12
42
  if (!active || !payload || !payload.length)
13
43
  return null;
14
44
  // Calculate position - align with the right side of the bars
@@ -29,6 +59,10 @@ var CustomTooltip = function (props) {
29
59
  flexDirection: 'column',
30
60
  gap: '0.5rem'
31
61
  };
62
+ (0, react_1.useEffect)(function () {
63
+ setAccordionOverflow && setAccordionOverflow('visible');
64
+ return function () { return setAccordionOverflow && setAccordionOverflow('hidden'); };
65
+ }, []);
32
66
  return (react_1.default.createElement("div", { style: style }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: index, style: {
33
67
  display: 'flex',
34
68
  alignItems: 'center',
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { Dispatch, SetStateAction } from "react";
2
2
  export interface BaseConfigs {
3
3
  barHeight: number;
4
4
  labelToBarGap: number;
@@ -21,6 +21,7 @@ export interface BarChartProps {
21
21
  tooltipLabelsMapping: {
22
22
  [key: string]: string;
23
23
  };
24
+ tooltipLabelsPath: string | string[];
24
25
  labelPath: string;
25
26
  onClick?: (name: string) => void;
26
27
  valueSuffix?: string;
@@ -28,5 +29,6 @@ export interface BarChartProps {
28
29
  showPercent?: boolean;
29
30
  breakdownDisplayType?: "grouped" | "stacked";
30
31
  colorIdx?: number;
32
+ setAccordionOverflow?: Dispatch<SetStateAction<string>>;
31
33
  }
32
34
  export declare const BarChart: React.FC<BarChartProps>;
@@ -65,7 +65,7 @@ var CustomizedLabel_1 = require("./comps/CustomizedLabel");
65
65
  var colors_1 = require("../../themes/colors");
66
66
  var CustomTooltip_1 = __importDefault(require("./comps/CustomTooltip"));
67
67
  var usePrepareData = function (_a) {
68
- var _data = _a._data, labelPath = _a.labelPath, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, isBreakdown = _a.isBreakdown, showPercent = _a.showPercent;
68
+ var _data = _a._data, labelPath = _a.labelPath, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, isBreakdown = _a.isBreakdown, showPercent = _a.showPercent;
69
69
  return (0, react_1.useMemo)(function () {
70
70
  var finalData = __spreadArray([], _data, true);
71
71
  var totalCount = !isBreakdown
@@ -90,7 +90,9 @@ var usePrepareData = function (_a) {
90
90
  return {
91
91
  labels: __assign(__assign({}, (showPercent
92
92
  ? { percentage: (0, _EXPORTS_1.getPercentage)(count, totalCount[index]) }
93
- : {})), { count: count, tooltipLabel: (tooltipLabelsMapping === null || tooltipLabelsMapping === void 0 ? void 0 : tooltipLabelsMapping[path]) || path, name: (0, _EXPORTS_1.getVal)(d, labelPath) }),
93
+ : {})), { count: count, tooltipLabel: tooltipLabelsPath
94
+ ? tooltipLabelsPath[i] ? ((0, _EXPORTS_1.getVal)(d, tooltipLabelsPath[i]) || tooltipLabelsPath[i]) : path
95
+ : ((tooltipLabelsMapping === null || tooltipLabelsMapping === void 0 ? void 0 : tooltipLabelsMapping[path]) || path), name: (0, _EXPORTS_1.getVal)(d, labelPath) }),
94
96
  };
95
97
  });
96
98
  });
@@ -192,13 +194,14 @@ var barConfigs = {
192
194
  },
193
195
  };
194
196
  var BarChart = function (_a) {
195
- var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.breakdownDisplayType, breakdownDisplayType = _c === void 0 ? "grouped" : _c, _d = _a.showCount, showCount = _d === void 0 ? true : _d, _e = _a.showPercent, showPercent = _e === void 0 ? true : _e, _f = _a.colorIdx, colorIdx = _f === void 0 ? 0 : _f;
197
+ var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.breakdownDisplayType, breakdownDisplayType = _c === void 0 ? "grouped" : _c, _d = _a.showCount, showCount = _d === void 0 ? true : _d, _e = _a.showPercent, showPercent = _e === void 0 ? true : _e, _f = _a.colorIdx, colorIdx = _f === void 0 ? 0 : _f, setAccordionOverflow = _a.setAccordionOverflow;
196
198
  var isBreakdown = Array.isArray(valuePath);
197
199
  var data = usePrepareData({
198
200
  _data: _data,
199
201
  labelPath: labelPath,
200
202
  valuePath: valuePath,
201
203
  tooltipLabelsMapping: tooltipLabelsMapping,
204
+ tooltipLabelsPath: tooltipLabelsPath,
202
205
  isBreakdown: isBreakdown,
203
206
  showPercent: showPercent,
204
207
  });
@@ -269,7 +272,7 @@ var BarChart = function (_a) {
269
272
  // god knows why the dataindex gets stored against props.label.
270
273
  // this is some internal recharts thing for tooltips specifically.
271
274
  // we dont do this.
272
- value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColors[(colorIdx + idx) % colors_1.dataVizColors.length] })); }) })));
275
+ value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColors[(colorIdx + idx) % colors_1.dataVizColors.length] })); }), setAccordionOverflow: setAccordionOverflow })));
273
276
  }, cursor: false, allowEscapeViewBox: { x: true, y: true } })),
274
277
  isBreakdown
275
278
  ? data[0].map(function (_, stackIndex) {
@@ -44,17 +44,18 @@ var DataVizAccordion = function (_a) {
44
44
  },
45
45
  };
46
46
  var _c = (0, react_2.useState)(chartOptions[0]), activeCompConfig = _c[0], setActiveCompConfig = _c[1];
47
- var genActiveChartComp = function (activeCompConfig) {
47
+ var genActiveChartComp = function (activeCompConfig, setAccordionOverflow) {
48
48
  var ActiveChartComp = ChartComps[activeCompConfig.comp].comp;
49
49
  var wrapperStyle = ChartComps[activeCompConfig.comp].wrapperStyle;
50
50
  return (react_1.default.createElement("div", { style: __assign({ padding: "0 1.6rem 1rem 1.6rem" }, (wrapperStyle || {})) },
51
- react_1.default.createElement(ActiveChartComp, __assign({}, props, activeCompConfig.props))));
51
+ react_1.default.createElement(ActiveChartComp, __assign({}, props, activeCompConfig.props, { setAccordionOverflow: setAccordionOverflow }))));
52
52
  };
53
- return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, actionsConfig: chartOptions.length > 1 && chartOptions.map(function (d) { return ({
53
+ var _d = (0, react_2.useState)('hidden'), accordionOverflow = _d[0], setAccordionOverflow = _d[1];
54
+ return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, accordionOverflow: accordionOverflow, actionsConfig: chartOptions.length > 1 && chartOptions.map(function (d) { return ({
54
55
  display: d.display,
55
56
  onClick: function () {
56
57
  return setActiveCompConfig(d);
57
58
  },
58
- }); }) }, genActiveChartComp(activeCompConfig)));
59
+ }); }) }, genActiveChartComp(activeCompConfig, setAccordionOverflow)));
59
60
  };
60
61
  exports.DataVizAccordion = DataVizAccordion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.175.0",
3
+ "version": "2.175.2",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",