styled-components 6.0.0-beta.7 → 6.0.0-beta.8
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/models/ThemeProvider.d.ts +1 -1
- package/dist/styled-components-macro.cjs.js +7 -2
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +28 -22
- 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 +27 -21
- 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 +22 -18
- 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/tsconfig.tsbuildinfo +1 -1
- package/native/dist/models/ThemeProvider.d.ts +1 -1
- package/native/dist/styled-components.native.cjs.js +18 -12
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +1 -1
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@ export interface DefaultTheme {
|
|
|
27
27
|
declare type ThemeFn = (outerTheme?: DefaultTheme) => DefaultTheme;
|
|
28
28
|
declare type ThemeArgument = DefaultTheme | ThemeFn;
|
|
29
29
|
declare type Props = {
|
|
30
|
-
children?: React.
|
|
30
|
+
children?: React.ReactNode;
|
|
31
31
|
theme: ThemeArgument;
|
|
32
32
|
};
|
|
33
33
|
export declare const ThemeContext: React.Context<DefaultTheme | undefined>;
|
|
@@ -8,6 +8,11 @@ var traverse = require('@babel/traverse');
|
|
|
8
8
|
var babelPluginMacros = require('babel-plugin-macros');
|
|
9
9
|
var babelPlugin = require('babel-plugin-styled-components');
|
|
10
10
|
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var traverse__default = /*#__PURE__*/_interopDefaultLegacy(traverse);
|
|
14
|
+
var babelPlugin__default = /*#__PURE__*/_interopDefaultLegacy(babelPlugin);
|
|
15
|
+
|
|
11
16
|
function styledComponentsMacro(_a) {
|
|
12
17
|
var references = _a.references, state = _a.state, t = _a.babel.types, _b = _a.config, _c = _b === void 0 ? {} : _b, _d = _c.importModuleName, importModuleName = _d === void 0 ? 'styled-components' : _d, config = tslib.__rest(_c, ["importModuleName"]);
|
|
13
18
|
var program = state.file.path;
|
|
@@ -33,11 +38,11 @@ function styledComponentsMacro(_a) {
|
|
|
33
38
|
});
|
|
34
39
|
// SECOND STEP : apply babel-plugin-styled-components to the file
|
|
35
40
|
var stateWithOpts = tslib.__assign(tslib.__assign({}, state), { opts: tslib.__assign(tslib.__assign({}, config), { topLevelImportPaths: (config.topLevelImportPaths || []).concat(importModuleName) }), customImportName: customImportName });
|
|
36
|
-
|
|
41
|
+
traverse__default["default"](program.parent, babelPlugin__default["default"]({ types: t }).visitor, undefined, stateWithOpts);
|
|
37
42
|
}
|
|
38
43
|
var index = babelPluginMacros.createMacro(styledComponentsMacro, {
|
|
39
44
|
configName: 'styledComponents',
|
|
40
45
|
});
|
|
41
46
|
|
|
42
|
-
exports
|
|
47
|
+
exports["default"] = index;
|
|
43
48
|
//# sourceMappingURL=styled-components-macro.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled-components-macro.cjs.js","sources":["../src/macro/index.ts"],"sourcesContent":["import { types } from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport traverse from '@babel/traverse';\nimport { createMacro, MacroParams } from 'babel-plugin-macros';\nimport babelPlugin from 'babel-plugin-styled-components';\n\nfunction styledComponentsMacro({\n references,\n state,\n babel: { types: t },\n config: { importModuleName = 'styled-components', ...config } = {},\n}: MacroParams) {\n const program = state.file.path;\n\n // FIRST STEP : replace `styled-components/macro` by `styled-components\n // references looks like this\n // { default: [path, path], css: [path], ... }\n let customImportName;\n Object.keys(references).forEach(refName => {\n // generate new identifier\n let id: types.Identifier;\n if (refName === 'default') {\n id = addDefault(program, importModuleName, { nameHint: 'styled' });\n customImportName = id;\n } else {\n id = addNamed(program, refName, importModuleName, { nameHint: refName });\n }\n\n // update references with the new identifiers\n references[refName].forEach(referencePath => {\n // eslint-disable-next-line no-param-reassign\n (referencePath.node as types.Identifier).name = id.name;\n });\n });\n\n // SECOND STEP : apply babel-plugin-styled-components to the file\n const stateWithOpts = {\n ...state,\n opts: {\n ...config,\n topLevelImportPaths: (config.topLevelImportPaths || []).concat(importModuleName),\n },\n customImportName,\n };\n traverse(program.parent, babelPlugin({ types: t }).visitor, undefined, stateWithOpts);\n}\n\nexport default createMacro(styledComponentsMacro, {\n configName: 'styledComponents',\n});\n"],"names":["__rest","addDefault","addNamed","__assign","createMacro"],"mappings":"
|
|
1
|
+
{"version":3,"file":"styled-components-macro.cjs.js","sources":["../src/macro/index.ts"],"sourcesContent":["import { types } from '@babel/core';\nimport { addDefault, addNamed } from '@babel/helper-module-imports';\nimport traverse from '@babel/traverse';\nimport { createMacro, MacroParams } from 'babel-plugin-macros';\nimport babelPlugin from 'babel-plugin-styled-components';\n\nfunction styledComponentsMacro({\n references,\n state,\n babel: { types: t },\n config: { importModuleName = 'styled-components', ...config } = {},\n}: MacroParams) {\n const program = state.file.path;\n\n // FIRST STEP : replace `styled-components/macro` by `styled-components\n // references looks like this\n // { default: [path, path], css: [path], ... }\n let customImportName;\n Object.keys(references).forEach(refName => {\n // generate new identifier\n let id: types.Identifier;\n if (refName === 'default') {\n id = addDefault(program, importModuleName, { nameHint: 'styled' });\n customImportName = id;\n } else {\n id = addNamed(program, refName, importModuleName, { nameHint: refName });\n }\n\n // update references with the new identifiers\n references[refName].forEach(referencePath => {\n // eslint-disable-next-line no-param-reassign\n (referencePath.node as types.Identifier).name = id.name;\n });\n });\n\n // SECOND STEP : apply babel-plugin-styled-components to the file\n const stateWithOpts = {\n ...state,\n opts: {\n ...config,\n topLevelImportPaths: (config.topLevelImportPaths || []).concat(importModuleName),\n },\n customImportName,\n };\n traverse(program.parent, babelPlugin({ types: t }).visitor, undefined, stateWithOpts);\n}\n\nexport default createMacro(styledComponentsMacro, {\n configName: 'styledComponents',\n});\n"],"names":["__rest","addDefault","addNamed","__assign","traverse","babelPlugin","createMacro"],"mappings":";;;;;;;;;;;;;;;AAMA,SAAS,qBAAqB,CAAC,EAKjB,EAAA;IAJZ,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,KAAK,GAAA,EAAA,CAAA,KAAA,EACW,CAAC,GAAA,EAAA,CAAA,KAAA,CAAA,KAAA,EACjB,EAAA,GAAA,EAAA,CAAA,MAAkE,EAAlE,EAAA,GAAA,EAAA,KAAA,KAAA,CAAA,GAAgE,EAAE,GAAA,EAAA,EAAxD,EAAsC,GAAA,EAAA,CAAA,gBAAA,EAAtC,gBAAgB,GAAA,EAAA,KAAA,KAAA,CAAA,GAAG,mBAAmB,GAAA,EAAA,EAAK,MAAM,GAAnDA,YAAA,CAAA,EAAA,EAAA,CAAA,kBAAA,CAAqD,CAAK,CAAA;AAElE,IAAA,IAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;;;AAKhC,IAAA,IAAI,gBAAgB,CAAC;IACrB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAA,OAAO,EAAA;;AAErC,QAAA,IAAI,EAAoB,CAAC;QACzB,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,YAAA,EAAE,GAAGC,8BAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YACnE,gBAAgB,GAAG,EAAE,CAAC;AACvB,SAAA;AAAM,aAAA;AACL,YAAA,EAAE,GAAGC,4BAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,SAAA;;AAGD,QAAA,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAA,aAAa,EAAA;;YAEtC,aAAa,CAAC,IAAyB,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;AAC1D,SAAC,CAAC,CAAC;AACL,KAAC,CAAC,CAAC;;IAGH,IAAM,aAAa,GACdC,cAAA,CAAAA,cAAA,CAAA,EAAA,EAAA,KAAK,CACR,EAAA,EAAA,IAAI,EACCA,cAAA,CAAAA,cAAA,CAAA,EAAA,EAAA,MAAM,CACT,EAAA,EAAA,mBAAmB,EAAE,CAAC,MAAM,CAAC,mBAAmB,IAAI,EAAE,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAElF,CAAA,EAAA,gBAAgB,EAAA,gBAAA,EAAA,CACjB,CAAC;IACFC,4BAAQ,CAAC,OAAO,CAAC,MAAM,EAAEC,+BAAW,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AACxF,CAAC;AAED,YAAeC,6BAAW,CAAC,qBAAqB,EAAE;AAChD,IAAA,UAAU,EAAE,kBAAkB;AAC/B,CAAA,CAAC;;;;"}
|
|
@@ -8,11 +8,17 @@ var shallowequal = require('shallowequal');
|
|
|
8
8
|
var stylis = require('stylis');
|
|
9
9
|
var unitless = require('@emotion/unitless');
|
|
10
10
|
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
+
var shallowequal__default = /*#__PURE__*/_interopDefaultLegacy(shallowequal);
|
|
15
|
+
var unitless__default = /*#__PURE__*/_interopDefaultLegacy(unitless);
|
|
16
|
+
|
|
11
17
|
var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
12
18
|
'data-styled';
|
|
13
19
|
var SC_ATTR_ACTIVE = 'active';
|
|
14
20
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
15
|
-
var SC_VERSION = "6.0.0-beta.
|
|
21
|
+
var SC_VERSION = "6.0.0-beta.8";
|
|
16
22
|
var SPLITTER = '/*!sc*/\n';
|
|
17
23
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
18
24
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -1061,9 +1067,9 @@ function createStylisInstance(_a) {
|
|
|
1061
1067
|
return stringifyRules;
|
|
1062
1068
|
}
|
|
1063
1069
|
|
|
1064
|
-
var StyleSheetContext =
|
|
1070
|
+
var StyleSheetContext = React__default["default"].createContext(undefined);
|
|
1065
1071
|
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1066
|
-
var StylisContext =
|
|
1072
|
+
var StylisContext = React__default["default"].createContext(undefined);
|
|
1067
1073
|
StylisContext.Consumer;
|
|
1068
1074
|
var mainSheet = new StyleSheet();
|
|
1069
1075
|
var mainStylis = createStylisInstance();
|
|
@@ -1097,12 +1103,12 @@ function StyleSheetManager(props) {
|
|
|
1097
1103
|
});
|
|
1098
1104
|
}, [props.disableVendorPrefixes, props.namespace, plugins]);
|
|
1099
1105
|
React.useEffect(function () {
|
|
1100
|
-
if (!
|
|
1106
|
+
if (!shallowequal__default["default"](plugins, props.stylisPlugins))
|
|
1101
1107
|
setPlugins(props.stylisPlugins);
|
|
1102
1108
|
}, [props.stylisPlugins]);
|
|
1103
|
-
return (
|
|
1104
|
-
|
|
1105
|
-
?
|
|
1109
|
+
return (React__default["default"].createElement(StyleSheetContext.Provider, { value: styleSheet },
|
|
1110
|
+
React__default["default"].createElement(StylisContext.Provider, { value: stylis }, process.env.NODE_ENV !== 'production'
|
|
1111
|
+
? React__default["default"].Children.only(props.children)
|
|
1106
1112
|
: props.children)));
|
|
1107
1113
|
}
|
|
1108
1114
|
|
|
@@ -1136,7 +1142,7 @@ function addUnitIfNeeded(name, value) {
|
|
|
1136
1142
|
if (value == null || typeof value === 'boolean' || value === '') {
|
|
1137
1143
|
return '';
|
|
1138
1144
|
}
|
|
1139
|
-
if (typeof value === 'number' && value !== 0 && !(name in
|
|
1145
|
+
if (typeof value === 'number' && value !== 0 && !(name in unitless__default["default"])) {
|
|
1140
1146
|
return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
|
|
1141
1147
|
}
|
|
1142
1148
|
return String(value).trim();
|
|
@@ -1343,7 +1349,7 @@ var ComponentStyle = /** @class */ (function () {
|
|
|
1343
1349
|
return ComponentStyle;
|
|
1344
1350
|
}());
|
|
1345
1351
|
|
|
1346
|
-
var ThemeContext =
|
|
1352
|
+
var ThemeContext = React__default["default"].createContext(undefined);
|
|
1347
1353
|
var ThemeConsumer = ThemeContext.Consumer;
|
|
1348
1354
|
function mergeTheme(theme, outerTheme) {
|
|
1349
1355
|
if (!theme) {
|
|
@@ -1372,7 +1378,7 @@ function ThemeProvider(props) {
|
|
|
1372
1378
|
if (!props.children) {
|
|
1373
1379
|
return null;
|
|
1374
1380
|
}
|
|
1375
|
-
return
|
|
1381
|
+
return React__default["default"].createElement(ThemeContext.Provider, { value: themeContext }, props.children);
|
|
1376
1382
|
}
|
|
1377
1383
|
|
|
1378
1384
|
var identifiers = {};
|
|
@@ -1494,7 +1500,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
1494
1500
|
* forwardRef creates a new interim component, which we'll take advantage of
|
|
1495
1501
|
* instead of extending ParentComponent to create _another_ interim class
|
|
1496
1502
|
*/
|
|
1497
|
-
var WrappedStyledComponent =
|
|
1503
|
+
var WrappedStyledComponent = React__default["default"].forwardRef(forwardRef);
|
|
1498
1504
|
WrappedStyledComponent.attrs = finalAttrs;
|
|
1499
1505
|
WrappedStyledComponent.componentStyle = componentStyle;
|
|
1500
1506
|
WrappedStyledComponent.displayName = displayName;
|
|
@@ -1655,10 +1661,10 @@ function createGlobalStyle(strings) {
|
|
|
1655
1661
|
var GlobalStyleComponent = function (props) {
|
|
1656
1662
|
var styleSheet = useStyleSheet();
|
|
1657
1663
|
var stylis = useStylis();
|
|
1658
|
-
var theme =
|
|
1659
|
-
var instanceRef =
|
|
1664
|
+
var theme = React__default["default"].useContext(ThemeContext);
|
|
1665
|
+
var instanceRef = React__default["default"].useRef(styleSheet.allocateGSInstance(styledComponentId));
|
|
1660
1666
|
var instance = instanceRef.current;
|
|
1661
|
-
if (process.env.NODE_ENV !== 'production' &&
|
|
1667
|
+
if (process.env.NODE_ENV !== 'production' && React__default["default"].Children.count(props.children)) {
|
|
1662
1668
|
// eslint-disable-next-line no-console
|
|
1663
1669
|
console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
|
|
1664
1670
|
}
|
|
@@ -1673,7 +1679,7 @@ function createGlobalStyle(strings) {
|
|
|
1673
1679
|
{
|
|
1674
1680
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1675
1681
|
// @ts-expect-error still using React 17 types for the time being
|
|
1676
|
-
(
|
|
1682
|
+
(React__default["default"].useInsertionEffect || React__default["default"].useLayoutEffect)(function () {
|
|
1677
1683
|
if (!styleSheet.server) {
|
|
1678
1684
|
renderStyles(instance, props, styleSheet, theme, stylis);
|
|
1679
1685
|
return function () { return globalStyle.removeStyles(instance, styleSheet); };
|
|
@@ -1691,7 +1697,7 @@ function createGlobalStyle(strings) {
|
|
|
1691
1697
|
globalStyle.renderStyles(instance, context, styleSheet, stylis);
|
|
1692
1698
|
}
|
|
1693
1699
|
}
|
|
1694
|
-
return
|
|
1700
|
+
return React__default["default"].memo(GlobalStyleComponent);
|
|
1695
1701
|
}
|
|
1696
1702
|
|
|
1697
1703
|
function keyframes(strings) {
|
|
@@ -1712,14 +1718,14 @@ function keyframes(strings) {
|
|
|
1712
1718
|
}
|
|
1713
1719
|
|
|
1714
1720
|
function withTheme(Component) {
|
|
1715
|
-
var WithTheme =
|
|
1716
|
-
var theme =
|
|
1721
|
+
var WithTheme = React__default["default"].forwardRef(function (props, ref) {
|
|
1722
|
+
var theme = React__default["default"].useContext(ThemeContext);
|
|
1717
1723
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
1718
1724
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
1719
1725
|
// eslint-disable-next-line no-console
|
|
1720
1726
|
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), "\""));
|
|
1721
1727
|
}
|
|
1722
|
-
return
|
|
1728
|
+
return React__default["default"].createElement(Component, tslib.__assign({}, props, { theme: themeProp, ref: ref }));
|
|
1723
1729
|
});
|
|
1724
1730
|
WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
|
|
1725
1731
|
return hoistNonReactStatics(WithTheme, Component);
|
|
@@ -1764,7 +1770,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1764
1770
|
props.nonce = nonce;
|
|
1765
1771
|
}
|
|
1766
1772
|
// v4 returned an array for this fn, so we'll do the same for v5 for backward compat
|
|
1767
|
-
return [
|
|
1773
|
+
return [React__default["default"].createElement("style", tslib.__assign({}, props, { key: "sc-0-0" }))];
|
|
1768
1774
|
};
|
|
1769
1775
|
this.seal = function () {
|
|
1770
1776
|
_this.sealed = true;
|
|
@@ -1776,7 +1782,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1776
1782
|
if (this.sealed) {
|
|
1777
1783
|
throw throwStyledComponentsError(2);
|
|
1778
1784
|
}
|
|
1779
|
-
return
|
|
1785
|
+
return React__default["default"].createElement(StyleSheetManager, { sheet: this.instance }, children);
|
|
1780
1786
|
};
|
|
1781
1787
|
// eslint-disable-next-line consistent-return
|
|
1782
1788
|
// @ts-expect-error alternate return types are not possible due to code transformation
|
|
@@ -1829,7 +1835,7 @@ exports.ThemeProvider = ThemeProvider;
|
|
|
1829
1835
|
exports.__PRIVATE__ = __PRIVATE__;
|
|
1830
1836
|
exports.createGlobalStyle = createGlobalStyle;
|
|
1831
1837
|
exports.css = css;
|
|
1832
|
-
exports
|
|
1838
|
+
exports["default"] = styled;
|
|
1833
1839
|
exports.isStyledComponent = isStyledComponent;
|
|
1834
1840
|
exports.keyframes = keyframes;
|
|
1835
1841
|
exports.styled = styled;
|