@unocss/preset-mini 0.31.17 → 0.32.0

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.
@@ -155,21 +155,28 @@ 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
 
@@ -153,21 +153,28 @@ 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.31.17",
3
+ "version": "0.32.0",
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.17"
64
+ "@unocss/core": "0.32.0"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",