|
2 | 2 |
|
3 | 3 | namespace Backstage\Fields\Fields; |
4 | 4 |
|
5 | | -use Filament\Forms; |
6 | | -use Illuminate\Support\Str; |
7 | | -use Forms\Components\Placeholder; |
8 | | -use Backstage\Fields\Models\Field; |
9 | | -use Illuminate\Support\Collection; |
| 5 | +use Backstage\Fields\Concerns\HasConfigurableFields; |
| 6 | +use Backstage\Fields\Concerns\HasFieldTypeResolver; |
| 7 | +use Backstage\Fields\Concerns\HasOptions; |
| 8 | +use Backstage\Fields\Contracts\FieldContract; |
| 9 | +use Backstage\Fields\Enums\Field as FieldEnum; |
10 | 10 | use Backstage\Fields\Facades\Fields; |
| 11 | +use Backstage\Fields\Models\Field; |
| 12 | +use Filament\Forms; |
11 | 13 | use Filament\Forms\Components\Hidden; |
| 14 | +use Filament\Forms\Components\Repeater as Input; |
| 15 | +use Filament\Forms\Components\Repeater\TableColumn; |
12 | 16 | use Filament\Forms\Components\Select; |
13 | | -use Filament\Schemas\Components\Grid; |
14 | | -use Filament\Schemas\Components\Tabs; |
15 | | -use Filament\Support\Enums\Alignment; |
16 | 17 | use Filament\Forms\Components\TextInput; |
| 18 | +use Filament\Schemas\Components\Grid; |
17 | 19 | use Filament\Schemas\Components\Section; |
18 | | -use Backstage\Fields\Concerns\HasOptions; |
| 20 | +use Filament\Schemas\Components\Tabs; |
19 | 21 | use Filament\Schemas\Components\Tabs\Tab; |
20 | | -use Backstage\Fields\Contracts\FieldContract; |
21 | | -use Backstage\Fields\Enums\Field as FieldEnum; |
22 | 22 | use Filament\Schemas\Components\Utilities\Get; |
23 | 23 | use Filament\Schemas\Components\Utilities\Set; |
24 | | -use Filament\Forms\Components\Repeater as Input; |
25 | | -use Backstage\Fields\Concerns\HasFieldTypeResolver; |
26 | | -use Filament\Forms\Components\Repeater\TableColumn; |
27 | | -use Backstage\Fields\Concerns\HasConfigurableFields; |
| 24 | +use Filament\Support\Enums\Alignment; |
| 25 | +use Forms\Components\Placeholder; |
| 26 | +use Illuminate\Support\Collection; |
| 27 | +use Illuminate\Support\Str; |
28 | 28 | use Saade\FilamentAdjacencyList\Forms\Components\AdjacencyList; |
29 | 29 |
|
30 | 30 | class Repeater extends Base implements FieldContract |
@@ -80,11 +80,11 @@ public static function make(string $name, ?Field $field = null): Input |
80 | 80 |
|
81 | 81 | if ($field && $field->children->count() > 0) { |
82 | 82 | $input = $input->schema(self::generateSchemaFromChildren($field->children)); |
83 | | - |
| 83 | + |
84 | 84 | // Apply table mode if enabled |
85 | 85 | if ($field->config['tableMode'] ?? self::getDefaultConfig()['tableMode']) { |
86 | 86 | $tableColumns = self::generateTableColumnsFromChildren($field->children, $field->config['tableColumns'] ?? []); |
87 | | - if (!empty($tableColumns)) { |
| 87 | + if (! empty($tableColumns)) { |
88 | 88 | $input = $input->table($tableColumns); |
89 | 89 | } |
90 | 90 | } |
@@ -141,7 +141,7 @@ public function getForm(): array |
141 | 141 | ->label(__('Columns')) |
142 | 142 | ->default(1) |
143 | 143 | ->numeric() |
144 | | - ->visible(fn (Get $get): bool => !($get('config.tableMode') ?? false)), |
| 144 | + ->visible(fn (Get $get): bool => ! ($get('config.tableMode') ?? false)), |
145 | 145 | AdjacencyList::make('config.form') |
146 | 146 | ->columnSpanFull() |
147 | 147 | ->label(__('Fields')) |
@@ -260,38 +260,38 @@ private static function generateTableColumnsFromChildren(Collection $children, a |
260 | 260 | foreach ($children as $child) { |
261 | 261 | $slug = $child['slug']; |
262 | 262 | $name = $child['name']; |
263 | | - |
| 263 | + |
264 | 264 | $columnConfig = $tableColumnsConfig[$slug] ?? []; |
265 | | - |
| 265 | + |
266 | 266 | $tableColumn = TableColumn::make($name); |
267 | | - |
| 267 | + |
268 | 268 | // Apply custom configuration if provided |
269 | 269 | if (isset($columnConfig['hiddenHeaderLabel']) && $columnConfig['hiddenHeaderLabel']) { |
270 | 270 | $tableColumn = $tableColumn->hiddenHeaderLabel(); |
271 | 271 | } |
272 | | - |
| 272 | + |
273 | 273 | if (isset($columnConfig['markAsRequired']) && $columnConfig['markAsRequired']) { |
274 | 274 | $tableColumn = $tableColumn->markAsRequired(); |
275 | 275 | } |
276 | | - |
| 276 | + |
277 | 277 | if (isset($columnConfig['wrapHeader']) && $columnConfig['wrapHeader']) { |
278 | 278 | $tableColumn = $tableColumn->wrapHeader(); |
279 | 279 | } |
280 | | - |
| 280 | + |
281 | 281 | if (isset($columnConfig['alignment'])) { |
282 | | - $alignment = match($columnConfig['alignment']) { |
| 282 | + $alignment = match ($columnConfig['alignment']) { |
283 | 283 | 'start' => Alignment::Start, |
284 | 284 | 'center' => Alignment::Center, |
285 | 285 | 'end' => Alignment::End, |
286 | 286 | default => Alignment::Start, |
287 | 287 | }; |
288 | 288 | $tableColumn = $tableColumn->alignment($alignment); |
289 | 289 | } |
290 | | - |
| 290 | + |
291 | 291 | if (isset($columnConfig['width'])) { |
292 | 292 | $tableColumn = $tableColumn->width($columnConfig['width']); |
293 | 293 | } |
294 | | - |
| 294 | + |
295 | 295 | $tableColumns[] = $tableColumn; |
296 | 296 | } |
297 | 297 |
|
|
0 commit comments