Единый интерфейс элементов

This commit is contained in:
2025-07-22 19:44:49 +03:00
parent 553da77a87
commit 3fc352f8e9
36 changed files with 2108 additions and 675 deletions

View File

@@ -0,0 +1,53 @@
import { Input } from '@/component/ui/input'
import { ElementDefinition } from '@/entitiy/element/model/interface'
import { ExtraSettingsBadge } from '@/entitiy/element/ui/extraSettingsBadge'
import { Type } from 'lucide-react'
interface TextConfig {
placeholder?: string
required?: boolean
targetCells: any[]
name?: string
}
export const textDefinition: ElementDefinition<TextConfig, string> = {
type: 'text',
label: 'Текстовое поле',
icon: <Type className="h-4 w-4" />,
version: 1,
defaultConfig: {
placeholder: '',
required: false,
targetCells: [],
name: '',
},
mapToCells: config => config.targetCells || [],
Editor: () => <ExtraSettingsBadge />,
Preview: ({ config }) => (
<div className="space-y-1">
{config.name && (
<label className="text-sm font-medium text-gray-900">
{config.name}
{config.required && <span className="ml-1 text-red-500">*</span>}
</label>
)}
<Input placeholder={config.placeholder} className="w-full" />
</div>
),
Render: ({ config, value, onChange }) => (
<div className="space-y-1">
{config.name && (
<label className="text-sm font-medium text-gray-900">
{config.name}
{config.required && <span className="ml-1 text-red-500">*</span>}
</label>
)}
<Input
placeholder={config.placeholder}
value={value || ''}
onChange={e => onChange?.(e.target.value)}
required={config.required}
/>
</div>
),
}