UNPKG

@ionic/core

Version:
4 lines 2.54 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{r as registerInstance,h,e as Host,f as getElement}from"./index-527b9e34.js";import{p as printIonWarning}from"./index-cfd9c1f2.js";import{c as createColorClasses}from"./theme-01f3f29c.js";import{x as eye,y as eyeOff}from"./index-e2cf2ceb.js";import{b as getIonMode}from"./ionic-global-b26f573e.js";var iosInputPasswordToggleCss="";var IonInputPasswordToggleIosStyle0=iosInputPasswordToggleCss;var mdInputPasswordToggleCss="";var IonInputPasswordToggleMdStyle0=mdInputPasswordToggleCss;var InputPasswordToggle=function(){function e(e){var t=this;registerInstance(this,e);this.togglePasswordVisibility=function(){var e=t.inputElRef;if(!e){return}e.type=e.type==="text"?"password":"text"};this.color=undefined;this.showIcon=undefined;this.hideIcon=undefined;this.type="password"}e.prototype.onTypeChange=function(e){if(e!=="text"&&e!=="password"){printIonWarning('[ion-input-password-toggle] - Only inputs of type "text" or "password" are supported. Input of type "'.concat(e,'" is not compatible.'),this.el);return}};e.prototype.connectedCallback=function(){var e=this.el;var t=this.inputElRef=e.closest("ion-input");if(!t){printIonWarning("[ion-input-password-toggle] - No ancestor ion-input found. This component must be slotted inside of an ion-input.",e);return}this.type=t.type};e.prototype.disconnectedCallback=function(){this.inputElRef=null};e.prototype.render=function(){var e;var t,o;var n=this,s=n.color,r=n.type;var i=getIonMode(this);var a=(t=this.showIcon)!==null&&t!==void 0?t:eye;var u=(o=this.hideIcon)!==null&&o!==void 0?o:eyeOff;var d=r==="text";return h(Host,{key:"1a28e078c83e74c72d8bb8189ece93ec2e3fa3d0",class:createColorClasses(s,(e={},e[i]=true,e))},h("ion-button",{key:"039d1bab764093bb6fe4a34299b0872abda087fd",mode:i,color:s,fill:"clear",shape:"round","aria-checked":d?"true":"false","aria-label":"show password",role:"switch",type:"button",onPointerDown:function(e){e.preventDefault()},onClick:this.togglePasswordVisibility},h("ion-icon",{key:"26477ee97b808c3d79944bf5e33d4e05f1ae0b3f",slot:"icon-only","aria-hidden":"true",icon:d?u:a})))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{type:["onTypeChange"]}},enumerable:false,configurable:true});return e}();InputPasswordToggle.style={ios:IonInputPasswordToggleIosStyle0,md:IonInputPasswordToggleMdStyle0};export{InputPasswordToggle as ion_input_password_toggle};