@mui/x-charts 8.5.2 → 8.6.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/BarChart/AnimatedBarElement.js +3 -1
- package/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
- package/BarChart/BarLabel/BarLabelPlot.js +33 -25
- package/BarChart/BarPlot.js +55 -40
- package/BarChart/barClasses.d.ts +12 -0
- package/BarChart/barClasses.js +25 -0
- package/BarChart/index.d.ts +3 -1
- package/BarChart/index.js +23 -1
- package/BarChart/types.d.ts +5 -1
- package/CHANGELOG.md +203 -11
- package/ChartsLegend/ChartsLegend.d.ts +1 -0
- package/ChartsLegend/ChartsLegend.js +2 -0
- package/ChartsLegend/ContinuousColorLegend.d.ts +1 -0
- package/ChartsLegend/PiecewiseColorLegend.d.ts +1 -0
- package/ChartsLegend/chartsLegendClasses.d.ts +3 -1
- package/ChartsLegend/chartsLegendClasses.js +2 -1
- package/ChartsSurface/ChartsSurface.d.ts +1 -1
- package/ChartsXAxis/ChartsXAxis.js +4 -108
- package/ChartsXAxis/getVisibleLabels.d.ts +14 -0
- package/ChartsXAxis/getVisibleLabels.js +71 -0
- package/ChartsXAxis/shortenLabels.d.ts +4 -0
- package/ChartsXAxis/shortenLabels.js +48 -0
- package/ChartsYAxis/ChartsYAxis.js +2 -39
- package/ChartsYAxis/shortenLabels.d.ts +4 -0
- package/ChartsYAxis/shortenLabels.js +46 -0
- package/LineChart/AnimatedArea.js +4 -1
- package/LineChart/AnimatedLine.js +4 -1
- package/LineChart/CircleMarkElement.js +4 -1
- package/LineChart/MarkElement.js +4 -1
- package/LineChart/MarkPlot.js +1 -0
- package/PieChart/PieArc.js +3 -1
- package/PieChart/PiePlot.js +6 -0
- package/PieChart/index.d.ts +3 -1
- package/PieChart/index.js +18 -1
- package/PieChart/pieClasses.d.ts +12 -0
- package/PieChart/pieClasses.js +24 -0
- package/ScatterChart/Scatter.d.ts +2 -0
- package/ScatterChart/Scatter.js +9 -1
- package/ScatterChart/index.d.ts +3 -1
- package/ScatterChart/index.js +16 -1
- package/ScatterChart/scatterClasses.d.ts +8 -0
- package/ScatterChart/scatterClasses.js +22 -0
- package/Toolbar/ToolbarButton.js +2 -0
- package/esm/BarChart/AnimatedBarElement.js +3 -1
- package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
- package/esm/BarChart/BarLabel/BarLabelPlot.js +33 -25
- package/esm/BarChart/BarPlot.js +55 -40
- package/esm/BarChart/barClasses.d.ts +12 -0
- package/esm/BarChart/barClasses.js +15 -0
- package/esm/BarChart/index.d.ts +3 -1
- package/esm/BarChart/index.js +2 -1
- package/esm/BarChart/types.d.ts +5 -1
- package/esm/ChartsLegend/ChartsLegend.d.ts +1 -0
- package/esm/ChartsLegend/ChartsLegend.js +2 -0
- package/esm/ChartsLegend/ContinuousColorLegend.d.ts +1 -0
- package/esm/ChartsLegend/PiecewiseColorLegend.d.ts +1 -0
- package/esm/ChartsLegend/chartsLegendClasses.d.ts +3 -1
- package/esm/ChartsLegend/chartsLegendClasses.js +2 -1
- package/esm/ChartsSurface/ChartsSurface.d.ts +1 -1
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -106
- package/esm/ChartsXAxis/getVisibleLabels.d.ts +14 -0
- package/esm/ChartsXAxis/getVisibleLabels.js +67 -0
- package/esm/ChartsXAxis/shortenLabels.d.ts +4 -0
- package/esm/ChartsXAxis/shortenLabels.js +42 -0
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -38
- package/esm/ChartsYAxis/shortenLabels.d.ts +4 -0
- package/esm/ChartsYAxis/shortenLabels.js +41 -0
- package/esm/LineChart/AnimatedArea.js +4 -1
- package/esm/LineChart/AnimatedLine.js +4 -1
- package/esm/LineChart/CircleMarkElement.js +4 -1
- package/esm/LineChart/MarkElement.js +4 -1
- package/esm/LineChart/MarkPlot.js +1 -0
- package/esm/PieChart/PieArc.js +3 -1
- package/esm/PieChart/PiePlot.js +6 -0
- package/esm/PieChart/index.d.ts +3 -1
- package/esm/PieChart/index.js +2 -1
- package/esm/PieChart/pieClasses.d.ts +12 -0
- package/esm/PieChart/pieClasses.js +15 -0
- package/esm/ScatterChart/Scatter.d.ts +2 -0
- package/esm/ScatterChart/Scatter.js +9 -1
- package/esm/ScatterChart/index.d.ts +3 -1
- package/esm/ScatterChart/index.js +2 -1
- package/esm/ScatterChart/scatterClasses.d.ts +8 -0
- package/esm/ScatterChart/scatterClasses.js +13 -0
- package/esm/Toolbar/ToolbarButton.js +2 -0
- package/esm/hooks/useItemHighlighted.js +2 -2
- package/esm/index.js +1 -1
- package/esm/internals/components/NotRendered.d.ts +9 -0
- package/esm/internals/components/NotRendered.js +10 -0
- package/esm/internals/createSeriesSelectorOfType.js +2 -2
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +3 -29
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +30 -2
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +14 -724
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +10 -10
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +8 -2
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +3 -29
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +6 -54
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +12 -208
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +7 -66
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.js +2 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +21 -6222
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +4 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +50 -5
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +18 -622
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -3
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +18 -230
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +6 -6
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +20 -4
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +17 -2012
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +39 -4
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +3 -27
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +5 -40
- package/esm/internals/plugins/utils/selectors.d.ts +18 -6
- package/esm/internals/plugins/utils/selectors.js +3 -3
- package/esm/internals/store/useSelector.d.ts +2 -2
- package/esm/internals/store/useSelector.js +2 -2
- package/esm/locales/enUS.d.ts +3 -0
- package/esm/locales/enUS.js +8 -2
- package/esm/locales/frFR.d.ts +3 -0
- package/esm/locales/frFR.js +7 -0
- package/esm/locales/ptBR.d.ts +3 -0
- package/esm/locales/ptBR.js +7 -1
- package/esm/locales/ptPT.d.ts +3 -0
- package/esm/locales/ptPT.js +7 -1
- package/esm/locales/utils/chartsLocaleTextApi.d.ts +17 -0
- package/esm/locales/utils/getChartsLocalization.d.ts +3 -0
- package/esm/locales/utils/imageMimeTypes.d.ts +2 -0
- package/esm/locales/utils/imageMimeTypes.js +5 -0
- package/esm/models/slots/chartsBaseSlotProps.d.ts +4 -0
- package/hooks/useItemHighlighted.js +2 -2
- package/index.js +1 -1
- package/internals/components/NotRendered.d.ts +9 -0
- package/internals/components/NotRendered.js +16 -0
- package/internals/createSeriesSelectorOfType.js +2 -2
- package/internals/index.d.ts +1 -0
- package/internals/index.js +12 -0
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +3 -29
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +30 -2
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +14 -724
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +11 -10
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +8 -2
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +3 -29
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +1 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +6 -54
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +12 -208
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.d.ts +7 -66
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisLayout.selectors.js +4 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +21 -6222
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +4 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +50 -5
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +18 -622
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +3 -3
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +18 -230
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +6 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +20 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +17 -2012
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +2 -2
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +39 -4
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +3 -27
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +1 -1
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +5 -40
- package/internals/plugins/utils/selectors.d.ts +18 -6
- package/internals/plugins/utils/selectors.js +3 -3
- package/internals/store/useSelector.d.ts +2 -2
- package/internals/store/useSelector.js +2 -2
- package/locales/enUS.d.ts +3 -0
- package/locales/enUS.js +8 -2
- package/locales/frFR.d.ts +3 -0
- package/locales/frFR.js +7 -0
- package/locales/ptBR.d.ts +3 -0
- package/locales/ptBR.js +7 -1
- package/locales/ptPT.d.ts +3 -0
- package/locales/ptPT.js +7 -1
- package/locales/utils/chartsLocaleTextApi.d.ts +17 -0
- package/locales/utils/getChartsLocalization.d.ts +3 -0
- package/locales/utils/imageMimeTypes.d.ts +2 -0
- package/locales/utils/imageMimeTypes.js +11 -0
- package/models/slots/chartsBaseSlotProps.d.ts +4 -0
- package/package.json +3 -3
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { UseChartVoronoiSignature } from "./useChartVoronoi.types.js";
|
|
3
|
-
export declare const selectorChartsVoronoiIsVoronoiEnabled: ((state: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./useChartVoronoi.types.js").UseChartVoronoiState & Partial<{}> & {
|
|
1
|
+
export declare const selectorChartsVoronoiIsVoronoiEnabled: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./useChartVoronoi.types.js").UseChartVoronoiState & Partial<{}> & {
|
|
4
2
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
-
}) => boolean | undefined) & {
|
|
6
|
-
clearCache: () => void;
|
|
7
|
-
resultsCount: () => number;
|
|
8
|
-
resetResultsCount: () => void;
|
|
9
3
|
} & {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}) => boolean | undefined;
|
|
13
|
-
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
14
|
-
isVoronoiEnabled?: boolean;
|
|
15
|
-
}) => boolean | undefined) & {
|
|
16
|
-
clearCache: () => void;
|
|
17
|
-
resultsCount: () => number;
|
|
18
|
-
resetResultsCount: () => void;
|
|
19
|
-
};
|
|
20
|
-
lastResult: () => boolean | undefined;
|
|
21
|
-
dependencies: [ChartRootSelector<UseChartVoronoiSignature>];
|
|
22
|
-
recomputations: () => number;
|
|
23
|
-
resetRecomputations: () => void;
|
|
24
|
-
dependencyRecomputations: () => number;
|
|
25
|
-
resetDependencyRecomputations: () => void;
|
|
26
|
-
} & {
|
|
27
|
-
memoize: typeof import("reselect").weakMapMemoize;
|
|
28
|
-
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
29
|
-
};
|
|
4
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
+
}, boolean | undefined, any[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createSelector } from "../../utils/selectors.js";
|
|
2
2
|
const selectVoronoi = state => state.voronoi;
|
|
3
|
-
export const selectorChartsVoronoiIsVoronoiEnabled = createSelector(selectVoronoi, voronoi => voronoi?.isVoronoiEnabled);
|
|
3
|
+
export const selectorChartsVoronoiIsVoronoiEnabled = createSelector([selectVoronoi], voronoi => voronoi?.isVoronoiEnabled);
|
|
@@ -1,45 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { UseChartZAxisSignature } from "./useChartZAxis.types.js";
|
|
3
|
-
export declare const selectorChartZAxis: ((state: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./useChartZAxis.types.js").UseChartZAxisState & Partial<{}> & {
|
|
1
|
+
export declare const selectorChartZAxis: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./useChartZAxis.types.js").UseChartZAxisState & Partial<{}> & {
|
|
4
2
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
-
}
|
|
3
|
+
} & {
|
|
4
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
+
}, {
|
|
6
6
|
axis: {
|
|
7
7
|
[axisId: string]: import("../../../index.js").ZAxisDefaultized;
|
|
8
8
|
};
|
|
9
9
|
axisIds: import("../../../index.js").AxisId[];
|
|
10
|
-
}
|
|
11
|
-
clearCache: () => void;
|
|
12
|
-
resultsCount: () => number;
|
|
13
|
-
resetResultsCount: () => void;
|
|
14
|
-
} & {
|
|
15
|
-
resultFunc: (resultFuncArgs_0: ChartState<[UseChartZAxisSignature]>) => {
|
|
16
|
-
axis: {
|
|
17
|
-
[axisId: string]: import("../../../index.js").ZAxisDefaultized;
|
|
18
|
-
};
|
|
19
|
-
axisIds: import("../../../index.js").AxisId[];
|
|
20
|
-
};
|
|
21
|
-
memoizedResultFunc: ((resultFuncArgs_0: ChartState<[UseChartZAxisSignature]>) => {
|
|
22
|
-
axis: {
|
|
23
|
-
[axisId: string]: import("../../../index.js").ZAxisDefaultized;
|
|
24
|
-
};
|
|
25
|
-
axisIds: import("../../../index.js").AxisId[];
|
|
26
|
-
}) & {
|
|
27
|
-
clearCache: () => void;
|
|
28
|
-
resultsCount: () => number;
|
|
29
|
-
resetResultsCount: () => void;
|
|
30
|
-
};
|
|
31
|
-
lastResult: () => {
|
|
32
|
-
axis: {
|
|
33
|
-
[axisId: string]: import("../../../index.js").ZAxisDefaultized;
|
|
34
|
-
};
|
|
35
|
-
axisIds: import("../../../index.js").AxisId[];
|
|
36
|
-
};
|
|
37
|
-
dependencies: [(state: ChartState<[UseChartZAxisSignature]>) => ChartState<[UseChartZAxisSignature]>];
|
|
38
|
-
recomputations: () => number;
|
|
39
|
-
resetRecomputations: () => void;
|
|
40
|
-
dependencyRecomputations: () => number;
|
|
41
|
-
resetDependencyRecomputations: () => void;
|
|
42
|
-
} & {
|
|
43
|
-
memoize: typeof import("reselect").weakMapMemoize;
|
|
44
|
-
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
45
|
-
};
|
|
10
|
+
}, []>;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ChartAnyPluginSignature, ChartState } from "../models/index.js";
|
|
3
|
-
export type ChartRootSelector<TSignature extends ChartAnyPluginSignature> = <
|
|
4
|
-
export type ChartOptionalRootSelector<TSignature extends ChartAnyPluginSignature> = <
|
|
5
|
-
export type ChartsSelector<
|
|
1
|
+
import { SelectorArray, Combiner, Selector, GetStateFromSelectors, GetParamsFromSelectors, CreateSelectorOptions } from 'reselect';
|
|
2
|
+
import { ChartAnyPluginSignature, ChartState, ChartStateCacheKey } from "../models/index.js";
|
|
3
|
+
export type ChartRootSelector<TSignature extends ChartAnyPluginSignature> = Selector<ChartState<[TSignature]>, TSignature['state'][keyof TSignature['state']]>;
|
|
4
|
+
export type ChartOptionalRootSelector<TSignature extends ChartAnyPluginSignature> = Selector<ChartState<[], [TSignature]>, TSignature['state'][keyof TSignature['state']] | undefined>;
|
|
5
|
+
export type ChartsSelector<Signatures extends readonly ChartAnyPluginSignature[] = [], OptionalSignatures extends readonly ChartAnyPluginSignature[] = [], Result = unknown, Args extends readonly any[] = []> = Selector<ChartState<Signatures, OptionalSignatures>, Result, Args>;
|
|
6
|
+
type InterruptRecursion = NonNullable<unknown>;
|
|
7
|
+
type AnyFunction = (...args: any[]) => any;
|
|
8
|
+
export type Simplify<T> = T extends AnyFunction ? T : { [KeyType in keyof T]: T[KeyType] } & NonNullable<unknown>;
|
|
6
9
|
/**
|
|
7
10
|
* Method wrapping reselect's createSelector to provide caching for chart instances.
|
|
8
11
|
*
|
|
9
12
|
*/
|
|
10
|
-
export declare const createSelector:
|
|
13
|
+
export declare const createSelector: <InputSelectors extends SelectorArray<any>, Result>(...createSelectorArgs: [inputSelectors: [...InputSelectors], combiner: Combiner<InputSelectors, Result>, createSelectorOptions?: Simplify<CreateSelectorOptions<any,
|
|
14
|
+
// MemoizeFunction,
|
|
15
|
+
any,
|
|
16
|
+
// ArgsMemoizeFunction,
|
|
17
|
+
any,
|
|
18
|
+
// OverrideMemoizeFunction,
|
|
19
|
+
any>>]) => Selector<GetStateFromSelectors<InputSelectors> & {
|
|
20
|
+
cacheKey: ChartStateCacheKey;
|
|
21
|
+
}, Result, GetParamsFromSelectors<InputSelectors> & InterruptRecursion>;
|
|
22
|
+
export {};
|
|
@@ -12,7 +12,7 @@ const cache = new WeakMap();
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
export const createSelector = (...createSelectorArgs) => {
|
|
15
|
-
const selector = (state, selectorArgs) => {
|
|
15
|
+
const selector = (state, ...selectorArgs) => {
|
|
16
16
|
const cacheKey = state.cacheKey;
|
|
17
17
|
|
|
18
18
|
// If there is no cache for the current chart instance, create one.
|
|
@@ -25,13 +25,13 @@ export const createSelector = (...createSelectorArgs) => {
|
|
|
25
25
|
// If there is a cached selector, execute it.
|
|
26
26
|
const cachedSelector = cacheForCurrentChartInstance.get(createSelectorArgs);
|
|
27
27
|
if (cachedSelector) {
|
|
28
|
-
return cachedSelector(state, selectorArgs);
|
|
28
|
+
return cachedSelector(state, ...selectorArgs);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Otherwise, create a new selector and cache it and execute it.
|
|
32
32
|
const fn = reselectCreateSelector(...createSelectorArgs);
|
|
33
33
|
cacheForCurrentChartInstance.set(createSelectorArgs, fn);
|
|
34
|
-
return fn(state, selectorArgs);
|
|
34
|
+
return fn(state, ...selectorArgs);
|
|
35
35
|
};
|
|
36
36
|
return selector;
|
|
37
37
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartAnyPluginSignature
|
|
1
|
+
import { ChartAnyPluginSignature } from "../plugins/models/index.js";
|
|
2
2
|
import { ChartsSelector } from "../plugins/utils/selectors.js";
|
|
3
3
|
import { ChartStore } from "../plugins/utils/ChartStore.js";
|
|
4
|
-
export declare const useSelector: <TSignatures extends readonly ChartAnyPluginSignature[], TOptionalSignatures extends readonly ChartAnyPluginSignature[], TArgs,
|
|
4
|
+
export declare const useSelector: <TSignatures extends readonly ChartAnyPluginSignature[], TOptionalSignatures extends readonly ChartAnyPluginSignature[], TArgs extends readonly any[], TResult = unknown>(store: ChartStore<TSignatures, TOptionalSignatures>, selector: ChartsSelector<TSignatures, TOptionalSignatures, TResult, TArgs>, args?: [TArgs] extends [never] ? [] : TArgs, equals?: (a: TResult, b: TResult) => boolean) => TResult;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* More info: https://github.com/mui/mui-x/issues/18303#issuecomment-2958392341 */
|
|
3
3
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';
|
|
4
4
|
const defaultCompare = Object.is;
|
|
5
|
-
export const useSelector = (store, selector, args =
|
|
6
|
-
const selectorWithArgs = state => selector(state, args);
|
|
5
|
+
export const useSelector = (store, selector, args = [], equals = defaultCompare) => {
|
|
6
|
+
const selectorWithArgs = state => selector(state, ...args);
|
|
7
7
|
return useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, selectorWithArgs, equals);
|
|
8
8
|
};
|
package/esm/locales/enUS.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export declare const enUS: {
|
|
|
10
10
|
noData?: string | undefined;
|
|
11
11
|
zoomIn?: string | undefined;
|
|
12
12
|
zoomOut?: string | undefined;
|
|
13
|
+
toolbarExport?: string | undefined;
|
|
14
|
+
toolbarExportPrint?: string | undefined;
|
|
15
|
+
toolbarExportImage?: ((mimeType: import("./utils/imageMimeTypes.js").ChartImageExportMimeType | (string & {})) => string) | undefined;
|
|
13
16
|
};
|
|
14
17
|
};
|
|
15
18
|
};
|
package/esm/locales/enUS.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { imageMimeTypes } from "./utils/imageMimeTypes.js";
|
|
1
2
|
import { getChartsLocalization } from "./utils/getChartsLocalization.js";
|
|
2
3
|
|
|
3
4
|
// This object is not Partial<ChartsLocaleText> because it is the default values
|
|
4
5
|
|
|
5
6
|
export const enUSLocaleText = {
|
|
6
|
-
|
|
7
|
+
/* Overlay */
|
|
7
8
|
loading: 'Loading data…',
|
|
8
9
|
noData: 'No data to display',
|
|
10
|
+
/* Toolbar */
|
|
9
11
|
zoomIn: 'Zoom in',
|
|
10
|
-
zoomOut: 'Zoom out'
|
|
12
|
+
zoomOut: 'Zoom out',
|
|
13
|
+
toolbarExport: 'Export',
|
|
14
|
+
/* Toolbar Export Menu */
|
|
15
|
+
toolbarExportPrint: 'Print',
|
|
16
|
+
toolbarExportImage: mimeType => `Export as ${imageMimeTypes[mimeType] ?? mimeType}`
|
|
11
17
|
};
|
|
12
18
|
export const DEFAULT_LOCALE = enUSLocaleText;
|
|
13
19
|
export const enUS = getChartsLocalization(enUSLocaleText);
|
package/esm/locales/frFR.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare const frFR: {
|
|
|
9
9
|
noData?: string | undefined;
|
|
10
10
|
zoomIn?: string | undefined;
|
|
11
11
|
zoomOut?: string | undefined;
|
|
12
|
+
toolbarExport?: string | undefined;
|
|
13
|
+
toolbarExportPrint?: string | undefined;
|
|
14
|
+
toolbarExportImage?: ((mimeType: import("./utils/imageMimeTypes.js").ChartImageExportMimeType | (string & {})) => string) | undefined;
|
|
12
15
|
};
|
|
13
16
|
};
|
|
14
17
|
};
|
package/esm/locales/frFR.js
CHANGED
|
@@ -3,7 +3,14 @@ export const frFRLocalText = {
|
|
|
3
3
|
// Overlay
|
|
4
4
|
loading: 'Chargement…',
|
|
5
5
|
noData: 'Pas de données'
|
|
6
|
+
|
|
7
|
+
// Toolbar
|
|
6
8
|
// zoomIn: 'Zoom in',
|
|
7
9
|
// zoomOut: 'Zoom out',
|
|
10
|
+
// toolbarExport: 'Export',
|
|
11
|
+
|
|
12
|
+
// Toolbar Export Menu
|
|
13
|
+
// toolbarExportPrint: 'Print',
|
|
14
|
+
// toolbarExportImage: mimeType => `Export as ${imageMimeTypes[mimeType] ?? mimeType}`,
|
|
8
15
|
};
|
|
9
16
|
export const frFR = getChartsLocalization(frFRLocalText);
|
package/esm/locales/ptBR.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare const ptBR: {
|
|
|
9
9
|
noData?: string | undefined;
|
|
10
10
|
zoomIn?: string | undefined;
|
|
11
11
|
zoomOut?: string | undefined;
|
|
12
|
+
toolbarExport?: string | undefined;
|
|
13
|
+
toolbarExportPrint?: string | undefined;
|
|
14
|
+
toolbarExportImage?: ((mimeType: import("./utils/imageMimeTypes.js").ChartImageExportMimeType | (string & {})) => string) | undefined;
|
|
12
15
|
};
|
|
13
16
|
};
|
|
14
17
|
};
|
package/esm/locales/ptBR.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { imageMimeTypes } from "./utils/imageMimeTypes.js";
|
|
1
2
|
import { getChartsLocalization } from "./utils/getChartsLocalization.js";
|
|
2
3
|
export const ptBRLocaleText = {
|
|
3
4
|
// Overlay
|
|
4
5
|
loading: 'Carregando dados…',
|
|
5
6
|
noData: 'Sem dados para exibir',
|
|
7
|
+
// Toolbar
|
|
6
8
|
zoomIn: 'Aumentar zoom',
|
|
7
|
-
zoomOut: 'Diminuir zoom'
|
|
9
|
+
zoomOut: 'Diminuir zoom',
|
|
10
|
+
toolbarExport: 'Exportar',
|
|
11
|
+
// Toolbar Export Menu
|
|
12
|
+
toolbarExportPrint: 'Imprimir',
|
|
13
|
+
toolbarExportImage: mimeType => `Exportar como ${imageMimeTypes[mimeType] ?? mimeType}`
|
|
8
14
|
};
|
|
9
15
|
export const ptBR = getChartsLocalization(ptBRLocaleText);
|
package/esm/locales/ptPT.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare const ptPT: {
|
|
|
9
9
|
noData?: string | undefined;
|
|
10
10
|
zoomIn?: string | undefined;
|
|
11
11
|
zoomOut?: string | undefined;
|
|
12
|
+
toolbarExport?: string | undefined;
|
|
13
|
+
toolbarExportPrint?: string | undefined;
|
|
14
|
+
toolbarExportImage?: ((mimeType: import("./utils/imageMimeTypes.js").ChartImageExportMimeType | (string & {})) => string) | undefined;
|
|
12
15
|
};
|
|
13
16
|
};
|
|
14
17
|
};
|
package/esm/locales/ptPT.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { imageMimeTypes } from "./utils/imageMimeTypes.js";
|
|
1
2
|
import { getChartsLocalization } from "./utils/getChartsLocalization.js";
|
|
2
3
|
export const ptPTLocaleText = {
|
|
3
4
|
// Overlay
|
|
4
5
|
loading: 'Carregando dados…',
|
|
5
6
|
noData: 'Sem dados para mostrar',
|
|
7
|
+
// Toolbar
|
|
6
8
|
zoomIn: 'Aumentar zoom',
|
|
7
|
-
zoomOut: 'Diminuir zoom'
|
|
9
|
+
zoomOut: 'Diminuir zoom',
|
|
10
|
+
toolbarExport: 'Exportar',
|
|
11
|
+
// Toolbar Export Menu
|
|
12
|
+
toolbarExportPrint: 'Imprimir',
|
|
13
|
+
toolbarExportImage: mimeType => `Exportar como ${imageMimeTypes[mimeType] ?? mimeType}`
|
|
8
14
|
};
|
|
9
15
|
export const ptPT = getChartsLocalization(ptPTLocaleText);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChartImageExportMimeType } from "./imageMimeTypes.js";
|
|
1
2
|
export interface ChartsLocaleText {
|
|
2
3
|
/**
|
|
3
4
|
* Title displayed in the overlay if `loading` is `true`.
|
|
@@ -15,5 +16,21 @@ export interface ChartsLocaleText {
|
|
|
15
16
|
* Tooltip text shown when hovering over the zoom out button.
|
|
16
17
|
*/
|
|
17
18
|
zoomOut: string;
|
|
19
|
+
/**
|
|
20
|
+
* Text for the export button tooltip in the toolbar.
|
|
21
|
+
*/
|
|
22
|
+
toolbarExport: string;
|
|
23
|
+
/**
|
|
24
|
+
* Text for the print button in the toolbar's export menu.
|
|
25
|
+
*/
|
|
26
|
+
toolbarExportPrint: string;
|
|
27
|
+
/**
|
|
28
|
+
* Text for an "Export as {image type}" button in the toolbar's export menu.
|
|
29
|
+
* The only format supported in all browsers is 'image/png'.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} mimeType The MIME type of the image to export, e.g., 'image/png'.
|
|
32
|
+
* @returns {string} The localized string for an export image button.
|
|
33
|
+
*/
|
|
34
|
+
toolbarExportImage: (mimeType: ChartImageExportMimeType | (string & {})) => string;
|
|
18
35
|
}
|
|
19
36
|
export type ChartsTranslationKeys = keyof ChartsLocaleText;
|
|
@@ -13,6 +13,9 @@ export declare const getChartsLocalization: (chartsTranslations: Partial<ChartsL
|
|
|
13
13
|
noData?: string | undefined;
|
|
14
14
|
zoomIn?: string | undefined;
|
|
15
15
|
zoomOut?: string | undefined;
|
|
16
|
+
toolbarExport?: string | undefined;
|
|
17
|
+
toolbarExportPrint?: string | undefined;
|
|
18
|
+
toolbarExportImage?: ((mimeType: import("./imageMimeTypes.js").ChartImageExportMimeType | (string & {})) => string) | undefined;
|
|
16
19
|
};
|
|
17
20
|
};
|
|
18
21
|
};
|
|
@@ -7,14 +7,18 @@ export type ChartBaseCommonProps<T = HTMLElement> = React.DOMAttributes<T> & {
|
|
|
7
7
|
};
|
|
8
8
|
export type ChartBaseIconProps = ChartBaseCommonProps<SVGSVGElement> & {
|
|
9
9
|
titleAccess?: string;
|
|
10
|
+
fontSize?: 'small' | 'medium' | 'large' | 'inherit';
|
|
10
11
|
};
|
|
11
12
|
export type ChartBaseButtonProps = ChartBaseCommonProps & {
|
|
12
13
|
ref?: React.Ref<HTMLButtonElement>;
|
|
14
|
+
id?: string;
|
|
13
15
|
disabled?: boolean;
|
|
14
16
|
tabIndex?: number;
|
|
15
17
|
};
|
|
16
18
|
export type ChartBaseIconButtonProps = ChartBaseCommonProps & {
|
|
17
19
|
ref?: React.Ref<HTMLButtonElement>;
|
|
20
|
+
id?: string;
|
|
18
21
|
disabled?: boolean;
|
|
19
22
|
tabIndex?: number;
|
|
23
|
+
size?: 'small' | 'medium' | 'large';
|
|
20
24
|
};
|
|
@@ -19,8 +19,8 @@ var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHi
|
|
|
19
19
|
*/
|
|
20
20
|
function useItemHighlighted(item) {
|
|
21
21
|
const store = (0, _useStore.useStore)();
|
|
22
|
-
const isHighlighted = (0, _useSelector.useSelector)(store, _useChartHighlight.selectorChartsIsHighlighted, item);
|
|
23
|
-
const isFaded = (0, _useSelector.useSelector)(store, _useChartHighlight.selectorChartsIsFaded, item);
|
|
22
|
+
const isHighlighted = (0, _useSelector.useSelector)(store, _useChartHighlight.selectorChartsIsHighlighted, [item]);
|
|
23
|
+
const isFaded = (0, _useSelector.useSelector)(store, _useChartHighlight.selectorChartsIsFaded, [item]);
|
|
24
24
|
return {
|
|
25
25
|
isHighlighted,
|
|
26
26
|
isFaded: !isHighlighted && isFaded
|
package/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* This component is used to assert that a certain component should not be rendered.
|
|
4
|
+
* It is used in cases where we want to apply styles to a component that is not rendered because we use the `as` prop (introduced by `styled`) to replace the rendered component.
|
|
5
|
+
* We need it because we don't know the component that will be rendered at the time of writing the styles.
|
|
6
|
+
*
|
|
7
|
+
* @param _props Not used
|
|
8
|
+
*/
|
|
9
|
+
export declare function NotRendered<T>(_props: T): React.ReactNode;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NotRendered = NotRendered;
|
|
7
|
+
/**
|
|
8
|
+
* This component is used to assert that a certain component should not be rendered.
|
|
9
|
+
* It is used in cases where we want to apply styles to a component that is not rendered because we use the `as` prop (introduced by `styled`) to replace the rendered component.
|
|
10
|
+
* We need it because we don't know the component that will be rendered at the time of writing the styles.
|
|
11
|
+
*
|
|
12
|
+
* @param _props Not used
|
|
13
|
+
*/
|
|
14
|
+
function NotRendered(_props) {
|
|
15
|
+
throw new Error('Failed assertion: should not be rendered');
|
|
16
|
+
}
|
|
@@ -38,11 +38,11 @@ function createSeriesSelectorsOfType(seriesType) {
|
|
|
38
38
|
});
|
|
39
39
|
return ids => {
|
|
40
40
|
const store = (0, _useStore.useStore)();
|
|
41
|
-
return (0, _useSelector.useSelector)(store, selectorSeriesWithIds, ids, _fastArrayCompare.fastArrayCompare);
|
|
41
|
+
return (0, _useSelector.useSelector)(store, selectorSeriesWithIds, [ids], _fastArrayCompare.fastArrayCompare);
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function createAllSeriesSelectorOfType(seriesType) {
|
|
45
|
-
const selectorSeries = (0, _selectors.createSelector)(_useChartSeries.selectorChartSeriesProcessed, processedSeries => processedSeries[seriesType]);
|
|
45
|
+
const selectorSeries = (0, _selectors.createSelector)([_useChartSeries.selectorChartSeriesProcessed], processedSeries => processedSeries[seriesType]);
|
|
46
46
|
return () => {
|
|
47
47
|
const store = (0, _useStore.useStore)();
|
|
48
48
|
return (0, _useSelector.useSelector)(store, selectorSeries);
|
package/internals/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./components/ChartsAxesGradients/index.js";
|
|
2
2
|
export * from "./components/ChartsWrapper/index.js";
|
|
3
3
|
export * from "../ChartsLabel/ChartsLabelMark.js";
|
|
4
|
+
export * from "./components/NotRendered.js";
|
|
4
5
|
export { useSeries } from "../hooks/useSeries.js";
|
|
5
6
|
export { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
|
|
6
7
|
export { useDrawingArea } from "../hooks/useDrawingArea.js";
|
package/internals/index.js
CHANGED
|
@@ -111,6 +111,18 @@ Object.keys(_ChartsLabelMark).forEach(function (key) {
|
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
|
+
var _NotRendered = require("./components/NotRendered");
|
|
115
|
+
Object.keys(_NotRendered).forEach(function (key) {
|
|
116
|
+
if (key === "default" || key === "__esModule") return;
|
|
117
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
118
|
+
if (key in exports && exports[key] === _NotRendered[key]) return;
|
|
119
|
+
Object.defineProperty(exports, key, {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: function () {
|
|
122
|
+
return _NotRendered[key];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
114
126
|
var _useSeries = require("../hooks/useSeries");
|
|
115
127
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
116
128
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type { UseChartAnimationSignature } from "./useChartAnimation.types.js";
|
|
3
|
-
export declare const selectorChartSkipAnimation: ((state: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("./useChartAnimation.types.js").UseChartAnimationState & Partial<{}> & {
|
|
1
|
+
export declare const selectorChartSkipAnimation: import("reselect").Selector<import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("./useChartAnimation.types.js").UseChartAnimationState & Partial<{}> & {
|
|
4
2
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
-
}) => boolean) & {
|
|
6
|
-
clearCache: () => void;
|
|
7
|
-
resultsCount: () => number;
|
|
8
|
-
resetResultsCount: () => void;
|
|
9
3
|
} & {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
skipAnimationRequests: number;
|
|
13
|
-
}) => boolean;
|
|
14
|
-
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
15
|
-
skip: boolean;
|
|
16
|
-
skipAnimationRequests: number;
|
|
17
|
-
}) => boolean) & {
|
|
18
|
-
clearCache: () => void;
|
|
19
|
-
resultsCount: () => number;
|
|
20
|
-
resetResultsCount: () => void;
|
|
21
|
-
};
|
|
22
|
-
lastResult: () => boolean;
|
|
23
|
-
dependencies: [ChartRootSelector<UseChartAnimationSignature>];
|
|
24
|
-
recomputations: () => number;
|
|
25
|
-
resetRecomputations: () => void;
|
|
26
|
-
dependencyRecomputations: () => number;
|
|
27
|
-
resetDependencyRecomputations: () => void;
|
|
28
|
-
} & {
|
|
29
|
-
memoize: typeof import("reselect").weakMapMemoize;
|
|
30
|
-
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
31
|
-
};
|
|
4
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
+
}, boolean, any[]>;
|
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.selectorChartSkipAnimation = void 0;
|
|
7
7
|
var _selectors = require("../../utils/selectors");
|
|
8
8
|
const selectorChartAnimationState = state => state.animation;
|
|
9
|
-
const selectorChartSkipAnimation = exports.selectorChartSkipAnimation = (0, _selectors.createSelector)(selectorChartAnimationState, state => state.skip || state.skipAnimationRequests > 0);
|
|
9
|
+
const selectorChartSkipAnimation = exports.selectorChartSkipAnimation = (0, _selectors.createSelector)([selectorChartAnimationState], state => state.skip || state.skipAnimationRequests > 0);
|
|
@@ -15,6 +15,7 @@ var _useSelector = require("../../../store/useSelector");
|
|
|
15
15
|
var _constants = require("../../../../constants");
|
|
16
16
|
var _useChartDimensions = require("./useChartDimensions.selectors");
|
|
17
17
|
var _defaultizeMargin = require("../../../defaultizeMargin");
|
|
18
|
+
var _getSVGPoint = require("../../../getSVGPoint");
|
|
18
19
|
const MAX_COMPUTE_RUN = 10;
|
|
19
20
|
const useChartDimensions = ({
|
|
20
21
|
params,
|
|
@@ -156,16 +157,43 @@ const useChartDimensions = ({
|
|
|
156
157
|
const isYInside = React.useCallback(y => y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height, [drawingArea.height, drawingArea.top]);
|
|
157
158
|
const isPointInside = React.useCallback((x, y, targetElement) => {
|
|
158
159
|
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
159
|
-
if (targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
160
|
+
if (targetElement && 'closest' in targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
160
161
|
return true;
|
|
161
162
|
}
|
|
162
163
|
return isXInside(x) && isYInside(y);
|
|
163
164
|
}, [isXInside, isYInside]);
|
|
165
|
+
const isElementInside = React.useCallback(element => {
|
|
166
|
+
const svgElement = svgRef.current;
|
|
167
|
+
if (!element || !(element instanceof Element) || !svgElement) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
171
|
+
if (element.closest('[data-drawing-container]')) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
const rect = element.getBoundingClientRect();
|
|
175
|
+
const {
|
|
176
|
+
x: left,
|
|
177
|
+
y: top
|
|
178
|
+
} = (0, _getSVGPoint.getSVGPoint)(svgElement, {
|
|
179
|
+
clientX: rect.left,
|
|
180
|
+
clientY: rect.top
|
|
181
|
+
});
|
|
182
|
+
const {
|
|
183
|
+
x: right,
|
|
184
|
+
y: bottom
|
|
185
|
+
} = (0, _getSVGPoint.getSVGPoint)(svgElement, {
|
|
186
|
+
clientX: rect.right,
|
|
187
|
+
clientY: rect.bottom
|
|
188
|
+
});
|
|
189
|
+
return isXInside(left) && isXInside(right) && isYInside(top) && isYInside(bottom);
|
|
190
|
+
}, [isXInside, isYInside, svgRef]);
|
|
164
191
|
return {
|
|
165
192
|
instance: {
|
|
166
193
|
isPointInside,
|
|
167
194
|
isXInside,
|
|
168
|
-
isYInside
|
|
195
|
+
isYInside,
|
|
196
|
+
isElementInside
|
|
169
197
|
}
|
|
170
198
|
};
|
|
171
199
|
};
|