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-beta.12 to 10.0.0-beta.13

dist/styled-base.umd.min.js

30

dist/styled-base.browser.cjs.js

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

var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -20,2 +21,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) {

@@ -43,11 +51,9 @@ 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 () {

@@ -75,2 +81,3 @@ var args = arguments;

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

@@ -94,4 +101,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;

@@ -103,7 +110,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];

@@ -120,3 +130,3 @@ }

var ele = React.createElement(baseTag, newProps);
var ele = React.createElement(finalTag, newProps);

@@ -123,0 +133,0 @@ return ele;

@@ -9,2 +9,3 @@ import { createElement } from 'react';

var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -14,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) {

@@ -37,11 +45,9 @@ 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 () {

@@ -69,2 +75,3 @@ var args = arguments;

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

@@ -88,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;

@@ -97,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];

@@ -114,3 +124,3 @@ }

var ele = createElement(baseTag, newProps);
var ele = createElement(finalTag, newProps);

@@ -117,0 +127,0 @@ return ele;

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

var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -20,2 +21,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 isBrowser = typeof document !== 'undefined';

@@ -45,11 +53,9 @@

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 () {

@@ -77,2 +83,3 @@ var args = arguments;

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

@@ -96,4 +103,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;

@@ -105,7 +112,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];

@@ -122,3 +132,3 @@ }

var ele = React.createElement(baseTag, newProps);
var ele = React.createElement(finalTag, newProps);

@@ -125,0 +135,0 @@ if (!isBrowser && rules !== undefined) {

'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");
}

@@ -16,2 +16,7 @@ "use strict";

},
getDefaultShouldForwardProp = function(tag) {
return "string" == typeof tag && 96 < tag.charCodeAt(0)
? testOmitPropsOnStringTag
: testOmitPropsOnComponent;
},
isBrowser = "undefined" != typeof document,

@@ -33,118 +38,123 @@ createStyled = function createStyled(tag, options) {

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 &&
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 || props.innerRef);
var ele = React.createElement(baseTag, 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)
),
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
? _objectAssign({}, 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;

@@ -9,2 +9,3 @@ import { createElement, Fragment } from 'react';

var testOmitPropsOnStringTag = isPropValid;
var testOmitPropsOnComponent = function testOmitPropsOnComponent(key) {

@@ -14,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 isBrowser = typeof document !== 'undefined';

@@ -39,11 +47,9 @@

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 () {

@@ -71,2 +77,3 @@ var args = arguments;

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

@@ -90,4 +97,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;

@@ -99,7 +106,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];

@@ -116,3 +126,3 @@ }

var ele = createElement(baseTag, newProps);
var ele = createElement(finalTag, newProps);

@@ -119,0 +129,0 @@ if (!isBrowser && rules !== undefined) {

{
"name": "@emotion/styled-base",
"version": "10.0.0-beta.12",
"version": "10.0.0-beta.13",
"description": "base styled API for emotion",

@@ -18,5 +18,5 @@ "main": "dist/styled-base.cjs.js",

"dependencies": {
"@emotion/is-prop-valid": "^0.7.0",
"@emotion/serialize": "0.10.6",
"@emotion/utils": "^0.11.0",
"@emotion/is-prop-valid": "0.7.1",
"@emotion/serialize": "0.11.0",
"@emotion/utils": "0.11.1",
"object-assign": "^4.1.1"

@@ -40,3 +40,6 @@ },

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

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

import {
testOmitPropsOnComponent,
testOmitPropsOnStringTag,
getDefaultShouldForwardProp,
type StyledOptions,

@@ -47,13 +46,9 @@ type CreateStyled

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')

@@ -85,2 +80,4 @@ return function(): StyledComponent {

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

@@ -105,7 +102,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}`

@@ -115,8 +116,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)
) {

@@ -139,3 +148,3 @@ newProps[key] = props[key]

const ele = React.createElement(baseTag, newProps)
const ele = React.createElement(finalTag, newProps)
if (!isBrowser && rules !== undefined) {

@@ -142,0 +151,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