@props([ 'tabs', 'contents' => [], 'active' => null, 'justifyAlign' => 'start', 'isVertical' => false, ]) @if($tabs) @php // Если содержимое не передано, создаем его из слотов if ($contents === []) { $tabs = collect($tabs) ->mapWithKeys(fn($value, $name) => [ Str::camel($name) => $value ]) ->all(); $contents = collect($__laravel_slots ?? []) ->mapWithKeys(fn($contentSlot, $name) => [ Str::camel($name) => $contentSlot ]) ->filter(fn($contentSlot, $name) => array_key_exists($name, $tabs)) ->all(); } @endphp
class(['tabs']) }} x-data="tabs( '{{ $active ?? (request()->has('tab') ? request()->tab : (isset($_GET['tab']) ? $_GET['tab'] : array_key_first($tabs))) }}', {{ $isVertical ? 'true' : 'false' }} )" x-init="() => { const hash = window.location.hash.replace('#', ''); if (hash && $el.querySelector(`#${hash}`)) { activeTab = hash; } }" >
@foreach($contents as $tabId => $tabContent)
{!! $tabContent !!}
@endforeach
@endif