@zuzjs/core 0.1.5 → 0.1.6
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/colors.d.ts +24 -0
- package/dist/cjs/colors.js +26 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +7 -3
- package/dist/{index.js → cjs/index.js} +56 -88
- package/dist/cjs/regexps.js +6 -0
- package/dist/{types.d.ts → cjs/types.d.ts} +1 -1
- package/dist/cjs/types.js +5 -0
- package/dist/{withGlobals.js → cjs/withGlobals.js} +1 -3
- package/dist/esm/colors.d.ts +24 -0
- package/dist/esm/colors.js +26 -0
- package/dist/esm/index.d.ts +40 -0
- package/dist/esm/index.js +373 -0
- package/dist/esm/regexps.d.ts +3 -0
- package/dist/esm/regexps.js +6 -0
- package/dist/esm/types.d.ts +22 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/withGlobals.d.ts +25 -0
- package/dist/esm/withGlobals.js +77 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +9 -4
- package/dist/regexps.js +0 -9
- package/dist/types.js +0 -8
- /package/dist/{regexps.d.ts → cjs/regexps.d.ts} +0 -0
- /package/dist/{withGlobals.d.ts → cjs/withGlobals.d.ts} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An array of color names.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This array contains a list of color names that can be used in CSS or other color-related operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare const colorNames: string[];
|
|
8
|
+
/**
|
|
9
|
+
* colorPalatter contains colors and their corresponding shades.
|
|
10
|
+
*/
|
|
11
|
+
export declare const colorPalette: {
|
|
12
|
+
green: {
|
|
13
|
+
50: string;
|
|
14
|
+
100: string;
|
|
15
|
+
200: string;
|
|
16
|
+
300: string;
|
|
17
|
+
400: string;
|
|
18
|
+
500: string;
|
|
19
|
+
600: string;
|
|
20
|
+
700: string;
|
|
21
|
+
800: string;
|
|
22
|
+
900: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An array of color names.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This array contains a list of color names that can be used in CSS or other color-related operations.
|
|
6
|
+
*/
|
|
7
|
+
export const colorNames = [
|
|
8
|
+
'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen'
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* colorPalatter contains colors and their corresponding shades.
|
|
12
|
+
*/
|
|
13
|
+
export const colorPalette = {
|
|
14
|
+
green: {
|
|
15
|
+
50: '#e8f5e9',
|
|
16
|
+
100: '#c8e6c9',
|
|
17
|
+
200: '#a5d6a7',
|
|
18
|
+
300: '#81c784',
|
|
19
|
+
400: '#66bb6a',
|
|
20
|
+
500: '#4caf50',
|
|
21
|
+
600: '#43a047',
|
|
22
|
+
700: '#388e3c',
|
|
23
|
+
800: '#2e7d32',
|
|
24
|
+
900: '#1b5e20',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { AxiosProgressEvent } from "axios";
|
|
2
|
-
import {
|
|
1
|
+
import { AxiosProgressEvent, CancelTokenSource } from "axios";
|
|
2
|
+
import { dynamic, FormatNumberParams, sortOptions } from "./types";
|
|
3
|
+
export { CancelTokenSource, AxiosProgressEvent as UploadProgressEvent };
|
|
4
|
+
export * from "./types";
|
|
3
5
|
export declare const __SALT: string;
|
|
4
6
|
export { default as "_" } from "./withGlobals";
|
|
5
7
|
export declare const numberInRange: (min: number, max: number) => number;
|
|
@@ -14,10 +16,12 @@ export declare const pluralize: (word: string, count: number) => string;
|
|
|
14
16
|
export declare const isHexColor: (color: string) => boolean;
|
|
15
17
|
export declare const isRgbaColor: (color: string) => boolean;
|
|
16
18
|
export declare const isHslColor: (color: string) => boolean;
|
|
19
|
+
export declare const isColorName: (color: string) => boolean;
|
|
17
20
|
export declare const isColor: (color: string) => boolean;
|
|
18
21
|
export declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
19
22
|
export declare const removeDuplicates: <T>(array: T[]) => T[];
|
|
20
|
-
export declare const
|
|
23
|
+
export declare const getCancelToken: () => CancelTokenSource;
|
|
24
|
+
export declare const withPost: <T>(uri: string, data: dynamic | FormData | string, timeout?: number, ignoreKind?: boolean, headers?: dynamic, onProgress?: (ev: AxiosProgressEvent) => void) => Promise<T>;
|
|
21
25
|
export declare const withGet: <T>(uri: string, timeout?: number, ignoreKind?: boolean) => Promise<T>;
|
|
22
26
|
export declare const withTime: (fun: (...args: any[]) => any) => {
|
|
23
27
|
result: any;
|
|
@@ -1,58 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const withGlobals_1 = __importDefault(require("./withGlobals"));
|
|
15
|
-
exports.__SALT = `zuzjs-core`;
|
|
16
|
-
var withGlobals_2 = require("./withGlobals");
|
|
17
|
-
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return __importDefault(withGlobals_2).default; } });
|
|
18
|
-
const numberInRange = (min, max) => {
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import Hashids from "hashids";
|
|
3
|
+
import Cookies from "js-cookie";
|
|
4
|
+
import md5 from "md5";
|
|
5
|
+
import moment from "moment";
|
|
6
|
+
import { colorNames } from "./colors";
|
|
7
|
+
import { hexColorRegex, hslColorRegex, rgbaColorRegex } from "./regexps";
|
|
8
|
+
import { SORT } from "./types";
|
|
9
|
+
import _ from "./withGlobals";
|
|
10
|
+
export * from "./types";
|
|
11
|
+
export const __SALT = `zuzjs-core`;
|
|
12
|
+
export { default as "_" } from "./withGlobals";
|
|
13
|
+
export const numberInRange = (min, max) => {
|
|
19
14
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
20
15
|
};
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
exports.toHash = toHash;
|
|
24
|
-
const fromHash = (str, SALT = null) => {
|
|
16
|
+
export const toHash = (n, len = 6, SALT = null) => new Hashids(SALT || __SALT, len).encode(n);
|
|
17
|
+
export const fromHash = (str, SALT = null) => {
|
|
25
18
|
try {
|
|
26
|
-
const n = new
|
|
19
|
+
const n = new Hashids(SALT || __SALT, +process.env.HASHIDS_LENGTH).decode(str);
|
|
27
20
|
return n.length >= 0 ? Number(n[0]) : 0;
|
|
28
21
|
}
|
|
29
22
|
catch (e) {
|
|
30
23
|
return 0;
|
|
31
24
|
}
|
|
32
25
|
};
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
exports.urlencode = urlencode;
|
|
44
|
-
const pluralize = (word, count) => `${word}${count !== 1 ? 's' : ''}`;
|
|
45
|
-
exports.pluralize = pluralize;
|
|
46
|
-
const isHexColor = (color) => regexps_1.hexColorRegex.test(color);
|
|
47
|
-
exports.isHexColor = isHexColor;
|
|
48
|
-
const isRgbaColor = (color) => regexps_1.rgbaColorRegex.test(color);
|
|
49
|
-
exports.isRgbaColor = isRgbaColor;
|
|
50
|
-
const isHslColor = (color) => regexps_1.hslColorRegex.test(color);
|
|
51
|
-
exports.isHslColor = isHslColor;
|
|
26
|
+
export const MD5 = (str) => md5(str);
|
|
27
|
+
export const uuid = (len) => toHash(numberInRange(11111111111, 999999999999));
|
|
28
|
+
export const ucfirst = (o) => `${o.charAt(0).toUpperCase()}${o.substring(1, o.length)}`;
|
|
29
|
+
export const urldecode = (str) => decodeURIComponent(str.replace(/\+/g, '%20'));
|
|
30
|
+
export const urlencode = (str) => encodeURIComponent(str);
|
|
31
|
+
export const pluralize = (word, count) => `${word}${count !== 1 ? 's' : ''}`;
|
|
32
|
+
export const isHexColor = (color) => hexColorRegex.test(color);
|
|
33
|
+
export const isRgbaColor = (color) => rgbaColorRegex.test(color);
|
|
34
|
+
export const isHslColor = (color) => hslColorRegex.test(color);
|
|
35
|
+
export const isColorName = (color) => colorNames.includes(color.toLowerCase());
|
|
52
36
|
// Function to validate a color string
|
|
53
|
-
const isColor = (color) =>
|
|
54
|
-
|
|
55
|
-
const hexToRgba = (hex, alpha = 1) => {
|
|
37
|
+
export const isColor = (color) => isHexColor(color) || isRgbaColor(color) || isHslColor(color);
|
|
38
|
+
export const hexToRgba = (hex, alpha = 1) => {
|
|
56
39
|
// Remove the hash symbol if present
|
|
57
40
|
hex = hex.replace(/^#/, '');
|
|
58
41
|
// If shorthand hex (#RGB), expand it to full form (#RRGGBB)
|
|
@@ -66,8 +49,7 @@ const hexToRgba = (hex, alpha = 1) => {
|
|
|
66
49
|
const b = bigint & 255;
|
|
67
50
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
68
51
|
};
|
|
69
|
-
|
|
70
|
-
const removeDuplicates = (array) => {
|
|
52
|
+
export const removeDuplicates = (array) => {
|
|
71
53
|
return array.reduce((accumulator, currentValue) => {
|
|
72
54
|
if (!accumulator.includes(currentValue)) {
|
|
73
55
|
accumulator.push(currentValue);
|
|
@@ -75,15 +57,15 @@ const removeDuplicates = (array) => {
|
|
|
75
57
|
return accumulator;
|
|
76
58
|
}, []);
|
|
77
59
|
};
|
|
78
|
-
|
|
79
|
-
const withPost = async (uri, data, timeout = 60, ignoreKind = false, headers, onProgress) => {
|
|
80
|
-
const _cookies =
|
|
60
|
+
export const getCancelToken = () => axios.CancelToken.source();
|
|
61
|
+
export const withPost = async (uri, data, timeout = 60, ignoreKind = false, headers, onProgress) => {
|
|
62
|
+
const _cookies = Cookies.get();
|
|
81
63
|
if (data instanceof FormData) {
|
|
82
64
|
for (const c in _cookies) {
|
|
83
65
|
data.append(c, _cookies[c]);
|
|
84
66
|
}
|
|
85
67
|
return new Promise((resolve, reject) => {
|
|
86
|
-
(
|
|
68
|
+
axios({
|
|
87
69
|
method: 'post',
|
|
88
70
|
url: uri,
|
|
89
71
|
data: data,
|
|
@@ -105,9 +87,9 @@ const withPost = async (uri, data, timeout = 60, ignoreKind = false, headers, on
|
|
|
105
87
|
.catch(err => reject(err));
|
|
106
88
|
});
|
|
107
89
|
}
|
|
108
|
-
else if ((
|
|
90
|
+
else if (_(data).isString()) {
|
|
109
91
|
return new Promise((resolve, reject) => {
|
|
110
|
-
|
|
92
|
+
axios.post(uri, data, {
|
|
111
93
|
timeout: 1000 * timeout,
|
|
112
94
|
headers: {
|
|
113
95
|
'Content-Type': 'application/json',
|
|
@@ -132,7 +114,7 @@ const withPost = async (uri, data, timeout = 60, ignoreKind = false, headers, on
|
|
|
132
114
|
}
|
|
133
115
|
else if (typeof data === "object" && !Array.isArray(data) && data !== null) {
|
|
134
116
|
return new Promise((resolve, reject) => {
|
|
135
|
-
|
|
117
|
+
axios.post(uri, {
|
|
136
118
|
...data,
|
|
137
119
|
..._cookies,
|
|
138
120
|
__stmp: new Date().getTime() / 1000
|
|
@@ -163,10 +145,9 @@ const withPost = async (uri, data, timeout = 60, ignoreKind = false, headers, on
|
|
|
163
145
|
reject();
|
|
164
146
|
});
|
|
165
147
|
};
|
|
166
|
-
|
|
167
|
-
const withGet = async (uri, timeout = 60, ignoreKind = false) => {
|
|
148
|
+
export const withGet = async (uri, timeout = 60, ignoreKind = false) => {
|
|
168
149
|
return new Promise((resolve, reject) => {
|
|
169
|
-
|
|
150
|
+
axios
|
|
170
151
|
.get(uri, { timeout: timeout * 1000 })
|
|
171
152
|
.then((resp) => {
|
|
172
153
|
if (resp.data && (ignoreKind || "kind" in resp.data)) {
|
|
@@ -191,8 +172,7 @@ const withGet = async (uri, timeout = 60, ignoreKind = false) => {
|
|
|
191
172
|
});
|
|
192
173
|
});
|
|
193
174
|
};
|
|
194
|
-
|
|
195
|
-
const withTime = (fun) => {
|
|
175
|
+
export const withTime = (fun) => {
|
|
196
176
|
const start = new Date().getTime();
|
|
197
177
|
const result = fun();
|
|
198
178
|
const end = new Date().getTime();
|
|
@@ -201,18 +181,14 @@ const withTime = (fun) => {
|
|
|
201
181
|
executionTime: end - start
|
|
202
182
|
};
|
|
203
183
|
};
|
|
204
|
-
|
|
205
|
-
const time = (stamp, format) => {
|
|
184
|
+
export const time = (stamp, format) => {
|
|
206
185
|
return stamp ?
|
|
207
|
-
|
|
208
|
-
: (
|
|
186
|
+
moment.unix(+stamp / 1000).format(format || `YYYY-MM-DD HH:mm:ss`)
|
|
187
|
+
: moment().format(format || `YYYY-MM-DD HH:mm:ss`);
|
|
209
188
|
};
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const arrayRand = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
214
|
-
exports.arrayRand = arrayRand;
|
|
215
|
-
const formatNumber = ({ number, locale = 'en-US', style = `decimal`, decimal = 2, currency }) => {
|
|
189
|
+
export const timeSince = (stamp) => moment(stamp).fromNow();
|
|
190
|
+
export const arrayRand = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
191
|
+
export const formatNumber = ({ number, locale = 'en-US', style = `decimal`, decimal = 2, currency }) => {
|
|
216
192
|
if (style === 'currency' && !currency) {
|
|
217
193
|
throw new TypeError('Currency code is required with currency style.');
|
|
218
194
|
}
|
|
@@ -233,8 +209,7 @@ const formatNumber = ({ number, locale = 'en-US', style = `decimal`, decimal = 2
|
|
|
233
209
|
maximumFractionDigits: +number % 1 > 0 ? 2 : 0
|
|
234
210
|
}).format(+number);
|
|
235
211
|
};
|
|
236
|
-
|
|
237
|
-
const formatSize = (bytes) => {
|
|
212
|
+
export const formatSize = (bytes) => {
|
|
238
213
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
239
214
|
const _bytes = `string` == typeof bytes ? parseFloat(bytes) : bytes;
|
|
240
215
|
if (_bytes == 0)
|
|
@@ -244,8 +219,7 @@ const formatSize = (bytes) => {
|
|
|
244
219
|
const nx = _bytes / Math.pow(1024, i);
|
|
245
220
|
return nx.toFixed(2) + ' ' + sizes[i];
|
|
246
221
|
};
|
|
247
|
-
|
|
248
|
-
const copyToClipboard = (text) => {
|
|
222
|
+
export const copyToClipboard = (text) => {
|
|
249
223
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
250
224
|
return navigator.clipboard.writeText(text);
|
|
251
225
|
}
|
|
@@ -269,9 +243,8 @@ const copyToClipboard = (text) => {
|
|
|
269
243
|
});
|
|
270
244
|
}
|
|
271
245
|
};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
direction: types_1.SORT.Asc,
|
|
246
|
+
export const natsort = (options = {
|
|
247
|
+
direction: SORT.Asc,
|
|
275
248
|
caseSensitive: false,
|
|
276
249
|
}) => {
|
|
277
250
|
const ore = /^0/;
|
|
@@ -285,7 +258,7 @@ const natsort = (options = {
|
|
|
285
258
|
const nre = /(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g;
|
|
286
259
|
// datetime
|
|
287
260
|
const dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/; // tslint:disable-line
|
|
288
|
-
const GREATER = options.direction ==
|
|
261
|
+
const GREATER = options.direction == SORT.Desc ? -1 : 1;
|
|
289
262
|
const SMALLER = -GREATER;
|
|
290
263
|
const _normalize = !options.caseSensitive
|
|
291
264
|
? (s) => s.toString().toLowerCase().replace(tre, '')
|
|
@@ -372,24 +345,20 @@ const natsort = (options = {
|
|
|
372
345
|
return 0;
|
|
373
346
|
};
|
|
374
347
|
};
|
|
375
|
-
|
|
376
|
-
const camelCase = (str, ucf = false) => {
|
|
348
|
+
export const camelCase = (str, ucf = false) => {
|
|
377
349
|
return str
|
|
378
350
|
.toLowerCase()
|
|
379
351
|
.split(/[^a-zA-Z0-9]+/) // Split by any non-alphanumeric character
|
|
380
352
|
.map((word, index) => index === 0
|
|
381
|
-
? ucf ?
|
|
382
|
-
:
|
|
353
|
+
? ucf ? ucfirst(word) : word
|
|
354
|
+
: ucfirst(word))
|
|
383
355
|
.join('');
|
|
384
356
|
};
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
exports.camelCaseToDash = camelCaseToDash;
|
|
388
|
-
const clamp = (value, min, max) => {
|
|
357
|
+
export const camelCaseToDash = (str) => str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
358
|
+
export const clamp = (value, min, max) => {
|
|
389
359
|
return Math.min(Math.max(value, min), max);
|
|
390
360
|
};
|
|
391
|
-
|
|
392
|
-
const slugify = (text, separator = "-") => {
|
|
361
|
+
export const slugify = (text, separator = "-") => {
|
|
393
362
|
if (undefined == text) {
|
|
394
363
|
console.log(text, `is undefined`);
|
|
395
364
|
return ``;
|
|
@@ -402,4 +371,3 @@ const slugify = (text, separator = "-") => {
|
|
|
402
371
|
.replace(new RegExp(`\\${separator}{2,}`, "g"), separator) // Remove duplicate separators
|
|
403
372
|
.replace(new RegExp(`^\\${separator}|\\${separator}$`, "g"), ""); // Trim separators from ends
|
|
404
373
|
};
|
|
405
|
-
exports.slugify = slugify;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Hex color regex (#RGB, #RRGGBB)
|
|
2
|
+
export const hexColorRegex = /^#([A-Fa-f0-9]{3}){1,2}$/;
|
|
3
|
+
// RGBA color regex (rgba(255, 255, 255, 1))
|
|
4
|
+
export const rgbaColorRegex = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/;
|
|
5
|
+
// HSL color regex (hsl(360, 100%, 100%))
|
|
6
|
+
export const hslColorRegex = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
class withGlobals {
|
|
4
2
|
_;
|
|
5
3
|
constructor(value) {
|
|
@@ -76,4 +74,4 @@ class withGlobals {
|
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
const _ = (value) => new withGlobals(value);
|
|
79
|
-
|
|
77
|
+
export default _;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An array of color names.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This array contains a list of color names that can be used in CSS or other color-related operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare const colorNames: string[];
|
|
8
|
+
/**
|
|
9
|
+
* colorPalatter contains colors and their corresponding shades.
|
|
10
|
+
*/
|
|
11
|
+
export declare const colorPalette: {
|
|
12
|
+
green: {
|
|
13
|
+
50: string;
|
|
14
|
+
100: string;
|
|
15
|
+
200: string;
|
|
16
|
+
300: string;
|
|
17
|
+
400: string;
|
|
18
|
+
500: string;
|
|
19
|
+
600: string;
|
|
20
|
+
700: string;
|
|
21
|
+
800: string;
|
|
22
|
+
900: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An array of color names.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This array contains a list of color names that can be used in CSS or other color-related operations.
|
|
6
|
+
*/
|
|
7
|
+
export const colorNames = [
|
|
8
|
+
'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen'
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* colorPalatter contains colors and their corresponding shades.
|
|
12
|
+
*/
|
|
13
|
+
export const colorPalette = {
|
|
14
|
+
green: {
|
|
15
|
+
50: '#e8f5e9',
|
|
16
|
+
100: '#c8e6c9',
|
|
17
|
+
200: '#a5d6a7',
|
|
18
|
+
300: '#81c784',
|
|
19
|
+
400: '#66bb6a',
|
|
20
|
+
500: '#4caf50',
|
|
21
|
+
600: '#43a047',
|
|
22
|
+
700: '#388e3c',
|
|
23
|
+
800: '#2e7d32',
|
|
24
|
+
900: '#1b5e20',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AxiosProgressEvent, CancelTokenSource } from "axios";
|
|
2
|
+
import { dynamic, FormatNumberParams, sortOptions } from "./types";
|
|
3
|
+
export { CancelTokenSource, AxiosProgressEvent as UploadProgressEvent };
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export declare const __SALT: string;
|
|
6
|
+
export { default as "_" } from "./withGlobals";
|
|
7
|
+
export declare const numberInRange: (min: number, max: number) => number;
|
|
8
|
+
export declare const toHash: (n: number, len?: number, SALT?: string | null) => string;
|
|
9
|
+
export declare const fromHash: (str: string, SALT?: string | null) => number;
|
|
10
|
+
export declare const MD5: (str: string) => string;
|
|
11
|
+
export declare const uuid: (len: number) => string;
|
|
12
|
+
export declare const ucfirst: (o: any) => string;
|
|
13
|
+
export declare const urldecode: (str: string) => string;
|
|
14
|
+
export declare const urlencode: (str: string) => string;
|
|
15
|
+
export declare const pluralize: (word: string, count: number) => string;
|
|
16
|
+
export declare const isHexColor: (color: string) => boolean;
|
|
17
|
+
export declare const isRgbaColor: (color: string) => boolean;
|
|
18
|
+
export declare const isHslColor: (color: string) => boolean;
|
|
19
|
+
export declare const isColorName: (color: string) => boolean;
|
|
20
|
+
export declare const isColor: (color: string) => boolean;
|
|
21
|
+
export declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
22
|
+
export declare const removeDuplicates: <T>(array: T[]) => T[];
|
|
23
|
+
export declare const getCancelToken: () => CancelTokenSource;
|
|
24
|
+
export declare const withPost: <T>(uri: string, data: dynamic | FormData | string, timeout?: number, ignoreKind?: boolean, headers?: dynamic, onProgress?: (ev: AxiosProgressEvent) => void) => Promise<T>;
|
|
25
|
+
export declare const withGet: <T>(uri: string, timeout?: number, ignoreKind?: boolean) => Promise<T>;
|
|
26
|
+
export declare const withTime: (fun: (...args: any[]) => any) => {
|
|
27
|
+
result: any;
|
|
28
|
+
executionTime: number;
|
|
29
|
+
};
|
|
30
|
+
export declare const time: (stamp?: number, format?: string) => string;
|
|
31
|
+
export declare const timeSince: (stamp: number) => string;
|
|
32
|
+
export declare const arrayRand: (arr: any[]) => any;
|
|
33
|
+
export declare const formatNumber: ({ number, locale, style, decimal, currency }: FormatNumberParams) => string;
|
|
34
|
+
export declare const formatSize: (bytes: number | string) => string;
|
|
35
|
+
export declare const copyToClipboard: (text: string) => Promise<unknown>;
|
|
36
|
+
export declare const natsort: (options?: sortOptions) => (a: string | number, b: string | number) => number;
|
|
37
|
+
export declare const camelCase: (str: string, ucf?: boolean) => string;
|
|
38
|
+
export declare const camelCaseToDash: (str: string) => string;
|
|
39
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
40
|
+
export declare const slugify: (text: string, separator?: string) => string;
|