Skip to content

Commit 54f0e53

Browse files
committed
Add Blade Defaults
1 parent eda4c5e commit 54f0e53

File tree

16 files changed

+264
-216
lines changed

16 files changed

+264
-216
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ phpunit.xml.bak
2121
phpstan.txt
2222
coverage.xml
2323
./tmp/**
24+
tests.txt

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22

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

5-
@if ($isTailwind)
6-
<tr {{ $attributes }}>
7-
<td colspan="{{ $this->getColspanCount() }}">
5+
<tr {{ $attributes }}>
6+
<td colspan="{{ $this->getColspanCount() }}">
7+
@if ($isTailwind)
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>
11-
</td>
12-
</tr>
13-
@elseif ($isBootstrap)
14-
<tr {{ $attributes }}>
15-
<td colspan="{{ $this->getColspanCount() }}">
11+
@else
1612
{{ $this->getEmptyMessage() }}
17-
</td>
18-
</tr>
19-
@endif
13+
14+
@endif
15+
</td>
16+
</tr>

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22
@props(['column', 'colIndex'])
33

44
@php
5-
$customAttributes = $this->getTdAttributes($column, $row, $colIndex, $rowIndex)
5+
$customAttributes = $this->getTdAttributesBag($column, $row, $colIndex, $rowIndex)
66
@endphp
77

8-
<td wire:key="{{ $tableName . '-table-td-'.$row->{$primaryKey}.'-'.$column->getSlug() }}"
9-
@if ($column->isClickable())
10-
@if($this->getTableRowUrlTarget($row) === 'navigate') wire:navigate href="{{ $this->getTableRowUrl($row) }}"
11-
@else onclick="window.open('{{ $this->getTableRowUrl($row) }}', '{{ $this->getTableRowUrlTarget($row) ?? '_self' }}')"
12-
@endif
13-
@endif
14-
{{
15-
$attributes->merge($customAttributes)
16-
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true)])
8+
<td {{
9+
$customAttributes->merge()
10+
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium' => $isTailwind && ($customAttributes['default-styling'] ?? ($customAttributes['default'] ?? true))])
11+
->class(['dark:text-white' => $isTailwind && ($customAttributes['default-colors'] ?? ($customAttributes['default'] ?? true))])
1712
->class(['hidden' => $isTailwind && $column && $column->shouldCollapseAlways()])
1813
->class(['hidden md:table-cell' => $isTailwind && $column && $column->shouldCollapseOnMobile()])
1914
->class(['hidden lg:table-cell' => $isTailwind && $column && $column->shouldCollapseOnTablet()])
@@ -23,7 +18,6 @@
2318
->class(['d-none d-lg-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnTablet()])
2419
->class(['laravel-livewire-tables-cursor' => $isBootstrap && $column && $column->isClickable()])
2520
->except(['default','default-styling','default-colors'])
26-
}}
27-
>
28-
{{ $slot }}
21+
}}>
22+
{{ $slot }}
2923
</td>

resources/views/components/table/td/bulk-actions.blade.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,23 @@
22
@props(['row', 'rowIndex'])
33

44
@php
5-
$customAttributes = $this->getBulkActionsTdAttributes();
6-
$bulkActionsTdCheckboxAttributes = $this->getBulkActionsTdCheckboxAttributes();
7-
$theme = $this->getTheme();
5+
$customAttributes = $this->getBulkActionsTdAttributesNew($row->{$primaryKey});
6+
$bulkActionsTdCheckboxAttributes = $this->getBulkActionsTdCheckboxAttributesNew($row->{$primaryKey});
87
@endphp
98

109
@if ($this->bulkActionsAreEnabled() && $this->hasBulkActions())
11-
<x-livewire-tables::table.td.plain wire:key="{{ $tableName }}-tbody-td-bulk-actions-td-{{ $row->{$primaryKey} }}" :displayMinimisedOnReorder="true" :$customAttributes>
10+
<x-livewire-tables::table.td.plain :$customAttributes>
1211
<div @class([
13-
'inline-flex rounded-md shadow-sm' => $theme === 'tailwind',
14-
'form-check' => $theme === 'bootstrap-5',
12+
'inline-flex rounded-md shadow-sm' => $this->isTailwind,
13+
'form-check' => $this->isBootstrap,
1514
])>
16-
<input
17-
x-cloak x-show="!currentlyReorderingStatus"
18-
x-model="selectedItems"
19-
wire:key="{{ $tableName . 'selectedItems-'.$row->{$primaryKey} }}"
20-
wire:loading.attr.delay="disabled"
21-
value="{{ $row->{$primaryKey} }}"
22-
type="checkbox"
23-
{{
15+
<input {{
2416
$attributes->merge($bulkActionsTdCheckboxAttributes)->class([
25-
'rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => ($theme === 'tailwind') && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
26-
'form-check-input' => ($theme === 'bootstrap-5') && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
17+
'rounded shadow-sm transition duration-150 ease-in-out focus:ring focus:ring-opacity-50' => $this->isTailwind && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-styling'] ?? true)),
18+
'border-gray-300 text-indigo-600 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => $this->isTailwind && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-colors'] ?? true)),
19+
'form-check-input' => $this->isBootstrap && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
2720
])->except(['default','default-styling','default-colors'])
28-
}}
29-
/>
21+
}} />
3022
</div>
3123
</x-livewire-tables::table.td.plain>
3224
@endif

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
@if ($isTailwind)
66
<td x-data="{open:false}" wire:key="{{ $tableName }}-collapsingIcon-{{ $rowIndex }}-{{ md5(now()) }}"
77
{{
8-
$attributes
9-
->merge(['class' => 'p-3 table-cell text-center '])
10-
->class(['sm:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
11-
->class(['md:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
12-
->class(['lg:hidden' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
8+
$attributes->merge()
9+
->class(['p-3 table-cell text-center' => $this->isTailwind])
10+
->class(['sm:hidden' => $this->isTailwind && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
11+
->class(['md:hidden' => $this->isTailwind && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
12+
->class(['lg:hidden' => $this->isTailwind && !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
13+
->class(['d-sm-none' => $this->isBootstrap && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
14+
->class(['d-md-none' => $this->isBootstrap && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
15+
->class(['d-lg-none' => $this->isBootstrap && !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
16+
1317
}}
1418
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
1519
>
@@ -43,12 +47,7 @@
4347
</td>
4448
@elseif ($isBootstrap)
4549
<td x-data="{open:false}" wire:key="{{ $tableName }}-collapsingIcon-{{ $rowIndex }}-{{ md5(now()) }}"
46-
{{
47-
$attributes
48-
->class(['d-sm-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
49-
->class(['d-md-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
50-
->class(['d-lg-none' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
51-
}}
50+
5251
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
5352
>
5453
@if (! $hidden)

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

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,16 @@
22
@props(['column' => null, 'customAttributes' => [], 'displayMinimisedOnReorder' => false, 'hideUntilReorder' => false])
33

44

5-
@if ($isTailwind)
6-
<td x-cloak {{ $attributes
7-
->merge($customAttributes)
8-
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $customAttributes['default'] ?? true])
9-
->class(['hidden' => $column && $column->shouldCollapseAlways()])
10-
->class(['hidden md:table-cell' => $column && $column->shouldCollapseOnMobile()])
11-
->class(['hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet()])
12-
->except(['default','default-styling','default-colors'])
13-
}} @if($hideUntilReorder) x-show="reorderDisplayColumn" @endif >
14-
{{ $slot }}
15-
</td>
16-
@elseif ($isBootstrap)
17-
<td {{ $attributes
18-
->merge($customAttributes)
19-
->class(['' => $customAttributes['default'] ?? true])
20-
->class(['d-none' => $column && $column->shouldCollapseAlways()])
21-
->class(['d-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile()])
22-
->class(['d-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet()])
23-
->except(['default','default-styling','default-colors'])
24-
}}>
25-
{{ $slot }}
26-
</td>
27-
@endif
5+
<td x-cloak {{ $attributes
6+
->merge($customAttributes)
7+
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true)])
8+
->class(['hidden' => $isTailwind && $column && $column->shouldCollapseAlways()])
9+
->class(['hidden md:table-cell' => $isTailwind && $column && $column->shouldCollapseOnMobile()])
10+
->class(['hidden lg:table-cell' => $isTailwind && $column && $column->shouldCollapseOnTablet()])
11+
->class(['d-none' => $isBootstrap && $column && $column->shouldCollapseAlways()])
12+
->class(['d-none d-md-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnMobile()])
13+
->class(['d-none d-lg-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnTablet()])
14+
->except(['default','default-styling','default-colors'])
15+
}} @if($hideUntilReorder) x-show="reorderDisplayColumn" @endif >
16+
{{ $slot }}
17+
</td>

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

Lines changed: 36 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,81 +10,50 @@
1010
$customSortIconAttributes = $allThAttributes['sortIconAttributes'];
1111
$customLabelAttributes = $allThAttributes['labelAttributes'];
1212
13-
//$customThAttributes = $this->getThAttributes($column);
14-
//$customSortButtonAttributes = $this->getThSortButtonAttributes($column);
15-
//$customSortIconAttributes = $this->getThSortIconAttributes($column);
16-
1713
$direction = $column->hasField() ? $this->getSort($column->getColumnSelectName()) : $this->getSort($column->getSlug()) ?? null ;
1814
@endphp
1915

20-
@if ($isTailwind)
21-
<th scope="col" {{
22-
$attributes->merge($customThAttributes)
23-
->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true))])
24-
->class(['px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true))])
25-
->class(['hidden' => $column->shouldCollapseAlways()])
26-
->class(['hidden md:table-cell' => $column->shouldCollapseOnMobile()])
27-
->class(['hidden lg:table-cell' => $column->shouldCollapseOnTablet()])
28-
->except(['default', 'default-colors', 'default-styling'])
29-
}}
30-
>
31-
@if($column->getColumnLabelStatus())
32-
@unless ($this->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
33-
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
34-
@else
35-
<button wire:click="sortBy('{{ $column->getColumnSortKey() }}')"
36-
{{
37-
$attributes->merge($customSortButtonAttributes)
38-
->class(['text-gray-500 dark:text-gray-400' => (($customSortButtonAttributes['default-colors'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
39-
->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
40-
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
41-
}}
42-
>
43-
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
44-
<x-livewire-tables::table.th.sort-icons :$direction
45-
{{
46-
$attributes->merge($customSortIconAttributes)
47-
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
48-
}}
49-
/>
16+
<th scope="col" {{ $attributes->merge($customThAttributes)
17+
->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => $isTailwind && (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true))])
18+
->class(['px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => $isTailwind && (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true))])
19+
->class(['hidden' => $isTailwind && $column->shouldCollapseAlways()])
20+
->class(['hidden md:table-cell' => $isTailwind && $column->shouldCollapseOnMobile()])
21+
->class(['hidden lg:table-cell' => $isTailwind && $column->shouldCollapseOnTablet()])
22+
->class(['d-none' => $isBootstrap && $column->shouldCollapseAlways()])
23+
->class(['d-none d-md-table-cell' => $isBootstrap && $column->shouldCollapseOnMobile()])
24+
->class(['d-none d-lg-table-cell' => $isBootstrap && $column->shouldCollapseOnTablet()])
25+
->except(['default', 'default-colors', 'default-styling'])
26+
}}>
27+
@if($column->getColumnLabelStatus())
28+
@unless ($this->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
29+
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
30+
@else
5031

51-
</button>
52-
@endunless
53-
@endif
54-
</th>
55-
@elseif ($isBootstrap)
56-
<th scope="col" {{
57-
$attributes->merge($customThAttributes)
58-
->class(['' => $customThAttributes['default'] ?? true])
59-
->class(['d-none' => $column->shouldCollapseAlways()])
60-
->class(['d-none d-md-table-cell' => $column->shouldCollapseOnMobile()])
61-
->class(['d-none d-lg-table-cell' => $column->shouldCollapseOnTablet()])
62-
->except(['default','default-styling','default-colors'])
63-
}}
64-
>
65-
@if($column->getColumnLabelStatus())
66-
@unless ($this->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
67-
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
68-
@else
69-
<div
70-
class="d-flex align-items-center laravel-livewire-tables-cursor"
71-
wire:click="sortBy('{{ $column->getColumnSortKey() }}')"
72-
{{
73-
$attributes->merge($customSortButtonAttributes)
32+
@if ($isTailwind)
33+
<button wire:click="sortBy('{{ $column->getColumnSortKey() }}')" {{
34+
$attributes->merge($customSortButtonAttributes)
35+
->class(['text-gray-500 dark:text-gray-400' => (($customSortButtonAttributes['default-colors'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
36+
->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
37+
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
38+
}}>
39+
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
40+
<x-livewire-tables::table.th.sort-icons :$direction {{ $attributes->merge($customSortIconAttributes)
41+
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
42+
}} />
43+
</button>
44+
@elseif ($isBootstrap)
45+
<div class="d-flex align-items-center laravel-livewire-tables-cursor" wire:click="sortBy('{{ $column->getColumnSortKey() }}')" {{ $attributes->merge($customSortButtonAttributes)
7446
->class(['' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
7547
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
76-
}}
77-
>
48+
}}>
7849
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
7950

80-
<x-livewire-tables::table.th.sort-icons :$direction {{
81-
$attributes->merge($customSortButtonAttributes)
51+
<x-livewire-tables::table.th.sort-icons :$direction {{ $attributes->merge($customSortButtonAttributes)
8252
->class(['' => (($customSortButtonAttributes['default-colors'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
8353
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
84-
}}
85-
/>
54+
}} />
8655
</div>
87-
@endunless
88-
@endif
89-
</th>
90-
@endif
56+
@endif
57+
@endunless
58+
@endif
59+
</th>

0 commit comments

Comments
 (0)