import React, { useState } from 'react' import { Pencil } from 'lucide-react' import { useFormStore } from '../store/useFormStore' import ConditionalLogicToggle from './ConditionalLogicToggle' import ImageFieldEditor from './field-editors/ImageFieldEditor' import StaticContentEditor from './field-editors/StaticContentEditor' import UtilityFieldSettings from './field-editors/UtilityFieldSettings' import FieldIconControl from './field-editors/FieldIconControl' import OptionsEditor from './property/OptionsEditor' import FieldStylePicker from './property/FieldStylePicker' import { FieldColors, hasFieldColors, DefaultValueEditor, SubfieldsEditor, DateSettings, TimeSettings, PhoneSettings, RichTextToggle, ImageStyleSettings, GridSettings, } from './property/TypeSettings' import { getFieldType, Slot, useRegistryVersion } from '../extensions/registry' import { BUILTIN_FIELD_TYPES } from './FormField' import InfoTip from './property/InfoTip' import { SettingLabel, AccordionSection } from './property/PanelParts' // Human-readable field type for the storefront-style "Edit : [Type]" chip. const FIELD_TYPE_LABELS = { select: 'Dropdown', tel: 'Phone', url: 'Website', textarea: 'Paragraph Text', text: 'Text', checkbox: 'Checkbox', radio: 'Radio', 'static-content': 'Static Content', html: 'HTML', captcha: 'CAPTCHA', } export function getFieldTypeDisplay(type) { if (!type) return 'Unknown Field Type' if (FIELD_TYPE_LABELS[type]) return FIELD_TYPE_LABELS[type] const registered = getFieldType(type) if (registered && (registered.typeLabel || registered.label)) return registered.typeLabel || registered.label return type.split('-').map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(' ') } export default function PropertyEditor() { useRegistryVersion() const activeFieldId = useFormStore((state) => state.activeFieldId) const fields = useFormStore((state) => state.fields) const updateField = useFormStore((state) => state.updateField) const setIsLogicSidebarOpen = useFormStore((state) => state.setIsLogicSidebarOpen) // Fields inside container columns are editable too (a `columns` array holds column definitions). const findField = (list) => { for (const f of list || []) { if (f.id === activeFieldId) return f if (f.columns && !Array.isArray(f.columns) && typeof f.columns === 'object') { for (const col of Object.values(f.columns)) { const found = Array.isArray(col) ? findField(col) : null if (found) return found } } } return null } const activeField = findField(fields) // the reference builder accordion: one section open at a time, General open by default. const [openSection, setOpenSection] = useState('General') const setActiveFieldId = useFormStore((state) => state.setActiveFieldId) if (!activeField) { return (
Unsupported field type: {String(t || 'unknown')}
This field type can't be edited here. The field and its settings are kept when you save the form.
Edit : {typeDisplay}