tailwindcss 3.0.0-alpha.2 → 3.0.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/lib/cli.js +58 -58
- package/lib/corePluginList.js +3 -0
- package/lib/corePlugins.js +138 -65
- package/lib/css/preflight.css +2 -1
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +6 -2
- package/lib/lib/expandApplyAtRules.js +4 -4
- package/lib/lib/expandTailwindAtRules.js +2 -0
- package/lib/lib/generateRules.js +36 -0
- package/lib/lib/setupContextUtils.js +8 -65
- package/lib/lib/substituteScreenAtRules.js +7 -4
- package/lib/util/buildMediaQuery.js +13 -24
- package/lib/util/dataTypes.js +14 -3
- package/lib/util/formatVariantSelector.js +88 -4
- package/lib/util/isValidArbitraryValue.js +64 -0
- package/lib/util/nameClass.js +1 -0
- package/lib/util/normalizeScreens.js +61 -0
- package/lib/util/resolveConfig.js +8 -8
- package/package.json +10 -10
- package/peers/.svgo.yml +75 -0
- package/peers/index.js +3784 -3146
- package/peers/orders/concentric-css.json +299 -0
- package/peers/orders/smacss.json +299 -0
- package/peers/orders/source.json +295 -0
- package/src/.DS_Store +0 -0
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +114 -60
- package/src/css/preflight.css +2 -1
- package/src/lib/detectNesting.js +22 -3
- package/src/lib/evaluateTailwindFunctions.js +5 -2
- package/src/lib/expandTailwindAtRules.js +2 -0
- package/src/lib/generateRules.js +34 -0
- package/src/lib/setupContextUtils.js +6 -58
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/dataTypes.js +11 -6
- package/src/util/formatVariantSelector.js +92 -1
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/nameClass.js +1 -1
- package/src/util/normalizeScreens.js +45 -0
- package/stubs/defaultConfig.stub.js +17 -0
- package/CHANGELOG.md +0 -1825
package/lib/corePlugins.js
CHANGED
|
@@ -16,6 +16,7 @@ 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");
|
|
19
20
|
var _parseBoxShadowValue = require("./util/parseBoxShadowValue");
|
|
20
21
|
function _interopRequireDefault(obj) {
|
|
21
22
|
return obj && obj.__esModule ? obj : {
|
|
@@ -58,6 +59,7 @@ let variantPlugins = {
|
|
|
58
59
|
'&::selection'
|
|
59
60
|
]);
|
|
60
61
|
addVariant('file', '&::file-selector-button');
|
|
62
|
+
addVariant('placeholder', '&::placeholder');
|
|
61
63
|
addVariant('before', ({ container })=>{
|
|
62
64
|
container.walkRules((rule)=>{
|
|
63
65
|
let foundContent = false;
|
|
@@ -197,15 +199,18 @@ let variantPlugins = {
|
|
|
197
199
|
addVariant('print', '@media print');
|
|
198
200
|
},
|
|
199
201
|
screenVariants: ({ theme , addVariant })=>{
|
|
200
|
-
for(let screen
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
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}`);
|
|
204
205
|
}
|
|
206
|
+
},
|
|
207
|
+
orientationVariants: ({ addVariant })=>{
|
|
208
|
+
addVariant('portrait', '@media (orientation: portrait)');
|
|
209
|
+
addVariant('landscape', '@media (orientation: landscape)');
|
|
205
210
|
}
|
|
206
211
|
};
|
|
207
212
|
exports.variantPlugins = variantPlugins;
|
|
208
|
-
let
|
|
213
|
+
let corePlugins = {
|
|
209
214
|
preflight: ({ addBase })=>{
|
|
210
215
|
let preflightStyles = _postcss.default.parse(_fs.default.readFileSync(path.join(__dirname, './css/preflight.css'), 'utf8'));
|
|
211
216
|
addBase([
|
|
@@ -216,27 +221,11 @@ let corePlugins1 = {
|
|
|
216
221
|
]);
|
|
217
222
|
},
|
|
218
223
|
container: (()=>{
|
|
219
|
-
function extractMinWidths(
|
|
220
|
-
return
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
min: breakpoints
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
if (!Array.isArray(breakpoints)) {
|
|
228
|
-
breakpoints = [
|
|
229
|
-
breakpoints
|
|
230
|
-
];
|
|
231
|
-
}
|
|
232
|
-
return breakpoints.filter((breakpoint)=>{
|
|
233
|
-
var ref;
|
|
234
|
-
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'));
|
|
235
|
-
}).map((breakpoint)=>{
|
|
236
|
-
var ref;
|
|
237
|
-
return (ref = breakpoint['min-width']) !== null && ref !== void 0 ? ref : breakpoint.min;
|
|
238
|
-
});
|
|
239
|
-
});
|
|
224
|
+
function extractMinWidths(breakpoints = []) {
|
|
225
|
+
return breakpoints.flatMap((breakpoint1)=>breakpoint1.values.map((breakpoint)=>breakpoint.min
|
|
226
|
+
)
|
|
227
|
+
).filter((v)=>v !== undefined
|
|
228
|
+
);
|
|
240
229
|
}
|
|
241
230
|
function mapMinWidthsToPadding(minWidths, screens, paddings) {
|
|
242
231
|
if (typeof paddings === 'undefined') {
|
|
@@ -260,25 +249,25 @@ let corePlugins1 = {
|
|
|
260
249
|
});
|
|
261
250
|
}
|
|
262
251
|
for (let minWidth of minWidths){
|
|
263
|
-
for (let
|
|
264
|
-
let
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
252
|
+
for (let screen of screens){
|
|
253
|
+
for (let { min } of screen.values){
|
|
254
|
+
if (min === minWidth) {
|
|
255
|
+
mapping.push({
|
|
256
|
+
minWidth,
|
|
257
|
+
padding: paddings[screen.name]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
271
260
|
}
|
|
272
261
|
}
|
|
273
262
|
}
|
|
274
263
|
return mapping;
|
|
275
264
|
}
|
|
276
265
|
return function({ addComponents , theme }) {
|
|
277
|
-
let screens = theme('container.screens', theme('screens'));
|
|
266
|
+
let screens = (0, _normalizeScreens).normalizeScreens(theme('container.screens', theme('screens')));
|
|
278
267
|
let minWidths = extractMinWidths(screens);
|
|
279
268
|
let paddings = mapMinWidthsToPadding(minWidths, screens, theme('container.padding'));
|
|
280
269
|
let generatePaddingFor = (minWidth)=>{
|
|
281
|
-
let paddingConfig = paddings.find((padding)
|
|
270
|
+
let paddingConfig = paddings.find((padding)=>padding.minWidth === minWidth
|
|
282
271
|
);
|
|
283
272
|
if (!paddingConfig) {
|
|
284
273
|
return {
|
|
@@ -922,7 +911,9 @@ let corePlugins1 = {
|
|
|
922
911
|
],
|
|
923
912
|
],
|
|
924
913
|
],
|
|
925
|
-
]
|
|
914
|
+
], {
|
|
915
|
+
supportsNegativeValues: true
|
|
916
|
+
}),
|
|
926
917
|
transform: ({ addBase , addUtilities })=>{
|
|
927
918
|
addBase({
|
|
928
919
|
'@defaults transform': {
|
|
@@ -1010,7 +1001,15 @@ let corePlugins1 = {
|
|
|
1010
1001
|
});
|
|
1011
1002
|
},
|
|
1012
1003
|
cursor: (0, _createUtilityPlugin).default('cursor'),
|
|
1013
|
-
touchAction: ({ addUtilities })=>{
|
|
1004
|
+
touchAction: ({ addBase , addUtilities })=>{
|
|
1005
|
+
addBase({
|
|
1006
|
+
'@defaults touch-action': {
|
|
1007
|
+
'--tw-pan-x': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
1008
|
+
'--tw-pan-y': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
1009
|
+
'--tw-pinch-zoom': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
1010
|
+
'--tw-touch-action': 'var(--tw-pan-x) var(--tw-pan-y) var(--tw-pinch-zoom)'
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1014
1013
|
addUtilities({
|
|
1015
1014
|
'.touch-auto': {
|
|
1016
1015
|
'touch-action': 'auto'
|
|
@@ -1019,25 +1018,46 @@ let corePlugins1 = {
|
|
|
1019
1018
|
'touch-action': 'none'
|
|
1020
1019
|
},
|
|
1021
1020
|
'.touch-pan-x': {
|
|
1022
|
-
'touch-action':
|
|
1021
|
+
'@defaults touch-action': {
|
|
1022
|
+
},
|
|
1023
|
+
'--tw-pan-x': 'pan-x',
|
|
1024
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1023
1025
|
},
|
|
1024
1026
|
'.touch-pan-left': {
|
|
1025
|
-
'touch-action':
|
|
1027
|
+
'@defaults touch-action': {
|
|
1028
|
+
},
|
|
1029
|
+
'--tw-pan-x': 'pan-left',
|
|
1030
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1026
1031
|
},
|
|
1027
1032
|
'.touch-pan-right': {
|
|
1028
|
-
'touch-action':
|
|
1033
|
+
'@defaults touch-action': {
|
|
1034
|
+
},
|
|
1035
|
+
'--tw-pan-x': 'pan-right',
|
|
1036
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1029
1037
|
},
|
|
1030
1038
|
'.touch-pan-y': {
|
|
1031
|
-
'touch-action':
|
|
1039
|
+
'@defaults touch-action': {
|
|
1040
|
+
},
|
|
1041
|
+
'--tw-pan-y': 'pan-y',
|
|
1042
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1032
1043
|
},
|
|
1033
1044
|
'.touch-pan-up': {
|
|
1034
|
-
'touch-action':
|
|
1045
|
+
'@defaults touch-action': {
|
|
1046
|
+
},
|
|
1047
|
+
'--tw-pan-y': 'pan-up',
|
|
1048
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1035
1049
|
},
|
|
1036
1050
|
'.touch-pan-down': {
|
|
1037
|
-
'touch-action':
|
|
1051
|
+
'@defaults touch-action': {
|
|
1052
|
+
},
|
|
1053
|
+
'--tw-pan-y': 'pan-down',
|
|
1054
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1038
1055
|
},
|
|
1039
1056
|
'.touch-pinch-zoom': {
|
|
1040
|
-
'touch-action':
|
|
1057
|
+
'@defaults touch-action': {
|
|
1058
|
+
},
|
|
1059
|
+
'--tw-pinch-zoom': 'pinch-zoom',
|
|
1060
|
+
'touch-action': 'var(--tw-touch-action)'
|
|
1041
1061
|
},
|
|
1042
1062
|
'.touch-manipulation': {
|
|
1043
1063
|
'touch-action': 'manipulation'
|
|
@@ -1661,10 +1681,10 @@ let corePlugins1 = {
|
|
|
1661
1681
|
}
|
|
1662
1682
|
});
|
|
1663
1683
|
},
|
|
1664
|
-
divideColor: ({ matchUtilities , theme , corePlugins })=>{
|
|
1684
|
+
divideColor: ({ matchUtilities , theme , corePlugins: corePlugins1 })=>{
|
|
1665
1685
|
matchUtilities({
|
|
1666
1686
|
divide: (value)=>{
|
|
1667
|
-
if (!
|
|
1687
|
+
if (!corePlugins1('divideOpacity')) {
|
|
1668
1688
|
return {
|
|
1669
1689
|
['& > :not([hidden]) ~ :not([hidden])']: {
|
|
1670
1690
|
'border-color': (0, _toColorValue).default(value)
|
|
@@ -2075,8 +2095,8 @@ let corePlugins1 = {
|
|
|
2075
2095
|
}
|
|
2076
2096
|
});
|
|
2077
2097
|
},
|
|
2078
|
-
borderColor: ({ addBase , matchUtilities , theme , corePlugins })=>{
|
|
2079
|
-
if (!
|
|
2098
|
+
borderColor: ({ addBase , matchUtilities , theme , corePlugins: corePlugins2 })=>{
|
|
2099
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2080
2100
|
let value = theme('borderColor.DEFAULT', 'currentColor');
|
|
2081
2101
|
addBase({
|
|
2082
2102
|
'@defaults border-width': {
|
|
@@ -2094,7 +2114,7 @@ let corePlugins1 = {
|
|
|
2094
2114
|
}
|
|
2095
2115
|
matchUtilities({
|
|
2096
2116
|
border: (value)=>{
|
|
2097
|
-
if (!
|
|
2117
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2098
2118
|
return {
|
|
2099
2119
|
'border-color': (0, _toColorValue).default(value)
|
|
2100
2120
|
};
|
|
@@ -2114,7 +2134,7 @@ let corePlugins1 = {
|
|
|
2114
2134
|
});
|
|
2115
2135
|
matchUtilities({
|
|
2116
2136
|
'border-x': (value)=>{
|
|
2117
|
-
if (!
|
|
2137
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2118
2138
|
return {
|
|
2119
2139
|
'border-left-color': (0, _toColorValue).default(value),
|
|
2120
2140
|
'border-right-color': (0, _toColorValue).default(value)
|
|
@@ -2130,7 +2150,7 @@ let corePlugins1 = {
|
|
|
2130
2150
|
});
|
|
2131
2151
|
},
|
|
2132
2152
|
'border-y': (value)=>{
|
|
2133
|
-
if (!
|
|
2153
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2134
2154
|
return {
|
|
2135
2155
|
'border-top-color': (0, _toColorValue).default(value),
|
|
2136
2156
|
'border-bottom-color': (0, _toColorValue).default(value)
|
|
@@ -2152,7 +2172,7 @@ let corePlugins1 = {
|
|
|
2152
2172
|
});
|
|
2153
2173
|
matchUtilities({
|
|
2154
2174
|
'border-t': (value)=>{
|
|
2155
|
-
if (!
|
|
2175
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2156
2176
|
return {
|
|
2157
2177
|
'border-top-color': (0, _toColorValue).default(value)
|
|
2158
2178
|
};
|
|
@@ -2164,7 +2184,7 @@ let corePlugins1 = {
|
|
|
2164
2184
|
});
|
|
2165
2185
|
},
|
|
2166
2186
|
'border-r': (value)=>{
|
|
2167
|
-
if (!
|
|
2187
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2168
2188
|
return {
|
|
2169
2189
|
'border-right-color': (0, _toColorValue).default(value)
|
|
2170
2190
|
};
|
|
@@ -2176,7 +2196,7 @@ let corePlugins1 = {
|
|
|
2176
2196
|
});
|
|
2177
2197
|
},
|
|
2178
2198
|
'border-b': (value)=>{
|
|
2179
|
-
if (!
|
|
2199
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2180
2200
|
return {
|
|
2181
2201
|
'border-bottom-color': (0, _toColorValue).default(value)
|
|
2182
2202
|
};
|
|
@@ -2188,7 +2208,7 @@ let corePlugins1 = {
|
|
|
2188
2208
|
});
|
|
2189
2209
|
},
|
|
2190
2210
|
'border-l': (value)=>{
|
|
2191
|
-
if (!
|
|
2211
|
+
if (!corePlugins2('borderOpacity')) {
|
|
2192
2212
|
return {
|
|
2193
2213
|
'border-left-color': (0, _toColorValue).default(value)
|
|
2194
2214
|
};
|
|
@@ -2213,10 +2233,10 @@ let corePlugins1 = {
|
|
|
2213
2233
|
]
|
|
2214
2234
|
],
|
|
2215
2235
|
]),
|
|
2216
|
-
backgroundColor: ({ matchUtilities , theme , corePlugins })=>{
|
|
2236
|
+
backgroundColor: ({ matchUtilities , theme , corePlugins: corePlugins3 })=>{
|
|
2217
2237
|
matchUtilities({
|
|
2218
2238
|
bg: (value)=>{
|
|
2219
|
-
if (!
|
|
2239
|
+
if (!corePlugins3('backgroundOpacity')) {
|
|
2220
2240
|
return {
|
|
2221
2241
|
'background-color': (0, _toColorValue).default(value)
|
|
2222
2242
|
};
|
|
@@ -2297,6 +2317,12 @@ let corePlugins1 = {
|
|
|
2297
2317
|
},
|
|
2298
2318
|
'.decoration-clone': {
|
|
2299
2319
|
'box-decoration-break': 'clone'
|
|
2320
|
+
},
|
|
2321
|
+
'.box-decoration-slice': {
|
|
2322
|
+
'box-decoration-break': 'slice'
|
|
2323
|
+
},
|
|
2324
|
+
'.box-decoration-clone': {
|
|
2325
|
+
'box-decoration-break': 'clone'
|
|
2300
2326
|
}
|
|
2301
2327
|
});
|
|
2302
2328
|
},
|
|
@@ -2736,10 +2762,10 @@ let corePlugins1 = {
|
|
|
2736
2762
|
], {
|
|
2737
2763
|
supportsNegativeValues: true
|
|
2738
2764
|
}),
|
|
2739
|
-
textColor: ({ matchUtilities , theme , corePlugins })=>{
|
|
2765
|
+
textColor: ({ matchUtilities , theme , corePlugins: corePlugins4 })=>{
|
|
2740
2766
|
matchUtilities({
|
|
2741
2767
|
text: (value)=>{
|
|
2742
|
-
if (!
|
|
2768
|
+
if (!corePlugins4('textOpacity')) {
|
|
2743
2769
|
return {
|
|
2744
2770
|
color: (0, _toColorValue).default(value)
|
|
2745
2771
|
};
|
|
@@ -2768,6 +2794,9 @@ let corePlugins1 = {
|
|
|
2768
2794
|
'.underline': {
|
|
2769
2795
|
'text-decoration': 'underline'
|
|
2770
2796
|
},
|
|
2797
|
+
'.overline': {
|
|
2798
|
+
'text-decoration': 'overline'
|
|
2799
|
+
},
|
|
2771
2800
|
'.line-through': {
|
|
2772
2801
|
'text-decoration': 'line-through'
|
|
2773
2802
|
},
|
|
@@ -2786,11 +2815,55 @@ let corePlugins1 = {
|
|
|
2786
2815
|
}, {
|
|
2787
2816
|
values: (0, _flattenColorPalette).default(theme('textDecorationColor')),
|
|
2788
2817
|
type: [
|
|
2789
|
-
'color'
|
|
2790
|
-
'any'
|
|
2818
|
+
'color'
|
|
2791
2819
|
]
|
|
2792
2820
|
});
|
|
2793
2821
|
},
|
|
2822
|
+
textDecorationStyle: ({ addUtilities })=>{
|
|
2823
|
+
addUtilities({
|
|
2824
|
+
'.decoration-solid': {
|
|
2825
|
+
'text-decoration-style': 'solid'
|
|
2826
|
+
},
|
|
2827
|
+
'.decoration-double': {
|
|
2828
|
+
'text-decoration-style': 'double'
|
|
2829
|
+
},
|
|
2830
|
+
'.decoration-dotted': {
|
|
2831
|
+
'text-decoration-style': 'dotted'
|
|
2832
|
+
},
|
|
2833
|
+
'.decoration-dashed': {
|
|
2834
|
+
'text-decoration-style': 'dashed'
|
|
2835
|
+
},
|
|
2836
|
+
'.decoration-wavy': {
|
|
2837
|
+
'text-decoration-style': 'wavy'
|
|
2838
|
+
}
|
|
2839
|
+
});
|
|
2840
|
+
},
|
|
2841
|
+
textDecorationThickness: (0, _createUtilityPlugin).default('textDecorationThickness', [
|
|
2842
|
+
[
|
|
2843
|
+
'decoration',
|
|
2844
|
+
[
|
|
2845
|
+
'text-decoration-thickness'
|
|
2846
|
+
]
|
|
2847
|
+
]
|
|
2848
|
+
], {
|
|
2849
|
+
type: [
|
|
2850
|
+
'length',
|
|
2851
|
+
'percentage'
|
|
2852
|
+
]
|
|
2853
|
+
}),
|
|
2854
|
+
textUnderlineOffset: (0, _createUtilityPlugin).default('textUnderlineOffset', [
|
|
2855
|
+
[
|
|
2856
|
+
'underline-offset',
|
|
2857
|
+
[
|
|
2858
|
+
'text-underline-offset'
|
|
2859
|
+
]
|
|
2860
|
+
]
|
|
2861
|
+
], {
|
|
2862
|
+
type: [
|
|
2863
|
+
'length',
|
|
2864
|
+
'percentage'
|
|
2865
|
+
]
|
|
2866
|
+
}),
|
|
2794
2867
|
fontSmoothing: ({ addUtilities })=>{
|
|
2795
2868
|
addUtilities({
|
|
2796
2869
|
'.antialiased': {
|
|
@@ -2803,10 +2876,10 @@ let corePlugins1 = {
|
|
|
2803
2876
|
}
|
|
2804
2877
|
});
|
|
2805
2878
|
},
|
|
2806
|
-
placeholderColor: ({ matchUtilities , theme , corePlugins })=>{
|
|
2879
|
+
placeholderColor: ({ matchUtilities , theme , corePlugins: corePlugins5 })=>{
|
|
2807
2880
|
matchUtilities({
|
|
2808
2881
|
placeholder: (value)=>{
|
|
2809
|
-
if (!
|
|
2882
|
+
if (!corePlugins5('placeholderOpacity')) {
|
|
2810
2883
|
return {
|
|
2811
2884
|
'&::placeholder': {
|
|
2812
2885
|
color: (0, _toColorValue).default(value)
|
|
@@ -3589,4 +3662,4 @@ let corePlugins1 = {
|
|
|
3589
3662
|
],
|
|
3590
3663
|
])
|
|
3591
3664
|
};
|
|
3592
|
-
exports.corePlugins =
|
|
3665
|
+
exports.corePlugins = corePlugins;
|
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)=>{
|
|
@@ -12,9 +12,9 @@ function _interopRequireDefault(obj) {
|
|
|
12
12
|
default: obj
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
return typeof
|
|
15
|
+
function prefix(context, selector) {
|
|
16
|
+
let prefix1 = context.tailwindConfig.prefix;
|
|
17
|
+
return typeof prefix1 === 'function' ? prefix1(selector) : prefix1 + selector;
|
|
18
18
|
}
|
|
19
19
|
function buildApplyCache(applyCandidates, context) {
|
|
20
20
|
for (let candidate of applyCandidates){
|
|
@@ -156,7 +156,7 @@ function processApply(root, context) {
|
|
|
156
156
|
}
|
|
157
157
|
for (let applyCandidate of applyCandidates){
|
|
158
158
|
if (!applyClassCache.has(applyCandidate)) {
|
|
159
|
-
if (applyCandidate ===
|
|
159
|
+
if (applyCandidate === prefix(context, 'group')) {
|
|
160
160
|
// TODO: Link to specific documentation page with error code.
|
|
161
161
|
throw apply.error(`@apply should not be used with the '${applyCandidate}' utility`);
|
|
162
162
|
}
|
|
@@ -46,6 +46,8 @@ const PATTERNS = [
|
|
|
46
46
|
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source,
|
|
47
47
|
/([^<>"'`\s]*\['[^"'`\s]*'\])/.source,
|
|
48
48
|
/([^<>"'`\s]*\["[^"'`\s]*"\])/.source,
|
|
49
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:'[^"'`\s]*'\])/.source,
|
|
50
|
+
/([^<>"'`\s]*\[[^<>"'`\s]*:"[^"'`\s]*"\])/.source,
|
|
49
51
|
/([^<>"'`\s]*\[[^"'`\s]+\][^<>"'`\s]*)/.source,
|
|
50
52
|
/([^<>"'`\s]*[^"'`\s:])/.source
|
|
51
53
|
].join('|');
|
package/lib/lib/generateRules.js
CHANGED
|
@@ -11,6 +11,9 @@ var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
|
|
|
11
11
|
var _pluginUtils = require("../util/pluginUtils");
|
|
12
12
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
13
13
|
var _formatVariantSelector = require("../util/formatVariantSelector");
|
|
14
|
+
var _nameClass = require("../util/nameClass");
|
|
15
|
+
var _dataTypes = require("../util/dataTypes");
|
|
16
|
+
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
14
17
|
function _interopRequireDefault(obj) {
|
|
15
18
|
return obj && obj.__esModule ? obj : {
|
|
16
19
|
default: obj
|
|
@@ -250,6 +253,31 @@ function parseRules(rule, cache, options = {
|
|
|
250
253
|
options
|
|
251
254
|
];
|
|
252
255
|
}
|
|
256
|
+
function extractArbitraryProperty(classCandidate, context) {
|
|
257
|
+
var ref;
|
|
258
|
+
let [, property, value] = (ref = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && ref !== void 0 ? ref : [];
|
|
259
|
+
if (value === undefined) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
let normalized = (0, _dataTypes).normalize(value);
|
|
263
|
+
if (!(0, _isValidArbitraryValue).default(normalized)) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
return [
|
|
267
|
+
[
|
|
268
|
+
{
|
|
269
|
+
sort: context.arbitraryPropertiesSort,
|
|
270
|
+
layer: 'utilities'
|
|
271
|
+
},
|
|
272
|
+
()=>({
|
|
273
|
+
[(0, _nameClass).asClass(classCandidate)]: {
|
|
274
|
+
[property]: normalized
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
,
|
|
278
|
+
],
|
|
279
|
+
];
|
|
280
|
+
}
|
|
253
281
|
function* resolveMatchedPlugins(classCandidate, context) {
|
|
254
282
|
if (context.candidateRuleMap.has(classCandidate)) {
|
|
255
283
|
yield [
|
|
@@ -257,6 +285,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
|
|
|
257
285
|
'DEFAULT'
|
|
258
286
|
];
|
|
259
287
|
}
|
|
288
|
+
yield* (function*(arbitraryPropertyRule) {
|
|
289
|
+
if (arbitraryPropertyRule !== null) {
|
|
290
|
+
yield [
|
|
291
|
+
arbitraryPropertyRule,
|
|
292
|
+
'DEFAULT'
|
|
293
|
+
];
|
|
294
|
+
}
|
|
295
|
+
})(extractArbitraryProperty(classCandidate, context));
|
|
260
296
|
let candidatePrefix = classCandidate;
|
|
261
297
|
let negative = false;
|
|
262
298
|
const twConfigPrefix = context.tailwindConfig.prefix;
|
|
@@ -23,6 +23,7 @@ var sharedState = _interopRequireWildcard(require("./sharedState"));
|
|
|
23
23
|
var _toPath = require("../util/toPath");
|
|
24
24
|
var _log = _interopRequireDefault(require("../util/log"));
|
|
25
25
|
var _negateValue = _interopRequireDefault(require("../util/negateValue"));
|
|
26
|
+
var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
|
|
26
27
|
function _interopRequireDefault(obj) {
|
|
27
28
|
return obj && obj.__esModule ? obj : {
|
|
28
29
|
default: obj
|
|
@@ -160,68 +161,6 @@ function withIdentifiers(styles) {
|
|
|
160
161
|
});
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
|
-
let matchingBrackets = new Map([
|
|
164
|
-
[
|
|
165
|
-
'{',
|
|
166
|
-
'}'
|
|
167
|
-
],
|
|
168
|
-
[
|
|
169
|
-
'[',
|
|
170
|
-
']'
|
|
171
|
-
],
|
|
172
|
-
[
|
|
173
|
-
'(',
|
|
174
|
-
')'
|
|
175
|
-
],
|
|
176
|
-
]);
|
|
177
|
-
let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
|
|
178
|
-
v,
|
|
179
|
-
k
|
|
180
|
-
]
|
|
181
|
-
));
|
|
182
|
-
let quotes = new Set([
|
|
183
|
-
'"',
|
|
184
|
-
"'",
|
|
185
|
-
'`'
|
|
186
|
-
]);
|
|
187
|
-
// Arbitrary values must contain balanced brackets (), [] and {}. Escaped
|
|
188
|
-
// values don't count, and brackets inside quotes also don't count.
|
|
189
|
-
//
|
|
190
|
-
// E.g.: w-[this-is]w-[weird-and-invalid]
|
|
191
|
-
// E.g.: w-[this-is\\]w-\\[weird-but-valid]
|
|
192
|
-
// E.g.: content-['this-is-also-valid]-weirdly-enough']
|
|
193
|
-
function isValidArbitraryValue(value) {
|
|
194
|
-
let stack = [];
|
|
195
|
-
let inQuotes = false;
|
|
196
|
-
for(let i = 0; i < value.length; i++){
|
|
197
|
-
let char = value[i];
|
|
198
|
-
// Non-escaped quotes allow us to "allow" anything in between
|
|
199
|
-
if (quotes.has(char) && value[i - 1] !== '\\') {
|
|
200
|
-
inQuotes = !inQuotes;
|
|
201
|
-
}
|
|
202
|
-
if (inQuotes) continue;
|
|
203
|
-
if (value[i - 1] === '\\') continue; // Escaped
|
|
204
|
-
if (matchingBrackets.has(char)) {
|
|
205
|
-
stack.push(char);
|
|
206
|
-
} else if (inverseMatchingBrackets.has(char)) {
|
|
207
|
-
let inverse = inverseMatchingBrackets.get(char);
|
|
208
|
-
// Nothing to pop from, therefore it is unbalanced
|
|
209
|
-
if (stack.length <= 0) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
// Popped value must match the inverse value, otherwise it is unbalanced
|
|
213
|
-
if (stack.pop() !== inverse) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// If there is still something on the stack, it is also unbalanced
|
|
219
|
-
if (stack.length > 0) {
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
// All good, totally balanced!
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
164
|
function buildPluginApi(tailwindConfig, context, { variantList , variantMap , offsets , classList }) {
|
|
226
165
|
function getConfigValue(path, defaultValue) {
|
|
227
166
|
return path ? (0, _dlv).default(tailwindConfig, path, defaultValue) : tailwindConfig;
|
|
@@ -409,7 +348,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
409
348
|
if (!type.includes(coercedType) && !isOnlyPlugin) {
|
|
410
349
|
return [];
|
|
411
350
|
}
|
|
412
|
-
if (!
|
|
351
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
413
352
|
return [];
|
|
414
353
|
}
|
|
415
354
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -466,7 +405,7 @@ function buildPluginApi(tailwindConfig, context, { variantList , variantMap , of
|
|
|
466
405
|
return [];
|
|
467
406
|
}
|
|
468
407
|
}
|
|
469
|
-
if (!
|
|
408
|
+
if (!(0, _isValidArbitraryValue).default(value)) {
|
|
470
409
|
return [];
|
|
471
410
|
}
|
|
472
411
|
let ruleSets = [].concat(rule(value)).filter(Boolean).map((declaration)=>({
|
|
@@ -608,7 +547,8 @@ function resolvePlugins(context, root) {
|
|
|
608
547
|
_corePlugins.variantPlugins['reducedMotionVariants'],
|
|
609
548
|
_corePlugins.variantPlugins['darkVariants'],
|
|
610
549
|
_corePlugins.variantPlugins['printVariant'],
|
|
611
|
-
_corePlugins.variantPlugins['screenVariants'],
|
|
550
|
+
_corePlugins.variantPlugins['screenVariants'],
|
|
551
|
+
_corePlugins.variantPlugins['orientationVariants'],
|
|
612
552
|
];
|
|
613
553
|
return [
|
|
614
554
|
...corePluginList,
|
|
@@ -652,6 +592,9 @@ function registerPlugins(plugins, context) {
|
|
|
652
592
|
offsets.user,
|
|
653
593
|
]);
|
|
654
594
|
let reservedBits = BigInt(highestOffset.toString(2).length);
|
|
595
|
+
// A number one less than the top range of the highest offset area
|
|
596
|
+
// so arbitrary properties are always sorted at the end.
|
|
597
|
+
context.arbitraryPropertiesSort = (1n << reservedBits << 0n) - 1n;
|
|
655
598
|
context.layerOrder = {
|
|
656
599
|
base: 1n << reservedBits << 0n,
|
|
657
600
|
components: 1n << reservedBits << 1n,
|