@udixio/theme 2.1.11 → 2.1.13

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/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## 2.1.13 (2026-02-02)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **theme:** remove debug `console.log` from `udixio ([e02f6ce](https://github.com/Udixio/UI/commit/e02f6ce))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Joël VIGREUX
10
+
11
+ ## 2.1.12 (2026-01-30)
12
+
13
+ ### 🚀 Features
14
+
15
+ - **theme:** improve tone logic and adjust background calculations ([6eda481](https://github.com/Udixio/UI/commit/6eda481))
16
+ - **theme:** add `createMinContrastToneAdjuster` util for dynamic tone adjustments ([d963806](https://github.com/Udixio/UI/commit/d963806))
17
+
18
+ ### ❤️ Thank You
19
+
20
+ - Joël VIGREUX
21
+
1
22
  ## 2.1.11 (2026-01-18)
2
23
 
3
24
  This was a version bump only for @udixio/theme to align it with other projects, there were no code changes.
package/dist/bin.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  const commander = require("commander");
3
3
  const chokidar = require("chokidar");
4
4
  const chalk = require("chalk");
5
- const loadFromPath = require("./load-from-path-BCkiZx6_.cjs");
5
+ const loadFromPath = require("./load-from-path-DDQroKk-.cjs");
6
6
  const program = new commander.Command();
7
7
  async function runOnce(configPath) {
8
8
  try {
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Command } from "commander";
2
2
  import chokidar from "chokidar";
3
3
  import chalk from "chalk";
4
- import { l as loadFromPath } from "./load-from-path-C4axFso4.js";
4
+ import { l as loadFromPath } from "./load-from-path-B7BI6LZa.js";
5
5
  const program = new Command();
6
6
  async function runOnce(configPath) {
7
7
  try {
package/dist/browser.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const loader = require("./loader-1Pp2rd0P.cjs");
4
- const font_plugin = require("./font.plugin-B0SKfA9r.cjs");
3
+ const loader = require("./loader-CgJ2JY88.cjs");
4
+ const font_plugin = require("./font.plugin-B9NdGRxC.cjs");
5
5
  exports.API = loader.API;
6
6
  exports.AppContainer = loader.AppContainer;
7
7
  exports.AppModule = loader.AppModule;
package/dist/browser.js CHANGED
@@ -1,44 +1,44 @@
1
- import { A, a, b, h, i, C, j, k, e, f, o, n, q, D, P, r, s, v, u, V, z, c, d, m, F, g, w, x, l, p, G, B, t, y, E } from "./loader--tJzL1CC.js";
2
- import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BReTQTWQ.js";
1
+ import { A, a, b, C, c, d, e, f, g, h, i, j, k, D, P, l, m, n, o, V, p, q, r, s, t, u, v, w, x, y, z, B, E, F, G } from "./loader-Cy_VzOHt.js";
2
+ import { F as F2, a as a2, P as P2, b as b2, d as d2 } from "./font.plugin-b3GDzC1A.js";
3
3
  export {
4
4
  A as API,
5
5
  a as AppContainer,
6
6
  b as AppModule,
7
- h as Color,
8
- i as ColorAlias,
9
- C as ColorApi,
10
- j as ColorFromHex,
11
- k as ColorFromPalette,
12
- e as ColorManager,
13
- f as ColorModule,
14
- o as Context,
15
- n as ContextModule,
16
- q as ContrastCurve,
7
+ C as Color,
8
+ c as ColorAlias,
9
+ d as ColorApi,
10
+ e as ColorFromHex,
11
+ f as ColorFromPalette,
12
+ g as ColorManager,
13
+ h as ColorModule,
14
+ i as Context,
15
+ j as ContextModule,
16
+ k as ContrastCurve,
17
17
  D as DynamicColor,
18
18
  F2 as FontFamily,
19
- b2 as FontPlugin,
19
+ a2 as FontPlugin,
20
20
  P as Palette,
21
- r as PaletteApi,
22
- s as PaletteModule,
21
+ l as PaletteApi,
22
+ m as PaletteModule,
23
23
  P2 as PluginAbstract,
24
- v as PluginApi,
25
- a2 as PluginImplAbstract,
26
- u as PluginModule,
24
+ n as PluginApi,
25
+ b2 as PluginImplAbstract,
26
+ o as PluginModule,
27
27
  V as Variant,
28
- z as Variants,
29
- c as bootstrap,
30
- d as capitalizeFirstLetter,
31
- m as defaultColors,
28
+ p as Variants,
29
+ q as bootstrap,
30
+ r as capitalizeFirstLetter,
31
+ s as defaultColors,
32
32
  d2 as defineConfig,
33
- F as expressiveVariant,
34
- g as getInitialToneFromBackground,
35
- w as getPiecewiseHue,
36
- x as getRotatedHue,
37
- l as highestSurface,
38
- p as loader,
39
- G as neutralVariant,
33
+ t as expressiveVariant,
34
+ u as getInitialToneFromBackground,
35
+ v as getPiecewiseHue,
36
+ w as getRotatedHue,
37
+ x as highestSurface,
38
+ y as loader,
39
+ z as neutralVariant,
40
40
  B as tonalSpotVariant,
41
- t as toneDeltaPair,
42
- y as variant,
43
- E as vibrantVariant
41
+ E as toneDeltaPair,
42
+ F as variant,
43
+ G as vibrantVariant
44
44
  };
@@ -2,7 +2,7 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- require("./loader-1Pp2rd0P.cjs");
5
+ require("./loader-CgJ2JY88.cjs");
6
6
  class PluginAbstract {
7
7
  constructor(options) {
8
8
  __publicField(this, "options");
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import "./loader--tJzL1CC.js";
4
+ import "./loader-Cy_VzOHt.js";
5
5
  class PluginAbstract {
6
6
  constructor(options) {
7
7
  __publicField(this, "options");
@@ -222,7 +222,7 @@ class FontPluginImpl extends PluginImplAbstract {
222
222
  export {
223
223
  FontFamily as F,
224
224
  PluginAbstract as P,
225
- PluginImplAbstract as a,
226
- FontPlugin as b,
225
+ FontPlugin as a,
226
+ PluginImplAbstract as b,
227
227
  defineConfig as d
228
228
  };
@@ -1,4 +1,4 @@
1
- import { p as loader } from "./loader--tJzL1CC.js";
1
+ import { y as loader } from "./loader-Cy_VzOHt.js";
2
2
  import * as fs from "node:fs";
3
3
  async function resolveConfig(configPath = "./theme.config") {
4
4
  const { createJiti } = await import("jiti");
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
22
  mod
23
23
  ));
24
- const loader = require("./loader-1Pp2rd0P.cjs");
24
+ const loader = require("./loader-CgJ2JY88.cjs");
25
25
  const fs = require("node:fs");
26
26
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
27
27
  function _interopNamespaceDefault(e) {
@@ -44,7 +44,7 @@ const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
44
44
  async function resolveConfig(configPath = "./theme.config") {
45
45
  const { createJiti } = await import("jiti");
46
46
  const { resolve } = await import("pathe");
47
- const jiti = createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("load-from-path-BCkiZx6_.cjs", document.baseURI).href, {
47
+ const jiti = createJiti(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("load-from-path-DDQroKk-.cjs", document.baseURI).href, {
48
48
  debug: process.env.NODE_ENV === "development",
49
49
  fsCache: true,
50
50
  interopDefault: true
@@ -3090,10 +3090,26 @@ const surfaceContainerTone = (layer, api) => {
3090
3090
  };
3091
3091
  const highestSurface = (context, colorService) => {
3092
3092
  if (colorService instanceof ColorApi) {
3093
- return colorService.get("surface");
3093
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3094
3094
  } else {
3095
- return colorService.get("surface");
3095
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3096
+ }
3097
+ };
3098
+ const createMinContrastToneAdjuster = (ctx, colors, options) => {
3099
+ const { selfKey, referenceKey, minContrast = 3 } = options;
3100
+ const referenceTone = referenceKey ? colors.get(referenceKey).getTone() : highestSurface(ctx, colors).getTone();
3101
+ const baseTone = colors.get(selfKey).options.tone;
3102
+ let selfTone = baseTone;
3103
+ if (materialColorUtilities.Contrast.ratioOfTones(referenceTone, selfTone) < minContrast) {
3104
+ const ratio = calculateToneAdjustmentPercentage(
3105
+ referenceTone,
3106
+ selfTone,
3107
+ minContrast
3108
+ );
3109
+ const inverseT = inverseTone(baseTone);
3110
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
3096
3111
  }
3112
+ return selfTone;
3097
3113
  };
3098
3114
  const udixioVariant = variant({
3099
3115
  name: "udixio",
@@ -3153,19 +3169,20 @@ const udixioVariant = variant({
3153
3169
  [colorKey]: {
3154
3170
  palette: () => palettes.get(colorKey),
3155
3171
  tone: () => {
3156
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3172
+ return colors2.get("primary").getTone();
3157
3173
  },
3158
- isBackground: true,
3159
- background: () => highestSurface(ctx, colors2),
3160
- contrastCurve: () => getCurve(4.5),
3161
- adjustTone: () => toneDeltaPair(
3162
- colors2.get(colorContainerKey),
3163
- colors2.get(colorKey),
3164
- 5,
3165
- "relative_lighter",
3166
- true,
3167
- "farther"
3168
- )
3174
+ isBackground: true
3175
+ // background: () => highestSurface(ctx, colors),
3176
+ // contrastCurve: () => getCurve(4.5),
3177
+ // adjustTone: () =>
3178
+ // toneDeltaPair(
3179
+ // colors.get(colorContainerKey),
3180
+ // colors.get(colorKey),
3181
+ // 5,
3182
+ // 'relative_lighter',
3183
+ // true,
3184
+ // 'farther',
3185
+ // ),
3169
3186
  },
3170
3187
  // [colorDimKey]: {
3171
3188
  // palette: () => palettes.get(colorKey),
@@ -3207,7 +3224,14 @@ const udixioVariant = variant({
3207
3224
  },
3208
3225
  isBackground: true,
3209
3226
  background: () => highestSurface(ctx, colors2),
3210
- adjustTone: () => void 0,
3227
+ adjustTone: () => toneDeltaPair(
3228
+ colors2.get(colorKey),
3229
+ colors2.get(colorContainerKey),
3230
+ 15,
3231
+ "relative_darker",
3232
+ true,
3233
+ "farther"
3234
+ ),
3211
3235
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3212
3236
  },
3213
3237
  [onColorContainerKey]: {
@@ -3403,19 +3427,9 @@ const udixioVariant = variant({
3403
3427
  background: () => highestSurface(ctx, colors),
3404
3428
  contrastCurve: () => getCurve(4.5),
3405
3429
  adjustTone: () => () => {
3406
- const surfaceTone = colors.get("surface").getTone();
3407
- const primaryTone = colors.get("primary").options.tone;
3408
- let selfTone = primaryTone;
3409
- if (materialColorUtilities.Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
3410
- const ratio = calculateToneAdjustmentPercentage(
3411
- surfaceTone,
3412
- selfTone,
3413
- 3
3414
- );
3415
- const inverseT = inverseTone(primaryTone);
3416
- selfTone = selfTone + (inverseT - selfTone) * ratio;
3417
- }
3418
- return selfTone;
3430
+ return createMinContrastToneAdjuster(ctx, colors, {
3431
+ selfKey: "primary"
3432
+ });
3419
3433
  }
3420
3434
  },
3421
3435
  // primaryDim: {
@@ -3523,19 +3537,20 @@ const udixioVariant = variant({
3523
3537
  secondary: {
3524
3538
  palette: () => palettes.get("secondary"),
3525
3539
  tone: () => {
3526
- return ctx.isDark ? 80 : tMaxC(palettes.get("secondary"));
3540
+ return colors.get("primary").getTone();
3527
3541
  },
3528
- isBackground: true,
3529
- background: () => highestSurface(ctx, colors),
3530
- contrastCurve: () => getCurve(4.5),
3531
- adjustTone: () => toneDeltaPair(
3532
- getColor("secondaryContainer"),
3533
- getColor("secondary"),
3534
- 5,
3535
- "relative_lighter",
3536
- true,
3537
- "farther"
3538
- )
3542
+ isBackground: true
3543
+ // background: () => highestSurface(ctx, colors),
3544
+ // contrastCurve: () => getCurve(4.5),
3545
+ // adjustTone: () =>
3546
+ // toneDeltaPair(
3547
+ // getColor('secondaryContainer'),
3548
+ // getColor('secondary'),
3549
+ // 5,
3550
+ // 'relative_lighter',
3551
+ // true,
3552
+ // 'farther',
3553
+ // ),
3539
3554
  },
3540
3555
  // secondaryDim: {
3541
3556
  // palette: () => palettes.get('secondary'),
@@ -3571,7 +3586,14 @@ const udixioVariant = variant({
3571
3586
  },
3572
3587
  isBackground: true,
3573
3588
  background: () => highestSurface(ctx, colors),
3574
- adjustTone: () => void 0,
3589
+ adjustTone: () => toneDeltaPair(
3590
+ colors.get("secondary"),
3591
+ colors.get("secondaryContainer"),
3592
+ 15,
3593
+ "relative_darker",
3594
+ true,
3595
+ "farther"
3596
+ ),
3575
3597
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3576
3598
  },
3577
3599
  onSecondaryContainer: {
@@ -3627,19 +3649,21 @@ const udixioVariant = variant({
3627
3649
  tertiary: {
3628
3650
  palette: () => palettes.get("tertiary"),
3629
3651
  tone: () => {
3630
- return ctx.isDark ? tMaxC(palettes.get("tertiary"), 0, 98) : tMaxC(palettes.get("tertiary"));
3652
+ const tone = colors.get("primary").getTone();
3653
+ return Math.max(20, Math.min(80, tone));
3631
3654
  },
3632
- isBackground: true,
3633
- background: () => highestSurface(ctx, colors),
3634
- contrastCurve: () => getCurve(4.5),
3635
- adjustTone: () => toneDeltaPair(
3636
- getColor("tertiaryContainer"),
3637
- getColor("tertiary"),
3638
- 5,
3639
- "relative_lighter",
3640
- true,
3641
- "farther"
3642
- )
3655
+ isBackground: true
3656
+ // background: () => highestSurface(ctx, colors),
3657
+ // contrastCurve: () => getCurve(4.5),
3658
+ // adjustTone: () =>
3659
+ // toneDeltaPair(
3660
+ // getColor('tertiaryContainer'),
3661
+ // getColor('tertiary'),
3662
+ // 5,
3663
+ // 'relative_lighter',
3664
+ // true,
3665
+ // 'farther',
3666
+ // ),
3643
3667
  },
3644
3668
  // tertiaryDim: {
3645
3669
  // palette: () => palettes.get('tertiary'),
@@ -3675,7 +3699,14 @@ const udixioVariant = variant({
3675
3699
  },
3676
3700
  isBackground: true,
3677
3701
  background: () => highestSurface(ctx, colors),
3678
- adjustTone: () => void 0,
3702
+ adjustTone: () => toneDeltaPair(
3703
+ colors.get("tertiary"),
3704
+ colors.get("tertiaryContainer"),
3705
+ 15,
3706
+ "relative_darker",
3707
+ true,
3708
+ "farther"
3709
+ ),
3679
3710
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3680
3711
  },
3681
3712
  onTertiaryContainer: {
@@ -3089,10 +3089,26 @@ const surfaceContainerTone = (layer, api) => {
3089
3089
  };
3090
3090
  const highestSurface = (context, colorService) => {
3091
3091
  if (colorService instanceof ColorApi) {
3092
- return colorService.get("surface");
3092
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3093
3093
  } else {
3094
- return colorService.get("surface");
3094
+ return context.isDark ? colorService.get("surfaceBright") : colorService.get("surfaceDim");
3095
+ }
3096
+ };
3097
+ const createMinContrastToneAdjuster = (ctx, colors, options) => {
3098
+ const { selfKey, referenceKey, minContrast = 3 } = options;
3099
+ const referenceTone = referenceKey ? colors.get(referenceKey).getTone() : highestSurface(ctx, colors).getTone();
3100
+ const baseTone = colors.get(selfKey).options.tone;
3101
+ let selfTone = baseTone;
3102
+ if (Contrast.ratioOfTones(referenceTone, selfTone) < minContrast) {
3103
+ const ratio = calculateToneAdjustmentPercentage(
3104
+ referenceTone,
3105
+ selfTone,
3106
+ minContrast
3107
+ );
3108
+ const inverseT = inverseTone(baseTone);
3109
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
3095
3110
  }
3111
+ return selfTone;
3096
3112
  };
3097
3113
  const udixioVariant = variant({
3098
3114
  name: "udixio",
@@ -3152,19 +3168,20 @@ const udixioVariant = variant({
3152
3168
  [colorKey]: {
3153
3169
  palette: () => palettes.get(colorKey),
3154
3170
  tone: () => {
3155
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
3171
+ return colors2.get("primary").getTone();
3156
3172
  },
3157
- isBackground: true,
3158
- background: () => highestSurface(ctx, colors2),
3159
- contrastCurve: () => getCurve(4.5),
3160
- adjustTone: () => toneDeltaPair(
3161
- colors2.get(colorContainerKey),
3162
- colors2.get(colorKey),
3163
- 5,
3164
- "relative_lighter",
3165
- true,
3166
- "farther"
3167
- )
3173
+ isBackground: true
3174
+ // background: () => highestSurface(ctx, colors),
3175
+ // contrastCurve: () => getCurve(4.5),
3176
+ // adjustTone: () =>
3177
+ // toneDeltaPair(
3178
+ // colors.get(colorContainerKey),
3179
+ // colors.get(colorKey),
3180
+ // 5,
3181
+ // 'relative_lighter',
3182
+ // true,
3183
+ // 'farther',
3184
+ // ),
3168
3185
  },
3169
3186
  // [colorDimKey]: {
3170
3187
  // palette: () => palettes.get(colorKey),
@@ -3206,7 +3223,14 @@ const udixioVariant = variant({
3206
3223
  },
3207
3224
  isBackground: true,
3208
3225
  background: () => highestSurface(ctx, colors2),
3209
- adjustTone: () => void 0,
3226
+ adjustTone: () => toneDeltaPair(
3227
+ colors2.get(colorKey),
3228
+ colors2.get(colorContainerKey),
3229
+ 15,
3230
+ "relative_darker",
3231
+ true,
3232
+ "farther"
3233
+ ),
3210
3234
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3211
3235
  },
3212
3236
  [onColorContainerKey]: {
@@ -3402,19 +3426,9 @@ const udixioVariant = variant({
3402
3426
  background: () => highestSurface(ctx, colors),
3403
3427
  contrastCurve: () => getCurve(4.5),
3404
3428
  adjustTone: () => () => {
3405
- const surfaceTone = colors.get("surface").getTone();
3406
- const primaryTone = colors.get("primary").options.tone;
3407
- let selfTone = primaryTone;
3408
- if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
3409
- const ratio = calculateToneAdjustmentPercentage(
3410
- surfaceTone,
3411
- selfTone,
3412
- 3
3413
- );
3414
- const inverseT = inverseTone(primaryTone);
3415
- selfTone = selfTone + (inverseT - selfTone) * ratio;
3416
- }
3417
- return selfTone;
3429
+ return createMinContrastToneAdjuster(ctx, colors, {
3430
+ selfKey: "primary"
3431
+ });
3418
3432
  }
3419
3433
  },
3420
3434
  // primaryDim: {
@@ -3522,19 +3536,20 @@ const udixioVariant = variant({
3522
3536
  secondary: {
3523
3537
  palette: () => palettes.get("secondary"),
3524
3538
  tone: () => {
3525
- return ctx.isDark ? 80 : tMaxC(palettes.get("secondary"));
3539
+ return colors.get("primary").getTone();
3526
3540
  },
3527
- isBackground: true,
3528
- background: () => highestSurface(ctx, colors),
3529
- contrastCurve: () => getCurve(4.5),
3530
- adjustTone: () => toneDeltaPair(
3531
- getColor("secondaryContainer"),
3532
- getColor("secondary"),
3533
- 5,
3534
- "relative_lighter",
3535
- true,
3536
- "farther"
3537
- )
3541
+ isBackground: true
3542
+ // background: () => highestSurface(ctx, colors),
3543
+ // contrastCurve: () => getCurve(4.5),
3544
+ // adjustTone: () =>
3545
+ // toneDeltaPair(
3546
+ // getColor('secondaryContainer'),
3547
+ // getColor('secondary'),
3548
+ // 5,
3549
+ // 'relative_lighter',
3550
+ // true,
3551
+ // 'farther',
3552
+ // ),
3538
3553
  },
3539
3554
  // secondaryDim: {
3540
3555
  // palette: () => palettes.get('secondary'),
@@ -3570,7 +3585,14 @@ const udixioVariant = variant({
3570
3585
  },
3571
3586
  isBackground: true,
3572
3587
  background: () => highestSurface(ctx, colors),
3573
- adjustTone: () => void 0,
3588
+ adjustTone: () => toneDeltaPair(
3589
+ colors.get("secondary"),
3590
+ colors.get("secondaryContainer"),
3591
+ 15,
3592
+ "relative_darker",
3593
+ true,
3594
+ "farther"
3595
+ ),
3574
3596
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3575
3597
  },
3576
3598
  onSecondaryContainer: {
@@ -3626,19 +3648,21 @@ const udixioVariant = variant({
3626
3648
  tertiary: {
3627
3649
  palette: () => palettes.get("tertiary"),
3628
3650
  tone: () => {
3629
- return ctx.isDark ? tMaxC(palettes.get("tertiary"), 0, 98) : tMaxC(palettes.get("tertiary"));
3651
+ const tone = colors.get("primary").getTone();
3652
+ return Math.max(20, Math.min(80, tone));
3630
3653
  },
3631
- isBackground: true,
3632
- background: () => highestSurface(ctx, colors),
3633
- contrastCurve: () => getCurve(4.5),
3634
- adjustTone: () => toneDeltaPair(
3635
- getColor("tertiaryContainer"),
3636
- getColor("tertiary"),
3637
- 5,
3638
- "relative_lighter",
3639
- true,
3640
- "farther"
3641
- )
3654
+ isBackground: true
3655
+ // background: () => highestSurface(ctx, colors),
3656
+ // contrastCurve: () => getCurve(4.5),
3657
+ // adjustTone: () =>
3658
+ // toneDeltaPair(
3659
+ // getColor('tertiaryContainer'),
3660
+ // getColor('tertiary'),
3661
+ // 5,
3662
+ // 'relative_lighter',
3663
+ // true,
3664
+ // 'farther',
3665
+ // ),
3642
3666
  },
3643
3667
  // tertiaryDim: {
3644
3668
  // palette: () => palettes.get('tertiary'),
@@ -3674,7 +3698,14 @@ const udixioVariant = variant({
3674
3698
  },
3675
3699
  isBackground: true,
3676
3700
  background: () => highestSurface(ctx, colors),
3677
- adjustTone: () => void 0,
3701
+ adjustTone: () => toneDeltaPair(
3702
+ colors.get("tertiary"),
3703
+ colors.get("tertiaryContainer"),
3704
+ 15,
3705
+ "relative_darker",
3706
+ true,
3707
+ "farther"
3708
+ ),
3678
3709
  contrastCurve: () => ctx.contrastLevel > 0 ? getCurve(1.5) : void 0
3679
3710
  },
3680
3711
  onTertiaryContainer: {
@@ -3845,37 +3876,37 @@ const loader = async (config, load = true) => {
3845
3876
  export {
3846
3877
  API as A,
3847
3878
  tonalSpotVariant as B,
3848
- ColorApi as C,
3879
+ Color as C,
3849
3880
  DynamicColor as D,
3850
- vibrantVariant as E,
3851
- expressiveVariant as F,
3852
- neutralVariant as G,
3881
+ toneDeltaPair as E,
3882
+ variant as F,
3883
+ vibrantVariant as G,
3853
3884
  Palette as P,
3854
3885
  Variant as V,
3855
3886
  AppContainer as a,
3856
3887
  AppModule as b,
3857
- bootstrap as c,
3858
- capitalizeFirstLetter as d,
3859
- ColorManager as e,
3860
- ColorModule as f,
3861
- getInitialToneFromBackground as g,
3862
- Color as h,
3863
- ColorAlias as i,
3864
- ColorFromHex as j,
3865
- ColorFromPalette as k,
3866
- highestSurface$1 as l,
3867
- defaultColors as m,
3868
- ContextModule as n,
3869
- Context as o,
3870
- loader as p,
3871
- ContrastCurve as q,
3872
- PaletteApi as r,
3873
- PaletteModule as s,
3874
- toneDeltaPair as t,
3875
- PluginModule as u,
3876
- PluginApi as v,
3877
- getPiecewiseHue as w,
3878
- getRotatedHue as x,
3879
- variant as y,
3880
- Variants as z
3888
+ ColorAlias as c,
3889
+ ColorApi as d,
3890
+ ColorFromHex as e,
3891
+ ColorFromPalette as f,
3892
+ ColorManager as g,
3893
+ ColorModule as h,
3894
+ Context as i,
3895
+ ContextModule as j,
3896
+ ContrastCurve as k,
3897
+ PaletteApi as l,
3898
+ PaletteModule as m,
3899
+ PluginApi as n,
3900
+ PluginModule as o,
3901
+ Variants as p,
3902
+ bootstrap as q,
3903
+ capitalizeFirstLetter as r,
3904
+ defaultColors as s,
3905
+ expressiveVariant as t,
3906
+ getInitialToneFromBackground as u,
3907
+ getPiecewiseHue as v,
3908
+ getRotatedHue as w,
3909
+ highestSurface$1 as x,
3910
+ loader as y,
3911
+ neutralVariant as z
3881
3912
  };
package/dist/node.cjs CHANGED
@@ -22,9 +22,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const loader = require("./loader-1Pp2rd0P.cjs");
26
- const font_plugin = require("./font.plugin-B0SKfA9r.cjs");
27
- const loadFromPath = require("./load-from-path-BCkiZx6_.cjs");
25
+ const loader = require("./loader-CgJ2JY88.cjs");
26
+ const font_plugin = require("./font.plugin-B9NdGRxC.cjs");
27
+ const loadFromPath = require("./load-from-path-DDQroKk-.cjs");
28
28
  let unpluginInstance = null;
29
29
  const createUnpluginTheme = async () => {
30
30
  if (unpluginInstance) {
package/dist/node.js CHANGED
@@ -1,7 +1,7 @@
1
- import { A, a, b, h, i, C, j, k, e, f, o, n, q, D, P, r, s, v, u, V, z, c, d, m, F, g, w, x, l, p, G, B, t, y, E } from "./loader--tJzL1CC.js";
2
- import { F as F2, b as b2, P as P2, a as a2, d as d2 } from "./font.plugin-BReTQTWQ.js";
3
- import { l as loadFromPath } from "./load-from-path-C4axFso4.js";
4
- import { r as r2 } from "./load-from-path-C4axFso4.js";
1
+ import { A, a, b, C, c, d, e, f, g, h, i, j, k, D, P, l, m, n, o, V, p, q, r, s, t, u, v, w, x, y, z, B, E, F, G } from "./loader-Cy_VzOHt.js";
2
+ import { F as F2, a as a2, P as P2, b as b2, d as d2 } from "./font.plugin-b3GDzC1A.js";
3
+ import { l as loadFromPath } from "./load-from-path-B7BI6LZa.js";
4
+ import { r as r2 } from "./load-from-path-B7BI6LZa.js";
5
5
  let unpluginInstance = null;
6
6
  const createUnpluginTheme = async () => {
7
7
  if (unpluginInstance) {
@@ -128,48 +128,48 @@ export {
128
128
  A as API,
129
129
  a as AppContainer,
130
130
  b as AppModule,
131
- h as Color,
132
- i as ColorAlias,
133
- C as ColorApi,
134
- j as ColorFromHex,
135
- k as ColorFromPalette,
136
- e as ColorManager,
137
- f as ColorModule,
138
- o as Context,
139
- n as ContextModule,
140
- q as ContrastCurve,
131
+ C as Color,
132
+ c as ColorAlias,
133
+ d as ColorApi,
134
+ e as ColorFromHex,
135
+ f as ColorFromPalette,
136
+ g as ColorManager,
137
+ h as ColorModule,
138
+ i as Context,
139
+ j as ContextModule,
140
+ k as ContrastCurve,
141
141
  D as DynamicColor,
142
142
  F2 as FontFamily,
143
- b2 as FontPlugin,
143
+ a2 as FontPlugin,
144
144
  P as Palette,
145
- r as PaletteApi,
146
- s as PaletteModule,
145
+ l as PaletteApi,
146
+ m as PaletteModule,
147
147
  P2 as PluginAbstract,
148
- v as PluginApi,
149
- a2 as PluginImplAbstract,
150
- u as PluginModule,
148
+ n as PluginApi,
149
+ b2 as PluginImplAbstract,
150
+ o as PluginModule,
151
151
  V as Variant,
152
- z as Variants,
153
- c as bootstrap,
154
- d as capitalizeFirstLetter,
155
- m as defaultColors,
152
+ p as Variants,
153
+ q as bootstrap,
154
+ r as capitalizeFirstLetter,
155
+ s as defaultColors,
156
156
  d2 as defineConfig,
157
157
  esbuildPlugin,
158
- F as expressiveVariant,
159
- g as getInitialToneFromBackground,
160
- w as getPiecewiseHue,
161
- x as getRotatedHue,
162
- l as highestSurface,
158
+ t as expressiveVariant,
159
+ u as getInitialToneFromBackground,
160
+ v as getPiecewiseHue,
161
+ w as getRotatedHue,
162
+ x as highestSurface,
163
163
  loadFromPath,
164
- p as loader,
165
- G as neutralVariant,
164
+ y as loader,
165
+ z as neutralVariant,
166
166
  r2 as resolveConfig,
167
167
  rollupPlugin,
168
168
  B as tonalSpotVariant,
169
- t as toneDeltaPair,
169
+ E as toneDeltaPair,
170
170
  unpluginUdixioTheme,
171
- y as variant,
172
- E as vibrantVariant,
171
+ F as variant,
172
+ G as vibrantVariant,
173
173
  vitePlugin,
174
174
  webpackPlugin
175
175
  };
@@ -1,3 +1,11 @@
1
1
  import { Variant } from '../variant';
2
+ import { DynamicColorKey } from '../../color/color.utils';
3
+ import { ColorApi, ColorManager } from '../../color';
4
+ import { Context } from '../../context';
5
+ export declare const createMinContrastToneAdjuster: (ctx: Context, colors: ColorManager | ColorApi, options: {
6
+ selfKey: DynamicColorKey;
7
+ referenceKey?: DynamicColorKey;
8
+ minContrast?: number;
9
+ }) => number;
2
10
  export declare const udixioVariant: Variant;
3
11
  //# sourceMappingURL=udixio.variant.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"udixio.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/udixio.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAuD9E,eAAO,MAAM,aAAa,EAAE,OAovB1B,CAAC"}
1
+ {"version":3,"file":"udixio.variant.d.ts","sourceRoot":"","sources":["../../../src/variant/variants/udixio.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAEL,eAAe,EAIhB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAIL,QAAQ,EAER,YAAY,EAEb,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAyCxC,eAAO,MAAM,6BAA6B,GACxC,KAAK,OAAO,EACZ,QAAQ,YAAY,GAAG,QAAQ,EAC/B,SAAS;IACP,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,WAuBF,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OAiwB1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udixio/theme",
3
- "version": "2.1.11",
3
+ "version": "2.1.13",
4
4
  "type": "module",
5
5
  "main": "./dist/node.js",
6
6
  "module": "./dist/node.js",
@@ -47,12 +47,50 @@ const highestSurface = (
47
47
  colorService: ColorManager | ColorApi,
48
48
  ): Color => {
49
49
  if (colorService instanceof ColorApi) {
50
- return colorService.get('surface');
50
+ return context.isDark
51
+ ? colorService.get('surfaceBright')
52
+ : colorService.get('surfaceDim');
51
53
  } else {
52
- return colorService.get('surface');
54
+ return context.isDark
55
+ ? colorService.get('surfaceBright')
56
+ : colorService.get('surfaceDim');
53
57
  }
54
58
  };
55
59
 
60
+ // Permet de réutiliser la logique "si contraste < minContrast, pousser le tone vers l'inverse"
61
+ // pour n'importe quelle couleur (pas seulement `primary`), et avec une référence configurable.
62
+ export const createMinContrastToneAdjuster = (
63
+ ctx: Context,
64
+ colors: ColorManager | ColorApi,
65
+ options: {
66
+ selfKey: DynamicColorKey;
67
+ referenceKey?: DynamicColorKey; // par défaut: la surface la plus "haute"
68
+ minContrast?: number; // par défaut: 3
69
+ },
70
+ ) => {
71
+ const { selfKey, referenceKey, minContrast = 3 } = options;
72
+
73
+ const referenceTone = referenceKey
74
+ ? colors.get(referenceKey).getTone()
75
+ : highestSurface(ctx, colors).getTone();
76
+
77
+ // On part du tone "source" défini dans les options (comme ton code `primary`).
78
+ const baseTone = (colors.get(selfKey) as ColorFromPalette).options.tone;
79
+
80
+ let selfTone = baseTone;
81
+ if (Contrast.ratioOfTones(referenceTone, selfTone) < minContrast) {
82
+ const ratio = calculateToneAdjustmentPercentage(
83
+ referenceTone,
84
+ selfTone,
85
+ minContrast,
86
+ );
87
+ const inverseT = inverseTone(baseTone);
88
+ selfTone = selfTone + (inverseT - selfTone) * ratio;
89
+ }
90
+
91
+ return selfTone;
92
+ };
93
+
56
94
  export const udixioVariant: Variant = variant({
57
95
  name: 'udixio',
58
96
  palettes: {
@@ -124,20 +162,21 @@ export const udixioVariant: Variant = variant({
124
162
  [colorKey]: {
125
163
  palette: () => palettes.get(colorKey),
126
164
  tone: () => {
127
- return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
165
+ return colors.get('primary').getTone();
166
+ // return ctx.isDark ? 80 : tMaxC(palettes.get(colorKey));
128
167
  },
129
168
  isBackground: true,
130
- background: () => highestSurface(ctx, colors),
131
- contrastCurve: () => getCurve(4.5),
132
- adjustTone: () =>
133
- toneDeltaPair(
134
- colors.get(colorContainerKey),
135
- colors.get(colorKey),
136
- 5,
137
- 'relative_lighter',
138
- true,
139
- 'farther',
140
- ),
169
+ // background: () => highestSurface(ctx, colors),
170
+ // contrastCurve: () => getCurve(4.5),
171
+ // adjustTone: () =>
172
+ // toneDeltaPair(
173
+ // colors.get(colorContainerKey),
174
+ // colors.get(colorKey),
175
+ // 5,
176
+ // 'relative_lighter',
177
+ // true,
178
+ // 'farther',
179
+ // ),
141
180
  },
142
181
  // [colorDimKey]: {
143
182
  // palette: () => palettes.get(colorKey),
@@ -181,7 +220,15 @@ export const udixioVariant: Variant = variant({
181
220
  },
182
221
  isBackground: true,
183
222
  background: () => highestSurface(ctx, colors),
184
- adjustTone: () => undefined,
223
+ adjustTone: () =>
224
+ toneDeltaPair(
225
+ colors.get(colorKey),
226
+ colors.get(colorContainerKey),
227
+ 15,
228
+ 'relative_darker',
229
+ true,
230
+ 'farther',
231
+ ),
185
232
  contrastCurve: () =>
186
233
  ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
187
234
  },
@@ -380,20 +427,9 @@ export const udixioVariant: Variant = variant({
380
427
  background: () => highestSurface(ctx, colors),
381
428
  contrastCurve: () => getCurve(4.5),
382
429
  adjustTone: () => () => {
383
- const surfaceTone = colors.get('surface').getTone();
384
- const primaryTone = (colors.get('primary') as ColorFromPalette)
385
- .options.tone;
386
- let selfTone = primaryTone;
387
- if (Contrast.ratioOfTones(surfaceTone, selfTone) < 3) {
388
- const ratio = calculateToneAdjustmentPercentage(
389
- surfaceTone,
390
- selfTone,
391
- 3,
392
- );
393
- const inverseT = inverseTone(primaryTone);
394
- selfTone = selfTone + (inverseT - selfTone) * ratio;
395
- }
396
- return selfTone;
430
+ return createMinContrastToneAdjuster(ctx, colors, {
431
+ selfKey: 'primary',
432
+ });
397
433
  },
398
434
  },
399
435
  // primaryDim: {
@@ -510,20 +546,20 @@ export const udixioVariant: Variant = variant({
510
546
  secondary: {
511
547
  palette: () => palettes.get('secondary'),
512
548
  tone: () => {
513
- return ctx.isDark ? 80 : tMaxC(palettes.get('secondary'));
549
+ return colors.get('primary').getTone();
514
550
  },
515
551
  isBackground: true,
516
- background: () => highestSurface(ctx, colors),
517
- contrastCurve: () => getCurve(4.5),
518
- adjustTone: () =>
519
- toneDeltaPair(
520
- getColor('secondaryContainer'),
521
- getColor('secondary'),
522
- 5,
523
- 'relative_lighter',
524
- true,
525
- 'farther',
526
- ),
552
+ // background: () => highestSurface(ctx, colors),
553
+ // contrastCurve: () => getCurve(4.5),
554
+ // adjustTone: () =>
555
+ // toneDeltaPair(
556
+ // getColor('secondaryContainer'),
557
+ // getColor('secondary'),
558
+ // 5,
559
+ // 'relative_lighter',
560
+ // true,
561
+ // 'farther',
562
+ // ),
527
563
  },
528
564
  // secondaryDim: {
529
565
  // palette: () => palettes.get('secondary'),
@@ -559,7 +595,15 @@ export const udixioVariant: Variant = variant({
559
595
  },
560
596
  isBackground: true,
561
597
  background: () => highestSurface(ctx, colors),
562
- adjustTone: () => undefined,
598
+ adjustTone: () =>
599
+ toneDeltaPair(
600
+ colors.get('secondary'),
601
+ colors.get('secondaryContainer'),
602
+ 15,
603
+ 'relative_darker',
604
+ true,
605
+ 'farther',
606
+ ),
563
607
  contrastCurve: () =>
564
608
  ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
565
609
  },
@@ -621,22 +665,21 @@ export const udixioVariant: Variant = variant({
621
665
  tertiary: {
622
666
  palette: () => palettes.get('tertiary'),
623
667
  tone: () => {
624
- return ctx.isDark
625
- ? tMaxC(palettes.get('tertiary'), 0, 98)
626
- : tMaxC(palettes.get('tertiary'));
668
+ const tone = colors.get('primary').getTone();
669
+ return Math.max(20, Math.min(80, tone));
627
670
  },
628
671
  isBackground: true,
629
- background: () => highestSurface(ctx, colors),
630
- contrastCurve: () => getCurve(4.5),
631
- adjustTone: () =>
632
- toneDeltaPair(
633
- getColor('tertiaryContainer'),
634
- getColor('tertiary'),
635
- 5,
636
- 'relative_lighter',
637
- true,
638
- 'farther',
639
- ),
672
+ // background: () => highestSurface(ctx, colors),
673
+ // contrastCurve: () => getCurve(4.5),
674
+ // adjustTone: () =>
675
+ // toneDeltaPair(
676
+ // getColor('tertiaryContainer'),
677
+ // getColor('tertiary'),
678
+ // 5,
679
+ // 'relative_lighter',
680
+ // true,
681
+ // 'farther',
682
+ // ),
640
683
  },
641
684
  // tertiaryDim: {
642
685
  // palette: () => palettes.get('tertiary'),
@@ -672,7 +715,15 @@ export const udixioVariant: Variant = variant({
672
715
  },
673
716
  isBackground: true,
674
717
  background: () => highestSurface(ctx, colors),
675
- adjustTone: () => undefined,
718
+ adjustTone: () =>
719
+ toneDeltaPair(
720
+ colors.get('tertiary'),
721
+ colors.get('tertiaryContainer'),
722
+ 15,
723
+ 'relative_darker',
724
+ true,
725
+ 'farther',
726
+ ),
676
727
  contrastCurve: () =>
677
728
  ctx.contrastLevel > 0 ? getCurve(1.5) : undefined,
678
729
  },