import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-4a3a9179.js";var pdsTableHeadCellCss=":host{--background-fixed:var(--pine-color-base-white);--border:var(--pine-border-default);--box-shadow:3px 3px 6px -2px rgba(0, 0, 0, 0.1);--color-sorting:var(--pine-color-neutral-charcoal-500);--color:var(--pine-color-neutral-charcoal-200);--fixed-cell-position:0;--font-size:var(--pine-font-size-body-sm);--font-weight:var(--pine-font-weight-medium);--line-height:var(--pine-line-height-sm);--margin-arrow:var(--pine-spacing-xxs);--padding-arrow:calc(var(--pine-spacing-xxs) / 2);--padding-compact:var(--pine-spacing-xxs);--padding:calc(var(--pine-spacing-md) / 2);-webkit-border-after:var(--border);border-block-end:var(--border);color:var(--color);display:table-cell;font-size:var(--font-size);font-style:normal;font-weight:var(--font-weight);line-height:var(--line-height);padding:var(--padding);text-align:start;vertical-align:inherit}:host(.is-compact){padding-block:var(--padding-compact)}:host(.is-fixed){background:var(--background-fixed);left:var(--fixed-cell-position);position:-webkit-sticky;position:sticky;z-index:1}:host(.has-scrolled.is-fixed){-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}:host(.is-sortable){cursor:pointer}:host(.is-sortable) pds-icon{-webkit-margin-start:var(--margin-arrow);margin-inline-start:var(--margin-arrow);-webkit-padding-before:var(--padding-arrow);padding-block-start:var(--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}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:"855185382f83a8434abb9b1ccf222c8ef47e399a",class:this.classNames(),role:"columnheader",onClick:this.toggleSort,style:this.tableRef&&this.tableRef.fixedColumn&&this.tableRef.selectable?{"--fixed-cell-position":"40px"}:{}},h("slot",{key:"78f3f9551be753e3be9953dfa57a9924d2dd4950"}),this.sortable&&h("pds-icon",{name:this.sortingDirection==="asc"?"up-small":"down-small"}))};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