22
33namespace Backstage \Fields \Concerns ;
44
5+ use Filament \Schemas \Components \Fieldset ;
6+ use Filament \Schemas \Components \Grid ;
7+ use Filament \Forms \Components \Select ;
8+ use Filament \Schemas \Components \Utilities \Get ;
9+ use Filament \Schemas \Components \Utilities \Set ;
10+ use Filament \Forms \Components \Hidden ;
11+ use Filament \Forms \Components \TextInput ;
512use Filament \Forms ;
6- use Filament \Forms \Components \Fieldset ;
7- use Filament \Forms \Components \Grid ;
813use Filament \Forms \Components \Repeater ;
914use Illuminate \Support \Facades \Schema ;
1015use Illuminate \Support \Str ;
@@ -101,13 +106,13 @@ protected static function getSelectableValuesConfig(): array
101106
102107 protected function selectableValuesFormFields (string $ type , string $ label , string $ arrayComponent ): Fieldset
103108 {
104- return Forms \ Components \ Fieldset::make ($ label )
109+ return Fieldset::make ($ label )
105110 ->columnSpanFull ()
106111 ->label (__ ($ label ))
107112 ->schema ([
108- Forms \ Components \ Grid::make (2 )
113+ Grid::make (2 )
109114 ->schema ([
110- Forms \ Components \ Select::make ("config. {$ type }" )
115+ Select::make ("config. {$ type }" )
111116 ->options ([
112117 'array ' => __ ('Array ' ),
113118 'relationship ' => __ ('Relationship ' ),
@@ -120,22 +125,22 @@ protected function selectableValuesFormFields(string $type, string $label, strin
120125 $ arrayComponent ::make ('config.options ' )
121126 ->label (__ ('Options ' ))
122127 ->columnSpanFull ()
123- ->visible (fn (Forms \ Get $ get ): bool => $ get ("config. {$ type }" ) == 'array ' )
124- ->required (fn (Forms \ Get $ get ): bool => $ get ("config. {$ type }" ) == 'array ' ),
128+ ->visible (fn (Get $ get ): bool => $ get ("config. {$ type }" ) == 'array ' )
129+ ->required (fn (Get $ get ): bool => $ get ("config. {$ type }" ) == 'array ' ),
125130 // Relationship options
126131 Repeater::make ('config.relations ' )
127132 ->label (__ ('Relations ' ))
128133 ->schema ([
129134 Grid::make ()
130135 ->columns (2 )
131136 ->schema ([
132- Forms \ Components \ Select::make ('resource ' )
137+ Select::make ('resource ' )
133138 ->label (__ ('Resource ' ))
134139 ->searchable ()
135140 ->preload ()
136141 ->columnSpanFull ()
137142 ->live (debounce: 250 )
138- ->afterStateUpdated (function (Forms \ Set $ set , ?string $ state ) {
143+ ->afterStateUpdated (function (Set $ set , ?string $ state ) {
139144 $ model = static ::resolveResourceModel ($ state );
140145
141146 if (! $ model ) {
@@ -169,32 +174,32 @@ protected function selectableValuesFormFields(string $type, string $label, strin
169174 ->toArray ();
170175 })
171176 ->noSearchResultsMessage (__ ('No types found ' ))
172- ->required (fn (Forms \ Get $ get ): bool => $ get ("config. {$ type }" ) == 'relationship ' ),
173- Forms \ Components \ Select::make ('relationValue ' )
177+ ->required (fn (Get $ get ): bool => $ get ("config. {$ type }" ) == 'relationship ' ),
178+ Select::make ('relationValue ' )
174179 ->label (__ ('Column ' ))
175180 ->helperText (__ ('The column to use as name for the options ' ))
176- ->options (fn (Forms \ Get $ get ) => $ get ('relationValue_options ' ) ?? [])
181+ ->options (fn (Get $ get ) => $ get ('relationValue_options ' ) ?? [])
177182 ->searchable ()
178- ->visible (fn (Forms \ Get $ get ): bool => ! empty ($ get ('resource ' )))
179- ->required (fn (Forms \ Get $ get ): bool => ! empty ($ get ('resource ' ))),
180- Forms \ Components \ Hidden::make ('relationKey ' )
183+ ->visible (fn (Get $ get ): bool => ! empty ($ get ('resource ' )))
184+ ->required (fn (Get $ get ): bool => ! empty ($ get ('resource ' ))),
185+ Hidden::make ('relationKey ' )
181186 ->default ('ulid ' )
182187 ->label (__ ('Key ' ))
183- ->required (fn (Forms \ Get $ get ): bool => $ get ("config. {$ type }" ) == 'relationship ' ),
184- Forms \ Components \ Repeater::make ('relationValue_filters ' )
188+ ->required (fn (Get $ get ): bool => $ get ("config. {$ type }" ) == 'relationship ' ),
189+ Repeater::make ('relationValue_filters ' )
185190 ->label (__ ('Filters ' ))
186- ->visible (fn (Forms \ Get $ get ): bool => ! empty ($ get ('resource ' )))
191+ ->visible (fn (Get $ get ): bool => ! empty ($ get ('resource ' )))
187192 ->schema ([
188- Forms \ Components \ Grid::make (3 )
193+ Grid::make (3 )
189194 ->schema ([
190- Forms \ Components \ Select::make ('column ' )
191- ->options (fn (\ Filament \ Forms \ Get $ get ) => $ get ('../../relationValue_options ' ) ?? [
195+ Select::make ('column ' )
196+ ->options (fn (Get $ get ) => $ get ('../../relationValue_options ' ) ?? [
192197 'slug ' => __ ('Slug ' ),
193198 'name ' => __ ('Name ' ),
194199 ])
195200 ->live ()
196201 ->label (__ ('Column ' )),
197- Forms \ Components \ Select::make ('operator ' )
202+ Select::make ('operator ' )
198203 ->options ([
199204 '= ' => __ ('Equal ' ),
200205 '!= ' => __ ('Not equal ' ),
@@ -206,8 +211,8 @@ protected function selectableValuesFormFields(string $type, string $label, strin
206211 'NOT LIKE ' => __ ('Not like ' ),
207212 ])
208213 ->label (__ ('Operator ' )),
209- Forms \ Components \ TextInput::make ('value ' )
210- ->datalist (function (Forms \ Get $ get ) {
214+ TextInput::make ('value ' )
215+ ->datalist (function (Get $ get ) {
211216 $ resource = $ get ('../../resource ' );
212217 $ column = $ get ('column ' );
213218
@@ -233,7 +238,7 @@ protected function selectableValuesFormFields(string $type, string $label, strin
233238 ->columnSpanFull (),
234239 ]),
235240 ])
236- ->visible (fn (Forms \ Get $ get ): bool => $ get ("config. {$ type }" ) == 'relationship ' )
241+ ->visible (fn (Get $ get ): bool => $ get ("config. {$ type }" ) == 'relationship ' )
237242 ->columnSpanFull (),
238243 ]),
239244 ]);
0 commit comments