@oslokommune/punkt-elements
Version:
Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo
24 lines • 2.43 kB
JavaScript
const e=require(`./element-DjtxO-1r.cjs`),t=require(`./class-map-CJ-msbHs.cjs`),n=require(`./element-with-slot-CWoTGA1B.cjs`),r=require(`./icon-Dr8sfT2X.cjs`),i=require(`./utils-CM67Oudc.cjs`),a=require(`./input-wrapper-CQGoyLdZ.cjs`);var o=class extends n.t{constructor(...e){super(...e),this.forId=i.n(),this.helptext=``,this.helptextDropdown=``,this.helptextDropdownButton=a.t.props.helptextDropdownButton.default,this.isHelpTextOpen=!1}render(){let i=()=>{let e=!this.isHelpTextOpen;this.isHelpTextOpen=e,this.dispatchEvent(new CustomEvent(`toggleHelpText`,{bubbles:!0,detail:{isOpen:e}}))},a=t.t({"pkt-inputwrapper__helptext-container":!0,"pkt-inputwrapper__has-helptext":this.helptext||this.helptextDropdown||this.hasSlotContent()});return e.d`${e.d`<div class="${a}">
<div class="pkt-inputwrapper__helptext" id="${this.forId}-helptext">
<div class="pkt-contents" name="helptext">${n.n(this)}</div>
${this.helptext&&r.r(this.helptext)}
</div>
${this.helptextDropdown?e.d`<div class="pkt-inputwrapper__helptext-expandable">
<button
class="pkt-link pkt-link--icon-right pkt-btn pkt-btn--small pkt-btn--tertiary pkt-btn--icon-right"
type="button"
@click=${i}
>
<pkt-icon
class="pkt-btn__icon"
name="${this.isHelpTextOpen?`chevron-thin-up`:`chevron-thin-down`}"
></pkt-icon>
<span class="pkt-btn__text">${r.r(this.helptextDropdownButton)}</span>
</button>
<div
class="${t.t({"pkt-inputwrapper__helptext":!0,"pkt-inputwrapper__helptext-expandable-open":this.isHelpTextOpen,"pkt-inputwrapper__helptext-expandable-closed":!this.isHelpTextOpen})}"
>
${r.r(this.helptextDropdown)}
</div>
</div>`:e.l}
</div>`}`}};e.r([e.s({type:String,reflect:!0})],o.prototype,`forId`,void 0),e.r([e.s({type:String})],o.prototype,`helptext`,void 0),e.r([e.s({type:String})],o.prototype,`helptextDropdown`,void 0),e.r([e.s({type:String})],o.prototype,`helptextDropdownButton`,void 0),e.r([e.o()],o.prototype,`isHelpTextOpen`,void 0);try{e.c(`pkt-helptext`)(o)}catch{console.warn(`Forsøker å definere <pkt-helptext>, men den er allerede definert`)}var s=o;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});