styled-components 6.0.0-beta.2 → 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 -25
- package/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/dist/constructors/css.d.ts +1 -1
- 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 +38 -44
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +38 -44
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +38 -44
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +38 -44
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +38 -44
- 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 +45 -39
- 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/mixinDeep.d.ts +2 -2
- package/native/dist/constructors/constructWithOptions.d.ts +26 -25
- package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/native/dist/constructors/css.d.ts +1 -1
- 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 +10 -17
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +10 -17
- 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 +45 -39
- 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/mixinDeep.d.ts +2 -2
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IStyledComponentFactory, RuleSet, StyledOptions, WebTarget } from '../types';
|
|
2
|
-
declare function createStyledComponent<Target extends WebTarget, OuterProps
|
|
2
|
+
declare function createStyledComponent<Target extends WebTarget, OuterProps extends object, Statics extends object = object>(target: Target, options: StyledOptions<'web', OuterProps>, rules: RuleSet<OuterProps>): ReturnType<IStyledComponentFactory<'web', Target, OuterProps, Statics>>;
|
|
3
3
|
export default createStyledComponent;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const _default: (InlineStyle: IInlineStyleConstructor<any>) => <Target extends NativeTarget, OuterProps extends
|
|
1
|
+
import type { ExecutionProps, IInlineStyleConstructor, IStyledComponent, IStyledComponentFactory, NativeTarget, RuleSet, StyledOptions } from '../types';
|
|
2
|
+
declare const _default: (InlineStyle: IInlineStyleConstructor<any>) => <Target extends NativeTarget, OuterProps extends ExecutionProps, Statics extends object = object>(target: Target, options: StyledOptions<"native", OuterProps>, rules: RuleSet<OuterProps>) => IStyledComponent<"native", Target, OuterProps & object> & Statics & object;
|
|
3
3
|
export default _default;
|
package/dist/native/index.d.ts
CHANGED
|
@@ -6,35 +6,31 @@ import useTheme from '../hooks/useTheme';
|
|
|
6
6
|
import ThemeProvider, { ThemeConsumer, ThemeContext } from '../models/ThemeProvider';
|
|
7
7
|
import { NativeTarget } from '../types';
|
|
8
8
|
import isStyledComponent from '../utils/isStyledComponent';
|
|
9
|
-
declare const styled: (<Target extends NativeTarget>(tag: Target) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
TouchableHighlight: Styled<"native", typeof import("react-native").TouchableHighlight, import("react-native").TouchableHighlightProps, unknown, unknown>;
|
|
35
|
-
TouchableOpacity: Styled<"native", typeof import("react-native").TouchableOpacity, import("react-native").TouchableOpacityProps, unknown, unknown>;
|
|
36
|
-
View: Styled<"native", typeof import("react-native").View, import("react-native").ViewProps, unknown, unknown>;
|
|
37
|
-
VirtualizedList: Styled<"native", typeof import("react-native").VirtualizedList, import("react-native").VirtualizedListProps<unknown>, unknown, unknown>;
|
|
9
|
+
declare const styled: (<Target extends NativeTarget>(tag: Target) => Styled<"native", Target, Target extends import("../types").KnownTarget ? React.ComponentPropsWithRef<Target> : object, object>) & {
|
|
10
|
+
ActivityIndicator: Styled<"native", typeof import("react-native").ActivityIndicator, import("react-native").ActivityIndicatorProps & React.RefAttributes<import("react-native").ActivityIndicator>, object>;
|
|
11
|
+
Button: Styled<"native", typeof import("react-native").Button, import("react-native").ButtonProps & React.RefAttributes<import("react-native").Button>, object>;
|
|
12
|
+
DatePickerIOS: Styled<"native", typeof import("react-native").DatePickerIOS, import("react-native").DatePickerIOSProps & React.RefAttributes<import("react-native").DatePickerIOS>, object>;
|
|
13
|
+
DrawerLayoutAndroid: Styled<"native", typeof import("react-native").DrawerLayoutAndroid, import("react-native").DrawerLayoutAndroidProps & React.RefAttributes<import("react-native").DrawerLayoutAndroid>, object>;
|
|
14
|
+
FlatList: Styled<"native", typeof import("react-native").FlatList, import("react-native").FlatListProps<unknown> & React.RefAttributes<import("react-native").FlatList<unknown>>, object>;
|
|
15
|
+
Image: Styled<"native", typeof import("react-native").Image, import("react-native").ImageProps & React.RefAttributes<import("react-native").Image>, object>;
|
|
16
|
+
ImageBackground: Styled<"native", typeof import("react-native").ImageBackground, import("react-native").ImageBackgroundProps & React.RefAttributes<import("react-native").ImageBackground>, object>;
|
|
17
|
+
KeyboardAvoidingView: Styled<"native", typeof import("react-native").KeyboardAvoidingView, import("react-native").KeyboardAvoidingViewProps & React.RefAttributes<import("react-native").KeyboardAvoidingView>, object>;
|
|
18
|
+
Modal: Styled<"native", typeof import("react-native").Modal, import("react-native").ModalBaseProps & import("react-native").ModalPropsIOS & import("react-native").ModalPropsAndroid & import("react-native").ViewProps & React.RefAttributes<import("react-native").Modal>, object>;
|
|
19
|
+
Pressable: Styled<"native", import("react").ForwardRefExoticComponent<import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>>, import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>, object>;
|
|
20
|
+
ProgressBarAndroid: Styled<"native", typeof import("react-native").ProgressBarAndroid, import("react-native").ProgressBarAndroidProps & React.RefAttributes<import("react-native").ProgressBarAndroid>, object>;
|
|
21
|
+
ProgressViewIOS: Styled<"native", typeof import("react-native").ProgressViewIOS, import("react-native").ProgressViewIOSProps & React.RefAttributes<import("react-native").ProgressViewIOS>, object>;
|
|
22
|
+
RefreshControl: Styled<"native", typeof import("react-native").RefreshControl, import("react-native").RefreshControlProps & React.RefAttributes<import("react-native").RefreshControl>, object>;
|
|
23
|
+
SafeAreaView: Styled<"native", typeof import("react-native").SafeAreaView, import("react-native").ViewProps & React.RefAttributes<import("react-native").SafeAreaView>, object>;
|
|
24
|
+
ScrollView: Styled<"native", typeof import("react-native").ScrollView, import("react-native").ScrollViewProps & React.RefAttributes<import("react-native").ScrollView>, object>;
|
|
25
|
+
SectionList: Styled<"native", typeof import("react-native").SectionList, import("react-native").SectionListProps<unknown, unknown> & React.RefAttributes<import("react-native").SectionList<unknown, unknown>>, object>;
|
|
26
|
+
Slider: Styled<"native", typeof import("react-native").Slider, import("react-native").SliderProps & React.RefAttributes<import("react-native").Slider>, object>;
|
|
27
|
+
Switch: Styled<"native", typeof import("react-native").Switch, import("react-native").SwitchProps & React.RefAttributes<import("react-native").Switch>, object>;
|
|
28
|
+
Text: Styled<"native", typeof import("react-native").Text, import("react-native").TextProps & React.RefAttributes<import("react-native").Text>, object>;
|
|
29
|
+
TextInput: Styled<"native", typeof import("react-native").TextInput, import("react-native").TextInputProps & React.RefAttributes<import("react-native").TextInput>, object>;
|
|
30
|
+
TouchableHighlight: Styled<"native", typeof import("react-native").TouchableHighlight, import("react-native").TouchableHighlightProps & React.RefAttributes<import("react-native").TouchableHighlight>, object>;
|
|
31
|
+
TouchableOpacity: Styled<"native", typeof import("react-native").TouchableOpacity, import("react-native").TouchableOpacityProps & React.RefAttributes<import("react-native").TouchableOpacity>, object>;
|
|
32
|
+
View: Styled<"native", typeof import("react-native").View, import("react-native").ViewProps & React.RefAttributes<import("react-native").View>, object>;
|
|
33
|
+
VirtualizedList: Styled<"native", typeof import("react-native").VirtualizedList, import("react-native").VirtualizedListProps<unknown> & React.RefAttributes<import("react-native").VirtualizedList<unknown>>, object>;
|
|
38
34
|
};
|
|
39
35
|
export { IStyledComponent, IStyledComponentFactory, IStyledStatics, NativeTarget, StyledOptions, } from '../types';
|
|
40
36
|
export { css, isStyledComponent, ThemeProvider, ThemeConsumer, ThemeContext, withTheme, useTheme };
|
|
@@ -18,7 +18,7 @@ var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR
|
|
|
18
18
|
'data-styled';
|
|
19
19
|
var SC_ATTR_ACTIVE = 'active';
|
|
20
20
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
21
|
-
var SC_VERSION = "6.0.0-beta.
|
|
21
|
+
var SC_VERSION = "6.0.0-beta.3";
|
|
22
22
|
var SPLITTER = '/*!sc*/\n';
|
|
23
23
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
24
24
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -1140,8 +1140,8 @@ function addUnitIfNeeded(name, value) {
|
|
|
1140
1140
|
* inlined version of
|
|
1141
1141
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
1142
1142
|
*/
|
|
1143
|
-
var uppercaseCheck = /
|
|
1144
|
-
var uppercasePattern = /
|
|
1143
|
+
var uppercaseCheck = /[A-Z]/;
|
|
1144
|
+
var uppercasePattern = /[A-Z]/g;
|
|
1145
1145
|
var msPattern = /^ms-/;
|
|
1146
1146
|
var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
|
|
1147
1147
|
/**
|
|
@@ -1158,7 +1158,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
|
|
|
1158
1158
|
* is converted to `-ms-`.
|
|
1159
1159
|
*/
|
|
1160
1160
|
function hyphenateStyleName(string) {
|
|
1161
|
-
return uppercaseCheck.test(string)
|
|
1161
|
+
return uppercaseCheck.test(string) && !string.startsWith('--')
|
|
1162
1162
|
? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
|
|
1163
1163
|
: string;
|
|
1164
1164
|
}
|
|
@@ -1248,8 +1248,7 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
1248
1248
|
function isStaticRules(rules) {
|
|
1249
1249
|
for (var i = 0; i < rules.length; i += 1) {
|
|
1250
1250
|
var rule = rules[i];
|
|
1251
|
-
if (isFunction(rule) &&
|
|
1252
|
-
!isStyledComponent(rule)) {
|
|
1251
|
+
if (isFunction(rule) && !isStyledComponent(rule)) {
|
|
1253
1252
|
// functions are allowed to be static if they're just being
|
|
1254
1253
|
// used to get the classname of a nested styled component
|
|
1255
1254
|
return false;
|
|
@@ -1383,35 +1382,10 @@ function generateId(displayName, parentComponentId) {
|
|
|
1383
1382
|
SC_VERSION + name + identifiers[name]));
|
|
1384
1383
|
return parentComponentId ? "".concat(parentComponentId, "-").concat(componentId) : componentId;
|
|
1385
1384
|
}
|
|
1386
|
-
function useResolvedAttrs(theme, props, attrs) {
|
|
1387
|
-
if (theme === void 0) { theme = EMPTY_OBJECT; }
|
|
1388
|
-
// NOTE: can't memoize this
|
|
1389
|
-
// returns [context, resolvedAttrs]
|
|
1390
|
-
// where resolvedAttrs is only the things injected by the attrs themselves
|
|
1391
|
-
var context = tslib.__assign(tslib.__assign({}, props), { theme: theme });
|
|
1392
|
-
attrs.forEach(function (attrDef) {
|
|
1393
|
-
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1394
|
-
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1395
|
-
var key;
|
|
1396
|
-
/* eslint-disable guard-for-in */
|
|
1397
|
-
for (key in resolvedAttrDef) {
|
|
1398
|
-
// @ts-expect-error bad types
|
|
1399
|
-
context[key] =
|
|
1400
|
-
key === 'className'
|
|
1401
|
-
? joinStrings(context[key], resolvedAttrDef[key])
|
|
1402
|
-
: key === 'style'
|
|
1403
|
-
? tslib.__assign(tslib.__assign({}, context[key]), resolvedAttrDef[key]) : resolvedAttrDef[key];
|
|
1404
|
-
}
|
|
1405
|
-
/* eslint-enable guard-for-in */
|
|
1406
|
-
});
|
|
1407
|
-
return context;
|
|
1408
|
-
}
|
|
1409
1385
|
function useInjectedStyle(componentStyle, isStatic, resolvedAttrs, warnTooManyClasses) {
|
|
1410
1386
|
var styleSheet = useStyleSheet();
|
|
1411
1387
|
var stylis = useStylis();
|
|
1412
|
-
var className = isStatic
|
|
1413
|
-
? componentStyle.generateAndInjectStyles(EMPTY_OBJECT, styleSheet, stylis)
|
|
1414
|
-
: componentStyle.generateAndInjectStyles(resolvedAttrs, styleSheet, stylis);
|
|
1388
|
+
var className = componentStyle.generateAndInjectStyles(isStatic ? EMPTY_OBJECT : resolvedAttrs, styleSheet, stylis);
|
|
1415
1389
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1416
1390
|
if (process.env.NODE_ENV !== 'production')
|
|
1417
1391
|
React.useDebugValue(className);
|
|
@@ -1428,36 +1402,56 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef, isStati
|
|
|
1428
1402
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
1429
1403
|
// but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
|
|
1430
1404
|
// should be an immutable value, but behave for now.
|
|
1431
|
-
var theme = determineTheme(props, React.useContext(ThemeContext), defaultProps);
|
|
1432
|
-
var context =
|
|
1405
|
+
var theme = determineTheme(props, React.useContext(ThemeContext), defaultProps) || EMPTY_OBJECT;
|
|
1406
|
+
var context = componentAttrs.reduce(function (p, attrDef) {
|
|
1407
|
+
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(p) : attrDef;
|
|
1408
|
+
var key;
|
|
1409
|
+
/* eslint-disable guard-for-in */
|
|
1410
|
+
for (key in resolvedAttrDef) {
|
|
1411
|
+
// @ts-expect-error bad types
|
|
1412
|
+
p[key] =
|
|
1413
|
+
key === 'className'
|
|
1414
|
+
? // @ts-expect-error bad types
|
|
1415
|
+
joinStrings(p[key], resolvedAttrDef[key])
|
|
1416
|
+
: key === 'style'
|
|
1417
|
+
? // @ts-expect-error bad types
|
|
1418
|
+
tslib.__assign(tslib.__assign({}, p[key]), resolvedAttrDef[key]) : // @ts-expect-error bad types
|
|
1419
|
+
resolvedAttrDef[key];
|
|
1420
|
+
}
|
|
1421
|
+
/* eslint-enable guard-for-in */
|
|
1422
|
+
return p;
|
|
1423
|
+
}, tslib.__assign(tslib.__assign({}, props), { theme: theme }));
|
|
1433
1424
|
var generatedClassName = useInjectedStyle(componentStyle, isStatic, context, process.env.NODE_ENV !== 'production' ? forwardedComponent.warnTooManyClasses : undefined);
|
|
1434
1425
|
var refToForward = forwardedRef;
|
|
1435
|
-
var elementToBeCreated = context
|
|
1426
|
+
var elementToBeCreated = context.as || target;
|
|
1436
1427
|
var isTargetTag = isTag(elementToBeCreated);
|
|
1437
|
-
var propsForElement = {};
|
|
1438
1428
|
// eslint-disable-next-line guard-for-in
|
|
1439
1429
|
for (var key in context) {
|
|
1430
|
+
// @ts-expect-error type narrowing not working properly
|
|
1440
1431
|
if (key[0] === '$' || key === 'as' || key === 'theme')
|
|
1441
|
-
|
|
1432
|
+
context[key] = undefined;
|
|
1442
1433
|
else if (key === 'forwardedAs') {
|
|
1443
|
-
|
|
1434
|
+
context.as = context[key];
|
|
1435
|
+
context[key] = undefined;
|
|
1444
1436
|
}
|
|
1445
|
-
else if (shouldForwardProp ? shouldForwardProp(key, elementToBeCreated) :
|
|
1437
|
+
else if (shouldForwardProp ? !shouldForwardProp(key, elementToBeCreated) : false) {
|
|
1446
1438
|
// Don't pass through non HTML tags through to HTML elements
|
|
1447
|
-
|
|
1439
|
+
// @ts-expect-error we don't know ahead of time
|
|
1440
|
+
context[key] = undefined;
|
|
1448
1441
|
}
|
|
1449
1442
|
}
|
|
1450
|
-
|
|
1443
|
+
context[
|
|
1451
1444
|
// handle custom elements which React doesn't properly alias
|
|
1452
1445
|
isTargetTag &&
|
|
1453
1446
|
domElements.indexOf(elementToBeCreated) === -1
|
|
1454
1447
|
? 'class'
|
|
1455
1448
|
: 'className'] = foldedComponentIds
|
|
1456
|
-
.concat(styledComponentId,
|
|
1449
|
+
.concat(styledComponentId, generatedClassName !== styledComponentId ? generatedClassName : '', context.className || '')
|
|
1457
1450
|
.filter(Boolean)
|
|
1458
1451
|
.join(' ');
|
|
1459
|
-
|
|
1460
|
-
|
|
1452
|
+
// @ts-expect-error idk the type is probably wrong in this file
|
|
1453
|
+
context.ref = refToForward;
|
|
1454
|
+
return React.createElement(elementToBeCreated, context);
|
|
1461
1455
|
}
|
|
1462
1456
|
function createStyledComponent(target, options, rules) {
|
|
1463
1457
|
var isTargetStyledComp = isStyledComponent(target);
|