tiny-essentials 1.23.2 → 1.24.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/changelog/1/23/2.md +2 -0
- package/changelog/1/24/0.md +10 -0
- package/dist/v1/TinyColorValidator.min.js +1 -0
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/build/TinyColorValidator.cjs +7 -0
- package/dist/v1/build/TinyColorValidator.d.mts +3 -0
- package/dist/v1/build/TinyColorValidator.mjs +2 -0
- package/dist/v1/index.cjs +2 -0
- package/dist/v1/index.d.mts +2 -1
- package/dist/v1/index.mjs +2 -1
- package/dist/v1/libs/TinyColorValidator.cjs +907 -0
- package/dist/v1/libs/TinyColorValidator.d.mts +452 -0
- package/dist/v1/libs/TinyColorValidator.mjs +853 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
- package/docs/v1/README.md +1 -0
- package/docs/v1/libs/TinyColorValidator.md +532 -0
- package/package.json +5 -1
package/docs/v1/README.md
CHANGED
|
@@ -59,6 +59,7 @@ This folder contains the core scripts we have worked on so far. Each file is a m
|
|
|
59
59
|
- 🎲 **[TinySimpleDice](./libs/TinySimpleDice.md)** — A lightweight and flexible dice rolling utility with configurable maximum values, zero allowance, and array/Set index rolling support.
|
|
60
60
|
- 👀 **[TinyElementObserver](./libs/TinyElementObserver.md)** — A DOM mutation tracking utility built on MutationObserver, with customizable detectors for handling changes, event dispatching, and lifecycle management.
|
|
61
61
|
- ⏳ **[TinyLoadingScreen](./libs/TinyLoadingScreen.md)** — A lightweight, fully-configurable loading overlay with fade-in/out animations, custom messages (string or HTMLElement), HTML rendering option, and status-change callbacks.
|
|
62
|
+
- 🎨 **[TinyColorValidator](./libs/TinyColorValidator.md)** — A comprehensive CSS color validation and parsing utility supporting HEX, HEXA, RGB, RGBA, HSL, HSLA, HWB, Lab, LCH, standard HTML color names, and special keywords, with automatic type detection and parsing.
|
|
62
63
|
|
|
63
64
|
### 3. **`fileManager/`**
|
|
64
65
|
* 📁 **[Main](./fileManager/main.md)** — A Node.js file/directory utility module with support for JSON, backups, renaming, size analysis, and more.
|
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
# 🎨 TinyColorValidator Documentation
|
|
2
|
+
|
|
3
|
+
## 📐 Angle Units
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
/**
|
|
7
|
+
* Represents the allowed angle unit types for CSS color functions.
|
|
8
|
+
*
|
|
9
|
+
* - `deg` → Degrees (0–360).
|
|
10
|
+
* - `grad` → Gradians (0–400).
|
|
11
|
+
* - `rad` → Radians (0–2π).
|
|
12
|
+
* - `turn` → Turns (0–1).
|
|
13
|
+
*/
|
|
14
|
+
type AngleUnit = 'deg' | 'grad' | 'rad' | 'turn';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🌈 TinyColorValidator Class
|
|
20
|
+
|
|
21
|
+
The `TinyColorValidator` class provides utilities for validating and parsing **CSS color values** in multiple formats.
|
|
22
|
+
It supports **hex, RGB/RGBA, HSL/HSLA, HWB, LAB, LCH, HTML named colors, and special keywords**.
|
|
23
|
+
|
|
24
|
+
### ✨ Features
|
|
25
|
+
|
|
26
|
+
* Validate (`isHex`, `isRgb`, `isHsl`, etc.) color formats.
|
|
27
|
+
* Parse (`parseRgb`, `parseHsl`, etc.) into numeric components.
|
|
28
|
+
* Manage and extend HTML color names and special keywords dynamically.
|
|
29
|
+
|
|
30
|
+
### 🧩 Example
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const validator = new TinyColorValidator("rgb(255, 0, 0)");
|
|
34
|
+
|
|
35
|
+
console.log(validator.isRgb()); // true ✅
|
|
36
|
+
console.log(validator.parseRgb()); // [255, 0, 0]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🎨 Supported Formats
|
|
42
|
+
|
|
43
|
+
* **Hexadecimal** → `#RGB`, `#RRGGBB`, `#RRGGBBAA`
|
|
44
|
+
* **RGB / RGBA** → `rgb(r, g, b)`, `rgba(r, g, b, a)`
|
|
45
|
+
* **HSL / HSLA** → `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
|
|
46
|
+
* **HWB** → `hwb(hue whiteness% blackness%)`
|
|
47
|
+
* **LAB** → `lab(L a b)`
|
|
48
|
+
* **LCH** → `lch(L C H)`
|
|
49
|
+
* **HTML Named Colors** → e.g. `red`, `blue`, `rebeccapurple`
|
|
50
|
+
* **Special Keywords** → `transparent`, `currentColor`
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 🖌️ HTML Color Names API
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
TinyColorValidator.getNames(): string[]
|
|
58
|
+
TinyColorValidator.addName(name: string): boolean
|
|
59
|
+
TinyColorValidator.removeName(name: string): boolean
|
|
60
|
+
TinyColorValidator.hasName(name: string): boolean
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
* **`getNames()`** → Returns all HTML color names as an array.
|
|
64
|
+
* **`addName(name)`** → Adds a new HTML color name (case-insensitive).
|
|
65
|
+
* **`removeName(name)`** → Removes an existing HTML color name.
|
|
66
|
+
* **`hasName(name)`** → Checks if a given name exists.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 🌟 Special Color Names API
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
TinyColorValidator.getSpecialNames(): string[]
|
|
74
|
+
TinyColorValidator.addSpecialName(name: string): boolean
|
|
75
|
+
TinyColorValidator.removeSpecialName(name: string): boolean
|
|
76
|
+
TinyColorValidator.hasSpecialName(name: string): boolean
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
* **`getSpecialNames()`** → Returns all special keywords.
|
|
80
|
+
* **`addSpecialName(name)`** → Adds a new special keyword.
|
|
81
|
+
* **`removeSpecialName(name)`** → Removes an existing keyword.
|
|
82
|
+
* **`hasSpecialName(name)`** → Checks if the keyword exists.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🧱 Instance Properties
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
class TinyColorValidator {
|
|
90
|
+
#code: string;
|
|
91
|
+
|
|
92
|
+
constructor(code: TinyColorValidatorT);
|
|
93
|
+
get code(): string;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
* **`#code`** → Internal storage for the provided color string.
|
|
98
|
+
* **`get code()`** → Retrieves the original input string.
|
|
99
|
+
* **`constructor(code)`** → Creates a new validator instance with the given color string.
|
|
100
|
+
|
|
101
|
+
### 🏷️ Color Type Storage
|
|
102
|
+
|
|
103
|
+
* **Private property:** `#type`
|
|
104
|
+
* **Type:** `ColorTypes | null`
|
|
105
|
+
* **Description:** Internal storage for the detected type of the CSS color.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
/**
|
|
109
|
+
* Internal storage for the code type.
|
|
110
|
+
* @type {ColorTypes|null}
|
|
111
|
+
*/
|
|
112
|
+
#type;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
* **Getter:** `type`
|
|
116
|
+
* **Returns:** `ColorTypes | null`
|
|
117
|
+
* **Description:** Returns the currently stored color type.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
/**
|
|
121
|
+
* Gets the current code type.
|
|
122
|
+
* @returns {ColorTypes|null} The stored code type.
|
|
123
|
+
*/
|
|
124
|
+
get type() {
|
|
125
|
+
return this.#type;
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 🎨 HEX & HEXA Validation
|
|
132
|
+
|
|
133
|
+
### 🔍 `static isHex(input: string): boolean`
|
|
134
|
+
|
|
135
|
+
Validates whether a string is a valid HEX color (`#RGB` or `#RRGGBB`).
|
|
136
|
+
|
|
137
|
+
* ✅ Returns `true` if valid.
|
|
138
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
### 🔍 `isHex(): boolean`
|
|
143
|
+
|
|
144
|
+
Instance method that validates the stored color code as a HEX color.
|
|
145
|
+
|
|
146
|
+
* ✅ Returns `true` if valid.
|
|
147
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### 🔍 `static isHexa(input: string): boolean`
|
|
152
|
+
|
|
153
|
+
Validates whether a string is a valid HEXA color (`#RRGGBBAA`).
|
|
154
|
+
|
|
155
|
+
* ✅ Returns `true` if valid.
|
|
156
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### 🔍 `isHexa(): boolean`
|
|
161
|
+
|
|
162
|
+
Instance method that validates the stored color code as a HEXA color.
|
|
163
|
+
|
|
164
|
+
* ✅ Returns `true` if valid.
|
|
165
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 🎨 RGB & RGBA Validation
|
|
170
|
+
|
|
171
|
+
### 🔍 `static isRgb(input: string): boolean`
|
|
172
|
+
|
|
173
|
+
Validates whether a string is a valid RGB color.
|
|
174
|
+
|
|
175
|
+
* ✅ Returns `true` if valid.
|
|
176
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### 🔍 `isRgb(): boolean`
|
|
181
|
+
|
|
182
|
+
Instance method that validates the stored color code as an RGB color.
|
|
183
|
+
|
|
184
|
+
* ✅ Returns `true` if valid.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### 🔍 `static isRgba(input: string): boolean`
|
|
189
|
+
|
|
190
|
+
Validates whether a string is a valid RGBA color.
|
|
191
|
+
|
|
192
|
+
* ✅ Returns `true` if valid.
|
|
193
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### 🔍 `isRgba(): boolean`
|
|
198
|
+
|
|
199
|
+
Instance method that validates the stored color code as an RGBA color.
|
|
200
|
+
|
|
201
|
+
* ✅ Returns `true` if valid.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 🎨 HSL & HSLA Validation
|
|
206
|
+
|
|
207
|
+
### 🔍 `static isHsl(input: string): boolean`
|
|
208
|
+
|
|
209
|
+
Validates whether a string is a valid HSL color.
|
|
210
|
+
|
|
211
|
+
* ✅ Returns `true` if valid.
|
|
212
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### 🔍 `isHsl(): boolean`
|
|
217
|
+
|
|
218
|
+
Instance method that validates the stored color code as an HSL color.
|
|
219
|
+
|
|
220
|
+
* ✅ Returns `true` if valid.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### 🔍 `static isHsla(input: string): boolean`
|
|
225
|
+
|
|
226
|
+
Validates whether a string is a valid HSLA color.
|
|
227
|
+
|
|
228
|
+
* ✅ Returns `true` if valid.
|
|
229
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
### 🔍 `isHsla(): boolean`
|
|
234
|
+
|
|
235
|
+
Instance method that validates the stored color code as an HSLA color.
|
|
236
|
+
|
|
237
|
+
* ✅ Returns `true` if valid.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 🎨 HWB, Lab & LCH Validation
|
|
242
|
+
|
|
243
|
+
### 🔍 `static isHwb(input: string): boolean`
|
|
244
|
+
|
|
245
|
+
Validates whether a string is a valid HWB color.
|
|
246
|
+
|
|
247
|
+
* ✅ Returns `true` if valid.
|
|
248
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
### 🔍 `isHwb(): boolean`
|
|
253
|
+
|
|
254
|
+
Instance method that validates the stored color code as an HWB color.
|
|
255
|
+
|
|
256
|
+
* ✅ Returns `true` if valid.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
### 🔍 `static isLab(input: string): boolean`
|
|
261
|
+
|
|
262
|
+
Validates whether a string is a valid CIELAB (Lab) color.
|
|
263
|
+
|
|
264
|
+
* ✅ Returns `true` if valid.
|
|
265
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### 🔍 `isLab(): boolean`
|
|
270
|
+
|
|
271
|
+
Instance method that validates the stored color code as a Lab color.
|
|
272
|
+
|
|
273
|
+
* ✅ Returns `true` if valid.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
### 🔍 `static isLch(input: string): boolean`
|
|
278
|
+
|
|
279
|
+
Validates whether a string is a valid LCH color.
|
|
280
|
+
|
|
281
|
+
* ✅ Returns `true` if valid.
|
|
282
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
### 🔍 `isLch(): boolean`
|
|
287
|
+
|
|
288
|
+
Instance method that validates the stored color code as an LCH color.
|
|
289
|
+
|
|
290
|
+
* ✅ Returns `true` if valid.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## 🎨 Named Colors
|
|
295
|
+
|
|
296
|
+
### 🔍 `static isName(input: string): boolean`
|
|
297
|
+
|
|
298
|
+
Validates whether a string matches a **standard HTML color name**.
|
|
299
|
+
|
|
300
|
+
* ✅ Returns `true` if valid.
|
|
301
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
### 🔍 `isName(): boolean`
|
|
306
|
+
|
|
307
|
+
Instance method that validates the stored color code as a **standard HTML color name**.
|
|
308
|
+
|
|
309
|
+
* ✅ Returns `true` if valid.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
### 🔍 `static isSpecialName(input: string): boolean`
|
|
314
|
+
|
|
315
|
+
Validates whether a string matches a **special CSS color keyword** (e.g., `currentColor`, `transparent`).
|
|
316
|
+
|
|
317
|
+
* ✅ Returns `true` if valid.
|
|
318
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
### 🔍 `isSpecialName(): boolean`
|
|
323
|
+
|
|
324
|
+
Instance method that validates the stored color code as a **special CSS color keyword**.
|
|
325
|
+
|
|
326
|
+
* ✅ Returns `true` if valid.
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 🎨 Universal Color Validation
|
|
331
|
+
|
|
332
|
+
### 🔍 `static isColor(input: string): string|null`
|
|
333
|
+
|
|
334
|
+
Checks whether a string is **any valid CSS color**, including:
|
|
335
|
+
|
|
336
|
+
* HEX / HEXA
|
|
337
|
+
|
|
338
|
+
* RGB / RGBA
|
|
339
|
+
|
|
340
|
+
* HSL / HSLA
|
|
341
|
+
|
|
342
|
+
* HWB
|
|
343
|
+
|
|
344
|
+
* Lab
|
|
345
|
+
|
|
346
|
+
* LCH
|
|
347
|
+
|
|
348
|
+
* HTML color names
|
|
349
|
+
|
|
350
|
+
* Special CSS keywords
|
|
351
|
+
|
|
352
|
+
* ✅ Returns `true` if valid.
|
|
353
|
+
|
|
354
|
+
* ⚠️ Throws `TypeError` if input is not a string.
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## 🎨 Color Parsing
|
|
359
|
+
|
|
360
|
+
### 🔍 `parse(): any[] | string | null`
|
|
361
|
+
|
|
362
|
+
Automatically parses the stored color code based on its detected type (`#type`).
|
|
363
|
+
|
|
364
|
+
* 📤 Returns numeric components for functional colors (RGB, HSL, Lab, etc.) or the lowercase string for named/special colors. Returns `null` if the code is invalid.
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
### 🔎 `static parseHex(input: string): string|null`
|
|
369
|
+
|
|
370
|
+
Parses a HEX color (`#RGB` or `#RRGGBB`).
|
|
371
|
+
|
|
372
|
+
* 📥 Input: HEX string.
|
|
373
|
+
* 📤 Output: Regex match group or `null` if invalid.
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
### 🔎 `parseHex(): string|null`
|
|
378
|
+
|
|
379
|
+
Parses the stored color code as a HEX color.
|
|
380
|
+
|
|
381
|
+
* 📤 Returns match result or `null` if invalid.
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
### 🔎 `static parseHexa(input: string): string|null`
|
|
386
|
+
|
|
387
|
+
Parses a HEXA color (`#RRGGBBAA`).
|
|
388
|
+
|
|
389
|
+
* 📥 Input: HEXA string.
|
|
390
|
+
* 📤 Output: Regex match group or `null` if invalid.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
### 🔎 `parseHexa(): string|null`
|
|
395
|
+
|
|
396
|
+
Parses the stored color code as a HEXA color.
|
|
397
|
+
|
|
398
|
+
* 📤 Returns match result or `null` if invalid.
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 🎨 Parsing RGB & RGBA
|
|
403
|
+
|
|
404
|
+
### 🔎 `static parseRgb(input: string): [number, number, number]|null`
|
|
405
|
+
|
|
406
|
+
Parses an RGB color (`rgb(r, g, b)`).
|
|
407
|
+
|
|
408
|
+
* 📥 Input: RGB string.
|
|
409
|
+
* 📤 Output: `[r, g, b]` as numbers, or `null` if invalid.
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
### 🔎 `parseRgb(): [number, number, number]|null`
|
|
414
|
+
|
|
415
|
+
Parses the stored color code as an RGB color.
|
|
416
|
+
|
|
417
|
+
* 📤 Returns `[r, g, b]` or `null`.
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
### 🔎 `static parseRgba(input: string): [number, number, number, number]|null`
|
|
422
|
+
|
|
423
|
+
Parses an RGBA color (`rgba(r, g, b, a)`).
|
|
424
|
+
|
|
425
|
+
* 📥 Input: RGBA string.
|
|
426
|
+
* 📤 Output: `[r, g, b, a]` as numbers, or `null` if invalid.
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
### 🔎 `parseRgba(): [number, number, number, number]|null`
|
|
431
|
+
|
|
432
|
+
Parses the stored color code as an RGBA color.
|
|
433
|
+
|
|
434
|
+
* 📤 Returns `[r, g, b, a]` or `null`.
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## 🎨 Parsing HSL & HSLA
|
|
439
|
+
|
|
440
|
+
### 🔎 `static parseHsl(input: string): [number, number, number]|null`
|
|
441
|
+
|
|
442
|
+
Parses an HSL color string (`hsl(h, s%, l%)`).
|
|
443
|
+
|
|
444
|
+
* 📥 Input: HSL string
|
|
445
|
+
* 📤 Output: `[h, s, l]` as numbers, or `null` if invalid
|
|
446
|
+
* ⚠️ Throws `TypeError` if input is not a string
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
### 🔎 `parseHsl(): [number, number, number]|null`
|
|
451
|
+
|
|
452
|
+
Parses the stored color code as an HSL color.
|
|
453
|
+
|
|
454
|
+
* 📤 Returns `[h, s, l]` or `null`
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
### 🔎 `static parseHsla(input: string): [number, number, number, number]|null`
|
|
459
|
+
|
|
460
|
+
Parses an HSLA color string (`hsla(h, s%, l%, a)`).
|
|
461
|
+
|
|
462
|
+
* 📥 Input: HSLA string
|
|
463
|
+
* 📤 Output: `[h, s, l, a]` as numbers, or `null` if invalid
|
|
464
|
+
* ⚠️ Throws `TypeError` if input is not a string
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
### 🔎 `parseHsla(): [number, number, number, number]|null`
|
|
469
|
+
|
|
470
|
+
Parses the stored color code as an HSLA color.
|
|
471
|
+
|
|
472
|
+
* 📤 Returns `[h, s, l, a]` or `null`
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## 🎨 Parsing HWB
|
|
477
|
+
|
|
478
|
+
### 🔎 `static parseHwb(input: string): [number, AngleUnit|null, number, number]|null`
|
|
479
|
+
|
|
480
|
+
Parses an HWB color string (`hwb(hue, whiteness%, blackness%[, alpha])`).
|
|
481
|
+
|
|
482
|
+
* 📥 Input: HWB string
|
|
483
|
+
* 📤 Output: `[hue, angleUnit, whiteness, blackness]` or `null`
|
|
484
|
+
* ⚠️ Throws `TypeError` if input is not a string
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
### 🔎 `parseHwb(): [number, AngleUnit|null, number, number]|null`
|
|
489
|
+
|
|
490
|
+
Parses the stored color code as an HWB color.
|
|
491
|
+
|
|
492
|
+
* 📤 Returns `[hue, angleUnit, whiteness, blackness]` or `null`
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## 🎨 Parsing Lab (CIELAB)
|
|
497
|
+
|
|
498
|
+
### 🔎 `static parseLab(input: string): [number, number, number]|null`
|
|
499
|
+
|
|
500
|
+
Parses a Lab color string (`lab(L a b[/alpha])`).
|
|
501
|
+
|
|
502
|
+
* 📥 Input: Lab string
|
|
503
|
+
* 📤 Output: `[L, a, b]` as numbers, or `null` if invalid
|
|
504
|
+
* ⚠️ Throws `TypeError` if input is not a string
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
### 🔎 `parseLab(): [number, number, number]|null`
|
|
509
|
+
|
|
510
|
+
Parses the stored color code as a Lab color.
|
|
511
|
+
|
|
512
|
+
* 📤 Returns `[L, a, b]` or `null`
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## 🎨 Parsing LCH
|
|
517
|
+
|
|
518
|
+
### 🔎 `static parseLch(input: string): [number, number, number, AngleUnit|null]|null`
|
|
519
|
+
|
|
520
|
+
Parses an LCH color string (`lch(L C H[/alpha])`).
|
|
521
|
+
|
|
522
|
+
* 📥 Input: LCH string
|
|
523
|
+
* 📤 Output: `[L, C, H, angleUnit]` or `null`
|
|
524
|
+
* ⚠️ Throws `TypeError` if input is not a string
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
### 🔎 `parseLch(): [number, number, number, AngleUnit|null]|null`
|
|
529
|
+
|
|
530
|
+
Parses the stored color code as an LCH color.
|
|
531
|
+
|
|
532
|
+
* 📤 Returns `[L, C, H, angleUnit]` or `null`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|
|
@@ -164,6 +164,10 @@
|
|
|
164
164
|
"require": "./dist/v1/libs/TinyLoadingScreen.cjs",
|
|
165
165
|
"import": "./dist/v1/libs/TinyLoadingScreen.mjs"
|
|
166
166
|
},
|
|
167
|
+
"./libs/TinyColorValidator": {
|
|
168
|
+
"require": "./dist/v1/libs/TinyColorValidator.cjs",
|
|
169
|
+
"import": "./dist/v1/libs/TinyColorValidator.mjs"
|
|
170
|
+
},
|
|
167
171
|
"./libs/TinyInventoryTrader": {
|
|
168
172
|
"require": "./dist/v1/libs/TinyInventoryTrader.cjs",
|
|
169
173
|
"import": "./dist/v1/libs/TinyInventoryTrader.mjs"
|