"""
Dropdown component schemas.

Mirrors lightwave-ui/src/components/base/dropdown/.
"""

from typing import Literal

from pydantic import BaseModel, ConfigDict, Field


class DropdownOption(BaseModel):
    """
    Dropdown option item.
    """

    value: str = Field(..., description="Option value")
    label: str = Field(..., description="Display label")
    description: str | None = Field(None, description="Optional description")
    icon: str | None = Field(None, description="Optional icon")
    disabled: bool = Field(False, description="Disabled state")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


class DropdownProps(BaseModel):
    """
    Dropdown/select component props.

    Matches TypeScript DropdownProps.
    """

    # Options
    options: list[DropdownOption] = Field(default_factory=list, description="Dropdown options")
    value: str | None = Field(None, description="Selected value")
    default_value: str | None = Field(None, serialization_alias="defaultValue", description="Default value")

    # Labels
    label: str | None = Field(None, description="Field label")
    placeholder: str | None = Field(None, description="Placeholder text")
    hint: str | None = Field(None, description="Hint text below dropdown")

    # Size
    size: Literal["sm", "md"] = Field("sm", description="Dropdown size")

    # State
    is_disabled: bool = Field(False, serialization_alias="isDisabled", description="Disabled state")
    is_required: bool = Field(False, serialization_alias="isRequired", description="Required field")
    is_error: bool = Field(False, serialization_alias="isError", description="Error state")
    error_message: str | None = Field(None, serialization_alias="errorMessage", description="Error message")

    model_config = ConfigDict(
        populate_by_name=True,
        extra="forbid",
    )


__all__ = [
    "DropdownOption",
    "DropdownProps",
]
