@govtechsg/sgds-web-component 3.5.2-rc.0 → 3.5.2-rc.1

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.
@@ -2004,7 +2004,7 @@ const tt=1,it=2,lt=e=>(...t)=>({_$litDirective$:e,values:t});class ot{constructo
2004
2004
  `}}dl.styles=[cl],t([Ge({type:Boolean,reflect:!0})],dl.prototype,"active",void 0),t([Ge({type:Boolean,reflect:!0})],dl.prototype,"disabled",void 0),t([Ge({type:String})],dl.prototype,"value",void 0);class hl extends dl{constructor(){super(...arguments),this._renderItemContent=()=>Q`<div class="normal-item-content">
2005
2005
  <slot></slot>
2006
2006
  ${this.active?Q` <sgds-icon name="check"></sgds-icon> `:ie}
2007
- </div>`}}hl.dependencies={"sgds-icon":al};class vl extends ll{constructor(){super(...arguments),this._blockInputKeydown=e=>{"Tab"!==e.key&&e.preventDefault()}}connectedCallback(){super.connectedCallback(),this.addEventListener("sgds-hide",(async()=>{(await this._input).focus()}))}async firstUpdated(){super.firstUpdated(),console.log(this.options,"before awaiting");const e=this.options.map((async e=>await e.updateComplete));if(await Promise.all(e),console.log(this.options,"after awaiting"),this.menuList=this.options.length>0?this._getMenuListFromOptions():this.menuList,this.value){const e=this.menuList.filter((({value:e})=>e===this.value));this.displayValue=e[0].label,this._setActiveToOption()}this.input=await this._input,this._mixinValidate(this.input),this.menuIsOpen&&!this.readonly&&this.showMenu()}_setActiveToOption(){const e=this.menuList.findIndex((e=>e.value.toString()===this.value));this.options.forEach(((t,i)=>{t.active=i===e}))}async _handleValueChange(){this._setActiveToOption(),this.relayNativeEvent(new Event("change",{bubbles:!0,composed:!0})),this.emit("sgds-change"),this.value&&this.emit("sgds-select");const e=await this._input;this._mixinSetFormValue(),this._mixinValidate(e),(this._isTouched||""!==this.value)&&(this.invalid=!this._mixinReportValidity())}async _handleItemSelected(e){var t,i,l;const o=e.target,n=null!==(i=null===(t=o.textContent)||void 0===t?void 0:t.trim())&&void 0!==i?i:"",a={label:n,value:null!==(l=o.getAttribute("value"))&&void 0!==l?l:n};this.value=a.value.toString(),this.displayValue=a.label,this.hideMenu()}_handleFocus(){this.emit("sgds-focus")}async _handleInputBlur(e){e.preventDefault(),this.emit("sgds-blur")}async _mixinResetFormControl(){this.value=this.defaultValue;const e=this.menuList.filter((({value:e})=>e===this.value));e.length<=0?this.displayValue="":this.displayValue=e[0].label,this._mixinResetValidity(await this._input)}_renderEmptyMenu(){return Q` <div class="empty-menu">No options</div> `}_renderMenu(){const e=this.menuList.map((e=>{const t=e.value===this.value;return Q`
2007
+ </div>`}}hl.dependencies={"sgds-icon":al};class vl extends ll{constructor(){super(...arguments),this._blockInputKeydown=e=>{"Tab"!==e.key&&e.preventDefault()}}connectedCallback(){super.connectedCallback(),this.addEventListener("sgds-hide",(async()=>{(await this._input).focus()}))}get menuListFromlightDomOptions(){return this.lighDomOptions.map((e=>({disabled:e.hasAttribute("disabled"),value:e.getAttribute("value"),label:e.textContent})))}get lighDomOptions(){return Array.from(this.querySelectorAll("sgds-select-options"))}async firstUpdated(){if(super.firstUpdated(),this.options.length>0?this.menuList=this._getMenuListFromOptions():this.lighDomOptions.length>0&&(this.menuList=this.menuListFromlightDomOptions),this.value){const e=this.menuList.filter((({value:e})=>e===this.value));this.displayValue=e[0].label,this._setActiveToOption()}this.input=await this._input,this._mixinValidate(this.input),this.menuIsOpen&&!this.readonly&&this.showMenu()}_setActiveToOption(){const e=this.menuList.findIndex((e=>e.value.toString()===this.value));this.options.forEach(((t,i)=>{t.active=i===e}))}async _handleValueChange(){this._setActiveToOption(),this.relayNativeEvent(new Event("change",{bubbles:!0,composed:!0})),this.emit("sgds-change"),this.value&&this.emit("sgds-select");const e=await this._input;this._mixinSetFormValue(),this._mixinValidate(e),(this._isTouched||""!==this.value)&&(this.invalid=!this._mixinReportValidity())}async _handleItemSelected(e){var t,i,l;const o=e.target,n=null!==(i=null===(t=o.textContent)||void 0===t?void 0:t.trim())&&void 0!==i?i:"",a={label:n,value:null!==(l=o.getAttribute("value"))&&void 0!==l?l:n};this.value=a.value.toString(),this.displayValue=a.label,this.hideMenu()}_handleFocus(){this.emit("sgds-focus")}async _handleInputBlur(e){e.preventDefault(),this.emit("sgds-blur")}async _mixinResetFormControl(){this.value=this.defaultValue;const e=this.menuList.filter((({value:e})=>e===this.value));e.length<=0?this.displayValue="":this.displayValue=e[0].label,this._mixinResetValidity(await this._input)}_renderEmptyMenu(){return Q` <div class="empty-menu">No options</div> `}_renderMenu(){const e=this.menuList.map((e=>{const t=e.value===this.value;return Q`
2008
2008
  <sgds-select-option
2009
2009
  ?active=${t}
2010
2010
  value=${e.value}