'use client'; import type { TreeNode, TreeRowSlot } from '../../../data/Tree/types'; import { FileIcon, type FileIconSize } from './FileIcon'; import type { FolderIconOverrides } from './specialFolders'; export interface CreateFileIconSlotOptions { /** * How to read the displayed name (with extension) for a node. Use the same * accessor you pass to ``. */ getName: (node: TreeNode) => string; /** Pixel size for both file and folder icons. Default: 16. */ size?: FileIconSize; /** * Override or extend the built-in special-folder mapping (e.g. give * `tests` a custom icon). Keys are matched case-insensitively. */ folderOverrides?: FolderIconOverrides; } /** * Build a `renderIcon` slot for `` that uses `` for both * leaves and folders. * * @example * ```tsx * n.data.name} * renderIcon={createFileIconSlot({ getName: (n) => n.data.name })} * /> * ``` */ export function createFileIconSlot({ getName, size = 16, folderOverrides, }: CreateFileIconSlotOptions): TreeRowSlot { return ({ node, isFolder, isExpanded }) => ( ); }