diff --git a/src/DataTransferObjects/Filters/FilterPillData.php b/src/DataTransferObjects/Filters/FilterPillData.php index 8ecc241a7..53a5d1c98 100644 --- a/src/DataTransferObjects/Filters/FilterPillData.php +++ b/src/DataTransferObjects/Filters/FilterPillData.php @@ -12,15 +12,15 @@ public function __construct( protected string $filterKey, protected string $filterPillTitle, protected string|array|null $filterPillValue, - protected string $separator, - public bool $isAnExternalLivewireFilter, - public bool $hasCustomPillBlade, - protected ?string $customPillBlade, - protected array $filterPillsItemAttributes, - protected bool $renderPillsAsHtml, - protected bool $watchForEvents, - protected array $customResetButtonAttributes, - protected bool $renderPillsTitleAsHtml) {} + protected string $separator = ',', + public bool $isAnExternalLivewireFilter = false, + public bool $hasCustomPillBlade = false, + protected ?string $customPillBlade = null, + protected array $filterPillsItemAttributes = [], + protected bool $renderPillsAsHtml = false, + protected bool $watchForEvents = false, + protected array $customResetButtonAttributes = [], + protected bool $renderPillsTitleAsHtml = false) {} public static function make(string $filterKey, string $filterPillTitle, string|array|null $filterPillValue, string $separator = ', ', bool $isAnExternalLivewireFilter = false, bool $hasCustomPillBlade = false, ?string $customPillBlade = null, array $filterPillsItemAttributes = [], bool $renderPillsAsHtml = false, bool $watchForEvents = false, array $customResetButtonAttributes = [], bool $renderPillsTitleAsHtml = false): FilterPillData { @@ -43,7 +43,7 @@ public function getPillValue(): array|string|null public function getHasCustomPillBlade(): bool { - return $this->hasCustomPillBlade ?? false; + return $this->hasCustomPillBlade; } public function getCustomPillBlade(): ?string @@ -53,32 +53,32 @@ public function getCustomPillBlade(): ?string public function getCustomResetButtonAttributes(): array { - return $this->customResetButtonAttributes ?? []; + return $this->customResetButtonAttributes; } public function getIsAnExternalLivewireFilter(): int { - return intval($this->isAnExternalLivewireFilter ?? 0); + return intval($this->isAnExternalLivewireFilter); } public function getSeparator(): string { - return $this->separator ?? ', '; + return $this->separator; } public function shouldUsePillsAsHtml(): int { - return intval($this->renderPillsAsHtml ?? 0); + return intval($this->renderPillsAsHtml); } public function shouldUsePillsTitleAsHtml(): int { - return intval($this->renderPillsTitleAsHtml ?? 0); + return intval($this->renderPillsTitleAsHtml); } public function shouldWatchForEvents(): int { - return intval($this->watchForEvents ?? 0); + return intval($this->watchForEvents); } public function isPillValueAnArray(): bool diff --git a/src/DataTransferObjects/Filters/StandardFilterPillData.php b/src/DataTransferObjects/Filters/StandardFilterPillData.php index 60a8ff5f9..978837ac1 100644 --- a/src/DataTransferObjects/Filters/StandardFilterPillData.php +++ b/src/DataTransferObjects/Filters/StandardFilterPillData.php @@ -28,7 +28,7 @@ public function getPillValue(): string public function shouldUsePillsAsHtml(): bool { - return $this->renderPillsAsHtml ?? false; + return $this->renderPillsAsHtml; } public function toArray(): array diff --git a/src/Traits/Configuration/CollapsingColumnConfiguration.php b/src/Traits/Configuration/CollapsingColumnConfiguration.php index dada8b991..c1d2e51f3 100644 --- a/src/Traits/Configuration/CollapsingColumnConfiguration.php +++ b/src/Traits/Configuration/CollapsingColumnConfiguration.php @@ -27,8 +27,7 @@ public function setCollapsingColumnsDisabled(): self public function unsetCollapsedStatuses(): void { - unset($this->shouldAlwaysCollapse); - unset($this->shouldMobileCollapse); - unset($this->shouldTabletCollapse); + $this->shouldAlwaysCollapse = $this->shouldMobileCollapse = $this->shouldTabletCollapse = false; + } } diff --git a/src/Views/Columns/ArrayColumn.php b/src/Views/Columns/ArrayColumn.php index 26d39dbfd..c1470aaab 100644 --- a/src/Views/Columns/ArrayColumn.php +++ b/src/Views/Columns/ArrayColumn.php @@ -24,6 +24,10 @@ class ArrayColumn extends Column protected mixed $outputFormat = null; + public ?string $outputWrapperStart = null; + + public ?string $outputWrapperEnd = null; + public function __construct(string $title, ?string $from = null) { parent::__construct($title, $from); @@ -49,6 +53,12 @@ public function getContents(Model $row): null|string|\BackedEnum|HtmlString|Data $outputValues[] = call_user_func($this->getOutputFormatCallback(), $i, $v); } - return new HtmlString((! empty($outputValues) ? implode($this->getSeparator(), $outputValues) : $this->getEmptyValue())); + $returnedValue = (! empty($outputValues) ? implode($this->getSeparator(), $outputValues) : $this->getEmptyValue()); + + if ($this->hasOutputWrapperStart() && $this->hasOutputWrapperEnd()) { + $returnedValue = $this->getOutputWrapperStart().$returnedValue.$this->getOutputWrapperEnd(); + } + + return new HtmlString($returnedValue); } } diff --git a/src/Views/Columns/Traits/Configuration/ArrayColumnConfiguration.php b/src/Views/Columns/Traits/Configuration/ArrayColumnConfiguration.php index 3cab2b52d..19891bbf2 100644 --- a/src/Views/Columns/Traits/Configuration/ArrayColumnConfiguration.php +++ b/src/Views/Columns/Traits/Configuration/ArrayColumnConfiguration.php @@ -2,6 +2,8 @@ namespace Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration; +use Illuminate\View\ComponentAttributeBag; + trait ArrayColumnConfiguration { public function separator(string $value): self @@ -34,4 +36,36 @@ public function emptyValue(string $emptyValue): self return $this; } + + public function wrapperStart(string $value): self + { + $this->outputWrapperStart = $value; + + return $this; + } + + public function wrapperEnd(string $value): self + { + $this->outputWrapperEnd = $value; + + return $this; + } + + public function flexCol(array $attribs = []): self + { + $bag = new ComponentAttributeBag(['class' => $this->isTailwind() ? 'flex flex-col' : 'd-flex d-flex-col']); + + return $this->wrapperStart('