-
Notifications
You must be signed in to change notification settings - Fork 3
/
react_media_queryable.min.js
2 lines (2 loc) · 3.15 KB
/
react_media_queryable.min.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.MediaQueryable=t(require("react")):e.MediaQueryable=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var n=r(1),i=r(2),o=r(3);e.exports=n.createClass({displayName:"MediaQueryable",mediaListener:null,propTypes:{className:n.PropTypes.string,defaultMediaQuery:n.PropTypes.string.isRequired,mediaQueries:n.PropTypes.object.isRequired,style:n.PropTypes.object},getInitialState:function(){return{mediaQuery:void 0}},componentDidMount:function(){this.mediaListener=new i(this.props.mediaQueries,this._onMediaQueryChange)},componentWillUnmount:function(){this.mediaListener&&this.mediaListener.stopListening()},render:function(){var e=this._currentMediaQuery();if(!e)return null;var t=n.Children.map(this.props.children,function(e){if(null!==e)return n.cloneElement(e,{mediaQuery:this._currentMediaQuery()})},this);return n.DOM.div(o({},{children:t,className:this.props.className,style:this.props.style}))},_currentMediaQuery:function(){return this.state.mediaQuery||this.props.defaultMediaQuery||null},_onMediaQueryChange:function(e){this.setState({mediaQuery:e})}})},function(t,r){t.exports=e},function(e,t){function r(e,t){this.changeHandler=t,this.mqls=this._buildMediaQueryLists(e)}r.prototype.stopListening=function(){var e;for(e in this.mqls){var t=this.mqls[e];t.removeListener&&t.removeListener(t._fn)}},r.prototype._buildMediaQueryLists=function(e){if(!window.matchMedia)return{};var t,r={};for(t in e){var n=this._setupListeners(t,e[t]);r[t]=n,this._handleMediaQueryChange(n.matches,t)}return r},r.prototype._setupListeners=function(e,t){if(window.matchMedia){var r=window.matchMedia(t);return r._fn=function(t){return this._handleMediaQueryChange(t.matches,e)}.bind(this),r.addListener(r._fn),r}},r.prototype._handleMediaQueryChange=function(e,t){if(e)return this.changeHandler(t)},e.exports=r},function(e,t){"use strict";function r(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function n(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;var n=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==n.join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(e){i[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(o){return!1}}var i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=n()?Object.assign:function(e,t){for(var n,s,a=r(e),u=1;u<arguments.length;u++){n=Object(arguments[u]);for(var c in n)i.call(n,c)&&(a[c]=n[c]);if(Object.getOwnPropertySymbols){s=Object.getOwnPropertySymbols(n);for(var d=0;d<s.length;d++)o.call(n,s[d])&&(a[s[d]]=n[s[d]])}}return a}}])});
//# sourceMappingURL=react_media_queryable.js.map