oolib 2.127.3 → 2.127.5

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.
@@ -13,6 +13,7 @@ export interface ModalSmallProps {
13
13
  alignActions?: alignActionsType;
14
14
  desktopWidth?: string;
15
15
  children: ReactNode;
16
+ disableHeader: boolean;
16
17
  }
17
18
  /**
18
19
  * @component Renders a small modal component with customizable content and actions.
@@ -30,6 +31,7 @@ export interface ModalSmallProps {
30
31
  * @prop {alignActionsType} alignActions: A string indicating how the modal actions buttons should be aligned. Defaults to "right".
31
32
  * @prop {string} desktopWidth: A string indicating the width of the modal on desktop views. Defaults to "50vw".
32
33
  * @prop {React.ReactNode} children: The content to be rendered inside the modal.
34
+ * @prop {boolean} disableHeader: Disable the modal header
33
35
  * @return {ReactElement} The rendered modal component.
34
36
  */
35
37
  export declare const ModalSmall: FunctionComponent<ModalSmallProps>;
@@ -22,10 +22,11 @@ var Modal_1 = require("../../Modal");
22
22
  * @prop {alignActionsType} alignActions: A string indicating how the modal actions buttons should be aligned. Defaults to "right".
23
23
  * @prop {string} desktopWidth: A string indicating the width of the modal on desktop views. Defaults to "50vw".
24
24
  * @prop {React.ReactNode} children: The content to be rendered inside the modal.
25
+ * @prop {boolean} disableHeader: Disable the modal header
25
26
  * @return {ReactElement} The rendered modal component.
26
27
  */
27
28
  var ModalSmall = function (_a) {
28
- var title = _a.title, onClose = _a.onClose, invert = _a.invert, showActionPanel = _a.showActionPanel, _b = _a.onCloseText, onCloseText = _b === void 0 ? "Close" : _b, onConfirm = _a.onConfirm, _c = _a.onConfirmText, onConfirmText = _c === void 0 ? "Confirm" : _c, _d = _a.overflowVisible, overflowVisible = _d === void 0 ? true : _d, _e = _a.fitToContentHeight, fitToContentHeight = _e === void 0 ? true : _e, _f = _a.alignActions, alignActions = _f === void 0 ? "right" : _f, _g = _a.desktopWidth, desktopWidth = _g === void 0 ? "50vw" : _g, children = _a.children;
29
- return (react_1.default.createElement(Modal_1.Modal, { title: title, onClose: onClose, onCloseText: onCloseText, onConfirm: onConfirm, onConfirmText: onConfirmText, desktopWidth: desktopWidth, overflowVisible: overflowVisible, fitToContentHeight: fitToContentHeight, invert: invert, showActionPanel: showActionPanel, alignActions: alignActions, children: react_1.default.createElement("div", { style: { padding: "2rem" } }, children) }));
29
+ var title = _a.title, onClose = _a.onClose, invert = _a.invert, showActionPanel = _a.showActionPanel, _b = _a.onCloseText, onCloseText = _b === void 0 ? "Close" : _b, onConfirm = _a.onConfirm, _c = _a.onConfirmText, onConfirmText = _c === void 0 ? "Confirm" : _c, _d = _a.overflowVisible, overflowVisible = _d === void 0 ? true : _d, _e = _a.fitToContentHeight, fitToContentHeight = _e === void 0 ? true : _e, _f = _a.alignActions, alignActions = _f === void 0 ? "right" : _f, _g = _a.desktopWidth, desktopWidth = _g === void 0 ? "50vw" : _g, children = _a.children, disableHeader = _a.disableHeader;
30
+ return (react_1.default.createElement(Modal_1.Modal, { title: title, onClose: onClose, onCloseText: onCloseText, onConfirm: onConfirm, onConfirmText: onConfirmText, desktopWidth: desktopWidth, overflowVisible: overflowVisible, fitToContentHeight: fitToContentHeight, invert: invert, showActionPanel: showActionPanel, alignActions: alignActions, children: react_1.default.createElement("div", { style: { padding: "2rem" } }, children), disableHeader: disableHeader }));
30
31
  };
31
32
  exports.ModalSmall = ModalSmall;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPath, onClick, colors, valueSuffix, }: {
2
+ export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPath, onClick, colors, valueSuffix, showCount }: {
3
3
  data: any;
4
4
  valuePath: string;
5
5
  labelPath: string;
@@ -7,4 +7,5 @@ export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPat
7
7
  onClick?: (name: string) => void;
8
8
  colors?: string[];
9
9
  valueSuffix?: string;
10
+ showCount?: boolean;
10
11
  }) => React.JSX.Element;
@@ -49,6 +49,7 @@ var recharts_1 = require("recharts");
49
49
  var _EXPORTS_1 = require("../../utils/_EXPORTS");
50
50
  var Typo_1 = require("../Typo");
51
51
  var getTotalCount_1 = require("../../utils/getTotalCount");
52
+ var themes_1 = require("../../themes");
52
53
  var chartColors = [
53
54
  "rgb(120, 86, 255)",
54
55
  "rgb(255, 117, 86)",
@@ -69,10 +70,13 @@ var renderCustomizedLabel = function (_a) {
69
70
  return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, x: 0, y: y - offset, fill: "black", textAnchor: "start", dominantBaseline: "middle", className: "SANS_2" }, value));
70
71
  };
71
72
  var renderCustomizedValue = function (_a) {
72
- var y = _a.y, width = _a.width, height = _a.height, value = _a.value, suffix = _a.suffix, opacity = _a.opacity;
73
+ var y = _a.y, width = _a.width, height = _a.height, value = _a.value, showCount = _a.showCount, suffix = _a.suffix, opacity = _a.opacity;
73
74
  var xOffset = 5;
74
75
  var yOffset = 2;
75
- return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, fontWeight: "600", x: width + xOffset, y: y + height / 2 + yOffset, fill: "black", textAnchor: "start", dominantBaseline: "middle", className: "SANS_2" }, "".concat(value).concat(suffix || "")));
76
+ var percent = value.split("_")[0]; //cuz value here is always percentage_count;
77
+ var count = value.split("_")[1];
78
+ return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, fontWeight: "600", x: width + xOffset, y: y + height / 2 + yOffset, fill: "black", textAnchor: "start", dominantBaseline: "middle", className: "SANS_2" }, "".concat(percent).concat(suffix || ""),
79
+ react_1.default.createElement("tspan", { fill: themes_1.colors.greyColor50, y: y + height / 2 + yOffset }, showCount ? " | ".concat(count) : '')));
76
80
  };
77
81
  var _dataSample = [
78
82
  { name: "Great food", value: 72.3, Type: 0 },
@@ -85,17 +89,30 @@ var configs = {
85
89
  barGap: 32,
86
90
  };
87
91
  var PercentBarChart = function (_a) {
88
- var _b = _a.data, _data = _b === void 0 ? _dataSample : _b, title = _a.title, _c = _a.valuePath, valuePath = _c === void 0 ? "value" : _c, _d = _a.labelPath, labelPath = _d === void 0 ? "name" : _d, onClick = _a.onClick, _e = _a.colors, colors = _e === void 0 ? chartColors : _e, _f = _a.valueSuffix, valueSuffix = _f === void 0 ? "%" : _f;
92
+ var _b = _a.data, _data = _b === void 0 ? _dataSample : _b, title = _a.title, _c = _a.valuePath, valuePath = _c === void 0 ? "value" : _c, // 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
93
+ _d = _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
94
+ labelPath = _d === void 0 ? "name" : _d, onClick = _a.onClick, _e = _a.colors, colors = _e === void 0 ? chartColors : _e, _f = _a.valueSuffix, valueSuffix = _f === void 0 ? "%" : _f, _g = _a.showCount, showCount = _g === void 0 ? true : _g;
89
95
  var totalCount = (0, getTotalCount_1.getTotalCount)({ data: _data, countPath: valuePath });
90
96
  var data = (0, react_1.useMemo)(function () {
91
97
  var finalData = __spreadArray([], _data, true);
92
- finalData = finalData.map(function (d, i) { return (__assign(__assign({}, d), { value: (0, _EXPORTS_1.getPercentage)((0, _EXPORTS_1.getVal)(d, valuePath), totalCount), name: (0, _EXPORTS_1.getVal)(d, labelPath), color: colors[i % colors.length] })); });
98
+ finalData = finalData.map(function (d, i) {
99
+ var percentage = (0, _EXPORTS_1.getPercentage)((0, _EXPORTS_1.getVal)(d, valuePath), totalCount);
100
+ var count = (0, _EXPORTS_1.getVal)(d, valuePath);
101
+ return ({
102
+ // ...d,
103
+ percentage: percentage,
104
+ count: count,
105
+ percentage_count: percentage + '_' + count,
106
+ name: (0, _EXPORTS_1.getVal)(d, labelPath),
107
+ color: colors[i % colors.length],
108
+ });
109
+ });
93
110
  finalData.sort(function (a, b) {
94
111
  return Number(b.value || 0) - Number(a.value || 0);
95
112
  });
96
113
  return finalData;
97
114
  }, [_data, labelPath, valuePath]);
98
- var _g = (0, react_1.useState)(undefined), activeBar = _g[0], setActiveBar = _g[1];
115
+ var _h = (0, react_1.useState)(undefined), activeBar = _h[0], setActiveBar = _h[1];
99
116
  var changeBarOpacityFn = function (name) {
100
117
  return activeBar && activeBar !== name ? 0.4 : 1;
101
118
  };
@@ -114,7 +131,7 @@ var PercentBarChart = function (_a) {
114
131
  } },
115
132
  react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number" }),
116
133
  react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category", width: 250, dataKey: labelPath }),
117
- react_1.default.createElement(recharts_1.Bar, __assign({ radius: [2, 4, 4, 2], style: onClick ? { cursor: "pointer" } : {}, dataKey: "value" }, (onClick
134
+ react_1.default.createElement(recharts_1.Bar, __assign({ radius: [2, 4, 4, 2], style: onClick ? { cursor: "pointer" } : {}, dataKey: "percentage" }, (onClick
118
135
  ? {
119
136
  onMouseOver: function (args) { return setActiveBar(args[labelPath]); },
120
137
  onMouseOut: function () { return setActiveBar(undefined); },
@@ -131,12 +148,14 @@ var PercentBarChart = function (_a) {
131
148
  opacity: changeBarOpacityFn(props[labelPath]),
132
149
  });
133
150
  } }),
134
- react_1.default.createElement(recharts_1.LabelList, { dataKey: "value", offset: 0, content: function (props) {
151
+ react_1.default.createElement(recharts_1.LabelList, { dataKey: "percentage_count", offset: 0, content: function (props) {
152
+ console.log({ props: props });
135
153
  return renderCustomizedValue({
136
154
  y: props.y,
137
155
  width: props.width,
138
156
  height: props.height,
139
- value: props.value,
157
+ value: props.value, //here value is the percentage
158
+ showCount: showCount,
140
159
  suffix: valueSuffix,
141
160
  opacity: changeBarOpacityFn(props[labelPath]),
142
161
  });
@@ -69,10 +69,9 @@ var RadioListMultiQuestion = function (_a) {
69
69
  react_1.default.createElement(Typo_1.SANS_3, { semibold: true }, subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.display))), options === null || options === void 0 ? void 0 :
70
70
  options.map(function (option, i) {
71
71
  var _a;
72
- return (react_1.default.createElement("td", { key: "".concat(subQuestion.value, "-").concat(option === null || option === void 0 ? void 0 : option.value), style: { borderLeft: "1px solid ".concat(greyColor10) } },
72
+ return (react_1.default.createElement("td", { key: "".concat(subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.value, "-").concat(option === null || option === void 0 ? void 0 : option.value), style: { borderLeft: "1px solid ".concat(greyColor10) } },
73
73
  react_1.default.createElement(styled_1.StyledElem, null,
74
- react_1.default.createElement(RadioAndCheckbox_1.RadioButton, { isSelected: (Object.keys(value).length > 0 && (subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.value)) &&
75
- ((_a = value[subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.value]) === null || _a === void 0 ? void 0 : _a.value) === (option === null || option === void 0 ? void 0 : option.value), onClick: function () { return !readOnly && handleChange(subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.value, option); } }))));
74
+ react_1.default.createElement(RadioAndCheckbox_1.RadioButton, { isSelected: value[subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.value] && ((_a = value[subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.value]) === null || _a === void 0 ? void 0 : _a.value) === (option === null || option === void 0 ? void 0 : option.value), onClick: function () { return !readOnly && handleChange(subQuestion === null || subQuestion === void 0 ? void 0 : subQuestion.value, option); } }))));
76
75
  }))); })))));
77
76
  };
78
77
  exports.default = RadioListMultiQuestion;
@@ -28,11 +28,11 @@ var _RadioListMultiQuestion = function (args) {
28
28
  { display: 'Check the delivery date', value: 'check_delivery_date' },
29
29
  { display: 'Check for payment options', value: 'check_payment_options' },
30
30
  ], options: [
31
- { display: 'Never' },
32
- // { display: 'Rarely', value: 'rarely' },
33
- // { display: 'Sometimes', value: 'sometimes' },
34
- // { display: 'Often', value: 'often' },
35
- // { display: 'Always', value: 'always' },
31
+ { display: 'Never', value: 'never' },
32
+ { display: 'Rarely', value: 'rarely' },
33
+ { display: 'Sometimes', value: 'sometimes' },
34
+ { display: 'Often', value: 'often' },
35
+ { display: 'Always', value: 'always' },
36
36
  ], sublabel: "Select all that apply", value: value, onChange: function (d) { return setValue(d); }, readOnly: args.readOnly })));
37
37
  };
38
38
  exports._RadioListMultiQuestion = _RadioListMultiQuestion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.127.3",
3
+ "version": "2.127.5",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",