Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="flex flex-col gap-2">
<label for="option-{{ $key }}" class="text-sm font-semibold text-[var(--ca-text)]">
{{ $field['label'] }}
</label>

@if (! empty($field['help']))
<p class="text-xs text-[var(--ca-muted)]">{{ $field['help'] }}</p>
@endif

<select
id="option-{{ $key }}"
wire:model.live="options.{{ $key }}"
class="w-full rounded-[var(--ca-radius-md)] border border-[var(--ca-border)] bg-white px-3 py-2 text-sm text-[var(--ca-text)] ca-focus-ring">
@if (! empty($field['placeholder']))
<option value="">{{ $field['placeholder'] }}</option>
@endif
@foreach (($field['options'] ?? []) as $option)
<option value="{{ $option['value'] }}">{{ $option['label'] }}</option>
@endforeach
</select>
</div>
24 changes: 24 additions & 0 deletions tests/Feature/Livewire/DashboardConverterSettingsFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,27 @@ function settingsComponent(array $schema, array $options = [])
->set('options.quality', 'medium')
->assertSet('options.quality', 'medium');
});

it('renders a select option field with all choices', function () {
settingsComponent(
schema: [
[
'key' => 'page_size',
'type' => 'select',
'label' => 'Page size',
'default' => 'auto',
'options' => [
['value' => 'auto', 'label' => 'Auto'],
['value' => 'a4', 'label' => 'A4'],
['value' => 'letter', 'label' => 'Letter'],
],
],
],
options: ['page_size' => 'auto'],
)
->assertSee('Page size')
->assertSee('Auto')
->assertSee('A4')
->assertSee('Letter')
->assertSeeHtml('wire:model.live="options.page_size"');
});