1
- <x-livewire-tables::table >
1
+ <x-livewire-tables::table wire:sortable = " {{ $reorderRows } } " >
2
2
<x-slot name =" head" >
3
+ @if (is_string ($reorderRows ) )
4
+ <x-livewire-tables::table .heading />
5
+ @endif
6
+
3
7
@if (count ($bulkActions ) )
4
8
<x-livewire-tables::table .heading >
5
9
<div class =" inline-flex rounded-md shadow-sm" >
@@ -20,6 +24,7 @@ class="rounded-md shadow-sm border-gray-300 block transition duration-150 ease-i
20
24
<x-livewire-tables::table .heading />
21
25
@else
22
26
<x-livewire-tables::table .heading
27
+ :sortingEnabled =" $sortingEnabled"
23
28
:sortable =" $column->isSortable()"
24
29
:column =" $column->column()"
25
30
:direction =" $column->column() ? $sorts[$column->column()] ?? null : null"
@@ -32,12 +37,19 @@ class="rounded-md shadow-sm border-gray-300 block transition duration-150 ease-i
32
37
</x-slot >
33
38
34
39
<x-slot name =" body" >
40
+ @php
41
+ $colspan = count ($columns );
42
+ if (count ($bulkActions )) $colspan ++ ;
43
+ if (is_string ($reorderRows )) $colspan ++ ;
44
+ @endphp
45
+
35
46
@include (' livewire-tables::tailwind.includes.bulk-select-row' )
36
47
37
48
@forelse ($rows as $index => $row )
38
49
<x-livewire-tables::table .row
39
50
wire:loading.class.delay =" opacity-50"
40
- wire:key =" table-row-{{ $row -> getKey () } }"
51
+ wire:key =" table-row-{{ $row -> {$primaryKey } } }"
52
+ wire:sortable.item =" {{ $row -> {$primaryKey } } }"
41
53
:url =" method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
42
54
:class ="
43
55
($index % 2 === 0 ?
@@ -49,6 +61,14 @@ class="rounded-md shadow-sm border-gray-300 block transition duration-150 ease-i
49
61
:id =" method_exists($this, 'setTableRowId') ? $this->setTableRowId($row) : ''"
50
62
:customAttributes =" method_exists($this, 'setTableRowAttributes') ? $this->setTableRowAttributes($row) : []"
51
63
>
64
+ @if (is_string ($reorderRows ) )
65
+ <x-livewire-tables::table .cell wire:sortable.handle >
66
+ <svg xmlns =" http://www.w3.org/2000/svg" style =" width :1em ;height :1em ;" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" >
67
+ <path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2" d =" M4 6h16M4 12h16M4 18h16" />
68
+ </svg >
69
+ </x-livewire-tables::table .cell >
70
+ @endif
71
+
52
72
@if (count ($bulkActions ) )
53
73
<x-livewire-tables::table .cell >
54
74
<div class =" inline-flex rounded-md shadow-sm" >
0 commit comments