UNPKG

@limetech/lime-elements

Version:
45 lines • 31.7 kB
import{_ as t,a as n,M as i,c as e,b as r,m as u}from"./p-ChRGk668.js";import{a as s,M as o,b as c}from"./p-BN1-aIOw.js";import{a as h,M as f}from"./p-C9yTLqR8.js"; /** * @license * Copyright 2018 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */var a={LINE_RIPPLE_ACTIVE:"mdc-line-ripple--active",LINE_RIPPLE_DEACTIVATING:"mdc-line-ripple--deactivating"},l=function(i){function e(t){var r=i.call(this,n(n({},e.defaultAdapter),t))||this;return r.transitionEndHandler=function(t){r.handleTransitionEnd(t)},r}return t(e,i),Object.defineProperty(e,"cssClasses",{get:function(){return a},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},setStyle:function(){},registerEventHandler:function(){},deregisterEventHandler:function(){}}},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.adapter.registerEventHandler("transitionend",this.transitionEndHandler)},e.prototype.destroy=function(){this.adapter.deregisterEventHandler("transitionend",this.transitionEndHandler)},e.prototype.activate=function(){this.adapter.removeClass(a.LINE_RIPPLE_DEACTIVATING),this.adapter.addClass(a.LINE_RIPPLE_ACTIVE)},e.prototype.setRippleCenter=function(t){this.adapter.setStyle("transform-origin",t+"px center")},e.prototype.deactivate=function(){this.adapter.addClass(a.LINE_RIPPLE_DEACTIVATING)},e.prototype.handleTransitionEnd=function(t){var n=this.adapter.hasClass(a.LINE_RIPPLE_DEACTIVATING);"opacity"===t.propertyName&&n&&(this.adapter.removeClass(a.LINE_RIPPLE_ACTIVE),this.adapter.removeClass(a.LINE_RIPPLE_DEACTIVATING))},e}(i),d=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return t(i,n),i.attachTo=function(t){return new i(t)},i.prototype.activate=function(){this.foundation.activate()},i.prototype.deactivate=function(){this.foundation.deactivate()},i.prototype.setRippleCenter=function(t){this.foundation.setRippleCenter(t)},i.prototype.getDefaultFoundation=function(){var t=this;return new l({addClass:function(n){return t.root.classList.add(n)},removeClass:function(n){return t.root.classList.remove(n)},hasClass:function(n){return t.root.classList.contains(n)},setStyle:function(n,i){return t.root.style.setProperty(n,i)},registerEventHandler:function(n,i){return t.listen(n,i)},deregisterEventHandler:function(n,i){return t.unlisten(n,i)}})},i}(e),b={NOTCH_ELEMENT_SELECTOR:".mdc-notched-outline__notch"},g={NOTCH_ELEMENT_PADDING:8},m={NO_LABEL:"mdc-notched-outline--no-label",OUTLINE_NOTCHED:"mdc-notched-outline--notched",OUTLINE_UPGRADED:"mdc-notched-outline--upgraded"},v=function(i){function e(t){return i.call(this,n(n({},e.defaultAdapter),t))||this}return t(e,i),Object.defineProperty(e,"strings",{get:function(){return b},enumerable:!1,configurable:!0}),Object.defineProperty(e,"cssClasses",{get:function(){return m},enumerable:!1,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return g},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},setNotchWidthProperty:function(){},removeNotchWidthProperty:function(){}}},enumerable:!1,configurable:!0}),e.prototype.notch=function(t){var n=e.cssClasses.OUTLINE_NOTCHED;t>0&&(t+=g.NOTCH_ELEMENT_PADDING),this.adapter.setNotchWidthProperty(t),this.adapter.addClass(n)},e.prototype.closeNotch=function(){this.adapter.removeClass(e.cssClasses.OUTLINE_NOTCHED),this.adapter.removeNotchWidthProperty()},e}(i),O=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return t(i,n),i.attachTo=function(t){return new i(t)},i.prototype.initialSyncWithDOM=function(){this.notchElement=this.root.querySelector(b.NOTCH_ELEMENT_SELECTOR);var t=this.root.querySelector("."+h.cssClasses.ROOT);t?(t.style.transitionDuration="0s",this.root.classList.add(m.OUTLINE_UPGRADED),requestAnimationFrame((function(){t.style.transitionDuration=""}))):this.root.classList.add(m.NO_LABEL)},i.prototype.notch=function(t){this.foundation.notch(t)},i.prototype.closeNotch=function(){this.foundation.closeNotch()},i.prototype.getDefaultFoundation=function(){var t=this;return new v({addClass:function(n){return t.root.classList.add(n)},removeClass:function(n){return t.root.classList.remove(n)},setNotchWidthProperty:function(n){t.notchElement.style.setProperty("width",n+"px")},removeNotchWidthProperty:function(){t.notchElement.style.removeProperty("width")}})},i}(e),E={ROOT:"mdc-text-field-character-counter"},I={ROOT_SELECTOR:"."+E.ROOT},C=function(i){function e(t){return i.call(this,n(n({},e.defaultAdapter),t))||this}return t(e,i),Object.defineProperty(e,"cssClasses",{get:function(){return E},enumerable:!1,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return I},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{setContent:function(){}}},enumerable:!1,configurable:!0}),e.prototype.setCounterValue=function(t,n){t=Math.min(t,n),this.adapter.setContent(t+" / "+n)},e}(i),L=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return t(i,n),i.attachTo=function(t){return new i(t)},Object.defineProperty(i.prototype,"foundationForTextField",{get:function(){return this.foundation},enumerable:!1,configurable:!0}),i.prototype.getDefaultFoundation=function(){var t=this;return new C({setContent:function(n){t.root.textContent=n}})},i}(e),p={ARIA_CONTROLS:"aria-controls",ARIA_DESCRIBEDBY:"aria-describedby",INPUT_SELECTOR:".mdc-text-field__input",LABEL_SELECTOR:".mdc-floating-label",LEADING_ICON_SELECTOR:".mdc-text-field__icon--leading",LINE_RIPPLE_SELECTOR:".mdc-line-ripple",OUTLINE_SELECTOR:".mdc-notched-outline",PREFIX_SELECTOR:".mdc-text-field__affix--prefix",SUFFIX_SELECTOR:".mdc-text-field__affix--suffix",TRAILING_ICON_SELECTOR:".mdc-text-field__icon--trailing"},T={DISABLED:"mdc-text-field--disabled",FOCUSED:"mdc-text-field--focused",HELPER_LINE:"mdc-text-field-helper-line",INVALID:"mdc-text-field--invalid",LABEL_FLOATING:"mdc-text-field--label-floating",NO_LABEL:"mdc-text-field--no-label",OUTLINED:"mdc-text-field--outlined",ROOT:"mdc-text-field",TEXTAREA:"mdc-text-field--textarea",WITH_LEADING_ICON:"mdc-text-field--with-leading-icon",WITH_TRAILING_ICON:"mdc-text-field--with-trailing-icon",WITH_INTERNAL_COUNTER:"mdc-text-field--with-internal-counter"},A={LABEL_SCALE:.75},x=["pattern","min","max","required","step","minlength","maxlength"],_=["color","date","datetime-local","month","range","time","week"],R=["mousedown","touchstart"],j=["click","keydown"],N=function(i){function e(t,r){void 0===r&&(r={});var u=i.call(this,n(n({},e.defaultAdapter),t))||this;return u.isFocused=!1,u.receivedUserInput=!1,u.valid=!0,u.useNativeValidation=!0,u.validateOnValueChange=!0,u.helperText=r.helperText,u.characterCounter=r.characterCounter,u.leadingIcon=r.leadingIcon,u.trailingIcon=r.trailingIcon,u.inputFocusHandler=function(){u.activateFocus()},u.inputBlurHandler=function(){u.deactivateFocus()},u.inputInputHandler=function(){u.handleInput()},u.setPointerXOffset=function(t){u.setTransformOrigin(t)},u.textFieldInteractionHandler=function(){u.handleTextFieldInteraction()},u.validationAttributeChangeHandler=function(t){u.handleValidationAttributeChange(t)},u}return t(e,i),Object.defineProperty(e,"cssClasses",{get:function(){return T},enumerable:!1,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return p},enumerable:!1,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return A},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shouldAlwaysFloat",{get:function(){var t=this.getNativeInput().type;return _.indexOf(t)>=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shouldFloat",{get:function(){return this.shouldAlwaysFloat||this.isFocused||!!this.getValue()||this.isBadInput()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shouldShake",{get:function(){return!this.isFocused&&!this.isValid()&&!!this.getValue()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!0},setInputAttr:function(){},removeInputAttr:function(){},registerTextFieldInteractionHandler:function(){},deregisterTextFieldInteractionHandler:function(){},registerInputInteractionHandler:function(){},deregisterInputInteractionHandler:function(){},registerValidationAttributeChangeHandler:function(){return new MutationObserver((function(){}))},deregisterValidationAttributeChangeHandler:function(){},getNativeInput:function(){return null},isFocused:function(){return!1},activateLineRipple:function(){},deactivateLineRipple:function(){},setLineRippleTransformOrigin:function(){},shakeLabel:function(){},floatLabel:function(){},setLabelRequired:function(){},hasLabel:function(){return!1},getLabelWidth:function(){return 0},hasOutline:function(){return!1},notchOutline:function(){},closeOutline:function(){}}},enumerable:!1,configurable:!0}),e.prototype.init=function(){var t,n,i,e;this.adapter.hasLabel()&&this.getNativeInput().required&&this.adapter.setLabelRequired(!0),this.adapter.isFocused()?this.inputFocusHandler():this.adapter.hasLabel()&&this.shouldFloat&&(this.notchOutline(!0),this.adapter.floatLabel(!0),this.styleFloating(!0)),this.adapter.registerInputInteractionHandler("focus",this.inputFocusHandler),this.adapter.registerInputInteractionHandler("blur",this.inputBlurHandler),this.adapter.registerInputInteractionHandler("input",this.inputInputHandler);try{for(var u=r(R),s=u.next();!s.done;s=u.next())this.adapter.registerInputInteractionHandler(s.value,this.setPointerXOffset)}catch(n){t={error:n}}finally{try{s&&!s.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}try{for(var o=r(j),c=o.next();!c.done;c=o.next())this.adapter.registerTextFieldInteractionHandler(c.value,this.textFieldInteractionHandler)}catch(t){i={error:t}}finally{try{c&&!c.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}this.validationObserver=this.adapter.registerValidationAttributeChangeHandler(this.validationAttributeChangeHandler),this.setcharacterCounter(this.getValue().length)},e.prototype.destroy=function(){var t,n,i,e;this.adapter.deregisterInputInteractionHandler("focus",this.inputFocusHandler),this.adapter.deregisterInputInteractionHandler("blur",this.inputBlurHandler),this.adapter.deregisterInputInteractionHandler("input",this.inputInputHandler);try{for(var u=r(R),s=u.next();!s.done;s=u.next())this.adapter.deregisterInputInteractionHandler(s.value,this.setPointerXOffset)}catch(n){t={error:n}}finally{try{s&&!s.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}try{for(var o=r(j),c=o.next();!c.done;c=o.next())this.adapter.deregisterTextFieldInteractionHandler(c.value,this.textFieldInteractionHandler)}catch(t){i={error:t}}finally{try{c&&!c.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}this.adapter.deregisterValidationAttributeChangeHandler(this.validationObserver)},e.prototype.handleTextFieldInteraction=function(){var t=this.adapter.getNativeInput();t&&t.disabled||(this.receivedUserInput=!0)},e.prototype.handleValidationAttributeChange=function(t){var n=this;t.some((function(t){return x.indexOf(t)>-1&&(n.styleValidity(!0),n.adapter.setLabelRequired(n.getNativeInput().required),!0)})),t.indexOf("maxlength")>-1&&this.setcharacterCounter(this.getValue().length)},e.prototype.notchOutline=function(t){if(this.adapter.hasOutline()&&this.adapter.hasLabel())if(t){var n=this.adapter.getLabelWidth()*A.LABEL_SCALE;this.adapter.notchOutline(n)}else this.adapter.closeOutline()},e.prototype.activateFocus=function(){this.isFocused=!0,this.styleFocused(this.isFocused),this.adapter.activateLineRipple(),this.adapter.hasLabel()&&(this.notchOutline(this.shouldFloat),this.adapter.floatLabel(this.shouldFloat),this.styleFloating(this.shouldFloat),this.adapter.shakeLabel(this.shouldShake)),!this.helperText||!this.helperText.isPersistent()&&this.helperText.isValidation()&&this.valid||this.helperText.showToScreenReader()},e.prototype.setTransformOrigin=function(t){if(!this.isDisabled()&&!this.adapter.hasOutline()){var n=t.touches,i=n?n[0]:t,e=i.target.getBoundingClientRect();this.adapter.setLineRippleTransformOrigin(i.clientX-e.left)}},e.prototype.handleInput=function(){this.autoCompleteFocus(),this.setcharacterCounter(this.getValue().length)},e.prototype.autoCompleteFocus=function(){this.receivedUserInput||this.activateFocus()},e.prototype.deactivateFocus=function(){this.isFocused=!1,this.adapter.deactivateLineRipple();var t=this.isValid();this.styleValidity(t),this.styleFocused(this.isFocused),this.adapter.hasLabel()&&(this.notchOutline(this.shouldFloat),this.adapter.floatLabel(this.shouldFloat),this.styleFloating(this.shouldFloat),this.adapter.shakeLabel(this.shouldShake)),this.shouldFloat||(this.receivedUserInput=!1)},e.prototype.getValue=function(){return this.getNativeInput().value},e.prototype.setValue=function(t){if(this.getValue()!==t&&(this.getNativeInput().value=t),this.setcharacterCounter(t.length),this.validateOnValueChange){var n=this.isValid();this.styleValidity(n)}this.adapter.hasLabel()&&(this.notchOutline(this.shouldFloat),this.adapter.floatLabel(this.shouldFloat),this.styleFloating(this.shouldFloat),this.validateOnValueChange&&this.adapter.shakeLabel(this.shouldShake))},e.prototype.isValid=function(){return this.useNativeValidation?this.isNativeInputValid():this.valid},e.prototype.setValid=function(t){this.valid=t,this.styleValidity(t);var n=!t&&!this.isFocused&&!!this.getValue();this.adapter.hasLabel()&&this.adapter.shakeLabel(n)},e.prototype.setValidateOnValueChange=function(t){this.validateOnValueChange=t},e.prototype.getValidateOnValueChange=function(){return this.validateOnValueChange},e.prototype.setUseNativeValidation=function(t){this.useNativeValidation=t},e.prototype.isDisabled=function(){return this.getNativeInput().disabled},e.prototype.setDisabled=function(t){this.getNativeInput().disabled=t,this.styleDisabled(t)},e.prototype.setHelperTextContent=function(t){this.helperText&&this.helperText.setContent(t)},e.prototype.setLeadingIconAriaLabel=function(t){this.leadingIcon&&this.leadingIcon.setAriaLabel(t)},e.prototype.setLeadingIconContent=function(t){this.leadingIcon&&this.leadingIcon.setContent(t)},e.prototype.setTrailingIconAriaLabel=function(t){this.trailingIcon&&this.trailingIcon.setAriaLabel(t)},e.prototype.setTrailingIconContent=function(t){this.trailingIcon&&this.trailingIcon.setContent(t)},e.prototype.setcharacterCounter=function(t){if(this.characterCounter){var n=this.getNativeInput().maxLength;if(-1===n)throw new Error("MDCTextFieldFoundation: Expected maxlength html property on text input or textarea.");this.characterCounter.setCounterValue(t,n)}},e.prototype.isBadInput=function(){return this.getNativeInput().validity.badInput||!1},e.prototype.isNativeInputValid=function(){return this.getNativeInput().validity.valid},e.prototype.styleValidity=function(t){var n=e.cssClasses.INVALID;if(t?this.adapter.removeClass(n):this.adapter.addClass(n),this.helperText){if(this.helperText.setValidity(t),!this.helperText.isValidation())return;var i=this.helperText.isVisible(),r=this.helperText.getId();i&&r?this.adapter.setInputAttr(p.ARIA_DESCRIBEDBY,r):this.adapter.removeInputAttr(p.ARIA_DESCRIBEDBY)}},e.prototype.styleFocused=function(t){var n=e.cssClasses.FOCUSED;t?this.adapter.addClass(n):this.adapter.removeClass(n)},e.prototype.styleDisabled=function(t){var n=e.cssClasses,i=n.DISABLED,r=n.INVALID;t?(this.adapter.addClass(i),this.adapter.removeClass(r)):this.adapter.removeClass(i),this.leadingIcon&&this.leadingIcon.setDisabled(t),this.trailingIcon&&this.trailingIcon.setDisabled(t)},e.prototype.styleFloating=function(t){var n=e.cssClasses.LABEL_FLOATING;t?this.adapter.addClass(n):this.adapter.removeClass(n)},e.prototype.getNativeInput=function(){return(this.adapter?this.adapter.getNativeInput():null)||{disabled:!1,maxLength:-1,required:!1,type:"input",validity:{badInput:!1,valid:!0},value:""}},e}(i),w={HELPER_TEXT_PERSISTENT:"mdc-text-field-helper-text--persistent",HELPER_TEXT_VALIDATION_MSG:"mdc-text-field-helper-text--validation-msg",ROOT:"mdc-text-field-helper-text"},y={ARIA_HIDDEN:"aria-hidden",ROLE:"role",ROOT_SELECTOR:"."+w.ROOT},H=function(i){function e(t){return i.call(this,n(n({},e.defaultAdapter),t))||this}return t(e,i),Object.defineProperty(e,"cssClasses",{get:function(){return w},enumerable:!1,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return y},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClass:function(){},removeClass:function(){},hasClass:function(){return!1},getAttr:function(){return null},setAttr:function(){},removeAttr:function(){},setContent:function(){}}},enumerable:!1,configurable:!0}),e.prototype.getId=function(){return this.adapter.getAttr("id")},e.prototype.isVisible=function(){return"true"!==this.adapter.getAttr(y.ARIA_HIDDEN)},e.prototype.setContent=function(t){this.adapter.setContent(t)},e.prototype.isPersistent=function(){return this.adapter.hasClass(w.HELPER_TEXT_PERSISTENT)},e.prototype.setPersistent=function(t){t?this.adapter.addClass(w.HELPER_TEXT_PERSISTENT):this.adapter.removeClass(w.HELPER_TEXT_PERSISTENT)},e.prototype.isValidation=function(){return this.adapter.hasClass(w.HELPER_TEXT_VALIDATION_MSG)},e.prototype.setValidation=function(t){t?this.adapter.addClass(w.HELPER_TEXT_VALIDATION_MSG):this.adapter.removeClass(w.HELPER_TEXT_VALIDATION_MSG)},e.prototype.showToScreenReader=function(){this.adapter.removeAttr(y.ARIA_HIDDEN)},e.prototype.setValidity=function(t){var n=this.adapter.hasClass(w.HELPER_TEXT_PERSISTENT),i=this.adapter.hasClass(w.HELPER_TEXT_VALIDATION_MSG)&&!t;i?(this.showToScreenReader(),"alert"===this.adapter.getAttr(y.ROLE)?this.refreshAlertRole():this.adapter.setAttr(y.ROLE,"alert")):this.adapter.removeAttr(y.ROLE),n||i||this.hide()},e.prototype.hide=function(){this.adapter.setAttr(y.ARIA_HIDDEN,"true")},e.prototype.refreshAlertRole=function(){var t=this;this.adapter.removeAttr(y.ROLE),requestAnimationFrame((function(){t.adapter.setAttr(y.ROLE,"alert")}))},e}(i),F=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return t(i,n),i.attachTo=function(t){return new i(t)},Object.defineProperty(i.prototype,"foundationForTextField",{get:function(){return this.foundation},enumerable:!1,configurable:!0}),i.prototype.getDefaultFoundation=function(){var t=this;return new H({addClass:function(n){return t.root.classList.add(n)},removeClass:function(n){return t.root.classList.remove(n)},hasClass:function(n){return t.root.classList.contains(n)},getAttr:function(n){return t.root.getAttribute(n)},setAttr:function(n,i){return t.root.setAttribute(n,i)},removeAttr:function(n){return t.root.removeAttribute(n)},setContent:function(n){t.root.textContent=n}})},i}(e),S={ICON_EVENT:"MDCTextField:icon",ICON_ROLE:"button"},D={ROOT:"mdc-text-field__icon"},P=["click","keydown"],M=function(i){function e(t){var r=i.call(this,n(n({},e.defaultAdapter),t))||this;return r.savedTabIndex=null,r.interactionHandler=function(t){r.handleInteraction(t)},r}return t(e,i),Object.defineProperty(e,"strings",{get:function(){return S},enumerable:!1,configurable:!0}),Object.defineProperty(e,"cssClasses",{get:function(){return D},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{getAttr:function(){return null},setAttr:function(){},removeAttr:function(){},setContent:function(){},registerInteractionHandler:function(){},deregisterInteractionHandler:function(){},notifyIconAction:function(){}}},enumerable:!1,configurable:!0}),e.prototype.init=function(){var t,n;this.savedTabIndex=this.adapter.getAttr("tabindex");try{for(var i=r(P),e=i.next();!e.done;e=i.next())this.adapter.registerInteractionHandler(e.value,this.interactionHandler)}catch(n){t={error:n}}finally{try{e&&!e.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},e.prototype.destroy=function(){var t,n;try{for(var i=r(P),e=i.next();!e.done;e=i.next())this.adapter.deregisterInteractionHandler(e.value,this.interactionHandler)}catch(n){t={error:n}}finally{try{e&&!e.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},e.prototype.setDisabled=function(t){this.savedTabIndex&&(t?(this.adapter.setAttr("tabindex","-1"),this.adapter.removeAttr("role")):(this.adapter.setAttr("tabindex",this.savedTabIndex),this.adapter.setAttr("role",S.ICON_ROLE)))},e.prototype.setAriaLabel=function(t){this.adapter.setAttr("aria-label",t)},e.prototype.setContent=function(t){this.adapter.setContent(t)},e.prototype.handleInteraction=function(t){("click"===t.type||"Enter"===t.key||13===t.keyCode)&&(t.preventDefault(),this.adapter.notifyIconAction())},e}(i),B=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return t(i,n),i.attachTo=function(t){return new i(t)},Object.defineProperty(i.prototype,"foundationForTextField",{get:function(){return this.foundation},enumerable:!1,configurable:!0}),i.prototype.getDefaultFoundation=function(){var t=this;return new M({getAttr:function(n){return t.root.getAttribute(n)},setAttr:function(n,i){return t.root.setAttribute(n,i)},removeAttr:function(n){return t.root.removeAttribute(n)},setContent:function(n){t.root.textContent=n},registerInteractionHandler:function(n,i){return t.listen(n,i)},deregisterInteractionHandler:function(n,i){return t.unlisten(n,i)},notifyIconAction:function(){return t.emit(M.strings.ICON_EVENT,{},!0)}})},i}(e),k=function(i){function e(){return null!==i&&i.apply(this,arguments)||this}return t(e,i),e.attachTo=function(t){return new e(t)},e.prototype.initialize=function(t,n,i,e,r,u,s){void 0===t&&(t=function(t,n){return new o(t,n)}),void 0===n&&(n=function(t){return new d(t)}),void 0===i&&(i=function(t){return new F(t)}),void 0===e&&(e=function(t){return new L(t)}),void 0===r&&(r=function(t){return new B(t)}),void 0===u&&(u=function(t){return new f(t)}),void 0===s&&(s=function(t){return new O(t)}),this.input=this.root.querySelector(p.INPUT_SELECTOR);var c=this.root.querySelector(p.LABEL_SELECTOR);this.label=c?u(c):null;var h=this.root.querySelector(p.LINE_RIPPLE_SELECTOR);this.lineRipple=h?n(h):null;var a=this.root.querySelector(p.OUTLINE_SELECTOR);this.outline=a?s(a):null;var l=H.strings,b=this.root.nextElementSibling,g=b&&b.classList.contains(T.HELPER_LINE),m=g&&b&&b.querySelector(l.ROOT_SELECTOR);this.helperText=m?i(m):null;var v=C.strings,E=this.root.querySelector(v.ROOT_SELECTOR);!E&&g&&b&&(E=b.querySelector(v.ROOT_SELECTOR)),this.characterCounter=E?e(E):null;var I=this.root.querySelector(p.LEADING_ICON_SELECTOR);this.leadingIcon=I?r(I):null;var A=this.root.querySelector(p.TRAILING_ICON_SELECTOR);this.trailingIcon=A?r(A):null,this.prefix=this.root.querySelector(p.PREFIX_SELECTOR),this.suffix=this.root.querySelector(p.SUFFIX_SELECTOR),this.ripple=this.createRipple(t)},e.prototype.destroy=function(){this.ripple&&this.ripple.destroy(),this.lineRipple&&this.lineRipple.destroy(),this.helperText&&this.helperText.destroy(),this.characterCounter&&this.characterCounter.destroy(),this.leadingIcon&&this.leadingIcon.destroy(),this.trailingIcon&&this.trailingIcon.destroy(),this.label&&this.label.destroy(),this.outline&&this.outline.destroy(),i.prototype.destroy.call(this)},e.prototype.initialSyncWithDOM=function(){this.disabled=this.input.disabled},Object.defineProperty(e.prototype,"value",{get:function(){return this.foundation.getValue()},set:function(t){this.foundation.setValue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this.foundation.isDisabled()},set:function(t){this.foundation.setDisabled(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valid",{get:function(){return this.foundation.isValid()},set:function(t){this.foundation.setValid(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"required",{get:function(){return this.input.required},set:function(t){this.input.required=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pattern",{get:function(){return this.input.pattern},set:function(t){this.input.pattern=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minLength",{get:function(){return this.input.minLength},set:function(t){this.input.minLength=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxLength",{get:function(){return this.input.maxLength},set:function(t){t<0?this.input.removeAttribute("maxLength"):this.input.maxLength=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"min",{get:function(){return this.input.min},set:function(t){this.input.min=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this.input.max},set:function(t){this.input.max=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"step",{get:function(){return this.input.step},set:function(t){this.input.step=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"helperTextContent",{set:function(t){this.foundation.setHelperTextContent(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leadingIconAriaLabel",{set:function(t){this.foundation.setLeadingIconAriaLabel(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leadingIconContent",{set:function(t){this.foundation.setLeadingIconContent(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"trailingIconAriaLabel",{set:function(t){this.foundation.setTrailingIconAriaLabel(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"trailingIconContent",{set:function(t){this.foundation.setTrailingIconContent(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useNativeValidation",{set:function(t){this.foundation.setUseNativeValidation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"prefixText",{get:function(){return this.prefix?this.prefix.textContent:null},set:function(t){this.prefix&&(this.prefix.textContent=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"suffixText",{get:function(){return this.suffix?this.suffix.textContent:null},set:function(t){this.suffix&&(this.suffix.textContent=t)},enumerable:!1,configurable:!0}),e.prototype.focus=function(){this.input.focus()},e.prototype.layout=function(){this.foundation.notchOutline(this.foundation.shouldFloat)},e.prototype.getDefaultFoundation=function(){var t=n(n(n(n(n({},this.getRootAdapterMethods()),this.getInputAdapterMethods()),this.getLabelAdapterMethods()),this.getLineRippleAdapterMethods()),this.getOutlineAdapterMethods());return new N(t,this.getFoundationMap())},e.prototype.getRootAdapterMethods=function(){var t=this;return{addClass:function(n){return t.root.classList.add(n)},removeClass:function(n){return t.root.classList.remove(n)},hasClass:function(n){return t.root.classList.contains(n)},registerTextFieldInteractionHandler:function(n,i){t.listen(n,i)},deregisterTextFieldInteractionHandler:function(n,i){t.unlisten(n,i)},registerValidationAttributeChangeHandler:function(n){var i=new MutationObserver((function(t){return n(function(t){return t.map((function(t){return t.attributeName})).filter((function(t){return t}))}(t))}));return i.observe(t.input,{attributes:!0}),i},deregisterValidationAttributeChangeHandler:function(t){t.disconnect()}}},e.prototype.getInputAdapterMethods=function(){var t=this;return{getNativeInput:function(){return t.input},setInputAttr:function(n,i){t.input.setAttribute(n,i)},removeInputAttr:function(n){t.input.removeAttribute(n)},isFocused:function(){return document.activeElement===t.input},registerInputInteractionHandler:function(n,i){t.input.addEventListener(n,i,s())},deregisterInputInteractionHandler:function(n,i){t.input.removeEventListener(n,i,s())}}},e.prototype.getLabelAdapterMethods=function(){var t=this;return{floatLabel:function(n){t.label&&t.label.float(n)},getLabelWidth:function(){return t.label?t.label.getWidth():0},hasLabel:function(){return Boolean(t.label)},shakeLabel:function(n){t.label&&t.label.shake(n)},setLabelRequired:function(n){t.label&&t.label.setRequired(n)}}},e.prototype.getLineRippleAdapterMethods=function(){var t=this;return{activateLineRipple:function(){t.lineRipple&&t.lineRipple.activate()},deactivateLineRipple:function(){t.lineRipple&&t.lineRipple.deactivate()},setLineRippleTransformOrigin:function(n){t.lineRipple&&t.lineRipple.setRippleCenter(n)}}},e.prototype.getOutlineAdapterMethods=function(){var t=this;return{closeOutline:function(){t.outline&&t.outline.closeNotch()},hasOutline:function(){return Boolean(t.outline)},notchOutline:function(n){t.outline&&t.outline.notch(n)}}},e.prototype.getFoundationMap=function(){return{characterCounter:this.characterCounter?this.characterCounter.foundationForTextField:void 0,helperText:this.helperText?this.helperText.foundationForTextField:void 0,leadingIcon:this.leadingIcon?this.leadingIcon.foundationForTextField:void 0,trailingIcon:this.trailingIcon?this.trailingIcon.foundationForTextField:void 0}},e.prototype.createRipple=function(t){var i=this,e=this.root.classList.contains(T.TEXTAREA),r=this.root.classList.contains(T.OUTLINED);if(e||r)return null;var h=n(n({},o.createAdapter(this)),{isSurfaceActive:function(){return u(i.input,":active")},registerInteractionHandler:function(t,n){i.input.addEventListener(t,n,s())},deregisterInteractionHandler:function(t,n){i.input.removeEventListener(t,n,s())}});return t(this.root,new c(h))},e}(e); /** * @license * Copyright 2018 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */export{k as M}