Skip to content

update alpinejs to v3 #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,099 changes: 214 additions & 9,885 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"production": "mix --production"
},
"devDependencies": {
"axios": "^0.21.1",
"axios": "^0.21.4",
"highlight.js": "^10.5.0",
"laravel-mix": "^6.0.23",
"vue-template-compiler": "^2.6.12"
Expand All @@ -20,7 +20,7 @@
"@tailwindcss/forms": "^0.2.1",
"@tailwindcss/typography": "^0.4.0",
"algoliasearch": "^4.8.4",
"alpinejs": "^2.0",
"alpinejs": "^3.0",
"autoprefixer": "^10.2.4",
"choices.js": "^9.0.1",
"postcss": "^8.2.10",
Expand Down
6 changes: 5 additions & 1 deletion resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'alpinejs';
import Alpine from 'alpinejs';
import hljs from 'highlight.js';
import Choices from 'choices.js';

Expand All @@ -8,6 +8,10 @@ require('./bootstrap');
require('./search');
require('./editor');

window.Alpine = Alpine;

Alpine.start();

// Create a multiselect element.
window.choices = (element) => {
return new Choices(element, { maxItemCount: 3, removeItemButton: true });
Expand Down
2 changes: 1 addition & 1 deletion resources/views/_partials/_search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>

<input
@click.away="results = false"
@click.outside="results = false"
@keyup="search(event).then(function({ results: hits }) { results = true; threads = hits[0].hits; articles = hits[1].hits; })"
type="search"
name="search"
Expand Down
4 changes: 2 additions & 2 deletions resources/views/articles/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class="form-control"
@formGroup('tags')
<label for="tags">Tags</label>

<select name="tags[]" id="create-article" multiple x-data="{}" x-init="function () { choices($el) }">
<select name="tags[]" id="create-article" multiple x-data="{}" x-init="$nextTick(function () { choices($el) })">
@foreach($tags as $tag)
<option value="{{ $tag->id }}" @if(in_array($tag->id, $selectedTags)) selected @endif>{{ $tag->name }}</option>
@endforeach
Expand Down Expand Up @@ -76,7 +76,7 @@ class="button button-primary"
Save changes
</button>
@else
<span class="relative z-0 inline-flex shadow-sm" x-data="{ showDropdown: false }" @click.away="showDropdown = false">
<span class="relative z-0 inline-flex shadow-sm" x-data="{ showDropdown: false }" @click.outside="showDropdown = false">
<button
type="submit"
name="submitted"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/articles/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

<div
x-data="{}"
x-init="function () { highlightCode($el); }"
x-init="$nextTick(function () { highlightCode($el); })"
class="prose prose-lg text-gray-800 prose-lio"
>
<x-buk-markdown>{!! $article->body() !!}</x-buk-markdown>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/articles/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div class="space-y-1">
<x-forms.label for="tags">Tags</x-forms.label>

<select name="tags[]" id="create-article" multiple x-data="{}" x-init="function () { choices($el) }">
<select name="tags[]" id="create-article" multiple x-data="{}" x-init="$nextTick(function () { choices($el) })">
@foreach($tags as $tag)
<option value="{{ $tag->id }}" @if(in_array($tag->id, $selectedTags)) selected @endif>{{ $tag->name }}</option>
@endforeach
Expand Down Expand Up @@ -87,7 +87,7 @@ class="button button-primary"
Save changes
</button>
@else
<span class="relative z-0 inline-flex shadow-sm" x-data="{ showDropdown: false }" @click.away="showDropdown = false">
<span class="relative z-0 inline-flex shadow-sm" x-data="{ showDropdown: false }" @click.outside="showDropdown = false">
<button
type="submit"
name="submitted"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/threads/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="space-y-1">
<x-forms.label for="tags">Tags</x-forms.label>

<select name="tags[]" id="create-thread" multiple x-data="{}" x-init="function () { choices($el) }">
<select name="tags[]" id="create-thread" multiple x-data="{}" x-init="$nextTick(function () { choices($el) })">
@foreach($tags as $tag)
<option value="{{ $tag->id }}" @if(in_array($tag->id, $selectedTags)) selected @endif>{{ $tag->name }}</option>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/threads/reply-menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class="flex items-center gap-x-2 font-medium text-gray-300 hover:text-lio-500"
@endcan

@can(App\Policies\ReplyPolicy::UPDATE, $reply)
<div class="relative -mr-3" x-data="{ open: false }" @click.away="open = false">
<div class="relative -mr-3" x-data="{ open: false }" @click.outside="open = false">

<button
class="p-2 rounded hover:bg-gray-100"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/threads/reply.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div
class="prose prose-lio max-w-none p-6 break-words"
x-data="{}"
x-init="function () { highlightCode($el); }"
x-init="$nextTick(function () { highlightCode($el); })"
x-html="{{ json_encode(replace_links(md_to_html($reply->body()))) }}"
>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/threads/thread-menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@canany([App\Policies\ThreadPolicy::UPDATE, App\Policies\ThreadPolicy::DELETE], $thread)
<div class="flex items-center gap-x-3">
<div class="relative -mr-3" x-data="{ open: false }" @click.away="open = false">
<div class="relative -mr-3" x-data="{ open: false }" @click.outside="open = false">

<button
class="p-2 rounded hover:bg-gray-100"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/threads/thread.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div
class="prose prose-lio max-w-none p-6 break-words"
x-data="{}"
x-init="function () { highlightCode($el); }"
x-init="$nextTick(function () { highlightCode($el); })"
x-html="{{ json_encode(replace_links(md_to_html($thread->body()))) }}"
>
</div>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/layouts/_alerts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class="text-xl"
data-dismiss="alert"
aria-hidden="true"
@click="$el.remove()"
@click="$root.remove()"
>
&times;
</button>
Expand All @@ -24,7 +24,7 @@ class="text-xl"
class="text-xl"
data-dismiss="alert"
aria-hidden="true"
@click="$el.remove()"
@click="$root.remove()"
>
&times;
</button>
Expand Down
10 changes: 5 additions & 5 deletions resources/views/layouts/_nav.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<nav class="{{ isset($hasShadow) ? 'shadow mb-1' : '' }}">
<div class="container mx-auto text-gray-800 lg:block lg:py-8" x-data="{ nav: false, search: false, community: false, chat: false, settings: false }" @click.away="nav = false">
<div class="container mx-auto text-gray-800 lg:block lg:py-8" x-data="{ nav: false, search: false, community: false, chat: false, settings: false }" @click.outside="nav = false">
<div class="block bg-white 2xl:-mx-10">
<div class="lg:px-4 lg:flex">
<div class="block lg:flex lg:items-center lg:flex-shrink-0">
Expand Down Expand Up @@ -44,7 +44,7 @@
</li>

<li class="rounded lg:mb-0 lg:hover:bg-gray-100">
<div @click.away="chat = false" class="relative">
<div @click.outside="chat = false" class="relative">
<div>
<button @click="chat = !chat" class="flex items-center lg:mb-0 py-1 px-2">
Chat
Expand All @@ -71,7 +71,7 @@
</li>

<li class="rounded lg:mb-0 lg:hover:bg-gray-100">
<div @click.away="community = false" class="relative" x-data="{ community: false }">
<div @click.outside="community = false" class="relative" x-data="{ community: false }">
<button @click="community = !community" class="flex items-center lg:mb-0 py-1 px-2">
Community
<x-heroicon-s-chevron-down x-show="!community" class="w-4 h-4 ml-1"/>
Expand Down Expand Up @@ -120,7 +120,7 @@
</div>

<div class="w-full block gap-x-4 lg:flex lg:items-center lg:justify-end">
<div class="lg:block" x-cloak :class="{ 'block': search, 'hidden': !search }" @click.away="search = false">
<div class="lg:block" x-cloak :class="{ 'block': search, 'hidden': !search }" @click.outside="search = false">
@include('_partials._search')
</div>

Expand Down Expand Up @@ -159,7 +159,7 @@

<x-avatar :user="Auth::user()" class="h-8 w-8" />

<div @click.away="settings = false">
<div @click.outside="settings = false">
<button @click="settings = !settings" class="flex items-center">
{{ Auth::user()->username() }}
<x-heroicon-s-chevron-down x-show="!settings" class="w-4 h-4 ml-1"/>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/editor.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</span>
@endif

<div x-data="editorConfig($wire.entangle('body').defer)" @editor-control-clicked.window="handleClick($event.detail, $el)" class="bg-white rounded-md shadow-md">
<div x-data="editorConfig($wire.entangle('body').defer)" @editor-control-clicked.window="handleClick($event.detail, $root)" class="bg-white rounded-md shadow-md">

<ul class="flex p-5 gap-x-4">
<li>
Expand Down