@tenphi/glaze 0.12.0 → 0.13.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/dist/index.cjs +238 -157
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -58
- package/dist/index.d.mts +76 -58
- package/dist/index.mjs +238 -157
- package/dist/index.mjs.map +1 -1
- package/docs/api.md +135 -69
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -314,11 +314,16 @@ interface ResolvedColor {
|
|
|
314
314
|
/** Adaptation mode. Present only for regular colors, omitted for shadows. */
|
|
315
315
|
mode?: AdaptationMode;
|
|
316
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Lightness window value. A `[lo, hi]` tuple (0–100) or `false` to disable
|
|
319
|
+
* clamping entirely (equivalent to `[0, 100]`).
|
|
320
|
+
*/
|
|
321
|
+
type LightnessWindow = false | [number, number];
|
|
317
322
|
interface GlazeConfig {
|
|
318
|
-
/** Light scheme lightness window [lo, hi]. Default: [10, 100]. */
|
|
319
|
-
lightLightness?:
|
|
320
|
-
/** Dark scheme lightness window [lo, hi]. Default: [15, 95]. */
|
|
321
|
-
darkLightness?:
|
|
323
|
+
/** Light scheme lightness window [lo, hi]. Default: [10, 100]. Pass `false` to disable clamping. */
|
|
324
|
+
lightLightness?: LightnessWindow;
|
|
325
|
+
/** Dark scheme lightness window [lo, hi]. Default: [15, 95]. Pass `false` to disable clamping. */
|
|
326
|
+
darkLightness?: LightnessWindow;
|
|
322
327
|
/** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
|
|
323
328
|
darkDesaturation?: number;
|
|
324
329
|
/**
|
|
@@ -354,8 +359,8 @@ interface GlazeConfig {
|
|
|
354
359
|
autoFlip?: boolean;
|
|
355
360
|
}
|
|
356
361
|
interface GlazeConfigResolved {
|
|
357
|
-
lightLightness:
|
|
358
|
-
darkLightness:
|
|
362
|
+
lightLightness: LightnessWindow;
|
|
363
|
+
darkLightness: LightnessWindow;
|
|
359
364
|
darkDesaturation: number;
|
|
360
365
|
darkCurve: HCPair<number>;
|
|
361
366
|
states: {
|
|
@@ -366,11 +371,37 @@ interface GlazeConfigResolved {
|
|
|
366
371
|
shadowTuning?: ShadowTuning;
|
|
367
372
|
autoFlip: boolean;
|
|
368
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Per-instance config override for `glaze.color()` and `glaze()` themes.
|
|
376
|
+
* Fields that are set take priority over the live global config. Fields
|
|
377
|
+
* that are omitted fall through to the live global at resolve time.
|
|
378
|
+
*
|
|
379
|
+
* `false` for a lightness window disables clamping (equivalent to `[0, 100]`).
|
|
380
|
+
*/
|
|
381
|
+
interface GlazeConfigOverride {
|
|
382
|
+
/** Light scheme lightness window, or `false` to disable clamping. */
|
|
383
|
+
lightLightness?: LightnessWindow;
|
|
384
|
+
/** Dark scheme lightness window, or `false` to disable clamping. */
|
|
385
|
+
darkLightness?: LightnessWindow;
|
|
386
|
+
/** Saturation reduction factor for dark scheme (0–1). */
|
|
387
|
+
darkDesaturation?: number;
|
|
388
|
+
/** Möbius beta for dark auto-inversion. Accepts [normal, hc] pair. */
|
|
389
|
+
darkCurve?: HCPair<number>;
|
|
390
|
+
/** Whether to auto-flip lightness when contrast can't be met. */
|
|
391
|
+
autoFlip?: boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Shadow tuning defaults. Only meaningful for themes; harmless on
|
|
394
|
+
* standalone color tokens.
|
|
395
|
+
*/
|
|
396
|
+
shadowTuning?: ShadowTuning;
|
|
397
|
+
}
|
|
369
398
|
/** Serialized theme configuration (no resolved values). */
|
|
370
399
|
interface GlazeThemeExport {
|
|
371
400
|
hue: number;
|
|
372
401
|
saturation: number;
|
|
373
402
|
colors: ColorMap;
|
|
403
|
+
/** Per-theme config override, if any. */
|
|
404
|
+
config?: GlazeConfigOverride;
|
|
374
405
|
}
|
|
375
406
|
/** Input for `glaze.shadow()` standalone factory. */
|
|
376
407
|
interface GlazeShadowInput {
|
|
@@ -436,7 +467,7 @@ interface GlazeColorInput {
|
|
|
436
467
|
* - `{ l, c, h }` — OKLCh (L/C: 0–1, H: degrees), same as `oklch()` strings.
|
|
437
468
|
*/
|
|
438
469
|
type GlazeColorValue = string | OkhslColor | RgbColor | OklchColor;
|
|
439
|
-
/**
|
|
470
|
+
/** Color overrides for the `from` and value-shorthand inputs. */
|
|
440
471
|
interface GlazeColorOverrides {
|
|
441
472
|
/**
|
|
442
473
|
* Override hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
|
|
@@ -487,6 +518,11 @@ interface GlazeColorOverrides {
|
|
|
487
518
|
* lightness per-scheme (matches theme behavior for dependent colors).
|
|
488
519
|
* - Relative `hue: '+N'` / `'-N'` still anchors to the seed (the
|
|
489
520
|
* value passed to `glaze.color()`), not the base.
|
|
521
|
+
* - When the base was created via the structured form (with explicit
|
|
522
|
+
* `hue`/`saturation`/`lightness`), it is resolved at full range
|
|
523
|
+
* (`lightLightness: false`) for the linking math — ensuring the
|
|
524
|
+
* contrast/lightness anchor matches the input lightness, not the
|
|
525
|
+
* windowed output. The base's own `.resolve()` output is unaffected.
|
|
490
526
|
*
|
|
491
527
|
* The base token's `.resolve()` is called lazily on first resolve and
|
|
492
528
|
* its result is captured by reference; later mutations to the base's
|
|
@@ -507,41 +543,17 @@ interface GlazeColorOverrides {
|
|
|
507
543
|
name?: string;
|
|
508
544
|
}
|
|
509
545
|
/**
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* Defaults for `glaze.color()` vary by input form, and both fields are
|
|
514
|
-
* snapshotted from `globalConfig` at color-creation time so later
|
|
515
|
-
* `glaze.configure()` calls don't retroactively change already-created
|
|
516
|
-
* tokens (and `token.export()` round-trips byte-for-byte):
|
|
517
|
-
*
|
|
518
|
-
* - **Value-shorthand** (hex / `rgb()` / `hsl()` / `okhsl()` / `oklch()`
|
|
519
|
-
* strings, `{ r, g, b }`, `{ h, s, l }`, `{ l, c, h }`):
|
|
520
|
-
* - `lightLightness: false` — preserve input exactly.
|
|
521
|
-
* - `darkLightness: globalConfig.darkLightness` — snapshotted at create time.
|
|
546
|
+
* Object input for `glaze.color()` that carries a raw color value plus
|
|
547
|
+
* optional color overrides in the same object.
|
|
522
548
|
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* Passing this object replaces both fields at once. To keep one
|
|
528
|
-
* field's default while overriding the other, restate the default
|
|
529
|
-
* explicitly.
|
|
549
|
+
* ```ts
|
|
550
|
+
* glaze.color({ from: '#1a1a2e', base: bg, contrast: 'AA' })
|
|
551
|
+
* glaze.color({ from: { r: 38, g: 252, b: 178 }, lightness: '+10' })
|
|
552
|
+
* ```
|
|
530
553
|
*/
|
|
531
|
-
interface
|
|
532
|
-
/**
|
|
533
|
-
|
|
534
|
-
* (preserve input) for value-shorthand inputs; plain
|
|
535
|
-
* `globalConfig.lightLightness` for structured inputs only. Pass
|
|
536
|
-
* `false` to preserve input lightness in light mode.
|
|
537
|
-
*/
|
|
538
|
-
lightLightness?: false | [number, number];
|
|
539
|
-
/**
|
|
540
|
-
* Dark-mode lightness window. Snapshotted from `globalConfig` at
|
|
541
|
-
* create time for value-shorthand and structured inputs. Pass `false`
|
|
542
|
-
* to preserve input lightness in dark mode too.
|
|
543
|
-
*/
|
|
544
|
-
darkLightness?: false | [number, number];
|
|
554
|
+
interface GlazeFromInput extends GlazeColorOverrides {
|
|
555
|
+
/** The source color value. Accepts the same forms as a bare `GlazeColorValue`. */
|
|
556
|
+
from: GlazeColorValue;
|
|
545
557
|
}
|
|
546
558
|
/** Options for `GlazeColorToken.css()`. */
|
|
547
559
|
interface GlazeColorCssOptions {
|
|
@@ -577,7 +589,7 @@ interface GlazeColorToken {
|
|
|
577
589
|
css(options: GlazeColorCssOptions): GlazeCssResult;
|
|
578
590
|
/**
|
|
579
591
|
* Serialize the token as a JSON-safe object. Captures the original
|
|
580
|
-
* input value, overrides, and
|
|
592
|
+
* input value, overrides, and config so it can be rehydrated via
|
|
581
593
|
* `glaze.colorFrom(...)`. `base` is recursively serialized.
|
|
582
594
|
*/
|
|
583
595
|
export(): GlazeColorTokenExport;
|
|
@@ -589,8 +601,8 @@ interface GlazeColorToken {
|
|
|
589
601
|
interface GlazeColorTokenExport {
|
|
590
602
|
/**
|
|
591
603
|
* Discriminator for the source overload that created the token.
|
|
592
|
-
* - `'value'`: created via `glaze.color(value, overrides
|
|
593
|
-
* - `'structured'`: created via `glaze.color({ hue, saturation, ... }
|
|
604
|
+
* - `'value'`: created via `glaze.color(value)` or `glaze.color({ from, ...overrides })`.
|
|
605
|
+
* - `'structured'`: created via `glaze.color({ hue, saturation, ... })`.
|
|
594
606
|
*/
|
|
595
607
|
form: 'value' | 'structured';
|
|
596
608
|
/** Original input. For `form: 'value'` this is the raw `GlazeColorValue`; for `form: 'structured'` this is the structured input. */
|
|
@@ -600,15 +612,14 @@ interface GlazeColorTokenExport {
|
|
|
600
612
|
* serialized. Only present for `form: 'value'`.
|
|
601
613
|
*/
|
|
602
614
|
overrides?: GlazeColorOverridesExport;
|
|
603
|
-
/** Lightness scaling override, if any. */
|
|
604
|
-
scaling?: GlazeColorScaling;
|
|
605
615
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
616
|
+
* Effective config snapshot at creation time — captures the merged
|
|
617
|
+
* result of the global config + any per-call override at the moment
|
|
618
|
+
* the token was created. Only fields that differ from their
|
|
619
|
+
* post-merge defaults are present. Used by `glaze.colorFrom()` to
|
|
620
|
+
* reproduce deterministic behavior across `configure()` calls.
|
|
610
621
|
*/
|
|
611
|
-
|
|
622
|
+
config?: GlazeConfigOverride;
|
|
612
623
|
}
|
|
613
624
|
/**
|
|
614
625
|
* Serializable shape of a structured `glaze.color({...})` input.
|
|
@@ -691,6 +702,8 @@ interface GlazeExtendOptions {
|
|
|
691
702
|
hue?: number;
|
|
692
703
|
saturation?: number;
|
|
693
704
|
colors?: ColorMap;
|
|
705
|
+
/** Config override for the child theme. Merged with the parent's override. */
|
|
706
|
+
config?: GlazeConfigOverride;
|
|
694
707
|
}
|
|
695
708
|
interface GlazeTokenOptions {
|
|
696
709
|
/** Prefix mode. `true` uses "<themeName>-", or provide a custom map. */
|
|
@@ -789,25 +802,30 @@ type PaletteInput = Record<string, GlazeTheme>;
|
|
|
789
802
|
/**
|
|
790
803
|
* Create a single-hue glaze theme.
|
|
791
804
|
*
|
|
805
|
+
* An optional `config` override can be supplied to customize the resolve
|
|
806
|
+
* behavior for this theme (lightness windows, dark curve, etc.). The
|
|
807
|
+
* override is **merged over the live global config at resolve time** —
|
|
808
|
+
* the theme still reacts to later `configure()` calls for fields it
|
|
809
|
+
* didn't override.
|
|
810
|
+
*
|
|
792
811
|
* @example
|
|
793
812
|
* ```ts
|
|
794
|
-
* const primary = glaze({ hue: 280, saturation: 80 });
|
|
795
|
-
* // or shorthand:
|
|
796
813
|
* const primary = glaze(280, 80);
|
|
814
|
+
* // or shorthand:
|
|
815
|
+
* const primary = glaze({ hue: 280, saturation: 80 });
|
|
816
|
+
* // with config override:
|
|
817
|
+
* const raw = glaze(280, 80, { lightLightness: false });
|
|
797
818
|
* ```
|
|
798
819
|
*/
|
|
799
820
|
declare function glaze(hueOrOptions: number | {
|
|
800
821
|
hue: number;
|
|
801
822
|
saturation: number;
|
|
802
|
-
}, saturation?: number): GlazeTheme;
|
|
823
|
+
}, saturation?: number, config?: GlazeConfigOverride): GlazeTheme;
|
|
803
824
|
declare namespace glaze {
|
|
804
825
|
var configure: (config: GlazeConfig) => void;
|
|
805
826
|
var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
|
|
806
827
|
var from: (data: GlazeThemeExport) => GlazeTheme;
|
|
807
|
-
var color:
|
|
808
|
-
(input: GlazeColorInput, scaling?: GlazeColorScaling): GlazeColorToken;
|
|
809
|
-
(value: GlazeColorValue, overrides?: GlazeColorOverrides, scaling?: GlazeColorScaling): GlazeColorToken;
|
|
810
|
-
};
|
|
828
|
+
var color: (input: GlazeFromInput | GlazeColorInput | GlazeColorValue, config?: GlazeConfigOverride) => GlazeColorToken;
|
|
811
829
|
var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
|
|
812
830
|
var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat) => string;
|
|
813
831
|
var fromHex: (hex: string) => GlazeTheme;
|
|
@@ -912,5 +930,5 @@ declare function formatHsl(h: number, s: number, l: number): string;
|
|
|
912
930
|
*/
|
|
913
931
|
declare function formatOklch(h: number, s: number, l: number): string;
|
|
914
932
|
//#endregion
|
|
915
|
-
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type
|
|
933
|
+
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type LightnessWindow, type MinContrast, type MixColorDef, type OkhslColor, type OklchColor, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type RgbColor, type ShadowColorDef, type ShadowTuning, contrastRatioFromLuminance, findLightnessForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, gamutClampedLuminance, glaze, hslToSrgb, okhslToLinearSrgb, okhslToOklab, okhslToSrgb, oklabToOkhsl, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveMinContrast, srgbToOkhsl };
|
|
916
934
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -314,11 +314,16 @@ interface ResolvedColor {
|
|
|
314
314
|
/** Adaptation mode. Present only for regular colors, omitted for shadows. */
|
|
315
315
|
mode?: AdaptationMode;
|
|
316
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Lightness window value. A `[lo, hi]` tuple (0–100) or `false` to disable
|
|
319
|
+
* clamping entirely (equivalent to `[0, 100]`).
|
|
320
|
+
*/
|
|
321
|
+
type LightnessWindow = false | [number, number];
|
|
317
322
|
interface GlazeConfig {
|
|
318
|
-
/** Light scheme lightness window [lo, hi]. Default: [10, 100]. */
|
|
319
|
-
lightLightness?:
|
|
320
|
-
/** Dark scheme lightness window [lo, hi]. Default: [15, 95]. */
|
|
321
|
-
darkLightness?:
|
|
323
|
+
/** Light scheme lightness window [lo, hi]. Default: [10, 100]. Pass `false` to disable clamping. */
|
|
324
|
+
lightLightness?: LightnessWindow;
|
|
325
|
+
/** Dark scheme lightness window [lo, hi]. Default: [15, 95]. Pass `false` to disable clamping. */
|
|
326
|
+
darkLightness?: LightnessWindow;
|
|
322
327
|
/** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
|
|
323
328
|
darkDesaturation?: number;
|
|
324
329
|
/**
|
|
@@ -354,8 +359,8 @@ interface GlazeConfig {
|
|
|
354
359
|
autoFlip?: boolean;
|
|
355
360
|
}
|
|
356
361
|
interface GlazeConfigResolved {
|
|
357
|
-
lightLightness:
|
|
358
|
-
darkLightness:
|
|
362
|
+
lightLightness: LightnessWindow;
|
|
363
|
+
darkLightness: LightnessWindow;
|
|
359
364
|
darkDesaturation: number;
|
|
360
365
|
darkCurve: HCPair<number>;
|
|
361
366
|
states: {
|
|
@@ -366,11 +371,37 @@ interface GlazeConfigResolved {
|
|
|
366
371
|
shadowTuning?: ShadowTuning;
|
|
367
372
|
autoFlip: boolean;
|
|
368
373
|
}
|
|
374
|
+
/**
|
|
375
|
+
* Per-instance config override for `glaze.color()` and `glaze()` themes.
|
|
376
|
+
* Fields that are set take priority over the live global config. Fields
|
|
377
|
+
* that are omitted fall through to the live global at resolve time.
|
|
378
|
+
*
|
|
379
|
+
* `false` for a lightness window disables clamping (equivalent to `[0, 100]`).
|
|
380
|
+
*/
|
|
381
|
+
interface GlazeConfigOverride {
|
|
382
|
+
/** Light scheme lightness window, or `false` to disable clamping. */
|
|
383
|
+
lightLightness?: LightnessWindow;
|
|
384
|
+
/** Dark scheme lightness window, or `false` to disable clamping. */
|
|
385
|
+
darkLightness?: LightnessWindow;
|
|
386
|
+
/** Saturation reduction factor for dark scheme (0–1). */
|
|
387
|
+
darkDesaturation?: number;
|
|
388
|
+
/** Möbius beta for dark auto-inversion. Accepts [normal, hc] pair. */
|
|
389
|
+
darkCurve?: HCPair<number>;
|
|
390
|
+
/** Whether to auto-flip lightness when contrast can't be met. */
|
|
391
|
+
autoFlip?: boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Shadow tuning defaults. Only meaningful for themes; harmless on
|
|
394
|
+
* standalone color tokens.
|
|
395
|
+
*/
|
|
396
|
+
shadowTuning?: ShadowTuning;
|
|
397
|
+
}
|
|
369
398
|
/** Serialized theme configuration (no resolved values). */
|
|
370
399
|
interface GlazeThemeExport {
|
|
371
400
|
hue: number;
|
|
372
401
|
saturation: number;
|
|
373
402
|
colors: ColorMap;
|
|
403
|
+
/** Per-theme config override, if any. */
|
|
404
|
+
config?: GlazeConfigOverride;
|
|
374
405
|
}
|
|
375
406
|
/** Input for `glaze.shadow()` standalone factory. */
|
|
376
407
|
interface GlazeShadowInput {
|
|
@@ -436,7 +467,7 @@ interface GlazeColorInput {
|
|
|
436
467
|
* - `{ l, c, h }` — OKLCh (L/C: 0–1, H: degrees), same as `oklch()` strings.
|
|
437
468
|
*/
|
|
438
469
|
type GlazeColorValue = string | OkhslColor | RgbColor | OklchColor;
|
|
439
|
-
/**
|
|
470
|
+
/** Color overrides for the `from` and value-shorthand inputs. */
|
|
440
471
|
interface GlazeColorOverrides {
|
|
441
472
|
/**
|
|
442
473
|
* Override hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
|
|
@@ -487,6 +518,11 @@ interface GlazeColorOverrides {
|
|
|
487
518
|
* lightness per-scheme (matches theme behavior for dependent colors).
|
|
488
519
|
* - Relative `hue: '+N'` / `'-N'` still anchors to the seed (the
|
|
489
520
|
* value passed to `glaze.color()`), not the base.
|
|
521
|
+
* - When the base was created via the structured form (with explicit
|
|
522
|
+
* `hue`/`saturation`/`lightness`), it is resolved at full range
|
|
523
|
+
* (`lightLightness: false`) for the linking math — ensuring the
|
|
524
|
+
* contrast/lightness anchor matches the input lightness, not the
|
|
525
|
+
* windowed output. The base's own `.resolve()` output is unaffected.
|
|
490
526
|
*
|
|
491
527
|
* The base token's `.resolve()` is called lazily on first resolve and
|
|
492
528
|
* its result is captured by reference; later mutations to the base's
|
|
@@ -507,41 +543,17 @@ interface GlazeColorOverrides {
|
|
|
507
543
|
name?: string;
|
|
508
544
|
}
|
|
509
545
|
/**
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* Defaults for `glaze.color()` vary by input form, and both fields are
|
|
514
|
-
* snapshotted from `globalConfig` at color-creation time so later
|
|
515
|
-
* `glaze.configure()` calls don't retroactively change already-created
|
|
516
|
-
* tokens (and `token.export()` round-trips byte-for-byte):
|
|
517
|
-
*
|
|
518
|
-
* - **Value-shorthand** (hex / `rgb()` / `hsl()` / `okhsl()` / `oklch()`
|
|
519
|
-
* strings, `{ r, g, b }`, `{ h, s, l }`, `{ l, c, h }`):
|
|
520
|
-
* - `lightLightness: false` — preserve input exactly.
|
|
521
|
-
* - `darkLightness: globalConfig.darkLightness` — snapshotted at create time.
|
|
546
|
+
* Object input for `glaze.color()` that carries a raw color value plus
|
|
547
|
+
* optional color overrides in the same object.
|
|
522
548
|
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* Passing this object replaces both fields at once. To keep one
|
|
528
|
-
* field's default while overriding the other, restate the default
|
|
529
|
-
* explicitly.
|
|
549
|
+
* ```ts
|
|
550
|
+
* glaze.color({ from: '#1a1a2e', base: bg, contrast: 'AA' })
|
|
551
|
+
* glaze.color({ from: { r: 38, g: 252, b: 178 }, lightness: '+10' })
|
|
552
|
+
* ```
|
|
530
553
|
*/
|
|
531
|
-
interface
|
|
532
|
-
/**
|
|
533
|
-
|
|
534
|
-
* (preserve input) for value-shorthand inputs; plain
|
|
535
|
-
* `globalConfig.lightLightness` for structured inputs only. Pass
|
|
536
|
-
* `false` to preserve input lightness in light mode.
|
|
537
|
-
*/
|
|
538
|
-
lightLightness?: false | [number, number];
|
|
539
|
-
/**
|
|
540
|
-
* Dark-mode lightness window. Snapshotted from `globalConfig` at
|
|
541
|
-
* create time for value-shorthand and structured inputs. Pass `false`
|
|
542
|
-
* to preserve input lightness in dark mode too.
|
|
543
|
-
*/
|
|
544
|
-
darkLightness?: false | [number, number];
|
|
554
|
+
interface GlazeFromInput extends GlazeColorOverrides {
|
|
555
|
+
/** The source color value. Accepts the same forms as a bare `GlazeColorValue`. */
|
|
556
|
+
from: GlazeColorValue;
|
|
545
557
|
}
|
|
546
558
|
/** Options for `GlazeColorToken.css()`. */
|
|
547
559
|
interface GlazeColorCssOptions {
|
|
@@ -577,7 +589,7 @@ interface GlazeColorToken {
|
|
|
577
589
|
css(options: GlazeColorCssOptions): GlazeCssResult;
|
|
578
590
|
/**
|
|
579
591
|
* Serialize the token as a JSON-safe object. Captures the original
|
|
580
|
-
* input value, overrides, and
|
|
592
|
+
* input value, overrides, and config so it can be rehydrated via
|
|
581
593
|
* `glaze.colorFrom(...)`. `base` is recursively serialized.
|
|
582
594
|
*/
|
|
583
595
|
export(): GlazeColorTokenExport;
|
|
@@ -589,8 +601,8 @@ interface GlazeColorToken {
|
|
|
589
601
|
interface GlazeColorTokenExport {
|
|
590
602
|
/**
|
|
591
603
|
* Discriminator for the source overload that created the token.
|
|
592
|
-
* - `'value'`: created via `glaze.color(value, overrides
|
|
593
|
-
* - `'structured'`: created via `glaze.color({ hue, saturation, ... }
|
|
604
|
+
* - `'value'`: created via `glaze.color(value)` or `glaze.color({ from, ...overrides })`.
|
|
605
|
+
* - `'structured'`: created via `glaze.color({ hue, saturation, ... })`.
|
|
594
606
|
*/
|
|
595
607
|
form: 'value' | 'structured';
|
|
596
608
|
/** Original input. For `form: 'value'` this is the raw `GlazeColorValue`; for `form: 'structured'` this is the structured input. */
|
|
@@ -600,15 +612,14 @@ interface GlazeColorTokenExport {
|
|
|
600
612
|
* serialized. Only present for `form: 'value'`.
|
|
601
613
|
*/
|
|
602
614
|
overrides?: GlazeColorOverridesExport;
|
|
603
|
-
/** Lightness scaling override, if any. */
|
|
604
|
-
scaling?: GlazeColorScaling;
|
|
605
615
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
616
|
+
* Effective config snapshot at creation time — captures the merged
|
|
617
|
+
* result of the global config + any per-call override at the moment
|
|
618
|
+
* the token was created. Only fields that differ from their
|
|
619
|
+
* post-merge defaults are present. Used by `glaze.colorFrom()` to
|
|
620
|
+
* reproduce deterministic behavior across `configure()` calls.
|
|
610
621
|
*/
|
|
611
|
-
|
|
622
|
+
config?: GlazeConfigOverride;
|
|
612
623
|
}
|
|
613
624
|
/**
|
|
614
625
|
* Serializable shape of a structured `glaze.color({...})` input.
|
|
@@ -691,6 +702,8 @@ interface GlazeExtendOptions {
|
|
|
691
702
|
hue?: number;
|
|
692
703
|
saturation?: number;
|
|
693
704
|
colors?: ColorMap;
|
|
705
|
+
/** Config override for the child theme. Merged with the parent's override. */
|
|
706
|
+
config?: GlazeConfigOverride;
|
|
694
707
|
}
|
|
695
708
|
interface GlazeTokenOptions {
|
|
696
709
|
/** Prefix mode. `true` uses "<themeName>-", or provide a custom map. */
|
|
@@ -789,25 +802,30 @@ type PaletteInput = Record<string, GlazeTheme>;
|
|
|
789
802
|
/**
|
|
790
803
|
* Create a single-hue glaze theme.
|
|
791
804
|
*
|
|
805
|
+
* An optional `config` override can be supplied to customize the resolve
|
|
806
|
+
* behavior for this theme (lightness windows, dark curve, etc.). The
|
|
807
|
+
* override is **merged over the live global config at resolve time** —
|
|
808
|
+
* the theme still reacts to later `configure()` calls for fields it
|
|
809
|
+
* didn't override.
|
|
810
|
+
*
|
|
792
811
|
* @example
|
|
793
812
|
* ```ts
|
|
794
|
-
* const primary = glaze({ hue: 280, saturation: 80 });
|
|
795
|
-
* // or shorthand:
|
|
796
813
|
* const primary = glaze(280, 80);
|
|
814
|
+
* // or shorthand:
|
|
815
|
+
* const primary = glaze({ hue: 280, saturation: 80 });
|
|
816
|
+
* // with config override:
|
|
817
|
+
* const raw = glaze(280, 80, { lightLightness: false });
|
|
797
818
|
* ```
|
|
798
819
|
*/
|
|
799
820
|
declare function glaze(hueOrOptions: number | {
|
|
800
821
|
hue: number;
|
|
801
822
|
saturation: number;
|
|
802
|
-
}, saturation?: number): GlazeTheme;
|
|
823
|
+
}, saturation?: number, config?: GlazeConfigOverride): GlazeTheme;
|
|
803
824
|
declare namespace glaze {
|
|
804
825
|
var configure: (config: GlazeConfig) => void;
|
|
805
826
|
var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
|
|
806
827
|
var from: (data: GlazeThemeExport) => GlazeTheme;
|
|
807
|
-
var color:
|
|
808
|
-
(input: GlazeColorInput, scaling?: GlazeColorScaling): GlazeColorToken;
|
|
809
|
-
(value: GlazeColorValue, overrides?: GlazeColorOverrides, scaling?: GlazeColorScaling): GlazeColorToken;
|
|
810
|
-
};
|
|
828
|
+
var color: (input: GlazeFromInput | GlazeColorInput | GlazeColorValue, config?: GlazeConfigOverride) => GlazeColorToken;
|
|
811
829
|
var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
|
|
812
830
|
var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat) => string;
|
|
813
831
|
var fromHex: (hex: string) => GlazeTheme;
|
|
@@ -912,5 +930,5 @@ declare function formatHsl(h: number, s: number, l: number): string;
|
|
|
912
930
|
*/
|
|
913
931
|
declare function formatOklch(h: number, s: number, l: number): string;
|
|
914
932
|
//#endregion
|
|
915
|
-
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type
|
|
933
|
+
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type LightnessWindow, type MinContrast, type MixColorDef, type OkhslColor, type OklchColor, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type RgbColor, type ShadowColorDef, type ShadowTuning, contrastRatioFromLuminance, findLightnessForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, gamutClampedLuminance, glaze, hslToSrgb, okhslToLinearSrgb, okhslToOklab, okhslToSrgb, oklabToOkhsl, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveMinContrast, srgbToOkhsl };
|
|
916
934
|
//# sourceMappingURL=index.d.mts.map
|