@props(['name', 'key' => '', 'option' => '', 'disabled' => false, 'value' => null, 'size' => 'sm', 'bold' => false]) @php $dotName = dot_name($name); $isDisabled = $disabled; $isError = $errors->has($name); $value = old($dotName, $value); if ($value && $value instanceof UnitEnum) { $value = $value->value; } $iconSize = match ($size) { 'sm' => 'size-4.5', 'md' => 'size-5', 'lg' => 'size-5.5', default => 'size-4.5', }; $textSize = match ($size) { 'sm' => 'text-sm', 'md' => 'text-base', 'lg' => 'text-lg', default => 'text-sm', }; @endphp @php $id = 'radio-' . $name . '-' . $key; $isCustom = !is_string($option); if ($isCustom) { $label = $option['label'] ?? ''; $type = isset($option['type']) ? $option['type'] : null; $color = isset($option['color']) ? $option['color'] : 'blue'; $helperText = $option['helper-text'] ?? ''; } else { $label = $option; $type = null; $color = 'blue'; } $colorClassMap = match($color) { 'blue' => 'text-blue-600 focus:ring-blue-500 dark:focus:ring-blue-600', 'red' => 'text-red-600 focus:ring-red-500 dark:focus:ring-red-600', 'green' => 'text-green-600 focus:ring-green-500 dark:focus:ring-green-600', 'yellow' => 'text-yellow-400 focus:ring-yellow-300 dark:focus:ring-yellow-400', 'gray' => 'text-gray-600 focus:ring-gray-500 dark:focus:ring-gray-600', default => 'text-blue-600 focus:ring-blue-500 dark:focus:ring-blue-600', }; @endphp
@php $classes = cn( $iconSize, $colorClassMap, 'bg-gray-100 border-gray-300 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600', ); @endphp