styled-components 6.0.0-beta.9 → 6.0.0-rc.0

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 (67) hide show
  1. package/dist/base.d.ts +2 -8
  2. package/dist/constructors/constructWithOptions.d.ts +6 -6
  3. package/dist/hoc/withTheme.d.ts +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/models/ComponentStyle.d.ts +0 -1
  6. package/dist/models/StyleSheetManager.d.ts +27 -9
  7. package/dist/models/ThemeProvider.d.ts +4 -3
  8. package/dist/native/index.d.ts +25 -26
  9. package/dist/sheet/GroupedTag.d.ts +1 -1
  10. package/dist/sheet/Sheet.d.ts +3 -3
  11. package/dist/sheet/types.d.ts +1 -1
  12. package/dist/styled-components-macro.cjs.js +0 -1
  13. package/dist/styled-components-macro.cjs.js.map +1 -1
  14. package/dist/styled-components-macro.esm.js +0 -1
  15. package/dist/styled-components-macro.esm.js.map +1 -1
  16. package/dist/styled-components.browser.cjs.js +1 -1845
  17. package/dist/styled-components.browser.cjs.js.map +1 -1
  18. package/dist/styled-components.browser.esm.js +1 -1819
  19. package/dist/styled-components.browser.esm.js.map +1 -1
  20. package/dist/styled-components.cjs.js +1 -1865
  21. package/dist/styled-components.cjs.js.map +1 -1
  22. package/dist/styled-components.esm.js +1 -1839
  23. package/dist/styled-components.esm.js.map +1 -1
  24. package/dist/styled-components.js +258 -235
  25. package/dist/styled-components.js.map +1 -1
  26. package/dist/styled-components.min.js +1 -1
  27. package/dist/styled-components.min.js.map +1 -1
  28. package/dist/test/types.d.ts +9 -0
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/dist/types.d.ts +34 -41
  31. package/dist/utils/determineTheme.d.ts +4 -2
  32. package/dist/utils/domElements.d.ts +1 -1
  33. package/dist/utils/flatten.d.ts +1 -1
  34. package/dist/utils/hoist.d.ts +3 -3
  35. package/dist/utils/isFunction.d.ts +1 -1
  36. package/dist/utils/isPlainObject.d.ts +1 -1
  37. package/dist/utils/isStatelessFunction.d.ts +1 -1
  38. package/dist/utils/joinStrings.d.ts +2 -1
  39. package/dist/utils/stylis.d.ts +1 -1
  40. package/native/dist/base.d.ts +2 -8
  41. package/native/dist/constructors/constructWithOptions.d.ts +6 -6
  42. package/native/dist/hoc/withTheme.d.ts +1 -1
  43. package/native/dist/index.d.ts +1 -1
  44. package/native/dist/models/ComponentStyle.d.ts +0 -1
  45. package/native/dist/models/StyleSheetManager.d.ts +27 -9
  46. package/native/dist/models/ThemeProvider.d.ts +4 -3
  47. package/native/dist/native/index.d.ts +25 -26
  48. package/native/dist/sheet/GroupedTag.d.ts +1 -1
  49. package/native/dist/sheet/Sheet.d.ts +3 -3
  50. package/native/dist/sheet/types.d.ts +1 -1
  51. package/native/dist/styled-components.native.cjs.js +1 -1305
  52. package/native/dist/styled-components.native.cjs.js.map +1 -1
  53. package/native/dist/styled-components.native.esm.js +1 -1287
  54. package/native/dist/styled-components.native.esm.js.map +1 -1
  55. package/native/dist/test/types.d.ts +9 -0
  56. package/native/dist/types.d.ts +34 -41
  57. package/native/dist/utils/determineTheme.d.ts +4 -2
  58. package/native/dist/utils/domElements.d.ts +1 -1
  59. package/native/dist/utils/flatten.d.ts +1 -1
  60. package/native/dist/utils/hoist.d.ts +3 -3
  61. package/native/dist/utils/isFunction.d.ts +1 -1
  62. package/native/dist/utils/isPlainObject.d.ts +1 -1
  63. package/native/dist/utils/isStatelessFunction.d.ts +1 -1
  64. package/native/dist/utils/joinStrings.d.ts +2 -1
  65. package/native/dist/utils/stylis.d.ts +1 -1
  66. package/package.json +23 -48
  67. package/dist/hooks/useTheme.d.ts +0 -3
@@ -8,7 +8,6 @@ export default class ComponentStyle {
8
8
  baseStyle: ComponentStyle | null | undefined;
9
9
  componentId: string;
10
10
  isStatic: boolean;
11
- names: string[];
12
11
  rules: RuleSet<any>;
13
12
  staticRulesId: string;
14
13
  constructor(rules: RuleSet<any>, componentId: string, baseStyle?: ComponentStyle);
@@ -1,17 +1,20 @@
1
1
  import React from 'react';
2
2
  import StyleSheet from '../sheet';
3
- import { Stringifier } from '../types';
4
- export declare type IStyleSheetContext = StyleSheet | void;
3
+ import { ShouldForwardProp, Stringifier } from '../types';
4
+ export declare const mainSheet: StyleSheet;
5
+ export declare const mainStylis: Stringifier;
6
+ export type IStyleSheetContext = {
7
+ shouldForwardProp?: ShouldForwardProp<'web'>;
8
+ styleSheet: StyleSheet;
9
+ stylis: Stringifier;
10
+ };
5
11
  export declare const StyleSheetContext: React.Context<IStyleSheetContext>;
6
12
  export declare const StyleSheetConsumer: React.Consumer<IStyleSheetContext>;
7
- export declare type IStylisContext = Stringifier | void;
13
+ export type IStylisContext = Stringifier | void;
8
14
  export declare const StylisContext: React.Context<IStylisContext>;
9
15
  export declare const StylisConsumer: React.Consumer<IStylisContext>;
10
- export declare const mainSheet: StyleSheet;
11
- export declare const mainStylis: Stringifier;
12
- export declare function useStyleSheet(): StyleSheet;
13
- export declare function useStylis(): Stringifier;
14
- export declare type IStyleSheetManager = React.PropsWithChildren<{
16
+ export declare function useStyleSheetContext(): IStyleSheetContext;
17
+ export type IStyleSheetManager = React.PropsWithChildren<{
15
18
  /**
16
19
  * If desired, you can pass this prop to disable "speedy" insertion mode, which
17
20
  * uses the browser [CSSOM APIs](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet).
@@ -22,7 +25,7 @@ export declare type IStyleSheetManager = React.PropsWithChildren<{
22
25
  * If you are working exclusively with modern browsers, vendor prefixes can often be omitted
23
26
  * to reduce the weight of CSS on the page.
24
27
  */
25
- disableVendorPrefixes?: boolean;
28
+ enableVendorPrefixes?: boolean;
26
29
  /**
27
30
  * Provide an optional selector to be prepended to all generated style rules.
28
31
  */
@@ -31,6 +34,21 @@ export declare type IStyleSheetManager = React.PropsWithChildren<{
31
34
  * Create and provide your own `StyleSheet` if necessary for advanced SSR scenarios.
32
35
  */
33
36
  sheet?: StyleSheet;
37
+ /**
38
+ * Starting in v6, styled-components no longer does its own prop validation
39
+ * and recommends use of transient props "$prop" to pass style-only props to
40
+ * components. If for some reason you are not able to use transient props, a
41
+ * prop validation function can be provided via `StyleSheetManager`, such as
42
+ * `@emotion/is-prop-valid`.
43
+ *
44
+ * When the return value is `true`, props will be forwarded to the DOM/underlying
45
+ * component. If return value is `false`, the prop will be discarded after styles
46
+ * are calculated.
47
+ *
48
+ * Manually composing `styled.{element}.withConfig({shouldForwardProp})` will
49
+ * override this default.
50
+ */
51
+ shouldForwardProp?: IStyleSheetContext['shouldForwardProp'];
34
52
  /**
35
53
  * An array of plugins to be run by stylis (style processor) during compilation.
36
54
  * Check out [what's available on npm*](https://www.npmjs.com/search?q=keywords%3Astylis).
@@ -24,14 +24,15 @@ import React from 'react';
24
24
  export interface DefaultTheme {
25
25
  [key: string]: any;
26
26
  }
27
- declare type ThemeFn = (outerTheme?: DefaultTheme) => DefaultTheme;
28
- declare type ThemeArgument = DefaultTheme | ThemeFn;
29
- declare type Props = {
27
+ type ThemeFn = (outerTheme?: DefaultTheme) => DefaultTheme;
28
+ type ThemeArgument = DefaultTheme | ThemeFn;
29
+ type Props = {
30
30
  children?: React.ReactNode;
31
31
  theme: ThemeArgument;
32
32
  };
33
33
  export declare const ThemeContext: React.Context<DefaultTheme | undefined>;
34
34
  export declare const ThemeConsumer: React.Consumer<DefaultTheme | undefined>;
35
+ export declare function useTheme(): DefaultTheme | undefined;
35
36
  /**
36
37
  * Provide a theme to an entire react component tree via context
37
38
  */
@@ -2,35 +2,34 @@ import React from 'react';
2
2
  import { Styled } from '../constructors/constructWithOptions';
3
3
  import css from '../constructors/css';
4
4
  import withTheme from '../hoc/withTheme';
5
- import useTheme from '../hooks/useTheme';
6
- import ThemeProvider, { ThemeConsumer, ThemeContext } from '../models/ThemeProvider';
5
+ import ThemeProvider, { ThemeConsumer, ThemeContext, useTheme } from '../models/ThemeProvider';
7
6
  import { NativeTarget } from '../types';
8
7
  import isStyledComponent from '../utils/isStyledComponent';
9
8
  declare const styled: (<Target extends NativeTarget>(tag: Target) => Styled<"native", Target, Target extends import("../types").KnownTarget ? React.ComponentPropsWithRef<Target> : object, object, object>) & {
10
- ActivityIndicator: Styled<"native", typeof import("react-native").ActivityIndicator, object, object, object>;
11
- Button: Styled<"native", typeof import("react-native").Button, object, object, object>;
12
- DatePickerIOS: Styled<"native", typeof import("react-native").DatePickerIOS, object, object, object>;
13
- DrawerLayoutAndroid: Styled<"native", typeof import("react-native").DrawerLayoutAndroid, object, object, object>;
14
- FlatList: Styled<"native", typeof import("react-native").FlatList, object, object, object>;
15
- Image: Styled<"native", typeof import("react-native").Image, object, object, object>;
16
- ImageBackground: Styled<"native", typeof import("react-native").ImageBackground, object, object, object>;
17
- KeyboardAvoidingView: Styled<"native", typeof import("react-native").KeyboardAvoidingView, object, object, object>;
18
- Modal: Styled<"native", typeof import("react-native").Modal, object, object, object>;
19
- Pressable: Styled<"native", import("react").ForwardRefExoticComponent<import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>>, object, object, object>;
20
- ProgressBarAndroid: Styled<"native", typeof import("react-native").ProgressBarAndroid, object, object, object>;
21
- ProgressViewIOS: Styled<"native", typeof import("react-native").ProgressViewIOS, object, object, object>;
22
- RefreshControl: Styled<"native", typeof import("react-native").RefreshControl, object, object, object>;
23
- SafeAreaView: Styled<"native", typeof import("react-native").SafeAreaView, object, object, object>;
24
- ScrollView: Styled<"native", typeof import("react-native").ScrollView, object, object, object>;
25
- SectionList: Styled<"native", typeof import("react-native").SectionList, object, object, object>;
26
- Slider: Styled<"native", typeof import("react-native").Slider, object, object, object>;
27
- Switch: Styled<"native", typeof import("react-native").Switch, object, object, object>;
28
- Text: Styled<"native", typeof import("react-native").Text, object, object, object>;
29
- TextInput: Styled<"native", typeof import("react-native").TextInput, object, object, object>;
30
- TouchableHighlight: Styled<"native", typeof import("react-native").TouchableHighlight, object, object, object>;
31
- TouchableOpacity: Styled<"native", typeof import("react-native").TouchableOpacity, object, object, object>;
32
- View: Styled<"native", typeof import("react-native").View, object, object, object>;
33
- VirtualizedList: Styled<"native", typeof import("react-native").VirtualizedList, object, object, object>;
9
+ ActivityIndicator: Styled<"native", typeof import("react-native").ActivityIndicator, import("react-native").ActivityIndicatorProps, object, object>;
10
+ Button: Styled<"native", typeof import("react-native").Button, import("react-native").ButtonProps, object, object>;
11
+ DatePickerIOS: Styled<"native", typeof import("react-native").DatePickerIOS, import("react-native").DatePickerIOSProps, object, object>;
12
+ DrawerLayoutAndroid: Styled<"native", typeof import("react-native").DrawerLayoutAndroid, import("react-native").DrawerLayoutAndroidProps, object, object>;
13
+ FlatList: Styled<"native", typeof import("react-native").FlatList, import("react-native").FlatListProps<unknown>, object, object>;
14
+ Image: Styled<"native", typeof import("react-native").Image, import("react-native").ImageProps, object, object>;
15
+ ImageBackground: Styled<"native", typeof import("react-native").ImageBackground, import("react-native").ImageBackgroundProps, object, object>;
16
+ KeyboardAvoidingView: Styled<"native", typeof import("react-native").KeyboardAvoidingView, import("react-native").KeyboardAvoidingViewProps, object, object>;
17
+ Modal: Styled<"native", typeof import("react-native").Modal, import("react-native").ModalBaseProps & import("react-native").ModalPropsIOS & import("react-native").ModalPropsAndroid & import("react-native").ViewProps, object, object>;
18
+ 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, object>;
19
+ ProgressBarAndroid: Styled<"native", typeof import("react-native").ProgressBarAndroid, import("react-native").ProgressBarAndroidProps, object, object>;
20
+ ProgressViewIOS: Styled<"native", typeof import("react-native").ProgressViewIOS, import("react-native").ProgressViewIOSProps, object, object>;
21
+ RefreshControl: Styled<"native", typeof import("react-native").RefreshControl, import("react-native").RefreshControlProps, object, object>;
22
+ SafeAreaView: Styled<"native", typeof import("react-native").SafeAreaView, import("react-native").ViewProps, object, object>;
23
+ ScrollView: Styled<"native", typeof import("react-native").ScrollView, import("react-native").ScrollViewProps, object, object>;
24
+ SectionList: Styled<"native", typeof import("react-native").SectionList, import("react-native").SectionListProps<unknown, unknown>, object, object>;
25
+ Slider: Styled<"native", typeof import("react-native").Slider, import("react-native").SliderProps, object, object>;
26
+ Switch: Styled<"native", typeof import("react-native").Switch, import("react-native").SwitchProps, object, object>;
27
+ Text: Styled<"native", typeof import("react-native").Text, import("react-native").TextProps, object, object>;
28
+ TextInput: Styled<"native", typeof import("react-native").TextInput, import("react-native").TextInputProps, object, object>;
29
+ TouchableHighlight: Styled<"native", typeof import("react-native").TouchableHighlight, import("react-native").TouchableHighlightProps, object, object>;
30
+ TouchableOpacity: Styled<"native", typeof import("react-native").TouchableOpacity, import("react-native").TouchableOpacityProps, object, object>;
31
+ View: Styled<"native", typeof import("react-native").View, import("react-native").ViewProps, object, object>;
32
+ VirtualizedList: Styled<"native", typeof import("react-native").VirtualizedList, import("react-native").VirtualizedListProps<unknown>, object, object>;
34
33
  };
35
34
  export { DefaultTheme, ExecutionContext, ExecutionProps, IStyledComponent, IStyledComponentFactory, IStyledStatics, NativeTarget, PolymorphicComponent, PolymorphicComponentProps, Runtime, StyledObject, StyledOptions, } from '../types';
36
35
  export { css, isStyledComponent, ThemeProvider, ThemeConsumer, ThemeContext, withTheme, useTheme };
@@ -5,7 +5,7 @@ export declare const makeGroupedTag: (tag: Tag) => {
5
5
  length: number;
6
6
  tag: Tag;
7
7
  indexOfGroup(group: number): number;
8
- insertRules(group: number, rules: string | string[]): void;
8
+ insertRules(group: number, rules: string[]): void;
9
9
  clearGroup(group: number): void;
10
10
  getGroup(group: number): string;
11
11
  };
@@ -1,13 +1,13 @@
1
1
  import { GroupedTag, Sheet, SheetOptions } from './types';
2
- declare type SheetConstructorArgs = {
2
+ type SheetConstructorArgs = {
3
3
  isServer?: boolean;
4
4
  useCSSOMInjection?: boolean;
5
5
  target?: HTMLElement;
6
6
  };
7
- declare type GlobalStylesAllocationMap = {
7
+ type GlobalStylesAllocationMap = {
8
8
  [key: string]: number;
9
9
  };
10
- declare type NamesAllocationMap = Map<string, Set<string>>;
10
+ type NamesAllocationMap = Map<string, Set<string>>;
11
11
  /** Contains the main stylesheet logic for stringification and caching */
12
12
  export default class StyleSheet implements Sheet {
13
13
  gs: GlobalStylesAllocationMap;
@@ -14,7 +14,7 @@ export interface GroupedTag {
14
14
  length: number;
15
15
  tag: Tag;
16
16
  }
17
- export declare type SheetOptions = {
17
+ export type SheetOptions = {
18
18
  isServer: boolean;
19
19
  target?: HTMLElement;
20
20
  useCSSOMInjection: boolean;