colorizr 5.1.0 → 5.1.1
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.d.mts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/extract-color-parts.ts +3 -3
- package/src/index.ts +2 -1
- package/src/modules/validators.ts +2 -2
- package/src/random.ts +1 -1
- package/src/scale.ts +19 -5
- package/src/types/index.ts +0 -2
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,6 @@ type ColorTypeInput = ColorType | 'named';
|
|
|
9
9
|
type ColorValue = ColorModel | HEX;
|
|
10
10
|
type ConverterParameters<TModel extends ColorModel> = TModel | ColorTuple;
|
|
11
11
|
type HEX = `#${string}`;
|
|
12
|
-
type PlainObject<T = any> = Record<string, T>;
|
|
13
12
|
interface Analysis {
|
|
14
13
|
brightnessDifference: number;
|
|
15
14
|
colorDifference: number;
|
|
@@ -524,7 +523,7 @@ declare function desaturate(input: string, amount: number, format?: ColorType):
|
|
|
524
523
|
type ExtractColorPartsReturn = {
|
|
525
524
|
alpha?: number;
|
|
526
525
|
model: ColorModelKey;
|
|
527
|
-
} &
|
|
526
|
+
} & Record<string, number>;
|
|
528
527
|
/**
|
|
529
528
|
* Extract the color parts from a CSS color string.
|
|
530
529
|
* Hex colors are supported via conversion.
|
|
@@ -919,7 +918,7 @@ declare function rotate(input: string, degrees: number, format?: ColorType): str
|
|
|
919
918
|
*/
|
|
920
919
|
declare function saturate(input: string, amount: number, format?: ColorType): string;
|
|
921
920
|
|
|
922
|
-
type ScaleMode = 'light' | 'dark';
|
|
921
|
+
type ScaleMode = 'light' | 'dark' | 'reversed';
|
|
923
922
|
type ScaleVariant = 'deep' | 'neutral' | 'pastel' | 'subtle' | 'vibrant';
|
|
924
923
|
/**
|
|
925
924
|
* Parabolic chroma curve with a movable center.
|
|
@@ -1044,7 +1043,14 @@ interface ScaleOptions {
|
|
|
1044
1043
|
* Theme-aware lightness direction.
|
|
1045
1044
|
*
|
|
1046
1045
|
* - 'light': Low keys (50) are lightest, high keys (950) are darkest
|
|
1047
|
-
* - 'dark': Low keys (50) are darkest, high keys (950) are lightest
|
|
1046
|
+
* - 'dark': Low keys (50) are darkest, high keys (950) are lightest, re-derived
|
|
1047
|
+
* with the lightness ramp running in the dark direction
|
|
1048
|
+
* - 'reversed': the 'light' palette with its keys reversed — identical colors in
|
|
1049
|
+
* mirrored order (50↔950, 100↔900, …)
|
|
1050
|
+
*
|
|
1051
|
+
* `dark` re-derives the scale, so its intermediate steps are not a reversal of
|
|
1052
|
+
* `light` (they coincide only when `lightnessCurve` is linear). `reversed`
|
|
1053
|
+
* re-labels the `light` palette, so it mirrors exactly at any curve.
|
|
1048
1054
|
*
|
|
1049
1055
|
* @default 'light'
|
|
1050
1056
|
*/
|
|
@@ -1142,4 +1148,4 @@ declare function toGamut(input: string, format?: ColorType): string;
|
|
|
1142
1148
|
*/
|
|
1143
1149
|
declare function transparentize(input: string, alpha: number, format?: ColorType): string;
|
|
1144
1150
|
|
|
1145
|
-
export { APCA_VERSION, type Analysis, CLMS_TO_OKLAB, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DEG2RAD, DELTA_E_JND, type FormatCSSOptions, GAMUT_EPSILON, type HEX, type HSL, type HueMode, type LAB, type LCH, LMS_TO_LRGB, LRGB_TO_LMS, type MixOptions, OKLAB_TO_CLMS, P3_TO_SRGB, P3_TO_XYZ, PRECISION, type PaletteOptions,
|
|
1151
|
+
export { APCA_VERSION, type Analysis, CLMS_TO_OKLAB, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DEG2RAD, DELTA_E_JND, type FormatCSSOptions, GAMUT_EPSILON, type HEX, type HSL, type HueMode, type LAB, type LCH, LMS_TO_LRGB, LRGB_TO_LMS, type MixOptions, OKLAB_TO_CLMS, P3_TO_SRGB, P3_TO_XYZ, PRECISION, type PaletteOptions, RAD2DEG, type RGB, type RandomOptions, type ReadableColorMethod, type ReadableColorOptions, SRGB_TO_P3, type ScaleChromaPeak, type ScaleMode, type ScaleOptions, type ScaleRange, type ScaleVariant, type Scheme, type SchemeOptions, XYZ_TO_SRGB, addAlphaToHex, apcaContrast, brightnessDifference, chroma, colorDifference, compare, contrast, convertAlphaToHex, convertCSS, darken, Colorizr as default, deltaE, desaturate, extractAlphaFromHex, extractColorParts, formatCSS, formatHex, getColorType, getP3MaxChroma, getP3MaxColor, getScaleStepKeys, grayscale, hex2hsl, hex2oklab, hex2oklch, hex2rgb, hsl2hex, hsl2oklab, hsl2oklch, hsl2rgb, invert, isHSL, isHex, isInGamut, isLAB, isLCH, isRGB, isValidColor, lighten, luminance, mix, name, oklab2hex, oklab2hsl, oklab2oklch, oklab2rgb, oklabToLinearP3, oklabToLinearSRGB, oklch2hex, oklch2hsl, oklch2oklab, oklch2rgb, opacify, opacity, palette, parseCSS, random, readableColor, removeAlphaFromHex, rgb2hex, rgb2hsl, rgb2oklab, rgb2oklch, rotate, saturate, scale, scheme, srgbGammaDecode, srgbGammaEncode, toGamut, transparentize };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ type ColorTypeInput = ColorType | 'named';
|
|
|
9
9
|
type ColorValue = ColorModel | HEX;
|
|
10
10
|
type ConverterParameters<TModel extends ColorModel> = TModel | ColorTuple;
|
|
11
11
|
type HEX = `#${string}`;
|
|
12
|
-
type PlainObject<T = any> = Record<string, T>;
|
|
13
12
|
interface Analysis {
|
|
14
13
|
brightnessDifference: number;
|
|
15
14
|
colorDifference: number;
|
|
@@ -524,7 +523,7 @@ declare function desaturate(input: string, amount: number, format?: ColorType):
|
|
|
524
523
|
type ExtractColorPartsReturn = {
|
|
525
524
|
alpha?: number;
|
|
526
525
|
model: ColorModelKey;
|
|
527
|
-
} &
|
|
526
|
+
} & Record<string, number>;
|
|
528
527
|
/**
|
|
529
528
|
* Extract the color parts from a CSS color string.
|
|
530
529
|
* Hex colors are supported via conversion.
|
|
@@ -919,7 +918,7 @@ declare function rotate(input: string, degrees: number, format?: ColorType): str
|
|
|
919
918
|
*/
|
|
920
919
|
declare function saturate(input: string, amount: number, format?: ColorType): string;
|
|
921
920
|
|
|
922
|
-
type ScaleMode = 'light' | 'dark';
|
|
921
|
+
type ScaleMode = 'light' | 'dark' | 'reversed';
|
|
923
922
|
type ScaleVariant = 'deep' | 'neutral' | 'pastel' | 'subtle' | 'vibrant';
|
|
924
923
|
/**
|
|
925
924
|
* Parabolic chroma curve with a movable center.
|
|
@@ -1044,7 +1043,14 @@ interface ScaleOptions {
|
|
|
1044
1043
|
* Theme-aware lightness direction.
|
|
1045
1044
|
*
|
|
1046
1045
|
* - 'light': Low keys (50) are lightest, high keys (950) are darkest
|
|
1047
|
-
* - 'dark': Low keys (50) are darkest, high keys (950) are lightest
|
|
1046
|
+
* - 'dark': Low keys (50) are darkest, high keys (950) are lightest, re-derived
|
|
1047
|
+
* with the lightness ramp running in the dark direction
|
|
1048
|
+
* - 'reversed': the 'light' palette with its keys reversed — identical colors in
|
|
1049
|
+
* mirrored order (50↔950, 100↔900, …)
|
|
1050
|
+
*
|
|
1051
|
+
* `dark` re-derives the scale, so its intermediate steps are not a reversal of
|
|
1052
|
+
* `light` (they coincide only when `lightnessCurve` is linear). `reversed`
|
|
1053
|
+
* re-labels the `light` palette, so it mirrors exactly at any curve.
|
|
1048
1054
|
*
|
|
1049
1055
|
* @default 'light'
|
|
1050
1056
|
*/
|
|
@@ -1142,4 +1148,4 @@ declare function toGamut(input: string, format?: ColorType): string;
|
|
|
1142
1148
|
*/
|
|
1143
1149
|
declare function transparentize(input: string, alpha: number, format?: ColorType): string;
|
|
1144
1150
|
|
|
1145
|
-
export { APCA_VERSION, type Analysis, CLMS_TO_OKLAB, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DEG2RAD, DELTA_E_JND, type FormatCSSOptions, GAMUT_EPSILON, type HEX, type HSL, type HueMode, type LAB, type LCH, LMS_TO_LRGB, LRGB_TO_LMS, type MixOptions, OKLAB_TO_CLMS, P3_TO_SRGB, P3_TO_XYZ, PRECISION, type PaletteOptions,
|
|
1151
|
+
export { APCA_VERSION, type Analysis, CLMS_TO_OKLAB, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DEG2RAD, DELTA_E_JND, type FormatCSSOptions, GAMUT_EPSILON, type HEX, type HSL, type HueMode, type LAB, type LCH, LMS_TO_LRGB, LRGB_TO_LMS, type MixOptions, OKLAB_TO_CLMS, P3_TO_SRGB, P3_TO_XYZ, PRECISION, type PaletteOptions, RAD2DEG, type RGB, type RandomOptions, type ReadableColorMethod, type ReadableColorOptions, SRGB_TO_P3, type ScaleChromaPeak, type ScaleMode, type ScaleOptions, type ScaleRange, type ScaleVariant, type Scheme, type SchemeOptions, XYZ_TO_SRGB, addAlphaToHex, apcaContrast, brightnessDifference, chroma, colorDifference, compare, contrast, convertAlphaToHex, convertCSS, darken, Colorizr as default, deltaE, desaturate, extractAlphaFromHex, extractColorParts, formatCSS, formatHex, getColorType, getP3MaxChroma, getP3MaxColor, getScaleStepKeys, grayscale, hex2hsl, hex2oklab, hex2oklch, hex2rgb, hsl2hex, hsl2oklab, hsl2oklch, hsl2rgb, invert, isHSL, isHex, isInGamut, isLAB, isLCH, isRGB, isValidColor, lighten, luminance, mix, name, oklab2hex, oklab2hsl, oklab2oklch, oklab2rgb, oklabToLinearP3, oklabToLinearSRGB, oklch2hex, oklch2hsl, oklch2oklab, oklch2rgb, opacify, opacity, palette, parseCSS, random, readableColor, removeAlphaFromHex, rgb2hex, rgb2hsl, rgb2oklab, rgb2oklch, rotate, saturate, scale, scheme, srgbGammaDecode, srgbGammaEncode, toGamut, transparentize };
|
package/dist/index.js
CHANGED
|
@@ -2397,10 +2397,11 @@ function scale(input, options = {}) {
|
|
|
2397
2397
|
lock,
|
|
2398
2398
|
maxLightness,
|
|
2399
2399
|
minLightness,
|
|
2400
|
-
mode
|
|
2400
|
+
mode: mode === "reversed" ? "light" : mode
|
|
2401
2401
|
});
|
|
2402
|
+
const ordered = mode === "reversed" ? Object.fromEntries(keys.map((key, index) => [key, palette2[keys[keys.length - 1 - index]]])) : palette2;
|
|
2402
2403
|
return Object.fromEntries(
|
|
2403
|
-
Object.entries(
|
|
2404
|
+
Object.entries(ordered).map(([key, value]) => [key, formatCSS(value, { format: colorFormat })])
|
|
2404
2405
|
);
|
|
2405
2406
|
}
|
|
2406
2407
|
|