@infinityfx/lively 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./pop-4d766072.js"),r=require("./_rollupPluginBabelHelpers-7a0b7756.js");function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:e.scaleCorrection,use:o.use.bind(this,e)}}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:e.scaleCorrection,use:i.use.bind(this,e)}}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:e.scaleCorrection,use:t.use.bind(this,e)}}o.use=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.scaleCorrection,i=void 0!==o&&o;return new e.Animation({opacity:1,scaleCorrection:i,duration:.65},{opacity:0})},i.use=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.direction,i=void 0===o?"right":o,t=r.scaleCorrection,n=void 0!==t&&t,c=0,s=1,a={x:0,y:.5};switch(i){case"left":a.x=1;break;case"up":c=1,s=0,a={x:0,y:1};break;case"down":c=1,s=0,a={x:0,y:0}}return new e.Animation({scale:{x:1},scaleCorrection:n,origin:a,duration:.6},{scale:{x:c,y:s}})},t.use=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=o.direction,t=void 0===i?"right":i,n=o.scaleCorrection,c=void 0!==n&&n;return["left","right","top","bottom"].includes(t)||(t="right"),new e.Animation({clip:r._defineProperty({},t,0),scaleCorrection:c},{clip:r._defineProperty({},t,1)})},exports.Move=e.Move,exports.Pop=e.Pop,exports.Fade=o,exports.Scale=i,exports.Wipe=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./pop-b7e362c3.js"),t=require("@babel/runtime/helpers/objectWithoutProperties");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/typeof"),require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator");var o=n(e),i=n(t);function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?c(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.use=a.use.bind(a,e),a}a.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.Animation(u({opacity:1,duration:.65},e),{opacity:0})};var p=["direction"];function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return b.use=b.use.bind(b,e),b}b.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,o=i.default(e,p),c=0,u=1,a={x:0,y:.5};switch(n){case"left":a.x=1;break;case"up":c=1,u=0,a={x:0,y:1};break;case"down":c=1,u=0,a={x:0,y:0}}return new r.Animation(l({scale:{x:1},origin:a,duration:.6},o),{scale:{x:c,y:u}})};var f=["direction"];function O(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?O(Object(t),!0).forEach((function(r){o.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return d.use=d.use.bind(d,e),d}d.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,n=void 0===t?"right":t,c=i.default(e,f);return["left","right","top","bottom"].includes(n)||(n="right"),new r.Animation(y({clip:o.default({},n,0)},c),{clip:o.default({},n,1)})},exports.Move=r.Move,exports.Pop=r.Pop,exports.Fade=a,exports.Scale=b,exports.Wipe=d;
package/dist/cjs/hooks.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./_rollupPluginBabelHelpers-7a0b7756.js"),r=require("react");exports.useUnmount=function(u){var t=r.useState(u),n=e._slicedToArray(t,2),c=n[0],o=n[1],s=r.useRef();return r.useEffect((function(){u&&o(!0),!u&&s.current&&s.current.play(s.current.props.onUnmount,{callback:function(){o(!1)}})}),[u]),[c,s]};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),r=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=t(e);exports.useUnmount=function(e){var t=r.useState(e),n=u.default(t,2),c=n[0],o=n[1],a=r.useRef();return r.useEffect((function(){e&&o(!0),!e&&a.current&&a.current.play(a.current.props.onUnmount,{reverse:!0,callback:function(){o(!1)}})}),[e]),[c,a]};
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./_rollupPluginBabelHelpers-7a0b7756.js"),t=require("react"),i=require("./pop-4d766072.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),o=function(r){e._inherits(h,r);var n,o,a,s,l,c,p,u=e._createSuper(h);function h(t){var i;for(var r in e._classCallCheck(this,h),(i=u.call(this,t)).hover=!1,i.hasFocus=!1,i.inView=!1,i.scrollDelta=0,i.viewportMargin=t.viewportMargin,i.elements=[],i.animations={default:i.toAnimation(i.props.animate)},i.props.animations)i.animations[r]=i.toAnimation(i.props.animations[r]);return i.level=0,i.children=[],i}return e._createClass(h,[{key:"toAnimation",value:function(t){return!t||"object"!==e._typeof(t)&&"function"!=typeof t?null:"use"in t?t.use():new i.Animation(e._objectSpread2(e._objectSpread2({},t),{},{scaleCorrection:this.props.scaleCorrection}),this.props.initial)}},{key:"countNestedLevels",value:function(e){var i=this;if(!e)return 0;var r=0,n=0;return t.Children.forEach(e,(function(e){var o;if(t.isValidElement(e)){e.type===h&&(r=1);var a=i.countNestedLevels(null===(o=e.props)||void 0===o?void 0:o.children);n=n<a?a:n}})),n+r}},{key:"componentDidMount",value:function(){var e=this;this.elements.forEach((function(t){var i;null===(i=e.animations.default)||void 0===i||i.setInitialStyles(t)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),i.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll())}},{key:"componentWillUnmount",value:function(){i.removeEventListener("scroll",this.scrollEventListener),this.props.onUnmount&&(this.props.parentLevel<1||this.props.noCascade)&&this.play(this.props.onUnmount,{reverse:!0,immediate:!0})}},{key:"inViewport",value:function(){var t=this,i=!0,r=!0;return this.elements.forEach((function(e){var n=e.getBoundingClientRect().y;i=i&&n+e.clientHeight*(1-t.viewportMargin)<window.innerHeight,r=r&&n>window.innerHeight+e.clientHeight*t.viewportMargin})),this.elements.length||this.children.forEach((function(t){var n=t.animatable.inViewport(),o=e._slicedToArray(n,2),a=o[0],s=o[1];i=i&&a,r=r&&s})),[i,r]}},{key:"onScroll",value:(p=e._asyncToGenerator(e._regeneratorRuntime().mark((function t(){var i,r,n,o;return e._regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(Date.now()-this.scrollDelta<350)){t.next=2;break}return t.abrupt("return");case 2:this.scrollDelta=Date.now(),i=this.inViewport(),r=e._slicedToArray(i,2),n=r[0],o=r[1],!this.inView&&n&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&o&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return p.apply(this,arguments)})},{key:"onEnter",value:(c=e._asyncToGenerator(e._regeneratorRuntime().mark((function t(i){var r,n=arguments;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(i);case 3:case"end":return e.stop()}}),t,this)}))),function(e){return c.apply(this,arguments)})},{key:"onLeave",value:(l=e._asyncToGenerator(e._regeneratorRuntime().mark((function t(i){var r,n=arguments;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(i);case 3:case"end":return e.stop()}}),t,this)}))),function(e){return l.apply(this,arguments)})},{key:"onFocus",value:(s=e._asyncToGenerator(e._regeneratorRuntime().mark((function t(i){var r,n=arguments;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(i);case 3:case"end":return e.stop()}}),t,this)}))),function(e){return s.apply(this,arguments)})},{key:"onBlur",value:(a=e._asyncToGenerator(e._regeneratorRuntime().mark((function t(i){var r,n=arguments;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(i);case 3:case"end":return e.stop()}}),t,this)}))),function(e){return a.apply(this,arguments)})},{key:"onClick",value:(o=e._asyncToGenerator(e._regeneratorRuntime().mark((function t(i){var r,n=arguments;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(i);case 3:case"end":return e.stop()}}),t,this)}))),function(e){return o.apply(this,arguments)})},{key:"play",value:(n=e._asyncToGenerator(e._regeneratorRuntime().mark((function t(r){var n,o,a,s,l,c,p,u,h,v,d,m,f,y,g,b,_=this,w=arguments;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=w.length>1&&void 0!==w[1]?w[1]:{},o=n.callback,a=n.reverse,s=void 0!==a&&a,l=n.immediate,c=void 0!==l&&l,p=n.cascade,u=void 0!==p&&p,h=n.groupAdjust,v=void 0===h?0:h,d=n.cascadeDelay,m=void 0===d?0:d,f=n.staggerDelay,y=void 0===f?0:f,!(this.props.parentLevel>0)||u){e.next=3;break}return e.abrupt("return");case 3:if(g="string"==typeof r?this.animations[r]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var i="group"in _.props?_.props.parentLevel-_.props.group:_.level+v;m=s?g.duration:m;var r=s?i*m:(_.props.parentLevel-i)*m;r=_.props.stagger*t+r+y,b=r>b?r:b,g.play(e,{delay:r,reverse:s,immediate:c})})),this.children.forEach((function(e){var t=e.animatable,i=e.staggerIndex,n=void 0===i?-1:i;null==t||t.play(r,{reverse:s,immediate:c,cascade:!0,staggerDelay:n<0?0:_.props.stagger*n,cascadeDelay:g.duration,groupAdjust:n<0?0:1})})),o&&i.AnimationQueue.delay(o,b+g.duration);case 10:case"end":return e.stop()}}),t,this)}))),function(e){return n.apply(this,arguments)})},{key:"style",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e._objectSpread2(e._objectSpread2({},t),{},{transitionProperty:"transform, opacity, clip-path, border-radius, background-color, color, width, height, left, top",willChange:"transform"});return i}},{key:"mergeProperties",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e._objectSpread2(e._objectSpread2({},i),t);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:"object"===e._typeof(t[n])&&"object"===e._typeof(i[n])&&(r[n]=e._objectSpread2(e._objectSpread2({},i[n]),t[n]));return r}},{key:"deepClone",value:function(i){var r,n=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=o.index,s=void 0===a?0:a,l=o.useElements,c=void 0!==l&&l,p=o.useEvents,u=void 0!==p&&p;if(!t.isValidElement(i))return i;var v,d={};i.type!==h&&(c&&(d={style:this.style(null===(v=i.props)||void 0===v?void 0:v.style),ref:function(e){return n.elements[s]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(d=e._objectSpread2(e._objectSpread2({},d),{},{onMouseEnter:function(e){var t;return n.onEnter(e,null===(t=i.props)||void 0===t?void 0:t.onMouseEnter)},onMouseLeave:function(e){var t;return n.onLeave(e,null===(t=i.props)||void 0===t?void 0:t.onMouseLeave)},onFocus:function(e){var t;return n.onFocus(e,null===(t=i.props)||void 0===t?void 0:t.onFocus)},onBlur:function(e){var t;return n.onBlur(e,null===(t=i.props)||void 0===t?void 0:t.onBlur)},onClick:function(e){var t;return n.onClick(e,null===(t=i.props)||void 0===t?void 0:t.onClick)}}),u=!1));i.type!==h||null!==(r=i.props)&&void 0!==r&&r.noCascade||(d=e._objectSpread2(e._objectSpread2(e._objectSpread2({},d),this.mergeProperties(i.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return n.children[n.children.length]={animatable:e,staggerIndex:c?s:-1}}}));var m=t.Children.map(i.props.children,(function(e,t){return n.deepClone(e,{index:t,useEvents:u})}));return Object.values(d).length?t.cloneElement(i,d,m):i}},{key:"render",value:function(){var e=this;return this.level=this.countNestedLevels(this.props.children),t.Children.map(this.props.children,(function(t,i){return e.deepClone(t,{index:i,useElements:!0,useEvents:!0})}))}}]),h}(t.Component);e._defineProperty(o,"defaultProps",{scaleCorrection:!1,parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var a=["levels","animations"],s=function(i){e._inherits(s,i);var r=e._createSuper(s);function s(t){var i;return e._classCallCheck(this,s),(i=r.call(this,t)).levels=i.props.levels,i.animations=new Array(i.levels).fill(0).map((function(e,t){return t<i.props.animations.length?i.props.animations[t]:i.props.animations[i.props.animations.length-1]})),i}return e._createClass(s,[{key:"makeAnimatable",value:function(i){var r=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(s<1||t.Children.count(i)<1)return i;var l=this.props;l.levels,l.animations;var c=e._objectWithoutProperties(l,a),p=this.animations[this.levels-s];return s===this.levels&&(c.ref=function(e){return r.animatable=e}),n.default.createElement(o,e._extends({animate:p,scaleCorrection:p.scaleCorrection},c),t.Children.map(i,(function(e){return t.isValidElement(e)?t.cloneElement(e,{},r.makeAnimatable(e.props.children,s-1)):e})))}},{key:"play",value:function(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(i=this.animatable)||void 0===i||i.play(t,e._objectSpread2(e._objectSpread2({},r),{},{reverse:!0}))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),s}(t.Component);e._defineProperty(s,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[i.Move,i.Pop]});var l=function(t){e._inherits(n,t);var r=e._createSuper(n);function n(t){var i;return e._classCallCheck(this,n),(i=r.call(this,t)).animations.morphs=[],i}return e._createClass(n,[{key:"componentDidMount",value:function(){var e=this,t=this.elements[0];t&&(i.Animation.setInitial(t),t.setAttribute("uitools-morph-id",this.props.id),t.setAttribute("uitools-morph-active",this.props.active),this.self=t,this.createResetAnimation(),i.AnimationQueue.delay((function(){for(var i=document.querySelectorAll('[uitools-morph-id="'.concat(e.props.id,'"]')),r=0;r<i.length;r++)i[r]!==t&&(e.createMorphAnimation(i[r],r),"true"!==i[r].getAttribute("uitools-morph-active")&&e.animations.transition.setInitialStyles(i[r]))}),.001))}},{key:"componentDidUpdate",value:function(){var e=this,t="true"===this.self.getAttribute("uitools-morph-active");this.self.setAttribute("uitools-morph-active",this.props.active),i.AnimationQueue.delay((function(){if(e.props.active&&!t)e.animations.transition.setInitialStyles(e.self),e.animations.transition.play(e.self);else if(!e.props.active&&t){for(var i=0,r=document.querySelectorAll('[uitools-morph-id="'.concat(e.props.id,'"]')),n=0;n<r.length;n++)if(r[n]!==e.self&&"true"===r[n].getAttribute("uitools-morph-active")){i=n;break}e.animations.morphs[i].play(e.self)}}),.001)}},{key:"createResetAnimation",value:function(){var e,t=null===(e=this.self.UITools)||void 0===e?void 0:e.initialStyles;this.animations.transition=new i.Animation({opacity:[0,0,1],scale:{x:1,y:1},position:{x:0,y:0},borderRadius:t.borderRadius,backgroundColor:[t.backgroundColor,t.backgroundColor,t.backgroundColor],scaleCorrection:this.scaleCorrection},{})}},{key:"createMorphAnimation",value:function(e,t){var r,n,o=null===(r=this.self.UITools)||void 0===r?void 0:r.initialStyles,a=null===(n=e.UITools)||void 0===n?void 0:n.initialStyles;this.animations.morphs[t]=new i.Animation({position:[{x:0,y:0},{x:a.x-o.x+(a.clientWidth-o.clientWidth)/2,y:a.y-o.y+(a.clientHeight-o.clientHeight)/2},{x:a.x-o.x+(a.clientWidth-o.clientWidth)/2,y:a.y-o.y+(a.clientHeight-o.clientHeight)/2}],scale:[{x:1,y:1},{x:a.clientWidth/o.clientWidth,y:a.clientHeight/o.clientHeight},{x:a.clientWidth/o.clientWidth,y:a.clientHeight/o.clientHeight}],opacity:[1,1,0],borderRadius:[o.borderRadius,a.borderRadius,a.borderRadius],backgroundColor:[o.backgroundColor,a.backgroundColor,a.backgroundColor],scaleCorrection:this.scaleCorrection},{})}}]),n}(o);e._defineProperty(l,"defaultProps",{id:0,active:!1,scaleCorrection:!1}),exports.Animatable=o,exports.Animate=s,exports.Morph=l;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/typeof"),n=require("@babel/runtime/helpers/classCallCheck"),i=require("@babel/runtime/helpers/createClass"),o=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),s=require("@babel/runtime/helpers/getPrototypeOf"),l=require("@babel/runtime/helpers/defineProperty"),u=require("@babel/runtime/regenerator"),p=require("react"),c=require("./pop-b7e362c3.js"),h=require("@babel/runtime/helpers/extends"),f=require("@babel/runtime/helpers/objectWithoutProperties"),d=require("@babel/runtime/helpers/get");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("@babel/runtime/helpers/toConsumableArray");var y=v(e),m=v(t),b=v(r),g=v(n),w=v(i),k=v(o),E=v(a),O=v(s),x=v(l),A=v(u),P=v(p),j=v(h),C=v(f),L=v(d);function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function D(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach((function(t){x.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=O.default(e);if(t){var i=O.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var M=function(e){k.default(h,e);var t,r,n,i,o,a,s,l,u=R(h);function h(e){var t;for(var r in g.default(this,h),(t=u.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return w.default(h,[{key:"toAnimation",value:function(e){return!e||"object"!==b.default(e)&&"function"!=typeof e?null:"use"in e?e.use():new c.Animation(D({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return p.Children.forEach(e,(function(e){var i;if(p.isValidElement(e)){e.type===h&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:function(){var e=this;this.elements.forEach((function(t){var r;null===(r=e.animations.default)||void 0===r||r.setInitial(t,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),c.addEventListener("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll())}},{key:"componentWillUnmount",value:function(){c.removeEventListener("scroll",this.scrollEventListener),this.props.onUnmount&&(this.props.parentLevel<1||this.props.noCascade)&&this.play(this.props.onUnmount,{reverse:!0,immediate:!0})}},{key:"inViewport",value:function(){var e=this,t=!0,r=!0;return this.elements.forEach((function(n){var i=n.getBoundingClientRect().y;t=t&&i+n.clientHeight*(1-e.viewportMargin)<window.innerHeight,r=r&&i>window.innerHeight+n.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var n=e.animatable.inViewport(),i=m.default(n,2),o=i[0],a=i[1];t=t&&o,r=r&&a})),[t,r]}},{key:"onScroll",value:(l=y.default(A.default.mark((function e(){var t,r,n,i;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()-this.scrollDelta<350)){e.next=2;break}return e.abrupt("return");case 2:this.scrollDelta=Date.now(),t=this.inViewport(),r=m.default(t,2),n=r[0],i=r[1],!this.inView&&n&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&i&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"onEnter",value:(s=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"onLeave",value:(a=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"onFocus",value:(o=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"onBlur",value:(i=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"onClick",value:(n=y.default(A.default.mark((function e(t){var r,n=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setInitial",value:(r=y.default(A.default.mark((function e(t){var r,n,i=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"play",value:(t=y.default(A.default.mark((function e(t){var r,n,i,o,a,s,l,u,p,h,f,d,v,y,m,b,g=this,w=arguments;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=w.length>1&&void 0!==w[1]?w[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,a=r.immediate,s=void 0!==a&&a,l=r.cascade,u=void 0!==l&&l,p=r.groupAdjust,h=void 0===p?0:p,f=r.cascadeDelay,d=void 0===f?0:f,v=r.staggerDelay,y=void 0===v?0:v,!(this.props.parentLevel>0)||u){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:b=0,this.elements.forEach((function(e,t){var r="group"in g.props?g.props.parentLevel-g.props.group:g.level+h;d=o?m.duration:d;var n=o?r*d:(g.props.parentLevel-r)*d;n=g.props.stagger*t+n+y,b=n>b?n:b,m.play(e,{delay:n,reverse:o,immediate:s})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:s,cascade:!0,staggerDelay:i<0?0:g.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&c.AnimationQueue.delay(n,b+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"style",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=D(D({},e),{},{transitionProperty:"transform, opacity, clip-path, border-radius, background-color, color, width, height, left, top",willChange:"transform"});return t}},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=D(D({},t),e);for(var n in r)["children","parentLevel","ref"].includes(n)?delete r[n]:Array.isArray(e[n])||Array.isArray(t[n])||"object"===b.default(e[n])&&"object"===b.default(t[n])&&(r[n]=D(D({},t[n]),e[n]));return r}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,a=n.useElements,s=void 0!==a&&a,l=n.useEvents,u=void 0!==l&&l;if(!p.isValidElement(e))return e;var c,f={};e.type===h||e.type.prototype instanceof h||(s&&(f={style:this.style(null===(c=e.props)||void 0===c?void 0:c.style),ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(f=D(D({},f),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1));!(e.type===h||e.type.prototype instanceof h)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(f=D(D(D({},f),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:s?o:-1}}}));var d=p.Children.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return Object.values(f).length?p.cloneElement(e,f,d):e}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,p.Children.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),h}(p.Component);x.default(M,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var q=["levels","animations"];function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){x.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function F(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=O.default(e);if(t){var i=O.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}var B=function(e){k.default(r,e);var t=F(r);function r(e){var n;return g.default(this,r),(n=t.call(this,e)).levels=n.props.levels,n.animations=new Array(n.levels).fill(0).map((function(e,t){return t<n.props.animations.length?n.props.animations[t]:n.props.animations[n.props.animations.length-1]})),n}return w.default(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||p.Children.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=C.default(n,q),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),P.default.createElement(M,j.default({animate:o},i),p.Children.map(e,(function(e){return p.isValidElement(e)?p.cloneElement(e,{},t.makeAnimatable(e.props.children,r-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,V({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}(p.Component);function H(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return U(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return U(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function T(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=O.default(e);if(t){var i=O.default(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E.default(this,r)}}x.default(B,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[c.Move,c.Pop]});var G=function(e){k.default(r,e);var t=T(r);function r(e){var n;return g.default(this,r),(n=t.call(this,e)).id=n.props.parentGroup+n.props.group,n}return w.default(r,[{key:"componentDidMount",value:function(){var e=this;this.element=this.elements[0],this.element&&(c.Animation.setInitial(this.element),this.animations.transition=this.createResetAnimation(),this.element.setAttribute("uitools-morph-id",this.id),this.element.setAttribute("uitools-morph-active",this.props.active),c.AnimationQueue.delay((function(){for(var t=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),r=0;r<t.length;r++)t[r]!==e.element&&(e.animations[r]=e.createMorphAnimation(t[r]));e.props.active||e.props.parentGroup.length||e.setInitial("transition")}),.001))}},{key:"componentDidUpdate",value:function(){var e=this;"true"===this.element.getAttribute("uitools-morph-active")!==this.props.active&&(this.element.setAttribute("uitools-morph-active",this.props.active),c.AnimationQueue.delay((function(){if(e.props.active)e.play("transition");else{for(var t=0,r=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),n=0;n<r.length;n++)if(r[n]!==e.element&&"true"===r[n].getAttribute("uitools-morph-active")){t=n;break}e.play(t.toString())}}),.001))}},{key:"getParentPosition",value:function(e){var t,r=this.props.useLayout?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return(null==r?void 0:r.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,i=null===(r=e.UITools)||void 0===r?void 0:r.initialStyles,o=i.x-n.x,a=i.y-n.y;if(this.props.parentGroup.length){var s=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-s.x,a-=l.y-s.y}return this.props.useLayout||(o+=(i.clientWidth-n.clientWidth)/2,a+=(i.clientHeight-n.clientHeight)/2),[{x:0,y:0},{x:o,y:a},{x:o,y:a}]}},{key:"scaleKeyframes",value:function(e,t){var r=t.clientWidth/e.clientWidth,n=t.clientHeight/e.clientHeight;return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createMorphAnimation",value:function(e){var t,n,i,o=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,a=null===(n=e.UITools)||void 0===n?void 0:n.initialStyles,s={useLayout:this.props.useLayout},l=H(r.properties);try{for(l.s();!(i=l.n()).done;){var u=i.value;if(!this.props.ignore.includes(u))switch(u){case"position":s[u]=this.positionKeyframes(e);break;case"scale":s[u]=this.scaleKeyframes(o,a);break;case"opacity":s[u]=[1,1,0];break;default:s[u]=[o[u],a[u],a[u]]}}}catch(e){l.e(e)}finally{l.f()}return new c.Animation(s)}},{key:"createResetAnimation",value:function(){var e,t,n=null===(e=this.element.UITools)||void 0===e?void 0:e.initialStyles,i={useLayout:this.props.useLayout},o=H(r.properties);try{for(o.s();!(t=o.n()).done;){var a=t.value;if(!this.props.ignore.includes(a))switch(a){case"position":i[a]={x:0,y:0};break;case"scale":i[a]={x:1,y:1};break;case"opacity":i[a]=[0,0,1];break;default:i[a]=[n[a],n[a],n[a]]}}}catch(e){o.e(e)}finally{o.f()}return new c.Animation(i)}},{key:"parentStyle",value:function(){return{position:"relative",background:"transparent",border:"none",pointerEvents:"none"}}},{key:"childStyle",value:function(){return{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"}}},{key:"getChildren",value:function(e){var t=this;return p.Children.map(e,(function(e){if(!p.isValidElement(e))return e;var n=e.type!==r?{}:{parentGroup:t.props.parentGroup+t.props.group};return p.cloneElement(e,n,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!p.isValidElement(t))return t;var n=this.getChildren(t.props.children),i=this.props.useLayout?{style:this.childStyle()}:{},o=L.default(O.default(r.prototype),"render",this).call(this,p.cloneElement(t,i,n));return this.props.useLayout?p.cloneElement(t,{style:this.parentStyle()},o):o}}]),r}(M);x.default(G,"properties",["position","scale","opacity","backgroundColor","color","borderRadius"]),x.default(G,"defaultProps",{group:0,parentGroup:"",active:!1,useLayout:!1,ignore:[]}),exports.Animatable=M,exports.Animate=B,exports.Morph=G;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/objectWithoutProperties"),i=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/typeof"),a=require("@babel/runtime/helpers/classCallCheck"),o=require("@babel/runtime/helpers/createClass"),s=require("@babel/runtime/helpers/asyncToGenerator"),l=require("@babel/runtime/regenerator");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(e),d=u(t),p=u(i),f=u(n),h=u(r),v=u(a),y=u(o),g=u(s),b=u(l),m=function(){function e(){v.default(this,e),this.queue=[],this.tick()}var t,i;return y.default(e,[{key:"tick",value:(i=g.default(b.default.mark((function e(){var t,i;return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){e.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>t)){e.next=6;break}return this.queue.splice(0,i),e.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,e.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"search",value:function(e){for(var t,i,n=0,r=this.queue.length-1;n<=r;)if(t=n+r>>>1,(i=this.queue[t].timestamp-e.timestamp)<0)n=t+1;else{if(!(i>0))return t;r=t-1}return n}},{key:"insert",value:function(e){var t=this.search(e);this.queue.splice(t,0,e)}},{key:"delay",value:function(e,t){e instanceof Function&&this.insert({callback:e,timestamp:Date.now()+1e3*t})}}],[{key:"get",value:function(){return"UITools"in window||(window.UITools={}),"AnimationLoop"in window.UITools||(window.UITools.AnimationQueue=new e),window.UITools.AnimationQueue}},{key:"delay",value:(t=g.default(b.default.mark((function e(t,i){return b.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.get().delay(t,i));case 1:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"sleep",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){e.delay(i,t)}))}}]),e}(),w=function(e){var t=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==o?parseInt(o,16):255}},k=function(e){var t=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=p.default(t,5);i[0];var n=i[1],r=i[2],a=i[3],o=i[4];return{r:parseInt(n),g:parseInt(r),b:parseInt(a),a:void 0!==o?parseInt(o):255}},I=["delay","duration","repeat","interpolate","origin","useLayout"],x=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.delay,n=void 0===i?0:i,r=t.duration,a=void 0===r?1:r,o=t.repeat,s=void 0===o?1:o,l=t.interpolate,u=void 0===l?"ease":l,c=t.origin,p=void 0===c?{x:.5,y:.5}:c,f=t.useLayout,h=void 0!==f&&f,y=d.default(t,I),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};v.default(this,e),this.useLayout=h,this.keyframes=this.getKeyframes(y,g),this.delay=n,this.duration=a,this.delta=a/(this.keyframes.length-1),this.interpolation=u,this.origin=this.originToStyle(p),this.repeat=s}return y.default(e,[{key:"originToStyle",value:function(e){var t=.5,i=.5;if("object"===h.default(e))t=e.x,i=e.y;else if("string"==typeof e)switch(e){case"left":t=0;break;case"right":t=1;break;case"top":i=0;break;case"bottom":i=1}else t=i=e;return"".concat(100*t,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=0,a=function(a){var o=a in n?n[a]:e.initials[a];Array.isArray(t[a])||(t[a]=[t[a]]),t[a]=t[a].length>1?t[a]:[o].concat(f.default(t[a])),t[a]=t[a].map((function(e){return i.sanitize(a,e)})),r=t[a].length>r?t[a].length:r};for(var o in t)a(o);return new Array(r).fill(0).map((function(n,a){var o={};for(var s in t)s in e.initials&&(o[s]=i.interpolateKeyframe(t[s],a,r));return i.keyframeToStyle(o)}))}},{key:"sanitize",value:function(t,i){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return w(i);if(i.match(/^rgba?\(.*\)$/i))return k(i);var a=parseFloat(i),o=i.match(/[^0-9\.]*$/i);return isNaN(a)?e.initials[t]:("%"===o&&(a/=100),o?[a,o]:a)}if("object"===h.default(i)){var s=Object.keys(i);("x"in i||"y"in i)&&(s=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(s=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(s=["left","right","top","bottom"]),s.forEach((function(e){i[e]=n.sanitize(t,i[e],e)}))}return void 0!==i?i:r?e.initials[t][r]:e.initials[t]}},{key:"interpolate",value:function(e,t,i){if("string"==typeof e||"string"==typeof t)return i>.5?t:e;var n=!1;Array.isArray(e)&&(n=e[1],e=e[0]),Array.isArray(t)&&(n=t[1],t=t[0]);var r=e*(1-i)+t*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(e,t,i){var n=this;if(e.length===i)return e[t];var r=t*((e.length-1)/(i-1)),a=Math.floor(r),o=e[a];if(a===e.length-1)return o;var s=e[a+1];if("object"===h.default(o)){var l={};return Object.keys(o).forEach((function(e){l[e]=n.interpolate(o[e],s[e],r-a)})),l}return this.interpolate(o,s,r-a)}},{key:"toString",value:function(e,t){return Array.isArray(e)&&(t=e[1],e=e[0]),e*("%"===t?100:1)+t}},{key:"toLength",value:function(e){return Array.isArray(e)&&(e="px"===e[1]?e[0]+"px":e[0]),e}},{key:"keyframeToStyle",value:function(e){var t=this,i={transform:""};return Object.entries(e).forEach((function(e){var n=p.default(e,2),r=n[0],a=n[1];switch(r){case"position":i.transform+="translate(".concat(t.toString(a.x,"px"),", ").concat(t.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),t.useLayout){i.width=t.toLength(a.x),i.height=t.toLength(a.y);break}i.transform+="scale(".concat(t.toString(a.x,"%"),", ").concat(t.toString(a.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((t.toString(a),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(t.toString(a.top,"%")," ").concat(t.toString(a.right,"%")," ").concat(t.toString(a.bottom,"%")," ").concat(t.toString(a.left,"%"),")");break;case"borderRadius":i[r]=t.toString(a,"px");break;case"backgroundColor":case"color":i[r]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"opacity":case"active":i[r]=a}})),i.transform.length||delete i.transform,i}},{key:"setInitial",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i&&e.setInitial(t),t.style.transitionDuration="0s";var n=this.keyframes[0];this.apply(t,n,!0)}},{key:"test",value:function(e,t,i,n,r,a){var o=n+r+((i-=t-(e="string"==typeof e?parseInt(e)/t:e)*t)<0?i:0),s=n/(n+r);return{size:(i<0?0:i)+"px",padStart:(n=a?e*n:o*s)+"px",padEnd:(r=a?e*r:o*(1-s))+"px"}}},{key:"apply",value:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=function(){var n=e.UITools.initialStyles;Object.entries(t).forEach((function(t){var r=p.default(t,2),a=r[0],o=r[1];if("width"===a){var s=n.clientWidth,l=n.width,u=n.paddingLeft,c=n.paddingRight,d=n.includePadding,f=i.test(o,s,l,u,c,d),h=f.size,v=f.padStart,y=f.padEnd;return e.style.width=h,e.style.paddingLeft=v,void(e.style.paddingRight=y)}if("height"===a){var g=n.clientHeight,b=n.height,m=n.paddingTop,w=n.paddingBottom,k=n.includePadding,I=i.test(o,g,b,m,w,k),x=I.size,T=I.padStart,O=I.padEnd;return e.style.height=x,e.style.paddingTop=T,void(e.style.paddingBottom=O)}"active"!==a&&(e.style[a]=o)}))};if("active"in t){var a=Object.keys(t.active)[0];"start"===a||n?(e.style.display=t.active[a]?"":"none",n?r():m.delay(r,.01)):(m.delay((function(){e.style.display=t.active[a]?"":"none"}),this.delta),r())}else r()}},{key:"start",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.immediate,n=void 0!==i&&i,r=t.reverse,a=void 0!==r&&r,o=t.repeat,s=void 0===o?this.repeat:o;!e.UITools.animating||n?(this.setInitial(e),e.style.transitionDuration="".concat(this.delta,"s"),e.style.transitionTimingFunction=this.interpolation,e.style.transformOrigin=this.origin,e.UITools.animating=!0,e.UITools.index=1,this.getNext(e,a,s)):e.UITools.queue.push([this,{reverse:a,repeat:s}])}},{key:"play",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,a=i.immediate,o=void 0!==a&&a,s=i.reverse,l=void 0!==s&&s;e.style&&(this.delay||r?m.delay((function(){return t.start(e,{immediate:o,reverse:l})}),this.delay+r):this.start(e,{immediate:o,reverse:l}))}},{key:"getNext",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e.UITools.index===this.keyframes.length){e.UITools.animating=!1;var r=e.UITools.queue.shift()||[],a=p.default(r,2),o=a[0],s=a[1];return o?o.start(e,s):void(n>1&&this.start(e,{reverse:i,repeat:n-1}))}var l=e.UITools.index;i&&(l=this.keyframes.length-1-l),requestAnimationFrame((function(){t.apply(e,t.keyframes[l])})),e.UITools.index++,m.delay((function(){return t.getNext(e,i,n)}),this.delta)}}],[{key:"setInitial",value:function(e){var t=getComputedStyle(e),i=t.width,n=t.height,r=t.paddingLeft,a=t.paddingRight,o=t.paddingTop,s=t.paddingBottom,l=t.borderRadius,u=t.boxSizing,c=t.backgroundColor,d=t.color,p=e.getBoundingClientRect(),f=p.x,h=p.y;"UITools"in e||(e.UITools={}),"queue"in e.UITools||(e.UITools.queue=[]),"initialStyles"in e.UITools||(e.UITools.initialStyles={x:f,y:h,includePadding:"border-box"===u,clientWidth:e.clientWidth,clientHeight:e.clientHeight,width:parseInt(i),height:parseInt(n),paddingLeft:parseInt(r),paddingRight:parseInt(a),paddingTop:parseInt(o),paddingBottom:parseInt(s),borderRadius:parseInt(l.split(" ")[0]),backgroundColor:c,color:d})}}]),e}();c.default(x,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,active:{start:!0},backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255}});var T=["direction"];function O(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function U(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?O(Object(i),!0).forEach((function(t){c.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):O(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function j(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return j.use=j.use.bind(j,e),j}function S(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function q(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?S(Object(i),!0).forEach((function(t){c.default(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):S(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E.use=E.use.bind(E,e),E}j.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.direction,i=void 0===t?"up":t,n=d.default(e,T),r="0px",a="20px";switch(i){case"down":a="-20px";break;case"left":r="20px",a="0px";break;case"right":r="-20px",a="0px"}return new x(U({position:{x:"0px",y:"0px"},opacity:1,duration:.5},n),{position:{x:r,y:a},opacity:0})},E.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new x(q({opacity:1,scale:1,duration:.25},e),{opacity:0,scale:.85})},exports.Animation=x,exports.AnimationQueue=m,exports.Move=j,exports.Pop=E,exports.addEventListener=function(e,t){var i;t instanceof Function&&(null!==(i=window.UITools)&&void 0!==i&&i.Events||(window.UITools={Events:{}}),e in window.UITools.Events||(window.UITools.Events[e]={unique:0},window.addEventListener(e,(function(t){Object.values(window.UITools.Events[e]).forEach((function(e){e instanceof Function&&e(t)}))}))),t.UITools={ListenerID:window.UITools.Events[e].unique},window.UITools.Events[e][window.UITools.Events[e].unique]=t,window.UITools.Events[e].unique++)},exports.removeEventListener=function(e,t){var i,n,r;"undefined"!=typeof window&&null!==(i=window.UITools)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[e]&&null!=t&&null!==(r=t.UITools)&&void 0!==r&&r.ListenerID&&delete window.UITools.Events[e][t.UITools.ListenerID]};
@@ -1 +1 @@
1
- import{A as e}from"./pop-daf75174.js";export{M as Move,P as Pop}from"./pop-daf75174.js";import{c as o}from"./_rollupPluginBabelHelpers-e1425fd3.js";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:e.scaleCorrection,use:r.use.bind(this,e)}}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:e.scaleCorrection,use:i.use.bind(this,e)}}function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:e.scaleCorrection,use:t.use.bind(this,e)}}r.use=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=o.scaleCorrection,i=void 0!==r&&r;return new e({opacity:1,scaleCorrection:i,duration:.65},{opacity:0})},i.use=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=o.direction,i=void 0===r?"right":r,t=o.scaleCorrection,n=void 0!==t&&t,c=0,s=1,a={x:0,y:.5};switch(i){case"left":a.x=1;break;case"up":c=1,s=0,a={x:0,y:1};break;case"down":c=1,s=0,a={x:0,y:0}}return new e({scale:{x:1},scaleCorrection:n,origin:a,duration:.6},{scale:{x:c,y:s}})},t.use=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r.direction,t=void 0===i?"right":i,n=r.scaleCorrection,c=void 0!==n&&n;return["left","right","top","bottom"].includes(t)||(t="right"),new e({clip:o({},t,0),scaleCorrection:c},{clip:o({},t,1)})};export{r as Fade,i as Scale,t as Wipe};
1
+ import e from"@babel/runtime/helpers/defineProperty";import{A as r}from"./pop-262b0878.js";export{M as Move,P as Pop}from"./pop-262b0878.js";import t from"@babel/runtime/helpers/objectWithoutProperties";import"@babel/runtime/helpers/slicedToArray";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";function n(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function o(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.use=i.use.bind(i,e),i}i.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r(o({opacity:1,duration:.65},e),{opacity:0})};var c=["direction"];function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function b(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s.use=s.use.bind(s,e),s}s.use=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.direction,o=void 0===n?"right":n,i=t(e,c),p=0,s=1,u={x:0,y:.5};switch(o){case"left":u.x=1;break;case"up":p=1,s=0,u={x:0,y:1};break;case"down":p=1,s=0,u={x:0,y:0}}return new r(b({scale:{x:1},origin:u,duration:.6},i),{scale:{x:p,y:s}})};var u=["direction"];function a(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function O(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return O.use=O.use.bind(O,e),O}O.use=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.direction,i=void 0===o?"right":o,c=t(n,u);return["left","right","top","bottom"].includes(i)||(i="right"),new r(l({clip:e({},i,0)},c),{clip:e({},i,1)})};export{i as Fade,s as Scale,O as Wipe};
package/dist/esm/hooks.js CHANGED
@@ -1 +1 @@
1
- import{g as r}from"./_rollupPluginBabelHelpers-e1425fd3.js";import{useState as n,useRef as o,useEffect as t}from"react";function e(e){var u=n(e),c=r(u,2),l=c[0],p=c[1],a=o();return t((function(){e&&p(!0),!e&&a.current&&a.current.play(a.current.props.onUnmount,{callback:function(){p(!1)}})}),[e]),[l,a]}export{e as useUnmount};
1
+ import r from"@babel/runtime/helpers/slicedToArray";import{useState as e,useRef as n,useEffect as t}from"react";function o(o){var c=e(o),u=r(c,2),a=u[0],i=u[1],p=n();return t((function(){o&&i(!0),!o&&p.current&&p.current.play(p.current.props.onUnmount,{reverse:!0,callback:function(){i(!1)}})}),[o]),[a,p]}export{o as useUnmount};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{_ as e,a as t,b as i,c as n,d as r,e as o,f as s,g as a,h as l,i as p,j as u,k as c}from"./_rollupPluginBabelHelpers-e1425fd3.js";import h,{Children as v,isValidElement as d,cloneElement as f,Component as m}from"react";import{A as y,a as g,r as w,b as k,M as b,P as C}from"./pop-daf75174.js";var x=function(n){e(E,m);var u,c,h,b,C,x,A,L=t(E);function E(e){var t;for(var i in r(this,E),(t=L.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[i]=t.toAnimation(t.props.animations[i]);return t.level=0,t.children=[],t}return i(E,[{key:"toAnimation",value:function(e){return!e||"object"!==o(e)&&"function"!=typeof e?null:"use"in e?e.use():new y(s(s({},e),{},{scaleCorrection:this.props.scaleCorrection}),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var i=0,n=0;return v.forEach(e,(function(e){var r;if(d(e)){e.type===E&&(i=1);var o=t.countNestedLevels(null===(r=e.props)||void 0===r?void 0:r.children);n=n<o?o:n}})),n+i}},{key:"componentDidMount",value:function(){var e=this;this.elements.forEach((function(t){var i;null===(i=e.animations.default)||void 0===i||i.setInitialStyles(t)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),g("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll())}},{key:"componentWillUnmount",value:function(){w("scroll",this.scrollEventListener),this.props.onUnmount&&(this.props.parentLevel<1||this.props.noCascade)&&this.play(this.props.onUnmount,{reverse:!0,immediate:!0})}},{key:"inViewport",value:function(){var e=this,t=!0,i=!0;return this.elements.forEach((function(n){var r=n.getBoundingClientRect().y;t=t&&r+n.clientHeight*(1-e.viewportMargin)<window.innerHeight,i=i&&r>window.innerHeight+n.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var n=e.animatable.inViewport(),r=a(n,2),o=r[0],s=r[1];t=t&&o,i=i&&s})),[t,i]}},{key:"onScroll",value:(A=l(p().mark((function e(){var t,i,n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()-this.scrollDelta<350)){e.next=2;break}return e.abrupt("return");case 2:this.scrollDelta=Date.now(),t=this.inViewport(),i=a(t,2),n=i[0],r=i[1],!this.inView&&n&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&r&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return A.apply(this,arguments)})},{key:"onEnter",value:(x=l(p().mark((function e(t){var i,n=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),i&&i(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return x.apply(this,arguments)})},{key:"onLeave",value:(C=l(p().mark((function e(t){var i,n=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),i&&i(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"onFocus",value:(b=l(p().mark((function e(t){var i,n=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),i&&i(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"onBlur",value:(h=l(p().mark((function e(t){var i,n=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),i&&i(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"onClick",value:(c=l(p().mark((function e(t){var i,n=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),i&&i(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"play",value:(u=l(p().mark((function e(t){var i,n,r,o,s,a,l,u,c,h,v,d,f,m,y,g,w=this,b=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=b.length>1&&void 0!==b[1]?b[1]:{},n=i.callback,r=i.reverse,o=void 0!==r&&r,s=i.immediate,a=void 0!==s&&s,l=i.cascade,u=void 0!==l&&l,c=i.groupAdjust,h=void 0===c?0:c,v=i.cascadeDelay,d=void 0===v?0:v,f=i.staggerDelay,m=void 0===f?0:f,!(this.props.parentLevel>0)||u){e.next=3;break}return e.abrupt("return");case 3:if(y="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:g=0,this.elements.forEach((function(e,t){var i="group"in w.props?w.props.parentLevel-w.props.group:w.level+h;d=o?y.duration:d;var n=o?i*d:(w.props.parentLevel-i)*d;n=w.props.stagger*t+n+m,g=n>g?n:g,y.play(e,{delay:n,reverse:o,immediate:a})})),this.children.forEach((function(e){var i=e.animatable,n=e.staggerIndex,r=void 0===n?-1:n;null==i||i.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:r<0?0:w.props.stagger*r,cascadeDelay:y.duration,groupAdjust:r<0?0:1})})),n&&k.delay(n,g+y.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"style",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=s(s({},e),{},{transitionProperty:"transform, opacity, clip-path, border-radius, background-color, color, width, height, left, top",willChange:"transform"});return t}},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=s(s({},t),e);for(var n in i)["children","parentLevel","ref"].includes(n)?delete i[n]:"object"===o(e[n])&&"object"===o(t[n])&&(i[n]=s(s({},t[n]),e[n]));return i}},{key:"deepClone",value:function(e){var t,i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.index,o=void 0===r?0:r,a=n.useElements,l=void 0!==a&&a,p=n.useEvents,u=void 0!==p&&p;if(!d(e))return e;var c,h={};e.type!==E&&(l&&(h={style:this.style(null===(c=e.props)||void 0===c?void 0:c.style),ref:function(e){return i.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(h=s(s({},h),{},{onMouseEnter:function(t){var n;return i.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return i.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return i.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return i.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return i.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1));e.type!==E||null!==(t=e.props)&&void 0!==t&&t.noCascade||(h=s(s(s({},h),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return i.children[i.children.length]={animatable:e,staggerIndex:l?o:-1}}}));var m=v.map(e.props.children,(function(e,t){return i.deepClone(e,{index:t,useEvents:u})}));return Object.values(h).length?f(e,h,m):e}},{key:"render",value:function(){var e=this;return this.level=this.countNestedLevels(this.props.children),v.map(this.props.children,(function(t,i){return e.deepClone(t,{index:i,useElements:!0,useEvents:!0})}))}}]),E}();n(x,"defaultProps",{scaleCorrection:!1,parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var A=["levels","animations"],L=function(n){e(a,m);var o=t(a);function a(e){var t;return r(this,a),(t=o.call(this,e)).levels=t.props.levels,t.animations=new Array(t.levels).fill(0).map((function(e,i){return i<t.props.animations.length?t.props.animations[i]:t.props.animations[t.props.animations.length-1]})),t}return i(a,[{key:"makeAnimatable",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(i<1||v.count(e)<1)return e;var n=this.props;n.levels,n.animations;var r=u(n,A),o=this.animations[this.levels-i];return i===this.levels&&(r.ref=function(e){return t.animatable=e}),h.createElement(x,c({animate:o,scaleCorrection:o.scaleCorrection},r),v.map(e,(function(e){return d(e)?f(e,{},t.makeAnimatable(e.props.children,i-1)):e})))}},{key:"play",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,s(s({},i),{},{reverse:!0}))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),a}();n(L,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[b,C]});var E=function(n){e(s,x);var o=t(s);function s(e){var t;return r(this,s),(t=o.call(this,e)).animations.morphs=[],t}return i(s,[{key:"componentDidMount",value:function(){var e=this,t=this.elements[0];t&&(y.setInitial(t),t.setAttribute("uitools-morph-id",this.props.id),t.setAttribute("uitools-morph-active",this.props.active),this.self=t,this.createResetAnimation(),k.delay((function(){for(var i=document.querySelectorAll('[uitools-morph-id="'.concat(e.props.id,'"]')),n=0;n<i.length;n++)i[n]!==t&&(e.createMorphAnimation(i[n],n),"true"!==i[n].getAttribute("uitools-morph-active")&&e.animations.transition.setInitialStyles(i[n]))}),.001))}},{key:"componentDidUpdate",value:function(){var e=this,t="true"===this.self.getAttribute("uitools-morph-active");this.self.setAttribute("uitools-morph-active",this.props.active),k.delay((function(){if(e.props.active&&!t)e.animations.transition.setInitialStyles(e.self),e.animations.transition.play(e.self);else if(!e.props.active&&t){for(var i=0,n=document.querySelectorAll('[uitools-morph-id="'.concat(e.props.id,'"]')),r=0;r<n.length;r++)if(n[r]!==e.self&&"true"===n[r].getAttribute("uitools-morph-active")){i=r;break}e.animations.morphs[i].play(e.self)}}),.001)}},{key:"createResetAnimation",value:function(){var e,t=null===(e=this.self.UITools)||void 0===e?void 0:e.initialStyles;this.animations.transition=new y({opacity:[0,0,1],scale:{x:1,y:1},position:{x:0,y:0},borderRadius:t.borderRadius,backgroundColor:[t.backgroundColor,t.backgroundColor,t.backgroundColor],scaleCorrection:this.scaleCorrection},{})}},{key:"createMorphAnimation",value:function(e,t){var i,n,r=null===(i=this.self.UITools)||void 0===i?void 0:i.initialStyles,o=null===(n=e.UITools)||void 0===n?void 0:n.initialStyles;this.animations.morphs[t]=new y({position:[{x:0,y:0},{x:o.x-r.x+(o.clientWidth-r.clientWidth)/2,y:o.y-r.y+(o.clientHeight-r.clientHeight)/2},{x:o.x-r.x+(o.clientWidth-r.clientWidth)/2,y:o.y-r.y+(o.clientHeight-r.clientHeight)/2}],scale:[{x:1,y:1},{x:o.clientWidth/r.clientWidth,y:o.clientHeight/r.clientHeight},{x:o.clientWidth/r.clientWidth,y:o.clientHeight/r.clientHeight}],opacity:[1,1,0],borderRadius:[r.borderRadius,o.borderRadius,o.borderRadius],backgroundColor:[r.backgroundColor,o.backgroundColor,o.backgroundColor],scaleCorrection:this.scaleCorrection},{})}}]),s}();n(E,"defaultProps",{id:0,active:!1,scaleCorrection:!1});export{x as Animatable,L as Animate,E as Morph};
1
+ import e from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/helpers/typeof";import n from"@babel/runtime/helpers/classCallCheck";import i from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import u from"@babel/runtime/regenerator";import p,{Children as c,isValidElement as h,cloneElement as f,Component as v}from"react";import{A as y,a as d,r as m,b,M as g,P as w}from"./pop-262b0878.js";import k from"@babel/runtime/helpers/extends";import O from"@babel/runtime/helpers/objectWithoutProperties";import x from"@babel/runtime/helpers/get";import"@babel/runtime/helpers/toConsumableArray";function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var E=function(s){o(E,v);var a,l,p,g,w,k,O,x,P=A(E);function E(e){var t;for(var r in n(this,E),(t=P.call(this,e)).hover=!1,t.hasFocus=!1,t.inView=!1,t.scrollDelta=0,t.viewportMargin=e.viewportMargin,t.elements=[],t.animations={default:t.toAnimation(t.props.animate)},t.props.animations)t.animations[r]=t.toAnimation(t.props.animations[r]);return t.level=0,t.children=[],t}return i(E,[{key:"toAnimation",value:function(e){return!e||"object"!==r(e)&&"function"!=typeof e?null:"use"in e?e.use():new y(j({},e),this.props.initial)}},{key:"countNestedLevels",value:function(e){var t=this;if(!e)return 0;var r=0,n=0;return c.forEach(e,(function(e){var i;if(h(e)){e.type===E&&(r=1);var o=t.countNestedLevels(null===(i=e.props)||void 0===i?void 0:i.children);n=n<o?o:n}})),n+r}},{key:"componentDidMount",value:function(){var e=this;this.elements.forEach((function(t){var r;null===(r=e.animations.default)||void 0===r||r.setInitial(t,!0)})),(this.props.parentLevel<1||this.props.noCascade)&&(this.scrollEventListener=this.onScroll.bind(this),d("scroll",this.scrollEventListener),this.props.onMount&&this.play(this.props.onMount,{staggerDelay:.001,immediate:!0}),this.props.whileViewport&&this.onScroll())}},{key:"componentWillUnmount",value:function(){m("scroll",this.scrollEventListener),this.props.onUnmount&&(this.props.parentLevel<1||this.props.noCascade)&&this.play(this.props.onUnmount,{reverse:!0,immediate:!0})}},{key:"inViewport",value:function(){var e=this,r=!0,n=!0;return this.elements.forEach((function(t){var i=t.getBoundingClientRect().y;r=r&&i+t.clientHeight*(1-e.viewportMargin)<window.innerHeight,n=n&&i>window.innerHeight+t.clientHeight*e.viewportMargin})),this.elements.length||this.children.forEach((function(e){var i=e.animatable.inViewport(),o=t(i,2),s=o[0],a=o[1];r=r&&s,n=n&&a})),[r,n]}},{key:"onScroll",value:(x=e(u.mark((function e(){var r,n,i,o;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Date.now()-this.scrollDelta<350)){e.next=2;break}return e.abrupt("return");case 2:this.scrollDelta=Date.now(),r=this.inViewport(),n=t(r,2),i=n[0],o=n[1],!this.inView&&i&&(this.inView=!0,this.props.whileViewport&&this.play(this.props.whileViewport)),this.inView&&o&&(this.inView=!1,this.props.whileViewport&&this.play(this.props.whileViewport,{reverse:!0,immediate:!0}));case 6:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"onEnter",value:(O=e(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover||(this.props.whileHover&&this.play(this.props.whileHover),this.hover=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return O.apply(this,arguments)})},{key:"onLeave",value:(k=e(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hover&&(this.props.whileHover&&this.play(this.props.whileHover,{reverse:!0}),this.hover=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"onFocus",value:(w=e(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus||(this.props.whileFocus&&this.play(this.props.whileFocus),this.hasFocus=!0),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"onBlur",value:(g=e(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.hasFocus&&(this.props.whileFocus&&this.play(this.props.whileFocus,{reverse:!0}),this.hasFocus=!1),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"onClick",value:(p=e(u.mark((function e(t){var r,n=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],this.props.onClick&&this.play(this.props.onClick),r&&r(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"setInitial",value:(l=e(u.mark((function e(t){var r,n,i=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],n="string"==typeof t?this.animations[t]:this.animations.default){e.next=4;break}return e.abrupt("return");case 4:this.elements.forEach((function(e){n.setInitial(e,r)})),this.children.forEach((function(e){var n=e.animatable;null==n||n.setInitial(t,r)}));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"play",value:(a=e(u.mark((function e(t){var r,n,i,o,s,a,l,p,c,h,f,v,y,d,m,g,w=this,k=arguments;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=k.length>1&&void 0!==k[1]?k[1]:{},n=r.callback,i=r.reverse,o=void 0!==i&&i,s=r.immediate,a=void 0!==s&&s,l=r.cascade,p=void 0!==l&&l,c=r.groupAdjust,h=void 0===c?0:c,f=r.cascadeDelay,v=void 0===f?0:f,y=r.staggerDelay,d=void 0===y?0:y,!(this.props.parentLevel>0)||p){e.next=3;break}return e.abrupt("return");case 3:if(m="string"==typeof t?this.animations[t]:this.animations.default){e.next=6;break}return e.abrupt("return");case 6:g=0,this.elements.forEach((function(e,t){var r="group"in w.props?w.props.parentLevel-w.props.group:w.level+h;v=o?m.duration:v;var n=o?r*v:(w.props.parentLevel-r)*v;n=w.props.stagger*t+n+d,g=n>g?n:g,m.play(e,{delay:n,reverse:o,immediate:a})})),this.children.forEach((function(e){var r=e.animatable,n=e.staggerIndex,i=void 0===n?-1:n;null==r||r.play(t,{reverse:o,immediate:a,cascade:!0,staggerDelay:i<0?0:w.props.stagger*i,cascadeDelay:m.duration,groupAdjust:i<0?0:1})})),n&&b.delay(n,g+m.duration);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"style",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=j(j({},e),{},{transitionProperty:"transform, opacity, clip-path, border-radius, background-color, color, width, height, left, top",willChange:"transform"});return t}},{key:"mergeProperties",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=j(j({},t),e);for(var i in n)["children","parentLevel","ref"].includes(i)?delete n[i]:Array.isArray(e[i])||Array.isArray(t[i])||"object"===r(e[i])&&"object"===r(t[i])&&(n[i]=j(j({},t[i]),e[i]));return n}},{key:"deepClone",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.index,o=void 0===i?0:i,s=n.useElements,a=void 0!==s&&s,l=n.useEvents,u=void 0!==l&&l;if(!h(e))return e;var p,v={};e.type===E||e.type.prototype instanceof E||(a&&(v={style:this.style(null===(p=e.props)||void 0===p?void 0:p.style),ref:function(e){return r.elements[o]=e}}),u&&(this.props.parentLevel<1||this.props.noCascade)&&(v=j(j({},v),{},{onMouseEnter:function(t){var n;return r.onEnter(t,null===(n=e.props)||void 0===n?void 0:n.onMouseEnter)},onMouseLeave:function(t){var n;return r.onLeave(t,null===(n=e.props)||void 0===n?void 0:n.onMouseLeave)},onFocus:function(t){var n;return r.onFocus(t,null===(n=e.props)||void 0===n?void 0:n.onFocus)},onBlur:function(t){var n;return r.onBlur(t,null===(n=e.props)||void 0===n?void 0:n.onBlur)},onClick:function(t){var n;return r.onClick(t,null===(n=e.props)||void 0===n?void 0:n.onClick)}}),u=!1));!(e.type===E||e.type.prototype instanceof E)||null!==(t=e.props)&&void 0!==t&&t.noCascade||(v=j(j(j({},v),this.mergeProperties(e.props,this.props)),{},{parentLevel:this.parentLevel>0?this.parentLevel:this.level,ref:function(e){return r.children[r.childrenIndex++]={animatable:e,staggerIndex:a?o:-1}}}));var y=c.map(e.props.children,(function(e,t){return r.deepClone(e,{index:t,useEvents:u})}));return Object.values(v).length?f(e,v,y):e}},{key:"render",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props.children;return this.level=this.countNestedLevels(t),this.childrenIndex=0,c.map(t,(function(t,r){return e.deepClone(t,{index:r,useElements:!0,useEvents:!0})}))}}]),E}();l(E,"defaultProps",{parentLevel:0,stagger:.1,viewportMargin:.25,animate:{},animations:{}});var L=["levels","animations"];function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function D(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}var R=function(e){o(r,v);var t=D(r);function r(e){var i;return n(this,r),(i=t.call(this,e)).levels=i.props.levels,i.animations=new Array(i.levels).fill(0).map((function(e,t){return t<i.props.animations.length?i.props.animations[t]:i.props.animations[i.props.animations.length-1]})),i}return i(r,[{key:"makeAnimatable",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(r<1||c.count(e)<1)return e;var n=this.props;n.levels,n.animations;var i=O(n,L),o=this.animations[this.levels-r];return r===this.levels&&(i.ref=function(e){return t.animatable=e}),p.createElement(E,k({animate:o},i),c.map(e,(function(e){return h(e)?f(e,{},t.makeAnimatable(e.props.children,r-1)):e})))}},{key:"play",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(t=this.animatable)||void 0===t||t.play(e,S({},r))}},{key:"render",value:function(){return this.makeAnimatable(this.props.children,this.levels)}}]),r}();function I(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function F(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=a(e);if(t){var i=a(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}l(R,"defaultProps",{levels:1,stagger:.1,viewportMargin:.25,animations:[g,w]});var V=function(e){o(r,E);var t=F(r);function r(e){var i;return n(this,r),(i=t.call(this,e)).id=i.props.parentGroup+i.props.group,i}return i(r,[{key:"componentDidMount",value:function(){var e=this;this.element=this.elements[0],this.element&&(y.setInitial(this.element),this.animations.transition=this.createResetAnimation(),this.element.setAttribute("uitools-morph-id",this.id),this.element.setAttribute("uitools-morph-active",this.props.active),b.delay((function(){for(var t=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),r=0;r<t.length;r++)t[r]!==e.element&&(e.animations[r]=e.createMorphAnimation(t[r]));e.props.active||e.props.parentGroup.length||e.setInitial("transition")}),.001))}},{key:"componentDidUpdate",value:function(){var e=this;"true"===this.element.getAttribute("uitools-morph-active")!==this.props.active&&(this.element.setAttribute("uitools-morph-active",this.props.active),b.delay((function(){if(e.props.active)e.play("transition");else{for(var t=0,r=document.querySelectorAll('[uitools-morph-id="'.concat(e.id,'"]')),n=0;n<r.length;n++)if(r[n]!==e.element&&"true"===r[n].getAttribute("uitools-morph-active")){t=n;break}e.play(t.toString())}}),.001))}},{key:"getParentPosition",value:function(e){var t,r=this.props.useLayout?null===(t=e.parentElement)||void 0===t?void 0:t.parentElement:e.parentElement;return(null==r?void 0:r.getBoundingClientRect())||{x:0,y:0}}},{key:"positionKeyframes",value:function(e){var t,r,n=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,i=null===(r=e.UITools)||void 0===r?void 0:r.initialStyles,o=i.x-n.x,s=i.y-n.y;if(this.props.parentGroup.length){var a=this.getParentPosition(this.element),l=this.getParentPosition(e);o-=l.x-a.x,s-=l.y-a.y}return this.props.useLayout||(o+=(i.clientWidth-n.clientWidth)/2,s+=(i.clientHeight-n.clientHeight)/2),[{x:0,y:0},{x:o,y:s},{x:o,y:s}]}},{key:"scaleKeyframes",value:function(e,t){var r=t.clientWidth/e.clientWidth,n=t.clientHeight/e.clientHeight;return[{x:1,y:1},{x:r,y:n},{x:r,y:n}]}},{key:"createMorphAnimation",value:function(e){var t,n,i,o=null===(t=this.element.UITools)||void 0===t?void 0:t.initialStyles,s=null===(n=e.UITools)||void 0===n?void 0:n.initialStyles,a={useLayout:this.props.useLayout},l=I(r.properties);try{for(l.s();!(i=l.n()).done;){var u=i.value;if(!this.props.ignore.includes(u))switch(u){case"position":a[u]=this.positionKeyframes(e);break;case"scale":a[u]=this.scaleKeyframes(o,s);break;case"opacity":a[u]=[1,1,0];break;default:a[u]=[o[u],s[u],s[u]]}}}catch(e){l.e(e)}finally{l.f()}return new y(a)}},{key:"createResetAnimation",value:function(){var e,t,n=null===(e=this.element.UITools)||void 0===e?void 0:e.initialStyles,i={useLayout:this.props.useLayout},o=I(r.properties);try{for(o.s();!(t=o.n()).done;){var s=t.value;if(!this.props.ignore.includes(s))switch(s){case"position":i[s]={x:0,y:0};break;case"scale":i[s]={x:1,y:1};break;case"opacity":i[s]=[0,0,1];break;default:i[s]=[n[s],n[s],n[s]]}}}catch(e){o.e(e)}finally{o.f()}return new y(i)}},{key:"parentStyle",value:function(){return{position:"relative",background:"transparent",border:"none",pointerEvents:"none"}}},{key:"childStyle",value:function(){return{position:"absolute",margin:0,top:0,left:0,pointerEvents:"initial"}}},{key:"getChildren",value:function(e){var t=this;return c.map(e,(function(e){if(!h(e))return e;var n=e.type!==r?{}:{parentGroup:t.props.parentGroup+t.props.group};return f(e,n,t.getChildren(e.props.children))}))}},{key:"render",value:function(){var e,t=null!==(e=this.props.children)&&void 0!==e&&e.length?this.props.children[0]:this.props.children;if(!h(t))return t;var n=this.getChildren(t.props.children),i=this.props.useLayout?{style:this.childStyle()}:{},o=x(a(r.prototype),"render",this).call(this,f(t,i,n));return this.props.useLayout?f(t,{style:this.parentStyle()},o):o}}]),r}();l(V,"properties",["position","scale","opacity","backgroundColor","color","borderRadius"]),l(V,"defaultProps",{group:0,parentGroup:"",active:!1,useLayout:!1,ignore:[]});export{E as Animatable,R as Animate,V as Morph};
@@ -0,0 +1 @@
1
+ import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/objectWithoutProperties";import i from"@babel/runtime/helpers/slicedToArray";import n from"@babel/runtime/helpers/toConsumableArray";import r from"@babel/runtime/helpers/typeof";import o from"@babel/runtime/helpers/classCallCheck";import a from"@babel/runtime/helpers/createClass";import s from"@babel/runtime/helpers/asyncToGenerator";import l from"@babel/runtime/regenerator";var c=function(){function t(){o(this,t),this.queue=[],this.tick()}var e,i;return a(t,[{key:"tick",value:(i=s(l.mark((function t(){var e,i;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){t.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>e)){t.next=6;break}return this.queue.splice(0,i),t.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,t.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"search",value:function(t){for(var e,i,n=0,r=this.queue.length-1;n<=r;)if(e=n+r>>>1,(i=this.queue[e].timestamp-t.timestamp)<0)n=e+1;else{if(!(i>0))return e;r=e-1}return n}},{key:"insert",value:function(t){var e=this.search(t);this.queue.splice(e,0,t)}},{key:"delay",value:function(t,e){t instanceof Function&&this.insert({callback:t,timestamp:Date.now()+1e3*e})}}],[{key:"get",value:function(){return"UITools"in window||(window.UITools={}),"AnimationLoop"in window.UITools||(window.UITools.AnimationQueue=new t),window.UITools.AnimationQueue}},{key:"delay",value:(e=s(l.mark((function t(e,i){return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.get().delay(e,i));case 1:case"end":return t.stop()}}),t,this)}))),function(t,i){return e.apply(this,arguments)})},{key:"sleep",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){t.delay(i,e)}))}}]),t}(),u=function(t){var e=t.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),n=i(e,5);n[0];var r=n[1],o=n[2],a=n[3],s=n[4];return{r:parseInt(r.padStart(2,r),16),g:parseInt(o.padStart(2,o),16),b:parseInt(a.padStart(2,a),16),a:void 0!==s?parseInt(s,16):255}},d=function(t){var e=t.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),n=i(e,5);n[0];var r=n[1],o=n[2],a=n[3],s=n[4];return{r:parseInt(r),g:parseInt(o),b:parseInt(a),a:void 0!==s?parseInt(s):255}},p=function(t,e){var i;e instanceof Function&&(null!==(i=window.UITools)&&void 0!==i&&i.Events||(window.UITools={Events:{}}),t in window.UITools.Events||(window.UITools.Events[t]={unique:0},window.addEventListener(t,(function(e){Object.values(window.UITools.Events[t]).forEach((function(t){t instanceof Function&&t(e)}))}))),e.UITools={ListenerID:window.UITools.Events[t].unique},window.UITools.Events[t][window.UITools.Events[t].unique]=e,window.UITools.Events[t].unique++)},f=function(t,e){var i,n,r;"undefined"!=typeof window&&null!==(i=window.UITools)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[t]&&null!=e&&null!==(r=e.UITools)&&void 0!==r&&r.ListenerID&&delete window.UITools.Events[t][e.UITools.ListenerID]},h=["delay","duration","repeat","interpolate","origin","useLayout"],y=function(){function t(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=i.delay,r=void 0===n?0:n,a=i.duration,s=void 0===a?1:a,l=i.repeat,c=void 0===l?1:l,u=i.interpolate,d=void 0===u?"ease":u,p=i.origin,f=void 0===p?{x:.5,y:.5}:p,y=i.useLayout,v=void 0!==y&&y,g=e(i,h),b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,t),this.useLayout=v,this.keyframes=this.getKeyframes(g,b),this.delay=r,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation=d,this.origin=this.originToStyle(f),this.repeat=c}return a(t,[{key:"originToStyle",value:function(t){var e=.5,i=.5;if("object"===r(t))e=t.x,i=t.y;else if("string"==typeof t)switch(t){case"left":e=0;break;case"right":e=1;break;case"top":i=0;break;case"bottom":i=1}else e=i=t;return"".concat(100*e,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(e){var i=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=0,a=function(a){var s=a in r?r[a]:t.initials[a];Array.isArray(e[a])||(e[a]=[e[a]]),e[a]=e[a].length>1?e[a]:[s].concat(n(e[a])),e[a]=e[a].map((function(t){return i.sanitize(a,t)})),o=e[a].length>o?e[a].length:o};for(var s in e)a(s);return new Array(o).fill(0).map((function(n,r){var a={};for(var s in e)s in t.initials&&(a[s]=i.interpolateKeyframe(e[s],r,o));return i.keyframeToStyle(a)}))}},{key:"sanitize",value:function(e,i){var n=this,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof i){if(i.match(/^#[0-9a-f]{3,8}$/i))return u(i);if(i.match(/^rgba?\(.*\)$/i))return d(i);var a=parseFloat(i),s=i.match(/[^0-9\.]*$/i);return isNaN(a)?t.initials[e]:("%"===s&&(a/=100),s?[a,s]:a)}if("object"===r(i)){var l=Object.keys(i);("x"in i||"y"in i)&&(l=["x","y"]),("r"in i||"g"in i||"b"in i||"a"in i)&&(l=["r","g","b","a"]),("left"in i||"right"in i||"top"in i||"bottom"in i)&&(l=["left","right","top","bottom"]),l.forEach((function(t){i[t]=n.sanitize(e,i[t],t)}))}return void 0!==i?i:o?t.initials[e][o]:t.initials[e]}},{key:"interpolate",value:function(t,e,i){if("string"==typeof t||"string"==typeof e)return i>.5?e:t;var n=!1;Array.isArray(t)&&(n=t[1],t=t[0]),Array.isArray(e)&&(n=e[1],e=e[0]);var r=t*(1-i)+e*i;return n?[r,n]:r}},{key:"interpolateKeyframe",value:function(t,e,i){var n=this;if(t.length===i)return t[e];var o=e*((t.length-1)/(i-1)),a=Math.floor(o),s=t[a];if(a===t.length-1)return s;var l=t[a+1];if("object"===r(s)){var c={};return Object.keys(s).forEach((function(t){c[t]=n.interpolate(s[t],l[t],o-a)})),c}return this.interpolate(s,l,o-a)}},{key:"toString",value:function(t,e){return Array.isArray(t)&&(e=t[1],t=t[0]),t*("%"===e?100:1)+e}},{key:"toLength",value:function(t){return Array.isArray(t)&&(t="px"===t[1]?t[0]+"px":t[0]),t}},{key:"keyframeToStyle",value:function(t){var e=this,n={transform:""};return Object.entries(t).forEach((function(t){var r=i(t,2),o=r[0],a=r[1];switch(o){case"position":n.transform+="translate(".concat(e.toString(a.x,"px"),", ").concat(e.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),e.useLayout){n.width=e.toLength(a.x),n.height=e.toLength(a.y);break}n.transform+="scale(".concat(e.toString(a.x,"%"),", ").concat(e.toString(a.y,"%"),") ");break;case"rotation":n.transform+="rotate(".concat((e.toString(a),"deg"),") ");break;case"clip":n.clipPath="inset(".concat(e.toString(a.top,"%")," ").concat(e.toString(a.right,"%")," ").concat(e.toString(a.bottom,"%")," ").concat(e.toString(a.left,"%"),")");break;case"borderRadius":n[o]=e.toString(a,"px");break;case"backgroundColor":case"color":n[o]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"opacity":case"active":n[o]=a}})),n.transform.length||delete n.transform,n}},{key:"setInitial",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i&&t.setInitial(e),e.style.transitionDuration="0s";var n=this.keyframes[0];this.apply(e,n,!0)}},{key:"test",value:function(t,e,i,n,r,o){var a=n+r+((i-=e-(t="string"==typeof t?parseInt(t)/e:t)*e)<0?i:0),s=n/(n+r);return{size:(i<0?0:i)+"px",padStart:(n=o?t*n:a*s)+"px",padEnd:(r=o?t*r:a*(1-s))+"px"}}},{key:"apply",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=function(){var r=t.UITools.initialStyles;Object.entries(e).forEach((function(e){var o=i(e,2),a=o[0],s=o[1];if("width"===a){var l=r.clientWidth,c=r.width,u=r.paddingLeft,d=r.paddingRight,p=r.includePadding,f=n.test(s,l,c,u,d,p),h=f.size,y=f.padStart,v=f.padEnd;return t.style.width=h,t.style.paddingLeft=y,void(t.style.paddingRight=v)}if("height"===a){var g=r.clientHeight,b=r.height,m=r.paddingTop,w=r.paddingBottom,k=r.includePadding,I=n.test(s,g,b,m,w,k),x=I.size,T=I.padStart,O=I.padEnd;return t.style.height=x,t.style.paddingTop=T,void(t.style.paddingBottom=O)}"active"!==a&&(t.style[a]=s)}))};if("active"in e){var a=Object.keys(e.active)[0];"start"===a||r?(t.style.display=e.active[a]?"":"none",r?o():c.delay(o,.01)):(c.delay((function(){t.style.display=e.active[a]?"":"none"}),this.delta),o())}else o()}},{key:"start",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.immediate,n=void 0!==i&&i,r=e.reverse,o=void 0!==r&&r,a=e.repeat,s=void 0===a?this.repeat:a;!t.UITools.animating||n?(this.setInitial(t),t.style.transitionDuration="".concat(this.delta,"s"),t.style.transitionTimingFunction=this.interpolation,t.style.transformOrigin=this.origin,t.UITools.animating=!0,t.UITools.index=1,this.getNext(t,o,s)):t.UITools.queue.push([this,{reverse:o,repeat:s}])}},{key:"play",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,r=void 0===n?0:n,o=i.immediate,a=void 0!==o&&o,s=i.reverse,l=void 0!==s&&s;t.style&&(this.delay||r?c.delay((function(){return e.start(t,{immediate:a,reverse:l})}),this.delay+r):this.start(t,{immediate:a,reverse:l}))}},{key:"getNext",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(t.UITools.index===this.keyframes.length){t.UITools.animating=!1;var o=t.UITools.queue.shift()||[],a=i(o,2),s=a[0],l=a[1];return s?s.start(t,l):void(r>1&&this.start(t,{reverse:n,repeat:r-1}))}var u=t.UITools.index;n&&(u=this.keyframes.length-1-u),requestAnimationFrame((function(){e.apply(t,e.keyframes[u])})),t.UITools.index++,c.delay((function(){return e.getNext(t,n,r)}),this.delta)}}],[{key:"setInitial",value:function(t){var e=getComputedStyle(t),i=e.width,n=e.height,r=e.paddingLeft,o=e.paddingRight,a=e.paddingTop,s=e.paddingBottom,l=e.borderRadius,c=e.boxSizing,u=e.backgroundColor,d=e.color,p=t.getBoundingClientRect(),f=p.x,h=p.y;"UITools"in t||(t.UITools={}),"queue"in t.UITools||(t.UITools.queue=[]),"initialStyles"in t.UITools||(t.UITools.initialStyles={x:f,y:h,includePadding:"border-box"===c,clientWidth:t.clientWidth,clientHeight:t.clientHeight,width:parseInt(i),height:parseInt(n),paddingLeft:parseInt(r),paddingRight:parseInt(o),paddingTop:parseInt(a),paddingBottom:parseInt(s),borderRadius:parseInt(l.split(" ")[0]),backgroundColor:u,color:d})}}]),t}();t(y,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,active:{start:!0},backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255}});var v=["direction"];function g(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function b(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?g(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function m(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return m.use=m.use.bind(m,t),m}function w(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function k(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?w(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function I(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return I.use=I.use.bind(I,t),I}m.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.direction,n=void 0===i?"up":i,r=e(t,v),o="0px",a="20px";switch(n){case"down":a="-20px";break;case"left":o="20px",a="0px";break;case"right":o="-20px",a="0px"}return new y(b({position:{x:"0px",y:"0px"},opacity:1,duration:.5},r),{position:{x:o,y:a},opacity:0})},I.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new y(k({opacity:1,scale:1,duration:.25},t),{opacity:0,scale:.85})};export{y as A,m as M,I as P,p as a,c as b,f as r};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinityfx/lively",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Zero configuration, performant react animation library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -18,6 +18,7 @@
18
18
  "require": "./dist/cjs/hooks.js"
19
19
  }
20
20
  },
21
+ "types": "./types/index.d.ts",
21
22
  "repository": "infinityfx-llc/lively",
22
23
  "author": "InfinityFX <contact@infinity-fx.com> (https://infinity-fx.com)",
23
24
  "license": "GPL-3.0",
@@ -32,21 +33,24 @@
32
33
  "animate"
33
34
  ],
34
35
  "scripts": {
35
- "build": "rollup -c",
36
+ "build": "rollup -c --environment NODE_ENV:production",
36
37
  "watch": "rollup -c -w"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "react": ">=16.0.0",
40
- "react-dom": ">=16.0.0"
41
+ "react-dom": ">=16.0.0",
42
+ "@babel/runtime": "^7.0.0"
41
43
  },
42
44
  "devDependencies": {
43
45
  "@babel/core": "^7.18.6",
44
46
  "@babel/preset-env": "^7.18.6",
45
47
  "@babel/preset-react": "^7.18.6",
48
+ "@babel/plugin-transform-runtime": "^7.18.6",
46
49
  "@rollup/plugin-babel": "^5.3.1",
47
50
  "@rollup/plugin-node-resolve": "^13.3.0",
48
51
  "rollup": "^2.75.7",
49
- "rollup-plugin-terser": "^7.0.2"
52
+ "rollup-plugin-terser": "^7.0.2",
53
+ "rollup-plugin-delete": "^2.0.0"
50
54
  },
51
55
  "sideEffects": false
52
56
  }
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+
3
+ declare interface Animatable {
4
+ stagger?: number;
5
+ viewportMargin?: number;
6
+ animate?: object;
7
+ initial?: object;
8
+ animations?: object;
9
+ noCascade?: boolean;
10
+ onMount?: string | boolean;
11
+ onUnmount?: string | boolean;
12
+ whileViewport?: string | boolean;
13
+ whileHover?: string | boolean;
14
+ whileFocus?: string | boolean;
15
+ }
16
+
17
+ export class Animatable extends React.Component<Animatable> {
18
+
19
+ private toAnimation;
20
+
21
+ private countNestedLevels;
22
+
23
+ private inViewport;
24
+
25
+ private onScroll;
26
+
27
+ private onEnter;
28
+
29
+ private onLeave;
30
+
31
+ private onFocus;
32
+
33
+ private onBlur;
34
+
35
+ private onClick;
36
+
37
+ setInitial(animationName: string, reset?: boolean): Promise<void>;
38
+
39
+ play(animationName: string, { callback, reverse, immediate, cascade, groupAdjust, cascadeDelay, staggerDelay }?: {
40
+ callback?: Function;
41
+ reverse?: boolean;
42
+ immediate?: boolean;
43
+ cascade?: boolean;
44
+ groupAdjust?: number;
45
+ cascadeDelay?: number;
46
+ staggerDelay?: number;
47
+ }): Promise<void>;
48
+
49
+ private style;
50
+
51
+ private mergeProperties;
52
+
53
+ private deepClone;
54
+
55
+ }
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ declare interface Animate {
4
+ stagger?: number;
5
+ viewportMargin?: number;
6
+ animations?: array;
7
+ onMount?: string | boolean;
8
+ onUnmount?: string | boolean;
9
+ whileViewport?: string | boolean;
10
+ whileHover?: string | boolean;
11
+ whileFocus?: string | boolean;
12
+ }
13
+
14
+ export class Animate extends React.Component<Animate> {
15
+
16
+ private makeAnimatable;
17
+
18
+ play(animationName: string, { callback, reverse, immediate, cascade, groupAdjust, cascadeDelay, staggerDelay }?: {
19
+ callback?: Function;
20
+ reverse?: boolean;
21
+ immediate?: boolean;
22
+ cascade?: boolean;
23
+ groupAdjust?: number;
24
+ cascadeDelay?: number;
25
+ staggerDelay?: number;
26
+ }): Promise<void>;
27
+
28
+ }
@@ -0,0 +1,4 @@
1
+ export as namespace Lively;
2
+
3
+ export { Animatable } from './animatable';
4
+ export { Morph } from './morph';
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ declare interface Morph {
4
+ active?: boolean;
5
+ group?: number;
6
+ useLayout?: boolean;
7
+ }
8
+
9
+ export class Morph extends React.Component<Morph> {
10
+
11
+ private getParentPosition;
12
+
13
+ private positionKeyframes;
14
+
15
+ private scaleKeyframes;
16
+
17
+ private createMorphAnimation;
18
+
19
+ private createResetAnimation;
20
+
21
+ private parentStyle;
22
+
23
+ private childStyle;
24
+
25
+ private getChildren;
26
+
27
+ }
@@ -1,3 +0,0 @@
1
- "use strict";function t(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function r(){
2
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
3
- r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function f(t,r,e,n){var o=r&&r.prototype instanceof p?r:p,i=Object.create(o.prototype),a=new _(n||[]);return i._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var c=O(a,e);if(c){if(c===s)continue;return c}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var u=l(t,r,e);if("normal"===u.type){if(n=e.done?"completed":"suspendedYield",u.arg===s)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(n="completed",e.method="throw",e.arg=u.arg)}}}(t,e,a),i}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var s={};function p(){}function h(){}function y(){}var v={};u(v,i,(function(){return this}));var d=Object.getPrototypeOf,b=d&&d(d(E([])));b&&b!==e&&n.call(b,i)&&(v=b);var m=y.prototype=p.prototype=Object.create(v);function g(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function w(t,r){function e(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var f=u.arg,s=f.value;return s&&"object"==typeof s&&n.call(s,"__await")?r.resolve(s.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(s).then((function(t){f.value=t,a(f)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}}function O(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,O(t,r),"throw"===r.method))return s;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=l(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,s;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,s):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,s)}function j(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function x(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function E(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,o=function r(){for(;++e<t.length;)if(n.call(t,e))return r.value=t[e],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return h.prototype=y,u(m,"constructor",y),u(y,"constructor",h),h.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===h||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new w(f(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=E,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),s},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),x(e),s}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;x(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:E(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),s}},t}function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function o(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function a(){return a=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},a.apply(this,arguments)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function u(t,r){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},u(t,r)}function f(t,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function l(t,r){if(t){if("string"==typeof t)return s(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?s(t,r):void 0}}function s(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}exports._asyncToGenerator=function(t){return function(){var r=this,e=arguments;return new Promise((function(o,i){var a=t.apply(r,e);function c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}},exports._classCallCheck=function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")},exports._createClass=function(t,r,e){return r&&o(t.prototype,r),e&&o(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t},exports._createSuper=function(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var e,n=c(t);if(r){var o=c(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return f(this,e)}},exports._defineProperty=i,exports._extends=a,exports._inherits=function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&u(t,r)},exports._objectSpread2=function(r){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?t(Object(n),!0).forEach((function(t){i(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))}))}return r},exports._objectWithoutProperties=function(t,r){if(null==t)return{};var e,n,o=function(t,r){if(null==t)return{};var e,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)e=i[n],r.indexOf(e)>=0||(o[e]=t[e]);return o}(t,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)e=i[n],r.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(o[e]=t[e])}return o},exports._regeneratorRuntime=r,exports._slicedToArray=function(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==e)return;var n,o,i=[],a=!0,c=!1;try{for(e=e.call(t);!(a=(n=e.next()).done)&&(i.push(n.value),!r||i.length!==r);a=!0);}catch(t){c=!0,o=t}finally{try{a||null==e.return||e.return()}finally{if(c)throw o}}return i}(t,r)||l(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},exports._toConsumableArray=function(t){return function(t){if(Array.isArray(t))return s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||l(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()},exports._typeof=e;
@@ -1 +0,0 @@
1
- "use strict";var t=require("./_rollupPluginBabelHelpers-7a0b7756.js"),e=function(){function e(){t._classCallCheck(this,e),this.queue=[],this.tick()}var i,n;return t._createClass(e,[{key:"tick",value:(n=t._asyncToGenerator(t._regeneratorRuntime().mark((function e(){var i,n;return t._regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=Date.now(),n=0;case 2:if(!(n<this.queue.length+1)){t.next=10;break}if(!(this.queue.length===n||this.queue[n].timestamp>i)){t.next=6;break}return this.queue.splice(0,n),t.abrupt("break",10);case 6:this.queue[n].callback();case 7:n++,t.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return t.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"search",value:function(t){for(var e,i,n=0,o=this.queue.length-1;n<=o;)if(e=n+o>>>1,(i=this.queue[e].timestamp-t.timestamp)<0)n=e+1;else{if(!(i>0))return e;o=e-1}return n}},{key:"insert",value:function(t){var e=this.search(t);this.queue.splice(e,0,t)}},{key:"delay",value:function(t,e){t instanceof Function&&this.insert({callback:t,timestamp:Date.now()+1e3*e})}}],[{key:"get",value:function(){return"UITools"in window||(window.UITools={}),"AnimationLoop"in window.UITools||(window.UITools.AnimationQueue=new e),window.UITools.AnimationQueue}},{key:"delay",value:(i=t._asyncToGenerator(t._regeneratorRuntime().mark((function e(i,n){return t._regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.get().delay(i,n));case 1:case"end":return t.stop()}}),e,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"sleep",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){t.delay(i,e)}))}}]),e}(),i=function(e){var i=e.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),n=t._slicedToArray(i,5);n[0];var o=n[1],r=n[2],a=n[3],s=n[4];return{r:parseInt(o.padStart(2,o),16),g:parseInt(r.padStart(2,r),16),b:parseInt(a.padStart(2,a),16),a:void 0!==s?parseInt(s,16):255}},n=function(e){var i=e.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),n=t._slicedToArray(i,5);n[0];var o=n[1],r=n[2],a=n[3],s=n[4];return{r:parseInt(o),g:parseInt(r),b:parseInt(a),a:void 0!==s?parseInt(s):255}},o=["delay","duration","loop","interpolate","origin","scaleCorrection"],r=function(){function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.delay,n=void 0===i?0:i,a=e.duration,s=void 0===a?1:a,l=e.loop,c=void 0!==l&&l,u=e.interpolate,d=void 0===u?"ease":u,p=e.origin,h=void 0===p?{x:.5,y:.5}:p,v=e.scaleCorrection,f=void 0!==v&&v,y=t._objectWithoutProperties(e,o),g=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t._classCallCheck(this,r),this.scaleCorrection=f,this.keyframes=this.getKeyframes(y,g),this.delay=n,this.duration=s,this.delta=s/(this.keyframes.length-1),this.interpolation=d,this.origin=this.originToStyle(h),this.loop=c}return t._createClass(r,[{key:"originToStyle",value:function(e){var i=.5,n=.5;if("object"===t._typeof(e))i=e.x,n=e.y;else if("string"==typeof e)switch(e){case"left":i=0;break;case"right":i=1;break;case"top":n=0;break;case"bottom":n=1}else i=n=e;return"".concat(100*i,"% ").concat(100*n,"%")}},{key:"getKeyframes",value:function(e){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=0,a=function(a){var s=a in n?n[a]:r.initials[a];Array.isArray(e[a])||(e[a]=[e[a]]),e[a]=e[a].length>1?e[a]:[s].concat(t._toConsumableArray(e[a])),e[a]=e[a].map((function(t){return i.sanitize(a,t)})),o=e[a].length>o?e[a].length:o};for(var s in e)a(s);return new Array(o).fill(0).map((function(t,n){var a={};for(var s in e)s in r.initials&&(a[s]=i.interpolateKeyframe(e[s],n,o));return i.keyframeToStyle(a)}))}},{key:"sanitize",value:function(e,o){var a=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof o){if(o.match(/^#[0-9a-f]{3,8}$/i))return i(o);if(o.match(/^rgba?\(.*\)$/i))return n(o);var l=parseFloat(o),c=o.match(/[^0-9\.]*$/i);return isNaN(l)?r.initials[e]:("%"===c&&(l/=100),c?[l,c]:l)}if("object"===t._typeof(o)){var u=Object.keys(o);("x"in o||"y"in o)&&(u=["x","y"]),("r"in o||"g"in o||"b"in o||"a"in o)&&(u=["r","g","b","a"]),("left"in o||"right"in o||"top"in o||"bottom"in o)&&(u=["left","right","top","bottom"]),u.forEach((function(t){o[t]=a.sanitize(e,o[t],t)}))}return void 0!==o?o:r.initials[e][s]}},{key:"interpolate",value:function(t,e,i){if("string"==typeof t||"string"==typeof e)return i>.5?e:t;var n=!1;Array.isArray(t)&&(n=t[1],t=t[0]),Array.isArray(e)&&(n=e[1],e=e[0]);var o=t*(1-i)+e*i;return n?[o,n]:o}},{key:"interpolateKeyframe",value:function(e,i,n){var o=this;if(e.length===n)return e[i];var r=i*((e.length-1)/(n-1)),a=Math.floor(r),s=e[a];if(a===e.length-1)return s;var l=e[a+1];if("object"===t._typeof(s)){var c={};return Object.keys(s).forEach((function(t){c[t]=o.interpolate(s[t],l[t],r-a)})),c}return this.interpolate(s,l,r-a)}},{key:"toString",value:function(t,e){return Array.isArray(t)&&(e=t[1],t=t[0]),t*("%"===e?100:1)+e}},{key:"toLength",value:function(t){return Array.isArray(t)&&(t="px"===t[1]?t[0]+"px":t[0]),t}},{key:"keyframeToStyle",value:function(e){var i=this,n={transform:""};return Object.entries(e).forEach((function(e){var o=t._slicedToArray(e,2),r=o[0],a=o[1];switch(r){case"position":n.transform+="translate(".concat(i.toString(a.x,"px"),", ").concat(i.toString(a.y,"px"),") ");break;case"scale":if("number"==typeof a&&(a={x:a,y:a}),i.scaleCorrection){n.width=i.toLength(a.x),n.height=i.toLength(a.y);break}n.transform+="scale(".concat(i.toString(a.x,"%"),", ").concat(i.toString(a.y,"%"),") ");break;case"rotation":n.transform+="rotate(".concat((i.toString(a),"deg"),") ");break;case"clip":n.clipPath="inset(".concat(i.toString(a.top,"%")," ").concat(i.toString(a.right,"%")," ").concat(i.toString(a.bottom,"%")," ").concat(i.toString(a.left,"%"),")");break;case"borderRadius":n[r]=i.toString(a,"px");break;case"backgroundColor":case"color":n[r]="rgba(".concat(a.r,", ").concat(a.g,", ").concat(a.b,", ").concat(a.a,")");break;case"opacity":case"active":n[r]=a}})),n.transform.length||delete n.transform,n}},{key:"setInitialStyles",value:function(t){r.setInitial(t);var e=this.keyframes[0];t.style.transitionDuration="0s",this.apply(t,e,!0)}},{key:"test",value:function(t,e,i,n,o,r){var a=n+o+((i-=e-(t="string"==typeof t?parseInt(t)/e:t)*e)<0?i:0),s=n/(n+o);return{size:(i<0?0:i)+"px",padStart:(n=r?t*n:a*s)+"px",padEnd:(o=r?t*o:a*(1-s))+"px"}}},{key:"apply",value:function(i,n){var o=this,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=function(){var e=i.UITools.initialStyles;Object.entries(n).forEach((function(n){var r=t._slicedToArray(n,2),a=r[0],s=r[1];if("width"===a){var l=e.clientWidth,c=e.width,u=e.paddingLeft,d=e.paddingRight,p=e.includePadding,h=o.test(s,l,c,u,d,p),v=h.size,f=h.padStart,y=h.padEnd;return i.style.width=v,i.style.paddingLeft=f,void(i.style.paddingRight=y)}if("height"===a){var g=e.clientHeight,m=e.height,b=e.paddingTop,k=e.paddingBottom,w=e.includePadding,I=o.test(s,g,m,b,k,w),x=I.size,T=I.padStart,U=I.padEnd;return i.style.height=x,i.style.paddingTop=T,void(i.style.paddingBottom=U)}"active"!==a&&(i.style[a]=s)}))};if("active"in n){var s=Object.keys(n.active)[0];"start"===s||r?(i.style.display=n.active[s]?"":"none",r?a():e.delay(a,.01)):(e.delay((function(){i.style.display=n.active[s]?"":"none"}),this.delta),a())}else a()}},{key:"start",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.immediate,n=void 0!==i&&i,o=e.reverse,r=void 0!==o&&o;!t.UITools.animating||n?(t.style.transitionDuration="".concat(this.delta,"s"),t.style.transitionTimingFunction=this.interpolation,t.style.transformOrigin=this.origin,t.UITools.animating=!0,t.UITools.index=1,this.getNext(t,r)):t.UITools.queue.push([this,{reverse:r}])}},{key:"play",value:function(t){var i=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.delay,r=void 0===o?0:o,a=n.immediate,s=void 0!==a&&a,l=n.reverse,c=void 0!==l&&l;t.style&&(this.delay||r?e.delay((function(){return i.start(t,{immediate:s,reverse:c})}),this.delay+r):this.start(t,{immediate:s,reverse:c}))}},{key:"getNext",value:function(i){var n=this,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(i.UITools.index===this.keyframes.length){i.UITools.animating=!1;var r=i.UITools.queue.shift()||[],a=t._slicedToArray(r,2),s=a[0],l=a[1];return s?s.start(i,l):void(this.loop&&this.start(i,l))}var c=i.UITools.index;o&&(c=this.keyframes.length-1-c),requestAnimationFrame((function(){n.apply(i,n.keyframes[c])})),i.UITools.index++,e.delay((function(){return n.getNext(i,o)}),this.delta)}}],[{key:"setInitial",value:function(t){var e=getComputedStyle(t),i=e.width,n=e.height,o=e.paddingLeft,r=e.paddingRight,a=e.paddingTop,s=e.paddingBottom,l=e.borderRadius,c=e.boxSizing,u=e.backgroundColor,d=e.color,p=t.getBoundingClientRect(),h=p.x,v=p.y;"UITools"in t||(t.UITools={}),"queue"in t.UITools||(t.UITools.queue=[]),"initialStyles"in t.UITools||(t.UITools.initialStyles={x:h,y:v,includePadding:"border-box"===c,clientWidth:t.clientWidth,clientHeight:t.clientHeight,width:parseInt(i),height:parseInt(n),paddingLeft:parseInt(o),paddingRight:parseInt(r),paddingTop:parseInt(a),paddingBottom:parseInt(s),borderRadius:parseInt(l.split(" ")[0]),backgroundColor:u,color:d})}}]),r}();function a(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:t.scaleCorrection,use:a.use.bind(this,t)}}function s(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:t.scaleCorrection,use:s.use.bind(this,t)}}t._defineProperty(r,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,active:{start:!0},backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255}}),a.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.direction,i=void 0===e?"up":e,n=t.scaleCorrection,o=void 0!==n&&n,a="0px",s="20px";switch(i){case"down":s="-20px";break;case"left":a="20px",s="0px";break;case"right":a="-20px",s="0px"}return new r({position:{x:"0px",y:"0px"},opacity:1,scaleCorrection:o,duration:.5},{position:{x:a,y:s},opacity:0})},s.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.scaleCorrection,i=void 0!==e&&e;return new r({opacity:1,scale:1,scaleCorrection:i,duration:.25},{opacity:0,scale:.85})},exports.Animation=r,exports.AnimationQueue=e,exports.Move=a,exports.Pop=s,exports.addEventListener=function(t,e){var i;e instanceof Function&&(null!==(i=window.UITools)&&void 0!==i&&i.Events||(window.UITools={Events:{}}),t in window.UITools.Events||(window.UITools.Events[t]={unique:0},window.addEventListener(t,(function(e){Object.values(window.UITools.Events[t]).forEach((function(t){t instanceof Function&&t(e)}))}))),e.UITools={ListenerID:window.UITools.Events[t].unique},window.UITools.Events[t][window.UITools.Events[t].unique]=e,window.UITools.Events[t].unique++)},exports.removeEventListener=function(t,e){var i,n,o;"undefined"!=typeof window&&null!==(i=window.UITools)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[t]&&null!=e&&null!==(o=e.UITools)&&void 0!==o&&o.ListenerID&&delete window.UITools.Events[t][e.UITools.ListenerID]};
@@ -1,3 +0,0 @@
1
- function t(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,n)}return e}function r(r){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?t(Object(n),!0).forEach((function(t){f(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))}))}return r}function e(){
2
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
3
- e=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function f(t,r,e,n){var o=r&&r.prototype instanceof h?r:h,i=Object.create(o.prototype),a=new E(n||[]);return i._invoke=function(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return L()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var c=O(a,e);if(c){if(c===s)continue;return c}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var u=l(t,r,e);if("normal"===u.type){if(n=e.done?"completed":"suspendedYield",u.arg===s)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(n="completed",e.method="throw",e.arg=u.arg)}}}(t,e,a),i}function l(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var s={};function h(){}function p(){}function y(){}var v={};u(v,i,(function(){return this}));var d=Object.getPrototypeOf,b=d&&d(d(P([])));b&&b!==r&&n.call(b,i)&&(v=b);var m=y.prototype=h.prototype=Object.create(v);function g(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function w(t,r){function e(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var f=u.arg,s=f.value;return s&&"object"==typeof s&&n.call(s,"__await")?r.resolve(s.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(s).then((function(t){f.value=t,a(f)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,n){function i(){return new r((function(r,o){e(t,n,r,o)}))}return o=o?o.then(i,i):i()}}function O(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,O(t,r),"throw"===r.method))return s;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=l(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,s;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,s):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,s)}function j(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function x(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,o=function r(){for(;++e<t.length;)if(n.call(t,e))return r.value=t[e],r.done=!1,r;return r.value=void 0,r.done=!0,r};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,u(m,"constructor",y),u(y,"constructor",p),p.displayName=u(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===p||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new w(f(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},g(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=P,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),s},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),x(e),s}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;x(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:P(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),s}},t}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function i(t){return function(){var r=this,e=arguments;return new Promise((function(n,i){var a=t.apply(r,e);function c(t){o(a,n,i,c,u,"next",t)}function u(t){o(a,n,i,c,u,"throw",t)}c(void 0)}))}}function a(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function c(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function u(t,r,e){return r&&c(t.prototype,r),e&&c(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function l(){return l=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},l.apply(this,arguments)}function s(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&p(t,r)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function p(t,r){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},p(t,r)}function y(t,r){if(null==t)return{};var e,n,o=function(t,r){if(null==t)return{};var e,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)e=i[n],r.indexOf(e)>=0||(o[e]=t[e]);return o}(t,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)e=i[n],r.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(o[e]=t[e])}return o}function v(t,r){if(r&&("object"==typeof r||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function d(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var e,n=h(t);if(r){var o=h(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return v(this,e)}}function b(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==e)return;var n,o,i=[],a=!0,c=!1;try{for(e=e.call(t);!(a=(n=e.next()).done)&&(i.push(n.value),!r||i.length!==r);a=!0);}catch(t){c=!0,o=t}finally{try{a||null==e.return||e.return()}finally{if(c)throw o}}return i}(t,r)||g(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t){return function(t){if(Array.isArray(t))return w(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||g(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t,r){if(t){if("string"==typeof t)return w(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?w(t,r):void 0}}function w(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}export{s as _,d as a,u as b,f as c,a as d,n as e,r as f,b as g,i as h,e as i,y as j,l as k,m as l};
@@ -1 +0,0 @@
1
- import{b as t,d as e,h as i,i as n,g as a,e as o,c as r,j as s,l}from"./_rollupPluginBabelHelpers-e1425fd3.js";var c=function(){function a(){e(this,a),this.queue=[],this.tick()}var o,r;return t(a,[{key:"tick",value:(r=i(n().mark((function t(){var e,i;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=Date.now(),i=0;case 2:if(!(i<this.queue.length+1)){t.next=10;break}if(!(this.queue.length===i||this.queue[i].timestamp>e)){t.next=6;break}return this.queue.splice(0,i),t.abrupt("break",10);case 6:this.queue[i].callback();case 7:i++,t.next=2;break;case 10:requestAnimationFrame(this.tick.bind(this));case 11:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"search",value:function(t){for(var e,i,n=0,a=this.queue.length-1;n<=a;)if(e=n+a>>>1,(i=this.queue[e].timestamp-t.timestamp)<0)n=e+1;else{if(!(i>0))return e;a=e-1}return n}},{key:"insert",value:function(t){var e=this.search(t);this.queue.splice(e,0,t)}},{key:"delay",value:function(t,e){t instanceof Function&&this.insert({callback:t,timestamp:Date.now()+1e3*e})}}],[{key:"get",value:function(){return"UITools"in window||(window.UITools={}),"AnimationLoop"in window.UITools||(window.UITools.AnimationQueue=new a),window.UITools.AnimationQueue}},{key:"delay",value:(o=i(n().mark((function t(e,i){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.get().delay(e,i));case 1:case"end":return t.stop()}}),t,this)}))),function(t,e){return o.apply(this,arguments)})},{key:"sleep",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(i){t.delay(i,e)}))}}]),a}(),u=function(t){var e=t.match(/^#([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?/i),i=a(e,5);i[0];var n=i[1],o=i[2],r=i[3],s=i[4];return{r:parseInt(n.padStart(2,n),16),g:parseInt(o.padStart(2,o),16),b:parseInt(r.padStart(2,r),16),a:void 0!==s?parseInt(s,16):255}},d=function(t){var e=t.match(/^rgba?\((\d+)\D+(\d+)\D+(\d+)\D*(\d+)?\)/i),i=a(e,5);i[0];var n=i[1],o=i[2],r=i[3],s=i[4];return{r:parseInt(n),g:parseInt(o),b:parseInt(r),a:void 0!==s?parseInt(s):255}},h=function(t,e){var i;e instanceof Function&&(null!==(i=window.UITools)&&void 0!==i&&i.Events||(window.UITools={Events:{}}),t in window.UITools.Events||(window.UITools.Events[t]={unique:0},window.addEventListener(t,(function(e){Object.values(window.UITools.Events[t]).forEach((function(t){t instanceof Function&&t(e)}))}))),e.UITools={ListenerID:window.UITools.Events[t].unique},window.UITools.Events[t][window.UITools.Events[t].unique]=e,window.UITools.Events[t].unique++)},p=function(t,e){var i,n,a;"undefined"!=typeof window&&null!==(i=window.UITools)&&void 0!==i&&null!==(n=i.Events)&&void 0!==n&&n[t]&&null!=e&&null!==(a=e.UITools)&&void 0!==a&&a.ListenerID&&delete window.UITools.Events[t][e.UITools.ListenerID]},v=["delay","duration","loop","interpolate","origin","scaleCorrection"],f=function(){function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.delay,a=void 0===n?0:n,o=t.duration,r=void 0===o?1:o,l=t.loop,c=void 0!==l&&l,u=t.interpolate,d=void 0===u?"ease":u,h=t.origin,p=void 0===h?{x:.5,y:.5}:h,f=t.scaleCorrection,g=void 0!==f&&f,y=s(t,v),m=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(this,i),this.scaleCorrection=g,this.keyframes=this.getKeyframes(y,m),this.delay=a,this.duration=r,this.delta=r/(this.keyframes.length-1),this.interpolation=d,this.origin=this.originToStyle(p),this.loop=c}return t(i,[{key:"originToStyle",value:function(t){var e=.5,i=.5;if("object"===o(t))e=t.x,i=t.y;else if("string"==typeof t)switch(t){case"left":e=0;break;case"right":e=1;break;case"top":i=0;break;case"bottom":i=1}else e=i=t;return"".concat(100*e,"% ").concat(100*i,"%")}},{key:"getKeyframes",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=0,o=function(o){var r=o in n?n[o]:i.initials[o];Array.isArray(t[o])||(t[o]=[t[o]]),t[o]=t[o].length>1?t[o]:[r].concat(l(t[o])),t[o]=t[o].map((function(t){return e.sanitize(o,t)})),a=t[o].length>a?t[o].length:a};for(var r in t)o(r);return new Array(a).fill(0).map((function(n,o){var r={};for(var s in t)s in i.initials&&(r[s]=e.interpolateKeyframe(t[s],o,a));return e.keyframeToStyle(r)}))}},{key:"sanitize",value:function(t,e){var n=this,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("string"==typeof e){if(e.match(/^#[0-9a-f]{3,8}$/i))return u(e);if(e.match(/^rgba?\(.*\)$/i))return d(e);var r=parseFloat(e),s=e.match(/[^0-9\.]*$/i);return isNaN(r)?i.initials[t]:("%"===s&&(r/=100),s?[r,s]:r)}if("object"===o(e)){var l=Object.keys(e);("x"in e||"y"in e)&&(l=["x","y"]),("r"in e||"g"in e||"b"in e||"a"in e)&&(l=["r","g","b","a"]),("left"in e||"right"in e||"top"in e||"bottom"in e)&&(l=["left","right","top","bottom"]),l.forEach((function(i){e[i]=n.sanitize(t,e[i],i)}))}return void 0!==e?e:i.initials[t][a]}},{key:"interpolate",value:function(t,e,i){if("string"==typeof t||"string"==typeof e)return i>.5?e:t;var n=!1;Array.isArray(t)&&(n=t[1],t=t[0]),Array.isArray(e)&&(n=e[1],e=e[0]);var a=t*(1-i)+e*i;return n?[a,n]:a}},{key:"interpolateKeyframe",value:function(t,e,i){var n=this;if(t.length===i)return t[e];var a=e*((t.length-1)/(i-1)),r=Math.floor(a),s=t[r];if(r===t.length-1)return s;var l=t[r+1];if("object"===o(s)){var c={};return Object.keys(s).forEach((function(t){c[t]=n.interpolate(s[t],l[t],a-r)})),c}return this.interpolate(s,l,a-r)}},{key:"toString",value:function(t,e){return Array.isArray(t)&&(e=t[1],t=t[0]),t*("%"===e?100:1)+e}},{key:"toLength",value:function(t){return Array.isArray(t)&&(t="px"===t[1]?t[0]+"px":t[0]),t}},{key:"keyframeToStyle",value:function(t){var e=this,i={transform:""};return Object.entries(t).forEach((function(t){var n=a(t,2),o=n[0],r=n[1];switch(o){case"position":i.transform+="translate(".concat(e.toString(r.x,"px"),", ").concat(e.toString(r.y,"px"),") ");break;case"scale":if("number"==typeof r&&(r={x:r,y:r}),e.scaleCorrection){i.width=e.toLength(r.x),i.height=e.toLength(r.y);break}i.transform+="scale(".concat(e.toString(r.x,"%"),", ").concat(e.toString(r.y,"%"),") ");break;case"rotation":i.transform+="rotate(".concat((e.toString(r),"deg"),") ");break;case"clip":i.clipPath="inset(".concat(e.toString(r.top,"%")," ").concat(e.toString(r.right,"%")," ").concat(e.toString(r.bottom,"%")," ").concat(e.toString(r.left,"%"),")");break;case"borderRadius":i[o]=e.toString(r,"px");break;case"backgroundColor":case"color":i[o]="rgba(".concat(r.r,", ").concat(r.g,", ").concat(r.b,", ").concat(r.a,")");break;case"opacity":case"active":i[o]=r}})),i.transform.length||delete i.transform,i}},{key:"setInitialStyles",value:function(t){i.setInitial(t);var e=this.keyframes[0];t.style.transitionDuration="0s",this.apply(t,e,!0)}},{key:"test",value:function(t,e,i,n,a,o){var r=n+a+((i-=e-(t="string"==typeof t?parseInt(t)/e:t)*e)<0?i:0),s=n/(n+a);return{size:(i<0?0:i)+"px",padStart:(n=o?t*n:r*s)+"px",padEnd:(a=o?t*a:r*(1-s))+"px"}}},{key:"apply",value:function(t,e){var i=this,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=function(){var n=t.UITools.initialStyles;Object.entries(e).forEach((function(e){var o=a(e,2),r=o[0],s=o[1];if("width"===r){var l=n.clientWidth,c=n.width,u=n.paddingLeft,d=n.paddingRight,h=n.includePadding,p=i.test(s,l,c,u,d,h),v=p.size,f=p.padStart,g=p.padEnd;return t.style.width=v,t.style.paddingLeft=f,void(t.style.paddingRight=g)}if("height"===r){var y=n.clientHeight,m=n.height,b=n.paddingTop,k=n.paddingBottom,w=n.includePadding,I=i.test(s,y,m,b,k,w),x=I.size,T=I.padStart,U=I.padEnd;return t.style.height=x,t.style.paddingTop=T,void(t.style.paddingBottom=U)}"active"!==r&&(t.style[r]=s)}))};if("active"in e){var r=Object.keys(e.active)[0];"start"===r||n?(t.style.display=e.active[r]?"":"none",n?o():c.delay(o,.01)):(c.delay((function(){t.style.display=e.active[r]?"":"none"}),this.delta),o())}else o()}},{key:"start",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.immediate,n=void 0!==i&&i,a=e.reverse,o=void 0!==a&&a;!t.UITools.animating||n?(t.style.transitionDuration="".concat(this.delta,"s"),t.style.transitionTimingFunction=this.interpolation,t.style.transformOrigin=this.origin,t.UITools.animating=!0,t.UITools.index=1,this.getNext(t,o)):t.UITools.queue.push([this,{reverse:o}])}},{key:"play",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i.delay,a=void 0===n?0:n,o=i.immediate,r=void 0!==o&&o,s=i.reverse,l=void 0!==s&&s;t.style&&(this.delay||a?c.delay((function(){return e.start(t,{immediate:r,reverse:l})}),this.delay+a):this.start(t,{immediate:r,reverse:l}))}},{key:"getNext",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(t.UITools.index===this.keyframes.length){t.UITools.animating=!1;var n=t.UITools.queue.shift()||[],o=a(n,2),r=o[0],s=o[1];return r?r.start(t,s):void(this.loop&&this.start(t,s))}var l=t.UITools.index;i&&(l=this.keyframes.length-1-l),requestAnimationFrame((function(){e.apply(t,e.keyframes[l])})),t.UITools.index++,c.delay((function(){return e.getNext(t,i)}),this.delta)}}],[{key:"setInitial",value:function(t){var e=getComputedStyle(t),i=e.width,n=e.height,a=e.paddingLeft,o=e.paddingRight,r=e.paddingTop,s=e.paddingBottom,l=e.borderRadius,c=e.boxSizing,u=e.backgroundColor,d=e.color,h=t.getBoundingClientRect(),p=h.x,v=h.y;"UITools"in t||(t.UITools={}),"queue"in t.UITools||(t.UITools.queue=[]),"initialStyles"in t.UITools||(t.UITools.initialStyles={x:p,y:v,includePadding:"border-box"===c,clientWidth:t.clientWidth,clientHeight:t.clientHeight,width:parseInt(i),height:parseInt(n),paddingLeft:parseInt(a),paddingRight:parseInt(o),paddingTop:parseInt(r),paddingBottom:parseInt(s),borderRadius:parseInt(l.split(" ")[0]),backgroundColor:u,color:d})}}]),i}();function g(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:t.scaleCorrection,use:g.use.bind(this,t)}}function y(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{scaleCorrection:t.scaleCorrection,use:y.use.bind(this,t)}}r(f,"initials",{opacity:1,scale:{x:1,y:1},position:{x:0,y:0},clip:{left:0,top:0,right:0,bottom:0},borderRadius:0,active:{start:!0},backgroundColor:{r:127,g:127,b:127,a:255},color:{r:127,g:127,b:127,a:255}}),g.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.direction,i=void 0===e?"up":e,n=t.scaleCorrection,a=void 0!==n&&n,o="0px",r="20px";switch(i){case"down":r="-20px";break;case"left":o="20px",r="0px";break;case"right":o="-20px",r="0px"}return new f({position:{x:"0px",y:"0px"},opacity:1,scaleCorrection:a,duration:.5},{position:{x:o,y:r},opacity:0})},y.use=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.scaleCorrection,i=void 0!==e&&e;return new f({opacity:1,scale:1,scaleCorrection:i,duration:.25},{opacity:0,scale:.85})};export{f as A,g as M,y as P,h as a,c as b,p as r};