summaryrefslogtreecommitdiff
path: root/src/Toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/Toolbar')
-rw-r--r--src/Toolbar/ColumnSelect.php17
-rw-r--r--src/Toolbar/Filter.php8
-rw-r--r--src/Toolbar/Item.php32
-rw-r--r--src/Toolbar/PageSize.php19
-rw-r--r--src/Toolbar/Search.php25
5 files changed, 101 insertions, 0 deletions
diff --git a/src/Toolbar/ColumnSelect.php b/src/Toolbar/ColumnSelect.php
new file mode 100644
index 0000000..a70c49a
--- /dev/null
+++ b/src/Toolbar/ColumnSelect.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Lightscale\LaralightTables\Toolbar;
+
+use Illuminate\View\View;
+
+class ColumnSelect extends Item
+{
+ public function __construct() {}
+
+ public function render(): View
+ {
+ return view('laralight-tables::toolbar.column-select', [
+ 'allColumns' => $this->getTable()->getColumns()
+ ]);
+ }
+}
diff --git a/src/Toolbar/Filter.php b/src/Toolbar/Filter.php
new file mode 100644
index 0000000..ebda2c6
--- /dev/null
+++ b/src/Toolbar/Filter.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace Lightscale\LaralightTables\Toolbar;
+
+abstract class Filter extends Item
+{
+
+}
diff --git a/src/Toolbar/Item.php b/src/Toolbar/Item.php
new file mode 100644
index 0000000..168f877
--- /dev/null
+++ b/src/Toolbar/Item.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Lightscale\LaralightTables\Toolbar;
+
+use Lightscale\LaralightTables\TableComponent;
+use Lightscale\LaralightTables\Toolbar;
+
+use Illuminate\View\View;
+use Illuminate\Support\HtmlString;
+
+abstract class Item
+{
+ private Toolbar $toolbar;
+
+ public function setToolbar(Toolbar $toolbar): void
+ {
+ $this->toolbar = $toolbar;
+ }
+
+ public function getToolbar(): Toolbar
+ {
+ return $this->toolbar;
+ }
+
+ public function getTable(): TableComponent
+ {
+ return $this->getToolbar()->getTable();
+ }
+
+ abstract public function render(): View|HtmlString|string|null;
+
+}
diff --git a/src/Toolbar/PageSize.php b/src/Toolbar/PageSize.php
new file mode 100644
index 0000000..9c2821a
--- /dev/null
+++ b/src/Toolbar/PageSize.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Lightscale\LaralightTables\Toolbar;
+
+use Illuminate\View\View;
+
+class PageSize extends Item
+{
+ public function __construct(
+ private array $pageSizes = [10, 25, 50],
+ ) {}
+
+ public function render(): View
+ {
+ return view('laralight-tables::toolbar.page-size', [
+ 'pageSizes' => $this->pageSizes,
+ ]);
+ }
+}
diff --git a/src/Toolbar/Search.php b/src/Toolbar/Search.php
new file mode 100644
index 0000000..0b0dc37
--- /dev/null
+++ b/src/Toolbar/Search.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Lightscale\LaralightTables\Toolbar;
+
+use Illuminate\View\View;
+
+class Search extends Item
+{
+ public function __construct(
+ protected int $debounce = 250,
+ protected int $minLength = 2,
+ ) {}
+
+ public function getMinLength(): int
+ {
+ return $this->minLength;
+ }
+
+ public function render(): View
+ {
+ return view('laralight-tables::toolbar.search', [
+ 'debounce' => $this->debounce,
+ ]);
+ }
+}