UNPKG

@ionic/core

Version:
4 lines 1.6 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{r as t,m as o,e as s,h as e,j as i,k as n}from"./p-B_U9CtaY.js";import{c as a}from"./p-DiVJyqlX.js";import{x as r,y as c}from"./p-BLV6ykCk.js";const p=class{constructor(o){t(this,o),this.type="password",this.togglePasswordVisibility=()=>{const{inputElRef:t}=this;t&&(t.type="text"===t.type?"password":"text")}}onTypeChange(t){"text"===t||"password"===t||o(`[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,s=this.inputElRef=t.closest("ion-input");s?this.type=s.type:o("[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(){var t,o;const{color:n,type:p}=this,d=s(this),l=null!==(t=this.showIcon)&&void 0!==t?t:c,h=null!==(o=this.hideIcon)&&void 0!==o?o:r,u="text"===p;return e(i,{key:"91bc55664d496fe457518bd112865dd7811d0c17",class:a(n,{[d]:!0})},e("ion-button",{key:"f3e436422110c9cb4d5c0b83500255b24ab4cdef",mode:d,color:n,fill:"clear",shape:"round","aria-checked":u?"true":"false","aria-label":u?"Hide password":"Show password",role:"switch",type:"button",onPointerDown:t=>{t.preventDefault()},onClick:this.togglePasswordVisibility},e("ion-icon",{key:"5c8b121153f148f92aa7cba0447673a4f6f3ad1e",slot:"icon-only","aria-hidden":"true",icon:u?h:l})))}get el(){return n(this)}static get watchers(){return{type:["onTypeChange"]}}};p.style={ios:"",md:""};export{p as ion_input_password_toggle}