Repository: ui
Issue: [bug]: inconsistency in distinguishing files and folders in file tree
Labels: bug

### Describe the bug

Hello and thanks for this great project!

Related to [A sidebar with a collapsible file tree.](https://ui.shadcn.com/blocks#sidebar-11)

I believe there is an issue with the file tree. Although the component renders correctly, it seems that it is doing so only because the sample data is incorrect. There seems to be a pattern where a string followed by a nested array represents a folder containing the array of items. So for example `["hello", ["route.ts"]]` represents a folder named `hello` which contains a file `route.ts`. This would also imply that `"components", ["ui", "button.tsx", "card.tsx"]` would represent a folder named `components` which contains three items `"ui", "button.tsx", "card.tsx"`. If the data were to properly represent `ui` as a folder containing `"button.tsx", "card.tsx"` it would be structured like this: `"components", ["ui", ["button.tsx", "card.tsx"]]`.

To fix the issue, I believe that we need to make the sample data consistent, and also fix the implementation. I will submit [a PR](https://github.com/shadcn-ui/ui/pull/6001) that proposes a solution. I am happy to provide further information or otherwise contribute in any way that would be useful.

# Correctly rendered component

![Screenshot 2024-12-05 at 12 04 41 PM](https://github.com/user-attachments/assets/6538ee69-d263-49a8-a81b-210247d435b3)

# Current behavior

Sample data provided in the component:
```ts
// This is sample data.
const data = {
  changes: [
    {
      file: "README.md",
      state: "M",
    },
    {
      file: "api/hello/route.ts",
      state: "U",
    },
    {
      file: "app/layout.tsx",
      state: "M",
    },
  ],
  tree: [
    [
      "app",
      [
        "api",
        ["hello", ["route.ts"]],
        "page.tsx",
        "layout.tsx",
        ["blog", ["page.tsx"]],
      ],
    ],
    [
      "components",
      ["ui", "button.tsx", "card.tsx"],
      "header.tsx",
      "footer.tsx",
    ],
    ["lib", ["util.ts"]],
    ["public", "favicon.ico", "vercel.svg"],
    ".eslintrc.json",
    ".gitignore",
    "next.config.js",
    "tailwind.config.js",
    "package.json",
    "README.md",
  ],
}
```

# Expected behavior

The following sample data should render the component correctly:

```ts
const data = {
  changes: [
    {
      file: "README.md",
      state: "M",
    },
    {
      file: "api/hello/route.ts",
      state: "U",
    },
    {
      file: "app/layout.tsx",
      state: "M",
    },
  ],
  tree: [
    [
      "app",
      [
        "api",
        ["hello", ["route.ts"]],
        "page.tsx",
        "layout.tsx",
        ["blog", ["page.tsx"]],
      ],
    ],
    [
      "components",
      [["ui", ["button.tsx", "card.tsx"]], "header.tsx", "footer.tsx"],
    ],
    ["lib", ["util.ts"]],
    ["public", ["favicon.ico", "vercel.svg"]],
    ".eslintrc.json",
    ".gitignore",
    "next.config.js",
    "tailwind.config.js",
    "package.json",
    "README.md",
  ],
}
```



### Affected component/components

sidebar-11

### How to reproduce

1. The issue is visible here: [A sidebar with a collapsible file tree.](https://ui.shadcn.com/blocks#sidebar-11)
1. Compare the Preview and Code.

Alternatively, you can see the problem in a different context:

Update the sample data to have a new file under the "api/hello" folder:

```ts
    [
      "app",
      [
        "api",
        ["hello", ["route.ts", "a-new-file.ts"]],
        "page.tsx",
        "layout.tsx",
        ["blog", ["page.tsx"]],
      ],
    ],
```

Notice that `route.ts` is now a folder containing `a-new-file.ts`.

### Codesandbox/StackBlitz link

https://stackblitz.com/edit/stackblitz-starters-eh5nkj?file=components%2Fapp-sidebar.tsx

### Logs

_No response_

### System Info

```bash
NA
```


### Before submitting

- [X] I've made research efforts and searched the documentation
- [X] I've searched for existing issues