-
Notifications
You must be signed in to change notification settings - Fork 554
/
Input.php
60 lines (56 loc) · 1.75 KB
/
Input.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace A17\Twill\View\Components\Fields;
use Illuminate\Contracts\View\View;
class Input extends TwillFormComponent
{
public function __construct(
string $name,
string $label,
bool $renderForBlocks = false,
bool $renderForModal = false,
bool $translated = false,
bool $required = false,
?string $note = '',
mixed $default = null,
bool $disabled = false,
bool $readOnly = false,
bool $inModal = false,
// Component specific
public string $type = 'text',
public ?string $placeholder = '',
public ?string $direction = 'auto',
public ?int $maxlength = null,
public ?int $rows = null,
public ?string $ref = null,
public ?string $onChange = null,
public ?string $onChangeAttribute = null,
public ?string $prefix = null,
public null|int|float $min = null,
public null|int|float $max = null,
public null|int|float $step = null,
public ?string $mask = null,
) {
parent::__construct(
name: $name,
label: $label,
note: $note,
inModal: $inModal,
readOnly: $readOnly,
renderForBlocks: $renderForBlocks,
renderForModal: $renderForModal,
disabled: $disabled,
required: $required,
translated: $translated,
default: $default
);
}
public function render(): View
{
return view(
'twill::partials.form._input',
array_merge($this->data(), [
'onChangeFullAttribute' => $this->onChangeAttribute ? "('" . $this->onChangeAttribute . "', ...arguments)" : "",
])
);
}
}