Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
174 lines
5.5 KiB
PHP
174 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace Filament\Forms\Components;
|
|
|
|
use Closure;
|
|
use Filament\Forms\Components\Concerns\CanDisableGrammarly;
|
|
use Filament\Schemas\Components\Concerns\CanStripCharactersFromState;
|
|
use Filament\Schemas\Components\Concerns\CanTrimState;
|
|
use Filament\Schemas\Components\StateCasts\StripCharactersStateCast;
|
|
use Filament\Support\Components\Contracts\HasEmbeddedView;
|
|
use Filament\Support\Concerns\HasExtraAlpineAttributes;
|
|
use Filament\Support\Facades\FilamentAsset;
|
|
use Illuminate\Support\Js;
|
|
|
|
class Textarea extends Field implements Contracts\CanBeLengthConstrained, HasEmbeddedView
|
|
{
|
|
use CanDisableGrammarly;
|
|
use CanStripCharactersFromState;
|
|
use CanTrimState;
|
|
use Concerns\CanBeAutocompleted;
|
|
use Concerns\CanBeLengthConstrained;
|
|
use Concerns\CanBeReadOnly;
|
|
use Concerns\HasExtraInputAttributes;
|
|
use Concerns\HasPlaceholder;
|
|
use HasExtraAlpineAttributes;
|
|
|
|
protected ?string $publishedViewOverrideCheckPath = 'filament-forms::components.textarea';
|
|
|
|
protected int | Closure | null $cols = null;
|
|
|
|
protected int | Closure | null $rows = null;
|
|
|
|
protected bool | Closure $shouldAutosize = false;
|
|
|
|
public function autosize(bool | Closure $condition = true): static
|
|
{
|
|
$this->shouldAutosize = $condition;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function cols(int | Closure | null $cols): static
|
|
{
|
|
$this->cols = $cols;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function rows(int | Closure | null $rows): static
|
|
{
|
|
$this->rows = $rows;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCols(): ?int
|
|
{
|
|
return $this->evaluate($this->cols);
|
|
}
|
|
|
|
public function getRows(): ?int
|
|
{
|
|
return $this->evaluate($this->rows);
|
|
}
|
|
|
|
public function shouldAutosize(): bool
|
|
{
|
|
return (bool) $this->evaluate($this->shouldAutosize);
|
|
}
|
|
|
|
public function toEmbeddedHtml(): string
|
|
{
|
|
$isDisabled = $this->isDisabled();
|
|
$rows = $this->getRows();
|
|
$placeholder = $this->getPlaceholder();
|
|
$shouldAutosize = $this->shouldAutosize();
|
|
$statePath = $this->getStatePath();
|
|
|
|
$initialHeight = (($rows ?? 2) * 1.5) + 0.75;
|
|
|
|
$wrapperAttributes = $this->getExtraAttributeBag()
|
|
->class([
|
|
'fi-fo-textarea',
|
|
'fi-autosizable' => $shouldAutosize,
|
|
]);
|
|
|
|
$textareaAttributes = $this->getExtraInputAttributeBag()
|
|
->merge([
|
|
'autocomplete' => $this->getAutocomplete(),
|
|
'autofocus' => $this->isAutofocused(),
|
|
'cols' => $this->getCols(),
|
|
'disabled' => $isDisabled,
|
|
'id' => $this->getId(),
|
|
'maxlength' => $this->getMaxLength(),
|
|
'minlength' => $this->getMinLength(),
|
|
'placeholder' => filled($placeholder) ? e($placeholder) : null,
|
|
'readonly' => $this->isReadOnly(),
|
|
'required' => $this->isRequired(),
|
|
'rows' => $rows,
|
|
$this->applyStateBindingModifiers('wire:model') => $statePath,
|
|
], escape: false);
|
|
|
|
$alpineAttributes = $this->getExtraAlpineAttributeBag();
|
|
|
|
ob_start(); ?>
|
|
|
|
<div wire:ignore.self style="height: <?= e($initialHeight) ?>rem">
|
|
<textarea
|
|
x-load
|
|
x-load-src="<?= e(FilamentAsset::getAlpineComponentSrc('textarea', 'filament/forms')) ?>"
|
|
x-data="textareaFormComponent({
|
|
initialHeight: <?= Js::from($initialHeight) ?>,
|
|
shouldAutosize: <?= Js::from($shouldAutosize) ?>,
|
|
state: $wire.$entangle('<?= e($statePath) ?>'),
|
|
})"
|
|
<?php if ($shouldAutosize) { ?>
|
|
x-intersect.once="resize()"
|
|
x-on:resize.window="resize()"
|
|
<?php } ?>
|
|
x-model="state"
|
|
<?php if ($this->isGrammarlyDisabled()) { ?>
|
|
data-gramm="false"
|
|
data-gramm_editor="false"
|
|
data-enable-grammarly="false"
|
|
<?php } ?>
|
|
<?= $alpineAttributes->toHtml() ?>
|
|
<?= $textareaAttributes->toHtml() ?>
|
|
></textarea>
|
|
</div>
|
|
|
|
<?php $slotHtml = ob_get_clean();
|
|
|
|
return $this->wrapEmbeddedHtml(
|
|
$this->wrapInputHtml(
|
|
$slotHtml,
|
|
attributes: $wrapperAttributes,
|
|
),
|
|
extraWrapperAttributes: ['class' => 'fi-fo-textarea-wrp'],
|
|
);
|
|
}
|
|
|
|
public function getDefaultStateCasts(): array
|
|
{
|
|
return [
|
|
...parent::getDefaultStateCasts(),
|
|
...($this->hasStripCharacters() ? [app(StripCharactersStateCast::class, ['characters' => $this->getStripCharacters()])] : []),
|
|
];
|
|
}
|
|
|
|
public function mutateDehydratedState(mixed $state): mixed
|
|
{
|
|
$state = $this->trimState($state);
|
|
|
|
return parent::mutateDehydratedState($state);
|
|
}
|
|
|
|
public function mutateStateForValidation(mixed $state): mixed
|
|
{
|
|
$state = $this->stripCharactersFromState($state);
|
|
$state = $this->trimState($state);
|
|
|
|
return parent::mutateStateForValidation($state);
|
|
}
|
|
|
|
public function mutatesDehydratedState(): bool
|
|
{
|
|
return parent::mutatesDehydratedState() || $this->isTrimmed();
|
|
}
|
|
|
|
public function mutatesStateForValidation(): bool
|
|
{
|
|
return parent::mutatesStateForValidation() || $this->hasStripCharacters() || $this->isTrimmed();
|
|
}
|
|
}
|