@mui/x-tree-view 7.7.0 → 7.7.1

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 (62) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/RichTreeView/RichTreeView.plugins.d.ts +3 -3
  3. package/RichTreeView/RichTreeView.plugins.js +1 -2
  4. package/SimpleTreeView/SimpleTreeView.plugins.d.ts +3 -3
  5. package/SimpleTreeView/SimpleTreeView.plugins.js +1 -2
  6. package/TreeItem/TreeItem.types.d.ts +8 -3
  7. package/hooks/useTreeItem2Utils/useTreeItem2Utils.d.ts +4 -0
  8. package/hooks/useTreeItem2Utils/useTreeItem2Utils.js +9 -0
  9. package/hooks/useTreeViewApiRef.d.ts +1 -1
  10. package/index.js +1 -1
  11. package/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +3 -1
  12. package/internals/TreeViewProvider/TreeViewContext.d.ts +2 -8
  13. package/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -3
  14. package/internals/TreeViewProvider/useTreeViewContext.d.ts +1 -1
  15. package/internals/corePlugins/corePlugins.d.ts +4 -1
  16. package/internals/corePlugins/corePlugins.js +2 -1
  17. package/internals/corePlugins/index.d.ts +1 -1
  18. package/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.types.d.ts +0 -4
  19. package/internals/hooks/useInstanceEventHandler.d.ts +2 -2
  20. package/internals/index.d.ts +1 -2
  21. package/internals/index.js +3 -1
  22. package/internals/models/plugin.d.ts +22 -16
  23. package/internals/models/treeView.d.ts +2 -2
  24. package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +1 -1
  25. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.types.d.ts +1 -3
  26. package/internals/plugins/useTreeViewIcons/useTreeViewIcons.types.d.ts +1 -1
  27. package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.types.d.ts +1 -1
  28. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +1 -1
  29. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +1 -1
  30. package/internals/utils/publishTreeViewEvent.d.ts +1 -1
  31. package/internals/utils/utils.d.ts +1 -0
  32. package/internals/utils/utils.js +7 -1
  33. package/modern/RichTreeView/RichTreeView.plugins.js +1 -2
  34. package/modern/SimpleTreeView/SimpleTreeView.plugins.js +1 -2
  35. package/modern/hooks/useTreeItem2Utils/useTreeItem2Utils.js +9 -0
  36. package/modern/index.js +1 -1
  37. package/modern/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +3 -1
  38. package/modern/internals/corePlugins/corePlugins.js +2 -1
  39. package/modern/internals/index.js +3 -1
  40. package/modern/internals/utils/utils.js +7 -1
  41. package/node/RichTreeView/RichTreeView.plugins.js +1 -2
  42. package/node/SimpleTreeView/SimpleTreeView.plugins.js +1 -2
  43. package/node/hooks/useTreeItem2Utils/useTreeItem2Utils.js +9 -0
  44. package/node/index.js +1 -1
  45. package/node/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +3 -1
  46. package/node/internals/corePlugins/corePlugins.js +2 -1
  47. package/node/internals/index.js +0 -7
  48. package/node/internals/utils/utils.js +8 -1
  49. package/package.json +3 -3
  50. package/useTreeItem2/useTreeItem2.d.ts +1 -1
  51. package/useTreeItem2/useTreeItem2.types.d.ts +10 -5
  52. /package/internals/{plugins → corePlugins}/useTreeViewId/index.d.ts +0 -0
  53. /package/internals/{plugins → corePlugins}/useTreeViewId/index.js +0 -0
  54. /package/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.d.ts +0 -0
  55. /package/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.js +0 -0
  56. /package/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.types.js +0 -0
  57. /package/modern/internals/{plugins → corePlugins}/useTreeViewId/index.js +0 -0
  58. /package/modern/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.js +0 -0
  59. /package/modern/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.types.js +0 -0
  60. /package/node/internals/{plugins → corePlugins}/useTreeViewId/index.js +0 -0
  61. /package/node/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.js +0 -0
  62. /package/node/internals/{plugins → corePlugins}/useTreeViewId/useTreeViewId.types.js +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,88 @@
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.7.1
7
+
8
+ _Jun 21, 2024_
9
+
10
+ We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🌍 Improve Portuguese (pt-PT) locale on the Data Grid
13
+ - 🌍 Improve Danish (da-DK) locale on the Date and Time Pickers
14
+ - 🐞 Bugfixes
15
+ - 📚 Documentation improvements
16
+
17
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
18
+
19
+ ### Data Grid
20
+
21
+ #### `@mui/x-data-grid@7.7.1`
22
+
23
+ - [DataGrid][docs] Clarify enabling pagination (#13350) @oliviertassinari
24
+ - [DataGrid] Fix CSV export escaping for non-string values (#13560) @joeycumines-scw
25
+ - [l10n] Improve Portuguese (pt-PT) locale (#13348) @joaosreis
26
+
27
+ #### `@mui/x-data-grid-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
28
+
29
+ Same changes as in `@mui/x-data-grid@7.7.1`, plus:
30
+
31
+ - [DataGrid] Warn about `getTreeDataPath` reference (#13519) @cherniavskii
32
+
33
+ #### `@mui/x-data-grid-premium@7.7.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
34
+
35
+ Same changes as in `@mui/x-data-grid-pro@7.7.1`.
36
+
37
+ ### Date and Time Pickers
38
+
39
+ #### `@mui/x-date-pickers@7.7.1`
40
+
41
+ - [fields] Prevent digit editing on the `Space` key down (#13510) @flaviendelangle
42
+ - [l10n] Improve Danish (da-DK) locale (#13375) @jacrowland1
43
+ - [pickers] Add context to `onAccept` callback (#13511) @flaviendelangle
44
+ - [pickers] Always use the same timezone in the field, the view and the layout components (#13481) @flaviendelangle
45
+ - [pickers] Fix `AdapterDateFnsV3` generated method types (#13464) @alexey-kozlenkov
46
+ - [pickers] Fix controlled `view` behavior (#13552) @LukasTy
47
+ - [TimePicker] Improves RTL verification for the time pickers default views (#13447) @arthurbalduini
48
+
49
+ #### `@mui/x-date-pickers-pro@7.7.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
+
51
+ Same changes as in `@mui/x-date-pickers@7.7.1`, plus:
52
+
53
+ - [DateRangePicker] Add accessible name to calendar grid (#13538) @LukasTy
54
+
55
+ ### Charts
56
+
57
+ #### `@mui/x-charts@7.7.1`
58
+
59
+ - [charts] Divide `CartesianProvider` to use logic in Pro package (#13531) @JCQuintas
60
+ - [charts] Do not publish the pro package (#13539) @alexfauquette
61
+ - [charts] Export `Pro` versions of regular charts (#13547) @JCQuintas
62
+ - [charts] Prepare `ChartContainerPro` for future Zoom changes (#13532) @JCQuintas
63
+ - [charts] Remove unnecessary proptypes from internal component (#13518) @JCQuintas
64
+
65
+ ### Tree View
66
+
67
+ #### `@mui/x-tree-view@7.7.1`
68
+
69
+ - [TreeView] Improve typing to support optional dependencies in plugins and in the item (#13523) @flaviendelangle
70
+ - [TreeView] Move `useTreeViewId` to the core plugins (#13566) @flaviendelangle
71
+ - [TreeView] Remove unused state from `useTreeViewId` (#13579) @flaviendelangle
72
+ - [TreeView] Support `itemId` with escaping characters when using `SimpleTreeView` (#13487) @oukunan
73
+
74
+ ### Docs
75
+
76
+ - [docs] Add section about the new uncovered product watermark (#13568) @michelengelen
77
+ - [docs] Document the `PickerValidDate` type override (#13476) @flaviendelangle
78
+ - [docs] Fix typo (#13507) @anshtiwatne
79
+ - [docs] Remove "-" in heat-map and tree-map urls (#13569) @alexfauquette
80
+ - [docs] Use dedicated tab for weather dataset (#13513) @alexfauquette
81
+ - [x-license] license update proposal (#13459) @michelengelen
82
+
83
+ ### Core
84
+
85
+ - [core] Fix failing CI test (#13574) @alexfauquette
86
+ - [infra] Remove explicit `@testing-library/react` dependency (#13478) @LukasTy
87
+
6
88
  ## 7.7.0
7
89
 
8
90
  _Jun 13, 2024_
@@ -1,13 +1,13 @@
1
- import { UseTreeViewIdParameters } from '../internals/plugins/useTreeViewId';
1
+ import { TreeViewCorePluginParameters } from '../internals/corePlugins';
2
2
  import { UseTreeViewItemsParameters } from '../internals/plugins/useTreeViewItems';
3
3
  import { UseTreeViewExpansionParameters } from '../internals/plugins/useTreeViewExpansion';
4
4
  import { UseTreeViewSelectionParameters } from '../internals/plugins/useTreeViewSelection';
5
5
  import { UseTreeViewFocusParameters } from '../internals/plugins/useTreeViewFocus';
6
6
  import { UseTreeViewIconsParameters } from '../internals/plugins/useTreeViewIcons';
7
7
  import { ConvertPluginsIntoSignatures, MergeSignaturesProperty } from '../internals/models';
8
- export declare const RICH_TREE_VIEW_PLUGINS: readonly [import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewId").UseTreeViewIdSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewItems").UseTreeViewItemsSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewExpansion").UseTreeViewExpansionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewSelection").UseTreeViewSelectionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewFocus").UseTreeViewFocusSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewKeyboardNavigation").UseTreeViewKeyboardNavigationSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewIcons").UseTreeViewIconsSignature>];
8
+ export declare const RICH_TREE_VIEW_PLUGINS: readonly [import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewItems").UseTreeViewItemsSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewExpansion").UseTreeViewExpansionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewSelection").UseTreeViewSelectionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewFocus").UseTreeViewFocusSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewKeyboardNavigation").UseTreeViewKeyboardNavigationSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewIcons").UseTreeViewIconsSignature>];
9
9
  export type RichTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof RICH_TREE_VIEW_PLUGINS>;
10
10
  export type RichTreeViewPluginSlots = MergeSignaturesProperty<RichTreeViewPluginSignatures, 'slots'>;
11
11
  export type RichTreeViewPluginSlotProps = MergeSignaturesProperty<RichTreeViewPluginSignatures, 'slotProps'>;
12
- export interface RichTreeViewPluginParameters<R extends {}, Multiple extends boolean | undefined> extends UseTreeViewIdParameters, UseTreeViewItemsParameters<R>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple>, UseTreeViewIconsParameters {
12
+ export interface RichTreeViewPluginParameters<R extends {}, Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, UseTreeViewItemsParameters<R>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple>, UseTreeViewIconsParameters {
13
13
  }
@@ -1,10 +1,9 @@
1
- import { useTreeViewId } from '../internals/plugins/useTreeViewId';
2
1
  import { useTreeViewItems } from '../internals/plugins/useTreeViewItems';
3
2
  import { useTreeViewExpansion } from '../internals/plugins/useTreeViewExpansion';
4
3
  import { useTreeViewSelection } from '../internals/plugins/useTreeViewSelection';
5
4
  import { useTreeViewFocus } from '../internals/plugins/useTreeViewFocus';
6
5
  import { useTreeViewKeyboardNavigation } from '../internals/plugins/useTreeViewKeyboardNavigation';
7
6
  import { useTreeViewIcons } from '../internals/plugins/useTreeViewIcons';
8
- export const RICH_TREE_VIEW_PLUGINS = [useTreeViewId, useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons];
7
+ export const RICH_TREE_VIEW_PLUGINS = [useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons];
9
8
 
10
9
  // We can't infer this type from the plugin, otherwise we would lose the generics.
@@ -1,13 +1,13 @@
1
- import { UseTreeViewIdParameters } from '../internals/plugins/useTreeViewId';
1
+ import { TreeViewCorePluginParameters } from '../internals/corePlugins';
2
2
  import { UseTreeViewItemsParameters } from '../internals/plugins/useTreeViewItems';
3
3
  import { UseTreeViewExpansionParameters } from '../internals/plugins/useTreeViewExpansion';
4
4
  import { UseTreeViewSelectionParameters } from '../internals/plugins/useTreeViewSelection';
5
5
  import { UseTreeViewFocusParameters } from '../internals/plugins/useTreeViewFocus';
6
6
  import { UseTreeViewIconsParameters } from '../internals/plugins/useTreeViewIcons';
7
7
  import { ConvertPluginsIntoSignatures, MergeSignaturesProperty } from '../internals/models';
8
- export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewId").UseTreeViewIdSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewItems").UseTreeViewItemsSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewExpansion").UseTreeViewExpansionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewSelection").UseTreeViewSelectionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewFocus").UseTreeViewFocusSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewKeyboardNavigation").UseTreeViewKeyboardNavigationSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewIcons").UseTreeViewIconsSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewJSXItems").UseTreeViewJSXItemsSignature>];
8
+ export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewItems").UseTreeViewItemsSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewExpansion").UseTreeViewExpansionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewSelection").UseTreeViewSelectionSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewFocus").UseTreeViewFocusSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewKeyboardNavigation").UseTreeViewKeyboardNavigationSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewIcons").UseTreeViewIconsSignature>, import("../internals/models").TreeViewPlugin<import("../internals/plugins/useTreeViewJSXItems").UseTreeViewJSXItemsSignature>];
9
9
  export type SimpleTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
10
10
  export type SimpleTreeViewPluginSlots = MergeSignaturesProperty<SimpleTreeViewPluginSignatures, 'slots'>;
11
11
  export type SimpleTreeViewPluginSlotProps = MergeSignaturesProperty<SimpleTreeViewPluginSignatures, 'slotProps'>;
12
- export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends UseTreeViewIdParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple>, UseTreeViewIconsParameters {
12
+ export interface SimpleTreeViewPluginParameters<Multiple extends boolean | undefined> extends TreeViewCorePluginParameters, Omit<UseTreeViewItemsParameters<any>, 'items' | 'isItemDisabled' | 'getItemLabel' | 'getItemId'>, UseTreeViewExpansionParameters, UseTreeViewFocusParameters, UseTreeViewSelectionParameters<Multiple>, UseTreeViewIconsParameters {
13
13
  }
@@ -1,4 +1,3 @@
1
- import { useTreeViewId } from '../internals/plugins/useTreeViewId';
2
1
  import { useTreeViewItems } from '../internals/plugins/useTreeViewItems';
3
2
  import { useTreeViewExpansion } from '../internals/plugins/useTreeViewExpansion';
4
3
  import { useTreeViewSelection } from '../internals/plugins/useTreeViewSelection';
@@ -6,6 +5,6 @@ import { useTreeViewFocus } from '../internals/plugins/useTreeViewFocus';
6
5
  import { useTreeViewKeyboardNavigation } from '../internals/plugins/useTreeViewKeyboardNavigation';
7
6
  import { useTreeViewIcons } from '../internals/plugins/useTreeViewIcons';
8
7
  import { useTreeViewJSXItems } from '../internals/plugins/useTreeViewJSXItems';
9
- export const SIMPLE_TREE_VIEW_PLUGINS = [useTreeViewId, useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons, useTreeViewJSXItems];
8
+ export const SIMPLE_TREE_VIEW_PLUGINS = [useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons, useTreeViewJSXItems];
10
9
 
11
10
  // We can't infer this type from the plugin, otherwise we would lose the generics.
@@ -14,7 +14,6 @@ import { UseTreeViewItemsSignature } from '../internals/plugins/useTreeViewItems
14
14
  import { UseTreeViewFocusSignature } from '../internals/plugins/useTreeViewFocus';
15
15
  import { UseTreeViewExpansionSignature } from '../internals/plugins/useTreeViewExpansion';
16
16
  import { UseTreeViewKeyboardNavigationSignature } from '../internals/plugins/useTreeViewKeyboardNavigation';
17
- import { UseTreeViewIdSignature } from '../internals/plugins/useTreeViewId';
18
17
  export interface TreeItemSlots {
19
18
  /**
20
19
  * The icon used to collapse the item.
@@ -110,12 +109,18 @@ export interface TreeItemOwnerState extends TreeItemProps {
110
109
  disabled: boolean;
111
110
  indentationAtItemLevel: boolean;
112
111
  }
112
+ /**
113
+ * Plugins that need to be present in the Tree View in order for `TreeItem` to work correctly.
114
+ */
113
115
  export type TreeItemMinimalPlugins = readonly [
114
116
  UseTreeViewIconsSignature,
115
117
  UseTreeViewSelectionSignature,
116
118
  UseTreeViewItemsSignature,
117
119
  UseTreeViewFocusSignature,
118
120
  UseTreeViewExpansionSignature,
119
- UseTreeViewKeyboardNavigationSignature,
120
- UseTreeViewIdSignature
121
+ UseTreeViewKeyboardNavigationSignature
121
122
  ];
123
+ /**
124
+ * Plugins that `TreeItem` can use if they are present, but are not required.
125
+ */
126
+ export type TreeItemOptionalPlugins = readonly [];
@@ -9,6 +9,10 @@ interface UseTreeItem2UtilsReturnValue {
9
9
  interactions: UseTreeItem2Interactions;
10
10
  status: UseTreeItem2Status;
11
11
  }
12
+ /**
13
+ * Plugins that `useTreeItem2Utils` can use if they are present, but are not required.
14
+ */
15
+ export type UseTreeItem2UtilsOptionalPlugins = readonly [];
12
16
  export declare const useTreeItem2Utils: ({ itemId, children, }: {
13
17
  itemId: string;
14
18
  children: React.ReactNode;
@@ -5,6 +5,15 @@ const isItemExpandable = reactChildren => {
5
5
  }
6
6
  return Boolean(reactChildren);
7
7
  };
8
+
9
+ /**
10
+ * Plugins that need to be present in the Tree View in order for `useTreeItem2Utils` to work correctly.
11
+ */
12
+
13
+ /**
14
+ * Plugins that `useTreeItem2Utils` can use if they are present, but are not required.
15
+ */
16
+
8
17
  export const useTreeItem2Utils = ({
9
18
  itemId,
10
19
  children
@@ -3,4 +3,4 @@ import { TreeViewAnyPluginSignature, TreeViewPublicAPI } from '../internals/mode
3
3
  /**
4
4
  * Hook that instantiates a [[TreeViewApiRef]].
5
5
  */
6
- export declare const useTreeViewApiRef: <TSignatures extends readonly TreeViewAnyPluginSignature[] = readonly [import("../internals").UseTreeViewIdSignature, import("../internals").UseTreeViewItemsSignature, import("../internals").UseTreeViewExpansionSignature, import("../internals").UseTreeViewSelectionSignature, import("../internals").UseTreeViewFocusSignature, import("../internals").UseTreeViewKeyboardNavigationSignature, import("../internals").UseTreeViewIconsSignature]>() => React.MutableRefObject<TreeViewPublicAPI<TSignatures> | undefined>;
6
+ export declare const useTreeViewApiRef: <TSignatures extends readonly TreeViewAnyPluginSignature[] = readonly [import("../internals").UseTreeViewItemsSignature, import("../internals").UseTreeViewExpansionSignature, import("../internals").UseTreeViewSelectionSignature, import("../internals").UseTreeViewFocusSignature, import("../internals").UseTreeViewKeyboardNavigationSignature, import("../internals").UseTreeViewIconsSignature]>() => React.MutableRefObject<TreeViewPublicAPI<TSignatures> | undefined>;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.7.0
2
+ * @mui/x-tree-view v7.7.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useTreeViewContext } from './useTreeViewContext';
4
+ import { escapeOperandAttributeSelector } from '../utils/utils';
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  export const TreeViewChildrenItemContext = /*#__PURE__*/React.createContext(null);
6
7
  if (process.env.NODE_ENV !== 'production') {
@@ -34,7 +35,8 @@ export function TreeViewChildrenItemProvider(props) {
34
35
  return;
35
36
  }
36
37
  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 escapedIdAttr = escapeOperandAttributeSelector(idAttr);
39
+ const childrenElements = rootRef.current.querySelectorAll(`${itemId == null ? '' : `*[id="${escapedIdAttr}"] `}[role="treeitem"]:not(*[id="${escapedIdAttr}"] [role="treeitem"] [role="treeitem"])`);
38
40
  const childrenIds = Array.from(childrenElements).map(child => childrenIdAttrToIdRef.current.get(child.id));
39
41
  const hasChanged = childrenIds.length !== previousChildrenIds.length || childrenIds.some((childId, index) => childId !== previousChildrenIds[index]);
40
42
  if (hasChanged) {
@@ -1,12 +1,6 @@
1
1
  import * as React from 'react';
2
+ import { TreeViewContextValue } from './TreeViewProvider.types';
2
3
  /**
3
4
  * @ignore - internal component.
4
5
  */
5
- export declare const TreeViewContext: React.Context<{
6
- instance: import("../corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types").UseTreeViewInstanceEventsInstance;
7
- publicAPI: {};
8
- rootRef: React.RefObject<HTMLUListElement>;
9
- wrapItem: import("../models").TreeItemWrapper<any>;
10
- wrapRoot: import("../models").TreeRootWrapper<any>;
11
- runItemPlugins: import("./TreeViewProvider.types").TreeViewItemPluginsRunner;
12
- } | null>;
6
+ export declare const TreeViewContext: React.Context<TreeViewContextValue<any> | null>;
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { MergeSignaturesProperty, TreeItemWrapper, TreeRootWrapper, TreeViewAnyPluginSignature, TreeViewInstance, TreeViewItemPluginResponse, TreeViewPublicAPI } from '../models';
3
3
  export type TreeViewItemPluginsRunner = <TProps extends {}>(props: TProps) => Required<TreeViewItemPluginResponse>;
4
- export type TreeViewContextValue<TSignatures extends readonly TreeViewAnyPluginSignature[]> = MergeSignaturesProperty<TSignatures, 'contextValue'> & {
5
- instance: TreeViewInstance<TSignatures>;
6
- publicAPI: TreeViewPublicAPI<TSignatures>;
4
+ export type TreeViewContextValue<TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []> = MergeSignaturesProperty<TSignatures, 'contextValue'> & Partial<MergeSignaturesProperty<TOptionalSignatures, 'contextValue'>> & {
5
+ instance: TreeViewInstance<TSignatures, TOptionalSignatures>;
6
+ publicAPI: TreeViewPublicAPI<TSignatures, TOptionalSignatures>;
7
7
  rootRef: React.RefObject<HTMLUListElement>;
8
8
  wrapItem: TreeItemWrapper<TSignatures>;
9
9
  wrapRoot: TreeRootWrapper<TSignatures>;
@@ -1,3 +1,3 @@
1
1
  import { TreeViewAnyPluginSignature } from '../models';
2
2
  import { TreeViewContextValue } from './TreeViewProvider.types';
3
- export declare const useTreeViewContext: <TSignatures extends readonly TreeViewAnyPluginSignature[]>() => NonNullable<TreeViewContextValue<TSignatures>>;
3
+ export declare const useTreeViewContext: <TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []>() => NonNullable<TreeViewContextValue<TSignatures, TOptionalSignatures>>;
@@ -1,7 +1,10 @@
1
+ import { UseTreeViewIdParameters } from './useTreeViewId';
1
2
  import { ConvertPluginsIntoSignatures } from '../models';
2
3
  /**
3
4
  * Internal plugins that create the tools used by the other plugins.
4
5
  * These plugins are used by the tree view components.
5
6
  */
6
- export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("../models").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>];
7
+ export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("../models").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>, import("../models").TreeViewPlugin<import("./useTreeViewId").UseTreeViewIdSignature>];
7
8
  export type TreeViewCorePluginSignatures = ConvertPluginsIntoSignatures<typeof TREE_VIEW_CORE_PLUGINS>;
9
+ export interface TreeViewCorePluginParameters extends UseTreeViewIdParameters {
10
+ }
@@ -1,6 +1,7 @@
1
1
  import { useTreeViewInstanceEvents } from './useTreeViewInstanceEvents';
2
+ import { useTreeViewId } from './useTreeViewId';
2
3
  /**
3
4
  * Internal plugins that create the tools used by the other plugins.
4
5
  * These plugins are used by the tree view components.
5
6
  */
6
- export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents];
7
+ export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents, useTreeViewId];
@@ -1,2 +1,2 @@
1
1
  export { TREE_VIEW_CORE_PLUGINS } from './corePlugins';
2
- export type { TreeViewCorePluginSignatures } from './corePlugins';
2
+ export type { TreeViewCorePluginSignatures, TreeViewCorePluginParameters } from './corePlugins';
@@ -19,12 +19,8 @@ export interface UseTreeViewIdParameters {
19
19
  id?: string;
20
20
  }
21
21
  export type UseTreeViewIdDefaultizedParameters = UseTreeViewIdParameters;
22
- export interface UseTreeViewIdState {
23
- focusedItemId: string | null;
24
- }
25
22
  export type UseTreeViewIdSignature = TreeViewPluginSignature<{
26
23
  params: UseTreeViewIdParameters;
27
24
  defaultizedParams: UseTreeViewIdDefaultizedParameters;
28
25
  instance: UseTreeViewIdInstance;
29
- state: UseTreeViewIdState;
30
26
  }>;
@@ -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").MergeSignaturesProperty<[import("../corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types").UseTreeViewInstanceEventsSignature, ...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").MergeSignaturesProperty<[import("../corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types").UseTreeViewInstanceEventsSignature, import("../corePlugins/useTreeViewId").UseTreeViewIdSignature, ...Instance["$$signature"]["dependencies"]], "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").MergeSignaturesProperty<[import("../corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types").UseTreeViewInstanceEventsSignature, ...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").MergeSignaturesProperty<[import("../corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types").UseTreeViewInstanceEventsSignature, import("../corePlugins/useTreeViewId").UseTreeViewIdSignature, ...Instance["$$signature"]["dependencies"]], "events">>(instance: Instance, eventName: E, handler: TreeViewEventListener<TreeViewUsedEvents<Instance['$$signature']>[E]>) => void;
15
15
  export {};
@@ -2,6 +2,7 @@ export { useTreeView } from './useTreeView';
2
2
  export { TreeViewProvider } from './TreeViewProvider';
3
3
  export { unstable_resetCleanupTracking } from './hooks/useInstanceEventHandler';
4
4
  export type { TreeViewPlugin, TreeViewPluginSignature, ConvertPluginsIntoSignatures, MergeSignaturesProperty, TreeViewPublicAPI, TreeViewExperimentalFeatures, } from './models';
5
+ export type { TreeViewCorePluginParameters } from './corePlugins';
5
6
  export { useTreeViewExpansion } from './plugins/useTreeViewExpansion';
6
7
  export type { UseTreeViewExpansionSignature, UseTreeViewExpansionParameters, } from './plugins/useTreeViewExpansion';
7
8
  export { useTreeViewSelection } from './plugins/useTreeViewSelection';
@@ -10,8 +11,6 @@ export { useTreeViewFocus } from './plugins/useTreeViewFocus';
10
11
  export type { UseTreeViewFocusSignature, UseTreeViewFocusParameters, } from './plugins/useTreeViewFocus';
11
12
  export { useTreeViewKeyboardNavigation } from './plugins/useTreeViewKeyboardNavigation';
12
13
  export type { UseTreeViewKeyboardNavigationSignature } from './plugins/useTreeViewKeyboardNavigation';
13
- export { useTreeViewId } from './plugins/useTreeViewId';
14
- export type { UseTreeViewIdSignature, UseTreeViewIdParameters } from './plugins/useTreeViewId';
15
14
  export { useTreeViewIcons } from './plugins/useTreeViewIcons';
16
15
  export type { UseTreeViewIconsSignature, UseTreeViewIconsParameters, } from './plugins/useTreeViewIcons';
17
16
  export { useTreeViewItems } from './plugins/useTreeViewItems';
@@ -1,12 +1,14 @@
1
1
  export { useTreeView } from './useTreeView';
2
2
  export { TreeViewProvider } from './TreeViewProvider';
3
3
  export { unstable_resetCleanupTracking } from './hooks/useInstanceEventHandler';
4
+
5
+ // Core plugins
6
+
4
7
  // Plugins
5
8
  export { useTreeViewExpansion } from './plugins/useTreeViewExpansion';
6
9
  export { useTreeViewSelection } from './plugins/useTreeViewSelection';
7
10
  export { useTreeViewFocus } from './plugins/useTreeViewFocus';
8
11
  export { useTreeViewKeyboardNavigation } from './plugins/useTreeViewKeyboardNavigation';
9
- export { useTreeViewId } from './plugins/useTreeViewId';
10
12
  export { useTreeViewIcons } from './plugins/useTreeViewIcons';
11
13
  export { useTreeViewItems } from './plugins/useTreeViewItems';
12
14
  export { useTreeViewJSXItems } from './plugins/useTreeViewJSXItems';
@@ -42,7 +42,8 @@ export type TreeViewPluginSignature<T extends {
42
42
  };
43
43
  modelNames?: keyof T['defaultizedParams'];
44
44
  experimentalFeatures?: string;
45
- dependantPlugins?: readonly TreeViewAnyPluginSignature[];
45
+ dependencies?: readonly TreeViewAnyPluginSignature[];
46
+ optionalDependencies?: readonly TreeViewAnyPluginSignature[];
46
47
  }> = {
47
48
  params: T extends {
48
49
  params: {};
@@ -78,16 +79,20 @@ export type TreeViewPluginSignature<T extends {
78
79
  [TControlled in T['modelNames']]-?: TreeViewModel<Exclude<T['defaultizedParams'][TControlled], undefined>>;
79
80
  } : {};
80
81
  experimentalFeatures: T['experimentalFeatures'];
81
- dependantPlugins: T extends {
82
- dependantPlugins: Array<any>;
83
- } ? T['dependantPlugins'] : [];
82
+ dependencies: T extends {
83
+ dependencies: Array<any>;
84
+ } ? T['dependencies'] : [];
85
+ optionalDependencies: T extends {
86
+ optionalDependencies: Array<any>;
87
+ } ? T['optionalDependencies'] : [];
84
88
  };
85
89
  export type TreeViewAnyPluginSignature = {
86
90
  state: any;
87
91
  instance: any;
88
92
  params: any;
89
93
  defaultizedParams: any;
90
- dependantPlugins: any;
94
+ dependencies: any;
95
+ optionalDependencies: any;
91
96
  events: any;
92
97
  contextValue: any;
93
98
  slots: any;
@@ -96,25 +101,26 @@ export type TreeViewAnyPluginSignature = {
96
101
  experimentalFeatures: any;
97
102
  publicAPI: any;
98
103
  };
99
- type TreeViewUsedPlugins<TSignature extends TreeViewAnyPluginSignature> = [
104
+ type TreeViewRequiredPlugins<TSignature extends TreeViewAnyPluginSignature> = [
100
105
  ...TreeViewCorePluginSignatures,
101
- ...TSignature['dependantPlugins']
106
+ ...TSignature['dependencies']
102
107
  ];
103
- export type TreeViewUsedParams<TSignature extends TreeViewAnyPluginSignature> = TSignature['params'] & MergeSignaturesProperty<TreeViewUsedPlugins<TSignature>, 'params'>;
104
- type TreeViewUsedDefaultizedParams<TSignature extends TreeViewAnyPluginSignature> = TSignature['defaultizedParams'] & MergeSignaturesProperty<TreeViewUsedPlugins<TSignature>, 'defaultizedParams'>;
105
- export type TreeViewUsedInstance<TSignature extends TreeViewAnyPluginSignature> = TSignature['instance'] & MergeSignaturesProperty<TreeViewUsedPlugins<TSignature>, 'instance'> & {
108
+ type PluginPropertyWithDependencies<TSignature extends TreeViewAnyPluginSignature, TProperty extends keyof TreeViewAnyPluginSignature> = TSignature[TProperty] & MergeSignaturesProperty<TreeViewRequiredPlugins<TSignature>, TProperty> & Partial<MergeSignaturesProperty<TSignature['optionalDependencies'], TProperty>>;
109
+ export type TreeViewUsedParams<TSignature extends TreeViewAnyPluginSignature> = PluginPropertyWithDependencies<TSignature, 'params'>;
110
+ type TreeViewUsedDefaultizedParams<TSignature extends TreeViewAnyPluginSignature> = PluginPropertyWithDependencies<TSignature, 'defaultizedParams'>;
111
+ export type TreeViewUsedInstance<TSignature extends TreeViewAnyPluginSignature> = PluginPropertyWithDependencies<TSignature, 'instance'> & {
106
112
  /**
107
113
  * Private property only defined in TypeScript to be able to access the plugin signature from the instance object.
108
114
  */
109
115
  $$signature: TSignature;
110
116
  };
111
- type TreeViewUsedState<TSignature extends TreeViewAnyPluginSignature> = TSignature['state'] & MergeSignaturesProperty<TreeViewUsedPlugins<TSignature>, 'state'>;
112
- type TreeViewUsedExperimentalFeatures<TSignature extends TreeViewAnyPluginSignature> = TreeViewExperimentalFeatures<[TSignature, ...TSignature['dependantPlugins']]>;
117
+ type TreeViewUsedState<TSignature extends TreeViewAnyPluginSignature> = PluginPropertyWithDependencies<TSignature, 'state'>;
118
+ type TreeViewUsedExperimentalFeatures<TSignature extends TreeViewAnyPluginSignature> = TreeViewExperimentalFeatures<[TSignature, ...TSignature['dependencies']]>;
113
119
  type RemoveSetValue<Models extends Record<string, TreeViewModel<any>>> = {
114
120
  [K in keyof Models]: Omit<Models[K], 'setValue'>;
115
121
  };
116
- export type TreeViewUsedModels<TSignature extends TreeViewAnyPluginSignature> = TSignature['models'] & RemoveSetValue<MergeSignaturesProperty<TreeViewUsedPlugins<TSignature>, 'models'>>;
117
- export type TreeViewUsedEvents<TSignature extends TreeViewAnyPluginSignature> = TSignature['events'] & MergeSignaturesProperty<TreeViewUsedPlugins<TSignature>, 'events'>;
122
+ export type TreeViewUsedModels<TSignature extends TreeViewAnyPluginSignature> = TSignature['models'] & RemoveSetValue<MergeSignaturesProperty<TreeViewRequiredPlugins<TSignature>, 'models'>>;
123
+ export type TreeViewUsedEvents<TSignature extends TreeViewAnyPluginSignature> = TSignature['events'] & MergeSignaturesProperty<TreeViewRequiredPlugins<TSignature>, 'events'>;
118
124
  export interface TreeViewItemPluginOptions<TProps extends {}> extends TreeViewItemPluginResponse {
119
125
  props: TProps;
120
126
  }
@@ -150,12 +156,12 @@ export type TreeViewPlugin<TSignature extends TreeViewAnyPluginSignature> = {
150
156
  * @param {{ nodeId: TreeViewItemId; children: React.ReactNode; }} params The params of the item.
151
157
  * @returns {React.ReactNode} The wrapped item.
152
158
  */
153
- wrapItem?: TreeItemWrapper<[TSignature, ...TSignature['dependantPlugins']]>;
159
+ wrapItem?: TreeItemWrapper<[TSignature, ...TSignature['dependencies']]>;
154
160
  /**
155
161
  * Render function used to add React wrappers around the TreeView.
156
162
  * @param {{ children: React.ReactNode; }} params The params of the root.
157
163
  * @returns {React.ReactNode} The wrapped root.
158
164
  */
159
- wrapRoot?: TreeRootWrapper<[TSignature, ...TSignature['dependantPlugins']]>;
165
+ wrapRoot?: TreeRootWrapper<[TSignature, ...TSignature['dependencies']]>;
160
166
  };
161
167
  export {};
@@ -21,8 +21,8 @@ export interface TreeViewModel<TValue> {
21
21
  value: TValue;
22
22
  setControlledValue: (value: TValue | ((prevValue: TValue) => TValue)) => void;
23
23
  }
24
- export type TreeViewInstance<TSignatures extends readonly TreeViewAnyPluginSignature[]> = MergeSignaturesProperty<[...TreeViewCorePluginSignatures, ...TSignatures], 'instance'>;
25
- export type TreeViewPublicAPI<TSignatures extends readonly TreeViewAnyPluginSignature[]> = MergeSignaturesProperty<[...TreeViewCorePluginSignatures, ...TSignatures], 'publicAPI'>;
24
+ export type TreeViewInstance<TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []> = MergeSignaturesProperty<[...TreeViewCorePluginSignatures, ...TSignatures], 'instance'> & Partial<MergeSignaturesProperty<TOptionalSignatures, 'instance'>>;
25
+ export type TreeViewPublicAPI<TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []> = MergeSignaturesProperty<[...TreeViewCorePluginSignatures, ...TSignatures], 'publicAPI'> & Partial<MergeSignaturesProperty<TOptionalSignatures, 'instance'>>;
26
26
  export type TreeViewExperimentalFeatures<TSignatures extends readonly TreeViewAnyPluginSignature[]> = {
27
27
  [key in MergeSignaturesProperty<TSignatures, 'experimentalFeatures'>]?: boolean;
28
28
  };
@@ -73,5 +73,5 @@ export type UseTreeViewExpansionSignature = TreeViewPluginSignature<{
73
73
  instance: UseTreeViewExpansionInstance;
74
74
  publicAPI: UseTreeViewExpansionPublicAPI;
75
75
  modelNames: 'expandedItems';
76
- dependantPlugins: [UseTreeViewItemsSignature];
76
+ dependencies: [UseTreeViewItemsSignature];
77
77
  }>;
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { TreeViewPluginSignature } from '../../models';
3
- import { UseTreeViewIdSignature } from '../useTreeViewId/useTreeViewId.types';
4
3
  import type { UseTreeViewItemsSignature } from '../useTreeViewItems';
5
4
  import type { UseTreeViewSelectionSignature } from '../useTreeViewSelection';
6
5
  import { UseTreeViewExpansionSignature } from '../useTreeViewExpansion';
@@ -55,8 +54,7 @@ export type UseTreeViewFocusSignature = TreeViewPluginSignature<{
55
54
  instance: UseTreeViewFocusInstance;
56
55
  publicAPI: UseTreeViewFocusPublicAPI;
57
56
  state: UseTreeViewFocusState;
58
- dependantPlugins: [
59
- UseTreeViewIdSignature,
57
+ dependencies: [
60
58
  UseTreeViewItemsSignature,
61
59
  UseTreeViewSelectionSignature,
62
60
  UseTreeViewExpansionSignature
@@ -38,6 +38,6 @@ export type UseTreeViewIconsSignature = TreeViewPluginSignature<{
38
38
  contextValue: UseTreeViewIconsContextValue;
39
39
  slots: UseTreeViewIconsSlots;
40
40
  slotProps: UseTreeViewIconsSlotProps;
41
- dependantPlugins: [UseTreeViewItemsSignature, UseTreeViewSelectionSignature];
41
+ dependencies: [UseTreeViewItemsSignature, UseTreeViewSelectionSignature];
42
42
  }>;
43
43
  export {};
@@ -33,5 +33,5 @@ export type UseTreeViewJSXItemsSignature = TreeViewPluginSignature<{
33
33
  params: UseTreeViewJSXItemsParameters;
34
34
  defaultizedParams: UseTreeViewItemsDefaultizedParameters;
35
35
  instance: UseTreeViewItemsInstance;
36
- dependantPlugins: [UseTreeViewItemsSignature, UseTreeViewKeyboardNavigationSignature];
36
+ dependencies: [UseTreeViewItemsSignature, UseTreeViewKeyboardNavigationSignature];
37
37
  }>;
@@ -24,7 +24,7 @@ export interface UseTreeViewKeyboardNavigationInstance {
24
24
  }
25
25
  export type UseTreeViewKeyboardNavigationSignature = TreeViewPluginSignature<{
26
26
  instance: UseTreeViewKeyboardNavigationInstance;
27
- dependantPlugins: [
27
+ dependencies: [
28
28
  UseTreeViewItemsSignature,
29
29
  UseTreeViewSelectionSignature,
30
30
  UseTreeViewFocusSignature,
@@ -101,7 +101,7 @@ export type UseTreeViewSelectionSignature = TreeViewPluginSignature<{
101
101
  instance: UseTreeViewSelectionInstance;
102
102
  contextValue: UseTreeViewSelectionContextValue;
103
103
  modelNames: 'selectedItems';
104
- dependantPlugins: [
104
+ dependencies: [
105
105
  UseTreeViewItemsSignature,
106
106
  UseTreeViewExpansionSignature,
107
107
  UseTreeViewItemsSignature
@@ -2,4 +2,4 @@ import { UseTreeViewInstanceEventsInstance } from '../corePlugins/useTreeViewIns
2
2
  import { TreeViewAnyPluginSignature, TreeViewUsedEvents } from '../models';
3
3
  export declare const publishTreeViewEvent: <Instance extends UseTreeViewInstanceEventsInstance & {
4
4
  $$signature: TreeViewAnyPluginSignature;
5
- }, E extends keyof Instance["$$signature"]["events"] | keyof import("../models").MergeSignaturesProperty<[import("../corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types").UseTreeViewInstanceEventsSignature, ...Instance["$$signature"]["dependantPlugins"]], "events">>(instance: Instance, eventName: E, params: TreeViewUsedEvents<Instance['$$signature']>[E]['params']) => void;
5
+ }, E extends keyof Instance["$$signature"]["events"] | keyof import("../models").MergeSignaturesProperty<[import("../corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.types").UseTreeViewInstanceEventsSignature, import("../corePlugins/useTreeViewId").UseTreeViewIdSignature, ...Instance["$$signature"]["dependencies"]], "events">>(instance: Instance, eventName: E, params: TreeViewUsedEvents<Instance['$$signature']>[E]['params']) => void;
@@ -1 +1,2 @@
1
1
  export declare const getActiveElement: (root?: Document | ShadowRoot) => Element | null;
2
+ export declare function escapeOperandAttributeSelector(operand: string): string;
@@ -8,4 +8,10 @@ export const getActiveElement = (root = document) => {
8
8
  return getActiveElement(activeEl.shadowRoot);
9
9
  }
10
10
  return activeEl;
11
- };
11
+ };
12
+
13
+ // TODO, eventually replaces this function with CSS.escape, once available in jsdom, either added manually or built in
14
+ // https://github.com/jsdom/jsdom/issues/1550#issuecomment-236734471
15
+ export function escapeOperandAttributeSelector(operand) {
16
+ return operand.replace(/["\\]/g, '\\$&');
17
+ }
@@ -1,10 +1,9 @@
1
- import { useTreeViewId } from '../internals/plugins/useTreeViewId';
2
1
  import { useTreeViewItems } from '../internals/plugins/useTreeViewItems';
3
2
  import { useTreeViewExpansion } from '../internals/plugins/useTreeViewExpansion';
4
3
  import { useTreeViewSelection } from '../internals/plugins/useTreeViewSelection';
5
4
  import { useTreeViewFocus } from '../internals/plugins/useTreeViewFocus';
6
5
  import { useTreeViewKeyboardNavigation } from '../internals/plugins/useTreeViewKeyboardNavigation';
7
6
  import { useTreeViewIcons } from '../internals/plugins/useTreeViewIcons';
8
- export const RICH_TREE_VIEW_PLUGINS = [useTreeViewId, useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons];
7
+ export const RICH_TREE_VIEW_PLUGINS = [useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons];
9
8
 
10
9
  // We can't infer this type from the plugin, otherwise we would lose the generics.
@@ -1,4 +1,3 @@
1
- import { useTreeViewId } from '../internals/plugins/useTreeViewId';
2
1
  import { useTreeViewItems } from '../internals/plugins/useTreeViewItems';
3
2
  import { useTreeViewExpansion } from '../internals/plugins/useTreeViewExpansion';
4
3
  import { useTreeViewSelection } from '../internals/plugins/useTreeViewSelection';
@@ -6,6 +5,6 @@ import { useTreeViewFocus } from '../internals/plugins/useTreeViewFocus';
6
5
  import { useTreeViewKeyboardNavigation } from '../internals/plugins/useTreeViewKeyboardNavigation';
7
6
  import { useTreeViewIcons } from '../internals/plugins/useTreeViewIcons';
8
7
  import { useTreeViewJSXItems } from '../internals/plugins/useTreeViewJSXItems';
9
- export const SIMPLE_TREE_VIEW_PLUGINS = [useTreeViewId, useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons, useTreeViewJSXItems];
8
+ export const SIMPLE_TREE_VIEW_PLUGINS = [useTreeViewItems, useTreeViewExpansion, useTreeViewSelection, useTreeViewFocus, useTreeViewKeyboardNavigation, useTreeViewIcons, useTreeViewJSXItems];
10
9
 
11
10
  // We can't infer this type from the plugin, otherwise we would lose the generics.
@@ -5,6 +5,15 @@ const isItemExpandable = reactChildren => {
5
5
  }
6
6
  return Boolean(reactChildren);
7
7
  };
8
+
9
+ /**
10
+ * Plugins that need to be present in the Tree View in order for `useTreeItem2Utils` to work correctly.
11
+ */
12
+
13
+ /**
14
+ * Plugins that `useTreeItem2Utils` can use if they are present, but are not required.
15
+ */
16
+
8
17
  export const useTreeItem2Utils = ({
9
18
  itemId,
10
19
  children
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.7.0
2
+ * @mui/x-tree-view v7.7.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useTreeViewContext } from './useTreeViewContext';
4
+ import { escapeOperandAttributeSelector } from '../utils/utils';
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  export const TreeViewChildrenItemContext = /*#__PURE__*/React.createContext(null);
6
7
  if (process.env.NODE_ENV !== 'production') {
@@ -34,7 +35,8 @@ export function TreeViewChildrenItemProvider(props) {
34
35
  return;
35
36
  }
36
37
  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 escapedIdAttr = escapeOperandAttributeSelector(idAttr);
39
+ const childrenElements = rootRef.current.querySelectorAll(`${itemId == null ? '' : `*[id="${escapedIdAttr}"] `}[role="treeitem"]:not(*[id="${escapedIdAttr}"] [role="treeitem"] [role="treeitem"])`);
38
40
  const childrenIds = Array.from(childrenElements).map(child => childrenIdAttrToIdRef.current.get(child.id));
39
41
  const hasChanged = childrenIds.length !== previousChildrenIds.length || childrenIds.some((childId, index) => childId !== previousChildrenIds[index]);
40
42
  if (hasChanged) {
@@ -1,6 +1,7 @@
1
1
  import { useTreeViewInstanceEvents } from './useTreeViewInstanceEvents';
2
+ import { useTreeViewId } from './useTreeViewId';
2
3
  /**
3
4
  * Internal plugins that create the tools used by the other plugins.
4
5
  * These plugins are used by the tree view components.
5
6
  */
6
- export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents];
7
+ export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents, useTreeViewId];
@@ -1,12 +1,14 @@
1
1
  export { useTreeView } from './useTreeView';
2
2
  export { TreeViewProvider } from './TreeViewProvider';
3
3
  export { unstable_resetCleanupTracking } from './hooks/useInstanceEventHandler';
4
+
5
+ // Core plugins
6
+
4
7
  // Plugins
5
8
  export { useTreeViewExpansion } from './plugins/useTreeViewExpansion';
6
9
  export { useTreeViewSelection } from './plugins/useTreeViewSelection';
7
10
  export { useTreeViewFocus } from './plugins/useTreeViewFocus';
8
11
  export { useTreeViewKeyboardNavigation } from './plugins/useTreeViewKeyboardNavigation';
9
- export { useTreeViewId } from './plugins/useTreeViewId';
10
12
  export { useTreeViewIcons } from './plugins/useTreeViewIcons';
11
13
  export { useTreeViewItems } from './plugins/useTreeViewItems';
12
14
  export { useTreeViewJSXItems } from './plugins/useTreeViewJSXItems';
@@ -8,4 +8,10 @@ export const getActiveElement = (root = document) => {
8
8
  return getActiveElement(activeEl.shadowRoot);
9
9
  }
10
10
  return activeEl;
11
- };
11
+ };
12
+
13
+ // TODO, eventually replaces this function with CSS.escape, once available in jsdom, either added manually or built in
14
+ // https://github.com/jsdom/jsdom/issues/1550#issuecomment-236734471
15
+ export function escapeOperandAttributeSelector(operand) {
16
+ return operand.replace(/["\\]/g, '\\$&');
17
+ }
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.RICH_TREE_VIEW_PLUGINS = void 0;
7
- var _useTreeViewId = require("../internals/plugins/useTreeViewId");
8
7
  var _useTreeViewItems = require("../internals/plugins/useTreeViewItems");
9
8
  var _useTreeViewExpansion = require("../internals/plugins/useTreeViewExpansion");
10
9
  var _useTreeViewSelection = require("../internals/plugins/useTreeViewSelection");
11
10
  var _useTreeViewFocus = require("../internals/plugins/useTreeViewFocus");
12
11
  var _useTreeViewKeyboardNavigation = require("../internals/plugins/useTreeViewKeyboardNavigation");
13
12
  var _useTreeViewIcons = require("../internals/plugins/useTreeViewIcons");
14
- const RICH_TREE_VIEW_PLUGINS = exports.RICH_TREE_VIEW_PLUGINS = [_useTreeViewId.useTreeViewId, _useTreeViewItems.useTreeViewItems, _useTreeViewExpansion.useTreeViewExpansion, _useTreeViewSelection.useTreeViewSelection, _useTreeViewFocus.useTreeViewFocus, _useTreeViewKeyboardNavigation.useTreeViewKeyboardNavigation, _useTreeViewIcons.useTreeViewIcons];
13
+ const RICH_TREE_VIEW_PLUGINS = exports.RICH_TREE_VIEW_PLUGINS = [_useTreeViewItems.useTreeViewItems, _useTreeViewExpansion.useTreeViewExpansion, _useTreeViewSelection.useTreeViewSelection, _useTreeViewFocus.useTreeViewFocus, _useTreeViewKeyboardNavigation.useTreeViewKeyboardNavigation, _useTreeViewIcons.useTreeViewIcons];
15
14
 
16
15
  // We can't infer this type from the plugin, otherwise we would lose the generics.
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.SIMPLE_TREE_VIEW_PLUGINS = void 0;
7
- var _useTreeViewId = require("../internals/plugins/useTreeViewId");
8
7
  var _useTreeViewItems = require("../internals/plugins/useTreeViewItems");
9
8
  var _useTreeViewExpansion = require("../internals/plugins/useTreeViewExpansion");
10
9
  var _useTreeViewSelection = require("../internals/plugins/useTreeViewSelection");
@@ -12,6 +11,6 @@ var _useTreeViewFocus = require("../internals/plugins/useTreeViewFocus");
12
11
  var _useTreeViewKeyboardNavigation = require("../internals/plugins/useTreeViewKeyboardNavigation");
13
12
  var _useTreeViewIcons = require("../internals/plugins/useTreeViewIcons");
14
13
  var _useTreeViewJSXItems = require("../internals/plugins/useTreeViewJSXItems");
15
- const SIMPLE_TREE_VIEW_PLUGINS = exports.SIMPLE_TREE_VIEW_PLUGINS = [_useTreeViewId.useTreeViewId, _useTreeViewItems.useTreeViewItems, _useTreeViewExpansion.useTreeViewExpansion, _useTreeViewSelection.useTreeViewSelection, _useTreeViewFocus.useTreeViewFocus, _useTreeViewKeyboardNavigation.useTreeViewKeyboardNavigation, _useTreeViewIcons.useTreeViewIcons, _useTreeViewJSXItems.useTreeViewJSXItems];
14
+ const SIMPLE_TREE_VIEW_PLUGINS = exports.SIMPLE_TREE_VIEW_PLUGINS = [_useTreeViewItems.useTreeViewItems, _useTreeViewExpansion.useTreeViewExpansion, _useTreeViewSelection.useTreeViewSelection, _useTreeViewFocus.useTreeViewFocus, _useTreeViewKeyboardNavigation.useTreeViewKeyboardNavigation, _useTreeViewIcons.useTreeViewIcons, _useTreeViewJSXItems.useTreeViewJSXItems];
16
15
 
17
16
  // We can't infer this type from the plugin, otherwise we would lose the generics.
@@ -11,6 +11,15 @@ const isItemExpandable = reactChildren => {
11
11
  }
12
12
  return Boolean(reactChildren);
13
13
  };
14
+
15
+ /**
16
+ * Plugins that need to be present in the Tree View in order for `useTreeItem2Utils` to work correctly.
17
+ */
18
+
19
+ /**
20
+ * Plugins that `useTreeItem2Utils` can use if they are present, but are not required.
21
+ */
22
+
14
23
  const useTreeItem2Utils = ({
15
24
  itemId,
16
25
  children
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.7.0
2
+ * @mui/x-tree-view v7.7.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -9,6 +9,7 @@ exports.TreeViewChildrenItemProvider = TreeViewChildrenItemProvider;
9
9
  var React = _interopRequireWildcard(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _useTreeViewContext = require("./useTreeViewContext");
12
+ var _utils = require("../utils/utils");
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -44,7 +45,8 @@ function TreeViewChildrenItemProvider(props) {
44
45
  return;
45
46
  }
46
47
  const previousChildrenIds = instance.getItemOrderedChildrenIds(itemId ?? null) ?? [];
47
- const childrenElements = rootRef.current.querySelectorAll(`${itemId == null ? '' : `*[id="${idAttr}"] `}[role="treeitem"]:not(*[id="${idAttr}"] [role="treeitem"] [role="treeitem"])`);
48
+ const escapedIdAttr = (0, _utils.escapeOperandAttributeSelector)(idAttr);
49
+ const childrenElements = rootRef.current.querySelectorAll(`${itemId == null ? '' : `*[id="${escapedIdAttr}"] `}[role="treeitem"]:not(*[id="${escapedIdAttr}"] [role="treeitem"] [role="treeitem"])`);
48
50
  const childrenIds = Array.from(childrenElements).map(child => childrenIdAttrToIdRef.current.get(child.id));
49
51
  const hasChanged = childrenIds.length !== previousChildrenIds.length || childrenIds.some((childId, index) => childId !== previousChildrenIds[index]);
50
52
  if (hasChanged) {
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TREE_VIEW_CORE_PLUGINS = void 0;
7
7
  var _useTreeViewInstanceEvents = require("./useTreeViewInstanceEvents");
8
+ var _useTreeViewId = require("./useTreeViewId");
8
9
  /**
9
10
  * Internal plugins that create the tools used by the other plugins.
10
11
  * These plugins are used by the tree view components.
11
12
  */
12
- const TREE_VIEW_CORE_PLUGINS = exports.TREE_VIEW_CORE_PLUGINS = [_useTreeViewInstanceEvents.useTreeViewInstanceEvents];
13
+ const TREE_VIEW_CORE_PLUGINS = exports.TREE_VIEW_CORE_PLUGINS = [_useTreeViewInstanceEvents.useTreeViewInstanceEvents, _useTreeViewId.useTreeViewId];
@@ -45,12 +45,6 @@ Object.defineProperty(exports, "useTreeViewIcons", {
45
45
  return _useTreeViewIcons.useTreeViewIcons;
46
46
  }
47
47
  });
48
- Object.defineProperty(exports, "useTreeViewId", {
49
- enumerable: true,
50
- get: function () {
51
- return _useTreeViewId.useTreeViewId;
52
- }
53
- });
54
48
  Object.defineProperty(exports, "useTreeViewItems", {
55
49
  enumerable: true,
56
50
  get: function () {
@@ -82,7 +76,6 @@ var _useTreeViewExpansion = require("./plugins/useTreeViewExpansion");
82
76
  var _useTreeViewSelection = require("./plugins/useTreeViewSelection");
83
77
  var _useTreeViewFocus = require("./plugins/useTreeViewFocus");
84
78
  var _useTreeViewKeyboardNavigation = require("./plugins/useTreeViewKeyboardNavigation");
85
- var _useTreeViewId = require("./plugins/useTreeViewId");
86
79
  var _useTreeViewIcons = require("./plugins/useTreeViewIcons");
87
80
  var _useTreeViewItems = require("./plugins/useTreeViewItems");
88
81
  var _useTreeViewJSXItems = require("./plugins/useTreeViewJSXItems");
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.escapeOperandAttributeSelector = escapeOperandAttributeSelector;
6
7
  exports.getActiveElement = void 0;
7
8
  // https://www.abeautifulsite.net/posts/finding-the-active-element-in-a-shadow-root/
8
9
  const getActiveElement = (root = document) => {
@@ -15,4 +16,10 @@ const getActiveElement = (root = document) => {
15
16
  }
16
17
  return activeEl;
17
18
  };
18
- exports.getActiveElement = getActiveElement;
19
+
20
+ // TODO, eventually replaces this function with CSS.escape, once available in jsdom, either added manually or built in
21
+ // https://github.com/jsdom/jsdom/issues/1550#issuecomment-236734471
22
+ exports.getActiveElement = getActiveElement;
23
+ function escapeOperandAttributeSelector(operand) {
24
+ return operand.replace(/["\\]/g, '\\$&');
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-tree-view",
3
- "version": "7.7.0",
3
+ "version": "7.7.1",
4
4
  "description": "The community edition of the Tree View components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -35,8 +35,8 @@
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.24.7",
37
37
  "@mui/base": "^5.0.0-beta.40",
38
- "@mui/system": "^5.15.15",
39
- "@mui/utils": "^5.15.14",
38
+ "@mui/system": "^5.15.20",
39
+ "@mui/utils": "^5.15.20",
40
40
  "@types/react-transition-group": "^4.4.10",
41
41
  "clsx": "^2.1.1",
42
42
  "prop-types": "^15.8.1",
@@ -1,2 +1,2 @@
1
1
  import { UseTreeItem2Parameters, UseTreeItem2ReturnValue, UseTreeItem2MinimalPlugins } from './useTreeItem2.types';
2
- export declare const useTreeItem2: <TSignatures extends UseTreeItem2MinimalPlugins = UseTreeItem2MinimalPlugins>(parameters: UseTreeItem2Parameters) => UseTreeItem2ReturnValue<TSignatures>;
2
+ export declare const useTreeItem2: <TSignatures extends UseTreeItem2MinimalPlugins = UseTreeItem2MinimalPlugins, TOptionalSignatures extends readonly [] = readonly []>(parameters: UseTreeItem2Parameters) => UseTreeItem2ReturnValue<TSignatures, TOptionalSignatures>;
@@ -1,10 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { TreeViewItemId } from '../models';
3
3
  import { MuiCancellableEventHandler } from '../internals/models/MuiCancellableEvent';
4
- import { TreeViewAnyPluginSignature, TreeViewPublicAPI } from '../internals/models';
4
+ import { TreeViewPublicAPI } from '../internals/models';
5
5
  import { UseTreeViewSelectionSignature } from '../internals/plugins/useTreeViewSelection';
6
6
  import { UseTreeViewItemsSignature } from '../internals/plugins/useTreeViewItems';
7
- import { UseTreeViewIdSignature } from '../internals/plugins/useTreeViewId';
8
7
  import { UseTreeViewFocusSignature } from '../internals/plugins/useTreeViewFocus';
9
8
  import { UseTreeViewKeyboardNavigationSignature } from '../internals/plugins/useTreeViewKeyboardNavigation';
10
9
  export interface UseTreeItem2Parameters {
@@ -95,7 +94,7 @@ export interface UseTreeItem2Status {
95
94
  selected: boolean;
96
95
  disabled: boolean;
97
96
  }
98
- export interface UseTreeItem2ReturnValue<TSignatures extends readonly TreeViewAnyPluginSignature[]> {
97
+ export interface UseTreeItem2ReturnValue<TSignatures extends UseTreeItem2MinimalPlugins, TOptionalSignatures extends UseTreeItem2OptionalPlugins> {
99
98
  /**
100
99
  * Resolver for the root slot's props.
101
100
  * @param {ExternalProps} externalProps Additional props for the root slot
@@ -143,12 +142,18 @@ export interface UseTreeItem2ReturnValue<TSignatures extends readonly TreeViewAn
143
142
  /**
144
143
  * The object the allows Tree View manipulation.
145
144
  */
146
- publicAPI: TreeViewPublicAPI<TSignatures>;
145
+ publicAPI: TreeViewPublicAPI<TSignatures, TOptionalSignatures>;
147
146
  }
147
+ /**
148
+ * Plugins that need to be present in the Tree View in order for `useTreeItem2` to work correctly.
149
+ */
148
150
  export type UseTreeItem2MinimalPlugins = readonly [
149
151
  UseTreeViewSelectionSignature,
150
152
  UseTreeViewItemsSignature,
151
- UseTreeViewIdSignature,
152
153
  UseTreeViewFocusSignature,
153
154
  UseTreeViewKeyboardNavigationSignature
154
155
  ];
156
+ /**
157
+ * Plugins that `useTreeItem2` can use if they are present, but are not required.
158
+ */
159
+ export type UseTreeItem2OptionalPlugins = readonly [];