styled-components 6.3.1 → 6.3.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.
- package/dist/base.d.ts +12 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constructors/constructWithOptions.d.ts +17 -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 +17 -0
- package/dist/hoc/withTheme.d.ts +4 -0
- package/dist/index-standalone.d.ts +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/models/ComponentStyle.d.ts +18 -0
- package/dist/models/GlobalStyle.d.ts +11 -0
- package/dist/models/InlineStyle.d.ts +7 -0
- package/dist/models/Keyframes.d.ts +10 -0
- package/dist/models/ServerStyleSheet.d.ts +15 -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 +19 -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 +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 +7 -1
- 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/types.d.ts +212 -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/dist/native/index.d.ts +1 -1
- package/native/dist/dist/utils/domElements.d.ts +1 -1
- package/native/dist/native/index.d.ts +1 -1
- 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/package.json +3 -2
- package/native/dist/dist/test/globals.d.ts +0 -2
- package/native/dist/dist/test/utils.d.ts +0 -163
- package/native/dist/dist/test/veryLargeUnionType.d.ts +0 -1
- package/native/dist/test/globals.d.ts +0 -2
- package/native/dist/test/utils.d.ts +0 -163
- package/native/dist/test/veryLargeUnionType.d.ts +0 -1
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SC_VERSION } from './constants';
|
|
2
|
+
import createGlobalStyle from './constructors/createGlobalStyle';
|
|
3
|
+
import css from './constructors/css';
|
|
4
|
+
import keyframes from './constructors/keyframes';
|
|
5
|
+
import withTheme from './hoc/withTheme';
|
|
6
|
+
import ServerStyleSheet from './models/ServerStyleSheet';
|
|
7
|
+
import { IStyleSheetContext, IStyleSheetManager, IStylisContext, StyleSheetConsumer, StyleSheetContext, StyleSheetManager } from './models/StyleSheetManager';
|
|
8
|
+
import ThemeProvider, { ThemeConsumer, ThemeContext, useTheme } from './models/ThemeProvider';
|
|
9
|
+
import isStyledComponent from './utils/isStyledComponent';
|
|
10
|
+
export * from './secretInternals';
|
|
11
|
+
export { Attrs, DefaultTheme, ShouldForwardProp } from './types';
|
|
12
|
+
export { IStyleSheetContext, IStyleSheetManager, IStylisContext, ServerStyleSheet, StyleSheetConsumer, StyleSheetContext, StyleSheetManager, ThemeConsumer, ThemeContext, ThemeProvider, createGlobalStyle, css, isStyledComponent, keyframes, useTheme, SC_VERSION as version, withTheme, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const SC_ATTR: string;
|
|
2
|
+
export declare const SC_ATTR_ACTIVE = "active";
|
|
3
|
+
export declare const SC_ATTR_VERSION = "data-styled-version";
|
|
4
|
+
export declare const SC_VERSION: string;
|
|
5
|
+
export declare const SPLITTER = "/*!sc*/\n";
|
|
6
|
+
export declare const IS_BROWSER: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Detect if we're running in a React Server Component environment.
|
|
9
|
+
* RSC environments lack createContext, making this a reliable indicator.
|
|
10
|
+
*/
|
|
11
|
+
export declare const IS_RSC: boolean;
|
|
12
|
+
export declare const DISABLE_SPEEDY: boolean;
|
|
13
|
+
export declare const STATIC_EXECUTION_CONTEXT: {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Attrs, BaseObject, ExecutionProps, Interpolation, IStyledComponent, IStyledComponentFactory, KnownTarget, NoInfer, Runtime, StyledOptions, StyledTarget, Styles, Substitute } from '../types';
|
|
2
|
+
type AttrsResult<T extends Attrs<any>> = T extends (...args: any) => infer P ? P extends object ? P : never : T extends object ? T : never;
|
|
3
|
+
/**
|
|
4
|
+
* Based on Attrs being a simple object or function that returns
|
|
5
|
+
* a prop object, inspect the attrs result and attempt to extract
|
|
6
|
+
* any "as" prop usage to modify the runtime target.
|
|
7
|
+
*/
|
|
8
|
+
type AttrsTarget<R extends Runtime, T extends Attrs<any>, FallbackTarget extends StyledTarget<R>, Result extends ExecutionProps = AttrsResult<T>> = Result extends {
|
|
9
|
+
as: infer RuntimeTarget;
|
|
10
|
+
} ? RuntimeTarget extends KnownTarget ? RuntimeTarget : FallbackTarget : FallbackTarget;
|
|
11
|
+
export interface Styled<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object, OuterStatics extends object = BaseObject> {
|
|
12
|
+
<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 & (R extends 'web' ? Target extends string ? {} : Omit<Target, keyof React.Component<any>> : {});
|
|
13
|
+
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>;
|
|
14
|
+
withConfig: (config: StyledOptions<R, OuterProps>) => Styled<R, Target, OuterProps, OuterStatics>;
|
|
15
|
+
}
|
|
16
|
+
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>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExecutionProps, Interpolation, Styles } from '../types';
|
|
3
|
+
export default function createGlobalStyle<Props extends object>(strings: Styles<Props>, ...interpolations: Array<Interpolation<Props>>): React.NamedExoticComponent<ExecutionProps & Props>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Interpolation, NoInfer, RuleSet, Styles } from '../types';
|
|
2
|
+
declare function css(styles: Styles<object>, ...interpolations: Interpolation<object>[]): RuleSet<object>;
|
|
3
|
+
declare function css<Props extends object>(styles: Styles<NoInfer<Props>>, ...interpolations: Interpolation<NoInfer<Props>>[]): RuleSet<NoInfer<Props>>;
|
|
4
|
+
export default css;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BaseObject, KnownTarget, WebTarget } from '../types';
|
|
3
|
+
import { SupportedHTMLElements } from '../utils/domElements';
|
|
4
|
+
import { Styled as StyledInstance } from './constructWithOptions';
|
|
5
|
+
declare const baseStyled: <Target extends WebTarget, InjectedProps extends object = BaseObject>(tag: Target) => StyledInstance<"web", Target, Target extends KnownTarget ? React.ComponentPropsWithRef<Target> & InjectedProps : InjectedProps, BaseObject>;
|
|
6
|
+
declare const styled: typeof baseStyled & { [E in SupportedHTMLElements]: StyledInstance<"web", E, React.JSX.IntrinsicElements[E]>; };
|
|
7
|
+
export default styled;
|
|
8
|
+
export { StyledInstance };
|
|
9
|
+
/**
|
|
10
|
+
* This is the type of the `styled` HOC.
|
|
11
|
+
*/
|
|
12
|
+
export type Styled = typeof styled;
|
|
13
|
+
/**
|
|
14
|
+
* Use this higher-order type for scenarios where you are wrapping `styled`
|
|
15
|
+
* and providing extra props as a third-party library.
|
|
16
|
+
*/
|
|
17
|
+
export type LibraryStyled<LibraryProps extends object = BaseObject> = <Target extends WebTarget>(tag: Target) => typeof baseStyled<Target, LibraryProps>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AnyComponent, ExecutionProps } from '../types';
|
|
3
|
+
import { NonReactStatics } from '../utils/hoist';
|
|
4
|
+
export default function withTheme<T extends AnyComponent>(Component: T): React.ForwardRefExoticComponent<React.PropsWithoutRef<React.ComponentPropsWithRef<T> & ExecutionProps> & React.RefAttributes<T>> & NonReactStatics<T>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import styled, { LibraryStyled, Styled, StyledInstance } from './constructors/styled';
|
|
2
|
+
export * from './base';
|
|
3
|
+
export { CSSKeyframes, CSSObject, CSSProp, CSSProperties, CSSPseudos, DataAttributes, DefaultTheme, ExecutionContext, ExecutionProps, FastOmit, Interpolation, IStyledComponent, IStyledComponentFactory, IStyledStatics, PolymorphicComponent, PolymorphicComponentProps, RuleSet, Runtime, StyledObject, StyledOptions, StyleFunction, SupportedHTMLElements, WebTarget, } from './types';
|
|
4
|
+
export { styled as default, LibraryStyled, Styled, styled, StyledInstance };
|
|
@@ -0,0 +1,18 @@
|
|
|
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): {
|
|
15
|
+
className: string;
|
|
16
|
+
css: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -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,7 @@
|
|
|
1
|
+
import { IInlineStyleConstructor, StyleSheet } from '../types';
|
|
2
|
+
export declare const RN_UNSUPPORTED_VALUES: string[];
|
|
3
|
+
export declare const resetStyleCache: () => void;
|
|
4
|
+
/**
|
|
5
|
+
* InlineStyle takes arbitrary CSS and generates a flat object
|
|
6
|
+
*/
|
|
7
|
+
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,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type PipeableStream } from 'react-dom/server';
|
|
3
|
+
import type * as streamInternal from 'stream';
|
|
4
|
+
import StyleSheet from '../sheet';
|
|
5
|
+
export default class ServerStyleSheet {
|
|
6
|
+
instance: StyleSheet;
|
|
7
|
+
sealed: boolean;
|
|
8
|
+
constructor();
|
|
9
|
+
_emitSheetCSS: () => string;
|
|
10
|
+
collectStyles(children: any): React.JSX.Element;
|
|
11
|
+
getStyleTags: () => string;
|
|
12
|
+
getStyleElement: () => React.JSX.Element[];
|
|
13
|
+
interleaveWithNodeStream(input: NodeJS.ReadableStream | PipeableStream): streamInternal.Transform;
|
|
14
|
+
seal: () => void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type stylis from 'stylis';
|
|
3
|
+
import StyleSheet from '../sheet';
|
|
4
|
+
import { InsertionTarget, 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 | InsertionTarget;
|
|
64
|
+
}>;
|
|
65
|
+
export declare function StyleSheetManager(props: IStyleSheetManager): React.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 BaseObject, Statics extends BaseObject = 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, 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>) => ReturnType<IStyledComponentFactory<"native", Target, OuterProps, Statics>>;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type DefaultThemeAsObject<T = object> = Record<keyof T, any>;
|
|
3
|
+
/**
|
|
4
|
+
* Override DefaultTheme to get accurate typings for your project.
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* // create styled-components.d.ts in your project source
|
|
8
|
+
* // if it isn't being picked up, check tsconfig compilerOptions.types
|
|
9
|
+
* import type { CSSProp } from "styled-components";
|
|
10
|
+
* import Theme from './theme';
|
|
11
|
+
*
|
|
12
|
+
* type ThemeType = typeof Theme;
|
|
13
|
+
*
|
|
14
|
+
* declare module "styled-components" {
|
|
15
|
+
* export interface DefaultTheme extends ThemeType {}
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* declare module "react" {
|
|
19
|
+
* interface DOMAttributes<T> {
|
|
20
|
+
* css?: CSSProp;
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface DefaultTheme extends DefaultThemeAsObject {
|
|
26
|
+
}
|
|
27
|
+
type ThemeFn = (outerTheme?: DefaultTheme | undefined) => DefaultTheme;
|
|
28
|
+
type ThemeArgument = DefaultTheme | ThemeFn;
|
|
29
|
+
type Props = {
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
theme: ThemeArgument;
|
|
32
|
+
};
|
|
33
|
+
export declare const ThemeContext: React.Context<DefaultTheme | undefined>;
|
|
34
|
+
export declare const ThemeConsumer: React.Consumer<DefaultTheme | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the current theme (as provided by the closest ancestor `ThemeProvider`.)
|
|
37
|
+
*
|
|
38
|
+
* If no `ThemeProvider` is found, the function will error. If you need access to the theme in an
|
|
39
|
+
* uncertain composition scenario, `React.useContext(ThemeContext)` will not emit an error if there
|
|
40
|
+
* is no `ThemeProvider` ancestor.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useTheme(): DefaultTheme;
|
|
43
|
+
/**
|
|
44
|
+
* Provide a theme to an entire react component tree via context
|
|
45
|
+
*/
|
|
46
|
+
export default function ThemeProvider(props: Props): React.JSX.Element | null;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Styled } from '../constructors/constructWithOptions';
|
|
3
|
+
import css from '../constructors/css';
|
|
4
|
+
import withTheme from '../hoc/withTheme';
|
|
5
|
+
import ThemeProvider, { ThemeConsumer, ThemeContext, useTheme } from '../models/ThemeProvider';
|
|
6
|
+
import { NativeTarget, RuleSet } from '../types';
|
|
7
|
+
import isStyledComponent from '../utils/isStyledComponent';
|
|
8
|
+
declare const reactNative: Awaited<typeof import("react-native")>;
|
|
9
|
+
declare const baseStyled: <Target extends NativeTarget>(tag: Target) => Styled<"native", Target, Target extends import("../types").KnownTarget ? React.ComponentPropsWithRef<Target> : import("../types").BaseObject, import("../types").BaseObject>;
|
|
10
|
+
declare const aliases: readonly ["ActivityIndicator", "Button", "DatePickerIOS", "DrawerLayoutAndroid", "FlatList", "Image", "ImageBackground", "KeyboardAvoidingView", "Modal", "Pressable", "ProgressBarAndroid", "ProgressViewIOS", "RefreshControl", "SafeAreaView", "ScrollView", "SectionList", "Slider", "Switch", "Text", "TextInput", "TouchableHighlight", "TouchableOpacity", "View", "VirtualizedList"];
|
|
11
|
+
type KnownComponents = (typeof aliases)[number];
|
|
12
|
+
/** Isolates RN-provided components since they don't expose a helper type for this. */
|
|
13
|
+
type RNComponents = {
|
|
14
|
+
[K in keyof typeof reactNative]: (typeof reactNative)[K] extends React.ComponentType<any> ? (typeof reactNative)[K] : never;
|
|
15
|
+
};
|
|
16
|
+
declare const styled: typeof baseStyled & { [E in KnownComponents]: Styled<"native", RNComponents[E], React.ComponentProps<RNComponents[E]>>; };
|
|
17
|
+
declare const toStyleSheet: (rules: RuleSet<object>) => import("css-to-react-native").Style;
|
|
18
|
+
export { CSSKeyframes, CSSObject, CSSProperties, CSSPseudos, DefaultTheme, ExecutionContext, ExecutionProps, IStyledComponent, IStyledComponentFactory, IStyledStatics, NativeTarget, PolymorphicComponent, PolymorphicComponentProps, Runtime, StyledObject, StyledOptions, } from '../types';
|
|
19
|
+
export { css, styled as default, isStyledComponent, styled, ThemeConsumer, ThemeContext, ThemeProvider, toStyleSheet, useTheme, withTheme, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tag } from './types';
|
|
2
|
+
/** Create a GroupedTag with an underlying Tag implementation */
|
|
3
|
+
export declare const makeGroupedTag: (tag: Tag) => {
|
|
4
|
+
groupSizes: Uint32Array;
|
|
5
|
+
length: number;
|
|
6
|
+
tag: Tag;
|
|
7
|
+
indexOfGroup(group: number): number;
|
|
8
|
+
insertRules(group: number, rules: string[]): void;
|
|
9
|
+
clearGroup(group: number): void;
|
|
10
|
+
getGroup(group: number): string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InsertionTarget } from '../types';
|
|
2
|
+
import { GroupedTag, Sheet, SheetOptions } from './types';
|
|
3
|
+
type SheetConstructorArgs = {
|
|
4
|
+
isServer?: boolean;
|
|
5
|
+
useCSSOMInjection?: boolean;
|
|
6
|
+
target?: InsertionTarget | undefined;
|
|
7
|
+
};
|
|
8
|
+
type GlobalStylesAllocationMap = {
|
|
9
|
+
[key: string]: number;
|
|
10
|
+
};
|
|
11
|
+
type NamesAllocationMap = Map<string, Set<string>>;
|
|
12
|
+
/** Contains the main stylesheet logic for stringification and caching */
|
|
13
|
+
export default class StyleSheet implements Sheet {
|
|
14
|
+
gs: GlobalStylesAllocationMap;
|
|
15
|
+
names: NamesAllocationMap;
|
|
16
|
+
options: SheetOptions;
|
|
17
|
+
server: boolean;
|
|
18
|
+
tag?: GroupedTag | undefined;
|
|
19
|
+
/** Register a group ID to give it an index */
|
|
20
|
+
static registerId(id: string): number;
|
|
21
|
+
constructor(options?: SheetConstructorArgs, globalStyles?: GlobalStylesAllocationMap, names?: NamesAllocationMap | undefined);
|
|
22
|
+
rehydrate(): void;
|
|
23
|
+
reconstructWithOptions(options: SheetConstructorArgs, withNames?: boolean): StyleSheet;
|
|
24
|
+
allocateGSInstance(id: string): number;
|
|
25
|
+
/** Lazily initialises a GroupedTag for when it's actually needed */
|
|
26
|
+
getTag(): GroupedTag;
|
|
27
|
+
/** Check whether a name is known for caching */
|
|
28
|
+
hasNameForId(id: string, name: string): boolean;
|
|
29
|
+
/** Mark a group's name as known for caching */
|
|
30
|
+
registerName(id: string, name: string): void;
|
|
31
|
+
/** Insert new rules which also marks the name as known */
|
|
32
|
+
insertRules(id: string, name: string, rules: string | string[]): void;
|
|
33
|
+
/** Clears all cached names for a given group ID */
|
|
34
|
+
clearNames(id: string): void;
|
|
35
|
+
/** Clears all rules for a given group ID */
|
|
36
|
+
clearRules(id: string): void;
|
|
37
|
+
/** Clears the entire tag which deletes all rules but not its names */
|
|
38
|
+
clearTag(): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { InsertionTarget } from '../types';
|
|
2
|
+
import { SheetOptions } from './types';
|
|
3
|
+
/** Create a CSSStyleSheet-like tag depending on the environment */
|
|
4
|
+
export declare const makeTag: ({ isServer, useCSSOMInjection, target }: SheetOptions) => {
|
|
5
|
+
rules: string[];
|
|
6
|
+
length: number;
|
|
7
|
+
insertRule(index: number, rule: string): boolean;
|
|
8
|
+
deleteRule(index: number): void;
|
|
9
|
+
getRule(index: number): string;
|
|
10
|
+
} | {
|
|
11
|
+
element: HTMLStyleElement;
|
|
12
|
+
sheet: CSSStyleSheet;
|
|
13
|
+
length: number;
|
|
14
|
+
insertRule(index: number, rule: string): boolean;
|
|
15
|
+
deleteRule(index: number): void;
|
|
16
|
+
getRule(index: number): string;
|
|
17
|
+
} | {
|
|
18
|
+
element: HTMLStyleElement;
|
|
19
|
+
nodes: NodeListOf<Node>;
|
|
20
|
+
length: number;
|
|
21
|
+
insertRule(index: number, rule: string): boolean;
|
|
22
|
+
deleteRule(index: number): void;
|
|
23
|
+
getRule(index: number): string;
|
|
24
|
+
};
|
|
25
|
+
export declare const CSSOMTag: {
|
|
26
|
+
new (target?: InsertionTarget | undefined): {
|
|
27
|
+
element: HTMLStyleElement;
|
|
28
|
+
sheet: CSSStyleSheet;
|
|
29
|
+
length: number;
|
|
30
|
+
insertRule(index: number, rule: string): boolean;
|
|
31
|
+
deleteRule(index: number): void;
|
|
32
|
+
getRule(index: number): string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/** A Tag that emulates the CSSStyleSheet API but uses text nodes */
|
|
36
|
+
export declare const TextTag: {
|
|
37
|
+
new (target?: InsertionTarget | undefined): {
|
|
38
|
+
element: HTMLStyleElement;
|
|
39
|
+
nodes: NodeListOf<Node>;
|
|
40
|
+
length: number;
|
|
41
|
+
insertRule(index: number, rule: string): boolean;
|
|
42
|
+
deleteRule(index: number): void;
|
|
43
|
+
getRule(index: number): string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
|
|
47
|
+
export declare const VirtualTag: {
|
|
48
|
+
new (_target?: InsertionTarget | undefined): {
|
|
49
|
+
rules: string[];
|
|
50
|
+
length: number;
|
|
51
|
+
insertRule(index: number, rule: string): boolean;
|
|
52
|
+
deleteRule(index: number): void;
|
|
53
|
+
getRule(index: number): string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InsertionTarget } from '../types';
|
|
2
|
+
/** Create a style element inside `target` or <head> after the last */
|
|
3
|
+
export declare const makeStyleTag: (target?: InsertionTarget | undefined) => HTMLStyleElement;
|
|
4
|
+
/** Get the CSSStyleSheet instance for a given style element */
|
|
5
|
+
export declare const getSheet: (tag: HTMLStyleElement) => CSSStyleSheet;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Sheet';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { InsertionTarget } from '../types';
|
|
2
|
+
/** CSSStyleSheet-like Tag abstraction for CSS rules */
|
|
3
|
+
export interface Tag {
|
|
4
|
+
insertRule(index: number, rule: string): boolean;
|
|
5
|
+
deleteRule(index: number): void;
|
|
6
|
+
getRule(index: number): string;
|
|
7
|
+
length: number;
|
|
8
|
+
}
|
|
9
|
+
/** Group-aware Tag that sorts rules by indices */
|
|
10
|
+
export interface GroupedTag {
|
|
11
|
+
clearGroup(group: number): void;
|
|
12
|
+
getGroup(group: number): string;
|
|
13
|
+
groupSizes: Uint32Array;
|
|
14
|
+
insertRules(group: number, rules: string | string[]): void;
|
|
15
|
+
length: number;
|
|
16
|
+
tag: Tag;
|
|
17
|
+
}
|
|
18
|
+
export type SheetOptions = {
|
|
19
|
+
isServer: boolean;
|
|
20
|
+
target?: InsertionTarget | undefined;
|
|
21
|
+
useCSSOMInjection: boolean;
|
|
22
|
+
};
|
|
23
|
+
export interface Sheet {
|
|
24
|
+
allocateGSInstance(id: string): number;
|
|
25
|
+
clearNames(id: string): void;
|
|
26
|
+
clearRules(id: string): void;
|
|
27
|
+
clearTag(): void;
|
|
28
|
+
getTag(): GroupedTag;
|
|
29
|
+
hasNameForId(id: string, name: string): boolean;
|
|
30
|
+
insertRules(id: string, name: string, rules: string | string[]): void;
|
|
31
|
+
options: SheetOptions;
|
|
32
|
+
names: Map<string, Set<string>>;
|
|
33
|
+
registerName(id: string, name: string): void;
|
|
34
|
+
rehydrate(): void;
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|