@props([ 'icon' => null, 'label', 'href' => null, 'variant' => 'secondary', 'size' => 'md', 'type' => 'button', 'tooltipPosition' => 'bottom', 'tooltip' => 'auto', 'disabled' => false, ]) @php $variants = ['primary', 'secondary', 'ghost', 'danger']; $sizes = ['sm', 'md', 'lg']; $variant = in_array($variant, $variants, true) ? $variant : 'secondary'; $size = in_array($size, $sizes, true) ? $size : 'md'; $classes = ['ui-icon-button', 'ui-icon-button--'.$variant, 'ui-icon-button--'.$size]; $hasSlot = trim((string) $slot) !== ''; $familiarIcons = [ 'x', 'close', 'eye', 'filter', 'search', 'plus', 'edit', 'trash', 'chevron-up', 'chevron-down', 'chevron-left', 'chevron-right', ]; $tooltipEnabled = $tooltip === 'auto' ? ! in_array($icon, $familiarIcons, true) : (is_string($tooltip) ? filled($tooltip) : (bool) $tooltip); $tooltipText = is_string($tooltip) && $tooltip !== 'auto' ? $tooltip : $label; $controlAttributes = $attributes->except('title'); @endphp @if ($href) class($classes)->merge([ 'href' => $href, 'aria-label' => $label, 'data-ui-icon-button' => true, 'data-ui-tooltip-placement' => $tooltipPosition, ]) }} @unless ($tooltipEnabled) data-ui-tooltip-skip="true" @endunless @if ($disabled) aria-disabled="true" tabindex="-1" @endif > @if ($hasSlot) {{ $slot }} @elseif ($icon) @endif @else @endif