Skip to content

Commit fecf8a1

Browse files
committed
Merge Test
1 parent 5679ec4 commit fecf8a1

File tree

597 files changed

+42252
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

597 files changed

+42252
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Features\Actions\Core\Configuration;
4+
5+
trait ActionsConfiguration
6+
{
7+
public function setActionsInToolbar(bool $status): self
8+
{
9+
$this->displayActionsInToolbar = $status;
10+
11+
return $this;
12+
}
13+
14+
public function setActionsInToolbarEnabled(): self
15+
{
16+
return $this->setActionsInToolbar(true);
17+
}
18+
19+
public function setActionsInToolbarDisabled(): self
20+
{
21+
return $this->setActionsInToolbar(false);
22+
}
23+
24+
protected function setActionsPosition(string $position): self
25+
{
26+
$this->actionsPosition = ($position == 'left' || $position == 'center' || $position == 'right') ? $position : 'right';
27+
28+
return $this;
29+
}
30+
31+
public function setActionsLeft(): self
32+
{
33+
return $this->setActionsPosition('left');
34+
}
35+
36+
public function setActionsCenter(): self
37+
{
38+
return $this->setActionsPosition('center');
39+
}
40+
41+
public function setActionsRight(): self
42+
{
43+
return $this->setActionsPosition('right');
44+
}
45+
46+
public function setActionsAsDropdown(bool $status): self
47+
{
48+
$this->displayActionsAsDropdown = $status;
49+
50+
return $this;
51+
}
52+
53+
public function setActionsAsDropdownEnabled(): self
54+
{
55+
$this->setActionsInToolbarEnabled();
56+
57+
return $this->setActionsAsDropdown(true);
58+
}
59+
60+
public function setActionsAsDropdownDisabled(): self
61+
{
62+
return $this->setActionsAsDropdown(false);
63+
}
64+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Features\Actions\Core\Helpers;
4+
5+
use Livewire\Attributes\Computed;
6+
use Rappasoft\LaravelLivewireTables\Features\Actions\Views\Action;
7+
use Rappasoft\LaravelLivewireTables\Collections\ActionCollection;
8+
9+
trait ActionsHelpers
10+
{
11+
/**
12+
* Undocumented function
13+
*
14+
* @return boolean
15+
*/
16+
#[Computed]
17+
public function showActionsInToolbarLeft(): bool
18+
{
19+
return $this->hasActions() && $this->showActionsInToolbar() && $this->getActionsPosition() === 'left';
20+
}
21+
22+
/**
23+
* Undocumented function
24+
*
25+
* @return boolean
26+
*/
27+
#[Computed]
28+
public function showActionsInToolbarRight(): bool
29+
{
30+
return $this->hasActions() && $this->showActionsInToolbar() && $this->getActionsPosition() === 'right';
31+
}
32+
33+
/**
34+
* Determines whether to display the Actions in the Toolbar
35+
*
36+
* @return boolean
37+
*/
38+
#[Computed]
39+
public function showActionsInToolbar(): bool
40+
{
41+
return $this->displayActionsInToolbar ?? false;
42+
}
43+
44+
/**
45+
* Determines whether to display the Actions in a Dropdown in the Toolbar by default
46+
*
47+
* @return boolean
48+
*/
49+
#[Computed]
50+
public function showActionsAsDropdown(): bool
51+
{
52+
return $this->displayActionsAsDropdown ?? false;
53+
}
54+
/**
55+
* Retrieves the position of the Actions (e.g. left/right)
56+
*
57+
* @return string
58+
*/
59+
#[Computed]
60+
public function getActionsPosition(): string
61+
{
62+
return $this->actionsPosition ?? 'right';
63+
}
64+
65+
/**
66+
* Returns whether there are any valid actions
67+
*
68+
* @return boolean
69+
*/
70+
#[Computed]
71+
public function hasActions(): bool
72+
{
73+
if (! isset($this->validActions) || empty($this->validActions)) {
74+
$this->validActions = $this->getActions();
75+
}
76+
77+
return $this->validActions->count() > 0;
78+
}
79+
80+
/**
81+
* Retrieves the valid actions
82+
*
83+
* @return ActionCollection<int,Action>
84+
*/
85+
#[Computed]
86+
public function getActions(): ActionCollection
87+
{
88+
return (new ActionCollection($this->actions()))
89+
->each(function (Action $action, int $key) {
90+
$action->setTheme($this->getTheme());
91+
});
92+
93+
}
94+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Features\Actions\Core\Styling;
4+
5+
use Livewire\Attributes\Computed;
6+
use Illuminate\View\ComponentAttributeBag;
7+
8+
trait HasActionsStyling
9+
{
10+
/**
11+
* Undocumented variable
12+
*
13+
* @var array<mixed>
14+
*/
15+
protected array $actionWrapperAttributes = ['class' => '', 'default-styling' => true, 'default-colors' => true];
16+
17+
/**
18+
* Undocumented variable
19+
*
20+
* @var array<mixed>
21+
*/
22+
protected array $actionsMenuAttributes = ['default-colors' => true, 'default-styling' => true];
23+
24+
/**
25+
* Undocumented variable
26+
*
27+
* @var array<mixed>|null
28+
*/
29+
protected ?array $actionsMenuTransitionAttributes;
30+
31+
/**
32+
* Undocumented variable
33+
*
34+
* @var array<mixed>
35+
*/
36+
protected array $actionsButtonAttributes = ['default-colors' => true, 'default-styling' => true];
37+
38+
/**
39+
* Undocumented function
40+
*
41+
* @return array<mixed>
42+
*/
43+
#[Computed]
44+
public function getActionWrapperAttributes(): array
45+
{
46+
return [...['class' => '', 'default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes];
47+
}
48+
49+
/**
50+
* Undocumented function
51+
*
52+
* @param array<mixed> $actionWrapperAttributes
53+
* @return self
54+
*/
55+
public function setActionWrapperAttributes(array $actionWrapperAttributes): self
56+
{
57+
$this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];
58+
59+
return $this;
60+
}
61+
62+
/**
63+
* Undocumented function
64+
*
65+
* @param array<mixed> $actionsMenuAttributes
66+
* @return self
67+
*/
68+
public function setActionMenuAttributes(array $actionsMenuAttributes): self
69+
{
70+
$this->actionsMenuAttributes = [...$this->actionsMenuAttributes, ...$actionsMenuAttributes];
71+
72+
return $this;
73+
}
74+
/**
75+
* Used to get attributes for the Bulk Actions Button
76+
*
77+
* @return array<mixed>
78+
*/
79+
#[Computed]
80+
public function getActionsButtonAttributes(): array
81+
{
82+
return [...['x-ref' => 'actionsMenuButton', 'type' => 'button', 'aria-haspopup' => 'false'], ...(($this->isTailwind() || $this->isTailwind4()) ? ['x-on:click' => 'open = !open'] : ['data-toggle' => 'dropdown', 'data-bs-toggle' => 'dropdown']), ...$this->getCustomAttributes('actionsButtonAttributes', true)];
83+
84+
}
85+
86+
/**
87+
* Undocumented function
88+
*
89+
* @return ComponentAttributeBag
90+
*/
91+
public function getActionsButtonAttributesBag(): ComponentAttributeBag
92+
{
93+
return $this->getCustomAttributesBagFromArray($this->getActionsButtonAttributes());
94+
}
95+
96+
/**
97+
* Used to get attributes for the Actions Menu (Dropdown)
98+
*
99+
* @return array<mixed>
100+
*/
101+
#[Computed]
102+
public function getActionsMenuAttributes(): array
103+
{
104+
return [...$this->getCoreMenuAttributes(), ...(($this->isTailwind() || $this->isTailwind4()) ? ['x-anchor.bottom-start' => '$refs.actionsMenuButton'] : []), ...$this->getActionsMenuTransitionAttributes(), ...$this->getCustomAttributes('actionsMenuAttributes', true, false)];
105+
}
106+
107+
/**
108+
* Gets Actions Menu Transition Attributes
109+
*
110+
* @return array<mixed>
111+
*/
112+
protected function getActionsMenuTransitionAttributes(): array
113+
{
114+
if($this->isTailwind() || $this->isTailwind4())
115+
{
116+
return isset($this->actionsMenuTransitionAttributes) ? $this->actionsMenuTransitionAttributes : $this->getCoreTransitionAttributes();
117+
}
118+
return [];
119+
}
120+
121+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Features\Actions\Core;
4+
5+
use Rappasoft\LaravelLivewireTables\Collections\ActionCollection;
6+
use Rappasoft\LaravelLivewireTables\Features\Actions\Core\Configuration\ActionsConfiguration;
7+
use Rappasoft\LaravelLivewireTables\Features\Actions\Core\Helpers\ActionsHelpers;
8+
use Rappasoft\LaravelLivewireTables\Features\Actions\Core\Styling\HasActionsStyling;
9+
10+
trait WithActions
11+
{
12+
use ActionsConfiguration,
13+
ActionsHelpers,
14+
HasActionsStyling;
15+
16+
/**
17+
* Undocumented variable
18+
*
19+
* @var boolean
20+
*/
21+
protected bool $displayActionsInToolbar = false;
22+
23+
/**
24+
* Undocumented variable
25+
*
26+
* @var boolean
27+
*/
28+
protected bool $displayActionsAsDropdown = false;
29+
30+
/**
31+
* Undocumented variable
32+
*
33+
* @var string
34+
*/
35+
protected string $actionsPosition = 'right';
36+
37+
/**
38+
* Undocumented variable
39+
*
40+
* @var ActionCollection<int,\Rappasoft\LaravelLivewireTables\Features\Actions\Views\Action>|null
41+
*/
42+
protected ?ActionCollection $validActions;
43+
44+
/**
45+
* Undocumented function
46+
*
47+
* @return array<mixed>
48+
*/
49+
protected function actions(): array
50+
{
51+
return [];
52+
}
53+
}

0 commit comments

Comments
 (0)