@unocss/preset-mini 0.28.0 → 0.28.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.
@@ -180,11 +180,11 @@ const flex = [
180
180
  ["flex", { display: "flex" }],
181
181
  ["inline-flex", { display: "inline-flex" }],
182
182
  ["flex-inline", { display: "inline-flex" }],
183
+ [/^flex-(.*)$/, ([, d]) => ({ flex: utilities.handler.bracket(d) != null ? utilities.handler.bracket(d).split(" ").map((e) => utilities.handler.cssvar.fraction(e) ?? e).join(" ") : utilities.handler.cssvar.fraction(d) })],
183
184
  ["flex-1", { flex: "1 1 0%" }],
184
185
  ["flex-auto", { flex: "1 1 auto" }],
185
186
  ["flex-initial", { flex: "0 1 auto" }],
186
187
  ["flex-none", { flex: "none" }],
187
- [/^flex-(\[.+\])$/, ([, d]) => ({ flex: utilities.handler.bracket(d).replace(/\d+\/\d+/, ($1) => utilities.handler.fraction($1)) })],
188
188
  [/^(?:flex-)?shrink$/, () => ({ "flex-shrink": 1 })],
189
189
  [/^(?:flex-)?shrink-0$/, () => ({ "flex-shrink": 0 })],
190
190
  [/^(?:flex-)?grow$/, () => ({ "flex-grow": 1 })],
@@ -781,7 +781,6 @@ const variablesAbbrMap = {
781
781
  break: "word-break",
782
782
  case: "text-transform",
783
783
  content: "align-content",
784
- flex: "flex",
785
784
  fw: "font-weight",
786
785
  items: "align-items",
787
786
  justify: "justify-content",
@@ -178,11 +178,11 @@ const flex = [
178
178
  ["flex", { display: "flex" }],
179
179
  ["inline-flex", { display: "inline-flex" }],
180
180
  ["flex-inline", { display: "inline-flex" }],
181
+ [/^flex-(.*)$/, ([, d]) => ({ flex: handler.bracket(d) != null ? handler.bracket(d).split(" ").map((e) => handler.cssvar.fraction(e) ?? e).join(" ") : handler.cssvar.fraction(d) })],
181
182
  ["flex-1", { flex: "1 1 0%" }],
182
183
  ["flex-auto", { flex: "1 1 auto" }],
183
184
  ["flex-initial", { flex: "0 1 auto" }],
184
185
  ["flex-none", { flex: "none" }],
185
- [/^flex-(\[.+\])$/, ([, d]) => ({ flex: handler.bracket(d).replace(/\d+\/\d+/, ($1) => handler.fraction($1)) })],
186
186
  [/^(?:flex-)?shrink$/, () => ({ "flex-shrink": 1 })],
187
187
  [/^(?:flex-)?shrink-0$/, () => ({ "flex-shrink": 0 })],
188
188
  [/^(?:flex-)?grow$/, () => ({ "flex-grow": 1 })],
@@ -779,7 +779,6 @@ const variablesAbbrMap = {
779
779
  break: "word-break",
780
780
  case: "text-transform",
781
781
  content: "align-content",
782
- flex: "flex",
783
782
  fw: "font-weight",
784
783
  items: "align-items",
785
784
  justify: "justify-content",
@@ -4,6 +4,12 @@ const variants$1 = require('./variants.cjs');
4
4
  const core = require('@unocss/core');
5
5
 
6
6
  const regexCache = {};
7
+ const calcMaxWidthBySize = (size) => {
8
+ const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
9
+ const unit = size.slice(value.length);
10
+ const maxWidth = parseFloat(value) - 0.1;
11
+ return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
12
+ };
7
13
  const variantBreakpoints = (matcher, { theme }) => {
8
14
  const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
9
15
  for (const [point, size, idx] of variantEntries) {
@@ -16,23 +22,26 @@ const variantBreakpoints = (matcher, { theme }) => {
16
22
  const m = matcher.slice(pre.length);
17
23
  if (m === "container")
18
24
  continue;
19
- let direction = "min";
25
+ const isLtPrefix = pre.startsWith("lt-");
26
+ const isAtPrefix = pre.startsWith("at-");
20
27
  let order = 1e3;
21
- if (pre.startsWith("lt-")) {
22
- direction = "max";
28
+ if (isLtPrefix) {
23
29
  order -= idx + 1;
24
- } else {
25
- order += idx + 1;
30
+ return {
31
+ matcher: m,
32
+ parent: [`@media (max-width: ${calcMaxWidthBySize(size)})`, order]
33
+ };
26
34
  }
27
- if (pre.startsWith("at-") && idx < variantEntries.length - 1) {
35
+ order += idx + 1;
36
+ if (isAtPrefix && idx < variantEntries.length - 1) {
28
37
  return {
29
38
  matcher: m,
30
- parent: [`@media (min-width: ${size}) and (max-width: ${variantEntries[idx + 1][1]})`, order]
39
+ parent: [`@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`, order]
31
40
  };
32
41
  }
33
42
  return {
34
43
  matcher: m,
35
- parent: [`@media (${direction}-width: ${size})`, order]
44
+ parent: [`@media (min-width: ${size})`, order]
36
45
  };
37
46
  }
38
47
  };
@@ -2,6 +2,12 @@ import { v as variantParentMatcher, a as variantMatcher } from './variants.mjs';
2
2
  import { toArray, escapeRegExp } from '@unocss/core';
3
3
 
4
4
  const regexCache = {};
5
+ const calcMaxWidthBySize = (size) => {
6
+ const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
7
+ const unit = size.slice(value.length);
8
+ const maxWidth = parseFloat(value) - 0.1;
9
+ return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
10
+ };
5
11
  const variantBreakpoints = (matcher, { theme }) => {
6
12
  const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
7
13
  for (const [point, size, idx] of variantEntries) {
@@ -14,23 +20,26 @@ const variantBreakpoints = (matcher, { theme }) => {
14
20
  const m = matcher.slice(pre.length);
15
21
  if (m === "container")
16
22
  continue;
17
- let direction = "min";
23
+ const isLtPrefix = pre.startsWith("lt-");
24
+ const isAtPrefix = pre.startsWith("at-");
18
25
  let order = 1e3;
19
- if (pre.startsWith("lt-")) {
20
- direction = "max";
26
+ if (isLtPrefix) {
21
27
  order -= idx + 1;
22
- } else {
23
- order += idx + 1;
28
+ return {
29
+ matcher: m,
30
+ parent: [`@media (max-width: ${calcMaxWidthBySize(size)})`, order]
31
+ };
24
32
  }
25
- if (pre.startsWith("at-") && idx < variantEntries.length - 1) {
33
+ order += idx + 1;
34
+ if (isAtPrefix && idx < variantEntries.length - 1) {
26
35
  return {
27
36
  matcher: m,
28
- parent: [`@media (min-width: ${size}) and (max-width: ${variantEntries[idx + 1][1]})`, order]
37
+ parent: [`@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`, order]
29
38
  };
30
39
  }
31
40
  return {
32
41
  matcher: m,
33
- parent: [`@media (${direction}-width: ${size})`, order]
42
+ parent: [`@media (min-width: ${size})`, order]
34
43
  };
35
44
  }
36
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.28.0",
3
+ "version": "0.28.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.28.0"
64
+ "@unocss/core": "0.28.3"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",