- Changed component styles and classes to align with TailAdmin design patterns. - Updated color schemes, typography, and layout for consistency across components. - Refactored Info Row, Network Address Card, Notice Banner, Progress Bar, Resource Gauge, Section Header, Server Status, Spinner, Stat Card, and Tab Panel components. - Enhanced responsiveness and accessibility features in various components.
147 lines
7.0 KiB
PHP
147 lines
7.0 KiB
PHP
{{--
|
|
Editable Field Component - TailAdmin style
|
|
A field with display value and edit button that opens a modal
|
|
|
|
Usage:
|
|
<x-proxmox::ui.editable-field
|
|
label="Hostname"
|
|
:value="$server->hostname"
|
|
:editing="$isEditingHostname"
|
|
wire:model="hostname"
|
|
edit-click="startEditingHostname"
|
|
cancel-click="cancelEditingHostname"
|
|
save-click="updateHostname"
|
|
>
|
|
<x-slot:hint>
|
|
Additional information about the field...
|
|
</x-slot:hint>
|
|
</x-proxmox::ui.editable-field>
|
|
--}}
|
|
|
|
@props([
|
|
'label',
|
|
'value',
|
|
'placeholder' => null,
|
|
'editing' => false,
|
|
'editClick' => null,
|
|
'cancelClick' => null,
|
|
'saveClick' => null,
|
|
'applyClick' => null,
|
|
'applyLabel' => 'Save & Apply',
|
|
'error' => null,
|
|
])
|
|
|
|
<div class="space-y-2" x-data="{ showEditModal: @entangle($attributes->wire('model')->value() ? 'isEditing' . ucfirst($label) : 'editing') }">
|
|
<label class="text-theme-sm font-medium text-gray-700 dark:text-gray-300">{{ $label }}</label>
|
|
<div class="flex items-center gap-2.5 rounded-lg border border-gray-200 bg-gray-50 px-4 py-2.5 text-theme-sm dark:border-gray-700 dark:bg-gray-800">
|
|
<span class="flex-1 truncate text-gray-700 dark:text-gray-300">{{ $value ?? 'Not set' }}</span>
|
|
@if($editClick)
|
|
<button
|
|
wire:click="{{ $editClick }}"
|
|
type="button"
|
|
class="text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300"
|
|
aria-label="Edit {{ $label }}"
|
|
>
|
|
<x-ri-edit-line class="size-4" />
|
|
</button>
|
|
@endif
|
|
</div>
|
|
|
|
@if($editing !== false)
|
|
<!-- Edit Modal Backdrop -->
|
|
<div
|
|
x-cloak
|
|
x-show="showEditModal"
|
|
x-transition:enter="transition ease-out duration-200"
|
|
x-transition:enter-start="opacity-0"
|
|
x-transition:enter-end="opacity-100"
|
|
x-transition:leave="transition ease-in duration-150"
|
|
x-transition:leave-start="opacity-100"
|
|
x-transition:leave-end="opacity-0"
|
|
@click="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
|
|
@keydown.escape.window="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
|
|
class="fixed inset-0 z-99999 bg-gray-900/50 backdrop-blur-sm dark:bg-gray-900/80"
|
|
style="display: none;"
|
|
></div>
|
|
|
|
<!-- Edit Modal -->
|
|
<div
|
|
x-cloak
|
|
x-show="showEditModal"
|
|
x-transition:enter="transition ease-out duration-200"
|
|
x-transition:enter-start="opacity-0 scale-95"
|
|
x-transition:enter-end="opacity-100 scale-100"
|
|
x-transition:leave="transition ease-in duration-150"
|
|
x-transition:leave-start="opacity-100 scale-100"
|
|
x-transition:leave-end="opacity-0 scale-95"
|
|
@click.away="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
|
|
class="fixed inset-0 z-99999 flex items-center justify-center p-4"
|
|
style="display: none;"
|
|
>
|
|
<div class="relative w-full max-w-xl space-y-5 rounded-2xl border border-gray-200 bg-white p-6 shadow-theme-lg dark:border-gray-800 dark:bg-gray-900">
|
|
<div class="flex items-center justify-between">
|
|
<h4 class="text-lg font-semibold text-gray-800 dark:text-white/90">Edit {{ $label }}</h4>
|
|
<button
|
|
type="button"
|
|
class="flex size-9 items-center justify-center rounded-lg text-gray-500 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-300"
|
|
@click="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
|
|
aria-label="Close"
|
|
>
|
|
<x-ri-close-line class="size-5" />
|
|
</button>
|
|
</div>
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<label class="text-theme-sm font-medium text-gray-500 dark:text-gray-400">{{ $label }}</label>
|
|
<input
|
|
type="text"
|
|
{{ $attributes->whereStartsWith('wire:model') }}
|
|
class="mt-2 h-11 w-full rounded-lg border border-gray-300 bg-transparent px-4 text-theme-sm shadow-theme-xs placeholder:text-gray-400 focus:border-brand-300 focus:outline-none focus:ring-3 focus:ring-brand-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:placeholder:text-gray-500 dark:focus:border-brand-600"
|
|
placeholder="{{ $placeholder ?? 'Enter ' . strtolower($label) }}"
|
|
/>
|
|
</div>
|
|
|
|
@if($error)
|
|
<div class="text-theme-sm text-error-500">{{ $error }}</div>
|
|
@endif
|
|
|
|
@if(isset($hint))
|
|
<div class="text-theme-xs text-gray-500 dark:text-gray-400">{{ $hint }}</div>
|
|
@endif
|
|
</div>
|
|
|
|
<div class="flex justify-end gap-3 border-t border-gray-200 pt-4 dark:border-gray-800">
|
|
@if($cancelClick)
|
|
<button
|
|
type="button"
|
|
@click="showEditModal = false; $wire.{{ $cancelClick }}()"
|
|
class="rounded-lg bg-white px-4 py-2.5 text-theme-sm font-medium text-gray-700 shadow-theme-xs ring-1 ring-gray-300 transition-colors duration-150 hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:ring-gray-700 dark:hover:bg-gray-700"
|
|
>
|
|
Cancel
|
|
</button>
|
|
@endif
|
|
@if($saveClick)
|
|
<button
|
|
type="button"
|
|
wire:click="{{ $saveClick }}"
|
|
class="rounded-lg bg-brand-500 px-4 py-2.5 text-theme-sm font-medium text-white shadow-theme-xs transition-colors duration-150 hover:bg-brand-600"
|
|
>
|
|
Save
|
|
</button>
|
|
@endif
|
|
@if($applyClick)
|
|
<button
|
|
type="button"
|
|
wire:click="{{ $applyClick }}"
|
|
class="rounded-lg bg-brand-500 px-4 py-2.5 text-theme-sm font-medium text-white shadow-theme-xs transition-colors duration-150 hover:bg-brand-600"
|
|
>
|
|
{{ $applyLabel }}
|
|
</button>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
</div>
|