@scania/tegel
Version:
Tegel Design System
1 lines • 2.66 kB
JavaScript
import{r as t,h as e,H as o,g as s}from"./p-2049fab2.js";const i=["compactDesign"],a=class{constructor(e){t(this,e),this.showIcon=!0,this.renderSlot=!0,this.inputFocused=!1,this.compactDesign=!1,this.tableId=""}internalTdsPropChangeListener(t){this.tableId===t.detail.tableId&&t.detail.changed.filter((t=>i.includes(t))).forEach((e=>{if(void 0===this[e])throw console.error(`Table prop is not supported: ${e}`),new Error(`Table prop is not supported: ${e}`);this[e]=t.detail[e]}))}connectedCallback(){const t=this.host.closest("tds-table");t?this.tableId=t.getAttribute("table-id"):console.error("Failed to find parent tds-table element.")}componentWillLoad(){const t=this.host.closest("tds-table");t?i.forEach((e=>{this[e]=t[e]})):console.error("Failed to find parent tds-table element.")}handleSlotChange(){this.validateSlot()}validateSlot(){const t=Array.from(this.host.children).filter((t=>"INPUT"===t.tagName));if(1!==t.length)console.warn("TABLE-HEADER-INPUT-WRAPPER: Wrapper only accepts input as children."),this.renderSlot=!1;else{this.renderSlot||(this.renderSlot=!0);const e=t[0];e.addEventListener("focus",(()=>{this.inputFocused=!0})),e.addEventListener("blur",(()=>{this.inputFocused=!1}))}}render(){return e(o,{key:"e92640dc4c88b52574960d7234b377d7e5eaaa8e",class:{"focused-input-wrapper":this.inputFocused,"show-icon":this.showIcon,"tds-table__compact":this.compactDesign}},this.renderSlot?e("slot",{onSlotchange:()=>this.handleSlotChange()}):null,this.showIcon?e("tds-icon",{svgTitle:"search",class:"search-icon",slot:"icon",size:"16px",name:"search"}):null)}get host(){return s(this)}};a.style=":host{position:relative}:host(:hover) tds-icon{display:inline-block}:host(.focused-input-wrapper) tds-icon{display:inline-block}:host(.focused-input-wrapper) ::slotted(input:not(:focus)){background-color:var(--tds-table-input-background-hover)}:host(.show-icon) ::slotted(input){padding-left:35px}tds-icon.search-icon{color:var(--tds-table-input-header-icon);position:absolute;left:15px;top:1px}::slotted(input){box-sizing:border-box;font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls);color:var(--tds-table-color);padding-left:var(--tds-spacing-element-16);padding-right:var(--tds-spacing-element-16);height:48px;border-radius:0;background-color:transparent;border:0;border-bottom:2px solid transparent}::slotted(input)::placeholder{color:var(--tds-table-input-header-placeholder)}::slotted(input:focus){outline:none;background-color:var(--tds-table-input-header-background-focus);border-bottom:2px solid var(--tds-text-field-bar)}:host(.tds-table__compact) ::slotted(input){height:32px;}";export{a as tds_table_header_input_wrapper}