oolib 2.199.4 → 2.199.6
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/v2/components/cards/CardContent/index.js +5 -1
- package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/OptimizedTooltip.d.ts +8 -0
- package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/OptimizedTooltip.js +118 -0
- package/dist/v2/components/dataviz/BarChart/index.js +2 -9
- package/package.json +1 -1
|
@@ -69,6 +69,10 @@ var CardContent = function (_a) {
|
|
|
69
69
|
react_1.default.createElement(LineClampWrapper_1.LineClampWrapper, { title: title, noOfLines_M: 6 },
|
|
70
70
|
react_1.default.createElement(styled_1.StyledTitle, { capitalize: true, className: "StyledTitle" }, localize(title))))) : null,
|
|
71
71
|
description ? (react_1.default.createElement(styled_2.StyledDescription, null,
|
|
72
|
-
react_1.default.createElement(LineClampWrapper_1.LineClampWrapper, { title: description, noOfLines_M: 6 }, description))) : null)
|
|
72
|
+
react_1.default.createElement(LineClampWrapper_1.LineClampWrapper, { title: description, noOfLines_M: 6 }, description))) : null),
|
|
73
|
+
react_1.default.createElement("div", null, (metaBlock === null || metaBlock === void 0 ? void 0 : metaBlock.length) > 0 ? (
|
|
74
|
+
//show only two meta for cardContent
|
|
75
|
+
react_1.default.createElement(styled_2.StyledMetaBlockWrapper, null,
|
|
76
|
+
react_1.default.createElement(MetaBlock_1.default, { data: data, config: metaBlock }))) : null))));
|
|
73
77
|
};
|
|
74
78
|
exports.CardContent = CardContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TooltipProps } from "recharts";
|
|
3
|
+
interface OptimizedTooltipProps extends TooltipProps<number, string> {
|
|
4
|
+
showPercent?: boolean;
|
|
5
|
+
breakdownCategoryName?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const OptimizedTooltip: React.FC<OptimizedTooltipProps>;
|
|
8
|
+
export default OptimizedTooltip;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
var react_1 = __importStar(require("react"));
|
|
44
|
+
var styled_components_1 = __importDefault(require("styled-components"));
|
|
45
|
+
var __1 = require("../../../../../..");
|
|
46
|
+
var Typo2_1 = require("../../../../Typo2");
|
|
47
|
+
var LegendTooltipGlyph_1 = require("../LegendTooltipGlyph");
|
|
48
|
+
var UI_CAPTION_DF_WITH_LINE_CLAMP = (0, styled_components_1.default)(Typo2_1.UI_CAPTION_DF)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n /* ", " */\n"], ["\n /* ", " */\n"])), function (_a) {
|
|
49
|
+
var clampT = _a.clampT;
|
|
50
|
+
return (clampT ? (0, __1.clampText)(3) : "");
|
|
51
|
+
});
|
|
52
|
+
var OptimizedTooltip = (0, react_1.memo)(function (_a) {
|
|
53
|
+
var _b, _c;
|
|
54
|
+
var active = _a.active, payload = _a.payload, label = _a.label, _d = _a.showPercent, showPercent = _d === void 0 ? false : _d, breakdownCategoryName = _a.breakdownCategoryName;
|
|
55
|
+
// Early return for better performance
|
|
56
|
+
if (!active || !(payload === null || payload === void 0 ? void 0 : payload.length))
|
|
57
|
+
return null;
|
|
58
|
+
// Transform payload data to match your original tooltip structure
|
|
59
|
+
var value = ((_c = (_b = payload === null || payload === void 0 ? void 0 : payload[0]) === null || _b === void 0 ? void 0 : _b.payload) === null || _c === void 0 ? void 0 : _c.map(function (entry) {
|
|
60
|
+
return {
|
|
61
|
+
barColor: entry.labels.barColor,
|
|
62
|
+
percentage: entry.labels.percentage || 0,
|
|
63
|
+
count: entry.labels.count,
|
|
64
|
+
tooltipLabel: entry.labels.tooltipLabel,
|
|
65
|
+
name: entry.labels.name,
|
|
66
|
+
};
|
|
67
|
+
})) || [];
|
|
68
|
+
var style = {
|
|
69
|
+
backgroundColor: __1.colors2.black,
|
|
70
|
+
color: __1.colors2.white,
|
|
71
|
+
border: "1px solid ".concat(__1.colors2.grey10),
|
|
72
|
+
borderRadius: "6px",
|
|
73
|
+
padding: "8px",
|
|
74
|
+
boxShadow: "0px 4px 10px 0px rgba(0, 0, 0, 0.12)",
|
|
75
|
+
zIndex: 100000,
|
|
76
|
+
width: "max-content",
|
|
77
|
+
maxWidth: "300px",
|
|
78
|
+
maxHeight: "500px",
|
|
79
|
+
overflow: "auto",
|
|
80
|
+
display: "flex",
|
|
81
|
+
flexDirection: "column",
|
|
82
|
+
gap: "1rem",
|
|
83
|
+
fontSize: "12px",
|
|
84
|
+
};
|
|
85
|
+
return (react_1.default.createElement(react_1.Fragment, null,
|
|
86
|
+
react_1.default.createElement("div", { style: style },
|
|
87
|
+
breakdownCategoryName && (react_1.default.createElement(Typo2_1.UI_CAPTION_BOLD_DF, null, breakdownCategoryName)),
|
|
88
|
+
react_1.default.createElement("div", { style: {
|
|
89
|
+
display: "grid",
|
|
90
|
+
gridTemplateColumns: showPercent ? "auto auto auto" : "auto auto",
|
|
91
|
+
gap: "0.6rem",
|
|
92
|
+
} },
|
|
93
|
+
react_1.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" } }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: index },
|
|
94
|
+
react_1.default.createElement("div", { style: {
|
|
95
|
+
display: "flex",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
gap: "0.6rem",
|
|
98
|
+
} },
|
|
99
|
+
react_1.default.createElement(LegendTooltipGlyph_1.LegendTooltipGlyph, { color: entry.barColor }),
|
|
100
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_BOLD_DF, null, showPercent
|
|
101
|
+
? entry.percentage + "%"
|
|
102
|
+
: entry.count || "0")))); })),
|
|
103
|
+
showPercent && (react_1.default.createElement("div", { style: {
|
|
104
|
+
display: "flex",
|
|
105
|
+
flexDirection: "column",
|
|
106
|
+
gap: "1rem",
|
|
107
|
+
} }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: index },
|
|
108
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_DF, null, entry.count || "0"))); }))),
|
|
109
|
+
react_1.default.createElement("div", { style: {
|
|
110
|
+
paddingLeft: "0.8rem",
|
|
111
|
+
display: "flex",
|
|
112
|
+
flexDirection: "column",
|
|
113
|
+
gap: "1rem",
|
|
114
|
+
} }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: index },
|
|
115
|
+
react_1.default.createElement(UI_CAPTION_DF_WITH_LINE_CLAMP, null, entry.tooltipLabel))); }))))));
|
|
116
|
+
});
|
|
117
|
+
exports.default = OptimizedTooltip;
|
|
118
|
+
var templateObject_1;
|
|
@@ -55,8 +55,8 @@ var CustomizedLabel_1 = require("./comps/CustomizedLabel");
|
|
|
55
55
|
var __1 = require("../../../..");
|
|
56
56
|
var usePrepareData_1 = require("../utils/usePrepareData");
|
|
57
57
|
var _base_barchart_ui_configs_1 = require("./_base_barchart_ui_configs");
|
|
58
|
-
var CustomTooltip_1 = __importDefault(require("./comps/CustomTooltip"));
|
|
59
58
|
var Legend_1 = require("./comps/Legend");
|
|
59
|
+
var OptimizedTooltip_1 = __importDefault(require("./comps/CustomTooltip/OptimizedTooltip"));
|
|
60
60
|
var useTrackMousePosition = function () {
|
|
61
61
|
var _a = (0, react_1.useState)({
|
|
62
62
|
x: 0,
|
|
@@ -268,14 +268,7 @@ var BarChartRenderer = function (_a) {
|
|
|
268
268
|
} },
|
|
269
269
|
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number", domain: [0, dataMaxValue] }),
|
|
270
270
|
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
|
|
271
|
-
isBreakdown && (react_1.default.createElement(recharts_1.Tooltip, { content:
|
|
272
|
-
var _a;
|
|
273
|
-
return (react_1.default.createElement(CustomTooltip_1.default, __assign({}, props, { breakdownCategoryName: breakdownCategoryName, activeBar: activeBar, mousePosition: mousePosition, showPercent: showPercent,
|
|
274
|
-
// god knows why the dataindex gets stored against props.label.
|
|
275
|
-
// this is some internal recharts thing for tooltips specifically.
|
|
276
|
-
// we dont do this.
|
|
277
|
-
value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign({}, item.labels)); }) })));
|
|
278
|
-
}, cursor: false, allowEscapeViewBox: { x: true, y: true } })),
|
|
271
|
+
isBreakdown && (react_1.default.createElement(recharts_1.Tooltip, { cursor: false, content: react_1.default.createElement(OptimizedTooltip_1.default, null), animationDuration: 0, isAnimationActive: false, allowEscapeViewBox: { x: false, y: false }, position: { x: undefined, y: undefined } })),
|
|
279
272
|
isBreakdown
|
|
280
273
|
? data[0].map(function (_, stackIndex) {
|
|
281
274
|
//note that this map renders the individual bars within a breakdown group
|