@unocss/preset-mini 0.16.1 → 0.17.2

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.
@@ -8,20 +8,22 @@ const variantBreakpoints = (matcher, _, theme) => {
8
8
  const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
9
9
  for (const [point, size, idx] of variantEntries) {
10
10
  if (!regexCache[point])
11
- regexCache[point] = new RegExp(`^((?:[a|l]t-)?${point}[:-])`);
11
+ regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
12
12
  const match = matcher.match(regexCache[point]);
13
13
  if (!match)
14
14
  continue;
15
15
  const [, pre] = match;
16
+ const m = matcher.slice(pre.length);
17
+ if (m === "container")
18
+ continue;
16
19
  let direction = "min";
17
- let order = parseInt(size);
20
+ let order = 1e3;
18
21
  if (pre.startsWith("lt-")) {
19
22
  direction = "max";
20
- order = -order;
23
+ order -= idx + 1;
24
+ } else {
25
+ order += idx + 1;
21
26
  }
22
- const m = matcher.slice(pre.length);
23
- if (m === "container")
24
- continue;
25
27
  if (pre.startsWith("at-") && idx < variantEntries.length - 1) {
26
28
  return {
27
29
  matcher: m,
@@ -35,10 +37,13 @@ const variantBreakpoints = (matcher, _, theme) => {
35
37
  }
36
38
  };
37
39
 
38
- const variantChildren = [
39
- variants$1.variantMatcher("children", (input) => `${input} > *`),
40
+ const variantCombinators = [
40
41
  variants$1.variantMatcher("all", (input) => `${input} *`),
41
- variants$1.variantMatcher("next", (input) => `${input}+*`)
42
+ variants$1.variantMatcher("children", (input) => `${input}>*`),
43
+ variants$1.variantMatcher("next", (input) => `${input}+*`),
44
+ variants$1.variantMatcher("sibling", (input) => `${input}+*`),
45
+ variants$1.variantMatcher("siblings", (input) => `${input}~*`),
46
+ variants$1.variantMatcher("svg", (input) => `${input} svg *`)
42
47
  ];
43
48
 
44
49
  const variantColorsClass = [
@@ -113,15 +118,16 @@ const variants = [
113
118
  variantNegative,
114
119
  variantImportant,
115
120
  variantBreakpoints,
116
- ...variantChildren,
121
+ ...variantCombinators,
117
122
  pseudo.variantPseudoClasses,
118
- pseudo.variantPseudoElements
123
+ pseudo.variantPseudoElements,
124
+ pseudo.partClasses
119
125
  ];
120
126
 
121
127
  exports.variantBreakpoints = variantBreakpoints;
122
- exports.variantChildren = variantChildren;
123
128
  exports.variantColorsClass = variantColorsClass;
124
129
  exports.variantColorsMedia = variantColorsMedia;
130
+ exports.variantCombinators = variantCombinators;
125
131
  exports.variantImportant = variantImportant;
126
132
  exports.variantNegative = variantNegative;
127
133
  exports.variantSpace = variantSpace;
@@ -1,25 +1,27 @@
1
1
  import { v as variantMatcher } from './variants.mjs';
2
- import { v as variantPseudoClasses, a as variantPseudoElements } from './pseudo.mjs';
2
+ import { v as variantPseudoClasses, a as variantPseudoElements, p as partClasses } from './pseudo.mjs';
3
3
 
4
4
  const regexCache = {};
5
5
  const variantBreakpoints = (matcher, _, theme) => {
6
6
  const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
7
7
  for (const [point, size, idx] of variantEntries) {
8
8
  if (!regexCache[point])
9
- regexCache[point] = new RegExp(`^((?:[a|l]t-)?${point}[:-])`);
9
+ regexCache[point] = new RegExp(`^((?:[al]t-)?${point}[:-])`);
10
10
  const match = matcher.match(regexCache[point]);
11
11
  if (!match)
12
12
  continue;
13
13
  const [, pre] = match;
14
+ const m = matcher.slice(pre.length);
15
+ if (m === "container")
16
+ continue;
14
17
  let direction = "min";
15
- let order = parseInt(size);
18
+ let order = 1e3;
16
19
  if (pre.startsWith("lt-")) {
17
20
  direction = "max";
18
- order = -order;
21
+ order -= idx + 1;
22
+ } else {
23
+ order += idx + 1;
19
24
  }
20
- const m = matcher.slice(pre.length);
21
- if (m === "container")
22
- continue;
23
25
  if (pre.startsWith("at-") && idx < variantEntries.length - 1) {
24
26
  return {
25
27
  matcher: m,
@@ -33,10 +35,13 @@ const variantBreakpoints = (matcher, _, theme) => {
33
35
  }
34
36
  };
35
37
 
36
- const variantChildren = [
37
- variantMatcher("children", (input) => `${input} > *`),
38
+ const variantCombinators = [
38
39
  variantMatcher("all", (input) => `${input} *`),
39
- variantMatcher("next", (input) => `${input}+*`)
40
+ variantMatcher("children", (input) => `${input}>*`),
41
+ variantMatcher("next", (input) => `${input}+*`),
42
+ variantMatcher("sibling", (input) => `${input}+*`),
43
+ variantMatcher("siblings", (input) => `${input}~*`),
44
+ variantMatcher("svg", (input) => `${input} svg *`)
40
45
  ];
41
46
 
42
47
  const variantColorsClass = [
@@ -111,9 +116,10 @@ const variants = [
111
116
  variantNegative,
112
117
  variantImportant,
113
118
  variantBreakpoints,
114
- ...variantChildren,
119
+ ...variantCombinators,
115
120
  variantPseudoClasses,
116
- variantPseudoElements
121
+ variantPseudoElements,
122
+ partClasses
117
123
  ];
118
124
 
119
- export { variantColorsMedia as a, variantColorsClass as b, variantBreakpoints as c, variantChildren as d, variantImportant as e, variantNegative as f, variantSpace as g, variants as v };
125
+ export { variantColorsMedia as a, variantColorsClass as b, variantBreakpoints as c, variantCombinators as d, variantImportant as e, variantNegative as f, variantSpace as g, variants as v };
@@ -2,40 +2,42 @@
2
2
 
3
3
  const core = require('@unocss/core');
4
4
 
5
- const CONTROL_BYPASS_PSEUDO = "$$no-pseudo";
5
+ const CONTROL_BYPASS_PSEUDO_CLASS = "$$no-pseudo";
6
6
  const PseudoClasses = Object.fromEntries([
7
+ "any-link",
8
+ "link",
9
+ "visited",
10
+ "target",
11
+ "hover",
7
12
  "active",
8
- "checked",
9
- "default",
10
- "empty",
11
- "enabled",
12
- "disabled",
13
- "first-of-type",
14
- ["first", "first-child"],
15
13
  "focus-visible",
16
14
  "focus-within",
17
15
  "focus",
18
- "hover",
19
- "indeterminate",
20
- "invalid",
21
- "last-of-type",
22
- ["last", "last-child"],
23
- "link",
24
- "only-child",
25
- "only-of-type",
26
- "optional",
27
- "placeholder-shown",
16
+ "autofill",
17
+ "enabled",
18
+ "disabled",
28
19
  "read-only",
29
20
  "read-write",
21
+ "placeholder-shown",
22
+ "default",
23
+ "checked",
24
+ "indeterminate",
25
+ "valid",
26
+ "invalid",
30
27
  "required",
28
+ "optional",
31
29
  "root",
32
- "target",
33
- "valid",
34
- "visited",
30
+ "empty",
35
31
  ["even-of-type", "nth-of-type(even)"],
36
32
  ["even", "nth-child(even)"],
37
33
  ["odd-of-type", "nth-of-type(odd)"],
38
- ["odd", "nth-child(odd)"]
34
+ ["odd", "nth-child(odd)"],
35
+ "first-of-type",
36
+ ["first", "first-child"],
37
+ "last-of-type",
38
+ ["last", "last-child"],
39
+ "only-child",
40
+ "only-of-type"
39
41
  ].map(core.toArray));
40
42
  const PseudoElements = [
41
43
  "before",
@@ -44,23 +46,24 @@ const PseudoElements = [
44
46
  "first-line",
45
47
  "selection"
46
48
  ];
49
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
47
50
  const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
48
51
  const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
49
52
  const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
50
53
  const PseudoClassesNotRE = new RegExp(`^not-(${PseudoClassesStr})[:-]`);
51
- const PseudoClassesGroupRE = new RegExp(`^group-(${PseudoClassesStr})[:-]`);
52
- const PseudoClassesPeerRE = new RegExp(`^peer-(${PseudoClassesStr})[:-]`);
54
+ const PseudoClassesGroupRE = new RegExp(`^group-((not-)?(${PseudoClassesStr}))[:-]`);
55
+ const PseudoClassesPeerRE = new RegExp(`^peer-((not-)?(${PseudoClassesStr}))[:-]`);
53
56
  const variantPseudoElements = (input) => {
54
57
  const match = input.match(PseudoElementsRE);
55
58
  if (match) {
56
59
  return {
57
60
  matcher: input.slice(match[1].length + 1),
58
- selector: (s, body) => shouldAdd(body) && `${s}::${match[1]}`
61
+ selector: (s) => `${s}::${match[1]}`
59
62
  };
60
63
  }
61
64
  };
62
65
  function shouldAdd(entires) {
63
- return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO) || void 0;
66
+ return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO_CLASS) || void 0;
64
67
  }
65
68
  const variantPseudoClasses = {
66
69
  match: (input) => {
@@ -82,7 +85,9 @@ const variantPseudoClasses = {
82
85
  }
83
86
  match = input.match(PseudoClassesGroupRE);
84
87
  if (match) {
85
- const pseudo = PseudoClasses[match[1]] || match[1];
88
+ let pseudo = PseudoClasses[match[3]] || match[3];
89
+ if (match[2])
90
+ pseudo = `not(:${pseudo})`;
86
91
  return {
87
92
  matcher: input.slice(match[1].length + 7),
88
93
  selector: (s, body) => shouldAdd(body) && s.includes(".group:") ? s.replace(/\.group:/, `.group:${pseudo}:`) : `.group:${pseudo} ${s}`
@@ -90,17 +95,35 @@ const variantPseudoClasses = {
90
95
  }
91
96
  match = input.match(PseudoClassesPeerRE);
92
97
  if (match) {
93
- const pseudo = PseudoClasses[match[1]] || match[1];
98
+ let pseudo = PseudoClasses[match[3]] || match[3];
99
+ if (match[2])
100
+ pseudo = `not(:${pseudo})`;
94
101
  return {
95
102
  matcher: input.slice(match[1].length + 6),
96
- selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo} ~ ${s}`
103
+ selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo}~${s}`
104
+ };
105
+ }
106
+ },
107
+ multiPass: true
108
+ };
109
+ const partClasses = {
110
+ match: (input) => {
111
+ const match = input.match(PartClassesRE);
112
+ if (match) {
113
+ const part = `part(${match[2]})`;
114
+ return {
115
+ matcher: input.slice(match[1].length),
116
+ selector: (s, body) => {
117
+ return shouldAdd(body) && `${s}::${part}`;
118
+ }
97
119
  };
98
120
  }
99
121
  },
100
122
  multiPass: true
101
123
  };
102
124
 
103
- exports.CONTROL_BYPASS_PSEUDO = CONTROL_BYPASS_PSEUDO;
125
+ exports.CONTROL_BYPASS_PSEUDO_CLASS = CONTROL_BYPASS_PSEUDO_CLASS;
104
126
  exports.PseudoClasses = PseudoClasses;
127
+ exports.partClasses = partClasses;
105
128
  exports.variantPseudoClasses = variantPseudoClasses;
106
129
  exports.variantPseudoElements = variantPseudoElements;
@@ -1,39 +1,41 @@
1
1
  import { toArray } from '@unocss/core';
2
2
 
3
- const CONTROL_BYPASS_PSEUDO = "$$no-pseudo";
3
+ const CONTROL_BYPASS_PSEUDO_CLASS = "$$no-pseudo";
4
4
  const PseudoClasses = Object.fromEntries([
5
+ "any-link",
6
+ "link",
7
+ "visited",
8
+ "target",
9
+ "hover",
5
10
  "active",
6
- "checked",
7
- "default",
8
- "empty",
9
- "enabled",
10
- "disabled",
11
- "first-of-type",
12
- ["first", "first-child"],
13
11
  "focus-visible",
14
12
  "focus-within",
15
13
  "focus",
16
- "hover",
17
- "indeterminate",
18
- "invalid",
19
- "last-of-type",
20
- ["last", "last-child"],
21
- "link",
22
- "only-child",
23
- "only-of-type",
24
- "optional",
25
- "placeholder-shown",
14
+ "autofill",
15
+ "enabled",
16
+ "disabled",
26
17
  "read-only",
27
18
  "read-write",
19
+ "placeholder-shown",
20
+ "default",
21
+ "checked",
22
+ "indeterminate",
23
+ "valid",
24
+ "invalid",
28
25
  "required",
26
+ "optional",
29
27
  "root",
30
- "target",
31
- "valid",
32
- "visited",
28
+ "empty",
33
29
  ["even-of-type", "nth-of-type(even)"],
34
30
  ["even", "nth-child(even)"],
35
31
  ["odd-of-type", "nth-of-type(odd)"],
36
- ["odd", "nth-child(odd)"]
32
+ ["odd", "nth-child(odd)"],
33
+ "first-of-type",
34
+ ["first", "first-child"],
35
+ "last-of-type",
36
+ ["last", "last-child"],
37
+ "only-child",
38
+ "only-of-type"
37
39
  ].map(toArray));
38
40
  const PseudoElements = [
39
41
  "before",
@@ -42,23 +44,24 @@ const PseudoElements = [
42
44
  "first-line",
43
45
  "selection"
44
46
  ];
47
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
45
48
  const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
46
49
  const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
47
50
  const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
48
51
  const PseudoClassesNotRE = new RegExp(`^not-(${PseudoClassesStr})[:-]`);
49
- const PseudoClassesGroupRE = new RegExp(`^group-(${PseudoClassesStr})[:-]`);
50
- const PseudoClassesPeerRE = new RegExp(`^peer-(${PseudoClassesStr})[:-]`);
52
+ const PseudoClassesGroupRE = new RegExp(`^group-((not-)?(${PseudoClassesStr}))[:-]`);
53
+ const PseudoClassesPeerRE = new RegExp(`^peer-((not-)?(${PseudoClassesStr}))[:-]`);
51
54
  const variantPseudoElements = (input) => {
52
55
  const match = input.match(PseudoElementsRE);
53
56
  if (match) {
54
57
  return {
55
58
  matcher: input.slice(match[1].length + 1),
56
- selector: (s, body) => shouldAdd(body) && `${s}::${match[1]}`
59
+ selector: (s) => `${s}::${match[1]}`
57
60
  };
58
61
  }
59
62
  };
60
63
  function shouldAdd(entires) {
61
- return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO) || void 0;
64
+ return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO_CLASS) || void 0;
62
65
  }
63
66
  const variantPseudoClasses = {
64
67
  match: (input) => {
@@ -80,7 +83,9 @@ const variantPseudoClasses = {
80
83
  }
81
84
  match = input.match(PseudoClassesGroupRE);
82
85
  if (match) {
83
- const pseudo = PseudoClasses[match[1]] || match[1];
86
+ let pseudo = PseudoClasses[match[3]] || match[3];
87
+ if (match[2])
88
+ pseudo = `not(:${pseudo})`;
84
89
  return {
85
90
  matcher: input.slice(match[1].length + 7),
86
91
  selector: (s, body) => shouldAdd(body) && s.includes(".group:") ? s.replace(/\.group:/, `.group:${pseudo}:`) : `.group:${pseudo} ${s}`
@@ -88,14 +93,31 @@ const variantPseudoClasses = {
88
93
  }
89
94
  match = input.match(PseudoClassesPeerRE);
90
95
  if (match) {
91
- const pseudo = PseudoClasses[match[1]] || match[1];
96
+ let pseudo = PseudoClasses[match[3]] || match[3];
97
+ if (match[2])
98
+ pseudo = `not(:${pseudo})`;
92
99
  return {
93
100
  matcher: input.slice(match[1].length + 6),
94
- selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo} ~ ${s}`
101
+ selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo}~${s}`
102
+ };
103
+ }
104
+ },
105
+ multiPass: true
106
+ };
107
+ const partClasses = {
108
+ match: (input) => {
109
+ const match = input.match(PartClassesRE);
110
+ if (match) {
111
+ const part = `part(${match[2]})`;
112
+ return {
113
+ matcher: input.slice(match[1].length),
114
+ selector: (s, body) => {
115
+ return shouldAdd(body) && `${s}::${part}`;
116
+ }
95
117
  };
96
118
  }
97
119
  },
98
120
  multiPass: true
99
121
  };
100
122
 
101
- export { CONTROL_BYPASS_PSEUDO as C, PseudoClasses as P, variantPseudoElements as a, variantPseudoClasses as v };
123
+ export { CONTROL_BYPASS_PSEUDO_CLASS as C, PseudoClasses as P, variantPseudoElements as a, partClasses as p, variantPseudoClasses as v };