{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "files-file-tree",
  "type": "registry:component",
  "title": "File trees",
  "description": "A file tree with declarative folders and one selection",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-data.json",
    "https://gpuixui.sudokw.com/gpuix-icons.json",
    "https://gpuixui.sudokw.com/gpuix-motion.json",
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/files/src/recipe.ts",
      "target": "@ui/gpuixui/files/recipe.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { classesToStyle } from \"../tw/index.js\";\nimport * as MutableHashMap from \"effect/MutableHashMap\";\nimport * as Option from \"effect/Option\";\nimport type { Theme } from \"./theme.js\";\n\nconst CACHE_LIMIT = 256;\n\nconst compiled = new WeakMap<\n  Theme,\n  MutableHashMap.MutableHashMap<string, StyleDesc>\n>();\n\nexport const recipeStyle = (recipe: string, theme: Theme): StyleDesc => {\n  const byRecipe = compiled.get(theme);\n  if (byRecipe !== undefined) {\n    const hit = MutableHashMap.get(byRecipe, recipe);\n    if (Option.isSome(hit)) return hit.value;\n  }\n  const style = Object.freeze(classesToStyle(recipe, theme).style);\n  if (byRecipe === undefined) {\n    compiled.set(theme, MutableHashMap.make([recipe, style]));\n  } else if (MutableHashMap.size(byRecipe) < CACHE_LIMIT) {\n    MutableHashMap.set(byRecipe, recipe, style);\n  }\n  return style;\n};\n"
    },
    {
      "path": "packages/files/src/theme.ts",
      "target": "@ui/gpuixui/files/theme.ts",
      "type": "registry:lib",
      "content": "import type { Theme } from \"../tokens/index.js\";\nimport { useTheme as useTokenTheme } from \"../tokens/react.js\";\n\nexport {\n  pointerWash,\n  statusTone,\n  textStyle,\n  themeColors,\n} from \"../tokens/index.js\";\nexport type { Theme };\n\nexport const useTheme = (): Theme => useTokenTheme();\n"
    },
    {
      "path": "packages/files/src/tree/file-tree.tsx",
      "target": "@ui/gpuixui/files/tree/file-tree.tsx",
      "type": "registry:component",
      "content": "import type {\n  EventPayload,\n  MotionProps,\n  Props,\n  PublicInstance,\n} from \"@gpuix/react\";\nimport { mergeStyles } from \"@gpuix/react/floating\";\nimport {\n  TREE_INDENT,\n  TREE_INSET,\n  expandedSet,\n  paintedRows,\n  treeName,\n  type TreeCursor,\n  type TreeRow,\n} from \"../../data/index.js\";\nimport { useTree } from \"../../data/tree/use-tree.js\";\nimport { Icon, type IconName } from \"../../icons/index.js\";\nimport {\n  delayedTiming,\n  transitionWindowMs,\n  type PresenceTiming,\n} from \"../../motion/presence.js\";\nimport { useSurfaceTiming } from \"../../motion/react/presence.js\";\nimport { iconSideOf, rowHeightOf, storedText } from \"../../primitives/core/index.js\";\nimport { cn } from \"../../tw/index.js\";\nimport * as Arr from \"effect/Array\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Option from \"effect/Option\";\nimport {\n  Children,\n  Fragment,\n  createContext,\n  isValidElement,\n  useContext,\n  useEffect,\n  useMemo,\n  useRef,\n  useState,\n  type ReactNode,\n} from \"react\";\nimport { recipeStyle } from \"../recipe.js\";\nimport { pointerWash, textStyle, themeColors, useTheme } from \"../theme.js\";\nimport {\n  fileIcon,\n  fileKindOf,\n  fileTreePaths,\n  fileTreeTab,\n  visibleFileRows,\n  type FileKind,\n  type FileNode,\n} from \"./logic.js\";\nimport { FILE_TREE_ROOT, FILE_TREE_ROW } from \"./recipe.js\";\n\nexport interface FileTreeProps extends Omit<Props, \"children\"> {\n  readonly expanded?: Iterable<string>;\n\n  readonly defaultExpanded?: Iterable<string>;\n\n  readonly selected?: string | null;\n\n  readonly onSelect?: (path: string) => void;\n\n  readonly onExpandedChange?: (expanded: ReadonlyArray<string>) => void;\n\n  readonly children?: ReactNode;\n\n  readonly height?: number;\n  readonly className?: string;\n\n  readonly testId?: string;\n}\n\nexport interface FileTreeFolderProps {\n  readonly path: string;\n\n  readonly name: string;\n\n  readonly children?: ReactNode;\n}\n\nexport interface FileTreeFileProps {\n  readonly path: string;\n\n  readonly name: string;\n\n  readonly icon?: IconName;\n\n  readonly children?: ReactNode;\n}\n\nexport interface FileTreeIconProps {\n  readonly name?: IconName;\n\n  readonly selected?: boolean;\n\n  readonly children?: ReactNode;\n}\n\nexport interface FileTreeNameProps {\n  readonly selected?: boolean;\n\n  readonly children?: ReactNode;\n}\n\nconst Declared = createContext(false);\n\nconst nameOf = (type: unknown): string =>\n  typeof type === \"function\" && type.name !== \"\" ? type.name : \"element\";\n\nconst useDeclared = (part: string): void => {\n  if (!useContext(Declared)) {\n    throw new Error(`${part} must be used inside FileTree.`);\n  }\n};\n\nexport const FileTreeFolder = (_props: FileTreeFolderProps): null => {\n  useDeclared(\"FileTreeFolder\");\n  return null;\n};\n\nexport const FileTreeFile = (_props: FileTreeFileProps): null => {\n  useDeclared(\"FileTreeFile\");\n  return null;\n};\n\nexport const FileTreeIcon = ({\n  name,\n  selected = false,\n  children,\n}: FileTreeIconProps) => {\n  const theme = useTheme();\n  const colors = themeColors(theme);\n  const tint = selected ? colors.foreground : colors.mutedForeground;\n  return (\n    <div\n      role=\"presentation\"\n      style={{\n        width: iconSideOf(theme, \"md\"),\n        height: iconSideOf(theme, \"md\"),\n        display: \"flex\",\n        flexShrink: 0,\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        marginLeft: theme.spacing.xs,\n        pointerEvents: \"none\",\n      }}\n    >\n      {name === undefined ? (\n        children\n      ) : tint === undefined ? undefined : (\n        <Icon name={name} size=\"md\" color={tint} />\n      )}\n    </div>\n  );\n};\n\nexport const FileTreeName = ({ children }: FileTreeNameProps) => {\n  const theme = useTheme();\n  const colors = themeColors(theme);\n  return (\n    <div\n      style={{\n        flexGrow: 1,\n        minWidth: 0,\n        marginLeft: theme.spacing.xs,\n        overflow: \"hidden\",\n      }}\n    >\n      <text\n        style={{\n          ...textStyle(theme, \"label\"),\n          color: colors.foreground,\n          display: \"block\",\n          whiteSpace: \"nowrap\",\n          textOverflow: \"ellipsis\",\n        }}\n      >\n        {children}\n      </text>\n    </div>\n  );\n};\n\ninterface DeclaredTree {\n  readonly nodes: ReadonlyArray<FileNode>;\n  readonly content: ReadonlyMap<string, ReactNode>;\n}\n\nconst declare = (children: ReactNode): DeclaredTree => {\n  const content = new Map<string, ReactNode>();\n\n  const nodes = (next: ReactNode): ReadonlyArray<FileNode> =>\n    Arr.flatMap(Children.toArray(next), (child) => {\n      if (!isValidElement(child)) {\n        throw new Error(\n          `FileTree renders FileTreeFolder and FileTreeFile parts; received ${typeof child}.`,\n        );\n      }\n      if (child.type === Fragment) {\n        return nodes(\n          (child.props as { readonly children?: ReactNode }).children,\n        );\n      }\n      if (\n        isValidElement<FileTreeFolderProps>(child) &&\n        child.type === FileTreeFolder\n      ) {\n        return [\n          {\n            path: child.props.path,\n            name: child.props.name,\n            children: nodes(child.props.children),\n          },\n        ];\n      }\n      if (\n        isValidElement<FileTreeFileProps>(child) &&\n        child.type === FileTreeFile\n      ) {\n        if (child.props.children !== undefined) {\n          content.set(child.props.path, child.props.children);\n        }\n        return [\n          {\n            path: child.props.path,\n            name: child.props.name,\n            ...(child.props.icon === undefined\n              ? {}\n              : { icon: child.props.icon }),\n          },\n        ];\n      }\n      throw new Error(\n        `FileTree renders FileTreeFolder and FileTreeFile parts; ${nameOf(child.type)} is neither.`,\n      );\n    });\n\n  return { nodes: nodes(children), content };\n};\n\nconst kindOf = (node: FileNode): FileKind =>\n  node.children === undefined ? fileKindOf(node.name, false) : \"folder\";\n\nconst glyphOf = (node: FileNode, expanded: boolean): IconName =>\n  node.icon ?? fileIcon(kindOf(node), expanded);\n\ninterface FileTreeRowProps {\n  readonly row: TreeRow<FileNode>;\n  readonly selected: boolean;\n  readonly tabbable: boolean;\n  readonly content: ReactNode;\n  readonly testId: string | undefined;\n\n  readonly entering: boolean;\n\n  readonly leaving: boolean;\n  readonly timing: PresenceTiming;\n  readonly onPress: () => void;\n  readonly onKeyDown: (event: EventPayload) => void;\n  readonly attach?: (instance: PublicInstance | null) => void;\n}\n\nconst FOLD_LEAD_MS = 20;\n\nconst FileTreeRow = ({\n  row,\n  selected,\n  tabbable,\n  content,\n  testId,\n  entering,\n  leaving,\n  timing,\n  onPress,\n  onKeyDown,\n  attach,\n}: FileTreeRowProps) => {\n  const theme = useTheme();\n  const colors = themeColors(theme);\n  const tint = selected ? colors.foreground : colors.mutedForeground;\n  const hover = selected ? colors.hover : colors.hover;\n  const press =\n    pointerWash(theme, \"active\", selected ? \"accent\" : \"hover\") ??\n    colors.active;\n  const height = rowHeightOf(theme);\n  const resting = { height, opacity: 1 };\n  const folded = { height: 0, opacity: 0 };\n  const motion: MotionProps = {\n    initial: entering ? folded : resting,\n    animate: leaving ? folded : resting,\n    transition: leaving\n      ? delayedTiming(timing.exit, FOLD_LEAD_MS)\n      : timing.enter,\n  };\n\n  return (\n    <div\n      ref={attach}\n      role=\"treeitem\"\n      aria-label={treeName(row.node.name, row.key)}\n      aria-level={row.depth + 1}\n      {...(leaving\n        ? { \"aria-hidden\": true }\n        : row.node.children === undefined\n          ? { \"aria-selected\": selected }\n          : row.hasChildren\n            ? { \"aria-expanded\": row.expanded }\n            : {})}\n      tabIndex={!leaving && tabbable ? 0 : -1}\n      testId={testId}\n      onClick={leaving ? undefined : onPress}\n      onKeyDown={leaving ? undefined : onKeyDown}\n      motion={motion}\n      style={{\n        ...recipeStyle(FILE_TREE_ROW, theme),\n        height,\n        overflow: \"hidden\",\n        paddingLeft: TREE_INSET + row.depth * TREE_INDENT,\n        paddingRight: theme.spacing.sm,\n        borderRadius: theme.radius.md,\n        backgroundColor: selected ? colors.hover : undefined,\n        ...(leaving ? { pointerEvents: \"none\" } : {}),\n        hover: { backgroundColor: hover },\n        active: { backgroundColor: press },\n        focusVisible: {\n          outlineWidth: 2,\n          outlineColor: colors.ring,\n          outlineOffset: -2,\n        },\n      }}\n    >\n      <div\n        role=\"presentation\"\n        testId={testId === undefined ? undefined : `${testId}-slot`}\n        style={{\n          width: iconSideOf(theme, \"md\"),\n          height: iconSideOf(theme, \"md\"),\n          display: \"flex\",\n          flexShrink: 0,\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          pointerEvents: \"none\",\n        }}\n      >\n        {row.hasChildren && tint !== undefined ? (\n          <Icon\n            name={row.expanded ? \"chevron-down\" : \"chevron-right\"}\n            size=\"md\"\n            color={tint}\n          />\n        ) : undefined}\n      </div>\n      {content === undefined ? (\n        <>\n          <FileTreeIcon\n            name={glyphOf(row.node, row.expanded)}\n            selected={selected}\n          />\n          <FileTreeName selected={selected}>{row.node.name}</FileTreeName>\n        </>\n      ) : (\n        content\n      )}\n    </div>\n  );\n};\n\ntype Fold = Option.Option<{\n  readonly leaving: ReadonlyArray<TreeRow<FileNode>>;\n  readonly before: ReadonlyArray<TreeRow<FileNode>>;\n  readonly entering: HashSet.HashSet<string>;\n}>;\n\nexport const FileTree = ({\n  expanded,\n  defaultExpanded,\n  selected,\n  onSelect,\n  onExpandedChange,\n  children,\n  height,\n  className,\n  testId,\n  style,\n  ...rest\n}: FileTreeProps) => {\n  const theme = useTheme();\n  const colors = themeColors(theme);\n  const declared = useMemo(() => declare(children), [children]);\n  const [storedExpanded, setStoredExpanded] = useState<HashSet.HashSet<string>>(\n    () => expandedSet(defaultExpanded),\n  );\n  const open = expanded === undefined ? storedExpanded : expandedSet(expanded);\n  const rows = useMemo(\n    () => visibleFileRows(declared.nodes, open),\n    [declared.nodes, open],\n  );\n  const selectedPath = storedText(selected);\n  const [active, setActive] = useState<Option.Option<string>>(() =>\n    Option.map(fileTreeTab(rows, selectedPath), (row) => row.key),\n  );\n  const pendingSelection = useRef(false);\n  const timing = useSurfaceTiming(\"normal\");\n  const foldWindow = Math.max(\n    transitionWindowMs(timing.enter),\n    transitionWindowMs(delayedTiming(timing.exit, FOLD_LEAD_MS)),\n  );\n  const [fold, setFold] = useState<Fold>(Option.none());\n  const [seen, setSeen] = useState(rows);\n\n  if (seen !== rows) {\n    const before = seen;\n    const visible = HashSet.fromIterable(Arr.map(rows, (row) => row.key));\n    const previous = HashSet.fromIterable(Arr.map(before, (row) => row.key));\n    const leaving = Arr.filter(before, (row) => !HashSet.has(visible, row.key));\n    const entering = Arr.filter(rows, (row) => !HashSet.has(previous, row.key));\n    setSeen(rows);\n    setFold(\n      foldWindow === 0 ||\n        (Arr.isReadonlyArrayEmpty(leaving) &&\n          Arr.isReadonlyArrayEmpty(entering))\n        ? Option.none()\n        : Option.some({\n            leaving,\n            before,\n            entering: HashSet.fromIterable(Arr.map(entering, (row) => row.key)),\n          }),\n    );\n  }\n\n  useEffect(() => {\n    if (Option.isNone(fold)) return;\n    const handle = setTimeout(() => setFold(Option.none()), foldWindow);\n    return () => clearTimeout(handle);\n  }, [fold, foldWindow]);\n\n  const painted = paintedRows(\n    rows,\n    Option.match(fold, {\n      onNone: () => [],\n      onSome: (current) => current.leaving,\n    }),\n    Option.match(fold, {\n      onNone: () => rows,\n      onSome: (current) => current.before,\n    }),\n  );\n  const report = (next: HashSet.HashSet<string>): void => {\n    if (HashSet.isSubset(open, next) && HashSet.isSubset(next, open)) return;\n    if (expanded === undefined) setStoredExpanded(next);\n    onExpandedChange?.(fileTreePaths(next));\n  };\n\n  const commit = (next: TreeCursor): void => {\n    setActive(next.active);\n    report(next.expanded);\n  };\n\n  const tree = useTree({\n    rows,\n    labelOf: (node) => node.name,\n    cursor: { expanded: open, active },\n    onCursorChange: commit,\n    onActivate: (row) => {\n      if (row.node.children === undefined) onSelect?.(row.key);\n    },\n  });\n\n  useEffect(() => {\n    pendingSelection.current = true;\n  }, [selectedPath]);\n\n  useEffect(() => {\n    if (!pendingSelection.current) return;\n    if (selectedPath === undefined) {\n      pendingSelection.current = false;\n      return;\n    }\n    const tab = fileTreeTab(rows, selectedPath);\n    if (Option.isNone(tab) || tab.value.key !== selectedPath) return;\n    pendingSelection.current = false;\n    if (Option.contains(active, selectedPath)) return;\n    tree.commit(\n      { expanded: open, active: Option.some(selectedPath) },\n      { focus: false },\n    );\n  }, [selectedPath, active, rows, open, tree]);\n\n  const bound =\n    height !== undefined && Number.isFinite(height) && height > 0\n      ? height\n      : undefined;\n\n  return (\n    <Declared.Provider value={true}>\n      <div\n        {...rest}\n        role=\"tree\"\n        testId={testId}\n        style={mergeStyles(\n          mergeStyles(recipeStyle(cn(FILE_TREE_ROOT, className), theme), {\n            ...(bound === undefined\n              ? {}\n              : {\n                  height: bound,\n                  flexGrow: 0,\n                  flexShrink: 0,\n                  flexBasis: bound,\n                }),\n            overflowY: \"scroll\",\n            scrollbarColor: colors.scrollbar,\n          }),\n          style,\n        )}\n      >\n        {Arr.map(painted, ({ row, leaving }) => (\n          <FileTreeRow\n            key={row.key}\n            row={row}\n            selected={row.key === selectedPath}\n            tabbable={Option.contains(tree.tabKey, row.key)}\n            content={declared.content.get(row.key)}\n            testId={\n              testId === undefined ? undefined : `${testId}-row-${row.key}`\n            }\n            entering={Option.match(fold, {\n              onNone: () => false,\n              onSome: (current) => HashSet.has(current.entering, row.key),\n            })}\n            leaving={leaving}\n            timing={timing}\n            onPress={() => tree.activate(row)}\n            onKeyDown={tree.handleKey}\n            attach={leaving ? undefined : tree.attach(row.key)}\n          />\n        ))}\n      </div>\n    </Declared.Provider>\n  );\n};\n"
    },
    {
      "path": "packages/files/src/tree/logic.ts",
      "target": "@ui/gpuixui/files/tree/logic.ts",
      "type": "registry:lib",
      "content": "import {\n  findRow,\n  flattenTree,\n  type TreeRow,\n  type TreeSpec,\n} from \"../../data/index.js\";\nimport type { IconName } from \"../../icons/index.js\";\nimport { Result, pipe } from \"effect\";\nimport * as Arr from \"effect/Array\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Option from \"effect/Option\";\nimport * as Order from \"effect/Order\";\nimport * as R from \"effect/Record\";\nimport * as Str from \"effect/String\";\n\nexport type FileKind = \"folder\" | \"file\" | \"image\" | \"code\" | \"data\" | \"config\";\n\nexport interface FileNode {\n  readonly name: string;\n\n  readonly path: string;\n\n  readonly children?: ReadonlyArray<FileNode>;\n\n  readonly icon?: IconName;\n}\n\nconst IMAGE_EXTENSIONS: ReadonlyArray<string> = [\n  \"png\",\n  \"jpg\",\n  \"jpeg\",\n  \"gif\",\n  \"svg\",\n  \"webp\",\n  \"ico\",\n];\n\nconst CODE_EXTENSIONS: ReadonlyArray<string> = [\n  \"ts\",\n  \"tsx\",\n  \"js\",\n  \"jsx\",\n  \"mjs\",\n  \"cjs\",\n  \"py\",\n  \"rb\",\n  \"go\",\n  \"rs\",\n  \"java\",\n  \"c\",\n  \"h\",\n  \"cpp\",\n  \"hpp\",\n  \"css\",\n  \"html\",\n  \"sh\",\n];\n\nconst CONFIG_EXTENSIONS: ReadonlyArray<string> = [\n  \"json\",\n  \"yaml\",\n  \"yml\",\n  \"toml\",\n  \"ini\",\n  \"env\",\n  \"lock\",\n  \"gitignore\",\n];\n\nconst DATA_EXTENSIONS: ReadonlyArray<string> = [\"csv\", \"sql\", \"db\", \"sqlite\"];\n\nconst extensionOf = (name: string): Option.Option<string> => {\n  const segments = Str.split(\".\")(name);\n  return segments.length > 1\n    ? Option.map(Arr.last(segments), Str.toLowerCase)\n    : Option.none();\n};\n\nexport const fileKindOf = (name: string, isDirectory: boolean): FileKind => {\n  if (isDirectory) return \"folder\";\n  const extension = Option.getOrElse(extensionOf(name), () => \"\");\n  if (Arr.contains(IMAGE_EXTENSIONS, extension)) return \"image\";\n  if (Arr.contains(CODE_EXTENSIONS, extension)) return \"code\";\n  if (Arr.contains(CONFIG_EXTENSIONS, extension)) return \"config\";\n  if (Arr.contains(DATA_EXTENSIONS, extension)) return \"data\";\n  return \"file\";\n};\n\nexport const fileIcon = (kind: FileKind, _expanded: boolean): IconName =>\n  kind === \"folder\" ? \"folder\" : \"file\";\n\nconst toSegments = (\n  path: string,\n): Result.Result<ReadonlyArray<string>, void> => {\n  const segments = Arr.filter(Str.split(\"/\")(path), Str.isNonEmpty);\n  return Arr.isReadonlyArrayNonEmpty(segments)\n    ? Result.succeed(segments)\n    : Result.failVoid;\n};\n\nconst nonEmptyTail = (\n  segments: ReadonlyArray<string>,\n): Result.Result<ReadonlyArray<string>, void> =>\n  Option.match(Arr.tail(segments), {\n    onNone: () => Result.failVoid,\n    onSome: (rest) =>\n      Arr.isReadonlyArrayNonEmpty(rest)\n        ? Result.succeed(rest)\n        : Result.failVoid,\n  });\n\nconst byFolderThenName: Order.Order<FileNode> = Order.combine(\n  Order.mapInput(Order.Number, (node: FileNode) =>\n    node.children === undefined ? 1 : 0,\n  ),\n  Order.mapInput(Order.String, (node: FileNode) => node.name),\n);\n\nconst sortNodes = (nodes: ReadonlyArray<FileNode>): ReadonlyArray<FileNode> =>\n  Arr.sort(nodes, byFolderThenName);\n\nconst build = (\n  prefix: ReadonlyArray<string>,\n  paths: ReadonlyArray<ReadonlyArray<string>>,\n): ReadonlyArray<FileNode> =>\n  pipe(\n    Arr.groupBy(paths, (segments) =>\n      Option.getOrElse(Arr.head(segments), () => \"\"),\n    ),\n    R.toEntries,\n    Arr.map(([name, members]) => {\n      const path = Arr.join([...prefix, name], \"/\");\n      const children = sortNodes(\n        build([...prefix, name], Arr.filterMap(members, nonEmptyTail)),\n      );\n      return Arr.isReadonlyArrayNonEmpty(children)\n        ? { name, path, children }\n        : { name, path };\n    }),\n    sortNodes,\n  );\n\nexport const buildFileTree = (\n  paths: ReadonlyArray<string>,\n): ReadonlyArray<FileNode> => build([], Arr.filterMap(paths, toSegments));\n\nexport const fileTreeSpec: TreeSpec<FileNode> = {\n  keyOf: (node) => node.path,\n  childrenOf: (node) => node.children ?? [],\n};\n\nexport const visibleFileRows = (\n  roots: ReadonlyArray<FileNode>,\n  expanded: Iterable<string>,\n): ReadonlyArray<TreeRow<FileNode>> =>\n  flattenTree(roots, fileTreeSpec, HashSet.fromIterable(expanded));\n\nexport const fileTreeTab = <T>(\n  rows: ReadonlyArray<TreeRow<T>>,\n  selected: string | undefined,\n): Option.Option<TreeRow<T>> =>\n  Option.orElse(findRow(rows, Option.fromNullishOr(selected)), () =>\n    Arr.head(rows),\n  );\n\nexport const fileTreePaths = (\n  expanded: Iterable<string>,\n): ReadonlyArray<string> =>\n  Arr.sort(Arr.fromIterable(HashSet.fromIterable(expanded)), Order.String);\n"
    },
    {
      "path": "packages/files/src/tree/recipe.ts",
      "target": "@ui/gpuixui/files/tree/recipe.ts",
      "type": "registry:lib",
      "content": "export const FILE_TREE_ROOT = \"flex flex-col overflow-hidden\";\n\nexport const FILE_TREE_ROW =\n  \"flex flex-row items-center shrink-0 text-sm cursor-pointer\";\n"
    }
  ],
  "docs": "[File trees](https://gpuixui.sudokw.com/files/file-tree) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/files/file-tree",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}