@react-fabric/utilities 1.0.0-beta.9 → 1.0.1
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/css/boundingBox.js +72 -0
- package/dist/cjs/css/cn.js +39 -0
- package/dist/cjs/css/imageColorset.js +96 -0
- package/dist/cjs/data/countries.js +98 -0
- package/dist/cjs/{_fileType.js → data/fileType.js} +37 -19
- package/dist/cjs/data/format.js +136 -0
- package/dist/cjs/helpers/debounce.js +63 -0
- package/dist/cjs/{useLogger.js → helpers/getLogger.js} +96 -96
- package/dist/cjs/helpers/lonlat.js +99 -0
- package/dist/cjs/index.js +99 -76
- package/dist/cjs/lists/dedupe.js +54 -0
- package/dist/cjs/lists/flatten.js +66 -0
- package/dist/cjs/{_getByPath.js → lists/getByPath.js} +58 -37
- package/dist/cjs/lists/groupBy.js +49 -0
- package/dist/cjs/matchers/compare.js +70 -0
- package/dist/cjs/matchers/isEmpty.js +34 -0
- package/dist/cjs/matchers/isEqual.js +82 -0
- package/dist/cjs/matchers/nullChecks.js +61 -0
- package/dist/cjs/matchers/typeChecks.js +127 -0
- package/dist/cjs/strings/ascii.js +105 -0
- package/dist/cjs/strings/hash.js +75 -0
- package/dist/cjs/strings/interpolate.js +47 -0
- package/dist/cjs/strings/matchString.js +54 -0
- package/dist/cjs/strings/template.js +48 -0
- package/dist/cjs/strings/tokenize.js +83 -0
- package/dist/cjs/utils/mergeRefs.js +56 -0
- package/dist/esm/css/boundingBox.js +71 -0
- package/dist/esm/css/cn.js +39 -0
- package/dist/esm/css/imageColorset.js +96 -0
- package/dist/esm/data/countries.js +98 -0
- package/dist/esm/{_fileType.js → data/fileType.js} +37 -19
- package/dist/esm/data/format.js +138 -0
- package/dist/esm/helpers/debounce.js +63 -0
- package/dist/esm/{useLogger.js → helpers/getLogger.js} +96 -96
- package/dist/esm/helpers/lonlat.js +97 -0
- package/dist/esm/index.js +54 -36
- package/dist/esm/lists/dedupe.js +54 -0
- package/dist/esm/lists/flatten.js +65 -0
- package/dist/esm/{_getByPath.js → lists/getByPath.js} +50 -29
- package/dist/esm/lists/groupBy.js +49 -0
- package/dist/esm/matchers/compare.js +70 -0
- package/dist/esm/matchers/isEmpty.js +34 -0
- package/dist/esm/matchers/isEqual.js +82 -0
- package/dist/esm/matchers/nullChecks.js +58 -0
- package/dist/esm/matchers/typeChecks.js +119 -0
- package/dist/esm/strings/ascii.js +105 -0
- package/dist/esm/strings/hash.js +73 -0
- package/dist/esm/strings/interpolate.js +47 -0
- package/dist/esm/strings/matchString.js +54 -0
- package/dist/esm/strings/template.js +48 -0
- package/dist/esm/strings/tokenize.js +82 -0
- package/dist/esm/utils/mergeRefs.js +56 -0
- package/dist/types/css/boundingBox.d.ts +46 -0
- package/dist/types/css/cn.d.ts +26 -0
- package/dist/types/css/imageColorset.d.ts +37 -0
- package/dist/types/data/countries.d.ts +136 -0
- package/dist/types/{_fileType.d.ts → data/fileType.d.ts} +41 -1
- package/dist/types/data/format.d.ts +122 -0
- package/dist/types/helpers/debounce.d.ts +38 -0
- package/dist/types/helpers/getLogger.d.ts +49 -0
- package/dist/types/helpers/lonlat.d.ts +48 -0
- package/dist/types/index.d.ts +54 -20
- package/dist/types/lists/dedupe.d.ts +36 -0
- package/dist/types/lists/flatten.d.ts +47 -0
- package/dist/types/lists/getByPath.d.ts +45 -0
- package/dist/types/lists/groupBy.d.ts +36 -0
- package/dist/types/matchers/compare.d.ts +38 -0
- package/dist/types/matchers/isEmpty.d.ts +38 -0
- package/dist/types/matchers/isEqual.d.ts +39 -0
- package/dist/types/matchers/nullChecks.d.ts +43 -0
- package/dist/types/matchers/typeChecks.d.ts +107 -0
- package/dist/types/strings/ascii.d.ts +34 -0
- package/dist/types/strings/hash.d.ts +46 -0
- package/dist/types/strings/interpolate.d.ts +34 -0
- package/dist/types/strings/matchString.d.ts +41 -0
- package/dist/types/strings/template.d.ts +35 -0
- package/dist/types/strings/tokenize.d.ts +44 -0
- package/dist/types/utils/mergeRefs.d.ts +36 -0
- package/package.json +13 -11
- package/src/css/boundingBox.ts +80 -0
- package/src/css/cn.ts +32 -0
- package/src/css/imageColorset.ts +97 -0
- package/src/data/countries.ts +126 -0
- package/src/{_fileType.ts → data/fileType.ts} +72 -89
- package/src/data/format.ts +192 -0
- package/src/helpers/debounce.ts +49 -0
- package/src/{useLogger.ts → helpers/getLogger.ts} +52 -101
- package/src/helpers/lonlat.ts +124 -0
- package/src/index.ts +57 -37
- package/src/lists/dedupe.ts +46 -0
- package/src/lists/flatten.ts +56 -0
- package/src/lists/getByPath.ts +122 -0
- package/src/lists/groupBy.ts +47 -0
- package/src/matchers/compare.ts +64 -0
- package/src/matchers/isEmpty.ts +54 -0
- package/src/matchers/isEqual.ts +71 -0
- package/src/matchers/nullChecks.ts +55 -0
- package/src/matchers/typeChecks.ts +146 -0
- package/src/strings/ascii.ts +100 -0
- package/src/strings/hash.ts +68 -0
- package/src/strings/interpolate.ts +42 -0
- package/src/strings/matchString.ts +49 -0
- package/src/strings/template.ts +43 -0
- package/src/strings/tokenize.ts +77 -0
- package/src/utils/mergeRefs.ts +47 -0
- package/src/{yup.ts → utils/yup.ts} +3 -3
- package/dist/cjs/_ascii.js +0 -76
- package/dist/cjs/_boundingBox.js +0 -59
- package/dist/cjs/_countries.js +0 -2805
- package/dist/cjs/_debounce.js +0 -53
- package/dist/cjs/_dedupe.js +0 -63
- package/dist/cjs/_fetch.js +0 -128
- package/dist/cjs/_format.js +0 -118
- package/dist/cjs/_hash.js +0 -67
- package/dist/cjs/_interpolate.js +0 -47
- package/dist/cjs/_isEqual.js +0 -108
- package/dist/cjs/_isType.js +0 -98
- package/dist/cjs/_mergeRefs.js +0 -40
- package/dist/cjs/_tokenize.js +0 -67
- package/dist/cjs/getImageColorset.js +0 -70
- package/dist/esm/_ascii.js +0 -76
- package/dist/esm/_boundingBox.js +0 -58
- package/dist/esm/_countries.js +0 -2805
- package/dist/esm/_debounce.js +0 -53
- package/dist/esm/_dedupe.js +0 -60
- package/dist/esm/_fetch.js +0 -128
- package/dist/esm/_format.js +0 -120
- package/dist/esm/_hash.js +0 -65
- package/dist/esm/_interpolate.js +0 -46
- package/dist/esm/_isEqual.js +0 -106
- package/dist/esm/_isType.js +0 -85
- package/dist/esm/_mergeRefs.js +0 -40
- package/dist/esm/_tokenize.js +0 -66
- package/dist/esm/getImageColorset.js +0 -70
- package/dist/types/_ascii.d.ts +0 -5
- package/dist/types/_boundingBox.d.ts +0 -10
- package/dist/types/_countries.d.ts +0 -85
- package/dist/types/_debounce.d.ts +0 -8
- package/dist/types/_dedupe.d.ts +0 -4
- package/dist/types/_fetch.d.ts +0 -23
- package/dist/types/_format.d.ts +0 -27
- package/dist/types/_getByPath.d.ts +0 -10
- package/dist/types/_hash.d.ts +0 -16
- package/dist/types/_interpolate.d.ts +0 -6
- package/dist/types/_isEqual.d.ts +0 -15
- package/dist/types/_isType.d.ts +0 -14
- package/dist/types/_mergeRefs.d.ts +0 -1
- package/dist/types/_tokenize.d.ts +0 -8
- package/dist/types/getImageColorset.d.ts +0 -1
- package/dist/types/useLogger.d.ts +0 -25
- package/src/_ascii.ts +0 -93
- package/src/_boundingBox.ts +0 -72
- package/src/_countries.ts +0 -3046
- package/src/_debounce.ts +0 -42
- package/src/_dedupe.ts +0 -56
- package/src/_fetch.ts +0 -109
- package/src/_format.ts +0 -141
- package/src/_getByPath.ts +0 -108
- package/src/_hash.ts +0 -62
- package/src/_interpolate.ts +0 -42
- package/src/_isEqual.ts +0 -102
- package/src/_isType.ts +0 -105
- package/src/_mergeRefs.ts +0 -33
- package/src/_tokenize.ts +0 -69
- package/src/getImageColorset.ts +0 -81
- /package/dist/cjs/{yup.js → utils/yup.js} +0 -0
- /package/dist/esm/{yup.js → utils/yup.js} +0 -0
- /package/dist/types/{yup.d.ts → utils/yup.d.ts} +0 -0
package/dist/esm/_mergeRefs.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* React Fabric
|
|
5
|
-
* @version: 1.0.0
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
10
|
-
*
|
|
11
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
13
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
14
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
-
* subject to the following conditions:
|
|
16
|
-
*
|
|
17
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
18
|
-
* portions of the Software.
|
|
19
|
-
*
|
|
20
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
21
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/* istanbul ignore file */
|
|
27
|
-
|
|
28
|
-
var mergeRefs = function mergeRefs() {
|
|
29
|
-
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
-
refs[_key] = arguments[_key];
|
|
31
|
-
}
|
|
32
|
-
return function (el) {
|
|
33
|
-
refs.forEach(function (ref) {
|
|
34
|
-
if (typeof ref === "function") ref(el);
|
|
35
|
-
if (ref && "current" in ref) ref.current = el;
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { mergeRefs };
|
package/dist/esm/_tokenize.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { isEmpty, isArray } from './_isType.js';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* React Fabric
|
|
7
|
-
* @version: 1.0.0
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
14
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
15
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
16
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
17
|
-
* subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
20
|
-
* portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
23
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
24
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
25
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* split text into array of tokens by word boundaries
|
|
31
|
-
* @param str
|
|
32
|
-
* @param keywords
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
var tokenize = function tokenize(str, keywords) {
|
|
36
|
-
if (isEmpty(keywords)) {
|
|
37
|
-
return [[str, ""]];
|
|
38
|
-
}
|
|
39
|
-
var keys = isArray(keywords) ? keywords : [keywords];
|
|
40
|
-
var keyMap = keys.map(function (key) {
|
|
41
|
-
// escape regex control characters
|
|
42
|
-
var escapedKey = key.replace(/([+*.?^$()[\]\\!&|\-=])/gm, "\\$1");
|
|
43
|
-
// place token within word boundaries if start/end with alpha-numeric
|
|
44
|
-
if (key.match(/^[a-z0-9]/i) != null) escapedKey = "\\b".concat(escapedKey);
|
|
45
|
-
if (key.match(/[a-z0-9]$/i) != null) escapedKey = "".concat(escapedKey, "\\b");
|
|
46
|
-
return escapedKey;
|
|
47
|
-
});
|
|
48
|
-
var regx = new RegExp("(".concat(keyMap.join("|"), ")"), "img");
|
|
49
|
-
var match;
|
|
50
|
-
var lastIndex = 0;
|
|
51
|
-
var tokens = [];
|
|
52
|
-
while ((match = regx.exec(str)) !== null) {
|
|
53
|
-
tokens.push([str.substring(lastIndex, match.index), str.substring(match.index, regx.lastIndex)]);
|
|
54
|
-
lastIndex = regx.lastIndex;
|
|
55
|
-
}
|
|
56
|
-
tokens.push([str.substring(lastIndex), ""]);
|
|
57
|
-
return tokens;
|
|
58
|
-
};
|
|
59
|
-
var iconToken = function iconToken(str) {
|
|
60
|
-
var split = str.trim().split(" ");
|
|
61
|
-
var first = split[0];
|
|
62
|
-
var last = split.length > 1 && split.pop();
|
|
63
|
-
return (first && last ? "".concat(first.charAt(0)).concat(last.charAt(0)) : "".concat(first.substring(0, 2))).toUpperCase();
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export { iconToken, tokenize };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* React Fabric
|
|
5
|
-
* @version: 1.0.0
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
10
|
-
*
|
|
11
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
13
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
14
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
-
* subject to the following conditions:
|
|
16
|
-
*
|
|
17
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
18
|
-
* portions of the Software.
|
|
19
|
-
*
|
|
20
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
21
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/* istanbul ignore file */
|
|
27
|
-
|
|
28
|
-
var getImageColorset = function getImageColorset(el) {
|
|
29
|
-
// create canvas
|
|
30
|
-
var canvas = document.createElement("canvas");
|
|
31
|
-
canvas.width = Math.min(500, el.naturalWidth);
|
|
32
|
-
canvas.height = Math.min(500, el.naturalHeight);
|
|
33
|
-
var ctx = canvas.getContext("2d");
|
|
34
|
-
if (ctx != null) {
|
|
35
|
-
ctx.drawImage(el, 0, 0, el.naturalWidth, el.naturalHeight, 0, 0, canvas.width, canvas.height);
|
|
36
|
-
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
37
|
-
var data = imageData.data;
|
|
38
|
-
var r, g, b;
|
|
39
|
-
var dark = 0;
|
|
40
|
-
var light = 0;
|
|
41
|
-
var totalPixels = 0;
|
|
42
|
-
var transparent = (data === null || data === void 0 ? void 0 : data[3]) === 0;
|
|
43
|
-
for (var x = 0, len = data.length; x < len; x += 4) {
|
|
44
|
-
if (data[x + 3] === 0) {
|
|
45
|
-
transparent = true;
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (transparent && data[x - 1] === 1) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
r = data[x];
|
|
52
|
-
g = data[x + 1];
|
|
53
|
-
b = data[x + 2];
|
|
54
|
-
totalPixels++;
|
|
55
|
-
0.2126 * r + 0.7152 * g + 0.0722 * b < 128 ? dark++ : light++;
|
|
56
|
-
}
|
|
57
|
-
var diff = light / totalPixels - dark / totalPixels;
|
|
58
|
-
var ret = diff > 0 ? "light" : "dark";
|
|
59
|
-
if (transparent) {
|
|
60
|
-
ret += "_transparent";
|
|
61
|
-
}
|
|
62
|
-
return ret;
|
|
63
|
-
}
|
|
64
|
-
return "light";
|
|
65
|
-
};
|
|
66
|
-
if (typeof window !== "undefined")
|
|
67
|
-
// @ts-expect-error ignore
|
|
68
|
-
window.getImageColorset = getImageColorset;
|
|
69
|
-
|
|
70
|
-
export { getImageColorset };
|
package/dist/types/_ascii.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* box "x,y,w,h" | [x,y,w,h]
|
|
3
|
-
* returns canvas box [x,y,w,h]
|
|
4
|
-
*/
|
|
5
|
-
export declare const getBox: (box?: string | [number, number, number, number]) => [number, number, number, number];
|
|
6
|
-
/**
|
|
7
|
-
* box "x1,y1,x2,y2" | [x1,y1,x2,y2]
|
|
8
|
-
* returns canvas box [x,y,w,h]
|
|
9
|
-
*/
|
|
10
|
-
export declare const getBoundingBox: (box?: string | [number, number, number, number]) => [number, number, number, number];
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export interface Country {
|
|
5
|
-
continent: string;
|
|
6
|
-
iso2: string;
|
|
7
|
-
iso3: string;
|
|
8
|
-
alt?: string;
|
|
9
|
-
name: string;
|
|
10
|
-
alpha: string;
|
|
11
|
-
fullname: string;
|
|
12
|
-
capital: string;
|
|
13
|
-
tld: string;
|
|
14
|
-
currency: string;
|
|
15
|
-
phone: string;
|
|
16
|
-
emoji: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* country list with helper functions
|
|
20
|
-
*/
|
|
21
|
-
declare const _default: {
|
|
22
|
-
/**
|
|
23
|
-
* Get iso2 code
|
|
24
|
-
* @param code
|
|
25
|
-
*/
|
|
26
|
-
toIso2(code: string): string | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Get iso3 code
|
|
29
|
-
* @param code
|
|
30
|
-
*/
|
|
31
|
-
toIso3(code: string): string | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Country flag emoji
|
|
34
|
-
* @param code
|
|
35
|
-
*/
|
|
36
|
-
emoji(code: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Get country name
|
|
39
|
-
* @param code
|
|
40
|
-
*/
|
|
41
|
-
name: (code: string) => string;
|
|
42
|
-
/**
|
|
43
|
-
* Find country by code
|
|
44
|
-
* @param code
|
|
45
|
-
* @return continent: string;
|
|
46
|
-
* @return iso2: string;
|
|
47
|
-
* @return iso3: string;
|
|
48
|
-
* @return name: string;
|
|
49
|
-
* @return fullname: string;
|
|
50
|
-
* @return capital: string;
|
|
51
|
-
* @return tld: string;
|
|
52
|
-
* @return currency: string;
|
|
53
|
-
* @return phone: string;
|
|
54
|
-
* @return emoji: string;
|
|
55
|
-
*/
|
|
56
|
-
find(code: string): Country | undefined;
|
|
57
|
-
list: ({
|
|
58
|
-
continent: string;
|
|
59
|
-
iso2: string;
|
|
60
|
-
iso3: string;
|
|
61
|
-
alpha: string;
|
|
62
|
-
name: string;
|
|
63
|
-
fullname: string;
|
|
64
|
-
capital: string;
|
|
65
|
-
tld: string;
|
|
66
|
-
currency: string;
|
|
67
|
-
phone: string;
|
|
68
|
-
emoji: string;
|
|
69
|
-
alt?: undefined;
|
|
70
|
-
} | {
|
|
71
|
-
continent: string;
|
|
72
|
-
iso2: string;
|
|
73
|
-
iso3: string;
|
|
74
|
-
alt: string;
|
|
75
|
-
alpha: string;
|
|
76
|
-
name: string;
|
|
77
|
-
fullname: string;
|
|
78
|
-
capital: string;
|
|
79
|
-
tld: string;
|
|
80
|
-
currency: string;
|
|
81
|
-
phone: string;
|
|
82
|
-
emoji: string;
|
|
83
|
-
})[];
|
|
84
|
-
};
|
|
85
|
-
export default _default;
|
package/dist/types/_dedupe.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const dedupe: (list: any[], key?: string) => any[];
|
|
2
|
-
export declare const flatten: (list: any[]) => any[];
|
|
3
|
-
export declare const flattenAndDedupe: (list?: any[], key?: string) => any[];
|
|
4
|
-
export declare const groupBy: <T extends KeyValue<any>>(list: T[], prop: keyof T, missingKey?: string) => KeyValue<T[]>;
|
package/dist/types/_fetch.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
declare type METHODS = "get" | "post" | "put" | "delete";
|
|
2
|
-
declare interface FetchOptions {
|
|
3
|
-
body?: KeyValue | FormData;
|
|
4
|
-
headers?: KeyValue;
|
|
5
|
-
signal?: string | AbortSignal;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Fetch helper
|
|
9
|
-
* @param method
|
|
10
|
-
* @param url
|
|
11
|
-
* @param options.headers
|
|
12
|
-
* @param options.body
|
|
13
|
-
* @param options.signal
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare const _fetch: {
|
|
17
|
-
(method: METHODS, url: string, { headers, body, signal }: FetchOptions): Promise<any>;
|
|
18
|
-
/** ***************** attach isAborted helper to fetch method *******************/
|
|
19
|
-
isAborted({ name }: Error): boolean;
|
|
20
|
-
/** ***************** attach abort helper to fetch method *******************/
|
|
21
|
-
abort(signal: string): void;
|
|
22
|
-
};
|
|
23
|
-
export {};
|
package/dist/types/_format.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare namespace Format {
|
|
2
|
-
/** ***************** format phone number using `libphonenumber-js` *******************/
|
|
3
|
-
const phone: (value?: string, country?: string, useCss?: boolean) => string | undefined;
|
|
4
|
-
/** ***************** format whole number using `numeral` *******************/
|
|
5
|
-
const number: (number?: string | number, format?: string) => string;
|
|
6
|
-
/** ***************** format bytes using `numeral` *******************/
|
|
7
|
-
const bytes: (number?: string | number) => string;
|
|
8
|
-
/** ***************** format percentage using `numeral` *******************/
|
|
9
|
-
const percent: (number?: string | number) => string;
|
|
10
|
-
/** ***************** format date using `date-fns` *******************/
|
|
11
|
-
const date: (date?: Date | string | number, fmt?: string) => string;
|
|
12
|
-
/** ***************** format time duration from total seconds/milliseconds *******************/
|
|
13
|
-
/**
|
|
14
|
-
* Format time duration with milliseconds
|
|
15
|
-
* @param number
|
|
16
|
-
* @param isFraction
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
const duration: (number?: string | number, isFraction?: boolean) => string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Format time duration without milliseconds
|
|
22
|
-
* @param number
|
|
23
|
-
* @param isFraction
|
|
24
|
-
* @returns
|
|
25
|
-
*/
|
|
26
|
-
const durationSeconds: (number?: string | number, isFraction?: boolean) => string | undefined;
|
|
27
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* get property value by path
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare const getByPath: <T = any>(obj: KeyValue, path: string, defaultValue?: any) => T;
|
|
6
|
-
/**
|
|
7
|
-
* get first available value in list
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const getValue: (...args: any[]) => any;
|
package/dist/types/_hash.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* calculate hash from string
|
|
3
|
-
* @param str
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare const hash: (str: string) => number;
|
|
7
|
-
/**
|
|
8
|
-
* generate short hash from current time
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const shortHash: () => string;
|
|
12
|
-
/**
|
|
13
|
-
* generate uuid using `crypto.getRandomValues`
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare const uuid: () => string;
|
package/dist/types/_isEqual.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* check equality of objects
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare const isEqual: (obj: unknown, test: unknown) => boolean;
|
|
6
|
-
/**
|
|
7
|
-
* match strings
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const matchString: (base: string, match: string, equality?: "start" | boolean) => boolean;
|
|
11
|
-
/**
|
|
12
|
-
* compare values
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare const compareValues: (order?: "asc" | "desc", key?: string) => (a: unknown, b: unknown) => 0 | 1 | -1;
|
package/dist/types/_isType.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const isUndefined: (value: AnyObject) => value is undefined;
|
|
2
|
-
export declare const isNull: (value: AnyObject) => value is null;
|
|
3
|
-
export declare const isNil: (val: AnyObject) => val is undefined;
|
|
4
|
-
export declare const isEmpty: (val: AnyObject) => val is undefined;
|
|
5
|
-
export declare const isObject: (val: AnyObject) => val is KeyValue<any>;
|
|
6
|
-
export declare const isArray: <T = any>(val: AnyObject) => val is T[];
|
|
7
|
-
export declare const isString: (value: AnyObject) => value is string;
|
|
8
|
-
export declare const isNumber: (value: AnyObject) => value is number;
|
|
9
|
-
export declare const isBoolean: (value: AnyObject) => value is boolean;
|
|
10
|
-
export declare const isTrue: (value?: AnyObject) => value is true;
|
|
11
|
-
export declare const isFalse: (value?: AnyObject) => value is false;
|
|
12
|
-
export declare const isColor: (color: string) => boolean;
|
|
13
|
-
export declare const isSvgPath: (value: AnyObject) => value is string;
|
|
14
|
-
export declare const isRtl: () => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const mergeRefs: (...refs: AnyObject[]) => (el: AnyObject) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getImageColorset: (el: HTMLImageElement) => string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
interface LogDetail {
|
|
2
|
-
module?: string;
|
|
3
|
-
process?: string;
|
|
4
|
-
duration?: number;
|
|
5
|
-
totalTime?: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const useLogger: (mod?: string) => {
|
|
11
|
-
timer(process: string): {
|
|
12
|
-
log: (msg: string, ...rest: unknown[]) => void;
|
|
13
|
-
debug: (msg: string, ...rest: unknown[]) => void;
|
|
14
|
-
info: (msg: string, ...rest: unknown[]) => void;
|
|
15
|
-
error: (msg: string, ...rest: unknown[]) => void;
|
|
16
|
-
warning: (msg: string, ...rest: unknown[]) => void;
|
|
17
|
-
end: (msg?: string, ...rest: unknown[]) => void;
|
|
18
|
-
};
|
|
19
|
-
log(msg: string, { module, ...opts }: LogDetail, ...rest: unknown[]): void;
|
|
20
|
-
debug(msg: string, { module, ...opts }: LogDetail, ...rest: unknown[]): void;
|
|
21
|
-
info(msg: string, { module, ...opts }: LogDetail, ...rest: unknown[]): void;
|
|
22
|
-
error(msg: string, { module, ...opts }: LogDetail, ...rest: unknown[]): void;
|
|
23
|
-
warning(msg: string, { module, ...opts }: LogDetail, ...rest: unknown[]): void;
|
|
24
|
-
};
|
|
25
|
-
export {};
|
package/src/_ascii.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/* istanbul ignore file */
|
|
25
|
-
|
|
26
|
-
import { isEmpty } from "./_isType";
|
|
27
|
-
|
|
28
|
-
/** ***************** latin-ascii conversions *******************/
|
|
29
|
-
const conversions = {
|
|
30
|
-
AE: "Æ|Ǽ",
|
|
31
|
-
Ae: "Ä",
|
|
32
|
-
ae: "ä|æ|ǽ",
|
|
33
|
-
OE: "Œ",
|
|
34
|
-
Oe: "Ö",
|
|
35
|
-
oe: "ö|œ",
|
|
36
|
-
Ue: "Ü",
|
|
37
|
-
ue: "ü",
|
|
38
|
-
IJ: "IJ",
|
|
39
|
-
ij: "ij",
|
|
40
|
-
ss: "ß",
|
|
41
|
-
A: "À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ",
|
|
42
|
-
a: "à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª",
|
|
43
|
-
C: "Ç|Ć|Ĉ|Ċ|Č",
|
|
44
|
-
c: "ç|ć|ĉ|ċ|č",
|
|
45
|
-
D: "Ð|Ď|Đ",
|
|
46
|
-
d: "ð|ď|đ",
|
|
47
|
-
E: "È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě",
|
|
48
|
-
e: "è|é|ê|ë|ē|ĕ|ė|ę|ě",
|
|
49
|
-
G: "Ĝ|Ğ|Ġ|Ģ",
|
|
50
|
-
g: "ĝ|ğ|ġ|ģ",
|
|
51
|
-
H: "Ĥ|Ħ",
|
|
52
|
-
h: "ĥ|ħ",
|
|
53
|
-
I: "Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ",
|
|
54
|
-
i: "ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı",
|
|
55
|
-
J: "Ĵ",
|
|
56
|
-
j: "ĵ",
|
|
57
|
-
K: "Ķ",
|
|
58
|
-
k: "ķ",
|
|
59
|
-
L: "Ĺ|Ļ|Ľ|Ŀ|Ł",
|
|
60
|
-
l: "ĺ|ļ|ľ|ŀ|ł",
|
|
61
|
-
N: "Ñ|Ń|Ņ|Ň",
|
|
62
|
-
n: "ñ|ń|ņ|ň|ʼn",
|
|
63
|
-
O: "Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ",
|
|
64
|
-
o: "ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º",
|
|
65
|
-
R: "Ŕ|Ŗ|Ř",
|
|
66
|
-
r: "ŕ|ŗ|ř",
|
|
67
|
-
S: "Ś|Ŝ|Ş|Š",
|
|
68
|
-
s: "ś|ŝ|ş|š|ſ",
|
|
69
|
-
T: "Ţ|Ť|Ŧ",
|
|
70
|
-
t: "ţ|ť|ŧ",
|
|
71
|
-
U: "Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ",
|
|
72
|
-
u: "ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ",
|
|
73
|
-
Y: "Ý|Ÿ|Ŷ",
|
|
74
|
-
y: "ý|ÿ|ŷ",
|
|
75
|
-
W: "Ŵ",
|
|
76
|
-
w: "ŵ",
|
|
77
|
-
Z: "Ź|Ż|Ž",
|
|
78
|
-
z: "ź|ż|ž",
|
|
79
|
-
f: "ƒ",
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* latin to ascii converter for convenient searching
|
|
84
|
-
* @internal
|
|
85
|
-
*/
|
|
86
|
-
export const ascii = (str: string) => {
|
|
87
|
-
if (isEmpty(str)) return "";
|
|
88
|
-
Object.entries(conversions).forEach(([a, l]) => {
|
|
89
|
-
const re = new RegExp(l, "g");
|
|
90
|
-
str = `${str}`.replace(re, a);
|
|
91
|
-
});
|
|
92
|
-
return str;
|
|
93
|
-
};
|
package/src/_boundingBox.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* React Fabric
|
|
3
|
-
* @version: 1.0.0
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c) 2024 Adarsh Pastakia
|
|
8
|
-
*
|
|
9
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
-
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
-
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
-
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
-
* subject to the following conditions:
|
|
14
|
-
*
|
|
15
|
-
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
-
* portions of the Software.
|
|
17
|
-
*
|
|
18
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
-
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
-
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { isEmpty } from "./_isType";
|
|
25
|
-
|
|
26
|
-
const _getBox = (
|
|
27
|
-
box: string | [number, number, number, number],
|
|
28
|
-
): [number, number, number, number] => {
|
|
29
|
-
let boundingBox: any = box;
|
|
30
|
-
if (isEmpty(box)) return [0, 0, 0, 0];
|
|
31
|
-
if (typeof box === "string") {
|
|
32
|
-
boundingBox = box.split(",");
|
|
33
|
-
}
|
|
34
|
-
if (Array.isArray(boundingBox)) {
|
|
35
|
-
boundingBox = boundingBox.map((b) => parseInt(b, 10));
|
|
36
|
-
}
|
|
37
|
-
return boundingBox;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* box "x,y,w,h" | [x,y,w,h]
|
|
42
|
-
* returns canvas box [x,y,w,h]
|
|
43
|
-
*/
|
|
44
|
-
export const getBox = (
|
|
45
|
-
box: string | [number, number, number, number] = "0,0,0,0",
|
|
46
|
-
) => {
|
|
47
|
-
const boundingBox = _getBox(box);
|
|
48
|
-
|
|
49
|
-
let [x, y, w, h] = boundingBox;
|
|
50
|
-
w = x < 0 ? w + x : w;
|
|
51
|
-
h = y < 0 ? h + y : h;
|
|
52
|
-
x = x > 0 ? x : 0;
|
|
53
|
-
y = y > 0 ? y : 0;
|
|
54
|
-
return [x, y, w, h] as [number, number, number, number];
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* box "x1,y1,x2,y2" | [x1,y1,x2,y2]
|
|
59
|
-
* returns canvas box [x,y,w,h]
|
|
60
|
-
*/
|
|
61
|
-
export const getBoundingBox = (
|
|
62
|
-
box: string | [number, number, number, number] = "0,0,0,0",
|
|
63
|
-
) => {
|
|
64
|
-
const boundingBox = _getBox(box);
|
|
65
|
-
|
|
66
|
-
let [x1, y1, x2, y2] = boundingBox;
|
|
67
|
-
const w = x2 - x1;
|
|
68
|
-
const h = y2 - y1;
|
|
69
|
-
x1 = x1 > 0 ? x1 : 0;
|
|
70
|
-
y1 = y1 > 0 ? y1 : 0;
|
|
71
|
-
return [x1, y1, w, h] as [number, number, number, number];
|
|
72
|
-
};
|