haze-ui 1.22.0 → 1.23.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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Pure OKLCH / OKLab color math. Zero dependencies.
3
+ *
4
+ * Conversion matrices and transfer functions follow Björn Ottosson's OKLab
5
+ * reference implementation (https://bottosson.github.io/posts/oklab/):
6
+ * sRGB gamma encode/decode, the linear-RGB→LMS matrix, the cube/cbrt
7
+ * non-linearity, and the LMS'→OKLab matrix (plus its inverse).
8
+ */
9
+ export type Oklch = {
10
+ l: number;
11
+ c: number;
12
+ h: number;
13
+ alpha?: number;
14
+ };
15
+ /**
16
+ * Reduce chroma until the color fits the sRGB gamut, preserving lightness and
17
+ * hue exactly (unlike an 8-bit hex round-trip, which quantizes all channels).
18
+ */
19
+ export declare function clampChroma(color: Oklch): Oklch;
20
+ /** Parse `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` into OKLCH. */
21
+ export declare function parseHex(hex: string): Oklch;
22
+ /**
23
+ * Parse an `oklch(l c h)` or `oklch(l c h / a)` string. Lightness/chroma may
24
+ * be given as percentages (`62.8%`), hue as degrees (`30deg`); the `none`
25
+ * keyword is accepted for any channel.
26
+ */
27
+ export declare function parseOklch(input: string): Oklch;
28
+ /** Convert OKLCH to an sRGB hex string, gamut-clamped via chroma reduction. */
29
+ export declare function oklchToHex(color: Oklch): string;
30
+ /** Format as a CSS `oklch()` string: l/c to 3 decimals, h to 1 decimal. */
31
+ export declare function formatOklch(color: Oklch): string;
32
+ /** WCAG 2.x contrast ratio via sRGB relative luminance. */
33
+ export declare function wcagContrast(a: Oklch, b: Oklch): number;
34
+ /** Perceptual distance: Euclidean distance in OKLab space. */
35
+ export declare function deltaE(a: Oklch, b: Oklch): number;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * OKLCH-derived color palette — the single source of truth for haze-ui color
3
+ * tokens.
4
+ *
5
+ * Primitive 12-step scales are seeded from the hex values of the previous
6
+ * hand-tuned token system, so every semantic base color lands within ΔE ≤ 1.0
7
+ * of its predecessor. Semantic tokens alias primitive steps; interaction
8
+ * states (hover / active / subtle / focus-ring / border-hover) are emitted as
9
+ * CSS relative-color formulas so consumer overrides of a base color propagate
10
+ * to its derived states at runtime.
11
+ */
12
+ import type { Oklch } from './oklch';
13
+ export type Mode = 'light' | 'dark';
14
+ export type Family = 'gray' | 'blue' | 'green' | 'amber' | 'red';
15
+ export type PrimitiveScales = Record<Mode, Record<Family, readonly string[]>>;
16
+ export type SemanticColorToken = {
17
+ /** CSS custom property name, e.g. '--haze-color-primary'. */
18
+ name: string;
19
+ /** Human-readable label for the docs registry. */
20
+ label: string;
21
+ /** Emitted CSS value per mode: a primitive alias or a relative-color formula. */
22
+ css: Record<Mode, string>;
23
+ /** Concrete computed value per mode (formula math applied to the aliased base). */
24
+ resolved: Record<Mode, Oklch>;
25
+ };
26
+ declare const PRIMITIVES: PrimitiveScales;
27
+ declare const SEMANTIC_COLOR_TOKENS: readonly SemanticColorToken[];
28
+ export { PRIMITIVES, SEMANTIC_COLOR_TOKENS };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haze-ui",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "type": "module",
5
5
  "description": "A React UI component library powered by react-use-control and Linaria",
6
6
  "main": "./dist/index.js",
@@ -89,6 +89,7 @@
89
89
  "@testing-library/jest-dom": "^7.0.1",
90
90
  "@testing-library/react": "^16.3.3",
91
91
  "@testing-library/user-event": "^14.6.6",
92
+ "@types/culori": "^4.0.1",
92
93
  "@types/jest-axe": "^3.5.9",
93
94
  "@types/node": "^26.4.0",
94
95
  "@types/ramda": "^0.32.0",
@@ -102,6 +103,7 @@
102
103
  "babel-plugin-transform-jsx-condition": "^0.1.3",
103
104
  "commitizen": "^4.3.2",
104
105
  "core-js": "^3.50.0",
106
+ "culori": "^4.0.2",
105
107
  "date-fns": "^4.4.0",
106
108
  "eslint": "^10.9.1",
107
109
  "eslint-plugin-compat": "^7.0.2",