rxan-react
Version:
Rxan (RxJS Animation) adaptor library for react
3 lines (2 loc) • 4.21 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("react"))&&"object"==typeof t&&"default"in t?t.default:t;function o(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t}).apply(this,arguments)}function a(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}exports.withRxan=function(t,c){return function(p){switch(void 0!==c.startPropName&&console.warn("Config 'startPropName' is deprecated. Please use 'mapAnimationToProps' instead."),void 0!==c.stopPropName&&console.warn("Config 'stopPropName' is deprecated. Please use 'mapAnimationToProps' instead."),void 0!==c.valuePropName&&console.warn("Config 'valuePropName' is deprecated. Please use 'mapAnimationToProps' instead."),(c=function(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?a(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):a(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({startPropName:"start",stopPropName:"stop",valuePropName:"value",autoStartAt:"nothing",stopBeforeAutoStart:!1,mapAnimationToProps:function(t,e,o){var r;return n(r={},this.valuePropName,t),n(r,this.startPropName,e),n(r,this.stopPropName,o),r}},c)).autoStartAt){case"nothing":case"constructor":case"componentDidMount":case"componentWillUpdate":case"componentDidUpdate":break;default:console.error("Config autoStartAt has invalid value. It should be one of the following.\n undefined\n 'nothing'\n 'constructor'\n 'componentDidMount'\n 'componentWillUpdate'\n 'componentDidUpdate'")}return function(n){function a(t,e){var o,n,r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),n=this,(o=!(r=i(a).call(this,t,e))||"object"!=typeof r&&"function"!=typeof r?u(n):r).state={lastValue:void 0},o.subscription=void 0,o.autoStart=o.autoStart.bind(u(o)),o.start=o.start.bind(u(o)),o.stop=o.stop.bind(u(o)),"constructor"===c.autoStartAt&&o.autoStart(),o}var l,f,b;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(a,e.Component),l=a,(f=[{key:"componentDidMount",value:function(){"componentDidMount"===c.autoStartAt&&this.autoStart()}},{key:"componentWillUpdate",value:function(){"componentWillUpdate"===c.autoStartAt&&this.autoStart()}},{key:"componentDidUpdate",value:function(){"componentDidUpdate"===c.autoStartAt&&this.autoStart()}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"autoStart",value:function(){c.stopBeforeAutoStart&&this.stop(),this.start()}},{key:"start",value:function(){var e=this;this.subscription||(this.subscription=t.subscribe((function(t){e.setState({lastValue:t})}),void 0,(function(){e.stop()})))}},{key:"stop",value:function(){this.subscription&&(this.subscription.unsubscribe(),this.subscription=void 0)}},{key:"render",value:function(){var t=c.mapAnimationToProps(this.state.lastValue,this.start,this.stop);return e.createElement(p,r({},this.props,t))}}])&&o(l.prototype,f),b&&o(l,b),a}()}};
//# sourceMappingURL=index.cjs.min.js.map
;