glamor
Version:
inline css for component systems
1,326 lines (1,138 loc) • 91.6 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Glamor"] = factory();
else
root["Glamor"] = factory();
})(this, function() {
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;
/******/
/******/ // 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 = 4);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isPrefixedValue;
var regex = /-webkit-|-moz-|-ms-/;
function isPrefixedValue(value) {
return typeof value === 'string' && regex.test(value);
}
module.exports = exports['default'];
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function toObject(val) {
if (val === null || val === undefined) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function shouldUseNative() {
try {
if (!Object.assign) {
return false;
}
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test2 = {};
for (var i = 0; i < 10; i++) {
test2['_' + String.fromCharCode(i)] = i;
}
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
return test2[n];
});
if (order2.join('') !== '0123456789') {
return false;
}
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
test3[letter] = letter;
});
if (Object.keys(Object.assign({}, test3)).join('') !==
'abcdefghijklmnopqrst') {
return false;
}
return true;
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
}
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
var from;
var to = toObject(target);
var symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(from, symbols[i])) {
to[symbols[i]] = from[symbols[i]];
}
}
}
}
return to;
};
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2014-2015, 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.
*
*/
var emptyFunction = __webpack_require__(7);
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var warning = emptyFunction;
if (true) {
(function () {
var printWarning = function printWarning(format) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
if (typeof console !== 'undefined') {
console.error(message);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
};
warning = function warning(condition, format) {
if (format === undefined) {
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
}
if (format.indexOf('Failed Composite propType: ') === 0) {
return; // Ignore CompositeComponent proptype check.
}
if (!condition) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}
printWarning.apply(undefined, [format].concat(args));
}
};
})();
}
module.exports = warning;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = capitalizeString;
function capitalizeString(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
module.exports = exports["default"];
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
// CONCATENATED MODULE: ./src/sheet.js
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_object_assign__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_object_assign___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_object_assign__);
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
/*
high performance StyleSheet for css-in-js systems
- uses multiple style tags behind the scenes for millions of rules
- uses `insertRule` for appending in production for *much* faster performance
- 'polyfills' on server side
// usage
import StyleSheet from 'glamor/lib/sheet'
let styleSheet = new StyleSheet()
styleSheet.inject()
- 'injects' the stylesheet into the page (or into memory if on server)
styleSheet.insert('#box { border: 1px solid red; }')
- appends a css rule into the stylesheet
styleSheet.flush()
- empties the stylesheet of all its contents
*/
function last(arr) {
return arr[arr.length - 1];
}
function sheetForTag(tag) {
if (tag.sheet) {
return tag.sheet;
}
// this weirdness brought to you by firefox
for (var i = 0; i < document.styleSheets.length; i++) {
if (document.styleSheets[i].ownerNode === tag) {
return document.styleSheets[i];
}
}
}
var isBrowser = typeof window !== 'undefined';
var isDev = "development" === 'development' || !"development"; //(x => (x === 'development') || !x)(process.env.NODE_ENV)
var isTest = "development" === 'test';
var oldIE = function () {
if (isBrowser) {
var div = document.createElement('div');
div.innerHTML = '<!--[if lt IE 10]><i></i><![endif]-->';
return div.getElementsByTagName('i').length === 1;
}
}();
function makeStyleTag() {
var tag = document.createElement('style');
tag.type = 'text/css';
tag.setAttribute('data-glamor', '');
tag.appendChild(document.createTextNode(''));
(document.head || document.getElementsByTagName('head')[0]).appendChild(tag);
return tag;
}
function StyleSheet() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$speedy = _ref.speedy,
speedy = _ref$speedy === undefined ? !isDev && !isTest : _ref$speedy,
_ref$maxLength = _ref.maxLength,
maxLength = _ref$maxLength === undefined ? isBrowser && oldIE ? 4000 : 65000 : _ref$maxLength;
this.isSpeedy = speedy; // the big drawback here is that the css won't be editable in devtools
this.sheet = undefined;
this.tags = [];
this.maxLength = maxLength;
this.ctr = 0;
}
__WEBPACK_IMPORTED_MODULE_0_object_assign___default()(StyleSheet.prototype, {
getSheet: function getSheet() {
return sheetForTag(last(this.tags));
},
inject: function inject() {
var _this = this;
if (this.injected) {
throw new Error('already injected stylesheet!');
}
if (isBrowser) {
this.tags[0] = makeStyleTag();
} else {
// server side 'polyfill'. just enough behavior to be useful.
this.sheet = {
cssRules: [],
insertRule: function insertRule(rule) {
// enough 'spec compliance' to be able to extract the rules later
// in other words, just the cssText field
_this.sheet.cssRules.push({ cssText: rule });
}
};
}
this.injected = true;
},
speedy: function speedy(bool) {
if (this.ctr !== 0) {
throw new Error('cannot change speedy mode after inserting any rule to sheet. Either call speedy(' + bool + ') earlier in your app, or call flush() before speedy(' + bool + ')');
}
this.isSpeedy = !!bool;
},
_insert: function _insert(rule) {
// this weirdness for perf, and chrome's weird bug
// https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
try {
var sheet = this.getSheet();
sheet.insertRule(rule, rule.indexOf('@import') !== -1 ? 0 : sheet.cssRules.length);
} catch (e) {
if (isDev) {
// might need beter dx for this
console.warn('whoops, illegal rule inserted', rule); //eslint-disable-line no-console
}
}
},
insert: function insert(rule) {
if (isBrowser) {
// this is the ultrafast version, works across browsers
if (this.isSpeedy && this.getSheet().insertRule) {
this._insert(rule);
}
// more browser weirdness. I don't even know
// else if(this.tags.length > 0 && this.tags::last().styleSheet) {
// this.tags::last().styleSheet.cssText+= rule
// }
else {
if (rule.indexOf('@import') !== -1) {
var tag = last(this.tags);
tag.insertBefore(document.createTextNode(rule), tag.firstChild);
} else {
last(this.tags).appendChild(document.createTextNode(rule));
}
}
} else {
// server side is pretty simple
this.sheet.insertRule(rule, rule.indexOf('@import') !== -1 ? 0 : this.sheet.cssRules.length);
}
this.ctr++;
if (isBrowser && this.ctr % this.maxLength === 0) {
this.tags.push(makeStyleTag());
}
return this.ctr - 1;
},
// commenting this out till we decide on v3's decision
// _replace(index, rule) {
// // this weirdness for perf, and chrome's weird bug
// // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
// try {
// let sheet = this.getSheet()
// sheet.deleteRule(index) // todo - correct index here
// sheet.insertRule(rule, index)
// }
// catch(e) {
// if(isDev) {
// // might need beter dx for this
// console.warn('whoops, problem replacing rule', rule) //eslint-disable-line no-console
// }
// }
// }
// replace(index, rule) {
// if(isBrowser) {
// if(this.isSpeedy && this.getSheet().insertRule) {
// this._replace(index, rule)
// }
// else {
// let _slot = Math.floor((index + this.maxLength) / this.maxLength) - 1
// let _index = (index % this.maxLength) + 1
// let tag = this.tags[_slot]
// tag.replaceChild(document.createTextNode(rule), tag.childNodes[_index])
// }
// }
// else {
// let rules = this.sheet.cssRules
// this.sheet.cssRules = [ ...rules.slice(0, index), { cssText: rule }, ...rules.slice(index + 1) ]
// }
// }
delete: function _delete(index) {
// we insert a blank rule when 'deleting' so previously returned indexes remain stable
return this.replace(index, '');
},
flush: function flush() {
if (isBrowser) {
this.tags.forEach(function (tag) {
return tag.parentNode.removeChild(tag);
});
this.tags = [];
this.sheet = null;
this.ctr = 0;
// todo - look for remnants in document.styleSheets
} else {
// simpler on server
this.sheet.cssRules = [];
}
this.injected = false;
},
rules: function rules() {
if (!isBrowser) {
return this.sheet.cssRules;
}
var arr = [];
this.tags.forEach(function (tag) {
return arr.splice.apply(arr, [arr.length, 0].concat(_toConsumableArray(Array.from(sheetForTag(tag).cssRules))));
});
return arr;
}
});
// CONCATENATED MODULE: ./src/CSSPropertyOperations/CSSProperty.js
/**
* 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.
*
* @providesModule CSSProperty
*/
/**
* CSS properties which accept numbers but are not in units of "px".
*/
var isUnitlessNumber = {
animationIterationCount: true,
borderImageOutset: true,
borderImageSlice: true,
borderImageWidth: true,
boxFlex: true,
boxFlexGroup: true,
boxOrdinalGroup: true,
columnCount: true,
flex: true,
flexGrow: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
flexOrder: true,
gridRow: true,
gridRowStart: true,
gridRowEnd: true,
gridColumn: true,
gridColumnStart: true,
gridColumnEnd: true,
fontWeight: true,
lineClamp: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
tabSize: true,
widows: true,
zIndex: true,
zoom: true,
// SVG-related properties
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeDasharray: true,
strokeDashoffset: true,
strokeMiterlimit: true,
strokeOpacity: true,
strokeWidth: true
/**
* @param {string} prefix vendor-specific prefix, eg: Webkit
* @param {string} key style name, eg: transitionDuration
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
* WebkitTransitionDuration
*/
};function prefixKey(prefix, key) {
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
}
/**
* Support style names that may come passed in prefixed by adding permutations
* of vendor prefixes.
*/
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
// infinite loop, because it iterates over the newly added props too.
Object.keys(isUnitlessNumber).forEach(function (prop) {
prefixes.forEach(function (prefix) {
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
});
});
/**
* Most style properties can be unset by doing .style[prop] = '' but IE8
* doesn't like doing that with shorthand properties so for the properties that
* IE8 breaks on, which are listed here, we instead unset each of the
* individual properties. See http://bugs.jquery.com/ticket/12385.
* The 4-value 'clock' properties like margin, padding, border-width seem to
* behave without any problems. Curiously, list-style works too without any
* special prodding.
*/
var shorthandPropertyExpansions = {
background: {
backgroundAttachment: true,
backgroundColor: true,
backgroundImage: true,
backgroundPositionX: true,
backgroundPositionY: true,
backgroundRepeat: true
},
backgroundPosition: {
backgroundPositionX: true,
backgroundPositionY: true
},
border: {
borderWidth: true,
borderStyle: true,
borderColor: true
},
borderBottom: {
borderBottomWidth: true,
borderBottomStyle: true,
borderBottomColor: true
},
borderLeft: {
borderLeftWidth: true,
borderLeftStyle: true,
borderLeftColor: true
},
borderRight: {
borderRightWidth: true,
borderRightStyle: true,
borderRightColor: true
},
borderTop: {
borderTopWidth: true,
borderTopStyle: true,
borderTopColor: true
},
font: {
fontStyle: true,
fontVariant: true,
fontWeight: true,
fontSize: true,
lineHeight: true,
fontFamily: true
},
outline: {
outlineWidth: true,
outlineStyle: true,
outlineColor: true
}
};
var CSSProperty = {
isUnitlessNumber: isUnitlessNumber,
shorthandPropertyExpansions: shorthandPropertyExpansions
};
/* harmony default export */ var CSSProperty_defaultExport = (CSSProperty);
// CONCATENATED MODULE: ./src/CSSPropertyOperations/dangerousStyleValue.js
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fbjs_lib_warning__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_fbjs_lib_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_fbjs_lib_warning__);
/**
* 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.
*
* @providesModule dangerousStyleValue
*/
var dangerousStyleValue_isUnitlessNumber = CSSProperty_defaultExport.isUnitlessNumber;
var styleWarnings = {};
/**
* Convert a value into the proper css writable value. The style name `name`
* should be logical (no hyphens), as specified
* in `CSSProperty.isUnitlessNumber`.
*
* @param {string} name CSS property name such as `topMargin`.
* @param {*} value CSS property value such as `10px`.
* @param {ReactDOMComponent} component
* @return {string} Normalized style value with dimensions applied.
*/
function dangerousStyleValue(name, value, component) {
// Note that we've removed escapeTextForBrowser() calls here since the
// whole string will be escaped when the attribute is injected into
// the markup. If you provide unsafe user data here they can inject
// arbitrary CSS which may be problematic (I couldn't repro this):
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
// http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
// This is not an XSS hole but instead a potential CSS injection issue
// which has lead to a greater discussion about how we're going to
// trust URLs moving forward. See #2115901
var isEmpty = value == null || typeof value === 'boolean' || value === '';
if (isEmpty) {
return '';
}
var isNonNumeric = isNaN(value);
if (isNonNumeric || value === 0 || dangerousStyleValue_isUnitlessNumber.hasOwnProperty(name) && dangerousStyleValue_isUnitlessNumber[name]) {
return '' + value; // cast to string
}
if (typeof value === 'string') {
if (true) {
// Allow '0' to pass through without warning. 0 is already special and
// doesn't require units, so we don't need to warn about it.
if (component && value !== '0') {
var owner = component._currentElement._owner;
var ownerName = owner ? owner.getName() : null;
if (ownerName && !styleWarnings[ownerName]) {
styleWarnings[ownerName] = {};
}
var warned = false;
if (ownerName) {
var warnings = styleWarnings[ownerName];
warned = warnings[name];
if (!warned) {
warnings[name] = true;
}
}
if (!warned) {
true ? __WEBPACK_IMPORTED_MODULE_1_fbjs_lib_warning___default()(false, 'a `%s` tag (owner: `%s`) was passed a numeric string value ' + 'for CSS property `%s` (value: `%s`) which will be treated ' + 'as a unitless number in a future version of React.', component._currentElement.type, ownerName || 'unknown', name, value) : void 0;
}
}
}
value = value.trim();
}
return value + 'px';
}
/* harmony default export */ var dangerousStyleValue_defaultExport = (dangerousStyleValue);
// CONCATENATED MODULE: ./src/CSSPropertyOperations/index.js
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fbjs_lib_camelizeStyleName__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fbjs_lib_camelizeStyleName___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_fbjs_lib_camelizeStyleName__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_fbjs_lib_hyphenateStyleName__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_fbjs_lib_hyphenateStyleName___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_fbjs_lib_hyphenateStyleName__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_fbjs_lib_memoizeStringOnly__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_fbjs_lib_memoizeStringOnly___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_fbjs_lib_memoizeStringOnly__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_fbjs_lib_warning__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_fbjs_lib_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_fbjs_lib_warning__);
/**
* 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.
*
* @providesModule CSSPropertyOperations
*/
var processStyleName = __WEBPACK_IMPORTED_MODULE_3_fbjs_lib_memoizeStringOnly___default()(__WEBPACK_IMPORTED_MODULE_2_fbjs_lib_hyphenateStyleName___default.a);
if (true) {
// 'msTransform' is correct, but the other prefixes should be capitalized
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
// style values shouldn't contain a semicolon
var badStyleValueWithSemicolonPattern = /;\s*$/;
var warnedStyleNames = {};
var warnedStyleValues = {};
var warnedForNaNValue = false;
var warnHyphenatedStyleName = function warnHyphenatedStyleName(name, owner) {
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
return;
}
warnedStyleNames[name] = true;
true ? __WEBPACK_IMPORTED_MODULE_4_fbjs_lib_warning___default()(false, 'Unsupported style property %s. Did you mean %s?%s', name, __WEBPACK_IMPORTED_MODULE_0_fbjs_lib_camelizeStyleName___default()(name), checkRenderMessage(owner)) : void 0;
};
var warnBadVendoredStyleName = function warnBadVendoredStyleName(name, owner) {
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
return;
}
warnedStyleNames[name] = true;
true ? __WEBPACK_IMPORTED_MODULE_4_fbjs_lib_warning___default()(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?%s', name, name.charAt(0).toUpperCase() + name.slice(1), checkRenderMessage(owner)) : void 0;
};
var warnStyleValueWithSemicolon = function warnStyleValueWithSemicolon(name, value, owner) {
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
return;
}
warnedStyleValues[value] = true;
true ? __WEBPACK_IMPORTED_MODULE_4_fbjs_lib_warning___default()(false, 'Style property values shouldn\'t contain a semicolon.%s ' + 'Try "%s: %s" instead.', checkRenderMessage(owner), name, value.replace(badStyleValueWithSemicolonPattern, '')) : void 0;
};
var warnStyleValueIsNaN = function warnStyleValueIsNaN(name, value, owner) {
if (warnedForNaNValue) {
return;
}
warnedForNaNValue = true;
true ? __WEBPACK_IMPORTED_MODULE_4_fbjs_lib_warning___default()(false, '`NaN` is an invalid value for the `%s` css style property.%s', name, checkRenderMessage(owner)) : void 0;
};
var checkRenderMessage = function checkRenderMessage(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
};
/**
* @param {string} name
* @param {*} value
* @param {ReactDOMComponent} component
*/
var warnValidStyle = function warnValidStyle(name, value, component) {
//eslint-disable-line no-var
var owner = void 0;
if (component) {
owner = component._currentElement._owner;
}
if (name.indexOf('-') > -1) {
warnHyphenatedStyleName(name, owner);
} else if (badVendoredStyleNamePattern.test(name)) {
warnBadVendoredStyleName(name, owner);
} else if (badStyleValueWithSemicolonPattern.test(value)) {
warnStyleValueWithSemicolon(name, value, owner);
}
if (typeof value === 'number' && isNaN(value)) {
warnStyleValueIsNaN(name, value, owner);
}
};
}
/**
* Serializes a mapping of style properties for use as inline styles:
*
* > createMarkupForStyles({width: '200px', height: 0})
* "width:200px;height:0;"
*
* Undefined values are ignored so that declarative programming is easier.
* The result should be HTML-escaped before insertion into the DOM.
*
* @param {object} styles
* @param {ReactDOMComponent} component
* @return {?string}
*/
function createMarkupForStyles(styles, component) {
var serialized = '';
for (var styleName in styles) {
var isCustomProp = styleName.indexOf('--') === 0;
if (!styles.hasOwnProperty(styleName)) {
continue;
}
if (styleName === 'label') {
continue;
}
var styleValue = styles[styleName];
if ("development" !== 'production' && !isCustomProp) {
warnValidStyle(styleName, styleValue, component);
}
if (styleValue != null) {
if (isCustomProp) {
serialized += styleName + ':' + styleValue + ';';
} else {
serialized += processStyleName(styleName) + ':';
serialized += dangerousStyleValue_defaultExport(styleName, styleValue, component) + ';';
}
}
}
return serialized || null;
}
// CONCATENATED MODULE: ./src/clean.js
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; };
// Returns true for null, false, undefined and {}
function isFalsy(value) {
return value === null || value === undefined || value === false || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && Object.keys(value).length === 0;
}
function cleanObject(object) {
if (isFalsy(object)) return null;
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') return object;
var acc = {},
keys = Object.keys(object),
hasFalsy = false;
for (var i = 0; i < keys.length; i++) {
var value = object[keys[i]];
var filteredValue = clean(value);
if (filteredValue === null || filteredValue !== value) {
hasFalsy = true;
}
if (filteredValue !== null) {
acc[keys[i]] = filteredValue;
}
}
return Object.keys(acc).length === 0 ? null : hasFalsy ? acc : object;
}
function cleanArray(rules) {
var hasFalsy = false;
var filtered = [];
rules.forEach(function (rule) {
var filteredRule = clean(rule);
if (filteredRule === null || filteredRule !== rule) {
hasFalsy = true;
}
if (filteredRule !== null) {
filtered.push(filteredRule);
}
});
return filtered.length == 0 ? null : hasFalsy ? filtered : rules;
}
// Takes style array or object provided by user and clears all the falsy data
// If there is no styles left after filtration returns null
function clean(input) {
return Array.isArray(input) ? cleanArray(input) : cleanObject(input);
}
// CONCATENATED MODULE: ./src/prefixer.js
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_inline_style_prefixer_static_staticData__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_inline_style_prefixer_static_staticData___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_inline_style_prefixer_static_staticData__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_inline_style_prefixer_utils_prefixProperty__ = __webpack_require__(12);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_inline_style_prefixer_utils_prefixProperty___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_inline_style_prefixer_utils_prefixProperty__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_inline_style_prefixer_utils_prefixValue__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_inline_style_prefixer_utils_prefixValue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_inline_style_prefixer_utils_prefixValue__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_inline_style_prefixer_static_plugins_cursor__ = __webpack_require__(14);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_inline_style_prefixer_static_plugins_cursor___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_inline_style_prefixer_static_plugins_cursor__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_inline_style_prefixer_static_plugins_crossFade__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_inline_style_prefixer_static_plugins_crossFade___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_inline_style_prefixer_static_plugins_crossFade__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_inline_style_prefixer_static_plugins_filter__ = __webpack_require__(16);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_inline_style_prefixer_static_plugins_filter___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_inline_style_prefixer_static_plugins_filter__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_inline_style_prefixer_static_plugins_flex__ = __webpack_require__(17);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_inline_style_prefixer_static_plugins_flex___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_inline_style_prefixer_static_plugins_flex__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_inline_style_prefixer_static_plugins_flexboxOld__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_inline_style_prefixer_static_plugins_flexboxOld___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_inline_style_prefixer_static_plugins_flexboxOld__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_inline_style_prefixer_static_plugins_gradient__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_inline_style_prefixer_static_plugins_gradient___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_inline_style_prefixer_static_plugins_gradient__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_inline_style_prefixer_static_plugins_imageSet__ = __webpack_require__(20);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_inline_style_prefixer_static_plugins_imageSet___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9_inline_style_prefixer_static_plugins_imageSet__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_inline_style_prefixer_static_plugins_position__ = __webpack_require__(21);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_inline_style_prefixer_static_plugins_position___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10_inline_style_prefixer_static_plugins_position__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_inline_style_prefixer_static_plugins_sizing__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_inline_style_prefixer_static_plugins_sizing___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_11_inline_style_prefixer_static_plugins_sizing__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12_inline_style_prefixer_static_plugins_transition__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12_inline_style_prefixer_static_plugins_transition___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_12_inline_style_prefixer_static_plugins_transition__);
// custom facade for inline-style-prefixer
var plugins = [__WEBPACK_IMPORTED_MODULE_4_inline_style_prefixer_static_plugins_crossFade___default.a, __WEBPACK_IMPORTED_MODULE_3_inline_style_prefixer_static_plugins_cursor___default.a, __WEBPACK_IMPORTED_MODULE_5_inline_style_prefixer_static_plugins_filter___default.a, __WEBPACK_IMPORTED_MODULE_7_inline_style_prefixer_static_plugins_flexboxOld___default.a, __WEBPACK_IMPORTED_MODULE_8_inline_style_prefixer_static_plugins_gradient___default.a, __WEBPACK_IMPORTED_MODULE_9_inline_style_prefixer_static_plugins_imageSet___default.a, __WEBPACK_IMPORTED_MODULE_10_inline_style_prefixer_static_plugins_position___default.a, __WEBPACK_IMPORTED_MODULE_11_inline_style_prefixer_static_plugins_sizing___default.a, __WEBPACK_IMPORTED_MODULE_12_inline_style_prefixer_static_plugins_transition___default.a, __WEBPACK_IMPORTED_MODULE_6_inline_style_prefixer_static_plugins_flex___default.a];
var prefixMap = __WEBPACK_IMPORTED_MODULE_0_inline_style_prefixer_static_staticData___default.a.prefixMap;
function prefixer(style) {
for (var property in style) {
var value = style[property];
var processedValue = __WEBPACK_IMPORTED_MODULE_2_inline_style_prefixer_utils_prefixValue___default()(plugins, property, value, style, prefixMap);
// only modify the value if it was touched
// by any plugin to prevent unnecessary mutations
if (processedValue) {
style[property] = processedValue;
}
__WEBPACK_IMPORTED_MODULE_1_inline_style_prefixer_utils_prefixProperty___default()(prefixMap, property, style);
}
return style;
}
// CONCATENATED MODULE: ./src/plugins.js
/* harmony import */ var plugins___WEBPACK_IMPORTED_MODULE_0_object_assign__ = __webpack_require__(1);
/* harmony import */ var plugins___WEBPACK_IMPORTED_MODULE_0_object_assign___default = __webpack_require__.n(plugins___WEBPACK_IMPORTED_MODULE_0_object_assign__);
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 plugins_isDev = function (x) {
return x === 'development' || !x;
}("development");
function PluginSet(initial) {
this.fns = initial || [];
}
plugins___WEBPACK_IMPORTED_MODULE_0_object_assign___default()(PluginSet.prototype, {
add: function add() {
var _this = this;
for (var _len = arguments.length, fns = Array(_len), _key = 0; _key < _len; _key++) {
fns[_key] = arguments[_key];
}
fns.forEach(function (fn) {
if (_this.fns.indexOf(fn) >= 0) {
if (plugins_isDev) {
console.warn('adding the same plugin again, ignoring'); //eslint-disable-line no-console
}
} else {
_this.fns = [fn].concat(_this.fns);
}
});
},
remove: function remove(fn) {
this.fns = this.fns.filter(function (x) {
return x !== fn;
});
},
clear: function clear() {
this.fns = [];
},
transform: function transform(o) {
return this.fns.reduce(function (o, fn) {
return fn(o);
}, o);
}
});
function fallbacks(node) {
var hasArray = Object.keys(node.style).map(function (x) {
return Array.isArray(node.style[x]);
}).indexOf(true) >= 0;
if (hasArray) {
var style = node.style;
var flattened = Object.keys(style).reduce(function (o, key) {
o[key] = Array.isArray(style[key]) ? style[key].join('; ' + processStyleName(key) + ': ') : style[key];
return o;
}, {});
// todo -
// flatten arrays which haven't been flattened yet
return plugins___WEBPACK_IMPORTED_MODULE_0_object_assign___default()({}, node, { style: flattened });
}
return node;
}
var contentValues = ['normal', 'none', 'counter', 'open-quote', 'close-quote', 'no-open-quote', 'no-close-quote', 'initial', 'inherit'];
function contentWrap(node) {
if (node.style.content) {
var cont = node.style.content;
if (contentValues.indexOf(cont) >= 0) {
return node;
}
if (/^(attr|calc|counters?|url)\(/.test(cont)) {
return node;
}
if (cont.charAt(0) === cont.charAt(cont.length - 1) && (cont.charAt(0) === '"' || cont.charAt(0) === "'")) {
return node;
}
return _extends({}, node, { style: _extends({}, node.style, { content: '"' + cont + '"' }) });
}
return node;
}
function plugins_prefixes(node) {
return plugins___WEBPACK_IMPORTED_MODULE_0_object_assign___default()({}, node, { style: prefixer(_extends({}, node.style)) });
}
// CONCATENATED MODULE: ./src/hash.js
// murmurhash2 via https://gist.github.com/raycmorgan/588423
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = seed ^ str.length;
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);
k = Umul32(k, m);
k ^= k >>> r;
k = Umul32(k, m);
h = Umul32(h, m);
h ^= k;
currentIndex += 4;
length -= 4;
}
switch (length) {
case 3:
h ^= UInt16(str, currentIndex);
h ^= str.charCodeAt(currentIndex + 2) << 16;
h = Umul32(h, m);
break;
case 2:
h ^= UInt16(str, currentIndex);
h = Umul32(h, m);
break;
case 1:
h ^= str.charCodeAt(currentIndex);
h = Umul32(h, m);
break;
}
h ^= h >>> 13;
h = Umul32(h, m);
h ^= h >>> 15;
return h >>> 0;
}
function UInt32(str, pos) {
return str.charCodeAt(pos++) + (str.charCodeAt(pos++) << 8) + (str.charCodeAt(pos++) << 16) + (str.charCodeAt(pos) << 24);
}
function UInt16(str, pos) {
return str.charCodeAt(pos++) + (str.charCodeAt(pos++) << 8);
}
function Umul32(n, m) {
n = n | 0;
m = m | 0;
var nlo = n & 0xffff;
var nhi = n >>> 16;
var res = nlo * m + ((nhi * m & 0xffff) << 16) | 0;
return res;
}
// CONCATENATED MODULE: ./src/index.js
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "styleSheet", function() { return styleSheet; });
/* harmony export (immutable) */ __webpack_exports__["speedy"] = speedy;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "plugins", function() { return src_plugins; });
/* harmony export (immutable) */ __webpack_exports__["simulations"] = simulations;
/* harmony export (immutable) */ __webpack_exports__["simulate"] = simulate;
/* harmony export (immutable) */ __webpack_exports__["cssLabels"] = cssLabels;
/* harmony export (immutable) */ __webpack_exports__["isLikeRule"] = isLikeRule;
/* harmony export (immutable) */ __webpack_exports__["idFor"] = idFor;
/* harmony export (immutable) */ __webpack_exports__["css"] = css;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "insertRule", function() { return insertRule; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "insertGlobal", function() { return insertGlobal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fontFace", function() { return fontFace; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "keyframes", function() { return keyframes; });
/* harmony export (immutable) */ __webpack_exports__["rehydrate"] = rehydrate;
/* harmony export (immutable) */ __webpack_exports__["flush"] = flush;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "presets", function() { return presets; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "style", function() { return src_style; });
/* harmony export (immutable) */ __webpack_exports__["select"] = select;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "$", function() { return $; });
/* harmony export (immutable) */ __webpack_exports__["parent"] = parent;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "merge", function() { return merge; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compose", function() { return compose; });
/* harmony export (immutable) */ __webpack_exports__["media"] = media;
/* harmony export (immutable) */ __webpack_exports__["pseudo"] = pseudo;
/* harmony export (immutable) */ __webpack_exports__["active"] = active;
/* harmony export (immutable) */ __webpack_exports__["any"] = any;
/* harmony export (immutable) */ __webpack_exports__["checked"] = checked;
/* harmony export (immutable) */ __webpack_exports__["disabled"] = disabled;
/* harmony export (immutable) */ __webpack_exports__["empty"] = empty;
/* harmony export (immutable) */ __webpack_exports__["enabled"] = enabled;
/* harmony export (immutable) */ __webpack_exports__["_default"] = _default;
/* harmony export (immutable) */ __webpack_exports__["first"] = first;
/* harmony export (immutable) */ __webpack_exports__["firstChild"] = firstChild;
/* harmony export (immutable) */ __webpack_exports__["firstOfType"] = firstOfType;
/* harmony export (immutable) */ __webpack_exports__["fullscreen"] = fullscreen;
/* harmony export (immutable) */ __webpack_exports__["focus"] = focus;
/* harmony export (immutable) */ __webpack_exports__["hover"] = hover;
/* harmony export (immutable) */ __webpack_exports__["indeterminate"] = indeterminate;
/* harmony export (immutable) */ __webpack_exports__["inRange"] = inRange;
/* harmony export (immutable) */ __webpack_exports__["invalid"] = invalid;
/* harmony export (immutable) */ __webpack_exports__["lastChild"] = lastChild;
/* harmony export (immutable) */ __webpack_exports__["lastOfType"] = lastOfType;
/* harmony export (immutable) */ __webpack_exports__["left"] = left;
/* harmony export (immutable) */ __webpack_exports__["link"] = link;
/* harmony export (immutable) */ __webpack_exports__["onlyChild"] = onlyChild;
/* harmony export (immutable) */ __webpack_exports__["onlyOfType"] = onlyOfType;
/* harmony export (immutable) */ __webpack_exports__["optional"] = optional;
/* harmony export (immutable) */ __webpack_exports__["outOfRange"] = outOfRange;
/* harmony export (immutable) */ __webpack_exports__["readOnly"] = readOnly;
/* harmony export (immutable) */ __webpack_exports__["readWrite"] = readWrite;
/* harmony export (immutable) */ __webpack_exports__["required"] = required;
/* harmony export (immutable) */ __webpack_exports__["right"] = right;
/* harmony export (immutable) */ __webpack_exports__["root"] = root;
/* harmony export (immutable) */ __webpack_exports__["scope"] = scope;
/* harmony export (immutable) */ __webpack_exports__["target"] = target;
/* harmony export (immutable) */ __webpack_exports__["valid"] = valid;
/* harmony export (immutable) */ __webpack_exports__["visited"] = visited;
/* harmony export (immutable) */ __webpack_exports__["dir"] = dir;
/* harmony export (immutable) */ __webpack_exports__["lang"] = lang;
/* harmony export (immutable) */ __webpack_exports__["not"] = not;
/* harmony export (immutable) */ __webpack_exports__["nthChild"] = nthChild;
/* harmony export (immutable) */ __webpack_exports__["nthLastChild"] = nthLastChild;
/* harmony export (immutable) */ __webpack_exports__["nthLastOfType"] = nthLastOfType;
/* harmony export (immutable) */ __webpack_exports__["nthOfType"] = nthOfType;
/* harmony export (immutable) */ __webpack_exports__["after"] = after;
/* harmony export (immutable) */ __webpack_exports__["before"] = before;
/* harmony export (immutable) */ __webpack_exports__["firstLetter"] = firstLetter;
/* harmony export (immutable) */ __webpack_exports__["firstLine"] = firstLine;
/* harmony export (immutable) */ __webpack_exports__["selection"] = selection;
/* harmony export (immutable) */ __webpack_exports__["backdrop"] = backdrop;
/* harmony export (immutable) */ __webpack_exports__["placeholder"] = placeholder;
/* harmony export (immutable) */ __webpack_exports__["cssFor"] = cssFor;
/* harmony export (immutable) */ __webpack_exports__["attribsFor"] = attribsFor;
/* harmony import */ var src___WEBPACK_IMPORTED_MODULE_0_object_assign__ = __webpack_require__(1);
/* harmony import */ var src___WEBPACK_IMPORTED_MODULE_0_object_assign___default = __webpack_require__.n(src___WEBPACK_IMPORTED_MODULE_0_object_assign__);
function src__toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
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; }
/* stylesheet */
var styleSheet = new StyleSheet();
// an isomorphic StyleSheet shim. hides all the nitty gritty.
// /**************** LIFTOFF IN 3... 2... 1... ****************/
styleSheet.inject(); //eslint-disable-line indent
// /**************** TO THE MOOOOOOON ****************/
// convenience function to toggle speedy
function speedy(bool) {
return styleSheet.speedy(bool);
}
// plugins
// we include these by default
var src_plugins = styleSheet.plugins = new PluginSet([plugins_prefixes, contentWrap, fallbacks]);
src_plugins.media = new PluginSet(); // neat! media, font-face, keyframes
src_plugins.fontFace = new PluginSet();
src_plugins.keyframes = new PluginSet([plugins_prefixes, fallbacks]);
// define some constants
var src_isDev = "development" === 'development' || !"development";
var src_isTest = "development" === 'test';
var src_isBrowser = typeof window !== 'undefined';
/**** simulations ****/
// a flag to enable simulation meta tags on dom nodes
// defaults to true in dev mode. recommend *not* to
// toggle often.
var canSimulate = src_isDev;
// we use these flags for issuing warnings when simulate is called
// in prod / in incorrect order
var warned1 = false,
warned2 = false;
// toggles simulation activity. shouldn't be needed in most cases
function simulations() {
var bool = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
canSimulate = !!bool;
}
// use this on dom nodes to 'simulate' pseudoclasses
// <div {...hover({ color: 'red' })} {...simulate('hover', 'visited')}>...</div>
// you can even send in some weird ones, as long as it's in simple format
// and matches an existing rule on the element
// eg simulate('nthChild2', ':hover:active') etc
function simulate() {
for (var _len = arguments.length, pseudos = Array(_len), _key = 0; _key < _len; _key++) {
pseudos[_key] = arguments[_key];
}
pseudos = clean(pseudos);
if (!pseudos) return {};
if (!canSimulate) {
if (!warned1) {
console.warn('can\'t simulate without once calling simulations(true)'); //eslint-disable-line no-console
warned1 = true;
}
if (!src_isDev && !src_isTest && !warned2) {
console.warn('don\'t use simulation outside dev'); //eslint-disable-line no-console
warned2 = true;
}
return {};
}
return pseudos.reduce(function (o, p) {
return o['data-simulate-' + simple(p)] = '', o;
}, {});
}
/**** labels ****/
// toggle for debug labels.
// *shouldn't* have to mess with this manually
var hasLabels = src_isDev;
function cssLabels(bool) {
hasLabels = !!bool;
}
// takes a string, converts to lowercase, strips out nonalphanumeric.
fun