styled-components 6.0.0-beta.1 → 6.0.0-beta.3
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/constructors/constructWithOptions.d.ts +26 -30
- package/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/dist/constructors/css.d.ts +2 -2
- package/dist/constructors/keyframes.d.ts +1 -1
- package/dist/constructors/styled.d.ts +177 -181
- 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 +27 -31
- package/dist/styled-components-macro.cjs.js +47 -1
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components-macro.esm.js +38 -1
- package/dist/styled-components-macro.esm.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +1848 -1
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +1823 -1
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +1868 -1
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +1843 -1
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +2068 -1
- 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 +63 -68
- 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/generateDisplayName.d.ts +1 -1
- package/dist/utils/getComponentName.d.ts +1 -1
- 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/isTag.d.ts +1 -1
- package/dist/utils/mixinDeep.d.ts +2 -2
- package/native/dist/constructors/constructWithOptions.d.ts +26 -30
- package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/native/dist/constructors/css.d.ts +2 -2
- package/native/dist/constructors/keyframes.d.ts +1 -1
- package/native/dist/constructors/styled.d.ts +177 -181
- 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 +27 -31
- package/native/dist/styled-components.native.cjs.js +15 -26
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +15 -26
- 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 +63 -68
- 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/generateDisplayName.d.ts +1 -1
- package/native/dist/utils/getComponentName.d.ts +1 -1
- 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/isTag.d.ts +1 -1
- package/native/dist/utils/mixinDeep.d.ts +2 -2
- package/package.json +2 -3
|
@@ -69,7 +69,7 @@ var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR
|
|
|
69
69
|
'data-styled';
|
|
70
70
|
var SC_ATTR_ACTIVE = 'active';
|
|
71
71
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
72
|
-
var SC_VERSION = "6.0.0-beta.
|
|
72
|
+
var SC_VERSION = "6.0.0-beta.3";
|
|
73
73
|
var SPLITTER = '/*!sc*/\n';
|
|
74
74
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
75
75
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -658,8 +658,8 @@ function getComponentName(target) {
|
|
|
658
658
|
* inlined version of
|
|
659
659
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
660
660
|
*/
|
|
661
|
-
var uppercaseCheck = /
|
|
662
|
-
var uppercasePattern = /
|
|
661
|
+
var uppercaseCheck = /[A-Z]/;
|
|
662
|
+
var uppercasePattern = /[A-Z]/g;
|
|
663
663
|
var msPattern = /^ms-/;
|
|
664
664
|
var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
|
|
665
665
|
/**
|
|
@@ -676,7 +676,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
|
|
|
676
676
|
* is converted to `-ms-`.
|
|
677
677
|
*/
|
|
678
678
|
function hyphenateStyleName(string) {
|
|
679
|
-
return uppercaseCheck.test(string)
|
|
679
|
+
return uppercaseCheck.test(string) && !string.startsWith('--')
|
|
680
680
|
? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
|
|
681
681
|
: string;
|
|
682
682
|
}
|
|
@@ -759,9 +759,7 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
759
759
|
!(result instanceof Keyframes) &&
|
|
760
760
|
!isPlainObject(result)) {
|
|
761
761
|
// eslint-disable-next-line no-console
|
|
762
|
-
console.error("".concat(getComponentName(
|
|
763
|
-
// @ts-expect-error handling unexpected input
|
|
764
|
-
chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
|
|
762
|
+
console.error("".concat(getComponentName(chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
|
|
765
763
|
}
|
|
766
764
|
return flatten(result, executionContext, styleSheet, stylisInstance);
|
|
767
765
|
}
|
|
@@ -1121,7 +1119,6 @@ function useResolvedAttrs(theme, props, attrs) {
|
|
|
1121
1119
|
var context = __assign(__assign({}, props), { theme: theme });
|
|
1122
1120
|
var resolvedAttrs = {};
|
|
1123
1121
|
attrs.forEach(function (attrDef) {
|
|
1124
|
-
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1125
1122
|
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1126
1123
|
var key;
|
|
1127
1124
|
/* eslint-disable guard-for-in */
|
|
@@ -1133,8 +1130,6 @@ function useResolvedAttrs(theme, props, attrs) {
|
|
|
1133
1130
|
});
|
|
1134
1131
|
return [context, resolvedAttrs];
|
|
1135
1132
|
}
|
|
1136
|
-
// Validator defaults to true if not in HTML/DOM env
|
|
1137
|
-
var validAttr = function () { return true; };
|
|
1138
1133
|
function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
1139
1134
|
var componentAttrs = forwardedComponent.attrs, inlineStyle = forwardedComponent.inlineStyle, defaultProps = forwardedComponent.defaultProps, shouldForwardProp = forwardedComponent.shouldForwardProp, target = forwardedComponent.target;
|
|
1140
1135
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
@@ -1144,7 +1139,7 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1144
1139
|
var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
|
|
1145
1140
|
var generatedStyles = inlineStyle.generateStyleObject(context);
|
|
1146
1141
|
var refToForward = forwardedRef;
|
|
1147
|
-
var elementToBeCreated = attrs
|
|
1142
|
+
var elementToBeCreated = attrs.as || props.as || target;
|
|
1148
1143
|
var computedProps = attrs !== props ? __assign(__assign({}, props), attrs) : props;
|
|
1149
1144
|
var propsForElement = {};
|
|
1150
1145
|
// eslint-disable-next-line guard-for-in
|
|
@@ -1154,22 +1149,16 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1154
1149
|
else if (key === 'forwardedAs') {
|
|
1155
1150
|
propsForElement.as = computedProps[key];
|
|
1156
1151
|
}
|
|
1157
|
-
else if (!shouldForwardProp || shouldForwardProp(key,
|
|
1152
|
+
else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
|
|
1158
1153
|
propsForElement[key] = computedProps[key];
|
|
1159
1154
|
}
|
|
1160
1155
|
}
|
|
1161
1156
|
propsForElement.style = useMemo(function () {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
else if (props.style == null) {
|
|
1168
|
-
return generatedStyles;
|
|
1169
|
-
}
|
|
1170
|
-
else {
|
|
1171
|
-
return [generatedStyles].concat(props.style || []);
|
|
1172
|
-
}
|
|
1157
|
+
return typeof props.style === 'function'
|
|
1158
|
+
? function (state) { return [generatedStyles].concat(props.style(state)); }
|
|
1159
|
+
: props.style
|
|
1160
|
+
? [generatedStyles].concat(props.style)
|
|
1161
|
+
: generatedStyles;
|
|
1173
1162
|
}, [props.style, generatedStyles]);
|
|
1174
1163
|
propsForElement.ref = refToForward;
|
|
1175
1164
|
return createElement(elementToBeCreated, propsForElement);
|
|
@@ -1190,9 +1179,9 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1190
1179
|
if (options.shouldForwardProp) {
|
|
1191
1180
|
var passedShouldForwardPropFn_1 = options.shouldForwardProp;
|
|
1192
1181
|
// compose nested shouldForwardProp calls
|
|
1193
|
-
shouldForwardProp = function (prop,
|
|
1194
|
-
return shouldForwardPropFn_1(prop,
|
|
1195
|
-
passedShouldForwardPropFn_1(prop,
|
|
1182
|
+
shouldForwardProp = function (prop, elementToBeCreated) {
|
|
1183
|
+
return shouldForwardPropFn_1(prop, elementToBeCreated) &&
|
|
1184
|
+
passedShouldForwardPropFn_1(prop, elementToBeCreated);
|
|
1196
1185
|
};
|
|
1197
1186
|
}
|
|
1198
1187
|
else {
|