import{__awaiter,__generator}from"tslib";import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-ca411ad2.js";var pdsTableCss=":host{--color-background-default:var(--pine-color-white);background:var(--color-background-default);border-collapse:separate;-webkit-box-sizing:border-box;box-sizing:border-box;display:table;width:100%}:host(:focus-visible){--box-shadow-focus:0 0 0 2px var(--pine-color-blue-200);-webkit-box-shadow:var(--box-shadow-focus);box-shadow:var(--box-shadow-focus);outline:none}:host(.is-responsive){background-attachment:local, local, scroll, scroll;background-image:-webkit-gradient(linear, left top, right top, from(var(--color-background-default)), to(var(--color-background-default))), -webkit-gradient(linear, left top, right top, from(var(--color-background-default)), to(var(--color-background-default))), -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, 0.1)), to(rgba(255, 255, 255, 0))), -webkit-gradient(linear, right top, left top, from(rgba(0, 0, 0, 0.1)), to(rgba(255, 255, 255, 0)));background-image:linear-gradient(to right, var(--color-background-default), var(--color-background-default)), linear-gradient(to right, var(--color-background-default), var(--color-background-default)), linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0)), linear-gradient(to left, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0));background-position:left center, right center, left center, right center;background-repeat:no-repeat;background-size:4px 100%, 4px 100%, 4px 100%, 4px 100%;display:block;margin:0 auto;max-width:-webkit-fit-content;max-width:-moz-fit-content;max-width:fit-content;overflow-x:auto;white-space:nowrap}";var PdsTableStyle0=pdsTableCss;var PdsTable=function(){function t(t){registerInstance(this,t);this.pdsTableSelect=createEvent(this,"pdsTableSelect",7);this.pdsTableSelectAll=createEvent(this,"pdsTableSelectAll",7);this.compact=undefined;this.componentId=undefined;this.responsive=undefined;this.fixedColumn=undefined;this.selectable=undefined;this.sortingColumn=null;this.sortingDirection="asc"}t.prototype.componentWillLoad=function(){this.sortingColumn=null};t.prototype.classNames=function(){var t=["pds-table"];if(this.compact){t.push("is-compact")}if(this.responsive){t.push("is-responsive")}return t.join("  ")};t.prototype.sortTable=function(t,e){var r=this.el.querySelector("pds-table-body");var a=Array.from(r.querySelectorAll("pds-table-row"));var o=Array.from(this.el.querySelectorAll("pds-table-head-cell[sortable]"));var n=o.find((function(e){return e.innerText.trim()===t}));if(!n){console.warn('Column "'.concat(t,'" not found.'));return}var i=o.indexOf(n);a.sort((function(t,r){var a=t.querySelector("pds-table-cell:nth-child(".concat(i+1,")")).textContent.trim();var o=r.querySelector("pds-table-cell:nth-child(".concat(i+1,")")).textContent.trim();if(e==="asc"){return a.localeCompare(o)}else{return o.localeCompare(a)}}));r.innerHTML="";a.forEach((function(t){r.appendChild(t)}))};t.prototype.handleTableSort=function(t){var e=t.detail.direction;this.sortTable(t.detail.column,e);this.sortingColumn=t.detail.column;this.sortingDirection=e};t.prototype.handleTableSelectAll=function(t){if(t.defaultPrevented)return;var e=this.el.querySelector("pds-table-body");var r=Array.from(e.querySelectorAll("pds-table-row"));r.forEach((function(e){e.isSelected=t.detail.isSelected}))};t.prototype.handleTableSelect=function(t){return __awaiter(this,void 0,void 0,(function(){var e,r,a,o,n;return __generator(this,(function(i){if(t.defaultPrevented)return[2];e=this.el.querySelectorAll("pds-table-row");r=Array.from(e).every((function(t){return t.isSelected}));a=Array.from(e).every((function(t){return!t.isSelected}));o=this.el.querySelector("pds-table-head");if(!o)return[2];n=o.shadowRoot.querySelector("pds-checkbox");n.checked=r;n.indeterminate=!r&&!a;return[2]}))}))};t.prototype.render=function(){return h(Host,{key:"95cc4db296681faa0fc046c9b1d6807d640b7730",class:this.classNames(),id:this.componentId,role:"grid",selectable:this.selectable,tabindex:"0"},h("slot",{key:"ecc9bc0761409d5a2819a05d72290c294e27454f"}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();PdsTable.style=PdsTableStyle0;export{PdsTable as pds_table};
//# sourceMappingURL=pds-table.entry.js.map