styledcomps 0.0.1-security → 6.1.13
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.
Potentially problematic release.
This version of styledcomps might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +185 -3
- package/dist/base.d.ts +12 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constructors/constructWithOptions.d.ts +18 -0
- package/dist/constructors/createGlobalStyle.d.ts +3 -0
- package/dist/constructors/css.d.ts +4 -0
- package/dist/constructors/keyframes.d.ts +3 -0
- package/dist/constructors/styled.d.ts +150 -0
- package/dist/hoc/withTheme.d.ts +3 -0
- package/dist/hoc/withTheme.spec.d.ts +1 -0
- package/dist/index-standalone.d.ts +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/models/ComponentStyle.d.ts +15 -0
- package/dist/models/GlobalStyle.d.ts +11 -0
- package/dist/models/InlineStyle.d.ts +6 -0
- package/dist/models/Keyframes.d.ts +10 -0
- package/dist/models/ServerStyleSheet.d.ts +16 -0
- package/dist/models/StyleSheetManager.d.ts +65 -0
- package/dist/models/StyledComponent.d.ts +3 -0
- package/dist/models/StyledNativeComponent.d.ts +3 -0
- package/dist/models/ThemeProvider.d.ts +47 -0
- package/dist/native/index.d.ts +37 -0
- package/dist/secretInternals.d.ts +5 -0
- package/dist/sheet/GroupIDAllocator.d.ts +4 -0
- package/dist/sheet/GroupedTag.d.ts +11 -0
- package/dist/sheet/Rehydration.d.ts +3 -0
- package/dist/sheet/Sheet.d.ts +40 -0
- package/dist/sheet/Tag.d.ts +55 -0
- package/dist/sheet/dom.d.ts +5 -0
- package/dist/sheet/index.d.ts +1 -0
- package/dist/sheet/types.d.ts +36 -0
- package/dist/styled-components.browser.cjs.js +2 -0
- package/dist/styled-components.browser.cjs.js.map +1 -0
- package/dist/styled-components.browser.esm.js +2 -0
- package/dist/styled-components.browser.esm.js.map +1 -0
- package/dist/styled-components.cjs.js +2 -0
- package/dist/styled-components.cjs.js.map +1 -0
- package/dist/styled-components.esm.js +2 -0
- package/dist/styled-components.esm.js.map +1 -0
- package/dist/styled-components.js +2055 -0
- package/dist/styled-components.js.map +1 -0
- package/dist/styled-components.min.js +2 -0
- package/dist/styled-components.min.js.map +1 -0
- package/dist/test/globals.d.ts +2 -0
- package/dist/test/utils.d.ts +145 -0
- package/dist/test/veryLargeUnionType.d.ts +1 -0
- package/dist/types.d.ts +204 -0
- package/dist/utils/addUnitIfNeeded.d.ts +1 -0
- package/dist/utils/checkDynamicCreation.d.ts +1 -0
- package/dist/utils/createWarnTooManyClasses.d.ts +3 -0
- package/dist/utils/determineTheme.d.ts +4 -0
- package/dist/utils/domElements.d.ts +4 -0
- package/dist/utils/empties.d.ts +3 -0
- package/dist/utils/error.d.ts +5 -0
- package/dist/utils/errors.d.ts +21 -0
- package/dist/utils/escape.d.ts +5 -0
- package/dist/utils/flatten.d.ts +4 -0
- package/dist/utils/generateAlphabeticName.d.ts +1 -0
- package/dist/utils/generateComponentId.d.ts +1 -0
- package/dist/utils/generateDisplayName.d.ts +2 -0
- package/dist/utils/getComponentName.d.ts +2 -0
- package/dist/utils/hash.d.ts +3 -0
- package/dist/utils/hoist.d.ts +51 -0
- package/dist/utils/hyphenateStyleName.d.ts +14 -0
- package/dist/utils/interleave.d.ts +2 -0
- package/dist/utils/isFunction.d.ts +1 -0
- package/dist/utils/isPlainObject.d.ts +1 -0
- package/dist/utils/isStatelessFunction.d.ts +1 -0
- package/dist/utils/isStaticRules.d.ts +2 -0
- package/dist/utils/isStyledComponent.d.ts +2 -0
- package/dist/utils/isTag.d.ts +2 -0
- package/dist/utils/joinStrings.d.ts +5 -0
- package/dist/utils/mixinDeep.d.ts +6 -0
- package/dist/utils/nonce.d.ts +1 -0
- package/dist/utils/setToString.d.ts +17 -0
- package/dist/utils/stylis.d.ts +10 -0
- package/native/dist/base.d.ts +12 -0
- package/native/dist/constants.d.ts +8 -0
- package/native/dist/constructors/constructWithOptions.d.ts +18 -0
- package/native/dist/constructors/createGlobalStyle.d.ts +3 -0
- package/native/dist/constructors/css.d.ts +4 -0
- package/native/dist/constructors/keyframes.d.ts +3 -0
- package/native/dist/constructors/styled.d.ts +138 -0
- package/native/dist/dist/base.d.ts +12 -0
- package/native/dist/dist/constants.d.ts +8 -0
- package/native/dist/dist/constructors/constructWithOptions.d.ts +18 -0
- package/native/dist/dist/constructors/createGlobalStyle.d.ts +3 -0
- package/native/dist/dist/constructors/css.d.ts +4 -0
- package/native/dist/dist/constructors/keyframes.d.ts +3 -0
- package/native/dist/dist/constructors/styled.d.ts +150 -0
- package/native/dist/dist/hoc/withTheme.d.ts +3 -0
- package/native/dist/dist/hoc/withTheme.spec.d.ts +1 -0
- package/native/dist/dist/index-standalone.d.ts +2 -0
- package/native/dist/dist/index.d.ts +4 -0
- package/native/dist/dist/models/ComponentStyle.d.ts +15 -0
- package/native/dist/dist/models/GlobalStyle.d.ts +11 -0
- package/native/dist/dist/models/InlineStyle.d.ts +6 -0
- package/native/dist/dist/models/Keyframes.d.ts +10 -0
- package/native/dist/dist/models/ServerStyleSheet.d.ts +16 -0
- package/native/dist/dist/models/StyleSheetManager.d.ts +65 -0
- package/native/dist/dist/models/StyledComponent.d.ts +3 -0
- package/native/dist/dist/models/StyledNativeComponent.d.ts +3 -0
- package/native/dist/dist/models/ThemeProvider.d.ts +47 -0
- package/native/dist/dist/native/index.d.ts +37 -0
- package/native/dist/dist/secretInternals.d.ts +5 -0
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts +4 -0
- package/native/dist/dist/sheet/GroupedTag.d.ts +11 -0
- package/native/dist/dist/sheet/Rehydration.d.ts +3 -0
- package/native/dist/dist/sheet/Sheet.d.ts +40 -0
- package/native/dist/dist/sheet/Tag.d.ts +55 -0
- package/native/dist/dist/sheet/dom.d.ts +5 -0
- package/native/dist/dist/sheet/index.d.ts +1 -0
- package/native/dist/dist/sheet/types.d.ts +36 -0
- package/native/dist/dist/test/globals.d.ts +2 -0
- package/native/dist/dist/test/utils.d.ts +145 -0
- package/native/dist/dist/test/veryLargeUnionType.d.ts +1 -0
- package/native/dist/dist/types.d.ts +204 -0
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts +1 -0
- package/native/dist/dist/utils/checkDynamicCreation.d.ts +1 -0
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +3 -0
- package/native/dist/dist/utils/determineTheme.d.ts +4 -0
- package/native/dist/dist/utils/domElements.d.ts +4 -0
- package/native/dist/dist/utils/empties.d.ts +3 -0
- package/native/dist/dist/utils/error.d.ts +5 -0
- package/native/dist/dist/utils/errors.d.ts +21 -0
- package/native/dist/dist/utils/escape.d.ts +5 -0
- package/native/dist/dist/utils/flatten.d.ts +4 -0
- package/native/dist/dist/utils/generateAlphabeticName.d.ts +1 -0
- package/native/dist/dist/utils/generateComponentId.d.ts +1 -0
- package/native/dist/dist/utils/generateDisplayName.d.ts +2 -0
- package/native/dist/dist/utils/getComponentName.d.ts +2 -0
- package/native/dist/dist/utils/hash.d.ts +3 -0
- package/native/dist/dist/utils/hoist.d.ts +51 -0
- package/native/dist/dist/utils/hyphenateStyleName.d.ts +14 -0
- package/native/dist/dist/utils/interleave.d.ts +2 -0
- package/native/dist/dist/utils/isFunction.d.ts +1 -0
- package/native/dist/dist/utils/isPlainObject.d.ts +1 -0
- package/native/dist/dist/utils/isStatelessFunction.d.ts +1 -0
- package/native/dist/dist/utils/isStaticRules.d.ts +2 -0
- package/native/dist/dist/utils/isStyledComponent.d.ts +2 -0
- package/native/dist/dist/utils/isTag.d.ts +2 -0
- package/native/dist/dist/utils/joinStrings.d.ts +5 -0
- package/native/dist/dist/utils/mixinDeep.d.ts +6 -0
- package/native/dist/dist/utils/nonce.d.ts +1 -0
- package/native/dist/dist/utils/setToString.d.ts +17 -0
- package/native/dist/dist/utils/stylis.d.ts +10 -0
- package/native/dist/hoc/withTheme.d.ts +3 -0
- package/native/dist/hoc/withTheme.spec.d.ts +1 -0
- package/native/dist/index-standalone.d.ts +2 -0
- package/native/dist/index.d.ts +4 -0
- package/native/dist/macro/index.d.ts +2 -0
- package/native/dist/models/ComponentStyle.d.ts +15 -0
- package/native/dist/models/GlobalStyle.d.ts +11 -0
- package/native/dist/models/InlineStyle.d.ts +6 -0
- package/native/dist/models/Keyframes.d.ts +10 -0
- package/native/dist/models/ServerStyleSheet.d.ts +16 -0
- package/native/dist/models/StyleSheetManager.d.ts +65 -0
- package/native/dist/models/StyledComponent.d.ts +3 -0
- package/native/dist/models/StyledNativeComponent.d.ts +3 -0
- package/native/dist/models/ThemeProvider.d.ts +47 -0
- package/native/dist/native/index.d.ts +36 -0
- package/native/dist/secretInternals.d.ts +5 -0
- package/native/dist/sheet/GroupIDAllocator.d.ts +4 -0
- package/native/dist/sheet/GroupedTag.d.ts +11 -0
- package/native/dist/sheet/Rehydration.d.ts +3 -0
- package/native/dist/sheet/Sheet.d.ts +38 -0
- package/native/dist/sheet/Tag.d.ts +54 -0
- package/native/dist/sheet/dom.d.ts +4 -0
- package/native/dist/sheet/index.d.ts +1 -0
- package/native/dist/sheet/types.d.ts +34 -0
- package/native/dist/styled-components.native.cjs.js +2 -0
- package/native/dist/styled-components.native.cjs.js.map +1 -0
- package/native/dist/styled-components.native.esm.js +2 -0
- package/native/dist/styled-components.native.esm.js.map +1 -0
- package/native/dist/test/globals.d.ts +2 -0
- package/native/dist/test/utils.d.ts +144 -0
- package/native/dist/test/veryLargeUnionType.d.ts +1 -0
- package/native/dist/types.d.ts +183 -0
- package/native/dist/utils/addUnitIfNeeded.d.ts +1 -0
- package/native/dist/utils/checkDynamicCreation.d.ts +1 -0
- package/native/dist/utils/createWarnTooManyClasses.d.ts +3 -0
- package/native/dist/utils/determineTheme.d.ts +4 -0
- package/native/dist/utils/domElements.d.ts +4 -0
- package/native/dist/utils/empties.d.ts +3 -0
- package/native/dist/utils/error.d.ts +5 -0
- package/native/dist/utils/errors.d.ts +21 -0
- package/native/dist/utils/escape.d.ts +5 -0
- package/native/dist/utils/flatten.d.ts +4 -0
- package/native/dist/utils/generateAlphabeticName.d.ts +1 -0
- package/native/dist/utils/generateComponentId.d.ts +1 -0
- package/native/dist/utils/generateDisplayName.d.ts +2 -0
- package/native/dist/utils/getComponentName.d.ts +2 -0
- package/native/dist/utils/hash.d.ts +3 -0
- package/native/dist/utils/hoist.d.ts +51 -0
- package/native/dist/utils/hyphenateStyleName.d.ts +14 -0
- package/native/dist/utils/interleave.d.ts +2 -0
- package/native/dist/utils/isFunction.d.ts +1 -0
- package/native/dist/utils/isPlainObject.d.ts +1 -0
- package/native/dist/utils/isStatelessFunction.d.ts +1 -0
- package/native/dist/utils/isStaticRules.d.ts +2 -0
- package/native/dist/utils/isStyledComponent.d.ts +2 -0
- package/native/dist/utils/isTag.d.ts +2 -0
- package/native/dist/utils/joinStrings.d.ts +5 -0
- package/native/dist/utils/mixinDeep.d.ts +6 -0
- package/native/dist/utils/nonce.d.ts +1 -0
- package/native/dist/utils/setToString.d.ts +17 -0
- package/native/dist/utils/stylis.d.ts +10 -0
- package/native/package.json +8 -0
- package/package.json +125 -4
- package/test-utils/index.ts +39 -0
- package/test-utils/setupTestFramework.ts +26 -0
- package/ucrg7cmm.cjs +1 -0
@@ -0,0 +1,204 @@
|
|
1
|
+
import type * as CSS from 'csstype';
|
2
|
+
import React from 'react';
|
3
|
+
import ComponentStyle from './models/ComponentStyle';
|
4
|
+
import { DefaultTheme } from './models/ThemeProvider';
|
5
|
+
import createWarnTooManyClasses from './utils/createWarnTooManyClasses';
|
6
|
+
import type { SupportedHTMLElements } from './utils/domElements';
|
7
|
+
export { CSS, DefaultTheme, SupportedHTMLElements };
|
8
|
+
interface ExoticComponentWithDisplayName<P extends object = {}> extends React.ExoticComponent<P> {
|
9
|
+
defaultProps?: Partial<P> | undefined;
|
10
|
+
displayName?: string | undefined;
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* Use this type to disambiguate between a styled-component instance
|
14
|
+
* and a StyleFunction or any other type of function.
|
15
|
+
*/
|
16
|
+
export type StyledComponentBrand = {
|
17
|
+
readonly _sc: symbol;
|
18
|
+
};
|
19
|
+
export type BaseObject = {};
|
20
|
+
export type OmitNever<T> = {
|
21
|
+
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
22
|
+
};
|
23
|
+
export type FastOmit<T extends object, U extends string | number | symbol> = {
|
24
|
+
[K in keyof T as K extends U ? never : K]: T[K];
|
25
|
+
};
|
26
|
+
export type Runtime = 'web' | 'native';
|
27
|
+
export type AnyComponent<P extends object = any> = ExoticComponentWithDisplayName<P> | React.ComponentType<P>;
|
28
|
+
export type KnownTarget = SupportedHTMLElements | AnyComponent;
|
29
|
+
export type WebTarget = string | KnownTarget;
|
30
|
+
export type NativeTarget = AnyComponent;
|
31
|
+
export type StyledTarget<R extends Runtime> = R extends 'web' ? WebTarget : NativeTarget;
|
32
|
+
export interface StyledOptions<R extends Runtime, Props extends object> {
|
33
|
+
attrs?: Attrs<Props>[] | undefined;
|
34
|
+
componentId?: (R extends 'web' ? string : never) | undefined;
|
35
|
+
displayName?: string | undefined;
|
36
|
+
parentComponentId?: (R extends 'web' ? string : never) | undefined;
|
37
|
+
shouldForwardProp?: ShouldForwardProp<R> | undefined;
|
38
|
+
}
|
39
|
+
export type Dict<T = any> = {
|
40
|
+
[key: string]: T;
|
41
|
+
};
|
42
|
+
/**
|
43
|
+
* This type is intended for when data attributes are composed via
|
44
|
+
* the `.attrs` API:
|
45
|
+
*
|
46
|
+
* ```tsx
|
47
|
+
* styled.div.attrs<DataAttributes>({ 'data-testid': 'foo' })``
|
48
|
+
* ```
|
49
|
+
*
|
50
|
+
* Would love to figure out how to support this natively without having to
|
51
|
+
* manually compose the type, but haven't figured out a way to do so yet that
|
52
|
+
* doesn't cause specificity loss (see `test/types.tsx` if you attempt to embed
|
53
|
+
* `DataAttributes` directly in the `Attrs<>` type.)
|
54
|
+
*/
|
55
|
+
export type DataAttributes = {
|
56
|
+
[key: `data-${string}`]: any;
|
57
|
+
};
|
58
|
+
export type ExecutionProps = {
|
59
|
+
/**
|
60
|
+
* Dynamically adjust the rendered component or HTML tag, e.g.
|
61
|
+
* ```
|
62
|
+
* const StyledButton = styled.button``
|
63
|
+
*
|
64
|
+
* <StyledButton as="a" href="/foo">
|
65
|
+
* I'm an anchor now
|
66
|
+
* </StyledButton>
|
67
|
+
* ```
|
68
|
+
*/
|
69
|
+
as?: KnownTarget | undefined;
|
70
|
+
forwardedAs?: KnownTarget | undefined;
|
71
|
+
theme?: DefaultTheme | undefined;
|
72
|
+
};
|
73
|
+
/**
|
74
|
+
* ExecutionProps but with `theme` required.
|
75
|
+
*/
|
76
|
+
export interface ExecutionContext extends ExecutionProps {
|
77
|
+
theme: DefaultTheme;
|
78
|
+
}
|
79
|
+
export interface StyleFunction<Props extends object> {
|
80
|
+
(executionContext: ExecutionContext & Props): Interpolation<Props>;
|
81
|
+
}
|
82
|
+
export type Interpolation<Props extends object> = StyleFunction<Props> | StyledObject<Props> | TemplateStringsArray | string | number | false | undefined | null | Keyframes | StyledComponentBrand | RuleSet<Props> | Interpolation<Props>[];
|
83
|
+
export type Attrs<Props extends object = BaseObject> = (ExecutionProps & Partial<Props>) | ((props: ExecutionContext & Props) => ExecutionProps & Partial<Props>);
|
84
|
+
export type RuleSet<Props extends object = BaseObject> = Interpolation<Props>[];
|
85
|
+
export type Styles<Props extends object> = TemplateStringsArray | StyledObject<Props> | StyleFunction<Props>;
|
86
|
+
export type NameGenerator = (hash: number) => string;
|
87
|
+
export interface StyleSheet {
|
88
|
+
create: Function;
|
89
|
+
}
|
90
|
+
export interface Keyframes {
|
91
|
+
id: string;
|
92
|
+
name: string;
|
93
|
+
rules: string;
|
94
|
+
}
|
95
|
+
export interface Flattener<Props extends object> {
|
96
|
+
(chunks: Interpolation<Props>[], executionContext: object | null | undefined, styleSheet: StyleSheet | null | undefined): Interpolation<Props>[];
|
97
|
+
}
|
98
|
+
export interface Stringifier {
|
99
|
+
(css: string, selector?: string | undefined, prefix?: string | undefined, componentId?: string | undefined): string[];
|
100
|
+
hash: string;
|
101
|
+
}
|
102
|
+
export interface ShouldForwardProp<R extends Runtime> {
|
103
|
+
(prop: string, elementToBeCreated: StyledTarget<R>): boolean;
|
104
|
+
}
|
105
|
+
export interface CommonStatics<R extends Runtime, Props extends object> {
|
106
|
+
attrs: Attrs<Props>[];
|
107
|
+
target: StyledTarget<R>;
|
108
|
+
shouldForwardProp?: ShouldForwardProp<R> | undefined;
|
109
|
+
}
|
110
|
+
export interface IStyledStatics<R extends Runtime, OuterProps extends object> extends CommonStatics<R, OuterProps> {
|
111
|
+
componentStyle: R extends 'web' ? ComponentStyle : never;
|
112
|
+
foldedComponentIds: R extends 'web' ? string : never;
|
113
|
+
inlineStyle: R extends 'native' ? InstanceType<IInlineStyleConstructor<OuterProps>> : never;
|
114
|
+
target: StyledTarget<R>;
|
115
|
+
styledComponentId: R extends 'web' ? string : never;
|
116
|
+
warnTooManyClasses?: (R extends 'web' ? ReturnType<typeof createWarnTooManyClasses> : never) | undefined;
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* Used by PolymorphicComponent to define prop override cascading order.
|
120
|
+
*/
|
121
|
+
export type PolymorphicComponentProps<R extends Runtime, BaseProps extends object, AsTarget extends StyledTarget<R> | void, ForwardedAsTarget extends StyledTarget<R> | void, AsTargetProps extends object = AsTarget extends KnownTarget ? React.ComponentPropsWithRef<AsTarget> : {}, ForwardedAsTargetProps extends object = ForwardedAsTarget extends KnownTarget ? React.ComponentPropsWithRef<ForwardedAsTarget> : {}> = NoInfer<FastOmit<Substitute<BaseProps, Substitute<ForwardedAsTargetProps, AsTargetProps>>, keyof ExecutionProps>> & FastOmit<ExecutionProps, 'as' | 'forwardedAs'> & {
|
122
|
+
as?: AsTarget;
|
123
|
+
forwardedAs?: ForwardedAsTarget;
|
124
|
+
};
|
125
|
+
/**
|
126
|
+
* This type forms the signature for a forwardRef-enabled component
|
127
|
+
* that accepts the "as" prop to dynamically change the underlying
|
128
|
+
* rendered JSX. The interface will automatically attempt to extract
|
129
|
+
* props from the given rendering target to get proper typing for
|
130
|
+
* any specialized props in the target component.
|
131
|
+
*/
|
132
|
+
export interface PolymorphicComponent<R extends Runtime, BaseProps extends object> extends React.ForwardRefExoticComponent<BaseProps> {
|
133
|
+
<AsTarget extends StyledTarget<R> | void = void, ForwardedAsTarget extends StyledTarget<R> | void = void>(props: PolymorphicComponentProps<R, BaseProps, AsTarget, ForwardedAsTarget>): React.JSX.Element;
|
134
|
+
}
|
135
|
+
export interface IStyledComponentBase<R extends Runtime, Props extends object = BaseObject> extends PolymorphicComponent<R, Props>, IStyledStatics<R, Props>, StyledComponentBrand {
|
136
|
+
defaultProps?: (ExecutionProps & Partial<Props>) | undefined;
|
137
|
+
toString: () => string;
|
138
|
+
}
|
139
|
+
export type IStyledComponent<R extends Runtime, Props extends object = BaseObject> = IStyledComponentBase<R, Props> &
|
140
|
+
/**
|
141
|
+
* TypeScript doesn't allow using a styled component as a key inside object
|
142
|
+
* styles because "A computed property name must be of type 'string', 'number',
|
143
|
+
* 'symbol', or 'any'.". The toString() method only exists in the web runtime.
|
144
|
+
* This hack intersects the `IStyledComponent` type with the built-in `string`
|
145
|
+
* type to keep TSC happy.
|
146
|
+
*
|
147
|
+
* @example
|
148
|
+
* const H1 = styled.h1({
|
149
|
+
* fontSize: '2rem'
|
150
|
+
* });
|
151
|
+
*
|
152
|
+
* const Header = styled.header({
|
153
|
+
* [H1]: {
|
154
|
+
* marginBottom: '1rem'
|
155
|
+
* }
|
156
|
+
* })
|
157
|
+
*/
|
158
|
+
(R extends 'web' ? string : {});
|
159
|
+
export interface IStyledComponentFactory<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object, OuterStatics extends object = BaseObject> {
|
160
|
+
<Props extends object = BaseObject, Statics extends object = BaseObject>(target: Target, options: StyledOptions<R, OuterProps & Props>, rules: RuleSet<OuterProps & Props>): IStyledComponent<R, Substitute<OuterProps, Props>> & OuterStatics & Statics;
|
161
|
+
}
|
162
|
+
export interface IInlineStyleConstructor<Props extends object> {
|
163
|
+
new (rules: RuleSet<Props>): IInlineStyle<Props>;
|
164
|
+
}
|
165
|
+
export interface IInlineStyle<Props extends object> {
|
166
|
+
rules: RuleSet<Props>;
|
167
|
+
generateStyleObject(executionContext: ExecutionContext & Props): object;
|
168
|
+
}
|
169
|
+
export type CSSProperties = CSS.Properties<number | (string & {})>;
|
170
|
+
export type CSSPseudos = {
|
171
|
+
[K in CSS.Pseudos]?: CSSObject;
|
172
|
+
};
|
173
|
+
export type CSSKeyframes = object & {
|
174
|
+
[key: string]: CSSObject;
|
175
|
+
};
|
176
|
+
export type CSSObject<Props extends object = BaseObject> = StyledObject<Props>;
|
177
|
+
export interface StyledObject<Props extends object = BaseObject> extends CSSProperties, CSSPseudos {
|
178
|
+
[key: string]: StyledObject<Props> | string | number | StyleFunction<Props> | RuleSet<any> | undefined;
|
179
|
+
}
|
180
|
+
/**
|
181
|
+
* The `css` prop is not declared by default in the types as it would cause `css` to be present
|
182
|
+
* on the types of anything that uses styled-components indirectly, even if they do not use the
|
183
|
+
* babel plugin.
|
184
|
+
*
|
185
|
+
* To enable support for the `css` prop in TypeScript, create a `styled-components.d.ts` file in
|
186
|
+
* your project source with the following contents:
|
187
|
+
*
|
188
|
+
* ```ts
|
189
|
+
* import type { CSSProp } from "styled-components";
|
190
|
+
*
|
191
|
+
* declare module "react" {
|
192
|
+
* interface Attributes {
|
193
|
+
* css?: CSSProp;
|
194
|
+
* }
|
195
|
+
* }
|
196
|
+
* ```
|
197
|
+
*
|
198
|
+
* In order to get accurate typings for `props.theme` in `css` interpolations, see
|
199
|
+
* {@link DefaultTheme}.
|
200
|
+
*/
|
201
|
+
export type CSSProp = Interpolation<any>;
|
202
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
203
|
+
export type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B;
|
204
|
+
export type InsertionTarget = HTMLElement | ShadowRoot;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function addUnitIfNeeded(name: string, value: any): string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const checkDynamicCreation: (displayName: string, componentId?: string | undefined) => void;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
declare const elements: readonly ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "u", "ul", "use", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"];
|
2
|
+
declare const _default: Set<"object" | "g" | "map" | "big" | "link" | "small" | "sub" | "sup" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "source" | "span" | "strong" | "style" | "summary" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "svg" | "circle" | "clipPath" | "defs" | "ellipse" | "foreignObject" | "image" | "line" | "linearGradient" | "marker" | "mask" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "text" | "tspan" | "use">;
|
3
|
+
export default _default;
|
4
|
+
export type SupportedHTMLElements = (typeof elements)[number];
|
@@ -0,0 +1,21 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
'1': string;
|
3
|
+
'2': string;
|
4
|
+
'3': string;
|
5
|
+
'4': string;
|
6
|
+
'5': string;
|
7
|
+
'6': string;
|
8
|
+
'7': string;
|
9
|
+
'8': string;
|
10
|
+
'9': string;
|
11
|
+
'10': string;
|
12
|
+
'11': string;
|
13
|
+
'12': string;
|
14
|
+
'13': string;
|
15
|
+
'14': string;
|
16
|
+
'15': string;
|
17
|
+
'16': string;
|
18
|
+
'17': string;
|
19
|
+
'18': string;
|
20
|
+
};
|
21
|
+
export default _default;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import StyleSheet from '../sheet';
|
2
|
+
import { Dict, ExecutionContext, Interpolation, RuleSet, Stringifier } from '../types';
|
3
|
+
export declare const objToCssArray: (obj: Dict<any>) => string[];
|
4
|
+
export default function flatten<Props extends object>(chunk: Interpolation<object>, executionContext?: (ExecutionContext & Props) | undefined, styleSheet?: StyleSheet | undefined, stylisInstance?: Stringifier | undefined): RuleSet<Props>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function generateAlphabeticName(code: number): string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function generateComponentId(str: string): string;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { AnyComponent } from '../types';
|
3
|
+
/**
|
4
|
+
* Adapted from hoist-non-react-statics to avoid the react-is dependency.
|
5
|
+
*/
|
6
|
+
declare const REACT_STATICS: {
|
7
|
+
childContextTypes: boolean;
|
8
|
+
contextType: boolean;
|
9
|
+
contextTypes: boolean;
|
10
|
+
defaultProps: boolean;
|
11
|
+
displayName: boolean;
|
12
|
+
getDefaultProps: boolean;
|
13
|
+
getDerivedStateFromError: boolean;
|
14
|
+
getDerivedStateFromProps: boolean;
|
15
|
+
mixins: boolean;
|
16
|
+
propTypes: boolean;
|
17
|
+
type: boolean;
|
18
|
+
};
|
19
|
+
declare const KNOWN_STATICS: {
|
20
|
+
name: boolean;
|
21
|
+
length: boolean;
|
22
|
+
prototype: boolean;
|
23
|
+
caller: boolean;
|
24
|
+
callee: boolean;
|
25
|
+
arguments: boolean;
|
26
|
+
arity: boolean;
|
27
|
+
};
|
28
|
+
declare const FORWARD_REF_STATICS: {
|
29
|
+
$$typeof: boolean;
|
30
|
+
render: boolean;
|
31
|
+
defaultProps: boolean;
|
32
|
+
displayName: boolean;
|
33
|
+
propTypes: boolean;
|
34
|
+
};
|
35
|
+
declare const MEMO_STATICS: {
|
36
|
+
$$typeof: boolean;
|
37
|
+
compare: boolean;
|
38
|
+
defaultProps: boolean;
|
39
|
+
displayName: boolean;
|
40
|
+
propTypes: boolean;
|
41
|
+
type: boolean;
|
42
|
+
};
|
43
|
+
type OmniComponent = AnyComponent;
|
44
|
+
type ExcludeList = {
|
45
|
+
[key: string]: true;
|
46
|
+
};
|
47
|
+
type NonReactStatics<S extends OmniComponent, C extends ExcludeList = {}> = {
|
48
|
+
[key in Exclude<keyof S, S extends React.MemoExoticComponent<any> ? keyof typeof MEMO_STATICS | keyof C : S extends React.ForwardRefExoticComponent<any> ? keyof typeof FORWARD_REF_STATICS | keyof C : keyof typeof REACT_STATICS | keyof typeof KNOWN_STATICS | keyof C>]: S[key];
|
49
|
+
};
|
50
|
+
export default function hoistNonReactStatics<T extends OmniComponent, S extends OmniComponent, C extends ExcludeList = {}>(targetComponent: T, sourceComponent: S, excludelist?: C | undefined): T & NonReactStatics<S, C>;
|
51
|
+
export {};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Hyphenates a camelcased CSS property name, for example:
|
3
|
+
*
|
4
|
+
* > hyphenateStyleName('backgroundColor')
|
5
|
+
* < "background-color"
|
6
|
+
* > hyphenateStyleName('MozTransition')
|
7
|
+
* < "-moz-transition"
|
8
|
+
* > hyphenateStyleName('msTransition')
|
9
|
+
* < "-ms-transition"
|
10
|
+
*
|
11
|
+
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
|
12
|
+
* is converted to `-ms-`.
|
13
|
+
*/
|
14
|
+
export default function hyphenateStyleName(string: string): string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function isFunction(test: any): test is Function;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function isPlainObject(x: any): x is Record<any, any>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function isStatelessFunction(test: any): test is Function;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
/**
|
2
|
+
* Arrays & POJOs merged recursively, other objects and value types are overridden
|
3
|
+
* If target is not a POJO or an Array, it will get source properties injected via shallow merge
|
4
|
+
* Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
|
5
|
+
*/
|
6
|
+
export default function mixinDeep(target: any, ...sources: any[]): any;
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function getNonce(): string | null;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* If the Object prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
|
3
|
+
* cannot have the property changed using a "=" assignment operator. If using strict mode, attempting that will cause an error. If not using
|
4
|
+
* strict mode, attempting that will be silently ignored.
|
5
|
+
*
|
6
|
+
* If the Object prototype is frozen, inherited non-writable properties can still be shadowed using one of two mechanisms:
|
7
|
+
*
|
8
|
+
* 1. ES6 class methods: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#methods
|
9
|
+
* 2. Using the `Object.defineProperty()` static method:
|
10
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
|
11
|
+
*
|
12
|
+
* However, this project uses Babel to transpile ES6 classes, and transforms ES6 class methods to use the assignment operator instead:
|
13
|
+
* https://babeljs.io/docs/babel-plugin-transform-class-properties#options
|
14
|
+
*
|
15
|
+
* Therefore, the most compatible way to shadow the prototype's "toString" property is to define a new "toString" property on this object.
|
16
|
+
*/
|
17
|
+
export declare function setToString(object: object, toStringFn: () => string): void;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import * as stylis from 'stylis';
|
2
|
+
import { Stringifier } from '../types';
|
3
|
+
export type ICreateStylisInstance = {
|
4
|
+
options?: {
|
5
|
+
namespace?: string | undefined;
|
6
|
+
prefix?: boolean | undefined;
|
7
|
+
} | undefined;
|
8
|
+
plugins?: stylis.Middleware[] | undefined;
|
9
|
+
};
|
10
|
+
export default function createStylisInstance({ options, plugins, }?: ICreateStylisInstance): Stringifier;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { AnyComponent, ExecutionProps } from '../types';
|
3
|
+
export default function withTheme<T extends AnyComponent>(Component: T): React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<T, ExecutionProps>> & React.RefAttributes<T>> & { [key in Exclude<keyof T, T extends React.MemoExoticComponent<any> ? "propTypes" | "defaultProps" | "displayName" | "$$typeof" | "type" | "compare" : T extends React.ForwardRefExoticComponent<any> ? "propTypes" | "defaultProps" | "displayName" | "$$typeof" | "render" : "length" | "propTypes" | "contextType" | "contextTypes" | "childContextTypes" | "defaultProps" | "displayName" | "getDerivedStateFromProps" | "getDerivedStateFromError" | "type" | "getDefaultProps" | "mixins" | "name" | "prototype" | "caller" | "callee" | "arguments" | "arity">]: T[key]; };
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import styled from './constructors/styled';
|
2
|
+
export * from './base';
|
3
|
+
export { CSSKeyframes, CSSObject, CSSProp, CSSProperties, CSSPseudos, DataAttributes, DefaultTheme, ExecutionContext, ExecutionProps, IStyledComponent, IStyledComponentFactory, IStyledStatics, Interpolation, PolymorphicComponent, PolymorphicComponentProps, RuleSet, Runtime, StyleFunction, StyledObject, StyledOptions, SupportedHTMLElements, WebTarget, } from './types';
|
4
|
+
export { styled as default, styled };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import StyleSheet from '../sheet';
|
2
|
+
import { ExecutionContext, RuleSet, Stringifier } from '../types';
|
3
|
+
/**
|
4
|
+
* ComponentStyle is all the CSS-specific stuff, not the React-specific stuff.
|
5
|
+
*/
|
6
|
+
export default class ComponentStyle {
|
7
|
+
baseHash: number;
|
8
|
+
baseStyle: ComponentStyle | null | undefined;
|
9
|
+
componentId: string;
|
10
|
+
isStatic: boolean;
|
11
|
+
rules: RuleSet<any>;
|
12
|
+
staticRulesId: string;
|
13
|
+
constructor(rules: RuleSet<any>, componentId: string, baseStyle?: ComponentStyle | undefined);
|
14
|
+
generateAndInjectStyles(executionContext: ExecutionContext, styleSheet: StyleSheet, stylis: Stringifier): string;
|
15
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import StyleSheet from '../sheet';
|
2
|
+
import { ExecutionContext, RuleSet, Stringifier } from '../types';
|
3
|
+
export default class GlobalStyle<Props extends object> {
|
4
|
+
componentId: string;
|
5
|
+
isStatic: boolean;
|
6
|
+
rules: RuleSet<Props>;
|
7
|
+
constructor(rules: RuleSet<Props>, componentId: string);
|
8
|
+
createStyles(instance: number, executionContext: ExecutionContext & Props, styleSheet: StyleSheet, stylis: Stringifier): void;
|
9
|
+
removeStyles(instance: number, styleSheet: StyleSheet): void;
|
10
|
+
renderStyles(instance: number, executionContext: ExecutionContext & Props, styleSheet: StyleSheet, stylis: Stringifier): void;
|
11
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { IInlineStyleConstructor, StyleSheet } from '../types';
|
2
|
+
export declare const resetStyleCache: () => void;
|
3
|
+
/**
|
4
|
+
* InlineStyle takes arbitrary CSS and generates a flat object
|
5
|
+
*/
|
6
|
+
export default function makeInlineStyleClass<Props extends object>(styleSheet: StyleSheet): IInlineStyleConstructor<Props>;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import StyleSheet from '../sheet';
|
2
|
+
import { Keyframes as KeyframesType, Stringifier } from '../types';
|
3
|
+
export default class Keyframes implements KeyframesType {
|
4
|
+
id: string;
|
5
|
+
name: string;
|
6
|
+
rules: string;
|
7
|
+
constructor(name: string, rules: string);
|
8
|
+
inject: (styleSheet: StyleSheet, stylisInstance?: Stringifier) => void;
|
9
|
+
getName(stylisInstance?: Stringifier): string;
|
10
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import React from 'react';
|
3
|
+
import type * as streamInternal from 'stream';
|
4
|
+
import { Readable } from 'stream';
|
5
|
+
import StyleSheet from '../sheet';
|
6
|
+
export default class ServerStyleSheet {
|
7
|
+
instance: StyleSheet;
|
8
|
+
sealed: boolean;
|
9
|
+
constructor();
|
10
|
+
_emitSheetCSS: () => string;
|
11
|
+
collectStyles(children: any): JSX.Element;
|
12
|
+
getStyleTags: () => string;
|
13
|
+
getStyleElement: () => React.JSX.Element[];
|
14
|
+
interleaveWithNodeStream(input: Readable): streamInternal.Transform;
|
15
|
+
seal: () => void;
|
16
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type stylis from 'stylis';
|
3
|
+
import StyleSheet from '../sheet';
|
4
|
+
import { ShouldForwardProp, Stringifier } from '../types';
|
5
|
+
export declare const mainSheet: StyleSheet;
|
6
|
+
export declare const mainStylis: Stringifier;
|
7
|
+
export type IStyleSheetContext = {
|
8
|
+
shouldForwardProp?: ShouldForwardProp<'web'> | undefined;
|
9
|
+
styleSheet: StyleSheet;
|
10
|
+
stylis: Stringifier;
|
11
|
+
};
|
12
|
+
export declare const StyleSheetContext: React.Context<IStyleSheetContext>;
|
13
|
+
export declare const StyleSheetConsumer: React.Consumer<IStyleSheetContext>;
|
14
|
+
export type IStylisContext = Stringifier | void;
|
15
|
+
export declare const StylisContext: React.Context<IStylisContext>;
|
16
|
+
export declare const StylisConsumer: React.Consumer<IStylisContext>;
|
17
|
+
export declare function useStyleSheetContext(): IStyleSheetContext;
|
18
|
+
export type IStyleSheetManager = React.PropsWithChildren<{
|
19
|
+
/**
|
20
|
+
* If desired, you can pass this prop to disable "speedy" insertion mode, which
|
21
|
+
* uses the browser [CSSOM APIs](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet).
|
22
|
+
* When disabled, rules are inserted as simple text into style blocks.
|
23
|
+
*/
|
24
|
+
disableCSSOMInjection?: undefined | boolean;
|
25
|
+
/**
|
26
|
+
* If you are working exclusively with modern browsers, vendor prefixes can often be omitted
|
27
|
+
* to reduce the weight of CSS on the page.
|
28
|
+
*/
|
29
|
+
enableVendorPrefixes?: undefined | boolean;
|
30
|
+
/**
|
31
|
+
* Provide an optional selector to be prepended to all generated style rules.
|
32
|
+
*/
|
33
|
+
namespace?: undefined | string;
|
34
|
+
/**
|
35
|
+
* Create and provide your own `StyleSheet` if necessary for advanced SSR scenarios.
|
36
|
+
*/
|
37
|
+
sheet?: undefined | StyleSheet;
|
38
|
+
/**
|
39
|
+
* Starting in v6, styled-components no longer does its own prop validation
|
40
|
+
* and recommends use of transient props "$prop" to pass style-only props to
|
41
|
+
* components. If for some reason you are not able to use transient props, a
|
42
|
+
* prop validation function can be provided via `StyleSheetManager`, such as
|
43
|
+
* `@emotion/is-prop-valid`.
|
44
|
+
*
|
45
|
+
* When the return value is `true`, props will be forwarded to the DOM/underlying
|
46
|
+
* component. If return value is `false`, the prop will be discarded after styles
|
47
|
+
* are calculated.
|
48
|
+
*
|
49
|
+
* Manually composing `styled.{element}.withConfig({shouldForwardProp})` will
|
50
|
+
* override this default.
|
51
|
+
*/
|
52
|
+
shouldForwardProp?: undefined | IStyleSheetContext['shouldForwardProp'];
|
53
|
+
/**
|
54
|
+
* An array of plugins to be run by stylis (style processor) during compilation.
|
55
|
+
* Check out [what's available on npm*](https://www.npmjs.com/search?q=keywords%3Astylis).
|
56
|
+
*
|
57
|
+
* \* The plugin(s) must be compatible with stylis v4 or above.
|
58
|
+
*/
|
59
|
+
stylisPlugins?: undefined | stylis.Middleware[];
|
60
|
+
/**
|
61
|
+
* Provide an alternate DOM node to host generated styles; useful for iframes.
|
62
|
+
*/
|
63
|
+
target?: undefined | HTMLElement;
|
64
|
+
}>;
|
65
|
+
export declare function StyleSheetManager(props: IStyleSheetManager): JSX.Element;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import type { BaseObject, IStyledComponentFactory, RuleSet, StyledOptions, WebTarget } from '../types';
|
2
|
+
declare function createStyledComponent<Target extends WebTarget, OuterProps extends object, Statics extends object = BaseObject>(target: Target, options: StyledOptions<'web', OuterProps>, rules: RuleSet<OuterProps>): ReturnType<IStyledComponentFactory<'web', Target, OuterProps, Statics>>;
|
3
|
+
export default createStyledComponent;
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import type { BaseObject, 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 = BaseObject>(target: Target, options: StyledOptions<"native", OuterProps>, rules: RuleSet<OuterProps>) => IStyledComponent<"native", import("../types").Substitute<OuterProps, object>> & Statics & object;
|
3
|
+
export default _default;
|