"use client"; import * as React from "react"; import { ExternalLink, FileIcon, Link2, User, X, } from "lucide-react"; import { cn } from "@/lib/utils"; import { Avatar, AvatarFallback, AvatarImage, } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Input } from "@/components/ui/input"; export type PropertyFieldType = | "text" | "richtext" | "number" | "date" | "select" | "multiselect" | "person" | "relation" | "url" | "file" | "checkbox"; export interface PropertyDefinitionInput { name: string; fieldType: PropertyFieldType; config?: { options?: { label: string; value: string }[]; [key: string]: unknown; } | null; } export interface PropertyEditorProps { definition: PropertyDefinitionInput; value: unknown; onChange: (value: unknown) => void; className?: string; } function initials(name: string) { return name .split(/\s+/) .map((p) => p[0]) .join("") .slice(0, 2) .toUpperCase(); } export function PropertyEditor({ definition, value, onChange, className, }: PropertyEditorProps) { const { name, fieldType, config } = definition; const options = config?.options ?? []; const row = (control: React.ReactNode) => (
{control}
); switch (fieldType) { case "text": return row( onChange(e.target.value)} className="h-8 text-xs" />, ); case "richtext": return row(