import { ActionIcon, ColorInput, Group, NumberInput, Paper, SegmentedControl, Select, Stack, Text, TextInput, Tooltip, } from '@mantine/core'; import { IconTrash } from '@tabler/icons-react'; import { useTranslation } from 'react-i18next'; import type { TemplateFieldPlacement, TemplateVariable } from '@ema-platform/api'; interface Props { block: TemplateFieldPlacement | null; variables: TemplateVariable[]; onChange: (block: TemplateFieldPlacement) => void; onDelete: (id: string) => void; disabled: boolean; } /** Everything about the selected block that is not its position on the page. */ export function BlockPropertiesPanel({ block, variables, onChange, onDelete, disabled, }: Props) { const { t } = useTranslation(); if (!block) { return ( {t('designer.noBlockSelected', 'Select a block on the page to edit it.')} ); } const isLiteral = block.variable === null; return ( {t('designer.blockProperties', 'Selected block')} onDelete(block.id)} > onChange( value === 'text' ? { ...block, variable: null, text: block.text ?? '' } : { ...block, variable: variables[0]?.key ?? 'companyName' }, ) } data={[ { value: 'variable', label: t('designer.blockVariable', 'Variable') }, { value: 'text', label: t('designer.blockText', 'Fixed text') }, ]} /> {isLiteral ? ( onChange({ ...block, text: e.currentTarget.value })} disabled={disabled} /> ) : (