@unocss/preset-wind4 66.1.0-beta.6 → 66.1.0-beta.7

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,7 +1,7 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { Postprocessor, Preflight, Variant, PresetOptions } from '@unocss/core';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
4
- export { r as rules } from './shared/preset-wind4.DIUjJahF.mjs';
2
+ import { Postprocessor, Preflight, Variant, PresetOptions, PreflightContext } from '@unocss/core';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
4
+ export { r as rules } from './shared/preset-wind4.D71xGC6i.mjs';
5
5
  export { shortcuts } from './shortcuts.mjs';
6
6
  export { t as theme } from './shared/preset-wind4.BOe5kxIw.mjs';
7
7
 
@@ -90,7 +90,15 @@ interface PresetWind4Options extends PresetOptions {
90
90
  *
91
91
  * @default 'on-demand'
92
92
  */
93
- themeVariable?: boolean | 'on-demand';
93
+ themePreflight?: boolean | 'on-demand';
94
+ /**
95
+ * Process theme variables before generating CSS variables.
96
+ *
97
+ * @param vars [key, value][]
98
+ * @param ctx {@link PreflightContext}
99
+ * @returns
100
+ */
101
+ processThemeVars?: (vars: [string, string][], ctx: PreflightContext) => void | [string, string][];
94
102
  }
95
103
  declare const presetWind4: _unocss_core.PresetFactory<Theme, PresetWind4Options>;
96
104
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { Postprocessor, Preflight, Variant, PresetOptions } from '@unocss/core';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
4
- export { r as rules } from './shared/preset-wind4.BJEl798_.js';
2
+ import { Postprocessor, Preflight, Variant, PresetOptions, PreflightContext } from '@unocss/core';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
4
+ export { r as rules } from './shared/preset-wind4.Ca5oWgxX.js';
5
5
  export { shortcuts } from './shortcuts.js';
6
6
  export { t as theme } from './shared/preset-wind4.BOe5kxIw.js';
7
7
 
@@ -90,7 +90,15 @@ interface PresetWind4Options extends PresetOptions {
90
90
  *
91
91
  * @default 'on-demand'
92
92
  */
93
- themeVariable?: boolean | 'on-demand';
93
+ themePreflight?: boolean | 'on-demand';
94
+ /**
95
+ * Process theme variables before generating CSS variables.
96
+ *
97
+ * @param vars [key, value][]
98
+ * @param ctx {@link PreflightContext}
99
+ * @returns
100
+ */
101
+ processThemeVars?: (vars: [string, string][], ctx: PreflightContext) => void | [string, string][];
94
102
  }
95
103
  declare const presetWind4: _unocss_core.PresetFactory<Theme, PresetWind4Options>;
96
104
 
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import { LAYER_PREFLIGHTS, definePreset } from '@unocss/core';
2
2
  import { extractorArbitraryVariants } from '@unocss/extractor-arbitrary-variants';
3
- import { a as themeTracking, J as compressCSS, P as PRESET_NAME, I as hyphenate, p as passThemeKey, g as globalKeywords, t as trackedTheme } from './shared/preset-wind4.47ZKbxbU.mjs';
3
+ import { a as themeTracking, J as compressCSS, P as PRESET_NAME, w as getThemeByKey, I as hyphenate, p as passThemeKey, g as globalKeywords, t as trackedTheme } from './shared/preset-wind4.CkxnR6p3.mjs';
4
4
  import { alphaPlaceholdersRE } from '@unocss/rule-utils';
5
5
  import { postprocessors } from './postprocess.mjs';
6
- import { l as variants } from './shared/preset-wind4.fVfslvMN.mjs';
6
+ import { l as variants } from './shared/preset-wind4.DXr6hHdY.mjs';
7
7
  import { theme as theme$1 } from './theme.mjs';
8
- import { s as shortcuts } from './shared/preset-wind4.BvXCZB8z.mjs';
9
- import { r as rules } from './shared/preset-wind4.We0XxImM.mjs';
8
+ import { s as shortcuts } from './shared/preset-wind4.BwU-POWl.mjs';
9
+ import { r as rules } from './shared/preset-wind4.CJ98Gjkm.mjs';
10
10
  import './colors.mjs';
11
- import './shared/preset-wind4.39lqTMpc.mjs';
11
+ import './shared/preset-wind4.DhDf1e1c.mjs';
12
12
 
13
13
  const resetCSS = `
14
14
  /*
@@ -399,7 +399,7 @@ function reset(options) {
399
399
  if (options.reset === false)
400
400
  return void 0;
401
401
  return {
402
- getCSS: () => {
402
+ getCSS: ({ generator }) => {
403
403
  themeTracking("font", "sans");
404
404
  themeTracking("font", "mono");
405
405
  themeTracking("defaults", ["font", "family"]);
@@ -408,7 +408,7 @@ function reset(options) {
408
408
  themeTracking("defaults", ["monoFont", "family"]);
409
409
  themeTracking("defaults", ["monoFont", "featureSettings"]);
410
410
  themeTracking("defaults", ["monoFont", "variationSettings"]);
411
- return compressCSS(resetCSS);
411
+ return compressCSS(resetCSS, generator.config.envMode === "dev");
412
412
  },
413
413
  layer: LAYER_PREFLIGHTS
414
414
  };
@@ -428,24 +428,23 @@ const ExcludeCssVarKeys = [
428
428
  "media",
429
429
  "supports"
430
430
  ];
431
- function themeToCSSVars(theme2, keys) {
432
- let cssVariables = "";
431
+ function getThemeVarsMap(theme2, keys) {
432
+ const themeMap = /* @__PURE__ */ new Map([
433
+ ["--spacing", theme2.spacing.DEFAULT]
434
+ ]);
433
435
  function process(obj, prefix) {
434
436
  for (const key in obj) {
435
437
  if (key === "DEFAULT" && Object.keys(obj).length === 1) {
436
- cssVariables += `${hyphenate(`--${prefix}`)}: ${obj[key].replace(alphaPlaceholdersRE, "1")};
437
- `;
438
+ themeMap.set(hyphenate(`--${prefix}`), obj[key].replace(alphaPlaceholdersRE, "1"));
438
439
  }
439
440
  if (passThemeKey.includes(key))
440
441
  continue;
441
442
  if (Array.isArray(obj[key])) {
442
- cssVariables += `${hyphenate(`--${prefix}-${key}`)}: ${obj[key].join(",").replace(alphaPlaceholdersRE, "1")};
443
- `;
443
+ themeMap.set(hyphenate(`--${prefix}-${key}`), obj[key].join(",").replace(alphaPlaceholdersRE, "1"));
444
444
  } else if (typeof obj[key] === "object") {
445
445
  process(obj[key], `${prefix}-${key}`);
446
446
  } else {
447
- cssVariables += `${hyphenate(`--${prefix}-${key}`)}: ${obj[key].replace(alphaPlaceholdersRE, "1")};
448
- `;
447
+ themeMap.set(hyphenate(`--${prefix}-${key}`), obj[key].replace(alphaPlaceholdersRE, "1"));
449
448
  }
450
449
  }
451
450
  }
@@ -454,39 +453,49 @@ function themeToCSSVars(theme2, keys) {
454
453
  continue;
455
454
  process(theme2[key], key);
456
455
  }
457
- return cssVariables;
456
+ return themeMap;
458
457
  }
459
458
  function theme(options) {
460
459
  return {
461
460
  layer: "theme",
462
- getCSS({ theme: theme2, generator }) {
463
- if (options.themeVariable === false) {
461
+ getCSS(ctx) {
462
+ const { theme: theme2, generator } = ctx;
463
+ if (options.themePreflight === false) {
464
464
  return void 0;
465
- } else if (options.themeVariable === "on-demand") {
465
+ }
466
+ let deps;
467
+ const generateCSS = (deps2) => {
468
+ if (options.processThemeVars) {
469
+ deps2 = options.processThemeVars(deps2, ctx) ?? deps2;
470
+ }
471
+ if (deps2.length === 0)
472
+ return void 0;
473
+ const depCSS = deps2.map(([key, value]) => `${key}: ${value};`).join("\n");
474
+ return compressCSS(`
475
+ :root, :host {
476
+ ${depCSS}
477
+ }`, generator.config.envMode === "dev");
478
+ };
479
+ if (options.themePreflight === "on-demand") {
466
480
  const self = generator.config.presets.find((p) => p.name === PRESET_NAME);
467
481
  if (!self || self.meta.themeDeps.size === 0)
468
- return;
469
- const depCSS = Array.from(self.meta.themeDeps).map((k) => {
482
+ return void 0;
483
+ deps = Array.from(self.meta.themeDeps).map((k) => {
470
484
  const [key, prop] = k.split(":");
471
- const props = prop.split("-");
472
- const v = props.reduce((o, p) => o?.[p], theme2[key]);
485
+ let v = getThemeByKey(theme2, key, prop.split("-")) ?? getThemeByKey(theme2, key, [prop]);
486
+ if (typeof v === "object") {
487
+ v = v.DEFAULT;
488
+ }
473
489
  if (v) {
474
- return `--${hyphenate(`${key}${prop !== "DEFAULT" ? `-${prop}` : ""}`)}: ${v};`;
490
+ return [`--${hyphenate(`${key}${prop !== "DEFAULT" ? `-${prop}` : ""}`)}`, v];
475
491
  }
476
492
  return void 0;
477
- });
478
- return compressCSS(`
479
- :root {
480
- ${depCSS.filter(Boolean).join("\n")}
481
- }`);
493
+ }).filter(Boolean);
482
494
  } else {
483
495
  const keys = Object.keys(theme2).filter((k) => !ExcludeCssVarKeys.includes(k));
484
- return compressCSS(`
485
- :root {
486
- --spacing: ${theme2.spacing.DEFAULT};
487
- ${themeToCSSVars(theme2, keys).trim()}
488
- }`);
496
+ deps = Array.from(getThemeVarsMap(theme2, keys));
489
497
  }
498
+ return generateCSS(deps);
490
499
  }
491
500
  };
492
501
  }
@@ -514,7 +523,7 @@ const presetWind4 = definePreset((options = {}) => {
514
523
  options.attributifyPseudo = options.attributifyPseudo ?? false;
515
524
  options.variablePrefix = options.variablePrefix ?? "un-";
516
525
  options.important = options.important ?? false;
517
- options.themeVariable = options.themeVariable ?? "on-demand";
526
+ options.themePreflight = options.themePreflight ?? "on-demand";
518
527
  return {
519
528
  name: PRESET_NAME,
520
529
  rules,
@@ -1,8 +1,8 @@
1
1
  import { PresetWind4Options } from './index.mjs';
2
2
  export { postprocessors } from './index.mjs';
3
3
  import { Postprocessor } from '@unocss/core';
4
- import './shared/preset-wind4.MiZzPO05.mjs';
5
- import './shared/preset-wind4.DIUjJahF.mjs';
4
+ import './shared/preset-wind4.BXbWGSRz.mjs';
5
+ import './shared/preset-wind4.D71xGC6i.mjs';
6
6
  import './shortcuts.mjs';
7
7
  import './shared/preset-wind4.BOe5kxIw.mjs';
8
8
 
@@ -1,8 +1,8 @@
1
1
  import { PresetWind4Options } from './index.js';
2
2
  export { postprocessors } from './index.js';
3
3
  import { Postprocessor } from '@unocss/core';
4
- import './shared/preset-wind4.MiZzPO05.js';
5
- import './shared/preset-wind4.BJEl798_.js';
4
+ import './shared/preset-wind4.BXbWGSRz.js';
5
+ import './shared/preset-wind4.Ca5oWgxX.js';
6
6
  import './shortcuts.js';
7
7
  import './shared/preset-wind4.BOe5kxIw.js';
8
8
 
package/dist/rules.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Rule, CSSEntries, Shortcut, StaticRule } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
3
- export { r as rules } from './shared/preset-wind4.DIUjJahF.mjs';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
3
+ export { r as rules } from './shared/preset-wind4.D71xGC6i.mjs';
4
4
 
5
5
  declare const verticalAligns: Rule<Theme>[];
6
6
  declare const textAligns: Rule<Theme>[];
package/dist/rules.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Rule, CSSEntries, Shortcut, StaticRule } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
3
- export { r as rules } from './shared/preset-wind4.BJEl798_.js';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
3
+ export { r as rules } from './shared/preset-wind4.Ca5oWgxX.js';
4
4
 
5
5
  declare const verticalAligns: Rule<Theme>[];
6
6
  declare const textAligns: Rule<Theme>[];
package/dist/rules.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { d as accents, am as accessibility, H as alignments, a as animations, c as appearance, _ as appearances, U as aspectRatio, aj as backgroundBlendModes, b as backgroundStyles, m as bgColors, g as borderStyles, h as borders, S as boxShadows, N as boxSizing, a7 as breaks, e as carets, n as colorScheme, p as columns, a0 as contains, a5 as contentVisibility, a6 as contents, aB as cssProperty, aA as cssVariables, $ as cursors, Z as displays, u as divides, al as dynamicViewportHeight, x as filters, y as flex, J as flexGridJustifiesAlignments, L as floats, ac as fontSmoothings, ab as fontStyles, ay as fontVariantNumeric, at as fonts, z as gaps, A as grids, j as handlerBorderStyle, ad as hyphens, i as imageRenderings, K as insets, ah as isolations, F as justifies, C as lineClamps, l as listStyle, W as margins, ak as mixBlendModes, Y as notLastChildSelector, ai as objectPositions, k as opacity, G as orders, o as outline, B as overflows, f as overscrolls, V as paddings, D as placeholders, I as placements, a1 as pointerEvents, E as positions, O as questionMark, a2 as resizes, P as rings, r as rules, ag as screenReadersAccess, s as scrollBehaviors, Q as scrolls, R as shadowProperties, T as sizes, X as spaces, az as splitShorthand, an as svgUtilities, au as tabSizes, ao as tables, t as textAligns, q as textDecorations, av as textIndents, a9 as textOverflows, ax as textShadows, aw as textStrokes, aa as textTransforms, a8 as textWraps, ap as touchActions, aq as transformBase, ar as transforms, as as transitions, a3 as userSelects, v as verticalAligns, aC as viewTransition, a4 as whitespaces, w as willChange, ae as writingModes, af as writingOrientations, M as zIndexes } from './shared/preset-wind4.We0XxImM.mjs';
2
- export { a as container, c as containerParent, b as containerShortcuts } from './shared/preset-wind4.39lqTMpc.mjs';
3
- import './shared/preset-wind4.47ZKbxbU.mjs';
1
+ export { d as accents, am as accessibility, H as alignments, a as animations, c as appearance, _ as appearances, U as aspectRatio, aj as backgroundBlendModes, b as backgroundStyles, m as bgColors, g as borderStyles, h as borders, S as boxShadows, N as boxSizing, a7 as breaks, e as carets, n as colorScheme, p as columns, a0 as contains, a5 as contentVisibility, a6 as contents, aB as cssProperty, aA as cssVariables, $ as cursors, Z as displays, u as divides, al as dynamicViewportHeight, x as filters, y as flex, J as flexGridJustifiesAlignments, L as floats, ac as fontSmoothings, ab as fontStyles, ay as fontVariantNumeric, at as fonts, z as gaps, A as grids, j as handlerBorderStyle, ad as hyphens, i as imageRenderings, K as insets, ah as isolations, F as justifies, C as lineClamps, l as listStyle, W as margins, ak as mixBlendModes, Y as notLastChildSelector, ai as objectPositions, k as opacity, G as orders, o as outline, B as overflows, f as overscrolls, V as paddings, D as placeholders, I as placements, a1 as pointerEvents, E as positions, O as questionMark, a2 as resizes, P as rings, r as rules, ag as screenReadersAccess, s as scrollBehaviors, Q as scrolls, R as shadowProperties, T as sizes, X as spaces, az as splitShorthand, an as svgUtilities, au as tabSizes, ao as tables, t as textAligns, q as textDecorations, av as textIndents, a9 as textOverflows, ax as textShadows, aw as textStrokes, aa as textTransforms, a8 as textWraps, ap as touchActions, aq as transformBase, ar as transforms, as as transitions, a3 as userSelects, v as verticalAligns, aC as viewTransition, a4 as whitespaces, w as willChange, ae as writingModes, af as writingOrientations, M as zIndexes } from './shared/preset-wind4.CJ98Gjkm.mjs';
2
+ export { a as container, c as containerParent, b as containerShortcuts } from './shared/preset-wind4.DhDf1e1c.mjs';
3
+ import './shared/preset-wind4.CkxnR6p3.mjs';
4
4
  import '@unocss/core';
5
5
  import '@unocss/rule-utils';
@@ -1,5 +1,7 @@
1
1
  interface Colors {
2
- [key: string]: Colors | string;
2
+ [key: string]: Colors & {
3
+ DEFAULT?: string;
4
+ } | string;
3
5
  }
4
6
  interface ThemeAnimation {
5
7
  keyframes?: Record<string, string>;
@@ -1,5 +1,7 @@
1
1
  interface Colors {
2
- [key: string]: Colors | string;
2
+ [key: string]: Colors & {
3
+ DEFAULT?: string;
4
+ } | string;
3
5
  }
4
6
  interface ThemeAnimation {
5
7
  keyframes?: Record<string, string>;
@@ -1,4 +1,4 @@
1
- import { b as containerShortcuts } from './preset-wind4.39lqTMpc.mjs';
1
+ import { b as containerShortcuts } from './preset-wind4.DhDf1e1c.mjs';
2
2
 
3
3
  const shortcuts = [
4
4
  ...containerShortcuts
@@ -1,6 +1,6 @@
1
- import { g as globalKeywords, b as h, D as makeGlobalStaticRules, f as positionMap, r as parseColor, S as SpecialColorKey, K as defineProperty, q as colorResolver, E as isCSSMathFn, d as directionMap, z as hasParseableColor, c as cornerMap, p as passThemeKey, a as themeTracking, o as colorCSSGenerator, F as isSize, l as directionSize, n as numberResolver, m as colorableShadows, i as insetMap, I as hyphenate, A as resolveBreakpoints, G as transformXYZ, x as xyzMap, L as bracketTypeRe } from './preset-wind4.47ZKbxbU.mjs';
1
+ import { g as globalKeywords, b as h, D as makeGlobalStaticRules, f as positionMap, r as parseColor, S as SpecialColorKey, K as defineProperty, a as themeTracking, L as detectThemeValue, q as colorResolver, E as isCSSMathFn, d as directionMap, z as hasParseableColor, c as cornerMap, p as passThemeKey, o as colorCSSGenerator, F as isSize, l as directionSize, n as numberResolver, m as colorableShadows, i as insetMap, I as hyphenate, A as resolveBreakpoints, G as transformXYZ, x as xyzMap, M as bracketTypeRe } from './preset-wind4.CkxnR6p3.mjs';
2
2
  import { notNull, uniq } from '@unocss/core';
3
- import { a as container, c as containerParent } from './preset-wind4.39lqTMpc.mjs';
3
+ import { a as container, c as containerParent } from './preset-wind4.DhDf1e1c.mjs';
4
4
  import { getStringComponent } from '@unocss/rule-utils';
5
5
 
6
6
  const verticalAlignAlias = {
@@ -138,13 +138,21 @@ function bgGradientColorResolver() {
138
138
  const data = parseColor(body, theme);
139
139
  if (data) {
140
140
  const { color, key, alpha } = data;
141
- if (Object.values(SpecialColorKey).includes(color)) {
142
- css[`--un-gradient-${position}`] = color;
143
- } else {
144
- css[`--un-${position}-opacity`] = alpha;
145
- const value = key ? `var(--colors-${key})` : color;
146
- css[`--un-gradient-${position}`] = `color-mix(in oklab, ${value} var(--un-${position}-opacity), transparent)`;
147
- yield defineProperty(`--un-${position}-opacity`, { syntax: "<percentage>", initialValue: "100%" });
141
+ if (color) {
142
+ if (Object.values(SpecialColorKey).includes(color)) {
143
+ css[`--un-gradient-${position}`] = color;
144
+ } else {
145
+ css[`--un-${position}-opacity`] = alpha;
146
+ const value = key ? `var(--colors-${key})` : color;
147
+ css[`--un-gradient-${position}`] = `color-mix(in oklab, ${value} var(--un-${position}-opacity), transparent)`;
148
+ yield defineProperty(`--un-${position}-opacity`, { syntax: "<percentage>", initialValue: "100%" });
149
+ }
150
+ if (key) {
151
+ themeTracking(`colors`, key);
152
+ }
153
+ if (theme) {
154
+ detectThemeValue(color, theme);
155
+ }
148
156
  }
149
157
  } else {
150
158
  css[`--un-gradient-${position}`] = h.bracket.cssvar(body);
@@ -715,7 +723,7 @@ const filterBaseKeys = [
715
723
  "drop-shadow"
716
724
  ];
717
725
  const filterProperties = filterBaseKeys.map((i) => defineProperty(`--un-${i}`)).join("\n");
718
- const filterCSS = filterBaseKeys.map((i) => `var(--un-${i})`).join(" ");
726
+ const filterCSS = filterBaseKeys.map((i) => `var(--un-${i},)`).join(" ");
719
727
  const backdropBaseKeys = [
720
728
  "backdrop-blur",
721
729
  "backdrop-brightness",
@@ -728,7 +736,7 @@ const backdropBaseKeys = [
728
736
  "backdrop-sepia"
729
737
  ];
730
738
  const backdropProperties = backdropBaseKeys.map((i) => defineProperty(`--un-${i}`)).join("\n");
731
- const backdropCSS = backdropBaseKeys.map((i) => `var(--un-${i})`).join(" ");
739
+ const backdropCSS = backdropBaseKeys.map((i) => `var(--un-${i},)`).join(" ");
732
740
  function percentWithDefault(str) {
733
741
  let v = h.bracket.cssvar(str || "");
734
742
  if (v != null)
@@ -1965,12 +1973,12 @@ const transitions = [
1965
1973
  ([, d]) => ({ "transition-delay": h.bracket.cssvar.time(d) })
1966
1974
  ],
1967
1975
  [
1968
- /^(?:transition-)?ease-(.+)$/,
1969
- ([, d], { theme }) => {
1976
+ /^(?:transition-)?ease(?:-(.+))?$/,
1977
+ ([, d = "DEFAULT"], { theme }) => {
1970
1978
  let v;
1971
1979
  if (theme.ease?.[d]) {
1972
1980
  themeTracking("ease", d);
1973
- v = `var(--ease-${d})`;
1981
+ v = `var(--ease${d === "DEFAULT" ? "" : `-${d}`})`;
1974
1982
  } else {
1975
1983
  v = h.bracket.cssvar(d);
1976
1984
  }
@@ -1,5 +1,5 @@
1
1
  import { Rule } from '@unocss/core';
2
- import { T as Theme } from './preset-wind4.MiZzPO05.js';
2
+ import { T as Theme } from './preset-wind4.BXbWGSRz.js';
3
3
 
4
4
  declare const rules: Rule<Theme>[];
5
5
 
@@ -505,12 +505,15 @@ function colorCSSGenerator(data, property, varName, ctx) {
505
505
  } else {
506
506
  const alphaKey = `--un-${varName}-opacity`;
507
507
  const value = key ? `var(--colors-${key})` : color;
508
- if (key) {
509
- themeTracking(`colors`, key);
510
- }
511
508
  css[alphaKey] = alpha;
512
509
  css[property] = `color-mix(in oklch, ${value} var(${alphaKey}), transparent)${rawColorComment}`;
513
510
  result.push(defineProperty(alphaKey, { syntax: "<percentage>", initialValue: "100%" }));
511
+ if (key) {
512
+ themeTracking(`colors`, key);
513
+ }
514
+ if (ctx?.theme) {
515
+ detectThemeValue(color, ctx.theme);
516
+ }
514
517
  }
515
518
  return result;
516
519
  }
@@ -571,10 +574,16 @@ function parseThemeColor(theme, keys) {
571
574
  no = scale;
572
575
  _keys = keys.slice(0, -1);
573
576
  }
574
- const colorData = getThemeColor(theme, _keys);
577
+ const colorData = getThemeByKey(theme, "colors", _keys);
575
578
  if (typeof colorData === "object") {
576
- color = colorData[no ?? "400"];
577
- key = [..._keys, no ?? "400"].join("-");
579
+ if (no && colorData[no]) {
580
+ color = colorData[no];
581
+ key = [..._keys, no].join("-");
582
+ } else if (!no && colorData.DEFAULT) {
583
+ color = colorData.DEFAULT;
584
+ no = "DEFAULT";
585
+ key = _keys.join("-");
586
+ }
578
587
  } else if (typeof colorData === "string" && !no) {
579
588
  color = colorData;
580
589
  key = _keys.join("-");
@@ -587,15 +596,18 @@ function parseThemeColor(theme, keys) {
587
596
  key
588
597
  };
589
598
  }
590
- function getThemeColor(theme, keys) {
591
- let obj = theme.colors;
599
+ function getThemeByKey(theme, themeKey, keys) {
600
+ let obj = theme[themeKey];
592
601
  let index = -1;
593
602
  for (const k of keys) {
594
603
  index += 1;
595
604
  if (obj && typeof obj !== "string") {
596
- const camel = keys.slice(index).join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase());
605
+ const camel = camelize(keys.slice(index).join("-"));
597
606
  if (obj[camel])
598
607
  return obj[camel];
608
+ const hyphen = keys.slice(index).join("-");
609
+ if (obj[hyphen])
610
+ return obj[hyphen];
599
611
  if (obj[k]) {
600
612
  obj = obj[k];
601
613
  continue;
@@ -650,7 +662,9 @@ function camelize(str) {
650
662
  function hyphenate(str) {
651
663
  return str.replace(/(?:^|\B)([A-Z])/g, "-$1").toLowerCase();
652
664
  }
653
- function compressCSS(css) {
665
+ function compressCSS(css, isDev = false) {
666
+ if (isDev)
667
+ return css.trim();
654
668
  return css.trim().replace(/\s+/g, " ").replace(/\/\*[\s\S]*?\*\//g, "");
655
669
  }
656
670
  function defineProperty(property, options = {}) {
@@ -661,5 +675,18 @@ function defineProperty(property, options = {}) {
661
675
  } = options;
662
676
  return `@property ${property} {syntax: "${syntax}";inherits: ${inherits};${initialValue != null ? `initial-value: ${initialValue};` : ""}}`;
663
677
  }
678
+ function detectThemeValue(value, theme) {
679
+ if (value.startsWith("var(")) {
680
+ const variable = value.match(/var\(--([\w-]+)(?:,.*)?\)/)?.[1];
681
+ if (variable) {
682
+ const [key, ...path] = variable.split("-");
683
+ const themeValue = getThemeByKey(theme, key, path);
684
+ if (themeValue != null) {
685
+ themeTracking(key, path);
686
+ detectThemeValue(themeValue, theme);
687
+ }
688
+ }
689
+ }
690
+ }
664
691
 
665
- export { resolveBreakpoints as A, resolveVerticalBreakpoints as B, CONTROL_MINI_NO_NEGATIVE as C, makeGlobalStaticRules as D, isCSSMathFn as E, isSize as F, transformXYZ as G, camelize as H, hyphenate as I, compressCSS as J, defineProperty as K, bracketTypeRe as L, PRESET_NAME as P, SpecialColorKey as S, themeTracking as a, h as b, cornerMap as c, directionMap as d, xyzArray as e, positionMap as f, globalKeywords as g, handler as h, insetMap as i, cssMathFnRE as j, cssVarFnRE as k, directionSize as l, colorableShadows as m, numberResolver as n, colorCSSGenerator as o, passThemeKey as p, colorResolver as q, parseColor as r, splitShorthand as s, trackedTheme as t, parseThemeColor as u, valueHandlers as v, getThemeColor as w, xyzMap as x, colorVariable as y, hasParseableColor as z };
692
+ export { resolveBreakpoints as A, resolveVerticalBreakpoints as B, CONTROL_MINI_NO_NEGATIVE as C, makeGlobalStaticRules as D, isCSSMathFn as E, isSize as F, transformXYZ as G, camelize as H, hyphenate as I, compressCSS as J, defineProperty as K, detectThemeValue as L, bracketTypeRe as M, PRESET_NAME as P, SpecialColorKey as S, themeTracking as a, h as b, cornerMap as c, directionMap as d, xyzArray as e, positionMap as f, globalKeywords as g, handler as h, insetMap as i, cssMathFnRE as j, cssVarFnRE as k, directionSize as l, colorableShadows as m, numberResolver as n, colorCSSGenerator as o, passThemeKey as p, colorResolver as q, parseColor as r, splitShorthand as s, trackedTheme as t, parseThemeColor as u, valueHandlers as v, getThemeByKey as w, xyzMap as x, colorVariable as y, hasParseableColor as z };
@@ -1,5 +1,5 @@
1
1
  import { Rule } from '@unocss/core';
2
- import { T as Theme } from './preset-wind4.MiZzPO05.mjs';
2
+ import { T as Theme } from './preset-wind4.BXbWGSRz.mjs';
3
3
 
4
4
  declare const rules: Rule<Theme>[];
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { variantGetParameter, variantMatcher, variantGetBracket, variantParentMatcher, getBracket, hasThemeFn, transformThemeFn, getStringComponent } from '@unocss/rule-utils';
2
- import { b as h, A as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE, j as cssMathFnRE, k as cssVarFnRE, z as hasParseableColor } from './preset-wind4.47ZKbxbU.mjs';
2
+ import { b as h, A as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE, j as cssMathFnRE, k as cssVarFnRE, z as hasParseableColor } from './preset-wind4.CkxnR6p3.mjs';
3
3
  import { escapeRegExp, escapeSelector } from '@unocss/core';
4
4
 
5
5
  const variantAria = {
@@ -1,5 +1,5 @@
1
1
  import { isString } from '@unocss/core';
2
- import { A as resolveBreakpoints } from './preset-wind4.47ZKbxbU.mjs';
2
+ import { A as resolveBreakpoints } from './preset-wind4.CkxnR6p3.mjs';
3
3
 
4
4
  const containerParent = [
5
5
  [/^@container(?:\/(\w+))?(?:-(normal))?$/, ([, l, v]) => {
@@ -1,5 +1,5 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
3
3
 
4
4
  declare const shortcuts: _unocss_core.Shortcut<Theme>[];
5
5
 
@@ -1,5 +1,5 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
3
3
 
4
4
  declare const shortcuts: _unocss_core.Shortcut<Theme>[];
5
5
 
@@ -1,5 +1,5 @@
1
- export { s as shortcuts } from './shared/preset-wind4.BvXCZB8z.mjs';
2
- import './shared/preset-wind4.39lqTMpc.mjs';
1
+ export { s as shortcuts } from './shared/preset-wind4.BwU-POWl.mjs';
2
+ import './shared/preset-wind4.DhDf1e1c.mjs';
3
3
  import '@unocss/core';
4
- import './shared/preset-wind4.47ZKbxbU.mjs';
4
+ import './shared/preset-wind4.CkxnR6p3.mjs';
5
5
  import '@unocss/rule-utils';
package/dist/theme.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { colors } from './colors.mjs';
2
2
  export { t as theme } from './shared/preset-wind4.BOe5kxIw.mjs';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
4
- export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.MiZzPO05.mjs';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
4
+ export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.BXbWGSRz.mjs';
5
5
 
6
6
  declare const animation: {
7
7
  keyframes: {
package/dist/theme.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { colors } from './colors.js';
2
2
  export { t as theme } from './shared/preset-wind4.BOe5kxIw.js';
3
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
4
- export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.MiZzPO05.js';
3
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
4
+ export { C as Colors, a as ThemeAnimation } from './shared/preset-wind4.BXbWGSRz.js';
5
5
 
6
6
  declare const animation: {
7
7
  keyframes: {
package/dist/utils.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Arrayable, DynamicMatcher, RuleContext, CSSObject, CSSValueInput, VariantContext, StaticRule } from '@unocss/core';
2
2
  import * as _unocss_rule_utils from '@unocss/rule-utils';
3
3
  export * from '@unocss/rule-utils';
4
- import { T as Theme, C as Colors } from './shared/preset-wind4.MiZzPO05.mjs';
4
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
5
5
 
6
6
  declare const PRESET_NAME = "@unocss/preset-wind4";
7
7
  /** Keys will not appear in the theme variable. */
@@ -121,7 +121,7 @@ declare function parseThemeColor(theme: Theme, keys: string[]): {
121
121
  no: string | undefined;
122
122
  key: string | undefined;
123
123
  } | undefined;
124
- declare function getThemeColor(theme: Theme, keys: string[]): string | Colors | undefined;
124
+ declare function getThemeByKey(theme: Theme, themeKey: keyof Theme, keys: string[]): any;
125
125
  declare function colorVariable(str: string, varName: string): string;
126
126
  declare function hasParseableColor(color: string | undefined, theme: Theme): boolean;
127
127
  declare function resolveBreakpoints({ theme, generator }: Readonly<VariantContext<Theme>>, key?: 'breakpoint' | 'verticalBreakpoint'): {
@@ -138,11 +138,12 @@ declare function isSize(str: string): boolean;
138
138
  declare function transformXYZ(d: string, v: string, name: string): [string, string][];
139
139
  declare function camelize(str: string): string;
140
140
  declare function hyphenate(str: string): string;
141
- declare function compressCSS(css: string): string;
141
+ declare function compressCSS(css: string, isDev?: boolean): string;
142
142
  declare function defineProperty(property: string, options?: {
143
143
  syntax?: string;
144
144
  inherits?: boolean;
145
145
  initialValue?: unknown;
146
146
  }): string;
147
+ declare function detectThemeValue(value: string, theme: Theme): void;
147
148
 
148
- export { CONTROL_MINI_NO_NEGATIVE, PRESET_NAME, SpecialColorKey, camelize, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, directionMap, directionSize, getThemeColor, globalKeywords, h, handler, hasParseableColor, hyphenate, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, themeTracking, trackedTheme, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
149
+ export { CONTROL_MINI_NO_NEGATIVE, PRESET_NAME, SpecialColorKey, camelize, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, detectThemeValue, directionMap, directionSize, getThemeByKey, globalKeywords, h, handler, hasParseableColor, hyphenate, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, themeTracking, trackedTheme, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Arrayable, DynamicMatcher, RuleContext, CSSObject, CSSValueInput, VariantContext, StaticRule } from '@unocss/core';
2
2
  import * as _unocss_rule_utils from '@unocss/rule-utils';
3
3
  export * from '@unocss/rule-utils';
4
- import { T as Theme, C as Colors } from './shared/preset-wind4.MiZzPO05.js';
4
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
5
5
 
6
6
  declare const PRESET_NAME = "@unocss/preset-wind4";
7
7
  /** Keys will not appear in the theme variable. */
@@ -121,7 +121,7 @@ declare function parseThemeColor(theme: Theme, keys: string[]): {
121
121
  no: string | undefined;
122
122
  key: string | undefined;
123
123
  } | undefined;
124
- declare function getThemeColor(theme: Theme, keys: string[]): string | Colors | undefined;
124
+ declare function getThemeByKey(theme: Theme, themeKey: keyof Theme, keys: string[]): any;
125
125
  declare function colorVariable(str: string, varName: string): string;
126
126
  declare function hasParseableColor(color: string | undefined, theme: Theme): boolean;
127
127
  declare function resolveBreakpoints({ theme, generator }: Readonly<VariantContext<Theme>>, key?: 'breakpoint' | 'verticalBreakpoint'): {
@@ -138,11 +138,12 @@ declare function isSize(str: string): boolean;
138
138
  declare function transformXYZ(d: string, v: string, name: string): [string, string][];
139
139
  declare function camelize(str: string): string;
140
140
  declare function hyphenate(str: string): string;
141
- declare function compressCSS(css: string): string;
141
+ declare function compressCSS(css: string, isDev?: boolean): string;
142
142
  declare function defineProperty(property: string, options?: {
143
143
  syntax?: string;
144
144
  inherits?: boolean;
145
145
  initialValue?: unknown;
146
146
  }): string;
147
+ declare function detectThemeValue(value: string, theme: Theme): void;
147
148
 
148
- export { CONTROL_MINI_NO_NEGATIVE, PRESET_NAME, SpecialColorKey, camelize, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, directionMap, directionSize, getThemeColor, globalKeywords, h, handler, hasParseableColor, hyphenate, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, themeTracking, trackedTheme, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
149
+ export { CONTROL_MINI_NO_NEGATIVE, PRESET_NAME, SpecialColorKey, camelize, colorCSSGenerator, colorResolver, colorVariable, colorableShadows, compressCSS, cornerMap, cssMathFnRE, cssVarFnRE, defineProperty, detectThemeValue, directionMap, directionSize, getThemeByKey, globalKeywords, h, handler, hasParseableColor, hyphenate, insetMap, isCSSMathFn, isSize, makeGlobalStaticRules, numberResolver, parseColor, parseThemeColor, passThemeKey, positionMap, resolveBreakpoints, resolveVerticalBreakpoints, splitShorthand, themeTracking, trackedTheme, transformXYZ, handlers as valueHandlers, xyzArray, xyzMap };
package/dist/utils.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { C as CONTROL_MINI_NO_NEGATIVE, P as PRESET_NAME, S as SpecialColorKey, H as camelize, o as colorCSSGenerator, q as colorResolver, y as colorVariable, m as colorableShadows, J as compressCSS, c as cornerMap, j as cssMathFnRE, k as cssVarFnRE, K as defineProperty, d as directionMap, l as directionSize, w as getThemeColor, g as globalKeywords, b as h, h as handler, z as hasParseableColor, I as hyphenate, i as insetMap, E as isCSSMathFn, F as isSize, D as makeGlobalStaticRules, n as numberResolver, r as parseColor, u as parseThemeColor, p as passThemeKey, f as positionMap, A as resolveBreakpoints, B as resolveVerticalBreakpoints, s as splitShorthand, a as themeTracking, t as trackedTheme, G as transformXYZ, v as valueHandlers, e as xyzArray, x as xyzMap } from './shared/preset-wind4.47ZKbxbU.mjs';
1
+ export { C as CONTROL_MINI_NO_NEGATIVE, P as PRESET_NAME, S as SpecialColorKey, H as camelize, o as colorCSSGenerator, q as colorResolver, y as colorVariable, m as colorableShadows, J as compressCSS, c as cornerMap, j as cssMathFnRE, k as cssVarFnRE, K as defineProperty, L as detectThemeValue, d as directionMap, l as directionSize, w as getThemeByKey, g as globalKeywords, b as h, h as handler, z as hasParseableColor, I as hyphenate, i as insetMap, E as isCSSMathFn, F as isSize, D as makeGlobalStaticRules, n as numberResolver, r as parseColor, u as parseThemeColor, p as passThemeKey, f as positionMap, A as resolveBreakpoints, B as resolveVerticalBreakpoints, s as splitShorthand, a as themeTracking, t as trackedTheme, G as transformXYZ, v as valueHandlers, e as xyzArray, x as xyzMap } from './shared/preset-wind4.CkxnR6p3.mjs';
2
2
  export * from '@unocss/rule-utils';
3
3
  import '@unocss/core';
@@ -1,8 +1,8 @@
1
1
  import { VariantObject, Variant, VariantFunction } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.mjs';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.mjs';
3
3
  import { PresetWind4Options } from './index.mjs';
4
4
  export { variants } from './index.mjs';
5
- import './shared/preset-wind4.DIUjJahF.mjs';
5
+ import './shared/preset-wind4.D71xGC6i.mjs';
6
6
  import './shortcuts.mjs';
7
7
  import './shared/preset-wind4.BOe5kxIw.mjs';
8
8
 
@@ -1,8 +1,8 @@
1
1
  import { VariantObject, Variant, VariantFunction } from '@unocss/core';
2
- import { T as Theme } from './shared/preset-wind4.MiZzPO05.js';
2
+ import { T as Theme } from './shared/preset-wind4.BXbWGSRz.js';
3
3
  import { PresetWind4Options } from './index.js';
4
4
  export { variants } from './index.js';
5
- import './shared/preset-wind4.BJEl798_.js';
5
+ import './shared/preset-wind4.Ca5oWgxX.js';
6
6
  import './shortcuts.js';
7
7
  import './shared/preset-wind4.BOe5kxIw.js';
8
8
 
package/dist/variants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as calcMaxWidthBySize, D as placeholderModifier, v as variantAria, b as variantBreakpoints, d as variantChildren, h as variantColorsMediaOrClass, i as variantColorsScheme, e as variantCombinators, g as variantContainerQuery, q as variantContrasts, w as variantCssLayer, p as variantCustomMedia, j as variantDataAttribute, t as variantForcedColors, n as variantImportant, x as variantInternalLayer, m as variantLanguageDirections, r as variantMotions, C as variantNegative, s as variantOrientations, H as variantPartClasses, o as variantPrint, F as variantPseudoClassFunctions, E as variantPseudoClassesAndElements, y as variantScope, u as variantSelector, I as variantStartingStyle, B as variantStickyHover, J as variantSupports, f as variantSvgCombinators, a as variantTaggedAriaAttributes, k as variantTaggedDataAttributes, G as variantTaggedPseudoClasses, A as variantTheme, z as variantVariables, l as variants } from './shared/preset-wind4.fVfslvMN.mjs';
1
+ export { c as calcMaxWidthBySize, D as placeholderModifier, v as variantAria, b as variantBreakpoints, d as variantChildren, h as variantColorsMediaOrClass, i as variantColorsScheme, e as variantCombinators, g as variantContainerQuery, q as variantContrasts, w as variantCssLayer, p as variantCustomMedia, j as variantDataAttribute, t as variantForcedColors, n as variantImportant, x as variantInternalLayer, m as variantLanguageDirections, r as variantMotions, C as variantNegative, s as variantOrientations, H as variantPartClasses, o as variantPrint, F as variantPseudoClassFunctions, E as variantPseudoClassesAndElements, y as variantScope, u as variantSelector, I as variantStartingStyle, B as variantStickyHover, J as variantSupports, f as variantSvgCombinators, a as variantTaggedAriaAttributes, k as variantTaggedDataAttributes, G as variantTaggedPseudoClasses, A as variantTheme, z as variantVariables, l as variants } from './shared/preset-wind4.DXr6hHdY.mjs';
2
2
  import '@unocss/rule-utils';
3
- import './shared/preset-wind4.47ZKbxbU.mjs';
3
+ import './shared/preset-wind4.CkxnR6p3.mjs';
4
4
  import '@unocss/core';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-wind4",
3
3
  "type": "module",
4
- "version": "66.1.0-beta.6",
4
+ "version": "66.1.0-beta.7",
5
5
  "description": "Tailwind 4 compact preset for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -65,9 +65,9 @@
65
65
  "dist"
66
66
  ],
67
67
  "dependencies": {
68
- "@unocss/core": "66.1.0-beta.6",
69
- "@unocss/extractor-arbitrary-variants": "66.1.0-beta.6",
70
- "@unocss/rule-utils": "66.1.0-beta.6"
68
+ "@unocss/core": "66.1.0-beta.7",
69
+ "@unocss/extractor-arbitrary-variants": "66.1.0-beta.7",
70
+ "@unocss/rule-utils": "66.1.0-beta.7"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "unbuild",