Skip to content

Commit

Permalink
Merge branch 'async-alpine' into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Dec 19, 2024
2 parents d11d59e + 216df0a commit 5279639
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 89 deletions.
7 changes: 0 additions & 7 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ corePackages.forEach((packageName) => {
})
})

compile({
...defaultOptions,
platform: 'browser',
entryPoints: [`./node_modules/async-alpine/dist/async-alpine.script.js`],
outfile: `./packages/support/dist/async-alpine.js`,
})

compile({
...defaultOptions,
platform: 'browser',
Expand Down
9 changes: 4 additions & 5 deletions docs/07-advanced/02-assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,12 @@ FilamentAsset::register([

When you run `php artisan filament:assets`, the compiled file will be copied into the `/public` directory.

Finally, you can load this asynchronous Alpine component in your view using `ax-load` attributes and the `FilamentAsset::getAlpineComponentSrc()` method:
Finally, you can load this asynchronous Alpine component in your view using `x-load` attributes and the `FilamentAsset::getAlpineComponentSrc()` method:

```blade
<div
x-ignore
ax-load
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('test-component') }}"
x-load
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('test-component') }}"
x-data="testComponent({
state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$statePath}')") }},
})"
Expand All @@ -351,7 +350,7 @@ Finally, you can load this asynchronous Alpine component in your view using `ax-

This example is for a [custom form field](../forms/fields/custom). It passes the `state` in as a parameter to the `testComponent()` function, which is entangled with a Livewire component property. You can pass in any parameters you want, and access them in the `testComponent()` function. If you're not using a custom form field, you can ignore the `state` parameter in this example.

The `ax-load` attributes come from the [Async Alpine](https://async-alpine.dev/docs/strategies) package, and any features of that package can be used here.
The `x-load` attributes come from the [Async Alpine](https://async-alpine.dev/docs/strategies) package, and any features of that package can be used here.

### Registering script data

Expand Down
7 changes: 3 additions & 4 deletions docs/08-plugins/02-build-a-panel-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class ClockWidget extends Widget

Next, we'll need to create the view for our widget. Create a new file at `resources/views/widget.blade.php` and add the following code. We'll make use of Filament's blade components to save time on writing the html for the widget.

We are using async Alpine to load our Alpine component, so we'll need to add the `x-ignore` attribute to the div that will load our component. We'll also need to add the `ax-load` attribute to the div to tell Alpine to load our component. You can learn more about this in the [Core Concepts](../advanced/assets#asynchronous-alpinejs-components) section of the docs.
We are using async Alpine to load our Alpine component, so we'll need to add the `x-load` attribute to the div to tell Alpine to load our component. You can learn more about this in the [Core Concepts](../advanced/assets#asynchronous-alpinejs-components) section of the docs.

```blade
<x-filament-widgets::widget>
Expand All @@ -154,9 +154,8 @@ We are using async Alpine to load our Alpine component, so we'll need to add the
</x-slot>
<div
x-ignore
ax-load
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('clock-widget', 'awcodes/clock-widget') }}"
x-load
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('clock-widget', 'awcodes/clock-widget') }}"
x-data="clockWidget()"
class="text-center"
>
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@tailwindcss/typography": "^0.5.9",
"alpine-lazy-load-assets": "^1.3.0",
"alpinejs": "^3.10.4",
"async-alpine": "v1.2.1",
"async-alpine": "^2.0.0",
"autoprefixer": "^10.4.0",
"chart.js": "^4.4.7",
"chartjs-adapter-luxon": "^1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@
"
>
<div
x-ignore
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('color-picker', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('color-picker', 'filament/forms') }}"
x-data="colorPickerFormComponent({
isAutofocused: @js($isAutofocused()),
isDisabled: @js($isDisabled),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@
/>
@else
<div
x-ignore
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('date-time-picker', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('date-time-picker', 'filament/forms') }}"
x-data="dateTimePickerFormComponent({
displayFormat:
'{{ convert_date_format($getDisplayFormat())->to('day.js') }}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
>
<div
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('file-upload', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('file-upload', 'filament/forms') }}"
x-data="fileUploadFormComponent({
acceptedFileTypes: @js($getAcceptedFileTypes()),
imageEditorEmptyFillColor: @js($getImageEditorEmptyFillColor()),
Expand Down Expand Up @@ -116,7 +116,6 @@
},
})"
wire:ignore
x-ignore
{{
$attributes
->merge([
Expand Down
7 changes: 3 additions & 4 deletions packages/forms/resources/views/components/key-value.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@
>
<div
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('key-value', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('key-value', 'filament/forms') }}"
wire:ignore
x-data="keyValueFormComponent({
state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$statePath}')") }},
})"
x-ignore
{{
$attributes
->merge($getExtraAlpineAttributes(), escape: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class="fi-fo-markdown-editor fi-disabled prose block w-full max-w-none rounded-l
"
>
<div
{{-- prettier-ignore-start --}}ax-load="visible || event (ax-modal-opened)"
{{-- prettier-ignore-start --}}x-load="visible || event (x-modal-opened)"
{{-- prettier-ignore-end --}}
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('markdown-editor', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('markdown-editor', 'filament/forms') }}"
x-data="markdownEditorFormComponent({
canAttachFiles: @js($hasToolbarButton('attachFiles')),
isLiveDebounced: @js($isLiveDebounced()),
Expand Down Expand Up @@ -52,7 +52,6 @@ class="fi-fo-markdown-editor fi-disabled prose block w-full max-w-none rounded-l
})
},
})"
x-ignore
wire:ignore
{{ $getExtraAlpineAttributeBag() }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ class="fi-fo-rich-editor fi-disabled prose block w-full max-w-none rounded-lg bg
>
<div
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('rich-editor', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('rich-editor', 'filament/forms') }}"
x-data="richEditorFormComponent({
state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$statePath}')", isOptimisticallyLive: false) }},
})"
x-ignore
x-on:trix-attachment-add="
if (! $event.attachment.file) return
Expand Down
7 changes: 3 additions & 4 deletions packages/forms/resources/views/components/select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@ class="hidden"
}"
></div>
<div
x-ignore
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('select', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('select', 'filament/forms') }}"
x-data="selectFormComponent({
canSelectPlaceholder: @js($canSelectPlaceholder),
isHtmlAllowed: @js($isHtmlAllowed()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@
>
<div
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('tags-input', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('tags-input', 'filament/forms') }}"
x-data="tagsInputFormComponent({
state: $wire.{{ $applyStateBindingModifiers("\$entangle('{$statePath}')") }},
splitKeys: @js($getSplitKeys()),
})"
x-ignore
{{ $getExtraAlpineAttributeBag() }}
>
<x-filament::input
Expand Down
7 changes: 3 additions & 4 deletions packages/forms/resources/views/components/textarea.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@
>
<div wire:ignore.self style="height: '{{ $initialHeight . 'rem' }}'">
<textarea
x-ignore
@if (FilamentView::hasSpaMode())
{{-- format-ignore-start --}}ax-load="visible || event (ax-modal-opened)"{{-- format-ignore-end --}}
{{-- format-ignore-start --}}x-load="visible || event (x-modal-opened)"{{-- format-ignore-end --}}
@else
ax-load
x-load
@endif
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('textarea', 'filament/forms') }}"
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('textarea', 'filament/forms') }}"
x-data="textareaFormComponent({
initialHeight: @js($initialHeight),
shouldAutosize: @js($shouldAutosize),
Expand Down
2 changes: 1 addition & 1 deletion packages/support/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"illuminate/support": "^10.45|^11.0",
"illuminate/view": "^10.45|^11.0",
"kirschbaum-development/eloquent-power-joins": "^3.0|^4.0",
"livewire/livewire": "3.5.12",
"livewire/livewire": "^3.5",
"nette/php-generator": "^4.0",
"ryangjchandler/blade-capture-directive": "^0.2|^0.3|^1.0",
"spatie/color": "^1.5",
Expand Down
1 change: 0 additions & 1 deletion packages/support/dist/async-alpine.js

This file was deleted.

12 changes: 6 additions & 6 deletions packages/support/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/support/resources/js/components/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default ({ id }) => ({
this.$nextTick(() => {
this.isOpen = true

this.$dispatch('ax-modal-opened')
this.$dispatch('x-modal-opened')
})
},
})
Loading

0 comments on commit 5279639

Please sign in to comment.