hextimator 0.5.1 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,4 +1,34 @@
1
- ## 0.5.1 (Latest)
1
+ ## 0.7.0 (Latest)
2
+
3
+ - Adds an opt-in `invertedVariants: true` format option that emits an -inverted copy of every token holding the opposite mode's value, plus a companion hextimator/tailwind-inverted.css so utilities like `bg-surface-inverted` just work.
4
+
5
+ - Renamed `ThemeAdjustments.lightness` → `baseLightness` to disambiguate it from the _relative_ `lightness` offset used by `addToken({ from, lightness })`. Same word was doing two different jobs (absolute theme anchor vs. relative offset), which made the API confusing.
6
+
7
+ ```ts
8
+ // Before (0.6)
9
+ hextimate(color).style({
10
+ light: { lightness: 0.7 },
11
+ dark: { lightness: 0.6 },
12
+ });
13
+
14
+ // After (0.7)
15
+ hextimate(color).style({
16
+ light: { baseLightness: 0.7 },
17
+ dark: { baseLightness: 0.6 },
18
+ });
19
+ ```
20
+
21
+ The old `lightness` field still works as a deprecated alias and emits a one-time `console.warn`.
22
+
23
+ Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
24
+
25
+ ## 0.6.0
26
+
27
+ - [#114](https://github.com/fgrgic/hextimator/pull/114) **Breaking**. Uses `surface` instead of `base` for the background tokens (e.g. `base-strong` → `surface-strong`). This avoids a class-name collision with Tailwind's built-in text-base font-size utility and makes the token name match its semantic purpose (the surface behind your content).
28
+
29
+ Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
30
+
31
+ ## 0.5.1
2
32
 
3
33
  - [#110](https://github.com/fgrgic/hextimator/pull/110): Add ./presets as a dedicated subpath export so `import { tinted } from 'hextimator/presets'` works
4
34
 
@@ -23,7 +53,7 @@
23
53
  - New CLI flags mirroring the options: `--dark-mode <strategy>` and `--selector <css>`. The `--theme` flag is ignored for `css`/`tailwind-css` outputs (both themes always combine into one string).
24
54
  - React integration unchanged.
25
55
 
26
- Migration checklist: [migrating-from-0.4.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migrating-from-0.4.md).
56
+ Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
27
57
 
28
58
  ## 0.4.0
29
59
 
@@ -55,7 +85,7 @@
55
85
  <HextimatorScope style={s} /> → <HextimatorScope wrapperStyle={s} />
56
86
  ```
57
87
 
58
- Migration checklist: [migrating-from-0.2.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migrating-from-0.2.md).
88
+ Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
59
89
 
60
90
  ## 0.2.0
61
91
 
package/README.md CHANGED
@@ -121,8 +121,8 @@ Presets can bring their own **`style`** (contrast, chroma, and other generation
121
121
 
122
122
  ```typescript
123
123
  const theme = hextimate("#DEC0DE")
124
- .preset(presets.tinted) // e.g. sets a looser baseMaxChroma
125
- .style({ baseMaxChroma: 0.01 }) // tighten further for this app
124
+ .preset(presets.tinted) // e.g. sets a looser surfaceMaxChroma
125
+ .style({ surfaceMaxChroma: 0.01 }) // tighten further for this app
126
126
  .preset(presets.shadcn)
127
127
  .format();
128
128
  ```
@@ -143,7 +143,7 @@ const theme = hextimate("#0FF5E7").format({ as: "css", colors: "oklch" });
143
143
 
144
144
  ```typescript
145
145
  hextimate("#FACADE")
146
- .style({ minContrastRatio: "AA", baseMaxChroma: 0.02 })
146
+ .style({ minContrastRatio: "AA", surfaceMaxChroma: 0.02 })
147
147
  .format();
148
148
  ```
149
149
 
@@ -200,7 +200,7 @@ All formats return `{ light: { ... }, dark: { ... } }`.
200
200
 
201
201
  Besides hex, **`hextimate`** accepts CSS color strings, RGB tuples, and numeric `0xRRGGBB`—anything **`parseColor`** understands.
202
202
 
203
- > **Note on alpha**: Alpha values are intentionally ignored — `rgba(255, 0, 0, 0.5)` is treated as fully opaque `rgb(255, 0, 0)`. Alpha tokens undermine accessibility guarantees because contrast ratios depend on the background, which hextimator does not control. You can always add an opacity modifier later if you wish (e.g. `base-accent-weak/20` in tailwind).
203
+ > **Note on alpha**: Alpha values are intentionally ignored — `rgba(255, 0, 0, 0.5)` is treated as fully opaque `rgb(255, 0, 0)`. Alpha tokens undermine accessibility guarantees because contrast ratios depend on the background, which hextimator does not control. You can always add an opacity modifier later if you wish (e.g. `accent-weak/20` in tailwind).
204
204
 
205
205
  Before `.format()` you can still chain **`addRole` / `addVariant` / `addToken`**, **`.preset()`**, **`.fork()`**, **`.simulate()` / `.adaptFor()`**, and anything else in [Extending the palette](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/extending-the-palette.md) or [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md).
206
206
 
@@ -208,7 +208,7 @@ Before `.format()` you can still chain **`addRole` / `addVariant` / `addToken`**
208
208
 
209
209
  1. **Parse** any color input into a normalized `Color` object.
210
210
  2. **Convert** to OKLCH (perceptual color space) so lightness and chroma adjustments look uniform across hues.
211
- 3. **Generate** accent, base, and semantic color scales — each with DEFAULT, strong, weak, and foreground variants.
211
+ 3. **Generate** accent, surface, and semantic color scales — each with DEFAULT, strong, weak, and foreground variants.
212
212
  4. **Gamut-map** back to sRGB via binary-search chroma reduction (preserves lightness and hue).
213
213
  5. **Format** into your chosen output (CSS vars, Tailwind, SCSS, JSON, or plain object).
214
214
 
@@ -251,7 +251,7 @@ See **[React (full guide)](https://github.com/fgrgic/hextimator/blob/main/packag
251
251
 
252
252
  ### `fallback.css`
253
253
 
254
- Pre-JS placeholder: neutral values for the same variables as default `hextimate()` (and `hextimator/tailwind.css`). Use in **client-rendered** apps so the first paint is not missing `--accent`, `--base`, etc. before your bundle runs; runtime theme CSS then replaces them. Import **before** `tailwind.css` if you use it.
254
+ Pre-JS placeholder: neutral values for the same variables as default `hextimate()` (and `hextimator/tailwind.css`). Use in **client-rendered** apps so the first paint is not missing `--accent`, `--surface`, etc. before your bundle runs; runtime theme CSS then replaces them. Import **before** `tailwind.css` if you use it.
255
255
 
256
256
  ```css
257
257
  @import "hextimator/fallback.css";
@@ -262,16 +262,19 @@ Does not match **preset-only** token names (e.g. shadcn); use the CLI to generat
262
262
 
263
263
  ## Documentation
264
264
 
265
- - [Migrating from 0.2.x](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migrating-from-0.2.md) — breaking changes for 0.3.0
265
+ - [Customization](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/customization.md) — style and format options reference
266
266
  - [Extending the palette](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/extending-the-palette.md) — `addRole`, `addVariant`, `addToken`
267
267
  - [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md) — drop-in configs for shadcn/ui, or create your own
268
268
  - [Multiple themes](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/multiple-themes.md) — dynamic theming and `.fork()`
269
- - [Customization](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/customization.md) — style and format options reference
270
269
  - [Color vision deficiency](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/color-vision-deficiency.md) — simulate and adapt for CVD
271
270
  - [React](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/react.md) — hook, `HextimatorStyle`, provider, scoped themes, dark mode
272
271
  - [Tailwind CSS v4](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/tailwind.md) — setup and usage with Tailwind
273
272
  - [Real-world examples](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/examples.md) — shadcn/ui, Stripe, Slack configurations
274
273
 
274
+ ### For migrating from previous versions
275
+
276
+ - [Migration guide](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md) — breaking changes by version
277
+
275
278
  ## Contributing
276
279
 
277
280
  Issues and PRs are welcome at [github.com/fgrgic/hextimator](https://github.com/fgrgic/hextimator/issues).
@@ -75,10 +75,19 @@ type ColorInput = HexString | CSSColorString | ColorTuple | Color | number;
75
75
  */
76
76
  interface ThemeAdjustments {
77
77
  /**
78
- * Absolute OKLCH lightness for this theme (0–1).
78
+ * Absolute OKLCH lightness anchor for this theme's accent color (0–1).
79
+ *
80
+ * This is the *baseline* the palette is generated around — distinct from
81
+ * the *relative* `lightness` offsets used by `addToken({ from, lightness })`.
79
82
  *
80
83
  * Default: 0.7 for light, 0.6 for dark.
81
84
  */
85
+ baseLightness?: number;
86
+ /**
87
+ * @deprecated Renamed to `baseLightness` in 0.7.0 to disambiguate it from
88
+ * the relative `lightness` offset used by `addToken({ from, lightness })`.
89
+ * Still works as a fallback. Will be removed in a future release.
90
+ */
82
91
  lightness?: number;
83
92
  /**
84
93
  * Maximum chroma for accent/semantic colors in this theme.
@@ -95,10 +104,10 @@ interface ThemeAdjustments {
95
104
  */
96
105
  minContrastRatio?: 'AAA' | 'AA' | number;
97
106
  /**
98
- * Maximum chroma for the baseline colors (base, strong, weak) in this theme.
99
- * Overrides the global `baseMaxChroma` for this theme only.
107
+ * Maximum chroma for the surface colors (surface, strong, weak) in this theme.
108
+ * Overrides the global `surfaceMaxChroma` for this theme only.
100
109
  */
101
- baseMaxChroma?: number;
110
+ surfaceMaxChroma?: number;
102
111
  /**
103
112
  * Maximum chroma for foreground colors in this theme.
104
113
  * Overrides the global `foregroundMaxChroma` for this theme only.
@@ -110,23 +119,23 @@ interface ThemeAdjustments {
110
119
  */
111
120
  interface HextimateStyleOptions {
112
121
  /**
113
- * Preferred base color for dark and light mode.
114
- * It will be used as a baseline to generate the rest of base colors (strong, weak).
122
+ * Preferred surface color for dark and light mode.
123
+ * It will be used as a baseline to generate the rest of surface colors (strong, weak).
115
124
  * If not provided, it will be derived from the main input color with very low chroma.
116
125
  *
117
- * Takes precedence over `baseHueShift` when both are set.
126
+ * Takes precedence over `surfaceHueShift` when both are set.
118
127
  */
119
- baseColor?: ColorInput;
128
+ surfaceColor?: ColorInput;
120
129
  /**
121
- * Rotate the base color's hue relative to the accent color (in degrees).
130
+ * Rotate the surface color's hue relative to the accent color (in degrees).
122
131
  *
123
132
  * Examples: 180 for complementary, 30 for analogous, -30 for the other direction.
124
133
  *
125
- * Ignored when an explicit `baseColor` is provided.
134
+ * Ignored when an explicit `surfaceColor` is provided.
126
135
  *
127
136
  * Default: 0 (same hue as the accent).
128
137
  */
129
- baseHueShift?: number;
138
+ surfaceHueShift?: number;
130
139
  /**
131
140
  * Semantic colors to use for the theme
132
141
  * If not provided, they will be generated from the provided main color,
@@ -139,12 +148,12 @@ interface HextimateStyleOptions {
139
148
  };
140
149
  /**
141
150
  * Invert the hue used for the accent color in dark mode.
142
- * Uses base hue as accent, and accent hue as base.
143
- * Only has effect if `baseColor` is provided alongside the main accent color
151
+ * Uses surface hue as accent, and accent hue as surface.
152
+ * Only has effect if `surfaceColor` is provided alongside the main accent color
144
153
  *
145
154
  * Default: false.
146
155
  */
147
- invertDarkModeBaseAccent?: boolean;
156
+ invertDarkModeSurfaceAccent?: boolean;
148
157
  /**
149
158
  * Degree ranges for the semantic colors.
150
159
  * Determines where to look for "green", "red", "yellow" in the color space.
@@ -159,14 +168,14 @@ interface HextimateStyleOptions {
159
168
  warning?: [number, number];
160
169
  };
161
170
  /**
162
- * Maximum chroma for the baseline colors (base, strong, weak).
163
- * Higher values will produce more colorful baseline colors, lower values will produce more gray baseline colors.
171
+ * Maximum chroma for the surface colors (surface, strong, weak).
172
+ * Higher values will produce more colorful surface colors, lower values will produce more gray surface colors.
164
173
  *
165
174
  * Default: 0.01.
166
175
  */
167
- baseMaxChroma?: number;
176
+ surfaceMaxChroma?: number;
168
177
  /**
169
- * Maximum chroma for all the foreground colors (e.g. base-accent-foreground)
178
+ * Maximum chroma for all the foreground colors (e.g. surface-accent-foreground)
170
179
  * Higher values will produce more colorful foreground colors, lower values will produce more gray foreground colors.
171
180
  *
172
181
  * Default: 0.01.
@@ -214,7 +223,7 @@ interface HextimateFormatOptions {
214
223
  * Internal name → your custom name.
215
224
  *
216
225
  * Examples:
217
- * - base: "bg"
226
+ * - surface: "bg"
218
227
  * - accent: "button"
219
228
  * - positive: "success"
220
229
  * - negative: "error"
@@ -222,7 +231,7 @@ interface HextimateFormatOptions {
222
231
  *
223
232
  * If not provided, the default role names will be used.
224
233
  * The default role names are:
225
- * - base: "base"
234
+ * - surface: "surface"
226
235
  * - accent: "accent"
227
236
  * - positive: "positive"
228
237
  * - negative: "negative"
@@ -245,16 +254,16 @@ interface HextimateFormatOptions {
245
254
  * If not provided, the default separator will be used.
246
255
  * The default separator is: "-"
247
256
  *
248
- * Use "_" for "base_strong", "/" for "base/strong", etc.
257
+ * Use "_" for "surface_strong", "/" for "surface/strong", etc.
249
258
  */
250
259
  separator?: string;
251
260
  /**
252
261
  * Output format.
253
- * - "object" (default): { base: "#f2eee8", "base-strong": "#d4cfc8", ...}
262
+ * - "object" (default): { surface: "#f2eee8", "surface-strong": "#d4cfc8", ...}
254
263
  * - "css": ready-to-paste CSS stylesheet string with `:root {}` and a dark-mode wrapper
255
- * - "tailwind": { base: { DEFAULT: "#f2eee8", strong: "#d4cfc8", weak: "#faf8f6" } }
256
- * - "scss": { $base: "#f2eee8", $base-strong: "#d4cfc8", ...}
257
- * - "json": '{ "base": "#f2eee8", "base-strong": "#d4cfc8", ...}'
264
+ * - "tailwind": { surface: { DEFAULT: "#f2eee8", strong: "#d4cfc8", weak: "#faf8f6" } }
265
+ * - "scss": { $surface: "#f2eee8", $surface-strong: "#d4cfc8", ...}
266
+ * - "json": '{ "surface": "#f2eee8", "surface-strong": "#d4cfc8", ...}'
258
267
  * - "tailwind-css": Tailwind v4 stylesheet string with a single `@theme { ... }` block and dark-mode overrides
259
268
  *
260
269
  * Stylesheet outputs (`css`, `tailwind-css`) combine light + dark into one
@@ -306,6 +315,30 @@ interface HextimateFormatOptions {
306
315
  * Example: `['strong', 'weak']` removes those variants from all roles.
307
316
  */
308
317
  excludeVariants?: string[];
318
+ /**
319
+ * Emit an extra `-inverted` copy of every token whose value is the
320
+ * opposite mode's value (light tokens get dark values, dark tokens get
321
+ * light values). Inverted tokens flip with the active mode, just like
322
+ * regular tokens.
323
+ *
324
+ * Use for sections that intentionally contrast with the surrounding
325
+ * theme: testimonials, alternating stripes, hero callouts, "spotlight"
326
+ * panels. One class (`bg-surface-inverted`) flips both ways.
327
+ *
328
+ * For "always this mode" sections, compose with the dark-mode variant:
329
+ * - Always dark: `bg-surface-inverted dark:bg-surface`
330
+ * - Always light: `bg-surface dark:bg-surface-inverted`
331
+ *
332
+ * Example output (flat keys):
333
+ * - `accent-inverted`, `accent-strong-inverted`, `accent-foreground-inverted`
334
+ *
335
+ * Tailwind users need to pair this with the companion stylesheet:
336
+ * `@import "hextimator/tailwind-inverted.css";` to get utilities like
337
+ * `bg-accent-inverted`, `text-accent-foreground-inverted`.
338
+ *
339
+ * Default: `false`.
340
+ */
341
+ invertedVariants?: boolean;
309
342
  }
310
343
  /**
311
344
  * Combined options for the convenience API.
@@ -384,10 +417,10 @@ type VariantPlacement = {
384
417
  * simple contrast adjustments.
385
418
  *
386
419
  * @example
387
- * { from: "base.weak", lightness: -0.05 }
420
+ * { from: "surface.weak", lightness: -0.05 }
388
421
  * { from: "accent", hue: -20 }
389
- * { from: "base", emphasis: 0.12 }
390
- * { from: "base.foreground", emphasis: -0.2 }
422
+ * { from: "surface", emphasis: 0.12 }
423
+ * { from: "surface.foreground", emphasis: -0.2 }
391
424
  */
392
425
  interface DerivedToken {
393
426
  from: string;
@@ -402,7 +435,7 @@ interface DerivedToken {
402
435
  * @example
403
436
  * "#FF6600"
404
437
  * { from: "accent", lightness: +0.1 }
405
- * { light: { from: "base.weak", lightness: -0.05 }, dark: { from: "base.weak", lightness: +0.05 } }
438
+ * { light: { from: "surface.weak", lightness: -0.05 }, dark: { from: "surface.weak", lightness: +0.05 } }
406
439
  */
407
440
  type TokenValue = ColorInput | DerivedToken | {
408
441
  light: DerivedToken | ColorInput;
@@ -421,7 +454,7 @@ declare class HextimatePaletteBuilder {
421
454
  private presetFormatDefaults?;
422
455
  constructor(color: Color);
423
456
  /**
424
- * Merges style options into the builder and regenerates the base palettes,
457
+ * Merges style options into the builder and regenerates the palettes,
425
458
  * then replays recorded operations so roles and variants reflect the new style.
426
459
  */
427
460
  style(partial: Partial<HextimateStyleOptions>): this;
@@ -434,7 +467,7 @@ declare class HextimatePaletteBuilder {
434
467
  *
435
468
  * The color can be a direct color value or a derived token referencing an existing role.
436
469
  *
437
- * e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified hue as the base.
470
+ * e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified color.
438
471
  * `addRole('cta', { from: 'accent', hue: 180 })` adds a "cta" role with a complementary hue to accent.
439
472
  *
440
473
  * @param name Role name (e.g. "cta", "banner")
@@ -459,7 +492,7 @@ declare class HextimatePaletteBuilder {
459
492
  * `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
460
493
  *
461
494
  * It can also be used to override specific tokens after generation.
462
- * `addToken('base-strong', '#ff0066')` overrides the automatically generated "base-strong" variant with a custom color.
495
+ * `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
463
496
  *
464
497
  * @param name Token name (e.g. "brand", "logo")
465
498
  * @param value Token value, which can be an exact color, or derived from an existing role+variant.
@@ -469,7 +502,7 @@ declare class HextimatePaletteBuilder {
469
502
  * Applies a preset that configures roles, tokens, and format defaults
470
503
  * for a specific framework or convention (e.g. shadcn/ui).
471
504
  *
472
- * Preset format defaults are used as a base in `.format()` — any options
505
+ * Preset format defaults are used as defaults in `.format()` — any options
473
506
  * you pass to `.format()` will override the preset's defaults.
474
507
  *
475
508
  * @example
@@ -490,7 +523,7 @@ declare class HextimatePaletteBuilder {
490
523
  * Does not merge `preset.style` — used when replaying onto a builder whose `this.options` already reflect merged style.
491
524
  */
492
525
  private recordPresetWithoutStyleMerge;
493
- /** Roles, variants, tokens, and format only — `this.options` and base palettes are already correct. */
526
+ /** Roles, variants, tokens, and format only — `this.options` and palettes are already correct. */
494
527
  private applyPresetRolesTokensFormat;
495
528
  /**
496
529
  *
@@ -525,7 +558,7 @@ declare class HextimatePaletteBuilder {
525
558
  */
526
559
  adaptFor(type: CVDType, severity?: number): this;
527
560
  /**
528
- * Creates a new builder instance with the same operations history, optionally from a different base color.
561
+ * Creates a new builder instance with the same operations history, optionally from a different accent color.
529
562
  * To change style options on the fork, chain `.style()` after `.fork()`.
530
563
  *
531
564
  * @param color Optional new accent/brand color. If omitted, the fork uses the same color as this builder.
@@ -552,6 +585,7 @@ declare class HextimatePaletteBuilder {
552
585
  as: 'object' | 'scss';
553
586
  }): HextimateResult<FlatTokenMap>;
554
587
  format(options?: HextimateFormatOptions): HextimateResult | string;
588
+ private buildInvertedEntries;
555
589
  private applyRole;
556
590
  private applyVariant;
557
591
  private applyToken;
@@ -856,6 +856,12 @@ function buildTokenEntries(palette, options) {
856
856
  }
857
857
  return entries;
858
858
  }
859
+ function withInvertedSuffix(entry, sep) {
860
+ if (entry.isDefault && entry.variant === "DEFAULT") {
861
+ return { ...entry, isDefault: false, variant: "inverted" };
862
+ }
863
+ return { ...entry, variant: `${entry.variant}${sep}inverted` };
864
+ }
859
865
 
860
866
  // src/format/formatters.ts
861
867
  function toFlatKey(entry, sep) {
@@ -1164,11 +1170,19 @@ function expandColorToScale(color, themeType, options) {
1164
1170
  }
1165
1171
  var LIGHT_THEME_LIGHTNESS_RANGE = [0.4, 0.99];
1166
1172
  var DARK_THEME_LIGHTNESS_RANGE = [0.2, 0.8];
1173
+ var warnedLegacyLightness = false;
1167
1174
  function resolveThemeLightness(themeType, options) {
1168
1175
  const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
1169
1176
  const range = themeType === "light" ? LIGHT_THEME_LIGHTNESS_RANGE : DARK_THEME_LIGHTNESS_RANGE;
1170
- if (themeAdjustments?.lightness !== void 0) {
1171
- return Math.min(Math.max(themeAdjustments.lightness, range[0]), range[1]);
1177
+ const value = themeAdjustments?.baseLightness ?? themeAdjustments?.lightness;
1178
+ if (themeAdjustments?.baseLightness === void 0 && themeAdjustments?.lightness !== void 0 && !warnedLegacyLightness && typeof console !== "undefined") {
1179
+ warnedLegacyLightness = true;
1180
+ console.warn(
1181
+ "[hextimator] `style({ light/dark: { lightness } })` is deprecated. Rename to `baseLightness` to disambiguate from the relative `lightness` offset used by `addToken({ from, lightness })`. Will be removed in a future release."
1182
+ );
1183
+ }
1184
+ if (value !== void 0) {
1185
+ return Math.min(Math.max(value, range[0]), range[1]);
1172
1186
  }
1173
1187
  return themeType === "light" ? DEFAULT_LIGHT_THEME_LIGHTNESS : DEFAULT_DARK_THEME_LIGHTNESS;
1174
1188
  }
@@ -1232,20 +1246,20 @@ function calculateContrast(colorA, colorB) {
1232
1246
 
1233
1247
  // src/generate/generateAccent.ts
1234
1248
  function generateAccent(accent, themeType, options) {
1235
- const invertBaseAndAccent = themeType === "dark" && options?.invertDarkModeBaseAccent;
1236
- if (invertBaseAndAccent) {
1249
+ const invertSurfaceAndAccent = themeType === "dark" && options?.invertDarkModeSurfaceAccent;
1250
+ if (invertSurfaceAndAccent) {
1237
1251
  const accentOklch = convert(accent, "oklch");
1238
- const baseHueShift = options?.baseHueShift ?? 0;
1239
- let baseOklch = options?.baseColor ? convert(parse(options.baseColor), "oklch") : convert(accent, "oklch");
1240
- if (baseHueShift !== 0 && !options?.baseColor) {
1241
- baseOklch = {
1242
- ...baseOklch,
1243
- h: wrapHue(accentOklch.h + baseHueShift)
1252
+ const surfaceHueShift = options?.surfaceHueShift ?? 0;
1253
+ let surfaceOklch = options?.surfaceColor ? convert(parse(options.surfaceColor), "oklch") : convert(accent, "oklch");
1254
+ if (surfaceHueShift !== 0 && !options?.surfaceColor) {
1255
+ surfaceOklch = {
1256
+ ...surfaceOklch,
1257
+ h: wrapHue(accentOklch.h + surfaceHueShift)
1244
1258
  };
1245
1259
  }
1246
1260
  const maxChroma = options?.dark?.maxChroma;
1247
1261
  const invertedAccent = {
1248
- ...baseOklch,
1262
+ ...surfaceOklch,
1249
1263
  c: maxChroma !== void 0 ? Math.min(accentOklch.c, maxChroma) : accentOklch.c
1250
1264
  };
1251
1265
  return expandColorToScale(invertedAccent, themeType, options);
@@ -1253,47 +1267,6 @@ function generateAccent(accent, themeType, options) {
1253
1267
  return expandColorToScale(accent, themeType, options);
1254
1268
  }
1255
1269
 
1256
- // src/generate/generateBase.ts
1257
- var BASELINE_DARK_L_VALUE = 0.2;
1258
- var BASELINE_LIGHT_L_VALUE = 0.97;
1259
- var BASELINE_MAX_CHROMA = 0.01;
1260
- var STRONG_DELTA_DARK = -0.1;
1261
- var STRONG_DELTA_LIGHT = 0.02;
1262
- var WEAK_DELTA_DARK = 0.1;
1263
- var WEAK_DELTA_LIGHT = -0.03;
1264
- function generateBase(color, themeType, options) {
1265
- const invertBaseAndAccent = themeType === "dark" && options?.invertDarkModeBaseAccent;
1266
- const preferredBaseColorInput = invertBaseAndAccent ? color ?? options?.baseColor : options?.baseColor ?? color;
1267
- const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
1268
- const baselineMaxChroma = themeAdjustments?.baseMaxChroma ?? options?.baseMaxChroma ?? BASELINE_MAX_CHROMA;
1269
- const preferredBaseColor = convert(parse(preferredBaseColorInput), "oklch");
1270
- let baseHue = preferredBaseColor.h;
1271
- const baseChroma = Math.min(preferredBaseColor.c, baselineMaxChroma);
1272
- const baseHueShift = options?.baseHueShift ?? 0;
1273
- if (baseHueShift !== 0 && !options?.baseColor && !invertBaseAndAccent) {
1274
- baseHue = wrapHue(convert(color, "oklch").h + baseHueShift);
1275
- }
1276
- const normalizedPreferredBaseColor = {
1277
- ...preferredBaseColor,
1278
- h: baseHue,
1279
- c: baseChroma,
1280
- l: themeType === "light" ? BASELINE_LIGHT_L_VALUE : BASELINE_DARK_L_VALUE
1281
- };
1282
- return expandColorToScale(normalizedPreferredBaseColor, themeType, {
1283
- baselineLValueDark: BASELINE_DARK_L_VALUE,
1284
- baselineLValueLight: BASELINE_LIGHT_L_VALUE,
1285
- strongDeltaDark: STRONG_DELTA_DARK,
1286
- strongDeltaLight: STRONG_DELTA_LIGHT,
1287
- weakDeltaDark: WEAK_DELTA_DARK,
1288
- weakDeltaLight: WEAK_DELTA_LIGHT,
1289
- minContrastRatio: options?.minContrastRatio,
1290
- hueShift: options?.hueShift,
1291
- foregroundMaxChroma: options?.foregroundMaxChroma,
1292
- light: options?.light,
1293
- dark: options?.dark
1294
- });
1295
- }
1296
-
1297
1270
  // src/generate/generateSemanticColors.ts
1298
1271
  var POSITIVE_RANGE = [135, 160];
1299
1272
  var NEGATIVE_RANGE = [5, 25];
@@ -1395,10 +1368,54 @@ function _getSplitComplementaryColors(color) {
1395
1368
  ];
1396
1369
  }
1397
1370
 
1371
+ // src/generate/generateSurface.ts
1372
+ var BASELINE_DARK_L_VALUE = 0.2;
1373
+ var BASELINE_LIGHT_L_VALUE = 0.97;
1374
+ var BASELINE_MAX_CHROMA = 0.01;
1375
+ var STRONG_DELTA_DARK = -0.1;
1376
+ var STRONG_DELTA_LIGHT = 0.02;
1377
+ var WEAK_DELTA_DARK = 0.1;
1378
+ var WEAK_DELTA_LIGHT = -0.03;
1379
+ function generateSurface(color, themeType, options) {
1380
+ const invertSurfaceAndAccent = themeType === "dark" && options?.invertDarkModeSurfaceAccent;
1381
+ const preferredSurfaceColorInput = invertSurfaceAndAccent ? color ?? options?.surfaceColor : options?.surfaceColor ?? color;
1382
+ const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
1383
+ const surfaceMaxChroma = themeAdjustments?.surfaceMaxChroma ?? options?.surfaceMaxChroma ?? BASELINE_MAX_CHROMA;
1384
+ const preferredSurfaceColor = convert(
1385
+ parse(preferredSurfaceColorInput),
1386
+ "oklch"
1387
+ );
1388
+ let surfaceHue = preferredSurfaceColor.h;
1389
+ const surfaceChroma = Math.min(preferredSurfaceColor.c, surfaceMaxChroma);
1390
+ const surfaceHueShift = options?.surfaceHueShift ?? 0;
1391
+ if (surfaceHueShift !== 0 && !options?.surfaceColor && !invertSurfaceAndAccent) {
1392
+ surfaceHue = wrapHue(convert(color, "oklch").h + surfaceHueShift);
1393
+ }
1394
+ const normalizedPreferredSurfaceColor = {
1395
+ ...preferredSurfaceColor,
1396
+ h: surfaceHue,
1397
+ c: surfaceChroma,
1398
+ l: themeType === "light" ? BASELINE_LIGHT_L_VALUE : BASELINE_DARK_L_VALUE
1399
+ };
1400
+ return expandColorToScale(normalizedPreferredSurfaceColor, themeType, {
1401
+ baselineLValueDark: BASELINE_DARK_L_VALUE,
1402
+ baselineLValueLight: BASELINE_LIGHT_L_VALUE,
1403
+ strongDeltaDark: STRONG_DELTA_DARK,
1404
+ strongDeltaLight: STRONG_DELTA_LIGHT,
1405
+ weakDeltaDark: WEAK_DELTA_DARK,
1406
+ weakDeltaLight: WEAK_DELTA_LIGHT,
1407
+ minContrastRatio: options?.minContrastRatio,
1408
+ hueShift: options?.hueShift,
1409
+ foregroundMaxChroma: options?.foregroundMaxChroma,
1410
+ light: options?.light,
1411
+ dark: options?.dark
1412
+ });
1413
+ }
1414
+
1398
1415
  // src/generate/generate.ts
1399
1416
  function generate(color, themeType, options) {
1400
1417
  return {
1401
- base: generateBase(color, themeType, options),
1418
+ surface: generateSurface(color, themeType, options),
1402
1419
  accent: generateAccent(color, themeType, options),
1403
1420
  ...generateSemanticColors(color, themeType, options)
1404
1421
  };
@@ -1443,7 +1460,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1443
1460
  this.seedOptionsForFork({});
1444
1461
  }
1445
1462
  /**
1446
- * Merges style options into the builder and regenerates the base palettes,
1463
+ * Merges style options into the builder and regenerates the palettes,
1447
1464
  * then replays recorded operations so roles and variants reflect the new style.
1448
1465
  */
1449
1466
  style(partial) {
@@ -1532,7 +1549,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1532
1549
  *
1533
1550
  * The color can be a direct color value or a derived token referencing an existing role.
1534
1551
  *
1535
- * e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified hue as the base.
1552
+ * e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified color.
1536
1553
  * `addRole('cta', { from: 'accent', hue: 180 })` adds a "cta" role with a complementary hue to accent.
1537
1554
  *
1538
1555
  * @param name Role name (e.g. "cta", "banner")
@@ -1565,7 +1582,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1565
1582
  * `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
1566
1583
  *
1567
1584
  * It can also be used to override specific tokens after generation.
1568
- * `addToken('base-strong', '#ff0066')` overrides the automatically generated "base-strong" variant with a custom color.
1585
+ * `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
1569
1586
  *
1570
1587
  * @param name Token name (e.g. "brand", "logo")
1571
1588
  * @param value Token value, which can be an exact color, or derived from an existing role+variant.
@@ -1579,7 +1596,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1579
1596
  * Applies a preset that configures roles, tokens, and format defaults
1580
1597
  * for a specific framework or convention (e.g. shadcn/ui).
1581
1598
  *
1582
- * Preset format defaults are used as a base in `.format()` — any options
1599
+ * Preset format defaults are used as defaults in `.format()` — any options
1583
1600
  * you pass to `.format()` will override the preset's defaults.
1584
1601
  *
1585
1602
  * @example
@@ -1620,7 +1637,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1620
1637
  this.operations.push({ method: "preset", args: [preset] });
1621
1638
  this.applyPresetRolesTokensFormat(preset);
1622
1639
  }
1623
- /** Roles, variants, tokens, and format only — `this.options` and base palettes are already correct. */
1640
+ /** Roles, variants, tokens, and format only — `this.options` and palettes are already correct. */
1624
1641
  applyPresetRolesTokensFormat(preset) {
1625
1642
  for (const role of preset.roles ?? []) {
1626
1643
  this.applyRole(role.name, role.color);
@@ -1689,7 +1706,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1689
1706
  return this;
1690
1707
  }
1691
1708
  /**
1692
- * Creates a new builder instance with the same operations history, optionally from a different base color.
1709
+ * Creates a new builder instance with the same operations history, optionally from a different accent color.
1693
1710
  * To change style options on the fork, chain `.style()` after `.fork()`.
1694
1711
  *
1695
1712
  * @param color Optional new accent/brand color. If omitted, the fork uses the same color as this builder.
@@ -1748,18 +1765,42 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1748
1765
  this.darkPalette,
1749
1766
  colorFormat
1750
1767
  );
1768
+ const inverted = mergedOptions?.invertedVariants ? this.buildInvertedEntries(mergedOptions, lightTokens, darkTokens) : { lightBlock: [], darkBlock: [] };
1751
1769
  if (mergedOptions?.as === "css" || mergedOptions?.as === "tailwind-css") {
1752
1770
  return formatStylesheet(
1753
1771
  this.lightPalette,
1754
1772
  this.darkPalette,
1755
1773
  mergedOptions,
1756
- lightTokens,
1757
- darkTokens
1774
+ [...lightTokens, ...inverted.lightBlock],
1775
+ [...darkTokens, ...inverted.darkBlock]
1758
1776
  );
1759
1777
  }
1760
1778
  return {
1761
- light: format(this.lightPalette, mergedOptions, lightTokens),
1762
- dark: format(this.darkPalette, mergedOptions, darkTokens)
1779
+ light: format(this.lightPalette, mergedOptions, [
1780
+ ...lightTokens,
1781
+ ...inverted.lightBlock
1782
+ ]),
1783
+ dark: format(this.darkPalette, mergedOptions, [
1784
+ ...darkTokens,
1785
+ ...inverted.darkBlock
1786
+ ])
1787
+ };
1788
+ }
1789
+ buildInvertedEntries(options, lightStandalone, darkStandalone) {
1790
+ const sep = options.separator ?? "-";
1791
+ const lightBase = buildTokenEntries(this.lightPalette, options);
1792
+ const darkBase = buildTokenEntries(this.darkPalette, options);
1793
+ return {
1794
+ // Light block carries dark values under -inverted suffix.
1795
+ lightBlock: [
1796
+ ...darkBase.map((e) => withInvertedSuffix(e, sep)),
1797
+ ...darkStandalone.map((e) => withInvertedSuffix(e, sep))
1798
+ ],
1799
+ // Dark block carries light values under -inverted suffix.
1800
+ darkBlock: [
1801
+ ...lightBase.map((e) => withInvertedSuffix(e, sep)),
1802
+ ...lightStandalone.map((e) => withInvertedSuffix(e, sep))
1803
+ ]
1763
1804
  };
1764
1805
  }
1765
1806
  applyRole(name, color) {
@@ -1930,7 +1971,9 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
1930
1971
  if (this.strongSideVariants.includes(variantName)) {
1931
1972
  return this.strongSideVariants;
1932
1973
  }
1933
- const sampleRole = Object.keys(this.lightPalette).find((r) => r !== "base");
1974
+ const sampleRole = Object.keys(this.lightPalette).find(
1975
+ (r) => r !== "surface"
1976
+ );
1934
1977
  if (!sampleRole) return null;
1935
1978
  const scale = this.lightPalette[sampleRole];
1936
1979
  if (!scale[variantName]) return null;