You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

radio-deck.blade.php 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. @php
  2. use Filament\Support\Enums\IconPosition;
  3. use Filament\Support\Enums\Alignment;
  4. use Filament\Support\Enums\IconSize;
  5. $id = $getId();
  6. $isDisabled = $isDisabled();
  7. $isMultiple = $isMultiple();
  8. $statePath = $getStatePath();
  9. @endphp
  10. <x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
  11. <x-filament::grid :default="$getColumns('default')" :sm="$getColumns('sm')" :md="$getColumns('md')"
  12. :lg="$getColumns('lg')" :xl="$getColumns('xl')"
  13. :two-xl="$getColumns('2xl')" is-grid @class(['gap-5'])>
  14. @foreach ($getOptions() as $value => $label)
  15. @php
  16. $shouldOptionBeDisabled = $isDisabled || $isOptionDisabled($value, $label);
  17. @endphp
  18. <label class="flex cursor-pointer gap-x-3">
  19. <input @disabled($shouldOptionBeDisabled) id="{{ $id }}-{{ $value }}"
  20. @if (! $isMultiple)
  21. name="{{ $id }}"
  22. @endif
  23. type="{{ $isMultiple ? 'checkbox' : 'radio' }}"
  24. value="{{ $value }}" wire:loading.attr="disabled"
  25. {{ $applyStateBindingModifiers('wire:model') }}="{{ $statePath }}"
  26. {{ $getExtraInputAttributeBag()->class(['peer hidden']) }} />
  27. @php
  28. $iconExists = $hasIcons($value);
  29. $iconPosition = $getIconPosition();
  30. $alignment = $getAlignment();
  31. $direction = $getDirection();
  32. $gap = $getGap();
  33. $padding = $getPadding();
  34. $color = $getColor();
  35. $icon = $getIcon($value);
  36. $iconSize = $getIconSize();
  37. $iconSizeSm = $getIconSizes('sm');
  38. $iconSizeMd = $getIconSizes('md');
  39. $iconSizeLg = $getIconSizes('lg');
  40. $descriptionExists = $hasDescription($value);
  41. $description = $getDescription($value);
  42. @endphp
  43. <div {{ $getExtraCardsAttributeBag()->class([
  44. 'flex w-full text-sm leading-6 rounded-lg bg-white dark:bg-gray-900',
  45. $padding ?: 'px-4 py-2',
  46. $gap ?: 'gap-5',
  47. match ($direction) {
  48. 'column' => 'flex-col',
  49. default => 'flex-row',
  50. },
  51. $iconExists
  52. ? match ($iconPosition) {
  53. IconPosition::Before, 'before' => 'justify-start',
  54. IconPosition::After, 'after' => 'justify-between flex-row-reverse',
  55. default => 'justify-start',
  56. }
  57. : 'justify-start',
  58. match ($alignment) {
  59. Alignment::Center, 'center' => 'items-center',
  60. Alignment::Start, 'start' => 'items-start',
  61. Alignment::End, 'end' => 'items-end',
  62. default => 'items-center',
  63. },
  64. 'ring-1 ring-gray-950/10 dark:ring-white/20 peer-checked:ring-2',
  65. 'peer-disabled:bg-gray-100/50 dark:peer-disabled:bg-gray-700/50 peer-disabled:cursor-not-allowed',
  66. match ($color) {
  67. 'gray' => 'peer-checked:ring-gray-600 dark:peer-checked:ring-gray-500',
  68. default
  69. => 'fi-color-custom peer-checked:ring-custom-600 dark:peer-checked:ring-custom-500',
  70. },
  71. ]) }} @style([
  72. \Filament\Support\get_color_css_variables($color, shades: [600, 500]) => $color !== 'gray',
  73. ])>
  74. @if ($iconExists)
  75. <x-filament::icon :icon="$icon" @class([
  76. 'flex-shrink-0',
  77. match ($iconSize) {
  78. IconSize::Small => $iconSizeSm ?: 'h-8 w-8',
  79. 'sm' => $iconSizeSm ?: 'h-8 w-8',
  80. IconSize::Medium => $iconSizeMd ?: 'h-9 w-9',
  81. 'md' => $iconSizeMd ?: 'h-9 w-9',
  82. IconSize::Large => $iconSizeLg ?: 'h-10 w-10',
  83. 'lg' => $iconSizeLg ?: 'h-10 w-10',
  84. default => 'h-8 w-8',
  85. },
  86. match ($color) {
  87. 'gray' => 'fi-color-gray text-gray-600 dark:text-gray-500',
  88. default => 'fi-color-custom text-custom-600 dark:text-custom-500',
  89. },
  90. ]) @style([
  91. \Filament\Support\get_color_css_variables($color, shades: [600, 500]) => $color !== 'gray',
  92. ]) />
  93. @endif
  94. <div {{ $getExtraOptionsAttributeBag()->merge(['class' =>'place-items-start']) }}>
  95. <span class="font-medium text-gray-950 dark:text-white">
  96. {{ $label }}
  97. </span>
  98. @if ($descriptionExists)
  99. <p {{ $getExtraDescriptionsAttributeBag()->merge(['class' =>'text-gray-500 dark:text-gray-400']) }}>
  100. {{ $description }}
  101. </p>
  102. @endif
  103. </div>
  104. </div>
  105. </label>
  106. @endforeach
  107. </x-filament::grid>
  108. </x-dynamic-component>