@unocss/preset-wind 0.22.6 → 0.24.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
@@ -1,6 +1,6 @@
1
1
  # @unocss/preset-wind
2
2
 
3
- Tailwind / Windi CSS compact preset for UnoCSS, [UnoCSS](https://github.com/antfu/unocss).
3
+ Tailwind / Windi CSS compact preset for UnoCSS, [UnoCSS](https://github.com/unocss/unocss).
4
4
 
5
5
  ## Installation
6
6
 
package/dist/index.cjs CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const variants = require('@unocss/preset-mini/variants');
6
5
  const core = require('@unocss/core');
7
6
  const theme$1 = require('@unocss/preset-mini/theme');
8
7
  const presetMini = require('@unocss/preset-mini');
9
8
  const rules$1 = require('@unocss/preset-mini/rules');
10
9
  const utils = require('@unocss/preset-mini/utils');
10
+ const variants$1 = require('@unocss/preset-mini/variants');
11
11
 
12
12
  const animations = [
13
13
  [/^(?:animate-)?keyframes-(.+)$/, ([, name], { theme, constructCSS }) => {
@@ -25,16 +25,14 @@ ${constructCSS({ animation: `${name}` })}`;
25
25
  return `@keyframes ${name}${kf}
26
26
  ${constructCSS(Object.assign({ animation: `${name} ${duration} ${timing} infinite` }, props))}`;
27
27
  }
28
- return { animate: utils.handler.bracket.cssvar(name) };
28
+ return { animation: utils.handler.bracket.cssvar(name) };
29
29
  }],
30
30
  [/^animate-name-(.+)/, ([, d]) => ({ "animation-name": utils.handler.bracket.cssvar(d) ?? d })],
31
31
  [/^animate-duration-(.+)$/, ([, d]) => ({ "animation-duration": utils.handler.bracket.cssvar.time(d) })],
32
32
  [/^animate-delay-(.+)$/, ([, d]) => ({ "animation-delay": utils.handler.bracket.cssvar.time(d) })],
33
33
  [/^animate-ease(?:-(.+))?$/, ([, d], { theme }) => ({ "animation-timing-function": theme.easing?.[d || "DEFAULT"] ?? utils.handler.bracket.cssvar(d) })],
34
- [/^animate-(?:fill-|mode-|fill-mode-)?(forwards|backwards|both|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-fill-mode": d })],
35
- [/^animate-(?:fill-|mode-|fill-mode-)none$/, () => ({ "animation-fill-mode": "none" })],
36
- [/^animate-(?:direction-)?(reverse|alternate|alternate-reverse|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-direction": d })],
37
- [/^animate-(?:direction-)?normal$/, () => ({ "animation-direction": "normal" })],
34
+ [/^animate-(?:fill-|mode-|fill-mode-)?(none|forwards|backwards|both|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-fill-mode": d })],
35
+ [/^animate-(?:direction-)?(normal|reverse|alternate|alternate-reverse|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-direction": d })],
38
36
  [/^animate-(?:iteration-|count-|iteration-count-)(.+)$/, ([, d]) => ({ "animation-iteration-count": utils.handler.bracket.cssvar(d) ?? d.replace(/\-/g, ",") })],
39
37
  [/^animate-(?:play-|state-|play-state-)?(paused|running|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-play-state": d })],
40
38
  ["animate-none", { animation: "none" }]
@@ -44,15 +42,15 @@ const bgGradientColorResolver = (mode) => ([, body], { theme }) => {
44
42
  const data = utils.parseColor(body, theme);
45
43
  if (!data)
46
44
  return;
47
- const { alpha, color, rgba } = data;
45
+ const { alpha, color, cssColor } = data;
48
46
  if (!color)
49
47
  return;
50
48
  let colorString = color;
51
- if (rgba) {
49
+ if (cssColor) {
52
50
  if (alpha != null)
53
- colorString = `rgba(${rgba.join(",")})`;
51
+ colorString = utils.colorToString(cssColor, alpha);
54
52
  else
55
- colorString = `rgba(${rgba.join(",")}, var(--un-${mode}-opacity, 1))`;
53
+ colorString = utils.colorToString(cssColor, `var(--un-${mode}-opacity, ${cssColor.alpha ?? 1})`);
56
54
  }
57
55
  switch (mode) {
58
56
  case "from":
@@ -267,8 +265,8 @@ const percentWithDefault = (str) => {
267
265
  return v;
268
266
  };
269
267
  const toFilter = (varName, resolver) => ([, b, s], { theme }) => {
270
- const value = resolver(s, theme);
271
- if (value != null && value !== "") {
268
+ const value = resolver(s, theme) ?? (s === "none" ? "0" : "");
269
+ if (value !== "") {
272
270
  if (b) {
273
271
  return [
274
272
  backdropFilterBase,
@@ -292,7 +290,7 @@ const toFilter = (varName, resolver) => ([, b, s], { theme }) => {
292
290
  const dropShadowResolver = ([, s], { theme }) => {
293
291
  let v = theme.dropShadow?.[s || "DEFAULT"];
294
292
  if (v != null) {
295
- const shadows = rules$1.colorableShadows(v, "--un-drop-shadow-color");
293
+ const shadows = utils.colorableShadows(v, "--un-drop-shadow-color");
296
294
  return [
297
295
  filterBase,
298
296
  {
@@ -340,12 +338,7 @@ const filters = [
340
338
  ["backdrop-filter-none", {
341
339
  "-webkit-backdrop-filter": "none",
342
340
  "backdrop-filter": "none"
343
- }],
344
- [/^(?:filter-)?(blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia)-none$/, ([, s]) => ({ filter: `${s}(0)` })],
345
- [/^backdrop-(blur|brightness|contrast|grayscale|hue-rotate|invert|opacity|saturate|sepia)-none$/, ([, s]) => ({
346
- "-webkit-backdrop-filter": `${s}(0)`,
347
- "backdrop-filter": `${s}(0)`
348
- })]
341
+ }]
349
342
  ];
350
343
 
351
344
  const spaces = [
@@ -755,6 +748,10 @@ const rules = [
755
748
  rules$1.questionMark
756
749
  ].flat(1);
757
750
 
751
+ const shortcuts = [
752
+ ...containerShortcuts
753
+ ];
754
+
758
755
  const theme = {
759
756
  ...theme$1.theme,
760
757
  animation: {
@@ -948,6 +945,13 @@ function hasOpacityValue(body) {
948
945
  return false;
949
946
  }
950
947
 
948
+ const variants = (options) => [
949
+ placeholderModifier,
950
+ variantSpaceAndDivide,
951
+ ...variants$1.variants(options),
952
+ ...variantColorsScheme
953
+ ];
954
+
951
955
  const presetWind = (options = {}) => {
952
956
  options.dark = options.dark ?? "class";
953
957
  options.attributifyPseudo = options.attributifyPseudo ?? false;
@@ -955,15 +959,8 @@ const presetWind = (options = {}) => {
955
959
  name: "@unocss/preset-wind",
956
960
  theme,
957
961
  rules,
958
- shortcuts: [
959
- ...containerShortcuts
960
- ],
961
- variants: [
962
- placeholderModifier,
963
- variantSpaceAndDivide,
964
- ...variants.variants(options),
965
- ...variantColorsScheme
966
- ],
962
+ shortcuts,
963
+ variants: variants(options),
967
964
  options
968
965
  };
969
966
  };
@@ -971,4 +968,7 @@ const presetWind = (options = {}) => {
971
968
  exports.colors = presetMini.colors;
972
969
  exports["default"] = presetWind;
973
970
  exports.presetWind = presetWind;
971
+ exports.rules = rules;
972
+ exports.shortcuts = shortcuts;
974
973
  exports.theme = theme;
974
+ exports.variants = variants;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,19 @@
1
- import { Preset } from '@unocss/core';
1
+ import * as _unocss_core from '@unocss/core';
2
+ import { Rule, Variant, Preset } from '@unocss/core';
3
+ import * as _unocss_preset_mini from '@unocss/preset-mini';
2
4
  import { Theme, PresetMiniOptions } from '@unocss/preset-mini';
3
5
  export { Theme, colors } from '@unocss/preset-mini';
4
6
 
7
+ declare const rules: Rule[];
8
+
9
+ declare const shortcuts: _unocss_core.Shortcut<_unocss_preset_mini.Theme>[];
10
+
5
11
  declare const theme: Theme;
6
12
 
13
+ declare const variants: (options: UnoOptions) => Variant<Theme>[];
14
+
7
15
  interface UnoOptions extends PresetMiniOptions {
8
16
  }
9
17
  declare const presetWind: (options?: UnoOptions) => Preset<Theme>;
10
18
 
11
- export { UnoOptions, presetWind as default, presetWind, theme };
19
+ export { UnoOptions, presetWind as default, presetWind, rules, shortcuts, theme, variants };
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { variants } from '@unocss/preset-mini/variants';
2
1
  import { toArray, CONTROL_SHORTCUT_NO_MERGE } from '@unocss/core';
3
2
  import { theme as theme$1 } from '@unocss/preset-mini/theme';
4
3
  export { colors } from '@unocss/preset-mini';
5
- import { varEmpty, colorableShadows, cssVariables as cssVariables$1, cssProperty, pointerEvents, appearances, positions, insets, zIndexes, orders, grids, floats, margins, boxSizing, displays, aspectRatio, sizes, flex, transforms, cursors, userSelects, resizes, appearance, placements, alignments, justifies, gaps, overflows, textOverflows, whitespaces, breaks, borders, bgColors, svgUtilities, paddings, textAligns, textIndents, verticalAligns, fonts, fontStyles, textColors, textDecorations, fontSmoothings, tabSizes, textStrokes, textShadows, opacity, boxShadows, outline, rings, transitions, willChange, contents, questionMark } from '@unocss/preset-mini/rules';
6
- import { handler, positionMap, parseColor, colorResolver, directionMap, directionSize, variantMatcher, variantParentMatcher } from '@unocss/preset-mini/utils';
4
+ import { varEmpty, cssVariables as cssVariables$1, cssProperty, pointerEvents, appearances, positions, insets, zIndexes, orders, grids, floats, margins, boxSizing, displays, aspectRatio, sizes, flex, transforms, cursors, userSelects, resizes, appearance, placements, alignments, justifies, gaps, overflows, textOverflows, whitespaces, breaks, borders, bgColors, svgUtilities, paddings, textAligns, textIndents, verticalAligns, fonts, fontStyles, textColors, textDecorations, fontSmoothings, tabSizes, textStrokes, textShadows, opacity, boxShadows, outline, rings, transitions, willChange, contents, questionMark } from '@unocss/preset-mini/rules';
5
+ import { handler, positionMap, parseColor, colorToString, colorResolver, colorableShadows, directionMap, directionSize, variantMatcher, variantParentMatcher } from '@unocss/preset-mini/utils';
6
+ import { variants as variants$1 } from '@unocss/preset-mini/variants';
7
7
 
8
8
  const animations = [
9
9
  [/^(?:animate-)?keyframes-(.+)$/, ([, name], { theme, constructCSS }) => {
@@ -21,16 +21,14 @@ ${constructCSS({ animation: `${name}` })}`;
21
21
  return `@keyframes ${name}${kf}
22
22
  ${constructCSS(Object.assign({ animation: `${name} ${duration} ${timing} infinite` }, props))}`;
23
23
  }
24
- return { animate: handler.bracket.cssvar(name) };
24
+ return { animation: handler.bracket.cssvar(name) };
25
25
  }],
26
26
  [/^animate-name-(.+)/, ([, d]) => ({ "animation-name": handler.bracket.cssvar(d) ?? d })],
27
27
  [/^animate-duration-(.+)$/, ([, d]) => ({ "animation-duration": handler.bracket.cssvar.time(d) })],
28
28
  [/^animate-delay-(.+)$/, ([, d]) => ({ "animation-delay": handler.bracket.cssvar.time(d) })],
29
29
  [/^animate-ease(?:-(.+))?$/, ([, d], { theme }) => ({ "animation-timing-function": theme.easing?.[d || "DEFAULT"] ?? handler.bracket.cssvar(d) })],
30
- [/^animate-(?:fill-|mode-|fill-mode-)?(forwards|backwards|both|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-fill-mode": d })],
31
- [/^animate-(?:fill-|mode-|fill-mode-)none$/, () => ({ "animation-fill-mode": "none" })],
32
- [/^animate-(?:direction-)?(reverse|alternate|alternate-reverse|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-direction": d })],
33
- [/^animate-(?:direction-)?normal$/, () => ({ "animation-direction": "normal" })],
30
+ [/^animate-(?:fill-|mode-|fill-mode-)?(none|forwards|backwards|both|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-fill-mode": d })],
31
+ [/^animate-(?:direction-)?(normal|reverse|alternate|alternate-reverse|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-direction": d })],
34
32
  [/^animate-(?:iteration-|count-|iteration-count-)(.+)$/, ([, d]) => ({ "animation-iteration-count": handler.bracket.cssvar(d) ?? d.replace(/\-/g, ",") })],
35
33
  [/^animate-(?:play-|state-|play-state-)?(paused|running|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-play-state": d })],
36
34
  ["animate-none", { animation: "none" }]
@@ -40,15 +38,15 @@ const bgGradientColorResolver = (mode) => ([, body], { theme }) => {
40
38
  const data = parseColor(body, theme);
41
39
  if (!data)
42
40
  return;
43
- const { alpha, color, rgba } = data;
41
+ const { alpha, color, cssColor } = data;
44
42
  if (!color)
45
43
  return;
46
44
  let colorString = color;
47
- if (rgba) {
45
+ if (cssColor) {
48
46
  if (alpha != null)
49
- colorString = `rgba(${rgba.join(",")})`;
47
+ colorString = colorToString(cssColor, alpha);
50
48
  else
51
- colorString = `rgba(${rgba.join(",")}, var(--un-${mode}-opacity, 1))`;
49
+ colorString = colorToString(cssColor, `var(--un-${mode}-opacity, ${cssColor.alpha ?? 1})`);
52
50
  }
53
51
  switch (mode) {
54
52
  case "from":
@@ -263,8 +261,8 @@ const percentWithDefault = (str) => {
263
261
  return v;
264
262
  };
265
263
  const toFilter = (varName, resolver) => ([, b, s], { theme }) => {
266
- const value = resolver(s, theme);
267
- if (value != null && value !== "") {
264
+ const value = resolver(s, theme) ?? (s === "none" ? "0" : "");
265
+ if (value !== "") {
268
266
  if (b) {
269
267
  return [
270
268
  backdropFilterBase,
@@ -336,12 +334,7 @@ const filters = [
336
334
  ["backdrop-filter-none", {
337
335
  "-webkit-backdrop-filter": "none",
338
336
  "backdrop-filter": "none"
339
- }],
340
- [/^(?:filter-)?(blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia)-none$/, ([, s]) => ({ filter: `${s}(0)` })],
341
- [/^backdrop-(blur|brightness|contrast|grayscale|hue-rotate|invert|opacity|saturate|sepia)-none$/, ([, s]) => ({
342
- "-webkit-backdrop-filter": `${s}(0)`,
343
- "backdrop-filter": `${s}(0)`
344
- })]
337
+ }]
345
338
  ];
346
339
 
347
340
  const spaces = [
@@ -751,6 +744,10 @@ const rules = [
751
744
  questionMark
752
745
  ].flat(1);
753
746
 
747
+ const shortcuts = [
748
+ ...containerShortcuts
749
+ ];
750
+
754
751
  const theme = {
755
752
  ...theme$1,
756
753
  animation: {
@@ -944,6 +941,13 @@ function hasOpacityValue(body) {
944
941
  return false;
945
942
  }
946
943
 
944
+ const variants = (options) => [
945
+ placeholderModifier,
946
+ variantSpaceAndDivide,
947
+ ...variants$1(options),
948
+ ...variantColorsScheme
949
+ ];
950
+
947
951
  const presetWind = (options = {}) => {
948
952
  options.dark = options.dark ?? "class";
949
953
  options.attributifyPseudo = options.attributifyPseudo ?? false;
@@ -951,17 +955,10 @@ const presetWind = (options = {}) => {
951
955
  name: "@unocss/preset-wind",
952
956
  theme,
953
957
  rules,
954
- shortcuts: [
955
- ...containerShortcuts
956
- ],
957
- variants: [
958
- placeholderModifier,
959
- variantSpaceAndDivide,
960
- ...variants(options),
961
- ...variantColorsScheme
962
- ],
958
+ shortcuts,
959
+ variants: variants(options),
963
960
  options
964
961
  };
965
962
  };
966
963
 
967
- export { presetWind as default, presetWind, theme };
964
+ export { presetWind as default, presetWind, rules, shortcuts, theme, variants };
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@unocss/preset-wind",
3
- "version": "0.22.6",
3
+ "version": "0.24.1",
4
4
  "description": "Tailwind / Windi CSS compact preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
7
7
  "unocss-preset"
8
8
  ],
9
- "homepage": "https://github.com/antfu/unocss/tree/main/packages/preset-wind#readme",
9
+ "homepage": "https://github.com/unocss/unocss/tree/main/packages/preset-wind#readme",
10
10
  "bugs": {
11
- "url": "https://github.com/antfu/unocss/issues"
11
+ "url": "https://github.com/unocss/unocss/issues"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git+https://github.com/antfu/unocss.git",
15
+ "url": "git+https://github.com/unocss/unocss.git",
16
16
  "directory": "packages/preset-wind"
17
17
  },
18
18
  "funding": "https://github.com/sponsors/antfu",
@@ -35,8 +35,8 @@
35
35
  "*.css"
36
36
  ],
37
37
  "dependencies": {
38
- "@unocss/core": "0.22.6",
39
- "@unocss/preset-mini": "0.22.6"
38
+ "@unocss/core": "0.24.1",
39
+ "@unocss/preset-mini": "0.24.1"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "unbuild",