@mui/x-charts-premium 9.8.0 → 9.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 (152) hide show
  1. package/BarChartPremium/BarChartPremium.d.mts +1 -1
  2. package/BarChartPremium/BarChartPremium.d.ts +1 -1
  3. package/BarChartPremium/BarChartPremium.js +14 -3
  4. package/BarChartPremium/BarChartPremium.mjs +14 -3
  5. package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.mts +2 -1
  6. package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.ts +2 -1
  7. package/BarChartPremium/RangeBar/FocusedRangeBar.d.mts +1 -1
  8. package/BarChartPremium/RangeBar/FocusedRangeBar.d.ts +1 -1
  9. package/BarChartPremium/RangeBar/seriesConfig/index.js +2 -2
  10. package/BarChartPremium/RangeBar/seriesConfig/index.mjs +2 -2
  11. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.mts +2 -3
  12. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.ts +2 -3
  13. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.js +12 -15
  14. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.mjs +11 -14
  15. package/CHANGELOG.md +119 -0
  16. package/CandlestickChart/CandlestickPlot.d.mts +2 -1
  17. package/CandlestickChart/CandlestickPlot.d.ts +2 -1
  18. package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.mts +2 -1
  19. package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.ts +2 -1
  20. package/CandlestickChart/seriesConfig/index.js +2 -2
  21. package/CandlestickChart/seriesConfig/index.mjs +2 -2
  22. package/CandlestickChart/seriesConfig/tooltipPosition.d.mts +2 -3
  23. package/CandlestickChart/seriesConfig/tooltipPosition.d.ts +2 -3
  24. package/CandlestickChart/seriesConfig/tooltipPosition.js +10 -14
  25. package/CandlestickChart/seriesConfig/tooltipPosition.mjs +10 -14
  26. package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.mts +1 -1
  27. package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.ts +1 -1
  28. package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
  29. package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
  30. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.mts +1 -1
  31. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.ts +1 -1
  32. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.js +2 -2
  33. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.mjs +2 -2
  34. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.mts +4 -3
  35. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.ts +4 -3
  36. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.js +2 -1
  37. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.mjs +2 -1
  38. package/ChartsGeoDataProviderPremium/index.d.mts +2 -1
  39. package/ChartsGeoDataProviderPremium/index.d.ts +2 -1
  40. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.mts +2 -1
  41. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.ts +2 -1
  42. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +2 -2
  43. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +2 -2
  44. package/ChartsRenderer/components/PaletteOption.d.mts +1 -1
  45. package/ChartsRenderer/components/PaletteOption.d.ts +1 -1
  46. package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.mts +2 -1
  47. package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.ts +2 -1
  48. package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.mts +1 -1
  49. package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.ts +1 -1
  50. package/HeatmapPremium/HeatmapPlotPremium.d.mts +1 -1
  51. package/HeatmapPremium/HeatmapPlotPremium.d.ts +1 -1
  52. package/Map/FocusedMapShape.d.mts +2 -1
  53. package/Map/FocusedMapShape.d.ts +2 -1
  54. package/Map/GeoDataPlot.d.mts +1 -1
  55. package/Map/GeoDataPlot.d.ts +1 -1
  56. package/Map/Graticule.d.mts +1 -1
  57. package/Map/Graticule.d.ts +1 -1
  58. package/Map/MapImagePlot.d.mts +1 -1
  59. package/Map/MapImagePlot.d.ts +1 -1
  60. package/Map/MapShape.d.mts +1 -1
  61. package/Map/MapShape.d.ts +1 -1
  62. package/Map/MapShapePlot.d.mts +1 -1
  63. package/Map/MapShapePlot.d.ts +1 -1
  64. package/Map/index.d.mts +1 -3
  65. package/Map/index.d.ts +1 -3
  66. package/Map/seriesConfig/tooltipPosition.d.mts +1 -1
  67. package/Map/seriesConfig/tooltipPosition.d.ts +1 -1
  68. package/Map/seriesConfig/tooltipPosition.js +2 -8
  69. package/Map/seriesConfig/tooltipPosition.mjs +3 -9
  70. package/RadialBarChart/RadialBarElement.d.mts +1 -1
  71. package/RadialBarChart/RadialBarElement.d.ts +1 -1
  72. package/RadialBarChart/seriesConfig/index.js +2 -2
  73. package/RadialBarChart/seriesConfig/index.mjs +2 -2
  74. package/RadialBarChart/seriesConfig/tooltipPosition.d.mts +2 -3
  75. package/RadialBarChart/seriesConfig/tooltipPosition.d.ts +2 -3
  76. package/RadialBarChart/seriesConfig/tooltipPosition.js +4 -6
  77. package/RadialBarChart/seriesConfig/tooltipPosition.mjs +2 -5
  78. package/RadialLineChart/RadialArea.d.mts +2 -1
  79. package/RadialLineChart/RadialArea.d.ts +2 -1
  80. package/RadialLineChart/RadialAreaPlot.d.mts +1 -1
  81. package/RadialLineChart/RadialAreaPlot.d.ts +1 -1
  82. package/RadialLineChart/RadialLine.d.mts +1 -1
  83. package/RadialLineChart/RadialLine.d.ts +1 -1
  84. package/RadialLineChart/RadialLineHighlightElement.d.mts +1 -1
  85. package/RadialLineChart/RadialLineHighlightElement.d.ts +1 -1
  86. package/RadialLineChart/RadialLineHighlightPlot.d.mts +1 -1
  87. package/RadialLineChart/RadialLineHighlightPlot.d.ts +1 -1
  88. package/RadialLineChart/RadialLinePlot.d.mts +1 -1
  89. package/RadialLineChart/RadialLinePlot.d.ts +1 -1
  90. package/RadialLineChart/RadialMarkPlot.d.mts +1 -1
  91. package/RadialLineChart/RadialMarkPlot.d.ts +1 -1
  92. package/RadialLineChart/seriesConfig/index.js +2 -2
  93. package/RadialLineChart/seriesConfig/index.mjs +2 -2
  94. package/RadialLineChart/seriesConfig/tooltipPosition.d.mts +2 -3
  95. package/RadialLineChart/seriesConfig/tooltipPosition.d.ts +2 -3
  96. package/RadialLineChart/seriesConfig/tooltipPosition.js +4 -6
  97. package/RadialLineChart/seriesConfig/tooltipPosition.mjs +2 -5
  98. package/ScatterChartPremium/ScatterPlotPremium.d.mts +2 -1
  99. package/ScatterChartPremium/ScatterPlotPremium.d.ts +2 -1
  100. package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.mts +2 -1
  101. package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.ts +2 -1
  102. package/index.js +1 -1
  103. package/index.mjs +1 -1
  104. package/internals/plugins/useGeoProjection/factories.d.mts +3 -0
  105. package/internals/plugins/useGeoProjection/factories.d.ts +3 -0
  106. package/internals/plugins/useGeoProjection/factories.js +29 -0
  107. package/internals/plugins/useGeoProjection/factories.mjs +23 -0
  108. package/internals/plugins/useGeoProjection/projection.utils.d.mts +17 -0
  109. package/internals/plugins/useGeoProjection/projection.utils.d.ts +17 -0
  110. package/internals/plugins/useGeoProjection/projection.utils.js +67 -0
  111. package/internals/plugins/useGeoProjection/projection.utils.mjs +59 -0
  112. package/internals/plugins/useGeoProjection/useGeoProjection.js +7 -40
  113. package/internals/plugins/useGeoProjection/useGeoProjection.mjs +7 -40
  114. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.mts +47 -11
  115. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.ts +47 -11
  116. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.js +118 -8
  117. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.mjs +117 -8
  118. package/internals/plugins/useGeoProjection/useGeoProjection.types.d.mts +63 -2
  119. package/internals/plugins/useGeoProjection/useGeoProjection.types.d.ts +63 -2
  120. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.mts +11 -0
  121. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.ts +11 -0
  122. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.js +65 -0
  123. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.mjs +58 -0
  124. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.mts +13 -0
  125. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.ts +13 -0
  126. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.js +62 -0
  127. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.mjs +56 -0
  128. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.mts +13 -0
  129. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.ts +13 -0
  130. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.js +64 -0
  131. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.mjs +58 -0
  132. package/internals/plugins/useGeoProjectionZoom/index.d.mts +2 -0
  133. package/internals/plugins/useGeoProjectionZoom/index.d.ts +2 -0
  134. package/internals/plugins/useGeoProjectionZoom/index.js +12 -0
  135. package/internals/plugins/useGeoProjectionZoom/index.mjs +1 -0
  136. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.mts +31 -0
  137. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.ts +31 -0
  138. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.js +187 -0
  139. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.mjs +177 -0
  140. package/internals/plugins/useGeoProjectionZoom/rotationMath.d.mts +23 -0
  141. package/internals/plugins/useGeoProjectionZoom/rotationMath.d.ts +23 -0
  142. package/internals/plugins/useGeoProjectionZoom/rotationMath.js +190 -0
  143. package/internals/plugins/useGeoProjectionZoom/rotationMath.mjs +182 -0
  144. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.mts +3 -0
  145. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.ts +3 -0
  146. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.js +174 -0
  147. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.mjs +166 -0
  148. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.mts +152 -0
  149. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.ts +152 -0
  150. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.js +5 -0
  151. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.mjs +1 -0
  152. package/package.json +6 -6
@@ -0,0 +1,65 @@
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.usePanOnDrag = void 0;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _internals = require("@mui/x-charts-pro/internals");
11
+ var _useGeoProjection = require("../../useGeoProjection");
12
+ var _mapZoom = require("../mapZoom.utils");
13
+ const usePanOnDrag = ({
14
+ store,
15
+ instance
16
+ }, applyView, options) => {
17
+ const {
18
+ enabled,
19
+ rotationAllowed,
20
+ translationAllowed,
21
+ maxEmptySpace
22
+ } = options;
23
+ const projection = store.use(_useGeoProjection.selectorChartProjection);
24
+ const geoPoint = React.useRef(null);
25
+ const dragStartPoint = React.useRef(null);
26
+ const dragCurrentPoint = React.useRef(null);
27
+ (0, _internals.useDragGesture)(instance, {
28
+ enabled,
29
+ onPanStart: event => {
30
+ if (!projection || !projection.invert) {
31
+ return;
32
+ }
33
+ geoPoint.current = projection.invert([event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY]);
34
+ dragStartPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
35
+ dragCurrentPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
36
+ },
37
+ onPanEnd: () => {
38
+ geoPoint.current = null;
39
+ dragStartPoint.current = null;
40
+ dragCurrentPoint.current = null;
41
+ },
42
+ onPan: delta => {
43
+ if (!projection || dragCurrentPoint.current === null || geoPoint.current === null) {
44
+ return;
45
+ }
46
+ dragCurrentPoint.current = [dragCurrentPoint.current[0] + delta.x, dragCurrentPoint.current[1] + delta.y];
47
+ const nextRotation = (0, _mapZoom.getRotation)(projection, geoPoint.current, dragCurrentPoint.current, 1, rotationAllowed);
48
+ const rotate = projection.rotate?.();
49
+ if (nextRotation) {
50
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
51
+ }
52
+ const translation = (0, _mapZoom.getTranslation)(store, projection, geoPoint.current, dragCurrentPoint.current, translationAllowed, maxEmptySpace);
53
+ projection.rotate?.(rotate);
54
+ if (nextRotation || translation) {
55
+ applyView({
56
+ zoomLevel: store.state.geoProjectionZoom.zoomLevel ?? 1,
57
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
58
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
59
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
60
+ });
61
+ }
62
+ }
63
+ });
64
+ };
65
+ exports.usePanOnDrag = usePanOnDrag;
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { useDragGesture } from '@mui/x-charts-pro/internals';
5
+ import { selectorChartProjection } from "../../useGeoProjection/index.mjs";
6
+ import { getRotation, getTranslation } from "../mapZoom.utils.mjs";
7
+ export const usePanOnDrag = ({
8
+ store,
9
+ instance
10
+ }, applyView, options) => {
11
+ const {
12
+ enabled,
13
+ rotationAllowed,
14
+ translationAllowed,
15
+ maxEmptySpace
16
+ } = options;
17
+ const projection = store.use(selectorChartProjection);
18
+ const geoPoint = React.useRef(null);
19
+ const dragStartPoint = React.useRef(null);
20
+ const dragCurrentPoint = React.useRef(null);
21
+ useDragGesture(instance, {
22
+ enabled,
23
+ onPanStart: event => {
24
+ if (!projection || !projection.invert) {
25
+ return;
26
+ }
27
+ geoPoint.current = projection.invert([event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY]);
28
+ dragStartPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
29
+ dragCurrentPoint.current = [event.detail.srcEvent.offsetX, event.detail.srcEvent.offsetY];
30
+ },
31
+ onPanEnd: () => {
32
+ geoPoint.current = null;
33
+ dragStartPoint.current = null;
34
+ dragCurrentPoint.current = null;
35
+ },
36
+ onPan: delta => {
37
+ if (!projection || dragCurrentPoint.current === null || geoPoint.current === null) {
38
+ return;
39
+ }
40
+ dragCurrentPoint.current = [dragCurrentPoint.current[0] + delta.x, dragCurrentPoint.current[1] + delta.y];
41
+ const nextRotation = getRotation(projection, geoPoint.current, dragCurrentPoint.current, 1, rotationAllowed);
42
+ const rotate = projection.rotate?.();
43
+ if (nextRotation) {
44
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
45
+ }
46
+ const translation = getTranslation(store, projection, geoPoint.current, dragCurrentPoint.current, translationAllowed, maxEmptySpace);
47
+ projection.rotate?.(rotate);
48
+ if (nextRotation || translation) {
49
+ applyView({
50
+ zoomLevel: store.state.geoProjectionZoom.zoomLevel ?? 1,
51
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
52
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
53
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
54
+ });
55
+ }
56
+ }
57
+ });
58
+ };
@@ -0,0 +1,13 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.mjs";
3
+ export declare const useZoomOnPinch: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ minZoomLevel: number;
12
+ maxZoomLevel: number;
13
+ }) => void;
@@ -0,0 +1,13 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.js";
3
+ export declare const useZoomOnPinch: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ minZoomLevel: number;
12
+ maxZoomLevel: number;
13
+ }) => void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useZoomOnPinch = void 0;
8
+ var _internals = require("@mui/x-charts-pro/internals");
9
+ var _useGeoProjection = require("../../useGeoProjection");
10
+ var _mapZoom = require("../mapZoom.utils");
11
+ const useZoomOnPinch = ({
12
+ store,
13
+ instance
14
+ }, applyView, options) => {
15
+ const {
16
+ enabled,
17
+ rotationAllowed,
18
+ translationAllowed,
19
+ maxEmptySpace
20
+ } = options;
21
+ const projection = store.use(_useGeoProjection.selectorChartProjection);
22
+ const clampZoomLevel = zoomLevel => Math.max(options.minZoomLevel, Math.min(options.maxZoomLevel, zoomLevel));
23
+ (0, _internals.usePinchGesture)(instance, {
24
+ enabled,
25
+ onPinch: (point, deltaScale) => {
26
+ if (!projection || !projection.invert) {
27
+ return;
28
+ }
29
+
30
+ // Same clamp-then-derive-factor flow as the wheel, so pinch obeys the identical bounds.
31
+ const currentZoom = store.state.geoProjectionZoom.zoomLevel ?? 1;
32
+ const nextZoom = clampZoomLevel(currentZoom * (1 + deltaScale));
33
+ const factor = nextZoom / currentZoom;
34
+ if (factor === 1) {
35
+ return;
36
+ }
37
+ const geoPoint = projection.invert([point.x, point.y]);
38
+ if (!geoPoint) {
39
+ return;
40
+ }
41
+ const nextRotation = (0, _mapZoom.getRotation)(projection, geoPoint, [point.x, point.y], factor, rotationAllowed);
42
+ const scale = projection.scale();
43
+ const rotate = projection.rotate?.();
44
+ if (nextRotation) {
45
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
46
+ }
47
+ projection.scale(scale * factor);
48
+ const translation = (0, _mapZoom.getTranslation)(store, projection, geoPoint, [point.x, point.y], translationAllowed, maxEmptySpace, store.state.geoProjectionZoom.translation ?? [0, 0]);
49
+ projection.rotate?.(rotate);
50
+ projection.scale(scale);
51
+ if (nextRotation || translation) {
52
+ applyView({
53
+ zoomLevel: nextZoom,
54
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
55
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
56
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
57
+ });
58
+ }
59
+ }
60
+ });
61
+ };
62
+ exports.useZoomOnPinch = useZoomOnPinch;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+
3
+ import { usePinchGesture } from '@mui/x-charts-pro/internals';
4
+ import { selectorChartProjection } from "../../useGeoProjection/index.mjs";
5
+ import { getRotation, getTranslation } from "../mapZoom.utils.mjs";
6
+ export const useZoomOnPinch = ({
7
+ store,
8
+ instance
9
+ }, applyView, options) => {
10
+ const {
11
+ enabled,
12
+ rotationAllowed,
13
+ translationAllowed,
14
+ maxEmptySpace
15
+ } = options;
16
+ const projection = store.use(selectorChartProjection);
17
+ const clampZoomLevel = zoomLevel => Math.max(options.minZoomLevel, Math.min(options.maxZoomLevel, zoomLevel));
18
+ usePinchGesture(instance, {
19
+ enabled,
20
+ onPinch: (point, deltaScale) => {
21
+ if (!projection || !projection.invert) {
22
+ return;
23
+ }
24
+
25
+ // Same clamp-then-derive-factor flow as the wheel, so pinch obeys the identical bounds.
26
+ const currentZoom = store.state.geoProjectionZoom.zoomLevel ?? 1;
27
+ const nextZoom = clampZoomLevel(currentZoom * (1 + deltaScale));
28
+ const factor = nextZoom / currentZoom;
29
+ if (factor === 1) {
30
+ return;
31
+ }
32
+ const geoPoint = projection.invert([point.x, point.y]);
33
+ if (!geoPoint) {
34
+ return;
35
+ }
36
+ const nextRotation = getRotation(projection, geoPoint, [point.x, point.y], factor, rotationAllowed);
37
+ const scale = projection.scale();
38
+ const rotate = projection.rotate?.();
39
+ if (nextRotation) {
40
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
41
+ }
42
+ projection.scale(scale * factor);
43
+ const translation = getTranslation(store, projection, geoPoint, [point.x, point.y], translationAllowed, maxEmptySpace, store.state.geoProjectionZoom.translation ?? [0, 0]);
44
+ projection.rotate?.(rotate);
45
+ projection.scale(scale);
46
+ if (nextRotation || translation) {
47
+ applyView({
48
+ zoomLevel: nextZoom,
49
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
50
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
51
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
52
+ });
53
+ }
54
+ }
55
+ });
56
+ };
@@ -0,0 +1,13 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.mjs";
3
+ export declare const useZoomOnWheel: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ minZoomLevel: number;
12
+ maxZoomLevel: number;
13
+ }) => void;
@@ -0,0 +1,13 @@
1
+ import type { ChartPlugin } from '@mui/x-charts/internals';
2
+ import type { MapRotationAxis, MapTranslationAxis, MapZoomView, UseGeoProjectionZoomSignature } from "../useGeoProjectionZoom.types.js";
3
+ export declare const useZoomOnWheel: ({
4
+ store,
5
+ instance
6
+ }: Pick<Parameters<ChartPlugin<UseGeoProjectionZoomSignature>>[0], "store" | "instance">, applyView: (newView: MapZoomView) => void, options: {
7
+ enabled: boolean;
8
+ rotationAllowed: MapRotationAxis;
9
+ translationAllowed: MapTranslationAxis;
10
+ maxEmptySpace: number;
11
+ minZoomLevel: number;
12
+ maxZoomLevel: number;
13
+ }) => void;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useZoomOnWheel = void 0;
8
+ var _internals = require("@mui/x-charts-pro/internals");
9
+ var _useGeoProjection = require("../../useGeoProjection");
10
+ var _mapZoom = require("../mapZoom.utils");
11
+ const useZoomOnWheel = ({
12
+ store,
13
+ instance
14
+ }, applyView, options) => {
15
+ const {
16
+ enabled,
17
+ rotationAllowed,
18
+ translationAllowed,
19
+ maxEmptySpace
20
+ } = options;
21
+ const projection = store.use(_useGeoProjection.selectorChartProjection);
22
+ const clampZoomLevel = zoomLevel => Math.max(options.minZoomLevel, Math.min(options.maxZoomLevel, zoomLevel));
23
+ (0, _internals.useWheelGesture)(instance, {
24
+ enabled,
25
+ onWheel: (point, event) => {
26
+ if (!projection || !projection.invert) {
27
+ return;
28
+ }
29
+
30
+ // Clamp the target zoom first, then derive the factor actually applied. At the bounds the
31
+ // factor collapses to `1`, so wheeling further neither scales nor shifts the map.
32
+ const currentZoom = store.state.geoProjectionZoom.zoomLevel ?? 1;
33
+ const rawFactor = event.deltaY < 0 ? _mapZoom.WHEEL_ZOOM_STEP : 1 / _mapZoom.WHEEL_ZOOM_STEP;
34
+ const nextZoom = clampZoomLevel(currentZoom * rawFactor);
35
+ const factor = nextZoom / currentZoom;
36
+ if (factor === 1) {
37
+ return;
38
+ }
39
+ const geoPoint = projection.invert([point.x, point.y]);
40
+ if (!geoPoint) {
41
+ return;
42
+ }
43
+ const rotate = projection.rotate?.();
44
+ const scale = projection.scale();
45
+ const nextRotation = (0, _mapZoom.getRotation)(projection, geoPoint, [point.x, point.y], factor, rotationAllowed);
46
+ if (nextRotation) {
47
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
48
+ }
49
+ projection.scale(scale * factor);
50
+ const translation = (0, _mapZoom.getTranslation)(store, projection, geoPoint, [point.x, point.y], translationAllowed, maxEmptySpace);
51
+ projection.rotate?.(rotate);
52
+ projection.scale(scale);
53
+ if (nextRotation || translation) {
54
+ applyView({
55
+ zoomLevel: nextZoom,
56
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
57
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
58
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
59
+ });
60
+ }
61
+ }
62
+ });
63
+ };
64
+ exports.useZoomOnWheel = useZoomOnWheel;
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+
3
+ import { useWheelGesture } from '@mui/x-charts-pro/internals';
4
+ import { selectorChartProjection } from "../../useGeoProjection/index.mjs";
5
+ import { getRotation, getTranslation, WHEEL_ZOOM_STEP } from "../mapZoom.utils.mjs";
6
+ export const useZoomOnWheel = ({
7
+ store,
8
+ instance
9
+ }, applyView, options) => {
10
+ const {
11
+ enabled,
12
+ rotationAllowed,
13
+ translationAllowed,
14
+ maxEmptySpace
15
+ } = options;
16
+ const projection = store.use(selectorChartProjection);
17
+ const clampZoomLevel = zoomLevel => Math.max(options.minZoomLevel, Math.min(options.maxZoomLevel, zoomLevel));
18
+ useWheelGesture(instance, {
19
+ enabled,
20
+ onWheel: (point, event) => {
21
+ if (!projection || !projection.invert) {
22
+ return;
23
+ }
24
+
25
+ // Clamp the target zoom first, then derive the factor actually applied. At the bounds the
26
+ // factor collapses to `1`, so wheeling further neither scales nor shifts the map.
27
+ const currentZoom = store.state.geoProjectionZoom.zoomLevel ?? 1;
28
+ const rawFactor = event.deltaY < 0 ? WHEEL_ZOOM_STEP : 1 / WHEEL_ZOOM_STEP;
29
+ const nextZoom = clampZoomLevel(currentZoom * rawFactor);
30
+ const factor = nextZoom / currentZoom;
31
+ if (factor === 1) {
32
+ return;
33
+ }
34
+ const geoPoint = projection.invert([point.x, point.y]);
35
+ if (!geoPoint) {
36
+ return;
37
+ }
38
+ const rotate = projection.rotate?.();
39
+ const scale = projection.scale();
40
+ const nextRotation = getRotation(projection, geoPoint, [point.x, point.y], factor, rotationAllowed);
41
+ if (nextRotation) {
42
+ projection.rotate?.([-nextRotation[0], -nextRotation[1], nextRotation[2]]);
43
+ }
44
+ projection.scale(scale * factor);
45
+ const translation = getTranslation(store, projection, geoPoint, [point.x, point.y], translationAllowed, maxEmptySpace);
46
+ projection.rotate?.(rotate);
47
+ projection.scale(scale);
48
+ if (nextRotation || translation) {
49
+ applyView({
50
+ zoomLevel: nextZoom,
51
+ center: nextRotation ? [nextRotation[0], nextRotation[1]] : store.state.geoProjectionZoom.center ?? [0, 0],
52
+ translation: translation ?? store.state.geoProjectionZoom.translation ?? [0, 0],
53
+ roll: nextRotation ? nextRotation[2] : store.state.geoProjectionZoom.roll ?? 0
54
+ });
55
+ }
56
+ }
57
+ });
58
+ };
@@ -0,0 +1,2 @@
1
+ export { useGeoProjectionZoom } from "./useGeoProjectionZoom.mjs";
2
+ export type { UseGeoProjectionZoomSignature, MapZoomView } from "./useGeoProjectionZoom.types.mjs";
@@ -0,0 +1,2 @@
1
+ export { useGeoProjectionZoom } from "./useGeoProjectionZoom.js";
2
+ export type { UseGeoProjectionZoomSignature, MapZoomView } from "./useGeoProjectionZoom.types.js";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useGeoProjectionZoom", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _useGeoProjectionZoom.useGeoProjectionZoom;
10
+ }
11
+ });
12
+ var _useGeoProjectionZoom = require("./useGeoProjectionZoom");
@@ -0,0 +1 @@
1
+ export { useGeoProjectionZoom } from "./useGeoProjectionZoom.mjs";
@@ -0,0 +1,31 @@
1
+ import type { GeoProjection } from '@mui/x-charts-vendor/d3-geo';
2
+ import type { ChartUsedStore } from '@mui/x-charts/internals';
3
+ import type { MapRotationAxis, MapTranslationAxis } from "./useGeoProjectionZoom.types.mjs";
4
+ import type { GeoProjectionInput } from "../useGeoProjection/index.mjs";
5
+ /** Multiplicative zoom step applied per wheel tick. */
6
+ export declare const WHEEL_ZOOM_STEP = 1.1;
7
+ /** Multiplicative zoom step applied per `zoomIn`/`zoomOut` call. */
8
+ export declare const BUTTON_ZOOM_STEP = 1.3;
9
+ type ProjectionFamily = 'azimuthal' | 'conic' | 'cylindrical' | 'albersUsa';
10
+ export declare function getProjectionFamily(projection: GeoProjectionInput | null): ProjectionFamily;
11
+ export declare function getDefaultMapInteraction(projection: GeoProjectionInput | null): {
12
+ rotationAllowed: MapRotationAxis;
13
+ translationAllowed: MapTranslationAxis;
14
+ };
15
+ /**
16
+ * For a given projection, apply a zoom factor to the scale and return the rotation that renders
17
+ * `geoPoint` at the `to` pixel coordinates, as `[longitude, latitude, roll]` (the view `center` plus
18
+ * the third d3 rotation angle).
19
+ *
20
+ * - With `rotationAllowed: 'both+roll'`, the roll is free to move but kept as stable as possible: the
21
+ * shortest-arc rotation dragging `geoPoint` onto `to` is composed with the current orientation, so
22
+ * the roll only drifts as much as strictly required.
23
+ * - With `rotationAllowed: 'both'`, both longitude and latitude are free but the roll is kept fixed at
24
+ * the current value.
25
+ * - With `rotationAllowed: 'longitude'`, only the longitude is solved; the latitude and roll are kept fixed.
26
+ * - With `rotationAllowed: 'none'`, `null` is returned so the caller keeps the current rotation.
27
+ */
28
+ export declare function getRotation(projection: GeoProjection, geoPoint: [number, number], to: [number, number], zoomFactor?: number, rotationAllowed?: MapRotationAxis): [number, number, number] | null;
29
+ export declare function clampTranslationAxis(value: number, init: number, boundingBox0: number, boundingBox1: number, areaStart: number, areaEnd: number, gap: number): number;
30
+ export declare function getTranslation(store: ChartUsedStore<any>, projection: GeoProjection, geoPoint: [number, number], to: [number, number], translationAllowed?: MapTranslationAxis, maxEmptySpace?: number, currentTranslation?: [number, number]): [number, number] | null;
31
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { GeoProjection } from '@mui/x-charts-vendor/d3-geo';
2
+ import type { ChartUsedStore } from '@mui/x-charts/internals';
3
+ import type { MapRotationAxis, MapTranslationAxis } from "./useGeoProjectionZoom.types.js";
4
+ import type { GeoProjectionInput } from "../useGeoProjection/index.js";
5
+ /** Multiplicative zoom step applied per wheel tick. */
6
+ export declare const WHEEL_ZOOM_STEP = 1.1;
7
+ /** Multiplicative zoom step applied per `zoomIn`/`zoomOut` call. */
8
+ export declare const BUTTON_ZOOM_STEP = 1.3;
9
+ type ProjectionFamily = 'azimuthal' | 'conic' | 'cylindrical' | 'albersUsa';
10
+ export declare function getProjectionFamily(projection: GeoProjectionInput | null): ProjectionFamily;
11
+ export declare function getDefaultMapInteraction(projection: GeoProjectionInput | null): {
12
+ rotationAllowed: MapRotationAxis;
13
+ translationAllowed: MapTranslationAxis;
14
+ };
15
+ /**
16
+ * For a given projection, apply a zoom factor to the scale and return the rotation that renders
17
+ * `geoPoint` at the `to` pixel coordinates, as `[longitude, latitude, roll]` (the view `center` plus
18
+ * the third d3 rotation angle).
19
+ *
20
+ * - With `rotationAllowed: 'both+roll'`, the roll is free to move but kept as stable as possible: the
21
+ * shortest-arc rotation dragging `geoPoint` onto `to` is composed with the current orientation, so
22
+ * the roll only drifts as much as strictly required.
23
+ * - With `rotationAllowed: 'both'`, both longitude and latitude are free but the roll is kept fixed at
24
+ * the current value.
25
+ * - With `rotationAllowed: 'longitude'`, only the longitude is solved; the latitude and roll are kept fixed.
26
+ * - With `rotationAllowed: 'none'`, `null` is returned so the caller keeps the current rotation.
27
+ */
28
+ export declare function getRotation(projection: GeoProjection, geoPoint: [number, number], to: [number, number], zoomFactor?: number, rotationAllowed?: MapRotationAxis): [number, number, number] | null;
29
+ export declare function clampTranslationAxis(value: number, init: number, boundingBox0: number, boundingBox1: number, areaStart: number, areaEnd: number, gap: number): number;
30
+ export declare function getTranslation(store: ChartUsedStore<any>, projection: GeoProjection, geoPoint: [number, number], to: [number, number], translationAllowed?: MapTranslationAxis, maxEmptySpace?: number, currentTranslation?: [number, number]): [number, number] | null;
31
+ export {};