@unocss/preset-mini 0.48.4 → 0.49.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ npm i -D @unocss/preset-mini
11
11
  ```ts
12
12
  import presetMini from '@unocss/preset-mini'
13
13
 
14
- Unocss({
14
+ UnoCSS({
15
15
  presets: [
16
16
  presetMini(),
17
17
  ],
package/dist/index.cjs CHANGED
@@ -8,8 +8,8 @@ const colors$1 = require('./shared/preset-mini.e54ce13d.cjs');
8
8
  const _default$1 = require('./shared/preset-mini.435805c5.cjs');
9
9
  const colors = require('./shared/preset-mini.30606736.cjs');
10
10
  const _default = require('./shared/preset-mini.43dfafb9.cjs');
11
- const _default$2 = require('./shared/preset-mini.89cb41ec.cjs');
12
- require('./shared/preset-mini.28b1d01c.cjs');
11
+ const _default$2 = require('./shared/preset-mini.12bd206f.cjs');
12
+ require('./shared/preset-mini.b5a73465.cjs');
13
13
 
14
14
  const preflights = [
15
15
  {
@@ -28,25 +28,41 @@ const presetMini = (options = {}) => {
28
28
  options.dark = options.dark ?? "class";
29
29
  options.attributifyPseudo = options.attributifyPseudo ?? false;
30
30
  options.preflight = options.preflight ?? true;
31
+ options.variablePrefix = options.variablePrefix ?? "un-";
31
32
  return {
32
33
  name: "@unocss/preset-mini",
33
34
  theme: _default.theme,
34
35
  rules: _default$1.rules,
35
36
  variants: _default$2.variants(options),
36
37
  options,
37
- postprocess: options.variablePrefix && options.variablePrefix !== "un-" ? VarPrefixPostprocessor(options.variablePrefix) : void 0,
38
- preflights: options.preflight ? preflights : [],
38
+ postprocess: VarPrefixPostprocessor(options.variablePrefix),
39
+ preflights: options.preflight ? normalizePreflights(preflights, options.variablePrefix) : [],
39
40
  prefix: options.prefix
40
41
  };
41
42
  };
42
43
  function VarPrefixPostprocessor(prefix) {
43
- return (obj) => {
44
- obj.entries.forEach((i) => {
45
- i[0] = i[0].replace(/^--un-/, `--${prefix}`);
46
- if (typeof i[1] === "string")
47
- i[1] = i[1].replace(/var\(--un-/g, `var(--${prefix}`);
48
- });
49
- };
44
+ if (prefix !== "un-") {
45
+ return (obj) => {
46
+ obj.entries.forEach((i) => {
47
+ i[0] = i[0].replace(/^--un-/, `--${prefix}`);
48
+ if (typeof i[1] === "string")
49
+ i[1] = i[1].replace(/var\(--un-/g, `var(--${prefix}`);
50
+ });
51
+ };
52
+ }
53
+ }
54
+ function normalizePreflights(preflights3, variablePrefix) {
55
+ if (variablePrefix !== "un-") {
56
+ return preflights3.map((p) => ({
57
+ ...p,
58
+ getCSS: (() => async (ctx) => {
59
+ const css = await p.getCSS(ctx);
60
+ if (css)
61
+ return css.replace(/--un-/g, `--${variablePrefix}`);
62
+ })()
63
+ }));
64
+ }
65
+ return preflights3;
50
66
  }
51
67
 
52
68
  exports.parseColor = colors$1.parseColor;
@@ -54,5 +70,6 @@ exports.colors = colors.colors;
54
70
  exports.theme = _default.theme;
55
71
  exports.VarPrefixPostprocessor = VarPrefixPostprocessor;
56
72
  exports["default"] = presetMini;
73
+ exports.normalizePreflights = normalizePreflights;
57
74
  exports.preflights = preflights;
58
75
  exports.presetMini = presetMini;
package/dist/index.d.ts CHANGED
@@ -55,6 +55,7 @@ interface PresetMiniOptions extends PresetOptions {
55
55
  }
56
56
  declare const presetMini: (options?: PresetMiniOptions) => Preset<Theme>;
57
57
 
58
- declare function VarPrefixPostprocessor(prefix: string): Postprocessor;
58
+ declare function VarPrefixPostprocessor(prefix: string): Postprocessor | undefined;
59
+ declare function normalizePreflights(preflights: Preflight[], variablePrefix: string): Preflight<{}>[];
59
60
 
60
- export { DarkModeSelectors, PresetMiniOptions, VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
61
+ export { DarkModeSelectors, PresetMiniOptions, VarPrefixPostprocessor, presetMini as default, normalizePreflights, preflights, presetMini };
package/dist/index.mjs CHANGED
@@ -5,8 +5,8 @@ import { r as rules } from './shared/preset-mini.6b96b995.mjs';
5
5
  export { c as colors } from './shared/preset-mini.65ac75be.mjs';
6
6
  import { t as theme } from './shared/preset-mini.0a36abfc.mjs';
7
7
  export { t as theme } from './shared/preset-mini.0a36abfc.mjs';
8
- import { v as variants } from './shared/preset-mini.0d510914.mjs';
9
- import './shared/preset-mini.bd4c0c0c.mjs';
8
+ import { v as variants } from './shared/preset-mini.7ae92961.mjs';
9
+ import './shared/preset-mini.d79c2b40.mjs';
10
10
 
11
11
  const preflights = [
12
12
  {
@@ -25,25 +25,41 @@ const presetMini = (options = {}) => {
25
25
  options.dark = options.dark ?? "class";
26
26
  options.attributifyPseudo = options.attributifyPseudo ?? false;
27
27
  options.preflight = options.preflight ?? true;
28
+ options.variablePrefix = options.variablePrefix ?? "un-";
28
29
  return {
29
30
  name: "@unocss/preset-mini",
30
31
  theme,
31
32
  rules,
32
33
  variants: variants(options),
33
34
  options,
34
- postprocess: options.variablePrefix && options.variablePrefix !== "un-" ? VarPrefixPostprocessor(options.variablePrefix) : void 0,
35
- preflights: options.preflight ? preflights : [],
35
+ postprocess: VarPrefixPostprocessor(options.variablePrefix),
36
+ preflights: options.preflight ? normalizePreflights(preflights, options.variablePrefix) : [],
36
37
  prefix: options.prefix
37
38
  };
38
39
  };
39
40
  function VarPrefixPostprocessor(prefix) {
40
- return (obj) => {
41
- obj.entries.forEach((i) => {
42
- i[0] = i[0].replace(/^--un-/, `--${prefix}`);
43
- if (typeof i[1] === "string")
44
- i[1] = i[1].replace(/var\(--un-/g, `var(--${prefix}`);
45
- });
46
- };
41
+ if (prefix !== "un-") {
42
+ return (obj) => {
43
+ obj.entries.forEach((i) => {
44
+ i[0] = i[0].replace(/^--un-/, `--${prefix}`);
45
+ if (typeof i[1] === "string")
46
+ i[1] = i[1].replace(/var\(--un-/g, `var(--${prefix}`);
47
+ });
48
+ };
49
+ }
50
+ }
51
+ function normalizePreflights(preflights3, variablePrefix) {
52
+ if (variablePrefix !== "un-") {
53
+ return preflights3.map((p) => ({
54
+ ...p,
55
+ getCSS: (() => async (ctx) => {
56
+ const css = await p.getCSS(ctx);
57
+ if (css)
58
+ return css.replace(/--un-/g, `--${variablePrefix}`);
59
+ })()
60
+ }));
61
+ }
62
+ return preflights3;
47
63
  }
48
64
 
49
- export { VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
65
+ export { VarPrefixPostprocessor, presetMini as default, normalizePreflights, preflights, presetMini };
@@ -2,15 +2,15 @@
2
2
 
3
3
  const colors = require('./preset-mini.e54ce13d.cjs');
4
4
  const core = require('@unocss/core');
5
- const variants$1 = require('./preset-mini.28b1d01c.cjs');
5
+ const variants$1 = require('./preset-mini.b5a73465.cjs');
6
6
 
7
7
  const variantAria = {
8
8
  name: "aria",
9
- match(matcher, { theme }) {
10
- const variant = variants$1.variantGetParameter("aria-", matcher, [":", "-"]);
9
+ match(matcher, ctx) {
10
+ const variant = variants$1.variantGetParameter("aria-", matcher, ctx.generator.config.separators);
11
11
  if (variant) {
12
12
  const [match, rest] = variant;
13
- const aria = colors.handler.bracket(match) ?? theme.aria?.[match] ?? "";
13
+ const aria = colors.handler.bracket(match) ?? ctx.theme.aria?.[match] ?? "";
14
14
  if (aria) {
15
15
  return {
16
16
  matcher: rest,
@@ -21,74 +21,77 @@ const variantAria = {
21
21
  }
22
22
  };
23
23
 
24
- const regexCache = {};
25
24
  const calcMaxWidthBySize = (size) => {
26
25
  const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
27
26
  const unit = size.slice(value.length);
28
27
  const maxWidth = parseFloat(value) - 0.1;
29
28
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
30
29
  };
31
- const variantBreakpoints = {
32
- name: "breakpoints",
33
- match(matcher, context) {
34
- const variantEntries = Object.entries(colors.resolveBreakpoints(context) ?? {}).map(([point, size], idx) => [point, size, idx]);
35
- for (const [point, size, idx] of variantEntries) {
36
- if (!regexCache[point])
37
- regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
38
- const match = matcher.match(regexCache[point]);
39
- if (!match)
40
- continue;
41
- const [, pre] = match;
42
- const m = matcher.slice(pre.length);
43
- if (m === "container")
44
- continue;
45
- const isLtPrefix = pre.startsWith("lt-");
46
- const isAtPrefix = pre.startsWith("at-");
47
- let order = 1e3;
48
- if (isLtPrefix) {
49
- order -= idx + 1;
50
- return {
51
- matcher: m,
52
- handle: (input, next) => next({
53
- ...input,
54
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (max-width: ${calcMaxWidthBySize(size)})`,
55
- parentOrder: order
56
- })
57
- };
58
- }
59
- order += idx + 1;
60
- if (isAtPrefix && idx < variantEntries.length - 1) {
30
+ const variantBreakpoints = () => {
31
+ const regexCache = {};
32
+ return {
33
+ name: "breakpoints",
34
+ match(matcher, context) {
35
+ const variantEntries = Object.entries(colors.resolveBreakpoints(context) ?? {}).map(([point, size], idx) => [point, size, idx]);
36
+ for (const [point, size, idx] of variantEntries) {
37
+ if (!regexCache[point])
38
+ regexCache[point] = new RegExp(`^((?:[al]t-)?${point}(?:${context.generator.config.separators.join("|")}))`);
39
+ const match = matcher.match(regexCache[point]);
40
+ if (!match)
41
+ continue;
42
+ const [, pre] = match;
43
+ const m = matcher.slice(pre.length);
44
+ if (m === "container")
45
+ continue;
46
+ const isLtPrefix = pre.startsWith("lt-");
47
+ const isAtPrefix = pre.startsWith("at-");
48
+ let order = 1e3;
49
+ if (isLtPrefix) {
50
+ order -= idx + 1;
51
+ return {
52
+ matcher: m,
53
+ handle: (input, next) => next({
54
+ ...input,
55
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (max-width: ${calcMaxWidthBySize(size)})`,
56
+ parentOrder: order
57
+ })
58
+ };
59
+ }
60
+ order += idx + 1;
61
+ if (isAtPrefix && idx < variantEntries.length - 1) {
62
+ return {
63
+ matcher: m,
64
+ handle: (input, next) => next({
65
+ ...input,
66
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`,
67
+ parentOrder: order
68
+ })
69
+ };
70
+ }
61
71
  return {
62
72
  matcher: m,
63
73
  handle: (input, next) => next({
64
74
  ...input,
65
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`,
75
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size})`,
66
76
  parentOrder: order
67
77
  })
68
78
  };
69
79
  }
70
- return {
71
- matcher: m,
72
- handle: (input, next) => next({
73
- ...input,
74
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size})`,
75
- parentOrder: order
76
- })
77
- };
78
- }
79
- },
80
- multiPass: true,
81
- autocomplete: "(at-|lt-|)$breakpoints:"
80
+ },
81
+ multiPass: true,
82
+ autocomplete: "(at-|lt-|)$breakpoints:"
83
+ };
82
84
  };
83
85
 
84
86
  const scopeMatcher = (name, combinator) => ({
85
87
  name: `combinator:${name}`,
86
- match(matcher) {
88
+ match(matcher, ctx) {
87
89
  if (!matcher.startsWith(name))
88
90
  return;
89
- let body = variants$1.variantGetBracket(`${name}-`, matcher, [":", "-"]);
91
+ const separators = ctx.generator.config.separators;
92
+ let body = variants$1.variantGetBracket(`${name}-`, matcher, separators);
90
93
  if (!body) {
91
- for (const separator of [":", "-"]) {
94
+ for (const separator of separators) {
92
95
  if (matcher.startsWith(`${name}${separator}`)) {
93
96
  body = ["", matcher.slice(name.length + separator.length)];
94
97
  break;
@@ -117,10 +120,10 @@ const variantCombinators = [
117
120
 
118
121
  const variantContainerQuery = {
119
122
  name: "@",
120
- match(matcher, { theme }) {
123
+ match(matcher, ctx) {
121
124
  if (matcher.startsWith("@container"))
122
125
  return;
123
- const variant = variants$1.variantGetParameter("@", matcher, [":", "-"]);
126
+ const variant = variants$1.variantGetParameter("@", matcher, ctx.generator.config.separators);
124
127
  if (variant) {
125
128
  const [match, rest, label] = variant;
126
129
  const unbracket = colors.handler.bracket(match);
@@ -130,7 +133,7 @@ const variantContainerQuery = {
130
133
  if (minWidth)
131
134
  container = `(min-width: ${minWidth})`;
132
135
  } else {
133
- container = theme.containers?.[match] ?? "";
136
+ container = ctx.theme.containers?.[match] ?? "";
134
137
  }
135
138
  if (container) {
136
139
  core.warnOnce("The container query variant is experimental and may not follow semver.");
@@ -149,11 +152,11 @@ const variantContainerQuery = {
149
152
 
150
153
  const variantDataAttribute = {
151
154
  name: "data",
152
- match(matcher, { theme }) {
153
- const variant = variants$1.variantGetParameter("data-", matcher, [":", "-"]);
155
+ match(matcher, ctx) {
156
+ const variant = variants$1.variantGetParameter("data-", matcher, ctx.generator.config.separators);
154
157
  if (variant) {
155
158
  const [match, rest] = variant;
156
- const dataAttribute = colors.handler.bracket(match) ?? theme.data?.[match] ?? "";
159
+ const dataAttribute = colors.handler.bracket(match) ?? ctx.theme.data?.[match] ?? "";
157
160
  if (dataAttribute) {
158
161
  return {
159
162
  matcher: rest,
@@ -167,13 +170,13 @@ const variantDataAttribute = {
167
170
  const variantPrint = variants$1.variantParentMatcher("print", "@media print");
168
171
  const variantCustomMedia = {
169
172
  name: "media",
170
- match(matcher, { theme }) {
171
- const variant = variants$1.variantGetParameter("media-", matcher, [":", "-"]);
173
+ match(matcher, ctx) {
174
+ const variant = variants$1.variantGetParameter("media-", matcher, ctx.generator.config.separators);
172
175
  if (variant) {
173
176
  const [match, rest] = variant;
174
177
  let media = colors.handler.bracket(match) ?? "";
175
178
  if (media === "")
176
- media = theme.media?.[match] ?? "";
179
+ media = ctx.theme.media?.[match] ?? "";
177
180
  if (media) {
178
181
  return {
179
182
  matcher: rest,
@@ -190,13 +193,13 @@ const variantCustomMedia = {
190
193
 
191
194
  const variantSupports = {
192
195
  name: "supports",
193
- match(matcher, { theme }) {
194
- const variant = variants$1.variantGetParameter("supports-", matcher, [":", "-"]);
196
+ match(matcher, ctx) {
197
+ const variant = variants$1.variantGetParameter("supports-", matcher, ctx.generator.config.separators);
195
198
  if (variant) {
196
199
  const [match, rest] = variant;
197
200
  let supports = colors.handler.bracket(match) ?? "";
198
201
  if (supports === "")
199
- supports = theme.supports?.[match] ?? "";
202
+ supports = ctx.theme.supports?.[match] ?? "";
200
203
  if (supports) {
201
204
  return {
202
205
  matcher: rest,
@@ -232,8 +235,8 @@ const variantLanguageDirections = [
232
235
 
233
236
  const variantSelector = {
234
237
  name: "selector",
235
- match(matcher) {
236
- const variant = variants$1.variantGetBracket("selector-", matcher, [":", "-"]);
238
+ match(matcher, ctx) {
239
+ const variant = variants$1.variantGetBracket("selector-", matcher, ctx.generator.config.separators);
237
240
  if (variant) {
238
241
  const [match, rest] = variant;
239
242
  const selector = colors.handler.bracket(match);
@@ -248,8 +251,8 @@ const variantSelector = {
248
251
  };
249
252
  const variantCssLayer = {
250
253
  name: "layer",
251
- match(matcher) {
252
- const variant = variants$1.variantGetParameter("layer-", matcher, [":", "-"]);
254
+ match(matcher, ctx) {
255
+ const variant = variants$1.variantGetParameter("layer-", matcher, ctx.generator.config.separators);
253
256
  if (variant) {
254
257
  const [match, rest] = variant;
255
258
  const layer = colors.handler.bracket(match) ?? match;
@@ -267,8 +270,8 @@ const variantCssLayer = {
267
270
  };
268
271
  const variantInternalLayer = {
269
272
  name: "uno-layer",
270
- match(matcher) {
271
- const variant = variants$1.variantGetParameter("uno-layer-", matcher, [":", "-"]);
273
+ match(matcher, ctx) {
274
+ const variant = variants$1.variantGetParameter("uno-layer-", matcher, ctx.generator.config.separators);
272
275
  if (variant) {
273
276
  const [match, rest] = variant;
274
277
  const layer = colors.handler.bracket(match) ?? match;
@@ -283,8 +286,8 @@ const variantInternalLayer = {
283
286
  };
284
287
  const variantScope = {
285
288
  name: "scope",
286
- match(matcher) {
287
- const variant = variants$1.variantGetBracket("scope-", matcher, [":", "-"]);
289
+ match(matcher, ctx) {
290
+ const variant = variants$1.variantGetBracket("scope-", matcher, ctx.generator.config.separators);
288
291
  if (variant) {
289
292
  const [match, rest] = variant;
290
293
  const scope = colors.handler.bracket(match);
@@ -299,14 +302,14 @@ const variantScope = {
299
302
  };
300
303
  const variantVariables = {
301
304
  name: "variables",
302
- match(matcher) {
305
+ match(matcher, ctx) {
303
306
  if (!matcher.startsWith("["))
304
307
  return;
305
308
  const [match, rest] = colors.getBracket(matcher, "[", "]") ?? [];
306
309
  if (!(match && rest))
307
310
  return;
308
311
  let newMatcher;
309
- for (const separator of [":", "-"]) {
312
+ for (const separator of ctx.generator.config.separators) {
310
313
  if (rest.startsWith(separator)) {
311
314
  newMatcher = rest.slice(separator.length);
312
315
  break;
@@ -382,28 +385,33 @@ const variantNegative = {
382
385
  }
383
386
  };
384
387
 
385
- const variantImportant = {
386
- name: "important",
387
- match(matcher) {
388
- let base;
389
- const match = matcher.match(/^(important[:-]|!)/);
390
- if (match)
391
- base = matcher.slice(match[0].length);
392
- else if (matcher.endsWith("!"))
393
- base = matcher.slice(0, -1);
394
- if (base) {
395
- return {
396
- matcher: base,
397
- body: (body) => {
398
- body.forEach((v) => {
399
- if (v[1])
400
- v[1] += " !important";
401
- });
402
- return body;
403
- }
404
- };
388
+ const variantImportant = () => {
389
+ let re;
390
+ return {
391
+ name: "important",
392
+ match(matcher, ctx) {
393
+ if (!re)
394
+ re = new RegExp(`^(important(?:${ctx.generator.config.separators.join("|")})|!)`);
395
+ let base;
396
+ const match = matcher.match(re);
397
+ if (match)
398
+ base = matcher.slice(match[0].length);
399
+ else if (matcher.endsWith("!"))
400
+ base = matcher.slice(0, -1);
401
+ if (base) {
402
+ return {
403
+ matcher: base,
404
+ body: (body) => {
405
+ body.forEach((v) => {
406
+ if (v[1])
407
+ v[1] += " !important";
408
+ });
409
+ return body;
410
+ }
411
+ };
412
+ }
405
413
  }
406
- }
414
+ };
407
415
  };
408
416
 
409
417
  const PseudoClasses = Object.fromEntries([
@@ -471,8 +479,9 @@ const sortValue = (pseudo) => {
471
479
  };
472
480
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
473
481
  const rawRE = new RegExp(`^(${core.escapeRegExp(parent)}:)(\\S+)${core.escapeRegExp(combinator)}\\1`);
474
- const pseudoRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))(?:(/\\w+))?[:-]`);
475
- const pseudoColonRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesColonStr}))(?:(/\\w+))?[:]`);
482
+ let splitRE;
483
+ let pseudoRE;
484
+ let pseudoColonRE;
476
485
  const matchBracket = (input) => {
477
486
  const body = variants$1.variantGetBracket(`${tag}-`, input, []);
478
487
  if (!body)
@@ -481,7 +490,7 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
481
490
  const bracketValue = colors.handler.bracket(match);
482
491
  if (bracketValue == null)
483
492
  return;
484
- const label = rest.split(/[:-]/, 1)?.[0] ?? "";
493
+ const label = rest.split(splitRE, 1)?.[0] ?? "";
485
494
  const prefix = `${parent}${core.escapeSelector(label)}`;
486
495
  return [
487
496
  label,
@@ -507,7 +516,12 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
507
516
  };
508
517
  return {
509
518
  name: `pseudo:${tag}`,
510
- match(input) {
519
+ match(input, ctx) {
520
+ if (!(splitRE && pseudoRE && pseudoColonRE)) {
521
+ splitRE = new RegExp(`(?:${ctx.generator.config.separators.join("|")})`);
522
+ pseudoRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))(?:(/\\w+))?(?:${ctx.generator.config.separators.join("|")})`);
523
+ pseudoColonRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesColonStr}))(?:(/\\w+))?(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
524
+ }
511
525
  if (!input.startsWith(tag))
512
526
  return;
513
527
  const result = matchBracket(input) || matchPseudo(input);
@@ -530,50 +544,62 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
530
544
  };
531
545
  const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
532
546
  const PseudoClassesAndElementsColonStr = Object.entries(PseudoClassesColon).map(([key]) => key).join("|");
533
- const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
534
- const PseudoClassesAndElementsColonRE = new RegExp(`^(${PseudoClassesAndElementsColonStr})[:]`);
535
- const variantPseudoClassesAndElements = {
536
- name: "pseudo",
537
- match(input) {
538
- const match = input.match(PseudoClassesAndElementsRE) || input.match(PseudoClassesAndElementsColonRE);
539
- if (match) {
540
- const pseudo = PseudoClasses[match[1]] || PseudoClassesColon[match[1]] || `:${match[1]}`;
541
- return {
542
- matcher: input.slice(match[0].length),
543
- handle: (input2, next) => {
544
- const selectors = pseudo.startsWith("::") ? {
545
- pseudo: `${input2.pseudo}${pseudo}`
546
- } : {
547
- selector: `${input2.selector}${pseudo}`
548
- };
549
- return next({
550
- ...input2,
551
- ...selectors,
552
- sort: sortValue(match[1])
553
- });
554
- }
555
- };
556
- }
557
- },
558
- multiPass: true,
559
- autocomplete: `(${PseudoClassesAndElementsStr}):`
547
+ const variantPseudoClassesAndElements = () => {
548
+ let PseudoClassesAndElementsRE;
549
+ let PseudoClassesAndElementsColonRE;
550
+ return {
551
+ name: "pseudo",
552
+ match(input, ctx) {
553
+ if (!(PseudoClassesAndElementsRE && PseudoClassesAndElementsRE)) {
554
+ PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})(?:${ctx.generator.config.separators.join("|")})`);
555
+ PseudoClassesAndElementsColonRE = new RegExp(`^(${PseudoClassesAndElementsColonStr})(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
556
+ }
557
+ const match = input.match(PseudoClassesAndElementsRE) || input.match(PseudoClassesAndElementsColonRE);
558
+ if (match) {
559
+ const pseudo = PseudoClasses[match[1]] || PseudoClassesColon[match[1]] || `:${match[1]}`;
560
+ return {
561
+ matcher: input.slice(match[0].length),
562
+ handle: (input2, next) => {
563
+ const selectors = pseudo.startsWith("::") ? {
564
+ pseudo: `${input2.pseudo}${pseudo}`
565
+ } : {
566
+ selector: `${input2.selector}${pseudo}`
567
+ };
568
+ return next({
569
+ ...input2,
570
+ ...selectors,
571
+ sort: sortValue(match[1])
572
+ });
573
+ }
574
+ };
575
+ }
576
+ },
577
+ multiPass: true,
578
+ autocomplete: `(${PseudoClassesAndElementsStr}|${PseudoClassesAndElementsColonStr}):`
579
+ };
560
580
  };
561
- const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
562
- const PseudoClassColonFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesColonStr})[:]`);
563
- const variantPseudoClassFunctions = {
564
- match(input) {
565
- const match = input.match(PseudoClassFunctionsRE) || input.match(PseudoClassColonFunctionsRE);
566
- if (match) {
567
- const fn = match[1];
568
- const pseudo = PseudoClasses[match[2]] || PseudoClassesColon[match[2]] || `:${match[2]}`;
569
- return {
570
- matcher: input.slice(match[0].length),
571
- selector: (s) => `${s}:${fn}(${pseudo})`
572
- };
573
- }
574
- },
575
- multiPass: true,
576
- autocomplete: `(${PseudoClassFunctionsStr})-(${PseudoClassesStr}|${PseudoClassesColonStr}):`
581
+ const variantPseudoClassFunctions = () => {
582
+ let PseudoClassFunctionsRE;
583
+ let PseudoClassColonFunctionsRE;
584
+ return {
585
+ match(input, ctx) {
586
+ if (!(PseudoClassFunctionsRE && PseudoClassColonFunctionsRE)) {
587
+ PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})(?:${ctx.generator.config.separators.join("|")})`);
588
+ PseudoClassColonFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesColonStr})(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
589
+ }
590
+ const match = input.match(PseudoClassFunctionsRE) || input.match(PseudoClassColonFunctionsRE);
591
+ if (match) {
592
+ const fn = match[1];
593
+ const pseudo = PseudoClasses[match[2]] || PseudoClassesColon[match[2]] || `:${match[2]}`;
594
+ return {
595
+ matcher: input.slice(match[0].length),
596
+ selector: (s) => `${s}:${fn}(${pseudo})`
597
+ };
598
+ }
599
+ },
600
+ multiPass: true,
601
+ autocomplete: `(${PseudoClassFunctionsStr})-(${PseudoClassesStr}|${PseudoClassesColonStr}):`
602
+ };
577
603
  };
578
604
  const variantTaggedPseudoClasses = (options = {}) => {
579
605
  const attributify = !!options?.attributifyPseudo;
@@ -606,14 +632,14 @@ const variants = (options) => [
606
632
  variantSelector,
607
633
  variantInternalLayer,
608
634
  variantNegative,
609
- variantImportant,
635
+ variantImportant(),
610
636
  variantSupports,
611
637
  variantPrint,
612
638
  variantCustomMedia,
613
- variantBreakpoints,
639
+ variantBreakpoints(),
614
640
  ...variantCombinators,
615
- variantPseudoClassesAndElements,
616
- variantPseudoClassFunctions,
641
+ variantPseudoClassesAndElements(),
642
+ variantPseudoClassFunctions(),
617
643
  ...variantTaggedPseudoClasses(options),
618
644
  partClasses,
619
645
  ...variantColorsMediaOrClass(options),
@@ -1,14 +1,14 @@
1
1
  import { h as handler, l as resolveBreakpoints, q as getBracket, C as CONTROL_MINI_NO_NEGATIVE, t as getComponent } from './preset-mini.ca595ab5.mjs';
2
2
  import { warnOnce, escapeRegExp, escapeSelector } from '@unocss/core';
3
- import { v as variantGetParameter, a as variantGetBracket, b as variantParentMatcher, c as variantMatcher } from './preset-mini.bd4c0c0c.mjs';
3
+ import { v as variantGetParameter, a as variantGetBracket, b as variantParentMatcher, c as variantMatcher } from './preset-mini.d79c2b40.mjs';
4
4
 
5
5
  const variantAria = {
6
6
  name: "aria",
7
- match(matcher, { theme }) {
8
- const variant = variantGetParameter("aria-", matcher, [":", "-"]);
7
+ match(matcher, ctx) {
8
+ const variant = variantGetParameter("aria-", matcher, ctx.generator.config.separators);
9
9
  if (variant) {
10
10
  const [match, rest] = variant;
11
- const aria = handler.bracket(match) ?? theme.aria?.[match] ?? "";
11
+ const aria = handler.bracket(match) ?? ctx.theme.aria?.[match] ?? "";
12
12
  if (aria) {
13
13
  return {
14
14
  matcher: rest,
@@ -19,74 +19,77 @@ const variantAria = {
19
19
  }
20
20
  };
21
21
 
22
- const regexCache = {};
23
22
  const calcMaxWidthBySize = (size) => {
24
23
  const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
25
24
  const unit = size.slice(value.length);
26
25
  const maxWidth = parseFloat(value) - 0.1;
27
26
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
28
27
  };
29
- const variantBreakpoints = {
30
- name: "breakpoints",
31
- match(matcher, context) {
32
- const variantEntries = Object.entries(resolveBreakpoints(context) ?? {}).map(([point, size], idx) => [point, size, idx]);
33
- for (const [point, size, idx] of variantEntries) {
34
- if (!regexCache[point])
35
- regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
36
- const match = matcher.match(regexCache[point]);
37
- if (!match)
38
- continue;
39
- const [, pre] = match;
40
- const m = matcher.slice(pre.length);
41
- if (m === "container")
42
- continue;
43
- const isLtPrefix = pre.startsWith("lt-");
44
- const isAtPrefix = pre.startsWith("at-");
45
- let order = 1e3;
46
- if (isLtPrefix) {
47
- order -= idx + 1;
48
- return {
49
- matcher: m,
50
- handle: (input, next) => next({
51
- ...input,
52
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (max-width: ${calcMaxWidthBySize(size)})`,
53
- parentOrder: order
54
- })
55
- };
56
- }
57
- order += idx + 1;
58
- if (isAtPrefix && idx < variantEntries.length - 1) {
28
+ const variantBreakpoints = () => {
29
+ const regexCache = {};
30
+ return {
31
+ name: "breakpoints",
32
+ match(matcher, context) {
33
+ const variantEntries = Object.entries(resolveBreakpoints(context) ?? {}).map(([point, size], idx) => [point, size, idx]);
34
+ for (const [point, size, idx] of variantEntries) {
35
+ if (!regexCache[point])
36
+ regexCache[point] = new RegExp(`^((?:[al]t-)?${point}(?:${context.generator.config.separators.join("|")}))`);
37
+ const match = matcher.match(regexCache[point]);
38
+ if (!match)
39
+ continue;
40
+ const [, pre] = match;
41
+ const m = matcher.slice(pre.length);
42
+ if (m === "container")
43
+ continue;
44
+ const isLtPrefix = pre.startsWith("lt-");
45
+ const isAtPrefix = pre.startsWith("at-");
46
+ let order = 1e3;
47
+ if (isLtPrefix) {
48
+ order -= idx + 1;
49
+ return {
50
+ matcher: m,
51
+ handle: (input, next) => next({
52
+ ...input,
53
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (max-width: ${calcMaxWidthBySize(size)})`,
54
+ parentOrder: order
55
+ })
56
+ };
57
+ }
58
+ order += idx + 1;
59
+ if (isAtPrefix && idx < variantEntries.length - 1) {
60
+ return {
61
+ matcher: m,
62
+ handle: (input, next) => next({
63
+ ...input,
64
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`,
65
+ parentOrder: order
66
+ })
67
+ };
68
+ }
59
69
  return {
60
70
  matcher: m,
61
71
  handle: (input, next) => next({
62
72
  ...input,
63
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`,
73
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size})`,
64
74
  parentOrder: order
65
75
  })
66
76
  };
67
77
  }
68
- return {
69
- matcher: m,
70
- handle: (input, next) => next({
71
- ...input,
72
- parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size})`,
73
- parentOrder: order
74
- })
75
- };
76
- }
77
- },
78
- multiPass: true,
79
- autocomplete: "(at-|lt-|)$breakpoints:"
78
+ },
79
+ multiPass: true,
80
+ autocomplete: "(at-|lt-|)$breakpoints:"
81
+ };
80
82
  };
81
83
 
82
84
  const scopeMatcher = (name, combinator) => ({
83
85
  name: `combinator:${name}`,
84
- match(matcher) {
86
+ match(matcher, ctx) {
85
87
  if (!matcher.startsWith(name))
86
88
  return;
87
- let body = variantGetBracket(`${name}-`, matcher, [":", "-"]);
89
+ const separators = ctx.generator.config.separators;
90
+ let body = variantGetBracket(`${name}-`, matcher, separators);
88
91
  if (!body) {
89
- for (const separator of [":", "-"]) {
92
+ for (const separator of separators) {
90
93
  if (matcher.startsWith(`${name}${separator}`)) {
91
94
  body = ["", matcher.slice(name.length + separator.length)];
92
95
  break;
@@ -115,10 +118,10 @@ const variantCombinators = [
115
118
 
116
119
  const variantContainerQuery = {
117
120
  name: "@",
118
- match(matcher, { theme }) {
121
+ match(matcher, ctx) {
119
122
  if (matcher.startsWith("@container"))
120
123
  return;
121
- const variant = variantGetParameter("@", matcher, [":", "-"]);
124
+ const variant = variantGetParameter("@", matcher, ctx.generator.config.separators);
122
125
  if (variant) {
123
126
  const [match, rest, label] = variant;
124
127
  const unbracket = handler.bracket(match);
@@ -128,7 +131,7 @@ const variantContainerQuery = {
128
131
  if (minWidth)
129
132
  container = `(min-width: ${minWidth})`;
130
133
  } else {
131
- container = theme.containers?.[match] ?? "";
134
+ container = ctx.theme.containers?.[match] ?? "";
132
135
  }
133
136
  if (container) {
134
137
  warnOnce("The container query variant is experimental and may not follow semver.");
@@ -147,11 +150,11 @@ const variantContainerQuery = {
147
150
 
148
151
  const variantDataAttribute = {
149
152
  name: "data",
150
- match(matcher, { theme }) {
151
- const variant = variantGetParameter("data-", matcher, [":", "-"]);
153
+ match(matcher, ctx) {
154
+ const variant = variantGetParameter("data-", matcher, ctx.generator.config.separators);
152
155
  if (variant) {
153
156
  const [match, rest] = variant;
154
- const dataAttribute = handler.bracket(match) ?? theme.data?.[match] ?? "";
157
+ const dataAttribute = handler.bracket(match) ?? ctx.theme.data?.[match] ?? "";
155
158
  if (dataAttribute) {
156
159
  return {
157
160
  matcher: rest,
@@ -165,13 +168,13 @@ const variantDataAttribute = {
165
168
  const variantPrint = variantParentMatcher("print", "@media print");
166
169
  const variantCustomMedia = {
167
170
  name: "media",
168
- match(matcher, { theme }) {
169
- const variant = variantGetParameter("media-", matcher, [":", "-"]);
171
+ match(matcher, ctx) {
172
+ const variant = variantGetParameter("media-", matcher, ctx.generator.config.separators);
170
173
  if (variant) {
171
174
  const [match, rest] = variant;
172
175
  let media = handler.bracket(match) ?? "";
173
176
  if (media === "")
174
- media = theme.media?.[match] ?? "";
177
+ media = ctx.theme.media?.[match] ?? "";
175
178
  if (media) {
176
179
  return {
177
180
  matcher: rest,
@@ -188,13 +191,13 @@ const variantCustomMedia = {
188
191
 
189
192
  const variantSupports = {
190
193
  name: "supports",
191
- match(matcher, { theme }) {
192
- const variant = variantGetParameter("supports-", matcher, [":", "-"]);
194
+ match(matcher, ctx) {
195
+ const variant = variantGetParameter("supports-", matcher, ctx.generator.config.separators);
193
196
  if (variant) {
194
197
  const [match, rest] = variant;
195
198
  let supports = handler.bracket(match) ?? "";
196
199
  if (supports === "")
197
- supports = theme.supports?.[match] ?? "";
200
+ supports = ctx.theme.supports?.[match] ?? "";
198
201
  if (supports) {
199
202
  return {
200
203
  matcher: rest,
@@ -230,8 +233,8 @@ const variantLanguageDirections = [
230
233
 
231
234
  const variantSelector = {
232
235
  name: "selector",
233
- match(matcher) {
234
- const variant = variantGetBracket("selector-", matcher, [":", "-"]);
236
+ match(matcher, ctx) {
237
+ const variant = variantGetBracket("selector-", matcher, ctx.generator.config.separators);
235
238
  if (variant) {
236
239
  const [match, rest] = variant;
237
240
  const selector = handler.bracket(match);
@@ -246,8 +249,8 @@ const variantSelector = {
246
249
  };
247
250
  const variantCssLayer = {
248
251
  name: "layer",
249
- match(matcher) {
250
- const variant = variantGetParameter("layer-", matcher, [":", "-"]);
252
+ match(matcher, ctx) {
253
+ const variant = variantGetParameter("layer-", matcher, ctx.generator.config.separators);
251
254
  if (variant) {
252
255
  const [match, rest] = variant;
253
256
  const layer = handler.bracket(match) ?? match;
@@ -265,8 +268,8 @@ const variantCssLayer = {
265
268
  };
266
269
  const variantInternalLayer = {
267
270
  name: "uno-layer",
268
- match(matcher) {
269
- const variant = variantGetParameter("uno-layer-", matcher, [":", "-"]);
271
+ match(matcher, ctx) {
272
+ const variant = variantGetParameter("uno-layer-", matcher, ctx.generator.config.separators);
270
273
  if (variant) {
271
274
  const [match, rest] = variant;
272
275
  const layer = handler.bracket(match) ?? match;
@@ -281,8 +284,8 @@ const variantInternalLayer = {
281
284
  };
282
285
  const variantScope = {
283
286
  name: "scope",
284
- match(matcher) {
285
- const variant = variantGetBracket("scope-", matcher, [":", "-"]);
287
+ match(matcher, ctx) {
288
+ const variant = variantGetBracket("scope-", matcher, ctx.generator.config.separators);
286
289
  if (variant) {
287
290
  const [match, rest] = variant;
288
291
  const scope = handler.bracket(match);
@@ -297,14 +300,14 @@ const variantScope = {
297
300
  };
298
301
  const variantVariables = {
299
302
  name: "variables",
300
- match(matcher) {
303
+ match(matcher, ctx) {
301
304
  if (!matcher.startsWith("["))
302
305
  return;
303
306
  const [match, rest] = getBracket(matcher, "[", "]") ?? [];
304
307
  if (!(match && rest))
305
308
  return;
306
309
  let newMatcher;
307
- for (const separator of [":", "-"]) {
310
+ for (const separator of ctx.generator.config.separators) {
308
311
  if (rest.startsWith(separator)) {
309
312
  newMatcher = rest.slice(separator.length);
310
313
  break;
@@ -380,28 +383,33 @@ const variantNegative = {
380
383
  }
381
384
  };
382
385
 
383
- const variantImportant = {
384
- name: "important",
385
- match(matcher) {
386
- let base;
387
- const match = matcher.match(/^(important[:-]|!)/);
388
- if (match)
389
- base = matcher.slice(match[0].length);
390
- else if (matcher.endsWith("!"))
391
- base = matcher.slice(0, -1);
392
- if (base) {
393
- return {
394
- matcher: base,
395
- body: (body) => {
396
- body.forEach((v) => {
397
- if (v[1])
398
- v[1] += " !important";
399
- });
400
- return body;
401
- }
402
- };
386
+ const variantImportant = () => {
387
+ let re;
388
+ return {
389
+ name: "important",
390
+ match(matcher, ctx) {
391
+ if (!re)
392
+ re = new RegExp(`^(important(?:${ctx.generator.config.separators.join("|")})|!)`);
393
+ let base;
394
+ const match = matcher.match(re);
395
+ if (match)
396
+ base = matcher.slice(match[0].length);
397
+ else if (matcher.endsWith("!"))
398
+ base = matcher.slice(0, -1);
399
+ if (base) {
400
+ return {
401
+ matcher: base,
402
+ body: (body) => {
403
+ body.forEach((v) => {
404
+ if (v[1])
405
+ v[1] += " !important";
406
+ });
407
+ return body;
408
+ }
409
+ };
410
+ }
403
411
  }
404
- }
412
+ };
405
413
  };
406
414
 
407
415
  const PseudoClasses = Object.fromEntries([
@@ -469,8 +477,9 @@ const sortValue = (pseudo) => {
469
477
  };
470
478
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
471
479
  const rawRE = new RegExp(`^(${escapeRegExp(parent)}:)(\\S+)${escapeRegExp(combinator)}\\1`);
472
- const pseudoRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))(?:(/\\w+))?[:-]`);
473
- const pseudoColonRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesColonStr}))(?:(/\\w+))?[:]`);
480
+ let splitRE;
481
+ let pseudoRE;
482
+ let pseudoColonRE;
474
483
  const matchBracket = (input) => {
475
484
  const body = variantGetBracket(`${tag}-`, input, []);
476
485
  if (!body)
@@ -479,7 +488,7 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
479
488
  const bracketValue = handler.bracket(match);
480
489
  if (bracketValue == null)
481
490
  return;
482
- const label = rest.split(/[:-]/, 1)?.[0] ?? "";
491
+ const label = rest.split(splitRE, 1)?.[0] ?? "";
483
492
  const prefix = `${parent}${escapeSelector(label)}`;
484
493
  return [
485
494
  label,
@@ -505,7 +514,12 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
505
514
  };
506
515
  return {
507
516
  name: `pseudo:${tag}`,
508
- match(input) {
517
+ match(input, ctx) {
518
+ if (!(splitRE && pseudoRE && pseudoColonRE)) {
519
+ splitRE = new RegExp(`(?:${ctx.generator.config.separators.join("|")})`);
520
+ pseudoRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))(?:(/\\w+))?(?:${ctx.generator.config.separators.join("|")})`);
521
+ pseudoColonRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesColonStr}))(?:(/\\w+))?(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
522
+ }
509
523
  if (!input.startsWith(tag))
510
524
  return;
511
525
  const result = matchBracket(input) || matchPseudo(input);
@@ -528,50 +542,62 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
528
542
  };
529
543
  const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
530
544
  const PseudoClassesAndElementsColonStr = Object.entries(PseudoClassesColon).map(([key]) => key).join("|");
531
- const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
532
- const PseudoClassesAndElementsColonRE = new RegExp(`^(${PseudoClassesAndElementsColonStr})[:]`);
533
- const variantPseudoClassesAndElements = {
534
- name: "pseudo",
535
- match(input) {
536
- const match = input.match(PseudoClassesAndElementsRE) || input.match(PseudoClassesAndElementsColonRE);
537
- if (match) {
538
- const pseudo = PseudoClasses[match[1]] || PseudoClassesColon[match[1]] || `:${match[1]}`;
539
- return {
540
- matcher: input.slice(match[0].length),
541
- handle: (input2, next) => {
542
- const selectors = pseudo.startsWith("::") ? {
543
- pseudo: `${input2.pseudo}${pseudo}`
544
- } : {
545
- selector: `${input2.selector}${pseudo}`
546
- };
547
- return next({
548
- ...input2,
549
- ...selectors,
550
- sort: sortValue(match[1])
551
- });
552
- }
553
- };
554
- }
555
- },
556
- multiPass: true,
557
- autocomplete: `(${PseudoClassesAndElementsStr}):`
545
+ const variantPseudoClassesAndElements = () => {
546
+ let PseudoClassesAndElementsRE;
547
+ let PseudoClassesAndElementsColonRE;
548
+ return {
549
+ name: "pseudo",
550
+ match(input, ctx) {
551
+ if (!(PseudoClassesAndElementsRE && PseudoClassesAndElementsRE)) {
552
+ PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})(?:${ctx.generator.config.separators.join("|")})`);
553
+ PseudoClassesAndElementsColonRE = new RegExp(`^(${PseudoClassesAndElementsColonStr})(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
554
+ }
555
+ const match = input.match(PseudoClassesAndElementsRE) || input.match(PseudoClassesAndElementsColonRE);
556
+ if (match) {
557
+ const pseudo = PseudoClasses[match[1]] || PseudoClassesColon[match[1]] || `:${match[1]}`;
558
+ return {
559
+ matcher: input.slice(match[0].length),
560
+ handle: (input2, next) => {
561
+ const selectors = pseudo.startsWith("::") ? {
562
+ pseudo: `${input2.pseudo}${pseudo}`
563
+ } : {
564
+ selector: `${input2.selector}${pseudo}`
565
+ };
566
+ return next({
567
+ ...input2,
568
+ ...selectors,
569
+ sort: sortValue(match[1])
570
+ });
571
+ }
572
+ };
573
+ }
574
+ },
575
+ multiPass: true,
576
+ autocomplete: `(${PseudoClassesAndElementsStr}|${PseudoClassesAndElementsColonStr}):`
577
+ };
558
578
  };
559
- const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
560
- const PseudoClassColonFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesColonStr})[:]`);
561
- const variantPseudoClassFunctions = {
562
- match(input) {
563
- const match = input.match(PseudoClassFunctionsRE) || input.match(PseudoClassColonFunctionsRE);
564
- if (match) {
565
- const fn = match[1];
566
- const pseudo = PseudoClasses[match[2]] || PseudoClassesColon[match[2]] || `:${match[2]}`;
567
- return {
568
- matcher: input.slice(match[0].length),
569
- selector: (s) => `${s}:${fn}(${pseudo})`
570
- };
571
- }
572
- },
573
- multiPass: true,
574
- autocomplete: `(${PseudoClassFunctionsStr})-(${PseudoClassesStr}|${PseudoClassesColonStr}):`
579
+ const variantPseudoClassFunctions = () => {
580
+ let PseudoClassFunctionsRE;
581
+ let PseudoClassColonFunctionsRE;
582
+ return {
583
+ match(input, ctx) {
584
+ if (!(PseudoClassFunctionsRE && PseudoClassColonFunctionsRE)) {
585
+ PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})(?:${ctx.generator.config.separators.join("|")})`);
586
+ PseudoClassColonFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesColonStr})(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
587
+ }
588
+ const match = input.match(PseudoClassFunctionsRE) || input.match(PseudoClassColonFunctionsRE);
589
+ if (match) {
590
+ const fn = match[1];
591
+ const pseudo = PseudoClasses[match[2]] || PseudoClassesColon[match[2]] || `:${match[2]}`;
592
+ return {
593
+ matcher: input.slice(match[0].length),
594
+ selector: (s) => `${s}:${fn}(${pseudo})`
595
+ };
596
+ }
597
+ },
598
+ multiPass: true,
599
+ autocomplete: `(${PseudoClassFunctionsStr})-(${PseudoClassesStr}|${PseudoClassesColonStr}):`
600
+ };
575
601
  };
576
602
  const variantTaggedPseudoClasses = (options = {}) => {
577
603
  const attributify = !!options?.attributifyPseudo;
@@ -604,14 +630,14 @@ const variants = (options) => [
604
630
  variantSelector,
605
631
  variantInternalLayer,
606
632
  variantNegative,
607
- variantImportant,
633
+ variantImportant(),
608
634
  variantSupports,
609
635
  variantPrint,
610
636
  variantCustomMedia,
611
- variantBreakpoints,
637
+ variantBreakpoints(),
612
638
  ...variantCombinators,
613
- variantPseudoClassesAndElements,
614
- variantPseudoClassFunctions,
639
+ variantPseudoClassesAndElements(),
640
+ variantPseudoClassFunctions(),
615
641
  ...variantTaggedPseudoClasses(options),
616
642
  partClasses,
617
643
  ...variantColorsMediaOrClass(options),
@@ -4,10 +4,12 @@ const core = require('@unocss/core');
4
4
  const colors = require('./preset-mini.e54ce13d.cjs');
5
5
 
6
6
  const variantMatcher = (name, handler) => {
7
- const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
7
+ let re;
8
8
  return {
9
9
  name,
10
- match(input) {
10
+ match(input, ctx) {
11
+ if (!re)
12
+ re = new RegExp(`^${core.escapeRegExp(name)}(?:${ctx.generator.config.separators.join("|")})`);
11
13
  const match = input.match(re);
12
14
  if (match) {
13
15
  return {
@@ -23,10 +25,12 @@ const variantMatcher = (name, handler) => {
23
25
  };
24
26
  };
25
27
  const variantParentMatcher = (name, parent) => {
26
- const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
28
+ let re;
27
29
  return {
28
30
  name,
29
- match(input) {
31
+ match(input, ctx) {
32
+ if (!re)
33
+ re = new RegExp(`^${core.escapeRegExp(name)}(?:${ctx.generator.config.separators.join("|")})`);
30
34
  const match = input.match(re);
31
35
  if (match) {
32
36
  return {
@@ -2,10 +2,12 @@ import { escapeRegExp } from '@unocss/core';
2
2
  import { q as getBracket } from './preset-mini.ca595ab5.mjs';
3
3
 
4
4
  const variantMatcher = (name, handler) => {
5
- const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
5
+ let re;
6
6
  return {
7
7
  name,
8
- match(input) {
8
+ match(input, ctx) {
9
+ if (!re)
10
+ re = new RegExp(`^${escapeRegExp(name)}(?:${ctx.generator.config.separators.join("|")})`);
9
11
  const match = input.match(re);
10
12
  if (match) {
11
13
  return {
@@ -21,10 +23,12 @@ const variantMatcher = (name, handler) => {
21
23
  };
22
24
  };
23
25
  const variantParentMatcher = (name, parent) => {
24
- const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
26
+ let re;
25
27
  return {
26
28
  name,
27
- match(input) {
29
+ match(input, ctx) {
30
+ if (!re)
31
+ re = new RegExp(`^${escapeRegExp(name)}(?:${ctx.generator.config.separators.join("|")})`);
28
32
  const match = input.match(re);
29
33
  if (match) {
30
34
  return {
package/dist/utils.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const colors = require('./shared/preset-mini.e54ce13d.cjs');
6
- const variants = require('./shared/preset-mini.28b1d01c.cjs');
6
+ const variants = require('./shared/preset-mini.b5a73465.cjs');
7
7
  require('@unocss/core');
8
8
 
9
9
 
package/dist/utils.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  export { C as CONTROL_MINI_NO_NEGATIVE, f as colorOpacityToString, c as colorResolver, e as colorToString, i as colorableShadows, b as cornerMap, d as directionMap, o as directionSize, q as getBracket, t as getComponent, z as getComponents, g as globalKeywords, w as h, h as handler, a as hasParseableColor, u as hex2rgba, j as insetMap, m as makeGlobalStaticRules, p as parseColor, v as parseCssColor, k as positionMap, l as resolveBreakpoints, r as resolveVerticalBreakpoints, s as splitShorthand, y as valueHandlers, x as xyzMap } from './shared/preset-mini.ca595ab5.mjs';
2
- export { a as variantGetBracket, v as variantGetParameter, c as variantMatcher, b as variantParentMatcher } from './shared/preset-mini.bd4c0c0c.mjs';
2
+ export { a as variantGetBracket, v as variantGetParameter, c as variantMatcher, b as variantParentMatcher } from './shared/preset-mini.d79c2b40.mjs';
3
3
  import '@unocss/core';
package/dist/variants.cjs CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const _default = require('./shared/preset-mini.89cb41ec.cjs');
5
+ const _default = require('./shared/preset-mini.12bd206f.cjs');
6
6
  require('./shared/preset-mini.e54ce13d.cjs');
7
7
  require('@unocss/core');
8
- require('./shared/preset-mini.28b1d01c.cjs');
8
+ require('./shared/preset-mini.b5a73465.cjs');
9
9
 
10
10
 
11
11
 
@@ -1,6 +1,6 @@
1
1
  import { VariantObject, Variant } from '@unocss/core';
2
- import { T as Theme } from './types-fa74508f.js';
3
2
  import { PresetMiniOptions } from './index.js';
3
+ import { T as Theme } from './types-fa74508f.js';
4
4
  import './colors-b217808a.js';
5
5
  import './default-344896b2.js';
6
6
  import './utilities-d2f973f4.js';
@@ -8,7 +8,7 @@ import './utilities-d2f973f4.js';
8
8
  declare const variantAria: VariantObject;
9
9
 
10
10
  declare const calcMaxWidthBySize: (size: string) => string;
11
- declare const variantBreakpoints: Variant<Theme>;
11
+ declare const variantBreakpoints: () => VariantObject;
12
12
 
13
13
  declare const variantCombinators: Variant[];
14
14
 
@@ -16,7 +16,7 @@ declare const variantContainerQuery: VariantObject;
16
16
 
17
17
  declare const variantDataAttribute: VariantObject;
18
18
 
19
- declare const variantPrint: Variant;
19
+ declare const variantPrint: VariantObject;
20
20
  declare const variantCustomMedia: VariantObject;
21
21
 
22
22
  declare const variantSupports: VariantObject;
@@ -33,12 +33,12 @@ declare const variantInternalLayer: Variant;
33
33
  declare const variantScope: Variant;
34
34
  declare const variantVariables: Variant;
35
35
 
36
- declare const variantPseudoClassesAndElements: VariantObject;
37
- declare const variantPseudoClassFunctions: VariantObject;
36
+ declare const variantPseudoClassesAndElements: () => VariantObject;
37
+ declare const variantPseudoClassFunctions: () => VariantObject;
38
38
  declare const variantTaggedPseudoClasses: (options?: PresetMiniOptions) => VariantObject[];
39
39
  declare const partClasses: VariantObject;
40
40
 
41
- declare const variantImportant: Variant;
41
+ declare const variantImportant: () => VariantObject;
42
42
 
43
43
  declare const variantNegative: Variant;
44
44
 
package/dist/variants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as calcMaxWidthBySize, t as partClasses, a as variantAria, b as variantBreakpoints, j as variantColorsMediaOrClass, d as variantCombinators, e as variantContainerQuery, m as variantCssLayer, h as variantCustomMedia, f as variantDataAttribute, u as variantImportant, n as variantInternalLayer, k as variantLanguageDirections, w as variantNegative, g as variantPrint, r as variantPseudoClassFunctions, q as variantPseudoClassesAndElements, o as variantScope, l as variantSelector, i as variantSupports, s as variantTaggedPseudoClasses, p as variantVariables, v as variants } from './shared/preset-mini.0d510914.mjs';
1
+ export { c as calcMaxWidthBySize, t as partClasses, a as variantAria, b as variantBreakpoints, j as variantColorsMediaOrClass, d as variantCombinators, e as variantContainerQuery, m as variantCssLayer, h as variantCustomMedia, f as variantDataAttribute, u as variantImportant, n as variantInternalLayer, k as variantLanguageDirections, w as variantNegative, g as variantPrint, r as variantPseudoClassFunctions, q as variantPseudoClassesAndElements, o as variantScope, l as variantSelector, i as variantSupports, s as variantTaggedPseudoClasses, p as variantVariables, v as variants } from './shared/preset-mini.7ae92961.mjs';
2
2
  import './shared/preset-mini.ca595ab5.mjs';
3
3
  import '@unocss/core';
4
- import './shared/preset-mini.bd4c0c0c.mjs';
4
+ import './shared/preset-mini.d79c2b40.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.48.4",
3
+ "version": "0.49.0",
4
4
  "description": "The minimal preset for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -61,7 +61,7 @@
61
61
  "*.css"
62
62
  ],
63
63
  "dependencies": {
64
- "@unocss/core": "0.48.4"
64
+ "@unocss/core": "0.49.0"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",