@unocss/preset-mini 0.31.0 → 0.31.5

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.
@@ -4,27 +4,30 @@ const utilities = require('./utilities.cjs');
4
4
  const core = require('@unocss/core');
5
5
 
6
6
  const verticalAlignAlias = {
7
- mid: "middle",
8
- base: "baseline",
9
- btm: "bottom"
7
+ "mid": "middle",
8
+ "base": "baseline",
9
+ "btm": "bottom",
10
+ "baseline": "baseline",
11
+ "top": "top",
12
+ "middle": "middle",
13
+ "bottom": "bottom",
14
+ "text-top": "text-top",
15
+ "text-bottom": "text-bottom",
16
+ "sub": "sub",
17
+ "super": "super"
10
18
  };
11
19
  const verticalAligns = [
12
- [/^(?:vertical|align|v)-(baseline|top|middle|bottom|text-top|text-bottom|sub|super|mid|base|btm)$/, ([, v]) => ({ "vertical-align": verticalAlignAlias[v] || v }), { autocomplete: "(vertical|align|v)-(baseline|top|middle|bottom|text-top|text-bottom|sub|super|mid|base|btm)" }]
13
- ];
14
- const textAligns = [
15
- ["text-center", { "text-align": "center" }],
16
- ["text-left", { "text-align": "left" }],
17
- ["text-right", { "text-align": "right" }],
18
- ["text-justify", { "text-align": "justify" }]
20
+ [/^(?:vertical|align|v)-(.+)$/, ([, v]) => ({ "vertical-align": verticalAlignAlias[v] }), { autocomplete: `(vertical|align|v)-(${Object.keys(verticalAlignAlias).join("|")})` }]
19
21
  ];
22
+ const textAligns = ["center", "left", "right", "justify", "start", "end", "inherit", "initial", "unset", "revert"].map((v) => [`text-${v}`, { "text-align": v }]);
20
23
 
21
24
  const outline = [
22
25
  [/^outline-(?:width-|size-)?(.+)$/, ([, d], { theme }) => ({ "outline-width": theme.lineWidth?.[d] ?? utilities.handler.bracket.cssvar.px(d) }), { autocomplete: "outline-(width|size)-<num>" }],
23
26
  [/^outline-(?:color-)?(.+)$/, utilities.colorResolver("outline-color", "outline-color"), { autocomplete: "outline-$colors" }],
24
27
  [/^outline-offset-(.+)$/, ([, d], { theme }) => ({ "outline-offset": theme.lineWidth?.[d] ?? utilities.handler.bracket.cssvar.px(d) }), { autocomplete: "outline-(offset)-<num>" }],
25
28
  ["outline", { "outline-style": "solid" }],
26
- [/^outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c }), { autocomplete: "outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)" }],
27
- ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
29
+ ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }],
30
+ ...["auto", "dashed", "dotted", "double", "hidden", "solid", "groove", "ridge", "inset", "outset", "inherit", "initial", "revert", "unset"].map((v) => [`outline-${v}`, { "outline-style": v }])
28
31
  ];
29
32
  const appearance = [
30
33
  ["appearance-none", {
@@ -42,6 +45,7 @@ const willChange = [
42
45
  [/^will-change-(.+)/, ([, p]) => ({ "will-change": willChangeProperty(p) })]
43
46
  ];
44
47
 
48
+ const borderStyles = ["solid", "dashed", "dotted", "double", "hidden", "none", "groove", "ridge", "inset", "outset", "initial", "inherit", "revert", "unset"];
45
49
  const borders = [
46
50
  [/^(?:border|b)()(?:-(.+))?$/, handlerBorder, { autocomplete: "(border|b)-<directions>" }],
47
51
  [/^(?:border|b)-([xy])(?:-(.+))?$/, handlerBorder],
@@ -68,12 +72,8 @@ const borders = [
68
72
  [/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
69
73
  [/^(?:border-|b-)?(?:rounded|rd)-([bi][se])(?:-(.+))?$/, handlerRounded],
70
74
  [/^(?:border-|b-)?(?:rounded|rd)-([bi][se]-[bi][se])(?:-(.+))?$/, handlerRounded],
71
- ["border-solid", { "border-style": "solid" }],
72
- ["border-dashed", { "border-style": "dashed" }],
73
- ["border-dotted", { "border-style": "dotted" }],
74
- ["border-double", { "border-style": "double" }],
75
- ["border-hidden", { "border-style": "hidden" }],
76
- ["border-none", { "border-style": "none" }]
75
+ [/^(?:border|b)-(?:style-)?()(.+)$/, handlerBorderStyle, { autocomplete: ["(border|b)-style", `(border|b)-(${borderStyles.join("|")})`, "(border|b)-<directions>-style", `(border|b)-<directions>-(${borderStyles.join("|")})`, `(border|b)-<directions>-style-(${borderStyles.join("|")})`, `(border|b)-style-(${borderStyles.join("|")})`] }],
76
+ [/^(?:border|b)-([rltbsexy])-(?:style-)?(.+)$/, handlerBorderStyle]
77
77
  ];
78
78
  const borderColorResolver = (direction) => ([, body], theme) => {
79
79
  const data = utilities.parseColor(body, theme);
@@ -106,10 +106,11 @@ const borderColorResolver = (direction) => ([, body], theme) => {
106
106
  };
107
107
  function handlerBorder(m, ctx) {
108
108
  const borderSizes = handlerBorderSize(m, ctx);
109
- if (borderSizes) {
109
+ const borderStyle = handlerBorderStyle(["", m[1], "solid"]);
110
+ if (borderSizes && borderStyle) {
110
111
  return [
111
112
  ...borderSizes,
112
- ["border-style", "solid"]
113
+ ...borderStyle
113
114
  ];
114
115
  }
115
116
  }
@@ -133,6 +134,14 @@ function handlerRounded([, a = "", s], { theme }) {
133
134
  if (a in utilities.cornerMap && v != null)
134
135
  return utilities.cornerMap[a].map((i) => [`border${i}-radius`, v]);
135
136
  }
137
+ function handlerBorderStyle([, a = "", s]) {
138
+ if (borderStyles.includes(s)) {
139
+ if (a in utilities.directionMap)
140
+ return utilities.directionMap[a].map((i) => [`border${i}-style`, s]);
141
+ else
142
+ return [["border-style", s]];
143
+ }
144
+ }
136
145
 
137
146
  const opacity = [
138
147
  [/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: utilities.handler.bracket.percent.cssvar(d) })]
@@ -2,27 +2,30 @@ import { h as handler, c as colorResolver, d as directionMap, a as hasParseableC
2
2
  import { toArray, CONTROL_SHORTCUT_NO_MERGE } from '@unocss/core';
3
3
 
4
4
  const verticalAlignAlias = {
5
- mid: "middle",
6
- base: "baseline",
7
- btm: "bottom"
5
+ "mid": "middle",
6
+ "base": "baseline",
7
+ "btm": "bottom",
8
+ "baseline": "baseline",
9
+ "top": "top",
10
+ "middle": "middle",
11
+ "bottom": "bottom",
12
+ "text-top": "text-top",
13
+ "text-bottom": "text-bottom",
14
+ "sub": "sub",
15
+ "super": "super"
8
16
  };
9
17
  const verticalAligns = [
10
- [/^(?:vertical|align|v)-(baseline|top|middle|bottom|text-top|text-bottom|sub|super|mid|base|btm)$/, ([, v]) => ({ "vertical-align": verticalAlignAlias[v] || v }), { autocomplete: "(vertical|align|v)-(baseline|top|middle|bottom|text-top|text-bottom|sub|super|mid|base|btm)" }]
11
- ];
12
- const textAligns = [
13
- ["text-center", { "text-align": "center" }],
14
- ["text-left", { "text-align": "left" }],
15
- ["text-right", { "text-align": "right" }],
16
- ["text-justify", { "text-align": "justify" }]
18
+ [/^(?:vertical|align|v)-(.+)$/, ([, v]) => ({ "vertical-align": verticalAlignAlias[v] }), { autocomplete: `(vertical|align|v)-(${Object.keys(verticalAlignAlias).join("|")})` }]
17
19
  ];
20
+ const textAligns = ["center", "left", "right", "justify", "start", "end", "inherit", "initial", "unset", "revert"].map((v) => [`text-${v}`, { "text-align": v }]);
18
21
 
19
22
  const outline = [
20
23
  [/^outline-(?:width-|size-)?(.+)$/, ([, d], { theme }) => ({ "outline-width": theme.lineWidth?.[d] ?? handler.bracket.cssvar.px(d) }), { autocomplete: "outline-(width|size)-<num>" }],
21
24
  [/^outline-(?:color-)?(.+)$/, colorResolver("outline-color", "outline-color"), { autocomplete: "outline-$colors" }],
22
25
  [/^outline-offset-(.+)$/, ([, d], { theme }) => ({ "outline-offset": theme.lineWidth?.[d] ?? handler.bracket.cssvar.px(d) }), { autocomplete: "outline-(offset)-<num>" }],
23
26
  ["outline", { "outline-style": "solid" }],
24
- [/^outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c }), { autocomplete: "outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)" }],
25
- ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
27
+ ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }],
28
+ ...["auto", "dashed", "dotted", "double", "hidden", "solid", "groove", "ridge", "inset", "outset", "inherit", "initial", "revert", "unset"].map((v) => [`outline-${v}`, { "outline-style": v }])
26
29
  ];
27
30
  const appearance = [
28
31
  ["appearance-none", {
@@ -40,6 +43,7 @@ const willChange = [
40
43
  [/^will-change-(.+)/, ([, p]) => ({ "will-change": willChangeProperty(p) })]
41
44
  ];
42
45
 
46
+ const borderStyles = ["solid", "dashed", "dotted", "double", "hidden", "none", "groove", "ridge", "inset", "outset", "initial", "inherit", "revert", "unset"];
43
47
  const borders = [
44
48
  [/^(?:border|b)()(?:-(.+))?$/, handlerBorder, { autocomplete: "(border|b)-<directions>" }],
45
49
  [/^(?:border|b)-([xy])(?:-(.+))?$/, handlerBorder],
@@ -66,12 +70,8 @@ const borders = [
66
70
  [/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
67
71
  [/^(?:border-|b-)?(?:rounded|rd)-([bi][se])(?:-(.+))?$/, handlerRounded],
68
72
  [/^(?:border-|b-)?(?:rounded|rd)-([bi][se]-[bi][se])(?:-(.+))?$/, handlerRounded],
69
- ["border-solid", { "border-style": "solid" }],
70
- ["border-dashed", { "border-style": "dashed" }],
71
- ["border-dotted", { "border-style": "dotted" }],
72
- ["border-double", { "border-style": "double" }],
73
- ["border-hidden", { "border-style": "hidden" }],
74
- ["border-none", { "border-style": "none" }]
73
+ [/^(?:border|b)-(?:style-)?()(.+)$/, handlerBorderStyle, { autocomplete: ["(border|b)-style", `(border|b)-(${borderStyles.join("|")})`, "(border|b)-<directions>-style", `(border|b)-<directions>-(${borderStyles.join("|")})`, `(border|b)-<directions>-style-(${borderStyles.join("|")})`, `(border|b)-style-(${borderStyles.join("|")})`] }],
74
+ [/^(?:border|b)-([rltbsexy])-(?:style-)?(.+)$/, handlerBorderStyle]
75
75
  ];
76
76
  const borderColorResolver = (direction) => ([, body], theme) => {
77
77
  const data = parseColor(body, theme);
@@ -104,10 +104,11 @@ const borderColorResolver = (direction) => ([, body], theme) => {
104
104
  };
105
105
  function handlerBorder(m, ctx) {
106
106
  const borderSizes = handlerBorderSize(m, ctx);
107
- if (borderSizes) {
107
+ const borderStyle = handlerBorderStyle(["", m[1], "solid"]);
108
+ if (borderSizes && borderStyle) {
108
109
  return [
109
110
  ...borderSizes,
110
- ["border-style", "solid"]
111
+ ...borderStyle
111
112
  ];
112
113
  }
113
114
  }
@@ -131,6 +132,14 @@ function handlerRounded([, a = "", s], { theme }) {
131
132
  if (a in cornerMap && v != null)
132
133
  return cornerMap[a].map((i) => [`border${i}-radius`, v]);
133
134
  }
135
+ function handlerBorderStyle([, a = "", s]) {
136
+ if (borderStyles.includes(s)) {
137
+ if (a in directionMap)
138
+ return directionMap[a].map((i) => [`border${i}-style`, s]);
139
+ else
140
+ return [["border-style", s]];
141
+ }
142
+ }
134
143
 
135
144
  const opacity = [
136
145
  [/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: handler.bracket.percent.cssvar(d) })]
@@ -475,11 +475,8 @@ function global(str) {
475
475
  return str;
476
476
  }
477
477
  function properties(str) {
478
- for (const prop of str.split(",")) {
479
- if (!cssProps.includes(prop))
480
- return;
481
- }
482
- return str;
478
+ if (str.split(",").every((prop) => cssProps.includes(prop)))
479
+ return str;
483
480
  }
484
481
 
485
482
  const valueHandlers = {
@@ -473,11 +473,8 @@ function global(str) {
473
473
  return str;
474
474
  }
475
475
  function properties(str) {
476
- for (const prop of str.split(",")) {
477
- if (!cssProps.includes(prop))
478
- return;
479
- }
480
- return str;
476
+ if (str.split(",").every((prop) => cssProps.includes(prop)))
477
+ return str;
481
478
  }
482
479
 
483
480
  const valueHandlers = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.31.0",
3
+ "version": "0.31.5",
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.0"
64
+ "@unocss/core": "0.31.5"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",