@momentum-ui/web-components 3.2.15 → 3.2.16

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.
@@ -1,4 +1,4 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("@popperjs/core/lib/modifiers/arrow"),require("@popperjs/core/lib/modifiers/flip"),require("@popperjs/core/lib/modifiers/offset"),require("@popperjs/core/lib/modifiers/preventOverflow"),require("@popperjs/core/lib/popper-lite"),require("lit/directives/unsafe-html.js"),require("papaparse"));else if("function"==typeof define&&define.amd)define(["lit","lit/decorators.js","lit/directives/class-map.js","lit/directives/style-map.js","lit/directives/if-defined.js","@momentum-ui/icons/data/momentumUiIconsNames.json","@momentum-ui/utils/lib/getColorValue","mobx","@popperjs/core/lib/modifiers/arrow","@popperjs/core/lib/modifiers/flip","@popperjs/core/lib/modifiers/offset","@popperjs/core/lib/modifiers/preventOverflow","@popperjs/core/lib/popper-lite","lit/directives/unsafe-html.js","papaparse"],t);else{var i="object"==typeof exports?t(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("@popperjs/core/lib/modifiers/arrow"),require("@popperjs/core/lib/modifiers/flip"),require("@popperjs/core/lib/modifiers/offset"),require("@popperjs/core/lib/modifiers/preventOverflow"),require("@popperjs/core/lib/popper-lite"),require("lit/directives/unsafe-html.js"),require("papaparse")):t(e.lit,e["lit/decorators.js"],e["lit/directives/class-map.js"],e["lit/directives/style-map.js"],e["lit/directives/if-defined.js"],e["@momentum-ui/icons/data/momentumUiIconsNames.json"],e["@momentum-ui/utils/lib/getColorValue"],e.mobx,e["@popperjs/core/lib/modifiers/arrow"],e["@popperjs/core/lib/modifiers/flip"],e["@popperjs/core/lib/modifiers/offset"],e["@popperjs/core/lib/modifiers/preventOverflow"],e["@popperjs/core/lib/popper-lite"],e["lit/directives/unsafe-html.js"],e.papaparse);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(self,(e,t,i,o,s,r,l,n,a,d,p,c,h,m,u)=>(()=>{"use strict";var f,g={7936(e,t,i){i.r(t),i.d(t,{TableAdvanced:()=>b}),i(5983),i(1821),i(708);var o=i(9609),s=i(9938),r=i(4084),l=i(7161),n=i(429),a=i(5125),d=i(291),p=i(6968),c=i(8187),h=i.n(c),m=i(4841),u=i(597),f=i(9125),g=function(e,t,i,o){var s,r=arguments.length,l=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,o);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(l=(r<3?s(l):r>3?s(t,i,l):s(t,i))||l);return r>3&&l&&Object.defineProperty(t,i,l),l};const v=document.createElement("img");var b;v.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(e){let t=class extends((0,s.d)(l.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=e=>e.preventDefault(),this.eX=0,this.onResize=(e,t)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const o=e.target;null===(i=e.dataTransfer)||void 0===i||i.setDragImage(v,0,0);const s=this.COLS.map(e=>this.shadowRoot.querySelector(`th.col-index-${e.index}`));this.COLS.forEach((e,t)=>e.width=s[t].offsetWidth+"px"),this.updCols();const r=e.x;this.eX=e.x;let l=-1,n=-1,a=-1;const d=this.COLS[t.index-1],p=s[t.index],c=s[t.index-1],h=p.offsetWidth,m=c.offsetWidth,u=()=>{const e=this.eX;if(l!=e&&0!=e){l=e;const i=l-r;n=h-i,a=m+i,t.width=n+"px",d.width=a+"px",this.updCols()}},f=e=>this.eX=e.x,g=()=>{this.isResizing=!1,o.removeEventListener("drag",u),o.removeEventListener("dragend",g),document.removeEventListener("dragover",f)};o.addEventListener("drag",u),o.addEventListener("dragend",g),document.addEventListener("dragover",f)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}update(e){super.update(e),e.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(e){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(e){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var e;let t=0;const i=(e,i)=>{var o,s,r,l;const n=e.filters||(null===(s=null===(o=this.tableConfig.default)||void 0===o?void 0:o.col)||void 0===s?void 0:s.filters),a=n?"forString"==n?f.d.optionsString:"forNumber"==n?f.d.optionsNumber:n.length?n:null:null;this.COLS.push({options:Object.assign({},e),index:t++,group:i,sort:"default",sorter:e.sorter||(null===(l=null===(r=this.tableConfig.default)||void 0===r?void 0:r.col)||void 0===l?void 0:l.sorter),isCollapsable:this.tableConfig.cols.collapse==e.id,filter:a?{list:a,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(e=>{"children"in e?e.children.forEach(t=>i(t,{name:e.groupName,length:e.children.length})):i(e)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)}populateData(){const e=this.COLS.length;if("csv"in this.tableData){const e=h().parse(this.tableData.csv,{skipEmptyLines:!0,transform:e=>e.trim()});if(e.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(e.errors,null,2));{const t=e.data;this.ROWS=t.map(e=>e.map(e=>({text:e})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(e=>e.map(e=>({text:e})));else{for(;this.tableData.list.length>e;)this.ROWS.push(this.tableData.list.splice(0,e).map(e=>({text:e})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(e=>({text:e})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const e=this.COLS.length;this.ROWS.reduce((e,t)=>e+t.length,0)%e==0?this.ROWS.forEach((t,i)=>{const o=t.length;o!=e&&(this.error=`DATA ERROR: Total number of cols (=${e}) and data[${i}] length (=${o}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const e=this.tableConfig.cellTemplates,t=Object.keys(e||{});e&&t.length&&this.ROWS.forEach((t,i)=>{t.forEach((t,o)=>{for(const s in e){const r=t.text.indexOf(s);if(-1!=r){const l=e[s],n=this.querySelector(`#${l.templateName}`);if(null==n){console.warn(`cellTemplates["${s}"]: Missing '${l.templateName}' template.`);continue}let a=t.text.replace(s,"");l.contentCb&&(a=l.contentCb({col:o,row:i,content:a,insertIndex:r})),this.ROWS[i][o]={text:a,template:{template:n,templateCb:l.templateCb,insertIndex:"replace"==l.contentUse?-1:r}};break}}})})}setDefaultFilterAndSort(){var e,t;const i=null===(e=this.tableConfig.default)||void 0===e?void 0:e.sort;if(i){const e=this.COLS.find(e=>e.options.id==i.colId);e?this.sort(e,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const o=null===(t=this.tableConfig.default)||void 0===t?void 0:t.filter;if(o){const e=this.COLS.find(e=>e.options.id==o.colId);e?e.filter?(e.filter.selectedIndex=o.selectedIndex,e.filter.input=o.input,this.updCols(),this.filter(e)):console.warn(`Cant find filters on ${o.colId} col`):console.warn(`Cant find ${o.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const e=this.COLS[this.dragCol],t=this.COLS[this.dropCol],i=e.group,o=t.group,s=e.index,r=t.index;e.group=o,t.group=i,e.index=r,t.index=s,this.COLS[this.dragCol]=t,this.COLS[this.dropCol]=e,this.ROWS.forEach(e=>{const t=e[this.dragCol],i=e[this.dropCol];e[this.dragCol]=i,e[this.dropCol]=t}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(e,t){e.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==e.options.id?i.sort=t||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:e.sort}))}filter(e){if(!e.filter)return;this.clearSelection(),this.drops=[];const t=e.filter.input.trim(),i=e.filter.list[e.filter.selectedIndex];e.filter.active=!!t,this.requestUpdate(),t?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:t}):this["md-table-advanced-change"].emit({type:"filter-off",filter:e.filter.list[e.filter.selectedIndex]})}selectRow(e){var t;const i=e.row.idx,o=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)?(e.metaKey?o?delete this.selected[i]:this.selected[i]=!0:e.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(e=>+e)})):o?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(e,t){e.stopPropagation(),this.expandedRowIdx[t]?(delete this.expandedRowIdx[t],this["md-table-advanced-change"].emit({type:"collapse",row:t})):(this.expandedRowIdx[t]=!0,this["md-table-advanced-change"].emit({type:"expand",row:t})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return l.html` <div>${this.error}</div> `;const{head:e}=this.tableConfig,t=(0,a.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return l.html`
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("@popperjs/core/lib/modifiers/arrow"),require("@popperjs/core/lib/modifiers/flip"),require("@popperjs/core/lib/modifiers/offset"),require("@popperjs/core/lib/modifiers/preventOverflow"),require("@popperjs/core/lib/popper-lite"),require("lit/directives/unsafe-html.js"),require("papaparse"));else if("function"==typeof define&&define.amd)define(["lit","lit/decorators.js","lit/directives/class-map.js","lit/directives/style-map.js","lit/directives/if-defined.js","@momentum-ui/icons/data/momentumUiIconsNames.json","@momentum-ui/utils/lib/getColorValue","mobx","@popperjs/core/lib/modifiers/arrow","@popperjs/core/lib/modifiers/flip","@popperjs/core/lib/modifiers/offset","@popperjs/core/lib/modifiers/preventOverflow","@popperjs/core/lib/popper-lite","lit/directives/unsafe-html.js","papaparse"],t);else{var i="object"==typeof exports?t(require("lit"),require("lit/decorators.js"),require("lit/directives/class-map.js"),require("lit/directives/style-map.js"),require("lit/directives/if-defined.js"),require("@momentum-ui/icons/data/momentumUiIconsNames.json"),require("@momentum-ui/utils/lib/getColorValue"),require("mobx"),require("@popperjs/core/lib/modifiers/arrow"),require("@popperjs/core/lib/modifiers/flip"),require("@popperjs/core/lib/modifiers/offset"),require("@popperjs/core/lib/modifiers/preventOverflow"),require("@popperjs/core/lib/popper-lite"),require("lit/directives/unsafe-html.js"),require("papaparse")):t(e.lit,e["lit/decorators.js"],e["lit/directives/class-map.js"],e["lit/directives/style-map.js"],e["lit/directives/if-defined.js"],e["@momentum-ui/icons/data/momentumUiIconsNames.json"],e["@momentum-ui/utils/lib/getColorValue"],e.mobx,e["@popperjs/core/lib/modifiers/arrow"],e["@popperjs/core/lib/modifiers/flip"],e["@popperjs/core/lib/modifiers/offset"],e["@popperjs/core/lib/modifiers/preventOverflow"],e["@popperjs/core/lib/popper-lite"],e["lit/directives/unsafe-html.js"],e.papaparse);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(self,(e,t,i,o,s,r,l,a,n,d,p,c,h,m,u)=>(()=>{"use strict";var f,g={7936(e,t,i){i.r(t),i.d(t,{TableAdvanced:()=>b}),i(5983),i(1821),i(708);var o=i(9609),s=i(9938),r=i(4084),l=i(7161),a=i(429),n=i(5125),d=i(291),p=i(6968),c=i(8187),h=i.n(c),m=i(4841),u=i(597),f=i(9125),g=function(e,t,i,o){var s,r=arguments.length,l=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(l=(r<3?s(l):r>3?s(t,i,l):s(t,i))||l);return r>3&&l&&Object.defineProperty(t,i,l),l};const v=document.createElement("img");var b;v.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(e){let t=class extends((0,s.d)(l.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=e=>e.preventDefault(),this.eX=0,this.onResize=(e,t)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const o=e.target;null===(i=e.dataTransfer)||void 0===i||i.setDragImage(v,0,0);const s=this.COLS.map(e=>this.shadowRoot.querySelector(`th.col-index-${e.index}`));this.COLS.forEach((e,t)=>e.width=s[t].offsetWidth+"px"),this.updCols();const r=e.x;this.eX=e.x;let l=-1,a=-1,n=-1;const d=this.COLS[t.index-1],p=s[t.index],c=s[t.index-1],h=p.offsetWidth,m=c.offsetWidth,u=()=>{const e=this.eX;if(l!=e&&0!=e){l=e;const i=l-r;a=h-i,n=m+i,t.width=a+"px",d.width=n+"px",this.updCols()}},f=e=>this.eX=e.x,g=()=>{this.isResizing=!1,o.removeEventListener("drag",u),o.removeEventListener("dragend",g),document.removeEventListener("dragover",f)};o.addEventListener("drag",u),o.addEventListener("dragend",g),document.addEventListener("dragover",f)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}willUpdate(e){var t;null===(t=super.willUpdate)||void 0===t||t.call(this,e),e.has("data")&&void 0!==e.get("data")&&(this.error="")}update(e){super.update(e),e.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(e){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(e){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var e;let t=0;const i=(e,i)=>{var o,s,r,l;const a=e.filters||(null===(s=null===(o=this.tableConfig.default)||void 0===o?void 0:o.col)||void 0===s?void 0:s.filters),n=a?"forString"==a?f.d.optionsString:"forNumber"==a?f.d.optionsNumber:a.length?a:null:null;this.COLS.push({options:Object.assign({},e),index:t++,group:i,sort:"default",sorter:e.sorter||(null===(l=null===(r=this.tableConfig.default)||void 0===r?void 0:r.col)||void 0===l?void 0:l.sorter),isCollapsable:this.tableConfig.cols.collapse==e.id,filter:n?{list:n,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(e=>{"children"in e?e.children.forEach(t=>i(t,{name:e.groupName,length:e.children.length})):i(e)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)}populateData(){const e=this.COLS.length;if("csv"in this.tableData){const e=h().parse(this.tableData.csv,{skipEmptyLines:!0,transform:e=>e.trim()});if(e.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(e.errors,null,2));{const t=e.data;this.ROWS=t.map(e=>e.map(e=>({text:e})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(e=>e.map(e=>({text:e})));else{for(;this.tableData.list.length>e;)this.ROWS.push(this.tableData.list.splice(0,e).map(e=>({text:e})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(e=>({text:e})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const e=this.COLS.length;this.ROWS.reduce((e,t)=>e+t.length,0)%e==0?this.ROWS.forEach((t,i)=>{const o=t.length;o!=e&&(this.error=`DATA ERROR: Total number of cols (=${e}) and data[${i}] length (=${o}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const e=this.tableConfig.cellTemplates,t=Object.keys(e||{});e&&t.length&&this.ROWS.forEach((t,i)=>{t.forEach((t,o)=>{for(const s in e){const r=t.text.indexOf(s);if(-1!=r){const l=e[s],a=this.querySelector(`#${l.templateName}`);if(null==a){console.warn(`cellTemplates["${s}"]: Missing '${l.templateName}' template.`);continue}let n=t.text.replace(s,"");l.contentCb&&(n=l.contentCb({col:o,row:i,content:n,insertIndex:r})),this.ROWS[i][o]={text:n,template:{template:a,templateCb:l.templateCb,insertIndex:"replace"==l.contentUse?-1:r}};break}}})})}setDefaultFilterAndSort(){var e,t;const i=null===(e=this.tableConfig.default)||void 0===e?void 0:e.sort;if(i){const e=this.COLS.find(e=>e.options.id==i.colId);e?this.sort(e,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const o=null===(t=this.tableConfig.default)||void 0===t?void 0:t.filter;if(o){const e=this.COLS.find(e=>e.options.id==o.colId);e?e.filter?(e.filter.selectedIndex=o.selectedIndex,e.filter.input=o.input,this.updCols(),this.filter(e)):console.warn(`Cant find filters on ${o.colId} col`):console.warn(`Cant find ${o.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const e=this.COLS[this.dragCol],t=this.COLS[this.dropCol],i=e.group,o=t.group,s=e.index,r=t.index;e.group=o,t.group=i,e.index=r,t.index=s,this.COLS[this.dragCol]=t,this.COLS[this.dropCol]=e,this.ROWS.forEach(e=>{const t=e[this.dragCol],i=e[this.dropCol];e[this.dragCol]=i,e[this.dropCol]=t}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(e,t){e.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==e.options.id?i.sort=t||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:e.sort}))}filter(e){if(!e.filter)return;this.clearSelection(),this.drops=[];const t=e.filter.input.trim(),i=e.filter.list[e.filter.selectedIndex];e.filter.active=!!t,this.requestUpdate(),t?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:t}):this["md-table-advanced-change"].emit({type:"filter-off",filter:e.filter.list[e.filter.selectedIndex]})}selectRow(e){var t;const i=e.row.idx,o=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)?(e.metaKey?o?delete this.selected[i]:this.selected[i]=!0:e.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(e=>+e)})):o?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(e,t){e.stopPropagation(),this.expandedRowIdx[t]?(delete this.expandedRowIdx[t],this["md-table-advanced-change"].emit({type:"collapse",row:t})):(this.expandedRowIdx[t]=!0,this["md-table-advanced-change"].emit({type:"expand",row:t})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return l.html` <div>${this.error}</div> `;const{head:e}=this.tableConfig,t=(0,n.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return l.html`
2
2
  <div class="md-table-advanced">
3
3
  <slot></slot>
4
4
  <table class=${t} summary=${(0,d.ifDefined)(null==e?void 0:e.summary)}>
@@ -35,7 +35,7 @@
35
35
  <thead>
36
36
  ${e} ${i}
37
37
  </thead>
38
- `}sortIconTemplate(e){return"ascending"===e?l.html`<md-icon name="sort-descending-bold" size="16" iconSet="momentumDesign"></md-icon>`:"descending"===e?l.html`<md-icon name="sort-ascending-bold" size="16" iconSet="momentumDesign"></md-icon>`:l.html`<md-icon name="unsorted-bold" size="16" iconSet="momentumDesign"></md-icon>`}renderCol(e,t){var i,o;const s=null===(o=null===(i=e.filter)||void 0===i?void 0:i.list[e.filter.selectedIndex])||void 0===o?void 0:o.input,r=(0,a.classMap)({ascending:"ascending"==e.sort,descending:"descending"==e.sort});return l.html`
38
+ `}sortIconTemplate(e){return"ascending"===e?l.html`<md-icon name="sort-descending-bold" size="16" iconSet="momentumDesign"></md-icon>`:"descending"===e?l.html`<md-icon name="sort-ascending-bold" size="16" iconSet="momentumDesign"></md-icon>`:l.html`<md-icon name="unsorted-bold" size="16" iconSet="momentumDesign"></md-icon>`}renderCol(e,t){var i,o;const s=null===(o=null===(i=e.filter)||void 0===i?void 0:i.list[e.filter.selectedIndex])||void 0===o?void 0:o.input,r=(0,n.classMap)({ascending:"ascending"==e.sort,descending:"descending"==e.sort});return l.html`
39
39
  <th
40
40
  rowspan=${(0,d.ifDefined)(t)}
41
41
  width=${(0,d.ifDefined)(e.width?e.width:e.options.width)}
@@ -100,7 +100,7 @@
100
100
  `}renderColDrag(e){return this.tableConfig.cols.isDraggable?l.html`
101
101
  <div
102
102
  draggable="true"
103
- class="drag-area-col ${(0,a.classMap)({drag:-1!=this.dragCol,over:this.dropCol==e.index&&this.dropCol!=this.dragCol})}"
103
+ class="drag-area-col ${(0,n.classMap)({drag:-1!=this.dragCol,over:this.dropCol==e.index&&this.dropCol!=this.dragCol})}"
104
104
  @dragstart=${t=>{this.isResizing||-1!=this.dragRow||(this.dragCol=e.index,t.dataTransfer.setDragImage(t.target.parentNode,0,0))}}
105
105
  @dragenter=${()=>{this.isResizing||-1!=this.dragRow||(this.dropCol=e.index)}}
106
106
  @dragend=${()=>this.onDropCol()}
@@ -115,16 +115,16 @@
115
115
  ${this.renderRow(t,i)} ${o?t.children.map(e=>this.renderRow(e,i)):l.nothing}
116
116
  `})}
117
117
  </tbody>
118
- `}processTemplate(e){const t=document.importNode(e.content,!0);return Array.from(t.childNodes).map(e=>e.nodeType===Node.ELEMENT_NODE?e.outerHTML:e.nodeType===Node.TEXT_NODE&&e.textContent||"").join("")}processTemplateCallback(e){const t=document.importNode(e.template.content,!0);return e.cb({content:e.content,row:e.row,col:e.col,insertIndex:e.insertIndex,fragment:t}),Array.from(t.childNodes).map(e=>e.nodeType===Node.ELEMENT_NODE?e.outerHTML:e.nodeType===Node.TEXT_NODE&&e.textContent||"").join("")}renderRow(e,t){const i=Object.prototype.hasOwnProperty.call(this.selected,e.idx),o=(0,a.classMap)({selected:i,selectable:this.isSelectable&&!i,ghost:e.isGhost});return l.html`
118
+ `}processTemplate(e){const t=document.importNode(e.content,!0);return Array.from(t.childNodes).map(e=>e.nodeType===Node.ELEMENT_NODE?e.outerHTML:e.nodeType===Node.TEXT_NODE&&e.textContent||"").join("")}processTemplateCallback(e){const t=document.importNode(e.template.content,!0);return e.cb({content:e.content,row:e.row,col:e.col,insertIndex:e.insertIndex,fragment:t}),Array.from(t.childNodes).map(e=>e.nodeType===Node.ELEMENT_NODE?e.outerHTML:e.nodeType===Node.TEXT_NODE&&e.textContent||"").join("")}renderRow(e,t){const i=Object.prototype.hasOwnProperty.call(this.selected,e.idx),o=(0,n.classMap)({selected:i,selectable:this.isSelectable&&!i,ghost:e.isGhost});return l.html`
119
119
  <tr
120
120
  class=${o}
121
121
  tabindex=${(0,d.ifDefined)("true"===this.isRowFocusable?"0":void 0)}
122
122
  part=${e.first?"first-row":"row"}
123
123
  @click=${({shiftKey:t,metaKey:i})=>{this.isSelectable&&this.selectRow({row:e,shiftKey:t,metaKey:i})}}
124
124
  >
125
- ${e.cells.map((i,o)=>{var s;const r=this.COLS[o];let n=i.text;const a=i.template;a&&(n=a.templateCb?l.html`${(0,p.unsafeHTML)(this.processTemplateCallback({cb:a.templateCb,insertIndex:a.insertIndex,template:a.template,content:i.text,row:e.idx,col:o}))}`:l.html`${(0,p.unsafeHTML)(this.processTemplate(a.template))}`,-1!=a.insertIndex&&(n=l.html`
126
- ${a.insertIndex>0?i.text.substring(0,a.insertIndex):l.nothing} ${n}
127
- ${a.insertIndex<i.text.length-1?i.text.substring(a.insertIndex):l.nothing}
125
+ ${e.cells.map((i,o)=>{var s;const r=this.COLS[o];let a=i.text;const n=i.template;n&&(a=n.templateCb?l.html`${(0,p.unsafeHTML)(this.processTemplateCallback({cb:n.templateCb,insertIndex:n.insertIndex,template:n.template,content:i.text,row:e.idx,col:o}))}`:l.html`${(0,p.unsafeHTML)(this.processTemplate(n.template))}`,-1!=n.insertIndex&&(a=l.html`
126
+ ${n.insertIndex>0?i.text.substring(0,n.insertIndex):l.nothing} ${a}
127
+ ${n.insertIndex<i.text.length-1?i.text.substring(n.insertIndex):l.nothing}
128
128
  `));const d=(null===(s=this.tableConfig.rows)||void 0===s?void 0:s.isDraggable)&&"child"!=e.collapse,c=d&&-1!=this.dragRow&&this.dragRow!=e.idxDrag,h=d&&0==o,m=l.html`
129
129
  <div
130
130
  class="inner-cell"
@@ -158,9 +158,9 @@
158
158
  ${"collapsed"==e.collapse?l.html` <md-icon name="plus-bold" size="12" iconSet="momentumDesign"></md-icon> `:l.html` <md-icon name="minus-bold" size="12" iconSet="momentumDesign"></md-icon> `}
159
159
  </button>
160
160
  `:l.nothing}
161
- <span>${"child"==e.collapse?l.nothing:n}</span>
162
- `:l.html` <span>${n}</span> `}
161
+ <span>${"child"==e.collapse?l.nothing:a}</span>
162
+ `:l.html` <span>${a}</span> `}
163
163
  </div>
164
164
  `;return r.options.isHeader?l.html` <th part="cell-ishead" scope="row" title="${i.text}">${m}</th> `:l.html` <td part=${0===o?"first-cell":"cell"} title="${i.text}">${m}</td> `})}
165
165
  </tr>
166
- `}static get styles(){return[r.A,m.A]}};g([(0,n.property)({attribute:"config"})],t.prototype,"config",void 0),g([(0,n.property)({attribute:"data"})],t.prototype,"data",void 0),g([(0,n.property)({type:String})],t.prototype,"isRowFocusable",void 0),g([(0,u.Wj)()],t.prototype,"md-table-advanced-change",void 0),g([(0,n.state)()],t.prototype,"tableConfig",void 0),g([(0,n.state)()],t.prototype,"tableData",void 0),g([(0,n.state)()],t.prototype,"error",void 0),g([(0,n.state)()],t.prototype,"COLS",void 0),g([(0,n.state)()],t.prototype,"ROWS",void 0),g([(0,n.state)()],t.prototype,"dragRow",void 0),g([(0,n.state)()],t.prototype,"dropRow",void 0),g([(0,n.state)()],t.prototype,"drops",void 0),g([(0,n.state)()],t.prototype,"dragCol",void 0),g([(0,n.state)()],t.prototype,"dropCol",void 0),g([(0,n.queryAll)("tr[tabindex]")],t.prototype,"tableRaws",void 0),g([(0,u.sg)(500)],t.prototype,"filter",null),t=g([(0,o.w)("md-table-advanced")],t),e.ELEMENT=t}(b||(b={}))},2022(e){e.exports=r},554(e){e.exports=l},2962(e){e.exports=a},6538(e){e.exports=d},8250(e){e.exports=p},9371(e){e.exports=c},4863(e){e.exports=h},7161(t){t.exports=e},429(e){e.exports=t},5125(e){e.exports=i},291(e){e.exports=s},318(e){e.exports=o},6968(e){e.exports=m},5314(e){e.exports=n},8187(e){e.exports=u}},v={};function b(e){var t=v[e];if(void 0!==t)return t.exports;var i=v[e]={exports:{}};return g[e](i,i.exports,b),i.exports}b.m=g,f=[],b.O=(e,t,i,o)=>{if(!t){var s=1/0;for(a=0;a<f.length;a++){for(var[t,i,o]=f[a],r=!0,l=0;l<t.length;l++)(!1&o||s>=o)&&Object.keys(b.O).every(e=>b.O[e](t[l]))?t.splice(l--,1):(r=!1,o<s&&(s=o));if(r){f.splice(a--,1);var n=i();void 0!==n&&(e=n)}}return e}o=o||0;for(var a=f.length;a>0&&f[a-1][2]>o;a--)f[a]=f[a-1];f[a]=[t,i,o]},b.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return b.d(t,{a:t}),t},b.d=(e,t)=>{for(var i in t)b.o(t,i)&&!b.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},b.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),b.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={4139:0};b.O.j=t=>0===e[t];var t=(t,i)=>{var o,s,[r,l,n]=i,a=0;if(r.some(t=>0!==e[t])){for(o in l)b.o(l,o)&&(b.m[o]=l[o]);if(n)var d=n(b)}for(t&&t(i);a<r.length;a++)s=r[a],b.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return b.O(d)},i=self["momentum-web-components-[id]"]=self["momentum-web-components-[id]"]||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})();var x=b.O(void 0,[9609,4084,3305,4739,7154,9773,5983,9488,1821,519,2050,8441,9983,4700,9146,708,8881],()=>b(7936));return b.O(x)})());
166
+ `}static get styles(){return[r.A,m.A]}};g([(0,a.property)({attribute:"config"})],t.prototype,"config",void 0),g([(0,a.property)({attribute:"data"})],t.prototype,"data",void 0),g([(0,a.property)({type:String})],t.prototype,"isRowFocusable",void 0),g([(0,u.Wj)()],t.prototype,"md-table-advanced-change",void 0),g([(0,a.state)()],t.prototype,"tableConfig",void 0),g([(0,a.state)()],t.prototype,"tableData",void 0),g([(0,a.state)()],t.prototype,"error",void 0),g([(0,a.state)()],t.prototype,"COLS",void 0),g([(0,a.state)()],t.prototype,"ROWS",void 0),g([(0,a.state)()],t.prototype,"dragRow",void 0),g([(0,a.state)()],t.prototype,"dropRow",void 0),g([(0,a.state)()],t.prototype,"drops",void 0),g([(0,a.state)()],t.prototype,"dragCol",void 0),g([(0,a.state)()],t.prototype,"dropCol",void 0),g([(0,a.queryAll)("tr[tabindex]")],t.prototype,"tableRaws",void 0),g([(0,u.sg)(500)],t.prototype,"filter",null),t=g([(0,o.w)("md-table-advanced")],t),e.ELEMENT=t}(b||(b={}))},2022(e){e.exports=r},554(e){e.exports=l},2962(e){e.exports=n},6538(e){e.exports=d},8250(e){e.exports=p},9371(e){e.exports=c},4863(e){e.exports=h},7161(t){t.exports=e},429(e){e.exports=t},5125(e){e.exports=i},291(e){e.exports=s},318(e){e.exports=o},6968(e){e.exports=m},5314(e){e.exports=a},8187(e){e.exports=u}},v={};function b(e){var t=v[e];if(void 0!==t)return t.exports;var i=v[e]={exports:{}};return g[e](i,i.exports,b),i.exports}b.m=g,f=[],b.O=(e,t,i,o)=>{if(!t){var s=1/0;for(n=0;n<f.length;n++){for(var[t,i,o]=f[n],r=!0,l=0;l<t.length;l++)(!1&o||s>=o)&&Object.keys(b.O).every(e=>b.O[e](t[l]))?t.splice(l--,1):(r=!1,o<s&&(s=o));if(r){f.splice(n--,1);var a=i();void 0!==a&&(e=a)}}return e}o=o||0;for(var n=f.length;n>0&&f[n-1][2]>o;n--)f[n]=f[n-1];f[n]=[t,i,o]},b.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return b.d(t,{a:t}),t},b.d=(e,t)=>{for(var i in t)b.o(t,i)&&!b.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},b.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),b.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={4139:0};b.O.j=t=>0===e[t];var t=(t,i)=>{var o,s,[r,l,a]=i,n=0;if(r.some(t=>0!==e[t])){for(o in l)b.o(l,o)&&(b.m[o]=l[o]);if(a)var d=a(b)}for(t&&t(i);n<r.length;n++)s=r[n],b.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return b.O(d)},i=self["momentum-web-components-[id]"]=self["momentum-web-components-[id]"]||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))})();var x=b.O(void 0,[9609,4084,3305,4739,7154,9773,5983,9488,1821,519,2050,8441,9983,4700,9146,708,8881],()=>b(7936));return b.O(x)})());
@@ -1,4 +1,4 @@
1
- var t,e,i={7936(t,e,i){i.d(e,{v:()=>v}),i(5983),i(1821),i(708);var o=i(9609),s=i(9938),r=i(4084),a=i(2927),l=i(8899),n=i(4955),d=i(3517),h=i(7638),c=i(6897),p=i(4841),m=i(597),g=i(9125),u=function(t,e,i,o){var s,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var l=t.length-1;l>=0;l--)(s=t[l])&&(a=(r<3?s(a):r>3?s(e,i,a):s(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a};const f=document.createElement("img");var v;f.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(t){let e=class extends((0,s.d)(a.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=t=>t.preventDefault(),this.eX=0,this.onResize=(t,e)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const o=t.target;null===(i=t.dataTransfer)||void 0===i||i.setDragImage(f,0,0);const s=this.COLS.map(t=>this.shadowRoot.querySelector(`th.col-index-${t.index}`));this.COLS.forEach((t,e)=>t.width=s[e].offsetWidth+"px"),this.updCols();const r=t.x;this.eX=t.x;let a=-1,l=-1,n=-1;const d=this.COLS[e.index-1],h=s[e.index],c=s[e.index-1],p=h.offsetWidth,m=c.offsetWidth,g=()=>{const t=this.eX;if(a!=t&&0!=t){a=t;const i=a-r;l=p-i,n=m+i,e.width=l+"px",d.width=n+"px",this.updCols()}},u=t=>this.eX=t.x,v=()=>{this.isResizing=!1,o.removeEventListener("drag",g),o.removeEventListener("dragend",v),document.removeEventListener("dragover",u)};o.addEventListener("drag",g),o.addEventListener("dragend",v),document.addEventListener("dragover",u)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}update(t){super.update(t),t.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var t;let e=0;const i=(t,i)=>{var o,s,r,a;const l=t.filters||(null===(s=null===(o=this.tableConfig.default)||void 0===o?void 0:o.col)||void 0===s?void 0:s.filters),n=l?"forString"==l?g.d.optionsString:"forNumber"==l?g.d.optionsNumber:l.length?l:null:null;this.COLS.push({options:Object.assign({},t),index:e++,group:i,sort:"default",sorter:t.sorter||(null===(a=null===(r=this.tableConfig.default)||void 0===r?void 0:r.col)||void 0===a?void 0:a.sorter),isCollapsable:this.tableConfig.cols.collapse==t.id,filter:n?{list:n,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(t=>{"children"in t?t.children.forEach(e=>i(e,{name:t.groupName,length:t.children.length})):i(t)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)}populateData(){const t=this.COLS.length;if("csv"in this.tableData){const t=c.default.parse(this.tableData.csv,{skipEmptyLines:!0,transform:t=>t.trim()});if(t.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(t.errors,null,2));{const e=t.data;this.ROWS=e.map(t=>t.map(t=>({text:t})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(t=>t.map(t=>({text:t})));else{for(;this.tableData.list.length>t;)this.ROWS.push(this.tableData.list.splice(0,t).map(t=>({text:t})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(t=>({text:t})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const t=this.COLS.length;this.ROWS.reduce((t,e)=>t+e.length,0)%t==0?this.ROWS.forEach((e,i)=>{const o=e.length;o!=t&&(this.error=`DATA ERROR: Total number of cols (=${t}) and data[${i}] length (=${o}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const t=this.tableConfig.cellTemplates,e=Object.keys(t||{});t&&e.length&&this.ROWS.forEach((e,i)=>{e.forEach((e,o)=>{for(const s in t){const r=e.text.indexOf(s);if(-1!=r){const a=t[s],l=this.querySelector(`#${a.templateName}`);if(null==l){console.warn(`cellTemplates["${s}"]: Missing '${a.templateName}' template.`);continue}let n=e.text.replace(s,"");a.contentCb&&(n=a.contentCb({col:o,row:i,content:n,insertIndex:r})),this.ROWS[i][o]={text:n,template:{template:l,templateCb:a.templateCb,insertIndex:"replace"==a.contentUse?-1:r}};break}}})})}setDefaultFilterAndSort(){var t,e;const i=null===(t=this.tableConfig.default)||void 0===t?void 0:t.sort;if(i){const t=this.COLS.find(t=>t.options.id==i.colId);t?this.sort(t,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const o=null===(e=this.tableConfig.default)||void 0===e?void 0:e.filter;if(o){const t=this.COLS.find(t=>t.options.id==o.colId);t?t.filter?(t.filter.selectedIndex=o.selectedIndex,t.filter.input=o.input,this.updCols(),this.filter(t)):console.warn(`Cant find filters on ${o.colId} col`):console.warn(`Cant find ${o.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const t=this.COLS[this.dragCol],e=this.COLS[this.dropCol],i=t.group,o=e.group,s=t.index,r=e.index;t.group=o,e.group=i,t.index=r,e.index=s,this.COLS[this.dragCol]=e,this.COLS[this.dropCol]=t,this.ROWS.forEach(t=>{const e=t[this.dragCol],i=t[this.dropCol];t[this.dragCol]=i,t[this.dropCol]=e}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(t,e){t.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==t.options.id?i.sort=e||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:t.sort}))}filter(t){if(!t.filter)return;this.clearSelection(),this.drops=[];const e=t.filter.input.trim(),i=t.filter.list[t.filter.selectedIndex];t.filter.active=!!e,this.requestUpdate(),e?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:e}):this["md-table-advanced-change"].emit({type:"filter-off",filter:t.filter.list[t.filter.selectedIndex]})}selectRow(t){var e;const i=t.row.idx,o=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)?(t.metaKey?o?delete this.selected[i]:this.selected[i]=!0:t.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(t=>+t)})):o?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(t,e){t.stopPropagation(),this.expandedRowIdx[e]?(delete this.expandedRowIdx[e],this["md-table-advanced-change"].emit({type:"collapse",row:e})):(this.expandedRowIdx[e]=!0,this["md-table-advanced-change"].emit({type:"expand",row:e})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return a.html` <div>${this.error}</div> `;const{head:t}=this.tableConfig,e=(0,n.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return a.html`
1
+ var t,e,i={7936(t,e,i){i.d(e,{v:()=>v}),i(5983),i(1821),i(708);var o=i(9609),s=i(9938),r=i(4084),a=i(2927),l=i(8899),n=i(4955),d=i(3517),h=i(7638),c=i(6897),p=i(4841),m=i(597),g=i(9125),u=function(t,e,i,o){var s,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var l=t.length-1;l>=0;l--)(s=t[l])&&(a=(r<3?s(a):r>3?s(e,i,a):s(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a};const f=document.createElement("img");var v;f.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(t){let e=class extends((0,s.d)(a.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=t=>t.preventDefault(),this.eX=0,this.onResize=(t,e)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const o=t.target;null===(i=t.dataTransfer)||void 0===i||i.setDragImage(f,0,0);const s=this.COLS.map(t=>this.shadowRoot.querySelector(`th.col-index-${t.index}`));this.COLS.forEach((t,e)=>t.width=s[e].offsetWidth+"px"),this.updCols();const r=t.x;this.eX=t.x;let a=-1,l=-1,n=-1;const d=this.COLS[e.index-1],h=s[e.index],c=s[e.index-1],p=h.offsetWidth,m=c.offsetWidth,g=()=>{const t=this.eX;if(a!=t&&0!=t){a=t;const i=a-r;l=p-i,n=m+i,e.width=l+"px",d.width=n+"px",this.updCols()}},u=t=>this.eX=t.x,v=()=>{this.isResizing=!1,o.removeEventListener("drag",g),o.removeEventListener("dragend",v),document.removeEventListener("dragover",u)};o.addEventListener("drag",g),o.addEventListener("dragend",v),document.addEventListener("dragover",u)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}willUpdate(t){var e;null===(e=super.willUpdate)||void 0===e||e.call(this,t),t.has("data")&&void 0!==t.get("data")&&(this.error="")}update(t){super.update(t),t.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var t;let e=0;const i=(t,i)=>{var o,s,r,a;const l=t.filters||(null===(s=null===(o=this.tableConfig.default)||void 0===o?void 0:o.col)||void 0===s?void 0:s.filters),n=l?"forString"==l?g.d.optionsString:"forNumber"==l?g.d.optionsNumber:l.length?l:null:null;this.COLS.push({options:Object.assign({},t),index:e++,group:i,sort:"default",sorter:t.sorter||(null===(a=null===(r=this.tableConfig.default)||void 0===r?void 0:r.col)||void 0===a?void 0:a.sorter),isCollapsable:this.tableConfig.cols.collapse==t.id,filter:n?{list:n,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(t=>{"children"in t?t.children.forEach(e=>i(e,{name:t.groupName,length:t.children.length})):i(t)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)}populateData(){const t=this.COLS.length;if("csv"in this.tableData){const t=c.default.parse(this.tableData.csv,{skipEmptyLines:!0,transform:t=>t.trim()});if(t.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(t.errors,null,2));{const e=t.data;this.ROWS=e.map(t=>t.map(t=>({text:t})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(t=>t.map(t=>({text:t})));else{for(;this.tableData.list.length>t;)this.ROWS.push(this.tableData.list.splice(0,t).map(t=>({text:t})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(t=>({text:t})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const t=this.COLS.length;this.ROWS.reduce((t,e)=>t+e.length,0)%t==0?this.ROWS.forEach((e,i)=>{const o=e.length;o!=t&&(this.error=`DATA ERROR: Total number of cols (=${t}) and data[${i}] length (=${o}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const t=this.tableConfig.cellTemplates,e=Object.keys(t||{});t&&e.length&&this.ROWS.forEach((e,i)=>{e.forEach((e,o)=>{for(const s in t){const r=e.text.indexOf(s);if(-1!=r){const a=t[s],l=this.querySelector(`#${a.templateName}`);if(null==l){console.warn(`cellTemplates["${s}"]: Missing '${a.templateName}' template.`);continue}let n=e.text.replace(s,"");a.contentCb&&(n=a.contentCb({col:o,row:i,content:n,insertIndex:r})),this.ROWS[i][o]={text:n,template:{template:l,templateCb:a.templateCb,insertIndex:"replace"==a.contentUse?-1:r}};break}}})})}setDefaultFilterAndSort(){var t,e;const i=null===(t=this.tableConfig.default)||void 0===t?void 0:t.sort;if(i){const t=this.COLS.find(t=>t.options.id==i.colId);t?this.sort(t,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const o=null===(e=this.tableConfig.default)||void 0===e?void 0:e.filter;if(o){const t=this.COLS.find(t=>t.options.id==o.colId);t?t.filter?(t.filter.selectedIndex=o.selectedIndex,t.filter.input=o.input,this.updCols(),this.filter(t)):console.warn(`Cant find filters on ${o.colId} col`):console.warn(`Cant find ${o.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const t=this.COLS[this.dragCol],e=this.COLS[this.dropCol],i=t.group,o=e.group,s=t.index,r=e.index;t.group=o,e.group=i,t.index=r,e.index=s,this.COLS[this.dragCol]=e,this.COLS[this.dropCol]=t,this.ROWS.forEach(t=>{const e=t[this.dragCol],i=t[this.dropCol];t[this.dragCol]=i,t[this.dropCol]=e}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(t,e){t.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==t.options.id?i.sort=e||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:t.sort}))}filter(t){if(!t.filter)return;this.clearSelection(),this.drops=[];const e=t.filter.input.trim(),i=t.filter.list[t.filter.selectedIndex];t.filter.active=!!e,this.requestUpdate(),e?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:e}):this["md-table-advanced-change"].emit({type:"filter-off",filter:t.filter.list[t.filter.selectedIndex]})}selectRow(t){var e;const i=t.row.idx,o=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)?(t.metaKey?o?delete this.selected[i]:this.selected[i]=!0:t.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(t=>+t)})):o?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(t,e){t.stopPropagation(),this.expandedRowIdx[e]?(delete this.expandedRowIdx[e],this["md-table-advanced-change"].emit({type:"collapse",row:e})):(this.expandedRowIdx[e]=!0,this["md-table-advanced-change"].emit({type:"expand",row:e})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return a.html` <div>${this.error}</div> `;const{head:t}=this.tableConfig,e=(0,n.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return a.html`
2
2
  <div class="md-table-advanced">
3
3
  <slot></slot>
4
4
  <table class=${e} summary=${(0,d.ifDefined)(null==t?void 0:t.summary)}>
@@ -1774,7 +1774,7 @@ import*as t from"luxon";var e,i,s={3701(t,e,i){i.d(e,{n:()=>s});var s,o=i(2900),
1774
1774
  ></span>
1775
1775
  ${this.step?this.ticksTemplate():l.nothing} ${this.hideValue?l.nothing:this.displayValueTemplate()}
1776
1776
  </div>
1777
- `}};m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"min",void 0),m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"max",void 0),m([(0,d.property)({type:Boolean,attribute:"hide-value"})],e.prototype,"hideValue",void 0),m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"now",null),m([(0,d.property)({type:Number})],e.prototype,"text",void 0),m([(0,d.property)({type:String})],e.prototype,"label",void 0),m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"step",void 0),m([(0,d.property)({type:Boolean,reflect:!0})],e.prototype,"disabled",null),m([(0,d.state)()],e.prototype,"dragging",void 0),e=m([(0,r.w)("md-slider")],e),t.ELEMENT=e}(s||(s={}))},7936(t,e,i){i.d(e,{v:()=>y}),i(5983),i(1821),i(708);var s=i(9609),o=i(9938),a=i(4084),r=i(2927),n=i(8899),l=i(4955),d=i(3517),h=i(7638),c=i(6897),p=i(4841),u=i(597),m=i(9125),b=function(t,e,i,s){var o,a=arguments.length,r=a<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};const v=document.createElement("img");var y;v.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(t){let e=class extends((0,o.d)(r.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=t=>t.preventDefault(),this.eX=0,this.onResize=(t,e)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const s=t.target;null===(i=t.dataTransfer)||void 0===i||i.setDragImage(v,0,0);const o=this.COLS.map(t=>this.shadowRoot.querySelector(`th.col-index-${t.index}`));this.COLS.forEach((t,e)=>t.width=o[e].offsetWidth+"px"),this.updCols();const a=t.x;this.eX=t.x;let r=-1,n=-1,l=-1;const d=this.COLS[e.index-1],h=o[e.index],c=o[e.index-1],p=h.offsetWidth,u=c.offsetWidth,m=()=>{const t=this.eX;if(r!=t&&0!=t){r=t;const i=r-a;n=p-i,l=u+i,e.width=n+"px",d.width=l+"px",this.updCols()}},b=t=>this.eX=t.x,y=()=>{this.isResizing=!1,s.removeEventListener("drag",m),s.removeEventListener("dragend",y),document.removeEventListener("dragover",b)};s.addEventListener("drag",m),s.addEventListener("dragend",y),document.addEventListener("dragover",b)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}update(t){super.update(t),t.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var t;let e=0;const i=(t,i)=>{var s,o,a,r;const n=t.filters||(null===(o=null===(s=this.tableConfig.default)||void 0===s?void 0:s.col)||void 0===o?void 0:o.filters),l=n?"forString"==n?m.d.optionsString:"forNumber"==n?m.d.optionsNumber:n.length?n:null:null;this.COLS.push({options:Object.assign({},t),index:e++,group:i,sort:"default",sorter:t.sorter||(null===(r=null===(a=this.tableConfig.default)||void 0===a?void 0:a.col)||void 0===r?void 0:r.sorter),isCollapsable:this.tableConfig.cols.collapse==t.id,filter:l?{list:l,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(t=>{"children"in t?t.children.forEach(e=>i(e,{name:t.groupName,length:t.children.length})):i(t)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)}populateData(){const t=this.COLS.length;if("csv"in this.tableData){const t=c.default.parse(this.tableData.csv,{skipEmptyLines:!0,transform:t=>t.trim()});if(t.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(t.errors,null,2));{const e=t.data;this.ROWS=e.map(t=>t.map(t=>({text:t})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(t=>t.map(t=>({text:t})));else{for(;this.tableData.list.length>t;)this.ROWS.push(this.tableData.list.splice(0,t).map(t=>({text:t})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(t=>({text:t})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const t=this.COLS.length;this.ROWS.reduce((t,e)=>t+e.length,0)%t==0?this.ROWS.forEach((e,i)=>{const s=e.length;s!=t&&(this.error=`DATA ERROR: Total number of cols (=${t}) and data[${i}] length (=${s}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const t=this.tableConfig.cellTemplates,e=Object.keys(t||{});t&&e.length&&this.ROWS.forEach((e,i)=>{e.forEach((e,s)=>{for(const o in t){const a=e.text.indexOf(o);if(-1!=a){const r=t[o],n=this.querySelector(`#${r.templateName}`);if(null==n){console.warn(`cellTemplates["${o}"]: Missing '${r.templateName}' template.`);continue}let l=e.text.replace(o,"");r.contentCb&&(l=r.contentCb({col:s,row:i,content:l,insertIndex:a})),this.ROWS[i][s]={text:l,template:{template:n,templateCb:r.templateCb,insertIndex:"replace"==r.contentUse?-1:a}};break}}})})}setDefaultFilterAndSort(){var t,e;const i=null===(t=this.tableConfig.default)||void 0===t?void 0:t.sort;if(i){const t=this.COLS.find(t=>t.options.id==i.colId);t?this.sort(t,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const s=null===(e=this.tableConfig.default)||void 0===e?void 0:e.filter;if(s){const t=this.COLS.find(t=>t.options.id==s.colId);t?t.filter?(t.filter.selectedIndex=s.selectedIndex,t.filter.input=s.input,this.updCols(),this.filter(t)):console.warn(`Cant find filters on ${s.colId} col`):console.warn(`Cant find ${s.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const t=this.COLS[this.dragCol],e=this.COLS[this.dropCol],i=t.group,s=e.group,o=t.index,a=e.index;t.group=s,e.group=i,t.index=a,e.index=o,this.COLS[this.dragCol]=e,this.COLS[this.dropCol]=t,this.ROWS.forEach(t=>{const e=t[this.dragCol],i=t[this.dropCol];t[this.dragCol]=i,t[this.dropCol]=e}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(t,e){t.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==t.options.id?i.sort=e||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:t.sort}))}filter(t){if(!t.filter)return;this.clearSelection(),this.drops=[];const e=t.filter.input.trim(),i=t.filter.list[t.filter.selectedIndex];t.filter.active=!!e,this.requestUpdate(),e?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:e}):this["md-table-advanced-change"].emit({type:"filter-off",filter:t.filter.list[t.filter.selectedIndex]})}selectRow(t){var e;const i=t.row.idx,s=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)?(t.metaKey?s?delete this.selected[i]:this.selected[i]=!0:t.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(t=>+t)})):s?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(t,e){t.stopPropagation(),this.expandedRowIdx[e]?(delete this.expandedRowIdx[e],this["md-table-advanced-change"].emit({type:"collapse",row:e})):(this.expandedRowIdx[e]=!0,this["md-table-advanced-change"].emit({type:"expand",row:e})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return r.html` <div>${this.error}</div> `;const{head:t}=this.tableConfig,e=(0,l.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return r.html`
1777
+ `}};m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"min",void 0),m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"max",void 0),m([(0,d.property)({type:Boolean,attribute:"hide-value"})],e.prototype,"hideValue",void 0),m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"now",null),m([(0,d.property)({type:Number})],e.prototype,"text",void 0),m([(0,d.property)({type:String})],e.prototype,"label",void 0),m([(0,d.property)({type:Number,reflect:!0})],e.prototype,"step",void 0),m([(0,d.property)({type:Boolean,reflect:!0})],e.prototype,"disabled",null),m([(0,d.state)()],e.prototype,"dragging",void 0),e=m([(0,r.w)("md-slider")],e),t.ELEMENT=e}(s||(s={}))},7936(t,e,i){i.d(e,{v:()=>y}),i(5983),i(1821),i(708);var s=i(9609),o=i(9938),a=i(4084),r=i(2927),n=i(8899),l=i(4955),d=i(3517),h=i(7638),c=i(6897),p=i(4841),u=i(597),m=i(9125),b=function(t,e,i,s){var o,a=arguments.length,r=a<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};const v=document.createElement("img");var y;v.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(t){let e=class extends((0,o.d)(r.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=t=>t.preventDefault(),this.eX=0,this.onResize=(t,e)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const s=t.target;null===(i=t.dataTransfer)||void 0===i||i.setDragImage(v,0,0);const o=this.COLS.map(t=>this.shadowRoot.querySelector(`th.col-index-${t.index}`));this.COLS.forEach((t,e)=>t.width=o[e].offsetWidth+"px"),this.updCols();const a=t.x;this.eX=t.x;let r=-1,n=-1,l=-1;const d=this.COLS[e.index-1],h=o[e.index],c=o[e.index-1],p=h.offsetWidth,u=c.offsetWidth,m=()=>{const t=this.eX;if(r!=t&&0!=t){r=t;const i=r-a;n=p-i,l=u+i,e.width=n+"px",d.width=l+"px",this.updCols()}},b=t=>this.eX=t.x,y=()=>{this.isResizing=!1,s.removeEventListener("drag",m),s.removeEventListener("dragend",y),document.removeEventListener("dragover",b)};s.addEventListener("drag",m),s.addEventListener("dragend",y),document.addEventListener("dragover",b)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}willUpdate(t){var e;null===(e=super.willUpdate)||void 0===e||e.call(this,t),t.has("data")&&void 0!==t.get("data")&&(this.error="")}update(t){super.update(t),t.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var t;let e=0;const i=(t,i)=>{var s,o,a,r;const n=t.filters||(null===(o=null===(s=this.tableConfig.default)||void 0===s?void 0:s.col)||void 0===o?void 0:o.filters),l=n?"forString"==n?m.d.optionsString:"forNumber"==n?m.d.optionsNumber:n.length?n:null:null;this.COLS.push({options:Object.assign({},t),index:e++,group:i,sort:"default",sorter:t.sorter||(null===(r=null===(a=this.tableConfig.default)||void 0===a?void 0:a.col)||void 0===r?void 0:r.sorter),isCollapsable:this.tableConfig.cols.collapse==t.id,filter:l?{list:l,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(t=>{"children"in t?t.children.forEach(e=>i(e,{name:t.groupName,length:t.children.length})):i(t)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)}populateData(){const t=this.COLS.length;if("csv"in this.tableData){const t=c.default.parse(this.tableData.csv,{skipEmptyLines:!0,transform:t=>t.trim()});if(t.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(t.errors,null,2));{const e=t.data;this.ROWS=e.map(t=>t.map(t=>({text:t})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(t=>t.map(t=>({text:t})));else{for(;this.tableData.list.length>t;)this.ROWS.push(this.tableData.list.splice(0,t).map(t=>({text:t})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(t=>({text:t})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const t=this.COLS.length;this.ROWS.reduce((t,e)=>t+e.length,0)%t==0?this.ROWS.forEach((e,i)=>{const s=e.length;s!=t&&(this.error=`DATA ERROR: Total number of cols (=${t}) and data[${i}] length (=${s}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const t=this.tableConfig.cellTemplates,e=Object.keys(t||{});t&&e.length&&this.ROWS.forEach((e,i)=>{e.forEach((e,s)=>{for(const o in t){const a=e.text.indexOf(o);if(-1!=a){const r=t[o],n=this.querySelector(`#${r.templateName}`);if(null==n){console.warn(`cellTemplates["${o}"]: Missing '${r.templateName}' template.`);continue}let l=e.text.replace(o,"");r.contentCb&&(l=r.contentCb({col:s,row:i,content:l,insertIndex:a})),this.ROWS[i][s]={text:l,template:{template:n,templateCb:r.templateCb,insertIndex:"replace"==r.contentUse?-1:a}};break}}})})}setDefaultFilterAndSort(){var t,e;const i=null===(t=this.tableConfig.default)||void 0===t?void 0:t.sort;if(i){const t=this.COLS.find(t=>t.options.id==i.colId);t?this.sort(t,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const s=null===(e=this.tableConfig.default)||void 0===e?void 0:e.filter;if(s){const t=this.COLS.find(t=>t.options.id==s.colId);t?t.filter?(t.filter.selectedIndex=s.selectedIndex,t.filter.input=s.input,this.updCols(),this.filter(t)):console.warn(`Cant find filters on ${s.colId} col`):console.warn(`Cant find ${s.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const t=this.COLS[this.dragCol],e=this.COLS[this.dropCol],i=t.group,s=e.group,o=t.index,a=e.index;t.group=s,e.group=i,t.index=a,e.index=o,this.COLS[this.dragCol]=e,this.COLS[this.dropCol]=t,this.ROWS.forEach(t=>{const e=t[this.dragCol],i=t[this.dropCol];t[this.dragCol]=i,t[this.dropCol]=e}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(t,e){t.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==t.options.id?i.sort=e||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:t.sort}))}filter(t){if(!t.filter)return;this.clearSelection(),this.drops=[];const e=t.filter.input.trim(),i=t.filter.list[t.filter.selectedIndex];t.filter.active=!!e,this.requestUpdate(),e?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:e}):this["md-table-advanced-change"].emit({type:"filter-off",filter:t.filter.list[t.filter.selectedIndex]})}selectRow(t){var e;const i=t.row.idx,s=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)?(t.metaKey?s?delete this.selected[i]:this.selected[i]=!0:t.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(t=>+t)})):s?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(t,e){t.stopPropagation(),this.expandedRowIdx[e]?(delete this.expandedRowIdx[e],this["md-table-advanced-change"].emit({type:"collapse",row:e})):(this.expandedRowIdx[e]=!0,this["md-table-advanced-change"].emit({type:"expand",row:e})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return r.html` <div>${this.error}</div> `;const{head:t}=this.tableConfig,e=(0,l.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return r.html`
1778
1778
  <div class="md-table-advanced">
1779
1779
  <slot></slot>
1780
1780
  <table class=${e} summary=${(0,d.ifDefined)(null==t?void 0:t.summary)}>
@@ -2419,7 +2419,7 @@
2419
2419
  part="spinner"
2420
2420
  style=${(0,d.styleMap)(this.spinnerStyleMap)}
2421
2421
  ></i>
2422
- `}};c([(0,n.property)({type:Number,reflect:!0})],e.prototype,"size",void 0),e=c([(0,s.w)("md-spinner")],e),t.ELEMENT=e}(o||(o={}))},7936(t,e,i){i.d(e,{TableAdvanced:()=>g}),i(5983),i(1821),i(708);var o=i(9609),s=i(9938),r=i(4084),a=i(7161),n=i(429),l=i(5125),d=i(291),h=i(6968),c=i(8187),p=i.n(c),u=i(4841),m=i(597),v=i(9125),y=function(t,e,i,o){var s,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(e,i,a):s(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a};const b=document.createElement("img");var g;b.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(t){let e=class extends((0,s.d)(a.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=t=>t.preventDefault(),this.eX=0,this.onResize=(t,e)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const o=t.target;null===(i=t.dataTransfer)||void 0===i||i.setDragImage(b,0,0);const s=this.COLS.map(t=>this.shadowRoot.querySelector(`th.col-index-${t.index}`));this.COLS.forEach((t,e)=>t.width=s[e].offsetWidth+"px"),this.updCols();const r=t.x;this.eX=t.x;let a=-1,n=-1,l=-1;const d=this.COLS[e.index-1],h=s[e.index],c=s[e.index-1],p=h.offsetWidth,u=c.offsetWidth,m=()=>{const t=this.eX;if(a!=t&&0!=t){a=t;const i=a-r;n=p-i,l=u+i,e.width=n+"px",d.width=l+"px",this.updCols()}},v=t=>this.eX=t.x,y=()=>{this.isResizing=!1,o.removeEventListener("drag",m),o.removeEventListener("dragend",y),document.removeEventListener("dragover",v)};o.addEventListener("drag",m),o.addEventListener("dragend",y),document.addEventListener("dragover",v)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}update(t){super.update(t),t.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var t;let e=0;const i=(t,i)=>{var o,s,r,a;const n=t.filters||(null===(s=null===(o=this.tableConfig.default)||void 0===o?void 0:o.col)||void 0===s?void 0:s.filters),l=n?"forString"==n?v.d.optionsString:"forNumber"==n?v.d.optionsNumber:n.length?n:null:null;this.COLS.push({options:Object.assign({},t),index:e++,group:i,sort:"default",sorter:t.sorter||(null===(a=null===(r=this.tableConfig.default)||void 0===r?void 0:r.col)||void 0===a?void 0:a.sorter),isCollapsable:this.tableConfig.cols.collapse==t.id,filter:l?{list:l,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(t=>{"children"in t?t.children.forEach(e=>i(e,{name:t.groupName,length:t.children.length})):i(t)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)}populateData(){const t=this.COLS.length;if("csv"in this.tableData){const t=p().parse(this.tableData.csv,{skipEmptyLines:!0,transform:t=>t.trim()});if(t.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(t.errors,null,2));{const e=t.data;this.ROWS=e.map(t=>t.map(t=>({text:t})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(t=>t.map(t=>({text:t})));else{for(;this.tableData.list.length>t;)this.ROWS.push(this.tableData.list.splice(0,t).map(t=>({text:t})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(t=>({text:t})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const t=this.COLS.length;this.ROWS.reduce((t,e)=>t+e.length,0)%t==0?this.ROWS.forEach((e,i)=>{const o=e.length;o!=t&&(this.error=`DATA ERROR: Total number of cols (=${t}) and data[${i}] length (=${o}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const t=this.tableConfig.cellTemplates,e=Object.keys(t||{});t&&e.length&&this.ROWS.forEach((e,i)=>{e.forEach((e,o)=>{for(const s in t){const r=e.text.indexOf(s);if(-1!=r){const a=t[s],n=this.querySelector(`#${a.templateName}`);if(null==n){console.warn(`cellTemplates["${s}"]: Missing '${a.templateName}' template.`);continue}let l=e.text.replace(s,"");a.contentCb&&(l=a.contentCb({col:o,row:i,content:l,insertIndex:r})),this.ROWS[i][o]={text:l,template:{template:n,templateCb:a.templateCb,insertIndex:"replace"==a.contentUse?-1:r}};break}}})})}setDefaultFilterAndSort(){var t,e;const i=null===(t=this.tableConfig.default)||void 0===t?void 0:t.sort;if(i){const t=this.COLS.find(t=>t.options.id==i.colId);t?this.sort(t,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const o=null===(e=this.tableConfig.default)||void 0===e?void 0:e.filter;if(o){const t=this.COLS.find(t=>t.options.id==o.colId);t?t.filter?(t.filter.selectedIndex=o.selectedIndex,t.filter.input=o.input,this.updCols(),this.filter(t)):console.warn(`Cant find filters on ${o.colId} col`):console.warn(`Cant find ${o.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const t=this.COLS[this.dragCol],e=this.COLS[this.dropCol],i=t.group,o=e.group,s=t.index,r=e.index;t.group=o,e.group=i,t.index=r,e.index=s,this.COLS[this.dragCol]=e,this.COLS[this.dropCol]=t,this.ROWS.forEach(t=>{const e=t[this.dragCol],i=t[this.dropCol];t[this.dragCol]=i,t[this.dropCol]=e}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(t,e){t.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==t.options.id?i.sort=e||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:t.sort}))}filter(t){if(!t.filter)return;this.clearSelection(),this.drops=[];const e=t.filter.input.trim(),i=t.filter.list[t.filter.selectedIndex];t.filter.active=!!e,this.requestUpdate(),e?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:e}):this["md-table-advanced-change"].emit({type:"filter-off",filter:t.filter.list[t.filter.selectedIndex]})}selectRow(t){var e;const i=t.row.idx,o=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)?(t.metaKey?o?delete this.selected[i]:this.selected[i]=!0:t.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(t=>+t)})):o?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(t,e){t.stopPropagation(),this.expandedRowIdx[e]?(delete this.expandedRowIdx[e],this["md-table-advanced-change"].emit({type:"collapse",row:e})):(this.expandedRowIdx[e]=!0,this["md-table-advanced-change"].emit({type:"expand",row:e})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return a.html` <div>${this.error}</div> `;const{head:t}=this.tableConfig,e=(0,l.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return a.html`
2422
+ `}};c([(0,n.property)({type:Number,reflect:!0})],e.prototype,"size",void 0),e=c([(0,s.w)("md-spinner")],e),t.ELEMENT=e}(o||(o={}))},7936(t,e,i){i.d(e,{TableAdvanced:()=>g}),i(5983),i(1821),i(708);var o=i(9609),s=i(9938),r=i(4084),a=i(7161),n=i(429),l=i(5125),d=i(291),h=i(6968),c=i(8187),p=i.n(c),u=i(4841),m=i(597),v=i(9125),y=function(t,e,i,o){var s,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var n=t.length-1;n>=0;n--)(s=t[n])&&(a=(r<3?s(a):r>3?s(e,i,a):s(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a};const b=document.createElement("img");var g;b.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",function(t){let e=class extends((0,s.d)(a.LitElement)){constructor(){super(...arguments),this.isRowFocusable="true",this.error="",this.COLS=[],this.ROWS=[],this.updCols=()=>this.requestUpdate("COLS"),this.updRows=()=>this.requestUpdate("ROWS"),this.dragRow=-1,this.dropRow=-1,this.drops=[],this.dragRowElem=null,this.dragCol=-1,this.dropCol=-1,this.isResizing=!1,this.isSelectable=!1,this.selected={},this.expandedRowIdx={},this.dragover=t=>t.preventDefault(),this.eX=0,this.onResize=(t,e)=>{var i;if(-1!=this.dragCol||-1!=this.dragRow)return;this.isResizing=!0;const o=t.target;null===(i=t.dataTransfer)||void 0===i||i.setDragImage(b,0,0);const s=this.COLS.map(t=>this.shadowRoot.querySelector(`th.col-index-${t.index}`));this.COLS.forEach((t,e)=>t.width=s[e].offsetWidth+"px"),this.updCols();const r=t.x;this.eX=t.x;let a=-1,n=-1,l=-1;const d=this.COLS[e.index-1],h=s[e.index],c=s[e.index-1],p=h.offsetWidth,u=c.offsetWidth,m=()=>{const t=this.eX;if(a!=t&&0!=t){a=t;const i=a-r;n=p-i,l=u+i,e.width=n+"px",d.width=l+"px",this.updCols()}},v=t=>this.eX=t.x,y=()=>{this.isResizing=!1,o.removeEventListener("drag",m),o.removeEventListener("dragend",y),document.removeEventListener("dragover",v)};o.addEventListener("drag",m),o.addEventListener("dragend",y),document.addEventListener("dragover",v)}}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dragover",this.dragover)}connectedCallback(){super.connectedCallback(),document.addEventListener("dragover",this.dragover),this.updateTableConfig(),this.updateTableData(),this.populateTable()}willUpdate(t){var e;null===(e=super.willUpdate)||void 0===e||e.call(this,t),t.has("data")&&void 0!==t.get("data")&&(this.error="")}update(t){super.update(t),t.has("data")&&(this.updateTableData(),this.updateDataInTable())}updateTableData(){if("string"==typeof this.data)try{this.tableData=JSON.parse(this.data)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the config json")}else this.tableData=Object.assign({},this.data)}updateTableConfig(){if("string"==typeof this.config)try{this.tableConfig=JSON.parse(this.config)}catch(t){console.error("[INVALID_JSON_FORMAT] Please recheck the data json")}else this.tableConfig=Object.assign({},this.config)}populateColumns(){var t;let e=0;const i=(t,i)=>{var o,s,r,a;const n=t.filters||(null===(s=null===(o=this.tableConfig.default)||void 0===o?void 0:o.col)||void 0===s?void 0:s.filters),l=n?"forString"==n?v.d.optionsString:"forNumber"==n?v.d.optionsNumber:n.length?n:null:null;this.COLS.push({options:Object.assign({},t),index:e++,group:i,sort:"default",sorter:t.sorter||(null===(a=null===(r=this.tableConfig.default)||void 0===r?void 0:r.col)||void 0===a?void 0:a.sorter),isCollapsable:this.tableConfig.cols.collapse==t.id,filter:l?{list:l,selectedIndex:0,input:"",active:!1,menuVisible:!1}:void 0})};this.tableConfig.cols.define.forEach(t=>{"children"in t?t.children.forEach(e=>i(e,{name:t.groupName,length:t.children.length})):i(t)}),this.isSelectable=!!this.tableConfig.rows&&"none"!=(null===(t=this.tableConfig.rows)||void 0===t?void 0:t.selectable)}populateData(){const t=this.COLS.length;if("csv"in this.tableData){const t=p().parse(this.tableData.csv,{skipEmptyLines:!0,transform:t=>t.trim()});if(t.errors)return void(this.error="PARSE ERROR:\n"+JSON.stringify(t.errors,null,2));{const e=t.data;this.ROWS=e.map(t=>t.map(t=>({text:t})))}}else if("list2d"in this.tableData)this.ROWS=this.tableData.list2d.map(t=>t.map(t=>({text:t})));else{for(;this.tableData.list.length>t;)this.ROWS.push(this.tableData.list.splice(0,t).map(t=>({text:t})));0!=this.tableData.list.length&&this.ROWS.push(this.tableData.list.map(t=>({text:t})))}0!=this.ROWS.length||(this.error="DATA ERROR: Data is empty")}validateData(){const t=this.COLS.length;this.ROWS.reduce((t,e)=>t+e.length,0)%t==0?this.ROWS.forEach((e,i)=>{const o=e.length;o!=t&&(this.error=`DATA ERROR: Total number of cols (=${t}) and data[${i}] length (=${o}) mismatch`)}):this.error=this.error="DATA ERROR: Data length mismatch. You must provide (numberOfRows * numberOfColumns) amount of data values."}populateTemplate(){const t=this.tableConfig.cellTemplates,e=Object.keys(t||{});t&&e.length&&this.ROWS.forEach((e,i)=>{e.forEach((e,o)=>{for(const s in t){const r=e.text.indexOf(s);if(-1!=r){const a=t[s],n=this.querySelector(`#${a.templateName}`);if(null==n){console.warn(`cellTemplates["${s}"]: Missing '${a.templateName}' template.`);continue}let l=e.text.replace(s,"");a.contentCb&&(l=a.contentCb({col:o,row:i,content:l,insertIndex:r})),this.ROWS[i][o]={text:l,template:{template:n,templateCb:a.templateCb,insertIndex:"replace"==a.contentUse?-1:r}};break}}})})}setDefaultFilterAndSort(){var t,e;const i=null===(t=this.tableConfig.default)||void 0===t?void 0:t.sort;if(i){const t=this.COLS.find(t=>t.options.id==i.colId);t?this.sort(t,i.order):console.warn(`Cant find ${i.colId} col - for sorting`)}const o=null===(e=this.tableConfig.default)||void 0===e?void 0:e.filter;if(o){const t=this.COLS.find(t=>t.options.id==o.colId);t?t.filter?(t.filter.selectedIndex=o.selectedIndex,t.filter.input=o.input,this.updCols(),this.filter(t)):console.warn(`Cant find filters on ${o.colId} col`):console.warn(`Cant find ${o.colId} col - for filtering`)}}populateTable(){this.populateColumns(),this.populateData(),this.validateData(),this.setDefaultFilterAndSort(),this.populateTemplate()}updateDataInTable(){this.populateData(),this.validateData(),this.populateTemplate()}onDropRow(){this.dragRow!=this.dropRow&&this.drops.push([this.dragRow,this.dropRow]),this.dragRow=-1,this.dropRow=-1,this.dragRowElem&&(this.dragRowElem.setAttribute("draggable","false"),this.dragRowElem=null)}onDropCol(){if(this.dragCol!=this.dropCol){const t=this.COLS[this.dragCol],e=this.COLS[this.dropCol],i=t.group,o=e.group,s=t.index,r=e.index;t.group=o,e.group=i,t.index=r,e.index=s,this.COLS[this.dragCol]=e,this.COLS[this.dropCol]=t,this.ROWS.forEach(t=>{const e=t[this.dragCol],i=t[this.dropCol];t[this.dragCol]=i,t[this.dropCol]=e}),this.updCols(),this.updRows()}this.dragCol=-1,this.dropCol=-1}sort(t,e){t.sorter&&(this.clearSelection(),this.drops=[],this.COLS.forEach(i=>{i.options.id==t.options.id?i.sort=e||("default"==i.sort?"ascending":"ascending"==i.sort?"descending":"default"):i.sort="default"}),this.updCols(),this.requestUpdate(),this["md-table-advanced-change"].emit({type:"sort",order:t.sort}))}filter(t){if(!t.filter)return;this.clearSelection(),this.drops=[];const e=t.filter.input.trim(),i=t.filter.list[t.filter.selectedIndex];t.filter.active=!!e,this.requestUpdate(),e?this["md-table-advanced-change"].emit({type:"filter-on",filter:i,input:e}):this["md-table-advanced-change"].emit({type:"filter-off",filter:t.filter.list[t.filter.selectedIndex]})}selectRow(t){var e;const i=t.row.idx,o=Object.prototype.hasOwnProperty.call(this.selected,i);"multiple"==(null===(e=this.tableConfig.rows)||void 0===e?void 0:e.selectable)?(t.metaKey?o?delete this.selected[i]:this.selected[i]=!0:t.shiftKey||(this.selected={[i]:!0}),this["md-table-advanced-change"].emit({type:"multi-select",rows:Object.keys(this.selected).map(t=>+t)})):o?this.clearSelection():(this.selected={[i]:!0},this["md-table-advanced-change"].emit({type:"select",index:i})),this.requestUpdate("selected")}clearSelection(){this.selected={},this.requestUpdate("selected")}collapseToggle(t,e){t.stopPropagation(),this.expandedRowIdx[e]?(delete this.expandedRowIdx[e],this["md-table-advanced-change"].emit({type:"collapse",row:e})):(this.expandedRowIdx[e]=!0,this["md-table-advanced-change"].emit({type:"expand",row:e})),this.clearSelection(),this.requestUpdate()}render(){if(this.error)return a.html` <div>${this.error}</div> `;const{head:t}=this.tableConfig,e=(0,l.classMap)({"sticky-header":!!this.tableConfig.isStickyHeader});return a.html`
2423
2423
  <div class="md-table-advanced">
2424
2424
  <slot></slot>
2425
2425
  <table class=${e} summary=${(0,d.ifDefined)(null==t?void 0:t.summary)}>
@@ -10,7 +10,7 @@ export declare class EditableFieldTemplateSandbox extends LitElement {
10
10
  disconnectedCallback(): void;
11
11
  setErrorMessage: () => void;
12
12
  resetErrorMessage: () => void;
13
- renderErrorMessage(): import("lit-html").TemplateResult<1> | typeof nothing;
13
+ renderErrorMessage(): typeof nothing | import("lit-html").TemplateResult<1>;
14
14
  render(): import("lit-html").TemplateResult<1>;
15
15
  }
16
16
  export declare const editableField: import("lit-html").TemplateResult<1>;
@@ -78,7 +78,7 @@ export declare namespace Avatar {
78
78
  private get chatIconSize();
79
79
  private get presenceSize();
80
80
  private get iconSize();
81
- get renderIsTyping(): import("lit-html").TemplateResult<1> | typeof nothing;
81
+ get renderIsTyping(): typeof nothing | import("lit-html").TemplateResult<1>;
82
82
  private get avatarLetter();
83
83
  private get avatarIcon();
84
84
  private get avatarImage();
@@ -88,8 +88,8 @@ export declare namespace Avatar {
88
88
  handleKeyDown(event: KeyboardEvent): void;
89
89
  handleClick(event: MouseEvent): void;
90
90
  private getBrandOrDesignIconSet;
91
- get avatarContent(): import("lit-html").TemplateResult<1> | typeof nothing;
92
- renderPresence(): import("lit-html").TemplateResult<1> | typeof nothing;
91
+ get avatarContent(): typeof nothing | import("lit-html").TemplateResult<1>;
92
+ renderPresence(): typeof nothing | import("lit-html").TemplateResult<1>;
93
93
  private renderAvatarContent;
94
94
  render(): import("lit-html").TemplateResult<1>;
95
95
  }
@@ -31,7 +31,7 @@ export declare namespace Badge {
31
31
  renderTextColor: () => string | typeof nothing;
32
32
  renderHeight: () => string | typeof nothing;
33
33
  renderWidth: () => string | typeof nothing;
34
- getStyles: () => import("lit-html").TemplateResult<1> | typeof nothing;
34
+ getStyles: () => typeof nothing | import("lit-html").TemplateResult<1>;
35
35
  static get styles(): import("lit").CSSResult[];
36
36
  private get computedAriaHiddenSplits();
37
37
  private get computedTabIndex();
@@ -129,10 +129,10 @@ export declare namespace Button {
129
129
  get slottedText(): string | undefined;
130
130
  get hasIcon(): boolean;
131
131
  iconTemplate: () => import("lit-html").TemplateResult<1>;
132
- textTemplate: () => import("lit-html").TemplateResult<1> | typeof nothing;
132
+ textTemplate: () => typeof nothing | import("lit-html").TemplateResult<1>;
133
133
  childrenTemplate(): import("lit-html").TemplateResult<1>;
134
134
  get computedAriaExpand(): "true" | "false" | undefined;
135
- buttonTemplate(tag: Button.Tag): import("lit-html").TemplateResult<1> | typeof nothing;
135
+ buttonTemplate(tag: Button.Tag): typeof nothing | import("lit-html").TemplateResult<1>;
136
136
  get buttonContainerClassMap(): {
137
137
  "md-button__container": boolean;
138
138
  "md-button__container--small": boolean;
@@ -52,10 +52,10 @@ export declare namespace Chip {
52
52
  protected renderBgColor: () => string | typeof nothing;
53
53
  protected renderTextColor: () => string | typeof nothing;
54
54
  protected renderHeight: () => string | typeof nothing;
55
- protected getStyles: () => import("lit-html").TemplateResult<1> | typeof nothing;
55
+ protected getStyles: () => typeof nothing | import("lit-html").TemplateResult<1>;
56
56
  static get styles(): import("lit").CSSResult[];
57
- protected loadingTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
58
- protected iconTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
57
+ protected loadingTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
58
+ protected iconTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
59
59
  getToolTipContent(): string;
60
60
  private get textContentClassMap();
61
61
  private get textContentTemplate();
@@ -199,7 +199,7 @@ export declare namespace ComboBox {
199
199
  arrowButtonTemplate(): TemplateResult<1>;
200
200
  groupArrowButtonTemplate(data: string): TemplateResult<1>;
201
201
  getSelectAllOption(): TemplateResult<1>;
202
- getSelctedCount(): TemplateResult<1> | typeof nothing;
202
+ getSelctedCount(): typeof nothing | TemplateResult<1>;
203
203
  checkForVirtualScroll(): boolean;
204
204
  rangeChanged(): void;
205
205
  getCustomErrorContent(): DocumentFragment;
@@ -210,8 +210,8 @@ export declare namespace ComboBox {
210
210
  addStyle(): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/style-map.js").StyleMapDirective>;
211
211
  renderItem(option: OptionMember | string, index: number): TemplateResult;
212
212
  inputTitle(): string;
213
- helpTextTemplate(): TemplateResult<1> | typeof nothing;
214
- messagesTemplate(): TemplateResult<1> | typeof nothing;
213
+ helpTextTemplate(): typeof nothing | TemplateResult<1>;
214
+ messagesTemplate(): typeof nothing | TemplateResult<1>;
215
215
  get newArrowButtonTemplate(): TemplateResult<1>;
216
216
  get renderNewMomentumArrow(): TemplateResult;
217
217
  get renderTrailingInputControls(): TemplateResult;
@@ -139,8 +139,8 @@ export declare namespace Dropdown {
139
139
  };
140
140
  handleInput(event: Event): void;
141
141
  private notifyInputValueChanged;
142
- helpTextTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
143
- messagesTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
142
+ helpTextTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
143
+ messagesTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
144
144
  iconTemplate(): import("lit-html").TemplateResult<1>;
145
145
  clearButtonTemplate(): import("lit-html").TemplateResult<1>;
146
146
  arrowButtonTemplate(): import("lit-html").TemplateResult<1>;
@@ -40,7 +40,7 @@ export declare namespace EditableTextfield {
40
40
  showAlert(): void;
41
41
  static get styles(): CSSResultArray;
42
42
  get overflowStyles(): string | false | 0;
43
- messagesTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
43
+ messagesTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
44
44
  render(): import("lit-html").TemplateResult<1>;
45
45
  }
46
46
  }
@@ -166,15 +166,15 @@ export declare namespace Input {
166
166
  get hasRightIcon(): boolean;
167
167
  private get effectiveAriaLabel();
168
168
  inputTemplate(): import("lit-html").TemplateResult<1>;
169
- inputLeftTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
169
+ inputLeftTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
170
170
  private get inputRightTemplateClassMap();
171
171
  inputRightTemplate(): import("lit-html").TemplateResult<1> | undefined;
172
172
  private get comboBoxButtonTemplate();
173
173
  private characterCountLabelTemplate;
174
- secondaryLabelTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
175
- helpTextTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
176
- messagesTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
177
- labelTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
174
+ secondaryLabelTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
175
+ helpTextTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
176
+ messagesTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
177
+ labelTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
178
178
  static get styles(): import("lit").CSSResult[];
179
179
  render(): import("lit-html").TemplateResult<1>;
180
180
  }
@@ -23,7 +23,7 @@ export declare namespace Radio {
23
23
  private get inputAriaLabel();
24
24
  static get styles(): import("lit").CSSResult[];
25
25
  private get helpTextClassMap();
26
- messagesTemplate(): import("lit-html").TemplateResult<1> | typeof nothing;
26
+ messagesTemplate(): typeof nothing | import("lit-html").TemplateResult<1>;
27
27
  render(): import("lit-html").TemplateResult<1>;
28
28
  }
29
29
  export {};
@@ -43,6 +43,7 @@ export declare namespace TableAdvanced {
43
43
  tableRaws?: HTMLTableRowElement[];
44
44
  disconnectedCallback(): void;
45
45
  connectedCallback(): void;
46
+ protected willUpdate(changedProperties: PropertyValues): void;
46
47
  protected update(changedProperties: PropertyValues): void;
47
48
  private updateTableData;
48
49
  private updateTableConfig;
@@ -6,5 +6,5 @@ export declare const getChannelAvatar: (selected: boolean, status: string | null
6
6
  export declare const renderTaskType: (mediaType: string, selected: boolean, status: string | null, iconSrc: string) => TemplateResult<1>;
7
7
  export declare const renderStatus: (status: string) => TemplateResult<1>;
8
8
  export declare const renderLegacyTaskType: (mediaType: string, selected: boolean, iconSrc: string) => TemplateResult<1>;
9
- export declare const renderChatCount: (quantity: number, isRestyle: boolean, element: HTMLElement) => TemplateResult<1> | typeof nothing;
9
+ export declare const renderChatCount: (quantity: number, isRestyle: boolean, element: HTMLElement) => typeof nothing | TemplateResult<1>;
10
10
  export {};
@@ -3,7 +3,7 @@ import { LitElement, nothing, PropertyValues } from "lit";
3
3
  export declare class ColorTableSandbox extends LitElement {
4
4
  private colorTokenTableData;
5
5
  firstUpdated(changedProperties: PropertyValues): void;
6
- renderColorTable(): import("lit-html").TemplateResult<1> | typeof nothing;
6
+ renderColorTable(): typeof nothing | import("lit-html").TemplateResult<1>;
7
7
  static get styles(): import("lit").CSSResult[];
8
8
  render(): import("lit-html").TemplateResult<1>;
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momentum-ui/web-components",
3
- "version": "3.2.15",
3
+ "version": "3.2.16",
4
4
  "author": "Yana Harris",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/momentum-design/momentum-ui.git",