Skip to content

Commit fe27099

Browse files
committed
- bugfix: filter-form component not cacheable
- enhancement: changing chartData to protected to avoid livewire diff overhead on updates for large datasets
1 parent 37eb518 commit fe27099

5 files changed

Lines changed: 40 additions & 5 deletions

File tree

resources/views/widgets/components/filter-form.blade.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['width'])
1+
@props(['indicatorsCount','width'])
22

33
@php
44
use Filament\Support\Enums\Width;
@@ -15,6 +15,19 @@ class="fi-icon-btn relative flex items-center justify-center rounded-lg outline-
1515
</span>
1616

1717
<x-filament::icon icon="heroicon-s-funnel" class="h-5 w-5" />
18+
@if ($indicatorsCount > 0)
19+
<div class="absolute start-full top-0 z-10 -ms-1 -translate-x-1/2 rounded-md bg-white dark:bg-gray-900">
20+
<div
21+
style="--c-50:var(--primary-50);--c-300:var(--primary-300);--c-400:var(--primary-400);--c-600:var(--primary-600);"
22+
class="fi-badge flex items-center justify-center gap-x-1 whitespace-nowrap rounded-md text-xs font-medium ring-1 ring-inset px-0.5 min-w-[theme(spacing.4)] tracking-tighter bg-custom-50 text-custom-600 ring-custom-600/10 dark:bg-custom-400/10 dark:text-custom-400 dark:ring-custom-400/30">
23+
24+
<span>
25+
{{ $indicatorsCount }}
26+
</span>
27+
28+
</div>
29+
</div>
30+
@endif
1831

1932
</button>
2033
</div>

resources/views/widgets/components/header.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['heading', 'subheading', 'width', 'filters', 'filterFormAccessible'])
1+
@props(['heading', 'subheading', 'width', 'indicatorsCount','filters', 'filterFormAccessible'])
22
<div class="filament-plotly-header">
33
@if ($heading || $subheading || $filters || $filterFormAccessible)
44
<div class="sm:flex justify-between gap-4 py-2 relative">
@@ -31,9 +31,9 @@
3131
</div>
3232

3333
@if ($this->filterFormAccessible)
34-
<div class="123">
34+
<div>
3535

36-
<x-filament-plotly::filter-form :width="$width">
36+
<x-filament-plotly::filter-form :indicatorsCount="$indicatorsCount" :width="$width">
3737
{{ $filterForm }}
3838
</x-filament-plotly::filter-form>
3939

src/Components/FilterForm.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Asharif88\FilamentPlotly\Components;
4+
5+
use Illuminate\View\Component;
6+
7+
class FilterForm extends Component
8+
{
9+
public function __construct(
10+
public $indicatorsCount,
11+
public $width
12+
) {}
13+
14+
/**
15+
* Renders the view for the filter-form component.
16+
*/
17+
public function render(): \Illuminate\Contracts\View\View
18+
{
19+
return view('filament-plotly::widgets.components.filter-form');
20+
}
21+
}

src/Components/Header.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public function __construct(
1010
public $heading,
1111
public $subheading,
1212
public $filters,
13+
public $indicatorsCount,
1314
public $width,
1415
public $filterFormAccessible
1516
) {}

src/Widgets/PlotlyWidget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PlotlyWidget extends Widget implements HasSchemas
3434
// @phpstan-ignore-next-line
3535
protected string $view = 'filament-plotly::widgets.plotly-widget';
3636

37-
public ?array $chartData = null;
37+
protected ?array $chartData = null;
3838

3939
public ?array $chartConfig = null;
4040

0 commit comments

Comments
 (0)