Merge branch '2.x' into 3.x

This commit is contained in:
Dan Harrin
2023-01-22 15:54:28 +00:00
6 changed files with 96 additions and 31 deletions
@@ -8,16 +8,20 @@ use Illuminate\View\ComponentAttributeBag;
trait HasExtraInputAttributes
{
/**
* @var array<mixed> | Closure
* @var array<array<mixed> | Closure>
*/
protected array | Closure $extraInputAttributes = [];
protected array $extraInputAttributes = [];
/**
* @param array<mixed> | Closure $attributes
*/
public function extraInputAttributes(array | Closure $attributes): static
public function extraInputAttributes(array | Closure $attributes, bool $merge = false): static
{
$this->extraInputAttributes = $attributes;
if ($merge) {
$this->extraInputAttributes[] = $attributes;
} else {
$this->extraInputAttributes = [$attributes];
}
return $this;
}
@@ -27,7 +31,13 @@ trait HasExtraInputAttributes
*/
public function getExtraInputAttributes(): array
{
return $this->evaluate($this->extraInputAttributes);
$temporaryAttributeBag = new ComponentAttributeBag();
foreach ($this->extraInputAttributes as $extraInputAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraInputAttributes));
}
return $temporaryAttributeBag->getAttributes();
}
public function getExtraInputAttributeBag(): ComponentAttributeBag
@@ -28,9 +28,9 @@ class DateTimePicker extends Field
protected string | Closure | null $displayFormat = null;
/**
* @var array<mixed> | Closure
* @var array<array<mixed> | Closure>
*/
protected array | Closure $extraTriggerAttributes = [];
protected array $extraTriggerAttributes = [];
protected int | null $firstDayOfWeek = null;
@@ -148,9 +148,13 @@ class DateTimePicker extends Field
/**
* @param array<mixed> | Closure $attributes
*/
public function extraTriggerAttributes(array | Closure $attributes): static
public function extraTriggerAttributes(array | Closure $attributes, bool $merge = false): static
{
$this->extraTriggerAttributes = $attributes;
if ($merge) {
$this->extraAttributes[] = $attributes;
} else {
$this->extraAttributes = [$attributes];
}
return $this;
}
@@ -347,7 +351,13 @@ class DateTimePicker extends Field
*/
public function getExtraTriggerAttributes(): array
{
return $this->evaluate($this->extraTriggerAttributes);
$temporaryAttributeBag = new ComponentAttributeBag();
foreach ($this->extraTriggerAttributes as $extraTriggerAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraTriggerAttributes));
}
return $temporaryAttributeBag->getAttributes();
}
public function getExtraTriggerAttributeBag(): ComponentAttributeBag
@@ -8,16 +8,20 @@ use Illuminate\View\ComponentAttributeBag;
trait HasExtraAlpineAttributes
{
/**
* @var array<mixed> | Closure
* @var array<array<mixed> | Closure>
*/
protected array | Closure $extraAlpineAttributes = [];
protected array $extraAlpineAttributes = [];
/**
* @param array<mixed> | Closure $attributes
*/
public function extraAlpineAttributes(array | Closure $attributes): static
public function extraAlpineAttributes(array | Closure $attributes, bool $merge = false): static
{
$this->extraAlpineAttributes = $attributes;
if ($merge) {
$this->extraAlpineAttributes[] = $attributes;
} else {
$this->extraAlpineAttributes = [$attributes];
}
return $this;
}
@@ -27,7 +31,13 @@ trait HasExtraAlpineAttributes
*/
public function getExtraAlpineAttributes(): array
{
return $this->evaluate($this->extraAlpineAttributes);
$temporaryAttributeBag = new ComponentAttributeBag();
foreach ($this->extraAlpineAttributes as $extraAlpineAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAlpineAttributes));
}
return $temporaryAttributeBag->getAttributes();
}
public function getExtraAlpineAttributeBag(): ComponentAttributeBag
@@ -8,16 +8,20 @@ use Illuminate\View\ComponentAttributeBag;
trait HasExtraAttributes
{
/**
* @var array<mixed> | Closure
* @var array<array<mixed> | Closure>
*/
protected array | Closure $extraAttributes = [];
protected array $extraAttributes = [];
/**
* @param array<mixed> | Closure $attributes
*/
public function extraAttributes(array | Closure $attributes): static
public function extraAttributes(array | Closure $attributes, bool $merge = false): static
{
$this->extraAttributes = $attributes;
if ($merge) {
$this->extraAttributes[] = $attributes;
} else {
$this->extraAttributes = [$attributes];
}
return $this;
}
@@ -27,7 +31,13 @@ trait HasExtraAttributes
*/
public function getExtraAttributes(): array
{
return $this->evaluate($this->extraAttributes);
$temporaryAttributeBag = new ComponentAttributeBag();
foreach ($this->extraAttributes as $extraAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraAttributes));
}
return $temporaryAttributeBag->getAttributes();
}
public function getExtraAttributeBag(): ComponentAttributeBag
@@ -8,16 +8,20 @@ use Illuminate\View\ComponentAttributeBag;
trait HasExtraHeaderAttributes
{
/**
* @var array<mixed> | Closure
* @var array<mixed>
*/
protected array | Closure $extraHeaderAttributes = [];
protected array $extraHeaderAttributes = [];
/**
* @param array<mixed> | Closure $attributes
* @param array<array<mixed> | Closure> $attributes
*/
public function extraHeaderAttributes(array | Closure $attributes): static
public function extraHeaderAttributes(array | Closure $attributes, bool $merge = false): static
{
$this->extraHeaderAttributes = $attributes;
if ($merge) {
$this->extraHeaderAttributes[] = $attributes;
} else {
$this->extraHeaderAttributes = [$attributes];
}
return $this;
}
@@ -27,7 +31,18 @@ trait HasExtraHeaderAttributes
*/
public function getExtraHeaderAttributes(): array
{
return $this->evaluate($this->extraHeaderAttributes);
$temporaryAttributeBag = new ComponentAttributeBag();
foreach ($this->extraHeaderAttributes as $extraHeaderAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraHeaderAttributes));
}
return $temporaryAttributeBag->getAttributes();
}
public function getExtraHeaderAttributeBag(): ComponentAttributeBag
{
return new ComponentAttributeBag($this->getExtraHeaderAttributes());
}
public function getExtraHeaderAttributeBag(): ComponentAttributeBag
+15 -5
View File
@@ -29,9 +29,9 @@ class ImageColumn extends Column
protected int | string | Closure | null $width = null;
/**
* @var array<mixed> | Closure
* @var array<array<mixed> | Closure>
*/
protected array | Closure $extraImgAttributes = [];
protected array $extraImgAttributes = [];
protected function setUp(): void
{
@@ -197,9 +197,13 @@ class ImageColumn extends Column
/**
* @param array<mixed> | Closure $attributes
*/
public function extraImgAttributes(array | Closure $attributes): static
public function extraImgAttributes(array | Closure $attributes, bool $merge = false): static
{
$this->extraImgAttributes = $attributes;
if ($merge) {
$this->extraImgAttributes[] = $attributes;
} else {
$this->extraImgAttributes = [$attributes];
}
return $this;
}
@@ -209,7 +213,13 @@ class ImageColumn extends Column
*/
public function getExtraImgAttributes(): array
{
return $this->evaluate($this->extraImgAttributes);
$temporaryAttributeBag = new ComponentAttributeBag();
foreach ($this->extraImgAttributes as $extraImgAttributes) {
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraImgAttributes));
}
return $temporaryAttributeBag->getAttributes();
}
public function getExtraImgAttributeBag(): ComponentAttributeBag