hextimator 0.7.0 → 0.8.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 +4 -0
- package/README.md +2 -2
- package/dist/{HextimatePaletteBuilder-Bc-GHsBy.d.ts → HextimatePaletteBuilder-CNjOKwbY.d.ts} +12 -2
- package/dist/{chunk-4WWRI5QJ.js → chunk-KFH2N7CF.js} +7 -6
- package/dist/cli.js +12 -6
- package/dist/{index-B9eHpF-F.d.ts → index-kecVj5cB.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/presets.d.ts +2 -2
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/llms.txt +4 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## Unreleased
|
|
2
|
+
|
|
3
|
+
- Adds optional `keyPrefix` on `HextimateFormatOptions` for flat `as: "object"` and `as: "json"` output (CLI: `--key-prefix`). Use `keyPrefix: "--"` when you want CSS custom property names as object keys without using stylesheet output.
|
|
4
|
+
|
|
1
5
|
## 0.7.0 (Latest)
|
|
2
6
|
|
|
3
7
|
- 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.
|
package/README.md
CHANGED
|
@@ -175,12 +175,12 @@ Both options use internal names (before any `roleNames`/`variantNames` remapping
|
|
|
175
175
|
|
|
176
176
|
All formats return `{ light: { ... }, dark: { ... } }`.
|
|
177
177
|
|
|
178
|
-
- **`"object"`** (default) — plain keys: `accent`, `accent-strong`, …
|
|
178
|
+
- **`"object"`** (default) — plain keys: `accent`, `accent-strong`, … Optional **`keyPrefix: "--"`** gives `--accent`, `--accent-strong`, … when you need CSS-style names without stylesheet output.
|
|
179
179
|
- **`"css"`** — CSS custom properties: `--accent`, `--accent-strong`, …
|
|
180
180
|
- **`"tailwind"`** — nested tokens: `{ accent: { DEFAULT, strong, … } }`
|
|
181
181
|
- **`"tailwind-css"`** — `@theme` block with `--color-accent`, `--color-accent-strong`, …
|
|
182
182
|
- **`"scss"`** — SCSS variables: `$accent`, `$accent-strong`, …
|
|
183
|
-
- **`"json"`** — JSON string of the plain object
|
|
183
|
+
- **`"json"`** — JSON string of the plain object (supports **`keyPrefix`** the same way as **`object`**)
|
|
184
184
|
|
|
185
185
|
### Color value formats
|
|
186
186
|
|
package/dist/{HextimatePaletteBuilder-Bc-GHsBy.d.ts → HextimatePaletteBuilder-CNjOKwbY.d.ts}
RENAMED
|
@@ -257,9 +257,19 @@ interface HextimateFormatOptions {
|
|
|
257
257
|
* Use "_" for "surface_strong", "/" for "surface/strong", etc.
|
|
258
258
|
*/
|
|
259
259
|
separator?: string;
|
|
260
|
+
/**
|
|
261
|
+
* String prepended to every flat token key in `as: "object"` and `as: "json"`.
|
|
262
|
+
* Use `"--"` for CSS custom property names (`"--surface"`, `"--accent-strong"`).
|
|
263
|
+
*
|
|
264
|
+
* Ignored for `scss` (`$` prefix), nested `tailwind`, and stylesheet outputs
|
|
265
|
+
* (`css`, `tailwind-css` already declare variables with `--`).
|
|
266
|
+
*
|
|
267
|
+
* Default: `""` (no prefix).
|
|
268
|
+
*/
|
|
269
|
+
keyPrefix?: string;
|
|
260
270
|
/**
|
|
261
271
|
* Output format.
|
|
262
|
-
* - "object" (default): { surface: "#f2eee8", "surface-strong": "#d4cfc8", ...}
|
|
272
|
+
* - "object" (default): { surface: "#f2eee8", "surface-strong": "#d4cfc8", ...} or with keyPrefix "--": { "--surface": "...", "--surface-strong": "..." }
|
|
263
273
|
* - "css": ready-to-paste CSS stylesheet string with `:root {}` and a dark-mode wrapper
|
|
264
274
|
* - "tailwind": { surface: { DEFAULT: "#f2eee8", strong: "#d4cfc8", weak: "#faf8f6" } }
|
|
265
275
|
* - "scss": { $surface: "#f2eee8", $surface-strong: "#d4cfc8", ...}
|
|
@@ -570,7 +580,7 @@ declare class HextimatePaletteBuilder {
|
|
|
570
580
|
* When a preset has been applied, its format options are used as defaults.
|
|
571
581
|
* Any options passed here override the preset's defaults.
|
|
572
582
|
*
|
|
573
|
-
* @param options Format options controlling output shape (`as`), color serialization (`colors`), role/variant renaming, and
|
|
583
|
+
* @param options Format options controlling output shape (`as`), color serialization (`colors`), role/variant renaming, separator, and optional flat-key `keyPrefix`.
|
|
574
584
|
*/
|
|
575
585
|
format(options: HextimateFormatOptions & {
|
|
576
586
|
as: 'tailwind';
|
|
@@ -868,10 +868,10 @@ function toFlatKey(entry, sep) {
|
|
|
868
868
|
if (entry.isDefault && entry.variant === "DEFAULT") return entry.role;
|
|
869
869
|
return `${entry.role}${sep}${entry.variant}`;
|
|
870
870
|
}
|
|
871
|
-
function formatObject(entries, sep) {
|
|
871
|
+
function formatObject(entries, sep, keyPrefix = "") {
|
|
872
872
|
const result = {};
|
|
873
873
|
for (const entry of entries) {
|
|
874
|
-
result[toFlatKey(entry, sep)] = entry.value;
|
|
874
|
+
result[`${keyPrefix}${toFlatKey(entry, sep)}`] = entry.value;
|
|
875
875
|
}
|
|
876
876
|
return result;
|
|
877
877
|
}
|
|
@@ -890,8 +890,8 @@ function formatTailwind(entries) {
|
|
|
890
890
|
}
|
|
891
891
|
return result;
|
|
892
892
|
}
|
|
893
|
-
function formatJSON(entries, sep) {
|
|
894
|
-
return JSON.stringify(formatObject(entries, sep), null, 2);
|
|
893
|
+
function formatJSON(entries, sep, keyPrefix = "") {
|
|
894
|
+
return JSON.stringify(formatObject(entries, sep, keyPrefix), null, 2);
|
|
895
895
|
}
|
|
896
896
|
function declsFromEntries(entries, sep, prefix, indent) {
|
|
897
897
|
return entries.map((e) => `${indent}${prefix}${toFlatKey(e, sep)}: ${e.value};`).join("\n");
|
|
@@ -950,15 +950,16 @@ function format(palette, options, standaloneTokens) {
|
|
|
950
950
|
const entries = buildTokenEntries(palette, options);
|
|
951
951
|
if (standaloneTokens) entries.push(...standaloneTokens);
|
|
952
952
|
const sep = options?.separator ?? "-";
|
|
953
|
+
const keyPrefix = options?.keyPrefix ?? "";
|
|
953
954
|
switch (options?.as) {
|
|
954
955
|
case "scss":
|
|
955
956
|
return formatSCSS(entries, sep);
|
|
956
957
|
case "tailwind":
|
|
957
958
|
return formatTailwind(entries);
|
|
958
959
|
case "json":
|
|
959
|
-
return formatJSON(entries, sep);
|
|
960
|
+
return formatJSON(entries, sep, keyPrefix);
|
|
960
961
|
default:
|
|
961
|
-
return formatObject(entries, sep);
|
|
962
|
+
return formatObject(entries, sep, keyPrefix);
|
|
962
963
|
}
|
|
963
964
|
}
|
|
964
965
|
function formatStylesheet(lightPalette, darkPalette, options, lightStandalone, darkStandalone) {
|
package/dist/cli.js
CHANGED
|
@@ -876,10 +876,10 @@ function toFlatKey(entry, sep) {
|
|
|
876
876
|
if (entry.isDefault && entry.variant === "DEFAULT") return entry.role;
|
|
877
877
|
return `${entry.role}${sep}${entry.variant}`;
|
|
878
878
|
}
|
|
879
|
-
function formatObject(entries, sep) {
|
|
879
|
+
function formatObject(entries, sep, keyPrefix = "") {
|
|
880
880
|
const result = {};
|
|
881
881
|
for (const entry of entries) {
|
|
882
|
-
result[toFlatKey(entry, sep)] = entry.value;
|
|
882
|
+
result[`${keyPrefix}${toFlatKey(entry, sep)}`] = entry.value;
|
|
883
883
|
}
|
|
884
884
|
return result;
|
|
885
885
|
}
|
|
@@ -898,8 +898,8 @@ function formatTailwind(entries) {
|
|
|
898
898
|
}
|
|
899
899
|
return result;
|
|
900
900
|
}
|
|
901
|
-
function formatJSON(entries, sep) {
|
|
902
|
-
return JSON.stringify(formatObject(entries, sep), null, 2);
|
|
901
|
+
function formatJSON(entries, sep, keyPrefix = "") {
|
|
902
|
+
return JSON.stringify(formatObject(entries, sep, keyPrefix), null, 2);
|
|
903
903
|
}
|
|
904
904
|
function declsFromEntries(entries, sep, prefix, indent) {
|
|
905
905
|
return entries.map((e) => `${indent}${prefix}${toFlatKey(e, sep)}: ${e.value};`).join("\n");
|
|
@@ -958,15 +958,16 @@ function format(palette, options, standaloneTokens) {
|
|
|
958
958
|
const entries = buildTokenEntries(palette, options);
|
|
959
959
|
if (standaloneTokens) entries.push(...standaloneTokens);
|
|
960
960
|
const sep = options?.separator ?? "-";
|
|
961
|
+
const keyPrefix = options?.keyPrefix ?? "";
|
|
961
962
|
switch (options?.as) {
|
|
962
963
|
case "scss":
|
|
963
964
|
return formatSCSS(entries, sep);
|
|
964
965
|
case "tailwind":
|
|
965
966
|
return formatTailwind(entries);
|
|
966
967
|
case "json":
|
|
967
|
-
return formatJSON(entries, sep);
|
|
968
|
+
return formatJSON(entries, sep, keyPrefix);
|
|
968
969
|
default:
|
|
969
|
-
return formatObject(entries, sep);
|
|
970
|
+
return formatObject(entries, sep, keyPrefix);
|
|
970
971
|
}
|
|
971
972
|
}
|
|
972
973
|
function formatStylesheet(lightPalette, darkPalette, options, lightStandalone, darkStandalone) {
|
|
@@ -2339,6 +2340,7 @@ Format options:
|
|
|
2339
2340
|
--dark-mode <strategy> media | class | data-attribute | off (css/tailwind-css only, default: media)
|
|
2340
2341
|
--selector <css> Root selector for css output (default: :root)
|
|
2341
2342
|
--separator <char> Token separator (default: -)
|
|
2343
|
+
--key-prefix <str> Prepend to keys (object/json only); use -- for CSS vars (default: empty)
|
|
2342
2344
|
--exclude-role <name> Omit a role from output (repeatable)
|
|
2343
2345
|
--exclude-variant <name> Omit a variant from output (repeatable)
|
|
2344
2346
|
|
|
@@ -2398,6 +2400,7 @@ function run() {
|
|
|
2398
2400
|
"dark-mode": { type: "string" },
|
|
2399
2401
|
selector: { type: "string" },
|
|
2400
2402
|
separator: { type: "string" },
|
|
2403
|
+
"key-prefix": { type: "string" },
|
|
2401
2404
|
"exclude-role": { type: "string", multiple: true },
|
|
2402
2405
|
"exclude-variant": { type: "string", multiple: true },
|
|
2403
2406
|
"surface-color": { type: "string" },
|
|
@@ -2566,6 +2569,9 @@ function run() {
|
|
|
2566
2569
|
} else if (!hasPreset) {
|
|
2567
2570
|
formatOptions.separator = "-";
|
|
2568
2571
|
}
|
|
2572
|
+
if (values["key-prefix"] !== void 0) {
|
|
2573
|
+
formatOptions.keyPrefix = values["key-prefix"];
|
|
2574
|
+
}
|
|
2569
2575
|
if (values["exclude-role"]?.length) {
|
|
2570
2576
|
formatOptions.excludeRoles = values["exclude-role"];
|
|
2571
2577
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-
|
|
2
|
-
export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimateOptions, h as HextimatePreset, i as HextimateResult, j as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-
|
|
3
|
-
export { i as presets } from './index-
|
|
1
|
+
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-CNjOKwbY.js';
|
|
2
|
+
export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimateOptions, h as HextimatePreset, i as HextimateResult, j as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-CNjOKwbY.js';
|
|
3
|
+
export { i as presets } from './index-kecVj5cB.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Daltonize a color for a specific type of color vision deficiency (CVD).
|
package/dist/index.js
CHANGED
package/dist/presets.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-
|
|
2
|
-
export { h as HextimatePreset } from './HextimatePaletteBuilder-
|
|
1
|
+
export { b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-kecVj5cB.js';
|
|
2
|
+
export { h as HextimatePreset } from './HextimatePaletteBuilder-CNjOKwbY.js';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as HextimateStyleOptions, h as HextimatePreset, H as HextimatePaletteBuilder, i as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-
|
|
1
|
+
import { j as HextimateStyleOptions, h as HextimatePreset, H as HextimatePaletteBuilder, i as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-CNjOKwbY.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
package/llms.txt
CHANGED
|
@@ -57,18 +57,19 @@ Tune how the palette is built with `.style(partial)` (`HextimateStyleOptions`, s
|
|
|
57
57
|
| `roleNames` | `Record<string, string>` — rename roles in output keys | built-in names |
|
|
58
58
|
| `variantNames` | `Record<string, string>` — rename variant suffixes | built-in names |
|
|
59
59
|
| `separator` | `string` — between role and variant in keys | `"-"` |
|
|
60
|
+
| `keyPrefix` | `string` — prepended to each key (`object` / `json` only); e.g. `"--"` for CSS vars | `""` |
|
|
60
61
|
| `darkMode` | `"media"`, `"class"`, `"data-attribute"`, `false` (stylesheet outputs only) | `"media"` |
|
|
61
62
|
| `selector` | `string` — root selector for `as: "css"` | `":root"` |
|
|
62
63
|
| `excludeRoles` | `string[]` — role keys to omit entirely from output (by internal name, before `roleNames`) | `[]` |
|
|
63
64
|
| `excludeVariants` | `string[]` — variant keys to omit from every role's output (by internal name, before `variantNames`) | `[]` |
|
|
64
65
|
|
|
65
66
|
Output shape depends on `as`:
|
|
66
|
-
- `"object"` → `{ light, dark }` flat maps: `{ accent: "#...", "accent-strong": "#..." }`
|
|
67
|
+
- `"object"` → `{ light, dark }` flat maps: `{ accent: "#...", "accent-strong": "#..." }` (with `keyPrefix: "--"`: `{ "--accent": "...", "--accent-strong": "..." }`)
|
|
67
68
|
- `"css"` → `string` — ready-to-paste CSS stylesheet with `:root {}` and a dark-mode wrapper
|
|
68
69
|
- `"tailwind"` → `{ light, dark }` nested maps: `{ accent: { DEFAULT: "#...", strong: "#..." } }`
|
|
69
70
|
- `"tailwind-css"` → `string` — Tailwind v4 stylesheet: single `@theme { --color-accent: #...; }` block plus dark overrides
|
|
70
71
|
- `"scss"` → `{ light, dark }` flat maps: `{ "$accent": "#...", "$accent-strong": "#..." }`
|
|
71
|
-
- `"json"` → `{ light, dark }` JSON strings
|
|
72
|
+
- `"json"` → `{ light, dark }` JSON strings (`keyPrefix` applies like `"object"`)
|
|
72
73
|
|
|
73
74
|
Pick the dark wrapper with `darkMode`: `"media"` (default) wraps dark tokens in `@media (prefers-color-scheme: dark)`; `"class"` uses `.dark`; `"data-attribute"` uses `[data-theme="dark"]`; `false` omits dark entirely. For `as: "css"`, change the root selector with `selector` (e.g. `selector: "[data-theme]"`).
|
|
74
75
|
|
|
@@ -298,6 +299,7 @@ Both commands are identical. Use whichever you prefer.
|
|
|
298
299
|
| `-t, --theme` | `light`, `dark`, `both` (ignored for `css`/`tailwind-css` — both always combine into one string) | `both` |
|
|
299
300
|
| `-p, --preset` | Apply preset (repeatable, applied in order): `shadcn`, `mui`, `muted`, `vibrant`, `tinted` | — |
|
|
300
301
|
| `--separator` | Token separator between role and variant | `-` |
|
|
302
|
+
| `--key-prefix` | Prepend to keys (`object` / `json` only); pass `--` for CSS custom properties | empty |
|
|
301
303
|
| `--dark-mode` | `media`, `class`, `data-attribute`, `false` (stylesheet outputs only) | `media` |
|
|
302
304
|
| `--selector` | Root selector for `--format css` | `:root` |
|
|
303
305
|
| `--exclude-role` | Omit a role from output by internal name (repeatable) | — |
|
package/package.json
CHANGED