@props([ 'show' => true, 'class' => [], 'icon' => null, 'ricon' => null, 'label' => null, 'color' => 'primary', 'size' => null, 'type' => 'button', 'route' => null, 'url' => null, 'href' => null, 'dismiss' => null, 'toggle' => null, 'click' => null, 'confirm' => false, 'spin' => true ]) @php if (!$show) return; if ($route) $href = route($route); else if ($url) $href = url($url); $classes = is_array($class) ? $class : explode(' ', trim($class)); $attributes = $attributes->class([ 'btn btn-' . $color, 'btn-' . $size => $size, ...$classes ])->merge([ 'type' => !$href ? $type : null, 'href' => $href, 'data-bs-dismiss' => $dismiss, 'data-bs-toggle' => $toggle, 'wire:click' => $click, 'wire:loading.attr' => !$href && ($spin && $click) ? 'disabled' : null, 'wire:loading.class'=> !$href && ($spin && $click) ? 'spinner spinner-right spinner-primary' : null, 'wire:target' => !$href && $click ? $click : null, 'onclick' => $confirm ? 'confirm("Êtes vous sûr(e) de vouloir ' . (is_string($confirm) ? $confirm : 'effectuer cette action') . '?") || event.stopImmediatePropagation()' : null, ]); @endphp <{{ $href ? 'a' : 'button' }} {{ $attributes }} > @if(($icon || $ricon) && strlen($label ?? $slot)) {{ $label ?? $slot }} @else {{ $label ?? $slot }} @endif