<?php

declare(strict_types=1);

namespace App\View\Components\Form;

use Illuminate\Support\Js;
use App\View\Components\FormComponent;

class CustomSelectOption extends FormComponent
{
    public function __construct(
        public $value = null,
        public $label = null,
        public $selectedLabel = null,
        public bool $disabled = false,
        public bool $isOptGroup = false,
    ) {
    }

    public function configToJs(): Js
    {
        return Js::from([
            'optionDisabled' => $this->disabled,
            'optionValue' => $this->value,
            'optionLabel' => $this->label,
            'optionSelectedLabel' => $this->selectedLabel ?? $this->label,
            'isOptGroup' => $this->isOptGroup,
        ]);
    }
}
