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
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import ComponentStyle from './models/ComponentStyle';
3
3
  import { DefaultTheme } from './models/ThemeProvider';
4
4
  import createWarnTooManyClasses from './utils/createWarnTooManyClasses';
5
- interface ExoticComponentWithDisplayName<P = unknown> extends React.ExoticComponent<P> {
5
+ interface ExoticComponentWithDisplayName<P = any> extends React.ExoticComponent<P> {
6
6
  defaultProps?: Partial<P>;
7
7
  displayName?: string;
8
8
  }
@@ -12,7 +12,7 @@ export declare type OmitNever<T> = {
12
12
  export declare type Runtime = 'web' | 'native';
13
13
  export { DefaultTheme };
14
14
  export declare type AnyComponent<P = any> = ExoticComponentWithDisplayName<P> | React.ComponentType<P>;
15
- export interface StyledOptions<R extends Runtime, Props> {
15
+ export interface StyledOptions<R extends Runtime, Props extends object> {
16
16
  attrs?: Attrs<Props>[];
17
17
  componentId?: R extends 'web' ? string : never;
18
18
  displayName?: string;
@@ -22,26 +22,34 @@ export interface StyledOptions<R extends Runtime, Props> {
22
22
  export declare type KnownTarget = keyof JSX.IntrinsicElements | AnyComponent;
23
23
  export declare type WebTarget = string | KnownTarget;
24
24
  export declare type NativeTarget = AnyComponent;
25
- export interface BaseExtensibleObject {
26
- [key: string]: any;
27
- }
28
- export interface ExtensibleObject extends BaseExtensibleObject {
29
- $as?: KnownTarget;
30
- $forwardedAs?: KnownTarget;
25
+ export declare type Dict<T> = {
26
+ [key: string]: T;
27
+ };
28
+ export interface ExecutionProps {
29
+ /**
30
+ * Dynamically adjust the rendered component or HTML tag, e.g.
31
+ * ```
32
+ * const StyledButton = styled.button``
33
+ *
34
+ * <StyledButton as="a" href="/foo">
35
+ * I'm an anchor now
36
+ * </StyledButton>
37
+ * ```
38
+ */
31
39
  as?: KnownTarget;
32
40
  forwardedAs?: KnownTarget;
33
41
  theme?: DefaultTheme;
34
42
  }
35
- export interface ExecutionContext extends ExtensibleObject {
43
+ export interface ExecutionContext extends ExecutionProps {
36
44
  theme: DefaultTheme;
37
45
  }
38
- export interface StyleFunction<Props = BaseExtensibleObject> {
46
+ export interface StyleFunction<Props extends object> {
39
47
  (executionContext: ExecutionContext & Props): Interpolation<Props>;
40
48
  }
41
- export declare type Interpolation<Props> = StyleFunction<Props> | StyledObject<Props> | TemplateStringsArray | string | number | undefined | null | Keyframes | IStyledComponent<'web', any, any> | Interpolation<Props>[];
42
- export declare type Attrs<Props> = (ExtensibleObject & Props) | ((props: ExecutionContext & Props) => Partial<Props>);
43
- export declare type RuleSet<Props> = Interpolation<Props>[];
44
- export declare type Styles<Props> = TemplateStringsArray | StyledObject<Props> | StyleFunction<Props>;
49
+ export declare type Interpolation<Props extends object> = StyleFunction<Props> | StyledObject<Props> | TemplateStringsArray | string | number | false | undefined | null | Keyframes | IStyledComponent<'web', any, any> | Interpolation<Props>[];
50
+ export declare type Attrs<Props extends object> = (ExecutionProps & Props) | ((props: ExecutionContext & Props) => Partial<Props>);
51
+ export declare type RuleSet<Props extends object> = Interpolation<ExecutionContext & Props>[];
52
+ export declare type Styles<Props extends object> = TemplateStringsArray | StyledObject<Props> | StyleFunction<Props>;
45
53
  export declare type NameGenerator = (hash: number) => string;
46
54
  export interface StyleSheet {
47
55
  create: Function;
@@ -51,58 +59,56 @@ export interface Keyframes {
51
59
  name: string;
52
60
  rules: string;
53
61
  }
54
- export interface Flattener<Props> {
62
+ export interface Flattener<Props extends object> {
55
63
  (chunks: Interpolation<Props>[], executionContext: Object | null | undefined, styleSheet: Object | null | undefined): Interpolation<Props>[];
56
64
  }
57
- export declare type FlattenerResult<Props> = RuleSet<Props> | number | string | string[] | IStyledComponent<any, any> | Keyframes;
65
+ export declare type FlattenerResult<Props extends object> = RuleSet<Props> | number | string | string[] | IStyledComponent<any, any, any> | Keyframes;
58
66
  export interface Stringifier {
59
67
  (css: string, selector?: string, prefix?: string, componentId?: string): string[];
60
68
  hash: string;
61
69
  }
62
70
  export interface ShouldForwardProp<R extends Runtime> {
63
- (prop: string, elementToBeCreated?: StyledTarget<R>): boolean;
71
+ (prop: string, elementToBeCreated: StyledTarget<R>): boolean;
64
72
  }
65
- export interface CommonStatics<R extends Runtime, Props> {
73
+ export interface CommonStatics<R extends Runtime, Props extends object> {
66
74
  attrs: Attrs<Props>[];
67
75
  target: StyledTarget<R>;
68
76
  shouldForwardProp?: ShouldForwardProp<R>;
69
77
  withComponent: any;
70
78
  }
71
- export interface IStyledStatics<R extends Runtime, OuterProps = unknown> extends CommonStatics<R, OuterProps> {
79
+ export interface IStyledStatics<R extends Runtime, OuterProps extends object> extends CommonStatics<R, OuterProps> {
72
80
  componentStyle: R extends 'web' ? ComponentStyle : never;
73
81
  foldedComponentIds: R extends 'web' ? Array<string> : never;
74
82
  inlineStyle: R extends 'native' ? InstanceType<IInlineStyleConstructor<OuterProps>> : never;
75
83
  target: StyledTarget<R>;
76
84
  styledComponentId: R extends 'web' ? string : never;
77
85
  warnTooManyClasses?: R extends 'web' ? ReturnType<typeof createWarnTooManyClasses> : never;
78
- withComponent: <Target extends StyledTarget<R>, Props = unknown>(tag: Target) => IStyledComponent<R, Target, OuterProps & Props>;
79
- }
80
- declare type PolymorphicComponentProps<R extends Runtime, ActualComponent extends StyledTarget<R>, PropsToBeInjectedIntoActualComponent extends {}, ActualComponentProps = ActualComponent extends KnownTarget ? React.ComponentPropsWithRef<ActualComponent> : {}> = React.HTMLAttributes<ActualComponent> & Omit<PropsToBeInjectedIntoActualComponent, keyof ActualComponentProps | 'as' | '$as'> & ActualComponentProps & ({
81
- $as: ActualComponent;
82
- as?: AnyComponent;
83
- } | {
84
- as?: ActualComponent;
85
- });
86
- interface PolymorphicComponent<R extends Runtime, FallbackComponent extends StyledTarget<R>, ExpectedProps = unknown, PropsToBeInjectedIntoActualComponent = unknown> extends React.ForwardRefExoticComponent<ExpectedProps> {
87
- <ActualComponent extends StyledTarget<R> = FallbackComponent>(props: PolymorphicComponentProps<R, ActualComponent, ExpectedProps & PropsToBeInjectedIntoActualComponent>): React.ReactElement<PolymorphicComponentProps<R, ActualComponent, ExecutionContext & ExpectedProps & PropsToBeInjectedIntoActualComponent>, ActualComponent>;
88
- }
89
- export interface IStyledComponent<R extends Runtime, Target extends StyledTarget<R>, Props = unknown> extends PolymorphicComponent<R, Target, Props, ExecutionContext>, IStyledStatics<R, Props> {
90
- defaultProps?: Partial<ExtensibleObject & (Target extends KnownTarget ? React.ComponentProps<Target> : {}) & Props>;
86
+ withComponent: <Target extends StyledTarget<R>, Props extends object = object>(tag: Target) => IStyledComponent<R, Target, OuterProps & Props>;
87
+ }
88
+ declare type PolymorphicComponentProps<R extends Runtime, E extends StyledTarget<R>, P extends object> = {
89
+ as?: E;
90
+ theme?: DefaultTheme;
91
+ } & P & (E extends KnownTarget ? Omit<React.ComponentProps<E>, keyof P | 'as'> : object);
92
+ interface PolymorphicComponent<R extends Runtime, P extends object, FallbackComponent extends StyledTarget<R>> extends React.ForwardRefExoticComponent<P> {
93
+ <E extends StyledTarget<R> = FallbackComponent>(props: PolymorphicComponentProps<R, E, P>): React.ReactElement | null;
94
+ }
95
+ export interface IStyledComponent<R extends Runtime, Target extends StyledTarget<R>, Props extends object> extends PolymorphicComponent<R, Props, Target>, IStyledStatics<R, Props> {
96
+ defaultProps?: Partial<ExecutionProps & (Target extends KnownTarget ? React.ComponentProps<Target> : {}) & Props>;
91
97
  toString: () => string;
92
98
  }
93
- export interface IStyledComponentFactory<R extends Runtime, Target extends StyledTarget<R>, Props = unknown, Statics = unknown> {
94
- (target: Target, options: StyledOptions<R, Props>, rules: RuleSet<Props>): IStyledComponent<R, Target, Props> & Statics;
99
+ export interface IStyledComponentFactory<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object, OuterStatics extends object = object> {
100
+ <Props extends object = object, Statics extends object = object>(target: Target, options: StyledOptions<R, OuterProps>, rules: RuleSet<OuterProps & Props>): IStyledComponent<R, Target, OuterProps & Props> & OuterStatics & Statics;
95
101
  }
96
- export interface IInlineStyleConstructor<Props = unknown> {
102
+ export interface IInlineStyleConstructor<Props extends object> {
97
103
  new (rules: RuleSet<Props>): IInlineStyle<Props>;
98
104
  }
99
- export interface IInlineStyle<Props = unknown> {
105
+ export interface IInlineStyle<Props extends object> {
100
106
  rules: RuleSet<Props>;
101
107
  generateStyleObject(executionContext: Object): Object;
102
108
  }
103
109
  export declare type StyledTarget<R extends Runtime> = R extends 'web' ? WebTarget : NativeTarget;
104
- export interface StyledObject<Props = ExecutionContext> {
105
- [key: string]: BaseExtensibleObject | string | number | StyleFunction<Props>;
110
+ export interface StyledObject<Props extends object = ExecutionContext> {
111
+ [key: string]: Dict<any> | string | number | StyleFunction<Props>;
106
112
  }
107
113
  /**
108
114
  * Override DefaultTheme to get accurate typings for your project.
@@ -126,4 +132,4 @@ export interface StyledObject<Props = ExecutionContext> {
126
132
  * }
127
133
  * ```
128
134
  */
129
- export declare type CSSProp = string | StyledObject | StyleFunction;
135
+ export declare type CSSProp = string | StyledObject | StyleFunction<any>;
@@ -1,2 +1,2 @@
1
- import { ExtensibleObject } from '../types';
2
- export default function determineTheme(props: ExtensibleObject, providedTheme: any, defaultProps?: any): any;
1
+ import { ExecutionProps } from '../types';
2
+ export default function determineTheme(props: ExecutionProps, providedTheme: any, defaultProps?: any): any;
@@ -1,3 +1,3 @@
1
- import { ExtensibleObject } from '../types';
1
+ import { Dict } from '../types';
2
2
  export declare const EMPTY_ARRAY: readonly any[];
3
- export declare const EMPTY_OBJECT: Readonly<ExtensibleObject>;
3
+ export declare const EMPTY_OBJECT: Readonly<Dict<any>>;
@@ -1,4 +1,4 @@
1
1
  import StyleSheet from '../sheet';
2
- import { ExecutionContext, ExtensibleObject, Interpolation, Stringifier } from '../types';
3
- export declare const objToCssArray: (obj: ExtensibleObject, prevKey?: string) => string[];
4
- export default function flatten<Props = unknown>(chunk: Interpolation<Props>, executionContext?: ExecutionContext & Props, styleSheet?: StyleSheet, stylisInstance?: Stringifier): Interpolation<Props>;
2
+ import { Dict, ExecutionContext, Interpolation, RuleSet, Stringifier } from '../types';
3
+ export declare const objToCssArray: (obj: Dict<any>, prevKey?: string) => string[];
4
+ export default function flatten<Props extends object>(chunk: Interpolation<Props>, executionContext?: ExecutionContext & Props, styleSheet?: StyleSheet, stylisInstance?: Stringifier): Interpolation<Props> | RuleSet<Props>;
@@ -1,2 +1,2 @@
1
1
  import { Interpolation } from '../types';
2
- export default function interleave<Props = unknown>(strings: TemplateStringsArray, interpolations: Interpolation<Props>[]): Interpolation<Props>[];
2
+ export default function interleave<Props extends object>(strings: TemplateStringsArray, interpolations: Interpolation<Props>[]): Interpolation<Props>[];
@@ -1,2 +1,2 @@
1
1
  import { RuleSet } from '../types';
2
- export default function isStaticRules<Props = unknown>(rules: RuleSet<Props>): boolean;
2
+ export default function isStaticRules<Props extends object>(rules: RuleSet<Props>): boolean;
@@ -1,2 +1,2 @@
1
1
  import { IStyledComponent } from '../types';
2
- export default function isStyledComponent(target: any): target is IStyledComponent<'web', any>;
2
+ export default function isStyledComponent(target: any): target is IStyledComponent<'web', any, any>;
@@ -1,7 +1,7 @@
1
- import { ExtensibleObject } from '../types';
1
+ import { ExecutionProps } from '../types';
2
2
  /**
3
3
  * Arrays & POJOs merged recursively, other objects and value types are overridden
4
4
  * If target is not a POJO or an Array, it will get source properties injected via shallow merge
5
5
  * Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
6
6
  */
7
- export default function mixinDeep(target?: ExtensibleObject, ...sources: any[]): ExtensibleObject;
7
+ export default function mixinDeep(target?: ExecutionProps, ...sources: any[]): ExecutionProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styled-components",
3
- "version": "6.0.0-beta.2",
3
+ "version": "6.0.0-beta.3",
4
4
  "description": "Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/styled-components.cjs.js",
@@ -134,7 +134,7 @@
134
134
  "rollup-plugin-sourcemaps": "^0.6.3",
135
135
  "rollup-plugin-terser": "^7.0.2",
136
136
  "stylis-plugin-rtl": "^2.1.1",
137
- "typescript": "^4.7.4",
137
+ "typescript": "^4.8.3",
138
138
  "utility-types": "^3.10.0"
139
139
  },
140
140
  "bundlewatch": {