@openshift-migration-advisor/shared-components 0.24.0 → 0.25.0-6fd4e1ee8e11

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 (130) hide show
  1. package/README.md +31 -0
  2. package/dist/charts/index.d.ts +1 -1
  3. package/dist/charts/index.d.ts.map +1 -1
  4. package/dist/forms/RadioButtonFormGroup.d.ts.map +1 -1
  5. package/dist/forms/RadioButtonFormGroup.js +2 -2
  6. package/dist/report/ChartDownloadButton.d.ts +11 -0
  7. package/dist/report/ChartDownloadButton.d.ts.map +1 -0
  8. package/dist/report/ChartDownloadButton.js +24 -0
  9. package/dist/report/ChartExportProvider.d.ts +22 -0
  10. package/dist/report/ChartExportProvider.d.ts.map +1 -0
  11. package/dist/report/ChartExportProvider.js +222 -0
  12. package/dist/report/ChartExportSurface.d.ts +12 -0
  13. package/dist/report/ChartExportSurface.d.ts.map +1 -0
  14. package/dist/report/ChartExportSurface.js +32 -0
  15. package/dist/report/FeatureStatusBadge.d.ts +7 -0
  16. package/dist/report/FeatureStatusBadge.d.ts.map +1 -0
  17. package/dist/report/FeatureStatusBadge.js +13 -0
  18. package/dist/report/HostPowerStates.d.ts +8 -0
  19. package/dist/report/HostPowerStates.d.ts.map +1 -0
  20. package/dist/report/HostPowerStates.js +11 -0
  21. package/dist/report/InfrastructureSummary.d.ts +7 -0
  22. package/dist/report/InfrastructureSummary.d.ts.map +1 -0
  23. package/dist/report/InfrastructureSummary.js +9 -0
  24. package/dist/report/OSDistribution.d.ts +0 -2
  25. package/dist/report/OSDistribution.d.ts.map +1 -1
  26. package/dist/report/OSDistribution.js +10 -15
  27. package/dist/report/OsSupportTiersHelpPopover.d.ts.map +1 -1
  28. package/dist/report/OsSupportTiersHelpPopover.js +2 -31
  29. package/dist/report/OsUpgradeNotice.d.ts.map +1 -1
  30. package/dist/report/OsUpgradeNotice.js +1 -5
  31. package/dist/report/OsUpgradeRecommendationPopover.d.ts +0 -1
  32. package/dist/report/OsUpgradeRecommendationPopover.d.ts.map +1 -1
  33. package/dist/report/OsUpgradeRecommendationPopover.js +4 -3
  34. package/dist/report/PowerStateCard.d.ts +16 -0
  35. package/dist/report/PowerStateCard.d.ts.map +1 -0
  36. package/dist/report/PowerStateCard.js +9 -0
  37. package/dist/report/ReportExportMenu.d.ts +19 -0
  38. package/dist/report/ReportExportMenu.d.ts.map +1 -0
  39. package/dist/report/ReportExportMenu.js +31 -0
  40. package/dist/report/SupportTierBadge.d.ts +0 -1
  41. package/dist/report/SupportTierBadge.d.ts.map +1 -1
  42. package/dist/report/SupportTierBadge.js +1 -19
  43. package/dist/report/VCenterClusterDetails.d.ts +9 -0
  44. package/dist/report/VCenterClusterDetails.d.ts.map +1 -0
  45. package/dist/report/VCenterClusterDetails.js +31 -0
  46. package/dist/report/VmPowerStates.d.ts +8 -0
  47. package/dist/report/VmPowerStates.d.ts.map +1 -0
  48. package/dist/report/VmPowerStates.js +11 -0
  49. package/dist/report/captureChartElement.d.ts +8 -0
  50. package/dist/report/captureChartElement.d.ts.map +1 -0
  51. package/dist/report/captureChartElement.js +284 -0
  52. package/dist/report/chartExport.d.ts +57 -0
  53. package/dist/report/chartExport.d.ts.map +1 -0
  54. package/dist/report/chartExport.js +162 -0
  55. package/dist/report/chartExportContext.d.ts +28 -0
  56. package/dist/report/chartExportContext.d.ts.map +1 -0
  57. package/dist/report/chartExportContext.js +36 -0
  58. package/dist/report/chartExportFilenames.d.ts +4 -0
  59. package/dist/report/chartExportFilenames.d.ts.map +1 -0
  60. package/dist/report/chartExportFilenames.js +16 -0
  61. package/dist/report/constants.d.ts +2 -0
  62. package/dist/report/constants.d.ts.map +1 -1
  63. package/dist/report/constants.js +2 -0
  64. package/dist/report/dashboardStyles.d.ts +0 -4
  65. package/dist/report/dashboardStyles.d.ts.map +1 -1
  66. package/dist/report/dashboardStyles.js +0 -19
  67. package/dist/report/htmlExport.d.ts +9 -0
  68. package/dist/report/htmlExport.d.ts.map +1 -0
  69. package/dist/report/htmlExport.js +65 -0
  70. package/dist/report/index.d.ts +23 -0
  71. package/dist/report/index.d.ts.map +1 -1
  72. package/dist/report/index.js +21 -0
  73. package/dist/report/infrastructureSummaryModel.d.ts +82 -0
  74. package/dist/report/infrastructureSummaryModel.d.ts.map +1 -0
  75. package/dist/report/infrastructureSummaryModel.js +139 -0
  76. package/dist/report/pdfExport.d.ts +3 -0
  77. package/dist/report/pdfExport.d.ts.map +1 -0
  78. package/dist/report/pdfExport.js +82 -0
  79. package/dist/report/pdfPage.d.ts +15 -0
  80. package/dist/report/pdfPage.d.ts.map +1 -0
  81. package/dist/report/pdfPage.js +44 -0
  82. package/dist/report/powerStates.d.ts +11 -0
  83. package/dist/report/powerStates.d.ts.map +1 -0
  84. package/dist/report/powerStates.js +113 -0
  85. package/dist/report/reportExportOptions.d.ts +17 -0
  86. package/dist/report/reportExportOptions.d.ts.map +1 -0
  87. package/dist/report/reportExportOptions.js +31 -0
  88. package/dist/report/zipChartPngs.d.ts +3 -0
  89. package/dist/report/zipChartPngs.d.ts.map +1 -0
  90. package/dist/report/zipChartPngs.js +8 -0
  91. package/package.json +7 -2
  92. package/src/charts/index.ts +1 -0
  93. package/src/forms/RadioButtonFormGroup.tsx +10 -3
  94. package/src/report/ChartDownloadButton.tsx +59 -0
  95. package/src/report/ChartExportProvider.tsx +384 -0
  96. package/src/report/ChartExportSurface.tsx +60 -0
  97. package/src/report/FeatureStatusBadge.tsx +30 -0
  98. package/src/report/HostPowerStates.tsx +38 -0
  99. package/src/report/InfrastructureSummary.tsx +73 -0
  100. package/src/report/OSDistribution.tsx +96 -99
  101. package/src/report/OsSupportTiersHelpPopover.tsx +32 -62
  102. package/src/report/OsUpgradeNotice.tsx +1 -7
  103. package/src/report/OsUpgradeRecommendationPopover.tsx +3 -4
  104. package/src/report/PowerStateCard.tsx +86 -0
  105. package/src/report/ReportExportMenu.tsx +119 -0
  106. package/src/report/SupportTierBadge.tsx +12 -38
  107. package/src/report/VCenterClusterDetails.tsx +233 -0
  108. package/src/report/VmPowerStates.tsx +38 -0
  109. package/src/report/__tests__/ChartExportProvider.test.tsx +474 -0
  110. package/src/report/__tests__/HostPowerStates.test.tsx +47 -0
  111. package/src/report/__tests__/InfrastructureSummary.test.tsx +126 -0
  112. package/src/report/__tests__/OSDistribution.test.tsx +10 -11
  113. package/src/report/__tests__/captureChartElement.test.ts +132 -0
  114. package/src/report/__tests__/chartExportPackagers.test.ts +224 -0
  115. package/src/report/__tests__/infrastructureSummaryModel.test.ts +224 -0
  116. package/src/report/__tests__/powerStates.test.ts +70 -0
  117. package/src/report/captureChartElement.ts +368 -0
  118. package/src/report/chartExport.ts +237 -0
  119. package/src/report/chartExportContext.tsx +84 -0
  120. package/src/report/chartExportFilenames.ts +21 -0
  121. package/src/report/constants.ts +2 -0
  122. package/src/report/dashboardStyles.ts +0 -23
  123. package/src/report/htmlExport.ts +83 -0
  124. package/src/report/index.ts +128 -0
  125. package/src/report/infrastructureSummaryModel.ts +281 -0
  126. package/src/report/pdfExport.ts +154 -0
  127. package/src/report/pdfPage.ts +83 -0
  128. package/src/report/powerStates.ts +169 -0
  129. package/src/report/reportExportOptions.ts +53 -0
  130. package/src/report/zipChartPngs.ts +10 -0
@@ -1,9 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { css } from "@emotion/css";
3
2
  import { Content, Flex, FlexItem, Icon } from "@patternfly/react-core";
4
3
  import { InfoCircleIcon } from "@patternfly/react-icons";
5
- const noticeStyle = css `
6
- margin-bottom: var(--pf-t--global--spacer--200);
7
- `;
8
- export const OsUpgradeNotice = () => (_jsxs(Flex, { alignItems: { default: "alignItemsCenter" }, spaceItems: { default: "spaceItemsSm" }, className: noticeStyle, children: [_jsx(FlexItem, { children: _jsx(Icon, { status: "info", children: _jsx(InfoCircleIcon, {}) }) }), _jsx(FlexItem, { children: _jsx(Content, { component: "p", style: { fontWeight: 500 }, children: "Some operating systems may need upgrades before migration" }) })] }));
4
+ export const OsUpgradeNotice = () => (_jsxs(Flex, { alignItems: { default: "alignItemsCenter" }, spaceItems: { default: "spaceItemsSm" }, children: [_jsx(FlexItem, { children: _jsx(Icon, { status: "info", children: _jsx(InfoCircleIcon, {}) }) }), _jsx(FlexItem, { children: _jsx(Content, { component: "p", children: "Some operating systems may need upgrades before migration" }) })] }));
9
5
  OsUpgradeNotice.displayName = "OsUpgradeNotice";
@@ -6,7 +6,6 @@ export declare const OsUpgradeRecommendationPopover: FC<OsUpgradeRecommendationP
6
6
  interface OsNameCellProps {
7
7
  osName: string;
8
8
  upgradeRecommendation?: string;
9
- isExportMode?: boolean;
10
9
  }
11
10
  export declare const OsNameCell: FC<OsNameCellProps>;
12
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"OsUpgradeRecommendationPopover.d.ts","sourceRoot":"","sources":["../../src/report/OsUpgradeRecommendationPopover.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAchC,UAAU,mCAAmC;IAC3C,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAC7C,mCAAmC,CAiBpC,CAAC;AAIF,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA0B1C,CAAC"}
1
+ {"version":3,"file":"OsUpgradeRecommendationPopover.d.ts","sourceRoot":"","sources":["../../src/report/OsUpgradeRecommendationPopover.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAehC,UAAU,mCAAmC;IAC3C,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAC7C,mCAAmC,CAiBpC,CAAC;AAIF,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAyB1C,CAAC"}
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { css } from "@emotion/css";
3
3
  import { Button, Flex, FlexItem, Popover } from "@patternfly/react-core";
4
4
  import { InfoCircleIcon } from "@patternfly/react-icons";
5
+ import { chartExportHideProps } from "./chartExport.js";
5
6
  const upgradeRecommendationPopoverCloseButton = css `
6
7
  .pf-v6-c-popover__close .pf-v6-c-button.pf-m-plain,
7
8
  .pf-v6-c-popover__close .pf-v6-c-button.pf-m-plain:hover {
@@ -14,11 +15,11 @@ const infoButtonStyle = css `
14
15
  `;
15
16
  export const OsUpgradeRecommendationPopover = ({ upgradeRecommendation }) => (_jsx(Popover, { className: upgradeRecommendationPopoverCloseButton, position: "bottom", headerContent: "Upgrade to get support", bodyContent: _jsx("div", { children: upgradeRecommendation }), children: _jsx(Button, { type: "button", "aria-label": "Open operating system upgrade information", variant: "plain", className: infoButtonStyle, children: _jsx(InfoCircleIcon, { color: "var(--pf-t--global--icon--color--status--info--default)" }) }) }));
16
17
  OsUpgradeRecommendationPopover.displayName = "OsUpgradeRecommendationPopover";
17
- export const OsNameCell = ({ osName, upgradeRecommendation, isExportMode = false, }) => {
18
+ export const OsNameCell = ({ osName, upgradeRecommendation, }) => {
18
19
  const hasUpgradeRecommendation = upgradeRecommendation && upgradeRecommendation.trim() !== "";
19
- if (!hasUpgradeRecommendation || isExportMode) {
20
+ if (!hasUpgradeRecommendation) {
20
21
  return _jsx(_Fragment, { children: osName });
21
22
  }
22
- return (_jsxs(Flex, { alignItems: { default: "alignItemsCenter" }, spaceItems: { default: "spaceItemsXs" }, flexWrap: { default: "nowrap" }, children: [_jsx(FlexItem, { children: osName }), _jsx(FlexItem, { shrink: { default: "shrink" }, children: _jsx(OsUpgradeRecommendationPopover, { upgradeRecommendation: upgradeRecommendation }) })] }));
23
+ return (_jsxs(Flex, { alignItems: { default: "alignItemsCenter" }, spaceItems: { default: "spaceItemsXs" }, flexWrap: { default: "nowrap" }, children: [_jsx(FlexItem, { children: osName }), _jsx(FlexItem, { shrink: { default: "shrink" }, ...chartExportHideProps, children: _jsx(OsUpgradeRecommendationPopover, { upgradeRecommendation: upgradeRecommendation }) })] }));
23
24
  };
24
25
  OsNameCell.displayName = "OsNameCell";
@@ -0,0 +1,16 @@
1
+ import type { FC, ReactNode } from "react";
2
+ import { type MigrationDonutChartDatum, type MigrationDonutChartLegendVariant } from "../charts/MigrationDonutChart.js";
3
+ export interface PowerStateCardProps {
4
+ id: string;
5
+ title: string;
6
+ icon: ReactNode;
7
+ emptyTitle: string;
8
+ slices: MigrationDonutChartDatum[];
9
+ legend: Record<string, string>;
10
+ total: number;
11
+ subTitle: string;
12
+ itemsPerRow?: number;
13
+ legendVariant?: MigrationDonutChartLegendVariant;
14
+ }
15
+ export declare const PowerStateCard: FC<PowerStateCardProps>;
16
+ //# sourceMappingURL=PowerStateCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PowerStateCard.d.ts","sourceRoot":"","sources":["../../src/report/PowerStateCard.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,gCAAgC,EACtC,MAAM,kCAAkC,CAAC;AAM1C,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,wBAAwB,EAAE,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,gCAAgC,CAAC;CAClD;AAED,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAoDlD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Card, CardBody, CardTitle, Flex, FlexItem, } from "@patternfly/react-core";
3
+ import { MigrationDonutChart, } from "../charts/MigrationDonutChart.js";
4
+ import { CardEmptyState } from "./CardEmptyState.js";
5
+ import { ChartHeaderActions } from "./ChartDownloadButton.js";
6
+ import { ChartExportSurface } from "./ChartExportSurface.js";
7
+ import { dashboardStyles } from "./dashboardStyles.js";
8
+ export const PowerStateCard = ({ id, title, icon, emptyTitle, slices, legend, total, subTitle, itemsPerRow = 2, legendVariant = "html", }) => (_jsx(ChartExportSurface, { id: id, title: title, children: _jsxs(Card, { className: dashboardStyles.card, children: [_jsx(CardTitle, { children: _jsxs(Flex, { justifyContent: { default: "justifyContentSpaceBetween" }, alignItems: { default: "alignItemsCenter" }, children: [_jsxs(FlexItem, { children: [icon, " ", title] }), _jsx(ChartHeaderActions, { chartId: id, title: title })] }) }), _jsx(CardBody, { children: total === 0 ? (_jsx(CardEmptyState, { title: emptyTitle })) : (_jsx(MigrationDonutChart, { legendVariant: legendVariant, data: slices, legend: legend, height: 300, width: 420, donutThickness: 18, padAngle: 1, title: `${total}`, subTitle: subTitle, subTitleColor: "var(--pf-t--global--text--color--subtle)", titleFontSize: 34, labelFontSize: 16, itemsPerRow: itemsPerRow, marginLeft: "0%", tooltipLabelFormatter: ({ datum, percent }) => `${datum.countDisplay}\n${percent.toFixed(1)}%` })) })] }) }));
9
+ PowerStateCard.displayName = "PowerStateCard";
@@ -0,0 +1,19 @@
1
+ import { type FC } from "react";
2
+ import { type ReportExportOption, type StandardReportExportHandlers } from "./reportExportOptions.js";
3
+ export interface ReportExportMenuProps {
4
+ options: ReportExportOption[];
5
+ isLoading?: boolean;
6
+ loadingLabel?: string | null;
7
+ isDisabled?: boolean;
8
+ toggleLabel?: string;
9
+ }
10
+ export declare const ReportExportMenu: FC<ReportExportMenuProps>;
11
+ export interface ExportReportButtonProps extends StandardReportExportHandlers {
12
+ extraOptions?: ReportExportOption[];
13
+ isLoading?: boolean;
14
+ loadingLabel?: string | null;
15
+ isDisabled?: boolean;
16
+ toggleLabel?: string;
17
+ }
18
+ export declare const ExportReportButton: FC<ExportReportButtonProps>;
19
+ //# sourceMappingURL=ReportExportMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportExportMenu.d.ts","sourceRoot":"","sources":["../../src/report/ReportExportMenu.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AACpD,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,4BAA4B,EAElC,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CA8DtD,CAAC;AAIF,MAAM,WAAW,uBAAwB,SAAQ,4BAA4B;IAC3E,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAkB1D,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Dropdown, DropdownItem, DropdownList, MenuToggle, Spinner, } from "@patternfly/react-core";
3
+ import { DownloadIcon } from "@patternfly/react-icons";
4
+ import { useState } from "react";
5
+ import { standardReportExportOptions, } from "./reportExportOptions.js";
6
+ export const ReportExportMenu = ({ options, isLoading = false, loadingLabel = null, isDisabled = false, toggleLabel = "Export", }) => {
7
+ const [isDropdownOpen, setIsDropdownOpen] = useState(false);
8
+ if (options.length === 0) {
9
+ return null;
10
+ }
11
+ return (_jsx(Dropdown, { isOpen: isDropdownOpen, popperProps: {
12
+ placement: "bottom-end",
13
+ preventOverflow: true,
14
+ }, onSelect: () => {
15
+ setIsDropdownOpen(false);
16
+ }, onOpenChange: (isOpen) => {
17
+ setIsDropdownOpen(isOpen);
18
+ }, toggle: (toggleRef) => (_jsx(MenuToggle, { ref: toggleRef, onClick: () => {
19
+ setIsDropdownOpen((open) => !open);
20
+ }, isExpanded: isDropdownOpen, variant: "secondary", isDisabled: isLoading || isDisabled, "aria-label": "Export report options", icon: isLoading ? (_jsx(Spinner, { size: "sm", "aria-hidden": "true" })) : (_jsx(DownloadIcon, { "aria-hidden": "true" })), children: isLoading ? (loadingLabel ?? "Generating...") : toggleLabel })), children: _jsx(DropdownList, { children: options.map((option) => (_jsx(DropdownItem, { isDisabled: option.isDisabled, description: option.description, onClick: option.onSelect, children: option.label }, option.key))) }) }));
21
+ };
22
+ ReportExportMenu.displayName = "ReportExportMenu";
23
+ export const ExportReportButton = ({ onExportPdf, onExportPng, onExportHtml, extraOptions = [], ...menuProps }) => (_jsx(ReportExportMenu, { options: [
24
+ ...standardReportExportOptions({
25
+ onExportPdf,
26
+ onExportPng,
27
+ onExportHtml,
28
+ }),
29
+ ...extraOptions,
30
+ ], ...menuProps }));
31
+ ExportReportButton.displayName = "ExportReportButton";
@@ -2,7 +2,6 @@ import type { FC } from "react";
2
2
  import { type SupportTier } from "./osSupportTier.js";
3
3
  interface SupportTierBadgeProps {
4
4
  tier: SupportTier;
5
- isExportMode?: boolean;
6
5
  }
7
6
  export declare const SupportTierBadge: FC<SupportTierBadgeProps>;
8
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"SupportTierBadge.d.ts","sourceRoot":"","sources":["../../src/report/SupportTierBadge.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAW5B,UAAU,qBAAqB;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAYD,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAiBtD,CAAC"}
1
+ {"version":3,"file":"SupportTierBadge.d.ts","sourceRoot":"","sources":["../../src/report/SupportTierBadge.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAE5B,UAAU,qBAAqB;IAC7B,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAYtD,CAAC"}
@@ -1,23 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { css } from "@emotion/css";
3
2
  import { Label, Tooltip } from "@patternfly/react-core";
4
3
  import { getSupportTierBadgeColor, getSupportTierBadgeInlineStyle, getSupportTierDefinition, getSupportTierLegendLabel, } from "./osSupportTier.js";
5
- const exportBadgeStyle = css `
6
- display: inline-block;
7
- padding: var(--pf-t--global--spacer--xs) var(--pf-t--global--spacer--sm);
8
- border-radius: var(--pf-t--global--border--radius--pill);
9
- font-size: var(--pf-t--global--font--size--body--sm);
10
- line-height: var(--pf-t--global--font--line-height--body);
11
- white-space: nowrap;
12
- `;
13
- const ExportSupportTierBadge = ({ tier }) => {
14
- const { backgroundColor, color } = getSupportTierBadgeInlineStyle(tier);
15
- return (_jsx("span", { className: exportBadgeStyle, style: { backgroundColor, color }, children: getSupportTierLegendLabel(tier) }));
16
- };
17
- export const SupportTierBadge = ({ tier, isExportMode = false, }) => {
18
- if (isExportMode) {
19
- return _jsx(ExportSupportTierBadge, { tier: tier });
20
- }
21
- return (_jsx(Tooltip, { content: getSupportTierDefinition(tier), children: _jsx("span", { children: _jsx(Label, { color: getSupportTierBadgeColor(tier), isCompact: true, children: getSupportTierLegendLabel(tier) }) }) }));
22
- };
4
+ export const SupportTierBadge = ({ tier }) => (_jsx(Tooltip, { content: getSupportTierDefinition(tier), children: _jsx("span", { children: _jsx(Label, { color: getSupportTierBadgeColor(tier), isCompact: true, style: getSupportTierBadgeInlineStyle(tier), children: getSupportTierLegendLabel(tier) }) }) }));
23
5
  SupportTierBadge.displayName = "SupportTierBadge";
@@ -0,0 +1,9 @@
1
+ import type { FC } from "react";
2
+ import type { ClusterDetailRow, ClusterDetailsModel } from "./infrastructureSummaryModel.js";
3
+ export interface VCenterClusterDetailsProps {
4
+ isAggregateView: boolean;
5
+ rows: ClusterDetailRow[];
6
+ details?: ClusterDetailsModel;
7
+ }
8
+ export declare const VCenterClusterDetails: FC<VCenterClusterDetailsProps>;
9
+ //# sourceMappingURL=VCenterClusterDetails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VCenterClusterDetails.d.ts","sourceRoot":"","sources":["../../src/report/VCenterClusterDetails.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,iCAAiC,CAAC;AAEzC,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAsKD,eAAO,MAAM,qBAAqB,EAAE,EAAE,CAAC,0BAA0B,CA+BhE,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { css } from "@emotion/css";
3
+ import { Card, CardBody, CardTitle, Content, DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, Flex, FlexItem, Grid, GridItem, Label, LabelGroup, } from "@patternfly/react-core";
4
+ import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table";
5
+ import { ChartHeaderActions } from "./ChartDownloadButton.js";
6
+ import { ChartExportSurface } from "./ChartExportSurface.js";
7
+ import { chartExportScrollProps } from "./chartExport.js";
8
+ import { FeatureStatusBadge } from "./FeatureStatusBadge.js";
9
+ const clusterDetailsTableScrollStyle = css `
10
+ max-height: 320px;
11
+ overflow: auto;
12
+ `;
13
+ const FeatureList = ({ items }) => (_jsx(DescriptionList, { isHorizontal: true, isCompact: true, children: items.map((item) => (_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: item.label }), _jsx(DescriptionListDescription, { children: _jsx(FeatureStatusBadge, { status: item.status }) })] }, item.label))) }));
14
+ const AggregateClusterTable = ({ rows }) => (_jsxs(Table, { variant: "compact", borders: false, isStickyHeader: true, "data-testid": "vcenter-cluster-details-table", children: [_jsx(Thead, { children: _jsxs(Tr, { children: [_jsx(Th, { children: "Cluster name" }), _jsx(Th, { children: "Hosts" }), _jsx(Th, { children: "VMs" }), _jsx(Th, { children: "vMotion" }), _jsx(Th, { children: "DRS" }), _jsx(Th, { children: "vSAN" })] }) }), _jsx(Tbody, { children: rows.map((row) => (_jsxs(Tr, { children: [_jsx(Td, { dataLabel: "Cluster name", children: row.name }), _jsx(Td, { dataLabel: "Hosts", children: row.hosts }), _jsx(Td, { dataLabel: "VMs", children: row.vms }), _jsx(Td, { dataLabel: "vMotion", children: _jsx(FeatureStatusBadge, { status: row.vmotion }) }), _jsx(Td, { dataLabel: "DRS", children: _jsx(FeatureStatusBadge, { status: row.drs }) }), _jsx(Td, { dataLabel: "vSAN", children: _jsx(FeatureStatusBadge, { status: row.vsan }) })] }, row.id))) })] }));
15
+ const AggregateCluster = ({ rows }) => {
16
+ if (rows.length === 0) {
17
+ return _jsx(Content, { component: "p", children: "No vSphere clusters detected" });
18
+ }
19
+ return (_jsx("div", { className: clusterDetailsTableScrollStyle, "data-scroll-constrained": "true", ...chartExportScrollProps, children: _jsx(AggregateClusterTable, { rows: rows }) }));
20
+ };
21
+ const DetailedClusterView = ({ details, }) => (_jsxs(Grid, { hasGutter: true, children: [_jsx(GridItem, { children: _jsxs(DescriptionList, { isAutoFit: true, displaySize: "lg", children: [_jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "Hosts" }), _jsx(DescriptionListDescription, { children: details.hosts })] }), _jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "VMs" }), _jsx(DescriptionListDescription, { children: details.vms })] }), _jsxs(DescriptionListGroup, { children: [_jsx(DescriptionListTerm, { children: "Networks detected" }), _jsx(DescriptionListDescription, { children: details.networksDetected })] })] }) }), _jsx(GridItem, { md: 4, children: _jsxs(Card, { isFullHeight: true, children: [_jsx(CardTitle, { children: "Core infrastructure" }), _jsx(CardBody, { children: _jsx(FeatureList, { items: [
22
+ { label: "vMotion", status: details.vmotion },
23
+ { label: "DRS", status: details.drs },
24
+ { label: "HA", status: details.ha },
25
+ ] }) })] }) }), _jsx(GridItem, { md: 4, children: _jsxs(Card, { isFullHeight: true, children: [_jsx(CardTitle, { children: "vSAN capabilities" }), _jsx(CardBody, { children: _jsx(FeatureList, { items: [{ label: "vSAN", status: details.vsan }] }) })] }) }), _jsx(GridItem, { md: 4, children: _jsxs(Card, { isFullHeight: true, children: [_jsx(CardTitle, { children: "Network topology" }), _jsx(CardBody, { children: details.networks.length === 0 ? (_jsx(Content, { component: "p", children: "No networks detected" })) : (_jsxs(_Fragment, { children: [_jsxs(Content, { component: "p", children: [details.networksDetected, " ", details.networksDetected === 1
26
+ ? "network detected"
27
+ : "networks detected"] }), _jsx(LabelGroup, { isCompact: true, numLabels: details.networks.length, "aria-label": "Detected networks", children: details.networks.map((network, index) => (_jsx(Label, { color: "blue", isCompact: true, children: network.displayName }, `${network.name}-${network.vlanId ?? index}`))) })] })) })] }) })] }));
28
+ const CLUSTER_DETAILS_CHART_ID = "vcenter-cluster-details";
29
+ const CLUSTER_DETAILS_TITLE = "vCenter cluster details";
30
+ export const VCenterClusterDetails = ({ isAggregateView, rows, details, }) => (_jsx(ChartExportSurface, { id: CLUSTER_DETAILS_CHART_ID, title: CLUSTER_DETAILS_TITLE, children: _jsxs(Card, { isFullHeight: true, children: [_jsx(CardTitle, { children: _jsxs(Flex, { justifyContent: { default: "justifyContentSpaceBetween" }, alignItems: { default: "alignItemsCenter" }, children: [_jsx(FlexItem, { children: CLUSTER_DETAILS_TITLE }), _jsx(ChartHeaderActions, { chartId: CLUSTER_DETAILS_CHART_ID, title: CLUSTER_DETAILS_TITLE })] }) }), _jsx(CardBody, { children: isAggregateView || !details ? (_jsx(AggregateCluster, { rows: rows })) : (_jsx(DetailedClusterView, { details: details })) })] }) }));
31
+ VCenterClusterDetails.displayName = "VCenterClusterDetails";
@@ -0,0 +1,8 @@
1
+ import type { FC } from "react";
2
+ import type { MigrationDonutChartLegendVariant } from "../charts/MigrationDonutChart.js";
3
+ export interface VmPowerStatesProps {
4
+ powerStates?: Record<string, number>;
5
+ legendVariant?: MigrationDonutChartLegendVariant;
6
+ }
7
+ export declare const VmPowerStates: FC<VmPowerStatesProps>;
8
+ //# sourceMappingURL=VmPowerStates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VmPowerStates.d.ts","sourceRoot":"","sources":["../../src/report/VmPowerStates.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAKzF,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,gCAAgC,CAAC;CAClD;AAED,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAsBhD,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { VirtualMachineIcon } from "@patternfly/react-icons";
3
+ import { useMemo } from "react";
4
+ import { REPORT_CARD_EMPTY_STATE_TITLES } from "./constants.js";
5
+ import { PowerStateCard } from "./PowerStateCard.js";
6
+ import { buildVmPowerStateChart } from "./powerStates.js";
7
+ export const VmPowerStates = ({ powerStates, legendVariant, }) => {
8
+ const chart = useMemo(() => buildVmPowerStateChart(powerStates), [powerStates]);
9
+ return (_jsx(PowerStateCard, { id: "vm-power-states", title: "VM power states", icon: _jsx(VirtualMachineIcon, {}), emptyTitle: REPORT_CARD_EMPTY_STATE_TITLES.vmPowerStates, slices: chart.slices, legend: chart.legend, total: chart.total, subTitle: "VMs", legendVariant: legendVariant }));
10
+ };
11
+ VmPowerStates.displayName = "VmPowerStates";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tab panels stay mounted with `hidden` / `display:none` when another tab is
3
+ * active. html2canvas then measures a 0×0 box. Reveal those ancestors off-screen
4
+ * for the duration of the capture, then restore.
5
+ */
6
+ export declare function revealHiddenChartAncestors(element: HTMLElement): () => void;
7
+ export declare function captureChartElement(element: HTMLElement): Promise<HTMLCanvasElement>;
8
+ //# sourceMappingURL=captureChartElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captureChartElement.d.ts","sourceRoot":"","sources":["../../src/report/captureChartElement.ts"],"names":[],"mappings":"AAgCA;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,IAAI,CAqD3E;AAiPD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAkC5B"}
@@ -0,0 +1,284 @@
1
+ import html2canvas from "html2canvas-pro";
2
+ import { CHART_EXPORT_CAPTURING_ATTR, CHART_EXPORT_SCROLL_ATTR, shouldIgnoreChartExportElement, } from "./chartExport.js";
3
+ /** CSS-pixel scale; 2x made zip-all of ~15 live cards too slow. */
4
+ const CHART_CAPTURE_SCALE = 1;
5
+ const HIDDEN_LAYOUT_STYLE_KEYS = [
6
+ "display",
7
+ "position",
8
+ "left",
9
+ "top",
10
+ "width",
11
+ "maxHeight",
12
+ "overflow",
13
+ "zIndex",
14
+ ];
15
+ function isDisplayNone(node) {
16
+ return window.getComputedStyle(node).display === "none";
17
+ }
18
+ /**
19
+ * Tab panels stay mounted with `hidden` / `display:none` when another tab is
20
+ * active. html2canvas then measures a 0×0 box. Reveal those ancestors off-screen
21
+ * for the duration of the capture, then restore.
22
+ */
23
+ export function revealHiddenChartAncestors(element) {
24
+ const saved = [];
25
+ let node = element;
26
+ while (node && node !== document.documentElement) {
27
+ if (node.hidden || isDisplayNone(node)) {
28
+ saved.push({
29
+ node,
30
+ hidden: node.hidden,
31
+ styles: {
32
+ display: node.style.display,
33
+ position: node.style.position,
34
+ left: node.style.left,
35
+ top: node.style.top,
36
+ width: node.style.width,
37
+ maxHeight: node.style.maxHeight,
38
+ overflow: node.style.overflow,
39
+ zIndex: node.style.zIndex,
40
+ },
41
+ });
42
+ }
43
+ node = node.parentElement;
44
+ }
45
+ if (saved.length === 0) {
46
+ return () => undefined;
47
+ }
48
+ const outermost = saved[saved.length - 1].node;
49
+ const parentWidth = outermost.parentElement?.clientWidth ?? 0;
50
+ const layoutWidth = parentWidth || document.documentElement.clientWidth || 1024;
51
+ for (const entry of saved) {
52
+ entry.node.hidden = false;
53
+ entry.node.style.display = "block";
54
+ entry.node.style.position = "fixed";
55
+ entry.node.style.left = "-10000px";
56
+ entry.node.style.top = "0";
57
+ entry.node.style.width = `${layoutWidth}px`;
58
+ entry.node.style.maxHeight = "none";
59
+ entry.node.style.overflow = "visible";
60
+ entry.node.style.zIndex = "-1";
61
+ }
62
+ return () => {
63
+ for (const entry of saved) {
64
+ entry.node.hidden = entry.hidden;
65
+ for (const key of HIDDEN_LAYOUT_STYLE_KEYS) {
66
+ entry.node.style[key] = entry.styles[key];
67
+ }
68
+ }
69
+ };
70
+ }
71
+ const PADDED_CAPTURE_SELECTOR = ".pf-v6-c-card__title, .pf-v6-c-card__header, .pf-v6-c-card__body";
72
+ const CARD_CAPTURE_SELECTOR = ".pf-v6-c-card";
73
+ const TRANSPARENT_FILLS = new Set(["", "transparent", "rgba(0, 0, 0, 0)"]);
74
+ function queryCards(root) {
75
+ const cards = Array.from(root.querySelectorAll(CARD_CAPTURE_SELECTOR));
76
+ if (root.matches(CARD_CAPTURE_SELECTOR)) {
77
+ cards.unshift(root);
78
+ }
79
+ return cards;
80
+ }
81
+ function resolvedFill(color) {
82
+ return TRANSPARENT_FILLS.has(color) ? "#ffffff" : color;
83
+ }
84
+ function applyComputedPadding(source, dest) {
85
+ const computed = window.getComputedStyle(source);
86
+ dest.style.paddingTop = computed.paddingTop;
87
+ dest.style.paddingRight = computed.paddingRight;
88
+ dest.style.paddingBottom = computed.paddingBottom;
89
+ dest.style.paddingLeft = computed.paddingLeft;
90
+ }
91
+ function readCardBorder(source) {
92
+ if (source.style.borderWidth && source.style.borderStyle) {
93
+ return {
94
+ width: source.style.borderWidth,
95
+ style: source.style.borderStyle,
96
+ color: source.style.borderColor,
97
+ };
98
+ }
99
+ const computed = window.getComputedStyle(source);
100
+ const before = window.getComputedStyle(source, "::before");
101
+ const width = before.borderTopWidth && before.borderTopWidth !== "0px"
102
+ ? before.borderTopWidth
103
+ : computed.borderTopWidth;
104
+ const style = before.borderTopStyle && before.borderTopStyle !== "none"
105
+ ? before.borderTopStyle
106
+ : computed.borderTopStyle;
107
+ const color = before.borderTopColor && before.borderTopColor !== "rgba(0, 0, 0, 0)"
108
+ ? before.borderTopColor
109
+ : computed.borderTopColor;
110
+ if (width === "0px" || style === "none") {
111
+ return null;
112
+ }
113
+ return { width, style, color };
114
+ }
115
+ function applyCardChrome(source, dest) {
116
+ const computed = window.getComputedStyle(source);
117
+ dest.style.borderRadius = computed.borderRadius;
118
+ dest.style.backgroundColor = resolvedFill(computed.backgroundColor);
119
+ dest.style.overflow = "hidden";
120
+ const border = readCardBorder(source);
121
+ if (border) {
122
+ dest.style.borderWidth = border.width;
123
+ dest.style.borderStyle = border.style;
124
+ dest.style.borderColor = border.color;
125
+ }
126
+ }
127
+ function hideCardBeforePseudo() {
128
+ const style = document.createElement("style");
129
+ style.setAttribute("data-chart-export-hide-before", "");
130
+ style.textContent = `
131
+ [${CHART_EXPORT_CAPTURING_ATTR}] .pf-v6-c-card::before,
132
+ [${CHART_EXPORT_CAPTURING_ATTR}].pf-v6-c-card::before {
133
+ border: none !important;
134
+ box-shadow: none !important;
135
+ }
136
+ `;
137
+ document.head.append(style);
138
+ return () => {
139
+ style.remove();
140
+ };
141
+ }
142
+ function copyComputedPadding(node) {
143
+ const previous = {
144
+ paddingTop: node.style.paddingTop,
145
+ paddingRight: node.style.paddingRight,
146
+ paddingBottom: node.style.paddingBottom,
147
+ paddingLeft: node.style.paddingLeft,
148
+ };
149
+ applyComputedPadding(node, node);
150
+ return previous;
151
+ }
152
+ function copyCardChrome(node) {
153
+ const previous = {
154
+ borderRadius: node.style.borderRadius,
155
+ backgroundColor: node.style.backgroundColor,
156
+ overflow: node.style.getPropertyValue("overflow"),
157
+ overflowPriority: node.style.getPropertyPriority("overflow"),
158
+ borderWidth: node.style.borderWidth,
159
+ borderStyle: node.style.borderStyle,
160
+ borderColor: node.style.borderColor,
161
+ minHeight: node.style.minHeight,
162
+ height: node.style.height,
163
+ maxHeight: node.style.maxHeight,
164
+ };
165
+ applyCardChrome(node, node);
166
+ node.style.minHeight = "0px";
167
+ node.style.height = "auto";
168
+ node.style.maxHeight = "none";
169
+ return previous;
170
+ }
171
+ function applyComputedStylesToClone(sourceRoot, clonedRoot) {
172
+ const sourceCards = queryCards(sourceRoot);
173
+ const cloneCards = queryCards(clonedRoot);
174
+ sourceCards.forEach((source, index) => {
175
+ const dest = cloneCards[index];
176
+ if (dest) {
177
+ applyCardChrome(source, dest);
178
+ }
179
+ });
180
+ const sources = sourceRoot.querySelectorAll(PADDED_CAPTURE_SELECTOR);
181
+ const dests = clonedRoot.querySelectorAll(PADDED_CAPTURE_SELECTOR);
182
+ sources.forEach((source, index) => {
183
+ const dest = dests[index];
184
+ if (dest) {
185
+ applyComputedPadding(source, dest);
186
+ }
187
+ });
188
+ }
189
+ function prepareCaptureLayout(element) {
190
+ const expandNodes = [
191
+ element,
192
+ ...Array.from(element.querySelectorAll(`[${CHART_EXPORT_SCROLL_ATTR}], .pf-v6-c-card__body`)),
193
+ ];
194
+ const cards = queryCards(element);
195
+ const paddedNodes = Array.from(element.querySelectorAll(PADDED_CAPTURE_SELECTOR));
196
+ const previousExpand = expandNodes.map((node) => ({
197
+ node,
198
+ overflow: node.style.getPropertyValue("overflow"),
199
+ overflowPriority: node.style.getPropertyPriority("overflow"),
200
+ maxHeight: node.style.maxHeight,
201
+ height: node.style.height,
202
+ }));
203
+ const previousChrome = cards.map((node) => ({
204
+ node,
205
+ ...copyCardChrome(node),
206
+ }));
207
+ const previousPadding = paddedNodes.map((node) => ({
208
+ node,
209
+ ...copyComputedPadding(node),
210
+ }));
211
+ for (const node of expandNodes) {
212
+ node.style.setProperty("overflow", "visible", "important");
213
+ node.style.maxHeight = "none";
214
+ node.style.height = "auto";
215
+ }
216
+ return () => {
217
+ for (const entry of previousExpand) {
218
+ if (entry.overflow) {
219
+ entry.node.style.setProperty("overflow", entry.overflow, entry.overflowPriority);
220
+ }
221
+ else {
222
+ entry.node.style.removeProperty("overflow");
223
+ }
224
+ entry.node.style.maxHeight = entry.maxHeight;
225
+ entry.node.style.height = entry.height;
226
+ }
227
+ for (const entry of previousChrome) {
228
+ entry.node.style.borderRadius = entry.borderRadius;
229
+ entry.node.style.backgroundColor = entry.backgroundColor;
230
+ if (entry.overflow) {
231
+ entry.node.style.setProperty("overflow", entry.overflow, entry.overflowPriority);
232
+ }
233
+ else {
234
+ entry.node.style.removeProperty("overflow");
235
+ }
236
+ entry.node.style.borderWidth = entry.borderWidth;
237
+ entry.node.style.borderStyle = entry.borderStyle;
238
+ entry.node.style.borderColor = entry.borderColor;
239
+ entry.node.style.minHeight = entry.minHeight;
240
+ entry.node.style.height = entry.height;
241
+ entry.node.style.maxHeight = entry.maxHeight;
242
+ }
243
+ for (const entry of previousPadding) {
244
+ entry.node.style.paddingTop = entry.paddingTop;
245
+ entry.node.style.paddingRight = entry.paddingRight;
246
+ entry.node.style.paddingBottom = entry.paddingBottom;
247
+ entry.node.style.paddingLeft = entry.paddingLeft;
248
+ }
249
+ };
250
+ }
251
+ export async function captureChartElement(element) {
252
+ const restoreHidden = revealHiddenChartAncestors(element);
253
+ const restoreLayout = prepareCaptureLayout(element);
254
+ element.setAttribute(CHART_EXPORT_CAPTURING_ATTR, "");
255
+ const restoreCardBefore = hideCardBeforePseudo();
256
+ try {
257
+ await new Promise((resolve) => {
258
+ requestAnimationFrame(() => resolve());
259
+ });
260
+ if (element.getBoundingClientRect().width < 1) {
261
+ await new Promise((resolve) => {
262
+ requestAnimationFrame(() => resolve());
263
+ });
264
+ }
265
+ return html2canvas(element, {
266
+ useCORS: true,
267
+ backgroundColor: null,
268
+ logging: false,
269
+ scale: CHART_CAPTURE_SCALE,
270
+ imageTimeout: 0,
271
+ ignoreElements: (node) => node instanceof Element &&
272
+ shouldIgnoreChartExportElement(node, element),
273
+ onclone: (_clonedDoc, clonedElement) => {
274
+ applyComputedStylesToClone(element, clonedElement);
275
+ },
276
+ });
277
+ }
278
+ finally {
279
+ restoreCardBefore();
280
+ element.removeAttribute(CHART_EXPORT_CAPTURING_ATTR);
281
+ restoreLayout();
282
+ restoreHidden();
283
+ }
284
+ }
@@ -0,0 +1,57 @@
1
+ import type { CSSProperties } from "react";
2
+ export declare const CHART_EXPORT_HIDE_ATTR = "data-chart-export-hide";
3
+ export declare const CHART_EXPORT_SCROLL_ATTR = "data-chart-export-scroll";
4
+ export declare const CHART_EXPORT_CAPTURING_ATTR = "data-chart-capturing";
5
+ export declare const chartExportHideProps: {
6
+ readonly "data-chart-export-hide": "";
7
+ };
8
+ export declare const chartExportScrollProps: {
9
+ readonly "data-chart-export-scroll": "";
10
+ };
11
+ export declare const chartExportRootStyle: CSSProperties;
12
+ export type ChartExportMeta = {
13
+ id: string;
14
+ title: string;
15
+ filename?: string;
16
+ };
17
+ export type ChartExportView = {
18
+ id: string;
19
+ title: string;
20
+ filename?: string;
21
+ };
22
+ export type RegisteredChart = {
23
+ id: string;
24
+ title: string;
25
+ filename: string;
26
+ element: HTMLElement;
27
+ exportViews?: ChartExportView[];
28
+ activeExportViewId?: string;
29
+ setExportView?: (viewId: string) => Promise<void>;
30
+ };
31
+ export type ChartExportFile = {
32
+ filename: string;
33
+ blob: Blob;
34
+ };
35
+ export type ChartCaptureSource = {
36
+ id: string;
37
+ title: string;
38
+ filename: string;
39
+ capture: () => Promise<HTMLCanvasElement>;
40
+ };
41
+ export declare function releaseCanvas(canvas: HTMLCanvasElement): void;
42
+ export declare function waitForChartExportPaint(): Promise<void>;
43
+ export declare function chartExportViewsFromLabels(titlePrefix: string, labels: Record<string, string>): ChartExportView[];
44
+ export declare function toBulkChartCaptureSources(charts: RegisteredChart[], capture: (element: HTMLElement) => Promise<HTMLCanvasElement>, prepareElement?: (element: HTMLElement) => () => void): ChartCaptureSource[];
45
+ export declare function restoreChartExportViews(charts: RegisteredChart[]): Promise<void>;
46
+ export declare function sortRegisteredChartsByDocumentOrder(charts: RegisteredChart[]): RegisteredChart[];
47
+ export declare function canvasToBlob(canvas: HTMLCanvasElement): Promise<Blob>;
48
+ export declare function slugifyExportName(value: string): string;
49
+ export declare function chartPngFilename(title: string, id?: string): string;
50
+ /**
51
+ * html2canvas clones the whole document for every capture. Ignore everything
52
+ * except the target card (and ancestors / stylesheet nodes) so zip-all does
53
+ * not re-render every other chart.
54
+ */
55
+ export declare function shouldIgnoreChartExportElement(node: Element, captureRoot?: Element | null): boolean;
56
+ export declare function downloadBlob(blob: Blob, filename: string): void;
57
+ //# sourceMappingURL=chartExport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chartExport.d.ts","sourceRoot":"","sources":["../../src/report/chartExport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAElE,eAAO,MAAM,oBAAoB;;CAEvB,CAAC;AAEX,eAAO,MAAM,sBAAsB;;CAEzB,CAAC;AAEX,eAAO,MAAM,oBAAoB,EAAE,aAGlC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC3C,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAG7D;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CASvD;AAED,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,eAAe,EAAE,CAKnB;AAqBD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,EAC7D,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,IAAI,GACpD,kBAAkB,EAAE,CAyBtB;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,eAAe,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,eAAe,EAAE,GACxB,eAAe,EAAE,CAcnB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAU,GAAG,MAAM,CAEpE;AAWD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,OAAO,EACb,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,GAC3B,OAAO,CAeT;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAS/D"}