2024-12-22 18:34:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\View\Form;
|
|
|
|
|
|
|
|
use App\View\Traits\HasFormDimensions;
|
|
|
|
use Illuminate\View\Component;
|
|
|
|
|
|
|
|
class Editor extends Component
|
|
|
|
{
|
|
|
|
|
|
|
|
use HasFormDimensions;
|
|
|
|
|
|
|
|
public string $id;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
public string $name,
|
|
|
|
public string $size = 'default',
|
|
|
|
public ?string $hint = null,
|
|
|
|
public bool $required = false,
|
|
|
|
public string $label = '',
|
|
|
|
) {
|
|
|
|
$this->id = str()->uuid()->toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return <<<'HTML'
|
2024-12-22 19:26:59 +01:00
|
|
|
<div class="flex flex-col group {{$heightClass}}">
|
2024-12-22 18:34:00 +01:00
|
|
|
@if ($label)
|
|
|
|
<x-form::label :required="$required">{{$label}}</x-form::label>
|
|
|
|
@endif
|
|
|
|
|
|
|
|
<div class="relative w-full h-full">
|
|
|
|
<div class="
|
|
|
|
w-full border-gray-600 border-solid text-gray-300 bg-gray-700 leading-none rounded-lg
|
|
|
|
group-[.size-default]:border-2 group-[.size-sm]:border
|
|
|
|
group-[.size-default]:text-sm group-[.size-sm]:text-xs
|
|
|
|
group-[.size-default]:p-2 group-[.size-sm]:p-1
|
|
|
|
" @updated="$wire.{{$attributes->wire('model')->value}} = $event.detail" x-bind="editor"x-data="{
|
2024-12-22 19:26:59 +01:00
|
|
|
value: $wire.{{$attributes->wire('model')->value}},
|
2024-12-22 18:34:00 +01:00
|
|
|
}" id="{{$id}}" {{$attributes}}></div>
|
|
|
|
<x-ui::errors :for="$name" />
|
|
|
|
@if($hint)
|
|
|
|
<x-form::hint>{{$hint}}</x-form::hint>
|
|
|
|
@endif
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
HTML;
|
|
|
|
}
|
|
|
|
}
|