@unocss/preset-mini 0.27.5 → 0.28.1

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/README.md CHANGED
@@ -13,8 +13,8 @@ import presetMini from '@unocss/preset-mini'
13
13
 
14
14
  Unocss({
15
15
  presets: [
16
- presetMini()
17
- ]
16
+ presetMini(),
17
+ ],
18
18
  })
19
19
  ```
20
20
 
@@ -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 })],
@@ -211,7 +211,7 @@ const weightMap = {
211
211
  black: "900"
212
212
  };
213
213
  const fonts = [
214
- [/^font-(\w+)$/, ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] })],
214
+ [/^font-(\w+)$/, ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] || utilities.handler.global(d) })],
215
215
  [/^text-(.+)$/, ([, s = "base"], { theme }) => {
216
216
  const themed = core.toArray(theme.fontSize?.[s]);
217
217
  if (themed?.[0]) {
@@ -229,10 +229,10 @@ const fonts = [
229
229
  if (size != null)
230
230
  return { "font-size": size };
231
231
  }],
232
- [/^(?:font|fw)-?([^-]+)$/, ([, s]) => ({ "font-weight": weightMap[s] || utilities.handler.number(s) })],
233
- [/^(?:leading|lh)-(.+)$/, ([, s], { theme }) => ({ "line-height": theme.lineHeight?.[s] || utilities.handler.bracket.cssvar.rem(s) })],
234
- [/^tracking-(.+)$/, ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || utilities.handler.bracket.cssvar.rem(s) })],
235
- [/^word-spacing-(.+)$/, ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || utilities.handler.bracket.cssvar.rem(s) })]
232
+ [/^(?:font|fw)-?([^-]+)$/, ([, s]) => ({ "font-weight": weightMap[s] || utilities.handler.global.number(s) })],
233
+ [/^(?:leading|lh)-(.+)$/, ([, s], { theme }) => ({ "line-height": theme.lineHeight?.[s] || utilities.handler.bracket.cssvar.global.rem(s) })],
234
+ [/^tracking-(.+)$/, ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || utilities.handler.bracket.cssvar.global.rem(s) })],
235
+ [/^word-spacing-(.+)$/, ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || utilities.handler.bracket.cssvar.global.rem(s) })]
236
236
  ];
237
237
  const tabSizes = [
238
238
  [/^tab(?:-(.+))?$/, ([, s]) => {
@@ -247,7 +247,7 @@ const tabSizes = [
247
247
  }]
248
248
  ];
249
249
  const textIndents = [
250
- [/^indent(?:-(.+))?$/, ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || utilities.handler.bracket.cssvar.fraction.rem(s) })]
250
+ [/^indent(?:-(.+))?$/, ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || utilities.handler.bracket.cssvar.global.fraction.rem(s) })]
251
251
  ];
252
252
  const textStrokes = [
253
253
  [/^text-stroke(?:-(.+))?$/, ([, s], { theme }) => ({ "-webkit-text-stroke-width": theme.textStrokeWidth?.[s || "DEFAULT"] || utilities.handler.bracket.cssvar.px(s) })],
@@ -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 })],
@@ -209,7 +209,7 @@ const weightMap = {
209
209
  black: "900"
210
210
  };
211
211
  const fonts = [
212
- [/^font-(\w+)$/, ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] })],
212
+ [/^font-(\w+)$/, ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] || handler.global(d) })],
213
213
  [/^text-(.+)$/, ([, s = "base"], { theme }) => {
214
214
  const themed = toArray(theme.fontSize?.[s]);
215
215
  if (themed?.[0]) {
@@ -227,10 +227,10 @@ const fonts = [
227
227
  if (size != null)
228
228
  return { "font-size": size };
229
229
  }],
230
- [/^(?:font|fw)-?([^-]+)$/, ([, s]) => ({ "font-weight": weightMap[s] || handler.number(s) })],
231
- [/^(?:leading|lh)-(.+)$/, ([, s], { theme }) => ({ "line-height": theme.lineHeight?.[s] || handler.bracket.cssvar.rem(s) })],
232
- [/^tracking-(.+)$/, ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || handler.bracket.cssvar.rem(s) })],
233
- [/^word-spacing-(.+)$/, ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || handler.bracket.cssvar.rem(s) })]
230
+ [/^(?:font|fw)-?([^-]+)$/, ([, s]) => ({ "font-weight": weightMap[s] || handler.global.number(s) })],
231
+ [/^(?:leading|lh)-(.+)$/, ([, s], { theme }) => ({ "line-height": theme.lineHeight?.[s] || handler.bracket.cssvar.global.rem(s) })],
232
+ [/^tracking-(.+)$/, ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || handler.bracket.cssvar.global.rem(s) })],
233
+ [/^word-spacing-(.+)$/, ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || handler.bracket.cssvar.global.rem(s) })]
234
234
  ];
235
235
  const tabSizes = [
236
236
  [/^tab(?:-(.+))?$/, ([, s]) => {
@@ -245,7 +245,7 @@ const tabSizes = [
245
245
  }]
246
246
  ];
247
247
  const textIndents = [
248
- [/^indent(?:-(.+))?$/, ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || handler.bracket.cssvar.fraction.rem(s) })]
248
+ [/^indent(?:-(.+))?$/, ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || handler.bracket.cssvar.global.fraction.rem(s) })]
249
249
  ];
250
250
  const textStrokes = [
251
251
  [/^text-stroke(?:-(.+))?$/, ([, s], { theme }) => ({ "-webkit-text-stroke-width": theme.textStrokeWidth?.[s || "DEFAULT"] || handler.bracket.cssvar.px(s) })],
@@ -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
  };
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './types-f7b2c653';
1
+ import { T as Theme } from './types-f7b2c653.js';
2
2
 
3
3
  declare const colors: Theme['colors'];
4
4
 
package/dist/colors.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { c as colors } from './colors-ce2fecb8';
2
- import './types-f7b2c653';
1
+ export { c as colors } from './colors-ce2fecb8.js';
2
+ import './types-f7b2c653.js';
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './types-f7b2c653';
1
+ import { T as Theme } from './types-f7b2c653.js';
2
2
 
3
3
  declare const theme: Theme;
4
4
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { PresetOptions, Preset } from '@unocss/core';
2
- import { T as Theme } from './types-f7b2c653';
3
- export { T as Theme, a as ThemeAnimation } from './types-f7b2c653';
4
- export { t as theme } from './default-e6d1b2e8';
5
- export { c as colors } from './colors-ce2fecb8';
6
- export { p as parseColor } from './utilities-820bcff8';
2
+ import { T as Theme } from './types-f7b2c653.js';
3
+ export { T as Theme, a as ThemeAnimation } from './types-f7b2c653.js';
4
+ export { t as theme } from './default-e6d1b2e8.js';
5
+ export { c as colors } from './colors-ce2fecb8.js';
6
+ export { p as parseColor } from './utilities-820bcff8.js';
7
7
 
8
8
  interface PresetMiniOptions extends PresetOptions {
9
9
  /**
package/dist/rules.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Rule } from '@unocss/core';
2
- import { T as Theme } from './types-f7b2c653';
2
+ import { T as Theme } from './types-f7b2c653.js';
3
3
 
4
4
  declare const verticalAligns: Rule[];
5
5
  declare const textAligns: Rule[];
package/dist/theme.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { c as colors } from './colors-ce2fecb8';
2
- export { t as theme } from './default-e6d1b2e8';
3
- import { T as Theme } from './types-f7b2c653';
4
- export { T as Theme, a as ThemeAnimation } from './types-f7b2c653';
1
+ export { c as colors } from './colors-ce2fecb8.js';
2
+ export { t as theme } from './default-e6d1b2e8.js';
3
+ import { T as Theme } from './types-f7b2c653.js';
4
+ export { T as Theme, a as ThemeAnimation } from './types-f7b2c653.js';
5
5
 
6
6
  declare const blur: {
7
7
  DEFAULT: string;
@@ -1,5 +1,5 @@
1
1
  import { RuleContext, CSSEntries, ParsedColorValue, CSSObject } from '@unocss/core';
2
- import { T as Theme } from './types-f7b2c653';
2
+ import { T as Theme } from './types-f7b2c653.js';
3
3
 
4
4
  /**
5
5
  * Provide {@link DynamicMatcher} function returning spacing definition. See spacing rules.
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { RGBAColorValue, CSSColorValue, VariantHandler } from '@unocss/core';
3
- export { c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, p as parseColor } from './utilities-820bcff8';
4
- import './types-f7b2c653';
3
+ export { c as colorResolver, a as colorableShadows, d as directionSize, h as hasParseableColor, p as parseColor } from './utilities-820bcff8.js';
4
+ import './types-f7b2c653.js';
5
5
 
6
6
  declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
7
7
  declare function parseCssColor(str?: string): CSSColorValue | undefined;
@@ -1,9 +1,9 @@
1
1
  import { Variant, VariantFunction, VariantObject } from '@unocss/core';
2
- import { T as Theme } from './types-f7b2c653';
3
- import { PresetMiniOptions } from './index';
4
- import './default-e6d1b2e8';
5
- import './colors-ce2fecb8';
6
- import './utilities-820bcff8';
2
+ import { T as Theme } from './types-f7b2c653.js';
3
+ import { PresetMiniOptions } from './index.js';
4
+ import './default-e6d1b2e8.js';
5
+ import './colors-ce2fecb8.js';
6
+ import './utilities-820bcff8.js';
7
7
 
8
8
  declare const variantBreakpoints: Variant<Theme>;
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.27.5",
3
+ "version": "0.28.1",
4
4
  "description": "The minimal preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -11,19 +11,16 @@
11
11
  "url": "https://github.com/unocss/unocss/issues"
12
12
  },
13
13
  "license": "MIT",
14
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
14
15
  "repository": {
15
16
  "type": "git",
16
17
  "url": "git+https://github.com/unocss/unocss.git",
17
18
  "directory": "packages/preset-mini"
18
19
  },
19
20
  "funding": "https://github.com/sponsors/antfu",
20
- "author": "Anthony Fu <anthonyfu117@hotmail.com>",
21
- "sideEffects": false,
22
- "files": [
23
- "dist",
24
- "*.d.ts",
25
- "*.css"
26
- ],
21
+ "main": "dist/index.cjs",
22
+ "module": "dist/index.mjs",
23
+ "types": "dist/index.d.ts",
27
24
  "exports": {
28
25
  ".": {
29
26
  "require": "./dist/index.cjs",
@@ -57,14 +54,18 @@
57
54
  },
58
55
  "./*": "./*"
59
56
  },
60
- "main": "dist/index.cjs",
61
- "module": "dist/index.mjs",
62
- "types": "dist/index.d.ts",
57
+ "files": [
58
+ "dist",
59
+ "*.d.ts",
60
+ "*.css"
61
+ ],
62
+ "sideEffects": false,
63
63
  "dependencies": {
64
- "@unocss/core": "0.27.5"
64
+ "@unocss/core": "0.28.1"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",
68
68
  "stub": "unbuild --stub"
69
- }
69
+ },
70
+ "readme": "# @unocss/preset-mini\n\nThe minimal preset for [UnoCSS](https://github.com/unocss/unocss).\n\n## Installation\n\n```bash\nnpm i -D @unocss/preset-mini\n```\n\n```ts\nimport presetMini from '@unocss/preset-mini'\n\nUnocss({\n presets: [\n presetMini(),\n ],\n})\n```\n\n## License\n\nMIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)\n"
70
71
  }