diff --git a/resources/views/components/table-repeater.blade.php b/resources/views/components/table-repeater.blade.php index 282887f..fda77c4 100644 --- a/resources/views/components/table-repeater.blade.php +++ b/resources/views/components/table-repeater.blade.php @@ -3,6 +3,8 @@ use Filament\Support\Enums\Alignment; use Filament\Support\Enums\MaxWidth; + $isMinimal = $isMinimal(); + $containers = $getChildComponentContainers(); $addAction = $getAction($getAddActionName()); @@ -27,28 +29,26 @@ $statePath = $getStatePath(); foreach ($extraActions as $extraAction) { - $visibleExtraActions = array_filter( - $extraActions, - fn (Action $action): bool => $action->isVisible(), - ); + $visibleExtraActions = array_filter($extraActions, fn(Action $action): bool => $action->isVisible()); } foreach ($extraItemActions as $extraItemAction) { - $visibleExtraItemActions = array_filter( - $extraItemActions, - fn (Action $action): bool => $action->isVisible(), - ); + $visibleExtraItemActions = array_filter($extraItemActions, fn(Action $action): bool => $action->isVisible()); } - $hasActions = $reorderAction->isVisible() - || $cloneAction->isVisible() - || $deleteAction->isVisible() - || $moveUpAction->isVisible() - || $moveDownAction->isVisible() - || filled($visibleExtraItemActions); + $hasActions = + $reorderAction->isVisible() || + $cloneAction->isVisible() || + $deleteAction->isVisible() || + $moveUpAction->isVisible() || + $moveDownAction->isVisible() || + filled($visibleExtraItemActions); @endphp - +
merge($getExtraAttributes())->class([ @@ -60,140 +60,163 @@ 'xl', MaxWidth::ExtraLarge => 'break-point-xl', '2xl', MaxWidth::TwoExtraLarge => 'break-point-2xl', default => 'break-point-md', - } + }, ]) }} > + @if (count($containers) || $emptyLabel !== false) -
+
!$isMinimal, + ])> + ! $renderHeader, - 'table-repeater-header rounded-t-xl overflow-hidden border-b border-gray-950/5 dark:border-white/20' => $renderHeader, + 'table-repeater-header-hidden sr-only' => !$renderHeader, + 'table-repeater-header overflow-hidden' => $renderHeader, + 'border-b border-gray-950/5 dark:border-white/10 rounded-t-xl' => !$isMinimal, ])> - - @foreach ($headers as $key => $header) - !$isMinimal, + ])> + @foreach ($headers as $key => $header) + + @endforeach + @if ($hasActions && count($containers)) + - @endforeach - @if ($hasActions && count($containers)) - - @endif - + + @endif + !$isMinimal, + ]) > - @if (count($containers)) - @foreach ($containers as $uuid => $row) - @php - $visibleExtraItemActions = array_filter( - $extraItemActions, - fn (Action $action): bool => $action(['item' => $uuid])->isVisible(), - ); - @endphp - - @php($counter = 0) - @foreach($row->getComponents() as $cell) - @if($cell instanceof \Filament\Forms\Components\Hidden || $cell->isHidden()) - {{ $cell }} - @else - + @php($counter = 0) + @foreach ($row->getComponents() as $cell) + @if ($cell instanceof \Filament\Forms\Components\Hidden || $cell->isHidden()) {{ $cell }} - - @endif - @endforeach - - @if ($hasActions) - + @endif + @endforeach + + @if ($hasActions) + - @endif + + + @endif + + @endforeach + @else + + - @endforeach - @else - - - - @endif + @endif
getAlignment()) { - 'center', Alignment::Center => 'text-center', - 'right', 'end', Alignment::Right, Alignment::End => 'text-end', - default => 'text-start' - } - ]) - style="width: {{ $header->getWidth() }}" - > - {{ $header->getLabel() }} - @if ($header->isRequired()) - - * +
!$isMinimal, + // 'font-medium text-regular' => $isMinimal, + match ($header->getAlignment()) { + 'center', Alignment::Center => 'text-center', + 'right', 'end', Alignment::Right, Alignment::End => 'text-end', + default => 'text-start', + }, + ]) + style="width: {{ $header->getWidth() }}" + > + {{ $header->getLabel() }} + @if ($header->isRequired()) + + * + + @endif + !$isMinimal, + ])> + + {{ trans('table-repeater::components.repeater.row_actions.label') }} - @endif - - - {{ trans('table-repeater::components.repeater.row_actions.label') }} - -
! $streamlined, - 'has-hidden-label' => $cell->isLabelHidden(), - match($headers[$counter++]->getAlignment()) { - 'center', Alignment::Center => 'text-center', - 'right', 'end', Alignment::Right, Alignment::End => 'text-end', - default => 'text-start' - } - ]) - style="width: {{ $cell->getMaxWidth() ?? 'auto' }}" - > + @if (count($containers)) + @foreach ($containers as $uuid => $row) + @php + $visibleExtraItemActions = array_filter( + $extraItemActions, + fn(Action $action): bool => $action(['item' => $uuid])->isVisible(), + ); + @endphp +
-
    - @foreach ($visibleExtraItemActions as $extraItemAction) -
  • - {{ $extraItemAction(['item' => $uuid]) }} -
  • - @endforeach - - @if ($reorderAction->isVisible()) -
  • - {{ $reorderAction }} -
  • - @endif - - @if ($isReorderableWithButtons) - @if (! $loop->first) + @else +
!$streamlined && !$isMinimal, + 'pr-3 pt-5' => $isMinimal, + 'has-hidden-label' => $cell->isLabelHidden(), + match ($headers[$counter++]->getAlignment()) { + 'center', Alignment::Center => 'text-center', + 'right', 'end', Alignment::Right, Alignment::End => 'text-end', + default => 'text-start', + }, + ]) + style="width: {{ $cell->getMaxWidth() ?? 'auto' }}" + > + {{ $cell }} + +
    + @foreach ($visibleExtraItemActions as $extraItemAction) +
  • + {{ $extraItemAction(['item' => $uuid]) }} +
  • + @endforeach + + @if ($reorderAction->isVisible()) +
  • + {{ $reorderAction }} +
  • + @endif + + @if ($isReorderableWithButtons) + @if (!$loop->first) +
  • + {{ $moveUpAction(['item' => $uuid]) }} +
  • + @endif + + @if (!$loop->last) +
  • + {{ $moveDownAction(['item' => $uuid]) }} +
  • + @endif + @endif + + @if ($cloneAction->isVisible())
  • - {{ $moveUpAction(['item' => $uuid]) }} + {{ $cloneAction(['item' => $uuid]) }}
  • @endif - @if (! $loop->last) + @if ($deleteAction->isVisible())
  • - {{ $moveDownAction(['item' => $uuid]) }} + {{ $deleteAction(['item' => $uuid]) }}
  • @endif - @endif - - @if ($cloneAction->isVisible()) -
  • - {{ $cloneAction(['item' => $uuid]) }} -
  • - @endif - - @if ($deleteAction->isVisible()) -
  • - {{ $deleteAction(['item' => $uuid]) }} -
  • - @endif -
-
+ {{ $emptyLabel ?: trans('table-repeater::components.repeater.empty.label') }} +
- {{ $emptyLabel ?: trans('table-repeater::components.repeater.empty.label') }} -
@@ -209,7 +232,7 @@ class="table-repeater-column table-repeater-empty-column p-4 w-px text-center it @if (filled($visibleExtraActions)) @foreach ($visibleExtraActions as $extraAction)
  • - {{ ($extraAction) }} + {{ $extraAction }}
  • @endforeach @endif diff --git a/src/Components/TableRepeater.php b/src/Components/TableRepeater.php index d323b06..322d905 100644 --- a/src/Components/TableRepeater.php +++ b/src/Components/TableRepeater.php @@ -15,13 +15,14 @@ class TableRepeater extends Repeater use Concerns\HasHeader; protected bool | Closure | null $showLabels = null; + protected bool | Closure | null $minimal = false; protected function setUp(): void { parent::setUp(); $this->registerActions([ - fn (TableRepeater $component): array => $component->getExtraActions() + fn(TableRepeater $component): array => $component->getExtraActions() ]); } @@ -57,6 +58,18 @@ public function shouldShowLabels(): bool return $this->evaluate($this->showLabels) ?? false; } + public function minimal(bool | Closure | null $condition = true): static + { + $this->minimal = $condition; + + return $this; + } + + public function isMinimal(): bool + { + return $this->evaluate($this->minimal) ?? false; + } + public function getView(): string { return 'table-repeater::components.table-repeater';