styled-components 6.0.0-beta.2 → 6.0.0-beta.4
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 +1 -1
- package/dist/constructors/constructWithOptions.d.ts +21 -26
- package/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/dist/constructors/css.d.ts +4 -4
- package/dist/constructors/keyframes.d.ts +1 -1
- package/dist/constructors/styled.d.ts +176 -180
- package/dist/hoc/withTheme.d.ts +2 -2
- package/dist/models/GlobalStyle.d.ts +1 -1
- package/dist/models/InlineStyle.d.ts +1 -1
- package/dist/models/StyledComponent.d.ts +1 -1
- package/dist/models/StyledNativeComponent.d.ts +2 -2
- package/dist/native/index.d.ts +25 -29
- package/dist/styled-components.browser.cjs.js +52 -64
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +52 -64
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +52 -64
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +52 -64
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +52 -64
- 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/test/utils.d.ts +176 -180
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +56 -42
- package/dist/utils/determineTheme.d.ts +2 -2
- package/dist/utils/empties.d.ts +2 -2
- package/dist/utils/flatten.d.ts +3 -3
- package/dist/utils/interleave.d.ts +1 -1
- package/dist/utils/isStaticRules.d.ts +1 -1
- package/dist/utils/isStyledComponent.d.ts +1 -1
- package/dist/utils/joinStrings.d.ts +1 -1
- package/dist/utils/mixinDeep.d.ts +1 -2
- package/native/dist/base.d.ts +1 -1
- package/native/dist/constructors/constructWithOptions.d.ts +21 -26
- package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/native/dist/constructors/css.d.ts +4 -4
- package/native/dist/constructors/keyframes.d.ts +1 -1
- package/native/dist/constructors/styled.d.ts +176 -180
- package/native/dist/hoc/withTheme.d.ts +2 -2
- package/native/dist/models/GlobalStyle.d.ts +1 -1
- package/native/dist/models/InlineStyle.d.ts +1 -1
- package/native/dist/models/StyledComponent.d.ts +1 -1
- package/native/dist/models/StyledNativeComponent.d.ts +2 -2
- package/native/dist/native/index.d.ts +25 -29
- package/native/dist/styled-components.native.cjs.js +24 -37
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +24 -37
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/test/utils.d.ts +176 -180
- package/native/dist/types.d.ts +56 -42
- package/native/dist/utils/determineTheme.d.ts +2 -2
- package/native/dist/utils/empties.d.ts +2 -2
- package/native/dist/utils/flatten.d.ts +3 -3
- package/native/dist/utils/interleave.d.ts +1 -1
- package/native/dist/utils/isStaticRules.d.ts +1 -1
- package/native/dist/utils/isStyledComponent.d.ts +1 -1
- package/native/dist/utils/joinStrings.d.ts +1 -1
- package/native/dist/utils/mixinDeep.d.ts +1 -2
- package/package.json +3 -3
- package/test-utils/index.ts +10 -6
- 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,7 +8,7 @@ var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR
|
|
|
8
8
|
'data-styled';
|
|
9
9
|
var SC_ATTR_ACTIVE = 'active';
|
|
10
10
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
11
|
-
var SC_VERSION = "6.0.0-beta.
|
|
11
|
+
var SC_VERSION = "6.0.0-beta.4";
|
|
12
12
|
var SPLITTER = '/*!sc*/\n';
|
|
13
13
|
var IS_BROWSER = typeof undefined !== 'undefined' ;
|
|
14
14
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -437,8 +437,12 @@ function isStyledComponent(target) {
|
|
|
437
437
|
/**
|
|
438
438
|
* Convenience function for joining strings to form className chains
|
|
439
439
|
*/
|
|
440
|
-
function joinStrings(
|
|
441
|
-
|
|
440
|
+
function joinStrings() {
|
|
441
|
+
var args = [];
|
|
442
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
443
|
+
args[_i] = arguments[_i];
|
|
444
|
+
}
|
|
445
|
+
return args.filter(Boolean).join(' ');
|
|
442
446
|
}
|
|
443
447
|
|
|
444
448
|
function isPlainObject(x) {
|
|
@@ -477,7 +481,6 @@ function mixinRecursively(target, source, forceMerge) {
|
|
|
477
481
|
* Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
|
|
478
482
|
*/
|
|
479
483
|
function mixinDeep(target) {
|
|
480
|
-
if (target === void 0) { target = {}; }
|
|
481
484
|
var sources = [];
|
|
482
485
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
483
486
|
sources[_i - 1] = arguments[_i];
|
|
@@ -1130,8 +1133,8 @@ function addUnitIfNeeded(name, value) {
|
|
|
1130
1133
|
* inlined version of
|
|
1131
1134
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
1132
1135
|
*/
|
|
1133
|
-
var uppercaseCheck = /
|
|
1134
|
-
var uppercasePattern = /
|
|
1136
|
+
var uppercaseCheck = /[A-Z]/;
|
|
1137
|
+
var uppercasePattern = /[A-Z]/g;
|
|
1135
1138
|
var msPattern = /^ms-/;
|
|
1136
1139
|
var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
|
|
1137
1140
|
/**
|
|
@@ -1148,7 +1151,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
|
|
|
1148
1151
|
* is converted to `-ms-`.
|
|
1149
1152
|
*/
|
|
1150
1153
|
function hyphenateStyleName(string) {
|
|
1151
|
-
return uppercaseCheck.test(string)
|
|
1154
|
+
return uppercaseCheck.test(string) && !string.startsWith('--')
|
|
1152
1155
|
? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
|
|
1153
1156
|
: string;
|
|
1154
1157
|
}
|
|
@@ -1189,21 +1192,18 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
1189
1192
|
var ruleSet = [];
|
|
1190
1193
|
for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
|
|
1191
1194
|
result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
|
|
1192
|
-
if (result ===
|
|
1195
|
+
if (result.length === 0)
|
|
1193
1196
|
continue;
|
|
1194
|
-
|
|
1195
|
-
ruleSet.push.apply(ruleSet, result);
|
|
1196
|
-
else
|
|
1197
|
-
ruleSet.push(result);
|
|
1197
|
+
ruleSet.push.apply(ruleSet, result);
|
|
1198
1198
|
}
|
|
1199
1199
|
return ruleSet;
|
|
1200
1200
|
}
|
|
1201
1201
|
if (isFalsish(chunk)) {
|
|
1202
|
-
return
|
|
1202
|
+
return [];
|
|
1203
1203
|
}
|
|
1204
1204
|
/* Handle other components */
|
|
1205
1205
|
if (isStyledComponent(chunk)) {
|
|
1206
|
-
return ".".concat(chunk.styledComponentId);
|
|
1206
|
+
return [".".concat(chunk.styledComponentId)];
|
|
1207
1207
|
}
|
|
1208
1208
|
/* Either execute or defer the function */
|
|
1209
1209
|
if (isFunction(chunk)) {
|
|
@@ -1220,26 +1220,27 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
return flatten(result, executionContext, styleSheet, stylisInstance);
|
|
1222
1222
|
}
|
|
1223
|
-
else
|
|
1224
|
-
return chunk;
|
|
1223
|
+
else {
|
|
1224
|
+
return [chunk];
|
|
1225
|
+
}
|
|
1225
1226
|
}
|
|
1226
1227
|
if (chunk instanceof Keyframes) {
|
|
1227
1228
|
if (styleSheet) {
|
|
1228
1229
|
chunk.inject(styleSheet, stylisInstance);
|
|
1229
|
-
return chunk.getName(stylisInstance);
|
|
1230
|
+
return [chunk.getName(stylisInstance)];
|
|
1231
|
+
}
|
|
1232
|
+
else {
|
|
1233
|
+
return [chunk];
|
|
1230
1234
|
}
|
|
1231
|
-
else
|
|
1232
|
-
return chunk;
|
|
1233
1235
|
}
|
|
1234
1236
|
/* Handle objects */
|
|
1235
|
-
return isPlainObject(chunk) ? objToCssArray(chunk) : chunk.toString();
|
|
1237
|
+
return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
|
|
1236
1238
|
}
|
|
1237
1239
|
|
|
1238
1240
|
function isStaticRules(rules) {
|
|
1239
1241
|
for (var i = 0; i < rules.length; i += 1) {
|
|
1240
1242
|
var rule = rules[i];
|
|
1241
|
-
if (isFunction(rule) &&
|
|
1242
|
-
!isStyledComponent(rule)) {
|
|
1243
|
+
if (isFunction(rule) && !isStyledComponent(rule)) {
|
|
1243
1244
|
// functions are allowed to be static if they're just being
|
|
1244
1245
|
// used to get the classname of a nested styled component
|
|
1245
1246
|
return false;
|
|
@@ -1373,35 +1374,10 @@ function generateId(displayName, parentComponentId) {
|
|
|
1373
1374
|
SC_VERSION + name + identifiers[name]));
|
|
1374
1375
|
return parentComponentId ? "".concat(parentComponentId, "-").concat(componentId) : componentId;
|
|
1375
1376
|
}
|
|
1376
|
-
function useResolvedAttrs(theme, props, attrs) {
|
|
1377
|
-
if (theme === void 0) { theme = EMPTY_OBJECT; }
|
|
1378
|
-
// NOTE: can't memoize this
|
|
1379
|
-
// returns [context, resolvedAttrs]
|
|
1380
|
-
// where resolvedAttrs is only the things injected by the attrs themselves
|
|
1381
|
-
var context = __assign(__assign({}, props), { theme: theme });
|
|
1382
|
-
attrs.forEach(function (attrDef) {
|
|
1383
|
-
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1384
|
-
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1385
|
-
var key;
|
|
1386
|
-
/* eslint-disable guard-for-in */
|
|
1387
|
-
for (key in resolvedAttrDef) {
|
|
1388
|
-
// @ts-expect-error bad types
|
|
1389
|
-
context[key] =
|
|
1390
|
-
key === 'className'
|
|
1391
|
-
? joinStrings(context[key], resolvedAttrDef[key])
|
|
1392
|
-
: key === 'style'
|
|
1393
|
-
? __assign(__assign({}, context[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
|
|
1394
|
-
}
|
|
1395
|
-
/* eslint-enable guard-for-in */
|
|
1396
|
-
});
|
|
1397
|
-
return context;
|
|
1398
|
-
}
|
|
1399
1377
|
function useInjectedStyle(componentStyle, isStatic, resolvedAttrs, warnTooManyClasses) {
|
|
1400
1378
|
var styleSheet = useStyleSheet();
|
|
1401
1379
|
var stylis = useStylis();
|
|
1402
|
-
var className = isStatic
|
|
1403
|
-
? componentStyle.generateAndInjectStyles(EMPTY_OBJECT, styleSheet, stylis)
|
|
1404
|
-
: componentStyle.generateAndInjectStyles(resolvedAttrs, styleSheet, stylis);
|
|
1380
|
+
var className = componentStyle.generateAndInjectStyles(isStatic ? EMPTY_OBJECT : resolvedAttrs, styleSheet, stylis);
|
|
1405
1381
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1406
1382
|
if (process.env.NODE_ENV !== 'production')
|
|
1407
1383
|
useDebugValue(className);
|
|
@@ -1418,22 +1394,36 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef, isStati
|
|
|
1418
1394
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
1419
1395
|
// but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
|
|
1420
1396
|
// should be an immutable value, but behave for now.
|
|
1421
|
-
var theme = determineTheme(props, useContext(ThemeContext), defaultProps);
|
|
1422
|
-
var context =
|
|
1397
|
+
var theme = determineTheme(props, useContext(ThemeContext), defaultProps) || EMPTY_OBJECT;
|
|
1398
|
+
var context = componentAttrs.reduce(function (p, attrDef) {
|
|
1399
|
+
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(p) : attrDef;
|
|
1400
|
+
/* eslint-disable guard-for-in */
|
|
1401
|
+
for (var key in resolvedAttrDef) {
|
|
1402
|
+
// @ts-expect-error bad types
|
|
1403
|
+
p[key] =
|
|
1404
|
+
key === 'className'
|
|
1405
|
+
? joinStrings(p[key], resolvedAttrDef[key])
|
|
1406
|
+
: key === 'style'
|
|
1407
|
+
? __assign(__assign({}, p[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
|
|
1408
|
+
}
|
|
1409
|
+
/* eslint-enable guard-for-in */
|
|
1410
|
+
return p;
|
|
1411
|
+
}, __assign(__assign({}, props), { theme: theme }));
|
|
1423
1412
|
var generatedClassName = useInjectedStyle(componentStyle, isStatic, context, process.env.NODE_ENV !== 'production' ? forwardedComponent.warnTooManyClasses : undefined);
|
|
1424
1413
|
var refToForward = forwardedRef;
|
|
1425
|
-
var elementToBeCreated = context
|
|
1414
|
+
var elementToBeCreated = context.as || target;
|
|
1426
1415
|
var isTargetTag = isTag(elementToBeCreated);
|
|
1427
1416
|
var propsForElement = {};
|
|
1428
1417
|
// eslint-disable-next-line guard-for-in
|
|
1429
1418
|
for (var key in context) {
|
|
1430
|
-
|
|
1431
|
-
|
|
1419
|
+
// @ts-expect-error for..in iterates strings instead of keyof
|
|
1420
|
+
if (context[key] === undefined) ;
|
|
1421
|
+
else if (key[0] === '$' || key === 'as' || key === 'theme') ;
|
|
1432
1422
|
else if (key === 'forwardedAs') {
|
|
1433
|
-
propsForElement.as = context
|
|
1423
|
+
propsForElement.as = context.forwardedAs;
|
|
1434
1424
|
}
|
|
1435
|
-
else if (shouldForwardProp
|
|
1436
|
-
//
|
|
1425
|
+
else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
|
|
1426
|
+
// @ts-expect-error for..in iterates strings instead of keyof
|
|
1437
1427
|
propsForElement[key] = context[key];
|
|
1438
1428
|
}
|
|
1439
1429
|
}
|
|
@@ -1443,7 +1433,7 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef, isStati
|
|
|
1443
1433
|
domElements.indexOf(elementToBeCreated) === -1
|
|
1444
1434
|
? 'class'
|
|
1445
1435
|
: 'className'] = foldedComponentIds
|
|
1446
|
-
.concat(styledComponentId,
|
|
1436
|
+
.concat(styledComponentId, generatedClassName !== styledComponentId ? generatedClassName : '', context.className || '')
|
|
1447
1437
|
.filter(Boolean)
|
|
1448
1438
|
.join(' ');
|
|
1449
1439
|
propsForElement.ref = refToForward;
|
|
@@ -1459,7 +1449,9 @@ function createStyledComponent(target, options, rules) {
|
|
|
1459
1449
|
: options.componentId || componentId;
|
|
1460
1450
|
// fold the underlying StyledComponent attrs up (implicit extend)
|
|
1461
1451
|
var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
|
|
1462
|
-
? styledComponentTarget.attrs
|
|
1452
|
+
? styledComponentTarget.attrs
|
|
1453
|
+
.concat(attrs)
|
|
1454
|
+
.filter(Boolean)
|
|
1463
1455
|
: attrs;
|
|
1464
1456
|
var shouldForwardProp = options.shouldForwardProp;
|
|
1465
1457
|
if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
|
|
@@ -1554,11 +1546,7 @@ function interleave(strings, interpolations) {
|
|
|
1554
1546
|
* expand an array of styles.
|
|
1555
1547
|
*/
|
|
1556
1548
|
var addTag = function (arg) {
|
|
1557
|
-
|
|
1558
|
-
// eslint-disable-next-line no-param-reassign
|
|
1559
|
-
arg.isCss = true;
|
|
1560
|
-
}
|
|
1561
|
-
return arg;
|
|
1549
|
+
return Object.assign(arg, { isCss: true });
|
|
1562
1550
|
};
|
|
1563
1551
|
function css(styles) {
|
|
1564
1552
|
var interpolations = [];
|
|
@@ -1575,7 +1563,7 @@ function css(styles) {
|
|
|
1575
1563
|
if (interpolations.length === 0 &&
|
|
1576
1564
|
styleStringArray.length === 1 &&
|
|
1577
1565
|
typeof styleStringArray[0] === 'string') {
|
|
1578
|
-
return styleStringArray;
|
|
1566
|
+
return flatten(styleStringArray);
|
|
1579
1567
|
}
|
|
1580
1568
|
return addTag(flatten(interleave(styleStringArray, interpolations)));
|
|
1581
1569
|
}
|