tailwindcss 0.0.0-insiders.ca1dfd6 → 0.0.0-insiders.cab1fce

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 (148) hide show
  1. package/CHANGELOG.md +380 -1
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.d.ts +3 -0
  5. package/colors.js +2 -1
  6. package/defaultConfig.d.ts +3 -0
  7. package/defaultConfig.js +2 -1
  8. package/defaultTheme.d.ts +3 -0
  9. package/defaultTheme.js +2 -1
  10. package/lib/cli-peer-dependencies.js +10 -5
  11. package/lib/cli.js +311 -213
  12. package/lib/constants.js +9 -9
  13. package/lib/corePluginList.js +11 -1
  14. package/lib/corePlugins.js +1895 -1773
  15. package/lib/css/preflight.css +19 -13
  16. package/lib/featureFlags.js +22 -16
  17. package/lib/index.js +17 -8
  18. package/lib/lib/cacheInvalidation.js +69 -0
  19. package/lib/lib/collapseAdjacentRules.js +30 -14
  20. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  21. package/lib/lib/defaultExtractor.js +187 -0
  22. package/lib/lib/detectNesting.js +17 -2
  23. package/lib/lib/evaluateTailwindFunctions.js +40 -24
  24. package/lib/lib/expandApplyAtRules.js +414 -157
  25. package/lib/lib/expandTailwindAtRules.js +156 -151
  26. package/lib/lib/generateRules.js +402 -68
  27. package/lib/lib/getModuleDependencies.js +14 -14
  28. package/lib/lib/normalizeTailwindDirectives.js +45 -36
  29. package/lib/lib/partitionApplyAtRules.js +53 -0
  30. package/lib/lib/regex.js +53 -0
  31. package/lib/lib/resolveDefaultsAtRules.js +105 -90
  32. package/lib/lib/setupContextUtils.js +416 -291
  33. package/lib/lib/setupTrackingContext.js +60 -56
  34. package/lib/lib/sharedState.js +38 -15
  35. package/lib/lib/substituteScreenAtRules.js +9 -6
  36. package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
  37. package/lib/postcss-plugins/nesting/index.js +17 -0
  38. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  39. package/lib/processTailwindFeatures.js +21 -9
  40. package/lib/public/colors.js +244 -248
  41. package/lib/public/resolve-config.js +5 -5
  42. package/lib/util/buildMediaQuery.js +13 -24
  43. package/lib/util/cloneDeep.js +1 -1
  44. package/lib/util/cloneNodes.js +12 -1
  45. package/lib/util/color.js +43 -32
  46. package/lib/util/createPlugin.js +1 -2
  47. package/lib/util/createUtilityPlugin.js +13 -17
  48. package/lib/util/dataTypes.js +114 -74
  49. package/lib/util/defaults.js +6 -0
  50. package/lib/util/escapeClassName.js +5 -5
  51. package/lib/util/escapeCommas.js +1 -1
  52. package/lib/util/flattenColorPalette.js +2 -4
  53. package/lib/util/formatVariantSelector.js +194 -0
  54. package/lib/util/getAllConfigs.js +13 -5
  55. package/lib/util/hashConfig.js +5 -5
  56. package/lib/util/isKeyframeRule.js +1 -1
  57. package/lib/util/isPlainObject.js +1 -1
  58. package/lib/util/isValidArbitraryValue.js +64 -0
  59. package/lib/util/log.js +35 -19
  60. package/lib/util/nameClass.js +7 -6
  61. package/lib/util/negateValue.js +5 -3
  62. package/lib/util/normalizeConfig.js +233 -0
  63. package/lib/util/normalizeScreens.js +59 -0
  64. package/lib/util/parseAnimationValue.js +56 -56
  65. package/lib/util/parseBoxShadowValue.js +76 -0
  66. package/lib/util/parseDependency.js +32 -32
  67. package/lib/util/parseObjectStyles.js +6 -6
  68. package/lib/util/pluginUtils.js +67 -170
  69. package/lib/util/prefixSelector.js +4 -7
  70. package/lib/util/resolveConfig.js +123 -133
  71. package/lib/util/resolveConfigPath.js +17 -18
  72. package/lib/util/responsive.js +6 -6
  73. package/lib/util/splitAtTopLevelOnly.js +72 -0
  74. package/lib/util/toColorValue.js +1 -2
  75. package/lib/util/toPath.js +6 -1
  76. package/lib/util/transformThemeValue.js +42 -34
  77. package/lib/util/validateConfig.js +21 -0
  78. package/lib/util/withAlphaVariable.js +19 -19
  79. package/nesting/index.js +2 -12
  80. package/package.json +41 -42
  81. package/peers/index.js +11539 -10859
  82. package/plugin.d.ts +11 -0
  83. package/plugin.js +2 -1
  84. package/resolveConfig.js +2 -1
  85. package/scripts/create-plugin-list.js +2 -2
  86. package/scripts/generate-types.js +52 -0
  87. package/src/cli-peer-dependencies.js +7 -1
  88. package/src/cli.js +174 -41
  89. package/src/corePluginList.js +1 -1
  90. package/src/corePlugins.js +641 -596
  91. package/src/css/preflight.css +19 -13
  92. package/src/featureFlags.js +16 -10
  93. package/src/index.js +14 -6
  94. package/src/lib/cacheInvalidation.js +52 -0
  95. package/src/lib/collapseAdjacentRules.js +21 -2
  96. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  97. package/src/lib/defaultExtractor.js +192 -0
  98. package/src/lib/detectNesting.js +22 -3
  99. package/src/lib/evaluateTailwindFunctions.js +24 -7
  100. package/src/lib/expandApplyAtRules.js +442 -154
  101. package/src/lib/expandTailwindAtRules.js +91 -65
  102. package/src/lib/generateRules.js +409 -43
  103. package/src/lib/normalizeTailwindDirectives.js +10 -3
  104. package/src/lib/partitionApplyAtRules.js +52 -0
  105. package/src/lib/regex.js +74 -0
  106. package/src/lib/resolveDefaultsAtRules.js +74 -53
  107. package/src/lib/setupContextUtils.js +388 -208
  108. package/src/lib/setupTrackingContext.js +15 -12
  109. package/src/lib/sharedState.js +42 -7
  110. package/src/lib/substituteScreenAtRules.js +6 -3
  111. package/src/postcss-plugins/nesting/README.md +42 -0
  112. package/src/postcss-plugins/nesting/index.js +13 -0
  113. package/src/postcss-plugins/nesting/plugin.js +80 -0
  114. package/src/processTailwindFeatures.js +17 -2
  115. package/src/public/colors.js +4 -9
  116. package/src/util/buildMediaQuery.js +14 -18
  117. package/src/util/cloneNodes.js +14 -1
  118. package/src/util/color.js +31 -14
  119. package/src/util/createUtilityPlugin.js +2 -2
  120. package/src/util/dataTypes.js +56 -16
  121. package/src/util/defaults.js +6 -0
  122. package/src/util/formatVariantSelector.js +213 -0
  123. package/src/util/getAllConfigs.js +7 -0
  124. package/src/util/isValidArbitraryValue.js +61 -0
  125. package/src/util/log.js +23 -22
  126. package/src/util/nameClass.js +2 -2
  127. package/src/util/negateValue.js +4 -2
  128. package/src/util/normalizeConfig.js +262 -0
  129. package/src/util/normalizeScreens.js +45 -0
  130. package/src/util/parseBoxShadowValue.js +72 -0
  131. package/src/util/pluginUtils.js +51 -147
  132. package/src/util/prefixSelector.js +7 -8
  133. package/src/util/resolveConfig.js +108 -79
  134. package/src/util/splitAtTopLevelOnly.js +71 -0
  135. package/src/util/toPath.js +23 -1
  136. package/src/util/transformThemeValue.js +24 -7
  137. package/src/util/validateConfig.js +13 -0
  138. package/stubs/defaultConfig.stub.js +157 -94
  139. package/stubs/simpleConfig.stub.js +0 -1
  140. package/types/config.d.ts +325 -0
  141. package/types/generated/.gitkeep +0 -0
  142. package/types/generated/colors.d.ts +276 -0
  143. package/types/generated/corePluginList.d.ts +1 -0
  144. package/types/index.d.ts +1 -0
  145. package/types.d.ts +1 -0
  146. package/lib/lib/setupWatchingContext.js +0 -284
  147. package/nesting/plugin.js +0 -41
  148. package/src/lib/setupWatchingContext.js +0 -306
@@ -8,19 +8,44 @@ var _corePluginList = _interopRequireDefault(require("../corePluginList"));
8
8
  var _configurePlugins = _interopRequireDefault(require("./configurePlugins"));
9
9
  var _defaultConfigStub = _interopRequireDefault(require("../../stubs/defaultConfig.stub"));
10
10
  var _colors = _interopRequireDefault(require("../public/colors"));
11
- var _log = _interopRequireDefault(require("./log"));
12
11
  var _defaults = require("./defaults");
13
12
  var _toPath = require("./toPath");
13
+ var _normalizeConfig = require("./normalizeConfig");
14
+ var _isPlainObject = _interopRequireDefault(require("./isPlainObject"));
15
+ var _cloneDeep = require("./cloneDeep");
16
+ var _withAlphaVariable = require("./withAlphaVariable");
17
+ function resolveConfig(configs) {
18
+ let allConfigs = [
19
+ ...extractPluginConfigs(configs),
20
+ {
21
+ prefix: "",
22
+ important: false,
23
+ separator: ":",
24
+ variantOrder: _defaultConfigStub.default.variantOrder
25
+ },
26
+ ];
27
+ var ref, ref1;
28
+ return (0, _normalizeConfig).normalizeConfig((0, _defaults).defaults({
29
+ theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
30
+ return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {};
31
+ })))),
32
+ corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins
33
+ )),
34
+ plugins: resolvePluginLists(configs.map((c)=>{
35
+ return (ref1 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref1 !== void 0 ? ref1 : [];
36
+ }))
37
+ }, ...allConfigs));
38
+ }
14
39
  function _interopRequireDefault(obj) {
15
40
  return obj && obj.__esModule ? obj : {
16
41
  default: obj
17
42
  };
18
43
  }
19
44
  function isFunction(input) {
20
- return typeof input === 'function';
45
+ return typeof input === "function";
21
46
  }
22
47
  function isObject(input) {
23
- return typeof input === 'object' && input !== null;
48
+ return typeof input === "object" && input !== null;
24
49
  }
25
50
  function mergeWith(target, ...sources) {
26
51
  let customizer = sources.pop();
@@ -43,22 +68,45 @@ function mergeWith(target, ...sources) {
43
68
  const configUtils = {
44
69
  colors: _colors.default,
45
70
  negative (scale) {
46
- return Object.keys(scale).filter((key)=>scale[key] !== '0'
47
- ).reduce((negativeScale, key)=>({
48
- ...negativeScale,
49
- [`-${key}`]: (0, _negateValue).default(scale[key])
50
- })
51
- , {
52
- });
71
+ // TODO: Log that this function isn't really needed anymore?
72
+ return Object.keys(scale).filter((key)=>scale[key] !== "0"
73
+ ).reduce((negativeScale, key)=>{
74
+ let negativeValue = (0, _negateValue).default(scale[key]);
75
+ if (negativeValue !== undefined) {
76
+ negativeScale[`-${key}`] = negativeValue;
77
+ }
78
+ return negativeScale;
79
+ }, {});
53
80
  },
54
81
  breakpoints (screens) {
55
- return Object.keys(screens).filter((key)=>typeof screens[key] === 'string'
82
+ return Object.keys(screens).filter((key)=>typeof screens[key] === "string"
56
83
  ).reduce((breakpoints, key)=>({
57
84
  ...breakpoints,
58
85
  [`screen-${key}`]: screens[key]
59
86
  })
60
- , {
61
- });
87
+ , {});
88
+ },
89
+ rgb (property) {
90
+ if (!property.startsWith("--")) {
91
+ throw new Error("The rgb() helper requires a custom property name to be passed as the first argument.");
92
+ }
93
+ return ({ opacityValue })=>{
94
+ if (opacityValue === undefined || opacityValue === 1) {
95
+ return `rgb(var(${property}) / 1.0)`;
96
+ }
97
+ return `rgb(var(${property}) / ${opacityValue})`;
98
+ };
99
+ },
100
+ hsl (property) {
101
+ if (!property.startsWith("--")) {
102
+ throw new Error("The hsl() helper requires a custom property name to be passed as the first argument.");
103
+ }
104
+ return ({ opacityValue })=>{
105
+ if (opacityValue === undefined || opacityValue === 1) {
106
+ return `hsl(var(${property}) / 1)`;
107
+ }
108
+ return `hsl(var(${property}) / ${opacityValue})`;
109
+ };
62
110
  }
63
111
  };
64
112
  function value(valueToResolve, ...args) {
@@ -83,34 +131,32 @@ function collectExtends(items) {
83
131
  mergedValue
84
132
  ];
85
133
  });
86
- }, {
87
- });
134
+ }, {});
88
135
  }
89
136
  function mergeThemes(themes) {
90
137
  return {
91
138
  ...themes.reduce((merged, theme)=>(0, _defaults).defaults(merged, theme)
92
- , {
93
- }),
139
+ , {}),
94
140
  // In order to resolve n config objects, we combine all of their `extend` properties
95
141
  // into arrays instead of objects so they aren't overridden.
96
142
  extend: collectExtends(themes)
97
143
  };
98
144
  }
99
- function mergeExtensionCustomizer(merged, value) {
145
+ function mergeExtensionCustomizer(merged, value1) {
100
146
  // When we have an array of objects, we do want to merge it
101
147
  if (Array.isArray(merged) && isObject(merged[0])) {
102
- return merged.concat(value);
148
+ return merged.concat(value1);
103
149
  }
104
150
  // When the incoming value is an array, and the existing config is an object, prepend the existing object
105
- if (Array.isArray(value) && isObject(value[0]) && isObject(merged)) {
151
+ if (Array.isArray(value1) && isObject(value1[0]) && isObject(merged)) {
106
152
  return [
107
153
  merged,
108
- ...value
154
+ ...value1
109
155
  ];
110
156
  }
111
157
  // Override arrays (for example for font-families, box-shadows, ...)
112
- if (Array.isArray(value)) {
113
- return value;
158
+ if (Array.isArray(value1)) {
159
+ return value1;
114
160
  }
115
161
  // Execute default behaviour
116
162
  return undefined;
@@ -119,11 +165,9 @@ function mergeExtensions({ extend , ...theme }) {
119
165
  return mergeWith(theme, extend, (themeValue, extensions)=>{
120
166
  // The `extend` property is an array, so we need to check if it contains any functions
121
167
  if (!isFunction(themeValue) && !extensions.some(isFunction)) {
122
- return mergeWith({
123
- }, themeValue, ...extensions, mergeExtensionCustomizer);
168
+ return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer);
124
169
  }
125
- return (resolveThemePath, utils)=>mergeWith({
126
- }, ...[
170
+ return (resolveThemePath, utils)=>mergeWith({}, ...[
127
171
  themeValue,
128
172
  ...extensions
129
173
  ].map((e)=>value(e, resolveThemePath, utils)
@@ -131,28 +175,60 @@ function mergeExtensions({ extend , ...theme }) {
131
175
  ;
132
176
  });
133
177
  }
178
+ /**
179
+ *
180
+ * @param {string} key
181
+ * @return {Iterable<string[] & {alpha: string | undefined}>}
182
+ */ function* toPaths(key) {
183
+ let path = (0, _toPath).toPath(key);
184
+ if (path.length === 0) {
185
+ return;
186
+ }
187
+ yield path;
188
+ if (Array.isArray(key)) {
189
+ return;
190
+ }
191
+ let pattern = /^(.*?)\s*\/\s*([^/]+)$/;
192
+ let matches = key.match(pattern);
193
+ if (matches !== null) {
194
+ let [, prefix, alpha] = matches;
195
+ let newPath = (0, _toPath).toPath(prefix);
196
+ newPath.alpha = alpha;
197
+ yield newPath;
198
+ }
199
+ }
134
200
  function resolveFunctionKeys(object) {
201
+ // theme('colors.red.500 / 0.5') -> ['colors', 'red', '500 / 0', '5]
135
202
  const resolvePath = (key, defaultValue)=>{
136
- const path = (0, _toPath).toPath(key);
137
- let index = 0;
138
- let val = object;
139
- while(val !== undefined && val !== null && index < path.length){
140
- val = val[path[index++]];
141
- val = isFunction(val) ? val(resolvePath, configUtils) : val;
203
+ for (const path of toPaths(key)){
204
+ let index = 0;
205
+ let val = object;
206
+ while(val !== undefined && val !== null && index < path.length){
207
+ val = val[path[index++]];
208
+ let shouldResolveAsFn = isFunction(val) && (path.alpha === undefined || index < path.length - 1);
209
+ val = shouldResolveAsFn ? val(resolvePath, configUtils) : val;
210
+ }
211
+ if (val !== undefined) {
212
+ if (path.alpha !== undefined) {
213
+ return (0, _withAlphaVariable).withAlphaValue(val, path.alpha);
214
+ }
215
+ if ((0, _isPlainObject).default(val)) {
216
+ return (0, _cloneDeep).cloneDeep(val);
217
+ }
218
+ return val;
219
+ }
142
220
  }
143
- return val === undefined ? defaultValue : val;
221
+ return defaultValue;
144
222
  };
145
- resolvePath.theme = resolvePath;
146
- for(let key in configUtils){
147
- resolvePath[key] = configUtils[key];
148
- }
149
- return Object.keys(object).reduce((resolved, key)=>{
150
- return {
151
- ...resolved,
152
- [key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
153
- };
154
- }, {
223
+ // colors.red.500/50
224
+ Object.assign(resolvePath, {
225
+ theme: resolvePath,
226
+ ...configUtils
155
227
  });
228
+ return Object.keys(object).reduce((resolved, key)=>{
229
+ resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key];
230
+ return resolved;
231
+ }, {});
156
232
  }
157
233
  function extractPluginConfigs(configs) {
158
234
  let allConfigs = [];
@@ -161,8 +237,8 @@ function extractPluginConfigs(configs) {
161
237
  ...allConfigs,
162
238
  config
163
239
  ];
164
- var ref;
165
- const plugins = (ref = config === null || config === void 0 ? void 0 : config.plugins) !== null && ref !== void 0 ? ref : [];
240
+ var ref2;
241
+ const plugins = (ref2 = config === null || config === void 0 ? void 0 : config.plugins) !== null && ref2 !== void 0 ? ref2 : [];
166
242
  if (plugins.length === 0) {
167
243
  return;
168
244
  }
@@ -174,8 +250,7 @@ function extractPluginConfigs(configs) {
174
250
  allConfigs = [
175
251
  ...allConfigs,
176
252
  ...extractPluginConfigs([
177
- (ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {
178
- }
253
+ (ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {}
179
254
  ])
180
255
  ];
181
256
  });
@@ -206,88 +281,3 @@ function resolvePluginLists(pluginLists) {
206
281
  }, []);
207
282
  return result;
208
283
  }
209
- function resolveConfig(configs) {
210
- let allConfigs = [
211
- ...extractPluginConfigs(configs),
212
- {
213
- prefix: '',
214
- important: false,
215
- separator: ':',
216
- variantOrder: _defaultConfigStub.default.variantOrder
217
- },
218
- ];
219
- var ref, ref1;
220
- return normalizeConfig((0, _defaults).defaults({
221
- theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
222
- return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {
223
- };
224
- })))),
225
- corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins
226
- )),
227
- plugins: resolvePluginLists(configs.map((c)=>{
228
- return (ref1 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref1 !== void 0 ? ref1 : [];
229
- }))
230
- }, ...allConfigs));
231
- }
232
- let warnedAbout = new Set();
233
- function normalizeConfig(config) {
234
- var ref, ref1, ref2, ref3, ref4, ref5;
235
- if (!warnedAbout.has('purge-deprecation') && config.hasOwnProperty('purge')) {
236
- _log.default.warn([
237
- 'The `purge` option in your tailwind.config.js file has been deprecated.',
238
- 'Please rename this to `content` instead.',
239
- ]);
240
- warnedAbout.add('purge-deprecation');
241
- }
242
- config.content = {
243
- content: (()=>{
244
- let { content , purge } = config;
245
- if (Array.isArray(purge)) return purge;
246
- if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.content)) return purge.content;
247
- if (Array.isArray(content)) return content;
248
- if (Array.isArray(content === null || content === void 0 ? void 0 : content.content)) return content.content;
249
- return [];
250
- })(),
251
- safelist: (()=>{
252
- let { content , purge } = config;
253
- let [safelistKey, safelistPaths] = (()=>{
254
- var ref;
255
- if (Array.isArray(content === null || content === void 0 ? void 0 : content.safelist)) return [
256
- 'content.safelist',
257
- content.safelist
258
- ];
259
- if (Array.isArray(purge === null || purge === void 0 ? void 0 : purge.safelist)) return [
260
- 'purge.safelist',
261
- purge.safelist
262
- ];
263
- if (Array.isArray(purge === null || purge === void 0 ? void 0 : (ref = purge.options) === null || ref === void 0 ? void 0 : ref.safelist)) return [
264
- 'purge.options.safelist',
265
- purge.options.safelist
266
- ];
267
- return [
268
- null,
269
- []
270
- ];
271
- })();
272
- return safelistPaths.map((content)=>{
273
- if (typeof content === 'string') {
274
- return {
275
- raw: content,
276
- extension: 'html'
277
- };
278
- }
279
- if (content instanceof RegExp) {
280
- throw new Error(`Values inside '${safelistKey}' can only be of type 'string', found 'regex'.`);
281
- }
282
- throw new Error(`Values inside '${safelistKey}' can only be of type 'string', found '${typeof content}'.`);
283
- });
284
- })(),
285
- extract: ((ref = config.content) === null || ref === void 0 ? void 0 : ref.extract) || ((ref1 = config.purge) === null || ref1 === void 0 ? void 0 : ref1.extract) || {
286
- },
287
- options: ((ref2 = config.content) === null || ref2 === void 0 ? void 0 : ref2.options) || ((ref3 = config.purge) === null || ref3 === void 0 ? void 0 : ref3.options) || {
288
- },
289
- transform: ((ref4 = config.content) === null || ref4 === void 0 ? void 0 : ref4.transform) || ((ref5 = config.purge) === null || ref5 === void 0 ? void 0 : ref5.transform) || {
290
- }
291
- };
292
- return config;
293
- }
@@ -5,20 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.default = resolveConfigPath;
6
6
  var _fs = _interopRequireDefault(require("fs"));
7
7
  var _path = _interopRequireDefault(require("path"));
8
- function _interopRequireDefault(obj) {
9
- return obj && obj.__esModule ? obj : {
10
- default: obj
11
- };
12
- }
13
- function isObject(value) {
14
- return typeof value === 'object' && value !== null;
15
- }
16
- function isEmpty(obj) {
17
- return Object.keys(obj).length === 0;
18
- }
19
- function isString(value) {
20
- return typeof value === 'string' || value instanceof String;
21
- }
22
8
  function resolveConfigPath(pathOrConfig) {
23
9
  // require('tailwindcss')({ theme: ..., variants: ... })
24
10
  if (isObject(pathOrConfig) && pathOrConfig.config === undefined && !isEmpty(pathOrConfig)) {
@@ -38,15 +24,28 @@ function resolveConfigPath(pathOrConfig) {
38
24
  }
39
25
  // require('tailwindcss')
40
26
  for (const configFile of [
41
- './tailwind.config.js',
42
- './tailwind.config.cjs'
27
+ "./tailwind.config.js",
28
+ "./tailwind.config.cjs"
43
29
  ]){
44
30
  try {
45
31
  const configPath = _path.default.resolve(configFile);
46
32
  _fs.default.accessSync(configPath);
47
33
  return configPath;
48
- } catch (err) {
49
- }
34
+ } catch (err) {}
50
35
  }
51
36
  return null;
52
37
  }
38
+ function _interopRequireDefault(obj) {
39
+ return obj && obj.__esModule ? obj : {
40
+ default: obj
41
+ };
42
+ }
43
+ function isObject(value) {
44
+ return typeof value === "object" && value !== null;
45
+ }
46
+ function isEmpty(obj) {
47
+ return Object.keys(obj).length === 0;
48
+ }
49
+ function isString(value) {
50
+ return typeof value === "string" || value instanceof String;
51
+ }
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.default = responsive;
6
6
  var _postcss = _interopRequireDefault(require("postcss"));
7
7
  var _cloneNodes = _interopRequireDefault(require("./cloneNodes"));
8
- function _interopRequireDefault(obj) {
9
- return obj && obj.__esModule ? obj : {
10
- default: obj
11
- };
12
- }
13
8
  function responsive(rules) {
14
9
  return _postcss.default.atRule({
15
- name: 'responsive'
10
+ name: "responsive"
16
11
  }).append((0, _cloneNodes).default(Array.isArray(rules) ? rules : [
17
12
  rules
18
13
  ]));
19
14
  }
15
+ function _interopRequireDefault(obj) {
16
+ return obj && obj.__esModule ? obj : {
17
+ default: obj
18
+ };
19
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.splitAtTopLevelOnly = splitAtTopLevelOnly;
6
+ var regex = _interopRequireWildcard(require("../lib/regex"));
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
+ }
27
+ }
28
+ function* splitAtTopLevelOnly(input, separator) {
29
+ let SPECIALS = new RegExp(`[(){}\\[\\]${regex.escape(separator)}]`, "g");
30
+ let depth = 0;
31
+ let lastIndex = 0;
32
+ let found = false;
33
+ let separatorIndex = 0;
34
+ let separatorStart = 0;
35
+ let separatorLength = separator.length;
36
+ // Find all paren-like things & character
37
+ // And only split on commas if they're top-level
38
+ for (let match of input.matchAll(SPECIALS)){
39
+ let matchesSeparator = match[0] === separator[separatorIndex];
40
+ let atEndOfSeparator = separatorIndex === separatorLength - 1;
41
+ let matchesFullSeparator = matchesSeparator && atEndOfSeparator;
42
+ if (match[0] === "(") depth++;
43
+ if (match[0] === ")") depth--;
44
+ if (match[0] === "[") depth++;
45
+ if (match[0] === "]") depth--;
46
+ if (match[0] === "{") depth++;
47
+ if (match[0] === "}") depth--;
48
+ if (matchesSeparator && depth === 0) {
49
+ if (separatorStart === 0) {
50
+ separatorStart = match.index;
51
+ }
52
+ separatorIndex++;
53
+ }
54
+ if (matchesFullSeparator && depth === 0) {
55
+ found = true;
56
+ yield input.substring(lastIndex, separatorStart);
57
+ lastIndex = separatorStart + separatorLength;
58
+ }
59
+ if (separatorIndex === separatorLength) {
60
+ separatorIndex = 0;
61
+ separatorStart = 0;
62
+ }
63
+ }
64
+ // Provide the last segment of the string if available
65
+ // Otherwise the whole string since no `char`s were found
66
+ // This mirrors the behavior of string.split()
67
+ if (found) {
68
+ yield input.substring(lastIndex);
69
+ } else {
70
+ yield input;
71
+ }
72
+ }
@@ -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
  }
@@ -4,50 +4,58 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.default = transformThemeValue;
6
6
  var _postcss = _interopRequireDefault(require("postcss"));
7
- function _interopRequireDefault(obj) {
8
- return obj && obj.__esModule ? obj : {
9
- default: obj
10
- };
11
- }
12
7
  function transformThemeValue(themeSection) {
13
8
  if ([
14
- 'fontSize',
15
- 'outline'
9
+ "fontSize",
10
+ "outline"
16
11
  ].includes(themeSection)) {
17
- return (value)=>Array.isArray(value) ? value[0] : value
18
- ;
12
+ return (value)=>{
13
+ if (typeof value === "function") value = value({});
14
+ if (Array.isArray(value)) value = value[0];
15
+ return value;
16
+ };
19
17
  }
20
18
  if ([
21
- 'fontFamily',
22
- 'boxShadow',
23
- 'transitionProperty',
24
- 'transitionDuration',
25
- 'transitionDelay',
26
- 'transitionTimingFunction',
27
- 'backgroundImage',
28
- 'backgroundSize',
29
- 'backgroundColor',
30
- 'cursor',
31
- 'animation',
19
+ "fontFamily",
20
+ "boxShadow",
21
+ "transitionProperty",
22
+ "transitionDuration",
23
+ "transitionDelay",
24
+ "transitionTimingFunction",
25
+ "backgroundImage",
26
+ "backgroundSize",
27
+ "backgroundColor",
28
+ "cursor",
29
+ "animation",
32
30
  ].includes(themeSection)) {
33
- return (value)=>Array.isArray(value) ? value.join(', ') : value
34
- ;
31
+ return (value)=>{
32
+ if (typeof value === "function") value = value({});
33
+ if (Array.isArray(value)) value = value.join(", ");
34
+ return value;
35
+ };
35
36
  }
36
37
  // For backwards compatibility reasons, before we switched to underscores
37
38
  // instead of commas for arbitrary values.
38
39
  if ([
39
- 'gridTemplateColumns',
40
- 'gridTemplateRows',
41
- 'objectPosition'
40
+ "gridTemplateColumns",
41
+ "gridTemplateRows",
42
+ "objectPosition"
42
43
  ].includes(themeSection)) {
43
- return (value)=>typeof value === 'string' ? _postcss.default.list.comma(value).join(' ') : value
44
- ;
45
- }
46
- if (themeSection === 'colors') {
47
- return (value)=>typeof value === 'function' ? value({
48
- }) : value
49
- ;
44
+ return (value)=>{
45
+ if (typeof value === "function") value = value({});
46
+ if (typeof value === "string") value = _postcss.default.list.comma(value).join(" ");
47
+ return value;
48
+ };
50
49
  }
51
- return (value)=>value
52
- ;
50
+ return (value, opts = {})=>{
51
+ if (typeof value === "function") {
52
+ value = value(opts);
53
+ }
54
+ return value;
55
+ };
56
+ }
57
+ function _interopRequireDefault(obj) {
58
+ return obj && obj.__esModule ? obj : {
59
+ default: obj
60
+ };
53
61
  }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.validateConfig = validateConfig;
6
+ var _log = _interopRequireDefault(require("./log"));
7
+ function _interopRequireDefault(obj) {
8
+ return obj && obj.__esModule ? obj : {
9
+ default: obj
10
+ };
11
+ }
12
+ function validateConfig(config) {
13
+ if (config.content.files.length === 0) {
14
+ _log.default.warn("content-problems", [
15
+ "The `content` option in your Tailwind CSS configuration is missing or empty.",
16
+ "Configure your content sources or your generated CSS will be missing styles.",
17
+ "https://tailwindcss.com/docs/content-configuration",
18
+ ]);
19
+ }
20
+ return config;
21
+ }