1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EasyPanel\Parsers\HTMLInputs; |
4
|
|
|
|
5
|
|
|
abstract class BaseInput |
6
|
|
|
{ |
7
|
|
|
protected $key; |
8
|
|
|
protected $action; |
9
|
|
|
protected $mode; |
10
|
|
|
protected $label; |
11
|
|
|
protected $placeholder; |
12
|
|
|
protected $inputStyle; |
13
|
|
|
protected $autocomplete = 'on'; |
14
|
|
|
|
15
|
|
|
public function __construct($label) |
16
|
|
|
{ |
17
|
|
|
$this->label = $label; |
18
|
|
|
$this->mode = config('easy_panel.lazy_mode') ? 'wire:model.lazy' : 'wire:model'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public static function label($label) |
22
|
|
|
{ |
23
|
|
|
return new static($label); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function inputStyle($inputStyle) |
27
|
|
|
{ |
28
|
|
|
$this->inputStyle = $inputStyle; |
29
|
|
|
|
30
|
|
|
return $this; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function setKey($key) |
34
|
|
|
{ |
35
|
|
|
$this->key = $key; |
36
|
|
|
|
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setAction($action) |
41
|
|
|
{ |
42
|
|
|
$this->action = $action; |
43
|
|
|
|
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function placeholder($placeholder) |
48
|
|
|
{ |
49
|
|
|
$this->placeholder = $placeholder; |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function lazyMode() |
55
|
|
|
{ |
56
|
|
|
$this->mode = 'wire:model.lazy'; |
57
|
|
|
|
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function normalMode() |
62
|
|
|
{ |
63
|
|
|
$this->mode = 'wire:model'; |
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function deferMode() |
69
|
|
|
{ |
70
|
|
|
$this->mode = 'wire:model.defer'; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function withoutAutocomplete() |
76
|
|
|
{ |
77
|
|
|
$this->autocomplete = 'off'; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function withoutAutofill() |
83
|
|
|
{ |
84
|
|
|
$this->withoutAutocomplete(); |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function render() |
90
|
|
|
{ |
91
|
|
|
$array = [ |
92
|
|
|
'{{ Title }}' => $this->label, |
93
|
|
|
'{{ Name }}' => $this->key, |
94
|
|
|
'{{ Mode }}' => $this->mode, |
95
|
|
|
'{{ Action }}' => $this->action, |
96
|
|
|
'{{ placeholder }}' => $this->placeholder, |
97
|
|
|
'{{ inputStyle }}' => $this->inputStyle, |
98
|
|
|
'{{ autocomplete }}' => $this->autocomplete, |
99
|
|
|
]; |
100
|
|
|
|
101
|
|
|
return str_replace(array_keys($array), array_values($array), file_get_contents(__DIR__.'/stubs/'.$this->stub)); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getTitle() |
105
|
|
|
{ |
106
|
|
|
return $this->label; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getPlaceholder() |
110
|
|
|
{ |
111
|
|
|
return $this->placeholder; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
} |
115
|
|
|
|