diff --git a/config/searchable-select.php b/config/searchable-select.php
index c37b6b3..eff1aa1 100644
--- a/config/searchable-select.php
+++ b/config/searchable-select.php
@@ -12,17 +12,4 @@
*/
'theme' => env('SEARCHABLE_SELECT_THEME', 'tailwind'),
-
- /*
- |--------------------------------------------------------------------------
- | Bootstrap Version
- |--------------------------------------------------------------------------
- |
- | Specify the Bootstrap version you're using. This helps optimize
- | the CSS classes for your specific Bootstrap version.
- | Supported values: "5"
- |
- */
-
- 'bootstrap_version' => env('SEARCHABLE_SELECT_BOOTSTRAP_VERSION', '5'),
];
diff --git a/demo/routes/web.php b/demo/routes/web.php
index d3df3d2..0016766 100644
--- a/demo/routes/web.php
+++ b/demo/routes/web.php
@@ -51,4 +51,4 @@
}
return response()->json(array_values($countries));
-});
+})->middleware('throttle:60,1');
diff --git a/resources/views/partials/_searchable-select-script.blade.php b/resources/views/partials/_searchable-select-script.blade.php
new file mode 100644
index 0000000..0c1ae4b
--- /dev/null
+++ b/resources/views/partials/_searchable-select-script.blade.php
@@ -0,0 +1,184 @@
+@once
+
+@endonce
+
+@once
+@push('scripts')
+
+@endpush
+@endonce
diff --git a/resources/views/searchable-select-bootstrap.blade.php b/resources/views/searchable-select-bootstrap.blade.php
index af98cd0..71a6318 100644
--- a/resources/views/searchable-select-bootstrap.blade.php
+++ b/resources/views/searchable-select-bootstrap.blade.php
@@ -50,196 +50,29 @@
if ($grouped) {
foreach ($alpineOptions as $group) {
foreach ($group['items'] as $item) {
- $labelsMap[$item['value']] = $item['label'];
+ $labelsMap[(string) $item['value']] = $item['label'];
}
}
} else {
foreach ($alpineOptions as $item) {
- $labelsMap[$item['value']] = $item['label'];
+ $labelsMap[(string) $item['value']] = $item['label'];
}
}
+
+ $mappedSelectedValues = array_map(fn($v) => is_numeric($v) ? (int) $v : $v, $selectedValues);
@endphp
+@once
-
-@once
-@push('scripts')
-
-@endpush
@endonce
-
@@ -342,6 +175,11 @@ class="dropdown-menu show position-absolute shadow border rounded overflow-hidde
+ {{-- Error message --}}
+
+
+
+
@if ($grouped)
@@ -370,7 +208,7 @@ class="dropdown-item d-flex align-items-center justify-content-between py-2"
-
{{ $emptyMessage }}
@@ -395,7 +233,7 @@ class="dropdown-item d-flex align-items-center justify-content-between py-2"
-
{{ $emptyMessage }}
diff --git a/resources/views/searchable-select.blade.php b/resources/views/searchable-select.blade.php
index 3a45d2e..537ec17 100644
--- a/resources/views/searchable-select.blade.php
+++ b/resources/views/searchable-select.blade.php
@@ -51,190 +51,19 @@
if ($grouped) {
foreach ($alpineOptions as $group) {
foreach ($group['items'] as $item) {
- $labelsMap[$item['value']] = $item['label'];
+ $labelsMap[(string) $item['value']] = $item['label'];
}
}
} else {
foreach ($alpineOptions as $item) {
- $labelsMap[$item['value']] = $item['label'];
+ $labelsMap[(string) $item['value']] = $item['label'];
}
}
-@endphp
-
-
-
-@once
-@push('scripts')
-
-@endpush
-@endonce
+@include('searchable-select::partials._searchable-select-script')
@@ -344,6 +173,12 @@ class="w-full px-3 py-2.5 border-b border-gray-300 dark:border-gray-600 bg-white
+ {{-- Error message --}}
+
+
+
+
@if ($grouped)
@@ -372,7 +207,7 @@ class="w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0 ml-2"
-
{{ $emptyMessage }}
@@ -398,7 +233,7 @@ class="w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0 ml-2"
-
{{ $emptyMessage }}
diff --git a/src/SearchableSelectServiceProvider.php b/src/SearchableSelectServiceProvider.php
index 54dcc0d..d7e14b2 100644
--- a/src/SearchableSelectServiceProvider.php
+++ b/src/SearchableSelectServiceProvider.php
@@ -26,6 +26,10 @@ public function boot(): void
$this->publishes([
__DIR__.'/../config/searchable-select.php' => config_path('searchable-select.php'),
], 'searchable-select-config');
+
+ $this->publishes([
+ __DIR__.'/../resources/views' => resource_path('views/vendor/searchable-select'),
+ ], 'searchable-select-views');
}
}
}
diff --git a/src/View/Components/SearchableSelect.php b/src/View/Components/SearchableSelect.php
index 55bc9c9..74319a7 100644
--- a/src/View/Components/SearchableSelect.php
+++ b/src/View/Components/SearchableSelect.php
@@ -2,6 +2,7 @@
namespace Williamug\SearchableSelect\View\Components;
+use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class SearchableSelect extends Component
@@ -16,7 +17,7 @@ public function __construct(?string $theme = null)
/**
* Get the view / contents that represent the component.
*/
- public function render()
+ public function render(): View|\Closure|string
{
if ($this->currentTheme === 'bootstrap') {
return view('searchable-select::searchable-select-bootstrap');
diff --git a/tests/ArchTest.php b/tests/ArchTest.php
index 87fb64c..e6193b9 100644
--- a/tests/ArchTest.php
+++ b/tests/ArchTest.php
@@ -1,5 +1,5 @@
expect(['dd', 'dump', 'ray'])
+ ->expect(['dd', 'dump', 'ray', 'var_dump', 'print_r', 'var_export'])
->each->not->toBeUsed();