@unocss/preset-mini 0.45.29 → 0.46.0

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 (35) hide show
  1. package/dist/{colors-67ae184f.d.ts → colors-4d254848.d.ts} +1 -1
  2. package/dist/colors.d.ts +3 -2
  3. package/dist/{default-016bd463.d.ts → default-9096842f.d.ts} +1 -1
  4. package/dist/index.cjs +8 -7
  5. package/dist/index.d.ts +5 -5
  6. package/dist/index.mjs +10 -9
  7. package/dist/rules.cjs +3 -3
  8. package/dist/rules.d.ts +1 -1
  9. package/dist/rules.mjs +3 -3
  10. package/dist/shared/{preset-mini.7346cef1.cjs → preset-mini.0109bbf2.cjs} +64 -17
  11. package/dist/shared/{preset-mini.dadc4e80.mjs → preset-mini.13105b6e.mjs} +2 -2
  12. package/dist/shared/preset-mini.154e3363.mjs +67 -0
  13. package/dist/shared/{preset-mini.3602602e.mjs → preset-mini.739fdcc7.mjs} +2 -3
  14. package/dist/shared/{preset-mini.eeab2052.cjs → preset-mini.7c4b1c47.cjs} +2 -2
  15. package/dist/shared/{preset-mini.b300afab.cjs → preset-mini.7f221566.cjs} +2 -3
  16. package/dist/shared/preset-mini.968d02ba.cjs +72 -0
  17. package/dist/shared/{preset-mini.42e5e280.mjs → preset-mini.9c5f881e.mjs} +65 -19
  18. package/dist/shared/{preset-mini.d7aeeb41.mjs → preset-mini.9e26490c.mjs} +180 -102
  19. package/dist/shared/{preset-mini.85263b33.mjs → preset-mini.ae98d318.mjs} +2 -2
  20. package/dist/shared/{preset-mini.5d1fe287.cjs → preset-mini.f5f22d9a.cjs} +2 -2
  21. package/dist/shared/{preset-mini.eaaf9ac5.cjs → preset-mini.fc97229a.cjs} +179 -101
  22. package/dist/theme.cjs +3 -3
  23. package/dist/theme.d.ts +5 -4
  24. package/dist/theme.mjs +3 -3
  25. package/dist/{types-c22910b5.d.ts → types-3dbe7f66.d.ts} +3 -0
  26. package/dist/{utilities-d1833377.d.ts → utilities-8393c8ff.d.ts} +5 -4
  27. package/dist/utils.cjs +5 -2
  28. package/dist/utils.d.ts +5 -3
  29. package/dist/utils.mjs +2 -2
  30. package/dist/variants.cjs +3 -3
  31. package/dist/variants.d.ts +4 -4
  32. package/dist/variants.mjs +3 -3
  33. package/package.json +2 -2
  34. package/dist/shared/preset-mini.6d3bd985.cjs +0 -45
  35. package/dist/shared/preset-mini.f73f9ed7.mjs +0 -42
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './types-c22910b5.js';
1
+ import { T as Theme } from './types-3dbe7f66.js';
2
2
 
3
3
  declare const colors: Theme['colors'];
4
4
 
package/dist/colors.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { c as colors } from './colors-67ae184f.js';
2
- import './types-c22910b5.js';
1
+ export { c as colors } from './colors-4d254848.js';
2
+ import './types-3dbe7f66.js';
3
+ import '@unocss/core';
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './types-c22910b5.js';
1
+ import { T as Theme } from './types-3dbe7f66.js';
2
2
 
3
3
  declare const theme: Theme;
4
4
 
package/dist/index.cjs CHANGED
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const core = require('@unocss/core');
6
- require('./shared/preset-mini.b300afab.cjs');
7
- const colors$1 = require('./shared/preset-mini.7346cef1.cjs');
8
- const _default$1 = require('./shared/preset-mini.5d1fe287.cjs');
6
+ require('./shared/preset-mini.7f221566.cjs');
7
+ const colors$1 = require('./shared/preset-mini.0109bbf2.cjs');
8
+ const _default$1 = require('./shared/preset-mini.f5f22d9a.cjs');
9
9
  const colors = require('./shared/preset-mini.30606736.cjs');
10
- const _default = require('./shared/preset-mini.eeab2052.cjs');
11
- const _default$2 = require('./shared/preset-mini.eaaf9ac5.cjs');
12
- require('./shared/preset-mini.6d3bd985.cjs');
10
+ const _default = require('./shared/preset-mini.7c4b1c47.cjs');
11
+ const _default$2 = require('./shared/preset-mini.fc97229a.cjs');
12
+ require('./shared/preset-mini.968d02ba.cjs');
13
13
 
14
14
  const preflights = [
15
15
  {
@@ -17,7 +17,8 @@ const preflights = [
17
17
  getCSS(ctx) {
18
18
  if (ctx.theme.preflightBase) {
19
19
  const css = core.entriesToCss(Object.entries(ctx.theme.preflightBase));
20
- return `*,::before,::after{${css}}::backdrop{${css}}`;
20
+ const roots = core.toArray(ctx.theme.preflightRoot ?? ["*,::before,::after", "::backdrop"]);
21
+ return roots.map((root) => `${root}{${css}}`).join("");
21
22
  }
22
23
  }
23
24
  }
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Preflight, PresetOptions, Preset } from '@unocss/core';
2
- export { c as colors } from './colors-67ae184f.js';
3
- export { t as theme } from './default-016bd463.js';
4
- import { T as Theme } from './types-c22910b5.js';
5
- export { T as Theme, a as ThemeAnimation } from './types-c22910b5.js';
6
- export { p as parseColor } from './utilities-d1833377.js';
2
+ export { c as colors } from './colors-4d254848.js';
3
+ export { t as theme } from './default-9096842f.js';
4
+ import { T as Theme } from './types-3dbe7f66.js';
5
+ export { T as Theme, a as ThemeAnimation } from './types-3dbe7f66.js';
6
+ export { p as parseColor } from './utilities-8393c8ff.js';
7
7
 
8
8
  declare const preflights: Preflight[];
9
9
 
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { entriesToCss } from '@unocss/core';
2
- import './shared/preset-mini.3602602e.mjs';
3
- export { p as parseColor } from './shared/preset-mini.42e5e280.mjs';
4
- import { r as rules } from './shared/preset-mini.dadc4e80.mjs';
1
+ import { entriesToCss, toArray } from '@unocss/core';
2
+ import './shared/preset-mini.739fdcc7.mjs';
3
+ export { p as parseColor } from './shared/preset-mini.9c5f881e.mjs';
4
+ import { r as rules } from './shared/preset-mini.13105b6e.mjs';
5
5
  export { c as colors } from './shared/preset-mini.65ac75be.mjs';
6
- import { t as theme } from './shared/preset-mini.85263b33.mjs';
7
- export { t as theme } from './shared/preset-mini.85263b33.mjs';
8
- import { v as variants } from './shared/preset-mini.d7aeeb41.mjs';
9
- import './shared/preset-mini.f73f9ed7.mjs';
6
+ import { t as theme } from './shared/preset-mini.ae98d318.mjs';
7
+ export { t as theme } from './shared/preset-mini.ae98d318.mjs';
8
+ import { v as variants } from './shared/preset-mini.9e26490c.mjs';
9
+ import './shared/preset-mini.154e3363.mjs';
10
10
 
11
11
  const preflights = [
12
12
  {
@@ -14,7 +14,8 @@ const preflights = [
14
14
  getCSS(ctx) {
15
15
  if (ctx.theme.preflightBase) {
16
16
  const css = entriesToCss(Object.entries(ctx.theme.preflightBase));
17
- return `*,::before,::after{${css}}::backdrop{${css}}`;
17
+ const roots = toArray(ctx.theme.preflightRoot ?? ["*,::before,::after", "::backdrop"]);
18
+ return roots.map((root) => `${root}{${css}}`).join("");
18
19
  }
19
20
  }
20
21
  }
package/dist/rules.cjs CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const decoration = require('./shared/preset-mini.b300afab.cjs');
6
- const _default = require('./shared/preset-mini.5d1fe287.cjs');
7
- require('./shared/preset-mini.7346cef1.cjs');
5
+ const decoration = require('./shared/preset-mini.7f221566.cjs');
6
+ const _default = require('./shared/preset-mini.f5f22d9a.cjs');
7
+ require('./shared/preset-mini.0109bbf2.cjs');
8
8
  require('@unocss/core');
9
9
 
10
10
 
package/dist/rules.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Rule, CSSEntries } from '@unocss/core';
2
- import { T as Theme } from './types-c22910b5.js';
2
+ import { T as Theme } from './types-3dbe7f66.js';
3
3
 
4
4
  declare const verticalAligns: Rule[];
5
5
  declare const textAligns: Rule[];
package/dist/rules.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { F as alignments, C as appearance, s as appearances, R as borderStyles, b as borders, o as boxShadows, P as boxShadowsBase, K as boxSizing, z as breaks, c as contentVisibility, a as contents, q as cursors, d as displays, I as floats, n as fontSmoothings, m as fontStyles, f as fonts, S as handlerBorderStyle, H as insets, E as justifies, D as orders, B as outline, A as overflows, G as placements, u as pointerEvents, p as positions, v as resizes, Q as ringBase, r as rings, t as tabSizes, l as textAligns, h as textDecorations, e as textIndents, g as textOverflows, j as textShadows, i as textStrokes, k as textTransforms, O as transformBase, M as transforms, L as transitions, x as userSelects, T as varEmpty, w as verticalAligns, y as whitespaces, N as willChange, J as zIndexes } from './shared/preset-mini.3602602e.mjs';
2
- export { c as aspectRatio, b as bgColors, h as cssProperty, e as cssVariables, f as flex, g as gaps, a as grids, m as margins, o as opacity, p as paddings, q as questionMark, r as rules, s as sizes, d as svgUtilities, t as textColors } from './shared/preset-mini.dadc4e80.mjs';
3
- import './shared/preset-mini.42e5e280.mjs';
1
+ export { F as alignments, C as appearance, s as appearances, R as borderStyles, b as borders, o as boxShadows, P as boxShadowsBase, K as boxSizing, z as breaks, c as contentVisibility, a as contents, q as cursors, d as displays, I as floats, n as fontSmoothings, m as fontStyles, f as fonts, S as handlerBorderStyle, H as insets, E as justifies, D as orders, B as outline, A as overflows, G as placements, u as pointerEvents, p as positions, v as resizes, Q as ringBase, r as rings, t as tabSizes, l as textAligns, h as textDecorations, e as textIndents, g as textOverflows, j as textShadows, i as textStrokes, k as textTransforms, O as transformBase, M as transforms, L as transitions, x as userSelects, T as varEmpty, w as verticalAligns, y as whitespaces, N as willChange, J as zIndexes } from './shared/preset-mini.739fdcc7.mjs';
2
+ export { c as aspectRatio, b as bgColors, h as cssProperty, e as cssVariables, f as flex, g as gaps, a as grids, m as margins, o as opacity, p as paddings, q as questionMark, r as rules, s as sizes, d as svgUtilities, t as textColors } from './shared/preset-mini.13105b6e.mjs';
3
+ import './shared/preset-mini.9c5f881e.mjs';
4
4
  import '@unocss/core';
@@ -217,15 +217,19 @@ function fraction(str) {
217
217
  if (!Number.isNaN(num))
218
218
  return `${round(num * 100)}%`;
219
219
  }
220
- const bracketTypeRe = /^\[(color|length|position):/i;
221
- function bracketWithType(str, type) {
220
+ const bracketTypeRe = /^\[(color|length|position|quoted|string):/i;
221
+ function bracketWithType(str, requiredType) {
222
222
  if (str && str.startsWith("[") && str.endsWith("]")) {
223
223
  let base;
224
+ let hintedType;
224
225
  const match = str.match(bracketTypeRe);
225
- if (!match)
226
+ if (!match) {
226
227
  base = str.slice(1, -1);
227
- else if (type && match[1] === type)
228
+ } else {
229
+ if (!requiredType)
230
+ hintedType = match[1];
228
231
  base = str.slice(match[0].length, -1);
232
+ }
229
233
  if (!base)
230
234
  return;
231
235
  let curly = 0;
@@ -240,7 +244,13 @@ function bracketWithType(str, type) {
240
244
  }
241
245
  if (curly)
242
246
  return;
243
- return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (v) => {
247
+ switch (hintedType) {
248
+ case "string":
249
+ return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_");
250
+ case "quoted":
251
+ return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(["\\])/g, "\\$1").replace(/^(.+)$/, '"$1"');
252
+ }
253
+ return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (v) => {
244
254
  return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
245
255
  });
246
256
  }
@@ -454,29 +464,67 @@ function resolveVerticalBreakpoints({ theme, generator }) {
454
464
  function makeGlobalStaticRules(prefix, property) {
455
465
  return globalKeywords.map((keyword) => [`${prefix}-${keyword}`, { [property ?? prefix]: keyword }]);
456
466
  }
457
- function getComponent(str, open, close, separator) {
467
+ function getBracket(str, open, close) {
458
468
  if (str === "")
459
469
  return;
460
470
  const l = str.length;
461
471
  let parenthesis = 0;
472
+ let opened = false;
473
+ let openAt = 0;
462
474
  for (let i = 0; i < l; i++) {
463
475
  switch (str[i]) {
464
476
  case open:
477
+ if (!opened) {
478
+ opened = true;
479
+ openAt = i;
480
+ }
465
481
  parenthesis++;
466
482
  break;
467
483
  case close:
468
- if (--parenthesis < 0)
484
+ --parenthesis;
485
+ if (parenthesis < 0)
469
486
  return;
470
- break;
471
- case separator:
472
487
  if (parenthesis === 0) {
473
- if (i === 0 || i === l - 1)
474
- return;
475
488
  return [
476
- str.slice(0, i),
477
- str.slice(i + 1)
489
+ str.slice(openAt, i + 1),
490
+ str.slice(i + 1),
491
+ str.slice(0, openAt)
478
492
  ];
479
493
  }
494
+ break;
495
+ }
496
+ }
497
+ }
498
+ function getComponent(str, open, close, separators) {
499
+ if (str === "")
500
+ return;
501
+ if (core.isString(separators))
502
+ separators = [separators];
503
+ if (separators.length === 0)
504
+ return;
505
+ const l = str.length;
506
+ let parenthesis = 0;
507
+ for (let i = 0; i < l; i++) {
508
+ switch (str[i]) {
509
+ case open:
510
+ parenthesis++;
511
+ break;
512
+ case close:
513
+ if (--parenthesis < 0)
514
+ return;
515
+ break;
516
+ default:
517
+ for (const separator of separators) {
518
+ const separatorLength = separator.length;
519
+ if (separatorLength && separator === str.slice(i, i + separatorLength) && parenthesis === 0) {
520
+ if (i === 0 || i === l - separatorLength)
521
+ return;
522
+ return [
523
+ str.slice(0, i),
524
+ str.slice(i + separatorLength)
525
+ ];
526
+ }
527
+ }
480
528
  }
481
529
  }
482
530
  return [
@@ -484,16 +532,14 @@ function getComponent(str, open, close, separator) {
484
532
  ""
485
533
  ];
486
534
  }
487
- function getComponents(str, separator, limit) {
488
- if (separator.length !== 1)
489
- return;
535
+ function getComponents(str, separators, limit) {
490
536
  limit = limit ?? 10;
491
537
  const components = [];
492
538
  let i = 0;
493
539
  while (str !== "") {
494
540
  if (++i > limit)
495
541
  return;
496
- const componentPair = getComponent(str, "(", ")", separator);
542
+ const componentPair = getComponent(str, "(", ")", separators);
497
543
  if (!componentPair)
498
544
  return;
499
545
  const [component, rest] = componentPair;
@@ -691,6 +737,7 @@ exports.colorableShadows = colorableShadows;
691
737
  exports.cornerMap = cornerMap;
692
738
  exports.directionMap = directionMap;
693
739
  exports.directionSize = directionSize;
740
+ exports.getBracket = getBracket;
694
741
  exports.getComponent = getComponent;
695
742
  exports.getComponents = getComponents;
696
743
  exports.globalKeywords = globalKeywords;
@@ -1,5 +1,5 @@
1
- import { d as displays, b as borders, c as contentVisibility, a as contents, f as fonts, t as tabSizes, e as textIndents, g as textOverflows, h as textDecorations, i as textStrokes, j as textShadows, k as textTransforms, l as textAligns, m as fontStyles, n as fontSmoothings, o as boxShadows, r as rings, p as positions, q as cursors, s as appearances, u as pointerEvents, v as resizes, w as verticalAligns, x as userSelects, y as whitespaces, z as breaks, A as overflows, B as outline, C as appearance, D as orders, E as justifies, F as alignments, G as placements, H as insets, I as floats, J as zIndexes, K as boxSizing, L as transitions, M as transforms, N as willChange } from './preset-mini.3602602e.mjs';
2
- import { h as handler, c as colorResolver, n as numberWithUnitRE, r as resolveVerticalBreakpoints, l as resolveBreakpoints, o as directionSize } from './preset-mini.42e5e280.mjs';
1
+ import { d as displays, b as borders, c as contentVisibility, a as contents, f as fonts, t as tabSizes, e as textIndents, g as textOverflows, h as textDecorations, i as textStrokes, j as textShadows, k as textTransforms, l as textAligns, m as fontStyles, n as fontSmoothings, o as boxShadows, r as rings, p as positions, q as cursors, s as appearances, u as pointerEvents, v as resizes, w as verticalAligns, x as userSelects, y as whitespaces, z as breaks, A as overflows, B as outline, C as appearance, D as orders, E as justifies, F as alignments, G as placements, H as insets, I as floats, J as zIndexes, K as boxSizing, L as transitions, M as transforms, N as willChange } from './preset-mini.739fdcc7.mjs';
2
+ import { h as handler, c as colorResolver, n as numberWithUnitRE, r as resolveVerticalBreakpoints, l as resolveBreakpoints, o as directionSize } from './preset-mini.9c5f881e.mjs';
3
3
  import '@unocss/core';
4
4
 
5
5
  const opacity = [
@@ -0,0 +1,67 @@
1
+ import { escapeRegExp } from '@unocss/core';
2
+ import { q as getBracket } from './preset-mini.9c5f881e.mjs';
3
+
4
+ const variantMatcher = (name, handler) => {
5
+ const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
6
+ return {
7
+ name,
8
+ match(input) {
9
+ const match = input.match(re);
10
+ if (match) {
11
+ return {
12
+ matcher: input.slice(match[0].length),
13
+ handle: (input2, next) => next({
14
+ ...input2,
15
+ ...handler(input2)
16
+ })
17
+ };
18
+ }
19
+ },
20
+ autocomplete: `${name}:`
21
+ };
22
+ };
23
+ const variantParentMatcher = (name, parent) => {
24
+ const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
25
+ return {
26
+ name,
27
+ match(input) {
28
+ const match = input.match(re);
29
+ if (match) {
30
+ return {
31
+ matcher: input.slice(match[0].length),
32
+ handle: (input2, next) => next({
33
+ ...input2,
34
+ parent: `${input2.parent ? `${input2.parent} $$ ` : ""}${parent}`
35
+ })
36
+ };
37
+ }
38
+ },
39
+ autocomplete: `${name}:`
40
+ };
41
+ };
42
+ const variantGetBracket = (name, matcher, separators) => {
43
+ if (matcher.startsWith(`${name}-[`)) {
44
+ const [match, rest] = getBracket(matcher.slice(name.length + 1), "[", "]") ?? [];
45
+ if (match && rest) {
46
+ for (const separator of separators) {
47
+ if (rest.startsWith(separator))
48
+ return [match, rest.slice(separator.length), separator];
49
+ }
50
+ return [match, rest, ""];
51
+ }
52
+ }
53
+ };
54
+ const variantGetParameter = (name, matcher, separators) => {
55
+ if (matcher.startsWith(`${name}-`)) {
56
+ const body = variantGetBracket(name, matcher, separators);
57
+ if (body)
58
+ return body;
59
+ for (const separator of separators) {
60
+ const pos = matcher.indexOf(separator, name.length + 1);
61
+ if (pos !== -1)
62
+ return [matcher.slice(name.length + 1, pos), matcher.slice(pos + separator.length)];
63
+ }
64
+ }
65
+ };
66
+
67
+ export { variantParentMatcher as a, variantGetParameter as b, variantMatcher as c, variantGetBracket as v };
@@ -1,4 +1,4 @@
1
- import { g as globalKeywords, h as handler, c as colorResolver, d as directionMap, a as hasParseableColor, b as cornerMap, p as parseColor, e as colorToString, f as colorOpacityToString, m as makeGlobalStaticRules, i as colorableShadows, j as insetMap, k as positionMap, x as xyzMap } from './preset-mini.42e5e280.mjs';
1
+ import { g as globalKeywords, h as handler, c as colorResolver, d as directionMap, a as hasParseableColor, b as cornerMap, p as parseColor, e as colorToString, f as colorOpacityToString, m as makeGlobalStaticRules, i as colorableShadows, j as insetMap, k as positionMap, x as xyzMap } from './preset-mini.9c5f881e.mjs';
2
2
  import { toArray } from '@unocss/core';
3
3
 
4
4
  const verticalAlignAlias = {
@@ -485,8 +485,7 @@ const contentVisibility = [
485
485
  ...makeGlobalStaticRules("content-visibility")
486
486
  ];
487
487
  const contents = [
488
- [/^content-\[(.+)\]$/, ([, v]) => ({ content: `"${v}"` })],
489
- [/^content-(\$.+)]$/, ([, v]) => ({ content: handler.cssvar(v) })],
488
+ [/^content-(.+)$/, ([, v]) => ({ content: handler.bracket.cssvar(v) })],
490
489
  ["content-empty", { content: '""' }],
491
490
  ["content-none", { content: '""' }]
492
491
  ];
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const colors = require('./preset-mini.30606736.cjs');
4
- const decoration = require('./preset-mini.b300afab.cjs');
5
- require('./preset-mini.7346cef1.cjs');
4
+ const decoration = require('./preset-mini.7f221566.cjs');
5
+ require('./preset-mini.0109bbf2.cjs');
6
6
  require('@unocss/core');
7
7
 
8
8
  const fontFamily = {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const colors = require('./preset-mini.7346cef1.cjs');
3
+ const colors = require('./preset-mini.0109bbf2.cjs');
4
4
  const core = require('@unocss/core');
5
5
 
6
6
  const verticalAlignAlias = {
@@ -487,8 +487,7 @@ const contentVisibility = [
487
487
  ...colors.makeGlobalStaticRules("content-visibility")
488
488
  ];
489
489
  const contents = [
490
- [/^content-\[(.+)\]$/, ([, v]) => ({ content: `"${v}"` })],
491
- [/^content-(\$.+)]$/, ([, v]) => ({ content: colors.handler.cssvar(v) })],
490
+ [/^content-(.+)$/, ([, v]) => ({ content: colors.handler.bracket.cssvar(v) })],
492
491
  ["content-empty", { content: '""' }],
493
492
  ["content-none", { content: '""' }]
494
493
  ];
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ const core = require('@unocss/core');
4
+ const colors = require('./preset-mini.0109bbf2.cjs');
5
+
6
+ const variantMatcher = (name, handler) => {
7
+ const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
8
+ return {
9
+ name,
10
+ match(input) {
11
+ const match = input.match(re);
12
+ if (match) {
13
+ return {
14
+ matcher: input.slice(match[0].length),
15
+ handle: (input2, next) => next({
16
+ ...input2,
17
+ ...handler(input2)
18
+ })
19
+ };
20
+ }
21
+ },
22
+ autocomplete: `${name}:`
23
+ };
24
+ };
25
+ const variantParentMatcher = (name, parent) => {
26
+ const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
27
+ return {
28
+ name,
29
+ match(input) {
30
+ const match = input.match(re);
31
+ if (match) {
32
+ return {
33
+ matcher: input.slice(match[0].length),
34
+ handle: (input2, next) => next({
35
+ ...input2,
36
+ parent: `${input2.parent ? `${input2.parent} $$ ` : ""}${parent}`
37
+ })
38
+ };
39
+ }
40
+ },
41
+ autocomplete: `${name}:`
42
+ };
43
+ };
44
+ const variantGetBracket = (name, matcher, separators) => {
45
+ if (matcher.startsWith(`${name}-[`)) {
46
+ const [match, rest] = colors.getBracket(matcher.slice(name.length + 1), "[", "]") ?? [];
47
+ if (match && rest) {
48
+ for (const separator of separators) {
49
+ if (rest.startsWith(separator))
50
+ return [match, rest.slice(separator.length), separator];
51
+ }
52
+ return [match, rest, ""];
53
+ }
54
+ }
55
+ };
56
+ const variantGetParameter = (name, matcher, separators) => {
57
+ if (matcher.startsWith(`${name}-`)) {
58
+ const body = variantGetBracket(name, matcher, separators);
59
+ if (body)
60
+ return body;
61
+ for (const separator of separators) {
62
+ const pos = matcher.indexOf(separator, name.length + 1);
63
+ if (pos !== -1)
64
+ return [matcher.slice(name.length + 1, pos), matcher.slice(pos + separator.length)];
65
+ }
66
+ }
67
+ };
68
+
69
+ exports.variantGetBracket = variantGetBracket;
70
+ exports.variantGetParameter = variantGetParameter;
71
+ exports.variantMatcher = variantMatcher;
72
+ exports.variantParentMatcher = variantParentMatcher;
@@ -1,4 +1,4 @@
1
- import { escapeSelector, createValueHandler, toArray, escapeRegExp } from '@unocss/core';
1
+ import { escapeSelector, createValueHandler, toArray, isString, escapeRegExp } from '@unocss/core';
2
2
 
3
3
  const directionMap = {
4
4
  "l": ["-left"],
@@ -215,15 +215,19 @@ function fraction(str) {
215
215
  if (!Number.isNaN(num))
216
216
  return `${round(num * 100)}%`;
217
217
  }
218
- const bracketTypeRe = /^\[(color|length|position):/i;
219
- function bracketWithType(str, type) {
218
+ const bracketTypeRe = /^\[(color|length|position|quoted|string):/i;
219
+ function bracketWithType(str, requiredType) {
220
220
  if (str && str.startsWith("[") && str.endsWith("]")) {
221
221
  let base;
222
+ let hintedType;
222
223
  const match = str.match(bracketTypeRe);
223
- if (!match)
224
+ if (!match) {
224
225
  base = str.slice(1, -1);
225
- else if (type && match[1] === type)
226
+ } else {
227
+ if (!requiredType)
228
+ hintedType = match[1];
226
229
  base = str.slice(match[0].length, -1);
230
+ }
227
231
  if (!base)
228
232
  return;
229
233
  let curly = 0;
@@ -238,7 +242,13 @@ function bracketWithType(str, type) {
238
242
  }
239
243
  if (curly)
240
244
  return;
241
- return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/([^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (v) => {
245
+ switch (hintedType) {
246
+ case "string":
247
+ return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_");
248
+ case "quoted":
249
+ return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(["\\])/g, "\\$1").replace(/^(.+)$/, '"$1"');
250
+ }
251
+ return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (v) => {
242
252
  return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
243
253
  });
244
254
  }
@@ -452,29 +462,67 @@ function resolveVerticalBreakpoints({ theme, generator }) {
452
462
  function makeGlobalStaticRules(prefix, property) {
453
463
  return globalKeywords.map((keyword) => [`${prefix}-${keyword}`, { [property ?? prefix]: keyword }]);
454
464
  }
455
- function getComponent(str, open, close, separator) {
465
+ function getBracket(str, open, close) {
456
466
  if (str === "")
457
467
  return;
458
468
  const l = str.length;
459
469
  let parenthesis = 0;
470
+ let opened = false;
471
+ let openAt = 0;
460
472
  for (let i = 0; i < l; i++) {
461
473
  switch (str[i]) {
462
474
  case open:
475
+ if (!opened) {
476
+ opened = true;
477
+ openAt = i;
478
+ }
463
479
  parenthesis++;
464
480
  break;
465
481
  case close:
466
- if (--parenthesis < 0)
482
+ --parenthesis;
483
+ if (parenthesis < 0)
467
484
  return;
468
- break;
469
- case separator:
470
485
  if (parenthesis === 0) {
471
- if (i === 0 || i === l - 1)
472
- return;
473
486
  return [
474
- str.slice(0, i),
475
- str.slice(i + 1)
487
+ str.slice(openAt, i + 1),
488
+ str.slice(i + 1),
489
+ str.slice(0, openAt)
476
490
  ];
477
491
  }
492
+ break;
493
+ }
494
+ }
495
+ }
496
+ function getComponent(str, open, close, separators) {
497
+ if (str === "")
498
+ return;
499
+ if (isString(separators))
500
+ separators = [separators];
501
+ if (separators.length === 0)
502
+ return;
503
+ const l = str.length;
504
+ let parenthesis = 0;
505
+ for (let i = 0; i < l; i++) {
506
+ switch (str[i]) {
507
+ case open:
508
+ parenthesis++;
509
+ break;
510
+ case close:
511
+ if (--parenthesis < 0)
512
+ return;
513
+ break;
514
+ default:
515
+ for (const separator of separators) {
516
+ const separatorLength = separator.length;
517
+ if (separatorLength && separator === str.slice(i, i + separatorLength) && parenthesis === 0) {
518
+ if (i === 0 || i === l - separatorLength)
519
+ return;
520
+ return [
521
+ str.slice(0, i),
522
+ str.slice(i + separatorLength)
523
+ ];
524
+ }
525
+ }
478
526
  }
479
527
  }
480
528
  return [
@@ -482,16 +530,14 @@ function getComponent(str, open, close, separator) {
482
530
  ""
483
531
  ];
484
532
  }
485
- function getComponents(str, separator, limit) {
486
- if (separator.length !== 1)
487
- return;
533
+ function getComponents(str, separators, limit) {
488
534
  limit = limit ?? 10;
489
535
  const components = [];
490
536
  let i = 0;
491
537
  while (str !== "") {
492
538
  if (++i > limit)
493
539
  return;
494
- const componentPair = getComponent(str, "(", ")", separator);
540
+ const componentPair = getComponent(str, "(", ")", separators);
495
541
  if (!componentPair)
496
542
  return;
497
543
  const [component, rest] = componentPair;
@@ -681,4 +727,4 @@ function parseCssSpaceColorValues(componentString) {
681
727
  };
682
728
  }
683
729
 
684
- export { CONTROL_MINI_NO_NEGATIVE as C, hasParseableColor as a, cornerMap as b, colorResolver as c, directionMap as d, colorToString as e, colorOpacityToString as f, globalKeywords as g, handler as h, colorableShadows as i, insetMap as j, positionMap as k, resolveBreakpoints as l, makeGlobalStaticRules as m, numberWithUnitRE as n, directionSize as o, parseColor$1 as p, getComponent as q, resolveVerticalBreakpoints as r, hex2rgba as s, parseCssColor as t, h as u, valueHandlers as v, getComponents as w, xyzMap as x };
730
+ export { CONTROL_MINI_NO_NEGATIVE as C, hasParseableColor as a, cornerMap as b, colorResolver as c, directionMap as d, colorToString as e, colorOpacityToString as f, globalKeywords as g, handler as h, colorableShadows as i, insetMap as j, positionMap as k, resolveBreakpoints as l, makeGlobalStaticRules as m, numberWithUnitRE as n, directionSize as o, parseColor$1 as p, getBracket as q, resolveVerticalBreakpoints as r, getComponent as s, hex2rgba as t, parseCssColor as u, h as v, valueHandlers as w, xyzMap as x, getComponents as y };