@unocss/preset-mini 0.31.16 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  ];
@@ -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
  ];
@@ -155,25 +155,34 @@ const variantImportant = {
155
155
  },
156
156
  autocomplete: "(important)"
157
157
  };
158
+ const numberRE = /[0-9.]+(?:[a-z]+|%)?/;
158
159
  const variantNegative = {
159
160
  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
- });
161
+ if (!matcher.startsWith("-") || !matcher.match(/\d|-px|-full/))
162
+ return;
163
+ return {
164
+ matcher: matcher.slice(1),
165
+ body: (body) => {
166
+ let changed = false;
167
+ body.forEach((v) => {
168
+ const value = v[1]?.toString();
169
+ if (!value || v[0].startsWith("--un-scale") || value === "0")
170
+ return;
171
+ if (numberRE.test(value)) {
172
+ v[1] = value.replace(numberRE, (i) => `-${i}`);
173
+ changed = true;
174
+ }
175
+ });
176
+ if (changed)
169
177
  return body;
170
- }
171
- };
172
- }
178
+ }
179
+ };
173
180
  }
174
181
  };
175
182
 
176
183
  const PseudoClasses = Object.fromEntries([
184
+ ["first-letter", "::first"],
185
+ ["first-line", "::first"],
177
186
  "any-link",
178
187
  "link",
179
188
  "visited",
@@ -210,31 +219,22 @@ const PseudoClasses = Object.fromEntries([
210
219
  "last-of-type",
211
220
  ["last", ":last-child"],
212
221
  "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",
222
+ "only-of-type",
223
+ ["placeholder", "::placeholder"],
224
+ ["before", "::before"],
225
+ ["after", "::after"],
226
+ ["selection", "::selection"],
227
+ ["marker", "::marker"],
223
228
  ["file", "::file-selector-button"]
224
- ].map(core.toArray));
229
+ ].map((key) => typeof key === "string" ? [key, `:${key}`] : key));
225
230
  const PseudoClassFunctions = [
226
231
  "not",
227
232
  "is",
228
233
  "where",
229
234
  "has"
230
235
  ];
231
- const PseudoElementsStr = Object.keys(PseudoElements).join("|");
232
- const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
236
+ const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).join("|");
233
237
  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
238
  const sortValue = (pseudo) => {
239
239
  if (pseudo === "active")
240
240
  return 1;
@@ -256,22 +256,11 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
256
256
  }
257
257
  };
258
258
  };
259
- const variantPseudoElements = {
259
+ const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
260
+ const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
261
+ const variantPseudoClassesAndElements = {
260
262
  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);
263
+ const match = input.match(PseudoClassesAndElementsRE);
275
264
  if (match) {
276
265
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
277
266
  return {
@@ -282,8 +271,9 @@ const variantPseudoClasses = {
282
271
  }
283
272
  },
284
273
  multiPass: true,
285
- autocomplete: `(${PseudoClassesStr}):`
274
+ autocomplete: `(${PseudoClassesAndElementsStr}):`
286
275
  };
276
+ const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
287
277
  const variantPseudoClassFunctions = {
288
278
  match: (input) => {
289
279
  const match = input.match(PseudoClassFunctionsRE);
@@ -320,6 +310,7 @@ const variantTaggedPseudoClasses = (options = {}) => {
320
310
  }
321
311
  ];
322
312
  };
313
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
323
314
  const partClasses = {
324
315
  match: (input) => {
325
316
  const match = input.match(PartClassesRE);
@@ -343,10 +334,9 @@ const variants = (options) => [
343
334
  variantCustomMedia,
344
335
  variantBreakpoints,
345
336
  ...variantCombinators,
346
- variantPseudoClasses,
337
+ variantPseudoClassesAndElements,
347
338
  variantPseudoClassFunctions,
348
339
  ...variantTaggedPseudoClasses(options),
349
- variantPseudoElements,
350
340
  partClasses,
351
341
  ...variantColorsMediaOrClass(options),
352
342
  ...variantLanguageDirections,
@@ -364,8 +354,7 @@ exports.variantLayer = variantLayer;
364
354
  exports.variantNegative = variantNegative;
365
355
  exports.variantPrint = variantPrint;
366
356
  exports.variantPseudoClassFunctions = variantPseudoClassFunctions;
367
- exports.variantPseudoClasses = variantPseudoClasses;
368
- exports.variantPseudoElements = variantPseudoElements;
357
+ exports.variantPseudoClassesAndElements = variantPseudoClassesAndElements;
369
358
  exports.variantScope = variantScope;
370
359
  exports.variantSelector = variantSelector;
371
360
  exports.variantTaggedPseudoClasses = variantTaggedPseudoClasses;
@@ -1,6 +1,6 @@
1
1
  import { g as resolveBreakpoints } 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) => {
@@ -153,25 +153,34 @@ const variantImportant = {
153
153
  },
154
154
  autocomplete: "(important)"
155
155
  };
156
+ const numberRE = /[0-9.]+(?:[a-z]+|%)?/;
156
157
  const variantNegative = {
157
158
  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
- });
159
+ if (!matcher.startsWith("-") || !matcher.match(/\d|-px|-full/))
160
+ return;
161
+ return {
162
+ matcher: matcher.slice(1),
163
+ body: (body) => {
164
+ let changed = false;
165
+ body.forEach((v) => {
166
+ const value = v[1]?.toString();
167
+ if (!value || v[0].startsWith("--un-scale") || value === "0")
168
+ return;
169
+ if (numberRE.test(value)) {
170
+ v[1] = value.replace(numberRE, (i) => `-${i}`);
171
+ changed = true;
172
+ }
173
+ });
174
+ if (changed)
167
175
  return body;
168
- }
169
- };
170
- }
176
+ }
177
+ };
171
178
  }
172
179
  };
173
180
 
174
181
  const PseudoClasses = Object.fromEntries([
182
+ ["first-letter", "::first"],
183
+ ["first-line", "::first"],
175
184
  "any-link",
176
185
  "link",
177
186
  "visited",
@@ -208,31 +217,22 @@ const PseudoClasses = Object.fromEntries([
208
217
  "last-of-type",
209
218
  ["last", ":last-child"],
210
219
  "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",
220
+ "only-of-type",
221
+ ["placeholder", "::placeholder"],
222
+ ["before", "::before"],
223
+ ["after", "::after"],
224
+ ["selection", "::selection"],
225
+ ["marker", "::marker"],
221
226
  ["file", "::file-selector-button"]
222
- ].map(toArray));
227
+ ].map((key) => typeof key === "string" ? [key, `:${key}`] : key));
223
228
  const PseudoClassFunctions = [
224
229
  "not",
225
230
  "is",
226
231
  "where",
227
232
  "has"
228
233
  ];
229
- const PseudoElementsStr = Object.keys(PseudoElements).join("|");
230
- const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
234
+ const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).join("|");
231
235
  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
236
  const sortValue = (pseudo) => {
237
237
  if (pseudo === "active")
238
238
  return 1;
@@ -254,22 +254,11 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
254
254
  }
255
255
  };
256
256
  };
257
- const variantPseudoElements = {
257
+ const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).join("|");
258
+ const PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})[:-]`);
259
+ const variantPseudoClassesAndElements = {
258
260
  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);
261
+ const match = input.match(PseudoClassesAndElementsRE);
273
262
  if (match) {
274
263
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
275
264
  return {
@@ -280,8 +269,9 @@ const variantPseudoClasses = {
280
269
  }
281
270
  },
282
271
  multiPass: true,
283
- autocomplete: `(${PseudoClassesStr}):`
272
+ autocomplete: `(${PseudoClassesAndElementsStr}):`
284
273
  };
274
+ const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
285
275
  const variantPseudoClassFunctions = {
286
276
  match: (input) => {
287
277
  const match = input.match(PseudoClassFunctionsRE);
@@ -318,6 +308,7 @@ const variantTaggedPseudoClasses = (options = {}) => {
318
308
  }
319
309
  ];
320
310
  };
311
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
321
312
  const partClasses = {
322
313
  match: (input) => {
323
314
  const match = input.match(PartClassesRE);
@@ -341,14 +332,13 @@ const variants = (options) => [
341
332
  variantCustomMedia,
342
333
  variantBreakpoints,
343
334
  ...variantCombinators,
344
- variantPseudoClasses,
335
+ variantPseudoClassesAndElements,
345
336
  variantPseudoClassFunctions,
346
337
  ...variantTaggedPseudoClasses(options),
347
- variantPseudoElements,
348
338
  partClasses,
349
339
  ...variantColorsMediaOrClass(options),
350
340
  ...variantLanguageDirections,
351
341
  variantScope
352
342
  ];
353
343
 
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 };
344
+ 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 };
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;
@@ -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.16",
3
+ "version": "0.32.1",
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.16"
64
+ "@unocss/core": "0.32.1"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",