File tree Expand file tree Collapse file tree 4 files changed +76
-1
lines changed
Expand file tree Collapse file tree 4 files changed +76
-1
lines changed Original file line number Diff line number Diff line change 1+ @props ([
2+ ' label' => ' ' ,
3+ ' help' => ' ' ,
4+ ' hr' => ' '
5+ ] )
6+
7+ @php
8+ $required = $attributes [' required' ] ?? null ;
9+ if ($label ) {
10+ $label .= ($required ? ' <i class="text-error">*</i>' : ' ' );
11+ }
12+ $model = $attributes -> wire (' model' );
13+ $parameter = $model -> value ();
14+ $class = [];
15+ @endphp
16+
17+
18+ <div class =" {{ $label ? ' form-control' : ' inline-block' } }" >
19+ <label class =" label cursor-pointer{{ $hr ? ' flex flex-col items-start' : ' ' } }" >
20+ <span class =" label-text{{ $hr ? ' mb-1' : ' ' } }" >{!! $label ! !} </span >
21+ <x-lazy-select :attributes =" $attributes" >
22+ {{ $slot } }
23+ </x-lazy-select >
24+ </label >
25+ @if ($help )
26+ <div class =" tooltip w-6" data-tip =" {{ $help } }" >
27+ <svg xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24"
28+ class =" stroke-info h-6 w-6 flex-shrink-0" >
29+ <path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2"
30+ d =" M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" ></path >
31+ </svg >
32+ </div >
33+ @endif
34+ @if ($parameter )
35+ @error ($parameter )
36+ <div class =" alert alert-error mt-1 mb-2 shadow-lg" >
37+ <div >
38+ <svg xmlns =" http://www.w3.org/2000/svg" class =" h-6 w-6 flex-shrink-0 stroke-current" fill =" none"
39+ viewBox =" 0 0 24 24" >
40+ <path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2"
41+ d =" M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" ></path >
42+ </svg >
43+ {{ $message } }
44+ </div >
45+ </div >
46+ @enderror
47+ @endif
48+ </div >
Original file line number Diff line number Diff line change 22 ' hasError' => false ,
33 ' value' => ' '
44] )
5- <textarea {{ $attributes -> merge ([' class' => ' textarea ' . ($hasError ? ' textarea-error' : ' ' )]) } } >{{ $value ?: $slot } } </textarea >
5+ <textarea {{ $attributes -> merge ([' class' => ' w-full ' . ($hasError ? ' textarea-error' : ' ' )]) } } >{{ $value ?: $slot } } </textarea >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Step2dev \LazyUI \Components \Form ;
4+
5+ use Illuminate \Contracts \View \View ;
6+ use Step2dev \LazyUI \LazyComponent ;
7+
8+ class FormSelect extends LazyComponent
9+ {
10+ public ?string $ placeholder ;
11+
12+ public function __construct (public string $ label = '' , string $ placeholder = '' , public bool $ required = false )
13+ {
14+ $ this ->placeholder = (string ) str ($ placeholder ?: $ this ->label )->trim ()->ucfirst ();
15+ }
16+
17+ public function render (): \Closure |View
18+ {
19+ return function (array $ data ) {
20+ $ data ['attributes ' ]['required ' ] = $ this ->required ;
21+
22+ return view ('lazy::form.select ' , $ this ->mergeData ($ data ))->render ();
23+ };
24+ }
25+ }
Original file line number Diff line number Diff line change 2828use Step2dev \LazyUI \Components \Form \FormImage ;
2929use Step2dev \LazyUI \Components \Form \FormInput ;
3030use Step2dev \LazyUI \Components \Form \FormRichtext ;
31+ use Step2dev \LazyUI \Components \Form \FormSelect ;
3132use Step2dev \LazyUI \Components \Form \FormTextarea ;
3233use Step2dev \LazyUI \Components \Form \FormToggle ;
3334use Step2dev \LazyUI \Components \FormGroup ;
@@ -97,6 +98,7 @@ public function configurePackage(Package $package): void
9798 FormImage::class,
9899 FormInput::class,
99100 FormRichtext::class,
101+ FormSelect::class,
100102 FormTextarea::class,
101103 FormToggle::class,
102104 Image::class,
You can’t perform that action at this time.
0 commit comments