mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00

- enhance plugin card ui - refactor components to be more consistent - invert toggler label for better UX - edit view components regex
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Views\Components\Forms;
|
|
|
|
class MultiSelect extends FormComponent
|
|
{
|
|
protected array $props = ['options', 'selected'];
|
|
|
|
protected array $casts = [
|
|
'options' => 'array',
|
|
'selected' => 'array',
|
|
];
|
|
|
|
/**
|
|
* @var array<string, string>
|
|
*/
|
|
protected array $options = [];
|
|
|
|
/**
|
|
* @var string[]
|
|
*/
|
|
protected array $selected = [];
|
|
|
|
public function render(): string
|
|
{
|
|
$this->mergeClass('w-full bg-elevated border-3 border-contrast rounded-lg');
|
|
|
|
$defaultAttributes = [
|
|
'data-class' => $this->attributes['class'],
|
|
'multiple' => 'multiple',
|
|
'data-select-text' => lang('Common.forms.multiSelect.selectText'),
|
|
'data-loading-text' => lang('Common.forms.multiSelect.loadingText'),
|
|
'data-no-results-text' => lang('Common.forms.multiSelect.noResultsText'),
|
|
'data-no-choices-text' => lang('Common.forms.multiSelect.noChoicesText'),
|
|
'data-max-item-text' => lang('Common.forms.multiSelect.maxItemText'),
|
|
];
|
|
$extra = [...$defaultAttributes, ...$this->attributes];
|
|
|
|
return form_dropdown($this->name, $this->options, $this->selected, $extra);
|
|
}
|
|
}
|