-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/forms/src/Components/Concerns/HasExtraFieldWrapperAttributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Filament\Forms\Components\Concerns; | ||
|
||
use Closure; | ||
use Illuminate\View\ComponentAttributeBag; | ||
|
||
trait HasExtraFieldWrapperAttributes | ||
{ | ||
/** | ||
* @var array<array<mixed> | Closure> | ||
*/ | ||
protected array $extraFieldWrapperAttributes = []; | ||
|
||
/** | ||
* @param array<mixed> | Closure $attributes | ||
*/ | ||
public function extraFieldWrapperAttributes(array | Closure $attributes, bool $merge = false): static | ||
{ | ||
if ($merge) { | ||
$this->extraFieldWrapperAttributes[] = $attributes; | ||
} else { | ||
$this->extraFieldWrapperAttributes = [$attributes]; | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array<mixed> | ||
*/ | ||
public function getExtraFieldWrapperAttributes(): array | ||
{ | ||
$temporaryAttributeBag = new ComponentAttributeBag(); | ||
|
||
foreach ($this->extraFieldWrapperAttributes as $extraFieldWrapperAttributes) { | ||
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraFieldWrapperAttributes)); | ||
} | ||
|
||
return $temporaryAttributeBag->getAttributes(); | ||
} | ||
|
||
public function getExtraFieldWrapperAttributesBag(): ComponentAttributeBag | ||
{ | ||
return new ComponentAttributeBag($this->getExtraFieldWrapperAttributes()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/infolists/src/Components/Concerns/HasExtraEntryWrapperAttributes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Filament\Infolists\Components\Concerns; | ||
|
||
use Closure; | ||
use Illuminate\View\ComponentAttributeBag; | ||
|
||
trait HasExtraEntryWrapperAttributes | ||
{ | ||
/** | ||
* @var array<array<mixed> | Closure> | ||
*/ | ||
protected array $extraEntryWrapperAttributes = []; | ||
|
||
/** | ||
* @param array<mixed> | Closure $attributes | ||
*/ | ||
public function extraEntryWrapperAttributes(array | Closure $attributes, bool $merge = false): static | ||
{ | ||
if ($merge) { | ||
$this->extraEntryWrapperAttributes[] = $attributes; | ||
} else { | ||
$this->extraEntryWrapperAttributes = [$attributes]; | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array<mixed> | ||
*/ | ||
public function getExtraEntryWrapperAttributes(): array | ||
{ | ||
$temporaryAttributeBag = new ComponentAttributeBag(); | ||
|
||
foreach ($this->extraEntryWrapperAttributes as $extraEntryWrapperAttributes) { | ||
$temporaryAttributeBag = $temporaryAttributeBag->merge($this->evaluate($extraEntryWrapperAttributes)); | ||
} | ||
|
||
return $temporaryAttributeBag->getAttributes(); | ||
} | ||
|
||
public function getExtraEntryWrapperAttributesBag(): ComponentAttributeBag | ||
{ | ||
return new ComponentAttributeBag($this->getExtraEntryWrapperAttributes()); | ||
} | ||
} |