oolib 2.157.0 → 2.157.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -32,7 +32,6 @@ export { Tooltip } from "./components/Tooltip";
32
32
  export { ActionMenu } from "./components/ActionMenu";
33
33
  export { Accordion } from "./components/Accordion";
34
34
  export { PercentCompletedPie } from "./components/PercentCompletedPie";
35
- export { PercentBarChart } from "./components/PercentBarChart";
36
35
  export { Divider } from "./components/Divider";
37
36
  export { SkeletonLoader } from "./components/LoadersAndProgress/SkeletonLoader";
38
37
  export { ModalConfirm } from "./components/Modals/ModalConfirm";
package/dist/index.js CHANGED
@@ -17,8 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.ResourceInput = exports.IFrameInput = exports.PDFInput = exports.AudioInput = exports.VideoInput = exports.ProfileImageInput = exports.ImageInput = exports.MetaBlock = exports.genTagComp = exports.generateOptions = exports.OptionsSingle = exports.DropdownMulti = exports.DropdownSingle = exports.parseCardConfig = exports.ListProfile = exports.CardProfile = exports.CardEmbed = exports.DataVizAccordion = exports.BarChart = exports.DateTimeRangePicker = exports.DateTimePicker = exports.TimeRangePicker = exports.TimePicker = exports.DateRangePicker = exports.DatePicker = exports.TextLoader = exports.PageScrollIndicator = exports.HomeCover = exports.EmptyStates = exports.ModalSmall = exports.Modal = exports.ModalForms = exports.ModalConfirm = exports.SkeletonLoader = exports.Divider = exports.PercentBarChart = exports.PercentCompletedPie = exports.Accordion = exports.ActionMenu = exports.Tooltip = exports.OKELink = exports.UserRoleBadge = exports.Section = exports.LoaderOverlay = exports.Loader = exports.ProgressBar = exports.LoaderCircle = exports.icons = exports.colors = exports.GlobalStyles = void 0;
21
- exports.HintsProvider = exports.colors2 = exports.TableCellResizerPlugin = exports.styledOKELinkCSS = exports.SimpleTable = exports.ModalConfirmAction = exports.BannerProvider = exports.useBannerContext = exports.BannerContext = exports.BannerInfo = exports.BannerAlert = exports.GroupQuestionsInputSingle = void 0;
20
+ exports.GroupQuestionsInputSingle = exports.ResourceInput = exports.IFrameInput = exports.PDFInput = exports.AudioInput = exports.VideoInput = exports.ProfileImageInput = exports.ImageInput = exports.MetaBlock = exports.genTagComp = exports.generateOptions = exports.OptionsSingle = exports.DropdownMulti = exports.DropdownSingle = exports.parseCardConfig = exports.ListProfile = exports.CardProfile = exports.CardEmbed = exports.DataVizAccordion = exports.BarChart = exports.DateTimeRangePicker = exports.DateTimePicker = exports.TimeRangePicker = exports.TimePicker = exports.DateRangePicker = exports.DatePicker = exports.TextLoader = exports.PageScrollIndicator = exports.HomeCover = exports.EmptyStates = exports.ModalSmall = exports.Modal = exports.ModalForms = exports.ModalConfirm = exports.SkeletonLoader = exports.Divider = exports.PercentCompletedPie = exports.Accordion = exports.ActionMenu = exports.Tooltip = exports.OKELink = exports.UserRoleBadge = exports.Section = exports.LoaderOverlay = exports.Loader = exports.ProgressBar = exports.LoaderCircle = exports.icons = exports.colors = exports.GlobalStyles = void 0;
21
+ exports.HintsProvider = exports.colors2 = exports.TableCellResizerPlugin = exports.styledOKELinkCSS = exports.SimpleTable = exports.ModalConfirmAction = exports.BannerProvider = exports.useBannerContext = exports.BannerContext = exports.BannerInfo = exports.BannerAlert = void 0;
22
22
  //css and styling related ( styled-components )
23
23
  var globalStyles_1 = require("./globalStyles");
24
24
  Object.defineProperty(exports, "GlobalStyles", { enumerable: true, get: function () { return globalStyles_1.GlobalStyles; } });
@@ -64,8 +64,6 @@ var Accordion_1 = require("./components/Accordion");
64
64
  Object.defineProperty(exports, "Accordion", { enumerable: true, get: function () { return Accordion_1.Accordion; } });
65
65
  var PercentCompletedPie_1 = require("./components/PercentCompletedPie");
66
66
  Object.defineProperty(exports, "PercentCompletedPie", { enumerable: true, get: function () { return PercentCompletedPie_1.PercentCompletedPie; } });
67
- var PercentBarChart_1 = require("./components/PercentBarChart");
68
- Object.defineProperty(exports, "PercentBarChart", { enumerable: true, get: function () { return PercentBarChart_1.PercentBarChart; } });
69
67
  var Divider_1 = require("./components/Divider");
70
68
  Object.defineProperty(exports, "Divider", { enumerable: true, get: function () { return Divider_1.Divider; } });
71
69
  var SkeletonLoader_1 = require("./components/LoadersAndProgress/SkeletonLoader");
@@ -129,7 +129,7 @@ var BarChart = function (args) {
129
129
  // valuePath="stack1"
130
130
  labelPath: "display", title: "This is a Stacked BarChart", onClick: handleBarClick,
131
131
  // showPercent={true}
132
- colorIdx: 0 })),
132
+ colorIdx: 2 })),
133
133
  react_1.default.createElement("div", null,
134
134
  react_1.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "40px" } },
135
135
  react_1.default.createElement(BarChart_1.BarChart, { data: [
@@ -192,7 +192,7 @@ var BarChart = function (args) {
192
192
  // valuePath={["stack1", "stack2", "stack3", "stack4", "stack5", "stack6"]}
193
193
  valuePath: "stack1", labelPath: "display", title: "This is a Stacked BarChart", onClick: handleBarClick,
194
194
  // showPercent={true}
195
- colorIdx: 0 }),
195
+ colorIdx: 2 }),
196
196
  react_1.default.createElement(BarChart_1.BarChart, { data: [
197
197
  {
198
198
  display: "Logged In Once",
@@ -260,6 +260,6 @@ var BarChart = function (args) {
260
260
  // valuePath="stack1"
261
261
  breakdownDisplayType: "stacked", labelPath: "display", title: "This is a Stacked BarChart", onClick: handleBarClick,
262
262
  // showPercent={true}
263
- colorIdx: 0 })))));
263
+ colorIdx: 2 })))));
264
264
  };
265
265
  exports.BarChart = BarChart;
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { BaseConfigs } from "../..";
3
- import { DebugControls } from '../..';
2
+ import { BaseConfigs, DebugControls } from "../..";
4
3
  interface LabelData {
5
4
  percentage: number;
6
5
  count: number;
@@ -1,12 +1,33 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.CustomizedLabel = void 0;
7
- var react_1 = __importDefault(require("react"));
27
+ var react_1 = __importStar(require("react"));
8
28
  var themes_1 = require("../../../../themes");
9
29
  var colors_1 = require("../../../../themes/colors");
30
+ var TruncatedSVGText_1 = require("../TruncatedSVGText");
10
31
  var CustomizedLabel = function (_a) {
11
32
  var y = _a.y, width = _a.width, height = _a.height, value = _a.value, showPercent = _a.showPercent, showCount = _a.showCount, opacity = _a.opacity, _base_configs = _a._base_configs, _debug_controls = _a._debug_controls, onMouseOver = _a.onMouseOver, onMouseOut = _a.onMouseOut, onMouseDown = _a.onMouseDown, activeBar = _a.activeBar, TOT_HEIGHT_SINGLE_BAR_SECTION = _a.TOT_HEIGHT_SINGLE_BAR_SECTION, TOT_HEIGHT_GROUPED_BAR_SECTION = _a.TOT_HEIGHT_GROUPED_BAR_SECTION, CALC_SINGLE_BAR_SECTION_Y_POS = _a.CALC_SINGLE_BAR_SECTION_Y_POS, breakdownDisplayType = _a.breakdownDisplayType;
12
33
  if (!value)
@@ -37,12 +58,15 @@ var CustomizedLabel = function (_a) {
37
58
  return value.count;
38
59
  }
39
60
  };
61
+ var widthRef = (0, react_1.useRef)(null);
62
+ var textContainerRef = (0, react_1.useRef)(null);
40
63
  return (react_1.default.createElement("g", null,
41
- react_1.default.createElement("text", { opacity: opacity, x: _base_configs.marginLeft, dy: y - (_base_configs.labelToBarGap), fill: themes_1.colors.grey80, textAnchor: "start", className: "UI_BODY_BOLD_SM" },
64
+ react_1.default.createElement("text", { ref: textContainerRef, opacity: opacity, x: _base_configs.marginLeft, dy: y - (_base_configs.labelToBarGap), fill: themes_1.colors.grey80, textAnchor: "start", className: "UI_BODY_BOLD_SM" },
42
65
  formatValue(),
43
66
  showPercent && !isBreakdown && (react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 }, getCount())),
44
- react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 }, name)),
45
- react_1.default.createElement("rect", { style: onMouseDown ? { cursor: 'pointer' } : {}, onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, value); }, onMouseOver: function (e) { return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, value); }, onMouseOut: function (e) { return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, value); }, x: _base_configs.hoverRectStrokeWidth, y: (!isBreakdown || breakdownDisplayType === 'stacked')
67
+ react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 },
68
+ react_1.default.createElement(TruncatedSVGText_1.TruncatedSVGText, { text: name, textContainerRef: textContainerRef, widthRef: widthRef, widthOffset: -(_base_configs.marginLeft + _base_configs.marginRight) }))),
69
+ react_1.default.createElement("rect", { ref: widthRef, style: onMouseDown ? { cursor: 'pointer' } : {}, onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, value); }, onMouseOver: function (e) { return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, value); }, onMouseOut: function (e) { return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, value); }, x: _base_configs.hoverRectStrokeWidth, y: (!isBreakdown || breakdownDisplayType === 'stacked')
46
70
  ? _base_configs.hoverRectStrokeWidth + CALC_SINGLE_BAR_SECTION_Y_POS(value.dataIndex)
47
71
  : _base_configs.hoverRectStrokeWidth + (TOT_HEIGHT_GROUPED_BAR_SECTION + _base_configs.gapBetweenBarSections) * value[0].dataIndex, width: "calc(100% - ".concat(_base_configs.hoverRectStrokeWidth * 2, "px)"), height: (!isBreakdown || breakdownDisplayType === 'stacked') ? TOT_HEIGHT_SINGLE_BAR_SECTION : TOT_HEIGHT_GROUPED_BAR_SECTION, opacity: _debug_controls.mouseEventDetectorOpacity ||
48
72
  (activeBar === name ? 1 : 0), stroke: colors_1.colors.grey30, rx: 5, ry: 5, strokeWidth: "".concat(_base_configs.hoverRectStrokeWidth, "px"), fillOpacity: _debug_controls.mouseEventDetectorOpacity })));
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ export declare const TruncatedSVGText: ({ text, textContainerRef, widthRef, widthOffset }: {
3
+ text: any;
4
+ textContainerRef: any;
5
+ widthRef: any;
6
+ widthOffset?: number;
7
+ }) => React.JSX.Element;
@@ -0,0 +1,56 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.TruncatedSVGText = void 0;
27
+ var react_1 = __importStar(require("react"));
28
+ var TruncatedSVGText = function (_a) {
29
+ var _b;
30
+ var text = _a.text, textContainerRef = _a.textContainerRef, widthRef = _a.widthRef, _c = _a.widthOffset, widthOffset = _c === void 0 ? 0 : _c;
31
+ var textRef = (0, react_1.useRef)(null);
32
+ var _d = (0, react_1.useState)(false), isTextTruncated = _d[0], setIsTextTruncated = _d[1];
33
+ (0, react_1.useEffect)(function () {
34
+ var truncateText = function () {
35
+ var _a;
36
+ var element = textRef.current;
37
+ if (!element)
38
+ return;
39
+ var currentText = text;
40
+ var textWidth = textContainerRef.current.getComputedTextLength();
41
+ var totWidth = ((_a = widthRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) + widthOffset;
42
+ // Check if truncation is needed
43
+ if (textWidth > totWidth) {
44
+ setIsTextTruncated(true);
45
+ while (textWidth > totWidth && currentText.length > 0) {
46
+ currentText = currentText.slice(0, -1);
47
+ element.textContent = currentText + '...';
48
+ textWidth = textContainerRef.current.getComputedTextLength();
49
+ }
50
+ }
51
+ };
52
+ truncateText();
53
+ }, [text, (_b = widthRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width]);
54
+ return (react_1.default.createElement("tspan", { ref: textRef, onMouseOver: function () { return console.log(text); } }, text));
55
+ };
56
+ exports.TruncatedSVGText = TruncatedSVGText;
@@ -9,7 +9,6 @@ export interface BaseConfigs {
9
9
  hoverRectStrokeWidth: number;
10
10
  marginLeft: number;
11
11
  marginRight: number;
12
- startingColorIdx: number;
13
12
  gapBetweenBarsInGroup: number;
14
13
  }
15
14
  export interface DebugControls {
@@ -25,5 +24,6 @@ export interface BarChartProps {
25
24
  showCount?: boolean;
26
25
  showPercent?: boolean;
27
26
  breakdownDisplayType?: "grouped" | "stacked";
27
+ colorIdx?: number;
28
28
  }
29
29
  export declare const BarChart: React.FC<BarChartProps>;
@@ -120,7 +120,6 @@ var _base_configs = {
120
120
  //overall chart margin
121
121
  marginLeft: 6,
122
122
  marginRight: 6,
123
- startingColorIdx: 0, //this defines the idx in dataVizColors, from where color values should start being used.
124
123
  //grouped bar chart related properties
125
124
  gapBetweenBarsInGroup: 3,
126
125
  };
@@ -169,21 +168,21 @@ var barConfigs = {
169
168
  getDataKey: function (stackIndex) { return "".concat(stackIndex, ".labels.count"); },
170
169
  getStackId: function (stackIndex, breakdownDisplayType //replaced breakdownDisplayType
171
170
  ) { return (breakdownDisplayType === "stacked" ? "stack" : "stack-".concat(stackIndex)); },
172
- getCellFill: function (stackIndex, dataVizColors) {
173
- return dataVizColors[(_base_configs.startingColorIdx + stackIndex) % dataVizColors.length];
171
+ getCellFill: function (colorIdx, stackIndex, dataVizColors) {
172
+ return dataVizColors[(colorIdx + stackIndex) % dataVizColors.length];
174
173
  },
175
174
  },
176
175
  isNotBreakdown: {
177
176
  getBarRadius: function () { return _base_configs.barRadius; },
178
177
  getDataKey: function () { return "labels.count"; },
179
178
  getStackId: function () { return undefined; },
180
- getCellFill: function (_stackIndex, dataVizColors) {
181
- return dataVizColors[_base_configs.startingColorIdx];
179
+ getCellFill: function (colorIdx, _stackIndex, dataVizColors) {
180
+ return dataVizColors[colorIdx];
182
181
  },
183
182
  },
184
183
  };
185
184
  var BarChart = function (_a) {
186
- var _data = _a.data, valuePath = _a.valuePath, _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 ? false : _e;
185
+ var _data = _a.data, valuePath = _a.valuePath, _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;
187
186
  var isBreakdown = Array.isArray(valuePath);
188
187
  var data = usePrepareData({
189
188
  _data: _data,
@@ -192,7 +191,7 @@ var BarChart = function (_a) {
192
191
  isBreakdown: isBreakdown,
193
192
  showPercent: showPercent
194
193
  });
195
- var _f = (0, react_1.useState)(undefined), activeBar = _f[0], setActiveBar = _f[1];
194
+ var _g = (0, react_1.useState)(undefined), activeBar = _g[0], setActiveBar = _g[1];
196
195
  // menu options for grouped and stacked
197
196
  var renderBar = function (stackIndex, lastIndex) {
198
197
  if (stackIndex === void 0) { stackIndex = 0; }
@@ -209,7 +208,7 @@ var BarChart = function (_a) {
209
208
  width: props.width,
210
209
  height: props.height,
211
210
  value: isBreakdown
212
- ? data[props.index].map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColors[idx % colors_1.dataVizColors.length] })); })
211
+ ? data[props.index].map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColorsText[(colorIdx + idx) % colors_1.dataVizColorsText.length] })); })
213
212
  : props.value, showPercent: showPercent, showCount: showCount, opacity: 1, activeBar: activeBar, _base_configs: _base_configs, _debug_controls: _debug_controls }, (onClick
214
213
  ? {
215
214
  onMouseOver: function (e, value) {
@@ -229,7 +228,7 @@ var BarChart = function (_a) {
229
228
  : {})))); } })),
230
229
  data.map(function (d, index) { return (react_1.default.createElement(recharts_1.Cell, { y: (!isBreakdown || breakdownDisplayType === "stacked")
231
230
  ? CALC_SINGLE_BAR_SECTION_Y_POS(index) + CHART_OFFSET_TOP
232
- : CALC_GROUPED_BAR_SECTION_Y_POS(index, stackIndex, data[0].length) + CHART_OFFSET_TOP, key: "cell-".concat(index, "-").concat(stackIndex), opacity: 1, height: _base_configs.barHeight, fill: activeConfig.getCellFill(stackIndex, colors_1.dataVizColors) })); }))));
231
+ : CALC_GROUPED_BAR_SECTION_Y_POS(index, stackIndex, data[0].length) + CHART_OFFSET_TOP, key: "cell-".concat(index, "-").concat(stackIndex), opacity: 1, height: _base_configs.barHeight, fill: activeConfig.getCellFill(colorIdx, stackIndex, colors_1.dataVizColors) })); }))));
233
232
  };
234
233
  return (react_1.default.createElement("div", { style: {
235
234
  height: "".concat(isBreakdown && breakdownDisplayType === "grouped"
@@ -1,6 +1,13 @@
1
1
  import React from "react";
2
- export declare const DataVizAccordion: ({ title, chartOptions, ...props }: {
3
- [x: string]: any;
2
+ import { BarChartProps } from "../BarChart";
3
+ type ChartOptionConfig = {
4
+ display: string;
5
+ comp: 'PieChart' | 'BarChart';
6
+ props: BarChartProps;
7
+ };
8
+ interface DataVizAccordionProps extends BarChartProps {
4
9
  title?: string;
5
- chartOptions?: any[];
6
- }) => React.JSX.Element;
10
+ chartOptions: ChartOptionConfig[];
11
+ }
12
+ export declare const DataVizAccordion: React.FC<DataVizAccordionProps>;
13
+ export {};
@@ -32,7 +32,7 @@ var BarChart_1 = require("../BarChart");
32
32
  var PieChart_1 = require("../PieChart");
33
33
  var Accordion_1 = require("../Accordion");
34
34
  var DataVizAccordion = function (_a) {
35
- var _b = _a.title, title = _b === void 0 ? "some title" : _b, _c = _a.chartOptions, chartOptions = _c === void 0 ? [] : _c, props = __rest(_a, ["title", "chartOptions"]);
35
+ var title = _a.title, _b = _a.chartOptions, chartOptions = _b === void 0 ? [] : _b, props = __rest(_a, ["title", "chartOptions"]);
36
36
  var ChartComps = {
37
37
  PieChart: {
38
38
  comp: PieChart_1.PieChart,
@@ -40,23 +40,20 @@ var DataVizAccordion = function (_a) {
40
40
  },
41
41
  BarChart: {
42
42
  comp: BarChart_1.BarChart,
43
- wrapperStyle: { padding: "0 1rem 0.6rem 1rem" } // to offset the 6px left & right margins on the bar chart, so that the bars align with the header text
43
+ wrapperStyle: { padding: "0 1rem 0.6rem 1rem" }
44
44
  },
45
45
  };
46
- var _d = (0, react_2.useState)(chartOptions[0]), activeCompConfig = _d[0], setActiveCompConfig = _d[1];
46
+ var _c = (0, react_2.useState)(chartOptions[0]), activeCompConfig = _c[0], setActiveCompConfig = _c[1];
47
47
  var genActiveChartComp = function (activeCompConfig) {
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))));
52
52
  };
53
- return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, actionsConfig: chartOptions.map(function (d) { return ({
53
+ return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, actionsConfig: chartOptions.length > 1 && chartOptions.map(function (d) { return ({
54
54
  display: d.display,
55
55
  onClick: function () {
56
- return setActiveCompConfig({
57
- comp: d.comp,
58
- props: d.props,
59
- });
56
+ return setActiveCompConfig(d);
60
57
  },
61
58
  }); }) }, genActiveChartComp(activeCompConfig)));
62
59
  };
@@ -1,4 +1,5 @@
1
1
  export declare const dataVizColors: string[];
2
+ export declare const dataVizColorsText: string[];
2
3
  export declare const colors: {
3
4
  primary: string;
4
5
  secondary: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.colors = exports.dataVizColors = void 0;
3
+ exports.colors = exports.dataVizColorsText = exports.dataVizColors = void 0;
4
4
  var primary = "#006686";
5
5
  var secondary = "#456272";
6
6
  var tertiary = "#764F8B";
@@ -61,20 +61,16 @@ exports.dataVizColors = [
61
61
  "#AC8E68",
62
62
  "#CF8AF2",
63
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
- // ]
64
+ exports.dataVizColorsText = [
65
+ "#E92519",
66
+ "#0A8D1E",
67
+ "#C57800",
68
+ "#197BDE",
69
+ "#997F00",
70
+ "#13918C",
71
+ "#93662D",
72
+ "#B554E6",
73
+ ];
78
74
  exports.colors = {
79
75
  primary: primary,
80
76
  secondary: secondary,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.157.0",
3
+ "version": "2.157.1",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,20 +0,0 @@
1
- import React from "react";
2
- import { TBaseConfigs } from "../..";
3
- type TCustomizedLabeValue = {
4
- percentage: number;
5
- count: number;
6
- name: string;
7
- };
8
- export declare const CustomizedLabel: ({ y, width, height, value, plotDataPoint, opacity, _base_configs, onMouseOver, onMouseOut, onMouseDown, }: {
9
- y?: number | string;
10
- width?: number | string;
11
- height?: number | string;
12
- value?: TCustomizedLabeValue;
13
- opacity: number;
14
- plotDataPoint?: "percentage" | "count";
15
- _base_configs: TBaseConfigs;
16
- onMouseOver?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
17
- onMouseOut?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
18
- onMouseDown?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
19
- }) => React.JSX.Element;
20
- export {};
@@ -1,30 +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.CustomizedLabel = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var themes_1 = require("../../../../themes");
9
- var CustomizedLabel = function (_a) {
10
- var y = _a.y, width = _a.width, //i think this is the width and the height of the bar. dont need it just yet..
11
- height = _a.height, value = _a.value, plotDataPoint = _a.plotDataPoint, opacity = _a.opacity, _base_configs = _a._base_configs, onMouseOver = _a.onMouseOver, onMouseOut = _a.onMouseOut, onMouseDown = _a.onMouseDown;
12
- var yOffset = -(_base_configs.labelToBarGap + _base_configs.barHeight);
13
- var percent = value.percentage;
14
- var count = value.count;
15
- var name = value.name;
16
- var percentXOffset = 0;
17
- var xOffsetRelative = 10;
18
- return (react_1.default.createElement("g", null,
19
- react_1.default.createElement("text", { opacity: opacity, x: percentXOffset, y: y + yOffset, fill: themes_1.colors.greyColor100, textAnchor: "start", dominantBaseline: "middle", className: "UI_BODY_BOLD_SM" },
20
- plotDataPoint === "percentage"
21
- ? percent + "%"
22
- : plotDataPoint === "count"
23
- ? count
24
- : "",
25
- plotDataPoint === "percentage" && ( // basically no need to show this only if plotDataPoint is count, since in that case, count is already shown above
26
- react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, y: y + yOffset, fill: themes_1.colors.greyColor80 }, count)),
27
- react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, y: y + yOffset, fill: themes_1.colors.greyColor80 }, name)),
28
- react_1.default.createElement("rect", { onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, value); }, onMouseOver: function (e) { return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, value); }, onMouseOut: function (e) { return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, value); }, x: percentXOffset, y: y + _base_configs.mouseEventDetectorYOffset, width: width, height: _base_configs.mouseEventDetectorHeight, fill: "red", "fill-opacity": _base_configs.mouseEventDetectorOpacity })));
29
- };
30
- exports.CustomizedLabel = CustomizedLabel;
@@ -1,22 +0,0 @@
1
- import React from "react";
2
- export type TBaseConfigs = {
3
- barHeight: number;
4
- labelToBarGap: number;
5
- barGap: number;
6
- mouseEventDetectorYOffset: number;
7
- mouseEventDetectorHeight: number;
8
- mouseEventDetectorOpacity: number;
9
- };
10
- export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPath, onClick, colors, colorIdx, plotDataPoint, }: {
11
- data: any;
12
- valuePath: string;
13
- labelPath: string;
14
- title?: string;
15
- onClick?: (name: string) => void;
16
- colors?: string[];
17
- colorIdx?: number;
18
- valueSuffix?: string;
19
- plotDataPoint?: 'percentage' | 'count';
20
- showCount?: boolean;
21
- showPercent?: boolean;
22
- }) => React.JSX.Element;
@@ -1,153 +0,0 @@
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.PercentBarChart = void 0;
47
- var react_1 = __importStar(require("react"));
48
- var recharts_1 = require("recharts");
49
- var _EXPORTS_1 = require("../../utils/_EXPORTS");
50
- var Typo_1 = require("../Typo");
51
- var getTotalCount_1 = require("../../utils/getTotalCount");
52
- var CustomizedLabel_1 = require("./comps/CustomizedLabel");
53
- var chartColors = [
54
- "#5C80FF",
55
- "#FFA800",
56
- "#00BC8F",
57
- "#FF51CE",
58
- "rgb(173, 89, 108)",
59
- "rgb(114, 190, 244)",
60
- "rgb(255, 178, 122)",
61
- "rgb(14, 126, 161)",
62
- "rgb(60, 169, 116)",
63
- "rgb(254, 187, 178)",
64
- "rgb(204, 128, 217)",
65
- "rgb(91, 184, 175)",
66
- ];
67
- //if any changes are being made to the spacing and such of
68
- //this comps design, all these properties need to be carefully
69
- //observed and tweaked to ensure no ui has gotten warped due to sideeffects
70
- var _base_configs = {
71
- barRadius: 16,
72
- barHeight: 6,
73
- labelToBarGap: 6,
74
- barGap: 30,
75
- wrapperMarginBottom: -16,
76
- barCategoryGap: 18, // does some wierd shit really, simply pushes the entire graph down by this number. We need to to unhide the first label, which is happening only because we are using <Cell/> comp. too many inconsistencies in recharts
77
- mouseEventDetectorYOffset: -34, //this is inside CustomizedLabel. a big rect spread across the bar and label and gap to detect mouse events and transition smoothly to the next bar.
78
- mouseEventDetectorHeight: 40,
79
- mouseEventDetectorOpacity: 0 //only increase this for debugging. nothing else.
80
- };
81
- var PercentBarChart = function (_a) {
82
- var _data = _a.data, title = _a.title, _b = _a.valuePath, valuePath = _b === void 0 ? "value" : _b, // is relevant only for the initial data setting in useMemo. after that, the actual percentage is always stored against the 'percentage' key, and the count against the 'count' key
83
- _c = _a.labelPath, // is relevant only for the initial data setting in useMemo. after that, the actual percentage is always stored against the 'percentage' key, and the count against the 'count' key
84
- labelPath = _c === void 0 ? "name" : _c, // same as above for label path
85
- onClick = _a.onClick, _d = _a.colors, colors = _d === void 0 ? chartColors : _d, _e = _a.colorIdx, colorIdx = _e === void 0 ? 0 : _e, //if you are rendering a grid of such charts, then maybe you want each of their colors to be different. in that case, increment this idx from the parent component
86
- _f = _a.plotDataPoint, //if you are rendering a grid of such charts, then maybe you want each of their colors to be different. in that case, increment this idx from the parent component
87
- plotDataPoint = _f === void 0 ? 'percentage' : _f;
88
- var totalCount = (0, getTotalCount_1.getTotalCount)({ data: _data, countPath: valuePath });
89
- var data = (0, react_1.useMemo)(function () {
90
- var finalData = __spreadArray([], _data, true);
91
- finalData = finalData.map(function (d, i) {
92
- var count = (0, _EXPORTS_1.getVal)(d, valuePath);
93
- return ({
94
- labels: __assign(__assign({}, (plotDataPoint === 'percentage' ? { percentage: (0, _EXPORTS_1.getPercentage)((0, _EXPORTS_1.getVal)(d, valuePath), totalCount) } : {})), { count: count, name: (0, _EXPORTS_1.getVal)(d, labelPath) }),
95
- });
96
- });
97
- finalData.sort(function (a, b) {
98
- return Number((0, _EXPORTS_1.getVal)(b, "labels.".concat(plotDataPoint)) || 0) - Number((0, _EXPORTS_1.getVal)(a, "labels.".concat(plotDataPoint)) || 0);
99
- });
100
- return finalData;
101
- }, [_data, labelPath, valuePath]);
102
- var _g = (0, react_1.useState)(undefined), activeBar = _g[0], setActiveBar = _g[1];
103
- var changeBarOpacityFn = function (name) {
104
- return activeBar && activeBar !== name ? 0.4 : 1;
105
- };
106
- return (react_1.default.createElement("div", null,
107
- title && (react_1.default.createElement(Typo_1.SANS_4_5, { style: { paddingBottom: "2rem" }, semibold: true }, title)),
108
- react_1.default.createElement("div", { style: {
109
- height: "".concat(((_base_configs.barHeight + _base_configs.barGap) * data.length), "px"),
110
- width: "100%",
111
- } },
112
- react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: "100%" },
113
- react_1.default.createElement(recharts_1.BarChart, { width: 500, height: 500, barCategoryGap: _base_configs.barCategoryGap,
114
- // barSize={_base_configs.barHeight}
115
- data: data, layout: "vertical", margin: {
116
- top: 0,
117
- right: 0,
118
- left: 0,
119
- bottom: _base_configs.wrapperMarginBottom,
120
- }, onMouseEnter: function () {
121
- var args = [];
122
- for (var _i = 0; _i < arguments.length; _i++) {
123
- args[_i] = arguments[_i];
124
- }
125
- return console.log('mouse enter', args);
126
- }, onMouseLeave: function () {
127
- var args = [];
128
- for (var _i = 0; _i < arguments.length; _i++) {
129
- args[_i] = arguments[_i];
130
- }
131
- return console.log('mouse leave', args);
132
- } },
133
- react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number" }),
134
- react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
135
- react_1.default.createElement(recharts_1.Bar, { radius: _base_configs.barRadius, style: onClick ? { cursor: "pointer" } : {}, dataKey: "labels.".concat(plotDataPoint) },
136
- react_1.default.createElement(recharts_1.LabelList, { dataKey: "labels", offset: 0, content: function (props) { return react_1.default.createElement(CustomizedLabel_1.CustomizedLabel, __assign({ y: props.y,
137
- width: props.width,
138
- height: props.height,
139
- value: props.value, //here value is the percentage
140
- plotDataPoint: plotDataPoint, opacity: changeBarOpacityFn(props.value.name), _base_configs: _base_configs }, (onClick
141
- ? {
142
- onMouseOver: function (e, value) { return setActiveBar(value.name); },
143
- onMouseOut: function () { return setActiveBar(undefined); },
144
- onMouseDown: function (e, value) {
145
- setActiveBar(value.name);
146
- onClick(value.name);
147
- },
148
- }
149
- : {}))); } }),
150
- data.map(function (d, index) { return (react_1.default.createElement(react_1.default.Fragment, null,
151
- react_1.default.createElement(recharts_1.Cell, { opacity: changeBarOpacityFn(d.labels.name), key: "cell-".concat(index), height: _base_configs.barHeight, fill: colors[colorIdx] }))); })))))));
152
- };
153
- exports.PercentBarChart = PercentBarChart;
@@ -1,6 +0,0 @@
1
- declare namespace _default {
2
- let title: string;
3
- }
4
- export default _default;
5
- export function PercentBarChart_(args: any): React.JSX.Element;
6
- import React from 'react';
@@ -1,25 +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.PercentBarChart_ = void 0;
7
- var react_1 = __importDefault(require("react"));
8
- var PercentBarChart_1 = require("../../../components/PercentBarChart");
9
- exports.default = {
10
- title: "Components/PercentBarChart",
11
- };
12
- var data = [
13
- { display: 'Logged In Once', value: 60 },
14
- { display: 'Registered Users', value: 100 },
15
- { display: 'Created Profile', value: 20 },
16
- { display: 'Wrote at least 1 story', value: 8 }
17
- ];
18
- var PercentBarChart_ = function (args) {
19
- var handleBarClick = function (name) {
20
- console.log("Bar clicked: ".concat(name));
21
- };
22
- return (react_1.default.createElement("div", null,
23
- react_1.default.createElement(PercentBarChart_1.PercentBarChart, { data: data, labelPath: "display", valuePath: "value", title: "This is PercentBarChart representing the data", onClick: handleBarClick })));
24
- };
25
- exports.PercentBarChart_ = PercentBarChart_;