nhb-toolbox 4.0.76 → 4.0.80

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Color = void 0;
4
4
  const convert_1 = require("./convert");
5
+ const css_colors_1 = require("./css-colors");
5
6
  const helpers_1 = require("./helpers");
6
7
  const random_1 = require("./random");
7
8
  const hsl = (0, random_1.generateRandomHSLColor)();
@@ -9,7 +10,7 @@ const { hex, rgb } = (0, convert_1.convertColorCode)(hsl);
9
10
  /**
10
11
  * * Class representing a color and its conversions among `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` and `HSLA` formats.
11
12
  * * It has 13 instance methods to manipulate and play with the color values.
12
- * * It has 6 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
13
+ * * It has 7 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
13
14
  *
14
15
  * @property hex - The color in `Hex` format.
15
16
  * @property hex8 - The color in `Hex8` format.
@@ -44,7 +45,7 @@ class Color {
44
45
  * - It has 13 instance methods to manipulate and play with the color values.
45
46
  * - Use static methods like `Color.isHex6(color)` to validate color strings.
46
47
  *
47
- * @param toConvert - An optional input color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other (includes the current format) formats.
48
+ * @param color - An optional input color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other (includes the current format) formats.
48
49
  *
49
50
  * @example
50
51
  * // Convert an existing Hex color to all other formats
@@ -68,31 +69,42 @@ class Color {
68
69
  *
69
70
  * @returns Instance of `Color`.
70
71
  */
71
- constructor(toConvert) {
72
- if (toConvert) {
73
- const colors = this.#convertColorToOthers(toConvert);
74
- if ('hex8' in colors) {
75
- // Extract alpha color values (Hex8, RGBA, HSLA)
76
- const rgbaValues = (0, helpers_1._extractAlphaColorValues)(colors.rgba);
77
- const hslaValues = (0, helpers_1._extractAlphaColorValues)(colors.hsla);
78
- this.hex = colors.hex8.toUpperCase().slice(0, 7);
79
- this.hex8 = colors.hex8.toUpperCase();
80
- this.rgb = `rgb(${rgbaValues[0]}, ${rgbaValues[1]}, ${rgbaValues[2]})`;
81
- this.rgba = colors.rgba;
82
- this.hsl = `hsl(${hslaValues[0]}, ${hslaValues[1]}%, ${hslaValues[2]}%)`;
83
- this.hsla = colors.hsla;
72
+ constructor(color) {
73
+ if (color) {
74
+ if (Color.isCSSColor(color)) {
75
+ const newColor = new Color(css_colors_1.CSS_COLORS[color]);
76
+ this.hex = newColor.hex;
77
+ this.hex8 = newColor.hex8;
78
+ this.rgb = newColor.rgb;
79
+ this.rgba = newColor.rgba;
80
+ this.hsl = newColor.hsl;
81
+ this.hsla = newColor.hsla;
84
82
  }
85
83
  else {
86
- // Extract solid color values (Hex, RGB, HSL)
87
- const rgbValues = (0, helpers_1._extractSolidColorValues)(colors.rgb);
88
- const hslValues = (0, helpers_1._extractSolidColorValues)(colors.hsl);
89
- this.hex = colors.hex.toUpperCase();
90
- this.hex8 =
91
- `${colors.hex.toUpperCase()}${(0, helpers_1._convertOpacityToHex)(100)}`;
92
- this.rgb = colors.rgb;
93
- this.rgba = `rgba(${rgbValues[0]}, ${rgbValues[1]}, ${rgbValues[2]}, 1)`;
94
- this.hsl = colors.hsl;
95
- this.hsla = `hsla(${hslValues[0]}, ${hslValues[1]}%, ${hslValues[2]}%, 1)`;
84
+ const colors = this.#convertColorToOthers(color);
85
+ if ('hex8' in colors) {
86
+ // Extract alpha color values (Hex8, RGBA, HSLA)
87
+ const rgbaValues = (0, helpers_1._extractAlphaColorValues)(colors.rgba);
88
+ const hslaValues = (0, helpers_1._extractAlphaColorValues)(colors.hsla);
89
+ this.hex = colors.hex8.toUpperCase().slice(0, 7);
90
+ this.hex8 = colors.hex8.toUpperCase();
91
+ this.rgb = `rgb(${rgbaValues[0]}, ${rgbaValues[1]}, ${rgbaValues[2]})`;
92
+ this.rgba = colors.rgba;
93
+ this.hsl = `hsl(${hslaValues[0]}, ${hslaValues[1]}%, ${hslaValues[2]}%)`;
94
+ this.hsla = colors.hsla;
95
+ }
96
+ else {
97
+ // Extract solid color values (Hex, RGB, HSL)
98
+ const rgbValues = (0, helpers_1._extractSolidColorValues)(colors.rgb);
99
+ const hslValues = (0, helpers_1._extractSolidColorValues)(colors.hsl);
100
+ this.hex = colors.hex.toUpperCase();
101
+ this.hex8 =
102
+ `${colors.hex.toUpperCase()}${(0, helpers_1._convertOpacityToHex)(100)}`;
103
+ this.rgb = colors.rgb;
104
+ this.rgba = `rgba(${rgbValues[0]}, ${rgbValues[1]}, ${rgbValues[2]}, 1)`;
105
+ this.hsl = colors.hsl;
106
+ this.hsla = `hsla(${hslValues[0]}, ${hslValues[1]}%, ${hslValues[2]}%, 1)`;
107
+ }
96
108
  }
97
109
  }
98
110
  else {
@@ -370,6 +382,23 @@ class Color {
370
382
  static isHSLA(color) {
371
383
  return (0, helpers_1._isHSLA)(color);
372
384
  }
385
+ /**
386
+ * * Checks if a color is a valid CSS color name.
387
+ * - This method checks against a predefined list of CSS color names.
388
+ * - It does not validate format types like Hex, RGB, or HSL or their alpha channels.
389
+ *
390
+ * @param color - The color to check.
391
+ * @returns `true` if the color is a valid CSS color name, `false` otherwise.
392
+ */
393
+ static isCSSColor(color) {
394
+ return (!Color.isHex6(color) &&
395
+ !Color.isHex8(color) &&
396
+ !(0, helpers_1._isRGB)(color) &&
397
+ !(0, helpers_1._isRGBA)(color) &&
398
+ !(0, helpers_1._isHSL)(color) &&
399
+ !(0, helpers_1._isHSLA)(color) &&
400
+ color in css_colors_1.CSS_COLORS);
401
+ }
373
402
  /**
374
403
  * @private Converts the given color to all other formats while preserving the original.
375
404
  *
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CSS_COLORS = void 0;
4
+ exports.CSS_COLORS = {
5
+ black: '#000000',
6
+ silver: '#C0C0C0',
7
+ gray: '#808080',
8
+ white: '#FFFFFF',
9
+ maroon: '#800000',
10
+ red: '#FF0000',
11
+ purple: '#800080',
12
+ fuchsia: '#FF00FF',
13
+ green: '#008000',
14
+ lime: '#00FF00',
15
+ olive: '#808000',
16
+ yellow: '#FFFF00',
17
+ navy: '#000080',
18
+ blue: '#0000FF',
19
+ teal: '#008080',
20
+ aqua: '#00FFFF',
21
+ aliceblue: '#F0F8FF',
22
+ antiquewhite: '#FAEBD7',
23
+ aquamarine: '#7FFFD4',
24
+ azure: '#F0FFFF',
25
+ beige: '#F5F5DC',
26
+ bisque: '#FFE4C4',
27
+ blanchedalmond: '#FFEBCD',
28
+ blueviolet: '#8A2BE2',
29
+ brown: '#A52A2A',
30
+ burlywood: '#DEB887',
31
+ cadetblue: '#5F9EA0',
32
+ chartreuse: '#7FFF00',
33
+ chocolate: '#D2691E',
34
+ coral: '#FF7F50',
35
+ cornflowerblue: '#6495ED',
36
+ cornsilk: '#FFF8DC',
37
+ crimson: '#DC143C',
38
+ cyan: '#00FFFF',
39
+ darkblue: '#00008B',
40
+ darkcyan: '#008B8B',
41
+ darkgoldenrod: '#B8860B',
42
+ darkgray: '#A9A9A9',
43
+ darkgreen: '#006400',
44
+ darkgrey: '#A9A9A9',
45
+ darkkhaki: '#BDB76B',
46
+ darkmagenta: '#8B008B',
47
+ darkolivegreen: '#556B2F',
48
+ darkorange: '#FF8C00',
49
+ darkorchid: '#9932CC',
50
+ darkred: '#8B0000',
51
+ darksalmon: '#E9967A',
52
+ darkseagreen: '#8FBC8F',
53
+ darkslateblue: '#483D8B',
54
+ darkslategray: '#2F4F4F',
55
+ darkslategrey: '#2F4F4F',
56
+ darkturquoise: '#00CED1',
57
+ darkviolet: '#9400D3',
58
+ deeppink: '#FF1493',
59
+ deepskyblue: '#00BFFF',
60
+ dimgray: '#696969',
61
+ dimgrey: '#696969',
62
+ dodgerblue: '#1E90FF',
63
+ firebrick: '#B22222',
64
+ floralwhite: '#FFFAF0',
65
+ forestgreen: '#228B22',
66
+ gainsboro: '#DCDCDC',
67
+ ghostwhite: '#F8F8FF',
68
+ gold: '#FFD700',
69
+ goldenrod: '#DAA520',
70
+ greenyellow: '#ADFF2F',
71
+ grey: '#808080',
72
+ honeydew: '#F0FFF0',
73
+ hotpink: '#FF69B4',
74
+ indianred: '#CD5C5C',
75
+ indigo: '#4B0082',
76
+ ivory: '#FFFFF0',
77
+ khaki: '#F0E68C',
78
+ lavender: '#E6E6FA',
79
+ lavenderblush: '#FFF0F5',
80
+ lawngreen: '#7CFC00',
81
+ lemonchiffon: '#FFFACD',
82
+ lightblue: '#ADD8E6',
83
+ lightcoral: '#F08080',
84
+ lightcyan: '#E0FFFF',
85
+ lightgoldenrodyellow: '#FAFAD2',
86
+ lightgray: '#D3D3D3',
87
+ lightgreen: '#90EE90',
88
+ lightgrey: '#D3D3D3',
89
+ lightpink: '#FFB6C1',
90
+ lightsalmon: '#FFA07A',
91
+ lightseagreen: '#20B2AA',
92
+ lightskyblue: '#87CEFA',
93
+ lightslategray: '#778899',
94
+ lightslategrey: '#778899',
95
+ lightsteelblue: '#B0C4DE',
96
+ lightyellow: '#FFFFE0',
97
+ limegreen: '#32CD32',
98
+ linen: '#FAF0E6',
99
+ magenta: '#FF00FF',
100
+ mediumaquamarine: '#66CDAA',
101
+ mediumblue: '#0000CD',
102
+ mediumorchid: '#BA55D3',
103
+ mediumpurple: '#9370DB',
104
+ mediumseagreen: '#3CB371',
105
+ mediumslateblue: '#7B68EE',
106
+ mediumspringgreen: '#00FA9A',
107
+ mediumturquoise: '#48D1CC',
108
+ mediumvioletred: '#C71585',
109
+ midnightblue: '#191970',
110
+ mintcream: '#F5FFFA',
111
+ mistyrose: '#FFE4E1',
112
+ moccasin: '#FFE4B5',
113
+ navajowhite: '#FFDEAD',
114
+ oldlace: '#FDF5E6',
115
+ olivedrab: '#6B8E23',
116
+ orange: '#FFA500',
117
+ orangered: '#FF4500',
118
+ orchid: '#DA70D6',
119
+ palegoldenrod: '#EEE8AA',
120
+ palegreen: '#98FB98',
121
+ paleturquoise: '#AFEEEE',
122
+ palevioletred: '#DB7093',
123
+ papayawhip: '#FFEFD5',
124
+ peachpuff: '#FFDAB9',
125
+ peru: '#CD853F',
126
+ pink: '#FFC0CB',
127
+ plum: '#DDA0DD',
128
+ powderblue: '#B0E0E6',
129
+ rebeccapurple: '#663399',
130
+ rosybrown: '#BC8F8F',
131
+ royalblue: '#4169E1',
132
+ saddlebrown: '#8B4513',
133
+ salmon: '#FA8072',
134
+ sandybrown: '#F4A460',
135
+ seagreen: '#2E8B57',
136
+ seashell: '#FFF5EE',
137
+ sienna: '#A0522D',
138
+ skyblue: '#87CEEB',
139
+ slateblue: '#6A5ACD',
140
+ slategray: '#708090',
141
+ slategrey: '#708090',
142
+ snow: '#FFFAFA',
143
+ springgreen: '#00FF7F',
144
+ steelblue: '#4682B4',
145
+ tan: '#D2B48C',
146
+ thistle: '#D8BFD8',
147
+ tomato: '#FF6347',
148
+ transparent: '#00000000',
149
+ turquoise: '#40E0D0',
150
+ violet: '#EE82EE',
151
+ wheat: '#F5DEB3',
152
+ whitesmoke: '#F5F5F5',
153
+ yellowgreen: '#9ACD32',
154
+ grape: '#CC5DE8',
155
+ dark: '#3B3B3B',
156
+ volcano: '#FA541C',
157
+ geekblue: '#2F54EB',
158
+ success: '#4CAF50',
159
+ info: '#2196F3',
160
+ warning: '#FF9800',
161
+ error: '#F44336',
162
+ };
@@ -1,8 +1,8 @@
1
- import type { Analogous, ColorType, Hex6, Hex8, HSL, HSLA, Percent, RGB, RGBA, Tetrad, Triad } from './types';
1
+ import type { Analogous, ColorType, CSSColor, Hex6, Hex8, HSL, HSLA, Percent, RGB, RGBA, Tetrad, Triad } from './types';
2
2
  /**
3
3
  * * Class representing a color and its conversions among `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` and `HSLA` formats.
4
4
  * * It has 13 instance methods to manipulate and play with the color values.
5
- * * It has 6 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
5
+ * * It has 7 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
6
6
  *
7
7
  * @property hex - The color in `Hex` format.
8
8
  * @property hex8 - The color in `Hex8` format.
@@ -59,9 +59,9 @@ export declare class Color {
59
59
  *
60
60
  * Additionally:
61
61
  * - It has 13 instance methods to manipulate and play with the color values.
62
- * - Use available 6 static methods like `Color.isHex6(color)` to validate color strings.
62
+ * - Use available 7 static methods like `Color.isHex6(color)` to validate color strings.
63
63
  *
64
- * @param toConvert - A color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other formats (includes the current format).
64
+ * @param color - A color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other formats (includes the current format).
65
65
  *
66
66
  * @example
67
67
  * // Convert an existing Hex color to all other formats
@@ -80,7 +80,24 @@ export declare class Color {
80
80
  *
81
81
  * @returns Instance of `Color`.
82
82
  */
83
- constructor(toConvert: ColorType);
83
+ constructor(color: ColorType);
84
+ /**
85
+ * * Creates a new `Color` instance using a standard (CSS) named color and automatically converts it to all other supported formats: `Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, and `HSLA`.
86
+ *
87
+ * @description
88
+ * This allows you to use any valid named color from standard `150+ `CSS color names (e.g., `"red"`, `"blue"`, `"rebeccapurple"`)
89
+ *
90
+ * @param color - A named color string from standard `150+ `CSS color names.
91
+ *
92
+ * @example
93
+ * // Using a CSS named color
94
+ * const sky = new Color("skyblue");
95
+ * console.log(sky.hex); // '#87CEEB'
96
+ * console.log(sky.rgba); // 'rgba(135, 206, 235, 1)'
97
+ *
98
+ * @returns Instance of `Color`.
99
+ */
100
+ constructor(color: CSSColor);
84
101
  /** - Iterates over the color representations (Hex, RGB, HSL). */
85
102
  [Symbol.iterator](): Generator<RGB | HSL | Hex6 | RGBA | Hex8 | HSLA, void, unknown>;
86
103
  /**
@@ -222,5 +239,14 @@ export declare class Color {
222
239
  * @returns `true` if it's a `HSLA` color, `false` if not.
223
240
  */
224
241
  static isHSLA(color: string): color is HSLA;
242
+ /**
243
+ * * Checks if a color is a valid CSS color name.
244
+ * - This method checks against a predefined list of CSS color names.
245
+ * - It does not validate format types like Hex, RGB, or HSL or their alpha channels.
246
+ *
247
+ * @param color - The color to check.
248
+ * @returns `true` if the color is a valid CSS color name, `false` otherwise.
249
+ */
250
+ static isCSSColor(color: string): color is CSSColor;
225
251
  }
226
252
  //# sourceMappingURL=Color.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../src/colors/Color.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEX,SAAS,EAET,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,OAAO,EACP,GAAG,EACH,IAAI,EAEJ,MAAM,EACN,KAAK,EACL,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;;;GAWG;AACH,qBAAa,KAAK;;IACV,GAAG,EAAE,IAAI,CAAC;IACV,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,IAAI,CAAC;IAElB;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;gBACS,SAAS,EAAE,SAAS;IAwFhC,iEAAiE;IAChE,CAAC,MAAM,CAAC,QAAQ,CAAC;IASlB;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAkBrC;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK;IAUtC;;;;OAIG;IACH,eAA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,KAAK;IAWvB;;;;OAIG;IACH,eAAe,IAAI,MAAM;IAczB;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK;IAQtD;;;OAGG;IACH,YAAY,IAAI,OAAO;IAQvB;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG;IAIzC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG;IAIzC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI;IAI3C;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ;CA0DnD"}
@@ -0,0 +1,160 @@
1
+ export declare const CSS_COLORS: {
2
+ readonly black: "#000000";
3
+ readonly silver: "#C0C0C0";
4
+ readonly gray: "#808080";
5
+ readonly white: "#FFFFFF";
6
+ readonly maroon: "#800000";
7
+ readonly red: "#FF0000";
8
+ readonly purple: "#800080";
9
+ readonly fuchsia: "#FF00FF";
10
+ readonly green: "#008000";
11
+ readonly lime: "#00FF00";
12
+ readonly olive: "#808000";
13
+ readonly yellow: "#FFFF00";
14
+ readonly navy: "#000080";
15
+ readonly blue: "#0000FF";
16
+ readonly teal: "#008080";
17
+ readonly aqua: "#00FFFF";
18
+ readonly aliceblue: "#F0F8FF";
19
+ readonly antiquewhite: "#FAEBD7";
20
+ readonly aquamarine: "#7FFFD4";
21
+ readonly azure: "#F0FFFF";
22
+ readonly beige: "#F5F5DC";
23
+ readonly bisque: "#FFE4C4";
24
+ readonly blanchedalmond: "#FFEBCD";
25
+ readonly blueviolet: "#8A2BE2";
26
+ readonly brown: "#A52A2A";
27
+ readonly burlywood: "#DEB887";
28
+ readonly cadetblue: "#5F9EA0";
29
+ readonly chartreuse: "#7FFF00";
30
+ readonly chocolate: "#D2691E";
31
+ readonly coral: "#FF7F50";
32
+ readonly cornflowerblue: "#6495ED";
33
+ readonly cornsilk: "#FFF8DC";
34
+ readonly crimson: "#DC143C";
35
+ readonly cyan: "#00FFFF";
36
+ readonly darkblue: "#00008B";
37
+ readonly darkcyan: "#008B8B";
38
+ readonly darkgoldenrod: "#B8860B";
39
+ readonly darkgray: "#A9A9A9";
40
+ readonly darkgreen: "#006400";
41
+ readonly darkgrey: "#A9A9A9";
42
+ readonly darkkhaki: "#BDB76B";
43
+ readonly darkmagenta: "#8B008B";
44
+ readonly darkolivegreen: "#556B2F";
45
+ readonly darkorange: "#FF8C00";
46
+ readonly darkorchid: "#9932CC";
47
+ readonly darkred: "#8B0000";
48
+ readonly darksalmon: "#E9967A";
49
+ readonly darkseagreen: "#8FBC8F";
50
+ readonly darkslateblue: "#483D8B";
51
+ readonly darkslategray: "#2F4F4F";
52
+ readonly darkslategrey: "#2F4F4F";
53
+ readonly darkturquoise: "#00CED1";
54
+ readonly darkviolet: "#9400D3";
55
+ readonly deeppink: "#FF1493";
56
+ readonly deepskyblue: "#00BFFF";
57
+ readonly dimgray: "#696969";
58
+ readonly dimgrey: "#696969";
59
+ readonly dodgerblue: "#1E90FF";
60
+ readonly firebrick: "#B22222";
61
+ readonly floralwhite: "#FFFAF0";
62
+ readonly forestgreen: "#228B22";
63
+ readonly gainsboro: "#DCDCDC";
64
+ readonly ghostwhite: "#F8F8FF";
65
+ readonly gold: "#FFD700";
66
+ readonly goldenrod: "#DAA520";
67
+ readonly greenyellow: "#ADFF2F";
68
+ readonly grey: "#808080";
69
+ readonly honeydew: "#F0FFF0";
70
+ readonly hotpink: "#FF69B4";
71
+ readonly indianred: "#CD5C5C";
72
+ readonly indigo: "#4B0082";
73
+ readonly ivory: "#FFFFF0";
74
+ readonly khaki: "#F0E68C";
75
+ readonly lavender: "#E6E6FA";
76
+ readonly lavenderblush: "#FFF0F5";
77
+ readonly lawngreen: "#7CFC00";
78
+ readonly lemonchiffon: "#FFFACD";
79
+ readonly lightblue: "#ADD8E6";
80
+ readonly lightcoral: "#F08080";
81
+ readonly lightcyan: "#E0FFFF";
82
+ readonly lightgoldenrodyellow: "#FAFAD2";
83
+ readonly lightgray: "#D3D3D3";
84
+ readonly lightgreen: "#90EE90";
85
+ readonly lightgrey: "#D3D3D3";
86
+ readonly lightpink: "#FFB6C1";
87
+ readonly lightsalmon: "#FFA07A";
88
+ readonly lightseagreen: "#20B2AA";
89
+ readonly lightskyblue: "#87CEFA";
90
+ readonly lightslategray: "#778899";
91
+ readonly lightslategrey: "#778899";
92
+ readonly lightsteelblue: "#B0C4DE";
93
+ readonly lightyellow: "#FFFFE0";
94
+ readonly limegreen: "#32CD32";
95
+ readonly linen: "#FAF0E6";
96
+ readonly magenta: "#FF00FF";
97
+ readonly mediumaquamarine: "#66CDAA";
98
+ readonly mediumblue: "#0000CD";
99
+ readonly mediumorchid: "#BA55D3";
100
+ readonly mediumpurple: "#9370DB";
101
+ readonly mediumseagreen: "#3CB371";
102
+ readonly mediumslateblue: "#7B68EE";
103
+ readonly mediumspringgreen: "#00FA9A";
104
+ readonly mediumturquoise: "#48D1CC";
105
+ readonly mediumvioletred: "#C71585";
106
+ readonly midnightblue: "#191970";
107
+ readonly mintcream: "#F5FFFA";
108
+ readonly mistyrose: "#FFE4E1";
109
+ readonly moccasin: "#FFE4B5";
110
+ readonly navajowhite: "#FFDEAD";
111
+ readonly oldlace: "#FDF5E6";
112
+ readonly olivedrab: "#6B8E23";
113
+ readonly orange: "#FFA500";
114
+ readonly orangered: "#FF4500";
115
+ readonly orchid: "#DA70D6";
116
+ readonly palegoldenrod: "#EEE8AA";
117
+ readonly palegreen: "#98FB98";
118
+ readonly paleturquoise: "#AFEEEE";
119
+ readonly palevioletred: "#DB7093";
120
+ readonly papayawhip: "#FFEFD5";
121
+ readonly peachpuff: "#FFDAB9";
122
+ readonly peru: "#CD853F";
123
+ readonly pink: "#FFC0CB";
124
+ readonly plum: "#DDA0DD";
125
+ readonly powderblue: "#B0E0E6";
126
+ readonly rebeccapurple: "#663399";
127
+ readonly rosybrown: "#BC8F8F";
128
+ readonly royalblue: "#4169E1";
129
+ readonly saddlebrown: "#8B4513";
130
+ readonly salmon: "#FA8072";
131
+ readonly sandybrown: "#F4A460";
132
+ readonly seagreen: "#2E8B57";
133
+ readonly seashell: "#FFF5EE";
134
+ readonly sienna: "#A0522D";
135
+ readonly skyblue: "#87CEEB";
136
+ readonly slateblue: "#6A5ACD";
137
+ readonly slategray: "#708090";
138
+ readonly slategrey: "#708090";
139
+ readonly snow: "#FFFAFA";
140
+ readonly springgreen: "#00FF7F";
141
+ readonly steelblue: "#4682B4";
142
+ readonly tan: "#D2B48C";
143
+ readonly thistle: "#D8BFD8";
144
+ readonly tomato: "#FF6347";
145
+ readonly transparent: "#00000000";
146
+ readonly turquoise: "#40E0D0";
147
+ readonly violet: "#EE82EE";
148
+ readonly wheat: "#F5DEB3";
149
+ readonly whitesmoke: "#F5F5F5";
150
+ readonly yellowgreen: "#9ACD32";
151
+ readonly grape: "#CC5DE8";
152
+ readonly dark: "#3B3B3B";
153
+ readonly volcano: "#FA541C";
154
+ readonly geekblue: "#2F54EB";
155
+ readonly success: "#4CAF50";
156
+ readonly info: "#2196F3";
157
+ readonly warning: "#FF9800";
158
+ readonly error: "#F44336";
159
+ };
160
+ //# sourceMappingURL=css-colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-colors.d.ts","sourceRoot":"","sources":["../../../src/colors/css-colors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Jb,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { Branded } from '../types';
2
2
  import type { Color } from './Color';
3
+ import type { CSS_COLORS } from './css-colors';
3
4
  /** - A string, number for generating color. */
4
5
  export type ColorInput = string | number;
5
6
  /** - An array of strings/numbers or nested arrays of strings/numbers for generating colors. */
@@ -116,7 +117,12 @@ export interface Colors {
116
117
  /** - `HSLA` color (e.g., `hsla(14, 100%, 60%, 1)`) */
117
118
  hsla: HSLA;
118
119
  }
120
+ /** Analogous colors */
119
121
  export type Analogous = [Color, Color, Color];
122
+ /** Triad color */
120
123
  export type Triad = [Color, Color, Color];
124
+ /** Tetrad color */
121
125
  export type Tetrad = [Color, Color, Color, Color];
126
+ /** CSS named color, also includes different response colors */
127
+ export type CSSColor = keyof typeof CSS_COLORS;
122
128
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/colors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,+FAA+F;AAC/F,MAAM,WAAW,eAAgB,SAAQ,KAAK,CAAC,UAAU,GAAG,eAAe,CAAC;CAAG;AAE/E,qEAAqE;AACrE,MAAM,MAAM,OAAO,GAChB,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,C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I,EAAE,IAAI,CAAC;IACX,iDAAiD;IACjD,GAAG,EAAE,GAAG,CAAC;IACT,sDAAsD;IACtD,IAAI,EAAE,IAAI,CAAC;CACX;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE9C,MAAM,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE1C,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/colors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,+FAA+F;AAC/F,MAAM,WAAW,eAAgB,SAAQ,KAAK,CAAC,UAAU,GAAG,eAAe,CAAC;CAAG;AAE/E,qEAAqE;AACrE,MAAM,MAAM,OAAO,GAChB,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,CAAC,GACD,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,GACF,EAAE,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G,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAElD,+DAA+D;AAC/D,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,UAAU,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { convertColorCode } from './convert';
2
+ import { CSS_COLORS } from './css-colors';
2
3
  import { _convertOpacityToHex, _extractAlphaColorValues, _extractSolidColorValues, _isHSL, _isHSLA, _isRGB, _isRGBA, } from './helpers';
3
4
  import { generateRandomHSLColor } from './random';
4
5
  const hsl = generateRandomHSLColor();
@@ -6,7 +7,7 @@ const { hex, rgb } = convertColorCode(hsl);
6
7
  /**
7
8
  * * Class representing a color and its conversions among `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` and `HSLA` formats.
8
9
  * * It has 13 instance methods to manipulate and play with the color values.
9
- * * It has 6 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
10
+ * * It has 7 static methods that can be used to check if a color is in `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` or `HSLA` format.
10
11
  *
11
12
  * @property hex - The color in `Hex` format.
12
13
  * @property hex8 - The color in `Hex8` format.
@@ -41,7 +42,7 @@ export class Color {
41
42
  * - It has 13 instance methods to manipulate and play with the color values.
42
43
  * - Use static methods like `Color.isHex6(color)` to validate color strings.
43
44
  *
44
- * @param toConvert - An optional input color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other (includes the current format) formats.
45
+ * @param color - An optional input color string in any supported format (`Hex`, `Hex8`, `RGB`, `RGBA`, `HSL`, or `HSLA`) to convert in all other (includes the current format) formats.
45
46
  *
46
47
  * @example
47
48
  * // Convert an existing Hex color to all other formats
@@ -65,31 +66,42 @@ export class Color {
65
66
  *
66
67
  * @returns Instance of `Color`.
67
68
  */
68
- constructor(toConvert) {
69
- if (toConvert) {
70
- const colors = this.#convertColorToOthers(toConvert);
71
- if ('hex8' in colors) {
72
- // Extract alpha color values (Hex8, RGBA, HSLA)
73
- const rgbaValues = _extractAlphaColorValues(colors.rgba);
74
- const hslaValues = _extractAlphaColorValues(colors.hsla);
75
- this.hex = colors.hex8.toUpperCase().slice(0, 7);
76
- this.hex8 = colors.hex8.toUpperCase();
77
- this.rgb = `rgb(${rgbaValues[0]}, ${rgbaValues[1]}, ${rgbaValues[2]})`;
78
- this.rgba = colors.rgba;
79
- this.hsl = `hsl(${hslaValues[0]}, ${hslaValues[1]}%, ${hslaValues[2]}%)`;
80
- this.hsla = colors.hsla;
69
+ constructor(color) {
70
+ if (color) {
71
+ if (Color.isCSSColor(color)) {
72
+ const newColor = new Color(CSS_COLORS[color]);
73
+ this.hex = newColor.hex;
74
+ this.hex8 = newColor.hex8;
75
+ this.rgb = newColor.rgb;
76
+ this.rgba = newColor.rgba;
77
+ this.hsl = newColor.hsl;
78
+ this.hsla = newColor.hsla;
81
79
  }
82
80
  else {
83
- // Extract solid color values (Hex, RGB, HSL)
84
- const rgbValues = _extractSolidColorValues(colors.rgb);
85
- const hslValues = _extractSolidColorValues(colors.hsl);
86
- this.hex = colors.hex.toUpperCase();
87
- this.hex8 =
88
- `${colors.hex.toUpperCase()}${_convertOpacityToHex(100)}`;
89
- this.rgb = colors.rgb;
90
- this.rgba = `rgba(${rgbValues[0]}, ${rgbValues[1]}, ${rgbValues[2]}, 1)`;
91
- this.hsl = colors.hsl;
92
- this.hsla = `hsla(${hslValues[0]}, ${hslValues[1]}%, ${hslValues[2]}%, 1)`;
81
+ const colors = this.#convertColorToOthers(color);
82
+ if ('hex8' in colors) {
83
+ // Extract alpha color values (Hex8, RGBA, HSLA)
84
+ const rgbaValues = _extractAlphaColorValues(colors.rgba);
85
+ const hslaValues = _extractAlphaColorValues(colors.hsla);
86
+ this.hex = colors.hex8.toUpperCase().slice(0, 7);
87
+ this.hex8 = colors.hex8.toUpperCase();
88
+ this.rgb = `rgb(${rgbaValues[0]}, ${rgbaValues[1]}, ${rgbaValues[2]})`;
89
+ this.rgba = colors.rgba;
90
+ this.hsl = `hsl(${hslaValues[0]}, ${hslaValues[1]}%, ${hslaValues[2]}%)`;
91
+ this.hsla = colors.hsla;
92
+ }
93
+ else {
94
+ // Extract solid color values (Hex, RGB, HSL)
95
+ const rgbValues = _extractSolidColorValues(colors.rgb);
96
+ const hslValues = _extractSolidColorValues(colors.hsl);
97
+ this.hex = colors.hex.toUpperCase();
98
+ this.hex8 =
99
+ `${colors.hex.toUpperCase()}${_convertOpacityToHex(100)}`;
100
+ this.rgb = colors.rgb;
101
+ this.rgba = `rgba(${rgbValues[0]}, ${rgbValues[1]}, ${rgbValues[2]}, 1)`;
102
+ this.hsl = colors.hsl;
103
+ this.hsla = `hsla(${hslValues[0]}, ${hslValues[1]}%, ${hslValues[2]}%, 1)`;
104
+ }
93
105
  }
94
106
  }
95
107
  else {
@@ -367,6 +379,23 @@ export class Color {
367
379
  static isHSLA(color) {
368
380
  return _isHSLA(color);
369
381
  }
382
+ /**
383
+ * * Checks if a color is a valid CSS color name.
384
+ * - This method checks against a predefined list of CSS color names.
385
+ * - It does not validate format types like Hex, RGB, or HSL or their alpha channels.
386
+ *
387
+ * @param color - The color to check.
388
+ * @returns `true` if the color is a valid CSS color name, `false` otherwise.
389
+ */
390
+ static isCSSColor(color) {
391
+ return (!Color.isHex6(color) &&
392
+ !Color.isHex8(color) &&
393
+ !_isRGB(color) &&
394
+ !_isRGBA(color) &&
395
+ !_isHSL(color) &&
396
+ !_isHSLA(color) &&
397
+ color in CSS_COLORS);
398
+ }
370
399
  /**
371
400
  * @private Converts the given color to all other formats while preserving the original.
372
401
  *
@@ -0,0 +1,159 @@
1
+ export const CSS_COLORS = {
2
+ black: '#000000',
3
+ silver: '#C0C0C0',
4
+ gray: '#808080',
5
+ white: '#FFFFFF',
6
+ maroon: '#800000',
7
+ red: '#FF0000',
8
+ purple: '#800080',
9
+ fuchsia: '#FF00FF',
10
+ green: '#008000',
11
+ lime: '#00FF00',
12
+ olive: '#808000',
13
+ yellow: '#FFFF00',
14
+ navy: '#000080',
15
+ blue: '#0000FF',
16
+ teal: '#008080',
17
+ aqua: '#00FFFF',
18
+ aliceblue: '#F0F8FF',
19
+ antiquewhite: '#FAEBD7',
20
+ aquamarine: '#7FFFD4',
21
+ azure: '#F0FFFF',
22
+ beige: '#F5F5DC',
23
+ bisque: '#FFE4C4',
24
+ blanchedalmond: '#FFEBCD',
25
+ blueviolet: '#8A2BE2',
26
+ brown: '#A52A2A',
27
+ burlywood: '#DEB887',
28
+ cadetblue: '#5F9EA0',
29
+ chartreuse: '#7FFF00',
30
+ chocolate: '#D2691E',
31
+ coral: '#FF7F50',
32
+ cornflowerblue: '#6495ED',
33
+ cornsilk: '#FFF8DC',
34
+ crimson: '#DC143C',
35
+ cyan: '#00FFFF',
36
+ darkblue: '#00008B',
37
+ darkcyan: '#008B8B',
38
+ darkgoldenrod: '#B8860B',
39
+ darkgray: '#A9A9A9',
40
+ darkgreen: '#006400',
41
+ darkgrey: '#A9A9A9',
42
+ darkkhaki: '#BDB76B',
43
+ darkmagenta: '#8B008B',
44
+ darkolivegreen: '#556B2F',
45
+ darkorange: '#FF8C00',
46
+ darkorchid: '#9932CC',
47
+ darkred: '#8B0000',
48
+ darksalmon: '#E9967A',
49
+ darkseagreen: '#8FBC8F',
50
+ darkslateblue: '#483D8B',
51
+ darkslategray: '#2F4F4F',
52
+ darkslategrey: '#2F4F4F',
53
+ darkturquoise: '#00CED1',
54
+ darkviolet: '#9400D3',
55
+ deeppink: '#FF1493',
56
+ deepskyblue: '#00BFFF',
57
+ dimgray: '#696969',
58
+ dimgrey: '#696969',
59
+ dodgerblue: '#1E90FF',
60
+ firebrick: '#B22222',
61
+ floralwhite: '#FFFAF0',
62
+ forestgreen: '#228B22',
63
+ gainsboro: '#DCDCDC',
64
+ ghostwhite: '#F8F8FF',
65
+ gold: '#FFD700',
66
+ goldenrod: '#DAA520',
67
+ greenyellow: '#ADFF2F',
68
+ grey: '#808080',
69
+ honeydew: '#F0FFF0',
70
+ hotpink: '#FF69B4',
71
+ indianred: '#CD5C5C',
72
+ indigo: '#4B0082',
73
+ ivory: '#FFFFF0',
74
+ khaki: '#F0E68C',
75
+ lavender: '#E6E6FA',
76
+ lavenderblush: '#FFF0F5',
77
+ lawngreen: '#7CFC00',
78
+ lemonchiffon: '#FFFACD',
79
+ lightblue: '#ADD8E6',
80
+ lightcoral: '#F08080',
81
+ lightcyan: '#E0FFFF',
82
+ lightgoldenrodyellow: '#FAFAD2',
83
+ lightgray: '#D3D3D3',
84
+ lightgreen: '#90EE90',
85
+ lightgrey: '#D3D3D3',
86
+ lightpink: '#FFB6C1',
87
+ lightsalmon: '#FFA07A',
88
+ lightseagreen: '#20B2AA',
89
+ lightskyblue: '#87CEFA',
90
+ lightslategray: '#778899',
91
+ lightslategrey: '#778899',
92
+ lightsteelblue: '#B0C4DE',
93
+ lightyellow: '#FFFFE0',
94
+ limegreen: '#32CD32',
95
+ linen: '#FAF0E6',
96
+ magenta: '#FF00FF',
97
+ mediumaquamarine: '#66CDAA',
98
+ mediumblue: '#0000CD',
99
+ mediumorchid: '#BA55D3',
100
+ mediumpurple: '#9370DB',
101
+ mediumseagreen: '#3CB371',
102
+ mediumslateblue: '#7B68EE',
103
+ mediumspringgreen: '#00FA9A',
104
+ mediumturquoise: '#48D1CC',
105
+ mediumvioletred: '#C71585',
106
+ midnightblue: '#191970',
107
+ mintcream: '#F5FFFA',
108
+ mistyrose: '#FFE4E1',
109
+ moccasin: '#FFE4B5',
110
+ navajowhite: '#FFDEAD',
111
+ oldlace: '#FDF5E6',
112
+ olivedrab: '#6B8E23',
113
+ orange: '#FFA500',
114
+ orangered: '#FF4500',
115
+ orchid: '#DA70D6',
116
+ palegoldenrod: '#EEE8AA',
117
+ palegreen: '#98FB98',
118
+ paleturquoise: '#AFEEEE',
119
+ palevioletred: '#DB7093',
120
+ papayawhip: '#FFEFD5',
121
+ peachpuff: '#FFDAB9',
122
+ peru: '#CD853F',
123
+ pink: '#FFC0CB',
124
+ plum: '#DDA0DD',
125
+ powderblue: '#B0E0E6',
126
+ rebeccapurple: '#663399',
127
+ rosybrown: '#BC8F8F',
128
+ royalblue: '#4169E1',
129
+ saddlebrown: '#8B4513',
130
+ salmon: '#FA8072',
131
+ sandybrown: '#F4A460',
132
+ seagreen: '#2E8B57',
133
+ seashell: '#FFF5EE',
134
+ sienna: '#A0522D',
135
+ skyblue: '#87CEEB',
136
+ slateblue: '#6A5ACD',
137
+ slategray: '#708090',
138
+ slategrey: '#708090',
139
+ snow: '#FFFAFA',
140
+ springgreen: '#00FF7F',
141
+ steelblue: '#4682B4',
142
+ tan: '#D2B48C',
143
+ thistle: '#D8BFD8',
144
+ tomato: '#FF6347',
145
+ transparent: '#00000000',
146
+ turquoise: '#40E0D0',
147
+ violet: '#EE82EE',
148
+ wheat: '#F5DEB3',
149
+ whitesmoke: '#F5F5F5',
150
+ yellowgreen: '#9ACD32',
151
+ grape: '#CC5DE8',
152
+ dark: '#3B3B3B',
153
+ volcano: '#FA541C',
154
+ geekblue: '#2F54EB',
155
+ success: '#4CAF50',
156
+ info: '#2196F3',
157
+ warning: '#FF9800',
158
+ error: '#F44336',
159
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.0.76",
3
+ "version": "4.0.80",
4
4
  "description": "A versatile collection of smart, efficient, and reusable utility functions and classes for everyday development needs.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",