UNPKG

@ionic/core

Version:
4 lines 1.69 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{r as t,h as o,e as s,f as e}from"./p-66a5d6a8.js";import{p as i}from"./p-3f4327f7.js";import{c as n}from"./p-47794def.js";import{x as a,y as r}from"./p-da2b833b.js";import{b as p}from"./p-597ff9af.js";const d=class{constructor(o){t(this,o),this.togglePasswordVisibility=()=>{const{inputElRef:t}=this;t&&(t.type="text"===t.type?"password":"text")},this.color=void 0,this.showIcon=void 0,this.hideIcon=void 0,this.type="password"}onTypeChange(t){"text"===t||"password"===t||i(`ion-input-password-toggle only supports inputs of type "text" or "password". 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:i("No ancestor ion-input found for ion-input-password-toggle. This component must be slotted inside of an ion-input.",t)}disconnectedCallback(){this.inputElRef=null}render(){var t,e;const{color:i,type:d}=this,l=p(this),c=null!==(t=this.showIcon)&&void 0!==t?t:a,h=null!==(e=this.hideIcon)&&void 0!==e?e:r,f="text"===d;return o(s,{key:"d9811e25bfeb2aa197352bb9be852e9e420739d5",class:n(i,{[l]:!0})},o("ion-button",{key:"1eaea1442b248fb2b8d61538b27274e647a07804",mode:l,color:i,fill:"clear",shape:"round","aria-checked":f?"true":"false","aria-label":"show password",role:"switch",type:"button",onPointerDown:t=>{t.preventDefault()},onClick:this.togglePasswordVisibility},o("ion-icon",{key:"9c88de8f4631d9bde222ce2edf6950d639e04773",slot:"icon-only","aria-hidden":"true",icon:f?h:c})))}get el(){return e(this)}static get watchers(){return{type:["onTypeChange"]}}};d.style={ios:"",md:""};export{d as ion_input_password_toggle}