oolib 2.127.4 → 2.128.0
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/components/Modals/derivedComps/ModalSmall/index.d.ts +2 -0
- package/dist/components/Modals/derivedComps/ModalSmall/index.js +3 -2
- package/dist/components/PercentBarChart/index.d.ts +2 -1
- package/dist/components/PercentBarChart/index.js +27 -8
- package/dist/components/RadioListMultiQuestion/index.d.ts +1 -1
- package/dist/components/RadioListMultiQuestion/index.js +3 -4
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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,
|
|
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) {
|
|
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
|
|
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: "
|
|
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: "
|
|
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
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default RadioListMultiQuestion;
|
|
2
|
-
declare function RadioListMultiQuestion({ label, sublabel, options, subQuestionLabels, onChange, value
|
|
2
|
+
declare function RadioListMultiQuestion({ label, sublabel, options, subQuestionLabels, onChange, value, readOnly }: {
|
|
3
3
|
label: any;
|
|
4
4
|
sublabel: any;
|
|
5
5
|
options: any;
|
|
@@ -42,16 +42,15 @@ var BlockLabel_1 = require("../BlockLabel");
|
|
|
42
42
|
var themes_1 = require("../../themes");
|
|
43
43
|
var greyColor10 = themes_1.colors.greyColor10;
|
|
44
44
|
var RadioListMultiQuestion = function (_a) {
|
|
45
|
-
|
|
46
|
-
var
|
|
45
|
+
// const [ value, setValue ] = useState(_value);
|
|
46
|
+
var label = _a.label, sublabel = _a.sublabel, options = _a.options, subQuestionLabels = _a.subQuestionLabels, onChange = _a.onChange, value = _a.value, readOnly = _a.readOnly;
|
|
47
47
|
var handleChange = function (subQuestionValue, option) {
|
|
48
48
|
// const key = `${label.trim().replaceAll(' ','').toLowerCase()}.${subQuestionValue}`
|
|
49
49
|
var display = option.display, optionValue = option.value;
|
|
50
|
-
|
|
50
|
+
onChange(function (prevValue) {
|
|
51
51
|
var _a;
|
|
52
52
|
return (__assign(__assign({}, prevValue), (_a = {}, _a[subQuestionValue] = { display: display, value: optionValue }, _a)));
|
|
53
53
|
});
|
|
54
|
-
onChange(value);
|
|
55
54
|
};
|
|
56
55
|
return (react_1.default.createElement("div", null,
|
|
57
56
|
react_1.default.createElement(BlockLabel_1.BlockLabel, { label: label, sublabel: sublabel }),
|