2026-10-19 17:33:22 +03:00
|
|
|
function $({statePath:s,isCollapsed:l,collapseKey:u}){return{isCollapsed:u?Alpine.$persist(l).as(u):l,collapseFromEvent(m){m.detail===s&&(this.isCollapsed=!0)},expandFromEvent(m){m.detail===s&&(this.isCollapsed=!1)},expand(){this.isCollapsed=!1},toggleCollapsed(){this.isCollapsed=!this.isCollapsed},get itemClasses(){return{"fi-collapsed":this.isCollapsed}}}}function y({schemaComponent:s,moveUpAction:l,moveDownAction:u,reorderAction:m,message:S,hasCustomReorderAction:x}){let A=e=>JSON.stringify({name:e?.name,arguments:e?.arguments,context:e?.context});return{pending:null,frame:null,destroyed:!1,listeners:[],removeCommitHook:null,init(){let e=(t,o,a,p=!0)=>{t.addEventListener(o,a,p),this.listeners.push(()=>t.removeEventListener(o,a,p))};e(document,"pointerdown",t=>{this.pending?.control?.contains(t.target)||this.relinquishFocus()}),e(document,"keydown",t=>{t.key==="Tab"&&this.relinquishFocus()}),e(document,"focusin",t=>{this.pending&&t.target!==this.pending.control&&this.relinquishFocus()}),e(this.$root,"click",t=>{let o=t.target.closest("[data-reorder-direction]");if(!(!o||!this.owns(o))){if(this.pending){t.preventDefault(),t.stopImmediatePropagation();return}!o.dataset.reorderAction?.startsWith("mountAction(")||o.getAttribute("wire:click")!==o.dataset.reorderAction||o.getAttributeNames().some(a=>a==="wire:confirm"||a.startsWith("wire:confirm."))||o.disabled||this.begin(o.closest("[x-sortable-item]").getAttribute("x-sortable-item"),o.dataset.reorderDirection,o)}}),e(this.$root,"start",t=>{t.target===this.$refs.reorderItems&&this.begin(t.item.getAttribute("x-sortable-item"),"drag")}),e(this.$root,"end",t=>{if(t.target===this.$refs.reorderItems){if(t.oldDraggableIndex===t.newDraggableIndex){this.finish(),t.stopImmediatePropagation();return}this.setSortingDisabled(!0)}}),this.removeCommitHook=Livewire.hook("commit",({component:t,commit:o,succeed:a,fail:p})=>{let r=this.pending;if(t.id!==this.$wire.$id)return;let n=[];for(let i=this.$root;i&&!(i.hasAttribute("wire:id")&&i.getAttribute("wire:id")!==t.id);i=i.parentElement){let h=i.getAttribute("wire:partial");if(h&&n.push(h),i===t.el)break}let g=i=>i.html||n.some(h=>i.partials?.[h]);if(a(({effects:i})=>{this.pending===r&&(r&&(!r.synchronizing||!g(i))||this.schedule(()=>{this.destroyed||!this.$root.isConnected||(this.updateHandles(),r?.synchronizing&&this.isCurrent(r)&&this.finish())}))}),!r||r.synchronizing)return;let c=t.canonical.mountedActions??[],d=i=>i?.context?.schemaComponent===s&&i.name===r.action&&(r.direction==="drag"||String(i.arguments?.item)===r.item),v=c.some(d)&&!d(c.at(-1));if(!o.calls.some(i=>i.method==="mountAction"?d({name:i.params[0],arguments:i.params[1],context:i.params[2]}):["callMountedAction","unmountAction"].includes(i.method)&&c.some(d)))return;let C=o.calls.some(i=>i.method==="unmountAction");a(({effects:i})=>{if(!this.isCurrent(r))return;let h=t.canonical.mountedActions??[],k=h.some(d);for(let[f,w]of r.reopenedModals??[])A(h[f])!==w&&r.reopenedModals.delete(f);if(k){r.focus=!1,r.modal=!0,this.setSortingDisabled(!0);let f=h.length-1;h.length<c.length&&r.reopenedModals?.has(f)&&this.schedule(()=>{if(!this.isCurrent(r))return;let w=t.canonical.mountedActions??[];w.length===f+1&&A(w[f])===r.reopenedModals.get(f)&&this.$dispatch("open-modal",{id:`fi-${t.id}-action-${f}`})});return}if(!g(i)||v){this.resynchronize(r);return}this.schedule(()=>this.reconcile(r))}),p(()=>{this.isCurrent(r)&&(r.focus=!1,r.modal&&C&&(r.reopenedModals??(r.reopenedModals=new Map),r.reopenedModals.set(c.length-1,A(c.at(-1))),this.$dispatch("open-modal",{id:`fi-${t.id}-action-${c.length-1}`})),!r.modal&&(r.direction==="drag"?this.resynchronize(r):this.finish()))})}),this.updateHandles()},owns(e){return e.closest("[data-reorder-owner]")===this.$root},order(){return JSON.parse(this.$root.dataset.reorderItems)},reorder(e){e.target===this.$refs.reorderItems&&this.$wire.mountAction(m,{items:e.target.sortable.toArray()},{schemaComponent:s})},begin(e,t,o=null){this.pending={item:e,direction:t,control:o,focus:!o?.hasAttribute("data-reorder-hidden")&&document.activeElement===o,before:this
|