@unocss/preset-mini 0.31.17 → 0.32.7

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.
@@ -540,7 +540,10 @@ const whitespaces = [
540
540
  [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v }), { autocomplete: "(whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)" }]
541
541
  ];
542
542
  const contents = [
543
- [/^content-\[(.+)\]$/, ([, v]) => ({ content: `"${v}"` })],
543
+ [/^content-(.+)$/, ([, v]) => {
544
+ const c = utilities.handler.bracket.cssvar(v);
545
+ return { content: c == null ? `"${v}"` : c };
546
+ }],
544
547
  ["content-empty", { content: '""' }],
545
548
  ["content-none", { content: '""' }]
546
549
  ];
@@ -755,7 +758,8 @@ const transformBase = {
755
758
  "--un-translate-y": 0,
756
759
  "--un-translate-z": 0,
757
760
  ...transformCpu,
758
- [core.CONTROL_SHORTCUT_NO_MERGE]: ""
761
+ [core.CONTROL_SHORTCUT_NO_MERGE]: "",
762
+ [utilities.CONTROL_MINI_NO_NEGATIVE]: ""
759
763
  };
760
764
  const transforms = [
761
765
  [/^(?:transform-)?origin-(.+)$/, ([, s]) => ({ "transform-origin": utilities.positionMap[s] ?? utilities.handler.bracket.cssvar(s) }), { autocomplete: [`transform-origin-(${Object.keys(utilities.positionMap).join("|")})`, `origin-(${Object.keys(utilities.positionMap).join("|")})`] }],
@@ -976,7 +980,6 @@ const rules = [
976
980
  overflows,
977
981
  outline,
978
982
  appearance,
979
- positions,
980
983
  orders,
981
984
  justifies,
982
985
  alignments,
@@ -1,4 +1,4 @@
1
- import { h as handler, c as colorResolver, d as directionMap, a as hasParseableColor, p as parseColor, b as colorToString, e as cornerMap, f as colorableShadows, i as insetMap, r as resolveVerticalBreakpoints, g as resolveBreakpoints, j as directionSize, k as positionMap, x as xyzMap } from './utilities.mjs';
1
+ import { h as handler, c as colorResolver, d as directionMap, a as hasParseableColor, p as parseColor, b as colorToString, e as cornerMap, f as colorableShadows, i as insetMap, r as resolveVerticalBreakpoints, g as resolveBreakpoints, j as directionSize, C as CONTROL_MINI_NO_NEGATIVE, k as positionMap, x as xyzMap } from './utilities.mjs';
2
2
  import { toArray, CONTROL_SHORTCUT_NO_MERGE } from '@unocss/core';
3
3
 
4
4
  const verticalAlignAlias = {
@@ -538,7 +538,10 @@ const whitespaces = [
538
538
  [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v }), { autocomplete: "(whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)" }]
539
539
  ];
540
540
  const contents = [
541
- [/^content-\[(.+)\]$/, ([, v]) => ({ content: `"${v}"` })],
541
+ [/^content-(.+)$/, ([, v]) => {
542
+ const c = handler.bracket.cssvar(v);
543
+ return { content: c == null ? `"${v}"` : c };
544
+ }],
542
545
  ["content-empty", { content: '""' }],
543
546
  ["content-none", { content: '""' }]
544
547
  ];
@@ -753,7 +756,8 @@ const transformBase = {
753
756
  "--un-translate-y": 0,
754
757
  "--un-translate-z": 0,
755
758
  ...transformCpu,
756
- [CONTROL_SHORTCUT_NO_MERGE]: ""
759
+ [CONTROL_SHORTCUT_NO_MERGE]: "",
760
+ [CONTROL_MINI_NO_NEGATIVE]: ""
757
761
  };
758
762
  const transforms = [
759
763
  [/^(?:transform-)?origin-(.+)$/, ([, s]) => ({ "transform-origin": positionMap[s] ?? handler.bracket.cssvar(s) }), { autocomplete: [`transform-origin-(${Object.keys(positionMap).join("|")})`, `origin-(${Object.keys(positionMap).join("|")})`] }],
@@ -974,7 +978,6 @@ const rules = [
974
978
  overflows,
975
979
  outline,
976
980
  appearance,
977
- positions,
978
981
  orders,
979
982
  justifies,
980
983
  alignments,
@@ -12,6 +12,7 @@ const calcMaxWidthBySize = (size) => {
12
12
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
13
13
  };
14
14
  const variantBreakpoints = {
15
+ name: "breakpoints",
15
16
  match(matcher, context) {
16
17
  const variantEntries = Object.entries(utilities.resolveBreakpoints(context) ?? {}).map(([point, size], idx) => [point, size, idx]);
17
18
  for (const [point, size, idx] of variantEntries) {
@@ -52,13 +53,16 @@ const variantBreakpoints = {
52
53
 
53
54
  const scopeMatcher = (strict, name, template) => {
54
55
  const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
55
- return (matcher) => {
56
- const match = matcher.match(re);
57
- if (match) {
58
- return {
59
- matcher: matcher.slice(match[0].length),
60
- selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
61
- };
56
+ return {
57
+ name: `combinator:${name}`,
58
+ match: (matcher) => {
59
+ const match = matcher.match(re);
60
+ if (match) {
61
+ return {
62
+ matcher: matcher.slice(match[0].length),
63
+ selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
64
+ };
65
+ }
62
66
  }
63
67
  };
64
68
  };
@@ -75,14 +79,17 @@ const variantCombinators = [
75
79
  ];
76
80
 
77
81
  const variantPrint = variants$1.variantParentMatcher("print", "@media print");
78
- const variantCustomMedia = (matcher, { theme }) => {
79
- const match = matcher.match(/^media-([_\d\w]+)[:-]/);
80
- if (match) {
81
- const media = theme.media?.[match[1]] ?? `(--${match[1]})`;
82
- return {
83
- matcher: matcher.slice(match[0].length),
84
- parent: `@media ${media}`
85
- };
82
+ const variantCustomMedia = {
83
+ name: "media",
84
+ match(matcher, { theme }) {
85
+ const match = matcher.match(/^media-([_\d\w]+)[:-]/);
86
+ if (match) {
87
+ const media = theme.media?.[match[1]] ?? `(--${match[1]})`;
88
+ return {
89
+ matcher: matcher.slice(match[0].length),
90
+ parent: `@media ${media}`
91
+ };
92
+ }
86
93
  }
87
94
  };
88
95
 
@@ -105,6 +112,7 @@ const variantLanguageDirections = [
105
112
  ];
106
113
 
107
114
  const variantSelector = {
115
+ name: "selector",
108
116
  match(matcher) {
109
117
  const match = matcher.match(/^selector-\[(.+?)\][:-]/);
110
118
  if (match) {
@@ -116,6 +124,7 @@ const variantSelector = {
116
124
  }
117
125
  };
118
126
  const variantLayer = {
127
+ name: "layer",
119
128
  match(matcher) {
120
129
  const match = matcher.match(/^layer-([_\d\w]+)[:-]/);
121
130
  if (match) {
@@ -127,6 +136,7 @@ const variantLayer = {
127
136
  }
128
137
  };
129
138
  const variantScope = {
139
+ name: "scope",
130
140
  match(matcher) {
131
141
  const match = matcher.match(/^scope-([_\d\w]+)[:-]/);
132
142
  if (match) {
@@ -138,6 +148,7 @@ const variantScope = {
138
148
  }
139
149
  };
140
150
  const variantImportant = {
151
+ name: "important",
141
152
  match(matcher) {
142
153
  const match = matcher.match(/^(important[:-]|!)/);
143
154
  if (match) {
@@ -155,25 +166,37 @@ const variantImportant = {
155
166
  },
156
167
  autocomplete: "(important)"
157
168
  };
169
+ const numberRE = /[0-9.]+(?:[a-z]+|%)?/;
158
170
  const variantNegative = {
171
+ name: "negative",
159
172
  match(matcher) {
160
- if (matcher.startsWith("-")) {
161
- return {
162
- matcher: matcher.slice(1),
163
- body: (body) => {
164
- body.forEach((v) => {
165
- if (v[0].startsWith("--un-scale") || v[1]?.toString() === "0")
166
- return;
167
- v[1] = v[1]?.toString().replace(/[0-9.]+(?:[a-z]+|%)?/, (i) => `-${i}`);
168
- });
173
+ if (!matcher.startsWith("-") || !matcher.match(/\d|-px|-full/))
174
+ return;
175
+ return {
176
+ matcher: matcher.slice(1),
177
+ body: (body) => {
178
+ if (body.find((v) => v[0] === utilities.CONTROL_MINI_NO_NEGATIVE))
179
+ return;
180
+ let changed = false;
181
+ body.forEach((v) => {
182
+ const value = v[1]?.toString();
183
+ if (!value || value === "0")
184
+ return;
185
+ if (numberRE.test(value)) {
186
+ v[1] = value.replace(numberRE, (i) => `-${i}`);
187
+ changed = true;
188
+ }
189
+ });
190
+ if (changed)
169
191
  return body;
170
- }
171
- };
172
- }
192
+ }
193
+ };
173
194
  }
174
195
  };
175
196
 
176
197
  const PseudoClasses = Object.fromEntries([
198
+ ["first-letter", "::first"],
199
+ ["first-line", "::first"],
177
200
  "any-link",
178
201
  "link",
179
202
  "visited",
@@ -210,31 +233,22 @@ const PseudoClasses = Object.fromEntries([
210
233
  "last-of-type",
211
234
  ["last", ":last-child"],
212
235
  "only-child",
213
- "only-of-type"
214
- ].map(core.toArray));
215
- const PseudoElements = Object.fromEntries([
216
- "placeholder",
217
- "before",
218
- "after",
219
- "first-letter",
220
- "first-line",
221
- "selection",
222
- "marker",
236
+ "only-of-type",
237
+ ["placeholder", "::placeholder"],
238
+ ["before", "::before"],
239
+ ["after", "::after"],
240
+ ["selection", "::selection"],
241
+ ["marker", "::marker"],
223
242
  ["file", "::file-selector-button"]
224
- ].map(core.toArray));
243
+ ].map((key) => typeof key === "string" ? [key, `:${key}`] : key));
225
244
  const PseudoClassFunctions = [
226
245
  "not",
227
246
  "is",
228
247
  "where",
229
248
  "has"
230
249
  ];
231
- const PseudoElementsStr = Object.keys(PseudoElements).join("|");
232
- const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
250
+ const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).join("|");
233
251
  const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
234
- const PartClassesRE = /(part-\[(.+)]:)(.+)/;
235
- const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
236
- const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
237
- const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
238
252
  const sortValue = (pseudo) => {
239
253
  if (pseudo === "active")
240
254
  return 1;
@@ -242,36 +256,29 @@ const sortValue = (pseudo) => {
242
256
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
243
257
  const re = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))[:-]`);
244
258
  const rawRe = new RegExp(`^${core.escapeRegExp(parent)}:`);
245
- return (input) => {
246
- const match = input.match(re);
247
- if (match) {
248
- let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
249
- if (match[2])
250
- pseudo = `:${match[2]}(${pseudo})`;
251
- return {
252
- matcher: input.slice(match[0].length),
253
- selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
254
- sort: sortValue(match[3])
255
- };
259
+ return {
260
+ name: `pseudo:${tag}`,
261
+ match(input) {
262
+ const match = input.match(re);
263
+ if (match) {
264
+ let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
265
+ if (match[2])
266
+ pseudo = `:${match[2]}(${pseudo})`;
267
+ return {
268
+ matcher: input.slice(match[0].length),
269
+ selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
270
+ sort: sortValue(match[3])
271
+ };
272
+ }
256
273
  }
257
274
  };
258
275
  };
259
- const variantPseudoElements = {
276
+ const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
277
+ const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
278
+ const variantPseudoClassesAndElements = {
279
+ name: "pseudo",
260
280
  match: (input) => {
261
- const match = input.match(PseudoElementsRE);
262
- if (match) {
263
- const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
264
- return {
265
- matcher: input.slice(match[0].length),
266
- selector: (s) => `${s}${pseudo}`
267
- };
268
- }
269
- },
270
- autocomplete: `(${PseudoElementsStr}):`
271
- };
272
- const variantPseudoClasses = {
273
- match: (input) => {
274
- const match = input.match(PseudoClassesRE);
281
+ const match = input.match(PseudoClassesAndElementsRE);
275
282
  if (match) {
276
283
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
277
284
  return {
@@ -282,8 +289,9 @@ const variantPseudoClasses = {
282
289
  }
283
290
  },
284
291
  multiPass: true,
285
- autocomplete: `(${PseudoClassesStr}):`
292
+ autocomplete: `(${PseudoClassesAndElementsStr}):`
286
293
  };
294
+ const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
287
295
  const variantPseudoClassFunctions = {
288
296
  match: (input) => {
289
297
  const match = input.match(PseudoClassFunctionsRE);
@@ -303,23 +311,24 @@ const variantTaggedPseudoClasses = (options = {}) => {
303
311
  const attributify = !!options?.attributifyPseudo;
304
312
  return [
305
313
  {
306
- match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
314
+ ...taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
307
315
  multiPass: true
308
316
  },
309
317
  {
310
- match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
318
+ ...taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
311
319
  multiPass: true
312
320
  },
313
321
  {
314
- match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
322
+ ...taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
315
323
  multiPass: true
316
324
  },
317
325
  {
318
- match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
326
+ ...taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
319
327
  multiPass: true
320
328
  }
321
329
  ];
322
330
  };
331
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
323
332
  const partClasses = {
324
333
  match: (input) => {
325
334
  const match = input.match(PartClassesRE);
@@ -343,10 +352,9 @@ const variants = (options) => [
343
352
  variantCustomMedia,
344
353
  variantBreakpoints,
345
354
  ...variantCombinators,
346
- variantPseudoClasses,
355
+ variantPseudoClassesAndElements,
347
356
  variantPseudoClassFunctions,
348
357
  ...variantTaggedPseudoClasses(options),
349
- variantPseudoElements,
350
358
  partClasses,
351
359
  ...variantColorsMediaOrClass(options),
352
360
  ...variantLanguageDirections,
@@ -364,8 +372,7 @@ exports.variantLayer = variantLayer;
364
372
  exports.variantNegative = variantNegative;
365
373
  exports.variantPrint = variantPrint;
366
374
  exports.variantPseudoClassFunctions = variantPseudoClassFunctions;
367
- exports.variantPseudoClasses = variantPseudoClasses;
368
- exports.variantPseudoElements = variantPseudoElements;
375
+ exports.variantPseudoClassesAndElements = variantPseudoClassesAndElements;
369
376
  exports.variantScope = variantScope;
370
377
  exports.variantSelector = variantSelector;
371
378
  exports.variantTaggedPseudoClasses = variantTaggedPseudoClasses;
@@ -1,6 +1,6 @@
1
- import { g as resolveBreakpoints } from './utilities.mjs';
1
+ import { g as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE } from './utilities.mjs';
2
2
  import { v as variantParentMatcher, a as variantMatcher } from './variants.mjs';
3
- import { toArray, escapeRegExp } from '@unocss/core';
3
+ import { escapeRegExp } from '@unocss/core';
4
4
 
5
5
  const regexCache = {};
6
6
  const calcMaxWidthBySize = (size) => {
@@ -10,6 +10,7 @@ const calcMaxWidthBySize = (size) => {
10
10
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
11
11
  };
12
12
  const variantBreakpoints = {
13
+ name: "breakpoints",
13
14
  match(matcher, context) {
14
15
  const variantEntries = Object.entries(resolveBreakpoints(context) ?? {}).map(([point, size], idx) => [point, size, idx]);
15
16
  for (const [point, size, idx] of variantEntries) {
@@ -50,13 +51,16 @@ const variantBreakpoints = {
50
51
 
51
52
  const scopeMatcher = (strict, name, template) => {
52
53
  const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
53
- return (matcher) => {
54
- const match = matcher.match(re);
55
- if (match) {
56
- return {
57
- matcher: matcher.slice(match[0].length),
58
- selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
59
- };
54
+ return {
55
+ name: `combinator:${name}`,
56
+ match: (matcher) => {
57
+ const match = matcher.match(re);
58
+ if (match) {
59
+ return {
60
+ matcher: matcher.slice(match[0].length),
61
+ selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
62
+ };
63
+ }
60
64
  }
61
65
  };
62
66
  };
@@ -73,14 +77,17 @@ const variantCombinators = [
73
77
  ];
74
78
 
75
79
  const variantPrint = variantParentMatcher("print", "@media print");
76
- const variantCustomMedia = (matcher, { theme }) => {
77
- const match = matcher.match(/^media-([_\d\w]+)[:-]/);
78
- if (match) {
79
- const media = theme.media?.[match[1]] ?? `(--${match[1]})`;
80
- return {
81
- matcher: matcher.slice(match[0].length),
82
- parent: `@media ${media}`
83
- };
80
+ const variantCustomMedia = {
81
+ name: "media",
82
+ match(matcher, { theme }) {
83
+ const match = matcher.match(/^media-([_\d\w]+)[:-]/);
84
+ if (match) {
85
+ const media = theme.media?.[match[1]] ?? `(--${match[1]})`;
86
+ return {
87
+ matcher: matcher.slice(match[0].length),
88
+ parent: `@media ${media}`
89
+ };
90
+ }
84
91
  }
85
92
  };
86
93
 
@@ -103,6 +110,7 @@ const variantLanguageDirections = [
103
110
  ];
104
111
 
105
112
  const variantSelector = {
113
+ name: "selector",
106
114
  match(matcher) {
107
115
  const match = matcher.match(/^selector-\[(.+?)\][:-]/);
108
116
  if (match) {
@@ -114,6 +122,7 @@ const variantSelector = {
114
122
  }
115
123
  };
116
124
  const variantLayer = {
125
+ name: "layer",
117
126
  match(matcher) {
118
127
  const match = matcher.match(/^layer-([_\d\w]+)[:-]/);
119
128
  if (match) {
@@ -125,6 +134,7 @@ const variantLayer = {
125
134
  }
126
135
  };
127
136
  const variantScope = {
137
+ name: "scope",
128
138
  match(matcher) {
129
139
  const match = matcher.match(/^scope-([_\d\w]+)[:-]/);
130
140
  if (match) {
@@ -136,6 +146,7 @@ const variantScope = {
136
146
  }
137
147
  };
138
148
  const variantImportant = {
149
+ name: "important",
139
150
  match(matcher) {
140
151
  const match = matcher.match(/^(important[:-]|!)/);
141
152
  if (match) {
@@ -153,25 +164,37 @@ const variantImportant = {
153
164
  },
154
165
  autocomplete: "(important)"
155
166
  };
167
+ const numberRE = /[0-9.]+(?:[a-z]+|%)?/;
156
168
  const variantNegative = {
169
+ name: "negative",
157
170
  match(matcher) {
158
- if (matcher.startsWith("-")) {
159
- return {
160
- matcher: matcher.slice(1),
161
- body: (body) => {
162
- body.forEach((v) => {
163
- if (v[0].startsWith("--un-scale") || v[1]?.toString() === "0")
164
- return;
165
- v[1] = v[1]?.toString().replace(/[0-9.]+(?:[a-z]+|%)?/, (i) => `-${i}`);
166
- });
171
+ if (!matcher.startsWith("-") || !matcher.match(/\d|-px|-full/))
172
+ return;
173
+ return {
174
+ matcher: matcher.slice(1),
175
+ body: (body) => {
176
+ if (body.find((v) => v[0] === CONTROL_MINI_NO_NEGATIVE))
177
+ return;
178
+ let changed = false;
179
+ body.forEach((v) => {
180
+ const value = v[1]?.toString();
181
+ if (!value || value === "0")
182
+ return;
183
+ if (numberRE.test(value)) {
184
+ v[1] = value.replace(numberRE, (i) => `-${i}`);
185
+ changed = true;
186
+ }
187
+ });
188
+ if (changed)
167
189
  return body;
168
- }
169
- };
170
- }
190
+ }
191
+ };
171
192
  }
172
193
  };
173
194
 
174
195
  const PseudoClasses = Object.fromEntries([
196
+ ["first-letter", "::first"],
197
+ ["first-line", "::first"],
175
198
  "any-link",
176
199
  "link",
177
200
  "visited",
@@ -208,31 +231,22 @@ const PseudoClasses = Object.fromEntries([
208
231
  "last-of-type",
209
232
  ["last", ":last-child"],
210
233
  "only-child",
211
- "only-of-type"
212
- ].map(toArray));
213
- const PseudoElements = Object.fromEntries([
214
- "placeholder",
215
- "before",
216
- "after",
217
- "first-letter",
218
- "first-line",
219
- "selection",
220
- "marker",
234
+ "only-of-type",
235
+ ["placeholder", "::placeholder"],
236
+ ["before", "::before"],
237
+ ["after", "::after"],
238
+ ["selection", "::selection"],
239
+ ["marker", "::marker"],
221
240
  ["file", "::file-selector-button"]
222
- ].map(toArray));
241
+ ].map((key) => typeof key === "string" ? [key, `:${key}`] : key));
223
242
  const PseudoClassFunctions = [
224
243
  "not",
225
244
  "is",
226
245
  "where",
227
246
  "has"
228
247
  ];
229
- const PseudoElementsStr = Object.keys(PseudoElements).join("|");
230
- const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
248
+ const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).join("|");
231
249
  const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
232
- const PartClassesRE = /(part-\[(.+)]:)(.+)/;
233
- const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
234
- const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
235
- const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
236
250
  const sortValue = (pseudo) => {
237
251
  if (pseudo === "active")
238
252
  return 1;
@@ -240,36 +254,29 @@ const sortValue = (pseudo) => {
240
254
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
241
255
  const re = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))[:-]`);
242
256
  const rawRe = new RegExp(`^${escapeRegExp(parent)}:`);
243
- return (input) => {
244
- const match = input.match(re);
245
- if (match) {
246
- let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
247
- if (match[2])
248
- pseudo = `:${match[2]}(${pseudo})`;
249
- return {
250
- matcher: input.slice(match[0].length),
251
- selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
252
- sort: sortValue(match[3])
253
- };
257
+ return {
258
+ name: `pseudo:${tag}`,
259
+ match(input) {
260
+ const match = input.match(re);
261
+ if (match) {
262
+ let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
263
+ if (match[2])
264
+ pseudo = `:${match[2]}(${pseudo})`;
265
+ return {
266
+ matcher: input.slice(match[0].length),
267
+ selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
268
+ sort: sortValue(match[3])
269
+ };
270
+ }
254
271
  }
255
272
  };
256
273
  };
257
- const variantPseudoElements = {
274
+ const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
275
+ const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
276
+ const variantPseudoClassesAndElements = {
277
+ name: "pseudo",
258
278
  match: (input) => {
259
- const match = input.match(PseudoElementsRE);
260
- if (match) {
261
- const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
262
- return {
263
- matcher: input.slice(match[0].length),
264
- selector: (s) => `${s}${pseudo}`
265
- };
266
- }
267
- },
268
- autocomplete: `(${PseudoElementsStr}):`
269
- };
270
- const variantPseudoClasses = {
271
- match: (input) => {
272
- const match = input.match(PseudoClassesRE);
279
+ const match = input.match(PseudoClassesAndElementsRE);
273
280
  if (match) {
274
281
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
275
282
  return {
@@ -280,8 +287,9 @@ const variantPseudoClasses = {
280
287
  }
281
288
  },
282
289
  multiPass: true,
283
- autocomplete: `(${PseudoClassesStr}):`
290
+ autocomplete: `(${PseudoClassesAndElementsStr}):`
284
291
  };
292
+ const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
285
293
  const variantPseudoClassFunctions = {
286
294
  match: (input) => {
287
295
  const match = input.match(PseudoClassFunctionsRE);
@@ -301,23 +309,24 @@ const variantTaggedPseudoClasses = (options = {}) => {
301
309
  const attributify = !!options?.attributifyPseudo;
302
310
  return [
303
311
  {
304
- match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
312
+ ...taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
305
313
  multiPass: true
306
314
  },
307
315
  {
308
- match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
316
+ ...taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
309
317
  multiPass: true
310
318
  },
311
319
  {
312
- match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
320
+ ...taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
313
321
  multiPass: true
314
322
  },
315
323
  {
316
- match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
324
+ ...taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
317
325
  multiPass: true
318
326
  }
319
327
  ];
320
328
  };
329
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
321
330
  const partClasses = {
322
331
  match: (input) => {
323
332
  const match = input.match(PartClassesRE);
@@ -341,14 +350,13 @@ const variants = (options) => [
341
350
  variantCustomMedia,
342
351
  variantBreakpoints,
343
352
  ...variantCombinators,
344
- variantPseudoClasses,
353
+ variantPseudoClassesAndElements,
345
354
  variantPseudoClassFunctions,
346
355
  ...variantTaggedPseudoClasses(options),
347
- variantPseudoElements,
348
356
  partClasses,
349
357
  ...variantColorsMediaOrClass(options),
350
358
  ...variantLanguageDirections,
351
359
  variantScope
352
360
  ];
353
361
 
354
- export { variantBreakpoints as a, variantCombinators as b, variantPrint as c, variantCustomMedia as d, variantColorsMediaOrClass as e, variantLanguageDirections as f, variantSelector as g, variantLayer as h, variantScope as i, variantImportant as j, variantNegative as k, variantPseudoElements as l, variantPseudoClasses as m, variantPseudoClassFunctions as n, variantTaggedPseudoClasses as o, partClasses as p, variants as v };
362
+ export { variantBreakpoints as a, variantCombinators as b, variantPrint as c, variantCustomMedia as d, variantColorsMediaOrClass as e, variantLanguageDirections as f, variantSelector as g, variantLayer as h, variantScope as i, variantImportant as j, variantNegative as k, variantPseudoClassesAndElements as l, variantPseudoClassFunctions as m, variantTaggedPseudoClasses as n, partClasses as p, variants as v };
@@ -501,6 +501,7 @@ const valueHandlers = {
501
501
  const handler = core.createValueHandler(valueHandlers);
502
502
  const h = handler;
503
503
 
504
+ const CONTROL_MINI_NO_NEGATIVE = "$$mini-no-negative";
504
505
  const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
505
506
  const v = theme.spacing?.[size || "DEFAULT"] ?? handler.bracket.cssvar.auto.fraction.rem(size);
506
507
  if (v != null)
@@ -614,6 +615,7 @@ const resolveVerticalBreakpoints = ({ theme, generator }) => {
614
615
  return verticalBreakpoints;
615
616
  };
616
617
 
618
+ exports.CONTROL_MINI_NO_NEGATIVE = CONTROL_MINI_NO_NEGATIVE;
617
619
  exports.colorResolver = colorResolver;
618
620
  exports.colorToString = colorToString;
619
621
  exports.colorableShadows = colorableShadows;
@@ -499,6 +499,7 @@ const valueHandlers = {
499
499
  const handler = createValueHandler(valueHandlers);
500
500
  const h = handler;
501
501
 
502
+ const CONTROL_MINI_NO_NEGATIVE = "$$mini-no-negative";
502
503
  const directionSize = (propertyPrefix) => ([_, direction, size], { theme }) => {
503
504
  const v = theme.spacing?.[size || "DEFAULT"] ?? handler.bracket.cssvar.auto.fraction.rem(size);
504
505
  if (v != null)
@@ -612,4 +613,4 @@ const resolveVerticalBreakpoints = ({ theme, generator }) => {
612
613
  return verticalBreakpoints;
613
614
  };
614
615
 
615
- export { hasParseableColor as a, colorToString as b, colorResolver as c, directionMap as d, cornerMap as e, colorableShadows as f, resolveBreakpoints as g, handler as h, insetMap as i, directionSize as j, positionMap as k, hex2rgba as l, parseCssColor as m, getComponents as n, h as o, parseColor as p, resolveVerticalBreakpoints as r, valueHandlers as v, xyzMap as x };
616
+ export { CONTROL_MINI_NO_NEGATIVE as C, hasParseableColor as a, colorToString as b, colorResolver as c, directionMap as d, cornerMap as e, colorableShadows as f, resolveBreakpoints as g, handler as h, insetMap as i, directionSize as j, positionMap as k, hex2rgba as l, parseCssColor as m, getComponents as n, h as o, parseColor as p, resolveVerticalBreakpoints as r, valueHandlers as v, xyzMap as x };
@@ -5,6 +5,7 @@ const core = require('@unocss/core');
5
5
  const variantMatcher = (name, selector) => {
6
6
  const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
7
7
  return {
8
+ name,
8
9
  match: (input) => {
9
10
  const match = input.match(re);
10
11
  if (match) {
@@ -20,6 +21,7 @@ const variantMatcher = (name, selector) => {
20
21
  const variantParentMatcher = (name, parent) => {
21
22
  const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
22
23
  return {
24
+ name,
23
25
  match: (input) => {
24
26
  const match = input.match(re);
25
27
  if (match) {
@@ -3,6 +3,7 @@ import { escapeRegExp } from '@unocss/core';
3
3
  const variantMatcher = (name, selector) => {
4
4
  const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
5
5
  return {
6
+ name,
6
7
  match: (input) => {
7
8
  const match = input.match(re);
8
9
  if (match) {
@@ -18,6 +19,7 @@ const variantMatcher = (name, selector) => {
18
19
  const variantParentMatcher = (name, parent) => {
19
20
  const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
20
21
  return {
22
+ name,
21
23
  match: (input) => {
22
24
  const match = input.match(re);
23
25
  if (match) {
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { T as Theme } from './types-f7b2c653.js';
3
3
  export { T as Theme, a as ThemeAnimation } from './types-f7b2c653.js';
4
4
  export { t as theme } from './default-e6d1b2e8.js';
5
5
  export { c as colors } from './colors-ce2fecb8.js';
6
- export { p as parseColor } from './utilities-a7351781.js';
6
+ export { p as parseColor } from './utilities-e7a7f845.js';
7
7
 
8
8
  interface PresetMiniOptions extends PresetOptions {
9
9
  /**
@@ -1,6 +1,7 @@
1
1
  import { RuleContext, CSSEntries, ParsedColorValue, CSSObject, VariantContext } from '@unocss/core';
2
2
  import { T as Theme } from './types-f7b2c653.js';
3
3
 
4
+ declare const CONTROL_MINI_NO_NEGATIVE = "$$mini-no-negative";
4
5
  /**
5
6
  * Provide {@link DynamicMatcher} function returning spacing definition. See spacing rules.
6
7
  *
@@ -55,4 +56,4 @@ declare const hasParseableColor: (color: string | undefined, theme: Theme) => bo
55
56
  declare const resolveBreakpoints: ({ theme, generator }: Readonly<VariantContext<Theme>>) => Record<string, string> | undefined;
56
57
  declare const resolveVerticalBreakpoints: ({ theme, generator }: Readonly<VariantContext<Theme>>) => Record<string, string> | undefined;
57
58
 
58
- export { colorableShadows as a, resolveVerticalBreakpoints as b, colorResolver as c, directionSize as d, hasParseableColor as h, parseColor as p, resolveBreakpoints as r };
59
+ export { CONTROL_MINI_NO_NEGATIVE as C, colorableShadows as a, resolveVerticalBreakpoints as b, colorResolver as c, directionSize as d, hasParseableColor as h, parseColor as p, resolveBreakpoints as r };
package/dist/utils.cjs CHANGED
@@ -8,6 +8,7 @@ require('@unocss/core');
8
8
 
9
9
 
10
10
 
11
+ exports.CONTROL_MINI_NO_NEGATIVE = utilities.CONTROL_MINI_NO_NEGATIVE;
11
12
  exports.colorResolver = utilities.colorResolver;
12
13
  exports.colorToString = utilities.colorToString;
13
14
  exports.colorableShadows = utilities.colorableShadows;
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { RGBAColorValue, CSSColorValue, VariantObject } from '@unocss/core';
3
- export { c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints } from './utilities-a7351781.js';
3
+ export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, p as parseColor, r as resolveBreakpoints, b as resolveVerticalBreakpoints } from './utilities-e7a7f845.js';
4
4
  import './types-f7b2c653.js';
5
5
 
6
6
  declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
package/dist/utils.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { c as colorResolver, b as colorToString, f as colorableShadows, e as cornerMap, d as directionMap, j as directionSize, n as getComponents, o as h, h as handler, a as hasParseableColor, l as hex2rgba, i as insetMap, p as parseColor, m as parseCssColor, k as positionMap, g as resolveBreakpoints, r as resolveVerticalBreakpoints, v as valueHandlers, x as xyzMap } from './chunks/utilities.mjs';
1
+ export { C as CONTROL_MINI_NO_NEGATIVE, c as colorResolver, b as colorToString, f as colorableShadows, e as cornerMap, d as directionMap, j as directionSize, n as getComponents, o as h, h as handler, a as hasParseableColor, l as hex2rgba, i as insetMap, p as parseColor, m as parseCssColor, k as positionMap, g as resolveBreakpoints, r as resolveVerticalBreakpoints, v as valueHandlers, x as xyzMap } from './chunks/utilities.mjs';
2
2
  export { a as variantMatcher, v as variantParentMatcher } from './chunks/variants.mjs';
3
3
  import '@unocss/core';
package/dist/variants.cjs CHANGED
@@ -20,8 +20,7 @@ exports.variantLayer = _default.variantLayer;
20
20
  exports.variantNegative = _default.variantNegative;
21
21
  exports.variantPrint = _default.variantPrint;
22
22
  exports.variantPseudoClassFunctions = _default.variantPseudoClassFunctions;
23
- exports.variantPseudoClasses = _default.variantPseudoClasses;
24
- exports.variantPseudoElements = _default.variantPseudoElements;
23
+ exports.variantPseudoClassesAndElements = _default.variantPseudoClassesAndElements;
25
24
  exports.variantScope = _default.variantScope;
26
25
  exports.variantSelector = _default.variantSelector;
27
26
  exports.variantTaggedPseudoClasses = _default.variantTaggedPseudoClasses;
@@ -1,16 +1,16 @@
1
- import { Variant, VariantFunction, VariantObject } from '@unocss/core';
1
+ import { Variant, VariantObject } from '@unocss/core';
2
2
  import { T as Theme } from './types-f7b2c653.js';
3
3
  import { PresetMiniOptions } from './index.js';
4
4
  import './default-e6d1b2e8.js';
5
5
  import './colors-ce2fecb8.js';
6
- import './utilities-a7351781.js';
6
+ import './utilities-e7a7f845.js';
7
7
 
8
8
  declare const variantBreakpoints: Variant<Theme>;
9
9
 
10
10
  declare const variantCombinators: Variant[];
11
11
 
12
12
  declare const variantPrint: Variant;
13
- declare const variantCustomMedia: VariantFunction;
13
+ declare const variantCustomMedia: VariantObject;
14
14
 
15
15
  declare const variantColorsMediaOrClass: (options?: PresetMiniOptions) => Variant[];
16
16
 
@@ -24,10 +24,9 @@ declare const variantScope: Variant;
24
24
  declare const variantImportant: Variant;
25
25
  declare const variantNegative: Variant;
26
26
 
27
- declare const variantPseudoElements: VariantObject;
28
- declare const variantPseudoClasses: VariantObject;
27
+ declare const variantPseudoClassesAndElements: VariantObject;
29
28
  declare const variantPseudoClassFunctions: VariantObject;
30
29
  declare const variantTaggedPseudoClasses: (options?: PresetMiniOptions) => VariantObject[];
31
30
  declare const partClasses: VariantObject;
32
31
 
33
- export { partClasses, variantBreakpoints, variantColorsMediaOrClass, variantCombinators, variantCustomMedia, variantImportant, variantLanguageDirections, variantLayer, variantNegative, variantPrint, variantPseudoClassFunctions, variantPseudoClasses, variantPseudoElements, variantScope, variantSelector, variantTaggedPseudoClasses, variants };
32
+ export { partClasses, variantBreakpoints, variantColorsMediaOrClass, variantCombinators, variantCustomMedia, variantImportant, variantLanguageDirections, variantLayer, variantNegative, variantPrint, variantPseudoClassFunctions, variantPseudoClassesAndElements, variantScope, variantSelector, variantTaggedPseudoClasses, variants };
package/dist/variants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { p as partClasses, a as variantBreakpoints, e as variantColorsMediaOrClass, b as variantCombinators, d as variantCustomMedia, j as variantImportant, f as variantLanguageDirections, h as variantLayer, k as variantNegative, c as variantPrint, n as variantPseudoClassFunctions, m as variantPseudoClasses, l as variantPseudoElements, i as variantScope, g as variantSelector, o as variantTaggedPseudoClasses, v as variants } from './chunks/default3.mjs';
1
+ export { p as partClasses, a as variantBreakpoints, e as variantColorsMediaOrClass, b as variantCombinators, d as variantCustomMedia, j as variantImportant, f as variantLanguageDirections, h as variantLayer, k as variantNegative, c as variantPrint, m as variantPseudoClassFunctions, l as variantPseudoClassesAndElements, i as variantScope, g as variantSelector, n as variantTaggedPseudoClasses, v as variants } from './chunks/default3.mjs';
2
2
  import './chunks/utilities.mjs';
3
3
  import '@unocss/core';
4
4
  import './chunks/variants.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.31.17",
3
+ "version": "0.32.7",
4
4
  "description": "The minimal preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -61,7 +61,7 @@
61
61
  ],
62
62
  "sideEffects": false,
63
63
  "dependencies": {
64
- "@unocss/core": "0.31.17"
64
+ "@unocss/core": "0.32.7"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",