@unocss/preset-wind 0.22.2 → 0.22.6

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/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@ const rules$1 = require('@unocss/preset-mini/rules');
10
10
  const utils = require('@unocss/preset-mini/utils');
11
11
 
12
12
  const animations = [
13
- [/^keyframes-(.+)$/, ([, name], { theme, constructCSS }) => {
13
+ [/^(?:animate-)?keyframes-(.+)$/, ([, name], { theme, constructCSS }) => {
14
14
  const kf = theme.animation?.keyframes?.[name];
15
15
  if (kf)
16
16
  return `@keyframes ${name}${kf}
@@ -25,18 +25,18 @@ ${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
29
  }],
29
- [/^animate-(?:duration-)?(.+)$/, ([, d]) => ({ "animation-duration": utils.handler.bracket.time(d) })],
30
- [/^animate-delay-(.+)$/, ([, d]) => ({ "animation-delay": utils.handler.bracket.time(d) })],
31
- [/^animate-(?:fill-)?mode-(forwards|backwards|both|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-fill-mode": d })],
32
- ["animate-mode-none", { "animation-fill-mode": "none" }],
33
- ["animate-fill-mode-none", { "animation-fill-mode": "none" }],
30
+ [/^animate-name-(.+)/, ([, d]) => ({ "animation-name": utils.handler.bracket.cssvar(d) ?? d })],
31
+ [/^animate-duration-(.+)$/, ([, d]) => ({ "animation-duration": utils.handler.bracket.cssvar.time(d) })],
32
+ [/^animate-delay-(.+)$/, ([, d]) => ({ "animation-delay": utils.handler.bracket.cssvar.time(d) })],
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" })],
34
36
  [/^animate-(?:direction-)?(reverse|alternate|alternate-reverse|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-direction": d })],
35
- ["animate-normal", { "animation-direction": "normal" }],
36
- ["animate-direction-normal", { "animation-direction": "normal" }],
37
- [/^animate-(?:iteration-)?count-(.+)$/, ([, d]) => ({ "animation-iteration-count": utils.handler.bracket(d) ?? d.replace(/\-/g, ",") })],
38
- [/^animate-name-(.+)/, ([, d]) => ({ "animation-name": d })],
39
- [/^animate-play(?:-state)?-(paused|running|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-play-state": d })],
37
+ [/^animate-(?:direction-)?normal$/, () => ({ "animation-direction": "normal" })],
38
+ [/^animate-(?:iteration-|count-|iteration-count-)(.+)$/, ([, d]) => ({ "animation-iteration-count": utils.handler.bracket.cssvar(d) ?? d.replace(/\-/g, ",") })],
39
+ [/^animate-(?:play-|state-|play-state-)?(paused|running|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-play-state": d })],
40
40
  ["animate-none", { animation: "none" }]
41
41
  ];
42
42
 
@@ -175,7 +175,7 @@ const scrollBehaviors = [
175
175
  ];
176
176
 
177
177
  const columns = [
178
- [/^columns-(.+)$/, ([, v]) => ({ column: utils.handler.bracket.global.number.auto.numberWithUnit(v) })],
178
+ [/^columns-(.+)$/, ([, v]) => ({ columns: utils.handler.bracket.global.number.auto.numberWithUnit(v) })],
179
179
  ["break-before-auto", { "break-before": "auto" }],
180
180
  ["break-before-avoid", { "break-before": "avoid" }],
181
181
  ["break-before-all", { "break-before": "all" }],
@@ -259,7 +259,7 @@ const backdropFilterBase = {
259
259
  [core.CONTROL_SHORTCUT_NO_MERGE]: ""
260
260
  };
261
261
  const percentWithDefault = (str) => {
262
- let v = utils.handler.bracket(str || "");
262
+ let v = utils.handler.bracket.cssvar(str || "");
263
263
  if (v != null)
264
264
  return v;
265
265
  v = str ? utils.handler.percent(str) : "1";
@@ -301,7 +301,7 @@ const dropShadowResolver = ([, s], { theme }) => {
301
301
  }
302
302
  ];
303
303
  }
304
- v = utils.handler.bracket(s);
304
+ v = utils.handler.bracket.cssvar(s);
305
305
  if (v != null) {
306
306
  return [
307
307
  filterBase,
@@ -313,17 +313,17 @@ const dropShadowResolver = ([, s], { theme }) => {
313
313
  }
314
314
  };
315
315
  const filters = [
316
- [/^(?:(backdrop-)|filter-)?blur(?:-(.+))?$/, toFilter("blur", (s, theme) => theme.blur?.[s || "DEFAULT"] || utils.handler.bracket.px(s))],
317
- [/^(?:(backdrop-)|filter-)?brightness-(.+)$/, toFilter("brightness", (s) => utils.handler.bracket.percent(s))],
318
- [/^(?:(backdrop-)|filter-)?contrast-(.+)$/, toFilter("contrast", (s) => utils.handler.bracket.percent(s))],
316
+ [/^(?:(backdrop-)|filter-)?blur(?:-(.+))?$/, toFilter("blur", (s, theme) => theme.blur?.[s || "DEFAULT"] || utils.handler.bracket.cssvar.px(s))],
317
+ [/^(?:(backdrop-)|filter-)?brightness-(.+)$/, toFilter("brightness", (s) => utils.handler.bracket.cssvar.percent(s))],
318
+ [/^(?:(backdrop-)|filter-)?contrast-(.+)$/, toFilter("contrast", (s) => utils.handler.bracket.cssvar.percent(s))],
319
319
  [/^(?:filter-)?drop-shadow(?:-(.+))?$/, dropShadowResolver],
320
320
  [/^(?:filter-)?drop-shadow-color-(.+)$/, utils.colorResolver("--un-drop-shadow-color", "drop-shadow")],
321
- [/^(?:filter-)?drop-shadow-color-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-drop-shadow-opacity": utils.handler.bracket.percent.cssvar(opacity) })],
321
+ [/^(?:filter-)?drop-shadow-color-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-drop-shadow-opacity": utils.handler.bracket.percent(opacity) })],
322
322
  [/^(?:(backdrop-)|filter-)?grayscale(?:-(.+))?$/, toFilter("grayscale", percentWithDefault)],
323
- [/^(?:(backdrop-)|filter-)?hue-rotate-(.+)$/, toFilter("hue-rotate", (s) => utils.handler.bracket.degree(s))],
323
+ [/^(?:(backdrop-)|filter-)?hue-rotate-(.+)$/, toFilter("hue-rotate", (s) => utils.handler.bracket.cssvar.degree(s))],
324
324
  [/^(?:(backdrop-)|filter-)?invert(?:-(.+))?$/, toFilter("invert", percentWithDefault)],
325
- [/^(backdrop-)opacity-(.+)$/, toFilter("opacity", (s) => utils.handler.bracket.percent(s))],
326
- [/^(?:(backdrop-)|filter-)?saturate-(.+)$/, toFilter("saturate", (s) => utils.handler.bracket.percent(s))],
325
+ [/^(backdrop-)opacity-(.+)$/, toFilter("opacity", (s) => utils.handler.bracket.cssvar.percent(s))],
326
+ [/^(?:(backdrop-)|filter-)?saturate-(.+)$/, toFilter("saturate", (s) => utils.handler.bracket.cssvar.percent(s))],
327
327
  [/^(?:(backdrop-)|filter-)?sepia(?:-(.+))?$/, toFilter("sepia", percentWithDefault)],
328
328
  [/^filter$/, () => [
329
329
  filterBase,
@@ -354,17 +354,20 @@ const spaces = [
354
354
  [/^space-(block|inline)-(-?.+)$/, handlerSpace],
355
355
  [/^space-(block|inline)-reverse$/, ([, d]) => ({ [`--un-space-${d}-reverse`]: 1 })]
356
356
  ];
357
- function handlerSpace(match) {
358
- const [, direction] = match;
359
- const results = utils.directionSize("margin")(match)?.map((item) => {
360
- const value = item[0].endsWith("right") || item[0].endsWith("bottom") ? `calc(${item[1]} * var(--un-space-${direction}-reverse))` : `calc(${item[1]} * calc(1 - var(--un-space-${direction}-reverse)))`;
361
- return [item[0], value];
362
- });
363
- if (results) {
364
- return [
365
- [`--un-space-${direction}-reverse`, 0],
366
- ...results
367
- ];
357
+ function handlerSpace([, d, s = "1"]) {
358
+ const v = utils.handler.bracket.cssvar.auto.fraction.rem(s);
359
+ if (v != null) {
360
+ const results = utils.directionMap[d].map((item) => {
361
+ const key = `margin${item}`;
362
+ const value = item.endsWith("right") || item.endsWith("bottom") ? `calc(${v} * var(--un-space-${d}-reverse))` : `calc(${v} * calc(1 - var(--un-space-${d}-reverse)))`;
363
+ return [key, value];
364
+ });
365
+ if (results) {
366
+ return [
367
+ [`--un-space-${d}-reverse`, 0],
368
+ ...results
369
+ ];
370
+ }
368
371
  }
369
372
  }
370
373
 
@@ -502,26 +505,27 @@ const tables = [
502
505
  ];
503
506
 
504
507
  const variablesAbbrMap = {
505
- "write": "writing-mode",
506
- "write-orient": "text-orientation",
507
508
  "bg-blend": "background-blend-mode",
508
509
  "bg-clip": "-webkit-background-clip",
509
510
  "bg-gradient": "linear-gradient",
510
- "bg-origin-border": "background-origin",
511
+ "bg-image": "background-image",
512
+ "bg-origin": "background-origin",
511
513
  "bg-position": "background-position",
512
514
  "bg-repeat": "background-repeat",
513
515
  "bg-size": "background-size",
514
516
  "mix-blend": "mix-blend-mode",
515
- "animate-speed": "animation-speed"
517
+ "object": "object-fit",
518
+ "object-position": "object-position",
519
+ "write": "writing-mode",
520
+ "write-orient": "text-orientation"
516
521
  };
517
- const cssVariables = [[
518
- /^(.+)-\$(.+)$/,
519
- ([, name, varname]) => {
522
+ const cssVariables = [
523
+ [/^(.+?)-(\$.+)$/, ([, name, varname]) => {
520
524
  const prop = variablesAbbrMap[name];
521
525
  if (prop)
522
- return { [prop]: `var(--${varname})` };
523
- }
524
- ]];
526
+ return { [prop]: utils.handler.cssvar(varname) };
527
+ }]
528
+ ];
525
529
 
526
530
  const divides = [
527
531
  [/^divide-?([xy])$/, handlerDivide],
@@ -539,15 +543,19 @@ const divides = [
539
543
  ["divide-none", { "border-style": "none" }]
540
544
  ];
541
545
  function handlerDivide([, d, s = "1"]) {
542
- const v = utils.handler.bracket.px(s);
546
+ const v = utils.handler.bracket.cssvar.px(s);
543
547
  if (v != null) {
544
548
  const results = utils.directionMap[d].map((item) => {
545
549
  const key = `border${item}-width`;
546
550
  const value = item.endsWith("right") || item.endsWith("bottom") ? `calc(${v} * var(--un-divide-${d}-reverse))` : `calc(${v} * calc(1 - var(--un-divide-${d}-reverse)))`;
547
551
  return [key, value];
548
552
  });
549
- if (results)
550
- return [[`--un-divide-${d}-reverse`, 0], ...results];
553
+ if (results) {
554
+ return [
555
+ [`--un-divide-${d}-reverse`, 0],
556
+ ...results
557
+ ];
558
+ }
551
559
  }
552
560
  }
553
561
 
@@ -660,7 +668,7 @@ const scrolls = [
660
668
 
661
669
  const placeholders = [
662
670
  [/^\$ placeholder-(.+)$/, utils.colorResolver("color", "placeholder")],
663
- [/^\$ placeholder-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-placeholder-opacity": utils.handler.bracket.percent.cssvar(opacity) })]
671
+ [/^\$ placeholder-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-placeholder-opacity": utils.handler.bracket.percent(opacity) })]
664
672
  ];
665
673
 
666
674
  const rules = [
@@ -920,7 +928,7 @@ const variantSpaceAndDivide = (matcher) => {
920
928
  };
921
929
 
922
930
  const placeholderModifier = (input, { theme }) => {
923
- const m = input.match(/^(.*)\b(placeholder-)(.+?)$/);
931
+ const m = input.match(/^(.*)\b(placeholder-)(.+)$/);
924
932
  if (m) {
925
933
  const [, pre = "", p, body] = m;
926
934
  if (hasColorValue(body, theme) || hasOpacityValue(body)) {
@@ -936,7 +944,7 @@ function hasColorValue(body, theme) {
936
944
  function hasOpacityValue(body) {
937
945
  const match = body.match(/^op(?:acity)?-?(.+)$/);
938
946
  if (match && match[1] != null)
939
- return utils.handler.bracket.percent.cssvar(match[1]) != null;
947
+ return utils.handler.bracket.percent(match[1]) != null;
940
948
  return false;
941
949
  }
942
950
 
package/dist/index.mjs CHANGED
@@ -3,10 +3,10 @@ import { toArray, CONTROL_SHORTCUT_NO_MERGE } from '@unocss/core';
3
3
  import { theme as theme$1 } from '@unocss/preset-mini/theme';
4
4
  export { colors } from '@unocss/preset-mini';
5
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, directionSize, directionMap, variantMatcher, variantParentMatcher } from '@unocss/preset-mini/utils';
6
+ import { handler, positionMap, parseColor, colorResolver, directionMap, directionSize, variantMatcher, variantParentMatcher } from '@unocss/preset-mini/utils';
7
7
 
8
8
  const animations = [
9
- [/^keyframes-(.+)$/, ([, name], { theme, constructCSS }) => {
9
+ [/^(?:animate-)?keyframes-(.+)$/, ([, name], { theme, constructCSS }) => {
10
10
  const kf = theme.animation?.keyframes?.[name];
11
11
  if (kf)
12
12
  return `@keyframes ${name}${kf}
@@ -21,18 +21,18 @@ ${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
25
  }],
25
- [/^animate-(?:duration-)?(.+)$/, ([, d]) => ({ "animation-duration": handler.bracket.time(d) })],
26
- [/^animate-delay-(.+)$/, ([, d]) => ({ "animation-delay": handler.bracket.time(d) })],
27
- [/^animate-(?:fill-)?mode-(forwards|backwards|both|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-fill-mode": d })],
28
- ["animate-mode-none", { "animation-fill-mode": "none" }],
29
- ["animate-fill-mode-none", { "animation-fill-mode": "none" }],
26
+ [/^animate-name-(.+)/, ([, d]) => ({ "animation-name": handler.bracket.cssvar(d) ?? d })],
27
+ [/^animate-duration-(.+)$/, ([, d]) => ({ "animation-duration": handler.bracket.cssvar.time(d) })],
28
+ [/^animate-delay-(.+)$/, ([, d]) => ({ "animation-delay": handler.bracket.cssvar.time(d) })],
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" })],
30
32
  [/^animate-(?:direction-)?(reverse|alternate|alternate-reverse|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-direction": d })],
31
- ["animate-normal", { "animation-direction": "normal" }],
32
- ["animate-direction-normal", { "animation-direction": "normal" }],
33
- [/^animate-(?:iteration-)?count-(.+)$/, ([, d]) => ({ "animation-iteration-count": handler.bracket(d) ?? d.replace(/\-/g, ",") })],
34
- [/^animate-name-(.+)/, ([, d]) => ({ "animation-name": d })],
35
- [/^animate-play(?:-state)?-(paused|running|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-play-state": d })],
33
+ [/^animate-(?:direction-)?normal$/, () => ({ "animation-direction": "normal" })],
34
+ [/^animate-(?:iteration-|count-|iteration-count-)(.+)$/, ([, d]) => ({ "animation-iteration-count": handler.bracket.cssvar(d) ?? d.replace(/\-/g, ",") })],
35
+ [/^animate-(?:play-|state-|play-state-)?(paused|running|inherit|initial|revert|unset)$/, ([, d]) => ({ "animation-play-state": d })],
36
36
  ["animate-none", { animation: "none" }]
37
37
  ];
38
38
 
@@ -171,7 +171,7 @@ const scrollBehaviors = [
171
171
  ];
172
172
 
173
173
  const columns = [
174
- [/^columns-(.+)$/, ([, v]) => ({ column: handler.bracket.global.number.auto.numberWithUnit(v) })],
174
+ [/^columns-(.+)$/, ([, v]) => ({ columns: handler.bracket.global.number.auto.numberWithUnit(v) })],
175
175
  ["break-before-auto", { "break-before": "auto" }],
176
176
  ["break-before-avoid", { "break-before": "avoid" }],
177
177
  ["break-before-all", { "break-before": "all" }],
@@ -255,7 +255,7 @@ const backdropFilterBase = {
255
255
  [CONTROL_SHORTCUT_NO_MERGE]: ""
256
256
  };
257
257
  const percentWithDefault = (str) => {
258
- let v = handler.bracket(str || "");
258
+ let v = handler.bracket.cssvar(str || "");
259
259
  if (v != null)
260
260
  return v;
261
261
  v = str ? handler.percent(str) : "1";
@@ -297,7 +297,7 @@ const dropShadowResolver = ([, s], { theme }) => {
297
297
  }
298
298
  ];
299
299
  }
300
- v = handler.bracket(s);
300
+ v = handler.bracket.cssvar(s);
301
301
  if (v != null) {
302
302
  return [
303
303
  filterBase,
@@ -309,17 +309,17 @@ const dropShadowResolver = ([, s], { theme }) => {
309
309
  }
310
310
  };
311
311
  const filters = [
312
- [/^(?:(backdrop-)|filter-)?blur(?:-(.+))?$/, toFilter("blur", (s, theme) => theme.blur?.[s || "DEFAULT"] || handler.bracket.px(s))],
313
- [/^(?:(backdrop-)|filter-)?brightness-(.+)$/, toFilter("brightness", (s) => handler.bracket.percent(s))],
314
- [/^(?:(backdrop-)|filter-)?contrast-(.+)$/, toFilter("contrast", (s) => handler.bracket.percent(s))],
312
+ [/^(?:(backdrop-)|filter-)?blur(?:-(.+))?$/, toFilter("blur", (s, theme) => theme.blur?.[s || "DEFAULT"] || handler.bracket.cssvar.px(s))],
313
+ [/^(?:(backdrop-)|filter-)?brightness-(.+)$/, toFilter("brightness", (s) => handler.bracket.cssvar.percent(s))],
314
+ [/^(?:(backdrop-)|filter-)?contrast-(.+)$/, toFilter("contrast", (s) => handler.bracket.cssvar.percent(s))],
315
315
  [/^(?:filter-)?drop-shadow(?:-(.+))?$/, dropShadowResolver],
316
316
  [/^(?:filter-)?drop-shadow-color-(.+)$/, colorResolver("--un-drop-shadow-color", "drop-shadow")],
317
- [/^(?:filter-)?drop-shadow-color-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-drop-shadow-opacity": handler.bracket.percent.cssvar(opacity) })],
317
+ [/^(?:filter-)?drop-shadow-color-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-drop-shadow-opacity": handler.bracket.percent(opacity) })],
318
318
  [/^(?:(backdrop-)|filter-)?grayscale(?:-(.+))?$/, toFilter("grayscale", percentWithDefault)],
319
- [/^(?:(backdrop-)|filter-)?hue-rotate-(.+)$/, toFilter("hue-rotate", (s) => handler.bracket.degree(s))],
319
+ [/^(?:(backdrop-)|filter-)?hue-rotate-(.+)$/, toFilter("hue-rotate", (s) => handler.bracket.cssvar.degree(s))],
320
320
  [/^(?:(backdrop-)|filter-)?invert(?:-(.+))?$/, toFilter("invert", percentWithDefault)],
321
- [/^(backdrop-)opacity-(.+)$/, toFilter("opacity", (s) => handler.bracket.percent(s))],
322
- [/^(?:(backdrop-)|filter-)?saturate-(.+)$/, toFilter("saturate", (s) => handler.bracket.percent(s))],
321
+ [/^(backdrop-)opacity-(.+)$/, toFilter("opacity", (s) => handler.bracket.cssvar.percent(s))],
322
+ [/^(?:(backdrop-)|filter-)?saturate-(.+)$/, toFilter("saturate", (s) => handler.bracket.cssvar.percent(s))],
323
323
  [/^(?:(backdrop-)|filter-)?sepia(?:-(.+))?$/, toFilter("sepia", percentWithDefault)],
324
324
  [/^filter$/, () => [
325
325
  filterBase,
@@ -350,17 +350,20 @@ const spaces = [
350
350
  [/^space-(block|inline)-(-?.+)$/, handlerSpace],
351
351
  [/^space-(block|inline)-reverse$/, ([, d]) => ({ [`--un-space-${d}-reverse`]: 1 })]
352
352
  ];
353
- function handlerSpace(match) {
354
- const [, direction] = match;
355
- const results = directionSize("margin")(match)?.map((item) => {
356
- const value = item[0].endsWith("right") || item[0].endsWith("bottom") ? `calc(${item[1]} * var(--un-space-${direction}-reverse))` : `calc(${item[1]} * calc(1 - var(--un-space-${direction}-reverse)))`;
357
- return [item[0], value];
358
- });
359
- if (results) {
360
- return [
361
- [`--un-space-${direction}-reverse`, 0],
362
- ...results
363
- ];
353
+ function handlerSpace([, d, s = "1"]) {
354
+ const v = handler.bracket.cssvar.auto.fraction.rem(s);
355
+ if (v != null) {
356
+ const results = directionMap[d].map((item) => {
357
+ const key = `margin${item}`;
358
+ const value = item.endsWith("right") || item.endsWith("bottom") ? `calc(${v} * var(--un-space-${d}-reverse))` : `calc(${v} * calc(1 - var(--un-space-${d}-reverse)))`;
359
+ return [key, value];
360
+ });
361
+ if (results) {
362
+ return [
363
+ [`--un-space-${d}-reverse`, 0],
364
+ ...results
365
+ ];
366
+ }
364
367
  }
365
368
  }
366
369
 
@@ -498,26 +501,27 @@ const tables = [
498
501
  ];
499
502
 
500
503
  const variablesAbbrMap = {
501
- "write": "writing-mode",
502
- "write-orient": "text-orientation",
503
504
  "bg-blend": "background-blend-mode",
504
505
  "bg-clip": "-webkit-background-clip",
505
506
  "bg-gradient": "linear-gradient",
506
- "bg-origin-border": "background-origin",
507
+ "bg-image": "background-image",
508
+ "bg-origin": "background-origin",
507
509
  "bg-position": "background-position",
508
510
  "bg-repeat": "background-repeat",
509
511
  "bg-size": "background-size",
510
512
  "mix-blend": "mix-blend-mode",
511
- "animate-speed": "animation-speed"
513
+ "object": "object-fit",
514
+ "object-position": "object-position",
515
+ "write": "writing-mode",
516
+ "write-orient": "text-orientation"
512
517
  };
513
- const cssVariables = [[
514
- /^(.+)-\$(.+)$/,
515
- ([, name, varname]) => {
518
+ const cssVariables = [
519
+ [/^(.+?)-(\$.+)$/, ([, name, varname]) => {
516
520
  const prop = variablesAbbrMap[name];
517
521
  if (prop)
518
- return { [prop]: `var(--${varname})` };
519
- }
520
- ]];
522
+ return { [prop]: handler.cssvar(varname) };
523
+ }]
524
+ ];
521
525
 
522
526
  const divides = [
523
527
  [/^divide-?([xy])$/, handlerDivide],
@@ -535,15 +539,19 @@ const divides = [
535
539
  ["divide-none", { "border-style": "none" }]
536
540
  ];
537
541
  function handlerDivide([, d, s = "1"]) {
538
- const v = handler.bracket.px(s);
542
+ const v = handler.bracket.cssvar.px(s);
539
543
  if (v != null) {
540
544
  const results = directionMap[d].map((item) => {
541
545
  const key = `border${item}-width`;
542
546
  const value = item.endsWith("right") || item.endsWith("bottom") ? `calc(${v} * var(--un-divide-${d}-reverse))` : `calc(${v} * calc(1 - var(--un-divide-${d}-reverse)))`;
543
547
  return [key, value];
544
548
  });
545
- if (results)
546
- return [[`--un-divide-${d}-reverse`, 0], ...results];
549
+ if (results) {
550
+ return [
551
+ [`--un-divide-${d}-reverse`, 0],
552
+ ...results
553
+ ];
554
+ }
547
555
  }
548
556
  }
549
557
 
@@ -656,7 +664,7 @@ const scrolls = [
656
664
 
657
665
  const placeholders = [
658
666
  [/^\$ placeholder-(.+)$/, colorResolver("color", "placeholder")],
659
- [/^\$ placeholder-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-placeholder-opacity": handler.bracket.percent.cssvar(opacity) })]
667
+ [/^\$ placeholder-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-placeholder-opacity": handler.bracket.percent(opacity) })]
660
668
  ];
661
669
 
662
670
  const rules = [
@@ -916,7 +924,7 @@ const variantSpaceAndDivide = (matcher) => {
916
924
  };
917
925
 
918
926
  const placeholderModifier = (input, { theme }) => {
919
- const m = input.match(/^(.*)\b(placeholder-)(.+?)$/);
927
+ const m = input.match(/^(.*)\b(placeholder-)(.+)$/);
920
928
  if (m) {
921
929
  const [, pre = "", p, body] = m;
922
930
  if (hasColorValue(body, theme) || hasOpacityValue(body)) {
@@ -932,7 +940,7 @@ function hasColorValue(body, theme) {
932
940
  function hasOpacityValue(body) {
933
941
  const match = body.match(/^op(?:acity)?-?(.+)$/);
934
942
  if (match && match[1] != null)
935
- return handler.bracket.percent.cssvar(match[1]) != null;
943
+ return handler.bracket.percent(match[1]) != null;
936
944
  return false;
937
945
  }
938
946
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-wind",
3
- "version": "0.22.2",
3
+ "version": "0.22.6",
4
4
  "description": "Tailwind / Windi CSS compact preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -35,8 +35,8 @@
35
35
  "*.css"
36
36
  ],
37
37
  "dependencies": {
38
- "@unocss/core": "0.22.2",
39
- "@unocss/preset-mini": "0.22.2"
38
+ "@unocss/core": "0.22.6",
39
+ "@unocss/preset-mini": "0.22.6"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "unbuild",