"use client"
/**
* Shared “new folder” floating sheet (same shell as Export) — used by OS folder grid and column panel.
*/
import * as React from "react"
import {
FloatingSheetPanel,
FloatingSheetPanelBody,
FloatingSheetPanelContent,
FloatingSheetPanelHeader,
FloatingSheetPanelWorkflowFooter,
} from "@/lib/floating-sheet-panel"
import { cn } from "@/lib/utils"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import {
LIBRARY_FOLDER_COLOR_STYLES,
LIBRARY_FOLDER_ICON_OPTIONS,
type LibraryFolderColorKey,
} from "@/lib/mock/library-folders"
import { OsFolderGlyph } from "@/components/data-views/os-folder-glyph"
const COLOR_OPTIONS: LibraryFolderColorKey[] = [
"brand",
"success",
"warning",
"destructive",
"muted",
"chart1",
"chart2",
"chart3",
]
function FolderTilePreview({
name,
colorKey,
icon,
className,
}: {
name: string
colorKey: LibraryFolderColorKey
icon: string
className?: string
}) {
const display = name.trim() || "Untitled"
return (
)
}
export interface LibraryNewFolderSheetProps {
open: boolean
onOpenChange: (open: boolean) => void
/** Parent folder id for the new folder (`null` = top level). */
parentFolderId: string | null
/** Replaces default helper copy under the title. */
descriptionText?: string
/** When provided, the sheet is in "customize" mode with these initial values. */
customizingFolder?: {
name: string
icon: string
colorKey: LibraryFolderColorKey
parentId: string | null
} | null
onCreated: (folder: {
name: string
icon: string
colorKey: LibraryFolderColorKey
parentId: string | null
}) => void
}
export function LibraryNewFolderSheet({
open,
onOpenChange,
parentFolderId,
customizingFolder,
descriptionText = "Name, color, and icon update the preview. The folder is created in the location shown in the breadcrumb above the grid.",
onCreated,
}: LibraryNewFolderSheetProps) {
const [draft, setDraft] = React.useState<{
name: string
colorKey: LibraryFolderColorKey
icon: string
}>({ name: "Untitled", colorKey: "brand", icon: "fa-folder" })
const handleOpenChange = React.useCallback(
(next: boolean) => {
if (next) {
setDraft(
customizingFolder
? {
name: customizingFolder.name,
colorKey: customizingFolder.colorKey,
icon: customizingFolder.icon,
}
: { name: "Untitled", colorKey: "brand", icon: "fa-folder" },
)
}
onOpenChange(next)
},
[customizingFolder, onOpenChange],
)
const createDisabled = !draft.name.trim()
function commit() {
const v = draft.name.trim()
if (!v) return
onCreated({
name: v,
icon: draft.icon,
colorKey: draft.colorKey,
parentId: parentFolderId,
})
onOpenChange(false)
}
return (
onOpenChange(false)}
/>
)
}