@props([
'trigger' => null,
'content' => null,
'text' => null,
'position' => 'top',
'icon' => null,
'label' => null,
'id' => null,
'triggerAttributes' => [],
'showWhen' => null,
'disabled' => false,
])
@php
$position = in_array($position, ['top', 'right', 'bottom', 'left'], true) ? $position : 'top';
$tooltipId = $id ?: 'ui-tooltip-'.\Illuminate\Support\Str::uuid();
$hasTriggerSlot = trim((string) $slot) !== '';
$tooltipText = $text ?? $content ?? '';
@endphp
@if ($disabled)
@if ($hasTriggerSlot)
{{ $slot }}
@elseif ($trigger)
{{ $trigger }}
@elseif ($icon)
@if ($label)
{{ $label }}
@endif
@else
@if ($label)
{{ $label }}
@endif
@endif
@else
class(['ui-tooltip', 'ui-tooltip--'.$position])->merge([
'data-ui-tooltip' => true,
'data-ui-tooltip-placement' => $position,
'data-ui-tooltip-show-when' => $showWhen,
]) }}
>
$value)
{{ $attribute }}="{{ $value }}"
@endforeach
class="ui-tooltip__trigger"
data-ui-tooltip-trigger
@if ($hasTriggerSlot)
data-ui-tooltip-description-owner="nested-control"
@else
tabindex="0"
aria-describedby="{{ $tooltipId }}"
@endif
>
@if ($hasTriggerSlot)
{{ $slot }}
@elseif ($trigger)
{{ $trigger }}
@elseif ($icon)
@if ($label)
{{ $label }}
@endif
@else
@if ($label)
{{ $label }}
@endif
@endif
{{ $tooltipText }}
@endif