Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 16f128f

Browse files
committed
Merge branch 'form-features'
2 parents 8edbea9 + e1ac328 commit 16f128f

File tree

15 files changed

+133
-40
lines changed

15 files changed

+133
-40
lines changed

app/app/Http/Controllers/FormComponentsController.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ public function libraryDefaults()
121121
]);
122122
}
123123

124+
public function librarySubmitOnChange()
125+
{
126+
return view('form.components.librarySubmitOnChange', [
127+
]);
128+
}
129+
130+
public function submitOnChange(Request $request)
131+
{
132+
$request->validate([
133+
'name' => ['required', 'min:3'],
134+
]);
135+
136+
return redirect()->route('navigation.one');
137+
}
138+
124139
public function libraryChange()
125140
{
126141
return view('form.components.libraryChange', [

app/config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
|
7070
*/
7171

72-
'timezone' => 'UTC',
72+
'timezone' => env('APP_TIMEZONE', 'UTC'),
7373

7474
/*
7575
|--------------------------------------------------------------------------
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@extends('layout')
2+
3+
@section('content')
4+
5+
FormComponents
6+
7+
<div class="max-w-sm mx-auto px-4">
8+
<x-splade-form class="space-y-4" :action="route('form.components.submitOnChange')">
9+
<x-splade-select @change="form.submit" name="name" :options="['splade' => 'Splade']" placeholder="Select your country" choices />
10+
</x-splade-form>
11+
</div>
12+
13+
@endsection

app/routes/web.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
Route::get('form/components/libraries', [FormComponentsController::class, 'libraries'])->name('form.components.libraries');
9292
Route::get('form/components/libraryDefaults', [FormComponentsController::class, 'libraryDefaults'])->name('form.components.libraryDefaults');
9393
Route::get('form/components/libraryChange', [FormComponentsController::class, 'libraryChange'])->name('form.components.libraryChange');
94+
Route::get('form/components/librarySubmitOnChange', [FormComponentsController::class, 'librarySubmitOnChange'])->name('form.components.librarySubmitOnChange');
95+
Route::post('form/components/submitOnChange', [FormComponentsController::class, 'submitOnChange'])->name('form.components.submitOnChange');
9496
Route::get('form/components/custom', [FormComponentsController::class, 'custom'])->name('form.components.custom');
9597
Route::get('form/components/defaults', [FormComponentsController::class, 'defaults'])->name('form.components.defaults');
9698
Route::get('form/components/defaultJson', [FormComponentsController::class, 'defaultJson'])->name('form.components.defaultJson');

app/tests/Browser/Form/LibrariesTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,16 @@ public function it_can_provide_a_custom_set_of_js_options_to_flatpickr_through_t
216216
->assertInputValue('time2', '21:00');
217217
});
218218
}
219+
220+
/** @test */
221+
public function it_can_submit_the_form_on_change()
222+
{
223+
$this->browse(function (Browser $browser) {
224+
$browser->visit('form/components/librarySubmitOnChange')
225+
->waitForText('FormComponents')
226+
->choicesSelect('name', 'splade')
227+
->waitUntilMissingText('FormComponents')
228+
->assertRouteIs('navigation.one');
229+
});
230+
}
219231
}

lib/Components/Form.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default {
9595
processing: false,
9696
wasSuccessful: false,
9797
recentlySuccessful: false,
98-
recentlySuccessfulTimeoutId: null
98+
recentlySuccessfulTimeoutId: null,
9999
};
100100
},
101101
@@ -183,7 +183,9 @@ export default {
183183
.catch(() => {});
184184
},
185185
186-
request() {
186+
async request() {
187+
await this.$nextTick();
188+
187189
this.processing = true;
188190
this.wasSuccessful = false;
189191
this.recentlySuccessful = false;

lib/Components/OnClickOutside.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const listener = ref(null);
2727
const root = ref(null);
2828
const closeOnEscapeHandler = ref(null);
2929
30-
3130
onMounted(() => {
3231
listener.value = (e) => {
3332
if (e.target === root.value || root.value.contains(e.target)) {

lib/SpladePlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Form from "./Components/Form.vue";
1212
import Input from "./Components/Input.vue";
1313
import Link from "./Components/Link.vue";
1414
import Modal from "./Components/Modal.vue";
15+
import OnClickOutside from "./Components/OnClickOutside.vue";
1516
import Render from "./Components/Render.vue";
1617
import Select from "./Components/Select.vue";
1718
import State from "./Components/State.vue";
@@ -47,6 +48,7 @@ export default {
4748
.component(`${prefix}Form`, Form)
4849
.component(`${prefix}Input`, Input)
4950
.component(`${prefix}Modal`, Modal)
51+
.component(`${prefix}OnClickOutside`, OnClickOutside)
5052
.component(`${prefix}Render`, Render)
5153
.component(`${prefix}Select`, Select)
5254
.component(`${prefix}State`, State)

resources/views/outside.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<SpladeOnClickOutside {{ $attributes }}>
2+
{{ $slot }}
3+
</SpladeOnClickOutside>
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
1-
<SpladeTable {!! $attributes !!}
1+
<SpladeTable {!! $attributes->except('class') !!}
22
:striped="@js($striped)"
33
:columns="@js($table->columns())"
44
:default-visible-toggleable-columns="@js($table->defaultVisibleToggleableColumns())"
55
>
66
<template #default="{!! $scope !!}">
7-
@if($hasControls())
8-
@include('splade::table.controls')
9-
@endif
7+
<div {!! $attributes->only('class') !!}>
8+
@if($hasControls())
9+
@include('splade::table.controls')
10+
@endif
1011

11-
@foreach($table->searchInputs() as $searchInput)
12-
@includeUnless($searchInput->key === 'global', 'splade::table.search-row')
13-
@endforeach
12+
@foreach($table->searchInputs() as $searchInput)
13+
@includeUnless($searchInput->key === 'global', 'splade::table.search-row')
14+
@endforeach
1415

15-
<x-dynamic-component :component="$wrapperName">
16-
<table class="min-w-full divide-y divide-gray-200 bg-white">
17-
@isset($head)
18-
{{ $head }}
19-
@else
20-
@include('splade::table.head')
21-
@endisset
16+
<x-dynamic-component :component="$wrapperName">
17+
<table class="min-w-full divide-y divide-gray-200 bg-white">
18+
@isset($head)
19+
{{ $head }}
20+
@else
21+
@include('splade::table.head')
22+
@endisset
2223

23-
@isset($body)
24-
{{ $body }}
25-
@else
26-
@include('splade::table.body')
27-
@endisset
28-
</table>
29-
</x-dynamic-component>
24+
@isset($body)
25+
{{ $body }}
26+
@else
27+
@include('splade::table.body')
28+
@endisset
29+
</table>
30+
</x-dynamic-component>
3031

31-
@if($isPaginated())
32-
{{ $table->resource->links($paginationView, ['table' => $table]) }}
33-
@endif
32+
@if($isPaginated())
33+
{{ $table->resource->links($paginationView, ['table' => $table]) }}
34+
@endif
35+
</div>
3436
</template>
3537
</SpladeTable>

0 commit comments

Comments
 (0)