toolbox-x 2.0.13 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Color-B2SgCGbm.d.mts → Color-CInCJvH7.d.mts} +98 -14
- package/dist/{Color-asKZqwDF.d.cts → Color-CVRcGmWe.d.cts} +98 -14
- package/dist/{Stylog-CRNMQ_uV.d.cts → Stylog-00MmV27Z.d.cts} +1 -1
- package/dist/{Stylog-Cvzo5z86.d.mts → Stylog-Bi1f4CR9.d.mts} +1 -1
- package/dist/{array-D8VGEDBI.d.mts → array-CbAKXvhH.d.mts} +3 -1
- package/dist/{array-ChT6TxQ7.d.cts → array-EVkwcL_k.d.cts} +3 -1
- package/dist/{basics-Dald7J6c.mjs → basics-20lm69yy.mjs} +5 -98
- package/dist/{basics-Bb5ovcvz.cjs → basics-byj0VH1c.cjs} +5 -140
- package/dist/colors.cjs +130 -24
- package/dist/colors.d.cts +2 -2
- package/dist/colors.d.mts +2 -2
- package/dist/colors.mjs +130 -24
- package/dist/constants.cjs +14 -14
- package/dist/constants.mjs +1 -1
- package/dist/{convert-Cqy2Llek.cjs → convert-BjKz_hhr.cjs} +6 -2
- package/dist/{convert-lXdkXPJR.mjs → convert-DRZXcjcS.mjs} +6 -2
- package/dist/date.cjs +6 -6
- package/dist/date.mjs +4 -4
- package/dist/dom.cjs +12 -11
- package/dist/dom.d.cts +2 -2
- package/dist/dom.d.mts +2 -2
- package/dist/dom.mjs +7 -6
- package/dist/{form-CHFqlgPr.d.cts → form-DA-YShnM.d.cts} +3 -2
- package/dist/{form-crhNgN40.d.mts → form-DIYoIS0E.d.mts} +3 -2
- package/dist/{guards-D8Iz6EEy.cjs → guards-BSwFQX1M.cjs} +3 -3
- package/dist/{guards-DziDBD0p.mjs → guards-CNG9gnvL.mjs} +1 -1
- package/dist/guards-CqbVT4L5.cjs +156 -0
- package/dist/{guards-DGN95D2h.cjs → guards-CrfVwk0-.cjs} +1 -1
- package/dist/guards-DKGBsd6x.mjs +115 -0
- package/dist/{guards-D1et4U32.mjs → guards-Dc9MB9on.mjs} +3 -3
- package/dist/guards.cjs +37 -36
- package/dist/guards.d.cts +2 -2
- package/dist/guards.d.mts +2 -2
- package/dist/guards.mjs +5 -4
- package/dist/hash.cjs +8 -8
- package/dist/hash.mjs +8 -8
- package/dist/{index-C9x0f9jU.d.mts → index-BbBnKdBb.d.mts} +1 -1
- package/dist/{index-BgomIbws.d.cts → index-D00Uqm9S.d.cts} +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +4 -5
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +12 -12
- package/dist/{parse-DUJ0YThn.mjs → parse-TuFyLeVH.mjs} +3 -3
- package/dist/{parse-CbVVRoFY.cjs → parse-jh637S25.cjs} +4 -4
- package/dist/pluralizer.cjs +1 -1
- package/dist/pluralizer.mjs +1 -1
- package/dist/{query-B4Lrr5Vt.mjs → query-BomnyWh3.mjs} +5 -5
- package/dist/{query-BUBCpo-q.cjs → query-sWSi-d7u.cjs} +10 -10
- package/dist/{specials-dkYP1Nh2.cjs → specials-DU8u108m.cjs} +1 -1
- package/dist/{specials-Hq5Ncd6y.mjs → specials-krf7zsqI.mjs} +1 -1
- package/dist/stylog.cjs +3 -3
- package/dist/stylog.d.cts +2 -2
- package/dist/stylog.d.mts +2 -2
- package/dist/stylog.mjs +3 -3
- package/dist/types/array.d.cts +2 -2
- package/dist/types/array.d.mts +2 -2
- package/dist/types/colors.d.cts +1 -1
- package/dist/types/colors.d.mts +1 -1
- package/dist/types/form.d.cts +1 -1
- package/dist/types/form.d.mts +1 -1
- package/dist/types/stylog.d.cts +1 -1
- package/dist/types/stylog.d.mts +1 -1
- package/dist/{utilities-DPscNbS1.mjs → utilities-BSv8VbnM.mjs} +1 -1
- package/dist/{utilities-CWV1GPGY.cjs → utilities-BVpk3LKy.cjs} +1 -1
- package/package.json +6 -6
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { H as Branded, er as Percent, nt as Maybe } from "./object-DyVg8BFt.mjs";
|
|
17
|
+
import { H as Branded, Qn as NumberRange, er as Percent, nt as Maybe } from "./object-DyVg8BFt.mjs";
|
|
18
18
|
import { t as CSS_COLORS } from "./css-colors-Dqz6Bfnp.mjs";
|
|
19
19
|
|
|
20
20
|
//#region src/types/colors.d.ts
|
|
@@ -310,11 +310,17 @@ declare class Color {
|
|
|
310
310
|
/** Iterates over the color representations (`Hex`, `RGB`, `HSL`). */
|
|
311
311
|
[Symbol.iterator](): Generator<Hex6 | Hex8 | RGB | RGBA | HSL | HSLA, void, unknown>;
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
313
|
+
* Allows the color to be used in string and number contexts.
|
|
314
|
+
* @param hint The hint to determine the conversion type.
|
|
315
|
+
*/
|
|
316
|
+
[Symbol.toPrimitive](hint: string): number | this | Hex8;
|
|
317
|
+
/**
|
|
318
|
+
* @instance Sets the opacity of this color to the given **absolute** percentage and returns a new instance.
|
|
314
319
|
*
|
|
315
320
|
* @remarks
|
|
321
|
+
* - This is an **absolute setter**: passing `50` means "set opacity to exactly 50%", regardless of the current opacity.
|
|
316
322
|
* - For solid colors ({@link Hex6}/{@link RGB}/{@link HSL}): Adds an alpha channel with the specified opacity.
|
|
317
|
-
* - For alpha colors ({@link Hex8}/{@link RGBA}/{@link HSLA}):
|
|
323
|
+
* - For alpha colors ({@link Hex8}/{@link RGBA}/{@link HSLA}): Replaces the existing alpha channel.
|
|
318
324
|
*
|
|
319
325
|
* @param opacity - A number between `0-100` representing the opacity percentage.
|
|
320
326
|
* @returns A new instance of `Color` containing all color formats with the applied opacity.
|
|
@@ -331,31 +337,72 @@ declare class Color {
|
|
|
331
337
|
*/
|
|
332
338
|
applyOpacity(opacity: Percent): Color;
|
|
333
339
|
/**
|
|
334
|
-
* @instance Darkens the color by
|
|
335
|
-
*
|
|
336
|
-
* @
|
|
340
|
+
* @instance Darkens the color by **subtracting** the given percentage points from the current lightness in HSL space.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* - This is a **relative adjustment**: passing `20` means "reduce lightness by 20 percentage points" from its current value.
|
|
344
|
+
* - Lightness is clamped to `0%` at minimum.
|
|
345
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
346
|
+
*
|
|
347
|
+
* @param percent - The percentage points to subtract from lightness (`0–100`).
|
|
348
|
+
* @returns A new `Color` instance with the reduced lightness.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* const blue = new Color("#0000ff"); // hsl(240, 100%, 50%)
|
|
352
|
+
* const darkerBlue = blue.applyDarkness(20);
|
|
353
|
+
* console.log(darkerBlue.hsl); // hsl(240, 100%, 30%)
|
|
337
354
|
*/
|
|
338
355
|
applyDarkness(percent: Percent): Color;
|
|
339
356
|
/**
|
|
340
|
-
* @instance Lightens the color by
|
|
341
|
-
*
|
|
342
|
-
* @
|
|
357
|
+
* @instance Lightens the color by **adding** the given percentage points to the current lightness in HSL space.
|
|
358
|
+
*
|
|
359
|
+
* @remarks
|
|
360
|
+
* - This is a **relative adjustment**: passing `30` means "increase lightness by 30 percentage points" from its current value.
|
|
361
|
+
* - Lightness is clamped to `100%` at maximum.
|
|
362
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
363
|
+
*
|
|
364
|
+
* @param percent - The percentage points to add to lightness (`0–100`).
|
|
365
|
+
* @returns A new `Color` instance with the increased lightness.
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* const green = new Color("#008000"); // hsl(120, 100%, 25.1%)
|
|
369
|
+
* const lighterGreen = green.applyBrightness(30);
|
|
370
|
+
* console.log(lighterGreen.hsl); // hsl(120, 100%, 55.1%)
|
|
343
371
|
*/
|
|
344
372
|
applyBrightness(percent: Percent): Color;
|
|
345
373
|
/**
|
|
346
|
-
* @instance
|
|
347
|
-
*
|
|
348
|
-
* @
|
|
374
|
+
* @instance Desaturates the color by **subtracting** the given percentage points from the current saturation in HSL space.
|
|
375
|
+
*
|
|
376
|
+
* @remarks
|
|
377
|
+
* - This is a **relative adjustment**: passing `50` means "reduce saturation by 50 percentage points" from its current value.
|
|
378
|
+
* - Saturation is clamped to `0%` at minimum (fully desaturated / grayscale).
|
|
379
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
380
|
+
*
|
|
381
|
+
* @param percent - The percentage points to subtract from saturation (`0–100`).
|
|
382
|
+
* @returns A new `Color` instance with the reduced saturation.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* const pink = new Color("#ff69b4"); // hsl(330, 100%, 70.59%)
|
|
386
|
+
* const dullPink = pink.applyDullness(50);
|
|
387
|
+
* console.log(dullPink.hsl); // hsl(330, 50%, 70.59%)
|
|
349
388
|
*/
|
|
350
389
|
applyDullness(percent: Percent): Color;
|
|
351
390
|
/**
|
|
352
|
-
* @instance Softens the color toward white by reducing saturation and increasing lightness
|
|
391
|
+
* @instance Softens the color toward white by **proportionally** reducing saturation and increasing lightness.
|
|
353
392
|
*
|
|
354
393
|
* @remarks
|
|
355
|
-
* This
|
|
394
|
+
* - This is a **proportional blend**: passing `40` means "move 40% of the *remaining distance* toward pure white".
|
|
395
|
+
* - Unlike {@link applyBrightness} or {@link applyDullness}, the effect scales relative to the current distance from white, producing a natural pastel/tint effect.
|
|
396
|
+
* - This creates a soft UI-like white shade effect (similar to some UI libraries' light color scale).
|
|
397
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
356
398
|
*
|
|
357
399
|
* @param percent - Value from `0` to `100` representing how far to push the color toward white.
|
|
358
400
|
* @returns A new `Color` instance shifted toward white.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* const purple = new Color("#800080"); // hsl(300, 100%, 25.1%)
|
|
404
|
+
* const softPurple = purple.applyWhiteShade(40);
|
|
405
|
+
* console.log(softPurple.hsl); // hsl(300, 60%, 55.06%)
|
|
359
406
|
*/
|
|
360
407
|
applyWhiteShade(percent: Percent): Color;
|
|
361
408
|
/**
|
|
@@ -410,6 +457,25 @@ declare class Color {
|
|
|
410
457
|
* @returns An array of four `Color` instances: `[base, tetrad1, tetrad2, tetrad3]`.
|
|
411
458
|
*/
|
|
412
459
|
getTetradColors(): Tetrad;
|
|
460
|
+
/**
|
|
461
|
+
* @instance Generates a color palette of evenly distributed hues based on the current color's saturation, lightness, and alpha.
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
* - Colors are spaced evenly around the color wheel (`360° / count` apart), starting from the current hue.
|
|
465
|
+
* - Saturation, lightness, and alpha from the source color are preserved across all generated colors.
|
|
466
|
+
*
|
|
467
|
+
* @typeParam N - A literal number type representing the palette size.
|
|
468
|
+
* @param count - The number of colors to generate in the palette (must be a positive integer ≥ `1`). Default: `7`.
|
|
469
|
+
* @param step - The step value (degree) to be added to the hue of the previous color. Default: `360 / count`.
|
|
470
|
+
* @returns Array of `Color` instances with the specified count.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* const red = new Color("#ff0000");
|
|
474
|
+
* const palette = red.generatePalette(4);
|
|
475
|
+
* console.log(palette.map((color) => color.hex));
|
|
476
|
+
* // ['#FF0000', '#80FF00', '#00FFFF', '#8000FF']
|
|
477
|
+
*/
|
|
478
|
+
generatePalette(count?: NumberRange<1, 360>, step?: NumberRange<1, 360>): Array<Color>;
|
|
413
479
|
/**
|
|
414
480
|
* @instance Gets the `WCAG` accessibility rating between this and another color.
|
|
415
481
|
* @param other - The other color to test contrast against.
|
|
@@ -423,6 +489,24 @@ declare class Color {
|
|
|
423
489
|
* @returns `true` if light, `false` if dark.
|
|
424
490
|
*/
|
|
425
491
|
isLightColor(threshold?: number): boolean;
|
|
492
|
+
/**
|
|
493
|
+
* @instance Convert the color to string.
|
|
494
|
+
* @returns The `Hex8` representation of the color.
|
|
495
|
+
*
|
|
496
|
+
* @remarks
|
|
497
|
+
* - Called by `String()`, `Object.prototype.toString()` or in template literals.
|
|
498
|
+
* - Uses the same implementation as `toJSON()`.
|
|
499
|
+
*/
|
|
500
|
+
toString(): Hex8;
|
|
501
|
+
/**
|
|
502
|
+
* @instance Convert the color to JSON.
|
|
503
|
+
* @returns The `Hex8` representation of the color.
|
|
504
|
+
*
|
|
505
|
+
* @remarks
|
|
506
|
+
* - Called by `JSON.stringify()`.
|
|
507
|
+
* - It uses the same implementation as `toString()`.
|
|
508
|
+
*/
|
|
509
|
+
toJSON(): Hex8;
|
|
426
510
|
/**
|
|
427
511
|
* @static Checks if a color is in {@link Hex6} format.
|
|
428
512
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { H as Branded, er as Percent, nt as Maybe } from "./object-DyVg8BFt.cjs";
|
|
17
|
+
import { H as Branded, Qn as NumberRange, er as Percent, nt as Maybe } from "./object-DyVg8BFt.cjs";
|
|
18
18
|
import { t as CSS_COLORS } from "./css-colors-Dqz6Bfnp.cjs";
|
|
19
19
|
|
|
20
20
|
//#region src/types/colors.d.ts
|
|
@@ -310,11 +310,17 @@ declare class Color {
|
|
|
310
310
|
/** Iterates over the color representations (`Hex`, `RGB`, `HSL`). */
|
|
311
311
|
[Symbol.iterator](): Generator<Hex6 | Hex8 | RGB | RGBA | HSL | HSLA, void, unknown>;
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
313
|
+
* Allows the color to be used in string and number contexts.
|
|
314
|
+
* @param hint The hint to determine the conversion type.
|
|
315
|
+
*/
|
|
316
|
+
[Symbol.toPrimitive](hint: string): number | this | Hex8;
|
|
317
|
+
/**
|
|
318
|
+
* @instance Sets the opacity of this color to the given **absolute** percentage and returns a new instance.
|
|
314
319
|
*
|
|
315
320
|
* @remarks
|
|
321
|
+
* - This is an **absolute setter**: passing `50` means "set opacity to exactly 50%", regardless of the current opacity.
|
|
316
322
|
* - For solid colors ({@link Hex6}/{@link RGB}/{@link HSL}): Adds an alpha channel with the specified opacity.
|
|
317
|
-
* - For alpha colors ({@link Hex8}/{@link RGBA}/{@link HSLA}):
|
|
323
|
+
* - For alpha colors ({@link Hex8}/{@link RGBA}/{@link HSLA}): Replaces the existing alpha channel.
|
|
318
324
|
*
|
|
319
325
|
* @param opacity - A number between `0-100` representing the opacity percentage.
|
|
320
326
|
* @returns A new instance of `Color` containing all color formats with the applied opacity.
|
|
@@ -331,31 +337,72 @@ declare class Color {
|
|
|
331
337
|
*/
|
|
332
338
|
applyOpacity(opacity: Percent): Color;
|
|
333
339
|
/**
|
|
334
|
-
* @instance Darkens the color by
|
|
335
|
-
*
|
|
336
|
-
* @
|
|
340
|
+
* @instance Darkens the color by **subtracting** the given percentage points from the current lightness in HSL space.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* - This is a **relative adjustment**: passing `20` means "reduce lightness by 20 percentage points" from its current value.
|
|
344
|
+
* - Lightness is clamped to `0%` at minimum.
|
|
345
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
346
|
+
*
|
|
347
|
+
* @param percent - The percentage points to subtract from lightness (`0–100`).
|
|
348
|
+
* @returns A new `Color` instance with the reduced lightness.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* const blue = new Color("#0000ff"); // hsl(240, 100%, 50%)
|
|
352
|
+
* const darkerBlue = blue.applyDarkness(20);
|
|
353
|
+
* console.log(darkerBlue.hsl); // hsl(240, 100%, 30%)
|
|
337
354
|
*/
|
|
338
355
|
applyDarkness(percent: Percent): Color;
|
|
339
356
|
/**
|
|
340
|
-
* @instance Lightens the color by
|
|
341
|
-
*
|
|
342
|
-
* @
|
|
357
|
+
* @instance Lightens the color by **adding** the given percentage points to the current lightness in HSL space.
|
|
358
|
+
*
|
|
359
|
+
* @remarks
|
|
360
|
+
* - This is a **relative adjustment**: passing `30` means "increase lightness by 30 percentage points" from its current value.
|
|
361
|
+
* - Lightness is clamped to `100%` at maximum.
|
|
362
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
363
|
+
*
|
|
364
|
+
* @param percent - The percentage points to add to lightness (`0–100`).
|
|
365
|
+
* @returns A new `Color` instance with the increased lightness.
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* const green = new Color("#008000"); // hsl(120, 100%, 25.1%)
|
|
369
|
+
* const lighterGreen = green.applyBrightness(30);
|
|
370
|
+
* console.log(lighterGreen.hsl); // hsl(120, 100%, 55.1%)
|
|
343
371
|
*/
|
|
344
372
|
applyBrightness(percent: Percent): Color;
|
|
345
373
|
/**
|
|
346
|
-
* @instance
|
|
347
|
-
*
|
|
348
|
-
* @
|
|
374
|
+
* @instance Desaturates the color by **subtracting** the given percentage points from the current saturation in HSL space.
|
|
375
|
+
*
|
|
376
|
+
* @remarks
|
|
377
|
+
* - This is a **relative adjustment**: passing `50` means "reduce saturation by 50 percentage points" from its current value.
|
|
378
|
+
* - Saturation is clamped to `0%` at minimum (fully desaturated / grayscale).
|
|
379
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
380
|
+
*
|
|
381
|
+
* @param percent - The percentage points to subtract from saturation (`0–100`).
|
|
382
|
+
* @returns A new `Color` instance with the reduced saturation.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* const pink = new Color("#ff69b4"); // hsl(330, 100%, 70.59%)
|
|
386
|
+
* const dullPink = pink.applyDullness(50);
|
|
387
|
+
* console.log(dullPink.hsl); // hsl(330, 50%, 70.59%)
|
|
349
388
|
*/
|
|
350
389
|
applyDullness(percent: Percent): Color;
|
|
351
390
|
/**
|
|
352
|
-
* @instance Softens the color toward white by reducing saturation and increasing lightness
|
|
391
|
+
* @instance Softens the color toward white by **proportionally** reducing saturation and increasing lightness.
|
|
353
392
|
*
|
|
354
393
|
* @remarks
|
|
355
|
-
* This
|
|
394
|
+
* - This is a **proportional blend**: passing `40` means "move 40% of the *remaining distance* toward pure white".
|
|
395
|
+
* - Unlike {@link applyBrightness} or {@link applyDullness}, the effect scales relative to the current distance from white, producing a natural pastel/tint effect.
|
|
396
|
+
* - This creates a soft UI-like white shade effect (similar to some UI libraries' light color scale).
|
|
397
|
+
* - The original alpha (opacity) is preserved in the returned color.
|
|
356
398
|
*
|
|
357
399
|
* @param percent - Value from `0` to `100` representing how far to push the color toward white.
|
|
358
400
|
* @returns A new `Color` instance shifted toward white.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* const purple = new Color("#800080"); // hsl(300, 100%, 25.1%)
|
|
404
|
+
* const softPurple = purple.applyWhiteShade(40);
|
|
405
|
+
* console.log(softPurple.hsl); // hsl(300, 60%, 55.06%)
|
|
359
406
|
*/
|
|
360
407
|
applyWhiteShade(percent: Percent): Color;
|
|
361
408
|
/**
|
|
@@ -410,6 +457,25 @@ declare class Color {
|
|
|
410
457
|
* @returns An array of four `Color` instances: `[base, tetrad1, tetrad2, tetrad3]`.
|
|
411
458
|
*/
|
|
412
459
|
getTetradColors(): Tetrad;
|
|
460
|
+
/**
|
|
461
|
+
* @instance Generates a color palette of evenly distributed hues based on the current color's saturation, lightness, and alpha.
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
* - Colors are spaced evenly around the color wheel (`360° / count` apart), starting from the current hue.
|
|
465
|
+
* - Saturation, lightness, and alpha from the source color are preserved across all generated colors.
|
|
466
|
+
*
|
|
467
|
+
* @typeParam N - A literal number type representing the palette size.
|
|
468
|
+
* @param count - The number of colors to generate in the palette (must be a positive integer ≥ `1`). Default: `7`.
|
|
469
|
+
* @param step - The step value (degree) to be added to the hue of the previous color. Default: `360 / count`.
|
|
470
|
+
* @returns Array of `Color` instances with the specified count.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* const red = new Color("#ff0000");
|
|
474
|
+
* const palette = red.generatePalette(4);
|
|
475
|
+
* console.log(palette.map((color) => color.hex));
|
|
476
|
+
* // ['#FF0000', '#80FF00', '#00FFFF', '#8000FF']
|
|
477
|
+
*/
|
|
478
|
+
generatePalette(count?: NumberRange<1, 360>, step?: NumberRange<1, 360>): Array<Color>;
|
|
413
479
|
/**
|
|
414
480
|
* @instance Gets the `WCAG` accessibility rating between this and another color.
|
|
415
481
|
* @param other - The other color to test contrast against.
|
|
@@ -423,6 +489,24 @@ declare class Color {
|
|
|
423
489
|
* @returns `true` if light, `false` if dark.
|
|
424
490
|
*/
|
|
425
491
|
isLightColor(threshold?: number): boolean;
|
|
492
|
+
/**
|
|
493
|
+
* @instance Convert the color to string.
|
|
494
|
+
* @returns The `Hex8` representation of the color.
|
|
495
|
+
*
|
|
496
|
+
* @remarks
|
|
497
|
+
* - Called by `String()`, `Object.prototype.toString()` or in template literals.
|
|
498
|
+
* - Uses the same implementation as `toJSON()`.
|
|
499
|
+
*/
|
|
500
|
+
toString(): Hex8;
|
|
501
|
+
/**
|
|
502
|
+
* @instance Convert the color to JSON.
|
|
503
|
+
* @returns The `Hex8` representation of the color.
|
|
504
|
+
*
|
|
505
|
+
* @remarks
|
|
506
|
+
* - Called by `JSON.stringify()`.
|
|
507
|
+
* - It uses the same implementation as `toString()`.
|
|
508
|
+
*/
|
|
509
|
+
toJSON(): Hex8;
|
|
426
510
|
/**
|
|
427
511
|
* @static Checks if a color is in {@link Hex6} format.
|
|
428
512
|
*
|
|
@@ -19,6 +19,8 @@ import { E as NestedPrimitiveKey, ot as NormalPrimitiveKey, y as GenericObject }
|
|
|
19
19
|
//#region src/types/array.d.ts
|
|
20
20
|
/** * Flatten Array or Wrap in Array */
|
|
21
21
|
type Flattened<T> = T extends (infer U)[] ? Flattened<U> : T;
|
|
22
|
+
/** * Union of type `T` and array of `T` */
|
|
23
|
+
type TypeOrArray<T> = T | Array<T>;
|
|
22
24
|
/**
|
|
23
25
|
* * Configuration for `createOptionsArray`.
|
|
24
26
|
* - Defines the mapping between keys in the input objects and the keys in the output options.
|
|
@@ -127,4 +129,4 @@ interface FindOptions<T extends GenericObject = {}> {
|
|
|
127
129
|
data?: T[] | (() => T[]);
|
|
128
130
|
}
|
|
129
131
|
//#endregion
|
|
130
|
-
export { Flattened as a, OrderOption as c, SortOptions as d, FirstFieldValue as i, SortByOption as l, FindOptions as n, Option as o, FirstFieldKey as r, OptionsConfig as s, FieldValue as t, SortNature as u };
|
|
132
|
+
export { Flattened as a, OrderOption as c, SortOptions as d, TypeOrArray as f, FirstFieldValue as i, SortByOption as l, FindOptions as n, Option as o, FirstFieldKey as r, OptionsConfig as s, FieldValue as t, SortNature as u };
|
|
@@ -19,6 +19,8 @@ import { E as NestedPrimitiveKey, ot as NormalPrimitiveKey, y as GenericObject }
|
|
|
19
19
|
//#region src/types/array.d.ts
|
|
20
20
|
/** * Flatten Array or Wrap in Array */
|
|
21
21
|
type Flattened<T> = T extends (infer U)[] ? Flattened<U> : T;
|
|
22
|
+
/** * Union of type `T` and array of `T` */
|
|
23
|
+
type TypeOrArray<T> = T | Array<T>;
|
|
22
24
|
/**
|
|
23
25
|
* * Configuration for `createOptionsArray`.
|
|
24
26
|
* - Defines the mapping between keys in the input objects and the keys in the output options.
|
|
@@ -127,4 +129,4 @@ interface FindOptions<T extends GenericObject = {}> {
|
|
|
127
129
|
data?: T[] | (() => T[]);
|
|
128
130
|
}
|
|
129
131
|
//#endregion
|
|
130
|
-
export { Flattened as a, OrderOption as c, SortOptions as d, FirstFieldValue as i, SortByOption as l, FindOptions as n, Option as o, FirstFieldKey as r, OptionsConfig as s, FieldValue as t, SortNature as u };
|
|
132
|
+
export { Flattened as a, OrderOption as c, SortOptions as d, TypeOrArray as f, FirstFieldValue as i, SortByOption as l, FindOptions as n, Option as o, FirstFieldKey as r, OptionsConfig as s, FieldValue as t, SortNature as u };
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { a as isNonEmptyString, c as isNumber, d as isString, m as isUndefined, n as isBoolean, u as isPrimitive } from "./primitives-Djsevc69.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
18
|
+
import { C as isMethodDescriptor, E as isObjectWithKeys, T as isObject, b as isFunction, c as isHexString, d as isNumericString, g as isArrayOfType, h as isArray, j as isValidArray, m as isUUID, w as isNotEmptyObject } from "./specials-krf7zsqI.mjs";
|
|
19
|
+
import { a as normalizeNumber } from "./utilities-BSv8VbnM.mjs";
|
|
20
|
+
import { t as isDateLike } from "./guards-DKGBsd6x.mjs";
|
|
21
21
|
|
|
22
22
|
//#region src/array/helpers.ts
|
|
23
23
|
/**
|
|
@@ -133,99 +133,6 @@ function sortAnArray(array, options) {
|
|
|
133
133
|
return [...array];
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region src/date/guards.ts
|
|
138
|
-
/**
|
|
139
|
-
* * Checks if the provided value is a valid time string in "HH:MM" format.
|
|
140
|
-
*
|
|
141
|
-
* @param value - The value to check.
|
|
142
|
-
* @returns `true` if the value is a valid time string, `false` otherwise.
|
|
143
|
-
*/
|
|
144
|
-
function isValidTime(value) {
|
|
145
|
-
if (!isNonEmptyString(value)) return false;
|
|
146
|
-
const [hourStr, minuteStr] = value.split(":");
|
|
147
|
-
if (!isNumericString(hourStr) || !isNumericString(minuteStr)) return false;
|
|
148
|
-
const hour = Number(hourStr);
|
|
149
|
-
const minute = Number(minuteStr);
|
|
150
|
-
return hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* * Checks if the provided value is a valid `UTCOffset` (e.g. `UTC-01:30`).
|
|
154
|
-
*
|
|
155
|
-
* @param value - The value to check.
|
|
156
|
-
* @returns `true` if the value is a valid utc offset, `false` otherwise.
|
|
157
|
-
*/
|
|
158
|
-
function isValidUTCOffset(value) {
|
|
159
|
-
return isString(value) ? /^UTC[+-]?(?:0[0-9]|1[0-4]):(?:00|15|30|45)$/.test(value) : false;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* * Validates whether the provided value is a recognized IANA time zone identifier (excluding `"Factory"`), based on the {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}.
|
|
163
|
-
*
|
|
164
|
-
* @remarks
|
|
165
|
-
* - Relies on a large constant map of time zone identifiers, which can increase bundle size in browser environments. Matches against `597` identifiers.
|
|
166
|
-
* - Prefer {@link isNativeTimeZoneId} when you want a lightweight, native-only validation approach. Matches against `418` identifiers.
|
|
167
|
-
*
|
|
168
|
-
* @param value Time zone identifier to validate.
|
|
169
|
-
* @returns `true` if the value is a valid IANA time zone identifier, otherwise `false`.
|
|
170
|
-
*/
|
|
171
|
-
function isValidTimeZoneId(value) {
|
|
172
|
-
return isNonEmptyString(value) ? new Set([...IANA_TZ_IDS]).has(value) : false;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* * Validates whether the provided value is a supported time zone identifier using the native JavaScript API (`Intl.supportedValuesOf('timeZone')`).
|
|
176
|
-
*
|
|
177
|
-
* @remarks
|
|
178
|
-
* - Uses only native {@link Intl} capabilities—minimal code footprint, highly performant. Matches against `418` identifiers.
|
|
179
|
-
* - Prefer {@link isValidTimeZoneId} when validation must align strictly with the full
|
|
180
|
-
* {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database}. Matches against `597` identifiers.
|
|
181
|
-
*
|
|
182
|
-
* @param value Time zone identifier to validate.
|
|
183
|
-
* @returns `true` if the value is a valid native JS-supported time zone identifier, otherwise `false`.
|
|
184
|
-
*/
|
|
185
|
-
function isNativeTimeZoneId(value) {
|
|
186
|
-
return isNonEmptyString(value) ? new Set(NATIVE_TZ_IDS).has(value) : false;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* * Checks if the year is a leap year.
|
|
190
|
-
*
|
|
191
|
-
* - A year is a leap year if it is divisible by 4, but not divisible by 100, unless it is also divisible by 400.
|
|
192
|
-
* - For example, 2000 and 2400 are leap years, but 1900 and 2100 are not.
|
|
193
|
-
* @param year The year to check.
|
|
194
|
-
* @returns `true` if the year is a leap year, `false` otherwise.
|
|
195
|
-
*/
|
|
196
|
-
function isLeapYear(year) {
|
|
197
|
-
const $year = normalizeNumber(year);
|
|
198
|
-
return $year ? $year % 4 === 0 && $year % 100 !== 0 || $year % 400 === 0 : false;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* * Checks if a value is a date-like object from `Date`, `Chronos`, `Moment.js`, `Day.js`, `Luxon`, `JS-Joda`, or `Temporal`
|
|
202
|
-
* @param value Value to check if it is date-like object.
|
|
203
|
-
* @returns `true` if the value is date-like object, otherwise `false`.
|
|
204
|
-
*/
|
|
205
|
-
function isDateLike(value) {
|
|
206
|
-
if (value instanceof Date) return true;
|
|
207
|
-
if (isObject(value)) {
|
|
208
|
-
if (isFunction(value.format) && isFunction(value.toJSON) && isFunction(value.toISOString)) return true;
|
|
209
|
-
if (isFunction(value.toISO) && isFunction(value.toFormat) && isBoolean(value.isValid)) return true;
|
|
210
|
-
if (isFunction(value.plus) && isFunction(value.minus) && isFunction(value.equals) && isFunction(value.getClass)) return true;
|
|
211
|
-
if (isFunction(value.toJSON) && isFunction(value.toString) && [
|
|
212
|
-
"Instant",
|
|
213
|
-
"Duration",
|
|
214
|
-
"PlainDate",
|
|
215
|
-
"PlainTime",
|
|
216
|
-
"PlainDateTime",
|
|
217
|
-
"PlainMonthDay",
|
|
218
|
-
"PlainYearMonth",
|
|
219
|
-
"ZonedDateTime"
|
|
220
|
-
].includes(value.constructor?.name ?? "")) return true;
|
|
221
|
-
}
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
/** Checks if a value represents time value (number) with different forms of {@link TimeWithUnit units} */
|
|
225
|
-
function isTimeWithUnit(value) {
|
|
226
|
-
return isNonEmptyString(value) && /^-?\d*\.?\d+ *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.test(value);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
136
|
//#endregion
|
|
230
137
|
//#region src/utils/index.ts
|
|
231
138
|
/**
|
|
@@ -758,7 +665,7 @@ function bytesToBase64(bytes) {
|
|
|
758
665
|
const h2 = (o1 & 3) << 4 | o2 >> 4;
|
|
759
666
|
const h3 = (o2 & 15) << 2 | o3 >> 6;
|
|
760
667
|
const h4 = o3 & 63;
|
|
761
|
-
out += _b64chars[h1] + _b64chars[h2] + _b64chars[isNaN(o2) ? 64 : h3] + _b64chars[isNaN(o3) ? 64 : h4];
|
|
668
|
+
out += _b64chars[h1] + _b64chars[h2] + _b64chars[Number.isNaN(o2) ? 64 : h3] + _b64chars[Number.isNaN(o3) ? 64 : h4];
|
|
762
669
|
}
|
|
763
670
|
return out;
|
|
764
671
|
}
|
|
@@ -1843,4 +1750,4 @@ function trimString(input) {
|
|
|
1843
1750
|
}
|
|
1844
1751
|
|
|
1845
1752
|
//#endregion
|
|
1846
|
-
export {
|
|
1753
|
+
export { uint8To32ArrayBE as A, getInstanceMethodNames as B, bytesToUtf8 as C, intTo4BytesBE as D, hmacSha256 as E, debounceAction as F, stableStringify as G, getStaticMethodNames as H, deepParsePrimitives as I, naturalSort as J, stripJsonEdgeGarbage as K, definePrototypeMethod as L, convertArrayToString as M, countInstanceMethods as N, randomHex as O, countStaticMethods as P, getClassDetails as R, bytesToHex as S, hexToBytes as T, isDeepEqual as U, getStaticGetterNames as V, parseJSON as W, _getNumericProp as X, sortAnArray as Y, _resolveNestedKey as Z, _constantTimeEquals as _, isUUIDv1 as a, base64ToBytes as b, isUUIDv4 as c, isUUIDv7 as d, isUUIDv8 as f, sha256 as g, sha1 as h, decodeUUID as i, utf8ToBytes as j, sha256Bytes as k, isUUIDv5 as l, md5 as m, trimString as n, isUUIDv2 as o, uuid as p, throttleAction as q, truncateString as r, isUUIDv3 as s, generateRandomID as t, isUUIDv6 as u, _padStartWith0 as v, concatBytes as w, bytesToBase64 as x, _splitByCharLength as y, getInstanceGetterNames as z };
|