@scality/core-ui 0.162.0 → 0.163.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/barchartv2/Barchart.component.d.ts +0 -2
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +11 -1
- package/dist/components/barchartv2/utils.d.ts +25 -2
- package/dist/components/barchartv2/utils.d.ts.map +1 -1
- package/dist/components/barchartv2/utils.js +35 -3
- package/dist/components/chartlegend/ChartLegend.d.ts +8 -0
- package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegend.js +65 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts +17 -0
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -0
- package/dist/components/chartlegend/ChartLegendWrapper.js +50 -0
- package/dist/components/date/FormattedDateTime.d.ts +3 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +19 -1
- package/dist/components/date/FormattedDateTime.spec.js +12 -0
- package/dist/components/icon/Icon.component.d.ts +5 -5
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +33 -31
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +33 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -0
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +249 -0
- package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
- package/dist/components/selectv2/Selectv2.component.js +11 -6
- package/dist/components/steppers/Stepper.component.d.ts.map +1 -1
- package/dist/components/steppers/Stepper.component.js +9 -8
- package/dist/components/toast/ToastProvider.d.ts.map +1 -1
- package/dist/components/toast/ToastProvider.js +4 -5
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.js +3 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/next.d.ts +1 -0
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +1 -0
- package/dist/style/theme.d.ts +1 -0
- package/dist/style/theme.d.ts.map +1 -1
- package/dist/style/theme.js +28 -0
- package/package.json +2 -2
- package/src/lib/components/accordion/Accordion.test.tsx +7 -15
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +82 -101
- package/src/lib/components/barchartv2/Barchart.component.tsx +14 -2
- package/src/lib/components/barchartv2/utils.test.ts +117 -0
- package/src/lib/components/barchartv2/utils.ts +54 -6
- package/src/lib/components/chartlegend/ChartLegend.tsx +113 -0
- package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +85 -0
- package/src/lib/components/date/FormattedDateTime.spec.tsx +24 -0
- package/src/lib/components/date/FormattedDateTime.tsx +36 -2
- package/src/lib/components/healthselectorv2/HealthSelector.component.test.tsx +3 -3
- package/src/lib/components/icon/Icon.component.tsx +48 -60
- package/src/lib/components/inlineinput/InlineInput.test.tsx +22 -19
- package/src/lib/components/inputlist/InputList.test.tsx +21 -19
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +502 -0
- package/src/lib/components/searchinput/SearchInput.test.tsx +3 -7
- package/src/lib/components/selectv2/Selectv2.component.tsx +13 -5
- package/src/lib/components/selectv2/selectv2.test.tsx +62 -57
- package/src/lib/components/steppers/Stepper.component.tsx +10 -8
- package/src/lib/components/tablev2/TableSync.test.tsx +8 -11
- package/src/lib/components/tablev2/Tablev2.test.tsx +36 -37
- package/src/lib/components/toast/ToastProvider.tsx +14 -6
- package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +5 -7
- package/src/lib/index.ts +1 -0
- package/src/lib/next.ts +1 -0
- package/src/lib/style/theme.ts +29 -0
- package/stories/BarChart/barchart.stories.tsx +292 -125
- package/stories/format.mdx +4 -2
- package/stories/linetimeseriechart.stories.tsx +485 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ChartColors } from '../../style/theme';
|
|
2
1
|
import { UnitRange } from './utils';
|
|
3
2
|
export type TimeType = {
|
|
4
3
|
type: 'time';
|
|
@@ -39,7 +38,6 @@ export type BarchartSortFn<T extends BarchartBars> = (pointA: Record<T[number]['
|
|
|
39
38
|
export type BarchartProps<T extends BarchartBars> = {
|
|
40
39
|
type: 'category' | TimeType;
|
|
41
40
|
bars: T;
|
|
42
|
-
colorSet: Record<T[number]['label'], ChartColors | (string & {})>;
|
|
43
41
|
tooltip?: BarchartTooltipFn<T>;
|
|
44
42
|
defaultSort?: BarchartSortFn<T>;
|
|
45
43
|
unitRange?: UnitRange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Barchart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/Barchart.component.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAwB,SAAS,EAAgB,MAAM,SAAS,CAAC;AAkBxE,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE;QACT,SAAS,EAAE,IAAI,CAAC;QAChB,OAAO,EAAE,IAAI,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AACF,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,SAAS;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,EAAE,MAA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S,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAiHF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,YAAY,SAAS,aAAa,CAAC,CAAC,CAAC,4CA4HvE,CAAC"}
|
|
@@ -10,6 +10,7 @@ import { IconHelp } from '../iconhelper/IconHelper';
|
|
|
10
10
|
import { Loader } from '../loader/Loader.component';
|
|
11
11
|
import { Text } from '../text/Text.component';
|
|
12
12
|
import { renderTooltipContent, useChartData } from './utils';
|
|
13
|
+
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
13
14
|
const CHART_CONSTANTS = {
|
|
14
15
|
TICK_WIDTH_OFFSET: 5,
|
|
15
16
|
BAR_SIZE: 12,
|
|
@@ -56,8 +57,17 @@ const Loading = ({ height }) => {
|
|
|
56
57
|
/* ---------------------------------- MAIN COMPONENT ---------------------------------- */
|
|
57
58
|
export const Barchart = (props) => {
|
|
58
59
|
const theme = useTheme();
|
|
60
|
+
const { getColor } = useChartLegend();
|
|
59
61
|
const [hoveredValue, setHoveredValue] = useState();
|
|
60
|
-
const { height = CHART_CONSTANTS.DEFAULT_HEIGHT, bars, type = 'category',
|
|
62
|
+
const { height = CHART_CONSTANTS.DEFAULT_HEIGHT, bars, type = 'category', unitRange, stacked, defaultSort, tooltip, title, secondaryTitle, helpTooltip, rightTitle, isLoading, } = props;
|
|
63
|
+
// Create colorSet from ChartLegendWrapper
|
|
64
|
+
const colorSet = bars.reduce((acc, bar) => {
|
|
65
|
+
const color = getColor(bar.label);
|
|
66
|
+
if (color) {
|
|
67
|
+
acc[bar.label] = color;
|
|
68
|
+
}
|
|
69
|
+
return acc;
|
|
70
|
+
}, {});
|
|
61
71
|
const { rechartsBars, unitLabel, roundReferenceValue, rechartsData } = useChartData(bars, type, colorSet, stacked, defaultSort, unitRange);
|
|
62
72
|
return (_jsxs(Stack, { direction: "vertical", gap: "r8", children: [_jsx(ChartHeader, { title: title, secondaryTitle: secondaryTitle, helpTooltip: helpTooltip, rightTitle: rightTitle }), isLoading ? (_jsx(Loading, { height: height })) : (_jsx(StyledResponsiveContainer, { width: "100%", height: height, children: _jsxs(BarChart, { data: rechartsData, accessibilityLayer: true, barSize: CHART_CONSTANTS.BAR_SIZE, height: height, margin: CHART_CONSTANTS.CHART_MARGIN, children: [_jsx(CartesianGrid, { vertical: false, horizontal: false, fill: theme.backgroundLevel1 }), rechartsBars.map((bar) => {
|
|
63
73
|
const { fill, dataKey, stackId } = bar;
|
|
@@ -38,7 +38,7 @@ export declare const applySortingToData: <T extends BarchartBars>(data: {
|
|
|
38
38
|
* @param type - The chart type (category or time)
|
|
39
39
|
* @returns Recharts data format
|
|
40
40
|
*/
|
|
41
|
-
export declare const formatPrometheusDataToRechartsDataAndBars: <T extends BarchartBars>(bars: T, type: BarchartProps<T>["type"], colorSet: Record<
|
|
41
|
+
export declare const formatPrometheusDataToRechartsDataAndBars: <T extends BarchartBars>(bars: T, type: BarchartProps<T>["type"], colorSet: Record<string, ChartColors | string>, stacked?: boolean, defaultSort?: BarchartProps<T>["defaultSort"]) => {
|
|
42
42
|
data: {
|
|
43
43
|
[key: string]: string | number;
|
|
44
44
|
}[];
|
|
@@ -82,7 +82,30 @@ export declare const sortStackedBars: (rechartsBars: {
|
|
|
82
82
|
stackId?: string;
|
|
83
83
|
}[];
|
|
84
84
|
export declare const renderTooltipContent: <T extends BarchartBars>(props: TooltipContentProps<number, string>, tooltip: BarchartTooltipFn<T> | undefined, hoveredValue: string | undefined) => import("react").ReactNode;
|
|
85
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Filters both chart data and recharts bars to only include selected resources from legend
|
|
87
|
+
* @param data - Array of chart data objects with category and resource values
|
|
88
|
+
* @param rechartsBars - Array of recharts bar configurations
|
|
89
|
+
* @param selectedResources - Array of selected resource names
|
|
90
|
+
* @returns Object containing filtered data and recharts bars
|
|
91
|
+
*/
|
|
92
|
+
export declare const filterChartDataAndBarsByLegendSelection: (data: {
|
|
93
|
+
[key: string]: string | number;
|
|
94
|
+
}[], rechartsBars: {
|
|
95
|
+
dataKey: string;
|
|
96
|
+
fill: string;
|
|
97
|
+
stackId?: string;
|
|
98
|
+
}[], selectedResources: string[]) => {
|
|
99
|
+
filteredData: {
|
|
100
|
+
[key: string]: string | number;
|
|
101
|
+
}[];
|
|
102
|
+
filteredRechartsBars: {
|
|
103
|
+
dataKey: string;
|
|
104
|
+
fill: string;
|
|
105
|
+
stackId?: string;
|
|
106
|
+
}[];
|
|
107
|
+
};
|
|
108
|
+
export declare const useChartData: <T extends BarchartBars>(bars: T, type: BarchartProps<T>["type"], colorSet: Record<string, ChartColors | string>, stacked?: boolean, defaultSort?: BarchartProps<T>["defaultSort"], unitRange?: UnitRange) => {
|
|
86
109
|
rechartsBars: {
|
|
87
110
|
dataKey: string;
|
|
88
111
|
fill: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,MActD,CAAC;AAEF,eAAO,MAAM,cAAc,SACnB;IAAE,CAAC,GAAG,EAAE,MAAM,G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pB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,YACpC,OAAO,gBACH,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,cACjC,SAAS;;iBAnCI,MAAM;cAAQ,MAAM;kBAAY,MAAM;;;;;CAiEhE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DAY_MONTH_FORMATER, TIME_FORMATER } from '../date/FormattedDateTime';
|
|
2
2
|
import { chartColors } from '../../style/theme';
|
|
3
|
+
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
3
4
|
export const getRoundReferenceValue = (value) => {
|
|
4
5
|
if (value <= 0)
|
|
5
6
|
return 10; // Default for zero or negative values
|
|
@@ -292,12 +293,43 @@ export const renderTooltipContent = (props, tooltip, hoveredValue) => {
|
|
|
292
293
|
};
|
|
293
294
|
return tooltip(currentPoint);
|
|
294
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* Filters both chart data and recharts bars to only include selected resources from legend
|
|
298
|
+
* @param data - Array of chart data objects with category and resource values
|
|
299
|
+
* @param rechartsBars - Array of recharts bar configurations
|
|
300
|
+
* @param selectedResources - Array of selected resource names
|
|
301
|
+
* @returns Object containing filtered data and recharts bars
|
|
302
|
+
*/
|
|
303
|
+
export const filterChartDataAndBarsByLegendSelection = (data, rechartsBars, selectedResources) => {
|
|
304
|
+
// If no resources are selected, show all data and bars (default behavior)
|
|
305
|
+
if (selectedResources.length === 0) {
|
|
306
|
+
return { filteredData: data, filteredRechartsBars: rechartsBars };
|
|
307
|
+
}
|
|
308
|
+
// Filter recharts bars
|
|
309
|
+
const filteredRechartsBars = rechartsBars.filter((bar) => selectedResources.includes(bar.dataKey));
|
|
310
|
+
// Filter data to only include selected resources
|
|
311
|
+
const filteredData = data.map((item) => {
|
|
312
|
+
const filteredItem = {
|
|
313
|
+
category: item.category,
|
|
314
|
+
};
|
|
315
|
+
selectedResources.forEach((resource) => {
|
|
316
|
+
if (resource in item) {
|
|
317
|
+
filteredItem[resource] = item[resource];
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
return filteredItem;
|
|
321
|
+
});
|
|
322
|
+
return { filteredData, filteredRechartsBars };
|
|
323
|
+
};
|
|
295
324
|
export const useChartData = (bars, type, colorSet, stacked, defaultSort, unitRange) => {
|
|
325
|
+
const { selectedResources } = useChartLegend();
|
|
296
326
|
const { data, rechartsBars } = formatPrometheusDataToRechartsDataAndBars(bars, type, colorSet, stacked, defaultSort);
|
|
297
|
-
|
|
298
|
-
const {
|
|
327
|
+
// Filter both data and bars to only include selected resources for accurate maxValue calculation
|
|
328
|
+
const { filteredData, filteredRechartsBars } = filterChartDataAndBarsByLegendSelection(data, rechartsBars, selectedResources);
|
|
329
|
+
const maxValue = getMaxBarValue(filteredData, stacked);
|
|
330
|
+
const { unitLabel, roundReferenceValue, rechartsData } = computeUnitLabelAndRoundReferenceValue(filteredData, maxValue, unitRange);
|
|
299
331
|
return {
|
|
300
|
-
rechartsBars,
|
|
332
|
+
rechartsBars: filteredRechartsBars,
|
|
301
333
|
unitLabel,
|
|
302
334
|
roundReferenceValue,
|
|
303
335
|
rechartsData,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type ChartLegendProps = {
|
|
2
|
+
shape: 'line' | 'rectangle';
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
direction?: 'horizontal' | 'vertical';
|
|
5
|
+
};
|
|
6
|
+
export declare const ChartLegend: ({ shape, disabled, direction, }: ChartLegendProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=ChartLegend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegend.tsx"],"names":[],"mappings":"AAMA,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACvC,CAAC;AAkDF,eAAO,MAAM,WAAW,oCAIrB,gBAAgB,4CAgDlB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { useChartLegend } from './ChartLegendWrapper';
|
|
4
|
+
import { Text } from '../text/Text.component';
|
|
5
|
+
import { chartColors } from '../../style/theme';
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
const Legend = styled.div `
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: ${({ direction }) => direction === 'horizontal' ? 'row' : 'column'};
|
|
10
|
+
gap: ${({ direction }) => (direction === 'horizontal' ? '16px' : '8px')};
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
`;
|
|
13
|
+
const LegendItem = styled.div `
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 8px;
|
|
17
|
+
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
|
|
18
|
+
opacity: ${({ selected, disabled }) => (disabled ? 0.5 : selected ? 1 : 0.7)};
|
|
19
|
+
transition: opacity 0.2s ease;
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
const LegendShape = styled.div `
|
|
26
|
+
${({ shape, color, chartColors }) => {
|
|
27
|
+
if (shape === 'line') {
|
|
28
|
+
return `
|
|
29
|
+
width: 20px;
|
|
30
|
+
height: 2px;
|
|
31
|
+
background-color: ${chartColors[color] || color};
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
else if (shape === 'rectangle') {
|
|
35
|
+
return `
|
|
36
|
+
width: 12px;
|
|
37
|
+
height: 12px;
|
|
38
|
+
background-color: ${chartColors[color] || color};
|
|
39
|
+
border-radius: 2px;
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
console.error('The shape is not valid. Please use "line" or "rectangle".');
|
|
44
|
+
}
|
|
45
|
+
}}
|
|
46
|
+
`;
|
|
47
|
+
export const ChartLegend = ({ shape, disabled = false, direction = 'horizontal', }) => {
|
|
48
|
+
const { listResources, getColor, isSelected, addSelectedResource, removeSelectedResource, } = useChartLegend();
|
|
49
|
+
const resources = listResources();
|
|
50
|
+
const handleLegendClick = useCallback((resource) => {
|
|
51
|
+
if (disabled)
|
|
52
|
+
return;
|
|
53
|
+
if (isSelected(resource)) {
|
|
54
|
+
removeSelectedResource(resource);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
addSelectedResource(resource);
|
|
58
|
+
}
|
|
59
|
+
}, [disabled, isSelected, addSelectedResource, removeSelectedResource]);
|
|
60
|
+
return (_jsx(Legend, { direction: direction, children: resources.map((resource) => {
|
|
61
|
+
const color = getColor(resource);
|
|
62
|
+
const selected = isSelected(resource);
|
|
63
|
+
return (_jsxs(LegendItem, { disabled: disabled, selected: selected, onClick: () => handleLegendClick(resource), children: [_jsx(LegendShape, { color: color, shape: shape, chartColors: chartColors }), _jsx(Text, { variant: "Basic", children: resource })] }, resource));
|
|
64
|
+
}) }));
|
|
65
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChartColors } from '../../style/theme';
|
|
3
|
+
export type ChartLegendState = {
|
|
4
|
+
selectedResources: string[];
|
|
5
|
+
addSelectedResource: (resource: string) => void;
|
|
6
|
+
removeSelectedResource: (resource: string) => void;
|
|
7
|
+
isSelected: (resource: string) => boolean;
|
|
8
|
+
getColor: (resource: string) => string | undefined;
|
|
9
|
+
listResources: () => string[];
|
|
10
|
+
};
|
|
11
|
+
export type ChartLegendWrapperProps = {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
colorSet: Record<string, ChartColors | string>;
|
|
14
|
+
};
|
|
15
|
+
export declare const ChartLegendWrapper: ({ children, colorSet, }: ChartLegendWrapperProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const useChartLegend: () => ChartLegendState;
|
|
17
|
+
//# sourceMappingURL=ChartLegendWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartLegendWrapper.d.ts","sourceRoot":"","sources":["../../../src/lib/components/chartlegend/ChartLegendWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuC,SAAS,EAAwB,MAAM,OAAO,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,sBAAsB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1C,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACnD,aAAa,EAAE,MAAM,MAAM,EAAE,CAAC;CAC/B,CAAC;AAIF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,kBAAkB,4BAG5B,uBAAuB,4CAqDzB,CAAC;AAGF,eAAO,MAAM,cAAc,wBAM1B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState, useMemo, useCallback } from 'react';
|
|
3
|
+
const ChartLegendContext = createContext(null);
|
|
4
|
+
export const ChartLegendWrapper = ({ children, colorSet, }) => {
|
|
5
|
+
const [selectedResources, setSelectedResources] = useState([]);
|
|
6
|
+
const addSelectedResource = useCallback((resource) => {
|
|
7
|
+
setSelectedResources((prev) => prev.includes(resource) ? prev : [...prev, resource]);
|
|
8
|
+
}, []);
|
|
9
|
+
const removeSelectedResource = useCallback((resource) => {
|
|
10
|
+
setSelectedResources((prev) => prev.filter((r) => r !== resource));
|
|
11
|
+
}, []);
|
|
12
|
+
const isSelected = useCallback((resource) => {
|
|
13
|
+
return selectedResources.includes(resource);
|
|
14
|
+
}, [selectedResources]);
|
|
15
|
+
const getColor = useCallback((resource) => {
|
|
16
|
+
const color = colorSet[resource];
|
|
17
|
+
if (!color) {
|
|
18
|
+
console.warn(`ChartLegendWrapper: No color defined for resource "${resource}"`);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return color;
|
|
22
|
+
}, [colorSet]);
|
|
23
|
+
const listResources = useCallback(() => {
|
|
24
|
+
return Object.keys(colorSet);
|
|
25
|
+
}, [colorSet]);
|
|
26
|
+
const chartLegendState = useMemo(() => ({
|
|
27
|
+
selectedResources,
|
|
28
|
+
addSelectedResource,
|
|
29
|
+
removeSelectedResource,
|
|
30
|
+
isSelected,
|
|
31
|
+
getColor,
|
|
32
|
+
listResources,
|
|
33
|
+
}), [
|
|
34
|
+
selectedResources,
|
|
35
|
+
addSelectedResource,
|
|
36
|
+
removeSelectedResource,
|
|
37
|
+
isSelected,
|
|
38
|
+
getColor,
|
|
39
|
+
listResources,
|
|
40
|
+
]);
|
|
41
|
+
return (_jsx(ChartLegendContext.Provider, { value: chartLegendState, children: children }));
|
|
42
|
+
};
|
|
43
|
+
// Hook for accessing legend state in custom components
|
|
44
|
+
export const useChartLegend = () => {
|
|
45
|
+
const context = useContext(ChartLegendContext);
|
|
46
|
+
if (!context) {
|
|
47
|
+
throw new Error('useChartLegend must be used within a ChartLegendWrapper');
|
|
48
|
+
}
|
|
49
|
+
return context;
|
|
50
|
+
};
|
|
@@ -2,8 +2,10 @@ export declare const DATE_FORMATER: Intl.DateTimeFormat;
|
|
|
2
2
|
export declare const DAY_MONTH_FORMATER: Intl.DateTimeFormat;
|
|
3
3
|
export declare const TIME_SECOND_FORMATER: Intl.DateTimeFormat;
|
|
4
4
|
export declare const TIME_FORMATER: Intl.DateTimeFormat;
|
|
5
|
+
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND: Intl.DateTimeFormat;
|
|
6
|
+
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE: Intl.DateTimeFormat;
|
|
5
7
|
type FormattedDateTimeProps = {
|
|
6
|
-
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative';
|
|
8
|
+
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative' | 'day-month-abbreviated-hour-minute' | 'day-month-abbreviated-hour-minute-second';
|
|
7
9
|
value: Date;
|
|
8
10
|
};
|
|
9
11
|
export declare const FormattedDateTime: ({ format, value, }: FormattedDateTimeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,qBAKxB,CAAC;AAEH,eAAO,MAAM,kBAAkB,qBAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB,qBAK/B,CAAC;AAEH,eAAO,MAAM,aAAa,qBAIxB,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,qBAKxB,CAAC;AAEH,eAAO,MAAM,kBAAkB,qBAI7B,CAAC;AAEH,eAAO,MAAM,oBAAoB,qBAK/B,CAAC;AAEH,eAAO,MAAM,aAAa,qBAIxB,CAAC;AAEH,eAAO,MAAM,wCAAwC,qBAUpD,CAAC;AAEF,eAAO,MAAM,iCAAiC,qBAM5C,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,GACV,mCAAmC,GACnC,0CAA0C,CAAC;IAC/C,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAaF,eAAO,MAAM,iBAAiB,uBAG3B,sBAAsB,4CAiHxB,CAAC"}
|
|
@@ -23,6 +23,21 @@ export const TIME_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
|
23
23
|
hour: '2-digit',
|
|
24
24
|
minute: '2-digit',
|
|
25
25
|
});
|
|
26
|
+
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat('en-GB', {
|
|
27
|
+
day: 'numeric',
|
|
28
|
+
month: 'short',
|
|
29
|
+
hour: '2-digit',
|
|
30
|
+
minute: '2-digit',
|
|
31
|
+
second: '2-digit',
|
|
32
|
+
hour12: false,
|
|
33
|
+
});
|
|
34
|
+
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
|
|
35
|
+
day: 'numeric',
|
|
36
|
+
month: 'short',
|
|
37
|
+
hour: '2-digit',
|
|
38
|
+
minute: '2-digit',
|
|
39
|
+
hour12: false,
|
|
40
|
+
});
|
|
26
41
|
const isItFutureOrIsItPast = (timeDiff, stringToBeFormatted) => {
|
|
27
42
|
if (timeDiff > 0) {
|
|
28
43
|
return `${stringToBeFormatted} ago`;
|
|
@@ -64,7 +79,10 @@ export const FormattedDateTime = ({ format, value, }) => {
|
|
|
64
79
|
return (_jsx(Tooltip, { overlay: _jsx(FormattedDateTime, { format: "date-time-second", value: value }), children: isItFutureOrIsItPast(minuteDiff, `${Math.abs(minuteDiff)} minute${Math.abs(minuteDiff) > 1 ? 's' : ''}`) }));
|
|
65
80
|
}
|
|
66
81
|
return (_jsx(Tooltip, { overlay: _jsx(FormattedDateTime, { format: "date-time-second", value: value }), children: "few seconds ago" }));
|
|
67
|
-
|
|
82
|
+
case 'day-month-abbreviated-hour-minute':
|
|
83
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value).replace(',', '') }));
|
|
84
|
+
case 'day-month-abbreviated-hour-minute-second':
|
|
85
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value).replace(',', '') }));
|
|
68
86
|
default:
|
|
69
87
|
return _jsx(_Fragment, {});
|
|
70
88
|
}
|
|
@@ -137,4 +137,16 @@ describe('FormatttedDateTime', () => {
|
|
|
137
137
|
//V
|
|
138
138
|
expect(screen.getByText('2022-12-12 11:57:26')).toBeInTheDocument();
|
|
139
139
|
});
|
|
140
|
+
it('should display the date in the expected format of the xaxis tick in the chart', () => {
|
|
141
|
+
//S
|
|
142
|
+
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date('2022-10-06T18:33:00Z') }));
|
|
143
|
+
//V
|
|
144
|
+
expect(screen.getByText('6 Oct 18:33')).toBeInTheDocument();
|
|
145
|
+
});
|
|
146
|
+
it('should display the date in the expected format of date in the chart', () => {
|
|
147
|
+
//S
|
|
148
|
+
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute-second", value: new Date('2022-10-06T18:33:00Z') }));
|
|
149
|
+
//V
|
|
150
|
+
expect(screen.getByText('6 Oct 18:33:00')).toBeInTheDocument();
|
|
151
|
+
});
|
|
140
152
|
});
|
|
@@ -128,13 +128,13 @@ export declare const iconTable: {
|
|
|
128
128
|
Mail: string;
|
|
129
129
|
};
|
|
130
130
|
export declare const customIcons: {
|
|
131
|
-
'Remote-user': ({ ariaLabel, color, size }: {
|
|
132
|
-
|
|
131
|
+
'Remote-user': ({ "aria-label": ariaLabel, color, size }: {
|
|
132
|
+
"aria-label": any;
|
|
133
133
|
color: any;
|
|
134
134
|
size: any;
|
|
135
135
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
136
|
-
'Remote-group': ({ ariaLabel, color, size }: {
|
|
137
|
-
|
|
136
|
+
'Remote-group': ({ "aria-label": ariaLabel, color, size }: {
|
|
137
|
+
"aria-label": any;
|
|
138
138
|
color: any;
|
|
139
139
|
size: any;
|
|
140
140
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -148,7 +148,7 @@ type Props = {
|
|
|
148
148
|
ariaLabel?: string;
|
|
149
149
|
withWrapper?: boolean;
|
|
150
150
|
style?: CSSProperties;
|
|
151
|
-
onClick?: (event: MouseEvent) => void;
|
|
151
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
152
152
|
title?: string;
|
|
153
153
|
};
|
|
154
154
|
export declare const IconWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/icon/Icon.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EACL,aAAa,EAKd,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Icon.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/icon/Icon.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EACL,aAAa,EAKd,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOhD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6HrB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;CAOvB,CAAC;AAaF,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,SAAS,GAAG,MAAM,OAAO,WAAW,CAAC;AACzE,MAAM,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC;AAC1C,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAiBF,eAAO,MAAM,WAAW;UAAsB,QAAQ;SAiCrD,CAAC;AA2DF,iBAAS,IAAI,CAAC,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,2CAU7C;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
3
|
import { useEffect, useState, } from 'react';
|
|
4
|
-
import { useQuery } from 'react-query';
|
|
5
4
|
import styled, { css } from 'styled-components';
|
|
6
5
|
import { Loader } from '../loader/Loader.component';
|
|
7
6
|
import { RemoteGroup, RemoteUser } from './CustomsIcons';
|
|
7
|
+
// Module-level cache for imported icons
|
|
8
|
+
const iconCache = {};
|
|
8
9
|
export const iconTable = {
|
|
9
10
|
Account: 'fas faWallet',
|
|
10
11
|
Backend: 'fas faNetworkWired',
|
|
@@ -132,8 +133,8 @@ export const iconTable = {
|
|
|
132
133
|
Mail: 'fas faEnvelope',
|
|
133
134
|
};
|
|
134
135
|
export const customIcons = {
|
|
135
|
-
'Remote-user': ({ ariaLabel, color, size }) => (_jsx(RemoteUser, { ariaLabel: ariaLabel, color: color, size: size })),
|
|
136
|
-
'Remote-group': ({ ariaLabel, color, size }) => (_jsx(RemoteGroup, { ariaLabel: ariaLabel, color: color, size: size })),
|
|
136
|
+
'Remote-user': ({ 'aria-label': ariaLabel, color, size }) => (_jsx(RemoteUser, { ariaLabel: ariaLabel, color: color, size: size })),
|
|
137
|
+
'Remote-group': ({ 'aria-label': ariaLabel, color, size }) => (_jsx(RemoteGroup, { ariaLabel: ariaLabel, color: color, size: size })),
|
|
137
138
|
};
|
|
138
139
|
const IconStyled = styled(FontAwesomeIcon) `
|
|
139
140
|
${(props) => {
|
|
@@ -189,36 +190,37 @@ export const IconWrapper = styled.div `
|
|
|
189
190
|
align-items: center;
|
|
190
191
|
border-radius: 100%;
|
|
191
192
|
`;
|
|
192
|
-
function NonWrappedIcon({ name, size = '1x', color
|
|
193
|
+
function NonWrappedIcon({ name, size = '1x', color, ariaLabel = '', title, ...rest }) {
|
|
194
|
+
var _a;
|
|
193
195
|
const iconInfo = iconTable[name] || customIcons[name];
|
|
194
196
|
if (!iconInfo)
|
|
195
197
|
throw new Error(`${name}: is not a valid icon.`);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return (
|
|
198
|
+
// Loaded fortawesome icon if not a custom icon
|
|
199
|
+
const [icon, setIcon] = useState();
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
if (customIcons[name]) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const [iconType, iconClass] = iconInfo.split(' ');
|
|
205
|
+
const fontAwesomeType = iconType === 'far' ? 'free-regular-svg-icons' : 'free-solid-svg-icons';
|
|
206
|
+
const cacheKey = `${fontAwesomeType}/${iconClass}`;
|
|
207
|
+
if (iconCache[cacheKey]) {
|
|
208
|
+
setIcon(iconCache[cacheKey]);
|
|
209
|
+
return () => setIcon(undefined);
|
|
210
|
+
}
|
|
211
|
+
// Handle FontAwesome icons with dynamic import
|
|
212
|
+
import(`@fortawesome/${fontAwesomeType}/${iconClass}.js`)
|
|
213
|
+
.then((module) => {
|
|
214
|
+
setIcon(module[iconClass]);
|
|
215
|
+
iconCache[cacheKey] = module[iconClass];
|
|
216
|
+
});
|
|
217
|
+
return () => setIcon(undefined);
|
|
218
|
+
}, [name, iconInfo]);
|
|
219
|
+
if (!icon && !customIcons[name]) {
|
|
220
|
+
return (_jsx(DelayedFallback, { "aria-label": `${name} ${ariaLabel}`, children: _jsx(Loader, { size: "base" }) }));
|
|
221
|
+
}
|
|
222
|
+
const IconComponent = (_a = customIcons[name]) !== null && _a !== void 0 ? _a : IconStyled;
|
|
223
|
+
return (_jsx(IconComponent, { color: color, icon: icon, size: size, title: title, "aria-label": `${name} ${ariaLabel}`, ...rest }));
|
|
222
224
|
}
|
|
223
225
|
function Icon({ withWrapper, ...props }) {
|
|
224
226
|
if (withWrapper) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type Serie = {
|
|
2
|
+
resource: string;
|
|
3
|
+
data: [number, string | null][];
|
|
4
|
+
getTooltipLabel: (metricPrefix?: string, resource?: string) => string;
|
|
5
|
+
metricPrefix?: string;
|
|
6
|
+
isLineDashed?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type NonSymmetricalChartSerie = {
|
|
9
|
+
yAxisType?: 'default' | 'percentage';
|
|
10
|
+
series: Serie[];
|
|
11
|
+
};
|
|
12
|
+
type SymmetricalChartSerie = {
|
|
13
|
+
yAxisType: 'symmetrical';
|
|
14
|
+
series: {
|
|
15
|
+
above: Serie[];
|
|
16
|
+
below: Serie[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type LineChartProps = (NonSymmetricalChartSerie | SymmetricalChartSerie) & {
|
|
20
|
+
title: string;
|
|
21
|
+
height: number;
|
|
22
|
+
startingTimeStamp: number;
|
|
23
|
+
unitRange?: {
|
|
24
|
+
threshold: number;
|
|
25
|
+
label: string;
|
|
26
|
+
}[];
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
yAxisTitle?: string;
|
|
29
|
+
helpText?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function LineTimeSerieChart({ series, title, height, startingTimeStamp, unitRange, isLoading, yAxisType, yAxisTitle, helpText, ...rest }: LineChartProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=linetimeseriechart.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"AA2FA,MAAM,MAAM,KAAK,GAAG;IAElB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEhC,eAAe,EAAE,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAEtE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,SAAS,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACrC,MAAM,EAA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