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
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
'data-styled';
|
|
13
13
|
var SC_ATTR_ACTIVE = 'active';
|
|
14
14
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
15
|
-
var SC_VERSION = "6.0.0-beta.
|
|
15
|
+
var SC_VERSION = "6.0.0-beta.4";
|
|
16
16
|
var SPLITTER = '/*!sc*/\n';
|
|
17
17
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
18
18
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -924,8 +924,8 @@
|
|
|
924
924
|
* inlined version of
|
|
925
925
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
926
926
|
*/
|
|
927
|
-
var uppercaseCheck = /
|
|
928
|
-
var uppercasePattern = /
|
|
927
|
+
var uppercaseCheck = /[A-Z]/;
|
|
928
|
+
var uppercasePattern = /[A-Z]/g;
|
|
929
929
|
var msPattern = /^ms-/;
|
|
930
930
|
var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
|
|
931
931
|
/**
|
|
@@ -942,7 +942,7 @@
|
|
|
942
942
|
* is converted to `-ms-`.
|
|
943
943
|
*/
|
|
944
944
|
function hyphenateStyleName(string) {
|
|
945
|
-
return uppercaseCheck.test(string)
|
|
945
|
+
return uppercaseCheck.test(string) && !string.startsWith('--')
|
|
946
946
|
? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
|
|
947
947
|
: string;
|
|
948
948
|
}
|
|
@@ -998,21 +998,18 @@
|
|
|
998
998
|
var ruleSet = [];
|
|
999
999
|
for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
|
|
1000
1000
|
result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
|
|
1001
|
-
if (result ===
|
|
1001
|
+
if (result.length === 0)
|
|
1002
1002
|
continue;
|
|
1003
|
-
|
|
1004
|
-
ruleSet.push.apply(ruleSet, result);
|
|
1005
|
-
else
|
|
1006
|
-
ruleSet.push(result);
|
|
1003
|
+
ruleSet.push.apply(ruleSet, result);
|
|
1007
1004
|
}
|
|
1008
1005
|
return ruleSet;
|
|
1009
1006
|
}
|
|
1010
1007
|
if (isFalsish(chunk)) {
|
|
1011
|
-
return
|
|
1008
|
+
return [];
|
|
1012
1009
|
}
|
|
1013
1010
|
/* Handle other components */
|
|
1014
1011
|
if (isStyledComponent(chunk)) {
|
|
1015
|
-
return ".".concat(chunk.styledComponentId);
|
|
1012
|
+
return [".".concat(chunk.styledComponentId)];
|
|
1016
1013
|
}
|
|
1017
1014
|
/* Either execute or defer the function */
|
|
1018
1015
|
if (isFunction(chunk)) {
|
|
@@ -1028,26 +1025,27 @@
|
|
|
1028
1025
|
}
|
|
1029
1026
|
return flatten(result, executionContext, styleSheet, stylisInstance);
|
|
1030
1027
|
}
|
|
1031
|
-
else
|
|
1032
|
-
return chunk;
|
|
1028
|
+
else {
|
|
1029
|
+
return [chunk];
|
|
1030
|
+
}
|
|
1033
1031
|
}
|
|
1034
1032
|
if (chunk instanceof Keyframes) {
|
|
1035
1033
|
if (styleSheet) {
|
|
1036
1034
|
chunk.inject(styleSheet, stylisInstance);
|
|
1037
|
-
return chunk.getName(stylisInstance);
|
|
1035
|
+
return [chunk.getName(stylisInstance)];
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
return [chunk];
|
|
1038
1039
|
}
|
|
1039
|
-
else
|
|
1040
|
-
return chunk;
|
|
1041
1040
|
}
|
|
1042
1041
|
/* Handle objects */
|
|
1043
|
-
return isPlainObject(chunk) ? objToCssArray(chunk) : chunk.toString();
|
|
1042
|
+
return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
|
|
1044
1043
|
}
|
|
1045
1044
|
|
|
1046
1045
|
function isStaticRules(rules) {
|
|
1047
1046
|
for (var i = 0; i < rules.length; i += 1) {
|
|
1048
1047
|
var rule = rules[i];
|
|
1049
|
-
if (isFunction(rule) &&
|
|
1050
|
-
!isStyledComponent(rule)) {
|
|
1048
|
+
if (isFunction(rule) && !isStyledComponent(rule)) {
|
|
1051
1049
|
// functions are allowed to be static if they're just being
|
|
1052
1050
|
// used to get the classname of a nested styled component
|
|
1053
1051
|
return false;
|
|
@@ -1209,11 +1207,7 @@
|
|
|
1209
1207
|
* expand an array of styles.
|
|
1210
1208
|
*/
|
|
1211
1209
|
var addTag = function (arg) {
|
|
1212
|
-
|
|
1213
|
-
// eslint-disable-next-line no-param-reassign
|
|
1214
|
-
arg.isCss = true;
|
|
1215
|
-
}
|
|
1216
|
-
return arg;
|
|
1210
|
+
return Object.assign(arg, { isCss: true });
|
|
1217
1211
|
};
|
|
1218
1212
|
function css(styles) {
|
|
1219
1213
|
var interpolations = [];
|
|
@@ -1230,7 +1224,7 @@
|
|
|
1230
1224
|
if (interpolations.length === 0 &&
|
|
1231
1225
|
styleStringArray.length === 1 &&
|
|
1232
1226
|
typeof styleStringArray[0] === 'string') {
|
|
1233
|
-
return styleStringArray;
|
|
1227
|
+
return flatten(styleStringArray);
|
|
1234
1228
|
}
|
|
1235
1229
|
return addTag(flatten(interleave(styleStringArray, interpolations)));
|
|
1236
1230
|
}
|
|
@@ -1724,8 +1718,12 @@
|
|
|
1724
1718
|
/**
|
|
1725
1719
|
* Convenience function for joining strings to form className chains
|
|
1726
1720
|
*/
|
|
1727
|
-
function joinStrings(
|
|
1728
|
-
|
|
1721
|
+
function joinStrings() {
|
|
1722
|
+
var args = [];
|
|
1723
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1724
|
+
args[_i] = arguments[_i];
|
|
1725
|
+
}
|
|
1726
|
+
return args.filter(Boolean).join(' ');
|
|
1729
1727
|
}
|
|
1730
1728
|
|
|
1731
1729
|
function mixinRecursively(target, source, forceMerge) {
|
|
@@ -1753,7 +1751,6 @@
|
|
|
1753
1751
|
* Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
|
|
1754
1752
|
*/
|
|
1755
1753
|
function mixinDeep(target) {
|
|
1756
|
-
if (target === void 0) { target = {}; }
|
|
1757
1754
|
var sources = [];
|
|
1758
1755
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1759
1756
|
sources[_i - 1] = arguments[_i];
|
|
@@ -1855,35 +1852,10 @@
|
|
|
1855
1852
|
SC_VERSION + name + identifiers[name]));
|
|
1856
1853
|
return parentComponentId ? "".concat(parentComponentId, "-").concat(componentId) : componentId;
|
|
1857
1854
|
}
|
|
1858
|
-
function useResolvedAttrs(theme, props, attrs) {
|
|
1859
|
-
if (theme === void 0) { theme = EMPTY_OBJECT; }
|
|
1860
|
-
// NOTE: can't memoize this
|
|
1861
|
-
// returns [context, resolvedAttrs]
|
|
1862
|
-
// where resolvedAttrs is only the things injected by the attrs themselves
|
|
1863
|
-
var context = __assign(__assign({}, props), { theme: theme });
|
|
1864
|
-
attrs.forEach(function (attrDef) {
|
|
1865
|
-
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1866
|
-
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1867
|
-
var key;
|
|
1868
|
-
/* eslint-disable guard-for-in */
|
|
1869
|
-
for (key in resolvedAttrDef) {
|
|
1870
|
-
// @ts-expect-error bad types
|
|
1871
|
-
context[key] =
|
|
1872
|
-
key === 'className'
|
|
1873
|
-
? joinStrings(context[key], resolvedAttrDef[key])
|
|
1874
|
-
: key === 'style'
|
|
1875
|
-
? __assign(__assign({}, context[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
|
|
1876
|
-
}
|
|
1877
|
-
/* eslint-enable guard-for-in */
|
|
1878
|
-
});
|
|
1879
|
-
return context;
|
|
1880
|
-
}
|
|
1881
1855
|
function useInjectedStyle(componentStyle, isStatic, resolvedAttrs, warnTooManyClasses) {
|
|
1882
1856
|
var styleSheet = useStyleSheet();
|
|
1883
1857
|
var stylis = useStylis();
|
|
1884
|
-
var className = isStatic
|
|
1885
|
-
? componentStyle.generateAndInjectStyles(EMPTY_OBJECT, styleSheet, stylis)
|
|
1886
|
-
: componentStyle.generateAndInjectStyles(resolvedAttrs, styleSheet, stylis);
|
|
1858
|
+
var className = componentStyle.generateAndInjectStyles(isStatic ? EMPTY_OBJECT : resolvedAttrs, styleSheet, stylis);
|
|
1887
1859
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1888
1860
|
React.useDebugValue(className);
|
|
1889
1861
|
if (!isStatic && warnTooManyClasses) {
|
|
@@ -1898,22 +1870,36 @@
|
|
|
1898
1870
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
1899
1871
|
// but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
|
|
1900
1872
|
// should be an immutable value, but behave for now.
|
|
1901
|
-
var theme = determineTheme(props, React.useContext(ThemeContext), defaultProps);
|
|
1902
|
-
var context =
|
|
1873
|
+
var theme = determineTheme(props, React.useContext(ThemeContext), defaultProps) || EMPTY_OBJECT;
|
|
1874
|
+
var context = componentAttrs.reduce(function (p, attrDef) {
|
|
1875
|
+
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(p) : attrDef;
|
|
1876
|
+
/* eslint-disable guard-for-in */
|
|
1877
|
+
for (var key in resolvedAttrDef) {
|
|
1878
|
+
// @ts-expect-error bad types
|
|
1879
|
+
p[key] =
|
|
1880
|
+
key === 'className'
|
|
1881
|
+
? joinStrings(p[key], resolvedAttrDef[key])
|
|
1882
|
+
: key === 'style'
|
|
1883
|
+
? __assign(__assign({}, p[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
|
|
1884
|
+
}
|
|
1885
|
+
/* eslint-enable guard-for-in */
|
|
1886
|
+
return p;
|
|
1887
|
+
}, __assign(__assign({}, props), { theme: theme }));
|
|
1903
1888
|
var generatedClassName = useInjectedStyle(componentStyle, isStatic, context, forwardedComponent.warnTooManyClasses );
|
|
1904
1889
|
var refToForward = forwardedRef;
|
|
1905
|
-
var elementToBeCreated = context
|
|
1890
|
+
var elementToBeCreated = context.as || target;
|
|
1906
1891
|
var isTargetTag = isTag(elementToBeCreated);
|
|
1907
1892
|
var propsForElement = {};
|
|
1908
1893
|
// eslint-disable-next-line guard-for-in
|
|
1909
1894
|
for (var key in context) {
|
|
1910
|
-
|
|
1911
|
-
|
|
1895
|
+
// @ts-expect-error for..in iterates strings instead of keyof
|
|
1896
|
+
if (context[key] === undefined) ;
|
|
1897
|
+
else if (key[0] === '$' || key === 'as' || key === 'theme') ;
|
|
1912
1898
|
else if (key === 'forwardedAs') {
|
|
1913
|
-
propsForElement.as = context
|
|
1899
|
+
propsForElement.as = context.forwardedAs;
|
|
1914
1900
|
}
|
|
1915
|
-
else if (shouldForwardProp
|
|
1916
|
-
//
|
|
1901
|
+
else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
|
|
1902
|
+
// @ts-expect-error for..in iterates strings instead of keyof
|
|
1917
1903
|
propsForElement[key] = context[key];
|
|
1918
1904
|
}
|
|
1919
1905
|
}
|
|
@@ -1923,7 +1909,7 @@
|
|
|
1923
1909
|
domElements.indexOf(elementToBeCreated) === -1
|
|
1924
1910
|
? 'class'
|
|
1925
1911
|
: 'className'] = foldedComponentIds
|
|
1926
|
-
.concat(styledComponentId,
|
|
1912
|
+
.concat(styledComponentId, generatedClassName !== styledComponentId ? generatedClassName : '', context.className || '')
|
|
1927
1913
|
.filter(Boolean)
|
|
1928
1914
|
.join(' ');
|
|
1929
1915
|
propsForElement.ref = refToForward;
|
|
@@ -1939,7 +1925,9 @@
|
|
|
1939
1925
|
: options.componentId || componentId;
|
|
1940
1926
|
// fold the underlying StyledComponent attrs up (implicit extend)
|
|
1941
1927
|
var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
|
|
1942
|
-
? styledComponentTarget.attrs
|
|
1928
|
+
? styledComponentTarget.attrs
|
|
1929
|
+
.concat(attrs)
|
|
1930
|
+
.filter(Boolean)
|
|
1943
1931
|
: attrs;
|
|
1944
1932
|
var shouldForwardProp = options.shouldForwardProp;
|
|
1945
1933
|
if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
|