/** * Left-rail field-type palette for the form-widget drag-drop builder * (Phase 05 #58 follow-up). Each tile supports two interaction modes: * * 1. Click → calls `onAdd(type)`, which the parent * appends to the canvas using the palette's default field shape. * 2. Drag → exposes a `@dnd-kit` draggable so the user can drop the * tile directly onto a position on the sortable canvas. * * Keeping click+drag both functional is an explicit a11y requirement — * the keyboard sensor on the canvas handles reorder, and the click * path is the no-pointer "add field" affordance. */ import type * as React from "react"; import { useDraggable } from "@dnd-kit/core"; import { useTranslation } from "react-i18next"; import { paletteItems } from "./palette"; import type { BuilderFieldType } from "./types"; export type FieldPaletteProps = { onAdd: (type: BuilderFieldType) => void; }; function DraggablePaletteTile({ type, labelKey, helpKey, onAdd, }: { type: BuilderFieldType; labelKey: string; helpKey: string; onAdd: (type: BuilderFieldType) => void; }): React.JSX.Element { const { t } = useTranslation(); const label = t(labelKey); const help = t(helpKey); const { attributes, listeners, setNodeRef, isDragging } = useDraggable({ id: `palette:${type}`, data: { source: "palette", type }, }); return ( ); } export function FieldPalette({ onAdd }: FieldPaletteProps): React.JSX.Element { const { t } = useTranslation(); return ( ); }