@unocss/preset-mini 0.32.0 → 0.32.8

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
3
+ Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -20,4 +20,4 @@ Unocss({
20
20
 
21
21
  ## License
22
22
 
23
- MIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)
23
+ MIT License &copy; 2021-PRESENT [Anthony Fu](https://github.com/antfu)
@@ -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) {
@@ -157,16 +168,19 @@ const variantImportant = {
157
168
  };
158
169
  const numberRE = /[0-9.]+(?:[a-z]+|%)?/;
159
170
  const variantNegative = {
171
+ name: "negative",
160
172
  match(matcher) {
161
173
  if (!matcher.startsWith("-") || !matcher.match(/\d|-px|-full/))
162
174
  return;
163
175
  return {
164
176
  matcher: matcher.slice(1),
165
177
  body: (body) => {
178
+ if (body.find((v) => v[0] === utilities.CONTROL_MINI_NO_NEGATIVE))
179
+ return;
166
180
  let changed = false;
167
181
  body.forEach((v) => {
168
182
  const value = v[1]?.toString();
169
- if (!value || v[0].startsWith("--un-scale") || value === "0")
183
+ if (!value || value === "0")
170
184
  return;
171
185
  if (numberRE.test(value)) {
172
186
  v[1] = value.replace(numberRE, (i) => `-${i}`);
@@ -181,6 +195,8 @@ const variantNegative = {
181
195
  };
182
196
 
183
197
  const PseudoClasses = Object.fromEntries([
198
+ ["first-letter", "::first"],
199
+ ["first-line", "::first"],
184
200
  "any-link",
185
201
  "link",
186
202
  "visited",
@@ -217,31 +233,22 @@ const PseudoClasses = Object.fromEntries([
217
233
  "last-of-type",
218
234
  ["last", ":last-child"],
219
235
  "only-child",
220
- "only-of-type"
221
- ].map(core.toArray));
222
- const PseudoElements = Object.fromEntries([
223
- "placeholder",
224
- "before",
225
- "after",
226
- "first-letter",
227
- "first-line",
228
- "selection",
229
- "marker",
236
+ "only-of-type",
237
+ ["placeholder", "::placeholder"],
238
+ ["before", "::before"],
239
+ ["after", "::after"],
240
+ ["selection", "::selection"],
241
+ ["marker", "::marker"],
230
242
  ["file", "::file-selector-button"]
231
- ].map(core.toArray));
243
+ ].map((key) => typeof key === "string" ? [key, `:${key}`] : key));
232
244
  const PseudoClassFunctions = [
233
245
  "not",
234
246
  "is",
235
247
  "where",
236
248
  "has"
237
249
  ];
238
- const PseudoElementsStr = Object.keys(PseudoElements).join("|");
239
- const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
250
+ const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).join("|");
240
251
  const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
241
- const PartClassesRE = /(part-\[(.+)]:)(.+)/;
242
- const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
243
- const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
244
- const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
245
252
  const sortValue = (pseudo) => {
246
253
  if (pseudo === "active")
247
254
  return 1;
@@ -249,36 +256,29 @@ const sortValue = (pseudo) => {
249
256
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
250
257
  const re = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))[:-]`);
251
258
  const rawRe = new RegExp(`^${core.escapeRegExp(parent)}:`);
252
- return (input) => {
253
- const match = input.match(re);
254
- if (match) {
255
- let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
256
- if (match[2])
257
- pseudo = `:${match[2]}(${pseudo})`;
258
- return {
259
- matcher: input.slice(match[0].length),
260
- selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
261
- sort: sortValue(match[3])
262
- };
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
+ }
263
273
  }
264
274
  };
265
275
  };
266
- const variantPseudoElements = {
267
- match: (input) => {
268
- const match = input.match(PseudoElementsRE);
269
- if (match) {
270
- const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
271
- return {
272
- matcher: input.slice(match[0].length),
273
- selector: (s) => `${s}${pseudo}`
274
- };
275
- }
276
- },
277
- autocomplete: `(${PseudoElementsStr}):`
278
- };
279
- const variantPseudoClasses = {
276
+ const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
277
+ const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
278
+ const variantPseudoClassesAndElements = {
279
+ name: "pseudo",
280
280
  match: (input) => {
281
- const match = input.match(PseudoClassesRE);
281
+ const match = input.match(PseudoClassesAndElementsRE);
282
282
  if (match) {
283
283
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
284
284
  return {
@@ -289,8 +289,9 @@ const variantPseudoClasses = {
289
289
  }
290
290
  },
291
291
  multiPass: true,
292
- autocomplete: `(${PseudoClassesStr}):`
292
+ autocomplete: `(${PseudoClassesAndElementsStr}):`
293
293
  };
294
+ const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
294
295
  const variantPseudoClassFunctions = {
295
296
  match: (input) => {
296
297
  const match = input.match(PseudoClassFunctionsRE);
@@ -310,23 +311,24 @@ const variantTaggedPseudoClasses = (options = {}) => {
310
311
  const attributify = !!options?.attributifyPseudo;
311
312
  return [
312
313
  {
313
- match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
314
+ ...taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
314
315
  multiPass: true
315
316
  },
316
317
  {
317
- match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
318
+ ...taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
318
319
  multiPass: true
319
320
  },
320
321
  {
321
- match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
322
+ ...taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
322
323
  multiPass: true
323
324
  },
324
325
  {
325
- match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
326
+ ...taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
326
327
  multiPass: true
327
328
  }
328
329
  ];
329
330
  };
331
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
330
332
  const partClasses = {
331
333
  match: (input) => {
332
334
  const match = input.match(PartClassesRE);
@@ -350,10 +352,9 @@ const variants = (options) => [
350
352
  variantCustomMedia,
351
353
  variantBreakpoints,
352
354
  ...variantCombinators,
353
- variantPseudoClasses,
355
+ variantPseudoClassesAndElements,
354
356
  variantPseudoClassFunctions,
355
357
  ...variantTaggedPseudoClasses(options),
356
- variantPseudoElements,
357
358
  partClasses,
358
359
  ...variantColorsMediaOrClass(options),
359
360
  ...variantLanguageDirections,
@@ -371,8 +372,7 @@ exports.variantLayer = variantLayer;
371
372
  exports.variantNegative = variantNegative;
372
373
  exports.variantPrint = variantPrint;
373
374
  exports.variantPseudoClassFunctions = variantPseudoClassFunctions;
374
- exports.variantPseudoClasses = variantPseudoClasses;
375
- exports.variantPseudoElements = variantPseudoElements;
375
+ exports.variantPseudoClassesAndElements = variantPseudoClassesAndElements;
376
376
  exports.variantScope = variantScope;
377
377
  exports.variantSelector = variantSelector;
378
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) {
@@ -155,16 +166,19 @@ const variantImportant = {
155
166
  };
156
167
  const numberRE = /[0-9.]+(?:[a-z]+|%)?/;
157
168
  const variantNegative = {
169
+ name: "negative",
158
170
  match(matcher) {
159
171
  if (!matcher.startsWith("-") || !matcher.match(/\d|-px|-full/))
160
172
  return;
161
173
  return {
162
174
  matcher: matcher.slice(1),
163
175
  body: (body) => {
176
+ if (body.find((v) => v[0] === CONTROL_MINI_NO_NEGATIVE))
177
+ return;
164
178
  let changed = false;
165
179
  body.forEach((v) => {
166
180
  const value = v[1]?.toString();
167
- if (!value || v[0].startsWith("--un-scale") || value === "0")
181
+ if (!value || value === "0")
168
182
  return;
169
183
  if (numberRE.test(value)) {
170
184
  v[1] = value.replace(numberRE, (i) => `-${i}`);
@@ -179,6 +193,8 @@ const variantNegative = {
179
193
  };
180
194
 
181
195
  const PseudoClasses = Object.fromEntries([
196
+ ["first-letter", "::first"],
197
+ ["first-line", "::first"],
182
198
  "any-link",
183
199
  "link",
184
200
  "visited",
@@ -215,31 +231,22 @@ const PseudoClasses = Object.fromEntries([
215
231
  "last-of-type",
216
232
  ["last", ":last-child"],
217
233
  "only-child",
218
- "only-of-type"
219
- ].map(toArray));
220
- const PseudoElements = Object.fromEntries([
221
- "placeholder",
222
- "before",
223
- "after",
224
- "first-letter",
225
- "first-line",
226
- "selection",
227
- "marker",
234
+ "only-of-type",
235
+ ["placeholder", "::placeholder"],
236
+ ["before", "::before"],
237
+ ["after", "::after"],
238
+ ["selection", "::selection"],
239
+ ["marker", "::marker"],
228
240
  ["file", "::file-selector-button"]
229
- ].map(toArray));
241
+ ].map((key) => typeof key === "string" ? [key, `:${key}`] : key));
230
242
  const PseudoClassFunctions = [
231
243
  "not",
232
244
  "is",
233
245
  "where",
234
246
  "has"
235
247
  ];
236
- const PseudoElementsStr = Object.keys(PseudoElements).join("|");
237
- const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
248
+ const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).join("|");
238
249
  const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
239
- const PartClassesRE = /(part-\[(.+)]:)(.+)/;
240
- const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
241
- const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
242
- const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
243
250
  const sortValue = (pseudo) => {
244
251
  if (pseudo === "active")
245
252
  return 1;
@@ -247,36 +254,29 @@ const sortValue = (pseudo) => {
247
254
  const taggedPseudoClassMatcher = (tag, parent, combinator) => {
248
255
  const re = new RegExp(`^${tag}-((?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))[:-]`);
249
256
  const rawRe = new RegExp(`^${escapeRegExp(parent)}:`);
250
- return (input) => {
251
- const match = input.match(re);
252
- if (match) {
253
- let pseudo = PseudoClasses[match[3]] || `:${match[3]}`;
254
- if (match[2])
255
- pseudo = `:${match[2]}(${pseudo})`;
256
- return {
257
- matcher: input.slice(match[0].length),
258
- selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`,
259
- sort: sortValue(match[3])
260
- };
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
+ }
261
271
  }
262
272
  };
263
273
  };
264
- const variantPseudoElements = {
265
- match: (input) => {
266
- const match = input.match(PseudoElementsRE);
267
- if (match) {
268
- const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
269
- return {
270
- matcher: input.slice(match[0].length),
271
- selector: (s) => `${s}${pseudo}`
272
- };
273
- }
274
- },
275
- autocomplete: `(${PseudoElementsStr}):`
276
- };
277
- const variantPseudoClasses = {
274
+ const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
275
+ const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
276
+ const variantPseudoClassesAndElements = {
277
+ name: "pseudo",
278
278
  match: (input) => {
279
- const match = input.match(PseudoClassesRE);
279
+ const match = input.match(PseudoClassesAndElementsRE);
280
280
  if (match) {
281
281
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
282
282
  return {
@@ -287,8 +287,9 @@ const variantPseudoClasses = {
287
287
  }
288
288
  },
289
289
  multiPass: true,
290
- autocomplete: `(${PseudoClassesStr}):`
290
+ autocomplete: `(${PseudoClassesAndElementsStr}):`
291
291
  };
292
+ const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
292
293
  const variantPseudoClassFunctions = {
293
294
  match: (input) => {
294
295
  const match = input.match(PseudoClassFunctionsRE);
@@ -308,23 +309,24 @@ const variantTaggedPseudoClasses = (options = {}) => {
308
309
  const attributify = !!options?.attributifyPseudo;
309
310
  return [
310
311
  {
311
- match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
312
+ ...taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
312
313
  multiPass: true
313
314
  },
314
315
  {
315
- match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
316
+ ...taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
316
317
  multiPass: true
317
318
  },
318
319
  {
319
- match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
320
+ ...taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
320
321
  multiPass: true
321
322
  },
322
323
  {
323
- match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
324
+ ...taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
324
325
  multiPass: true
325
326
  }
326
327
  ];
327
328
  };
329
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
328
330
  const partClasses = {
329
331
  match: (input) => {
330
332
  const match = input.match(PartClassesRE);
@@ -348,14 +350,13 @@ const variants = (options) => [
348
350
  variantCustomMedia,
349
351
  variantBreakpoints,
350
352
  ...variantCombinators,
351
- variantPseudoClasses,
353
+ variantPseudoClassesAndElements,
352
354
  variantPseudoClassFunctions,
353
355
  ...variantTaggedPseudoClasses(options),
354
- variantPseudoElements,
355
356
  partClasses,
356
357
  ...variantColorsMediaOrClass(options),
357
358
  ...variantLanguageDirections,
358
359
  variantScope
359
360
  ];
360
361
 
361
- 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.32.0",
3
+ "version": "0.32.8",
4
4
  "description": "The minimal preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -61,11 +61,10 @@
61
61
  ],
62
62
  "sideEffects": false,
63
63
  "dependencies": {
64
- "@unocss/core": "0.32.0"
64
+ "@unocss/core": "0.32.8"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",
68
68
  "stub": "unbuild --stub"
69
- },
70
- "readme": "# @unocss/preset-mini\n\nThe minimal preset for [UnoCSS](https://github.com/unocss/unocss).\n\n## Installation\n\n```bash\nnpm i -D @unocss/preset-mini\n```\n\n```ts\nimport presetMini from '@unocss/preset-mini'\n\nUnocss({\n presets: [\n presetMini(),\n ],\n})\n```\n\n## License\n\nMIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)\n"
69
+ }
71
70
  }