@php
use Filament\Support\Enums\Alignment;
use Filament\Support\Enums\Width;
use Filament\Support\Facades\FilamentView;
use Filament\Support\View\Components\ModalComponent\IconComponent;
use Illuminate\View\ComponentAttributeBag;
@endphp
@props([
'alignment' => Alignment::Start,
'ariaLabelledby' => null,
'autofocus' => \Filament\Support\View\Components\ModalComponent::$isAutofocused,
'closeButton' => \Filament\Support\View\Components\ModalComponent::$hasCloseButton,
'closeByClickingAway' => \Filament\Support\View\Components\ModalComponent::$isClosedByClickingAway,
'closeByEscaping' => \Filament\Support\View\Components\ModalComponent::$isClosedByEscaping,
'closeEventName' => 'close-modal',
'closeQuietlyEventName' => 'close-modal-quietly',
'description' => null,
'extraModalWindowAttributeBag' => null,
'footer' => null,
'footerActions' => [],
'footerActionsAlignment' => Alignment::Start,
'header' => null,
'heading' => null,
'icon' => null,
'iconAlias' => null,
'iconColor' => 'primary',
'id' => null,
'openEventName' => 'open-modal',
'slideOver' => false,
'stickyFooter' => false,
'stickyHeader' => false,
'trigger' => null,
'visible' => true,
'width' => 'sm',
])
@php
$hasContent = ! \Filament\Support\is_slot_empty($slot);
$hasDescription = filled($description);
$hasFooter = (! \Filament\Support\is_slot_empty($footer)) || (is_array($footerActions) && count($footerActions)) || (! is_array($footerActions) && (! \Filament\Support\is_slot_empty($footerActions)));
$hasHeading = filled($heading);
$hasIcon = filled($icon);
if (! $alignment instanceof Alignment) {
$alignment = filled($alignment) ? (Alignment::tryFrom($alignment) ?? $alignment) : null;
}
if (! $footerActionsAlignment instanceof Alignment) {
$footerActionsAlignment = filled($footerActionsAlignment) ? (Alignment::tryFrom($footerActionsAlignment) ?? $footerActionsAlignment) : null;
}
if (is_string($width)) {
$width = Width::tryFrom($width) ?? $width;
}
$closeEventHandler = filled($id) ? '$dispatch(' . \Illuminate\Support\Js::from($closeEventName) . ', { id: ' . \Illuminate\Support\Js::from($id) . ' })' : 'close()';
$wireSubmitHandler = $attributes->get('wire:submit.prevent');
$attributes = $attributes->except(['wire:submit.prevent']);
@endphp
@if ($trigger)
{!! '
' !!}
{{-- Avoid formatting issues with unclosed elements --}}
attributes->get('disabled'))
x-on:click="$el.nextElementSibling.dispatchEvent(new CustomEvent(@js($openEventName)))"
@endif
{{ $trigger->attributes->except(['disabled'])->class(['fi-modal-trigger']) }}
>
{{ $trigger }}
@endif
class([
'fi-modal fi-absolute-positioning-context',
'fi-modal-slide-over' => $slideOver,
'fi-width-screen' => $width === Width::Screen,
])
}}
>
$closeByClickingAway,
])
>
<{{ filled($wireSubmitHandler) ? 'form' : 'div' }}
@if ($closeByEscaping)
x-on:keydown.window.escape="{{ $closeEventHandler }}"
@endif
x-show="isWindowVisible"
x-transition:enter="fi-transition-enter"
x-transition:leave="fi-transition-leave"
@if ($width !== Width::Screen)
x-transition:enter-start="fi-transition-enter-start"
x-transition:enter-end="fi-transition-enter-end"
x-transition:leave-start="fi-transition-leave-start"
x-transition:leave-end="fi-transition-leave-end"
@endif
@if (filled($wireSubmitHandler))
wire:submit.prevent="{!! $wireSubmitHandler !!}"
@endif
@if (filled($id))
wire:key="{{ isset($this) ? "{$this->getId()}." : '' }}modal.{{ $id }}.window"
@endif
{{
($extraModalWindowAttributeBag ?? new \Illuminate\View\ComponentAttributeBag)->class([
'fi-modal-window',
'fi-modal-window-has-close-btn' => $closeButton,
'fi-modal-window-has-content' => $hasContent,
'fi-modal-window-has-footer' => $hasFooter,
'fi-modal-window-has-icon' => $hasIcon,
'fi-modal-window-has-sticky-header' => $stickyHeader,
'fi-hidden' => ! $visible,
(($alignment instanceof Alignment) && (! $slideOver)) ? "fi-align-{$alignment->value}" : null,
($width instanceof Width) ? "fi-width-{$width->value}" : (is_string($width) ? $width : null),
])
}}
>
@if ($heading || $header)
getId()}." : '' }}modal.{{ $id }}.header"
@endif
@class([
'fi-modal-header',
'fi-sticky' => $stickyHeader,
'fi-vertical-align-center' => $hasIcon && $hasHeading && (! $hasDescription) && in_array($alignment, [Alignment::Start, Alignment::Left]),
])
>
@if ($closeButton)
@endif
@if ($header)
{{ $header }}
@else
@if ($hasIcon)
color(IconComponent::class, $iconColor)->class(['fi-modal-icon-bg']) }}
>
{{ \Filament\Support\generate_icon_html($icon, $iconAlias, size: \Filament\Support\Enums\IconSize::Large) }}
@endif
{{ $heading }}
@if ($hasDescription)
{{ $description }}
@endif
@endif
@endif
@if ($hasContent)
getId()}." : '' }}modal.{{ $id }}.content"
@endif
class="fi-modal-content"
>
{{ $slot }}
@endif
@if ($hasFooter)
getId()}." : '' }}modal.{{ $id }}.footer"
@endif
@class([
'fi-modal-footer',
'fi-sticky' => $stickyFooter,
($footerActionsAlignment instanceof Alignment) ? "fi-align-{$footerActionsAlignment->value}" : null,
])
>
@if (! \Filament\Support\is_slot_empty($footer))
{{ $footer }}
@else
@endif
@endif
{{ filled($wireSubmitHandler) ? 'form' : 'div' }}>
@if ($trigger)
{!! '
' !!}
{{-- Avoid formatting issues with unclosed elements --}}
@endif