$theme === 'tailwind',
- 'form-check' => $theme === 'bootstrap-5',
+ 'inline-flex rounded-md shadow-sm' => $this->isTailwind,
+ 'form-check' => $this->isBootstrap,
])
>
merge($bulkActionsThCheckboxAttributes)->class([
- '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') && ($bulkActionsThCheckboxAttributes['default'] ?? true),
- 'form-check-input' => ($theme === 'bootstrap-5') && ($bulkActionsThCheckboxAttributes['default'] ?? true),
+ '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 && (($bulkActionsThCheckboxAttributes['default'] ?? true) || ($bulkActionsThCheckboxAttributes['default-colors'] ?? true)),
+ 'rounded shadow-sm transition duration-150 ease-in-out focus:ring focus:ring-opacity-50 ' => $this->isTailwind && (($bulkActionsThCheckboxAttributes['default'] ?? true) || ($bulkActionsThCheckboxAttributes['default-styling'] ?? true)),
+ 'form-check-input' => $this->isBootstrap && ($bulkActionsThCheckboxAttributes['default'] ?? true),
])->except(['default','default-styling','default-colors'])
}}
/>
diff --git a/resources/views/components/table/th/collapsed-columns.blade.php b/resources/views/components/table/th/collapsed-columns.blade.php
index eebc53e70..ad8a1860d 100644
--- a/resources/views/components/table/th/collapsed-columns.blade.php
+++ b/resources/views/components/table/th/collapsed-columns.blade.php
@@ -1,29 +1,15 @@
-@aware([ 'tableName','isTailwind','isBootstrap'])
-
-@if ($this->collapsingColumnsAreEnabled() && $this->hasCollapsedColumns())
- @if ($isTailwind)
-
merge(['class' => 'table-cell dark:bg-gray-800 laravel-livewire-tables-reorderingMinimised'])
- ->class(['sm:hidden' => !$this->shouldCollapseOnTablet() && !$this->shouldCollapseAlways()])
- ->class(['md:hidden' => !$this->shouldCollapseOnMobile() && !$this->shouldCollapseOnTablet() && !$this->shouldCollapseAlways()])
- ->class(['lg:hidden' => !$this->shouldCollapseAlways()])
- }}
- :class="{ 'laravel-livewire-tables-reorderingMinimised': ! currentlyReorderingStatus }"
- > |
- @elseif ($isBootstrap)
-
merge(['class' => 'd-table-cell laravel-livewire-tables-reorderingMinimised'])
- ->class(['d-sm-none' => !$this->shouldCollapseOnTablet() && !$this->shouldCollapseAlways()])
- ->class(['d-md-none' => !$this->shouldCollapseOnMobile() && !$this->shouldCollapseOnTablet() && !$this->shouldCollapseAlways()])
- ->class(['d-lg-none' => !$this->shouldCollapseAlways()])
- }}
- :class="{ 'laravel-livewire-tables-reorderingMinimised': ! currentlyReorderingStatus }"
- > |
- @endif
+@if ($this->collapsingColumnsAreEnabled && $this->hasCollapsedColumns)
+
merge()
+ ->class([
+ 'table-cell dark:bg-gray-800 laravel-livewire-tables-reorderingMinimised' => $this->isTailwind,
+ 'sm:hidden' => $this->isTailwind && !$this->shouldCollapseOnTablet && !$this->shouldCollapseAlways,
+ 'md:hidden' => $this->isTailwind && !$this->shouldCollapseOnMobile && !$this->shouldCollapseOnTablet && !$this->shouldCollapseAlways,
+ 'lg:hidden' => $this->isTailwind && !$this->shouldCollapseAlways,
+ 'd-table-cell laravel-livewire-tables-reorderingMinimised' => $this->isBootstrap,
+ 'd-sm-none' => $this->isBootstrap && !$this->shouldCollapseOnTablet && !$this->shouldCollapseAlways,
+ 'd-md-none' => $this->isBootstrap && !$this->shouldCollapseOnMobile && !$this->shouldCollapseOnTablet && !$this->shouldCollapseAlways,
+ 'd-lg-none' => $this->isBootstrap && !$this->shouldCollapseAlways,
+ ])
+ }}> |
@endif
diff --git a/resources/views/components/table/th/label.blade.php b/resources/views/components/table/th/label.blade.php
new file mode 100644
index 000000000..bafe25fdb
--- /dev/null
+++ b/resources/views/components/table/th/label.blade.php
@@ -0,0 +1,4 @@
+@props(['columnTitle' => '', 'customLabelAttributes' => ['default' => true]])
+
except(['default', 'default-colors', 'default-styling']) }}>
+ {{ $columnTitle }}
+
diff --git a/resources/views/components/table/th/plain.blade.php b/resources/views/components/table/th/plain.blade.php
index 0b9c8326e..b15d56d0f 100644
--- a/resources/views/components/table/th/plain.blade.php
+++ b/resources/views/components/table/th/plain.blade.php
@@ -1,14 +1,11 @@
-@aware(['isTailwind','isBootstrap'])
@props(['displayMinimisedOnReorder' => false, 'hideUntilReorder' => false, 'customAttributes' => ['default' => true]])
-
merge($customAttributes)->class([
- 'table-cell px-3 py-2 md:px-6 md:py-3 text-center md:text-left bg-gray-50 dark:bg-gray-800 laravel-livewire-tables-reorderingMinimised' => ($isTailwind) && (($customAttributes['default-colors'] ?? true) || ($customAttributes['default'] ?? true)),
- 'laravel-livewire-tables-reorderingMinimised' => ($isBootstrap) && (($customAttributes['default-colors'] ?? true) || ($customAttributes['default'] ?? true)),
- ])
- }}
- @if($hideUntilReorder) :class="!reorderDisplayColumn && 'w-0 p-0 hidden'" @endif
->
+ 'table-cell px-3 py-2 md:px-6 md:py-3 text-center md:text-left laravel-livewire-tables-reorderingMinimised' => $this->isTailwind && (($customAttributes['default-styling'] ?? true) || ($customAttributes['default'] ?? true)),
+ 'bg-gray-50 dark:bg-gray-800' => $this->isTailwind && (($customAttributes['default-colors'] ?? true) || ($customAttributes['default'] ?? true)),
+ 'laravel-livewire-tables-reorderingMinimised' => $this->isBootstrap && (($customAttributes['default-colors'] ?? true) || ($customAttributes['default'] ?? true)),
+ ])->except(['default','default-styling','default-colors'])
+}}>
{{ $slot }}
|
diff --git a/resources/views/components/table/th/reorder.blade.php b/resources/views/components/table/th/reorder.blade.php
index e4fe7cecb..a3b1f7e86 100644
--- a/resources/views/components/table/th/reorder.blade.php
+++ b/resources/views/components/table/th/reorder.blade.php
@@ -1,14 +1,16 @@
-@aware(['tableName','isTailwind','isBootstrap'])
@php
$customThAttributes = $this->hasReorderThAttributes() ? $this->getReorderThAttributes() : $this->getAllThAttributes($this->getReorderColumn())['customAttributes'];
@endphp
-
merge($customThAttributes)
- ->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true))])
- ->class(['table-cell px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true))])
- ->class(['laravel-livewire-tables-reorderingMinimised' => ($isBootstrap) && ($customThAttributes['default'] ?? true)])
+ ->class([
+ 'table-cell px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => $this->isTailwind && (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true)),
+ 'text-gray-500 dark:bg-gray-800 dark:text-gray-400' => $this->isTailwind && (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true)),
+ 'laravel-livewire-tables-reorderingMinimised' => $this->isBootstrap && ($customThAttributes['default'] ?? true),
+ ])
+ ->except(['default','default-styling','default-colors'])
}}
>
diff --git a/resources/views/components/table/th/sort-icons.blade.php b/resources/views/components/table/th/sort-icons.blade.php
index b26b7d964..f08cd3473 100644
--- a/resources/views/components/table/th/sort-icons.blade.php
+++ b/resources/views/components/table/th/sort-icons.blade.php
@@ -1,32 +1,79 @@
-@props(['direction'])
-class([
+@props(['direction' => 'none', 'customIconAttributes'])
+ $this->isTailwind,
'relative d-flex align-items-center' => $this->isBootstrap
- ]) }}
+ ])
>
+
@if($this->isTailwind)
@switch($direction)
@case('asc')
-
-
- @break
+ merge($customIconAttributes)
+ ->class([
+ 'w-3 h-3' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ 'absolute opacity-100 group-hover:opacity-0',
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
+ merge($customIconAttributes)
+ ->class([
+ 'w-3 h-3' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ 'absolute opacity-0 group-hover:opacity-100',
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
+ @break
@case('desc')
-
-
- @break
+ merge($customIconAttributes)
+ ->class([
+ 'w-3 h-3' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ 'absolute opacity-100 group-hover:opacity-0',
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
+ merge($customIconAttributes)
+ ->class([
+ 'w-3 h-3' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ 'absolute opacity-0 group-hover:opacity-100',
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
+
+ @break
@default
-
- @endswitch
+ merge($customIconAttributes)
+ ->class([
+ 'w-3 h-3' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ 'absolute opacity-100 group-hover:opacity-0',
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
+ merge($customIconAttributes)
+ ->class([
+ 'w-3 h-3' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ 'absolute opacity-0 group-hover:opacity-100',
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
+ @endswitch
+
+
@else
@switch($direction)
@case('asc')
-
+ merge($customIconAttributes)
+ ->class([
+ 'laravel-livewire-tables-btn-smaller ms-1' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
@break
@case('desc')
-
+ merge($customIconAttributes)
+ ->class([
+ 'laravel-livewire-tables-btn-smaller ms-1' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
@break
@default
-
+ merge($customIconAttributes)
+ ->class([
+ 'laravel-livewire-tables-btn-smaller ms-1' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
+ ])
+ ->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
@endswitch
@endif
diff --git a/resources/views/datatable.blade.php b/resources/views/datatable.blade.php
index 7b90b7734..4b4feab5a 100644
--- a/resources/views/datatable.blade.php
+++ b/resources/views/datatable.blade.php
@@ -68,7 +68,7 @@
@endif
@foreach($this->selectedVisibleColumns as $index => $column)
-
+
@endforeach
@@ -84,19 +84,19 @@
@endif
@forelse ($this->getRows as $rowIndex => $row)
-
+
@if($this->getCurrentlyReorderingStatus)
-
+
@endif
@if($this->showBulkActionsSections)
-
+
@endif
@if ($this->showCollapsingColumnSections)
-
+
@endif
@foreach($this->selectedVisibleColumns as $colIndex => $column)
-
+
@if($column->isHtml())
{!! $column->setIndexes($rowIndex, $colIndex)->renderContents($row) !!}
@else
@@ -107,7 +107,7 @@
@if ($this->showCollapsingColumnSections)
-
+
@endif
@empty
diff --git a/src/Commands/MakeCommand.php b/src/Commands/MakeCommand.php
index bf06570ae..cc974885f 100644
--- a/src/Commands/MakeCommand.php
+++ b/src/Commands/MakeCommand.php
@@ -126,7 +126,7 @@ public function getModelImport(): string
if (isset($this->modelPath)) {
$filename = rtrim($this->modelPath, '/').'/'.$this->model.'.php';
if (File::exists($filename)) {
- //In case the file has more than one class which is highly unlikely but still possible
+ // In case the file has more than one class which is highly unlikely but still possible
$classes = array_filter($this->getClassesList($filename), function ($class) {
return substr($class, strrpos($class, '\\') + 1) == $this->model;
});
diff --git a/src/Traits/Helpers/CollapsingColumnHelpers.php b/src/Traits/Helpers/CollapsingColumnHelpers.php
index 131e43b65..e80e9da64 100644
--- a/src/Traits/Helpers/CollapsingColumnHelpers.php
+++ b/src/Traits/Helpers/CollapsingColumnHelpers.php
@@ -11,11 +11,13 @@ public function getCollapsingColumnsStatus(): bool
return $this->collapsingColumnsStatus;
}
+ #[Computed]
public function hasCollapsingColumns(): bool
{
return $this->getCollapsingColumnsStatus() === true;
}
+ #[Computed]
public function collapsingColumnsAreEnabled(): bool
{
return $this->getCollapsingColumnsStatus() === true;
diff --git a/src/Traits/Helpers/ColumnHelpers.php b/src/Traits/Helpers/ColumnHelpers.php
index 487bcb879..830756a0c 100644
--- a/src/Traits/Helpers/ColumnHelpers.php
+++ b/src/Traits/Helpers/ColumnHelpers.php
@@ -3,6 +3,7 @@
namespace Rappasoft\LaravelLivewireTables\Traits\Helpers;
use Illuminate\Support\Collection;
+use Livewire\Attributes\Computed;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\AggregateColumn;
@@ -133,6 +134,7 @@ public function hasCollapsedColumns(): bool
return false;
}
+ #[Computed]
public function shouldCollapseOnMobile(): bool
{
@@ -170,6 +172,7 @@ public function getVisibleMobileColumnsCount(): int
return $this->getVisibleMobileColumns()->count();
}
+ #[Computed]
public function shouldCollapseOnTablet(): bool
{
if (! isset($this->shouldTabletCollapse)) {
@@ -235,6 +238,7 @@ public function getCollapsedAlwaysColumnsCount(): int
return $this->getCollapsedAlwaysColumns()->count();
}
+ #[Computed]
public function shouldCollapseAlways(): bool
{
if (! isset($this->shouldAlwaysCollapse)) {
diff --git a/src/Traits/Helpers/TableAttributeHelpers.php b/src/Traits/Helpers/TableAttributeHelpers.php
index 5c8125fa9..36971ab3e 100644
--- a/src/Traits/Helpers/TableAttributeHelpers.php
+++ b/src/Traits/Helpers/TableAttributeHelpers.php
@@ -47,7 +47,7 @@ public function getThAttributes(Column $column): array
{
if (isset($this->thAttributesCallback)) {
- return array_merge(['default' => false, 'default-colors' => false, 'default-styling' => false], call_user_func($this->thAttributesCallback, $column));
+ return array_merge(['scope' => 'col', 'default' => false, 'default-colors' => false, 'default-styling' => false], call_user_func($this->thAttributesCallback, $column));
}
return ['default' => true, 'default-colors' => true, 'default-styling' => true];
diff --git a/src/Traits/WithData.php b/src/Traits/WithData.php
index b2d191031..e7b52518a 100644
--- a/src/Traits/WithData.php
+++ b/src/Traits/WithData.php
@@ -21,7 +21,7 @@ trait WithData
*/
public function bootedWithData(): void
{
- //Sets up the Builder Instance
+ // Sets up the Builder Instance
$this->setBuilder($this->builder());
}
diff --git a/src/Traits/WithReordering.php b/src/Traits/WithReordering.php
index 49d36f78f..ae5be34cb 100644
--- a/src/Traits/WithReordering.php
+++ b/src/Traits/WithReordering.php
@@ -51,13 +51,10 @@ public function enablePaginatedReordering(): void {}
public function enableReordering(): void
{
- //$this->enablePaginatedReordering();
-
$this->setReorderingSession();
$this->setReorderingBackup();
$this->resetReorderFields();
$this->reorderStatus = $this->currentlyReorderingStatus = $this->reorderDisplayColumn = true;
-
}
public function disableReordering(): void
diff --git a/src/Views/Traits/Filters/HasCustomPosition.php b/src/Views/Traits/Filters/HasCustomPosition.php
index 443baf749..4bdb670ee 100644
--- a/src/Views/Traits/Filters/HasCustomPosition.php
+++ b/src/Views/Traits/Filters/HasCustomPosition.php
@@ -67,7 +67,6 @@ public function hasFilterSlidedownColspan(): bool
public function setFilterSlidedownRow(string $filterSlidedownRow): self
{
- //$this->filterSlidedownRow = (is_int($filterSlidedownRow) ? $filterSlidedownRow : intval($filterSlidedownRow));
$this->filterSlidedownRow = intval($filterSlidedownRow);
return $this;
@@ -75,7 +74,6 @@ public function setFilterSlidedownRow(string $filterSlidedownRow): self
public function setFilterSlidedownColspan(string $filterSlidedownColspan): self
{
- //$this->filterSlidedownColspan = (is_int($filterSlidedownColspan) ? $filterSlidedownColspan : intval($filterSlidedownColspan));
$this->filterSlidedownColspan = intval($filterSlidedownColspan);
return $this;
diff --git a/tests/DataTableComponentTest.php b/tests/DataTableComponentTest.php
index 8237e8411..e0849463c 100644
--- a/tests/DataTableComponentTest.php
+++ b/tests/DataTableComponentTest.php
@@ -2,7 +2,6 @@
namespace Rappasoft\LaravelLivewireTables\Tests;
-use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\NoColumnsTable;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\FailingTables\NoPrimaryKeyTable;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
@@ -27,13 +26,6 @@ public function test_primary_key_can_be_checked_for_existence(): void
$this->assertFalse($this->basicTable->hasPrimaryKey());
}
- public function test_primary_key_has_to_be_set(): void
- {
- $this->expectException(\Illuminate\View\ViewException::class);
- Livewire::test(NoPrimaryKeyTable::class)
- ->call('setSearch', 'abcd');
- }
-
public function test_default_fingerprint_will_always_be_the_same_for_same_datatable(): void
{
$this->assertSame(
diff --git a/tests/Localisations/BaseLocalisationCase.php b/tests/Localisations/BaseLocalisationCase.php
index 595c019e7..e3ae15093 100644
--- a/tests/Localisations/BaseLocalisationCase.php
+++ b/tests/Localisations/BaseLocalisationCase.php
@@ -57,10 +57,10 @@ public static function localisationProvider(): array
'tw',
'uk',
];
- //return $availableLocales;
+ // return $availableLocales;
foreach ($availableLocales as $availableLocale) {
- //$array = require($baseDir.$availableLocale.'/core.php');
+ // $array = require($baseDir.$availableLocale.'/core.php');
$localisations[] = [
'locale' => $availableLocale,
// 'localisationStrings' => $array,
diff --git a/tests/Unit/Traits/Configuration/ComponentConfigurationTest.php b/tests/Unit/Traits/Configuration/ComponentConfigurationTest.php
index a477cf06c..bd593eeab 100644
--- a/tests/Unit/Traits/Configuration/ComponentConfigurationTest.php
+++ b/tests/Unit/Traits/Configuration/ComponentConfigurationTest.php
@@ -73,8 +73,8 @@ public function test_can_set_th_attributes(): void
return ['default' => true, 'here' => 'there'];
});
- $this->assertSame($this->basicTable->getThAttributes($this->basicTable->columns()[0]), ['default' => false, 'default-colors' => false, 'default-styling' => false, 'this' => 'that']);
- $this->assertSame($this->basicTable->getThAttributes($this->basicTable->columns()[1]), ['default' => true, 'default-colors' => false, 'default-styling' => false, 'here' => 'there']);
+ $this->assertSame($this->basicTable->getThAttributes($this->basicTable->columns()[0]), ['scope' => 'col', 'default' => false, 'default-colors' => false, 'default-styling' => false, 'this' => 'that']);
+ $this->assertSame($this->basicTable->getThAttributes($this->basicTable->columns()[1]), ['scope' => 'col', 'default' => true, 'default-colors' => false, 'default-styling' => false, 'here' => 'there']);
}
public function test_can_set_th_sort_button_attributes(): void
diff --git a/tests/Unit/Traits/Helpers/ColumnHelpersTest.php b/tests/Unit/Traits/Helpers/ColumnHelpersTest.php
index cfebce832..ec4f3814b 100644
--- a/tests/Unit/Traits/Helpers/ColumnHelpersTest.php
+++ b/tests/Unit/Traits/Helpers/ColumnHelpersTest.php
@@ -205,7 +205,7 @@ public function test_can_get_visible_tablet_columns_count(): void
$this->assertSame(7, $this->basicTable->getVisibleTabletColumnsCount());
}
- /// *** ** //
+ // / *** ** //
public function test_can_tell_if_columns_should_collapse_always(): void
{
@@ -299,7 +299,7 @@ public function test_can_check_if_column_has_secondary_header_filter(): void
$this->assertTrue($column->hasSecondaryHeaderCallback());
$contents = $column->getSecondaryHeaderFilter($this->basicTable->getFilterByKey($column->getSecondaryHeaderCallback()), $this->basicTable->getFilterGenericData());
- //$contents = $column->getSecondaryHeaderFilter($this->basicTable->getFilterByKey('breed'));
+ // $contents = $column->getSecondaryHeaderFilter($this->basicTable->getFilterByKey('breed'));
$this->assertStringContainsString('id="table-filter-breed-8-header"', $contents);
}
diff --git a/tests/Unit/Traits/Helpers/ComponentHelpersTest.php b/tests/Unit/Traits/Helpers/ComponentHelpersTest.php
index 6fbbf6364..d9deb58f4 100644
--- a/tests/Unit/Traits/Helpers/ComponentHelpersTest.php
+++ b/tests/Unit/Traits/Helpers/ComponentHelpersTest.php
@@ -244,7 +244,7 @@ public function test_can_get_hide_configurable_areas_when_reordering_status(): v
// Exists in DataTableComponentTest
// public function test_can_get_dataTable_fingerprint(): void
- //{
+ // {
// $this->assertSame($this->defaultFingerPrintingAlgo($this->basicTable::class), $this->basicTable->getDataTableFingerprint());
// }
diff --git a/tests/Unit/Traits/WithCustomisationsTest.php b/tests/Unit/Traits/WithCustomisationsTest.php
index 64ccf4d36..e5101454f 100644
--- a/tests/Unit/Traits/WithCustomisationsTest.php
+++ b/tests/Unit/Traits/WithCustomisationsTest.php
@@ -2,43 +2,12 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Traits;
-use Livewire\Component;
use Livewire\Features\SupportPageComponents\PageComponentConfig;
-use Livewire\Livewire;
use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
final class WithCustomisationsTest extends TestCase
{
- public function test_can_use_as_nested(): void
- {
- $test = Livewire::test([new class extends Component
- {
- public function render()
- {
- return <<<'HTML'
-
-
ParentComponentTest
-
-
- HTML;
- }
- },
- 'child' => new class extends PetsTable
- {
- public function configure(): void
- {
- parent::configure();
- $this->setLayout('livewire-tables::tests.layout1');
-
- }
- },
- ])
- ->assertSee('ParentComponentTest')
- ->assertSee('Cartman');
-
- }
-
public function test_can_use_as_full_page(): void
{
$temp = new class extends PetsTable
diff --git a/tests/Unit/Views/Columns/DateColumnTest.php b/tests/Unit/Views/Columns/DateColumnTest.php
index 1b3e96a94..876bb9bda 100644
--- a/tests/Unit/Views/Columns/DateColumnTest.php
+++ b/tests/Unit/Views/Columns/DateColumnTest.php
@@ -2,7 +2,7 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
-//use Illuminate\Support\Facades\Exceptions;
+// use Illuminate\Support\Facades\Exceptions;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\DateColumn;
diff --git a/tests/Unit/Views/Columns/IconColumnTest.php b/tests/Unit/Views/Columns/IconColumnTest.php
index 3696bbc67..a6a609939 100644
--- a/tests/Unit/Views/Columns/IconColumnTest.php
+++ b/tests/Unit/Views/Columns/IconColumnTest.php
@@ -2,7 +2,7 @@
namespace Rappasoft\LaravelLivewireTables\Tests\Unit\Views\Columns;
-//use Illuminate\Support\Facades\Exceptions;
+// use Illuminate\Support\Facades\Exceptions;
use Rappasoft\LaravelLivewireTables\Tests\Models\Pet;
use Rappasoft\LaravelLivewireTables\Tests\TestCase;
use Rappasoft\LaravelLivewireTables\Views\Columns\IconColumn;
diff --git a/tests/Unit/Visuals/BulkActionsVisualsTest.php b/tests/Unit/Visuals/BulkActionsVisualsTest.php
index 32f0a57cc..59570f3cd 100644
--- a/tests/Unit/Visuals/BulkActionsVisualsTest.php
+++ b/tests/Unit/Visuals/BulkActionsVisualsTest.php
@@ -192,7 +192,7 @@ public function exportBulk($items)
})->assertDontSee('Bulk Actions');
}
- public function test_bulk_dropdown_can_have_customised_classes(): void
+ public function test_bulk_dropdown_can_have_customised_classes_with_no_defaults(): void
{
Livewire::test(new class extends PetsTable
{
@@ -202,7 +202,7 @@ public function configure(): void
$this->setBulkActionsThAttributes([
'class' => 'bg-yellow-500 dark:bg-yellow-800',
'default' => false,
- 'default-styling' => true,
+ 'default-styling' => false,
'default-colors' => false,
]);
@@ -224,4 +224,103 @@ public function exportBulk($items)
'wire:key="table-thead-bulk-actions"',
]);
}
+
+ public function test_bulk_dropdown_can_have_customised_classes_with_default_styling(): void
+ {
+ Livewire::test(new class extends PetsTable
+ {
+ public function configure(): void
+ {
+ $this->setPrimaryKey('id');
+ $this->setBulkActionsThAttributes([
+ 'class' => 'bg-yellow-500 dark:bg-yellow-800',
+ 'default' => false,
+ 'default-styling' => true,
+ 'default-colors' => false,
+ ]);
+
+ }
+
+ public function bulkActions(): array
+ {
+ return ['exportBulk' => 'exportBulk'];
+ }
+
+ public function exportBulk($items)
+ {
+ return $items;
+ }
+ })->assertSee('Bulk Actions')
+ ->assertSeeHtmlInOrder([
+ 'scope="col"',
+ 'class="table-cell px-3 py-2 md:px-6 md:py-3 text-center md:text-left laravel-livewire-tables-reorderingMinimised bg-yellow-500 dark:bg-yellow-800"',
+ 'wire:key="table-thead-bulk-actions"',
+ ]);
+ }
+
+ public function test_bulk_dropdown_can_have_customised_classes_with_default_colors(): void
+ {
+ Livewire::test(new class extends PetsTable
+ {
+ public function configure(): void
+ {
+ $this->setPrimaryKey('id');
+ $this->setBulkActionsThAttributes([
+ 'class' => 'text-lg',
+ 'default' => false,
+ 'default-styling' => false,
+ 'default-colors' => true,
+ ]);
+
+ }
+
+ public function bulkActions(): array
+ {
+ return ['exportBulk' => 'exportBulk'];
+ }
+
+ public function exportBulk($items)
+ {
+ return $items;
+ }
+ })->assertSee('Bulk Actions')
+ ->assertSeeHtmlInOrder([
+ 'scope="col"',
+ 'class="bg-gray-50 dark:bg-gray-800 text-lg"',
+ 'wire:key="table-thead-bulk-actions"',
+ ]);
+ }
+
+ public function test_bulk_dropdown_can_have_customised_classes_with_defaults(): void
+ {
+ Livewire::test(new class extends PetsTable
+ {
+ public function configure(): void
+ {
+ $this->setPrimaryKey('id');
+ $this->setBulkActionsThAttributes([
+ 'class' => 'text-lg',
+ 'default' => true,
+ 'default-styling' => true,
+ 'default-colors' => true,
+ ]);
+
+ }
+
+ public function bulkActions(): array
+ {
+ return ['exportBulk' => 'exportBulk'];
+ }
+
+ public function exportBulk($items)
+ {
+ return $items;
+ }
+ })->assertSee('Bulk Actions')
+ ->assertSeeHtmlInOrder([
+ 'scope="col"',
+ 'class="table-cell px-3 py-2 md:px-6 md:py-3 text-center md:text-left laravel-livewire-tables-reorderingMinimised bg-gray-50 dark:bg-gray-800 text-lg"',
+ 'wire:key="table-thead-bulk-actions"',
+ ]);
+ }
}
diff --git a/tests/Unit/Visuals/CustomisationsVisualsTest.php b/tests/Unit/Visuals/CustomisationsVisualsTest.php
new file mode 100644
index 000000000..55a6da4e1
--- /dev/null
+++ b/tests/Unit/Visuals/CustomisationsVisualsTest.php
@@ -0,0 +1,46 @@
+
+ ParentComponentTest
+
+
+ HTML;
+ }
+ },
+ 'child' => new class extends PetsTable
+ {
+ public function configure(): void
+ {
+ parent::configure();
+ $this->setLayout('livewire-tables::tests.layout1');
+
+ }
+ },
+ ])
+ ->assertSee('ParentComponentTest')
+ ->assertSee('Cartman');
+
+ }
+}
diff --git a/tests/Unit/Visuals/DataTableComponentVisualsTest.php b/tests/Unit/Visuals/DataTableComponentVisualsTest.php
new file mode 100644
index 000000000..29fd9f01e
--- /dev/null
+++ b/tests/Unit/Visuals/DataTableComponentVisualsTest.php
@@ -0,0 +1,24 @@
+expectException(\Illuminate\View\ViewException::class);
+ Livewire::test(NoPrimaryKeyTable::class)
+ ->call('setSearch', 'abcd');
+ }
+}
diff --git a/tests/Unit/Visuals/SortingVisualsTest.php b/tests/Unit/Visuals/SortingVisualsTest.php
index 6a6333445..6a9df4714 100644
--- a/tests/Unit/Visuals/SortingVisualsTest.php
+++ b/tests/Unit/Visuals/SortingVisualsTest.php
@@ -37,7 +37,7 @@ public function test_th_headers_are_buttons_with_sorting_enabled(): void
Livewire::test(PetsTable::class)
->assertSeeHtmlInOrder([
'wire:click="sortBy(\'id\')"',
- 'class="flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none text-gray-500 dark:text-gray-400"',
+ 'class="text-gray-500 dark:text-gray-400 flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none"',
]);
}
@@ -58,12 +58,12 @@ public function test_th_headers_are_not_buttons_until_sorting_enabled(): void
->call('setSortingDisabled')
->assertDontSeeHtml('