@unocss/preset-mini 0.20.2 → 0.21.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.
- package/dist/chunks/default.cjs +8 -10
- package/dist/chunks/default.mjs +8 -10
- package/dist/chunks/default2.cjs +172 -163
- package/dist/chunks/default2.mjs +173 -164
- package/dist/chunks/default3.cjs +14 -32
- package/dist/chunks/default3.mjs +15 -32
- package/dist/chunks/pseudo.cjs +21 -16
- package/dist/chunks/pseudo.mjs +21 -16
- package/dist/chunks/utilities.cjs +67 -34
- package/dist/chunks/utilities.mjs +67 -35
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/theme.d.ts +0 -10
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.ts +8 -4
- package/dist/utils.mjs +1 -1
- package/dist/variants.cjs +0 -1
- package/dist/variants.d.ts +7 -5
- package/dist/variants.mjs +1 -1
- package/package.json +2 -2
package/dist/chunks/default3.mjs
CHANGED
|
@@ -44,24 +44,18 @@ const variantCombinators = [
|
|
|
44
44
|
variantMatcher("svg", (input) => `${input} svg *`)
|
|
45
45
|
];
|
|
46
46
|
|
|
47
|
-
const variantColorsMediaOrClass =
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (dark === "class")
|
|
54
|
-
return variantMatcher("light", (input) => `.light $$ ${input}`)(v);
|
|
55
|
-
},
|
|
56
|
-
(v, { options: { dark } }) => {
|
|
57
|
-
if (dark === "media")
|
|
58
|
-
return variantParentMatcher("dark", "@media (prefers-color-scheme: dark)")(v);
|
|
59
|
-
},
|
|
60
|
-
(v, { options: { dark } }) => {
|
|
61
|
-
if (dark === "media")
|
|
62
|
-
return variantParentMatcher("light", "@media (prefers-color-scheme: light)")(v);
|
|
47
|
+
const variantColorsMediaOrClass = (options = {}) => {
|
|
48
|
+
if (options?.dark === "class") {
|
|
49
|
+
return [
|
|
50
|
+
variantMatcher("dark", (input) => `.dark $$ ${input}`),
|
|
51
|
+
variantMatcher("light", (input) => `.light $$ ${input}`)
|
|
52
|
+
];
|
|
63
53
|
}
|
|
64
|
-
|
|
54
|
+
return [
|
|
55
|
+
variantParentMatcher("dark", "@media (prefers-color-scheme: dark)"),
|
|
56
|
+
variantParentMatcher("light", "@media (prefers-color-scheme: light)")
|
|
57
|
+
];
|
|
58
|
+
};
|
|
65
59
|
|
|
66
60
|
const variantLanguageDirections = [
|
|
67
61
|
variantMatcher("rtl", (input) => `[dir="rtl"] $$ ${input}`),
|
|
@@ -101,16 +95,6 @@ const variantNegative = {
|
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
};
|
|
104
|
-
const variantSpace = (matcher) => {
|
|
105
|
-
if (/^space-?([xy])-?(-?.+)$/.test(matcher) || /^divide-/.test(matcher)) {
|
|
106
|
-
return {
|
|
107
|
-
matcher,
|
|
108
|
-
selector: (input) => {
|
|
109
|
-
return `${input}>:not([hidden])~:not([hidden])`;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
98
|
|
|
115
99
|
const variantMotions = [
|
|
116
100
|
variantParentMatcher("motion-reduce", "@media (prefers-reduced-motion: reduce)"),
|
|
@@ -124,8 +108,7 @@ const variantOrientations = [
|
|
|
124
108
|
|
|
125
109
|
const variantPrint = variantParentMatcher("print", "@media print");
|
|
126
110
|
|
|
127
|
-
const variants = [
|
|
128
|
-
variantSpace,
|
|
111
|
+
const variants = (options) => [
|
|
129
112
|
variantNegative,
|
|
130
113
|
variantImportant,
|
|
131
114
|
variantPrint,
|
|
@@ -135,11 +118,11 @@ const variants = [
|
|
|
135
118
|
...variantCombinators,
|
|
136
119
|
variantPseudoClasses,
|
|
137
120
|
variantPseudoClassFunctions,
|
|
138
|
-
variantTaggedPseudoClasses,
|
|
121
|
+
...variantTaggedPseudoClasses(options),
|
|
139
122
|
variantPseudoElements,
|
|
140
123
|
partClasses,
|
|
141
|
-
...variantColorsMediaOrClass,
|
|
124
|
+
...variantColorsMediaOrClass(options),
|
|
142
125
|
...variantLanguageDirections
|
|
143
126
|
];
|
|
144
127
|
|
|
145
|
-
export { variantBreakpoints as a, variantCombinators as b, variantColorsMediaOrClass as c, variantLanguageDirections as d, variantImportant as e, variantNegative as f,
|
|
128
|
+
export { variantBreakpoints as a, variantCombinators as b, variantColorsMediaOrClass as c, variantLanguageDirections as d, variantImportant as e, variantNegative as f, variantMotions as g, variantOrientations as h, variantPrint as i, variants as v };
|
package/dist/chunks/pseudo.cjs
CHANGED
|
@@ -42,25 +42,27 @@ const PseudoClasses = Object.fromEntries([
|
|
|
42
42
|
"only-child",
|
|
43
43
|
"only-of-type"
|
|
44
44
|
].map(core.toArray));
|
|
45
|
-
const PseudoElements = [
|
|
45
|
+
const PseudoElements = Object.fromEntries([
|
|
46
46
|
"placeholder",
|
|
47
47
|
"before",
|
|
48
48
|
"after",
|
|
49
49
|
"first-letter",
|
|
50
50
|
"first-line",
|
|
51
51
|
"selection",
|
|
52
|
-
"marker"
|
|
53
|
-
]
|
|
52
|
+
"marker",
|
|
53
|
+
["file", "::file-selector-button"]
|
|
54
|
+
].map(core.toArray));
|
|
54
55
|
const PseudoClassFunctions = [
|
|
55
56
|
"not",
|
|
56
57
|
"is",
|
|
57
58
|
"where",
|
|
58
59
|
"has"
|
|
59
60
|
];
|
|
60
|
-
const
|
|
61
|
-
const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
|
|
61
|
+
const PseudoElementsStr = Object.keys(PseudoElements).join("|");
|
|
62
62
|
const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
|
|
63
63
|
const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
|
|
64
|
+
const PartClassesRE = /(part-\[(.+)]:)(.+)/;
|
|
65
|
+
const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
|
|
64
66
|
const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
|
|
65
67
|
const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
|
|
66
68
|
function shouldAdd(entires) {
|
|
@@ -87,9 +89,10 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
|
|
|
87
89
|
const variantPseudoElements = (input) => {
|
|
88
90
|
const match = input.match(PseudoElementsRE);
|
|
89
91
|
if (match) {
|
|
92
|
+
const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
|
|
90
93
|
return {
|
|
91
94
|
matcher: input.slice(match[1].length + 1),
|
|
92
|
-
selector: (s) => `${s}
|
|
95
|
+
selector: (s) => `${s}${pseudo}`
|
|
93
96
|
};
|
|
94
97
|
}
|
|
95
98
|
};
|
|
@@ -120,16 +123,18 @@ const variantPseudoClassFunctions = {
|
|
|
120
123
|
},
|
|
121
124
|
multiPass: true
|
|
122
125
|
};
|
|
123
|
-
const variantTaggedPseudoClasses = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
const variantTaggedPseudoClasses = (options = {}) => {
|
|
127
|
+
const attributify = !!options?.attributifyPseudo;
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
|
|
131
|
+
multiPass: true
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
|
|
135
|
+
multiPass: true
|
|
136
|
+
}
|
|
137
|
+
];
|
|
133
138
|
};
|
|
134
139
|
const partClasses = {
|
|
135
140
|
match: (input) => {
|
package/dist/chunks/pseudo.mjs
CHANGED
|
@@ -40,25 +40,27 @@ const PseudoClasses = Object.fromEntries([
|
|
|
40
40
|
"only-child",
|
|
41
41
|
"only-of-type"
|
|
42
42
|
].map(toArray));
|
|
43
|
-
const PseudoElements = [
|
|
43
|
+
const PseudoElements = Object.fromEntries([
|
|
44
44
|
"placeholder",
|
|
45
45
|
"before",
|
|
46
46
|
"after",
|
|
47
47
|
"first-letter",
|
|
48
48
|
"first-line",
|
|
49
49
|
"selection",
|
|
50
|
-
"marker"
|
|
51
|
-
]
|
|
50
|
+
"marker",
|
|
51
|
+
["file", "::file-selector-button"]
|
|
52
|
+
].map(toArray));
|
|
52
53
|
const PseudoClassFunctions = [
|
|
53
54
|
"not",
|
|
54
55
|
"is",
|
|
55
56
|
"where",
|
|
56
57
|
"has"
|
|
57
58
|
];
|
|
58
|
-
const
|
|
59
|
-
const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
|
|
59
|
+
const PseudoElementsStr = Object.keys(PseudoElements).join("|");
|
|
60
60
|
const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
|
|
61
61
|
const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
|
|
62
|
+
const PartClassesRE = /(part-\[(.+)]:)(.+)/;
|
|
63
|
+
const PseudoElementsRE = new RegExp(`^(${PseudoElementsStr})[:-]`);
|
|
62
64
|
const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
|
|
63
65
|
const PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})[:-]`);
|
|
64
66
|
function shouldAdd(entires) {
|
|
@@ -85,9 +87,10 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
|
|
|
85
87
|
const variantPseudoElements = (input) => {
|
|
86
88
|
const match = input.match(PseudoElementsRE);
|
|
87
89
|
if (match) {
|
|
90
|
+
const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
|
|
88
91
|
return {
|
|
89
92
|
matcher: input.slice(match[1].length + 1),
|
|
90
|
-
selector: (s) => `${s}
|
|
93
|
+
selector: (s) => `${s}${pseudo}`
|
|
91
94
|
};
|
|
92
95
|
}
|
|
93
96
|
};
|
|
@@ -118,16 +121,18 @@ const variantPseudoClassFunctions = {
|
|
|
118
121
|
},
|
|
119
122
|
multiPass: true
|
|
120
123
|
};
|
|
121
|
-
const variantTaggedPseudoClasses = {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
const variantTaggedPseudoClasses = (options = {}) => {
|
|
125
|
+
const attributify = !!options?.attributifyPseudo;
|
|
126
|
+
return [
|
|
127
|
+
{
|
|
128
|
+
match: taggedPseudoClassMatcher("group", attributify ? '[group=""]' : ".group", " "),
|
|
129
|
+
multiPass: true
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
|
|
133
|
+
multiPass: true
|
|
134
|
+
}
|
|
135
|
+
];
|
|
131
136
|
};
|
|
132
137
|
const partClasses = {
|
|
133
138
|
match: (input) => {
|
|
@@ -35,8 +35,33 @@ const xyzMap = {
|
|
|
35
35
|
"z": ["-z"],
|
|
36
36
|
"": ["-x", "-y"]
|
|
37
37
|
};
|
|
38
|
+
const basePositionMap = [
|
|
39
|
+
"top",
|
|
40
|
+
"top center",
|
|
41
|
+
"top left",
|
|
42
|
+
"top right",
|
|
43
|
+
"bottom",
|
|
44
|
+
"bottom center",
|
|
45
|
+
"bottom left",
|
|
46
|
+
"bottom right",
|
|
47
|
+
"left",
|
|
48
|
+
"left center",
|
|
49
|
+
"left top",
|
|
50
|
+
"left bottom",
|
|
51
|
+
"right",
|
|
52
|
+
"right center",
|
|
53
|
+
"right top",
|
|
54
|
+
"right bottom",
|
|
55
|
+
"center",
|
|
56
|
+
"center top",
|
|
57
|
+
"center bottom",
|
|
58
|
+
"center left",
|
|
59
|
+
"center right",
|
|
60
|
+
"center center"
|
|
61
|
+
];
|
|
62
|
+
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
38
63
|
|
|
39
|
-
const
|
|
64
|
+
const cssProps = [
|
|
40
65
|
"color",
|
|
41
66
|
"border-color",
|
|
42
67
|
"background-color",
|
|
@@ -53,17 +78,13 @@ const cssBasicProps = [
|
|
|
53
78
|
"zoom",
|
|
54
79
|
"text-shadow",
|
|
55
80
|
"transform",
|
|
56
|
-
"box-shadow"
|
|
57
|
-
];
|
|
58
|
-
const cssPositionProps = [
|
|
81
|
+
"box-shadow",
|
|
59
82
|
"backround-position",
|
|
60
83
|
"left",
|
|
61
84
|
"right",
|
|
62
85
|
"top",
|
|
63
86
|
"bottom",
|
|
64
|
-
"object-position"
|
|
65
|
-
];
|
|
66
|
-
const cssSizeProps = [
|
|
87
|
+
"object-position",
|
|
67
88
|
"max-height",
|
|
68
89
|
"min-height",
|
|
69
90
|
"max-width",
|
|
@@ -81,25 +102,31 @@ const cssSizeProps = [
|
|
|
81
102
|
"vertical-align",
|
|
82
103
|
"border-spacing",
|
|
83
104
|
"letter-spacing",
|
|
84
|
-
"word-spacing"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
105
|
+
"word-spacing",
|
|
106
|
+
"stroke",
|
|
107
|
+
"filter",
|
|
108
|
+
"backdrop-filter",
|
|
109
|
+
"fill",
|
|
110
|
+
"mask",
|
|
111
|
+
"mask-size",
|
|
112
|
+
"mask-border",
|
|
113
|
+
"clip-path",
|
|
114
|
+
"clip"
|
|
92
115
|
];
|
|
93
116
|
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
94
117
|
const numberRE = /^(-?[0-9.]+)$/i;
|
|
95
118
|
const unitOnlyRE = /^(px)$/i;
|
|
119
|
+
function round(n) {
|
|
120
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
121
|
+
}
|
|
96
122
|
function numberWithUnit(str) {
|
|
97
123
|
const match = str.match(numberWithUnitRE);
|
|
98
124
|
if (!match)
|
|
99
125
|
return;
|
|
100
|
-
const [, , unit] = match;
|
|
101
|
-
|
|
102
|
-
|
|
126
|
+
const [, n, unit] = match;
|
|
127
|
+
const num = parseFloat(n);
|
|
128
|
+
if (unit && !Number.isNaN(num))
|
|
129
|
+
return `${round(num)}${unit}`;
|
|
103
130
|
}
|
|
104
131
|
function auto(str) {
|
|
105
132
|
if (str === "auto" || str === "a")
|
|
@@ -112,11 +139,9 @@ function rem(str) {
|
|
|
112
139
|
if (!match)
|
|
113
140
|
return;
|
|
114
141
|
const [, n, unit] = match;
|
|
115
|
-
if (unit)
|
|
116
|
-
return str;
|
|
117
142
|
const num = parseFloat(n);
|
|
118
143
|
if (!Number.isNaN(num))
|
|
119
|
-
return `${num / 4}rem`;
|
|
144
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
120
145
|
}
|
|
121
146
|
function px(str) {
|
|
122
147
|
if (str.match(unitOnlyRE))
|
|
@@ -125,25 +150,23 @@ function px(str) {
|
|
|
125
150
|
if (!match)
|
|
126
151
|
return;
|
|
127
152
|
const [, n, unit] = match;
|
|
128
|
-
if (unit)
|
|
129
|
-
return str;
|
|
130
153
|
const num = parseFloat(n);
|
|
131
154
|
if (!Number.isNaN(num))
|
|
132
|
-
return `${num}px`;
|
|
155
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
133
156
|
}
|
|
134
157
|
function number(str) {
|
|
135
158
|
if (!numberRE.test(str))
|
|
136
159
|
return;
|
|
137
160
|
const num = parseFloat(str);
|
|
138
161
|
if (!Number.isNaN(num))
|
|
139
|
-
return num;
|
|
162
|
+
return round(num);
|
|
140
163
|
}
|
|
141
164
|
function percent(str) {
|
|
142
165
|
if (str.endsWith("%"))
|
|
143
166
|
str = str.slice(0, -1);
|
|
144
167
|
const num = parseFloat(str);
|
|
145
168
|
if (!Number.isNaN(num))
|
|
146
|
-
return `${num / 100}`;
|
|
169
|
+
return `${round(num / 100)}`;
|
|
147
170
|
}
|
|
148
171
|
function fraction(str) {
|
|
149
172
|
if (str === "full")
|
|
@@ -151,7 +174,7 @@ function fraction(str) {
|
|
|
151
174
|
const [left, right] = str.split("/");
|
|
152
175
|
const num = parseFloat(left) / parseFloat(right);
|
|
153
176
|
if (!Number.isNaN(num))
|
|
154
|
-
return `${num * 100}%`;
|
|
177
|
+
return `${round(num * 100)}%`;
|
|
155
178
|
}
|
|
156
179
|
function bracket(str) {
|
|
157
180
|
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
@@ -165,20 +188,28 @@ function cssvar(str) {
|
|
|
165
188
|
return `var(--${str.slice(1)})`;
|
|
166
189
|
}
|
|
167
190
|
function time(str) {
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
191
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
192
|
+
if (!match)
|
|
170
193
|
return;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
194
|
+
const [, n, unit] = match;
|
|
195
|
+
const num = parseFloat(n);
|
|
196
|
+
if (!Number.isNaN(num))
|
|
197
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
198
|
+
}
|
|
199
|
+
function degree(str) {
|
|
200
|
+
const match = str.match(/^(-?[0-9.]+)(deg)?$/i);
|
|
201
|
+
if (!match)
|
|
202
|
+
return;
|
|
203
|
+
const [, n, unit] = match;
|
|
204
|
+
const num = parseFloat(n);
|
|
205
|
+
if (!Number.isNaN(num))
|
|
206
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
174
207
|
}
|
|
175
208
|
function global(str) {
|
|
176
209
|
if (["inherit", "initial", "revert", "unset"].includes(str))
|
|
177
210
|
return str;
|
|
178
211
|
}
|
|
179
212
|
function properties(str) {
|
|
180
|
-
if (str === void 0)
|
|
181
|
-
return;
|
|
182
213
|
for (const prop of str.split(",")) {
|
|
183
214
|
if (!cssProps.includes(prop))
|
|
184
215
|
return;
|
|
@@ -198,6 +229,7 @@ const valueHandlers = {
|
|
|
198
229
|
bracket: bracket,
|
|
199
230
|
cssvar: cssvar,
|
|
200
231
|
time: time,
|
|
232
|
+
degree: degree,
|
|
201
233
|
global: global,
|
|
202
234
|
properties: properties
|
|
203
235
|
};
|
|
@@ -301,5 +333,6 @@ exports.directionSize = directionSize;
|
|
|
301
333
|
exports.h = h;
|
|
302
334
|
exports.handler = handler;
|
|
303
335
|
exports.parseColor = parseColor;
|
|
336
|
+
exports.positionMap = positionMap;
|
|
304
337
|
exports.valueHandlers = valueHandlers;
|
|
305
338
|
exports.xyzMap = xyzMap;
|
|
@@ -33,8 +33,33 @@ const xyzMap = {
|
|
|
33
33
|
"z": ["-z"],
|
|
34
34
|
"": ["-x", "-y"]
|
|
35
35
|
};
|
|
36
|
+
const basePositionMap = [
|
|
37
|
+
"top",
|
|
38
|
+
"top center",
|
|
39
|
+
"top left",
|
|
40
|
+
"top right",
|
|
41
|
+
"bottom",
|
|
42
|
+
"bottom center",
|
|
43
|
+
"bottom left",
|
|
44
|
+
"bottom right",
|
|
45
|
+
"left",
|
|
46
|
+
"left center",
|
|
47
|
+
"left top",
|
|
48
|
+
"left bottom",
|
|
49
|
+
"right",
|
|
50
|
+
"right center",
|
|
51
|
+
"right top",
|
|
52
|
+
"right bottom",
|
|
53
|
+
"center",
|
|
54
|
+
"center top",
|
|
55
|
+
"center bottom",
|
|
56
|
+
"center left",
|
|
57
|
+
"center right",
|
|
58
|
+
"center center"
|
|
59
|
+
];
|
|
60
|
+
const positionMap = Object.assign({}, ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })), ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p })));
|
|
36
61
|
|
|
37
|
-
const
|
|
62
|
+
const cssProps = [
|
|
38
63
|
"color",
|
|
39
64
|
"border-color",
|
|
40
65
|
"background-color",
|
|
@@ -51,17 +76,13 @@ const cssBasicProps = [
|
|
|
51
76
|
"zoom",
|
|
52
77
|
"text-shadow",
|
|
53
78
|
"transform",
|
|
54
|
-
"box-shadow"
|
|
55
|
-
];
|
|
56
|
-
const cssPositionProps = [
|
|
79
|
+
"box-shadow",
|
|
57
80
|
"backround-position",
|
|
58
81
|
"left",
|
|
59
82
|
"right",
|
|
60
83
|
"top",
|
|
61
84
|
"bottom",
|
|
62
|
-
"object-position"
|
|
63
|
-
];
|
|
64
|
-
const cssSizeProps = [
|
|
85
|
+
"object-position",
|
|
65
86
|
"max-height",
|
|
66
87
|
"min-height",
|
|
67
88
|
"max-width",
|
|
@@ -79,25 +100,31 @@ const cssSizeProps = [
|
|
|
79
100
|
"vertical-align",
|
|
80
101
|
"border-spacing",
|
|
81
102
|
"letter-spacing",
|
|
82
|
-
"word-spacing"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
"word-spacing",
|
|
104
|
+
"stroke",
|
|
105
|
+
"filter",
|
|
106
|
+
"backdrop-filter",
|
|
107
|
+
"fill",
|
|
108
|
+
"mask",
|
|
109
|
+
"mask-size",
|
|
110
|
+
"mask-border",
|
|
111
|
+
"clip-path",
|
|
112
|
+
"clip"
|
|
90
113
|
];
|
|
91
114
|
const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
|
|
92
115
|
const numberRE = /^(-?[0-9.]+)$/i;
|
|
93
116
|
const unitOnlyRE = /^(px)$/i;
|
|
117
|
+
function round(n) {
|
|
118
|
+
return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
|
|
119
|
+
}
|
|
94
120
|
function numberWithUnit(str) {
|
|
95
121
|
const match = str.match(numberWithUnitRE);
|
|
96
122
|
if (!match)
|
|
97
123
|
return;
|
|
98
|
-
const [, , unit] = match;
|
|
99
|
-
|
|
100
|
-
|
|
124
|
+
const [, n, unit] = match;
|
|
125
|
+
const num = parseFloat(n);
|
|
126
|
+
if (unit && !Number.isNaN(num))
|
|
127
|
+
return `${round(num)}${unit}`;
|
|
101
128
|
}
|
|
102
129
|
function auto(str) {
|
|
103
130
|
if (str === "auto" || str === "a")
|
|
@@ -110,11 +137,9 @@ function rem(str) {
|
|
|
110
137
|
if (!match)
|
|
111
138
|
return;
|
|
112
139
|
const [, n, unit] = match;
|
|
113
|
-
if (unit)
|
|
114
|
-
return str;
|
|
115
140
|
const num = parseFloat(n);
|
|
116
141
|
if (!Number.isNaN(num))
|
|
117
|
-
return `${num / 4}rem`;
|
|
142
|
+
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
118
143
|
}
|
|
119
144
|
function px(str) {
|
|
120
145
|
if (str.match(unitOnlyRE))
|
|
@@ -123,25 +148,23 @@ function px(str) {
|
|
|
123
148
|
if (!match)
|
|
124
149
|
return;
|
|
125
150
|
const [, n, unit] = match;
|
|
126
|
-
if (unit)
|
|
127
|
-
return str;
|
|
128
151
|
const num = parseFloat(n);
|
|
129
152
|
if (!Number.isNaN(num))
|
|
130
|
-
return `${num}px`;
|
|
153
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
131
154
|
}
|
|
132
155
|
function number(str) {
|
|
133
156
|
if (!numberRE.test(str))
|
|
134
157
|
return;
|
|
135
158
|
const num = parseFloat(str);
|
|
136
159
|
if (!Number.isNaN(num))
|
|
137
|
-
return num;
|
|
160
|
+
return round(num);
|
|
138
161
|
}
|
|
139
162
|
function percent(str) {
|
|
140
163
|
if (str.endsWith("%"))
|
|
141
164
|
str = str.slice(0, -1);
|
|
142
165
|
const num = parseFloat(str);
|
|
143
166
|
if (!Number.isNaN(num))
|
|
144
|
-
return `${num / 100}`;
|
|
167
|
+
return `${round(num / 100)}`;
|
|
145
168
|
}
|
|
146
169
|
function fraction(str) {
|
|
147
170
|
if (str === "full")
|
|
@@ -149,7 +172,7 @@ function fraction(str) {
|
|
|
149
172
|
const [left, right] = str.split("/");
|
|
150
173
|
const num = parseFloat(left) / parseFloat(right);
|
|
151
174
|
if (!Number.isNaN(num))
|
|
152
|
-
return `${num * 100}%`;
|
|
175
|
+
return `${round(num * 100)}%`;
|
|
153
176
|
}
|
|
154
177
|
function bracket(str) {
|
|
155
178
|
if (str && str[0] === "[" && str[str.length - 1] === "]") {
|
|
@@ -163,20 +186,28 @@ function cssvar(str) {
|
|
|
163
186
|
return `var(--${str.slice(1)})`;
|
|
164
187
|
}
|
|
165
188
|
function time(str) {
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
189
|
+
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
190
|
+
if (!match)
|
|
168
191
|
return;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
192
|
+
const [, n, unit] = match;
|
|
193
|
+
const num = parseFloat(n);
|
|
194
|
+
if (!Number.isNaN(num))
|
|
195
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
196
|
+
}
|
|
197
|
+
function degree(str) {
|
|
198
|
+
const match = str.match(/^(-?[0-9.]+)(deg)?$/i);
|
|
199
|
+
if (!match)
|
|
200
|
+
return;
|
|
201
|
+
const [, n, unit] = match;
|
|
202
|
+
const num = parseFloat(n);
|
|
203
|
+
if (!Number.isNaN(num))
|
|
204
|
+
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
172
205
|
}
|
|
173
206
|
function global(str) {
|
|
174
207
|
if (["inherit", "initial", "revert", "unset"].includes(str))
|
|
175
208
|
return str;
|
|
176
209
|
}
|
|
177
210
|
function properties(str) {
|
|
178
|
-
if (str === void 0)
|
|
179
|
-
return;
|
|
180
211
|
for (const prop of str.split(",")) {
|
|
181
212
|
if (!cssProps.includes(prop))
|
|
182
213
|
return;
|
|
@@ -196,6 +227,7 @@ const valueHandlers = {
|
|
|
196
227
|
bracket: bracket,
|
|
197
228
|
cssvar: cssvar,
|
|
198
229
|
time: time,
|
|
230
|
+
degree: degree,
|
|
199
231
|
global: global,
|
|
200
232
|
properties: properties
|
|
201
233
|
};
|
|
@@ -291,4 +323,4 @@ const colorResolver = (property, varName) => ([, body], { theme }) => {
|
|
|
291
323
|
}
|
|
292
324
|
};
|
|
293
325
|
|
|
294
|
-
export { cornerMap as a, capitalize as b, colorResolver as c, directionMap as d, directionSize as e,
|
|
326
|
+
export { cornerMap as a, capitalize as b, colorResolver as c, directionMap as d, directionSize as e, positionMap as f, h as g, handler as h, parseColor as p, valueHandlers as v, xyzMap as x };
|
package/dist/index.cjs
CHANGED
|
@@ -18,7 +18,7 @@ const presetMini = (options = {}) => {
|
|
|
18
18
|
name: "@unocss/preset-mini",
|
|
19
19
|
theme: _default.theme,
|
|
20
20
|
rules: _default$1.rules,
|
|
21
|
-
variants: _default$2.variants,
|
|
21
|
+
variants: _default$2.variants(options),
|
|
22
22
|
options,
|
|
23
23
|
postprocess: options.variablePrefix && options.variablePrefix !== "un-" ? VarPrefixPostprocessor(options.variablePrefix) : void 0
|
|
24
24
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ const presetMini = (options = {}) => {
|
|
|
15
15
|
name: "@unocss/preset-mini",
|
|
16
16
|
theme,
|
|
17
17
|
rules,
|
|
18
|
-
variants,
|
|
18
|
+
variants: variants(options),
|
|
19
19
|
options,
|
|
20
20
|
postprocess: options.variablePrefix && options.variablePrefix !== "un-" ? VarPrefixPostprocessor(options.variablePrefix) : void 0
|
|
21
21
|
};
|
package/dist/theme.d.ts
CHANGED
|
@@ -77,8 +77,6 @@ declare const baseSize: {
|
|
|
77
77
|
'5xl': string;
|
|
78
78
|
'6xl': string;
|
|
79
79
|
'7xl': string;
|
|
80
|
-
min: string;
|
|
81
|
-
max: string;
|
|
82
80
|
prose: string;
|
|
83
81
|
};
|
|
84
82
|
declare const width: {
|
|
@@ -94,8 +92,6 @@ declare const width: {
|
|
|
94
92
|
'5xl': string;
|
|
95
93
|
'6xl': string;
|
|
96
94
|
'7xl': string;
|
|
97
|
-
min: string;
|
|
98
|
-
max: string;
|
|
99
95
|
prose: string;
|
|
100
96
|
auto: string;
|
|
101
97
|
};
|
|
@@ -112,8 +108,6 @@ declare const maxWidth: {
|
|
|
112
108
|
'5xl': string;
|
|
113
109
|
'6xl': string;
|
|
114
110
|
'7xl': string;
|
|
115
|
-
min: string;
|
|
116
|
-
max: string;
|
|
117
111
|
prose: string;
|
|
118
112
|
none: string;
|
|
119
113
|
};
|
|
@@ -130,8 +124,6 @@ declare const height: {
|
|
|
130
124
|
'5xl': string;
|
|
131
125
|
'6xl': string;
|
|
132
126
|
'7xl': string;
|
|
133
|
-
min: string;
|
|
134
|
-
max: string;
|
|
135
127
|
prose: string;
|
|
136
128
|
auto: string;
|
|
137
129
|
};
|
|
@@ -148,8 +140,6 @@ declare const maxHeight: {
|
|
|
148
140
|
'5xl': string;
|
|
149
141
|
'6xl': string;
|
|
150
142
|
'7xl': string;
|
|
151
|
-
min: string;
|
|
152
|
-
max: string;
|
|
153
143
|
prose: string;
|
|
154
144
|
none: string;
|
|
155
145
|
};
|