@gravity-ui/chartkit 5.19.0 → 5.19.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.
|
@@ -4,7 +4,7 @@ import './tooltip.css';
|
|
|
4
4
|
export declare const SERIES_NAME_DATA_ATTRIBUTE = "data-series-name";
|
|
5
5
|
export declare const SERIES_IDX_DATA_ATTRIBUTE = "data-series-idx";
|
|
6
6
|
export declare const TOOLTIP_CONTAINER_CLASS_NAME = "_tooltip";
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const TOOLTIP_ROW_NAME_CLASS_NAME = "_tooltip-rows__name-td";
|
|
8
8
|
export declare const TOOLTIP_ROW_CLASS_NAME = "_tooltip-row";
|
|
9
9
|
export declare const TOOLTIP_HEADER_CLASS_NAME = "_tooltip-header";
|
|
10
10
|
export declare const TOOLTIP_LIST_CLASS_NAME = "_tooltip-list";
|
|
@@ -7,7 +7,7 @@ import './tooltip.css';
|
|
|
7
7
|
export const SERIES_NAME_DATA_ATTRIBUTE = 'data-series-name';
|
|
8
8
|
export const SERIES_IDX_DATA_ATTRIBUTE = 'data-series-idx';
|
|
9
9
|
export const TOOLTIP_CONTAINER_CLASS_NAME = '_tooltip';
|
|
10
|
-
export const
|
|
10
|
+
export const TOOLTIP_ROW_NAME_CLASS_NAME = '_tooltip-rows__name-td';
|
|
11
11
|
export const TOOLTIP_ROW_CLASS_NAME = '_tooltip-row';
|
|
12
12
|
export const TOOLTIP_HEADER_CLASS_NAME = '_tooltip-header';
|
|
13
13
|
export const TOOLTIP_LIST_CLASS_NAME = '_tooltip-list';
|
|
@@ -22,9 +22,18 @@ const renderLineShapeCell = (line) => `<td class="_tooltip-rows__shape-td">
|
|
|
22
22
|
${renderShapeIcon({ type: line.seriesShape })}
|
|
23
23
|
</div>
|
|
24
24
|
</td>`;
|
|
25
|
-
const renderNameCell = (line) =>
|
|
26
|
-
|
|
25
|
+
const renderNameCell = (line, options) => {
|
|
26
|
+
let value = '';
|
|
27
|
+
if (!line.hideSeriesName) {
|
|
28
|
+
value = line.seriesName;
|
|
29
|
+
if (!(options === null || options === void 0 ? void 0 : options.unsafe)) {
|
|
30
|
+
value = escapeHTML(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return `<td class="${TOOLTIP_ROW_NAME_CLASS_NAME}">
|
|
34
|
+
${value}
|
|
27
35
|
</td>`;
|
|
36
|
+
};
|
|
28
37
|
const renderPercentCell = (line) => `<td class="_tooltip-rows__percent-td">
|
|
29
38
|
${line.percentValue ? line.percentValue + '%' : ''}
|
|
30
39
|
</td>`;
|
|
@@ -61,7 +70,7 @@ const renderAdditionalSection = (data, splitTooltip = false, colspanNumber = 1)
|
|
|
61
70
|
: ''}
|
|
62
71
|
</td>`;
|
|
63
72
|
};
|
|
64
|
-
const renderRow = (line, { isSelectedLine, cellsRenderers, isSingleLine, allowComment, withDarkBackground, rowIndex, }) => {
|
|
73
|
+
const renderRow = (line, { isSelectedLine, cellsRenderers, isSingleLine, allowComment, withDarkBackground, rowIndex, unsafe, }) => {
|
|
65
74
|
const hasComment = line.commentText || line.xyCommentText;
|
|
66
75
|
const needRenderComment = allowComment && hasComment;
|
|
67
76
|
const fullCellsRenderers = cellsRenderers.slice();
|
|
@@ -106,7 +115,7 @@ const renderRow = (line, { isSelectedLine, cellsRenderers, isSingleLine, allowCo
|
|
|
106
115
|
: line.insertCellAt[index](line);
|
|
107
116
|
}
|
|
108
117
|
else {
|
|
109
|
-
return render(line);
|
|
118
|
+
return render(line, { unsafe });
|
|
110
119
|
}
|
|
111
120
|
})
|
|
112
121
|
.join('')}
|
|
@@ -155,6 +164,7 @@ export const formatTooltip = (data, tooltip, isMobile) => {
|
|
|
155
164
|
const rowRenderingConfig = {
|
|
156
165
|
isSingleLine: lines.length === 1,
|
|
157
166
|
cellsRenderers,
|
|
167
|
+
unsafe,
|
|
158
168
|
};
|
|
159
169
|
const rowRenderingConfigForSelectedLine = {
|
|
160
170
|
cellsRenderers,
|
|
@@ -76,10 +76,13 @@ export type TooltipLine = {
|
|
|
76
76
|
chartKitUnit?: FormatNumberOptions['unit'];
|
|
77
77
|
};
|
|
78
78
|
export type RowRenderingConfig = {
|
|
79
|
-
cellsRenderers: Array<(line: TooltipLine
|
|
79
|
+
cellsRenderers: Array<(line: TooltipLine, options?: {
|
|
80
|
+
unsafe?: boolean;
|
|
81
|
+
}) => string>;
|
|
80
82
|
isSelectedLine?: boolean;
|
|
81
83
|
allowComment?: boolean;
|
|
82
84
|
withDarkBackground?: boolean;
|
|
83
85
|
isSingleLine?: boolean;
|
|
84
86
|
rowIndex?: number;
|
|
87
|
+
unsafe?: boolean;
|
|
85
88
|
};
|
package/package.json
CHANGED