Skip to content

Commit

Permalink
[TreeView] Clean the usage of the term "item" and "node" in the inter…
Browse files Browse the repository at this point in the history
…nal API (#12449)
  • Loading branch information
noraleonte authored Mar 28, 2024
1 parent dcb6582 commit 8644e2a
Show file tree
Hide file tree
Showing 45 changed files with 414 additions and 414 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ function TreeView(inProps) {
ownerState,
});

const nodesToRender = instance.getNodesToRender();
const itemsToRender = instance.getItemsToRender();

const renderNode = ({ children: itemChildren, ...itemProps }) => {
const renderItem = ({ children: itemChildren, ...itemProps }) => {
return (
<TreeItem key={itemProps.itemId} {...itemProps}>
{itemChildren?.map(renderNode)}
{itemChildren?.map(renderItem)}
</TreeItem>
);
};

return (
<TreeViewProvider value={contextValue}>
<RichTreeViewRoot {...rootProps}>
{nodesToRender.map(renderNode)}
{itemsToRender.map(renderItem)}
</RichTreeViewRoot>
</TreeViewProvider>
);
Expand Down
10 changes: 5 additions & 5 deletions docs/data/tree-view/rich-tree-view/headless/LogExpandedItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,23 @@ function TreeView<R extends {}, Multiple extends boolean | undefined>(
ownerState,
});

const nodesToRender = instance.getNodesToRender();
const itemsToRender = instance.getItemsToRender();

const renderNode = ({
const renderItem = ({
children: itemChildren,
...itemProps
}: ReturnType<typeof instance.getNodesToRender>[number]) => {
}: ReturnType<typeof instance.getItemsToRender>[number]) => {
return (
<TreeItem key={itemProps.itemId} {...itemProps}>
{itemChildren?.map(renderNode)}
{itemChildren?.map(renderItem)}
</TreeItem>
);
};

return (
<TreeViewProvider value={contextValue}>
<RichTreeViewRoot {...rootProps}>
{nodesToRender.map(renderNode)}
{itemsToRender.map(renderItem)}
</RichTreeViewRoot>
</TreeViewProvider>
);
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/tree-view/rich-tree-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@
},
{
"name": "collapseIcon",
"description": "The default icon used to collapse the node.",
"description": "The default icon used to collapse the item.",
"class": null
},
{
"name": "expandIcon",
"description": "The default icon used to expand the node.",
"description": "The default icon used to expand the item.",
"class": null
},
{
"name": "endIcon",
"description": "The default icon displayed next to an end node.\nThis is applied to all tree nodes and can be overridden by the TreeItem `icon` slot prop.",
"description": "The default icon displayed next to an end item.\nThis is applied to all tree items and can be overridden by the TreeItem `icon` slot prop.",
"class": null
}
],
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/tree-view/simple-tree-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@
},
{
"name": "collapseIcon",
"description": "The default icon used to collapse the node.",
"description": "The default icon used to collapse the item.",
"class": null
},
{
"name": "expandIcon",
"description": "The default icon used to expand the node.",
"description": "The default icon used to expand the item.",
"class": null
},
{
"name": "endIcon",
"description": "The default icon displayed next to an end node.\nThis is applied to all tree nodes and can be overridden by the TreeItem `icon` slot prop.",
"description": "The default icon displayed next to an end item.\nThis is applied to all tree items and can be overridden by the TreeItem `icon` slot prop.",
"class": null
}
],
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/x/api/tree-view/tree-item-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"default": "TreeItem2Label",
"class": "MuiTreeItem2-label"
},
{ "name": "collapseIcon", "description": "The icon used to collapse the node.", "class": null },
{ "name": "expandIcon", "description": "The icon used to expand the node.", "class": null },
{ "name": "endIcon", "description": "The icon displayed next to an end node.", "class": null },
{ "name": "collapseIcon", "description": "The icon used to collapse the item.", "class": null },
{ "name": "expandIcon", "description": "The icon used to expand the item.", "class": null },
{ "name": "endIcon", "description": "The icon displayed next to an end item.", "class": null },
{
"name": "icon",
"description": "The icon to display next to the tree node's label.",
"description": "The icon to display next to the tree item's label.",
"class": null
}
],
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/tree-view/tree-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
{
"key": "iconContainer",
"className": "MuiTreeItem-iconContainer",
"description": "Styles applied to the tree node icon.",
"description": "Styles applied to the tree item icon.",
"isGlobal": false
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/x/api/tree-view/tree-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@
},
{
"name": "collapseIcon",
"description": "The default icon used to collapse the node.",
"description": "The default icon used to collapse the item.",
"class": null
},
{
"name": "expandIcon",
"description": "The default icon used to expand the node.",
"description": "The default icon used to expand the item.",
"class": null
},
{
"name": "endIcon",
"description": "The default icon displayed next to an end node.\nThis is applied to all tree nodes and can be overridden by the TreeItem `icon` slot prop.",
"description": "The default icon displayed next to an end item.\nThis is applied to all tree items and can be overridden by the TreeItem `icon` slot prop.",
"class": null
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
},
"classDescriptions": {},
"slotDescriptions": {
"collapseIcon": "The default icon used to collapse the node.",
"endIcon": "The default icon displayed next to an end node. This is applied to all tree nodes and can be overridden by the TreeItem <code>icon</code> slot prop.",
"expandIcon": "The default icon used to expand the node.",
"collapseIcon": "The default icon used to collapse the item.",
"endIcon": "The default icon displayed next to an end item. This is applied to all tree items and can be overridden by the TreeItem <code>icon</code> slot prop.",
"expandIcon": "The default icon used to expand the item.",
"item": "Custom component for the item.",
"root": "Element rendered at the root."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
},
"classDescriptions": {},
"slotDescriptions": {
"collapseIcon": "The default icon used to collapse the node.",
"endIcon": "The default icon displayed next to an end node. This is applied to all tree nodes and can be overridden by the TreeItem <code>icon</code> slot prop.",
"expandIcon": "The default icon used to expand the node.",
"collapseIcon": "The default icon used to collapse the item.",
"endIcon": "The default icon displayed next to an end item. This is applied to all tree items and can be overridden by the TreeItem <code>icon</code> slot prop.",
"expandIcon": "The default icon used to expand the item.",
"root": "Element rendered at the root."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
}
},
"slotDescriptions": {
"collapseIcon": "The icon used to collapse the node.",
"collapseIcon": "The icon used to collapse the item.",
"content": "The component that renders the content of the item. (e.g.: everything related to this item, not to its children).",
"endIcon": "The icon displayed next to an end node.",
"expandIcon": "The icon used to expand the node.",
"endIcon": "The icon displayed next to an end item.",
"expandIcon": "The icon used to expand the item.",
"groupTransition": "The component that renders the children of the item.",
"icon": "The icon to display next to the tree node&#39;s label.",
"icon": "The icon to display next to the tree item&#39;s label.",
"iconContainer": "The component that renders the icon.",
"label": "The component that renders the item label.",
"root": "The component that renders the root."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"iconContainer": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the tree node icon"
"nodeName": "the tree item icon"
},
"label": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the label element" },
"root": { "description": "Styles applied to the root element." },
Expand Down
6 changes: 3 additions & 3 deletions docs/translations/api-docs/tree-view/tree-view/tree-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
},
"classDescriptions": {},
"slotDescriptions": {
"collapseIcon": "The default icon used to collapse the node.",
"endIcon": "The default icon displayed next to an end node. This is applied to all tree nodes and can be overridden by the TreeItem <code>icon</code> slot prop.",
"expandIcon": "The default icon used to expand the node.",
"collapseIcon": "The default icon used to collapse the item.",
"endIcon": "The default icon displayed next to an end item. This is applied to all tree items and can be overridden by the TreeItem <code>icon</code> slot prop.",
"expandIcon": "The default icon used to expand the item.",
"root": "Element rendered at the root."
}
}
10 changes: 5 additions & 5 deletions packages/x-tree-view/src/RichTreeView/RichTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ const RichTreeView = React.forwardRef(function RichTreeView<
ownerState: props as RichTreeViewProps<any, any>,
});

const nodesToRender = instance.getNodesToRender();
const itemsToRender = instance.getItemsToRender();

const renderNode = ({
const renderItem = ({
label,
itemId,
id,
children,
}: ReturnType<typeof instance.getNodesToRender>[number]) => {
}: ReturnType<typeof instance.getItemsToRender>[number]) => {
return (
<WrappedTreeItem
slots={slots}
Expand All @@ -129,14 +129,14 @@ const RichTreeView = React.forwardRef(function RichTreeView<
id={id}
itemId={itemId}
>
{children?.map(renderNode)}
{children?.map(renderItem)}
</WrappedTreeItem>
);
};

return (
<TreeViewProvider value={contextValue}>
<Root {...rootProps}>{nodesToRender.map(renderNode)}</Root>
<Root {...rootProps}>{itemsToRender.map(renderItem)}</Root>
</TreeViewProvider>
);
}) as TreeViewComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
DefaultTreeViewPluginSlotProps,
DefaultTreeViewPluginSlots,
} from '../internals/plugins/defaultPlugins';
import { useTreeViewJSXNodes } from '../internals/plugins/useTreeViewJSXNodes';
import { useTreeViewJSXItems } from '../internals/plugins/useTreeViewJSXItems';
import { ConvertPluginsIntoSignatures } from '../internals/models';

export const SIMPLE_TREE_VIEW_PLUGINS = [
...DEFAULT_TREE_VIEW_PLUGINS,
useTreeViewJSXNodes,
useTreeViewJSXItems,
] as const;

export type SimpleTreeViewPlugins = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
Expand Down
Loading

0 comments on commit 8644e2a

Please sign in to comment.