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