tailwindcss 3.0.0-alpha.1 → 3.0.2

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.
Files changed (73) hide show
  1. package/colors.js +2 -1
  2. package/defaultConfig.js +2 -1
  3. package/defaultTheme.js +2 -1
  4. package/lib/cli.js +39 -35
  5. package/lib/constants.js +1 -1
  6. package/lib/corePluginList.js +10 -1
  7. package/lib/corePlugins.js +393 -259
  8. package/lib/css/preflight.css +14 -1
  9. package/lib/featureFlags.js +12 -7
  10. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  11. package/lib/lib/detectNesting.js +17 -2
  12. package/lib/lib/evaluateTailwindFunctions.js +9 -5
  13. package/lib/lib/expandApplyAtRules.js +26 -9
  14. package/lib/lib/expandTailwindAtRules.js +4 -1
  15. package/lib/lib/generateRules.js +151 -19
  16. package/lib/lib/resolveDefaultsAtRules.js +67 -56
  17. package/lib/lib/setupContextUtils.js +80 -80
  18. package/lib/lib/setupWatchingContext.js +5 -1
  19. package/lib/lib/sharedState.js +2 -2
  20. package/lib/lib/substituteScreenAtRules.js +7 -4
  21. package/lib/processTailwindFeatures.js +4 -0
  22. package/lib/util/buildMediaQuery.js +13 -24
  23. package/lib/util/createUtilityPlugin.js +5 -5
  24. package/lib/util/dataTypes.js +38 -7
  25. package/lib/util/formatVariantSelector.js +186 -0
  26. package/lib/util/isValidArbitraryValue.js +64 -0
  27. package/lib/util/nameClass.js +2 -1
  28. package/lib/util/negateValue.js +3 -1
  29. package/lib/util/normalizeConfig.js +22 -8
  30. package/lib/util/normalizeScreens.js +61 -0
  31. package/lib/util/parseBoxShadowValue.js +77 -0
  32. package/lib/util/pluginUtils.js +62 -158
  33. package/lib/util/prefixSelector.js +1 -3
  34. package/lib/util/resolveConfig.js +17 -13
  35. package/lib/util/transformThemeValue.js +23 -13
  36. package/package.json +15 -15
  37. package/peers/index.js +4456 -5450
  38. package/plugin.js +2 -1
  39. package/resolveConfig.js +2 -1
  40. package/src/.DS_Store +0 -0
  41. package/src/cli.js +9 -2
  42. package/src/corePluginList.js +1 -1
  43. package/src/corePlugins.js +392 -404
  44. package/src/css/preflight.css +14 -1
  45. package/src/featureFlags.js +14 -4
  46. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  47. package/src/lib/detectNesting.js +22 -3
  48. package/src/lib/evaluateTailwindFunctions.js +5 -2
  49. package/src/lib/expandApplyAtRules.js +29 -2
  50. package/src/lib/expandTailwindAtRules.js +5 -2
  51. package/src/lib/generateRules.js +155 -11
  52. package/src/lib/resolveDefaultsAtRules.js +67 -50
  53. package/src/lib/setupContextUtils.js +77 -67
  54. package/src/lib/setupWatchingContext.js +7 -0
  55. package/src/lib/sharedState.js +1 -1
  56. package/src/lib/substituteScreenAtRules.js +6 -3
  57. package/src/processTailwindFeatures.js +5 -0
  58. package/src/util/buildMediaQuery.js +14 -18
  59. package/src/util/createUtilityPlugin.js +2 -2
  60. package/src/util/dataTypes.js +43 -11
  61. package/src/util/formatVariantSelector.js +196 -0
  62. package/src/util/isValidArbitraryValue.js +61 -0
  63. package/src/util/nameClass.js +2 -2
  64. package/src/util/negateValue.js +4 -2
  65. package/src/util/normalizeConfig.js +17 -1
  66. package/src/util/normalizeScreens.js +45 -0
  67. package/src/util/parseBoxShadowValue.js +71 -0
  68. package/src/util/pluginUtils.js +50 -146
  69. package/src/util/prefixSelector.js +1 -4
  70. package/src/util/resolveConfig.js +7 -1
  71. package/src/util/transformThemeValue.js +22 -7
  72. package/stubs/defaultConfig.stub.js +118 -58
  73. package/CHANGELOG.md +0 -1759
@@ -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,19 +18,35 @@ exports.genericName = genericName;
17
18
  exports.absoluteSize = absoluteSize;
18
19
  exports.relativeSize = relativeSize;
19
20
  var _color = require("./color");
21
+ var _parseBoxShadowValue = require("./parseBoxShadowValue");
22
+ let cssFunctions = [
23
+ 'min',
24
+ 'max',
25
+ 'clamp',
26
+ 'calc'
27
+ ];
20
28
  // Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
21
29
  let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
22
30
  ;
23
31
  let UNDERSCORE = /_(?![^(]*\))/g // Underscore separator that is not located between brackets. E.g.: `rgba(255,_255,_255)_black` these don't count.
24
32
  ;
25
- function normalize(value) {
33
+ function normalize(value, isRoot = true) {
34
+ // Keep raw strings if it starts with `url(`
35
+ if (value.includes('url(')) {
36
+ return value.split(/(url\(.*?\))/g).filter(Boolean).map((part)=>{
37
+ if (/^url\(.*?\)$/.test(part)) {
38
+ return part;
39
+ }
40
+ return normalize(part, false);
41
+ }).join('');
42
+ }
26
43
  // Convert `_` to ` `, except for escaped underscores `\_`
27
44
  value = value.replace(/([^\\])_+/g, (fullMatch, characterBefore)=>characterBefore + ' '.repeat(fullMatch.length - 1)
28
45
  ).replace(/^_/g, ' ').replace(/\\_/g, '_');
29
46
  // Remove leftover whitespace
30
- value = value.trim();
31
- // Keep raw strings if it starts with `url(`
32
- if (value.startsWith('url(')) return value;
47
+ if (isRoot) {
48
+ value = value.trim();
49
+ }
33
50
  // Add spaces around operators inside calc() that do not follow an operator
34
51
  // or '('.
35
52
  return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ');
@@ -38,10 +55,12 @@ function url(value) {
38
55
  return value.startsWith('url(');
39
56
  }
40
57
  function number(value) {
41
- return !isNaN(Number(value));
58
+ return !isNaN(Number(value)) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?`).test(value)
59
+ );
42
60
  }
43
61
  function percentage(value) {
44
- return /%$/g.test(value) || /^calc\(.+?%\)/g.test(value);
62
+ return /%$/g.test(value) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?%`).test(value)
63
+ );
45
64
  }
46
65
  let lengthUnits = [
47
66
  'cm',
@@ -63,7 +82,10 @@ let lengthUnits = [
63
82
  ];
64
83
  let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`;
65
84
  function length(value) {
66
- return new RegExp(`${lengthUnitsPattern}$`).test(value) || new RegExp(`^calc\\(.+?${lengthUnitsPattern}`).test(value);
85
+ return value.split(UNDERSCORE).every((part)=>{
86
+ return part === '0' || new RegExp(`${lengthUnitsPattern}$`).test(part) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(part)
87
+ );
88
+ });
67
89
  }
68
90
  let lineWidths = new Set([
69
91
  'thin',
@@ -73,6 +95,15 @@ let lineWidths = new Set([
73
95
  function lineWidth(value) {
74
96
  return lineWidths.has(value);
75
97
  }
98
+ function shadow(value) {
99
+ let parsedShadows = (0, _parseBoxShadowValue).parseBoxShadowValue(normalize(value));
100
+ for (let parsedShadow of parsedShadows){
101
+ if (!parsedShadow.valid) {
102
+ return false;
103
+ }
104
+ }
105
+ return true;
106
+ }
76
107
  function color(value) {
77
108
  let colors = 0;
78
109
  let result = value.split(UNDERSCORE).every((part)=>{
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.formatVariantSelector = formatVariantSelector;
6
+ exports.finalizeSelector = finalizeSelector;
7
+ exports.selectorFunctions = void 0;
8
+ var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
9
+ var _unesc = _interopRequireDefault(require("postcss-selector-parser/dist/util/unesc"));
10
+ var _escapeClassName = _interopRequireDefault(require("../util/escapeClassName"));
11
+ var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ let MERGE = ':merge';
18
+ let PARENT = '&';
19
+ let selectorFunctions = new Set([
20
+ MERGE
21
+ ]);
22
+ exports.selectorFunctions = selectorFunctions;
23
+ function formatVariantSelector(current, ...others) {
24
+ for (let other of others){
25
+ let incomingValue = resolveFunctionArgument(other, MERGE);
26
+ if (incomingValue !== null) {
27
+ let existingValue = resolveFunctionArgument(current, MERGE, incomingValue);
28
+ if (existingValue !== null) {
29
+ let existingTarget = `${MERGE}(${incomingValue})`;
30
+ let splitIdx = other.indexOf(existingTarget);
31
+ let addition = other.slice(splitIdx + existingTarget.length).split(' ')[0];
32
+ current = current.replace(existingTarget, existingTarget + addition);
33
+ continue;
34
+ }
35
+ }
36
+ current = other.replace(PARENT, current);
37
+ }
38
+ return current;
39
+ }
40
+ function finalizeSelector(format, { selector: selector1 , candidate , context }) {
41
+ var ref, ref1;
42
+ var ref2;
43
+ let separator = (ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ':';
44
+ // Split by the separator, but ignore the separator inside square brackets:
45
+ //
46
+ // E.g.: dark:lg:hover:[paint-order:markers]
47
+ // ┬ ┬ ┬ ┬
48
+ // │ │ │ ╰── We will not split here
49
+ // ╰──┴─────┴─────────────── We will split here
50
+ //
51
+ let splitter = new RegExp(`\\${separator}(?![^[]*\\])`);
52
+ let base = candidate.split(splitter).pop();
53
+ if (context === null || context === void 0 ? void 0 : (ref1 = context.tailwindConfig) === null || ref1 === void 0 ? void 0 : ref1.prefix) {
54
+ format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
55
+ }
56
+ format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
57
+ // Normalize escaped classes, e.g.:
58
+ //
59
+ // The idea would be to replace the escaped `base` in the selector with the
60
+ // `format`. However, in css you can escape the same selector in a few
61
+ // different ways. This would result in different strings and therefore we
62
+ // can't replace it properly.
63
+ //
64
+ // base: bg-[rgb(255,0,0)]
65
+ // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
66
+ // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
67
+ //
68
+ selector1 = (0, _postcssSelectorParser).default((selectors)=>{
69
+ return selectors.walkClasses((node)=>{
70
+ if (node.raws && node.value.includes(base)) {
71
+ node.raws.value = (0, _escapeClassName).default((0, _unesc).default(node.raws.value));
72
+ }
73
+ return node;
74
+ });
75
+ }).processSync(selector1);
76
+ // We can safely replace the escaped base now, since the `base` section is
77
+ // now in a normalized escaped value.
78
+ selector1 = selector1.replace(`.${(0, _escapeClassName).default(base)}`, format);
79
+ // Remove unnecessary pseudo selectors that we used as placeholders
80
+ return (0, _postcssSelectorParser).default((selectors)=>{
81
+ return selectors.map((selector2)=>{
82
+ selector2.walkPseudos((p)=>{
83
+ if (selectorFunctions.has(p.value)) {
84
+ p.replaceWith(p.nodes);
85
+ }
86
+ return p;
87
+ });
88
+ // This will make sure to move pseudo's to the correct spot (the end for
89
+ // pseudo elements) because otherwise the selector will never work
90
+ // anyway.
91
+ //
92
+ // E.g.:
93
+ // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
94
+ // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
95
+ //
96
+ // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
97
+ function collectPseudoElements(selector) {
98
+ let nodes = [];
99
+ for (let node of selector.nodes){
100
+ if (isPseudoElement(node)) {
101
+ nodes.push(node);
102
+ selector.removeChild(node);
103
+ }
104
+ if (node === null || node === void 0 ? void 0 : node.nodes) {
105
+ nodes.push(...collectPseudoElements(node));
106
+ }
107
+ }
108
+ return nodes;
109
+ }
110
+ let pseudoElements = collectPseudoElements(selector2);
111
+ if (pseudoElements.length > 0) {
112
+ selector2.nodes.push(pseudoElements.sort(sortSelector));
113
+ }
114
+ return selector2;
115
+ });
116
+ }).processSync(selector1);
117
+ }
118
+ // Note: As a rule, double colons (::) should be used instead of a single colon
119
+ // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
120
+ // this distinction was not present in older versions of the W3C spec, most
121
+ // browsers support both syntaxes for the original pseudo-elements.
122
+ let pseudoElementsBC = [
123
+ ':before',
124
+ ':after',
125
+ ':first-line',
126
+ ':first-letter'
127
+ ];
128
+ // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
129
+ let pseudoElementExceptions = [
130
+ '::file-selector-button'
131
+ ];
132
+ // This will make sure to move pseudo's to the correct spot (the end for
133
+ // pseudo elements) because otherwise the selector will never work
134
+ // anyway.
135
+ //
136
+ // E.g.:
137
+ // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
138
+ // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
139
+ //
140
+ // `::before:hover` doesn't work, which means that we can make it work
141
+ // for you by flipping the order.
142
+ function sortSelector(a, z) {
143
+ // Both nodes are non-pseudo's so we can safely ignore them and keep
144
+ // them in the same order.
145
+ if (a.type !== 'pseudo' && z.type !== 'pseudo') {
146
+ return 0;
147
+ }
148
+ // If one of them is a combinator, we need to keep it in the same order
149
+ // because that means it will start a new "section" in the selector.
150
+ if (a.type === 'combinator' ^ z.type === 'combinator') {
151
+ return 0;
152
+ }
153
+ // One of the items is a pseudo and the other one isn't. Let's move
154
+ // the pseudo to the right.
155
+ if (a.type === 'pseudo' ^ z.type === 'pseudo') {
156
+ return (a.type === 'pseudo') - (z.type === 'pseudo');
157
+ }
158
+ // Both are pseudo's, move the pseudo elements (except for
159
+ // ::file-selector-button) to the right.
160
+ return isPseudoElement(a) - isPseudoElement(z);
161
+ }
162
+ function isPseudoElement(node) {
163
+ if (node.type !== 'pseudo') return false;
164
+ if (pseudoElementExceptions.includes(node.value)) return false;
165
+ return node.value.startsWith('::') || pseudoElementsBC.includes(node.value);
166
+ }
167
+ function resolveFunctionArgument(haystack, needle, arg) {
168
+ let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle);
169
+ if (startIdx === -1) return null;
170
+ // Start inside the `(`
171
+ startIdx += needle.length + 1;
172
+ let target = '';
173
+ let count = 0;
174
+ for (let char of haystack.slice(startIdx)){
175
+ if (char !== '(' && char !== ')') {
176
+ target += char;
177
+ } else if (char === '(') {
178
+ target += char;
179
+ count++;
180
+ } else if (char === ')') {
181
+ if (--count < 0) break; // unbalanced
182
+ target += char;
183
+ }
184
+ }
185
+ return target;
186
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.default = isValidArbitraryValue;
6
+ let matchingBrackets = new Map([
7
+ [
8
+ '{',
9
+ '}'
10
+ ],
11
+ [
12
+ '[',
13
+ ']'
14
+ ],
15
+ [
16
+ '(',
17
+ ')'
18
+ ],
19
+ ]);
20
+ let inverseMatchingBrackets = new Map(Array.from(matchingBrackets.entries()).map(([k, v])=>[
21
+ v,
22
+ k
23
+ ]
24
+ ));
25
+ let quotes = new Set([
26
+ '"',
27
+ "'",
28
+ '`'
29
+ ]);
30
+ function isValidArbitraryValue(value) {
31
+ let stack = [];
32
+ let inQuotes = false;
33
+ for(let i = 0; i < value.length; i++){
34
+ let char = value[i];
35
+ if (char === ':' && !inQuotes && stack.length === 0) {
36
+ return false;
37
+ }
38
+ // Non-escaped quotes allow us to "allow" anything in between
39
+ if (quotes.has(char) && value[i - 1] !== '\\') {
40
+ inQuotes = !inQuotes;
41
+ }
42
+ if (inQuotes) continue;
43
+ if (value[i - 1] === '\\') continue; // Escaped
44
+ if (matchingBrackets.has(char)) {
45
+ stack.push(char);
46
+ } else if (inverseMatchingBrackets.has(char)) {
47
+ let inverse = inverseMatchingBrackets.get(char);
48
+ // Nothing to pop from, therefore it is unbalanced
49
+ if (stack.length <= 0) {
50
+ return false;
51
+ }
52
+ // Popped value must match the inverse value, otherwise it is unbalanced
53
+ if (stack.pop() !== inverse) {
54
+ return false;
55
+ }
56
+ }
57
+ }
58
+ // If there is still something on the stack, it is also unbalanced
59
+ if (stack.length > 0) {
60
+ return false;
61
+ }
62
+ // All good, totally balanced!
63
+ return true;
64
+ }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ exports.asClass = asClass;
5
6
  exports.default = nameClass;
6
7
  exports.formatClass = formatClass;
7
8
  var _escapeClassName = _interopRequireDefault(require("./escapeClassName"));
@@ -21,7 +22,7 @@ function formatClass(classPrefix, key) {
21
22
  if (key === 'DEFAULT') {
22
23
  return classPrefix;
23
24
  }
24
- if (key === '-') {
25
+ if (key === '-' || key === '-DEFAULT') {
25
26
  return `-${classPrefix}`;
26
27
  }
27
28
  if (key.startsWith('-')) {
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.default = _default;
6
6
  function _default(value) {
7
7
  value = `${value}`;
8
+ if (value === '0') {
9
+ return '0';
10
+ }
8
11
  // Flip sign of numbers
9
12
  if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
10
13
  return value.replace(/^[+-]?/, (sign)=>sign === '-' ? '' : '-'
@@ -13,5 +16,4 @@ function _default(value) {
13
16
  if (value.includes('var(') || value.includes('calc(')) {
14
17
  return `calc(${value} * -1)`;
15
18
  }
16
- return value;
17
19
  }
@@ -120,6 +120,17 @@ function normalizeConfig(config) {
120
120
  if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return purge.options.safelist;
121
121
  return [];
122
122
  })();
123
+ // Normalize prefix option
124
+ if (typeof config.prefix === 'function') {
125
+ _log.default.warn('prefix-function', [
126
+ 'As of Tailwind CSS v3.0, `prefix` cannot be a function.',
127
+ 'Update `prefix` in your configuration to be a string to eliminate this warning.'
128
+ ]);
129
+ config.prefix = '';
130
+ } else {
131
+ var _prefix;
132
+ config.prefix = (_prefix = config.prefix) !== null && _prefix !== void 0 ? _prefix : '';
133
+ }
123
134
  // Normalize the `content`
124
135
  config.content = {
125
136
  files: (()=>{
@@ -145,16 +156,19 @@ function normalizeConfig(config) {
145
156
  })();
146
157
  let extractors = {
147
158
  };
148
- extractors.DEFAULT = (()=>{
149
- var ref, ref37, ref38, ref39;
150
- if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref37 = ref.options) === null || ref37 === void 0 ? void 0 : ref37.defaultExtractor) {
159
+ let defaultExtractor = (()=>{
160
+ var ref, ref10, ref11, ref12;
161
+ if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref10 = ref.options) === null || ref10 === void 0 ? void 0 : ref10.defaultExtractor) {
151
162
  return config.purge.options.defaultExtractor;
152
163
  }
153
- if ((ref38 = config.content) === null || ref38 === void 0 ? void 0 : (ref39 = ref38.options) === null || ref39 === void 0 ? void 0 : ref39.defaultExtractor) {
164
+ if ((ref11 = config.content) === null || ref11 === void 0 ? void 0 : (ref12 = ref11.options) === null || ref12 === void 0 ? void 0 : ref12.defaultExtractor) {
154
165
  return config.content.options.defaultExtractor;
155
166
  }
156
167
  return undefined;
157
168
  })();
169
+ if (defaultExtractor !== undefined) {
170
+ extractors.DEFAULT = defaultExtractor;
171
+ }
158
172
  // Functions
159
173
  if (typeof extract === 'function') {
160
174
  extractors.DEFAULT = extract;
@@ -171,11 +185,11 @@ function normalizeConfig(config) {
171
185
  })(),
172
186
  transform: (()=>{
173
187
  let transform = (()=>{
174
- var ref, ref49, ref50, ref51, ref52, ref53;
188
+ var ref, ref13, ref14, ref15, ref16, ref17;
175
189
  if ((ref = config.purge) === null || ref === void 0 ? void 0 : ref.transform) return config.purge.transform;
176
- if ((ref49 = config.content) === null || ref49 === void 0 ? void 0 : ref49.transform) return config.content.transform;
177
- if ((ref50 = config.purge) === null || ref50 === void 0 ? void 0 : (ref51 = ref50.transform) === null || ref51 === void 0 ? void 0 : ref51.DEFAULT) return config.purge.transform.DEFAULT;
178
- if ((ref52 = config.content) === null || ref52 === void 0 ? void 0 : (ref53 = ref52.transform) === null || ref53 === void 0 ? void 0 : ref53.DEFAULT) return config.content.transform.DEFAULT;
190
+ if ((ref13 = config.content) === null || ref13 === void 0 ? void 0 : ref13.transform) return config.content.transform;
191
+ if ((ref14 = config.purge) === null || ref14 === void 0 ? void 0 : (ref15 = ref14.transform) === null || ref15 === void 0 ? void 0 : ref15.DEFAULT) return config.purge.transform.DEFAULT;
192
+ if ((ref16 = config.content) === null || ref16 === void 0 ? void 0 : (ref17 = ref16.transform) === null || ref17 === void 0 ? void 0 : ref17.DEFAULT) return config.content.transform.DEFAULT;
179
193
  return {
180
194
  };
181
195
  })();
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.normalizeScreens = normalizeScreens;
6
+ function normalizeScreens(screens, root = true) {
7
+ if (Array.isArray(screens)) {
8
+ return screens.map((screen)=>{
9
+ if (root && Array.isArray(screen)) {
10
+ throw new Error('The tuple syntax is not supported for `screens`.');
11
+ }
12
+ if (typeof screen === 'string') {
13
+ return {
14
+ name: screen.toString(),
15
+ values: [
16
+ {
17
+ min: screen,
18
+ max: undefined
19
+ }
20
+ ]
21
+ };
22
+ }
23
+ let [name, options] = screen;
24
+ name = name.toString();
25
+ if (typeof options === 'string') {
26
+ return {
27
+ name,
28
+ values: [
29
+ {
30
+ min: options,
31
+ max: undefined
32
+ }
33
+ ]
34
+ };
35
+ }
36
+ if (Array.isArray(options)) {
37
+ return {
38
+ name,
39
+ values: options.map((option)=>resolveValue(option)
40
+ )
41
+ };
42
+ }
43
+ return {
44
+ name,
45
+ values: [
46
+ resolveValue(options)
47
+ ]
48
+ };
49
+ });
50
+ }
51
+ return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {
52
+ }), false);
53
+ }
54
+ function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {
55
+ }) {
56
+ return {
57
+ min,
58
+ max,
59
+ raw
60
+ };
61
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.parseBoxShadowValue = parseBoxShadowValue;
6
+ exports.formatBoxShadowValue = formatBoxShadowValue;
7
+ let KEYWORDS = new Set([
8
+ 'inset',
9
+ 'inherit',
10
+ 'initial',
11
+ 'revert',
12
+ 'unset'
13
+ ]);
14
+ let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
15
+ ;
16
+ let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
+ ;
18
+ let LENGTH = /^-?(\d+)(.*?)$/g;
19
+ function parseBoxShadowValue(input) {
20
+ let shadows = input.split(COMMA);
21
+ return shadows.map((shadow)=>{
22
+ let value = shadow.trim();
23
+ let result = {
24
+ raw: value
25
+ };
26
+ let parts = value.split(SPACE);
27
+ let seen = new Set();
28
+ for (let part of parts){
29
+ // Reset index, since the regex is stateful.
30
+ LENGTH.lastIndex = 0;
31
+ // Keyword
32
+ if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
33
+ result.keyword = part;
34
+ seen.add('KEYWORD');
35
+ } else if (LENGTH.test(part)) {
36
+ if (!seen.has('X')) {
37
+ result.x = part;
38
+ seen.add('X');
39
+ } else if (!seen.has('Y')) {
40
+ result.y = part;
41
+ seen.add('Y');
42
+ } else if (!seen.has('BLUR')) {
43
+ result.blur = part;
44
+ seen.add('BLUR');
45
+ } else if (!seen.has('SPREAD')) {
46
+ result.spread = part;
47
+ seen.add('SPREAD');
48
+ }
49
+ } else {
50
+ if (!result.color) {
51
+ result.color = part;
52
+ } else {
53
+ if (!result.unknown) result.unknown = [];
54
+ result.unknown.push(part);
55
+ }
56
+ }
57
+ }
58
+ // Check if valid
59
+ result.valid = result.x !== undefined && result.y !== undefined;
60
+ return result;
61
+ });
62
+ }
63
+ function formatBoxShadowValue(shadows) {
64
+ return shadows.map((shadow)=>{
65
+ if (!shadow.valid) {
66
+ return shadow.raw;
67
+ }
68
+ return [
69
+ shadow.keyword,
70
+ shadow.x,
71
+ shadow.y,
72
+ shadow.blur,
73
+ shadow.spread,
74
+ shadow.color
75
+ ].filter(Boolean).join(' ');
76
+ }).join(', ');
77
+ }