This commit is contained in:
Zep Fietje
2023-07-13 18:20:31 +02:00
parent a525f1c03b
commit ab92db3911
6 changed files with 18 additions and 21 deletions
+1 -1
View File
@@ -1 +1 @@
function t(){return{init:function(){this.$nextTick(()=>{this.render()})},render:function(){this.$el.scrollHeight>0&&(this.$el.style.height="150px",this.$el.style.height=this.$el.scrollHeight+2+"px")}}}export{t as default};
function t({initialHeight:e}){return{render:function(){this.$el.scrollHeight>0&&(this.$el.style.height=e+"rem",this.$el.style.height=this.$el.scrollHeight+"px")}}}export{t as default};
@@ -1,15 +1,9 @@
export default function textareaFormComponent() {
export default function textareaFormComponent({ initialHeight }) {
return {
init: function () {
this.$nextTick(() => {
this.render()
})
},
render: function () {
if (this.$el.scrollHeight > 0) {
this.$el.style.height = '150px'
this.$el.style.height = this.$el.scrollHeight + 2 + 'px'
this.$el.style.height = initialHeight + 'rem'
this.$el.style.height = this.$el.scrollHeight + 'px'
}
},
}
@@ -1,17 +1,20 @@
@php
$isConcealed = $isConcealed();
$rows = $getRows();
$statePath = $getStatePath();
$initialHeight = (($rows ?? 2) * 1.5) + 0.75;
@endphp
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<textarea
@if ($shouldAutosize())
x-ignore
ax-load
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('textarea', 'filament/forms') }}"
x-data="textareaFormComponent()"
x-data="textareaFormComponent({ initialHeight: @js($initialHeight) })"
x-ignore
x-on:input="render()"
style="height: 150px"
style="height: {{ $initialHeight }}rem"
{{ $getExtraAlpineAttributeBag() }}
@endif
{{
@@ -27,15 +30,15 @@
'placeholder' => $getPlaceholder(),
'readonly' => $isReadOnly(),
'required' => $isRequired() && (! $isConcealed),
'rows' => $getRows(),
'rows' => $rows,
$applyStateBindingModifiers('wire:model') => $statePath,
], escape: false)
->merge($getExtraAttributes(), escape: false)
->merge($getExtraInputAttributes(), escape: false)
->class([
'fi-fo-textarea block w-full rounded-lg shadow-sm outline-none transition duration-75 placeholder:text-gray-500 focus:ring-1 focus:ring-inset disabled:opacity-70 dark:bg-gray-700 dark:text-white sm:text-sm',
'border-gray-300 focus:border-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:focus:border-primary-500' => ! $errors->has($statePath),
'border-danger-600 ring-danger-600 dark:border-danger-400 dark:ring-danger-400' => $errors->has($statePath),
'fi-fo-textarea block w-full rounded-lg border-none bg-white px-3 py-1.5 text-base text-gray-950 shadow-sm outline-none ring-1 transition duration-75 placeholder:text-gray-400 focus:ring-2 disabled:bg-gray-50 disabled:text-gray-500 disabled:[-webkit-text-fill-color:theme(colors.gray.500)] disabled:placeholder:[-webkit-text-fill-color:theme(colors.gray.400)] dark:bg-gray-900 dark:text-white dark:placeholder:text-gray-500 dark:disabled:bg-gray-950 dark:disabled:text-gray-400 dark:disabled:[-webkit-text-fill-color:theme(colors.gray.400)] dark:disabled:placeholder:[-webkit-text-fill-color:theme(colors.gray.500)] sm:text-sm sm:leading-6',
'ring-gray-950/10 focus:ring-primary-600 dark:ring-white/20 dark:focus:ring-primary-600' => ! $errors->has($statePath),
'ring-danger-600 focus:ring-danger-600 dark:ring-danger-400 dark:focus:ring-danger-400' => $errors->has($statePath),
])
}}
></textarea>
+1 -1
View File
@@ -58,6 +58,6 @@ class Textarea extends Field implements Contracts\CanBeLengthConstrained
public function shouldAutosize(): bool
{
return $this->rows === null || ((bool) $this->evaluate($this->shouldAutosize));
return (bool) $this->evaluate($this->shouldAutosize);
}
}
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
@php
$chartColor = $getChartColor();
$descriptionColor = $getDescriptionColor();
$chartColor = $getChartColor() ?? 'gray';
$descriptionColor = $getDescriptionColor() ?? 'gray';
$descriptionIcon = $getDescriptionIcon();
$descriptionIconPosition = $getDescriptionIconPosition();
$url = $getUrl();