Skip to content

Commit 9d237c7

Browse files
committed
refactor: update Forms namespace to use Components across all files
1 parent aad5735 commit 9d237c7

File tree

9 files changed

+39
-34
lines changed

9 files changed

+39
-34
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class User extends Authenticatable implements FilamentUser, HasAvatar
158158

159159

160160
```php
161-
use Filament\Forms\Components\FileUpload;
161+
use Filament\Schemas\Components\FileUpload;
162162

163163
WirementBreezeCore::make()
164164
->avatarUploadComponent(fn($fileUpload) => $fileUpload->disableLabel())
@@ -256,8 +256,8 @@ php artisan make:livewire MyCustomComponent
256256

257257
```php
258258
use Kwhorne\WirementBreeze\Livewire\MyProfileComponent;
259-
use Filament\Forms\Components\TextInput;
260-
use Filament\Forms\Form;
259+
use Filament\Schemas\Components\TextInput;
260+
use Filament\Schemas\Schema;
261261

262262
class MyCustomComponent extends MyProfileComponent
263263
{
@@ -350,7 +350,7 @@ If you want to customize only the fields and notification in the personal info c
350350
```php
351351
namespace App\Livewire;
352352

353-
use Filament\Forms;
353+
use Filament\Forms\Components;
354354
use Filament\Notifications\Notification;
355355
use Kwhorne\WirementBreeze\Livewire\PersonalInfo;
356356

@@ -368,15 +368,15 @@ class CustomPersonalInfo extends PersonalInfo
368368
];
369369
}
370370

371-
protected function getNameComponent(): Forms\Components\TextInput
371+
protected function getNameComponent(): Components\TextInput
372372
{
373-
return Forms\Components\TextInput::make('custom_name_field')
373+
return Components\TextInput::make('custom_name_field')
374374
->required();
375375
}
376376

377-
protected function getEmailComponent(): Forms\Components\TextInput
377+
protected function getEmailComponent(): Components\TextInput
378378
{
379-
return Forms\Components\TextInput::make('custom_email_field')
379+
return Components\TextInput::make('custom_email_field')
380380
->required();
381381
}
382382

src/Actions/PasswordButtonAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Kwhorne\WirementBreeze\Actions;
44

55
use Filament\Actions\Action;
6-
use Filament\Forms;
6+
use Filament\Forms\Components;
77

88
class PasswordButtonAction extends Action
99
{
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
__('wirement-breeze::default.password_confirm.description')
2525
)
2626
->form([
27-
Forms\Components\TextInput::make('current_password')
27+
Components\TextInput::make('password')
2828
->label(__('wirement-breeze::default.password_confirm.current_password'))
2929
->required()
3030
->password()

src/Livewire/BrowserSessions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Kwhorne\WirementBreeze\Livewire;
44

55
use Carbon\Carbon;
6-
use Filament\Forms;
7-
use Filament\Forms\Components\Actions;
6+
use Filament\Forms\Components;
87
use Filament\Forms\Form;
8+
use Filament\Forms\Components\Actions;
99
use Filament\Notifications\Notification;
1010
use Illuminate\Support\Facades\Auth;
1111
use Illuminate\Support\Facades\DB;
@@ -31,7 +31,7 @@ public function form(Form $form): Form
3131
{
3232
return $form
3333
->schema([
34-
Forms\Components\ViewField::make('browserSessions')
34+
Components\ViewField::make('browserSessions')
3535
->label(__('wirement-breeze::default.profile.browser_sessions.label'))
3636
->hiddenLabel()
3737
->view($this->listView)
@@ -45,7 +45,7 @@ public function form(Form $form): Form
4545
->modalDescription(__('wirement-breeze::default.profile.browser_sessions.logout_description'))
4646
->modalSubmitActionLabel(__('wirement-breeze::default.profile.browser_sessions.logout_action'))
4747
->form([
48-
Forms\Components\TextInput::make('password')
48+
Components\TextInput::make('password')
4949
->password()
5050
->revealable()
5151
->label(__('wirement-breeze::default.fields.password'))

src/Livewire/PersonalInfo.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Kwhorne\WirementBreeze\Livewire;
44

55
use Filament\Facades\Filament;
6-
use Filament\Schemas\Components;
7-
use Filament\Schemas\Schema;
6+
use Filament\Forms\Components;
7+
use Filament\Forms\Form;
88
use Filament\Notifications\Notification;
99

1010
class PersonalInfo extends MyProfileComponent
@@ -70,10 +70,9 @@ protected function getEmailComponent(): Components\TextInput
7070
->label(__('wirement-breeze::default.fields.email'));
7171
}
7272

73-
public function form(Schema $schema): Schema
73+
public function form(Form $form): Form
7474
{
75-
return $schema
76-
->schema($this->getProfileFormSchema())->columns(3)
75+
return $form->schema($this->getProfileFormSchema())->columns(3)
7776
->statePath('data');
7877
}
7978

src/Livewire/SanctumTokens.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
use Carbon\Carbon;
66
use Filament\Facades\Filament;
7-
use Filament\Forms;
7+
use Filament\Forms\Components;
8+
use Filament\Forms\Form;
89
use Filament\Notifications\Notification;
910
use Filament\Tables;
1011
use Illuminate\Database\Eloquent\Builder;
@@ -31,6 +32,11 @@ public function mount()
3132
$this->user = Filament::getCurrentPanel()->auth()->user();
3233
}
3334

35+
public function form(Form $form): Form
36+
{
37+
return $form;
38+
}
39+
3440
protected function getTableQuery(): Builder
3541
{
3642
$auth = Filament::getCurrentPanel()->auth();
@@ -67,16 +73,16 @@ protected function getTableColumns(): array
6773
protected function getSanctumFormSchema(bool $edit = false): array
6874
{
6975
return [
70-
Forms\Components\TextInput::make('token_name')
76+
Components\TextInput::make('token_name')
7177
->label(__('wirement-breeze::default.fields.token_name'))
7278
->required()
7379
->hidden($edit),
74-
Forms\Components\CheckboxList::make('abilities')
80+
Components\CheckboxList::make('abilities')
7581
->label(__('wirement-breeze::default.fields.abilities'))
7682
->options(filament('wirement-breeze')->getSanctumPermissions())
7783
->columns($this->abilityColumns)
7884
->required(),
79-
Forms\Components\DatePicker::make('expires_at')
85+
Components\DatePicker::make('expires_at')
8086
->label(__('wirement-breeze::default.fields.token_expiry')),
8187

8288
];

src/Livewire/TwoFactorAuthentication.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Filament\Actions\Action;
66
use Filament\Facades\Filament;
7-
use Filament\Forms;
7+
use Filament\Forms\Components;
88
use Filament\Notifications\Notification;
99
use Illuminate\Support\Collection;
1010
use Kwhorne\WirementBreeze\Actions\PasswordButtonAction;
@@ -63,7 +63,7 @@ public function confirmAction(): Action
6363
->label(__('wirement-breeze::default.profile.2fa.actions.confirm_finish'))
6464
->modalWidth('sm')
6565
->form([
66-
Forms\Components\TextInput::make('code')
66+
Components\TextInput::make('code')
6767
->label(__('wirement-breeze::default.fields.2fa_code'))
6868
->placeholder('###-###')
6969
->required(),

src/Livewire/UpdatePassword.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Kwhorne\WirementBreeze\Livewire;
44

55
use Filament\Facades\Filament;
6-
use Filament\Forms;
6+
use Filament\Forms\Components;
77
use Filament\Forms\Form;
88
use Filament\Notifications\Notification;
99
use Illuminate\Support\Facades\Hash;
@@ -27,18 +27,18 @@ public function form(Form $form): Form
2727
{
2828
return $form
2929
->schema([
30-
Forms\Components\TextInput::make('current_password')
30+
Components\TextInput::make('current_password')
3131
->label(__('wirement-breeze::default.password_confirm.current_password'))
3232
->required()
3333
->password()
3434
->rule('current_password')
3535
->visible(filament('wirement-breeze')->getPasswordUpdateRequiresCurrent()),
36-
Forms\Components\TextInput::make('new_password')
36+
Components\TextInput::make('new_password')
3737
->label(__('wirement-breeze::default.fields.new_password'))
3838
->password()
3939
->rules(filament('wirement-breeze')->getPasswordUpdateRules())
4040
->required(),
41-
Forms\Components\TextInput::make('new_password_confirmation')
41+
Components\TextInput::make('new_password_confirmation')
4242
->label(__('wirement-breeze::default.fields.new_password_confirmation'))
4343
->password()
4444
->same('new_password')

src/Pages/TwoFactorPage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
77
use Filament\Actions\Action;
88
use Filament\Facades\Filament;
9-
use Filament\Forms;
9+
use Filament\Schemas\Components;
1010
use Filament\Http\Controllers\Auth\LogoutController;
1111
use Filament\Pages\Concerns\InteractsWithFormActions;
1212
use Filament\Pages\SimplePage;
@@ -52,7 +52,7 @@ public function mount()
5252
protected function getFormSchema(): array
5353
{
5454
return [
55-
Forms\Components\TextInput::make('code')
55+
Components\TextInput::make('code')
5656
->label($this->usingRecoveryCode ? __('wirement-breeze::default.fields.2fa_recovery_code') : __('wirement-breeze::default.fields.2fa_code'))
5757
->placeholder($this->usingRecoveryCode ? __('wirement-breeze::default.two_factor.recovery_code_placeholder') : __('wirement-breeze::default.two_factor.code_placeholder'))
5858
->hint(new HtmlString(Blade::render('
@@ -62,7 +62,7 @@ protected function getFormSchema(): array
6262
->extraInputAttributes(['class' => 'text-center', 'autocomplete' => $this->usingRecoveryCode ? 'off' : 'one-time-code'])
6363
->autofocus()
6464
->suffixAction(
65-
Forms\Components\Actions\Action::make('cancel')
65+
Components\Actions\Action::make('cancel')
6666
->ToolTip(__('wirement-breeze::default.cancel'))
6767
->icon('heroicon-o-x-circle')
6868
->action(function () {

src/WirementBreezeCore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Closure;
1212
use Filament\Contracts\Plugin;
1313
use Filament\Facades\Filament;
14-
use Filament\Forms;
14+
use Filament\Forms\Components;
1515
use Filament\Navigation\MenuItem;
1616
use Filament\Panel;
1717
use Filament\Support\Concerns\EvaluatesClosures;
@@ -194,7 +194,7 @@ public function avatarUploadComponent(Closure $component)
194194

195195
public function getAvatarUploadComponent()
196196
{
197-
$fileUpload = Forms\Components\FileUpload::make('avatar_url')
197+
$fileUpload = Components\FileUpload::make('avatar_url')
198198
->label(__('wirement-breeze::default.fields.avatar'))->avatar();
199199

200200
return is_null($this->avatarUploadComponent) ? $fileUpload : $this->evaluate($this->avatarUploadComponent, namedInjections: [

0 commit comments

Comments
 (0)