Skip to content

Commit 13d5c13

Browse files
committed
Tweaks
1 parent d658a60 commit 13d5c13

22 files changed

+896
-109
lines changed

resources/js/laravel-livewire-tables.min.js

Lines changed: 722 additions & 1 deletion
Large diffs are not rendered by default.

resources/views/components/includes/loading.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@aware(['tableName','isTailwind','isBootstrap'])
1+
@aware(['tableName','isTailwind','isBootstrap', 'currentlyReorderingStatus'])
22
@props(['colCount' => 1])
33

44
@php
@@ -39,4 +39,4 @@
3939
</div>
4040
@endif
4141
</td>
42-
</tr>
42+
</tr>

resources/views/components/table.blade.php

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@aware(['tableName','isTailwind','isBootstrap'])
1+
@aware(['tableName','isTailwind','isBootstrap', 'currentlyReorderingStatus'])
22
@props(['bulkActionsTdAttributes','bulkActionsTdCheckboxAttributes'])
33

44
@php($coreTableAttributes = $this->getCoreTableAttributes())
@@ -10,33 +10,27 @@
1010
'shadow overflow-y-auto border-b sm:rounded-lg' => $coreTableAttributes['wrapper']['default-styling'] ?? ($coreTableAttributes['wrapper']['default'] ?? false),
1111
])
1212
->except(['default','default-styling','default-colors'])
13-
}}>
14-
<table {{ $attributes->merge($coreTableAttributes['table'])
13+
}} >
14+
<table @if($currentlyReorderingStatus) x-data="reorderFunction" x-sort x-sort:config="{ filter: '.ignoresort', store: {
15+
set: function (sortable) {
16+
updateReorderedItems(sortable.toArray());
17+
}
18+
}
19+
}" @endif {{ $attributes->merge($coreTableAttributes['table'])
1520
->class([
1621
'divide-gray-200 dark:divide-none' => $coreTableAttributes['table']['default-colors'] ?? ($coreTableAttributes['table']['default'] ?? true),
1722
'min-w-full divide-y' => $coreTableAttributes['table']['default-styling'] ?? ($coreTableAttributes['table']['default'] ?? true),
1823
])
1924
->except(['default','default-styling','default-colors']) }}
2025
>
21-
<thead {{ $attributes->merge($coreTableAttributes['thead'])
22-
->class([
23-
'bg-gray-50 dark:bg-gray-800' => $coreTableAttributes['thead']['default-colors'] ?? ($coreTableAttributes['thead']['default'] ?? true),
24-
'' => $coreTableAttributes['thead']['default-styling'] ?? ($coreTableAttributes['thead']['default'] ?? true),
25-
])
26-
->except(['default','default-styling','default-colors']) }}
27-
>
28-
<tr>
29-
{{ $thead }}
30-
</tr>
31-
</thead>
26+
@isset($thead)
27+
{{ $thead }}
28+
@endisset
3229

3330
{{ $slot }}
3431

35-
3632
@isset($tfoot)
37-
<tfoot wire:key="{{ $tableName }}-tfoot">
38-
{{ $tfoot }}
39-
</tfoot>
33+
{{ $tfoot }}
4034
@endisset
4135
</table>
4236
</div>
@@ -57,6 +51,8 @@
5751
->except(['default','default-styling','default-colors'])
5852
}}
5953
>
54+
@isset($thead)
55+
6056
<thead {{ $attributes->merge($coreTableAttributes['thead'])
6157
->class([
6258
'' => $coreTableAttributes['thead']['default-colors'] ?? ($coreTableAttributes['thead']['default'] ?? true),
@@ -68,6 +64,7 @@
6864
{{ $thead }}
6965
</tr>
7066
</thead>
67+
@endisset
7168

7269
<tbody {{ $attributes->merge($coreTableAttributes['tbody'])
7370
->class([

resources/views/components/table/collapsed-columns.blade.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@aware([ 'tableName', 'primaryKey','isTailwind','isBootstrap', 'collapsingColumnDetails', 'rowPk','row', 'rowIndex','customAttributes', 'hasCollapsingColumns'])
1+
@aware([ 'tableName', 'primaryKey','isTailwind','isBootstrap', 'collapsingColumnDetails', 'rowPk','row', 'rowIndex','customAttributes', 'hasCollapsingColumns', 'colspanCount'])
22

33
@if ($hasCollapsingColumns)
4-
<tr x-data
4+
<tr data-id="tr-collapsed" x-data
55
@toggle-row-content.window="($event.detail.tableName === '{{ $tableName }}' && $event.detail.row === {{ $rowIndex }}) ? $el.classList.toggle('{{ $isBootstrap ? 'd-none' : 'hidden' }}') : null"
66
{{
77
$attributes->merge([
@@ -10,16 +10,15 @@
1010
])
1111
->merge($customAttributes)
1212
->class($isTailwind ? [
13-
'hidden bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => (($customAttributes['default'] ?? true) && $rowIndex % 2 === 0),
14-
'hidden bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => (($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0),
13+
'hidden rappasoft-striped-row' => $customAttributes['default'] ?? true,
1514
] : [
16-
'd-none bg-light rappasoft-striped-row' => ($rowIndex % 2 === 0 && ($customAttributes['default'] ?? true)),
17-
'd-none bg-white rappasoft-striped-row' => ($rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true)),
15+
'd-none rappasoft-striped-row' => ($rowIndex % 2 === 0 && ($customAttributes['default'] ?? true)),
16+
'd-none rappasoft-striped-row' => ($rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true)),
1817
])
1918
->except(['default','default-styling','default-colors'])
2019
}}
2120
>
22-
<td colspan="{{ $this->getColspanCount() }}" @class([
21+
<td colspan="{{ $colspanCount }}" @class([
2322
'text-left pt-4 pb-2 px-4' => $isTailwind,
2423
'text-start pt-3 p-2' => $isBootstrap,
2524
])>

resources/views/components/table/empty.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
@aware(['isTailwind','isBootstrap'])
1+
@aware(['isTailwind','isBootstrap', 'colspanCount'])
22

33
@php($attributes = $attributes->merge(['wire:key' => 'empty-message-'.$this->getId()]))
44

55
@if ($isTailwind)
66
<tr {{ $attributes }}>
7-
<td colspan="{{ $this->getColspanCount() }}">
7+
<td colspan="{{ $colspanCount }}">
88
<div class="flex justify-center items-center space-x-2 dark:bg-gray-800">
99
<span class="font-medium py-8 text-gray-400 text-lg dark:text-white">{{ $this->getEmptyMessage() }}</span>
1010
</div>
1111
</td>
1212
</tr>
1313
@elseif ($isBootstrap)
1414
<tr {{ $attributes }}>
15-
<td colspan="{{ $this->getColspanCount() }}">
15+
<td colspan="{{ $colspanCount }}">
1616
{{ $this->getEmptyMessage() }}
1717
</td>
1818
</tr>

resources/views/components/table/tbody.blade.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@aware(['tableName','showBulkActionsSections', 'coreTableAttributes', 'currentlyReorderingStatus', 'showCollapsingColumnSections', 'selectedVisibleColumns'])
1+
@aware(['tableName','showBulkActionsSections', 'coreTableAttributes', 'currentlyReorderingStatus', 'showCollapsingColumnSections', 'selectedVisibleColumns', 'columnCollapseInfo'])
22
@props(['row','rowIndex','rowPk','customAttributes'])
33
@php
44
if ($this->hasTableRowUrl())
@@ -13,9 +13,10 @@
1313
}
1414
@endphp
1515

16-
<tbody {{ $attributes->merge($coreTableAttributes['tbody'])
16+
<tbody @if($currentlyReorderingStatus) x-sort:item="'{{$rowPk}}'" data-id="{{$rowPk}}" @endif {{ $attributes->merge($coreTableAttributes['tbody'])
1717
->class([
18-
'bg-white divide-gray-200 dark:bg-gray-800 dark:divide-none' => $coreTableAttributes['tbody']['default-colors'] ?? ($coreTableAttributes['tbody']['default'] ?? true),
18+
'odd:bg-white odd:dark:bg-gray-700 odd:dark:text-white even:bg-gray-50 even:dark:bg-gray-800 even:dark:text-white',
19+
'divide-gray-200 dark:divide-none' => $coreTableAttributes['tbody']['default-colors'] ?? ($coreTableAttributes['tbody']['default'] ?? true),
1920
'divide-y' => $coreTableAttributes['tbody']['default-styling'] ?? ($coreTableAttributes['tbody']['default'] ?? true),
2021
])
2122
->except(['default','default-styling','default-colors'])
@@ -34,7 +35,7 @@
3435
@endif
3536

3637
@tableloop($selectedVisibleColumns as $colIndex => $column)
37-
<x-livewire-tables::table.td wire:key="{{ $tableName . '-' . $rowPk . '-datatable-td-' . $column->getSlug() }}" :$column :$colIndex >
38+
<x-livewire-tables::table.td :colData="$columnCollapseInfo[$colIndex] ?? []" :slug="$columnCollapseInfo[$colIndex] ? $columnCollapseInfo[$colIndex]['slug'] : $column->getSlug()" :$colIndex :customAttributes="$this->getTdAttributes($column, $row, $colIndex, $rowIndex)" >
3839
@if($column->isHtml())
3940
{!! $column->setIndexes($rowIndex, $colIndex)->renderContents($row) !!}
4041
@else

resources/views/components/table/td.blade.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
@aware([ 'row', 'rowIndex', 'tableName', 'primaryKey', 'rowPk', 'isTailwind','isBootstrap','rowUrl', 'rowTarget'])
2-
@props(['column', 'colIndex'])
1+
@aware([ 'rowIndex', 'tableName', 'rowPk', 'isTailwind','isBootstrap','rowUrl', 'rowTarget'])
2+
@props(['colIndex', 'customAttributes', 'slug', 'colData'])
33

4-
@php
5-
$customAttributes = $this->getTdAttributes($column, $row, $colIndex, $rowIndex);
6-
@endphp
74

8-
<td wire:key="{{ $tableName . '-table-td-'.$rowPk.'-'.$column->getSlug() }}" x-ref="{{ $tableName . "_" . $rowIndex."_".$colIndex}}"
9-
@if ($column->isClickable())
5+
<td wire:key="{{ $tableName . '-table-td-'.$rowPk.'-'.$slug }}" x-ref="{{ $tableName . "_" . $rowIndex. "_" . $colIndex }}"
6+
@if ($colData['isClickable'] ?? false)
107
@if($rowTarget === 'navigate') wire:navigate href="{{ $rowUrl }}"
118
@else onclick="window.open('{{ $rowUrl }}', '{{ $rowTarget ?? '_self' }}')"
129
@endif
1310
@endif
1411
{{
1512
$attributes->merge($customAttributes)
1613
->class($isTailwind ? [
17-
'px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true),
18-
'hidden' => $column && $column->shouldCollapseAlways(),
19-
'hidden md:table-cell' => $column && $column->shouldCollapseOnMobile(),
20-
'hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet(),
14+
'px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => ($customAttributes['default'] ?? true),
15+
'hidden' => $colData['shouldCollapseAlways'] ?? false,
16+
'hidden md:table-cell' => $colData['shouldCollapseOnMobile'] ?? false,
17+
'hidden lg:table-cell' => $colData['shouldCollapseOnTablet'] ?? false,
2118
] : [
2219
'' => ($customAttributes['default'] ?? true),
23-
'd-none' => $column && $column->shouldCollapseAlways(),
24-
'd-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile(),
25-
'd-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet(),
26-
'laravel-livewire-tables-cursor' => $column && $column->isClickable(),
20+
'd-none' => $colData['shouldCollapseAlways'] ?? false,
21+
'd-none d-md-table-cell' => $colData['shouldCollapseOnMobile'] ?? false,
22+
'd-none d-lg-table-cell' => $colData['shouldCollapseOnTablet'] ?? false,
23+
'laravel-livewire-tables-cursor' => $colData['isClickable'] ?? false,
2724
])
2825
->except(['default','default-styling','default-colors'])
2926
}}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@aware([ 'row', 'rowIndex', 'tableName', 'primaryKey', 'rowPk', 'isTailwind','isBootstrap','rowUrl', 'rowTarget', 'collapsingColumnDetails', 'columnCollapseInfo'])
2+
@props(['customAttributes', 'colData', 'colIndex'])
3+
4+
5+
<td wire:key="{{ $tableName . '-table-td-'.$rowPk.'-'.$colData['slug'] }}" x-ref="{{ $tableName . "_" . $rowIndex. "_" . $colIndex }}"
6+
@if ($colData['isClickable'] ?? false)
7+
@if($rowTarget === 'navigate') wire:navigate href="{{ $rowUrl }}"
8+
@else onclick="window.open('{{ $rowUrl }}', '{{ $rowTarget ?? '_self' }}')"
9+
@endif
10+
@endif
11+
{{
12+
$attributes->merge($customAttributes)
13+
->class($isTailwind ? [
14+
'px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true),
15+
'hidden' => $colData['shouldCollapseAlways'] ?? false,
16+
'hidden md:table-cell' => $colData['shouldCollapseOnMobile'] ?? false,
17+
'hidden lg:table-cell' => $colData['shouldCollapseOnTablet'] ?? false,
18+
] : [
19+
'' => ($customAttributes['default'] ?? true),
20+
'd-none' => $colData['shouldCollapseAlways'] ?? false,
21+
'd-none d-md-table-cell' => $colData['shouldCollapseOnMobile'] ?? false,
22+
'd-none d-lg-table-cell' => $colData['shouldCollapseOnTablet'] ?? false,
23+
'laravel-livewire-tables-cursor' => $colData['isClickable'] ?? false,
24+
])
25+
->except(['default','default-styling','default-colors'])
26+
}}
27+
>
28+
{{ $slot }}
29+
</td>

resources/views/components/table/td/reorder.blade.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
@aware([ 'tableName', 'isTailwind', 'isBootstrap', 'isBootstrap4', 'isBootstrap5'])
2-
@props(['rowID', 'rowIndex'])
1+
@aware([ 'tableName', 'isTailwind', 'isBootstrap', 'isBootstrap4', 'isBootstrap5', 'rowIndex', 'rowPk'])
32

4-
<x-livewire-tables::table.td.plain x-cloak x-show="currentlyReorderingStatus" wire:key="{{ $tableName }}-tbody-reorder-{{ $rowID }}" :displayMinimisedOnReorder="false">
3+
<x-livewire-tables::table.td.plain x-cloak x-show="currentlyReorderingStatus" wire:key="{{ $tableName }}-tbody-reorder-{{ $rowPk }}" :displayMinimisedOnReorder="false">
54
<svg
65
x-cloak x-show="currentlyReorderingStatus"
76
xmlns="http://www.w3.org/2000/svg"
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
@aware(['tableName', 'primaryKey','isTailwind','isBootstrap'])
22
<x-slot name="tfoot">
3-
@if ($this->useHeaderAsFooterIsEnabled())
4-
<x-livewire-tables::table.tr.secondary-header />
5-
@else
6-
<x-livewire-tables::table.tr.footer />
7-
@endif
8-
</x-slot>
3+
<tfoot data-id="tfoot" wire:key="{{ $tableName }}-tfoot">
4+
5+
@if ($this->useHeaderAsFooterIsEnabled())
6+
<x-livewire-tables::table.tr.secondary-header />
7+
@else
8+
<x-livewire-tables::table.tr.footer />
9+
@endif
10+
</tfoot>
11+
</x-slot>

0 commit comments

Comments
 (0)