Skip to content

Commit

Permalink
Migrate Styling Configs
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe committed Dec 11, 2024
1 parent d97455e commit 91fe219
Show file tree
Hide file tree
Showing 36 changed files with 403 additions and 204 deletions.
5 changes: 0 additions & 5 deletions src/Traits/Configuration/ActionsConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

trait ActionsConfiguration
{
public function setActionWrapperAttributes(array $actionWrapperAttributes): self
{
$this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];

return $this;
}

public function setActionsInToolbar(bool $status): self
{
Expand Down
22 changes: 0 additions & 22 deletions src/Traits/Configuration/CollapsingColumnConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,5 @@ public function setCollapsingColumnsDisabled(): self
return $this;
}

/**
* Used to set attributes for the Collapsed Column Collapse Button
*
* @param array<mixed> $collapsingColumnButtonCollapseAttributes
*/
public function setCollapsingColumnButtonCollapseAttributes(array $collapsingColumnButtonCollapseAttributes): self
{
$this->collapsingColumnButtonCollapseAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonCollapseAttributes];

return $this;
}

/**
* Used to set attributes for the Collapsed Column Expand Button
*
* @param array<mixed> $collapsingColumnButtonExpandAttributes
*/
public function setCollapsingColumnButtonExpandAttributes(array $collapsingColumnButtonExpandAttributes): self
{
$this->collapsingColumnButtonExpandAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonExpandAttributes];

return $this;
}
}
14 changes: 0 additions & 14 deletions src/Traits/Configuration/FooterConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,4 @@ public function setUseHeaderAsFooterDisabled(): self

return $this;
}

public function setFooterTrAttributes(Closure $callback): self
{
$this->footerTrAttributesCallback = $callback;

return $this;
}

public function setFooterTdAttributes(Closure $callback): self
{
$this->footerTdAttributesCallback = $callback;

return $this;
}
}
13 changes: 0 additions & 13 deletions src/Traits/Configuration/PaginationConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ public function setDefaultPerPage(int $defaultPerPage): self
return $this;
}

public function setPerPageFieldAttributes(array $attributes = []): self
{
$this->perPageFieldAttributes = [...$this->perPageFieldAttributes, ...$attributes];

return $this;
}

public function setShouldRetrieveTotalItemCountStatus(bool $status): self
{
$this->shouldRetrieveTotalItemCount = $status;
Expand All @@ -183,10 +176,4 @@ public function setShouldRetrieveTotalItemCountDisabled(): self
return $this;
}

public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
{
$this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);

return $this;
}
}
9 changes: 0 additions & 9 deletions src/Traits/Configuration/ReorderingConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,4 @@ public function setDefaultReorderSort(string $field, string $direction = 'asc'):
return $this;
}

/**
* Used to set attributes for the <th> for Reorder Column
*/
public function setReorderThAttributes(array $reorderThAttributes): self
{
$this->reorderThAttributes = [...$this->reorderThAttributes, ...$reorderThAttributes];

return $this;
}
}
16 changes: 0 additions & 16 deletions src/Traits/Configuration/SecondaryHeaderConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Rappasoft\LaravelLivewireTables\Traits\Configuration;

use Closure;

trait SecondaryHeaderConfiguration
{
public function setSecondaryHeaderStatus(bool $status): self
Expand All @@ -26,18 +24,4 @@ public function setSecondaryHeaderDisabled(): self

return $this;
}

public function setSecondaryHeaderTrAttributes(Closure $callback): self
{
$this->secondaryHeaderTrAttributesCallback = $callback;

return $this;
}

public function setSecondaryHeaderTdAttributes(Closure $callback): self
{
$this->secondaryHeaderTdAttributesCallback = $callback;

return $this;
}
}
5 changes: 0 additions & 5 deletions src/Traits/Helpers/ActionsHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ public function getActionsPosition(): string
return $this->actionsPosition ?? 'right';
}

#[Computed]
public function getActionWrapperAttributes(): array
{
return [...['class' => '', 'default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes];
}

#[Computed]
public function hasActions(): bool
Expand Down
22 changes: 0 additions & 22 deletions src/Traits/Helpers/CollapsingColumnHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,6 @@ public function collapsingColumnsAreDisabled(): bool
return $this->getCollapsingColumnsStatus() === false;
}

/**
* Retrieves attributes for the Collapsed Column Collapse Button
*
* @return array<mixed>
*/
#[Computed]
public function getCollapsingColumnButtonCollapseAttributes(): array
{
return [...['default-styling' => true, 'default-colors' => true], ...$this->collapsingColumnButtonCollapseAttributes];
}

/**
* Retrieves attributes for the Collapsed Column Expand Button
*
* @return array<mixed>
*/
#[Computed]
public function getCollapsingColumnButtonExpandAttributes(): array
{
return [...['default-styling' => true, 'default-colors' => true], ...$this->collapsingColumnButtonExpandAttributes];
}

#[Computed]
public function showCollapsingColumnSections(): bool
{
Expand Down
17 changes: 0 additions & 17 deletions src/Traits/Helpers/FooterHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,4 @@ public function useHeaderAsFooterIsDisabled(): bool
return $this->getUseHeaderAsFooterStatus() === false;
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getFooterTrAttributes($rows): array
{
return isset($this->footerTrAttributesCallback) ? call_user_func($this->footerTrAttributesCallback, $rows) : ['default' => true];
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getFooterTdAttributes(Column $column, $rows, int $index): array
{
return isset($this->footerTdAttributesCallback) ? call_user_func($this->footerTdAttributesCallback, $column, $rows, $index) : ['default' => true];
}
}
16 changes: 0 additions & 16 deletions src/Traits/Helpers/PaginationHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,10 @@ private function getPerPagePaginationSessionKey(): string
return $this->tableName.'-perPage';
}

#[Computed]
public function getPerPageFieldAttributes(): array
{
return $this->perPageFieldAttributes;
}

#[Computed]
public function getShouldRetrieveTotalItemCount(): bool
{
return $this->shouldRetrieveTotalItemCount;
}

public function getPaginationWrapperAttributes(): array
{
return $this->paginationWrapperAttributes ?? ['class' => ''];
}

#[Computed]
public function getPaginationWrapperAttributesBag(): ComponentAttributeBag
{
return new ComponentAttributeBag($this->getPaginationWrapperAttributes());
}
}
17 changes: 0 additions & 17 deletions src/Traits/Helpers/ReorderingHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,6 @@ public function getReorderingBackupSessionKey(): string
return $this->getTableName().'-reordering-backup';
}

/**
* Used to get attributes for the <th> for Bulk Actions
*
* @return array<mixed>
*/
#[Computed]
public function getReorderThAttributes(): array
{
return $this->reorderThAttributes ?? ['default' => true];
}

#[Computed]
public function hasReorderThAttributes(): bool
{
return $this->getReorderThAttributes() != ['default' => true];
}

public function getReorderColumn(): Column
{
return Column::make('reorder')->label(fn () => null);
Expand Down
19 changes: 0 additions & 19 deletions src/Traits/Helpers/SecondaryHeaderHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Rappasoft\LaravelLivewireTables\Traits\Helpers;

use Rappasoft\LaravelLivewireTables\Views\Column;

trait SecondaryHeaderHelpers
{
public function hasColumnsWithSecondaryHeader(): bool
Expand All @@ -26,21 +24,4 @@ public function secondaryHeaderIsDisabled(): bool
return $this->getSecondaryHeaderStatus() === false;
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getSecondaryHeaderTrAttributes($rows): array
{
return isset($this->secondaryHeaderTrAttributesCallback) ? call_user_func($this->secondaryHeaderTrAttributesCallback, $rows) : ['default' => true];
}

/**
* @param mixed $rows
* @return array<mixed>
*/
public function getSecondaryHeaderTdAttributes(Column $column, $rows, int $index): array
{
return isset($this->secondaryHeaderTdAttributesCallback) ? call_user_func($this->secondaryHeaderTdAttributesCallback, $column, $rows, $index) : ['default' => true];
}
}
13 changes: 13 additions & 0 deletions src/Traits/Styling/Configuration/ActionsStylingConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait ActionsStylingConfiguration
{
public function setActionWrapperAttributes(array $actionWrapperAttributes): self
{
$this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];

return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait CollapsingColumnsStylingConfiguration
{
/**
* Used to set attributes for the Collapsed Column Collapse Button
*
* @param array<mixed> $collapsingColumnButtonCollapseAttributes
*/
public function setCollapsingColumnButtonCollapseAttributes(array $collapsingColumnButtonCollapseAttributes): self
{
$this->collapsingColumnButtonCollapseAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonCollapseAttributes];

return $this;
}

/**
* Used to set attributes for the Collapsed Column Expand Button
*
* @param array<mixed> $collapsingColumnButtonExpandAttributes
*/
public function setCollapsingColumnButtonExpandAttributes(array $collapsingColumnButtonExpandAttributes): self
{
$this->collapsingColumnButtonExpandAttributes = [...['default-colors' => false, 'default-styling' => false], ...$collapsingColumnButtonExpandAttributes];

return $this;
}

}
23 changes: 23 additions & 0 deletions src/Traits/Styling/Configuration/FooterStylingConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

use Closure;

trait FooterStylingConfiguration
{
public function setFooterTrAttributes(Closure $callback): self
{
$this->footerTrAttributesCallback = $callback;

return $this;
}

public function setFooterTdAttributes(Closure $callback): self
{
$this->footerTdAttributesCallback = $callback;

return $this;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait PaginationStylingConfiguration
{

public function setPerPageFieldAttributes(array $attributes = []): self
{
$this->perPageFieldAttributes = [...$this->perPageFieldAttributes, ...$attributes];

return $this;
}

public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
{
$this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);

return $this;
}
}
18 changes: 18 additions & 0 deletions src/Traits/Styling/Configuration/ReorderStylingConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration;

trait ReorderStylingConfiguration
{

/**
* Used to set attributes for the <th> for Reorder Column
*/
public function setReorderThAttributes(array $reorderThAttributes): self
{
$this->reorderThAttributes = [...$this->reorderThAttributes, ...$reorderThAttributes];

return $this;
}

}
Loading

0 comments on commit 91fe219

Please sign in to comment.