import { icons } from "@/lib/client/icons"; import Fuse from "fuse.js"; import { forwardRef, useMemo } from "react"; import { FixedSizeGrid as Grid } from "react-window"; const fuse = new Fuse(icons, { keys: [{ name: "name", weight: 4 }, "tags", "categories"], threshold: 0.2, useExtendedSearch: true, }); type Props = { query: string; color: string; weight: "light" | "regular" | "bold" | "fill" | "duotone" | "thin"; iconName?: string; setIconName: Function; }; const IconGrid = ({ query, color, weight, iconName, setIconName }: Props) => { const filteredIcons = useMemo(() => { if (!query) { return icons; } return fuse.search(query).map((result) => result.item); }, [query]); const columnCount = 6; const rowCount = Math.ceil(filteredIcons.length / columnCount); const GUTTER_SIZE = 5; const Cell = ({ columnIndex, rowIndex, style }: any) => { const index = rowIndex * columnCount + columnIndex; if (index >= filteredIcons.length) return null; // Prevent overflow const icon = filteredIcons[index]; const IconComponent = icon.Icon; return (