styled-components 6.0.0-rc.3 → 6.0.0-rc.5
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 +16 -42
- package/dist/constructors/css.d.ts +2 -2
- package/dist/constructors/keyframes.d.ts +1 -1
- package/dist/constructors/styled.d.ts +524 -6
- package/dist/hoc/withTheme.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/models/Keyframes.d.ts +0 -1
- package/dist/models/ServerStyleSheet.d.ts +2 -1
- package/dist/models/StyledComponent.d.ts +2 -2
- package/dist/models/StyledNativeComponent.d.ts +2 -2
- package/dist/models/ThemeProvider.d.ts +8 -1
- package/dist/native/index.d.ts +28 -29
- package/dist/sheet/Sheet.d.ts +0 -2
- 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 +93 -38
- 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 +523 -179
- package/dist/types.d.ts +48 -54
- package/dist/utils/errors.d.ts +1 -0
- package/dist/utils/isStyledComponent.d.ts +2 -2
- package/dist/utils/joinStrings.d.ts +1 -1
- package/dist/utils/setToString.d.ts +17 -0
- package/native/dist/constructors/constructWithOptions.d.ts +16 -42
- package/native/dist/constructors/css.d.ts +2 -2
- package/native/dist/constructors/keyframes.d.ts +1 -1
- package/native/dist/constructors/styled.d.ts +524 -6
- package/native/dist/hoc/withTheme.d.ts +1 -1
- package/native/dist/index.d.ts +1 -1
- package/native/dist/models/Keyframes.d.ts +0 -1
- package/native/dist/models/ServerStyleSheet.d.ts +2 -1
- package/native/dist/models/StyledComponent.d.ts +2 -2
- package/native/dist/models/StyledNativeComponent.d.ts +2 -2
- package/native/dist/models/ThemeProvider.d.ts +8 -1
- package/native/dist/native/index.d.ts +28 -29
- package/native/dist/sheet/Sheet.d.ts +0 -2
- package/native/dist/styled-components.native.cjs.js +1 -1
- 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 +523 -179
- package/native/dist/types.d.ts +48 -54
- package/native/dist/utils/errors.d.ts +1 -0
- package/native/dist/utils/isStyledComponent.d.ts +2 -2
- package/native/dist/utils/joinStrings.d.ts +1 -1
- package/native/dist/utils/setToString.d.ts +17 -0
- package/package.json +8 -3
- package/test-utils/index.ts +3 -6
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
(global = global || self, global.styled = factory(global.React));
|
|
5
5
|
})(this, (function (React) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var SC_ATTR = (typeof process !== 'undefined' &&
|
|
8
|
-
typeof process.env !== 'undefined' &&
|
|
9
|
-
(process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
7
|
+
var SC_ATTR = (typeof process !== 'undefined' && typeof process.env !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
|
|
10
8
|
'data-styled';
|
|
11
9
|
var SC_ATTR_ACTIVE = 'active';
|
|
12
10
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
13
|
-
var SC_VERSION = "6.0.0-rc.
|
|
11
|
+
var SC_VERSION = "6.0.0-rc.5";
|
|
14
12
|
var SPLITTER = '/*!sc*/\n';
|
|
15
13
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
16
14
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -72,6 +70,26 @@
|
|
|
72
70
|
var EMPTY_ARRAY = Object.freeze([]);
|
|
73
71
|
var EMPTY_OBJECT = Object.freeze({});
|
|
74
72
|
|
|
73
|
+
/**
|
|
74
|
+
* If the Object prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
|
|
75
|
+
* cannot have the property changed using a "=" assignment operator. If using strict mode, attempting that will cause an error. If not using
|
|
76
|
+
* strict mode, attempting that will be silently ignored.
|
|
77
|
+
*
|
|
78
|
+
* If the Object prototype is frozen, inherited non-writable properties can still be shadowed using one of two mechanisms:
|
|
79
|
+
*
|
|
80
|
+
* 1. ES6 class methods: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#methods
|
|
81
|
+
* 2. Using the `Object.defineProperty()` static method:
|
|
82
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
|
|
83
|
+
*
|
|
84
|
+
* However, this project uses Babel to transpile ES6 classes, and transforms ES6 class methods to use the assignment operator instead:
|
|
85
|
+
* https://babeljs.io/docs/babel-plugin-transform-class-properties#options
|
|
86
|
+
*
|
|
87
|
+
* Therefore, the most compatible way to shadow the prototype's "toString" property is to define a new "toString" property on this object.
|
|
88
|
+
*/
|
|
89
|
+
function setToString(object, toStringFn) {
|
|
90
|
+
Object.defineProperty(object, 'toString', { value: toStringFn });
|
|
91
|
+
}
|
|
92
|
+
|
|
75
93
|
var errorMap = {
|
|
76
94
|
'1': 'Cannot create styled-component for component: %s.\n\n',
|
|
77
95
|
'2': "Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",
|
|
@@ -90,6 +108,7 @@
|
|
|
90
108
|
'15': "A stylis plugin has been supplied that is not named. We need a name for each plugin to be able to prevent styling collisions between different stylis configurations within the same app. Before you pass your plugin to `<StyleSheetManager stylisPlugins={[]}>`, please make sure each plugin is uniquely-named, e.g.\n\n```js\nObject.defineProperty(importedPlugin, 'name', { value: 'some-unique-name' });\n```\n\n",
|
|
91
109
|
'16': "Reached the limit of how many styled components may be created at group %s.\nYou may only create up to 1,073,741,824 components. If you're creating components dynamically,\nas for instance in your render method then you may be running into this limitation.\n\n",
|
|
92
110
|
'17': "CSSStyleSheet could not be found on HTMLStyleElement.\nHas styled-components' style tag been unmounted or altered by another script?\n",
|
|
111
|
+
'18': 'ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`',
|
|
93
112
|
};
|
|
94
113
|
|
|
95
114
|
var ERRORS = errorMap ;
|
|
@@ -473,6 +492,7 @@
|
|
|
473
492
|
function StyleSheet(options, globalStyles, names) {
|
|
474
493
|
if (options === void 0) { options = EMPTY_OBJECT; }
|
|
475
494
|
if (globalStyles === void 0) { globalStyles = {}; }
|
|
495
|
+
var _this = this;
|
|
476
496
|
this.options = __assign(__assign({}, defaultOptions), options);
|
|
477
497
|
this.gs = globalStyles;
|
|
478
498
|
this.names = new Map(names);
|
|
@@ -482,6 +502,7 @@
|
|
|
482
502
|
SHOULD_REHYDRATE = false;
|
|
483
503
|
rehydrateSheet(this);
|
|
484
504
|
}
|
|
505
|
+
setToString(this, function () { return outputSheet(_this); });
|
|
485
506
|
}
|
|
486
507
|
/** Register a group ID to give it an index */
|
|
487
508
|
StyleSheet.registerId = function (id) {
|
|
@@ -536,10 +557,6 @@
|
|
|
536
557
|
// so that we can continuously output only new rules
|
|
537
558
|
this.tag = undefined;
|
|
538
559
|
};
|
|
539
|
-
/** Outputs the current sheet as a CSS string with markers for SSR */
|
|
540
|
-
StyleSheet.prototype.toString = function () {
|
|
541
|
-
return outputSheet(this);
|
|
542
|
-
};
|
|
543
560
|
return StyleSheet;
|
|
544
561
|
}());
|
|
545
562
|
|
|
@@ -770,12 +787,12 @@
|
|
|
770
787
|
styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
|
|
771
788
|
}
|
|
772
789
|
};
|
|
773
|
-
this.toString = function () {
|
|
774
|
-
throw throwStyledComponentsError(12, String(_this.name));
|
|
775
|
-
};
|
|
776
790
|
this.name = name;
|
|
777
791
|
this.id = "sc-keyframes-".concat(name);
|
|
778
792
|
this.rules = rules;
|
|
793
|
+
setToString(this, function () {
|
|
794
|
+
throw throwStyledComponentsError(12, String(_this.name));
|
|
795
|
+
});
|
|
779
796
|
}
|
|
780
797
|
Keyframes.prototype.getName = function (stylisInstance) {
|
|
781
798
|
if (stylisInstance === void 0) { stylisInstance = mainStylis; }
|
|
@@ -1053,14 +1070,25 @@
|
|
|
1053
1070
|
}
|
|
1054
1071
|
return outerTheme ? __assign(__assign({}, outerTheme), theme) : theme;
|
|
1055
1072
|
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Returns the current theme (as provided by the closest ancestor `ThemeProvider`.)
|
|
1075
|
+
*
|
|
1076
|
+
* If no `ThemeProvider` is found, the function will error. If you need access to the theme in an
|
|
1077
|
+
* uncertain composition scenario, `React.useContext(ThemeContext)` will not emit an error if there
|
|
1078
|
+
* is no `ThemeProvider` ancestor.
|
|
1079
|
+
*/
|
|
1056
1080
|
function useTheme() {
|
|
1057
|
-
|
|
1081
|
+
var theme = React.useContext(ThemeContext);
|
|
1082
|
+
if (!theme) {
|
|
1083
|
+
throw throwStyledComponentsError(18);
|
|
1084
|
+
}
|
|
1085
|
+
return theme;
|
|
1058
1086
|
}
|
|
1059
1087
|
/**
|
|
1060
1088
|
* Provide a theme to an entire react component tree via context
|
|
1061
1089
|
*/
|
|
1062
1090
|
function ThemeProvider(props) {
|
|
1063
|
-
var outerTheme =
|
|
1091
|
+
var outerTheme = React.useContext(ThemeContext);
|
|
1064
1092
|
var themeContext = React.useMemo(function () { return mergeTheme(props.theme, outerTheme); }, [props.theme, outerTheme]);
|
|
1065
1093
|
if (!props.children) {
|
|
1066
1094
|
return null;
|
|
@@ -1192,7 +1220,7 @@
|
|
|
1192
1220
|
}
|
|
1193
1221
|
var GlobalStyleComponent = function (props) {
|
|
1194
1222
|
var ssc = useStyleSheetContext();
|
|
1195
|
-
var theme =
|
|
1223
|
+
var theme = React.useContext(ThemeContext);
|
|
1196
1224
|
var instanceRef = React.useRef(ssc.styleSheet.allocateGSInstance(styledComponentId));
|
|
1197
1225
|
var instance = instanceRef.current;
|
|
1198
1226
|
if (React.Children.count(props.children)) {
|
|
@@ -1349,7 +1377,7 @@
|
|
|
1349
1377
|
|
|
1350
1378
|
function withTheme(Component) {
|
|
1351
1379
|
var WithTheme = React.forwardRef(function (props, ref) {
|
|
1352
|
-
var theme =
|
|
1380
|
+
var theme = React.useContext(ThemeContext);
|
|
1353
1381
|
var themeProp = determineTheme(props, theme, Component.defaultProps);
|
|
1354
1382
|
if (themeProp === undefined) {
|
|
1355
1383
|
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), "\""));
|
|
@@ -1463,6 +1491,26 @@
|
|
|
1463
1491
|
withTheme: withTheme
|
|
1464
1492
|
});
|
|
1465
1493
|
|
|
1494
|
+
function memoize(fn) {
|
|
1495
|
+
var cache = Object.create(null);
|
|
1496
|
+
return function (arg) {
|
|
1497
|
+
if (cache[arg] === undefined) cache[arg] = fn(arg);
|
|
1498
|
+
return cache[arg];
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
|
|
1503
|
+
|
|
1504
|
+
var isPropValid = /* #__PURE__ */memoize(function (prop) {
|
|
1505
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
|
|
1506
|
+
/* o */
|
|
1507
|
+
&& prop.charCodeAt(1) === 110
|
|
1508
|
+
/* n */
|
|
1509
|
+
&& prop.charCodeAt(2) < 91;
|
|
1510
|
+
}
|
|
1511
|
+
/* Z+1 */
|
|
1512
|
+
);
|
|
1513
|
+
|
|
1466
1514
|
var LIMIT = 200;
|
|
1467
1515
|
var createWarnTooManyClasses = (function (displayName, componentId) {
|
|
1468
1516
|
var generatedClasses = {};
|
|
@@ -1780,7 +1828,6 @@
|
|
|
1780
1828
|
attrDef = attrs[i];
|
|
1781
1829
|
var resolvedAttrDef = isFunction(attrDef) ? attrDef(context) : attrDef;
|
|
1782
1830
|
for (var key in resolvedAttrDef) {
|
|
1783
|
-
// @ts-expect-error bad types
|
|
1784
1831
|
context[key] =
|
|
1785
1832
|
key === 'className'
|
|
1786
1833
|
? joinStrings(context[key], resolvedAttrDef[key])
|
|
@@ -1793,9 +1840,10 @@
|
|
|
1793
1840
|
}
|
|
1794
1841
|
return context;
|
|
1795
1842
|
}
|
|
1843
|
+
var seenUnknownProps = new Set();
|
|
1796
1844
|
function useStyledComponentImpl(forwardedComponent, props, forwardedRef, isStatic) {
|
|
1797
1845
|
var componentAttrs = forwardedComponent.attrs, componentStyle = forwardedComponent.componentStyle, defaultProps = forwardedComponent.defaultProps, foldedComponentIds = forwardedComponent.foldedComponentIds, styledComponentId = forwardedComponent.styledComponentId, target = forwardedComponent.target;
|
|
1798
|
-
var contextTheme =
|
|
1846
|
+
var contextTheme = React.useContext(ThemeContext);
|
|
1799
1847
|
var ssc = useStyleSheetContext();
|
|
1800
1848
|
var shouldForwardProp = forwardedComponent.shouldForwardProp || ssc.shouldForwardProp;
|
|
1801
1849
|
React.useDebugValue(styledComponentId);
|
|
@@ -1814,6 +1862,11 @@
|
|
|
1814
1862
|
}
|
|
1815
1863
|
else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
|
|
1816
1864
|
propsForElement[key] = context[key];
|
|
1865
|
+
if (!isPropValid(key) &&
|
|
1866
|
+
!seenUnknownProps.has(key)) {
|
|
1867
|
+
seenUnknownProps.add(key);
|
|
1868
|
+
console.warn("styled-components: it looks like an unknown prop \"".concat(key, "\" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)"));
|
|
1869
|
+
}
|
|
1817
1870
|
}
|
|
1818
1871
|
}
|
|
1819
1872
|
var generatedClassName = useInjectedStyle(componentStyle, isStatic, context);
|
|
@@ -1837,12 +1890,10 @@
|
|
|
1837
1890
|
return React.createElement(elementToBeCreated, propsForElement);
|
|
1838
1891
|
}
|
|
1839
1892
|
function createStyledComponent(target, options, rules) {
|
|
1840
|
-
var _a;
|
|
1841
1893
|
var isTargetStyledComp = isStyledComponent(target);
|
|
1842
1894
|
var styledComponentTarget = target;
|
|
1843
1895
|
var isCompositeComponent = !isTag(target);
|
|
1844
|
-
var _b = options.componentId, componentId = _b === void 0 ? generateId(options.displayName, options.parentComponentId) : _b, _c = options.displayName, displayName = _c === void 0 ? generateDisplayName(target) : _c;
|
|
1845
|
-
var attrs = ((_a = options.attrs) !== null && _a !== void 0 ? _a : []);
|
|
1896
|
+
var _a = options.attrs, attrs = _a === void 0 ? EMPTY_ARRAY : _a, _b = options.componentId, componentId = _b === void 0 ? generateId(options.displayName, options.parentComponentId) : _b, _c = options.displayName, displayName = _c === void 0 ? generateDisplayName(target) : _c;
|
|
1846
1897
|
var styledComponentId = options.displayName && options.componentId
|
|
1847
1898
|
? "".concat(escape(options.displayName), "-").concat(options.componentId)
|
|
1848
1899
|
: options.componentId || componentId;
|
|
@@ -1904,13 +1955,7 @@
|
|
|
1904
1955
|
checkDynamicCreation(displayName, styledComponentId);
|
|
1905
1956
|
WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName, styledComponentId);
|
|
1906
1957
|
}
|
|
1907
|
-
|
|
1908
|
-
// cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict
|
|
1909
|
-
// mode, attempting that will be silently ignored.
|
|
1910
|
-
// However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.
|
|
1911
|
-
Object.defineProperty(WrappedStyledComponent, 'toString', {
|
|
1912
|
-
value: function () { return ".".concat(WrappedStyledComponent.styledComponentId); },
|
|
1913
|
-
});
|
|
1958
|
+
setToString(WrappedStyledComponent, function () { return ".".concat(WrappedStyledComponent.styledComponentId); });
|
|
1914
1959
|
if (isCompositeComponent) {
|
|
1915
1960
|
var compositeComponentTarget = target;
|
|
1916
1961
|
hoistNonReactStatics(WrappedStyledComponent, compositeComponentTarget, {
|
|
@@ -1929,10 +1974,13 @@
|
|
|
1929
1974
|
|
|
1930
1975
|
function constructWithOptions(componentConstructor, tag, options) {
|
|
1931
1976
|
if (options === void 0) { options = EMPTY_OBJECT; }
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1977
|
+
/**
|
|
1978
|
+
* We trust that the tag is a valid component as long as it isn't
|
|
1979
|
+
* falsish. Typically the tag here is a string or function (i.e.
|
|
1980
|
+
* class or pure function component), however a component may also be
|
|
1981
|
+
* an object if it uses another utility, e.g. React.memo. React will
|
|
1982
|
+
* output an appropriate warning however if the `tag` isn't valid.
|
|
1983
|
+
*/
|
|
1936
1984
|
if (!tag) {
|
|
1937
1985
|
throw throwStyledComponentsError(1, tag);
|
|
1938
1986
|
}
|
|
@@ -1944,25 +1992,32 @@
|
|
|
1944
1992
|
}
|
|
1945
1993
|
return componentConstructor(tag, options, css.apply(void 0, __spreadArray([initialStyles], interpolations, false)));
|
|
1946
1994
|
};
|
|
1947
|
-
|
|
1995
|
+
/**
|
|
1996
|
+
* Attrs allows for accomplishing two goals:
|
|
1997
|
+
*
|
|
1998
|
+
* 1. Backfilling props at runtime more expressively than defaultProps
|
|
1999
|
+
* 2. Amending the prop interface of a wrapped styled component
|
|
2000
|
+
*/
|
|
1948
2001
|
templateFunction.attrs = function (attrs) {
|
|
1949
2002
|
return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), { attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean) }));
|
|
1950
2003
|
};
|
|
1951
2004
|
/**
|
|
1952
|
-
* If config methods are called, wrap up a new template function
|
|
2005
|
+
* If config methods are called, wrap up a new template function
|
|
2006
|
+
* and merge options.
|
|
2007
|
+
*/
|
|
1953
2008
|
templateFunction.withConfig = function (config) {
|
|
1954
2009
|
return constructWithOptions(componentConstructor, tag, __assign(__assign({}, options), config));
|
|
1955
2010
|
};
|
|
1956
2011
|
return templateFunction;
|
|
1957
2012
|
}
|
|
1958
2013
|
|
|
1959
|
-
function
|
|
2014
|
+
var baseStyled = function (tag) {
|
|
1960
2015
|
return constructWithOptions(createStyledComponent, tag);
|
|
1961
|
-
}
|
|
1962
|
-
var styled =
|
|
2016
|
+
};
|
|
2017
|
+
var styled = baseStyled;
|
|
2018
|
+
// Shorthands for all valid HTML Elements
|
|
1963
2019
|
domElements.forEach(function (domElement) {
|
|
1964
|
-
|
|
1965
|
-
styled[domElement] = createStyle(domElement);
|
|
2020
|
+
styled[domElement] = baseStyled(domElement);
|
|
1966
2021
|
});
|
|
1967
2022
|
|
|
1968
2023
|
/**
|