diff --git a/CHANGELOG.md b/CHANGELOG.md
index 02c0cab4f..20254a641 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,8 +2,12 @@
All notable changes to `laravel-livewire-tables` will be documented in this file
-## [v3.5.0] - 2024-11-06
+## [v3.5.1] - 2024-11-09
+### Bug Fixes
+- Fix NumberFilter bug for string values by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2034
+- Fixes for Filter Pills - Split blades, and ensure invalid filter alues are removed by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2035
+## [v3.5.0] - 2024-11-06
### Bug Fixes
- Issue in multiple places where there is incorrect brackets in conjunction with coalescing operator (??) by @mrl22 in https://github.com/rappasoft/laravel-livewire-tables/pull/2021
- Add Value to BooleanColumn custom view by @lrjoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2010
@@ -22,8 +26,6 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
- Fix missing i18n keys for FR, IT, EN, DE by @khwadj in https://github.com/rappasoft/laravel-livewire-tables/pull/1993
- Add lang Norwegian and Albanian by @channor in https://github.com/rappasoft/laravel-livewire-tables/pull/1988
-
-
## [v3.4.22] - 2024-09-29
### Bug Fixes
- Fix Loading Placeholder Bug - Breaking Table by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1969
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index ad1b2a7cb..df270ea9a 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -5,6 +5,7 @@
# Localisation Contributors
| Language | Contributor(s) |
| --- | --- |
+| Albanian (SQ) | [channor] (https://github.com/channor) |
| Arabic (AR) | None |
| Catalan (CA) | None |
| Brazilian (pt_BR) | [irineujunior](https://github.com/irineujunior)|
@@ -13,15 +14,17 @@
| Dutch (NL) | [siebsie23](https://github.com/siebsie23), [spekkie2002](https://github.com/spekkie2002), [Jerimu](https://github.com/Jerimu) |
| English (EN) | Core Team |
| Finnish (FI) | [devmikromike](https://github.com/devmikromike) |
-| French (FR) | [dgillier](https://github.com/dgillier) |
-| German (DE) | None |
+| French (FR) | [dgillier](https://github.com/dgillier), [khwadj](https://github.com/khwadj)|
+| German (DE) | [khwadj](https://github.com/khwadj) |
| Indonesian (ID) | None |
-| Italian (IT) | Core Team |
+| Italian (IT) | Core Team, [khwadj](https://github.com/khwadj) |
| Malay (MS) | [wanadri](https://github.com/wanadri) |
+| Norwegian (NB) | [channor] (https://github.com/channor) |
| Polish (PL) | [meavric](https://github.com/meavric) |
| Portugese (PT) | None |
| Russian (RU) | None |
| Spanish (ES) | [CristhoferMF](https://github.com/CristhoferMF) |
+| Swedish (SV) | [Aiiion](https://github.com/Aiiion) |
| Thai (TH) | None |
| Turkish (TK) | None |
| Ukrainian (UK) | [Oleksandr-Moik](https://github.com/Oleksandr-Moik) |
\ No newline at end of file
diff --git a/resources/views/components/tools/filter-pills.blade.php b/resources/views/components/tools/filter-pills.blade.php
index 004f82272..b55792b29 100644
--- a/resources/views/components/tools/filter-pills.blade.php
+++ b/resources/views/components/tools/filter-pills.blade.php
@@ -15,84 +15,19 @@
@foreach($this->getAppliedFiltersWithValues() as $filterSelectName => $value)
@php($filter = $this->getFilterByKey($filterSelectName))
-
- @continue(is_null($filter))
- @continue($filter->isHiddenFromPills())
+ @continue(is_null($filter) || $filter->isHiddenFromPills())
+ @php( $filterPillTitle = $filter->getFilterPillTitle())
+ @php( $filterPillValue = $filter->getFilterPillValue($value))
+ @php( $separator = method_exists($filter, 'getPillsSeparator') ? $filter->getPillsSeparator() : ', ')
+ @continue((is_array($filterPillValue) && empty($filterPillValue)))
@if ($filter->hasCustomPillBlade())
@include($filter->getCustomPillBlade(), ['filter' => $filter])
@else
- $isTailwind,
- 'badge badge-pill badge-info d-inline-flex align-items-center' => $isBootstrap4,
- 'badge rounded-pill bg-info d-inline-flex align-items-center' => $isBootstrap5,
- ])
- >
- {{ $filter->getFilterPillTitle() }}:
- @php( $filterPillValue = $filter->getFilterPillValue($value))
- @php( $separator = method_exists($filter, 'getPillsSeparator') ? $filter->getPillsSeparator() : ', ')
-
- @if(is_array($filterPillValue) && !empty($filterPillValue))
- @foreach($filterPillValue as $filterPillArrayValue)
- {{ $filterPillArrayValue }}{!! $separator !!}
- @endforeach
- @else
- {{ $filterPillValue }}
- @endif
-
- @if ($isTailwind)
-
- @else
- ($isBootstrap),
- ])
- >
- $isBootstrap4,
- 'visually-hidden' => $isBootstrap5,
- ])>
- @lang('livewire-tables::Remove filter option')
-
-
-
- @endif
-
+
@endif
@endforeach
-
- @if ($isTailwind)
-
- @else
- $isBootstrap4,
- 'badge rounded-pill bg-light text-dark text-decoration-none' => $isBootstrap5,
- ])
- >
- @lang('livewire-tables::Clear')
-
- @endif
+
@endif
diff --git a/resources/views/components/tools/filter-pills/buttons/reset-all.blade.php b/resources/views/components/tools/filter-pills/buttons/reset-all.blade.php
new file mode 100644
index 000000000..e4b6efb76
--- /dev/null
+++ b/resources/views/components/tools/filter-pills/buttons/reset-all.blade.php
@@ -0,0 +1,25 @@
+@aware(['isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])
+@if ($isTailwind)
+
+@else
+ $isBootstrap4,
+ 'badge rounded-pill bg-light text-dark text-decoration-none' => $isBootstrap5,
+ ])>
+ @lang('livewire-tables::Clear')
+
+@endif
diff --git a/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php b/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php
new file mode 100644
index 000000000..f33073b94
--- /dev/null
+++ b/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php
@@ -0,0 +1,31 @@
+@aware(['tableName','isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])
+@props(['filterKey'])
+@if ($isTailwind)
+
+@else
+ ($isBootstrap),
+ ])
+ >
+ $isBootstrap4,
+ 'visually-hidden' => $isBootstrap5,
+ ])>
+ @lang('livewire-tables::Remove filter option')
+
+
+
+@endif
\ No newline at end of file
diff --git a/resources/views/components/tools/filter-pills/item.blade.php b/resources/views/components/tools/filter-pills/item.blade.php
new file mode 100644
index 000000000..a69edc3a0
--- /dev/null
+++ b/resources/views/components/tools/filter-pills/item.blade.php
@@ -0,0 +1,23 @@
+@aware(['tableName','isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])
+@props(['filterPillTitle', 'filterPillValue', 'filterSelectName', 'separator'])
+ $isTailwind,
+ 'badge badge-pill badge-info d-inline-flex align-items-center' => $isBootstrap4,
+ 'badge rounded-pill bg-info d-inline-flex align-items-center' => $isBootstrap5,
+ ])
+>
+ {{ $filterPillTitle }}:
+
+ @if(is_array($filterPillValue))
+ @foreach($filterPillValue as $filterPillArrayValue)
+ {{ $filterPillArrayValue }}{!! !$loop->last ? $separator : '' !!}
+ @endforeach
+ @else
+ {{ $filterPillValue }}
+ @endif
+
+
+
+
diff --git a/src/Traits/Helpers/FilterHelpers.php b/src/Traits/Helpers/FilterHelpers.php
index d9bfddf51..c42fdeac2 100644
--- a/src/Traits/Helpers/FilterHelpers.php
+++ b/src/Traits/Helpers/FilterHelpers.php
@@ -226,11 +226,24 @@ public function hasAppliedVisibleFiltersForPills(): bool
/**
* @return array
*/
- public function getAppliedFiltersWithValues(): array
+ /*public function getAppliedFiltersWithValuesOld(): array
{
return $this->appliedFilters = array_filter($this->getAppliedFilters(), function ($item, $key) {
return ! $this->getFilterByKey($key)->isEmpty($item) && (is_array($item) ? count($item) : $item !== null);
}, ARRAY_FILTER_USE_BOTH);
+ }*/
+
+ /**
+ * @return array
+ */
+ public function getAppliedFiltersWithValues(): array
+ {
+ return $this->appliedFilters = array_filter($this->getAppliedFilters(), function ($item, $key) {
+ $filter = $this->getFilterByKey($key);
+ $item = (! is_null($item) && ! $filter->isEmpty($item)) ? $filter->validate($item) : $item;
+
+ return ! $filter->isEmpty($item) && (is_array($item) ? count($item) : $item !== null);
+ }, ARRAY_FILTER_USE_BOTH);
}
/**
diff --git a/src/Views/Filters/NumberFilter.php b/src/Views/Filters/NumberFilter.php
index d942396cc..259c99b95 100644
--- a/src/Views/Filters/NumberFilter.php
+++ b/src/Views/Filters/NumberFilter.php
@@ -4,11 +4,11 @@
use Rappasoft\LaravelLivewireTables\Views\Filter;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasWireables;
-use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{IsStringFilter};
+use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{IsNumericFilter};
class NumberFilter extends Filter
{
- use IsStringFilter;
+ use IsNumericFilter;
use HasWireables;
public string $wireMethod = 'blur';
@@ -17,12 +17,19 @@ class NumberFilter extends Filter
public function validate(float|int|string|array $value): float|int|string|false
{
+ $floatValue = (float) $value;
+ $intValue = (int) $value;
+
if (is_array($value)) {
return false;
} elseif (is_float($value)) {
- return (float) $value;
+ return $floatValue;
} elseif (is_int($value)) {
- return (int) $value;
+ return $intValue;
+ } elseif (is_numeric($value)) {
+ return (($floatValue - $intValue) == 0) ? $intValue : $floatValue;
+ } elseif (ctype_digit($value)) {
+ return $intValue;
}
return false;
diff --git a/src/Views/Traits/Filters/IsNumericFilter.php b/src/Views/Traits/Filters/IsNumericFilter.php
new file mode 100644
index 000000000..602b8fa96
--- /dev/null
+++ b/src/Views/Traits/Filters/IsNumericFilter.php
@@ -0,0 +1,23 @@
+validate($value) == false) : true;
+ }
+
+ /**
+ * Gets the Default Value for this Filter via the Component
+ */
+ public function getFilterDefaultValue(): ?string
+ {
+ return $this->filterDefaultValue ?? null;
+ }
+}
diff --git a/tests/Traits/Helpers/FilterHelpersTest.php b/tests/Traits/Helpers/FilterHelpersTest.php
index fee1bea06..51825ca62 100644
--- a/tests/Traits/Helpers/FilterHelpersTest.php
+++ b/tests/Traits/Helpers/FilterHelpersTest.php
@@ -104,7 +104,7 @@ public function test_can_set_filter_value(): void
$this->assertSame(['1'], $this->basicTable->getAppliedFilterWithValue('breed'));
- $this->basicTable->setFilter('breed_id_filter', '2');
+ $this->basicTable->setFilter('breed_id_filter', 2);
$this->assertSame('2', $this->basicTable->getAppliedFilterWithValue('breed_id_filter'));
diff --git a/tests/Traits/Helpers/SessionStorageHelpersTest.php b/tests/Traits/Helpers/SessionStorageHelpersTest.php
index 17362c503..cedade483 100644
--- a/tests/Traits/Helpers/SessionStorageHelpersTest.php
+++ b/tests/Traits/Helpers/SessionStorageHelpersTest.php
@@ -36,26 +36,26 @@ public function test_can_store_for_fikers(): void
$this->assertSame(['breed' => ['1']], $this->basicTable->appliedFilters);
$this->assertSame(['breed' => ['1']], $this->basicTable->getStoredFilterValues());
- $this->basicTable->setFilter('breed', ['22']);
- $this->assertSame(['breed' => ['22']], $this->basicTable->appliedFilters);
- $this->assertSame(['22'], $this->basicTable->getAppliedFilterWithValue('breed'));
- $this->assertSame(['breed' => ['22']], $this->basicTable->getStoredFilterValues());
+ $this->basicTable->setFilter('breed', ['2']);
+ $this->assertSame(['breed' => ['2']], $this->basicTable->appliedFilters);
+ $this->assertSame(['2'], $this->basicTable->getAppliedFilterWithValue('breed'));
+ $this->assertSame(['breed' => ['2']], $this->basicTable->getStoredFilterValues());
$this->basicTable->restoreFilterValues();
- $this->assertSame(['22'], $this->basicTable->getAppliedFilterWithValue('breed'));
- $this->assertSame(['breed' => ['22']], $this->basicTable->getStoredFilterValues());
+ $this->assertSame(['2'], $this->basicTable->getAppliedFilterWithValue('breed'));
+ $this->assertSame(['breed' => ['2']], $this->basicTable->getStoredFilterValues());
$this->basicTable->clearStoredFilterValues();
$this->assertSame([], $this->basicTable->getStoredFilterValues());
- $this->assertSame(['22'], $this->basicTable->getAppliedFilterWithValue('breed'));
+ $this->assertSame(['2'], $this->basicTable->getAppliedFilterWithValue('breed'));
- $this->basicTable->setFilter('breed', ['33']);
- $this->assertSame(['breed' => ['33']], $this->basicTable->getStoredFilterValues());
- $this->assertSame(['33'], $this->basicTable->getAppliedFilterWithValue('breed'));
+ $this->basicTable->setFilter('breed', ['3']);
+ $this->assertSame(['breed' => ['3']], $this->basicTable->getStoredFilterValues());
+ $this->assertSame(['3'], $this->basicTable->getAppliedFilterWithValue('breed'));
- $this->basicTable->appliedFilters = $this->basicTable->filterComponents = ['breed' => ['44']];
+ $this->basicTable->appliedFilters = $this->basicTable->filterComponents = ['breed' => ['4']];
$this->basicTable->storeFilterValues();
- $this->assertSame(['44'], $this->basicTable->getAppliedFilterWithValue('breed'));
+ $this->assertSame(['4'], $this->basicTable->getAppliedFilterWithValue('breed'));
$this->basicTable->appliedFilters = $this->basicTable->filterComponents = [];
$this->assertNull($this->basicTable->getAppliedFilterWithValue('breed'));
@@ -63,9 +63,9 @@ public function test_can_store_for_fikers(): void
$this->assertSame([], $this->basicTable->filterComponents);
$this->basicTable->restoreFilterValues();
- $this->assertSame(['breed' => ['44']], $this->basicTable->appliedFilters);
- $this->assertSame(['44'], $this->basicTable->getAppliedFilterWithValue('breed'));
- $this->assertSame(['breed' => ['44']], $this->basicTable->getStoredFilterValues());
+ $this->assertSame(['breed' => ['4']], $this->basicTable->appliedFilters);
+ $this->assertSame(['4'], $this->basicTable->getAppliedFilterWithValue('breed'));
+ $this->assertSame(['breed' => ['4']], $this->basicTable->getStoredFilterValues());
}
diff --git a/tests/Traits/Visuals/FilterVisualsTest.php b/tests/Traits/Visuals/FilterVisualsTest.php
index 5b34da945..2c24ee23c 100644
--- a/tests/Traits/Visuals/FilterVisualsTest.php
+++ b/tests/Traits/Visuals/FilterVisualsTest.php
@@ -152,7 +152,6 @@ public function filters(): array
'Cat',
'
',
'Dog',
- '
',
])
->set('filterComponents.breed', [1, 2])
->assertSeeHtmlInOrder([
diff --git a/tests/Views/Filters/NumberFilterTest.php b/tests/Views/Filters/NumberFilterTest.php
index 17c2dc066..1c732f555 100644
--- a/tests/Views/Filters/NumberFilterTest.php
+++ b/tests/Views/Filters/NumberFilterTest.php
@@ -158,13 +158,16 @@ public function test_can_set_number_filter_to_number(): void
$filter = NumberFilter::make('BreedID');
$this->assertSame(123, $filter->validate(123));
$this->assertSame(123.51, $filter->validate(123.51));
- $this->assertFalse($filter->validate('123'));
+ $this->assertSame(123, $filter->validate('123'));
+ $this->assertSame(123.51, $filter->validate('123.51'));
+
}
public function test_can_get_if_number_filter_empty(): void
{
$filter = NumberFilter::make('Active');
$this->assertTrue($filter->isEmpty(''));
+ $this->assertTrue($filter->isEmpty('q'));
$this->assertFalse($filter->isEmpty('123'));
}