@unocss/rule-utils 65.4.2 → 65.5.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.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { VariantHandlerContext, VariantObject } from '@unocss/core';
1
+ import { Arrayable, VariantHandlerContext, VariantObject } from '@unocss/core';
2
2
 
3
3
  interface CSSColorValue {
4
4
  type: string;
@@ -32,6 +32,7 @@ interface ParsedColorValue {
32
32
  */
33
33
  alpha: string | number | undefined;
34
34
  }
35
+ declare const alphaPlaceholders: string[];
35
36
  declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
36
37
  declare function parseCssColor(str?: string): CSSColorValue | undefined;
37
38
  declare function colorOpacityToString(color: CSSColorValue): string | number;
@@ -60,9 +61,9 @@ declare function getBracket(str: string, open: string, close: string): string[]
60
61
  declare function getStringComponent(str: string, open: string, close: string, separators: string | string[]): string[] | undefined;
61
62
  declare function getStringComponents(str: string, separators: string | string[], limit?: number): string[] | undefined;
62
63
 
63
- declare function variantMatcher(name: string, handler: (input: VariantHandlerContext) => Record<string, any>): VariantObject;
64
+ declare function variantMatcher(name: string, handler: Arrayable<(input: VariantHandlerContext) => Record<string, any>>): VariantObject;
64
65
  declare function variantParentMatcher(name: string, parent: string): VariantObject;
65
66
  declare function variantGetBracket(prefix: string, matcher: string, separators: string[]): string[] | undefined;
66
67
  declare function variantGetParameter(prefix: string, matcher: string, separators: string[]): string[] | undefined;
67
68
 
68
- export { type CSSColorValue, type ParsedColorValue, type RGBAColorValue, type ValueHandler, type ValueHandlerCallback, colorOpacityToString, colorToString, createValueHandler, getBracket, getStringComponent, getStringComponents, hasIconFn, hasThemeFn, hex2rgba, iconFnRE, parseCssColor, themeFnRE, transformThemeFn, transformThemeString, variantGetBracket, variantGetParameter, variantMatcher, variantParentMatcher };
69
+ export { type CSSColorValue, type ParsedColorValue, type RGBAColorValue, type ValueHandler, type ValueHandlerCallback, alphaPlaceholders, colorOpacityToString, colorToString, createValueHandler, getBracket, getStringComponent, getStringComponents, hasIconFn, hasThemeFn, hex2rgba, iconFnRE, parseCssColor, themeFnRE, transformThemeFn, transformThemeString, variantGetBracket, variantGetParameter, variantMatcher, variantParentMatcher };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { VariantHandlerContext, VariantObject } from '@unocss/core';
1
+ import { Arrayable, VariantHandlerContext, VariantObject } from '@unocss/core';
2
2
 
3
3
  interface CSSColorValue {
4
4
  type: string;
@@ -32,6 +32,7 @@ interface ParsedColorValue {
32
32
  */
33
33
  alpha: string | number | undefined;
34
34
  }
35
+ declare const alphaPlaceholders: string[];
35
36
  declare function hex2rgba(hex?: string): RGBAColorValue | undefined;
36
37
  declare function parseCssColor(str?: string): CSSColorValue | undefined;
37
38
  declare function colorOpacityToString(color: CSSColorValue): string | number;
@@ -60,9 +61,9 @@ declare function getBracket(str: string, open: string, close: string): string[]
60
61
  declare function getStringComponent(str: string, open: string, close: string, separators: string | string[]): string[] | undefined;
61
62
  declare function getStringComponents(str: string, separators: string | string[], limit?: number): string[] | undefined;
62
63
 
63
- declare function variantMatcher(name: string, handler: (input: VariantHandlerContext) => Record<string, any>): VariantObject;
64
+ declare function variantMatcher(name: string, handler: Arrayable<(input: VariantHandlerContext) => Record<string, any>>): VariantObject;
64
65
  declare function variantParentMatcher(name: string, parent: string): VariantObject;
65
66
  declare function variantGetBracket(prefix: string, matcher: string, separators: string[]): string[] | undefined;
66
67
  declare function variantGetParameter(prefix: string, matcher: string, separators: string[]): string[] | undefined;
67
68
 
68
- export { type CSSColorValue, type ParsedColorValue, type RGBAColorValue, type ValueHandler, type ValueHandlerCallback, colorOpacityToString, colorToString, createValueHandler, getBracket, getStringComponent, getStringComponents, hasIconFn, hasThemeFn, hex2rgba, iconFnRE, parseCssColor, themeFnRE, transformThemeFn, transformThemeString, variantGetBracket, variantGetParameter, variantMatcher, variantParentMatcher };
69
+ export { type CSSColorValue, type ParsedColorValue, type RGBAColorValue, type ValueHandler, type ValueHandlerCallback, alphaPlaceholders, colorOpacityToString, colorToString, createValueHandler, getBracket, getStringComponent, getStringComponents, hasIconFn, hasThemeFn, hex2rgba, iconFnRE, parseCssColor, themeFnRE, transformThemeFn, transformThemeString, variantGetBracket, variantGetParameter, variantMatcher, variantParentMatcher };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { isString, escapeRegExp } from '@unocss/core';
1
+ import { isString, escapeRegExp, toArray } from '@unocss/core';
2
2
  import MagicString from 'magic-string';
3
3
 
4
4
  function getBracket(str, open, close) {
@@ -163,7 +163,7 @@ function parseHexColor(str) {
163
163
  return {
164
164
  type: "rgb",
165
165
  components: digits.slice(0, 3),
166
- alpha: body.length === 3 ? undefined : Math.round(digits[3] / 255 * 100) / 100
166
+ alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
167
167
  };
168
168
  case 6:
169
169
  case 8:
@@ -171,7 +171,7 @@ function parseHexColor(str) {
171
171
  return {
172
172
  type: "rgb",
173
173
  components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
174
- alpha: body.length === 6 ? undefined : Math.round((value & 255) / 255 * 100) / 100
174
+ alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
175
175
  };
176
176
  }
177
177
  }
@@ -352,13 +352,15 @@ function variantMatcher(name, handler) {
352
352
  re = new RegExp(`^${escapeRegExp(name)}(?:${ctx.generator.config.separators.join("|")})`);
353
353
  const match = input.match(re);
354
354
  if (match) {
355
- return {
356
- matcher: input.slice(match[0].length),
355
+ const matcher = input.slice(match[0].length);
356
+ const handlers = toArray(handler).map((handler2) => ({
357
+ matcher,
357
358
  handle: (input2, next) => next({
358
359
  ...input2,
359
- ...handler(input2)
360
+ ...handler2(input2)
360
361
  })
361
- };
362
+ }));
363
+ return handlers.length === 1 ? handlers[0] : handlers;
362
364
  }
363
365
  },
364
366
  autocomplete: `${name}:`
@@ -419,4 +421,4 @@ function variantGetParameter(prefix, matcher, separators) {
419
421
  }
420
422
  }
421
423
 
422
- export { colorOpacityToString, colorToString, createValueHandler, getBracket, getStringComponent, getStringComponents, hasIconFn, hasThemeFn, hex2rgba, iconFnRE, parseCssColor, themeFnRE, transformThemeFn, transformThemeString, variantGetBracket, variantGetParameter, variantMatcher, variantParentMatcher };
424
+ export { alphaPlaceholders, colorOpacityToString, colorToString, createValueHandler, getBracket, getStringComponent, getStringComponents, hasIconFn, hasThemeFn, hex2rgba, iconFnRE, parseCssColor, themeFnRE, transformThemeFn, transformThemeString, variantGetBracket, variantGetParameter, variantMatcher, variantParentMatcher };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/rule-utils",
3
3
  "type": "module",
4
- "version": "65.4.2",
4
+ "version": "65.5.0",
5
5
  "description": "Utilities for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "homepage": "https://unocss.dev",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/unocss/unocss",
12
+ "url": "git+https://github.com/unocss/unocss",
13
13
  "directory": "packages-presets/rule-utils"
14
14
  },
15
15
  "bugs": {
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "magic-string": "^0.30.17",
37
- "@unocss/core": "^65.4.2"
37
+ "@unocss/core": "^65.5.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "unbuild",