@mui/x-charts-pro 8.14.0 → 8.15.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 (88) hide show
  1. package/BarChartPro/BarChartPro.js +8 -0
  2. package/BarChartPro/BarChartPro.plugins.d.ts +2 -2
  3. package/BarChartPro/BarChartPro.plugins.js +1 -1
  4. package/CHANGELOG.md +202 -0
  5. package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  6. package/ChartsBrushOverlay/index.d.ts +1 -0
  7. package/ChartsBrushOverlay/index.js +16 -0
  8. package/LineChartPro/LineChartPro.js +8 -0
  9. package/LineChartPro/LineChartPro.plugins.d.ts +2 -2
  10. package/LineChartPro/LineChartPro.plugins.js +1 -1
  11. package/SankeyChart/SankeyChart.d.ts +1 -1
  12. package/SankeyChart/SankeyChart.js +30 -0
  13. package/SankeyChart/SankeyChart.plugins.d.ts +3 -2
  14. package/SankeyChart/SankeyChart.plugins.js +2 -1
  15. package/SankeyChart/SankeyLinkElement.d.ts +1 -1
  16. package/SankeyChart/SankeyLinkElement.js +15 -2
  17. package/SankeyChart/SankeyNodeElement.d.ts +1 -1
  18. package/SankeyChart/SankeyNodeElement.js +16 -1
  19. package/SankeyChart/SankeyPlot.js +13 -1
  20. package/SankeyChart/plugins/index.d.ts +3 -0
  21. package/SankeyChart/plugins/index.js +49 -0
  22. package/SankeyChart/plugins/useSankeyHighlight.d.ts +7 -0
  23. package/SankeyChart/plugins/useSankeyHighlight.js +76 -0
  24. package/SankeyChart/plugins/useSankeyHighlight.selectors.d.ts +68 -0
  25. package/SankeyChart/plugins/useSankeyHighlight.selectors.js +126 -0
  26. package/SankeyChart/plugins/useSankeyHighlight.types.d.ts +55 -0
  27. package/SankeyChart/plugins/useSankeyHighlight.types.js +5 -0
  28. package/SankeyChart/sankey.highlight.types.d.ts +42 -0
  29. package/SankeyChart/sankey.highlight.types.js +6 -0
  30. package/SankeyChart/sankey.types.d.ts +3 -2
  31. package/SankeyChart/sankeyClasses.d.ts +1 -1
  32. package/SankeyChart/useSankeyChartProps.js +5 -5
  33. package/ScatterChartPro/ScatterChartPro.js +8 -0
  34. package/ScatterChartPro/ScatterChartPro.plugins.d.ts +2 -2
  35. package/ScatterChartPro/ScatterChartPro.plugins.js +1 -1
  36. package/esm/BarChartPro/BarChartPro.js +8 -0
  37. package/esm/BarChartPro/BarChartPro.plugins.d.ts +2 -2
  38. package/esm/BarChartPro/BarChartPro.plugins.js +2 -2
  39. package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
  40. package/esm/ChartsBrushOverlay/index.d.ts +1 -0
  41. package/esm/ChartsBrushOverlay/index.js +2 -0
  42. package/esm/LineChartPro/LineChartPro.js +8 -0
  43. package/esm/LineChartPro/LineChartPro.plugins.d.ts +2 -2
  44. package/esm/LineChartPro/LineChartPro.plugins.js +2 -2
  45. package/esm/SankeyChart/SankeyChart.d.ts +1 -1
  46. package/esm/SankeyChart/SankeyChart.js +30 -0
  47. package/esm/SankeyChart/SankeyChart.plugins.d.ts +3 -2
  48. package/esm/SankeyChart/SankeyChart.plugins.js +3 -4
  49. package/esm/SankeyChart/SankeyLinkElement.d.ts +1 -1
  50. package/esm/SankeyChart/SankeyLinkElement.js +16 -3
  51. package/esm/SankeyChart/SankeyNodeElement.d.ts +1 -1
  52. package/esm/SankeyChart/SankeyNodeElement.js +17 -2
  53. package/esm/SankeyChart/SankeyPlot.js +15 -3
  54. package/esm/SankeyChart/plugins/index.d.ts +3 -0
  55. package/esm/SankeyChart/plugins/index.js +3 -0
  56. package/esm/SankeyChart/plugins/useSankeyHighlight.d.ts +7 -0
  57. package/esm/SankeyChart/plugins/useSankeyHighlight.js +68 -0
  58. package/esm/SankeyChart/plugins/useSankeyHighlight.selectors.d.ts +68 -0
  59. package/esm/SankeyChart/plugins/useSankeyHighlight.selectors.js +120 -0
  60. package/esm/SankeyChart/plugins/useSankeyHighlight.types.d.ts +55 -0
  61. package/esm/SankeyChart/plugins/useSankeyHighlight.types.js +1 -0
  62. package/esm/SankeyChart/sankey.highlight.types.d.ts +42 -0
  63. package/esm/SankeyChart/sankey.highlight.types.js +3 -0
  64. package/esm/SankeyChart/sankey.types.d.ts +3 -2
  65. package/esm/SankeyChart/sankeyClasses.d.ts +1 -1
  66. package/esm/SankeyChart/useSankeyChartProps.js +5 -5
  67. package/esm/ScatterChartPro/ScatterChartPro.js +8 -0
  68. package/esm/ScatterChartPro/ScatterChartPro.plugins.d.ts +2 -2
  69. package/esm/ScatterChartPro/ScatterChartPro.plugins.js +2 -2
  70. package/esm/index.js +1 -1
  71. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +1 -1
  72. package/esm/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.js +1 -1
  73. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.d.ts +2 -2
  74. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +8 -5
  75. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +2 -2
  76. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +2 -2
  77. package/esm/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +2 -2
  78. package/esm/tests/constants.js +1 -0
  79. package/index.js +1 -1
  80. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +1 -1
  81. package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.js +1 -1
  82. package/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.d.ts +2 -2
  83. package/internals/plugins/useChartProZoom/gestureHooks/useZoom.utils.js +8 -5
  84. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +2 -2
  85. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnTapAndDrag.js +2 -2
  86. package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +2 -2
  87. package/package.json +5 -5
  88. package/tests/constants.js +7 -0
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useSankeyHighlight = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _useAssertModelConsistency = require("@mui/x-internals/useAssertModelConsistency");
10
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
11
+ var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
12
+ var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
13
+ /**
14
+ * Custom highlight plugin for Sankey charts that uses SankeyItemIdentifier
15
+ * instead of the standard HighlightItemData.
16
+ */
17
+ const useSankeyHighlight = ({
18
+ store,
19
+ params
20
+ }) => {
21
+ (0, _useAssertModelConsistency.useAssertModelConsistency)({
22
+ warningPrefix: 'MUI X Charts',
23
+ componentName: 'SankeyChart',
24
+ propName: 'highlightedItem',
25
+ controlled: params.highlightedItem,
26
+ defaultValue: null
27
+ });
28
+ (0, _useEnhancedEffect.default)(() => {
29
+ store.update(prevState => prevState.highlight.item === params.highlightedItem ? prevState : (0, _extends2.default)({}, prevState, {
30
+ highlight: (0, _extends2.default)({}, prevState.highlight, {
31
+ item: params.highlightedItem
32
+ })
33
+ }));
34
+ }, [store, params.highlightedItem]);
35
+ const clearHighlight = (0, _useEventCallback.default)(() => {
36
+ params.onHighlightChange?.(null);
37
+ store.update(prev => (0, _extends2.default)({}, prev, {
38
+ highlight: {
39
+ item: null
40
+ }
41
+ }));
42
+ });
43
+ const setHighlight = (0, _useEventCallback.default)(newItem => {
44
+ const prevItem = store.getSnapshot().highlight.item;
45
+ if ((0, _fastObjectShallowCompare.fastObjectShallowCompare)(prevItem, newItem)) {
46
+ return;
47
+ }
48
+ params.onHighlightChange?.(newItem);
49
+ store.update(prev => (0, _extends2.default)({}, prev, {
50
+ highlight: {
51
+ item: newItem
52
+ }
53
+ }));
54
+ });
55
+ return {
56
+ instance: {
57
+ clearHighlight,
58
+ setHighlight
59
+ }
60
+ };
61
+ };
62
+ exports.useSankeyHighlight = useSankeyHighlight;
63
+ useSankeyHighlight.getDefaultizedParams = ({
64
+ params
65
+ }) => (0, _extends2.default)({}, params, {
66
+ highlightedItem: params.highlightedItem ?? null
67
+ });
68
+ useSankeyHighlight.getInitialState = params => ({
69
+ highlight: {
70
+ item: params.highlightedItem
71
+ }
72
+ });
73
+ useSankeyHighlight.params = {
74
+ highlightedItem: true,
75
+ onHighlightChange: true
76
+ };
@@ -0,0 +1,68 @@
1
+ import type { SankeyLayoutLink, SankeyLayoutNode } from "../sankey.types.js";
2
+ import type { SankeyLinkFade, SankeyLinkHighlight, SankeyNodeFade, SankeyNodeHighlight } from "../sankey.highlight.types.js";
3
+ /**
4
+ * Get the node highlight configuration from the Sankey series.
5
+ * Defaults to 'nodes' if not specified.
6
+ */
7
+ export declare const selectorNodeHighlightConfig: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<{}> & {
8
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
9
+ } & {
10
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
11
+ }, SankeyNodeHighlight, any[]>;
12
+ /**
13
+ * Get the node fade configuration from the Sankey series.
14
+ * Defaults to 'none' if not specified.
15
+ */
16
+ export declare const selectorNodeFadeConfig: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<{}> & {
17
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
18
+ } & {
19
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
20
+ }, SankeyNodeFade, any[]>;
21
+ /**
22
+ * Get the link highlight configuration from the Sankey series.
23
+ * Defaults to 'links' if not specified.
24
+ */
25
+ export declare const selectorLinkHighlightConfig: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<{}> & {
26
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
27
+ } & {
28
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
29
+ }, SankeyLinkHighlight, any[]>;
30
+ /**
31
+ * Get the link fade configuration from the Sankey series.
32
+ * Defaults to 'none' if not specified.
33
+ */
34
+ export declare const selectorLinkFadeConfig: import("reselect").Selector<import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & Partial<{}> & {
35
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
36
+ } & {
37
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
38
+ }, SankeyLinkFade, any[]>;
39
+ /**
40
+ * Get the currently highlighted item in the Sankey chart.
41
+ * @param {UseSankeyHighlightSignature['state']} state The state of the chart.
42
+ * @returns {SankeyItemIdentifier | null} The highlighted item identifier or null.
43
+ */
44
+ export declare const selectorSankeyHighlightedItem: import("reselect").Selector<import("./useSankeyHighlight.types.js").UseSankeyHighlightState & {
45
+ cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
46
+ }, import("../index.js").SankeyItemIdentifier | null, []>;
47
+ /**
48
+ * Determines if a specific node should be highlighted.
49
+ * A node is highlighted if:
50
+ * - It's the highlighted node (unless highlight mode is 'none')
51
+ * - It's connected to a highlighted link (based on linkOptions.highlight)
52
+ */
53
+ export declare const selectorIsNodeHighlighted: import("reselect").Selector<any, boolean, [node: SankeyLayoutNode]>;
54
+ /**
55
+ * Selector that determines if a specific link should be highlighted.
56
+ * A link is highlighted if:
57
+ * - It's the highlighted link (unless highlight mode is 'none')
58
+ * - It's connected to a highlighted node (based on nodeOptions.highlight)
59
+ */
60
+ export declare const selectorIsLinkHighlighted: import("reselect").Selector<any, boolean, [link: SankeyLayoutLink]>;
61
+ /**
62
+ * Selector that determines if an item should be faded.
63
+ * An item is faded if:
64
+ * - There's a highlighted item
65
+ * - This item is not highlighted
66
+ * - The fade mode is 'global' for the highlighted element type
67
+ */
68
+ export declare const selectorIsSankeyItemFaded: import("reselect").Selector<any, boolean, [isHighlighted: any]>;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorSankeyHighlightedItem = exports.selectorNodeHighlightConfig = exports.selectorNodeFadeConfig = exports.selectorLinkHighlightConfig = exports.selectorLinkFadeConfig = exports.selectorIsSankeyItemFaded = exports.selectorIsNodeHighlighted = exports.selectorIsLinkHighlighted = void 0;
7
+ var _internals = require("@mui/x-charts/internals");
8
+ const selectorSankeyHighlight = state => state.highlight;
9
+ const selectSeries = state => state.series;
10
+ const selectorSankeySeries = (0, _internals.createSelector)([selectSeries], series => series.processedSeries.sankey?.series[series.processedSeries.sankey?.seriesOrder[0]] || null);
11
+ const DEFAULT_NODE_HIGHLIGHT = 'links';
12
+ const DEFAULT_LINK_HIGHLIGHT = 'links';
13
+ const DEFAULT_FADE = 'none';
14
+
15
+ /**
16
+ * Get the node highlight configuration from the Sankey series.
17
+ * Defaults to 'nodes' if not specified.
18
+ */
19
+ const selectorNodeHighlightConfig = exports.selectorNodeHighlightConfig = (0, _internals.createSelector)([selectorSankeySeries], series => series?.nodeOptions?.highlight ?? DEFAULT_NODE_HIGHLIGHT);
20
+
21
+ /**
22
+ * Get the node fade configuration from the Sankey series.
23
+ * Defaults to 'none' if not specified.
24
+ */
25
+ const selectorNodeFadeConfig = exports.selectorNodeFadeConfig = (0, _internals.createSelector)([selectorSankeySeries], series => series?.nodeOptions?.fade ?? DEFAULT_FADE);
26
+
27
+ /**
28
+ * Get the link highlight configuration from the Sankey series.
29
+ * Defaults to 'links' if not specified.
30
+ */
31
+ const selectorLinkHighlightConfig = exports.selectorLinkHighlightConfig = (0, _internals.createSelector)([selectorSankeySeries], series => series?.linkOptions?.highlight ?? DEFAULT_LINK_HIGHLIGHT);
32
+
33
+ /**
34
+ * Get the link fade configuration from the Sankey series.
35
+ * Defaults to 'none' if not specified.
36
+ */
37
+ const selectorLinkFadeConfig = exports.selectorLinkFadeConfig = (0, _internals.createSelector)([selectorSankeySeries], series => series?.linkOptions?.fade ?? DEFAULT_FADE);
38
+
39
+ /**
40
+ * Get the currently highlighted item in the Sankey chart.
41
+ * @param {UseSankeyHighlightSignature['state']} state The state of the chart.
42
+ * @returns {SankeyItemIdentifier | null} The highlighted item identifier or null.
43
+ */
44
+ const selectorSankeyHighlightedItem = exports.selectorSankeyHighlightedItem = (0, _internals.createSelector)([selectorSankeyHighlight], highlight => highlight.item);
45
+
46
+ /**
47
+ * Determines if a specific node should be highlighted.
48
+ * A node is highlighted if:
49
+ * - It's the highlighted node (unless highlight mode is 'none')
50
+ * - It's connected to a highlighted link (based on linkOptions.highlight)
51
+ */
52
+ const selectorIsNodeHighlighted = exports.selectorIsNodeHighlighted = (0, _internals.createSelector)([selectorSankeyHighlightedItem, selectorNodeHighlightConfig, selectorLinkHighlightConfig, (_, node) => node.id], (highlightedItem, nodeHighlight, linkHighlight, nodeId) => {
53
+ if (!highlightedItem) {
54
+ return false;
55
+ }
56
+ if (highlightedItem.subType === 'node' && highlightedItem.nodeId === nodeId) {
57
+ return nodeHighlight !== 'none';
58
+ }
59
+ if (highlightedItem.subType === 'link') {
60
+ if (!linkHighlight || linkHighlight === 'none' || linkHighlight === 'links') {
61
+ return false;
62
+ }
63
+ const {
64
+ sourceId,
65
+ targetId
66
+ } = highlightedItem;
67
+ switch (linkHighlight) {
68
+ case 'nodes':
69
+ return nodeId === sourceId || nodeId === targetId;
70
+ case 'source':
71
+ return nodeId === sourceId;
72
+ case 'target':
73
+ return nodeId === targetId;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ return false;
79
+ });
80
+
81
+ /**
82
+ * Selector that determines if a specific link should be highlighted.
83
+ * A link is highlighted if:
84
+ * - It's the highlighted link (unless highlight mode is 'none')
85
+ * - It's connected to a highlighted node (based on nodeOptions.highlight)
86
+ */
87
+ const selectorIsLinkHighlighted = exports.selectorIsLinkHighlighted = (0, _internals.createSelector)([selectorSankeyHighlightedItem, selectorNodeHighlightConfig, selectorLinkHighlightConfig, (_, link) => link], (highlightedItem, nodeHighlight, linkHighlight, link) => {
88
+ if (!highlightedItem) {
89
+ return false;
90
+ }
91
+ if (highlightedItem.subType === 'link' && highlightedItem.sourceId === link.source.id && highlightedItem.targetId === link.target.id) {
92
+ return linkHighlight !== 'none';
93
+ }
94
+ if (highlightedItem.subType === 'node') {
95
+ if (!nodeHighlight || nodeHighlight === 'none' || nodeHighlight === 'nodes') {
96
+ return false;
97
+ }
98
+ const highlightedNodeId = highlightedItem.nodeId;
99
+ switch (nodeHighlight) {
100
+ case 'links':
101
+ return link.source.id === highlightedNodeId || link.target.id === highlightedNodeId;
102
+ case 'incoming':
103
+ return link.target.id === highlightedNodeId;
104
+ case 'outgoing':
105
+ return link.source.id === highlightedNodeId;
106
+ default:
107
+ return false;
108
+ }
109
+ }
110
+ return false;
111
+ });
112
+
113
+ /**
114
+ * Selector that determines if an item should be faded.
115
+ * An item is faded if:
116
+ * - There's a highlighted item
117
+ * - This item is not highlighted
118
+ * - The fade mode is 'global' for the highlighted element type
119
+ */
120
+ const selectorIsSankeyItemFaded = exports.selectorIsSankeyItemFaded = (0, _internals.createSelector)([selectorSankeyHighlightedItem, selectorNodeFadeConfig, selectorLinkFadeConfig, (_, isHighlighted) => isHighlighted], (highlightedItem, nodeFade, linkFade, isHighlighted) => {
121
+ if (!highlightedItem || isHighlighted) {
122
+ return false;
123
+ }
124
+ const fadeMode = highlightedItem.subType === 'node' ? nodeFade : linkFade;
125
+ return fadeMode === 'global';
126
+ });
@@ -0,0 +1,55 @@
1
+ import { DefaultizedProps } from '@mui/x-internals/types';
2
+ import { ChartPluginSignature } from '@mui/x-charts/internals';
3
+ import { SankeyItemIdentifier } from "../sankey.types.js";
4
+ /**
5
+ * The data of the highlighted item in a Sankey chart.
6
+ * Can be either a node or a link.
7
+ *
8
+ * @example
9
+ * // Highlight a node
10
+ * { type: 'sankey', seriesId: 'series-1', subType: 'node', nodeId: 'A' }
11
+ *
12
+ * // Highlight a link
13
+ * { type: 'sankey', seriesId: 'series-1', subType: 'link', sourceId: 'A', targetId: 'B' }
14
+ *
15
+ * // Clear the highlight
16
+ * null
17
+ */
18
+ export type SankeyHighlightItemData = SankeyItemIdentifier;
19
+ export interface UseSankeyHighlightInstance {
20
+ /**
21
+ * Remove all highlight.
22
+ */
23
+ clearHighlight: () => void;
24
+ /**
25
+ * Set the highlighted item.
26
+ * @param {SankeyHighlightItemData} item The item to highlight.
27
+ */
28
+ setHighlight: (item: SankeyHighlightItemData) => void;
29
+ }
30
+ export interface UseSankeyHighlightParameters {
31
+ /**
32
+ * The highlighted item.
33
+ * Used when the highlight is controlled.
34
+ */
35
+ highlightedItem?: SankeyHighlightItemData | null;
36
+ /**
37
+ * The callback fired when the highlighted item changes.
38
+ *
39
+ * @param {SankeyHighlightItemData | null} highlightedItem The newly highlighted item.
40
+ */
41
+ onHighlightChange?: (highlightedItem: SankeyHighlightItemData | null) => void;
42
+ }
43
+ export type UseSankeyHighlightDefaultizedParameters = DefaultizedProps<UseSankeyHighlightParameters, 'highlightedItem'>;
44
+ export interface UseSankeyHighlightState {
45
+ highlight: {
46
+ item: SankeyHighlightItemData | null;
47
+ };
48
+ }
49
+ export type UseSankeyHighlightSignature = ChartPluginSignature<{
50
+ instance: UseSankeyHighlightInstance;
51
+ state: UseSankeyHighlightState;
52
+ params: UseSankeyHighlightParameters;
53
+ defaultizedParams: UseSankeyHighlightDefaultizedParameters;
54
+ modelNames: 'highlightedItem';
55
+ }>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,42 @@
1
+ export type SankeyNodeHighlight = 'nodes' | 'links' | 'incoming' | 'outgoing' | 'none';
2
+ export type SankeyNodeFade = 'global' | 'none';
3
+ export type SankeyLinkHighlight = 'links' | 'nodes' | 'source' | 'target' | 'none';
4
+ export type SankeyLinkFade = 'global' | 'none';
5
+ export type SankeyNodeHighlightScope = {
6
+ /**
7
+ * Highlight mode for nodes
8
+ * - 'nodes': Highlight hovered node
9
+ * - 'links': Highlight links connected to hovered node
10
+ * - 'incoming': Highlight incoming links to hovered node
11
+ * - 'outgoing': Highlight outgoing links from hovered node
12
+ * - 'none': No highlighting
13
+ * @default 'links'
14
+ */
15
+ highlight?: SankeyNodeHighlight;
16
+ /**
17
+ * Fade mode for nodes
18
+ * - 'global': Fade all non-highlighted items
19
+ * - 'none': No fading
20
+ * @default 'none'
21
+ */
22
+ fade?: SankeyNodeFade;
23
+ };
24
+ export type SankeyLinkHighlightScope = {
25
+ /**
26
+ * Highlight mode for links
27
+ * - 'links': Highlight hovered link
28
+ * - 'nodes': Highlight nodes connected to hovered link
29
+ * - 'source': Highlight source node of hovered link
30
+ * - 'target': Highlight target node of hovered link
31
+ * - 'none': No highlighting
32
+ * @default 'links'
33
+ */
34
+ highlight?: SankeyLinkHighlight;
35
+ /**
36
+ * Fade mode for links
37
+ * - 'global': Fade all non-highlighted items
38
+ * - 'none': No fading
39
+ * @default 'none'
40
+ */
41
+ fade?: SankeyLinkFade;
42
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -1,6 +1,7 @@
1
1
  import type { HighlightScope, SeriesId } from '@mui/x-charts/internals';
2
2
  import type { DefaultizedProps, MakeRequired } from '@mui/x-internals/types';
3
3
  import type { SankeyLink as D3SankeyLink, SankeyNode as D3SankeyNode } from '@mui/x-charts-vendor/d3-sankey';
4
+ import type { SankeyLinkHighlightScope, SankeyNodeHighlightScope } from "./sankey.highlight.types.js";
4
5
  export type SankeyNodeId = string | number;
5
6
  export interface SankeyNode {
6
7
  /**
@@ -79,7 +80,7 @@ export type SankeyNodeOptions = {
79
80
  * @returns {number} Comparison result
80
81
  */
81
82
  sort?: (a: SankeyLayoutNode, b: SankeyLayoutNode) => number | null;
82
- };
83
+ } & SankeyNodeHighlightScope;
83
84
  export type SankeyLinkOptions = {
84
85
  /**
85
86
  * Default color for links without specified colors.
@@ -111,7 +112,7 @@ export type SankeyLinkOptions = {
111
112
  * @default 10
112
113
  */
113
114
  curveCorrection?: number;
114
- };
115
+ } & SankeyLinkHighlightScope;
115
116
  export interface SankeyData {
116
117
  /**
117
118
  * An array of node configs for the Sankey diagram
@@ -12,4 +12,4 @@ export declare function getSankeyPlotUtilityClass(slot: string): string;
12
12
  export declare const sankeyPlotClasses: SankeyPlotClasses;
13
13
  export declare const useUtilityClasses: (ownerState: {
14
14
  classes?: Partial<SankeyPlotClasses>;
15
- }) => Record<"root" | "nodes" | "links" | "linkLabels", string>;
15
+ }) => Record<"nodes" | "links" | "root" | "linkLabels", string>;
@@ -10,7 +10,7 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
10
10
  var _constants = require("@mui/x-charts/constants");
11
11
  var _internals = require("@mui/x-charts/internals");
12
12
  var _SankeyChart = require("./SankeyChart.plugins");
13
- const _excluded = ["series", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "loading", "className", "apiRef", "onNodeClick", "onLinkClick"];
13
+ const _excluded = ["series", "width", "height", "margin", "colors", "sx", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className", "apiRef", "onNodeClick", "onLinkClick"];
14
14
  /**
15
15
  * A helper function that extracts SankeyChartProps from the input props
16
16
  * and returns an object with props for the children components of SankeyChart.
@@ -30,8 +30,8 @@ const useSankeyChartProps = props => {
30
30
  slots,
31
31
  slotProps,
32
32
  loading,
33
- // highlightedItem,
34
- // onHighlightChange,
33
+ highlightedItem,
34
+ onHighlightChange,
35
35
  className,
36
36
  apiRef,
37
37
  onNodeClick,
@@ -48,8 +48,8 @@ const useSankeyChartProps = props => {
48
48
  margin,
49
49
  colors,
50
50
  sx,
51
- // highlightedItem,
52
- // onHighlightChange,
51
+ highlightedItem,
52
+ onHighlightChange,
53
53
  className,
54
54
  apiRef,
55
55
  plugins: _SankeyChart.SANKEY_CHART_PLUGINS
@@ -111,6 +111,14 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
111
111
  x: _propTypes.default.oneOf(['band', 'line', 'none']),
112
112
  y: _propTypes.default.oneOf(['band', 'line', 'none'])
113
113
  }),
114
+ /**
115
+ * Configuration for the brush interaction.
116
+ */
117
+ brushConfig: _propTypes.default.shape({
118
+ enabled: _propTypes.default.bool,
119
+ preventHighlight: _propTypes.default.bool,
120
+ preventTooltip: _propTypes.default.bool
121
+ }),
114
122
  children: _propTypes.default.node,
115
123
  className: _propTypes.default.string,
116
124
  /**
@@ -1,5 +1,5 @@
1
- import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
1
+ import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature, UseChartBrushSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { UseChartProZoomSignature } from "../internals/plugins/useChartProZoom/index.js";
4
- export type ScatterChartProPluginSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'scatter'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
4
+ export type ScatterChartProPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<'scatter'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
5
  export declare const SCATTER_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<ScatterChartProPluginSignatures>;
@@ -7,4 +7,4 @@ exports.SCATTER_CHART_PRO_PLUGINS = void 0;
7
7
  var _internals = require("@mui/x-charts/internals");
8
8
  var _useChartProExport = require("../internals/plugins/useChartProExport");
9
9
  var _useChartProZoom = require("../internals/plugins/useChartProZoom");
10
- const SCATTER_CHART_PRO_PLUGINS = exports.SCATTER_CHART_PRO_PLUGINS = [_internals.useChartZAxis, _internals.useChartCartesianAxis, _internals.useChartInteraction, _internals.useChartHighlight, _internals.useChartClosestPoint, _internals.useChartKeyboardNavigation, _useChartProZoom.useChartProZoom, _useChartProExport.useChartProExport];
10
+ const SCATTER_CHART_PRO_PLUGINS = exports.SCATTER_CHART_PRO_PLUGINS = [_internals.useChartZAxis, _internals.useChartBrush, _internals.useChartCartesianAxis, _internals.useChartInteraction, _internals.useChartHighlight, _internals.useChartClosestPoint, _internals.useChartKeyboardNavigation, _useChartProZoom.useChartProZoom, _useChartProExport.useChartProExport];
@@ -118,6 +118,14 @@ process.env.NODE_ENV !== "production" ? BarChartPro.propTypes = {
118
118
  * Defines the border radius of the bar element.
119
119
  */
120
120
  borderRadius: PropTypes.number,
121
+ /**
122
+ * Configuration for the brush interaction.
123
+ */
124
+ brushConfig: PropTypes.shape({
125
+ enabled: PropTypes.bool,
126
+ preventHighlight: PropTypes.bool,
127
+ preventTooltip: PropTypes.bool
128
+ }),
121
129
  children: PropTypes.node,
122
130
  className: PropTypes.string,
123
131
  /**
@@ -1,5 +1,5 @@
1
- import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
1
+ import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartBrushSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { UseChartProZoomSignature } from "../internals/plugins/useChartProZoom/index.js";
4
- export type BarChartProPluginSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'bar'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
4
+ export type BarChartProPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<'bar'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
5
  export declare const BAR_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<BarChartProPluginSignatures>;
@@ -1,4 +1,4 @@
1
- import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation } from '@mui/x-charts/internals';
1
+ import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartBrush } from '@mui/x-charts/internals';
2
2
  import { useChartProExport } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { useChartProZoom } from "../internals/plugins/useChartProZoom/index.js";
4
- export const BAR_CHART_PRO_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartProZoom, useChartProExport];
4
+ export const BAR_CHART_PRO_PLUGINS = [useChartZAxis, useChartBrush, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartProZoom, useChartProExport];
@@ -11,7 +11,7 @@ import { defaultSlotsMaterial } from "../internals/material/index.js";
11
11
  import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
12
12
  import { useChartDataProviderProProps } from "./useChartDataProviderProProps.js";
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const releaseInfo = "MTc1OTk2ODAwMDAwMA==";
14
+ const releaseInfo = "MTc2MTE3NzYwMDAwMA==";
15
15
  const packageIdentifier = 'x-charts-pro';
16
16
  /**
17
17
  * Orchestrates the data providers for the chart components and hooks.
@@ -0,0 +1 @@
1
+ export * from '@mui/x-charts/ChartsBrushOverlay';
@@ -0,0 +1,2 @@
1
+ // Re-export automatically generated, to customize, simply remove this line.
2
+ export * from '@mui/x-charts/ChartsBrushOverlay';
@@ -110,6 +110,14 @@ process.env.NODE_ENV !== "production" ? LineChartPro.propTypes = {
110
110
  x: PropTypes.oneOf(['band', 'line', 'none']),
111
111
  y: PropTypes.oneOf(['band', 'line', 'none'])
112
112
  }),
113
+ /**
114
+ * Configuration for the brush interaction.
115
+ */
116
+ brushConfig: PropTypes.shape({
117
+ enabled: PropTypes.bool,
118
+ preventHighlight: PropTypes.bool,
119
+ preventTooltip: PropTypes.bool
120
+ }),
113
121
  children: PropTypes.node,
114
122
  className: PropTypes.string,
115
123
  /**
@@ -1,5 +1,5 @@
1
- import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
1
+ import { UseChartZAxisSignature, UseChartCartesianAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartBrushSignature, ConvertSignaturesIntoPlugins } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { UseChartProZoomSignature } from "../internals/plugins/useChartProZoom/index.js";
4
- export type LineChartProPluginSignatures = [UseChartZAxisSignature, UseChartCartesianAxisSignature<'line'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
4
+ export type LineChartProPluginSignatures = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<'line'>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartKeyboardNavigationSignature, UseChartProZoomSignature, UseChartProExportSignature];
5
5
  export declare const LINE_CHART_PRO_PLUGINS: ConvertSignaturesIntoPlugins<LineChartProPluginSignatures>;
@@ -1,4 +1,4 @@
1
- import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation } from '@mui/x-charts/internals';
1
+ import { useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartBrush } from '@mui/x-charts/internals';
2
2
  import { useChartProExport } from "../internals/plugins/useChartProExport/index.js";
3
3
  import { useChartProZoom } from "../internals/plugins/useChartProZoom/index.js";
4
- export const LINE_CHART_PRO_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartProZoom, useChartProExport];
4
+ export const LINE_CHART_PRO_PLUGINS = [useChartZAxis, useChartBrush, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartKeyboardNavigation, useChartProZoom, useChartProExport];
@@ -7,7 +7,7 @@ import { type SankeyChartPluginSignatures } from "./SankeyChart.plugins.js";
7
7
  import type { SankeySeriesType } from "./sankey.types.js";
8
8
  import type { SankeyChartSlotExtension } from "./sankeySlots.types.js";
9
9
  export type SankeySeries = MakeOptional<SankeySeriesType, 'type'>;
10
- export interface SankeyChartProps extends Omit<ChartContainerProProps<'sankey', SankeyChartPluginSignatures>, 'plugins' | 'series' | 'slotProps' | 'slots' | 'dataset' | 'hideLegend' | 'skipAnimation' | 'highlightedItem' | 'onHighlightChange'>, Omit<SankeyPlotProps, 'data'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, SankeyChartSlotExtension {
10
+ export interface SankeyChartProps extends Omit<ChartContainerProProps<'sankey', SankeyChartPluginSignatures>, 'plugins' | 'series' | 'slotProps' | 'slots' | 'dataset' | 'hideLegend' | 'skipAnimation'>, Omit<SankeyPlotProps, 'data'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, SankeyChartSlotExtension {
11
11
  /**
12
12
  * The series to display in the Sankey chart.
13
13
  * A single object is expected.
@@ -94,6 +94,30 @@ process.env.NODE_ENV !== "production" ? SankeyChart.propTypes = {
94
94
  * The height of the chart in px. If not defined, it takes the height of the parent element.
95
95
  */
96
96
  height: PropTypes.number,
97
+ /**
98
+ * The highlighted item.
99
+ * Used when the highlight is controlled.
100
+ */
101
+ highlightedItem: PropTypes.oneOfType([PropTypes.shape({
102
+ nodeId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
103
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
104
+ subType: PropTypes.oneOf([
105
+ /**
106
+ * Subtype to differentiate between node and link
107
+ */
108
+ 'node']).isRequired,
109
+ type: PropTypes.oneOf(['sankey']).isRequired
110
+ }), PropTypes.shape({
111
+ seriesId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
112
+ sourceId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
113
+ subType: PropTypes.oneOf([
114
+ /**
115
+ * Subtype to differentiate between node and link
116
+ */
117
+ 'link']).isRequired,
118
+ targetId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
119
+ type: PropTypes.oneOf(['sankey']).isRequired
120
+ })]),
97
121
  /**
98
122
  * This prop is used to help implement the accessibility logic.
99
123
  * If you don't provide this prop. It falls back to a randomly generated id.
@@ -120,6 +144,12 @@ process.env.NODE_ENV !== "production" ? SankeyChart.propTypes = {
120
144
  right: PropTypes.number,
121
145
  top: PropTypes.number
122
146
  })]),
147
+ /**
148
+ * The callback fired when the highlighted item changes.
149
+ *
150
+ * @param {SankeyHighlightItemData | null} highlightedItem The newly highlighted item.
151
+ */
152
+ onHighlightChange: PropTypes.func,
123
153
  /**
124
154
  * Callback fired when a sankey item is clicked.
125
155
  * @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
@@ -1,4 +1,5 @@
1
- import { ConvertSignaturesIntoPlugins, UseChartHighlightSignature, UseChartInteractionSignature } from '@mui/x-charts/internals';
1
+ import { ConvertSignaturesIntoPlugins, UseChartInteractionSignature } from '@mui/x-charts/internals';
2
2
  import { UseChartProExportSignature } from "../internals/plugins/useChartProExport/index.js";
3
- export type SankeyChartPluginSignatures = [UseChartInteractionSignature, UseChartHighlightSignature, UseChartProExportSignature];
3
+ import { type UseSankeyHighlightSignature } from "./plugins/index.js";
4
+ export type SankeyChartPluginSignatures = [UseChartInteractionSignature, UseSankeyHighlightSignature, UseChartProExportSignature];
4
5
  export declare const SANKEY_CHART_PLUGINS: ConvertSignaturesIntoPlugins<SankeyChartPluginSignatures>;