@tenphi/glaze 0.17.0 → 0.18.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/docs/api.md CHANGED
@@ -403,12 +403,29 @@ A bare number or preset means **WCAG**. Use `{ wcag }` / `{ apca }` to pick the
403
403
  contrast: 4.5 // WCAG 4.5
404
404
  contrast: 'AAA' // WCAG 7
405
405
  contrast: { wcag: 6 } // WCAG 6
406
- contrast: { wcag: [4.5, 7] } // WCAG 4.5 normal / 7 high-contrast
407
- contrast: { apca: 60 } // APCA Lc 60
408
- contrast: { apca: [45, 60] } // APCA Lc 45 normal / 60 high-contrast
409
- contrast: { apca: 'content' } // APCA preset -> Lc 60
410
- contrast: { apca: ['content', 'body'] } // Lc 60 normal / 75 high-contrast
411
- ```
406
+ contrast: { wcag: [4.5, 7] } // WCAG 4.5 normal / 7 high-contrast (explicit)
407
+ contrast: { apca: 60 } // APCA Lc 60 normal / 75 high-contrast (auto)
408
+ contrast: { apca: [45, 60] } // APCA Lc 45 normal / 60 high-contrast (explicit)
409
+ contrast: { apca: 'content' } // APCA preset -> Lc 60 normal / 75 high-contrast (auto)
410
+ contrast: { apca: ['content', 'body'] } // Lc 60 normal / 75 high-contrast (explicit)
411
+ ```
412
+
413
+ **WCAG HC auto-promotion:** a bare WCAG preset (no `[normal, hc]` pair at either
414
+ the outer `contrast` or inner `wcag` level) is automatically promoted to its
415
+ spec-defined "Enhanced" successor in high-contrast mode — `AA` → `AAA` (4.5 → 7)
416
+ and `AA-large` → `AAA-large` (3 → 4.5), per WCAG SC 1.4.3 → 1.4.6. `AAA` and
417
+ `AAA-large` are already the top WCAG tier and are left unchanged; bare numeric
418
+ targets have no successor tier and are also left unchanged. An explicit HC value
419
+ via either pair overrides and skips the promotion.
420
+
421
+ **APCA Enhanced Level (HC auto-boost):** a bare APCA scalar (no `[normal, hc]`
422
+ pair at either the outer `contrast` or inner `apca` level) is automatically
423
+ boosted by **+15 Lc** in high-contrast mode, the APCA analog of WCAG's
424
+ AAA-over-AA step. On by default; an explicit HC value via either pair
425
+ overrides it and skips the boost. The enhanced target is clamped to 106 Lc.
426
+ For large/bold text (where APCA caps contrast at Lc 90 to avoid glare), pass
427
+ an explicit HC pair to hold that ceiling — see
428
+ [`docs/okhst.md`](okhst.md) §Enhanced Level.
412
429
 
413
430
  APCA preset keywords (Bronze Simple Mode conformance levels, role-independent):
414
431
  `'preferred'` (Lc 90), `'body'` (75), `'content'` (60, ~AA), `'large'` (45, ~3:1),
@@ -1465,10 +1482,12 @@ import {
1465
1482
  |---|---|
1466
1483
  | `findToneForContrast(opts)` | Binary-search for the tone (0–1) that meets a contrast floor (WCAG or APCA) against a base color. Returns `{ tone, contrast, met, branch, flipped? }`. |
1467
1484
  | `findValueForMixContrast(opts)` | Same, but searches for a mix `value` (0–1) that meets a contrast floor between a base and a target. |
1468
- | `resolveContrastForMode(spec, isHC)` | Resolves a `ContrastSpec` to `{ metric: 'wcag' \| 'apca', target }` for the requested mode (picks the normal or HC entry of any pair). |
1485
+ | `resolveContrastForMode(spec, isHC, polarity?, outerExplicitHC?)` | Resolves a `ContrastSpec` to `{ metric: 'wcag' \| 'apca', target }` for the requested mode (picks the normal or HC entry of any pair). In HC, applies the metric's auto-enhancement unless `outerExplicitHC` is set or the inner metric pair carries an explicit HC value: APCA +15 Lc (clamped to 106); WCAG AA → AAA / AA-large → AAA-large (AAA-family and bare numbers unchanged). |
1469
1486
  | `resolveMinContrast(value)` | Resolves a `MinContrast` (WCAG preset or number) to a numeric ratio. |
1470
1487
  | `apcaContrast(yText, yBg)` | APCA Lc magnitude (0–106) for two relative luminances. |
1471
1488
 
1489
+ Exported constants: `APCA_PRESETS`, `APCA_HC_ENHANCEMENT` (`15`, the Enhanced Level delta), `APCA_MAX_LC` (`106`).
1490
+
1472
1491
  `findToneForContrast` options:
1473
1492
 
1474
1493
  | Option | Default | Description |
package/docs/okhst.md CHANGED
@@ -239,6 +239,55 @@ contrast: { apca: 'content' } // Lc 60
239
239
  contrast: { apca: ['content', 'body'] } // HC pair: 60 normal, 75 high-contrast
240
240
  ```
241
241
 
242
+ #### Enhanced Level (high-contrast auto-boost)
243
+
244
+ When an APCA target is given as a **bare scalar** (no `[normal, hc]` pair at
245
+ either the outer `contrast` level or the inner `apca` level), Glaze
246
+ automatically applies the APCA-W3 "Enhanced Level" delta — **+15 Lc** — in
247
+ high-contrast mode, analogous to WCAG's AAA-over-AA step. This is on by
248
+ default; provide an explicit HC value via either pair to override it.
249
+
250
+ ```ts
251
+ contrast: { apca: 60 } // Lc 60 normal, Lc 75 high-contrast (auto)
252
+ contrast: { apca: 'content' } // Lc 60 normal, Lc 75 high-contrast (auto)
253
+ contrast: { apca: [60, 90] } // Lc 60 normal, Lc 90 high-contrast (explicit)
254
+ contrast: [{ apca: 60 }, { apca: 90 }] // outer pair: explicit HC, no boost
255
+ contrast: { apca: 'preferred' } // Lc 90 normal, Lc 105 high-contrast (auto)
256
+ contrast: { apca: 100 } // Lc 100 normal, Lc 106 high-contrast (clamped)
257
+ ```
258
+
259
+ The enhanced target is clamped to `APCA_MAX_LC` (106).
260
+
261
+ > **Large-text glare caveat.** APCA-W3 also defines Lc 90 as a *maximum* for
262
+ > very large/bold text (>36px bold) and large areas of color, to prevent
263
+ > excessive glare. The +15 HC boost can therefore push a high baseline (e.g.
264
+ > `preferred` Lc 90 → 105) past that glare ceiling. This is intentional for
265
+ > small/standard text in HC (low-vision readability trumps glare, and small
266
+ > fonts have no APCA maximum), but if your HC tokens serve large/bold text,
267
+ > pass an explicit HC pair (`{ apca: [90, 90] }`) to hold the glare ceiling.
268
+ > Glaze does not model font size, so it can't enforce the large-text cap
269
+ > automatically.
270
+
271
+ #### WCAG HC auto-promotion
272
+
273
+ A bare WCAG preset (no `[normal, hc]` pair at either the outer `contrast` or
274
+ inner `wcag` level) is automatically promoted to its spec-defined "Enhanced"
275
+ successor in high-contrast mode — WCAG SC 1.4.3 (Minimum) → SC 1.4.6
276
+ (Enhanced), the direct analog of APCA's Enhanced Level:
277
+
278
+ ```ts
279
+ contrast: 'AA' // 4.5 normal, 7 high-contrast (auto -> AAA)
280
+ contrast: 'AA-large' // 3 normal, 4.5 high-contrast (auto -> AAA-large)
281
+ contrast: 'AAA' // 7 both modes (top tier, unchanged)
282
+ contrast: 'AAA-large' // 4.5 both modes (top tier, unchanged)
283
+ contrast: 5.5 // 5.5 both modes (bare number, no successor tier)
284
+ contrast: { wcag: ['AA', 'AA'] } // 4.5 both modes (explicit HC, no promotion)
285
+ ```
286
+
287
+ `AAA` and `AAA-large` are already the top WCAG tier and are left unchanged; bare
288
+ numeric targets have no defined successor tier and are also left unchanged. An
289
+ explicit HC value via either pair overrides and skips the promotion.
290
+
242
291
  ## Verification (APCA / WCAG drift)
243
292
 
244
293
  Because chromatic swatches inherit gray's tone-derived lightness but drift in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/glaze",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "OKHST-based color theme generator with WCAG contrast solving for light, dark, and high-contrast schemes",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",