@unocss/preset-mini 0.29.2 → 0.29.3

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.
@@ -63,7 +63,7 @@ const borders = [
63
63
  [/^(?:border|b)-([rltbse])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
64
64
  [/^(?:border|b)-(block|inline)-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
65
65
  [/^(?:border|b)-([bi][se])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
66
- [/^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/, handlerRounded, { autocomplete: ["(border|b)-(rounded-|rd-)<num>", "(rounded-|rd-)<num>"] }],
66
+ [/^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/, handlerRounded, { autocomplete: ["(border|b)-(rounded|rd)", "(border|b)-(rounded|rd)-<num>", "(rounded|rd)", "(rounded|rd)-<num>"] }],
67
67
  [/^(?:border-|b-)?(?:rounded|rd)-([rltb])(?:-(.+))?$/, handlerRounded],
68
68
  [/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
69
69
  [/^(?:border-|b-)?(?:rounded|rd)-([bi][se])(?:-(.+))?$/, handlerRounded],
@@ -61,7 +61,7 @@ const borders = [
61
61
  [/^(?:border|b)-([rltbse])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
62
62
  [/^(?:border|b)-(block|inline)-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
63
63
  [/^(?:border|b)-([bi][se])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
64
- [/^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/, handlerRounded, { autocomplete: ["(border|b)-(rounded-|rd-)<num>", "(rounded-|rd-)<num>"] }],
64
+ [/^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/, handlerRounded, { autocomplete: ["(border|b)-(rounded|rd)", "(border|b)-(rounded|rd)-<num>", "(rounded|rd)", "(rounded|rd)-<num>"] }],
65
65
  [/^(?:border-|b-)?(?:rounded|rd)-([rltb])(?:-(.+))?$/, handlerRounded],
66
66
  [/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
67
67
  [/^(?:border-|b-)?(?:rounded|rd)-([bi][se])(?:-(.+))?$/, handlerRounded],
@@ -10,40 +10,43 @@ const calcMaxWidthBySize = (size) => {
10
10
  const maxWidth = parseFloat(value) - 0.1;
11
11
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
12
12
  };
13
- const variantBreakpoints = (matcher, { theme }) => {
14
- const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
15
- for (const [point, size, idx] of variantEntries) {
16
- if (!regexCache[point])
17
- regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
18
- const match = matcher.match(regexCache[point]);
19
- if (!match)
20
- continue;
21
- const [, pre] = match;
22
- const m = matcher.slice(pre.length);
23
- if (m === "container")
24
- continue;
25
- const isLtPrefix = pre.startsWith("lt-");
26
- const isAtPrefix = pre.startsWith("at-");
27
- let order = 1e3;
28
- if (isLtPrefix) {
29
- order -= idx + 1;
13
+ const variantBreakpoints = {
14
+ match(matcher, { theme }) {
15
+ const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
16
+ for (const [point, size, idx] of variantEntries) {
17
+ if (!regexCache[point])
18
+ regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
19
+ const match = matcher.match(regexCache[point]);
20
+ if (!match)
21
+ continue;
22
+ const [, pre] = match;
23
+ const m = matcher.slice(pre.length);
24
+ if (m === "container")
25
+ continue;
26
+ const isLtPrefix = pre.startsWith("lt-");
27
+ const isAtPrefix = pre.startsWith("at-");
28
+ let order = 1e3;
29
+ if (isLtPrefix) {
30
+ order -= idx + 1;
31
+ return {
32
+ matcher: m,
33
+ parent: [`@media (max-width: ${calcMaxWidthBySize(size)})`, order]
34
+ };
35
+ }
36
+ order += idx + 1;
37
+ if (isAtPrefix && idx < variantEntries.length - 1) {
38
+ return {
39
+ matcher: m,
40
+ parent: [`@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`, order]
41
+ };
42
+ }
30
43
  return {
31
44
  matcher: m,
32
- parent: [`@media (max-width: ${calcMaxWidthBySize(size)})`, order]
45
+ parent: [`@media (min-width: ${size})`, order]
33
46
  };
34
47
  }
35
- order += idx + 1;
36
- if (isAtPrefix && idx < variantEntries.length - 1) {
37
- return {
38
- matcher: m,
39
- parent: [`@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`, order]
40
- };
41
- }
42
- return {
43
- matcher: m,
44
- parent: [`@media (min-width: ${size})`, order]
45
- };
46
- }
48
+ },
49
+ autocomplete: "(at-|lt-|)$breakpoints:"
47
50
  };
48
51
 
49
52
  const scopeMatcher = (strict, name, template) => {
@@ -250,15 +253,18 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
250
253
  }
251
254
  };
252
255
  };
253
- const variantPseudoElements = (input) => {
254
- const match = input.match(PseudoElementsRE);
255
- if (match) {
256
- const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
257
- return {
258
- matcher: input.slice(match[0].length),
259
- selector: (s) => `${s}${pseudo}`
260
- };
261
- }
256
+ const variantPseudoElements = {
257
+ match: (input) => {
258
+ const match = input.match(PseudoElementsRE);
259
+ if (match) {
260
+ const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
261
+ return {
262
+ matcher: input.slice(match[0].length),
263
+ selector: (s) => `${s}${pseudo}`
264
+ };
265
+ }
266
+ },
267
+ autocomplete: `(${PseudoElementsStr}):`
262
268
  };
263
269
  const variantPseudoClasses = {
264
270
  match: (input) => {
@@ -272,7 +278,8 @@ const variantPseudoClasses = {
272
278
  };
273
279
  }
274
280
  },
275
- multiPass: true
281
+ multiPass: true,
282
+ autocomplete: `(${PseudoClassesStr}):`
276
283
  };
277
284
  const variantPseudoClassFunctions = {
278
285
  match: (input) => {
@@ -286,7 +293,8 @@ const variantPseudoClassFunctions = {
286
293
  };
287
294
  }
288
295
  },
289
- multiPass: true
296
+ multiPass: true,
297
+ autocomplete: `(${PseudoClassFunctionsStr})-(${PseudoClassesStr}):`
290
298
  };
291
299
  const variantTaggedPseudoClasses = (options = {}) => {
292
300
  const attributify = !!options?.attributifyPseudo;
@@ -8,40 +8,43 @@ const calcMaxWidthBySize = (size) => {
8
8
  const maxWidth = parseFloat(value) - 0.1;
9
9
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
10
10
  };
11
- const variantBreakpoints = (matcher, { theme }) => {
12
- const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
13
- for (const [point, size, idx] of variantEntries) {
14
- if (!regexCache[point])
15
- regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
16
- const match = matcher.match(regexCache[point]);
17
- if (!match)
18
- continue;
19
- const [, pre] = match;
20
- const m = matcher.slice(pre.length);
21
- if (m === "container")
22
- continue;
23
- const isLtPrefix = pre.startsWith("lt-");
24
- const isAtPrefix = pre.startsWith("at-");
25
- let order = 1e3;
26
- if (isLtPrefix) {
27
- order -= idx + 1;
11
+ const variantBreakpoints = {
12
+ match(matcher, { theme }) {
13
+ const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
14
+ for (const [point, size, idx] of variantEntries) {
15
+ if (!regexCache[point])
16
+ regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
17
+ const match = matcher.match(regexCache[point]);
18
+ if (!match)
19
+ continue;
20
+ const [, pre] = match;
21
+ const m = matcher.slice(pre.length);
22
+ if (m === "container")
23
+ continue;
24
+ const isLtPrefix = pre.startsWith("lt-");
25
+ const isAtPrefix = pre.startsWith("at-");
26
+ let order = 1e3;
27
+ if (isLtPrefix) {
28
+ order -= idx + 1;
29
+ return {
30
+ matcher: m,
31
+ parent: [`@media (max-width: ${calcMaxWidthBySize(size)})`, order]
32
+ };
33
+ }
34
+ order += idx + 1;
35
+ if (isAtPrefix && idx < variantEntries.length - 1) {
36
+ return {
37
+ matcher: m,
38
+ parent: [`@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`, order]
39
+ };
40
+ }
28
41
  return {
29
42
  matcher: m,
30
- parent: [`@media (max-width: ${calcMaxWidthBySize(size)})`, order]
43
+ parent: [`@media (min-width: ${size})`, order]
31
44
  };
32
45
  }
33
- order += idx + 1;
34
- if (isAtPrefix && idx < variantEntries.length - 1) {
35
- return {
36
- matcher: m,
37
- parent: [`@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`, order]
38
- };
39
- }
40
- return {
41
- matcher: m,
42
- parent: [`@media (min-width: ${size})`, order]
43
- };
44
- }
46
+ },
47
+ autocomplete: "(at-|lt-|)$breakpoints:"
45
48
  };
46
49
 
47
50
  const scopeMatcher = (strict, name, template) => {
@@ -248,15 +251,18 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
248
251
  }
249
252
  };
250
253
  };
251
- const variantPseudoElements = (input) => {
252
- const match = input.match(PseudoElementsRE);
253
- if (match) {
254
- const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
255
- return {
256
- matcher: input.slice(match[0].length),
257
- selector: (s) => `${s}${pseudo}`
258
- };
259
- }
254
+ const variantPseudoElements = {
255
+ match: (input) => {
256
+ const match = input.match(PseudoElementsRE);
257
+ if (match) {
258
+ const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
259
+ return {
260
+ matcher: input.slice(match[0].length),
261
+ selector: (s) => `${s}${pseudo}`
262
+ };
263
+ }
264
+ },
265
+ autocomplete: `(${PseudoElementsStr}):`
260
266
  };
261
267
  const variantPseudoClasses = {
262
268
  match: (input) => {
@@ -270,7 +276,8 @@ const variantPseudoClasses = {
270
276
  };
271
277
  }
272
278
  },
273
- multiPass: true
279
+ multiPass: true,
280
+ autocomplete: `(${PseudoClassesStr}):`
274
281
  };
275
282
  const variantPseudoClassFunctions = {
276
283
  match: (input) => {
@@ -284,7 +291,8 @@ const variantPseudoClassFunctions = {
284
291
  };
285
292
  }
286
293
  },
287
- multiPass: true
294
+ multiPass: true,
295
+ autocomplete: `(${PseudoClassFunctionsStr})-(${PseudoClassesStr}):`
288
296
  };
289
297
  const variantTaggedPseudoClasses = (options = {}) => {
290
298
  const attributify = !!options?.attributifyPseudo;
@@ -4,26 +4,32 @@ const core = require('@unocss/core');
4
4
 
5
5
  const variantMatcher = (name, selector) => {
6
6
  const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
7
- return (input) => {
8
- const match = input.match(re);
9
- if (match) {
10
- return {
11
- matcher: input.slice(match[0].length),
12
- selector
13
- };
14
- }
7
+ return {
8
+ match: (input) => {
9
+ const match = input.match(re);
10
+ if (match) {
11
+ return {
12
+ matcher: input.slice(match[0].length),
13
+ selector
14
+ };
15
+ }
16
+ },
17
+ autocomplete: `${name}:`
15
18
  };
16
19
  };
17
20
  const variantParentMatcher = (name, parent) => {
18
21
  const re = new RegExp(`^${core.escapeRegExp(name)}[:-]`);
19
- return (input) => {
20
- const match = input.match(re);
21
- if (match) {
22
- return {
23
- matcher: input.slice(match[0].length),
24
- parent
25
- };
26
- }
22
+ return {
23
+ match: (input) => {
24
+ const match = input.match(re);
25
+ if (match) {
26
+ return {
27
+ matcher: input.slice(match[0].length),
28
+ parent
29
+ };
30
+ }
31
+ },
32
+ autocomplete: `${name}:`
27
33
  };
28
34
  };
29
35
 
@@ -2,26 +2,32 @@ import { escapeRegExp } from '@unocss/core';
2
2
 
3
3
  const variantMatcher = (name, selector) => {
4
4
  const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
5
- return (input) => {
6
- const match = input.match(re);
7
- if (match) {
8
- return {
9
- matcher: input.slice(match[0].length),
10
- selector
11
- };
12
- }
5
+ return {
6
+ match: (input) => {
7
+ const match = input.match(re);
8
+ if (match) {
9
+ return {
10
+ matcher: input.slice(match[0].length),
11
+ selector
12
+ };
13
+ }
14
+ },
15
+ autocomplete: `${name}:`
13
16
  };
14
17
  };
15
18
  const variantParentMatcher = (name, parent) => {
16
19
  const re = new RegExp(`^${escapeRegExp(name)}[:-]`);
17
- return (input) => {
18
- const match = input.match(re);
19
- if (match) {
20
- return {
21
- matcher: input.slice(match[0].length),
22
- parent
23
- };
24
- }
20
+ return {
21
+ match: (input) => {
22
+ const match = input.match(re);
23
+ if (match) {
24
+ return {
25
+ matcher: input.slice(match[0].length),
26
+ parent
27
+ };
28
+ }
29
+ },
30
+ autocomplete: `${name}:`
25
31
  };
26
32
  };
27
33
 
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { RGBAColorValue, CSSColorValue, VariantHandler } from '@unocss/core';
2
+ import { RGBAColorValue, CSSColorValue, VariantObject } from '@unocss/core';
3
3
  export { c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, p as parseColor } from './utilities-820bcff8.js';
4
4
  import './types-f7b2c653.js';
5
5
 
@@ -68,7 +68,7 @@ declare namespace handlers {
68
68
  declare const handler: _unocss_core.ValueHandler<"number" | "global" | "auto" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "cssvar" | "time" | "degree" | "properties">;
69
69
  declare const h: _unocss_core.ValueHandler<"number" | "global" | "auto" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "cssvar" | "time" | "degree" | "properties">;
70
70
 
71
- declare const variantMatcher: (name: string, selector?: ((input: string) => string | undefined) | undefined) => (input: string) => VariantHandler | undefined;
72
- declare const variantParentMatcher: (name: string, parent: string) => (input: string) => VariantHandler | undefined;
71
+ declare const variantMatcher: (name: string, selector?: ((input: string) => string | undefined) | undefined) => VariantObject;
72
+ declare const variantParentMatcher: (name: string, parent: string) => VariantObject;
73
73
 
74
74
  export { colorToString, cornerMap, directionMap, getComponents, h, handler, hex2rgba, insetMap, parseCssColor, positionMap, handlers as valueHandlers, variantMatcher, variantParentMatcher, xyzMap };
@@ -9,10 +9,10 @@ declare const variantBreakpoints: Variant<Theme>;
9
9
 
10
10
  declare const variantCombinators: Variant[];
11
11
 
12
- declare const variantPrint: VariantFunction;
12
+ declare const variantPrint: Variant;
13
13
  declare const variantCustomMedia: VariantFunction;
14
14
 
15
- declare const variantColorsMediaOrClass: (options?: PresetMiniOptions) => VariantFunction[];
15
+ declare const variantColorsMediaOrClass: (options?: PresetMiniOptions) => Variant[];
16
16
 
17
17
  declare const variants: (options: PresetMiniOptions) => Variant<Theme>[];
18
18
 
@@ -24,7 +24,7 @@ declare const variantScope: Variant;
24
24
  declare const variantImportant: Variant;
25
25
  declare const variantNegative: Variant;
26
26
 
27
- declare const variantPseudoElements: VariantFunction;
27
+ declare const variantPseudoElements: VariantObject;
28
28
  declare const variantPseudoClasses: VariantObject;
29
29
  declare const variantPseudoClassFunctions: VariantObject;
30
30
  declare const variantTaggedPseudoClasses: (options?: PresetMiniOptions) => VariantObject[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.29.2",
3
+ "version": "0.29.3",
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.29.2"
64
+ "@unocss/core": "0.29.3"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",