@greenborn/vue-table-editor 1.4.7 → 1.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/dist/vue-table-editor.js +835 -821
- package/dist/vue-table-editor.js.map +1 -1
- package/dist/vue-table-editor.umd.cjs +4 -4
- package/dist/vue-table-editor.umd.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k.VueTableEditor={},k.Vue))})(this,function(k,e){"use strict";class j{constructor(i={}){this.key=i.key||"",this.icon=i.icon,this.severity=i.severity||"primary",this.class=i.class||"",this.label=i.label||"",this._getLabel=i.getLabel||(()=>i.label||""),this._isVisible=i.isVisible||(()=>!0),this._isDisabled=i.isDisabled||(()=>!1),this.onClick=i.onClick||(()=>{}),this.helpKey=i.helpKey||null,this.permissions=i.permissions||null}getLabel(){return this._getLabel()}isVisible(){return this._isVisible()}isDisabled(){return this._isDisabled()}}function Oe(s){return s instanceof j?s:new j(s)}const tl="te_preferencias";function kt(s=tl){let i={};function u(){try{const m=localStorage.getItem(s);i=m?JSON.parse(m):{}}catch{i={}}}function r(){try{localStorage.setItem(s,JSON.stringify(i))}catch{}}return u(),{get misValores(){return i},valor(m){const y=i[m];if(!y)return null;try{return JSON.parse(y)}catch{return y}},async guardarValores(m){return i={...i,...m},r(),{status:!0}},async fetchMisPreferencias(){u()}}}const be={adapter:null};function ll(s){be.adapter=s}function gt(){return be.adapter||(be.adapter=kt()),be.adapter}const yt={search:'<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>',plus:'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',pencil:'<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/>',trash:'<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',columns:'<rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/>',eye:'<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>',refresh:'<polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>',"sort-asc":'<path d="M12 19V5"/><polyline points="5 12 12 5 19 12"/>',"sort-desc":'<path d="M12 5v14"/><polyline points="19 12 12 19 5 12"/>',sort:'<path d="M7 8h10"/><path d="M7 12h6"/><path d="M7 16h3"/>',grip:'<circle cx="9" cy="6" r="1"/><circle cx="15" cy="6" r="1"/><circle cx="9" cy="12" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="9" cy="18" r="1"/><circle cx="15" cy="18" r="1"/>',play:'<polygon points="6 3 20 12 6 21 6 3"/>',stop:'<rect x="6" y="6" width="12" height="12" rx="1"/>',files:'<polyline points="16 16 16 16"/><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/>',gear:'<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h0a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h0a1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82v0a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>'};function N(s){if(!s)return"";const i=nl(s),u=yt[i];return u?`<svg class="te-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${u}</svg>`:""}function nl(s){let i=String(s).trim().toLowerCase();return i=i.replace(/^bi\s+bi-/,""),i=i.replace(/^te-/,""),{"arrow-clockwise":"refresh","arrow-counterclockwise":"refresh","layout-three-columns":"columns","plus-lg":"plus","plus-circle":"plus","gear-fill":"gear",files:"files","play-fill":"play","stop-fill":"stop"}[i]||i}const ol=Object.keys(yt);function bt(s){return!s||s.length!==7?null:"#"+(255-parseInt(s.slice(1,3),16)).toString(16).padStart(2,"0")+(255-parseInt(s.slice(3,5),16)).toString(16).padStart(2,"0")+(255-parseInt(s.slice(5,7),16)).toString(16).padStart(2,"0")}function _t(s,i){if(!Array.isArray(s))return s;const u=i==null?void 0:i.fieldClasses;if(!u)return s;for(const r of s)u[r.field]&&(r.css=(r.css||"")+" "+u[r.field]);return s}function He(s,i){if(!i)return s;if(s.__css_class="",typeof i.rowClassFn=="function"&&(s.__css_class=i.rowClassFn(s)),typeof i.rowStyleFn=="function"&&(s.__style=i.rowStyleFn(s)),s.__field_styles={},i.fieldStyleFns)for(const u of Object.keys(i.fieldStyleFns))s[u]!=null&&(s.__field_styles[u]=i.fieldStyleFns[u](s[u]));return s}function $e(s,i){var r;if(s==null)return{value:null,style:null};const u=s[i==null?void 0:i.field];return u!=null&&typeof u=="object"&&"__style"in u?{value:u.value,style:u.__style}:(r=s.__field_styles)!=null&&r[i==null?void 0:i.field]?{value:u,style:s.__field_styles[i==null?void 0:i.field]}:{value:u,style:null}}function Bt(s,i){return $e(s,i).style}const al={class:"te-wrapper"},il={key:0,class:"te-toolbar"},rl={class:"te-toolbar-start"},sl=["disabled","onClick","title"],cl=["innerHTML"],dl={key:0,class:"te-toolbar-divider"},fl=["disabled","onClick","title"],ul=["innerHTML"],pl={key:0,class:"te-toolbar-end"},ml=["innerHTML"],hl={key:0,class:"te-dropdown-menu",style:{"min-width":"220px"}},kl=["id","value"],gl={class:"te-search"},yl=["innerHTML"],bl={key:0,class:"te-loading-overlay"},_l={key:1,class:"te-mobile-list"},Bl=["onClick","onDblclick"],Cl={class:"te-mobile-card-head"},El=["checked","onChange"],Vl=["checked","onClick"],Nl=["innerHTML"],Sl={key:0,class:"te-mobile-card-body"},wl=["innerHTML"],Ml=["disabled","onClick","title"],Dl=["innerHTML"],Tl={key:0,class:"te-mobile-empty"},Ll=["data-field"],vl={key:0,class:"te-header-group-row"},Fl={key:0,class:"te-th te-th-sel",rowspan:2},xl=["checked"],zl={key:1,class:"te-th te-th-acts",rowspan:2},Al=["colspan"],Pl={class:"te-th-content"},Rl={class:"te-th-group-label"},Ol=["data-field"],Hl={class:"te-th-content"},$l=["onClick"],Il={key:0,class:"te-sort-icon-std"},jl=["innerHTML"],Wl=["onPointerdown","onDblclick"],Gl={key:1,class:"te-header-row te-has-groups"},Jl=["data-field"],ql={class:"te-th-content"},Ul=["onClick"],Kl={key:0,class:"te-sort-icon-std"},Xl=["innerHTML"],Yl=["onPointerdown","onDblclick"],Ql={key:2,class:"te-header-row"},Zl={key:0,class:"te-th te-th-sel"},en=["checked"],tn={key:1,class:"te-th te-th-acts"},ln=["data-field","draggable","onDragstart","onDragenter","onDragover","onDragleave","onDrop"],nn={class:"te-th-content"},on=["innerHTML"],an=["onClick"],rn={key:0,class:"te-sort-icon-std"},sn=["innerHTML"],cn=["onPointerdown","onDblclick"],dn={key:0,class:"te-drop-indicator te-drop-left"},fn={key:1,class:"te-drop-indicator te-drop-right"},un={key:3,class:"te-filter-row"},pn={key:0,class:"te-td"},mn={key:1,class:"te-td"},hn=["onUpdate:modelValue"],kn=["value"],gn=["onUpdate:modelValue"],yn=["onPointerdown","onDblclick"],bn=["onClick","onDblclick"],_n=["checked","onChange"],Bn=["checked","onClick"],Cn={key:1,class:"te-td te-td-acts"},En={class:"te-actions-wrap"},Vn=["disabled","onClick","title"],Nn=["innerHTML"],Sn=["onBlur","onKeydown"],wn={key:1,class:"te-cell-wrap"},Mn=["onDblclick","innerHTML"],Dn=["onClick"],Tn=["innerHTML"],Ln=["onPointerdown","onDblclick"],vn={key:0},Fn=["colspan"],xn={key:0,class:"te-loading-spinner"},zn={class:"te-paginator"},An={class:"te-page-info"},Pn={class:"te-page-controls"},Rn=["disabled"],On=["disabled"],Hn={class:"te-page-current"},$n=["disabled"],In=["disabled"],jn=["value"],Wn="te_cfg",Ct={__name:"TableEditor",props:{api:{type:Object,default:null},permisos:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})},data:{type:[Array,Object],default:null},id:{type:String,default:null}},emits:["loaded","rowSelected","rowDoubleClick","createRequest","editRequest","deleteRequest"],setup(s,{expose:i,emit:u}){const r=s,m=u,y=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.preferencesStore)||gt()});function le(){return r.id?`${Wn}_${r.id}`:null}let Y=null;async function Un(){const t=le();if(!t)return null;try{const l=y.value.valor(t);return l?typeof l=="string"?JSON.parse(l):l:null}catch{return null}}async function We(){const t=le();if(!t)return;const l=qe.value.map(d=>d.field),o=new Set(C.value.map(d=>d.field)),a={};for(const d of l)a[d]=ce.value[d]||"15rem";const c=W.value.length?W.value:l,n=l.filter(d=>!o.has(d));await y.value.guardarValores({[t]:JSON.stringify({columnOrder:c,columnWidths:a,hiddenFields:n})})}function Ge(){Y&&clearTimeout(Y),Y=setTimeout(()=>{Y=null,We()},500)}function Je(){return q?(clearTimeout(q),q=null,We()):Y?(clearTimeout(Y),Y=null,We()):null}const B=e.ref([]),wt=e.ref([]),C=e.ref([]),qe=e.ref([]),Mt=e.ref(null),Dt=e.ref(!1),P=e.ref(!0),g=e.ref("single"),b=e.ref(null),V=e.ref(new Map),L=e.ref(null),Q=e.ref("asc"),R=e.ref({}),_e=e.ref(""),_=e.ref(1),M=e.ref(25),Tt=e.ref([25,50,100,200]),Be=e.ref(null),Lt=e.ref(!0),vt=e.ref(!1),Kn=e.ref(!0);e.ref(!0);const Ft=e.ref(!0),Xn=e.ref("3rem"),xt=e.ref("10rem"),ce=e.ref({}),W=e.ref([]),de=e.ref(!1),fe=e.ref(0),D=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.lazy)===!0}),O=e.computed(()=>{var t,l;return((t=r.config)==null?void 0:t.infiniteScroll)===!0||((l=r.config)==null?void 0:l.infiniteScroll)!==!1&&D.value}),Ce=e.ref(!1),G=e.ref(!0),Z=e.ref(1),Ue=e.ref(null),Ke=e.ref(null),Xe=e.ref(null),Ee=e.ref(!1);let J=null;const S=e.ref(null),H=e.ref(null),v=e.ref(null),F=e.ref(null);let Ve=null,Ne=null;const x=e.ref(null),ee=e.ref(""),Se=e.ref(null),ne=e.ref(null);let z=null,E=null,ue=null,pe=null,q=null;const me=e.ref({create:"Nuevo",edit:"Editar",delete:"Borrar",article:"un",deleted:"eliminado"}),w=e.computed(()=>{const t=C.value;if(W.value.length){const l=[];for(const o of W.value){const a=t.find(c=>c.field===o);a&&l.push(a)}for(const o of t)l.some(a=>a.field===o.field)||l.push(o);return l}return t}),T=e.computed(()=>lt.value.rowActions||[]),A=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.rowActionsMode)==="toolbar"}),Yn=e.computed(()=>{var t;return A.value&&((t=r.config)==null?void 0:t.cardActions)===!0}),Ye=e.computed(()=>A.value?T.value:[]),we=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.lazyProtocol)==="legacy"}),Qn=e.computed(()=>{var t;return!!((t=r.config)!=null&&t.columnFilterDefs)}),te=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.dataPipeline)||null}),Me=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.styling)||null}),Zn=e.computed(()=>{var t;return typeof((t=r.config)==null?void 0:t.permissionsCheck)=="function"}),eo=e.computed(()=>{let t=w.value.length+1;return g.value!==null&&t++,T.value.length&&!A.value&&t++,t}),De=e.computed(()=>{var t,l;return((l=(t=r.config)==null?void 0:t.columnGroups)==null?void 0:l.length)>0}),Qe=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.mobileListView)===!0}),zt=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.mobileBreakpoint)??768}),Te=e.ref(!1),At=e.computed(()=>w.value[0]||null),Pt=e.computed(()=>w.value.slice(1)),to=e.computed(()=>Qe.value&&Te.value);let U=null;function Ze(t){Te.value=t.matches}function Rt(){U&&U.removeEventListener("change",Ze),U=null,Te.value=!1,!(!Qe.value||typeof window>"u"||!window.matchMedia)&&(U=window.matchMedia(`(max-width: ${zt.value}px)`),Te.value=U.matches,U.addEventListener("change",Ze))}const Ot=e.computed(()=>{var t;return(t=r.config)==null?void 0:t.inlineEditing}),lo=e.computed(()=>{var t;return((t=Ot.value)==null?void 0:t.campos)||{}}),Ht=e.computed(()=>{if(!De.value)return[];const t=r.config.columnGroups||[],l=w.value,o={};for(let n=0;n<t.length;n++)for(const d of t[n].fields)o[d]=n;const a=[];let c=0;for(;c<l.length;){const n=l[c],d=o[n.field];if(d!==void 0){const f=[];for(;c<l.length&&o[l[c].field]===d;)f.push(l[c]),c++;a.push({_key:"g-"+d,_type:"group",headerName:t[d].headerName,_span:f.length,_cols:f})}else a.push({_key:"c-"+n.field,_type:"col",_col:n}),c++}return a}),Le=e.computed(()=>{let t=B.value||[];const l=_e.value;if(l){const o=l.toLowerCase();t=t.filter(a=>w.value.some(c=>{const n=a[c.field];return n!=null&&String(n).toLowerCase().includes(o)}))}for(const o of w.value){const a=R.value[o.field];if(a){const c=a.toLowerCase();t=t.filter(n=>{const d=n[o.field];return d!=null&&String(d).toLowerCase().includes(c)})}}return L.value&&(t=[...t].sort((o,a)=>{let c=o[L.value],n=a[L.value];return c==null&&(c=""),n==null&&(n=""),typeof c=="number"&&typeof n=="number"?Q.value==="asc"?c-n:n-c:(c=String(c).toLowerCase(),n=String(n).toLowerCase(),Q.value==="asc"?c.localeCompare(n):n.localeCompare(c))})),t}),et=e.computed(()=>D.value?fe.value:Le.value.length),he=e.computed(()=>Math.max(1,Math.ceil(et.value/M.value))),K=e.computed(()=>{if(O.value)return B.value||[];if(D.value)return B.value||[];const t=(_.value-1)*M.value;return Le.value.slice(t,t+M.value)}),no=e.computed(()=>(_.value-1)*M.value+1),oo=e.computed(()=>Math.min(_.value*M.value,et.value)),tt=e.computed(()=>K.value.length>0&&K.value.every(t=>ke(t))),lt=e.ref({toolbar:[new j({key:"refresh",icon:"refresh",severity:"outline-info",isVisible:()=>{var t;return!((t=r.config)!=null&&t.hideRefresh)},onClick:()=>Pe()}),new j({key:"csv",icon:"download",severity:"outline-info",label:"CSV",isVisible:()=>{var t;return!((t=r.config)!=null&&t.hideCsvExport)},onClick:()=>yo()}),new j({key:"create",icon:"plus",severity:"success",isVisible:()=>{var t,l;return((t=r.api)==null?void 0:t.create)!=null&&ve((l=r.permisos)==null?void 0:l.create)},getLabel:()=>me.value.create,onClick:()=>dt("create")}),new j({key:"edit",icon:"pencil",severity:"warning",isVisible:()=>{var t,l;return((t=r.api)==null?void 0:t.edit)!=null&&ve((l=r.permisos)==null?void 0:l.edit)},getLabel:()=>me.value.edit,isDisabled:()=>P.value,onClick:()=>dt("edit")}),new j({key:"delete",icon:"trash",severity:"danger",isVisible:()=>{var t,l;return((t=r.api)==null?void 0:t.delete)!=null&&ve((l=r.permisos)==null?void 0:l.delete)},getLabel:()=>me.value.delete,isDisabled:()=>P.value,onClick:()=>ko()})],rowActions:[]});function ve(t){return!t||!Zn.value?!0:!!r.config.permissionsCheck(t)}const $t=e.computed(()=>{var l,o;const t=[];for(const a of lt.value.toolbar)a.isVisible()&&t.push(a);if((o=(l=r.config)==null?void 0:l.buttons)!=null&&o.toolbar)for(const a of r.config.buttons.toolbar)t.push(Oe(a));return t});function It(){var t,l,o,a,c,n,d,f,p,$;((t=r.config)==null?void 0:t.selectionMode)!=null&&(g.value=r.config.selectionMode),((o=(l=r.config)==null?void 0:l.elementName)==null?void 0:o.gender)==="F"&&(me.value={create:"Nueva",edit:"Editar",delete:"Borrar",article:"una",deleted:"eliminada"}),((a=r.config)==null?void 0:a.pageSize)!=null&&(M.value=r.config.pageSize),((c=r.config)==null?void 0:c.pageSizeOptions)!=null&&(Tt.value=r.config.pageSizeOptions),((n=r.config)==null?void 0:n.scrollHeight)!=null&&(Be.value=r.config.scrollHeight),((d=r.config)==null?void 0:d.showPaginator)!=null&&(Lt.value=r.config.showPaginator),((f=r.config)==null?void 0:f.showFilterRow)!=null&&(vt.value=r.config.showFilterRow),($=(p=r.config)==null?void 0:p.buttons)!=null&&$.rowActions&&(lt.value.rowActions=r.config.buttons.rowActions.map(Oe)),e.nextTick(()=>el())}function nt(t,l){var c,n,d,f;let{value:o}=$e(t,l);if(o==null||o==="")return"-";const a=(n=(c=r.config)==null?void 0:c.valueFormatters)==null?void 0:n[l==null?void 0:l.field];if((l==null?void 0:l.form_type)==="color"){const p="#"+(o||"000000"),$=bt(p)||"#ffffff";return`<span class="te-color-badge" style="background:${p};color:${$}">${o}</span>`}if((l==null?void 0:l.form_type)==="json")return JSON.stringify(o);if((l==null?void 0:l.type)==="date"||(d=l==null?void 0:l.field)!=null&&d.endsWith("_at")||(f=l==null?void 0:l.field)!=null&&f.endsWith("At"))try{return new Date(o).toLocaleDateString()}catch{return o}if((l==null?void 0:l.type)==="datetime")try{return new Date(o).toLocaleString()}catch{return o}return(l==null?void 0:l.type)==="boolean"||(l==null?void 0:l.type)==="bool"?o?"Sí":"No":typeof a=="function"?a(t):String(o)}function ke(t){return g.value==="single"?b.value===t:V.value.has(t)}function ot(t){b.value===t?(b.value=null,P.value=!0,m("rowSelected",null)):(b.value=t,P.value=!1,m("rowSelected",t))}function at(t){V.value.has(t)?V.value.delete(t):V.value.set(t,!0),P.value=V.value.size===0,m("rowSelected",[...V.value.keys()])}function jt(){if(tt.value)V.value=new Map,P.value=!0,m("rowSelected",[]);else{const t=new Map;for(const l of K.value)t.set(l,!0);V.value=t,P.value=!1,m("rowSelected",[...t.keys()])}}function Wt(t){F.value||S.value||(g.value==="multiple"?at(t):ot(t))}function Gt(t){var l,o,a;F.value||S.value||(m("rowDoubleClick",t),(l=r.config)!=null&&l.editOnDoubleClick&&((o=r.api)!=null&&o.edit)&&ve((a=r.permisos)==null?void 0:a.edit)&&(g.value==="single"&&(b.value=t),dt("edit")))}function it(t){return L.value!==t?"sort":Q.value==="asc"?"sort-asc":"sort-desc"}function rt(t){if(F.value||S.value)return;ae();const l=w.value.find(o=>o.field===t);(l==null?void 0:l.sortable)!==!1&&(L.value===t?Q.value=Q.value==="asc"?"desc":"asc":(L.value=t,Q.value="asc"),_.value=1,D.value&&(O.value&&(Z.value=1,G.value=!0,B.value=[]),re()))}function ao(){pe&&clearTimeout(pe),pe=setTimeout(()=>{_.value=1,D.value&&(O.value&&(Z.value=1,G.value=!0,B.value=[]),re())},300)}function Jt(){ue&&clearTimeout(ue),ue=setTimeout(()=>{_.value=1,D.value&&(O.value&&(Z.value=1,G.value=!0,B.value=[]),re())},400)}function io(){q&&clearTimeout(q),q=setTimeout(()=>Ge(),300)}function Fe(t){ae(),_.value=Math.max(1,Math.min(t,he.value)),D.value&&re()}function ro(){ae(),_.value=1,D.value&&re()}function oe(t,l){if(t.button!==0||S.value)return;t.preventDefault();const o=t.currentTarget.closest("th, td");if(!(!o||o.getBoundingClientRect().right-t.clientX>11)){try{o.setPointerCapture(t.pointerId)}catch{}F.value=l,Ve=t.clientX,Ne=o.offsetWidth,document.body.style.cursor="col-resize",document.body.classList.add("te-resizing"),document.addEventListener("pointermove",st),document.addEventListener("pointerup",ct)}}function st(t){if(!F.value||Ve==null||Ne==null)return;const l=Math.max(100,Ne+(t.clientX-Ve));ce.value={...ce.value,[F.value]:l+"px"}}function ct(){document.removeEventListener("pointermove",st),document.removeEventListener("pointerup",ct),document.body.style.cursor="",document.body.classList.remove("te-resizing"),F.value&&Ge(),Ve=null,Ne=null,F.value=null}function ge(t,l){oe(t,l)}function so(t,l){if(F.value){t.preventDefault();return}S.value=l,H.value=null,v.value=null,t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",l))}function co(t,l){S.value===l||t.relatedTarget&&t.currentTarget.contains(t.relatedTarget)||(H.value=l)}function fo(t,l){if(S.value===l)return;t.dataTransfer&&(t.dataTransfer.dropEffect="move");const o=t.currentTarget.getBoundingClientRect();v.value=t.clientX<o.left+o.width/2?"left":"right"}function uo(t,l){t.currentTarget.contains(t.relatedTarget)||H.value===l&&(H.value=null,v.value=null)}function po(t,l){if(!S.value||S.value===l){xe();return}const o=W.value.length?[...W.value]:C.value.map(f=>f.field),a=o.indexOf(S.value),c=o.indexOf(l);if(a<0||c<0){xe();return}const[n]=o.splice(a,1),d=a<c?v.value==="right"?c:c-1:v.value==="left"?c:c+1;o.splice(Math.max(0,Math.min(o.length,d)),0,n),W.value=o,Ge(),xe()}function xe(){S.value=null,H.value=null,v.value=null}function ze(t){return lo.value[t==null?void 0:t.field]||null}function mo(t,l){return x.value?x.value.row===t&&x.value.field===l.field:!1}function qt(t,l,o){var d,f;if(!ze(o))return;(d=t==null?void 0:t.stopPropagation)==null||d.call(t);const n=((f=l.__raw)==null?void 0:f[o.field])??l[o.field]??"";ne.value=n,x.value={row:l,field:o.field},ee.value=n,e.nextTick(()=>{const p=Array.isArray(Se.value)?Se.value[0]:Se.value;p&&typeof p.focus=="function"&&(p.focus(),p.select())})}function Ut(t,l){if(!x.value)return;const o=ze(l);if(!o){ye();return}let a=ee.value;if(o.type==="currency"){const c=String(a).replace(/[^0-9,\-]/g,"").replace(",",".");if(a=parseFloat(c),isNaN(a)){ye();return}}else if(o.type==="integer"){if(a=parseInt(a,10),isNaN(a)||o.min!==void 0&&a<o.min){ye();return}}else if(o.type==="number"&&(a=parseFloat(a),isNaN(a)||o.min!==void 0&&a<o.min)){ye();return}t[l.field]=o.format?o.format(a):a,t.__raw||(t.__raw={}),t.__raw[l.field]=a,o.afterEdit&&o.afterEdit(t,l.field,a),x.value=null,ee.value="",ho(t,l.field,a)}function ye(){if(x.value&&ne.value!==null){const{row:t,field:l}=x.value;t[l]=ne.value}x.value=null,ee.value="",ne.value=null}function ho(t,l,o){const a=Ot.value;if(!(a!=null&&a.api))return;const c=t.id;if(!c)return;z&&(clearTimeout(z),z=null),E&&(E.api(E.data),E=null);const n=ne.value??t[l];E={api:a.api,data:{id:c,field:l,value:o}},z=setTimeout(async()=>{const d=await a.api({id:c,field:l,value:o});E=null,ie(d)?(t[l]=n,console.error("[TableEditor] inline save failed:",d)):a.onSave&&a.onSave()},a.debounce_ms??1e3)}function ae(){x.value=null,ee.value="",ne.value=null,z&&(clearTimeout(z),z=null),E&&(E.api(E.data),E=null)}function Kt(t){var a,c,n,d,f;const l=((c=(a=r.config)==null?void 0:a.extraFields)==null?void 0:c[t==="create"?"create":t==="edit"?"edit":"list"])||[],o=t==="edit";return{action:t,title:`${me.value[t]} ${((d=(n=r.config)==null?void 0:n.elementName)==null?void 0:d.singular)||""}`.trim(),campos:[...wt.value,...l],modelo:o?b.value:{},onSubmit:(f=r.api)==null?void 0:f[t],guardado:()=>Pe(),selectedRows:g.value==="multiple"?[...V.value.keys()]:[b.value]}}function dt(t){var o,a,c;if(!((o=r.api)!=null&&o[t]))return;const l=(c=(a=r.config)==null?void 0:a.crud)==null?void 0:c.openModal;if(typeof l=="function"){l(Kt(t));return}m(t+"Request",Kt(t))}async function ko(){var a,c;const l=(g.value==="multiple"?[...V.value.keys()]:[b.value]).map(n=>n==null?void 0:n.id).filter(Boolean);if(!l.length){m("deleteRequest",{ids:[],action:"delete"});return}const o=(c=(a=r.config)==null?void 0:a.crud)==null?void 0:c.confirmDelete;typeof o=="function"?Promise.resolve(o(l)).then(n=>{n&&go(l)}).catch(n=>console.error("[TableEditor] confirmDelete error:",n)):m("deleteRequest",{ids:l,action:"delete"})}async function go(t){var l;if(!(!((l=r.api)!=null&&l.delete)||!t.length))try{const o=await r.api.delete({id:t[0]});if(ie(o)){console.error("[TableEditor] delete failed:",o);return}b.value=null,V.value=new Map,P.value=!0,Pe()}catch(o){console.error("[TableEditor] delete error:",o)}}function ie(t){return t!=null&&(t.status===!1||t.stat===!1)}async function yo(){var t,l,o;if(D.value&&((t=r.config)!=null&&t.csvFetchAll)&&((l=r.api)!=null&&l.list))try{const a=ft({page:1});a[we.value?"rows":"pageSize"]=Math.max(fe.value||0,M.value);const c=await r.api.list(a);if(ie(c)){console.error("[TableEditor] CSV fetch error:",c);return}Xt(((o=c==null?void 0:c.data)==null?void 0:o.rows)||[]);return}catch(a){console.error("[TableEditor] CSV fetch error:",a);return}Xt(B.value||[])}function Xt(t){if(!t.length)return;const l=w.value;let o=l.map(c=>Yt(c.headerName)).join(",")+`
|
|
2
|
-
`;for(const c of t)o+=l.map(
|
|
3
|
-
`;const a=document.createElement("a");a.href="data:text/csv;charset=utf-8,"+encodeURIComponent("\uFEFF"+o),a.download="datos.csv",a.click()}function
|
|
4
|
-
`)?'"'+t+'"':t}function Ae(t){let l=String(t||"primary");return l.startsWith("te-btn-")?l:(l.startsWith("btn-")&&(l=l.slice(4)),"te-btn-"+l)}function Qt(t){Xe.value&&!Xe.value.contains(t.target)&&(Ee.value=!1)}function Pe(){ae(),b.value=null,V.value=new Map,P.value=!0,O.value&&(Z.value=1,G.value=!0,B.value=[]),Re()}function ft(t={}){const o={page:t.page??(O.value?Z.value:_.value),[we.value?"rows":"pageSize"]:M.value,sortField:L.value||"",sortOrder:Q.value,[we.value?"globalSearch":"search"]:_e.value||""},a={};for(const c of Object.keys(R.value))R.value[c]&&(a[c]=we.value?{value:R.value[c],matchMode:"contains"}:R.value[c]);return Object.keys(a).length&&(o.filters=JSON.stringify(a)),o}async function re(){var t,l;ae(),de.value=!0;try{const o=await r.api.list(ft());ie(o)||(fe.value=((t=o==null?void 0:o.data)==null?void 0:t.totalRecords)||((l=o==null?void 0:o.data)==null?void 0:l.total)||0,ut(o==null?void 0:o.data))}catch(o){console.error("[TableEditor] load error:",o)}finally{de.value=!1}}async function Re(t){var o;const l=t||r.data;if(l!=null)return ut(l);if((o=r.api)!=null&&o.list){if(D.value)return re();de.value=!0;try{const a=await r.api.list();ie(a)||ut(a==null?void 0:a.data)}catch(a){console.error("[TableEditor] load error:",a)}finally{de.value=!1}}m("rowSelected",g.value==="single"?null:[]),b.value=null,V.value=new Map}function ut(t){var a,c,n,d,f,p;if(!t){Dt.value=!0,m("loaded",!0);return}let l=t.rows||[],o=t.fields_def;if(te.value?(te.value.processRows&&(l=te.value.processRows(l,o)||l),te.value.processFields&&(o=te.value.processFields(o,l[0])??o)):Me.value&&(l=l.map($=>He($,Me.value))),B.value=l,ae(),o){const $=JSON.stringify(o.map(h=>h==null?void 0:h.field));if($===Mt.value)return;Mt.value=$;let se=[...o];(c=(a=r.config)==null?void 0:a.extraFields)!=null&&c.list&&se.push(...r.config.extraFields.list),Me.value&&_t(se,Me.value);const pt=(n=r.config)==null?void 0:n.columnFilterDefs;if(pt)for(const h of se)pt[h.field]&&(h.filter={type:"text",...pt[h.field]});wt.value=se;let mt=se;if((d=te.value)!=null&&d.processColumns&&(mt=te.value.processColumns(se)),C.value=[...mt],qe.value=[...mt],(f=r.config)!=null&&f.defaultColumnProps)for(let h=0;h<C.value.length;h++)C.value[h]={...C.value[h],...r.config.defaultColumnProps};if((p=r.config)!=null&&p.columnOrder){const h=[];for(const X of r.config.columnOrder){const I=C.value.find(ht=>ht.field===X);I&&h.push(I)}for(const X of C.value)h.some(I=>I.field===X.field)||h.push(X);C.value=h}Un().then(h=>{if(h!=null&&h.columnWidths)for(const[X,I]of Object.entries(h.columnWidths))ce.value[X]=I;if(W.value=(h==null?void 0:h.columnOrder)||[],Array.isArray(h==null?void 0:h.hiddenFields)&&h.hiddenFields.length){const X=new Set(h.hiddenFields),I=C.value.filter(ht=>!X.has(ht.field));I.length&&(C.value=I)}})}Dt.value=!0,m("loaded",!0)}function bo(){if(!O.value)return;const t=Ke.value;!t||!Ue.value||(J==null||J.disconnect(),J=new IntersectionObserver(([l])=>{l.isIntersecting&&G.value&&!Ce.value&&_o()},{root:t,rootMargin:"0px 0px 200px 0px",threshold:0}),J.observe(Ue.value))}async function _o(){var t,l,o;if(Ce.value=!0,D.value){Z.value++;try{const a=await r.api.list(ft({page:Z.value}));if(!ie(a)){const c=((t=a==null?void 0:a.data)==null?void 0:t.rows)||[];c.length&&(B.value=[...B.value,...c]),fe.value=((l=a==null?void 0:a.data)==null?void 0:l.totalRecords)||((o=a==null?void 0:a.data)==null?void 0:o.total)||0}G.value=B.value.length<fe.value}catch(a){console.error("[TableEditor] load more error:",a),G.value=!1}}else{const a=Le.value.length,c=B.value.length,n=Math.min(c+M.value,a);n>c&&(B.value=[...Le.value.slice(0,n)]),G.value=B.value.length<a}Ce.value=!1}function Zt(t,l){var a;const o=(a=r.config)==null?void 0:a.trackBy;if(o){if(typeof o=="function"){const c=o(t,l);if(c!=null)return c}else if((t==null?void 0:t[o])!=null)return t[o]}return(t==null?void 0:t.id)??(t==null?void 0:t.__uid)??l}e.watch(()=>r.data,t=>{(t==null?void 0:t.rows)!==void 0&&Re(t)}),e.watch(K,()=>el()),e.watch([Qe,zt],()=>Rt());function el(){!T.value.length||A.value||e.nextTick(()=>{const t=Ke.value;if(!t)return;let l=0;t.querySelectorAll(".te-actions-wrap").forEach(o=>{l=Math.max(l,o.scrollWidth)}),l>0&&(xt.value=Math.max(56,l+24)+"px")})}return e.onMounted(async()=>{It(),Rt(),document.addEventListener("click",Qt),window.addEventListener("beforeunload",Je),y.value.fetchMisPreferencias&&await y.value.fetchMisPreferencias(),await Re(),e.nextTick(()=>bo())}),e.onUnmounted(()=>{document.removeEventListener("click",Qt),U&&U.removeEventListener("change",Ze),document.removeEventListener("pointermove",st),document.removeEventListener("pointerup",ct),window.removeEventListener("beforeunload",Je),Je(),J==null||J.disconnect(),z&&(clearTimeout(z),z=null),E&&(E.api(E.data),E=null),ue&&clearTimeout(ue),pe&&clearTimeout(pe),q&&clearTimeout(q)}),i({loadData:Re,applyConfig:It,refresh:Pe}),(t,l)=>{var o,a,c;return e.openBlock(),e.createElementBlock("div",al,[!((o=s.config)!=null&&o.hideToolbar)||Ye.value.length?(e.openBlock(),e.createElementBlock("div",il,[e.createElementVNode("div",rl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($t.value,n=>(e.openBlock(),e.createElementBlock("button",{key:n.key,class:e.normalizeClass(["te-btn",Ae(n.severity),n.class]),disabled:n.isDisabled(),onClick:n.onClick,title:n.getLabel()},[n.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(N)(n.icon)},null,8,cl)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(n.getLabel()),1)],10,sl))),128)),Ye.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[$t.value.length?(e.openBlock(),e.createElementBlock("span",dl,"|")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ye.value,n=>(e.openBlock(),e.createElementBlock("button",{key:"ra-"+n.key,class:e.normalizeClass(["te-btn",Ae(n.severity),n.class]),disabled:n.isDisabled()||!b.value,onClick:d=>n.onClick(b.value),title:n.getLabel()},[n.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(N)(n.icon)},null,8,ul)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(n.getLabel()),1)],10,fl))),128))],64)):e.createCommentVNode("",!0)]),(a=s.config)!=null&&a.hideToolbarEnd?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",pl,[(c=s.config)!=null&&c.hideColumnSelector?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"te-dropdown",ref_key:"colsDropdownRef",ref:Xe},[e.createElementVNode("button",{class:"te-btn te-btn-outline-secondary",type:"button",title:"Columnas",onClick:l[0]||(l[0]=n=>Ee.value=!Ee.value)},[e.createElementVNode("span",{class:"te-btn-icon",innerHTML:e.unref(N)("columns")},null,8,ml),l[17]||(l[17]=e.createTextVNode("Columnas ",-1))]),Ee.value?(e.openBlock(),e.createElementBlock("div",hl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(qe.value,n=>(e.openBlock(),e.createElementBlock("label",{key:n.field,class:"te-dropdown-item"},[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"te-cols-"+n.field,value:n,"onUpdate:modelValue":l[1]||(l[1]=d=>C.value=d),class:"te-checkbox",onChange:io},null,40,kl),[[e.vModelCheckbox,C.value]]),e.createTextVNode(" "+e.toDisplayString(n.headerName),1)]))),128))])):e.createCommentVNode("",!0)],512)),e.createElementVNode("div",gl,[e.createElementVNode("span",{class:"te-search-icon",innerHTML:e.unref(N)("search")},null,8,yl),e.withDirectives(e.createElementVNode("input",{type:"text",class:"te-search-input","onUpdate:modelValue":l[2]||(l[2]=n=>_e.value=n),onInput:ao,placeholder:"Buscar..."},null,544),[[e.vModelText,_e.value]])])]))])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"te-scroll-wrap",style:e.normalizeStyle(Be.value?{height:Be.value,minHeight:Be.value}:{}),ref_key:"scrollWrapRef",ref:Ke},[de.value?(e.openBlock(),e.createElementBlock("div",bl,[...l[18]||(l[18]=[e.createElementVNode("div",{class:"te-loading-spinner",role:"status"},[e.createElementVNode("span",{class:"te-sr-only"},"Cargando...")],-1)])])):e.createCommentVNode("",!0),to.value?(e.openBlock(),e.createElementBlock("div",_l,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.value,(n,d)=>(e.openBlock(),e.createElementBlock("div",{key:Zt(n,d),class:e.normalizeClass(["te-mobile-card",n.__css_class,{"te-tr-selected":ke(n),"te-tr-highlight":b.value===n}]),style:e.normalizeStyle(n.__style),onClick:f=>Wt(n),onDblclick:f=>Gt(n)},[e.createElementVNode("div",Cl,[g.value!==null?(e.openBlock(),e.createElementBlock("div",{key:0,class:"te-mobile-card-sel",onClick:l[3]||(l[3]=e.withModifiers(()=>{},["stop"]))},[g.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:ke(n),onChange:f=>at(n),class:"te-checkbox"},null,40,El)):(e.openBlock(),e.createElementBlock("input",{key:1,type:"radio",checked:b.value===n,onClick:f=>ot(n),class:"te-checkbox"},null,8,Vl))])):e.createCommentVNode("",!0),At.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"te-mobile-card-title",innerHTML:nt(n,At.value)},null,8,Nl)):e.createCommentVNode("",!0)]),Pt.value.length?(e.openBlock(),e.createElementBlock("dl",Sl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Pt.value,f=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:f.field},[e.createElementVNode("dt",null,e.toDisplayString(f.headerName),1),e.createElementVNode("dd",{innerHTML:nt(n,f)},null,8,wl)],64))),128))])):e.createCommentVNode("",!0),T.value.length&&(!A.value||Yn.value)?(e.openBlock(),e.createElementBlock("div",{key:1,class:"te-mobile-card-actions",onClick:l[4]||(l[4]=e.withModifiers(()=>{},["stop"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,f=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:f.key},[f.isVisible()?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["te-btn",Ae(f.severity),f.class]),disabled:f.isDisabled(),onClick:e.withModifiers(p=>f.onClick(n),["stop"]),title:f.getLabel()},[f.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(N)(f.icon)},null,8,Dl)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(f.getLabel()),1)],10,Ml)):e.createCommentVNode("",!0)],64))),128))])):e.createCommentVNode("",!0)],46,Bl))),128)),K.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Tl,"Sin registros"))])):(e.openBlock(),e.createElementBlock("table",{key:2,class:e.normalizeClass(["te-table",{"te-striped":Kn.value}])},[e.createElementVNode("colgroup",null,[g.value!==null?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:Xn.value})},null,4)):e.createCommentVNode("",!0),T.value.length&&!A.value?(e.openBlock(),e.createElementBlock("col",{key:1,style:e.normalizeStyle({width:xt.value})},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,n=>(e.openBlock(),e.createElementBlock("col",{key:n.field,style:e.normalizeStyle({width:ce.value[n.field]||"15rem"}),"data-field":n.field},null,12,Ll))),128)),l[19]||(l[19]=e.createElementVNode("col",{class:"te-col-filler"},null,-1))]),e.createElementVNode("thead",null,[De.value?(e.openBlock(),e.createElementBlock("tr",vl,[g.value!==null?(e.openBlock(),e.createElementBlock("th",Fl,[g.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:tt.value,onChange:jt,class:"te-checkbox"},null,40,xl)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),T.value.length&&!A.value?(e.openBlock(),e.createElementBlock("th",zl,"Acciones")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ht.value,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n._key},[n._type==="group"?(e.openBlock(),e.createElementBlock("th",{key:0,colspan:n._span,class:"te-th te-th-group"},[e.createElementVNode("div",Pl,[e.createElementVNode("span",Rl,e.toDisplayString(n.headerName),1)])],8,Al)):(e.openBlock(),e.createElementBlock("th",{key:1,rowspan:2,"data-field":n._col.field,class:e.normalizeClass(["te-th",n._col.css,{"te-th-sorted":L.value===n._col.field}])},[e.createElementVNode("div",Hl,[e.createElementVNode("span",{class:"te-th-label",onClick:d=>rt(n._col.field)},[e.createTextVNode(e.toDisplayString(n._col.headerName)+" ",1),n._col.sortable!==!1?(e.openBlock(),e.createElementBlock("span",Il,[e.createElementVNode("span",{innerHTML:e.unref(N)(it(n._col.field))},null,8,jl)])):e.createCommentVNode("",!0)],8,$l)]),e.createElementVNode("div",{class:"te-resize-handle",onPointerdown:e.withModifiers(d=>oe(d,n._col.field),["stop"]),onDblclick:e.withModifiers(d=>ge(d,n._col.field),["stop"]),onClick:l[5]||(l[5]=e.withModifiers(()=>{},["stop"]))},null,40,Wl)],10,Ol))],64))),128)),l[20]||(l[20]=e.createElementVNode("th",{class:"te-th te-th-filler",rowspan:2},null,-1))])):e.createCommentVNode("",!0),De.value?(e.openBlock(),e.createElementBlock("tr",Gl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ht.value,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:"r2-"+n._key},[n._type==="group"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(n._cols,d=>(e.openBlock(),e.createElementBlock("th",{key:d.field,"data-field":d.field,class:e.normalizeClass(["te-th",d.css,{"te-th-sorted":L.value===d.field}])},[e.createElementVNode("div",ql,[e.createElementVNode("span",{class:"te-th-label",onClick:f=>rt(d.field)},[e.createTextVNode(e.toDisplayString(d.headerName)+" ",1),d.sortable!==!1?(e.openBlock(),e.createElementBlock("span",Kl,[e.createElementVNode("span",{innerHTML:e.unref(N)(it(d.field))},null,8,Xl)])):e.createCommentVNode("",!0)],8,Ul)]),e.createElementVNode("div",{class:"te-resize-handle",onPointerdown:e.withModifiers(f=>oe(f,d.field),["stop"]),onDblclick:e.withModifiers(f=>ge(f,d.field),["stop"]),onClick:l[6]||(l[6]=e.withModifiers(()=>{},["stop"]))},null,40,Yl)],10,Jl))),128)):e.createCommentVNode("",!0)],64))),128))])):e.createCommentVNode("",!0),De.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("tr",Ql,[g.value!==null?(e.openBlock(),e.createElementBlock("th",Zl,[g.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:tt.value,onChange:jt,class:"te-checkbox"},null,40,en)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),T.value.length&&!A.value?(e.openBlock(),e.createElementBlock("th",tn,"Acciones")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,n=>(e.openBlock(),e.createElementBlock("th",{key:n.field,"data-field":n.field,class:e.normalizeClass(["te-th",n.css,{"te-th-dragover-left":H.value===n.field&&v.value==="left","te-th-dragover-right":H.value===n.field&&v.value==="right","te-th-dragging":S.value===n.field,"te-th-sorted":L.value===n.field}]),draggable:Ft.value,onDragstart:d=>so(d,n.field),onDragenter:e.withModifiers(d=>co(d,n.field),["prevent"]),onDragover:e.withModifiers(d=>fo(d,n.field),["prevent"]),onDragleave:d=>uo(d,n.field),onDrop:e.withModifiers(d=>po(d,n.field),["prevent"]),onDragend:xe},[e.createElementVNode("div",nn,[Ft.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-th-grip",innerHTML:e.unref(N)("grip")},null,8,on)):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"te-th-label",onClick:d=>rt(n.field)},[e.createTextVNode(e.toDisplayString(n.headerName)+" ",1),n.sortable!==!1?(e.openBlock(),e.createElementBlock("span",rn,[e.createElementVNode("span",{innerHTML:e.unref(N)(it(n.field))},null,8,sn)])):e.createCommentVNode("",!0)],8,an)]),e.createElementVNode("div",{class:e.normalizeClass(["te-resize-handle",{"te-resizing-active":F.value===n.field}]),draggable:"false",onPointerdown:e.withModifiers(d=>oe(d,n.field),["stop"]),onDblclick:e.withModifiers(d=>ge(d,n.field),["stop"]),onClick:l[7]||(l[7]=e.withModifiers(()=>{},["stop"]))},null,42,cn),H.value===n.field&&v.value==="left"?(e.openBlock(),e.createElementBlock("div",dn)):e.createCommentVNode("",!0),H.value===n.field&&v.value==="right"?(e.openBlock(),e.createElementBlock("div",fn)):e.createCommentVNode("",!0)],42,ln))),128)),l[21]||(l[21]=e.createElementVNode("th",{class:"te-th te-th-filler"},null,-1))])),vt.value?(e.openBlock(),e.createElementBlock("tr",un,[g.value!==null?(e.openBlock(),e.createElementBlock("td",pn)):e.createCommentVNode("",!0),T.value.length&&!A.value?(e.openBlock(),e.createElementBlock("td",mn)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,n=>{var d,f;return e.openBlock(),e.createElementBlock("td",{key:"f-"+n.field,class:"te-td"},[((d=n.filter)==null?void 0:d.type)==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":p=>R.value[n.field]=p,onChange:Jt,class:"te-filter-input te-filter-select"},[l[22]||(l[22]=e.createElementVNode("option",{value:""},"Todos",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.filter.options,p=>(e.openBlock(),e.createElementBlock("option",{key:p.value,value:p.value},e.toDisplayString(p.label),9,kn))),128))],40,hn)),[[e.vModelSelect,R.value[n.field]]]):((f=n.filter)==null?void 0:f.type)==="text"||!Qn.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":p=>R.value[n.field]=p,onInput:Jt,type:"text",class:"te-filter-input",placeholder:""},null,40,gn)),[[e.vModelText,R.value[n.field]]]):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"te-resize-handle",draggable:"false",onPointerdown:e.withModifiers(p=>oe(p,n.field),["stop"]),onDblclick:e.withModifiers(p=>ge(p,n.field),["stop"]),onClick:l[8]||(l[8]=e.withModifiers(()=>{},["stop"]))},null,40,yn)])}),128)),l[23]||(l[23]=e.createElementVNode("td",{class:"te-td te-td-filler"},null,-1))])):e.createCommentVNode("",!0)]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(K.value,(n,d)=>(e.openBlock(),e.createElementBlock("tr",{key:Zt(n,d),class:e.normalizeClass(["te-tr",n.__css_class,{"te-tr-selected":ke(n),"te-tr-highlight":b.value===n}]),style:e.normalizeStyle(n.__style),onClick:f=>Wt(n),onDblclick:f=>Gt(n)},[g.value!==null?(e.openBlock(),e.createElementBlock("td",{key:0,class:"te-td te-td-sel",onClick:l[9]||(l[9]=e.withModifiers(()=>{},["stop"]))},[g.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:ke(n),onChange:f=>at(n),class:"te-checkbox"},null,40,_n)):(e.openBlock(),e.createElementBlock("input",{key:1,type:"radio",checked:b.value===n,onClick:f=>ot(n),class:"te-checkbox"},null,8,Bn))])):e.createCommentVNode("",!0),T.value.length&&!A.value?(e.openBlock(),e.createElementBlock("td",Cn,[e.createElementVNode("div",En,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,f=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:f.key},[f.isVisible()?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["te-btn",Ae(f.severity),f.class]),disabled:f.isDisabled(),onClick:e.withModifiers(p=>f.onClick(n),["stop"]),title:f.getLabel()},[f.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(N)(f.icon)},null,8,Nn)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(f.getLabel()),1)],10,Vn)):e.createCommentVNode("",!0)],64))),128))])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,f=>(e.openBlock(),e.createElementBlock("td",{key:f.field,class:e.normalizeClass(["te-td",f.css,{"te-td-inline-edit":!!ze(f)}]),style:e.normalizeStyle(e.unref(Bt)(n,f))},[mo(n,f)?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":l[10]||(l[10]=p=>ee.value=p),type:"text",class:"te-editing-input",onBlur:p=>Ut(n,f),onKeydown:[e.withKeys(p=>Ut(n,f),["enter"]),e.withKeys(ye,["escape"])],ref_for:!0,ref_key:"inlineEditRef",ref:Se},null,40,Sn)),[[e.vModelText,ee.value]]):(e.openBlock(),e.createElementBlock("div",wn,[e.createElementVNode("span",{onDblclick:p=>qt(p,n,f),innerHTML:nt(n,f)},null,40,Mn),ze(f)?(e.openBlock(),e.createElementBlock("button",{key:0,class:"te-inline-edit-btn",onClick:e.withModifiers(p=>qt(p,n,f),["stop"]),title:"Editar inline"},[e.createElementVNode("span",{class:"te-btn-icon",innerHTML:e.unref(N)("pencil")},null,8,Tn)],8,Dn)):e.createCommentVNode("",!0)])),e.createElementVNode("div",{class:"te-resize-handle",draggable:"false",onPointerdown:e.withModifiers(p=>oe(p,f.field),["stop"]),onDblclick:e.withModifiers(p=>ge(p,f.field),["stop"]),onClick:l[11]||(l[11]=e.withModifiers(()=>{},["stop"]))},null,40,Ln)],6))),128)),l[24]||(l[24]=e.createElementVNode("td",{class:"te-td te-td-filler"},null,-1))],46,bn))),128)),K.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("tr",vn,[e.createElementVNode("td",{colspan:eo.value,class:"te-td te-empty"},"Sin registros",8,Fn)]))])],2)),O.value?(e.openBlock(),e.createElementBlock("div",{key:3,ref_key:"sentinelRef",ref:Ue,class:"te-sentinel"},[Ce.value?(e.openBlock(),e.createElementBlock("span",xn)):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0)],4),e.withDirectives(e.createElementVNode("div",zn,[e.createElementVNode("span",An,"Mostrando "+e.toDisplayString(no.value)+" a "+e.toDisplayString(oo.value)+" de "+e.toDisplayString(et.value),1),e.createElementVNode("div",Pn,[e.createElementVNode("button",{class:"te-page-btn",disabled:_.value<=1,onClick:l[12]||(l[12]=n=>Fe(1))},"««",8,Rn),e.createElementVNode("button",{class:"te-page-btn",disabled:_.value<=1,onClick:l[13]||(l[13]=n=>Fe(_.value-1))},"«",8,On),e.createElementVNode("span",Hn,e.toDisplayString(_.value)+" / "+e.toDisplayString(he.value),1),e.createElementVNode("button",{class:"te-page-btn",disabled:_.value>=he.value,onClick:l[14]||(l[14]=n=>Fe(_.value+1))},"»",8,$n),e.createElementVNode("button",{class:"te-page-btn",disabled:_.value>=he.value,onClick:l[15]||(l[15]=n=>Fe(he.value))},"»»",8,In)]),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":l[16]||(l[16]=n=>M.value=n),class:"te-select",onChange:ro},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Tt.value,n=>(e.openBlock(),e.createElementBlock("option",{key:n,value:n},e.toDisplayString(n),9,jn))),128))],544),[[e.vModelSelect,M.value]])],512),[[e.vShow,!O.value&&Lt.value]])])}}};function Ie(s){if(!s||!Array.isArray(s))return{};const i={};for(const u of s)u.isJson&&(i[u.field]=u);return i}function Et(s,i){if(!s||!i)return s;for(const[u]of Object.entries(i)){const r=s[u];if(typeof r=="string")try{s[u]=JSON.parse(r)}catch{s[u]=r}}return s}function Vt(s,i,u){if(!s||!Array.isArray(s)||!i||!u)return s;for(const[r]of Object.entries(i)){const m=u[r];if(m&&typeof m=="object"&&!Array.isArray(m))for(const[y,le]of Object.entries(m))typeof le=="object"&&le!==null&&!Array.isArray(le)||s.push({field:`${r}.${y}`,headerName:y,sortable:!1,filterable:!1})}return s}function je(s,i){if(!s||!i)return s;for(const u of i)u.formatter&&typeof u.formatter=="function"&&(s[u.field]=u.formatter(s[u.field],s));return s}const Gn=je;function Nt(s){return!s||!Array.isArray(s)?[]:s.map(i=>({field:i.field,headerName:i.headerName||i.field,sortable:i.sortable!==!1,filterable:i.filterable!==!1,css:i.css||"",form_type:i.form_type||null,type:i.type||"text",editable:i.editable||!1}))}function Jn(s,i){if(!i||!i.length)return s;const u=[];for(const r of i){const m=s.find(y=>y.field===r);m&&u.push(m)}for(const r of s)u.some(m=>m.field===r.field)||u.push(r);return u}function St(s){return!s||!Array.isArray(s)?s:s.map(i=>({...i,headerName:i.headerName||i.field}))}function qn(s=null){return{processRows(i,u){if(!(i!=null&&i.length))return i;const r=Ie(u);for(let m=0;m<i.length;m++){let y=Et(i[m],r);y=je(y,u),i[m]=He(y,s)}return i},processFields(i,u){if(!i||!Array.isArray(i))return i;let r=i;return u&&(r=Vt([...r],Ie(r),u)),St(r)},processColumns(i){return Nt(i)}}}k.BtnConfig=j,k.TableEditor=Ct,k.applyFieldDefCss=_t,k.applyRowStyling=He,k.availableIcons=ol,k.cellStyle=Bt,k.createLocalStoragePrefsAdapter=kt,k.default=Ct,k.getCamposJSONyFieldDef=Vt,k.getCamposJson=Ie,k.getFieldDefFFormated=St,k.getGlobalPreferencesAdapter=gt,k.getProcessFieldDef=Nt,k.greenbornDataPipeline=qn,k.iconSvg=N,k.invertHexColor=bt,k.mapFilaJSONtabla=Et,k.reOrder=Jn,k.rowFormatter=je,k.row_formatter=Gn,k.setGlobalPreferencesAdapter=ll,k.toBtnConfig=Oe,k.unwrapCell=$e,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g.VueTableEditor={},g.Vue))})(this,function(g,e){"use strict";class W{constructor(i={}){this.key=i.key||"",this.icon=i.icon,this.severity=i.severity||"primary",this.class=i.class||"",this.label=i.label||"",this._getLabel=i.getLabel||(()=>i.label||""),this._isVisible=i.isVisible||(()=>!0),this._isDisabled=i.isDisabled||(()=>!1),this.onClick=i.onClick||(()=>{}),this.helpKey=i.helpKey||null,this.permissions=i.permissions||null}getLabel(){return this._getLabel()}isVisible(){return this._isVisible()}isDisabled(){return this._isDisabled()}}function $e(s){return s instanceof W?s:new W(s)}const ll="te_preferencias";function gt(s=ll){let i={};function u(){try{const h=localStorage.getItem(s);i=h?JSON.parse(h):{}}catch{i={}}}function r(){try{localStorage.setItem(s,JSON.stringify(i))}catch{}}return u(),{get misValores(){return i},valor(h){const B=i[h];if(!B)return null;try{return JSON.parse(B)}catch{return B}},async guardarValores(h){return i={...i,...h},r(),{status:!0}},async fetchMisPreferencias(){u()}}}const _e={adapter:null};function nl(s){_e.adapter=s}function yt(){return _e.adapter||(_e.adapter=gt()),_e.adapter}const bt={search:'<circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>',plus:'<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',pencil:'<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"/>',trash:'<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>',columns:'<rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/>',eye:'<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>',refresh:'<polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>',"sort-asc":'<path d="M12 19V5"/><polyline points="5 12 12 5 19 12"/>',"sort-desc":'<path d="M12 5v14"/><polyline points="19 12 12 19 5 12"/>',sort:'<path d="M7 8h10"/><path d="M7 12h6"/><path d="M7 16h3"/>',grip:'<circle cx="9" cy="6" r="1"/><circle cx="15" cy="6" r="1"/><circle cx="9" cy="12" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="9" cy="18" r="1"/><circle cx="15" cy="18" r="1"/>',play:'<polygon points="6 3 20 12 6 21 6 3"/>',stop:'<rect x="6" y="6" width="12" height="12" rx="1"/>',files:'<polyline points="16 16 16 16"/><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/>',gear:'<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h0a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h0a1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82v0a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>'};function M(s){if(!s)return"";const i=ol(s),u=bt[i];return u?`<svg class="te-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${u}</svg>`:""}function ol(s){let i=String(s).trim().toLowerCase();return i=i.replace(/^bi\s+bi-/,""),i=i.replace(/^te-/,""),{"arrow-clockwise":"refresh","arrow-counterclockwise":"refresh","layout-three-columns":"columns","plus-lg":"plus","plus-circle":"plus","gear-fill":"gear",files:"files","play-fill":"play","stop-fill":"stop"}[i]||i}const al=Object.keys(bt);function _t(s){return!s||s.length!==7?null:"#"+(255-parseInt(s.slice(1,3),16)).toString(16).padStart(2,"0")+(255-parseInt(s.slice(3,5),16)).toString(16).padStart(2,"0")+(255-parseInt(s.slice(5,7),16)).toString(16).padStart(2,"0")}function Bt(s,i){if(!Array.isArray(s))return s;const u=i==null?void 0:i.fieldClasses;if(!u)return s;for(const r of s)u[r.field]&&(r.css=(r.css||"")+" "+u[r.field]);return s}function Ie(s,i){if(!i)return s;if(s.__css_class="",typeof i.rowClassFn=="function"&&(s.__css_class=i.rowClassFn(s)),typeof i.rowStyleFn=="function"&&(s.__style=i.rowStyleFn(s)),s.__field_styles={},i.fieldStyleFns)for(const u of Object.keys(i.fieldStyleFns))s[u]!=null&&(s.__field_styles[u]=i.fieldStyleFns[u](s[u]));return s}function je(s,i){var r;if(s==null)return{value:null,style:null};const u=s[i==null?void 0:i.field];return u!=null&&typeof u=="object"&&"__style"in u?{value:u.value,style:u.__style}:(r=s.__field_styles)!=null&&r[i==null?void 0:i.field]?{value:u,style:s.__field_styles[i==null?void 0:i.field]}:{value:u,style:null}}function Ct(s,i){return je(s,i).style}const il={class:"te-wrapper"},rl={key:0,class:"te-toolbar"},sl={class:"te-toolbar-start"},cl=["disabled","onClick","title","data-help"],dl=["innerHTML"],fl={key:0,class:"te-toolbar-divider"},ul=["disabled","onClick","title","data-help"],pl=["innerHTML"],ml={key:0,class:"te-toolbar-end"},hl=["data-help"],kl=["innerHTML"],gl={key:0,class:"te-dropdown-menu",style:{"min-width":"220px"}},yl=["id","value"],bl=["data-help"],_l=["innerHTML"],Bl={key:0,class:"te-loading-overlay"},Cl={key:1,class:"te-mobile-list"},El=["onClick","onDblclick"],Vl={class:"te-mobile-card-head"},Nl=["checked","onChange"],Sl=["checked","onClick"],wl=["innerHTML"],Ml={key:0,class:"te-mobile-card-body"},Dl=["innerHTML"],Tl=["disabled","onClick","title","data-help"],Ll=["innerHTML"],vl={key:0,class:"te-mobile-empty"},Fl=["data-field"],xl={key:0,class:"te-header-group-row"},zl={key:0,class:"te-th te-th-sel",rowspan:2},Al=["checked"],Pl={key:1,class:"te-th te-th-acts",rowspan:2},Rl=["colspan"],Ol={class:"te-th-content"},Hl={class:"te-th-group-label"},$l=["data-field","data-help"],Il={class:"te-th-content"},jl=["onClick"],Kl={key:0,class:"te-sort-icon-std"},Wl=["innerHTML"],Gl=["onPointerdown","onDblclick"],Jl={key:1,class:"te-header-row te-has-groups"},ql=["data-field","data-help"],Ul={class:"te-th-content"},Xl=["onClick"],Yl={key:0,class:"te-sort-icon-std"},Ql=["innerHTML"],Zl=["onPointerdown","onDblclick"],en={key:2,class:"te-header-row"},tn={key:0,class:"te-th te-th-sel"},ln=["checked"],nn={key:1,class:"te-th te-th-acts"},on=["data-field","data-help","draggable","onDragstart","onDragenter","onDragover","onDragleave","onDrop"],an={class:"te-th-content"},rn=["innerHTML"],sn=["onClick"],cn={key:0,class:"te-sort-icon-std"},dn=["innerHTML"],fn=["onPointerdown","onDblclick"],un={key:0,class:"te-drop-indicator te-drop-left"},pn={key:1,class:"te-drop-indicator te-drop-right"},mn={key:3,class:"te-filter-row"},hn={key:0,class:"te-td"},kn={key:1,class:"te-td"},gn=["onUpdate:modelValue"],yn=["value"],bn=["onUpdate:modelValue"],_n=["onPointerdown","onDblclick"],Bn=["onClick","onDblclick"],Cn=["checked","onChange"],En=["checked","onClick"],Vn={key:1,class:"te-td te-td-acts"},Nn={class:"te-actions-wrap"},Sn=["disabled","onClick","title","data-help"],wn=["innerHTML"],Mn=["onBlur","onKeydown"],Dn={key:1,class:"te-cell-wrap"},Tn=["onDblclick","innerHTML"],Ln=["onClick"],vn=["innerHTML"],Fn=["onPointerdown","onDblclick"],xn={key:0},zn=["colspan"],An={key:0,class:"te-loading-spinner"},Pn=["data-help"],Rn={class:"te-page-info"},On={class:"te-page-controls"},Hn=["disabled"],$n=["disabled"],In={class:"te-page-current"},jn=["disabled"],Kn=["disabled"],Wn=["value"],Gn="te_cfg",Et={__name:"TableEditor",props:{api:{type:Object,default:null},permisos:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})},data:{type:[Array,Object],default:null},id:{type:String,default:null}},emits:["loaded","rowSelected","rowDoubleClick","createRequest","editRequest","deleteRequest"],setup(s,{expose:i,emit:u}){const r=s,h=u,B=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.preferencesStore)||yt()});function oe(){return r.id?`${Gn}_${r.id}`:null}let Z=null;async function Xn(){const t=oe();if(!t)return null;try{const l=B.value.valor(t);return l?typeof l=="string"?JSON.parse(l):l:null}catch{return null}}async function Ge(){const t=oe();if(!t)return;const l=Ue.value.map(m=>m.field),o=new Set(N.value.map(m=>m.field)),a={};for(const m of l)a[m]=de.value[m]||"15rem";const c=G.value.length?G.value:l,f=l.filter(m=>!o.has(m));await B.value.guardarValores({[t]:JSON.stringify({columnOrder:c,columnWidths:a,hiddenFields:f})})}function Je(){Z&&clearTimeout(Z),Z=setTimeout(()=>{Z=null,Ge()},500)}function qe(){return U?(clearTimeout(U),U=null,Ge()):Z?(clearTimeout(Z),Z=null,Ge()):null}const V=e.ref([]),Mt=e.ref([]),N=e.ref([]),Ue=e.ref([]),Dt=e.ref(null),Tt=e.ref(!1),H=e.ref(!0),_=e.ref("single"),C=e.ref(null),S=e.ref(new Map),x=e.ref(null),ee=e.ref("asc"),$=e.ref({}),Be=e.ref(""),E=e.ref(1),L=e.ref(25),Lt=e.ref([25,50,100,200]),Ce=e.ref(null),vt=e.ref(!0),Ft=e.ref(!1),Yn=e.ref(!0);e.ref(!0);const xt=e.ref(!0),Qn=e.ref("3rem"),zt=e.ref("10rem"),de=e.ref({}),G=e.ref([]),fe=e.ref(!1),ue=e.ref(0),v=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.lazy)===!0}),I=e.computed(()=>{var t,l;return((t=r.config)==null?void 0:t.infiniteScroll)===!0||((l=r.config)==null?void 0:l.infiniteScroll)!==!1&&v.value}),Ee=e.ref(!1),J=e.ref(!0),te=e.ref(1),Xe=e.ref(null),Ye=e.ref(null),Qe=e.ref(null),Ve=e.ref(!1);let q=null;const D=e.ref(null),j=e.ref(null),z=e.ref(null),A=e.ref(null);let Ne=null,Se=null;const P=e.ref(null),le=e.ref(""),we=e.ref(null),ae=e.ref(null);let R=null,w=null,pe=null,me=null,U=null;const he=e.ref({create:"Nuevo",edit:"Editar",delete:"Borrar",article:"un",deleted:"eliminado"}),T=e.computed(()=>{const t=N.value;if(G.value.length){const l=[];for(const o of G.value){const a=t.find(c=>c.field===o);a&&l.push(a)}for(const o of t)l.some(a=>a.field===o.field)||l.push(o);return l}return t}),F=e.computed(()=>ot.value.rowActions||[]),O=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.rowActionsMode)==="toolbar"}),Zn=e.computed(()=>{var t;return O.value&&((t=r.config)==null?void 0:t.cardActions)===!0}),Ze=e.computed(()=>O.value?F.value:[]),Me=e.computed(()=>_.value==="multiple"?[...S.value.keys()]:C.value?[C.value]:[]),De=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.lazyProtocol)==="legacy"}),eo=e.computed(()=>{var t;return!!((t=r.config)!=null&&t.columnFilterDefs)}),ne=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.dataPipeline)||null}),Te=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.styling)||null}),to=e.computed(()=>{var t;return typeof((t=r.config)==null?void 0:t.permissionsCheck)=="function"}),lo=e.computed(()=>{let t=T.value.length+1;return _.value!==null&&t++,F.value.length&&!O.value&&t++,t}),Le=e.computed(()=>{var t,l;return((l=(t=r.config)==null?void 0:t.columnGroups)==null?void 0:l.length)>0}),et=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.mobileListView)===!0}),At=e.computed(()=>{var t;return((t=r.config)==null?void 0:t.mobileBreakpoint)??768}),ve=e.ref(!1),Pt=e.computed(()=>T.value[0]||null),Rt=e.computed(()=>T.value.slice(1)),no=e.computed(()=>et.value&&ve.value);let X=null;function tt(t){ve.value=t.matches}function Ot(){X&&X.removeEventListener("change",tt),X=null,ve.value=!1,!(!et.value||typeof window>"u"||!window.matchMedia)&&(X=window.matchMedia(`(max-width: ${At.value}px)`),ve.value=X.matches,X.addEventListener("change",tt))}const Ht=e.computed(()=>{var t;return(t=r.config)==null?void 0:t.inlineEditing}),oo=e.computed(()=>{var t;return((t=Ht.value)==null?void 0:t.campos)||{}}),$t=e.computed(()=>{if(!Le.value)return[];const t=r.config.columnGroups||[],l=T.value,o={};for(let f=0;f<t.length;f++)for(const m of t[f].fields)o[m]=f;const a=[];let c=0;for(;c<l.length;){const f=l[c],m=o[f.field];if(m!==void 0){const b=[];for(;c<l.length&&o[l[c].field]===m;)b.push(l[c]),c++;a.push({_key:"g-"+m,_type:"group",headerName:t[m].headerName,_span:b.length,_cols:b})}else a.push({_key:"c-"+f.field,_type:"col",_col:f}),c++}return a}),Fe=e.computed(()=>{let t=V.value||[];const l=Be.value;if(l){const o=l.toLowerCase();t=t.filter(a=>T.value.some(c=>{const f=a[c.field];return f!=null&&String(f).toLowerCase().includes(o)}))}for(const o of T.value){const a=$.value[o.field];if(a){const c=a.toLowerCase();t=t.filter(f=>{const m=f[o.field];return m!=null&&String(m).toLowerCase().includes(c)})}}return x.value&&(t=[...t].sort((o,a)=>{let c=o[x.value],f=a[x.value];return c==null&&(c=""),f==null&&(f=""),typeof c=="number"&&typeof f=="number"?ee.value==="asc"?c-f:f-c:(c=String(c).toLowerCase(),f=String(f).toLowerCase(),ee.value==="asc"?c.localeCompare(f):f.localeCompare(c))})),t}),lt=e.computed(()=>v.value?ue.value:Fe.value.length),ke=e.computed(()=>Math.max(1,Math.ceil(lt.value/L.value))),Y=e.computed(()=>{if(I.value)return V.value||[];if(v.value)return V.value||[];const t=(E.value-1)*L.value;return Fe.value.slice(t,t+L.value)}),ao=e.computed(()=>(E.value-1)*L.value+1),io=e.computed(()=>Math.min(E.value*L.value,lt.value)),nt=e.computed(()=>Y.value.length>0&&Y.value.every(t=>ge(t))),ot=e.ref({toolbar:[new W({key:"refresh",icon:"refresh",severity:"outline-info",isVisible:()=>{var t;return!((t=r.config)!=null&&t.hideRefresh)},onClick:()=>Oe()}),new W({key:"csv",icon:"download",severity:"outline-info",label:"CSV",isVisible:()=>{var t;return!((t=r.config)!=null&&t.hideCsvExport)},onClick:()=>_o()}),new W({key:"create",icon:"plus",severity:"success",isVisible:()=>{var t,l;return((t=r.api)==null?void 0:t.create)!=null&&xe((l=r.permisos)==null?void 0:l.create)},getLabel:()=>he.value.create,onClick:()=>ut("create")}),new W({key:"edit",icon:"pencil",severity:"warning",isVisible:()=>{var t,l;return((t=r.api)==null?void 0:t.edit)!=null&&xe((l=r.permisos)==null?void 0:l.edit)},getLabel:()=>he.value.edit,isDisabled:()=>H.value,onClick:()=>ut("edit")}),new W({key:"delete",icon:"trash",severity:"danger",isVisible:()=>{var t,l;return((t=r.api)==null?void 0:t.delete)!=null&&xe((l=r.permisos)==null?void 0:l.delete)},getLabel:()=>he.value.delete,isDisabled:()=>H.value,onClick:()=>yo()})],rowActions:[]});function xe(t){return!t||!to.value?!0:!!r.config.permissionsCheck(t)}const It=e.computed(()=>{var l,o;const t=[];for(const a of ot.value.toolbar)a.isVisible()&&t.push(a);if((o=(l=r.config)==null?void 0:l.buttons)!=null&&o.toolbar)for(const a of r.config.buttons.toolbar)t.push($e(a));return t});function jt(){var t,l,o,a,c,f,m,b,n,p;((t=r.config)==null?void 0:t.selectionMode)!=null&&(_.value=r.config.selectionMode),((o=(l=r.config)==null?void 0:l.elementName)==null?void 0:o.gender)==="F"&&(he.value={create:"Nueva",edit:"Editar",delete:"Borrar",article:"una",deleted:"eliminada"}),((a=r.config)==null?void 0:a.pageSize)!=null&&(L.value=r.config.pageSize),((c=r.config)==null?void 0:c.pageSizeOptions)!=null&&(Lt.value=r.config.pageSizeOptions),((f=r.config)==null?void 0:f.scrollHeight)!=null&&(Ce.value=r.config.scrollHeight),((m=r.config)==null?void 0:m.showPaginator)!=null&&(vt.value=r.config.showPaginator),((b=r.config)==null?void 0:b.showFilterRow)!=null&&(Ft.value=r.config.showFilterRow),(p=(n=r.config)==null?void 0:n.buttons)!=null&&p.rowActions&&(ot.value.rowActions=r.config.buttons.rowActions.map($e)),e.nextTick(()=>tl())}function at(t,l){var c,f,m,b;let{value:o}=je(t,l);if(o==null||o==="")return"-";const a=(f=(c=r.config)==null?void 0:c.valueFormatters)==null?void 0:f[l==null?void 0:l.field];if((l==null?void 0:l.form_type)==="color"){const n="#"+(o||"000000"),p=_t(n)||"#ffffff";return`<span class="te-color-badge" style="background:${n};color:${p}">${o}</span>`}if((l==null?void 0:l.form_type)==="json")return JSON.stringify(o);if((l==null?void 0:l.type)==="date"||(m=l==null?void 0:l.field)!=null&&m.endsWith("_at")||(b=l==null?void 0:l.field)!=null&&b.endsWith("At"))try{return new Date(o).toLocaleDateString()}catch{return o}if((l==null?void 0:l.type)==="datetime")try{return new Date(o).toLocaleString()}catch{return o}return(l==null?void 0:l.type)==="boolean"||(l==null?void 0:l.type)==="bool"?o?"Sí":"No":typeof a=="function"?a(t):String(o)}function ge(t){return _.value==="single"?C.value===t:S.value.has(t)}function it(t){C.value===t?(C.value=null,H.value=!0,h("rowSelected",null)):(C.value=t,H.value=!1,h("rowSelected",t))}function rt(t){S.value.has(t)?S.value.delete(t):S.value.set(t,!0),H.value=S.value.size===0,h("rowSelected",[...S.value.keys()])}function Kt(){if(nt.value)S.value=new Map,H.value=!0,h("rowSelected",[]);else{const t=new Map;for(const l of Y.value)t.set(l,!0);S.value=t,H.value=!1,h("rowSelected",[...t.keys()])}}function Wt(t){A.value||D.value||(_.value==="multiple"?rt(t):it(t))}function Gt(t){var l,o,a;A.value||D.value||(h("rowDoubleClick",t),(l=r.config)!=null&&l.editOnDoubleClick&&((o=r.api)!=null&&o.edit)&&xe((a=r.permisos)==null?void 0:a.edit)&&(_.value==="single"&&(C.value=t),ut("edit")))}function st(t){return x.value!==t?"sort":ee.value==="asc"?"sort-asc":"sort-desc"}function ct(t){if(A.value||D.value)return;re();const l=T.value.find(o=>o.field===t);(l==null?void 0:l.sortable)!==!1&&(x.value===t?ee.value=ee.value==="asc"?"desc":"asc":(x.value=t,ee.value="asc"),E.value=1,v.value&&(I.value&&(te.value=1,J.value=!0,V.value=[]),ce()))}function ro(){me&&clearTimeout(me),me=setTimeout(()=>{E.value=1,v.value&&(I.value&&(te.value=1,J.value=!0,V.value=[]),ce())},300)}function Jt(){pe&&clearTimeout(pe),pe=setTimeout(()=>{E.value=1,v.value&&(I.value&&(te.value=1,J.value=!0,V.value=[]),ce())},400)}function so(){U&&clearTimeout(U),U=setTimeout(()=>Je(),300)}function ze(t){re(),E.value=Math.max(1,Math.min(t,ke.value)),v.value&&ce()}function co(){re(),E.value=1,v.value&&ce()}function ie(t,l){if(t.button!==0||D.value)return;t.preventDefault();const o=t.currentTarget.closest("th, td");if(!(!o||o.getBoundingClientRect().right-t.clientX>11)){try{o.setPointerCapture(t.pointerId)}catch{}A.value=l,Ne=t.clientX,Se=o.offsetWidth,document.body.style.cursor="col-resize",document.body.classList.add("te-resizing"),document.addEventListener("pointermove",dt),document.addEventListener("pointerup",ft)}}function dt(t){if(!A.value||Ne==null||Se==null)return;const l=Math.max(100,Se+(t.clientX-Ne));de.value={...de.value,[A.value]:l+"px"}}function ft(){document.removeEventListener("pointermove",dt),document.removeEventListener("pointerup",ft),document.body.style.cursor="",document.body.classList.remove("te-resizing"),A.value&&Je(),Ne=null,Se=null,A.value=null}function ye(t,l){ie(t,l)}function fo(t,l){if(A.value){t.preventDefault();return}D.value=l,j.value=null,z.value=null,t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",l))}function uo(t,l){D.value===l||t.relatedTarget&&t.currentTarget.contains(t.relatedTarget)||(j.value=l)}function po(t,l){if(D.value===l)return;t.dataTransfer&&(t.dataTransfer.dropEffect="move");const o=t.currentTarget.getBoundingClientRect();z.value=t.clientX<o.left+o.width/2?"left":"right"}function mo(t,l){t.currentTarget.contains(t.relatedTarget)||j.value===l&&(j.value=null,z.value=null)}function ho(t,l){if(!D.value||D.value===l){Ae();return}const o=G.value.length?[...G.value]:N.value.map(b=>b.field),a=o.indexOf(D.value),c=o.indexOf(l);if(a<0||c<0){Ae();return}const[f]=o.splice(a,1),m=a<c?z.value==="right"?c:c-1:z.value==="left"?c:c+1;o.splice(Math.max(0,Math.min(o.length,m)),0,f),G.value=o,Je(),Ae()}function Ae(){D.value=null,j.value=null,z.value=null}function Pe(t){return oo.value[t==null?void 0:t.field]||null}function ko(t,l){return P.value?P.value.row===t&&P.value.field===l.field:!1}function qt(t,l,o){var m,b;if(!Pe(o))return;(m=t==null?void 0:t.stopPropagation)==null||m.call(t);const f=((b=l.__raw)==null?void 0:b[o.field])??l[o.field]??"";ae.value=f,P.value={row:l,field:o.field},le.value=f,e.nextTick(()=>{const n=Array.isArray(we.value)?we.value[0]:we.value;n&&typeof n.focus=="function"&&(n.focus(),n.select())})}function Ut(t,l){if(!P.value)return;const o=Pe(l);if(!o){be();return}let a=le.value;if(o.type==="currency"){const c=String(a).replace(/[^0-9,\-]/g,"").replace(",",".");if(a=parseFloat(c),isNaN(a)){be();return}}else if(o.type==="integer"){if(a=parseInt(a,10),isNaN(a)||o.min!==void 0&&a<o.min){be();return}}else if(o.type==="number"&&(a=parseFloat(a),isNaN(a)||o.min!==void 0&&a<o.min)){be();return}t[l.field]=o.format?o.format(a):a,t.__raw||(t.__raw={}),t.__raw[l.field]=a,o.afterEdit&&o.afterEdit(t,l.field,a),P.value=null,le.value="",go(t,l.field,a)}function be(){if(P.value&&ae.value!==null){const{row:t,field:l}=P.value;t[l]=ae.value}P.value=null,le.value="",ae.value=null}function go(t,l,o){const a=Ht.value;if(!(a!=null&&a.api))return;const c=t.id;if(!c)return;R&&(clearTimeout(R),R=null),w&&(w.api(w.data),w=null);const f=ae.value??t[l];w={api:a.api,data:{id:c,field:l,value:o}},R=setTimeout(async()=>{const m=await a.api({id:c,field:l,value:o});w=null,se(m)?(t[l]=f,console.error("[TableEditor] inline save failed:",m)):a.onSave&&a.onSave()},a.debounce_ms??1e3)}function re(){P.value=null,le.value="",ae.value=null,R&&(clearTimeout(R),R=null),w&&(w.api(w.data),w=null)}function Xt(t){var a,c,f,m,b;const l=((c=(a=r.config)==null?void 0:a.extraFields)==null?void 0:c[t==="create"?"create":t==="edit"?"edit":"list"])||[],o=t==="edit";return{action:t,title:`${he.value[t]} ${((m=(f=r.config)==null?void 0:f.elementName)==null?void 0:m.singular)||""}`.trim(),campos:[...Mt.value,...l],modelo:o?C.value:{},onSubmit:(b=r.api)==null?void 0:b[t],guardado:()=>Oe(),selectedRows:_.value==="multiple"?[...S.value.keys()]:[C.value]}}function ut(t){var o,a,c;if(!((o=r.api)!=null&&o[t]))return;const l=(c=(a=r.config)==null?void 0:a.crud)==null?void 0:c.openModal;if(typeof l=="function"){l(Xt(t));return}h(t+"Request",Xt(t))}async function yo(){var a,c;const l=(_.value==="multiple"?[...S.value.keys()]:[C.value]).map(f=>f==null?void 0:f.id).filter(Boolean);if(!l.length){h("deleteRequest",{ids:[],action:"delete"});return}const o=(c=(a=r.config)==null?void 0:a.crud)==null?void 0:c.confirmDelete;typeof o=="function"?Promise.resolve(o(l)).then(f=>{f&&bo(l)}).catch(f=>console.error("[TableEditor] confirmDelete error:",f)):h("deleteRequest",{ids:l,action:"delete"})}async function bo(t){var l;if(!(!((l=r.api)!=null&&l.delete)||!t.length))try{const o=await r.api.delete({id:t[0]});if(se(o)){console.error("[TableEditor] delete failed:",o);return}C.value=null,S.value=new Map,H.value=!0,Oe()}catch(o){console.error("[TableEditor] delete error:",o)}}function se(t){return t!=null&&(t.status===!1||t.stat===!1)}async function _o(){var t,l,o;if(v.value&&((t=r.config)!=null&&t.csvFetchAll)&&((l=r.api)!=null&&l.list))try{const a=pt({page:1});a[De.value?"rows":"pageSize"]=Math.max(ue.value||0,L.value);const c=await r.api.list(a);if(se(c)){console.error("[TableEditor] CSV fetch error:",c);return}Yt(((o=c==null?void 0:c.data)==null?void 0:o.rows)||[]);return}catch(a){console.error("[TableEditor] CSV fetch error:",a);return}Yt(V.value||[])}function Yt(t){if(!t.length)return;const l=T.value;let o=l.map(c=>Qt(c.headerName)).join(",")+`
|
|
2
|
+
`;for(const c of t)o+=l.map(f=>Qt(c[f.field]!=null?String(c[f.field]):"")).join(",")+`
|
|
3
|
+
`;const a=document.createElement("a");a.href="data:text/csv;charset=utf-8,"+encodeURIComponent("\uFEFF"+o),a.download="datos.csv",a.click()}function Qt(t){return t=String(t).replace(/"/g,'""'),t.includes(",")||t.includes('"')||t.includes(`
|
|
4
|
+
`)?'"'+t+'"':t}function Re(t){let l=String(t||"primary");return l.startsWith("te-btn-")?l:(l.startsWith("btn-")&&(l=l.slice(4)),"te-btn-"+l)}function Zt(t){Qe.value&&!Qe.value.contains(t.target)&&(Ve.value=!1)}function Oe(){re(),C.value=null,S.value=new Map,H.value=!0,I.value&&(te.value=1,J.value=!0,V.value=[]),He()}function pt(t={}){const o={page:t.page??(I.value?te.value:E.value),[De.value?"rows":"pageSize"]:L.value,sortField:x.value||"",sortOrder:ee.value,[De.value?"globalSearch":"search"]:Be.value||""},a={};for(const c of Object.keys($.value))$.value[c]&&(a[c]=De.value?{value:$.value[c],matchMode:"contains"}:$.value[c]);return Object.keys(a).length&&(o.filters=JSON.stringify(a)),o}async function ce(){var t,l;re(),fe.value=!0;try{const o=await r.api.list(pt());se(o)||(ue.value=((t=o==null?void 0:o.data)==null?void 0:t.totalRecords)||((l=o==null?void 0:o.data)==null?void 0:l.total)||0,mt(o==null?void 0:o.data))}catch(o){console.error("[TableEditor] load error:",o)}finally{fe.value=!1}}async function He(t){var o;const l=t||r.data;if(l!=null)return mt(l);if((o=r.api)!=null&&o.list){if(v.value)return ce();fe.value=!0;try{const a=await r.api.list();se(a)||mt(a==null?void 0:a.data)}catch(a){console.error("[TableEditor] load error:",a)}finally{fe.value=!1}}h("rowSelected",_.value==="single"?null:[]),C.value=null,S.value=new Map}function mt(t){var a,c,f,m,b,n;if(!t){Tt.value=!0,h("loaded",!0);return}let l=t.rows||[],o=t.fields_def;if(ne.value?(ne.value.processRows&&(l=ne.value.processRows(l,o)||l),ne.value.processFields&&(o=ne.value.processFields(o,l[0])??o)):Te.value&&(l=l.map(p=>Ie(p,Te.value))),V.value=l,re(),o){const p=JSON.stringify(o.map(k=>k==null?void 0:k.field));if(p===Dt.value)return;Dt.value=p;let d=[...o];(c=(a=r.config)==null?void 0:a.extraFields)!=null&&c.list&&d.push(...r.config.extraFields.list),Te.value&&Bt(d,Te.value);const y=(f=r.config)==null?void 0:f.columnFilterDefs;if(y)for(const k of d)y[k.field]&&(k.filter={type:"text",...y[k.field]});Mt.value=d;let ht=d;if((m=ne.value)!=null&&m.processColumns&&(ht=ne.value.processColumns(d)),N.value=[...ht],Ue.value=[...ht],(b=r.config)!=null&&b.defaultColumnProps)for(let k=0;k<N.value.length;k++)N.value[k]={...N.value[k],...r.config.defaultColumnProps};if((n=r.config)!=null&&n.columnOrder){const k=[];for(const Q of r.config.columnOrder){const K=N.value.find(kt=>kt.field===Q);K&&k.push(K)}for(const Q of N.value)k.some(K=>K.field===Q.field)||k.push(Q);N.value=k}Xn().then(k=>{if(k!=null&&k.columnWidths)for(const[Q,K]of Object.entries(k.columnWidths))de.value[Q]=K;if(G.value=(k==null?void 0:k.columnOrder)||[],Array.isArray(k==null?void 0:k.hiddenFields)&&k.hiddenFields.length){const Q=new Set(k.hiddenFields),K=N.value.filter(kt=>!Q.has(kt.field));K.length&&(N.value=K)}})}Tt.value=!0,h("loaded",!0)}function Bo(){if(!I.value)return;const t=Ye.value;!t||!Xe.value||(q==null||q.disconnect(),q=new IntersectionObserver(([l])=>{l.isIntersecting&&J.value&&!Ee.value&&Co()},{root:t,rootMargin:"0px 0px 200px 0px",threshold:0}),q.observe(Xe.value))}async function Co(){var t,l,o;if(Ee.value=!0,v.value){te.value++;try{const a=await r.api.list(pt({page:te.value}));if(!se(a)){const c=((t=a==null?void 0:a.data)==null?void 0:t.rows)||[];c.length&&(V.value=[...V.value,...c]),ue.value=((l=a==null?void 0:a.data)==null?void 0:l.totalRecords)||((o=a==null?void 0:a.data)==null?void 0:o.total)||0}J.value=V.value.length<ue.value}catch(a){console.error("[TableEditor] load more error:",a),J.value=!1}}else{const a=Fe.value.length,c=V.value.length,f=Math.min(c+L.value,a);f>c&&(V.value=[...Fe.value.slice(0,f)]),J.value=V.value.length<a}Ee.value=!1}function el(t,l){var a;const o=(a=r.config)==null?void 0:a.trackBy;if(o){if(typeof o=="function"){const c=o(t,l);if(c!=null)return c}else if((t==null?void 0:t[o])!=null)return t[o]}return(t==null?void 0:t.id)??(t==null?void 0:t.__uid)??l}e.watch(()=>r.data,t=>{(t==null?void 0:t.rows)!==void 0&&He(t)}),e.watch(Y,()=>tl()),e.watch([et,At],()=>Ot());function tl(){!F.value.length||O.value||e.nextTick(()=>{const t=Ye.value;if(!t)return;let l=0;t.querySelectorAll(".te-actions-wrap").forEach(o=>{l=Math.max(l,o.scrollWidth)}),l>0&&(zt.value=Math.max(56,l+24)+"px")})}return e.onMounted(async()=>{jt(),Ot(),document.addEventListener("click",Zt),window.addEventListener("beforeunload",qe),B.value.fetchMisPreferencias&&await B.value.fetchMisPreferencias(),await He(),e.nextTick(()=>Bo())}),e.onUnmounted(()=>{document.removeEventListener("click",Zt),X&&X.removeEventListener("change",tt),document.removeEventListener("pointermove",dt),document.removeEventListener("pointerup",ft),window.removeEventListener("beforeunload",qe),qe(),q==null||q.disconnect(),R&&(clearTimeout(R),R=null),w&&(w.api(w.data),w=null),pe&&clearTimeout(pe),me&&clearTimeout(me),U&&clearTimeout(U)}),i({loadData:He,applyConfig:jt,refresh:Oe}),(t,l)=>{var o,a,c,f,m,b;return e.openBlock(),e.createElementBlock("div",il,[!((o=s.config)!=null&&o.hideToolbar)||Ze.value.length?(e.openBlock(),e.createElementBlock("div",rl,[e.createElementVNode("div",sl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(It.value,n=>(e.openBlock(),e.createElementBlock("button",{key:n.key,class:e.normalizeClass(["te-btn",Re(n.severity),n.class]),disabled:n.isDisabled(),onClick:n.onClick,title:n.getLabel(),"data-help":n.helpKey||void 0},[n.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(M)(n.icon)},null,8,dl)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(n.getLabel()),1)],10,cl))),128)),Ze.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[It.value.length?(e.openBlock(),e.createElementBlock("span",fl,"|")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ze.value,n=>(e.openBlock(),e.createElementBlock("button",{key:"ra-"+n.key,class:e.normalizeClass(["te-btn",Re(n.severity),n.class]),disabled:n.isDisabled()||!Me.value.length,onClick:p=>n.onClick(Me.value.length===1?Me.value[0]:Me.value),title:n.getLabel(),"data-help":n.helpKey||void 0},[n.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(M)(n.icon)},null,8,pl)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(n.getLabel()),1)],10,ul))),128))],64)):e.createCommentVNode("",!0)]),(a=s.config)!=null&&a.hideToolbarEnd?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ml,[(c=s.config)!=null&&c.hideColumnSelector?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:"te-dropdown",ref_key:"colsDropdownRef",ref:Qe,"data-help":((f=s.config)==null?void 0:f.columnSelectorHelpKey)||void 0},[e.createElementVNode("button",{class:"te-btn te-btn-outline-secondary",type:"button",title:"Columnas",onClick:l[0]||(l[0]=n=>Ve.value=!Ve.value)},[e.createElementVNode("span",{class:"te-btn-icon",innerHTML:e.unref(M)("columns")},null,8,kl),l[17]||(l[17]=e.createTextVNode("Columnas ",-1))]),Ve.value?(e.openBlock(),e.createElementBlock("div",gl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ue.value,n=>(e.openBlock(),e.createElementBlock("label",{key:n.field,class:"te-dropdown-item"},[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"te-cols-"+n.field,value:n,"onUpdate:modelValue":l[1]||(l[1]=p=>N.value=p),class:"te-checkbox",onChange:so},null,40,yl),[[e.vModelCheckbox,N.value]]),e.createTextVNode(" "+e.toDisplayString(n.headerName),1)]))),128))])):e.createCommentVNode("",!0)],8,hl)),e.createElementVNode("div",{class:"te-search","data-help":((m=s.config)==null?void 0:m.searchHelpKey)||void 0},[e.createElementVNode("span",{class:"te-search-icon",innerHTML:e.unref(M)("search")},null,8,_l),e.withDirectives(e.createElementVNode("input",{type:"text",class:"te-search-input","onUpdate:modelValue":l[2]||(l[2]=n=>Be.value=n),onInput:ro,placeholder:"Buscar..."},null,544),[[e.vModelText,Be.value]])],8,bl)]))])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"te-scroll-wrap",style:e.normalizeStyle(Ce.value?{height:Ce.value,minHeight:Ce.value}:{}),ref_key:"scrollWrapRef",ref:Ye},[fe.value?(e.openBlock(),e.createElementBlock("div",Bl,[...l[18]||(l[18]=[e.createElementVNode("div",{class:"te-loading-spinner",role:"status"},[e.createElementVNode("span",{class:"te-sr-only"},"Cargando...")],-1)])])):e.createCommentVNode("",!0),no.value?(e.openBlock(),e.createElementBlock("div",Cl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Y.value,(n,p)=>(e.openBlock(),e.createElementBlock("div",{key:el(n,p),class:e.normalizeClass(["te-mobile-card",n.__css_class,{"te-tr-selected":ge(n),"te-tr-highlight":C.value===n}]),style:e.normalizeStyle(n.__style),onClick:d=>Wt(n),onDblclick:d=>Gt(n)},[e.createElementVNode("div",Vl,[_.value!==null?(e.openBlock(),e.createElementBlock("div",{key:0,class:"te-mobile-card-sel",onClick:l[3]||(l[3]=e.withModifiers(()=>{},["stop"]))},[_.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:ge(n),onChange:d=>rt(n),class:"te-checkbox"},null,40,Nl)):(e.openBlock(),e.createElementBlock("input",{key:1,type:"radio",checked:C.value===n,onClick:d=>it(n),class:"te-checkbox"},null,8,Sl))])):e.createCommentVNode("",!0),Pt.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"te-mobile-card-title",innerHTML:at(n,Pt.value)},null,8,wl)):e.createCommentVNode("",!0)]),Rt.value.length?(e.openBlock(),e.createElementBlock("dl",Ml,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Rt.value,d=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.field},[e.createElementVNode("dt",null,e.toDisplayString(d.headerName),1),e.createElementVNode("dd",{innerHTML:at(n,d)},null,8,Dl)],64))),128))])):e.createCommentVNode("",!0),F.value.length&&(!O.value||Zn.value)?(e.openBlock(),e.createElementBlock("div",{key:1,class:"te-mobile-card-actions",onClick:l[4]||(l[4]=e.withModifiers(()=>{},["stop"]))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,d=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.key},[d.isVisible()?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["te-btn",Re(d.severity),d.class]),disabled:d.isDisabled(),onClick:e.withModifiers(y=>d.onClick(n),["stop"]),title:d.getLabel(),"data-help":d.helpKey||void 0},[d.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(M)(d.icon)},null,8,Ll)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(d.getLabel()),1)],10,Tl)):e.createCommentVNode("",!0)],64))),128))])):e.createCommentVNode("",!0)],46,El))),128)),Y.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",vl,"Sin registros"))])):(e.openBlock(),e.createElementBlock("table",{key:2,class:e.normalizeClass(["te-table",{"te-striped":Yn.value}])},[e.createElementVNode("colgroup",null,[_.value!==null?(e.openBlock(),e.createElementBlock("col",{key:0,style:e.normalizeStyle({width:Qn.value})},null,4)):e.createCommentVNode("",!0),F.value.length&&!O.value?(e.openBlock(),e.createElementBlock("col",{key:1,style:e.normalizeStyle({width:zt.value})},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,n=>(e.openBlock(),e.createElementBlock("col",{key:n.field,style:e.normalizeStyle({width:de.value[n.field]||"15rem"}),"data-field":n.field},null,12,Fl))),128)),l[19]||(l[19]=e.createElementVNode("col",{class:"te-col-filler"},null,-1))]),e.createElementVNode("thead",null,[Le.value?(e.openBlock(),e.createElementBlock("tr",xl,[_.value!==null?(e.openBlock(),e.createElementBlock("th",zl,[_.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:nt.value,onChange:Kt,class:"te-checkbox"},null,40,Al)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),F.value.length&&!O.value?(e.openBlock(),e.createElementBlock("th",Pl,"Acciones")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($t.value,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n._key},[n._type==="group"?(e.openBlock(),e.createElementBlock("th",{key:0,colspan:n._span,class:"te-th te-th-group"},[e.createElementVNode("div",Ol,[e.createElementVNode("span",Hl,e.toDisplayString(n.headerName),1)])],8,Rl)):(e.openBlock(),e.createElementBlock("th",{key:1,rowspan:2,"data-field":n._col.field,"data-help":n._col.helpKey||void 0,class:e.normalizeClass(["te-th",n._col.css,{"te-th-sorted":x.value===n._col.field}])},[e.createElementVNode("div",Il,[e.createElementVNode("span",{class:"te-th-label",onClick:p=>ct(n._col.field)},[e.createTextVNode(e.toDisplayString(n._col.headerName)+" ",1),n._col.sortable!==!1?(e.openBlock(),e.createElementBlock("span",Kl,[e.createElementVNode("span",{innerHTML:e.unref(M)(st(n._col.field))},null,8,Wl)])):e.createCommentVNode("",!0)],8,jl)]),e.createElementVNode("div",{class:"te-resize-handle",onPointerdown:e.withModifiers(p=>ie(p,n._col.field),["stop"]),onDblclick:e.withModifiers(p=>ye(p,n._col.field),["stop"]),onClick:l[5]||(l[5]=e.withModifiers(()=>{},["stop"]))},null,40,Gl)],10,$l))],64))),128)),l[20]||(l[20]=e.createElementVNode("th",{class:"te-th te-th-filler",rowspan:2},null,-1))])):e.createCommentVNode("",!0),Le.value?(e.openBlock(),e.createElementBlock("tr",Jl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($t.value,n=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:"r2-"+n._key},[n._type==="group"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(n._cols,p=>(e.openBlock(),e.createElementBlock("th",{key:p.field,"data-field":p.field,"data-help":p.helpKey||void 0,class:e.normalizeClass(["te-th",p.css,{"te-th-sorted":x.value===p.field}])},[e.createElementVNode("div",Ul,[e.createElementVNode("span",{class:"te-th-label",onClick:d=>ct(p.field)},[e.createTextVNode(e.toDisplayString(p.headerName)+" ",1),p.sortable!==!1?(e.openBlock(),e.createElementBlock("span",Yl,[e.createElementVNode("span",{innerHTML:e.unref(M)(st(p.field))},null,8,Ql)])):e.createCommentVNode("",!0)],8,Xl)]),e.createElementVNode("div",{class:"te-resize-handle",onPointerdown:e.withModifiers(d=>ie(d,p.field),["stop"]),onDblclick:e.withModifiers(d=>ye(d,p.field),["stop"]),onClick:l[6]||(l[6]=e.withModifiers(()=>{},["stop"]))},null,40,Zl)],10,ql))),128)):e.createCommentVNode("",!0)],64))),128))])):e.createCommentVNode("",!0),Le.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("tr",en,[_.value!==null?(e.openBlock(),e.createElementBlock("th",tn,[_.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:nt.value,onChange:Kt,class:"te-checkbox"},null,40,ln)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),F.value.length&&!O.value?(e.openBlock(),e.createElementBlock("th",nn,"Acciones")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,n=>(e.openBlock(),e.createElementBlock("th",{key:n.field,"data-field":n.field,"data-help":n.helpKey||void 0,class:e.normalizeClass(["te-th",n.css,{"te-th-dragover-left":j.value===n.field&&z.value==="left","te-th-dragover-right":j.value===n.field&&z.value==="right","te-th-dragging":D.value===n.field,"te-th-sorted":x.value===n.field}]),draggable:xt.value,onDragstart:p=>fo(p,n.field),onDragenter:e.withModifiers(p=>uo(p,n.field),["prevent"]),onDragover:e.withModifiers(p=>po(p,n.field),["prevent"]),onDragleave:p=>mo(p,n.field),onDrop:e.withModifiers(p=>ho(p,n.field),["prevent"]),onDragend:Ae},[e.createElementVNode("div",an,[xt.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-th-grip",innerHTML:e.unref(M)("grip")},null,8,rn)):e.createCommentVNode("",!0),e.createElementVNode("span",{class:"te-th-label",onClick:p=>ct(n.field)},[e.createTextVNode(e.toDisplayString(n.headerName)+" ",1),n.sortable!==!1?(e.openBlock(),e.createElementBlock("span",cn,[e.createElementVNode("span",{innerHTML:e.unref(M)(st(n.field))},null,8,dn)])):e.createCommentVNode("",!0)],8,sn)]),e.createElementVNode("div",{class:e.normalizeClass(["te-resize-handle",{"te-resizing-active":A.value===n.field}]),draggable:"false",onPointerdown:e.withModifiers(p=>ie(p,n.field),["stop"]),onDblclick:e.withModifiers(p=>ye(p,n.field),["stop"]),onClick:l[7]||(l[7]=e.withModifiers(()=>{},["stop"]))},null,42,fn),j.value===n.field&&z.value==="left"?(e.openBlock(),e.createElementBlock("div",un)):e.createCommentVNode("",!0),j.value===n.field&&z.value==="right"?(e.openBlock(),e.createElementBlock("div",pn)):e.createCommentVNode("",!0)],42,on))),128)),l[21]||(l[21]=e.createElementVNode("th",{class:"te-th te-th-filler"},null,-1))])),Ft.value?(e.openBlock(),e.createElementBlock("tr",mn,[_.value!==null?(e.openBlock(),e.createElementBlock("td",hn)):e.createCommentVNode("",!0),F.value.length&&!O.value?(e.openBlock(),e.createElementBlock("td",kn)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,n=>{var p,d;return e.openBlock(),e.createElementBlock("td",{key:"f-"+n.field,class:"te-td"},[((p=n.filter)==null?void 0:p.type)==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("select",{key:0,"onUpdate:modelValue":y=>$.value[n.field]=y,onChange:Jt,class:"te-filter-input te-filter-select"},[l[22]||(l[22]=e.createElementVNode("option",{value:""},"Todos",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.filter.options,y=>(e.openBlock(),e.createElementBlock("option",{key:y.value,value:y.value},e.toDisplayString(y.label),9,yn))),128))],40,gn)),[[e.vModelSelect,$.value[n.field]]]):((d=n.filter)==null?void 0:d.type)==="text"||!eo.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":y=>$.value[n.field]=y,onInput:Jt,type:"text",class:"te-filter-input",placeholder:""},null,40,bn)),[[e.vModelText,$.value[n.field]]]):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"te-resize-handle",draggable:"false",onPointerdown:e.withModifiers(y=>ie(y,n.field),["stop"]),onDblclick:e.withModifiers(y=>ye(y,n.field),["stop"]),onClick:l[8]||(l[8]=e.withModifiers(()=>{},["stop"]))},null,40,_n)])}),128)),l[23]||(l[23]=e.createElementVNode("td",{class:"te-td te-td-filler"},null,-1))])):e.createCommentVNode("",!0)]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Y.value,(n,p)=>(e.openBlock(),e.createElementBlock("tr",{key:el(n,p),class:e.normalizeClass(["te-tr",n.__css_class,{"te-tr-selected":ge(n),"te-tr-highlight":C.value===n}]),style:e.normalizeStyle(n.__style),onClick:d=>Wt(n),onDblclick:d=>Gt(n)},[_.value!==null?(e.openBlock(),e.createElementBlock("td",{key:0,class:"te-td te-td-sel",onClick:l[9]||(l[9]=e.withModifiers(()=>{},["stop"]))},[_.value==="multiple"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"checkbox",checked:ge(n),onChange:d=>rt(n),class:"te-checkbox"},null,40,Cn)):(e.openBlock(),e.createElementBlock("input",{key:1,type:"radio",checked:C.value===n,onClick:d=>it(n),class:"te-checkbox"},null,8,En))])):e.createCommentVNode("",!0),F.value.length&&!O.value?(e.openBlock(),e.createElementBlock("td",Vn,[e.createElementVNode("div",Nn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,d=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.key},[d.isVisible()?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["te-btn",Re(d.severity),d.class]),disabled:d.isDisabled(),onClick:e.withModifiers(y=>d.onClick(n),["stop"]),title:d.getLabel(),"data-help":d.helpKey||void 0},[d.icon?(e.openBlock(),e.createElementBlock("span",{key:0,class:"te-btn-icon",innerHTML:e.unref(M)(d.icon)},null,8,wn)):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(d.getLabel()),1)],10,Sn)):e.createCommentVNode("",!0)],64))),128))])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,d=>(e.openBlock(),e.createElementBlock("td",{key:d.field,class:e.normalizeClass(["te-td",d.css,{"te-td-inline-edit":!!Pe(d)}]),style:e.normalizeStyle(e.unref(Ct)(n,d))},[ko(n,d)?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":l[10]||(l[10]=y=>le.value=y),type:"text",class:"te-editing-input",onBlur:y=>Ut(n,d),onKeydown:[e.withKeys(y=>Ut(n,d),["enter"]),e.withKeys(be,["escape"])],ref_for:!0,ref_key:"inlineEditRef",ref:we},null,40,Mn)),[[e.vModelText,le.value]]):(e.openBlock(),e.createElementBlock("div",Dn,[e.createElementVNode("span",{onDblclick:y=>qt(y,n,d),innerHTML:at(n,d)},null,40,Tn),Pe(d)?(e.openBlock(),e.createElementBlock("button",{key:0,class:"te-inline-edit-btn",onClick:e.withModifiers(y=>qt(y,n,d),["stop"]),title:"Editar inline"},[e.createElementVNode("span",{class:"te-btn-icon",innerHTML:e.unref(M)("pencil")},null,8,vn)],8,Ln)):e.createCommentVNode("",!0)])),e.createElementVNode("div",{class:"te-resize-handle",draggable:"false",onPointerdown:e.withModifiers(y=>ie(y,d.field),["stop"]),onDblclick:e.withModifiers(y=>ye(y,d.field),["stop"]),onClick:l[11]||(l[11]=e.withModifiers(()=>{},["stop"]))},null,40,Fn)],6))),128)),l[24]||(l[24]=e.createElementVNode("td",{class:"te-td te-td-filler"},null,-1))],46,Bn))),128)),Y.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("tr",xn,[e.createElementVNode("td",{colspan:lo.value,class:"te-td te-empty"},"Sin registros",8,zn)]))])],2)),I.value?(e.openBlock(),e.createElementBlock("div",{key:3,ref_key:"sentinelRef",ref:Xe,class:"te-sentinel"},[Ee.value?(e.openBlock(),e.createElementBlock("span",An)):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0)],4),e.withDirectives(e.createElementVNode("div",{class:"te-paginator","data-help":((b=s.config)==null?void 0:b.paginatorHelpKey)||void 0},[e.createElementVNode("span",Rn,"Mostrando "+e.toDisplayString(ao.value)+" a "+e.toDisplayString(io.value)+" de "+e.toDisplayString(lt.value),1),e.createElementVNode("div",On,[e.createElementVNode("button",{class:"te-page-btn",disabled:E.value<=1,onClick:l[12]||(l[12]=n=>ze(1))},"««",8,Hn),e.createElementVNode("button",{class:"te-page-btn",disabled:E.value<=1,onClick:l[13]||(l[13]=n=>ze(E.value-1))},"«",8,$n),e.createElementVNode("span",In,e.toDisplayString(E.value)+" / "+e.toDisplayString(ke.value),1),e.createElementVNode("button",{class:"te-page-btn",disabled:E.value>=ke.value,onClick:l[14]||(l[14]=n=>ze(E.value+1))},"»",8,jn),e.createElementVNode("button",{class:"te-page-btn",disabled:E.value>=ke.value,onClick:l[15]||(l[15]=n=>ze(ke.value))},"»»",8,Kn)]),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":l[16]||(l[16]=n=>L.value=n),class:"te-select",onChange:co},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Lt.value,n=>(e.openBlock(),e.createElementBlock("option",{key:n,value:n},e.toDisplayString(n),9,Wn))),128))],544),[[e.vModelSelect,L.value]])],8,Pn),[[e.vShow,!I.value&&vt.value]])])}}};function Ke(s){if(!s||!Array.isArray(s))return{};const i={};for(const u of s)u.isJson&&(i[u.field]=u);return i}function Vt(s,i){if(!s||!i)return s;for(const[u]of Object.entries(i)){const r=s[u];if(typeof r=="string")try{s[u]=JSON.parse(r)}catch{s[u]=r}}return s}function Nt(s,i,u){if(!s||!Array.isArray(s)||!i||!u)return s;for(const[r]of Object.entries(i)){const h=u[r];if(h&&typeof h=="object"&&!Array.isArray(h))for(const[B,oe]of Object.entries(h))typeof oe=="object"&&oe!==null&&!Array.isArray(oe)||s.push({field:`${r}.${B}`,headerName:B,sortable:!1,filterable:!1})}return s}function We(s,i){if(!s||!i)return s;for(const u of i)u.formatter&&typeof u.formatter=="function"&&(s[u.field]=u.formatter(s[u.field],s));return s}const Jn=We;function St(s){return!s||!Array.isArray(s)?[]:s.map(i=>({field:i.field,headerName:i.headerName||i.field,sortable:i.sortable!==!1,filterable:i.filterable!==!1,css:i.css||"",form_type:i.form_type||null,type:i.type||"text",editable:i.editable||!1}))}function qn(s,i){if(!i||!i.length)return s;const u=[];for(const r of i){const h=s.find(B=>B.field===r);h&&u.push(h)}for(const r of s)u.some(h=>h.field===r.field)||u.push(r);return u}function wt(s){return!s||!Array.isArray(s)?s:s.map(i=>({...i,headerName:i.headerName||i.field}))}function Un(s=null){return{processRows(i,u){if(!(i!=null&&i.length))return i;const r=Ke(u);for(let h=0;h<i.length;h++){let B=Vt(i[h],r);B=We(B,u),i[h]=Ie(B,s)}return i},processFields(i,u){if(!i||!Array.isArray(i))return i;let r=i;return u&&(r=Nt([...r],Ke(r),u)),wt(r)},processColumns(i){return St(i)}}}g.BtnConfig=W,g.TableEditor=Et,g.applyFieldDefCss=Bt,g.applyRowStyling=Ie,g.availableIcons=al,g.cellStyle=Ct,g.createLocalStoragePrefsAdapter=gt,g.default=Et,g.getCamposJSONyFieldDef=Nt,g.getCamposJson=Ke,g.getFieldDefFFormated=wt,g.getGlobalPreferencesAdapter=yt,g.getProcessFieldDef=St,g.greenbornDataPipeline=Un,g.iconSvg=M,g.invertHexColor=_t,g.mapFilaJSONtabla=Vt,g.reOrder=qn,g.rowFormatter=We,g.row_formatter=Jn,g.setGlobalPreferencesAdapter=nl,g.toBtnConfig=$e,g.unwrapCell=je,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
5
5
|
//# sourceMappingURL=vue-table-editor.umd.cjs.map
|