tailwindcss 0.0.0-insiders.a6bcd22 → 0.0.0-insiders.a6f7a72
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 +27 -1
- package/lib/corePluginList.js +3 -0
- package/lib/corePlugins.js +119 -46
- package/lib/css/preflight.css +2 -1
- package/lib/lib/detectNesting.js +17 -2
- package/lib/lib/evaluateTailwindFunctions.js +6 -2
- 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 +58 -0
- package/package.json +9 -9
- package/peers/index.js +3713 -3001
- 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 +42 -0
- package/stubs/defaultConfig.stub.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,31 @@ 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 composable `touch-action` utilities ([#6115](https://github.com/tailwindlabs/tailwindcss/pull/6115))
|
|
19
|
+
- Add support for "arbitrary properties" ([#6161](https://github.com/tailwindlabs/tailwindcss/pull/6161))
|
|
20
|
+
- Add `portrait` and `landscape` variants ([#6046](https://github.com/tailwindlabs/tailwindcss/pull/6046))
|
|
21
|
+
- Add `text-decoration-style`, `text-decoration-thickness`, and `text-underline-offset` utilities ([#6004](https://github.com/tailwindlabs/tailwindcss/pull/6004))
|
|
22
|
+
- Add `menu` reset to preflight ([#6213](https://github.com/tailwindlabs/tailwindcss/pull/6213))
|
|
23
|
+
- Allow `0` as a valid `length` value ([#6233](https://github.com/tailwindlabs/tailwindcss/pull/6233), [#6259](https://github.com/tailwindlabs/tailwindcss/pull/6259))
|
|
24
|
+
- Add CSS functions to data types ([#6258](https://github.com/tailwindlabs/tailwindcss/pull/6258))
|
|
25
|
+
- Add CSS functions to data types ([#6258](https://github.com/tailwindlabs/tailwindcss/pull/6258))
|
|
26
|
+
- Support negative values for `scale-*` utilities ([c48e629](https://github.com/tailwindlabs/tailwindcss/commit/c48e629955585ad18dadba9f470fda59cc448ab7))
|
|
27
|
+
- Improve `length` data type, by validating each value individually ([#6283](https://github.com/tailwindlabs/tailwindcss/pull/6283))
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Deprecate `decoration-slice` and `decoration-break` in favor `box-decoration-slice` and `box-decoration-break` _(non-breaking)_ ([#6004](https://github.com/tailwindlabs/tailwindcss/pull/6004))
|
|
32
|
+
|
|
33
|
+
## [3.0.0-alpha.2] - 2021-11-08
|
|
34
|
+
|
|
10
35
|
### Changed
|
|
11
36
|
|
|
12
37
|
- Don't use pointer cursor on disabled buttons by default ([#5772](https://github.com/tailwindlabs/tailwindcss/pull/5772))
|
|
@@ -1653,7 +1678,8 @@ No release notes
|
|
|
1653
1678
|
|
|
1654
1679
|
- Everything!
|
|
1655
1680
|
|
|
1656
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.0-alpha.
|
|
1681
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.0-alpha.2...HEAD
|
|
1682
|
+
[3.0.0-alpha.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.0-alpha.1...v3.0.0-alpha.2
|
|
1657
1683
|
[3.0.0-alpha.1]: https://github.com/tailwindlabs/tailwindcss/compare/v2.2.19...v3.0.0-alpha.1
|
|
1658
1684
|
[2.2.19]: https://github.com/tailwindlabs/tailwindcss/compare/v2.2.18...v2.2.19
|
|
1659
1685
|
[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,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,11 +199,14 @@ 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;
|
|
@@ -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'
|
|
@@ -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
|
},
|
|
@@ -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': {
|
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)=>{
|
|
@@ -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,
|
|
@@ -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
|
}
|