nhb-toolbox 4.10.69 → 4.10.71

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.
Files changed (63) hide show
  1. package/dist/esm/array/Finder.js +5 -1
  2. package/dist/esm/array/basics.js +15 -7
  3. package/dist/esm/array/sort.js +16 -13
  4. package/dist/esm/array/transform.js +23 -14
  5. package/dist/esm/array/types.js +2 -1
  6. package/dist/esm/array/utils.js +4 -1
  7. package/dist/esm/colors/Color.js +51 -47
  8. package/dist/esm/colors/constants.js +6 -3
  9. package/dist/esm/colors/convert.js +74 -57
  10. package/dist/esm/colors/css-colors.js +4 -1
  11. package/dist/esm/colors/helpers.js +31 -14
  12. package/dist/esm/colors/initials.js +16 -13
  13. package/dist/esm/colors/random.js +12 -7
  14. package/dist/esm/colors/types.js +2 -1
  15. package/dist/esm/colors/utils.js +10 -5
  16. package/dist/esm/date/Chronos.js +57 -53
  17. package/dist/esm/date/chronos-fn.js +9 -6
  18. package/dist/esm/date/constants.js +29 -26
  19. package/dist/esm/date/greet.js +15 -12
  20. package/dist/esm/date/guards.js +15 -9
  21. package/dist/esm/date/types.js +2 -1
  22. package/dist/esm/date/utils.js +14 -6
  23. package/dist/esm/dom/query.js +17 -10
  24. package/dist/esm/dom/storage.js +15 -6
  25. package/dist/esm/dom/utils.js +8 -3
  26. package/dist/esm/form/convert.js +31 -27
  27. package/dist/esm/form/guards.js +18 -8
  28. package/dist/esm/form/transform.js +10 -6
  29. package/dist/esm/form/types.js +2 -1
  30. package/dist/esm/guards/non-primitives.js +39 -19
  31. package/dist/esm/guards/primitives.js +30 -14
  32. package/dist/esm/guards/specials.js +37 -23
  33. package/dist/esm/index.js +358 -45
  34. package/dist/esm/number/Currency.js +7 -3
  35. package/dist/esm/number/Unit.js +8 -4
  36. package/dist/esm/number/basics.js +27 -15
  37. package/dist/esm/number/constants.js +13 -10
  38. package/dist/esm/number/convert.js +12 -7
  39. package/dist/esm/number/fibonacci.js +10 -4
  40. package/dist/esm/number/guards.js +15 -6
  41. package/dist/esm/number/helpers.js +18 -11
  42. package/dist/esm/number/percent.js +14 -11
  43. package/dist/esm/number/prime.js +8 -3
  44. package/dist/esm/number/range.js +16 -13
  45. package/dist/esm/number/types.js +2 -1
  46. package/dist/esm/number/utilities.js +15 -7
  47. package/dist/esm/object/basics.js +7 -2
  48. package/dist/esm/object/convert.js +10 -4
  49. package/dist/esm/object/objectify.js +38 -27
  50. package/dist/esm/object/sanitize.js +25 -21
  51. package/dist/esm/object/types.js +2 -1
  52. package/dist/esm/string/anagram.js +4 -1
  53. package/dist/esm/string/basics.js +11 -4
  54. package/dist/esm/string/constants.js +4 -1
  55. package/dist/esm/string/convert.js +28 -16
  56. package/dist/esm/string/guards.js +17 -8
  57. package/dist/esm/string/types.js +2 -1
  58. package/dist/esm/string/utilities.js +9 -3
  59. package/dist/esm/types/index.js +2 -1
  60. package/dist/esm/utils/Paginator.js +5 -1
  61. package/dist/esm/utils/index.js +39 -25
  62. package/dist/esm/utils/types.js +2 -1
  63. package/package.json +1 -1
@@ -1,8 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Finder = void 0;
1
4
  /**
2
5
  * The `Finder` class performs optimized searching on arrays.
3
6
  * It supports binary search, fuzzy search, and smart caching with TTL.
4
7
  */
5
- export class Finder {
8
+ class Finder {
6
9
  static #DEFAULT_TTL = 1000 * 60 * 5;
7
10
  #cachedResult = new Map();
8
11
  #sortedCache = new Map();
@@ -283,3 +286,4 @@ export class Finder {
283
286
  };
284
287
  }
285
288
  }
289
+ exports.Finder = Finder;
@@ -1,17 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLastArrayElement = exports.shuffleArray = exports.isInvalidOrEmptyArray = exports.filterArrayOfObjects = exports.flattenArray = void 0;
1
4
  /**
2
5
  * * Flattens a nested array recursively or wraps any non-array data type in an array.
3
6
  *
4
7
  * @param input - The input value, which can be a nested array or a non-array value.
5
8
  * @returns A fully flattened array of type `Flatten<T>`. If the input is not an array, it wraps it in a single-element array.
6
9
  */
7
- export const flattenArray = (input) => {
10
+ const flattenArray = (input) => {
8
11
  if (!Array.isArray(input))
9
12
  return [input];
10
13
  return input.reduce((acc, item) => {
11
14
  // If item is an array, recursively flatten it; otherwise, add it directly.
12
- return acc.concat(Array.isArray(item) ? flattenArray(item) : [item]);
15
+ return acc.concat(Array.isArray(item) ? (0, exports.flattenArray)(item) : [item]);
13
16
  }, []);
14
17
  };
18
+ exports.flattenArray = flattenArray;
15
19
  /**
16
20
  * @deprecated _Please, use `findAll` instance method from `Finder` class for **more advanced filtering and searching.**_
17
21
  *
@@ -22,7 +26,7 @@ export const flattenArray = (input) => {
22
26
  * @returns The filtered array of objects.
23
27
  * @throws `Error` If the input is not a valid array.
24
28
  */
25
- export const filterArrayOfObjects = (array, conditions) => {
29
+ const filterArrayOfObjects = (array, conditions) => {
26
30
  if (!Array.isArray(array)) {
27
31
  throw new Error('The provided input is not a valid array!');
28
32
  }
@@ -33,13 +37,14 @@ export const filterArrayOfObjects = (array, conditions) => {
33
37
  return true;
34
38
  }));
35
39
  };
40
+ exports.filterArrayOfObjects = filterArrayOfObjects;
36
41
  /**
37
42
  * * Checks if a value is an empty array or an array with only empty values.
38
43
  *
39
44
  * @param value - The value to check.
40
45
  * @returns `true` if the value is not an array, an empty array, or an array containing only `null`, `undefined`, empty objects, or empty arrays.
41
46
  */
42
- export const isInvalidOrEmptyArray = (value) => {
47
+ const isInvalidOrEmptyArray = (value) => {
43
48
  if (!Array.isArray(value))
44
49
  return true;
45
50
  if (value?.length === 0)
@@ -48,14 +53,15 @@ export const isInvalidOrEmptyArray = (value) => {
48
53
  (Array.isArray(item) && item?.length === 0) ||
49
54
  (typeof item === 'object' && Object.keys(item || {})?.length === 0));
50
55
  };
56
+ exports.isInvalidOrEmptyArray = isInvalidOrEmptyArray;
51
57
  /**
52
58
  * * Shuffle the elements of an array.
53
59
  *
54
60
  * @param array Array to shuffle.
55
61
  * @returns Shuffled array.
56
62
  */
57
- export const shuffleArray = (array) => {
58
- if (isInvalidOrEmptyArray(array))
63
+ const shuffleArray = (array) => {
64
+ if ((0, exports.isInvalidOrEmptyArray)(array))
59
65
  return array;
60
66
  const shuffled = structuredClone(array);
61
67
  for (let i = shuffled?.length - 1; i > 0; i--) {
@@ -64,12 +70,14 @@ export const shuffleArray = (array) => {
64
70
  }
65
71
  return shuffled;
66
72
  };
73
+ exports.shuffleArray = shuffleArray;
67
74
  /**
68
75
  * * Get the last element of an array.
69
76
  *
70
77
  * @param array Array to get the last element from.
71
78
  * @returns The last element or `undefined` if the array is empty.
72
79
  */
73
- export const getLastArrayElement = (array) => {
80
+ const getLastArrayElement = (array) => {
74
81
  return array?.length > 0 ? array[array?.length - 1] : undefined;
75
82
  };
83
+ exports.getLastArrayElement = getLastArrayElement;
@@ -1,6 +1,9 @@
1
- import { isArrayOfType, isObject, isValidArray, } from '../guards/non-primitives.js';
2
- import { isBoolean, isNumber, isString } from '../guards/primitives.js';
3
- import { naturalSort } from './utils.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortAnArray = sortAnArray;
4
+ const non_primitives_1 = require("../guards/non-primitives");
5
+ const primitives_1 = require("../guards/primitives");
6
+ const utils_1 = require("./utils");
4
7
  /**
5
8
  * * Sorts an array of strings, numbers, booleans, or objects based on the provided options.
6
9
  *
@@ -13,27 +16,27 @@ import { naturalSort } from './utils.js';
13
16
  * @param options - Sorting options for objects.
14
17
  * @returns The sorted array.
15
18
  */
16
- export function sortAnArray(array, options) {
17
- if (!isValidArray(array))
19
+ function sortAnArray(array, options) {
20
+ if (!(0, non_primitives_1.isValidArray)(array))
18
21
  return array;
19
22
  // Check if the array contains strings
20
- if (isArrayOfType(array, isString)) {
23
+ if ((0, non_primitives_1.isArrayOfType)(array, primitives_1.isString)) {
21
24
  return [...array].sort((a, b) => options?.sortOrder === 'desc' ?
22
- naturalSort(b, a)
23
- : naturalSort(a, b));
25
+ (0, utils_1.naturalSort)(b, a)
26
+ : (0, utils_1.naturalSort)(a, b));
24
27
  }
25
28
  // Check if the array contains numbers
26
- if (isArrayOfType(array, isNumber)) {
29
+ if ((0, non_primitives_1.isArrayOfType)(array, primitives_1.isNumber)) {
27
30
  return [...array].sort((a, b) => options?.sortOrder === 'desc' ? b - a : a - b);
28
31
  }
29
32
  // Check if the array contains booleans
30
- if (isArrayOfType(array, isBoolean)) {
33
+ if ((0, non_primitives_1.isArrayOfType)(array, primitives_1.isBoolean)) {
31
34
  return [...array].sort((a, b) => options?.sortOrder === 'desc' ?
32
35
  Number(b) - Number(a)
33
36
  : Number(a) - Number(b));
34
37
  }
35
38
  // Handle array of objects
36
- if (isArrayOfType(array, isObject) && options && 'sortByField' in options) {
39
+ if ((0, non_primitives_1.isArrayOfType)(array, non_primitives_1.isObject) && options && 'sortByField' in options) {
37
40
  return [...array].sort((a, b) => {
38
41
  const _getKeyValue = (obj, path) => {
39
42
  return path
@@ -47,8 +50,8 @@ export function sortAnArray(array, options) {
47
50
  }
48
51
  if (typeof keyA === 'string' && typeof keyB === 'string') {
49
52
  return options?.sortOrder === 'desc' ?
50
- naturalSort(keyB, keyA)
51
- : naturalSort(keyA, keyB);
53
+ (0, utils_1.naturalSort)(keyB, keyA)
54
+ : (0, utils_1.naturalSort)(keyA, keyB);
52
55
  }
53
56
  if (typeof keyA === 'number' && typeof keyB === 'number') {
54
57
  return options?.sortOrder === 'desc' ?
@@ -1,5 +1,14 @@
1
- import { isNumber } from '../guards/primitives.js';
2
- import { isDeepEqual } from '../utils.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOptionsArray = createOptionsArray;
4
+ exports.removeDuplicatesFromArray = removeDuplicatesFromArray;
5
+ exports.getDuplicates = getDuplicates;
6
+ exports.findMissingElements = findMissingElements;
7
+ exports.splitArray = splitArray;
8
+ exports.rotateArray = rotateArray;
9
+ exports.moveArrayElement = moveArrayElement;
10
+ const primitives_1 = require("../guards/primitives");
11
+ const utils_1 = require("../utils");
3
12
  /**
4
13
  * * Converts an array of objects into a formatted array of options.
5
14
  *
@@ -7,11 +16,11 @@ import { isDeepEqual } from '../utils.js';
7
16
  * @param config - The configuration object to specify the keys for the `value` (firstFieldName) and `label` (secondFieldName) fields and rename as needed.
8
17
  * @returns An array of options, where each option has `value` and `label` fields as default or as specified by user in the config options.
9
18
  */
10
- export function createOptionsArray(data, config) {
19
+ function createOptionsArray(data, config) {
11
20
  const { firstFieldKey, secondFieldKey, firstFieldName = 'value', secondFieldName = 'label', retainNumberValue = false, } = config || {};
12
21
  if (data && data?.length) {
13
22
  return data?.map((datum) => {
14
- const firstValue = retainNumberValue && isNumber(datum[firstFieldKey]) ?
23
+ const firstValue = retainNumberValue && (0, primitives_1.isNumber)(datum[firstFieldKey]) ?
15
24
  datum[firstFieldKey]
16
25
  : String(datum[firstFieldKey] ?? '');
17
26
  return {
@@ -30,8 +39,8 @@ export function createOptionsArray(data, config) {
30
39
  * @param array - The array from which duplicates need to be removed.
31
40
  * @returns A new array with duplicates removed.
32
41
  */
33
- export function removeDuplicatesFromArray(array) {
34
- return array?.filter((item, index, self) => index === self?.findIndex((el) => isDeepEqual(el, item)));
42
+ function removeDuplicatesFromArray(array) {
43
+ return array?.filter((item, index, self) => index === self?.findIndex((el) => (0, utils_1.isDeepEqual)(el, item)));
35
44
  }
36
45
  /**
37
46
  * * Finds duplicate values in an array, runs deep comparison for objects and arrays.
@@ -39,12 +48,12 @@ export function removeDuplicatesFromArray(array) {
39
48
  * @param array - The array in which to find duplicates.
40
49
  * @returns An array containing all duplicate entries (each one only once).
41
50
  */
42
- export function getDuplicates(array) {
51
+ function getDuplicates(array) {
43
52
  const seen = [];
44
53
  const duplicates = [];
45
54
  for (const item of array) {
46
- const hasSeen = seen?.find((el) => isDeepEqual(el, item));
47
- const hasDuplicate = duplicates?.find((el) => isDeepEqual(el, item));
55
+ const hasSeen = seen?.find((el) => (0, utils_1.isDeepEqual)(el, item));
56
+ const hasDuplicate = duplicates?.find((el) => (0, utils_1.isDeepEqual)(el, item));
48
57
  if (hasSeen && !hasDuplicate) {
49
58
  duplicates?.push(item);
50
59
  }
@@ -70,10 +79,10 @@ export function getDuplicates(array) {
70
79
  * - `'from-second'` → values in `array2` missing in `array1`.
71
80
  * @returns An array of missing elements based on the comparison direction.
72
81
  */
73
- export function findMissingElements(array1, array2, missingFrom) {
82
+ function findMissingElements(array1, array2, missingFrom) {
74
83
  const source = (missingFrom === 'from-first' ? array1 : array2) ?? [];
75
84
  const target = (missingFrom === 'from-first' ? array2 : array1) ?? [];
76
- return source.filter((s) => !target?.some((t) => isDeepEqual(t, s)));
85
+ return source.filter((s) => !target?.some((t) => (0, utils_1.isDeepEqual)(t, s)));
77
86
  }
78
87
  /**
79
88
  * * Splits an array into chunks of a given size.
@@ -82,7 +91,7 @@ export function findMissingElements(array1, array2, missingFrom) {
82
91
  * @param chunkSize The size of each chunk.
83
92
  * @returns An array of chunked arrays.
84
93
  */
85
- export function splitArray(arr, chunkSize) {
94
+ function splitArray(arr, chunkSize) {
86
95
  const result = [];
87
96
  for (let i = 0; i < arr?.length; i += chunkSize) {
88
97
  result.push(arr.slice(i, i + chunkSize));
@@ -96,7 +105,7 @@ export function splitArray(arr, chunkSize) {
96
105
  * @param steps The number of positions to rotate (positive: right, negative: left).
97
106
  * @returns The rotated array.
98
107
  */
99
- export function rotateArray(arr, steps) {
108
+ function rotateArray(arr, steps) {
100
109
  const length = arr?.length;
101
110
  if (length === 0)
102
111
  return arr;
@@ -111,7 +120,7 @@ export function rotateArray(arr, steps) {
111
120
  * @param toIndex The new index for the element.
112
121
  * @returns A new array with the element moved.
113
122
  */
114
- export function moveArrayElement(arr, fromIndex, toIndex) {
123
+ function moveArrayElement(arr, fromIndex, toIndex) {
115
124
  const newArr = [...arr];
116
125
  const [item] = newArr.splice(fromIndex, 1);
117
126
  newArr.splice(toIndex, 0, item);
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.naturalSort = naturalSort;
1
4
  /**
2
5
  * * Compare two strings using natural sorting (e.g., "file2" < "file10").
3
6
  * Optionally supports case-insensitive and locale-aware string chunk comparisons.
@@ -9,7 +12,7 @@
9
12
  * @param options.localeAware - If true, uses localeCompare for string chunk comparisons. Defaults to `false`.
10
13
  * @returns A negative number if `a` comes before `b`, a positive number if `a` comes after `b`, or 0 if equal.
11
14
  */
12
- export function naturalSort(a, b, options) {
15
+ function naturalSort(a, b, options) {
13
16
  const { caseInsensitive = true, localeAware = false } = options || {};
14
17
  /**
15
18
  * * Splits a string into an array of number and non-number chunks.
@@ -1,10 +1,13 @@
1
- import { convertColorCode } from './convert.js';
2
- import { CSS_COLORS } from './css-colors.js';
3
- import { _convertOpacityToHex, _isHSL, _isHSLA, _isRGB, _isRGBA, } from './helpers.js';
4
- import { generateRandomHSLColor } from './random.js';
5
- import { extractAlphaColorValues, extractSolidColorValues } from './utils.js';
6
- const hsl = generateRandomHSLColor();
7
- const { hex, rgb } = convertColorCode(hsl);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Color = void 0;
4
+ const convert_1 = require("./convert");
5
+ const css_colors_1 = require("./css-colors");
6
+ const helpers_1 = require("./helpers");
7
+ const random_1 = require("./random");
8
+ const utils_1 = require("./utils");
9
+ const hsl = (0, random_1.generateRandomHSLColor)();
10
+ const { hex, rgb } = (0, convert_1.convertColorCode)(hsl);
8
11
  /**
9
12
  * * Class representing a color and its conversions among `Hex`, `Hex8` `RGB`, `RGBA`, `HSL` and `HSLA` formats.
10
13
  * * It has 13 instance methods to manipulate and play with the color values.
@@ -17,7 +20,7 @@ const { hex, rgb } = convertColorCode(hsl);
17
20
  * @property hsl - The color in `HSL` format.
18
21
  * @property hsla - The color in `HSLA` format.
19
22
  */
20
- export class Color {
23
+ class Color {
21
24
  hex;
22
25
  hex8;
23
26
  rgb;
@@ -70,7 +73,7 @@ export class Color {
70
73
  constructor(color) {
71
74
  if (color) {
72
75
  if (Color.isCSSColor(color)) {
73
- const newColor = new Color(CSS_COLORS[color]);
76
+ const newColor = new Color(css_colors_1.CSS_COLORS[color]);
74
77
  this.hex = newColor.hex;
75
78
  this.hex8 = newColor.hex8;
76
79
  this.rgb = newColor.rgb;
@@ -82,8 +85,8 @@ export class Color {
82
85
  const colors = this.#convertColorToOthers(color);
83
86
  if ('hex8' in colors) {
84
87
  // Extract alpha color values (Hex8, RGBA, HSLA)
85
- const rgbaValues = extractAlphaColorValues(colors.rgba);
86
- const hslaValues = extractAlphaColorValues(colors.hsla);
88
+ const rgbaValues = (0, utils_1.extractAlphaColorValues)(colors.rgba);
89
+ const hslaValues = (0, utils_1.extractAlphaColorValues)(colors.hsla);
87
90
  this.hex = colors.hex8.toUpperCase().slice(0, 7);
88
91
  this.hex8 = colors.hex8.toUpperCase();
89
92
  this.rgb = `rgb(${rgbaValues[0]}, ${rgbaValues[1]}, ${rgbaValues[2]})`;
@@ -93,11 +96,11 @@ export class Color {
93
96
  }
94
97
  else {
95
98
  // Extract solid color values (Hex, RGB, HSL)
96
- const rgbValues = extractSolidColorValues(colors.rgb);
97
- const hslValues = extractSolidColorValues(colors.hsl);
99
+ const rgbValues = (0, utils_1.extractSolidColorValues)(colors.rgb);
100
+ const hslValues = (0, utils_1.extractSolidColorValues)(colors.hsl);
98
101
  this.hex = colors.hex.toUpperCase();
99
102
  this.hex8 =
100
- `${colors.hex.toUpperCase()}${_convertOpacityToHex(100)}`;
103
+ `${colors.hex.toUpperCase()}${(0, helpers_1._convertOpacityToHex)(100)}`;
101
104
  this.rgb = colors.rgb;
102
105
  this.rgba = `rgba(${rgbValues[0]}, ${rgbValues[1]}, ${rgbValues[2]}, 1)`;
103
106
  this.hsl = colors.hsl;
@@ -106,12 +109,12 @@ export class Color {
106
109
  }
107
110
  }
108
111
  else {
109
- const rgbValues = extractSolidColorValues(rgb);
110
- const hslValues = extractSolidColorValues(hsl);
112
+ const rgbValues = (0, utils_1.extractSolidColorValues)(rgb);
113
+ const hslValues = (0, utils_1.extractSolidColorValues)(hsl);
111
114
  // Generate random colors
112
115
  this.hex = hex.toUpperCase();
113
116
  this.hex8 =
114
- `${hex.toUpperCase()}${_convertOpacityToHex(100)}`;
117
+ `${hex.toUpperCase()}${(0, helpers_1._convertOpacityToHex)(100)}`;
115
118
  this.rgb = rgb;
116
119
  this.rgba = `rgba(${rgbValues[0]}, ${rgbValues[1]}, ${rgbValues[2]}, 1)`;
117
120
  this.hsl = hsl;
@@ -147,10 +150,10 @@ export class Color {
147
150
  */
148
151
  applyOpacity(opacity) {
149
152
  const validOpacity = Math.min(100, Math.max(0, opacity));
150
- const alphaHex = _convertOpacityToHex(opacity);
153
+ const alphaHex = (0, helpers_1._convertOpacityToHex)(opacity);
151
154
  const alphaDecimal = validOpacity / 100;
152
- const rgbValues = extractSolidColorValues(this.rgb);
153
- const hslValues = extractSolidColorValues(this.hsl);
155
+ const rgbValues = (0, utils_1.extractSolidColorValues)(this.rgb);
156
+ const hslValues = (0, utils_1.extractSolidColorValues)(this.hsl);
154
157
  return Color.#fromParts({
155
158
  hex: this.hex.slice(0, 7).toUpperCase(),
156
159
  hex8: `${this.hex.slice(0, 7)}${alphaHex}`.toUpperCase(),
@@ -166,7 +169,7 @@ export class Color {
166
169
  * @returns A new `Color` instance with the modified darkness.
167
170
  */
168
171
  applyDarkness(percent) {
169
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
172
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
170
173
  const newL = Math.max(0, l - percent);
171
174
  const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
172
175
  return new Color(newHSL).applyOpacity((a * 100));
@@ -177,7 +180,7 @@ export class Color {
177
180
  * @returns A new `Color` instance with the modified lightness.
178
181
  */
179
182
  applyBrightness(percent) {
180
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
183
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
181
184
  const newL = Math.min(100, l + percent);
182
185
  const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
183
186
  return new Color(newHSL).applyOpacity((a * 100));
@@ -188,7 +191,7 @@ export class Color {
188
191
  * @returns A new `Color` instance with the modified saturation.
189
192
  */
190
193
  applyDullness(percent) {
191
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
194
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
192
195
  const newS = Math.max(0, s - percent);
193
196
  const newHSL = `hsl(${h}, ${newS}%, ${l}%)`;
194
197
  return new Color(newHSL).applyOpacity((a * 100));
@@ -200,7 +203,7 @@ export class Color {
200
203
  * @returns A new `Color` instance shifted toward white.
201
204
  */
202
205
  applyWhiteShade(percent) {
203
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
206
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
204
207
  // Cap values to avoid overshooting
205
208
  const newS = Math.max(0, s - (s * percent) / 100);
206
209
  const newL = Math.min(100, l + ((100 - l) * percent) / 100);
@@ -222,8 +225,8 @@ export class Color {
222
225
  blendWith(other, weight = 0.5) {
223
226
  const w = Math.max(0, Math.min(1, weight));
224
227
  const converted = Color.isCSSColor(other) ? new Color(other) : new Color(other);
225
- const [r1, b1, g1, a1] = extractAlphaColorValues(this.rgba);
226
- const [r2, b2, g2, a2] = extractAlphaColorValues(converted.rgba);
228
+ const [r1, b1, g1, a1] = (0, utils_1.extractAlphaColorValues)(this.rgba);
229
+ const [r2, b2, g2, a2] = (0, utils_1.extractAlphaColorValues)(converted.rgba);
227
230
  const alpha = Math.round((a1 * (1 - w) + a2 * w) * 100) / 100;
228
231
  const blendChannel = (c1, c2) => {
229
232
  return Math.round((c1 * a1 * (1 - w) + c2 * a2 * w) / alpha);
@@ -242,7 +245,7 @@ export class Color {
242
245
  contrastRatio(other) {
243
246
  const newColor = Color.isCSSColor(other) ? new Color(other) : new Color(other);
244
247
  const luminance = (rgb) => {
245
- const [r, g, b] = extractSolidColorValues(rgb).map((v) => {
248
+ const [r, g, b] = (0, utils_1.extractSolidColorValues)(rgb).map((v) => {
246
249
  const c = v / 255;
247
250
  return c <= 0.03928 ?
248
251
  c / 12.92
@@ -262,7 +265,7 @@ export class Color {
262
265
  * @returns A new Color that is the complement of the current color.
263
266
  */
264
267
  getComplementaryColor() {
265
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
268
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
266
269
  const newHue = (h + 180) % 360;
267
270
  const newHSL = `hsl(${newHue}, ${s}%, ${l}%)`;
268
271
  return new Color(newHSL).applyOpacity((a * 100));
@@ -273,7 +276,7 @@ export class Color {
273
276
  * @returns An array of three Color instances: [base, left, right].
274
277
  */
275
278
  getAnalogousColors() {
276
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
279
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
277
280
  const left = `hsl(${(h + 330) % 360}, ${s}%, ${l}%)`;
278
281
  const right = `hsl(${(h + 30) % 360}, ${s}%, ${l}%)`;
279
282
  const analogous = [this, new Color(left), new Color(right)];
@@ -285,7 +288,7 @@ export class Color {
285
288
  * @returns An array of three Color instances: [base, triad1, triad2].
286
289
  */
287
290
  getTriadColors() {
288
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
291
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
289
292
  const c1 = `hsl(${(h + 120) % 360}, ${s}%, ${l}%)`;
290
293
  const c2 = `hsl(${(h + 240) % 360}, ${s}%, ${l}%)`;
291
294
  const triad = [this, new Color(c1), new Color(c2)];
@@ -297,7 +300,7 @@ export class Color {
297
300
  * @returns An array of four Color instances: [base, tetrad1, tetrad2, tetrad3].
298
301
  */
299
302
  getTetradColors() {
300
- const [h, s, l, a] = extractAlphaColorValues(this.hsla);
303
+ const [h, s, l, a] = (0, utils_1.extractAlphaColorValues)(this.hsla);
301
304
  const c1 = `hsl(${(h + 90) % 360}, ${s}%, ${l}%)`;
302
305
  const c2 = `hsl(${(h + 180) % 360}, ${s}%, ${l}%)`;
303
306
  const c3 = `hsl(${(h + 270) % 360}, ${s}%, ${l}%)`;
@@ -322,7 +325,7 @@ export class Color {
322
325
  * @returns `true` if light, `false` if dark.
323
326
  */
324
327
  isLightColor() {
325
- const [r, g, b] = extractSolidColorValues(this.rgb);
328
+ const [r, g, b] = (0, utils_1.extractSolidColorValues)(this.rgb);
326
329
  const brightness = (r * 299 + g * 587 + b * 114) / 1000;
327
330
  return brightness > 127.5;
328
331
  }
@@ -351,7 +354,7 @@ export class Color {
351
354
  * @returns `true` if it's a `RGB` color, `false` if not.
352
355
  */
353
356
  static isRGB(color) {
354
- return _isRGB(color);
357
+ return (0, helpers_1._isRGB)(color);
355
358
  }
356
359
  /**
357
360
  * @static Checks if a color is in `RGBA` format and within valid ranges.
@@ -360,7 +363,7 @@ export class Color {
360
363
  * @returns `true` if it's a `RGBA` color, `false` if not.
361
364
  */
362
365
  static isRGBA(color) {
363
- return _isRGBA(color);
366
+ return (0, helpers_1._isRGBA)(color);
364
367
  }
365
368
  /**
366
369
  * @static Checks if a color is in `HSL` format and within valid ranges.
@@ -369,7 +372,7 @@ export class Color {
369
372
  * @returns `true` if it's a `HSL` color, `false` if not.
370
373
  */
371
374
  static isHSL(color) {
372
- return _isHSL(color);
375
+ return (0, helpers_1._isHSL)(color);
373
376
  }
374
377
  /**
375
378
  * @static Checks if a color is in `HSLA` format and within valid ranges.
@@ -378,7 +381,7 @@ export class Color {
378
381
  * @returns `true` if it's a `HSLA` color, `false` if not.
379
382
  */
380
383
  static isHSLA(color) {
381
- return _isHSLA(color);
384
+ return (0, helpers_1._isHSLA)(color);
382
385
  }
383
386
  /**
384
387
  * @static Checks if a color is a valid CSS color name.
@@ -391,11 +394,11 @@ export class Color {
391
394
  static isCSSColor(color) {
392
395
  return (!Color.isHex6(color) &&
393
396
  !Color.isHex8(color) &&
394
- !_isRGB(color) &&
395
- !_isRGBA(color) &&
396
- !_isHSL(color) &&
397
- !_isHSLA(color) &&
398
- color in CSS_COLORS);
397
+ !(0, helpers_1._isRGB)(color) &&
398
+ !(0, helpers_1._isRGBA)(color) &&
399
+ !(0, helpers_1._isHSL)(color) &&
400
+ !(0, helpers_1._isHSLA)(color) &&
401
+ color in css_colors_1.CSS_COLORS);
399
402
  }
400
403
  /**
401
404
  * @private Converts the given color to all other formats while preserving the original.
@@ -405,27 +408,27 @@ export class Color {
405
408
  */
406
409
  #convertColorToOthers(color) {
407
410
  if (Color.isHex6(color)) {
408
- const { rgb, hsl } = convertColorCode(color);
411
+ const { rgb, hsl } = (0, convert_1.convertColorCode)(color);
409
412
  return { hex: color, rgb, hsl };
410
413
  }
411
414
  else if (Color.isRGB(color)) {
412
- const { hex, hsl } = convertColorCode(color);
415
+ const { hex, hsl } = (0, convert_1.convertColorCode)(color);
413
416
  return { hex, rgb: color, hsl };
414
417
  }
415
418
  else if (Color.isHSL(color)) {
416
- const { hex, rgb } = convertColorCode(color);
419
+ const { hex, rgb } = (0, convert_1.convertColorCode)(color);
417
420
  return { hex, rgb, hsl: color };
418
421
  }
419
422
  else if (Color.isHex8(color)) {
420
- const { rgba, hsla } = convertColorCode(color);
423
+ const { rgba, hsla } = (0, convert_1.convertColorCode)(color);
421
424
  return { hex8: color, rgba, hsla };
422
425
  }
423
426
  else if (Color.isRGBA(color)) {
424
- const { hex8, hsla } = convertColorCode(color);
427
+ const { hex8, hsla } = (0, convert_1.convertColorCode)(color);
425
428
  return { hex8, rgba: color, hsla };
426
429
  }
427
430
  else if (Color.isHSLA(color)) {
428
- const { hex8, rgba } = convertColorCode(color);
431
+ const { hex8, rgba } = (0, convert_1.convertColorCode)(color);
429
432
  return { hex8, rgba, hsla: color };
430
433
  }
431
434
  throw new Error(`Unrecognized color format: ${color}`);
@@ -446,3 +449,4 @@ export class Color {
446
449
  return color;
447
450
  }
448
451
  }
452
+ exports.Color = Color;
@@ -1,5 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PERCENT_VALUES = exports.numberColorPalette = exports.alphabetColorPalette = void 0;
1
4
  /** Colors based on the ASCII value of the letter. */
2
- export const alphabetColorPalette = [
5
+ exports.alphabetColorPalette = [
3
6
  '#00094C',
4
7
  '#00376E',
5
8
  '#005600',
@@ -28,7 +31,7 @@ export const alphabetColorPalette = [
28
31
  '#824809',
29
32
  ];
30
33
  /** Colors based on the index of numbers. */
31
- export const numberColorPalette = [
34
+ exports.numberColorPalette = [
32
35
  '#893213',
33
36
  '#A44C15',
34
37
  '#8B4513',
@@ -40,7 +43,7 @@ export const numberColorPalette = [
40
43
  '#B5680A',
41
44
  '#6437B3',
42
45
  ];
43
- export const PERCENT_VALUES = [
46
+ exports.PERCENT_VALUES = [
44
47
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
45
48
  21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
46
49
  40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,