@ionic/core
Version:
Base components for Ionic
4 lines • 1.56 kB
JavaScript
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/
import{r as t,a as s,h as o,f as e,g as n}from"./p-BpRUsN_W.js";import{c as i}from"./p-byZM6qHV.js";import{x as a,y as r}from"./p-BvabGprD.js";import{b as p}from"./p-SEecsUh7.js";const c=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(){const{color:t,type:s}=this,n=p(this),c=this.showIcon??r,d=this.hideIcon??a,l="text"===s;return o(e,{key:"15a29e51abc236cc21943225ed377f5edca7d103",class:i(t,{[n]:!0})},o("ion-button",{key:"cc9c290e809db66c14aaf63eb496ccf94d3f6414",mode:n,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},o("ion-icon",{key:"8d1f5143bedabcff2a8792f35ef07fdac1236fd5",slot:"icon-only","aria-hidden":"true",icon:l?d:c})))}get el(){return n(this)}static get watchers(){return{type:[{onTypeChange:0}]}}};c.style={ios:"",md:""};export{c as ion_input_password_toggle}