update packages

This commit is contained in:
Meghdad committed 2026-11-25 21:50:39 +03:30
1 parent 8d5446f466
commit 8cfce7b922
51 files changed
+1983 -1681

No files matched your search

@@ -1 +1 @@
function a({state:r}){return{state:r,rows:[],init(){this.updateRows(),this.rows.length<=0?this.rows.push({key:"",value:""}):this.updateState(),this.$watch("state",(e,t)=>{if(!Array.isArray(e))return;let s=i=>i===null?0:Array.isArray(i)?i.length:typeof i!="object"?0:Object.keys(i).length;s(e)===0&&s(t)===0||this.updateRows()})},addRow(){this.rows.push({key:"",value:""}),this.updateState()},deleteRow(e){this.rows.splice(e,1),this.rows.length<=0&&this.addRow(),this.updateState()},reorderRows(e){let t=Alpine.raw(this.rows);this.rows=[];let s=t.splice(e.oldIndex,1)[0];t.splice(e.newIndex,0,s),this.$nextTick(()=>{this.rows=t,this.updateState()})},updateRows(){let t=Alpine.raw(this.state).map(({key:s,value:i})=>({key:s,value:i}));this.rows.forEach(s=>{(s.key===""||s.key===null)&&t.push({key:"",value:s.value})}),this.rows=t},updateState(){let e=[];this.rows.forEach(t=>{t.key===""||t.key===null||e.push({key:t.key,value:t.value})}),JSON.stringify(this.state)!==JSON.stringify(e)&&(this.state=e)}}}export{a as default};
function h({state:o,reordering:r={}}){return{state:o,rows:[],nextRowId:0,init(){this.updateRows(),this.rows.length<=0?this.addRow():this.updateState(),this.$watch("state",(t,i)=>{if(!Array.isArray(t)||JSON.stringify(t)===JSON.stringify(this.getState()))return;let e=s=>s===null?0:Array.isArray(s)?s.length:typeof s!="object"?0:Object.keys(s).length;e(t)===0&&e(i)===0||this.updateRows()}),this.$dispatch("async-component-ready")},addRow(){this.rows.push({id:this.nextRowId++,key:"",value:""}),this.updateState()},deleteRow(t){this.rows.splice(t,1),this.rows.length<=0&&this.addRow(),this.updateState()},reorderRows(t){t.oldDraggableIndex!==t.newDraggableIndex&&this.moveRow(this.rows[t.oldDraggableIndex].id,t.newDraggableIndex)},moveRow(t,i,e=document.activeElement){let s=this.rows.findIndex(a=>a.id===t);if(s<0||i<0||i>=this.rows.length||s===i)return;let[n]=this.rows.splice(s,1);this.rows.splice(i,0,n),this.updateState(),r.moved&&(this.$refs.reorderStatus.textContent="",this.$nextTick(()=>{!this.$root.isConnected||!this.rows.includes(n)||(this.$refs.reorderStatus.textContent=this.rowDescription(n,this.rows.indexOf(n),r.moved),[document.body,e].includes(document.activeElement)&&e.isConnected&&this.$root.contains(e)&&!e.disabled&&!e.hasAttribute("data-reorder-hidden")&&e.focus({preventScroll:!0}))}))},rowDescription(t,i,e=r.position){return e.replace(/:label|:position|:count/g,s=>({":label":String(t.key??"").trim()||r.row,":position":String(i+1),":count":String(this.rows.length)})[s])},updateRows(){let i=Alpine.raw(this.state).map(({key:e,value:s})=>({id:this.nextRowId++,key:e,value:s}));this.rows.forEach(e=>{(e.key===""||e.key===null)&&i.push(e)}),this.rows=i},getState(){return this.rows.filter(t=>t.key!==""&&t.key!==null).map(({key:t,value:i})=>({key:t,value:i}))},updateState(){let t=this.getState();JSON.stringify(this.state)!==JSON.stringify(t)&&(this.state=t)}}}export{h as default};