import React from 'react' import { AlertTriangle, Trash2 } from 'lucide-react' import { useFormStore } from '../../store/useFormStore' /** * Per-field error boundary: a field that fails to render shows a small notice in its place (edit mode) or nothing * (preview) instead of blanking the whole canvas. It tries again whenever the field changes (settings edit, undo). */ export default class FieldErrorBoundary extends React.Component { constructor(props) { super(props) this.state = { error: null, field: props.field } } static getDerivedStateFromError(error) { return { error } } static getDerivedStateFromProps(props, state) { if (props.field !== state.field) return { field: props.field, error: null } return null } componentDidCatch(error, info) { console.error(`Field "${this.props.field?.id}" (${this.props.field?.type}) failed to render:`, error, info?.componentStack) } render() { if (!this.state.error) return this.props.children const field = this.props.field || {} const viewMode = useFormStore.getState().viewMode if (viewMode === 'preview') return null return (