oolib 2.201.1 → 2.202.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/SimpleTable/index.js +3 -2
- package/dist/stories/Oolib/components/SimpleTable.stories.d.ts +1 -0
- package/dist/stories/Oolib/components/SimpleTable.stories.js +3 -1
- package/dist/stories/v2/components/cards/CardContent.stories.d.ts +5 -0
- package/dist/stories/v2/components/cards/ListContent.stories.d.ts +5 -0
- package/dist/stories/v2/components/cards/utils/cardArgTypes.d.ts +26 -18
- package/dist/stories/v2/components/cards/utils/cardArgTypes.js +5 -0
- package/dist/stories/v2/components/cards/utils/parseCardArgs.d.ts +4 -1
- package/dist/stories/v2/components/cards/utils/parseCardArgs.js +4 -3
- package/dist/v2/components/cards/CardContent/index.d.ts +2 -1
- package/dist/v2/components/cards/CardContent/index.js +5 -5
- package/dist/v2/components/cards/ListContent/index.d.ts +3 -2
- package/dist/v2/components/cards/ListContent/index.js +5 -5
- package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/index.js +3 -3
- package/dist/v2/components/dataviz/BarChart/index.d.ts +5 -2
- package/dist/v2/components/dataviz/BarChart/index.js +48 -25
- package/dist/v2/components/dataviz/BarGraphCollection/index.js +5 -13
- package/dist/v2/components/dataviz/HeatMapGrid/index.js +8 -8
- package/dist/v2/components/dataviz/HeatMapGrid/utils/useAxisMeasure.js +2 -2
- package/dist/v2/components/dataviz/PieChart/index.js +5 -8
- package/package.json +1 -1
|
@@ -103,6 +103,7 @@ function SimpleTable(_a) {
|
|
|
103
103
|
blockConfig: [undefined, { comp: 'DropdownSingle', props: {} }, { comp: 'DropdownSingle', props: {} }]
|
|
104
104
|
} : _b, _value = _a.value, onChange = _a.onChange, _c = _a.defaultColWidth, defaultColWidth = _c === void 0 ? 200 : _c;
|
|
105
105
|
var props = arguments[0];
|
|
106
|
+
var localize = (0, utilsOolib_1.useLocale)();
|
|
106
107
|
var theme = (0, styled_components_1.useTheme)();
|
|
107
108
|
var _d = theme || {}, RichTextEditor = _d.RichTextEditor /*: _RichTextEditor*/, convertToRichText = _d.convertToRichText;
|
|
108
109
|
//memoizing cuz we dont want all cell rtes to render everytime one cell changes
|
|
@@ -271,7 +272,7 @@ function SimpleTable(_a) {
|
|
|
271
272
|
react_1.default.createElement(Typo2_1.UI_BODY_BOLD_SM, null, config.headerForRowHeadersColumn),
|
|
272
273
|
react_1.default.createElement(ArrowDown, { size: 14, weight: "bold" })))) : (genCell({
|
|
273
274
|
cell: (0, convertRowHeaderConfigToCellData_1.convertRowHeaderConfigToCellData)({
|
|
274
|
-
rowHeaderData: config.rowHeaderData,
|
|
275
|
+
rowHeaderData: config.rowHeaderData.map(function (d) { return localize(d); }),
|
|
275
276
|
convertToRichText: convertToRichText,
|
|
276
277
|
rowIdx: rowIdx
|
|
277
278
|
}),
|
|
@@ -343,7 +344,7 @@ function SimpleTable(_a) {
|
|
|
343
344
|
config.colHeaderData &&
|
|
344
345
|
genRow({
|
|
345
346
|
row: (0, convertColHeaderConfigToRowData_1.convertColHeaderConfigToRowData)({
|
|
346
|
-
colHeaderData: config.colHeaderData,
|
|
347
|
+
colHeaderData: config.colHeaderData.map(function (d) { return localize(d); }),
|
|
347
348
|
convertToRichText: convertToRichText,
|
|
348
349
|
}),
|
|
349
350
|
}),
|
|
@@ -84,6 +84,7 @@ exports.default = {
|
|
|
84
84
|
defaultColWidth: 200,
|
|
85
85
|
disableAddRow: false,
|
|
86
86
|
disableRowActionsMenu: false,
|
|
87
|
+
readOnly: false,
|
|
87
88
|
},
|
|
88
89
|
parameters: {
|
|
89
90
|
docs: {
|
|
@@ -113,7 +114,8 @@ var SimpleTable = function (args) {
|
|
|
113
114
|
},
|
|
114
115
|
defaultColWidth: args.defaultColWidth,
|
|
115
116
|
value: val,
|
|
116
|
-
onChange: function (k, v) { return setVal(v); }
|
|
117
|
+
onChange: function (k, v) { return setVal(v); },
|
|
118
|
+
readOnly: args.readOnly
|
|
117
119
|
};
|
|
118
120
|
// useEffect(() => {
|
|
119
121
|
// console.log({data: props})
|
|
@@ -85,43 +85,51 @@ export namespace commonCardArgTypes {
|
|
|
85
85
|
let options_2: string[];
|
|
86
86
|
export { options_2 as options };
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
export namespace cardContentArgTypes {
|
|
90
|
-
export namespace tagDisplay {
|
|
88
|
+
export namespace labelTagColorPreset {
|
|
91
89
|
let name_9: string;
|
|
92
90
|
export { name_9 as name };
|
|
93
|
-
|
|
94
|
-
let type: string;
|
|
95
|
-
}
|
|
91
|
+
let control_9: string;
|
|
96
92
|
export { control_9 as control };
|
|
93
|
+
let options_3: string[];
|
|
94
|
+
export { options_3 as options };
|
|
97
95
|
}
|
|
98
|
-
|
|
96
|
+
}
|
|
97
|
+
export namespace cardContentArgTypes {
|
|
98
|
+
export namespace tagDisplay {
|
|
99
99
|
let name_10: string;
|
|
100
100
|
export { name_10 as name };
|
|
101
101
|
export namespace control_10 {
|
|
102
|
+
let type: string;
|
|
103
|
+
}
|
|
104
|
+
export { control_10 as control };
|
|
105
|
+
}
|
|
106
|
+
export namespace desc_1 {
|
|
107
|
+
let name_11: string;
|
|
108
|
+
export { name_11 as name };
|
|
109
|
+
export namespace control_11 {
|
|
102
110
|
let type_1: string;
|
|
103
111
|
export { type_1 as type };
|
|
104
112
|
}
|
|
105
|
-
export {
|
|
113
|
+
export { control_11 as control };
|
|
106
114
|
}
|
|
107
115
|
export { desc_1 as desc };
|
|
108
116
|
}
|
|
109
117
|
export namespace listContentArgTypes {
|
|
110
118
|
namespace statusTag {
|
|
111
|
-
let
|
|
112
|
-
export {
|
|
113
|
-
export namespace
|
|
119
|
+
let name_12: string;
|
|
120
|
+
export { name_12 as name };
|
|
121
|
+
export namespace control_12 {
|
|
114
122
|
let type_2: string;
|
|
115
123
|
export { type_2 as type };
|
|
116
124
|
}
|
|
117
|
-
export {
|
|
125
|
+
export { control_12 as control };
|
|
118
126
|
}
|
|
119
127
|
namespace variant {
|
|
120
|
-
let
|
|
121
|
-
export {
|
|
122
|
-
let
|
|
123
|
-
export {
|
|
124
|
-
let
|
|
125
|
-
export {
|
|
128
|
+
let name_13: string;
|
|
129
|
+
export { name_13 as name };
|
|
130
|
+
let control_13: string;
|
|
131
|
+
export { control_13 as control };
|
|
132
|
+
let options_4: string[];
|
|
133
|
+
export { options_4 as options };
|
|
126
134
|
}
|
|
127
135
|
}
|
|
@@ -54,6 +54,11 @@ exports.commonCardArgTypes = {
|
|
|
54
54
|
control: 'select',
|
|
55
55
|
options: [undefined, 'primary', 'secondary', 'positive', 'inProgress', 'warning', 'negative', 'special', 'grey'],
|
|
56
56
|
},
|
|
57
|
+
labelTagColorPreset: {
|
|
58
|
+
name: "Label Tag Color preset",
|
|
59
|
+
control: 'select',
|
|
60
|
+
options: [undefined, 'primary', 'secondary', 'positive', 'inProgress', 'warning', 'negative', 'special', 'grey'],
|
|
61
|
+
},
|
|
57
62
|
};
|
|
58
63
|
exports.cardContentArgTypes = {
|
|
59
64
|
tagDisplay: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function parseCardArgs({ cardLabel, title, mediaType, image, video, metaName, metaDate, statusTag, disabled, tagDisplay, highlight, desc, statusTagColorPreset }: {
|
|
1
|
+
export function parseCardArgs({ cardLabel, title, mediaType, image, video, metaName, metaDate, statusTag, disabled, tagDisplay, highlight, desc, statusTagColorPreset, labelTagColorPreset }: {
|
|
2
2
|
cardLabel: any;
|
|
3
3
|
title: any;
|
|
4
4
|
mediaType: any;
|
|
@@ -12,6 +12,7 @@ export function parseCardArgs({ cardLabel, title, mediaType, image, video, metaN
|
|
|
12
12
|
highlight: any;
|
|
13
13
|
desc: any;
|
|
14
14
|
statusTagColorPreset: any;
|
|
15
|
+
labelTagColorPreset: any;
|
|
15
16
|
}): {
|
|
16
17
|
data: {
|
|
17
18
|
title: any;
|
|
@@ -40,9 +41,11 @@ export function parseCardArgs({ cardLabel, title, mediaType, image, video, metaN
|
|
|
40
41
|
cardLabel: string;
|
|
41
42
|
tagDisplay: string;
|
|
42
43
|
statusTagColorPreset: string;
|
|
44
|
+
labelTagColorPreset: string;
|
|
43
45
|
desc: string;
|
|
44
46
|
};
|
|
45
47
|
disabled: any;
|
|
46
48
|
highlight: any;
|
|
47
49
|
statusTagColorPreset: any;
|
|
50
|
+
labelTagColorPreset: any;
|
|
48
51
|
};
|
|
@@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.parseCardArgs = void 0;
|
|
24
24
|
var parseCardArgs = function (_a) {
|
|
25
|
-
var cardLabel = _a.cardLabel, title = _a.title, mediaType = _a.mediaType, image = _a.image, video = _a.video, metaName = _a.metaName, metaDate = _a.metaDate, statusTag = _a.statusTag, disabled = _a.disabled, tagDisplay = _a.tagDisplay, highlight = _a.highlight, desc = _a.desc, statusTagColorPreset = _a.statusTagColorPreset;
|
|
25
|
+
var cardLabel = _a.cardLabel, title = _a.title, mediaType = _a.mediaType, image = _a.image, video = _a.video, metaName = _a.metaName, metaDate = _a.metaDate, statusTag = _a.statusTag, disabled = _a.disabled, tagDisplay = _a.tagDisplay, highlight = _a.highlight, desc = _a.desc, statusTagColorPreset = _a.statusTagColorPreset, labelTagColorPreset = _a.labelTagColorPreset;
|
|
26
26
|
var data = {
|
|
27
27
|
title: title,
|
|
28
28
|
cardLabel: cardLabel,
|
|
@@ -34,14 +34,15 @@ var parseCardArgs = function (_a) {
|
|
|
34
34
|
tagDisplay: tagDisplay,
|
|
35
35
|
desc: desc,
|
|
36
36
|
};
|
|
37
|
-
var config = __assign(__assign(__assign({ title: "title", cardLabel: "cardLabel", tagDisplay: "tagDisplay", statusTagColorPreset: 'statusTagColorPreset', desc: "desc" }, (mediaType === "image" ? { image: "image" } : {})), (mediaType === "video" ? { video: "video" } : {})), { metaBlock: __spreadArray(__spreadArray([], (metaName ? [{ key: "name", valuePath: "name" }] : []), true), (metaDate ? [{ key: "date", valuePath: "date" }] : []), true) });
|
|
37
|
+
var config = __assign(__assign(__assign({ title: "title", cardLabel: "cardLabel", tagDisplay: "tagDisplay", statusTagColorPreset: 'statusTagColorPreset', labelTagColorPreset: 'labelTagColorPreset', desc: "desc" }, (mediaType === "image" ? { image: "image" } : {})), (mediaType === "video" ? { video: "video" } : {})), { metaBlock: __spreadArray(__spreadArray([], (metaName ? [{ key: "name", valuePath: "name" }] : []), true), (metaDate ? [{ key: "date", valuePath: "date" }] : []), true) });
|
|
38
38
|
return {
|
|
39
39
|
data: data,
|
|
40
40
|
statusTag: statusTag,
|
|
41
41
|
config: config,
|
|
42
42
|
disabled: disabled,
|
|
43
43
|
highlight: highlight,
|
|
44
|
-
statusTagColorPreset: statusTagColorPreset
|
|
44
|
+
statusTagColorPreset: statusTagColorPreset,
|
|
45
|
+
labelTagColorPreset: labelTagColorPreset
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
48
|
exports.parseCardArgs = parseCardArgs;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function CardContent({ id, data, config, to, onClick, openInNewTab, highlight, statusTagColorPreset }: {
|
|
1
|
+
export function CardContent({ id, data, config, to, onClick, openInNewTab, highlight, statusTagColorPreset, labelTagColorPreset }: {
|
|
2
2
|
id: any;
|
|
3
3
|
data: any;
|
|
4
4
|
config: any;
|
|
@@ -7,5 +7,6 @@ export function CardContent({ id, data, config, to, onClick, openInNewTab, highl
|
|
|
7
7
|
openInNewTab: any;
|
|
8
8
|
highlight: any;
|
|
9
9
|
statusTagColorPreset: any;
|
|
10
|
+
labelTagColorPreset: any;
|
|
10
11
|
}): React.JSX.Element;
|
|
11
12
|
import React from "react";
|
|
@@ -25,9 +25,9 @@ var ImagePlaceholder_1 = require("../../ImagePlaceholder");
|
|
|
25
25
|
var Star = icons_1.icons.Star, CrownSimple = icons_1.icons.CrownSimple;
|
|
26
26
|
var success = themes_1.colors.success, white = themes_1.colors.white;
|
|
27
27
|
var CardLabelTag = function (_a) {
|
|
28
|
-
var label = _a.label, isEmbedPresent = _a.isEmbedPresent, isHighlightPresent = _a.isHighlightPresent, bothTagsDisplayTogether = _a.bothTagsDisplayTogether;
|
|
28
|
+
var label = _a.label, isEmbedPresent = _a.isEmbedPresent, isHighlightPresent = _a.isHighlightPresent, labelTagColorPreset = _a.labelTagColorPreset, bothTagsDisplayTogether = _a.bothTagsDisplayTogether;
|
|
29
29
|
return label ? (react_1.default.createElement(styled_2.StyledCardLabelWrapper, { isEmbedPresent: isEmbedPresent, isHighlightPresent: isHighlightPresent, bothTagsDisplayTogether: bothTagsDisplayTogether },
|
|
30
|
-
react_1.default.createElement(Tags_1.TagDisplay, { display: label.toUpperCase(), title: label, XS: true }))) : null;
|
|
30
|
+
react_1.default.createElement(Tags_1.TagDisplay, { display: label.toUpperCase(), title: label, colorPreset: labelTagColorPreset, XS: true }))) : null;
|
|
31
31
|
};
|
|
32
32
|
var StatusTag = function (_a) {
|
|
33
33
|
var display = _a.display, isEmbedPresent = _a.isEmbedPresent, isHighlightPresent = _a.isHighlightPresent, statusTagColorPreset = _a.statusTagColorPreset, bothTagsDisplayTogether = _a.bothTagsDisplayTogether;
|
|
@@ -36,7 +36,7 @@ var StatusTag = function (_a) {
|
|
|
36
36
|
};
|
|
37
37
|
var CardContent = function (_a) {
|
|
38
38
|
var id = _a.id, data = _a.data, config = _a.config, to = _a.to, onClick = _a.onClick, openInNewTab = _a.openInNewTab, highlight = _a.highlight, // primary | secondary
|
|
39
|
-
statusTagColorPreset = _a.statusTagColorPreset;
|
|
39
|
+
statusTagColorPreset = _a.statusTagColorPreset, labelTagColorPreset = _a.labelTagColorPreset;
|
|
40
40
|
var theme = (0, styled_components_1.useTheme)();
|
|
41
41
|
var localize = (0, utilsOolib_1.useLocale)();
|
|
42
42
|
var parseSpecialSyntax = (theme || {}).parseSpecialSyntax;
|
|
@@ -56,11 +56,11 @@ var CardContent = function (_a) {
|
|
|
56
56
|
react_1.default.createElement(styled_2.StyledCardWrapper, { id: id, highlight: highlight, onClick: onClick ? function (e) { return onClick(e, data); } : undefined },
|
|
57
57
|
react_1.default.createElement("div", null,
|
|
58
58
|
showEmbedSection ? (react_1.default.createElement(styled_2.StyledEmbedSection, null,
|
|
59
|
-
react_1.default.createElement(CardLabelTag, { label: cardLabel, isEmbedPresent: showEmbedSection, isHighlightPresent: highlight, statusTagColorPreset: statusTagColorPreset }),
|
|
59
|
+
react_1.default.createElement(CardLabelTag, { label: cardLabel, isEmbedPresent: showEmbedSection, isHighlightPresent: highlight, statusTagColorPreset: statusTagColorPreset, labelTagColorPreset: labelTagColorPreset }),
|
|
60
60
|
(0, mediaDataExists_1.imageDataExists)(image) ? (react_1.default.createElement("div", { style: { width: "100%" } }, react_1.default.createElement(ImageInput_1.ImageInput, { value: image, aspectRatio: "5/3", readOnly: true, defaultImageSpread: "cover", enableCaptions: false, disableImageBorder: true }))) : (0, mediaDataExists_1.videoDataExists)(video) ? (react_1.default.createElement("div", { style: { width: "100%", position: 'relative' } },
|
|
61
61
|
react_1.default.createElement(VideoInput_1.default, { value: video, readOnly: true, light: true }),
|
|
62
62
|
react_1.default.createElement("div", { style: { position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' } }))) : (react_1.default.createElement(ImagePlaceholder_1.ImagePlaceholder, { title: title })))) : (react_1.default.createElement(styled_2.StyledCardLabelAndStatusTagWrapper, null,
|
|
63
|
-
react_1.default.createElement(CardLabelTag, { label: cardLabel, isEmbedPresent: showEmbedSection, isHighlightPresent: highlight, bothTagsDisplayTogether: bothTagsDisplayTogether }),
|
|
63
|
+
react_1.default.createElement(CardLabelTag, { label: cardLabel, isEmbedPresent: showEmbedSection, isHighlightPresent: highlight, bothTagsDisplayTogether: bothTagsDisplayTogether, labelTagColorPreset: labelTagColorPreset }),
|
|
64
64
|
react_1.default.createElement(StatusTag, { display: tagDisplay, isEmbedPresent: showEmbedSection, isHighlightPresent: highlight, statusTagColorPreset: statusTagColorPreset, bothTagsDisplayTogether: bothTagsDisplayTogether }))),
|
|
65
65
|
highlight && react_1.default.createElement(styled_2.StyledStarWrapper, { highlight: highlight },
|
|
66
66
|
react_1.default.createElement(HighLightIcon, { size: 18, color: white, weight: "fill", style: { filter: "drop-shadow(0px 2px 8.2px rgba(0, 0, 0, 0.50 ))" } })),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function ListContent({ id, data, config, to, onClick, openInNewTab, statusTag, variant, highlight,
|
|
1
|
+
export function ListContent({ id, data, config, to, onClick, openInNewTab, statusTag, variant, highlight, statusTagColorPreset, labelTagColorPreset }: {
|
|
2
2
|
id: any;
|
|
3
3
|
data: any;
|
|
4
4
|
config: any;
|
|
@@ -8,6 +8,7 @@ export function ListContent({ id, data, config, to, onClick, openInNewTab, statu
|
|
|
8
8
|
statusTag: any;
|
|
9
9
|
variant?: string;
|
|
10
10
|
highlight: any;
|
|
11
|
-
|
|
11
|
+
statusTagColorPreset: any;
|
|
12
|
+
labelTagColorPreset: any;
|
|
12
13
|
}): React.JSX.Element;
|
|
13
14
|
import React from "react";
|
|
@@ -29,14 +29,14 @@ var styled_2 = require("../CardContent/styled");
|
|
|
29
29
|
var white = themes_1.colors.white;
|
|
30
30
|
var Star = icons_1.icons.Star, CrownSimple = icons_1.icons.CrownSimple;
|
|
31
31
|
var CustomTag = function (_a) {
|
|
32
|
-
var displayText = _a.displayText,
|
|
32
|
+
var displayText = _a.displayText, tagPreset = _a.tagPreset, bothTagsDisplayTogether = _a.bothTagsDisplayTogether;
|
|
33
33
|
return displayText ? (react_1.default.createElement(styled_js_1.StyledTagWrapper, { bothTagsDisplayTogether: bothTagsDisplayTogether },
|
|
34
|
-
react_1.default.createElement(Tags_1.TagDisplay, { display: displayText, title: displayText,
|
|
34
|
+
react_1.default.createElement(Tags_1.TagDisplay, { display: displayText, title: displayText, colorPreset: tagPreset, XS: true }))) : null;
|
|
35
35
|
};
|
|
36
36
|
var ListContent = function (_a) {
|
|
37
37
|
var id = _a.id, data = _a.data, config = _a.config, to = _a.to, onClick = _a.onClick, openInNewTab = _a.openInNewTab, statusTag = _a.statusTag, _b = _a.variant, variant = _b === void 0 ? "content" : _b, //alt = profile | contentEmbed -> contentEmbed just changes the borderStyle
|
|
38
38
|
highlight = _a.highlight, // primary | secondary
|
|
39
|
-
|
|
39
|
+
statusTagColorPreset = _a.statusTagColorPreset, labelTagColorPreset = _a.labelTagColorPreset;
|
|
40
40
|
var theme = (0, styled_components_1.useTheme)();
|
|
41
41
|
var localize = (0, utilsOolib_1.useLocale)();
|
|
42
42
|
var screenWidth = (0, _EXPORTS_1.useScreenWidth)();
|
|
@@ -62,8 +62,8 @@ var ListContent = function (_a) {
|
|
|
62
62
|
react_1.default.createElement(styled_js_1.StyledMainSection, null,
|
|
63
63
|
react_1.default.createElement("div", null,
|
|
64
64
|
(cardLabel || statusTag) && (react_1.default.createElement(styled_js_1.StyledLabelAndStatusTagWrapper, { highlight: highlight, mediaConfigExists: mediaConfigExists },
|
|
65
|
-
react_1.default.createElement(CustomTag, { displayText: cardLabel,
|
|
66
|
-
react_1.default.createElement(CustomTag, { displayText: statusTag,
|
|
65
|
+
react_1.default.createElement(CustomTag, { displayText: cardLabel, tagPreset: labelTagColorPreset, bothTagsDisplayTogether: bothTagsDisplayTogether }),
|
|
66
|
+
react_1.default.createElement(CustomTag, { displayText: statusTag, tagPreset: statusTagColorPreset ? statusTagColorPreset : highlight == "primary" ? "positive" : "warning", bothTagsDisplayTogether: bothTagsDisplayTogether }))),
|
|
67
67
|
title ? (react_1.default.createElement(LineClampWrapper_1.LineClampWrapper, { noOfLines_M: 4, noOfLines_D: 3, title: title },
|
|
68
68
|
react_1.default.createElement(styled_1.StyledTitle, { capitalize: true, className: "StyledTitle" },
|
|
69
69
|
react_1.default.createElement(styled_1.StyledTitleSpan, { className: "StyledTitleSpan" }, localize(title))))) : null,
|
|
@@ -98,7 +98,7 @@ var CustomTooltip = function (props) {
|
|
|
98
98
|
gridTemplateColumns: showPercent ? "auto auto auto" : "auto auto",
|
|
99
99
|
gap: "0.6rem",
|
|
100
100
|
} },
|
|
101
|
-
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 },
|
|
101
|
+
react_1.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" } }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: "count-".concat(entry.name, "-").concat(index) },
|
|
102
102
|
react_1.default.createElement("div", { style: {
|
|
103
103
|
display: "flex",
|
|
104
104
|
alignItems: "center",
|
|
@@ -106,14 +106,14 @@ var CustomTooltip = function (props) {
|
|
|
106
106
|
} },
|
|
107
107
|
react_1.default.createElement(LegendTooltipGlyph_1.LegendTooltipGlyph, { color: entry.barColor }),
|
|
108
108
|
react_1.default.createElement(Typo2_1.UI_CAPTION_BOLD_DF, null, showPercent ? entry.percentage + "%" : entry.count || "0")))); })),
|
|
109
|
-
showPercent && (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 },
|
|
109
|
+
showPercent && (react_1.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" } }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: "percent-".concat(entry.name, "-").concat(index) },
|
|
110
110
|
react_1.default.createElement(Typo2_1.UI_CAPTION_DF, { key: index }, entry.count || "0"))); }))),
|
|
111
111
|
react_1.default.createElement("div", { style: {
|
|
112
112
|
paddingLeft: "0.8rem",
|
|
113
113
|
display: "flex",
|
|
114
114
|
flexDirection: "column",
|
|
115
115
|
gap: "1rem",
|
|
116
|
-
} }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: index },
|
|
116
|
+
} }, value.map(function (entry, index) { return (react_1.default.createElement("div", { key: "label-".concat(entry.name, "-").concat(index) },
|
|
117
117
|
react_1.default.createElement(UI_CAPTION_DF_WITH_LINE_CLAMP, null, entry.tooltipLabel))); }))))));
|
|
118
118
|
};
|
|
119
119
|
exports.default = CustomTooltip;
|
|
@@ -4,11 +4,14 @@ export interface DebugControls {
|
|
|
4
4
|
mouseEventDetectorOpacity: number;
|
|
5
5
|
chartWrapperBgColor: string;
|
|
6
6
|
}
|
|
7
|
-
export declare const useTrackMousePosition: (
|
|
7
|
+
export declare const useTrackMousePosition: ({ containerRef }: {
|
|
8
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
9
|
+
}) => {
|
|
8
10
|
mousePosition: {
|
|
9
11
|
x: number;
|
|
10
12
|
y: number;
|
|
11
13
|
};
|
|
14
|
+
isHovering: boolean;
|
|
12
15
|
};
|
|
13
16
|
type BreakdownDisplayType = "grouped" | "stacked";
|
|
14
17
|
export interface BarChartProps {
|
|
@@ -38,5 +41,5 @@ export declare const useDecideLegendOrientation: (options?: {
|
|
|
38
41
|
export declare const FadeGradientWhenScroll: ({ style }: {
|
|
39
42
|
style?: {};
|
|
40
43
|
}) => React.JSX.Element;
|
|
41
|
-
export declare const BarChart: React.
|
|
44
|
+
export declare const BarChart: React.FunctionComponent<BarChartProps>;
|
|
42
45
|
export {};
|
|
@@ -57,26 +57,42 @@ var usePrepareData_1 = require("../utils/usePrepareData");
|
|
|
57
57
|
var _base_barchart_ui_configs_1 = require("./_base_barchart_ui_configs");
|
|
58
58
|
var CustomTooltip_1 = __importDefault(require("./comps/CustomTooltip"));
|
|
59
59
|
var Legend_1 = require("./comps/Legend");
|
|
60
|
-
var useTrackMousePosition = function () {
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
var useTrackMousePosition = function (_a) {
|
|
61
|
+
var containerRef = _a.containerRef;
|
|
62
|
+
var _b = (0, react_1.useState)(null), mousePosition = _b[0], setMousePosition = _b[1];
|
|
63
|
+
var isHoveringRef = (0, react_1.useRef)(false);
|
|
64
|
+
var throttledHandleMouseMove = (0, react_1.useRef)(lodash_1.default.throttle(function (e) {
|
|
65
|
+
var element = containerRef.current;
|
|
66
|
+
if (!element)
|
|
67
|
+
return;
|
|
68
|
+
var rect = element.getBoundingClientRect();
|
|
69
|
+
var isInside = (e.clientX >= rect.left &&
|
|
70
|
+
e.clientX <= rect.right &&
|
|
71
|
+
e.clientY >= rect.top &&
|
|
72
|
+
e.clientY <= rect.bottom);
|
|
73
|
+
if (isInside) {
|
|
74
|
+
var newPosition = { x: e.clientX, y: e.clientY };
|
|
75
|
+
setMousePosition(newPosition);
|
|
76
|
+
isHoveringRef.current = true;
|
|
77
|
+
}
|
|
78
|
+
else if (isHoveringRef.current) {
|
|
79
|
+
// Only update state when transitioning from inside to outside
|
|
80
|
+
setMousePosition(null);
|
|
81
|
+
isHoveringRef.current = false;
|
|
82
|
+
}
|
|
83
|
+
}, 16));
|
|
70
84
|
(0, react_1.useEffect)(function () {
|
|
71
|
-
|
|
72
|
-
// Clean up
|
|
85
|
+
document.addEventListener("mousemove", throttledHandleMouseMove.current);
|
|
73
86
|
return function () {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throttledHandleMouseMove.cancel();
|
|
87
|
+
document.removeEventListener("mousemove", throttledHandleMouseMove.current);
|
|
88
|
+
throttledHandleMouseMove.current.cancel();
|
|
77
89
|
};
|
|
78
|
-
}, [
|
|
79
|
-
return
|
|
90
|
+
}, []);
|
|
91
|
+
// Only return isHovering as a boolean when mousePosition exists
|
|
92
|
+
return {
|
|
93
|
+
mousePosition: mousePosition,
|
|
94
|
+
isHovering: mousePosition !== null
|
|
95
|
+
};
|
|
80
96
|
};
|
|
81
97
|
exports.useTrackMousePosition = useTrackMousePosition;
|
|
82
98
|
// CHART_OFFSET_TOP & CHART_OFFSET_TOP_BREAKDOWN is the y shift on top of the entire chart, because otherwise the chart starts with bar 1 at 0,0 coordinates
|
|
@@ -173,7 +189,7 @@ var renderBar = function (_a) {
|
|
|
173
189
|
? data[0].length
|
|
174
190
|
: 1;
|
|
175
191
|
var currentStackId = activeConfig.getStackId(stackIndex, breakdownDisplayType);
|
|
176
|
-
return (react_1.default.createElement(recharts_1.Bar, { key: "stack-".concat(stackIndex), radius: activeConfig.getBarRadius(stackIndex, breakdownDisplayType, totalStacks), dataKey: activeConfig.getDataKey(stackIndex), stackId: currentStackId },
|
|
192
|
+
return (react_1.default.createElement(recharts_1.Bar, { key: "stack-".concat(stackIndex), radius: activeConfig.getBarRadius(stackIndex, breakdownDisplayType, totalStacks), dataKey: activeConfig.getDataKey(stackIndex), stackId: currentStackId, isAnimationActive: false },
|
|
177
193
|
(!isBreakdown || stackIndex === 0) && (react_1.default.createElement(recharts_1.LabelList, { dataKey: isBreakdown ? function (dataPoint) { return dataPoint; } : "labels", offset: 0, position: "bottom", content: function (props) { return (react_1.default.createElement(CustomizedLabel_1.CustomizedLabel, __assign({ CALC_SINGLE_BAR_SECTION_Y_POS: CALC_SINGLE_BAR_SECTION_Y_POS, CALC_STACKED_BAR_SECTION_Y_POS: CALC_STACKED_BAR_SECTION_Y_POS, TOT_HEIGHT_SINGLE_BAR_SECTION: TOT_HEIGHT_SINGLE_BAR_SECTION, TOT_HEIGHT_STACKED_BAR_SECTION: TOT_HEIGHT_STACKED_BAR_SECTION, TOT_HEIGHT_GROUPED_BAR_SECTION: isBreakdown &&
|
|
178
194
|
breakdownDisplayType === "grouped"
|
|
179
195
|
? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(data[0].length)
|
|
@@ -253,8 +269,11 @@ exports.useDecideLegendOrientation = useDecideLegendOrientation;
|
|
|
253
269
|
var BarChartRenderer = function (_a) {
|
|
254
270
|
var data = _a.data, isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, showSumOfBreakdownValues = _a.showSumOfBreakdownValues, showPercent = _a.showPercent, showCount = _a.showCount, activeBar = _a.activeBar, setActiveBar = _a.setActiveBar, onClick = _a.onClick,
|
|
255
271
|
//
|
|
256
|
-
|
|
257
|
-
|
|
272
|
+
// mousePosition,
|
|
273
|
+
dataMaxValue = _a.dataMaxValue, breakdownCategoryName = _a.breakdownCategoryName;
|
|
274
|
+
var containerRef = (0, react_1.useRef)();
|
|
275
|
+
var _b = (0, exports.useTrackMousePosition)({ containerRef: containerRef }), mousePosition = _b.mousePosition, isHovering = _b.isHovering;
|
|
276
|
+
return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", ref: containerRef, height: CALC_TOTAL_HEIGHT_OF_CHART({
|
|
258
277
|
isBreakdown: isBreakdown,
|
|
259
278
|
breakdownDisplayType: breakdownDisplayType,
|
|
260
279
|
showSumOfBreakdownValues: showSumOfBreakdownValues,
|
|
@@ -268,7 +287,7 @@ var BarChartRenderer = function (_a) {
|
|
|
268
287
|
} },
|
|
269
288
|
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number", domain: [0, dataMaxValue] }),
|
|
270
289
|
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
|
|
271
|
-
isBreakdown && (react_1.default.createElement(recharts_1.Tooltip, { cursor: false,
|
|
290
|
+
(isBreakdown && mousePosition && isHovering) && (react_1.default.createElement(recharts_1.Tooltip, { cursor: false,
|
|
272
291
|
// content={<OptimizedTooltip />}
|
|
273
292
|
// animationDuration={0}
|
|
274
293
|
// isAnimationActive={false}
|
|
@@ -332,23 +351,27 @@ var BarChart = function (_a) {
|
|
|
332
351
|
summarizeAfterIdx: summarizeAfterIdx,
|
|
333
352
|
colorIdx: colorIdx
|
|
334
353
|
}), data = _j.data, dataMaxValue = _j.dataMaxValue, dataToSummarize = _j.dataToSummarize;
|
|
335
|
-
console.log({ data: data, valuePath: valuePath });
|
|
336
354
|
var _k = (0, exports.useDecideLegendOrientation)({
|
|
337
355
|
widthThreshold: 500
|
|
338
356
|
}), vizWrapperRef = _k.vizWrapperRef, orientation = _k.orientation;
|
|
339
357
|
var _l = (0, react_1.useState)(undefined), activeBar = _l[0], setActiveBar = _l[1];
|
|
340
358
|
// const mousePosition = {x: 0, y: 0}
|
|
341
|
-
|
|
359
|
+
// const { mousePosition, isHovering } = useTrackMousePosition({ wrapperRef: vizWrapperRef});
|
|
360
|
+
// { mousePosition : 0 }
|
|
342
361
|
// menu options for grouped and stacked
|
|
343
362
|
if (data.length === 0)
|
|
344
363
|
return react_1.default.createElement("div", null, "No data available");
|
|
345
364
|
return (react_1.default.createElement("div", { ref: vizWrapperRef, style: __assign(__assign({}, style), { width: "100%", background: _debug_controls.chartWrapperBgColor, display: 'flex', gap: '8px', flexDirection: orientation === 'vertical' ? 'row' : 'column', position: 'relative', overflow: 'auto' }) },
|
|
346
365
|
react_1.default.createElement("div", { style: { flexGrow: 1, position: 'relative' } },
|
|
347
|
-
react_1.default.createElement(BarChartRenderer, { data: data, dataToSummarize: dataToSummarize, isBreakdown: isBreakdown, breakdownDisplayType: breakdownDisplayType, showSumOfBreakdownValues: false, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick,
|
|
366
|
+
react_1.default.createElement(BarChartRenderer, { data: data, dataToSummarize: dataToSummarize, isBreakdown: isBreakdown, breakdownDisplayType: breakdownDisplayType, showSumOfBreakdownValues: false, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick,
|
|
367
|
+
// mousePosition: isHovering ? mousePosition : null,
|
|
368
|
+
dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName }),
|
|
348
369
|
dataToSummarize && (react_1.default.createElement(BarChartRenderer, { data: dataToSummarize,
|
|
349
370
|
isBreakdown: true,
|
|
350
371
|
breakdownDisplayType: "stacked",
|
|
351
|
-
showSumOfBreakdownValues: true, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick,
|
|
372
|
+
showSumOfBreakdownValues: true, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick,
|
|
373
|
+
// mousePosition: isHovering ? mousePosition : null,
|
|
374
|
+
dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName })),
|
|
352
375
|
orientation === 'vertical' && react_1.default.createElement(exports.FadeGradientWhenScroll, null)),
|
|
353
376
|
isBreakdown && react_1.default.createElement("div", { style: __assign({ position: 'sticky' }, (orientation === 'vertical' ? { top: 0 } : { bottom: 0, background: __1.colors2.white })) },
|
|
354
377
|
orientation === 'horizontal' && react_1.default.createElement(exports.FadeGradientWhenScroll, { style: { transform: 'translateY(-100%)', top: 0, bottom: 'unset', position: 'absolute', } }),
|
|
@@ -45,6 +45,7 @@ var useGetDimensions_1 = require("./utils/useGetDimensions");
|
|
|
45
45
|
// import { __GetContentTypeConfigNew } from "../../../../../utils/getters/gettersV2";
|
|
46
46
|
var CustomTooltip_1 = __importDefault(require("../BarChart/comps/CustomTooltip"));
|
|
47
47
|
var usePrepareData_1 = require("./utils/usePrepareData");
|
|
48
|
+
var BarChart_1 = require("../BarChart");
|
|
48
49
|
var grey5 = __1.colors2.grey5;
|
|
49
50
|
exports.BAR_GRAPH_HEIGHT = 250;
|
|
50
51
|
exports.DEFAULT_SINGLE_BAR_WIDTH = 24;
|
|
@@ -115,17 +116,8 @@ exports.BarGraphCollection = BarGraphCollection;
|
|
|
115
116
|
var BarGraph = function (_a) {
|
|
116
117
|
var _b;
|
|
117
118
|
var tagCategory = _a.tagCategory, index1 = _a.index1, _c = _a.showCount, showCount = _c === void 0 ? true : _c, _d = _a.showPercent, showPercent = _d === void 0 ? true : _d, onClick = _a.onClick, debug = _a.debug;
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
(0, react_1.useEffect)(function () {
|
|
121
|
-
var handleMouseMove = function (e) {
|
|
122
|
-
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
123
|
-
};
|
|
124
|
-
window.addEventListener('mousemove', handleMouseMove);
|
|
125
|
-
return function () {
|
|
126
|
-
window.removeEventListener('mousemove', handleMouseMove);
|
|
127
|
-
};
|
|
128
|
-
}, []);
|
|
119
|
+
var containerRef = (0, react_1.useRef)();
|
|
120
|
+
var _e = (0, BarChart_1.useTrackMousePosition)({ containerRef: containerRef }), mousePosition = _e.mousePosition, isHovering = _e.isHovering;
|
|
129
121
|
var truncateText = function (text, maxLength) {
|
|
130
122
|
if (maxLength === void 0) { maxLength = 30; }
|
|
131
123
|
if (!text)
|
|
@@ -145,7 +137,7 @@ var BarGraph = function (_a) {
|
|
|
145
137
|
onClick(tag.display);
|
|
146
138
|
}
|
|
147
139
|
};
|
|
148
|
-
return (react_1.default.createElement(styled_1.StyledBarGraphWrapper, { style: {
|
|
140
|
+
return (react_1.default.createElement(styled_1.StyledBarGraphWrapper, { ref: containerRef, style: {
|
|
149
141
|
height: "".concat(exports.BAR_GRAPH_HEIGHT, "px"),
|
|
150
142
|
gap: "".concat(exports.BAR_GAP, "rem"),
|
|
151
143
|
} }, (_b = tagCategory === null || tagCategory === void 0 ? void 0 : tagCategory.tagSpecificCount) === null || _b === void 0 ? void 0 : _b.map(function (tag, index) {
|
|
@@ -162,7 +154,7 @@ var BarGraph = function (_a) {
|
|
|
162
154
|
} }),
|
|
163
155
|
react_1.default.createElement(styled_1.StyledLabelWrapper, null,
|
|
164
156
|
react_1.default.createElement(__2.UI_BODY_SM, null, truncateText(tag === null || tag === void 0 ? void 0 : tag.display, 30))),
|
|
165
|
-
|
|
157
|
+
(isHovering && mousePosition) && (react_1.default.createElement(CustomTooltip_1.default, { active: true, payload: [tag], mousePosition: mousePosition, value: tooltipData, showPercent: showPercent })))));
|
|
166
158
|
})));
|
|
167
159
|
};
|
|
168
160
|
exports.BarGraph = BarGraph;
|
|
@@ -71,8 +71,8 @@ var _configs = {
|
|
|
71
71
|
};
|
|
72
72
|
var HeatMapCell = function (_a) {
|
|
73
73
|
var value = _a.value, dataMaxValue = _a.dataMaxValue, _b = _a.dataMinValue, dataMinValue = _b === void 0 ? 0 : _b, showPercent = _a.showPercent;
|
|
74
|
-
var
|
|
75
|
-
var _c = (0,
|
|
74
|
+
var containerRef = (0, react_1.useRef)();
|
|
75
|
+
var _c = (0, BarChart_1.useTrackMousePosition)({ containerRef: containerRef }), mousePosition = _c.mousePosition, isHovering = _c.isHovering;
|
|
76
76
|
var cellColor = (0, mapValueToColor_1.mapValueToColor)(value.labels.count, dataMinValue, dataMaxValue);
|
|
77
77
|
var getCellColorLightness = function () {
|
|
78
78
|
var splitUp = cellColor.trim().replace('hsl(', '');
|
|
@@ -84,8 +84,8 @@ var HeatMapCell = function (_a) {
|
|
|
84
84
|
var textColor = value.labels.count === 0
|
|
85
85
|
? __1.colors2.black
|
|
86
86
|
: getCellColorLightness() > 60 ? __1.colors2.black : __1.colors2.white;
|
|
87
|
-
return (react_1.default.createElement("div", {
|
|
88
|
-
|
|
87
|
+
return (react_1.default.createElement("div", { ref: containerRef },
|
|
88
|
+
(isHovering) && (react_1.default.createElement(CustomTooltip_1.default, { active: true, value: [__assign(__assign({}, value.labels), { tooltipLabel: value.labels.name + ' | ' + value.labels.tooltipLabel //bit of a hack but will sort later
|
|
89
89
|
})], showPercent: showPercent, mousePosition: mousePosition })),
|
|
90
90
|
react_1.default.createElement("div", { style: {
|
|
91
91
|
height: _configs.cellSize + "px",
|
|
@@ -137,7 +137,7 @@ var HeatMapGrid = function (_a) {
|
|
|
137
137
|
alignItems: "center",
|
|
138
138
|
gap: _configs.gridGap + "px",
|
|
139
139
|
minWidth: 'max-content',
|
|
140
|
-
} }, (_b = data[0]) === null || _b === void 0 ? void 0 : _b.map(function (dd, index) { return (react_1.default.createElement("div", { key: dd.labels.tooltipLabel, style: {
|
|
140
|
+
} }, (_b = data[0]) === null || _b === void 0 ? void 0 : _b.map(function (dd, index) { return (react_1.default.createElement("div", { key: "label-".concat(dd.labels.tooltipLabel, "-").concat(index), style: {
|
|
141
141
|
width: _configs.cellSize + "px",
|
|
142
142
|
height: xWidth + "px",
|
|
143
143
|
display: "flex",
|
|
@@ -175,8 +175,8 @@ var HeatMapGrid = function (_a) {
|
|
|
175
175
|
scrollableRef.current.scrollTop = e.target.scrollTop;
|
|
176
176
|
}
|
|
177
177
|
} }, data.map(function (d, idx) {
|
|
178
|
-
var _a;
|
|
179
|
-
return (react_1.default.createElement("div", { key: idx, style: {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
return (react_1.default.createElement("div", { key: "name-".concat((_a = d[0]) === null || _a === void 0 ? void 0 : _a.labels.name, "-").concat(idx), style: {
|
|
180
180
|
height: _configs.cellSize + "px",
|
|
181
181
|
textAlign: "right",
|
|
182
182
|
display: "flex",
|
|
@@ -185,7 +185,7 @@ var HeatMapGrid = function (_a) {
|
|
|
185
185
|
flexShrink: 0,
|
|
186
186
|
} },
|
|
187
187
|
react_1.default.createElement("div", { ref: function (el) { return setVerticalRef(idx, el); } },
|
|
188
|
-
react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: { maxWidth: yWidth + "px" } }, (
|
|
188
|
+
react_1.default.createElement(STYLED_UI_CAPTION_SEMIBOLD_DF, { style: { maxWidth: yWidth + "px" } }, (_b = d[0]) === null || _b === void 0 ? void 0 : _b.labels.name))));
|
|
189
189
|
})),
|
|
190
190
|
react_1.default.createElement("div", { ref: scrollableRef, style: {
|
|
191
191
|
gridRow: 2,
|
|
@@ -9,11 +9,11 @@ var useAxisMeasure = function (defaultAxisLabelWidth) {
|
|
|
9
9
|
var verticalRefs = (0, react_1.useRef)([]);
|
|
10
10
|
// Functions to set refs
|
|
11
11
|
var setHorizontalRef = function (index, el) {
|
|
12
|
-
console.log({
|
|
12
|
+
// console.log({horEL: el})
|
|
13
13
|
horizontalRefs.current[index] = el;
|
|
14
14
|
};
|
|
15
15
|
var setVerticalRef = function (index, el) {
|
|
16
|
-
console.log({
|
|
16
|
+
// console.log({verEL: el})
|
|
17
17
|
verticalRefs.current[index] = el;
|
|
18
18
|
};
|
|
19
19
|
console.log({ horizontalRefs: horizontalRefs, verticalRefs: verticalRefs });
|
|
@@ -135,9 +135,7 @@ var renderActiveShape = function (props) {
|
|
|
135
135
|
};
|
|
136
136
|
var PieChart = function (_a) {
|
|
137
137
|
var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, breakdownCategoryName = _a.breakdownCategoryName, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.colors, colors = _c === void 0 ? chartColors : _c, _d = _a.colorIdx, colorIdx = _d === void 0 ? 0 : _d, _e = _a.plotDataPoint, plotDataPoint = _e === void 0 ? "percentage" : _e, _f = _a.showPercent, showPercent = _f === void 0 ? true : _f, _g = _a.showCount, showCount = _g === void 0 ? false : _g, innerLabel = _a.innerLabel, style = _a.style;
|
|
138
|
-
var
|
|
139
|
-
var _h = (0, react_1.useState)(false), showTooltip = _h[0], setShowTooltip = _h[1]; // Add this line
|
|
140
|
-
var _j = (0, react_1.useState)(null), tooltipData = _j[0], setTooltipData = _j[1]; // Add this line
|
|
138
|
+
var _h = (0, react_1.useState)(null), tooltipData = _h[0], setTooltipData = _h[1]; // Add this line
|
|
141
139
|
var isBreakdown = Array.isArray(valuePath);
|
|
142
140
|
var barChartData = (0, usePrepareData_1.usePrepareData)({
|
|
143
141
|
_data: _data,
|
|
@@ -152,18 +150,17 @@ var PieChart = function (_a) {
|
|
|
152
150
|
}).data;
|
|
153
151
|
// Adapt the BarChart data format to PieChart format
|
|
154
152
|
var data = usePieChartData(barChartData, isBreakdown);
|
|
155
|
-
var
|
|
153
|
+
var _j = (0, BarChart_1.useDecideLegendOrientation)({
|
|
156
154
|
widthThreshold: 500
|
|
157
|
-
}), vizWrapperRef =
|
|
155
|
+
}), vizWrapperRef = _j.vizWrapperRef, orientation = _j.orientation;
|
|
156
|
+
var _k = (0, BarChart_2.useTrackMousePosition)({ containerRef: vizWrapperRef }), mousePosition = _k.mousePosition, isHovering = _k.isHovering;
|
|
158
157
|
var _l = (0, react_1.useState)(), activeIndex = _l[0], setActiveIndex = _l[1];
|
|
159
158
|
var onPieEnter = function (data, index) {
|
|
160
159
|
setActiveIndex(index);
|
|
161
|
-
setShowTooltip(true);
|
|
162
160
|
setTooltipData(data.payload);
|
|
163
161
|
};
|
|
164
162
|
var onPieLeave = function () {
|
|
165
163
|
setActiveIndex(undefined);
|
|
166
|
-
setShowTooltip(false);
|
|
167
164
|
setTooltipData(null);
|
|
168
165
|
};
|
|
169
166
|
var onPieClick = function (_, index) {
|
|
@@ -174,7 +171,7 @@ var PieChart = function (_a) {
|
|
|
174
171
|
if (data.length === 0)
|
|
175
172
|
return react_1.default.createElement("div", null, "No data available");
|
|
176
173
|
return (react_1.default.createElement("div", { ref: vizWrapperRef, style: __assign(__assign({}, style), { width: "100%", display: 'flex', gap: '8px', flexDirection: orientation === 'vertical' ? 'row' : 'column', position: 'relative' }) },
|
|
177
|
-
|
|
174
|
+
(isHovering && tooltipData) && (react_1.default.createElement(CustomTooltip_1.default, { active: true, value: [tooltipData.labels], showPercent: showPercent, mousePosition: mousePosition })),
|
|
178
175
|
react_1.default.createElement("div", { style: { flexGrow: 1, position: 'relative' } },
|
|
179
176
|
react_1.default.createElement("div", { className: "w-full", style: { height: "100%" } },
|
|
180
177
|
react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: "100%" },
|