# -*- coding: utf-8 -*- """ Formular-Feld-Definitionen fuer Scheduler-Komponenten in der TUI. """ from dataclasses import dataclass, field from enum import Enum from typing import Any class FieldType(Enum): """Typ eines Formular-Felds.""" TEXT = "text" # Einzeiliges Textfeld TEXTAREA = "textarea" # Mehrzeiliges Textfeld NUMBER = "number" # Numerisches Feld (int/float) CHECKBOX = "checkbox" # Boolean-Toggle SELECT = "select" # Dropdown-Auswahl RADIO = "radio" # Radio-Button-Gruppe DATETIME = "datetime" # Datum/Zeit-Eingabe (ISO-Format) TAGS = "tags" # Komma-separierte Liste WEEKDAYS = "weekdays" # Wochentag-Auswahl (Checkboxen Mo-So) KEY_VALUE = "key_value" # Key-Value Paare (Dict) @dataclass class FormField: """ Beschreibt ein Formular-Feld fuer die TUI. """ name: str # Interner Feldname (z.B. "expression") label: str # Anzeige-Label (z.B. "Cron-Ausdruck") field_type: FieldType = FieldType.TEXT # Widget-Typ required: bool = False # Pflichtfeld default: Any = None # Standardwert placeholder: str = "" # Platzhalter-Text help_text: str = "" # Hilfetext unter dem Feld # Text/Textarea max_length: int = 0 # Max. Zeichenlaenge (0=unbegrenzt) lines: int = 1 # Zeilen fuer Textarea # Number min_value: float | None = None # Minimum max_value: float | None = None # Maximum step: float = 1.0 # Schrittweite is_float: bool = False # Float statt Int # Select/Radio choices: list[tuple[str, str]] = field(default_factory=list) # (value, label) Paare # Validierung pattern: str = "" # Regex-Pattern fuer Validierung pattern_error: str = "" # Fehlermeldung bei Pattern-Mismatch # Gruppierung group: str = "" # Optionale Gruppe fuer visuelle Trennung @dataclass class FormValidationError: """Validierungsfehler fuer ein Formular-Feld.""" field_name: str message: str