actions.blade.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. @php
  2. use Filament\Support\Enums\Alignment;
  3. @endphp
  4. @props([
  5. 'actions' => [],
  6. 'alignment' => Alignment::Start,
  7. 'fullWidth' => false,
  8. ])
  9. @php
  10. if (is_array($actions)) {
  11. $actions = array_filter(
  12. $actions,
  13. fn ($action): bool => $action->isVisible(),
  14. );
  15. }
  16. if (! $alignment instanceof Alignment) {
  17. $alignment = filled($alignment) ? (Alignment::tryFrom($alignment) ?? $alignment) : null;
  18. }
  19. $hasActions = false;
  20. $hasSlot = ! \Filament\Support\is_slot_empty($slot);
  21. $actionsAreHtmlable = $actions instanceof \Illuminate\Contracts\Support\Htmlable;
  22. if ($hasSlot) {
  23. $hasActions = true;
  24. } elseif ($actionsAreHtmlable) {
  25. $hasActions = ! \Filament\Support\is_slot_empty($actions);
  26. } else {
  27. $hasActions = filled($actions);
  28. }
  29. @endphp
  30. @if ($hasActions)
  31. <div
  32. {{
  33. $attributes->class([
  34. 'fi-ac',
  35. 'fi-width-full' => $fullWidth,
  36. ($alignment instanceof Alignment) ? "fi-align-{$alignment->value}" : (is_string($alignment) ? $alignment : null) => ! $fullWidth,
  37. ])
  38. }}
  39. >
  40. @if ($hasSlot)
  41. {{ $slot }}
  42. @elseif ($actionsAreHtmlable)
  43. {{ $actions }}
  44. @else
  45. @foreach ($actions as $action)
  46. {{ $action }}
  47. @endforeach
  48. @endif
  49. </div>
  50. @endif