'use client'; import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from '@headlessui/react'; import type { IconSize, SortBy, SortDirection, ViewMode } from '@/types/documents'; import { IconsViewIcon, ListViewIcon, ColumnsViewIcon, GalleryViewIcon, SearchIcon, FolderPlusIcon, HamburgerIcon, } from './finderIcons'; import { ChevronUpDownIcon } from '@/components/icons/Icons'; import type { ReactNode } from 'react'; interface FinderToolbarProps { viewMode: ViewMode; onViewModeChange: (mode: ViewMode) => void; iconSize: IconSize; onIconSizeChange: (size: IconSize) => void; sortBy: SortBy; sortDirection: SortDirection; onSortByChange: (s: SortBy) => void; onSortDirectionToggle: () => void; query: string; onQueryChange: (q: string) => void; onNewFolder: () => void; onToggleSidebar: () => void; /** True when the columns view should be disabled (mobile viewport). */ isNarrow: boolean; /** App-level content rendered at the far left (brand/logo). */ leftSlot?: ReactNode; /** App-level content rendered at the far right (settings, user menu). */ rightSlot?: ReactNode; } const VIEW_BUTTONS: Array<{ value: ViewMode; label: string; Icon: typeof IconsViewIcon }> = [ { value: 'icons', label: 'Icons', Icon: IconsViewIcon }, { value: 'list', label: 'List', Icon: ListViewIcon }, { value: 'columns', label: 'Columns', Icon: ColumnsViewIcon }, { value: 'gallery', label: 'Gallery', Icon: GalleryViewIcon }, ]; const SORT_OPTIONS: Array<{ value: SortBy; label: string; asc: string; desc: string }> = [ { value: 'name', label: 'Name', asc: 'A → Z', desc: 'Z → A' }, { value: 'type', label: 'Kind', asc: 'A → Z', desc: 'Z → A' }, { value: 'date', label: 'Modified', asc: 'Oldest', desc: 'Newest' }, { value: 'size', label: 'Size', asc: 'Smallest', desc: 'Largest' }, ]; const ICON_SIZES: Array<{ value: IconSize; label: string }> = [ { value: 'sm', label: 'S' }, { value: 'md', label: 'M' }, { value: 'lg', label: 'L' }, { value: 'xl', label: 'XL' }, ]; // Match SettingsModal / UserMenu trigger sizing exactly so all bar buttons share one rhythm. const TOOLBAR_BTN = 'inline-flex items-center py-1 px-2 rounded-md border bg-base text-xs transition-all duration-200 ease-out hover:scale-[1.01]'; const TOOLBAR_BTN_INACTIVE = 'border-offbase text-foreground hover:text-accent hover:border-accent hover:bg-offbase'; // Pill-grouped segmented control. Outer pill carries the border; inner segments are // borderless and rely on bg/text color to show active/hover. Sized so the whole pill // matches the height of a standalone TOOLBAR_BTN. const PILL = 'inline-flex items-center rounded-md border border-offbase bg-base p-0.5 gap-0.5 shrink-0'; const PILL_SEGMENT = 'inline-flex items-center justify-center rounded-[5px] text-xs transition-colors duration-200 ease-out'; const PILL_SEGMENT_INACTIVE = 'text-muted hover:bg-offbase hover:text-accent'; const PILL_SEGMENT_ACTIVE = 'bg-offbase text-accent'; export function FinderToolbar({ viewMode, onViewModeChange, iconSize, onIconSizeChange, sortBy, sortDirection, onSortByChange, onSortDirectionToggle, query, onQueryChange, onNewFolder, onToggleSidebar, isNarrow, leftSlot, rightSlot, }: FinderToolbarProps) { const currentSort = SORT_OPTIONS.find((o) => o.value === sortBy) ?? SORT_OPTIONS[0]; const directionLabel = sortDirection === 'asc' ? currentSort.asc : currentSort.desc; return (