@monolith-forensics/monolith-ui 1.8.1 → 1.9.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 (179) hide show
  1. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +0 -4
  2. package/dist/Tabs/Tab.js +0 -8
  3. package/dist/TagBox/TagBox.d.ts +1 -1
  4. package/dist/TagBox/TagBox.js +135 -35
  5. package/dist/TagBox/types.d.ts +13 -0
  6. package/dist/core/controlSizes.d.ts +0 -26
  7. package/dist/core/controlSizes.js +0 -156
  8. package/dist/core/index.d.ts +1 -0
  9. package/dist/core/index.js +1 -0
  10. package/dist/theme/variants.js +0 -8
  11. package/package.json +1 -1
  12. package/dist/Charts/BarChart/BarChart.d.ts +0 -5
  13. package/dist/Charts/BarChart/BarChart.js +0 -563
  14. package/dist/Charts/BarChart/BarChart.lib.d.ts +0 -31
  15. package/dist/Charts/BarChart/BarChart.lib.js +0 -136
  16. package/dist/Charts/BarChart/BarChart.styled.d.ts +0 -56
  17. package/dist/Charts/BarChart/BarChart.styled.js +0 -119
  18. package/dist/Charts/BarChart/BarChart.types.d.ts +0 -179
  19. package/dist/Charts/BarChart/BarChart.types.js +0 -1
  20. package/dist/Charts/BarChart/index.d.ts +0 -3
  21. package/dist/Charts/BarChart/index.js +0 -2
  22. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +0 -11
  23. package/dist/Charts/ChartPrimitives/ChartExportControl.js +0 -29
  24. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +0 -1
  25. package/dist/Charts/ChartPrimitives/chartActions.styled.js +0 -8
  26. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +0 -12
  27. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +0 -52
  28. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +0 -19
  29. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +0 -61
  30. package/dist/Charts/ChartPrimitives/index.d.ts +0 -4
  31. package/dist/Charts/ChartPrimitives/index.js +0 -4
  32. package/dist/Charts/ChartUtils/chartColors.d.ts +0 -8
  33. package/dist/Charts/ChartUtils/chartColors.js +0 -65
  34. package/dist/Charts/ChartUtils/chartExport.d.ts +0 -47
  35. package/dist/Charts/ChartUtils/chartExport.js +0 -311
  36. package/dist/Charts/ChartUtils/chartMath.d.ts +0 -3
  37. package/dist/Charts/ChartUtils/chartMath.js +0 -3
  38. package/dist/Charts/ChartUtils/chartSizing.d.ts +0 -20
  39. package/dist/Charts/ChartUtils/chartSizing.js +0 -83
  40. package/dist/Charts/ChartUtils/index.d.ts +0 -4
  41. package/dist/Charts/ChartUtils/index.js +0 -4
  42. package/dist/Charts/HeatMap/HeatMap.d.ts +0 -5
  43. package/dist/Charts/HeatMap/HeatMap.js +0 -233
  44. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +0 -30
  45. package/dist/Charts/HeatMap/HeatMap.lib.js +0 -115
  46. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +0 -41
  47. package/dist/Charts/HeatMap/HeatMap.styled.js +0 -94
  48. package/dist/Charts/HeatMap/HeatMap.types.d.ts +0 -86
  49. package/dist/Charts/HeatMap/HeatMap.types.js +0 -1
  50. package/dist/Charts/HeatMap/index.d.ts +0 -3
  51. package/dist/Charts/HeatMap/index.js +0 -2
  52. package/dist/Charts/LineChart/LineChart.d.ts +0 -5
  53. package/dist/Charts/LineChart/LineChart.js +0 -548
  54. package/dist/Charts/LineChart/LineChart.lib.d.ts +0 -24
  55. package/dist/Charts/LineChart/LineChart.lib.js +0 -132
  56. package/dist/Charts/LineChart/LineChart.styled.d.ts +0 -64
  57. package/dist/Charts/LineChart/LineChart.styled.js +0 -151
  58. package/dist/Charts/LineChart/LineChart.types.d.ts +0 -201
  59. package/dist/Charts/LineChart/LineChart.types.js +0 -1
  60. package/dist/Charts/LineChart/index.d.ts +0 -3
  61. package/dist/Charts/LineChart/index.js +0 -2
  62. package/dist/Charts/PieChart/PieChart.d.ts +0 -4
  63. package/dist/Charts/PieChart/PieChart.js +0 -214
  64. package/dist/Charts/PieChart/PieChart.lib.d.ts +0 -5
  65. package/dist/Charts/PieChart/PieChart.lib.js +0 -19
  66. package/dist/Charts/PieChart/PieChart.styled.d.ts +0 -56
  67. package/dist/Charts/PieChart/PieChart.styled.js +0 -168
  68. package/dist/Charts/PieChart/PieChart.types.d.ts +0 -104
  69. package/dist/Charts/PieChart/PieChart.types.js +0 -1
  70. package/dist/Charts/PieChart/index.d.ts +0 -2
  71. package/dist/Charts/PieChart/index.js +0 -1
  72. package/dist/Charts/index.d.ts +0 -5
  73. package/dist/Charts/index.js +0 -4
  74. package/dist/QueryFilter/QueryFilter.constants.d.ts +0 -134
  75. package/dist/QueryFilter/QueryFilter.constants.js +0 -39
  76. package/dist/QueryFilter/QueryFilter.lib.d.ts +0 -14
  77. package/dist/QueryFilter/QueryFilter.lib.js +0 -84
  78. package/dist/QueryFilter/QueryFilter.styled.d.ts +0 -89
  79. package/dist/QueryFilter/QueryFilter.styled.js +0 -184
  80. package/dist/QueryFilter/QueryFilter.types.d.ts +0 -61
  81. package/dist/QueryFilter/QueryFilter.types.js +0 -1
  82. package/dist/QueryFilter/components/MultiSelectEditor.d.ts +0 -7
  83. package/dist/QueryFilter/components/MultiSelectEditor.js +0 -44
  84. package/dist/QueryFilter/components/RuleChip.d.ts +0 -8
  85. package/dist/QueryFilter/components/RuleChip.js +0 -37
  86. package/dist/QueryFilter/components/Rules.d.ts +0 -11
  87. package/dist/QueryFilter/components/Rules.js +0 -41
  88. package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +0 -5
  89. package/dist/QueryFilter/components/UnavailableRuleChip.js +0 -7
  90. package/dist/QueryFilter/components/ValueEditor.d.ts +0 -7
  91. package/dist/QueryFilter/components/ValueEditor.js +0 -45
  92. package/dist/QueryFilter/components/ValueSelector.d.ts +0 -7
  93. package/dist/QueryFilter/components/ValueSelector.js +0 -34
  94. package/dist/QueryFilter/components/index.d.ts +0 -6
  95. package/dist/QueryFilter/components/index.js +0 -6
  96. package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +0 -18
  97. package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +0 -6
  98. package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +0 -9
  99. package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +0 -42
  100. package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +0 -10
  101. package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +0 -60
  102. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +0 -9
  103. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +0 -30
  104. package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +0 -3
  105. package/dist/RichTextEditor/Components/CodeBlockNodeView.js +0 -28
  106. package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +0 -10
  107. package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +0 -17
  108. package/dist/RichTextEditor/Components/LinkEditor.d.ts +0 -8
  109. package/dist/RichTextEditor/Components/LinkEditor.js +0 -94
  110. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +0 -2
  111. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +0 -19
  112. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +0 -2
  113. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +0 -24
  114. package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +0 -2
  115. package/dist/RichTextEditor/Components/TableTools/TableRails.js +0 -180
  116. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +0 -5
  117. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +0 -6
  118. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +0 -5
  119. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +0 -183
  120. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +0 -16
  121. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +0 -217
  122. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +0 -8
  123. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +0 -11
  124. package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +0 -3
  125. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +0 -23
  126. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +0 -75
  127. package/dist/RichTextEditor/Components/TableTools/TableTools.js +0 -3
  128. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +0 -16
  129. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +0 -53
  130. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +0 -40
  131. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +0 -167
  132. package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +0 -76
  133. package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +0 -1
  134. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +0 -4
  135. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +0 -4
  136. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +0 -2
  137. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +0 -12
  138. package/dist/RichTextEditor/Components/TableTools/index.d.ts +0 -3
  139. package/dist/RichTextEditor/Components/TableTools/index.js +0 -2
  140. package/dist/RichTextEditor/Enums/HighlightColors.d.ts +0 -9
  141. package/dist/RichTextEditor/Enums/HighlightColors.js +0 -10
  142. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +0 -3
  143. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +0 -238
  144. package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +0 -20
  145. package/dist/RichTextEditor/Utils/codeBlockUtils.js +0 -137
  146. package/dist/RichTextEditor/Utils/codeUtils.d.ts +0 -3
  147. package/dist/RichTextEditor/Utils/codeUtils.js +0 -12
  148. package/dist/RichTextEditor/Utils/linkUtils.d.ts +0 -19
  149. package/dist/RichTextEditor/Utils/linkUtils.js +0 -57
  150. package/dist/RichTextEditor/Utils/tableUtils.d.ts +0 -1
  151. package/dist/RichTextEditor/Utils/tableUtils.js +0 -1
  152. package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +0 -24
  153. package/dist/SuperDatePicker/SuperDatePicker.constants.js +0 -30
  154. package/dist/SuperDatePicker/SuperDatePicker.d.ts +0 -3
  155. package/dist/SuperDatePicker/SuperDatePicker.js +0 -31
  156. package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +0 -17
  157. package/dist/SuperDatePicker/SuperDatePicker.lib.js +0 -206
  158. package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +0 -60
  159. package/dist/SuperDatePicker/SuperDatePicker.styled.js +0 -256
  160. package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +0 -48
  161. package/dist/SuperDatePicker/SuperDatePicker.types.js +0 -1
  162. package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +0 -7
  163. package/dist/SuperDatePicker/components/CommonPresetGroups.js +0 -6
  164. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +0 -10
  165. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +0 -9
  166. package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +0 -16
  167. package/dist/SuperDatePicker/components/EndpointDateInput.js +0 -26
  168. package/dist/SuperDatePicker/components/EndpointPopover.d.ts +0 -18
  169. package/dist/SuperDatePicker/components/EndpointPopover.js +0 -11
  170. package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +0 -14
  171. package/dist/SuperDatePicker/components/QuickRangeDropdown.js +0 -19
  172. package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +0 -18
  173. package/dist/SuperDatePicker/components/QuickRangePopover.js +0 -12
  174. package/dist/SuperDatePicker/components/index.d.ts +0 -6
  175. package/dist/SuperDatePicker/components/index.js +0 -6
  176. package/dist/SuperDatePicker/index.d.ts +0 -3
  177. package/dist/SuperDatePicker/index.js +0 -3
  178. package/dist/SuperDatePicker/useSuperDatePicker.d.ts +0 -32
  179. package/dist/SuperDatePicker/useSuperDatePicker.js +0 -125
@@ -1,61 +0,0 @@
1
- import styled from "styled-components";
2
- export const StyledChartTooltip = styled.div `
3
- position: absolute;
4
- z-index: 1;
5
- min-width: ${({ $minWidth = 120 }) => $minWidth}px;
6
- max-width: ${({ $maxWidth = 220 }) => $maxWidth}px;
7
- padding: 7px 9px;
8
- border: 1px solid ${({ theme }) => theme.palette.divider};
9
- border-radius: 4px;
10
- background: ${({ theme }) => theme.palette.background.paper};
11
- color: ${({ theme }) => theme.palette.text.primary};
12
- box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
13
- font-size: 12px;
14
- line-height: 1.35;
15
- pointer-events: none;
16
- transform: ${({ $transform = "translate(10px, -50%)" }) => $transform};
17
- `;
18
- export const StyledChartTooltipHeader = styled.div `
19
- display: flex;
20
- align-items: center;
21
- gap: 7px;
22
- min-width: 0;
23
- font-weight: 600;
24
- `;
25
- export const StyledChartTooltipSwatch = styled.span `
26
- width: 8px;
27
- height: 8px;
28
- flex: 0 0 auto;
29
- border-radius: ${({ $radius = "2px" }) => $radius};
30
- background: ${({ $color }) => $color};
31
- `;
32
- export const StyledChartTooltipLabel = styled.span `
33
- overflow: hidden;
34
- text-overflow: ellipsis;
35
- white-space: nowrap;
36
- `;
37
- export const StyledChartTooltipMeta = styled.div `
38
- display: flex;
39
- flex-direction: ${({ $direction = "row" }) => $direction};
40
- gap: ${({ $gap = 8 }) => $gap}px;
41
- margin-top: ${({ $marginTop = 3 }) => $marginTop}px;
42
- color: ${({ theme }) => theme.palette.text.secondary};
43
- font-variant-numeric: tabular-nums;
44
- `;
45
- export const StyledChartTooltipList = styled.div `
46
- display: flex;
47
- flex-direction: column;
48
- gap: 5px;
49
- margin-top: 8px;
50
- `;
51
- export const StyledChartTooltipRow = styled.div `
52
- display: grid;
53
- grid-template-columns: 8px minmax(0, 1fr) auto;
54
- align-items: center;
55
- gap: 7px;
56
- `;
57
- export const StyledChartTooltipValue = styled.span `
58
- color: ${({ theme }) => theme.palette.text.primary};
59
- font-variant-numeric: tabular-nums;
60
- white-space: nowrap;
61
- `;
@@ -1,4 +0,0 @@
1
- export * from "./ChartExportControl";
2
- export * from "./chartActions.styled";
3
- export * from "./chartLegend.styled";
4
- export * from "./chartTooltip.styled";
@@ -1,4 +0,0 @@
1
- export * from "./ChartExportControl";
2
- export * from "./chartActions.styled";
3
- export * from "./chartLegend.styled";
4
- export * from "./chartTooltip.styled";
@@ -1,8 +0,0 @@
1
- export type ChartColorGradientInput = string[] | {
2
- from: string;
3
- to: string;
4
- } | null | undefined;
5
- export declare const mixColors: (from: string, to: string, amount: number) => string;
6
- export declare const getGradientStops: (colorGradient?: ChartColorGradientInput) => string[] | null;
7
- export declare const getGradientColorFromStops: (stops: string[] | null | undefined, index: number, total: number) => string | undefined;
8
- export declare const getGradientColor: (colorGradient: ChartColorGradientInput, index: number, total: number) => string | undefined;
@@ -1,65 +0,0 @@
1
- import { clamp } from "./chartMath";
2
- const parseColor = (color) => {
3
- const trimmedColor = color.trim();
4
- const hexMatch = trimmedColor.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
5
- if (hexMatch) {
6
- const normalizedHex = hexMatch[1].length === 3
7
- ? hexMatch[1]
8
- .split("")
9
- .map((character) => character + character)
10
- .join("")
11
- : hexMatch[1];
12
- return {
13
- r: parseInt(normalizedHex.slice(0, 2), 16),
14
- g: parseInt(normalizedHex.slice(2, 4), 16),
15
- b: parseInt(normalizedHex.slice(4, 6), 16),
16
- a: 1,
17
- };
18
- }
19
- const rgbMatch = trimmedColor.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/i);
20
- if (!rgbMatch) {
21
- return null;
22
- }
23
- return {
24
- r: clamp(Number(rgbMatch[1]), 0, 255),
25
- g: clamp(Number(rgbMatch[2]), 0, 255),
26
- b: clamp(Number(rgbMatch[3]), 0, 255),
27
- a: rgbMatch[4] ? clamp(Number(rgbMatch[4]), 0, 1) : 1,
28
- };
29
- };
30
- export const mixColors = (from, to, amount) => {
31
- const normalizedAmount = clamp(amount, 0, 1);
32
- if (normalizedAmount === 0)
33
- return from;
34
- if (normalizedAmount === 1)
35
- return to;
36
- const fromColor = parseColor(from);
37
- const toColor = parseColor(to);
38
- if (!fromColor || !toColor) {
39
- return `color-mix(in srgb, ${from} ${(1 - normalizedAmount) * 100}%, ${to})`;
40
- }
41
- const r = Math.round(fromColor.r + (toColor.r - fromColor.r) * normalizedAmount);
42
- const g = Math.round(fromColor.g + (toColor.g - fromColor.g) * normalizedAmount);
43
- const b = Math.round(fromColor.b + (toColor.b - fromColor.b) * normalizedAmount);
44
- const a = fromColor.a + (toColor.a - fromColor.a) * normalizedAmount;
45
- return a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${a})`;
46
- };
47
- export const getGradientStops = (colorGradient) => {
48
- if (!colorGradient)
49
- return null;
50
- return Array.isArray(colorGradient)
51
- ? colorGradient.filter(Boolean)
52
- : [colorGradient.from, colorGradient.to].filter(Boolean);
53
- };
54
- export const getGradientColorFromStops = (stops, index, total) => {
55
- if (!(stops === null || stops === void 0 ? void 0 : stops.length))
56
- return undefined;
57
- if (stops.length === 1 || total <= 1)
58
- return stops[0];
59
- const progress = index / (total - 1);
60
- const scaledProgress = progress * (stops.length - 1);
61
- const stopIndex = Math.min(Math.floor(scaledProgress), stops.length - 2);
62
- const stopProgress = scaledProgress - stopIndex;
63
- return mixColors(stops[stopIndex], stops[stopIndex + 1], stopProgress);
64
- };
65
- export const getGradientColor = (colorGradient, index, total) => getGradientColorFromStops(getGradientStops(colorGradient), index, total);
@@ -1,47 +0,0 @@
1
- export type ChartExportFormat = "svg" | "png" | "jpg";
2
- export type ChartImageExportRequest = {
3
- /** Output format for the exported image. Defaults to "svg". */
4
- format?: ChartExportFormat;
5
- /** Base file name used for the downloaded chart image. */
6
- fileName?: string;
7
- /** Output scale used for raster exports like png and jpg. */
8
- scale?: number;
9
- /** Background color applied to jpg exports. */
10
- backgroundColor?: string;
11
- };
12
- export type ChartHandle = {
13
- /** Returns the live SVG element rendered by the chart. */
14
- getSvgElement: () => SVGSVGElement | null;
15
- /** Downloads the current chart image using the provided or default export options. */
16
- downloadImage: (request?: ChartImageExportRequest) => Promise<void>;
17
- /** Copies the current chart image to the clipboard. Defaults to png for broad paste compatibility. */
18
- copyImage: (request?: ChartImageExportRequest) => Promise<boolean>;
19
- };
20
- export type ChartExportOptions = {
21
- /** Shows a download button that can export the current chart image. Defaults to false. */
22
- showExportButton?: boolean;
23
- /** Base file name used for downloaded chart images. */
24
- exportFileName?: string;
25
- /** Image formats offered in the export menu. Defaults to svg, png, and jpg. */
26
- exportFormats?: ChartExportFormat[];
27
- /** Output scale used for raster exports like png and jpg. Defaults to 2. */
28
- exportScale?: number;
29
- /** Background color applied to jpg exports. Defaults to the theme paper color. */
30
- exportBackgroundColor?: string;
31
- };
32
- export declare const DEFAULT_CHART_EXPORT_FORMATS: ChartExportFormat[];
33
- export declare const downloadChartImage: ({ rootElement, svg, format, fileName, scale, backgroundColor, }: {
34
- rootElement?: HTMLElement | null;
35
- svg: SVGSVGElement | null;
36
- format: ChartExportFormat;
37
- fileName: string;
38
- scale?: number;
39
- backgroundColor?: string;
40
- }) => Promise<void>;
41
- export declare const copyChartImage: ({ rootElement, svg, format, scale, backgroundColor, }: {
42
- rootElement?: HTMLElement | null;
43
- svg: SVGSVGElement | null;
44
- format?: ChartExportFormat;
45
- scale?: number;
46
- backgroundColor?: string;
47
- }) => Promise<boolean>;
@@ -1,311 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- export const DEFAULT_CHART_EXPORT_FORMATS = [
11
- "svg",
12
- "png",
13
- "jpg",
14
- ];
15
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
16
- const XML_NAMESPACE = "http://www.w3.org/2000/xmlns/";
17
- const XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
18
- const getSvgDimensions = (svg) => {
19
- const viewBox = svg.viewBox.baseVal;
20
- if (viewBox && viewBox.width > 0 && viewBox.height > 0) {
21
- return {
22
- width: viewBox.width,
23
- height: viewBox.height,
24
- };
25
- }
26
- const widthAttr = Number(svg.getAttribute("width"));
27
- const heightAttr = Number(svg.getAttribute("height"));
28
- if (Number.isFinite(widthAttr) && Number.isFinite(heightAttr)) {
29
- return {
30
- width: widthAttr,
31
- height: heightAttr,
32
- };
33
- }
34
- const rect = svg.getBoundingClientRect();
35
- return {
36
- width: Math.max(Math.round(rect.width), 1),
37
- height: Math.max(Math.round(rect.height), 1),
38
- };
39
- };
40
- const copyComputedStyles = (source, target) => {
41
- const computedStyle = window.getComputedStyle(source);
42
- let inlineStyle = "";
43
- for (let index = 0; index < computedStyle.length; index += 1) {
44
- const propertyName = computedStyle[index];
45
- inlineStyle += `${propertyName}:${computedStyle.getPropertyValue(propertyName)};`;
46
- }
47
- if (inlineStyle) {
48
- target.setAttribute("style", inlineStyle);
49
- }
50
- };
51
- const inlineNodeStyles = (sourceRoot, targetRoot) => {
52
- const sourceElements = [sourceRoot, ...Array.from(sourceRoot.querySelectorAll("*"))];
53
- const targetElements = [targetRoot, ...Array.from(targetRoot.querySelectorAll("*"))];
54
- sourceElements.forEach((sourceElement, index) => {
55
- const targetElement = targetElements[index];
56
- if (!targetElement)
57
- return;
58
- copyComputedStyles(sourceElement, targetElement);
59
- });
60
- };
61
- const removeIgnoredNodes = (root) => {
62
- root
63
- .querySelectorAll('[data-chart-export-ignore="true"]')
64
- .forEach((element) => element.remove());
65
- };
66
- const serializeSvg = (svg) => {
67
- const clone = svg.cloneNode(true);
68
- const { width, height } = getSvgDimensions(svg);
69
- clone.setAttribute("version", "1.1");
70
- clone.setAttribute("xmlns", SVG_NAMESPACE);
71
- clone.setAttributeNS(XML_NAMESPACE, "xmlns:xlink", XLINK_NAMESPACE);
72
- clone.setAttribute("width", String(width));
73
- clone.setAttribute("height", String(height));
74
- if (!clone.getAttribute("viewBox")) {
75
- clone.setAttribute("viewBox", `0 0 ${width} ${height}`);
76
- }
77
- inlineNodeStyles(svg, clone);
78
- const serializer = new XMLSerializer();
79
- return `<?xml version="1.0" encoding="UTF-8"?>${serializer.serializeToString(clone)}`;
80
- };
81
- const getElementDimensions = (element) => {
82
- const rect = element.getBoundingClientRect();
83
- return {
84
- width: Math.max(Math.round(rect.width || element.offsetWidth || element.clientWidth || 1), 1),
85
- height: Math.max(Math.round(rect.height || element.offsetHeight || element.clientHeight || 1), 1),
86
- };
87
- };
88
- const isExportIgnored = (element) => element.closest('[data-chart-export-ignore="true"]') != null;
89
- const isVisibleElement = (element) => {
90
- const computedStyle = window.getComputedStyle(element);
91
- return (computedStyle.display !== "none" &&
92
- computedStyle.visibility !== "hidden" &&
93
- computedStyle.opacity !== "0");
94
- };
95
- const getElementText = (element) => {
96
- var _a, _b;
97
- const hasElementChildren = Array.from(element.childNodes).some((node) => node.nodeType === Node.ELEMENT_NODE);
98
- if (hasElementChildren)
99
- return "";
100
- return (_b = (_a = element.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : "";
101
- };
102
- const isRenderableColor = (color) => color !== "" && color !== "transparent" && color !== "rgba(0, 0, 0, 0)";
103
- const appendElementBox = (targetSvg, element, rootRect) => {
104
- const computedStyle = window.getComputedStyle(element);
105
- const backgroundColor = computedStyle.backgroundColor;
106
- const borderColor = computedStyle.borderColor;
107
- const borderWidth = Number.parseFloat(computedStyle.borderWidth) || 0;
108
- const hasBackground = isRenderableColor(backgroundColor);
109
- const hasBorder = borderWidth > 0 && isRenderableColor(borderColor);
110
- if (!hasBackground && !hasBorder)
111
- return;
112
- const rect = element.getBoundingClientRect();
113
- const radius = Number.parseFloat(computedStyle.borderRadius) || 0;
114
- const box = document.createElementNS(SVG_NAMESPACE, "rect");
115
- box.setAttribute("x", String(rect.left - rootRect.left));
116
- box.setAttribute("y", String(rect.top - rootRect.top));
117
- box.setAttribute("width", String(Math.max(rect.width, 0)));
118
- box.setAttribute("height", String(Math.max(rect.height, 0)));
119
- box.setAttribute("rx", String(radius));
120
- box.setAttribute("ry", String(radius));
121
- box.setAttribute("fill", hasBackground ? backgroundColor : "none");
122
- if (hasBorder) {
123
- box.setAttribute("stroke", borderColor);
124
- box.setAttribute("stroke-width", String(borderWidth));
125
- }
126
- targetSvg.appendChild(box);
127
- };
128
- const appendElementText = (targetSvg, element, rootRect) => {
129
- const text = getElementText(element);
130
- if (!text)
131
- return;
132
- const computedStyle = window.getComputedStyle(element);
133
- const rect = element.getBoundingClientRect();
134
- const textNode = document.createElementNS(SVG_NAMESPACE, "text");
135
- const fontSize = Number.parseFloat(computedStyle.fontSize) || 12;
136
- const fontWeight = computedStyle.fontWeight;
137
- const textAlign = computedStyle.textAlign;
138
- const isRightAligned = textAlign === "right" || textAlign === "end";
139
- const isCenterAligned = textAlign === "center";
140
- const x = isRightAligned
141
- ? rect.right - rootRect.left
142
- : isCenterAligned
143
- ? rect.left - rootRect.left + rect.width / 2
144
- : rect.left - rootRect.left;
145
- textNode.textContent = text;
146
- textNode.setAttribute("x", String(x));
147
- textNode.setAttribute("y", String(rect.top - rootRect.top + rect.height / 2));
148
- textNode.setAttribute("text-anchor", isRightAligned ? "end" : isCenterAligned ? "middle" : "start");
149
- textNode.setAttribute("dominant-baseline", "central");
150
- textNode.setAttribute("fill", computedStyle.color);
151
- textNode.setAttribute("font-family", computedStyle.fontFamily);
152
- textNode.setAttribute("font-size", `${fontSize}px`);
153
- textNode.setAttribute("font-weight", fontWeight);
154
- if (computedStyle.fontVariantNumeric) {
155
- textNode.setAttribute("font-variant-numeric", computedStyle.fontVariantNumeric);
156
- }
157
- targetSvg.appendChild(textNode);
158
- };
159
- const appendNestedSvg = (targetSvg, svg, rootRect) => {
160
- const clone = svg.cloneNode(true);
161
- const rect = svg.getBoundingClientRect();
162
- inlineNodeStyles(svg, clone);
163
- removeIgnoredNodes(clone);
164
- clone.setAttribute("x", String(rect.left - rootRect.left));
165
- clone.setAttribute("y", String(rect.top - rootRect.top));
166
- clone.setAttribute("width", String(Math.max(rect.width, 1)));
167
- clone.setAttribute("height", String(Math.max(rect.height, 1)));
168
- targetSvg.appendChild(clone);
169
- };
170
- const serializeElement = (element) => {
171
- const { width, height } = getElementDimensions(element);
172
- const rootRect = element.getBoundingClientRect();
173
- const wrapperSvg = document.createElementNS(SVG_NAMESPACE, "svg");
174
- wrapperSvg.setAttribute("version", "1.1");
175
- wrapperSvg.setAttribute("xmlns", SVG_NAMESPACE);
176
- wrapperSvg.setAttributeNS(XML_NAMESPACE, "xmlns:xlink", XLINK_NAMESPACE);
177
- wrapperSvg.setAttribute("width", String(width));
178
- wrapperSvg.setAttribute("height", String(height));
179
- wrapperSvg.setAttribute("viewBox", `0 0 ${width} ${height}`);
180
- const appendElement = (currentElement) => {
181
- if (currentElement !== element && isExportIgnored(currentElement))
182
- return;
183
- if (!isVisibleElement(currentElement))
184
- return;
185
- if (currentElement instanceof SVGSVGElement) {
186
- appendNestedSvg(wrapperSvg, currentElement, rootRect);
187
- return;
188
- }
189
- appendElementBox(wrapperSvg, currentElement, rootRect);
190
- appendElementText(wrapperSvg, currentElement, rootRect);
191
- Array.from(currentElement.children).forEach(appendElement);
192
- };
193
- appendElement(element);
194
- const serializer = new XMLSerializer();
195
- return `<?xml version="1.0" encoding="UTF-8"?>${serializer.serializeToString(wrapperSvg)}`;
196
- };
197
- const triggerDownload = (blob, fileName) => {
198
- const objectUrl = URL.createObjectURL(blob);
199
- const anchor = document.createElement("a");
200
- anchor.href = objectUrl;
201
- anchor.download = fileName;
202
- document.body.appendChild(anchor);
203
- anchor.click();
204
- document.body.removeChild(anchor);
205
- window.setTimeout(() => {
206
- URL.revokeObjectURL(objectUrl);
207
- }, 0);
208
- };
209
- const rasterizeSvg = (_a) => __awaiter(void 0, [_a], void 0, function* ({ svgMarkup, format, width, height, scale, backgroundColor, }) {
210
- if (typeof window !== "undefined" && "fonts" in document) {
211
- yield document.fonts.ready;
212
- }
213
- const svgBlob = new Blob([svgMarkup], {
214
- type: "image/svg+xml;charset=utf-8",
215
- });
216
- const svgUrl = URL.createObjectURL(svgBlob);
217
- try {
218
- const image = yield new Promise((resolve, reject) => {
219
- const nextImage = new Image();
220
- nextImage.onload = () => resolve(nextImage);
221
- nextImage.onerror = () => reject(new Error("Unable to render the chart image."));
222
- nextImage.src = svgUrl;
223
- });
224
- const canvas = document.createElement("canvas");
225
- canvas.width = Math.max(Math.round(width * scale), 1);
226
- canvas.height = Math.max(Math.round(height * scale), 1);
227
- const context = canvas.getContext("2d");
228
- if (!context) {
229
- throw new Error("Unable to create a canvas for chart export.");
230
- }
231
- context.setTransform(scale, 0, 0, scale, 0, 0);
232
- if (format === "jpg") {
233
- context.fillStyle = backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : "#ffffff";
234
- context.fillRect(0, 0, width, height);
235
- }
236
- context.drawImage(image, 0, 0, width, height);
237
- const mimeType = format === "png" ? "image/png" : "image/jpeg";
238
- return yield new Promise((resolve, reject) => {
239
- canvas.toBlob((blob) => {
240
- if (!blob) {
241
- reject(new Error("Unable to generate the exported chart image."));
242
- return;
243
- }
244
- resolve(blob);
245
- }, mimeType, format === "jpg" ? 0.92 : undefined);
246
- });
247
- }
248
- finally {
249
- URL.revokeObjectURL(svgUrl);
250
- }
251
- });
252
- const getChartImageBlob = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rootElement, svg, format, scale = 2, backgroundColor, }) {
253
- if (typeof window === "undefined" || typeof document === "undefined") {
254
- return null;
255
- }
256
- if (!rootElement && !svg)
257
- return null;
258
- const safeScale = Number.isFinite(scale) ? Math.max(scale, 1) : 2;
259
- const svgMarkup = rootElement ? serializeElement(rootElement) : serializeSvg(svg);
260
- const { width, height } = rootElement
261
- ? getElementDimensions(rootElement)
262
- : getSvgDimensions(svg);
263
- if (format === "svg") {
264
- return new Blob([svgMarkup], {
265
- type: "image/svg+xml;charset=utf-8",
266
- });
267
- }
268
- return yield rasterizeSvg({
269
- svgMarkup,
270
- format,
271
- width,
272
- height,
273
- scale: safeScale,
274
- backgroundColor,
275
- });
276
- });
277
- export const downloadChartImage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rootElement, svg, format, fileName, scale = 2, backgroundColor, }) {
278
- const blob = yield getChartImageBlob({
279
- rootElement,
280
- svg,
281
- format,
282
- scale,
283
- backgroundColor,
284
- });
285
- if (!blob)
286
- return;
287
- triggerDownload(blob, `${fileName}.${format}`);
288
- });
289
- export const copyChartImage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rootElement, svg, format = "png", scale = 2, backgroundColor, }) {
290
- var _b;
291
- if (typeof window === "undefined" ||
292
- typeof navigator === "undefined" ||
293
- typeof ClipboardItem === "undefined" ||
294
- !((_b = navigator.clipboard) === null || _b === void 0 ? void 0 : _b.write)) {
295
- return false;
296
- }
297
- const blob = yield getChartImageBlob({
298
- rootElement,
299
- svg,
300
- format,
301
- scale,
302
- backgroundColor,
303
- });
304
- if (!blob)
305
- return false;
306
- const clipboardItem = new ClipboardItem({
307
- [blob.type]: blob,
308
- });
309
- yield navigator.clipboard.write([clipboardItem]);
310
- return true;
311
- });
@@ -1,3 +0,0 @@
1
- export declare const formatDefaultValue: (value: number) => string;
2
- export declare const clamp: (value: number, min: number, max: number) => number;
3
- export declare const easeOutCubic: (value: number) => number;
@@ -1,3 +0,0 @@
1
- export const formatDefaultValue = (value) => new Intl.NumberFormat().format(value);
2
- export const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
3
- export const easeOutCubic = (value) => 1 - Math.pow(1 - value, 3);
@@ -1,20 +0,0 @@
1
- import { RefObject } from "react";
2
- export type ChartDimension = number | string;
3
- export type ChartResponsiveSizeOptions = {
4
- width?: ChartDimension;
5
- height?: ChartDimension;
6
- responsive?: boolean;
7
- aspectRatio?: number;
8
- defaultWidth: number;
9
- defaultHeight: number;
10
- minWidth: number;
11
- minHeight: number;
12
- };
13
- export type ResolvedChartSize = {
14
- width: number;
15
- height: number;
16
- widthStyle?: string;
17
- heightStyle?: string;
18
- fillAvailableWidth: boolean;
19
- };
20
- export declare const useChartResponsiveSize: (ref: RefObject<HTMLElement | null>, { width, height, responsive, aspectRatio, defaultWidth, defaultHeight, minWidth, minHeight, }: ChartResponsiveSizeOptions) => ResolvedChartSize;
@@ -1,83 +0,0 @@
1
- import { useEffect, useMemo, useState } from "react";
2
- const toDimensionStyle = (dimension) => {
3
- if (dimension == null || typeof dimension === "number")
4
- return undefined;
5
- return dimension;
6
- };
7
- const toNumericDimension = (dimension, fallback) => typeof dimension === "number" && Number.isFinite(dimension)
8
- ? dimension
9
- : fallback;
10
- const getElementSize = (element) => {
11
- const rect = element.getBoundingClientRect();
12
- return {
13
- width: Math.max(Math.round(rect.width || element.clientWidth || 0), 0),
14
- height: Math.max(Math.round(rect.height || element.clientHeight || 0), 0),
15
- };
16
- };
17
- export const useChartResponsiveSize = (ref, { width, height, responsive = false, aspectRatio, defaultWidth, defaultHeight, minWidth, minHeight, }) => {
18
- const resolvedWidthInput = width !== null && width !== void 0 ? width : (responsive ? "100%" : defaultWidth);
19
- const resolvedHeightInput = height !== null && height !== void 0 ? height : defaultHeight;
20
- const shouldMeasureWidth = responsive || typeof resolvedWidthInput === "string";
21
- const shouldMeasureHeight = typeof resolvedHeightInput === "string";
22
- const shouldMeasure = shouldMeasureWidth || shouldMeasureHeight;
23
- const [measuredSize, setMeasuredSize] = useState({ width: 0, height: 0 });
24
- useEffect(() => {
25
- if (!shouldMeasure)
26
- return;
27
- const element = ref.current;
28
- if (!element)
29
- return;
30
- const updateSize = () => {
31
- const nextSize = getElementSize(element);
32
- setMeasuredSize((currentSize) => currentSize.width === nextSize.width &&
33
- currentSize.height === nextSize.height
34
- ? currentSize
35
- : nextSize);
36
- };
37
- updateSize();
38
- if (typeof ResizeObserver === "undefined") {
39
- window.addEventListener("resize", updateSize);
40
- return () => window.removeEventListener("resize", updateSize);
41
- }
42
- const observer = new ResizeObserver(updateSize);
43
- observer.observe(element);
44
- return () => observer.disconnect();
45
- }, [ref, shouldMeasure]);
46
- return useMemo(() => {
47
- const fallbackWidth = toNumericDimension(resolvedWidthInput, defaultWidth);
48
- const fallbackHeight = toNumericDimension(resolvedHeightInput, defaultHeight);
49
- const measuredWidth = shouldMeasureWidth && measuredSize.width > 0
50
- ? measuredSize.width
51
- : fallbackWidth;
52
- const safeWidth = Math.max(measuredWidth, minWidth);
53
- const resolvedAspectRatio = aspectRatio != null && Number.isFinite(aspectRatio) && aspectRatio > 0
54
- ? aspectRatio
55
- : null;
56
- const measuredHeight = height == null && resolvedAspectRatio != null
57
- ? safeWidth / resolvedAspectRatio
58
- : shouldMeasureHeight && measuredSize.height > 0
59
- ? measuredSize.height
60
- : fallbackHeight;
61
- return {
62
- width: Math.max(Math.round(safeWidth), minWidth),
63
- height: Math.max(Math.round(measuredHeight), minHeight),
64
- widthStyle: toDimensionStyle(resolvedWidthInput),
65
- heightStyle: toDimensionStyle(resolvedHeightInput),
66
- fillAvailableWidth: responsive || typeof resolvedWidthInput === "string",
67
- };
68
- }, [
69
- aspectRatio,
70
- defaultHeight,
71
- defaultWidth,
72
- height,
73
- measuredSize.height,
74
- measuredSize.width,
75
- minHeight,
76
- minWidth,
77
- resolvedHeightInput,
78
- resolvedWidthInput,
79
- responsive,
80
- shouldMeasureHeight,
81
- shouldMeasureWidth,
82
- ]);
83
- };
@@ -1,4 +0,0 @@
1
- export * from "./chartColors";
2
- export * from "./chartExport";
3
- export * from "./chartMath";
4
- export * from "./chartSizing";
@@ -1,4 +0,0 @@
1
- export * from "./chartColors";
2
- export * from "./chartExport";
3
- export * from "./chartMath";
4
- export * from "./chartSizing";
@@ -1,5 +0,0 @@
1
- import { ReactElement, RefAttributes } from "react";
2
- import { ChartHandle } from "../ChartUtils";
3
- import { HeatMapProps } from "./HeatMap.types";
4
- declare const HeatMap: <TData>(props: HeatMapProps<TData> & RefAttributes<ChartHandle>) => ReactElement | null;
5
- export default HeatMap;