@oscarpalmer/atoms 0.78.0 → 0.80.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.
Files changed (113) hide show
  1. package/dist/array/sort.cjs +5 -10
  2. package/dist/array/sort.js +5 -10
  3. package/dist/colour/base.cjs +27 -2
  4. package/dist/colour/base.js +27 -2
  5. package/dist/colour/functions.cjs +1 -1
  6. package/dist/colour/functions.js +1 -1
  7. package/dist/colour/hsl.cjs +2 -12
  8. package/dist/colour/hsl.js +2 -12
  9. package/dist/colour/index.cjs +5 -0
  10. package/dist/colour/index.js +6 -1
  11. package/dist/colour/rgb.cjs +2 -8
  12. package/dist/colour/rgb.js +2 -8
  13. package/dist/index.cjs +5 -0
  14. package/dist/index.js +5 -0
  15. package/dist/internal/array/find.cjs +6 -7
  16. package/dist/internal/array/find.js +6 -7
  17. package/dist/value/equal.cjs +4 -1
  18. package/dist/value/equal.js +4 -1
  19. package/package.json +15 -8
  20. package/src/array/chunk.ts +1 -1
  21. package/src/array/count.ts +2 -2
  22. package/src/array/exists.ts +2 -2
  23. package/src/array/filter.ts +2 -2
  24. package/src/array/find.ts +2 -2
  25. package/src/array/group-by.ts +2 -2
  26. package/src/array/index-of.ts +2 -2
  27. package/src/array/index.ts +3 -2
  28. package/src/array/insert.ts +2 -2
  29. package/src/array/models.ts +1 -1
  30. package/src/array/shuffle.ts +1 -1
  31. package/src/array/sort.ts +13 -20
  32. package/src/array/splice.ts +1 -1
  33. package/src/array/to-map.ts +2 -2
  34. package/src/array/to-record.ts +60 -60
  35. package/src/array/unique.ts +5 -5
  36. package/src/colour/base.ts +48 -12
  37. package/src/colour/functions.ts +4 -4
  38. package/src/colour/hex.ts +3 -3
  39. package/src/colour/hsl.ts +6 -18
  40. package/src/colour/index.ts +2 -1
  41. package/src/colour/is.ts +4 -7
  42. package/src/colour/rgb.ts +6 -14
  43. package/src/emitter.ts +1 -1
  44. package/src/function.ts +2 -2
  45. package/src/index.ts +16 -16
  46. package/src/internal/array/callbacks.ts +2 -2
  47. package/src/internal/array/find.ts +10 -11
  48. package/src/internal/value/handle.ts +1 -1
  49. package/src/is.ts +2 -2
  50. package/src/logger.ts +1 -1
  51. package/src/query.ts +4 -4
  52. package/src/random.ts +1 -1
  53. package/src/sized.ts +1 -1
  54. package/src/string/case.ts +1 -1
  55. package/src/string/index.ts +2 -1
  56. package/src/string/template.ts +3 -3
  57. package/src/value/clone.ts +3 -3
  58. package/src/value/compare.ts +3 -3
  59. package/src/value/diff.ts +4 -4
  60. package/src/value/equal.ts +6 -3
  61. package/src/value/get.ts +2 -2
  62. package/src/value/index.ts +2 -1
  63. package/src/value/merge.ts +2 -2
  64. package/src/value/set.ts +2 -2
  65. package/src/value/smush.ts +3 -3
  66. package/src/value/unsmush.ts +3 -3
  67. package/types/array/count.d.ts +1 -1
  68. package/types/array/exists.d.ts +1 -1
  69. package/types/array/filter.d.ts +1 -1
  70. package/types/array/find.d.ts +1 -1
  71. package/types/array/group-by.d.ts +1 -1
  72. package/types/array/index-of.d.ts +1 -1
  73. package/types/array/index.d.ts +1 -1
  74. package/types/array/insert.d.ts +1 -1
  75. package/types/array/models.d.ts +1 -1
  76. package/types/array/sort.d.ts +2 -2
  77. package/types/array/to-map.d.ts +1 -1
  78. package/types/array/to-record.d.ts +1 -1
  79. package/types/array/unique.d.ts +1 -1
  80. package/types/colour/base.d.cts +9 -1
  81. package/types/colour/base.d.ts +12 -2
  82. package/types/colour/functions.d.cts +9 -1
  83. package/types/colour/functions.d.ts +3 -3
  84. package/types/colour/hex.d.cts +9 -1
  85. package/types/colour/hex.d.ts +2 -2
  86. package/types/colour/hsl.d.cts +9 -1
  87. package/types/colour/hsl.d.ts +3 -3
  88. package/types/colour/index.d.cts +27 -1
  89. package/types/colour/index.d.ts +2 -1
  90. package/types/colour/is.d.cts +10 -2
  91. package/types/colour/is.d.ts +4 -4
  92. package/types/colour/rgb.d.cts +9 -1
  93. package/types/colour/rgb.d.ts +3 -3
  94. package/types/function.d.ts +1 -1
  95. package/types/index.d.cts +37 -9
  96. package/types/index.d.ts +16 -16
  97. package/types/internal/array/callbacks.d.ts +1 -1
  98. package/types/internal/array/find.d.ts +1 -1
  99. package/types/internal/value/handle.d.ts +1 -1
  100. package/types/is.d.ts +1 -1
  101. package/types/models.d.cts +10 -3
  102. package/types/query.d.ts +1 -1
  103. package/types/string/template.d.ts +1 -1
  104. package/types/value/get.d.cts +10 -3
  105. package/types/value/get.d.ts +1 -1
  106. package/types/value/index.d.cts +10 -3
  107. package/types/value/index.d.ts +1 -1
  108. package/types/value/merge.d.ts +1 -1
  109. package/types/value/set.d.cts +2 -1
  110. package/types/value/set.d.ts +1 -1
  111. package/types/value/smush.d.cts +10 -3
  112. package/types/value/smush.d.ts +1 -1
  113. package/types/value/unsmush.d.ts +1 -1
@@ -1,6 +1,6 @@
1
- import type {PlainObject} from '~/models';
2
- import {getString} from '~/string/index';
3
- import {getValue} from '~/value/get';
1
+ import type {PlainObject} from '../models';
2
+ import {getString} from '../string/index';
3
+ import {getValue} from '../value/get';
4
4
 
5
5
  type Options = {
6
6
  /**
@@ -1,5 +1,5 @@
1
- import {isArrayOrPlainObject} from '~/is';
2
- import type {ArrayOrPlainObject, GenericCallback, PlainObject} from '~/models';
1
+ import {isArrayOrPlainObject} from '../is';
2
+ import type {ArrayOrPlainObject, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Clone any kind of value _(deeply, if needed)_
@@ -46,7 +46,7 @@ export function clone(value: unknown) {
46
46
  return cloneRegularExpression(value);
47
47
 
48
48
  case isArrayOrPlainObject(value):
49
- return cloneObject(value);
49
+ return cloneObject(value as ArrayOrPlainObject);
50
50
 
51
51
  default:
52
52
  return structuredClone(value);
@@ -1,6 +1,6 @@
1
- import {max} from '~/math';
2
- import {getNumber} from '~/number';
3
- import {words, getString, join} from '~/string';
1
+ import {max} from '../math';
2
+ import {getNumber} from '../number';
3
+ import {getString, join, words} from '../string/index';
4
4
 
5
5
  /**
6
6
  * Compare two values _(for sorting purposes)_
package/src/value/diff.ts CHANGED
@@ -1,7 +1,7 @@
1
- import {isArrayOrPlainObject} from '~/is';
2
- import type {ArrayOrPlainObject, Key, PlainObject} from '~/models';
3
- import {join} from '~/string/index';
4
- import {equal} from '~/value/equal';
1
+ import {isArrayOrPlainObject} from '../is';
2
+ import type {ArrayOrPlainObject, Key, PlainObject} from '../models';
3
+ import {join} from '../string/index';
4
+ import {equal} from '../value/equal';
5
5
 
6
6
  export type DiffType = 'full' | 'none' | 'partial';
7
7
 
@@ -1,5 +1,5 @@
1
- import {isPlainObject} from '~/is';
2
- import type {ArrayOrPlainObject, PlainObject} from '~/models';
1
+ import {isPlainObject} from '../is';
2
+ import type {ArrayOrPlainObject, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * Are two strings equal? _(Case-sensitive by default)_
@@ -54,7 +54,10 @@ export function equal(
54
54
 
55
55
  case Array.isArray(first) && Array.isArray(second):
56
56
  case isPlainObject(first) && isPlainObject(second):
57
- return equalObject(first, second);
57
+ return equalObject(
58
+ first as ArrayOrPlainObject,
59
+ second as ArrayOrPlainObject,
60
+ );
58
61
 
59
62
  case typeof first === 'string' && ignoreCase === true:
60
63
  return Object.is(first.toLowerCase(), (second as string).toLowerCase());
package/src/value/get.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type {ToString} from 'type-fest/source/internal/string';
2
- import {handleValue} from '~/internal/value/handle';
3
- import type {ArrayOrPlainObject, Get, Paths} from '~/models';
2
+ import {handleValue} from '../internal/value/handle';
3
+ import type {ArrayOrPlainObject, Get, Paths} from '../models';
4
4
 
5
5
  /**
6
6
  * - Get the value from an object using a known path
@@ -1,4 +1,4 @@
1
- import type {PlainObject} from '~/models';
1
+ import type {PlainObject} from '../models';
2
2
 
3
3
  /**
4
4
  * Create a new object with only the specified keys
@@ -28,3 +28,4 @@ export * from './merge';
28
28
  export * from './set';
29
29
  export * from './smush';
30
30
  export * from './unsmush';
31
+
@@ -1,5 +1,5 @@
1
- import {isArrayOrPlainObject} from '~/is';
2
- import type {ArrayOrPlainObject, PlainObject} from '~/models';
1
+ import {isArrayOrPlainObject} from '../is';
2
+ import type {ArrayOrPlainObject, PlainObject} from '../models';
3
3
 
4
4
  type MergeOptions = {
5
5
  /**
package/src/value/set.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {handleValue} from '~/internal/value/handle';
2
- import type {ArrayOrPlainObject, Paths, PlainObject} from '~/models';
1
+ import {handleValue} from '../internal/value/handle';
2
+ import type {ArrayOrPlainObject, Paths, PlainObject} from '../models';
3
3
 
4
4
  /**
5
5
  * - Set the value in an object using a known path
@@ -1,8 +1,8 @@
1
1
  import type {Get, Paths, Simplify} from 'type-fest';
2
2
  import type {ToString} from 'type-fest/source/internal/string';
3
- import {isArrayOrPlainObject} from '~/is';
4
- import type {ArrayOrPlainObject, PlainObject} from '~/models';
5
- import {join} from '~/string/index';
3
+ import {isArrayOrPlainObject} from '../is';
4
+ import type {ArrayOrPlainObject, PlainObject} from '../models';
5
+ import {join} from '../string/index';
6
6
 
7
7
  type Smushed<Value> = Simplify<{
8
8
  [Key in Paths<Value>]: Get<Value, ToString<Key>>;
@@ -1,7 +1,7 @@
1
1
  import type {KeysOfUnion, Simplify} from 'type-fest';
2
- import {isArrayOrPlainObject} from '~/is';
3
- import type {PlainObject} from '~/models';
4
- import {setValue} from '~/value/set';
2
+ import {isArrayOrPlainObject} from '../is';
3
+ import type {PlainObject} from '../models';
4
+ import {setValue} from '../value/set';
5
5
 
6
6
  type Unsmushed<Value extends PlainObject> = Simplify<
7
7
  Omit<
@@ -1,4 +1,4 @@
1
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
2
  /**
3
3
  * Get the number of items _(count)_ that match the given value
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
2
  /**
3
3
  * Does the value exist in array?
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
2
  /**
3
3
  * Get a filtered array of items matching `value`
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
2
  /**
3
3
  * Get the first item matching `value` _(or `undefined` if no match is found)_
4
4
  */
@@ -1,5 +1,5 @@
1
1
  import type { Simplify } from 'type-fest';
2
- import type { Key, KeyedValue, PlainObject } from '~/models';
2
+ import type { Key, KeyedValue, PlainObject } from '../models';
3
3
  /**
4
4
  * Create a record from an array of items using a specific key
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
2
  /**
3
3
  * Get the index for the first item matching `value` _(or `-1` if no match is found)_
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { NestedArrayType } from '~/models';
1
+ import type { NestedArrayType } from '../models';
2
2
  /**
3
3
  * Flatten an array _(using native `flat` and maximum depth)_
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { InsertType } from '~/array/models';
1
+ import type { InsertType } from './models';
2
2
  /**
3
3
  * - Insert values into an array _(at the end)_
4
4
  * - _(Uses chunking to avoid stack overflow_)
@@ -1,4 +1,4 @@
1
- import type { GenericCallback, Key } from '~/models';
1
+ import type { GenericCallback, Key } from '../models';
2
2
  export type Callbacks = {
3
3
  bool?: GenericCallback;
4
4
  key?: GenericCallback;
@@ -1,5 +1,5 @@
1
- import type { SortKey } from '~/array/models';
2
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
+ import type { SortKey } from './models';
3
3
  /**
4
4
  * Sort an array of items _(defaults to ascending)_
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
2
  /**
3
3
  * Create a map from an array of items _(using their indices as keys)_
4
4
  */
@@ -1,5 +1,5 @@
1
1
  import type { Simplify } from 'type-fest';
2
- import type { Key, KeyedValue, PlainObject } from '~/models';
2
+ import type { Key, KeyedValue, PlainObject } from '../models';
3
3
  /**
4
4
  * Create a record from an array of items _(using their indices as keys)_
5
5
  */
@@ -1,4 +1,4 @@
1
- import type { Key, PlainObject } from '~/models';
1
+ import type { Key, PlainObject } from '../models';
2
2
  /**
3
3
  * Get an array of unique items
4
4
  */
@@ -77,6 +77,10 @@ declare class HexColour {
77
77
  */
78
78
  static toRgb(value: string): RGBColour;
79
79
  }
80
+ export type Properties = {
81
+ hsl: Array<keyof HSLColourValue>;
82
+ rgb: Array<keyof RGBColourValue>;
83
+ };
80
84
  export declare abstract class Colour<Model> {
81
85
  private readonly $colour;
82
86
  protected readonly state: ColourState<Model>;
@@ -84,7 +88,11 @@ export declare abstract class Colour<Model> {
84
88
  * Get the current value of the colour
85
89
  */
86
90
  get value(): Model;
87
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
91
+ /**
92
+ * Set the current value of the colour
93
+ */
94
+ set value(value: Model);
95
+ constructor(type: keyof Properties, value: Model);
88
96
  /**
89
97
  * Convert the colour to a hex-colour
90
98
  */
@@ -1,4 +1,10 @@
1
- import type { HexColour } from '~/colour/hex';
1
+ import type { HexColour } from './hex';
2
+ import type { HSLColourValue } from './hsl';
3
+ import type { RGBColourValue } from './rgb';
4
+ type Properties = {
5
+ hsl: Array<keyof HSLColourValue>;
6
+ rgb: Array<keyof RGBColourValue>;
7
+ };
2
8
  export declare abstract class Colour<Model> {
3
9
  private readonly $colour;
4
10
  protected readonly state: ColourState<Model>;
@@ -6,7 +12,11 @@ export declare abstract class Colour<Model> {
6
12
  * Get the current value of the colour
7
13
  */
8
14
  get value(): Model;
9
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
15
+ /**
16
+ * Set the current value of the colour
17
+ */
18
+ set value(value: Model);
19
+ constructor(type: keyof Properties, value: Model);
10
20
  /**
11
21
  * Convert the colour to a hex-colour
12
22
  */
@@ -77,6 +77,10 @@ declare class HexColour {
77
77
  */
78
78
  static toRgb(value: string): RGBColour;
79
79
  }
80
+ export type Properties = {
81
+ hsl: Array<keyof HSLColourValue>;
82
+ rgb: Array<keyof RGBColourValue>;
83
+ };
80
84
  declare abstract class Colour<Model> {
81
85
  private readonly $colour;
82
86
  protected readonly state: ColourState<Model>;
@@ -84,7 +88,11 @@ declare abstract class Colour<Model> {
84
88
  * Get the current value of the colour
85
89
  */
86
90
  get value(): Model;
87
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
91
+ /**
92
+ * Set the current value of the colour
93
+ */
94
+ set value(value: Model);
95
+ constructor(type: keyof Properties, value: Model);
88
96
  /**
89
97
  * Convert the colour to a hex-colour
90
98
  */
@@ -1,6 +1,6 @@
1
- import { HexColour } from '~/colour/hex';
2
- import { HSLColour, type HSLColourValue } from '~/colour/hsl';
3
- import { RGBColour, type RGBColourValue } from '~/colour/rgb';
1
+ import { HexColour } from './hex';
2
+ import { HSLColour, type HSLColourValue } from './hsl';
3
+ import { RGBColour, type RGBColourValue } from './rgb';
4
4
  export declare const anyPattern: RegExp;
5
5
  export declare function getNormalisedHex(value: string): string;
6
6
  /**
@@ -81,6 +81,10 @@ export declare class HexColour {
81
81
  * Get a hex-colour from a string
82
82
  */
83
83
  export declare function getHexColour(value: string): HexColour;
84
+ export type Properties = {
85
+ hsl: Array<keyof HSLColourValue>;
86
+ rgb: Array<keyof RGBColourValue>;
87
+ };
84
88
  declare abstract class Colour<Model> {
85
89
  private readonly $colour;
86
90
  protected readonly state: ColourState<Model>;
@@ -88,7 +92,11 @@ declare abstract class Colour<Model> {
88
92
  * Get the current value of the colour
89
93
  */
90
94
  get value(): Model;
91
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
95
+ /**
96
+ * Set the current value of the colour
97
+ */
98
+ set value(value: Model);
99
+ constructor(type: keyof Properties, value: Model);
92
100
  /**
93
101
  * Convert the colour to a hex-colour
94
102
  */
@@ -1,5 +1,5 @@
1
- import type { HSLColour } from '~/colour/hsl';
2
- import type { RGBColour } from '~/colour/rgb';
1
+ import type { HSLColour } from './hsl';
2
+ import type { RGBColour } from './rgb';
3
3
  export declare class HexColour {
4
4
  private readonly $colour;
5
5
  private readonly state;
@@ -81,6 +81,10 @@ declare class HexColour {
81
81
  */
82
82
  static toRgb(value: string): RGBColour;
83
83
  }
84
+ export type Properties = {
85
+ hsl: Array<keyof HSLColourValue>;
86
+ rgb: Array<keyof RGBColourValue>;
87
+ };
84
88
  declare abstract class Colour<Model> {
85
89
  private readonly $colour;
86
90
  protected readonly state: ColourState<Model>;
@@ -88,7 +92,11 @@ declare abstract class Colour<Model> {
88
92
  * Get the current value of the colour
89
93
  */
90
94
  get value(): Model;
91
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
95
+ /**
96
+ * Set the current value of the colour
97
+ */
98
+ set value(value: Model);
99
+ constructor(type: keyof Properties, value: Model);
92
100
  /**
93
101
  * Convert the colour to a hex-colour
94
102
  */
@@ -1,6 +1,6 @@
1
- import { Colour } from '~/colour/base';
2
- import type { HexColour } from '~/colour/hex';
3
- import type { RGBColour } from '~/colour/rgb';
1
+ import { Colour } from './base';
2
+ import type { HexColour } from './hex';
3
+ import type { RGBColour } from './rgb';
4
4
  export type HSLColourValue = {
5
5
  hue: number;
6
6
  lightness: number;
@@ -85,6 +85,10 @@ export declare class HexColour {
85
85
  * Get a hex-colour from a string
86
86
  */
87
87
  export declare function getHexColour(value: string): HexColour;
88
+ export type Properties = {
89
+ hsl: Array<keyof HSLColourValue>;
90
+ rgb: Array<keyof RGBColourValue>;
91
+ };
88
92
  declare abstract class Colour<Model> {
89
93
  private readonly $colour;
90
94
  protected readonly state: ColourState<Model>;
@@ -92,7 +96,11 @@ declare abstract class Colour<Model> {
92
96
  * Get the current value of the colour
93
97
  */
94
98
  get value(): Model;
95
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
99
+ /**
100
+ * Set the current value of the colour
101
+ */
102
+ set value(value: Model);
103
+ constructor(type: keyof Properties, value: Model);
96
104
  /**
97
105
  * Convert the colour to a hex-colour
98
106
  */
@@ -161,6 +169,24 @@ export declare class RGBColour extends Colour<RGBColourValue> {
161
169
  * Get an RGB-colour from a value-object
162
170
  */
163
171
  export declare function getRGBColour(value: RGBColourValue): RGBColour;
172
+ /**
173
+ * Convert a hex-colour to an RGB-colour
174
+ */
175
+ export declare function hexToRgb(value: string): RGBColour;
176
+ /**
177
+ * - Convert an HSL-colour to an RGB-colour
178
+ * - Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L61
179
+ */
180
+ export declare function hslToRgb(value: HSLColourValue): RGBColour;
181
+ /**
182
+ * Convert an RGB-colour to a hex-colour
183
+ */
184
+ export declare function rgbToHex(value: RGBColourValue): HexColour;
185
+ /**
186
+ * - Convert an RGB-colour to an HSL-colour
187
+ * - Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L26
188
+ */
189
+ export declare function rgbToHsl(rgb: RGBColourValue): HSLColour;
164
190
  /**
165
191
  * Is the value a colour?
166
192
  */
@@ -1,8 +1,9 @@
1
- import type { RGBColourValue } from '~/colour/rgb';
1
+ import type { RGBColourValue } from './rgb';
2
2
  /**
3
3
  * Get a foreground colour _(usually text)_ based on a background colour's luminance
4
4
  */
5
5
  export declare function getForegroundColour(value: RGBColourValue): string;
6
+ export { hexToRgb, hslToRgb, rgbToHex, rgbToHsl } from './functions';
6
7
  export { getHexColour, HexColour } from './hex';
7
8
  export { getHSLColour, HSLColour, type HSLColourValue } from './hsl';
8
9
  export { isColour, isHexColour, isHSLColour, isRGBColour } from './is';
@@ -77,6 +77,10 @@ declare class HexColour {
77
77
  */
78
78
  static toRgb(value: string): RGBColour;
79
79
  }
80
+ export type Properties = {
81
+ hsl: Array<keyof HSLColourValue>;
82
+ rgb: Array<keyof RGBColourValue>;
83
+ };
80
84
  declare abstract class Colour<Model> {
81
85
  private readonly $colour;
82
86
  protected readonly state: ColourState<Model>;
@@ -84,7 +88,11 @@ declare abstract class Colour<Model> {
84
88
  * Get the current value of the colour
85
89
  */
86
90
  get value(): Model;
87
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
91
+ /**
92
+ * Set the current value of the colour
93
+ */
94
+ set value(value: Model);
95
+ constructor(type: keyof Properties, value: Model);
88
96
  /**
89
97
  * Convert the colour to a hex-colour
90
98
  */
@@ -153,7 +161,7 @@ declare class RGBColour extends Colour<RGBColourValue> {
153
161
  * Is the value a colour?
154
162
  */
155
163
  export declare function isColour(value: unknown): value is HexColour | HSLColour | RGBColour;
156
- export declare function isColourValue<Expected>(value: unknown, properties: Array<keyof Expected>): value is Expected;
164
+ export declare function isColourValue(value: unknown, properties: string[]): boolean;
157
165
  /**
158
166
  * Is the value a hex-colour?
159
167
  */
@@ -1,11 +1,11 @@
1
- import type { HexColour } from '~/colour/hex';
2
- import type { HSLColour } from '~/colour/hsl';
3
- import type { RGBColour } from '~/colour/rgb';
1
+ import type { HexColour } from './hex';
2
+ import type { HSLColour } from './hsl';
3
+ import type { RGBColour } from './rgb';
4
4
  /**
5
5
  * Is the value a colour?
6
6
  */
7
7
  export declare function isColour(value: unknown): value is HexColour | HSLColour | RGBColour;
8
- export declare function isColourValue<Expected>(value: unknown, properties: Array<keyof Expected>): value is Expected;
8
+ export declare function isColourValue(value: unknown, properties: string[]): boolean;
9
9
  /**
10
10
  * Is the value a hex-colour?
11
11
  */
@@ -77,6 +77,10 @@ declare class HexColour {
77
77
  */
78
78
  static toRgb(value: string): RGBColour;
79
79
  }
80
+ export type Properties = {
81
+ hsl: Array<keyof HSLColourValue>;
82
+ rgb: Array<keyof RGBColourValue>;
83
+ };
80
84
  declare abstract class Colour<Model> {
81
85
  private readonly $colour;
82
86
  protected readonly state: ColourState<Model>;
@@ -84,7 +88,11 @@ declare abstract class Colour<Model> {
84
88
  * Get the current value of the colour
85
89
  */
86
90
  get value(): Model;
87
- constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
91
+ /**
92
+ * Set the current value of the colour
93
+ */
94
+ set value(value: Model);
95
+ constructor(type: keyof Properties, value: Model);
88
96
  /**
89
97
  * Convert the colour to a hex-colour
90
98
  */
@@ -1,6 +1,6 @@
1
- import { Colour } from '~/colour/base';
2
- import type { HexColour } from '~/colour/hex';
3
- import type { HSLColour } from '~/colour/hsl';
1
+ import { Colour } from './base';
2
+ import type { HexColour } from './hex';
3
+ import type { HSLColour } from './hsl';
4
4
  export type RGBColourValue = {
5
5
  blue: number;
6
6
  green: number;
@@ -1,4 +1,4 @@
1
- import type { GenericCallback } from '~/models';
1
+ import type { GenericCallback } from './models';
2
2
  type Debounced<Callback extends GenericCallback> = Callback & {
3
3
  /**
4
4
  * Cancel the debounce
package/types/index.d.cts CHANGED
@@ -401,6 +401,7 @@ export type StringDigit =
401
401
  | '7'
402
402
  | '8'
403
403
  | '9';
404
+ type NoInfer$1<T> = T extends infer U ? U : never;
404
405
  /**
405
406
  Returns a boolean for whether the given type is `any`.
406
407
 
@@ -429,7 +430,7 @@ const anyA = get(anyObject, 'a');
429
430
  @category Type Guard
430
431
  @category Utilities
431
432
  */
432
- export type IsAny<T> = 0 extends 1 & T ? true : false;
433
+ export type IsAny<T> = 0 extends 1 & NoInfer$1<T> ? true : false;
433
434
  export type Numeric = number | bigint;
434
435
  export type Zero = 0 | 0n;
435
436
  /**
@@ -1438,8 +1439,14 @@ export type PropertyOf<
1438
1439
  ? undefined
1439
1440
  : Key extends keyof BaseType
1440
1441
  ? StrictPropertyOf<BaseType, Key, Options>
1441
- : BaseType extends readonly [] | readonly [unknown, ...unknown[]]
1442
- ? unknown // It's a tuple, but `Key` did not extend `keyof BaseType`. So the index is out of bounds.
1442
+ : BaseType extends readonly unknown[]
1443
+ ? Key extends `${number}`
1444
+ ? number extends BaseType['length']
1445
+ ? Strictify<BaseType[number], Options>
1446
+ : Key extends keyof BaseType
1447
+ ? Strictify<BaseType[Key & keyof BaseType], Options>
1448
+ : unknown
1449
+ : unknown
1443
1450
  : BaseType extends {
1444
1451
  [n: number]: infer Item;
1445
1452
  length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
@@ -2506,6 +2513,10 @@ export declare class HexColour {
2506
2513
  * Get a hex-colour from a string
2507
2514
  */
2508
2515
  export declare function getHexColour(value: string): HexColour;
2516
+ export type Properties = {
2517
+ hsl: Array<keyof HSLColourValue>;
2518
+ rgb: Array<keyof RGBColourValue>;
2519
+ };
2509
2520
  declare abstract class Colour<Model> {
2510
2521
  private readonly $colour;
2511
2522
  protected readonly state: ColourState<Model>;
@@ -2513,12 +2524,11 @@ declare abstract class Colour<Model> {
2513
2524
  * Get the current value of the colour
2514
2525
  */
2515
2526
  get value(): Model;
2516
- constructor(
2517
- type: string,
2518
- value: Model,
2519
- defaults: Model,
2520
- properties: Array<keyof Model>,
2521
- );
2527
+ /**
2528
+ * Set the current value of the colour
2529
+ */
2530
+ set value(value: Model);
2531
+ constructor(type: keyof Properties, value: Model);
2522
2532
  /**
2523
2533
  * Convert the colour to a hex-colour
2524
2534
  */
@@ -2587,6 +2597,24 @@ export declare class RGBColour extends Colour<RGBColourValue> {
2587
2597
  * Get an RGB-colour from a value-object
2588
2598
  */
2589
2599
  export declare function getRGBColour(value: RGBColourValue): RGBColour;
2600
+ /**
2601
+ * Convert a hex-colour to an RGB-colour
2602
+ */
2603
+ export declare function hexToRgb(value: string): RGBColour;
2604
+ /**
2605
+ * - Convert an HSL-colour to an RGB-colour
2606
+ * - Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L61
2607
+ */
2608
+ export declare function hslToRgb(value: HSLColourValue): RGBColour;
2609
+ /**
2610
+ * Convert an RGB-colour to a hex-colour
2611
+ */
2612
+ export declare function rgbToHex(value: RGBColourValue): HexColour;
2613
+ /**
2614
+ * - Convert an RGB-colour to an HSL-colour
2615
+ * - Thanks, https://github.com/color-js/color.js/blob/main/src/spaces/hsl.js#L26
2616
+ */
2617
+ export declare function rgbToHsl(rgb: RGBColourValue): HSLColour;
2590
2618
  /**
2591
2619
  * Is the value a colour?
2592
2620
  */