styled-components 5.0.0-testgrouplimit.0 → 5.1.0
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/README.md +180 -0
- package/dist/styled-components.browser.cjs.js +102 -62
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +104 -64
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +102 -62
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +104 -64
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +103 -63
- 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/native/dist/styled-components.native.cjs.js +56 -94
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +57 -95
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/package.json +14 -2
- package/primitives/dist/styled-components-primitives.cjs.js +56 -94
- package/primitives/dist/styled-components-primitives.cjs.js.map +1 -1
- package/primitives/dist/styled-components-primitives.esm.js +57 -95
- package/primitives/dist/styled-components-primitives.esm.js.map +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://www.styled-components.com">
|
|
3
|
+
<img alt="styled-components" src="https://raw.githubusercontent.com/styled-components/brand/master/styled-components.png" height="150px" />
|
|
4
|
+
</a>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<br />
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
<strong>Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅</strong>
|
|
11
|
+
<br />
|
|
12
|
+
<br />
|
|
13
|
+
<a href="https://www.npmjs.com/package/styled-components"><img src="https://www.styled-components.com/proxy/downloads.svg" alt="downloads: 600k/month"></a>
|
|
14
|
+
<a href="#backers" alt="sponsors on Open Collective"><img src="https://opencollective.com/styled-components/backers/badge.svg" /></a> <a href="#sponsors" alt="Sponsors on Open Collective"><img src="https://opencollective.com/styled-components/sponsors/badge.svg" /></a> <a href="https://spectrum.chat/styled-components"><img src="https://withspectrum.github.io/badge/badge.svg" alt="Join the community on Spectrum"></a>
|
|
15
|
+
<a href="https://bundlephobia.com/result?p=styled-components" title="styled-components latest minified+gzip size"><img src="https://badgen.net/bundlephobia/minzip/styled-components" alt="gzip size"></a>
|
|
16
|
+
<a href="#alternative-installation-methods"><img src="https://img.shields.io/badge/module%20formats-umd%2C%20cjs%2C%20esm-green.svg" alt="module formats: umd, cjs, esm"></a>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<br />
|
|
20
|
+
<br />
|
|
21
|
+
|
|
22
|
+
Utilising [tagged template literals](https://www.styled-components.com/docs/advanced#tagged-template-literals) (a recent addition to JavaScript) and the [power of CSS](https://www.styled-components.com/docs/api#supported-css), `styled-components` allows you to write actual CSS code to style your components. It also removes the mapping between components and styles – using components as a low-level styling construct could not be easier!
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
const Button = styled.button`
|
|
26
|
+
color: grey;
|
|
27
|
+
`;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Alternatively, you may use [style objects](https://www.styled-components.com/docs/advanced#style-objects). This allows for easy porting of CSS from inline styles, while still supporting the more advanced styled-components capabilities like component selectors and media queries.
|
|
31
|
+
|
|
32
|
+
```jsx
|
|
33
|
+
const Button = styled.button({
|
|
34
|
+
color: 'grey',
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Equivalent to:
|
|
39
|
+
|
|
40
|
+
```jsx
|
|
41
|
+
const Button = styled.button`
|
|
42
|
+
color: grey;
|
|
43
|
+
`;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`styled-components` is compatible with both React (for web) and React Native – meaning it's the perfect choice even for truly universal apps! See the [documentation about React Native](https://www.styled-components.com/docs/basics#react-native) for more information.
|
|
47
|
+
|
|
48
|
+
_Supported by [Front End Center](https://frontend.center). Thank you for making this possible!_
|
|
49
|
+
|
|
50
|
+
## Upgrading from v4
|
|
51
|
+
|
|
52
|
+
1. `npm install styled-components@^5.0.0 react@^16.8 react-dom@^16.8 react-is@^16.8`
|
|
53
|
+
1. ??
|
|
54
|
+
1. Profit!
|
|
55
|
+
|
|
56
|
+
> If you use jest-styled-components, make sure you update that too.
|
|
57
|
+
|
|
58
|
+
## [Docs](https://www.styled-components.com/docs)
|
|
59
|
+
|
|
60
|
+
**See the documentation at [styled-components.com/docs](https://www.styled-components.com/docs)** for more information about using `styled-components`!
|
|
61
|
+
|
|
62
|
+
Quicklinks to some of the most-visited pages:
|
|
63
|
+
|
|
64
|
+
- [**Getting started**](https://www.styled-components.com/docs/basics)
|
|
65
|
+
- [API Reference](https://styled-components.com/docs/api)
|
|
66
|
+
- [Theming](https://www.styled-components.com/docs/advanced#theming)
|
|
67
|
+
- [Server-side rendering](https://www.styled-components.com/docs/advanced#server-side-rendering)
|
|
68
|
+
- [Tagged Template Literals explained](https://www.styled-components.com/docs/advanced#tagged-template-literals)
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
<!-- prettier-ignore -->
|
|
73
|
+
```JSX
|
|
74
|
+
import React from 'react';
|
|
75
|
+
|
|
76
|
+
import styled from 'styled-components';
|
|
77
|
+
|
|
78
|
+
// Create a <Title> react component that renders an <h1> which is
|
|
79
|
+
// centered, palevioletred and sized at 1.5em
|
|
80
|
+
const Title = styled.h1`
|
|
81
|
+
font-size: 1.5em;
|
|
82
|
+
text-align: center;
|
|
83
|
+
color: palevioletred;
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
// Create a <Wrapper> react component that renders a <section> with
|
|
87
|
+
// some padding and a papayawhip background
|
|
88
|
+
const Wrapper = styled.section`
|
|
89
|
+
padding: 4em;
|
|
90
|
+
background: papayawhip;
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
// Use them like any other React component – except they're styled!
|
|
94
|
+
<Wrapper>
|
|
95
|
+
<Title>Hello World, this is my first styled component!</Title>
|
|
96
|
+
</Wrapper>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This is what you'll see in your browser:
|
|
100
|
+
|
|
101
|
+
<div align="center">
|
|
102
|
+
<a href="https://styled-components.com">
|
|
103
|
+
<img alt="Screenshot of the above code ran in a browser" src="http://i.imgur.com/wUJpcjY.jpg" />
|
|
104
|
+
</a>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
## Babel Macro
|
|
108
|
+
|
|
109
|
+
If you're using tooling that has babel-plugin-macros set up, you can switch to the `styled-components/macro` import path instead to gain the effects of the babel plugin without further setup.
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
import styled from 'styled-components/macro';
|
|
113
|
+
|
|
114
|
+
// A static className will be generated for Title (important for SSR)
|
|
115
|
+
const Title = styled.h1`
|
|
116
|
+
font-size: 1.5em;
|
|
117
|
+
text-align: center;
|
|
118
|
+
color: palevioletred;
|
|
119
|
+
`;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If you wish to provide configuration options to the babel plugin similar to how you would in a `.babelrc`, [see this guide](https://github.com/kentcdodds/babel-plugin-macros/blob/master/other/docs/author.md#config-experimental). The config name is `"styledComponents"`.
|
|
123
|
+
|
|
124
|
+
## Built with `styled-components`
|
|
125
|
+
|
|
126
|
+
A lot of hard work goes into community libraries, projects, and guides. A lot of them make it easier to get started or help you with your next project! There’s also a whole lot of interesting apps and sites that people have built using styled-components.
|
|
127
|
+
|
|
128
|
+
Make sure to head over to [awesome-styled-components](https://github.com/styled-components/awesome-styled-components) to see them all! And please contribute and add your own work to the list so others can find it.
|
|
129
|
+
|
|
130
|
+
## Contributing
|
|
131
|
+
|
|
132
|
+
If you want to contribute to `styled-components` please see our [contributing and community guidelines](./CONTRIBUTING.md), they'll help you get set up locally and explain the whole process.
|
|
133
|
+
|
|
134
|
+
Please also note that all repositories under the `styled-components` organization follow our [Code of Conduct](./CODE_OF_CONDUCT.md), make sure to review and follow it.
|
|
135
|
+
|
|
136
|
+
## Badge
|
|
137
|
+
|
|
138
|
+
Let everyone know you're using _styled-components_ → [](https://github.com/styled-components/styled-components)
|
|
139
|
+
|
|
140
|
+
```md
|
|
141
|
+
[](https://github.com/styled-components/styled-components)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Contributors
|
|
145
|
+
|
|
146
|
+
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
|
147
|
+
<a href="https://github.com/styled-components/styled-components/graphs/contributors"><img src="https://opencollective.com/styled-components/contributors.svg?width=890" /></a>
|
|
148
|
+
|
|
149
|
+
## Backers
|
|
150
|
+
|
|
151
|
+
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/styled-components#backer)]
|
|
152
|
+
|
|
153
|
+
<a href="https://opencollective.com/styled-components#backers" target="_blank"><img src="https://opencollective.com/styled-components/backers.svg?width=890"></a>
|
|
154
|
+
|
|
155
|
+
## Sponsors
|
|
156
|
+
|
|
157
|
+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/styled-components#sponsor)]
|
|
158
|
+
|
|
159
|
+
<a href="https://opencollective.com/styled-components/sponsor/0/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/0/avatar.svg"></a>
|
|
160
|
+
<a href="https://opencollective.com/styled-components/sponsor/1/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/1/avatar.svg"></a>
|
|
161
|
+
<a href="https://opencollective.com/styled-components/sponsor/2/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/2/avatar.svg"></a>
|
|
162
|
+
<a href="https://opencollective.com/styled-components/sponsor/3/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/3/avatar.svg"></a>
|
|
163
|
+
<a href="https://opencollective.com/styled-components/sponsor/4/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/4/avatar.svg"></a>
|
|
164
|
+
<a href="https://opencollective.com/styled-components/sponsor/5/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/5/avatar.svg"></a>
|
|
165
|
+
<a href="https://opencollective.com/styled-components/sponsor/6/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/6/avatar.svg"></a>
|
|
166
|
+
<a href="https://opencollective.com/styled-components/sponsor/7/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/7/avatar.svg"></a>
|
|
167
|
+
<a href="https://opencollective.com/styled-components/sponsor/8/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/8/avatar.svg"></a>
|
|
168
|
+
<a href="https://opencollective.com/styled-components/sponsor/9/website" target="_blank"><img src="https://opencollective.com/styled-components/sponsor/9/avatar.svg"></a>
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
Licensed under the MIT License, Copyright © 2016-present Glen Maddern and Maximilian Stoiber.
|
|
173
|
+
|
|
174
|
+
See [LICENSE](./LICENSE) for more information.
|
|
175
|
+
|
|
176
|
+
## Acknowledgements
|
|
177
|
+
|
|
178
|
+
This project builds on a long line of earlier work by clever folks all around the world. We'd like to thank Charlie Somerville, Nik Graf, Sunil Pai, Michael Chan, Andrey Popp, Jed Watson & Andrey Sitnik who contributed ideas, code or inspiration.
|
|
179
|
+
|
|
180
|
+
Special thanks to [@okonet](https://github.com/okonet) for the fantastic logo.
|
|
@@ -59,7 +59,7 @@ var interleave = (function (strings, interpolations) {
|
|
|
59
59
|
|
|
60
60
|
//
|
|
61
61
|
var isPlainObject = (function (x) {
|
|
62
|
-
return typeof x === 'object' && x.
|
|
62
|
+
return x !== null && typeof x === 'object' && (x.toString ? x.toString() : Object.prototype.toString.call(x)) === '[object Object]' && !reactIs.typeOf(x);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
//
|
|
@@ -92,7 +92,8 @@ function isStyledComponent(target) {
|
|
|
92
92
|
var SC_ATTR = typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || 'data-styled';
|
|
93
93
|
var SC_ATTR_ACTIVE = 'active';
|
|
94
94
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
95
|
-
var SC_VERSION = "5.
|
|
95
|
+
var SC_VERSION = "5.1.0";
|
|
96
|
+
var SPLITTER = '/*!sc*/\n';
|
|
96
97
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
97
98
|
var DISABLE_SPEEDY = typeof SC_DISABLE_SPEEDY === 'boolean' && SC_DISABLE_SPEEDY || typeof process !== 'undefined' && (process.env.REACT_APP_SC_DISABLE_SPEEDY || process.env.SC_DISABLE_SPEEDY) || process.env.NODE_ENV !== 'production'; // Shared empty execution context when generating static styles
|
|
98
99
|
|
|
@@ -236,9 +237,7 @@ var makeTag = function makeTag(_ref) {
|
|
|
236
237
|
return new TextTag(target);
|
|
237
238
|
}
|
|
238
239
|
};
|
|
239
|
-
var CSSOMTag =
|
|
240
|
-
/*#__PURE__*/
|
|
241
|
-
function () {
|
|
240
|
+
var CSSOMTag = /*#__PURE__*/function () {
|
|
242
241
|
function CSSOMTag(target) {
|
|
243
242
|
var element = this.element = makeStyleTag(target); // Avoid Edge bug where empty style elements don't create sheets
|
|
244
243
|
|
|
@@ -278,9 +277,7 @@ function () {
|
|
|
278
277
|
}();
|
|
279
278
|
/** A Tag that emulates the CSSStyleSheet API but uses text nodes */
|
|
280
279
|
|
|
281
|
-
var TextTag =
|
|
282
|
-
/*#__PURE__*/
|
|
283
|
-
function () {
|
|
280
|
+
var TextTag = /*#__PURE__*/function () {
|
|
284
281
|
function TextTag(target) {
|
|
285
282
|
var element = this.element = makeStyleTag(target);
|
|
286
283
|
this.nodes = element.childNodes;
|
|
@@ -318,9 +315,7 @@ function () {
|
|
|
318
315
|
}();
|
|
319
316
|
/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
|
|
320
317
|
|
|
321
|
-
var VirtualTag =
|
|
322
|
-
/*#__PURE__*/
|
|
323
|
-
function () {
|
|
318
|
+
var VirtualTag = /*#__PURE__*/function () {
|
|
324
319
|
function VirtualTag(_target) {
|
|
325
320
|
this.rules = [];
|
|
326
321
|
this.length = 0;
|
|
@@ -362,9 +357,7 @@ var makeGroupedTag = function makeGroupedTag(tag) {
|
|
|
362
357
|
};
|
|
363
358
|
var BASE_SIZE = 1 << 9;
|
|
364
359
|
|
|
365
|
-
var DefaultGroupedTag =
|
|
366
|
-
/*#__PURE__*/
|
|
367
|
-
function () {
|
|
360
|
+
var DefaultGroupedTag = /*#__PURE__*/function () {
|
|
368
361
|
function DefaultGroupedTag(tag) {
|
|
369
362
|
this.groupSizes = new Uint32Array(BASE_SIZE);
|
|
370
363
|
this.length = BASE_SIZE;
|
|
@@ -441,7 +434,7 @@ function () {
|
|
|
441
434
|
var endIndex = startIndex + length;
|
|
442
435
|
|
|
443
436
|
for (var i = startIndex; i < endIndex; i++) {
|
|
444
|
-
css += this.tag.getRule(i) +
|
|
437
|
+
css += "" + this.tag.getRule(i) + SPLITTER;
|
|
445
438
|
}
|
|
446
439
|
|
|
447
440
|
return css;
|
|
@@ -484,8 +477,7 @@ var setGroupForId = function setGroupForId(id, group) {
|
|
|
484
477
|
|
|
485
478
|
//
|
|
486
479
|
var SELECTOR = "style[" + SC_ATTR + "][" + SC_ATTR_VERSION + "=\"" + SC_VERSION + "\"]";
|
|
487
|
-
var
|
|
488
|
-
var MARKER_RE = new RegExp("^" + SC_ATTR + "\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\]");
|
|
480
|
+
var MARKER_RE = new RegExp("^" + SC_ATTR + "\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)");
|
|
489
481
|
var outputSheet = function outputSheet(sheet) {
|
|
490
482
|
var tag = sheet.getTag();
|
|
491
483
|
var length = tag.length;
|
|
@@ -510,7 +502,7 @@ var outputSheet = function outputSheet(sheet) {
|
|
|
510
502
|
// after the actual rules to simplify the rehydration
|
|
511
503
|
|
|
512
504
|
|
|
513
|
-
css += "" + rules + selector + "{content:\"" + content + "\"}
|
|
505
|
+
css += "" + rules + selector + "{content:\"" + content + "\"}" + SPLITTER;
|
|
514
506
|
}
|
|
515
507
|
|
|
516
508
|
return css;
|
|
@@ -529,13 +521,13 @@ var rehydrateNamesFromContent = function rehydrateNamesFromContent(sheet, id, co
|
|
|
529
521
|
};
|
|
530
522
|
|
|
531
523
|
var rehydrateSheetFromTag = function rehydrateSheetFromTag(sheet, style) {
|
|
532
|
-
var
|
|
524
|
+
var parts = style.innerHTML.split(SPLITTER);
|
|
533
525
|
var rules = [];
|
|
534
|
-
var parts; // parts = [match, selector, content]
|
|
535
|
-
// eslint-disable-next-line no-cond-assign
|
|
536
526
|
|
|
537
|
-
|
|
538
|
-
var
|
|
527
|
+
for (var i = 0, l = parts.length; i < l; i++) {
|
|
528
|
+
var part = parts[i].trim();
|
|
529
|
+
if (!part) continue;
|
|
530
|
+
var marker = part.match(MARKER_RE);
|
|
539
531
|
|
|
540
532
|
if (marker) {
|
|
541
533
|
var group = parseInt(marker[1], 10) | 0;
|
|
@@ -546,13 +538,13 @@ var rehydrateSheetFromTag = function rehydrateSheetFromTag(sheet, style) {
|
|
|
546
538
|
setGroupForId(id, group); // Rehydrate names and rules
|
|
547
539
|
// looks like: data-styled.g11[id="idA"]{content:"nameA,"}
|
|
548
540
|
|
|
549
|
-
rehydrateNamesFromContent(sheet, id,
|
|
541
|
+
rehydrateNamesFromContent(sheet, id, marker[3]);
|
|
550
542
|
sheet.getTag().insertRules(group, rules);
|
|
551
543
|
}
|
|
552
544
|
|
|
553
545
|
rules.length = 0;
|
|
554
546
|
} else {
|
|
555
|
-
rules.push(
|
|
547
|
+
rules.push(part);
|
|
556
548
|
}
|
|
557
549
|
}
|
|
558
550
|
};
|
|
@@ -580,9 +572,7 @@ var defaultOptions = {
|
|
|
580
572
|
};
|
|
581
573
|
/** Contains the main stylesheet logic for stringification and caching */
|
|
582
574
|
|
|
583
|
-
var StyleSheet =
|
|
584
|
-
/*#__PURE__*/
|
|
585
|
-
function () {
|
|
575
|
+
var StyleSheet = /*#__PURE__*/function () {
|
|
586
576
|
/** Register a group ID to give it an index */
|
|
587
577
|
StyleSheet.registerId = function registerId(id) {
|
|
588
578
|
return getGroupForId(id);
|
|
@@ -910,18 +900,16 @@ function StyleSheetManager(props) {
|
|
|
910
900
|
React.useEffect(function () {
|
|
911
901
|
if (!shallowequal(plugins, props.stylisPlugins)) setPlugins(props.stylisPlugins);
|
|
912
902
|
}, [props.stylisPlugins]);
|
|
913
|
-
return React__default.createElement(StyleSheetContext.Provider, {
|
|
903
|
+
return /*#__PURE__*/React__default.createElement(StyleSheetContext.Provider, {
|
|
914
904
|
value: styleSheet
|
|
915
|
-
}, React__default.createElement(StylisContext.Provider, {
|
|
905
|
+
}, /*#__PURE__*/React__default.createElement(StylisContext.Provider, {
|
|
916
906
|
value: stylis
|
|
917
907
|
}, process.env.NODE_ENV !== 'production' ? React__default.Children.only(props.children) : props.children));
|
|
918
908
|
}
|
|
919
909
|
|
|
920
910
|
//
|
|
921
911
|
|
|
922
|
-
var Keyframes =
|
|
923
|
-
/*#__PURE__*/
|
|
924
|
-
function () {
|
|
912
|
+
var Keyframes = /*#__PURE__*/function () {
|
|
925
913
|
function Keyframes(name, stringifyArgs) {
|
|
926
914
|
var _this = this;
|
|
927
915
|
|
|
@@ -1240,9 +1228,7 @@ function isStaticRules(rules) {
|
|
|
1240
1228
|
the React-specific stuff.
|
|
1241
1229
|
*/
|
|
1242
1230
|
|
|
1243
|
-
var ComponentStyle =
|
|
1244
|
-
/*#__PURE__*/
|
|
1245
|
-
function () {
|
|
1231
|
+
var ComponentStyle = /*#__PURE__*/function () {
|
|
1246
1232
|
function ComponentStyle(rules, componentId) {
|
|
1247
1233
|
this.rules = rules;
|
|
1248
1234
|
this.staticRulesId = '';
|
|
@@ -1335,6 +1321,36 @@ var createWarnTooManyClasses = (function (displayName, componentId) {
|
|
|
1335
1321
|
};
|
|
1336
1322
|
});
|
|
1337
1323
|
|
|
1324
|
+
//
|
|
1325
|
+
var invalidHookCallRe = /invalid hook call/i;
|
|
1326
|
+
var seen = new Set();
|
|
1327
|
+
var checkDynamicCreation = function checkDynamicCreation(displayName, componentId) {
|
|
1328
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1329
|
+
var parsedIdString = componentId ? " with the id of \"" + componentId + "\"" : '';
|
|
1330
|
+
var message = "The component " + displayName + parsedIdString + " has been created dynamically.\n" + 'You may see this warning because you\'ve called styled inside another component.\n' + 'To resolve this only create new StyledComponents outside of any render method and function component.';
|
|
1331
|
+
|
|
1332
|
+
try {
|
|
1333
|
+
// We purposefully call `useRef` outside of a component and expect it to throw
|
|
1334
|
+
// If it doesn't, then we're inside another component.
|
|
1335
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
1336
|
+
React.useRef();
|
|
1337
|
+
|
|
1338
|
+
if (!seen.has(message)) {
|
|
1339
|
+
// eslint-disable-next-line no-console
|
|
1340
|
+
console.warn(message);
|
|
1341
|
+
seen.add(message);
|
|
1342
|
+
}
|
|
1343
|
+
} catch (error) {
|
|
1344
|
+
// The error here is expected, since we're expecting anything that uses `checkDynamicCreation` to
|
|
1345
|
+
// be called outside of a React component.
|
|
1346
|
+
if (invalidHookCallRe.test(error.message)) {
|
|
1347
|
+
// This shouldn't happen, but resets `warningSeen` if we had this error happen intermittently
|
|
1348
|
+
seen["delete"](message);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1338
1354
|
//
|
|
1339
1355
|
var determineTheme = (function (props, providedTheme, defaultProps) {
|
|
1340
1356
|
if (defaultProps === void 0) {
|
|
@@ -1420,7 +1436,7 @@ function ThemeProvider(props) {
|
|
|
1420
1436
|
return null;
|
|
1421
1437
|
}
|
|
1422
1438
|
|
|
1423
|
-
return React__default.createElement(ThemeContext.Provider, {
|
|
1439
|
+
return /*#__PURE__*/React__default.createElement(ThemeContext.Provider, {
|
|
1424
1440
|
value: themeContext
|
|
1425
1441
|
}, props.children);
|
|
1426
1442
|
}
|
|
@@ -1491,6 +1507,7 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1491
1507
|
componentStyle = forwardedComponent.componentStyle,
|
|
1492
1508
|
defaultProps = forwardedComponent.defaultProps,
|
|
1493
1509
|
foldedComponentIds = forwardedComponent.foldedComponentIds,
|
|
1510
|
+
shouldForwardProp = forwardedComponent.shouldForwardProp,
|
|
1494
1511
|
styledComponentId = forwardedComponent.styledComponentId,
|
|
1495
1512
|
target = forwardedComponent.target;
|
|
1496
1513
|
React.useDebugValue(styledComponentId); // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
|
|
@@ -1505,21 +1522,18 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
|
|
|
1505
1522
|
|
|
1506
1523
|
var generatedClassName = useInjectedStyle(componentStyle, componentAttrs.length > 0, context, process.env.NODE_ENV !== 'production' ? forwardedComponent.warnTooManyClasses : undefined);
|
|
1507
1524
|
var refToForward = forwardedRef;
|
|
1508
|
-
var elementToBeCreated = attrs.as || props.as || target;
|
|
1525
|
+
var elementToBeCreated = attrs.$as || props.$as || attrs.as || props.as || target;
|
|
1509
1526
|
var isTargetTag = isTag(elementToBeCreated);
|
|
1510
1527
|
var computedProps = attrs !== props ? _extends({}, props, {}, attrs) : props;
|
|
1511
|
-
var
|
|
1512
|
-
var propsForElement =
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
// Don't pass through non HTML tags through to HTML elements
|
|
1521
|
-
propsForElement[key] = computedProps[key];
|
|
1522
|
-
}
|
|
1528
|
+
var propFilterFn = shouldForwardProp || isTargetTag && validAttr;
|
|
1529
|
+
var propsForElement = {}; // eslint-disable-next-line guard-for-in
|
|
1530
|
+
|
|
1531
|
+
for (var key in computedProps) {
|
|
1532
|
+
if (key[0] === '$' || key === 'as') continue;else if (key === 'forwardedAs') {
|
|
1533
|
+
propsForElement.as = computedProps[key];
|
|
1534
|
+
} else if (!propFilterFn || propFilterFn(key, validAttr)) {
|
|
1535
|
+
// Don't pass through non HTML tags through to HTML elements
|
|
1536
|
+
propsForElement[key] = computedProps[key];
|
|
1523
1537
|
}
|
|
1524
1538
|
}
|
|
1525
1539
|
|
|
@@ -1544,7 +1558,24 @@ function createStyledComponent(target, options, rules) {
|
|
|
1544
1558
|
var styledComponentId = options.displayName && options.componentId ? escape(options.displayName) + "-" + options.componentId : options.componentId || componentId; // fold the underlying StyledComponent attrs up (implicit extend)
|
|
1545
1559
|
|
|
1546
1560
|
var finalAttrs = // $FlowFixMe
|
|
1547
|
-
isTargetStyledComp && target.attrs ? Array.prototype.concat(target.attrs, attrs).filter(Boolean) : attrs;
|
|
1561
|
+
isTargetStyledComp && target.attrs ? Array.prototype.concat(target.attrs, attrs).filter(Boolean) : attrs; // eslint-disable-next-line prefer-destructuring
|
|
1562
|
+
|
|
1563
|
+
var shouldForwardProp = options.shouldForwardProp; // $FlowFixMe
|
|
1564
|
+
|
|
1565
|
+
if (isTargetStyledComp && target.shouldForwardProp) {
|
|
1566
|
+
if (shouldForwardProp) {
|
|
1567
|
+
// compose nested shouldForwardProp calls
|
|
1568
|
+
shouldForwardProp = function shouldForwardProp(prop, filterFn) {
|
|
1569
|
+
return (// $FlowFixMe
|
|
1570
|
+
target.shouldForwardProp(prop, filterFn) && options.shouldForwardProp(prop, filterFn)
|
|
1571
|
+
);
|
|
1572
|
+
};
|
|
1573
|
+
} else {
|
|
1574
|
+
// eslint-disable-next-line prefer-destructuring
|
|
1575
|
+
shouldForwardProp = target.shouldForwardProp;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1548
1579
|
var componentStyle = new ComponentStyle(isTargetStyledComp ? // fold the underlying StyledComponent rules up (implicit extend)
|
|
1549
1580
|
// $FlowFixMe
|
|
1550
1581
|
target.componentStyle.rules.concat(rules) : rules, styledComponentId);
|
|
@@ -1564,7 +1595,8 @@ function createStyledComponent(target, options, rules) {
|
|
|
1564
1595
|
WrappedStyledComponent = React__default.forwardRef(forwardRef);
|
|
1565
1596
|
WrappedStyledComponent.attrs = finalAttrs;
|
|
1566
1597
|
WrappedStyledComponent.componentStyle = componentStyle;
|
|
1567
|
-
WrappedStyledComponent.displayName = displayName;
|
|
1598
|
+
WrappedStyledComponent.displayName = displayName;
|
|
1599
|
+
WrappedStyledComponent.shouldForwardProp = shouldForwardProp; // this static is used to preserve the cascade of static classes for component selector
|
|
1568
1600
|
// purposes; this is especially important with usage of the css prop
|
|
1569
1601
|
|
|
1570
1602
|
WrappedStyledComponent.foldedComponentIds = isTargetStyledComp ? // $FlowFixMe
|
|
@@ -1600,6 +1632,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
1600
1632
|
});
|
|
1601
1633
|
|
|
1602
1634
|
if (process.env.NODE_ENV !== 'production') {
|
|
1635
|
+
checkDynamicCreation(displayName, styledComponentId);
|
|
1603
1636
|
WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName, styledComponentId);
|
|
1604
1637
|
} // $FlowFixMe
|
|
1605
1638
|
|
|
@@ -1615,6 +1648,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
1615
1648
|
componentStyle: true,
|
|
1616
1649
|
displayName: true,
|
|
1617
1650
|
foldedComponentIds: true,
|
|
1651
|
+
shouldForwardProp: true,
|
|
1618
1652
|
self: true,
|
|
1619
1653
|
styledComponentId: true,
|
|
1620
1654
|
target: true,
|
|
@@ -1643,9 +1677,7 @@ domElements.forEach(function (domElement) {
|
|
|
1643
1677
|
|
|
1644
1678
|
//
|
|
1645
1679
|
|
|
1646
|
-
var GlobalStyle =
|
|
1647
|
-
/*#__PURE__*/
|
|
1648
|
-
function () {
|
|
1680
|
+
var GlobalStyle = /*#__PURE__*/function () {
|
|
1649
1681
|
function GlobalStyle(rules, componentId) {
|
|
1650
1682
|
this.rules = rules;
|
|
1651
1683
|
this.componentId = componentId;
|
|
@@ -1685,6 +1717,10 @@ function createGlobalStyle(strings) {
|
|
|
1685
1717
|
var styledComponentId = "sc-global-" + generateComponentId(JSON.stringify(rules));
|
|
1686
1718
|
var globalStyle = new GlobalStyle(rules, styledComponentId);
|
|
1687
1719
|
|
|
1720
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1721
|
+
checkDynamicCreation(styledComponentId);
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1688
1724
|
function GlobalStyleComponent(props) {
|
|
1689
1725
|
var styleSheet = useStyleSheet();
|
|
1690
1726
|
var stylis = useStylis();
|
|
@@ -1702,6 +1738,12 @@ function createGlobalStyle(strings) {
|
|
|
1702
1738
|
console.warn("The global style component " + styledComponentId + " was given child JSX. createGlobalStyle does not render children.");
|
|
1703
1739
|
}
|
|
1704
1740
|
|
|
1741
|
+
if (process.env.NODE_ENV !== 'production' && rules.some(function (rule) {
|
|
1742
|
+
return typeof rule === 'string' && rule.indexOf('@import') !== -1;
|
|
1743
|
+
})) {
|
|
1744
|
+
console.warn("Please do not use @import CSS syntax in createGlobalStyle at this time, as the CSSOM APIs we use in production do not handle it well. Instead, we recommend using a library such as react-helmet to inject a typical <link> meta tag to the stylesheet, or simply embedding it manually in your index.html <head> section for a simpler app.");
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1705
1747
|
if (globalStyle.isStatic) {
|
|
1706
1748
|
globalStyle.renderStyles(instance, STATIC_EXECUTION_CONTEXT, styleSheet, stylis);
|
|
1707
1749
|
} else {
|
|
@@ -1741,9 +1783,7 @@ function keyframes(strings) {
|
|
|
1741
1783
|
return new Keyframes(name, [rules, name, '@keyframes']);
|
|
1742
1784
|
}
|
|
1743
1785
|
|
|
1744
|
-
var ServerStyleSheet =
|
|
1745
|
-
/*#__PURE__*/
|
|
1746
|
-
function () {
|
|
1786
|
+
var ServerStyleSheet = /*#__PURE__*/function () {
|
|
1747
1787
|
function ServerStyleSheet() {
|
|
1748
1788
|
var _this = this;
|
|
1749
1789
|
|
|
@@ -1781,7 +1821,7 @@ function () {
|
|
|
1781
1821
|
} // v4 returned an array for this fn, so we'll do the same for v5 for backward compat
|
|
1782
1822
|
|
|
1783
1823
|
|
|
1784
|
-
return [React__default.createElement("style", _extends({}, props, {
|
|
1824
|
+
return [/*#__PURE__*/React__default.createElement("style", _extends({}, props, {
|
|
1785
1825
|
key: "sc-0-0"
|
|
1786
1826
|
}))];
|
|
1787
1827
|
};
|
|
@@ -1803,7 +1843,7 @@ function () {
|
|
|
1803
1843
|
return throwStyledComponentsError(2);
|
|
1804
1844
|
}
|
|
1805
1845
|
|
|
1806
|
-
return React__default.createElement(StyleSheetManager, {
|
|
1846
|
+
return /*#__PURE__*/React__default.createElement(StyleSheetManager, {
|
|
1807
1847
|
sheet: this.instance
|
|
1808
1848
|
}, children);
|
|
1809
1849
|
};
|
|
@@ -1837,7 +1877,7 @@ var withTheme = (function (Component) {
|
|
|
1837
1877
|
console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"" + getComponentName(Component) + "\"");
|
|
1838
1878
|
}
|
|
1839
1879
|
|
|
1840
|
-
return React__default.createElement(Component, _extends({}, props, {
|
|
1880
|
+
return /*#__PURE__*/React__default.createElement(Component, _extends({}, props, {
|
|
1841
1881
|
theme: themeProp,
|
|
1842
1882
|
ref: ref
|
|
1843
1883
|
}));
|
|
@@ -1862,7 +1902,7 @@ var __PRIVATE__ = {
|
|
|
1862
1902
|
//
|
|
1863
1903
|
/* Define bundle version for export */
|
|
1864
1904
|
|
|
1865
|
-
var version = "5.
|
|
1905
|
+
var version = "5.1.0";
|
|
1866
1906
|
/* Warning if you've imported this file on React Native */
|
|
1867
1907
|
|
|
1868
1908
|
if (process.env.NODE_ENV !== 'production' && typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|