styled-components 6.0.0-beta.1 → 6.0.0-beta.10
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 +1858 -1
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +1832 -1
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +1879 -1
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +1853 -1
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +1978 -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 +87 -81
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +74 -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,7 +1,7 @@
|
|
|
1
1
|
import { __spreadArray, __assign } from 'tslib';
|
|
2
2
|
import React, { useContext, useMemo, createElement } from 'react';
|
|
3
3
|
import 'shallowequal';
|
|
4
|
-
import { prefixer, stringify,
|
|
4
|
+
import { prefixer, stringify, compile, middleware, RULESET } from 'stylis';
|
|
5
5
|
import unitless from '@emotion/unitless';
|
|
6
6
|
import transformDeclPairs from 'css-to-react-native';
|
|
7
7
|
import { parse } from 'postcss';
|
|
@@ -65,22 +65,24 @@ function throwStyledComponentsError(code) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
68
|
+
var SC_ATTR = (typeof process !== 'undefined' && typeof process.env !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
69
69
|
'data-styled';
|
|
70
70
|
var SC_ATTR_ACTIVE = 'active';
|
|
71
71
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
72
|
-
var SC_VERSION = "6.0.0-beta.
|
|
72
|
+
var SC_VERSION = "6.0.0-beta.10";
|
|
73
73
|
var SPLITTER = '/*!sc*/\n';
|
|
74
74
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
75
75
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
76
76
|
? SC_DISABLE_SPEEDY
|
|
77
77
|
: typeof process !== 'undefined' &&
|
|
78
|
+
typeof process.env !== 'undefined' &&
|
|
78
79
|
typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
|
|
79
80
|
process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''
|
|
80
81
|
? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false'
|
|
81
82
|
? false
|
|
82
83
|
: process.env.REACT_APP_SC_DISABLE_SPEEDY
|
|
83
84
|
: typeof process !== 'undefined' &&
|
|
85
|
+
typeof process.env !== 'undefined' &&
|
|
84
86
|
typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' &&
|
|
85
87
|
process.env.SC_DISABLE_SPEEDY !== ''
|
|
86
88
|
? process.env.SC_DISABLE_SPEEDY === 'false'
|
|
@@ -229,7 +231,6 @@ var rehydrateNamesFromContent = function (sheet, id, content) {
|
|
|
229
231
|
var names = content.split(',');
|
|
230
232
|
var name;
|
|
231
233
|
for (var i = 0, l = names.length; i < l; i++) {
|
|
232
|
-
// eslint-disable-next-line
|
|
233
234
|
if ((name = names[i])) {
|
|
234
235
|
sheet.registerName(id, name);
|
|
235
236
|
}
|
|
@@ -539,6 +540,27 @@ var COMPLEX_SELECTOR_PREFIX = [':', '[', '.', '#'];
|
|
|
539
540
|
function serialize(children, callback) {
|
|
540
541
|
return children.map(function (c, i) { return callback(c, i, children, callback); }).filter(Boolean);
|
|
541
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Takes an element and recurses through it's rules added the namespace to the start of each selector.
|
|
545
|
+
* Takes into account media queries by recursing through child rules if they are present.
|
|
546
|
+
*/
|
|
547
|
+
function recursivelySetNamepace(compiled, namespace) {
|
|
548
|
+
return compiled.map(function (rule) {
|
|
549
|
+
if (rule.type === 'rule') {
|
|
550
|
+
// add the namespace to the start
|
|
551
|
+
rule.value = "".concat(namespace, " ").concat(rule.value);
|
|
552
|
+
// add the namespace after each comma for subsequent selectors.
|
|
553
|
+
rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
|
|
554
|
+
rule.props = rule.props.map(function (prop) {
|
|
555
|
+
return "".concat(namespace, " ").concat(prop);
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
if (Array.isArray(rule.children)) {
|
|
559
|
+
rule.children = recursivelySetNamepace(rule.children, namespace);
|
|
560
|
+
}
|
|
561
|
+
return rule;
|
|
562
|
+
});
|
|
563
|
+
}
|
|
542
564
|
function createStylisInstance(_a) {
|
|
543
565
|
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;
|
|
544
566
|
var _componentId;
|
|
@@ -572,7 +594,11 @@ function createStylisInstance(_a) {
|
|
|
572
594
|
props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
|
|
573
595
|
}
|
|
574
596
|
};
|
|
575
|
-
var stringifyRules = function (css, selector,
|
|
597
|
+
var stringifyRules = function (css, selector,
|
|
598
|
+
/**
|
|
599
|
+
* This "prefix" referes to a _selector_ prefix.
|
|
600
|
+
*/
|
|
601
|
+
prefix, componentId) {
|
|
576
602
|
if (selector === void 0) { selector = ''; }
|
|
577
603
|
if (prefix === void 0) { prefix = ''; }
|
|
578
604
|
if (componentId === void 0) { componentId = '&'; }
|
|
@@ -585,11 +611,18 @@ function createStylisInstance(_a) {
|
|
|
585
611
|
_selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
|
|
586
612
|
_consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
|
|
587
613
|
var middlewares = plugins.slice();
|
|
614
|
+
/**
|
|
615
|
+
* Enables automatic vendor-prefixing for styles.
|
|
616
|
+
*/
|
|
588
617
|
if (options.prefix || options.prefix === undefined) {
|
|
589
618
|
middlewares.unshift(prefixer);
|
|
590
619
|
}
|
|
591
620
|
middlewares.push(selfReferenceReplacementPlugin, stringify);
|
|
592
|
-
|
|
621
|
+
var compiled = compile(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
|
|
622
|
+
if (options.namespace) {
|
|
623
|
+
compiled = recursivelySetNamepace(compiled, options.namespace);
|
|
624
|
+
}
|
|
625
|
+
return serialize(compiled, middleware(middlewares));
|
|
593
626
|
};
|
|
594
627
|
stringifyRules.hash = plugins.length
|
|
595
628
|
? plugins
|
|
@@ -604,7 +637,10 @@ function createStylisInstance(_a) {
|
|
|
604
637
|
return stringifyRules;
|
|
605
638
|
}
|
|
606
639
|
|
|
607
|
-
var StyleSheetContext = React.createContext(
|
|
640
|
+
var StyleSheetContext = React.createContext({
|
|
641
|
+
shouldForwardProp: undefined,
|
|
642
|
+
styleSheet: undefined,
|
|
643
|
+
});
|
|
608
644
|
StyleSheetContext.Consumer;
|
|
609
645
|
var StylisContext = React.createContext(undefined);
|
|
610
646
|
StylisContext.Consumer;
|
|
@@ -658,8 +694,8 @@ function getComponentName(target) {
|
|
|
658
694
|
* inlined version of
|
|
659
695
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
660
696
|
*/
|
|
661
|
-
var uppercaseCheck = /
|
|
662
|
-
var uppercasePattern = /
|
|
697
|
+
var uppercaseCheck = /[A-Z]/;
|
|
698
|
+
var uppercasePattern = /[A-Z]/g;
|
|
663
699
|
var msPattern = /^ms-/;
|
|
664
700
|
var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
|
|
665
701
|
/**
|
|
@@ -676,7 +712,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
|
|
|
676
712
|
* is converted to `-ms-`.
|
|
677
713
|
*/
|
|
678
714
|
function hyphenateStyleName(string) {
|
|
679
|
-
return uppercaseCheck.test(string)
|
|
715
|
+
return uppercaseCheck.test(string) && !string.startsWith('--')
|
|
680
716
|
? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
|
|
681
717
|
: string;
|
|
682
718
|
}
|
|
@@ -732,21 +768,18 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
732
768
|
var ruleSet = [];
|
|
733
769
|
for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
|
|
734
770
|
result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
|
|
735
|
-
if (result ===
|
|
771
|
+
if (result.length === 0)
|
|
736
772
|
continue;
|
|
737
|
-
|
|
738
|
-
ruleSet.push.apply(ruleSet, result);
|
|
739
|
-
else
|
|
740
|
-
ruleSet.push(result);
|
|
773
|
+
ruleSet.push.apply(ruleSet, result);
|
|
741
774
|
}
|
|
742
775
|
return ruleSet;
|
|
743
776
|
}
|
|
744
777
|
if (isFalsish(chunk)) {
|
|
745
|
-
return
|
|
778
|
+
return [];
|
|
746
779
|
}
|
|
747
780
|
/* Handle other components */
|
|
748
781
|
if (isStyledComponent(chunk)) {
|
|
749
|
-
return ".".concat(chunk.styledComponentId);
|
|
782
|
+
return [".".concat(chunk.styledComponentId)];
|
|
750
783
|
}
|
|
751
784
|
/* Either execute or defer the function */
|
|
752
785
|
if (isFunction(chunk)) {
|
|
@@ -757,27 +790,27 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
757
790
|
typeof result === 'object' &&
|
|
758
791
|
!Array.isArray(result) &&
|
|
759
792
|
!(result instanceof Keyframes) &&
|
|
760
|
-
!isPlainObject(result)
|
|
761
|
-
|
|
762
|
-
console.error("".concat(getComponentName(
|
|
763
|
-
// @ts-expect-error handling unexpected input
|
|
764
|
-
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."));
|
|
793
|
+
!isPlainObject(result) &&
|
|
794
|
+
result !== null) {
|
|
795
|
+
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."));
|
|
765
796
|
}
|
|
766
797
|
return flatten(result, executionContext, styleSheet, stylisInstance);
|
|
767
798
|
}
|
|
768
|
-
else
|
|
769
|
-
return chunk;
|
|
799
|
+
else {
|
|
800
|
+
return [chunk];
|
|
801
|
+
}
|
|
770
802
|
}
|
|
771
803
|
if (chunk instanceof Keyframes) {
|
|
772
804
|
if (styleSheet) {
|
|
773
805
|
chunk.inject(styleSheet, stylisInstance);
|
|
774
|
-
return chunk.getName(stylisInstance);
|
|
806
|
+
return [chunk.getName(stylisInstance)];
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
return [chunk];
|
|
775
810
|
}
|
|
776
|
-
else
|
|
777
|
-
return chunk;
|
|
778
811
|
}
|
|
779
812
|
/* Handle objects */
|
|
780
|
-
return isPlainObject(chunk) ? objToCssArray(chunk) : chunk.toString();
|
|
813
|
+
return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
|
|
781
814
|
}
|
|
782
815
|
|
|
783
816
|
function interleave(strings, interpolations) {
|
|
@@ -793,11 +826,7 @@ function interleave(strings, interpolations) {
|
|
|
793
826
|
* expand an array of styles.
|
|
794
827
|
*/
|
|
795
828
|
var addTag = function (arg) {
|
|
796
|
-
|
|
797
|
-
// eslint-disable-next-line no-param-reassign
|
|
798
|
-
arg.isCss = true;
|
|
799
|
-
}
|
|
800
|
-
return arg;
|
|
829
|
+
return Object.assign(arg, { isCss: true });
|
|
801
830
|
};
|
|
802
831
|
function css(styles) {
|
|
803
832
|
var interpolations = [];
|
|
@@ -814,7 +843,7 @@ function css(styles) {
|
|
|
814
843
|
if (interpolations.length === 0 &&
|
|
815
844
|
styleStringArray.length === 1 &&
|
|
816
845
|
typeof styleStringArray[0] === 'string') {
|
|
817
|
-
return styleStringArray;
|
|
846
|
+
return flatten(styleStringArray);
|
|
818
847
|
}
|
|
819
848
|
return addTag(flatten(interleave(styleStringArray, interpolations)));
|
|
820
849
|
}
|
|
@@ -995,7 +1024,6 @@ function withTheme(Component) {
|
|
|
995
1024
|
var theme = React.useContext(ThemeContext);
|
|
996
1025
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
997
1026
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
998
|
-
// eslint-disable-next-line no-console
|
|
999
1027
|
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), "\""));
|
|
1000
1028
|
}
|
|
1001
1029
|
return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
|
|
@@ -1048,7 +1076,6 @@ function makeInlineStyleClass(styleSheet) {
|
|
|
1048
1076
|
declPairs_1.push([node.prop, node.value]);
|
|
1049
1077
|
}
|
|
1050
1078
|
else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {
|
|
1051
|
-
/* eslint-disable no-console */
|
|
1052
1079
|
console.warn("Node of type ".concat(node.type, " not supported as an inline style"));
|
|
1053
1080
|
}
|
|
1054
1081
|
});
|
|
@@ -1101,7 +1128,6 @@ function mixinRecursively(target, source, forceMerge) {
|
|
|
1101
1128
|
* Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
|
|
1102
1129
|
*/
|
|
1103
1130
|
function mixinDeep(target) {
|
|
1104
|
-
if (target === void 0) { target = {}; }
|
|
1105
1131
|
var sources = [];
|
|
1106
1132
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1107
1133
|
sources[_i - 1] = arguments[_i];
|
|
@@ -1121,20 +1147,15 @@ function useResolvedAttrs(theme, props, attrs) {
|
|
|
1121
1147
|
var context = __assign(__assign({}, props), { theme: theme });
|
|
1122
1148
|
var resolvedAttrs = {};
|
|
1123
1149
|
attrs.forEach(function (attrDef) {
|
|
1124
|
-
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1125
1150
|
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1126
1151
|
var key;
|
|
1127
|
-
/* eslint-disable guard-for-in */
|
|
1128
1152
|
for (key in resolvedAttrDef) {
|
|
1129
1153
|
// @ts-expect-error bad types
|
|
1130
1154
|
context[key] = resolvedAttrs[key] = resolvedAttrDef[key];
|
|
1131
1155
|
}
|
|
1132
|
-
/* eslint-enable guard-for-in */
|
|
1133
1156
|
});
|
|
1134
1157
|
return [context, resolvedAttrs];
|
|
1135
1158
|
}
|
|
1136
|
-
// Validator defaults to true if not in HTML/DOM env
|
|
1137
|
-
var validAttr = function () { return true; };
|
|
1138
1159
|
function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
1139
1160
|
var componentAttrs = forwardedComponent.attrs, inlineStyle = forwardedComponent.inlineStyle, defaultProps = forwardedComponent.defaultProps, shouldForwardProp = forwardedComponent.shouldForwardProp, target = forwardedComponent.target;
|
|
1140
1161
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
@@ -1144,32 +1165,25 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1144
1165
|
var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
|
|
1145
1166
|
var generatedStyles = inlineStyle.generateStyleObject(context);
|
|
1146
1167
|
var refToForward = forwardedRef;
|
|
1147
|
-
var elementToBeCreated = attrs
|
|
1168
|
+
var elementToBeCreated = attrs.as || props.as || target;
|
|
1148
1169
|
var computedProps = attrs !== props ? __assign(__assign({}, props), attrs) : props;
|
|
1149
1170
|
var propsForElement = {};
|
|
1150
|
-
// eslint-disable-next-line guard-for-in
|
|
1151
1171
|
for (var key in computedProps) {
|
|
1152
1172
|
if (key[0] === '$' || key === 'as')
|
|
1153
1173
|
continue;
|
|
1154
1174
|
else if (key === 'forwardedAs') {
|
|
1155
1175
|
propsForElement.as = computedProps[key];
|
|
1156
1176
|
}
|
|
1157
|
-
else if (!shouldForwardProp || shouldForwardProp(key,
|
|
1177
|
+
else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
|
|
1158
1178
|
propsForElement[key] = computedProps[key];
|
|
1159
1179
|
}
|
|
1160
1180
|
}
|
|
1161
1181
|
propsForElement.style = useMemo(function () {
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
else if (props.style == null) {
|
|
1168
|
-
return generatedStyles;
|
|
1169
|
-
}
|
|
1170
|
-
else {
|
|
1171
|
-
return [generatedStyles].concat(props.style || []);
|
|
1172
|
-
}
|
|
1182
|
+
return typeof props.style === 'function'
|
|
1183
|
+
? function (state) { return [generatedStyles].concat(props.style(state)); }
|
|
1184
|
+
: props.style
|
|
1185
|
+
? [generatedStyles].concat(props.style)
|
|
1186
|
+
: generatedStyles;
|
|
1173
1187
|
}, [props.style, generatedStyles]);
|
|
1174
1188
|
propsForElement.ref = refToForward;
|
|
1175
1189
|
return createElement(elementToBeCreated, propsForElement);
|
|
@@ -1183,25 +1197,22 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1183
1197
|
var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
|
|
1184
1198
|
? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
|
|
1185
1199
|
: attrs;
|
|
1186
|
-
// eslint-disable-next-line prefer-destructuring
|
|
1187
1200
|
var shouldForwardProp = options.shouldForwardProp;
|
|
1188
1201
|
if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
|
|
1189
1202
|
var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
|
|
1190
1203
|
if (options.shouldForwardProp) {
|
|
1191
1204
|
var passedShouldForwardPropFn_1 = options.shouldForwardProp;
|
|
1192
1205
|
// compose nested shouldForwardProp calls
|
|
1193
|
-
shouldForwardProp = function (prop,
|
|
1194
|
-
return shouldForwardPropFn_1(prop,
|
|
1195
|
-
passedShouldForwardPropFn_1(prop,
|
|
1206
|
+
shouldForwardProp = function (prop, elementToBeCreated) {
|
|
1207
|
+
return shouldForwardPropFn_1(prop, elementToBeCreated) &&
|
|
1208
|
+
passedShouldForwardPropFn_1(prop, elementToBeCreated);
|
|
1196
1209
|
};
|
|
1197
1210
|
}
|
|
1198
1211
|
else {
|
|
1199
|
-
// eslint-disable-next-line prefer-destructuring
|
|
1200
1212
|
shouldForwardProp = shouldForwardPropFn_1;
|
|
1201
1213
|
}
|
|
1202
1214
|
}
|
|
1203
1215
|
var forwardRef = function (props, ref) {
|
|
1204
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1205
1216
|
return useStyledComponentImpl(WrappedStyledComponent, props, ref);
|
|
1206
1217
|
};
|
|
1207
1218
|
forwardRef.displayName = displayName;
|
|
@@ -1218,10 +1229,6 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1218
1229
|
WrappedStyledComponent.styledComponentId = true;
|
|
1219
1230
|
// fold the underlying StyledComponent target up since we folded the styles
|
|
1220
1231
|
WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
|
|
1221
|
-
WrappedStyledComponent.withComponent = function withComponent(tag) {
|
|
1222
|
-
var newOptions = __assign(__assign({}, options), { attrs: finalAttrs });
|
|
1223
|
-
return createStyledNativeComponent(tag, newOptions, rules);
|
|
1224
|
-
};
|
|
1225
1232
|
Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
|
|
1226
1233
|
get: function () {
|
|
1227
1234
|
return this._foldedDefaultProps;
|
|
@@ -1239,14 +1246,12 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1239
1246
|
displayName: true,
|
|
1240
1247
|
shouldForwardProp: true,
|
|
1241
1248
|
target: true,
|
|
1242
|
-
withComponent: true,
|
|
1243
1249
|
});
|
|
1244
1250
|
return WrappedStyledComponent;
|
|
1245
1251
|
};
|
|
1246
1252
|
return createStyledNativeComponent;
|
|
1247
1253
|
});
|
|
1248
1254
|
|
|
1249
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1250
1255
|
var reactNative = require('react-native');
|
|
1251
1256
|
var InlineStyle = makeInlineStyleClass(reactNative.StyleSheet);
|
|
1252
1257
|
var StyledNativeComponent = _StyledNativeComponent(InlineStyle);
|
|
@@ -1297,5 +1302,5 @@ aliases.forEach(function (alias) {
|
|
|
1297
1302
|
});
|
|
1298
1303
|
});
|
|
1299
1304
|
|
|
1300
|
-
export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, useTheme, withTheme };
|
|
1305
|
+
export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, styled, useTheme, withTheme };
|
|
1301
1306
|
//# sourceMappingURL=styled-components.native.esm.js.map
|