UNPKG

presentation-table

Version:

The Augmented.js Next - Presentation Table View Module.

2 lines 23.1 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("presentation-models"),require("presentation-dom"),require("next-core-utilities"),require("presentation-decorator")):"function"==typeof define&&define.amd?define("presentation-table",["presentation-models","presentation-dom","next-core-utilities","presentation-decorator"],t):"object"==typeof exports?exports["presentation-table"]=t(require("presentation-models"),require("presentation-dom"),require("next-core-utilities"),require("presentation-decorator")):e["presentation-table"]=t(e["presentation-models"],e["presentation-dom"],e["next-core-utilities"],e["presentation-decorator"])}(this,(function(e,t,i,s){return function(e){var t={};function i(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(s,n,function(t){return e[t]}.bind(null,n));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/dist/",i(i.s=4)}([function(t,i){t.exports=e},function(e,i){e.exports=t},function(e,t){e.exports=i},function(e,t){e.exports=s},function(e,t,i){"use strict";i.r(t),i.d(t,"AutomaticTable",(function(){return v})),i.d(t,"BigDataTable",(function(){return C})),i.d(t,"EditableBigDataTable",(function(){return S})),i.d(t,"EditableLocalStorageTable",(function(){return A})),i.d(t,"EditableTable",(function(){return E})),i.d(t,"LocalStorageTable",(function(){return P})),i.d(t,"Spreadsheet",(function(){return x}));var s=i(2),n=i(3),l=i(1),r=i(0);const o="data-name",a="data-type",c="data-description",h="data-index",d="data-label",u="sorted",m=(e,t,i,s,n,l,r,m,p,b,g,f,y,v)=>{const C=document.createElement("table"),S=document.createElement("thead"),A=document.createElement("tbody");let E,P;C.setAttribute("data-"+t,t),C.setAttribute(o,t),C.setAttribute(c,i),i&&(E=document.createElement("caption"),t&&E.setAttribute("title",t),P=document.createTextNode(i),E.appendChild(P),C.appendChild(E)),((e,t,i,s,n,l,r)=>{if(t&&e){const h=document.createElement("tr");let d,m,p,b;for(p in l&&(d=document.createElement("th"),d.setAttribute(o,"select"),r?d.innerHTML='<i class="material-icons">check_box_outline_blank</i>':(m=document.createTextNode("❏"),d.appendChild(m)),h.appendChild(d)),i&&(d=document.createElement("th"),d.setAttribute(o,"lineNumber"),m=document.createTextNode("#"),d.appendChild(m),h.appendChild(d)),t){let e=!0;null!==n&&(e=-1!==n.indexOf(p)),e&&t.hasOwnProperty(p)&&(b=t[p],d=document.createElement("th"),d.setAttribute(o,p),d.setAttribute(c,b.description),d.setAttribute(a,b.type),s===p&&d.classList.add(u),m=document.createTextNode(b.description),d.appendChild(m),h.appendChild(d))}e.appendChild(h)}})(S,s,l,r,p,b,v),C.appendChild(S),C.appendChild(A),n&&(m?((e,t,i,s,n,l,r,c)=>{const m=t.length,p=s;let b,g,f,y,v,C,S,A,E,P;for(b=0;b<m;b++){for(f in g=t[b],A=document.createElement("tr"),r&&(C=document.createElement("td"),C.setAttribute(o,"select"),S=document.createElement("input"),S.type="checkbox",S.name=String(b),S.setAttribute("value",String(b)),S.setAttribute("data-"+c,"row-"+b),S.setAttribute(h,b),C.appendChild(S),C.classList.add("label","select"),A.appendChild(C)),p&&(C=document.createElement("td"),S=document.createTextNode(String(b+1)),C.appendChild(S),C.classList.add("label","number"),A.appendChild(C)),i){let e=!0;if(null!==l&&(e=-1!==l.indexOf(f)),e&&g.hasOwnProperty(f)){if(P=i[f]?i[f]:{},y=g[f],v=typeof y,C=document.createElement("td"),C.classList.add(v),n===f&&C.classList.add(u),C.setAttribute(a,v),C.setAttribute(d,f),"object"===v)if(Array.isArray(y)){let e,t,i=0,s=y.length;for(E=document.createElement("select"),i=0;i<s;i++)e=document.createElement("option"),e.setAttribute("value",y[i]),t=document.createTextNode(y[i]),e.appendChild(t),E.appendChild(e)}else E=document.createElement("textarea"),E.setAttribute("value",JSON.stringify(y));else if("boolean"===v)E=document.createElement("input"),E.setAttribute("type","checkbox"),!0===y&&E.setAttribute("checked","checked"),E.setAttribute("value",y);else if("number"===v||"integer"===v)E=document.createElement("input"),E.setAttribute("type","number"),E.setAttribute("value",y),"integer"===v&&E.setAttribute("step","1.0");else if("string"===v&&P.enum){E=document.createElement("select");let e,t,i=0,s=P.enum.length;for(i=0;i<s;i++)e=document.createElement("option"),e.setAttribute("value",P.enum[i]),t=document.createTextNode(P.enum[i]),y===P.enum[i]&&e.setAttribute("selected","selected"),e.appendChild(t),E.appendChild(e)}else"string"===v&&"email"===P.format?(E=document.createElement("input"),E.setAttribute("type","email"),E.setAttribute("value",y)):"string"===v&&"uri"===P.format?(E=document.createElement("input"),E.setAttribute("type","url"),E.setAttribute("value",y)):"string"===v&&"date-time"===P.format?(E=document.createElement("input"),E.setAttribute("type","datetime"),E.setAttribute("value",y)):(E=document.createElement("input"),E.setAttribute("type","text"),E.setAttribute("value",y));"string"===v&&P.pattern&&E.setAttribute("pattern",P.pattern),null!==P.minimum&&void 0!==P.minimum&&E.setAttribute("min",P.minimum),null!==P.maximum&&void 0!==P.maximum&&E.setAttribute("max",P.maximum),"string"===v&&null!==P.minlength&&void 0!==P.minlength&&E.setAttribute("minlength",P.minlength),"string"===v&&null!==P.maxlength&&void 0!==P.maxlength&&E.setAttribute("maxlength",P.maxlength),E.setAttribute(o,f),E.setAttribute(h,b),E.setAttribute("data-"+c,c),E.setAttribute("name",f),C.appendChild(E),A.appendChild(C)}}e.appendChild(A)}})(A,n,s,l,r,p,b,t):((e,t,i,s,n,l,r,c,m,p,b)=>{const g=t.length;let f,y,v,C,S,A,E,P;for(f=0;f<g;f++){for(v in y=t[f],P=document.createElement("tr"),r&&(A=document.createElement("td"),A.setAttribute(o,"select"),E=document.createElement("input"),E.type="checkbox",E.name=String(f),E.setAttribute("value",String(f)),E.setAttribute("data-"+c,"row-"+f),E.setAttribute(h,f),A.appendChild(E),A.classList.add("label","select"),P.appendChild(A)),s&&(A=document.createElement("td"),E=document.createTextNode(String(f+1)),A.appendChild(E),A.classList.add("label","number"),P.appendChild(A)),i){let e=!0;if(null!==l&&(e=-1!==l.indexOf(v)),e&&y.hasOwnProperty(v)){if(C=y[v],S=typeof C,A=document.createElement("td"),E=document.createTextNode(C),m&&p&&b&&(p.column===v||p.wholeRow)){const e=document.createElement("a");e.href=b(y),e.appendChild(E),A.appendChild(e)}else A.appendChild(E);A.classList.add(S),n===v&&A.classList.add(u),A.setAttribute(a,S),A.setAttribute(d,v),P.appendChild(A)}}e.appendChild(P)}})(A,n,s,l,r,p,b,t,g,f,y)),e.appendChild(C)};var p=e=>{let t="";if(e&&e.length>0){t+='<ul class="errors">';const i=e.length;let s=0,n=0;for(s=0;s<i;s++){const i=e[s].errors.length;for(n=0;n<i;n++)t=t+"<li>"+e[s].errors[n]+"</li>"}t+="</ul>"}return t};const b=(e,t,i,s,n)=>{let l,r,o,a,c="";if(n||(n=","),i){let e;for(e in i)i.hasOwnProperty(e)&&(c=c+e+n);c=c.slice(0,-1),c+="\n"}const h=s.length;for(l=0;l<h;l++){for(o in r=s[l],r)r.hasOwnProperty(o)&&(a=r[o],c=c+a+n);c=c.slice(0,-1),c+="\n"}return c},g=(e,t,i,s,n,l,r,h)=>{let d=`<table ${o}="${e}" ${c}="${t}">`;return e&&(d+="<caption",t&&(d+=` title="${t}"`),d+=`>${e}</caption>`),d+="<thead>",d+=((e,t,i,s)=>{let n="";if(e){let s,l;for(s in n+="<tr>",t&&(n+=`<th ${o}="lineNumber">#</th>`),e)e.hasOwnProperty(s)&&(l=e[s],n+=`<th ${o}="${s}" ${c}="${l.description}" ${a}="${l.type}"`,i===s&&(n=n+' class="'+u+'"'),n=n+">"+l.description+"</th>");n+="</tr>"}return n})(i,n,l),d+="</thead><tbody>",s&&(d+=r?(void 0)(s,i,n,l,h):((e,t,i,s,n)=>{let l,r,o,c,h,d="",m=e.length;for(l=0;l<m;l++){for(o in r=e[l],d+="<tr>",i&&(d=d+'<td class="label number">'+(l+1)+"</td>"),r)r.hasOwnProperty(o)&&(c=r[o],h=typeof c,d=d+"<td "+a+'="'+h+'" class="'+h,s===o&&(d=d+" "+u),d=d+'">'+c+"</td>");d+="</tr>"}return d})(s,0,n,l)),d+="</tbody></table>",d};var f=async(e,t,i,s,n)=>{let l="";return l="csv"===e?await b(0,0,s,n):"tsv"===e?await((e,t,i,s)=>b(0,0,i,s,"\t"))(0,0,s,n):"json"===e?n:await g(t,i,s,n,!1,null),l};class y extends n.DecoratorView{constructor(e={}){super(e);const t=this.style?this.style+" ":"";if(e.theme?this.theme=`${t}${e.theme}`:this.theme=t+"material",e.linkable?this.linkable=e.linkable:this.linkable=!1,e.links?this.links=e.links:this.links={wholeRow:!0,column:"",link:"rowLink"},e.selectable?this.selectable=e.selectable:this.selectable=!1,e.sortable?this.sortable=e.sortable:this.sortable=!1,e.sortStyle?this.sortStyle=e.sortStyle:this.sortStyle="client",e.sortKey?this.sortKey=e.sortKey:this.sortKey=null,e.display?this.display=e.display:this.display=null,e.pagination?this.renderPaginationControl=e.pagination:this.renderPaginationControl=!1,e.paginationAPI?this.paginationAPI=e.paginationAPI:this.paginationAPI=null,e.description?this.description=e.description:this.description="",e.localStorage?this.localStorage=e.localStorage:this.localStorage=!1,e.localStorageKey?this.localStorageKey=e.localStorageKey:this.localStorageKey="augmented.localstorage.autotable.key",e.editable?this.editable=e.editable:this.editable=!1,e.crossOrigin?this.crossOrigin=e.crossOrigin:this.crossOrigin=!1,e.lineNumbers?this.lineNumbers=e.lineNumbers:this.lineNumbers=!1,e.uri?this.uri=e.uri:this.uri=!1,e.data?this.data=e.data:this.data=[],e.messagePosition?this.messagePosition=e.messagePosition:this.messagePosition="bottom",e.collection&&(this.collection=e.collection),this._columns={},this.isInitalized=!1,this.pageControlBound=!1,this.model||(this.model=new r.Model),this.collection&&this.collection.reset(),!this.collection&&this.paginationAPI?(this.collection=r.PaginationFactory.getPaginatedCollection(this.paginationAPI),this.paginationAPI=this.collection.paginationAPI,this.localStorage=!1):!this.collection&&this.localStorage?this.collection=new r.LocalStorageCollection:this.collection||(this.collection=new r.Collection),e.schema)if(Object(s.isObject)(e.schema))this.schema=e.schema;else{let t=null;try{t=JSON.parse(e.schema),t&&Object(s.isObject)(t)&&(this.schema=t)}catch(e){}this.schema||(this.retrieveSchema(e.schema),this.isInitalized=!1)}else this.schema=null;this.uri&&this.collection&&(this.collection.uri=e.uri),this.data&&Array.isArray(this.data)&&this.populate(this.data),e.localStorageKey&&!e.uri&&(this.localStorageKey=e.localStorageKey,this.uri=null),this.collection&&(this.collection.crossOrigin=this.crossOrigin),this.schema?(this.name&&""!==this.name||!this.schema.title||(this.name=this.schema.title,this.name.split(" ").join("")),this.description&&""!==this.description||!this.schema.description||(this.description=this.schema.description),this.isInitalized||(this._columns=this.schema.properties,this.collection.schema=this.schema,this.isInitalized=!0)):this.isInitalized=!1,e.fetchOnStart?this._fetchOnStart=!0:this._fetchOnStart=!1}setTheme(e){const t=l.Dom.selector(this.el);if(t){let i=t.querySelector("table");i&&i.setAttribute("class",e)}this.theme=e}rowLink(e){return""}sortBy(e){e&&(this.editable||!this.editable&&this.sortKey!==e)&&(this.sortKey=e,this.collection.sortByKey(e),this.refresh())}currentPage(){return this.collection.currentPage}totalPages(){return this.collection.totalPages}nextPage(){this.collection.nextPage(),this.refresh()}previousPage(){this.collection.previousPage(),this.refresh()}goToPage(e){this.collection.goToPage(e),this.refresh()}firstPage(){this.collection.firstPage(),this.refresh()}lastPage(){this.collection.lastPage(),this.refresh()}editCell(e,t,i){if(e&&t){let s=this.collection.at(e),n=this.columns[t];s&&n&&s.set(n,i)}}copyCell(e,t,i,s){if(e&&t&&i&&s){let i=this.collection.at(e),s=this.columns[t],n=this.collection.at(row);i&&s&&n&&n.set(s,value1)}}clearCell(e,t){this.editCell(e,t,null)}render(){if(this.model||(this.model=new r.Model),!this.isInitalized)return this;if(this.sortable&&this._unbindSortableColumnEvents(),this.editable&&this._unbindCellChangeEvents(),this.template="notused",this.showProgressBar(!0),this.el){const e="string"==typeof this.el?document.querySelector(this.el):this.el;let t=document.createElement(e.tagName);if(t){let i=document.createElement("progress"),s=document.createTextNode("Please wait.");i.appendChild(s),t.appendChild(i);const n=this._style.includes("material");"top"===this.messagePosition&&(i=document.createElement("p"),i.classList.add("message"),t.appendChild(i)),m(t,this.name,this.description,this._columns,this.collection.toJSON(),this.lineNumbers,this.sortKey,this.editable,this.display,this.selectable,this.linkable,this.links,this[this.links.link],n),this.renderPaginationControl&&((e,t,i)=>{let s,n,l;s=document.createElement("div"),s.classList.add("paginationControl"),n=document.createElement("span"),n.classList.add("first"),l=document.createTextNode("<< First"),n.appendChild(l),s.appendChild(n),n=document.createElement("span"),n.classList.add("previous"),l=document.createTextNode("< Previous"),n.appendChild(l),s.appendChild(n),n=document.createElement("span"),n.classList.add("current"),l=document.createTextNode(`${t} of ${i}`),n.appendChild(l),s.appendChild(n),n=document.createElement("span"),n.classList.add("next"),l=document.createTextNode("Next >"),n.appendChild(l),s.appendChild(n),n=document.createElement("span"),n.classList.add("last"),l=document.createTextNode("Last >>"),n.appendChild(l),s.appendChild(n),e.appendChild(s)})(t,this.currentPage(),this.totalPages()),"bottom"===this.messagePosition&&(i=document.createElement("p"),i.classList.add("message"),t.appendChild(i));const r=l.Diff.createDOMMap(t,!1),o=l.Diff.createDOMMap(e,!1);l.Diff.diff(r,o,e)}}else console.warn(`AUGMENTED: AutoTable ${this.name} no element anchor, not rendering.`);return this.renderPaginationControl&&this._bindPaginationControlEvents(),this.delegateEvents(),this.sortable&&this._bindSortableColumnEvents(),this.editable&&this._bindCellChangeEvents(),this.showProgressBar(!1),this.setTheme(this.theme),this._fetchOnStart&&(this.fetch(),this._fetchOnStart=!1),this}async retrieveSchema(e){try{const t=await fetch(e),i={schema:await t.json()};return this.initialize(i)}catch(e){return this.showMessage(`${this.name} Failed to fetch schema!! ${e}`),null}}fetch(){this.showProgressBar(!0);const e=this;this.uri&&(this.collection.uri=this.uri),this.collection.fetch({reset:!0,success(){e.showProgressBar(!1),e.sortKey=null,e.populate(e.collection.toJSON()),e.refresh()},error(){e.showProgressBar(!1),e.showMessage("AutomaticTable fetch failed!")}})}save(e){if(this.editable||e){this.showProgressBar(!0);const e=this,t=function(){return e.showProgressBar(!1),!0},i=function(){return e.showProgressBar(!1),e.showMessage("AutomaticTable save failed!"),!1};this.collection.save({reset:!0,success(){t()},error(){i()}})}return!1}populate(e){e&&Array.isArray(e)&&(this.sortKey=null,this.data=e,this.collection.reset(this.data))}clear(){this.sortKey=null,this.data=[],this.collection.reset(null)}refresh(){return this.render()}saveCell(e){const t=e.target,i=parseInt(t.getAttribute(h)),s=this.collection.at(i);let n=t.value;"number"===t.getAttribute("type")&&(n=parseInt(t.value)),s?s.set(t.getAttribute(o),n):console.warn(`Could not find the row ${i} in table "${this.name}"`,t,t.getAttribute(h))}compileTemplate(){return""}setURI(e){e&&(this.uri=e,this.collection.uri=e)}setSchema(e){this.schema=e,this._columns=e.properties,this.collection.reset(),this.collection.schema=e,this.uri&&(this.collection.uri=this.uri)}showProgressBar(e){if(this.el){const t=l.Dom.selector(this.el);if(t){let i=t.querySelector("progress");i&&(i.style.display=e?"block":"none",i.style.visibility=e?"visible":"hidden")}}}showMessage(e){if(this.el&&e){let t=l.Dom.selector(this.el).querySelector("p[class=message]");t&&(t.innerHTML=e)}}validate(){let e=this.collection?this.collection.validate():null;return!this.collection.isValid()&&e&&e.messages?this.showMessage(p(e.messages)):this.showMessage(""),e}isValid(){return!this.collection||this.collection.isValid()}remove(){if(this.undelegateEvents(),this.off(),this.stopListening(),this.el){const e=l.Dom.selector(this.el);e&&(e.innerHTML="")}return l.Dom.empty(this.el),this}getSelected(e){const t=Object.keys(this.model._attributes),i=t.length,s=[];let n=0;for(n=0;n<i;n++)if(t[n].includes("row-")&&!0===this.model._attributes[t[n]]){const i=Number(t[n].substring(4)),l=this.collection.at(i);l&&void 0!==l&&(e?s.push(l.toJSON()):s.push(l))}return s}getSelectedAsJSON(){return this.getSelected(!0)}getSelectedIndex(){const e=Object.keys(this.model._attributes),t=e.length,i=[];let s=0;for(s=0;s<t;s++)e[s].includes("row-")&&!0===this.model._attributes[e[s]]&&i.push(Number(e[s].substring(4)));return i}removeRows(e){const t=e.length;let i=0;for(i=0;i<t;i++){const t=e[i];t&&!t.uri&&this.uri&&(t.uri=this.uri+"/"+t.id);this.collection.removeModels(t)}return this.refresh(),t}removeSelectedRows(){return this.removeRows(this.getSelected())}async addRow(e){return await this.collection.addModels(e),await this.refresh()}async exportTo(e){return await f(e,this.name,this.description,this._columns,await this.collection.toJSON())}_bindCellChangeEvents(){let e="string"==typeof this.el?this.el:this.el.localName,t=[].slice.call(document.querySelectorAll(e+" table tr td input")),i=0,s=t.length;for(i=0;i<s;i++)t[i].addEventListener("change",this.saveCell.bind(this),!1);for(t=[].slice.call(document.querySelectorAll(e+" table tr td select")),i=0,s=t.length,i=0;i<s;i++)t[i].addEventListener("change",this.saveCell.bind(this),!1)}_unbindCellChangeEvents(){let e="string"==typeof this.el?this.el:this.el.localName,t=[].slice.call(document.querySelectorAll(e+" table tr td input")),i=0,s=t.length;for(i=0;i<s;i++)t[i].removeEventListener("change",this.saveCell,!1);for(t=[].slice.call(document.querySelectorAll(e+" table tr td select")),i=0,s=t.length,i=0;i<s;i++)t[i].removeEventListener("change",this.saveCell,!1)}_unbindPaginationControlEvents(){if(this.pageControlBound){let e="string"==typeof this.el?this.el:this.el.localName,t=document.querySelector(e+" div.paginationControl span.first"),i=document.querySelector(e+" div.paginationControl span.previous"),s=document.querySelector(e+" div.paginationControl span.next"),n=document.querySelector(e+" div.paginationControl span.last");t&&t.removeEventListener("click",this.firstPage,!1),i&&i.removeEventListener("click",this.previousPage,!1),s&&s.removeEventListener("click",this.nextPage,!1),n&&n.removeEventListener("click",this.lastPage,!1),this.pageControlBound=!1}}_bindPaginationControlEvents(){if(!this.pageControlBound){let e="string"==typeof this.el?this.el:this.el.localName,t=document.querySelector(e+" div.paginationControl span.first"),i=document.querySelector(e+" div.paginationControl span.previous"),s=document.querySelector(e+" div.paginationControl span.next"),n=document.querySelector(e+" div.paginationControl span.last");t&&t.addEventListener("click",this.firstPage.bind(this),!1),i&&i.addEventListener("click",this.previousPage.bind(this),!1),s&&s.addEventListener("click",this.nextPage.bind(this),!1),n&&n.addEventListener("click",this.lastPage.bind(this),!1),this.pageControlBound=!0}}_deriveEventTarget(e){let t=null;return e&&(t=e.target.getAttribute(o)),t}_sortByHeaderEvent(e){let t=this._deriveEventTarget(e);this.sortBy(t)}_unbindSortableColumnEvents(){if(this.el&&this.sortable){let e;e="string"==typeof this.el?document.querySelectorAll(this.el+" table tr th"):document.querySelectorAll(this.el.localName+" table tr th");let t=0,i=e.length;for(t=0;t<i;t++)e[t].removeEventListener("click",this._sortByHeaderEvent,!1)}}_bindSortableColumnEvents(){if(this.el&&this.sortable){let e;e="string"==typeof this.el?document.querySelectorAll(this.el+" table tr th"):document.querySelectorAll(this.el.localName+" table tr th");let t=0,i=e.length;for(t=0;t<i;t++)"lineNumber"===e[t].getAttribute(o)||e[t].addEventListener("click",this._sortByHeaderEvent.bind(this),!1)}}}var v=y;var C=class extends v{constructor(e){e||(e={}),e.lineNumbers=!0,e.sortable=!0,super(e),this.renderPaginationControl=!0}};var S=class extends v{constructor(e){e||(e={}),e.lineNumbers=!0,e.sortable=!0,e.editable=!0,super(e),this.renderPaginationControl=!0}};var A=class extends v{constructor(e){e||(e={}),e.lineNumbers=!0,e.sortable=!0,e.editable=!0,e.localStorage=!0,super(e),this.renderPaginationControl=!0}};var E=class extends v{constructor(e){e||(e={}),e.lineNumbers=!0,e.editable=!0,super(e)}};var P=class extends v{constructor(e){e||(e={}),e.lineNumbers=!0,e.sortable=!0,e.editable=!1,e.localStorage=!0,super(e),this.renderPaginationControl=!0}};var x=class extends v{constructor(e){if(super(e),this.lineNumbers=!0,this.sortable=!0,this.editable=!0,e&&e.pagination?this.renderPaginationControl=e.pagination:this.renderPaginationControl=!1,e&&e.rows?this.rows=e.rows:this.rows=10,e&&e.columns?this.columns=e.columns:this.rows=5,this.collection?this.collection.reset():!this.collection&&this.localStorage?this.collection=new r.LocalStorageCollection:this.collection||(this.collection=new r.Collection),e){if(e.schema)if(Object(s.isObject)(e.schema))this.schema=e.schema;else{let t=null;try{t=JSON.parse(e.schema),t&&Object(s.isObject)(t)&&(this.schema=t)}catch(e){}this.schema||(this.retrieveSchema(e.schema),this.isInitalized=!1)}e.el&&(this.el=e.el),e.uri&&(this.uri=e.uri,this.collection.url=e.uri),e.data&&Array.isArray(e.data)&&this.populate(e.data),e.sortable&&(this.sortable=e.sortable),e.lineNumbers&&(this.lineNumbers=e.lineNumbers),e.localStorageKey&&!e.uri&&(this.localStorageKey=e.localStorageKey,this.uri=null)}if(this.collection&&this.uri&&(this.collection.url=this.uri),this.collection&&(this.collection.crossOrigin=this.crossOrigin),this.schema)this.name&&""!==this.name||!this.schema.title||(this.name=this.schema.title),this.description&&""!==this.description||!this.schema.description||(this.description=this.schema.description),this.isInitalized||(this._columns=this.schema.properties,this.collection.schema=this.schema);else{this.schema={$schema:"http://json-schema.org/draft-04/schema#",title:"untitled",type:"object",description:"",properties:{}};let e=0;for(e=0;e<this.columns;e++)this.schema.properties[String.fromCharCode(65+e)]={description:"",type:"string"};this._columns=this.schema.properties,this.collection.schema=this.schema}this._generate(),this.collection.set(this.data),this.isInitalized=!0}_generate(){if(this.schema&&this.schema.properties){let e=0,t=0,i=Object.keys(this.schema.properties),s=i.length,n={};for(this.data=[],t=0;t<this.rows;t++){for(n={},e=0;e<s;e++)n[i[e]]="";this.data.push(n)}}}}}])})); //# sourceMappingURL=presentation-table.js.map