= 6ddde416cf feature: introduce Choices component and service management entities
- Added `Choices` component for dropdowns with search and multi-selection functionality.
- Implemented foundational classes for service connection:
  - `ConnectServiceData`
  - `ConnectedServiceFactory`
  - `ConnectedServicesService`
- Added `ConnectServiceForm` Livewire component for managing service connections.
- Introduced shared utility traits (`HasAttributeHelpers`) and error components.
- Added components for generic use: `Input` and `ListItem`.
2026-05-13 09:52:03 +00:00

84 lines
2.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class ListItem extends Component
{
public string $uuid;
public function __construct(
public object|array $item,
public ?string $id = null,
public string $value = 'name',
public ?string $subValue = '',
public ?bool $noSeparator = false,
public ?bool $noHover = false,
public ?string $link = null,
public ?string $fallbackAvatar = null,
// Slots
public mixed $actions = null,
) {
$this->uuid = 'component'.md5(serialize($this)).$id;
}
public function render(): View|Closure|string
{
return <<<'HTML'
<div wire:key="{{ $uuid }}">
<div
{{ $attributes->class([
"flex justify-start items-center gap-4 px-3 py-3",
"hover:bg-gray-200" => !$noHover,
"cursor-pointer" => $link
])
}}
>
<!-- CONTENT -->
<div class="flex-1 overflow-hidden whitespace-nowrap text-ellipsis truncate mary-hideable">
@if($link)
<a href="{{ $link }}" wire:navigate>
@endif
<div>
<div @if(!is_string($value)) {{ $value->attributes->class(["font-semibold truncate"]) }} @else class="font-semibold truncate" @endif>
{{ is_string($value) ? data_get($item, $value) : $value }}
</div>
<div @if(!is_string($subValue)) {{ $subValue->attributes->class(["text-base-content/50 text-sm truncate"]) }} @else class="text-base-content/50 text-sm truncate" @endif>
{{ is_string($subValue) ? data_get($item, $subValue) : $subValue }}
</div>
</div>
@if($link)
</a>
@endif
</div>
<!-- ACTION -->
@if($actions)
@if($link && !Str::of($actions)->contains([':click', '@click' , 'href']))
<a href="{{ $link }}" wire:navigate>
@endif
<div {{ $actions->attributes->class(["flex items-center gap-3 mary-hideable"]) }}>
{{ $actions }}
</div>
@if($link && !Str::of($actions)->contains([':click', '@click' , 'href']))
</a>
@endif
@endif
</div>
</div>
HTML;
}
}