UNPKG

@ionic/core

Version:
4 lines 2.53 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-738d7504.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-ca86cf32.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 supports inputs of type "text" or "password". 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("No ancestor ion-input found for ion-input-password-toggle. 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:"d9811e25bfeb2aa197352bb9be852e9e420739d5",class:createColorClasses(s,(e={},e[i]=true,e))},h("ion-button",{key:"1eaea1442b248fb2b8d61538b27274e647a07804",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:"9c88de8f4631d9bde222ce2edf6950d639e04773",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};