import * as React from "react"; import { CheckIcon } from "@phosphor-icons/react"; import { ScrollFade } from "../../primitives"; import { cn } from "../../../lib/utils"; import type { FontPickerFontCatalogEntry, FontPickerFontFilterValue, } from "./font-catalog"; import { getFontFamilyStyle } from "./font-picker-value"; export const fontItemHeightPx = 36; export const fontItemGapPx = 1; export const fontVirtualItemStepPx = fontItemHeightPx + fontItemGapPx; export const fontListOverscanItems = 6; export const fontListHeightWithFooterPx = 240; export const fontPreloadBufferAheadItems = 60; export const fontPreloadBufferBehindItems = 30; export type FontPickerPinnedSelectedRowSide = "bottom" | "top" | null; type FontPickerListProps = { attachScrollViewport: (node: HTMLDivElement | null) => void; bottomSpacerHeight: number; category: FontPickerFontFilterValue; clearHoverPreview: () => void; filteredFontCount: number; onFontBlur: () => void; onFontFocus: (font: FontPickerFontCatalogEntry) => void; onFontMouseEnter: (font: FontPickerFontCatalogEntry) => void; onFontSelect: (font: FontPickerFontCatalogEntry) => void; pinnedSelectedRowSide: FontPickerPinnedSelectedRowSide; query: string; scrollToFontIndex: (index: number) => void; selectedFont: FontPickerFontCatalogEntry | null | undefined; selectedFontId: string; selectedFontIndex: number; selectedFontPreviewStyle?: React.CSSProperties; topSpacerHeight: number; virtualEndIndex: number; virtualStartIndex: number; visibleFonts: readonly FontPickerFontCatalogEntry[]; }; const menuItemInteractionClassName = "hover:bg-[color:color-mix(in_oklab,var(--muted-foreground)_10%,transparent)] hover:text-[color:var(--foreground)] focus:bg-[color:color-mix(in_oklab,var(--muted-foreground)_10%,transparent)] focus:text-[color:var(--foreground)]"; export function FontPickerList({ attachScrollViewport, bottomSpacerHeight, category, clearHoverPreview, filteredFontCount, onFontBlur, onFontFocus, onFontMouseEnter, onFontSelect, pinnedSelectedRowSide, query, scrollToFontIndex, selectedFont, selectedFontId, selectedFontIndex, selectedFontPreviewStyle, topSpacerHeight, virtualEndIndex, virtualStartIndex, visibleFonts, }: FontPickerListProps): React.JSX.Element { return (