Skip to content

Commit c576c28

Browse files
authored
v3.4.16 (#1897)
## [v3.4.16] - 2024-08-27 ### New Features - Add icon column by @lrljoe in #1902 - Enable/Disable Tools/Toolbar by @lrljoe in #1896 ### Bug Fixes - Fix has actions by @lrljoe in #1901 - Use Computed Properties By Default by @lrljoe in #1898 ### Tweaks - PHPStan - Config File Update and Baseline by @lrljoe in #1903
1 parent d140f39 commit c576c28

32 files changed

+807
-42
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to `laravel-livewire-tables` will be documented in this file
44

5+
## [v3.4.16] - 2024-08-27
6+
### New Features
7+
- Add icon column by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1902
8+
- Enable/Disable Tools/Toolbar by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1896
9+
10+
### Bug Fixes
11+
- Fix has actions by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1901
12+
- Use Computed Properties By Default by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1898
13+
14+
### Tweaks
15+
- PHPStan - Config File Update and Baseline by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1903
16+
517
## [v3.4.15] - 2024-08-25
618
### New Features
719
- BooleanColumn - Toggleable Callback by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1892
Binary file not shown.

docs/column-types/icon_column.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: Icon Columns (beta)
3+
weight: 10
4+
---
5+
6+
Icon columns provide a way to display icons in your table without having to use `format()` or partial views.
7+
8+
### setIcon
9+
setIcon requires a valid path to an SVG (Directly or via a Library), it receives the $row, and $value (if available) to help you customise which icon to use
10+
```php
11+
IconColumn::make('Icon', 'status')
12+
->setIcon(function ($row, $value) {
13+
if($value == 1) {
14+
return "heroicon-o-check-circle";
15+
}
16+
else
17+
{
18+
return "heroicon-o-x-circle";
19+
}
20+
}),
21+
```
22+
23+
### attributes
24+
Attributes receives the $row, and $value (if available) to help you customise which attributes to apply, you may pass both classes, and other SVG specific attributes.
25+
```php
26+
IconColumn::make('Icon', 'status')
27+
->setIcon(function ($row, $value) { if($value == 1) { return "heroicon-o-check-circle"; } else { return "heroicon-o-x-circle"; } })
28+
->attributes(function ($row, $value) {
29+
if($value == 1) {
30+
return [
31+
'class' => 'w-6 h-6',
32+
'stroke' => '#008000'
33+
];
34+
}
35+
else
36+
{
37+
return [
38+
'class' => 'w-3 h-3',
39+
'stroke' => '#FF0000'
40+
];
41+
}
42+
}),
43+
```
44+
45+
For example:
46+
### Example
47+
```php
48+
IconColumn::make('Icon', 'status')
49+
->setIcon(function ($row, $value) { if($value == 1) { return "heroicon-o-check-circle"; } else { return "heroicon-o-x-circle"; } })
50+
->attributes(function ($row, $value) {
51+
if($value == 3) {
52+
return [
53+
'class' => 'w-3 h-3',
54+
'stroke' => '#008000'
55+
];
56+
}
57+
else if($value == 2) {
58+
return [
59+
'class' => 'w-3 h-3',
60+
'stroke' => '#0000FF'
61+
];
62+
}
63+
else
64+
{
65+
return [
66+
'class' => 'w-3 h-3',
67+
'stroke' => '#FF0000'
68+
];
69+
}
70+
}),
71+
```
72+
73+
Please also see the following for other available methods:
74+
<ul>
75+
<li>
76+
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/available-methods">Available Methods</a>
77+
</li>
78+
<li>
79+
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/column-selection">Column Selection</a>
80+
</li>
81+
<li>
82+
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/secondary-header">Secondary Header</a>
83+
</li>
84+
<li>
85+
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/footer">Footer</a>
86+
</li>
87+
</ul>

docs/column-types/image_columns.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Image Columns
3-
weight: 10
3+
weight: 11
44
---
55

66
Image columns provide a way to display images in your table without having to use `format()` or partial views:

docs/column-types/link_columns.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Link Columns
3-
weight: 11
3+
weight: 12
44
---
55

66
Link columns provide a way to display HTML links in your table without having to use `format()` or partial views:

docs/column-types/livewire_component_column.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Livewire Component (beta)
3-
weight: 12
3+
weight: 13
44
---
55

66
Livewire Component Columns allow for the use of a Livewire Component as a Column.

docs/column-types/sum_column.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Sum Columns (beta)
3-
weight: 13
3+
weight: 14
44
---
55

66
Sum columns provide an easy way to display the "Sum" of a field on a relation.

docs/column-types/view_component_column.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: View Component Columns
3-
weight: 14
3+
weight: 15
44
---
55

66
View Component columns let you specify a component name and attributes and provide attributes to the View Component. This will render the View Component in it's entirety.

docs/column-types/wire_link_column.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Wire Link Column (beta)
3-
weight: 15
3+
weight: 16
44
---
55

66
WireLink columns provide a way to display Wired Links in your table without having to use `format()` or partial views, with or without a Confirmation Message

docs/columns/other-column-types.md

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ weight: 4
2828
<li>
2929
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/column-types/date_columns">Date Columns</a>
3030
</li>
31+
<li>
32+
[Icon Columns (Beta)](../column-types/icon_columns)
33+
</li>
3134
<li>
3235
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/column-types/image_columns">Image Columns</a>
3336
</li>

docs/misc/tools.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Tools
3+
weight: 9
4+
---
5+
6+
The Table offers additional configuration to show/hide the Tools/Toolbar sections:
7+
## Tools
8+
Contains:
9+
- Filter Pills
10+
- Sorting Pills
11+
- The Toolbar
12+
13+
## Toolbar
14+
Contains:
15+
- Actions (if set to Toolbar)
16+
- Column Select dropdown
17+
- Configurable Areas for Toolbar
18+
- Filters Button/Dropdown/Popover
19+
- Pagination dropdown
20+
- Reorder Button
21+
- Search Input
22+
23+
## Component Available Methods
24+
25+
### setToolsEnabled
26+
The Default Behaviour, Tools Are Enabled. But will only be rendered if there are available/enabled elements. If the Toolbar is enabled, this takes into account any Toolbar elements that are present.
27+
```php
28+
public function configure(): void
29+
{
30+
$this->setToolsEnabled();
31+
}
32+
```
33+
34+
### setToolsDisabled
35+
Disables the Tools section, this includes the Toolbar, and Sort/Filter pills
36+
```php
37+
public function configure(): void
38+
{
39+
$this->setToolsDisabled();
40+
}
41+
```
42+
43+
### setToolBarEnabled
44+
The Default Behaviour, ToolBar is Enabled. But will only be rendered if there are available/enabled elements
45+
```php
46+
public function configure(): void
47+
{
48+
$this->setToolBarEnabled();
49+
}
50+
```
51+
52+
### setToolBarDisabled
53+
Disables the Toolbar, which contains the Reorder, Filters, Search, Column Select, Pagination buttons/options. Does not impact the Filter/Sort pills (if enabled)
54+
```php
55+
public function configure(): void
56+
{
57+
$this->setToolBarDisabled();
58+
}
59+
```

phpstan-baseline.neon

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Offset '1' on array\\<string, non\\-empty\\-array\\<int\\<0, max\\>, mixed\\>\\> in empty\\(\\) does not exist\\.$#"
5+
count: 1
6+
path: src/DataTableComponent.php
7+
8+
-
9+
message: "#^Offset '99' on array\\<string, non\\-empty\\-array\\<int\\<0, max\\>, mixed\\>\\> in isset\\(\\) does not exist\\.$#"
10+
count: 1
11+
path: src/DataTableComponent.php
12+
13+
-
14+
message: "#^Offset '99' on non\\-empty\\-array\\<1\\|string, array\\<int\\<0, max\\>, mixed\\>\\> in isset\\(\\) does not exist\\.$#"
15+
count: 1
16+
path: src/DataTableComponent.php
17+
18+
-
19+
message: "#^Property Illuminate\\\\Database\\\\Query\\\\Builder\\:\\:\\$joins \\(array\\) on left side of \\?\\? is not nullable\\.$#"
20+
count: 1
21+
path: src/DataTableComponent.php
22+
23+
-
24+
message: "#^Property Rappasoft\\\\LaravelLivewireTables\\\\DataTableComponent\\:\\:\\$model has no type specified\\.$#"
25+
count: 1
26+
path: src/DataTableComponent.php
27+
28+
-
29+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
30+
count: 1
31+
path: src/Views/Action.php
32+
33+
-
34+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
35+
count: 1
36+
path: src/Views/Column.php
37+
38+
-
39+
message: "#^Unsafe usage of new static\\(\\)\\.$#"
40+
count: 1
41+
path: src/Views/Filter.php
42+
43+
-
44+
message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<int,string\\>\\:\\:filter\\(\\) expects \\(callable\\(string, int\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int\\<0, max\\> given\\.$#"
45+
count: 1
46+
path: src/Views/Filters/MultiSelectDropdownFilter.php
47+
48+
-
49+
message: "#^Unable to resolve the template type TMapWithKeysKey in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
50+
count: 1
51+
path: src/Views/Filters/MultiSelectDropdownFilter.php
52+
53+
-
54+
message: "#^Unable to resolve the template type TMapWithKeysValue in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
55+
count: 1
56+
path: src/Views/Filters/MultiSelectDropdownFilter.php
57+
58+
-
59+
message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<int,string\\>\\:\\:filter\\(\\) expects \\(callable\\(string, int\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int\\<0, max\\> given\\.$#"
60+
count: 1
61+
path: src/Views/Filters/MultiSelectFilter.php
62+
63+
-
64+
message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<int,string\\>\\:\\:filter\\(\\) expects \\(callable\\(string, int\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int\\<0, max\\> given\\.$#"
65+
count: 1
66+
path: src/Views/Filters/NumberRangeFilter.php
67+
68+
-
69+
message: "#^Unable to resolve the template type TMapWithKeysKey in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
70+
count: 1
71+
path: src/Views/Filters/SelectFilter.php
72+
73+
-
74+
message: "#^Unable to resolve the template type TMapWithKeysValue in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
75+
count: 1
76+
path: src/Views/Filters/SelectFilter.php

phpstan.neon

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
includes:
22
- vendor/larastan/larastan/extension.neon
3+
- phpstan-baseline.neon
34

45
parameters:
56
paths:
@@ -14,14 +15,4 @@ parameters:
1415
reportUnmatchedIgnoredErrors: false
1516
ignoreErrors:
1617
- identifier: missingType.generics
17-
- identifier: missingType.iterableValue
18-
- '#Property Rappasoft\\LaravelLivewireTables\\DataTableComponent\:\:\$model has no type specified#'
19-
- '#Unable to resolve the template type TMapWithKeysKey in call to method Illuminate\\Support\\Collection#'
20-
- '#Unable to resolve the template type TMapWithKeysValue in call to method Illuminate\\Support\\Collection#'
21-
- '#Access to an undefined property Rappasoft\\LaravelLivewireTables\\Views\\Column\:\:\$view#'
22-
- "#Unsafe usage of new static#"
23-
- '#on array\<string, non-empty-array\<int\<0, max\>, mixed\>\> in empty\(\) does not exist.#'
24-
- '#on array<string, non-empty-array<int<0, max>, mixed>> in isset\(\) does not exist#'
25-
- '#on non-empty-array<1\|string, array<int<0, max>, mixed>> in isset\(\) does not exist.#'
26-
- '#\$callback of method Illuminate\\Support\\Collection<int,string>::filter\(\) expects \(callable\(string, int\): bool\)\|null, Closure\(mixed\): int<0, max> given.#'
27-
- '#Property Illuminate\\Database\\Query\\Builder\:\:\$joins \(array\) on left side of \?\? is not nullable.#'
18+
- identifier: missingType.iterableValue

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

-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
@aware(['component', 'tableName','isTailwind','isBootstrap'])
22
@props([])
33

4-
@if ($this->hasConfigurableAreaFor('before-toolbar'))
5-
@include($this->getConfigurableAreaFor('before-toolbar'), $this->getParametersForConfigurableArea('before-toolbar'))
6-
@endif
7-
84
<div @class([
95
'd-md-flex justify-content-between mb-3' => $this->isBootstrap,
106
'md:flex md:justify-between mb-4 px-4 md:p-0' => $this->isTailwind,
@@ -90,9 +86,3 @@
9086
<x-livewire-tables::tools.toolbar.items.filter-slidedown />
9187
@endif
9288

93-
94-
@if ($this->hasConfigurableAreaFor('after-toolbar'))
95-
<div x-cloak x-show="!currentlyReorderingStatus" >
96-
@include($this->getConfigurableAreaFor('after-toolbar'), $this->getParametersForConfigurableArea('after-toolbar'))
97-
</div>
98-
@endif

resources/views/datatable.blade.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,23 @@
1717
@include($this->getConfigurableAreaFor('before-tools'), $this->getParametersForConfigurableArea('before-tools'))
1818
@endif
1919

20+
@if($this->shouldShowTools)
2021
<x-livewire-tables::tools>
2122
@if ($this->showSortPillsSection)
2223
<x-livewire-tables::tools.sorting-pills />
2324
@endif
2425
@if($this->showFilterPillsSection)
2526
<x-livewire-tables::tools.filter-pills />
2627
@endif
27-
<x-livewire-tables::tools.toolbar />
28+
29+
@includeWhen($this->hasConfigurableAreaFor('before-toolbar'), $this->getConfigurableAreaFor('before-toolbar'), $this->getParametersForConfigurableArea('before-toolbar'))
30+
@if($this->shouldShowToolBar)
31+
<x-livewire-tables::tools.toolbar />
32+
@endif
33+
@includeWhen($this->hasConfigurableAreaFor('after-toolbar'), $this->getConfigurableAreaFor('after-toolbar'), $this->getParametersForConfigurableArea('after-toolbar'))
34+
2835
</x-livewire-tables::tools>
36+
@endif
2937

3038
<x-livewire-tables::table>
3139

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="livewire-tables-columns-icon">
2+
@svg(
3+
$icon,
4+
$classes,
5+
$attributes,
6+
)
7+
</div>

src/Traits/ComponentUtilities.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trait ComponentUtilities
4545

4646
protected array $extraWithAvgs = [];
4747

48-
protected bool $useComputedProperties = false;
48+
protected bool $useComputedProperties = true;
4949

5050
/**
5151
* Set any configuration options

0 commit comments

Comments
 (0)