Skip to content

Commit 761f8ae

Browse files
committed
Adjust Search
1 parent f18ec67 commit 761f8ae

File tree

11 files changed

+62
-44
lines changed

11 files changed

+62
-44
lines changed

resources/views/components/bulk-actions/thead/thead.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
@aware([ 'tableName', 'isTailwind', 'isBootstrap', 'localisationPath'])
1+
@aware([ 'tableName', 'isTailwind', 'isBootstrap', 'localisationPath', 'collapsingColumnInfo'])
22

33
@if ($this->bulkActionsAreEnabled() && $this->hasBulkActions())
44
@php
5-
$colspan = $this->getColspanCount();
5+
$colspan = $collapsingColumnInfo['colspanCount'];
66
$selectAll = $this->selectAllIsEnabled();
77
$simplePagination = $this->isPaginationMethod('simple');
88
@endphp

resources/views/components/bulk-actions/tr.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
@aware([ 'tableName', 'isTailwind', 'isBootstrap', 'localisationPath'])
1+
@aware([ 'tableName', 'isTailwind', 'isBootstrap', 'localisationPath', 'collapsingColumnInfo'])
22

33
@if ($this->bulkActionsAreEnabled() && $this->hasBulkActions())
44
@php
5-
$colspan = $this->getColspanCount();
5+
$colspan = $collapsingColumnInfo['colspanCount'];
66
$selectAll = $this->selectAllIsEnabled();
77
$simplePagination = $this->isPaginationMethod('simple');
88
@endphp

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
->except(['default','default-styling','default-colors'])
1919
}}
2020
>
21-
<td colspan="{{ $this->getColspanCount() }}" @class([
21+
<td colspan="{{ $collapsingColumnInfo['colspanCount'] }}" @class([
2222
'text-left pt-4 pb-2 px-4' => $isTailwind,
2323
'text-start pt-3 p-2' => $isBootstrap,
2424
])>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
->except(['default','default-styling','default-colors'])
1919
}}
2020
>
21-
<td colspan="{{ $this->getColspanCount() }}" @class([
21+
<td colspan="{{ $collapsingColumnInfo['colspanCount'] }}" @class([
2222
'text-left pt-4 pb-2 px-4' => $isTailwind,
2323
'text-start pt-3 p-2' => $isBootstrap,
2424
])>

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

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

33
<tr {{ $attributes->merge(['wire:key' => 'empty-message-'.$this->getId()]) }}>
4-
<td colspan="{{ $this->getColspanCount() }}">
4+
<td colspan="{{ $collapsingColumnInfo['colspanCount'] }}">
55
@if ($isTailwind)
66
<div class="flex justify-center items-center space-x-2 dark:bg-gray-800">
77
<span class="font-medium py-8 text-gray-400 text-lg dark:text-white">{{ $this->getEmptyMessage() }}</span>

resources/views/components/tools/toolbar/items/search-field.blade.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

resources/views/components/tools/toolbar/items/search/input.blade.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
@aware(['isTailwind', 'isBootstrap'])
1+
@aware(['isTailwind', 'isBootstrap', 'searchViewAttributes'])
22
<input
3-
wire:model{{ $this->getSearchOptions() }}="search"
4-
placeholder="{{ $this->getSearchPlaceholder() }}"
3+
wire:model{{ $searchViewAttributes['searchOptions'] }}="search"
4+
placeholder="{{ $searchViewAttributes['searchPlaceholder'] }}"
55
type="text"
66
{{
7-
$attributes->merge($this->getSearchFieldAttributes())
7+
$attributes->merge($searchViewAttributes['searchFieldAttributes'])
88
->class($isTailwind ?
99
[
10-
'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-none rounded-l-md focus:ring-0 focus:border-gray-300' => $this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)),
11-
'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-md focus:ring focus:ring-opacity-50' => !$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-styling'] ?? true)),
12-
'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-gray-300' =>$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)),
13-
'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-indigo-300 focus:ring-indigo-200' =>!$this->hasSearch() && (($this->getSearchFieldAttributes()['default'] ?? true) || ($this->getSearchFieldAttributes()['default-colors'] ?? true)),
14-
'block w-full' => !$this->hasSearchIcon(),
15-
'pl-8 pr-4' => $this->hasSearchIcon(),
10+
'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-none rounded-l-md focus:ring-0 focus:border-gray-300' => $searchViewAttributes['hasSearch'] && (($searchViewAttributes['searchFieldAttributes']['default'] ?? true) || ($searchViewAttributes['searchFieldAttributes']['default-styling'] ?? true)),
11+
'rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 rounded-md focus:ring focus:ring-opacity-50' => !$searchViewAttributes['hasSearch'] && (($searchViewAttributes['searchFieldAttributes']['default'] ?? true) || ($searchViewAttributes['searchFieldAttributes']['default-styling'] ?? true)),
12+
'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-gray-300' =>$searchViewAttributes['hasSearch'] && (($searchViewAttributes['searchFieldAttributes']['default'] ?? true) || ($searchViewAttributes['searchFieldAttributes']['default-colors'] ?? true)),
13+
'border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-indigo-300 focus:ring-indigo-200' =>!$searchViewAttributes['hasSearch'] && (($searchViewAttributes['searchFieldAttributes']['default'] ?? true) || ($searchViewAttributes['searchFieldAttributes']['default-colors'] ?? true)),
14+
'block w-full' => !$searchViewAttributes['icon']['hasSearchIcon'],
15+
'pl-8 pr-4' => $searchViewAttributes['icon']['hasSearchIcon'],
1616
] :
1717
[
18-
'form-control' => $this->getSearchFieldAttributes()['default'] ?? true,
19-
'block w-full' => !$this->hasSearchIcon(),
20-
'pl-8 pr-4' => $this->hasSearchIcon(),
18+
'form-control' => $searchViewAttributes['searchFieldAttributes']['default'] ?? true,
19+
'block w-full' => !$searchViewAttributes['icon']['hasSearchIcon'],
20+
'pl-8 pr-4' => $searchViewAttributes['icon']['hasSearchIcon'],
2121
],
2222
)
2323
->except(['default','default-styling','default-colors'])
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@aware(['isTailwind', 'isBootstrap'])
2+
@props(['searchViewAttributes'])
3+
4+
<div
5+
@class([
6+
'mb-3 mb-md-0 input-group' => $isBootstrap,
7+
'rounded-md shadow-sm' => $isTailwind,
8+
'flex' => ($isTailwind && !$searchViewAttributes['icon']['hasSearchIcon']),
9+
'relative inline-flex flex-row' => $searchViewAttributes['icon']['hasSearchIcon'],
10+
])>
11+
12+
@if($searchViewAttributes['icon']['hasSearchIcon'])
13+
<x-livewire-tables::tools.toolbar.items.search.icon :searchIcon="$searchViewAttributes['icon']['searchIcon']" :searchIconClasses="$searchViewAttributes['icon']['classes']" :searchIconOtherAttributes="$searchViewAttributes['icon']['otherAttributes']" />
14+
@endif
15+
16+
<x-livewire-tables::tools.toolbar.items.search.input />
17+
18+
@if ($searchViewAttributes['hasSearch'])
19+
<x-livewire-tables::tools.toolbar.items.search.remove />
20+
@endif
21+
</div>

resources/views/components/tools/toolbar/toolbar.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@aware([ 'tableName','isTailwind','isBootstrap'])
22
@props([])
3-
@php($toolBarAttributes = $this->getToolBarAttributesBag)
3+
@php($toolBarAttributes = $this->getToolBarAttributesBag())
44

55
<div
66
{{
@@ -31,7 +31,7 @@
3131
@endif
3232

3333
@if ($this->showSearchField())
34-
<x-livewire-tables::tools.toolbar.items.search-field />
34+
<x-livewire-tables::tools.toolbar.items.search.search :searchViewAttributes="$this->getSearchViewAttributes()" />
3535
@endif
3636

3737
@if ($this->showFiltersButton())

src/Traits/Core/Search/Styling/HasSearchInput.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,20 @@ public function hasSearchPlaceholder(): bool
4040
{
4141
return $this->searchPlaceholder !== null;
4242
}
43+
44+
public function getSearchViewAttributes(): array
45+
{
46+
return [
47+
'hasSearch' => $this->hasSearch(),
48+
'icon' => [
49+
'classes' => $this->getSearchIconClasses(),
50+
'hasSearchIcon' => $this->hasSearchIcon(),
51+
'searchIcon' => $this->getSearchIcon(),
52+
'otherAttributes' => $this->getSearchIconOtherAttributes(),
53+
],
54+
'searchFieldAttributes' => $this->getSearchFieldAttributes(),
55+
'searchOptions' => $this->getSearchOptions(),
56+
'searchPlaceholder' => $this->getSearchPlaceholder(),
57+
];
58+
}
4359
}

0 commit comments

Comments
 (0)