@scality/core-ui 0.168.0 → 0.170.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/.github/workflows/github-pages.yml +5 -3
- package/.storybook/preview.js +1 -0
- package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
- package/dist/components/barchartv2/Barchart.component.js +6 -5
- package/dist/components/barchartv2/ChartTooltip.d.ts +9 -13
- package/dist/components/barchartv2/ChartTooltip.d.ts.map +1 -1
- package/dist/components/barchartv2/ChartTooltip.js +14 -4
- package/dist/components/barchartv2/utils.d.ts +9 -2
- package/dist/components/barchartv2/utils.d.ts.map +1 -1
- package/dist/components/barchartv2/utils.js +12 -16
- package/dist/components/buttonv2/Buttonv2.component.d.ts.map +1 -1
- package/dist/components/buttonv2/Buttonv2.component.js +27 -6
- package/dist/components/date/FormattedDateTime.d.ts +54 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.js +78 -6
- package/dist/components/date/FormattedDateTime.spec.js +12 -3
- package/dist/components/layout/v2/index.d.ts +2 -1
- package/dist/components/layout/v2/index.d.ts.map +1 -1
- package/dist/components/layout/v2/index.js +3 -3
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
- package/dist/components/linetimeseriechart/linetimeseriechart.component.js +30 -32
- package/dist/components/linetimeseriechart/utils.d.ts +16 -0
- package/dist/components/linetimeseriechart/utils.d.ts.map +1 -0
- package/dist/components/linetimeseriechart/utils.js +28 -0
- package/dist/style/theme.d.ts +2 -2
- package/dist/style/theme.d.ts.map +1 -1
- package/dist/style/theme.js +26 -0
- package/package.json +5 -4
- package/src/lib/components/barchartv2/Barchart.component.test.tsx +1 -1
- package/src/lib/components/barchartv2/Barchart.component.tsx +14 -6
- package/src/lib/components/barchartv2/ChartTooltip.test.tsx +119 -0
- package/src/lib/components/barchartv2/ChartTooltip.tsx +49 -19
- package/src/lib/components/barchartv2/utils.test.ts +29 -44
- package/src/lib/components/barchartv2/utils.ts +22 -29
- package/src/lib/components/buttonv2/Buttonv2.component.tsx +27 -6
- package/src/lib/components/date/FormattedDateTime.spec.tsx +27 -2
- package/src/lib/components/date/FormattedDateTime.tsx +89 -10
- package/src/lib/components/layout/v2/index.tsx +5 -3
- package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +61 -57
- package/src/lib/components/linetimeseriechart/linetimeseriechart.test.tsx +58 -55
- package/src/lib/components/linetimeseriechart/utils.test.ts +87 -0
- package/src/lib/components/linetimeseriechart/utils.ts +43 -0
- package/src/lib/style/theme.ts +26 -0
- package/stories/BarChart/barchart.stories.tsx +1 -1
- package/stories/color.mdx +12 -0
- package/stories/formattedate.stories.tsx +7 -0
- package/stories/layout.stories.tsx +19 -0
|
@@ -11,7 +11,9 @@ jobs:
|
|
|
11
11
|
- uses: actions/setup-node@v4
|
|
12
12
|
with:
|
|
13
13
|
node-version: 20
|
|
14
|
-
- run:
|
|
15
|
-
|
|
14
|
+
- run: |
|
|
15
|
+
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
|
16
|
+
npm ci
|
|
17
|
+
npm run storybook:deploy
|
|
16
18
|
env:
|
|
17
|
-
|
|
19
|
+
STORYBOOK_DISABLE_TELEMETRY: 1
|
package/.storybook/preview.js
CHANGED
|
@@ -18,6 +18,7 @@ export const globalTypes = {
|
|
|
18
18
|
{ value: 'darkRebrand', title: ' A-Dark', icon: 'moon' },
|
|
19
19
|
{ value: 'artescaLight', title: 'A-Light', icon: 'sun' },
|
|
20
20
|
{ value: 'ring9dark', title: 'R-Dark', icon: 'moon' },
|
|
21
|
+
{ value: 'G-Dark', title: 'G-Dark', icon: 'moon' },
|
|
21
22
|
],
|
|
22
23
|
},
|
|
23
24
|
},
|
|
@@ -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":"AAuBA,OAAO,EAAE,SAAS,EAAgB,MAAM,SAAS,CAAC;AAiBlD,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;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,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,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;CACvE,EAAE,CAAC;AAEJ,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,YAAY,IAAI,CAAC,YAAY,EAAE;IACrE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,MAAM,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAC5E,KAAK,KAAK,CAAC,SAAS,CAAC;AAEtB,MAAM,MAAM,cAAc,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M,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB;AAID;;;;;GAKG;AACH,eAAO,MAAM,UAAU,cACV,MAAM,YACP,MAAM,KACf,KAAK,CAAC,SAoBR,CAAC;AAEF,eAAO,MAAM,UAAU,uDAOpB,eAAe,4CAkCjB,CAAC;AA2EF,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,YAAY,SAAS,aAAa,CAAC,CAAC,CAAC,4CAsJvE,CAAC"}
|
|
@@ -5,13 +5,14 @@ import styled, { useTheme } from 'styled-components';
|
|
|
5
5
|
import { spacing, Stack, Wrap } from '../../spacing';
|
|
6
6
|
import { chartColors, fontSize } from '../../style/theme';
|
|
7
7
|
import { Box } from '../box/Box';
|
|
8
|
+
import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
|
|
8
9
|
import { ConstrainedText } from '../constrainedtext/Constrainedtext.component';
|
|
10
|
+
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
9
11
|
import { IconHelp } from '../iconhelper/IconHelper';
|
|
10
12
|
import { Loader } from '../loader/Loader.component';
|
|
11
13
|
import { Text } from '../text/Text.component';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
14
|
+
import { ChartTooltip } from './ChartTooltip';
|
|
15
|
+
import { useChartData } from './utils';
|
|
15
16
|
const CHART_CONSTANTS = {
|
|
16
17
|
TICK_WIDTH_OFFSET: 5,
|
|
17
18
|
BAR_SIZE: 12,
|
|
@@ -110,7 +111,7 @@ export const Barchart = (props) => {
|
|
|
110
111
|
: CHART_CONSTANTS.BAR_SIZE
|
|
111
112
|
: CHART_CONSTANTS.BAR_SIZE, height: height, margin: CHART_CONSTANTS.CHART_MARGIN, barCategoryGap: type.type === 'category' ? type.gap : undefined, children: [_jsx(CartesianGrid, { vertical: false, horizontal: false, fill: theme.backgroundLevel1 }), rechartsBars.map((bar) => {
|
|
112
113
|
const { fill, dataKey, stackId } = bar;
|
|
113
|
-
return (_jsx(Bar, { dataKey: dataKey, fill: chartColors[fill] || fill, minPointSize: stacked ? 0 : CHART_CONSTANTS.MIN_POINT_SIZE, stackId: stackId, onMouseOver: () => setHoveredValue(dataKey), onMouseLeave: () => setHoveredValue(undefined) }, dataKey));
|
|
114
|
+
return (_jsx(Bar, { dataKey: dataKey, fill: chartColors[fill] || fill, minPointSize: stacked ? 0 : CHART_CONSTANTS.MIN_POINT_SIZE, stackId: stackId, isAnimationActive: false, onMouseOver: () => setHoveredValue(dataKey), onMouseLeave: () => setHoveredValue(undefined) }, dataKey));
|
|
114
115
|
}), _jsx(YAxis, { tickCount: 1, unit: ` ${unitLabel}`, domain: [0, roundReferenceValue], tickFormatter: (value) => new Intl.NumberFormat('fr-FR').format(value.toFixed(0)) // Add a space as thousand separator
|
|
115
116
|
, axisLine: false, tick: {
|
|
116
117
|
fill: theme.textSecondary,
|
|
@@ -121,5 +122,5 @@ export const Barchart = (props) => {
|
|
|
121
122
|
stroke: theme.textSecondary,
|
|
122
123
|
}, axisLine: {
|
|
123
124
|
stroke: theme.textSecondary,
|
|
124
|
-
} }), _jsx(Tooltip, { content: (props) =>
|
|
125
|
+
} }), _jsx(Tooltip, { content: (props) => (_jsx(ChartTooltip, { type: type, colorSet: colorSet, tooltipProps: props, hoveredValue: hoveredValue, tooltip: tooltip })), cursor: false })] }) }))] }));
|
|
125
126
|
};
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { BarchartBars } from './Barchart.component';
|
|
1
|
+
import { BarchartBars, BarchartTooltipFn, CategoryType, TimeType } from './Barchart.component';
|
|
2
|
+
import { TooltipContentProps } from 'recharts';
|
|
2
3
|
export declare const ChartTooltipContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
4
|
export declare const ChartTooltipItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
4
5
|
isHovered: boolean;
|
|
5
6
|
}, never>;
|
|
6
|
-
export declare const ChartTooltip: <T extends BarchartBars>({ type,
|
|
7
|
-
type:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
isHovered: boolean;
|
|
14
|
-
}[];
|
|
15
|
-
};
|
|
16
|
-
colorSet: Record<string, string>;
|
|
17
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const ChartTooltip: <T extends BarchartBars>({ type, tooltipProps, colorSet, hoveredValue, tooltip, }: {
|
|
8
|
+
type: TimeType | CategoryType;
|
|
9
|
+
tooltipProps: TooltipContentProps<number, string>;
|
|
10
|
+
colorSet?: Record<string, string>;
|
|
11
|
+
hoveredValue: string | undefined;
|
|
12
|
+
tooltip?: BarchartTooltipFn<T>;
|
|
13
|
+
}) => string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
18
14
|
//# sourceMappingURL=ChartTooltip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/ChartTooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/ChartTooltip.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,eAAO,MAAM,qBAAqB,yGAYjC,CAAC;AAEF,eAAO,MAAM,gBAAgB;eAA2B,OAAO;SAM9D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,YAAY,4DAMhD;IACD,IAAI,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC9B,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;CAChC,iIAwDA,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { spacing, Stack, Wrap } from '../../spacing';
|
|
4
4
|
import { Text } from '../text/Text.component';
|
|
5
5
|
import { fontSize, fontWeight } from '../../style/theme';
|
|
6
6
|
import { LegendShape } from '../chartlegend/ChartLegend';
|
|
7
7
|
import { FormattedDateTime } from '../date/FormattedDateTime';
|
|
8
|
+
import { getCurrentPoint } from './utils';
|
|
8
9
|
export const ChartTooltipContainer = styled.div `
|
|
9
10
|
background-color: ${({ theme }) => theme.backgroundLevel1};
|
|
10
11
|
padding: ${spacing.r4} ${spacing.r8};
|
|
@@ -24,8 +25,17 @@ export const ChartTooltipItem = styled.div `
|
|
|
24
25
|
gap: 8px;
|
|
25
26
|
font-weight: ${({ isHovered }) => isHovered ? fontWeight.bold : fontWeight.base};
|
|
26
27
|
`;
|
|
27
|
-
export const ChartTooltip = ({ type,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
export const ChartTooltip = ({ type, tooltipProps, colorSet, hoveredValue, tooltip, }) => {
|
|
29
|
+
const { active } = tooltipProps;
|
|
30
|
+
if (!active) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const currentPoint = getCurrentPoint(tooltipProps, hoveredValue);
|
|
34
|
+
if (tooltip) {
|
|
35
|
+
return tooltip(currentPoint);
|
|
36
|
+
}
|
|
37
|
+
return (_jsxs(ChartTooltipContainer, { children: [_jsx(Text, { isEmphazed: true, children: type.type === 'time' ? (_jsxs(_Fragment, { children: [_jsx(FormattedDateTime, { format: "long-date", value: new Date(currentPoint.category) }), ' ', type.type === 'time' &&
|
|
38
|
+
type.timeRange.interval < 24 * 60 * 60 * 1000 && (_jsx(FormattedDateTime, { format: "time", value: new Date(currentPoint.category) }))] })) : (currentPoint.category) }), _jsx(Stack, { direction: "vertical", gap: "r8", style: { width: '100%' }, children: currentPoint.values.map((value) => {
|
|
39
|
+
return (_jsxs(Wrap, { gap: spacing.r32, children: [_jsxs(ChartTooltipItem, { isHovered: value.isHovered, children: [colorSet && (_jsx(LegendShape, { color: colorSet[value.label], shape: "rectangle", chartColors: colorSet })), value.label] }), _jsx(ChartTooltipItem, { isHovered: value.isHovered, children: value.value })] }, value.label));
|
|
30
40
|
}) })] }));
|
|
31
41
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BarchartProps, BarchartBars
|
|
1
|
+
import { BarchartProps, BarchartBars } from './Barchart.component';
|
|
2
2
|
import { TooltipContentProps } from 'recharts';
|
|
3
3
|
import { ChartColors } from '../../style/theme';
|
|
4
4
|
export declare const getRoundReferenceValue: (value: number) => number;
|
|
@@ -81,7 +81,6 @@ export declare const sortStackedBars: (rechartsBars: {
|
|
|
81
81
|
fill: string;
|
|
82
82
|
stackId?: string;
|
|
83
83
|
}[];
|
|
84
|
-
export declare const renderTooltipContent: <T extends BarchartBars>(props: TooltipContentProps<number, string>, tooltip: BarchartTooltipFn<T> | undefined, hoveredValue: string | undefined) => import("react").ReactNode;
|
|
85
84
|
/**
|
|
86
85
|
* Filters both chart data and recharts bars to only include selected resources from legend
|
|
87
86
|
* @param data - Array of chart data objects with category and resource values
|
|
@@ -115,4 +114,12 @@ export declare const useChartData: <T extends BarchartBars>(bars: T, type: Barch
|
|
|
115
114
|
roundReferenceValue: number;
|
|
116
115
|
rechartsData: any;
|
|
117
116
|
};
|
|
117
|
+
export declare const getCurrentPoint: <T extends BarchartBars>(props: TooltipContentProps<number, string>, hoveredValue: string | undefined) => {
|
|
118
|
+
category: string | number;
|
|
119
|
+
values: {
|
|
120
|
+
label: T[number]["label"];
|
|
121
|
+
value: number;
|
|
122
|
+
isHovered: boolean;
|
|
123
|
+
}[];
|
|
124
|
+
};
|
|
118
125
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EAEb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,sBAAsB,UAAW,MAAM,KAAG,MAkBtD,CAAC;AAEF,eAAO,MAAM,cAAc,SACnB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,YAChC,OAAO,WAuBlB,CAAC;AAkDF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,YAAY,QAChD,CAAC,QACD;IACJ,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,eACY,MAAM,EAAE;;GAsCtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,YAAY,QACpD,CAAC,eACM,MAAM,EAAE;;GA2BtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,YAAY,QACjD;IAAE,CAAC,GAAG,EAAE,MAA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AM,GAAG,MAAM,GAAG,MAAM,CAAC;CAChC,EAAE,YACO,OAAO,gBACH,MAAM,EAAE;aARX,MAAM;UACT,MAAM;cACF,MAAM;GA8CnB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uCAAuC,SAC5C;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,gBAC5B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,qBAChD,MAAM,EAAE;;;;;iBADF,MAAM;cAAQ,MAAM;kBAAY,MAAM;;CA2BhE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,YAAY,QAC3C,CAAC,QACD,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,YACpB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,YACpC,OAAO,gBACH,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,cACjC,SAAS,mBACJ,SAAS,GAAG,QAAQ;;iBApCZ,MAAM;cAAQ,MAAM;kBAAY,MAAM;;;;;CAuEhE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,YAAY,SAC7C,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,gBAC5B,MAAM,GAAG,SAAS;cAeX,MAAM,GAAG,MAAM;;eAV3B,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;eAClB,MAAM;mBACF,OAAO;;CAWrB,CAAC"}
|
|
@@ -270,22 +270,6 @@ export const sortStackedBars = (rechartsBars, data, stacked, legendOrder) => {
|
|
|
270
270
|
// Remove the average property and keep only the bar data
|
|
271
271
|
return barAverages.map(({ average, ...bar }) => bar);
|
|
272
272
|
};
|
|
273
|
-
export const renderTooltipContent = (props, tooltip, hoveredValue) => {
|
|
274
|
-
const { active, payload, label } = props;
|
|
275
|
-
if (!active || !tooltip) {
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
278
|
-
const tooltipValues = payload.map((item) => ({
|
|
279
|
-
label: item.name,
|
|
280
|
-
value: item.value,
|
|
281
|
-
isHovered: item.name === hoveredValue,
|
|
282
|
-
}));
|
|
283
|
-
const currentPoint = {
|
|
284
|
-
category: label,
|
|
285
|
-
values: tooltipValues,
|
|
286
|
-
};
|
|
287
|
-
return tooltip(currentPoint);
|
|
288
|
-
};
|
|
289
273
|
/**
|
|
290
274
|
* Filters both chart data and recharts bars to only include selected resources from legend
|
|
291
275
|
* @param data - Array of chart data objects with category and resource values
|
|
@@ -330,3 +314,15 @@ export const useChartData = (bars, type, colorSet, stacked, defaultSort, unitRan
|
|
|
330
314
|
rechartsData,
|
|
331
315
|
};
|
|
332
316
|
};
|
|
317
|
+
export const getCurrentPoint = (props, hoveredValue) => {
|
|
318
|
+
const { payload, label } = props;
|
|
319
|
+
const tooltipValues = payload.map((item) => ({
|
|
320
|
+
label: item.name,
|
|
321
|
+
value: item.value,
|
|
322
|
+
isHovered: item.name === hoveredValue,
|
|
323
|
+
}));
|
|
324
|
+
return {
|
|
325
|
+
category: label,
|
|
326
|
+
values: tooltipValues,
|
|
327
|
+
};
|
|
328
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Buttonv2.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/buttonv2/Buttonv2.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAI7C,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAW,KAAK,IAAI,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE9E,eAAO,MAAM,iBAAiB,oIAI7B,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,IAAI,CACtB,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,MAAM,GAAG,OAAO,CACjB,GAAG;IACF,OAA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,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AACF,eAAO,MAAM,YAAY,+GA0KxB,CAAC;AACF,eAAO,MAAM,WAAW,0GAIvB,CAAC;AACF,eAAO,MAAM,UAAU;WAAwB,KAAK,CAAC,SAAS;SAS7D,CAAC;AAEF,eAAO,MAAM,YAAY;;;SAaxB,CAAC;AAEF,iBAAS,MAAM,CAAC,EACd,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,OAAO,EACP,OAAO,EACP,SAAS,EACT,GAAG,IAAI,EACR,EAAE,KAAK,2CAqDP;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -35,8 +35,10 @@ export const ButtonStyled = styled.button `
|
|
|
35
35
|
switch (props.variant) {
|
|
36
36
|
case 'primary':
|
|
37
37
|
return css `
|
|
38
|
-
background
|
|
39
|
-
|
|
38
|
+
background: ${brand.buttonPrimary};
|
|
39
|
+
background-clip: padding-box, border-box;
|
|
40
|
+
border: ${spacing.r1} solid transparent;
|
|
41
|
+
border-color: ${brand.buttonPrimary};
|
|
40
42
|
color: ${brand.textPrimary};
|
|
41
43
|
&:hover:enabled {
|
|
42
44
|
cursor: pointer;
|
|
@@ -56,8 +58,10 @@ export const ButtonStyled = styled.button `
|
|
|
56
58
|
`;
|
|
57
59
|
case 'secondary':
|
|
58
60
|
return css `
|
|
59
|
-
background
|
|
60
|
-
|
|
61
|
+
background: ${brand.buttonSecondary};
|
|
62
|
+
background-clip: padding-box, border-box;
|
|
63
|
+
border: ${spacing.r1} solid transparent;
|
|
64
|
+
border-color: ${brand.buttonSecondary};
|
|
61
65
|
color: ${brand.textPrimary};
|
|
62
66
|
&:hover:enabled {
|
|
63
67
|
cursor: pointer;
|
|
@@ -71,7 +75,8 @@ export const ButtonStyled = styled.button `
|
|
|
71
75
|
&:active:enabled {
|
|
72
76
|
cursor: pointer;
|
|
73
77
|
color: ${brand.textPrimary};
|
|
74
|
-
border: ${spacing.r1} solid
|
|
78
|
+
border: ${spacing.r1} solid transparent;
|
|
79
|
+
border-color: ${brand.buttonSecondary};
|
|
75
80
|
}
|
|
76
81
|
`;
|
|
77
82
|
case 'danger':
|
|
@@ -93,13 +98,19 @@ export const ButtonStyled = styled.button `
|
|
|
93
98
|
`;
|
|
94
99
|
case 'outline':
|
|
95
100
|
return css `
|
|
96
|
-
border: ${spacing.r1} solid
|
|
101
|
+
border: ${spacing.r1} solid transparent;
|
|
102
|
+
border-color: ${brand.border}; // fallback for linear-gradient button themes
|
|
103
|
+
border-color: ${brand.buttonSecondary};
|
|
97
104
|
background-color: transparent;
|
|
98
105
|
color: ${brand.textPrimary};
|
|
99
106
|
&:hover:enabled {
|
|
100
107
|
cursor: pointer;
|
|
101
108
|
border-color: ${brand.infoPrimary};
|
|
102
109
|
color: ${brand.textPrimary};
|
|
110
|
+
|
|
111
|
+
&::before {
|
|
112
|
+
background-image: ${brand.buttonPrimary};
|
|
113
|
+
}
|
|
103
114
|
}
|
|
104
115
|
&:focus-visible:enabled {
|
|
105
116
|
${FocusVisibleStyle}
|
|
@@ -110,6 +121,16 @@ export const ButtonStyled = styled.button `
|
|
|
110
121
|
border: ${spacing.r1} solid ${brand.infoSecondary};
|
|
111
122
|
color: ${brand.textPrimary};
|
|
112
123
|
}
|
|
124
|
+
&::before {
|
|
125
|
+
content: '';
|
|
126
|
+
position: absolute;
|
|
127
|
+
inset: 0;
|
|
128
|
+
padding: ${spacing.r1};
|
|
129
|
+
border-radius: inherit;
|
|
130
|
+
mask: linear-gradient(white, white) content-box, linear-gradient(white, white);
|
|
131
|
+
mask-composite: exclude;
|
|
132
|
+
pointer-events: none;
|
|
133
|
+
}
|
|
113
134
|
`;
|
|
114
135
|
default:
|
|
115
136
|
}
|
|
@@ -1,19 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Long date formatter, with weekday, year, month and day. Used for describing long term date.
|
|
3
|
+
* @example Wednesday 6 October 2025
|
|
4
|
+
*/
|
|
1
5
|
export declare const LONG_DATE_FORMATER: Intl.DateTimeFormat;
|
|
6
|
+
/**
|
|
7
|
+
* @description Long date formatter, without weekday.
|
|
8
|
+
* @example 01 September 2025
|
|
9
|
+
*/
|
|
10
|
+
export declare const LONG_DATE_FORMATER_WITHOUT_WEEKDAY: Intl.DateTimeFormat;
|
|
11
|
+
/**
|
|
12
|
+
* @description Date formatter, with year, month and day. Used for describing long term date.
|
|
13
|
+
* @example 2025-01-01
|
|
14
|
+
*/
|
|
2
15
|
export declare const DATE_FORMATER: Intl.DateTimeFormat;
|
|
16
|
+
/**
|
|
17
|
+
* @description Day month formatter, with weekday, day and month. Used for describing long term date.
|
|
18
|
+
* @example Wed 6 Oct
|
|
19
|
+
*/
|
|
3
20
|
export declare const DAY_MONTH_FORMATER: Intl.DateTimeFormat;
|
|
21
|
+
/**
|
|
22
|
+
* @description Time formatter, with hour, minute and second. Used for describing long term date.
|
|
23
|
+
* @example 18:33:00
|
|
24
|
+
*/
|
|
4
25
|
export declare const TIME_SECOND_FORMATER: Intl.DateTimeFormat;
|
|
26
|
+
/**
|
|
27
|
+
* @description Time formatter, with hour and minute. Used for describing long term date.
|
|
28
|
+
* @example 18:33
|
|
29
|
+
*/
|
|
5
30
|
export declare const TIME_FORMATER: Intl.DateTimeFormat;
|
|
31
|
+
/**
|
|
32
|
+
* @description Day month abbreviated hour minute second formatter. Used for describing long term date.
|
|
33
|
+
* @example 6 Oct 18:33:00
|
|
34
|
+
*/
|
|
6
35
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND: Intl.DateTimeFormat;
|
|
36
|
+
/**
|
|
37
|
+
* @description Day month abbreviated hour minute formatter. Used for describing long term date.
|
|
38
|
+
* @example 6 Oct 18:33
|
|
39
|
+
*/
|
|
7
40
|
export declare const DAY_MONTH_ABBREVIATED_HOUR_MINUTE: Intl.DateTimeFormat;
|
|
8
41
|
/**
|
|
9
42
|
* @description Year month day formatter, without time. Used for describing long term date.
|
|
10
43
|
* @example 2025-01-01
|
|
11
44
|
*/
|
|
12
45
|
export declare const YEAR_MONTH_DAY_FORMATTER: Intl.DateTimeFormat;
|
|
46
|
+
/**
|
|
47
|
+
* @description Month day formatter, without year. Used for short term date ranges.
|
|
48
|
+
* @example 01-15
|
|
49
|
+
*/
|
|
50
|
+
export declare const MONTH_DAY_FORMATTER: Intl.DateTimeFormat;
|
|
13
51
|
type FormattedDateTimeProps = {
|
|
14
|
-
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative' | 'day-month-abbreviated-hour-minute' | 'day-month-abbreviated-hour-minute-second' | 'long-date' | 'chart-date' | 'year-month-day';
|
|
52
|
+
format: 'date' | 'date-time' | 'date-time-second' | 'time' | 'time-second' | 'relative' | 'day-month-abbreviated-hour-minute' | 'day-month-abbreviated-hour-minute-second' | 'long-date' | 'long-date-without-weekday' | 'chart-date' | 'year-month-day' | 'month-day';
|
|
15
53
|
value: Date;
|
|
16
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* @description Formats the date and time according to the format specified.
|
|
57
|
+
* @example
|
|
58
|
+
* date: '2025-01-01'
|
|
59
|
+
* 'date-time': '2025-01-01 00:00'
|
|
60
|
+
* 'date-time-second': '2025-01-01 00:00:00'
|
|
61
|
+
* time: '00:00'
|
|
62
|
+
* 'time-second': '00:00:00'
|
|
63
|
+
* relative: '1 month ago'
|
|
64
|
+
* 'day-month-abbreviated-hour-minute': '6 Oct 18:33'
|
|
65
|
+
* 'day-month-abbreviated-hour-minute-second': '6 Oct 18:33:00'
|
|
66
|
+
* 'long-date': 'Wednesday 6 October 2025'
|
|
67
|
+
* 'chart-date': '6 Oct'
|
|
68
|
+
* 'year-month-day': '2025-10-06'
|
|
69
|
+
*/
|
|
17
70
|
export declare const FormattedDateTime: ({ format, value, }: FormattedDateTimeProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
71
|
export {};
|
|
19
72
|
//# sourceMappingURL=FormattedDateTime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,qBAK7B,CAAC;AAEH,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;;;GAGG;AACH,eAAO,MAAM,wBAAwB,qBAInC,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,GACV,mCAAmC,GACnC,0CAA0C,GAC1C,WAAW,GACX,YAAY,GACZ,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormattedDateTime.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.tsx"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,qBAK7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kCAAkC,qBAI7C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,qBAKxB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,qBAI7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,qBAK/B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,qBAIxB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wCAAwC,qBAUpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iCAAiC,qBAM5C,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,qBAInC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,qBAG9B,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EACF,MAAM,GACN,WAAW,GACX,kBAAkB,GAClB,MAAM,GACN,aAAa,GACb,UAAU,GACV,mCAAmC,GACnC,0CAA0C,GAC1C,WAAW,GACX,2BAA2B,GAC3B,YAAY,GACZ,gBAAgB,GAChB,WAAW,CAAC;IAEhB,KAAK,EAAE,IAAI,CAAC;CACb,CAAC;AAaF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,uBAG3B,sBAAsB,4CAsIxB,CAAC"}
|
|
@@ -1,44 +1,81 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getDateDaysDiff } from './dateDiffer';
|
|
3
3
|
import { Tooltip } from '../tooltip/Tooltip.component';
|
|
4
|
+
/**
|
|
5
|
+
* @description Long date formatter, with weekday, year, month and day. Used for describing long term date.
|
|
6
|
+
* @example Wednesday 6 October 2025
|
|
7
|
+
*/
|
|
4
8
|
export const LONG_DATE_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
5
9
|
weekday: 'long',
|
|
6
10
|
year: 'numeric',
|
|
7
11
|
month: 'long',
|
|
8
|
-
day: '
|
|
12
|
+
day: '2-digit',
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* @description Long date formatter, without weekday.
|
|
16
|
+
* @example 01 September 2025
|
|
17
|
+
*/
|
|
18
|
+
export const LONG_DATE_FORMATER_WITHOUT_WEEKDAY = Intl.DateTimeFormat('en-GB', {
|
|
19
|
+
year: 'numeric',
|
|
20
|
+
month: 'long',
|
|
21
|
+
day: '2-digit',
|
|
9
22
|
});
|
|
23
|
+
/**
|
|
24
|
+
* @description Date formatter, with year, month and day. Used for describing long term date.
|
|
25
|
+
* @example 2025-01-01
|
|
26
|
+
*/
|
|
10
27
|
export const DATE_FORMATER = Intl.DateTimeFormat('fr-CA', {
|
|
11
28
|
year: 'numeric',
|
|
12
29
|
month: '2-digit',
|
|
13
30
|
day: '2-digit',
|
|
14
31
|
hour12: false,
|
|
15
32
|
});
|
|
33
|
+
/**
|
|
34
|
+
* @description Day month formatter, with weekday, day and month. Used for describing long term date.
|
|
35
|
+
* @example Wed 6 Oct
|
|
36
|
+
*/
|
|
16
37
|
export const DAY_MONTH_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
17
38
|
weekday: 'short',
|
|
18
39
|
day: '2-digit',
|
|
19
40
|
month: 'short',
|
|
20
41
|
});
|
|
42
|
+
/**
|
|
43
|
+
* @description Time formatter, with hour, minute and second. Used for describing long term date.
|
|
44
|
+
* @example 18:33:00
|
|
45
|
+
*/
|
|
21
46
|
export const TIME_SECOND_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
22
47
|
hour12: false,
|
|
23
48
|
hour: '2-digit',
|
|
24
49
|
minute: '2-digit',
|
|
25
50
|
second: '2-digit',
|
|
26
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* @description Time formatter, with hour and minute. Used for describing long term date.
|
|
54
|
+
* @example 18:33
|
|
55
|
+
*/
|
|
27
56
|
export const TIME_FORMATER = Intl.DateTimeFormat('en-GB', {
|
|
28
57
|
hour12: false,
|
|
29
58
|
hour: '2-digit',
|
|
30
59
|
minute: '2-digit',
|
|
31
60
|
});
|
|
61
|
+
/**
|
|
62
|
+
* @description Day month abbreviated hour minute second formatter. Used for describing long term date.
|
|
63
|
+
* @example 6 Oct 18:33:00
|
|
64
|
+
*/
|
|
32
65
|
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND = Intl.DateTimeFormat('en-GB', {
|
|
33
|
-
day: '
|
|
66
|
+
day: '2-digit',
|
|
34
67
|
month: 'short',
|
|
35
68
|
hour: '2-digit',
|
|
36
69
|
minute: '2-digit',
|
|
37
70
|
second: '2-digit',
|
|
38
71
|
hour12: false,
|
|
39
72
|
});
|
|
73
|
+
/**
|
|
74
|
+
* @description Day month abbreviated hour minute formatter. Used for describing long term date.
|
|
75
|
+
* @example 6 Oct 18:33
|
|
76
|
+
*/
|
|
40
77
|
export const DAY_MONTH_ABBREVIATED_HOUR_MINUTE = Intl.DateTimeFormat('en-GB', {
|
|
41
|
-
day: '
|
|
78
|
+
day: '2-digit',
|
|
42
79
|
month: 'short',
|
|
43
80
|
hour: '2-digit',
|
|
44
81
|
minute: '2-digit',
|
|
@@ -53,6 +90,14 @@ export const YEAR_MONTH_DAY_FORMATTER = Intl.DateTimeFormat('en-CA', {
|
|
|
53
90
|
month: '2-digit',
|
|
54
91
|
day: '2-digit',
|
|
55
92
|
});
|
|
93
|
+
/**
|
|
94
|
+
* @description Month day formatter, without year. Used for short term date ranges.
|
|
95
|
+
* @example 01-15
|
|
96
|
+
*/
|
|
97
|
+
export const MONTH_DAY_FORMATTER = Intl.DateTimeFormat('en-CA', {
|
|
98
|
+
month: '2-digit',
|
|
99
|
+
day: '2-digit',
|
|
100
|
+
});
|
|
56
101
|
const isItFutureOrIsItPast = (timeDiff, stringToBeFormatted) => {
|
|
57
102
|
if (timeDiff > 0) {
|
|
58
103
|
return `${stringToBeFormatted} ago`;
|
|
@@ -61,6 +106,21 @@ const isItFutureOrIsItPast = (timeDiff, stringToBeFormatted) => {
|
|
|
61
106
|
return `in ${stringToBeFormatted}`;
|
|
62
107
|
}
|
|
63
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* @description Formats the date and time according to the format specified.
|
|
111
|
+
* @example
|
|
112
|
+
* date: '2025-01-01'
|
|
113
|
+
* 'date-time': '2025-01-01 00:00'
|
|
114
|
+
* 'date-time-second': '2025-01-01 00:00:00'
|
|
115
|
+
* time: '00:00'
|
|
116
|
+
* 'time-second': '00:00:00'
|
|
117
|
+
* relative: '1 month ago'
|
|
118
|
+
* 'day-month-abbreviated-hour-minute': '6 Oct 18:33'
|
|
119
|
+
* 'day-month-abbreviated-hour-minute-second': '6 Oct 18:33:00'
|
|
120
|
+
* 'long-date': 'Wednesday 6 October 2025'
|
|
121
|
+
* 'chart-date': '6 Oct'
|
|
122
|
+
* 'year-month-day': '2025-10-06'
|
|
123
|
+
*/
|
|
64
124
|
export const FormattedDateTime = ({ format, value, }) => {
|
|
65
125
|
switch (format) {
|
|
66
126
|
case 'date':
|
|
@@ -95,15 +155,27 @@ export const FormattedDateTime = ({ format, value, }) => {
|
|
|
95
155
|
}
|
|
96
156
|
return (_jsx(Tooltip, { overlay: _jsx(FormattedDateTime, { format: "date-time-second", value: value }), children: "few seconds ago" }));
|
|
97
157
|
case 'day-month-abbreviated-hour-minute':
|
|
98
|
-
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value)
|
|
158
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE.format(value)
|
|
159
|
+
.replace(',', '')
|
|
160
|
+
.replace(/Sept/g, 'Sep') }));
|
|
99
161
|
case 'day-month-abbreviated-hour-minute-second':
|
|
100
|
-
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value)
|
|
162
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_ABBREVIATED_HOUR_MINUTE_SECOND.format(value)
|
|
163
|
+
.replace(',', '')
|
|
164
|
+
// replace Sept with Sep to keep 3 letter month
|
|
165
|
+
.replace(/Sept/g, 'Sep') }));
|
|
101
166
|
case 'long-date':
|
|
102
167
|
return _jsx(_Fragment, { children: LONG_DATE_FORMATER.format(value) });
|
|
168
|
+
case 'long-date-without-weekday':
|
|
169
|
+
return _jsx(_Fragment, { children: LONG_DATE_FORMATER_WITHOUT_WEEKDAY.format(value) });
|
|
103
170
|
case 'chart-date':
|
|
104
|
-
return _jsx(_Fragment, { children: DAY_MONTH_FORMATER.format(value)
|
|
171
|
+
return (_jsx(_Fragment, { children: DAY_MONTH_FORMATER.format(value)
|
|
172
|
+
.replace(/[ ,]/g, '')
|
|
173
|
+
// replace Sept with Sep to keep 3 letter month
|
|
174
|
+
.replace(/Sept/g, 'Sep') }));
|
|
105
175
|
case 'year-month-day':
|
|
106
176
|
return _jsx(_Fragment, { children: YEAR_MONTH_DAY_FORMATTER.format(value) });
|
|
177
|
+
case 'month-day':
|
|
178
|
+
return _jsx(_Fragment, { children: MONTH_DAY_FORMATTER.format(value) });
|
|
107
179
|
default:
|
|
108
180
|
return _jsx(_Fragment, {});
|
|
109
181
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { FormattedDateTime } from './FormattedDateTime';
|
|
4
4
|
import userEvent from '@testing-library/user-event';
|
|
@@ -141,12 +141,21 @@ describe('FormatttedDateTime', () => {
|
|
|
141
141
|
//S
|
|
142
142
|
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date('2022-10-06T18:33:00Z') }));
|
|
143
143
|
//V
|
|
144
|
-
expect(screen.getByText('
|
|
144
|
+
expect(screen.getByText('06 Oct 18:33')).toBeInTheDocument();
|
|
145
145
|
});
|
|
146
146
|
it('should display the date in the expected format of date in the chart', () => {
|
|
147
147
|
//S
|
|
148
148
|
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute-second", value: new Date('2022-10-06T18:33:00Z') }));
|
|
149
149
|
//V
|
|
150
|
-
expect(screen.getByText('
|
|
150
|
+
expect(screen.getByText('06 Oct 18:33:00')).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
it('should display 3 letter month for September date', () => {
|
|
153
|
+
//S
|
|
154
|
+
render(_jsxs(_Fragment, { children: [_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date('2022-09-06T18:33:00Z') }), _jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute-second", value: new Date('2022-09-06T18:33:00Z') }), _jsx(FormattedDateTime, { format: "chart-date", value: new Date('2022-09-06T18:33:00Z') })] }));
|
|
155
|
+
//V
|
|
156
|
+
expect(screen.getByText(/06 Sep 18:33/)).toBeInTheDocument();
|
|
157
|
+
expect(screen.getByText(/06 Sep 18:33:00/)).toBeInTheDocument();
|
|
158
|
+
expect(screen.getByText(/Tue06Sep/)).toBeInTheDocument();
|
|
159
|
+
expect(screen.queryByText(/Sept/)).not.toBeInTheDocument();
|
|
151
160
|
});
|
|
152
161
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
export declare function Layout({ children: app, headerNavigation, }: {
|
|
2
|
+
export declare function Layout({ children: app, headerNavigation, variant, }: {
|
|
3
3
|
children: ReactElement | ReactElement[];
|
|
4
4
|
headerNavigation: ReactElement;
|
|
5
|
+
variant?: 'transparent';
|
|
5
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/v2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAgBrC,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EAAE,GAAG,EACb,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/v2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAgBrC,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EAAE,GAAG,EACb,gBAAgB,EAChB,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,CAAC;IACxC,gBAAgB,EAAE,YAAY,CAAC;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,2CAOA"}
|
|
@@ -6,11 +6,11 @@ const LayoutContainer = styled.div `
|
|
|
6
6
|
flex-direction: column;
|
|
7
7
|
height: 100vh;
|
|
8
8
|
box-sizing: border-box;
|
|
9
|
-
background: ${
|
|
9
|
+
background: ${props => props.variant === 'transparent' ? 'transparent' : props.theme.backgroundLevel1};
|
|
10
10
|
`;
|
|
11
11
|
const Navigation = styled.div `
|
|
12
12
|
height: ${navbarHeight};
|
|
13
13
|
`;
|
|
14
|
-
export function Layout({ children: app, headerNavigation, }) {
|
|
15
|
-
return (_jsxs(LayoutContainer, { className: "layout-container", children: [_jsx(Navigation, { children: headerNavigation }), app] }));
|
|
14
|
+
export function Layout({ children: app, headerNavigation, variant, }) {
|
|
15
|
+
return (_jsxs(LayoutContainer, { className: "layout-container", variant: variant, children: [_jsx(Navigation, { children: headerNavigation }), app] }));
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linetimeseriechart.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx"],"names":[],"mappings":"AAoGA,MAAM,MAAM,KAAK,GAAG;IAElB,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAEzC,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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