Skip to content

Commit de8d3bb

Browse files
authored
Typehinting in blade components (#2081)
1 parent 772c49c commit de8d3bb

34 files changed

+325
-299
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
->class(['' => $this->isTailwind && $this->getActionWrapperAttributes['default-colors'] ?? true])
55
->class(['d-flex flex-cols py-2 space-x-2' => $this->isBootstrap && $this->getActionWrapperAttributes['default-styling'] ?? true])
66
->class(['' => $this->isBootstrap && $this->getActionWrapperAttributes['default-colors'] ?? true])
7-
->class(['justify-start' => $this->getActionsPosition == 'left'])
8-
->class(['justify-center' => $this->getActionsPosition == 'center'])
9-
->class(['justify-end' => $this->getActionsPosition == 'right'])
10-
->class(['pl-2' => $this->showActionsInToolbar && $this->getActionsPosition == 'left'])
11-
->class(['pr-2' => $this->showActionsInToolbar && $this->getActionsPosition == 'right'])
7+
->class(['justify-start' => $this->getActionsPosition === 'left'])
8+
->class(['justify-center' => $this->getActionsPosition === 'center'])
9+
->class(['justify-end' => $this->getActionsPosition === 'right'])
10+
->class(['pl-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'left'])
11+
->class(['pr-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'right'])
1212
->except(['default','default-styling','default-colors'])
1313
}} >
1414
@foreach($this->getActions as $action)
1515
{{ $action->render() }}
1616
@endforeach
17-
</div>
17+
</div>

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

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

44
@php
5-
$loaderRow = $this->getLoadingPlaceHolderRowAttributes();
6-
$loaderCell = $this->getLoadingPlaceHolderCellAttributes();
7-
$loaderIcon = $this->getLoadingPlaceHolderIconAttributes();
5+
$loaderRow = $this->getLoadingPlaceHolderRowAttributes();
6+
$loaderCell = $this->getLoadingPlaceHolderCellAttributes();
7+
$loaderIcon = $this->getLoadingPlaceHolderIconAttributes();
88
@endphp
99

1010
<tr wire:key="{{ $tableName }}-loader" wire:loading.class.remove="hidden d-none" {{
@@ -27,11 +27,10 @@
2727
$attributes->merge($loaderIcon)
2828
->class(['lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true)])
2929
->class(['lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true)])
30-
->except(['default','default-styling','default-colors']);
30+
->except(['default','default-styling','default-colors'])
3131
}}></div>
3232
<div>{!! $this->getLoadingPlaceholderContent() !!}</div>
3333
</div>
3434
@endif
3535
</td>
3636
</tr>
37-

resources/views/components/table.blade.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
{{ $attributes->merge($customAttributes['table'])
2222
->class(['min-w-full divide-y divide-gray-200 dark:divide-none' => $customAttributes['table']['default'] ?? true])
2323
->except(['default','default-styling','default-colors']) }}
24-
24+
2525
>
2626
<thead wire:key="{{ $tableName }}-thead"
2727
{{ $attributes->merge($customAttributes['thead'])
@@ -43,11 +43,11 @@
4343
{{ $slot }}
4444
</tbody>
4545

46-
@if (isset($tfoot))
46+
@isset($tfoot)
4747
<tfoot wire:key="{{ $tableName }}-tfoot">
4848
{{ $tfoot }}
4949
</tfoot>
50-
@endif
50+
@endisset
5151
</table>
5252
</div>
5353
@elseif ($isBootstrap)
@@ -84,11 +84,11 @@
8484
{{ $slot }}
8585
</tbody>
8686

87-
@if (isset($tfoot))
87+
@isset($tfoot)
8888
<tfoot wire:key="{{ $tableName }}-tfoot">
8989
{{ $tfoot }}
9090
</tfoot>
91-
@endif
91+
@endisset
9292
</table>
9393
</div>
9494
@endif

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@
5050
colspan="{{ $colspan }}"
5151
>
5252
<div>
53+
@php /** @var \Rappasoft\LaravelLivewireTables\Views\Column $column */ @endphp
5354
@foreach($columns as $colIndex => $column)
5455
@continue($column->isHidden())
5556
@continue($this->columnSelectIsEnabled() && ! $this->columnSelectIsEnabledForColumn($column))
5657

5758
<p wire:key="{{ $tableName }}-row-{{ $row->{$primaryKey} }}-collapsed-contents-{{ $colIndex }}"
58-
59+
5960
@class([
6061
'block mb-2' => $isTailwind && $column->shouldCollapseAlways(),
6162
'block mb-2 sm:hidden' => $isTailwind && !$column->shouldCollapseAlways() && !$column->shouldCollapseOnTablet() && !$column->shouldCollapseOnMobile(),
6263
'block mb-2 md:hidden' => $isTailwind && !$column->shouldCollapseAlways() && !$column->shouldCollapseOnTablet() && $column->shouldCollapseOnMobile(),
6364
'block mb-2 lg:hidden' => $isTailwind && !$column->shouldCollapseAlways() && ($column->shouldCollapseOnTablet() || $column->shouldCollapseOnMobile()),
64-
65+
6566
'd-block mb-2' => $isBootstrap && $column->shouldCollapseAlways(),
6667
'd-block mb-2 d-sm-none' => $isBootstrap && !$column->shouldCollapseAlways() && !$column->shouldCollapseOnTablet() && !$column->shouldCollapseOnMobile(),
6768
'd-block mb-2 d-md-none' => $isBootstrap && !$column->shouldCollapseAlways() && !$column->shouldCollapseOnTablet() && $column->shouldCollapseOnMobile(),

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

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

44
@php
5+
/** @var \Rappasoft\LaravelLivewireTables\Views\Column $column */
56
$customAttributes = $this->getTdAttributes($column, $row, $colIndex, $rowIndex)
67
@endphp
78

89
<td wire:key="{{ $tableName . '-table-td-'.$row->{$primaryKey}.'-'.$column->getSlug() }}"
910
@if ($column->isClickable())
10-
@if($this->getTableRowUrlTarget($row) === "navigate") wire:navigate href="{{ $this->getTableRowUrl($row) }}"
11+
@if($this->getTableRowUrlTarget($row) === 'navigate') wire:navigate href="{{ $this->getTableRowUrl($row) }}"
1112
@else onclick="window.open('{{ $this->getTableRowUrl($row) }}', '{{ $this->getTableRowUrlTarget($row) ?? '_self' }}')"
1213
@endif
1314
@endif

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@aware(['component', 'rowIndex', 'rowID','isTailwind','isBootstrap'])
22
@props(['column' => null, 'customAttributes' => [], 'displayMinimisedOnReorder' => false, 'hideUntilReorder' => false])
33

4+
@php /** @var \Rappasoft\LaravelLivewireTables\Views\Column|null $column */ @endphp
5+
46
@if ($isTailwind)
57
<td x-cloak {{ $attributes
68
->merge($customAttributes)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@props(['column', 'index'])
33

44
@php
5+
/** @var \Rappasoft\LaravelLivewireTables\Views\Column $column */
56
$attributes = $attributes->merge(['wire:key' => $tableName . '-header-col-'.$column->getSlug()]);
67
$allThAttributes = $this->getAllThAttributes($column);
78
@@ -41,7 +42,7 @@
4142
}}
4243
>
4344
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
44-
<x-livewire-tables::table.th.sort-icons :$direction
45+
<x-livewire-tables::table.th.sort-icons :$direction
4546
{{
4647
$attributes->merge($customSortIconAttributes)
4748
->except(['default', 'default-colors', 'default-styling', 'wire:key'])

resources/views/components/tools.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@aware(['component','isTailwind','isBootstrap'])
22
@php($toolsAttributes = $this->getToolsAttributesBag())
33

4-
<div {{
4+
<div {{
55
$toolsAttributes->merge()
66
->class(['flex-col' => $isTailwind && ($toolsAttributes['default-styling'] ?? true)])
77
->class(['d-flex flex-column' => $isBootstrap && ($toolsAttributes['default-styling'] ?? true)])
8-
->except(['default','default-styling','default-colors'])
8+
->except(['default','default-styling','default-colors'])
99
}}
1010
>
1111
{{ $slot }}

resources/views/components/tools/filter-label.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
@props(['filter', 'filterLayout' => 'popover', 'tableName' => 'table', 'isTailwind' => false, 'isBootstrap' => false, 'isBootstrap4' => false, 'isBootstrap5' => false, 'for' => null])
33

44
@php
5+
/** @var \Rappasoft\LaravelLivewireTables\Views\Filter $filter */
56
$filterLabelAttributes = $filter->getFilterLabelAttributes();
67
$customLabelAttributes = $filter->getLabelAttributes();
7-
88
@endphp
9+
910
@if($filter->hasCustomFilterLabel() && !$filter->hasCustomPosition())
1011
@include($filter->getCustomFilterLabel(),['filter' => $filter, 'filterLayout' => $filterLayout, 'tableName' => $tableName, 'isTailwind' => $isTailwind, 'isBootstrap' => $isBootstrap, 'isBootstrap4' => $isBootstrap4, 'isBootstrap5' => $isBootstrap5, 'customLabelAttributes' => $customLabelAttributes])
1112
@elseif(!$filter->hasCustomPosition())
@@ -14,13 +15,12 @@
1415
{{
1516
$attributes->merge($customLabelAttributes)->merge($filterLabelAttributes)
1617
->class(['block text-sm font-medium leading-5 text-gray-700 dark:text-white' => $isTailwind && ($filterLabelAttributes['default'] ?? true)])
17-
->class(['d-block' => $isBootstrap && $filterLayout == 'slide-down' && ($filterLabelAttributes['default'] ?? true)])
18-
->class(['mb-2' => $isBootstrap && $filterLayout == 'popover' && ($filterLabelAttributes['default'] ?? true)])
18+
->class(['d-block' => $isBootstrap && $filterLayout === 'slide-down' && ($filterLabelAttributes['default'] ?? true)])
19+
->class(['mb-2' => $isBootstrap && $filterLayout === 'popover' && ($filterLabelAttributes['default'] ?? true)])
1920
->except(['default', 'default-colors', 'default-styling'])
2021
}}
2122

2223
>
2324
{{ $filter->getName() }}
2425
</label>
25-
2626
@endif

resources/views/components/tools/filter-pills.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
</small>
1515

1616
@foreach($this->getAppliedFiltersWithValues() as $filterSelectName => $value)
17+
@php /** @var \Rappasoft\LaravelLivewireTables\Views\Filter $filter */ @endphp
1718
@php($filter = $this->getFilterByKey($filterSelectName))
1819
@continue(is_null($filter) || $filter->isHiddenFromPills())
1920
@php( $filterPillTitle = $filter->getFilterPillTitle())
@@ -31,4 +32,3 @@
3132
</div>
3233
</div>
3334
@endif
34-

0 commit comments

Comments
 (0)