styled-components 6.0.0-beta.1 → 6.0.0-beta.11
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 +3 -3
- package/dist/constructors/constructWithOptions.d.ts +24 -31
- package/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/dist/constructors/css.d.ts +4 -4
- package/dist/constructors/keyframes.d.ts +1 -1
- package/dist/constructors/styled.d.ts +177 -181
- package/dist/hoc/withTheme.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/models/GlobalStyle.d.ts +1 -1
- package/dist/models/InlineStyle.d.ts +1 -1
- package/dist/models/StyleSheetManager.d.ts +58 -14
- package/dist/models/StyledComponent.d.ts +1 -1
- package/dist/models/StyledNativeComponent.d.ts +2 -2
- package/dist/models/ThemeProvider.d.ts +1 -1
- package/dist/native/index.d.ts +28 -32
- package/dist/styled-components-macro.cjs.js +46 -1
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components-macro.esm.js +37 -1
- package/dist/styled-components-macro.esm.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +1859 -1
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +1833 -1
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +1880 -1
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +1854 -1
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +1979 -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/test/types.d.ts +1 -0
- package/dist/test/utils.d.ts +176 -180
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +81 -73
- package/dist/utils/determineTheme.d.ts +2 -2
- package/dist/utils/domElements.d.ts +1 -1
- package/dist/utils/empties.d.ts +2 -2
- package/dist/utils/flatten.d.ts +3 -3
- package/dist/utils/generateDisplayName.d.ts +1 -1
- package/dist/utils/getComponentName.d.ts +1 -1
- package/dist/utils/interleave.d.ts +1 -1
- package/dist/utils/isStaticRules.d.ts +1 -1
- package/dist/utils/isStyledComponent.d.ts +1 -1
- package/dist/utils/isTag.d.ts +1 -1
- package/dist/utils/joinStrings.d.ts +1 -1
- package/dist/utils/mixinDeep.d.ts +1 -2
- package/dist/utils/stylis.d.ts +3 -3
- package/native/dist/base.d.ts +3 -3
- package/native/dist/constructors/constructWithOptions.d.ts +24 -31
- package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/native/dist/constructors/css.d.ts +4 -4
- package/native/dist/constructors/keyframes.d.ts +1 -1
- package/native/dist/constructors/styled.d.ts +177 -181
- package/native/dist/hoc/withTheme.d.ts +2 -2
- package/native/dist/index.d.ts +2 -2
- package/native/dist/models/GlobalStyle.d.ts +1 -1
- package/native/dist/models/InlineStyle.d.ts +1 -1
- package/native/dist/models/StyleSheetManager.d.ts +58 -14
- package/native/dist/models/StyledComponent.d.ts +1 -1
- package/native/dist/models/StyledNativeComponent.d.ts +2 -2
- package/native/dist/models/ThemeProvider.d.ts +1 -1
- package/native/dist/native/index.d.ts +28 -32
- package/native/dist/styled-components.native.cjs.js +88 -81
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +75 -69
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/test/types.d.ts +1 -0
- package/native/dist/test/utils.d.ts +176 -180
- package/native/dist/types.d.ts +81 -73
- package/native/dist/utils/determineTheme.d.ts +2 -2
- package/native/dist/utils/domElements.d.ts +1 -1
- package/native/dist/utils/empties.d.ts +2 -2
- package/native/dist/utils/flatten.d.ts +3 -3
- package/native/dist/utils/generateDisplayName.d.ts +1 -1
- package/native/dist/utils/getComponentName.d.ts +1 -1
- package/native/dist/utils/interleave.d.ts +1 -1
- package/native/dist/utils/isStaticRules.d.ts +1 -1
- package/native/dist/utils/isStyledComponent.d.ts +1 -1
- package/native/dist/utils/isTag.d.ts +1 -1
- package/native/dist/utils/joinStrings.d.ts +1 -1
- package/native/dist/utils/mixinDeep.d.ts +1 -2
- package/native/dist/utils/stylis.d.ts +3 -3
- package/package.json +40 -39
- package/test-utils/index.ts +10 -6
- package/native/dist/base.d.ts.map +0 -1
- package/native/dist/constants.d.ts.map +0 -1
- package/native/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/native/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/native/dist/constructors/css.d.ts.map +0 -1
- package/native/dist/constructors/keyframes.d.ts.map +0 -1
- package/native/dist/constructors/styled.d.ts.map +0 -1
- package/native/dist/dist/base.d.ts +0 -18
- package/native/dist/dist/base.d.ts.map +0 -1
- package/native/dist/dist/constants.d.ts +0 -9
- package/native/dist/dist/constants.d.ts.map +0 -1
- package/native/dist/dist/constructors/constructWithOptions.d.ts +0 -20
- package/native/dist/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/native/dist/dist/constructors/createGlobalStyle.d.ts +0 -4
- package/native/dist/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/native/dist/dist/constructors/css.d.ts +0 -5
- package/native/dist/dist/constructors/css.d.ts.map +0 -1
- package/native/dist/dist/constructors/keyframes.d.ts +0 -4
- package/native/dist/dist/constructors/keyframes.d.ts.map +0 -1
- package/native/dist/dist/constructors/styled.d.ts +0 -186
- package/native/dist/dist/constructors/styled.d.ts.map +0 -1
- package/native/dist/dist/hoc/withTheme.d.ts +0 -4
- package/native/dist/dist/hoc/withTheme.d.ts.map +0 -1
- package/native/dist/dist/hoc/withTheme.spec.d.ts +0 -2
- package/native/dist/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/native/dist/dist/hooks/useTheme.d.ts +0 -4
- package/native/dist/dist/hooks/useTheme.d.ts.map +0 -1
- package/native/dist/dist/index-standalone.d.ts +0 -3
- package/native/dist/dist/index-standalone.d.ts.map +0 -1
- package/native/dist/dist/index.d.ts +0 -4
- package/native/dist/dist/index.d.ts.map +0 -1
- package/native/dist/dist/macro/index.d.ts +0 -3
- package/native/dist/dist/macro/index.d.ts.map +0 -1
- package/native/dist/dist/macro/test/babel.config.d.ts +0 -1
- package/native/dist/dist/macro/test/babel.config.d.ts.map +0 -1
- package/native/dist/dist/models/ComponentStyle.d.ts +0 -16
- package/native/dist/dist/models/ComponentStyle.d.ts.map +0 -1
- package/native/dist/dist/models/GlobalStyle.d.ts +0 -12
- package/native/dist/dist/models/GlobalStyle.d.ts.map +0 -1
- package/native/dist/dist/models/InlineStyle.d.ts +0 -7
- package/native/dist/dist/models/InlineStyle.d.ts.map +0 -1
- package/native/dist/dist/models/Keyframes.d.ts +0 -12
- package/native/dist/dist/models/Keyframes.d.ts.map +0 -1
- package/native/dist/dist/models/ServerStyleSheet.d.ts +0 -16
- package/native/dist/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/native/dist/dist/models/StyleSheetManager.d.ts +0 -22
- package/native/dist/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/native/dist/dist/models/StyledComponent.d.ts +0 -4
- package/native/dist/dist/models/StyledComponent.d.ts.map +0 -1
- package/native/dist/dist/models/StyledNativeComponent.d.ts +0 -4
- package/native/dist/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/native/dist/dist/models/ThemeProvider.d.ts +0 -18
- package/native/dist/dist/models/ThemeProvider.d.ts.map +0 -1
- package/native/dist/dist/native/index.d.ts +0 -65
- package/native/dist/dist/native/index.d.ts.map +0 -1
- package/native/dist/dist/primitives/index.d.ts +0 -23
- package/native/dist/dist/primitives/index.d.ts.map +0 -1
- package/native/dist/dist/secretInternals.d.ts +0 -6
- package/native/dist/dist/secretInternals.d.ts.map +0 -1
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts +0 -5
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/native/dist/dist/sheet/GroupedTag.d.ts +0 -12
- package/native/dist/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/native/dist/dist/sheet/Rehydration.d.ts +0 -4
- package/native/dist/dist/sheet/Rehydration.d.ts.map +0 -1
- package/native/dist/dist/sheet/Sheet.d.ts +0 -41
- package/native/dist/dist/sheet/Sheet.d.ts.map +0 -1
- package/native/dist/dist/sheet/Tag.d.ts +0 -55
- package/native/dist/dist/sheet/Tag.d.ts.map +0 -1
- package/native/dist/dist/sheet/dom.d.ts +0 -5
- package/native/dist/dist/sheet/dom.d.ts.map +0 -1
- package/native/dist/dist/sheet/index.d.ts +0 -2
- package/native/dist/dist/sheet/index.d.ts.map +0 -1
- package/native/dist/dist/sheet/types.d.ts +0 -35
- package/native/dist/dist/sheet/types.d.ts.map +0 -1
- package/native/dist/dist/test/globals.d.ts +0 -3
- package/native/dist/dist/test/globals.d.ts.map +0 -1
- package/native/dist/dist/test/utils.d.ts +0 -192
- package/native/dist/dist/test/utils.d.ts.map +0 -1
- package/native/dist/dist/types.d.ts +0 -121
- package/native/dist/dist/types.d.ts.map +0 -1
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts +0 -2
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/native/dist/dist/utils/checkDynamicCreation.d.ts +0 -2
- package/native/dist/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -4
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/native/dist/dist/utils/determineTheme.d.ts +0 -3
- package/native/dist/dist/utils/determineTheme.d.ts.map +0 -1
- package/native/dist/dist/utils/domElements.d.ts +0 -3
- package/native/dist/dist/utils/domElements.d.ts.map +0 -1
- package/native/dist/dist/utils/empties.d.ts +0 -4
- package/native/dist/dist/utils/empties.d.ts.map +0 -1
- package/native/dist/dist/utils/error.d.ts +0 -6
- package/native/dist/dist/utils/error.d.ts.map +0 -1
- package/native/dist/dist/utils/errors.d.ts +0 -21
- package/native/dist/dist/utils/errors.d.ts.map +0 -1
- package/native/dist/dist/utils/escape.d.ts +0 -6
- package/native/dist/dist/utils/escape.d.ts.map +0 -1
- package/native/dist/dist/utils/flatten.d.ts +0 -5
- package/native/dist/dist/utils/flatten.d.ts.map +0 -1
- package/native/dist/dist/utils/generateAlphabeticName.d.ts +0 -2
- package/native/dist/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/native/dist/dist/utils/generateComponentId.d.ts +0 -2
- package/native/dist/dist/utils/generateComponentId.d.ts.map +0 -1
- package/native/dist/dist/utils/generateDisplayName.d.ts +0 -3
- package/native/dist/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/native/dist/dist/utils/getComponentName.d.ts +0 -3
- package/native/dist/dist/utils/getComponentName.d.ts.map +0 -1
- package/native/dist/dist/utils/hash.d.ts +0 -4
- package/native/dist/dist/utils/hash.d.ts.map +0 -1
- package/native/dist/dist/utils/hoist.d.ts +0 -52
- package/native/dist/dist/utils/hoist.d.ts.map +0 -1
- package/native/dist/dist/utils/hyphenateStyleName.d.ts +0 -15
- package/native/dist/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/native/dist/dist/utils/interleave.d.ts +0 -3
- package/native/dist/dist/utils/interleave.d.ts.map +0 -1
- package/native/dist/dist/utils/isFunction.d.ts +0 -2
- package/native/dist/dist/utils/isFunction.d.ts.map +0 -1
- package/native/dist/dist/utils/isPlainObject.d.ts +0 -2
- package/native/dist/dist/utils/isPlainObject.d.ts.map +0 -1
- package/native/dist/dist/utils/isStatelessFunction.d.ts +0 -2
- package/native/dist/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/native/dist/dist/utils/isStaticRules.d.ts +0 -3
- package/native/dist/dist/utils/isStaticRules.d.ts.map +0 -1
- package/native/dist/dist/utils/isStyledComponent.d.ts +0 -3
- package/native/dist/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/native/dist/dist/utils/isTag.d.ts +0 -3
- package/native/dist/dist/utils/isTag.d.ts.map +0 -1
- package/native/dist/dist/utils/joinStrings.d.ts +0 -5
- package/native/dist/dist/utils/joinStrings.d.ts.map +0 -1
- package/native/dist/dist/utils/mixinDeep.d.ts +0 -8
- package/native/dist/dist/utils/mixinDeep.d.ts.map +0 -1
- package/native/dist/dist/utils/nonce.d.ts +0 -2
- package/native/dist/dist/utils/nonce.d.ts.map +0 -1
- package/native/dist/dist/utils/stylis.d.ts +0 -10
- package/native/dist/dist/utils/stylis.d.ts.map +0 -1
- package/native/dist/hoc/withTheme.d.ts.map +0 -1
- package/native/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/native/dist/hooks/useTheme.d.ts.map +0 -1
- package/native/dist/index-standalone.d.ts.map +0 -1
- package/native/dist/index.d.ts.map +0 -1
- package/native/dist/macro/index.d.ts.map +0 -1
- package/native/dist/macro/test/babel.config.d.ts +0 -1
- package/native/dist/macro/test/babel.config.d.ts.map +0 -1
- package/native/dist/models/ComponentStyle.d.ts.map +0 -1
- package/native/dist/models/GlobalStyle.d.ts.map +0 -1
- package/native/dist/models/InlineStyle.d.ts.map +0 -1
- package/native/dist/models/Keyframes.d.ts.map +0 -1
- package/native/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/native/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/native/dist/models/StyledComponent.d.ts.map +0 -1
- package/native/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/native/dist/models/ThemeProvider.d.ts.map +0 -1
- package/native/dist/native/index.d.ts.map +0 -1
- package/native/dist/primitives/index.d.ts +0 -23
- package/native/dist/primitives/index.d.ts.map +0 -1
- package/native/dist/secretInternals.d.ts.map +0 -1
- package/native/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/native/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/native/dist/sheet/Rehydration.d.ts.map +0 -1
- package/native/dist/sheet/Sheet.d.ts.map +0 -1
- package/native/dist/sheet/Tag.d.ts.map +0 -1
- package/native/dist/sheet/dom.d.ts.map +0 -1
- package/native/dist/sheet/index.d.ts.map +0 -1
- package/native/dist/sheet/types.d.ts.map +0 -1
- package/native/dist/test/globals.d.ts.map +0 -1
- package/native/dist/test/utils.d.ts.map +0 -1
- package/native/dist/types.d.ts.map +0 -1
- package/native/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/native/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/native/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/native/dist/utils/determineTheme.d.ts.map +0 -1
- package/native/dist/utils/domElements.d.ts.map +0 -1
- package/native/dist/utils/empties.d.ts.map +0 -1
- package/native/dist/utils/error.d.ts.map +0 -1
- package/native/dist/utils/errors.d.ts.map +0 -1
- package/native/dist/utils/escape.d.ts.map +0 -1
- package/native/dist/utils/flatten.d.ts.map +0 -1
- package/native/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/native/dist/utils/generateComponentId.d.ts.map +0 -1
- package/native/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/native/dist/utils/getComponentName.d.ts.map +0 -1
- package/native/dist/utils/hash.d.ts.map +0 -1
- package/native/dist/utils/hoist.d.ts.map +0 -1
- package/native/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/native/dist/utils/interleave.d.ts.map +0 -1
- package/native/dist/utils/isFunction.d.ts.map +0 -1
- package/native/dist/utils/isPlainObject.d.ts.map +0 -1
- package/native/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/native/dist/utils/isStaticRules.d.ts.map +0 -1
- package/native/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/native/dist/utils/isTag.d.ts.map +0 -1
- package/native/dist/utils/joinStrings.d.ts.map +0 -1
- package/native/dist/utils/mixinDeep.d.ts.map +0 -1
- package/native/dist/utils/nonce.d.ts.map +0 -1
- package/native/dist/utils/stylis.d.ts.map +0 -1
|
@@ -1,21 +1,65 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import StyleSheet from '../sheet';
|
|
3
|
-
import { Stringifier } from '../types';
|
|
4
|
-
declare type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
disableVendorPrefixes?: boolean;
|
|
8
|
-
sheet?: StyleSheet;
|
|
9
|
-
stylisPlugins?: stylis.Middleware[];
|
|
10
|
-
target?: HTMLElement;
|
|
3
|
+
import { ShouldForwardProp, Stringifier } from '../types';
|
|
4
|
+
export declare type IStyleSheetContext = {
|
|
5
|
+
shouldForwardProp?: ShouldForwardProp<'web'>;
|
|
6
|
+
styleSheet?: StyleSheet;
|
|
11
7
|
};
|
|
12
|
-
export declare const StyleSheetContext: React.Context<
|
|
13
|
-
export declare const StyleSheetConsumer: React.Consumer<
|
|
14
|
-
export declare
|
|
15
|
-
export declare const
|
|
8
|
+
export declare const StyleSheetContext: React.Context<IStyleSheetContext>;
|
|
9
|
+
export declare const StyleSheetConsumer: React.Consumer<IStyleSheetContext>;
|
|
10
|
+
export declare type IStylisContext = Stringifier | void;
|
|
11
|
+
export declare const StylisContext: React.Context<IStylisContext>;
|
|
12
|
+
export declare const StylisConsumer: React.Consumer<IStylisContext>;
|
|
16
13
|
export declare const mainSheet: StyleSheet;
|
|
17
14
|
export declare const mainStylis: Stringifier;
|
|
15
|
+
export declare function useShouldForwardProp(): ShouldForwardProp<"web"> | undefined;
|
|
18
16
|
export declare function useStyleSheet(): StyleSheet;
|
|
19
17
|
export declare function useStylis(): Stringifier;
|
|
20
|
-
export
|
|
21
|
-
|
|
18
|
+
export declare 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?: 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
|
+
disableVendorPrefixes?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Provide an optional selector to be prepended to all generated style rules.
|
|
32
|
+
*/
|
|
33
|
+
namespace?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Create and provide your own `StyleSheet` if necessary for advanced SSR scenarios.
|
|
36
|
+
*/
|
|
37
|
+
sheet?: 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?: 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?: stylis.Middleware[];
|
|
60
|
+
/**
|
|
61
|
+
* Provide an alternate DOM node to host generated styles; useful for iframes.
|
|
62
|
+
*/
|
|
63
|
+
target?: HTMLElement;
|
|
64
|
+
}>;
|
|
65
|
+
export declare function StyleSheetManager(props: IStyleSheetManager): JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IStyledComponentFactory, RuleSet, StyledOptions, WebTarget } from '../types';
|
|
2
|
-
declare function createStyledComponent<Target extends WebTarget, OuterProps
|
|
2
|
+
declare function createStyledComponent<Target extends WebTarget, OuterProps extends object, Statics extends object = object>(target: Target, options: StyledOptions<'web', OuterProps>, rules: RuleSet<OuterProps>): ReturnType<IStyledComponentFactory<'web', Target, OuterProps, Statics>>;
|
|
3
3
|
export default createStyledComponent;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const _default: (InlineStyle: IInlineStyleConstructor<any>) => <Target extends NativeTarget, OuterProps extends
|
|
1
|
+
import type { 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 = object>(target: Target, options: StyledOptions<"native", OuterProps>, rules: RuleSet<OuterProps>) => IStyledComponent<"native", Target, OuterProps & object> & Statics & object;
|
|
3
3
|
export default _default;
|
|
@@ -27,7 +27,7 @@ export interface DefaultTheme {
|
|
|
27
27
|
declare type ThemeFn = (outerTheme?: DefaultTheme) => DefaultTheme;
|
|
28
28
|
declare type ThemeArgument = DefaultTheme | ThemeFn;
|
|
29
29
|
declare type Props = {
|
|
30
|
-
children?: React.
|
|
30
|
+
children?: React.ReactNode;
|
|
31
31
|
theme: ThemeArgument;
|
|
32
32
|
};
|
|
33
33
|
export declare const ThemeContext: React.Context<DefaultTheme | undefined>;
|
|
@@ -1,41 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Styled } from '../constructors/constructWithOptions';
|
|
3
3
|
import css from '../constructors/css';
|
|
4
4
|
import withTheme from '../hoc/withTheme';
|
|
5
5
|
import useTheme from '../hooks/useTheme';
|
|
6
6
|
import ThemeProvider, { ThemeConsumer, ThemeContext } from '../models/ThemeProvider';
|
|
7
7
|
import { NativeTarget } from '../types';
|
|
8
8
|
import isStyledComponent from '../utils/isStyledComponent';
|
|
9
|
-
declare const styled: (<Target extends NativeTarget>(tag: Target) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
TouchableHighlight: NativeStyled<typeof import("react-native").TouchableHighlight, import("react-native").TouchableHighlightProps, unknown, unknown>;
|
|
35
|
-
TouchableOpacity: NativeStyled<typeof import("react-native").TouchableOpacity, import("react-native").TouchableOpacityProps, unknown, unknown>;
|
|
36
|
-
View: NativeStyled<typeof import("react-native").View, import("react-native").ViewProps, unknown, unknown>;
|
|
37
|
-
VirtualizedList: NativeStyled<typeof import("react-native").VirtualizedList, import("react-native").VirtualizedListProps<unknown>, unknown, unknown>;
|
|
9
|
+
declare const styled: (<Target extends NativeTarget>(tag: Target) => Styled<"native", Target, Target extends import("../types").KnownTarget ? React.ComponentPropsWithRef<Target> : object, object, object>) & {
|
|
10
|
+
ActivityIndicator: Styled<"native", typeof import("react-native").ActivityIndicator, object, object, object>;
|
|
11
|
+
Button: Styled<"native", typeof import("react-native").Button, object, object, object>;
|
|
12
|
+
DatePickerIOS: Styled<"native", typeof import("react-native").DatePickerIOS, object, object, object>;
|
|
13
|
+
DrawerLayoutAndroid: Styled<"native", typeof import("react-native").DrawerLayoutAndroid, object, object, object>;
|
|
14
|
+
FlatList: Styled<"native", typeof import("react-native").FlatList, object, object, object>;
|
|
15
|
+
Image: Styled<"native", typeof import("react-native").Image, object, object, object>;
|
|
16
|
+
ImageBackground: Styled<"native", typeof import("react-native").ImageBackground, object, object, object>;
|
|
17
|
+
KeyboardAvoidingView: Styled<"native", typeof import("react-native").KeyboardAvoidingView, object, object, object>;
|
|
18
|
+
Modal: Styled<"native", typeof import("react-native").Modal, object, object, object>;
|
|
19
|
+
Pressable: Styled<"native", import("react").ForwardRefExoticComponent<import("react-native").PressableProps & import("react").RefAttributes<import("react-native").View>>, object, object, object>;
|
|
20
|
+
ProgressBarAndroid: Styled<"native", typeof import("react-native").ProgressBarAndroid, object, object, object>;
|
|
21
|
+
ProgressViewIOS: Styled<"native", typeof import("react-native").ProgressViewIOS, object, object, object>;
|
|
22
|
+
RefreshControl: Styled<"native", typeof import("react-native").RefreshControl, object, object, object>;
|
|
23
|
+
SafeAreaView: Styled<"native", typeof import("react-native").SafeAreaView, object, object, object>;
|
|
24
|
+
ScrollView: Styled<"native", typeof import("react-native").ScrollView, object, object, object>;
|
|
25
|
+
SectionList: Styled<"native", typeof import("react-native").SectionList, object, object, object>;
|
|
26
|
+
Slider: Styled<"native", typeof import("react-native").Slider, object, object, object>;
|
|
27
|
+
Switch: Styled<"native", typeof import("react-native").Switch, object, object, object>;
|
|
28
|
+
Text: Styled<"native", typeof import("react-native").Text, object, object, object>;
|
|
29
|
+
TextInput: Styled<"native", typeof import("react-native").TextInput, object, object, object>;
|
|
30
|
+
TouchableHighlight: Styled<"native", typeof import("react-native").TouchableHighlight, object, object, object>;
|
|
31
|
+
TouchableOpacity: Styled<"native", typeof import("react-native").TouchableOpacity, object, object, object>;
|
|
32
|
+
View: Styled<"native", typeof import("react-native").View, object, object, object>;
|
|
33
|
+
VirtualizedList: Styled<"native", typeof import("react-native").VirtualizedList, object, object, object>;
|
|
38
34
|
};
|
|
39
|
-
export {
|
|
35
|
+
export { DefaultTheme, ExecutionContext, ExecutionProps, IStyledComponent, IStyledComponentFactory, IStyledStatics, NativeTarget, PolymorphicComponent, PolymorphicComponentProps, Runtime, StyledObject, StyledOptions, } from '../types';
|
|
40
36
|
export { css, isStyledComponent, ThemeProvider, ThemeConsumer, ThemeContext, withTheme, useTheme };
|
|
41
|
-
export default
|
|
37
|
+
export { styled, styled as default };
|
|
@@ -10,11 +10,11 @@ var unitless = require('@emotion/unitless');
|
|
|
10
10
|
var transformDeclPairs = require('css-to-react-native');
|
|
11
11
|
var postcss = require('postcss');
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
15
|
-
var React__default = /*#__PURE__*/
|
|
16
|
-
var unitless__default = /*#__PURE__*/
|
|
17
|
-
var transformDeclPairs__default = /*#__PURE__*/
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
16
|
+
var unitless__default = /*#__PURE__*/_interopDefault(unitless);
|
|
17
|
+
var transformDeclPairs__default = /*#__PURE__*/_interopDefault(transformDeclPairs);
|
|
18
18
|
|
|
19
19
|
var EMPTY_ARRAY = Object.freeze([]);
|
|
20
20
|
var EMPTY_OBJECT = Object.freeze({});
|
|
@@ -75,22 +75,24 @@ function throwStyledComponentsError(code) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
78
|
+
var SC_ATTR = (typeof process !== 'undefined' && typeof process.env !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
79
79
|
'data-styled';
|
|
80
80
|
var SC_ATTR_ACTIVE = 'active';
|
|
81
81
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
82
|
-
var SC_VERSION = "6.0.0-beta.
|
|
82
|
+
var SC_VERSION = "6.0.0-beta.11";
|
|
83
83
|
var SPLITTER = '/*!sc*/\n';
|
|
84
84
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
85
85
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
86
86
|
? SC_DISABLE_SPEEDY
|
|
87
87
|
: typeof process !== 'undefined' &&
|
|
88
|
+
typeof process.env !== 'undefined' &&
|
|
88
89
|
typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
|
|
89
90
|
process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''
|
|
90
91
|
? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false'
|
|
91
92
|
? false
|
|
92
93
|
: process.env.REACT_APP_SC_DISABLE_SPEEDY
|
|
93
94
|
: typeof process !== 'undefined' &&
|
|
95
|
+
typeof process.env !== 'undefined' &&
|
|
94
96
|
typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' &&
|
|
95
97
|
process.env.SC_DISABLE_SPEEDY !== ''
|
|
96
98
|
? process.env.SC_DISABLE_SPEEDY === 'false'
|
|
@@ -239,7 +241,6 @@ var rehydrateNamesFromContent = function (sheet, id, content) {
|
|
|
239
241
|
var names = content.split(',');
|
|
240
242
|
var name;
|
|
241
243
|
for (var i = 0, l = names.length; i < l; i++) {
|
|
242
|
-
// eslint-disable-next-line
|
|
243
244
|
if ((name = names[i])) {
|
|
244
245
|
sheet.registerName(id, name);
|
|
245
246
|
}
|
|
@@ -549,6 +550,28 @@ var COMPLEX_SELECTOR_PREFIX = [':', '[', '.', '#'];
|
|
|
549
550
|
function serialize(children, callback) {
|
|
550
551
|
return children.map(function (c, i) { return callback(c, i, children, callback); }).filter(Boolean);
|
|
551
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Takes an element and recurses through it's rules added the namespace to the start of each selector.
|
|
555
|
+
* Takes into account media queries by recursing through child rules if they are present.
|
|
556
|
+
*/
|
|
557
|
+
function recursivelySetNamepace(compiled, namespace) {
|
|
558
|
+
return compiled.map(function (rule) {
|
|
559
|
+
if (rule.type === 'rule') {
|
|
560
|
+
// add the namespace to the start
|
|
561
|
+
rule.value = "".concat(namespace, " ").concat(rule.value);
|
|
562
|
+
// add the namespace after each comma for subsequent selectors.
|
|
563
|
+
// @ts-expect-error we target modern browsers but intentionally transpile to ES5 for speed
|
|
564
|
+
rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
|
|
565
|
+
rule.props = rule.props.map(function (prop) {
|
|
566
|
+
return "".concat(namespace, " ").concat(prop);
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
if (Array.isArray(rule.children)) {
|
|
570
|
+
rule.children = recursivelySetNamepace(rule.children, namespace);
|
|
571
|
+
}
|
|
572
|
+
return rule;
|
|
573
|
+
});
|
|
574
|
+
}
|
|
552
575
|
function createStylisInstance(_a) {
|
|
553
576
|
var _b = _a === void 0 ? EMPTY_OBJECT : _a, _c = _b.options, options = _c === void 0 ? EMPTY_OBJECT : _c, _d = _b.plugins, plugins = _d === void 0 ? EMPTY_ARRAY : _d;
|
|
554
577
|
var _componentId;
|
|
@@ -582,7 +605,11 @@ function createStylisInstance(_a) {
|
|
|
582
605
|
props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
|
|
583
606
|
}
|
|
584
607
|
};
|
|
585
|
-
var stringifyRules = function (css, selector,
|
|
608
|
+
var stringifyRules = function (css, selector,
|
|
609
|
+
/**
|
|
610
|
+
* This "prefix" referes to a _selector_ prefix.
|
|
611
|
+
*/
|
|
612
|
+
prefix, componentId) {
|
|
586
613
|
if (selector === void 0) { selector = ''; }
|
|
587
614
|
if (prefix === void 0) { prefix = ''; }
|
|
588
615
|
if (componentId === void 0) { componentId = '&'; }
|
|
@@ -595,11 +622,18 @@ function createStylisInstance(_a) {
|
|
|
595
622
|
_selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
|
|
596
623
|
_consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
|
|
597
624
|
var middlewares = plugins.slice();
|
|
625
|
+
/**
|
|
626
|
+
* Enables automatic vendor-prefixing for styles.
|
|
627
|
+
*/
|
|
598
628
|
if (options.prefix || options.prefix === undefined) {
|
|
599
629
|
middlewares.unshift(stylis.prefixer);
|
|
600
630
|
}
|
|
601
631
|
middlewares.push(selfReferenceReplacementPlugin, stylis.stringify);
|
|
602
|
-
|
|
632
|
+
var compiled = stylis.compile(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
|
|
633
|
+
if (options.namespace) {
|
|
634
|
+
compiled = recursivelySetNamepace(compiled, options.namespace);
|
|
635
|
+
}
|
|
636
|
+
return serialize(compiled, stylis.middleware(middlewares));
|
|
603
637
|
};
|
|
604
638
|
stringifyRules.hash = plugins.length
|
|
605
639
|
? plugins
|
|
@@ -614,9 +648,12 @@ function createStylisInstance(_a) {
|
|
|
614
648
|
return stringifyRules;
|
|
615
649
|
}
|
|
616
650
|
|
|
617
|
-
var StyleSheetContext = React__default
|
|
651
|
+
var StyleSheetContext = React__default.default.createContext({
|
|
652
|
+
shouldForwardProp: undefined,
|
|
653
|
+
styleSheet: undefined,
|
|
654
|
+
});
|
|
618
655
|
StyleSheetContext.Consumer;
|
|
619
|
-
var StylisContext = React__default
|
|
656
|
+
var StylisContext = React__default.default.createContext(undefined);
|
|
620
657
|
StylisContext.Consumer;
|
|
621
658
|
new StyleSheet();
|
|
622
659
|
var mainStylis = createStylisInstance();
|
|
@@ -651,7 +688,7 @@ function addUnitIfNeeded(name, value) {
|
|
|
651
688
|
if (value == null || typeof value === 'boolean' || value === '') {
|
|
652
689
|
return '';
|
|
653
690
|
}
|
|
654
|
-
if (typeof value === 'number' && value !== 0 && !(name in unitless__default
|
|
691
|
+
if (typeof value === 'number' && value !== 0 && !(name in unitless__default.default)) {
|
|
655
692
|
return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
|
|
656
693
|
}
|
|
657
694
|
return String(value).trim();
|
|
@@ -668,8 +705,8 @@ function getComponentName(target) {
|
|
|
668
705
|
* inlined version of
|
|
669
706
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
670
707
|
*/
|
|
671
|
-
var uppercaseCheck = /
|
|
672
|
-
var uppercasePattern = /
|
|
708
|
+
var uppercaseCheck = /[A-Z]/;
|
|
709
|
+
var uppercasePattern = /[A-Z]/g;
|
|
673
710
|
var msPattern = /^ms-/;
|
|
674
711
|
var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
|
|
675
712
|
/**
|
|
@@ -686,7 +723,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
|
|
|
686
723
|
* is converted to `-ms-`.
|
|
687
724
|
*/
|
|
688
725
|
function hyphenateStyleName(string) {
|
|
689
|
-
return uppercaseCheck.test(string)
|
|
726
|
+
return uppercaseCheck.test(string) && !string.startsWith('--')
|
|
690
727
|
? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
|
|
691
728
|
: string;
|
|
692
729
|
}
|
|
@@ -742,21 +779,18 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
742
779
|
var ruleSet = [];
|
|
743
780
|
for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
|
|
744
781
|
result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
|
|
745
|
-
if (result ===
|
|
782
|
+
if (result.length === 0)
|
|
746
783
|
continue;
|
|
747
|
-
|
|
748
|
-
ruleSet.push.apply(ruleSet, result);
|
|
749
|
-
else
|
|
750
|
-
ruleSet.push(result);
|
|
784
|
+
ruleSet.push.apply(ruleSet, result);
|
|
751
785
|
}
|
|
752
786
|
return ruleSet;
|
|
753
787
|
}
|
|
754
788
|
if (isFalsish(chunk)) {
|
|
755
|
-
return
|
|
789
|
+
return [];
|
|
756
790
|
}
|
|
757
791
|
/* Handle other components */
|
|
758
792
|
if (isStyledComponent(chunk)) {
|
|
759
|
-
return ".".concat(chunk.styledComponentId);
|
|
793
|
+
return [".".concat(chunk.styledComponentId)];
|
|
760
794
|
}
|
|
761
795
|
/* Either execute or defer the function */
|
|
762
796
|
if (isFunction(chunk)) {
|
|
@@ -767,27 +801,27 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
767
801
|
typeof result === 'object' &&
|
|
768
802
|
!Array.isArray(result) &&
|
|
769
803
|
!(result instanceof Keyframes) &&
|
|
770
|
-
!isPlainObject(result)
|
|
771
|
-
|
|
772
|
-
console.error("".concat(getComponentName(
|
|
773
|
-
// @ts-expect-error handling unexpected input
|
|
774
|
-
chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
|
|
804
|
+
!isPlainObject(result) &&
|
|
805
|
+
result !== null) {
|
|
806
|
+
console.error("".concat(getComponentName(chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
|
|
775
807
|
}
|
|
776
808
|
return flatten(result, executionContext, styleSheet, stylisInstance);
|
|
777
809
|
}
|
|
778
|
-
else
|
|
779
|
-
return chunk;
|
|
810
|
+
else {
|
|
811
|
+
return [chunk];
|
|
812
|
+
}
|
|
780
813
|
}
|
|
781
814
|
if (chunk instanceof Keyframes) {
|
|
782
815
|
if (styleSheet) {
|
|
783
816
|
chunk.inject(styleSheet, stylisInstance);
|
|
784
|
-
return chunk.getName(stylisInstance);
|
|
817
|
+
return [chunk.getName(stylisInstance)];
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
return [chunk];
|
|
785
821
|
}
|
|
786
|
-
else
|
|
787
|
-
return chunk;
|
|
788
822
|
}
|
|
789
823
|
/* Handle objects */
|
|
790
|
-
return isPlainObject(chunk) ? objToCssArray(chunk) : chunk.toString();
|
|
824
|
+
return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
|
|
791
825
|
}
|
|
792
826
|
|
|
793
827
|
function interleave(strings, interpolations) {
|
|
@@ -803,11 +837,7 @@ function interleave(strings, interpolations) {
|
|
|
803
837
|
* expand an array of styles.
|
|
804
838
|
*/
|
|
805
839
|
var addTag = function (arg) {
|
|
806
|
-
|
|
807
|
-
// eslint-disable-next-line no-param-reassign
|
|
808
|
-
arg.isCss = true;
|
|
809
|
-
}
|
|
810
|
-
return arg;
|
|
840
|
+
return Object.assign(arg, { isCss: true });
|
|
811
841
|
};
|
|
812
842
|
function css(styles) {
|
|
813
843
|
var interpolations = [];
|
|
@@ -824,7 +854,7 @@ function css(styles) {
|
|
|
824
854
|
if (interpolations.length === 0 &&
|
|
825
855
|
styleStringArray.length === 1 &&
|
|
826
856
|
typeof styleStringArray[0] === 'string') {
|
|
827
|
-
return styleStringArray;
|
|
857
|
+
return flatten(styleStringArray);
|
|
828
858
|
}
|
|
829
859
|
return addTag(flatten(interleave(styleStringArray, interpolations)));
|
|
830
860
|
}
|
|
@@ -858,7 +888,7 @@ function constructWithOptions(componentConstructor, tag, options) {
|
|
|
858
888
|
return templateFunction;
|
|
859
889
|
}
|
|
860
890
|
|
|
861
|
-
var ThemeContext = React__default
|
|
891
|
+
var ThemeContext = React__default.default.createContext(undefined);
|
|
862
892
|
var ThemeConsumer = ThemeContext.Consumer;
|
|
863
893
|
function mergeTheme(theme, outerTheme) {
|
|
864
894
|
if (!theme) {
|
|
@@ -887,7 +917,7 @@ function ThemeProvider(props) {
|
|
|
887
917
|
if (!props.children) {
|
|
888
918
|
return null;
|
|
889
919
|
}
|
|
890
|
-
return React__default
|
|
920
|
+
return React__default.default.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
|
|
891
921
|
}
|
|
892
922
|
|
|
893
923
|
function determineTheme(props, providedTheme, defaultProps) {
|
|
@@ -1001,14 +1031,13 @@ function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
|
|
|
1001
1031
|
}
|
|
1002
1032
|
|
|
1003
1033
|
function withTheme(Component) {
|
|
1004
|
-
var WithTheme = React__default
|
|
1005
|
-
var theme = React__default
|
|
1034
|
+
var WithTheme = React__default.default.forwardRef(function (props, ref) {
|
|
1035
|
+
var theme = React__default.default.useContext(ThemeContext);
|
|
1006
1036
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
1007
1037
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
1008
|
-
// eslint-disable-next-line no-console
|
|
1009
1038
|
console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"".concat(getComponentName(Component), "\""));
|
|
1010
1039
|
}
|
|
1011
|
-
return React__default
|
|
1040
|
+
return React__default.default.createElement(Component, tslib.__assign({}, props, { theme: themeProp, ref: ref }));
|
|
1012
1041
|
});
|
|
1013
1042
|
WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
|
|
1014
1043
|
return hoistNonReactStatics(WithTheme, Component);
|
|
@@ -1058,11 +1087,10 @@ function makeInlineStyleClass(styleSheet) {
|
|
|
1058
1087
|
declPairs_1.push([node.prop, node.value]);
|
|
1059
1088
|
}
|
|
1060
1089
|
else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {
|
|
1061
|
-
/* eslint-disable no-console */
|
|
1062
1090
|
console.warn("Node of type ".concat(node.type, " not supported as an inline style"));
|
|
1063
1091
|
}
|
|
1064
1092
|
});
|
|
1065
|
-
var styleObject = transformDeclPairs__default
|
|
1093
|
+
var styleObject = transformDeclPairs__default.default(declPairs_1);
|
|
1066
1094
|
var styles = styleSheet.create({
|
|
1067
1095
|
generated: styleObject,
|
|
1068
1096
|
});
|
|
@@ -1111,7 +1139,6 @@ function mixinRecursively(target, source, forceMerge) {
|
|
|
1111
1139
|
* Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
|
|
1112
1140
|
*/
|
|
1113
1141
|
function mixinDeep(target) {
|
|
1114
|
-
if (target === void 0) { target = {}; }
|
|
1115
1142
|
var sources = [];
|
|
1116
1143
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1117
1144
|
sources[_i - 1] = arguments[_i];
|
|
@@ -1131,20 +1158,15 @@ function useResolvedAttrs(theme, props, attrs) {
|
|
|
1131
1158
|
var context = tslib.__assign(tslib.__assign({}, props), { theme: theme });
|
|
1132
1159
|
var resolvedAttrs = {};
|
|
1133
1160
|
attrs.forEach(function (attrDef) {
|
|
1134
|
-
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1135
1161
|
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1136
1162
|
var key;
|
|
1137
|
-
/* eslint-disable guard-for-in */
|
|
1138
1163
|
for (key in resolvedAttrDef) {
|
|
1139
1164
|
// @ts-expect-error bad types
|
|
1140
1165
|
context[key] = resolvedAttrs[key] = resolvedAttrDef[key];
|
|
1141
1166
|
}
|
|
1142
|
-
/* eslint-enable guard-for-in */
|
|
1143
1167
|
});
|
|
1144
1168
|
return [context, resolvedAttrs];
|
|
1145
1169
|
}
|
|
1146
|
-
// Validator defaults to true if not in HTML/DOM env
|
|
1147
|
-
var validAttr = function () { return true; };
|
|
1148
1170
|
function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
1149
1171
|
var componentAttrs = forwardedComponent.attrs, inlineStyle = forwardedComponent.inlineStyle, defaultProps = forwardedComponent.defaultProps, shouldForwardProp = forwardedComponent.shouldForwardProp, target = forwardedComponent.target;
|
|
1150
1172
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
@@ -1154,32 +1176,25 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1154
1176
|
var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
|
|
1155
1177
|
var generatedStyles = inlineStyle.generateStyleObject(context);
|
|
1156
1178
|
var refToForward = forwardedRef;
|
|
1157
|
-
var elementToBeCreated = attrs
|
|
1179
|
+
var elementToBeCreated = attrs.as || props.as || target;
|
|
1158
1180
|
var computedProps = attrs !== props ? tslib.__assign(tslib.__assign({}, props), attrs) : props;
|
|
1159
1181
|
var propsForElement = {};
|
|
1160
|
-
// eslint-disable-next-line guard-for-in
|
|
1161
1182
|
for (var key in computedProps) {
|
|
1162
1183
|
if (key[0] === '$' || key === 'as')
|
|
1163
1184
|
continue;
|
|
1164
1185
|
else if (key === 'forwardedAs') {
|
|
1165
1186
|
propsForElement.as = computedProps[key];
|
|
1166
1187
|
}
|
|
1167
|
-
else if (!shouldForwardProp || shouldForwardProp(key,
|
|
1188
|
+
else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
|
|
1168
1189
|
propsForElement[key] = computedProps[key];
|
|
1169
1190
|
}
|
|
1170
1191
|
}
|
|
1171
1192
|
propsForElement.style = React.useMemo(function () {
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
else if (props.style == null) {
|
|
1178
|
-
return generatedStyles;
|
|
1179
|
-
}
|
|
1180
|
-
else {
|
|
1181
|
-
return [generatedStyles].concat(props.style || []);
|
|
1182
|
-
}
|
|
1193
|
+
return typeof props.style === 'function'
|
|
1194
|
+
? function (state) { return [generatedStyles].concat(props.style(state)); }
|
|
1195
|
+
: props.style
|
|
1196
|
+
? [generatedStyles].concat(props.style)
|
|
1197
|
+
: generatedStyles;
|
|
1183
1198
|
}, [props.style, generatedStyles]);
|
|
1184
1199
|
propsForElement.ref = refToForward;
|
|
1185
1200
|
return React.createElement(elementToBeCreated, propsForElement);
|
|
@@ -1193,25 +1208,22 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1193
1208
|
var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
|
|
1194
1209
|
? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
|
|
1195
1210
|
: attrs;
|
|
1196
|
-
// eslint-disable-next-line prefer-destructuring
|
|
1197
1211
|
var shouldForwardProp = options.shouldForwardProp;
|
|
1198
1212
|
if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
|
|
1199
1213
|
var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
|
|
1200
1214
|
if (options.shouldForwardProp) {
|
|
1201
1215
|
var passedShouldForwardPropFn_1 = options.shouldForwardProp;
|
|
1202
1216
|
// compose nested shouldForwardProp calls
|
|
1203
|
-
shouldForwardProp = function (prop,
|
|
1204
|
-
return shouldForwardPropFn_1(prop,
|
|
1205
|
-
passedShouldForwardPropFn_1(prop,
|
|
1217
|
+
shouldForwardProp = function (prop, elementToBeCreated) {
|
|
1218
|
+
return shouldForwardPropFn_1(prop, elementToBeCreated) &&
|
|
1219
|
+
passedShouldForwardPropFn_1(prop, elementToBeCreated);
|
|
1206
1220
|
};
|
|
1207
1221
|
}
|
|
1208
1222
|
else {
|
|
1209
|
-
// eslint-disable-next-line prefer-destructuring
|
|
1210
1223
|
shouldForwardProp = shouldForwardPropFn_1;
|
|
1211
1224
|
}
|
|
1212
1225
|
}
|
|
1213
1226
|
var forwardRef = function (props, ref) {
|
|
1214
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1215
1227
|
return useStyledComponentImpl(WrappedStyledComponent, props, ref);
|
|
1216
1228
|
};
|
|
1217
1229
|
forwardRef.displayName = displayName;
|
|
@@ -1219,7 +1231,7 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1219
1231
|
* forwardRef creates a new interim component, which we'll take advantage of
|
|
1220
1232
|
* instead of extending ParentComponent to create _another_ interim class
|
|
1221
1233
|
*/
|
|
1222
|
-
var WrappedStyledComponent = React__default
|
|
1234
|
+
var WrappedStyledComponent = React__default.default.forwardRef(forwardRef);
|
|
1223
1235
|
WrappedStyledComponent.attrs = finalAttrs;
|
|
1224
1236
|
WrappedStyledComponent.inlineStyle = new InlineStyle(isTargetStyledComp ? styledComponentTarget.inlineStyle.rules.concat(rules) : rules);
|
|
1225
1237
|
WrappedStyledComponent.displayName = displayName;
|
|
@@ -1228,10 +1240,6 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1228
1240
|
WrappedStyledComponent.styledComponentId = true;
|
|
1229
1241
|
// fold the underlying StyledComponent target up since we folded the styles
|
|
1230
1242
|
WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
|
|
1231
|
-
WrappedStyledComponent.withComponent = function withComponent(tag) {
|
|
1232
|
-
var newOptions = tslib.__assign(tslib.__assign({}, options), { attrs: finalAttrs });
|
|
1233
|
-
return createStyledNativeComponent(tag, newOptions, rules);
|
|
1234
|
-
};
|
|
1235
1243
|
Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
|
|
1236
1244
|
get: function () {
|
|
1237
1245
|
return this._foldedDefaultProps;
|
|
@@ -1249,14 +1257,12 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1249
1257
|
displayName: true,
|
|
1250
1258
|
shouldForwardProp: true,
|
|
1251
1259
|
target: true,
|
|
1252
|
-
withComponent: true,
|
|
1253
1260
|
});
|
|
1254
1261
|
return WrappedStyledComponent;
|
|
1255
1262
|
};
|
|
1256
1263
|
return createStyledNativeComponent;
|
|
1257
1264
|
});
|
|
1258
1265
|
|
|
1259
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1260
1266
|
var reactNative = require('react-native');
|
|
1261
1267
|
var InlineStyle = makeInlineStyleClass(reactNative.StyleSheet);
|
|
1262
1268
|
var StyledNativeComponent = _StyledNativeComponent(InlineStyle);
|
|
@@ -1311,8 +1317,9 @@ exports.ThemeConsumer = ThemeConsumer;
|
|
|
1311
1317
|
exports.ThemeContext = ThemeContext;
|
|
1312
1318
|
exports.ThemeProvider = ThemeProvider;
|
|
1313
1319
|
exports.css = css;
|
|
1314
|
-
exports
|
|
1320
|
+
exports.default = styled;
|
|
1315
1321
|
exports.isStyledComponent = isStyledComponent;
|
|
1322
|
+
exports.styled = styled;
|
|
1316
1323
|
exports.useTheme = useTheme;
|
|
1317
1324
|
exports.withTheme = withTheme;
|
|
1318
1325
|
//# sourceMappingURL=styled-components.native.cjs.js.map
|