@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.
- package/dist/array/sort.cjs +5 -10
- package/dist/array/sort.js +5 -10
- package/dist/colour/base.cjs +27 -2
- package/dist/colour/base.js +27 -2
- package/dist/colour/functions.cjs +1 -1
- package/dist/colour/functions.js +1 -1
- package/dist/colour/hsl.cjs +2 -12
- package/dist/colour/hsl.js +2 -12
- package/dist/colour/index.cjs +5 -0
- package/dist/colour/index.js +6 -1
- package/dist/colour/rgb.cjs +2 -8
- package/dist/colour/rgb.js +2 -8
- package/dist/index.cjs +5 -0
- package/dist/index.js +5 -0
- package/dist/internal/array/find.cjs +6 -7
- package/dist/internal/array/find.js +6 -7
- package/dist/value/equal.cjs +4 -1
- package/dist/value/equal.js +4 -1
- package/package.json +15 -8
- package/src/array/chunk.ts +1 -1
- package/src/array/count.ts +2 -2
- package/src/array/exists.ts +2 -2
- package/src/array/filter.ts +2 -2
- package/src/array/find.ts +2 -2
- package/src/array/group-by.ts +2 -2
- package/src/array/index-of.ts +2 -2
- package/src/array/index.ts +3 -2
- package/src/array/insert.ts +2 -2
- package/src/array/models.ts +1 -1
- package/src/array/shuffle.ts +1 -1
- package/src/array/sort.ts +13 -20
- package/src/array/splice.ts +1 -1
- package/src/array/to-map.ts +2 -2
- package/src/array/to-record.ts +60 -60
- package/src/array/unique.ts +5 -5
- package/src/colour/base.ts +48 -12
- package/src/colour/functions.ts +4 -4
- package/src/colour/hex.ts +3 -3
- package/src/colour/hsl.ts +6 -18
- package/src/colour/index.ts +2 -1
- package/src/colour/is.ts +4 -7
- package/src/colour/rgb.ts +6 -14
- package/src/emitter.ts +1 -1
- package/src/function.ts +2 -2
- package/src/index.ts +16 -16
- package/src/internal/array/callbacks.ts +2 -2
- package/src/internal/array/find.ts +10 -11
- package/src/internal/value/handle.ts +1 -1
- package/src/is.ts +2 -2
- package/src/logger.ts +1 -1
- package/src/query.ts +4 -4
- package/src/random.ts +1 -1
- package/src/sized.ts +1 -1
- package/src/string/case.ts +1 -1
- package/src/string/index.ts +2 -1
- package/src/string/template.ts +3 -3
- package/src/value/clone.ts +3 -3
- package/src/value/compare.ts +3 -3
- package/src/value/diff.ts +4 -4
- package/src/value/equal.ts +6 -3
- package/src/value/get.ts +2 -2
- package/src/value/index.ts +2 -1
- package/src/value/merge.ts +2 -2
- package/src/value/set.ts +2 -2
- package/src/value/smush.ts +3 -3
- package/src/value/unsmush.ts +3 -3
- package/types/array/count.d.ts +1 -1
- package/types/array/exists.d.ts +1 -1
- package/types/array/filter.d.ts +1 -1
- package/types/array/find.d.ts +1 -1
- package/types/array/group-by.d.ts +1 -1
- package/types/array/index-of.d.ts +1 -1
- package/types/array/index.d.ts +1 -1
- package/types/array/insert.d.ts +1 -1
- package/types/array/models.d.ts +1 -1
- package/types/array/sort.d.ts +2 -2
- package/types/array/to-map.d.ts +1 -1
- package/types/array/to-record.d.ts +1 -1
- package/types/array/unique.d.ts +1 -1
- package/types/colour/base.d.cts +9 -1
- package/types/colour/base.d.ts +12 -2
- package/types/colour/functions.d.cts +9 -1
- package/types/colour/functions.d.ts +3 -3
- package/types/colour/hex.d.cts +9 -1
- package/types/colour/hex.d.ts +2 -2
- package/types/colour/hsl.d.cts +9 -1
- package/types/colour/hsl.d.ts +3 -3
- package/types/colour/index.d.cts +27 -1
- package/types/colour/index.d.ts +2 -1
- package/types/colour/is.d.cts +10 -2
- package/types/colour/is.d.ts +4 -4
- package/types/colour/rgb.d.cts +9 -1
- package/types/colour/rgb.d.ts +3 -3
- package/types/function.d.ts +1 -1
- package/types/index.d.cts +37 -9
- package/types/index.d.ts +16 -16
- package/types/internal/array/callbacks.d.ts +1 -1
- package/types/internal/array/find.d.ts +1 -1
- package/types/internal/value/handle.d.ts +1 -1
- package/types/is.d.ts +1 -1
- package/types/models.d.cts +10 -3
- package/types/query.d.ts +1 -1
- package/types/string/template.d.ts +1 -1
- package/types/value/get.d.cts +10 -3
- package/types/value/get.d.ts +1 -1
- package/types/value/index.d.cts +10 -3
- package/types/value/index.d.ts +1 -1
- package/types/value/merge.d.ts +1 -1
- package/types/value/set.d.cts +2 -1
- package/types/value/set.d.ts +1 -1
- package/types/value/smush.d.cts +10 -3
- package/types/value/smush.d.ts +1 -1
- package/types/value/unsmush.d.ts +1 -1
package/src/string/template.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {PlainObject} from '
|
|
2
|
-
import {getString} from '
|
|
3
|
-
import {getValue} from '
|
|
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
|
/**
|
package/src/value/clone.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {isArrayOrPlainObject} from '
|
|
2
|
-
import type {ArrayOrPlainObject,
|
|
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);
|
package/src/value/compare.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {max} from '
|
|
2
|
-
import {getNumber} from '
|
|
3
|
-
import {
|
|
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 '
|
|
2
|
-
import type {ArrayOrPlainObject, Key, PlainObject} from '
|
|
3
|
-
import {join} from '
|
|
4
|
-
import {equal} from '
|
|
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
|
|
package/src/value/equal.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {isPlainObject} from '
|
|
2
|
-
import type {ArrayOrPlainObject, PlainObject} from '
|
|
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(
|
|
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 '
|
|
3
|
-
import type {ArrayOrPlainObject, Get, Paths} from '
|
|
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
|
package/src/value/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {PlainObject} from '
|
|
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
|
+
|
package/src/value/merge.ts
CHANGED
package/src/value/set.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {handleValue} from '
|
|
2
|
-
import type {ArrayOrPlainObject, Paths, PlainObject} from '
|
|
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
|
package/src/value/smush.ts
CHANGED
|
@@ -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 '
|
|
4
|
-
import type {ArrayOrPlainObject, PlainObject} from '
|
|
5
|
-
import {join} from '
|
|
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>>;
|
package/src/value/unsmush.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {KeysOfUnion, Simplify} from 'type-fest';
|
|
2
|
-
import {isArrayOrPlainObject} from '
|
|
3
|
-
import type {PlainObject} from '
|
|
4
|
-
import {setValue} from '
|
|
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<
|
package/types/array/count.d.ts
CHANGED
package/types/array/exists.d.ts
CHANGED
package/types/array/filter.d.ts
CHANGED
package/types/array/find.d.ts
CHANGED
package/types/array/index.d.ts
CHANGED
package/types/array/insert.d.ts
CHANGED
package/types/array/models.d.ts
CHANGED
package/types/array/sort.d.ts
CHANGED
package/types/array/to-map.d.ts
CHANGED
package/types/array/unique.d.ts
CHANGED
package/types/colour/base.d.cts
CHANGED
|
@@ -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
|
-
|
|
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
|
*/
|
package/types/colour/base.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type { HexColour } from '
|
|
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
|
-
|
|
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
|
-
|
|
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 '
|
|
2
|
-
import { HSLColour, type HSLColourValue } from '
|
|
3
|
-
import { RGBColour, type RGBColourValue } from '
|
|
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
|
/**
|
package/types/colour/hex.d.cts
CHANGED
|
@@ -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
|
-
|
|
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
|
*/
|
package/types/colour/hex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HSLColour } from '
|
|
2
|
-
import type { RGBColour } from '
|
|
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;
|
package/types/colour/hsl.d.cts
CHANGED
|
@@ -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
|
-
|
|
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
|
*/
|
package/types/colour/hsl.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Colour } from '
|
|
2
|
-
import type { HexColour } from '
|
|
3
|
-
import type { RGBColour } from '
|
|
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;
|
package/types/colour/index.d.cts
CHANGED
|
@@ -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
|
-
|
|
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
|
*/
|
package/types/colour/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { RGBColourValue } from '
|
|
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';
|
package/types/colour/is.d.cts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
164
|
+
export declare function isColourValue(value: unknown, properties: string[]): boolean;
|
|
157
165
|
/**
|
|
158
166
|
* Is the value a hex-colour?
|
|
159
167
|
*/
|
package/types/colour/is.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { HexColour } from '
|
|
2
|
-
import type { HSLColour } from '
|
|
3
|
-
import type { RGBColour } from '
|
|
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
|
|
8
|
+
export declare function isColourValue(value: unknown, properties: string[]): boolean;
|
|
9
9
|
/**
|
|
10
10
|
* Is the value a hex-colour?
|
|
11
11
|
*/
|
package/types/colour/rgb.d.cts
CHANGED
|
@@ -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
|
-
|
|
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
|
*/
|
package/types/colour/rgb.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Colour } from '
|
|
2
|
-
import type { HexColour } from '
|
|
3
|
-
import type { HSLColour } from '
|
|
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;
|
package/types/function.d.ts
CHANGED
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
|
|
1442
|
-
?
|
|
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
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
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
|
*/
|