index.blade.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. @props([
  2. 'availableHeight' => null,
  3. 'availableWidth' => null,
  4. 'flip' => true,
  5. 'maxHeight' => null,
  6. 'offset' => 8,
  7. 'placement' => null,
  8. 'shift' => false,
  9. 'size' => false,
  10. 'sizePadding' => 16,
  11. 'teleport' => false,
  12. 'trigger' => null,
  13. 'width' => null,
  14. ])
  15. @php
  16. use Filament\Support\Enums\Width;
  17. $sizeConfig = collect([
  18. 'availableHeight' => $availableHeight,
  19. 'availableWidth' => $availableWidth,
  20. 'padding' => $sizePadding,
  21. ])->filter()->toJson();
  22. if (is_string($width)) {
  23. $width = Width::tryFrom($width) ?? $width;
  24. }
  25. @endphp
  26. <div
  27. x-data="filamentDropdown"
  28. {{ $attributes->class(['fi-dropdown']) }}
  29. >
  30. <div
  31. x-on:mousedown="if ($event.button === 0) toggle($event)"
  32. {{ $trigger->attributes->class(['fi-dropdown-trigger']) }}
  33. >
  34. {{ $trigger }}
  35. </div>
  36. @if (! \Filament\Support\is_slot_empty($slot))
  37. <div
  38. x-cloak
  39. x-float{{ $placement ? ".placement.{$placement}" : '' }}{{ $size ? '.size' : '' }}{{ $flip ? '.flip' : '' }}{{ $shift ? '.shift' : '' }}{{ $teleport ? '.teleport' : '' }}{{ $offset ? '.offset' : '' }}="{ offset: {{ $offset }}, {{ $size ? ('size: ' . $sizeConfig) : '' }} }"
  40. x-ref="panel"
  41. x-transition:enter-start="fi-opacity-0"
  42. x-transition:leave-end="fi-opacity-0"
  43. @if ($attributes->has('wire:key'))
  44. wire:ignore.self
  45. wire:key="{{ $attributes->get('wire:key') }}.panel"
  46. @endif
  47. @class([
  48. 'fi-dropdown-panel',
  49. ($width instanceof Width) ? "fi-width-{$width->value}" : (is_string($width) ? $width : ''),
  50. 'fi-scrollable' => $maxHeight || $size,
  51. ])
  52. @style([
  53. "max-height: {$maxHeight}" => $maxHeight,
  54. ])
  55. >
  56. {{ $slot }}
  57. </div>
  58. @endif
  59. </div>