tailwindcss 0.0.0-insiders.e2d5f21 → 0.0.0-insiders.e302ef1

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 (91) hide show
  1. package/CHANGELOG.md +244 -3
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.js +2 -1
  5. package/defaultConfig.js +2 -1
  6. package/defaultTheme.js +2 -1
  7. package/lib/cli.js +123 -88
  8. package/lib/corePlugins.js +288 -360
  9. package/lib/css/preflight.css +4 -4
  10. package/lib/featureFlags.js +4 -5
  11. package/lib/index.js +12 -3
  12. package/lib/lib/cacheInvalidation.js +69 -0
  13. package/lib/lib/collapseAdjacentRules.js +14 -1
  14. package/lib/lib/collapseDuplicateDeclarations.js +52 -1
  15. package/lib/lib/defaultExtractor.js +44 -0
  16. package/lib/lib/evaluateTailwindFunctions.js +1 -1
  17. package/lib/lib/expandApplyAtRules.js +265 -60
  18. package/lib/lib/expandTailwindAtRules.js +63 -48
  19. package/lib/lib/generateRules.js +136 -34
  20. package/lib/lib/normalizeTailwindDirectives.js +10 -2
  21. package/lib/lib/partitionApplyAtRules.js +53 -0
  22. package/lib/lib/resolveDefaultsAtRules.js +30 -12
  23. package/lib/lib/setupContextUtils.js +137 -81
  24. package/lib/lib/setupTrackingContext.js +8 -7
  25. package/lib/lib/sharedState.js +38 -5
  26. package/{nesting → lib/postcss-plugins/nesting}/README.md +0 -0
  27. package/lib/postcss-plugins/nesting/index.js +17 -0
  28. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  29. package/lib/processTailwindFeatures.js +10 -2
  30. package/lib/util/cloneNodes.js +12 -1
  31. package/lib/util/color.js +23 -8
  32. package/lib/util/createPlugin.js +1 -2
  33. package/lib/util/createUtilityPlugin.js +4 -8
  34. package/lib/util/dataTypes.js +4 -2
  35. package/lib/util/defaults.js +6 -0
  36. package/lib/util/flattenColorPalette.js +1 -3
  37. package/lib/util/log.js +10 -6
  38. package/lib/util/normalizeConfig.js +47 -15
  39. package/lib/util/normalizeScreens.js +6 -5
  40. package/lib/util/parseBoxShadowValue.js +44 -4
  41. package/lib/util/pluginUtils.js +6 -13
  42. package/lib/util/prefixSelector.js +4 -5
  43. package/lib/util/resolveConfig.js +48 -27
  44. package/lib/util/resolveConfigPath.js +1 -2
  45. package/lib/util/toColorValue.js +1 -2
  46. package/lib/util/toPath.js +6 -1
  47. package/lib/util/transformThemeValue.js +4 -8
  48. package/nesting/index.js +2 -12
  49. package/package.json +28 -33
  50. package/peers/index.js +3209 -4239
  51. package/plugin.js +2 -1
  52. package/resolveConfig.js +2 -1
  53. package/src/cli.js +62 -15
  54. package/src/corePlugins.js +212 -217
  55. package/src/css/preflight.css +4 -4
  56. package/src/featureFlags.js +3 -3
  57. package/src/index.js +14 -6
  58. package/src/lib/cacheInvalidation.js +52 -0
  59. package/src/lib/collapseAdjacentRules.js +16 -1
  60. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  61. package/src/lib/defaultExtractor.js +50 -0
  62. package/src/lib/evaluateTailwindFunctions.js +1 -1
  63. package/src/lib/expandApplyAtRules.js +285 -56
  64. package/src/lib/expandTailwindAtRules.js +75 -37
  65. package/src/lib/generateRules.js +121 -27
  66. package/src/lib/normalizeTailwindDirectives.js +7 -1
  67. package/src/lib/partitionApplyAtRules.js +52 -0
  68. package/src/lib/resolveDefaultsAtRules.js +35 -10
  69. package/src/lib/setupContextUtils.js +127 -45
  70. package/src/lib/setupTrackingContext.js +8 -7
  71. package/src/lib/sharedState.js +42 -4
  72. package/src/postcss-plugins/nesting/README.md +42 -0
  73. package/src/postcss-plugins/nesting/index.js +13 -0
  74. package/src/postcss-plugins/nesting/plugin.js +80 -0
  75. package/src/processTailwindFeatures.js +12 -2
  76. package/src/util/cloneNodes.js +14 -1
  77. package/src/util/color.js +20 -7
  78. package/src/util/dataTypes.js +7 -5
  79. package/src/util/defaults.js +6 -0
  80. package/src/util/log.js +10 -6
  81. package/src/util/normalizeConfig.js +24 -3
  82. package/src/util/normalizeScreens.js +6 -3
  83. package/src/util/parseBoxShadowValue.js +51 -3
  84. package/src/util/pluginUtils.js +1 -1
  85. package/src/util/prefixSelector.js +7 -5
  86. package/src/util/resolveConfig.js +41 -1
  87. package/src/util/toPath.js +23 -1
  88. package/stubs/defaultConfig.stub.js +2 -2
  89. package/lib/lib/setupWatchingContext.js +0 -288
  90. package/nesting/plugin.js +0 -41
  91. package/src/lib/setupWatchingContext.js +0 -311
@@ -3,11 +3,22 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = cloneNodes;
6
- function cloneNodes(nodes, source) {
6
+ function cloneNodes(nodes, source = undefined, raws = undefined) {
7
7
  return nodes.map((node)=>{
8
8
  let cloned = node.clone();
9
9
  if (source !== undefined) {
10
10
  cloned.source = source;
11
+ if ('walk' in cloned) {
12
+ cloned.walk((child)=>{
13
+ child.source = source;
14
+ });
15
+ }
16
+ }
17
+ if (raws !== undefined) {
18
+ cloned.raws.tailwind = {
19
+ ...cloned.raws.tailwind,
20
+ ...raws
21
+ };
11
22
  }
12
23
  return cloned;
13
24
  });
package/lib/util/color.js CHANGED
@@ -15,7 +15,8 @@ let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i;
15
15
  let VALUE = `(?:\\d+|\\d*\\.\\d+)%?`;
16
16
  let SEP = `(?:\\s*,\\s*|\\s+)`;
17
17
  let ALPHA_SEP = `\\s*[,/]\\s*`;
18
- let RGB_HSL = new RegExp(`^(rgb|hsl)a?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
18
+ let RGB = new RegExp(`^rgba?\\(\\s*(${VALUE})${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
19
+ let HSL = new RegExp(`^hsla?\\(\\s*((?:${VALUE})(?:deg|rad|grad|turn)?)${SEP}(${VALUE})${SEP}(${VALUE})(?:${ALPHA_SEP}(${VALUE}))?\\s*\\)$`);
19
20
  function parseColor(value) {
20
21
  if (typeof value !== 'string') {
21
22
  return null;
@@ -62,18 +63,32 @@ function parseColor(value) {
62
63
  alpha: hex[4] ? (parseInt(hex[4], 16) / 255).toString() : undefined
63
64
  };
64
65
  }
65
- let match = value.match(RGB_HSL);
66
- if (match !== null) {
66
+ let rgbMatch = value.match(RGB);
67
+ if (rgbMatch !== null) {
67
68
  var ref, ref1;
68
69
  return {
69
- mode: match[1],
70
+ mode: 'rgb',
71
+ color: [
72
+ rgbMatch[1],
73
+ rgbMatch[2],
74
+ rgbMatch[3]
75
+ ].map((v)=>v.toString()
76
+ ),
77
+ alpha: (ref = rgbMatch[4]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
78
+ };
79
+ }
80
+ let hslMatch = value.match(HSL);
81
+ if (hslMatch !== null) {
82
+ var ref2, ref3;
83
+ return {
84
+ mode: 'hsl',
70
85
  color: [
71
- match[2],
72
- match[3],
73
- match[4]
86
+ hslMatch[1],
87
+ hslMatch[2],
88
+ hslMatch[3]
74
89
  ].map((v)=>v.toString()
75
90
  ),
76
- alpha: (ref = match[5]) === null || ref === void 0 ? void 0 : (ref1 = ref.toString) === null || ref1 === void 0 ? void 0 : ref1.call(ref)
91
+ alpha: (ref2 = hslMatch[4]) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.toString) === null || ref3 === void 0 ? void 0 : ref3.call(ref2)
77
92
  };
78
93
  }
79
94
  return null;
@@ -9,8 +9,7 @@ function createPlugin(plugin, config) {
9
9
  config
10
10
  };
11
11
  }
12
- createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({
13
- })
12
+ createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})
14
13
  ) {
15
14
  const optionsFunction = function(options) {
16
15
  return {
@@ -16,8 +16,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [
16
16
  themeKey
17
17
  ]
18
18
  ]
19
- ], { filterDefault =false , ...options } = {
20
- }) {
19
+ ], { filterDefault =false , ...options } = {}) {
21
20
  let transformValue = (0, _transformThemeValue).default(themeKey);
22
21
  return function({ matchUtilities , theme }) {
23
22
  for (let utilityVariation of utilityVariations){
@@ -37,15 +36,12 @@ function createUtilityPlugin(themeKey, utilityVariations = [
37
36
  return Object.assign(obj, {
38
37
  [name]: transformValue(value)
39
38
  });
40
- }, {
41
- });
39
+ }, {});
42
40
  }
43
41
  });
44
- }, {
45
- }), {
42
+ }, {}), {
46
43
  ...options,
47
- values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {
48
- }).filter(([modifier])=>modifier !== 'DEFAULT'
44
+ values: filterDefault ? Object.fromEntries(Object.entries((ref = theme(themeKey)) !== null && ref !== void 0 ? ref : {}).filter(([modifier])=>modifier !== 'DEFAULT'
49
45
  )) : theme(themeKey)
50
46
  });
51
47
  }
@@ -82,8 +82,10 @@ let lengthUnits = [
82
82
  ];
83
83
  let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`;
84
84
  function length(value) {
85
- return value === '0' || new RegExp(`${lengthUnitsPattern}$`).test(value) || cssFunctions.some((fn)=>new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(value)
86
- );
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
+ });
87
89
  }
88
90
  let lineWidths = new Set([
89
91
  'thin',
@@ -11,6 +11,12 @@ function defaults(target, ...sources) {
11
11
  target[k] = source[k];
12
12
  }
13
13
  }
14
+ for (let k1 of Object.getOwnPropertySymbols(source)){
15
+ var ref1;
16
+ if (!(target === null || target === void 0 ? void 0 : (ref1 = target.hasOwnProperty) === null || ref1 === void 0 ? void 0 : ref1.call(target, k1))) {
17
+ target[k1] = source[k1];
18
+ }
19
+ }
14
20
  }
15
21
  return target;
16
22
  }
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.default = void 0;
6
- const flattenColorPalette = (colors)=>Object.assign({
7
- }, ...Object.entries(colors !== null && colors !== void 0 ? colors : {
8
- }).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
6
+ const flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == 'object' ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({
9
7
  [color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex
10
8
  })
11
9
  ) : [
package/lib/util/log.js CHANGED
@@ -2,25 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ exports.dim = dim;
5
6
  exports.default = void 0;
6
- var _chalk = _interopRequireDefault(require("chalk"));
7
+ var _picocolors = _interopRequireDefault(require("picocolors"));
7
8
  function _interopRequireDefault(obj) {
8
9
  return obj && obj.__esModule ? obj : {
9
10
  default: obj
10
11
  };
11
12
  }
12
13
  let alreadyShown = new Set();
13
- function log(chalk, messages, key) {
14
+ function log(type, messages, key) {
14
15
  if (process.env.JEST_WORKER_ID !== undefined) return;
15
16
  if (key && alreadyShown.has(key)) return;
16
17
  if (key) alreadyShown.add(key);
17
18
  console.warn('');
18
- messages.forEach((message)=>console.warn(chalk, '-', message)
19
+ messages.forEach((message)=>console.warn(type, '-', message)
19
20
  );
20
21
  }
22
+ function dim(input) {
23
+ return _picocolors.default.dim(input);
24
+ }
21
25
  var _default = {
22
26
  info (key, messages) {
23
- log(_chalk.default.bold.cyan('info'), ...Array.isArray(key) ? [
27
+ log(_picocolors.default.bold(_picocolors.default.cyan('info')), ...Array.isArray(key) ? [
24
28
  key
25
29
  ] : [
26
30
  messages,
@@ -28,7 +32,7 @@ var _default = {
28
32
  ]);
29
33
  },
30
34
  warn (key, messages) {
31
- log(_chalk.default.bold.yellow('warn'), ...Array.isArray(key) ? [
35
+ log(_picocolors.default.bold(_picocolors.default.yellow('warn')), ...Array.isArray(key) ? [
32
36
  key
33
37
  ] : [
34
38
  messages,
@@ -36,7 +40,7 @@ var _default = {
36
40
  ]);
37
41
  },
38
42
  risk (key, messages) {
39
- log(_chalk.default.bold.magenta('risk'), ...Array.isArray(key) ? [
43
+ log(_picocolors.default.bold(_picocolors.default.magenta('risk')), ...Array.isArray(key) ? [
40
44
  key
41
45
  ] : [
42
46
  messages,
@@ -3,11 +3,27 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.normalizeConfig = normalizeConfig;
6
- var _log = _interopRequireDefault(require("./log"));
7
- function _interopRequireDefault(obj) {
8
- return obj && obj.__esModule ? obj : {
9
- default: obj
10
- };
6
+ var _log = _interopRequireWildcard(require("./log"));
7
+ function _interopRequireWildcard(obj) {
8
+ if (obj && obj.__esModule) {
9
+ return obj;
10
+ } else {
11
+ var newObj = {};
12
+ if (obj != null) {
13
+ for(var key in obj){
14
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
15
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
16
+ if (desc.get || desc.set) {
17
+ Object.defineProperty(newObj, key, desc);
18
+ } else {
19
+ newObj[key] = obj[key];
20
+ }
21
+ }
22
+ }
23
+ }
24
+ newObj.default = obj;
25
+ return newObj;
26
+ }
11
27
  }
12
28
  function normalizeConfig(config) {
13
29
  // Quick structure validation
@@ -107,7 +123,8 @@ function normalizeConfig(config) {
107
123
  if (!valid) {
108
124
  _log.default.warn('purge-deprecation', [
109
125
  'The `purge`/`content` options have changed in Tailwind CSS v3.0.',
110
- 'Update your configuration file to eliminate this warning.'
126
+ 'Update your configuration file to eliminate this warning.',
127
+ 'https://tailwindcss.com/docs/upgrade-guide#configure-content-sources',
111
128
  ]);
112
129
  }
113
130
  // Normalize the `safelist`
@@ -124,7 +141,8 @@ function normalizeConfig(config) {
124
141
  if (typeof config.prefix === 'function') {
125
142
  _log.default.warn('prefix-function', [
126
143
  '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.'
144
+ 'Update `prefix` in your configuration to be a string to eliminate this warning.',
145
+ 'https://tailwindcss.com/docs/upgrade-guide#prefix-cannot-be-a-function',
128
146
  ]);
129
147
  config.prefix = '';
130
148
  } else {
@@ -151,11 +169,9 @@ function normalizeConfig(config) {
151
169
  if ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.extract) === null || ref5 === void 0 ? void 0 : ref5.DEFAULT) return config.content.extract.DEFAULT;
152
170
  if ((ref6 = config.purge) === null || ref6 === void 0 ? void 0 : (ref7 = ref6.options) === null || ref7 === void 0 ? void 0 : ref7.extractors) return config.purge.options.extractors;
153
171
  if ((ref8 = config.content) === null || ref8 === void 0 ? void 0 : (ref9 = ref8.options) === null || ref9 === void 0 ? void 0 : ref9.extractors) return config.content.options.extractors;
154
- return {
155
- };
172
+ return {};
156
173
  })();
157
- let extractors = {
158
- };
174
+ let extractors = {};
159
175
  let defaultExtractor = (()=>{
160
176
  var ref, ref10, ref11, ref12;
161
177
  if ((ref = config.purge) === null || ref === void 0 ? void 0 : (ref10 = ref.options) === null || ref10 === void 0 ? void 0 : ref10.defaultExtractor) {
@@ -190,11 +206,9 @@ function normalizeConfig(config) {
190
206
  if ((ref13 = config.content) === null || ref13 === void 0 ? void 0 : ref13.transform) return config.content.transform;
191
207
  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
208
  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;
193
- return {
194
- };
209
+ return {};
195
210
  })();
196
- let transformers = {
197
- };
211
+ let transformers = {};
198
212
  if (typeof transform === 'function') {
199
213
  transformers.DEFAULT = transform;
200
214
  }
@@ -204,5 +218,23 @@ function normalizeConfig(config) {
204
218
  return transformers;
205
219
  })()
206
220
  };
221
+ // Validate globs to prevent bogus globs.
222
+ // E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
223
+ for (let file of config.content.files){
224
+ if (typeof file === 'string' && /{([^,]*?)}/g.test(file)) {
225
+ _log.default.warn('invalid-glob-braces', [
226
+ `The glob pattern ${(0, _log).dim(file)} in your Tailwind CSS configuration is invalid.`,
227
+ `Update it to ${(0, _log).dim(file.replace(/{([^,]*?)}/g, '$1'))} to silence this warning.`
228
+ ]);
229
+ break;
230
+ }
231
+ }
232
+ if (config.content.files.length === 0) {
233
+ _log.default.warn('content-problems', [
234
+ 'The `content` option in your Tailwind CSS configuration is missing or empty.',
235
+ 'Configure your content sources or your generated CSS will be missing styles.',
236
+ 'https://tailwindcss.com/docs/content-configuration',
237
+ ]);
238
+ }
207
239
  return config;
208
240
  }
@@ -3,9 +3,12 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.normalizeScreens = normalizeScreens;
6
- function normalizeScreens(screens) {
6
+ function normalizeScreens(screens, root = true) {
7
7
  if (Array.isArray(screens)) {
8
8
  return screens.map((screen)=>{
9
+ if (root && Array.isArray(screen)) {
10
+ throw new Error('The tuple syntax is not supported for `screens`.');
11
+ }
9
12
  if (typeof screen === 'string') {
10
13
  return {
11
14
  name: screen.toString(),
@@ -45,11 +48,9 @@ function normalizeScreens(screens) {
45
48
  };
46
49
  });
47
50
  }
48
- return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {
49
- }));
51
+ return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {}), false);
50
52
  }
51
- function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {
52
- }) {
53
+ function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {}) {
53
54
  return {
54
55
  min,
55
56
  max,
@@ -11,13 +11,53 @@ let KEYWORDS = new Set([
11
11
  'revert',
12
12
  'unset'
13
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
14
  let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
15
  ;
18
- let LENGTH = /^-?(\d+)(.*?)$/g;
16
+ let LENGTH = /^-?(\d+|\.\d+)(.*?)$/g;
17
+ let SPECIALS = /[(),]/g;
18
+ /**
19
+ * This splits a string on top-level commas.
20
+ *
21
+ * Regex doesn't support recursion (at least not the JS-flavored version).
22
+ * So we have to use a tiny state machine to keep track of paren vs comma
23
+ * placement. Before we'd only exclude commas from the inner-most nested
24
+ * set of parens rather than any commas that were not contained in parens
25
+ * at all which is the intended behavior here.
26
+ *
27
+ * Expected behavior:
28
+ * var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)
29
+ * ─┬─ ┬ ┬ ┬
30
+ * x x x ╰──────── Split because top-level
31
+ * ╰──────────────┴──┴───────────── Ignored b/c inside >= 1 levels of parens
32
+ *
33
+ * @param {string} input
34
+ */ function* splitByTopLevelCommas(input) {
35
+ SPECIALS.lastIndex = -1;
36
+ let depth = 0;
37
+ let lastIndex = 0;
38
+ let found = false;
39
+ // Find all parens & commas
40
+ // And only split on commas if they're top-level
41
+ for (let match of input.matchAll(SPECIALS)){
42
+ if (match[0] === '(') depth++;
43
+ if (match[0] === ')') depth--;
44
+ if (match[0] === ',' && depth === 0) {
45
+ found = true;
46
+ yield input.substring(lastIndex, match.index);
47
+ lastIndex = match.index + match[0].length;
48
+ }
49
+ }
50
+ // Provide the last segment of the string if available
51
+ // Otherwise the whole string since no commas were found
52
+ // This mirrors the behavior of string.split()
53
+ if (found) {
54
+ yield input.substring(lastIndex);
55
+ } else {
56
+ yield input;
57
+ }
58
+ }
19
59
  function parseBoxShadowValue(input) {
20
- let shadows = input.split(COMMA);
60
+ let shadows = Array.from(splitByTopLevelCommas(input));
21
61
  return shadows.map((shadow)=>{
22
62
  let value = shadow.trim();
23
63
  let result = {
@@ -40,8 +40,7 @@ function resolveArbitraryValue(modifier, validate) {
40
40
  }
41
41
  return (0, _dataTypes).normalize(value);
42
42
  }
43
- function asNegativeValue(modifier, lookup = {
44
- }, validate) {
43
+ function asNegativeValue(modifier, lookup = {}, validate) {
45
44
  let positiveValue = lookup[modifier];
46
45
  if (positiveValue !== undefined) {
47
46
  return (0, _negateValue).default(positiveValue);
@@ -54,10 +53,8 @@ function asNegativeValue(modifier, lookup = {
54
53
  return (0, _negateValue).default(resolved);
55
54
  }
56
55
  }
57
- function asValue(modifier, options = {
58
- }, { validate =()=>true
59
- } = {
60
- }) {
56
+ function asValue(modifier, options = {}, { validate =()=>true
57
+ } = {}) {
61
58
  var ref;
62
59
  let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
63
60
  if (value !== undefined) {
@@ -83,10 +80,7 @@ function splitAlpha(modifier) {
83
80
  modifier.slice(slashIdx + 1)
84
81
  ];
85
82
  }
86
- function asColor(modifier, options = {
87
- }, { tailwindConfig ={
88
- } } = {
89
- }) {
83
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
90
84
  var ref;
91
85
  if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
92
86
  var ref1;
@@ -112,8 +106,7 @@ function asColor(modifier, options = {
112
106
  validate: _dataTypes.color
113
107
  });
114
108
  }
115
- function asLookupValue(modifier, options = {
116
- }) {
109
+ function asLookupValue(modifier, options = {}) {
117
110
  var ref;
118
111
  return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
119
112
  }
@@ -177,7 +170,7 @@ function coerceValue(types, modifier, options, tailwindConfig) {
177
170
  let result = typeMap[type](modifier, options, {
178
171
  tailwindConfig
179
172
  });
180
- if (result) return [
173
+ if (result !== undefined) return [
181
174
  result,
182
175
  type
183
176
  ];
@@ -4,18 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.default = _default;
6
6
  var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
7
- var _tap = require("./tap");
8
7
  function _interopRequireDefault(obj) {
9
8
  return obj && obj.__esModule ? obj : {
10
9
  default: obj
11
10
  };
12
11
  }
13
- function _default(prefix, selector) {
12
+ function _default(prefix, selector, prependNegative = false) {
14
13
  return (0, _postcssSelectorParser).default((selectors)=>{
15
14
  selectors.walkClasses((classSelector)=>{
16
- (0, _tap).tap(classSelector.value, (baseClass)=>{
17
- classSelector.value = `${prefix}${baseClass}`;
18
- });
15
+ let baseClass = classSelector.value;
16
+ let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith('-');
17
+ classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
19
18
  });
20
19
  }).processSync(selector);
21
20
  }
@@ -11,6 +11,8 @@ var _colors = _interopRequireDefault(require("../public/colors"));
11
11
  var _defaults = require("./defaults");
12
12
  var _toPath = require("./toPath");
13
13
  var _normalizeConfig = require("./normalizeConfig");
14
+ var _isPlainObject = _interopRequireDefault(require("./isPlainObject"));
15
+ var _cloneDeep = require("./cloneDeep");
14
16
  function _interopRequireDefault(obj) {
15
17
  return obj && obj.__esModule ? obj : {
16
18
  default: obj
@@ -51,8 +53,7 @@ const configUtils = {
51
53
  negativeScale[`-${key}`] = negativeValue;
52
54
  }
53
55
  return negativeScale;
54
- }, {
55
- });
56
+ }, {});
56
57
  },
57
58
  breakpoints (screens) {
58
59
  return Object.keys(screens).filter((key)=>typeof screens[key] === 'string'
@@ -60,11 +61,32 @@ const configUtils = {
60
61
  ...breakpoints,
61
62
  [`screen-${key}`]: screens[key]
62
63
  })
63
- , {
64
- });
64
+ , {});
65
+ },
66
+ rgb (property) {
67
+ if (!property.startsWith('--')) {
68
+ throw new Error('The rgb() helper requires a custom property name to be passed as the first argument.');
69
+ }
70
+ return ({ opacityValue })=>{
71
+ if (opacityValue === undefined || opacityValue === 1) {
72
+ return `rgb(var(${property}) / 1.0)`;
73
+ }
74
+ return `rgb(var(${property}) / ${opacityValue})`;
75
+ };
76
+ },
77
+ hsl (property) {
78
+ if (!property.startsWith('--')) {
79
+ throw new Error('The hsl() helper requires a custom property name to be passed as the first argument.');
80
+ }
81
+ return ({ opacityValue })=>{
82
+ if (opacityValue === undefined || opacityValue === 1) {
83
+ return `hsl(var(${property}) / 1)`;
84
+ }
85
+ return `hsl(var(${property}) / ${opacityValue})`;
86
+ };
65
87
  }
66
88
  };
67
- function value1(valueToResolve, ...args) {
89
+ function value(valueToResolve, ...args) {
68
90
  return isFunction(valueToResolve) ? valueToResolve(...args) : valueToResolve;
69
91
  }
70
92
  function collectExtends(items) {
@@ -86,34 +108,32 @@ function collectExtends(items) {
86
108
  mergedValue
87
109
  ];
88
110
  });
89
- }, {
90
- });
111
+ }, {});
91
112
  }
92
113
  function mergeThemes(themes) {
93
114
  return {
94
115
  ...themes.reduce((merged, theme)=>(0, _defaults).defaults(merged, theme)
95
- , {
96
- }),
116
+ , {}),
97
117
  // In order to resolve n config objects, we combine all of their `extend` properties
98
118
  // into arrays instead of objects so they aren't overridden.
99
119
  extend: collectExtends(themes)
100
120
  };
101
121
  }
102
- function mergeExtensionCustomizer(merged, value) {
122
+ function mergeExtensionCustomizer(merged, value1) {
103
123
  // When we have an array of objects, we do want to merge it
104
124
  if (Array.isArray(merged) && isObject(merged[0])) {
105
- return merged.concat(value);
125
+ return merged.concat(value1);
106
126
  }
107
127
  // When the incoming value is an array, and the existing config is an object, prepend the existing object
108
- if (Array.isArray(value) && isObject(value[0]) && isObject(merged)) {
128
+ if (Array.isArray(value1) && isObject(value1[0]) && isObject(merged)) {
109
129
  return [
110
130
  merged,
111
- ...value
131
+ ...value1
112
132
  ];
113
133
  }
114
134
  // Override arrays (for example for font-families, box-shadows, ...)
115
- if (Array.isArray(value)) {
116
- return value;
135
+ if (Array.isArray(value1)) {
136
+ return value1;
117
137
  }
118
138
  // Execute default behaviour
119
139
  return undefined;
@@ -122,14 +142,12 @@ function mergeExtensions({ extend , ...theme }) {
122
142
  return mergeWith(theme, extend, (themeValue, extensions)=>{
123
143
  // The `extend` property is an array, so we need to check if it contains any functions
124
144
  if (!isFunction(themeValue) && !extensions.some(isFunction)) {
125
- return mergeWith({
126
- }, themeValue, ...extensions, mergeExtensionCustomizer);
145
+ return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer);
127
146
  }
128
- return (resolveThemePath, utils)=>mergeWith({
129
- }, ...[
147
+ return (resolveThemePath, utils)=>mergeWith({}, ...[
130
148
  themeValue,
131
149
  ...extensions
132
- ].map((e)=>value1(e, resolveThemePath, utils)
150
+ ].map((e)=>value(e, resolveThemePath, utils)
133
151
  ), mergeExtensionCustomizer)
134
152
  ;
135
153
  });
@@ -143,7 +161,13 @@ function resolveFunctionKeys(object) {
143
161
  val = val[path[index++]];
144
162
  val = isFunction(val) ? val(resolvePath, configUtils) : val;
145
163
  }
146
- return val === undefined ? defaultValue : val;
164
+ if (val === undefined) {
165
+ return defaultValue;
166
+ }
167
+ if ((0, _isPlainObject).default(val)) {
168
+ return (0, _cloneDeep).cloneDeep(val);
169
+ }
170
+ return val;
147
171
  };
148
172
  resolvePath.theme = resolvePath;
149
173
  for(let key1 in configUtils){
@@ -154,8 +178,7 @@ function resolveFunctionKeys(object) {
154
178
  ...resolved,
155
179
  [key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
156
180
  };
157
- }, {
158
- });
181
+ }, {});
159
182
  }
160
183
  function extractPluginConfigs(configs) {
161
184
  let allConfigs = [];
@@ -177,8 +200,7 @@ function extractPluginConfigs(configs) {
177
200
  allConfigs = [
178
201
  ...allConfigs,
179
202
  ...extractPluginConfigs([
180
- (ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {
181
- }
203
+ (ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {}
182
204
  ])
183
205
  ];
184
206
  });
@@ -222,8 +244,7 @@ function resolveConfig(configs) {
222
244
  var ref, ref2;
223
245
  return (0, _normalizeConfig).normalizeConfig((0, _defaults).defaults({
224
246
  theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
225
- return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {
226
- };
247
+ return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {};
227
248
  })))),
228
249
  corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins
229
250
  )),
@@ -45,8 +45,7 @@ function resolveConfigPath(pathOrConfig) {
45
45
  const configPath = _path.default.resolve(configFile);
46
46
  _fs.default.accessSync(configPath);
47
47
  return configPath;
48
- } catch (err) {
49
- }
48
+ } catch (err) {}
50
49
  }
51
50
  return null;
52
51
  }
@@ -4,6 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.default = toColorValue;
6
6
  function toColorValue(maybeFunction) {
7
- return typeof maybeFunction === 'function' ? maybeFunction({
8
- }) : maybeFunction;
7
+ return typeof maybeFunction === 'function' ? maybeFunction({}) : maybeFunction;
9
8
  }
@@ -5,5 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.toPath = toPath;
6
6
  function toPath(path) {
7
7
  if (Array.isArray(path)) return path;
8
- return path.split(/[\.\]\[]+/g);
8
+ let openBrackets = path.split('[').length - 1;
9
+ let closedBrackets = path.split(']').length - 1;
10
+ if (openBrackets !== closedBrackets) {
11
+ throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`);
12
+ }
13
+ return path.split(/\.(?![^\[]*\])|[\[\]]/g).filter(Boolean);
9
14
  }