styled-components 6.0.0-beta.6 → 6.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/models/StyleSheetManager.d.ts +38 -13
- package/dist/native/index.d.ts +1 -1
- package/dist/styled-components-macro.cjs.js +2 -7
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +36 -40
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +17 -16
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +35 -39
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +17 -16
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +32 -130
- package/dist/styled-components.js.map +1 -1
- package/dist/styled-components.min.js +1 -1
- package/dist/styled-components.min.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +0 -2
- package/dist/utils/stylis.d.ts +3 -3
- package/native/dist/base.d.ts +2 -2
- package/native/dist/index.d.ts +1 -1
- package/native/dist/models/StyleSheetManager.d.ts +38 -13
- package/native/dist/native/index.d.ts +1 -1
- package/native/dist/styled-components.native.cjs.js +24 -25
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +13 -9
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/types.d.ts +0 -2
- package/native/dist/utils/stylis.d.ts +3 -3
- package/package.json +31 -32
- package/native/dist/base.d.ts.map +0 -1
- package/native/dist/constants.d.ts.map +0 -1
- package/native/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/native/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/native/dist/constructors/css.d.ts.map +0 -1
- package/native/dist/constructors/keyframes.d.ts.map +0 -1
- package/native/dist/constructors/styled.d.ts.map +0 -1
- package/native/dist/dist/base.d.ts +0 -18
- package/native/dist/dist/base.d.ts.map +0 -1
- package/native/dist/dist/constants.d.ts +0 -9
- package/native/dist/dist/constants.d.ts.map +0 -1
- package/native/dist/dist/constructors/constructWithOptions.d.ts +0 -20
- package/native/dist/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/native/dist/dist/constructors/createGlobalStyle.d.ts +0 -4
- package/native/dist/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/native/dist/dist/constructors/css.d.ts +0 -5
- package/native/dist/dist/constructors/css.d.ts.map +0 -1
- package/native/dist/dist/constructors/keyframes.d.ts +0 -4
- package/native/dist/dist/constructors/keyframes.d.ts.map +0 -1
- package/native/dist/dist/constructors/styled.d.ts +0 -186
- package/native/dist/dist/constructors/styled.d.ts.map +0 -1
- package/native/dist/dist/hoc/withTheme.d.ts +0 -4
- package/native/dist/dist/hoc/withTheme.d.ts.map +0 -1
- package/native/dist/dist/hoc/withTheme.spec.d.ts +0 -2
- package/native/dist/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/native/dist/dist/hooks/useTheme.d.ts +0 -4
- package/native/dist/dist/hooks/useTheme.d.ts.map +0 -1
- package/native/dist/dist/index-standalone.d.ts +0 -3
- package/native/dist/dist/index-standalone.d.ts.map +0 -1
- package/native/dist/dist/index.d.ts +0 -4
- package/native/dist/dist/index.d.ts.map +0 -1
- package/native/dist/dist/macro/index.d.ts +0 -3
- package/native/dist/dist/macro/index.d.ts.map +0 -1
- package/native/dist/dist/macro/test/babel.config.d.ts +0 -1
- package/native/dist/dist/macro/test/babel.config.d.ts.map +0 -1
- package/native/dist/dist/models/ComponentStyle.d.ts +0 -16
- package/native/dist/dist/models/ComponentStyle.d.ts.map +0 -1
- package/native/dist/dist/models/GlobalStyle.d.ts +0 -12
- package/native/dist/dist/models/GlobalStyle.d.ts.map +0 -1
- package/native/dist/dist/models/InlineStyle.d.ts +0 -7
- package/native/dist/dist/models/InlineStyle.d.ts.map +0 -1
- package/native/dist/dist/models/Keyframes.d.ts +0 -12
- package/native/dist/dist/models/Keyframes.d.ts.map +0 -1
- package/native/dist/dist/models/ServerStyleSheet.d.ts +0 -16
- package/native/dist/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/native/dist/dist/models/StyleSheetManager.d.ts +0 -22
- package/native/dist/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/native/dist/dist/models/StyledComponent.d.ts +0 -4
- package/native/dist/dist/models/StyledComponent.d.ts.map +0 -1
- package/native/dist/dist/models/StyledNativeComponent.d.ts +0 -4
- package/native/dist/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/native/dist/dist/models/ThemeProvider.d.ts +0 -18
- package/native/dist/dist/models/ThemeProvider.d.ts.map +0 -1
- package/native/dist/dist/native/index.d.ts +0 -65
- package/native/dist/dist/native/index.d.ts.map +0 -1
- package/native/dist/dist/primitives/index.d.ts +0 -23
- package/native/dist/dist/primitives/index.d.ts.map +0 -1
- package/native/dist/dist/secretInternals.d.ts +0 -6
- package/native/dist/dist/secretInternals.d.ts.map +0 -1
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts +0 -5
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/native/dist/dist/sheet/GroupedTag.d.ts +0 -12
- package/native/dist/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/native/dist/dist/sheet/Rehydration.d.ts +0 -4
- package/native/dist/dist/sheet/Rehydration.d.ts.map +0 -1
- package/native/dist/dist/sheet/Sheet.d.ts +0 -41
- package/native/dist/dist/sheet/Sheet.d.ts.map +0 -1
- package/native/dist/dist/sheet/Tag.d.ts +0 -55
- package/native/dist/dist/sheet/Tag.d.ts.map +0 -1
- package/native/dist/dist/sheet/dom.d.ts +0 -5
- package/native/dist/dist/sheet/dom.d.ts.map +0 -1
- package/native/dist/dist/sheet/index.d.ts +0 -2
- package/native/dist/dist/sheet/index.d.ts.map +0 -1
- package/native/dist/dist/sheet/types.d.ts +0 -35
- package/native/dist/dist/sheet/types.d.ts.map +0 -1
- package/native/dist/dist/test/globals.d.ts +0 -3
- package/native/dist/dist/test/globals.d.ts.map +0 -1
- package/native/dist/dist/test/utils.d.ts +0 -192
- package/native/dist/dist/test/utils.d.ts.map +0 -1
- package/native/dist/dist/types.d.ts +0 -121
- package/native/dist/dist/types.d.ts.map +0 -1
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts +0 -2
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/native/dist/dist/utils/checkDynamicCreation.d.ts +0 -2
- package/native/dist/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -4
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/native/dist/dist/utils/determineTheme.d.ts +0 -3
- package/native/dist/dist/utils/determineTheme.d.ts.map +0 -1
- package/native/dist/dist/utils/domElements.d.ts +0 -3
- package/native/dist/dist/utils/domElements.d.ts.map +0 -1
- package/native/dist/dist/utils/empties.d.ts +0 -4
- package/native/dist/dist/utils/empties.d.ts.map +0 -1
- package/native/dist/dist/utils/error.d.ts +0 -6
- package/native/dist/dist/utils/error.d.ts.map +0 -1
- package/native/dist/dist/utils/errors.d.ts +0 -21
- package/native/dist/dist/utils/errors.d.ts.map +0 -1
- package/native/dist/dist/utils/escape.d.ts +0 -6
- package/native/dist/dist/utils/escape.d.ts.map +0 -1
- package/native/dist/dist/utils/flatten.d.ts +0 -5
- package/native/dist/dist/utils/flatten.d.ts.map +0 -1
- package/native/dist/dist/utils/generateAlphabeticName.d.ts +0 -2
- package/native/dist/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/native/dist/dist/utils/generateComponentId.d.ts +0 -2
- package/native/dist/dist/utils/generateComponentId.d.ts.map +0 -1
- package/native/dist/dist/utils/generateDisplayName.d.ts +0 -3
- package/native/dist/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/native/dist/dist/utils/getComponentName.d.ts +0 -3
- package/native/dist/dist/utils/getComponentName.d.ts.map +0 -1
- package/native/dist/dist/utils/hash.d.ts +0 -4
- package/native/dist/dist/utils/hash.d.ts.map +0 -1
- package/native/dist/dist/utils/hoist.d.ts +0 -52
- package/native/dist/dist/utils/hoist.d.ts.map +0 -1
- package/native/dist/dist/utils/hyphenateStyleName.d.ts +0 -15
- package/native/dist/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/native/dist/dist/utils/interleave.d.ts +0 -3
- package/native/dist/dist/utils/interleave.d.ts.map +0 -1
- package/native/dist/dist/utils/isFunction.d.ts +0 -2
- package/native/dist/dist/utils/isFunction.d.ts.map +0 -1
- package/native/dist/dist/utils/isPlainObject.d.ts +0 -2
- package/native/dist/dist/utils/isPlainObject.d.ts.map +0 -1
- package/native/dist/dist/utils/isStatelessFunction.d.ts +0 -2
- package/native/dist/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/native/dist/dist/utils/isStaticRules.d.ts +0 -3
- package/native/dist/dist/utils/isStaticRules.d.ts.map +0 -1
- package/native/dist/dist/utils/isStyledComponent.d.ts +0 -3
- package/native/dist/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/native/dist/dist/utils/isTag.d.ts +0 -3
- package/native/dist/dist/utils/isTag.d.ts.map +0 -1
- package/native/dist/dist/utils/joinStrings.d.ts +0 -5
- package/native/dist/dist/utils/joinStrings.d.ts.map +0 -1
- package/native/dist/dist/utils/mixinDeep.d.ts +0 -8
- package/native/dist/dist/utils/mixinDeep.d.ts.map +0 -1
- package/native/dist/dist/utils/nonce.d.ts +0 -2
- package/native/dist/dist/utils/nonce.d.ts.map +0 -1
- package/native/dist/dist/utils/stylis.d.ts +0 -10
- package/native/dist/dist/utils/stylis.d.ts.map +0 -1
- package/native/dist/hoc/withTheme.d.ts.map +0 -1
- package/native/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/native/dist/hooks/useTheme.d.ts.map +0 -1
- package/native/dist/index-standalone.d.ts.map +0 -1
- package/native/dist/index.d.ts.map +0 -1
- package/native/dist/macro/index.d.ts.map +0 -1
- package/native/dist/macro/test/babel.config.d.ts +0 -1
- package/native/dist/macro/test/babel.config.d.ts.map +0 -1
- package/native/dist/models/ComponentStyle.d.ts.map +0 -1
- package/native/dist/models/GlobalStyle.d.ts.map +0 -1
- package/native/dist/models/InlineStyle.d.ts.map +0 -1
- package/native/dist/models/Keyframes.d.ts.map +0 -1
- package/native/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/native/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/native/dist/models/StyledComponent.d.ts.map +0 -1
- package/native/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/native/dist/models/ThemeProvider.d.ts.map +0 -1
- package/native/dist/native/index.d.ts.map +0 -1
- package/native/dist/primitives/index.d.ts +0 -23
- package/native/dist/primitives/index.d.ts.map +0 -1
- package/native/dist/secretInternals.d.ts.map +0 -1
- package/native/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/native/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/native/dist/sheet/Rehydration.d.ts.map +0 -1
- package/native/dist/sheet/Sheet.d.ts.map +0 -1
- package/native/dist/sheet/Tag.d.ts.map +0 -1
- package/native/dist/sheet/dom.d.ts.map +0 -1
- package/native/dist/sheet/index.d.ts.map +0 -1
- package/native/dist/sheet/types.d.ts.map +0 -1
- package/native/dist/test/globals.d.ts.map +0 -1
- package/native/dist/test/utils.d.ts.map +0 -1
- package/native/dist/types.d.ts.map +0 -1
- package/native/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/native/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/native/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/native/dist/utils/determineTheme.d.ts.map +0 -1
- package/native/dist/utils/domElements.d.ts.map +0 -1
- package/native/dist/utils/empties.d.ts.map +0 -1
- package/native/dist/utils/error.d.ts.map +0 -1
- package/native/dist/utils/errors.d.ts.map +0 -1
- package/native/dist/utils/escape.d.ts.map +0 -1
- package/native/dist/utils/flatten.d.ts.map +0 -1
- package/native/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/native/dist/utils/generateComponentId.d.ts.map +0 -1
- package/native/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/native/dist/utils/getComponentName.d.ts.map +0 -1
- package/native/dist/utils/hash.d.ts.map +0 -1
- package/native/dist/utils/hoist.d.ts.map +0 -1
- package/native/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/native/dist/utils/interleave.d.ts.map +0 -1
- package/native/dist/utils/isFunction.d.ts.map +0 -1
- package/native/dist/utils/isPlainObject.d.ts.map +0 -1
- package/native/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/native/dist/utils/isStaticRules.d.ts.map +0 -1
- package/native/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/native/dist/utils/isTag.d.ts.map +0 -1
- package/native/dist/utils/joinStrings.d.ts.map +0 -1
- package/native/dist/utils/mixinDeep.d.ts.map +0 -1
- package/native/dist/utils/nonce.d.ts.map +0 -1
- package/native/dist/utils/stylis.d.ts.map +0 -1
|
@@ -8,17 +8,11 @@ var shallowequal = require('shallowequal');
|
|
|
8
8
|
var stylis = require('stylis');
|
|
9
9
|
var unitless = require('@emotion/unitless');
|
|
10
10
|
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
-
var shallowequal__default = /*#__PURE__*/_interopDefaultLegacy(shallowequal);
|
|
15
|
-
var unitless__default = /*#__PURE__*/_interopDefaultLegacy(unitless);
|
|
16
|
-
|
|
17
11
|
var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
18
12
|
'data-styled';
|
|
19
13
|
var SC_ATTR_ACTIVE = 'active';
|
|
20
14
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
21
|
-
var SC_VERSION = "6.0.0-beta.
|
|
15
|
+
var SC_VERSION = "6.0.0-beta.7";
|
|
22
16
|
var SPLITTER = '/*!sc*/\n';
|
|
23
17
|
var IS_BROWSER = typeof undefined !== 'undefined' ;
|
|
24
18
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -1026,7 +1020,11 @@ function createStylisInstance(_a) {
|
|
|
1026
1020
|
props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
|
|
1027
1021
|
}
|
|
1028
1022
|
};
|
|
1029
|
-
var stringifyRules = function (css, selector,
|
|
1023
|
+
var stringifyRules = function (css, selector,
|
|
1024
|
+
/**
|
|
1025
|
+
* This "prefix" referes to a _selector_ prefix.
|
|
1026
|
+
*/
|
|
1027
|
+
prefix, componentId) {
|
|
1030
1028
|
if (selector === void 0) { selector = ''; }
|
|
1031
1029
|
if (prefix === void 0) { prefix = ''; }
|
|
1032
1030
|
if (componentId === void 0) { componentId = '&'; }
|
|
@@ -1039,11 +1037,16 @@ function createStylisInstance(_a) {
|
|
|
1039
1037
|
_selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
|
|
1040
1038
|
_consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
|
|
1041
1039
|
var middlewares = plugins.slice();
|
|
1040
|
+
/**
|
|
1041
|
+
* Enables automatic vendor-prefixing for styles.
|
|
1042
|
+
*/
|
|
1042
1043
|
if (options.prefix || options.prefix === undefined) {
|
|
1043
1044
|
middlewares.unshift(stylis.prefixer);
|
|
1044
1045
|
}
|
|
1045
1046
|
middlewares.push(selfReferenceReplacementPlugin, stylis.stringify);
|
|
1046
|
-
return serialize(stylis.compile(
|
|
1047
|
+
return serialize(stylis.compile(options.namespace || prefix || selector
|
|
1048
|
+
? "".concat(options.namespace ? options.namespace + ' ' : '').concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }")
|
|
1049
|
+
: flatCSS), stylis.middleware(middlewares));
|
|
1047
1050
|
};
|
|
1048
1051
|
stringifyRules.hash = plugins.length
|
|
1049
1052
|
? plugins
|
|
@@ -1058,9 +1061,9 @@ function createStylisInstance(_a) {
|
|
|
1058
1061
|
return stringifyRules;
|
|
1059
1062
|
}
|
|
1060
1063
|
|
|
1061
|
-
var StyleSheetContext =
|
|
1064
|
+
var StyleSheetContext = React.createContext(undefined);
|
|
1062
1065
|
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1063
|
-
var StylisContext =
|
|
1066
|
+
var StylisContext = React.createContext(undefined);
|
|
1064
1067
|
StylisContext.Consumer;
|
|
1065
1068
|
var mainSheet = new StyleSheet();
|
|
1066
1069
|
var mainStylis = createStylisInstance();
|
|
@@ -1089,17 +1092,17 @@ function StyleSheetManager(props) {
|
|
|
1089
1092
|
}, [props.disableCSSOMInjection, props.sheet, props.target]);
|
|
1090
1093
|
var stylis = React.useMemo(function () {
|
|
1091
1094
|
return createStylisInstance({
|
|
1092
|
-
options: { prefix: !props.disableVendorPrefixes },
|
|
1095
|
+
options: { namespace: props.namespace, prefix: !props.disableVendorPrefixes },
|
|
1093
1096
|
plugins: plugins,
|
|
1094
1097
|
});
|
|
1095
|
-
}, [props.disableVendorPrefixes, plugins]);
|
|
1098
|
+
}, [props.disableVendorPrefixes, props.namespace, plugins]);
|
|
1096
1099
|
React.useEffect(function () {
|
|
1097
|
-
if (!
|
|
1100
|
+
if (!shallowequal(plugins, props.stylisPlugins))
|
|
1098
1101
|
setPlugins(props.stylisPlugins);
|
|
1099
1102
|
}, [props.stylisPlugins]);
|
|
1100
|
-
return (
|
|
1101
|
-
|
|
1102
|
-
?
|
|
1103
|
+
return (React.createElement(StyleSheetContext.Provider, { value: styleSheet },
|
|
1104
|
+
React.createElement(StylisContext.Provider, { value: stylis }, process.env.NODE_ENV !== 'production'
|
|
1105
|
+
? React.Children.only(props.children)
|
|
1103
1106
|
: props.children)));
|
|
1104
1107
|
}
|
|
1105
1108
|
|
|
@@ -1133,7 +1136,7 @@ function addUnitIfNeeded(name, value) {
|
|
|
1133
1136
|
if (value == null || typeof value === 'boolean' || value === '') {
|
|
1134
1137
|
return '';
|
|
1135
1138
|
}
|
|
1136
|
-
if (typeof value === 'number' && value !== 0 && !(name in
|
|
1139
|
+
if (typeof value === 'number' && value !== 0 && !(name in unitless)) {
|
|
1137
1140
|
return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
|
|
1138
1141
|
}
|
|
1139
1142
|
return String(value).trim();
|
|
@@ -1340,7 +1343,7 @@ var ComponentStyle = /** @class */ (function () {
|
|
|
1340
1343
|
return ComponentStyle;
|
|
1341
1344
|
}());
|
|
1342
1345
|
|
|
1343
|
-
var ThemeContext =
|
|
1346
|
+
var ThemeContext = React.createContext(undefined);
|
|
1344
1347
|
var ThemeConsumer = ThemeContext.Consumer;
|
|
1345
1348
|
function mergeTheme(theme, outerTheme) {
|
|
1346
1349
|
if (!theme) {
|
|
@@ -1369,7 +1372,7 @@ function ThemeProvider(props) {
|
|
|
1369
1372
|
if (!props.children) {
|
|
1370
1373
|
return null;
|
|
1371
1374
|
}
|
|
1372
|
-
return
|
|
1375
|
+
return React.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
|
|
1373
1376
|
}
|
|
1374
1377
|
|
|
1375
1378
|
var identifiers = {};
|
|
@@ -1491,7 +1494,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
1491
1494
|
* forwardRef creates a new interim component, which we'll take advantage of
|
|
1492
1495
|
* instead of extending ParentComponent to create _another_ interim class
|
|
1493
1496
|
*/
|
|
1494
|
-
var WrappedStyledComponent =
|
|
1497
|
+
var WrappedStyledComponent = React.forwardRef(forwardRef);
|
|
1495
1498
|
WrappedStyledComponent.attrs = finalAttrs;
|
|
1496
1499
|
WrappedStyledComponent.componentStyle = componentStyle;
|
|
1497
1500
|
WrappedStyledComponent.displayName = displayName;
|
|
@@ -1504,13 +1507,6 @@ function createStyledComponent(target, options, rules) {
|
|
|
1504
1507
|
WrappedStyledComponent.styledComponentId = styledComponentId;
|
|
1505
1508
|
// fold the underlying StyledComponent target up since we folded the styles
|
|
1506
1509
|
WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
|
|
1507
|
-
WrappedStyledComponent.withComponent = function withComponent(tag) {
|
|
1508
|
-
var previousComponentId = options.componentId, optionsToCopy = tslib.__rest(options, ["componentId"]);
|
|
1509
|
-
var newComponentId = previousComponentId &&
|
|
1510
|
-
"".concat(previousComponentId, "-").concat(isTag(tag) ? tag : escape(getComponentName(tag)));
|
|
1511
|
-
var newOptions = tslib.__assign(tslib.__assign({}, optionsToCopy), { attrs: finalAttrs, componentId: newComponentId });
|
|
1512
|
-
return createStyledComponent(tag, newOptions, rules);
|
|
1513
|
-
};
|
|
1514
1510
|
Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
|
|
1515
1511
|
get: function () {
|
|
1516
1512
|
return this._foldedDefaultProps;
|
|
@@ -1537,7 +1533,6 @@ function createStyledComponent(target, options, rules) {
|
|
|
1537
1533
|
shouldForwardProp: true,
|
|
1538
1534
|
styledComponentId: true,
|
|
1539
1535
|
target: true,
|
|
1540
|
-
withComponent: true,
|
|
1541
1536
|
});
|
|
1542
1537
|
}
|
|
1543
1538
|
return WrappedStyledComponent;
|
|
@@ -1660,10 +1655,10 @@ function createGlobalStyle(strings) {
|
|
|
1660
1655
|
var GlobalStyleComponent = function (props) {
|
|
1661
1656
|
var styleSheet = useStyleSheet();
|
|
1662
1657
|
var stylis = useStylis();
|
|
1663
|
-
var theme =
|
|
1664
|
-
var instanceRef =
|
|
1658
|
+
var theme = React.useContext(ThemeContext);
|
|
1659
|
+
var instanceRef = React.useRef(styleSheet.allocateGSInstance(styledComponentId));
|
|
1665
1660
|
var instance = instanceRef.current;
|
|
1666
|
-
if (process.env.NODE_ENV !== 'production' &&
|
|
1661
|
+
if (process.env.NODE_ENV !== 'production' && React.Children.count(props.children)) {
|
|
1667
1662
|
// eslint-disable-next-line no-console
|
|
1668
1663
|
console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
|
|
1669
1664
|
}
|
|
@@ -1686,7 +1681,7 @@ function createGlobalStyle(strings) {
|
|
|
1686
1681
|
globalStyle.renderStyles(instance, context, styleSheet, stylis);
|
|
1687
1682
|
}
|
|
1688
1683
|
}
|
|
1689
|
-
return
|
|
1684
|
+
return React.memo(GlobalStyleComponent);
|
|
1690
1685
|
}
|
|
1691
1686
|
|
|
1692
1687
|
function keyframes(strings) {
|
|
@@ -1707,14 +1702,14 @@ function keyframes(strings) {
|
|
|
1707
1702
|
}
|
|
1708
1703
|
|
|
1709
1704
|
function withTheme(Component) {
|
|
1710
|
-
var WithTheme =
|
|
1711
|
-
var theme =
|
|
1705
|
+
var WithTheme = React.forwardRef(function (props, ref) {
|
|
1706
|
+
var theme = React.useContext(ThemeContext);
|
|
1712
1707
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
1713
1708
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
1714
1709
|
// eslint-disable-next-line no-console
|
|
1715
1710
|
console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"".concat(getComponentName(Component), "\""));
|
|
1716
1711
|
}
|
|
1717
|
-
return
|
|
1712
|
+
return React.createElement(Component, tslib.__assign({}, props, { theme: themeProp, ref: ref }));
|
|
1718
1713
|
});
|
|
1719
1714
|
WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
|
|
1720
1715
|
return hoistNonReactStatics(WithTheme, Component);
|
|
@@ -1760,7 +1755,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1760
1755
|
props.nonce = nonce;
|
|
1761
1756
|
}
|
|
1762
1757
|
// v4 returned an array for this fn, so we'll do the same for v5 for backward compat
|
|
1763
|
-
return [
|
|
1758
|
+
return [React.createElement("style", tslib.__assign({}, props, { key: "sc-0-0" }))];
|
|
1764
1759
|
};
|
|
1765
1760
|
this.seal = function () {
|
|
1766
1761
|
_this.sealed = true;
|
|
@@ -1772,7 +1767,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1772
1767
|
if (this.sealed) {
|
|
1773
1768
|
throw throwStyledComponentsError(2);
|
|
1774
1769
|
}
|
|
1775
|
-
return
|
|
1770
|
+
return React.createElement(StyleSheetManager, { sheet: this.instance }, children);
|
|
1776
1771
|
};
|
|
1777
1772
|
// eslint-disable-next-line consistent-return
|
|
1778
1773
|
// @ts-expect-error alternate return types are not possible due to code transformation
|
|
@@ -1854,9 +1849,10 @@ exports.ThemeProvider = ThemeProvider;
|
|
|
1854
1849
|
exports.__PRIVATE__ = __PRIVATE__;
|
|
1855
1850
|
exports.createGlobalStyle = createGlobalStyle;
|
|
1856
1851
|
exports.css = css;
|
|
1857
|
-
exports
|
|
1852
|
+
exports.default = styled;
|
|
1858
1853
|
exports.isStyledComponent = isStyledComponent;
|
|
1859
1854
|
exports.keyframes = keyframes;
|
|
1855
|
+
exports.styled = styled;
|
|
1860
1856
|
exports.useTheme = useTheme;
|
|
1861
1857
|
exports.version = SC_VERSION;
|
|
1862
1858
|
exports.withTheme = withTheme;
|