@mui/x-tree-view 7.3.0 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +220 -7
  2. package/TreeItem/TreeItem.js +1 -2
  3. package/TreeItem/TreeItemContent.js +1 -2
  4. package/TreeItem/useTreeItemState.js +1 -3
  5. package/TreeItem2/TreeItem2.js +2 -3
  6. package/hooks/useTreeItem2Utils/useTreeItem2Utils.js +1 -3
  7. package/index.js +1 -1
  8. package/internals/TreeViewProvider/useTreeViewContext.d.ts +1 -1
  9. package/internals/hooks/useInstanceEventHandler.d.ts +2 -2
  10. package/internals/models/treeView.d.ts +0 -6
  11. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -4
  12. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +31 -63
  13. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +82 -94
  14. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +32 -5
  15. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.d.ts +9 -0
  16. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +21 -0
  17. package/internals/useTreeView/useTreeView.types.d.ts +1 -1
  18. package/internals/useTreeView/useTreeViewModels.d.ts +1 -1
  19. package/internals/utils/extractPluginParamsFromProps.d.ts +1 -1
  20. package/internals/utils/publishTreeViewEvent.d.ts +1 -1
  21. package/internals/utils/tree.d.ts +17 -1
  22. package/internals/utils/tree.js +34 -4
  23. package/modern/TreeItem/TreeItem.js +1 -2
  24. package/modern/TreeItem/TreeItemContent.js +1 -2
  25. package/modern/TreeItem/useTreeItemState.js +1 -3
  26. package/modern/TreeItem2/TreeItem2.js +2 -3
  27. package/modern/hooks/useTreeItem2Utils/useTreeItem2Utils.js +1 -3
  28. package/modern/index.js +1 -1
  29. package/modern/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -4
  30. package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +31 -63
  31. package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +82 -94
  32. package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +21 -0
  33. package/modern/internals/utils/tree.js +34 -4
  34. package/modern/useTreeItem2/useTreeItem2.js +3 -3
  35. package/node/RichTreeView/RichTreeView.js +1 -1
  36. package/node/SimpleTreeView/SimpleTreeView.js +1 -1
  37. package/node/TreeItem/TreeItem.js +1 -1
  38. package/node/TreeItem/TreeItemContent.js +1 -1
  39. package/node/TreeItem/useTreeItemState.js +1 -3
  40. package/node/TreeItem2/TreeItem2.js +2 -2
  41. package/node/TreeItem2Icon/TreeItem2Icon.js +1 -1
  42. package/node/TreeView/TreeView.js +1 -1
  43. package/node/hooks/useTreeItem2Utils/useTreeItem2Utils.js +1 -3
  44. package/node/hooks/useTreeViewApiRef.js +1 -1
  45. package/node/icons/icons.js +1 -1
  46. package/node/index.js +1 -1
  47. package/node/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +1 -1
  48. package/node/internals/TreeViewProvider/TreeViewContext.js +1 -1
  49. package/node/internals/TreeViewProvider/TreeViewProvider.js +1 -1
  50. package/node/internals/TreeViewProvider/useTreeViewContext.js +1 -1
  51. package/node/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +1 -1
  52. package/node/internals/hooks/useInstanceEventHandler.js +1 -1
  53. package/node/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +1 -1
  54. package/node/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +2 -5
  55. package/node/internals/plugins/useTreeViewId/useTreeViewId.js +1 -1
  56. package/node/internals/plugins/useTreeViewItems/useTreeViewItems.js +1 -1
  57. package/node/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
  58. package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +32 -64
  59. package/node/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +82 -94
  60. package/node/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +29 -0
  61. package/node/internals/useTreeView/useTreeView.js +1 -1
  62. package/node/internals/useTreeView/useTreeViewModels.js +1 -1
  63. package/node/internals/utils/tree.js +37 -5
  64. package/node/useTreeItem2/useTreeItem2.js +3 -3
  65. package/package.json +4 -6
  66. package/useTreeItem2/useTreeItem2.js +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,219 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.4.0
7
+
8
+ _May 10, 2024_
9
+
10
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - ✨ Add optional `id` attribute on shortcut items of the Date and Time Pickers
13
+ - 🎁 Add support for `date-fns-jalali` v3 in the Date and Time Pickers
14
+ - 🚀 Support rounded corners on `BarChart`
15
+ - 🌍 Add accessibility page to TreeView docs
16
+ - 🐞 Bugfixes
17
+ - 📚 Documentation improvements
18
+
19
+ ### Data Grid
20
+
21
+ #### `@mui/x-data-grid@7.4.0`
22
+
23
+ - [DataGrid] Fix error when focus moves from column header to `svg` element (#13028) @oukunan
24
+ - [DataGrid] Fix error on column groups change (#12965) @romgrk
25
+
26
+ #### `@mui/x-data-grid-pro@7.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
27
+
28
+ Same changes as in `@mui/x-data-grid@7.4.0`.
29
+
30
+ #### `@mui/x-data-grid-premium@7.4.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
31
+
32
+ Same changes as in `@mui/x-data-grid-pro@7.4.0`.
33
+
34
+ ### Date and Time Pickers
35
+
36
+ #### `@mui/x-date-pickers@7.4.0`
37
+
38
+ - [fields] Fix regression preventing form submit on "Enter" click (#13065) @LukasTy
39
+ - [pickers] Add `AdapterDateFnsJalaliV3` adapter (#12891) @smmoosavi
40
+ - [pickers] Add optional `id` attribute on shortcut items (#12976) @noraleonte
41
+
42
+ #### `@mui/x-date-pickers-pro@7.4.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
43
+
44
+ Same changes as in `@mui/x-date-pickers@7.4.0`.
45
+
46
+ ### Charts
47
+
48
+ #### `@mui/x-charts@7.4.0`
49
+
50
+ - [charts] Add `ChartsGrid` to `themeAugmentation` (#13026) @noraleonte
51
+ - [charts] Support rounded corners on `BarChart` (#12834) @JCQuintas
52
+
53
+ ### Tree View
54
+
55
+ #### `@mui/x-tree-view@7.4.0`
56
+
57
+ - [TreeView] Fix props propagation and theme entry in `TreeItem2` (#12889) @flaviendelangle
58
+
59
+ ### Docs
60
+
61
+ - [docs] Add accessibility page to TreeView docs (#12845) @noraleonte
62
+ - [docs] Fix Charts styling typos (#13061) @oliviertassinari
63
+ - [docs] Fix legal link to EULA free trial (#13013) @oliviertassinari
64
+ - [docs] Update interface name in pinned columns docs (#13070) @cherniavskii
65
+
66
+ ### Core
67
+
68
+ - [core] Improve release process docs (#12977) @JCQuintas
69
+ - [core] Prepare React 19 (#12991) @oliviertassinari
70
+ - [docs-infra] Fix Netlify PR preview path (#12993) @oliviertassinari
71
+ - [infra] Automation: Add release PR reviewers (#12982) @michelengelen
72
+
73
+ ## 7.3.2
74
+
75
+ _May 2, 2024_
76
+
77
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
78
+
79
+ - 🎁 Add "no data" and "loading" states to charts, allowing users to create [custom visualizations for each state](https://mui.com/x/react-charts/styling/#overlay)
80
+ - 🌍 Improve Hebrew (he-IL) and Hungarian (hu-HU) locales on the Date and Time Pickers
81
+ - 🌍 Improve Danish (da-DK) and Slovak (sk-SK) locales on the Data Grid
82
+ - 📝 Fix a [typo](https://github.com/mui/mui-x/pull/12941/files/4bf4bffbc2799a01a96bc7458a17318cf41c1722#diff-26c31cc69d6f51110f89e339578ef9b3d4a3551f79077fff73f7babb81c5099f) in the auto-generated Charts gradient `id` attribute.
83
+ It should not affect you, but if you were relying on the gradient `id` attribute, please update your usage.
84
+ - 🐞 Bugfixes
85
+ - 📚 Documentation improvements
86
+
87
+ ### Data Grid
88
+
89
+ #### `@mui/x-data-grid@7.3.2`
90
+
91
+ - [DataGrid] Allow to change reset text in the columns management panel (#12972) @MBilalShafi
92
+ - [DataGrid] Derive `formattedValue` from the edit value when passing to `renderEditCell` (#12870) @cherniavskii
93
+ - [DataGrid] Fix rows not being recomputed on `props.rowCount` change (#12833) @MBilalShafi
94
+ - [l10n] Improve Danish (da-DK) locale (#12844) @fosterbuster
95
+ - [l10n] Improve Slovak (sk-SK) locale (#12949) @stefikp
96
+
97
+ #### `@mui/x-data-grid-pro@7.3.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
98
+
99
+ Same changes as in `@mui/x-data-grid@7.3.2`.
100
+
101
+ #### `@mui/x-data-grid-premium@7.3.2` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
102
+
103
+ Same changes as in `@mui/x-data-grid-pro@7.3.2`, plus:
104
+
105
+ - [DataGridPremium] Fix print export not working with row grouping (#12957) @MBilalShafi
106
+
107
+ ### Date and Time Pickers
108
+
109
+ #### `@mui/x-date-pickers@7.3.2`
110
+
111
+ - [l10n] Improve Hebrew (he-IL) locale (#12910) @michaelNXT1
112
+ - [l10n] Improve Hungarian (hu-HU) locale (#12930) @noherczeg
113
+ - [pickers] Fix typo on the `viewRenderers` prop description (#12915) @flaviendelangle
114
+ - [pickers] Improve TypeScript performance in `PickersDay` (#12920) @flaviendelangle
115
+
116
+ #### `@mui/x-date-pickers-pro@7.3.2` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
117
+
118
+ Same changes as in `@mui/x-date-pickers@7.3.2`.
119
+
120
+ ### Charts
121
+
122
+ #### `@mui/x-charts@7.3.2`
123
+
124
+ - [charts] Add an overlay for "no data" or "loading" states (#12817) @alexfauquette
125
+ - [charts] Fix typos in documentation, translations and errors (#12941) @JCQuintas
126
+ - [charts] Fix `prop.slots` and `prop.slotProps` not passed to `<ChartsTooltip />` (#12939) @JCQuintas
127
+
128
+ ### Docs
129
+
130
+ - [docs] Improve Data Grid migration guide (#12969) @MBilalShafi
131
+ - [docs] Polish references to the plans (#12922) @oliviertassinari
132
+
133
+ ### Core
134
+
135
+ - [core] Fix dependencies (#12951) @LukasTy
136
+ - [core] Remove inconsistent blank lines (#12966) @oliviertassinari
137
+ - [code-infra] Bump node image used by CI in docker (#12961) @LukasTy
138
+ - [docs-infra] Remove no longer needed `next.config` settings (#12861) @oliviertassinari
139
+ - [docs-infra] Use the `@mui/docs/HighlightedCode` (#12848) @alexfauquette
140
+ - [test] Restore `t` command (#12948) @LukasTy
141
+
142
+ ## 7.3.1
143
+
144
+ _Apr 26, 2024_
145
+
146
+ We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
147
+
148
+ - 🎁 Scatter Charts get a [z-axis to allow coloring data points independently from their coordinates](https://mui.com/x/react-charts/scatter/#color-scale)
149
+ - 🌍 Improve Catalan (ca-ES) and Spanish (es-ES) locales on the Date and Time Pickers
150
+ - 🐞 Bugfixes
151
+ - 📚 Documentation improvements
152
+
153
+ ### Data Grid
154
+
155
+ #### `@mui/x-data-grid@7.3.1`
156
+
157
+ - [DataGrid] Fix date filtering for negative timezone offsets (#12836) @cherniavskii
158
+ - [DataGrid] Fix flex column width when used with pinned columns (#12849) @romgrk
159
+ - [DataGrid] Fix group header resize (#12863) @arminmeh
160
+ - [DataGrid] Pass slot props to `columnHeaders` slot (#12768) @cherniavskii
161
+
162
+ #### `@mui/x-data-grid-pro@7.3.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
163
+
164
+ Same changes as in `@mui/x-data-grid@7.3.1`.
165
+
166
+ #### `@mui/x-data-grid-premium@7.3.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
167
+
168
+ Same changes as in `@mui/x-data-grid-pro@7.3.1`.
169
+
170
+ ### Date and Time Pickers
171
+
172
+ #### `@mui/x-date-pickers@7.3.1`
173
+
174
+ - [l10n] Improve Catalan (ca-ES) locale (#12856) @soler1212
175
+ - [l10n] Improve Spanish (es-ES) locale (#12858) @soler1212
176
+
177
+ #### `@mui/x-date-pickers-pro@7.3.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
178
+
179
+ Same changes as in `@mui/x-date-pickers@7.3.1`.
180
+
181
+ ### Charts
182
+
183
+ #### `@mui/x-charts@7.3.1`
184
+
185
+ - [charts] Add documentation on border radius alternative for `BarCharts` (#12859) @JCQuintas
186
+ - [charts] Add z-axis to colorize scatter charts (#12738) @alexfauquette
187
+ - [charts] Fix left/bottomAxis not picking up default axis id (#12894) @JCQuintas
188
+ - [charts] Improve default tooltip content (#12257) @oliviertassinari
189
+ - [charts] Round y values for bar chart (#12846) @alexfauquette
190
+
191
+ ### Tree View
192
+
193
+ #### `@mui/x-tree-view@7.3.1`
194
+
195
+ - [TreeView] Remove un-needed `aria-activedescendant` attribute (#12867) @flaviendelangle
196
+ - [TreeView] Rework the selection internals (#12703) @flaviendelangle
197
+ - [TreeView] Use the order in which the items are displayed for `type-ahead` (#12827) @flaviendelangle
198
+
199
+ ### Docs
200
+
201
+ - [docs] Add demo for styling charts with `sx` props (#12791) @derek-0000
202
+ - [docs] Cover webpack 4 support in migration guide (#12710) @cherniavskii
203
+ - [docs] Document interfaces for charts (#12656) @alexfauquette
204
+ - [docs] Fix Vale regression (#12862) @oliviertassinari
205
+ - [docs] Improve Data Grid migration guide (#12879) @MBilalShafi
206
+ - [docs] Update Column features availability (#12865) @DanailH
207
+
208
+ ### Core
209
+
210
+ - [core] Fix `l10n` GH workflow (#12895) @LukasTy
211
+ - [core] Match Base UI and Toolpad @oliviertassinari
212
+ - [core] Remove redundant `setupFiles` entries in `package.json` (#12899) @LukasTy
213
+ - [core] Use `describeTreeView` for focus tests (#12698) @flaviendelangle
214
+ - [core] Use `describeTreeView` for type-ahead tests (#12811) @flaviendelangle
215
+ - [code-infra] Change package manager to `pnpm` (#11875) @LukasTy
216
+ - [code-infra] Closer sync with eslint config of codebase (#12864) @oliviertassinari
217
+ - [support-infra] Add release announcement to GitHub workflows (#11867) (#12843) @michelengelen
218
+
6
219
  ## 7.3.0
7
220
 
8
221
  _Apr 18, 2024_
@@ -228,7 +441,7 @@ Same changes as in `@mui/x-date-pickers@7.1.1`, plus:
228
441
 
229
442
  - [TreeView] Add JSDoc to all `publicAPI` methods (#12649) @flaviendelangle
230
443
  - [TreeView] Create `RichTreeViewPro` component (not released yet) (#12610) @flaviendelangle
231
- - [TreeView] Create pro package (not released yet) (#12240) @flaviendelangle
444
+ - [TreeView] Create Pro package (not released yet) (#12240) @flaviendelangle
232
445
  - [TreeView] Fix typo in errors (#12623) @alissa-tung
233
446
  - [TreeView] New API method: `setItemExpansion` (#12595) @flaviendelangle
234
447
 
@@ -243,7 +456,7 @@ Same changes as in `@mui/x-date-pickers@7.1.1`, plus:
243
456
  - [docs] Fix type arguments in Custom Field page (#12619) @Juneezee
244
457
  - [docs] Fix typo in `getItemId` prop description (#12637) @flaviendelangle
245
458
  - [docs] Make the Charts `margin` usage more visible (#12591) @alexfauquette
246
- - [docs] Match IE 11 spacing with Material UI @oliviertassinari
459
+ - [docs] Match IE 11 spacing with Material UI @oliviertassinari
247
460
  - [docs] Move data grid interfaces to standard API page layout (#12016) @alexfauquette
248
461
  - [docs] Remove ` around @default values (#12158) @alexfauquette
249
462
  - [docs] Remove `day` from the default `dayOfWeekFormatter` function params (#12644) @LukasTy
@@ -506,7 +719,7 @@ Same changes as in `@mui/x-date-pickers@7.0.0`, plus:
506
719
  - [docs] Update links to v6 (#12496) @cherniavskii
507
720
  - [docs] Update links to v7 docs (#12500) @noraleonte
508
721
  - [docs] Update supported versions (#12508) @joserodolfofreitas
509
- - [docs] Update "What's new in MUI X" page #12527 @cherniavskii
722
+ - [docs] Update "What's new in MUI X" page #12527 @cherniavskii
510
723
 
511
724
  ### Core
512
725
 
@@ -2440,7 +2653,7 @@ Same changes as in `@mui/x-date-pickers@7.0.0-alpha.3`.
2440
2653
  - [core] Make `@mui/system` a direct dependency (#11128) @LukasTy
2441
2654
  - [core] Remove blank lines, coding style @oliviertassinari
2442
2655
  - [core] Remove outdated `ENABLE_AD` env variable (#11181) @oliviertassinari
2443
- - [github] Do not add `plan: Pro` and `plan: Premium` labels on pro / premium issue templates (#10183) @flaviendelangle
2656
+ - [github] Do not add `plan: Pro` and `plan: Premium` labels on Pro / Premium issue templates (#10183) @flaviendelangle
2444
2657
 
2445
2658
  ## 7.0.0-alpha.2
2446
2659
 
@@ -3363,10 +3576,10 @@ Same changes as in `@mui/x-date-pickers@6.19.5`.
3363
3576
  - [docs] Fix the Treemap illustration (#12189) @danilo-leal
3364
3577
  - [docs] Fix typo for `AdapterDateFnsV3` (#12037) @flaviendelangle
3365
3578
  - [docs] Improve performance on Charts entry point @oliviertassinari
3366
- - [docs] Move Heatmap to pro (#12170) @alexfauquette
3579
+ - [docs] Move Heatmap to Pro (#12170) @alexfauquette
3367
3580
  - [docs] Remove Charts installation next tag call-out (#12133) @LukasTy
3368
3581
  - [docs] Removed `focused` prop from demo (#12126) @michelengelen
3369
- - [docs] Add missing Heatmap pro icon @oliviertassinari
3582
+ - [docs] Add missing Heatmap Pro icon @oliviertassinari
3370
3583
  - [docs] Add more illustrations to the Overview page (#12041) @danilo-leal
3371
3584
  - [docs] Avoid use of shorthand (#12009) @oliviertassinari
3372
3585
 
@@ -6093,7 +6306,7 @@ We'd like to offer a big thanks to the 11 contributors who made this release pos
6093
6306
  - [docs] Create examples of pickers with custom fields (#8034) @flaviendelangle
6094
6307
  - [docs] Fix 301 redirections @oliviertassinari
6095
6308
  - [docs] Fix link to React's docs @oliviertassinari
6096
- - [docs] Fix pro license links to point to the same page (#8303) @LukasTy
6309
+ - [docs] Fix Pro license links to point to the same page (#8303) @LukasTy
6097
6310
  - [docs] Give an incentive to upgrade (#8269) @oliviertassinari
6098
6311
  - [docs] Improve contrast on data grid navigation (#8239) @oliviertassinari
6099
6312
  - [docs] Update shortcuts page to use slotProps (#8288) @dcorb
@@ -19,8 +19,7 @@ import { treeItemClasses, getTreeItemUtilityClass } from './treeItemClasses';
19
19
  import { useTreeViewContext } from '../internals/TreeViewProvider/useTreeViewContext';
20
20
  import { TreeViewCollapseIcon, TreeViewExpandIcon } from '../icons';
21
21
  import { TreeItem2Provider } from '../TreeItem2Provider';
22
- import { jsx as _jsx } from "react/jsx-runtime";
23
- import { jsxs as _jsxs } from "react/jsx-runtime";
22
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
23
  const useUtilityClasses = ownerState => {
25
24
  const {
26
25
  classes
@@ -5,8 +5,7 @@ import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
7
7
  import { useTreeItemState } from './useTreeItemState';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
9
  /**
11
10
  * @ignore - internal component.
12
11
  */
@@ -32,9 +32,7 @@ export function useTreeItemState(itemId) {
32
32
  const multiple = multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);
33
33
  if (multiple) {
34
34
  if (event.shiftKey) {
35
- instance.selectRange(event, {
36
- end: itemId
37
- });
35
+ instance.expandSelectionRange(event, itemId);
38
36
  } else {
39
37
  instance.selectItem(event, itemId, true);
40
38
  }
@@ -14,8 +14,7 @@ import { unstable_useTreeItem2 as useTreeItem2 } from '../useTreeItem2';
14
14
  import { getTreeItemUtilityClass, treeItemClasses } from '../TreeItem';
15
15
  import { TreeItem2Icon } from '../TreeItem2Icon';
16
16
  import { TreeItem2Provider } from '../TreeItem2Provider';
17
- import { jsx as _jsx } from "react/jsx-runtime";
18
- import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
18
  export const TreeItem2Root = styled('li', {
20
19
  name: 'MuiTreeItem2',
21
20
  slot: 'Root',
@@ -122,7 +121,7 @@ export const TreeItem2IconContainer = styled('div', {
122
121
  }
123
122
  });
124
123
  export const TreeItem2GroupTransition = styled(Collapse, {
125
- name: 'MuiTreeItem2GroupTransition',
124
+ name: 'MuiTreeItem2',
126
125
  slot: 'GroupTransition',
127
126
  overridesResolver: (props, styles) => styles.groupTransition
128
127
  })({
@@ -40,9 +40,7 @@ export const useTreeItem2Utils = ({
40
40
  const multiple = multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);
41
41
  if (multiple) {
42
42
  if (event.shiftKey) {
43
- instance.selectRange(event, {
44
- end: itemId
45
- });
43
+ instance.expandSelectionRange(event, itemId);
46
44
  } else {
47
45
  instance.selectItem(event, itemId, true);
48
46
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.3.0
2
+ * @mui/x-tree-view v7.4.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,3 +1,3 @@
1
1
  import { TreeViewAnyPluginSignature } from '../models';
2
2
  import { TreeViewContextValue } from './TreeViewProvider.types';
3
- export declare const useTreeViewContext: <TPlugins extends readonly TreeViewAnyPluginSignature[]>() => TreeViewContextValue<TPlugins>;
3
+ export declare const useTreeViewContext: <TPlugins extends readonly TreeViewAnyPluginSignature[]>() => NonNullable<TreeViewContextValue<TPlugins>>;
@@ -7,9 +7,9 @@ interface RegistryContainer {
7
7
  }
8
8
  export declare function createUseInstanceEventHandler(registryContainer: RegistryContainer): <Instance extends UseTreeViewInstanceEventsInstance & {
9
9
  $$signature: TreeViewAnyPluginSignature;
10
- }, E extends keyof Instance["$$signature"]["events"] | keyof import("../models").MergePluginsProperty<[import("../corePlugins").TreeViewCorePluginsSignature, ...Instance["$$signature"]["dependantPlugins"]], "events">>(instance: Instance, eventName: E, handler: TreeViewEventListener<TreeViewUsedEvents<Instance["$$signature"]>[E]>) => void;
10
+ }, E extends keyof Instance["$$signature"]["events"] | keyof import("../models").MergePluginsProperty<[import("../corePlugins").TreeViewCorePluginsSignature, ...Instance["$$signature"]["dependantPlugins"]], "events">>(instance: Instance, eventName: E, handler: TreeViewEventListener<TreeViewUsedEvents<Instance['$$signature']>[E]>) => void;
11
11
  export declare const unstable_resetCleanupTracking: () => void;
12
12
  export declare const useInstanceEventHandler: <Instance extends UseTreeViewInstanceEventsInstance & {
13
13
  $$signature: TreeViewAnyPluginSignature;
14
- }, E extends keyof Instance["$$signature"]["events"] | keyof import("../models").MergePluginsProperty<[import("../corePlugins").TreeViewCorePluginsSignature, ...Instance["$$signature"]["dependantPlugins"]], "events">>(instance: Instance, eventName: E, handler: TreeViewEventListener<TreeViewUsedEvents<Instance["$$signature"]>[E]>) => void;
14
+ }, E extends keyof Instance["$$signature"]["events"] | keyof import("../models").MergePluginsProperty<[import("../corePlugins").TreeViewCorePluginsSignature, ...Instance["$$signature"]["dependantPlugins"]], "events">>(instance: Instance, eventName: E, handler: TreeViewEventListener<TreeViewUsedEvents<Instance['$$signature']>[E]>) => void;
15
15
  export {};
@@ -11,12 +11,6 @@ export interface TreeViewItemMeta {
11
11
  */
12
12
  label?: string;
13
13
  }
14
- export interface TreeViewItemRange {
15
- start?: string | null;
16
- end?: string | null;
17
- next?: string | null;
18
- current?: string;
19
- }
20
14
  export interface TreeViewModel<TValue> {
21
15
  name: string;
22
16
  value: TValue;
@@ -105,12 +105,9 @@ export const useTreeViewFocus = ({
105
105
  instance.focusDefaultItem(event);
106
106
  }
107
107
  };
108
- const focusedItem = instance.getItemMeta(state.focusedItemId);
109
- const activeDescendant = focusedItem ? instance.getTreeItemIdAttribute(focusedItem.id, focusedItem.idAttribute) : null;
110
108
  return {
111
109
  getRootProps: otherHandlers => ({
112
- onFocus: createRootHandleFocus(otherHandlers),
113
- 'aria-activedescendant': activeDescendant ?? undefined
110
+ onFocus: createRootHandleFocus(otherHandlers)
114
111
  }),
115
112
  publicAPI: {
116
113
  focusItem
@@ -5,14 +5,6 @@ import { getFirstNavigableItem, getLastNavigableItem, getNextNavigableItem, getP
5
5
  function isPrintableCharacter(string) {
6
6
  return !!string && string.length === 1 && !!string.match(/\S/);
7
7
  }
8
- function findNextFirstChar(firstChars, startIndex, char) {
9
- for (let i = startIndex; i < firstChars.length; i += 1) {
10
- if (char === firstChars[i]) {
11
- return i;
12
- }
13
- }
14
- return -1;
15
- }
16
8
  export const useTreeViewKeyboardNavigation = ({
17
9
  instance,
18
10
  params,
@@ -35,42 +27,29 @@ export const useTreeViewKeyboardNavigation = ({
35
27
  Object.values(state.items.itemMetaMap).forEach(processItem);
36
28
  firstCharMap.current = newFirstCharMap;
37
29
  }, [state.items.itemMetaMap, params.getItemId, instance]);
38
- const getFirstMatchingItem = (itemId, firstChar) => {
39
- let start;
40
- let index;
41
- const lowercaseChar = firstChar.toLowerCase();
42
- const firstCharIds = [];
43
- const firstChars = [];
44
- // This really only works since the ids are strings
45
- Object.keys(firstCharMap.current).forEach(mapItemId => {
46
- const map = instance.getItemMeta(mapItemId);
47
- const visible = map.parentId ? instance.isItemExpanded(map.parentId) : true;
48
- const shouldBeSkipped = params.disabledItemsFocusable ? false : instance.isItemDisabled(mapItemId);
49
- if (visible && !shouldBeSkipped) {
50
- firstCharIds.push(mapItemId);
51
- firstChars.push(firstCharMap.current[mapItemId]);
30
+ const getFirstMatchingItem = (itemId, query) => {
31
+ const cleanQuery = query.toLowerCase();
32
+ const getNextItem = itemIdToCheck => {
33
+ const nextItemId = getNextNavigableItem(instance, itemIdToCheck);
34
+ // We reached the end of the tree, check from the beginning
35
+ if (nextItemId === null) {
36
+ return getFirstNavigableItem(instance);
37
+ }
38
+ return nextItemId;
39
+ };
40
+ let matchingItemId = null;
41
+ let currentItemId = getNextItem(itemId);
42
+ const checkedItems = {};
43
+ // The "!checkedItems[currentItemId]" condition avoids an infinite loop when there is no matching item.
44
+ while (matchingItemId == null && !checkedItems[currentItemId]) {
45
+ if (firstCharMap.current[currentItemId] === cleanQuery) {
46
+ matchingItemId = currentItemId;
47
+ } else {
48
+ checkedItems[currentItemId] = true;
49
+ currentItemId = getNextItem(currentItemId);
52
50
  }
53
- });
54
-
55
- // Get start index for search based on position of currentItem
56
- start = firstCharIds.indexOf(itemId) + 1;
57
- if (start >= firstCharIds.length) {
58
- start = 0;
59
- }
60
-
61
- // Check remaining slots in the menu
62
- index = findNextFirstChar(firstChars, start, lowercaseChar);
63
-
64
- // If not found in remaining slots, check from beginning
65
- if (index === -1) {
66
- index = findNextFirstChar(firstChars, 0, lowercaseChar);
67
- }
68
-
69
- // If a match was found...
70
- if (index > -1) {
71
- return firstCharIds[index];
72
51
  }
73
- return null;
52
+ return matchingItemId;
74
53
  };
75
54
  const canToggleItemSelection = itemId => !params.disableSelection && !instance.isItemDisabled(itemId);
76
55
  const canToggleItemExpansion = itemId => {
@@ -95,9 +74,7 @@ export const useTreeViewKeyboardNavigation = ({
95
74
  {
96
75
  event.preventDefault();
97
76
  if (params.multiSelect && event.shiftKey) {
98
- instance.selectRange(event, {
99
- end: itemId
100
- });
77
+ instance.expandSelectionRange(event, itemId);
101
78
  } else if (params.multiSelect) {
102
79
  instance.selectItem(event, itemId, true);
103
80
  } else {
@@ -136,10 +113,7 @@ export const useTreeViewKeyboardNavigation = ({
136
113
  // Multi select behavior when pressing Shift + ArrowDown
137
114
  // Toggles the selection state of the next item
138
115
  if (params.multiSelect && event.shiftKey && canToggleItemSelection(nextItem)) {
139
- instance.selectRange(event, {
140
- end: nextItem,
141
- current: itemId
142
- }, true);
116
+ instance.selectItemFromArrowNavigation(event, itemId, nextItem);
143
117
  }
144
118
  }
145
119
  break;
@@ -156,10 +130,7 @@ export const useTreeViewKeyboardNavigation = ({
156
130
  // Multi select behavior when pressing Shift + ArrowUp
157
131
  // Toggles the selection state of the previous item
158
132
  if (params.multiSelect && event.shiftKey && canToggleItemSelection(previousItem)) {
159
- instance.selectRange(event, {
160
- end: previousItem,
161
- current: itemId
162
- }, true);
133
+ instance.selectItemFromArrowNavigation(event, itemId, previousItem);
163
134
  }
164
135
  }
165
136
  break;
@@ -202,12 +173,12 @@ export const useTreeViewKeyboardNavigation = ({
202
173
  // Focuses the first item in the tree
203
174
  case key === 'Home':
204
175
  {
205
- instance.focusItem(event, getFirstNavigableItem(instance));
206
-
207
176
  // Multi select behavior when pressing Ctrl + Shift + Home
208
177
  // Selects the focused item and all items up to the first item.
209
178
  if (canToggleItemSelection(itemId) && params.multiSelect && ctrlPressed && event.shiftKey) {
210
- instance.rangeSelectToFirst(event, itemId);
179
+ instance.selectRangeFromStartToItem(event, itemId);
180
+ } else {
181
+ instance.focusItem(event, getFirstNavigableItem(instance));
211
182
  }
212
183
  event.preventDefault();
213
184
  break;
@@ -216,12 +187,12 @@ export const useTreeViewKeyboardNavigation = ({
216
187
  // Focuses the last item in the tree
217
188
  case key === 'End':
218
189
  {
219
- instance.focusItem(event, getLastNavigableItem(instance));
220
-
221
190
  // Multi select behavior when pressing Ctrl + Shirt + End
222
191
  // Selects the focused item and all the items down to the last item.
223
192
  if (canToggleItemSelection(itemId) && params.multiSelect && ctrlPressed && event.shiftKey) {
224
- instance.rangeSelectToLast(event, itemId);
193
+ instance.selectRangeFromItemToEnd(event, itemId);
194
+ } else {
195
+ instance.focusItem(event, getLastNavigableItem(instance));
225
196
  }
226
197
  event.preventDefault();
227
198
  break;
@@ -239,10 +210,7 @@ export const useTreeViewKeyboardNavigation = ({
239
210
  // Selects all the items
240
211
  case key === 'a' && ctrlPressed && params.multiSelect && !params.disableSelection:
241
212
  {
242
- instance.selectRange(event, {
243
- start: getFirstNavigableItem(instance),
244
- end: getLastNavigableItem(instance)
245
- });
213
+ instance.selectAllNavigableItems(event);
246
214
  event.preventDefault();
247
215
  break;
248
216
  }