@php $resolvedId = $id ?: 'cb-table-'.uniqid(); $resolvedAjax = $ajax ?: request()->url(); $resolvedOptions = array_merge([ 'defaultSort' => [ 'column' => 'created_at', 'dir' => 'desc', ], 'perPage' => 15, ], $options ?? []); $resolvedColumns = $columns ?? []; $showControls = (bool) ($resolvedOptions['showControls'] ?? true); $useHeadSlot = isset($head) && $head instanceof \Illuminate\View\ComponentSlot && $head->isNotEmpty(); $useColgroupSlot = isset($colgroup) && $colgroup instanceof \Illuminate\View\ComponentSlot && $colgroup->isNotEmpty(); $useLoadingSlot = isset($loading) && $loading instanceof \Illuminate\View\ComponentSlot && $loading->isNotEmpty(); $useEmptySlot = isset($empty) && $empty instanceof \Illuminate\View\ComponentSlot && $empty->isNotEmpty(); // Match legacy admin tables: avoid extra vertical gap between card + pagination (pagination uses mt-4). $rootClass = trim((string) ($resolvedOptions['rootClass'] ?? ($showControls ? 'space-y-3' : ''))); $tableCellpadding = (int) ($resolvedOptions['cellpadding'] ?? 16); @endphp
{{-- Default controls (optional; can be hidden later via options) --}} @if($showControls)
@endif @isset($filters) @if($filters instanceof \Illuminate\View\ComponentSlot) {{ $filters }} @endif @endisset
0) cellpadding="{{ $tableCellpadding }}" @endif class="w-full table-fixed text-left text-sm text-muted-foreground" data-cb-table data-cb-ajax-url="{{ $resolvedAjax }}" data-cb-per-page="{{ (int) ($resolvedOptions['perPage'] ?? 15) }}" @if($actionsBase) data-cb-actions-base="{{ $actionsBase }}" @endif @if(!empty($resolvedOptions['defaultSort']['column'])) data-cb-default-sort="{{ $resolvedOptions['defaultSort']['column'] }}" @endif @if(!empty($resolvedOptions['defaultSort']['dir'])) data-cb-default-sort-dir="{{ $resolvedOptions['defaultSort']['dir'] }}" @endif > @if($useColgroupSlot) {{ $colgroup }} @endif @if($useHeadSlot) {{ $head }} @elseif(!empty($resolvedColumns)) @foreach($resolvedColumns as $col) @php $data = $col['data'] ?? ''; $label = $col['label'] ?? $data; $type = $col['type'] ?? null; $sortable = $col['sortable'] ?? $col['orderable'] ?? true; $searchable = $col['searchable'] ?? true; $align = $col['align'] ?? ($data === '_actions' ? 'right' : 'left'); @endphp @endforeach @else {{-- If no columns passed, developer may provide headers via the `head` slot with @if($useLoadingSlot) {{ $loading }} @else @endif
{{ $label }}
--}} {{ $head ?? '' }} @endif
{{-- Safe JSON config for the JS engine (no inline JS). --}}