@unocss/preset-mini 66.3.2 → 66.4.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
@@ -72,4 +72,5 @@ declare const presetMini: _unocss_core.PresetFactory<Theme, PresetMiniOptions>;
72
72
 
73
73
  declare function VarPrefixPostprocessor(prefix: string): Postprocessor | undefined;
74
74
 
75
- export { type DarkModeSelectors, type PresetMiniOptions, Theme, VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
75
+ export { Theme, VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
76
+ export type { DarkModeSelectors, PresetMiniOptions };
package/dist/index.d.ts CHANGED
@@ -72,4 +72,5 @@ declare const presetMini: _unocss_core.PresetFactory<Theme, PresetMiniOptions>;
72
72
 
73
73
  declare function VarPrefixPostprocessor(prefix: string): Postprocessor | undefined;
74
74
 
75
- export { type DarkModeSelectors, type PresetMiniOptions, Theme, VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
75
+ export { Theme, VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
76
+ export type { DarkModeSelectors, PresetMiniOptions };
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { entriesToCss, toArray, definePreset } from '@unocss/core';
2
2
  import { extractorArbitraryVariants } from '@unocss/extractor-arbitrary-variants';
3
3
  import { g as globalKeywords } from './shared/preset-mini.DrfPDgwn.mjs';
4
4
  export { k as parseColor } from './shared/preset-mini.DrfPDgwn.mjs';
5
- import { i as variants } from './shared/preset-mini.-NZCZZOn.mjs';
5
+ import { i as variants } from './shared/preset-mini.DbGR1fYK.mjs';
6
6
  import { r as rules } from './shared/preset-mini.BbFVnwVO.mjs';
7
7
  import { t as theme } from './shared/preset-mini.BsxsSmTL.mjs';
8
8
  export { colors } from './colors.mjs';
@@ -1,6 +1,6 @@
1
+ import { escapeSelector, escapeRegExp, toArray } from '@unocss/core';
1
2
  import { variantGetParameter, calcMaxWidthBySize, variantMatcher, variantGetBracket, variantParentMatcher, getBracket, hasThemeFn, transformThemeFn, getStringComponent, createPartClasses, createPseudoClassesAndElements, createPseudoClassFunctions, createTaggedPseudoClasses } from '@unocss/rule-utils';
2
3
  import { a as h, r as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE, e as cssMathFnRE, f as cssVarFnRE } from './preset-mini.DrfPDgwn.mjs';
3
- import { toArray } from '@unocss/core';
4
4
 
5
5
  const variantAria = {
6
6
  name: "aria",
@@ -19,7 +19,7 @@ const variantAria = {
19
19
  },
20
20
  multiPass: true
21
21
  };
22
- function taggedAria(tagName) {
22
+ function taggedAria(tagName, combinator, options = {}) {
23
23
  return {
24
24
  name: `${tagName}-aria`,
25
25
  match(matcher, ctx) {
@@ -28,21 +28,78 @@ function taggedAria(tagName) {
28
28
  const [match, rest, label] = variant;
29
29
  const ariaAttribute = h.bracket(match) ?? ctx.theme.aria?.[match] ?? "";
30
30
  if (ariaAttribute) {
31
+ const attributify = !!options?.attributifyPseudo;
32
+ let firstPrefix = options?.prefix ?? "";
33
+ firstPrefix = (Array.isArray(firstPrefix) ? firstPrefix : [firstPrefix]).filter(Boolean)[0] ?? "";
34
+ const parent = `${attributify ? `[${firstPrefix}${tagName}=""]` : `.${firstPrefix}${tagName}`}`;
35
+ const escapedLabel = escapeSelector(label ? `/${label}` : "");
31
36
  return {
32
- matcher: `${tagName}-[[aria-${ariaAttribute}]]${label ? `/${label}` : ""}:${rest}`
37
+ matcher: rest,
38
+ handle: (input, next) => {
39
+ const regexp = new RegExp(`${escapeRegExp(parent)}${escapeRegExp(escapedLabel)}(?:\\[.+?\\])+`);
40
+ const match2 = input.prefix.match(regexp);
41
+ let nextPrefix;
42
+ if (match2) {
43
+ const insertIndex = (match2.index ?? 0) + parent.length + escapedLabel.length;
44
+ nextPrefix = [
45
+ input.prefix.slice(0, insertIndex),
46
+ `[aria-${ariaAttribute}]`,
47
+ input.prefix.slice(insertIndex)
48
+ ].join("");
49
+ } else {
50
+ const prefixGroupIndex = Math.max(input.prefix.indexOf(parent), 0);
51
+ nextPrefix = [
52
+ input.prefix.slice(0, prefixGroupIndex),
53
+ parent,
54
+ escapedLabel,
55
+ `[aria-${ariaAttribute}]`,
56
+ combinator,
57
+ input.prefix.slice(prefixGroupIndex)
58
+ ].join("");
59
+ }
60
+ return next({
61
+ ...input,
62
+ prefix: nextPrefix
63
+ });
64
+ }
33
65
  };
34
66
  }
35
67
  }
36
- }
68
+ },
69
+ multiPass: true
37
70
  };
38
71
  }
39
- const variantTaggedAriaAttributes = [
40
- taggedAria("group"),
41
- taggedAria("peer"),
42
- taggedAria("parent"),
43
- taggedAria("previous"),
44
- taggedAria("has")
45
- ];
72
+ function taggedHasAria() {
73
+ return {
74
+ name: "has-aria",
75
+ match(matcher, ctx) {
76
+ const variant = variantGetParameter("has-aria-", matcher, ctx.generator.config.separators);
77
+ if (variant) {
78
+ const [match, rest] = variant;
79
+ const ariaAttribute = h.bracket(match) ?? ctx.theme.aria?.[match] ?? "";
80
+ if (ariaAttribute) {
81
+ return {
82
+ matcher: rest,
83
+ handle: (input, next) => next({
84
+ ...input,
85
+ pseudo: `${input.pseudo}:has([aria-${ariaAttribute}])`
86
+ })
87
+ };
88
+ }
89
+ }
90
+ },
91
+ multiPass: true
92
+ };
93
+ }
94
+ function variantTaggedAriaAttributes(options = {}) {
95
+ return [
96
+ taggedAria("group", " ", options),
97
+ taggedAria("peer", "~", options),
98
+ taggedAria("parent", ">", options),
99
+ taggedAria("previous", "+", options),
100
+ taggedHasAria()
101
+ ];
102
+ }
46
103
 
47
104
  const sizePseudo = /(max|min)-\[([^\]]*)\]:/;
48
105
  function variantBreakpoints() {
@@ -218,7 +275,7 @@ const variantDataAttribute = {
218
275
  },
219
276
  multiPass: true
220
277
  };
221
- function taggedData(tagName) {
278
+ function taggedData(tagName, combinator, options = {}) {
222
279
  return {
223
280
  name: `${tagName}-data`,
224
281
  match(matcher, ctx) {
@@ -227,21 +284,78 @@ function taggedData(tagName) {
227
284
  const [match, rest, label] = variant;
228
285
  const dataAttribute = h.bracket(match) ?? ctx.theme.data?.[match] ?? "";
229
286
  if (dataAttribute) {
287
+ const attributify = !!options?.attributifyPseudo;
288
+ let firstPrefix = options?.prefix ?? "";
289
+ firstPrefix = (Array.isArray(firstPrefix) ? firstPrefix : [firstPrefix]).filter(Boolean)[0] ?? "";
290
+ const parent = `${attributify ? `[${firstPrefix}${tagName}=""]` : `.${firstPrefix}${tagName}`}`;
291
+ const escapedLabel = escapeSelector(label ? `/${label}` : "");
230
292
  return {
231
- matcher: `${tagName}-[[data-${dataAttribute}]]${label ? `/${label}` : ""}:${rest}`
293
+ matcher: rest,
294
+ handle: (input, next) => {
295
+ const regexp = new RegExp(`${escapeRegExp(parent)}${escapeRegExp(escapedLabel)}(?:\\[.+?\\])+`);
296
+ const match2 = input.prefix.match(regexp);
297
+ let nextPrefix;
298
+ if (match2) {
299
+ const insertIndex = (match2.index ?? 0) + parent.length + escapedLabel.length;
300
+ nextPrefix = [
301
+ input.prefix.slice(0, insertIndex),
302
+ `[data-${dataAttribute}]`,
303
+ input.prefix.slice(insertIndex)
304
+ ].join("");
305
+ } else {
306
+ const prefixGroupIndex = Math.max(input.prefix.indexOf(parent), 0);
307
+ nextPrefix = [
308
+ input.prefix.slice(0, prefixGroupIndex),
309
+ parent,
310
+ escapedLabel,
311
+ `[data-${dataAttribute}]`,
312
+ combinator,
313
+ input.prefix.slice(prefixGroupIndex)
314
+ ].join("");
315
+ }
316
+ return next({
317
+ ...input,
318
+ prefix: nextPrefix
319
+ });
320
+ }
232
321
  };
233
322
  }
234
323
  }
235
- }
324
+ },
325
+ multiPass: true
236
326
  };
237
327
  }
238
- const variantTaggedDataAttributes = [
239
- taggedData("group"),
240
- taggedData("peer"),
241
- taggedData("parent"),
242
- taggedData("previous"),
243
- taggedData("has")
244
- ];
328
+ function taggedHasData() {
329
+ return {
330
+ name: "has-data",
331
+ match(matcher, ctx) {
332
+ const variant = variantGetParameter("has-data-", matcher, ctx.generator.config.separators);
333
+ if (variant) {
334
+ const [match, rest] = variant;
335
+ const dataAttribute = h.bracket(match) ?? ctx.theme.data?.[match] ?? "";
336
+ if (dataAttribute) {
337
+ return {
338
+ matcher: rest,
339
+ handle: (input, next) => next({
340
+ ...input,
341
+ pseudo: `${input.pseudo}:has([data-${dataAttribute}])`
342
+ })
343
+ };
344
+ }
345
+ }
346
+ },
347
+ multiPass: true
348
+ };
349
+ }
350
+ function variantTaggedDataAttributes(options = {}) {
351
+ return [
352
+ taggedData("group", " ", options),
353
+ taggedData("peer", "~", options),
354
+ taggedData("parent", ">", options),
355
+ taggedData("previous", "+", options),
356
+ taggedHasData()
357
+ ];
358
+ }
245
359
 
246
360
  const variantLanguageDirections = [
247
361
  variantMatcher("rtl", (input) => ({ prefix: `[dir="rtl"] $$ ${input.prefix}` })),
@@ -570,8 +684,8 @@ function variants(options) {
570
684
  ...variantChildren,
571
685
  variantContainerQuery,
572
686
  variantVariables,
573
- ...variantTaggedDataAttributes,
574
- ...variantTaggedAriaAttributes,
687
+ ...variantTaggedDataAttributes(options),
688
+ ...variantTaggedAriaAttributes(options),
575
689
  variantTheme
576
690
  ];
577
691
  }
package/dist/utils.d.mts CHANGED
@@ -40,11 +40,29 @@ declare const handlers_px: typeof px;
40
40
  declare const handlers_rem: typeof rem;
41
41
  declare const handlers_time: typeof time;
42
42
  declare namespace handlers {
43
- export { handlers_auto as auto, handlers_bracket as bracket, handlers_bracketOfColor as bracketOfColor, handlers_bracketOfLength as bracketOfLength, handlers_bracketOfPosition as bracketOfPosition, handlers_cssvar as cssvar, handlers_degree as degree, handlers_fraction as fraction, handlers_global as global, handlers_number as number, handlers_numberWithUnit as numberWithUnit, handlers_percent as percent, handlers_position as position, handlers_properties as properties, handlers_px as px, handlers_rem as rem, handlers_time as time };
43
+ export {
44
+ handlers_auto as auto,
45
+ handlers_bracket as bracket,
46
+ handlers_bracketOfColor as bracketOfColor,
47
+ handlers_bracketOfLength as bracketOfLength,
48
+ handlers_bracketOfPosition as bracketOfPosition,
49
+ handlers_cssvar as cssvar,
50
+ handlers_degree as degree,
51
+ handlers_fraction as fraction,
52
+ handlers_global as global,
53
+ handlers_number as number,
54
+ handlers_numberWithUnit as numberWithUnit,
55
+ handlers_percent as percent,
56
+ handlers_position as position,
57
+ handlers_properties as properties,
58
+ handlers_px as px,
59
+ handlers_rem as rem,
60
+ handlers_time as time,
61
+ };
44
62
  }
45
63
 
46
- declare const handler: _unocss_rule_utils.ValueHandler<"number" | "global" | "auto" | "px" | "position" | "numberWithUnit" | "rem" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
47
- declare const h: _unocss_rule_utils.ValueHandler<"number" | "global" | "auto" | "px" | "position" | "numberWithUnit" | "rem" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
64
+ declare const handler: _unocss_rule_utils.ValueHandler<"number" | "numberWithUnit" | "auto" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "global" | "properties" | "position">;
65
+ declare const h: _unocss_rule_utils.ValueHandler<"number" | "numberWithUnit" | "auto" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "global" | "properties" | "position">;
48
66
 
49
67
  declare const directionMap: Record<string, string[]>;
50
68
  declare const insetMap: Record<string, string[]>;
package/dist/utils.d.ts CHANGED
@@ -40,11 +40,29 @@ declare const handlers_px: typeof px;
40
40
  declare const handlers_rem: typeof rem;
41
41
  declare const handlers_time: typeof time;
42
42
  declare namespace handlers {
43
- export { handlers_auto as auto, handlers_bracket as bracket, handlers_bracketOfColor as bracketOfColor, handlers_bracketOfLength as bracketOfLength, handlers_bracketOfPosition as bracketOfPosition, handlers_cssvar as cssvar, handlers_degree as degree, handlers_fraction as fraction, handlers_global as global, handlers_number as number, handlers_numberWithUnit as numberWithUnit, handlers_percent as percent, handlers_position as position, handlers_properties as properties, handlers_px as px, handlers_rem as rem, handlers_time as time };
43
+ export {
44
+ handlers_auto as auto,
45
+ handlers_bracket as bracket,
46
+ handlers_bracketOfColor as bracketOfColor,
47
+ handlers_bracketOfLength as bracketOfLength,
48
+ handlers_bracketOfPosition as bracketOfPosition,
49
+ handlers_cssvar as cssvar,
50
+ handlers_degree as degree,
51
+ handlers_fraction as fraction,
52
+ handlers_global as global,
53
+ handlers_number as number,
54
+ handlers_numberWithUnit as numberWithUnit,
55
+ handlers_percent as percent,
56
+ handlers_position as position,
57
+ handlers_properties as properties,
58
+ handlers_px as px,
59
+ handlers_rem as rem,
60
+ handlers_time as time,
61
+ };
44
62
  }
45
63
 
46
- declare const handler: _unocss_rule_utils.ValueHandler<"number" | "global" | "auto" | "px" | "position" | "numberWithUnit" | "rem" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
47
- declare const h: _unocss_rule_utils.ValueHandler<"number" | "global" | "auto" | "px" | "position" | "numberWithUnit" | "rem" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "properties">;
64
+ declare const handler: _unocss_rule_utils.ValueHandler<"number" | "numberWithUnit" | "auto" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "global" | "properties" | "position">;
65
+ declare const h: _unocss_rule_utils.ValueHandler<"number" | "numberWithUnit" | "auto" | "rem" | "px" | "percent" | "fraction" | "bracket" | "bracketOfColor" | "bracketOfLength" | "bracketOfPosition" | "cssvar" | "time" | "degree" | "global" | "properties" | "position">;
48
66
 
49
67
  declare const directionMap: Record<string, string[]>;
50
68
  declare const insetMap: Record<string, string[]>;
@@ -7,7 +7,7 @@ import './shared/preset-mini.oF7XTPi1.mjs';
7
7
  import '@unocss/rule-utils';
8
8
 
9
9
  declare const variantAria: VariantObject;
10
- declare const variantTaggedAriaAttributes: Variant[];
10
+ declare function variantTaggedAriaAttributes(options?: PresetMiniOptions): Variant[];
11
11
 
12
12
  declare function variantBreakpoints(): VariantObject;
13
13
 
@@ -20,7 +20,7 @@ declare const variantContainerQuery: VariantObject;
20
20
  declare function variantColorsMediaOrClass(options?: PresetMiniOptions): Variant[];
21
21
 
22
22
  declare const variantDataAttribute: VariantObject;
23
- declare const variantTaggedDataAttributes: Variant[];
23
+ declare function variantTaggedDataAttributes(options?: PresetMiniOptions): Variant[];
24
24
 
25
25
  declare function variants(options: PresetMiniOptions): Variant<Theme>[];
26
26
 
@@ -7,7 +7,7 @@ import './shared/preset-mini.CRliz1QB.js';
7
7
  import '@unocss/rule-utils';
8
8
 
9
9
  declare const variantAria: VariantObject;
10
- declare const variantTaggedAriaAttributes: Variant[];
10
+ declare function variantTaggedAriaAttributes(options?: PresetMiniOptions): Variant[];
11
11
 
12
12
  declare function variantBreakpoints(): VariantObject;
13
13
 
@@ -20,7 +20,7 @@ declare const variantContainerQuery: VariantObject;
20
20
  declare function variantColorsMediaOrClass(options?: PresetMiniOptions): Variant[];
21
21
 
22
22
  declare const variantDataAttribute: VariantObject;
23
- declare const variantTaggedDataAttributes: Variant[];
23
+ declare function variantTaggedDataAttributes(options?: PresetMiniOptions): Variant[];
24
24
 
25
25
  declare function variants(options: PresetMiniOptions): Variant<Theme>[];
26
26
 
package/dist/variants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { v as variantAria, b as variantBreakpoints, c as variantChildren, f as variantColorsMediaOrClass, d as variantCombinators, e as variantContainerQuery, o as variantCssLayer, m as variantCustomMedia, g as variantDataAttribute, k as variantImportant, p as variantInternalLayer, j as variantLanguageDirections, t as variantNegative, y as variantPartClasses, l as variantPrint, w as variantPseudoClassFunctions, u as variantPseudoClassesAndElements, q as variantScope, n as variantSelector, z as variantStartingStyle, A as variantSupports, a as variantTaggedAriaAttributes, h as variantTaggedDataAttributes, x as variantTaggedPseudoClasses, s as variantTheme, r as variantVariables, i as variants } from './shared/preset-mini.-NZCZZOn.mjs';
1
+ export { v as variantAria, b as variantBreakpoints, c as variantChildren, f as variantColorsMediaOrClass, d as variantCombinators, e as variantContainerQuery, o as variantCssLayer, m as variantCustomMedia, g as variantDataAttribute, k as variantImportant, p as variantInternalLayer, j as variantLanguageDirections, t as variantNegative, y as variantPartClasses, l as variantPrint, w as variantPseudoClassFunctions, u as variantPseudoClassesAndElements, q as variantScope, n as variantSelector, z as variantStartingStyle, A as variantSupports, a as variantTaggedAriaAttributes, h as variantTaggedDataAttributes, x as variantTaggedPseudoClasses, s as variantTheme, r as variantVariables, i as variants } from './shared/preset-mini.DbGR1fYK.mjs';
2
+ import '@unocss/core';
2
3
  import '@unocss/rule-utils';
3
4
  import './shared/preset-mini.DrfPDgwn.mjs';
4
- import '@unocss/core';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
3
  "type": "module",
4
- "version": "66.3.2",
4
+ "version": "66.4.0",
5
5
  "description": "The minimal preset 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": "git+https://github.com/unocss/unocss",
12
+ "url": "git+https://github.com/unocss/unocss.git",
13
13
  "directory": "packages-presets/preset-mini"
14
14
  },
15
15
  "bugs": {
@@ -56,9 +56,9 @@
56
56
  "dist"
57
57
  ],
58
58
  "dependencies": {
59
- "@unocss/core": "66.3.2",
60
- "@unocss/extractor-arbitrary-variants": "66.3.2",
61
- "@unocss/rule-utils": "66.3.2"
59
+ "@unocss/rule-utils": "66.4.0",
60
+ "@unocss/core": "66.4.0",
61
+ "@unocss/extractor-arbitrary-variants": "66.4.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "unbuild",