@solid-primitives/utils 7.0.0-next.0 → 7.0.0-next.2
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/colors/helpers.d.ts +46 -41
- package/dist/colors/helpers.js +776 -851
- package/dist/colors/index.d.ts +6 -4
- package/dist/colors/index.js +5 -4
- package/dist/colors/intl.d.ts +56 -52
- package/dist/colors/intl.js +55 -66
- package/dist/colors/manipulation.d.ts +136 -131
- package/dist/colors/manipulation.js +215 -242
- package/dist/colors/types.d.ts +73 -68
- package/dist/colors/types.js +1 -14
- package/dist/immutable/array.d.ts +113 -108
- package/dist/immutable/array.js +122 -128
- package/dist/immutable/copy.d.ts +25 -21
- package/dist/immutable/copy.js +31 -29
- package/dist/immutable/index.d.ts +8 -6
- package/dist/immutable/index.js +7 -6
- package/dist/immutable/number.d.ts +11 -7
- package/dist/immutable/number.js +21 -27
- package/dist/immutable/object.d.ts +55 -58
- package/dist/immutable/object.js +46 -48
- package/dist/immutable/types.d.ts +9 -7
- package/dist/immutable/types.js +1 -1
- package/dist/immutable/update.d.ts +33 -28
- package/dist/immutable/update.js +27 -27
- package/dist/index.d.ts +226 -222
- package/dist/index.js +285 -311
- package/dist/types.d.ts +63 -75
- package/dist/types.js +1 -1
- package/package.json +11 -7
package/dist/colors/types.d.ts
CHANGED
|
@@ -1,77 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
/* @ts-self-types="./types.d.ts" */
|
|
2
|
+
import { ColorIntlTranslations } from "./intl.js";
|
|
3
|
+
|
|
4
|
+
//#region src/colors/types.d.ts
|
|
2
5
|
/** Supported color string formats. Formats without an `a` suffix treat alpha as fully opaque. */
|
|
3
|
-
|
|
6
|
+
type ColorFormat = "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "hsb" | "hsba";
|
|
4
7
|
/** The three supported color spaces. */
|
|
5
|
-
|
|
8
|
+
type ColorSpace = "rgb" | "hsl" | "hsb";
|
|
6
9
|
/** Individual channel names across all supported color spaces. */
|
|
7
|
-
|
|
10
|
+
type ColorChannel = "hue" | "saturation" | "brightness" | "lightness" | "red" | "green" | "blue" | "alpha";
|
|
8
11
|
/** Maps x/y/z axes to {@link ColorChannel} names for 2D color gradient pickers. */
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
type ColorAxes = {
|
|
13
|
+
xChannel: ColorChannel;
|
|
14
|
+
yChannel: ColorChannel;
|
|
15
|
+
zChannel: ColorChannel;
|
|
13
16
|
};
|
|
14
17
|
/** Numeric constraints for a single color channel, used to drive sliders and steppers. */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
interface ColorChannelRange {
|
|
19
|
+
/** Minimum value of the channel. */
|
|
20
|
+
minValue: number;
|
|
21
|
+
/** Maximum value of the channel. */
|
|
22
|
+
maxValue: number;
|
|
23
|
+
/** Increment/decrement step (e.g. arrow key). */
|
|
24
|
+
step: number;
|
|
25
|
+
/** Larger increment/decrement step (e.g. page-up/down key). */
|
|
26
|
+
pageSize: number;
|
|
24
27
|
}
|
|
25
28
|
/** Represents an immutable color value. All mutation methods return a new `Color` instance. */
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
29
|
+
interface Color {
|
|
30
|
+
/** Returns a new `Color` converted to `format`. */
|
|
31
|
+
toFormat(format: ColorFormat): Color;
|
|
32
|
+
/**
|
|
33
|
+
* Serializes the color to a CSS string.
|
|
34
|
+
* Defaults to `"css"` which produces the most browser-compatible form for each space
|
|
35
|
+
* (`rgb(...)`, `hsla(...)`, etc.).
|
|
36
|
+
*/
|
|
37
|
+
toString(format?: ColorFormat | "css"): string;
|
|
38
|
+
/** Returns a deep clone of this color. */
|
|
39
|
+
clone(): Color;
|
|
40
|
+
/** Returns the RGB integer representation (`0xRRGGBB`), ignoring alpha. */
|
|
41
|
+
toHexInt(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the numeric value for `channel`.
|
|
44
|
+
* @throws if `channel` is not part of this color's space.
|
|
45
|
+
*/
|
|
46
|
+
getChannelValue(channel: ColorChannel): number;
|
|
47
|
+
/**
|
|
48
|
+
* Returns a new `Color` with `channel` set to `value`.
|
|
49
|
+
* @throws if `channel` is not part of this color's space.
|
|
50
|
+
*/
|
|
51
|
+
withChannelValue(channel: ColorChannel, value: number): Color;
|
|
52
|
+
/** Returns the {@link ColorChannelRange} for `channel` in this color space. */
|
|
53
|
+
getChannelRange(channel: ColorChannel): ColorChannelRange;
|
|
54
|
+
/** Returns a localized label for `channel` (e.g. `"Red"`, `"Saturation"`). */
|
|
55
|
+
getChannelName(channel: ColorChannel, translations: ColorIntlTranslations): string;
|
|
56
|
+
/** Returns `Intl.NumberFormatOptions` appropriate for displaying this channel's value. */
|
|
57
|
+
getChannelFormatOptions(channel: ColorChannel): Intl.NumberFormatOptions;
|
|
58
|
+
/** Returns the channel value formatted as a locale-aware string (e.g. `"50%"`, `"220°"`). */
|
|
59
|
+
formatChannelValue(channel: ColorChannel): string;
|
|
60
|
+
/** Returns the color space this color lives in. */
|
|
61
|
+
getColorSpace(): ColorSpace;
|
|
62
|
+
/**
|
|
63
|
+
* Resolves the x/y/z channel assignment for a 2D color area picker.
|
|
64
|
+
* Pass `xChannel` and/or `yChannel` to fix specific axes; the remaining
|
|
65
|
+
* channel is inferred as the z axis.
|
|
66
|
+
*/
|
|
67
|
+
getColorSpaceAxes(xyChannels: {
|
|
68
|
+
xChannel?: ColorChannel;
|
|
69
|
+
yChannel?: ColorChannel;
|
|
70
|
+
}): ColorAxes;
|
|
71
|
+
/** Returns the three channel names for this color's space, in display order. */
|
|
72
|
+
getColorChannels(): [ColorChannel, ColorChannel, ColorChannel];
|
|
73
|
+
/**
|
|
74
|
+
* Returns a human-readable color name derived from OKLCH analysis
|
|
75
|
+
* (e.g. `"dark vibrant blue"`, `"pale cyan, 20% transparent"`).
|
|
76
|
+
*/
|
|
77
|
+
getColorName(translations: ColorIntlTranslations): string;
|
|
78
|
+
/** Returns just the hue family name (e.g. `"blue"`, `"orange yellow"`). */
|
|
79
|
+
getHueName(translations: ColorIntlTranslations): string;
|
|
77
80
|
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { Color, ColorAxes, ColorChannel, ColorChannelRange, ColorFormat, ColorSpace };
|
package/dist/colors/types.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Portions of this file are based on code from Kobalte.
|
|
3
|
-
* MIT License, Copyright Fabien Marie-Louise.
|
|
4
|
-
*
|
|
5
|
-
* Credits to the Kobalte team:
|
|
6
|
-
* https://github.com/kobaltedev/kobalte/tree/main/packages/core/src/colors
|
|
7
|
-
*
|
|
8
|
-
* Which in turn is based on code from React Spectrum.
|
|
9
|
-
* Apache License Version 2.0, Copyright 2020 Adobe.
|
|
10
|
-
*
|
|
11
|
-
* Credits to the React Spectrum team:
|
|
12
|
-
* https://github.com/adobe/react-spectrum/blob/68e305768cb829bab7b9836dded593bd731259f3/packages/%40react-types/color/src/index.d.ts
|
|
13
|
-
*/
|
|
14
|
-
export {};
|
|
1
|
+
/* @ts-self-types="./types.d.ts" */
|
|
@@ -1,112 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
/* @ts-self-types="./array.d.ts" */
|
|
2
|
+
import { AnyClass, ItemsOf, Many } from "../types.js";
|
|
3
|
+
import { FlattenArray, MappingFn, Predicate } from "./types.js";
|
|
4
|
+
|
|
5
|
+
//#region src/immutable/array.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* non-mutating `Array.prototype.push()`
|
|
8
|
+
* @returns changed array copy
|
|
9
|
+
*/
|
|
10
|
+
declare const push: <T>(list: readonly T[], ...items: T[]) => T[];
|
|
11
|
+
/**
|
|
12
|
+
* non-mutating function that drops n items from the array start.
|
|
13
|
+
* @returns changed array copy
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const newList = drop([1,2,3])
|
|
18
|
+
* newList // => [2,3]
|
|
19
|
+
*
|
|
20
|
+
* const newList = drop([1,2,3], 2)
|
|
21
|
+
* newList // => [3]
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare const drop: <T>(list: T[], n?: number) => T[];
|
|
25
|
+
/**
|
|
26
|
+
* non-mutating function that drops n items from the array end.
|
|
27
|
+
* @returns changed array copy
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const newList = dropRight([1,2,3])
|
|
32
|
+
* newList // => [1,2]
|
|
33
|
+
*
|
|
34
|
+
* const newList = dropRight([1,2,3], 2)
|
|
35
|
+
* newList // => [1]
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const dropRight: <T>(list: T[], n?: number) => T[];
|
|
39
|
+
/**
|
|
40
|
+
* standalone `Array.prototype.filter()` that filters out passed item
|
|
41
|
+
* @returns changed array copy
|
|
42
|
+
*/
|
|
43
|
+
declare const filterOut: <T>(list: readonly T[], item: T) => T[] & {
|
|
44
|
+
removed: number;
|
|
42
45
|
};
|
|
43
46
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
* standalone `Array.prototype.filter()`
|
|
48
|
+
* @returns changed array copy
|
|
49
|
+
*/
|
|
50
|
+
declare function filter<T>(list: readonly T[], predicate: Predicate<T>): T[] & {
|
|
51
|
+
removed: number;
|
|
49
52
|
};
|
|
50
53
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
54
|
+
* non-mutating `Array.prototype.sort()` as a standalone function
|
|
55
|
+
* @returns changed array copy
|
|
56
|
+
*/
|
|
57
|
+
declare const sort: <T>(list: T[], compareFn?: (a: T, b: T) => number) => T[];
|
|
58
|
+
/**
|
|
59
|
+
* standalone `Array.prototype.map()` function
|
|
60
|
+
*/
|
|
61
|
+
declare const map: <T, V>(list: readonly T[], mapFn: MappingFn<T, V>) => V[];
|
|
62
|
+
/**
|
|
63
|
+
* standalone `Array.prototype.slice()` function
|
|
64
|
+
*/
|
|
65
|
+
declare const slice: <T>(list: readonly T[], start?: number, end?: number) => T[];
|
|
66
|
+
/**
|
|
67
|
+
* non-mutating `Array.prototype.splice()` as a standalone function
|
|
68
|
+
* @returns changed array copy
|
|
69
|
+
*/
|
|
70
|
+
declare const splice: <T>(list: readonly T[], start: number, deleteCount?: number, ...items: T[]) => T[];
|
|
71
|
+
/**
|
|
72
|
+
* non-mutating `Array.prototype.fill()` as a standalone function
|
|
73
|
+
* @returns changed array copy
|
|
74
|
+
*/
|
|
75
|
+
declare const fill: <T>(list: readonly T[], value: T, start?: number, end?: number) => T[];
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new array concatenating array with any additional arrays and/or values.
|
|
78
|
+
* @param ...a values or arrays
|
|
79
|
+
* @returns new concatenated array
|
|
80
|
+
*/
|
|
81
|
+
declare function concat<A extends any[], V extends ItemsOf<A>>(...a: A): Array<V extends any[] ? ItemsOf<V> : V>;
|
|
82
|
+
/**
|
|
83
|
+
* Remove item from array
|
|
84
|
+
* @returns changed array copy
|
|
85
|
+
*/
|
|
86
|
+
declare const remove: <T>(list: readonly T[], item: T, ...insertItems: T[]) => T[];
|
|
87
|
+
/**
|
|
88
|
+
* Remove multiple items from an array
|
|
89
|
+
* @returns changed array copy
|
|
90
|
+
*/
|
|
91
|
+
declare const removeItems: <T>(list: readonly T[], ...items: T[]) => T[];
|
|
92
|
+
/**
|
|
93
|
+
* Flattens a nested array into a one-level array
|
|
94
|
+
* @returns changed array copy
|
|
95
|
+
*/
|
|
96
|
+
declare const flatten: <T extends any[]>(arr: T) => FlattenArray<T>[];
|
|
97
|
+
/**
|
|
98
|
+
* Sort an array by object key, or multiple keys
|
|
99
|
+
* @returns changed array copy
|
|
100
|
+
*/
|
|
101
|
+
declare const sortBy: <T>(arr: T[], ...paths: T extends object ? (Many<keyof T> | Many<(item: T) => any>)[] : Many<(item: T) => any>[]) => T[];
|
|
102
|
+
/**
|
|
103
|
+
* Returns a subset of items that are instances of provided Classes
|
|
104
|
+
* @param list list of original items
|
|
105
|
+
* @param ...classes list or classes
|
|
106
|
+
* @returns changed array copy
|
|
107
|
+
*/
|
|
108
|
+
declare const filterInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Extract<T, InstanceType<ItemsOf<I>>>[];
|
|
109
|
+
/**
|
|
110
|
+
* Returns a subset of items that aren't instances of provided Classes
|
|
111
|
+
* @param list list of original items
|
|
112
|
+
* @param ...classes list or classes
|
|
113
|
+
* @returns changed array copy
|
|
114
|
+
*/
|
|
115
|
+
declare const filterOutInstance: <T, I extends AnyClass[]>(list: readonly T[], ...classes: I) => Exclude<T, InstanceType<ItemsOf<I>>>[];
|
|
116
|
+
//#endregion
|
|
117
|
+
export { concat, drop, dropRight, fill, filter, filterInstance, filterOut, filterOutInstance, flatten, map, push, remove, removeItems, slice, sort, sortBy, splice };
|