Socket
Socket
Sign inDemoInstall

@emotion/styled-base

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emotion/styled-base - npm Package Compare versions

Comparing version 10.0.0-really-unsafe-please-do-not-use.2 to 10.0.0

dist/styled-base.umd.min.js

96

dist/styled-base.browser.cjs.js

@@ -9,2 +9,3 @@ 'use strict';

var isPropValid = _interopDefault(require('@emotion/is-prop-valid'));
var _objectAssign = _interopDefault(require('object-assign'));
var core = require('@emotion/core');

@@ -14,21 +15,4 @@ var utils = require('@emotion/utils');

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var testOmitPropsOnStringTag = isPropValid;
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -38,2 +22,9 @@ return key !== 'theme' && key !== 'innerRef';

var getDefaultShouldForwardProp = function getDefaultShouldForwardProp(tag) {
return typeof tag === 'string' && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
tag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
};
var createStyled = function createStyled(tag, options) {

@@ -61,40 +52,26 @@ if (process.env.NODE_ENV !== 'production') {

var baseTag = isReal && tag.__emotion_base || tag;
var isStringTag = typeof baseTag === 'string';
if (typeof shouldForwardProp !== 'function') {
shouldForwardProp = isStringTag && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
baseTag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
if (typeof shouldForwardProp !== 'function' && isReal) {
shouldForwardProp = tag.__emotion_forwardProp;
}
var defaultShouldForwardProp = shouldForwardProp || getDefaultShouldForwardProp(baseTag);
var shouldUseAs = !defaultShouldForwardProp('as');
return function () {
var args = arguments;
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : []; // idk if this is worth it.
// it's only for when autoLabel is on and styles are completely static
// and it's only a performance optimisation
// just committing this in case we want it later
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : [];
if (identifierName !== undefined && args.length === 1 && styles.length === 0 && args[0].styles !== undefined) {
styles.push({
name: args[0].name,
label: identifierName,
styles: args[0].styles,
map: args[0].map
});
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
styles.push(args[0][0]);
var len = args.length;
var i = 1;
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
styles.push(args[0][0]);
var len = args.length;
var i = 1;
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}

@@ -105,2 +82,3 @@ }

return React.createElement(core.ThemeContext.Consumer, null, function (theme) {
var finalTag = shouldUseAs && props.as || baseTag;
var className = '';

@@ -124,4 +102,4 @@ var classInterpolations = [];

var serialized = serialize.serializeStyles(context.registered, styles.concat(classInterpolations), mergedProps);
var rules = utils.insertStyles(context, serialized, isStringTag);
var serialized = serialize.serializeStyles(styles.concat(classInterpolations), context.registered, mergedProps);
var rules = utils.insertStyles(context, serialized, typeof finalTag === 'string');
className += context.key + "-" + serialized.name;

@@ -133,7 +111,10 @@

var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(finalTag) : defaultShouldForwardProp;
var newProps = {};
for (var _key in props) {
if (shouldUseAs && _key === 'as') continue;
if ( // $FlowFixMe
shouldForwardProp(_key)) {
finalShouldForwardProp(_key)) {
newProps[_key] = props[_key];

@@ -144,12 +125,9 @@ }

newProps.className = className;
newProps.ref = ref || props.innerRef;
{
newProps.ref = ref;
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is no longer allowed, please use the `ref` prop instead');
}
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is deprecated and will be removed in a future major version of Emotion, please use the `ref` prop instead' + (identifierName === undefined ? '' : " in the usage of `" + identifierName + "`"));
}
var ele = React.createElement(baseTag, newProps);
var ele = React.createElement(finalTag, newProps);

@@ -177,3 +155,3 @@ return ele;

Styled.withComponent = function (nextTag, nextOptions) {
return createStyled(nextTag, nextOptions !== undefined ? _extends({}, options || {}, nextOptions) : options).apply(void 0, styles);
return createStyled(nextTag, nextOptions !== undefined ? _objectAssign({}, options || {}, nextOptions) : options).apply(void 0, styles);
};

@@ -180,0 +158,0 @@

import { createElement } from 'react';
import isPropValid from '@emotion/is-prop-valid';
import _objectAssign from 'object-assign';
import { withEmotionCache, ThemeContext } from '@emotion/core';

@@ -7,21 +8,4 @@ import { getRegisteredStyles, insertStyles } from '@emotion/utils';

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var testOmitPropsOnStringTag = isPropValid;
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -31,2 +15,9 @@ return key !== 'theme' && key !== 'innerRef';

var getDefaultShouldForwardProp = function getDefaultShouldForwardProp(tag) {
return typeof tag === 'string' && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
tag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
};
var createStyled = function createStyled(tag, options) {

@@ -54,40 +45,26 @@ if (process.env.NODE_ENV !== 'production') {

var baseTag = isReal && tag.__emotion_base || tag;
var isStringTag = typeof baseTag === 'string';
if (typeof shouldForwardProp !== 'function') {
shouldForwardProp = isStringTag && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
baseTag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
if (typeof shouldForwardProp !== 'function' && isReal) {
shouldForwardProp = tag.__emotion_forwardProp;
}
var defaultShouldForwardProp = shouldForwardProp || getDefaultShouldForwardProp(baseTag);
var shouldUseAs = !defaultShouldForwardProp('as');
return function () {
var args = arguments;
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : []; // idk if this is worth it.
// it's only for when autoLabel is on and styles are completely static
// and it's only a performance optimisation
// just committing this in case we want it later
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : [];
if (identifierName !== undefined && args.length === 1 && styles.length === 0 && args[0].styles !== undefined) {
styles.push({
name: args[0].name,
label: identifierName,
styles: args[0].styles,
map: args[0].map
});
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
styles.push(args[0][0]);
var len = args.length;
var i = 1;
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
styles.push(args[0][0]);
var len = args.length;
var i = 1;
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}

@@ -98,2 +75,3 @@ }

return createElement(ThemeContext.Consumer, null, function (theme) {
var finalTag = shouldUseAs && props.as || baseTag;
var className = '';

@@ -117,4 +95,4 @@ var classInterpolations = [];

var serialized = serializeStyles(context.registered, styles.concat(classInterpolations), mergedProps);
var rules = insertStyles(context, serialized, isStringTag);
var serialized = serializeStyles(styles.concat(classInterpolations), context.registered, mergedProps);
var rules = insertStyles(context, serialized, typeof finalTag === 'string');
className += context.key + "-" + serialized.name;

@@ -126,7 +104,10 @@

var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(finalTag) : defaultShouldForwardProp;
var newProps = {};
for (var _key in props) {
if (shouldUseAs && _key === 'as') continue;
if ( // $FlowFixMe
shouldForwardProp(_key)) {
finalShouldForwardProp(_key)) {
newProps[_key] = props[_key];

@@ -137,12 +118,9 @@ }

newProps.className = className;
newProps.ref = ref || props.innerRef;
{
newProps.ref = ref;
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is no longer allowed, please use the `ref` prop instead');
}
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is deprecated and will be removed in a future major version of Emotion, please use the `ref` prop instead' + (identifierName === undefined ? '' : " in the usage of `" + identifierName + "`"));
}
var ele = createElement(baseTag, newProps);
var ele = createElement(finalTag, newProps);

@@ -170,3 +148,3 @@ return ele;

Styled.withComponent = function (nextTag, nextOptions) {
return createStyled(nextTag, nextOptions !== undefined ? _extends({}, options || {}, nextOptions) : options).apply(void 0, styles);
return createStyled(nextTag, nextOptions !== undefined ? _objectAssign({}, options || {}, nextOptions) : options).apply(void 0, styles);
};

@@ -173,0 +151,0 @@

@@ -9,2 +9,3 @@ 'use strict';

var isPropValid = _interopDefault(require('@emotion/is-prop-valid'));
var _objectAssign = _interopDefault(require('object-assign'));
var core = require('@emotion/core');

@@ -14,21 +15,4 @@ var utils = require('@emotion/utils');

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var testOmitPropsOnStringTag = isPropValid;
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -38,2 +22,11 @@ return key !== 'theme' && key !== 'innerRef';

var getDefaultShouldForwardProp = function getDefaultShouldForwardProp(tag) {
return typeof tag === 'string' && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
tag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
};
var isBrowser = typeof document !== 'undefined';
var createStyled = function createStyled(tag, options) {

@@ -61,40 +54,26 @@ if (process.env.NODE_ENV !== 'production') {

var baseTag = isReal && tag.__emotion_base || tag;
var isStringTag = typeof baseTag === 'string';
if (typeof shouldForwardProp !== 'function') {
shouldForwardProp = isStringTag && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
baseTag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
if (typeof shouldForwardProp !== 'function' && isReal) {
shouldForwardProp = tag.__emotion_forwardProp;
}
var defaultShouldForwardProp = shouldForwardProp || getDefaultShouldForwardProp(baseTag);
var shouldUseAs = !defaultShouldForwardProp('as');
return function () {
var args = arguments;
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : []; // idk if this is worth it.
// it's only for when autoLabel is on and styles are completely static
// and it's only a performance optimisation
// just committing this in case we want it later
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : [];
if (identifierName !== undefined && args.length === 1 && styles.length === 0 && args[0].styles !== undefined) {
styles.push({
name: args[0].name,
label: identifierName,
styles: args[0].styles,
map: args[0].map
});
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
styles.push(args[0][0]);
var len = args.length;
var i = 1;
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
styles.push(args[0][0]);
var len = args.length;
var i = 1;
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}

@@ -105,2 +84,3 @@ }

return React.createElement(core.ThemeContext.Consumer, null, function (theme) {
var finalTag = shouldUseAs && props.as || baseTag;
var className = '';

@@ -124,4 +104,4 @@ var classInterpolations = [];

var serialized = serialize.serializeStyles(context.registered, styles.concat(classInterpolations), mergedProps);
var rules = utils.insertStyles(context, serialized, isStringTag);
var serialized = serialize.serializeStyles(styles.concat(classInterpolations), context.registered, mergedProps);
var rules = utils.insertStyles(context, serialized, typeof finalTag === 'string');
className += context.key + "-" + serialized.name;

@@ -133,7 +113,10 @@

var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(finalTag) : defaultShouldForwardProp;
var newProps = {};
for (var _key in props) {
if (shouldUseAs && _key === 'as') continue;
if ( // $FlowFixMe
shouldForwardProp(_key)) {
finalShouldForwardProp(_key)) {
newProps[_key] = props[_key];

@@ -144,14 +127,11 @@ }

newProps.className = className;
newProps.ref = ref || props.innerRef;
{
newProps.ref = ref;
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is no longer allowed, please use the `ref` prop instead');
}
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is deprecated and will be removed in a future major version of Emotion, please use the `ref` prop instead' + (identifierName === undefined ? '' : " in the usage of `" + identifierName + "`"));
}
var ele = React.createElement(baseTag, newProps);
var ele = React.createElement(finalTag, newProps);
if (!utils.isBrowser && rules !== undefined) {
if (!isBrowser && rules !== undefined) {
var _ref;

@@ -193,3 +173,3 @@

Styled.withComponent = function (nextTag, nextOptions) {
return createStyled(nextTag, nextOptions !== undefined ? _extends({}, options || {}, nextOptions) : options).apply(void 0, styles);
return createStyled(nextTag, nextOptions !== undefined ? _objectAssign({}, options || {}, nextOptions) : options).apply(void 0, styles);
};

@@ -196,0 +176,0 @@

'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./styled-base.cjs.prod.js');
if (process.env.NODE_ENV === "production") {
module.exports = require("./styled-base.cjs.prod.js");
} else {
module.exports = require('./styled-base.cjs.dev.js');
module.exports = require("./styled-base.cjs.dev.js");
}

@@ -8,22 +8,16 @@ "use strict";

isPropValid = _interopDefault(require("@emotion/is-prop-valid")),
_objectAssign = _interopDefault(require("object-assign")),
core = require("@emotion/core"),
utils = require("@emotion/utils"),
serialize = require("@emotion/serialize");
function _extends() {
return (_extends =
Object.assign ||
function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source)
Object.prototype.hasOwnProperty.call(source, key) &&
(target[key] = source[key]);
}
return target;
}).apply(this, arguments);
}
var testOmitPropsOnStringTag = isPropValid,
serialize = require("@emotion/serialize"),
testOmitPropsOnStringTag = isPropValid,
testOmitPropsOnComponent = function(key) {
return "theme" !== key && "innerRef" !== key;
},
getDefaultShouldForwardProp = function(tag) {
return "string" == typeof tag && 96 < tag.charCodeAt(0)
? testOmitPropsOnStringTag
: testOmitPropsOnComponent;
},
isBrowser = "undefined" != typeof document,
createStyled = function createStyled(tag, options) {

@@ -44,129 +38,123 @@ var identifierName, shouldForwardProp, targetClassName;

var isReal = tag.__emotion_real === tag,
baseTag = (isReal && tag.__emotion_base) || tag,
isStringTag = "string" == typeof baseTag;
return (
"function" != typeof shouldForwardProp &&
(shouldForwardProp =
isStringTag && 96 < baseTag.charCodeAt(0)
? testOmitPropsOnStringTag
: testOmitPropsOnComponent),
function() {
var args = arguments,
styles =
isReal && void 0 !== tag.__emotion_styles
? tag.__emotion_styles.slice(0)
: [];
if (
void 0 !== identifierName &&
1 === args.length &&
0 === styles.length &&
void 0 !== args[0].styles
)
styles.push({
name: args[0].name,
label: identifierName,
styles: args[0].styles,
map: args[0].map
});
else if (
(void 0 !== identifierName &&
styles.push("label:" + identifierName + ";"),
null == args[0] || void 0 === args[0].raw)
)
styles.push.apply(styles, args);
else {
styles.push(args[0][0]);
for (var len = args.length, i = 1; i < len; i++)
styles.push(args[i], args[0][i]);
}
var Styled = core.withEmotionCache(function(props, context, ref) {
return React.createElement(core.ThemeContext.Consumer, null, function(
theme
) {
var className = "",
classInterpolations = [],
mergedProps = props;
if (null == props.theme) {
for (var key in ((mergedProps = {}), props))
mergedProps[key] = props[key];
mergedProps.theme = theme;
}
"string" == typeof props.className &&
(className += utils.getRegisteredStyles(
context.registered,
classInterpolations,
props.className
));
var serialized = serialize.serializeStyles(
context.registered,
styles.concat(classInterpolations),
mergedProps
baseTag = (isReal && tag.__emotion_base) || tag;
"function" != typeof shouldForwardProp &&
isReal &&
(shouldForwardProp = tag.__emotion_forwardProp);
var defaultShouldForwardProp =
shouldForwardProp || getDefaultShouldForwardProp(baseTag),
shouldUseAs = !defaultShouldForwardProp("as");
return function() {
var args = arguments,
styles =
isReal && void 0 !== tag.__emotion_styles
? tag.__emotion_styles.slice(0)
: [];
if (
(void 0 !== identifierName &&
styles.push("label:" + identifierName + ";"),
null == args[0] || void 0 === args[0].raw)
)
styles.push.apply(styles, args);
else {
styles.push(args[0][0]);
for (var len = args.length, i = 1; i < len; i++)
styles.push(args[i], args[0][i]);
}
var Styled = core.withEmotionCache(function(props, context, ref) {
return React.createElement(core.ThemeContext.Consumer, null, function(
theme
) {
var finalTag = (shouldUseAs && props.as) || baseTag,
className = "",
classInterpolations = [],
mergedProps = props;
if (null == props.theme) {
for (var key in ((mergedProps = {}), props))
mergedProps[key] = props[key];
mergedProps.theme = theme;
}
"string" == typeof props.className &&
(className += utils.getRegisteredStyles(
context.registered,
classInterpolations,
props.className
));
var serialized = serialize.serializeStyles(
styles.concat(classInterpolations),
context.registered,
mergedProps
),
rules = utils.insertStyles(
context,
serialized,
"string" == typeof finalTag
);
(className += context.key + "-" + serialized.name),
void 0 !== targetClassName && (className += " " + targetClassName);
var finalShouldForwardProp =
shouldUseAs && void 0 === shouldForwardProp
? getDefaultShouldForwardProp(finalTag)
: defaultShouldForwardProp,
newProps = {};
for (var _key in props)
(shouldUseAs && "as" === _key) ||
(finalShouldForwardProp(_key) && (newProps[_key] = props[_key]));
(newProps.className = className),
(newProps.ref = ref || props.innerRef);
var ele = React.createElement(finalTag, newProps);
if (!isBrowser && void 0 !== rules) {
for (
var _ref,
serializedNames = serialized.name,
next = serialized.next;
void 0 !== next;
)
(serializedNames += " " + next.name), (next = next.next);
return React.createElement(
React.Fragment,
null,
React.createElement(
"style",
(((_ref = {})["data-emotion-" + context.key] = serializedNames),
(_ref.dangerouslySetInnerHTML = { __html: rules }),
(_ref.nonce = context.sheet.nonce),
_ref)
),
rules = utils.insertStyles(context, serialized, isStringTag);
(className += context.key + "-" + serialized.name),
void 0 !== targetClassName &&
(className += " " + targetClassName);
var newProps = {};
for (var _key in props)
shouldForwardProp(_key) && (newProps[_key] = props[_key]);
(newProps.className = className), (newProps.ref = ref);
var ele = React.createElement(baseTag, newProps);
if (!utils.isBrowser && void 0 !== rules) {
for (
var _ref,
serializedNames = serialized.name,
next = serialized.next;
void 0 !== next;
)
(serializedNames += " " + next.name), (next = next.next);
return React.createElement(
React.Fragment,
null,
React.createElement(
"style",
(((_ref = {})[
"data-emotion-" + context.key
] = serializedNames),
(_ref.dangerouslySetInnerHTML = { __html: rules }),
(_ref.nonce = context.sheet.nonce),
_ref)
),
ele
);
}
return ele;
});
ele
);
}
return ele;
});
return (
(Styled.displayName =
void 0 !== identifierName
? identifierName
: "Styled(" +
("string" == typeof baseTag
? baseTag
: baseTag.displayName || baseTag.name || "Component") +
")"),
(Styled.defaultProps = tag.defaultProps),
((Styled.__emotion_real = Styled).__emotion_base = baseTag),
(Styled.__emotion_styles = styles),
(Styled.__emotion_forwardProp = shouldForwardProp),
Object.defineProperty(Styled, "toString", {
value: function() {
return "." + targetClassName;
}
}),
(Styled.withComponent = function(nextTag, nextOptions) {
return createStyled(
nextTag,
void 0 !== nextOptions
? _extends({}, options || {}, nextOptions)
: options
).apply(void 0, styles);
}),
Styled
);
}
);
});
return (
(Styled.displayName =
void 0 !== identifierName
? identifierName
: "Styled(" +
("string" == typeof baseTag
? baseTag
: baseTag.displayName || baseTag.name || "Component") +
")"),
(Styled.defaultProps = tag.defaultProps),
((Styled.__emotion_real = Styled).__emotion_base = baseTag),
(Styled.__emotion_styles = styles),
(Styled.__emotion_forwardProp = shouldForwardProp),
Object.defineProperty(Styled, "toString", {
value: function() {
return "." + targetClassName;
}
}),
(Styled.withComponent = function(nextTag, nextOptions) {
return createStyled(
nextTag,
void 0 !== nextOptions
? _objectAssign({}, options || {}, nextOptions)
: options
).apply(void 0, styles);
}),
Styled
);
};
};
exports.default = createStyled;
import { createElement, Fragment } from 'react';
import isPropValid from '@emotion/is-prop-valid';
import _objectAssign from 'object-assign';
import { withEmotionCache, ThemeContext } from '@emotion/core';
import { getRegisteredStyles, insertStyles, isBrowser } from '@emotion/utils';
import { getRegisteredStyles, insertStyles } from '@emotion/utils';
import { serializeStyles } from '@emotion/serialize';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var testOmitPropsOnStringTag = isPropValid;
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -30,2 +14,11 @@ return key !== 'theme' && key !== 'innerRef';

var getDefaultShouldForwardProp = function getDefaultShouldForwardProp(tag) {
return typeof tag === 'string' && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
tag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
};
var isBrowser = typeof document !== 'undefined';
var createStyled = function createStyled(tag, options) {

@@ -53,40 +46,26 @@ if (process.env.NODE_ENV !== 'production') {

var baseTag = isReal && tag.__emotion_base || tag;
var isStringTag = typeof baseTag === 'string';
if (typeof shouldForwardProp !== 'function') {
shouldForwardProp = isStringTag && // 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
baseTag.charCodeAt(0) > 96 ? testOmitPropsOnStringTag : testOmitPropsOnComponent;
if (typeof shouldForwardProp !== 'function' && isReal) {
shouldForwardProp = tag.__emotion_forwardProp;
}
var defaultShouldForwardProp = shouldForwardProp || getDefaultShouldForwardProp(baseTag);
var shouldUseAs = !defaultShouldForwardProp('as');
return function () {
var args = arguments;
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : []; // idk if this is worth it.
// it's only for when autoLabel is on and styles are completely static
// and it's only a performance optimisation
// just committing this in case we want it later
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : [];
if (identifierName !== undefined && args.length === 1 && styles.length === 0 && args[0].styles !== undefined) {
styles.push({
name: args[0].name,
label: identifierName,
styles: args[0].styles,
map: args[0].map
});
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
if (identifierName !== undefined) {
styles.push("label:" + identifierName + ";");
}
styles.push(args[0][0]);
var len = args.length;
var i = 1;
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args);
} else {
styles.push(args[0][0]);
var len = args.length;
var i = 1;
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}
for (; i < len; i++) {
styles.push(args[i], args[0][i]);
}

@@ -97,2 +76,3 @@ }

return createElement(ThemeContext.Consumer, null, function (theme) {
var finalTag = shouldUseAs && props.as || baseTag;
var className = '';

@@ -116,4 +96,4 @@ var classInterpolations = [];

var serialized = serializeStyles(context.registered, styles.concat(classInterpolations), mergedProps);
var rules = insertStyles(context, serialized, isStringTag);
var serialized = serializeStyles(styles.concat(classInterpolations), context.registered, mergedProps);
var rules = insertStyles(context, serialized, typeof finalTag === 'string');
className += context.key + "-" + serialized.name;

@@ -125,7 +105,10 @@

var finalShouldForwardProp = shouldUseAs && shouldForwardProp === undefined ? getDefaultShouldForwardProp(finalTag) : defaultShouldForwardProp;
var newProps = {};
for (var _key in props) {
if (shouldUseAs && _key === 'as') continue;
if ( // $FlowFixMe
shouldForwardProp(_key)) {
finalShouldForwardProp(_key)) {
newProps[_key] = props[_key];

@@ -136,12 +119,9 @@ }

newProps.className = className;
newProps.ref = ref || props.innerRef;
{
newProps.ref = ref;
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is no longer allowed, please use the `ref` prop instead');
}
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error('`innerRef` is deprecated and will be removed in a future major version of Emotion, please use the `ref` prop instead' + (identifierName === undefined ? '' : " in the usage of `" + identifierName + "`"));
}
var ele = createElement(baseTag, newProps);
var ele = createElement(finalTag, newProps);

@@ -185,3 +165,3 @@ if (!isBrowser && rules !== undefined) {

Styled.withComponent = function (nextTag, nextOptions) {
return createStyled(nextTag, nextOptions !== undefined ? _extends({}, options || {}, nextOptions) : options).apply(void 0, styles);
return createStyled(nextTag, nextOptions !== undefined ? _objectAssign({}, options || {}, nextOptions) : options).apply(void 0, styles);
};

@@ -188,0 +168,0 @@

{
"name": "@emotion/styled-base",
"version": "10.0.0-really-unsafe-please-do-not-use.2",
"version": "10.0.0",
"description": "base styled API for emotion",

@@ -11,11 +11,20 @@ "main": "dist/styled-base.cjs.js",

},
"types": "types/index.d.ts",
"license": "MIT",
"repository": "https://github.com/emotion-js/emotion/tree/master/next-packages/styled-base",
"repository": "https://github.com/emotion-js/emotion/tree/master/packages/styled-base",
"scripts": {
"test:typescript": "dtslint types"
},
"dependencies": {
"@emotion/is-prop-valid": "^10.0.0-really-unsafe-please-do-not-use.2",
"@emotion/serialize": "^10.0.0-really-unsafe-please-do-not-use.2",
"@emotion/utils": "^10.0.0-really-unsafe-please-do-not-use.2"
"@emotion/is-prop-valid": "0.7.2",
"@emotion/serialize": "0.11.0",
"@emotion/utils": "0.11.1",
"object-assign": "^4.1.1"
},
"devDependencies": {
"@types/react": "16.3.18",
"dtslint": "^0.3.0"
},
"peerDependencies": {
"@emotion/core": "0.x.x",
"@emotion/core": "^10.0.0",
"react": ">=16.3.0"

@@ -28,6 +37,9 @@ },

"src",
"dist"
"dist",
"types"
],
"umd:main": "./dist/index.min.js",
"gitHead": "0da0de50f6f2c19e46bca7662d1a954d48db1264"
"umd:main": "dist/styled-base.umd.min.js",
"preconstruct": {
"umdName": "emotionStyledBase"
}
}

@@ -5,4 +5,3 @@ // @flow

import {
testOmitPropsOnComponent,
testOmitPropsOnStringTag,
getDefaultShouldForwardProp,
type StyledOptions,

@@ -12,5 +11,7 @@ type CreateStyled

import { withEmotionCache, ThemeContext } from '@emotion/core'
import { getRegisteredStyles, insertStyles, isBrowser } from '@emotion/utils'
import { getRegisteredStyles, insertStyles } from '@emotion/utils'
import { serializeStyles } from '@emotion/serialize'
let isBrowser = typeof document !== 'undefined'
type StyledComponent = (

@@ -46,13 +47,9 @@ props: *

const baseTag = (isReal && tag.__emotion_base) || tag
let isStringTag = typeof baseTag === 'string'
if (typeof shouldForwardProp !== 'function') {
shouldForwardProp =
isStringTag &&
// 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
baseTag.charCodeAt(0) > 96
? testOmitPropsOnStringTag
: testOmitPropsOnComponent
if (typeof shouldForwardProp !== 'function' && isReal) {
shouldForwardProp = tag.__emotion_forwardProp
}
let defaultShouldForwardProp =
shouldForwardProp || getDefaultShouldForwardProp(baseTag)
const shouldUseAs = !defaultShouldForwardProp('as')

@@ -66,32 +63,14 @@ return function(): StyledComponent {

// idk if this is worth it.
// it's only for when autoLabel is on and styles are completely static
// and it's only a performance optimisation
// just committing this in case we want it later
if (
identifierName !== undefined &&
args.length === 1 &&
styles.length === 0 &&
args[0].styles !== undefined
) {
styles.push({
name: args[0].name,
label: identifierName,
styles: args[0].styles,
map: args[0].map
})
if (identifierName !== undefined) {
styles.push(`label:${identifierName};`)
}
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args)
} else {
if (identifierName !== undefined) {
styles.push(`label:${identifierName};`)
styles.push(args[0][0])
let len = args.length
let i = 1
for (; i < len; i++) {
styles.push(args[i], args[0][i])
}
if (args[0] == null || args[0].raw === undefined) {
styles.push.apply(styles, args)
} else {
styles.push(args[0][0])
let len = args.length
let i = 1
for (; i < len; i++) {
styles.push(args[i], args[0][i])
}
}
}

@@ -103,2 +82,4 @@

{theme => {
const finalTag = (shouldUseAs && props.as) || baseTag
let className = ''

@@ -123,7 +104,11 @@ let classInterpolations = []

const serialized = serializeStyles(
styles.concat(classInterpolations),
context.registered,
styles.concat(classInterpolations),
mergedProps
)
const rules = insertStyles(context, serialized, isStringTag)
const rules = insertStyles(
context,
serialized,
typeof finalTag === 'string'
)
className += `${context.key}-${serialized.name}`

@@ -133,8 +118,16 @@ if (targetClassName !== undefined) {

}
const finalShouldForwardProp =
shouldUseAs && shouldForwardProp === undefined
? getDefaultShouldForwardProp(finalTag)
: defaultShouldForwardProp
let newProps = {}
for (let key in props) {
if (shouldUseAs && key === 'as') continue
if (
// $FlowFixMe
shouldForwardProp(key)
finalShouldForwardProp(key)
) {

@@ -146,16 +139,14 @@ newProps[key] = props[key]

newProps.className = className
if (process.env.PREACT) {
if (props.innerRef != null) {
newProps.ref = props.innerRef
}
} else {
newProps.ref = ref
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error(
'`innerRef` is no longer allowed, please use the `ref` prop instead'
)
}
newProps.ref = ref || props.innerRef
if (process.env.NODE_ENV !== 'production' && props.innerRef) {
console.error(
'`innerRef` is deprecated and will be removed in a future major version of Emotion, please use the `ref` prop instead' +
(identifierName === undefined
? ''
: ` in the usage of \`${identifierName}\``)
)
}
const ele = React.createElement(baseTag, newProps)
const ele = React.createElement(finalTag, newProps)
if (!isBrowser && rules !== undefined) {

@@ -162,0 +153,0 @@ let serializedNames = serialized.name

@@ -7,6 +7,15 @@ // @flow

export const testOmitPropsOnStringTag: (key: string) => boolean = isPropValid
export const testOmitPropsOnComponent = (key: string) =>
const testOmitPropsOnStringTag = isPropValid
const testOmitPropsOnComponent = (key: string) =>
key !== 'theme' && key !== 'innerRef'
export const getDefaultShouldForwardProp = (tag: React.ElementType) =>
typeof tag === 'string' &&
// 96 is one less than the char code
// for "a" so this is checking that
// it's a lowercase character
tag.charCodeAt(0) > 96
? testOmitPropsOnStringTag
: testOmitPropsOnComponent
export type StyledOptions = {

@@ -13,0 +22,0 @@ label?: string,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc