@unocss/preset-mini 0.45.30 → 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.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,6 +1,6 @@
1
- import { l as resolveBreakpoints, q as getComponent, h as handler, C as CONTROL_MINI_NO_NEGATIVE } from './preset-mini.7d4b2219.mjs';
2
- import { escapeRegExp } from '@unocss/core';
3
- import { v as variantParentMatcher, a as variantMatcher } from './preset-mini.f73f9ed7.mjs';
1
+ import { l as resolveBreakpoints, h as handler, q as getBracket, C as CONTROL_MINI_NO_NEGATIVE, s as getComponent } from './preset-mini.9c5f881e.mjs';
2
+ import { escapeRegExp, warnOnce, escapeSelector } from '@unocss/core';
3
+ import { v as variantGetBracket, a as variantParentMatcher, b as variantGetParameter, c as variantMatcher } from './preset-mini.154e3363.mjs';
4
4
 
5
5
  const regexCache = {};
6
6
  const calcMaxWidthBySize = (size) => {
@@ -62,48 +62,59 @@ const variantBreakpoints = {
62
62
  autocomplete: "(at-|lt-|)$breakpoints:"
63
63
  };
64
64
 
65
- const scopeMatcher = (strict, name, template) => {
66
- const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
67
- return {
68
- name: `combinator:${name}`,
69
- match: (matcher) => {
70
- const match = matcher.match(re);
71
- if (match) {
72
- return {
73
- matcher: matcher.slice(match[0].length),
74
- selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
75
- };
65
+ const scopeMatcher = (name, combinator) => ({
66
+ name: `combinator:${name}`,
67
+ match(matcher) {
68
+ if (!matcher.startsWith(name))
69
+ return;
70
+ let body = variantGetBracket(name, matcher, [":", "-"]);
71
+ if (!body) {
72
+ for (const separator of [":", "-"]) {
73
+ if (matcher.startsWith(`${name}${separator}`)) {
74
+ body = ["", matcher.slice(name.length + separator.length)];
75
+ break;
76
+ }
76
77
  }
77
- },
78
- multiPass: true
79
- };
80
- };
78
+ if (!body)
79
+ return;
80
+ }
81
+ let bracketValue = handler.bracket(body[0]) ?? "";
82
+ if (bracketValue === "")
83
+ bracketValue = "*";
84
+ return {
85
+ matcher: body[1],
86
+ selector: (s) => `${s}${combinator}${bracketValue}`
87
+ };
88
+ },
89
+ multiPass: true
90
+ });
81
91
  const variantCombinators = [
82
- scopeMatcher(false, "all", "&&-s &&-c"),
83
- scopeMatcher(false, "children", "&&-s>&&-c"),
84
- scopeMatcher(false, "next", "&&-s+&&-c"),
85
- scopeMatcher(false, "sibling", "&&-s+&&-c"),
86
- scopeMatcher(false, "siblings", "&&-s~&&-c"),
87
- scopeMatcher(true, "group", "&&-c &&-s"),
88
- scopeMatcher(true, "parent", "&&-c>&&-s"),
89
- scopeMatcher(true, "previous", "&&-c+&&-s"),
90
- scopeMatcher(true, "peer", "&&-c~&&-s")
92
+ scopeMatcher("all", " "),
93
+ scopeMatcher("children", ">"),
94
+ scopeMatcher("next", "+"),
95
+ scopeMatcher("sibling", "+"),
96
+ scopeMatcher("siblings", "~")
91
97
  ];
92
98
 
93
99
  const variantPrint = variantParentMatcher("print", "@media print");
94
100
  const variantCustomMedia = {
95
101
  name: "media",
96
102
  match(matcher, { theme }) {
97
- const match = matcher.match(/^media-([_\d\w]+)[:-]/);
98
- if (match) {
99
- const media = theme.media?.[match[1]] ?? `(--${match[1]})`;
100
- return {
101
- matcher: matcher.slice(match[0].length),
102
- handle: (input, next) => next({
103
- ...input,
104
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@media ${media}`
105
- })
106
- };
103
+ const variant = variantGetParameter("media", matcher, [":", "-"]);
104
+ if (variant) {
105
+ const [match, rest] = variant;
106
+ let media = handler.bracket(match) ?? "";
107
+ if (media === "")
108
+ media = theme.media?.[match] ?? "";
109
+ if (media) {
110
+ return {
111
+ matcher: rest,
112
+ handle: (input, next) => next({
113
+ ...input,
114
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media ${media}`
115
+ })
116
+ };
117
+ }
107
118
  }
108
119
  },
109
120
  multiPass: true
@@ -112,17 +123,12 @@ const variantCustomMedia = {
112
123
  const variantSupports = {
113
124
  name: "supports",
114
125
  match(matcher, { theme }) {
115
- if (matcher.startsWith("supports-")) {
116
- const matcherValue = matcher.substring(9);
117
- const [match, rest] = getComponent(matcherValue, "[", "]", ":") ?? [];
118
- if (!(match && rest && rest !== ""))
119
- return;
126
+ const variant = variantGetParameter("supports", matcher, [":", "-"]);
127
+ if (variant) {
128
+ const [match, rest] = variant;
120
129
  let supports = handler.bracket(match) ?? "";
121
- if (supports === "") {
122
- const themeValue = theme.supports?.[match];
123
- if (themeValue)
124
- supports = themeValue;
125
- }
130
+ if (supports === "")
131
+ supports = theme.supports?.[match] ?? "";
126
132
  if (supports) {
127
133
  return {
128
134
  matcher: rest,
@@ -159,51 +165,67 @@ const variantLanguageDirections = [
159
165
  const variantSelector = {
160
166
  name: "selector",
161
167
  match(matcher) {
162
- const match = matcher.match(/^selector-\[(.+?)\][:-]/);
163
- if (match) {
164
- return {
165
- matcher: matcher.slice(match[0].length),
166
- selector: () => match[1]
167
- };
168
+ const variant = variantGetBracket("selector", matcher, [":", "-"]);
169
+ if (variant) {
170
+ const [match, rest] = variant;
171
+ const selector = handler.bracket(match);
172
+ if (selector) {
173
+ return {
174
+ matcher: rest,
175
+ selector: () => selector
176
+ };
177
+ }
168
178
  }
169
179
  }
170
180
  };
171
181
  const variantCssLayer = {
172
182
  name: "layer",
173
183
  match(matcher) {
174
- const match = matcher.match(/^layer-([_\d\w]+)[:-]/);
175
- if (match) {
176
- return {
177
- matcher: matcher.slice(match[0].length),
178
- handle: (input, next) => next({
179
- ...input,
180
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@layer ${match[1]}`
181
- })
182
- };
184
+ const variant = variantGetParameter("layer", matcher, [":", "-"]);
185
+ if (variant) {
186
+ const [match, rest] = variant;
187
+ const layer = handler.bracket(match) ?? match;
188
+ if (layer) {
189
+ return {
190
+ matcher: rest,
191
+ handle: (input, next) => next({
192
+ ...input,
193
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@layer ${layer}`
194
+ })
195
+ };
196
+ }
183
197
  }
184
198
  }
185
199
  };
186
200
  const variantInternalLayer = {
187
201
  name: "uno-layer",
188
202
  match(matcher) {
189
- const match = matcher.match(/^uno-layer-([_\d\w]+)[:-]/);
190
- if (match) {
191
- return {
192
- matcher: matcher.slice(match[0].length),
193
- layer: match[1]
194
- };
203
+ const variant = variantGetParameter("uno-layer", matcher, [":", "-"]);
204
+ if (variant) {
205
+ const [match, rest] = variant;
206
+ const layer = handler.bracket(match) ?? match;
207
+ if (layer) {
208
+ return {
209
+ matcher: rest,
210
+ layer
211
+ };
212
+ }
195
213
  }
196
214
  }
197
215
  };
198
216
  const variantScope = {
199
217
  name: "scope",
200
218
  match(matcher) {
201
- const match = matcher.match(/^scope-([_\d\w]+)[:-]/);
202
- if (match) {
203
- return {
204
- matcher: matcher.slice(match[0].length),
205
- selector: (s) => `.${match[1]} $$ ${s}`
206
- };
219
+ const variant = variantGetBracket("scope", matcher, [":", "-"]);
220
+ if (variant) {
221
+ const [match, rest] = variant;
222
+ const scope = handler.bracket(match);
223
+ if (scope) {
224
+ return {
225
+ matcher: rest,
226
+ selector: (s) => `${scope} $$ ${s}`
227
+ };
228
+ }
207
229
  }
208
230
  }
209
231
  };
@@ -212,16 +234,26 @@ const variantVariables = {
212
234
  match(matcher) {
213
235
  if (!matcher.startsWith("["))
214
236
  return;
215
- const [match, rest] = getComponent(matcher, "[", "]", ":") ?? [];
216
- if (!(match && rest && rest !== ""))
237
+ const [match, rest] = getBracket(matcher, "[", "]") ?? [];
238
+ if (!(match && rest))
239
+ return;
240
+ let newMatcher;
241
+ for (const separator of [":", "-"]) {
242
+ if (rest.startsWith(separator)) {
243
+ newMatcher = rest.slice(separator.length);
244
+ break;
245
+ }
246
+ }
247
+ if (newMatcher == null)
217
248
  return;
218
249
  const variant = handler.bracket(match) ?? "";
219
- if (!(variant.startsWith("@") || variant.includes("&")))
250
+ const useParent = variant.startsWith("@");
251
+ if (!(useParent || variant.includes("&")))
220
252
  return;
221
253
  return {
222
- matcher: rest,
254
+ matcher: newMatcher,
223
255
  handle(input, next) {
224
- const updates = variant.startsWith("@") ? {
256
+ const updates = useParent ? {
225
257
  parent: `${input.parent ? `${input.parent} $$ ` : ""}${variant}`
226
258
  } : {
227
259
  selector: variant.replace(/&/g, input.selector)
@@ -370,26 +402,60 @@ const sortValue = (pseudo) => {
370
402
  return 1;
371
403
  };
372
404
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
373
- const rawRe = new RegExp(`^(${escapeRegExp(parent)}:)(\\S+)${escapeRegExp(combinator)}\\1`);
374
- const pseudoRE = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))[:-]`);
375
- const pseudoColonRE = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesColonStr}))[:]`);
405
+ const rawRE = new RegExp(`^(${escapeRegExp(parent)}:)(\\S+)${escapeRegExp(combinator)}\\1`);
406
+ const pseudoRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))(?:(/\\w+))?[:-]`);
407
+ const pseudoColonRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesColonStr}))(?:(/\\w+))?[:]`);
408
+ const matchBracket = (input) => {
409
+ const body = variantGetBracket(tag, input, []);
410
+ if (!body)
411
+ return;
412
+ const [match, rest] = body;
413
+ const bracketValue = handler.bracket(match);
414
+ if (bracketValue == null)
415
+ return;
416
+ const label = rest.split(/[:-]/, 1)?.[0] ?? "";
417
+ const prefix = `${parent}${escapeSelector(label)}`;
418
+ return [
419
+ label,
420
+ input.slice(input.length - (rest.length - label.length - 1)),
421
+ bracketValue.includes("&") ? bracketValue.replace(/&/g, prefix) : `${prefix}${bracketValue}`
422
+ ];
423
+ };
424
+ const matchPseudo = (input) => {
425
+ const match = input.match(pseudoRE) || input.match(pseudoColonRE);
426
+ if (!match)
427
+ return;
428
+ const [original, fn, pseudoKey] = match;
429
+ const label = match[3] ?? "";
430
+ let pseudo = PseudoClasses[pseudoKey] || PseudoClassesColon[pseudoKey] || `:${pseudoKey}`;
431
+ if (fn)
432
+ pseudo = `:${fn}(${pseudo})`;
433
+ return [
434
+ label,
435
+ input.slice(original.length),
436
+ `${parent}${escapeSelector(label)}${pseudo}`,
437
+ sortValue(pseudoKey)
438
+ ];
439
+ };
376
440
  return {
377
441
  name: `pseudo:${tag}`,
378
442
  match(input) {
379
- const match = input.match(pseudoRE) || input.match(pseudoColonRE);
380
- if (match) {
381
- let pseudo = PseudoClasses[match[3]] || PseudoClassesColon[match[3]] || `:${match[3]}`;
382
- if (match[2])
383
- pseudo = `:${match[2]}(${pseudo})`;
384
- return {
385
- matcher: input.slice(match[0].length),
386
- handle: (input2, next) => next({
387
- ...input2,
388
- prefix: `${parent}${pseudo}${combinator}${input2.prefix}`.replace(rawRe, "$1$2:"),
389
- sort: sortValue(match[3])
390
- })
391
- };
392
- }
443
+ if (!input.startsWith(tag))
444
+ return;
445
+ const result = matchBracket(input) || matchPseudo(input);
446
+ if (!result)
447
+ return;
448
+ const [label, matcher, prefix, sort] = result;
449
+ if (label !== "")
450
+ warnOnce("The labeled pseudo is experimental and may be changed in breaking ways at any time.");
451
+ return {
452
+ matcher,
453
+ handle: (input2, next) => next({
454
+ ...input2,
455
+ prefix: `${prefix}${combinator}${input2.prefix}`.replace(rawRE, "$1$2:")
456
+ }),
457
+ sort
458
+ };
393
459
  },
394
460
  multiPass: true
395
461
  };
@@ -400,7 +466,7 @@ const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})
400
466
  const PseudoClassesAndElementsColonRE = new RegExp(`^(${PseudoClassesAndElementsColonStr})[:]`);
401
467
  const variantPseudoClassesAndElements = {
402
468
  name: "pseudo",
403
- match: (input) => {
469
+ match(input) {
404
470
  const match = input.match(PseudoClassesAndElementsRE) || input.match(PseudoClassesAndElementsColonRE);
405
471
  if (match) {
406
472
  const pseudo = PseudoClasses[match[1]] || PseudoClassesColon[match[1]] || `:${match[1]}`;
@@ -427,7 +493,7 @@ const variantPseudoClassesAndElements = {
427
493
  const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
428
494
  const PseudoClassColonFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesColonStr})[:]`);
429
495
  const variantPseudoClassFunctions = {
430
- match: (input) => {
496
+ match(input) {
431
497
  const match = input.match(PseudoClassFunctionsRE) || input.match(PseudoClassColonFunctionsRE);
432
498
  if (match) {
433
499
  const fn = match[1];
@@ -452,7 +518,7 @@ const variantTaggedPseudoClasses = (options = {}) => {
452
518
  };
453
519
  const PartClassesRE = /(part-\[(.+)]:)(.+)/;
454
520
  const partClasses = {
455
- match: (input) => {
521
+ match(input) {
456
522
  const match = input.match(PartClassesRE);
457
523
  if (match) {
458
524
  const part = `part(${match[2]})`;
@@ -466,7 +532,6 @@ const partClasses = {
466
532
  };
467
533
 
468
534
  const variants = (options) => [
469
- variantVariables,
470
535
  variantCssLayer,
471
536
  variantSelector,
472
537
  variantInternalLayer,
@@ -483,7 +548,8 @@ const variants = (options) => [
483
548
  partClasses,
484
549
  ...variantColorsMediaOrClass(options),
485
550
  ...variantLanguageDirections,
486
- variantScope
551
+ variantScope,
552
+ variantVariables
487
553
  ];
488
554
 
489
555
  export { variantBreakpoints as a, variantCombinators as b, calcMaxWidthBySize as c, variantPrint as d, variantCustomMedia as e, variantSupports as f, variantColorsMediaOrClass as g, variantLanguageDirections as h, variantSelector as i, variantCssLayer as j, variantInternalLayer as k, variantScope as l, variantVariables as m, variantPseudoClassesAndElements as n, variantPseudoClassFunctions as o, variantTaggedPseudoClasses as p, partClasses as q, variantImportant as r, variantNegative as s, variants as v };
@@ -1,6 +1,6 @@
1
1
  import { c as colors } from './preset-mini.65ac75be.mjs';
2
- import { O as transformBase, P as boxShadowsBase, Q as ringBase } from './preset-mini.7c9c225a.mjs';
3
- import './preset-mini.7d4b2219.mjs';
2
+ import { O as transformBase, P as boxShadowsBase, Q as ringBase } from './preset-mini.739fdcc7.mjs';
3
+ import './preset-mini.9c5f881e.mjs';
4
4
  import '@unocss/core';
5
5
 
6
6
  const fontFamily = {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const decoration = require('./preset-mini.740f2131.cjs');
4
- const colors = require('./preset-mini.2d0396b3.cjs');
3
+ const decoration = require('./preset-mini.7f221566.cjs');
4
+ const colors = require('./preset-mini.0109bbf2.cjs');
5
5
  require('@unocss/core');
6
6
 
7
7
  const opacity = [