{{-- format-ignore-start --}} @props([ // your table headers in tags 'header' => '', // setting to true will result in a striped table 'striped' => config('bladewind.table.striped', false), // should the table with displayed with a drop-shadow effect 'hasShadow' => config('bladewind.table.has_shadow', false), // should the table have a border on all four sides 'hasBorder' => config('bladewind.table.has_border', false), // should the table have row dividers 'divided' => config('bladewind.table.divided', true), // if table has row dividers, how wide should they be // available value are regular, thin 'divider' => config('bladewind.table.divider', 'regular'), // should rows light up on hover 'hasHover' => config('bladewind.table.has_hover', true), // should the rows be tighter together 'compact' => config('bladewind.table.compact', false), // provide a table name you can access via css 'name' => defaultBladewindName('tbl-'), 'data' => null, 'excludeColumns' => null, 'includeColumns' => null, 'actionIcons' => null, 'groupby' => null, 'actionsTitle' => 'actions', 'columnAliases' => [], 'searchable' => config('bladewind.table.searchable', false), 'searchPlaceholder' => config('bladewind.table.search_placeholder', __("bladewind::bladewind.table_search_placeholder")), 'searchField' => null, 'searchDebounce' => 0, 'searchMinLength' => 0, 'celled' => config('bladewind.table.celled', false), 'uppercasing' => config('bladewind.table.uppercasing', true), 'noDataMessage' => config('bladewind.table.no_data_message', __("bladewind::bladewind.table_no_data")), 'messageAsEmptyState' => config('bladewind.table.message_as_empty_state', false), // parameters expected by the empty state component --------------- 'image' => asset('vendor/bladewind/images/empty-state.svg'), 'heading' => '', 'buttonLabel' => '', 'showImage' => config('bladewind.table.show_image', true), 'onclick' => '', //------------------ end empty state parameters ------------------- 'selectable' => config('bladewind.table.selectable', false), 'checkable' => config('bladewind.table.checkable', false), 'transparent' => config('bladewind.table.transparent', false), 'selectedValue' => null, 'sortable' => config('bladewind.table.sortable', false), 'sortableColumns' => [], 'paginated' => config('bladewind.table.paginated', false), 'paginationStyle' => config('bladewind.table.pagination_style', 'arrows'), 'pageSize' => config('bladewind.table.page_size', 25), 'showRowNumbers' => config('bladewind.table.show_row_numbers', false), 'showTotal' => config('bladewind.table.show_total', true), 'showPageNumber' => config('bladewind.table.show_page_number', true), 'showTotalPages' => config('bladewind.table.show_total_pages', false), 'defaultPage' => 1, 'totalLabel' => config('bladewind.table.total_label', __("bladewind::bladewind.pagination_label")), 'limit' => null, 'layout' => 'auto', 'groupHeadingCss' => '', 'nonce' => config('bladewind.script.nonce', null), ]) @php // reset variables for Laravel 8 support $hasShadow = parseBladewindVariable($hasShadow); $hasHover = parseBladewindVariable($hasHover); $striped = parseBladewindVariable($striped); $compact = parseBladewindVariable($compact); $divided = parseBladewindVariable($divided); $searchable = parseBladewindVariable($searchable); $searchField = parseBladewindVariable($searchField, 'string'); $searchDebounce = parseBladewindVariable($searchDebounce, 'int'); $searchMinLength = parseBladewindVariable($searchMinLength, 'int'); $uppercasing = parseBladewindVariable($uppercasing); $celled = parseBladewindVariable($celled); $selectable = parseBladewindVariable($selectable); $checkable = parseBladewindVariable($checkable); $transparent = parseBladewindVariable($transparent); $paginated = parseBladewindVariable($paginated); $sortable = parseBladewindVariable($sortable); $pageSize = parseBladewindVariable($pageSize, 'int'); $messageAsEmptyState = parseBladewindVariable($messageAsEmptyState); $showRowNumbers = parseBladewindVariable($showRowNumbers); $showTotal = parseBladewindVariable($showTotal); $defaultPage = parseBladewindVariable($defaultPage, 'int'); $name = preg_replace('/[\s-]/', '_', $name); $iconsArray = []; $canGroup = false; $excludeColumns = !empty($excludeColumns) ? explode(',', str_replace(' ','', $excludeColumns)) : []; $actionIcons = (!empty($actionIcons)) ? ((is_array($actionIcons)) ? $actionIcons : json_decode(str_replace('"', '"', $actionIcons), true)) : []; $columnAliases = (!empty($columnAliases)) ? ((is_array($columnAliases)) ? $columnAliases : json_decode(str_replace('"', '"', $columnAliases), true)) : []; if($checkable) $selectable = true; if (!is_null($data)) { $data = (!is_array($data)) ? json_decode(str_replace('"', '"', $data), true) : $data; $totalRecords = (!empty($limit)) ? $limit : count($data); $defaultPage = ($defaultPage > ceil($totalRecords/$pageSize)) ? 1 : $defaultPage; $tableHeadings = $allTableHeadings = ($totalRecords > 0) ? array_keys((array) $data[0]) : (($columnAliases) ?? []); if( !empty($excludeColumns) ) { $tableHeadings = array_values(array_diff($tableHeadings, $excludeColumns)); } if( !empty($includeColumns) ) { $excludeColumns = []; $tableHeadings = explode(',', str_replace(' ','', $includeColumns)); } if($sortable){ $sortableColumns = empty($sortableColumns) ? $tableHeadings : explode(',', str_replace(' ','', $sortableColumns)); } if(!empty($groupby) && in_array($groupby, $tableHeadings)) { $canGroup = true; $groupedData = collect($data)->groupBy($groupby); $uniqueGroupHeadings = $groupedData->keys()->all(); $tableHeadings = collect($tableHeadings)->reject(fn($heading) => $heading === $groupby)->values()->all(); } // build action icons foreach ($actionIcons as $action) { $actionArray = explode('|',$action); $tempActionsArray = []; foreach($actionArray as $this_action){ $action_str_to_arr = explode(':', $this_action); $tempActionsArray[trim($action_str_to_arr[0])] = trim($action_str_to_arr[1]); } $iconsArray[] = $tempActionsArray; } if(!function_exists('build_click')){ function build_click($click, $rowData){ return preg_replace_callback('/{\w+}/', function ($matches) use ($rowData) { foreach($matches as $match) { return $rowData[str_replace('}', '', str_replace('{', '', $match))]; } }, $click); } } } @endphp {{-- format-ignore-end --}} let tableData_{{str_replace('-','_', $name)}} = {!! json_encode($data) !!};
($hasBorder && !$celled) ])>
@if($searchable)
@endif $hasShadow, 'divided' => $divided, 'thin' => $divided && $divider == 'thin', 'striped' => $striped, 'celled' => $celled, 'with-hover-effect' => $hasHover, 'compact' => $compact, 'uppercase-headers' => $uppercasing, 'sortable' => $sortable, 'paginated' => $paginated, 'selectable' => $selectable, 'checkable' => $checkable, 'transparent' => $transparent ])> @if(is_null($data) || $layout == 'custom') @if(!empty($header)) {{ $header }} @endif {{ $slot }} @else @if($showRowNumbers) @endif @foreach($tableHeadings as $th) @continue(!empty($excludeColumns) && in_array($th, $excludeColumns)) @php // get positions/indices of the fields to be displayed // use these indices to directly target data to display from $data $indices[] = $loop->index; @endphp @endforeach @if(!empty($actionIcons)) @endif @if($totalRecords > 0 && $layout == 'auto') @if($canGroup) @foreach($groupedData as $heading => $rows) @foreach($rows as $row) @php $row_id = $row['id'] ?? uniqid(); @endphp @foreach($tableHeadings as $th) @endforeach @endforeach @endforeach @else @foreach($data as $row) @php $row_id = $row['id'] ?? uniqid(); $row_page = (!$paginated || $loop->iteration < $pageSize) ? 1 : ceil($loop->iteration/$pageSize); @endphp @if(!empty($limit) && $loop->iteration > $limit) @break @endif @if($showRowNumbers) @endif @foreach($tableHeadings as $th) {{-- @if(in_array($loop->index, $indices))--}} {{-- @endif--}} @endforeach @endforeach @endif @else @endif @endif
# {{ str_replace('_', ' ', $columnAliases[$th] ?? $th ) }} @if($sortable && in_array($th, $sortableColumns)) {{$actionsTitle}}
empty($groupHeadingCss), "$groupHeadingCss" => !empty($groupHeadingCss)])>{{ $heading }}
{!! $row[$th] !!}
{{$loop->iteration}}{!! $row[$th] !!}
@if($messageAsEmptyState) @else {{ $noDataMessage }} @endif
@if($paginated && !empty($totalRecords)) @endif
@once @endonce @if($selectable) listenToSelectableTableRowEvents('{{$name}}'); @endif @if($checkable) @once @endonce addCheckboxesToTable('.bw-table.{{$name}}'); @if(!empty($selectedValue)) checkSelected('.bw-table.{{$name}}', '{{$selectedValue}}') @endif @endif @if($sortable) @once const originalTableOrder = new Map(); // Save the initial order of all tables when the page loads window.onload = saveOriginalTableOrder; @endonce @endif