nhb-toolbox 4.28.56 → 4.28.60

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/CHANGELOG.md CHANGED
@@ -4,9 +4,20 @@
4
4
 
5
5
  All notable changes to the package will be documented here.
6
6
 
7
+ ## [4.28.60] - 2026-01-13
8
+
9
+ - **Fixed** `Chronos.getZodiacSign` boundary handling to correctly wrap across year transitions for *zodiac presets*.
10
+ - **Improved** zodiac resolution logic to ensure consistent results for early-January dates without altering existing zodiac presets.
11
+ - **Updated** `ZodiacArray` and `ZodiacOptions` types to support custom zodiac definitions with *correctly inferred sign names*.
12
+
13
+ ## [4.28.57] - 2026-01-07
14
+
15
+ - **Enhanced** `Color.isLightColor` with an *optional brightness threshold* for custom light/dark detection.
16
+ - **Refined** `TSDoc` to *improve* **IDE IntelliSense** for selected methods in `Color` and `Stylog`.
17
+
7
18
  ## [4.28.56] - 2026-01-05
8
19
 
9
- - **Resolved** an *issue affecting the conversion of Gregorian date strings to Bangla dates*.
20
+ - **Resolved** an *issue affecting the conversion of Gregorian date strings to Bangla dates* in `BanglaCalendar`.
10
21
 
11
22
  ## [4.28.54] - 2026-01-02
12
23
 
@@ -18,17 +18,18 @@ class Color {
18
18
  hsla;
19
19
  constructor(color) {
20
20
  if (color) {
21
- if (_a.isCSSColor(color)) {
22
- const newColor = new _a(css_colors_1.CSS_COLORS[color?.trim()]);
23
- this.hex = newColor.hex;
24
- this.hex8 = newColor.hex8;
25
- this.rgb = newColor.rgb;
26
- this.rgba = newColor.rgba;
27
- this.hsl = newColor.hsl;
28
- this.hsla = newColor.hsla;
21
+ const $color = color.trim();
22
+ if (_a.isCSSColor($color)) {
23
+ const { hex, hex8, rgb, rgba, hsl, hsla } = new _a(css_colors_1.CSS_COLORS[$color]);
24
+ this.hex = hex;
25
+ this.hex8 = hex8;
26
+ this.rgb = rgb;
27
+ this.rgba = rgba;
28
+ this.hsl = hsl;
29
+ this.hsla = hsla;
29
30
  }
30
31
  else {
31
- const colors = this.#convertColorToOthers(color?.trim());
32
+ const colors = this.#convertColorToOthers($color);
32
33
  if ('hex8' in colors) {
33
34
  const [r, g, b] = (0, utils_1.extractAlphaColorValues)(colors.rgba);
34
35
  const [h, s, l] = (0, utils_1.extractAlphaColorValues)(colors.hsla);
@@ -40,28 +41,24 @@ class Color {
40
41
  this.hsla = colors.hsla;
41
42
  }
42
43
  else {
43
- const [r, g, b] = (0, utils_1.extractSolidColorValues)(colors.rgb);
44
- const [h, s, l] = (0, utils_1.extractSolidColorValues)(colors.hsl);
45
44
  this.hex = colors.hex.toUpperCase();
46
- this.hex8 = `${colors.hex.toUpperCase()}${(0, helpers_1._percentToHex)(100)}`;
45
+ this.hex8 = this.#hex6ToHex8(colors.hex);
47
46
  this.rgb = colors.rgb;
48
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
47
+ this.rgba = this.#rgbToRGBA(colors.rgb);
49
48
  this.hsl = colors.hsl;
50
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
49
+ this.hsla = this.#hslToHSLA(colors.hsl);
51
50
  }
52
51
  }
53
52
  }
54
53
  else {
55
54
  const hsl = (0, random_1.generateRandomHSLColor)();
56
55
  const { hex, rgb } = (0, convert_1.convertColorCode)(hsl);
57
- const [r, g, b] = (0, utils_1.extractSolidColorValues)(rgb);
58
- const [h, s, l] = (0, utils_1.extractSolidColorValues)(hsl);
59
56
  this.hex = hex.toUpperCase();
60
- this.hex8 = `${hex.toUpperCase()}${(0, helpers_1._percentToHex)(100)}`;
57
+ this.hex8 = this.#hex6ToHex8(hex);
61
58
  this.rgb = rgb;
62
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
59
+ this.rgba = this.#rgbToRGBA(rgb);
63
60
  this.hsl = hsl;
64
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
61
+ this.hsla = this.#hslToHSLA(hsl);
65
62
  }
66
63
  }
67
64
  *[Symbol.iterator]() {
@@ -72,6 +69,17 @@ class Color {
72
69
  yield this.hsl;
73
70
  yield this.hsla;
74
71
  }
72
+ #hex6ToHex8(hex) {
73
+ return `${hex.toUpperCase()}${(0, helpers_1._percentToHex)(100)}`;
74
+ }
75
+ #rgbToRGBA(rgb) {
76
+ const [r, g, b] = (0, utils_1.extractSolidColorValues)(rgb);
77
+ return `rgba(${r}, ${g}, ${b}, 1)`;
78
+ }
79
+ #hslToHSLA(hsl) {
80
+ const [h, s, l] = (0, utils_1.extractSolidColorValues)(hsl);
81
+ return `hsla(${h}, ${s}%, ${l}%, 1)`;
82
+ }
75
83
  applyOpacity(opacity) {
76
84
  const hex8 = `${this.hex.slice(0, 7)}${(0, helpers_1._percentToHex)(opacity)}`.toUpperCase();
77
85
  return new _a(hex8);
@@ -168,10 +176,10 @@ class Color {
168
176
  return 'AA';
169
177
  return 'Fail';
170
178
  }
171
- isLightColor() {
179
+ isLightColor(threshold = 127.5) {
172
180
  const [r, g, b] = (0, utils_1.extractSolidColorValues)(this.rgb);
173
181
  const brightness = (r * 299 + g * 587 + b * 114) / 1000;
174
- return brightness > 127.5;
182
+ return brightness > Math.min(255, Math.max(0, threshold));
175
183
  }
176
184
  static isHex6(color) {
177
185
  return /^#[0-9A-Fa-f]{6}$/.test(color?.trim());
@@ -74,22 +74,20 @@ exports.WESTERN_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
74
74
  ['Libra', [9, 23]],
75
75
  ['Scorpio', [10, 23]],
76
76
  ['Sagittarius', [11, 22]],
77
- ['Capricorn', [12, 22]],
78
77
  ]);
79
78
  exports.VEDIC_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
80
79
  ['Capricorn', [1, 14]],
81
80
  ['Aquarius', [2, 13]],
82
81
  ['Pisces', [3, 14]],
83
- ['Aries', [4, 13]],
84
- ['Taurus', [5, 14]],
85
- ['Gemini', [6, 14]],
82
+ ['Aries', [4, 14]],
83
+ ['Taurus', [5, 15]],
84
+ ['Gemini', [6, 15]],
86
85
  ['Cancer', [7, 16]],
87
- ['Leo', [8, 16]],
88
- ['Virgo', [9, 16]],
89
- ['Libra', [10, 16]],
90
- ['Scorpio', [11, 15]],
91
- ['Sagittarius', [12, 15]],
92
- ['Capricorn', [1, 14]],
86
+ ['Leo', [8, 17]],
87
+ ['Virgo', [9, 17]],
88
+ ['Libra', [10, 17]],
89
+ ['Scorpio', [11, 16]],
90
+ ['Sagittarius', [12, 16]],
93
91
  ]);
94
92
  exports.ZODIAC_PRESETS = /* @__PURE__ */ Object.freeze({
95
93
  western: exports.WESTERN_ZODIAC_SIGNS,
@@ -14,12 +14,18 @@ const zodiacPlugin = ($Chronos) => {
14
14
  month = this.isoMonth;
15
15
  date = this.date;
16
16
  }
17
- const signs = [...(custom ?? constants_1.ZODIAC_PRESETS[preset])].sort((a, b) => a[1][0] * 100 + a[1][1] - (b[1][0] * 100 + b[1][1]));
17
+ const _toHundreds = (range) => {
18
+ return range[0] * 100 + range[1];
19
+ };
20
+ const signs = [...(custom ?? constants_1.ZODIAC_PRESETS[preset])].sort((a, b) => _toHundreds(a[1]) - _toHundreds(b[1]));
18
21
  for (let i = signs.length - 1; i >= 0; i--) {
19
22
  const [sign, [m, d]] = signs[i];
20
23
  if (month > m || (month === m && date >= d)) {
21
24
  return sign;
22
25
  }
26
+ if (i === 0) {
27
+ return signs.at(-1)[0];
28
+ }
23
29
  }
24
30
  return signs[0][0];
25
31
  };
@@ -266,9 +266,11 @@ export declare class Color {
266
266
  getWCAGRating(other: ColorType | CSSColor): 'Fail' | 'AA' | 'AAA';
267
267
  /**
268
268
  * @instance Determines if the color is light based on its perceived brightness.
269
+ * @param threshold Optional brightness threshold (`0–255`). Defaults to `127.5`.
270
+ * @remarks The brightness {@link threshold} is clamped to the valid *RGB range* (`0–255`) to prevent invalid comparisons.
269
271
  * @returns `true` if light, `false` if dark.
270
272
  */
271
- isLightColor(): boolean;
273
+ isLightColor(threshold?: number): boolean;
272
274
  /**
273
275
  * @static Checks if a color is in {@link Hex6} format.
274
276
  *
@@ -14,7 +14,7 @@ export type Hex = `#${string}`;
14
14
  * * Represents a hexadecimal color code.
15
15
  * * Format: `#3C6945`
16
16
  */
17
- export type Hex6 = Branded<`#${string}`, 'Hex6'>;
17
+ export type Hex6 = Branded<Hex, 'Hex6'>;
18
18
  /**
19
19
  * * Represents an RGB color string.
20
20
  * * Format: `rgb(R, G, B)`
@@ -37,7 +37,7 @@ export type HSL = `hsl(${number}, ${number}%, ${number}%)` | `hsl(${number},${nu
37
37
  * * Represents a hexadecimal color code with optional alpha channel.
38
38
  * * Format: `#3C6945FF`
39
39
  */
40
- export type Hex8 = Branded<`#${string}`, 'Hex8'>;
40
+ export type Hex8 = Branded<Hex, 'Hex8'>;
41
41
  /**
42
42
  * * Represents an RGBA color string, now includes optional alpha (opacity).
43
43
  * * Format: `rgba(R, G, B, A)`
@@ -21,15 +21,15 @@ export declare const SORTED_TIME_FORMATS: readonly ("MM" | "SS" | "ms" | "DD" |
21
21
  /** Ranges for day parts. */
22
22
  export declare const DATE_PART_RANGES: Readonly<Record<DayPart, [ClockHour, ClockHour]>>;
23
23
  /** Western Zodiac Signs */
24
- export declare const WESTERN_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]], readonly ["Capricorn", readonly [12, 22]]];
24
+ export declare const WESTERN_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]];
25
25
  /** Vedic Zodiac Sign */
26
- export declare const VEDIC_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 13]], readonly ["Taurus", readonly [5, 14]], readonly ["Gemini", readonly [6, 14]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 16]], readonly ["Virgo", readonly [9, 16]], readonly ["Libra", readonly [10, 16]], readonly ["Scorpio", readonly [11, 15]], readonly ["Sagittarius", readonly [12, 15]], readonly ["Capricorn", readonly [1, 14]]];
26
+ export declare const VEDIC_ZODIAC_SIGNS: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 14]], readonly ["Taurus", readonly [5, 15]], readonly ["Gemini", readonly [6, 15]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 17]], readonly ["Virgo", readonly [9, 17]], readonly ["Libra", readonly [10, 17]], readonly ["Scorpio", readonly [11, 16]], readonly ["Sagittarius", readonly [12, 16]]];
27
27
  /** Zodiac Signs Presets */
28
28
  export declare const ZODIAC_PRESETS: Readonly<{
29
- readonly western: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]], readonly ["Capricorn", readonly [12, 22]]];
30
- readonly vedic: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 13]], readonly ["Taurus", readonly [5, 14]], readonly ["Gemini", readonly [6, 14]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 16]], readonly ["Virgo", readonly [9, 16]], readonly ["Libra", readonly [10, 16]], readonly ["Scorpio", readonly [11, 15]], readonly ["Sagittarius", readonly [12, 15]], readonly ["Capricorn", readonly [1, 14]]];
31
- readonly tropical: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]], readonly ["Capricorn", readonly [12, 22]]];
32
- readonly sidereal: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 13]], readonly ["Taurus", readonly [5, 14]], readonly ["Gemini", readonly [6, 14]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 16]], readonly ["Virgo", readonly [9, 16]], readonly ["Libra", readonly [10, 16]], readonly ["Scorpio", readonly [11, 15]], readonly ["Sagittarius", readonly [12, 15]], readonly ["Capricorn", readonly [1, 14]]];
29
+ readonly western: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]];
30
+ readonly vedic: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 14]], readonly ["Taurus", readonly [5, 15]], readonly ["Gemini", readonly [6, 15]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 17]], readonly ["Virgo", readonly [9, 17]], readonly ["Libra", readonly [10, 17]], readonly ["Scorpio", readonly [11, 16]], readonly ["Sagittarius", readonly [12, 16]]];
31
+ readonly tropical: readonly [readonly ["Capricorn", readonly [12, 22]], readonly ["Aquarius", readonly [1, 20]], readonly ["Pisces", readonly [2, 19]], readonly ["Aries", readonly [3, 21]], readonly ["Taurus", readonly [4, 20]], readonly ["Gemini", readonly [5, 21]], readonly ["Cancer", readonly [6, 21]], readonly ["Leo", readonly [7, 23]], readonly ["Virgo", readonly [8, 23]], readonly ["Libra", readonly [9, 23]], readonly ["Scorpio", readonly [10, 23]], readonly ["Sagittarius", readonly [11, 22]]];
32
+ readonly sidereal: readonly [readonly ["Capricorn", readonly [1, 14]], readonly ["Aquarius", readonly [2, 13]], readonly ["Pisces", readonly [3, 14]], readonly ["Aries", readonly [4, 14]], readonly ["Taurus", readonly [5, 15]], readonly ["Gemini", readonly [6, 15]], readonly ["Cancer", readonly [7, 16]], readonly ["Leo", readonly [8, 17]], readonly ["Virgo", readonly [9, 17]], readonly ["Libra", readonly [10, 17]], readonly ["Scorpio", readonly [11, 16]], readonly ["Sagittarius", readonly [12, 16]]];
33
33
  }>;
34
34
  /** Variants of different time units */
35
35
  export declare const TIME_UNIT_VARIANTS: Readonly<{
@@ -6,7 +6,7 @@ declare module '../Chronos' {
6
6
  * @param options Optional config to choose preset or provide custom zodiac date ranges.
7
7
  * @returns The matching zodiac sign from preset/custom list.
8
8
  */
9
- getZodiacSign(options?: ZodiacOptions): ZodiacSign;
9
+ getZodiacSign<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
10
10
  /**
11
11
  * @instance Returns the zodiac sign based on current date or `birthDate` option.
12
12
  * @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/names#getzodiacsign getZodiacSign} method.
@@ -14,8 +14,8 @@ declare module '../Chronos' {
14
14
  * @param options Optional config to choose preset or provide custom zodiac date ranges.
15
15
  * @returns The matching zodiac sign from preset/custom list.
16
16
  */
17
- zodiac(options?: ZodiacOptions): ZodiacSign;
17
+ zodiac<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
18
18
  }
19
19
  }
20
- /** * Plugin to inject `getZodiacSign`/`zodiac` method */
20
+ /** * Plugin to inject `zodiac` related methods */
21
21
  export declare const zodiacPlugin: ($Chronos: $Chronos) => void;
@@ -304,20 +304,20 @@ export type DayPartConfig = Record<DayPart, [ClockHour, ClockHour]>;
304
304
  export type Quarter = 1 | 2 | 3 | 4;
305
305
  /** Academic year, e.g. `2024-2025` */
306
306
  export type AcademicYear = `${number}-${number}`;
307
- /** Names of Zodiac signs */
307
+ /** Names of standard Zodiac signs */
308
308
  export type ZodiacSign = (typeof WESTERN_ZODIAC_SIGNS)[number][0];
309
309
  /** Presets for Zodiac Sign Configuration */
310
310
  export type ZodiacPreset = keyof typeof ZODIAC_PRESETS;
311
311
  /** Shape of Zodiac signs array */
312
- export type ZodiacArray = Array<[ZodiacSign, [NumberRange<1, 12>, NumberRange<1, 31>]]>;
312
+ export type ZodiacArray<Sign extends string = ZodiacSign> = Array<[Sign, [NumberRange<1, 12>, NumberRange<1, 31>]] | Readonly<[Sign, Readonly<[NumberRange<1, 12>, NumberRange<1, 31>]>]>>;
313
313
  /** Options for configuring Zodiac sign getter */
314
- export interface ZodiacOptions {
314
+ export interface ZodiacOptions<Sign extends string = ZodiacSign> {
315
315
  /** - Optional birthdate in `MM-DD` format (1-based month). */
316
316
  birthDate?: MonthDateString;
317
317
  /** Optional Zodiac preset to use. Default is `western`. `western` and `tropical`, `vedic` and `sidereal` are same. */
318
318
  preset?: ZodiacPreset;
319
- /** Custom Zodiac date ranges. */
320
- custom?: ZodiacArray;
319
+ /** Custom Zodiac date ranges. Overrides presets. */
320
+ custom?: ZodiacArray<Sign> | Readonly<ZodiacArray<Sign>>;
321
321
  }
322
322
  /** - Represents the full name of a weekday, e.g., 'Monday', 'Tuesday' etc. */
323
323
  export type WeekDay = (typeof DAYS)[number];
@@ -17,12 +17,11 @@ export type AnsiSequence = [string, string];
17
17
  /**
18
18
  * * Type representing a fully chainable `LogStyler` instance.
19
19
  *
20
- * @remarks - Each property corresponds to a style (foreground color, background color, or text effect) and returns a new `Stylog` instance, allowing fluent chaining like:
21
- *
22
- * **This type combines:**
23
- * - The methods of `LogStyler` (e.g., `.style()`, `.log()`)
24
- * - Dynamically generated properties for all available `Styles`
25
- * that return another `Stylog` instance for chaining.
20
+ * @remarks
21
+ * - Each property corresponds to a style and returns a new `Stylog` instance, allowing fluent chaining.
22
+ * - **This type combines:**
23
+ * - The methods of `LogStyler` (e.g., `.style()`, `.log()`)
24
+ * - Dynamically generated properties for all available `Styles` that return another `Stylog` instance for chaining.
26
25
  *
27
26
  * @example
28
27
  * Stylog.green.bold.bgBlue.log('Hello World');
@@ -229,7 +228,7 @@ export declare class LogStyler {
229
228
  /**
230
229
  * * Apply a HEX color to the text foreground.
231
230
  *
232
- * @param code - HEX color string (e.g., '#4682B4' or '4682B4').
231
+ * @param code - HEX color string (e.g., `'#4682B4'` or `'4682B4'`).
233
232
  * @returns A new `StylogChain` instance with the HEX color applied.
234
233
  *
235
234
  * @example
@@ -254,7 +253,7 @@ export declare class LogStyler {
254
253
  /**
255
254
  * * Apply a HEX color to the text background.
256
255
  *
257
- * @param code - HEX color string (e.g., '#4682B4' or '4682B4').
256
+ * @param code - HEX color string (e.g., `'#4682B4'` or `'4682B4'`).
258
257
  * @returns A new StylogChain instance with the HEX background color applied.
259
258
  *
260
259
  * @example
@@ -279,7 +278,7 @@ export declare class LogStyler {
279
278
  /**
280
279
  * * Apply an RGB color to the text foreground using a CSS-like string.
281
280
  *
282
- * @param code - RGB color string (e.g., 'rgb(11, 45, 1)' or '11, 45, 1').
281
+ * @param code - RGB color string (e.g., `'rgb(11, 45, 1)'` or `'11, 45, 1'`).
283
282
  * @returns A new `StylogChain` instance with the RGB color applied.
284
283
  *
285
284
  * @example
@@ -325,7 +324,7 @@ export declare class LogStyler {
325
324
  /**
326
325
  * * Apply an RGB color to the text background using a CSS-like string.
327
326
  *
328
- * @param code - RGB color string (e.g., 'rgb(225, 169, 196)' or '225, 169, 196').
327
+ * @param code - RGB color string (e.g., `'rgb(225, 169, 196)'` or `'225, 169, 196'`).
329
328
  * @returns A new `StylogChain` instance with the RGB background color applied.
330
329
  *
331
330
  * @example
@@ -371,7 +370,7 @@ export declare class LogStyler {
371
370
  /**
372
371
  * * Apply an HSL color to the text foreground using a CSS-like string.
373
372
  *
374
- * @param code - HSL color string (e.g., 'hsl(50 80.5% 40%)').
373
+ * @param code - HSL color string (e.g., `'hsl(50 80.5% 40%)'`).
375
374
  * @returns A new `StylogChain` instance with the HSL color applied.
376
375
  *
377
376
  * @example
@@ -396,9 +395,9 @@ export declare class LogStyler {
396
395
  /**
397
396
  * * Apply an HSL color to the text foreground using individual components.
398
397
  *
399
- * @param hue - Hue component (0-360).
400
- * @param saturation - Saturation component (0-100 or 0-100%).
401
- * @param lightness - Lightness component (0-100 or 0-100%).
398
+ * @param hue - Hue component (`0-360`).
399
+ * @param saturation - Saturation component (`0-100`).
400
+ * @param lightness - Lightness component (`0-100`).
402
401
  * @returns A new `StylogChain` instance with the HSL color applied.
403
402
  *
404
403
  * @example
@@ -417,7 +416,7 @@ export declare class LogStyler {
417
416
  /**
418
417
  * * Apply an HSL color to the text background using a CSS-like string.
419
418
  *
420
- * @param code - HSL color string (e.g., 'hsl(50 80.5% 40%)').
419
+ * @param code - HSL color string (e.g., `'hsl(50 80.5% 40%)'`).
421
420
  * @returns A new `StylogChain` instance with the HSL background color applied.
422
421
  *
423
422
  * @example
@@ -442,9 +441,9 @@ export declare class LogStyler {
442
441
  /**
443
442
  * * Apply an HSL color to the text background using individual components.
444
443
  *
445
- * @param hue - Hue component (0-360).
446
- * @param saturation - Saturation component (0-100 or 0-100%).
447
- * @param lightness - Lightness component (0-100 or 0-100%).
444
+ * @param hue - Hue component (`0-360`).
445
+ * @param saturation - Saturation component (`0-100`).
446
+ * @param lightness - Lightness component (`0-100`).
448
447
  * @returns A new StylogChain instance with the HSL background color applied.
449
448
  *
450
449
  * @example
@@ -15,17 +15,18 @@ export class Color {
15
15
  hsla;
16
16
  constructor(color) {
17
17
  if (color) {
18
- if (_a.isCSSColor(color)) {
19
- const newColor = new _a(CSS_COLORS[color?.trim()]);
20
- this.hex = newColor.hex;
21
- this.hex8 = newColor.hex8;
22
- this.rgb = newColor.rgb;
23
- this.rgba = newColor.rgba;
24
- this.hsl = newColor.hsl;
25
- this.hsla = newColor.hsla;
18
+ const $color = color.trim();
19
+ if (_a.isCSSColor($color)) {
20
+ const { hex, hex8, rgb, rgba, hsl, hsla } = new _a(CSS_COLORS[$color]);
21
+ this.hex = hex;
22
+ this.hex8 = hex8;
23
+ this.rgb = rgb;
24
+ this.rgba = rgba;
25
+ this.hsl = hsl;
26
+ this.hsla = hsla;
26
27
  }
27
28
  else {
28
- const colors = this.#convertColorToOthers(color?.trim());
29
+ const colors = this.#convertColorToOthers($color);
29
30
  if ('hex8' in colors) {
30
31
  const [r, g, b] = extractAlphaColorValues(colors.rgba);
31
32
  const [h, s, l] = extractAlphaColorValues(colors.hsla);
@@ -37,28 +38,24 @@ export class Color {
37
38
  this.hsla = colors.hsla;
38
39
  }
39
40
  else {
40
- const [r, g, b] = extractSolidColorValues(colors.rgb);
41
- const [h, s, l] = extractSolidColorValues(colors.hsl);
42
41
  this.hex = colors.hex.toUpperCase();
43
- this.hex8 = `${colors.hex.toUpperCase()}${_percentToHex(100)}`;
42
+ this.hex8 = this.#hex6ToHex8(colors.hex);
44
43
  this.rgb = colors.rgb;
45
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
44
+ this.rgba = this.#rgbToRGBA(colors.rgb);
46
45
  this.hsl = colors.hsl;
47
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
46
+ this.hsla = this.#hslToHSLA(colors.hsl);
48
47
  }
49
48
  }
50
49
  }
51
50
  else {
52
51
  const hsl = generateRandomHSLColor();
53
52
  const { hex, rgb } = convertColorCode(hsl);
54
- const [r, g, b] = extractSolidColorValues(rgb);
55
- const [h, s, l] = extractSolidColorValues(hsl);
56
53
  this.hex = hex.toUpperCase();
57
- this.hex8 = `${hex.toUpperCase()}${_percentToHex(100)}`;
54
+ this.hex8 = this.#hex6ToHex8(hex);
58
55
  this.rgb = rgb;
59
- this.rgba = `rgba(${r}, ${g}, ${b}, 1)`;
56
+ this.rgba = this.#rgbToRGBA(rgb);
60
57
  this.hsl = hsl;
61
- this.hsla = `hsla(${h}, ${s}%, ${l}%, 1)`;
58
+ this.hsla = this.#hslToHSLA(hsl);
62
59
  }
63
60
  }
64
61
  *[Symbol.iterator]() {
@@ -69,6 +66,17 @@ export class Color {
69
66
  yield this.hsl;
70
67
  yield this.hsla;
71
68
  }
69
+ #hex6ToHex8(hex) {
70
+ return `${hex.toUpperCase()}${_percentToHex(100)}`;
71
+ }
72
+ #rgbToRGBA(rgb) {
73
+ const [r, g, b] = extractSolidColorValues(rgb);
74
+ return `rgba(${r}, ${g}, ${b}, 1)`;
75
+ }
76
+ #hslToHSLA(hsl) {
77
+ const [h, s, l] = extractSolidColorValues(hsl);
78
+ return `hsla(${h}, ${s}%, ${l}%, 1)`;
79
+ }
72
80
  applyOpacity(opacity) {
73
81
  const hex8 = `${this.hex.slice(0, 7)}${_percentToHex(opacity)}`.toUpperCase();
74
82
  return new _a(hex8);
@@ -165,10 +173,10 @@ export class Color {
165
173
  return 'AA';
166
174
  return 'Fail';
167
175
  }
168
- isLightColor() {
176
+ isLightColor(threshold = 127.5) {
169
177
  const [r, g, b] = extractSolidColorValues(this.rgb);
170
178
  const brightness = (r * 299 + g * 587 + b * 114) / 1000;
171
- return brightness > 127.5;
179
+ return brightness > Math.min(255, Math.max(0, threshold));
172
180
  }
173
181
  static isHex6(color) {
174
182
  return /^#[0-9A-Fa-f]{6}$/.test(color?.trim());
@@ -71,22 +71,20 @@ export const WESTERN_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
71
71
  ['Libra', [9, 23]],
72
72
  ['Scorpio', [10, 23]],
73
73
  ['Sagittarius', [11, 22]],
74
- ['Capricorn', [12, 22]],
75
74
  ]);
76
75
  export const VEDIC_ZODIAC_SIGNS = /* @__PURE__ */ Object.freeze([
77
76
  ['Capricorn', [1, 14]],
78
77
  ['Aquarius', [2, 13]],
79
78
  ['Pisces', [3, 14]],
80
- ['Aries', [4, 13]],
81
- ['Taurus', [5, 14]],
82
- ['Gemini', [6, 14]],
79
+ ['Aries', [4, 14]],
80
+ ['Taurus', [5, 15]],
81
+ ['Gemini', [6, 15]],
83
82
  ['Cancer', [7, 16]],
84
- ['Leo', [8, 16]],
85
- ['Virgo', [9, 16]],
86
- ['Libra', [10, 16]],
87
- ['Scorpio', [11, 15]],
88
- ['Sagittarius', [12, 15]],
89
- ['Capricorn', [1, 14]],
83
+ ['Leo', [8, 17]],
84
+ ['Virgo', [9, 17]],
85
+ ['Libra', [10, 17]],
86
+ ['Scorpio', [11, 16]],
87
+ ['Sagittarius', [12, 16]],
90
88
  ]);
91
89
  export const ZODIAC_PRESETS = /* @__PURE__ */ Object.freeze({
92
90
  western: WESTERN_ZODIAC_SIGNS,
@@ -11,12 +11,18 @@ export const zodiacPlugin = ($Chronos) => {
11
11
  month = this.isoMonth;
12
12
  date = this.date;
13
13
  }
14
- const signs = [...(custom ?? ZODIAC_PRESETS[preset])].sort((a, b) => a[1][0] * 100 + a[1][1] - (b[1][0] * 100 + b[1][1]));
14
+ const _toHundreds = (range) => {
15
+ return range[0] * 100 + range[1];
16
+ };
17
+ const signs = [...(custom ?? ZODIAC_PRESETS[preset])].sort((a, b) => _toHundreds(a[1]) - _toHundreds(b[1]));
15
18
  for (let i = signs.length - 1; i >= 0; i--) {
16
19
  const [sign, [m, d]] = signs[i];
17
20
  if (month > m || (month === m && date >= d)) {
18
21
  return sign;
19
22
  }
23
+ if (i === 0) {
24
+ return signs.at(-1)[0];
25
+ }
20
26
  }
21
27
  return signs[0][0];
22
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.28.56",
3
+ "version": "4.28.60",
4
4
  "description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -46,9 +46,9 @@
46
46
  "devDependencies": {
47
47
  "@eslint/js": "^9.39.2",
48
48
  "@types/jest": "^30.0.0",
49
- "@types/node": "^25.0.3",
50
- "@typescript-eslint/eslint-plugin": "^8.51.0",
51
- "@typescript-eslint/parser": "^8.51.0",
49
+ "@types/node": "^25.0.6",
50
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
51
+ "@typescript-eslint/parser": "^8.53.0",
52
52
  "eslint": "^9.39.2",
53
53
  "eslint-config-prettier": "^10.1.8",
54
54
  "eslint-plugin-prettier": "^5.5.4",
@@ -60,7 +60,7 @@
60
60
  "prettier": "^3.7.4",
61
61
  "ts-jest": "^29.4.6",
62
62
  "typescript": "^5.9.3",
63
- "typescript-eslint": "^8.51.0"
63
+ "typescript-eslint": "^8.53.0"
64
64
  },
65
65
  "keywords": [
66
66
  "toolbox",