1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace JeroenNoten\LaravelAdminLte\Components; |
4
|
|
|
|
5
|
|
|
use Illuminate\View\Component; |
6
|
|
|
|
7
|
|
|
class InputGroupComponent extends Component |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* The name and id attribute for the input group item. The input group item |
11
|
|
|
* may be an "input", a "select", a "textarea", etc. |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
public $name; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The label of the input group. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
public $label; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The input group size (you can specify 'sm' or 'lg'). |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
public $size; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Extra classes for the label container. This provides a way to customize |
33
|
|
|
* the label style. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
public $labelClass; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Extra classes for the "form-group" element. This provides a way to |
41
|
|
|
* customize the main container style. |
42
|
|
|
* |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
public $topClass; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Indicates if the invalid feedback is disabled for the input group. |
49
|
|
|
* |
50
|
|
|
* @var bool |
51
|
|
|
*/ |
52
|
|
|
public $disableFeedback; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Create a new component instance. |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
8 |
|
public function __construct( |
60
|
|
|
$name, $label = null, $size = null, |
61
|
|
|
$labelClass = null, $topClass = null, $disableFeedback = null |
62
|
|
|
) { |
63
|
8 |
|
$this->name = $name; |
64
|
8 |
|
$this->label = $label; |
65
|
8 |
|
$this->size = $size; |
66
|
8 |
|
$this->topClass = $topClass; |
67
|
8 |
|
$this->labelClass = $labelClass; |
68
|
8 |
|
$this->disableFeedback = $disableFeedback; |
69
|
8 |
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Make the class attribute for the "input-group" element. |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
1 |
|
public function makeInputGroupClass() |
77
|
|
|
{ |
78
|
1 |
|
$classes = ['input-group']; |
79
|
|
|
|
80
|
1 |
|
if (isset($this->size) && in_array($this->size, ['sm', 'lg'])) { |
81
|
1 |
|
$classes[] = "input-group-{$this->size}"; |
82
|
|
|
} |
83
|
|
|
|
84
|
1 |
|
return implode(' ', $classes); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Make the class attribute for the "form-group" element. |
89
|
|
|
* |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
1 |
|
public function makeFormGroupClass() |
93
|
|
|
{ |
94
|
1 |
|
$classes = ['form-group']; |
95
|
|
|
|
96
|
1 |
|
if (isset($this->topClass)) { |
97
|
1 |
|
$classes[] = $this->topClass; |
98
|
|
|
} |
99
|
|
|
|
100
|
1 |
|
return implode(' ', $classes); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Make the class attribute for the input group item. |
105
|
|
|
* |
106
|
|
|
* @param string $invalid |
107
|
|
|
* @return string |
108
|
|
|
*/ |
109
|
1 |
|
public function makeItemClass($invalid) |
110
|
|
|
{ |
111
|
1 |
|
$classes = ['form-control']; |
112
|
|
|
|
113
|
1 |
|
if (! empty($invalid) && ! isset($this->disableFeedback)) { |
114
|
1 |
|
$classes[] = 'is-invalid'; |
115
|
|
|
} |
116
|
|
|
|
117
|
1 |
|
return implode(' ', $classes); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get the view / contents that represent the component. |
122
|
|
|
* |
123
|
|
|
* @return \Illuminate\View\View|string |
124
|
|
|
*/ |
125
|
1 |
|
public function render() |
126
|
|
|
{ |
127
|
1 |
|
return view('adminlte::components.input-group-component'); |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|