tailwindcss 0.0.0-insiders.a4d1bdb → 0.0.0-insiders.abcd9ac

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.
@@ -1797,7 +1797,7 @@ exports.backgroundColor = backgroundColor;
1797
1797
  let backgroundOpacity = (0, _createUtilityPlugin.default)('backgroundOpacity', [['bg-opacity', ['--tw-bg-opacity']]]);
1798
1798
  exports.backgroundOpacity = backgroundOpacity;
1799
1799
  let backgroundImage = (0, _createUtilityPlugin.default)('backgroundImage', [['bg', ['background-image']]], {
1800
- resolveArbitraryValue: _pluginUtils.asLookupValue
1800
+ resolveArbitraryValue: [_pluginUtils.asLookupValue, _pluginUtils.asURL]
1801
1801
  });
1802
1802
  exports.backgroundImage = backgroundImage;
1803
1803
 
@@ -1984,7 +1984,7 @@ let stroke = ({
1984
1984
 
1985
1985
  exports.stroke = stroke;
1986
1986
  let strokeWidth = (0, _createUtilityPlugin.default)('strokeWidth', [['stroke', ['stroke-width']]], {
1987
- resolveArbitraryValue: _pluginUtils.asLength
1987
+ resolveArbitraryValue: [_pluginUtils.asLength, _pluginUtils.asURL]
1988
1988
  });
1989
1989
  exports.strokeWidth = strokeWidth;
1990
1990
 
@@ -21,7 +21,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
21
21
 
22
22
  let env = sharedState.env;
23
23
  let contentMatchCache = sharedState.contentMatchCache;
24
- const PATTERNS = [/([^<>"'`\s]*\['[^"'`\s]*'\])/.source, // `content-['hello']` but not `content-['hello']']`
24
+ const PATTERNS = [/([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source, // bg-[url('...')]
25
+ /([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source, // bg-[url("...")]
26
+ /([^<>"'`\s]*\['[^"'`\s]*'\])/.source, // `content-['hello']` but not `content-['hello']']`
25
27
  /([^<>"'`\s]*\["[^"'`\s]*"\])/.source, // `content-["hello"]` but not `content-["hello"]"]`
26
28
  /([^<>"'`\s]*\[[^"'`\s]+\])/.source, // `fill-[#bada55]`
27
29
  /([^<>"'`\s]*[^"'`\s:])/.source // `px-1.5`, `uppercase` but not `uppercase:`].join('|')
@@ -11,7 +11,7 @@ var _pluginUtils = require("../util/pluginUtils");
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- let asMap = new Map([[_pluginUtils.asValue, 'any'], [_pluginUtils.asColor, 'color'], [_pluginUtils.asAngle, 'angle'], [_pluginUtils.asLength, 'length'], [_pluginUtils.asLookupValue, 'lookup']]);
14
+ let asMap = new Map([[_pluginUtils.asValue, 'any'], [_pluginUtils.asColor, 'color'], [_pluginUtils.asAngle, 'angle'], [_pluginUtils.asLength, 'length'], [_pluginUtils.asURL, 'url'], [_pluginUtils.asLookupValue, 'lookup']]);
15
15
 
16
16
  function createUtilityPlugin(themeKey, utilityVariations = [[themeKey, [themeKey]]], {
17
17
  filterDefault = false,
@@ -23,7 +23,7 @@ function createUtilityPlugin(themeKey, utilityVariations = [[themeKey, [themeKey
23
23
  theme
24
24
  }) {
25
25
  for (let utilityVariation of utilityVariations) {
26
- var _theme, _asMap$get;
26
+ var _theme, _asMap$get2;
27
27
 
28
28
  let group = Array.isArray(utilityVariation[0]) ? utilityVariation : [utilityVariation];
29
29
  matchUtilities(group.reduce((obj, [classPrefix, properties]) => {
@@ -44,7 +44,11 @@ function createUtilityPlugin(themeKey, utilityVariations = [[themeKey, [themeKey
44
44
  });
45
45
  }, {}), {
46
46
  values: filterDefault ? Object.fromEntries(Object.entries((_theme = theme(themeKey)) !== null && _theme !== void 0 ? _theme : {}).filter(([modifier]) => modifier !== 'DEFAULT')) : theme(themeKey),
47
- type: (_asMap$get = asMap.get(resolveArbitraryValue)) !== null && _asMap$get !== void 0 ? _asMap$get : 'any'
47
+ type: Array.isArray(resolveArbitraryValue) ? resolveArbitraryValue.map(typeResolver => {
48
+ var _asMap$get;
49
+
50
+ return (_asMap$get = asMap.get(typeResolver)) !== null && _asMap$get !== void 0 ? _asMap$get : 'any';
51
+ }) : (_asMap$get2 = asMap.get(resolveArbitraryValue)) !== null && _asMap$get2 !== void 0 ? _asMap$get2 : 'any'
48
52
  });
49
53
  }
50
54
  };
@@ -13,6 +13,7 @@ exports.asValue = asValue;
13
13
  exports.asUnit = asUnit;
14
14
  exports.asColor = asColor;
15
15
  exports.asAngle = asAngle;
16
+ exports.asURL = asURL;
16
17
  exports.asLength = asLength;
17
18
  exports.asLookupValue = asLookupValue;
18
19
  exports.coerceValue = coerceValue;
@@ -223,7 +224,9 @@ function asValue(modifier, lookup = {}, {
223
224
  } // convert `_` to ` `, escept for escaped underscores `\_`
224
225
 
225
226
 
226
- value = value.replace(/([^\\])_/g, '$1 ').replace(/^_/g, ' ').replace(/\\_/g, '_'); // add spaces around operators inside calc() that do not follow an operator or (
227
+ value = value.replace(/([^\\])_/g, '$1 ').replace(/^_/g, ' ').replace(/\\_/g, '_'); // Keep raw strings if it starts with `url(`
228
+
229
+ if (value.startsWith('url(')) return value; // add spaces around operators inside calc() that do not follow an operator or (
227
230
 
228
231
  return value.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, '$1 $2 ');
229
232
  }
@@ -281,6 +284,12 @@ function asAngle(modifier, lookup = {}) {
281
284
  return asUnit(modifier, ['deg', 'grad', 'rad', 'turn'], lookup);
282
285
  }
283
286
 
287
+ function asURL(modifier, lookup = {}) {
288
+ return asValue(modifier, lookup, {
289
+ validate: value => value.startsWith('url(')
290
+ });
291
+ }
292
+
284
293
  function asLength(modifier, lookup = {}) {
285
294
  return asUnit(modifier, ['cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px', 'em', 'ex', 'ch', 'rem', 'lh', 'vw', 'vh', 'vmin', 'vmax', '%'], lookup);
286
295
  }
@@ -294,6 +303,7 @@ let typeMap = {
294
303
  color: asColor,
295
304
  angle: asAngle,
296
305
  length: asLength,
306
+ url: asURL,
297
307
  lookup: asLookupValue
298
308
  };
299
309
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "0.0.0-insiders.a4d1bdb",
3
+ "version": "0.0.0-insiders.abcd9ac",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -17,6 +17,7 @@ import {
17
17
  transformAllClasses,
18
18
  transformLastClasses,
19
19
  asLength,
20
+ asURL,
20
21
  asLookupValue,
21
22
  } from './util/pluginUtils'
22
23
  import packageJson from '../package.json'
@@ -1361,7 +1362,7 @@ export let backgroundOpacity = createUtilityPlugin('backgroundOpacity', [
1361
1362
  export let backgroundImage = createUtilityPlugin(
1362
1363
  'backgroundImage',
1363
1364
  [['bg', ['background-image']]],
1364
- { resolveArbitraryValue: asLookupValue }
1365
+ { resolveArbitraryValue: [asLookupValue, asURL] }
1365
1366
  )
1366
1367
  export let gradientColorStops = (() => {
1367
1368
  function transparentTo(value) {
@@ -1482,7 +1483,7 @@ export let stroke = ({ matchUtilities, theme }) => {
1482
1483
  }
1483
1484
 
1484
1485
  export let strokeWidth = createUtilityPlugin('strokeWidth', [['stroke', ['stroke-width']]], {
1485
- resolveArbitraryValue: asLength,
1486
+ resolveArbitraryValue: [asLength, asURL],
1486
1487
  })
1487
1488
 
1488
1489
  export let objectFit = ({ addUtilities }) => {
@@ -7,6 +7,8 @@ let env = sharedState.env
7
7
  let contentMatchCache = sharedState.contentMatchCache
8
8
 
9
9
  const PATTERNS = [
10
+ /([^<>"'`\s]*\[\w*\('[^"'`\s]*'\)\])/.source, // bg-[url('...')]
11
+ /([^<>"'`\s]*\[\w*\("[^"'`\s]*"\)\])/.source, // bg-[url("...")]
10
12
  /([^<>"'`\s]*\['[^"'`\s]*'\])/.source, // `content-['hello']` but not `content-['hello']']`
11
13
  /([^<>"'`\s]*\["[^"'`\s]*"\])/.source, // `content-["hello"]` but not `content-["hello"]"]`
12
14
  /([^<>"'`\s]*\[[^"'`\s]+\])/.source, // `fill-[#bada55]`
@@ -1,11 +1,12 @@
1
1
  import transformThemeValue from './transformThemeValue'
2
- import { asValue, asColor, asAngle, asLength, asLookupValue } from '../util/pluginUtils'
2
+ import { asValue, asColor, asAngle, asLength, asURL, asLookupValue } from '../util/pluginUtils'
3
3
 
4
4
  let asMap = new Map([
5
5
  [asValue, 'any'],
6
6
  [asColor, 'color'],
7
7
  [asAngle, 'angle'],
8
8
  [asLength, 'length'],
9
+ [asURL, 'url'],
9
10
  [asLookupValue, 'lookup'],
10
11
  ])
11
12
 
@@ -38,7 +39,9 @@ export default function createUtilityPlugin(
38
39
  Object.entries(theme(themeKey) ?? {}).filter(([modifier]) => modifier !== 'DEFAULT')
39
40
  )
40
41
  : theme(themeKey),
41
- type: asMap.get(resolveArbitraryValue) ?? 'any',
42
+ type: Array.isArray(resolveArbitraryValue)
43
+ ? resolveArbitraryValue.map((typeResolver) => asMap.get(typeResolver) ?? 'any')
44
+ : asMap.get(resolveArbitraryValue) ?? 'any',
42
45
  }
43
46
  )
44
47
  }
@@ -175,6 +175,9 @@ export function asValue(modifier, lookup = {}, { validate = () => true } = {}) {
175
175
  .replace(/^_/g, ' ')
176
176
  .replace(/\\_/g, '_')
177
177
 
178
+ // Keep raw strings if it starts with `url(`
179
+ if (value.startsWith('url(')) return value
180
+
178
181
  // add spaces around operators inside calc() that do not follow an operator or (
179
182
  return value.replace(
180
183
  /(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,
@@ -236,6 +239,12 @@ export function asAngle(modifier, lookup = {}) {
236
239
  return asUnit(modifier, ['deg', 'grad', 'rad', 'turn'], lookup)
237
240
  }
238
241
 
242
+ export function asURL(modifier, lookup = {}) {
243
+ return asValue(modifier, lookup, {
244
+ validate: (value) => value.startsWith('url('),
245
+ })
246
+ }
247
+
239
248
  export function asLength(modifier, lookup = {}) {
240
249
  return asUnit(
241
250
  modifier,
@@ -271,6 +280,7 @@ let typeMap = {
271
280
  color: asColor,
272
281
  angle: asAngle,
273
282
  length: asLength,
283
+ url: asURL,
274
284
  lookup: asLookupValue,
275
285
  }
276
286