Skip to content

Commit

Permalink
Fix dynamic component bug preventing checkboxes/radios from using wir…
Browse files Browse the repository at this point in the history
…e:model.live - fixes #601
  • Loading branch information
calebporzio committed Nov 7, 2024
1 parent 5895892 commit 87d1b2b
Show file tree
Hide file tree
Showing 321 changed files with 339 additions and 955 deletions.
2 changes: 0 additions & 2 deletions src/Console/IconCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ protected function generateIconBlade($svg) {
$stub = <<<'HTML'
{{-- Credit: Lucide (https://lucide.dev) --}}
@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp
@props([
'variant' => 'outline',
])
Expand Down
9 changes: 8 additions & 1 deletion src/FluxServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function register(): void
public function boot(): void
{
$this->bootComponentPath();

$this->bootTagCompiler();
$this->bootMacros();

AssetManager::boot();

Expand Down Expand Up @@ -55,6 +55,13 @@ public function bootTagCompiler()
});
}

public function bootMacros()
{
app('view')::macro('getCurrentComponentData', function () {
return $this->currentComponentData;
});
}

public function bootCommands()
{
if (! $this->app->runningInConsole()) {
Expand Down
13 changes: 13 additions & 0 deletions src/FluxTagCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ class FluxTagCompiler extends ComponentTagCompiler
{
public function componentString(string $component, array $attributes)
{
// A component that forwards all data, attributes, and named slots to another component...
if ($component === 'flux::delegate-component') {
$component = $attributes['component'];

$class = \Illuminate\View\AnonymousComponent::class;

return "##BEGIN-COMPONENT-CLASS##@component('{$class}', 'flux::' . {$component}, [
'view' => md5('flux') . '::' . {$component},
'data' => \$__env->getCurrentComponentData(),
])
<?php \$component->withAttributes(\$attributes->all()); ?>";
}

return parent::componentString($component, $attributes);
}

Expand Down
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/academic-cap.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -47,4 +45,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -46,4 +44,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/archive-box-x-mark.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -47,4 +45,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/archive-box.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -47,4 +45,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-down-circle.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-down-left.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -46,4 +44,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-down-right.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-down-tray.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -46,4 +44,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-down.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-left-circle.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -46,4 +44,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -45,4 +43,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-left.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-long-down.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-long-left.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-long-right.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-long-up.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
4 changes: 1 addition & 3 deletions stubs/resources/views/flux/icon/arrow-path.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{{-- Credit: Heroicons (https://heroicons.com) --}}

@php $attributes = $unescapedForwardedAttributes ?? $attributes; @endphp

@props([
'variant' => 'outline',
])
Expand Down Expand Up @@ -44,4 +42,4 @@

<?php break; ?>

<?php endswitch; ?>
<?php endswitch; ?>
Loading

0 comments on commit 87d1b2b

Please sign in to comment.