@scality/core-ui 0.171.0 → 0.172.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.
Files changed (72) hide show
  1. package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
  2. package/dist/components/barchartv2/Barchart.component.js +2 -2
  3. package/dist/components/barchartv2/BarchartTooltip.d.ts +11 -0
  4. package/dist/components/barchartv2/BarchartTooltip.d.ts.map +1 -0
  5. package/dist/components/barchartv2/BarchartTooltip.js +27 -0
  6. package/dist/components/charttooltip/ChartTooltip.d.ts +13 -0
  7. package/dist/components/charttooltip/ChartTooltip.d.ts.map +1 -0
  8. package/dist/components/charttooltip/ChartTooltip.js +49 -0
  9. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +4 -0
  10. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +1 -1
  11. package/dist/components/globalhealthbar/GlobalHealthBar.component.js +4 -0
  12. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts +10 -0
  13. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +1 -0
  14. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.js +78 -0
  15. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts +18 -0
  16. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +1 -0
  17. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.js +95 -0
  18. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts +7 -0
  19. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +1 -0
  20. package/dist/components/globalhealthbar/components/HealthBarXAxis.js +25 -0
  21. package/dist/components/globalhealthbar/healthBarUtils.d.ts +77 -0
  22. package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +1 -0
  23. package/dist/components/globalhealthbar/healthBarUtils.js +196 -0
  24. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +2 -0
  25. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +1 -0
  26. package/dist/components/globalhealthbar/healthBarUtils.spec.js +391 -0
  27. package/dist/components/globalhealthbar/useHealthBarData.d.ts +18 -0
  28. package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +1 -0
  29. package/dist/components/globalhealthbar/useHealthBarData.js +46 -0
  30. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +2 -0
  31. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +1 -0
  32. package/dist/components/globalhealthbar/useHealthBarData.spec.js +207 -0
  33. package/dist/components/icon/Icon.component.js +2 -2
  34. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +0 -2
  35. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
  36. package/dist/components/linetimeseriechart/linetimeseriechart.component.js +17 -57
  37. package/dist/components/sparkline/sparkline.component.d.ts +16 -0
  38. package/dist/components/sparkline/sparkline.component.d.ts.map +1 -0
  39. package/dist/components/sparkline/sparkline.component.js +20 -0
  40. package/dist/components/text/Text.component.d.ts +1 -1
  41. package/dist/components/text/Text.component.d.ts.map +1 -1
  42. package/dist/components/text/Text.component.js +6 -1
  43. package/dist/next.d.ts +3 -1
  44. package/dist/next.d.ts.map +1 -1
  45. package/dist/next.js +3 -1
  46. package/package.json +2 -2
  47. package/src/lib/components/barchartv2/Barchart.component.tsx +3 -2
  48. package/src/lib/components/barchartv2/{ChartTooltip.test.tsx → BarchartTooltip.test.tsx} +35 -12
  49. package/src/lib/components/barchartv2/BarchartTooltip.tsx +89 -0
  50. package/src/lib/components/charttooltip/ChartTooltip.tsx +83 -0
  51. package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +4 -1
  52. package/src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component.tsx +203 -0
  53. package/src/lib/components/globalhealthbar/components/GlobalHealthBarTooltip.tsx +173 -0
  54. package/src/lib/components/globalhealthbar/components/HealthBarXAxis.tsx +94 -0
  55. package/src/lib/components/globalhealthbar/healthBarUtils.spec.ts +701 -0
  56. package/src/lib/components/globalhealthbar/healthBarUtils.ts +311 -0
  57. package/src/lib/components/globalhealthbar/useHealthBarData.spec.tsx +487 -0
  58. package/src/lib/components/globalhealthbar/useHealthBarData.ts +74 -0
  59. package/src/lib/components/icon/Icon.component.tsx +2 -2
  60. package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +50 -77
  61. package/src/lib/components/sparkline/sparkline.component.tsx +54 -0
  62. package/src/lib/components/text/Text.component.tsx +8 -2
  63. package/src/lib/next.ts +8 -1
  64. package/stories/GlobalHealthBar/globalhealthbarRecharts.stories.tsx +145 -0
  65. package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +5 -0
  66. package/stories/InlineInput/InlineInput.stories.tsx +7 -1
  67. package/stories/globalhealthbar.stories.tsx +25 -5
  68. package/stories/sparkline.stories.tsx +168 -0
  69. package/dist/components/barchartv2/ChartTooltip.d.ts +0 -14
  70. package/dist/components/barchartv2/ChartTooltip.d.ts.map +0 -1
  71. package/dist/components/barchartv2/ChartTooltip.js +0 -41
  72. package/src/lib/components/barchartv2/ChartTooltip.tsx +0 -106
@@ -1 +1 @@
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,MA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EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,UAAU,eAAe;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,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"}
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,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AC,4CAuJvE,CAAC"}
@@ -11,7 +11,7 @@ import { FormattedDateTime } from '../date/FormattedDateTime';
11
11
  import { IconHelp } from '../iconhelper/IconHelper';
12
12
  import { Loader } from '../loader/Loader.component';
13
13
  import { Text } from '../text/Text.component';
14
- import { ChartTooltip } from './ChartTooltip';
14
+ import { BarchartTooltip } from './BarchartTooltip';
15
15
  import { useChartData } from './utils';
16
16
  const CHART_CONSTANTS = {
17
17
  TICK_WIDTH_OFFSET: 4,
@@ -122,5 +122,5 @@ export const Barchart = (props) => {
122
122
  stroke: theme.textSecondary,
123
123
  }, axisLine: {
124
124
  stroke: theme.textSecondary,
125
- } }), _jsx(Tooltip, { content: (props) => (_jsx(ChartTooltip, { type: type, colorSet: colorSet, tooltipProps: props, hoveredValue: hoveredValue, tooltip: tooltip })), cursor: false })] }) }))] }));
125
+ } }), _jsx(Tooltip, { content: (props) => (_jsx(BarchartTooltip, { type: type, colorSet: colorSet, tooltipProps: props, hoveredValue: hoveredValue, tooltip: tooltip, unitLabel: unitLabel })), cursor: false })] }) }))] }));
126
126
  };
@@ -0,0 +1,11 @@
1
+ import { BarchartBars, BarchartTooltipFn, CategoryType, TimeType } from './Barchart.component';
2
+ import { TooltipContentProps } from 'recharts';
3
+ export declare const BarchartTooltip: <T extends BarchartBars>({ type, tooltipProps, colorSet, hoveredValue, tooltip, unitLabel, }: {
4
+ type: TimeType | CategoryType;
5
+ tooltipProps: TooltipContentProps<number, string>;
6
+ colorSet?: Record<string, string>;
7
+ hoveredValue: string | undefined;
8
+ tooltip?: BarchartTooltipFn<T>;
9
+ unitLabel?: string;
10
+ }) => string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
11
+ //# sourceMappingURL=BarchartTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BarchartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/barchartv2/BarchartTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAU/C,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,YAAY,uEAOnD;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;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,iIAyDA,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FormattedDateTime } from '../date/FormattedDateTime';
3
+ import { getCurrentPoint } from './utils';
4
+ import { ChartTooltipContainer, ChartTooltipItem, ChartTooltipHeader, ChartTooltipItemsContainer, } from '../charttooltip/ChartTooltip';
5
+ import { LegendShape } from '../chartlegend/ChartLegend';
6
+ export const BarchartTooltip = ({ type, tooltipProps, colorSet, hoveredValue, tooltip, unitLabel, }) => {
7
+ const { active } = tooltipProps;
8
+ if (!active) {
9
+ return null;
10
+ }
11
+ const currentPoint = getCurrentPoint(tooltipProps, hoveredValue);
12
+ if (tooltip) {
13
+ return tooltip(currentPoint);
14
+ }
15
+ return (_jsxs(ChartTooltipContainer, { children: [_jsx(ChartTooltipHeader, { children: type.type === 'time' ? (_jsx(FormattedDateTime, { format: type.timeRange.interval < 24 * 60 * 60 * 1000
16
+ ? 'day-month-abbreviated-hour-minute-second'
17
+ : 'long-date-without-weekday', value: new Date(currentPoint.category) })) : (currentPoint.category) }), _jsx(ChartTooltipItemsContainer, { children: currentPoint.values.map((value) => {
18
+ const legendIcon = colorSet && (_jsx(LegendShape, { color: colorSet[value.label], shape: "rectangle", chartColors: colorSet }));
19
+ const formattedValue = Number.isInteger(value.value)
20
+ ? `${value.value}`
21
+ : value.value.toFixed(2);
22
+ const valueWithUnit = unitLabel
23
+ ? `${formattedValue} ${unitLabel}`
24
+ : formattedValue;
25
+ return (_jsx(ChartTooltipItem, { label: value.label, value: valueWithUnit, isHovered: value.isHovered, legendIcon: legendIcon }, value.label));
26
+ }) })] }));
27
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export declare const ChartTooltipContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
+ interface ChartTooltipItemProps {
4
+ label: React.ReactNode;
5
+ value: React.ReactNode;
6
+ isHovered?: boolean;
7
+ legendIcon?: React.ReactNode;
8
+ }
9
+ export declare const ChartTooltipItem: React.FC<ChartTooltipItemProps>;
10
+ export declare const ChartTooltipHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
11
+ export declare const ChartTooltipItemsContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
12
+ export {};
13
+ //# sourceMappingURL=ChartTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../src/lib/components/charttooltip/ChartTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,eAAO,MAAM,qBAAqB,yGAUjC,CAAC;AA+BF,UAAU,qBAAqB;IAC7B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAe5D,CAAC;AAEF,eAAO,MAAM,kBAAkB,yGAK9B,CAAC;AAEF,eAAO,MAAM,0BAA0B,yGAKtC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styled from 'styled-components';
3
+ import { spacing } from '../../spacing';
4
+ import { fontSize, fontWeight } from '../../style/theme';
5
+ export const ChartTooltipContainer = styled.div `
6
+ border: 1px solid ${({ theme }) => theme.border};
7
+ background-color: ${({ theme }) => theme.backgroundLevel1};
8
+ color: ${({ theme }) => theme.textPrimary};
9
+ border-radius: 4px;
10
+ font-size: ${fontSize.small};
11
+ padding: ${spacing.r8};
12
+ min-width: 10rem;
13
+ max-width: 250px;
14
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
15
+ `;
16
+ const TooltipText = styled.div `
17
+ color: ${({ theme, isHovered }) => isHovered ? theme.textPrimary : theme.textSecondary};
18
+ font-size: ${fontSize.smaller};
19
+ font-weight: ${({ isHovered }) => isHovered ? fontWeight.bold : fontWeight.base};
20
+ text-align: ${({ align }) => align || 'left'};
21
+ ${({ align }) => align === 'right' && 'flex-shrink: 0;'}
22
+ `;
23
+ const TooltipRow = styled.div `
24
+ display: flex;
25
+ justify-content: space-between;
26
+ align-items: center;
27
+ gap: ${spacing.r32};
28
+ width: 100%;
29
+ `;
30
+ const TooltipLabel = styled.div `
31
+ display: flex;
32
+ align-items: center;
33
+ gap: ${spacing.r8};
34
+ flex: 1;
35
+ min-width: 0;
36
+ `;
37
+ export const ChartTooltipItem = ({ label, value, isHovered = false, legendIcon, }) => (_jsxs(TooltipRow, { children: [_jsxs(TooltipLabel, { children: [legendIcon, _jsx(TooltipText, { isHovered: isHovered, children: label })] }), _jsx(TooltipText, { isHovered: isHovered, align: "right", children: value })] }));
38
+ export const ChartTooltipHeader = styled.div `
39
+ color: ${({ theme }) => theme.textPrimary};
40
+ font-weight: ${fontWeight.bold};
41
+ text-align: center;
42
+ margin-bottom: ${spacing.r8};
43
+ `;
44
+ export const ChartTooltipItemsContainer = styled.div `
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: ${spacing.r8};
48
+ width: 100%;
49
+ `;
@@ -14,6 +14,10 @@ export type GlobalHealthProps = {
14
14
  height?: number;
15
15
  tooltipPosition?: Position;
16
16
  };
17
+ /**
18
+ * @deprecated Use GlobalHealthBar v2 instead
19
+ * @example import { GlobalHealthBar } from '@scality/core-ui/dist/next';
20
+ */
17
21
  declare function GlobalHealthBar({ id, alerts, start, end, height, tooltipPosition, }: GlobalHealthProps): import("react/jsx-runtime").JSX.Element;
18
22
  export { GlobalHealthBar };
19
23
  //# sourceMappingURL=GlobalHealthBar.component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalHealthBar.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,KAAK,QAAQ,GAAG,OAAO,GAAG,GAAG,OAAO,MAAM,CAAC;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B,CAAC;AAEF,iBAAS,eAAe,CAAC,EACvB,EAAE,EACF,MAAM,EACN,KAAK,EACL,GAAG,EACH,MAAU,EACV,eAAqB,GACtB,EAAE,iBAAiB,2CAyKnB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"GlobalHealthBar.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,KAAK,QAAQ,GAAG,OAAO,GAAG,GAAG,OAAO,MAAM,CAAC;AAC3C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B,CAAC;AACF;;;GAGG;AACH,iBAAS,eAAe,CAAC,EACvB,EAAE,EACF,MAAM,EACN,KAAK,EACL,GAAG,EACH,MAAU,EACV,eAAqB,GACtB,EAAE,iBAAiB,2CAyKnB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -6,6 +6,10 @@ import { useTheme } from 'styled-components';
6
6
  import { formatValue } from './tooltip/index';
7
7
  export const TOP = 'top';
8
8
  export const BOTTOM = 'bottom';
9
+ /**
10
+ * @deprecated Use GlobalHealthBar v2 instead
11
+ * @example import { GlobalHealthBar } from '@scality/core-ui/dist/next';
12
+ */
9
13
  function GlobalHealthBar({ id, alerts, start, end, height = 8, tooltipPosition = TOP, }) {
10
14
  const theme = useTheme();
11
15
  const trimAlerts = alerts.map((alert) => {
@@ -0,0 +1,10 @@
1
+ import { Alert } from './useHealthBarData';
2
+ export interface GlobalHealthProps {
3
+ id: string;
4
+ alerts: Alert[];
5
+ start: Date;
6
+ end: Date;
7
+ }
8
+ export declare function GlobalHealthBar({ id, alerts, start, end }: GlobalHealthProps): import("react/jsx-runtime").JSX.Element;
9
+ export type { Alert };
10
+ //# sourceMappingURL=GlobalHealthBarRecharts.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalHealthBarRecharts.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAoB,MAAM,oBAAoB,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAMD,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,iBAAiB,2CAyK5E;AAGD,YAAY,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useRef, useState } from 'react';
3
+ import { Bar, BarChart, ResponsiveContainer, Tooltip, YAxis, } from 'recharts';
4
+ import styled, { useTheme } from 'styled-components';
5
+ import { GlobalHealthBarTooltip } from './components/GlobalHealthBarTooltip';
6
+ import { HealthBarXAxis } from './components/HealthBarXAxis';
7
+ import { CHART_CONFIG, getNavigationAction, getNavigationStateUpdate, } from './healthBarUtils';
8
+ import { useHealthBarData } from './useHealthBarData';
9
+ const ChartInteractiveContainer = styled.div `
10
+ position: relative;
11
+ `;
12
+ export function GlobalHealthBar({ id, alerts, start, end }) {
13
+ const [tooltipData, setTooltipData] = useState(null);
14
+ const [focusedAlertIndex, setFocusedAlertIndex] = useState(-1);
15
+ const [keyboardActive, setKeyboardActive] = useState(false);
16
+ const chartContainerRef = useRef(null);
17
+ const theme = useTheme();
18
+ const startTimestamp = new Date(start).getTime();
19
+ const endTimestamp = new Date(end).getTime();
20
+ const { chartData, alertsMap, alertKeys } = useHealthBarData(alerts, startTimestamp, endTimestamp, id);
21
+ const handlePointerEnter = useCallback((key) => {
22
+ setTooltipData(alertsMap[key]);
23
+ }, [alertsMap]);
24
+ const handlePointerLeave = useCallback(() => {
25
+ if (!keyboardActive) {
26
+ setTooltipData(null);
27
+ }
28
+ }, [keyboardActive]);
29
+ const { warningKeys, criticalKeys, unavailableKeys } = alertKeys;
30
+ // Get all alert keys in order for keyboard navigation
31
+ const allAlertKeys = useMemo(() => {
32
+ return Object.values(alertsMap).sort((a, b) => {
33
+ return new Date(a.startsAt).getTime() - new Date(b.startsAt).getTime();
34
+ });
35
+ }, [alertsMap]);
36
+ // Handle keyboard navigation
37
+ const handleKeyDown = useCallback((event) => {
38
+ const action = getNavigationAction(event.key);
39
+ if (!action || allAlertKeys.length === 0)
40
+ return;
41
+ event.preventDefault();
42
+ const update = getNavigationStateUpdate(action, focusedAlertIndex, allAlertKeys);
43
+ setFocusedAlertIndex(update.newIndex);
44
+ setTooltipData(update.selectedAlert);
45
+ setKeyboardActive(update.shouldActivateKeyboard);
46
+ }, [allAlertKeys, focusedAlertIndex]);
47
+ // Handle focus events
48
+ const handleFocus = useCallback(() => {
49
+ if (allAlertKeys.length > 0 && focusedAlertIndex === -1) {
50
+ setFocusedAlertIndex(0);
51
+ setTooltipData(allAlertKeys[0]);
52
+ setKeyboardActive(true);
53
+ }
54
+ }, [allAlertKeys, focusedAlertIndex]);
55
+ const handleBlur = useCallback(() => {
56
+ setKeyboardActive(false);
57
+ setFocusedAlertIndex(-1);
58
+ setTooltipData(null);
59
+ }, []);
60
+ // Handle mouse enter to disable keyboard mode
61
+ const handleMouseEnter = useCallback(() => {
62
+ setKeyboardActive(false);
63
+ }, []);
64
+ const allAlertBars = useMemo(() => {
65
+ const configs = [
66
+ { keys: unavailableKeys, fill: theme.textSecondary },
67
+ { keys: warningKeys, fill: theme.statusWarning },
68
+ { keys: criticalKeys, fill: theme.statusCritical },
69
+ ];
70
+ return configs.flatMap(({ keys, fill }) => keys.map((key) => ({ key, fill })));
71
+ }, [unavailableKeys, warningKeys, criticalKeys, theme]);
72
+ return (_jsx(ChartInteractiveContainer, { ref: chartContainerRef, tabIndex: 0, role: "application", "aria-label": `Health bar chart with ${allAlertKeys.length} alerts. Use arrow keys to navigate, Escape to close tooltip.`, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, onMouseEnter: handleMouseEnter, children: _jsx(ResponsiveContainer, { width: '100%', height: CHART_CONFIG.CHART_HEIGHT, children: _jsxs(BarChart, { data: chartData, layout: "vertical", barSize: CHART_CONFIG.BAR_SIZE, accessibilityLayer: true, margin: CHART_CONFIG.MARGINS, children: [_jsx(HealthBarXAxis, { startTimestamp: startTimestamp, endTimestamp: endTimestamp }), _jsx(Tooltip, { allowEscapeViewBox: { x: true, y: true }, isAnimationActive: false, shared: false, wrapperStyle: {
73
+ width: '20rem',
74
+ position: 'fixed',
75
+ }, content: (props) => {
76
+ return (_jsx(GlobalHealthBarTooltip, { tooltipData: tooltipData, tooltipProps: props, chartContainerRef: chartContainerRef, isKeyboardActive: keyboardActive, startTimestamp: startTimestamp, endTimestamp: endTimestamp }));
77
+ } }), _jsx(YAxis, { yAxisId: 'background', type: "category", hide: true }), allAlertBars.map(({ key }) => (_jsx(YAxis, { yAxisId: key, type: "category", hide: true }, `yAxis${key}`))), _jsx(Bar, { dataKey: "range", fill: theme.statusHealthy, radius: CHART_CONFIG.RADIUS_SIZE, yAxisId: "background", isAnimationActive: false }), allAlertBars.map(({ key, fill }) => (_jsx(Bar, { dataKey: key, yAxisId: key, fill: fill, onPointerEnter: () => handlePointerEnter(key), onPointerLeave: () => handlePointerLeave(), isAnimationActive: false })))] }) }) }));
78
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { Alert } from '../GlobalHealthBarRecharts.component';
3
+ import { TooltipContentProps } from 'recharts';
4
+ interface GlobalHealthBarTooltipProps {
5
+ tooltipData: Alert | null;
6
+ coordinate?: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ tooltipProps: TooltipContentProps<number, string>;
11
+ chartContainerRef: React.RefObject<HTMLDivElement>;
12
+ isKeyboardActive?: boolean;
13
+ startTimestamp?: number;
14
+ endTimestamp?: number;
15
+ }
16
+ export declare const GlobalHealthBarTooltip: (props: GlobalHealthBarTooltipProps) => React.ReactPortal | null;
17
+ export {};
18
+ //# sourceMappingURL=GlobalHealthBarTooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalHealthBarTooltip.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/globalhealthbar/components/GlobalHealthBarTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,OAAO,EAAE,KAAK,EAAE,MAAM,sCAAsC,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAI/C,UAAU,2BAA2B;IACnC,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,YAAY,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACnD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAoBD,eAAO,MAAM,sBAAsB,UAAW,2BAA2B,6BA+HxE,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createPortal } from 'react-dom';
3
+ import { useEffect, useState } from 'react';
4
+ import styled, { css, useTheme } from 'styled-components';
5
+ import { useFloating, autoUpdate, offset, flip, shift, } from '@floating-ui/react';
6
+ import { FormattedDateTime, Stack, Text, Wrap, spacing } from '../../../index';
7
+ import { zIndex } from '../../../style/theme';
8
+ import { CHART_CONFIG, getTooltipPosition } from '../healthBarUtils';
9
+ const TooltipContainer = styled.div `
10
+ ${(props) => {
11
+ const theme = useTheme();
12
+ return css `
13
+ border: 1px solid ${theme.border};
14
+ width: 24rem;
15
+ z-index: ${zIndex.tooltip};
16
+ color: ${theme.textSecondary};
17
+ background-color: ${theme.backgroundLevel1};
18
+ border-radius: 4px;
19
+ padding: ${spacing.r8};
20
+ pointer-events: none;
21
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
22
+ `;
23
+ }}
24
+ `;
25
+ export const GlobalHealthBarTooltip = (props) => {
26
+ const { tooltipData, tooltipProps, chartContainerRef, isKeyboardActive = false, startTimestamp = 0, endTimestamp = 0, } = props;
27
+ const { coordinate } = tooltipProps;
28
+ const [virtualElement, setVirtualElement] = useState(null);
29
+ const { refs, floatingStyles } = useFloating({
30
+ elements: {
31
+ reference: virtualElement,
32
+ },
33
+ middleware: [
34
+ offset(({ placement }) => {
35
+ // Use larger offset when tooltip is on top
36
+ // to avoid tooltip over bar
37
+ return placement.includes('top') ? 20 : 30;
38
+ }),
39
+ flip(),
40
+ shift({ padding: 10 }),
41
+ ],
42
+ whileElementsMounted: autoUpdate,
43
+ });
44
+ // Create virtual element from coordinate
45
+ useEffect(() => {
46
+ if (chartContainerRef.current) {
47
+ const chartRect = chartContainerRef.current.getBoundingClientRect();
48
+ let tooltipX;
49
+ let tooltipY;
50
+ if (isKeyboardActive && tooltipData && startTimestamp && endTimestamp) {
51
+ // Calculate the chart's usable width (excluding margins)
52
+ const chartUsableWidth = chartRect.width -
53
+ CHART_CONFIG.MARGINS.left -
54
+ CHART_CONFIG.MARGINS.right;
55
+ // Use the same positioning logic as alert bars
56
+ const alertCenterX = getTooltipPosition(tooltipData, startTimestamp, endTimestamp, chartUsableWidth);
57
+ // Position tooltip at the center of the alert's time span
58
+ // alertCenterX already includes the margin offset, so just add chartRect.left
59
+ tooltipX = chartRect.left + alertCenterX;
60
+ tooltipY = chartRect.top + CHART_CONFIG.BAR_SIZE;
61
+ }
62
+ else {
63
+ // For mouse navigation, use the provided coordinate
64
+ tooltipX = chartRect.left + (coordinate === null || coordinate === void 0 ? void 0 : coordinate.x);
65
+ tooltipY = chartRect.top + (coordinate === null || coordinate === void 0 ? void 0 : coordinate.y);
66
+ }
67
+ setVirtualElement({
68
+ getBoundingClientRect() {
69
+ return {
70
+ width: 0,
71
+ height: 0,
72
+ x: tooltipX,
73
+ y: tooltipY,
74
+ left: tooltipX,
75
+ top: tooltipY,
76
+ right: tooltipX,
77
+ bottom: tooltipY,
78
+ };
79
+ },
80
+ });
81
+ }
82
+ }, [
83
+ coordinate,
84
+ chartContainerRef,
85
+ isKeyboardActive,
86
+ tooltipData,
87
+ startTimestamp,
88
+ endTimestamp,
89
+ ]);
90
+ if (!tooltipData)
91
+ return null;
92
+ const { description, startsAt, endsAt, severity } = tooltipData;
93
+ const tooltipContent = (_jsx(TooltipContainer, { ref: refs.setFloating, style: floatingStyles, children: _jsxs(Stack, { direction: "vertical", gap: "r8", children: [_jsxs(Wrap, { children: [_jsx(Text, { variant: "Smaller", children: "Severity" }), _jsx(Text, { color: "textPrimary", variant: "Smaller", children: severity })] }), _jsxs(Wrap, { children: [_jsx(Text, { variant: "Smaller", children: "Start" }), _jsx(Text, { color: "textPrimary", variant: "Smaller", children: _jsx(FormattedDateTime, { format: "date-time", value: new Date(startsAt) }) })] }), _jsxs(Wrap, { children: [_jsx(Text, { variant: "Smaller", children: "End" }), _jsx(Text, { color: "textPrimary", variant: "Smaller", children: _jsx(FormattedDateTime, { format: "date-time", value: new Date(endsAt) }) })] }), _jsxs(Wrap, { children: [_jsx(Text, { variant: "Smaller", style: { paddingRight: spacing.r32 }, children: "Description" }), _jsx(Text, { color: "textPrimary", variant: "Smaller", style: { whiteSpace: 'wrap', textAlign: 'justify' }, children: description })] })] }) }));
94
+ return createPortal(tooltipContent, document.body);
95
+ };
@@ -0,0 +1,7 @@
1
+ interface HealthBarXAxisProps {
2
+ startTimestamp: number;
3
+ endTimestamp: number;
4
+ }
5
+ export declare const HealthBarXAxis: ({ startTimestamp, endTimestamp, }: HealthBarXAxisProps) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=HealthBarXAxis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HealthBarXAxis.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/globalhealthbar/components/HealthBarXAxis.tsx"],"names":[],"mappings":"AAWA,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAiDD,eAAO,MAAM,cAAc,sCAGxB,mBAAmB,4CA2BrB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { XAxis } from 'recharts';
3
+ import { useTheme } from 'styled-components';
4
+ import { fontSize } from '../../../style/theme';
5
+ import { getTicks, calculateLabelVisibility, TIME_CONSTANTS, getEdgeMargin, } from '../healthBarUtils';
6
+ import { FormattedDateTime } from '../../date/FormattedDateTime';
7
+ const CustomTick = ({ tickProps, startTimestamp, endTimestamp, }) => {
8
+ const theme = useTheme();
9
+ const { y, payload, width, index, visibleTicksCount } = tickProps;
10
+ const span = endTimestamp - startTimestamp;
11
+ const is7DaySpan = span === 7 * TIME_CONSTANTS.ONE_DAY;
12
+ const isDaySpan = span === TIME_CONSTANTS.ONE_DAY;
13
+ const shouldShowLabel = calculateLabelVisibility(width, visibleTicksCount, span, index, endTimestamp);
14
+ const edgeMargin = getEdgeMargin(index, visibleTicksCount, isDaySpan);
15
+ return (
16
+ // use coordinate to center the text
17
+ shouldShowLabel && (_jsx("g", { transform: `translate(${payload.coordinate},${y})`, children: _jsx("text", { textAnchor: "middle", dy: 10, dx: edgeMargin, fontSize: fontSize.smaller, fill: theme.textSecondary, children: is7DaySpan || isDaySpan ? (_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date(payload.value) })) : (_jsx(FormattedDateTime, { format: "time", value: new Date(payload.value) })) }) })));
18
+ };
19
+ export const HealthBarXAxis = ({ startTimestamp, endTimestamp, }) => {
20
+ const theme = useTheme();
21
+ const ticks = getTicks(startTimestamp, endTimestamp);
22
+ return (_jsx(XAxis, { allowDataOverflow: true, dataKey: "start", type: "number", domain: [startTimestamp, endTimestamp], tickSize: 5, minTickGap: 10, interval: 0, tick: (props) => {
23
+ return (_jsx(CustomTick, { tickProps: props, startTimestamp: startTimestamp, endTimestamp: endTimestamp }));
24
+ }, ticks: ticks, tickLine: { stroke: theme.textSecondary }, axisLine: false }));
25
+ };
@@ -0,0 +1,77 @@
1
+ export declare const CHART_CONFIG: {
2
+ readonly RADIUS_SIZE: 4;
3
+ readonly EDGE_THRESHOLD: 8;
4
+ readonly CHART_HEIGHT: 50;
5
+ readonly BAR_SIZE: 8;
6
+ readonly TICK_SIZE: 4;
7
+ readonly TOOLTIP_OFFSET: 24;
8
+ readonly FONT_SIZE: string;
9
+ readonly TEXT_DY_OFFSET: 12;
10
+ readonly TICK_INTERVAL: 0;
11
+ readonly MARGINS: {
12
+ readonly left: 28;
13
+ readonly right: 28;
14
+ readonly bottom: 4;
15
+ readonly top: 4;
16
+ };
17
+ };
18
+ export declare const TIME_CONSTANTS: {
19
+ readonly ONE_HOUR: number;
20
+ readonly ONE_DAY: number;
21
+ readonly ONE_WEEK: number;
22
+ readonly MARGIN_HOURS: 6;
23
+ readonly FIFTEEN_MINUTES: number;
24
+ readonly SIX_HOURS: number;
25
+ };
26
+ export declare const LABEL_CONFIG: {
27
+ readonly MIN_SPACE_PER_TICK: 80;
28
+ readonly MODULO_CONFIG: {
29
+ readonly [x: number]: 2 | 3;
30
+ };
31
+ };
32
+ export declare const calculateSevenDayTicks: (endTimestamp: number) => number[];
33
+ export declare const calculateDayTicks: (endTimestamp: number) => number[];
34
+ export declare const calculateHourTicks: (endTimestamp: number) => number[];
35
+ export declare const getEdgeMargin: (index: number, totalTicks: number, isDaySpan: boolean) => number;
36
+ export declare const getTicks: (startTimestamp: number, endTimestamp: number) => number[];
37
+ export interface LabelVisibilityConfig {
38
+ hasEnoughSpace: boolean;
39
+ timeSpan: number;
40
+ tickIndex: number;
41
+ totalTicks: number;
42
+ }
43
+ export declare const calculateLabelVisibility: (chartWidth: number, totalTicks: number, span: number, index: number, endTimestamp: number) => boolean;
44
+ /**
45
+ * Core calculation for alert positioning within a time range
46
+ */
47
+ export declare const calculateAlertPosition: (alertStartTimestamp: number, alertEndTimestamp: number, chartStartTimestamp: number, chartEndTimestamp: number, availableWidth: number, baseX?: number) => {
48
+ startX: number;
49
+ width: number;
50
+ relativeSize: number;
51
+ };
52
+ export type NavigationAction = 'previous' | 'next' | 'first' | 'last' | 'escape';
53
+ export interface NavigationState {
54
+ newIndex: number;
55
+ selectedAlert: any | null;
56
+ shouldActivateKeyboard: boolean;
57
+ }
58
+ /**
59
+ * Maps keyboard events to navigation actions
60
+ */
61
+ export declare const getNavigationAction: (key: string) => NavigationAction | null;
62
+ /**
63
+ * Calculates new index based on navigation action
64
+ */
65
+ export declare const calculateNavigationIndex: (action: NavigationAction, currentIndex: number, arrayLength: number) => number;
66
+ /**
67
+ * Gets complete navigation state update for a given action
68
+ */
69
+ export declare const getNavigationStateUpdate: <T>(action: NavigationAction, currentIndex: number, alerts: T[]) => NavigationState;
70
+ /**
71
+ * Calculates tooltip position for an alert based on its time range
72
+ */
73
+ export declare const getTooltipPosition: (alert: {
74
+ startsAt: string;
75
+ endsAt: string;
76
+ }, startTimestamp: number, endTimestamp: number, chartUsableWidth: number) => number;
77
+ //# sourceMappingURL=healthBarUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthBarUtils.d.ts","sourceRoot":"","sources":["../../../src/lib/components/globalhealthbar/healthBarUtils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;CAWf,CAAC;AAEX,eAAO,MAAM,cAAc;;;;;;;CAOjB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