@unocss/preset-mini 0.24.4 → 0.25.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.
@@ -472,6 +472,7 @@ const whitespaces = [
472
472
  [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
473
473
  ];
474
474
  const contents = [
475
+ [/^content-\[(.+)\]$/, ([, v]) => ({ content: `"${v}"` })],
475
476
  ["content-empty", { content: '""' }],
476
477
  ["content-none", { content: '""' }]
477
478
  ];
@@ -470,6 +470,7 @@ const whitespaces = [
470
470
  [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
471
471
  ];
472
472
  const contents = [
473
+ [/^content-\[(.+)\]$/, ([, v]) => ({ content: `"${v}"` })],
473
474
  ["content-empty", { content: '""' }],
474
475
  ["content-none", { content: '""' }]
475
476
  ];
@@ -61,15 +61,17 @@ const variantCombinators = [
61
61
  scopeMatcher(true, "peer", "&&-c~&&-s")
62
62
  ];
63
63
 
64
- const variantMotions = [
65
- variants$1.variantParentMatcher("motion-reduce", "@media (prefers-reduced-motion: reduce)"),
66
- variants$1.variantParentMatcher("motion-safe", "@media (prefers-reduced-motion: no-preference)")
67
- ];
68
- const variantOrientations = [
69
- variants$1.variantParentMatcher("landscape", "@media (orientation: landscape)"),
70
- variants$1.variantParentMatcher("portrait", "@media (orientation: portrait)")
71
- ];
72
64
  const variantPrint = variants$1.variantParentMatcher("print", "@media print");
65
+ const variantCustomMedia = (matcher, { theme }) => {
66
+ const match = matcher.match(/^media-([_\d\w]+)[:-]/);
67
+ if (match) {
68
+ const media = theme.media?.[match[1]] ?? `(--${match[1]})`;
69
+ return {
70
+ matcher: matcher.slice(match[0].length),
71
+ parent: `@media ${media}`
72
+ };
73
+ }
74
+ };
73
75
 
74
76
  const variantColorsMediaOrClass = (options = {}) => {
75
77
  if (options?.dark === "class") {
@@ -89,9 +91,20 @@ const variantLanguageDirections = [
89
91
  variants$1.variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
90
92
  ];
91
93
 
94
+ const variantSelector = {
95
+ match(matcher) {
96
+ const match = matcher.match(/^selector-\[(.+?)\][:-]/);
97
+ if (match) {
98
+ return {
99
+ matcher: matcher.slice(match[0].length),
100
+ selector: () => match[1]
101
+ };
102
+ }
103
+ }
104
+ };
92
105
  const variantLayer = {
93
106
  match(matcher) {
94
- const match = matcher.match(/^layer-([\d\w]+)[:-]/);
107
+ const match = matcher.match(/^layer-([_\d\w]+)[:-]/);
95
108
  if (match) {
96
109
  return {
97
110
  matcher: matcher.slice(match[0].length),
@@ -100,6 +113,17 @@ const variantLayer = {
100
113
  }
101
114
  }
102
115
  };
116
+ const variantScope = {
117
+ match(matcher) {
118
+ const match = matcher.match(/^scope-([_\d\w]+)[:-]/);
119
+ if (match) {
120
+ return {
121
+ matcher: matcher.slice(match[0].length),
122
+ selector: (s) => `.${match[1]} $$ ${s}`
123
+ };
124
+ }
125
+ }
126
+ };
103
127
  const variantImportant = {
104
128
  match(matcher) {
105
129
  if (matcher.startsWith("!")) {
@@ -291,12 +315,12 @@ const partClasses = {
291
315
  };
292
316
 
293
317
  const variants = (options) => [
318
+ variantSelector,
294
319
  variantLayer,
295
320
  variantNegative,
296
321
  variantImportant,
297
322
  variantPrint,
298
- ...variantOrientations,
299
- ...variantMotions,
323
+ variantCustomMedia,
300
324
  variantBreakpoints,
301
325
  ...variantCombinators,
302
326
  variantPseudoClasses,
@@ -305,22 +329,24 @@ const variants = (options) => [
305
329
  variantPseudoElements,
306
330
  partClasses,
307
331
  ...variantColorsMediaOrClass(options),
308
- ...variantLanguageDirections
332
+ ...variantLanguageDirections,
333
+ variantScope
309
334
  ];
310
335
 
311
336
  exports.partClasses = partClasses;
312
337
  exports.variantBreakpoints = variantBreakpoints;
313
338
  exports.variantColorsMediaOrClass = variantColorsMediaOrClass;
314
339
  exports.variantCombinators = variantCombinators;
340
+ exports.variantCustomMedia = variantCustomMedia;
315
341
  exports.variantImportant = variantImportant;
316
342
  exports.variantLanguageDirections = variantLanguageDirections;
317
343
  exports.variantLayer = variantLayer;
318
- exports.variantMotions = variantMotions;
319
344
  exports.variantNegative = variantNegative;
320
- exports.variantOrientations = variantOrientations;
321
345
  exports.variantPrint = variantPrint;
322
346
  exports.variantPseudoClassFunctions = variantPseudoClassFunctions;
323
347
  exports.variantPseudoClasses = variantPseudoClasses;
324
348
  exports.variantPseudoElements = variantPseudoElements;
349
+ exports.variantScope = variantScope;
350
+ exports.variantSelector = variantSelector;
325
351
  exports.variantTaggedPseudoClasses = variantTaggedPseudoClasses;
326
352
  exports.variants = variants;
@@ -59,15 +59,17 @@ const variantCombinators = [
59
59
  scopeMatcher(true, "peer", "&&-c~&&-s")
60
60
  ];
61
61
 
62
- const variantMotions = [
63
- variantParentMatcher("motion-reduce", "@media (prefers-reduced-motion: reduce)"),
64
- variantParentMatcher("motion-safe", "@media (prefers-reduced-motion: no-preference)")
65
- ];
66
- const variantOrientations = [
67
- variantParentMatcher("landscape", "@media (orientation: landscape)"),
68
- variantParentMatcher("portrait", "@media (orientation: portrait)")
69
- ];
70
62
  const variantPrint = variantParentMatcher("print", "@media print");
63
+ const variantCustomMedia = (matcher, { theme }) => {
64
+ const match = matcher.match(/^media-([_\d\w]+)[:-]/);
65
+ if (match) {
66
+ const media = theme.media?.[match[1]] ?? `(--${match[1]})`;
67
+ return {
68
+ matcher: matcher.slice(match[0].length),
69
+ parent: `@media ${media}`
70
+ };
71
+ }
72
+ };
71
73
 
72
74
  const variantColorsMediaOrClass = (options = {}) => {
73
75
  if (options?.dark === "class") {
@@ -87,9 +89,20 @@ const variantLanguageDirections = [
87
89
  variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
88
90
  ];
89
91
 
92
+ const variantSelector = {
93
+ match(matcher) {
94
+ const match = matcher.match(/^selector-\[(.+?)\][:-]/);
95
+ if (match) {
96
+ return {
97
+ matcher: matcher.slice(match[0].length),
98
+ selector: () => match[1]
99
+ };
100
+ }
101
+ }
102
+ };
90
103
  const variantLayer = {
91
104
  match(matcher) {
92
- const match = matcher.match(/^layer-([\d\w]+)[:-]/);
105
+ const match = matcher.match(/^layer-([_\d\w]+)[:-]/);
93
106
  if (match) {
94
107
  return {
95
108
  matcher: matcher.slice(match[0].length),
@@ -98,6 +111,17 @@ const variantLayer = {
98
111
  }
99
112
  }
100
113
  };
114
+ const variantScope = {
115
+ match(matcher) {
116
+ const match = matcher.match(/^scope-([_\d\w]+)[:-]/);
117
+ if (match) {
118
+ return {
119
+ matcher: matcher.slice(match[0].length),
120
+ selector: (s) => `.${match[1]} $$ ${s}`
121
+ };
122
+ }
123
+ }
124
+ };
101
125
  const variantImportant = {
102
126
  match(matcher) {
103
127
  if (matcher.startsWith("!")) {
@@ -289,12 +313,12 @@ const partClasses = {
289
313
  };
290
314
 
291
315
  const variants = (options) => [
316
+ variantSelector,
292
317
  variantLayer,
293
318
  variantNegative,
294
319
  variantImportant,
295
320
  variantPrint,
296
- ...variantOrientations,
297
- ...variantMotions,
321
+ variantCustomMedia,
298
322
  variantBreakpoints,
299
323
  ...variantCombinators,
300
324
  variantPseudoClasses,
@@ -303,7 +327,8 @@ const variants = (options) => [
303
327
  variantPseudoElements,
304
328
  partClasses,
305
329
  ...variantColorsMediaOrClass(options),
306
- ...variantLanguageDirections
330
+ ...variantLanguageDirections,
331
+ variantScope
307
332
  ];
308
333
 
309
- export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g, variantLayer as h, variantImportant as i, variantNegative as j, variantPseudoElements as k, variantPseudoClasses as l, variantPseudoClassFunctions as m, variantTaggedPseudoClasses as n, partClasses as p, variants as v };
334
+ export { variantBreakpoints as a, variantCombinators as b, variantPrint as c, variantCustomMedia as d, variantColorsMediaOrClass as e, variantLanguageDirections as f, variantSelector as g, variantLayer as h, variantScope as i, variantImportant as j, variantNegative as k, variantPseudoElements as l, variantPseudoClasses as m, variantPseudoClassFunctions as n, variantTaggedPseudoClasses as o, partClasses as p, variants as v };
@@ -58,7 +58,7 @@ function parseColor$1(str) {
58
58
  return color;
59
59
  }
60
60
  function parseHexColor(str) {
61
- const [, body] = str.match(/^#?([\da-f]+)$/i) || [];
61
+ const [, body] = str.match(/^#([\da-f]+)$/i) || [];
62
62
  if (!body)
63
63
  return;
64
64
  switch (body.length) {
@@ -497,9 +497,9 @@ const parseColor = (body, theme) => {
497
497
  const bracket = handler.bracket(main);
498
498
  const bracketOrMain = bracket || main;
499
499
  if (bracketOrMain.startsWith("#"))
500
- color = bracketOrMain.slice(1);
500
+ color = bracketOrMain;
501
501
  else if (bracketOrMain.startsWith("hex-"))
502
- color = bracketOrMain.slice(4);
502
+ color = `#${bracketOrMain.slice(4)}`;
503
503
  else if (main.startsWith("$"))
504
504
  color = handler.cssvar(main);
505
505
  color = color || bracket;
@@ -56,7 +56,7 @@ function parseColor$1(str) {
56
56
  return color;
57
57
  }
58
58
  function parseHexColor(str) {
59
- const [, body] = str.match(/^#?([\da-f]+)$/i) || [];
59
+ const [, body] = str.match(/^#([\da-f]+)$/i) || [];
60
60
  if (!body)
61
61
  return;
62
62
  switch (body.length) {
@@ -495,9 +495,9 @@ const parseColor = (body, theme) => {
495
495
  const bracket = handler.bracket(main);
496
496
  const bracketOrMain = bracket || main;
497
497
  if (bracketOrMain.startsWith("#"))
498
- color = bracketOrMain.slice(1);
498
+ color = bracketOrMain;
499
499
  else if (bracketOrMain.startsWith("hex-"))
500
- color = bracketOrMain.slice(4);
500
+ color = `#${bracketOrMain.slice(4)}`;
501
501
  else if (main.startsWith("$"))
502
502
  color = handler.cssvar(main);
503
503
  color = color || bracket;
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './types-f185ef8d';
1
+ import { T as Theme } from './types-ef1d7462';
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-06de139a';
2
- import './types-f185ef8d';
1
+ export { c as colors } from './colors-0db1b382';
2
+ import './types-ef1d7462';
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './types-f185ef8d';
1
+ import { T as Theme } from './types-ef1d7462';
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-f185ef8d';
3
- export { T as Theme, a as ThemeAnimation } from './types-f185ef8d';
4
- export { t as theme } from './default-595a2a04';
5
- export { c as colors } from './colors-06de139a';
6
- export { p as parseColor } from './utilities-df1ea892';
2
+ import { T as Theme } from './types-ef1d7462';
3
+ export { T as Theme, a as ThemeAnimation } from './types-ef1d7462';
4
+ export { t as theme } from './default-3eaf5bb0';
5
+ export { c as colors } from './colors-0db1b382';
6
+ export { p as parseColor } from './utilities-43c87ad4';
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-f185ef8d';
2
+ import { T as Theme } from './types-ef1d7462';
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-06de139a';
2
- export { t as theme } from './default-595a2a04';
3
- import { T as Theme } from './types-f185ef8d';
4
- export { T as Theme, a as ThemeAnimation } from './types-f185ef8d';
1
+ export { c as colors } from './colors-0db1b382';
2
+ export { t as theme } from './default-3eaf5bb0';
3
+ import { T as Theme } from './types-ef1d7462';
4
+ export { T as Theme, a as ThemeAnimation } from './types-ef1d7462';
5
5
 
6
6
  declare const blur: {
7
7
  DEFAULT: string;
@@ -33,6 +33,7 @@ interface Theme {
33
33
  blur?: Record<string, string>;
34
34
  dropShadow?: Record<string, string | string[]>;
35
35
  easing?: Record<string, string>;
36
+ media?: Record<string, string>;
36
37
  animation?: ThemeAnimation;
37
38
  }
38
39
 
@@ -1,5 +1,5 @@
1
1
  import { DynamicMatcher, ParsedColorValue } from '@unocss/core';
2
- import { T as Theme } from './types-f185ef8d';
2
+ import { T as Theme } from './types-ef1d7462';
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, p as parseColor } from './utilities-df1ea892';
4
- import './types-f185ef8d';
3
+ export { c as colorResolver, a as colorableShadows, d as directionSize, p as parseColor } from './utilities-43c87ad4';
4
+ import './types-ef1d7462';
5
5
 
6
6
  declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
7
7
  declare function parseCssColor(str?: string): CSSColorValue | undefined;
package/dist/variants.cjs CHANGED
@@ -12,15 +12,16 @@ exports.partClasses = _default.partClasses;
12
12
  exports.variantBreakpoints = _default.variantBreakpoints;
13
13
  exports.variantColorsMediaOrClass = _default.variantColorsMediaOrClass;
14
14
  exports.variantCombinators = _default.variantCombinators;
15
+ exports.variantCustomMedia = _default.variantCustomMedia;
15
16
  exports.variantImportant = _default.variantImportant;
16
17
  exports.variantLanguageDirections = _default.variantLanguageDirections;
17
18
  exports.variantLayer = _default.variantLayer;
18
- exports.variantMotions = _default.variantMotions;
19
19
  exports.variantNegative = _default.variantNegative;
20
- exports.variantOrientations = _default.variantOrientations;
21
20
  exports.variantPrint = _default.variantPrint;
22
21
  exports.variantPseudoClassFunctions = _default.variantPseudoClassFunctions;
23
22
  exports.variantPseudoClasses = _default.variantPseudoClasses;
24
23
  exports.variantPseudoElements = _default.variantPseudoElements;
24
+ exports.variantScope = _default.variantScope;
25
+ exports.variantSelector = _default.variantSelector;
25
26
  exports.variantTaggedPseudoClasses = _default.variantTaggedPseudoClasses;
26
27
  exports.variants = _default.variants;
@@ -1,17 +1,16 @@
1
1
  import { Variant, VariantFunction, VariantObject } from '@unocss/core';
2
- import { T as Theme } from './types-f185ef8d';
2
+ import { T as Theme } from './types-ef1d7462';
3
3
  import { PresetMiniOptions } from './index';
4
- import './default-595a2a04';
5
- import './colors-06de139a';
6
- import './utilities-df1ea892';
4
+ import './default-3eaf5bb0';
5
+ import './colors-0db1b382';
6
+ import './utilities-43c87ad4';
7
7
 
8
8
  declare const variantBreakpoints: Variant<Theme>;
9
9
 
10
10
  declare const variantCombinators: Variant[];
11
11
 
12
- declare const variantMotions: VariantFunction[];
13
- declare const variantOrientations: VariantFunction[];
14
12
  declare const variantPrint: VariantFunction;
13
+ declare const variantCustomMedia: VariantFunction;
15
14
 
16
15
  declare const variantColorsMediaOrClass: (options?: PresetMiniOptions) => VariantFunction[];
17
16
 
@@ -19,7 +18,9 @@ declare const variants: (options: PresetMiniOptions) => Variant<Theme>[];
19
18
 
20
19
  declare const variantLanguageDirections: Variant[];
21
20
 
21
+ declare const variantSelector: Variant;
22
22
  declare const variantLayer: Variant;
23
+ declare const variantScope: Variant;
23
24
  declare const variantImportant: Variant;
24
25
  declare const variantNegative: Variant;
25
26
 
@@ -29,4 +30,4 @@ declare const variantPseudoClassFunctions: VariantObject;
29
30
  declare const variantTaggedPseudoClasses: (options?: PresetMiniOptions) => VariantObject[];
30
31
  declare const partClasses: VariantObject;
31
32
 
32
- export { partClasses, variantBreakpoints, variantColorsMediaOrClass, variantCombinators, variantImportant, variantLanguageDirections, variantLayer, variantMotions, variantNegative, variantOrientations, variantPrint, variantPseudoClassFunctions, variantPseudoClasses, variantPseudoElements, variantTaggedPseudoClasses, variants };
33
+ export { partClasses, variantBreakpoints, variantColorsMediaOrClass, variantCombinators, variantCustomMedia, variantImportant, variantLanguageDirections, variantLayer, variantNegative, variantPrint, variantPseudoClassFunctions, variantPseudoClasses, variantPseudoElements, variantScope, variantSelector, variantTaggedPseudoClasses, variants };
package/dist/variants.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { p as partClasses, a as variantBreakpoints, f as variantColorsMediaOrClass, b as variantCombinators, i as variantImportant, g as variantLanguageDirections, h as variantLayer, c as variantMotions, j as variantNegative, d as variantOrientations, e as variantPrint, m as variantPseudoClassFunctions, l as variantPseudoClasses, k as variantPseudoElements, n as variantTaggedPseudoClasses, v as variants } from './chunks/default3.mjs';
1
+ export { p as partClasses, a as variantBreakpoints, e as variantColorsMediaOrClass, b as variantCombinators, d as variantCustomMedia, j as variantImportant, f as variantLanguageDirections, h as variantLayer, k as variantNegative, c as variantPrint, n as variantPseudoClassFunctions, m as variantPseudoClasses, l as variantPseudoElements, i as variantScope, g as variantSelector, o as variantTaggedPseudoClasses, v as variants } from './chunks/default3.mjs';
2
2
  import './chunks/variants.mjs';
3
3
  import '@unocss/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.24.4",
3
+ "version": "0.25.0",
4
4
  "description": "The minimal preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -61,7 +61,7 @@
61
61
  "*.css"
62
62
  ],
63
63
  "dependencies": {
64
- "@unocss/core": "0.24.4"
64
+ "@unocss/core": "0.25.0"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",