{{-- Reusable modal wrapper matching styles from resources/views/sites/_global_forms/*. Example: [body slot] ... Anuluj Zapisz --}} @props([ 'modalId', 'type' => 'info', 'ariaLabelledby' => 'exampleModalCenterTitle', 'formId' => null, 'action' => null, 'routeName' => null, 'method' => 'POST', 'enctype' => null, 'includeCsrf' => true, 'panelClass' => null, 'headerIcon' => null, 'title' => null, 'titleClass' => '', 'width' => null, 'maxWidth' => null, 'showClose' => true, 'showDefaultFooter' => true, 'footerAlign' => 'center', 'cancelText' => null, 'cancelClass' => null, 'submitText' => null, 'submitClass' => null, ]) @php $themes = [ 'add' => [ 'panelClass' => 'alert-success', 'headerIcon' => 'fa fa-info-circle', 'title' => 'Informacja !', 'width' => 700, 'cancelText' => 'Anuluj', 'cancelClass' => 'btn btn-secondary', 'submitText' => 'Zapisz', 'submitClass' => 'btn btn-success', ], 'edit' => [ 'panelClass' => 'alert-primary', 'headerIcon' => 'fa fa-edit', 'title' => 'Edycja rekordu.', 'width' => 800, 'cancelText' => 'Anuluj', 'cancelClass' => 'btn btn-secondary', 'submitText' => 'Zapisz', 'submitClass' => 'btn btn-primary', ], 'delete' => [ 'panelClass' => 'alert-danger', 'headerIcon' => 'fas fa-exclamation-circle', 'title' => 'Potwierdz !', 'width' => 600, 'cancelText' => 'Anuluj', 'cancelClass' => 'btn btn-secondary', 'submitText' => 'Wykonaj', 'submitClass' => 'btn btn-danger', ], 'status' => [ 'panelClass' => 'alert-warning', 'headerIcon' => 'fas fa-exclamation-circle', 'title' => 'Potwierdz !', 'width' => 600, 'cancelText' => 'Anuluj', 'cancelClass' => 'btn btn-secondary', 'submitText' => 'Zmien status', 'submitClass' => 'btn btn-warning', ], 'info' => [ 'panelClass' => 'alert-info', 'headerIcon' => 'fa fa-info-circle', 'title' => 'Informacja !', 'width' => 700, 'cancelText' => 'Zamknij', 'cancelClass' => 'btn btn-info', 'submitText' => null, 'submitClass' => null, ], ]; $themeKey = strtolower((string) $type); $theme = $themes[$themeKey] ?? $themes['info']; $resolvedPanelClass = $panelClass ?? $theme['panelClass']; $resolvedHeaderIcon = $headerIcon ?? $theme['headerIcon']; $resolvedTitle = $title ?? $theme['title']; $resolvedWidth = $width ?? $theme['width']; $resolvedCancelText = $cancelText ?? $theme['cancelText']; $resolvedCancelClass = $cancelClass ?? $theme['cancelClass']; $resolvedSubmitText = $submitText ?? $theme['submitText']; $resolvedSubmitClass = $submitClass ?? $theme['submitClass']; $resolvedAction = $action; if ($resolvedAction === null && $routeName !== null) { $resolvedAction = route($routeName); } $normalizedMethod = strtoupper((string) $method); $formMethod = in_array($normalizedMethod, ['GET', 'POST'], true) ? $normalizedMethod : 'POST'; $spoofMethod = in_array($normalizedMethod, ['PUT', 'PATCH', 'DELETE'], true) ? $normalizedMethod : null; $shouldWrapForm = ($formId !== null) || ($resolvedAction !== null); $resolvedFormId = $formId ?? ('form_' . $themeKey); $normalizeSize = static function ($value) { if ($value === null || $value === '') { return null; } return is_numeric($value) ? ((string) $value) . 'px' : (string) $value; }; $panelWidthCss = $normalizeSize($resolvedWidth); $dialogMaxWidthCss = $normalizeSize($maxWidth ?? $resolvedWidth); $dialogStyle = $dialogMaxWidthCss ? 'max-width: ' . $dialogMaxWidthCss . ';' : null; $panelStyle = 'border-radius: 15px; pointer-events: auto;' . ($panelWidthCss ? ' width: ' . $panelWidthCss . ';' : ''); $footerAlignMap = [ 'start' => 'flex-start', 'end' => 'flex-end', 'between' => 'space-between', 'around' => 'space-around', 'center' => 'center', ]; $resolvedFooterAlign = $footerAlignMap[$footerAlign] ?? 'center'; @endphp