@mui/x-charts 8.11.1 → 8.11.2

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 (76) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
  3. package/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +9 -52
  4. package/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
  5. package/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +15 -51
  6. package/ChartsXAxis/ChartsXAxis.js +4 -6
  7. package/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
  8. package/ChartsXAxis/ChartsXAxisImpl.js +117 -0
  9. package/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -496
  10. package/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -31
  11. package/ChartsXAxis/utilities.d.ts +1 -2
  12. package/ChartsXAxis/utilities.js +1 -7
  13. package/{esm/ChartsYAxis/ChartsGroupedYAxis.d.ts → ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
  14. package/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +9 -52
  15. package/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
  16. package/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +15 -50
  17. package/ChartsYAxis/ChartsYAxis.js +6 -8
  18. package/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
  19. package/ChartsYAxis/ChartsYAxisImpl.js +133 -0
  20. package/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -504
  21. package/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +5 -44
  22. package/ChartsYAxis/utilities.d.ts +0 -1
  23. package/ChartsYAxis/utilities.js +1 -7
  24. package/esm/ChartsXAxis/ChartsGroupedXAxisTicks.d.ts +8 -0
  25. package/esm/ChartsXAxis/{ChartsGroupedXAxis.js → ChartsGroupedXAxisTicks.js} +10 -53
  26. package/esm/ChartsXAxis/ChartsSingleXAxisTicks.d.ts +10 -0
  27. package/esm/ChartsXAxis/{ChartsSingleXAxis.js → ChartsSingleXAxisTicks.js} +16 -54
  28. package/esm/ChartsXAxis/ChartsXAxis.js +4 -6
  29. package/esm/ChartsXAxis/ChartsXAxisImpl.d.ts +13 -0
  30. package/esm/ChartsXAxis/ChartsXAxisImpl.js +110 -0
  31. package/esm/ChartsXAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -496
  32. package/esm/ChartsXAxis/{useAxisProps.js → useAxisTicksProps.js} +3 -29
  33. package/esm/ChartsXAxis/utilities.d.ts +1 -2
  34. package/esm/ChartsXAxis/utilities.js +0 -6
  35. package/{ChartsYAxis/ChartsGroupedYAxis.d.ts → esm/ChartsYAxis/ChartsGroupedYAxisTicks.d.ts} +2 -2
  36. package/esm/ChartsYAxis/{ChartsGroupedYAxis.js → ChartsGroupedYAxisTicks.js} +10 -53
  37. package/esm/ChartsYAxis/ChartsSingleYAxisTicks.d.ts +10 -0
  38. package/esm/ChartsYAxis/{ChartsSingleYAxis.js → ChartsSingleYAxisTicks.js} +16 -53
  39. package/esm/ChartsYAxis/ChartsYAxis.js +5 -7
  40. package/esm/ChartsYAxis/ChartsYAxisImpl.d.ts +13 -0
  41. package/esm/ChartsYAxis/ChartsYAxisImpl.js +126 -0
  42. package/esm/ChartsYAxis/{useAxisProps.d.ts → useAxisTicksProps.d.ts} +1 -504
  43. package/esm/ChartsYAxis/{useAxisProps.js → useAxisTicksProps.js} +4 -42
  44. package/esm/ChartsYAxis/utilities.d.ts +0 -1
  45. package/esm/ChartsYAxis/utilities.js +0 -6
  46. package/esm/hooks/useInteractionItemProps.js +5 -4
  47. package/esm/hooks/useTicks.js +8 -1
  48. package/esm/index.js +1 -1
  49. package/esm/internals/dateHelpers.d.ts +4 -2
  50. package/esm/internals/dateHelpers.js +5 -4
  51. package/esm/internals/defaultValueFormatters.js +5 -0
  52. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
  53. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  54. package/esm/locales/index.d.ts +2 -1
  55. package/esm/locales/index.js +1 -0
  56. package/esm/locales/svSE.d.ts +19 -0
  57. package/esm/locales/svSE.js +15 -0
  58. package/hooks/useInteractionItemProps.js +6 -4
  59. package/hooks/useTicks.js +8 -1
  60. package/index.js +1 -1
  61. package/internals/dateHelpers.d.ts +4 -2
  62. package/internals/dateHelpers.js +5 -4
  63. package/internals/defaultValueFormatters.js +5 -0
  64. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -5
  65. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -2
  66. package/locales/index.d.ts +2 -1
  67. package/locales/index.js +11 -0
  68. package/locales/svSE.d.ts +19 -0
  69. package/locales/svSE.js +21 -0
  70. package/package.json +4 -4
  71. package/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
  72. package/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
  73. package/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
  74. package/esm/ChartsXAxis/ChartsGroupedXAxis.d.ts +0 -7
  75. package/esm/ChartsXAxis/ChartsSingleXAxis.d.ts +0 -7
  76. package/esm/ChartsYAxis/ChartsSingleYAxis.d.ts +0 -7
package/CHANGELOG.md CHANGED
@@ -5,6 +5,101 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.11.2
9
+
10
+ _Sep 10, 2025_
11
+
12
+ We'd like to extend a big thank you to the 13 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 🐞 Bugfixes
15
+ - 📚 Documentation improvements
16
+
17
+ Special thanks go out to the community members for their valuable contributions:
18
+ @ludvigeriksson, @sai6855
19
+
20
+ The following are all team members who have contributed to this release:
21
+ @alexfauquette, @bernardobelchior, @brijeshb42, @flaviendelangle, @Janpot, @LukasTy, @MBilalShafi, @noraleonte, @rita-codes, @romgrk, @siriwatknp
22
+
23
+ ### Data Grid
24
+
25
+ #### `@mui/x-data-grid@8.11.2`
26
+
27
+ - [DataGrid] Allow opting out of the exclude row selection model (#19423) @MBilalShafi
28
+ - [DataGrid] Fix column dropdown menu text alignment for the "Unpin" menu item (#19462) @MBilalShafi
29
+ - [DataGrid] Fix indeterminate state for "Select all" checkbox with exclude model (#19466) @MBilalShafi
30
+ - [DataGrid] Fix styled API arguments error (#19460) @MBilalShafi
31
+ - [DataGrid] Fix `stringify()` for theme objects (#19427) @romgrk
32
+
33
+ #### `@mui/x-data-grid-pro@8.11.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
34
+
35
+ Same changes as in `@mui/x-data-grid@8.11.2`.
36
+
37
+ #### `@mui/x-data-grid-premium@8.11.2` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
38
+
39
+ Same changes as in `@mui/x-data-grid-pro@8.11.2`, plus:
40
+
41
+ - [DataGridPremium] Fallback to the regular reorder method for plain data (#19467) @MBilalShafi
42
+ - [DataGridPremium] Fix showing `0` as total aggregation value when aggregation position is set to `null` for row groups (#19515) @cherniavskii
43
+
44
+ ### Date and Time Pickers
45
+
46
+ #### `@mui/x-date-pickers@8.11.2`
47
+
48
+ - [pickers] Gracefully handle `textField.slotProps` (#18980) @LukasTy
49
+ - [pickers] Improve hour and minute placement in Date Time Picker (#19227) @MBilalShafi
50
+ - [pickers] Use `calendarState.currentMonth` in Month Calendar when available (#19073) @LukasTy
51
+ - [pickers] Improve invalid value pasting into a section (#19357) @sai6855
52
+ - [fields] Remove redundant `id` and `aria-labelledby` attributes from spinbuttons (#19523) @LukasTy
53
+
54
+ #### `@mui/x-date-pickers-pro@8.11.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
55
+
56
+ Same changes as in `@mui/x-date-pickers@8.11.2`.
57
+
58
+ ### Charts
59
+
60
+ #### `@mui/x-charts@8.11.2`
61
+
62
+ - [charts] Fix highlight regression (#19486) @alexfauquette
63
+ - [charts] Improve code reuse in `ChartsXAxis` and `ChartsYAxis` (#19198) @bernardobelchior
64
+ - [charts] Simplify params in `getRange` and `createDateFormatter` (#19517) @bernardobelchior
65
+ - [charts] Handle domain edge cases with `filterMode: 'discard'` (#19199) @bernardobelchior
66
+ - [l10n] Add Swedish (sv-SE) locale (#19489) @ludvigeriksson
67
+
68
+ #### `@mui/x-charts-pro@8.11.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
69
+
70
+ Same changes as in `@mui/x-charts@8.11.2`.
71
+
72
+ ### Tree View
73
+
74
+ #### `@mui/x-tree-view@8.11.2`
75
+
76
+ - [TreeView] Do not mutate `props.items` in the `getItemTree()` method (#19483) @flaviendelangle
77
+ - [TreeView] Expose a new hook to apply selection propagation on the selected items (#19402) @flaviendelangle
78
+
79
+ #### `@mui/x-tree-view-pro@8.11.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
80
+
81
+ Same changes as in `@mui/x-tree-view@8.11.2`.
82
+
83
+ ### Codemod
84
+
85
+ #### `@mui/x-codemod@8.11.2`
86
+
87
+ Internal changes.
88
+
89
+ ### Docs
90
+
91
+ - [docs] Add recipe for save and manage filters from the panel (#19361) @siriwatknp
92
+
93
+ ### Core
94
+
95
+ - [code-infra] Remove log when restarting dev server (#19490) @bernardobelchior
96
+ - [code-infra] Store test results in CI (#19507) @Janpot
97
+
98
+ ### Miscellaneous
99
+
100
+ - [infra] Set nodejs versions of various CIs to 22.18 (#19503) @brijeshb42
101
+ - [test] Split infinitive @romgrk
102
+
8
103
  ## 8.11.1
9
104
 
10
105
  _Sep 4, 2025_
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { ChartsXAxisProps } from "../models/axis.js";
3
+ interface ChartsGroupedXAxisProps extends ChartsXAxisProps {}
4
+ /**
5
+ * @ignore - internal component.
6
+ */
7
+ declare function ChartsGroupedXAxisTicks(inProps: ChartsGroupedXAxisProps): React.JSX.Element;
8
+ export { ChartsGroupedXAxisTicks };
@@ -6,15 +6,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.ChartsGroupedXAxis = ChartsGroupedXAxis;
9
+ exports.ChartsGroupedXAxisTicks = ChartsGroupedXAxisTicks;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
- var _useDrawingArea = require("../hooks/useDrawingArea");
13
12
  var _isBandScale = require("../internals/isBandScale");
14
13
  var _useChartContext = require("../context/ChartProvider/useChartContext");
15
14
  var _utilities = require("./utilities");
16
15
  var _useTicksGrouped = require("../hooks/useTicksGrouped");
17
- var _useAxisProps = require("./useAxisProps");
16
+ var _useAxisTicksProps = require("./useAxisTicksProps");
18
17
  var _jsxRuntime = require("react/jsx-runtime");
19
18
  const DEFAULT_GROUPING_CONFIG = {
20
19
  tickSize: 6
@@ -27,58 +26,36 @@ const getGroupingConfig = (groups, groupIndex, tickSize) => {
27
26
  tickSize: config.tickSize ?? calculatedTickSize
28
27
  });
29
28
  };
30
-
31
29
  /**
32
30
  * @ignore - internal component.
33
31
  */
34
- function ChartsGroupedXAxis(inProps) {
32
+ function ChartsGroupedXAxisTicks(inProps) {
35
33
  const {
36
34
  xScale,
37
35
  defaultizedProps,
38
36
  tickNumber,
39
37
  positionSign,
40
- skipAxisRendering,
41
38
  classes,
42
- Line,
43
39
  Tick,
44
40
  TickLabel,
45
- Label,
46
- axisTickLabelProps,
47
- axisLabelProps
48
- } = (0, _useAxisProps.useAxisProps)(inProps);
41
+ axisTickLabelProps
42
+ } = (0, _useAxisTicksProps.useAxisTicksProps)(inProps);
49
43
  if (!(0, _isBandScale.isBandScale)(xScale)) {
50
44
  throw new Error('MUI X Charts: ChartsGroupedXAxis only supports the `band` and `point` scale types.');
51
45
  }
52
46
  const {
53
- position,
54
- disableLine,
55
47
  disableTicks,
56
- label,
57
48
  tickSize,
58
49
  valueFormatter,
59
50
  slotProps,
60
51
  tickInterval,
61
52
  tickPlacement,
62
- tickLabelPlacement,
63
- sx,
64
- offset,
65
- height: axisHeight
53
+ tickLabelPlacement
66
54
  } = defaultizedProps;
67
55
  const groups = defaultizedProps.groups;
68
- const drawingArea = (0, _useDrawingArea.useDrawingArea)();
69
- const {
70
- left,
71
- top,
72
- width,
73
- height
74
- } = drawingArea;
75
56
  const {
76
57
  instance
77
58
  } = (0, _useChartContext.useChartContext)();
78
- const labelRefPoint = {
79
- x: left + width / 2,
80
- y: positionSign * axisHeight
81
- };
82
59
  const xTicks = (0, _useTicksGrouped.useTicksGrouped)({
83
60
  scale: xScale,
84
61
  tickNumber,
@@ -89,23 +66,8 @@ function ChartsGroupedXAxis(inProps) {
89
66
  direction: 'x',
90
67
  groups
91
68
  });
92
-
93
- // Skip axis rendering if no data is available
94
- // - The domain is an empty array for band/point scales.
95
- // - The domains contains Infinity for continuous scales.
96
- // - The position is set to 'none'.
97
- if (skipAxisRendering) {
98
- return null;
99
- }
100
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_utilities.XAxisRoot, {
101
- transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
102
- className: classes.root,
103
- sx: sx,
104
- children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
105
- x1: left,
106
- x2: left + width,
107
- className: classes.line
108
- }, slotProps?.axisLine)), xTicks.map((item, index) => {
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
70
+ children: xTicks.map((item, index) => {
109
71
  const {
110
72
  offset: tickOffset,
111
73
  labelOffset
@@ -133,11 +95,6 @@ function ChartsGroupedXAxis(inProps) {
133
95
  text: tickLabel
134
96
  }))]
135
97
  }, index);
136
- }), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
137
- className: classes.label,
138
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
139
- text: label
140
- }))
141
- })]
98
+ })
142
99
  });
143
100
  }
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { ChartsXAxisProps } from "../models/axis.js";
3
+ interface ChartsSingleXAxisProps extends ChartsXAxisProps {
4
+ axisLabelHeight: number;
5
+ }
6
+ /**
7
+ * @ignore - internal component.
8
+ */
9
+ declare function ChartsSingleXAxisTicks(inProps: ChartsSingleXAxisProps): React.JSX.Element;
10
+ export { ChartsSingleXAxisTicks };
@@ -6,11 +6,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.ChartsSingleXAxis = ChartsSingleXAxis;
9
+ exports.ChartsSingleXAxisTicks = ChartsSingleXAxisTicks;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
+ var _RtlProvider = require("@mui/system/RtlProvider");
12
13
  var _useIsHydrated = require("../hooks/useIsHydrated");
13
- var _domUtils = require("../internals/domUtils");
14
14
  var _useTicks = require("../hooks/useTicks");
15
15
  var _useMounted = require("../hooks/useMounted");
16
16
  var _useDrawingArea = require("../hooks/useDrawingArea");
@@ -18,33 +18,30 @@ var _useChartContext = require("../context/ChartProvider/useChartContext");
18
18
  var _shortenLabels = require("./shortenLabels");
19
19
  var _getVisibleLabels = require("./getVisibleLabels");
20
20
  var _utilities = require("./utilities");
21
- var _useAxisProps = require("./useAxisProps");
21
+ var _useAxisTicksProps = require("./useAxisTicksProps");
22
22
  var _jsxRuntime = require("react/jsx-runtime");
23
23
  /**
24
24
  * @ignore - internal component.
25
- */function ChartsSingleXAxis(inProps) {
25
+ */
26
+ function ChartsSingleXAxisTicks(inProps) {
27
+ const {
28
+ axisLabelHeight
29
+ } = inProps;
26
30
  const {
27
31
  xScale,
28
32
  defaultizedProps,
29
33
  tickNumber,
30
34
  positionSign,
31
- skipAxisRendering,
32
35
  classes,
33
- Line,
34
36
  Tick,
35
37
  TickLabel,
36
- Label,
37
38
  axisTickLabelProps,
38
- axisLabelProps,
39
- reverse,
40
- isRtl
41
- } = (0, _useAxisProps.useAxisProps)(inProps);
39
+ reverse
40
+ } = (0, _useAxisTicksProps.useAxisTicksProps)(inProps);
41
+ const isRtl = (0, _RtlProvider.useRtl)();
42
42
  const isMounted = (0, _useMounted.useMounted)();
43
43
  const {
44
- position,
45
- disableLine,
46
44
  disableTicks,
47
- label,
48
45
  tickSize: tickSizeProp,
49
46
  valueFormatter,
50
47
  slotProps,
@@ -53,17 +50,9 @@ var _jsxRuntime = require("react/jsx-runtime");
53
50
  tickPlacement,
54
51
  tickLabelPlacement,
55
52
  tickLabelMinGap,
56
- sx,
57
- offset,
58
53
  height: axisHeight
59
54
  } = defaultizedProps;
60
55
  const drawingArea = (0, _useDrawingArea.useDrawingArea)();
61
- const {
62
- left,
63
- top,
64
- width,
65
- height
66
- } = drawingArea;
67
56
  const {
68
57
  instance
69
58
  } = (0, _useChartContext.useChartContext)();
@@ -87,31 +76,11 @@ var _jsxRuntime = require("react/jsx-runtime");
87
76
  isXInside: instance.isXInside
88
77
  });
89
78
 
90
- // Skip axis rendering if no data is available
91
- // - The domain is an empty array for band/point scales.
92
- // - The domains contains Infinity for continuous scales.
93
- // - The position is set to 'none'.
94
- if (skipAxisRendering) {
95
- return null;
96
- }
97
- const labelHeight = label ? (0, _domUtils.getStringSize)(label, axisLabelProps.style).height : 0;
98
- const labelRefPoint = {
99
- x: left + width / 2,
100
- y: positionSign * axisHeight
101
- };
102
-
103
79
  /* If there's an axis title, the tick labels have less space to render */
104
- const tickLabelsMaxHeight = Math.max(0, axisHeight - (label ? labelHeight + _utilities.AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - _utilities.TICK_LABEL_GAP);
80
+ const tickLabelsMaxHeight = Math.max(0, axisHeight - (axisLabelHeight > 0 ? axisLabelHeight + _utilities.AXIS_LABEL_TICK_LABEL_GAP : 0) - tickSize - _utilities.TICK_LABEL_GAP);
105
81
  const tickLabels = isHydrated ? (0, _shortenLabels.shortenLabels)(visibleLabels, drawingArea, tickLabelsMaxHeight, isRtl, axisTickLabelProps.style) : new Map(Array.from(visibleLabels).map(item => [item, item.formattedValue]));
106
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_utilities.XAxisRoot, {
107
- transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
108
- className: classes.root,
109
- sx: sx,
110
- children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
111
- x1: left,
112
- x2: left + width,
113
- className: classes.line
114
- }, slotProps?.axisLine)), xTicks.map((item, index) => {
82
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
83
+ children: xTicks.map((item, index) => {
115
84
  const {
116
85
  offset: tickOffset,
117
86
  labelOffset
@@ -134,11 +103,6 @@ var _jsxRuntime = require("react/jsx-runtime");
134
103
  text: tickLabel
135
104
  }))]
136
105
  }, index);
137
- }), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
138
- className: classes.label,
139
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
140
- text: label
141
- }))
142
- })]
106
+ })
143
107
  });
144
108
  }
@@ -12,8 +12,7 @@ var React = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _warning = require("@mui/x-internals/warning");
14
14
  var _useAxis = require("../hooks/useAxis");
15
- var _ChartsSingleXAxis = require("./ChartsSingleXAxis");
16
- var _ChartsGroupedXAxis = require("./ChartsGroupedXAxis");
15
+ var _ChartsXAxisImpl = require("./ChartsXAxisImpl");
17
16
  var _jsxRuntime = require("react/jsx-runtime");
18
17
  /**
19
18
  * Demos:
@@ -33,10 +32,9 @@ var _jsxRuntime = require("react/jsx-runtime");
33
32
  (0, _warning.warnOnce)(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
34
33
  return null;
35
34
  }
36
- if ('groups' in axis && Array.isArray(axis.groups)) {
37
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGroupedXAxis.ChartsGroupedXAxis, (0, _extends2.default)({}, inProps));
38
- }
39
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSingleXAxis.ChartsSingleXAxis, (0, _extends2.default)({}, inProps));
35
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXAxisImpl.ChartsXAxisImpl, (0, _extends2.default)({}, inProps, {
36
+ axis: axis
37
+ }));
40
38
  }
41
39
  process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
42
40
  // ----------------------------- Warning --------------------------------
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { AxisScaleConfig, ChartsXAxisProps, ComputedAxis } from "../models/axis.js";
3
+ interface ChartsXAxisImplProps extends Omit<ChartsXAxisProps, 'axis'> {
4
+ axis: ComputedAxis<keyof AxisScaleConfig, any, ChartsXAxisProps>;
5
+ }
6
+ /**
7
+ * @ignore - internal component. Use `ChartsXAxis` instead.
8
+ */
9
+ export declare function ChartsXAxisImpl({
10
+ axis,
11
+ ...inProps
12
+ }: ChartsXAxisImplProps): React.JSX.Element | null;
13
+ export {};
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.ChartsXAxisImpl = ChartsXAxisImpl;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
+ var React = _interopRequireWildcard(require("react"));
13
+ var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _ChartsSingleXAxisTicks = require("./ChartsSingleXAxisTicks");
16
+ var _ChartsGroupedXAxisTicks = require("./ChartsGroupedXAxisTicks");
17
+ var _ChartsText = require("../ChartsText");
18
+ var _isBandScale = require("../internals/isBandScale");
19
+ var _isInfinity = require("../internals/isInfinity");
20
+ var _utilities = require("./utilities");
21
+ var _hooks = require("../hooks");
22
+ var _domUtils = require("../internals/domUtils");
23
+ var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+ const _excluded = ["axis"],
26
+ _excluded2 = ["scale", "tickNumber", "reverse"];
27
+ const XAxisRoot = (0, _styles.styled)(_AxisSharedComponents.AxisRoot, {
28
+ name: 'MuiChartsXAxis',
29
+ slot: 'Root'
30
+ })({});
31
+ /**
32
+ * @ignore - internal component. Use `ChartsXAxis` instead.
33
+ */
34
+ function ChartsXAxisImpl(_ref) {
35
+ let {
36
+ axis
37
+ } = _ref,
38
+ inProps = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
39
+ const {
40
+ scale: xScale
41
+ } = axis,
42
+ settings = (0, _objectWithoutPropertiesLoose2.default)(axis, _excluded2);
43
+
44
+ // eslint-disable-next-line material-ui/mui-name-matches-component-name
45
+ const themedProps = (0, _styles.useThemeProps)({
46
+ props: (0, _extends2.default)({}, settings, inProps),
47
+ name: 'MuiChartsXAxis'
48
+ });
49
+ const defaultizedProps = (0, _extends2.default)({}, _utilities.defaultProps, themedProps);
50
+ const {
51
+ position,
52
+ labelStyle,
53
+ offset,
54
+ slots,
55
+ slotProps,
56
+ sx,
57
+ disableLine,
58
+ label,
59
+ height: axisHeight
60
+ } = defaultizedProps;
61
+ const theme = (0, _styles.useTheme)();
62
+ const classes = (0, _utilities.useUtilityClasses)(defaultizedProps);
63
+ const {
64
+ left,
65
+ top,
66
+ width,
67
+ height
68
+ } = (0, _hooks.useDrawingArea)();
69
+ const positionSign = position === 'bottom' ? 1 : -1;
70
+ const Line = slots?.axisLine ?? 'line';
71
+ const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
72
+ const axisLabelProps = (0, _useSlotProps.default)({
73
+ elementType: Label,
74
+ externalSlotProps: slotProps?.axisLabel,
75
+ additionalProps: {
76
+ style: (0, _extends2.default)({}, theme.typography.body1, {
77
+ lineHeight: 1,
78
+ fontSize: 14,
79
+ textAnchor: 'middle',
80
+ dominantBaseline: position === 'bottom' ? 'text-after-edge' : 'text-before-edge'
81
+ }, labelStyle)
82
+ },
83
+ ownerState: {}
84
+ });
85
+ if (position === 'none') {
86
+ return null;
87
+ }
88
+ const labelHeight = label ? (0, _domUtils.getStringSize)(label, axisLabelProps.style).height : 0;
89
+ const domain = xScale.domain();
90
+ const isScaleBand = (0, _isBandScale.isBandScale)(xScale);
91
+ const skipTickRendering = isScaleBand && domain.length === 0 || !isScaleBand && domain.some(_isInfinity.isInfinity);
92
+ let children = null;
93
+ if (!skipTickRendering) {
94
+ children = 'groups' in axis && Array.isArray(axis.groups) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGroupedXAxisTicks.ChartsGroupedXAxisTicks, (0, _extends2.default)({}, inProps)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSingleXAxisTicks.ChartsSingleXAxisTicks, (0, _extends2.default)({}, inProps, {
95
+ axisLabelHeight: labelHeight
96
+ }));
97
+ }
98
+ const labelRefPoint = {
99
+ x: left + width / 2,
100
+ y: positionSign * axisHeight
101
+ };
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(XAxisRoot, {
103
+ transform: `translate(0, ${position === 'bottom' ? top + height + offset : top - offset})`,
104
+ className: classes.root,
105
+ sx: sx,
106
+ children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
107
+ x1: left,
108
+ x2: left + width,
109
+ className: classes.line
110
+ }, slotProps?.axisLine)), children, label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
111
+ className: classes.label,
112
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
113
+ text: label
114
+ }))
115
+ })]
116
+ });
117
+ }