@mui/x-tree-view 8.22.0 → 8.23.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/CHANGELOG.md +202 -0
- package/RichTreeView/RichTreeView.js +7 -0
- package/SimpleTreeView/SimpleTreeView.plugins.d.ts +1 -1
- package/TreeItem/TreeItem.js +9 -2
- package/esm/RichTreeView/RichTreeView.js +7 -0
- package/esm/SimpleTreeView/SimpleTreeView.plugins.d.ts +1 -1
- package/esm/TreeItem/TreeItem.js +9 -2
- package/esm/hooks/useApplyPropagationToSelectedItemsOnMount.js +1 -1
- package/esm/hooks/useTreeItemUtils/useTreeItemUtils.js +1 -1
- package/esm/hooks/useTreeViewApiRef.d.ts +1 -1
- package/esm/hooks/useTreeViewApiRef.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/models/treeView.d.ts +1 -0
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +6 -6
- package/esm/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +4 -4
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.js +13 -8
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +4 -0
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +5 -1
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +7 -0
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.utils.d.ts +1 -1
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +1 -0
- package/esm/internals/plugins/useTreeViewJSXItems/itemPlugin.js +6 -4
- package/esm/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +3 -3
- package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +4 -4
- package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +1 -1
- package/esm/internals/plugins/useTreeViewSelection/itemPlugin.js +5 -5
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +3 -2
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.d.ts +6 -1
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.js +7 -2
- package/esm/internals/useTreeView/useTreeView.js +2 -2
- package/esm/useTreeItem/useTreeItem.js +1 -1
- package/esm/useTreeItem/useTreeItem.types.d.ts +5 -0
- package/hooks/useApplyPropagationToSelectedItemsOnMount.js +1 -1
- package/hooks/useTreeItemUtils/useTreeItemUtils.js +1 -1
- package/hooks/useTreeViewApiRef.d.ts +1 -1
- package/hooks/useTreeViewApiRef.js +1 -1
- package/index.js +1 -1
- package/internals/models/treeView.d.ts +1 -0
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +6 -6
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +4 -4
- package/internals/plugins/useTreeViewItems/useTreeViewItems.js +13 -8
- package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +4 -0
- package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +5 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +7 -0
- package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.d.ts +1 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +1 -0
- package/internals/plugins/useTreeViewJSXItems/itemPlugin.js +6 -4
- package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +3 -3
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +4 -4
- package/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +1 -1
- package/internals/plugins/useTreeViewSelection/itemPlugin.js +5 -5
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +3 -2
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.d.ts +6 -1
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.js +7 -2
- package/internals/useTreeView/useTreeView.js +2 -2
- package/package.json +3 -3
- package/useTreeItem/useTreeItem.js +1 -1
- package/useTreeItem/useTreeItem.types.d.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,208 @@
|
|
|
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.23.0
|
|
9
|
+
|
|
10
|
+
_Dec 23, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🧮 Support Data Grid `size`, `size(true)`, and `size(false)` [aggregations for `'boolean'` column type](https://mui.com/x/react-data-grid/aggregation/#usage-with-row-grouping)
|
|
15
|
+
- 🔎 Allow zooming a heatmap
|
|
16
|
+
|
|
17
|
+
Special thanks go out to these community members for their valuable contributions:
|
|
18
|
+
@henkerik, @sai6855
|
|
19
|
+
|
|
20
|
+
The following team members contributed to this release:
|
|
21
|
+
@alelthomas, @alexfauquette, @arminmeh, @bernardobelchior, @brijeshb42, @flaviendelangle, @JCQuintas, @mapache-salvaje, @MBilalShafi, @siriwatknp
|
|
22
|
+
|
|
23
|
+
### Data Grid
|
|
24
|
+
|
|
25
|
+
#### `@mui/x-data-grid@8.23.0`
|
|
26
|
+
|
|
27
|
+
- [DataGrid] Fix columns state and columns prop sync issue (#20703) @arminmeh
|
|
28
|
+
- [DataGrid] Fix filter datetime with seconds (#20557) @siriwatknp
|
|
29
|
+
- [DataGrid] Add new `includeHeaderFilters` flag to include header filters when autosizing columns (#20510) @siriwatknp
|
|
30
|
+
- [DataGrid] Prevent default on `Enter` key down when starting editing (#20751) @siriwatknp
|
|
31
|
+
- [l10n] Improve Portuguese from Portugal (pt-PT) locale (#20722) @Copilot
|
|
32
|
+
|
|
33
|
+
#### `@mui/x-data-grid-pro@8.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
34
|
+
|
|
35
|
+
Same changes as in `@mui/x-data-grid@8.23.0`, plus:
|
|
36
|
+
|
|
37
|
+
- [DataGridPro] Fix crash on rows change in tree data with pagination (#20215) @Copilot
|
|
38
|
+
|
|
39
|
+
#### `@mui/x-data-grid-premium@8.23.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
40
|
+
|
|
41
|
+
Same changes as in `@mui/x-data-grid-pro@8.23.0`, plus:
|
|
42
|
+
|
|
43
|
+
- [DataGridPremium] Add aggregation for `'boolean'` column type (#20683) @arminmeh
|
|
44
|
+
- [DataGridPremium] Fix strategy value computation with row grouping (#20725) @MBilalShafi
|
|
45
|
+
- [DataGridPremium] Handle `isRowSelectable()` checks for the rows missing due to `keepNonExistentRowsSelected` (#20668) @arminmeh
|
|
46
|
+
|
|
47
|
+
### Date and Time Pickers
|
|
48
|
+
|
|
49
|
+
#### `@mui/x-date-pickers@8.23.0`
|
|
50
|
+
|
|
51
|
+
Internal changes.
|
|
52
|
+
|
|
53
|
+
#### `@mui/x-date-pickers-pro@8.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
54
|
+
|
|
55
|
+
Same changes as in `@mui/x-date-pickers@8.23.0`.
|
|
56
|
+
|
|
57
|
+
### Charts
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-charts@8.23.0`
|
|
60
|
+
|
|
61
|
+
- [charts] Custom stack functions implementation (#20679) @JCQuintas
|
|
62
|
+
- [charts] Extract keyboard focus navigation to the series config (#20693) @alexfauquette
|
|
63
|
+
- [charts] Fix demo not wrapping in mobile (#20713) @JCQuintas
|
|
64
|
+
- [charts] Fix missing dependencies in `x-charts-vendor` (#20685) @henkerik
|
|
65
|
+
- [charts] Remove webkit test differences (#20707) @JCQuintas
|
|
66
|
+
|
|
67
|
+
#### `@mui/x-charts-pro@8.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
68
|
+
|
|
69
|
+
Same changes as in `@mui/x-charts@8.23.0`, plus:
|
|
70
|
+
|
|
71
|
+
- [charts-pro] Allow registering preview plots from higher tier packages (#20716) @bernardobelchior
|
|
72
|
+
- [charts-pro] Fix erroneous behavior when adding/removing pointers from zoom&pan gestures (#20698) @JCQuintas
|
|
73
|
+
- [charts-pro] Move heatmap highlight handling to plot component (#20701) @bernardobelchior
|
|
74
|
+
- [charts-pro] Add zoom to heatmap (#20708) @bernardobelchior
|
|
75
|
+
|
|
76
|
+
#### `@mui/x-charts-premium@8.23.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
77
|
+
|
|
78
|
+
Same changes as in `@mui/x-charts-pro@8.23.0`.
|
|
79
|
+
|
|
80
|
+
### Tree View
|
|
81
|
+
|
|
82
|
+
#### `@mui/x-tree-view@8.23.0`
|
|
83
|
+
|
|
84
|
+
- [tree view] Add new APIs to disable selection feature for tree view item (#20666) @siriwatknp
|
|
85
|
+
|
|
86
|
+
#### `@mui/x-tree-view-pro@8.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
87
|
+
|
|
88
|
+
Same changes as in `@mui/x-tree-view@8.23.0`.
|
|
89
|
+
|
|
90
|
+
### Codemod
|
|
91
|
+
|
|
92
|
+
#### `@mui/x-codemod@8.23.0`
|
|
93
|
+
|
|
94
|
+
Internal changes.
|
|
95
|
+
|
|
96
|
+
### Docs
|
|
97
|
+
|
|
98
|
+
- [docs] Clarify feature availability and relationship between Community and Pro/Premium docs (#20714) @mapache-salvaje
|
|
99
|
+
- [docs] Copyedit Tree View docs and apply new component style rules (DX-19) (#20652) @mapache-salvaje
|
|
100
|
+
- [docs] Fix `ColumnPinningDynamicRowHeight` demo (#20750) @sai6855
|
|
101
|
+
- [docs] Clean up Charts docs sidebar (DX-97) (#20700) @alelthomas
|
|
102
|
+
- [docs] Fix tick labels not being shown on a demo (#20718) @sai6855
|
|
103
|
+
|
|
104
|
+
### Core
|
|
105
|
+
|
|
106
|
+
- [code-infra] Bump prettier to 3.7.4 (#20709) @JCQuintas
|
|
107
|
+
- [code-infra] Fix contributor generation logic in changelog script (#20705) @brijeshb42
|
|
108
|
+
|
|
109
|
+
## 8.22.1
|
|
110
|
+
|
|
111
|
+
_Dec 17, 2025_
|
|
112
|
+
|
|
113
|
+
We'd like to extend a big thank you to the 13 contributors who made this release possible. Here are some highlights ✨:
|
|
114
|
+
|
|
115
|
+
- 🌎 Improve Swedish (sv-SE) locale on the Data Grid
|
|
116
|
+
- 🐞 Bugfixes
|
|
117
|
+
|
|
118
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
119
|
+
@KyeongJooni, @VismaAndreasIvarsson
|
|
120
|
+
|
|
121
|
+
The following team members contributed to this release:
|
|
122
|
+
@alelthomas, @alexfauquette, @arminmeh, @bernardobelchior, @Janpot, @JCQuintas, @mapache-salvaje, @michelengelen, @mj12albert, @prakhargupta1, @romgrk, @siriwatknp
|
|
123
|
+
|
|
124
|
+
### Data Grid
|
|
125
|
+
|
|
126
|
+
#### `@mui/x-data-grid@8.22.1`
|
|
127
|
+
|
|
128
|
+
- [data grid] Fix column menu keyboard shortcut (#20621) @mj12albert
|
|
129
|
+
- [data grid] Fix row checkbox disabled state on first render and keep cell focusable (ARIA) (#20641) @michelengelen
|
|
130
|
+
- [data grid] Fix tree data selection bug (#20528) @michelengelen
|
|
131
|
+
- [data grid] Prevent clear cell selection on edit mode (#20544) @siriwatknp
|
|
132
|
+
- [data grid] Refactor column merge logic to prioritize defined properties only (#20640) @michelengelen
|
|
133
|
+
- [data grid] Reset row spanning on row expansion change (#20661) @siriwatknp
|
|
134
|
+
- [data grid] Resize newly added rows while resize action is happening (#20676)
|
|
135
|
+
- [l10n] Improve Swedish (sv-SE) locale (#20682) @VismaAndreasIvarsson
|
|
136
|
+
|
|
137
|
+
#### `@mui/x-data-grid-pro@8.22.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
138
|
+
|
|
139
|
+
Same changes as in `@mui/x-data-grid@8.22.1`.
|
|
140
|
+
|
|
141
|
+
#### `@mui/x-data-grid-premium@8.22.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
142
|
+
|
|
143
|
+
Same changes as in `@mui/x-data-grid-pro@8.22.1`, plus:
|
|
144
|
+
|
|
145
|
+
- [DataGridPremium] Import `useId()` from `@mui/utils` to maintain React 17 compatibility (#20635) @arminmeh
|
|
146
|
+
|
|
147
|
+
### Date and Time Pickers
|
|
148
|
+
|
|
149
|
+
#### `@mui/x-date-pickers@8.22.1`
|
|
150
|
+
|
|
151
|
+
- [pickers] Add minutesStep validation test (#20672) @KyeongJooni
|
|
152
|
+
- [pickers] Fix `onAccept()` returning wrong year after selecting year then month (#20639) @michelengelen
|
|
153
|
+
|
|
154
|
+
#### `@mui/x-date-pickers-pro@8.22.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
155
|
+
|
|
156
|
+
Same changes as in `@mui/x-date-pickers@8.22.1`.
|
|
157
|
+
|
|
158
|
+
### Charts
|
|
159
|
+
|
|
160
|
+
#### `@mui/x-charts@8.22.1`
|
|
161
|
+
|
|
162
|
+
- [charts] Extract `FocusedPieArc` from `PieArcPlot` (#20613) @alexfauquette
|
|
163
|
+
- [charts] Fix regression on the highlight control (#20627) @alexfauquette
|
|
164
|
+
- [charts] Refactor: `useSelector()` => `store.use()` (#20681) @romgrk
|
|
165
|
+
- [charts] Remove duplicated types (#20694) @alexfauquette
|
|
166
|
+
- [charts] Remove unused generics from bar charts (#20642) @bernardobelchior
|
|
167
|
+
- [charts] Simplify tooltip position getter for pie chart (#20625) @alexfauquette
|
|
168
|
+
|
|
169
|
+
#### `@mui/x-charts-pro@8.22.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
170
|
+
|
|
171
|
+
Same changes as in `@mui/x-charts@8.22.1`, plus:
|
|
172
|
+
|
|
173
|
+
- [charts-pro] Add heatmap performance benchmark (#20695) @bernardobelchior
|
|
174
|
+
|
|
175
|
+
#### `@mui/x-charts-premium@8.22.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
176
|
+
|
|
177
|
+
Same changes as in `@mui/x-charts-pro@8.22.1`, plus:
|
|
178
|
+
|
|
179
|
+
- [charts-premium] Create `BarChartPremium` (#20643) @bernardobelchior
|
|
180
|
+
|
|
181
|
+
### Tree View
|
|
182
|
+
|
|
183
|
+
#### `@mui/x-tree-view@8.22.1`
|
|
184
|
+
|
|
185
|
+
Internal changes.
|
|
186
|
+
|
|
187
|
+
#### `@mui/x-tree-view-pro@8.22.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
188
|
+
|
|
189
|
+
Same changes as in `@mui/x-tree-view@8.22.1`.
|
|
190
|
+
|
|
191
|
+
### Codemod
|
|
192
|
+
|
|
193
|
+
#### `@mui/x-codemod@8.22.1`
|
|
194
|
+
|
|
195
|
+
Internal changes.
|
|
196
|
+
|
|
197
|
+
### Docs
|
|
198
|
+
|
|
199
|
+
- [docs] Add button to GitHub source code for the Data Grid advanced demos (DX-50) (#20633) @alelthomas
|
|
200
|
+
- [docs] Remove `seriesConfig` to prevent future confusion (#20678) @alexfauquette
|
|
201
|
+
- [docs] Revise the Data Grid's API object doc for clarity and style (#20649) @mapache-salvaje
|
|
202
|
+
- [docs] Update list of charts (#20479) @prakhargupta1
|
|
203
|
+
|
|
204
|
+
### Core
|
|
205
|
+
|
|
206
|
+
- [code-infra] Regression tests improvements (#20441) @Janpot
|
|
207
|
+
- [code-infra] Test utils upgrade (#20592) @Janpot
|
|
208
|
+
- [code-infra] Try to fix the Tree View flacky tests (#20573) @JCQuintas
|
|
209
|
+
|
|
8
210
|
## 8.22.0
|
|
9
211
|
|
|
10
212
|
_Dec 11, 2025_
|
|
@@ -239,6 +239,13 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
|
239
239
|
* @default () => false
|
|
240
240
|
*/
|
|
241
241
|
isItemEditable: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.bool]),
|
|
242
|
+
/**
|
|
243
|
+
* Used to determine if a given item should have selection disabled.
|
|
244
|
+
* @template R
|
|
245
|
+
* @param {R} item The item to check.
|
|
246
|
+
* @returns {boolean} `true` if the item should have selection disabled.
|
|
247
|
+
*/
|
|
248
|
+
isItemSelectionDisabled: _propTypes.default.func,
|
|
242
249
|
/**
|
|
243
250
|
* Horizontal indentation between an item and its children.
|
|
244
251
|
* Examples: 24, "24px", "2rem", "2em".
|
|
@@ -6,4 +6,4 @@ import { UseTreeViewFocusParameters } from "../internals/plugins/useTreeViewFocu
|
|
|
6
6
|
import { ConvertPluginsIntoSignatures } from "../internals/models/index.js";
|
|
7
7
|
export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewItemsSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewExpansionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewSelectionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewFocusSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewKeyboardNavigationSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewJSXItemsSignature>];
|
|
8
8
|
export type SimpleTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
|
|
9
|
-
export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
|
|
9
|
+
export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'isItemSelectionDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
|
package/TreeItem/TreeItem.js
CHANGED
|
@@ -30,7 +30,7 @@ var _TreeItemLabelInput = require("../TreeItemLabelInput");
|
|
|
30
30
|
var _TreeViewStyleContext = require("../internals/TreeViewProvider/TreeViewStyleContext");
|
|
31
31
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
32
32
|
const _excluded = ["visible"],
|
|
33
|
-
_excluded2 = ["id", "itemId", "label", "disabled", "children", "slots", "slotProps", "classes"];
|
|
33
|
+
_excluded2 = ["id", "itemId", "label", "disabled", "disableSelection", "children", "slots", "slotProps", "classes"];
|
|
34
34
|
const useThemeProps = (0, _zeroStyled.createUseThemeProps)('MuiTreeItem');
|
|
35
35
|
const TreeItemRoot = exports.TreeItemRoot = (0, _zeroStyled.styled)('li', {
|
|
36
36
|
name: 'MuiTreeItem',
|
|
@@ -226,6 +226,7 @@ const TreeItem = exports.TreeItem = /*#__PURE__*/React.forwardRef(function TreeI
|
|
|
226
226
|
itemId,
|
|
227
227
|
label,
|
|
228
228
|
disabled,
|
|
229
|
+
disableSelection,
|
|
229
230
|
children,
|
|
230
231
|
slots = {},
|
|
231
232
|
slotProps = {},
|
|
@@ -250,7 +251,8 @@ const TreeItem = exports.TreeItem = /*#__PURE__*/React.forwardRef(function TreeI
|
|
|
250
251
|
itemId,
|
|
251
252
|
children,
|
|
252
253
|
label,
|
|
253
|
-
disabled
|
|
254
|
+
disabled,
|
|
255
|
+
disableSelection
|
|
254
256
|
});
|
|
255
257
|
const classes = useUtilityClasses(classesProp);
|
|
256
258
|
const Root = slots.root ?? TreeItemRoot;
|
|
@@ -373,6 +375,11 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
|
|
|
373
375
|
* @default false
|
|
374
376
|
*/
|
|
375
377
|
disabled: _propTypes.default.bool,
|
|
378
|
+
/**
|
|
379
|
+
* If `true`, the item cannot be selected.
|
|
380
|
+
* @default false
|
|
381
|
+
*/
|
|
382
|
+
disableSelection: _propTypes.default.bool,
|
|
376
383
|
/**
|
|
377
384
|
* The id attribute of the item. If not provided, it will be generated.
|
|
378
385
|
*/
|
|
@@ -232,6 +232,13 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
|
232
232
|
* @default () => false
|
|
233
233
|
*/
|
|
234
234
|
isItemEditable: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
235
|
+
/**
|
|
236
|
+
* Used to determine if a given item should have selection disabled.
|
|
237
|
+
* @template R
|
|
238
|
+
* @param {R} item The item to check.
|
|
239
|
+
* @returns {boolean} `true` if the item should have selection disabled.
|
|
240
|
+
*/
|
|
241
|
+
isItemSelectionDisabled: PropTypes.func,
|
|
235
242
|
/**
|
|
236
243
|
* Horizontal indentation between an item and its children.
|
|
237
244
|
* Examples: 24, "24px", "2rem", "2em".
|
|
@@ -6,4 +6,4 @@ import { UseTreeViewFocusParameters } from "../internals/plugins/useTreeViewFocu
|
|
|
6
6
|
import { ConvertPluginsIntoSignatures } from "../internals/models/index.js";
|
|
7
7
|
export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewItemsSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewExpansionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewSelectionSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewFocusSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewKeyboardNavigationSignature>, import("../internals/index.js").TreeViewPlugin<import("../internals/index.js").UseTreeViewJSXItemsSignature>];
|
|
8
8
|
export type SimpleTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
|
|
9
|
-
export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
|
|
9
|
+
export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'isItemSelectionDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple> {}
|
package/esm/TreeItem/TreeItem.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
const _excluded = ["visible"],
|
|
6
|
-
_excluded2 = ["id", "itemId", "label", "disabled", "children", "slots", "slotProps", "classes"];
|
|
6
|
+
_excluded2 = ["id", "itemId", "label", "disabled", "disableSelection", "children", "slots", "slotProps", "classes"];
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import clsx from 'clsx';
|
|
@@ -219,6 +219,7 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
|
|
|
219
219
|
itemId,
|
|
220
220
|
label,
|
|
221
221
|
disabled,
|
|
222
|
+
disableSelection,
|
|
222
223
|
children,
|
|
223
224
|
slots = {},
|
|
224
225
|
slotProps = {},
|
|
@@ -243,7 +244,8 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
|
|
|
243
244
|
itemId,
|
|
244
245
|
children,
|
|
245
246
|
label,
|
|
246
|
-
disabled
|
|
247
|
+
disabled,
|
|
248
|
+
disableSelection
|
|
247
249
|
});
|
|
248
250
|
const classes = useUtilityClasses(classesProp);
|
|
249
251
|
const Root = slots.root ?? TreeItemRoot;
|
|
@@ -366,6 +368,11 @@ process.env.NODE_ENV !== "production" ? TreeItem.propTypes = {
|
|
|
366
368
|
* @default false
|
|
367
369
|
*/
|
|
368
370
|
disabled: PropTypes.bool,
|
|
371
|
+
/**
|
|
372
|
+
* If `true`, the item cannot be selected.
|
|
373
|
+
* @default false
|
|
374
|
+
*/
|
|
375
|
+
disableSelection: PropTypes.bool,
|
|
369
376
|
/**
|
|
370
377
|
* The id attribute of the item. If not provided, it will be generated.
|
|
371
378
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRefWithInit } from '@base-ui
|
|
1
|
+
import { useRefWithInit } from '@base-ui/utils/useRefWithInit';
|
|
2
2
|
import { getLookupFromArray } from "../internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js";
|
|
3
3
|
const defaultGetItemId = item => item.id;
|
|
4
4
|
const defaultGetItemChildren = item => item.children;
|
|
@@ -3,6 +3,6 @@ import { TreeViewAnyPluginSignature, TreeViewPublicAPI } from "../internals/mode
|
|
|
3
3
|
import { RichTreeViewPluginSignatures } from "../RichTreeView/RichTreeView.plugins.js";
|
|
4
4
|
/**
|
|
5
5
|
* Hook that instantiates a [[TreeViewApiRef]].
|
|
6
|
-
* @deprecated Use `useRichTreeViewApiRef`, `useRichTreeViewProApiRef` or `useSimpleTreeViewApiRef` instead.
|
|
6
|
+
* @deprecated Use `useRichTreeViewApiRef()`, `useRichTreeViewProApiRef()` or `useSimpleTreeViewApiRef()` instead.
|
|
7
7
|
*/
|
|
8
8
|
export declare const useTreeViewApiRef: <TSignatures extends readonly TreeViewAnyPluginSignature[] = RichTreeViewPluginSignatures>() => React.RefObject<TreeViewPublicAPI<TSignatures> | undefined>;
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
/**
|
|
5
5
|
* Hook that instantiates a [[TreeViewApiRef]].
|
|
6
|
-
* @deprecated Use `useRichTreeViewApiRef`, `useRichTreeViewProApiRef` or `useSimpleTreeViewApiRef` instead.
|
|
6
|
+
* @deprecated Use `useRichTreeViewApiRef()`, `useRichTreeViewProApiRef()` or `useSimpleTreeViewApiRef()` instead.
|
|
7
7
|
*/
|
|
8
8
|
export const useTreeViewApiRef = () => React.useRef(undefined);
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { useAssertModelConsistency } from '@mui/x-internals/useAssertModelConsistency';
|
|
3
|
-
import {
|
|
4
|
-
import { useIsoLayoutEffect } from '@base-ui
|
|
3
|
+
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
4
|
+
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
5
5
|
import { expansionSelectors } from "./useTreeViewExpansion.selectors.js";
|
|
6
6
|
import { getExpansionTrigger } from "./useTreeViewExpansion.utils.js";
|
|
7
7
|
import { itemsSelectors } from "../useTreeViewItems/useTreeViewItems.selectors.js";
|
|
@@ -37,10 +37,10 @@ export const useTreeViewExpansion = ({
|
|
|
37
37
|
}
|
|
38
38
|
params.onExpandedItemsChange?.(event, value);
|
|
39
39
|
};
|
|
40
|
-
const resetItemExpansion =
|
|
40
|
+
const resetItemExpansion = useStableCallback(() => {
|
|
41
41
|
setExpandedItems(null, []);
|
|
42
42
|
});
|
|
43
|
-
const applyItemExpansion =
|
|
43
|
+
const applyItemExpansion = useStableCallback(({
|
|
44
44
|
itemId,
|
|
45
45
|
event,
|
|
46
46
|
shouldBeExpanded
|
|
@@ -57,7 +57,7 @@ export const useTreeViewExpansion = ({
|
|
|
57
57
|
}
|
|
58
58
|
setExpandedItems(event, newExpanded);
|
|
59
59
|
});
|
|
60
|
-
const setItemExpansion =
|
|
60
|
+
const setItemExpansion = useStableCallback(({
|
|
61
61
|
itemId,
|
|
62
62
|
event = null,
|
|
63
63
|
shouldBeExpanded
|
|
@@ -83,7 +83,7 @@ export const useTreeViewExpansion = ({
|
|
|
83
83
|
shouldBeExpanded: cleanShouldBeExpanded
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
|
-
const isItemExpanded =
|
|
86
|
+
const isItemExpanded = useStableCallback(itemId => {
|
|
87
87
|
return expansionSelectors.isItemExpanded(store.state, itemId);
|
|
88
88
|
});
|
|
89
89
|
const expandAllSiblings = (event, itemId) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import {
|
|
2
|
+
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
3
3
|
import { useStoreEffect } from '@mui/x-internals/store';
|
|
4
4
|
import { focusSelectors } from "./useTreeViewFocus.selectors.js";
|
|
5
5
|
import { expansionSelectors } from "../useTreeViewExpansion/useTreeViewExpansion.selectors.js";
|
|
@@ -9,7 +9,7 @@ export const useTreeViewFocus = ({
|
|
|
9
9
|
params,
|
|
10
10
|
store
|
|
11
11
|
}) => {
|
|
12
|
-
const setFocusedItemId =
|
|
12
|
+
const setFocusedItemId = useStableCallback(itemId => {
|
|
13
13
|
const focusedItemId = focusSelectors.focusedItemId(store.state);
|
|
14
14
|
if (focusedItemId === itemId) {
|
|
15
15
|
return;
|
|
@@ -32,13 +32,13 @@ export const useTreeViewFocus = ({
|
|
|
32
32
|
params.onItemFocus(event, itemId);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
const focusItem =
|
|
35
|
+
const focusItem = useStableCallback((event, itemId) => {
|
|
36
36
|
// If we receive an itemId, and it is visible, the focus will be set to it
|
|
37
37
|
if (isItemVisible(itemId)) {
|
|
38
38
|
innerFocusItem(event, itemId);
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
-
const removeFocusedItem =
|
|
41
|
+
const removeFocusedItem = useStableCallback(() => {
|
|
42
42
|
const focusedItemId = focusSelectors.focusedItemId(store.state);
|
|
43
43
|
if (focusedItemId == null) {
|
|
44
44
|
return;
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
|
6
6
|
import { buildItemsLookups, buildItemsState, TREE_VIEW_ROOT_PARENT_ID } from "./useTreeViewItems.utils.js";
|
|
7
7
|
import { TreeViewItemDepthContext } from "../../TreeViewItemDepthContext/index.js";
|
|
8
8
|
import { itemsSelectors } from "./useTreeViewItems.selectors.js";
|
|
9
9
|
import { idSelectors } from "../../corePlugins/useTreeViewId/index.js";
|
|
10
10
|
import { generateTreeItemIdAttribute } from "../../corePlugins/useTreeViewId/useTreeViewId.utils.js";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const defaultIsItemSelectionDisabled = item => item.disableSelection === true;
|
|
12
13
|
export const useTreeViewItems = ({
|
|
13
14
|
instance,
|
|
14
15
|
params,
|
|
@@ -16,16 +17,17 @@ export const useTreeViewItems = ({
|
|
|
16
17
|
}) => {
|
|
17
18
|
const itemsConfig = React.useMemo(() => ({
|
|
18
19
|
isItemDisabled: params.isItemDisabled,
|
|
20
|
+
isItemSelectionDisabled: params.isItemSelectionDisabled,
|
|
19
21
|
getItemLabel: params.getItemLabel,
|
|
20
22
|
getItemChildren: params.getItemChildren,
|
|
21
23
|
getItemId: params.getItemId
|
|
22
|
-
}), [params.isItemDisabled, params.getItemLabel, params.getItemChildren, params.getItemId]);
|
|
24
|
+
}), [params.isItemDisabled, params.isItemSelectionDisabled, params.getItemLabel, params.getItemChildren, params.getItemId]);
|
|
23
25
|
const getItem = React.useCallback(itemId => itemsSelectors.itemModel(store.state, itemId), [store]);
|
|
24
26
|
const getParentId = React.useCallback(itemId => {
|
|
25
27
|
const itemMeta = itemsSelectors.itemMeta(store.state, itemId);
|
|
26
28
|
return itemMeta?.parentId || null;
|
|
27
29
|
}, [store]);
|
|
28
|
-
const setIsItemDisabled =
|
|
30
|
+
const setIsItemDisabled = useStableCallback(({
|
|
29
31
|
itemId,
|
|
30
32
|
shouldBeDisabled
|
|
31
33
|
}) => {
|
|
@@ -104,7 +106,7 @@ export const useTreeViewItems = ({
|
|
|
104
106
|
};
|
|
105
107
|
store.set('items', _extends({}, store.state.items, lookups));
|
|
106
108
|
};
|
|
107
|
-
const removeChildren =
|
|
109
|
+
const removeChildren = useStableCallback(parentId => {
|
|
108
110
|
const newMetaMap = Object.keys(store.state.items.itemMetaLookup).reduce((acc, key) => {
|
|
109
111
|
const item = store.state.items.itemMetaLookup[key];
|
|
110
112
|
if (item.parentId === parentId) {
|
|
@@ -125,7 +127,7 @@ export const useTreeViewItems = ({
|
|
|
125
127
|
itemChildrenIndexesLookup: newItemChildrenIndexesLookup
|
|
126
128
|
}));
|
|
127
129
|
});
|
|
128
|
-
const addExpandableItems =
|
|
130
|
+
const addExpandableItems = useStableCallback(items => {
|
|
129
131
|
const newItemMetaLookup = _extends({}, store.state.items.itemMetaLookup);
|
|
130
132
|
for (const itemId of items) {
|
|
131
133
|
newItemMetaLookup[itemId] = _extends({}, newItemMetaLookup[itemId], {
|
|
@@ -148,8 +150,8 @@ export const useTreeViewItems = ({
|
|
|
148
150
|
store.set('items', _extends({}, store.state.items, newState));
|
|
149
151
|
}, [instance, store, params.items, params.disabledItemsFocusable, itemsConfig]);
|
|
150
152
|
|
|
151
|
-
// Wrap `props.onItemClick` with `
|
|
152
|
-
const handleItemClick =
|
|
153
|
+
// Wrap `props.onItemClick` with `useStableCallback` to prevent unneeded context updates.
|
|
154
|
+
const handleItemClick = useStableCallback((event, itemId) => {
|
|
153
155
|
if (params.onItemClick) {
|
|
154
156
|
params.onItemClick(event, itemId);
|
|
155
157
|
}
|
|
@@ -185,6 +187,7 @@ useTreeViewItems.getInitialState = params => ({
|
|
|
185
187
|
disabledItemsFocusable: params.disabledItemsFocusable,
|
|
186
188
|
config: {
|
|
187
189
|
isItemDisabled: params.isItemDisabled,
|
|
190
|
+
isItemSelectionDisabled: params.isItemSelectionDisabled,
|
|
188
191
|
getItemId: params.getItemId,
|
|
189
192
|
getItemLabel: params.getItemLabel,
|
|
190
193
|
getItemChildren: params.getItemChildren
|
|
@@ -195,7 +198,8 @@ useTreeViewItems.applyDefaultValuesToParams = ({
|
|
|
195
198
|
params
|
|
196
199
|
}) => _extends({}, params, {
|
|
197
200
|
disabledItemsFocusable: params.disabledItemsFocusable ?? false,
|
|
198
|
-
itemChildrenIndentation: params.itemChildrenIndentation ?? '12px'
|
|
201
|
+
itemChildrenIndentation: params.itemChildrenIndentation ?? '12px',
|
|
202
|
+
isItemSelectionDisabled: params.isItemSelectionDisabled ?? defaultIsItemSelectionDisabled
|
|
199
203
|
});
|
|
200
204
|
useTreeViewItems.wrapRoot = ({
|
|
201
205
|
children
|
|
@@ -210,6 +214,7 @@ useTreeViewItems.params = {
|
|
|
210
214
|
disabledItemsFocusable: true,
|
|
211
215
|
items: true,
|
|
212
216
|
isItemDisabled: true,
|
|
217
|
+
isItemSelectionDisabled: true,
|
|
213
218
|
getItemLabel: true,
|
|
214
219
|
getItemChildren: true,
|
|
215
220
|
getItemId: true,
|
|
@@ -53,4 +53,8 @@ export declare const itemsSelectors: {
|
|
|
53
53
|
* Checks whether an item can be focused.
|
|
54
54
|
*/
|
|
55
55
|
canItemBeFocused: (state: TreeViewState<[UseTreeViewItemsSignature]>, itemId: string) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Checks whether an item is selectable based on the `isItemSelectionDisabled` prop.
|
|
58
|
+
*/
|
|
59
|
+
isItemSelectable: (state: TreeViewState<[UseTreeViewItemsSignature]>, itemId: string) => boolean;
|
|
56
60
|
};
|
|
@@ -56,5 +56,9 @@ export const itemsSelectors = {
|
|
|
56
56
|
/**
|
|
57
57
|
* Checks whether an item can be focused.
|
|
58
58
|
*/
|
|
59
|
-
canItemBeFocused: createSelector((state, itemId) => state.items.disabledItemsFocusable || !isItemDisabled(state.items.itemMetaLookup, itemId))
|
|
59
|
+
canItemBeFocused: createSelector((state, itemId) => state.items.disabledItemsFocusable || !isItemDisabled(state.items.itemMetaLookup, itemId)),
|
|
60
|
+
/**
|
|
61
|
+
* Checks whether an item is selectable based on the `isItemSelectionDisabled` prop.
|
|
62
|
+
*/
|
|
63
|
+
isItemSelectable: createSelector((state, itemId) => state.items.itemMetaLookup[itemId]?.selectable ?? true)
|
|
60
64
|
};
|
|
@@ -100,6 +100,13 @@ export interface UseTreeViewItemsParameters<R extends {
|
|
|
100
100
|
* @returns {boolean} `true` if the item should be disabled.
|
|
101
101
|
*/
|
|
102
102
|
isItemDisabled?: (item: R) => boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Used to determine if a given item should have selection disabled.
|
|
105
|
+
* @template R
|
|
106
|
+
* @param {R} item The item to check.
|
|
107
|
+
* @returns {boolean} `true` if the item should have selection disabled.
|
|
108
|
+
*/
|
|
109
|
+
isItemSelectionDisabled?: (item: R) => boolean;
|
|
103
110
|
/**
|
|
104
111
|
* Used to determine the string label for a given item.
|
|
105
112
|
*
|
|
@@ -45,5 +45,5 @@ interface BuildItemsLookupsParameters {
|
|
|
45
45
|
[itemId: string]: TreeViewItemMeta;
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
export interface BuildItemsLookupConfig extends Pick<UseTreeViewItemsParametersWithDefaults<TreeViewBaseItem>, 'isItemDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'> {}
|
|
48
|
+
export interface BuildItemsLookupConfig extends Pick<UseTreeViewItemsParametersWithDefaults<TreeViewBaseItem>, 'isItemDisabled' | 'isItemSelectionDisabled' | 'getItemLabel' | 'getItemChildren' | 'getItemId'> {}
|
|
49
49
|
export {};
|
|
@@ -120,6 +120,7 @@ export function buildItemsLookups(parameters) {
|
|
|
120
120
|
idAttribute: undefined,
|
|
121
121
|
expandable: isItemExpandable(item, children),
|
|
122
122
|
disabled: config.isItemDisabled ? config.isItemDisabled(item) : false,
|
|
123
|
+
selectable: config.isItemSelectionDisabled ? !config.isItemSelectionDisabled(item) : true,
|
|
123
124
|
depth
|
|
124
125
|
};
|
|
125
126
|
orderedChildrenIds.push(id);
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useStore } from '@mui/x-internals/store';
|
|
5
|
-
import { useMergedRefs } from '@base-ui
|
|
6
|
-
import { useIsoLayoutEffect } from '@base-ui
|
|
5
|
+
import { useMergedRefs } from '@base-ui/utils/useMergedRefs';
|
|
6
|
+
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
|
7
7
|
import { useTreeViewContext } from "../../TreeViewProvider/index.js";
|
|
8
8
|
import { TreeViewChildrenItemContext } from "../../TreeViewProvider/TreeViewChildrenItemProvider.js";
|
|
9
9
|
import { itemHasChildren } from "../../../hooks/useTreeItemUtils/useTreeItemUtils.js";
|
|
@@ -21,6 +21,7 @@ export const useTreeViewJSXItemsItemPlugin = ({
|
|
|
21
21
|
const {
|
|
22
22
|
children,
|
|
23
23
|
disabled = false,
|
|
24
|
+
disableSelection = false,
|
|
24
25
|
label,
|
|
25
26
|
itemId,
|
|
26
27
|
id
|
|
@@ -58,9 +59,10 @@ export const useTreeViewJSXItemsItemPlugin = ({
|
|
|
58
59
|
idAttribute: id,
|
|
59
60
|
parentId,
|
|
60
61
|
expandable,
|
|
61
|
-
disabled
|
|
62
|
+
disabled,
|
|
63
|
+
selectable: !disableSelection
|
|
62
64
|
});
|
|
63
|
-
}, [instance, parentId, itemId, expandable, disabled, id]);
|
|
65
|
+
}, [instance, parentId, itemId, expandable, disabled, disableSelection, id]);
|
|
64
66
|
React.useEffect(() => {
|
|
65
67
|
if (label) {
|
|
66
68
|
return instance.mapLabelFromJSX(itemId, (pluginContentRef.current?.textContent ?? '').toLowerCase());
|