styled-components 6.0.0-beta.8 → 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/native/index.d.ts +25 -25
- package/dist/styled-components-macro.cjs.js +5 -5
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +27 -26
- 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 +26 -25
- 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 +19 -22
- 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/native/index.d.ts +25 -25
- package/native/dist/styled-components.native.cjs.js +16 -16
- 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","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,
|
|
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,I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;;;;"}
|
|
@@ -8,17 +8,17 @@ var shallowequal = require('shallowequal');
|
|
|
8
8
|
var stylis = require('stylis');
|
|
9
9
|
var unitless = require('@emotion/unitless');
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
|
-
var React__default = /*#__PURE__*/
|
|
14
|
-
var shallowequal__default = /*#__PURE__*/
|
|
15
|
-
var unitless__default = /*#__PURE__*/
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
|
+
var shallowequal__default = /*#__PURE__*/_interopDefault(shallowequal);
|
|
15
|
+
var unitless__default = /*#__PURE__*/_interopDefault(unitless);
|
|
16
16
|
|
|
17
17
|
var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
18
18
|
'data-styled';
|
|
19
19
|
var SC_ATTR_ACTIVE = 'active';
|
|
20
20
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
21
|
-
var SC_VERSION = "6.0.0-beta.
|
|
21
|
+
var SC_VERSION = "6.0.0-beta.9";
|
|
22
22
|
var SPLITTER = '/*!sc*/\n';
|
|
23
23
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
24
24
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -240,6 +240,7 @@ var domElements = [
|
|
|
240
240
|
'track',
|
|
241
241
|
'u',
|
|
242
242
|
'ul',
|
|
243
|
+
'use',
|
|
243
244
|
'var',
|
|
244
245
|
'video',
|
|
245
246
|
'wbr',
|
|
@@ -1067,9 +1068,9 @@ function createStylisInstance(_a) {
|
|
|
1067
1068
|
return stringifyRules;
|
|
1068
1069
|
}
|
|
1069
1070
|
|
|
1070
|
-
var StyleSheetContext = React__default
|
|
1071
|
+
var StyleSheetContext = React__default.default.createContext(undefined);
|
|
1071
1072
|
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1072
|
-
var StylisContext = React__default
|
|
1073
|
+
var StylisContext = React__default.default.createContext(undefined);
|
|
1073
1074
|
StylisContext.Consumer;
|
|
1074
1075
|
var mainSheet = new StyleSheet();
|
|
1075
1076
|
var mainStylis = createStylisInstance();
|
|
@@ -1103,12 +1104,12 @@ function StyleSheetManager(props) {
|
|
|
1103
1104
|
});
|
|
1104
1105
|
}, [props.disableVendorPrefixes, props.namespace, plugins]);
|
|
1105
1106
|
React.useEffect(function () {
|
|
1106
|
-
if (!shallowequal__default
|
|
1107
|
+
if (!shallowequal__default.default(plugins, props.stylisPlugins))
|
|
1107
1108
|
setPlugins(props.stylisPlugins);
|
|
1108
1109
|
}, [props.stylisPlugins]);
|
|
1109
|
-
return (React__default
|
|
1110
|
-
React__default
|
|
1111
|
-
? React__default
|
|
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)
|
|
1112
1113
|
: props.children)));
|
|
1113
1114
|
}
|
|
1114
1115
|
|
|
@@ -1142,7 +1143,7 @@ function addUnitIfNeeded(name, value) {
|
|
|
1142
1143
|
if (value == null || typeof value === 'boolean' || value === '') {
|
|
1143
1144
|
return '';
|
|
1144
1145
|
}
|
|
1145
|
-
if (typeof value === 'number' && value !== 0 && !(name in unitless__default
|
|
1146
|
+
if (typeof value === 'number' && value !== 0 && !(name in unitless__default.default)) {
|
|
1146
1147
|
return "".concat(value, "px"); // Presumes implicit 'px' suffix for unitless numbers
|
|
1147
1148
|
}
|
|
1148
1149
|
return String(value).trim();
|
|
@@ -1349,7 +1350,7 @@ var ComponentStyle = /** @class */ (function () {
|
|
|
1349
1350
|
return ComponentStyle;
|
|
1350
1351
|
}());
|
|
1351
1352
|
|
|
1352
|
-
var ThemeContext = React__default
|
|
1353
|
+
var ThemeContext = React__default.default.createContext(undefined);
|
|
1353
1354
|
var ThemeConsumer = ThemeContext.Consumer;
|
|
1354
1355
|
function mergeTheme(theme, outerTheme) {
|
|
1355
1356
|
if (!theme) {
|
|
@@ -1378,7 +1379,7 @@ function ThemeProvider(props) {
|
|
|
1378
1379
|
if (!props.children) {
|
|
1379
1380
|
return null;
|
|
1380
1381
|
}
|
|
1381
|
-
return React__default
|
|
1382
|
+
return React__default.default.createElement(ThemeContext.Provider, { value: themeContext }, props.children);
|
|
1382
1383
|
}
|
|
1383
1384
|
|
|
1384
1385
|
var identifiers = {};
|
|
@@ -1500,7 +1501,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
1500
1501
|
* forwardRef creates a new interim component, which we'll take advantage of
|
|
1501
1502
|
* instead of extending ParentComponent to create _another_ interim class
|
|
1502
1503
|
*/
|
|
1503
|
-
var WrappedStyledComponent = React__default
|
|
1504
|
+
var WrappedStyledComponent = React__default.default.forwardRef(forwardRef);
|
|
1504
1505
|
WrappedStyledComponent.attrs = finalAttrs;
|
|
1505
1506
|
WrappedStyledComponent.componentStyle = componentStyle;
|
|
1506
1507
|
WrappedStyledComponent.displayName = displayName;
|
|
@@ -1661,10 +1662,10 @@ function createGlobalStyle(strings) {
|
|
|
1661
1662
|
var GlobalStyleComponent = function (props) {
|
|
1662
1663
|
var styleSheet = useStyleSheet();
|
|
1663
1664
|
var stylis = useStylis();
|
|
1664
|
-
var theme = React__default
|
|
1665
|
-
var instanceRef = React__default
|
|
1665
|
+
var theme = React__default.default.useContext(ThemeContext);
|
|
1666
|
+
var instanceRef = React__default.default.useRef(styleSheet.allocateGSInstance(styledComponentId));
|
|
1666
1667
|
var instance = instanceRef.current;
|
|
1667
|
-
if (process.env.NODE_ENV !== 'production' && React__default
|
|
1668
|
+
if (process.env.NODE_ENV !== 'production' && React__default.default.Children.count(props.children)) {
|
|
1668
1669
|
// eslint-disable-next-line no-console
|
|
1669
1670
|
console.warn("The global style component ".concat(styledComponentId, " was given child JSX. createGlobalStyle does not render children."));
|
|
1670
1671
|
}
|
|
@@ -1679,7 +1680,7 @@ function createGlobalStyle(strings) {
|
|
|
1679
1680
|
{
|
|
1680
1681
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1681
1682
|
// @ts-expect-error still using React 17 types for the time being
|
|
1682
|
-
(React__default
|
|
1683
|
+
(React__default.default.useInsertionEffect || React__default.default.useLayoutEffect)(function () {
|
|
1683
1684
|
if (!styleSheet.server) {
|
|
1684
1685
|
renderStyles(instance, props, styleSheet, theme, stylis);
|
|
1685
1686
|
return function () { return globalStyle.removeStyles(instance, styleSheet); };
|
|
@@ -1697,7 +1698,7 @@ function createGlobalStyle(strings) {
|
|
|
1697
1698
|
globalStyle.renderStyles(instance, context, styleSheet, stylis);
|
|
1698
1699
|
}
|
|
1699
1700
|
}
|
|
1700
|
-
return React__default
|
|
1701
|
+
return React__default.default.memo(GlobalStyleComponent);
|
|
1701
1702
|
}
|
|
1702
1703
|
|
|
1703
1704
|
function keyframes(strings) {
|
|
@@ -1718,14 +1719,14 @@ function keyframes(strings) {
|
|
|
1718
1719
|
}
|
|
1719
1720
|
|
|
1720
1721
|
function withTheme(Component) {
|
|
1721
|
-
var WithTheme = React__default
|
|
1722
|
-
var theme = React__default
|
|
1722
|
+
var WithTheme = React__default.default.forwardRef(function (props, ref) {
|
|
1723
|
+
var theme = React__default.default.useContext(ThemeContext);
|
|
1723
1724
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
1724
1725
|
if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
|
1725
1726
|
// eslint-disable-next-line no-console
|
|
1726
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), "\""));
|
|
1727
1728
|
}
|
|
1728
|
-
return React__default
|
|
1729
|
+
return React__default.default.createElement(Component, tslib.__assign({}, props, { theme: themeProp, ref: ref }));
|
|
1729
1730
|
});
|
|
1730
1731
|
WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
|
|
1731
1732
|
return hoistNonReactStatics(WithTheme, Component);
|
|
@@ -1770,7 +1771,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1770
1771
|
props.nonce = nonce;
|
|
1771
1772
|
}
|
|
1772
1773
|
// v4 returned an array for this fn, so we'll do the same for v5 for backward compat
|
|
1773
|
-
return [React__default
|
|
1774
|
+
return [React__default.default.createElement("style", tslib.__assign({}, props, { key: "sc-0-0" }))];
|
|
1774
1775
|
};
|
|
1775
1776
|
this.seal = function () {
|
|
1776
1777
|
_this.sealed = true;
|
|
@@ -1782,7 +1783,7 @@ var ServerStyleSheet = /** @class */ (function () {
|
|
|
1782
1783
|
if (this.sealed) {
|
|
1783
1784
|
throw throwStyledComponentsError(2);
|
|
1784
1785
|
}
|
|
1785
|
-
return React__default
|
|
1786
|
+
return React__default.default.createElement(StyleSheetManager, { sheet: this.instance }, children);
|
|
1786
1787
|
};
|
|
1787
1788
|
// eslint-disable-next-line consistent-return
|
|
1788
1789
|
// @ts-expect-error alternate return types are not possible due to code transformation
|
|
@@ -1835,7 +1836,7 @@ exports.ThemeProvider = ThemeProvider;
|
|
|
1835
1836
|
exports.__PRIVATE__ = __PRIVATE__;
|
|
1836
1837
|
exports.createGlobalStyle = createGlobalStyle;
|
|
1837
1838
|
exports.css = css;
|
|
1838
|
-
exports
|
|
1839
|
+
exports.default = styled;
|
|
1839
1840
|
exports.isStyledComponent = isStyledComponent;
|
|
1840
1841
|
exports.keyframes = keyframes;
|
|
1841
1842
|
exports.styled = styled;
|