Add wire:navigate support by default in menu items #2

This commit is contained in:
samy
2025-08-16 08:37:55 -10:00
parent da3c6ab144
commit b79d529b0c
4 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
@source inline("loading-bars loading-infinity loading-circle loading-spinner loading-ring loading-ball"); #loading-overlay{display: none; position: fixed; top:0; left:0; width: 100%; height: 100%; min-height: 100vh; background: rgba(45,45,65,.6); z-index: 100;}#loading-overlay div{margin:auto}
@source inline("loading-bars loading-infinity loading-circle loading-spinner loading-ring loading-ball");#loading-overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;min-height:100vh;background:#2d2d4199;z-index:100}#loading-overlay div{margin:auto}
+1 -1
View File
@@ -1 +1 @@
document.addEventListener("alpine:init",()=>{Alpine.directive("confirm-modal",(c,a,{evaluate:l})=>{c.addEventListener("click",m=>{m.preventDefault();const o=document.getElementById("global-confirm-modal"),e=c.dataset;console.log("Dataset:",e),document.getElementById("confirm-title").innerHTML=e.title||"Confirm Action",document.getElementById("confirm-message").innerHTML=e.message||"Are you sure you want to proceed?",document.getElementById("confirm-cancel").innerHTML=e.cancelLabel||"Cancel",document.getElementById("confirm-confirm").innerHTML=e.confirmLabel||"Confirm",document.getElementById("confirm-confirm").addEventListener("click",()=>{var d;if(e.url)window.location.href=e.url;else if(e.action){const t=document.createElement("form");t.method="POST",t.action=e.action;const i=(d=document.querySelector('meta[name="csrf-token"]'))==null?void 0:d.content;if(i){const n=document.createElement("input");n.type="hidden",n.name="_token",n.value=i,t.appendChild(n)}if(e.method&&e.method.toUpperCase()!=="POST"){const n=document.createElement("input");n.type="hidden",n.name="_method",n.value=e.method,t.appendChild(n)}document.body.appendChild(t),t.submit()}else console.error("No URL or action specified for confirmation."),o.close()}),document.getElementById("confirm-cancel").addEventListener("click",()=>{o.close()}),o.showModal()})})});
document.addEventListener("alpine:init",()=>{Alpine.directive("confirm-modal",(t,c,{evaluate:a})=>{t.addEventListener("click",m=>{m.preventDefault();const d=document.getElementById("global-confirm-modal"),e=t.dataset;console.log("Dataset:",e),document.getElementById("confirm-title").innerHTML=e.title||"Confirm Action",document.getElementById("confirm-message").innerHTML=e.message||"Are you sure you want to proceed?",document.getElementById("confirm-cancel").innerHTML=e.cancelLabel||"Cancel",document.getElementById("confirm-confirm").innerHTML=e.confirmLabel||"Confirm",document.getElementById("confirm-confirm").addEventListener("click",()=>{var i;if(e.url)window.location.href=e.url;else if(e.action){const o=document.createElement("form");o.method="POST",o.action=e.action;const r=(i=document.querySelector('meta[name="csrf-token"]'))==null?void 0:i.content;if(r){const n=document.createElement("input");n.type="hidden",n.name="_token",n.value=r,o.appendChild(n)}if(e.method&&e.method.toUpperCase()!=="POST"){const n=document.createElement("input");n.type="hidden",n.name="_method",n.value=e.method,o.appendChild(n)}document.body.appendChild(o),o.submit()}else console.error("No URL or action specified for confirmation."),d.close()}),document.getElementById("confirm-cancel").addEventListener("click",()=>{d.close()}),d.showModal()})})});(function(){const t=()=>{document.querySelectorAll(".dropdown.dropdown-open").forEach(c=>c.classList.remove("dropdown-open")),document.querySelectorAll("details[open]").forEach(c=>c.removeAttribute("open")),document.activeElement&&document.activeElement.blur&&document.activeElement.blur()};window.addEventListener("livewire:navigated",t),window.addEventListener("livewire:navigating",t),window.addEventListener("popstate",t),window.addEventListener("pageshow",t)})();
+2 -1
View File
@@ -1 +1,2 @@
import './__modals'
import './__modals'
import './__close-dropdowns-on-navigate'
@@ -1,6 +1,13 @@
@props([
'label' => '',
'link' => null,
'useNavigate' => true
])
<li><a class="whitespace-nowrap" @if($link) href="{{ $link }}" @endif>{{ $label }}</a></li>
<li>
<a
class="whitespace-nowrap"
@if($link) href="{{ $link }}" @endif
@if($useNavigate) wire:navigate @endif
>{{ $label }}</a>
</li>