@unocss/preset-mini 0.45.30 → 0.46.1

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.2d0396b3.cjs → preset-mini.0109bbf2.cjs} +53 -16
  11. package/dist/shared/{preset-mini.389e54ff.mjs → preset-mini.13105b6e.mjs} +2 -2
  12. package/dist/shared/preset-mini.154e3363.mjs +67 -0
  13. package/dist/shared/{preset-mini.7c9c225a.mjs → preset-mini.739fdcc7.mjs} +2 -3
  14. package/dist/shared/{preset-mini.2ee569b4.cjs → preset-mini.7c4b1c47.cjs} +2 -2
  15. package/dist/shared/{preset-mini.740f2131.cjs → preset-mini.7f221566.cjs} +2 -3
  16. package/dist/shared/preset-mini.968d02ba.cjs +72 -0
  17. package/dist/shared/{preset-mini.7d4b2219.mjs → preset-mini.9c5f881e.mjs} +54 -18
  18. package/dist/shared/{preset-mini.3a35507d.mjs → preset-mini.9e26490c.mjs} +167 -101
  19. package/dist/shared/{preset-mini.b0834387.mjs → preset-mini.ae98d318.mjs} +2 -2
  20. package/dist/shared/{preset-mini.5e4ef283.cjs → preset-mini.f5f22d9a.cjs} +2 -2
  21. package/dist/shared/{preset-mini.5c501ea4.cjs → preset-mini.fc97229a.cjs} +166 -100
  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.740f2131.cjs');
7
- const colors$1 = require('./shared/preset-mini.2d0396b3.cjs');
8
- const _default$1 = require('./shared/preset-mini.5e4ef283.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.2ee569b4.cjs');
11
- const _default$2 = require('./shared/preset-mini.5c501ea4.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.7c9c225a.mjs';
3
- export { p as parseColor } from './shared/preset-mini.7d4b2219.mjs';
4
- import { r as rules } from './shared/preset-mini.389e54ff.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.b0834387.mjs';
7
- export { t as theme } from './shared/preset-mini.b0834387.mjs';
8
- import { v as variants } from './shared/preset-mini.3a35507d.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.740f2131.cjs');
6
- const _default = require('./shared/preset-mini.5e4ef283.cjs');
7
- require('./shared/preset-mini.2d0396b3.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.7c9c225a.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.389e54ff.mjs';
3
- import './shared/preset-mini.7d4b2219.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,7 +217,7 @@ function fraction(str) {
217
217
  if (!Number.isNaN(num))
218
218
  return `${round(num * 100)}%`;
219
219
  }
220
- const bracketTypeRe = /^\[(color|length|position|raw|string):/i;
220
+ const bracketTypeRe = /^\[(color|length|position|quoted|string):/i;
221
221
  function bracketWithType(str, requiredType) {
222
222
  if (str && str.startsWith("[") && str.endsWith("]")) {
223
223
  let base;
@@ -245,10 +245,10 @@ function bracketWithType(str, requiredType) {
245
245
  if (curly)
246
246
  return;
247
247
  switch (hintedType) {
248
- case "raw":
249
- return base;
250
248
  case "string":
251
- return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(['\\])/g, "\\$1").replace(/^(.+)$/, "'$1'");
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
252
  }
253
253
  return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (v) => {
254
254
  return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
@@ -464,29 +464,67 @@ function resolveVerticalBreakpoints({ theme, generator }) {
464
464
  function makeGlobalStaticRules(prefix, property) {
465
465
  return globalKeywords.map((keyword) => [`${prefix}-${keyword}`, { [property ?? prefix]: keyword }]);
466
466
  }
467
- function getComponent(str, open, close, separator) {
467
+ function getBracket(str, open, close) {
468
468
  if (str === "")
469
469
  return;
470
470
  const l = str.length;
471
471
  let parenthesis = 0;
472
+ let opened = false;
473
+ let openAt = 0;
472
474
  for (let i = 0; i < l; i++) {
473
475
  switch (str[i]) {
474
476
  case open:
477
+ if (!opened) {
478
+ opened = true;
479
+ openAt = i;
480
+ }
475
481
  parenthesis++;
476
482
  break;
477
483
  case close:
478
- if (--parenthesis < 0)
484
+ --parenthesis;
485
+ if (parenthesis < 0)
479
486
  return;
480
- break;
481
- case separator:
482
487
  if (parenthesis === 0) {
483
- if (i === 0 || i === l - 1)
484
- return;
485
488
  return [
486
- str.slice(0, i),
487
- str.slice(i + 1)
489
+ str.slice(openAt, i + 1),
490
+ str.slice(i + 1),
491
+ str.slice(0, openAt)
488
492
  ];
489
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
+ }
490
528
  }
491
529
  }
492
530
  return [
@@ -494,16 +532,14 @@ function getComponent(str, open, close, separator) {
494
532
  ""
495
533
  ];
496
534
  }
497
- function getComponents(str, separator, limit) {
498
- if (separator.length !== 1)
499
- return;
535
+ function getComponents(str, separators, limit) {
500
536
  limit = limit ?? 10;
501
537
  const components = [];
502
538
  let i = 0;
503
539
  while (str !== "") {
504
540
  if (++i > limit)
505
541
  return;
506
- const componentPair = getComponent(str, "(", ")", separator);
542
+ const componentPair = getComponent(str, "(", ")", separators);
507
543
  if (!componentPair)
508
544
  return;
509
545
  const [component, rest] = componentPair;
@@ -701,6 +737,7 @@ exports.colorableShadows = colorableShadows;
701
737
  exports.cornerMap = cornerMap;
702
738
  exports.directionMap = directionMap;
703
739
  exports.directionSize = directionSize;
740
+ exports.getBracket = getBracket;
704
741
  exports.getComponent = getComponent;
705
742
  exports.getComponents = getComponents;
706
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.7c9c225a.mjs';
2
- import { h as handler, c as colorResolver, n as numberWithUnitRE, r as resolveVerticalBreakpoints, l as resolveBreakpoints, o as directionSize } from './preset-mini.7d4b2219.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.7d4b2219.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.740f2131.cjs');
5
- require('./preset-mini.2d0396b3.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.2d0396b3.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,7 +215,7 @@ function fraction(str) {
215
215
  if (!Number.isNaN(num))
216
216
  return `${round(num * 100)}%`;
217
217
  }
218
- const bracketTypeRe = /^\[(color|length|position|raw|string):/i;
218
+ const bracketTypeRe = /^\[(color|length|position|quoted|string):/i;
219
219
  function bracketWithType(str, requiredType) {
220
220
  if (str && str.startsWith("[") && str.endsWith("]")) {
221
221
  let base;
@@ -243,10 +243,10 @@ function bracketWithType(str, requiredType) {
243
243
  if (curly)
244
244
  return;
245
245
  switch (hintedType) {
246
- case "raw":
247
- return base;
248
246
  case "string":
249
- return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(['\\])/g, "\\$1").replace(/^(.+)$/, "'$1'");
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
250
  }
251
251
  return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (v) => {
252
252
  return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
@@ -462,29 +462,67 @@ function resolveVerticalBreakpoints({ theme, generator }) {
462
462
  function makeGlobalStaticRules(prefix, property) {
463
463
  return globalKeywords.map((keyword) => [`${prefix}-${keyword}`, { [property ?? prefix]: keyword }]);
464
464
  }
465
- function getComponent(str, open, close, separator) {
465
+ function getBracket(str, open, close) {
466
466
  if (str === "")
467
467
  return;
468
468
  const l = str.length;
469
469
  let parenthesis = 0;
470
+ let opened = false;
471
+ let openAt = 0;
470
472
  for (let i = 0; i < l; i++) {
471
473
  switch (str[i]) {
472
474
  case open:
475
+ if (!opened) {
476
+ opened = true;
477
+ openAt = i;
478
+ }
473
479
  parenthesis++;
474
480
  break;
475
481
  case close:
476
- if (--parenthesis < 0)
482
+ --parenthesis;
483
+ if (parenthesis < 0)
477
484
  return;
478
- break;
479
- case separator:
480
485
  if (parenthesis === 0) {
481
- if (i === 0 || i === l - 1)
482
- return;
483
486
  return [
484
- str.slice(0, i),
485
- str.slice(i + 1)
487
+ str.slice(openAt, i + 1),
488
+ str.slice(i + 1),
489
+ str.slice(0, openAt)
486
490
  ];
487
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
+ }
488
526
  }
489
527
  }
490
528
  return [
@@ -492,16 +530,14 @@ function getComponent(str, open, close, separator) {
492
530
  ""
493
531
  ];
494
532
  }
495
- function getComponents(str, separator, limit) {
496
- if (separator.length !== 1)
497
- return;
533
+ function getComponents(str, separators, limit) {
498
534
  limit = limit ?? 10;
499
535
  const components = [];
500
536
  let i = 0;
501
537
  while (str !== "") {
502
538
  if (++i > limit)
503
539
  return;
504
- const componentPair = getComponent(str, "(", ")", separator);
540
+ const componentPair = getComponent(str, "(", ")", separators);
505
541
  if (!componentPair)
506
542
  return;
507
543
  const [component, rest] = componentPair;
@@ -691,4 +727,4 @@ function parseCssSpaceColorValues(componentString) {
691
727
  };
692
728
  }
693
729
 
694
- 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 };