pretty-lights
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -51,6 +51,3 @@ "use strict"; | ||
// | ||
// export type EmotionBabelPluginPass = BabelPluginPass & { | ||
// emotionImportPath: string, | ||
// cssPropIdentifiers: Array<Identifier>, | ||
// importedNames: ImportedNames, | ||
// export type PrettyLightsBabelPluginPass = BabelPluginPass & { | ||
// count: number, | ||
@@ -211,11 +208,5 @@ // opts: any, | ||
}; | ||
const importedNameKeys = Object.keys(defaultImportedNames).map(key => key === 'styled' ? 'default' : key); | ||
const defaultEmotionPaths = ['emotion', 'react-emotion', 'preact-emotion', '@emotion/primitives']; | ||
const importedNameKeys = Object.keys(defaultImportedNames); | ||
const defaultPrettyLightPaths = ['pretty-lights']; | ||
function getRelativePath(filepath, absoluteInstancePath) { | ||
const relativePath = _path.default.relative(_path.default.dirname(filepath), absoluteInstancePath); | ||
return relativePath.charAt(0) === '.' ? relativePath : `./${relativePath}`; | ||
} | ||
function getAbsolutePath(instancePath, rootPath) { | ||
@@ -231,12 +222,2 @@ if (instancePath.charAt(0) === '.') { | ||
function getInstancePathToImport(instancePath, filepath) { | ||
const absolutePath = getAbsolutePath(instancePath, process.cwd()); | ||
if (absolutePath === false) { | ||
return instancePath; | ||
} | ||
return getRelativePath(filepath, absolutePath); | ||
} | ||
function getInstancePathToCompare(instancePath, rootPath) { | ||
@@ -257,3 +238,3 @@ const absolutePath = getAbsolutePath(instancePath, rootPath); | ||
return { | ||
name: 'emotion', | ||
name: 'pretty-lights', | ||
// not required | ||
@@ -266,10 +247,4 @@ // eslint-disable-next-line | ||
const hasFilepath = path.hub.file.opts.filename && path.hub.file.opts.filename !== 'unknown'; | ||
state.emotionImportPath = 'emotion'; | ||
if (state.opts.primaryInstance !== undefined) { | ||
state.emotionImportPath = getInstancePathToImport(state.opts.primaryInstance, path.hub.file.opts.filename); | ||
} | ||
state.importedNames = { ...defaultImportedNames, | ||
...state.opts.importedNames | ||
state.prettyLightsImportPath = 'pretty-lights'; | ||
state.importedNames = { ...defaultImportedNames | ||
}; | ||
@@ -329,3 +304,3 @@ const imports = []; | ||
const emotionPaths = defaultEmotionPaths.concat((state.opts.instances || []).map(instancePath => getInstancePathToCompare(instancePath, process.cwd()))); | ||
const prettyLightsPaths = defaultPrettyLightPaths; | ||
const dirname = hasFilepath ? _path.default.dirname(path.hub.file.opts.filename) : ''; | ||
@@ -336,3 +311,3 @@ imports.forEach(({ | ||
}) => { | ||
if (emotionPaths.indexOf(getInstancePathToCompare(source, dirname)) !== -1) { | ||
if (prettyLightsPaths.indexOf(getInstancePathToCompare(source, dirname)) !== -1) { | ||
const importedNames = specifiers.filter(v => importedNameKeys.indexOf(v.imported) !== -1).reduce((acc, { | ||
@@ -344,8 +319,5 @@ imported, | ||
}), defaultImportedNames); | ||
state.importedNames = { ...importedNames, | ||
...state.opts.importedNames | ||
}; | ||
state.importedNames = importedNames; | ||
} | ||
}); | ||
state.cssPropIdentifiers = []; | ||
} | ||
@@ -359,3 +331,3 @@ | ||
CallExpression(callExprPath) { | ||
if (callExprPath.node.callee.name === state.importedNames.css || state.cssPropIdentifiers.indexOf(callExprPath.node.callee) !== -1) { | ||
if (callExprPath.node.callee.name === state.importedNames.css) { | ||
hoistPureArgs(callExprPath); | ||
@@ -445,3 +417,3 @@ } | ||
} else if (t.isIdentifier(path.node.tag)) { | ||
if (path.node.tag.name === state.importedNames.css || state.cssPropIdentifiers.indexOf(path.node.tag) !== -1) { | ||
if (path.node.tag.name === state.importedNames.css) { | ||
replaceCssWithCallExpression(path, path.node.tag, state, t); | ||
@@ -448,0 +420,0 @@ } else if (path.node.tag.name === state.importedNames.keyframes) { |
@@ -15,4 +15,3 @@ "use strict"; | ||
// @flow | ||
// import type { EmotionBabelPluginPass } from './index' | ||
// import type { PrettyLightsBabelPluginPass } from './index' | ||
// import type { BabelFile } from 'babel-flow-types' | ||
@@ -19,0 +18,0 @@ function getGeneratorOpts(file) { |
@@ -42,13 +42,13 @@ "use strict"; | ||
function getStyles(emotion) { | ||
return Object.keys(emotion.caches.inserted).reduce((style, current) => { | ||
if (emotion.caches.inserted[current] === true) { | ||
function getStyles(lights) { | ||
return Object.keys(lights.caches.inserted).reduce((style, current) => { | ||
if (lights.caches.inserted[current] === true) { | ||
return style; | ||
} | ||
return style + emotion.caches.inserted[current]; | ||
return style + lights.caches.inserted[current]; | ||
}, ''); | ||
} | ||
function createSerializer(emotion, { | ||
function createSerializer(lights, { | ||
classNameReplacer, | ||
@@ -59,3 +59,3 @@ DOMElements = true | ||
nodes.forEach(node => { | ||
node.withEmotionStyles = true; | ||
node.withPrettyLightsStyles = true; | ||
}); | ||
@@ -69,8 +69,8 @@ } | ||
Object.keys(emotion.caches.registered).forEach(className => { | ||
Object.keys(lights.caches.registered).forEach(className => { | ||
const indexOfClassName = classNames.indexOf(className); | ||
if (indexOfClassName !== -1) { | ||
const nameWithoutKey = classNames[indexOfClassName].substring(emotion.caches.key.length + 1); | ||
styles += emotion.caches.inserted[nameWithoutKey]; | ||
const nameWithoutKey = classNames[indexOfClassName].substring(lights.caches.key.length + 1); | ||
styles += lights.caches.inserted[nameWithoutKey]; | ||
} | ||
@@ -84,3 +84,3 @@ }); | ||
console.error(e); | ||
throw new Error(`There was an error parsing css in jest-emotion: "${styles}"`); | ||
throw new Error(`There was an error parsing css in pretty-lights/jest: "${styles}"`); | ||
} | ||
@@ -97,7 +97,7 @@ | ||
const printedVal = printer(val); | ||
return (0, _replaceClassNames.replaceClassNames)(classNames, styles, printedVal, emotion.caches.key, classNameReplacer); | ||
return (0, _replaceClassNames.replaceClassNames)(classNames, styles, printedVal, lights.caches.key, classNameReplacer); | ||
} | ||
function test(val) { | ||
return val && !val.withEmotionStyles && (DOMElements ? (0, _utils.isReactElement)(val) || (0, _utils.isDOMElement)(val) : (0, _utils.isReactElement)(val)); | ||
return val && !val.withPrettyLightsStyles && (DOMElements ? (0, _utils.isReactElement)(val) || (0, _utils.isDOMElement)(val) : (0, _utils.isReactElement)(val)); | ||
} | ||
@@ -104,0 +104,0 @@ |
@@ -49,9 +49,9 @@ "use strict"; | ||
function getStylesFromClassNames(classNames, emotion) { | ||
return Object.keys(emotion.caches.registered).reduce((styles, className) => { | ||
function getStylesFromClassNames(classNames, lights) { | ||
return Object.keys(lights.caches.registered).reduce((styles, className) => { | ||
const indexOfClassName = classNames.indexOf(className); | ||
if (indexOfClassName !== -1) { | ||
const nameWithoutKey = classNames[indexOfClassName].substring(emotion.caches.key.length + 1); | ||
styles += emotion.caches.inserted[nameWithoutKey]; | ||
const nameWithoutKey = classNames[indexOfClassName].substring(lights.caches.key.length + 1); | ||
styles += lights.caches.inserted[nameWithoutKey]; | ||
} | ||
@@ -64,6 +64,6 @@ | ||
function createMatchers(emotion) { | ||
function createMatchers(lights) { | ||
function toHaveStyleRule(received, property, value) { | ||
const selectors = (0, _utils.getClassNamesFromNodes)([received]); | ||
const cssString = getStylesFromClassNames(selectors, emotion); | ||
const cssString = getStylesFromClassNames(selectors, lights); | ||
const styles = css.parse(cssString); | ||
@@ -70,0 +70,0 @@ const declaration = styles.stylesheet.rules.reduce((decs, rule) => Object.assign([], decs, rule.declarations), []).filter(dec => dec.type === 'declaration' && dec.property === property).pop(); |
@@ -8,3 +8,3 @@ "use strict"; | ||
const emotion = process.env.PRETTY_LIGHTS_TEST ? require('../src') : require('../'); | ||
module.exports = createSerializer(emotion); | ||
const lights = process.env.PRETTY_LIGHTS_TEST ? require('../src') : require('../'); | ||
module.exports = createSerializer(lights); |
@@ -1,2 +0,2 @@ | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("@emotion/stylis")),r=e(require("@emotion/hash")),n=e(require("stylis-rule-sheet")),o=e(require("@emotion/memoize")),i=e(require("@emotion/unitless")),s=e(require("@emotion/is-prop-valid")),a=e(require("@emotion/weak-memoize")),c=e(require("hoist-non-react-statics")),u=e(require("react")),l=/[A-Z]|^ms/g,p=o(function(e){return e.replace(l,"-$&").toLowerCase()}),d=function(e,t){return null==t||"boolean"==typeof t?"":1===i[e]||45===e.charCodeAt(1)||isNaN(t)||0===t?t:t+"px"};if("production"!==process.env.NODE_ENV){var f=/(attr|calc|counters?|url)\(/,h=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit","unset"],y=d;d=function(e,t){return"content"===e&&("string"!=typeof t||-1===h.indexOf(t)&&!f.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)))&&console.error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`"),y(e,t)}}var v=function(e){for(var t="",r=0;r<e.length;r+=1){var n=e[r];if(null!=n){var o=void 0;switch(typeof n){case"boolean":break;case"object":if(Array.isArray(n))o=v(n);else for(var i in o="",n)n[i]&&i&&(o&&(o+=" "),o+=i);break;default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},m="undefined"!=typeof document;function g(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key||""),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),(void 0!==e.container?e.container:document.head).appendChild(t),t}var _=function(e){this.isSpeedy="production"===process.env.NODE_ENV,this.tags=[],this.ctr=0,this.opts=e};_.prototype.inject=function(){if(this.injected)throw new Error("already injected!");this.tags[0]=g(this.opts),this.injected=!0},_.prototype.speedy=function(e){if(0!==this.ctr)throw new Error("cannot change speedy now");this.isSpeedy=!!e},_.prototype.insert=function(e,t){if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t+=1)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(this.tags[this.tags.length-1]);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"!==process.env.NODE_ENV&&console.warn("illegal rule",e)}}else{var n=g(this.opts);this.tags.push(n),n.appendChild(document.createTextNode(e+(t||"")))}this.ctr+=1,this.ctr%65e3==0&&this.tags.push(g(this.opts))},_.prototype.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0,this.injected=!1};var E=u.createContext({}),N=s,w=function(e){return"theme"!==e&&"innerRef"!==e},b=function(){return!0},O=function(e,t){for(var r=arguments,n=2,o=arguments.length;n<o;n+=1){var i=r[n],s=void 0;for(s in i)e(s)&&(t[s]=i[s])}return t},x=a(function(e){return a(function(t){return function(e,t){if("function"==typeof t){var r=t(e);if("production"!==process.env.NODE_ENV&&(null==r||"object"!=typeof r||Array.isArray(r)))throw new Error("[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!");return r}if("production"!==process.env.NODE_ENV&&(null==t||"object"!=typeof t||Array.isArray(t)))throw new Error("[ThemeProvider] Please make your theme prop a plain object");return Object.assign({},e,t)}(e,t)})});function C(){return(C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var j=function(e,o){if(void 0!==e.__SECRET_EMOTION__)return e.__SECRET_EMOTION__;void 0===o&&(o={});var i=o.key||"css";if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(i))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+i+'" was passed');var s,a,c=new _(o),u="",l=n(function(e){s+=e,m&&c.insert(e,u)});void 0!==o.prefix&&(a={prefix:o.prefix});var f={registered:{},inserted:{},nonce:o.nonce,key:i};m&&c.inject();var h=new t(a);function y(e,t){if(null==e)return"";switch(typeof e){case"boolean":return"";case"function":if(void 0!==e.__emotion_styles){var r=e.toString();if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");return r}return void 0===this&&"production"!==process.env.NODE_ENV&&console.error("Interpolating functions in css calls is deprecated and will be removed in the next major version of Emotion.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"),y.call(this,void 0===this?e():e(this.mergedProps,this.context),t);case"object":return function(e){if(N.has(e))return N.get(e);var t="";return Array.isArray(e)?e.forEach(function(e){t+=y.call(this,e,!1)},this):Object.keys(e).forEach(function(r){if("object"!=typeof e[r])t+=void 0!==f.registered[e[r]]?r+"{"+f.registered[e[r]]+"}":p(r)+":"+d(r,e[r])+";";else{if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");Array.isArray(e[r])&&"string"==typeof e[r][0]&&void 0===f.registered[e[r][0]]?e[r].forEach(function(e){t+=p(r)+":"+d(r,e)+";"}):t+=r+"{"+y.call(this,e[r],!1)+"}"}},this),N.set(e,t),t}.call(this,e);default:var n=f.registered[e];return!1===t&&void 0!==n?n:e}}h.use(o.stylisPlugins)(l);var g,E,N=new WeakMap,w=/label:\s*([^\s;\n{]+)\s*;/g,b=function(e,t){return r(e+t)+t};if("production"!==process.env.NODE_ENV){var O=b,x=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;b=function(e,t){return O(e.replace(x,function(e){return u=e,""}),t)}}var C=function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];var n=!0,o="",i="";return null==e||void 0===e.raw?(n=!1,o+=y.call(this,e,!1)):o+=e[0],t.forEach(function(t,r){o+=y.call(this,t,46===o.charCodeAt(o.length-1)),!0===n&&void 0!==e[r+1]&&(o+=e[r+1])},this),E=o,o=o.replace(w,function(e,t){return i+="-"+t,""}),g=b(o,i),o};if("production"!==process.env.NODE_ENV){var j=h;h=function(e,t){j(e,t),u=""}}function P(e,t){void 0===f.inserted[g]&&(s="",h(e,t),f.inserted[g]=s)}var A=function(){var e=C.apply(this,arguments),t=i+"-"+g;return void 0===f.registered[t]&&(f.registered[t]=E),P("."+t,e),t};function S(e,t){var r="";return t.split(" ").forEach(function(t){void 0!==f.registered[t]?e.push(t):r+=t+" "}),r}function T(e,t){var r=[],n=S(r,e);return r.length<2?e:n+A(r,t)}function k(e){f.inserted[e]=!0}if(m){var R=document.querySelectorAll("[data-emotion-"+i+"]");Array.prototype.forEach.call(R,function(e){c.tags[0].parentNode.insertBefore(e,c.tags[0]),e.getAttribute("data-emotion-"+i).split(" ").forEach(k)})}var q={flush:function(){m&&(c.flush(),c.inject()),f.inserted={},f.registered={}},hydrate:function(e){e.forEach(k)},cx:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return T(v(e))},merge:T,getRegisteredStyles:S,injectGlobal:function(){P("",C.apply(this,arguments))},keyframes:function(){var e=C.apply(this,arguments),t="animation-"+g;return P("","@keyframes "+t+"{"+e+"}"),t},css:A,sheet:c,caches:f};return e.__SECRET_EMOTION__=q,q}("undefined"!=typeof global?global:{}),P=function(e){var t=function(r,n){if("production"!==process.env.NODE_ENV&&void 0===r)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var o,i,s,a;void 0!==n&&(o=n.e,i=n.label,s=n.target,a=r.__emotion_forwardProp&&n.shouldForwardProp?function(e){return r.__emotion_forwardProp(e)&&n.shouldForwardProp(e)}:n.shouldForwardProp);var c=r.__emotion_real===r,l=void 0===o&&c&&r.__emotion_base||r;return"function"!=typeof a&&(a="string"==typeof l&&l.charAt(0)===l.charAt(0).toLowerCase()?N:w),function(){var p=arguments,d=c&&void 0!==r.__emotion_styles?r.__emotion_styles.slice(0):[];if(void 0!==i&&d.push("label:"+i+";"),void 0===o)if(null==p[0]||void 0===p[0].raw)d.push.apply(d,p);else{d.push(p[0][0]);for(var f=p.length,h=1;h<f;h+=1)d.push(p[h],p[0][h])}var y=function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.render=function(){var t=this;return u.createElement(E.Consumer,null,function(r){var n=t.props;t.mergedProps=O(b,{},n,{theme:n.theme||r});var i="",c=[];return n.className&&(i+=void 0===o?e.getRegisteredStyles(c,n.className):n.className+" "),i+=void 0===o?e.css.apply(t,d.concat(c)):o,void 0!==s&&(i+=" "+s),u.createElement(l,O(a,{},n,{className:i,ref:n.innerRef}))})},r}(u.Component);return y.displayName=void 0!==i?i:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",void 0!==r.defaultProps&&(y.defaultProps=r.defaultProps),y.__emotion_styles=d,y.__emotion_base=l,y.__emotion_real=y,y.__emotion_forwardProp=a,Object.defineProperty(y,"toString",{value:function(){return"production"!==process.env.NODE_ENV&&void 0===s?"NO_COMPONENT_SELECTOR":"."+s}}),y.withComponent=function(e,r){return t(e,void 0!==r?O(b,{},n,r):n).apply(void 0,d)},y}};return"production"!==process.env.NODE_ENV&&"undefined"!=typeof Proxy&&(t=new Proxy(t,{get:function(e,t){switch(t){case"__proto__":case"name":case"prototype":case"displayName":return e[t];default:throw new Error("You're trying to use the styled shorthand without babel-plugin-emotion.\nPlease install and setup babel-plugin-emotion or use the function call syntax(`styled('"+t+"')` instead of `styled."+t+"`)")}}})),t}(j),A=function(e){return function(t){for(var r,n=new RegExp(e.caches.key+"-([a-zA-Z0-9-_]+)","gm"),o={html:t,ids:[],css:""},i={};null!==(r=n.exec(t));)void 0===i[r[1]]&&(i[r[1]]=!0);return o.ids=Object.keys(e.caches.inserted).filter(function(t){return(!0===i[t]||void 0===e.caches.registered[e.caches.key+"-"+t])&&!0!==e.caches.inserted[t]&&(o.css+=e.caches.inserted[t],!0)}),o}}(j),S=j.hydrate,T=j.cx,k=j.merge,R=j.getRegisteredStyles,q=j.injectGlobal,D=j.keyframes,V=j.css,M=j.sheet,I=j.caches;exports.flush=j.flush,exports.hydrate=S,exports.cx=T,exports.merge=k,exports.getRegisteredStyles=R,exports.injectGlobal=q,exports.keyframes=D,exports.css=V,exports.sheet=M,exports.caches=I,exports.ThemeContext=E,exports.ThemeProvider=function(e){return u.createElement(E.Consumer,null,function(t){return e.theme!==t&&(t=x(t)(e.theme)),u.createElement(E.Provider,{value:t},e.children)})},exports.useTheme=function(){return u.useContext(E)},exports.withTheme=function(e){var t=e.displayName||e.name||"Component",r=u.forwardRef(function(t,r){return u.createElement(E.Consumer,null,function(n){return u.createElement(e,C({theme:n,ref:r},t))})});return r.displayName="WithTheme("+t+")",c(r,e)},exports.extractCritical=A,exports.styled=P; | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("@emotion/stylis")),r=e(require("@emotion/hash")),n=e(require("stylis-rule-sheet")),o=e(require("@emotion/memoize")),i=e(require("@emotion/unitless")),s=e(require("@emotion/is-prop-valid")),a=e(require("@emotion/weak-memoize")),c=e(require("hoist-non-react-statics")),u=e(require("react")),l=/[A-Z]|^ms/g,p=o(function(e){return e.replace(l,"-$&").toLowerCase()}),h=function(e,t){return null==t||"boolean"==typeof t?"":1===i[e]||45===e.charCodeAt(1)||isNaN(t)||0===t?t:t+"px"};if("production"!==process.env.NODE_ENV){var f=/(attr|calc|counters?|url)\(/,d=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit","unset"],y=h;h=function(e,t){return"content"===e&&("string"!=typeof t||-1===d.indexOf(t)&&!f.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)))&&console.error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`"),y(e,t)}}var v=function(e){for(var t="",r=0;r<e.length;r+=1){var n=e[r];if(null!=n){var o=void 0;switch(typeof n){case"boolean":break;case"object":if(Array.isArray(n))o=v(n);else for(var i in o="",n)n[i]&&i&&(o&&(o+=" "),o+=i);break;default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},m="undefined"!=typeof document;function g(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key||""),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),(void 0!==e.container?e.container:document.head).appendChild(t),t}var _=function(e){this.isSpeedy="production"===process.env.NODE_ENV,this.tags=[],this.ctr=0,this.opts=e};_.prototype.inject=function(){if(this.injected)throw new Error("already injected!");this.tags[0]=g(this.opts),this.injected=!0},_.prototype.speedy=function(e){if(0!==this.ctr)throw new Error("cannot change speedy now");this.isSpeedy=!!e},_.prototype.insert=function(e,t){if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t+=1)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(this.tags[this.tags.length-1]);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"!==process.env.NODE_ENV&&console.warn("illegal rule",e)}}else{var n=g(this.opts);this.tags.push(n),n.appendChild(document.createTextNode(e+(t||"")))}this.ctr+=1,this.ctr%65e3==0&&this.tags.push(g(this.opts))},_.prototype.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0,this.injected=!1};var E=u.createContext({}),w=s,N=function(e){return"theme"!==e&&"innerRef"!==e},b=function(){return!0},x=function(e,t){for(var r=arguments,n=2,o=arguments.length;n<o;n+=1){var i=r[n],s=void 0;for(s in i)e(s)&&(t[s]=i[s])}return t},O=a(function(e){return a(function(t){return function(e,t){if("function"==typeof t){var r=t(e);if("production"!==process.env.NODE_ENV&&(null==r||"object"!=typeof r||Array.isArray(r)))throw new Error("[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!");return r}if("production"!==process.env.NODE_ENV&&(null==t||"object"!=typeof t||Array.isArray(t)))throw new Error("[ThemeProvider] Please make your theme prop a plain object");return Object.assign({},e,t)}(e,t)})});function C(){return(C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function j(e,t,r){var n,o=t.theme&&t.theme[e];return"function"==typeof(n="function"==typeof o?o(r):r[o]?r[o]:r.none)?n(t):n}function P(e,t){return function(r){return j(e,r,t)}}P.variants=function(e,t,r){return function(n){var o=n[t]&&r[n[t]];return o&&j(e,n,o)}};var S=function(e,o){if(void 0!==e.__SECRET_LIGHTS__)return e.__SECRET_LIGHTS__;void 0===o&&(o={});var i=o.key||"css";if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(i))throw new Error('Pretty Lights key must only contain lower case alphabetical characters and - but "'+i+'" was passed');var s,a,c=new _(o),u="",l=n(function(e){s+=e,m&&c.insert(e,u)});void 0!==o.prefix&&(a={prefix:o.prefix});var f={registered:{},inserted:{},nonce:o.nonce,key:i};m&&c.inject();var d=new t(a);function y(e,t){if(null==e)return"";switch(typeof e){case"boolean":return"";case"function":if(void 0!==e.__lights_styles){var r=e.toString();if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with pretty-lights/babel.");return r}return void 0===this&&"production"!==process.env.NODE_ENV&&console.error("Interpolating functions in css calls is deprecated.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"),y.call(this,void 0===this?e():e(this.mergedProps,this.context),t);case"object":return function(e){if(w.has(e))return w.get(e);var t="";return Array.isArray(e)?e.forEach(function(e){t+=y.call(this,e,!1)},this):Object.keys(e).forEach(function(r){if("object"!=typeof e[r])t+=void 0!==f.registered[e[r]]?r+"{"+f.registered[e[r]]+"}":p(r)+":"+h(r,e[r])+";";else{if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with pretty-lights/babel.");Array.isArray(e[r])&&"string"==typeof e[r][0]&&void 0===f.registered[e[r][0]]?e[r].forEach(function(e){t+=p(r)+":"+h(r,e)+";"}):t+=r+"{"+y.call(this,e[r],!1)+"}"}},this),w.set(e,t),t}.call(this,e);default:var n=f.registered[e];return!1===t&&void 0!==n?n:e}}d.use(o.stylisPlugins)(l);var g,E,w=new WeakMap,N=/label:\s*([^\s;\n{]+)\s*;/g,b=function(e,t){return r(e+t)+t};if("production"!==process.env.NODE_ENV){var x=b,O=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;b=function(e,t){return x(e.replace(O,function(e){return u=e,""}),t)}}var C=function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];var n=!0,o="",i="";return null==e||void 0===e.raw?(n=!1,o+=y.call(this,e,!1)):o+=e[0],t.forEach(function(t,r){o+=y.call(this,t,46===o.charCodeAt(o.length-1)),!0===n&&void 0!==e[r+1]&&(o+=e[r+1])},this),E=o,o=o.replace(N,function(e,t){return i+="-"+t,""}),g=b(o,i),o};if("production"!==process.env.NODE_ENV){var j=d;d=function(e,t){j(e,t),u=""}}function P(e,t){void 0===f.inserted[g]&&(s="",d(e,t),f.inserted[g]=s)}var S=function(){var e=C.apply(this,arguments),t=i+"-"+g;return void 0===f.registered[t]&&(f.registered[t]=E),P("."+t,e),t};function A(e,t){var r="";return t.split(" ").forEach(function(t){void 0!==f.registered[t]?e.push(t):r+=t+" "}),r}function T(e,t){var r=[],n=A(r,e);return r.length<2?e:n+S(r,t)}function k(e){f.inserted[e]=!0}if(m){var R=document.querySelectorAll("[data-emotion-"+i+"]");Array.prototype.forEach.call(R,function(e){c.tags[0].parentNode.insertBefore(e,c.tags[0]),e.getAttribute("data-emotion-"+i).split(" ").forEach(k)})}var q={flush:function(){m&&(c.flush(),c.inject()),f.inserted={},f.registered={}},hydrate:function(e){e.forEach(k)},cx:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return T(v(e))},merge:T,getRegisteredStyles:A,injectGlobal:function(){P("",C.apply(this,arguments))},keyframes:function(){var e=C.apply(this,arguments),t="animation-"+g;return P("","@keyframes "+t+"{"+e+"}"),t},css:S,sheet:c,caches:f};return e.__SECRET_LIGHTS__=q,q}("undefined"!=typeof global?global:{}),A=function(e){var t=function(r,n){if("production"!==process.env.NODE_ENV&&void 0===r)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var o,i,s,a;void 0!==n&&(o=n.e,i=n.label,s=n.target,a=r.__lights_forwardProp&&n.shouldForwardProp?function(e){return r.__lights_forwardProp(e)&&n.shouldForwardProp(e)}:n.shouldForwardProp);var c=r.__lights_real===r,l=void 0===o&&c&&r.__lights_base||r;return"function"!=typeof a&&(a="string"==typeof l&&l.charAt(0)===l.charAt(0).toLowerCase()?w:N),function(){var p=arguments,h=c&&void 0!==r.__lights_styles?r.__lights_styles.slice(0):[];if(void 0!==i&&h.push("label:"+i+";"),void 0===o)if(null==p[0]||void 0===p[0].raw)h.push.apply(h,p);else{h.push(p[0][0]);for(var f=p.length,d=1;d<f;d+=1)h.push(p[d],p[0][d])}var y=function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.render=function(){var t=this;return u.createElement(E.Consumer,null,function(r){var n=t.props;t.mergedProps=x(b,{},n,{theme:n.theme||r});var i="",c=[];return n.className&&(i+=void 0===o?e.getRegisteredStyles(c,n.className):n.className+" "),i+=void 0===o?e.css.apply(t,h.concat(c)):o,void 0!==s&&(i+=" "+s),u.createElement(l,x(a,{},n,{className:i,ref:n.innerRef}))})},r}(u.Component);return y.displayName=void 0!==i?i:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",void 0!==r.defaultProps&&(y.defaultProps=r.defaultProps),y.__lights_styles=h,y.__lights_base=l,y.__lights_real=y,y.__lights_forwardProp=a,Object.defineProperty(y,"toString",{value:function(){return"production"!==process.env.NODE_ENV&&void 0===s?"NO_COMPONENT_SELECTOR":"."+s}}),y.withComponent=function(e,r){return t(e,void 0!==r?x(b,{},n,r):n).apply(void 0,h)},y}};return"production"!==process.env.NODE_ENV&&"undefined"!=typeof Proxy&&(t=new Proxy(t,{get:function(e,t){switch(t){case"__proto__":case"name":case"prototype":case"displayName":return e[t];default:throw new Error("You're trying to use the styled shorthand without the pretty-lights/babel plugin.\nPlease add pretty-lights/babel to your Babel config or use the function call syntax(`styled('"+t+"')` instead of `styled."+t+"`)")}}})),t}(S),T=function(e){return function(t){for(var r,n=new RegExp(e.caches.key+"-([a-zA-Z0-9-_]+)","gm"),o={html:t,ids:[],css:""},i={};null!==(r=n.exec(t));)void 0===i[r[1]]&&(i[r[1]]=!0);return o.ids=Object.keys(e.caches.inserted).filter(function(t){return(!0===i[t]||void 0===e.caches.registered[e.caches.key+"-"+t])&&!0!==e.caches.inserted[t]&&(o.css+=e.caches.inserted[t],!0)}),o}}(S),k=S.hydrate,R=S.cx,q=S.merge,D=S.getRegisteredStyles,V=S.injectGlobal,L=S.keyframes,G=S.css,I=S.sheet,M=S.caches;exports.flush=S.flush,exports.hydrate=k,exports.cx=R,exports.merge=q,exports.getRegisteredStyles=D,exports.injectGlobal=V,exports.keyframes=L,exports.css=G,exports.sheet=I,exports.caches=M,exports.ThemeContext=E,exports.ThemeProvider=function(e){return u.createElement(E.Consumer,null,function(t){return e.theme!==t&&(t=O(t)(e.theme)),u.createElement(E.Provider,{value:t},e.children)})},exports.useTheme=function(){return u.useContext(E)},exports.withTheme=function(e){var t=e.displayName||e.name||"Component",r=u.forwardRef(function(t,r){return u.createElement(E.Consumer,null,function(n){return u.createElement(e,C({theme:n,ref:r},t))})});return r.displayName="WithTheme("+t+")",c(r,e)},exports.themeFn=P,exports.extractCritical=T,exports.styled=A; | ||
//# sourceMappingURL=pretty-lights.js.map |
@@ -1,2 +0,2 @@ | ||
import e from"@emotion/stylis";import t from"@emotion/hash";import r from"stylis-rule-sheet";import n from"@emotion/memoize";import o from"@emotion/unitless";import i from"@emotion/is-prop-valid";import s from"@emotion/weak-memoize";import a from"hoist-non-react-statics";import c from"react";var u=/[A-Z]|^ms/g,l=n(function(e){return e.replace(u,"-$&").toLowerCase()}),p=function(e,t){return null==t||"boolean"==typeof t?"":1===o[e]||45===e.charCodeAt(1)||isNaN(t)||0===t?t:t+"px"};if("production"!==process.env.NODE_ENV){var f=/(attr|calc|counters?|url)\(/,d=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit","unset"],h=p;p=function(e,t){return"content"===e&&("string"!=typeof t||-1===d.indexOf(t)&&!f.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)))&&console.error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`"),h(e,t)}}var m=function(e){for(var t="",r=0;r<e.length;r+=1){var n=e[r];if(null!=n){var o=void 0;switch(typeof n){case"boolean":break;case"object":if(Array.isArray(n))o=m(n);else for(var i in o="",n)n[i]&&i&&(o&&(o+=" "),o+=i);break;default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},v="undefined"!=typeof document;function y(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key||""),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),(void 0!==e.container?e.container:document.head).appendChild(t),t}var _=function(e){this.isSpeedy="production"===process.env.NODE_ENV,this.tags=[],this.ctr=0,this.opts=e};_.prototype.inject=function(){if(this.injected)throw new Error("already injected!");this.tags[0]=y(this.opts),this.injected=!0},_.prototype.speedy=function(e){if(0!==this.ctr)throw new Error("cannot change speedy now");this.isSpeedy=!!e},_.prototype.insert=function(e,t){if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t+=1)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(this.tags[this.tags.length-1]);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"!==process.env.NODE_ENV&&console.warn("illegal rule",e)}}else{var n=y(this.opts);this.tags.push(n),n.appendChild(document.createTextNode(e+(t||"")))}this.ctr+=1,this.ctr%65e3==0&&this.tags.push(y(this.opts))},_.prototype.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0,this.injected=!1};var g=c.createContext({}),E=i,N=function(e){return"theme"!==e&&"innerRef"!==e},w=function(){return!0},b=function(e,t){for(var r=arguments,n=2,o=arguments.length;n<o;n+=1){var i=r[n],s=void 0;for(s in i)e(s)&&(t[s]=i[s])}return t},O=s(function(e){return s(function(t){return function(e,t){if("function"==typeof t){var r=t(e);if("production"!==process.env.NODE_ENV&&(null==r||"object"!=typeof r||Array.isArray(r)))throw new Error("[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!");return r}if("production"!==process.env.NODE_ENV&&(null==t||"object"!=typeof t||Array.isArray(t)))throw new Error("[ThemeProvider] Please make your theme prop a plain object");return Object.assign({},e,t)}(e,t)})}),C=function(e){return c.createElement(g.Consumer,null,function(t){return e.theme!==t&&(t=O(t)(e.theme)),c.createElement(g.Provider,{value:t},e.children)})};function j(){return(j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function A(e){var t=e.displayName||e.name||"Component",r=c.forwardRef(function(t,r){return c.createElement(g.Consumer,null,function(n){return c.createElement(e,j({theme:n,ref:r},t))})});return r.displayName="WithTheme("+t+")",a(r,e)}function P(){return c.useContext(g)}var S=function(n,o){if(void 0!==n.__SECRET_EMOTION__)return n.__SECRET_EMOTION__;void 0===o&&(o={});var i=o.key||"css";if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(i))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+i+'" was passed');var s,a,c=new _(o),u="",f=r(function(e){s+=e,v&&c.insert(e,u)});void 0!==o.prefix&&(a={prefix:o.prefix});var d={registered:{},inserted:{},nonce:o.nonce,key:i};v&&c.inject();var h=new e(a);function y(e,t){if(null==e)return"";switch(typeof e){case"boolean":return"";case"function":if(void 0!==e.__emotion_styles){var r=e.toString();if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");return r}return void 0===this&&"production"!==process.env.NODE_ENV&&console.error("Interpolating functions in css calls is deprecated and will be removed in the next major version of Emotion.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"),y.call(this,void 0===this?e():e(this.mergedProps,this.context),t);case"object":return function(e){if(N.has(e))return N.get(e);var t="";return Array.isArray(e)?e.forEach(function(e){t+=y.call(this,e,!1)},this):Object.keys(e).forEach(function(r){if("object"!=typeof e[r])t+=void 0!==d.registered[e[r]]?r+"{"+d.registered[e[r]]+"}":l(r)+":"+p(r,e[r])+";";else{if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");Array.isArray(e[r])&&"string"==typeof e[r][0]&&void 0===d.registered[e[r][0]]?e[r].forEach(function(e){t+=l(r)+":"+p(r,e)+";"}):t+=r+"{"+y.call(this,e[r],!1)+"}"}},this),N.set(e,t),t}.call(this,e);default:var n=d.registered[e];return!1===t&&void 0!==n?n:e}}h.use(o.stylisPlugins)(f);var g,E,N=new WeakMap,w=/label:\s*([^\s;\n{]+)\s*;/g,b=function(e,r){return t(e+r)+r};if("production"!==process.env.NODE_ENV){var O=b,C=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;b=function(e,t){return O(e.replace(C,function(e){return u=e,""}),t)}}var j=function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];var n=!0,o="",i="";return null==e||void 0===e.raw?(n=!1,o+=y.call(this,e,!1)):o+=e[0],t.forEach(function(t,r){o+=y.call(this,t,46===o.charCodeAt(o.length-1)),!0===n&&void 0!==e[r+1]&&(o+=e[r+1])},this),E=o,o=o.replace(w,function(e,t){return i+="-"+t,""}),g=b(o,i),o};if("production"!==process.env.NODE_ENV){var A=h;h=function(e,t){A(e,t),u=""}}function P(e,t){void 0===d.inserted[g]&&(s="",h(e,t),d.inserted[g]=s)}var S=function(){var e=j.apply(this,arguments),t=i+"-"+g;return void 0===d.registered[t]&&(d.registered[t]=E),P("."+t,e),t};function x(e,t){var r="";return t.split(" ").forEach(function(t){void 0!==d.registered[t]?e.push(t):r+=t+" "}),r}function k(e,t){var r=[],n=x(r,e);return r.length<2?e:n+S(r,t)}function T(e){d.inserted[e]=!0}if(v){var R=document.querySelectorAll("[data-emotion-"+i+"]");Array.prototype.forEach.call(R,function(e){c.tags[0].parentNode.insertBefore(e,c.tags[0]),e.getAttribute("data-emotion-"+i).split(" ").forEach(T)})}var D={flush:function(){v&&(c.flush(),c.inject()),d.inserted={},d.registered={}},hydrate:function(e){e.forEach(T)},cx:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return k(m(e))},merge:k,getRegisteredStyles:x,injectGlobal:function(){P("",j.apply(this,arguments))},keyframes:function(){var e=j.apply(this,arguments),t="animation-"+g;return P("","@keyframes "+t+"{"+e+"}"),t},css:S,sheet:c,caches:d};return n.__SECRET_EMOTION__=D,D}("undefined"!=typeof global?global:{}),x=function(e){var t=function(r,n){if("production"!==process.env.NODE_ENV&&void 0===r)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var o,i,s,a;void 0!==n&&(o=n.e,i=n.label,s=n.target,a=r.__emotion_forwardProp&&n.shouldForwardProp?function(e){return r.__emotion_forwardProp(e)&&n.shouldForwardProp(e)}:n.shouldForwardProp);var u=r.__emotion_real===r,l=void 0===o&&u&&r.__emotion_base||r;return"function"!=typeof a&&(a="string"==typeof l&&l.charAt(0)===l.charAt(0).toLowerCase()?E:N),function(){var p=arguments,f=u&&void 0!==r.__emotion_styles?r.__emotion_styles.slice(0):[];if(void 0!==i&&f.push("label:"+i+";"),void 0===o)if(null==p[0]||void 0===p[0].raw)f.push.apply(f,p);else{f.push(p[0][0]);for(var d=p.length,h=1;h<d;h+=1)f.push(p[h],p[0][h])}var m=function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.render=function(){var t=this;return c.createElement(g.Consumer,null,function(r){var n=t.props;t.mergedProps=b(w,{},n,{theme:n.theme||r});var i="",u=[];return n.className&&(i+=void 0===o?e.getRegisteredStyles(u,n.className):n.className+" "),i+=void 0===o?e.css.apply(t,f.concat(u)):o,void 0!==s&&(i+=" "+s),c.createElement(l,b(a,{},n,{className:i,ref:n.innerRef}))})},r}(c.Component);return m.displayName=void 0!==i?i:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",void 0!==r.defaultProps&&(m.defaultProps=r.defaultProps),m.__emotion_styles=f,m.__emotion_base=l,m.__emotion_real=m,m.__emotion_forwardProp=a,Object.defineProperty(m,"toString",{value:function(){return"production"!==process.env.NODE_ENV&&void 0===s?"NO_COMPONENT_SELECTOR":"."+s}}),m.withComponent=function(e,r){return t(e,void 0!==r?b(w,{},n,r):n).apply(void 0,f)},m}};return"production"!==process.env.NODE_ENV&&"undefined"!=typeof Proxy&&(t=new Proxy(t,{get:function(e,t){switch(t){case"__proto__":case"name":case"prototype":case"displayName":return e[t];default:throw new Error("You're trying to use the styled shorthand without babel-plugin-emotion.\nPlease install and setup babel-plugin-emotion or use the function call syntax(`styled('"+t+"')` instead of `styled."+t+"`)")}}})),t}(S),k=function(e){return function(t){for(var r,n=new RegExp(e.caches.key+"-([a-zA-Z0-9-_]+)","gm"),o={html:t,ids:[],css:""},i={};null!==(r=n.exec(t));)void 0===i[r[1]]&&(i[r[1]]=!0);return o.ids=Object.keys(e.caches.inserted).filter(function(t){return(!0===i[t]||void 0===e.caches.registered[e.caches.key+"-"+t])&&!0!==e.caches.inserted[t]&&(o.css+=e.caches.inserted[t],!0)}),o}}(S),T=S.flush,R=S.hydrate,D=S.cx,V=S.merge,M=S.getRegisteredStyles,q=S.injectGlobal,I=S.keyframes,L=S.css,z=S.sheet,Y=S.caches;export{T as flush,R as hydrate,D as cx,V as merge,M as getRegisteredStyles,q as injectGlobal,I as keyframes,L as css,z as sheet,Y as caches,g as ThemeContext,C as ThemeProvider,P as useTheme,A as withTheme,k as extractCritical,x as styled}; | ||
import e from"@emotion/stylis";import t from"@emotion/hash";import r from"stylis-rule-sheet";import n from"@emotion/memoize";import o from"@emotion/unitless";import i from"@emotion/is-prop-valid";import s from"@emotion/weak-memoize";import a from"hoist-non-react-statics";import c from"react";var u=/[A-Z]|^ms/g,l=n(function(e){return e.replace(u,"-$&").toLowerCase()}),f=function(e,t){return null==t||"boolean"==typeof t?"":1===o[e]||45===e.charCodeAt(1)||isNaN(t)||0===t?t:t+"px"};if("production"!==process.env.NODE_ENV){var p=/(attr|calc|counters?|url)\(/,h=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit","unset"],d=f;f=function(e,t){return"content"===e&&("string"!=typeof t||-1===h.indexOf(t)&&!p.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)))&&console.error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`"),d(e,t)}}var y=function(e){for(var t="",r=0;r<e.length;r+=1){var n=e[r];if(null!=n){var o=void 0;switch(typeof n){case"boolean":break;case"object":if(Array.isArray(n))o=y(n);else for(var i in o="",n)n[i]&&i&&(o&&(o+=" "),o+=i);break;default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},v="undefined"!=typeof document;function m(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key||""),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),(void 0!==e.container?e.container:document.head).appendChild(t),t}var g=function(e){this.isSpeedy="production"===process.env.NODE_ENV,this.tags=[],this.ctr=0,this.opts=e};g.prototype.inject=function(){if(this.injected)throw new Error("already injected!");this.tags[0]=m(this.opts),this.injected=!0},g.prototype.speedy=function(e){if(0!==this.ctr)throw new Error("cannot change speedy now");this.isSpeedy=!!e},g.prototype.insert=function(e,t){if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t+=1)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(this.tags[this.tags.length-1]);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"!==process.env.NODE_ENV&&console.warn("illegal rule",e)}}else{var n=m(this.opts);this.tags.push(n),n.appendChild(document.createTextNode(e+(t||"")))}this.ctr+=1,this.ctr%65e3==0&&this.tags.push(m(this.opts))},g.prototype.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0,this.injected=!1};var _=c.createContext({}),E=i,w=function(e){return"theme"!==e&&"innerRef"!==e},N=function(){return!0},b=function(e,t){for(var r=arguments,n=2,o=arguments.length;n<o;n+=1){var i=r[n],s=void 0;for(s in i)e(s)&&(t[s]=i[s])}return t},O=s(function(e){return s(function(t){return function(e,t){if("function"==typeof t){var r=t(e);if("production"!==process.env.NODE_ENV&&(null==r||"object"!=typeof r||Array.isArray(r)))throw new Error("[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!");return r}if("production"!==process.env.NODE_ENV&&(null==t||"object"!=typeof t||Array.isArray(t)))throw new Error("[ThemeProvider] Please make your theme prop a plain object");return Object.assign({},e,t)}(e,t)})}),C=function(e){return c.createElement(_.Consumer,null,function(t){return e.theme!==t&&(t=O(t)(e.theme)),c.createElement(_.Provider,{value:t},e.children)})};function j(){return(j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function P(e){var t=e.displayName||e.name||"Component",r=c.forwardRef(function(t,r){return c.createElement(_.Consumer,null,function(n){return c.createElement(e,j({theme:n,ref:r},t))})});return r.displayName="WithTheme("+t+")",a(r,e)}function S(){return c.useContext(_)}function A(e,t,r){var n,o=t.theme&&t.theme[e];return"function"==typeof(n="function"==typeof o?o(r):r[o]?r[o]:r.none)?n(t):n}function k(e,t){return function(r){return A(e,r,t)}}k.variants=function(e,t,r){return function(n){var o=n[t]&&r[n[t]];return o&&A(e,n,o)}};var x=function(n,o){if(void 0!==n.__SECRET_LIGHTS__)return n.__SECRET_LIGHTS__;void 0===o&&(o={});var i=o.key||"css";if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(i))throw new Error('Pretty Lights key must only contain lower case alphabetical characters and - but "'+i+'" was passed');var s,a,c=new g(o),u="",p=r(function(e){s+=e,v&&c.insert(e,u)});void 0!==o.prefix&&(a={prefix:o.prefix});var h={registered:{},inserted:{},nonce:o.nonce,key:i};v&&c.inject();var d=new e(a);function m(e,t){if(null==e)return"";switch(typeof e){case"boolean":return"";case"function":if(void 0!==e.__lights_styles){var r=e.toString();if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with pretty-lights/babel.");return r}return void 0===this&&"production"!==process.env.NODE_ENV&&console.error("Interpolating functions in css calls is deprecated.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"),m.call(this,void 0===this?e():e(this.mergedProps,this.context),t);case"object":return function(e){if(w.has(e))return w.get(e);var t="";return Array.isArray(e)?e.forEach(function(e){t+=m.call(this,e,!1)},this):Object.keys(e).forEach(function(r){if("object"!=typeof e[r])t+=void 0!==h.registered[e[r]]?r+"{"+h.registered[e[r]]+"}":l(r)+":"+f(r,e[r])+";";else{if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with pretty-lights/babel.");Array.isArray(e[r])&&"string"==typeof e[r][0]&&void 0===h.registered[e[r][0]]?e[r].forEach(function(e){t+=l(r)+":"+f(r,e)+";"}):t+=r+"{"+m.call(this,e[r],!1)+"}"}},this),w.set(e,t),t}.call(this,e);default:var n=h.registered[e];return!1===t&&void 0!==n?n:e}}d.use(o.stylisPlugins)(p);var _,E,w=new WeakMap,N=/label:\s*([^\s;\n{]+)\s*;/g,b=function(e,r){return t(e+r)+r};if("production"!==process.env.NODE_ENV){var O=b,C=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;b=function(e,t){return O(e.replace(C,function(e){return u=e,""}),t)}}var j=function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];var n=!0,o="",i="";return null==e||void 0===e.raw?(n=!1,o+=m.call(this,e,!1)):o+=e[0],t.forEach(function(t,r){o+=m.call(this,t,46===o.charCodeAt(o.length-1)),!0===n&&void 0!==e[r+1]&&(o+=e[r+1])},this),E=o,o=o.replace(N,function(e,t){return i+="-"+t,""}),_=b(o,i),o};if("production"!==process.env.NODE_ENV){var P=d;d=function(e,t){P(e,t),u=""}}function S(e,t){void 0===h.inserted[_]&&(s="",d(e,t),h.inserted[_]=s)}var A=function(){var e=j.apply(this,arguments),t=i+"-"+_;return void 0===h.registered[t]&&(h.registered[t]=E),S("."+t,e),t};function k(e,t){var r="";return t.split(" ").forEach(function(t){void 0!==h.registered[t]?e.push(t):r+=t+" "}),r}function x(e,t){var r=[],n=k(r,e);return r.length<2?e:n+A(r,t)}function T(e){h.inserted[e]=!0}if(v){var R=document.querySelectorAll("[data-emotion-"+i+"]");Array.prototype.forEach.call(R,function(e){c.tags[0].parentNode.insertBefore(e,c.tags[0]),e.getAttribute("data-emotion-"+i).split(" ").forEach(T)})}var D={flush:function(){v&&(c.flush(),c.inject()),h.inserted={},h.registered={}},hydrate:function(e){e.forEach(T)},cx:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return x(y(e))},merge:x,getRegisteredStyles:k,injectGlobal:function(){S("",j.apply(this,arguments))},keyframes:function(){var e=j.apply(this,arguments),t="animation-"+_;return S("","@keyframes "+t+"{"+e+"}"),t},css:A,sheet:c,caches:h};return n.__SECRET_LIGHTS__=D,D}("undefined"!=typeof global?global:{}),T=function(e){var t=function(r,n){if("production"!==process.env.NODE_ENV&&void 0===r)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var o,i,s,a;void 0!==n&&(o=n.e,i=n.label,s=n.target,a=r.__lights_forwardProp&&n.shouldForwardProp?function(e){return r.__lights_forwardProp(e)&&n.shouldForwardProp(e)}:n.shouldForwardProp);var u=r.__lights_real===r,l=void 0===o&&u&&r.__lights_base||r;return"function"!=typeof a&&(a="string"==typeof l&&l.charAt(0)===l.charAt(0).toLowerCase()?E:w),function(){var f=arguments,p=u&&void 0!==r.__lights_styles?r.__lights_styles.slice(0):[];if(void 0!==i&&p.push("label:"+i+";"),void 0===o)if(null==f[0]||void 0===f[0].raw)p.push.apply(p,f);else{p.push(f[0][0]);for(var h=f.length,d=1;d<h;d+=1)p.push(f[d],f[0][d])}var y=function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.render=function(){var t=this;return c.createElement(_.Consumer,null,function(r){var n=t.props;t.mergedProps=b(N,{},n,{theme:n.theme||r});var i="",u=[];return n.className&&(i+=void 0===o?e.getRegisteredStyles(u,n.className):n.className+" "),i+=void 0===o?e.css.apply(t,p.concat(u)):o,void 0!==s&&(i+=" "+s),c.createElement(l,b(a,{},n,{className:i,ref:n.innerRef}))})},r}(c.Component);return y.displayName=void 0!==i?i:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",void 0!==r.defaultProps&&(y.defaultProps=r.defaultProps),y.__lights_styles=p,y.__lights_base=l,y.__lights_real=y,y.__lights_forwardProp=a,Object.defineProperty(y,"toString",{value:function(){return"production"!==process.env.NODE_ENV&&void 0===s?"NO_COMPONENT_SELECTOR":"."+s}}),y.withComponent=function(e,r){return t(e,void 0!==r?b(N,{},n,r):n).apply(void 0,p)},y}};return"production"!==process.env.NODE_ENV&&"undefined"!=typeof Proxy&&(t=new Proxy(t,{get:function(e,t){switch(t){case"__proto__":case"name":case"prototype":case"displayName":return e[t];default:throw new Error("You're trying to use the styled shorthand without the pretty-lights/babel plugin.\nPlease add pretty-lights/babel to your Babel config or use the function call syntax(`styled('"+t+"')` instead of `styled."+t+"`)")}}})),t}(x),R=function(e){return function(t){for(var r,n=new RegExp(e.caches.key+"-([a-zA-Z0-9-_]+)","gm"),o={html:t,ids:[],css:""},i={};null!==(r=n.exec(t));)void 0===i[r[1]]&&(i[r[1]]=!0);return o.ids=Object.keys(e.caches.inserted).filter(function(t){return(!0===i[t]||void 0===e.caches.registered[e.caches.key+"-"+t])&&!0!==e.caches.inserted[t]&&(o.css+=e.caches.inserted[t],!0)}),o}}(x),D=x.flush,V=x.hydrate,L=x.cx,q=x.merge,I=x.getRegisteredStyles,G=x.injectGlobal,M=x.keyframes,z=x.css,F=x.sheet,Y=x.caches;export{D as flush,V as hydrate,L as cx,q as merge,I as getRegisteredStyles,G as injectGlobal,M as keyframes,z as css,F as sheet,Y as caches,_ as ThemeContext,C as ThemeProvider,S as useTheme,P as withTheme,k as themeFn,R as extractCritical,T as styled}; | ||
//# sourceMappingURL=pretty-lights.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@emotion/stylis"),require("@emotion/hash"),require("stylis-rule-sheet"),require("@emotion/memoize"),require("@emotion/unitless"),require("@emotion/is-prop-valid"),require("@emotion/weak-memoize"),require("hoist-non-react-statics"),require("react")):"function"==typeof define&&define.amd?define(["exports","@emotion/stylis","@emotion/hash","stylis-rule-sheet","@emotion/memoize","@emotion/unitless","@emotion/is-prop-valid","@emotion/weak-memoize","hoist-non-react-statics","react"],t):t(e.prettyLights={},e.Stylis,e.hashString,e.stylisRuleSheet,e.memoize,e.unitless,e.isPropValid,e.weakMemoize,e.hoistNonReactStatics,e.react)}(this,function(e,t,r,n,o,i,s,a,c,u){t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r,n=n&&n.hasOwnProperty("default")?n.default:n,o=o&&o.hasOwnProperty("default")?o.default:o,i=i&&i.hasOwnProperty("default")?i.default:i,s=s&&s.hasOwnProperty("default")?s.default:s,a=a&&a.hasOwnProperty("default")?a.default:a,c=c&&c.hasOwnProperty("default")?c.default:c,u=u&&u.hasOwnProperty("default")?u.default:u;var l=/[A-Z]|^ms/g,d=o(function(e){return e.replace(l,"-$&").toLowerCase()}),f=function(e,t){return null==t||"boolean"==typeof t?"":1===i[e]||45===e.charCodeAt(1)||isNaN(t)||0===t?t:t+"px"};if("production"!==process.env.NODE_ENV){var p=/(attr|calc|counters?|url)\(/,h=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit","unset"],y=f;f=function(e,t){return"content"===e&&("string"!=typeof t||-1===h.indexOf(t)&&!p.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)))&&console.error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`"),y(e,t)}}var m=function(e){for(var t="",r=0;r<e.length;r+=1){var n=e[r];if(null!=n){var o=void 0;switch(typeof n){case"boolean":break;case"object":if(Array.isArray(n))o=m(n);else for(var i in o="",n)n[i]&&i&&(o&&(o+=" "),o+=i);break;default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},v="undefined"!=typeof document;function g(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key||""),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),(void 0!==e.container?e.container:document.head).appendChild(t),t}var _=function(e){this.isSpeedy="production"===process.env.NODE_ENV,this.tags=[],this.ctr=0,this.opts=e};_.prototype.inject=function(){if(this.injected)throw new Error("already injected!");this.tags[0]=g(this.opts),this.injected=!0},_.prototype.speedy=function(e){if(0!==this.ctr)throw new Error("cannot change speedy now");this.isSpeedy=!!e},_.prototype.insert=function(e,t){if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t+=1)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(this.tags[this.tags.length-1]);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"!==process.env.NODE_ENV&&console.warn("illegal rule",e)}}else{var n=g(this.opts);this.tags.push(n),n.appendChild(document.createTextNode(e+(t||"")))}this.ctr+=1,this.ctr%65e3==0&&this.tags.push(g(this.opts))},_.prototype.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0,this.injected=!1};var E=u.createContext({}),w=s,N=function(e){return"theme"!==e&&"innerRef"!==e},O=function(){return!0},b=function(e,t){for(var r=arguments,n=2,o=arguments.length;n<o;n+=1){var i=r[n],s=void 0;for(s in i)e(s)&&(t[s]=i[s])}return t},P=a(function(e){return a(function(t){return function(e,t){if("function"==typeof t){var r=t(e);if("production"!==process.env.NODE_ENV&&(null==r||"object"!=typeof r||Array.isArray(r)))throw new Error("[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!");return r}if("production"!==process.env.NODE_ENV&&(null==t||"object"!=typeof t||Array.isArray(t)))throw new Error("[ThemeProvider] Please make your theme prop a plain object");return Object.assign({},e,t)}(e,t)})});function C(){return(C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var j=function(e,o){if(void 0!==e.__SECRET_EMOTION__)return e.__SECRET_EMOTION__;void 0===o&&(o={});var i=o.key||"css";if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(i))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+i+'" was passed');var s,a,c=new _(o),u="",l=n(function(e){s+=e,v&&c.insert(e,u)});void 0!==o.prefix&&(a={prefix:o.prefix});var p={registered:{},inserted:{},nonce:o.nonce,key:i};v&&c.inject();var h=new t(a);function y(e,t){if(null==e)return"";switch(typeof e){case"boolean":return"";case"function":if(void 0!==e.__emotion_styles){var r=e.toString();if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");return r}return void 0===this&&"production"!==process.env.NODE_ENV&&console.error("Interpolating functions in css calls is deprecated and will be removed in the next major version of Emotion.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"),y.call(this,void 0===this?e():e(this.mergedProps,this.context),t);case"object":return function(e){if(w.has(e))return w.get(e);var t="";return Array.isArray(e)?e.forEach(function(e){t+=y.call(this,e,!1)},this):Object.keys(e).forEach(function(r){if("object"!=typeof e[r])t+=void 0!==p.registered[e[r]]?r+"{"+p.registered[e[r]]+"}":d(r)+":"+f(r,e[r])+";";else{if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with babel-plugin-emotion.");Array.isArray(e[r])&&"string"==typeof e[r][0]&&void 0===p.registered[e[r][0]]?e[r].forEach(function(e){t+=d(r)+":"+f(r,e)+";"}):t+=r+"{"+y.call(this,e[r],!1)+"}"}},this),w.set(e,t),t}.call(this,e);default:var n=p.registered[e];return!1===t&&void 0!==n?n:e}}h.use(o.stylisPlugins)(l);var g,E,w=new WeakMap,N=/label:\s*([^\s;\n{]+)\s*;/g,O=function(e,t){return r(e+t)+t};if("production"!==process.env.NODE_ENV){var b=O,P=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;O=function(e,t){return b(e.replace(P,function(e){return u=e,""}),t)}}var C=function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];var n=!0,o="",i="";return null==e||void 0===e.raw?(n=!1,o+=y.call(this,e,!1)):o+=e[0],t.forEach(function(t,r){o+=y.call(this,t,46===o.charCodeAt(o.length-1)),!0===n&&void 0!==e[r+1]&&(o+=e[r+1])},this),E=o,o=o.replace(N,function(e,t){return i+="-"+t,""}),g=O(o,i),o};if("production"!==process.env.NODE_ENV){var j=h;h=function(e,t){j(e,t),u=""}}function S(e,t){void 0===p.inserted[g]&&(s="",h(e,t),p.inserted[g]=s)}var A=function(){var e=C.apply(this,arguments),t=i+"-"+g;return void 0===p.registered[t]&&(p.registered[t]=E),S("."+t,e),t};function x(e,t){var r="";return t.split(" ").forEach(function(t){void 0!==p.registered[t]?e.push(t):r+=t+" "}),r}function k(e,t){var r=[],n=x(r,e);return r.length<2?e:n+A(r,t)}function T(e){p.inserted[e]=!0}if(v){var R=document.querySelectorAll("[data-emotion-"+i+"]");Array.prototype.forEach.call(R,function(e){c.tags[0].parentNode.insertBefore(e,c.tags[0]),e.getAttribute("data-emotion-"+i).split(" ").forEach(T)})}var q={flush:function(){v&&(c.flush(),c.inject()),p.inserted={},p.registered={}},hydrate:function(e){e.forEach(T)},cx:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return k(m(e))},merge:k,getRegisteredStyles:x,injectGlobal:function(){S("",C.apply(this,arguments))},keyframes:function(){var e=C.apply(this,arguments),t="animation-"+g;return S("","@keyframes "+t+"{"+e+"}"),t},css:A,sheet:c,caches:p};return e.__SECRET_EMOTION__=q,q}("undefined"!=typeof global?global:{}),S=function(e){var t=function(r,n){if("production"!==process.env.NODE_ENV&&void 0===r)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var o,i,s,a;void 0!==n&&(o=n.e,i=n.label,s=n.target,a=r.__emotion_forwardProp&&n.shouldForwardProp?function(e){return r.__emotion_forwardProp(e)&&n.shouldForwardProp(e)}:n.shouldForwardProp);var c=r.__emotion_real===r,l=void 0===o&&c&&r.__emotion_base||r;return"function"!=typeof a&&(a="string"==typeof l&&l.charAt(0)===l.charAt(0).toLowerCase()?w:N),function(){var d=arguments,f=c&&void 0!==r.__emotion_styles?r.__emotion_styles.slice(0):[];if(void 0!==i&&f.push("label:"+i+";"),void 0===o)if(null==d[0]||void 0===d[0].raw)f.push.apply(f,d);else{f.push(d[0][0]);for(var p=d.length,h=1;h<p;h+=1)f.push(d[h],d[0][h])}var y=function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.render=function(){var t=this;return u.createElement(E.Consumer,null,function(r){var n=t.props;t.mergedProps=b(O,{},n,{theme:n.theme||r});var i="",c=[];return n.className&&(i+=void 0===o?e.getRegisteredStyles(c,n.className):n.className+" "),i+=void 0===o?e.css.apply(t,f.concat(c)):o,void 0!==s&&(i+=" "+s),u.createElement(l,b(a,{},n,{className:i,ref:n.innerRef}))})},r}(u.Component);return y.displayName=void 0!==i?i:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",void 0!==r.defaultProps&&(y.defaultProps=r.defaultProps),y.__emotion_styles=f,y.__emotion_base=l,y.__emotion_real=y,y.__emotion_forwardProp=a,Object.defineProperty(y,"toString",{value:function(){return"production"!==process.env.NODE_ENV&&void 0===s?"NO_COMPONENT_SELECTOR":"."+s}}),y.withComponent=function(e,r){return t(e,void 0!==r?b(O,{},n,r):n).apply(void 0,f)},y}};return"production"!==process.env.NODE_ENV&&"undefined"!=typeof Proxy&&(t=new Proxy(t,{get:function(e,t){switch(t){case"__proto__":case"name":case"prototype":case"displayName":return e[t];default:throw new Error("You're trying to use the styled shorthand without babel-plugin-emotion.\nPlease install and setup babel-plugin-emotion or use the function call syntax(`styled('"+t+"')` instead of `styled."+t+"`)")}}})),t}(j),A=function(e){return function(t){for(var r,n=new RegExp(e.caches.key+"-([a-zA-Z0-9-_]+)","gm"),o={html:t,ids:[],css:""},i={};null!==(r=n.exec(t));)void 0===i[r[1]]&&(i[r[1]]=!0);return o.ids=Object.keys(e.caches.inserted).filter(function(t){return(!0===i[t]||void 0===e.caches.registered[e.caches.key+"-"+t])&&!0!==e.caches.inserted[t]&&(o.css+=e.caches.inserted[t],!0)}),o}}(j),x=j.hydrate,k=j.cx,T=j.merge,R=j.getRegisteredStyles,q=j.injectGlobal,V=j.keyframes,D=j.css,M=j.sheet,z=j.caches;e.flush=j.flush,e.hydrate=x,e.cx=k,e.merge=T,e.getRegisteredStyles=R,e.injectGlobal=q,e.keyframes=V,e.css=D,e.sheet=M,e.caches=z,e.ThemeContext=E,e.ThemeProvider=function(e){return u.createElement(E.Consumer,null,function(t){return e.theme!==t&&(t=P(t)(e.theme)),u.createElement(E.Provider,{value:t},e.children)})},e.useTheme=function(){return u.useContext(E)},e.withTheme=function(e){var t=e.displayName||e.name||"Component",r=u.forwardRef(function(t,r){return u.createElement(E.Consumer,null,function(n){return u.createElement(e,C({theme:n,ref:r},t))})});return r.displayName="WithTheme("+t+")",c(r,e)},e.extractCritical=A,e.styled=S}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@emotion/stylis"),require("@emotion/hash"),require("stylis-rule-sheet"),require("@emotion/memoize"),require("@emotion/unitless"),require("@emotion/is-prop-valid"),require("@emotion/weak-memoize"),require("hoist-non-react-statics"),require("react")):"function"==typeof define&&define.amd?define(["exports","@emotion/stylis","@emotion/hash","stylis-rule-sheet","@emotion/memoize","@emotion/unitless","@emotion/is-prop-valid","@emotion/weak-memoize","hoist-non-react-statics","react"],t):t(e.prettyLights={},e.Stylis,e.hashString,e.stylisRuleSheet,e.memoize,e.unitless,e.isPropValid,e.weakMemoize,e.hoistNonReactStatics,e.react)}(this,function(e,t,r,n,o,i,s,a,c,u){t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r,n=n&&n.hasOwnProperty("default")?n.default:n,o=o&&o.hasOwnProperty("default")?o.default:o,i=i&&i.hasOwnProperty("default")?i.default:i,s=s&&s.hasOwnProperty("default")?s.default:s,a=a&&a.hasOwnProperty("default")?a.default:a,c=c&&c.hasOwnProperty("default")?c.default:c,u=u&&u.hasOwnProperty("default")?u.default:u;var l=/[A-Z]|^ms/g,f=o(function(e){return e.replace(l,"-$&").toLowerCase()}),h=function(e,t){return null==t||"boolean"==typeof t?"":1===i[e]||45===e.charCodeAt(1)||isNaN(t)||0===t?t:t+"px"};if("production"!==process.env.NODE_ENV){var d=/(attr|calc|counters?|url)\(/,p=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit","unset"],y=h;h=function(e,t){return"content"===e&&("string"!=typeof t||-1===p.indexOf(t)&&!d.test(t)&&(t.charAt(0)!==t.charAt(t.length-1)||'"'!==t.charAt(0)&&"'"!==t.charAt(0)))&&console.error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+t+"\"'`"),y(e,t)}}var v=function(e){for(var t="",r=0;r<e.length;r+=1){var n=e[r];if(null!=n){var o=void 0;switch(typeof n){case"boolean":break;case"object":if(Array.isArray(n))o=v(n);else for(var i in o="",n)n[i]&&i&&(o&&(o+=" "),o+=i);break;default:o=n}o&&(t&&(t+=" "),t+=o)}}return t},m="undefined"!=typeof document;function g(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key||""),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),(void 0!==e.container?e.container:document.head).appendChild(t),t}var _=function(e){this.isSpeedy="production"===process.env.NODE_ENV,this.tags=[],this.ctr=0,this.opts=e};_.prototype.inject=function(){if(this.injected)throw new Error("already injected!");this.tags[0]=g(this.opts),this.injected=!0},_.prototype.speedy=function(e){if(0!==this.ctr)throw new Error("cannot change speedy now");this.isSpeedy=!!e},_.prototype.insert=function(e,t){if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t+=1)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(this.tags[this.tags.length-1]);try{r.insertRule(e,r.cssRules.length)}catch(t){"production"!==process.env.NODE_ENV&&console.warn("illegal rule",e)}}else{var n=g(this.opts);this.tags.push(n),n.appendChild(document.createTextNode(e+(t||"")))}this.ctr+=1,this.ctr%65e3==0&&this.tags.push(g(this.opts))},_.prototype.flush=function(){this.tags.forEach(function(e){return e.parentNode.removeChild(e)}),this.tags=[],this.ctr=0,this.injected=!1};var E=u.createContext({}),w=s,N=function(e){return"theme"!==e&&"innerRef"!==e},b=function(){return!0},O=function(e,t){for(var r=arguments,n=2,o=arguments.length;n<o;n+=1){var i=r[n],s=void 0;for(s in i)e(s)&&(t[s]=i[s])}return t},P=a(function(e){return a(function(t){return function(e,t){if("function"==typeof t){var r=t(e);if("production"!==process.env.NODE_ENV&&(null==r||"object"!=typeof r||Array.isArray(r)))throw new Error("[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!");return r}if("production"!==process.env.NODE_ENV&&(null==t||"object"!=typeof t||Array.isArray(t)))throw new Error("[ThemeProvider] Please make your theme prop a plain object");return Object.assign({},e,t)}(e,t)})});function C(){return(C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function S(e,t,r){var n,o=t.theme&&t.theme[e];return"function"==typeof(n="function"==typeof o?o(r):r[o]?r[o]:r.none)?n(t):n}function j(e,t){return function(r){return S(e,r,t)}}j.variants=function(e,t,r){return function(n){var o=n[t]&&r[n[t]];return o&&S(e,n,o)}};var A=function(e,o){if(void 0!==e.__SECRET_LIGHTS__)return e.__SECRET_LIGHTS__;void 0===o&&(o={});var i=o.key||"css";if("production"!==process.env.NODE_ENV&&/[^a-z-]/.test(i))throw new Error('Pretty Lights key must only contain lower case alphabetical characters and - but "'+i+'" was passed');var s,a,c=new _(o),u="",l=n(function(e){s+=e,m&&c.insert(e,u)});void 0!==o.prefix&&(a={prefix:o.prefix});var d={registered:{},inserted:{},nonce:o.nonce,key:i};m&&c.inject();var p=new t(a);function y(e,t){if(null==e)return"";switch(typeof e){case"boolean":return"";case"function":if(void 0!==e.__lights_styles){var r=e.toString();if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with pretty-lights/babel.");return r}return void 0===this&&"production"!==process.env.NODE_ENV&&console.error("Interpolating functions in css calls is deprecated.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"),y.call(this,void 0===this?e():e(this.mergedProps,this.context),t);case"object":return function(e){if(w.has(e))return w.get(e);var t="";return Array.isArray(e)?e.forEach(function(e){t+=y.call(this,e,!1)},this):Object.keys(e).forEach(function(r){if("object"!=typeof e[r])t+=void 0!==d.registered[e[r]]?r+"{"+d.registered[e[r]]+"}":f(r)+":"+h(r,e[r])+";";else{if("NO_COMPONENT_SELECTOR"===r&&"production"!==process.env.NODE_ENV)throw new Error("Component selectors can only be used in conjunction with pretty-lights/babel.");Array.isArray(e[r])&&"string"==typeof e[r][0]&&void 0===d.registered[e[r][0]]?e[r].forEach(function(e){t+=f(r)+":"+h(r,e)+";"}):t+=r+"{"+y.call(this,e[r],!1)+"}"}},this),w.set(e,t),t}.call(this,e);default:var n=d.registered[e];return!1===t&&void 0!==n?n:e}}p.use(o.stylisPlugins)(l);var g,E,w=new WeakMap,N=/label:\s*([^\s;\n{]+)\s*;/g,b=function(e,t){return r(e+t)+t};if("production"!==process.env.NODE_ENV){var O=b,P=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;b=function(e,t){return O(e.replace(P,function(e){return u=e,""}),t)}}var C=function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];var n=!0,o="",i="";return null==e||void 0===e.raw?(n=!1,o+=y.call(this,e,!1)):o+=e[0],t.forEach(function(t,r){o+=y.call(this,t,46===o.charCodeAt(o.length-1)),!0===n&&void 0!==e[r+1]&&(o+=e[r+1])},this),E=o,o=o.replace(N,function(e,t){return i+="-"+t,""}),g=b(o,i),o};if("production"!==process.env.NODE_ENV){var S=p;p=function(e,t){S(e,t),u=""}}function j(e,t){void 0===d.inserted[g]&&(s="",p(e,t),d.inserted[g]=s)}var A=function(){var e=C.apply(this,arguments),t=i+"-"+g;return void 0===d.registered[t]&&(d.registered[t]=E),j("."+t,e),t};function x(e,t){var r="";return t.split(" ").forEach(function(t){void 0!==d.registered[t]?e.push(t):r+=t+" "}),r}function k(e,t){var r=[],n=x(r,e);return r.length<2?e:n+A(r,t)}function T(e){d.inserted[e]=!0}if(m){var R=document.querySelectorAll("[data-emotion-"+i+"]");Array.prototype.forEach.call(R,function(e){c.tags[0].parentNode.insertBefore(e,c.tags[0]),e.getAttribute("data-emotion-"+i).split(" ").forEach(T)})}var q={flush:function(){m&&(c.flush(),c.inject()),d.inserted={},d.registered={}},hydrate:function(e){e.forEach(T)},cx:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return k(v(e))},merge:k,getRegisteredStyles:x,injectGlobal:function(){j("",C.apply(this,arguments))},keyframes:function(){var e=C.apply(this,arguments),t="animation-"+g;return j("","@keyframes "+t+"{"+e+"}"),t},css:A,sheet:c,caches:d};return e.__SECRET_LIGHTS__=q,q}("undefined"!=typeof global?global:{}),x=function(e){var t=function(r,n){if("production"!==process.env.NODE_ENV&&void 0===r)throw new Error("You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.");var o,i,s,a;void 0!==n&&(o=n.e,i=n.label,s=n.target,a=r.__lights_forwardProp&&n.shouldForwardProp?function(e){return r.__lights_forwardProp(e)&&n.shouldForwardProp(e)}:n.shouldForwardProp);var c=r.__lights_real===r,l=void 0===o&&c&&r.__lights_base||r;return"function"!=typeof a&&(a="string"==typeof l&&l.charAt(0)===l.charAt(0).toLowerCase()?w:N),function(){var f=arguments,h=c&&void 0!==r.__lights_styles?r.__lights_styles.slice(0):[];if(void 0!==i&&h.push("label:"+i+";"),void 0===o)if(null==f[0]||void 0===f[0].raw)h.push.apply(h,f);else{h.push(f[0][0]);for(var d=f.length,p=1;p<d;p+=1)h.push(f[p],f[0][p])}var y=function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),(r.prototype=Object.create(t&&t.prototype)).constructor=r,r.prototype.render=function(){var t=this;return u.createElement(E.Consumer,null,function(r){var n=t.props;t.mergedProps=O(b,{},n,{theme:n.theme||r});var i="",c=[];return n.className&&(i+=void 0===o?e.getRegisteredStyles(c,n.className):n.className+" "),i+=void 0===o?e.css.apply(t,h.concat(c)):o,void 0!==s&&(i+=" "+s),u.createElement(l,O(a,{},n,{className:i,ref:n.innerRef}))})},r}(u.Component);return y.displayName=void 0!==i?i:"Styled("+("string"==typeof l?l:l.displayName||l.name||"Component")+")",void 0!==r.defaultProps&&(y.defaultProps=r.defaultProps),y.__lights_styles=h,y.__lights_base=l,y.__lights_real=y,y.__lights_forwardProp=a,Object.defineProperty(y,"toString",{value:function(){return"production"!==process.env.NODE_ENV&&void 0===s?"NO_COMPONENT_SELECTOR":"."+s}}),y.withComponent=function(e,r){return t(e,void 0!==r?O(b,{},n,r):n).apply(void 0,h)},y}};return"production"!==process.env.NODE_ENV&&"undefined"!=typeof Proxy&&(t=new Proxy(t,{get:function(e,t){switch(t){case"__proto__":case"name":case"prototype":case"displayName":return e[t];default:throw new Error("You're trying to use the styled shorthand without the pretty-lights/babel plugin.\nPlease add pretty-lights/babel to your Babel config or use the function call syntax(`styled('"+t+"')` instead of `styled."+t+"`)")}}})),t}(A),k=function(e){return function(t){for(var r,n=new RegExp(e.caches.key+"-([a-zA-Z0-9-_]+)","gm"),o={html:t,ids:[],css:""},i={};null!==(r=n.exec(t));)void 0===i[r[1]]&&(i[r[1]]=!0);return o.ids=Object.keys(e.caches.inserted).filter(function(t){return(!0===i[t]||void 0===e.caches.registered[e.caches.key+"-"+t])&&!0!==e.caches.inserted[t]&&(o.css+=e.caches.inserted[t],!0)}),o}}(A),T=A.hydrate,R=A.cx,q=A.merge,V=A.getRegisteredStyles,D=A.injectGlobal,L=A.keyframes,z=A.css,G=A.sheet,I=A.caches;e.flush=A.flush,e.hydrate=T,e.cx=R,e.merge=q,e.getRegisteredStyles=V,e.injectGlobal=D,e.keyframes=L,e.css=z,e.sheet=G,e.caches=I,e.ThemeContext=E,e.ThemeProvider=function(e){return u.createElement(E.Consumer,null,function(t){return e.theme!==t&&(t=P(t)(e.theme)),u.createElement(E.Provider,{value:t},e.children)})},e.useTheme=function(){return u.useContext(E)},e.withTheme=function(e){var t=e.displayName||e.name||"Component",r=u.forwardRef(function(t,r){return u.createElement(E.Consumer,null,function(n){return u.createElement(e,C({theme:n,ref:r},t))})});return r.displayName="WithTheme("+t+")",c(r,e)},e.themeFn=j,e.extractCritical=k,e.styled=x}); | ||
//# sourceMappingURL=pretty-lights.umd.js.map |
{ | ||
"name": "pretty-lights", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "CSS-in-JS with a reliable API", | ||
@@ -5,0 +5,0 @@ "main": "lib/pretty-lights.js", |
# pretty-lights | ||
CSS-in-JS with a reliable API | ||
THIS IS PRE-RELEASE SOFTWARE. DO NOT USE IT. | ||
THIS IS PRE-RELEASE SOFTWARE. DO NOT USE IT. | ||
Pretty Lights is a performant and flexible CSS-in-JS library. Building on many other CSS-in-JS libraries, it allows you to style apps quickly with string or object styles. It has predictable composition to avoid specificity issues with CSS. With source maps and labels, Pretty Lights has a great developer experience and great performance with heavy caching in production. | ||
## Installation | ||
```sh | ||
npm i --save pretty-lights | ||
yarn add pretty-lights | ||
``` | ||
## Usage | ||
To use it, import what you need. | ||
### `css` | ||
Use `css` to create class names with styles. | ||
```js | ||
import { css } from 'pretty-lights'; | ||
const className = css` | ||
color: hotpink; | ||
`; | ||
const SomeComponent = ({ children }) => ( | ||
<div className={className}>Some hotpink text.{children}</div> | ||
); | ||
const anotherClassName = css({ | ||
textDecoration: 'underline', | ||
}); | ||
const AnotherComponent = () => <div className={anotherClassName}>Some text with an underline.</div>; | ||
``` | ||
### `styled` | ||
`styled` is a way to create React components that have styles attached to them. | ||
```js | ||
import { styled } from 'pretty-lights'; | ||
const Button = styled('button')` | ||
color: hotpink; | ||
`; | ||
render(<Button>This is a hotpink button.</Button>); | ||
``` | ||
### `pretty-lights/babel` | ||
Pretty Lights has an optional [Babel](https://babeljs.io/) plugin that optimizes styles by compressing and hoisting them and creates a better developer experience with source maps and labels. | ||
Instructions on using the Babel plugin: [docs](./src/babel/README.md) | ||
## Documentation | ||
- [`css`](./src/create/README.md) | ||
- [`styled`](./src/styled/README.md) | ||
- [`extractCritical`](./src/server/README.md#extractcritical) / [`hydrate`](./src/create/README.md#hydrate) | ||
- [`ThemeProvider`](./src/theming/README.md#themeprovider) / [`withTheme`](./src/theming/README.md#withtheme) / [`useTheme`](./src/theming/README.md#usetheme) | ||
- [`pretty-lights/jest`](./src/jest/README.md) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186066
67
777