react-native-web-headroom
Version:
React Native Web Headroom
1,432 lines (1,126 loc) • 189 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
else if(typeof exports === 'object')
exports["Radium"] = factory(require("react"));
else
root["Radium"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 64);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout() {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
})();
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch (e) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch (e) {
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e) {
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e) {
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while (len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () {
return '/';
};
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function () {
return 0;
};
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (prefixedValue, value, keepUnprefixed) {
return keepUnprefixed ? [prefixedValue, value] : prefixedValue;
};
module.exports = exports["default"];
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
} else {
obj[key] = value;
}return obj;
}
// returns a style object with a single concated prefixed value string
exports.default = function (property, value) {
var replacer = arguments.length <= 2 || arguments[2] === undefined ? function (prefix, value) {
return prefix + value;
} : arguments[2];
return _defineProperty({}, property, ['-webkit-', '-moz-', ''].map(function (prefix) {
return replacer(prefix, value);
}));
};
module.exports = exports['default'];
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
if (process.env.NODE_ENV !== 'production') {
var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element') || 0xeac7;
var isValidElement = function isValidElement(object) {
return (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
};
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = __webpack_require__(59)(isValidElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(58)();
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
// helper to capitalize strings
exports.default = function (str) {
return str.charAt(0).toUpperCase() + str.slice(1);
};
module.exports = exports["default"];
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (value) {
if (Array.isArray(value)) value = value.join(',');
return value.match(/-webkit-|-moz-|-ms-/) !== null;
};
module.exports = exports['default'];
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
function makeEmptyFunction(arg) {
return function () {
return arg;
};
}
/**
* This function accepts and discards inputs; it has no side effects. This is
* primarily useful idiomatically for overridable function endpoints which
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
*/
var emptyFunction = function emptyFunction() {};
emptyFunction.thatReturns = makeEmptyFunction;
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
emptyFunction.thatReturnsThis = function () {
return this;
};
emptyFunction.thatReturnsArgument = function (arg) {
return arg;
};
module.exports = emptyFunction;
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var validateFormat = function validateFormat(format) {};
if (process.env.NODE_ENV !== 'production') {
validateFormat = function validateFormat(format) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
};
}
function invariant(condition, format, a, b, c, d, e, f) {
validateFormat(format);
if (!condition) {
var error;
if (format === undefined) {
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
module.exports = invariant;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = cssRuleSetToString;
var _appendPxIfNeeded = __webpack_require__(21);
var _appendPxIfNeeded2 = _interopRequireDefault(_appendPxIfNeeded);
var _camelCasePropsToDashCase = __webpack_require__(62);
var _camelCasePropsToDashCase2 = _interopRequireDefault(_camelCasePropsToDashCase);
var _mapObject = __webpack_require__(24);
var _mapObject2 = _interopRequireDefault(_mapObject);
var _prefixer = __webpack_require__(10);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function createMarkupForStyles(style) {
return Object.keys(style).map(function (property) {
return property + ': ' + style[property] + ';';
}).join('\n');
}
function cssRuleSetToString(selector, rules, userAgent) {
if (!rules) {
return '';
}
var rulesWithPx = (0, _mapObject2.default)(rules, function (value, key) {
return (0, _appendPxIfNeeded2.default)(key, value);
});
var prefixedRules = (0, _prefixer.getPrefixedStyle)(rulesWithPx, userAgent);
var cssPrefixedRules = (0, _camelCasePropsToDashCase2.default)(prefixedRules);
var serializedRules = createMarkupForStyles(cssPrefixedRules);
return selector + '{' + serializedRules + '}';
}
module.exports = exports['default'];
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(global, process) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
* Based on https://github.com/jsstyles/css-vendor, but without having to
* convert between different cases all the time.
*
*
*/
exports.getPrefixedKeyframes = getPrefixedKeyframes;
exports.getPrefixedStyle = getPrefixedStyle;
var _inlineStylePrefixer = __webpack_require__(31);
var _inlineStylePrefixer2 = _interopRequireDefault(_inlineStylePrefixer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function transformValues(style) {
return Object.keys(style).reduce(function (newStyle, key) {
var value = style[key];
if (Array.isArray(value)) {
value = value.join(';' + key + ':');
} else if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && typeof value.toString === 'function') {
value = value.toString();
}
newStyle[key] = value;
return newStyle;
}, {});
}
var _hasWarnedAboutUserAgent = false;
var _lastUserAgent = void 0;
var _cachedPrefixer = void 0;
function getPrefixer(userAgent) {
var actualUserAgent = userAgent || global && global.navigator && global.navigator.userAgent;
if (process.env.NODE_ENV !== 'production') {
if (!actualUserAgent && !_hasWarnedAboutUserAgent) {
/* eslint-disable no-console */
console.warn('Radium: userAgent should be supplied for server-side rendering. See ' + 'https://github.com/FormidableLabs/radium/tree/master/docs/api#radium ' + 'for more information.');
/* eslint-enable no-console */
_hasWarnedAboutUserAgent = true;
}
}
if (!_cachedPrefixer || actualUserAgent !== _lastUserAgent) {
if (actualUserAgent === 'all') {
_cachedPrefixer = {
prefix: _inlineStylePrefixer2.default.prefixAll,
prefixedKeyframes: 'keyframes'
};
} else {
_cachedPrefixer = new _inlineStylePrefixer2.default({ userAgent: actualUserAgent });
}
_lastUserAgent = actualUserAgent;
}
return _cachedPrefixer;
}
function getPrefixedKeyframes(userAgent) {
return getPrefixer(userAgent).prefixedKeyframes;
}
// Returns a new style object with vendor prefixes added to property names
// and values.
function getPrefixedStyle(style, userAgent) {
var styleWithFallbacks = transformValues(style);
var prefixer = getPrefixer(userAgent);
var prefixedStyle = prefixer.prefix(styleWithFallbacks);
return prefixedStyle;
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(60), __webpack_require__(0)))
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var StyleKeeper = function () {
function StyleKeeper(userAgent) {
_classCallCheck(this, StyleKeeper);
this._userAgent = userAgent;
this._listeners = [];
this._cssSet = {};
}
StyleKeeper.prototype.subscribe = function subscribe(listener) {
var _this = this;
if (this._listeners.indexOf(listener) === -1) {
this._listeners.push(listener);
}
return {
// Must be fat arrow to capture `this`
remove: function remove() {
var listenerIndex = _this._listeners.indexOf(listener);
if (listenerIndex > -1) {
_this._listeners.splice(listenerIndex, 1);
}
}
};
};
StyleKeeper.prototype.addCSS = function addCSS(css) {
var _this2 = this;
if (!this._cssSet[css]) {
this._cssSet[css] = true;
this._emitChange();
}
return {
// Must be fat arrow to capture `this`
remove: function remove() {
delete _this2._cssSet[css];
_this2._emitChange();
}
};
};
StyleKeeper.prototype.getCSS = function getCSS() {
return Object.keys(this._cssSet).join('\n');
};
StyleKeeper.prototype._emitChange = function _emitChange() {
this._listeners.forEach(function (listener) {
return listener();
});
};
return StyleKeeper;
}();
exports.default = StyleKeeper;
module.exports = exports['default'];
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.default = enhanceWithRadium;
var _react = __webpack_require__(2);
var _propTypes = __webpack_require__(4);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _styleKeeper = __webpack_require__(11);
var _styleKeeper2 = _interopRequireDefault(_styleKeeper);
var _resolveStyles = __webpack_require__(15);
var _resolveStyles2 = _interopRequireDefault(_resolveStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var KEYS_TO_IGNORE_WHEN_COPYING_PROPERTIES = ['arguments', 'callee', 'caller', 'length', 'name', 'prototype', 'type'];
function copyProperties(source, target) {
Object.getOwnPropertyNames(source).forEach(function (key) {
if (KEYS_TO_IGNORE_WHEN_COPYING_PROPERTIES.indexOf(key) < 0 && !target.hasOwnProperty(key)) {
var descriptor = Object.getOwnPropertyDescriptor(source, key);
Object.defineProperty(target, key, descriptor);
}
});
}
function isStateless(component) {
return !component.render && !(component.prototype && component.prototype.render);
}
// Check if value is a real ES class in Native / Node code.
// See: https://stackoverflow.com/a/30760236
function isNativeClass(component) {
return typeof component === 'function' && /^\s*class\s+/.test(component.toString());
}
// Manually apply babel-ish class inheritance.
function inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError('Super expression must either be null or a function, not ' + (typeof superClass === 'undefined' ? 'undefined' : _typeof(superClass)));
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(subClass, superClass);
} else {
subClass.__proto__ = superClass; // eslint-disable-line no-proto
}
}
}
function enhanceWithRadium(configOrComposedComponent) {
var _class, _temp;
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (typeof configOrComposedComponent !== 'function') {
var newConfig = _extends({}, config, configOrComposedComponent);
return function (configOrComponent) {
return enhanceWithRadium(configOrComponent, newConfig);
};
}
var component = configOrComposedComponent;
var ComposedComponent = component;
// Handle Native ES classes.
if (isNativeClass(ComposedComponent)) {
// Manually approximate babel's class transpilation, but _with_ a real `new` call.
ComposedComponent = function (OrigComponent) {
function NewComponent() {
// Ordinarily, babel would produce something like:
//
// ```
// return _possibleConstructorReturn(this, OrigComponent.apply(this, arguments));
// ```
//
// Instead, we just call `new` directly without the `_possibleConstructorReturn` wrapper.
var source = new (Function.prototype.bind.apply(OrigComponent, [null].concat(Array.prototype.slice.call(arguments))))();
// Then we manually update context with properties.
copyProperties(source, this);
return this;
}
inherits(NewComponent, OrigComponent);
return NewComponent;
}(ComposedComponent);
}
// Handle stateless components
if (isStateless(ComposedComponent)) {
ComposedComponent = function (_Component) {
_inherits(ComposedComponent, _Component);
function ComposedComponent() {
_classCallCheck(this, ComposedComponent);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
ComposedComponent.prototype.render = function render() {
return component(this.props, this.context);
};
return ComposedComponent;
}(_react.Component);
ComposedComponent.displayName = component.displayName || component.name;
}
var RadiumEnhancer = (_temp = _class = function (_ComposedComponent) {
_inherits(RadiumEnhancer, _ComposedComponent);
function RadiumEnhancer() {
_classCallCheck(this, RadiumEnhancer);
var _this2 = _possibleConstructorReturn(this, _ComposedComponent.apply(this, arguments));
_this2.state = _this2.state || {};
_this2.state._radiumStyleState = {};
_this2._radiumIsMounted = true;
return _this2;
}
RadiumEnhancer.prototype.componentWillUnmount = function componentWillUnmount() {
if (_ComposedComponent.prototype.componentWillUnmount) {
_ComposedComponent.prototype.componentWillUnmount.call(this);
}
this._radiumIsMounted = false;
if (this._radiumMouseUpListener) {
this._radiumMouseUpListener.remove();
}
if (this._radiumMediaQueryListenersByQuery) {
Object.keys(this._radiumMediaQueryListenersByQuery).forEach(function (query) {
this._radiumMediaQueryListenersByQuery[query].remove();
}, this);
}
};
RadiumEnhancer.prototype.getChildContext = function getChildContext() {
var superChildContext = _ComposedComponent.prototype.getChildContext ? _ComposedComponent.prototype.getChildContext.call(this) : {};
if (!this.props.radiumConfig) {
return superChildContext;
}
var newContext = _extends({}, superChildContext);
if (this.props.radiumConfig) {
newContext._radiumConfig = this.props.radiumConfig;
}
return newContext;
};
RadiumEnhancer.prototype.render = function render() {
var renderedElement = _ComposedComponent.prototype.render.call(this);
var currentConfig = this.props.radiumConfig || this.context._radiumConfig || config;
if (config && currentConfig !== config) {
currentConfig = _extends({}, config, currentConfig);
}
return (0, _resolveStyles2.default)(this, renderedElement, currentConfig);
};
return RadiumEnhancer;
}(ComposedComponent), _class._isRadiumEnhanced = true, _temp);
// Class inheritance uses Object.create and because of __proto__ issues
// with IE <10 any static properties of the superclass aren't inherited and
// so need to be manually populated.
// See http://babeljs.io/docs/advanced/caveats/#classes-10-and-below-
copyProperties(component, RadiumEnhancer);
if (process.env.NODE_ENV !== 'production') {
// This also fixes React Hot Loader by exposing the original components top
// level prototype methods on the Radium enhanced prototype as discussed in
// https://github.com/FormidableLabs/radium/issues/219.
copyProperties(ComposedComponent.prototype, RadiumEnhancer.prototype);
}
if (RadiumEnhancer.propTypes && RadiumEnhancer.propTypes.style) {
RadiumEnhancer.propTypes = _extends({}, RadiumEnhancer.propTypes, {
style: _propTypes2.default.oneOfType([_propTypes2.default.array, _propTypes2.default.object])
});
}
RadiumEnhancer.displayName = component.displayName || component.name || 'Component';
RadiumEnhancer.contextTypes = _extends({}, RadiumEnhancer.contextTypes, {
_radiumConfig: _propTypes2.default.object,
_radiumStyleKeeper: _propTypes2.default.instanceOf(_styleKeeper2.default)
});
RadiumEnhancer.childContextTypes = _extends({}, RadiumEnhancer.childContextTypes, {
_radiumConfig: _propTypes2.default.object,
_radiumStyleKeeper: _propTypes2.default.instanceOf(_styleKeeper2.default)
});
return RadiumEnhancer;
}
module.exports = exports['default'];
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _getStateKey = __webpack_require__(22);
var _getStateKey2 = _interopRequireDefault(_getStateKey);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getState = function getState(state, elementKey, value) {
var key = (0, _getStateKey2.default)(elementKey);
return !!state && !!state._radiumStyleState && !!state._radiumStyleState[key] && state._radiumStyleState[key][value];
};
exports.default = getState;
module.exports = exports['default'];
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _checkPropsPlugin = __webpack_require__(66);
var _checkPropsPlugin2 = _interopRequireDefault(_checkPropsPlugin);
var _keyframesPlugin = __webpack_require__(67);
var _keyframesPlugin2 = _interopRequireDefault(_keyframesPlugin);
var _mergeStyleArrayPlugin = __webpack_require__(68);
var _mergeStyleArrayPlugin2 = _interopRequireDefault(_mergeStyleArrayPlugin);
var _prefixPlugin = __webpack_require__(70);
var _prefixPlugin2 = _interopRequireDefault(_prefixPlugin);
var _removeNestedStylesPlugin = __webpack_require__(71);
var _removeNestedStylesPlugin2 = _interopRequireDefault(_removeNestedStylesPlugin);
var _resolveInteractionStylesPlugin = __webpack_require__(72);
var _resolveInteractionStylesPlugin2 = _interopRequireDefault(_resolveInteractionStylesPlugin);
var _resolveMediaQueriesPlugin = __webpack_require__(73);
var _resolveMediaQueriesPlugin2 = _interopRequireDefault(_resolveMediaQueriesPlugin);
var _visitedPlugin = __webpack_require__(74);
var _visitedPlugin2 = _interopRequireDefault(_visitedPlugin);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
checkProps: _checkPropsPlugin2.default,
keyframes: _keyframesPlugin2.default,
mergeStyleArray: _mergeStyleArrayPlugin2.default,
prefix: _prefixPlugin2.default,
removeNestedStyles: _removeNestedStylesPlugin2.default,
resolveInteractionStyles: _resolveInteractionStylesPlugin2.default,
resolveMediaQueries: _resolveMediaQueriesPlugin2.default,
visited: _visitedPlugin2.default
};
/* eslint-disable block-scoped-const */
module.exports = exports['default'];
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _appendImportantToEachValue = __webpack_require__(61);
var _appendImportantToEachValue2 = _interopRequireDefault(_appendImportantToEachValue);
var _cssRuleSetToString = __webpack_require__(9);
var _cssRuleSetToString2 = _interopRequireDefault(_cssRuleSetToString);
var _getState = __webpack_require__(13);
var _getState2 = _interopRequireDefault(_getState);
var _getStateKey = __webpack_require__(22);
var _getStateKey2 = _interopRequireDefault(_getStateKey);
var _hash = __webpack_require__(23);
var _hash2 = _interopRequireDefault(_hash);
var _mergeStyles = __webpack_require__(65);
var _plugins = __webpack_require__(14);
var _plugins2 = _interopRequireDefault(_plugins);
var _exenv = __webpack_require__(30);
var _exenv2 = _interopRequireDefault(_exenv);
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var DEFAULT_CONFIG = {
plugins: [_plugins2.default.mergeStyleArray, _plugins2.default.checkProps, _plugins2.default.resolveMediaQueries, _plugins2.default.resolveInteractionStyles, _plugins2.default.keyframes, _plugins2.default.visited, _plugins2.default.removeNestedStyles, _plugins2.default.prefix, _plugins2.default.checkProps]
};
// Gross
var globalState = {};
// Declare early for recursive helpers.
var resolveStyles = null;
var _shouldResolveStyles = function _shouldResolveStyles(component) {
return component.type && !component.type._isRadiumEnhanced;
};
var _resolveChildren = function _resolveChildren(_ref) {
var children = _ref.children,
component = _ref.component,
config = _ref.config,
existingKeyMap = _ref.existingKeyMap;
if (!children) {
return children;
}
var childrenType = typeof children === 'undefined' ? 'undefined' : _typeof(children);
if (childrenType === 'string' || childrenType === 'number') {
// Don't do anything with a single primitive child
return children;
}
if (childrenType === 'function') {
// Wrap the function, resolving styles on the result
return function () {
var result = children.apply(this, arguments);
if (_react2.default.isValidElement(result)) {
return resolveStyles(component, result, config, existingKeyMap, true);
}
return result;
};
}
if (_react2.default.Children.count(children) === 1 && children.type) {
// If a React Element is an only child, don't wrap it in an array for
// React.Children.map() for React.Children.only() compatibility.
var onlyChild = _react2.default.Children.only(children);
return resolveStyles(component, onlyChild, config, existingKeyMap, true);
}
return _react2.default.Children.map(children, function (child) {
if (_react2.default.isValidElement(child)) {
return resolveStyles(component, child, config, existingKeyMap, true);
}
return child;
});
};
// Recurse over props, just like children
var _resolveProps = function _resolveProps(_ref2) {
var component = _ref2.component,
config = _ref2.config,
existingKeyMap = _ref2.existingKeyMap,
props = _ref2.props;
var newProps = props;
Object.keys(props).forEach(function (prop) {
// We already recurse over children above
if (prop === 'children') {
return;
}
var propValue = props[prop];
if (_react2.default.isValidElement(propValue)) {
newProps = _extends({}, newProps);
newProps[prop] = resolveStyles(component, propValue, config, existingKeyMap, true);
}
});
return newProps;
};
var _buildGetKey = function _buildGetKey(_ref3) {
var componentName = _ref3.componentName,
existingKeyMap = _ref3.existingKeyMap,
renderedElement = _ref3.renderedElement;
// We need a unique key to correlate state changes due to user interaction
// with the rendered element, so we know to apply the proper interactive
// styles.
var originalKey = typeof renderedElement.ref === 'string' ? renderedElement.ref : renderedElement.key;
var key = (0, _getStateKey2.default)(originalKey);
var alreadyGotKey = false;
var getKey = function getKey() {
if (alreadyGotKey) {
return key;
}
alreadyGotKey = true;
if (existingKeyMap[key]) {
var elementName = void 0;
if (typeof renderedElement.type === 'string') {
elementName = renderedElement.type;
} else if (renderedElement.type.constructor) {
elementName = renderedElement.type.constructor.displayName || renderedElement.type.constructor.name;
}
throw new Error('Radium requires each element with interactive styles to have a unique ' + 'key, set using either the ref or key prop. ' + (originalKey ? 'Key "' + originalKey + '" is a duplicate.' : 'Multiple elements have no key specified.') + ' ' + 'Component: "' + componentName + '". ' + (elementName ? 'Element: "' + elementName + '".' : ''));
}
existingKeyMap[key] = true;
return key;
};
return getKey;
};
var _setStyleState = function _setStyleState(component, key, stateKey, value) {
if (!component._radiumIsMounted) {
return;
}
var existing = component._lastRadiumState || component.state && component.state._radiumStyleState || {};
var state = { _radiumStyleState: _extends({}, existing) };
state._radiumStyleState[key] = _extends({}, state._radiumStyleState[key]);
state._radiumStyleState[key][stateKey] = value;
component._lastRadiumState = state._radiumStyleState;
component.setState(state);
};
var _runPlugins = function _runPlugins(_ref4) {
var component = _ref4.component,
config = _ref4.config,
existingKeyMap = _ref4.existingKeyMap,
props = _ref4.props,
renderedElement = _ref4.renderedElement;
// Don't run plugins if renderedElement is not a simple ReactDOMElement or has
// no style.
if (!_react2.default.isValidElement(renderedElement) || typeof renderedElement.type !== 'string' || !props.style) {
return props;
}
var newProps = props;
var plugins = config.plugins || DEFAULT_CONFIG.plugins;
var componentName = component.constructor.displayName || component.constructor.name;
var getKey = _buildGetKey({
renderedElement: renderedElement,
existingKeyMap: existingKeyMap,
componentName: componentName
});
var getComponentField = function getComponentField(key) {
return component[key];
};
var getGlobalState = function getGlobalState(key) {
return globalState[key];
};
var componentGetState = function componentGetState(stateKey, elementKey) {
return (0, _getState2.default)(component.state, elementKey || getKey(), stateKey);
};
var setState = function setState(stateKey, value, elementKey) {
return _setStyleState(component, elementKey || getKey(), stateKey, value);
};
var addCSS = function addCSS(css) {
var styleKeeper = component._radiumStyleKeeper || component.context._radiumStyleKeeper;
if (!styleKeeper) {
if (__isTestModeEnabled) {
return {
remove: function remove() {}
};
}
throw new Error('To use plugins requiring `addCSS` (e.g. keyframes, media queries), ' + 'please wrap your application in the StyleRoot component. Component ' + 'name: `' + componentName + '`.');
}
return styleKeeper.addCSS(css);
};
var newStyle = props.style;
plugins.forEach(function (plugin) {
var result = plugin({
ExecutionEnvironment: _exenv2.default,
addCSS: addCSS,
appendImportantToEachValue: _appendImportantToEachValue2.default,
componentName: componentName,
config: config,
cssRuleSetToString: _cssRuleSetToString2.default,
getComponentField: getComponentField,
getGlobalState: getGlobalState,
getState: componentGetState,
hash: _hash2.default,
mergeStyles: _mergeStyles.mergeStyles,
props: newProps,
setState: setState,
isNestedStyle: _mergeStyles.isNestedStyle,
style: newStyle
}) || {};
newStyle = result.style || newStyle;
newProps = result.props && Object.keys(result.props).length ? _extends({}, newProps, result.props) : newProps;
var newComponentFields = result.componentFields || {};
Object.keys(newComponentFields).forEach(function (fieldName) {
component[fieldName] = newComponentFields[fieldName];
});
var newGlobalState = result.globalState || {};
Object.keys(newGlobalState).forEach(function (key) {
globalState[key] = newGlobalState[key];
});
});
if (newStyle !== props.style) {
newProps = _extends({}, newProps, { style: newStyle });
}
return newProps;
};
// Wrapper around React.cloneElement. To avoid processing the same element
// twice, whenever we clone an element add a special prop to make sure we don't
// process this element again.
var _cloneElement = function _cloneElement(renderedElement, newProps, newChildren) {
// Only add flag if this is a normal DOM element
if (typeof renderedElement.type === 'string') {
newProps = _extends({}, newProps, { 'data-radium': true });
}
return _react2.default.cloneElement(renderedElement, newProps, newChildren);
};
//
// The nucleus of Radium. resolveStyles is called on the rendered elements
// before they are returned in render. It iterates over the elements and
// children, rewriting props to add event handlers required to capture user
// interactions (e.g. mouse over). It also replaces the style prop because it
// adds in the various interaction styles (e.g. :hover).
//
resolveStyles = function resolveStyles(component, // ReactComponent, flow+eslint complaining
renderedElement) {
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_CONFIG;
var existingKeyMap = arguments[3];
var shouldCheckBeforeResolve = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
// ReactElement
existingKeyMap = existingKeyMap || {};
if (!renderedElement ||
// Bail if we've already processed this element. This ensures that only the
// owner of an element processes that element, since the owner's render
// function will be called first (which will always be the case, since you
// can't know what else to render until you render the parent component).
renderedElement.props && renderedElement.props['data-radium'] ||
// Bail if this element is a radium enhanced element, because if it is,
// then it will take care of resolving its own styles.
shouldCheckBeforeResolve && !_shouldResolveStyles(renderedElement)) {
return renderedElement;
}
var newChildren = _resolveChildren({
children: renderedElement.props.children,
component: component,
config: config,
existingKeyMap: existingKeyMap
});
var newProps = _resolveProps({
component: component,
config: config,
existingKeyMap: existingKeyMap,
props: renderedElement.props
});
newProps = _runPlugins({
component: component,
config: config,
existingKeyMap: existingKeyMap,
props: newProps,
renderedElement: renderedElement
});
// If nothing changed, don't bother cloning the element. Might be a bit
// wasteful, as we add the sentinal to stop double-processing when we clone.
// Assume benign double-processing is better than unneeded cloning.
if (newChildren === renderedElement.props.children && newProps === renderedElement.props) {
return renderedElement;
}
return _cloneElement(renderedElement, newProps !== renderedElement.props ? newProps : {}, newChildren);
};
// Only for use by tests
var __isTestModeEnabled = false;
if (process.env.NODE_ENV !== 'production') {
resolveStyles.__clearStateForTests = function () {
globalState = {};
};
resolveStyles.__setTestMode = function (isEnabled) {
__isTestModeEnabled = isEnabled;
};
}
exports.default = resolveStyles;
module.exports = exports['default'];
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var uppercasePattern = /[A-Z]/g;
var msPattern = /^ms-/;
var cache = {};
function hyphenateStyleName(string) {
return string in cache ? cache[string] : cache[string] = string.replace(uppercasePattern, '-$&').toLowerCase().replace(msPattern, '-ms-');
}
module.exports = hyphenateStyleName;
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = { "Webkit": { "transform": true, "transformOrigin": true, "transformOriginX": true, "transformOriginY": true, "backfaceVisibility": true, "perspective": true, "perspectiveOrigin": true, "transformStyle": true, "transformOriginZ": true, "animation": true, "animationDelay": true, "animationDirection": true, "animationFillMode": true, "animationDuration": true, "animationIterationCount": true, "animationName": true, "animationPlayState": true, "animationTimingFunction": true, "appearance": true, "userSelect": true, "fontKerning": true, "textEmphasisPosition": true, "textEmphasis": true, "textEmphasisStyle": true, "textEmphasisColor": true, "boxDecorationBreak": true, "clipPath": true, "maskImage": true, "maskMode": true, "maskRepeat": true, "maskPosition": true, "maskClip": true, "maskOrigin": true, "maskSize": true, "maskComposite": true, "mask": true, "maskBorderSource": true, "maskBorderMode": true, "maskBorderSlice": true, "maskBorderWidth": true, "maskBorderOutset": true, "maskBorderRepeat": true, "maskBorder": true, "maskType": true, "textDecorationStyle": true, "textDecorationSkip": true, "textDecorationLine": true, "textDecorationColor": true, "filter": true, "fontFeatureSettings": true, "breakAfter": true, "breakBefore": true, "breakInside": true, "columnCount": true, "columnFill": true, "columnGap": true, "columnRule": true, "columnRuleColor": true, "columnRuleStyle": true, "columnRuleWidth": true, "columns": true, "columnSpan": true, "columnWidth": true, "flex": true, "flexBasis": true, "flexDirection": true, "flexGrow": true, "flexFlow": true, "flexShrink": true, "flexWrap": true, "alignContent": true, "alignItems": true, "alignSelf": true, "justifyContent": true, "order": true, "transition": true, "transitionDelay": true, "transitionDuration": true, "transitionProperty": true, "transitionTimingFunction": true, "backdropFilter": true, "scrollSnapType": true, "scrollSnapPointsX": true, "scrollSnapPointsY": true, "scrollSnapDestination": true, "scrollSnapCoordinate": true, "shapeImageThreshold": true, "shapeImageMargin": true, "shapeImageOutside": true, "hyphens": true, "flowInto": true, "flowFrom": true, "regionFragment": true, "textSizeAdjust": true }, "Moz": { "appearance": true, "userSelect": true, "boxSizing": true, "textAlignLast": true, "textDecorationStyle": true, "textDecorationSkip": true, "textDecorationLine": true, "textDecorationColor": true, "tabSize": true, "hyphens": true, "fontFeatureSettings": true, "breakAfter": true, "breakBefore": true, "breakInside": true, "columnCount": true, "columnFill": true, "columnGap": true, "columnRule": true, "columnRuleColor": true, "columnRuleStyle": true, "columnRuleWidth": true, "columns": true, "columnSpan": true, "columnWidth": t