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