hextimator 0.15.0 → 0.15.1

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,9 @@
1
+ ## 0.15.1
2
+
3
+ ### Patch Changes
4
+
5
+ - [#204](https://github.com/fgrgic/hextimator/pull/204) [`b584853`](https://github.com/fgrgic/hextimator/commit/b584853cafe67ab17a5991bf26008239c48208b7) Thanks [@fgrgic](https://github.com/fgrgic)! - Keep text readable when a token pins `role.DEFAULT` or `role.foreground`. A pinned DEFAULT now flips `foreground` to the other end when it misses `minContrastRatio`, and `foreground-weak` is recomputed against the pinned colors. Pinned `foreground` and `foreground-weak` values are kept.
6
+
1
7
  ## 0.15.0
2
8
 
3
9
  ### Minor Changes
@@ -479,6 +479,7 @@ declare class HextimatePaletteBuilder {
479
479
  private readonly operations;
480
480
  private readonly standaloneTokens;
481
481
  private readonly foregroundOverrides;
482
+ private readonly pinnedCoordinates;
482
483
  private readonly weakSideVariants;
483
484
  private readonly strongSideVariants;
484
485
  private readonly foregroundAnchoredVariants;
@@ -1802,6 +1802,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1802
1802
  operations = [];
1803
1803
  standaloneTokens = [];
1804
1804
  foregroundOverrides = /* @__PURE__ */ new Map();
1805
+ pinnedCoordinates = /* @__PURE__ */ new Set();
1805
1806
  weakSideVariants = ["weak"];
1806
1807
  strongSideVariants = ["strong"];
1807
1808
  foregroundAnchoredVariants = /* @__PURE__ */ new Set();
@@ -1843,6 +1844,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1843
1844
  );
1844
1845
  this.standaloneTokens.length = 0;
1845
1846
  this.foregroundOverrides.clear();
1847
+ this.pinnedCoordinates.clear();
1846
1848
  this.weakSideVariants.length = 0;
1847
1849
  this.weakSideVariants.push("weak");
1848
1850
  this.strongSideVariants.length = 0;
@@ -2383,6 +2385,31 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2383
2385
  this.resolveTokenValue(value, "dark", this.darkPalette),
2384
2386
  "oklch"
2385
2387
  );
2388
+ this.pinnedCoordinates.add(coordinate);
2389
+ if (variant !== "DEFAULT" && variant !== "foreground") return;
2390
+ const repickForeground = variant === "DEFAULT" && !this.pinnedCoordinates.has(`${role}.foreground`);
2391
+ const recomputeWeak = !this.pinnedCoordinates.has(
2392
+ `${role}.foreground-weak`
2393
+ );
2394
+ const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + CONTRAST_MARGIN;
2395
+ for (const palette of [this.lightPalette, this.darkPalette]) {
2396
+ const scale = palette[role];
2397
+ if (scale.foreground === void 0) continue;
2398
+ const base = convert(parse(scale.DEFAULT), "oklch");
2399
+ let foreground = convert(parse(scale.foreground), "oklch");
2400
+ if (repickForeground && calculateContrast(foreground, base) < contrastTarget) {
2401
+ const [dark, light] = [0.1, 0.97].map((l) => ({ ...foreground, l }));
2402
+ foreground = calculateContrast(dark, base) >= calculateContrast(light, base) ? dark : light;
2403
+ scale.foreground = foreground;
2404
+ }
2405
+ if (recomputeWeak && scale["foreground-weak"] !== void 0) {
2406
+ scale["foreground-weak"] = computeSoftestForeground(
2407
+ foreground,
2408
+ base,
2409
+ contrastTarget
2410
+ );
2411
+ }
2412
+ }
2386
2413
  }
2387
2414
  /**
2388
2415
  * Standalone token names must not squash palette flat keys after
package/dist/cli.js CHANGED
@@ -1825,6 +1825,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1825
1825
  operations = [];
1826
1826
  standaloneTokens = [];
1827
1827
  foregroundOverrides = /* @__PURE__ */ new Map();
1828
+ pinnedCoordinates = /* @__PURE__ */ new Set();
1828
1829
  weakSideVariants = ["weak"];
1829
1830
  strongSideVariants = ["strong"];
1830
1831
  foregroundAnchoredVariants = /* @__PURE__ */ new Set();
@@ -1866,6 +1867,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1866
1867
  );
1867
1868
  this.standaloneTokens.length = 0;
1868
1869
  this.foregroundOverrides.clear();
1870
+ this.pinnedCoordinates.clear();
1869
1871
  this.weakSideVariants.length = 0;
1870
1872
  this.weakSideVariants.push("weak");
1871
1873
  this.strongSideVariants.length = 0;
@@ -2406,6 +2408,31 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2406
2408
  this.resolveTokenValue(value, "dark", this.darkPalette),
2407
2409
  "oklch"
2408
2410
  );
2411
+ this.pinnedCoordinates.add(coordinate);
2412
+ if (variant !== "DEFAULT" && variant !== "foreground") return;
2413
+ const repickForeground = variant === "DEFAULT" && !this.pinnedCoordinates.has(`${role}.foreground`);
2414
+ const recomputeWeak = !this.pinnedCoordinates.has(
2415
+ `${role}.foreground-weak`
2416
+ );
2417
+ const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + CONTRAST_MARGIN;
2418
+ for (const palette of [this.lightPalette, this.darkPalette]) {
2419
+ const scale = palette[role];
2420
+ if (scale.foreground === void 0) continue;
2421
+ const base = convert(parse(scale.DEFAULT), "oklch");
2422
+ let foreground = convert(parse(scale.foreground), "oklch");
2423
+ if (repickForeground && calculateContrast(foreground, base) < contrastTarget) {
2424
+ const [dark, light] = [0.1, 0.97].map((l) => ({ ...foreground, l }));
2425
+ foreground = calculateContrast(dark, base) >= calculateContrast(light, base) ? dark : light;
2426
+ scale.foreground = foreground;
2427
+ }
2428
+ if (recomputeWeak && scale["foreground-weak"] !== void 0) {
2429
+ scale["foreground-weak"] = computeSoftestForeground(
2430
+ foreground,
2431
+ base,
2432
+ contrastTarget
2433
+ );
2434
+ }
2435
+ }
2409
2436
  }
2410
2437
  /**
2411
2438
  * Standalone token names must not squash palette flat keys after
@@ -1,4 +1,4 @@
1
- import { g as HextimatePreset, d as ColorInput, H as HextimatePaletteBuilder, n as TokenValue } from './HextimatePaletteBuilder-2hj-zvnW.js';
1
+ import { g as HextimatePreset, d as ColorInput, H as HextimatePaletteBuilder, n as TokenValue } from './HextimatePaletteBuilder-C0N0NXSs.js';
2
2
 
3
3
  /**
4
4
  * Darker accents on light themes, lighter accents on dark themes.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, T as ThemeDefinition, H as HextimatePaletteBuilder, e as HextimateFormatOptions } from './HextimatePaletteBuilder-2hj-zvnW.js';
2
- export { D as DerivedToken, F as FlatTokenMap, f as FormatResult, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, R as RoleDefinition, j as RoleGenerator, k as ThemeAdjustments, l as ThemeTokenValue, m as TokenGenerator, n as TokenValue, V as VariantPlacement, o as baseTheme } from './HextimatePaletteBuilder-2hj-zvnW.js';
3
- import { b as boldTheme, m as muiTheme, a as mutedTheme, s as shadcnTheme, t as tintedTheme, v as vibrantTheme } from './index-B1LYbLO5.js';
4
- export { H as HextimateConfig, f as fromConfig, i as presets } from './index-B1LYbLO5.js';
1
+ import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, T as ThemeDefinition, H as HextimatePaletteBuilder, e as HextimateFormatOptions } from './HextimatePaletteBuilder-C0N0NXSs.js';
2
+ export { D as DerivedToken, F as FlatTokenMap, f as FormatResult, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, R as RoleDefinition, j as RoleGenerator, k as ThemeAdjustments, l as ThemeTokenValue, m as TokenGenerator, n as TokenValue, V as VariantPlacement, o as baseTheme } from './HextimatePaletteBuilder-C0N0NXSs.js';
3
+ import { b as boldTheme, m as muiTheme, a as mutedTheme, s as shadcnTheme, t as tintedTheme, v as vibrantTheme } from './index-BuvAqrm4.js';
4
+ export { H as HextimateConfig, f as fromConfig, i as presets } from './index-BuvAqrm4.js';
5
5
 
6
6
  /**
7
7
  * Daltonize a color for a specific type of color vision deficiency (CVD).
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  simulateColor,
10
10
  tailwindAliases,
11
11
  themes_exports
12
- } from "./chunk-3JIC7LRE.js";
12
+ } from "./chunk-IZQGOQA7.js";
13
13
  import {
14
14
  baseTheme,
15
15
  presets_exports
package/dist/presets.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { H as HextimateConfig, c as bold, d as mui, e as muted, g as shadcn, h as tinted, j as vibrant } from './index-B1LYbLO5.js';
2
- export { g as HextimatePreset } from './HextimatePaletteBuilder-2hj-zvnW.js';
1
+ export { H as HextimateConfig, c as bold, d as mui, e as muted, g as shadcn, h as tinted, j as vibrant } from './index-BuvAqrm4.js';
2
+ export { g as HextimatePreset } from './HextimatePaletteBuilder-C0N0NXSs.js';
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, T as ThemeDefinition, e as HextimateFormatOptions } from './HextimatePaletteBuilder-2hj-zvnW.js';
1
+ import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, T as ThemeDefinition, e as HextimateFormatOptions } from './HextimatePaletteBuilder-C0N0NXSs.js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { PropsWithChildren, RefObject, CSSProperties, ReactNode } from 'react';
4
4
 
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  hextimate
3
- } from "./chunk-3JIC7LRE.js";
3
+ } from "./chunk-IZQGOQA7.js";
4
4
  import "./chunk-Q6KJLMLM.js";
5
5
 
6
6
  // src/react/hextimator-provider.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hextimator",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Runtime theming for multi-tenant apps.",
5
5
  "keywords": [
6
6
  "color-palette",