styled-components 6.0.0-alpha.5 → 6.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constructors/constructWithOptions.d.ts +27 -14
- package/dist/constructors/css.d.ts +2 -2
- package/dist/constructors/styled.d.ts +178 -178
- package/dist/hoc/withTheme.d.ts +1 -1
- package/dist/native/index.d.ts +29 -53
- package/dist/sheet/Tag.d.ts +3 -3
- package/dist/sheet/dom.d.ts +1 -1
- package/dist/styled-components-macro.cjs.js +1 -1
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components-macro.esm.js +1 -1
- package/dist/styled-components-macro.esm.js.map +1 -1
- 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 +1 -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/utils.d.ts +178 -178
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +17 -20
- package/dist/utils/checkDynamicCreation.d.ts +1 -1
- package/dist/utils/flatten.d.ts +1 -1
- package/native/dist/constructors/constructWithOptions.d.ts +27 -14
- package/native/dist/constructors/css.d.ts +2 -2
- package/native/dist/constructors/styled.d.ts +178 -178
- package/native/dist/hoc/withTheme.d.ts +1 -1
- package/native/dist/native/index.d.ts +29 -53
- package/native/dist/sheet/Tag.d.ts +3 -3
- package/native/dist/sheet/dom.d.ts +1 -1
- package/native/dist/styled-components.native.cjs.js +404 -468
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +401 -465
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/test/utils.d.ts +178 -178
- package/native/dist/types.d.ts +17 -20
- package/native/dist/utils/checkDynamicCreation.d.ts +1 -1
- package/native/dist/utils/flatten.d.ts +1 -1
- package/package.json +25 -29
- package/dist/primitives/index.d.ts +0 -23
- package/primitives/dist/base.d.ts +0 -18
- package/primitives/dist/base.d.ts.map +0 -1
- package/primitives/dist/constants.d.ts +0 -8
- package/primitives/dist/constants.d.ts.map +0 -1
- package/primitives/dist/constructors/constructWithOptions.d.ts +0 -19
- package/primitives/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/primitives/dist/constructors/createGlobalStyle.d.ts +0 -3
- package/primitives/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/primitives/dist/constructors/css.d.ts +0 -4
- package/primitives/dist/constructors/css.d.ts.map +0 -1
- package/primitives/dist/constructors/keyframes.d.ts +0 -3
- package/primitives/dist/constructors/keyframes.d.ts.map +0 -1
- package/primitives/dist/constructors/styled.d.ts +0 -185
- package/primitives/dist/constructors/styled.d.ts.map +0 -1
- package/primitives/dist/dist/base.d.ts +0 -18
- package/primitives/dist/dist/base.d.ts.map +0 -1
- package/primitives/dist/dist/constants.d.ts +0 -9
- package/primitives/dist/dist/constants.d.ts.map +0 -1
- package/primitives/dist/dist/constructors/constructWithOptions.d.ts +0 -20
- package/primitives/dist/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/primitives/dist/dist/constructors/createGlobalStyle.d.ts +0 -4
- package/primitives/dist/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/primitives/dist/dist/constructors/css.d.ts +0 -5
- package/primitives/dist/dist/constructors/css.d.ts.map +0 -1
- package/primitives/dist/dist/constructors/keyframes.d.ts +0 -4
- package/primitives/dist/dist/constructors/keyframes.d.ts.map +0 -1
- package/primitives/dist/dist/constructors/styled.d.ts +0 -186
- package/primitives/dist/dist/constructors/styled.d.ts.map +0 -1
- package/primitives/dist/dist/hoc/withTheme.d.ts +0 -4
- package/primitives/dist/dist/hoc/withTheme.d.ts.map +0 -1
- package/primitives/dist/dist/hoc/withTheme.spec.d.ts +0 -2
- package/primitives/dist/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/primitives/dist/dist/hooks/useTheme.d.ts +0 -4
- package/primitives/dist/dist/hooks/useTheme.d.ts.map +0 -1
- package/primitives/dist/dist/index-standalone.d.ts +0 -3
- package/primitives/dist/dist/index-standalone.d.ts.map +0 -1
- package/primitives/dist/dist/index.d.ts +0 -4
- package/primitives/dist/dist/index.d.ts.map +0 -1
- package/primitives/dist/dist/macro/index.d.ts +0 -3
- package/primitives/dist/dist/macro/index.d.ts.map +0 -1
- package/primitives/dist/dist/macro/test/babel.config.d.ts +0 -1
- package/primitives/dist/dist/macro/test/babel.config.d.ts.map +0 -1
- package/primitives/dist/dist/models/ComponentStyle.d.ts +0 -16
- package/primitives/dist/dist/models/ComponentStyle.d.ts.map +0 -1
- package/primitives/dist/dist/models/GlobalStyle.d.ts +0 -12
- package/primitives/dist/dist/models/GlobalStyle.d.ts.map +0 -1
- package/primitives/dist/dist/models/InlineStyle.d.ts +0 -7
- package/primitives/dist/dist/models/InlineStyle.d.ts.map +0 -1
- package/primitives/dist/dist/models/Keyframes.d.ts +0 -12
- package/primitives/dist/dist/models/Keyframes.d.ts.map +0 -1
- package/primitives/dist/dist/models/ServerStyleSheet.d.ts +0 -16
- package/primitives/dist/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/primitives/dist/dist/models/StyleSheetManager.d.ts +0 -22
- package/primitives/dist/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/primitives/dist/dist/models/StyledComponent.d.ts +0 -4
- package/primitives/dist/dist/models/StyledComponent.d.ts.map +0 -1
- package/primitives/dist/dist/models/StyledNativeComponent.d.ts +0 -4
- package/primitives/dist/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/primitives/dist/dist/models/ThemeProvider.d.ts +0 -18
- package/primitives/dist/dist/models/ThemeProvider.d.ts.map +0 -1
- package/primitives/dist/dist/native/index.d.ts +0 -65
- package/primitives/dist/dist/native/index.d.ts.map +0 -1
- package/primitives/dist/dist/primitives/index.d.ts +0 -23
- package/primitives/dist/dist/primitives/index.d.ts.map +0 -1
- package/primitives/dist/dist/secretInternals.d.ts +0 -6
- package/primitives/dist/dist/secretInternals.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/GroupIDAllocator.d.ts +0 -5
- package/primitives/dist/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/GroupedTag.d.ts +0 -12
- package/primitives/dist/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/Rehydration.d.ts +0 -4
- package/primitives/dist/dist/sheet/Rehydration.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/Sheet.d.ts +0 -41
- package/primitives/dist/dist/sheet/Sheet.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/Tag.d.ts +0 -55
- package/primitives/dist/dist/sheet/Tag.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/dom.d.ts +0 -5
- package/primitives/dist/dist/sheet/dom.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/index.d.ts +0 -2
- package/primitives/dist/dist/sheet/index.d.ts.map +0 -1
- package/primitives/dist/dist/sheet/types.d.ts +0 -35
- package/primitives/dist/dist/sheet/types.d.ts.map +0 -1
- package/primitives/dist/dist/test/globals.d.ts +0 -3
- package/primitives/dist/dist/test/globals.d.ts.map +0 -1
- package/primitives/dist/dist/test/utils.d.ts +0 -192
- package/primitives/dist/dist/test/utils.d.ts.map +0 -1
- package/primitives/dist/dist/types.d.ts +0 -121
- package/primitives/dist/dist/types.d.ts.map +0 -1
- package/primitives/dist/dist/utils/addUnitIfNeeded.d.ts +0 -2
- package/primitives/dist/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/primitives/dist/dist/utils/checkDynamicCreation.d.ts +0 -2
- package/primitives/dist/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/primitives/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -4
- package/primitives/dist/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/primitives/dist/dist/utils/determineTheme.d.ts +0 -3
- package/primitives/dist/dist/utils/determineTheme.d.ts.map +0 -1
- package/primitives/dist/dist/utils/domElements.d.ts +0 -3
- package/primitives/dist/dist/utils/domElements.d.ts.map +0 -1
- package/primitives/dist/dist/utils/empties.d.ts +0 -4
- package/primitives/dist/dist/utils/empties.d.ts.map +0 -1
- package/primitives/dist/dist/utils/error.d.ts +0 -6
- package/primitives/dist/dist/utils/error.d.ts.map +0 -1
- package/primitives/dist/dist/utils/errors.d.ts +0 -21
- package/primitives/dist/dist/utils/errors.d.ts.map +0 -1
- package/primitives/dist/dist/utils/escape.d.ts +0 -6
- package/primitives/dist/dist/utils/escape.d.ts.map +0 -1
- package/primitives/dist/dist/utils/flatten.d.ts +0 -5
- package/primitives/dist/dist/utils/flatten.d.ts.map +0 -1
- package/primitives/dist/dist/utils/generateAlphabeticName.d.ts +0 -2
- package/primitives/dist/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/primitives/dist/dist/utils/generateComponentId.d.ts +0 -2
- package/primitives/dist/dist/utils/generateComponentId.d.ts.map +0 -1
- package/primitives/dist/dist/utils/generateDisplayName.d.ts +0 -3
- package/primitives/dist/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/primitives/dist/dist/utils/getComponentName.d.ts +0 -3
- package/primitives/dist/dist/utils/getComponentName.d.ts.map +0 -1
- package/primitives/dist/dist/utils/hash.d.ts +0 -4
- package/primitives/dist/dist/utils/hash.d.ts.map +0 -1
- package/primitives/dist/dist/utils/hoist.d.ts +0 -52
- package/primitives/dist/dist/utils/hoist.d.ts.map +0 -1
- package/primitives/dist/dist/utils/hyphenateStyleName.d.ts +0 -15
- package/primitives/dist/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/primitives/dist/dist/utils/interleave.d.ts +0 -3
- package/primitives/dist/dist/utils/interleave.d.ts.map +0 -1
- package/primitives/dist/dist/utils/isFunction.d.ts +0 -2
- package/primitives/dist/dist/utils/isFunction.d.ts.map +0 -1
- package/primitives/dist/dist/utils/isPlainObject.d.ts +0 -2
- package/primitives/dist/dist/utils/isPlainObject.d.ts.map +0 -1
- package/primitives/dist/dist/utils/isStatelessFunction.d.ts +0 -2
- package/primitives/dist/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/primitives/dist/dist/utils/isStaticRules.d.ts +0 -3
- package/primitives/dist/dist/utils/isStaticRules.d.ts.map +0 -1
- package/primitives/dist/dist/utils/isStyledComponent.d.ts +0 -3
- package/primitives/dist/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/primitives/dist/dist/utils/isTag.d.ts +0 -3
- package/primitives/dist/dist/utils/isTag.d.ts.map +0 -1
- package/primitives/dist/dist/utils/joinStrings.d.ts +0 -5
- package/primitives/dist/dist/utils/joinStrings.d.ts.map +0 -1
- package/primitives/dist/dist/utils/mixinDeep.d.ts +0 -8
- package/primitives/dist/dist/utils/mixinDeep.d.ts.map +0 -1
- package/primitives/dist/dist/utils/nonce.d.ts +0 -2
- package/primitives/dist/dist/utils/nonce.d.ts.map +0 -1
- package/primitives/dist/dist/utils/stylis.d.ts +0 -10
- package/primitives/dist/dist/utils/stylis.d.ts.map +0 -1
- package/primitives/dist/hoc/withTheme.d.ts +0 -3
- package/primitives/dist/hoc/withTheme.d.ts.map +0 -1
- package/primitives/dist/hoc/withTheme.spec.d.ts +0 -1
- package/primitives/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/primitives/dist/hooks/useTheme.d.ts +0 -3
- package/primitives/dist/hooks/useTheme.d.ts.map +0 -1
- package/primitives/dist/index-standalone.d.ts +0 -2
- package/primitives/dist/index-standalone.d.ts.map +0 -1
- package/primitives/dist/index.d.ts +0 -4
- package/primitives/dist/index.d.ts.map +0 -1
- package/primitives/dist/macro/index.d.ts +0 -2
- package/primitives/dist/macro/index.d.ts.map +0 -1
- package/primitives/dist/macro/test/babel.config.d.ts +0 -1
- package/primitives/dist/macro/test/babel.config.d.ts.map +0 -1
- package/primitives/dist/models/ComponentStyle.d.ts +0 -15
- package/primitives/dist/models/ComponentStyle.d.ts.map +0 -1
- package/primitives/dist/models/GlobalStyle.d.ts +0 -11
- package/primitives/dist/models/GlobalStyle.d.ts.map +0 -1
- package/primitives/dist/models/InlineStyle.d.ts +0 -6
- package/primitives/dist/models/InlineStyle.d.ts.map +0 -1
- package/primitives/dist/models/Keyframes.d.ts +0 -11
- package/primitives/dist/models/Keyframes.d.ts.map +0 -1
- package/primitives/dist/models/ServerStyleSheet.d.ts +0 -15
- package/primitives/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/primitives/dist/models/StyleSheetManager.d.ts +0 -21
- package/primitives/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/primitives/dist/models/StyledComponent.d.ts +0 -3
- package/primitives/dist/models/StyledComponent.d.ts.map +0 -1
- package/primitives/dist/models/StyledNativeComponent.d.ts +0 -3
- package/primitives/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/primitives/dist/models/ThemeProvider.d.ts +0 -39
- package/primitives/dist/models/ThemeProvider.d.ts.map +0 -1
- package/primitives/dist/native/index.d.ts +0 -65
- package/primitives/dist/native/index.d.ts.map +0 -1
- package/primitives/dist/primitives/index.d.ts +0 -23
- package/primitives/dist/primitives/index.d.ts.map +0 -1
- package/primitives/dist/secretInternals.d.ts +0 -5
- package/primitives/dist/secretInternals.d.ts.map +0 -1
- package/primitives/dist/sheet/GroupIDAllocator.d.ts +0 -4
- package/primitives/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/primitives/dist/sheet/GroupedTag.d.ts +0 -11
- package/primitives/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/primitives/dist/sheet/Rehydration.d.ts +0 -3
- package/primitives/dist/sheet/Rehydration.d.ts.map +0 -1
- package/primitives/dist/sheet/Sheet.d.ts +0 -40
- package/primitives/dist/sheet/Sheet.d.ts.map +0 -1
- package/primitives/dist/sheet/Tag.d.ts +0 -54
- package/primitives/dist/sheet/Tag.d.ts.map +0 -1
- package/primitives/dist/sheet/dom.d.ts +0 -4
- package/primitives/dist/sheet/dom.d.ts.map +0 -1
- package/primitives/dist/sheet/index.d.ts +0 -1
- package/primitives/dist/sheet/index.d.ts.map +0 -1
- package/primitives/dist/sheet/types.d.ts +0 -34
- package/primitives/dist/sheet/types.d.ts.map +0 -1
- package/primitives/dist/styled-components-primitives.cjs.js +0 -1292
- package/primitives/dist/styled-components-primitives.cjs.js.map +0 -1
- package/primitives/dist/styled-components-primitives.esm.js +0 -1274
- package/primitives/dist/styled-components-primitives.esm.js.map +0 -1
- package/primitives/dist/test/globals.d.ts +0 -2
- package/primitives/dist/test/globals.d.ts.map +0 -1
- package/primitives/dist/test/utils.d.ts +0 -191
- package/primitives/dist/test/utils.d.ts.map +0 -1
- package/primitives/dist/types.d.ts +0 -143
- package/primitives/dist/types.d.ts.map +0 -1
- package/primitives/dist/utils/addUnitIfNeeded.d.ts +0 -1
- package/primitives/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/primitives/dist/utils/checkDynamicCreation.d.ts +0 -1
- package/primitives/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/primitives/dist/utils/createWarnTooManyClasses.d.ts +0 -3
- package/primitives/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/primitives/dist/utils/determineTheme.d.ts +0 -2
- package/primitives/dist/utils/determineTheme.d.ts.map +0 -1
- package/primitives/dist/utils/domElements.d.ts +0 -2
- package/primitives/dist/utils/domElements.d.ts.map +0 -1
- package/primitives/dist/utils/empties.d.ts +0 -3
- package/primitives/dist/utils/empties.d.ts.map +0 -1
- package/primitives/dist/utils/error.d.ts +0 -5
- package/primitives/dist/utils/error.d.ts.map +0 -1
- package/primitives/dist/utils/errors.d.ts +0 -20
- package/primitives/dist/utils/errors.d.ts.map +0 -1
- package/primitives/dist/utils/escape.d.ts +0 -5
- package/primitives/dist/utils/escape.d.ts.map +0 -1
- package/primitives/dist/utils/flatten.d.ts +0 -4
- package/primitives/dist/utils/flatten.d.ts.map +0 -1
- package/primitives/dist/utils/generateAlphabeticName.d.ts +0 -1
- package/primitives/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/primitives/dist/utils/generateComponentId.d.ts +0 -1
- package/primitives/dist/utils/generateComponentId.d.ts.map +0 -1
- package/primitives/dist/utils/generateDisplayName.d.ts +0 -2
- package/primitives/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/primitives/dist/utils/getComponentName.d.ts +0 -2
- package/primitives/dist/utils/getComponentName.d.ts.map +0 -1
- package/primitives/dist/utils/hash.d.ts +0 -3
- package/primitives/dist/utils/hash.d.ts.map +0 -1
- package/primitives/dist/utils/hoist.d.ts +0 -51
- package/primitives/dist/utils/hoist.d.ts.map +0 -1
- package/primitives/dist/utils/hyphenateStyleName.d.ts +0 -14
- package/primitives/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/primitives/dist/utils/interleave.d.ts +0 -2
- package/primitives/dist/utils/interleave.d.ts.map +0 -1
- package/primitives/dist/utils/isFunction.d.ts +0 -1
- package/primitives/dist/utils/isFunction.d.ts.map +0 -1
- package/primitives/dist/utils/isPlainObject.d.ts +0 -1
- package/primitives/dist/utils/isPlainObject.d.ts.map +0 -1
- package/primitives/dist/utils/isStatelessFunction.d.ts +0 -1
- package/primitives/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/primitives/dist/utils/isStaticRules.d.ts +0 -2
- package/primitives/dist/utils/isStaticRules.d.ts.map +0 -1
- package/primitives/dist/utils/isStyledComponent.d.ts +0 -2
- package/primitives/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/primitives/dist/utils/isTag.d.ts +0 -2
- package/primitives/dist/utils/isTag.d.ts.map +0 -1
- package/primitives/dist/utils/joinStrings.d.ts +0 -4
- package/primitives/dist/utils/joinStrings.d.ts.map +0 -1
- package/primitives/dist/utils/mixinDeep.d.ts +0 -7
- package/primitives/dist/utils/mixinDeep.d.ts.map +0 -1
- package/primitives/dist/utils/nonce.d.ts +0 -1
- package/primitives/dist/utils/nonce.d.ts.map +0 -1
- package/primitives/dist/utils/stylis.d.ts +0 -9
- package/primitives/dist/utils/stylis.d.ts.map +0 -1
- package/primitives/package.json +0 -8
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __spreadArray, __read, __assign, __values } from 'tslib';
|
|
2
1
|
import React, { useContext, useMemo, createElement } from 'react';
|
|
3
2
|
import 'shallowequal';
|
|
4
3
|
import { prefixer, stringify, serialize, compile, middleware, RULESET } from 'stylis';
|
|
@@ -6,8 +5,8 @@ import unitless from '@emotion/unitless';
|
|
|
6
5
|
import transformDeclPairs from 'css-to-react-native';
|
|
7
6
|
import { parse } from 'postcss';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
9
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
11
10
|
|
|
12
11
|
var errorMap = {
|
|
13
12
|
'1': 'Cannot create styled-component for component: %s.\n\n',
|
|
@@ -29,21 +28,17 @@ var errorMap = {
|
|
|
29
28
|
'17': "CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",
|
|
30
29
|
};
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
const ERRORS = process.env.NODE_ENV !== 'production' ? errorMap : {};
|
|
33
32
|
/**
|
|
34
33
|
* super basic version of sprintf
|
|
35
34
|
*/
|
|
36
|
-
function format() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
var a = args[0];
|
|
42
|
-
var b = [];
|
|
43
|
-
for (var c = 1, len = args.length; c < len; c += 1) {
|
|
35
|
+
function format(...args) {
|
|
36
|
+
let a = args[0];
|
|
37
|
+
const b = [];
|
|
38
|
+
for (let c = 1, len = args.length; c < len; c += 1) {
|
|
44
39
|
b.push(args[c]);
|
|
45
40
|
}
|
|
46
|
-
b.forEach(
|
|
41
|
+
b.forEach(d => {
|
|
47
42
|
a = a.replace(/%[a-z]/, d);
|
|
48
43
|
});
|
|
49
44
|
return a;
|
|
@@ -52,27 +47,23 @@ function format() {
|
|
|
52
47
|
* Create an error file out of errors.md for development and a simple web link to the full errors
|
|
53
48
|
* in production mode.
|
|
54
49
|
*/
|
|
55
|
-
function throwStyledComponentsError(code) {
|
|
56
|
-
var interpolations = [];
|
|
57
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
58
|
-
interpolations[_i - 1] = arguments[_i];
|
|
59
|
-
}
|
|
50
|
+
function throwStyledComponentsError(code, ...interpolations) {
|
|
60
51
|
if (process.env.NODE_ENV === 'production') {
|
|
61
|
-
return new Error(
|
|
52
|
+
return new Error(`An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#${code} for more information.${interpolations.length > 0 ? ` Args: ${interpolations.join(', ')}` : ''}`);
|
|
62
53
|
}
|
|
63
54
|
else {
|
|
64
|
-
return new Error(format
|
|
55
|
+
return new Error(format(ERRORS[code], ...interpolations).trim());
|
|
65
56
|
}
|
|
66
57
|
}
|
|
67
58
|
|
|
68
|
-
|
|
59
|
+
const SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
69
60
|
'data-styled';
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
const SC_ATTR_ACTIVE = 'active';
|
|
62
|
+
const SC_ATTR_VERSION = 'data-styled-version';
|
|
63
|
+
const SC_VERSION = "6.0.0-alpha.6";
|
|
64
|
+
const SPLITTER = '/*!sc*/\n';
|
|
65
|
+
const IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
66
|
+
const DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
76
67
|
? SC_DISABLE_SPEEDY
|
|
77
68
|
: typeof process !== 'undefined' &&
|
|
78
69
|
typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
|
|
@@ -89,44 +80,47 @@ var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
|
89
80
|
: process.env.NODE_ENV !== 'production');
|
|
90
81
|
|
|
91
82
|
/** Create a GroupedTag with an underlying Tag implementation */
|
|
92
|
-
|
|
83
|
+
const makeGroupedTag = (tag) => {
|
|
93
84
|
return new DefaultGroupedTag(tag);
|
|
94
85
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
const BASE_SIZE = 1 << 9;
|
|
87
|
+
const DefaultGroupedTag = class DefaultGroupedTag {
|
|
88
|
+
groupSizes;
|
|
89
|
+
length;
|
|
90
|
+
tag;
|
|
91
|
+
constructor(tag) {
|
|
98
92
|
this.groupSizes = new Uint32Array(BASE_SIZE);
|
|
99
93
|
this.length = BASE_SIZE;
|
|
100
94
|
this.tag = tag;
|
|
101
95
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (
|
|
96
|
+
indexOfGroup(group) {
|
|
97
|
+
let index = 0;
|
|
98
|
+
for (let i = 0; i < group; i++) {
|
|
105
99
|
index += this.groupSizes[i];
|
|
106
100
|
}
|
|
107
101
|
return index;
|
|
108
|
-
}
|
|
109
|
-
|
|
102
|
+
}
|
|
103
|
+
insertRules(group, rules) {
|
|
110
104
|
if (group >= this.groupSizes.length) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
const oldBuffer = this.groupSizes;
|
|
106
|
+
const oldSize = oldBuffer.length;
|
|
107
|
+
let newSize = oldSize;
|
|
114
108
|
while (group >= newSize) {
|
|
115
109
|
newSize <<= 1;
|
|
116
110
|
if (newSize < 0) {
|
|
117
|
-
throw throwStyledComponentsError(16,
|
|
111
|
+
throw throwStyledComponentsError(16, `${group}`);
|
|
118
112
|
}
|
|
119
113
|
}
|
|
120
114
|
this.groupSizes = new Uint32Array(newSize);
|
|
121
115
|
this.groupSizes.set(oldBuffer);
|
|
122
116
|
this.length = newSize;
|
|
123
|
-
for (
|
|
117
|
+
for (let i = oldSize; i < newSize; i++) {
|
|
124
118
|
this.groupSizes[i] = 0;
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
|
-
|
|
121
|
+
let ruleIndex = this.indexOfGroup(group + 1);
|
|
128
122
|
if (Array.isArray(rules)) {
|
|
129
|
-
for (
|
|
123
|
+
for (let i = 0, l = rules.length; i < l; i++) {
|
|
130
124
|
if (this.tag.insertRule(ruleIndex, rules[i])) {
|
|
131
125
|
this.groupSizes[group]++;
|
|
132
126
|
ruleIndex++;
|
|
@@ -138,115 +132,110 @@ var DefaultGroupedTag = /** @class */ (function () {
|
|
|
138
132
|
this.groupSizes[group]++;
|
|
139
133
|
}
|
|
140
134
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
135
|
+
}
|
|
136
|
+
clearGroup(group) {
|
|
143
137
|
if (group < this.length) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
const length = this.groupSizes[group];
|
|
139
|
+
const startIndex = this.indexOfGroup(group);
|
|
140
|
+
const endIndex = startIndex + length;
|
|
147
141
|
this.groupSizes[group] = 0;
|
|
148
|
-
for (
|
|
142
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
149
143
|
this.tag.deleteRule(startIndex);
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
}
|
|
147
|
+
getGroup(group) {
|
|
148
|
+
let css = '';
|
|
155
149
|
if (group >= this.length || this.groupSizes[group] === 0) {
|
|
156
150
|
return css;
|
|
157
151
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
for (
|
|
162
|
-
css +=
|
|
152
|
+
const length = this.groupSizes[group];
|
|
153
|
+
const startIndex = this.indexOfGroup(group);
|
|
154
|
+
const endIndex = startIndex + length;
|
|
155
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
156
|
+
css += `${this.tag.getRule(i)}${SPLITTER}`;
|
|
163
157
|
}
|
|
164
158
|
return css;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
}());
|
|
159
|
+
}
|
|
160
|
+
};
|
|
168
161
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
162
|
+
const MAX_SMI = 1 << (31 - 1);
|
|
163
|
+
let groupIDRegister = new Map();
|
|
164
|
+
let reverseRegister = new Map();
|
|
165
|
+
let nextFreeGroup = 1;
|
|
166
|
+
const getGroupForId = (id) => {
|
|
174
167
|
if (groupIDRegister.has(id)) {
|
|
175
168
|
return groupIDRegister.get(id);
|
|
176
169
|
}
|
|
177
170
|
while (reverseRegister.has(nextFreeGroup)) {
|
|
178
171
|
nextFreeGroup++;
|
|
179
172
|
}
|
|
180
|
-
|
|
173
|
+
const group = nextFreeGroup++;
|
|
181
174
|
if (process.env.NODE_ENV !== 'production' && ((group | 0) < 0 || group > MAX_SMI)) {
|
|
182
|
-
throw throwStyledComponentsError(16,
|
|
175
|
+
throw throwStyledComponentsError(16, `${group}`);
|
|
183
176
|
}
|
|
184
177
|
groupIDRegister.set(id, group);
|
|
185
178
|
reverseRegister.set(group, id);
|
|
186
179
|
return group;
|
|
187
180
|
};
|
|
188
|
-
|
|
181
|
+
const getIdForGroup = (group) => {
|
|
189
182
|
return reverseRegister.get(group);
|
|
190
183
|
};
|
|
191
|
-
|
|
184
|
+
const setGroupForId = (id, group) => {
|
|
192
185
|
groupIDRegister.set(id, group);
|
|
193
186
|
reverseRegister.set(group, id);
|
|
194
187
|
};
|
|
195
188
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
189
|
+
const SELECTOR = `style[${SC_ATTR}][${SC_ATTR_VERSION}="${SC_VERSION}"]`;
|
|
190
|
+
const MARKER_RE = new RegExp(`^${SC_ATTR}\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)`);
|
|
191
|
+
const outputSheet = (sheet) => {
|
|
192
|
+
const tag = sheet.getTag();
|
|
193
|
+
const { length } = tag;
|
|
194
|
+
let css = '';
|
|
195
|
+
for (let group = 0; group < length; group++) {
|
|
196
|
+
const id = getIdForGroup(group);
|
|
204
197
|
if (id === undefined)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
198
|
+
continue;
|
|
199
|
+
const names = sheet.names.get(id);
|
|
200
|
+
const rules = tag.getGroup(group);
|
|
208
201
|
if (names === undefined || rules.length === 0)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
202
|
+
continue;
|
|
203
|
+
const selector = `${SC_ATTR}.g${group}[id="${id}"]`;
|
|
204
|
+
let content = '';
|
|
212
205
|
if (names !== undefined) {
|
|
213
|
-
names.forEach(
|
|
206
|
+
names.forEach(name => {
|
|
214
207
|
if (name.length > 0) {
|
|
215
|
-
content +=
|
|
208
|
+
content += `${name},`;
|
|
216
209
|
}
|
|
217
210
|
});
|
|
218
211
|
}
|
|
219
212
|
// NOTE: It's easier to collect rules and have the marker
|
|
220
213
|
// after the actual rules to simplify the rehydration
|
|
221
|
-
css +=
|
|
222
|
-
};
|
|
223
|
-
for (var group = 0; group < length; group++) {
|
|
224
|
-
_loop_1(group);
|
|
214
|
+
css += `${rules}${selector}{content:"${content}"}${SPLITTER}`;
|
|
225
215
|
}
|
|
226
216
|
return css;
|
|
227
217
|
};
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
for (
|
|
218
|
+
const rehydrateNamesFromContent = (sheet, id, content) => {
|
|
219
|
+
const names = content.split(',');
|
|
220
|
+
let name;
|
|
221
|
+
for (let i = 0, l = names.length; i < l; i++) {
|
|
232
222
|
// eslint-disable-next-line
|
|
233
223
|
if ((name = names[i])) {
|
|
234
224
|
sheet.registerName(id, name);
|
|
235
225
|
}
|
|
236
226
|
}
|
|
237
227
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
var part = parts[i].trim();
|
|
228
|
+
const rehydrateSheetFromTag = (sheet, style) => {
|
|
229
|
+
const parts = (style.textContent ?? '').split(SPLITTER);
|
|
230
|
+
const rules = [];
|
|
231
|
+
for (let i = 0, l = parts.length; i < l; i++) {
|
|
232
|
+
const part = parts[i].trim();
|
|
244
233
|
if (!part)
|
|
245
234
|
continue;
|
|
246
|
-
|
|
235
|
+
const marker = part.match(MARKER_RE);
|
|
247
236
|
if (marker) {
|
|
248
|
-
|
|
249
|
-
|
|
237
|
+
const group = parseInt(marker[1], 10) | 0;
|
|
238
|
+
const id = marker[2];
|
|
250
239
|
if (group !== 0) {
|
|
251
240
|
// Rehydrate componentId to group index mapping
|
|
252
241
|
setGroupForId(id, group);
|
|
@@ -262,10 +251,10 @@ var rehydrateSheetFromTag = function (sheet, style) {
|
|
|
262
251
|
}
|
|
263
252
|
}
|
|
264
253
|
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
for (
|
|
268
|
-
|
|
254
|
+
const rehydrateSheet = (sheet) => {
|
|
255
|
+
const nodes = document.querySelectorAll(SELECTOR);
|
|
256
|
+
for (let i = 0, l = nodes.length; i < l; i++) {
|
|
257
|
+
const node = nodes[i];
|
|
269
258
|
if (node && node.getAttribute(SC_ATTR) !== SC_ATTR_ACTIVE) {
|
|
270
259
|
rehydrateSheetFromTag(sheet, node);
|
|
271
260
|
if (node.parentNode) {
|
|
@@ -279,13 +268,13 @@ function getNonce() {
|
|
|
279
268
|
return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
|
|
280
269
|
}
|
|
281
270
|
|
|
282
|
-
|
|
271
|
+
const ELEMENT_TYPE = 1;
|
|
283
272
|
/* Node.ELEMENT_TYPE */
|
|
284
273
|
/** Find last style element if any inside target */
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
for (
|
|
288
|
-
|
|
274
|
+
const findLastStyleTag = (target) => {
|
|
275
|
+
const { childNodes } = target;
|
|
276
|
+
for (let i = childNodes.length; i >= 0; i--) {
|
|
277
|
+
const child = childNodes[i];
|
|
289
278
|
if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
|
|
290
279
|
return child;
|
|
291
280
|
}
|
|
@@ -293,29 +282,29 @@ var findLastStyleTag = function (target) {
|
|
|
293
282
|
return undefined;
|
|
294
283
|
};
|
|
295
284
|
/** Create a style element inside `target` or <head> after the last */
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
285
|
+
const makeStyleTag = (target) => {
|
|
286
|
+
const head = document.head;
|
|
287
|
+
const parent = target || head;
|
|
288
|
+
const style = document.createElement('style');
|
|
289
|
+
const prevStyle = findLastStyleTag(parent);
|
|
290
|
+
const nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
|
|
302
291
|
style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
|
|
303
292
|
style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
|
|
304
|
-
|
|
293
|
+
const nonce = getNonce();
|
|
305
294
|
if (nonce)
|
|
306
295
|
style.setAttribute('nonce', nonce);
|
|
307
296
|
parent.insertBefore(style, nextSibling);
|
|
308
297
|
return style;
|
|
309
298
|
};
|
|
310
299
|
/** Get the CSSStyleSheet instance for a given style element */
|
|
311
|
-
|
|
300
|
+
const getSheet = (tag) => {
|
|
312
301
|
if (tag.sheet) {
|
|
313
302
|
return tag.sheet;
|
|
314
303
|
}
|
|
315
304
|
// Avoid Firefox quirk where the style element might not have a sheet property
|
|
316
|
-
|
|
317
|
-
for (
|
|
318
|
-
|
|
305
|
+
const { styleSheets } = document;
|
|
306
|
+
for (let i = 0, l = styleSheets.length; i < l; i++) {
|
|
307
|
+
const sheet = styleSheets[i];
|
|
319
308
|
if (sheet.ownerNode === tag) {
|
|
320
309
|
return sheet;
|
|
321
310
|
}
|
|
@@ -324,8 +313,7 @@ var getSheet = function (tag) {
|
|
|
324
313
|
};
|
|
325
314
|
|
|
326
315
|
/** Create a CSSStyleSheet-like tag depending on the environment */
|
|
327
|
-
|
|
328
|
-
var isServer = _a.isServer, useCSSOMInjection = _a.useCSSOMInjection, target = _a.target;
|
|
316
|
+
const makeTag = ({ isServer, useCSSOMInjection, target }) => {
|
|
329
317
|
if (isServer) {
|
|
330
318
|
return new VirtualTag(target);
|
|
331
319
|
}
|
|
@@ -336,15 +324,18 @@ var makeTag = function (_a) {
|
|
|
336
324
|
return new TextTag(target);
|
|
337
325
|
}
|
|
338
326
|
};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
327
|
+
const CSSOMTag = class CSSOMTag {
|
|
328
|
+
element;
|
|
329
|
+
sheet;
|
|
330
|
+
length;
|
|
331
|
+
constructor(target) {
|
|
332
|
+
const element = (this.element = makeStyleTag(target));
|
|
342
333
|
// Avoid Edge bug where empty style elements don't create sheets
|
|
343
334
|
element.appendChild(document.createTextNode(''));
|
|
344
335
|
this.sheet = getSheet(element);
|
|
345
336
|
this.length = 0;
|
|
346
337
|
}
|
|
347
|
-
|
|
338
|
+
insertRule(index, rule) {
|
|
348
339
|
try {
|
|
349
340
|
this.sheet.insertRule(rule, index);
|
|
350
341
|
this.length++;
|
|
@@ -353,13 +344,13 @@ var CSSOMTag = /** @class */ (function () {
|
|
|
353
344
|
catch (_error) {
|
|
354
345
|
return false;
|
|
355
346
|
}
|
|
356
|
-
}
|
|
357
|
-
|
|
347
|
+
}
|
|
348
|
+
deleteRule(index) {
|
|
358
349
|
this.sheet.deleteRule(index);
|
|
359
350
|
this.length--;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
351
|
+
}
|
|
352
|
+
getRule(index) {
|
|
353
|
+
const rule = this.sheet.cssRules[index];
|
|
363
354
|
// Avoid IE11 quirk where cssText is inaccessible on some invalid rules
|
|
364
355
|
if (rule !== undefined && typeof rule.cssText === 'string') {
|
|
365
356
|
return rule.cssText;
|
|
@@ -367,20 +358,22 @@ var CSSOMTag = /** @class */ (function () {
|
|
|
367
358
|
else {
|
|
368
359
|
return '';
|
|
369
360
|
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
}());
|
|
361
|
+
}
|
|
362
|
+
};
|
|
373
363
|
/** A Tag that emulates the CSSStyleSheet API but uses text nodes */
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
364
|
+
const TextTag = class TextTag {
|
|
365
|
+
element;
|
|
366
|
+
nodes;
|
|
367
|
+
length;
|
|
368
|
+
constructor(target) {
|
|
369
|
+
const element = (this.element = makeStyleTag(target));
|
|
377
370
|
this.nodes = element.childNodes;
|
|
378
371
|
this.length = 0;
|
|
379
372
|
}
|
|
380
|
-
|
|
373
|
+
insertRule(index, rule) {
|
|
381
374
|
if (index <= this.length && index >= 0) {
|
|
382
|
-
|
|
383
|
-
|
|
375
|
+
const node = document.createTextNode(rule);
|
|
376
|
+
const refNode = this.nodes[index];
|
|
384
377
|
this.element.insertBefore(node, refNode || null);
|
|
385
378
|
this.length++;
|
|
386
379
|
return true;
|
|
@@ -388,28 +381,29 @@ var TextTag = /** @class */ (function () {
|
|
|
388
381
|
else {
|
|
389
382
|
return false;
|
|
390
383
|
}
|
|
391
|
-
}
|
|
392
|
-
|
|
384
|
+
}
|
|
385
|
+
deleteRule(index) {
|
|
393
386
|
this.element.removeChild(this.nodes[index]);
|
|
394
387
|
this.length--;
|
|
395
|
-
}
|
|
396
|
-
|
|
388
|
+
}
|
|
389
|
+
getRule(index) {
|
|
397
390
|
if (index < this.length) {
|
|
398
391
|
return this.nodes[index].textContent;
|
|
399
392
|
}
|
|
400
393
|
else {
|
|
401
394
|
return '';
|
|
402
395
|
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
}());
|
|
396
|
+
}
|
|
397
|
+
};
|
|
406
398
|
/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
|
|
407
|
-
|
|
408
|
-
|
|
399
|
+
const VirtualTag = class VirtualTag {
|
|
400
|
+
rules;
|
|
401
|
+
length;
|
|
402
|
+
constructor(_target) {
|
|
409
403
|
this.rules = [];
|
|
410
404
|
this.length = 0;
|
|
411
405
|
}
|
|
412
|
-
|
|
406
|
+
insertRule(index, rule) {
|
|
413
407
|
if (index <= this.length) {
|
|
414
408
|
this.rules.splice(index, 0, rule);
|
|
415
409
|
this.length++;
|
|
@@ -418,33 +412,42 @@ var VirtualTag = /** @class */ (function () {
|
|
|
418
412
|
else {
|
|
419
413
|
return false;
|
|
420
414
|
}
|
|
421
|
-
}
|
|
422
|
-
|
|
415
|
+
}
|
|
416
|
+
deleteRule(index) {
|
|
423
417
|
this.rules.splice(index, 1);
|
|
424
418
|
this.length--;
|
|
425
|
-
}
|
|
426
|
-
|
|
419
|
+
}
|
|
420
|
+
getRule(index) {
|
|
427
421
|
if (index < this.length) {
|
|
428
422
|
return this.rules[index];
|
|
429
423
|
}
|
|
430
424
|
else {
|
|
431
425
|
return '';
|
|
432
426
|
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
}());
|
|
427
|
+
}
|
|
428
|
+
};
|
|
436
429
|
|
|
437
|
-
|
|
438
|
-
|
|
430
|
+
let SHOULD_REHYDRATE = IS_BROWSER;
|
|
431
|
+
const defaultOptions = {
|
|
439
432
|
isServer: !IS_BROWSER,
|
|
440
433
|
useCSSOMInjection: !DISABLE_SPEEDY,
|
|
441
434
|
};
|
|
442
435
|
/** Contains the main stylesheet logic for stringification and caching */
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
436
|
+
class StyleSheet {
|
|
437
|
+
gs;
|
|
438
|
+
names;
|
|
439
|
+
options;
|
|
440
|
+
server;
|
|
441
|
+
tag;
|
|
442
|
+
/** Register a group ID to give it an index */
|
|
443
|
+
static registerId(id) {
|
|
444
|
+
return getGroupForId(id);
|
|
445
|
+
}
|
|
446
|
+
constructor(options = EMPTY_OBJECT, globalStyles = {}, names) {
|
|
447
|
+
this.options = {
|
|
448
|
+
...defaultOptions,
|
|
449
|
+
...options,
|
|
450
|
+
};
|
|
448
451
|
this.gs = globalStyles;
|
|
449
452
|
this.names = new Map(names);
|
|
450
453
|
this.server = !!options.isServer;
|
|
@@ -454,96 +457,89 @@ var StyleSheet = /** @class */ (function () {
|
|
|
454
457
|
rehydrateSheet(this);
|
|
455
458
|
}
|
|
456
459
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
StyleSheet.prototype.reconstructWithOptions = function (options, withNames) {
|
|
462
|
-
if (withNames === void 0) { withNames = true; }
|
|
463
|
-
return new StyleSheet(__assign(__assign({}, this.options), options), this.gs, (withNames && this.names) || undefined);
|
|
464
|
-
};
|
|
465
|
-
StyleSheet.prototype.allocateGSInstance = function (id) {
|
|
460
|
+
reconstructWithOptions(options, withNames = true) {
|
|
461
|
+
return new StyleSheet({ ...this.options, ...options }, this.gs, (withNames && this.names) || undefined);
|
|
462
|
+
}
|
|
463
|
+
allocateGSInstance(id) {
|
|
466
464
|
return (this.gs[id] = (this.gs[id] || 0) + 1);
|
|
467
|
-
}
|
|
465
|
+
}
|
|
468
466
|
/** Lazily initialises a GroupedTag for when it's actually needed */
|
|
469
|
-
|
|
467
|
+
getTag() {
|
|
470
468
|
return this.tag || (this.tag = makeGroupedTag(makeTag(this.options)));
|
|
471
|
-
}
|
|
469
|
+
}
|
|
472
470
|
/** Check whether a name is known for caching */
|
|
473
|
-
|
|
471
|
+
hasNameForId(id, name) {
|
|
474
472
|
return this.names.has(id) && this.names.get(id).has(name);
|
|
475
|
-
}
|
|
473
|
+
}
|
|
476
474
|
/** Mark a group's name as known for caching */
|
|
477
|
-
|
|
475
|
+
registerName(id, name) {
|
|
478
476
|
getGroupForId(id);
|
|
479
477
|
if (!this.names.has(id)) {
|
|
480
|
-
|
|
478
|
+
const groupNames = new Set();
|
|
481
479
|
groupNames.add(name);
|
|
482
480
|
this.names.set(id, groupNames);
|
|
483
481
|
}
|
|
484
482
|
else {
|
|
485
483
|
this.names.get(id).add(name);
|
|
486
484
|
}
|
|
487
|
-
}
|
|
485
|
+
}
|
|
488
486
|
/** Insert new rules which also marks the name as known */
|
|
489
|
-
|
|
487
|
+
insertRules(id, name, rules) {
|
|
490
488
|
this.registerName(id, name);
|
|
491
489
|
this.getTag().insertRules(getGroupForId(id), rules);
|
|
492
|
-
}
|
|
490
|
+
}
|
|
493
491
|
/** Clears all cached names for a given group ID */
|
|
494
|
-
|
|
492
|
+
clearNames(id) {
|
|
495
493
|
if (this.names.has(id)) {
|
|
496
494
|
this.names.get(id).clear();
|
|
497
495
|
}
|
|
498
|
-
}
|
|
496
|
+
}
|
|
499
497
|
/** Clears all rules for a given group ID */
|
|
500
|
-
|
|
498
|
+
clearRules(id) {
|
|
501
499
|
this.getTag().clearGroup(getGroupForId(id));
|
|
502
500
|
this.clearNames(id);
|
|
503
|
-
}
|
|
501
|
+
}
|
|
504
502
|
/** Clears the entire tag which deletes all rules but not its names */
|
|
505
|
-
|
|
503
|
+
clearTag() {
|
|
506
504
|
// NOTE: This does not clear the names, since it's only used during SSR
|
|
507
505
|
// so that we can continuously output only new rules
|
|
508
506
|
this.tag = undefined;
|
|
509
|
-
}
|
|
507
|
+
}
|
|
510
508
|
/** Outputs the current sheet as a CSS string with markers for SSR */
|
|
511
|
-
|
|
509
|
+
toString() {
|
|
512
510
|
return outputSheet(this);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
}());
|
|
511
|
+
}
|
|
512
|
+
}
|
|
516
513
|
|
|
517
|
-
|
|
514
|
+
const SEED = 5381;
|
|
518
515
|
// When we have separate strings it's useful to run a progressive
|
|
519
516
|
// version of djb2 where we pretend that we're still looping over
|
|
520
517
|
// the same string
|
|
521
|
-
|
|
522
|
-
|
|
518
|
+
const phash = (h, x) => {
|
|
519
|
+
let i = x.length;
|
|
523
520
|
while (i) {
|
|
524
521
|
h = (h * 33) ^ x.charCodeAt(--i);
|
|
525
522
|
}
|
|
526
523
|
return h;
|
|
527
524
|
};
|
|
528
525
|
// This is a djb2 hashing function
|
|
529
|
-
|
|
526
|
+
const hash = (x) => {
|
|
530
527
|
return phash(SEED, x);
|
|
531
528
|
};
|
|
532
529
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
function createStylisInstance(
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
var selfReferenceReplacer = function (match, offset, string) {
|
|
530
|
+
const COMMENT_REGEX = /^\s*\/\/.*$/gm;
|
|
531
|
+
const COMPLEX_SELECTOR_PREFIX = [':', '[', '.', '#'];
|
|
532
|
+
function createStylisInstance({ options = EMPTY_OBJECT, plugins = EMPTY_ARRAY, } = EMPTY_OBJECT) {
|
|
533
|
+
let _componentId;
|
|
534
|
+
let _selector;
|
|
535
|
+
let _selectorRegexp;
|
|
536
|
+
let _consecutiveSelfRefRegExp;
|
|
537
|
+
const selfReferenceReplacer = (match, offset, string) => {
|
|
542
538
|
if (
|
|
543
539
|
// do not replace the first occurrence if it is complex (has a modifier)
|
|
544
540
|
(offset === 0 ? !COMPLEX_SELECTOR_PREFIX.includes(string[_selector.length]) : true) && // no consecutive self refs (.b.b); that is a precedence boost and treated differently
|
|
545
541
|
!string.match(_consecutiveSelfRefRegExp)) {
|
|
546
|
-
return
|
|
542
|
+
return `.${_componentId}`;
|
|
547
543
|
}
|
|
548
544
|
return match;
|
|
549
545
|
};
|
|
@@ -559,34 +555,31 @@ function createStylisInstance(_a) {
|
|
|
559
555
|
*
|
|
560
556
|
* https://github.com/thysultan/stylis.js/tree/v4.0.2#abstract-syntax-structure
|
|
561
557
|
*/
|
|
562
|
-
|
|
558
|
+
const selfReferenceReplacementPlugin = element => {
|
|
563
559
|
if (element.type === RULESET && element.value.includes('&')) {
|
|
564
|
-
|
|
560
|
+
const props = element.props;
|
|
565
561
|
props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
|
|
566
562
|
}
|
|
567
563
|
};
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
if (prefix === void 0) { prefix = ''; }
|
|
571
|
-
if (componentId === void 0) { componentId = '&'; }
|
|
572
|
-
var flatCSS = css.replace(COMMENT_REGEX, '');
|
|
564
|
+
const stringifyRules = (css, selector = '', prefix = '', componentId = '&') => {
|
|
565
|
+
let flatCSS = css.replace(COMMENT_REGEX, '');
|
|
573
566
|
// stylis has no concept of state to be passed to plugins
|
|
574
567
|
// but since JS is single-threaded, we can rely on that to ensure
|
|
575
568
|
// these properties stay in sync with the current stylis run
|
|
576
569
|
_componentId = componentId;
|
|
577
570
|
_selector = selector;
|
|
578
|
-
_selectorRegexp = new RegExp(
|
|
579
|
-
_consecutiveSelfRefRegExp = new RegExp(
|
|
580
|
-
|
|
571
|
+
_selectorRegexp = new RegExp(`\\${_selector}\\b`, 'g');
|
|
572
|
+
_consecutiveSelfRefRegExp = new RegExp(`(\\${_selector}\\b){2,}`);
|
|
573
|
+
const middlewares = plugins.slice();
|
|
581
574
|
if (options.prefix || options.prefix === undefined) {
|
|
582
575
|
middlewares.unshift(prefixer);
|
|
583
576
|
}
|
|
584
577
|
middlewares.push(selfReferenceReplacementPlugin, stringify);
|
|
585
|
-
return serialize(compile(prefix || selector ?
|
|
578
|
+
return serialize(compile(prefix || selector ? `${prefix} ${selector} { ${flatCSS} }` : flatCSS), middleware(middlewares));
|
|
586
579
|
};
|
|
587
580
|
stringifyRules.hash = plugins.length
|
|
588
581
|
? plugins
|
|
589
|
-
.reduce(
|
|
582
|
+
.reduce((acc, plugin) => {
|
|
590
583
|
if (!plugin.name) {
|
|
591
584
|
throwStyledComponentsError(15);
|
|
592
585
|
}
|
|
@@ -597,36 +590,35 @@ function createStylisInstance(_a) {
|
|
|
597
590
|
return stringifyRules;
|
|
598
591
|
}
|
|
599
592
|
|
|
600
|
-
|
|
593
|
+
const StyleSheetContext = React.createContext(undefined);
|
|
601
594
|
StyleSheetContext.Consumer;
|
|
602
|
-
|
|
595
|
+
const StylisContext = React.createContext(undefined);
|
|
603
596
|
StylisContext.Consumer;
|
|
604
597
|
new StyleSheet();
|
|
605
|
-
|
|
598
|
+
const mainStylis = createStylisInstance();
|
|
606
599
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
var resolvedName = _this.name + stylisInstance.hash;
|
|
613
|
-
if (!styleSheet.hasNameForId(_this.id, resolvedName)) {
|
|
614
|
-
styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
this.toString = function () {
|
|
618
|
-
throw throwStyledComponentsError(12, String(_this.name));
|
|
619
|
-
};
|
|
600
|
+
class Keyframes {
|
|
601
|
+
id;
|
|
602
|
+
name;
|
|
603
|
+
rules;
|
|
604
|
+
constructor(name, rules) {
|
|
620
605
|
this.name = name;
|
|
621
|
-
this.id =
|
|
606
|
+
this.id = `sc-keyframes-${name}`;
|
|
622
607
|
this.rules = rules;
|
|
623
608
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
609
|
+
inject = (styleSheet, stylisInstance = mainStylis) => {
|
|
610
|
+
const resolvedName = this.name + stylisInstance.hash;
|
|
611
|
+
if (!styleSheet.hasNameForId(this.id, resolvedName)) {
|
|
612
|
+
styleSheet.insertRules(this.id, resolvedName, stylisInstance(this.rules, resolvedName, '@keyframes'));
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
toString = () => {
|
|
616
|
+
throw throwStyledComponentsError(12, String(this.name));
|
|
627
617
|
};
|
|
628
|
-
|
|
629
|
-
|
|
618
|
+
getName(stylisInstance = mainStylis) {
|
|
619
|
+
return this.name + stylisInstance.hash;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
630
622
|
|
|
631
623
|
// Taken from https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/shared/dangerousStyleValue.js
|
|
632
624
|
function addUnitIfNeeded(name, value) {
|
|
@@ -635,7 +627,7 @@ function addUnitIfNeeded(name, value) {
|
|
|
635
627
|
return '';
|
|
636
628
|
}
|
|
637
629
|
if (typeof value === 'number' && value !== 0 && !(name in unitless)) {
|
|
638
|
-
return
|
|
630
|
+
return `${value}px`; // Presumes implicit 'px' suffix for unitless numbers
|
|
639
631
|
}
|
|
640
632
|
return String(value).trim();
|
|
641
633
|
}
|
|
@@ -651,10 +643,10 @@ function getComponentName(target) {
|
|
|
651
643
|
* inlined version of
|
|
652
644
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
653
645
|
*/
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
646
|
+
const uppercaseCheck = /([A-Z])/;
|
|
647
|
+
const uppercasePattern = /([A-Z])/g;
|
|
648
|
+
const msPattern = /^ms-/;
|
|
649
|
+
const prefixAndLowerCase = (char) => `-${char.toLowerCase()}`;
|
|
658
650
|
/**
|
|
659
651
|
* Hyphenates a camelcased CSS property name, for example:
|
|
660
652
|
*
|
|
@@ -700,35 +692,33 @@ function isStyledComponent(target) {
|
|
|
700
692
|
/**
|
|
701
693
|
* It's falsish not falsy because 0 is allowed.
|
|
702
694
|
*/
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
var rules = [];
|
|
708
|
-
for (var key in obj) {
|
|
695
|
+
const isFalsish = (chunk) => chunk === undefined || chunk === null || chunk === false || chunk === '';
|
|
696
|
+
const objToCssArray = (obj, prevKey) => {
|
|
697
|
+
const rules = [];
|
|
698
|
+
for (const key in obj) {
|
|
709
699
|
if (!obj.hasOwnProperty(key) || isFalsish(obj[key]))
|
|
710
700
|
continue;
|
|
711
701
|
if ((Array.isArray(obj[key]) && obj[key].isCss) || isFunction(obj[key])) {
|
|
712
|
-
rules.push(
|
|
702
|
+
rules.push(`${hyphenateStyleName(key)}:`, obj[key], ';');
|
|
713
703
|
}
|
|
714
704
|
else if (isPlainObject(obj[key])) {
|
|
715
|
-
rules.push
|
|
705
|
+
rules.push(...objToCssArray(obj[key], key));
|
|
716
706
|
}
|
|
717
707
|
else {
|
|
718
|
-
rules.push(
|
|
708
|
+
rules.push(`${hyphenateStyleName(key)}: ${addUnitIfNeeded(key, obj[key])};`);
|
|
719
709
|
}
|
|
720
710
|
}
|
|
721
|
-
return prevKey ?
|
|
711
|
+
return prevKey ? [`${prevKey} {`, ...rules, '}'] : rules;
|
|
722
712
|
};
|
|
723
713
|
function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
724
714
|
if (Array.isArray(chunk)) {
|
|
725
|
-
|
|
726
|
-
for (
|
|
715
|
+
const ruleSet = [];
|
|
716
|
+
for (let i = 0, len = chunk.length, result; i < len; i += 1) {
|
|
727
717
|
result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
|
|
728
718
|
if (result === '')
|
|
729
719
|
continue;
|
|
730
720
|
else if (Array.isArray(result))
|
|
731
|
-
ruleSet.push
|
|
721
|
+
ruleSet.push(...result);
|
|
732
722
|
else
|
|
733
723
|
ruleSet.push(result);
|
|
734
724
|
}
|
|
@@ -739,22 +729,22 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
739
729
|
}
|
|
740
730
|
/* Handle other components */
|
|
741
731
|
if (isStyledComponent(chunk)) {
|
|
742
|
-
return
|
|
732
|
+
return `.${chunk.styledComponentId}`;
|
|
743
733
|
}
|
|
744
734
|
/* Either execute or defer the function */
|
|
745
735
|
if (isFunction(chunk)) {
|
|
746
736
|
if (isStatelessFunction(chunk) && executionContext) {
|
|
747
|
-
|
|
748
|
-
|
|
737
|
+
const chunkFn = chunk;
|
|
738
|
+
const result = chunkFn(executionContext);
|
|
749
739
|
if (process.env.NODE_ENV !== 'production' &&
|
|
750
740
|
typeof result === 'object' &&
|
|
751
741
|
!Array.isArray(result) &&
|
|
752
742
|
!(result instanceof Keyframes) &&
|
|
753
743
|
!isPlainObject(result)) {
|
|
754
744
|
// eslint-disable-next-line no-console
|
|
755
|
-
console.error(
|
|
745
|
+
console.error(`${getComponentName(
|
|
756
746
|
// @ts-expect-error handling unexpected input
|
|
757
|
-
chunkFn)
|
|
747
|
+
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.`);
|
|
758
748
|
}
|
|
759
749
|
return flatten(result, executionContext, styleSheet, stylisInstance);
|
|
760
750
|
}
|
|
@@ -774,8 +764,8 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
774
764
|
}
|
|
775
765
|
|
|
776
766
|
function interleave(strings, interpolations) {
|
|
777
|
-
|
|
778
|
-
for (
|
|
767
|
+
const result = [strings[0]];
|
|
768
|
+
for (let i = 0, len = interpolations.length; i < len; i += 1) {
|
|
779
769
|
result.push(interpolations[i], strings[i + 1]);
|
|
780
770
|
}
|
|
781
771
|
return result;
|
|
@@ -785,25 +775,22 @@ function interleave(strings, interpolations) {
|
|
|
785
775
|
* Used when flattening object styles to determine if we should
|
|
786
776
|
* expand an array of styles.
|
|
787
777
|
*/
|
|
788
|
-
|
|
778
|
+
const addTag = (arg) => {
|
|
789
779
|
if (Array.isArray(arg)) {
|
|
790
780
|
// eslint-disable-next-line no-param-reassign
|
|
791
781
|
arg.isCss = true;
|
|
792
782
|
}
|
|
793
783
|
return arg;
|
|
794
784
|
};
|
|
795
|
-
function css(styles) {
|
|
796
|
-
var interpolations = [];
|
|
797
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
798
|
-
interpolations[_i - 1] = arguments[_i];
|
|
799
|
-
}
|
|
785
|
+
function css(styles, ...interpolations) {
|
|
800
786
|
if (isFunction(styles) || isPlainObject(styles)) {
|
|
801
|
-
|
|
802
|
-
return addTag(flatten(interleave(EMPTY_ARRAY,
|
|
803
|
-
styleFunctionOrObject
|
|
804
|
-
|
|
787
|
+
const styleFunctionOrObject = styles;
|
|
788
|
+
return addTag(flatten(interleave(EMPTY_ARRAY, [
|
|
789
|
+
styleFunctionOrObject,
|
|
790
|
+
...interpolations,
|
|
791
|
+
])));
|
|
805
792
|
}
|
|
806
|
-
|
|
793
|
+
const styleStringArray = styles;
|
|
807
794
|
if (interpolations.length === 0 &&
|
|
808
795
|
styleStringArray.length === 1 &&
|
|
809
796
|
typeof styleStringArray[0] === 'string') {
|
|
@@ -812,8 +799,7 @@ function css(styles) {
|
|
|
812
799
|
return addTag(flatten(interleave(styleStringArray, interpolations)));
|
|
813
800
|
}
|
|
814
801
|
|
|
815
|
-
function constructWithOptions(componentConstructor, tag, options) {
|
|
816
|
-
if (options === void 0) { options = EMPTY_OBJECT; }
|
|
802
|
+
function constructWithOptions(componentConstructor, tag, options = EMPTY_OBJECT) {
|
|
817
803
|
// We trust that the tag is a valid component as long as it isn't falsish
|
|
818
804
|
// Typically the tag here is a string or function (i.e. class or pure function component)
|
|
819
805
|
// However a component may also be an object if it uses another utility, e.g. React.memo
|
|
@@ -822,34 +808,30 @@ function constructWithOptions(componentConstructor, tag, options) {
|
|
|
822
808
|
throw throwStyledComponentsError(1, tag);
|
|
823
809
|
}
|
|
824
810
|
/* This is callable directly as a template function */
|
|
825
|
-
|
|
826
|
-
var interpolations = [];
|
|
827
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
828
|
-
interpolations[_i - 1] = arguments[_i];
|
|
829
|
-
}
|
|
830
|
-
return componentConstructor(tag, options, css.apply(void 0, __spreadArray([initialStyles], __read(interpolations), false)));
|
|
831
|
-
};
|
|
811
|
+
const templateFunction = (initialStyles, ...interpolations) => componentConstructor(tag, options, css(initialStyles, ...interpolations));
|
|
832
812
|
/* Modify/inject new props at runtime */
|
|
833
|
-
templateFunction.attrs =
|
|
834
|
-
|
|
835
|
-
|
|
813
|
+
templateFunction.attrs = (attrs) => constructWithOptions(componentConstructor, tag, {
|
|
814
|
+
...options,
|
|
815
|
+
attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean),
|
|
816
|
+
});
|
|
836
817
|
/**
|
|
837
818
|
* If config methods are called, wrap up a new template function and merge options */
|
|
838
|
-
templateFunction.withConfig =
|
|
839
|
-
|
|
840
|
-
|
|
819
|
+
templateFunction.withConfig = (config) => constructWithOptions(componentConstructor, tag, {
|
|
820
|
+
...options,
|
|
821
|
+
...config,
|
|
822
|
+
});
|
|
841
823
|
return templateFunction;
|
|
842
824
|
}
|
|
843
825
|
|
|
844
|
-
|
|
845
|
-
|
|
826
|
+
const ThemeContext = React.createContext(undefined);
|
|
827
|
+
const ThemeConsumer = ThemeContext.Consumer;
|
|
846
828
|
function mergeTheme(theme, outerTheme) {
|
|
847
829
|
if (!theme) {
|
|
848
830
|
throw throwStyledComponentsError(14);
|
|
849
831
|
}
|
|
850
832
|
if (isFunction(theme)) {
|
|
851
|
-
|
|
852
|
-
|
|
833
|
+
const themeFn = theme;
|
|
834
|
+
const mergedTheme = themeFn(outerTheme);
|
|
853
835
|
if (process.env.NODE_ENV !== 'production' &&
|
|
854
836
|
(mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object')) {
|
|
855
837
|
throw throwStyledComponentsError(7);
|
|
@@ -859,34 +841,32 @@ function mergeTheme(theme, outerTheme) {
|
|
|
859
841
|
if (Array.isArray(theme) || typeof theme !== 'object') {
|
|
860
842
|
throw throwStyledComponentsError(8);
|
|
861
843
|
}
|
|
862
|
-
return outerTheme ?
|
|
844
|
+
return outerTheme ? { ...outerTheme, ...theme } : theme;
|
|
863
845
|
}
|
|
864
846
|
/**
|
|
865
847
|
* Provide a theme to an entire react component tree via context
|
|
866
848
|
*/
|
|
867
849
|
function ThemeProvider(props) {
|
|
868
|
-
|
|
869
|
-
|
|
850
|
+
const outerTheme = useContext(ThemeContext);
|
|
851
|
+
const themeContext = useMemo(() => mergeTheme(props.theme, outerTheme), [props.theme, outerTheme]);
|
|
870
852
|
if (!props.children) {
|
|
871
853
|
return null;
|
|
872
854
|
}
|
|
873
855
|
return React.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
|
|
874
856
|
}
|
|
875
857
|
|
|
876
|
-
function determineTheme(props, providedTheme, defaultProps) {
|
|
877
|
-
if (defaultProps === void 0) { defaultProps = EMPTY_OBJECT; }
|
|
858
|
+
function determineTheme(props, providedTheme, defaultProps = EMPTY_OBJECT) {
|
|
878
859
|
return (props.theme !== defaultProps.theme && props.theme) || providedTheme || defaultProps.theme;
|
|
879
860
|
}
|
|
880
861
|
|
|
881
|
-
|
|
882
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
862
|
+
const hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
883
863
|
// copied from react-is
|
|
884
|
-
|
|
885
|
-
|
|
864
|
+
const REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
865
|
+
const REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
886
866
|
/**
|
|
887
867
|
* Adapted from hoist-non-react-statics to avoid the react-is dependency.
|
|
888
868
|
*/
|
|
889
|
-
|
|
869
|
+
const REACT_STATICS = {
|
|
890
870
|
childContextTypes: true,
|
|
891
871
|
contextType: true,
|
|
892
872
|
contextTypes: true,
|
|
@@ -899,7 +879,7 @@ var REACT_STATICS = {
|
|
|
899
879
|
propTypes: true,
|
|
900
880
|
type: true,
|
|
901
881
|
};
|
|
902
|
-
|
|
882
|
+
const KNOWN_STATICS = {
|
|
903
883
|
name: true,
|
|
904
884
|
length: true,
|
|
905
885
|
prototype: true,
|
|
@@ -908,14 +888,14 @@ var KNOWN_STATICS = {
|
|
|
908
888
|
arguments: true,
|
|
909
889
|
arity: true,
|
|
910
890
|
};
|
|
911
|
-
|
|
891
|
+
const FORWARD_REF_STATICS = {
|
|
912
892
|
$$typeof: true,
|
|
913
893
|
render: true,
|
|
914
894
|
defaultProps: true,
|
|
915
895
|
displayName: true,
|
|
916
896
|
propTypes: true,
|
|
917
897
|
};
|
|
918
|
-
|
|
898
|
+
const MEMO_STATICS = {
|
|
919
899
|
$$typeof: true,
|
|
920
900
|
compare: true,
|
|
921
901
|
defaultProps: true,
|
|
@@ -923,13 +903,13 @@ var MEMO_STATICS = {
|
|
|
923
903
|
propTypes: true,
|
|
924
904
|
type: true,
|
|
925
905
|
};
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
906
|
+
const TYPE_STATICS = {
|
|
907
|
+
[REACT_FORWARD_REF_TYPE]: FORWARD_REF_STATICS,
|
|
908
|
+
[REACT_MEMO_TYPE]: MEMO_STATICS,
|
|
909
|
+
};
|
|
930
910
|
// adapted from react-is
|
|
931
911
|
function isMemo(object) {
|
|
932
|
-
|
|
912
|
+
const $$typeofType = 'type' in object && object.type.$$typeof;
|
|
933
913
|
return $$typeofType === REACT_MEMO_TYPE;
|
|
934
914
|
}
|
|
935
915
|
function getStatics(component) {
|
|
@@ -942,34 +922,34 @@ function getStatics(component) {
|
|
|
942
922
|
? TYPE_STATICS[component['$$typeof']]
|
|
943
923
|
: REACT_STATICS;
|
|
944
924
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
925
|
+
const defineProperty = Object.defineProperty;
|
|
926
|
+
const getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
927
|
+
const getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
928
|
+
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
929
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
930
|
+
const objectPrototype = Object.prototype;
|
|
951
931
|
function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
|
|
952
932
|
if (typeof sourceComponent !== 'string') {
|
|
953
933
|
// don't hoist over string (html) components
|
|
954
934
|
if (objectPrototype) {
|
|
955
|
-
|
|
935
|
+
const inheritedComponent = getPrototypeOf(sourceComponent);
|
|
956
936
|
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
|
957
937
|
hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);
|
|
958
938
|
}
|
|
959
939
|
}
|
|
960
|
-
|
|
940
|
+
let keys = getOwnPropertyNames(sourceComponent);
|
|
961
941
|
if (getOwnPropertySymbols) {
|
|
962
942
|
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
|
963
943
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
for (
|
|
967
|
-
|
|
944
|
+
const targetStatics = getStatics(targetComponent);
|
|
945
|
+
const sourceStatics = getStatics(sourceComponent);
|
|
946
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
947
|
+
const key = keys[i];
|
|
968
948
|
if (!(key in KNOWN_STATICS) &&
|
|
969
949
|
!(excludelist && excludelist[key]) &&
|
|
970
950
|
!(sourceStatics && key in sourceStatics) &&
|
|
971
951
|
!(targetStatics && key in targetStatics)) {
|
|
972
|
-
|
|
952
|
+
const descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
973
953
|
try {
|
|
974
954
|
// Avoid failures from read-only properties
|
|
975
955
|
defineProperty(targetComponent, key, descriptor);
|
|
@@ -984,31 +964,31 @@ function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
|
|
|
984
964
|
}
|
|
985
965
|
|
|
986
966
|
function withTheme(Component) {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
967
|
+
const WithTheme = React.forwardRef((props, ref) => {
|
|
968
|
+
const theme = React.useContext(ThemeContext);
|
|
969
|
+
const themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
990
970
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
991
971
|
// eslint-disable-next-line no-console
|
|
992
|
-
console.warn(
|
|
972
|
+
console.warn(`[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "${getComponentName(Component)}"`);
|
|
993
973
|
}
|
|
994
|
-
return React.createElement(Component,
|
|
974
|
+
return React.createElement(Component, { ...props, theme: themeProp, ref: ref });
|
|
995
975
|
});
|
|
996
|
-
WithTheme.displayName =
|
|
976
|
+
WithTheme.displayName = `WithTheme(${getComponentName(Component)})`;
|
|
997
977
|
return hoistNonReactStatics(WithTheme, Component);
|
|
998
978
|
}
|
|
999
979
|
|
|
1000
|
-
|
|
980
|
+
const useTheme = () => useContext(ThemeContext);
|
|
1001
981
|
|
|
1002
|
-
|
|
982
|
+
const AD_REPLACER_R = /(a)(d)/gi;
|
|
1003
983
|
/* This is the "capacity" of our alphabet i.e. 2x26 for all letters plus their capitalised
|
|
1004
984
|
* counterparts */
|
|
1005
|
-
|
|
985
|
+
const charsLength = 52;
|
|
1006
986
|
/* start at 75 for 'a' until 'z' (25) and then start at 65 for capitalised letters */
|
|
1007
|
-
|
|
987
|
+
const getAlphabeticChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
|
|
1008
988
|
/* input a number, usually a hash and convert it to base-52 */
|
|
1009
989
|
function generateAlphabeticName(code) {
|
|
1010
|
-
|
|
1011
|
-
|
|
990
|
+
let name = '';
|
|
991
|
+
let x;
|
|
1012
992
|
/* get a char and divide by alphabet-length */
|
|
1013
993
|
for (x = Math.abs(code); x > charsLength; x = (x / charsLength) | 0) {
|
|
1014
994
|
name = getAlphabeticChar(x % charsLength) + name;
|
|
@@ -1020,41 +1000,41 @@ function generateComponentId(str) {
|
|
|
1020
1000
|
return generateAlphabeticName(hash(str) >>> 0);
|
|
1021
1001
|
}
|
|
1022
1002
|
|
|
1023
|
-
|
|
1003
|
+
let generated = {};
|
|
1024
1004
|
/**
|
|
1025
1005
|
* InlineStyle takes arbitrary CSS and generates a flat object
|
|
1026
1006
|
*/
|
|
1027
1007
|
function makeInlineStyleClass(styleSheet) {
|
|
1028
|
-
|
|
1029
|
-
|
|
1008
|
+
const InlineStyle = class InlineStyle {
|
|
1009
|
+
rules;
|
|
1010
|
+
constructor(rules) {
|
|
1030
1011
|
this.rules = rules;
|
|
1031
1012
|
}
|
|
1032
|
-
|
|
1013
|
+
generateStyleObject(executionContext) {
|
|
1033
1014
|
// keyframes, functions, and component selectors are not allowed for React Native
|
|
1034
|
-
|
|
1035
|
-
|
|
1015
|
+
const flatCSS = flatten(this.rules, executionContext).join('');
|
|
1016
|
+
const hash = generateComponentId(flatCSS);
|
|
1036
1017
|
if (!generated[hash]) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
root.each(
|
|
1018
|
+
const root = parse(flatCSS);
|
|
1019
|
+
const declPairs = [];
|
|
1020
|
+
root.each(node => {
|
|
1040
1021
|
if (node.type === 'decl') {
|
|
1041
|
-
|
|
1022
|
+
declPairs.push([node.prop, node.value]);
|
|
1042
1023
|
}
|
|
1043
1024
|
else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {
|
|
1044
1025
|
/* eslint-disable no-console */
|
|
1045
|
-
console.warn(
|
|
1026
|
+
console.warn(`Node of type ${node.type} not supported as an inline style`);
|
|
1046
1027
|
}
|
|
1047
1028
|
});
|
|
1048
|
-
|
|
1049
|
-
|
|
1029
|
+
const styleObject = transformDeclPairs(declPairs);
|
|
1030
|
+
const styles = styleSheet.create({
|
|
1050
1031
|
generated: styleObject,
|
|
1051
1032
|
});
|
|
1052
1033
|
generated[hash] = styles.generated;
|
|
1053
1034
|
}
|
|
1054
1035
|
return generated[hash];
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
}());
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1058
1038
|
return InlineStyle;
|
|
1059
1039
|
}
|
|
1060
1040
|
|
|
@@ -1066,23 +1046,22 @@ function isTag(target) {
|
|
|
1066
1046
|
}
|
|
1067
1047
|
|
|
1068
1048
|
function generateDisplayName(target) {
|
|
1069
|
-
return isTag(target) ?
|
|
1049
|
+
return isTag(target) ? `styled.${target}` : `Styled(${getComponentName(target)})`;
|
|
1070
1050
|
}
|
|
1071
1051
|
|
|
1072
|
-
function mixinRecursively(target, source, forceMerge) {
|
|
1073
|
-
if (forceMerge === void 0) { forceMerge = false; }
|
|
1052
|
+
function mixinRecursively(target, source, forceMerge = false) {
|
|
1074
1053
|
/* only merge into POJOs, Arrays, but for top level objects only
|
|
1075
1054
|
* allow to merge into anything by passing forceMerge = true */
|
|
1076
1055
|
if (!forceMerge && !isPlainObject(target) && !Array.isArray(target)) {
|
|
1077
1056
|
return source;
|
|
1078
1057
|
}
|
|
1079
1058
|
if (Array.isArray(source)) {
|
|
1080
|
-
for (
|
|
1059
|
+
for (let key = 0; key < source.length; key++) {
|
|
1081
1060
|
target[key] = mixinRecursively(target[key], source[key]);
|
|
1082
1061
|
}
|
|
1083
1062
|
}
|
|
1084
1063
|
else if (isPlainObject(source)) {
|
|
1085
|
-
for (
|
|
1064
|
+
for (const key in source) {
|
|
1086
1065
|
target[key] = mixinRecursively(target[key], source[key]);
|
|
1087
1066
|
}
|
|
1088
1067
|
}
|
|
@@ -1093,39 +1072,23 @@ function mixinRecursively(target, source, forceMerge) {
|
|
|
1093
1072
|
* If target is not a POJO or an Array, it will get source properties injected via shallow merge
|
|
1094
1073
|
* Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
|
|
1095
1074
|
*/
|
|
1096
|
-
function mixinDeep(target) {
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
var sources = [];
|
|
1100
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1101
|
-
sources[_i - 1] = arguments[_i];
|
|
1102
|
-
}
|
|
1103
|
-
try {
|
|
1104
|
-
for (var sources_1 = __values(sources), sources_1_1 = sources_1.next(); !sources_1_1.done; sources_1_1 = sources_1.next()) {
|
|
1105
|
-
var source = sources_1_1.value;
|
|
1106
|
-
mixinRecursively(target, source, true);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1110
|
-
finally {
|
|
1111
|
-
try {
|
|
1112
|
-
if (sources_1_1 && !sources_1_1.done && (_a = sources_1.return)) _a.call(sources_1);
|
|
1113
|
-
}
|
|
1114
|
-
finally { if (e_1) throw e_1.error; }
|
|
1075
|
+
function mixinDeep(target = {}, ...sources) {
|
|
1076
|
+
for (const source of sources) {
|
|
1077
|
+
mixinRecursively(target, source, true);
|
|
1115
1078
|
}
|
|
1116
1079
|
return target;
|
|
1117
1080
|
}
|
|
1118
1081
|
|
|
1119
|
-
function useResolvedAttrs(theme, props, attrs) {
|
|
1120
|
-
if (theme === void 0) { theme = EMPTY_OBJECT; }
|
|
1082
|
+
function useResolvedAttrs(theme = EMPTY_OBJECT, props, attrs) {
|
|
1121
1083
|
// NOTE: can't memoize this
|
|
1122
1084
|
// returns [context, resolvedAttrs]
|
|
1123
1085
|
// where resolvedAttrs is only the things injected by the attrs themselves
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
attrs.forEach(
|
|
1127
|
-
|
|
1128
|
-
|
|
1086
|
+
const context = { ...props, theme };
|
|
1087
|
+
const resolvedAttrs = {};
|
|
1088
|
+
attrs.forEach(attrDef => {
|
|
1089
|
+
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1090
|
+
let resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1091
|
+
let key;
|
|
1129
1092
|
/* eslint-disable guard-for-in */
|
|
1130
1093
|
for (key in resolvedAttrDef) {
|
|
1131
1094
|
// @ts-expect-error bad types
|
|
@@ -1136,21 +1099,21 @@ function useResolvedAttrs(theme, props, attrs) {
|
|
|
1136
1099
|
return [context, resolvedAttrs];
|
|
1137
1100
|
}
|
|
1138
1101
|
// Validator defaults to true if not in HTML/DOM env
|
|
1139
|
-
|
|
1102
|
+
const validAttr = () => true;
|
|
1140
1103
|
function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
1141
|
-
|
|
1104
|
+
const { attrs: componentAttrs, inlineStyle, defaultProps, shouldForwardProp, target, } = forwardedComponent;
|
|
1142
1105
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
1143
1106
|
// but that'd be against the rules-of-hooks. We could be naughty and do it anyway as it
|
|
1144
1107
|
// should be an immutable value, but behave for now.
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1108
|
+
const theme = determineTheme(props, useContext(ThemeContext), defaultProps);
|
|
1109
|
+
const [context, attrs] = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs);
|
|
1110
|
+
const generatedStyles = inlineStyle.generateStyleObject(context);
|
|
1111
|
+
const refToForward = forwardedRef;
|
|
1112
|
+
const elementToBeCreated = attrs.$as || props.$as || attrs.as || props.as || target;
|
|
1113
|
+
const computedProps = attrs !== props ? { ...props, ...attrs } : props;
|
|
1114
|
+
const propsForElement = {};
|
|
1152
1115
|
// eslint-disable-next-line guard-for-in
|
|
1153
|
-
for (
|
|
1116
|
+
for (const key in computedProps) {
|
|
1154
1117
|
if (key[0] === '$' || key === 'as')
|
|
1155
1118
|
continue;
|
|
1156
1119
|
else if (key === 'forwardedAs') {
|
|
@@ -1160,9 +1123,9 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1160
1123
|
propsForElement[key] = computedProps[key];
|
|
1161
1124
|
}
|
|
1162
1125
|
}
|
|
1163
|
-
propsForElement.style = useMemo(
|
|
1126
|
+
propsForElement.style = useMemo(() => {
|
|
1164
1127
|
if (typeof props.style === 'function') {
|
|
1165
|
-
return
|
|
1128
|
+
return (state) => {
|
|
1166
1129
|
return [generatedStyles].concat(props.style(state));
|
|
1167
1130
|
};
|
|
1168
1131
|
}
|
|
@@ -1176,42 +1139,39 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1176
1139
|
propsForElement.ref = refToForward;
|
|
1177
1140
|
return createElement(elementToBeCreated, propsForElement);
|
|
1178
1141
|
}
|
|
1179
|
-
var _StyledNativeComponent = (
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1142
|
+
var _StyledNativeComponent = (InlineStyle) => {
|
|
1143
|
+
const createStyledNativeComponent = (target, options, rules) => {
|
|
1144
|
+
const isTargetStyledComp = isStyledComponent(target);
|
|
1145
|
+
const styledComponentTarget = target;
|
|
1146
|
+
const { displayName = generateDisplayName(target), attrs = EMPTY_ARRAY } = options;
|
|
1184
1147
|
// fold the underlying StyledComponent attrs up (implicit extend)
|
|
1185
|
-
|
|
1148
|
+
const finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
|
|
1186
1149
|
? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
|
|
1187
1150
|
: attrs;
|
|
1188
1151
|
// eslint-disable-next-line prefer-destructuring
|
|
1189
|
-
|
|
1152
|
+
let shouldForwardProp = options.shouldForwardProp;
|
|
1190
1153
|
if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
|
|
1191
|
-
|
|
1154
|
+
const shouldForwardPropFn = styledComponentTarget.shouldForwardProp;
|
|
1192
1155
|
if (options.shouldForwardProp) {
|
|
1193
|
-
|
|
1156
|
+
const passedShouldForwardPropFn = options.shouldForwardProp;
|
|
1194
1157
|
// compose nested shouldForwardProp calls
|
|
1195
|
-
shouldForwardProp =
|
|
1196
|
-
|
|
1197
|
-
passedShouldForwardPropFn_1(prop, filterFn, elementToBeCreated);
|
|
1198
|
-
};
|
|
1158
|
+
shouldForwardProp = (prop, filterFn, elementToBeCreated) => shouldForwardPropFn(prop, filterFn, elementToBeCreated) &&
|
|
1159
|
+
passedShouldForwardPropFn(prop, filterFn, elementToBeCreated);
|
|
1199
1160
|
}
|
|
1200
1161
|
else {
|
|
1201
1162
|
// eslint-disable-next-line prefer-destructuring
|
|
1202
|
-
shouldForwardProp =
|
|
1163
|
+
shouldForwardProp = shouldForwardPropFn;
|
|
1203
1164
|
}
|
|
1204
1165
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
};
|
|
1166
|
+
const forwardRef = (props, ref) =>
|
|
1167
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1168
|
+
useStyledComponentImpl(WrappedStyledComponent, props, ref);
|
|
1209
1169
|
forwardRef.displayName = displayName;
|
|
1210
1170
|
/**
|
|
1211
1171
|
* forwardRef creates a new interim component, which we'll take advantage of
|
|
1212
1172
|
* instead of extending ParentComponent to create _another_ interim class
|
|
1213
1173
|
*/
|
|
1214
|
-
|
|
1174
|
+
let WrappedStyledComponent = React.forwardRef(forwardRef);
|
|
1215
1175
|
WrappedStyledComponent.attrs = finalAttrs;
|
|
1216
1176
|
WrappedStyledComponent.inlineStyle = new InlineStyle(isTargetStyledComp ? styledComponentTarget.inlineStyle.rules.concat(rules) : rules);
|
|
1217
1177
|
WrappedStyledComponent.displayName = displayName;
|
|
@@ -1221,14 +1181,17 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1221
1181
|
// fold the underlying StyledComponent target up since we folded the styles
|
|
1222
1182
|
WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
|
|
1223
1183
|
WrappedStyledComponent.withComponent = function withComponent(tag) {
|
|
1224
|
-
|
|
1184
|
+
const newOptions = {
|
|
1185
|
+
...options,
|
|
1186
|
+
attrs: finalAttrs,
|
|
1187
|
+
};
|
|
1225
1188
|
return createStyledNativeComponent(tag, newOptions, rules);
|
|
1226
1189
|
};
|
|
1227
1190
|
Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
|
|
1228
|
-
get
|
|
1191
|
+
get() {
|
|
1229
1192
|
return this._foldedDefaultProps;
|
|
1230
1193
|
},
|
|
1231
|
-
set
|
|
1194
|
+
set(obj) {
|
|
1232
1195
|
this._foldedDefaultProps = isTargetStyledComp
|
|
1233
1196
|
? mixinDeep({}, styledComponentTarget.defaultProps, obj)
|
|
1234
1197
|
: obj;
|
|
@@ -1246,81 +1209,54 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1246
1209
|
return WrappedStyledComponent;
|
|
1247
1210
|
};
|
|
1248
1211
|
return createStyledNativeComponent;
|
|
1249
|
-
}
|
|
1212
|
+
};
|
|
1250
1213
|
|
|
1251
1214
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
return constructWithOptions(StyledNativeComponent, tag);
|
|
1257
|
-
};
|
|
1215
|
+
const reactNative = require('react-native');
|
|
1216
|
+
const InlineStyle = makeInlineStyleClass(reactNative.StyleSheet);
|
|
1217
|
+
const StyledNativeComponent = _StyledNativeComponent(InlineStyle);
|
|
1218
|
+
const baseStyled = (tag) => constructWithOptions(StyledNativeComponent, tag);
|
|
1258
1219
|
/* React native lazy-requires each of these modules for some reason, so let's
|
|
1259
1220
|
* assume it's for a good reason and not eagerly load them all */
|
|
1260
|
-
|
|
1221
|
+
const aliases = [
|
|
1261
1222
|
'ActivityIndicator',
|
|
1262
|
-
'ActivityIndicatorIOS',
|
|
1263
|
-
'ART',
|
|
1264
1223
|
'Button',
|
|
1265
1224
|
'DatePickerIOS',
|
|
1266
1225
|
'DrawerLayoutAndroid',
|
|
1267
1226
|
'FlatList',
|
|
1268
1227
|
'Image',
|
|
1269
1228
|
'ImageBackground',
|
|
1270
|
-
'ImageEditor',
|
|
1271
|
-
'ImageStore',
|
|
1272
1229
|
'KeyboardAvoidingView',
|
|
1273
|
-
'ListView',
|
|
1274
|
-
'MapView',
|
|
1275
1230
|
'Modal',
|
|
1276
|
-
'NavigatorIOS',
|
|
1277
|
-
'Picker',
|
|
1278
|
-
'PickerIOS',
|
|
1279
1231
|
'Pressable',
|
|
1280
1232
|
'ProgressBarAndroid',
|
|
1281
1233
|
'ProgressViewIOS',
|
|
1282
|
-
'RecyclerViewBackedScrollView',
|
|
1283
1234
|
'RefreshControl',
|
|
1284
1235
|
'SafeAreaView',
|
|
1285
1236
|
'ScrollView',
|
|
1286
1237
|
'SectionList',
|
|
1287
|
-
'SegmentedControlIOS',
|
|
1288
1238
|
'Slider',
|
|
1289
|
-
'SliderIOS',
|
|
1290
|
-
'SnapshotViewIOS',
|
|
1291
|
-
'StatusBar',
|
|
1292
|
-
'SwipeableListView',
|
|
1293
1239
|
'Switch',
|
|
1294
|
-
'SwitchAndroid',
|
|
1295
|
-
'SwitchIOS',
|
|
1296
|
-
'TabBarIOS',
|
|
1297
1240
|
'Text',
|
|
1298
1241
|
'TextInput',
|
|
1299
|
-
'ToastAndroid',
|
|
1300
|
-
'ToolbarAndroid',
|
|
1301
|
-
'Touchable',
|
|
1302
1242
|
'TouchableHighlight',
|
|
1303
|
-
'TouchableNativeFeedback',
|
|
1304
1243
|
'TouchableOpacity',
|
|
1305
|
-
'TouchableWithoutFeedback',
|
|
1306
1244
|
'View',
|
|
1307
|
-
'ViewPagerAndroid',
|
|
1308
1245
|
'VirtualizedList',
|
|
1309
|
-
'WebView',
|
|
1310
1246
|
];
|
|
1311
|
-
|
|
1247
|
+
const styled = baseStyled;
|
|
1312
1248
|
/* Define a getter for each alias which simply gets the reactNative component
|
|
1313
1249
|
* and passes it to styled */
|
|
1314
|
-
aliases.forEach(
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
// @ts-expect-error supporting old imports in some cases
|
|
1250
|
+
aliases.forEach(alias => Object.defineProperty(styled, alias, {
|
|
1251
|
+
enumerable: true,
|
|
1252
|
+
configurable: false,
|
|
1253
|
+
get() {
|
|
1254
|
+
if (alias in reactNative && reactNative[alias]) {
|
|
1320
1255
|
return styled(reactNative[alias]);
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
}
|
|
1256
|
+
}
|
|
1257
|
+
throw new Error(`${alias} is not available in the currently-installed version of react-native`);
|
|
1258
|
+
},
|
|
1259
|
+
}));
|
|
1324
1260
|
|
|
1325
1261
|
export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, useTheme, withTheme };
|
|
1326
1262
|
//# sourceMappingURL=styled-components.native.esm.js.map
|