UNPKG

@ionic/core

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