tailwindcss 0.0.0-insiders.f70175d → 0.0.0-insiders.f94a117
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/CHANGELOG.md +18 -1
- package/lib/corePluginList.js +1 -0
- package/lib/corePlugins.js +90 -46
- package/lib/css/preflight.css +4 -0
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +6 -2
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/dataTypes.js +11 -0
- package/lib/util/formatVariantSelector.js +78 -3
- package/lib/util/normalizeScreens.js +58 -0
- package/lib/util/parseBoxShadowValue.js +77 -0
- package/lib/util/pluginUtils.js +2 -1
- package/package.json +5 -5
- package/peers/index.js +3064 -2456
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +91 -43
- package/src/css/preflight.css +4 -0
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/dataTypes.js +13 -0
- package/src/util/formatVariantSelector.js +81 -0
- package/src/util/normalizeScreens.js +42 -0
- package/src/util/parseBoxShadowValue.js +71 -0
- package/src/util/pluginUtils.js +2 -0
- package/stubs/defaultConfig.stub.js +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Enforce the order of some variants (like `before` and `after`) ([#6018](https://github.com/tailwindlabs/tailwindcss/pull/6018))
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Add `placeholder` variant ([#6106](https://github.com/tailwindlabs/tailwindcss/pull/6106))
|
|
17
|
+
- Add tuple syntax for configuring screens while guaranteeing order ([#5956](https://github.com/tailwindlabs/tailwindcss/pull/5956))
|
|
18
|
+
- Add combinable `touch-action` support ([#6115](https://github.com/tailwindlabs/tailwindcss/pull/6115))
|
|
19
|
+
- Add `::file-selector-button` reset ([#6125](https://github.com/tailwindlabs/tailwindcss/pull/6125))
|
|
20
|
+
|
|
21
|
+
## [3.0.0-alpha.2] - 2021-11-08
|
|
22
|
+
|
|
10
23
|
### Changed
|
|
11
24
|
|
|
12
25
|
- Don't use pointer cursor on disabled buttons by default ([#5772](https://github.com/tailwindlabs/tailwindcss/pull/5772))
|
|
@@ -23,7 +36,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
36
|
- Add `grow-*` and `shrink-*` utilities, deprecate `flex-grow-*` and `flex-shrink-*` ([#5733](https://github.com/tailwindlabs/tailwindcss/pull/5733))
|
|
24
37
|
- Add `text-decoration-color` utilities ([#5760](https://github.com/tailwindlabs/tailwindcss/pull/5760))
|
|
25
38
|
- Add new declarative `addVariant` API ([#5809](https://github.com/tailwindlabs/tailwindcss/pull/5809))
|
|
39
|
+
- Add first-class `print` variant for targeting printed media ([#5885](https://github.com/tailwindlabs/tailwindcss/pull/5885))
|
|
26
40
|
- Add full color palette for `fill-*` and `stroke-*` utilities (#5933[](https://github.com/tailwindlabs/tailwindcss/pull/5933))
|
|
41
|
+
- Add composable API for colored box shadows ([#5979](https://github.com/tailwindlabs/tailwindcss/pull/5979))
|
|
27
42
|
|
|
28
43
|
### Fixed
|
|
29
44
|
|
|
@@ -34,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
34
49
|
- Allow `_` inside `url()` when using arbitrary values ([#5853](https://github.com/tailwindlabs/tailwindcss/pull/5853))
|
|
35
50
|
- Prevent crashes when using comments in `@layer` AtRules ([#5854](https://github.com/tailwindlabs/tailwindcss/pull/5854))
|
|
36
51
|
- Handle color transformations properly with `theme(...)` for all relevant plugins ([#4533](https://github.com/tailwindlabs/tailwindcss/pull/4533), [#5871](https://github.com/tailwindlabs/tailwindcss/pull/5871))
|
|
52
|
+
- Ensure `@apply`-ing a utility with multiple definitions works ([#5870](https://github.com/tailwindlabs/tailwindcss/pull/5870))
|
|
37
53
|
|
|
38
54
|
## [3.0.0-alpha.1] - 2021-10-01
|
|
39
55
|
|
|
@@ -1650,7 +1666,8 @@ No release notes
|
|
|
1650
1666
|
|
|
1651
1667
|
- Everything!
|
|
1652
1668
|
|
|
1653
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.0-alpha.
|
|
1669
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.0-alpha.2...HEAD
|
|
1670
|
+
[3.0.0-alpha.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.0-alpha.1...v3.0.0-alpha.2
|
|
1654
1671
|
[3.0.0-alpha.1]: https://github.com/tailwindlabs/tailwindcss/compare/v2.2.19...v3.0.0-alpha.1
|
|
1655
1672
|
[2.2.19]: https://github.com/tailwindlabs/tailwindcss/compare/v2.2.18...v2.2.19
|
|
1656
1673
|
[2.2.18]: https://github.com/tailwindlabs/tailwindcss/compare/v2.2.17...v2.2.18
|
package/lib/corePluginList.js
CHANGED
package/lib/corePlugins.js
CHANGED
|
@@ -16,6 +16,8 @@ var _isPlainObject = _interopRequireDefault(require("./util/isPlainObject"));
|
|
|
16
16
|
var _transformThemeValue = _interopRequireDefault(require("./util/transformThemeValue"));
|
|
17
17
|
var _packageJson = require("../package.json");
|
|
18
18
|
var _log = _interopRequireDefault(require("./util/log"));
|
|
19
|
+
var _normalizeScreens = require("./util/normalizeScreens");
|
|
20
|
+
var _parseBoxShadowValue = require("./util/parseBoxShadowValue");
|
|
19
21
|
function _interopRequireDefault(obj) {
|
|
20
22
|
return obj && obj.__esModule ? obj : {
|
|
21
23
|
default: obj
|
|
@@ -57,6 +59,7 @@ let variantPlugins = {
|
|
|
57
59
|
'&::selection'
|
|
58
60
|
]);
|
|
59
61
|
addVariant('file', '&::file-selector-button');
|
|
62
|
+
addVariant('placeholder', '&::placeholder');
|
|
60
63
|
addVariant('before', ({ container })=>{
|
|
61
64
|
container.walkRules((rule)=>{
|
|
62
65
|
let foundContent = false;
|
|
@@ -196,10 +199,9 @@ let variantPlugins = {
|
|
|
196
199
|
addVariant('print', '@media print');
|
|
197
200
|
},
|
|
198
201
|
screenVariants: ({ theme , addVariant })=>{
|
|
199
|
-
for(let screen
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
addVariant(screen, `@media ${query}`);
|
|
202
|
+
for (let screen of (0, _normalizeScreens).normalizeScreens(theme('screens'))){
|
|
203
|
+
let query = (0, _buildMediaQuery).default(screen);
|
|
204
|
+
addVariant(screen.name, `@media ${query}`);
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
};
|
|
@@ -215,27 +217,11 @@ let corePlugins1 = {
|
|
|
215
217
|
]);
|
|
216
218
|
},
|
|
217
219
|
container: (()=>{
|
|
218
|
-
function extractMinWidths(
|
|
219
|
-
return
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
min: breakpoints
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
if (!Array.isArray(breakpoints)) {
|
|
227
|
-
breakpoints = [
|
|
228
|
-
breakpoints
|
|
229
|
-
];
|
|
230
|
-
}
|
|
231
|
-
return breakpoints.filter((breakpoint)=>{
|
|
232
|
-
var ref;
|
|
233
|
-
return (breakpoint === null || breakpoint === void 0 ? void 0 : (ref = breakpoint.hasOwnProperty) === null || ref === void 0 ? void 0 : ref.call(breakpoint, 'min')) || (breakpoint === null || breakpoint === void 0 ? void 0 : breakpoint.hasOwnProperty('min-width'));
|
|
234
|
-
}).map((breakpoint)=>{
|
|
235
|
-
var ref;
|
|
236
|
-
return (ref = breakpoint['min-width']) !== null && ref !== void 0 ? ref : breakpoint.min;
|
|
237
|
-
});
|
|
238
|
-
});
|
|
220
|
+
function extractMinWidths(breakpoints = []) {
|
|
221
|
+
return breakpoints.flatMap((breakpoint1)=>breakpoint1.values.map((breakpoint)=>breakpoint.min
|
|
222
|
+
)
|
|
223
|
+
).filter((v)=>v !== undefined
|
|
224
|
+
);
|
|
239
225
|
}
|
|
240
226
|
function mapMinWidthsToPadding(minWidths, screens, paddings) {
|
|
241
227
|
if (typeof paddings === 'undefined') {
|
|
@@ -259,25 +245,25 @@ let corePlugins1 = {
|
|
|
259
245
|
});
|
|
260
246
|
}
|
|
261
247
|
for (let minWidth of minWidths){
|
|
262
|
-
for (let
|
|
263
|
-
let
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
248
|
+
for (let screen of screens){
|
|
249
|
+
for (let { min } of screen.values){
|
|
250
|
+
if (min === minWidth) {
|
|
251
|
+
mapping.push({
|
|
252
|
+
minWidth,
|
|
253
|
+
padding: paddings[screen.name]
|
|
254
|
+
});
|
|
255
|
+
}
|
|
270
256
|
}
|
|
271
257
|
}
|
|
272
258
|
}
|
|
273
259
|
return mapping;
|
|
274
260
|
}
|
|
275
261
|
return function({ addComponents , theme }) {
|
|
276
|
-
let screens = theme('container.screens', theme('screens'));
|
|
262
|
+
let screens = (0, _normalizeScreens).normalizeScreens(theme('container.screens', theme('screens')));
|
|
277
263
|
let minWidths = extractMinWidths(screens);
|
|
278
264
|
let paddings = mapMinWidthsToPadding(minWidths, screens, theme('container.padding'));
|
|
279
265
|
let generatePaddingFor = (minWidth)=>{
|
|
280
|
-
let paddingConfig = paddings.find((padding)
|
|
266
|
+
let paddingConfig = paddings.find((padding)=>padding.minWidth === minWidth
|
|
281
267
|
);
|
|
282
268
|
if (!paddingConfig) {
|
|
283
269
|
return {
|
|
@@ -1009,7 +995,15 @@ let corePlugins1 = {
|
|
|
1009
995
|
});
|
|
1010
996
|
},
|
|
1011
997
|
cursor: (0, _createUtilityPlugin).default('cursor'),
|
|
1012
|
-
touchAction: ({ addUtilities })=>{
|
|
998
|
+
touchAction: ({ addBase , addUtilities })=>{
|
|
999
|
+
addBase({
|
|
1000
|
+
'@defaults touch-action': {
|
|
1001
|
+
'--tw-pan-x': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
1002
|
+
'--tw-pan-y': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
1003
|
+
'--tw-pinch-zoom': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
1004
|
+
'--tw-touch-action': 'var(--tw-pan-x) var(--tw-pan-y) var(--tw-pinch-zoom)'
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1013
1007
|
addUtilities({
|
|
1014
1008
|
'.touch-auto': {
|
|
1015
1009
|
'touch-action': 'auto'
|
|
@@ -1018,25 +1012,46 @@ let corePlugins1 = {
|
|
|
1018
1012
|
'touch-action': 'none'
|
|
1019
1013
|
},
|
|
1020
1014
|
'.touch-pan-x': {
|
|
1021
|
-
'touch-action':
|
|
1015
|
+
'@defaults touch-action': {
|
|
1016
|
+
},
|
|
1017
|
+
'--tw-pan-x': 'pan-x',
|
|
1018
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1022
1019
|
},
|
|
1023
1020
|
'.touch-pan-left': {
|
|
1024
|
-
'touch-action':
|
|
1021
|
+
'@defaults touch-action': {
|
|
1022
|
+
},
|
|
1023
|
+
'--tw-pan-x': 'pan-left',
|
|
1024
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1025
1025
|
},
|
|
1026
1026
|
'.touch-pan-right': {
|
|
1027
|
-
'touch-action':
|
|
1027
|
+
'@defaults touch-action': {
|
|
1028
|
+
},
|
|
1029
|
+
'--tw-pan-x': 'pan-right',
|
|
1030
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1028
1031
|
},
|
|
1029
1032
|
'.touch-pan-y': {
|
|
1030
|
-
'touch-action':
|
|
1033
|
+
'@defaults touch-action': {
|
|
1034
|
+
},
|
|
1035
|
+
'--tw-pan-y': 'pan-y',
|
|
1036
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1031
1037
|
},
|
|
1032
1038
|
'.touch-pan-up': {
|
|
1033
|
-
'touch-action':
|
|
1039
|
+
'@defaults touch-action': {
|
|
1040
|
+
},
|
|
1041
|
+
'--tw-pan-y': 'pan-up',
|
|
1042
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1034
1043
|
},
|
|
1035
1044
|
'.touch-pan-down': {
|
|
1036
|
-
'touch-action':
|
|
1045
|
+
'@defaults touch-action': {
|
|
1046
|
+
},
|
|
1047
|
+
'--tw-pan-y': 'pan-down',
|
|
1048
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1037
1049
|
},
|
|
1038
1050
|
'.touch-pinch-zoom': {
|
|
1039
|
-
'touch-action':
|
|
1051
|
+
'@defaults touch-action': {
|
|
1052
|
+
},
|
|
1053
|
+
'--tw-pinch-zoom': 'pinch-zoom',
|
|
1054
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1040
1055
|
},
|
|
1041
1056
|
'.touch-manipulation': {
|
|
1042
1057
|
'touch-action': 'manipulation'
|
|
@@ -2995,24 +3010,52 @@ let corePlugins1 = {
|
|
|
2995
3010
|
'@defaults box-shadow': {
|
|
2996
3011
|
'--tw-ring-offset-shadow': '0 0 #0000',
|
|
2997
3012
|
'--tw-ring-shadow': '0 0 #0000',
|
|
2998
|
-
'--tw-shadow': '0 0 #0000'
|
|
3013
|
+
'--tw-shadow': '0 0 #0000',
|
|
3014
|
+
'--tw-shadow-colored': '0 0 #0000'
|
|
2999
3015
|
}
|
|
3000
3016
|
});
|
|
3001
3017
|
matchUtilities({
|
|
3002
3018
|
shadow: (value)=>{
|
|
3003
3019
|
value = transformValue(value);
|
|
3020
|
+
let ast = (0, _parseBoxShadowValue).parseBoxShadowValue(value);
|
|
3021
|
+
for (let shadow of ast){
|
|
3022
|
+
// Don't override color if the whole shadow is a variable
|
|
3023
|
+
if (!shadow.valid) {
|
|
3024
|
+
continue;
|
|
3025
|
+
}
|
|
3026
|
+
shadow.color = 'var(--tw-shadow-color)';
|
|
3027
|
+
}
|
|
3004
3028
|
return {
|
|
3005
3029
|
'@defaults box-shadow': {
|
|
3006
3030
|
},
|
|
3007
3031
|
'--tw-shadow': value === 'none' ? '0 0 #0000' : value,
|
|
3032
|
+
'--tw-shadow-colored': value === 'none' ? '0 0 #0000' : (0, _parseBoxShadowValue).formatBoxShadowValue(ast),
|
|
3008
3033
|
'box-shadow': defaultBoxShadow
|
|
3009
3034
|
};
|
|
3010
3035
|
}
|
|
3011
3036
|
}, {
|
|
3012
|
-
values: theme('boxShadow')
|
|
3037
|
+
values: theme('boxShadow'),
|
|
3038
|
+
type: [
|
|
3039
|
+
'shadow'
|
|
3040
|
+
]
|
|
3013
3041
|
});
|
|
3014
3042
|
};
|
|
3015
3043
|
})(),
|
|
3044
|
+
boxShadowColor: ({ matchUtilities , theme })=>{
|
|
3045
|
+
matchUtilities({
|
|
3046
|
+
shadow: (value)=>{
|
|
3047
|
+
return {
|
|
3048
|
+
'--tw-shadow-color': (0, _toColorValue).default(value),
|
|
3049
|
+
'--tw-shadow': 'var(--tw-shadow-colored)'
|
|
3050
|
+
};
|
|
3051
|
+
}
|
|
3052
|
+
}, {
|
|
3053
|
+
values: (0, _flattenColorPalette).default(theme('boxShadowColor')),
|
|
3054
|
+
type: [
|
|
3055
|
+
'color'
|
|
3056
|
+
]
|
|
3057
|
+
});
|
|
3058
|
+
},
|
|
3016
3059
|
outlineStyle: ({ addUtilities })=>{
|
|
3017
3060
|
addUtilities({
|
|
3018
3061
|
'.outline-none': {
|
|
@@ -3089,7 +3132,8 @@ let corePlugins1 = {
|
|
|
3089
3132
|
'--tw-ring-color': ringColorDefault,
|
|
3090
3133
|
'--tw-ring-offset-shadow': '0 0 #0000',
|
|
3091
3134
|
'--tw-ring-shadow': '0 0 #0000',
|
|
3092
|
-
'--tw-shadow': '0 0 #0000'
|
|
3135
|
+
'--tw-shadow': '0 0 #0000',
|
|
3136
|
+
'--tw-shadow-colored': '0 0 #0000'
|
|
3093
3137
|
}
|
|
3094
3138
|
});
|
|
3095
3139
|
matchUtilities({
|
package/lib/css/preflight.css
CHANGED
package/lib/lib/detectNesting.js
CHANGED
|
@@ -6,12 +6,27 @@ exports.default = _default;
|
|
|
6
6
|
function _default(_context) {
|
|
7
7
|
return (root, result)=>{
|
|
8
8
|
let found = false;
|
|
9
|
+
root.walkAtRules('tailwind', (node)=>{
|
|
10
|
+
if (found) return false;
|
|
11
|
+
if (node.parent && node.parent.type !== 'root') {
|
|
12
|
+
found = true;
|
|
13
|
+
node.warn(result, [
|
|
14
|
+
'Nested @tailwind rules were detected, but are not supported.',
|
|
15
|
+
"Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix",
|
|
16
|
+
'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy',
|
|
17
|
+
].join('\n'));
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
9
21
|
root.walkRules((rule)=>{
|
|
10
22
|
if (found) return false;
|
|
11
23
|
rule.walkRules((nestedRule)=>{
|
|
12
24
|
found = true;
|
|
13
|
-
nestedRule.warn(result,
|
|
14
|
-
|
|
25
|
+
nestedRule.warn(result, [
|
|
26
|
+
'Nested CSS was detected, but CSS nesting has not been configured correctly.',
|
|
27
|
+
'Please enable a CSS nesting plugin *before* Tailwind in your configuration.',
|
|
28
|
+
'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting',
|
|
29
|
+
].join('\n'));
|
|
15
30
|
return false;
|
|
16
31
|
});
|
|
17
32
|
});
|
|
@@ -7,6 +7,7 @@ var _dlv = _interopRequireDefault(require("dlv"));
|
|
|
7
7
|
var _didyoumean = _interopRequireDefault(require("didyoumean"));
|
|
8
8
|
var _transformThemeValue = _interopRequireDefault(require("../util/transformThemeValue"));
|
|
9
9
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
|
10
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
10
11
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
11
12
|
var _toPath = require("../util/toPath");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
@@ -149,10 +150,13 @@ function _default({ tailwindConfig: config }) {
|
|
|
149
150
|
},
|
|
150
151
|
screen: (node, screen)=>{
|
|
151
152
|
screen = screen.replace(/^['"]+/g, '').replace(/['"]+$/g, '');
|
|
152
|
-
|
|
153
|
+
let screens = (0, _normalizeScreens).normalizeScreens(config.theme.screens);
|
|
154
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
155
|
+
);
|
|
156
|
+
if (!screenDefinition) {
|
|
153
157
|
throw node.error(`The '${screen}' screen does not exist in your theme.`);
|
|
154
158
|
}
|
|
155
|
-
return (0, _buildMediaQuery).default(
|
|
159
|
+
return (0, _buildMediaQuery).default(screenDefinition);
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
162
|
return (root)=>{
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.default = _default;
|
|
6
|
+
var _normalizeScreens = require("../util/normalizeScreens");
|
|
6
7
|
var _buildMediaQuery = _interopRequireDefault(require("../util/buildMediaQuery"));
|
|
7
8
|
function _interopRequireDefault(obj) {
|
|
8
9
|
return obj && obj.__esModule ? obj : {
|
|
@@ -12,13 +13,15 @@ function _interopRequireDefault(obj) {
|
|
|
12
13
|
function _default({ tailwindConfig: { theme } }) {
|
|
13
14
|
return function(css) {
|
|
14
15
|
css.walkAtRules('screen', (atRule)=>{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let screen = atRule.params;
|
|
17
|
+
let screens = (0, _normalizeScreens).normalizeScreens(theme.screens);
|
|
18
|
+
let screenDefinition = screens.find(({ name })=>name === screen
|
|
19
|
+
);
|
|
20
|
+
if (!screenDefinition) {
|
|
18
21
|
throw atRule.error(`No \`${screen}\` screen found.`);
|
|
19
22
|
}
|
|
20
23
|
atRule.name = 'media';
|
|
21
|
-
atRule.params = (0, _buildMediaQuery).default(
|
|
24
|
+
atRule.params = (0, _buildMediaQuery).default(screenDefinition);
|
|
22
25
|
});
|
|
23
26
|
};
|
|
24
27
|
}
|
|
@@ -4,28 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.default = buildMediaQuery;
|
|
6
6
|
function buildMediaQuery(screens) {
|
|
7
|
-
|
|
8
|
-
screens
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return screen.raw;
|
|
21
|
-
}
|
|
22
|
-
return Object.entries(screen).map(([feature, value])=>{
|
|
23
|
-
var _feature;
|
|
24
|
-
feature = (_feature = ({
|
|
25
|
-
min: 'min-width',
|
|
26
|
-
max: 'max-width'
|
|
27
|
-
})[feature]) !== null && _feature !== void 0 ? _feature : feature;
|
|
28
|
-
return `(${feature}: ${value})`;
|
|
29
|
-
}).join(' and ');
|
|
30
|
-
}).join(', ');
|
|
7
|
+
screens = Array.isArray(screens) ? screens : [
|
|
8
|
+
screens
|
|
9
|
+
];
|
|
10
|
+
return screens.map((screen1)=>screen1.values.map((screen)=>{
|
|
11
|
+
if (screen.raw !== undefined) {
|
|
12
|
+
return screen.raw;
|
|
13
|
+
}
|
|
14
|
+
return [
|
|
15
|
+
screen.min && `(min-width: ${screen.min})`,
|
|
16
|
+
screen.max && `(max-width: ${screen.max})`,
|
|
17
|
+
].filter(Boolean).join(' and ');
|
|
18
|
+
})
|
|
19
|
+
).join(', ');
|
|
31
20
|
}
|
package/lib/util/dataTypes.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.number = number;
|
|
|
8
8
|
exports.percentage = percentage;
|
|
9
9
|
exports.length = length;
|
|
10
10
|
exports.lineWidth = lineWidth;
|
|
11
|
+
exports.shadow = shadow;
|
|
11
12
|
exports.color = color;
|
|
12
13
|
exports.image = image;
|
|
13
14
|
exports.gradient = gradient;
|
|
@@ -17,6 +18,7 @@ exports.genericName = genericName;
|
|
|
17
18
|
exports.absoluteSize = absoluteSize;
|
|
18
19
|
exports.relativeSize = relativeSize;
|
|
19
20
|
var _color = require("./color");
|
|
21
|
+
var _parseBoxShadowValue = require("./parseBoxShadowValue");
|
|
20
22
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
|
|
21
23
|
let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
|
|
22
24
|
;
|
|
@@ -82,6 +84,15 @@ let lineWidths = new Set([
|
|
|
82
84
|
function lineWidth(value) {
|
|
83
85
|
return lineWidths.has(value);
|
|
84
86
|
}
|
|
87
|
+
function shadow(value) {
|
|
88
|
+
let parsedShadows = (0, _parseBoxShadowValue).parseBoxShadowValue(normalize(value));
|
|
89
|
+
for (let parsedShadow of parsedShadows){
|
|
90
|
+
if (!parsedShadow.valid) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
85
96
|
function color(value) {
|
|
86
97
|
let colors = 0;
|
|
87
98
|
let result = value.split(UNDERSCORE).every((part)=>{
|
|
@@ -69,17 +69,92 @@ function finalizeSelector(format, { selector: selector1 , candidate , context }
|
|
|
69
69
|
selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
|
|
70
70
|
// Remove unnecessary pseudo selectors that we used as placeholders
|
|
71
71
|
return (0, _postcssSelectorParser).default((selectors)=>{
|
|
72
|
-
return selectors.map((
|
|
73
|
-
|
|
72
|
+
return selectors.map((selector2)=>{
|
|
73
|
+
selector2.walkPseudos((p)=>{
|
|
74
74
|
if (selectorFunctions.has(p.value)) {
|
|
75
75
|
p.replaceWith(p.nodes);
|
|
76
76
|
}
|
|
77
77
|
return p;
|
|
78
78
|
});
|
|
79
|
-
|
|
79
|
+
// This will make sure to move pseudo's to the correct spot (the end for
|
|
80
|
+
// pseudo elements) because otherwise the selector will never work
|
|
81
|
+
// anyway.
|
|
82
|
+
//
|
|
83
|
+
// E.g.:
|
|
84
|
+
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
85
|
+
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
86
|
+
//
|
|
87
|
+
// `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
|
|
88
|
+
function collectPseudoElements(selector) {
|
|
89
|
+
let nodes = [];
|
|
90
|
+
for (let node of selector.nodes){
|
|
91
|
+
if (isPseudoElement(node)) {
|
|
92
|
+
nodes.push(node);
|
|
93
|
+
selector.removeChild(node);
|
|
94
|
+
}
|
|
95
|
+
if (node === null || node === void 0 ? void 0 : node.nodes) {
|
|
96
|
+
nodes.push(...collectPseudoElements(node));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return nodes;
|
|
100
|
+
}
|
|
101
|
+
let pseudoElements = collectPseudoElements(selector2);
|
|
102
|
+
if (pseudoElements.length > 0) {
|
|
103
|
+
selector2.nodes.push(pseudoElements.sort(sortSelector));
|
|
104
|
+
}
|
|
105
|
+
return selector2;
|
|
80
106
|
});
|
|
81
107
|
}).processSync(selector1);
|
|
82
108
|
}
|
|
109
|
+
// Note: As a rule, double colons (::) should be used instead of a single colon
|
|
110
|
+
// (:). This distinguishes pseudo-classes from pseudo-elements. However, since
|
|
111
|
+
// this distinction was not present in older versions of the W3C spec, most
|
|
112
|
+
// browsers support both syntaxes for the original pseudo-elements.
|
|
113
|
+
let pseudoElementsBC = [
|
|
114
|
+
':before',
|
|
115
|
+
':after',
|
|
116
|
+
':first-line',
|
|
117
|
+
':first-letter'
|
|
118
|
+
];
|
|
119
|
+
// These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
|
|
120
|
+
let pseudoElementExceptions = [
|
|
121
|
+
'::file-selector-button'
|
|
122
|
+
];
|
|
123
|
+
// This will make sure to move pseudo's to the correct spot (the end for
|
|
124
|
+
// pseudo elements) because otherwise the selector will never work
|
|
125
|
+
// anyway.
|
|
126
|
+
//
|
|
127
|
+
// E.g.:
|
|
128
|
+
// - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
|
|
129
|
+
// - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
|
|
130
|
+
//
|
|
131
|
+
// `::before:hover` doesn't work, which means that we can make it work
|
|
132
|
+
// for you by flipping the order.
|
|
133
|
+
function sortSelector(a, z) {
|
|
134
|
+
// Both nodes are non-pseudo's so we can safely ignore them and keep
|
|
135
|
+
// them in the same order.
|
|
136
|
+
if (a.type !== 'pseudo' && z.type !== 'pseudo') {
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
// If one of them is a combinator, we need to keep it in the same order
|
|
140
|
+
// because that means it will start a new "section" in the selector.
|
|
141
|
+
if (a.type === 'combinator' ^ z.type === 'combinator') {
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
// One of the items is a pseudo and the other one isn't. Let's move
|
|
145
|
+
// the pseudo to the right.
|
|
146
|
+
if (a.type === 'pseudo' ^ z.type === 'pseudo') {
|
|
147
|
+
return (a.type === 'pseudo') - (z.type === 'pseudo');
|
|
148
|
+
}
|
|
149
|
+
// Both are pseudo's, move the pseudo elements (except for
|
|
150
|
+
// ::file-selector-button) to the right.
|
|
151
|
+
return isPseudoElement(a) - isPseudoElement(z);
|
|
152
|
+
}
|
|
153
|
+
function isPseudoElement(node) {
|
|
154
|
+
if (node.type !== 'pseudo') return false;
|
|
155
|
+
if (pseudoElementExceptions.includes(node.value)) return false;
|
|
156
|
+
return node.value.startsWith('::') || pseudoElementsBC.includes(node.value);
|
|
157
|
+
}
|
|
83
158
|
function resolveFunctionArgument(haystack, needle, arg) {
|
|
84
159
|
let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
|
|
85
160
|
if (startIdx === -1) return null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.normalizeScreens = normalizeScreens;
|
|
6
|
+
function normalizeScreens(screens) {
|
|
7
|
+
if (Array.isArray(screens)) {
|
|
8
|
+
return screens.map((screen)=>{
|
|
9
|
+
if (typeof screen === 'string') {
|
|
10
|
+
return {
|
|
11
|
+
name: screen.toString(),
|
|
12
|
+
values: [
|
|
13
|
+
{
|
|
14
|
+
min: screen,
|
|
15
|
+
max: undefined
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
let [name, options] = screen;
|
|
21
|
+
name = name.toString();
|
|
22
|
+
if (typeof options === 'string') {
|
|
23
|
+
return {
|
|
24
|
+
name,
|
|
25
|
+
values: [
|
|
26
|
+
{
|
|
27
|
+
min: options,
|
|
28
|
+
max: undefined
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(options)) {
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
values: options.map((option)=>resolveValue(option)
|
|
37
|
+
)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
values: [
|
|
43
|
+
resolveValue(options)
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {
|
|
52
|
+
}) {
|
|
53
|
+
return {
|
|
54
|
+
min,
|
|
55
|
+
max,
|
|
56
|
+
raw
|
|
57
|
+
};
|
|
58
|
+
}
|