styled-components 6.0.0-beta.7 → 6.0.0-beta.9
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 +9 -6
- package/dist/constructors/styled.d.ts +176 -176
- package/dist/models/ThemeProvider.d.ts +1 -1
- package/dist/native/index.d.ts +25 -25
- package/dist/styled-components-macro.cjs.js +6 -1
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +28 -21
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +2 -1
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +27 -20
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +2 -1
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +2 -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 +176 -176
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/utils/domElements.d.ts +1 -1
- package/native/dist/constructors/constructWithOptions.d.ts +9 -6
- package/native/dist/constructors/styled.d.ts +176 -176
- package/native/dist/models/ThemeProvider.d.ts +1 -1
- package/native/dist/native/index.d.ts +25 -25
- package/native/dist/styled-components.native.cjs.js +17 -11
- 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/native/dist/test/utils.d.ts +176 -176
- package/native/dist/types.d.ts +4 -4
- package/native/dist/utils/domElements.d.ts +1 -1
- package/package.json +17 -4
|
@@ -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,yBAAQ,CAAC,OAAO,CAAC,MAAM,EAAEC,4BAAW,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 _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
|
+
var shallowequal__default = /*#__PURE__*/_interopDefault(shallowequal);
|
|
15
|
+
var unitless__default = /*#__PURE__*/_interopDefault(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.9";
|
|
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'
|
|
@@ -234,6 +240,7 @@ var domElements = [
|
|
|
234
240
|
'track',
|
|
235
241
|
'u',
|
|
236
242
|
'ul',
|
|
243
|
+
'use',
|
|
237
244
|
'var',
|
|
238
245
|
'video',
|
|
239
246
|
'wbr',
|
|
@@ -1061,9 +1068,9 @@ function createStylisInstance(_a) {
|
|
|
1061
1068
|
return stringifyRules;
|
|
1062
1069
|
}
|
|
1063
1070
|
|
|
1064
|
-
var StyleSheetContext =
|
|
1071
|
+
var StyleSheetContext = React__default.default.createContext(undefined);
|
|
1065
1072
|
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1066
|
-
var StylisContext =
|
|
1073
|
+
var StylisContext = React__default.default.createContext(undefined);
|
|
1067
1074
|
StylisContext.Consumer;
|
|
1068
1075
|
var mainSheet = new StyleSheet();
|
|
1069
1076
|
var mainStylis = createStylisInstance();
|
|
@@ -1097,12 +1104,12 @@ function StyleSheetManager(props) {
|
|
|
1097
1104
|
});
|
|
1098
1105
|
}, [props.disableVendorPrefixes, props.namespace, plugins]);
|
|
1099
1106
|
React.useEffect(function () {
|
|
1100
|
-
if (!
|
|
1107
|
+
if (!shallowequal__default.default(plugins, props.stylisPlugins))
|
|
1101
1108
|
setPlugins(props.stylisPlugins);
|
|
1102
1109
|
}, [props.stylisPlugins]);
|
|
1103
|
-
return (
|
|
1104
|
-
|
|
1105
|
-
?
|
|
1110
|
+
return (React__default.default.createElement(StyleSheetContext.Provider, { value: styleSheet },
|
|
1111
|
+
React__default.default.createElement(StylisContext.Provider, { value: stylis }, process.env.NODE_ENV !== 'production'
|
|
1112
|
+
? React__default.default.Children.only(props.children)
|
|
1106
1113
|
: props.children)));
|
|
1107
1114
|
}
|
|
1108
1115
|
|
|
@@ -1136,7 +1143,7 @@ function addUnitIfNeeded(name, value) {
|
|
|
1136
1143
|
if (value == null || typeof value === 'boolean' || value === '') {
|
|
1137
1144
|
return '';
|
|
1138
1145
|
}
|
|
1139
|
-
if (typeof value === 'number' && value !== 0 && !(name in
|
|
1146
|
+
if (typeof value === 'number' && value !== 0 && !(name in unitless__default.default)) {
|
|
1140
1147
|
return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
|
|
1141
1148
|
}
|
|
1142
1149
|
return String(value).trim();
|
|
@@ -1343,7 +1350,7 @@ var ComponentStyle = /** @class */ (function () {
|
|
|
1343
1350
|
return ComponentStyle;
|
|
1344
1351
|
}());
|
|
1345
1352
|
|
|
1346
|
-
var ThemeContext =
|
|
1353
|
+
var ThemeContext = React__default.default.createContext(undefined);
|
|
1347
1354
|
var ThemeConsumer = ThemeContext.Consumer;
|
|
1348
1355
|
function mergeTheme(theme, outerTheme) {
|
|
1349
1356
|
if (!theme) {
|
|
@@ -1372,7 +1379,7 @@ function ThemeProvider(props) {
|
|
|
1372
1379
|
if (!props.children) {
|
|
1373
1380
|
return null;
|
|
1374
1381
|
}
|
|
1375
|
-
return
|
|
1382
|
+
return React__default.default.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
|
|
1376
1383
|
}
|
|
1377
1384
|
|
|
1378
1385
|
var identifiers = {};
|
|
@@ -1494,7 +1501,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
1494
1501
|
* forwardRef creates a new interim component, which we'll take advantage of
|
|
1495
1502
|
* instead of extending ParentComponent to create _another_ interim class
|
|
1496
1503
|
*/
|
|
1497
|
-
var WrappedStyledComponent =
|
|
1504
|
+
var WrappedStyledComponent = React__default.default.forwardRef(forwardRef);
|
|
1498
1505
|
WrappedStyledComponent.attrs = finalAttrs;
|
|
1499
1506
|
WrappedStyledComponent.componentStyle = componentStyle;
|
|
1500
1507
|
WrappedStyledComponent.displayName = displayName;
|
|
@@ -1655,10 +1662,10 @@ function createGlobalStyle(strings) {
|
|
|
1655
1662
|
var GlobalStyleComponent = function (props) {
|
|
1656
1663
|
var styleSheet = useStyleSheet();
|
|
1657
1664
|
var stylis = useStylis();
|
|
1658
|
-
var theme =
|
|
1659
|
-
var instanceRef =
|
|
1665
|
+
var theme = React__default.default.useContext(ThemeContext);
|
|
1666
|
+
var instanceRef = React__default.default.useRef(styleSheet.allocateGSInstance(styledComponentId));
|
|
1660
1667
|
var instance = instanceRef.current;
|
|
1661
|
-
if (process.env.NODE_ENV !== 'production' &&
|
|
1668
|
+
if (process.env.NODE_ENV !== 'production' && React__default.default.Children.count(props.children)) {
|
|
1662
1669
|
// eslint-disable-next-line no-console
|
|
1663
1670
|
console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
|
|
1664
1671
|
}
|
|
@@ -1673,7 +1680,7 @@ function createGlobalStyle(strings) {
|
|
|
1673
1680
|
{
|
|
1674
1681
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1675
1682
|
// @ts-expect-error still using React 17 types for the time being
|
|
1676
|
-
(
|
|
1683
|
+
(React__default.default.useInsertionEffect || React__default.default.useLayoutEffect)(function () {
|
|
1677
1684
|
if (!styleSheet.server) {
|
|
1678
1685
|
renderStyles(instance, props, styleSheet, theme, stylis);
|
|
1679
1686
|
return function () { return globalStyle.removeStyles(instance, styleSheet); };
|
|
@@ -1691,7 +1698,7 @@ function createGlobalStyle(strings) {
|
|
|
1691
1698
|
globalStyle.renderStyles(instance, context, styleSheet, stylis);
|
|
1692
1699
|
}
|
|
1693
1700
|
}
|
|
1694
|
-
return
|
|
1701
|
+
return React__default.default.memo(GlobalStyleComponent);
|
|
1695
1702
|
}
|
|
1696
1703
|
|
|
1697
1704
|
function keyframes(strings) {
|
|
@@ -1712,14 +1719,14 @@ function keyframes(strings) {
|
|
|
1712
1719
|
}
|
|
1713
1720
|
|
|
1714
1721
|
function withTheme(Component) {
|
|
1715
|
-
var WithTheme =
|
|
1716
|
-
var theme =
|
|
1722
|
+
var WithTheme = React__default.default.forwardRef(function (props, ref) {
|
|
1723
|
+
var theme = React__default.default.useContext(ThemeContext);
|
|
1717
1724
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
1718
1725
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
1719
1726
|
// eslint-disable-next-line no-console
|
|
1720
1727
|
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
1728
|
}
|
|
1722
|
-
return
|
|
1729
|
+
return React__default.default.createElement(Component, tslib.__assign({}, props, { theme: themeProp, ref: ref }));
|
|
1723
1730
|
});
|
|
1724
1731
|
WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
|
|
1725
1732
|
return hoistNonReactStatics(WithTheme, Component);
|
|
@@ -1764,7 +1771,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1764
1771
|
props.nonce = nonce;
|
|
1765
1772
|
}
|
|
1766
1773
|
// v4 returned an array for this fn, so we'll do the same for v5 for backward compat
|
|
1767
|
-
return [
|
|
1774
|
+
return [React__default.default.createElement("style", tslib.__assign({}, props, { key: "sc-0-0" }))];
|
|
1768
1775
|
};
|
|
1769
1776
|
this.seal = function () {
|
|
1770
1777
|
_this.sealed = true;
|
|
@@ -1776,7 +1783,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1776
1783
|
if (this.sealed) {
|
|
1777
1784
|
throw throwStyledComponentsError(2);
|
|
1778
1785
|
}
|
|
1779
|
-
return
|
|
1786
|
+
return React__default.default.createElement(StyleSheetManager, { sheet: this.instance }, children);
|
|
1780
1787
|
};
|
|
1781
1788
|
// eslint-disable-next-line consistent-return
|
|
1782
1789
|
// @ts-expect-error alternate return types are not possible due to code transformation
|