|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Xetaravel\View\Components; |
|
6
|
|
|
|
|
7
|
|
|
use Closure; |
|
8
|
|
|
use Illuminate\Contracts\View\View; |
|
9
|
|
|
use Illuminate\View\Component; |
|
10
|
|
|
|
|
11
|
|
|
class ColorPicker extends Component |
|
12
|
|
|
{ |
|
13
|
|
|
public string $uuid; |
|
14
|
|
|
|
|
15
|
|
|
public function __construct( |
|
16
|
|
|
public ?string $id = null, |
|
17
|
|
|
public ?string $label = null, |
|
18
|
|
|
public ?string $icon = '', |
|
19
|
|
|
public ?string $iconRight = null, |
|
20
|
|
|
public ?string $hint = null, |
|
21
|
|
|
public ?string $hintClass = 'fieldset-label', |
|
22
|
|
|
public ?string $prefix = null, |
|
23
|
|
|
public ?string $suffix = null, |
|
24
|
|
|
public ?bool $inline = false, |
|
25
|
|
|
public ?bool $clearable = false, |
|
26
|
|
|
|
|
27
|
|
|
// Validations |
|
28
|
|
|
public ?string $errorField = null, |
|
29
|
|
|
public ?string $errorClass = 'text-error', |
|
30
|
|
|
public ?bool $omitError = false, |
|
31
|
|
|
public ?bool $firstErrorOnly = false, |
|
32
|
|
|
) { |
|
33
|
|
|
$this->uuid = md5(serialize($this)) . $id; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function modelName(): ?string |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->attributes->whereStartsWith('wire:model')->first(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function errorFieldName(): ?string |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->errorField ?? $this->modelName(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function isReadonly(): bool |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->attributes->has('readonly') && $this->attributes->get('readonly') === true; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function isDisabled(): bool |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->attributes->has('disabled') && $this->attributes->get('disabled') === true; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get the view / contents that represent the component. |
|
58
|
|
|
*/ |
|
59
|
|
|
public function render(): View|Closure|string |
|
60
|
|
|
{ |
|
61
|
|
|
return view('components.color-picker'); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|