import * as React from "react"; import { MagnifyingGlassIcon } from "@phosphor-icons/react"; import { Input, PopoverContent, } from "../../primitives"; import { cn } from "../../../lib/utils"; import { FONT_PICKER_FILTER_OPTIONS, type FontPickerFontCatalogEntry, type FontPickerFontFilterValue, } from "./font-catalog"; import { FontPickerList, type FontPickerPinnedSelectedRowSide, } from "./font-picker-list"; import { FontPickerFooterControl, LetterSpacingIcon, LineHeightIcon, } from "./font-picker-footer"; type FontPickerStep = { label: string; numericValue: number; value: string; }; type FontPickerPopoverContentProps = { attachScrollViewport: (node: HTMLDivElement | null) => void; bottomSpacerHeight: number; category: FontPickerFontFilterValue; clearHoverPreview: () => void; disabled: boolean; filteredFontCount: number; lineHeightSteps: readonly FontPickerStep[]; lineHeightValueIndex: number; letterSpacingSteps: readonly FontPickerStep[]; letterSpacingValueIndex: number; onCategoryChange: (nextCategory: FontPickerFontFilterValue) => void; onFontBlur: () => void; onFontFocus: (font: FontPickerFontCatalogEntry) => void; onFontMouseEnter: (font: FontPickerFontCatalogEntry) => void; onFontSelect: (font: FontPickerFontCatalogEntry) => void; onLetterSpacingValueChange: (nextIndex: number) => void; onLineHeightValueChange: (nextIndex: number) => void; onQueryChange: (nextQuery: string) => void; pinnedSelectedRowSide: FontPickerPinnedSelectedRowSide; popoverWidth?: number; query: string; scrollToFontIndex: (index: number) => void; searchInputRef: React.Ref; searchPlaceholder: string; selectedFont: FontPickerFontCatalogEntry | null | undefined; selectedFontId: string; selectedFontIndex: number; selectedFontPreviewStyle?: React.CSSProperties; topSpacerHeight: number; virtualEndIndex: number; virtualStartIndex: number; visibleFonts: readonly FontPickerFontCatalogEntry[]; }; export function FontPickerPopoverContent({ attachScrollViewport, bottomSpacerHeight, category, clearHoverPreview, disabled, filteredFontCount, lineHeightSteps, lineHeightValueIndex, letterSpacingSteps, letterSpacingValueIndex, onCategoryChange, onFontBlur, onFontFocus, onFontMouseEnter, onFontSelect, onLetterSpacingValueChange, onLineHeightValueChange, onQueryChange, pinnedSelectedRowSide, popoverWidth, query, scrollToFontIndex, searchInputRef, searchPlaceholder, selectedFont, selectedFontId, selectedFontIndex, selectedFontPreviewStyle, topSpacerHeight, virtualEndIndex, virtualStartIndex, visibleFonts, }: FontPickerPopoverContentProps): React.JSX.Element { return (
onQueryChange(event.target.value)} placeholder={searchPlaceholder} type="text" value={query} />
{FONT_PICKER_FILTER_OPTIONS.map((option) => { const active = category === option.value; return ( ); })}
} onValueChange={onLetterSpacingValueChange} steps={letterSpacingSteps} title="Letter spacing" valueIndex={letterSpacingValueIndex} /> } onValueChange={onLineHeightValueChange} steps={lineHeightSteps} title="Line height" valueIndex={lineHeightValueIndex} />
); }