@mui/x-charts-premium 8.26.0 → 9.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChartPremium/BarChartPremium.d.ts +14 -2
- package/BarChartPremium/BarChartPremium.js +11 -5
- package/BarChartPremium/RangeBar/AnimatedRangeBarElement.js +1 -1
- package/BarChartPremium/RangeBar/FocusedRangeBar.d.ts +2 -0
- package/BarChartPremium/RangeBar/FocusedRangeBar.js +70 -0
- package/BarChartPremium/RangeBar/RangeBarPlot.js +1 -1
- package/BarChartPremium/RangeBar/createGetRangeBarDimensions.d.ts +13 -0
- package/BarChartPremium/RangeBar/createGetRangeBarDimensions.js +42 -0
- package/BarChartPremium/RangeBar/seriesConfig/getSeriesWithDefaultValues.d.ts +2 -2
- package/BarChartPremium/RangeBar/seriesConfig/index.js +4 -1
- package/BarChartPremium/RangeBar/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/BarChartPremium/RangeBar/seriesConfig/keyboardFocusHandler.js +22 -0
- package/BarChartPremium/RangeBar/seriesConfig/legend.js +0 -1
- package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.js +8 -2
- package/BarChartPremium/RangeBar/useRangeBarPlotData.d.ts +2 -9
- package/BarChartPremium/RangeBar/useRangeBarPlotData.js +16 -51
- package/BarChartPremium/index.d.ts +1 -0
- package/BarChartPremium/index.js +12 -0
- package/CHANGELOG.md +355 -3
- package/ChartContainerPremium/ChartContainerPremium.d.ts +17 -31
- package/ChartContainerPremium/ChartContainerPremium.js +15 -43
- package/ChartContainerPremium/useChartContainerPremiumProps.d.ts +10 -9
- package/ChartContainerPremium/useChartContainerPremiumProps.js +10 -27
- package/ChartDataProviderPremium/ChartDataProviderPremium.d.ts +7 -5
- package/ChartDataProviderPremium/ChartDataProviderPremium.js +6 -6
- package/ChartDataProviderPremium/index.d.ts +1 -1
- package/ChartDataProviderPremium/useChartDataProviderPremiumProps.d.ts +3 -3
- package/ChartZoomSlider/internals/previews/RangeBarPreviewPlot.js +1 -1
- package/ChartsContainer/index.d.ts +1 -0
- package/ChartsContainer/index.js +16 -0
- package/ChartsContainerPremium/ChartsContainerPremium.d.ts +37 -0
- package/ChartsContainerPremium/ChartsContainerPremium.js +52 -0
- package/ChartsContainerPremium/index.d.ts +2 -0
- package/ChartsContainerPremium/index.js +17 -0
- package/ChartsContainerPremium/useChartsContainerPremiumProps.d.ts +9 -0
- package/ChartsContainerPremium/useChartsContainerPremiumProps.js +33 -0
- package/ChartsContainerPro/index.d.ts +1 -0
- package/ChartsContainerPro/index.js +16 -0
- package/HeatmapPremium/HeatmapPlotPremium.d.ts +9 -0
- package/HeatmapPremium/HeatmapPlotPremium.js +29 -0
- package/HeatmapPremium/HeatmapPremium.d.ts +15 -0
- package/HeatmapPremium/HeatmapPremium.js +478 -0
- package/HeatmapPremium/HeatmapPremium.plugins.d.ts +4 -0
- package/HeatmapPremium/HeatmapPremium.plugins.js +9 -0
- package/HeatmapPremium/index.d.ts +1 -0
- package/HeatmapPremium/index.js +16 -0
- package/HeatmapPremium/useHeatmapPremiumProps.d.ts +16 -0
- package/HeatmapPremium/useHeatmapPremiumProps.js +26 -0
- package/HeatmapPremium/webgl/HeatmapWebGLPlot.d.ts +6 -0
- package/HeatmapPremium/webgl/HeatmapWebGLPlot.js +185 -0
- package/HeatmapPremium/webgl/HeatmapWebGLRenderer.d.ts +4 -0
- package/HeatmapPremium/webgl/HeatmapWebGLRenderer.js +23 -0
- package/HeatmapPremium/webgl/shaders.d.ts +3 -0
- package/HeatmapPremium/webgl/shaders.js +77 -0
- package/HeatmapPremium/webgl/useHeatmapPlotData.d.ts +12 -0
- package/HeatmapPremium/webgl/useHeatmapPlotData.js +58 -0
- package/HeatmapPremium/webgl/utils.d.ts +8 -0
- package/HeatmapPremium/webgl/utils.js +51 -0
- package/esm/BarChartPremium/BarChartPremium.d.ts +14 -2
- package/esm/BarChartPremium/BarChartPremium.js +12 -6
- package/esm/BarChartPremium/RangeBar/AnimatedRangeBarElement.js +1 -1
- package/esm/BarChartPremium/RangeBar/FocusedRangeBar.d.ts +2 -0
- package/esm/BarChartPremium/RangeBar/FocusedRangeBar.js +63 -0
- package/esm/BarChartPremium/RangeBar/RangeBarPlot.js +1 -1
- package/esm/BarChartPremium/RangeBar/createGetRangeBarDimensions.d.ts +13 -0
- package/esm/BarChartPremium/RangeBar/createGetRangeBarDimensions.js +36 -0
- package/esm/BarChartPremium/RangeBar/seriesConfig/getSeriesWithDefaultValues.d.ts +2 -2
- package/esm/BarChartPremium/RangeBar/seriesConfig/index.js +5 -2
- package/esm/BarChartPremium/RangeBar/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/esm/BarChartPremium/RangeBar/seriesConfig/keyboardFocusHandler.js +16 -0
- package/esm/BarChartPremium/RangeBar/seriesConfig/legend.js +0 -1
- package/esm/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.js +8 -2
- package/esm/BarChartPremium/RangeBar/useRangeBarPlotData.d.ts +2 -9
- package/esm/BarChartPremium/RangeBar/useRangeBarPlotData.js +16 -51
- package/esm/BarChartPremium/index.d.ts +1 -0
- package/esm/BarChartPremium/index.js +1 -0
- package/esm/ChartContainerPremium/ChartContainerPremium.d.ts +17 -31
- package/esm/ChartContainerPremium/ChartContainerPremium.js +16 -42
- package/esm/ChartContainerPremium/useChartContainerPremiumProps.d.ts +10 -9
- package/esm/ChartContainerPremium/useChartContainerPremiumProps.js +10 -25
- package/esm/ChartDataProviderPremium/ChartDataProviderPremium.d.ts +7 -5
- package/esm/ChartDataProviderPremium/ChartDataProviderPremium.js +6 -5
- package/esm/ChartDataProviderPremium/index.d.ts +1 -1
- package/esm/ChartDataProviderPremium/useChartDataProviderPremiumProps.d.ts +3 -3
- package/esm/ChartZoomSlider/internals/previews/RangeBarPreviewPlot.js +1 -1
- package/esm/ChartsContainer/index.d.ts +1 -0
- package/esm/ChartsContainer/index.js +2 -0
- package/esm/ChartsContainerPremium/ChartsContainerPremium.d.ts +37 -0
- package/esm/ChartsContainerPremium/ChartsContainerPremium.js +46 -0
- package/esm/ChartsContainerPremium/index.d.ts +2 -0
- package/esm/ChartsContainerPremium/index.js +2 -0
- package/esm/ChartsContainerPremium/useChartsContainerPremiumProps.d.ts +9 -0
- package/esm/ChartsContainerPremium/useChartsContainerPremiumProps.js +27 -0
- package/esm/ChartsContainerPro/index.d.ts +1 -0
- package/esm/ChartsContainerPro/index.js +2 -0
- package/esm/HeatmapPremium/HeatmapPlotPremium.d.ts +9 -0
- package/esm/HeatmapPremium/HeatmapPlotPremium.js +23 -0
- package/esm/HeatmapPremium/HeatmapPremium.d.ts +15 -0
- package/esm/HeatmapPremium/HeatmapPremium.js +472 -0
- package/esm/HeatmapPremium/HeatmapPremium.plugins.d.ts +4 -0
- package/esm/HeatmapPremium/HeatmapPremium.plugins.js +3 -0
- package/esm/HeatmapPremium/index.d.ts +1 -0
- package/esm/HeatmapPremium/index.js +1 -0
- package/esm/HeatmapPremium/useHeatmapPremiumProps.d.ts +16 -0
- package/esm/HeatmapPremium/useHeatmapPremiumProps.js +19 -0
- package/esm/HeatmapPremium/webgl/HeatmapWebGLPlot.d.ts +6 -0
- package/esm/HeatmapPremium/webgl/HeatmapWebGLPlot.js +178 -0
- package/esm/HeatmapPremium/webgl/HeatmapWebGLRenderer.d.ts +4 -0
- package/esm/HeatmapPremium/webgl/HeatmapWebGLRenderer.js +17 -0
- package/esm/HeatmapPremium/webgl/shaders.d.ts +3 -0
- package/esm/HeatmapPremium/webgl/shaders.js +71 -0
- package/esm/HeatmapPremium/webgl/useHeatmapPlotData.d.ts +12 -0
- package/esm/HeatmapPremium/webgl/useHeatmapPlotData.js +51 -0
- package/esm/HeatmapPremium/webgl/utils.d.ts +8 -0
- package/esm/HeatmapPremium/webgl/utils.js +41 -0
- package/esm/index.d.ts +5 -1
- package/esm/index.js +5 -2
- package/esm/internals/plugins/allPlugins.d.ts +1 -1
- package/esm/models/seriesType/rangeBar.d.ts +1 -1
- package/esm/typeOverloads/modules.d.ts +2 -1
- package/esm/utils/webgl/parseColor.d.ts +5 -0
- package/esm/utils/webgl/parseColor.js +78 -0
- package/esm/utils/webgl/useWebGLResizeObserver.d.ts +7 -0
- package/esm/utils/webgl/useWebGLResizeObserver.js +64 -0
- package/index.d.ts +5 -1
- package/index.js +33 -1
- package/internals/plugins/allPlugins.d.ts +1 -1
- package/models/seriesType/rangeBar.d.ts +1 -1
- package/package.json +9 -9
- package/typeOverloads/modules.d.ts +2 -1
- package/utils/webgl/parseColor.d.ts +5 -0
- package/utils/webgl/parseColor.js +84 -0
- package/utils/webgl/useWebGLResizeObserver.d.ts +7 -0
- package/utils/webgl/useWebGLResizeObserver.js +70 -0
package/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export * from '@mui/x-charts/ChartsSurface';
|
|
|
22
22
|
export * from '@mui/x-charts/ChartDataProvider';
|
|
23
23
|
export * from '@mui/x-charts/ChartsLabel';
|
|
24
24
|
export * from '@mui/x-charts-pro/Heatmap';
|
|
25
|
+
export { ChartsContainerPro } from '@mui/x-charts-pro/ChartsContainerPro';
|
|
26
|
+
export type { ChartsContainerProProps } from '@mui/x-charts-pro/ChartsContainerPro';
|
|
25
27
|
export { ChartContainerPro } from '@mui/x-charts-pro/ChartContainerPro';
|
|
26
28
|
export type { ChartContainerProProps } from '@mui/x-charts-pro/ChartContainerPro';
|
|
27
29
|
export * from '@mui/x-charts-pro/ChartDataProviderPro';
|
|
@@ -41,5 +43,7 @@ export * from "./models/index.js";
|
|
|
41
43
|
export * from "./plugins/index.js";
|
|
42
44
|
export * from "./ChartsRenderer/index.js";
|
|
43
45
|
export * from "./ChartDataProviderPremium/index.js";
|
|
46
|
+
export * from "./ChartsContainerPremium/index.js";
|
|
44
47
|
export * from "./ChartContainerPremium/index.js";
|
|
45
|
-
export * from "./BarChartPremium/index.js";
|
|
48
|
+
export * from "./BarChartPremium/index.js";
|
|
49
|
+
export * from "./HeatmapPremium/index.js";
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts-premium
|
|
2
|
+
* @mui/x-charts-premium v9.0.0-alpha.0
|
|
3
3
|
*
|
|
4
4
|
* @license SEE LICENSE IN LICENSE
|
|
5
5
|
* This source code is licensed under the SEE LICENSE IN LICENSE license found in the
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
11
11
|
value: true
|
|
12
12
|
});
|
|
13
13
|
var _exportNames = {
|
|
14
|
+
ChartsContainerPro: true,
|
|
14
15
|
ChartContainerPro: true
|
|
15
16
|
};
|
|
16
17
|
Object.defineProperty(exports, "ChartContainerPro", {
|
|
@@ -19,6 +20,12 @@ Object.defineProperty(exports, "ChartContainerPro", {
|
|
|
19
20
|
return _ChartContainerPro.ChartContainerPro;
|
|
20
21
|
}
|
|
21
22
|
});
|
|
23
|
+
Object.defineProperty(exports, "ChartsContainerPro", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _ChartsContainerPro.ChartsContainerPro;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
22
29
|
require("@mui/x-charts-pro/typeOverloads");
|
|
23
30
|
require("./typeOverloads/modules");
|
|
24
31
|
var _ChartsClipPath = require("@mui/x-charts/ChartsClipPath");
|
|
@@ -285,6 +292,7 @@ Object.keys(_Heatmap).forEach(function (key) {
|
|
|
285
292
|
}
|
|
286
293
|
});
|
|
287
294
|
});
|
|
295
|
+
var _ChartsContainerPro = require("@mui/x-charts-pro/ChartsContainerPro");
|
|
288
296
|
var _ChartContainerPro = require("@mui/x-charts-pro/ChartContainerPro");
|
|
289
297
|
var _ChartDataProviderPro = require("@mui/x-charts-pro/ChartDataProviderPro");
|
|
290
298
|
Object.keys(_ChartDataProviderPro).forEach(function (key) {
|
|
@@ -490,6 +498,18 @@ Object.keys(_ChartDataProviderPremium).forEach(function (key) {
|
|
|
490
498
|
}
|
|
491
499
|
});
|
|
492
500
|
});
|
|
501
|
+
var _ChartsContainerPremium = require("./ChartsContainerPremium");
|
|
502
|
+
Object.keys(_ChartsContainerPremium).forEach(function (key) {
|
|
503
|
+
if (key === "default" || key === "__esModule") return;
|
|
504
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
505
|
+
if (key in exports && exports[key] === _ChartsContainerPremium[key]) return;
|
|
506
|
+
Object.defineProperty(exports, key, {
|
|
507
|
+
enumerable: true,
|
|
508
|
+
get: function () {
|
|
509
|
+
return _ChartsContainerPremium[key];
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
});
|
|
493
513
|
var _ChartContainerPremium = require("./ChartContainerPremium");
|
|
494
514
|
Object.keys(_ChartContainerPremium).forEach(function (key) {
|
|
495
515
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -513,4 +533,16 @@ Object.keys(_BarChartPremium).forEach(function (key) {
|
|
|
513
533
|
return _BarChartPremium[key];
|
|
514
534
|
}
|
|
515
535
|
});
|
|
536
|
+
});
|
|
537
|
+
var _HeatmapPremium = require("./HeatmapPremium");
|
|
538
|
+
Object.keys(_HeatmapPremium).forEach(function (key) {
|
|
539
|
+
if (key === "default" || key === "__esModule") return;
|
|
540
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
541
|
+
if (key in exports && exports[key] === _HeatmapPremium[key]) return;
|
|
542
|
+
Object.defineProperty(exports, key, {
|
|
543
|
+
enumerable: true,
|
|
544
|
+
get: function () {
|
|
545
|
+
return _HeatmapPremium[key];
|
|
546
|
+
}
|
|
547
|
+
});
|
|
516
548
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ChartSeriesType, type ConvertSignaturesIntoPlugins, type UseChartCartesianAxisSignature, type UseChartTooltipSignature, type UseChartInteractionSignature, type UseChartZAxisSignature, type UseChartHighlightSignature, type UseChartPolarAxisSignature, type UseChartBrushSignature, type UseChartVisibilityManagerSignature } from '@mui/x-charts/internals';
|
|
2
2
|
import { type UseChartProExportSignature, type UseChartProZoomSignature } from '@mui/x-charts-pro/plugins';
|
|
3
|
-
export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartTooltipSignature
|
|
3
|
+
export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartTooltipSignature<TSeries>, UseChartInteractionSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature<TSeries>, UseChartHighlightSignature, UseChartVisibilityManagerSignature<TSeries>, UseChartProZoomSignature, UseChartProExportSignature];
|
|
4
4
|
export type AllPluginsType<TSeries extends ChartSeriesType = ChartSeriesType> = ConvertSignaturesIntoPlugins<AllPluginSignatures<TSeries>>;
|
|
5
5
|
export declare const ALL_PLUGINS: (import("@mui/x-charts/internals").ChartPlugin<UseChartZAxisSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartBrushSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartInteractionSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartHighlightSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartProZoomSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartProExportSignature> | import("@mui/x-charts/internals").ChartPlugin<UseChartTooltipSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartCartesianAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartPolarAxisSignature<any>> | import("@mui/x-charts/internals").ChartPlugin<UseChartVisibilityManagerSignature<any>>)[];
|
|
6
6
|
export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartTooltipSignature, UseChartInteractionSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature<TSeries>, UseChartHighlightSignature, UseChartVisibilityManagerSignature<TSeries>, UseChartProZoomSignature, UseChartProExportSignature];
|
|
@@ -2,7 +2,7 @@ import { type CartesianSeriesType, type CommonDefaultizedProps, type CommonSerie
|
|
|
2
2
|
import { type DefaultizedProps } from '@mui/x-internals/types';
|
|
3
3
|
/** [start, end] */
|
|
4
4
|
export type RangeBarValueType = [number, number];
|
|
5
|
-
export interface RangeBarSeriesType extends CommonSeriesType<RangeBarValueType | null>, CartesianSeriesType {
|
|
5
|
+
export interface RangeBarSeriesType extends CommonSeriesType<RangeBarValueType | null, 'rangeBar'>, CartesianSeriesType {
|
|
6
6
|
type: 'rangeBar';
|
|
7
7
|
/**
|
|
8
8
|
* Data associated to each range bar.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts-premium",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-alpha.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The Premium plan edition of the MUI X Charts components.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"directory": "packages/x-charts-premium"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/runtime": "^7.28.
|
|
31
|
-
"@mui/utils": "^7.3.
|
|
30
|
+
"@babel/runtime": "^7.28.6",
|
|
31
|
+
"@mui/utils": "^7.3.7",
|
|
32
32
|
"clsx": "^2.1.1",
|
|
33
33
|
"prop-types": "^15.8.1",
|
|
34
|
-
"@mui/x-charts
|
|
35
|
-
"@mui/x-charts": "
|
|
36
|
-
"@mui/x-
|
|
37
|
-
"@mui/x-
|
|
38
|
-
"@mui/x-license": "
|
|
34
|
+
"@mui/x-charts": "9.0.0-alpha.0",
|
|
35
|
+
"@mui/x-charts-pro": "9.0.0-alpha.0",
|
|
36
|
+
"@mui/x-internals": "9.0.0-alpha.0",
|
|
37
|
+
"@mui/x-charts-vendor": "9.0.0-alpha.0",
|
|
38
|
+
"@mui/x-license": "9.0.0-alpha.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@emotion/react": "^11.9.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"rasterizehtml": "^1.4.
|
|
57
|
+
"rasterizehtml": "^1.4.1"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=14.0.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DefaultizedProps, MakeRequired } from '@mui/x-internals/types';
|
|
2
|
-
import type { SeriesColor } from '@mui/x-charts/internals';
|
|
2
|
+
import type { CommonHighlightScope, SeriesColor } from '@mui/x-charts/internals';
|
|
3
3
|
import type { RangeBarValueType, RangeBarSeriesType } from "../models/index.js";
|
|
4
4
|
import type { DefaultizedRangeBarSeriesType, RangeBarItemIdentifier } from "../models/seriesType/rangeBar.js";
|
|
5
5
|
import type { BarSeries } from "../BarChart/index.js";
|
|
@@ -17,6 +17,7 @@ declare module '@mui/x-charts/internals' {
|
|
|
17
17
|
itemIdentifierWithData: RangeBarItemIdentifier;
|
|
18
18
|
valueType: RangeBarValueType | null;
|
|
19
19
|
axisType: 'cartesian';
|
|
20
|
+
highlightScope: CommonHighlightScope;
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseColor = parseColor;
|
|
7
|
+
const colorCache = new Map();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parse color string to RGBA object. Each channel is normalized to [0, 1].
|
|
11
|
+
* This function does not work in SSR.
|
|
12
|
+
*/
|
|
13
|
+
function parseColor(color) {
|
|
14
|
+
const cached = colorCache.get(color);
|
|
15
|
+
if (cached) {
|
|
16
|
+
return cached;
|
|
17
|
+
}
|
|
18
|
+
let result = parseColorUsingRegex(color);
|
|
19
|
+
if (result == null) {
|
|
20
|
+
result = parseRgbaColor(color);
|
|
21
|
+
}
|
|
22
|
+
if (result == null) {
|
|
23
|
+
result = parseColorUsingCanvas(color);
|
|
24
|
+
}
|
|
25
|
+
colorCache.set(color, result);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Validates hex color formats (#RGB, #RRGGBB, #RRGGBBAA)
|
|
30
|
+
const hexRegex = /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$|^[0-9A-Fa-f]{8}$/;
|
|
31
|
+
function parseColorUsingRegex(color) {
|
|
32
|
+
if (color.startsWith('#')) {
|
|
33
|
+
color = color.slice(1);
|
|
34
|
+
}
|
|
35
|
+
if (!hexRegex.test(color)) {
|
|
36
|
+
return null; // Invalid hex color
|
|
37
|
+
}
|
|
38
|
+
if (color.length === 3) {
|
|
39
|
+
color = color.split('').map(char => char + char).join('');
|
|
40
|
+
}
|
|
41
|
+
const r = parseInt(color.slice(0, 2), 16) / 255;
|
|
42
|
+
const g = parseInt(color.slice(2, 4), 16) / 255;
|
|
43
|
+
const b = parseInt(color.slice(4, 6), 16) / 255;
|
|
44
|
+
const a = color.length === 8 ? parseInt(color.substring(6, 8), 16) / 255 : 1;
|
|
45
|
+
return [r, g, b, a];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Parses rgb() and rgba() formats
|
|
49
|
+
const rgbaRegex = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i;
|
|
50
|
+
function parseRgbaColor(color) {
|
|
51
|
+
const match = color.match(rgbaRegex);
|
|
52
|
+
if (!match) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const r = parseInt(match[1], 10);
|
|
56
|
+
const g = parseInt(match[2], 10);
|
|
57
|
+
const b = parseInt(match[3], 10);
|
|
58
|
+
const a = match[4] !== undefined ? parseFloat(match[4]) : 1;
|
|
59
|
+
if (r > 255 || g > 255 || b > 255) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (a < 0 || a > 1) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return [r / 255, g / 255, b / 255, a];
|
|
66
|
+
}
|
|
67
|
+
let canvas;
|
|
68
|
+
function parseColorUsingCanvas(color) {
|
|
69
|
+
if (!canvas) {
|
|
70
|
+
if ('OffscreenCanvas' in window) {
|
|
71
|
+
canvas = new OffscreenCanvas(1, 1);
|
|
72
|
+
} else {
|
|
73
|
+
canvas = document.createElement('canvas');
|
|
74
|
+
canvas.width = 1;
|
|
75
|
+
canvas.height = 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const ctx = canvas.getContext('2d');
|
|
79
|
+
ctx.fillStyle = color;
|
|
80
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
81
|
+
const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data;
|
|
82
|
+
const result = [r / 255, g / 255, b / 255, a / 255];
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This hook calls the provided `onResize` callback whenever the WebGL canvas is resized.
|
|
3
|
+
* It detects size changes when the element is resized, the browser zoom updates or the device pixel ratio changes.
|
|
4
|
+
* These last two conditions aren't supported by Safari, so `onResize` won't be called in these cases on Safari.
|
|
5
|
+
* @param onResize
|
|
6
|
+
*/
|
|
7
|
+
export declare function useWebGLResizeObserver(onResize: () => void): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useWebGLResizeObserver = useWebGLResizeObserver;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _internals = require("@mui/x-charts/internals");
|
|
11
|
+
function getDevicePixelContentBoxSize(entry) {
|
|
12
|
+
// Safari does not support devicePixelContentBoxSize
|
|
13
|
+
if (entry.devicePixelContentBoxSize) {
|
|
14
|
+
return {
|
|
15
|
+
width: entry.devicePixelContentBoxSize[0].inlineSize,
|
|
16
|
+
height: entry.devicePixelContentBoxSize[0].blockSize
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// These values not correct, but they're as close as you can get in Safari
|
|
20
|
+
return {
|
|
21
|
+
width: entry.contentBoxSize[0].inlineSize * devicePixelRatio,
|
|
22
|
+
height: entry.contentBoxSize[0].blockSize * devicePixelRatio
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* This hook calls the provided `onResize` callback whenever the WebGL canvas is resized.
|
|
28
|
+
* It detects size changes when the element is resized, the browser zoom updates or the device pixel ratio changes.
|
|
29
|
+
* These last two conditions aren't supported by Safari, so `onResize` won't be called in these cases on Safari.
|
|
30
|
+
* @param onResize
|
|
31
|
+
*/
|
|
32
|
+
function useWebGLResizeObserver(onResize) {
|
|
33
|
+
const gl = (0, _internals.useWebGLContext)();
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const canvas = gl?.canvas;
|
|
36
|
+
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const observer = new ResizeObserver(entries => {
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
const {
|
|
42
|
+
width,
|
|
43
|
+
height
|
|
44
|
+
} = getDevicePixelContentBoxSize(entry);
|
|
45
|
+
canvas.width = Math.max(1, width);
|
|
46
|
+
canvas.height = Math.max(1, height);
|
|
47
|
+
|
|
48
|
+
// Update WebGL viewport
|
|
49
|
+
gl?.viewport(0, 0, width, height);
|
|
50
|
+
onResize();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
/* We use 'device-pixel-content-box' to observe the size of the canvas in device pixels, rather than CSS pixels.
|
|
55
|
+
* This ensures that we correctly handle high-DPI displays and browser zoom.
|
|
56
|
+
* However, this is not supported in Safari, which throws, so we fall back to 'content-box'.
|
|
57
|
+
* WebKit Bug: https://www2.webkit.org/show_bug.cgi?id=219005 */
|
|
58
|
+
observer.observe(canvas, {
|
|
59
|
+
box: 'device-pixel-content-box'
|
|
60
|
+
});
|
|
61
|
+
} catch {
|
|
62
|
+
observer.observe(canvas, {
|
|
63
|
+
box: 'content-box'
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return () => {
|
|
67
|
+
observer.disconnect();
|
|
68
|
+
};
|
|
69
|
+
}, [gl, gl?.canvas, onResize]);
|
|
70
|
+
}
|