@limetech/lime-elements
Version:
67 lines • 17 kB
JavaScript
import{_ as t,a as i,b as n,M as e,m as r,c as s}from"./p-ChRGk668.js";
/**
* @license
* Copyright 2019 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.
*/function o(t){return void 0===t&&(t=window),!!function(t){void 0===t&&(t=window);var i=!1;try{var n={get passive(){return i=!0,!1}},e=function(){};t.document.addEventListener("test",e,n),t.document.removeEventListener("test",e,n)}catch(t){i=!1}return i}
/**
* @license
* Copyright 2016 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.
*/(t)&&{passive:!0}}var u,a={BG_FOCUSED:"mdc-ripple-upgraded--background-focused",FG_ACTIVATION:"mdc-ripple-upgraded--foreground-activation",FG_DEACTIVATION:"mdc-ripple-upgraded--foreground-deactivation",ROOT:"mdc-ripple-upgraded",UNBOUNDED:"mdc-ripple-upgraded--unbounded"},c={VAR_FG_SCALE:"--mdc-ripple-fg-scale",VAR_FG_SIZE:"--mdc-ripple-fg-size",VAR_FG_TRANSLATE_END:"--mdc-ripple-fg-translate-end",VAR_FG_TRANSLATE_START:"--mdc-ripple-fg-translate-start",VAR_LEFT:"--mdc-ripple-left",VAR_TOP:"--mdc-ripple-top"},h={DEACTIVATION_TIMEOUT_MS:225,FG_DEACTIVATION_MS:150,INITIAL_ORIGIN_SCALE:.6,PADDING:10,TAP_DELAY_MS:300},f=["touchstart","pointerdown","mousedown","keydown"],d=["touchend","pointerup","mouseup","contextmenu"],l=[],v=function(e){function r(t){var n=e.call(this,i(i({},r.defaultAdapter),t))||this;return n.activationAnimationHasEnded=!1,n.activationTimer=0,n.fgDeactivationRemovalTimer=0,n.fgScale="0",n.frame={width:0,height:0},n.initialSize=0,n.layoutFrame=0,n.maxRadius=0,n.unboundedCoords={left:0,top:0},n.activationState=n.defaultActivationState(),n.activationTimerCallback=function(){n.activationAnimationHasEnded=!0,n.runDeactivationUXLogicIfReady()},n.activateHandler=function(t){n.activateImpl(t)},n.deactivateHandler=function(){n.deactivateImpl()},n.focusHandler=function(){n.handleFocus()},n.blurHandler=function(){n.handleBlur()},n.resizeHandler=function(){n.layout()},n}return t(r,e),Object.defineProperty(r,"cssClasses",{get:function(){return a},enumerable:!1,configurable:!0}),Object.defineProperty(r,"strings",{get:function(){return c},enumerable:!1,configurable:!0}),Object.defineProperty(r,"numbers",{get:function(){return h},enumerable:!1,configurable:!0}),Object.defineProperty(r,"defaultAdapter",{get:function(){return{addClass:function(){},browserSupportsCssVars:function(){return!0},computeBoundingRect:function(){return{top:0,right:0,bottom:0,left:0,width:0,height:0}},containsEventTarget:function(){return!0},deregisterDocumentInteractionHandler:function(){},deregisterInteractionHandler:function(){},deregisterResizeHandler:function(){},getWindowPageOffset:function(){return{x:0,y:0}},isSurfaceActive:function(){return!0},isSurfaceDisabled:function(){return!0},isUnbounded:function(){return!0},registerDocumentInteractionHandler:function(){},registerInteractionHandler:function(){},registerResizeHandler:function(){},removeClass:function(){},updateCssVariable:function(){}}},enumerable:!1,configurable:!0}),r.prototype.init=function(){var t=this,i=this.supportsPressRipple();if(this.registerRootHandlers(i),i){var n=r.cssClasses,e=n.ROOT,s=n.UNBOUNDED;requestAnimationFrame((function(){t.adapter.addClass(e),t.adapter.isUnbounded()&&(t.adapter.addClass(s),t.layoutInternal())}))}},r.prototype.destroy=function(){var t=this;if(this.supportsPressRipple()){this.activationTimer&&(clearTimeout(this.activationTimer),this.activationTimer=0,this.adapter.removeClass(r.cssClasses.FG_ACTIVATION)),this.fgDeactivationRemovalTimer&&(clearTimeout(this.fgDeactivationRemovalTimer),this.fgDeactivationRemovalTimer=0,this.adapter.removeClass(r.cssClasses.FG_DEACTIVATION));var i=r.cssClasses,n=i.ROOT,e=i.UNBOUNDED;requestAnimationFrame((function(){t.adapter.removeClass(n),t.adapter.removeClass(e),t.removeCssVars()}))}this.deregisterRootHandlers(),this.deregisterDeactivationHandlers()},r.prototype.activate=function(t){this.activateImpl(t)},r.prototype.deactivate=function(){this.deactivateImpl()},r.prototype.layout=function(){var t=this;this.layoutFrame&&cancelAnimationFrame(this.layoutFrame),this.layoutFrame=requestAnimationFrame((function(){t.layoutInternal(),t.layoutFrame=0}))},r.prototype.setUnbounded=function(t){var i=r.cssClasses.UNBOUNDED;t?this.adapter.addClass(i):this.adapter.removeClass(i)},r.prototype.handleFocus=function(){var t=this;requestAnimationFrame((function(){return t.adapter.addClass(r.cssClasses.BG_FOCUSED)}))},r.prototype.handleBlur=function(){var t=this;requestAnimationFrame((function(){return t.adapter.removeClass(r.cssClasses.BG_FOCUSED)}))},r.prototype.supportsPressRipple=function(){return this.adapter.browserSupportsCssVars()},r.prototype.defaultActivationState=function(){return{activationEvent:void 0,hasDeactivationUXRun:!1,isActivated:!1,isProgrammatic:!1,wasActivatedByPointer:!1,wasElementMadeActive:!1}},r.prototype.registerRootHandlers=function(t){var i,e;if(t){try{for(var r=n(f),s=r.next();!s.done;s=r.next())this.adapter.registerInteractionHandler(s.value,this.activateHandler)}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(i)throw i.error}}this.adapter.isUnbounded()&&this.adapter.registerResizeHandler(this.resizeHandler)}this.adapter.registerInteractionHandler("focus",this.focusHandler),this.adapter.registerInteractionHandler("blur",this.blurHandler)},r.prototype.registerDeactivationHandlers=function(t){var i,e;if("keydown"===t.type)this.adapter.registerInteractionHandler("keyup",this.deactivateHandler);else try{for(var r=n(d),s=r.next();!s.done;s=r.next())this.adapter.registerDocumentInteractionHandler(s.value,this.deactivateHandler)}catch(t){i={error:t}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(i)throw i.error}}},r.prototype.deregisterRootHandlers=function(){var t,i;try{for(var e=n(f),r=e.next();!r.done;r=e.next())this.adapter.deregisterInteractionHandler(r.value,this.activateHandler)}catch(i){t={error:i}}finally{try{r&&!r.done&&(i=e.return)&&i.call(e)}finally{if(t)throw t.error}}this.adapter.deregisterInteractionHandler("focus",this.focusHandler),this.adapter.deregisterInteractionHandler("blur",this.blurHandler),this.adapter.isUnbounded()&&this.adapter.deregisterResizeHandler(this.resizeHandler)},r.prototype.deregisterDeactivationHandlers=function(){var t,i;this.adapter.deregisterInteractionHandler("keyup",this.deactivateHandler);try{for(var e=n(d),r=e.next();!r.done;r=e.next())this.adapter.deregisterDocumentInteractionHandler(r.value,this.deactivateHandler)}catch(i){t={error:i}}finally{try{r&&!r.done&&(i=e.return)&&i.call(e)}finally{if(t)throw t.error}}},r.prototype.removeCssVars=function(){var t=this,i=r.strings;Object.keys(i).forEach((function(n){0===n.indexOf("VAR_")&&t.adapter.updateCssVariable(i[n],null)}))},r.prototype.activateImpl=function(t){var i=this;if(!this.adapter.isSurfaceDisabled()){var n=this.activationState;if(!n.isActivated){var e=this.previousActivationEvent;e&&void 0!==t&&e.type!==t.type||(n.isActivated=!0,n.isProgrammatic=void 0===t,n.activationEvent=t,n.wasActivatedByPointer=!n.isProgrammatic&&void 0!==t&&("mousedown"===t.type||"touchstart"===t.type||"pointerdown"===t.type),void 0!==t&&l.length>0&&l.some((function(t){return i.adapter.containsEventTarget(t)}))?this.resetActivationState():(void 0!==t&&(l.push(t.target),this.registerDeactivationHandlers(t)),n.wasElementMadeActive=this.checkElementMadeActive(t),n.wasElementMadeActive&&this.animateActivation(),requestAnimationFrame((function(){l=[],n.wasElementMadeActive||void 0===t||" "!==t.key&&32!==t.keyCode||(n.wasElementMadeActive=i.checkElementMadeActive(t),n.wasElementMadeActive&&i.animateActivation()),n.wasElementMadeActive||(i.activationState=i.defaultActivationState())}))))}}},r.prototype.checkElementMadeActive=function(t){return void 0===t||"keydown"!==t.type||this.adapter.isSurfaceActive()},r.prototype.animateActivation=function(){var t=this,i=r.strings,n=i.VAR_FG_TRANSLATE_START,e=i.VAR_FG_TRANSLATE_END,s=r.cssClasses,o=s.FG_DEACTIVATION,u=s.FG_ACTIVATION,a=r.numbers.DEACTIVATION_TIMEOUT_MS;this.layoutInternal();var c="",h="";if(!this.adapter.isUnbounded()){var f=this.getFgTranslationCoordinates(),d=f.startPoint,l=f.endPoint;c=d.x+"px, "+d.y+"px",h=l.x+"px, "+l.y+"px"}this.adapter.updateCssVariable(n,c),this.adapter.updateCssVariable(e,h),clearTimeout(this.activationTimer),clearTimeout(this.fgDeactivationRemovalTimer),this.rmBoundedActivationClasses(),this.adapter.removeClass(o),this.adapter.computeBoundingRect(),this.adapter.addClass(u),this.activationTimer=setTimeout((function(){t.activationTimerCallback()}),a)},r.prototype.getFgTranslationCoordinates=function(){var t,i=this.activationState;return{startPoint:t={x:(t=i.wasActivatedByPointer?function(t,i,n){if(!t)return{x:0,y:0};var e,r,s=i.x+n.left,o=i.y+n.top;return"touchstart"===t.type?(e=t.changedTouches[0].pageX-s,r=t.changedTouches[0].pageY-o):(e=t.pageX-s,r=t.pageY-o),{x:e,y:r}}
/**
* @license
* Copyright 2016 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.
*/(i.activationEvent,this.adapter.getWindowPageOffset(),this.adapter.computeBoundingRect()):{x:this.frame.width/2,y:this.frame.height/2}).x-this.initialSize/2,y:t.y-this.initialSize/2},endPoint:{x:this.frame.width/2-this.initialSize/2,y:this.frame.height/2-this.initialSize/2}}},r.prototype.runDeactivationUXLogicIfReady=function(){var t=this,i=r.cssClasses.FG_DEACTIVATION,n=this.activationState;(n.hasDeactivationUXRun||!n.isActivated)&&this.activationAnimationHasEnded&&(this.rmBoundedActivationClasses(),this.adapter.addClass(i),this.fgDeactivationRemovalTimer=setTimeout((function(){t.adapter.removeClass(i)}),h.FG_DEACTIVATION_MS))},r.prototype.rmBoundedActivationClasses=function(){this.adapter.removeClass(r.cssClasses.FG_ACTIVATION),this.activationAnimationHasEnded=!1,this.adapter.computeBoundingRect()},r.prototype.resetActivationState=function(){var t=this;this.previousActivationEvent=this.activationState.activationEvent,this.activationState=this.defaultActivationState(),setTimeout((function(){return t.previousActivationEvent=void 0}),r.numbers.TAP_DELAY_MS)},r.prototype.deactivateImpl=function(){var t=this,n=this.activationState;if(n.isActivated){var e=i({},n);n.isProgrammatic?(requestAnimationFrame((function(){t.animateDeactivation(e)})),this.resetActivationState()):(this.deregisterDeactivationHandlers(),requestAnimationFrame((function(){t.activationState.hasDeactivationUXRun=!0,t.animateDeactivation(e),t.resetActivationState()})))}},r.prototype.animateDeactivation=function(t){(t.wasActivatedByPointer||t.wasElementMadeActive)&&this.runDeactivationUXLogicIfReady()},r.prototype.layoutInternal=function(){this.frame=this.adapter.computeBoundingRect();var t=Math.max(this.frame.height,this.frame.width);this.maxRadius=this.adapter.isUnbounded()?t:Math.sqrt(Math.pow(this.frame.width,2)+Math.pow(this.frame.height,2))+r.numbers.PADDING;var i=Math.floor(t*r.numbers.INITIAL_ORIGIN_SCALE);this.initialSize=this.adapter.isUnbounded()&&i%2!=0?i-1:i,this.fgScale=""+this.maxRadius/this.initialSize,this.updateLayoutCssVars()},r.prototype.updateLayoutCssVars=function(){var t=r.strings,i=t.VAR_LEFT,n=t.VAR_TOP,e=t.VAR_FG_SCALE;this.adapter.updateCssVariable(t.VAR_FG_SIZE,this.initialSize+"px"),this.adapter.updateCssVariable(e,this.fgScale),this.adapter.isUnbounded()&&(this.unboundedCoords={left:Math.round(this.frame.width/2-this.initialSize/2),top:Math.round(this.frame.height/2-this.initialSize/2)},this.adapter.updateCssVariable(i,this.unboundedCoords.left+"px"),this.adapter.updateCssVariable(n,this.unboundedCoords.top+"px"))},r}(e),m=function(i){function n(){var t=null!==i&&i.apply(this,arguments)||this;return t.disabled=!1,t}return t(n,i),n.attachTo=function(t,i){void 0===i&&(i={isUnbounded:void 0});var e=new n(t);return void 0!==i.isUnbounded&&(e.unbounded=i.isUnbounded),e},n.createAdapter=function(t){return{addClass:function(i){return t.root.classList.add(i)},browserSupportsCssVars:function(){return function(t,i){void 0===i&&(i=!1);var n,e=window.CSS;if("boolean"==typeof u&&!i)return u;if(!e||"function"!=typeof e.supports)return!1;var r=e.supports("--css-vars","yes"),s=e.supports("(--css-vars: yes)")&&e.supports("color","#00000000");return n=r||s,i||(u=n),n}()},computeBoundingRect:function(){return t.root.getBoundingClientRect()},containsEventTarget:function(i){return t.root.contains(i)},deregisterDocumentInteractionHandler:function(t,i){return document.documentElement.removeEventListener(t,i,o())},deregisterInteractionHandler:function(i,n){return t.root.removeEventListener(i,n,o())},deregisterResizeHandler:function(t){return window.removeEventListener("resize",t)},getWindowPageOffset:function(){return{x:window.pageXOffset,y:window.pageYOffset}},isSurfaceActive:function(){return r(t.root,":active")},isSurfaceDisabled:function(){return Boolean(t.disabled)},isUnbounded:function(){return Boolean(t.unbounded)},registerDocumentInteractionHandler:function(t,i){return document.documentElement.addEventListener(t,i,o())},registerInteractionHandler:function(i,n){return t.root.addEventListener(i,n,o())},registerResizeHandler:function(t){return window.addEventListener("resize",t)},removeClass:function(i){return t.root.classList.remove(i)},updateCssVariable:function(i,n){return t.root.style.setProperty(i,n)}}},Object.defineProperty(n.prototype,"unbounded",{get:function(){return Boolean(this.isUnbounded)},set:function(t){this.isUnbounded=Boolean(t),this.setUnbounded()},enumerable:!1,configurable:!0}),n.prototype.activate=function(){this.foundation.activate()},n.prototype.deactivate=function(){this.foundation.deactivate()},n.prototype.layout=function(){this.foundation.layout()},n.prototype.getDefaultFoundation=function(){return new v(n.createAdapter(this))},n.prototype.initialSyncWithDOM=function(){this.isUnbounded="mdcRippleIsUnbounded"in this.root.dataset},n.prototype.setUnbounded=function(){this.foundation.setUnbounded(Boolean(this.isUnbounded))},n}(s);export{m as M,o as a,v as b}