diff --git a/app/Livewire/UI/Combobox.php b/app/Livewire/UI/Combobox.php
new file mode 100644
index 0000000..1fda33e
--- /dev/null
+++ b/app/Livewire/UI/Combobox.php
@@ -0,0 +1,66 @@
+value) {
+ $result = $this->model::findOrFail($this->value);
+ $this->selected = $result;
+ }
+
+ $this->results = collect([]);
+ }
+
+ public function updatedSearch($value)
+ {
+ $query = $this->model::query();
+
+ foreach ($this->searchable as $search) {
+ $query->where($search, 'like', "%$value%");
+ }
+
+ $this->results = $query->limit($this->limit)->get();
+ }
+
+ public function select($result)
+ {
+ $result = $this->results->find($result);
+
+ $this->value = $result->id;
+ $this->selected = $result;
+ $this->show = false;
+ $this->reset(['search', 'results']);
+ }
+
+ public function render()
+ {
+ return view('livewire.combobox.index');
+ }
+}
diff --git a/resources/views/livewire/combobox/index.blade.php b/resources/views/livewire/combobox/index.blade.php
new file mode 100644
index 0000000..69e01a3
--- /dev/null
+++ b/resources/views/livewire/combobox/index.blade.php
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+ @foreach ($results as $result)
+
+ {{ $result->{$display} }}
+
+ @if ($value === $result->id)
+
+ @endif
+
+ @endforeach
+ @if ($search && $results->isEmpty())
+ {{ __('No results found') }}
+ @endif
+
+
+
diff --git a/src/LaravelLuviServiceProvider.php b/src/LaravelLuviServiceProvider.php
index 9379777..7bc3392 100644
--- a/src/LaravelLuviServiceProvider.php
+++ b/src/LaravelLuviServiceProvider.php
@@ -38,6 +38,10 @@ class LaravelLuviServiceProvider extends ServiceProvider
'typography',
];
+ protected $livewireComponents = [
+ 'combobox',
+ ];
+
/**
* Register any application services.
*/
@@ -57,6 +61,16 @@ public function boot(): void
], $component);
}
+ foreach ($this->livewireComponents as $livewireComponent) {
+ $this->publishes([
+ __DIR__."/../resources/views/livewire/{$livewireComponent}" => resource_path("views/livewire/{$livewireComponent}"),
+ ], $livewireComponent);
+
+ $this->publishes([
+ __DIR__.'/../app/Livewire/UI/'.str($livewireComponent)->ucfirst().'.php' => app_path('Livewire/UI/'.str($livewireComponent)->ucfirst()).'.php',
+ ], $livewireComponent);
+ }
+
$this->publishes([
__DIR__.'/../App/Services/ButtonCvaService.php' => app_path('Services/ButtonCvaService.php'),
], 'button');