@ionic/core
Version:
Base components for Ionic
4 lines • 1.63 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
import{r as t,f as o,h as s,d as e,g as i}from"./p-4DxY6_gG.js";import{c as n}from"./p-DiVJyqlX.js";import{x as a,y as r}from"./p-DV3sJJW8.js";import{b as p}from"./p-Br3vSlYh.js";const c=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:i,type:c}=this,d=p(this),l=null!==(t=this.showIcon)&&void 0!==t?t:r,h=null!==(o=this.hideIcon)&&void 0!==o?o:a,u="text"===c;return s(e,{key:"91bc55664d496fe457518bd112865dd7811d0c17",class:n(i,{[d]:!0})},s("ion-button",{key:"f3e436422110c9cb4d5c0b83500255b24ab4cdef",mode:d,color:i,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},s("ion-icon",{key:"5c8b121153f148f92aa7cba0447673a4f6f3ad1e",slot:"icon-only","aria-hidden":"true",icon:u?h:l})))}get el(){return i(this)}static get watchers(){return{type:["onTypeChange"]}}};c.style={ios:"",md:""};export{c as ion_input_password_toggle}