@mui/x-tree-view 7.8.0 → 7.10.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 +140 -0
- package/RichTreeView/RichTreeView.js +9 -5
- package/SimpleTreeView/SimpleTreeView.js +9 -5
- package/TreeItem/useTreeItemState.js +16 -3
- package/TreeView/TreeView.js +9 -5
- package/hooks/useTreeItem2Utils/useTreeItem2Utils.js +16 -3
- package/index.js +1 -1
- package/internals/corePlugins/corePlugins.d.ts +1 -1
- package/internals/corePlugins/corePlugins.js +2 -1
- package/internals/corePlugins/useTreeViewOptionalPlugins/index.d.ts +2 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/index.js +1 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.d.ts +3 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.js +12 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.d.ts +8 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.js +1 -0
- package/internals/models/plugin.d.ts +1 -0
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +7 -7
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -2
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.types.d.ts +2 -2
- package/internals/plugins/useTreeViewItems/useTreeViewItems.js +28 -3
- package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +20 -9
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +15 -5
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +12 -4
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +25 -16
- package/internals/useTreeView/useTreeView.js +2 -1
- package/internals/utils/plugins.d.ts +2 -0
- package/internals/utils/plugins.js +4 -0
- package/modern/RichTreeView/RichTreeView.js +9 -5
- package/modern/SimpleTreeView/SimpleTreeView.js +9 -5
- package/modern/TreeItem/useTreeItemState.js +16 -3
- package/modern/TreeView/TreeView.js +9 -5
- package/modern/hooks/useTreeItem2Utils/useTreeItem2Utils.js +16 -3
- package/modern/index.js +1 -1
- package/modern/internals/corePlugins/corePlugins.js +2 -1
- package/modern/internals/corePlugins/useTreeViewOptionalPlugins/index.js +1 -0
- package/modern/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.js +12 -0
- package/modern/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.js +1 -0
- package/modern/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -2
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.js +28 -3
- package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +15 -5
- package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +12 -4
- package/modern/internals/useTreeView/useTreeView.js +2 -1
- package/modern/internals/utils/plugins.js +4 -0
- package/node/RichTreeView/RichTreeView.js +9 -5
- package/node/SimpleTreeView/SimpleTreeView.js +9 -5
- package/node/TreeItem/useTreeItemState.js +16 -3
- package/node/TreeView/TreeView.js +9 -5
- package/node/hooks/useTreeItem2Utils/useTreeItem2Utils.js +16 -3
- package/node/index.js +1 -1
- package/node/internals/corePlugins/corePlugins.js +2 -1
- package/node/internals/corePlugins/useTreeViewOptionalPlugins/index.js +12 -0
- package/node/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.js +19 -0
- package/node/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.js +5 -0
- package/node/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -2
- package/node/internals/plugins/useTreeViewItems/useTreeViewItems.js +28 -3
- package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +15 -5
- package/node/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +12 -4
- package/node/internals/useTreeView/useTreeView.js +2 -1
- package/node/internals/utils/plugins.js +11 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,146 @@
|
|
|
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.10.0
|
|
7
|
+
|
|
8
|
+
_Jul 11, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎁 Add selectors to support showing child row count in footer in the Data Grid
|
|
13
|
+
- ✨ New APIs for retrieving current item tree and item's children IDs in the Tree View
|
|
14
|
+
- 🌍 Improve Spanish (es-ES) locale on the Data Grid
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
- 📚 Documentation improvements
|
|
17
|
+
|
|
18
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
19
|
+
|
|
20
|
+
### Data Grid
|
|
21
|
+
|
|
22
|
+
#### `@mui/x-data-grid@7.10.0`
|
|
23
|
+
|
|
24
|
+
- [DataGrid] Add selectors to support showing child row count in footer (#13725) @KenanYusuf
|
|
25
|
+
- [DataGrid] Fix incorrect panels position when using a toolbar (#13474) @oukunan
|
|
26
|
+
- [DataGrid] Set default variant to `'standard'` in `GridFilterInputMultipleValue` (#13129) @tarunrajput
|
|
27
|
+
- [DataGrid] Use `readonly` on more array props (#13331) @pcorpet
|
|
28
|
+
- [l10n] Improve Spanish (es-ES) locale (#13772) @joserealdev
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-pro@7.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid@7.10.0`, plus:
|
|
33
|
+
|
|
34
|
+
- [DataGridPro] Keep bottom pinned row at the bottom (#13313) @romgrk
|
|
35
|
+
|
|
36
|
+
#### `@mui/x-data-grid-premium@7.10.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
37
|
+
|
|
38
|
+
Same changes as in `@mui/x-data-grid-pro@7.10.0`.
|
|
39
|
+
|
|
40
|
+
### Date and Time Pickers
|
|
41
|
+
|
|
42
|
+
#### `@mui/x-date-pickers@7.10.0`
|
|
43
|
+
|
|
44
|
+
- [fields] Prevent infinite recursion when ensuring selection (#13779) @LukasTy
|
|
45
|
+
- [fields] Unify fields behavior regardless of the `readOnly` flag (#13688) @LukasTy
|
|
46
|
+
|
|
47
|
+
#### `@mui/x-date-pickers-pro@7.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
48
|
+
|
|
49
|
+
Same changes as in `@mui/x-date-pickers@7.10.0`, plus:
|
|
50
|
+
|
|
51
|
+
- [DateRangePicker] Fix `calendarHeader` slot props propagation (#13780) @LukasTy
|
|
52
|
+
- [DateTimeRangePicker] Resolve `format` from given `views` (#13743) @LukasTy
|
|
53
|
+
|
|
54
|
+
### Charts
|
|
55
|
+
|
|
56
|
+
#### `@mui/x-charts@7.10.0`
|
|
57
|
+
|
|
58
|
+
- [charts] Fix displaying area of a `LineChart` when using the `log` scale (#13791) @alexfauquette
|
|
59
|
+
- [charts] Use correct click handler prop on pie chart `OnSeriesItemClick` documentation (#13761) @tonyhallett
|
|
60
|
+
|
|
61
|
+
### Tree View
|
|
62
|
+
|
|
63
|
+
#### `@mui/x-tree-view@7.10.0`
|
|
64
|
+
|
|
65
|
+
- [TreeView] Add `getItemTree` and `getItemOrderedChildrenIds` methods to the public API (#13804) @flaviendelangle
|
|
66
|
+
- [TreeView] Add utility function to check if an optional plugin is present (#13788) @flaviendelangle
|
|
67
|
+
|
|
68
|
+
### Docs
|
|
69
|
+
|
|
70
|
+
- [docs] Add missing default `loading` prop value (#13604) @oliviertassinari
|
|
71
|
+
- [docs] Add the `DateTimeRangePicker` to the "Commonly used components" demo (#13775) @flaviendelangle
|
|
72
|
+
- [docs] Fix Pickers customization playground overflow (#13742) @LukasTy
|
|
73
|
+
- [docs] Move Pickers dialog guidelines to accessibility page (#13778) @arthurbalduini
|
|
74
|
+
|
|
75
|
+
### Core
|
|
76
|
+
|
|
77
|
+
- [core] Sort `DATA_GRID_PROPS_DEFAULT_VALUES` alphabetically (#13783) @oliviertassinari
|
|
78
|
+
- [test] Fix split infinitive use in tests @oliviertassinari
|
|
79
|
+
|
|
80
|
+
## 7.9.0
|
|
81
|
+
|
|
82
|
+
_Jul 5, 2024_
|
|
83
|
+
|
|
84
|
+
We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
85
|
+
|
|
86
|
+
- 🔄 Add loading overlay variants, including a skeleton loader option to the Data Grid component. See [Loading overlay docs](https://mui.com/x/react-data-grid/overlays/#loading-overlay) for more details.
|
|
87
|
+
- 🌳 Add `selectItem` and `getItemDOMElement` methods to the TreeView component public API
|
|
88
|
+
- ⛏️ Make the `usePickersTranslations` hook public in the pickers component
|
|
89
|
+
- 🐞 Bugfixes
|
|
90
|
+
|
|
91
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
92
|
+
|
|
93
|
+
### Data Grid
|
|
94
|
+
|
|
95
|
+
#### `@mui/x-data-grid@7.9.0`
|
|
96
|
+
|
|
97
|
+
- [DataGrid] Add skeleton loading overlay support (#13293) @KenanYusuf
|
|
98
|
+
- [DataGrid] Fix pagination when `pagination={undefined}` (#13349) @sai6855
|
|
99
|
+
|
|
100
|
+
#### `@mui/x-data-grid-pro@7.9.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
101
|
+
|
|
102
|
+
Same changes as in `@mui/x-data-grid@7.9.0`.
|
|
103
|
+
|
|
104
|
+
#### `@mui/x-data-grid-premium@7.9.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
105
|
+
|
|
106
|
+
Same changes as in `@mui/x-data-grid-pro@7.9.0`.
|
|
107
|
+
|
|
108
|
+
### Date and Time Pickers
|
|
109
|
+
|
|
110
|
+
#### `@mui/x-date-pickers@7.9.0`
|
|
111
|
+
|
|
112
|
+
- [pickers] Make the `usePickersTranslations` hook public (#13657) @flaviendelangle
|
|
113
|
+
|
|
114
|
+
#### `@mui/x-date-pickers-pro@7.9.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
115
|
+
|
|
116
|
+
Same changes as in `@mui/x-date-pickers@7.9.0`.
|
|
117
|
+
|
|
118
|
+
### Charts
|
|
119
|
+
|
|
120
|
+
#### `@mui/x-charts@7.9.0`
|
|
121
|
+
|
|
122
|
+
- [charts] Add Heatmap (unreleased) (#13209) @alexfauquette
|
|
123
|
+
- [charts] Add initial `Zoom&Pan` to the Pro charts (unreleased) (#13405) @JCQuintas
|
|
124
|
+
- [charts] Fix Axis Highlight on horizontal bar charts regression (#13717) @JCQuintas
|
|
125
|
+
- [charts] Improve charts interaction for mobile users (#13692) @JCQuintas
|
|
126
|
+
- [charts] Add documentation on how to disable the tooltip on charts (#13724) @JCQuintas
|
|
127
|
+
|
|
128
|
+
### Tree View
|
|
129
|
+
|
|
130
|
+
#### `@mui/x-tree-view@7.9.0`
|
|
131
|
+
|
|
132
|
+
- [TreeView] Add `selectItem` and `getItemDOMElement` methods to the public API (#13485) @flaviendelangle
|
|
133
|
+
|
|
134
|
+
### Docs
|
|
135
|
+
|
|
136
|
+
- [docs] Fix custom "no results overlay" demo in dark mode (#13715) @KenanYusuf
|
|
137
|
+
|
|
138
|
+
### Core
|
|
139
|
+
|
|
140
|
+
- [core] Add `react_next` workflow in CircleCI (#13360) @cherniavskii
|
|
141
|
+
- [core] Create a new package to share utils across X packages (#13528) @flaviendelangle
|
|
142
|
+
- [core] Fix dependency setup (#13684) @LukasTy
|
|
143
|
+
- [core] Remove `jscodeshift-add-imports` package (#13720) @LukasTy
|
|
144
|
+
- [code-infra] Cleanup monorepo and `@mui/docs` usage (#13713) @LukasTy
|
|
145
|
+
|
|
6
146
|
## 7.8.0
|
|
7
147
|
|
|
8
148
|
_Jun 28, 2024_
|
|
@@ -137,6 +137,10 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
|
137
137
|
current: PropTypes.shape({
|
|
138
138
|
focusItem: PropTypes.func.isRequired,
|
|
139
139
|
getItem: PropTypes.func.isRequired,
|
|
140
|
+
getItemDOMElement: PropTypes.func.isRequired,
|
|
141
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
142
|
+
getItemTree: PropTypes.func.isRequired,
|
|
143
|
+
selectItem: PropTypes.func.isRequired,
|
|
140
144
|
setItemExpansion: PropTypes.func.isRequired
|
|
141
145
|
})
|
|
142
146
|
}),
|
|
@@ -234,34 +238,34 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
|
234
238
|
multiSelect: PropTypes.bool,
|
|
235
239
|
/**
|
|
236
240
|
* Callback fired when tree items are expanded/collapsed.
|
|
237
|
-
* @param {React.SyntheticEvent} event The event
|
|
241
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
238
242
|
* @param {array} itemIds The ids of the expanded items.
|
|
239
243
|
*/
|
|
240
244
|
onExpandedItemsChange: PropTypes.func,
|
|
241
245
|
/**
|
|
242
246
|
* Callback fired when a tree item is expanded or collapsed.
|
|
243
|
-
* @param {React.SyntheticEvent} event The event
|
|
247
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
244
248
|
* @param {array} itemId The itemId of the modified item.
|
|
245
249
|
* @param {array} isExpanded `true` if the item has just been expanded, `false` if it has just been collapsed.
|
|
246
250
|
*/
|
|
247
251
|
onItemExpansionToggle: PropTypes.func,
|
|
248
252
|
/**
|
|
249
253
|
* Callback fired when tree items are focused.
|
|
250
|
-
* @param {React.SyntheticEvent} event The event
|
|
254
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
|
|
251
255
|
* @param {string} itemId The id of the focused item.
|
|
252
256
|
* @param {string} value of the focused item.
|
|
253
257
|
*/
|
|
254
258
|
onItemFocus: PropTypes.func,
|
|
255
259
|
/**
|
|
256
260
|
* Callback fired when a tree item is selected or deselected.
|
|
257
|
-
* @param {React.SyntheticEvent} event The event
|
|
261
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
258
262
|
* @param {array} itemId The itemId of the modified item.
|
|
259
263
|
* @param {array} isSelected `true` if the item has just been selected, `false` if it has just been deselected.
|
|
260
264
|
*/
|
|
261
265
|
onItemSelectionToggle: PropTypes.func,
|
|
262
266
|
/**
|
|
263
267
|
* Callback fired when tree items are selected/deselected.
|
|
264
|
-
* @param {React.SyntheticEvent} event The event
|
|
268
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
265
269
|
* @param {string[] | string} itemIds The ids of the selected items.
|
|
266
270
|
* When `multiSelect` is `true`, this is an array of strings; when false (default) a string.
|
|
267
271
|
*/
|
|
@@ -95,6 +95,10 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
|
95
95
|
current: PropTypes.shape({
|
|
96
96
|
focusItem: PropTypes.func.isRequired,
|
|
97
97
|
getItem: PropTypes.func.isRequired,
|
|
98
|
+
getItemDOMElement: PropTypes.func.isRequired,
|
|
99
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
100
|
+
getItemTree: PropTypes.func.isRequired,
|
|
101
|
+
selectItem: PropTypes.func.isRequired,
|
|
98
102
|
setItemExpansion: PropTypes.func.isRequired
|
|
99
103
|
})
|
|
100
104
|
}),
|
|
@@ -170,34 +174,34 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
|
170
174
|
multiSelect: PropTypes.bool,
|
|
171
175
|
/**
|
|
172
176
|
* Callback fired when tree items are expanded/collapsed.
|
|
173
|
-
* @param {React.SyntheticEvent} event The event
|
|
177
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
174
178
|
* @param {array} itemIds The ids of the expanded items.
|
|
175
179
|
*/
|
|
176
180
|
onExpandedItemsChange: PropTypes.func,
|
|
177
181
|
/**
|
|
178
182
|
* Callback fired when a tree item is expanded or collapsed.
|
|
179
|
-
* @param {React.SyntheticEvent} event The event
|
|
183
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
180
184
|
* @param {array} itemId The itemId of the modified item.
|
|
181
185
|
* @param {array} isExpanded `true` if the item has just been expanded, `false` if it has just been collapsed.
|
|
182
186
|
*/
|
|
183
187
|
onItemExpansionToggle: PropTypes.func,
|
|
184
188
|
/**
|
|
185
189
|
* Callback fired when tree items are focused.
|
|
186
|
-
* @param {React.SyntheticEvent} event The event
|
|
190
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
|
|
187
191
|
* @param {string} itemId The id of the focused item.
|
|
188
192
|
* @param {string} value of the focused item.
|
|
189
193
|
*/
|
|
190
194
|
onItemFocus: PropTypes.func,
|
|
191
195
|
/**
|
|
192
196
|
* Callback fired when a tree item is selected or deselected.
|
|
193
|
-
* @param {React.SyntheticEvent} event The event
|
|
197
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
194
198
|
* @param {array} itemId The itemId of the modified item.
|
|
195
199
|
* @param {array} isSelected `true` if the item has just been selected, `false` if it has just been deselected.
|
|
196
200
|
*/
|
|
197
201
|
onItemSelectionToggle: PropTypes.func,
|
|
198
202
|
/**
|
|
199
203
|
* Callback fired when tree items are selected/deselected.
|
|
200
|
-
* @param {React.SyntheticEvent} event The event
|
|
204
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
201
205
|
* @param {string[] | string} itemIds The ids of the selected items.
|
|
202
206
|
* When `multiSelect` is `true`, this is an array of strings; when false (default) a string.
|
|
203
207
|
*/
|
|
@@ -39,10 +39,18 @@ export function useTreeItemState(itemId) {
|
|
|
39
39
|
if (event.shiftKey) {
|
|
40
40
|
instance.expandSelectionRange(event, itemId);
|
|
41
41
|
} else {
|
|
42
|
-
instance.selectItem(
|
|
42
|
+
instance.selectItem({
|
|
43
|
+
event,
|
|
44
|
+
itemId,
|
|
45
|
+
keepExistingSelection: true
|
|
46
|
+
});
|
|
43
47
|
}
|
|
44
48
|
} else {
|
|
45
|
-
instance.selectItem(
|
|
49
|
+
instance.selectItem({
|
|
50
|
+
event,
|
|
51
|
+
itemId,
|
|
52
|
+
shouldBeSelected: true
|
|
53
|
+
});
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
};
|
|
@@ -54,7 +62,12 @@ export function useTreeItemState(itemId) {
|
|
|
54
62
|
if (multiSelect && hasShift) {
|
|
55
63
|
instance.expandSelectionRange(event, itemId);
|
|
56
64
|
} else {
|
|
57
|
-
instance.selectItem(
|
|
65
|
+
instance.selectItem({
|
|
66
|
+
event,
|
|
67
|
+
itemId,
|
|
68
|
+
keepExistingSelection: multiSelect,
|
|
69
|
+
shouldBeSelected: event.target.checked
|
|
70
|
+
});
|
|
58
71
|
}
|
|
59
72
|
};
|
|
60
73
|
const preventSelection = event => {
|
package/TreeView/TreeView.js
CHANGED
|
@@ -72,6 +72,10 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
|
72
72
|
current: PropTypes.shape({
|
|
73
73
|
focusItem: PropTypes.func.isRequired,
|
|
74
74
|
getItem: PropTypes.func.isRequired,
|
|
75
|
+
getItemDOMElement: PropTypes.func.isRequired,
|
|
76
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
77
|
+
getItemTree: PropTypes.func.isRequired,
|
|
78
|
+
selectItem: PropTypes.func.isRequired,
|
|
75
79
|
setItemExpansion: PropTypes.func.isRequired
|
|
76
80
|
})
|
|
77
81
|
}),
|
|
@@ -147,34 +151,34 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
|
147
151
|
multiSelect: PropTypes.bool,
|
|
148
152
|
/**
|
|
149
153
|
* Callback fired when tree items are expanded/collapsed.
|
|
150
|
-
* @param {React.SyntheticEvent} event The event
|
|
154
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
151
155
|
* @param {array} itemIds The ids of the expanded items.
|
|
152
156
|
*/
|
|
153
157
|
onExpandedItemsChange: PropTypes.func,
|
|
154
158
|
/**
|
|
155
159
|
* Callback fired when a tree item is expanded or collapsed.
|
|
156
|
-
* @param {React.SyntheticEvent} event The event
|
|
160
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
157
161
|
* @param {array} itemId The itemId of the modified item.
|
|
158
162
|
* @param {array} isExpanded `true` if the item has just been expanded, `false` if it has just been collapsed.
|
|
159
163
|
*/
|
|
160
164
|
onItemExpansionToggle: PropTypes.func,
|
|
161
165
|
/**
|
|
162
166
|
* Callback fired when tree items are focused.
|
|
163
|
-
* @param {React.SyntheticEvent} event The event
|
|
167
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
|
|
164
168
|
* @param {string} itemId The id of the focused item.
|
|
165
169
|
* @param {string} value of the focused item.
|
|
166
170
|
*/
|
|
167
171
|
onItemFocus: PropTypes.func,
|
|
168
172
|
/**
|
|
169
173
|
* Callback fired when a tree item is selected or deselected.
|
|
170
|
-
* @param {React.SyntheticEvent} event The event
|
|
174
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
171
175
|
* @param {array} itemId The itemId of the modified item.
|
|
172
176
|
* @param {array} isSelected `true` if the item has just been selected, `false` if it has just been deselected.
|
|
173
177
|
*/
|
|
174
178
|
onItemSelectionToggle: PropTypes.func,
|
|
175
179
|
/**
|
|
176
180
|
* Callback fired when tree items are selected/deselected.
|
|
177
|
-
* @param {React.SyntheticEvent} event The event
|
|
181
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
178
182
|
* @param {string[] | string} itemIds The ids of the selected items.
|
|
179
183
|
* When `multiSelect` is `true`, this is an array of strings; when false (default) a string.
|
|
180
184
|
*/
|
|
@@ -57,10 +57,18 @@ export const useTreeItem2Utils = ({
|
|
|
57
57
|
if (event.shiftKey) {
|
|
58
58
|
instance.expandSelectionRange(event, itemId);
|
|
59
59
|
} else {
|
|
60
|
-
instance.selectItem(
|
|
60
|
+
instance.selectItem({
|
|
61
|
+
event,
|
|
62
|
+
itemId,
|
|
63
|
+
keepExistingSelection: true
|
|
64
|
+
});
|
|
61
65
|
}
|
|
62
66
|
} else {
|
|
63
|
-
instance.selectItem(
|
|
67
|
+
instance.selectItem({
|
|
68
|
+
event,
|
|
69
|
+
itemId,
|
|
70
|
+
shouldBeSelected: true
|
|
71
|
+
});
|
|
64
72
|
}
|
|
65
73
|
};
|
|
66
74
|
const handleCheckboxSelection = event => {
|
|
@@ -68,7 +76,12 @@ export const useTreeItem2Utils = ({
|
|
|
68
76
|
if (multiSelect && hasShift) {
|
|
69
77
|
instance.expandSelectionRange(event, itemId);
|
|
70
78
|
} else {
|
|
71
|
-
instance.selectItem(
|
|
79
|
+
instance.selectItem({
|
|
80
|
+
event,
|
|
81
|
+
itemId,
|
|
82
|
+
keepExistingSelection: multiSelect,
|
|
83
|
+
shouldBeSelected: event.target.checked
|
|
84
|
+
});
|
|
72
85
|
}
|
|
73
86
|
};
|
|
74
87
|
const interactions = {
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ConvertPluginsIntoSignatures } from '../models';
|
|
|
4
4
|
* Internal plugins that create the tools used by the other plugins.
|
|
5
5
|
* These plugins are used by the tree view components.
|
|
6
6
|
*/
|
|
7
|
-
export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("../models").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>, import("../models").TreeViewPlugin<import("./useTreeViewId").UseTreeViewIdSignature>];
|
|
7
|
+
export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("../models").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>, import("../models").TreeViewPlugin<import("./useTreeViewOptionalPlugins").UseTreeViewOptionalPluginsSignature>, import("../models").TreeViewPlugin<import("./useTreeViewId").UseTreeViewIdSignature>];
|
|
8
8
|
export type TreeViewCorePluginSignatures = ConvertPluginsIntoSignatures<typeof TREE_VIEW_CORE_PLUGINS>;
|
|
9
9
|
export interface TreeViewCorePluginParameters extends UseTreeViewIdParameters {
|
|
10
10
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useTreeViewInstanceEvents } from './useTreeViewInstanceEvents';
|
|
2
|
+
import { useTreeViewOptionalPlugins } from './useTreeViewOptionalPlugins';
|
|
2
3
|
import { useTreeViewId } from './useTreeViewId';
|
|
3
4
|
/**
|
|
4
5
|
* Internal plugins that create the tools used by the other plugins.
|
|
5
6
|
* These plugins are used by the tree view components.
|
|
6
7
|
*/
|
|
7
|
-
export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents, useTreeViewId];
|
|
8
|
+
export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents, useTreeViewOptionalPlugins, useTreeViewId];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTreeViewOptionalPlugins } from './useTreeViewOptionalPlugins';
|
package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeViewPlugin, TreeViewAnyPluginSignature, TreeViewPluginSignature } from '../../models';
|
|
2
|
+
interface UseTreeViewOptionalPluginsInstance {
|
|
3
|
+
getAvailablePlugins: () => Set<TreeViewPlugin<TreeViewAnyPluginSignature>>;
|
|
4
|
+
}
|
|
5
|
+
export type UseTreeViewOptionalPluginsSignature = TreeViewPluginSignature<{
|
|
6
|
+
instance: UseTreeViewOptionalPluginsInstance;
|
|
7
|
+
}>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,6 +15,7 @@ export interface TreeViewPluginOptions<TSignature extends TreeViewAnyPluginSigna
|
|
|
15
15
|
models: TreeViewUsedModels<TSignature>;
|
|
16
16
|
setState: React.Dispatch<React.SetStateAction<TreeViewUsedState<TSignature>>>;
|
|
17
17
|
rootRef: React.RefObject<HTMLUListElement>;
|
|
18
|
+
plugins: TreeViewPlugin<TreeViewAnyPluginSignature>[];
|
|
18
19
|
}
|
|
19
20
|
type TreeViewModelsInitializer<TSignature extends TreeViewAnyPluginSignature> = {
|
|
20
21
|
[TControlled in keyof TSignature['models']]: {
|
|
@@ -5,9 +5,9 @@ import { TreeViewItemId } from '../../../models';
|
|
|
5
5
|
export interface UseTreeViewExpansionPublicAPI {
|
|
6
6
|
/**
|
|
7
7
|
* Change the expansion status of a given item.
|
|
8
|
-
* @param {React.SyntheticEvent} event The
|
|
9
|
-
* @param {string} itemId The id of the item to
|
|
10
|
-
* @param {boolean} isExpanded
|
|
8
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
9
|
+
* @param {string} itemId The id of the item to expand of collapse.
|
|
10
|
+
* @param {boolean} isExpanded If `true` the item will be expanded. If `false` the item will be collapsed.
|
|
11
11
|
*/
|
|
12
12
|
setItemExpansion: (event: React.SyntheticEvent, itemId: string, isExpanded: boolean) => void;
|
|
13
13
|
}
|
|
@@ -29,13 +29,13 @@ export interface UseTreeViewExpansionInstance extends UseTreeViewExpansionPublic
|
|
|
29
29
|
/**
|
|
30
30
|
* Toggle the current expansion of an item.
|
|
31
31
|
* If it is expanded, it will be collapsed, and vice versa.
|
|
32
|
-
* @param {React.SyntheticEvent} event The
|
|
32
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
33
33
|
* @param {TreeViewItemId} itemId The id of the item to toggle.
|
|
34
34
|
*/
|
|
35
35
|
toggleItemExpansion: (event: React.SyntheticEvent, itemId: TreeViewItemId) => void;
|
|
36
36
|
/**
|
|
37
37
|
* Expand all the siblings (i.e.: the items that have the same parent) of a given item.
|
|
38
|
-
* @param {React.SyntheticEvent} event The
|
|
38
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
39
39
|
* @param {TreeViewItemId} itemId The id of the item whose siblings will be expanded.
|
|
40
40
|
*/
|
|
41
41
|
expandAllSiblings: (event: React.KeyboardEvent, itemId: TreeViewItemId) => void;
|
|
@@ -54,13 +54,13 @@ export interface UseTreeViewExpansionParameters {
|
|
|
54
54
|
defaultExpandedItems?: string[];
|
|
55
55
|
/**
|
|
56
56
|
* Callback fired when tree items are expanded/collapsed.
|
|
57
|
-
* @param {React.SyntheticEvent} event The event
|
|
57
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
58
58
|
* @param {array} itemIds The ids of the expanded items.
|
|
59
59
|
*/
|
|
60
60
|
onExpandedItemsChange?: (event: React.SyntheticEvent, itemIds: string[]) => void;
|
|
61
61
|
/**
|
|
62
62
|
* Callback fired when a tree item is expanded or collapsed.
|
|
63
|
-
* @param {React.SyntheticEvent} event The event
|
|
63
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
64
64
|
* @param {array} itemId The itemId of the modified item.
|
|
65
65
|
* @param {array} isExpanded `true` if the item has just been expanded, `false` if it has just been collapsed.
|
|
66
66
|
*/
|
|
@@ -43,8 +43,7 @@ export const useTreeViewFocus = ({
|
|
|
43
43
|
return itemMeta && (itemMeta.parentId == null || instance.isItemExpanded(itemMeta.parentId));
|
|
44
44
|
};
|
|
45
45
|
const innerFocusItem = (event, itemId) => {
|
|
46
|
-
const
|
|
47
|
-
const itemElement = document.getElementById(instance.getTreeItemIdAttribute(itemId, itemMeta.idAttribute));
|
|
46
|
+
const itemElement = instance.getItemDOMElement(itemId);
|
|
48
47
|
if (itemElement) {
|
|
49
48
|
itemElement.focus();
|
|
50
49
|
}
|
|
@@ -10,7 +10,7 @@ export interface UseTreeViewFocusPublicAPI {
|
|
|
10
10
|
*
|
|
11
11
|
* If the item is the child of a collapsed item, then this method will do nothing.
|
|
12
12
|
* Make sure to expand the ancestors of the item before calling this method if needed.
|
|
13
|
-
* @param {React.SyntheticEvent} event The event
|
|
13
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
14
14
|
* @param {TreeViewItemId} itemId The id of the item to focus.
|
|
15
15
|
*/
|
|
16
16
|
focusItem: (event: React.SyntheticEvent, itemId: string) => void;
|
|
@@ -38,7 +38,7 @@ export interface UseTreeViewFocusInstance extends UseTreeViewFocusPublicAPI {
|
|
|
38
38
|
export interface UseTreeViewFocusParameters {
|
|
39
39
|
/**
|
|
40
40
|
* Callback fired when tree items are focused.
|
|
41
|
-
* @param {React.SyntheticEvent} event The event
|
|
41
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change. **Warning**: This is a generic event not a focus event.
|
|
42
42
|
* @param {string} itemId The id of the focused item.
|
|
43
43
|
* @param {string} value of the focused item.
|
|
44
44
|
*/
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["children"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { publishTreeViewEvent } from '../../utils/publishTreeViewEvent';
|
|
4
6
|
import { buildSiblingIndexes, TREE_VIEW_ROOT_PARENT_ID } from './useTreeViewItems.utils';
|
|
@@ -37,7 +39,6 @@ const updateItemsState = ({
|
|
|
37
39
|
depth
|
|
38
40
|
};
|
|
39
41
|
itemMap[id] = item;
|
|
40
|
-
itemOrderedChildrenIds[id] = [];
|
|
41
42
|
const parentIdWithDefault = parentId ?? TREE_VIEW_ROOT_PARENT_ID;
|
|
42
43
|
if (!itemOrderedChildrenIds[parentIdWithDefault]) {
|
|
43
44
|
itemOrderedChildrenIds[parentIdWithDefault] = [];
|
|
@@ -66,6 +67,18 @@ export const useTreeViewItems = ({
|
|
|
66
67
|
}) => {
|
|
67
68
|
const getItemMeta = React.useCallback(itemId => state.items.itemMetaMap[itemId], [state.items.itemMetaMap]);
|
|
68
69
|
const getItem = React.useCallback(itemId => state.items.itemMap[itemId], [state.items.itemMap]);
|
|
70
|
+
const getItemTree = React.useCallback(() => {
|
|
71
|
+
const getItemFromItemId = id => {
|
|
72
|
+
const _state$items$itemMap$ = state.items.itemMap[id],
|
|
73
|
+
item = _objectWithoutPropertiesLoose(_state$items$itemMap$, _excluded);
|
|
74
|
+
const newChildren = state.items.itemOrderedChildrenIds[id];
|
|
75
|
+
if (newChildren) {
|
|
76
|
+
item.children = newChildren.map(getItemFromItemId);
|
|
77
|
+
}
|
|
78
|
+
return item;
|
|
79
|
+
};
|
|
80
|
+
return state.items.itemOrderedChildrenIds[TREE_VIEW_ROOT_PARENT_ID].map(getItemFromItemId);
|
|
81
|
+
}, [state.items.itemMap, state.items.itemOrderedChildrenIds]);
|
|
69
82
|
const isItemDisabled = React.useCallback(itemId => {
|
|
70
83
|
if (itemId == null) {
|
|
71
84
|
return false;
|
|
@@ -92,6 +105,13 @@ export const useTreeViewItems = ({
|
|
|
92
105
|
return state.items.itemChildrenIndexes[parentId][itemId];
|
|
93
106
|
}, [instance, state.items.itemChildrenIndexes]);
|
|
94
107
|
const getItemOrderedChildrenIds = React.useCallback(itemId => state.items.itemOrderedChildrenIds[itemId ?? TREE_VIEW_ROOT_PARENT_ID] ?? [], [state.items.itemOrderedChildrenIds]);
|
|
108
|
+
const getItemDOMElement = itemId => {
|
|
109
|
+
const itemMeta = instance.getItemMeta(itemId);
|
|
110
|
+
if (itemMeta == null) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return document.getElementById(instance.getTreeItemIdAttribute(itemId, itemMeta.idAttribute));
|
|
114
|
+
};
|
|
95
115
|
const isItemNavigable = itemId => {
|
|
96
116
|
if (params.disabledItemsFocusable) {
|
|
97
117
|
return true;
|
|
@@ -133,7 +153,7 @@ export const useTreeViewItems = ({
|
|
|
133
153
|
label: item.label,
|
|
134
154
|
itemId: item.id,
|
|
135
155
|
id: item.idAttribute,
|
|
136
|
-
children: state.items.itemOrderedChildrenIds[id]
|
|
156
|
+
children: state.items.itemOrderedChildrenIds[id]?.map(getPropsFromItemId)
|
|
137
157
|
};
|
|
138
158
|
};
|
|
139
159
|
return state.items.itemOrderedChildrenIds[TREE_VIEW_ROOT_PARENT_ID].map(getPropsFromItemId);
|
|
@@ -145,13 +165,18 @@ export const useTreeViewItems = ({
|
|
|
145
165
|
}
|
|
146
166
|
}),
|
|
147
167
|
publicAPI: {
|
|
148
|
-
getItem
|
|
168
|
+
getItem,
|
|
169
|
+
getItemDOMElement,
|
|
170
|
+
getItemTree,
|
|
171
|
+
getItemOrderedChildrenIds
|
|
149
172
|
},
|
|
150
173
|
instance: {
|
|
151
174
|
getItemMeta,
|
|
152
175
|
getItem,
|
|
176
|
+
getItemTree,
|
|
153
177
|
getItemsToRender,
|
|
154
178
|
getItemIndex,
|
|
179
|
+
getItemDOMElement,
|
|
155
180
|
getItemOrderedChildrenIds,
|
|
156
181
|
isItemDisabled,
|
|
157
182
|
isItemNavigable,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TreeViewItemMeta, DefaultizedProps, TreeViewPluginSignature } from '../../models';
|
|
2
|
-
import { TreeViewItemId } from '../../../models';
|
|
2
|
+
import { TreeViewBaseItem, TreeViewItemId } from '../../../models';
|
|
3
3
|
interface TreeViewItemProps {
|
|
4
4
|
label: string;
|
|
5
5
|
itemId: string;
|
|
@@ -10,10 +10,28 @@ export interface UseTreeViewItemsPublicAPI<R extends {}> {
|
|
|
10
10
|
/**
|
|
11
11
|
* Get the item with the given id.
|
|
12
12
|
* When used in the `SimpleTreeView`, it returns an object with the `id` and `label` properties.
|
|
13
|
-
* @param {string} itemId The id of the item to
|
|
13
|
+
* @param {string} itemId The id of the item to retrieve.
|
|
14
14
|
* @returns {R} The item with the given id.
|
|
15
15
|
*/
|
|
16
16
|
getItem: (itemId: TreeViewItemId) => R;
|
|
17
|
+
/**
|
|
18
|
+
* Get the DOM element of the item with the given id.
|
|
19
|
+
* @param {TreeViewItemId} itemId The id of the item to get the DOM element of.
|
|
20
|
+
* @returns {HTMLElement | null} The DOM element of the item with the given id.
|
|
21
|
+
*/
|
|
22
|
+
getItemDOMElement: (itemId: TreeViewItemId) => HTMLElement | null;
|
|
23
|
+
/**
|
|
24
|
+
* Get the ids of a given item's children.
|
|
25
|
+
* Those ids are returned in the order they should be rendered.
|
|
26
|
+
* @param {TreeViewItemId | null} itemId The id of the item to get the children of.
|
|
27
|
+
* @returns {TreeViewItemId[]} The ids of the item's children.
|
|
28
|
+
*/
|
|
29
|
+
getItemOrderedChildrenIds: (itemId: TreeViewItemId | null) => TreeViewItemId[];
|
|
30
|
+
/**
|
|
31
|
+
* Get all the items in the same format as provided by `props.items`.
|
|
32
|
+
* @returns {TreeViewItemProps[]} The items in the tree.
|
|
33
|
+
*/
|
|
34
|
+
getItemTree: () => TreeViewBaseItem[];
|
|
17
35
|
}
|
|
18
36
|
export interface UseTreeViewItemsInstance<R extends {}> extends UseTreeViewItemsPublicAPI<R> {
|
|
19
37
|
/**
|
|
@@ -30,13 +48,6 @@ export interface UseTreeViewItemsInstance<R extends {}> extends UseTreeViewItems
|
|
|
30
48
|
* @returns {TreeViewItemProps[]} The items to render.
|
|
31
49
|
*/
|
|
32
50
|
getItemsToRender: () => TreeViewItemProps[];
|
|
33
|
-
/**
|
|
34
|
-
* Get the ids of a given item's children.
|
|
35
|
-
* Those ids are returned in the order they should be rendered.
|
|
36
|
-
* @param {TreeViewItemId | null} itemId The id of the item to get the children of.
|
|
37
|
-
* @returns {TreeViewItemId[]} The ids of the item's children.
|
|
38
|
-
*/
|
|
39
|
-
getItemOrderedChildrenIds: (itemId: TreeViewItemId | null) => TreeViewItemId[];
|
|
40
51
|
/**
|
|
41
52
|
* Check if a given item is disabled.
|
|
42
53
|
* An item is disabled if it was marked as disabled or if one of its ancestors is disabled.
|