import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-2a33b470.js";import{e as upSmall,d as downSmall}from"./index-9f8fe796.js";var pdsTableHeadCellCss=":host{--border-head-cell-default:var(--pine-border-width-thin) solid var(--pine-color-grey-300);--box-shadow-default:3px 3px 6px -2px rgba(0, 0, 0, 0.1);--color-background-fixed:var(--pine-color-white);--color-sorting:var(--pine-color-grey-950);--color-text-default:var(--pine-color-grey-700);--dimension-fixed-cell-position:0;--font-size-head-cell:var(--pine-font-size-085);--font-weight-cell-default:var(--pine-font-weight-normal);--line-height-cell-default:var(--pine-line-height-125);--padding-cell-default:calc(var(--pine-spacing-300) / 2);--spacing-margin-inline-start-arrow:var(--pine-spacing-050);--spacing-padding-arrow:calc(var(--pine-spacing-050) / 2);--spacing-padding-block-compact:var(--pine-spacing-050);-webkit-border-after:var(--border-head-cell-default);border-block-end:var(--border-head-cell-default);color:var(--color-text-default);display:table-cell;font-size:var(--font-size-head-cell);font-style:normal;font-weight:var(--font-weight-cell-default);line-height:var(--line-height-cell-default);padding:var(--padding-cell-default);text-align:start;vertical-align:inherit}:host(.is-compact){padding-block:var(--spacing-padding-block-compact)}:host(.is-fixed){background:var(--color-background-fixed);left:var(--dimension-fixed-cell-position);position:-webkit-sticky;position:sticky;z-index:1}:host(.has-scrolled.is-fixed){-webkit-box-shadow:var(--box-shadow-default);box-shadow:var(--box-shadow-default)}:host(.is-sortable){cursor:pointer}:host(.is-sortable) pds-icon{-webkit-margin-start:var(--spacing-margin-inline-start-arrow);margin-inline-start:var(--spacing-margin-inline-start-arrow);-webkit-padding-before:var(--spacing-padding-arrow);padding-block-start:var(--spacing-padding-arrow);position:absolute}:host(.is-sortable:hover),:host(.is-active){color:var(--color-sorting)}";var PdsTableHeadCellStyle0=pdsTableHeadCellCss;var PdsTableHeadCell=function(){function e(e){var i=this;registerInstance(this,e);this.pdsTableSort=createEvent(this,"pdsTableSort",7);this.handleScroll=function(){if(i.tableRef.scrollLeft>0){i.tableScrolling=true}else{i.tableScrolling=false}};this.toggleSort=function(){if(i.sortable){var e=i.hostElement.innerText.trim();i.sortingDirection=i.sortingDirection==="asc"?"desc":"asc";i.tableRef.querySelectorAll("pds-table-head-cell").forEach((function(e){e.classList.remove("is-active")}));i.hostElement.classList.toggle("is-active");i.pdsTableSort.emit({column:e,direction:i.sortingDirection})}};this.sortable=undefined;this.sortingDirection="asc";this.tableScrolling=false;this.isSelected=false}e.prototype.componentWillRender=function(){this.tableRef=this.hostElement.closest("pds-table")};e.prototype.componentDidLoad=function(){if(this.tableRef&&this.tableRef.responsive&&this.tableRef.fixedColumn){this.tableRef.addEventListener("scroll",this.handleScroll)}};e.prototype.classNames=function(){var e=[];if(this.tableRef&&this.tableRef.compact){e.push("is-compact")}if(this.sortable){e.push("is-sortable")}if(this.sortable&&this.sortingDirection!==null){e.push("sort-"+this.sortingDirection)}if(this.tableRef&&this.tableRef.fixedColumn&&this.tableScrolling){e.push("has-scrolled")}return e.join("  ")};e.prototype.render=function(){return h(Host,{key:"72e242a22774d4b534b7a8653673606e0e9c6ef1",class:this.classNames(),role:"columnheader",onClick:this.toggleSort,style:this.tableRef&&this.tableRef.fixedColumn&&this.tableRef.selectable?{"--fixed-cell-position":"40px"}:{}},h("slot",{key:"08e1d5aab1761ed097e2669716884196c946bcc3"}),this.sortable&&h("pds-icon",{key:"43421a2b1401426878601468acee702ce45404bf",icon:this.sortingDirection==="asc"?upSmall:downSmall}))};Object.defineProperty(e.prototype,"hostElement",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();PdsTableHeadCell.style=PdsTableHeadCellStyle0;export{PdsTableHeadCell as pds_table_head_cell};
//# sourceMappingURL=pds-table-head-cell.entry.js.map