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.
Files changed (58) hide show
  1. package/dist/constructors/constructWithOptions.d.ts +26 -25
  2. package/dist/constructors/createGlobalStyle.d.ts +2 -2
  3. package/dist/constructors/css.d.ts +1 -1
  4. package/dist/constructors/keyframes.d.ts +1 -1
  5. package/dist/constructors/styled.d.ts +176 -180
  6. package/dist/hoc/withTheme.d.ts +2 -2
  7. package/dist/models/GlobalStyle.d.ts +1 -1
  8. package/dist/models/InlineStyle.d.ts +1 -1
  9. package/dist/models/StyledComponent.d.ts +1 -1
  10. package/dist/models/StyledNativeComponent.d.ts +2 -2
  11. package/dist/native/index.d.ts +25 -29
  12. package/dist/styled-components.browser.cjs.js +38 -44
  13. package/dist/styled-components.browser.cjs.js.map +1 -1
  14. package/dist/styled-components.browser.esm.js +38 -44
  15. package/dist/styled-components.browser.esm.js.map +1 -1
  16. package/dist/styled-components.cjs.js +38 -44
  17. package/dist/styled-components.cjs.js.map +1 -1
  18. package/dist/styled-components.esm.js +38 -44
  19. package/dist/styled-components.esm.js.map +1 -1
  20. package/dist/styled-components.js +38 -44
  21. package/dist/styled-components.js.map +1 -1
  22. package/dist/styled-components.min.js +1 -1
  23. package/dist/styled-components.min.js.map +1 -1
  24. package/dist/test/utils.d.ts +176 -180
  25. package/dist/tsconfig.tsbuildinfo +1 -1
  26. package/dist/types.d.ts +45 -39
  27. package/dist/utils/determineTheme.d.ts +2 -2
  28. package/dist/utils/empties.d.ts +2 -2
  29. package/dist/utils/flatten.d.ts +3 -3
  30. package/dist/utils/interleave.d.ts +1 -1
  31. package/dist/utils/isStaticRules.d.ts +1 -1
  32. package/dist/utils/isStyledComponent.d.ts +1 -1
  33. package/dist/utils/mixinDeep.d.ts +2 -2
  34. package/native/dist/constructors/constructWithOptions.d.ts +26 -25
  35. package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
  36. package/native/dist/constructors/css.d.ts +1 -1
  37. package/native/dist/constructors/keyframes.d.ts +1 -1
  38. package/native/dist/constructors/styled.d.ts +176 -180
  39. package/native/dist/hoc/withTheme.d.ts +2 -2
  40. package/native/dist/models/GlobalStyle.d.ts +1 -1
  41. package/native/dist/models/InlineStyle.d.ts +1 -1
  42. package/native/dist/models/StyledComponent.d.ts +1 -1
  43. package/native/dist/models/StyledNativeComponent.d.ts +2 -2
  44. package/native/dist/native/index.d.ts +25 -29
  45. package/native/dist/styled-components.native.cjs.js +10 -17
  46. package/native/dist/styled-components.native.cjs.js.map +1 -1
  47. package/native/dist/styled-components.native.esm.js +10 -17
  48. package/native/dist/styled-components.native.esm.js.map +1 -1
  49. package/native/dist/test/utils.d.ts +176 -180
  50. package/native/dist/types.d.ts +45 -39
  51. package/native/dist/utils/determineTheme.d.ts +2 -2
  52. package/native/dist/utils/empties.d.ts +2 -2
  53. package/native/dist/utils/flatten.d.ts +3 -3
  54. package/native/dist/utils/interleave.d.ts +1 -1
  55. package/native/dist/utils/isStaticRules.d.ts +1 -1
  56. package/native/dist/utils/isStyledComponent.d.ts +1 -1
  57. package/native/dist/utils/mixinDeep.d.ts +2 -2
  58. package/package.json +2 -2
@@ -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
- <Props = unknown, Statics = unknown>(initialStyles: import("../types").Styles<(Target extends import("../types").KnownTarget ? React.ComponentProps<Target> : unknown) & Props>, ...interpolations: import("../types").Interpolation<import("../types").ExecutionContext & (Target extends import("../types").KnownTarget ? React.ComponentProps<Target> : unknown) & Props>[]): import("../types").IStyledComponent<"native", Target, (Target extends import("../types").KnownTarget ? React.ComponentProps<Target> : unknown) & Props> & Statics;
11
- attrs(attrs: import("../types").Attrs<import("../types").ExtensibleObject & (Target extends import("../types").KnownTarget ? React.ComponentProps<Target> : unknown)>): any;
12
- withConfig(config: import("../types").StyledOptions<"native", Target extends import("../types").KnownTarget ? React.ComponentProps<Target> : unknown>): any;
13
- }) & {
14
- ActivityIndicator: Styled<"native", typeof import("react-native").ActivityIndicator, import("react-native").ActivityIndicatorProps, unknown, unknown>;
15
- Button: Styled<"native", typeof import("react-native").Button, import("react-native").ButtonProps, unknown, unknown>;
16
- DatePickerIOS: Styled<"native", typeof import("react-native").DatePickerIOS, import("react-native").DatePickerIOSProps, unknown, unknown>;
17
- DrawerLayoutAndroid: Styled<"native", typeof import("react-native").DrawerLayoutAndroid, import("react-native").DrawerLayoutAndroidProps, unknown, unknown>;
18
- FlatList: Styled<"native", typeof import("react-native").FlatList, import("react-native").FlatListProps<unknown>, unknown, unknown>;
19
- Image: Styled<"native", typeof import("react-native").Image, import("react-native").ImageProps, unknown, unknown>;
20
- ImageBackground: Styled<"native", typeof import("react-native").ImageBackground, import("react-native").ImageBackgroundProps, unknown, unknown>;
21
- KeyboardAvoidingView: Styled<"native", typeof import("react-native").KeyboardAvoidingView, import("react-native").KeyboardAvoidingViewProps, unknown, unknown>;
22
- Modal: Styled<"native", typeof import("react-native").Modal, import("react-native").ModalProps, unknown, unknown>;
23
- 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>, unknown, unknown>;
24
- ProgressBarAndroid: Styled<"native", typeof import("react-native").ProgressBarAndroid, import("react-native").ProgressBarAndroidProps, unknown, unknown>;
25
- ProgressViewIOS: Styled<"native", typeof import("react-native").ProgressViewIOS, import("react-native").ProgressViewIOSProps, unknown, unknown>;
26
- RefreshControl: Styled<"native", typeof import("react-native").RefreshControl, import("react-native").RefreshControlProps, unknown, unknown>;
27
- SafeAreaView: Styled<"native", typeof import("react-native").SafeAreaView, import("react-native").ViewProps, unknown, unknown>;
28
- ScrollView: Styled<"native", typeof import("react-native").ScrollView, import("react-native").ScrollViewProps, unknown, unknown>;
29
- SectionList: Styled<"native", typeof import("react-native").SectionList, import("react-native").SectionListProps<unknown, unknown>, unknown, unknown>;
30
- Slider: Styled<"native", typeof import("react-native").Slider, import("react-native").SliderProps, unknown, unknown>;
31
- Switch: Styled<"native", typeof import("react-native").Switch, import("react-native").SwitchProps, unknown, unknown>;
32
- Text: Styled<"native", typeof import("react-native").Text, import("react-native").TextProps, unknown, unknown>;
33
- TextInput: Styled<"native", typeof import("react-native").TextInput, import("react-native").TextInputProps, unknown, unknown>;
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 };
@@ -79,7 +79,7 @@ var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR
79
79
  'data-styled';
80
80
  var SC_ATTR_ACTIVE = 'active';
81
81
  var SC_ATTR_VERSION = 'data-styled-version';
82
- var SC_VERSION = "6.0.0-beta.2";
82
+ var SC_VERSION = "6.0.0-beta.3";
83
83
  var SPLITTER = '/*!sc*/\n';
84
84
  var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
85
85
  var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
@@ -668,8 +668,8 @@ function getComponentName(target) {
668
668
  * inlined version of
669
669
  * https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
670
670
  */
671
- var uppercaseCheck = /([A-Z])/;
672
- var uppercasePattern = /([A-Z])/g;
671
+ var uppercaseCheck = /[A-Z]/;
672
+ var uppercasePattern = /[A-Z]/g;
673
673
  var msPattern = /^ms-/;
674
674
  var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
675
675
  /**
@@ -686,7 +686,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
686
686
  * is converted to `-ms-`.
687
687
  */
688
688
  function hyphenateStyleName(string) {
689
- return uppercaseCheck.test(string)
689
+ return uppercaseCheck.test(string) && !string.startsWith('--')
690
690
  ? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
691
691
  : string;
692
692
  }
@@ -1129,7 +1129,6 @@ function useResolvedAttrs(theme, props, attrs) {
1129
1129
  var context = tslib.__assign(tslib.__assign({}, props), { theme: theme });
1130
1130
  var resolvedAttrs = {};
1131
1131
  attrs.forEach(function (attrDef) {
1132
- // @ts-expect-error narrowing isn't working properly for some reason
1133
1132
  var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
1134
1133
  var key;
1135
1134
  /* eslint-disable guard-for-in */
@@ -1150,7 +1149,7 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1150
1149
  var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
1151
1150
  var generatedStyles = inlineStyle.generateStyleObject(context);
1152
1151
  var refToForward = forwardedRef;
1153
- var elementToBeCreated = attrs.$as || props.$as || attrs.as || props.as || target;
1152
+ var elementToBeCreated = attrs.as || props.as || target;
1154
1153
  var computedProps = attrs !== props ? tslib.__assign(tslib.__assign({}, props), attrs) : props;
1155
1154
  var propsForElement = {};
1156
1155
  // eslint-disable-next-line guard-for-in
@@ -1165,17 +1164,11 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1165
1164
  }
1166
1165
  }
1167
1166
  propsForElement.style = React.useMemo(function () {
1168
- if (typeof props.style === 'function') {
1169
- return function (state) {
1170
- return [generatedStyles].concat(props.style(state));
1171
- };
1172
- }
1173
- else if (props.style == null) {
1174
- return generatedStyles;
1175
- }
1176
- else {
1177
- return [generatedStyles].concat(props.style || []);
1178
- }
1167
+ return typeof props.style === 'function'
1168
+ ? function (state) { return [generatedStyles].concat(props.style(state)); }
1169
+ : props.style
1170
+ ? [generatedStyles].concat(props.style)
1171
+ : generatedStyles;
1179
1172
  }, [props.style, generatedStyles]);
1180
1173
  propsForElement.ref = refToForward;
1181
1174
  return React.createElement(elementToBeCreated, propsForElement);