tests / feature (8.4) (push) Successful in 1m5s
tests / feature (8.5) (push) Successful in 1m4s
tests / lint (push) Successful in 59s
tests / browser (chrome, chromium) (push) Successful in 2m54s
tests / browser (firefox, firefox) (push) Successful in 3m3s
tests / browser (safari, webkit) (push) Successful in 4m13s
Outlined and filled text fields (input, password, auto-growing textarea, native select with the customizable select menu, file), checkbox with an indeterminate state, radio buttons, the M3 switch and form, ported from ReStride and extended. The first half of Phase 6. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
40 lines
1.7 KiB
PHP
40 lines
1.7 KiB
PHP
{{-- A multi-line field: the text field, grown to its content.
|
|
|
|
It starts at `rows` lines (3) and grows with what is typed up to `max-rows`, then scrolls;
|
|
`:autogrow="false"` keeps it at `rows` and lets it be resized by hand, vertically only, so a
|
|
form's column never moves. The label rests on the first line rather than in the middle of the
|
|
box. `label`, `hint`, `variant`; every other attribute reaches the `<textarea>`. --}}
|
|
|
|
@props([
|
|
'label' => null,
|
|
'hint' => null,
|
|
'hintClass' => null,
|
|
'variant' => null,
|
|
'rows' => 3,
|
|
'maxRows' => null,
|
|
'autogrow' => true,
|
|
])
|
|
|
|
@php
|
|
$model = $attributes->whereStartsWith('wire:model')->first();
|
|
$placeholder = filled($attributes->get('placeholder')) ? $attributes->get('placeholder') : ' ';
|
|
$id = $attributes->get('id') ?? 'field-'.substr(md5($model.'|'.$label.'|textarea'), 0, 12);
|
|
$messages = $model !== null && isset($errors) ? \Illuminate\Support\Arr::flatten($errors->get($model)) : [];
|
|
@endphp
|
|
|
|
<x-field :$id :$label :$hint :hint-class="$hintClass" :$messages :$variant :class="$attributes->get('class')" :data-readonly="$attributes->get('readonly') ? '' : null">
|
|
<textarea
|
|
{{ $attributes->except(['class', 'id', 'placeholder']) }}
|
|
id="{{ $id }}"
|
|
rows="{{ (int) $rows }}"
|
|
placeholder="{{ $placeholder }}"
|
|
@if ($autogrow)
|
|
data-autogrow
|
|
style="--field-rows: {{ (int) $rows }};@if ($maxRows) --field-max-rows: {{ (int) $maxRows }};@endif"
|
|
@endif
|
|
@if ($messages !== []) aria-invalid="true" @endif
|
|
@if ($messages !== [] || filled($hint)) aria-describedby="{{ $id }}-support" @endif
|
|
class="field-control"
|
|
></textarea>
|
|
</x-field>
|