@unocss/preset-mini 0.16.2 → 0.17.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.
- package/dist/chunks/default2.cjs +252 -432
- package/dist/chunks/default2.mjs +225 -400
- package/dist/chunks/default3.cjs +10 -6
- package/dist/chunks/default3.mjs +11 -7
- package/dist/chunks/pseudo.cjs +54 -30
- package/dist/chunks/pseudo.mjs +53 -30
- package/dist/chunks/utilities.cjs +294 -0
- package/dist/chunks/utilities.mjs +283 -0
- package/dist/chunks/variants.cjs +8 -6
- package/dist/chunks/variants.mjs +8 -6
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/rules.cjs +3 -8
- package/dist/rules.d.ts +5 -17
- package/dist/rules.mjs +2 -2
- package/dist/utils.cjs +11 -8
- package/dist/utils.d.ts +64 -4
- package/dist/utils.mjs +1 -1
- package/dist/variants.cjs +3 -2
- package/dist/variants.d.ts +4 -3
- package/dist/variants.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunks/index.cjs +0 -142
- package/dist/chunks/index.mjs +0 -134
package/dist/chunks/default3.cjs
CHANGED
|
@@ -37,10 +37,13 @@ const variantBreakpoints = (matcher, _, theme) => {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const
|
|
41
|
-
variants$1.variantMatcher("children", (input) => `${input} > *`),
|
|
40
|
+
const variantCombinators = [
|
|
42
41
|
variants$1.variantMatcher("all", (input) => `${input} *`),
|
|
43
|
-
variants$1.variantMatcher("
|
|
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 *`)
|
|
44
47
|
];
|
|
45
48
|
|
|
46
49
|
const variantColorsClass = [
|
|
@@ -115,15 +118,16 @@ const variants = [
|
|
|
115
118
|
variantNegative,
|
|
116
119
|
variantImportant,
|
|
117
120
|
variantBreakpoints,
|
|
118
|
-
...
|
|
121
|
+
...variantCombinators,
|
|
119
122
|
pseudo.variantPseudoClasses,
|
|
120
|
-
pseudo.variantPseudoElements
|
|
123
|
+
pseudo.variantPseudoElements,
|
|
124
|
+
pseudo.partClasses
|
|
121
125
|
];
|
|
122
126
|
|
|
123
127
|
exports.variantBreakpoints = variantBreakpoints;
|
|
124
|
-
exports.variantChildren = variantChildren;
|
|
125
128
|
exports.variantColorsClass = variantColorsClass;
|
|
126
129
|
exports.variantColorsMedia = variantColorsMedia;
|
|
130
|
+
exports.variantCombinators = variantCombinators;
|
|
127
131
|
exports.variantImportant = variantImportant;
|
|
128
132
|
exports.variantNegative = variantNegative;
|
|
129
133
|
exports.variantSpace = variantSpace;
|
package/dist/chunks/default3.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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) => {
|
|
@@ -35,10 +35,13 @@ const variantBreakpoints = (matcher, _, theme) => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const
|
|
39
|
-
variantMatcher("children", (input) => `${input} > *`),
|
|
38
|
+
const variantCombinators = [
|
|
40
39
|
variantMatcher("all", (input) => `${input} *`),
|
|
41
|
-
variantMatcher("
|
|
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 *`)
|
|
42
45
|
];
|
|
43
46
|
|
|
44
47
|
const variantColorsClass = [
|
|
@@ -113,9 +116,10 @@ const variants = [
|
|
|
113
116
|
variantNegative,
|
|
114
117
|
variantImportant,
|
|
115
118
|
variantBreakpoints,
|
|
116
|
-
...
|
|
119
|
+
...variantCombinators,
|
|
117
120
|
variantPseudoClasses,
|
|
118
|
-
variantPseudoElements
|
|
121
|
+
variantPseudoElements,
|
|
122
|
+
partClasses
|
|
119
123
|
];
|
|
120
124
|
|
|
121
|
-
export { variantColorsMedia as a, variantColorsClass as b, variantBreakpoints as c,
|
|
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 };
|
package/dist/chunks/pseudo.cjs
CHANGED
|
@@ -2,65 +2,69 @@
|
|
|
2
2
|
|
|
3
3
|
const core = require('@unocss/core');
|
|
4
4
|
|
|
5
|
-
const
|
|
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
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
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
|
-
"
|
|
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 = [
|
|
43
|
+
"placeholder",
|
|
41
44
|
"before",
|
|
42
45
|
"after",
|
|
43
46
|
"first-letter",
|
|
44
47
|
"first-line",
|
|
45
48
|
"selection"
|
|
46
49
|
];
|
|
50
|
+
const PartClassesRE = /(part-\[(.+)]:)(.+)/;
|
|
47
51
|
const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
|
|
48
52
|
const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
|
|
49
53
|
const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
|
|
50
54
|
const PseudoClassesNotRE = new RegExp(`^not-(${PseudoClassesStr})[:-]`);
|
|
51
|
-
const PseudoClassesGroupRE = new RegExp(`^group-(${PseudoClassesStr})[:-]`);
|
|
52
|
-
const PseudoClassesPeerRE = new RegExp(`^peer-(${PseudoClassesStr})[:-]`);
|
|
55
|
+
const PseudoClassesGroupRE = new RegExp(`^group-((not-)?(${PseudoClassesStr}))[:-]`);
|
|
56
|
+
const PseudoClassesPeerRE = new RegExp(`^peer-((not-)?(${PseudoClassesStr}))[:-]`);
|
|
53
57
|
const variantPseudoElements = (input) => {
|
|
54
58
|
const match = input.match(PseudoElementsRE);
|
|
55
59
|
if (match) {
|
|
56
60
|
return {
|
|
57
61
|
matcher: input.slice(match[1].length + 1),
|
|
58
|
-
selector: (s
|
|
62
|
+
selector: (s) => `${s}::${match[1]}`
|
|
59
63
|
};
|
|
60
64
|
}
|
|
61
65
|
};
|
|
62
66
|
function shouldAdd(entires) {
|
|
63
|
-
return !entires.find((i) => i[0] ===
|
|
67
|
+
return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO_CLASS) || void 0;
|
|
64
68
|
}
|
|
65
69
|
const variantPseudoClasses = {
|
|
66
70
|
match: (input) => {
|
|
@@ -82,7 +86,9 @@ const variantPseudoClasses = {
|
|
|
82
86
|
}
|
|
83
87
|
match = input.match(PseudoClassesGroupRE);
|
|
84
88
|
if (match) {
|
|
85
|
-
|
|
89
|
+
let pseudo = PseudoClasses[match[3]] || match[3];
|
|
90
|
+
if (match[2])
|
|
91
|
+
pseudo = `not(:${pseudo})`;
|
|
86
92
|
return {
|
|
87
93
|
matcher: input.slice(match[1].length + 7),
|
|
88
94
|
selector: (s, body) => shouldAdd(body) && s.includes(".group:") ? s.replace(/\.group:/, `.group:${pseudo}:`) : `.group:${pseudo} ${s}`
|
|
@@ -90,17 +96,35 @@ const variantPseudoClasses = {
|
|
|
90
96
|
}
|
|
91
97
|
match = input.match(PseudoClassesPeerRE);
|
|
92
98
|
if (match) {
|
|
93
|
-
|
|
99
|
+
let pseudo = PseudoClasses[match[3]] || match[3];
|
|
100
|
+
if (match[2])
|
|
101
|
+
pseudo = `not(:${pseudo})`;
|
|
94
102
|
return {
|
|
95
103
|
matcher: input.slice(match[1].length + 6),
|
|
96
|
-
selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo}
|
|
104
|
+
selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo}~${s}`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
multiPass: true
|
|
109
|
+
};
|
|
110
|
+
const partClasses = {
|
|
111
|
+
match: (input) => {
|
|
112
|
+
const match = input.match(PartClassesRE);
|
|
113
|
+
if (match) {
|
|
114
|
+
const part = `part(${match[2]})`;
|
|
115
|
+
return {
|
|
116
|
+
matcher: input.slice(match[1].length),
|
|
117
|
+
selector: (s, body) => {
|
|
118
|
+
return shouldAdd(body) && `${s}::${part}`;
|
|
119
|
+
}
|
|
97
120
|
};
|
|
98
121
|
}
|
|
99
122
|
},
|
|
100
123
|
multiPass: true
|
|
101
124
|
};
|
|
102
125
|
|
|
103
|
-
exports.
|
|
126
|
+
exports.CONTROL_BYPASS_PSEUDO_CLASS = CONTROL_BYPASS_PSEUDO_CLASS;
|
|
104
127
|
exports.PseudoClasses = PseudoClasses;
|
|
128
|
+
exports.partClasses = partClasses;
|
|
105
129
|
exports.variantPseudoClasses = variantPseudoClasses;
|
|
106
130
|
exports.variantPseudoElements = variantPseudoElements;
|
package/dist/chunks/pseudo.mjs
CHANGED
|
@@ -1,64 +1,68 @@
|
|
|
1
1
|
import { toArray } from '@unocss/core';
|
|
2
2
|
|
|
3
|
-
const
|
|
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
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
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
|
-
"
|
|
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 = [
|
|
41
|
+
"placeholder",
|
|
39
42
|
"before",
|
|
40
43
|
"after",
|
|
41
44
|
"first-letter",
|
|
42
45
|
"first-line",
|
|
43
46
|
"selection"
|
|
44
47
|
];
|
|
48
|
+
const PartClassesRE = /(part-\[(.+)]:)(.+)/;
|
|
45
49
|
const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
|
|
46
50
|
const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
|
|
47
51
|
const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
|
|
48
52
|
const PseudoClassesNotRE = new RegExp(`^not-(${PseudoClassesStr})[:-]`);
|
|
49
|
-
const PseudoClassesGroupRE = new RegExp(`^group-(${PseudoClassesStr})[:-]`);
|
|
50
|
-
const PseudoClassesPeerRE = new RegExp(`^peer-(${PseudoClassesStr})[:-]`);
|
|
53
|
+
const PseudoClassesGroupRE = new RegExp(`^group-((not-)?(${PseudoClassesStr}))[:-]`);
|
|
54
|
+
const PseudoClassesPeerRE = new RegExp(`^peer-((not-)?(${PseudoClassesStr}))[:-]`);
|
|
51
55
|
const variantPseudoElements = (input) => {
|
|
52
56
|
const match = input.match(PseudoElementsRE);
|
|
53
57
|
if (match) {
|
|
54
58
|
return {
|
|
55
59
|
matcher: input.slice(match[1].length + 1),
|
|
56
|
-
selector: (s
|
|
60
|
+
selector: (s) => `${s}::${match[1]}`
|
|
57
61
|
};
|
|
58
62
|
}
|
|
59
63
|
};
|
|
60
64
|
function shouldAdd(entires) {
|
|
61
|
-
return !entires.find((i) => i[0] ===
|
|
65
|
+
return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO_CLASS) || void 0;
|
|
62
66
|
}
|
|
63
67
|
const variantPseudoClasses = {
|
|
64
68
|
match: (input) => {
|
|
@@ -80,7 +84,9 @@ const variantPseudoClasses = {
|
|
|
80
84
|
}
|
|
81
85
|
match = input.match(PseudoClassesGroupRE);
|
|
82
86
|
if (match) {
|
|
83
|
-
|
|
87
|
+
let pseudo = PseudoClasses[match[3]] || match[3];
|
|
88
|
+
if (match[2])
|
|
89
|
+
pseudo = `not(:${pseudo})`;
|
|
84
90
|
return {
|
|
85
91
|
matcher: input.slice(match[1].length + 7),
|
|
86
92
|
selector: (s, body) => shouldAdd(body) && s.includes(".group:") ? s.replace(/\.group:/, `.group:${pseudo}:`) : `.group:${pseudo} ${s}`
|
|
@@ -88,14 +94,31 @@ const variantPseudoClasses = {
|
|
|
88
94
|
}
|
|
89
95
|
match = input.match(PseudoClassesPeerRE);
|
|
90
96
|
if (match) {
|
|
91
|
-
|
|
97
|
+
let pseudo = PseudoClasses[match[3]] || match[3];
|
|
98
|
+
if (match[2])
|
|
99
|
+
pseudo = `not(:${pseudo})`;
|
|
92
100
|
return {
|
|
93
101
|
matcher: input.slice(match[1].length + 6),
|
|
94
|
-
selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo}
|
|
102
|
+
selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo}~${s}`
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
multiPass: true
|
|
107
|
+
};
|
|
108
|
+
const partClasses = {
|
|
109
|
+
match: (input) => {
|
|
110
|
+
const match = input.match(PartClassesRE);
|
|
111
|
+
if (match) {
|
|
112
|
+
const part = `part(${match[2]})`;
|
|
113
|
+
return {
|
|
114
|
+
matcher: input.slice(match[1].length),
|
|
115
|
+
selector: (s, body) => {
|
|
116
|
+
return shouldAdd(body) && `${s}::${part}`;
|
|
117
|
+
}
|
|
95
118
|
};
|
|
96
119
|
}
|
|
97
120
|
},
|
|
98
121
|
multiPass: true
|
|
99
122
|
};
|
|
100
123
|
|
|
101
|
-
export {
|
|
124
|
+
export { CONTROL_BYPASS_PSEUDO_CLASS as C, PseudoClasses as P, variantPseudoElements as a, partClasses as p, variantPseudoClasses as v };
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const core = require('@unocss/core');
|
|
4
|
+
|
|
5
|
+
const directionMap = {
|
|
6
|
+
"l": ["-left"],
|
|
7
|
+
"r": ["-right"],
|
|
8
|
+
"t": ["-top"],
|
|
9
|
+
"b": ["-bottom"],
|
|
10
|
+
"s": ["-inline-start"],
|
|
11
|
+
"e": ["-inline-end"],
|
|
12
|
+
"x": ["-left", "-right"],
|
|
13
|
+
"y": ["-top", "-bottom"],
|
|
14
|
+
"": [""],
|
|
15
|
+
"a": [""]
|
|
16
|
+
};
|
|
17
|
+
const cornerMap = {
|
|
18
|
+
"t": ["-top-left", "-top-right"],
|
|
19
|
+
"r": ["-top-right", "-bottom-right"],
|
|
20
|
+
"b": ["-bottom-left", "-bottom-right"],
|
|
21
|
+
"l": ["-bottom-left", "-top-left"],
|
|
22
|
+
"tl": ["-top-left"],
|
|
23
|
+
"lt": ["-top-left"],
|
|
24
|
+
"tr": ["-top-right"],
|
|
25
|
+
"rt": ["-top-right"],
|
|
26
|
+
"bl": ["-bottom-left"],
|
|
27
|
+
"lb": ["-bottom-left"],
|
|
28
|
+
"br": ["-bottom-right"],
|
|
29
|
+
"rb": ["-bottom-right"],
|
|
30
|
+
"": [""]
|
|
31
|
+
};
|
|
32
|
+
const xyzMap = {
|
|
33
|
+
"x": ["-x"],
|
|
34
|
+
"y": ["-y"],
|
|
35
|
+
"z": ["-z"],
|
|
36
|
+
"": ["-x", "-y"]
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const cssBasicProps = [
|
|
40
|
+
"color",
|
|
41
|
+
"border-color",
|
|
42
|
+
"background-color",
|
|
43
|
+
"flex-grow",
|
|
44
|
+
"flex",
|
|
45
|
+
"flex-shrink",
|
|
46
|
+
"caret-color",
|
|
47
|
+
"font",
|
|
48
|
+
"gap",
|
|
49
|
+
"opacity",
|
|
50
|
+
"visibility",
|
|
51
|
+
"z-index",
|
|
52
|
+
"font-weight",
|
|
53
|
+
"zoom",
|
|
54
|
+
"text-shadow",
|
|
55
|
+
"transform",
|
|
56
|
+
"box-shadow"
|
|
57
|
+
];
|
|
58
|
+
const cssPositionProps = [
|
|
59
|
+
"backround-position",
|
|
60
|
+
"left",
|
|
61
|
+
"right",
|
|
62
|
+
"top",
|
|
63
|
+
"bottom",
|
|
64
|
+
"object-position"
|
|
65
|
+
];
|
|
66
|
+
const cssSizeProps = [
|
|
67
|
+
"max-height",
|
|
68
|
+
"min-height",
|
|
69
|
+
"max-width",
|
|
70
|
+
"min-width",
|
|
71
|
+
"height",
|
|
72
|
+
"width",
|
|
73
|
+
"border-width",
|
|
74
|
+
"margin",
|
|
75
|
+
"padding",
|
|
76
|
+
"outline-width",
|
|
77
|
+
"outline-offset",
|
|
78
|
+
"font-size",
|
|
79
|
+
"line-height",
|
|
80
|
+
"text-indent",
|
|
81
|
+
"vertical-align",
|
|
82
|
+
"border-spacing",
|
|
83
|
+
"letter-spacing",
|
|
84
|
+
"word-spacing"
|
|
85
|
+
];
|
|
86
|
+
const cssEnhanceProps = ["stroke", "filter", "backdrop-filter", "fill", "mask", "mask-size", "mask-border", "clip-path", "clip"];
|
|
87
|
+
const cssProps = [
|
|
88
|
+
...cssBasicProps,
|
|
89
|
+
...cssPositionProps,
|
|
90
|
+
...cssSizeProps,
|
|
91
|
+
...cssEnhanceProps
|
|
92
|
+
];
|
|
93
|
+
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
94
|
+
const numberRE = /^(-?[0-9.]+)$/i;
|
|
95
|
+
const unitOnlyRE = /^(px)$/i;
|
|
96
|
+
function numberWithUnit(str) {
|
|
97
|
+
const match = str.match(numberWithUnitRE);
|
|
98
|
+
if (!match)
|
|
99
|
+
return;
|
|
100
|
+
const [, , unit] = match;
|
|
101
|
+
if (unit)
|
|
102
|
+
return str;
|
|
103
|
+
}
|
|
104
|
+
function auto(str) {
|
|
105
|
+
if (str === "auto" || str === "a")
|
|
106
|
+
return "auto";
|
|
107
|
+
}
|
|
108
|
+
function rem(str) {
|
|
109
|
+
if (str.match(unitOnlyRE))
|
|
110
|
+
return `1${str}`;
|
|
111
|
+
const match = str.match(numberWithUnitRE);
|
|
112
|
+
if (!match)
|
|
113
|
+
return;
|
|
114
|
+
const [, n, unit] = match;
|
|
115
|
+
if (unit)
|
|
116
|
+
return str;
|
|
117
|
+
const num = parseFloat(n);
|
|
118
|
+
if (!Number.isNaN(num))
|
|
119
|
+
return `${num / 4}rem`;
|
|
120
|
+
}
|
|
121
|
+
function px(str) {
|
|
122
|
+
if (str.match(unitOnlyRE))
|
|
123
|
+
return `1${str}`;
|
|
124
|
+
const match = str.match(numberWithUnitRE);
|
|
125
|
+
if (!match)
|
|
126
|
+
return;
|
|
127
|
+
const [, n, unit] = match;
|
|
128
|
+
if (unit)
|
|
129
|
+
return str;
|
|
130
|
+
const num = parseFloat(n);
|
|
131
|
+
if (!Number.isNaN(num))
|
|
132
|
+
return `${num}px`;
|
|
133
|
+
}
|
|
134
|
+
function number(str) {
|
|
135
|
+
if (!numberRE.test(str))
|
|
136
|
+
return;
|
|
137
|
+
const num = parseFloat(str);
|
|
138
|
+
if (!Number.isNaN(num))
|
|
139
|
+
return num;
|
|
140
|
+
}
|
|
141
|
+
function percent(str) {
|
|
142
|
+
if (str.endsWith("%"))
|
|
143
|
+
str = str.slice(0, -1);
|
|
144
|
+
const num = parseFloat(str);
|
|
145
|
+
if (!Number.isNaN(num))
|
|
146
|
+
return `${num / 100}`;
|
|
147
|
+
}
|
|
148
|
+
function fraction(str) {
|
|
149
|
+
if (str === "full")
|
|
150
|
+
return "100%";
|
|
151
|
+
const [left, right] = str.split("/");
|
|
152
|
+
const num = parseFloat(left) / parseFloat(right);
|
|
153
|
+
if (!Number.isNaN(num))
|
|
154
|
+
return `${num * 100}%`;
|
|
155
|
+
}
|
|
156
|
+
function bracket(str) {
|
|
157
|
+
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
158
|
+
return str.slice(1, -1).replace(/_/g, " ").replace(/calc\((.*)/g, (v) => {
|
|
159
|
+
return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function cssvar(str) {
|
|
164
|
+
if (str.startsWith("$"))
|
|
165
|
+
return `var(--${str.slice(1)})`;
|
|
166
|
+
}
|
|
167
|
+
function time(str) {
|
|
168
|
+
const duration = Number(str.replace(/(s|ms)$/, ""));
|
|
169
|
+
if (isNaN(duration))
|
|
170
|
+
return;
|
|
171
|
+
if (/(s|ms)$/.test(str))
|
|
172
|
+
return str;
|
|
173
|
+
return `${str}ms`;
|
|
174
|
+
}
|
|
175
|
+
function global(str) {
|
|
176
|
+
if (["inherit", "initial", "revert", "unset"].includes(str))
|
|
177
|
+
return str;
|
|
178
|
+
}
|
|
179
|
+
function properties(str) {
|
|
180
|
+
if (str === void 0)
|
|
181
|
+
return;
|
|
182
|
+
for (const prop of str.split(",")) {
|
|
183
|
+
if (!cssProps.includes(prop))
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
return str;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const valueHandlers = {
|
|
190
|
+
__proto__: null,
|
|
191
|
+
numberWithUnit: numberWithUnit,
|
|
192
|
+
auto: auto,
|
|
193
|
+
rem: rem,
|
|
194
|
+
px: px,
|
|
195
|
+
number: number,
|
|
196
|
+
percent: percent,
|
|
197
|
+
fraction: fraction,
|
|
198
|
+
bracket: bracket,
|
|
199
|
+
cssvar: cssvar,
|
|
200
|
+
time: time,
|
|
201
|
+
global: global,
|
|
202
|
+
properties: properties
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const handler = core.createValueHandler(valueHandlers);
|
|
206
|
+
const h = handler;
|
|
207
|
+
|
|
208
|
+
function capitalize(str) {
|
|
209
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
210
|
+
}
|
|
211
|
+
const directionSize = (propertyPrefix) => ([_, direction, size]) => {
|
|
212
|
+
const v = handler.bracket.auto.rem.fraction.cssvar(size);
|
|
213
|
+
if (v !== void 0)
|
|
214
|
+
return directionMap[direction].map((i) => [`${propertyPrefix}${i}`, v]);
|
|
215
|
+
};
|
|
216
|
+
const getThemeColor = (theme, colors) => theme.colors?.[colors.join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase())];
|
|
217
|
+
const parseColor = (body, theme) => {
|
|
218
|
+
const [main, opacity] = body.split(/(?:\/|:)/);
|
|
219
|
+
const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
|
|
220
|
+
const [name] = colors;
|
|
221
|
+
if (!name)
|
|
222
|
+
return;
|
|
223
|
+
let color;
|
|
224
|
+
const bracket = handler.bracket(main);
|
|
225
|
+
const bracketOrMain = bracket || main;
|
|
226
|
+
if (bracketOrMain.startsWith("#"))
|
|
227
|
+
color = bracketOrMain.slice(1);
|
|
228
|
+
if (bracketOrMain.startsWith("hex-"))
|
|
229
|
+
color = bracketOrMain.slice(4);
|
|
230
|
+
color = color || bracket;
|
|
231
|
+
let no = "DEFAULT";
|
|
232
|
+
if (!color) {
|
|
233
|
+
let colorData;
|
|
234
|
+
const [scale] = colors.slice(-1);
|
|
235
|
+
if (scale.match(/^\d+$/)) {
|
|
236
|
+
no = scale;
|
|
237
|
+
colorData = getThemeColor(theme, colors.slice(0, -1));
|
|
238
|
+
} else {
|
|
239
|
+
colorData = getThemeColor(theme, colors);
|
|
240
|
+
if (!colorData) {
|
|
241
|
+
[, no = no] = colors;
|
|
242
|
+
colorData = getThemeColor(theme, [name]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (typeof colorData === "string")
|
|
246
|
+
color = colorData;
|
|
247
|
+
else if (no && colorData)
|
|
248
|
+
color = colorData[no];
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
opacity,
|
|
252
|
+
name,
|
|
253
|
+
no,
|
|
254
|
+
color,
|
|
255
|
+
rgba: core.hex2rgba(color)
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
259
|
+
const data = parseColor(body, theme);
|
|
260
|
+
if (!data)
|
|
261
|
+
return;
|
|
262
|
+
const { opacity, color, rgba } = data;
|
|
263
|
+
if (!color)
|
|
264
|
+
return;
|
|
265
|
+
const a = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba?.[3];
|
|
266
|
+
if (rgba) {
|
|
267
|
+
if (a != null && !Number.isNaN(a)) {
|
|
268
|
+
rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
|
|
269
|
+
return {
|
|
270
|
+
[property]: `rgba(${rgba.join(",")})`
|
|
271
|
+
};
|
|
272
|
+
} else {
|
|
273
|
+
return {
|
|
274
|
+
[`--un-${varName}-opacity`]: 1,
|
|
275
|
+
[property]: `rgba(${rgba.slice(0, 3).join(",")},var(--un-${varName}-opacity))`
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
return {
|
|
280
|
+
[property]: color.replace("%alpha", `${a || 1}`)
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
exports.capitalize = capitalize;
|
|
286
|
+
exports.colorResolver = colorResolver;
|
|
287
|
+
exports.cornerMap = cornerMap;
|
|
288
|
+
exports.directionMap = directionMap;
|
|
289
|
+
exports.directionSize = directionSize;
|
|
290
|
+
exports.h = h;
|
|
291
|
+
exports.handler = handler;
|
|
292
|
+
exports.parseColor = parseColor;
|
|
293
|
+
exports.valueHandlers = valueHandlers;
|
|
294
|
+
exports.xyzMap = xyzMap;
|