@gridui/palette 0.0.0-stage → 0.0.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/README.md +81 -2
- package/dist/bases.d.ts +3 -0
- package/dist/chunk-5VHUBXDO.js +202 -0
- package/dist/chunk-5VHUBXDO.js.map +7 -0
- package/dist/color.d.ts +26 -0
- package/dist/configuration.d.ts +2 -0
- package/dist/contract.d.ts +27 -0
- package/dist/create-palette.d.ts +2 -0
- package/dist/diagnostics.d.ts +11 -0
- package/dist/engine.d.ts +6 -0
- package/dist/engine.js +19 -0
- package/dist/engine.js.map +7 -0
- package/dist/engines.d.ts +9 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +310 -0
- package/dist/index.js.map +7 -0
- package/dist/roles.d.ts +2 -0
- package/dist/scales.d.ts +2 -0
- package/dist/scheme.d.ts +8 -0
- package/dist/types.d.ts +96 -0
- package/docs/catalog.json +286 -0
- package/docs/color-configuration.md +66 -0
- package/package.json +36 -3
package/README.md
CHANGED
|
@@ -1,3 +1,82 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gridui/palette
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generate a complete GridUI color palette from a seed with a replaceable color engine. The package runs in browsers, build scripts, and servers without React, CSS, or a DOM.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { complementary, createPalette } from "@gridui/palette";
|
|
7
|
+
|
|
8
|
+
const palette = createPalette({
|
|
9
|
+
seed: "#254fd0",
|
|
10
|
+
engine: complementary,
|
|
11
|
+
sources: { secondary: "#007e87" },
|
|
12
|
+
scales: { brand: { 50: "#256a78" } },
|
|
13
|
+
colorVariants: { plain: { light: { roles: { link: "#1746b0" } } } },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
palette.mappings; // Engine suggestions before overrides.
|
|
17
|
+
palette.sources.secondary; // "#007e87"
|
|
18
|
+
palette.colorVariants.plain.light.roles.link; // "#1746b0"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Engine contract
|
|
22
|
+
|
|
23
|
+
Import `@gridui/palette/engine` when you only need source colors or are authoring
|
|
24
|
+
an engine. The entry runs independently of scales, semantic roles, contrast
|
|
25
|
+
diagnostics, Theme, and Storybook.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { complementary, runPaletteEngine } from "@gridui/palette/engine";
|
|
29
|
+
|
|
30
|
+
const { seed, sources, mappings } = runPaletteEngine("#AbC", complementary);
|
|
31
|
+
// seed is "#aabbcc". sources contains all six colors.
|
|
32
|
+
// mappings contains the engine's normalized suggestions in derivation order.
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| Part | Contract |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| Input | One normalized, lowercase, opaque `#rrggbb` seed. The runner accepts `#RGB` or `#RRGGBB` and normalizes it before calling the engine. |
|
|
38
|
+
| Output | A synchronous, ordered, readonly array of `{ from, to, color }`. Each color is an opaque HEX suggestion. Return `[]` to use all source defaults. |
|
|
39
|
+
| Mapping order | Begin at `brand`. Each `from` must be the seed or an earlier target. Each `to` must be a fresh `secondary`, `neutral`, `success`, `warning`, or `danger`. |
|
|
40
|
+
| Fallbacks | Omitted neutral and secondary use the seed. Omitted status colors retain their standard anchors. |
|
|
41
|
+
| Overrides | The engine runs once per generation. Explicit source overrides apply after every suggestion has been computed. Pinning a parent keeps the original child suggestion. |
|
|
42
|
+
| Errors | Invalid seed, output shape, mapping order, target, or HEX value throws `TypeError`. Exceptions from user code propagate to the caller. |
|
|
43
|
+
|
|
44
|
+
## Supply an engine
|
|
45
|
+
|
|
46
|
+
Implement the exported function type. An application can capture its own settings
|
|
47
|
+
in a closure and pass the resulting function directly.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { colorFromOklch, colorToOklch, runPaletteEngine, type PaletteEngine } from "@gridui/palette/engine";
|
|
51
|
+
import { createPalette } from "@gridui/palette";
|
|
52
|
+
|
|
53
|
+
const analogous: PaletteEngine = seed => {
|
|
54
|
+
const color = colorToOklch(seed);
|
|
55
|
+
const secondary = colorFromOklch({ ...color, h: color.h + 35 });
|
|
56
|
+
return [{ from: "brand", to: "secondary", color: secondary }];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const suggestions = runPaletteEngine("#254fd0", analogous);
|
|
60
|
+
const palette = createPalette({ seed: "#254fd0", engine: analogous });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`monochromatic` (default) keeps the seed hue. `complementary` rotates it by
|
|
64
|
+
180° in OKLCH. Both bound secondary lightness and chroma. Enumerate the library
|
|
65
|
+
choices with `Object.keys(builtInPaletteEngines)`. To ship another built-in,
|
|
66
|
+
export its implementation and add it to that collection. Applications supply
|
|
67
|
+
their own engines directly through the function argument or the `engine` option.
|
|
68
|
+
|
|
69
|
+
## Customize and apply
|
|
70
|
+
|
|
71
|
+
Override inputs in increasing detail with `sources`, `scales`, and `colorVariants.<variant>.<mode>`. Use `base` for colors whose dependents should be recalculated and `roles` to pin a particular output. Add `strict: true` to reject final contrast failures. Editors can inspect `diagnostics.failures` while preserving the user's choices. See the [configuration reference](docs/color-configuration.md) for exact precedence and contrast checks.
|
|
72
|
+
|
|
73
|
+
To use a resolved palette with GridUI, load Theme CSS and pass the result to its adapter.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import "@gridui/theme/styles.css";
|
|
77
|
+
import { applyColorTheme, colorThemeFromPalette } from "@gridui/theme";
|
|
78
|
+
|
|
79
|
+
const restore = applyColorTheme(document.documentElement, colorThemeFromPalette(palette));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Explore **Foundations / Palette / Color Wheel**, **Customization**, and **Custom Engine** in Storybook.
|
package/dist/bases.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ColorBase, ColorMode, ColorOverrides, ColorScales, ColorVariant, ColorThemePaletteName } from "./types";
|
|
2
|
+
export declare const moveSurface: (value: string, amount: number) => string;
|
|
3
|
+
export declare const resolveBase: (scales: ColorScales, colorVariant: ColorVariant, mode: ColorMode, palette: ColorThemePaletteName, input: ColorOverrides) => ColorBase;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// src/color.ts
|
|
2
|
+
var black = [0, 0, 0];
|
|
3
|
+
var white = [255, 255, 255];
|
|
4
|
+
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
5
|
+
var hex = (color) => `#${color.map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
|
|
6
|
+
var parseColor = (input) => {
|
|
7
|
+
if (typeof input !== "string" || !/^#(?:[\da-f]{3}|[\da-f]{6})$/i.test(input.trim())) {
|
|
8
|
+
throw new TypeError("Theme color must be an opaque #RGB or #RRGGBB hex color.");
|
|
9
|
+
}
|
|
10
|
+
const value = input.trim().slice(1);
|
|
11
|
+
const expanded = value.length === 3 ? [...value].map((channel) => channel + channel).join("") : value;
|
|
12
|
+
return [
|
|
13
|
+
Number.parseInt(expanded.slice(0, 2), 16),
|
|
14
|
+
Number.parseInt(expanded.slice(2, 4), 16),
|
|
15
|
+
Number.parseInt(expanded.slice(4, 6), 16)
|
|
16
|
+
];
|
|
17
|
+
};
|
|
18
|
+
var normalizeThemeColor = (seed) => hex(parseColor(seed));
|
|
19
|
+
var linear = (channel) => {
|
|
20
|
+
const value = channel / 255;
|
|
21
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
22
|
+
};
|
|
23
|
+
var luminance = (color) => 0.2126 * linear(color[0]) + 0.7152 * linear(color[1]) + 0.0722 * linear(color[2]);
|
|
24
|
+
var contrast = (a, b) => {
|
|
25
|
+
const left = luminance(a);
|
|
26
|
+
const right = luminance(b);
|
|
27
|
+
return (Math.max(left, right) + 0.05) / (Math.min(left, right) + 0.05);
|
|
28
|
+
};
|
|
29
|
+
var foregroundFor = (background) => contrast(black, background) >= contrast(white, background) ? black : white;
|
|
30
|
+
var toLch = (color) => {
|
|
31
|
+
const r = linear(color[0]);
|
|
32
|
+
const g = linear(color[1]);
|
|
33
|
+
const b = linear(color[2]);
|
|
34
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
35
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
36
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
37
|
+
const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
38
|
+
const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
39
|
+
const c = Math.hypot(a, bb);
|
|
40
|
+
return {
|
|
41
|
+
l: clamp(0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 0, 1),
|
|
42
|
+
c: c < 1e-5 ? 0 : c,
|
|
43
|
+
h: c < 1e-5 ? 0 : (Math.atan2(bb, a) * 180 / Math.PI + 360) % 360
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var linearRgb = ({ l, c, h }) => {
|
|
47
|
+
const a = c * Math.cos(h * Math.PI / 180);
|
|
48
|
+
const b = c * Math.sin(h * Math.PI / 180);
|
|
49
|
+
const ll = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
50
|
+
const m = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
51
|
+
const s = (l - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
52
|
+
return [
|
|
53
|
+
4.0767416621 * ll - 3.3077115913 * m + 0.2309699292 * s,
|
|
54
|
+
-1.2684380046 * ll + 2.6097574011 * m - 0.3413193965 * s,
|
|
55
|
+
-0.0041960863 * ll - 0.7034186147 * m + 1.707614701 * s
|
|
56
|
+
];
|
|
57
|
+
};
|
|
58
|
+
var fromLch = (color) => {
|
|
59
|
+
if (color.l <= 0) {
|
|
60
|
+
return black;
|
|
61
|
+
}
|
|
62
|
+
if (color.l >= 1) {
|
|
63
|
+
return white;
|
|
64
|
+
}
|
|
65
|
+
const inGamut = (rgb2) => rgb2.every((channel) => channel >= -1e-7 && channel <= 1.0000001);
|
|
66
|
+
let rgb = linearRgb(color);
|
|
67
|
+
if (!inGamut(rgb)) {
|
|
68
|
+
let low = 0;
|
|
69
|
+
let high = color.c;
|
|
70
|
+
for (let step = 0; step < 24; step++) {
|
|
71
|
+
const middle = (low + high) / 2;
|
|
72
|
+
if (inGamut(linearRgb({ ...color, c: middle }))) {
|
|
73
|
+
low = middle;
|
|
74
|
+
} else {
|
|
75
|
+
high = middle;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
rgb = linearRgb({ ...color, c: low });
|
|
79
|
+
}
|
|
80
|
+
const encode = (value) => Math.round(clamp(value <= 31308e-7 ? 12.92 * value : 1.055 * value ** (1 / 2.4) - 0.055, 0, 1) * 255);
|
|
81
|
+
return [encode(rgb[0]), encode(rgb[1]), encode(rgb[2])];
|
|
82
|
+
};
|
|
83
|
+
var readable = (color, backgrounds, toward, ratio) => {
|
|
84
|
+
for (let step = 0; step <= 100; step++) {
|
|
85
|
+
const candidate = fromLch({ ...color, l: color.l + (toward - color.l) * step / 100 });
|
|
86
|
+
if (backgrounds.every((background) => contrast(candidate, background) >= ratio)) {
|
|
87
|
+
return candidate;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
throw new RangeError("Theme surfaces cannot share a readable foreground.");
|
|
91
|
+
};
|
|
92
|
+
var surfaceAppearance = (background) => foregroundFor(parseColor(background)) === black ? "light" : "dark";
|
|
93
|
+
var colorToOklch = (value) => toLch(parseColor(value));
|
|
94
|
+
var colorFromOklch = (value) => hex(fromLch(value));
|
|
95
|
+
|
|
96
|
+
// src/contract.ts
|
|
97
|
+
var paletteNames = ["neutral", "brand", "secondary", "success", "warning", "danger"];
|
|
98
|
+
var statusNames = ["success", "warning", "danger"];
|
|
99
|
+
var surfaceRoles = ["background", "surface", "surface-hover", "surface-pressed", "selection-background"];
|
|
100
|
+
var textRoles = ["foreground", "muted", "link", "status-success-text", "status-warning-text", "status-danger-text"];
|
|
101
|
+
var indicatorRoles = ["control-border", "focus-color", "selection-indicator", "status-success-border", "status-warning-border", "status-danger-border"];
|
|
102
|
+
var accentRoles = ["accent-background", "accent-hover", "accent-pressed"];
|
|
103
|
+
var colorRoles = [
|
|
104
|
+
...surfaceRoles,
|
|
105
|
+
...textRoles,
|
|
106
|
+
...indicatorRoles,
|
|
107
|
+
...accentRoles,
|
|
108
|
+
"accent-foreground",
|
|
109
|
+
"border",
|
|
110
|
+
"decoration",
|
|
111
|
+
"selection-tint",
|
|
112
|
+
"backdrop"
|
|
113
|
+
];
|
|
114
|
+
var defaultColorSeed = "#254fd0";
|
|
115
|
+
var contrastPolicy = { text: 4.5, indicator: 3 };
|
|
116
|
+
var colorVariantNames = ["soft", "deep", "plain"];
|
|
117
|
+
var modes = ["light", "dark"];
|
|
118
|
+
var scaleSteps = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 98, 100];
|
|
119
|
+
var defaultStatusColors = { success: "#16804a", warning: "#b77900", danger: "#d12c32" };
|
|
120
|
+
|
|
121
|
+
// src/engines.ts
|
|
122
|
+
function secondary(seed, rotation) {
|
|
123
|
+
const { l, c, h } = colorToOklch(seed);
|
|
124
|
+
const color = colorFromOklch({ l: clamp(l, 0.45, 0.75), c: Math.min(c, 0.16), h: (h + rotation) % 360 });
|
|
125
|
+
return { from: "brand", to: "secondary", color };
|
|
126
|
+
}
|
|
127
|
+
var monochromatic = (seed) => [secondary(seed, 0)];
|
|
128
|
+
var complementary = (seed) => [secondary(seed, 180)];
|
|
129
|
+
var builtInPaletteEngines = Object.freeze({ monochromatic, complementary });
|
|
130
|
+
var isBuiltInPaletteEngineName = (name) => typeof name === "string" && Object.hasOwn(builtInPaletteEngines, name);
|
|
131
|
+
|
|
132
|
+
// src/engine.ts
|
|
133
|
+
function runPaletteEngine(seed, engine = monochromatic) {
|
|
134
|
+
const brand = normalizeThemeColor(seed);
|
|
135
|
+
if (typeof engine !== "function") {
|
|
136
|
+
throw new TypeError("engine must be a function.");
|
|
137
|
+
}
|
|
138
|
+
const suggestions = engine(brand);
|
|
139
|
+
if (!Array.isArray(suggestions)) {
|
|
140
|
+
throw new TypeError("engine must return an array of mappings.");
|
|
141
|
+
}
|
|
142
|
+
const sources = { brand, neutral: brand, secondary: brand, ...defaultStatusColors };
|
|
143
|
+
const derived = /* @__PURE__ */ new Set(["brand"]);
|
|
144
|
+
const mappings = [];
|
|
145
|
+
for (const edge of suggestions) {
|
|
146
|
+
const path = `engine.mappings[${mappings.length}]`;
|
|
147
|
+
if (!edge || typeof edge !== "object") {
|
|
148
|
+
throw new TypeError(`${path} must be a mapping.`);
|
|
149
|
+
}
|
|
150
|
+
const { from, to, color } = edge;
|
|
151
|
+
if (!derived.has(from)) {
|
|
152
|
+
throw new TypeError(`${path}.from must be brand or an earlier target.`);
|
|
153
|
+
}
|
|
154
|
+
if (!paletteNames.includes(to) || derived.has(to)) {
|
|
155
|
+
throw new TypeError(`${path}.to must be a new non-brand source.`);
|
|
156
|
+
}
|
|
157
|
+
let candidate;
|
|
158
|
+
try {
|
|
159
|
+
candidate = normalizeThemeColor(color);
|
|
160
|
+
} catch (cause) {
|
|
161
|
+
throw new TypeError(`${path}.color must be opaque #RGB or #RRGGBB.`, { cause });
|
|
162
|
+
}
|
|
163
|
+
mappings.push({ from, to, color: candidate });
|
|
164
|
+
sources[to] = candidate;
|
|
165
|
+
derived.add(to);
|
|
166
|
+
}
|
|
167
|
+
return { seed: brand, sources, mappings };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
black,
|
|
172
|
+
white,
|
|
173
|
+
hex,
|
|
174
|
+
parseColor,
|
|
175
|
+
normalizeThemeColor,
|
|
176
|
+
contrast,
|
|
177
|
+
foregroundFor,
|
|
178
|
+
toLch,
|
|
179
|
+
fromLch,
|
|
180
|
+
readable,
|
|
181
|
+
surfaceAppearance,
|
|
182
|
+
colorToOklch,
|
|
183
|
+
colorFromOklch,
|
|
184
|
+
paletteNames,
|
|
185
|
+
statusNames,
|
|
186
|
+
surfaceRoles,
|
|
187
|
+
textRoles,
|
|
188
|
+
indicatorRoles,
|
|
189
|
+
accentRoles,
|
|
190
|
+
colorRoles,
|
|
191
|
+
defaultColorSeed,
|
|
192
|
+
contrastPolicy,
|
|
193
|
+
colorVariantNames,
|
|
194
|
+
modes,
|
|
195
|
+
scaleSteps,
|
|
196
|
+
monochromatic,
|
|
197
|
+
complementary,
|
|
198
|
+
builtInPaletteEngines,
|
|
199
|
+
isBuiltInPaletteEngineName,
|
|
200
|
+
runPaletteEngine
|
|
201
|
+
};
|
|
202
|
+
//# sourceMappingURL=chunk-5VHUBXDO.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/color.ts", "../src/contract.ts", "../src/engines.ts", "../src/engine.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Palette\n * @namespace ColorTheme\n * @description Color\n */\n\nexport type RGB = readonly [number, number, number];\nexport interface LCH { l: number; c: number; h: number }\n\nexport const black: RGB = [0, 0, 0];\nexport const white: RGB = [255, 255, 255];\nexport const clamp = (value: number, min: number, max: number): number => Math.min(max, Math.max(min, value));\nexport const hex = (color: RGB): string => `#${color.map((channel) => channel.toString(16).padStart(2, \"0\")).join(\"\")}`;\n\nexport const parseColor = (input: string): RGB => {\n if (typeof input !== \"string\" || !/^#(?:[\\da-f]{3}|[\\da-f]{6})$/i.test(input.trim())) {\n throw new TypeError(\"Theme color must be an opaque #RGB or #RRGGBB hex color.\");\n }\n const value = input.trim().slice(1);\n const expanded = value.length === 3 ? [...value].map((channel) => channel + channel).join(\"\") : value;\n return [\n Number.parseInt(expanded.slice(0, 2), 16),\n Number.parseInt(expanded.slice(2, 4), 16),\n Number.parseInt(expanded.slice(4, 6), 16),\n ];\n};\n\nexport const normalizeThemeColor = (seed: string): string => hex(parseColor(seed));\n\nconst linear = (channel: number): number => {\n const value = channel / 255;\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n};\nconst luminance = (color: RGB): number => 0.2126 * linear(color[0]) + 0.7152 * linear(color[1]) + 0.0722 * linear(color[2]);\nexport const contrast = (a: RGB, b: RGB): number => {\n const left = luminance(a);\n const right = luminance(b);\n return (Math.max(left, right) + 0.05) / (Math.min(left, right) + 0.05);\n};\nexport const foregroundFor = (background: RGB): RGB => contrast(black, background) >= contrast(white, background) ? black : white;\n\n// Oklab matrices: Bj\u00F6rn Ottosson's public-domain reference implementation.\n// https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab\nexport const toLch = (color: RGB): LCH => {\n const r = linear(color[0]);\n const g = linear(color[1]);\n const b = linear(color[2]);\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n const a = 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s;\n const bb = 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s;\n const c = Math.hypot(a, bb);\n return {\n l: clamp(0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s, 0, 1),\n c: c < 0.00001 ? 0 : c,\n h: c < 0.00001 ? 0 : (Math.atan2(bb, a) * 180 / Math.PI + 360) % 360,\n };\n};\n\nconst linearRgb = ({ l, c, h }: LCH): RGB => {\n const a = c * Math.cos(h * Math.PI / 180);\n const b = c * Math.sin(h * Math.PI / 180);\n const ll = (l + 0.3963377774 * a + 0.2158037573 * b) ** 3;\n const m = (l - 0.1055613458 * a - 0.0638541728 * b) ** 3;\n const s = (l - 0.0894841775 * a - 1.2914855480 * b) ** 3;\n return [\n 4.0767416621 * ll - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * ll + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * ll - 0.7034186147 * m + 1.7076147010 * s,\n ];\n};\n\nexport const fromLch = (color: LCH): RGB => {\n if (color.l <= 0) {\n return black;\n }\n if (color.l >= 1) {\n return white;\n }\n const inGamut = (rgb: RGB): boolean => rgb.every((channel) => channel >= -0.0000001 && channel <= 1.0000001);\n let rgb = linearRgb(color);\n if (!inGamut(rgb)) {\n // Preserve lightness and hue; reduce chroma to the sRGB boundary before rounding.\n let low = 0;\n let high = color.c;\n for (let step = 0; step < 24; step++) {\n const middle = (low + high) / 2;\n if (inGamut(linearRgb({ ...color, c: middle }))) {\n low = middle;\n } else {\n high = middle;\n }\n }\n rgb = linearRgb({ ...color, c: low });\n }\n const encode = (value: number): number => Math.round(clamp(value <= 0.0031308\n ? 12.92 * value : 1.055 * value ** (1 / 2.4) - 0.055, 0, 1) * 255);\n return [encode(rgb[0]), encode(rgb[1]), encode(rgb[2])];\n};\n\nexport const readable = (color: LCH, backgrounds: readonly RGB[], toward: 0 | 1, ratio: number): RGB => {\n for (let step = 0; step <= 100; step++) {\n const candidate = fromLch({ ...color, l: color.l + (toward - color.l) * step / 100 });\n if (backgrounds.every((background) => contrast(candidate, background) >= ratio)) {\n return candidate;\n }\n }\n // Never silently claim readability if a future scheme introduces incompatible surfaces.\n throw new RangeError(\"Theme surfaces cannot share a readable foreground.\");\n};\n\nexport const surfaceAppearance = (background: string): \"light\" | \"dark\" =>\n foregroundFor(parseColor(background)) === black ? \"light\" : \"dark\";\n\nexport const colorToOklch = (value: string): LCH => toLch(parseColor(value));\nexport const colorFromOklch = (value: LCH): string => hex(fromLch(value));\n", "/**\n * @author WMXPY\n * @package Palette\n * @namespace ColorTheme\n * @description Contract\n */\n\n/** One contract for generated values, CSS scopes, utilities, and diagnostics. */\nexport const paletteNames = [\"neutral\", \"brand\", \"secondary\", \"success\", \"warning\", \"danger\"] as const;\nexport const statusNames = [\"success\", \"warning\", \"danger\"] as const;\nexport const surfaceRoles = [\"background\", \"surface\", \"surface-hover\", \"surface-pressed\", \"selection-background\"] as const;\nexport const textRoles = [\"foreground\", \"muted\", \"link\", \"status-success-text\", \"status-warning-text\", \"status-danger-text\"] as const;\nexport const indicatorRoles = [\"control-border\", \"focus-color\", \"selection-indicator\", \"status-success-border\", \"status-warning-border\", \"status-danger-border\"] as const;\nexport const accentRoles = [\"accent-background\", \"accent-hover\", \"accent-pressed\"] as const;\nexport const colorRoles = [...surfaceRoles, ...textRoles, ...indicatorRoles, ...accentRoles,\n \"accent-foreground\", \"border\", \"decoration\", \"selection-tint\", \"backdrop\"] as const;\nexport const defaultColorSeed = \"#254fd0\";\nexport const contrastPolicy = { text: 4.5, indicator: 3 } as const;\n\nexport const colorVariantNames = [\"soft\", \"deep\", \"plain\"] as const;\nexport const modes = [\"light\", \"dark\"] as const;\nexport const scaleSteps = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 98, 100] as const;\nexport const defaultStatusColors = { success: \"#16804a\", warning: \"#b77900\", danger: \"#d12c32\" } as const;\n", "import { clamp, colorFromOklch, colorToOklch } from \"./color\";\nimport type { PaletteEngine, PaletteMapping } from \"./types\";\n\nfunction secondary(seed: string, rotation: number): PaletteMapping {\n const { l, c, h } = colorToOklch(seed);\n const color = colorFromOklch({ l: clamp(l, 0.45, 0.75), c: Math.min(c, 0.16), h: (h + rotation) % 360 });\n return { from: \"brand\", to: \"secondary\", color };\n}\n\nexport const monochromatic: PaletteEngine = seed => [secondary(seed, 0)];\nexport const complementary: PaletteEngine = seed => [secondary(seed, 180)];\n\nexport const builtInPaletteEngines = Object.freeze({ monochromatic, complementary });\nexport type BuiltInPaletteEngineName = keyof typeof builtInPaletteEngines;\nexport const isBuiltInPaletteEngineName = (name: unknown): name is BuiltInPaletteEngineName =>\n typeof name === \"string\" && Object.hasOwn(builtInPaletteEngines, name);\n", "import { normalizeThemeColor } from \"./color\";\nimport { defaultStatusColors, paletteNames } from \"./contract\";\nimport { monochromatic } from \"./engines\";\nimport type { ColorSources, ColorThemePaletteName, PaletteEngine, PaletteEngineResult, PaletteMapping } from \"./types\";\n\nexport { colorFromOklch, colorToOklch, type LCH } from \"./color\";\nexport { builtInPaletteEngines, complementary, isBuiltInPaletteEngineName, monochromatic, type BuiltInPaletteEngineName } from \"./engines\";\n\nexport type { PaletteEngine, PaletteEngineResult, PaletteMapping } from \"./types\";\n\n/** Run just the source stage. Invalid HEX colors and malformed mapping graphs throw TypeError. */\nexport function runPaletteEngine(seed: string, engine: PaletteEngine = monochromatic): PaletteEngineResult {\n const brand = normalizeThemeColor(seed);\n if (typeof engine !== \"function\") { throw new TypeError(\"engine must be a function.\"); }\n const suggestions = engine(brand);\n if (!Array.isArray(suggestions)) { throw new TypeError(\"engine must return an array of mappings.\"); }\n\n const sources: ColorSources = { brand, neutral: brand, secondary: brand, ...defaultStatusColors };\n const derived = new Set<ColorThemePaletteName>([\"brand\"]);\n const mappings: PaletteMapping[] = [];\n for (const edge of suggestions as readonly (PaletteMapping | null | undefined)[]) {\n const path = `engine.mappings[${mappings.length}]`;\n if (!edge || typeof edge !== \"object\") { throw new TypeError(`${path} must be a mapping.`); }\n const { from, to, color } = edge;\n if (!derived.has(from)) { throw new TypeError(`${path}.from must be brand or an earlier target.`); }\n if (!paletteNames.includes(to) || derived.has(to)) { throw new TypeError(`${path}.to must be a new non-brand source.`); }\n let candidate: string;\n try { candidate = normalizeThemeColor(color); }\n catch (cause) { throw new TypeError(`${path}.color must be opaque #RGB or #RRGGBB.`, { cause }); }\n mappings.push({ from, to, color: candidate });\n sources[to] = candidate;\n derived.add(to);\n }\n return { seed: brand, sources, mappings };\n}\n"],
|
|
5
|
+
"mappings": ";AAUO,IAAM,QAAa,CAAC,GAAG,GAAG,CAAC;AAC3B,IAAM,QAAa,CAAC,KAAK,KAAK,GAAG;AACjC,IAAM,QAAQ,CAAC,OAAe,KAAa,QAAwB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AACrG,IAAM,MAAM,CAAC,UAAuB,IAAI,MAAM,I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AC;AAAA,IAAG;AACjG,aAAS,KAAK,EAAE,MAAM,IAAI,OAAO,UAAU,CAAC;AAC5C,YAAQ,EAAE,IAAI;AACd,YAAQ,IAAI,EAAE;AAAA,EAClB;AACA,SAAO,EAAE,MAAM,OAAO,SAAS,SAAS;AAC5C;",
|
|
6
|
+
"names": ["rgb"]
|
|
7
|
+
}
|
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Palette
|
|
4
|
+
* @namespace ColorTheme
|
|
5
|
+
* @description Color
|
|
6
|
+
*/
|
|
7
|
+
export type RGB = readonly [number, number, number];
|
|
8
|
+
export interface LCH {
|
|
9
|
+
l: number;
|
|
10
|
+
c: number;
|
|
11
|
+
h: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const black: RGB;
|
|
14
|
+
export declare const white: RGB;
|
|
15
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
16
|
+
export declare const hex: (color: RGB) => string;
|
|
17
|
+
export declare const parseColor: (input: string) => RGB;
|
|
18
|
+
export declare const normalizeThemeColor: (seed: string) => string;
|
|
19
|
+
export declare const contrast: (a: RGB, b: RGB) => number;
|
|
20
|
+
export declare const foregroundFor: (background: RGB) => RGB;
|
|
21
|
+
export declare const toLch: (color: RGB) => LCH;
|
|
22
|
+
export declare const fromLch: (color: LCH) => RGB;
|
|
23
|
+
export declare const readable: (color: LCH, backgrounds: readonly RGB[], toward: 0 | 1, ratio: number) => RGB;
|
|
24
|
+
export declare const surfaceAppearance: (background: string) => "light" | "dark";
|
|
25
|
+
export declare const colorToOklch: (value: string) => LCH;
|
|
26
|
+
export declare const colorFromOklch: (value: LCH) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Palette
|
|
4
|
+
* @namespace ColorTheme
|
|
5
|
+
* @description Contract
|
|
6
|
+
*/
|
|
7
|
+
/** One contract for generated values, CSS scopes, utilities, and diagnostics. */
|
|
8
|
+
export declare const paletteNames: readonly ["neutral", "brand", "secondary", "success", "warning", "danger"];
|
|
9
|
+
export declare const statusNames: readonly ["success", "warning", "danger"];
|
|
10
|
+
export declare const surfaceRoles: readonly ["background", "surface", "surface-hover", "surface-pressed", "selection-background"];
|
|
11
|
+
export declare const textRoles: readonly ["foreground", "muted", "link", "status-success-text", "status-warning-text", "status-danger-text"];
|
|
12
|
+
export declare const indicatorRoles: readonly ["control-border", "focus-color", "selection-indicator", "status-success-border", "status-warning-border", "status-danger-border"];
|
|
13
|
+
export declare const accentRoles: readonly ["accent-background", "accent-hover", "accent-pressed"];
|
|
14
|
+
export declare const colorRoles: readonly ["background", "surface", "surface-hover", "surface-pressed", "selection-background", "foreground", "muted", "link", "status-success-text", "status-warning-text", "status-danger-text", "control-border", "focus-color", "selection-indicator", "status-success-border", "status-warning-border", "status-danger-border", "accent-background", "accent-hover", "accent-pressed", "accent-foreground", "border", "decoration", "selection-tint", "backdrop"];
|
|
15
|
+
export declare const defaultColorSeed = "#254fd0";
|
|
16
|
+
export declare const contrastPolicy: {
|
|
17
|
+
readonly text: 4.5;
|
|
18
|
+
readonly indicator: 3;
|
|
19
|
+
};
|
|
20
|
+
export declare const colorVariantNames: readonly ["soft", "deep", "plain"];
|
|
21
|
+
export declare const modes: readonly ["light", "dark"];
|
|
22
|
+
export declare const scaleSteps: readonly [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 98, 100];
|
|
23
|
+
export declare const defaultStatusColors: {
|
|
24
|
+
readonly success: "#16804a";
|
|
25
|
+
readonly warning: "#b77900";
|
|
26
|
+
readonly danger: "#d12c32";
|
|
27
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Palette
|
|
4
|
+
* @namespace ColorTheme
|
|
5
|
+
* @description Diagnostics
|
|
6
|
+
*/
|
|
7
|
+
import type { ColorVariants, ColorThemeDiagnostics } from "./types";
|
|
8
|
+
export declare const diagnose: (colorVariants: ColorVariants) => ColorThemeDiagnostics;
|
|
9
|
+
export declare const assertColorTheme: (theme: {
|
|
10
|
+
diagnostics: ColorThemeDiagnostics;
|
|
11
|
+
}) => void;
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PaletteEngine, PaletteEngineResult } from "./types";
|
|
2
|
+
export { colorFromOklch, colorToOklch, type LCH } from "./color";
|
|
3
|
+
export { builtInPaletteEngines, complementary, isBuiltInPaletteEngineName, monochromatic, type BuiltInPaletteEngineName } from "./engines";
|
|
4
|
+
export type { PaletteEngine, PaletteEngineResult, PaletteMapping } from "./types";
|
|
5
|
+
/** Run just the source stage. Invalid HEX colors and malformed mapping graphs throw TypeError. */
|
|
6
|
+
export declare function runPaletteEngine(seed: string, engine?: PaletteEngine): PaletteEngineResult;
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
builtInPaletteEngines,
|
|
3
|
+
colorFromOklch,
|
|
4
|
+
colorToOklch,
|
|
5
|
+
complementary,
|
|
6
|
+
isBuiltInPaletteEngineName,
|
|
7
|
+
monochromatic,
|
|
8
|
+
runPaletteEngine
|
|
9
|
+
} from "./chunk-5VHUBXDO.js";
|
|
10
|
+
export {
|
|
11
|
+
builtInPaletteEngines,
|
|
12
|
+
colorFromOklch,
|
|
13
|
+
colorToOklch,
|
|
14
|
+
complementary,
|
|
15
|
+
isBuiltInPaletteEngineName,
|
|
16
|
+
monochromatic,
|
|
17
|
+
runPaletteEngine
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PaletteEngine } from "./types";
|
|
2
|
+
export declare const monochromatic: PaletteEngine;
|
|
3
|
+
export declare const complementary: PaletteEngine;
|
|
4
|
+
export declare const builtInPaletteEngines: Readonly<{
|
|
5
|
+
monochromatic: PaletteEngine;
|
|
6
|
+
complementary: PaletteEngine;
|
|
7
|
+
}>;
|
|
8
|
+
export type BuiltInPaletteEngineName = keyof typeof builtInPaletteEngines;
|
|
9
|
+
export declare const isBuiltInPaletteEngineName: (name: unknown) => name is BuiltInPaletteEngineName;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createPalette } from "./create-palette";
|
|
2
|
+
export { runPaletteEngine, builtInPaletteEngines, complementary, isBuiltInPaletteEngineName, monochromatic, type BuiltInPaletteEngineName } from "./engine";
|
|
3
|
+
export { colorFromOklch, colorToOklch, surfaceAppearance, type LCH } from "./color";
|
|
4
|
+
export { colorRoles, colorVariantNames, defaultColorSeed, modes, paletteNames, scaleSteps } from "./contract";
|
|
5
|
+
export { normalizeThemeColor } from "./color";
|
|
6
|
+
export { assertColorTheme } from "./diagnostics";
|
|
7
|
+
export type { ColorBase, ColorMode, ColorOverrides, ColorScale, ColorScales, ColorScaleStep, ColorSources, ColorThemeContrast, ColorThemeDiagnostics, ColorThemePalette, ColorThemePaletteName, ColorThemeRole, ColorThemeSimilarity, ColorThemeStatus, ColorVariant, ColorVariantConfig, ColorVariants, PaletteConfig, PaletteEngine, PaletteEngineResult, PaletteMapping, ResolvedColorVariant, ResolvedPalette, } from "./types";
|