@mui/x-tree-view 7.11.0 → 7.11.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,90 @@
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.11.1
7
+
8
+ _Jul 25, 2024_
9
+
10
+ We'd like to offer a big thanks to the 18 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🔎 Allow `Zoom` to be controllable for charts (#13858) @JCQuintas
13
+ - 🌍 Add Icelandic (is-IS) and Norwegian Nynorsk (nn-NO) locales on the Data Grid
14
+ - 🌍 Improve Norwegian Bokmål (nb-NO) and German (de-DE) locales on the Data Grid
15
+ - 🌍 Add Norwegian Nynorsk (nn-NO) locale on the Date and Time Pickers
16
+ - 🐞 Bugfixes
17
+ - 📚 Documentation improvements
18
+
19
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
20
+
21
+ ### Data Grid
22
+
23
+ #### `@mui/x-data-grid@7.11.1`
24
+
25
+ - [DataGrid] Remove dead code in internal `GridPreferencesPanel` (#13934) @k-rajat19
26
+ - [DataGrid] Do not miss to escape formulas in CSV export (#13888) @arminmeh
27
+ - [l10n] Add Icelandic (is-IS) locale (#13283) @magnimarels
28
+ - [l10n] Add Norwegian nynorsk (nn-NO) locale and improve Norwegian bokmål (nb-NO) locale (#13588) @AnderzL7
29
+ - [l10n] Improve German (de-DE) locale (#13910) @lhilgert9
30
+
31
+ #### `@mui/x-data-grid-pro@7.11.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
32
+
33
+ Same changes as in `@mui/x-data-grid@7.11.1`.
34
+
35
+ #### `@mui/x-data-grid-premium@7.11.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
36
+
37
+ Same changes as in `@mui/x-data-grid-pro@7.11.1`, plus:
38
+
39
+ - [DataGridPremium] Pass the `api` object to events (#13893) @pcorpet
40
+ - [DataGridPremium] Fix paste to selected cells (#13967) @romgrk
41
+
42
+ ### Date and Time Pickers
43
+
44
+ #### `@mui/x-date-pickers@7.11.1`
45
+
46
+ - [fields] Prevent keyboard editing when disabled (#13900) @arthurbalduini
47
+ - [l10n] Add Norwegian Nynorsk (nn-NO) locale (#13946) @AnderzL7
48
+
49
+ #### `@mui/x-date-pickers-pro@7.11.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.11.1`.
52
+
53
+ ### Charts
54
+
55
+ #### `@mui/x-charts@7.11.1`
56
+
57
+ - [charts] Add `ownerState` function to `slotProps` typing when available (#13965) @alexfauquette
58
+ - [charts] Allow `Zoom` to be controllable (#13858) @JCQuintas
59
+ - [charts] Deprecate `xAxisKey` /`zAxisKey` in favor of `xAxisId`/`zAxisId` (#13940) @alexfauquette
60
+ - [charts] Hide empty arcs in the PieChart (#13897) @alexfauquette
61
+ - [charts] Limit the trigger of exit charts (#13682) @alexfauquette
62
+
63
+ ### Tree View
64
+
65
+ #### `@mui/x-tree-view@7.11.1`
66
+
67
+ - [TreeView] Allow the plugins to enrich the props passed to the item slots (#13953) @flaviendelangle
68
+
69
+ ### Docs
70
+
71
+ - [docs] Bump pnpm priority as a package manager (#13894) @oliviertassinari
72
+ - [docs] Explicitly mark charts pro as not released (#13905) @alexfauquette
73
+ - [docs] Fix dot consistency a11y table @oliviertassinari
74
+ - [docs] Fix some typos in charts docs (#13906) @cratiu222
75
+ - [docs] Fix spelling (#13902) @nnsW3
76
+ - [docs] Improve error message when moving between plans (#13874) @oliviertassinari
77
+ - [docs] Update `SparkLineChart` reference not being correctly capitalised (#13960) @duckboy81
78
+ - [docs] Fix scroll demos disorientation (#13909) @oliviertassinari
79
+
80
+ ### Core
81
+
82
+ - [core] Add `@mui/material-nextjs` to `MUI Core` renovate group (#13966) @LukasTy
83
+ - [core] Remove warning message in production (#13911) @oliviertassinari
84
+ - [code-infra] Reuse `useReactVersion` script from the monorepo (#13710) @cherniavskii
85
+ - [infra] Adds order id validation action (#13957) @michelengelen
86
+ - [infra] Fix order id validator action (#13971) @michelengelen
87
+ - [infra] Fix regex in order id validation (#13976) @michelengelen
88
+ - [infra] Issue template improvement (#13954) @michelengelen
89
+
6
90
  ## 7.11.0
7
91
 
8
92
  _Jul 18, 2024_
@@ -9,7 +9,7 @@ import { useTreeView } from '../internals/useTreeView';
9
9
  import { TreeViewProvider } from '../internals/TreeViewProvider';
10
10
  import { RICH_TREE_VIEW_PLUGINS } from './RichTreeView.plugins';
11
11
  import { TreeItem } from '../TreeItem';
12
- import { buildWarning } from '../internals/utils/warning';
12
+ import { warnOnce } from '../internals/utils/warning';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const useThemeProps = createUseThemeProps('MuiRichTreeView');
15
15
  const useUtilityClasses = ownerState => {
@@ -58,7 +58,6 @@ function WrappedTreeItem({
58
58
  children: children
59
59
  }));
60
60
  }
61
- const childrenWarning = buildWarning(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/']);
62
61
 
63
62
  /**
64
63
  *
@@ -77,7 +76,7 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
77
76
  });
78
77
  if (process.env.NODE_ENV !== 'production') {
79
78
  if (props.children != null) {
80
- childrenWarning();
79
+ warnOnce(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/.']);
81
80
  }
82
81
  }
83
82
  const {
@@ -8,7 +8,7 @@ import { getSimpleTreeViewUtilityClass } from './simpleTreeViewClasses';
8
8
  import { useTreeView } from '../internals/useTreeView';
9
9
  import { TreeViewProvider } from '../internals/TreeViewProvider';
10
10
  import { SIMPLE_TREE_VIEW_PLUGINS } from './SimpleTreeView.plugins';
11
- import { buildWarning } from '../internals/utils/warning';
11
+ import { warnOnce } from '../internals/utils/warning';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  const useThemeProps = createUseThemeProps('MuiSimpleTreeView');
14
14
  const useUtilityClasses = ownerState => {
@@ -32,7 +32,6 @@ export const SimpleTreeViewRoot = styled('ul', {
32
32
  position: 'relative'
33
33
  });
34
34
  const EMPTY_ITEMS = [];
35
- const itemsPropWarning = buildWarning(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/']);
36
35
 
37
36
  /**
38
37
  *
@@ -52,7 +51,7 @@ const SimpleTreeView = /*#__PURE__*/React.forwardRef(function SimpleTreeView(inP
52
51
  const ownerState = props;
53
52
  if (process.env.NODE_ENV !== 'production') {
54
53
  if (props.items != null) {
55
- itemsPropWarning();
54
+ warnOnce(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/.']);
56
55
  }
57
56
  }
58
57
  const {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.11.0
2
+ * @mui/x-tree-view v7.11.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -17,4 +17,4 @@ export { useTreeViewItems } from './plugins/useTreeViewItems';
17
17
  export type { UseTreeViewItemsSignature, UseTreeViewItemsParameters, } from './plugins/useTreeViewItems';
18
18
  export { useTreeViewJSXItems } from './plugins/useTreeViewJSXItems';
19
19
  export type { UseTreeViewJSXItemsSignature, UseTreeViewJSXItemsParameters, } from './plugins/useTreeViewJSXItems';
20
- export { buildWarning } from './utils/warning';
20
+ export { warnOnce } from './utils/warning';
@@ -12,4 +12,4 @@ export { useTreeViewKeyboardNavigation } from './plugins/useTreeViewKeyboardNavi
12
12
  export { useTreeViewIcons } from './plugins/useTreeViewIcons';
13
13
  export { useTreeViewItems } from './plugins/useTreeViewItems';
14
14
  export { useTreeViewJSXItems } from './plugins/useTreeViewJSXItems';
15
- export { buildWarning } from './utils/warning';
15
+ export { warnOnce } from './utils/warning';
@@ -1,3 +1,4 @@
1
1
  export * from './helpers';
2
2
  export * from './plugin';
3
+ export * from './itemPlugin';
3
4
  export * from './treeView';
@@ -1,3 +1,4 @@
1
1
  export * from './helpers';
2
2
  export * from './plugin';
3
+ export * from './itemPlugin';
3
4
  export * from './treeView';
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import { EventHandlers } from '@mui/base/utils';
3
+ import type { UseTreeItem2ContentSlotOwnProps, UseTreeItem2RootSlotOwnProps } from '../../useTreeItem2';
4
+ export interface TreeViewItemPluginSlotPropsEnhancerParams {
5
+ rootRefObject: React.MutableRefObject<HTMLLIElement | null>;
6
+ contentRefObject: React.MutableRefObject<HTMLDivElement | null>;
7
+ externalEventHandlers: EventHandlers;
8
+ }
9
+ type TreeViewItemPluginSlotPropsEnhancer<TSlotProps> = (params: TreeViewItemPluginSlotPropsEnhancerParams) => Partial<TSlotProps>;
10
+ export interface TreeViewItemPluginSlotPropsEnhancers {
11
+ root?: TreeViewItemPluginSlotPropsEnhancer<UseTreeItem2RootSlotOwnProps>;
12
+ content?: TreeViewItemPluginSlotPropsEnhancer<UseTreeItem2ContentSlotOwnProps>;
13
+ }
14
+ export interface TreeViewItemPluginResponse {
15
+ /**
16
+ * Root of the `content` slot enriched by the plugin.
17
+ */
18
+ contentRef?: React.RefCallback<HTMLElement> | null;
19
+ /**
20
+ * Ref of the `root` slot enriched by the plugin
21
+ */
22
+ rootRef?: React.RefCallback<HTMLLIElement> | null;
23
+ /**
24
+ * Callback to enhance the slot props of the Tree Item.
25
+ *
26
+ * Not all slots are enabled by default,
27
+ * if a new plugin needs to pass to an unconfigured slot,
28
+ * it just needs to be added to `TreeViewItemPluginSlotPropsEnhancers`
29
+ */
30
+ propsEnhancers?: TreeViewItemPluginSlotPropsEnhancers;
31
+ }
32
+ export interface TreeViewItemPluginOptions<TProps extends {}> extends Omit<TreeViewItemPluginResponse, 'propsEnhancers'> {
33
+ props: TProps;
34
+ }
35
+ export type TreeViewItemPlugin<TProps extends {}> = (options: TreeViewItemPluginOptions<TProps>) => void | TreeViewItemPluginResponse;
36
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -4,6 +4,7 @@ import { TreeViewExperimentalFeatures, TreeViewInstance, TreeViewModel } from '.
4
4
  import type { MergeSignaturesProperty, OptionalIfEmpty } from './helpers';
5
5
  import { TreeViewEventLookupElement } from './events';
6
6
  import type { TreeViewCorePluginSignatures } from '../corePlugins';
7
+ import { TreeViewItemPlugin } from './itemPlugin';
7
8
  import { TreeViewItemId } from '../../models';
8
9
  export interface TreeViewPluginOptions<TSignature extends TreeViewAnyPluginSignature> {
9
10
  instance: TreeViewUsedInstance<TSignature>;
@@ -126,20 +127,6 @@ type RemoveSetValue<Models extends Record<string, TreeViewModel<any>>> = {
126
127
  };
127
128
  export type TreeViewUsedModels<TSignature extends TreeViewAnyPluginSignature> = TSignature['models'] & RemoveSetValue<MergeSignaturesProperty<TreeViewRequiredPlugins<TSignature>, 'models'>>;
128
129
  export type TreeViewUsedEvents<TSignature extends TreeViewAnyPluginSignature> = TSignature['events'] & MergeSignaturesProperty<TreeViewRequiredPlugins<TSignature>, 'events'>;
129
- export interface TreeViewItemPluginOptions<TProps extends {}> extends TreeViewItemPluginResponse {
130
- props: TProps;
131
- }
132
- export interface TreeViewItemPluginResponse {
133
- /**
134
- * Root of the `content` slot enriched by the plugin.
135
- */
136
- contentRef?: React.RefCallback<HTMLElement> | null;
137
- /**
138
- * Ref of the `root` slot enriched by the plugin
139
- */
140
- rootRef?: React.RefCallback<HTMLLIElement> | null;
141
- }
142
- export type TreeViewItemPlugin<TProps extends {}> = (options: TreeViewItemPluginOptions<TProps>) => void | TreeViewItemPluginResponse;
143
130
  export type TreeItemWrapper<TSignatures extends readonly TreeViewAnyPluginSignature[]> = (params: {
144
131
  itemId: TreeViewItemId;
145
132
  children: React.ReactNode;
@@ -7,6 +7,8 @@ export const useTreeViewBuildContext = ({
7
7
  const runItemPlugins = itemPluginProps => {
8
8
  let finalRootRef = null;
9
9
  let finalContentRef = null;
10
+ const pluginPropEnhancers = [];
11
+ const pluginPropEnhancersNames = {};
10
12
  plugins.forEach(plugin => {
11
13
  if (!plugin.itemPlugin) {
12
14
  return;
@@ -22,10 +24,30 @@ export const useTreeViewBuildContext = ({
22
24
  if (itemPluginResponse?.contentRef) {
23
25
  finalContentRef = itemPluginResponse.contentRef;
24
26
  }
27
+ if (itemPluginResponse?.propsEnhancers) {
28
+ pluginPropEnhancers.push(itemPluginResponse.propsEnhancers);
29
+
30
+ // Prepare a list of all the slots which are enhanced by at least one plugin
31
+ Object.keys(itemPluginResponse.propsEnhancers).forEach(propsEnhancerName => {
32
+ pluginPropEnhancersNames[propsEnhancerName] = true;
33
+ });
34
+ }
25
35
  });
36
+ const resolvePropsEnhancer = currentSlotName => currentSlotParams => {
37
+ const enhancedProps = {};
38
+ pluginPropEnhancers.forEach(propsEnhancersForCurrentPlugin => {
39
+ const propsEnhancerForCurrentPluginAndSlot = propsEnhancersForCurrentPlugin[currentSlotName];
40
+ if (propsEnhancerForCurrentPluginAndSlot != null) {
41
+ Object.assign(enhancedProps, propsEnhancerForCurrentPluginAndSlot(currentSlotParams));
42
+ }
43
+ });
44
+ return enhancedProps;
45
+ };
46
+ const propsEnhancers = Object.fromEntries(Object.keys(pluginPropEnhancersNames).map(propEnhancerName => [propEnhancerName, resolvePropsEnhancer(propEnhancerName)]));
26
47
  return {
27
48
  contentRef: finalContentRef,
28
- rootRef: finalRootRef
49
+ rootRef: finalRootRef,
50
+ propsEnhancers
29
51
  };
30
52
  };
31
53
  const wrapItem = ({
@@ -1 +1,2 @@
1
- export declare const buildWarning: (message: string | string[], gravity?: "warning" | "error") => () => void;
1
+ export declare function warnOnce(message: string | string[], gravity?: 'warning' | 'error'): void;
2
+ export declare function clearWarningsCache(): void;
@@ -1,14 +1,21 @@
1
- export const buildWarning = (message, gravity = 'warning') => {
2
- let alreadyWarned = false;
1
+ const warnedOnceCache = new Set();
2
+
3
+ // TODO move to @mui/x-internals
4
+ // TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
5
+ export function warnOnce(message, gravity = 'warning') {
6
+ if (process.env.NODE_ENV === 'production') {
7
+ return;
8
+ }
3
9
  const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
4
- return () => {
5
- if (!alreadyWarned) {
6
- alreadyWarned = true;
7
- if (gravity === 'error') {
8
- console.error(cleanMessage);
9
- } else {
10
- console.warn(cleanMessage);
11
- }
10
+ if (!warnedOnceCache.has(cleanMessage)) {
11
+ warnedOnceCache.add(cleanMessage);
12
+ if (gravity === 'error') {
13
+ console.error(cleanMessage);
14
+ } else {
15
+ console.warn(cleanMessage);
12
16
  }
13
- };
14
- };
17
+ }
18
+ }
19
+ export function clearWarningsCache() {
20
+ warnedOnceCache.clear();
21
+ }
@@ -9,7 +9,7 @@ import { useTreeView } from '../internals/useTreeView';
9
9
  import { TreeViewProvider } from '../internals/TreeViewProvider';
10
10
  import { RICH_TREE_VIEW_PLUGINS } from './RichTreeView.plugins';
11
11
  import { TreeItem } from '../TreeItem';
12
- import { buildWarning } from '../internals/utils/warning';
12
+ import { warnOnce } from '../internals/utils/warning';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const useThemeProps = createUseThemeProps('MuiRichTreeView');
15
15
  const useUtilityClasses = ownerState => {
@@ -58,7 +58,6 @@ function WrappedTreeItem({
58
58
  children: children
59
59
  }));
60
60
  }
61
- const childrenWarning = buildWarning(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/']);
62
61
 
63
62
  /**
64
63
  *
@@ -77,7 +76,7 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
77
76
  });
78
77
  if (process.env.NODE_ENV !== 'production') {
79
78
  if (props.children != null) {
80
- childrenWarning();
79
+ warnOnce(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/.']);
81
80
  }
82
81
  }
83
82
  const {
@@ -8,7 +8,7 @@ import { getSimpleTreeViewUtilityClass } from './simpleTreeViewClasses';
8
8
  import { useTreeView } from '../internals/useTreeView';
9
9
  import { TreeViewProvider } from '../internals/TreeViewProvider';
10
10
  import { SIMPLE_TREE_VIEW_PLUGINS } from './SimpleTreeView.plugins';
11
- import { buildWarning } from '../internals/utils/warning';
11
+ import { warnOnce } from '../internals/utils/warning';
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  const useThemeProps = createUseThemeProps('MuiSimpleTreeView');
14
14
  const useUtilityClasses = ownerState => {
@@ -32,7 +32,6 @@ export const SimpleTreeViewRoot = styled('ul', {
32
32
  position: 'relative'
33
33
  });
34
34
  const EMPTY_ITEMS = [];
35
- const itemsPropWarning = buildWarning(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/']);
36
35
 
37
36
  /**
38
37
  *
@@ -52,7 +51,7 @@ const SimpleTreeView = /*#__PURE__*/React.forwardRef(function SimpleTreeView(inP
52
51
  const ownerState = props;
53
52
  if (process.env.NODE_ENV !== 'production') {
54
53
  if (props.items != null) {
55
- itemsPropWarning();
54
+ warnOnce(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/.']);
56
55
  }
57
56
  }
58
57
  const {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.11.0
2
+ * @mui/x-tree-view v7.11.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -12,4 +12,4 @@ export { useTreeViewKeyboardNavigation } from './plugins/useTreeViewKeyboardNavi
12
12
  export { useTreeViewIcons } from './plugins/useTreeViewIcons';
13
13
  export { useTreeViewItems } from './plugins/useTreeViewItems';
14
14
  export { useTreeViewJSXItems } from './plugins/useTreeViewJSXItems';
15
- export { buildWarning } from './utils/warning';
15
+ export { warnOnce } from './utils/warning';
@@ -1,3 +1,4 @@
1
1
  export * from './helpers';
2
2
  export * from './plugin';
3
+ export * from './itemPlugin';
3
4
  export * from './treeView';
@@ -0,0 +1 @@
1
+ export {};
@@ -7,6 +7,8 @@ export const useTreeViewBuildContext = ({
7
7
  const runItemPlugins = itemPluginProps => {
8
8
  let finalRootRef = null;
9
9
  let finalContentRef = null;
10
+ const pluginPropEnhancers = [];
11
+ const pluginPropEnhancersNames = {};
10
12
  plugins.forEach(plugin => {
11
13
  if (!plugin.itemPlugin) {
12
14
  return;
@@ -22,10 +24,30 @@ export const useTreeViewBuildContext = ({
22
24
  if (itemPluginResponse?.contentRef) {
23
25
  finalContentRef = itemPluginResponse.contentRef;
24
26
  }
27
+ if (itemPluginResponse?.propsEnhancers) {
28
+ pluginPropEnhancers.push(itemPluginResponse.propsEnhancers);
29
+
30
+ // Prepare a list of all the slots which are enhanced by at least one plugin
31
+ Object.keys(itemPluginResponse.propsEnhancers).forEach(propsEnhancerName => {
32
+ pluginPropEnhancersNames[propsEnhancerName] = true;
33
+ });
34
+ }
25
35
  });
36
+ const resolvePropsEnhancer = currentSlotName => currentSlotParams => {
37
+ const enhancedProps = {};
38
+ pluginPropEnhancers.forEach(propsEnhancersForCurrentPlugin => {
39
+ const propsEnhancerForCurrentPluginAndSlot = propsEnhancersForCurrentPlugin[currentSlotName];
40
+ if (propsEnhancerForCurrentPluginAndSlot != null) {
41
+ Object.assign(enhancedProps, propsEnhancerForCurrentPluginAndSlot(currentSlotParams));
42
+ }
43
+ });
44
+ return enhancedProps;
45
+ };
46
+ const propsEnhancers = Object.fromEntries(Object.keys(pluginPropEnhancersNames).map(propEnhancerName => [propEnhancerName, resolvePropsEnhancer(propEnhancerName)]));
26
47
  return {
27
48
  contentRef: finalContentRef,
28
- rootRef: finalRootRef
49
+ rootRef: finalRootRef,
50
+ propsEnhancers
29
51
  };
30
52
  };
31
53
  const wrapItem = ({
@@ -1,14 +1,21 @@
1
- export const buildWarning = (message, gravity = 'warning') => {
2
- let alreadyWarned = false;
1
+ const warnedOnceCache = new Set();
2
+
3
+ // TODO move to @mui/x-internals
4
+ // TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
5
+ export function warnOnce(message, gravity = 'warning') {
6
+ if (process.env.NODE_ENV === 'production') {
7
+ return;
8
+ }
3
9
  const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
4
- return () => {
5
- if (!alreadyWarned) {
6
- alreadyWarned = true;
7
- if (gravity === 'error') {
8
- console.error(cleanMessage);
9
- } else {
10
- console.warn(cleanMessage);
11
- }
10
+ if (!warnedOnceCache.has(cleanMessage)) {
11
+ warnedOnceCache.add(cleanMessage);
12
+ if (gravity === 'error') {
13
+ console.error(cleanMessage);
14
+ } else {
15
+ console.warn(cleanMessage);
12
16
  }
13
- };
14
- };
17
+ }
18
+ }
19
+ export function clearWarningsCache() {
20
+ warnedOnceCache.clear();
21
+ }
@@ -67,7 +67,6 @@ function WrappedTreeItem({
67
67
  children: children
68
68
  }));
69
69
  }
70
- const childrenWarning = (0, _warning.buildWarning)(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/']);
71
70
 
72
71
  /**
73
72
  *
@@ -86,7 +85,7 @@ const RichTreeView = exports.RichTreeView = /*#__PURE__*/React.forwardRef(functi
86
85
  });
87
86
  if (process.env.NODE_ENV !== 'production') {
88
87
  if (props.children != null) {
89
- childrenWarning();
88
+ (0, _warning.warnOnce)(['MUI X: The `RichTreeView` component does not support JSX children.', 'If you want to add items, you need to use the `items` prop.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/items/.']);
90
89
  }
91
90
  }
92
91
  const {
@@ -41,7 +41,6 @@ const SimpleTreeViewRoot = exports.SimpleTreeViewRoot = (0, _zeroStyled.styled)(
41
41
  position: 'relative'
42
42
  });
43
43
  const EMPTY_ITEMS = [];
44
- const itemsPropWarning = (0, _warning.buildWarning)(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/']);
45
44
 
46
45
  /**
47
46
  *
@@ -61,7 +60,7 @@ const SimpleTreeView = exports.SimpleTreeView = /*#__PURE__*/React.forwardRef(fu
61
60
  const ownerState = props;
62
61
  if (process.env.NODE_ENV !== 'production') {
63
62
  if (props.items != null) {
64
- itemsPropWarning();
63
+ (0, _warning.warnOnce)(['MUI X: The `SimpleTreeView` component does not support the `items` prop.', 'If you want to add items, you need to pass them as JSX children.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/simple-tree-view/items/.']);
65
64
  }
66
65
  }
67
66
  const {
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-tree-view v7.11.0
2
+ * @mui/x-tree-view v7.11.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -9,12 +9,6 @@ Object.defineProperty(exports, "TreeViewProvider", {
9
9
  return _TreeViewProvider.TreeViewProvider;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "buildWarning", {
13
- enumerable: true,
14
- get: function () {
15
- return _warning.buildWarning;
16
- }
17
- });
18
12
  Object.defineProperty(exports, "unstable_resetCleanupTracking", {
19
13
  enumerable: true,
20
14
  get: function () {
@@ -69,6 +63,12 @@ Object.defineProperty(exports, "useTreeViewSelection", {
69
63
  return _useTreeViewSelection.useTreeViewSelection;
70
64
  }
71
65
  });
66
+ Object.defineProperty(exports, "warnOnce", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _warning.warnOnce;
70
+ }
71
+ });
72
72
  var _useTreeView = require("./useTreeView");
73
73
  var _TreeViewProvider = require("./TreeViewProvider");
74
74
  var _useInstanceEventHandler = require("./hooks/useInstanceEventHandler");
@@ -25,6 +25,17 @@ Object.keys(_plugin).forEach(function (key) {
25
25
  }
26
26
  });
27
27
  });
28
+ var _itemPlugin = require("./itemPlugin");
29
+ Object.keys(_itemPlugin).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _itemPlugin[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _itemPlugin[key];
36
+ }
37
+ });
38
+ });
28
39
  var _treeView = require("./treeView");
29
40
  Object.keys(_treeView).forEach(function (key) {
30
41
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -13,6 +13,8 @@ const useTreeViewBuildContext = ({
13
13
  const runItemPlugins = itemPluginProps => {
14
14
  let finalRootRef = null;
15
15
  let finalContentRef = null;
16
+ const pluginPropEnhancers = [];
17
+ const pluginPropEnhancersNames = {};
16
18
  plugins.forEach(plugin => {
17
19
  if (!plugin.itemPlugin) {
18
20
  return;
@@ -28,10 +30,30 @@ const useTreeViewBuildContext = ({
28
30
  if (itemPluginResponse?.contentRef) {
29
31
  finalContentRef = itemPluginResponse.contentRef;
30
32
  }
33
+ if (itemPluginResponse?.propsEnhancers) {
34
+ pluginPropEnhancers.push(itemPluginResponse.propsEnhancers);
35
+
36
+ // Prepare a list of all the slots which are enhanced by at least one plugin
37
+ Object.keys(itemPluginResponse.propsEnhancers).forEach(propsEnhancerName => {
38
+ pluginPropEnhancersNames[propsEnhancerName] = true;
39
+ });
40
+ }
31
41
  });
42
+ const resolvePropsEnhancer = currentSlotName => currentSlotParams => {
43
+ const enhancedProps = {};
44
+ pluginPropEnhancers.forEach(propsEnhancersForCurrentPlugin => {
45
+ const propsEnhancerForCurrentPluginAndSlot = propsEnhancersForCurrentPlugin[currentSlotName];
46
+ if (propsEnhancerForCurrentPluginAndSlot != null) {
47
+ Object.assign(enhancedProps, propsEnhancerForCurrentPluginAndSlot(currentSlotParams));
48
+ }
49
+ });
50
+ return enhancedProps;
51
+ };
52
+ const propsEnhancers = Object.fromEntries(Object.keys(pluginPropEnhancersNames).map(propEnhancerName => [propEnhancerName, resolvePropsEnhancer(propEnhancerName)]));
32
53
  return {
33
54
  contentRef: finalContentRef,
34
- rootRef: finalRootRef
55
+ rootRef: finalRootRef,
56
+ propsEnhancers
35
57
  };
36
58
  };
37
59
  const wrapItem = ({
@@ -3,19 +3,26 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.buildWarning = void 0;
7
- const buildWarning = (message, gravity = 'warning') => {
8
- let alreadyWarned = false;
6
+ exports.clearWarningsCache = clearWarningsCache;
7
+ exports.warnOnce = warnOnce;
8
+ const warnedOnceCache = new Set();
9
+
10
+ // TODO move to @mui/x-internals
11
+ // TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
12
+ function warnOnce(message, gravity = 'warning') {
13
+ if (process.env.NODE_ENV === 'production') {
14
+ return;
15
+ }
9
16
  const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
10
- return () => {
11
- if (!alreadyWarned) {
12
- alreadyWarned = true;
13
- if (gravity === 'error') {
14
- console.error(cleanMessage);
15
- } else {
16
- console.warn(cleanMessage);
17
- }
17
+ if (!warnedOnceCache.has(cleanMessage)) {
18
+ warnedOnceCache.add(cleanMessage);
19
+ if (gravity === 'error') {
20
+ console.error(cleanMessage);
21
+ } else {
22
+ console.warn(cleanMessage);
18
23
  }
19
- };
20
- };
21
- exports.buildWarning = buildWarning;
24
+ }
25
+ }
26
+ function clearWarningsCache() {
27
+ warnedOnceCache.clear();
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-tree-view",
3
- "version": "7.11.0",
3
+ "version": "7.11.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,13 +35,13 @@
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.24.8",
37
37
  "@mui/base": "^5.0.0-beta.40",
38
- "@mui/system": "^5.16.2",
39
- "@mui/utils": "^5.16.2",
38
+ "@mui/system": "^5.16.5",
39
+ "@mui/utils": "^5.16.5",
40
40
  "@types/react-transition-group": "^4.4.10",
41
41
  "clsx": "^2.1.1",
42
42
  "prop-types": "^15.8.1",
43
43
  "react-transition-group": "^4.4.5",
44
- "@mui/x-internals": "7.11.0"
44
+ "@mui/x-internals": "7.11.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@emotion/react": "^11.9.0",
@@ -1,2 +1,2 @@
1
1
  export { useTreeItem2 as unstable_useTreeItem2 } from './useTreeItem2';
2
- export type { UseTreeItem2Parameters, UseTreeItem2ReturnValue, UseTreeItem2Status, UseTreeItem2ContentSlotOwnProps, } from './useTreeItem2.types';
2
+ export type { UseTreeItem2Parameters, UseTreeItem2ReturnValue, UseTreeItem2Status, UseTreeItem2RootSlotOwnProps, UseTreeItem2ContentSlotOwnProps, UseTreeItem2LabelSlotOwnProps, UseTreeItem2IconContainerSlotOwnProps, UseTreeItem2GroupTransitionSlotOwnProps, } from './useTreeItem2.types';