Skip to content

Commit f0931c3

Browse files
committed
Migration to support Livewire Filter Array filter pills, docs updates, and reverting away from computed properties for the theme determination
1 parent 599cc33 commit f0931c3

File tree

55 files changed

+1254
-683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1254
-683
lines changed

docs/column-types/array_column.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 2
55

66
Array columns provide an easy way to work with and display an array of data from a field.
77

8-
```
8+
```php
99
ArrayColumn::make('notes', 'name')
1010
->data(fn($value, $row) => ($row->notes))
1111
->outputFormat(fn($index, $value) => "<a href='".$value->id."'>".$value->name."</a>")
@@ -16,7 +16,7 @@ ArrayColumn::make('notes', 'name')
1616
### Empty Value
1717
You may define the default/empty value using the "emptyValue" method
1818

19-
```
19+
```php
2020
ArrayColumn::make('notes', 'name')
2121
->emptyValue('Unknown'),
2222
```

docs/column-types/avg_column.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 3
55

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

8-
```
8+
```php
99
AvgColumn::make('Average Related User Age')
1010
->setDataSource('users','age')
1111
->sortable(),

docs/column-types/count_column.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 8
55

66
Count columns provide an easy way to display the "Count" of a relation.
77

8-
```
8+
```php
99
CountColumn::make('Related Users')
1010
->setDataSource('users')
1111
->sortable(),

docs/column-types/livewire_component_column.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Livewire Component Columns allow for the use of a Livewire Component as a Column
88
This is **not recommended** as due to the nature of Livewire, it becomes inefficient at scale.
99

1010
## component
11-
```
11+
```php
1212
LivewireComponentColumn::make('Action')
1313
->component('PathToLivewireComponent'),
1414

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Livewire Custom Array Filter (Beta)
3+
weight: 13
4+
---
5+
6+
**IN BETA**
7+
This feature is currently in beta, and use in production is not recommended.
8+
9+
### Usage
10+
This allows you to use a child/nested Livewire Component in place of the existing Filters, giving you more control over the look/feel/behaviour of a filter. This version supports use of returning an array of values for use in filtering.
11+
12+
To use a LivewireComponentArrayFilter, you must include it in your namespace:
13+
```php
14+
use Rappasoft\LaravelLivewireTables\Views\Filters\LivewireComponentArrayFilter;
15+
```
16+
17+
When creating a filter:
18+
- Specify a unique name
19+
- Set the path to a valid Livewire Component
20+
- Define a filter() callback to define how the returned value will be used.
21+
22+
```php
23+
public function filters(): array
24+
{
25+
return [
26+
LivewireComponentArrayFilter::make('My External Filter')
27+
->setLivewireComponent('my-test-external-filter')
28+
->filter(function (Builder $builder, array $values) {
29+
$builder->whereIn('foreign_id', $values);
30+
}),
31+
];
32+
}
33+
```
34+
35+
### setPillsSeparator
36+
As this is an array, you can define the separator to use between pills values, by default this is set to ", "
37+
38+
```php
39+
public function filters(): array
40+
{
41+
return [
42+
LivewireComponentArrayFilter::make('My External Filter')
43+
->setLivewireComponent('my-test-external-filter')
44+
->setPillsSeparator(' OR ')
45+
->filter(function (Builder $builder, array $values) {
46+
$builder->whereIn('foreign_id', $values);
47+
}),
48+
];
49+
}
50+
```
51+

docs/filters/available-component-methods.md

Lines changed: 2 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -85,135 +85,9 @@ public function configure(): void
8585

8686
---
8787

88-
## setFilterPillsStatus
88+
## Pills
8989

90-
**Enabled by default**, show/hide the filter pills.
91-
92-
```php
93-
public function configure(): void
94-
{
95-
$this->setFilterPillsStatus(true);
96-
$this->setFilterPillsStatus(false);
97-
}
98-
```
99-
100-
## setFilterPillsEnabled
101-
102-
Show the filter pills for the component.
103-
104-
```php
105-
public function configure(): void
106-
{
107-
// Shorthand for $this->setFilterPillsStatus(true)
108-
$this->setFilterPillsEnabled();
109-
}
110-
```
111-
112-
## setFilterPillsDisabled
113-
114-
Hide the filter pills for the component.
115-
116-
```php
117-
public function configure(): void
118-
{
119-
// Shorthand for $this->setFilterPillsStatus(false)
120-
$this->setFilterPillsDisabled();
121-
}
122-
```
123-
124-
## setFilterPillsItemAttributes
125-
Allows for customisation of the appearance of the "Filter Pills Item"
126-
127-
Note that this utilises a refreshed approach for attributes, and allows for appending to, or replacing the styles and colors independently, via the below methods.
128-
129-
#### default-colors
130-
Setting to false will disable the default colors for the Filter Pills Item, the default colors are:
131-
132-
Bootstrap: None
133-
134-
Tailwind: `bg-indigo-100 text-indigo-800 dark:bg-indigo-200 dark:text-indigo-900`
135-
136-
#### default-styling
137-
Setting to false will disable the default styling for the Filter Pills Item, the default styling is:
138-
139-
Bootstrap 4: `badge badge-pill badge-info d-inline-flex align-items-center`
140-
141-
Bootstrap 5: `badge rounded-pill bg-info d-inline-flex align-items-center`
142-
143-
Tailwind: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 capitalize`
144-
145-
```php
146-
public function configure(): void
147-
{
148-
$this->setFilterPillsItemAttributes([
149-
'class' => 'bg-rose-300 text-rose-800 dark:bg-indigo-200 dark:text-indigo-900', // Add these classes to the filter pills item
150-
'default-colors' => false, // Do not output the default colors
151-
'default-styling' => true // Output the default styling
152-
]);
153-
}
154-
```
155-
156-
## setFilterPillsResetFilterButtonAttributes
157-
Allows for customisation of the appearance of the "Filter Pills Reset Filter Button"
158-
159-
Note that this utilises a refreshed approach for attributes, and allows for appending to, or replacing the styles and colors independently, via the below methods.
160-
161-
#### default-colors
162-
Setting to false will disable the default colors for the Filter Pills Reset Filter Button, the default colors are:
163-
164-
Bootstrap: None
165-
166-
Tailwind: `text-indigo-400 hover:bg-indigo-200 hover:text-indigo-500 focus:bg-indigo-500 focus:text-white`
167-
168-
#### default-styling
169-
Setting to false will disable the default styling for the Filter Pills Reset Filter Button, the default styling is:
170-
171-
Bootstrap: `text-white ml-2`
172-
173-
Tailwind: `flex-shrink-0 ml-0.5 h-4 w-4 rounded-full inline-flex items-center justify-center focus:outline-none`
174-
175-
```php
176-
public function configure(): void
177-
{
178-
$this->setFilterPillsResetFilterButtonAttributes([
179-
'class' => 'text-rose-400 hover:bg-rose-200 hover:text-rose-500 focus:bg-rose-500', // Add these classes to the filter pills reset filter button
180-
'default-colors' => false, // Do not output the default colors
181-
'default-styling' => true // Output the default styling
182-
]);
183-
}
184-
```
185-
186-
## setFilterPillsResetAllButtonAttributes
187-
Allows for customisation of the appearance of the "Filter Pills Reset All Button"
188-
189-
Note that this utilises a refreshed approach for attributes, and allows for appending to, or replacing the styles and colors independently, via the below methods.
190-
191-
#### default-colors
192-
Setting to false will disable the default colors for the Filter Pills Reset All Button, the default colors are:
193-
194-
Bootstrap: None
195-
196-
Tailwind: `bg-gray-100 text-gray-800 dark:bg-gray-200 dark:text-gray-900`
197-
198-
#### default-styling
199-
Setting to false will disable the default styling for the Filter Pills Reset All Button, the default styling is:
200-
201-
Bootstrap 4: `badge badge-pill badge-light`
202-
203-
Bootstrap 5: `badge rounded-pill bg-light text-dark text-decoration-none`
204-
205-
Tailwind: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium`
206-
207-
```php
208-
public function configure(): void
209-
{
210-
$this->setFilterPillsResetAllButtonAttributes([
211-
'class' => 'bg-rose-100 text-rose-800 dark:bg-gray-200 dark:text-gray-900', // Add these classes to the filter pills reset all button
212-
'default-colors' => false, // Do not output the default colors
213-
'default-styling' => true // Output the default styling
214-
]);
215-
}
216-
```
90+
See the [Filter Pills](./filter-pills) documentation for help with configuring the pills
21791

21892
---
21993

0 commit comments

Comments
 (0)