@mui/x-tree-view 7.1.1 → 7.3.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 +211 -0
- package/RichTreeView/RichTreeView.types.d.ts +3 -3
- package/TreeItem/TreeItem.js +1 -1
- package/TreeItem2/TreeItem2.d.ts +5 -1
- package/TreeItem2/TreeItem2.js +0 -1
- package/index.js +1 -1
- package/internals/TreeViewProvider/TreeViewChildrenItemProvider.d.ts +16 -0
- package/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +57 -0
- package/internals/TreeViewProvider/TreeViewContext.d.ts +2 -0
- package/internals/TreeViewProvider/TreeViewProvider.js +2 -3
- package/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -1
- package/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +7 -8
- package/internals/models/plugin.d.ts +13 -5
- package/internals/models/treeView.d.ts +1 -2
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +15 -15
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +31 -28
- package/internals/plugins/useTreeViewId/useTreeViewId.js +5 -7
- package/internals/plugins/useTreeViewId/useTreeViewId.types.d.ts +1 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.js +60 -50
- package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +19 -15
- package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.d.ts +4 -0
- package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +8 -0
- package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +73 -48
- package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.types.d.ts +3 -2
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +20 -18
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +11 -22
- package/internals/useTreeView/useTreeView.js +21 -3
- package/internals/utils/tree.d.ts +8 -0
- package/internals/utils/tree.js +137 -0
- package/modern/TreeItem/TreeItem.js +1 -1
- package/modern/TreeItem2/TreeItem2.js +0 -1
- package/modern/index.js +1 -1
- package/modern/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +57 -0
- package/modern/internals/TreeViewProvider/TreeViewProvider.js +2 -3
- package/modern/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +7 -8
- package/modern/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +15 -15
- package/modern/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +31 -28
- package/modern/internals/plugins/useTreeViewId/useTreeViewId.js +5 -7
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.js +60 -50
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +8 -0
- package/modern/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +73 -48
- package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +20 -18
- package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +11 -22
- package/modern/internals/useTreeView/useTreeView.js +21 -3
- package/modern/internals/utils/tree.js +137 -0
- package/modern/useTreeItem2/useTreeItem2.js +1 -1
- package/node/TreeItem/TreeItem.js +1 -1
- package/node/TreeItem2/TreeItem2.js +0 -1
- package/node/index.js +1 -1
- package/node/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +67 -0
- package/node/internals/TreeViewProvider/TreeViewProvider.js +2 -3
- package/node/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +7 -8
- package/node/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +15 -15
- package/node/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +31 -28
- package/node/internals/plugins/useTreeViewId/useTreeViewId.js +5 -7
- package/node/internals/plugins/useTreeViewItems/useTreeViewItems.js +60 -50
- package/node/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +15 -0
- package/node/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +73 -48
- package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +20 -18
- package/node/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +11 -22
- package/node/internals/useTreeView/useTreeView.js +21 -3
- package/node/internals/utils/tree.js +148 -0
- package/node/useTreeItem2/useTreeItem2.js +1 -1
- package/package.json +1 -1
- package/useTreeItem2/useTreeItem2.js +1 -1
- package/internals/TreeViewProvider/DescendantProvider.d.ts +0 -38
- package/internals/TreeViewProvider/DescendantProvider.js +0 -176
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.d.ts +0 -17
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +0 -55
- package/internals/useTreeView/useTreeView.utils.d.ts +0 -9
- package/internals/useTreeView/useTreeView.utils.js +0 -46
- package/modern/internals/TreeViewProvider/DescendantProvider.js +0 -176
- package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +0 -55
- package/modern/internals/useTreeView/useTreeView.utils.js +0 -46
- package/node/internals/TreeViewProvider/DescendantProvider.js +0 -185
- package/node/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +0 -62
- package/node/internals/useTreeView/useTreeView.utils.js +0 -58
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,167 @@
|
|
|
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.3.0
|
|
7
|
+
|
|
8
|
+
_Apr 18, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 📄 Support [unknown and estimated row count in server-side pagination](https://mui.com/x/react-data-grid/pagination/#index-based-pagination) (#12490) @MBilalShafi
|
|
13
|
+
- 🎨 Support color scales in Charts (#12490) @alexfauquette
|
|
14
|
+
Add a [`colorMap` configuration](https://mui.com/x/react-charts/styling/#values-color) to an axis, and the chart will use it to select colors.
|
|
15
|
+
Each impacted chart ([bar charts](https://mui.com/x/react-charts/bars/#color-scale), [line charts](https://mui.com/x/react-charts/lines/#color-scale), [scatter charts](https://mui.com/x/react-charts/scatter/#color-scale)) has a dedicated section explaining how this color map is impacting it.
|
|
16
|
+
|
|
17
|
+
<img src="https://github.com/mui/mui-x/assets/45398769/f0066606-3486-4c4e-b3be-7fdd56d763c3" alt="scatter chart with gradient along y-axis" />
|
|
18
|
+
|
|
19
|
+
- 🌍 Improve Danish (da-DK) locale on the Data Grid
|
|
20
|
+
- 🐞 Bugfixes
|
|
21
|
+
- 📚 Documentation improvements
|
|
22
|
+
|
|
23
|
+
### Data Grid
|
|
24
|
+
|
|
25
|
+
#### `@mui/x-data-grid@7.3.0`
|
|
26
|
+
|
|
27
|
+
- [DataGrid] Fix calling `onCellEditStop` on error (#12747) @sai6855
|
|
28
|
+
- [DataGrid] Fix column resize (#12792) @romgrk
|
|
29
|
+
- [DataGrid] Fix column separators (#12808) @romgrk
|
|
30
|
+
- [DataGrid] Limit panel width to not exceed screen width (#12799) @cherniavskii
|
|
31
|
+
- [DataGrid] Support advanced server-side pagination use cases (#12474) @MBilalShafi
|
|
32
|
+
- [DataGrid] Support state export and restore on grid density (#12671) @MBilalShafi
|
|
33
|
+
- [l10n] Improve Danish (da-DK) locale (#12784) @EmilBahnsen
|
|
34
|
+
|
|
35
|
+
#### `@mui/x-data-grid-pro@7.3.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
36
|
+
|
|
37
|
+
Same changes as in `@mui/x-data-grid@7.3.0`, plus:
|
|
38
|
+
|
|
39
|
+
- [DataGridPro] Implement header filter height (#12666) @romgrk
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-data-grid-premium@7.3.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
42
|
+
|
|
43
|
+
Same changes as in `@mui/x-data-grid-pro@7.3.0`.
|
|
44
|
+
|
|
45
|
+
### Charts
|
|
46
|
+
|
|
47
|
+
#### Breaking change
|
|
48
|
+
|
|
49
|
+
A typo fix:
|
|
50
|
+
|
|
51
|
+
```diff
|
|
52
|
+
- ContinuouseScaleName
|
|
53
|
+
+ ContinuousScaleName
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### `@mui/x-charts@7.3.0`
|
|
57
|
+
|
|
58
|
+
- [charts] Add `dataIndex` to series `valueFormatter` (#12745) @JCQuintas
|
|
59
|
+
- [charts] Add color scale (#12490) @alexfauquette
|
|
60
|
+
- [charts] Do not document the usage of `DEFAULT_X_AXIS_KEY` and `DEFAULT_Y_AXIS_KEY` (#12780) @alexfauquette
|
|
61
|
+
- [charts] Export more utils (#12744) @alexfauquette
|
|
62
|
+
- [charts] Fix passing slot props down to `PieArcLabel` (#12806) @JCQuintas
|
|
63
|
+
|
|
64
|
+
### Tree View
|
|
65
|
+
|
|
66
|
+
#### `@mui/x-tree-view@7.3.0`
|
|
67
|
+
|
|
68
|
+
- [TreeView] Support `defaultMuiPrevented` on the `onFocus` prop of the root slot (#12813) @flaviendelangle
|
|
69
|
+
|
|
70
|
+
### Docs
|
|
71
|
+
|
|
72
|
+
- [docs] Add grid cell display example to the migration guide (#12793) @romgrk
|
|
73
|
+
- [docs] Use charts classes objects (#12781) @alexfauquette
|
|
74
|
+
- [docs] Fix layout shift on demos (#12816) @zanivan
|
|
75
|
+
- [test] Increase timeout for test that sometimes fail on `DateTimeRangePicker` (#12786) @LukasTy
|
|
76
|
+
|
|
77
|
+
### Core
|
|
78
|
+
|
|
79
|
+
- [docs-infra] Prepare infra to document charts interfaces (#12653) @alexfauquette
|
|
80
|
+
|
|
81
|
+
## 7.2.0
|
|
82
|
+
|
|
83
|
+
_Apr 12, 2024_
|
|
84
|
+
|
|
85
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
86
|
+
|
|
87
|
+
- 🎨 Make grid colors customizable through the MUI themes API
|
|
88
|
+
- 🌍 Improve French (fr-FR), German (de-DE), and Swedish (sv-SE) locales on the Data Grid and Pickers
|
|
89
|
+
- 🐞 Bugfixes
|
|
90
|
+
- 📚 Documentation improvements
|
|
91
|
+
|
|
92
|
+
### Data Grid
|
|
93
|
+
|
|
94
|
+
#### `@mui/x-data-grid@7.2.0`
|
|
95
|
+
|
|
96
|
+
- [DataGrid] Add missing `api` property to `GridCallbackDetails` (#12742) @sai6855
|
|
97
|
+
- [DataGrid] Do not escape double quotes when copying to clipboard (#12722) @cherniavskii
|
|
98
|
+
- [DataGrid] Fix column vertical border (#12741) @romgrk
|
|
99
|
+
- [DataGrid] Fix invalid date error when filtering `date`/`dateTime` columns (#12709) @cherniavskii
|
|
100
|
+
- [DataGrid] Fix overflow with dynamic row height (#12683) @romgrk
|
|
101
|
+
- [DataGrid] Make colors customizable (#12614) @romgrk
|
|
102
|
+
- [l10n] Improve French (fr-FR) locale (#12755) @derek-0000
|
|
103
|
+
- [l10n] Improve German (de-DE) locale (#12752) @Jens-Schoen
|
|
104
|
+
- [l10n] Improve Swedish (sv-SE) locale (#12731) @pontusdacke
|
|
105
|
+
|
|
106
|
+
#### `@mui/x-data-grid-pro@7.2.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
107
|
+
|
|
108
|
+
Same changes as in `@mui/x-data-grid@7.2.0`.
|
|
109
|
+
|
|
110
|
+
#### `@mui/x-data-grid-premium@7.2.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
111
|
+
|
|
112
|
+
Same changes as in `@mui/x-data-grid-pro@7.2.0`, plus:
|
|
113
|
+
|
|
114
|
+
- [DataGridPremium] Fix clipboard paste not working when cell loses focus (#12724) @cherniavskii
|
|
115
|
+
|
|
116
|
+
### Date and Time Pickers
|
|
117
|
+
|
|
118
|
+
#### `@mui/x-date-pickers@7.2.0`
|
|
119
|
+
|
|
120
|
+
- [fields] Fix field editing after closing the picker (#12675) @LukasTy
|
|
121
|
+
- [l10n] Improve French (fr-FR) locale (#12692) @FaroukBel
|
|
122
|
+
- [l10n] Improve German (de-DE) locale (#12752) @Jens-Schoen
|
|
123
|
+
- [l10n] Improve Swedish (sv-SE) locale (#12731) @pontusdacke
|
|
124
|
+
- [pickers] Fix desktop date time Pickers grid layout (#12748) @LukasTy
|
|
125
|
+
|
|
126
|
+
#### `@mui/x-date-pickers-pro@7.2.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
127
|
+
|
|
128
|
+
Same changes as in `@mui/x-date-pickers@7.2.0`, plus:
|
|
129
|
+
|
|
130
|
+
- [DateTimeRangePicker] Fix desktop toolbar style (#12760) @LukasTy
|
|
131
|
+
|
|
132
|
+
### Charts
|
|
133
|
+
|
|
134
|
+
#### `@mui/x-charts@7.2.0`
|
|
135
|
+
|
|
136
|
+
- [charts] Fix Bar chart with empty dataset throwing an error (#12708) @JCQuintas
|
|
137
|
+
- [charts] Fix `tickLabelInterval` not working on `YAxis` (#12746) @JCQuintas
|
|
138
|
+
|
|
139
|
+
### Tree View
|
|
140
|
+
|
|
141
|
+
#### `@mui/x-tree-view@7.2.0`
|
|
142
|
+
|
|
143
|
+
- [TreeView] Add a new lookup to access an item index without expansive computation (#12729) @flaviendelangle
|
|
144
|
+
- [TreeView] Clean up usage of term "node" in internals (#12655) @noraleonte
|
|
145
|
+
- [TreeView] Improve performance by removing `getNavigableChildrenIds` method (#12713) @flaviendelangle
|
|
146
|
+
- [TreeView] Remove `state.items.itemTree` (#12717) @flaviendelangle
|
|
147
|
+
- [TreeView] Remove remaining occurences of the word "node" in the codebase (#12712) @flaviendelangle
|
|
148
|
+
- [TreeView] Return `instance` and `publicAPI` methods from plugin and populate the main objects inside `useTreeView` (#12650) @flaviendelangle
|
|
149
|
+
- [TreeView] Fix behaviors when the item order changes (#12369) @flaviendelangle
|
|
150
|
+
|
|
151
|
+
### Docs
|
|
152
|
+
|
|
153
|
+
- [docs] Add `AxisFormatter` documentation for customizing tick/tooltip value formatting (#12700) @JCQuintas
|
|
154
|
+
- [docs] Add file explorer example to rich tree view customization docs (#12707) @noraleonte
|
|
155
|
+
- [docs] Do not use import of depth 3 in the doc (#12716) @flaviendelangle
|
|
156
|
+
- [docs] Explain how to clip plots with composition (#12679) @alexfauquette
|
|
157
|
+
- [docs] Fix typo in Data Grid v7 migration page (#12720) @bfaulk96
|
|
158
|
+
- [docs] Fix typo in Pickers v7 migration page (#12721) @bfaulk96
|
|
159
|
+
|
|
160
|
+
### Core
|
|
161
|
+
|
|
162
|
+
- [core] Support multiple resolved `l10n` PR packages (#12735) @LukasTy
|
|
163
|
+
- [core] Update Netlify release references in release README (#12687) @LukasTy
|
|
164
|
+
- [core] Use `describeTreeView` for icons tests (#12672) @flaviendelangle
|
|
165
|
+
- [core] Use `describeTreeView` in existing tests for `useTreeViewItems` (#12732) @flaviendelangle
|
|
166
|
+
|
|
6
167
|
## 7.1.1
|
|
7
168
|
|
|
8
169
|
_Apr 5, 2024_
|
|
@@ -2972,6 +3133,56 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
|
|
|
2972
3133
|
- [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
|
|
2973
3134
|
- [license] Correctly throw errors (#10924) @oliviertassinari
|
|
2974
3135
|
|
|
3136
|
+
## 6.19.11
|
|
3137
|
+
|
|
3138
|
+
_Apr 18, 2024_
|
|
3139
|
+
|
|
3140
|
+
We'd like to offer a big thanks to the 1 contributor who made this release possible. Here are some highlights ✨:
|
|
3141
|
+
|
|
3142
|
+
- 🐞 Bugfixes
|
|
3143
|
+
|
|
3144
|
+
### Data Grid
|
|
3145
|
+
|
|
3146
|
+
#### `@mui/x-data-grid@6.19.11`
|
|
3147
|
+
|
|
3148
|
+
- [DataGrid] Fix virtualization memory leak (#12812) @romgrk
|
|
3149
|
+
|
|
3150
|
+
#### `@mui/x-data-grid-pro@6.19.11` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
3151
|
+
|
|
3152
|
+
Same changes as in `@mui/x-data-grid@6.19.11`.
|
|
3153
|
+
|
|
3154
|
+
#### `@mui/x-data-grid-premium@6.19.11` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
3155
|
+
|
|
3156
|
+
Same changes as in `@mui/x-data-grid-pro@6.19.11`.
|
|
3157
|
+
|
|
3158
|
+
## 6.19.10
|
|
3159
|
+
|
|
3160
|
+
_Apr 12, 2024_
|
|
3161
|
+
|
|
3162
|
+
We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
|
|
3163
|
+
|
|
3164
|
+
- 🐞 Bugfixes
|
|
3165
|
+
- 📚 Documentation improvements
|
|
3166
|
+
|
|
3167
|
+
### Data Grid
|
|
3168
|
+
|
|
3169
|
+
#### `@mui/x-data-grid@6.19.10`
|
|
3170
|
+
|
|
3171
|
+
- [DataGrid] Do not escape double quotes when copying to clipboard (#12734) @cherniavskii
|
|
3172
|
+
- [DataGrid] Fix bug in suspense (#12754) @cherniavskii
|
|
3173
|
+
|
|
3174
|
+
#### `@mui/x-data-grid-pro@6.19.10` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
3175
|
+
|
|
3176
|
+
Same changes as in `@mui/x-data-grid@6.19.10`.
|
|
3177
|
+
|
|
3178
|
+
#### `@mui/x-data-grid-premium@6.19.10` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
3179
|
+
|
|
3180
|
+
Same changes as in `@mui/x-data-grid-pro@6.19.10`.
|
|
3181
|
+
|
|
3182
|
+
### Core
|
|
3183
|
+
|
|
3184
|
+
- [core] Update the docs release source branch (#12685) @LukasTy
|
|
3185
|
+
|
|
2975
3186
|
## 6.19.9
|
|
2976
3187
|
|
|
2977
3188
|
_Apr 5, 2024_
|
|
@@ -4,10 +4,10 @@ import { SxProps } from '@mui/system';
|
|
|
4
4
|
import { SlotComponentProps } from '@mui/base/utils';
|
|
5
5
|
import { RichTreeViewClasses } from './richTreeViewClasses';
|
|
6
6
|
import { DefaultTreeViewPluginParameters, DefaultTreeViewPluginSlotProps, DefaultTreeViewPluginSlots, DefaultTreeViewPlugins } from '../internals/plugins/defaultPlugins';
|
|
7
|
-
import {
|
|
7
|
+
import { TreeItemProps } from '../TreeItem';
|
|
8
8
|
import { TreeItem2Props } from '../TreeItem2';
|
|
9
9
|
import { TreeViewItemId } from '../models';
|
|
10
|
-
import { TreeViewPublicAPI } from '../internals/models';
|
|
10
|
+
import { SlotComponentPropsFromProps, TreeViewPublicAPI } from '../internals/models';
|
|
11
11
|
interface RichTreeViewItemSlotOwnerState {
|
|
12
12
|
itemId: TreeViewItemId;
|
|
13
13
|
label: string;
|
|
@@ -26,7 +26,7 @@ export interface RichTreeViewSlots extends DefaultTreeViewPluginSlots {
|
|
|
26
26
|
}
|
|
27
27
|
export interface RichTreeViewSlotProps<R extends {}, Multiple extends boolean | undefined> extends DefaultTreeViewPluginSlotProps {
|
|
28
28
|
root?: SlotComponentProps<'ul', {}, RichTreeViewProps<R, Multiple>>;
|
|
29
|
-
item?:
|
|
29
|
+
item?: SlotComponentPropsFromProps<TreeItemProps | TreeItem2Props, {}, RichTreeViewItemSlotOwnerState>;
|
|
30
30
|
}
|
|
31
31
|
export type RichTreeViewApiRef = React.MutableRefObject<TreeViewPublicAPI<DefaultTreeViewPlugins> | undefined>;
|
|
32
32
|
export interface RichTreeViewPropsBase extends React.HTMLAttributes<HTMLUListElement> {
|
package/TreeItem/TreeItem.js
CHANGED
|
@@ -270,7 +270,7 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
|
|
|
270
270
|
onKeyDown?.(event);
|
|
271
271
|
instance.handleItemKeyDown(event, itemId);
|
|
272
272
|
};
|
|
273
|
-
const idAttribute = instance.
|
|
273
|
+
const idAttribute = instance.getTreeItemIdAttribute(itemId, id);
|
|
274
274
|
const tabIndex = instance.canItemBeTabbed(itemId) ? 0 : -1;
|
|
275
275
|
return /*#__PURE__*/_jsx(TreeItem2Provider, {
|
|
276
276
|
itemId: itemId,
|
package/TreeItem2/TreeItem2.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export declare const TreeItem2Content: import("@emotion/styled").StyledComponent
|
|
|
5
5
|
export declare const TreeItem2Label: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
6
6
|
export declare const TreeItem2IconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
7
7
|
export declare const TreeItem2GroupTransition: import("@emotion/styled").StyledComponent<Pick<import("@mui/material/Collapse").CollapseProps, keyof import("@mui/material/Collapse").CollapseProps> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
8
|
+
type TreeItem2Component = ((props: TreeItem2Props & React.RefAttributes<HTMLLIElement>) => React.JSX.Element) & {
|
|
9
|
+
propTypes?: any;
|
|
10
|
+
};
|
|
8
11
|
/**
|
|
9
12
|
*
|
|
10
13
|
* Demos:
|
|
@@ -15,4 +18,5 @@ export declare const TreeItem2GroupTransition: import("@emotion/styled").StyledC
|
|
|
15
18
|
*
|
|
16
19
|
* - [TreeItem2 API](https://mui.com/x/api/tree-view/tree-item-2/)
|
|
17
20
|
*/
|
|
18
|
-
export declare const TreeItem2:
|
|
21
|
+
export declare const TreeItem2: TreeItem2Component;
|
|
22
|
+
export {};
|
package/TreeItem2/TreeItem2.js
CHANGED
package/index.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const TreeViewChildrenItemContext: React.Context<TreeViewChildrenItemContextValue | null>;
|
|
3
|
+
interface TreeViewChildrenItemProviderProps {
|
|
4
|
+
itemId?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function TreeViewChildrenItemProvider(props: TreeViewChildrenItemProviderProps): React.JSX.Element;
|
|
8
|
+
export declare namespace TreeViewChildrenItemProvider {
|
|
9
|
+
var propTypes: any;
|
|
10
|
+
}
|
|
11
|
+
interface TreeViewChildrenItemContextValue {
|
|
12
|
+
registerChild: (idAttribute: string, itemId: string) => void;
|
|
13
|
+
unregisterChild: (idAttribute: string) => void;
|
|
14
|
+
parentId: string | null;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useTreeViewContext } from './useTreeViewContext';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export const TreeViewChildrenItemContext = /*#__PURE__*/React.createContext(null);
|
|
6
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7
|
+
TreeViewChildrenItemContext.displayName = 'TreeViewChildrenItemContext';
|
|
8
|
+
}
|
|
9
|
+
export function TreeViewChildrenItemProvider(props) {
|
|
10
|
+
const {
|
|
11
|
+
children,
|
|
12
|
+
itemId = null
|
|
13
|
+
} = props;
|
|
14
|
+
const {
|
|
15
|
+
instance,
|
|
16
|
+
rootRef
|
|
17
|
+
} = useTreeViewContext();
|
|
18
|
+
const childrenIdAttrToIdRef = React.useRef(new Map());
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (!rootRef.current) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let idAttr = null;
|
|
24
|
+
if (itemId == null) {
|
|
25
|
+
idAttr = rootRef.current.id;
|
|
26
|
+
} else {
|
|
27
|
+
// Undefined during 1st render
|
|
28
|
+
const itemMeta = instance.getItemMeta(itemId);
|
|
29
|
+
if (itemMeta !== undefined) {
|
|
30
|
+
idAttr = instance.getTreeItemIdAttribute(itemId, itemMeta.idAttribute);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (idAttr == null) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const previousChildrenIds = instance.getItemOrderedChildrenIds(itemId ?? null) ?? [];
|
|
37
|
+
const childrenElements = rootRef.current.querySelectorAll(`${itemId == null ? '' : `*[id="${idAttr}"] `}[role="treeitem"]:not(*[id="${idAttr}"] [role="treeitem"] [role="treeitem"])`);
|
|
38
|
+
const childrenIds = Array.from(childrenElements).map(child => childrenIdAttrToIdRef.current.get(child.id));
|
|
39
|
+
const hasChanged = childrenIds.length !== previousChildrenIds.length || childrenIds.some((childId, index) => childId !== previousChildrenIds[index]);
|
|
40
|
+
if (hasChanged) {
|
|
41
|
+
instance.setJSXItemsOrderedChildrenIds(itemId ?? null, childrenIds);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const value = React.useMemo(() => ({
|
|
45
|
+
registerChild: (childIdAttribute, childItemId) => childrenIdAttrToIdRef.current.set(childIdAttribute, childItemId),
|
|
46
|
+
unregisterChild: childIdAttribute => childrenIdAttrToIdRef.current.delete(childIdAttribute),
|
|
47
|
+
parentId: itemId
|
|
48
|
+
}), [itemId]);
|
|
49
|
+
return /*#__PURE__*/_jsx(TreeViewChildrenItemContext.Provider, {
|
|
50
|
+
value: value,
|
|
51
|
+
children: children
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
process.env.NODE_ENV !== "production" ? TreeViewChildrenItemProvider.propTypes = {
|
|
55
|
+
children: PropTypes.node,
|
|
56
|
+
id: PropTypes.string
|
|
57
|
+
} : void 0;
|
|
@@ -5,6 +5,8 @@ import * as React from 'react';
|
|
|
5
5
|
export declare const TreeViewContext: React.Context<{
|
|
6
6
|
instance: {};
|
|
7
7
|
publicAPI: {};
|
|
8
|
+
rootRef: React.RefObject<HTMLUListElement>;
|
|
8
9
|
wrapItem: import("../models").TreeItemWrapper;
|
|
10
|
+
wrapRoot: import("../models").TreeRootWrapper;
|
|
9
11
|
runItemPlugins: <TProps extends {}>(props: TProps) => Required<import("../models").TreeViewItemPluginResponse>;
|
|
10
12
|
} | null>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TreeViewContext } from './TreeViewContext';
|
|
3
|
-
import { DescendantProvider } from './DescendantProvider';
|
|
4
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
4
|
/**
|
|
6
5
|
* Sets up the contexts for the underlying TreeItem components.
|
|
@@ -14,8 +13,8 @@ export function TreeViewProvider(props) {
|
|
|
14
13
|
} = props;
|
|
15
14
|
return /*#__PURE__*/_jsx(TreeViewContext.Provider, {
|
|
16
15
|
value: value,
|
|
17
|
-
children:
|
|
18
|
-
children
|
|
16
|
+
children: value.wrapRoot({
|
|
17
|
+
children
|
|
19
18
|
})
|
|
20
19
|
});
|
|
21
20
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { MergePluginsProperty, TreeItemWrapper, TreeViewAnyPluginSignature, TreeViewInstance, TreeViewItemPluginResponse, TreeViewPublicAPI } from '../models';
|
|
2
|
+
import { MergePluginsProperty, TreeItemWrapper, TreeRootWrapper, TreeViewAnyPluginSignature, TreeViewInstance, TreeViewItemPluginResponse, TreeViewPublicAPI } from '../models';
|
|
3
3
|
export type TreeViewContextValue<TPlugins extends readonly TreeViewAnyPluginSignature[]> = MergePluginsProperty<TPlugins, 'contextValue'> & {
|
|
4
4
|
instance: TreeViewInstance<TPlugins>;
|
|
5
5
|
publicAPI: TreeViewPublicAPI<TPlugins>;
|
|
6
|
+
rootRef: React.RefObject<HTMLUListElement>;
|
|
6
7
|
wrapItem: TreeItemWrapper;
|
|
8
|
+
wrapRoot: TreeRootWrapper;
|
|
7
9
|
runItemPlugins: <TProps extends {}>(props: TProps) => Required<TreeViewItemPluginResponse>;
|
|
8
10
|
};
|
|
9
11
|
export interface TreeViewProviderProps<TPlugins extends readonly TreeViewAnyPluginSignature[]> {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { EventManager } from '../../utils/EventManager';
|
|
3
|
-
import { populateInstance } from '../../useTreeView/useTreeView.utils';
|
|
4
3
|
const isSyntheticEvent = event => {
|
|
5
4
|
return event.isPropagationStopped !== undefined;
|
|
6
5
|
};
|
|
7
|
-
export const useTreeViewInstanceEvents = ({
|
|
8
|
-
instance
|
|
9
|
-
}) => {
|
|
6
|
+
export const useTreeViewInstanceEvents = () => {
|
|
10
7
|
const [eventManager] = React.useState(() => new EventManager());
|
|
11
8
|
const publishEvent = React.useCallback((...args) => {
|
|
12
9
|
const [name, params, event = {}] = args;
|
|
@@ -22,9 +19,11 @@ export const useTreeViewInstanceEvents = ({
|
|
|
22
19
|
eventManager.removeListener(event, handler);
|
|
23
20
|
};
|
|
24
21
|
}, [eventManager]);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
return {
|
|
23
|
+
instance: {
|
|
24
|
+
$$publishEvent: publishEvent,
|
|
25
|
+
$$subscribeEvent: subscribeEvent
|
|
26
|
+
}
|
|
27
|
+
};
|
|
29
28
|
};
|
|
30
29
|
useTreeViewInstanceEvents.params = {};
|
|
@@ -7,7 +7,6 @@ import type { TreeViewCorePluginsSignature } from '../corePlugins';
|
|
|
7
7
|
import { TreeViewItemId } from '../../models';
|
|
8
8
|
export interface TreeViewPluginOptions<TSignature extends TreeViewAnyPluginSignature> {
|
|
9
9
|
instance: TreeViewUsedInstance<TSignature>;
|
|
10
|
-
publicAPI: TreeViewUsedPublicAPI<TSignature>;
|
|
11
10
|
params: TreeViewUsedDefaultizedParams<TSignature>;
|
|
12
11
|
state: TreeViewUsedState<TSignature>;
|
|
13
12
|
slots: TSignature['slots'];
|
|
@@ -23,7 +22,7 @@ type TreeViewModelsInitializer<TSignature extends TreeViewAnyPluginSignature> =
|
|
|
23
22
|
};
|
|
24
23
|
type TreeViewResponse<TSignature extends TreeViewAnyPluginSignature> = {
|
|
25
24
|
getRootProps?: <TOther extends EventHandlers = {}>(otherHandlers: TOther) => React.HTMLAttributes<HTMLUListElement>;
|
|
26
|
-
} & OptionalIfEmpty<'contextValue', TSignature['contextValue']>;
|
|
25
|
+
} & OptionalIfEmpty<'publicAPI', TSignature['publicAPI']> & OptionalIfEmpty<'instance', TSignature['instance']> & OptionalIfEmpty<'contextValue', TSignature['contextValue']>;
|
|
27
26
|
export type TreeViewPluginSignature<T extends {
|
|
28
27
|
params?: {};
|
|
29
28
|
defaultizedParams?: {};
|
|
@@ -135,8 +134,11 @@ export type TreeItemWrapper = (params: {
|
|
|
135
134
|
itemId: TreeViewItemId;
|
|
136
135
|
children: React.ReactNode;
|
|
137
136
|
}) => React.ReactNode;
|
|
137
|
+
export type TreeRootWrapper = (params: {
|
|
138
|
+
children: React.ReactNode;
|
|
139
|
+
}) => React.ReactNode;
|
|
138
140
|
export type TreeViewPlugin<TSignature extends TreeViewAnyPluginSignature> = {
|
|
139
|
-
(options: TreeViewPluginOptions<TSignature>):
|
|
141
|
+
(options: TreeViewPluginOptions<TSignature>): TreeViewResponse<TSignature>;
|
|
140
142
|
getDefaultizedParams?: (params: TreeViewUsedParams<TSignature>) => TSignature['defaultizedParams'];
|
|
141
143
|
getInitialState?: (params: TreeViewUsedDefaultizedParams<TSignature>) => TSignature['state'];
|
|
142
144
|
models?: TreeViewModelsInitializer<TSignature>;
|
|
@@ -144,9 +146,15 @@ export type TreeViewPlugin<TSignature extends TreeViewAnyPluginSignature> = {
|
|
|
144
146
|
itemPlugin?: TreeViewItemPlugin<any>;
|
|
145
147
|
/**
|
|
146
148
|
* Render function used to add React wrappers around the TreeItem.
|
|
147
|
-
* @param {
|
|
148
|
-
* @returns {React.ReactNode} The wrapped
|
|
149
|
+
* @param {{ nodeId: TreeViewItemId; children: React.ReactNode; }} params The params of the item.
|
|
150
|
+
* @returns {React.ReactNode} The wrapped item.
|
|
149
151
|
*/
|
|
150
152
|
wrapItem?: TreeItemWrapper;
|
|
153
|
+
/**
|
|
154
|
+
* Render function used to add React wrappers around the TreeView.
|
|
155
|
+
* @param {{ children: React.ReactNode; }} params The params of the root.
|
|
156
|
+
* @returns {React.ReactNode} The wrapped root.
|
|
157
|
+
*/
|
|
158
|
+
wrapRoot?: TreeRootWrapper;
|
|
151
159
|
};
|
|
152
160
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { TreeViewAnyPluginSignature } from './plugin';
|
|
2
2
|
import type { MergePluginsProperty } from './helpers';
|
|
3
|
-
export interface
|
|
3
|
+
export interface TreeViewItemMeta {
|
|
4
4
|
id: string;
|
|
5
5
|
idAttribute: string | undefined;
|
|
6
|
-
index: number;
|
|
7
6
|
parentId: string | null;
|
|
8
7
|
expandable: boolean;
|
|
9
8
|
disabled: boolean;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
4
|
-
import { populateInstance, populatePublicAPI } from '../../useTreeView/useTreeView.utils';
|
|
5
4
|
export const useTreeViewExpansion = ({
|
|
6
5
|
instance,
|
|
7
|
-
publicAPI,
|
|
8
6
|
params,
|
|
9
7
|
models
|
|
10
8
|
}) => {
|
|
@@ -20,7 +18,7 @@ export const useTreeViewExpansion = ({
|
|
|
20
18
|
models.expandedItems.setControlledValue(value);
|
|
21
19
|
};
|
|
22
20
|
const isItemExpanded = React.useCallback(itemId => expandedItemsMap.has(itemId), [expandedItemsMap]);
|
|
23
|
-
const isItemExpandable = React.useCallback(itemId => !!instance.
|
|
21
|
+
const isItemExpandable = React.useCallback(itemId => !!instance.getItemMeta(itemId)?.expandable, [instance]);
|
|
24
22
|
const toggleItemExpansion = useEventCallback((event, itemId) => {
|
|
25
23
|
const isExpandedBefore = instance.isItemExpanded(itemId);
|
|
26
24
|
instance.setItemExpansion(event, itemId, !isExpandedBefore);
|
|
@@ -42,8 +40,8 @@ export const useTreeViewExpansion = ({
|
|
|
42
40
|
setExpandedItems(event, newExpanded);
|
|
43
41
|
});
|
|
44
42
|
const expandAllSiblings = (event, itemId) => {
|
|
45
|
-
const
|
|
46
|
-
const siblings = instance.
|
|
43
|
+
const itemMeta = instance.getItemMeta(itemId);
|
|
44
|
+
const siblings = instance.getItemOrderedChildrenIds(itemMeta.parentId);
|
|
47
45
|
const diff = siblings.filter(child => instance.isItemExpandable(child) && !instance.isItemExpanded(child));
|
|
48
46
|
const newExpanded = models.expandedItems.value.concat(diff);
|
|
49
47
|
if (diff.length > 0) {
|
|
@@ -55,16 +53,18 @@ export const useTreeViewExpansion = ({
|
|
|
55
53
|
setExpandedItems(event, newExpanded);
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
return {
|
|
57
|
+
publicAPI: {
|
|
58
|
+
setItemExpansion
|
|
59
|
+
},
|
|
60
|
+
instance: {
|
|
61
|
+
isItemExpanded,
|
|
62
|
+
isItemExpandable,
|
|
63
|
+
setItemExpansion,
|
|
64
|
+
toggleItemExpansion,
|
|
65
|
+
expandAllSiblings
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
68
|
};
|
|
69
69
|
useTreeViewExpansion.models = {
|
|
70
70
|
expandedItems: {
|