smoothly 0.1.84 → 0.1.85
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/cjs/index.cjs.js +214 -116
- package/dist/collection/index.js +1 -1
- package/dist/collection/utilities/Cosmetic/Color/CommaRgb.js +90 -0
- package/dist/collection/utilities/Cosmetic/Color/Hex.js +11 -0
- package/dist/collection/utilities/Cosmetic/Color/Hsl.js +32 -0
- package/dist/collection/utilities/{colorNames.js → Cosmetic/Color/Name.js} +9 -1
- package/dist/collection/utilities/Cosmetic/Color/Rgb.js +19 -0
- package/dist/collection/utilities/Cosmetic/Color/index.js +23 -0
- package/dist/collection/utilities/Cosmetic/index.js +40 -0
- package/dist/collection/utilities/index.js +1 -1
- package/dist/custom-elements/index.js +221 -122
- package/dist/esm/index.js +215 -116
- package/dist/smoothly/index.esm.js +215 -116
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utilities/Cosmetic/Color/CommaRgb.d.ts +11 -0
- package/dist/types/utilities/Cosmetic/Color/Hex.d.ts +4 -0
- package/dist/types/utilities/Cosmetic/Color/Hsl.d.ts +4 -0
- package/dist/types/utilities/Cosmetic/Color/Name.d.ts +155 -0
- package/dist/types/utilities/Cosmetic/Color/Rgb.d.ts +4 -0
- package/dist/types/utilities/Cosmetic/Color/index.d.ts +170 -0
- package/dist/types/utilities/Cosmetic/index.d.ts +23 -0
- package/dist/types/utilities/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/collection/utilities/colorTransform.js +0 -120
- package/dist/types/utilities/colorNames.d.ts +0 -3
- package/dist/types/utilities/colorTransform.d.ts +0 -8
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -6,7 +6,52 @@ const App = require('./App-ffc56e72.js');
|
|
|
6
6
|
const index = require('./index-de5d1ee1.js');
|
|
7
7
|
require('./index-138c41c2.js');
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
var Hex;
|
|
10
|
+
(function (Hex) {
|
|
11
|
+
function is(value) {
|
|
12
|
+
const matchArray = (typeof value == "string" && value.match(/[0-9a-fA-F]/g)) || undefined;
|
|
13
|
+
return (typeof value == "string" &&
|
|
14
|
+
value.length > 3 &&
|
|
15
|
+
value[0] == "#" &&
|
|
16
|
+
((matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 3 || (matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 6));
|
|
17
|
+
}
|
|
18
|
+
Hex.is = is;
|
|
19
|
+
})(Hex || (Hex = {}));
|
|
20
|
+
|
|
21
|
+
var Hsl;
|
|
22
|
+
(function (Hsl) {
|
|
23
|
+
function is(value) {
|
|
24
|
+
const values = typeof value == "string" && value.length > 11 ? value.substring(4, value.length - 1).split(",") : [];
|
|
25
|
+
return (typeof value == "string" &&
|
|
26
|
+
value.length > 11 &&
|
|
27
|
+
value.substr(0, 4) == "hsl(" &&
|
|
28
|
+
value.substr(value.length - 1, 1) == ")" &&
|
|
29
|
+
values.length == 3 &&
|
|
30
|
+
values.every((single, index) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
let result = false;
|
|
33
|
+
if (index == 0)
|
|
34
|
+
result =
|
|
35
|
+
!Number.isNaN(single) &&
|
|
36
|
+
((_a = single.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == single.length &&
|
|
37
|
+
Number(single) >= 0 &&
|
|
38
|
+
Number(single) <= 360;
|
|
39
|
+
else {
|
|
40
|
+
const number = single.substr(0, single.length - 1);
|
|
41
|
+
result =
|
|
42
|
+
single[single.length - 1] == "%" &&
|
|
43
|
+
!Number.isNaN(number) &&
|
|
44
|
+
((_b = number.match(/[0-9]/g)) === null || _b === void 0 ? void 0 : _b.length) == number.length &&
|
|
45
|
+
Number(number) >= 0 &&
|
|
46
|
+
Number(number) <= 100;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
Hsl.is = is;
|
|
52
|
+
})(Hsl || (Hsl = {}));
|
|
53
|
+
|
|
54
|
+
const Names = {
|
|
10
55
|
aliceblue: "#f0f8ff",
|
|
11
56
|
antiquewhite: "#faebd7",
|
|
12
57
|
aqua: "#00ffff",
|
|
@@ -156,130 +201,183 @@ const colorNames = {
|
|
|
156
201
|
yellow: "#ffff00",
|
|
157
202
|
yellowgreen: "#9acd32",
|
|
158
203
|
};
|
|
204
|
+
var Name;
|
|
205
|
+
(function (Name) {
|
|
206
|
+
Name.types = () => Object.keys(Names);
|
|
207
|
+
function is(value) {
|
|
208
|
+
return typeof value == "string" && Name.types().includes(value.toLowerCase());
|
|
209
|
+
}
|
|
210
|
+
Name.is = is;
|
|
211
|
+
})(Name || (Name = {}));
|
|
159
212
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
result
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
213
|
+
var Rgb;
|
|
214
|
+
(function (Rgb) {
|
|
215
|
+
function is(value) {
|
|
216
|
+
const values = typeof value == "string" && value.length > 9 ? value.substring(4, value.length - 1).split(",") : [];
|
|
217
|
+
return (typeof value == "string" &&
|
|
218
|
+
value.length > 9 &&
|
|
219
|
+
value.substr(0, 4) == "rgb(" &&
|
|
220
|
+
value.substr(value.length - 1, 1) == ")" &&
|
|
221
|
+
values.length == 3 &&
|
|
222
|
+
values.every((value) => {
|
|
223
|
+
var _a;
|
|
224
|
+
return !Number.isNaN(value) &&
|
|
225
|
+
((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
|
|
226
|
+
Number(value) >= 0 &&
|
|
227
|
+
Number(value) <= 255;
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
Rgb.is = is;
|
|
231
|
+
})(Rgb || (Rgb = {}));
|
|
232
|
+
|
|
233
|
+
var CommaRgb;
|
|
234
|
+
(function (CommaRgb) {
|
|
235
|
+
function is(value) {
|
|
236
|
+
const values = typeof value == "string" ? value.split(",") : [];
|
|
237
|
+
return (values.length == 3 &&
|
|
238
|
+
values.every((value) => {
|
|
239
|
+
var _a;
|
|
240
|
+
return !Number.isNaN(value) &&
|
|
241
|
+
((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
|
|
242
|
+
Number(value) >= 0 &&
|
|
243
|
+
Number(value) <= 255;
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
CommaRgb.is = is;
|
|
247
|
+
function from(color) {
|
|
248
|
+
let result;
|
|
249
|
+
const colorWithoutSpace = typeof color == "string" ? color.replace(/ /g, "").toLowerCase() : undefined;
|
|
250
|
+
if (!colorWithoutSpace)
|
|
251
|
+
result = undefined;
|
|
252
|
+
else if (CommaRgb.is(colorWithoutSpace))
|
|
253
|
+
result = colorWithoutSpace;
|
|
254
|
+
else if (Hex.is(colorWithoutSpace))
|
|
255
|
+
result = fromHex(colorWithoutSpace);
|
|
256
|
+
else if (Rgb.is(colorWithoutSpace))
|
|
257
|
+
result = fromRgb(colorWithoutSpace);
|
|
258
|
+
else if (Name.is(colorWithoutSpace))
|
|
259
|
+
result = fromHex(Names[colorWithoutSpace]);
|
|
260
|
+
else if (Hsl.is(colorWithoutSpace))
|
|
261
|
+
result = fromHsl(colorWithoutSpace);
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
CommaRgb.from = from;
|
|
265
|
+
function fromHex(hex) {
|
|
266
|
+
let result = "0,0,0";
|
|
267
|
+
if (hex.length == 7)
|
|
268
|
+
result = `${parseInt(hex.substr(1, 2), 16)},${parseInt(hex.substr(3, 2), 16)},${parseInt(hex.substr(5, 2), 16)}`;
|
|
269
|
+
else if (hex.length == 4)
|
|
270
|
+
result = fromHex(`#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}`);
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
CommaRgb.fromHex = fromHex;
|
|
274
|
+
function fromRgb(rgb) {
|
|
275
|
+
return rgb.substring(4, rgb.length - 1);
|
|
276
|
+
}
|
|
277
|
+
CommaRgb.fromRgb = fromRgb;
|
|
278
|
+
function fromHsl(hsl) {
|
|
279
|
+
let result = "";
|
|
280
|
+
let h, s, l;
|
|
281
|
+
let r, g, b;
|
|
282
|
+
const HSL = hsl
|
|
283
|
+
.substring(4, hsl.length - 1)
|
|
284
|
+
.split(",")
|
|
285
|
+
.map((value, index) => Number(index == 0 ? value : value.substr(0, value.length - 1)));
|
|
286
|
+
if (HSL.length == 3) {
|
|
287
|
+
h = HSL[0] / 360;
|
|
288
|
+
s = HSL[1] / 100;
|
|
289
|
+
l = HSL[2] / 100;
|
|
290
|
+
if (s == 0)
|
|
291
|
+
r = g = b = l;
|
|
228
292
|
else {
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
Number(number) >= 0 &&
|
|
235
|
-
Number(number) <= 100;
|
|
293
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
294
|
+
const p = 2 * l - q;
|
|
295
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
296
|
+
g = hue2rgb(p, q, h);
|
|
297
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
236
298
|
}
|
|
237
|
-
|
|
238
|
-
}));
|
|
239
|
-
}
|
|
240
|
-
function hue2rgb(p, q, t) {
|
|
241
|
-
let result = p;
|
|
242
|
-
if (t < 0)
|
|
243
|
-
t += 1;
|
|
244
|
-
if (t > 1)
|
|
245
|
-
t -= 1;
|
|
246
|
-
if (t < 1 / 6)
|
|
247
|
-
result = p + (q - p) * 6 * t;
|
|
248
|
-
else if (t < 1 / 2)
|
|
249
|
-
result = q;
|
|
250
|
-
else if (t < 2 / 3)
|
|
251
|
-
result = p + (q - p) * (2 / 3 - t) * 6;
|
|
252
|
-
return result;
|
|
253
|
-
}
|
|
254
|
-
function hslToCommaRgb(hsl) {
|
|
255
|
-
let result;
|
|
256
|
-
let h, s, l;
|
|
257
|
-
let r, g, b;
|
|
258
|
-
const HSL = hsl
|
|
259
|
-
.substring(4, hsl.length - 1)
|
|
260
|
-
.split(",")
|
|
261
|
-
.map((value, index) => Number(index == 0 ? value : value.substr(0, value.length - 1)));
|
|
262
|
-
if (HSL.length == 3) {
|
|
263
|
-
h = HSL[0] / 360;
|
|
264
|
-
s = HSL[1] / 100;
|
|
265
|
-
l = HSL[2] / 100;
|
|
266
|
-
if (s == 0)
|
|
267
|
-
r = g = b = l;
|
|
268
|
-
else {
|
|
269
|
-
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
270
|
-
const p = 2 * l - q;
|
|
271
|
-
r = hue2rgb(p, q, h + 1 / 3);
|
|
272
|
-
g = hue2rgb(p, q, h);
|
|
273
|
-
b = hue2rgb(p, q, h - 1 / 3);
|
|
299
|
+
result = `${Math.round(255 * r)},${Math.round(255 * g)},${Math.round(255 * b)}`;
|
|
274
300
|
}
|
|
275
|
-
result
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
CommaRgb.fromHsl = fromHsl;
|
|
304
|
+
function hue2rgb(p, q, t) {
|
|
305
|
+
let result = p;
|
|
306
|
+
if (t < 0)
|
|
307
|
+
t += 1;
|
|
308
|
+
if (t > 1)
|
|
309
|
+
t -= 1;
|
|
310
|
+
if (t < 1 / 6)
|
|
311
|
+
result = p + (q - p) * 6 * t;
|
|
312
|
+
else if (t < 1 / 2)
|
|
313
|
+
result = q;
|
|
314
|
+
else if (t < 2 / 3)
|
|
315
|
+
result = p + (q - p) * (2 / 3 - t) * 6;
|
|
316
|
+
return result;
|
|
276
317
|
}
|
|
277
|
-
|
|
318
|
+
})(CommaRgb || (CommaRgb = {}));
|
|
319
|
+
|
|
320
|
+
var Color;
|
|
321
|
+
(function (Color) {
|
|
322
|
+
function is(value) {
|
|
323
|
+
return (typeof value == "string" &&
|
|
324
|
+
(CommaRgb.is(value) || Hex.is(value) || Hsl.is(value) || Name.is(value) || Rgb.is(value)));
|
|
325
|
+
}
|
|
326
|
+
Color.is = is;
|
|
327
|
+
function from(value) {
|
|
328
|
+
return is(value) ? value : undefined;
|
|
329
|
+
}
|
|
330
|
+
Color.from = from;
|
|
331
|
+
Color.Names = Names;
|
|
332
|
+
Color.Name = Name;
|
|
333
|
+
Color.CommaRgb = CommaRgb;
|
|
334
|
+
Color.Rgb = Rgb;
|
|
335
|
+
Color.Hex = Hex;
|
|
336
|
+
Color.Hsl = Hsl;
|
|
337
|
+
})(Color || (Color = {}));
|
|
338
|
+
|
|
339
|
+
function reduce(types, value) {
|
|
340
|
+
return types.reduce((r, c) => typeof value == "object" && value != null && typeof value[c] == "string"
|
|
341
|
+
? Object.assign(Object.assign({}, r), { [c]: value[c] }) : r, {});
|
|
278
342
|
}
|
|
343
|
+
exports.Cosmetic = void 0;
|
|
344
|
+
(function (Cosmetic) {
|
|
345
|
+
Cosmetic.types = Cosmetic;
|
|
346
|
+
function from(value) {
|
|
347
|
+
let result = {};
|
|
348
|
+
if (typeof value == "object" && value) {
|
|
349
|
+
result = {
|
|
350
|
+
text: reduce(["background", "color"], value.text),
|
|
351
|
+
border: reduce(["background", "color", "style", "radius", "width"], value.border),
|
|
352
|
+
gap: typeof value.gap == "string" ? value.gap : undefined,
|
|
353
|
+
dangerColor: typeof value.dangerColor == "string"
|
|
354
|
+
? value.dangerColor
|
|
355
|
+
: typeof value.danger_color == "string"
|
|
356
|
+
? value.danger_color
|
|
357
|
+
: undefined,
|
|
358
|
+
fontFamily: typeof value.fontFamily == "string"
|
|
359
|
+
? value.fontFamily
|
|
360
|
+
: typeof value.font_family == "string"
|
|
361
|
+
? value.font_family
|
|
362
|
+
: undefined,
|
|
363
|
+
background: typeof value.background == "string" ? value.background : undefined,
|
|
364
|
+
};
|
|
365
|
+
Object.keys(result).forEach((key) => {
|
|
366
|
+
var _a;
|
|
367
|
+
if (result[key] == undefined ||
|
|
368
|
+
(typeof result[key] == "object" && result[key] && Object.keys((_a = result[key]) !== null && _a !== void 0 ? _a : {}).length == 0)) {
|
|
369
|
+
delete result[key];
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return result;
|
|
374
|
+
}
|
|
375
|
+
Cosmetic.from = from;
|
|
376
|
+
Cosmetic.Color = Color;
|
|
377
|
+
})(exports.Cosmetic || (exports.Cosmetic = {}));
|
|
279
378
|
|
|
280
379
|
exports.App = App.App;
|
|
281
380
|
exports.ClientIdentifier = index.ClientIdentifier;
|
|
282
381
|
exports.Message = index.Message;
|
|
283
382
|
exports.Notice = index.Notice;
|
|
284
383
|
exports.Trigger = index.Trigger;
|
|
285
|
-
exports.toCommaRgb = toCommaRgb;
|
package/dist/collection/index.js
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Hex } from "./Hex";
|
|
2
|
+
import { Hsl } from "./Hsl";
|
|
3
|
+
import { Name as ColorName, Names } from "./Name";
|
|
4
|
+
import { Rgb } from "./Rgb";
|
|
5
|
+
export var CommaRgb;
|
|
6
|
+
(function (CommaRgb) {
|
|
7
|
+
function is(value) {
|
|
8
|
+
const values = typeof value == "string" ? value.split(",") : [];
|
|
9
|
+
return (values.length == 3 &&
|
|
10
|
+
values.every((value) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return !Number.isNaN(value) &&
|
|
13
|
+
((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
|
|
14
|
+
Number(value) >= 0 &&
|
|
15
|
+
Number(value) <= 255;
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
CommaRgb.is = is;
|
|
19
|
+
function from(color) {
|
|
20
|
+
let result;
|
|
21
|
+
const colorWithoutSpace = typeof color == "string" ? color.replace(/ /g, "").toLowerCase() : undefined;
|
|
22
|
+
if (!colorWithoutSpace)
|
|
23
|
+
result = undefined;
|
|
24
|
+
else if (CommaRgb.is(colorWithoutSpace))
|
|
25
|
+
result = colorWithoutSpace;
|
|
26
|
+
else if (Hex.is(colorWithoutSpace))
|
|
27
|
+
result = fromHex(colorWithoutSpace);
|
|
28
|
+
else if (Rgb.is(colorWithoutSpace))
|
|
29
|
+
result = fromRgb(colorWithoutSpace);
|
|
30
|
+
else if (ColorName.is(colorWithoutSpace))
|
|
31
|
+
result = fromHex(Names[colorWithoutSpace]);
|
|
32
|
+
else if (Hsl.is(colorWithoutSpace))
|
|
33
|
+
result = fromHsl(colorWithoutSpace);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
CommaRgb.from = from;
|
|
37
|
+
function fromHex(hex) {
|
|
38
|
+
let result = "0,0,0";
|
|
39
|
+
if (hex.length == 7)
|
|
40
|
+
result = `${parseInt(hex.substr(1, 2), 16)},${parseInt(hex.substr(3, 2), 16)},${parseInt(hex.substr(5, 2), 16)}`;
|
|
41
|
+
else if (hex.length == 4)
|
|
42
|
+
result = fromHex(`#${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}`);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
CommaRgb.fromHex = fromHex;
|
|
46
|
+
function fromRgb(rgb) {
|
|
47
|
+
return rgb.substring(4, rgb.length - 1);
|
|
48
|
+
}
|
|
49
|
+
CommaRgb.fromRgb = fromRgb;
|
|
50
|
+
function fromHsl(hsl) {
|
|
51
|
+
let result = "";
|
|
52
|
+
let h, s, l;
|
|
53
|
+
let r, g, b;
|
|
54
|
+
const HSL = hsl
|
|
55
|
+
.substring(4, hsl.length - 1)
|
|
56
|
+
.split(",")
|
|
57
|
+
.map((value, index) => Number(index == 0 ? value : value.substr(0, value.length - 1)));
|
|
58
|
+
if (HSL.length == 3) {
|
|
59
|
+
h = HSL[0] / 360;
|
|
60
|
+
s = HSL[1] / 100;
|
|
61
|
+
l = HSL[2] / 100;
|
|
62
|
+
if (s == 0)
|
|
63
|
+
r = g = b = l;
|
|
64
|
+
else {
|
|
65
|
+
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
66
|
+
const p = 2 * l - q;
|
|
67
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
68
|
+
g = hue2rgb(p, q, h);
|
|
69
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
70
|
+
}
|
|
71
|
+
result = `${Math.round(255 * r)},${Math.round(255 * g)},${Math.round(255 * b)}`;
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
CommaRgb.fromHsl = fromHsl;
|
|
76
|
+
function hue2rgb(p, q, t) {
|
|
77
|
+
let result = p;
|
|
78
|
+
if (t < 0)
|
|
79
|
+
t += 1;
|
|
80
|
+
if (t > 1)
|
|
81
|
+
t -= 1;
|
|
82
|
+
if (t < 1 / 6)
|
|
83
|
+
result = p + (q - p) * 6 * t;
|
|
84
|
+
else if (t < 1 / 2)
|
|
85
|
+
result = q;
|
|
86
|
+
else if (t < 2 / 3)
|
|
87
|
+
result = p + (q - p) * (2 / 3 - t) * 6;
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
})(CommaRgb || (CommaRgb = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var Hex;
|
|
2
|
+
(function (Hex) {
|
|
3
|
+
function is(value) {
|
|
4
|
+
const matchArray = (typeof value == "string" && value.match(/[0-9a-fA-F]/g)) || undefined;
|
|
5
|
+
return (typeof value == "string" &&
|
|
6
|
+
value.length > 3 &&
|
|
7
|
+
value[0] == "#" &&
|
|
8
|
+
((matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 3 || (matchArray === null || matchArray === void 0 ? void 0 : matchArray.length) == 6));
|
|
9
|
+
}
|
|
10
|
+
Hex.is = is;
|
|
11
|
+
})(Hex || (Hex = {}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export var Hsl;
|
|
2
|
+
(function (Hsl) {
|
|
3
|
+
function is(value) {
|
|
4
|
+
const values = typeof value == "string" && value.length > 11 ? value.substring(4, value.length - 1).split(",") : [];
|
|
5
|
+
return (typeof value == "string" &&
|
|
6
|
+
value.length > 11 &&
|
|
7
|
+
value.substr(0, 4) == "hsl(" &&
|
|
8
|
+
value.substr(value.length - 1, 1) == ")" &&
|
|
9
|
+
values.length == 3 &&
|
|
10
|
+
values.every((single, index) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
let result = false;
|
|
13
|
+
if (index == 0)
|
|
14
|
+
result =
|
|
15
|
+
!Number.isNaN(single) &&
|
|
16
|
+
((_a = single.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == single.length &&
|
|
17
|
+
Number(single) >= 0 &&
|
|
18
|
+
Number(single) <= 360;
|
|
19
|
+
else {
|
|
20
|
+
const number = single.substr(0, single.length - 1);
|
|
21
|
+
result =
|
|
22
|
+
single[single.length - 1] == "%" &&
|
|
23
|
+
!Number.isNaN(number) &&
|
|
24
|
+
((_b = number.match(/[0-9]/g)) === null || _b === void 0 ? void 0 : _b.length) == number.length &&
|
|
25
|
+
Number(number) >= 0 &&
|
|
26
|
+
Number(number) <= 100;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
Hsl.is = is;
|
|
32
|
+
})(Hsl || (Hsl = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const Names = {
|
|
2
2
|
aliceblue: "#f0f8ff",
|
|
3
3
|
antiquewhite: "#faebd7",
|
|
4
4
|
aqua: "#00ffff",
|
|
@@ -148,3 +148,11 @@ export const colorNames = {
|
|
|
148
148
|
yellow: "#ffff00",
|
|
149
149
|
yellowgreen: "#9acd32",
|
|
150
150
|
};
|
|
151
|
+
export var Name;
|
|
152
|
+
(function (Name) {
|
|
153
|
+
Name.types = () => Object.keys(Names);
|
|
154
|
+
function is(value) {
|
|
155
|
+
return typeof value == "string" && Name.types().includes(value.toLowerCase());
|
|
156
|
+
}
|
|
157
|
+
Name.is = is;
|
|
158
|
+
})(Name || (Name = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export var Rgb;
|
|
2
|
+
(function (Rgb) {
|
|
3
|
+
function is(value) {
|
|
4
|
+
const values = typeof value == "string" && value.length > 9 ? value.substring(4, value.length - 1).split(",") : [];
|
|
5
|
+
return (typeof value == "string" &&
|
|
6
|
+
value.length > 9 &&
|
|
7
|
+
value.substr(0, 4) == "rgb(" &&
|
|
8
|
+
value.substr(value.length - 1, 1) == ")" &&
|
|
9
|
+
values.length == 3 &&
|
|
10
|
+
values.every((value) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return !Number.isNaN(value) &&
|
|
13
|
+
((_a = value.match(/[0-9]/g)) === null || _a === void 0 ? void 0 : _a.length) == value.length &&
|
|
14
|
+
Number(value) >= 0 &&
|
|
15
|
+
Number(value) <= 255;
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
Rgb.is = is;
|
|
19
|
+
})(Rgb || (Rgb = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CommaRgb as ColorCommaRgb } from "./CommaRgb";
|
|
2
|
+
import { Hex as ColorHex } from "./Hex";
|
|
3
|
+
import { Hsl as ColorHsl } from "./Hsl";
|
|
4
|
+
import { Name as ColorName, Names as ColorNames } from "./Name";
|
|
5
|
+
import { Rgb as ColorRgb } from "./Rgb";
|
|
6
|
+
export var Color;
|
|
7
|
+
(function (Color) {
|
|
8
|
+
function is(value) {
|
|
9
|
+
return (typeof value == "string" &&
|
|
10
|
+
(ColorCommaRgb.is(value) || ColorHex.is(value) || ColorHsl.is(value) || ColorName.is(value) || ColorRgb.is(value)));
|
|
11
|
+
}
|
|
12
|
+
Color.is = is;
|
|
13
|
+
function from(value) {
|
|
14
|
+
return is(value) ? value : undefined;
|
|
15
|
+
}
|
|
16
|
+
Color.from = from;
|
|
17
|
+
Color.Names = ColorNames;
|
|
18
|
+
Color.Name = ColorName;
|
|
19
|
+
Color.CommaRgb = ColorCommaRgb;
|
|
20
|
+
Color.Rgb = ColorRgb;
|
|
21
|
+
Color.Hex = ColorHex;
|
|
22
|
+
Color.Hsl = ColorHsl;
|
|
23
|
+
})(Color || (Color = {}));
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Color as CosmeticColor } from "./Color";
|
|
2
|
+
function reduce(types, value) {
|
|
3
|
+
return types.reduce((r, c) => typeof value == "object" && value != null && typeof value[c] == "string"
|
|
4
|
+
? Object.assign(Object.assign({}, r), { [c]: value[c] }) : r, {});
|
|
5
|
+
}
|
|
6
|
+
export var Cosmetic;
|
|
7
|
+
(function (Cosmetic) {
|
|
8
|
+
Cosmetic.types = Cosmetic;
|
|
9
|
+
function from(value) {
|
|
10
|
+
let result = {};
|
|
11
|
+
if (typeof value == "object" && value) {
|
|
12
|
+
result = {
|
|
13
|
+
text: reduce(["background", "color"], value.text),
|
|
14
|
+
border: reduce(["background", "color", "style", "radius", "width"], value.border),
|
|
15
|
+
gap: typeof value.gap == "string" ? value.gap : undefined,
|
|
16
|
+
dangerColor: typeof value.dangerColor == "string"
|
|
17
|
+
? value.dangerColor
|
|
18
|
+
: typeof value.danger_color == "string"
|
|
19
|
+
? value.danger_color
|
|
20
|
+
: undefined,
|
|
21
|
+
fontFamily: typeof value.fontFamily == "string"
|
|
22
|
+
? value.fontFamily
|
|
23
|
+
: typeof value.font_family == "string"
|
|
24
|
+
? value.font_family
|
|
25
|
+
: undefined,
|
|
26
|
+
background: typeof value.background == "string" ? value.background : undefined,
|
|
27
|
+
};
|
|
28
|
+
Object.keys(result).forEach((key) => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (result[key] == undefined ||
|
|
31
|
+
(typeof result[key] == "object" && result[key] && Object.keys((_a = result[key]) !== null && _a !== void 0 ? _a : {}).length == 0)) {
|
|
32
|
+
delete result[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
Cosmetic.from = from;
|
|
39
|
+
Cosmetic.Color = CosmeticColor;
|
|
40
|
+
})(Cosmetic || (Cosmetic = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Cosmetic } from "./Cosmetic";
|