nhb-toolbox 4.0.46 → 4.0.50

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.
@@ -156,10 +156,10 @@ class Color {
156
156
  * @returns A new `Color` instance with the modified darkness.
157
157
  */
158
158
  applyDarkness(percent) {
159
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
159
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
160
160
  const newL = Math.max(0, l - percent);
161
161
  const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
162
- return new Color(newHSL);
162
+ return new Color(newHSL).applyOpacity((a * 100));
163
163
  }
164
164
  /**
165
165
  * @instance Lightens the color by increasing the lightness by the given percentage.
@@ -167,10 +167,10 @@ class Color {
167
167
  * @returns A new `Color` instance with the modified lightness.
168
168
  */
169
169
  applyBrightness(percent) {
170
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
170
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
171
171
  const newL = Math.min(100, l + percent);
172
172
  const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
173
- return new Color(newHSL);
173
+ return new Color(newHSL).applyOpacity((a * 100));
174
174
  }
175
175
  /**
176
176
  * @instance Reduces the saturation of the color to make it appear duller.
@@ -178,10 +178,10 @@ class Color {
178
178
  * @returns A new `Color` instance with the modified saturation.
179
179
  */
180
180
  applyDullness(percent) {
181
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
181
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
182
182
  const newS = Math.max(0, s - percent);
183
183
  const newHSL = `hsl(${h}, ${newS}%, ${l}%)`;
184
- return new Color(newHSL);
184
+ return new Color(newHSL).applyOpacity((a * 100));
185
185
  }
186
186
  /**
187
187
  * @instance Softens the color toward white by reducing saturation and increasing lightness based on a percentage.
@@ -190,15 +190,17 @@ class Color {
190
190
  * @returns A new `Color` instance shifted toward white.
191
191
  */
192
192
  applyWhiteShade(percent) {
193
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
193
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
194
194
  // Cap values to avoid overshooting
195
195
  const newS = Math.max(0, s - (s * percent) / 100);
196
196
  const newL = Math.min(100, l + ((100 - l) * percent) / 100);
197
197
  const newHSL = `hsl(${h}, ${newS}%, ${newL}%)`;
198
- return new Color(newHSL);
198
+ return new Color(newHSL).applyOpacity((a * 100));
199
199
  }
200
200
  /**
201
201
  * @instance Blends the current color with another color based on the given weight.
202
+ *
203
+ * - **NOTE:** *If any of the input colors has opacity (alpha channel), it might be lost from the generated alpha variants of the respective color formats.*
202
204
  * @param other - The color in any 6 `(Hex, Hex8 RGB, RGBA, HSL or HSLA)` to blend with.
203
205
  * @param weight - A number from 0 to 1 indicating the weight of the other color. Defaults to `0.5`.
204
206
  * - `weight = 0` → only the original color (this)
@@ -209,11 +211,20 @@ class Color {
209
211
  blendWith(other, weight = 0.5) {
210
212
  const w = Math.max(0, Math.min(1, weight));
211
213
  const converted = new Color(other);
212
- const rgb1 = (0, helpers_1._extractSolidColorValues)(this.rgb);
213
- const rgb2 = (0, helpers_1._extractSolidColorValues)(converted.rgb);
214
- const blended = rgb1.map((c, i) => Math.round(c * (1 - w) + rgb2[i] * w));
215
- const blendedRGB = `rgb(${blended[0]}, ${blended[1]}, ${blended[2]})`;
216
- return new Color(blendedRGB);
214
+ const [r1, b1, g1, a1] = (0, helpers_1._extractAlphaColorValues)(this.rgba);
215
+ const [r2, b2, g2, a2] = (0, helpers_1._extractAlphaColorValues)(converted.rgba);
216
+ const alpha = a1 * (1 - w) + a2 * w;
217
+ // ! Original code for solid color
218
+ // const blended = rgb1.map((c, i) =>
219
+ // Math.round(c * (1 - w) + rgb2[i] * w),
220
+ // ) as ColorNumbers;
221
+ // const blendedRGB = `rgb(${blended[0]}, ${blended[1]}, ${blended[2]})`;
222
+ const blendChannel = (c1, c2) => Math.round((c1 * a1 * (1 - w) + c2 * a2 * w) / alpha);
223
+ const r = blendChannel(r1, r2);
224
+ const g = blendChannel(g1, g2);
225
+ const b = blendChannel(b1, b2);
226
+ const blended = `rgba(${r}, ${g}, ${b}, ${+alpha.toFixed(2)})`;
227
+ return new Color(blended);
217
228
  }
218
229
  /**
219
230
  * @instance Calculates the contrast ratio between this color and another color (WCAG).
@@ -243,10 +254,10 @@ class Color {
243
254
  * @returns A new Color that is the complement of the current color.
244
255
  */
245
256
  getComplementaryColor() {
246
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
257
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
247
258
  const newHue = (h + 180) % 360;
248
259
  const newHSL = `hsl(${newHue}, ${s}%, ${l}%)`;
249
- return new Color(newHSL);
260
+ return new Color(newHSL).applyOpacity((a * 100));
250
261
  }
251
262
  /**
252
263
  * @instance Generates a color scheme of analogous colors, including the base color.
@@ -254,10 +265,11 @@ class Color {
254
265
  * @returns An array of three Color instances: [base, left, right].
255
266
  */
256
267
  getAnalogousColors() {
257
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
268
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
258
269
  const left = `hsl(${(h + 330) % 360}, ${s}%, ${l}%)`;
259
270
  const right = `hsl(${(h + 30) % 360}, ${s}%, ${l}%)`;
260
- return [this, new Color(left), new Color(right)];
271
+ const analogous = [this, new Color(left), new Color(right)];
272
+ return analogous.map((c) => c.applyOpacity((a * 100)));
261
273
  }
262
274
  /**
263
275
  * @instance Generates a color triad scheme including the base color.
@@ -265,10 +277,11 @@ class Color {
265
277
  * @returns An array of three Color instances: [base, triad1, triad2].
266
278
  */
267
279
  getTriadColors() {
268
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
280
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
269
281
  const c1 = `hsl(${(h + 120) % 360}, ${s}%, ${l}%)`;
270
282
  const c2 = `hsl(${(h + 240) % 360}, ${s}%, ${l}%)`;
271
- return [this, new Color(c1), new Color(c2)];
283
+ const triad = [this, new Color(c1), new Color(c2)];
284
+ return triad.map((c) => c.applyOpacity((a * 100)));
272
285
  }
273
286
  /**
274
287
  * @instance Generates a tetradic color scheme including the base color.
@@ -276,11 +289,12 @@ class Color {
276
289
  * @returns An array of four Color instances: [base, tetrad1, tetrad2, tetrad3].
277
290
  */
278
291
  getTetradColors() {
279
- const [h, s, l] = (0, helpers_1._extractSolidColorValues)(this.hsl);
292
+ const [h, s, l, a] = (0, helpers_1._extractAlphaColorValues)(this.hsla);
280
293
  const c1 = `hsl(${(h + 90) % 360}, ${s}%, ${l}%)`;
281
294
  const c2 = `hsl(${(h + 180) % 360}, ${s}%, ${l}%)`;
282
295
  const c3 = `hsl(${(h + 270) % 360}, ${s}%, ${l}%)`;
283
- return [this, new Color(c1), new Color(c2), new Color(c3)];
296
+ const tetrad = [this, new Color(c1), new Color(c2), new Color(c3)];
297
+ return tetrad.map((c) => c.applyOpacity((a * 100)));
284
298
  }
285
299
  /**
286
300
  * @instance Gets the `WCAG` accessibility rating between this and another color.
@@ -212,18 +212,6 @@ const createControlledFormData = (data, configs) => {
212
212
  _addToFormData(key, JSON.stringify(value));
213
213
  }
214
214
  }
215
- // else if (Array.isArray(value) && value.every(isNotEmptyObject)) {
216
- // if (shouldDotNotate(fullKey)) {
217
- // value.forEach((item, index) =>
218
- // _addToFormData(`${fullKey}[${index}]`, item),
219
- // );
220
- // } else if (shouldStringify(fullKey)) {
221
- // _addToFormData(
222
- // key,
223
- // value.map((item) => _processObject(item, parentKey)),
224
- // );
225
- // }
226
- // }
227
215
  else {
228
216
  // * For other cases, just append as key-value
229
217
  _addToFormData(key, value);
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sanitizeData = sanitizeData;
4
4
  exports.parseObjectValues = parseObjectValues;
5
+ const guards_1 = require("../form/guards");
5
6
  const non_primitives_1 = require("../guards/non-primitives");
7
+ const primitives_1 = require("../guards/primitives");
6
8
  const basics_1 = require("../string/basics");
7
9
  /**
8
10
  * * Sanitizes a string, array of strings, an object or array of objects by ignoring specified keys and trimming string values.
@@ -13,9 +15,46 @@ const basics_1 = require("../string/basics");
13
15
  * @returns A new string, object or array of strings or objects with the specified modifications.
14
16
  */
15
17
  function sanitizeData(input, options) {
16
- const { keysToIgnore: ignoreKeys = [], trimStrings = true, ignoreNullish = false, } = options || {};
18
+ const { keysToIgnore = [], requiredKeys = [], trimStrings = true, ignoreNullish = false, ignoreFalsy = false, } = options || {};
17
19
  // Flatten the object keys and use the keys for comparison
18
- const ignoreKeySet = new Set(ignoreKeys);
20
+ const ignoreKeySet = new Set(keysToIgnore);
21
+ const isRequiredKey = (key) => {
22
+ return Array.isArray(requiredKeys) ?
23
+ requiredKeys.some((path) => key === path || key.startsWith(`${path}.`))
24
+ : requiredKeys === '*';
25
+ };
26
+ /**
27
+ * * Recursively process an array and its nested content(s).
28
+ * @param arr Array to process.
29
+ * @param path Full path as dot notation if needed.
30
+ * @returns Processed array.
31
+ */
32
+ const _processArray = (arr, path) => {
33
+ return arr
34
+ .map((item) => {
35
+ if ((0, primitives_1.isString)(item) && trimStrings) {
36
+ return (0, basics_1.trimString)(item);
37
+ }
38
+ if (Array.isArray(item)) {
39
+ // Recursive sanitize
40
+ return _processArray(item, path);
41
+ }
42
+ if ((0, non_primitives_1.isObject)(item)) {
43
+ return _processObject(item, path);
44
+ }
45
+ return item;
46
+ })
47
+ .filter((v) => {
48
+ if (ignoreNullish && v == null)
49
+ return false;
50
+ if (ignoreFalsy && !v)
51
+ return false;
52
+ if (ignoreFalsy && (0, non_primitives_1.isObject)(v) && !(0, non_primitives_1.isNotEmptyObject)(v)) {
53
+ return false;
54
+ }
55
+ return true;
56
+ });
57
+ };
19
58
  /**
20
59
  * * Helper function to process a single object.
21
60
  *
@@ -30,23 +69,38 @@ function sanitizeData(input, options) {
30
69
  return acc;
31
70
  }
32
71
  // Exclude nullish values if specified
33
- if (ignoreNullish && (value === null || value === undefined)) {
72
+ if (ignoreNullish && !isRequiredKey(fullKeyPath) && value == null) {
34
73
  return acc;
35
74
  }
36
- // Trim string values if enabled
37
- if (typeof value === 'string' && trimStrings) {
75
+ // Exclude falsy values `0`, `false`, `null` and `undefined`
76
+ if (ignoreFalsy && !value && !isRequiredKey(fullKeyPath)) {
77
+ return acc;
78
+ }
79
+ if ((0, primitives_1.isString)(value) && trimStrings) {
80
+ // Trim string values if enabled
38
81
  acc[key] = (0, basics_1.trimString)(value);
39
82
  }
40
- else if (value &&
41
- typeof value === 'object' &&
42
- !Array.isArray(value)) {
83
+ else if (value && (0, non_primitives_1.isObject)(value)) {
43
84
  // Recursively process nested objects
44
85
  const processedValue = _processObject(value, fullKeyPath);
45
- // Only add the property if it's not an empty object
46
- if ((0, non_primitives_1.isNotEmptyObject)(processedValue)) {
86
+ // Add the property conditionally if it's not an empty object
87
+ if (!ignoreFalsy ||
88
+ isRequiredKey(fullKeyPath) ||
89
+ (0, non_primitives_1.isNotEmptyObject)(processedValue)) {
47
90
  acc[key] = processedValue;
48
91
  }
49
92
  }
93
+ else if (value && Array.isArray(value)) {
94
+ // Keep file arrays untouched
95
+ if ((0, guards_1.isFileArray)(value) || (0, guards_1.isCustomFileArray)(value)) {
96
+ acc[key] = value;
97
+ }
98
+ // acc[key as keyof T] = value.map(sanitizeData) as T[keyof T];
99
+ const sanitizedArray = _processArray(value, fullKeyPath);
100
+ if (!ignoreFalsy || sanitizedArray.length > 0) {
101
+ acc[key] = sanitizedArray;
102
+ }
103
+ }
50
104
  else {
51
105
  // Add other values as-is
52
106
  acc[key] = value;
@@ -54,22 +108,31 @@ function sanitizeData(input, options) {
54
108
  return acc;
55
109
  }, {});
56
110
  // Process strings
57
- if (typeof input === 'string') {
111
+ if ((0, primitives_1.isString)(input)) {
58
112
  return (0, basics_1.trimString)(input);
59
113
  }
60
114
  // Process array of strings and objects
61
115
  if (Array.isArray(input)) {
62
116
  // Process array of strings
63
- if (typeof input[0] === 'string') {
117
+ if ((0, non_primitives_1.isArrayOfType)(input, primitives_1.isString)) {
64
118
  return (0, basics_1.trimString)(input);
65
119
  }
66
- // Process array of objects
120
+ // * Handle arrays with nested strings/arrays/objects
67
121
  return input
68
- .map((obj) => _processObject(obj))
69
- .filter((obj) => (0, non_primitives_1.isNotEmptyObject)(obj));
122
+ .map((item) => sanitizeData(item, options))
123
+ .filter((val) => {
124
+ if (ignoreNullish && val == null)
125
+ return false;
126
+ if (ignoreFalsy && !val)
127
+ return false;
128
+ if (ignoreFalsy && (0, non_primitives_1.isObject)(val) && !(0, non_primitives_1.isNotEmptyObject)(val)) {
129
+ return false;
130
+ }
131
+ return true;
132
+ });
70
133
  }
71
134
  // Process object
72
- if (typeof input === 'object' && input !== null) {
135
+ if ((0, non_primitives_1.isObject)(input)) {
73
136
  return _processObject(input);
74
137
  }
75
138
  return input;
@@ -87,7 +150,7 @@ function parseObjectValues(object) {
87
150
  const parsedBody = {};
88
151
  if ((0, non_primitives_1.isNotEmptyObject)(object)) {
89
152
  Object.entries(object).forEach(([key, value]) => {
90
- if (typeof value !== 'string') {
153
+ if (!(0, primitives_1.isString)(value)) {
91
154
  parsedBody[key] = value;
92
155
  return;
93
156
  }
@@ -1,4 +1,4 @@
1
- import type { ColorType, Hex6, Hex8, HSL, HSLA, Percent, RGB, RGBA } from './types';
1
+ import type { Analogous, ColorType, 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.
@@ -82,7 +82,7 @@ export declare class Color {
82
82
  */
83
83
  constructor(toConvert: ColorType);
84
84
  /** - Iterates over the color representations (Hex, RGB, HSL). */
85
- [Symbol.iterator](): Generator<Hex6 | RGB | HSL | Hex8 | RGBA | HSLA, void, unknown>;
85
+ [Symbol.iterator](): Generator<RGB | HSL | Hex6 | RGBA | Hex8 | HSLA, void, unknown>;
86
86
  /**
87
87
  * @instance Applies or modifies the opacity of a color. Mutate the original instance.
88
88
  * - For solid colors (Hex6/RGB/HSL): Adds an alpha channel with the specified opacity.
@@ -129,6 +129,8 @@ export declare class Color {
129
129
  applyWhiteShade(percent: Percent): Color;
130
130
  /**
131
131
  * @instance Blends the current color with another color based on the given weight.
132
+ *
133
+ * - **NOTE:** *If any of the input colors has opacity (alpha channel), it might be lost from the generated alpha variants of the respective color formats.*
132
134
  * @param other - The color in any 6 `(Hex, Hex8 RGB, RGBA, HSL or HSLA)` to blend with.
133
135
  * @param weight - A number from 0 to 1 indicating the weight of the other color. Defaults to `0.5`.
134
136
  * - `weight = 0` → only the original color (this)
@@ -153,19 +155,19 @@ export declare class Color {
153
155
  * Analogous colors are next to each other on the color wheel (±30°).
154
156
  * @returns An array of three Color instances: [base, left, right].
155
157
  */
156
- getAnalogousColors(): [Color, Color, Color];
158
+ getAnalogousColors(): Analogous;
157
159
  /**
158
160
  * @instance Generates a color triad scheme including the base color.
159
161
  * Triadic colors are evenly spaced (120° apart) on the color wheel.
160
162
  * @returns An array of three Color instances: [base, triad1, triad2].
161
163
  */
162
- getTriadColors(): [Color, Color, Color];
164
+ getTriadColors(): Triad;
163
165
  /**
164
166
  * @instance Generates a tetradic color scheme including the base color.
165
167
  * Tetradic colors form a rectangle on the color wheel (90° apart).
166
168
  * @returns An array of four Color instances: [base, tetrad1, tetrad2, tetrad3].
167
169
  */
168
- getTetradColors(): [Color, Color, Color, Color];
170
+ getTetradColors(): Tetrad;
169
171
  /**
170
172
  * @instance Gets the `WCAG` accessibility rating between this and another color.
171
173
  * @param other - The other color to test contrast against.
@@ -1 +1 @@
1
- {"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../src/colors/Color.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,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AG,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;CAkD3C"}
@@ -1,4 +1,5 @@
1
1
  import type { Branded } from '../types';
2
+ import type { Color } from './Color';
2
3
  /** - A string, number for generating color. */
3
4
  export type ColorInput = string | number;
4
5
  /** - An array of strings/numbers or nested arrays of strings/numbers for generating colors. */
@@ -115,4 +116,7 @@ export interface Colors {
115
116
  /** - `HSLA` color (e.g., `hsla(14, 100%, 60%, 1)`) */
116
117
  hsla: HSLA;
117
118
  }
119
+ export type Analogous = [Color, Color, Color];
120
+ export type Triad = [Color, Color, Color];
121
+ export type Tetrad = [Color, Color, Color, Color];
118
122
  //# 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;AAExC,+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,EAA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yE;IACzE,IAAI,EAAE,CAAC,SAAS,IAAI,GAAG,cAAc,GAAG,KAAK,GAAG,IAAI,CAAC;CACrD;AAED,gDAAgD;AAChD,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEvD,sEAAsE;AACtE,MAAM,WAAW,MAAM;IACtB,sCAAsC;IACtC,GAAG,EAAE,IAAI,CAAC;IACV,2DAA2D;IAC3D,IAAI,EAAE,IAAI,CAAC;IACX,+CAA+C;IAC/C,GAAG,EAAE,GAAG,CAAC;IACT,oDAAoD;IACpD,IAAI,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 +1 @@
1
- {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/form/convert.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEX,aAAa,EAEb,MAAM,iBAAiB,CAAC;AAQzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,QACzD,CAAC,YACG,eAAe,CAAC,CAAC,CAAC,KAC1B,QAkQF,CAAC"}
1
+ {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/form/convert.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEX,aAAa,EAEb,MAAM,iBAAiB,CAAC;AAQzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,QACzD,CAAC,YACG,eAAe,CAAC,CAAC,CAAC,KAC1B,QAqPF,CAAC"}
@@ -10,14 +10,14 @@ import type { GenericObject, SanitizeOptions, StrictObject } from './types';
10
10
  */
11
11
  export declare function sanitizeData<T extends GenericObject>(object: T, options?: SanitizeOptions<T>): FlattenPartial<T>;
12
12
  /**
13
- * * Sanitizes an array of objects by ignoring specified keys and trimming string values based on options provided.
14
- * * Also excludes nullish values (null, undefined) if specified. Always ignores empty nested object(s).
13
+ * * Sanitizes a deeply nested array that may contain arrays, objects or other (mixed) data types.
14
+ * * Preserves structure while removing empty values and trimming strings and other operations.
15
15
  *
16
- * @param object - The object to sanitize.
17
- * @param options - Options that define which keys to ignore, whether to trim string values, and whether to exclude nullish values.
18
- * @returns A new array of objects with the specified modifications.
16
+ * @param array - A mixed array that may contain arrays, objects or other data types.
17
+ * @param options - Options to trim and filter values.
18
+ * @returns A new sanitized array with the specified modifications.
19
19
  */
20
- export declare function sanitizeData<T extends GenericObject>(array: T[], options?: SanitizeOptions<T>): FlattenPartial<T>[];
20
+ export declare function sanitizeData<T>(array: T[], options?: SanitizeOptions<T>): FlattenPartial<T>[];
21
21
  /**
22
22
  * * Trims all the words in a string.
23
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/object/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAEX,aAAa,EACb,eAAe,EACf,YAAY,EACZ,MAAM,SAAS,CAAC;AAEjB;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,aAAa,EACnD,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,cAAc,CAAC,CAAC,CAAC,CAAC;AAEr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,GAAG,YAAY,CAgCrE"}
@@ -41,14 +41,26 @@ export type NestedKeyString<T> = T extends AdvancedTypes ? never : T extends Gen
41
41
  export type NestedPrimitiveKey<T> = T extends AdvancedTypes ? never : T extends GenericObject ? {
42
42
  [K in keyof T & string]: NonNullable<T[K]> extends Primitive ? K : NonNullable<T[K]> extends GenericObject ? `${K}.${NestedPrimitiveKey<NonNullable<T[K]>>}` : never;
43
43
  }[keyof T & string] : never;
44
- /** - Options for `sanitizeData` */
45
- export interface SanitizeOptions<T extends GenericObject> {
46
- /** Keys to ignore */
44
+ /** - Options for `sanitizeData` utility. */
45
+ export interface SanitizeOptions<T> {
46
+ /**
47
+ * An array of dot-notation keys to exclude from the sanitized output.
48
+ * This is only applicable when sanitizing plain objects or arrays of objects.
49
+ * When applied to nested or irregular array structures, behavior may be inconsistent or partially ignored.
50
+ */
47
51
  keysToIgnore?: DotNotationKey<T>[];
48
- /** Whether to trim string values. Defaults to `true` */
52
+ /** Whether to trim string values. Defaults to `true`. */
49
53
  trimStrings?: boolean;
50
- /** Whether to exclude nullish (null or undefined) values. Defaults to `false` */
54
+ /** Whether to exclude nullish (`null` or `undefined`) values. Defaults to `false`. */
51
55
  ignoreNullish?: boolean;
56
+ /** Whether to exclude all falsy values (`false`, `0`, `empty string: ''`, `null`, `undefined` and `empty object and arrays` (`{}`, `[]`)). Defaults to `false`. */
57
+ ignoreFalsy?: boolean;
58
+ /**
59
+ * An array of dot-notation key paths that must be preserved in the sanitized output.
60
+ * Use `"*"` to retain all keys. This applies primarily to plain or nested objects and arrays of objects.
61
+ * When applied to nested or irregular array structures, behavior may be inconsistent or partially ignored.
62
+ */
63
+ requiredKeys?: '*' | DotNotationKey<T>[];
52
64
  }
53
65
  /** - Data after sanitization.
54
66
  * ! Unused
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/object/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MA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CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC1D,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAC5B,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAC1B,MAAM;CACR,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI;KACrC,CAAC,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC;CACnD,CAAC"}
@@ -153,10 +153,10 @@ export class Color {
153
153
  * @returns A new `Color` instance with the modified darkness.
154
154
  */
155
155
  applyDarkness(percent) {
156
- const [h, s, l] = _extractSolidColorValues(this.hsl);
156
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
157
157
  const newL = Math.max(0, l - percent);
158
158
  const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
159
- return new Color(newHSL);
159
+ return new Color(newHSL).applyOpacity((a * 100));
160
160
  }
161
161
  /**
162
162
  * @instance Lightens the color by increasing the lightness by the given percentage.
@@ -164,10 +164,10 @@ export class Color {
164
164
  * @returns A new `Color` instance with the modified lightness.
165
165
  */
166
166
  applyBrightness(percent) {
167
- const [h, s, l] = _extractSolidColorValues(this.hsl);
167
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
168
168
  const newL = Math.min(100, l + percent);
169
169
  const newHSL = `hsl(${h}, ${s}%, ${newL}%)`;
170
- return new Color(newHSL);
170
+ return new Color(newHSL).applyOpacity((a * 100));
171
171
  }
172
172
  /**
173
173
  * @instance Reduces the saturation of the color to make it appear duller.
@@ -175,10 +175,10 @@ export class Color {
175
175
  * @returns A new `Color` instance with the modified saturation.
176
176
  */
177
177
  applyDullness(percent) {
178
- const [h, s, l] = _extractSolidColorValues(this.hsl);
178
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
179
179
  const newS = Math.max(0, s - percent);
180
180
  const newHSL = `hsl(${h}, ${newS}%, ${l}%)`;
181
- return new Color(newHSL);
181
+ return new Color(newHSL).applyOpacity((a * 100));
182
182
  }
183
183
  /**
184
184
  * @instance Softens the color toward white by reducing saturation and increasing lightness based on a percentage.
@@ -187,15 +187,17 @@ export class Color {
187
187
  * @returns A new `Color` instance shifted toward white.
188
188
  */
189
189
  applyWhiteShade(percent) {
190
- const [h, s, l] = _extractSolidColorValues(this.hsl);
190
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
191
191
  // Cap values to avoid overshooting
192
192
  const newS = Math.max(0, s - (s * percent) / 100);
193
193
  const newL = Math.min(100, l + ((100 - l) * percent) / 100);
194
194
  const newHSL = `hsl(${h}, ${newS}%, ${newL}%)`;
195
- return new Color(newHSL);
195
+ return new Color(newHSL).applyOpacity((a * 100));
196
196
  }
197
197
  /**
198
198
  * @instance Blends the current color with another color based on the given weight.
199
+ *
200
+ * - **NOTE:** *If any of the input colors has opacity (alpha channel), it might be lost from the generated alpha variants of the respective color formats.*
199
201
  * @param other - The color in any 6 `(Hex, Hex8 RGB, RGBA, HSL or HSLA)` to blend with.
200
202
  * @param weight - A number from 0 to 1 indicating the weight of the other color. Defaults to `0.5`.
201
203
  * - `weight = 0` → only the original color (this)
@@ -206,11 +208,20 @@ export class Color {
206
208
  blendWith(other, weight = 0.5) {
207
209
  const w = Math.max(0, Math.min(1, weight));
208
210
  const converted = new Color(other);
209
- const rgb1 = _extractSolidColorValues(this.rgb);
210
- const rgb2 = _extractSolidColorValues(converted.rgb);
211
- const blended = rgb1.map((c, i) => Math.round(c * (1 - w) + rgb2[i] * w));
212
- const blendedRGB = `rgb(${blended[0]}, ${blended[1]}, ${blended[2]})`;
213
- return new Color(blendedRGB);
211
+ const [r1, b1, g1, a1] = _extractAlphaColorValues(this.rgba);
212
+ const [r2, b2, g2, a2] = _extractAlphaColorValues(converted.rgba);
213
+ const alpha = a1 * (1 - w) + a2 * w;
214
+ // ! Original code for solid color
215
+ // const blended = rgb1.map((c, i) =>
216
+ // Math.round(c * (1 - w) + rgb2[i] * w),
217
+ // ) as ColorNumbers;
218
+ // const blendedRGB = `rgb(${blended[0]}, ${blended[1]}, ${blended[2]})`;
219
+ const blendChannel = (c1, c2) => Math.round((c1 * a1 * (1 - w) + c2 * a2 * w) / alpha);
220
+ const r = blendChannel(r1, r2);
221
+ const g = blendChannel(g1, g2);
222
+ const b = blendChannel(b1, b2);
223
+ const blended = `rgba(${r}, ${g}, ${b}, ${+alpha.toFixed(2)})`;
224
+ return new Color(blended);
214
225
  }
215
226
  /**
216
227
  * @instance Calculates the contrast ratio between this color and another color (WCAG).
@@ -240,10 +251,10 @@ export class Color {
240
251
  * @returns A new Color that is the complement of the current color.
241
252
  */
242
253
  getComplementaryColor() {
243
- const [h, s, l] = _extractSolidColorValues(this.hsl);
254
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
244
255
  const newHue = (h + 180) % 360;
245
256
  const newHSL = `hsl(${newHue}, ${s}%, ${l}%)`;
246
- return new Color(newHSL);
257
+ return new Color(newHSL).applyOpacity((a * 100));
247
258
  }
248
259
  /**
249
260
  * @instance Generates a color scheme of analogous colors, including the base color.
@@ -251,10 +262,11 @@ export class Color {
251
262
  * @returns An array of three Color instances: [base, left, right].
252
263
  */
253
264
  getAnalogousColors() {
254
- const [h, s, l] = _extractSolidColorValues(this.hsl);
265
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
255
266
  const left = `hsl(${(h + 330) % 360}, ${s}%, ${l}%)`;
256
267
  const right = `hsl(${(h + 30) % 360}, ${s}%, ${l}%)`;
257
- return [this, new Color(left), new Color(right)];
268
+ const analogous = [this, new Color(left), new Color(right)];
269
+ return analogous.map((c) => c.applyOpacity((a * 100)));
258
270
  }
259
271
  /**
260
272
  * @instance Generates a color triad scheme including the base color.
@@ -262,10 +274,11 @@ export class Color {
262
274
  * @returns An array of three Color instances: [base, triad1, triad2].
263
275
  */
264
276
  getTriadColors() {
265
- const [h, s, l] = _extractSolidColorValues(this.hsl);
277
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
266
278
  const c1 = `hsl(${(h + 120) % 360}, ${s}%, ${l}%)`;
267
279
  const c2 = `hsl(${(h + 240) % 360}, ${s}%, ${l}%)`;
268
- return [this, new Color(c1), new Color(c2)];
280
+ const triad = [this, new Color(c1), new Color(c2)];
281
+ return triad.map((c) => c.applyOpacity((a * 100)));
269
282
  }
270
283
  /**
271
284
  * @instance Generates a tetradic color scheme including the base color.
@@ -273,11 +286,12 @@ export class Color {
273
286
  * @returns An array of four Color instances: [base, tetrad1, tetrad2, tetrad3].
274
287
  */
275
288
  getTetradColors() {
276
- const [h, s, l] = _extractSolidColorValues(this.hsl);
289
+ const [h, s, l, a] = _extractAlphaColorValues(this.hsla);
277
290
  const c1 = `hsl(${(h + 90) % 360}, ${s}%, ${l}%)`;
278
291
  const c2 = `hsl(${(h + 180) % 360}, ${s}%, ${l}%)`;
279
292
  const c3 = `hsl(${(h + 270) % 360}, ${s}%, ${l}%)`;
280
- return [this, new Color(c1), new Color(c2), new Color(c3)];
293
+ const tetrad = [this, new Color(c1), new Color(c2), new Color(c3)];
294
+ return tetrad.map((c) => c.applyOpacity((a * 100)));
281
295
  }
282
296
  /**
283
297
  * @instance Gets the `WCAG` accessibility rating between this and another color.
@@ -209,18 +209,6 @@ export const createControlledFormData = (data, configs) => {
209
209
  _addToFormData(key, JSON.stringify(value));
210
210
  }
211
211
  }
212
- // else if (Array.isArray(value) && value.every(isNotEmptyObject)) {
213
- // if (shouldDotNotate(fullKey)) {
214
- // value.forEach((item, index) =>
215
- // _addToFormData(`${fullKey}[${index}]`, item),
216
- // );
217
- // } else if (shouldStringify(fullKey)) {
218
- // _addToFormData(
219
- // key,
220
- // value.map((item) => _processObject(item, parentKey)),
221
- // );
222
- // }
223
- // }
224
212
  else {
225
213
  // * For other cases, just append as key-value
226
214
  _addToFormData(key, value);
@@ -1,4 +1,6 @@
1
- import { isNotEmptyObject } from '../guards/non-primitives';
1
+ import { isCustomFileArray, isFileArray } from '../form/guards';
2
+ import { isArrayOfType, isNotEmptyObject, isObject, } from '../guards/non-primitives';
3
+ import { isString } from '../guards/primitives';
2
4
  import { trimString } from '../string/basics';
3
5
  /**
4
6
  * * Sanitizes a string, array of strings, an object or array of objects by ignoring specified keys and trimming string values.
@@ -9,9 +11,46 @@ import { trimString } from '../string/basics';
9
11
  * @returns A new string, object or array of strings or objects with the specified modifications.
10
12
  */
11
13
  export function sanitizeData(input, options) {
12
- const { keysToIgnore: ignoreKeys = [], trimStrings = true, ignoreNullish = false, } = options || {};
14
+ const { keysToIgnore = [], requiredKeys = [], trimStrings = true, ignoreNullish = false, ignoreFalsy = false, } = options || {};
13
15
  // Flatten the object keys and use the keys for comparison
14
- const ignoreKeySet = new Set(ignoreKeys);
16
+ const ignoreKeySet = new Set(keysToIgnore);
17
+ const isRequiredKey = (key) => {
18
+ return Array.isArray(requiredKeys) ?
19
+ requiredKeys.some((path) => key === path || key.startsWith(`${path}.`))
20
+ : requiredKeys === '*';
21
+ };
22
+ /**
23
+ * * Recursively process an array and its nested content(s).
24
+ * @param arr Array to process.
25
+ * @param path Full path as dot notation if needed.
26
+ * @returns Processed array.
27
+ */
28
+ const _processArray = (arr, path) => {
29
+ return arr
30
+ .map((item) => {
31
+ if (isString(item) && trimStrings) {
32
+ return trimString(item);
33
+ }
34
+ if (Array.isArray(item)) {
35
+ // Recursive sanitize
36
+ return _processArray(item, path);
37
+ }
38
+ if (isObject(item)) {
39
+ return _processObject(item, path);
40
+ }
41
+ return item;
42
+ })
43
+ .filter((v) => {
44
+ if (ignoreNullish && v == null)
45
+ return false;
46
+ if (ignoreFalsy && !v)
47
+ return false;
48
+ if (ignoreFalsy && isObject(v) && !isNotEmptyObject(v)) {
49
+ return false;
50
+ }
51
+ return true;
52
+ });
53
+ };
15
54
  /**
16
55
  * * Helper function to process a single object.
17
56
  *
@@ -26,23 +65,38 @@ export function sanitizeData(input, options) {
26
65
  return acc;
27
66
  }
28
67
  // Exclude nullish values if specified
29
- if (ignoreNullish && (value === null || value === undefined)) {
68
+ if (ignoreNullish && !isRequiredKey(fullKeyPath) && value == null) {
30
69
  return acc;
31
70
  }
32
- // Trim string values if enabled
33
- if (typeof value === 'string' && trimStrings) {
71
+ // Exclude falsy values `0`, `false`, `null` and `undefined`
72
+ if (ignoreFalsy && !value && !isRequiredKey(fullKeyPath)) {
73
+ return acc;
74
+ }
75
+ if (isString(value) && trimStrings) {
76
+ // Trim string values if enabled
34
77
  acc[key] = trimString(value);
35
78
  }
36
- else if (value &&
37
- typeof value === 'object' &&
38
- !Array.isArray(value)) {
79
+ else if (value && isObject(value)) {
39
80
  // Recursively process nested objects
40
81
  const processedValue = _processObject(value, fullKeyPath);
41
- // Only add the property if it's not an empty object
42
- if (isNotEmptyObject(processedValue)) {
82
+ // Add the property conditionally if it's not an empty object
83
+ if (!ignoreFalsy ||
84
+ isRequiredKey(fullKeyPath) ||
85
+ isNotEmptyObject(processedValue)) {
43
86
  acc[key] = processedValue;
44
87
  }
45
88
  }
89
+ else if (value && Array.isArray(value)) {
90
+ // Keep file arrays untouched
91
+ if (isFileArray(value) || isCustomFileArray(value)) {
92
+ acc[key] = value;
93
+ }
94
+ // acc[key as keyof T] = value.map(sanitizeData) as T[keyof T];
95
+ const sanitizedArray = _processArray(value, fullKeyPath);
96
+ if (!ignoreFalsy || sanitizedArray.length > 0) {
97
+ acc[key] = sanitizedArray;
98
+ }
99
+ }
46
100
  else {
47
101
  // Add other values as-is
48
102
  acc[key] = value;
@@ -50,22 +104,31 @@ export function sanitizeData(input, options) {
50
104
  return acc;
51
105
  }, {});
52
106
  // Process strings
53
- if (typeof input === 'string') {
107
+ if (isString(input)) {
54
108
  return trimString(input);
55
109
  }
56
110
  // Process array of strings and objects
57
111
  if (Array.isArray(input)) {
58
112
  // Process array of strings
59
- if (typeof input[0] === 'string') {
113
+ if (isArrayOfType(input, isString)) {
60
114
  return trimString(input);
61
115
  }
62
- // Process array of objects
116
+ // * Handle arrays with nested strings/arrays/objects
63
117
  return input
64
- .map((obj) => _processObject(obj))
65
- .filter((obj) => isNotEmptyObject(obj));
118
+ .map((item) => sanitizeData(item, options))
119
+ .filter((val) => {
120
+ if (ignoreNullish && val == null)
121
+ return false;
122
+ if (ignoreFalsy && !val)
123
+ return false;
124
+ if (ignoreFalsy && isObject(val) && !isNotEmptyObject(val)) {
125
+ return false;
126
+ }
127
+ return true;
128
+ });
66
129
  }
67
130
  // Process object
68
- if (typeof input === 'object' && input !== null) {
131
+ if (isObject(input)) {
69
132
  return _processObject(input);
70
133
  }
71
134
  return input;
@@ -83,7 +146,7 @@ export function parseObjectValues(object) {
83
146
  const parsedBody = {};
84
147
  if (isNotEmptyObject(object)) {
85
148
  Object.entries(object).forEach(([key, value]) => {
86
- if (typeof value !== 'string') {
149
+ if (!isString(value)) {
87
150
  parsedBody[key] = value;
88
151
  return;
89
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhb-toolbox",
3
- "version": "4.0.46",
3
+ "version": "4.0.50",
4
4
  "description": "A versatile collection of smart, efficient, and reusable utility functions for everyday development needs.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",