UNPKG

@ionic/core

Version:
4 lines • 2.32 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{d as t,H as o,p as e,h as s,f as n,t as i}from"./p-Ct2aBEue.js";import{c as a}from"./p-byZM6qHV.js";import{l as p,m as c}from"./p-LpMHEu3v.js";import{b as r}from"./p-HthJZjZ6.js";import{d}from"./p-DDI6VLW9.js";import{d as l}from"./p-ChkSQqfP.js";import{d as u}from"./p-7KepMw9O.js";const f=t(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.type="password",this.togglePasswordVisibility=()=>{const{inputElRef:t}=this;t&&(t.type="text"===t.type?"password":"text")}}onTypeChange(t){"text"===t||"password"===t||e(`[ion-input-password-toggle] - Only inputs of type "text" or "password" are supported. Input of type "${t}" is not compatible.`,this.el)}connectedCallback(){const{el:t}=this,o=this.inputElRef=t.closest("ion-input");o?this.type=o.type:e("[ion-input-password-toggle] - No ancestor ion-input found. This component must be slotted inside of an ion-input.",t)}disconnectedCallback(){this.inputElRef=null}render(){const{color:t,type:o}=this,e=r(this),i=this.showIcon??c,d=this.hideIcon??p,l="text"===o;return s(n,{key:"15a29e51abc236cc21943225ed377f5edca7d103",class:a(t,{[e]:!0})},s("ion-button",{key:"cc9c290e809db66c14aaf63eb496ccf94d3f6414",mode:e,color:t,fill:"clear",shape:"round","aria-label":l?"Hide password":"Show password","aria-pressed":l?"true":"false",type:"button",onPointerDown:t=>{t.preventDefault()},onClick:this.togglePasswordVisibility},s("ion-icon",{key:"8d1f5143bedabcff2a8792f35ef07fdac1236fd5",slot:"icon-only","aria-hidden":"true",icon:l?d:i})))}get el(){return this}static get watchers(){return{type:[{onTypeChange:0}]}}static get style(){return{ios:"",md:""}}},[33,"ion-input-password-toggle",{color:[513],showIcon:[1,"show-icon"],hideIcon:[1,"hide-icon"],type:[1025]},void 0,{type:[{onTypeChange:0}]}]),m=f,h=function(){"undefined"!=typeof customElements&&["ion-input-password-toggle","ion-button","ion-icon","ion-ripple-effect"].forEach((t=>{switch(t){case"ion-input-password-toggle":customElements.get(i(t))||customElements.define(i(t),f);break;case"ion-button":customElements.get(i(t))||d();break;case"ion-icon":customElements.get(i(t))||l();break;case"ion-ripple-effect":customElements.get(i(t))||u()}}))};export{m as IonInputPasswordToggle,h as defineCustomElement}