styled-components 6.0.0-beta.1 → 6.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +3 -3
- package/dist/constructors/constructWithOptions.d.ts +24 -31
- package/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/dist/constructors/css.d.ts +4 -4
- package/dist/constructors/keyframes.d.ts +1 -1
- package/dist/constructors/styled.d.ts +177 -181
- package/dist/hoc/withTheme.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/models/GlobalStyle.d.ts +1 -1
- package/dist/models/InlineStyle.d.ts +1 -1
- package/dist/models/StyleSheetManager.d.ts +58 -14
- package/dist/models/StyledComponent.d.ts +1 -1
- package/dist/models/StyledNativeComponent.d.ts +2 -2
- package/dist/models/ThemeProvider.d.ts +1 -1
- package/dist/native/index.d.ts +28 -32
- package/dist/styled-components-macro.cjs.js +46 -1
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components-macro.esm.js +37 -1
- package/dist/styled-components-macro.esm.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +1859 -1
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +1833 -1
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +1880 -1
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +1854 -1
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +1979 -1
- package/dist/styled-components.js.map +1 -1
- package/dist/styled-components.min.js +1 -1
- package/dist/styled-components.min.js.map +1 -1
- package/dist/test/types.d.ts +1 -0
- package/dist/test/utils.d.ts +176 -180
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +81 -73
- package/dist/utils/determineTheme.d.ts +2 -2
- package/dist/utils/domElements.d.ts +1 -1
- package/dist/utils/empties.d.ts +2 -2
- package/dist/utils/flatten.d.ts +3 -3
- package/dist/utils/generateDisplayName.d.ts +1 -1
- package/dist/utils/getComponentName.d.ts +1 -1
- package/dist/utils/interleave.d.ts +1 -1
- package/dist/utils/isStaticRules.d.ts +1 -1
- package/dist/utils/isStyledComponent.d.ts +1 -1
- package/dist/utils/isTag.d.ts +1 -1
- package/dist/utils/joinStrings.d.ts +1 -1
- package/dist/utils/mixinDeep.d.ts +1 -2
- package/dist/utils/stylis.d.ts +3 -3
- package/native/dist/base.d.ts +3 -3
- package/native/dist/constructors/constructWithOptions.d.ts +24 -31
- package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
- package/native/dist/constructors/css.d.ts +4 -4
- package/native/dist/constructors/keyframes.d.ts +1 -1
- package/native/dist/constructors/styled.d.ts +177 -181
- package/native/dist/hoc/withTheme.d.ts +2 -2
- package/native/dist/index.d.ts +2 -2
- package/native/dist/models/GlobalStyle.d.ts +1 -1
- package/native/dist/models/InlineStyle.d.ts +1 -1
- package/native/dist/models/StyleSheetManager.d.ts +58 -14
- package/native/dist/models/StyledComponent.d.ts +1 -1
- package/native/dist/models/StyledNativeComponent.d.ts +2 -2
- package/native/dist/models/ThemeProvider.d.ts +1 -1
- package/native/dist/native/index.d.ts +28 -32
- package/native/dist/styled-components.native.cjs.js +88 -81
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +75 -69
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/test/types.d.ts +1 -0
- package/native/dist/test/utils.d.ts +176 -180
- package/native/dist/types.d.ts +81 -73
- package/native/dist/utils/determineTheme.d.ts +2 -2
- package/native/dist/utils/domElements.d.ts +1 -1
- package/native/dist/utils/empties.d.ts +2 -2
- package/native/dist/utils/flatten.d.ts +3 -3
- package/native/dist/utils/generateDisplayName.d.ts +1 -1
- package/native/dist/utils/getComponentName.d.ts +1 -1
- package/native/dist/utils/interleave.d.ts +1 -1
- package/native/dist/utils/isStaticRules.d.ts +1 -1
- package/native/dist/utils/isStyledComponent.d.ts +1 -1
- package/native/dist/utils/isTag.d.ts +1 -1
- package/native/dist/utils/joinStrings.d.ts +1 -1
- package/native/dist/utils/mixinDeep.d.ts +1 -2
- package/native/dist/utils/stylis.d.ts +3 -3
- package/package.json +40 -39
- package/test-utils/index.ts +10 -6
- package/native/dist/base.d.ts.map +0 -1
- package/native/dist/constants.d.ts.map +0 -1
- package/native/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/native/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/native/dist/constructors/css.d.ts.map +0 -1
- package/native/dist/constructors/keyframes.d.ts.map +0 -1
- package/native/dist/constructors/styled.d.ts.map +0 -1
- package/native/dist/dist/base.d.ts +0 -18
- package/native/dist/dist/base.d.ts.map +0 -1
- package/native/dist/dist/constants.d.ts +0 -9
- package/native/dist/dist/constants.d.ts.map +0 -1
- package/native/dist/dist/constructors/constructWithOptions.d.ts +0 -20
- package/native/dist/dist/constructors/constructWithOptions.d.ts.map +0 -1
- package/native/dist/dist/constructors/createGlobalStyle.d.ts +0 -4
- package/native/dist/dist/constructors/createGlobalStyle.d.ts.map +0 -1
- package/native/dist/dist/constructors/css.d.ts +0 -5
- package/native/dist/dist/constructors/css.d.ts.map +0 -1
- package/native/dist/dist/constructors/keyframes.d.ts +0 -4
- package/native/dist/dist/constructors/keyframes.d.ts.map +0 -1
- package/native/dist/dist/constructors/styled.d.ts +0 -186
- package/native/dist/dist/constructors/styled.d.ts.map +0 -1
- package/native/dist/dist/hoc/withTheme.d.ts +0 -4
- package/native/dist/dist/hoc/withTheme.d.ts.map +0 -1
- package/native/dist/dist/hoc/withTheme.spec.d.ts +0 -2
- package/native/dist/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/native/dist/dist/hooks/useTheme.d.ts +0 -4
- package/native/dist/dist/hooks/useTheme.d.ts.map +0 -1
- package/native/dist/dist/index-standalone.d.ts +0 -3
- package/native/dist/dist/index-standalone.d.ts.map +0 -1
- package/native/dist/dist/index.d.ts +0 -4
- package/native/dist/dist/index.d.ts.map +0 -1
- package/native/dist/dist/macro/index.d.ts +0 -3
- package/native/dist/dist/macro/index.d.ts.map +0 -1
- package/native/dist/dist/macro/test/babel.config.d.ts +0 -1
- package/native/dist/dist/macro/test/babel.config.d.ts.map +0 -1
- package/native/dist/dist/models/ComponentStyle.d.ts +0 -16
- package/native/dist/dist/models/ComponentStyle.d.ts.map +0 -1
- package/native/dist/dist/models/GlobalStyle.d.ts +0 -12
- package/native/dist/dist/models/GlobalStyle.d.ts.map +0 -1
- package/native/dist/dist/models/InlineStyle.d.ts +0 -7
- package/native/dist/dist/models/InlineStyle.d.ts.map +0 -1
- package/native/dist/dist/models/Keyframes.d.ts +0 -12
- package/native/dist/dist/models/Keyframes.d.ts.map +0 -1
- package/native/dist/dist/models/ServerStyleSheet.d.ts +0 -16
- package/native/dist/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/native/dist/dist/models/StyleSheetManager.d.ts +0 -22
- package/native/dist/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/native/dist/dist/models/StyledComponent.d.ts +0 -4
- package/native/dist/dist/models/StyledComponent.d.ts.map +0 -1
- package/native/dist/dist/models/StyledNativeComponent.d.ts +0 -4
- package/native/dist/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/native/dist/dist/models/ThemeProvider.d.ts +0 -18
- package/native/dist/dist/models/ThemeProvider.d.ts.map +0 -1
- package/native/dist/dist/native/index.d.ts +0 -65
- package/native/dist/dist/native/index.d.ts.map +0 -1
- package/native/dist/dist/primitives/index.d.ts +0 -23
- package/native/dist/dist/primitives/index.d.ts.map +0 -1
- package/native/dist/dist/secretInternals.d.ts +0 -6
- package/native/dist/dist/secretInternals.d.ts.map +0 -1
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts +0 -5
- package/native/dist/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/native/dist/dist/sheet/GroupedTag.d.ts +0 -12
- package/native/dist/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/native/dist/dist/sheet/Rehydration.d.ts +0 -4
- package/native/dist/dist/sheet/Rehydration.d.ts.map +0 -1
- package/native/dist/dist/sheet/Sheet.d.ts +0 -41
- package/native/dist/dist/sheet/Sheet.d.ts.map +0 -1
- package/native/dist/dist/sheet/Tag.d.ts +0 -55
- package/native/dist/dist/sheet/Tag.d.ts.map +0 -1
- package/native/dist/dist/sheet/dom.d.ts +0 -5
- package/native/dist/dist/sheet/dom.d.ts.map +0 -1
- package/native/dist/dist/sheet/index.d.ts +0 -2
- package/native/dist/dist/sheet/index.d.ts.map +0 -1
- package/native/dist/dist/sheet/types.d.ts +0 -35
- package/native/dist/dist/sheet/types.d.ts.map +0 -1
- package/native/dist/dist/test/globals.d.ts +0 -3
- package/native/dist/dist/test/globals.d.ts.map +0 -1
- package/native/dist/dist/test/utils.d.ts +0 -192
- package/native/dist/dist/test/utils.d.ts.map +0 -1
- package/native/dist/dist/types.d.ts +0 -121
- package/native/dist/dist/types.d.ts.map +0 -1
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts +0 -2
- package/native/dist/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/native/dist/dist/utils/checkDynamicCreation.d.ts +0 -2
- package/native/dist/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -4
- package/native/dist/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/native/dist/dist/utils/determineTheme.d.ts +0 -3
- package/native/dist/dist/utils/determineTheme.d.ts.map +0 -1
- package/native/dist/dist/utils/domElements.d.ts +0 -3
- package/native/dist/dist/utils/domElements.d.ts.map +0 -1
- package/native/dist/dist/utils/empties.d.ts +0 -4
- package/native/dist/dist/utils/empties.d.ts.map +0 -1
- package/native/dist/dist/utils/error.d.ts +0 -6
- package/native/dist/dist/utils/error.d.ts.map +0 -1
- package/native/dist/dist/utils/errors.d.ts +0 -21
- package/native/dist/dist/utils/errors.d.ts.map +0 -1
- package/native/dist/dist/utils/escape.d.ts +0 -6
- package/native/dist/dist/utils/escape.d.ts.map +0 -1
- package/native/dist/dist/utils/flatten.d.ts +0 -5
- package/native/dist/dist/utils/flatten.d.ts.map +0 -1
- package/native/dist/dist/utils/generateAlphabeticName.d.ts +0 -2
- package/native/dist/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/native/dist/dist/utils/generateComponentId.d.ts +0 -2
- package/native/dist/dist/utils/generateComponentId.d.ts.map +0 -1
- package/native/dist/dist/utils/generateDisplayName.d.ts +0 -3
- package/native/dist/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/native/dist/dist/utils/getComponentName.d.ts +0 -3
- package/native/dist/dist/utils/getComponentName.d.ts.map +0 -1
- package/native/dist/dist/utils/hash.d.ts +0 -4
- package/native/dist/dist/utils/hash.d.ts.map +0 -1
- package/native/dist/dist/utils/hoist.d.ts +0 -52
- package/native/dist/dist/utils/hoist.d.ts.map +0 -1
- package/native/dist/dist/utils/hyphenateStyleName.d.ts +0 -15
- package/native/dist/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/native/dist/dist/utils/interleave.d.ts +0 -3
- package/native/dist/dist/utils/interleave.d.ts.map +0 -1
- package/native/dist/dist/utils/isFunction.d.ts +0 -2
- package/native/dist/dist/utils/isFunction.d.ts.map +0 -1
- package/native/dist/dist/utils/isPlainObject.d.ts +0 -2
- package/native/dist/dist/utils/isPlainObject.d.ts.map +0 -1
- package/native/dist/dist/utils/isStatelessFunction.d.ts +0 -2
- package/native/dist/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/native/dist/dist/utils/isStaticRules.d.ts +0 -3
- package/native/dist/dist/utils/isStaticRules.d.ts.map +0 -1
- package/native/dist/dist/utils/isStyledComponent.d.ts +0 -3
- package/native/dist/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/native/dist/dist/utils/isTag.d.ts +0 -3
- package/native/dist/dist/utils/isTag.d.ts.map +0 -1
- package/native/dist/dist/utils/joinStrings.d.ts +0 -5
- package/native/dist/dist/utils/joinStrings.d.ts.map +0 -1
- package/native/dist/dist/utils/mixinDeep.d.ts +0 -8
- package/native/dist/dist/utils/mixinDeep.d.ts.map +0 -1
- package/native/dist/dist/utils/nonce.d.ts +0 -2
- package/native/dist/dist/utils/nonce.d.ts.map +0 -1
- package/native/dist/dist/utils/stylis.d.ts +0 -10
- package/native/dist/dist/utils/stylis.d.ts.map +0 -1
- package/native/dist/hoc/withTheme.d.ts.map +0 -1
- package/native/dist/hoc/withTheme.spec.d.ts.map +0 -1
- package/native/dist/hooks/useTheme.d.ts.map +0 -1
- package/native/dist/index-standalone.d.ts.map +0 -1
- package/native/dist/index.d.ts.map +0 -1
- package/native/dist/macro/index.d.ts.map +0 -1
- package/native/dist/macro/test/babel.config.d.ts +0 -1
- package/native/dist/macro/test/babel.config.d.ts.map +0 -1
- package/native/dist/models/ComponentStyle.d.ts.map +0 -1
- package/native/dist/models/GlobalStyle.d.ts.map +0 -1
- package/native/dist/models/InlineStyle.d.ts.map +0 -1
- package/native/dist/models/Keyframes.d.ts.map +0 -1
- package/native/dist/models/ServerStyleSheet.d.ts.map +0 -1
- package/native/dist/models/StyleSheetManager.d.ts.map +0 -1
- package/native/dist/models/StyledComponent.d.ts.map +0 -1
- package/native/dist/models/StyledNativeComponent.d.ts.map +0 -1
- package/native/dist/models/ThemeProvider.d.ts.map +0 -1
- package/native/dist/native/index.d.ts.map +0 -1
- package/native/dist/primitives/index.d.ts +0 -23
- package/native/dist/primitives/index.d.ts.map +0 -1
- package/native/dist/secretInternals.d.ts.map +0 -1
- package/native/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
- package/native/dist/sheet/GroupedTag.d.ts.map +0 -1
- package/native/dist/sheet/Rehydration.d.ts.map +0 -1
- package/native/dist/sheet/Sheet.d.ts.map +0 -1
- package/native/dist/sheet/Tag.d.ts.map +0 -1
- package/native/dist/sheet/dom.d.ts.map +0 -1
- package/native/dist/sheet/index.d.ts.map +0 -1
- package/native/dist/sheet/types.d.ts.map +0 -1
- package/native/dist/test/globals.d.ts.map +0 -1
- package/native/dist/test/utils.d.ts.map +0 -1
- package/native/dist/types.d.ts.map +0 -1
- package/native/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
- package/native/dist/utils/checkDynamicCreation.d.ts.map +0 -1
- package/native/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
- package/native/dist/utils/determineTheme.d.ts.map +0 -1
- package/native/dist/utils/domElements.d.ts.map +0 -1
- package/native/dist/utils/empties.d.ts.map +0 -1
- package/native/dist/utils/error.d.ts.map +0 -1
- package/native/dist/utils/errors.d.ts.map +0 -1
- package/native/dist/utils/escape.d.ts.map +0 -1
- package/native/dist/utils/flatten.d.ts.map +0 -1
- package/native/dist/utils/generateAlphabeticName.d.ts.map +0 -1
- package/native/dist/utils/generateComponentId.d.ts.map +0 -1
- package/native/dist/utils/generateDisplayName.d.ts.map +0 -1
- package/native/dist/utils/getComponentName.d.ts.map +0 -1
- package/native/dist/utils/hash.d.ts.map +0 -1
- package/native/dist/utils/hoist.d.ts.map +0 -1
- package/native/dist/utils/hyphenateStyleName.d.ts.map +0 -1
- package/native/dist/utils/interleave.d.ts.map +0 -1
- package/native/dist/utils/isFunction.d.ts.map +0 -1
- package/native/dist/utils/isPlainObject.d.ts.map +0 -1
- package/native/dist/utils/isStatelessFunction.d.ts.map +0 -1
- package/native/dist/utils/isStaticRules.d.ts.map +0 -1
- package/native/dist/utils/isStyledComponent.d.ts.map +0 -1
- package/native/dist/utils/isTag.d.ts.map +0 -1
- package/native/dist/utils/joinStrings.d.ts.map +0 -1
- package/native/dist/utils/mixinDeep.d.ts.map +0 -1
- package/native/dist/utils/nonce.d.ts.map +0 -1
- package/native/dist/utils/stylis.d.ts.map +0 -1
|
@@ -1,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.11";
|
|
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,28 @@ 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
|
+
// @ts-expect-error we target modern browsers but intentionally transpile to ES5 for speed
|
|
554
|
+
rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
|
|
555
|
+
rule.props = rule.props.map(function (prop) {
|
|
556
|
+
return "".concat(namespace, " ").concat(prop);
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (Array.isArray(rule.children)) {
|
|
560
|
+
rule.children = recursivelySetNamepace(rule.children, namespace);
|
|
561
|
+
}
|
|
562
|
+
return rule;
|
|
563
|
+
});
|
|
564
|
+
}
|
|
542
565
|
function createStylisInstance(_a) {
|
|
543
566
|
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
567
|
var _componentId;
|
|
@@ -572,7 +595,11 @@ function createStylisInstance(_a) {
|
|
|
572
595
|
props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
|
|
573
596
|
}
|
|
574
597
|
};
|
|
575
|
-
var stringifyRules = function (css, selector,
|
|
598
|
+
var stringifyRules = function (css, selector,
|
|
599
|
+
/**
|
|
600
|
+
* This "prefix" referes to a _selector_ prefix.
|
|
601
|
+
*/
|
|
602
|
+
prefix, componentId) {
|
|
576
603
|
if (selector === void 0) { selector = ''; }
|
|
577
604
|
if (prefix === void 0) { prefix = ''; }
|
|
578
605
|
if (componentId === void 0) { componentId = '&'; }
|
|
@@ -585,11 +612,18 @@ function createStylisInstance(_a) {
|
|
|
585
612
|
_selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
|
|
586
613
|
_consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
|
|
587
614
|
var middlewares = plugins.slice();
|
|
615
|
+
/**
|
|
616
|
+
* Enables automatic vendor-prefixing for styles.
|
|
617
|
+
*/
|
|
588
618
|
if (options.prefix || options.prefix === undefined) {
|
|
589
619
|
middlewares.unshift(prefixer);
|
|
590
620
|
}
|
|
591
621
|
middlewares.push(selfReferenceReplacementPlugin, stringify);
|
|
592
|
-
|
|
622
|
+
var compiled = compile(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
|
|
623
|
+
if (options.namespace) {
|
|
624
|
+
compiled = recursivelySetNamepace(compiled, options.namespace);
|
|
625
|
+
}
|
|
626
|
+
return serialize(compiled, middleware(middlewares));
|
|
593
627
|
};
|
|
594
628
|
stringifyRules.hash = plugins.length
|
|
595
629
|
? plugins
|
|
@@ -604,7 +638,10 @@ function createStylisInstance(_a) {
|
|
|
604
638
|
return stringifyRules;
|
|
605
639
|
}
|
|
606
640
|
|
|
607
|
-
var StyleSheetContext = React.createContext(
|
|
641
|
+
var StyleSheetContext = React.createContext({
|
|
642
|
+
shouldForwardProp: undefined,
|
|
643
|
+
styleSheet: undefined,
|
|
644
|
+
});
|
|
608
645
|
StyleSheetContext.Consumer;
|
|
609
646
|
var StylisContext = React.createContext(undefined);
|
|
610
647
|
StylisContext.Consumer;
|
|
@@ -658,8 +695,8 @@ function getComponentName(target) {
|
|
|
658
695
|
* inlined version of
|
|
659
696
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
660
697
|
*/
|
|
661
|
-
var uppercaseCheck = /
|
|
662
|
-
var uppercasePattern = /
|
|
698
|
+
var uppercaseCheck = /[A-Z]/;
|
|
699
|
+
var uppercasePattern = /[A-Z]/g;
|
|
663
700
|
var msPattern = /^ms-/;
|
|
664
701
|
var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
|
|
665
702
|
/**
|
|
@@ -676,7 +713,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
|
|
|
676
713
|
* is converted to `-ms-`.
|
|
677
714
|
*/
|
|
678
715
|
function hyphenateStyleName(string) {
|
|
679
|
-
return uppercaseCheck.test(string)
|
|
716
|
+
return uppercaseCheck.test(string) && !string.startsWith('--')
|
|
680
717
|
? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
|
|
681
718
|
: string;
|
|
682
719
|
}
|
|
@@ -732,21 +769,18 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
732
769
|
var ruleSet = [];
|
|
733
770
|
for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
|
|
734
771
|
result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
|
|
735
|
-
if (result ===
|
|
772
|
+
if (result.length === 0)
|
|
736
773
|
continue;
|
|
737
|
-
|
|
738
|
-
ruleSet.push.apply(ruleSet, result);
|
|
739
|
-
else
|
|
740
|
-
ruleSet.push(result);
|
|
774
|
+
ruleSet.push.apply(ruleSet, result);
|
|
741
775
|
}
|
|
742
776
|
return ruleSet;
|
|
743
777
|
}
|
|
744
778
|
if (isFalsish(chunk)) {
|
|
745
|
-
return
|
|
779
|
+
return [];
|
|
746
780
|
}
|
|
747
781
|
/* Handle other components */
|
|
748
782
|
if (isStyledComponent(chunk)) {
|
|
749
|
-
return ".".concat(chunk.styledComponentId);
|
|
783
|
+
return [".".concat(chunk.styledComponentId)];
|
|
750
784
|
}
|
|
751
785
|
/* Either execute or defer the function */
|
|
752
786
|
if (isFunction(chunk)) {
|
|
@@ -757,27 +791,27 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
|
|
|
757
791
|
typeof result === 'object' &&
|
|
758
792
|
!Array.isArray(result) &&
|
|
759
793
|
!(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."));
|
|
794
|
+
!isPlainObject(result) &&
|
|
795
|
+
result !== null) {
|
|
796
|
+
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
797
|
}
|
|
766
798
|
return flatten(result, executionContext, styleSheet, stylisInstance);
|
|
767
799
|
}
|
|
768
|
-
else
|
|
769
|
-
return chunk;
|
|
800
|
+
else {
|
|
801
|
+
return [chunk];
|
|
802
|
+
}
|
|
770
803
|
}
|
|
771
804
|
if (chunk instanceof Keyframes) {
|
|
772
805
|
if (styleSheet) {
|
|
773
806
|
chunk.inject(styleSheet, stylisInstance);
|
|
774
|
-
return chunk.getName(stylisInstance);
|
|
807
|
+
return [chunk.getName(stylisInstance)];
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
return [chunk];
|
|
775
811
|
}
|
|
776
|
-
else
|
|
777
|
-
return chunk;
|
|
778
812
|
}
|
|
779
813
|
/* Handle objects */
|
|
780
|
-
return isPlainObject(chunk) ? objToCssArray(chunk) : chunk.toString();
|
|
814
|
+
return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
|
|
781
815
|
}
|
|
782
816
|
|
|
783
817
|
function interleave(strings, interpolations) {
|
|
@@ -793,11 +827,7 @@ function interleave(strings, interpolations) {
|
|
|
793
827
|
* expand an array of styles.
|
|
794
828
|
*/
|
|
795
829
|
var addTag = function (arg) {
|
|
796
|
-
|
|
797
|
-
// eslint-disable-next-line no-param-reassign
|
|
798
|
-
arg.isCss = true;
|
|
799
|
-
}
|
|
800
|
-
return arg;
|
|
830
|
+
return Object.assign(arg, { isCss: true });
|
|
801
831
|
};
|
|
802
832
|
function css(styles) {
|
|
803
833
|
var interpolations = [];
|
|
@@ -814,7 +844,7 @@ function css(styles) {
|
|
|
814
844
|
if (interpolations.length === 0 &&
|
|
815
845
|
styleStringArray.length === 1 &&
|
|
816
846
|
typeof styleStringArray[0] === 'string') {
|
|
817
|
-
return styleStringArray;
|
|
847
|
+
return flatten(styleStringArray);
|
|
818
848
|
}
|
|
819
849
|
return addTag(flatten(interleave(styleStringArray, interpolations)));
|
|
820
850
|
}
|
|
@@ -995,7 +1025,6 @@ function withTheme(Component) {
|
|
|
995
1025
|
var theme = React.useContext(ThemeContext);
|
|
996
1026
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
997
1027
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
998
|
-
// eslint-disable-next-line no-console
|
|
999
1028
|
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
1029
|
}
|
|
1001
1030
|
return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
|
|
@@ -1048,7 +1077,6 @@ function makeInlineStyleClass(styleSheet) {
|
|
|
1048
1077
|
declPairs_1.push([node.prop, node.value]);
|
|
1049
1078
|
}
|
|
1050
1079
|
else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {
|
|
1051
|
-
/* eslint-disable no-console */
|
|
1052
1080
|
console.warn("Node of type ".concat(node.type, " not supported as an inline style"));
|
|
1053
1081
|
}
|
|
1054
1082
|
});
|
|
@@ -1101,7 +1129,6 @@ function mixinRecursively(target, source, forceMerge) {
|
|
|
1101
1129
|
* Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
|
|
1102
1130
|
*/
|
|
1103
1131
|
function mixinDeep(target) {
|
|
1104
|
-
if (target === void 0) { target = {}; }
|
|
1105
1132
|
var sources = [];
|
|
1106
1133
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1107
1134
|
sources[_i - 1] = arguments[_i];
|
|
@@ -1121,20 +1148,15 @@ function useResolvedAttrs(theme, props, attrs) {
|
|
|
1121
1148
|
var context = __assign(__assign({}, props), { theme: theme });
|
|
1122
1149
|
var resolvedAttrs = {};
|
|
1123
1150
|
attrs.forEach(function (attrDef) {
|
|
1124
|
-
// @ts-expect-error narrowing isn't working properly for some reason
|
|
1125
1151
|
var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
|
|
1126
1152
|
var key;
|
|
1127
|
-
/* eslint-disable guard-for-in */
|
|
1128
1153
|
for (key in resolvedAttrDef) {
|
|
1129
1154
|
// @ts-expect-error bad types
|
|
1130
1155
|
context[key] = resolvedAttrs[key] = resolvedAttrDef[key];
|
|
1131
1156
|
}
|
|
1132
|
-
/* eslint-enable guard-for-in */
|
|
1133
1157
|
});
|
|
1134
1158
|
return [context, resolvedAttrs];
|
|
1135
1159
|
}
|
|
1136
|
-
// Validator defaults to true if not in HTML/DOM env
|
|
1137
|
-
var validAttr = function () { return true; };
|
|
1138
1160
|
function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
1139
1161
|
var componentAttrs = forwardedComponent.attrs, inlineStyle = forwardedComponent.inlineStyle, defaultProps = forwardedComponent.defaultProps, shouldForwardProp = forwardedComponent.shouldForwardProp, target = forwardedComponent.target;
|
|
1140
1162
|
// NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
@@ -1144,32 +1166,25 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1144
1166
|
var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
|
|
1145
1167
|
var generatedStyles = inlineStyle.generateStyleObject(context);
|
|
1146
1168
|
var refToForward = forwardedRef;
|
|
1147
|
-
var elementToBeCreated = attrs
|
|
1169
|
+
var elementToBeCreated = attrs.as || props.as || target;
|
|
1148
1170
|
var computedProps = attrs !== props ? __assign(__assign({}, props), attrs) : props;
|
|
1149
1171
|
var propsForElement = {};
|
|
1150
|
-
// eslint-disable-next-line guard-for-in
|
|
1151
1172
|
for (var key in computedProps) {
|
|
1152
1173
|
if (key[0] === '$' || key === 'as')
|
|
1153
1174
|
continue;
|
|
1154
1175
|
else if (key === 'forwardedAs') {
|
|
1155
1176
|
propsForElement.as = computedProps[key];
|
|
1156
1177
|
}
|
|
1157
|
-
else if (!shouldForwardProp || shouldForwardProp(key,
|
|
1178
|
+
else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
|
|
1158
1179
|
propsForElement[key] = computedProps[key];
|
|
1159
1180
|
}
|
|
1160
1181
|
}
|
|
1161
1182
|
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
|
-
}
|
|
1183
|
+
return typeof props.style === 'function'
|
|
1184
|
+
? function (state) { return [generatedStyles].concat(props.style(state)); }
|
|
1185
|
+
: props.style
|
|
1186
|
+
? [generatedStyles].concat(props.style)
|
|
1187
|
+
: generatedStyles;
|
|
1173
1188
|
}, [props.style, generatedStyles]);
|
|
1174
1189
|
propsForElement.ref = refToForward;
|
|
1175
1190
|
return createElement(elementToBeCreated, propsForElement);
|
|
@@ -1183,25 +1198,22 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1183
1198
|
var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
|
|
1184
1199
|
? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
|
|
1185
1200
|
: attrs;
|
|
1186
|
-
// eslint-disable-next-line prefer-destructuring
|
|
1187
1201
|
var shouldForwardProp = options.shouldForwardProp;
|
|
1188
1202
|
if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
|
|
1189
1203
|
var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
|
|
1190
1204
|
if (options.shouldForwardProp) {
|
|
1191
1205
|
var passedShouldForwardPropFn_1 = options.shouldForwardProp;
|
|
1192
1206
|
// compose nested shouldForwardProp calls
|
|
1193
|
-
shouldForwardProp = function (prop,
|
|
1194
|
-
return shouldForwardPropFn_1(prop,
|
|
1195
|
-
passedShouldForwardPropFn_1(prop,
|
|
1207
|
+
shouldForwardProp = function (prop, elementToBeCreated) {
|
|
1208
|
+
return shouldForwardPropFn_1(prop, elementToBeCreated) &&
|
|
1209
|
+
passedShouldForwardPropFn_1(prop, elementToBeCreated);
|
|
1196
1210
|
};
|
|
1197
1211
|
}
|
|
1198
1212
|
else {
|
|
1199
|
-
// eslint-disable-next-line prefer-destructuring
|
|
1200
1213
|
shouldForwardProp = shouldForwardPropFn_1;
|
|
1201
1214
|
}
|
|
1202
1215
|
}
|
|
1203
1216
|
var forwardRef = function (props, ref) {
|
|
1204
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1205
1217
|
return useStyledComponentImpl(WrappedStyledComponent, props, ref);
|
|
1206
1218
|
};
|
|
1207
1219
|
forwardRef.displayName = displayName;
|
|
@@ -1218,10 +1230,6 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1218
1230
|
WrappedStyledComponent.styledComponentId = true;
|
|
1219
1231
|
// fold the underlying StyledComponent target up since we folded the styles
|
|
1220
1232
|
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
1233
|
Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
|
|
1226
1234
|
get: function () {
|
|
1227
1235
|
return this._foldedDefaultProps;
|
|
@@ -1239,14 +1247,12 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
1239
1247
|
displayName: true,
|
|
1240
1248
|
shouldForwardProp: true,
|
|
1241
1249
|
target: true,
|
|
1242
|
-
withComponent: true,
|
|
1243
1250
|
});
|
|
1244
1251
|
return WrappedStyledComponent;
|
|
1245
1252
|
};
|
|
1246
1253
|
return createStyledNativeComponent;
|
|
1247
1254
|
});
|
|
1248
1255
|
|
|
1249
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1250
1256
|
var reactNative = require('react-native');
|
|
1251
1257
|
var InlineStyle = makeInlineStyleClass(reactNative.StyleSheet);
|
|
1252
1258
|
var StyledNativeComponent = _StyledNativeComponent(InlineStyle);
|
|
@@ -1297,5 +1303,5 @@ aliases.forEach(function (alias) {
|
|
|
1297
1303
|
});
|
|
1298
1304
|
});
|
|
1299
1305
|
|
|
1300
|
-
export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, useTheme, withTheme };
|
|
1306
|
+
export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, styled, useTheme, withTheme };
|
|
1301
1307
|
//# sourceMappingURL=styled-components.native.esm.js.map
|