@unocss/preset-wind 0.18.1 → 0.20.2

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
@@ -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-(.+)$/, ([, name], { theme, constructCSS }) => {
@@ -34,22 +34,19 @@ ${constructCSS(Object.assign({ animation: `${name} ${duration} ${timing} infinit
34
34
  ["animate-none", { animation: "none" }]
35
35
  ];
36
36
 
37
- const colorResolver = (mode) => ([, body], { theme }) => {
37
+ const bgGradientColorResolver = (mode) => ([, body], { theme }) => {
38
38
  const data = utils.parseColor(body, theme);
39
39
  if (!data)
40
40
  return;
41
- const { opacity, color, rgba } = data;
41
+ const { alpha, color, rgba } = data;
42
42
  if (!color)
43
43
  return;
44
44
  let colorString = color;
45
45
  if (rgba) {
46
- const a = opacity ? opacity[0] === "[" ? utils.handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba[3];
47
- if (a != null && !Number.isNaN(a)) {
48
- rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
46
+ if (alpha != null)
49
47
  colorString = `rgba(${rgba.join(",")})`;
50
- } else {
51
- colorString = `rgba(${rgba.slice(0, 3).join(",")}, var(--un-${mode}-opacity, 1))`;
52
- }
48
+ else
49
+ colorString = `rgba(${rgba.join(",")}, var(--un-${mode}-opacity, 1))`;
53
50
  }
54
51
  switch (mode) {
55
52
  case "from":
@@ -101,9 +98,9 @@ const backgroundStyles = [
101
98
  ["bg-clip-content", { "-webkit-background-clip": "content-box", "background-attachment": "content-box" }],
102
99
  ["bg-clip-padding", { "-webkit-background-clip": "padding-box", "background-attachment": "padding-box" }],
103
100
  ["bg-clip-text", { "-webkit-background-clip": "text", "background-attachment": "text" }],
104
- [/^(?:bg-gradient-)?from-(.+)$/, colorResolver("from")],
105
- [/^(?:bg-gradient-)?to-(.+)$/, colorResolver("to")],
106
- [/^(?:bg-gradient-)?via-(.+)$/, colorResolver("via")],
101
+ [/^(?:bg-gradient-)?from-(.+)$/, bgGradientColorResolver("from")],
102
+ [/^(?:bg-gradient-)?to-(.+)$/, bgGradientColorResolver("to")],
103
+ [/^(?:bg-gradient-)?via-(.+)$/, bgGradientColorResolver("via")],
107
104
  [/^(?:bg-gradient-)?from-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-from-opacity": utils.handler.bracket.percent(opacity) })],
108
105
  [/^(?:bg-gradient-)?to-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-to-opacity": utils.handler.bracket.percent(opacity) })],
109
106
  [/^(?:bg-gradient-)?via-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-via-opacity": utils.handler.bracket.percent(opacity) })],
@@ -199,11 +196,7 @@ const scrollBehaviors = [
199
196
  ];
200
197
 
201
198
  const columns = [
202
- [/^columns-(.+)$/, ([, v]) => {
203
- const column = utils.handler.bracket.global.number.auto.numberWithUnit(v);
204
- if (column)
205
- return { column };
206
- }],
199
+ [/^columns-(.+)$/, ([, v]) => ({ column: utils.handler.bracket.global.number.auto.numberWithUnit(v) })],
207
200
  ["break-before-auto", { "break-before": "auto" }],
208
201
  ["break-before-avoid", { "break-before": "avoid" }],
209
202
  ["break-before-all", { "break-before": "all" }],
@@ -272,7 +265,7 @@ const filterBase = {
272
265
  "--un-sepia": rules$1.varEmpty,
273
266
  "--un-drop-shadow": rules$1.varEmpty,
274
267
  "filter": filterContnet,
275
- [variants.CONTROL_BYPASS_PSEUDO_CLASS]: ""
268
+ [variants$1.CONTROL_BYPASS_PSEUDO_CLASS]: ""
276
269
  };
277
270
  const backdropFilterContent = "var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-saturate) var(--un-backdrop-sepia)";
278
271
  const backdropFilterBase = {
@@ -286,7 +279,7 @@ const backdropFilterBase = {
286
279
  "--un-backdrop-sepia": rules$1.varEmpty,
287
280
  "-webkit-backdrop-filter": backdropFilterContent,
288
281
  "backdrop-filter": backdropFilterContent,
289
- [variants.CONTROL_BYPASS_PSEUDO_CLASS]: ""
282
+ [variants$1.CONTROL_BYPASS_PSEUDO_CLASS]: ""
290
283
  };
291
284
  const percentWithDefault = (defaultValue = "1") => (str) => {
292
285
  const v = str ? utils.handler.bracket.percent(str) : defaultValue;
@@ -484,11 +477,8 @@ const cssVariables = [[
484
477
  /^(.+)-\$(.+)$/,
485
478
  ([, name, varname]) => {
486
479
  const prop = variablesAbbrMap[name];
487
- if (prop) {
488
- return {
489
- [prop]: `var(--${varname})`
490
- };
491
- }
480
+ if (prop)
481
+ return { [prop]: `var(--${varname})` };
492
482
  }
493
483
  ]];
494
484
 
@@ -544,7 +534,7 @@ const fontVariantNumericBase = {
544
534
  "--un-numeric-spacing": rules$1.varEmpty,
545
535
  "--un-numeric-fraction": rules$1.varEmpty,
546
536
  "font-variant-numeric": "var(--un-ordinal) var(--un-slashed-zero) var(--un-numeric-figure) var(--un-numeric-spacing) var(--un-numeric-fraction)",
547
- [variants.CONTROL_BYPASS_PSEUDO_CLASS]: ""
537
+ [variants$1.CONTROL_BYPASS_PSEUDO_CLASS]: ""
548
538
  };
549
539
  const fontVariantNumeric = [
550
540
  [/^ordinal$/, () => [fontVariantNumericBase, { "--un-ordinal": "ordinal" }]],
@@ -563,7 +553,7 @@ const touchActionBase = {
563
553
  "--un-pan-y": rules$1.varEmpty,
564
554
  "--un-pinch-zoom": rules$1.varEmpty,
565
555
  "--un-touch-action": "var(--un-pan-x) var(--un-pan-y) var(--un-pinch-zoom)",
566
- [variants.CONTROL_BYPASS_PSEUDO_CLASS]: ""
556
+ [variants$1.CONTROL_BYPASS_PSEUDO_CLASS]: ""
567
557
  };
568
558
  const touchActions = [
569
559
  [/^touch-pan-(x|left|right)$/, ([, d]) => [
@@ -596,7 +586,7 @@ const scrolls = [
596
586
  [/^snap-(x|y|base)$/, ([, d]) => [
597
587
  {
598
588
  "--un-scroll-snap-strictness": "proximity",
599
- [variants.CONTROL_BYPASS_PSEUDO_CLASS]: ""
589
+ [variants$1.CONTROL_BYPASS_PSEUDO_CLASS]: ""
600
590
  },
601
591
  {
602
592
  "scroll-snap-type": `${d} var(--un-scroll-snap-strictness)`
@@ -858,39 +848,34 @@ const theme = {
858
848
  };
859
849
 
860
850
  const variantColorsScheme = [
861
- utils.variantMatcher("\\.dark", (input) => `.dark $$ ${input}`),
862
- utils.variantMatcher("\\.light", (input) => `.light $$ ${input}`),
863
- (v) => {
864
- const dark = utils.variantMatcher("@dark")(v);
865
- if (dark) {
866
- return {
867
- ...dark,
868
- parent: "@media (prefers-color-scheme: dark)"
869
- };
870
- }
871
- const light = utils.variantMatcher("@light")(v);
872
- if (light) {
873
- return {
874
- ...light,
875
- parent: "@media (prefers-color-scheme: light)"
876
- };
877
- }
878
- }
851
+ utils.variantMatcher(".dark", (input) => `.dark $$ ${input}`),
852
+ utils.variantMatcher(".light", (input) => `.light $$ ${input}`),
853
+ utils.variantParentMatcher("@dark", "@media (prefers-color-scheme: dark)"),
854
+ utils.variantParentMatcher("@light", "@media (prefers-color-scheme: light)")
879
855
  ];
880
856
 
881
- const presetWind = (options = {}) => ({
882
- name: "@unocss/preset-wind",
883
- theme,
884
- rules,
885
- shortcuts: [
886
- ...containerShortcuts
887
- ],
888
- variants: [
889
- ...variants.variants(options),
890
- ...variantColorsScheme
891
- ],
892
- options
893
- });
857
+ const variantFilePseudoElement = utils.variantMatcher("file", (input) => `${input}::file-selector-button`);
858
+
859
+ const variants = [
860
+ ...variants$1.variants,
861
+ variantFilePseudoElement,
862
+ ...variantColorsScheme
863
+ ];
864
+
865
+ const presetWind = (options = {}) => {
866
+ options.dark = options.dark ?? "class";
867
+ options.attributifyPseudo = options.attributifyPseudo ?? false;
868
+ return {
869
+ name: "@unocss/preset-wind",
870
+ theme,
871
+ rules,
872
+ shortcuts: [
873
+ ...containerShortcuts
874
+ ],
875
+ variants,
876
+ options
877
+ };
878
+ };
894
879
 
895
880
  exports.colors = presetMini.colors;
896
881
  exports["default"] = presetWind;
package/dist/index.d.ts CHANGED
@@ -1,18 +1,10 @@
1
1
  import { Preset } from '@unocss/core';
2
- import { Theme } from '@unocss/preset-mini';
2
+ import { Theme, PresetMiniOptions } from '@unocss/preset-mini';
3
3
  export { Theme, colors } from '@unocss/preset-mini';
4
4
 
5
5
  declare const theme: Theme;
6
6
 
7
- interface UnoOptions {
8
- /**
9
- * @default 'class'
10
- */
11
- dark?: 'class' | 'media';
12
- /**
13
- * @default false
14
- */
15
- attributifyPseudo?: Boolean;
7
+ interface UnoOptions extends PresetMiniOptions {
16
8
  }
17
9
  declare const presetWind: (options?: UnoOptions) => Preset<Theme>;
18
10
 
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { CONTROL_BYPASS_PSEUDO_CLASS, variants } from '@unocss/preset-mini/variants';
2
1
  import { toArray } from '@unocss/core';
3
2
  import { theme as theme$1 } from '@unocss/preset-mini/theme';
4
3
  export { colors } from '@unocss/preset-mini';
5
4
  import { varEmpty, cssVariables as cssVariables$1, 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, parseColor, colorResolver as colorResolver$1, directionSize, directionMap, variantMatcher } from '@unocss/preset-mini/utils';
5
+ import { handler, parseColor, colorResolver, directionSize, directionMap, variantMatcher, variantParentMatcher } from '@unocss/preset-mini/utils';
6
+ import { CONTROL_BYPASS_PSEUDO_CLASS, variants as variants$1 } from '@unocss/preset-mini/variants';
7
7
 
8
8
  const animations = [
9
9
  [/^animate-(.+)$/, ([, name], { theme, constructCSS }) => {
@@ -30,22 +30,19 @@ ${constructCSS(Object.assign({ animation: `${name} ${duration} ${timing} infinit
30
30
  ["animate-none", { animation: "none" }]
31
31
  ];
32
32
 
33
- const colorResolver = (mode) => ([, body], { theme }) => {
33
+ const bgGradientColorResolver = (mode) => ([, body], { theme }) => {
34
34
  const data = parseColor(body, theme);
35
35
  if (!data)
36
36
  return;
37
- const { opacity, color, rgba } = data;
37
+ const { alpha, color, rgba } = data;
38
38
  if (!color)
39
39
  return;
40
40
  let colorString = color;
41
41
  if (rgba) {
42
- const a = opacity ? opacity[0] === "[" ? handler.bracket.percent(opacity) : parseFloat(opacity) / 100 : rgba[3];
43
- if (a != null && !Number.isNaN(a)) {
44
- rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
42
+ if (alpha != null)
45
43
  colorString = `rgba(${rgba.join(",")})`;
46
- } else {
47
- colorString = `rgba(${rgba.slice(0, 3).join(",")}, var(--un-${mode}-opacity, 1))`;
48
- }
44
+ else
45
+ colorString = `rgba(${rgba.join(",")}, var(--un-${mode}-opacity, 1))`;
49
46
  }
50
47
  switch (mode) {
51
48
  case "from":
@@ -97,9 +94,9 @@ const backgroundStyles = [
97
94
  ["bg-clip-content", { "-webkit-background-clip": "content-box", "background-attachment": "content-box" }],
98
95
  ["bg-clip-padding", { "-webkit-background-clip": "padding-box", "background-attachment": "padding-box" }],
99
96
  ["bg-clip-text", { "-webkit-background-clip": "text", "background-attachment": "text" }],
100
- [/^(?:bg-gradient-)?from-(.+)$/, colorResolver("from")],
101
- [/^(?:bg-gradient-)?to-(.+)$/, colorResolver("to")],
102
- [/^(?:bg-gradient-)?via-(.+)$/, colorResolver("via")],
97
+ [/^(?:bg-gradient-)?from-(.+)$/, bgGradientColorResolver("from")],
98
+ [/^(?:bg-gradient-)?to-(.+)$/, bgGradientColorResolver("to")],
99
+ [/^(?:bg-gradient-)?via-(.+)$/, bgGradientColorResolver("via")],
103
100
  [/^(?:bg-gradient-)?from-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-from-opacity": handler.bracket.percent(opacity) })],
104
101
  [/^(?:bg-gradient-)?to-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-to-opacity": handler.bracket.percent(opacity) })],
105
102
  [/^(?:bg-gradient-)?via-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-via-opacity": handler.bracket.percent(opacity) })],
@@ -156,13 +153,13 @@ const accentOpacity = [
156
153
  [/^accent-op(?:acity)?-?(.+)$/, ([, d]) => ({ "--un-accent-opacity": handler.bracket.percent(d) })]
157
154
  ];
158
155
  const accentColors = [
159
- [/^accent-(.+)$/, colorResolver$1("accent-color", "accent")]
156
+ [/^accent-(.+)$/, colorResolver("accent-color", "accent")]
160
157
  ];
161
158
  const caretOpacity = [
162
159
  [/^caret-op(?:acity)?-?(.+)$/, ([, d]) => ({ "--un-caret-opacity": handler.bracket.percent(d) })]
163
160
  ];
164
161
  const caretColors = [
165
- [/^caret-(.+)$/, colorResolver$1("caret-color", "caret")]
162
+ [/^caret-(.+)$/, colorResolver("caret-color", "caret")]
166
163
  ];
167
164
  const imageRenderings = [
168
165
  ["image-render-auto", { "image-rendering": "auto" }],
@@ -195,11 +192,7 @@ const scrollBehaviors = [
195
192
  ];
196
193
 
197
194
  const columns = [
198
- [/^columns-(.+)$/, ([, v]) => {
199
- const column = handler.bracket.global.number.auto.numberWithUnit(v);
200
- if (column)
201
- return { column };
202
- }],
195
+ [/^columns-(.+)$/, ([, v]) => ({ column: handler.bracket.global.number.auto.numberWithUnit(v) })],
203
196
  ["break-before-auto", { "break-before": "auto" }],
204
197
  ["break-before-avoid", { "break-before": "avoid" }],
205
198
  ["break-before-all", { "break-before": "all" }],
@@ -480,16 +473,13 @@ const cssVariables = [[
480
473
  /^(.+)-\$(.+)$/,
481
474
  ([, name, varname]) => {
482
475
  const prop = variablesAbbrMap[name];
483
- if (prop) {
484
- return {
485
- [prop]: `var(--${varname})`
486
- };
487
- }
476
+ if (prop)
477
+ return { [prop]: `var(--${varname})` };
488
478
  }
489
479
  ]];
490
480
 
491
481
  const divideColors = [
492
- [/^divide-(.+)$/, colorResolver$1("border-color", "divide")],
482
+ [/^divide-(.+)$/, colorResolver("border-color", "divide")],
493
483
  [/^divide-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-divide-opacity": handler.bracket.percent(opacity) })]
494
484
  ];
495
485
  const divideSizes = [
@@ -854,38 +844,33 @@ const theme = {
854
844
  };
855
845
 
856
846
  const variantColorsScheme = [
857
- variantMatcher("\\.dark", (input) => `.dark $$ ${input}`),
858
- variantMatcher("\\.light", (input) => `.light $$ ${input}`),
859
- (v) => {
860
- const dark = variantMatcher("@dark")(v);
861
- if (dark) {
862
- return {
863
- ...dark,
864
- parent: "@media (prefers-color-scheme: dark)"
865
- };
866
- }
867
- const light = variantMatcher("@light")(v);
868
- if (light) {
869
- return {
870
- ...light,
871
- parent: "@media (prefers-color-scheme: light)"
872
- };
873
- }
874
- }
847
+ variantMatcher(".dark", (input) => `.dark $$ ${input}`),
848
+ variantMatcher(".light", (input) => `.light $$ ${input}`),
849
+ variantParentMatcher("@dark", "@media (prefers-color-scheme: dark)"),
850
+ variantParentMatcher("@light", "@media (prefers-color-scheme: light)")
875
851
  ];
876
852
 
877
- const presetWind = (options = {}) => ({
878
- name: "@unocss/preset-wind",
879
- theme,
880
- rules,
881
- shortcuts: [
882
- ...containerShortcuts
883
- ],
884
- variants: [
885
- ...variants(options),
886
- ...variantColorsScheme
887
- ],
888
- options
889
- });
853
+ const variantFilePseudoElement = variantMatcher("file", (input) => `${input}::file-selector-button`);
854
+
855
+ const variants = [
856
+ ...variants$1,
857
+ variantFilePseudoElement,
858
+ ...variantColorsScheme
859
+ ];
860
+
861
+ const presetWind = (options = {}) => {
862
+ options.dark = options.dark ?? "class";
863
+ options.attributifyPseudo = options.attributifyPseudo ?? false;
864
+ return {
865
+ name: "@unocss/preset-wind",
866
+ theme,
867
+ rules,
868
+ shortcuts: [
869
+ ...containerShortcuts
870
+ ],
871
+ variants,
872
+ options
873
+ };
874
+ };
890
875
 
891
876
  export { presetWind as default, presetWind, theme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-wind",
3
- "version": "0.18.1",
3
+ "version": "0.20.2",
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.18.1",
39
- "@unocss/preset-mini": "0.18.1"
38
+ "@unocss/core": "0.20.2",
39
+ "@unocss/preset-mini": "0.20.2"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "unbuild",