From ebd3a93cb236d0be606626926b644e5555fa0865 Mon Sep 17 00:00:00 2001 From: tlartem Date: Wed, 23 Jul 2025 18:28:00 +0300 Subject: [PATCH] f --- .../BasicElements/CheckboxElement.tsx | 53 ------- src/component/BasicElements/RadioElement.tsx | 139 ------------------ .../BasicElements/TextareaElement.tsx | 54 ------- src/component/BasicElements/index.ts | 5 +- src/component/TemplateManager/HeaderBar.tsx | 4 +- src/component/ui/badge.tsx | 2 +- src/component/ui/button.tsx | 31 ++-- src/component/ui/card.tsx | 29 ++-- src/component/ui/checkbox.tsx | 12 +- src/component/ui/dialog.tsx | 35 +++-- src/component/ui/input.tsx | 8 +- src/component/ui/label.tsx | 10 +- src/component/ui/radio-group.tsx | 12 +- src/component/ui/select.tsx | 45 +++--- src/component/ui/separator.tsx | 12 +- src/component/ui/textarea.tsx | 8 +- src/components/ui/button.tsx | 57 +++++++ .../model/implementations}/DateElement.tsx | 22 +-- src/entitiy/element/model/interface.ts | 14 +- src/page/ElementsCreation/Page.tsx | 4 +- src/page/ProtocolCreation/Page.tsx | 6 +- 21 files changed, 185 insertions(+), 377 deletions(-) delete mode 100644 src/component/BasicElements/CheckboxElement.tsx delete mode 100644 src/component/BasicElements/RadioElement.tsx delete mode 100644 src/component/BasicElements/TextareaElement.tsx create mode 100644 src/components/ui/button.tsx rename src/{component/BasicElements => entitiy/element/model/implementations}/DateElement.tsx (56%) diff --git a/src/component/BasicElements/CheckboxElement.tsx b/src/component/BasicElements/CheckboxElement.tsx deleted file mode 100644 index f7802aa..0000000 --- a/src/component/BasicElements/CheckboxElement.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { ElementDefinition } from '@/entitiy/element/model/interface' -import { CheckSquare } from 'lucide-react' - -interface CheckboxConfig { - placeholder?: string - required?: boolean - targetCells: any[] -} - -export const checkboxDefinition: ElementDefinition = { - type: 'checkbox', - label: 'Чекбокс', - icon: , - version: 1, - defaultConfig: { - placeholder: '', - required: false, - targetCells: [], - }, - mapToCells: config => config.targetCells || [], - mapToCellValues: (config, value) => { - const cells = config.targetCells || [] - return cells.map(target => ({ target, value: value || false })) - }, - Editor: () => ( -
- Дополнительные настройки отсутствуют -
- ), - Preview: ({ config }) => ( -
-
Предпросмотр
-
-
-
- {config.placeholder || 'Отметить'} -
-
-
- ), - Render: ({ config, value, onChange }) => ( -
- onChange?.(e.target.checked)} - required={config.required} - className="h-4 w-4" - /> - {config.placeholder || 'Отметить'} -
- ), -} diff --git a/src/component/BasicElements/RadioElement.tsx b/src/component/BasicElements/RadioElement.tsx deleted file mode 100644 index b85a3a4..0000000 --- a/src/component/BasicElements/RadioElement.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import { Button } from '@/component/ui/button' -import { Input } from '@/component/ui/input' -import { ElementDefinition } from '@/entitiy/element/model/interface' -import { ElementOption } from '@/type/template' -import { CheckSquare, Plus, Trash2 } from 'lucide-react' - -interface RadioConfig { - placeholder?: string - required?: boolean - options: ElementOption[] - targetCells: any[] -} - -export const radioDefinition: ElementDefinition = { - type: 'radio', - label: 'Радиокнопки', - icon: , - version: 1, - defaultConfig: { - placeholder: '', - required: false, - options: [], - targetCells: [], - }, - mapToCells: config => config.targetCells || [], - mapToCellValues: (config, value) => { - const cells = config.targetCells || [] - return cells.map(target => ({ target, value: value || '' })) - }, - Editor: ({ config, onChange }) => { - const handleAddOption = () => { - onChange({ - ...config, - options: [...config.options, { value: '', label: '' }], - }) - } - - const handleUpdateOption = ( - index: number, - field: 'value' | 'label', - value: string - ) => { - onChange({ - ...config, - options: config.options.map((option, i) => - i === index ? { ...option, [field]: value } : option - ), - }) - } - - const handleRemoveOption = (index: number) => { - onChange({ - ...config, - options: config.options.filter((_, i) => i !== index), - }) - } - - return ( -
-
-
- - -
-
- {config.options.map((option, index) => ( -
- - handleUpdateOption(index, 'value', e.target.value) - } - /> - - handleUpdateOption(index, 'label', e.target.value) - } - /> - -
- ))} -
-
-
- ) - }, - Preview: ({ config }) => ( -
-
Предпросмотр
-
-
- {config.options.length > 0 ? ( - config.options.map((option, index) => ( -
-
- {option.label} -
- )) - ) : ( -
-
- Вариант 1 -
- )} -
-
-
- ), - Render: ({ config, value, onChange }) => ( -
- {config.options.map((option, index) => ( -
- onChange?.(e.target.value)} - required={config.required} - className="h-4 w-4" - /> - {option.label} -
- ))} -
- ), -} diff --git a/src/component/BasicElements/TextareaElement.tsx b/src/component/BasicElements/TextareaElement.tsx deleted file mode 100644 index 4aef047..0000000 --- a/src/component/BasicElements/TextareaElement.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { Textarea } from '@/component/ui/textarea' -import { ElementDefinition } from '@/entitiy/element/model/interface' -import { FileText } from 'lucide-react' - -interface TextareaConfig { - placeholder?: string - required?: boolean - targetCells: any[] -} - -export const textareaDefinition: ElementDefinition = { - type: 'textarea', - label: 'Многострочный текст', - icon: , - version: 1, - defaultConfig: { - placeholder: '', - required: false, - targetCells: [], - }, - mapToCells: config => config.targetCells || [], - mapToCellValues: (config, value) => { - const cells = config.targetCells || [] - return cells.map(target => ({ target, value: value || '' })) - }, - Editor: () => ( -
- Дополнительные настройки отсутствуют -
- ), - Preview: ({ config }) => ( -
-
Предпросмотр
-
-