styled-components 6.0.0-rc.2-4007 → 6.0.0-rc.4
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 +13 -35
- package/dist/constructors/css.d.ts +2 -2
- package/dist/constructors/keyframes.d.ts +1 -1
- package/dist/constructors/styled.d.ts +522 -176
- package/dist/hoc/withTheme.d.ts +1 -1
- package/dist/models/Keyframes.d.ts +0 -1
- package/dist/models/ServerStyleSheet.d.ts +2 -1
- package/dist/models/StyledComponent.d.ts +2 -2
- package/dist/models/StyledNativeComponent.d.ts +2 -2
- package/dist/models/ThemeProvider.d.ts +8 -1
- package/dist/native/index.d.ts +25 -25
- package/dist/sheet/Sheet.d.ts +0 -2
- package/dist/styled-components.browser.cjs.js +1 -1
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +1 -1
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +1 -1
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +1 -1
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +91 -50
- 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 +522 -176
- package/dist/test/veryLargeUnionType.d.ts +1 -1
- package/dist/types.d.ts +41 -35
- package/dist/utils/errors.d.ts +1 -0
- package/dist/utils/isStyledComponent.d.ts +2 -2
- package/dist/utils/joinStrings.d.ts +1 -1
- package/dist/utils/setToString.d.ts +17 -0
- package/dist/utils/stylis.d.ts +2 -2
- package/native/dist/constructors/constructWithOptions.d.ts +13 -35
- 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 +522 -176
- package/native/dist/hoc/withTheme.d.ts +1 -1
- package/native/dist/models/Keyframes.d.ts +0 -1
- package/native/dist/models/ServerStyleSheet.d.ts +2 -1
- package/native/dist/models/StyledComponent.d.ts +2 -2
- package/native/dist/models/StyledNativeComponent.d.ts +2 -2
- package/native/dist/models/ThemeProvider.d.ts +8 -1
- package/native/dist/native/index.d.ts +25 -25
- package/native/dist/sheet/Sheet.d.ts +0 -2
- package/native/dist/styled-components.native.cjs.js +1 -1
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +1 -1
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/test/utils.d.ts +522 -176
- package/native/dist/test/veryLargeUnionType.d.ts +1 -1
- package/native/dist/types.d.ts +41 -35
- package/native/dist/utils/errors.d.ts +1 -0
- package/native/dist/utils/isStyledComponent.d.ts +2 -2
- package/native/dist/utils/joinStrings.d.ts +1 -1
- package/native/dist/utils/setToString.d.ts +17 -0
- package/native/dist/utils/stylis.d.ts +2 -2
- package/package.json +8 -3
- package/test-utils/index.ts +3 -6
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,40 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import { Attrs,
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Attrs, BaseObject, ExecutionProps, Interpolation, IStyledComponent, IStyledComponentFactory, KnownTarget, NoInfer, Runtime, StyledOptions, StyledTarget, Styles, Substitute } from '../types';
|
|
3
|
+
type AttrsResult<T extends Attrs<any>> = T extends (...args: any) => infer P ? P extends object ? P : never : T extends object ? T : never;
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Based on Attrs being a simple object or function that returns
|
|
6
|
+
* a prop object, inspect the attrs result and attempt to extract
|
|
7
|
+
* any "as" prop usage to modify the runtime target.
|
|
5
8
|
*/
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* If attrs type is a function (no type provided, inferring from usage), extract the return value
|
|
13
|
-
* and merge it with the existing type to hole-punch any required fields that are satisfied as
|
|
14
|
-
* a result of running attrs. Otherwise if we have a definite type then union the base props
|
|
15
|
-
* with the passed attr type to capture any intended overrides.
|
|
16
|
-
*/
|
|
17
|
-
type PropsSatisfiedByAttrs<T extends Attrs, Props extends object, Result extends ExecutionProps = AttrsResult<T>> = Omit<Props, keyof Result> & OptionalIntersection<Props, Result> & Partial<Omit<Result, keyof Props | 'as'>>;
|
|
18
|
-
/**
|
|
19
|
-
* Rejects an attr factory function argument (T) if it returns any properties not defined in Props.
|
|
20
|
-
*/
|
|
21
|
-
type StrictAttrFactory<T, Props> = T extends ((props: ExecutionContext & Props) => infer TResult) ? TResult extends SubsetOnly<TResult, (Partial<Props> & ExecutionProps & DataAttributes & React.AriaAttributes)> ? (props: ExecutionContext & Props) => TResult : never : never;
|
|
22
|
-
export interface Styled<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object = object, OuterStatics extends object = object, RuntimeInjectedProps extends ExecutionProps = object> {
|
|
23
|
-
<Props extends object = object, Statics extends object = object>(initialStyles: Styles<OuterProps & RuntimeInjectedProps & NoInfer<Props>>, ...interpolations: Interpolation<OuterProps & RuntimeInjectedProps & NoInfer<Props>>[]): // @ts-expect-error KnownTarget is a subset of StyledTarget<R>
|
|
24
|
-
IStyledComponent<R, ExtractAttrsTarget<R, RuntimeInjectedProps, Target>, OuterProps & Props> & OuterStatics & Statics;
|
|
25
|
-
/**
|
|
26
|
-
* This is a chainable method that attaches some props to a styled component.
|
|
27
|
-
* @param props An object containing prop values that will be merged into the rest of the component's props
|
|
28
|
-
* @argument Props Additional props being injected in `props`
|
|
29
|
-
*/
|
|
30
|
-
attrs<Props extends object = object, PropValues extends Partial<OuterProps> & ExecutionProps & DataAttributes & React.AriaAttributes & NoInfer<Props> = Partial<OuterProps> & ExecutionProps & DataAttributes & React.AriaAttributes & NoInfer<Props>>(props: PropValues & SubsetOnly<PropValues, Partial<OuterProps> & ExecutionProps & DataAttributes & React.AriaAttributes & NoInfer<Props>>): Styled<R, Target, PropsSatisfiedByAttrs<PropValues, OuterProps>, OuterStatics, Omit<RuntimeInjectedProps, keyof PropValues> & PropValues>;
|
|
31
|
-
/**
|
|
32
|
-
* This is a chainable method that attaches some props to a styled component.
|
|
33
|
-
* @param propFactory A function that receives the props that are passed into the component and computes a value, that is then going to be merged into the existing component props.
|
|
34
|
-
* @argument Props Additional props being returned by `propFactory`
|
|
35
|
-
*/
|
|
36
|
-
attrs<Props extends object = object, Factory extends ((...args: any[]) => any) = (...args: any[]) => any, TTarget extends StyledTarget<R> = ExtractAttrsTarget<R, AttrsResult<Factory>, Target>>(propFactory: Factory & StrictAttrFactory<Factory, OuterProps & NoInfer<Props>>): Styled<R, TTarget, PropsSatisfiedByAttrs<Factory, OuterProps>, OuterStatics, Omit<RuntimeInjectedProps, keyof AttrsResult<Factory>> & AttrsResult<Factory>>;
|
|
9
|
+
type AttrsTarget<R extends Runtime, T extends Attrs<any>, FallbackTarget extends StyledTarget<R>, Result extends ExecutionProps = AttrsResult<T>> = Result extends {
|
|
10
|
+
as: infer RuntimeTarget;
|
|
11
|
+
} ? RuntimeTarget extends KnownTarget ? RuntimeTarget : FallbackTarget : FallbackTarget;
|
|
12
|
+
export interface Styled<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object = Target extends KnownTarget ? React.ComponentPropsWithRef<Target> : BaseObject, OuterStatics extends object = BaseObject> {
|
|
13
|
+
<Props extends object = BaseObject, Statics extends object = BaseObject>(initialStyles: Styles<Substitute<OuterProps, NoInfer<Props>>>, ...interpolations: Interpolation<Substitute<OuterProps, NoInfer<Props>>>[]): IStyledComponent<R, Substitute<OuterProps, Props>> & OuterStatics & Statics;
|
|
14
|
+
attrs: <Props extends object = BaseObject, PrivateMergedProps extends object = Substitute<OuterProps, Props>, PrivateAttrsArg extends Attrs<PrivateMergedProps> = Attrs<PrivateMergedProps>, PrivateResolvedTarget extends StyledTarget<R> = AttrsTarget<R, PrivateAttrsArg, Target>>(attrs: PrivateAttrsArg) => Styled<R, PrivateResolvedTarget, PrivateResolvedTarget extends KnownTarget ? Substitute<Substitute<OuterProps, React.ComponentPropsWithRef<PrivateResolvedTarget>>, Props> : PrivateMergedProps, OuterStatics>;
|
|
37
15
|
withConfig: (config: StyledOptions<R, OuterProps>) => Styled<R, Target, OuterProps, OuterStatics>;
|
|
38
16
|
}
|
|
39
|
-
export default function constructWithOptions<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object = Target extends KnownTarget ? React.ComponentPropsWithRef<Target> :
|
|
17
|
+
export default function constructWithOptions<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object = Target extends KnownTarget ? React.ComponentPropsWithRef<Target> : BaseObject, OuterStatics extends object = BaseObject>(componentConstructor: IStyledComponentFactory<R, StyledTarget<R>, object, any>, tag: StyledTarget<R>, options?: StyledOptions<R, OuterProps>): Styled<R, Target, OuterProps, OuterStatics>;
|
|
40
18
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Interpolation, RuleSet, Styles } from '../types';
|
|
1
|
+
import { Interpolation, NoInfer, RuleSet, Styles } from '../types';
|
|
2
2
|
declare function css(styles: Styles<object>, ...interpolations: Interpolation<object>[]): RuleSet<object>;
|
|
3
|
-
declare function css<Props extends object>(styles: Styles<Props
|
|
3
|
+
declare function css<Props extends object>(styles: Styles<NoInfer<Props>>, ...interpolations: Interpolation<NoInfer<Props>>[]): RuleSet<NoInfer<Props>>;
|
|
4
4
|
export default css;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import Keyframes from '../models/Keyframes';
|
|
2
2
|
import { Interpolation, Styles } from '../types';
|
|
3
|
-
export default function keyframes<Props extends object =
|
|
3
|
+
export default function keyframes<Props extends object = {}>(strings: Styles<Props>, ...interpolations: Array<Interpolation<Props>>): Keyframes;
|