@fixefy/fixefy-ui-utils 0.2.74 → 0.2.76
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/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"date-fns": ">=3.6.0",
|
|
16
16
|
"graphql-tag": ">=2.12.6",
|
|
17
17
|
"jss": ">=10.10.0",
|
|
18
|
-
"next": ">=
|
|
18
|
+
"next": ">=16.0.0",
|
|
19
19
|
"pluralize": ">=8.0.0",
|
|
20
20
|
"react": ">=18.3.1",
|
|
21
21
|
"react-dom": ">=18.3.1",
|
|
@@ -26,11 +26,13 @@
|
|
|
26
26
|
"date-fns": "^4.1.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
+
"@swc/cli": "0.3.12",
|
|
30
|
+
"@swc/core": "1.5.24",
|
|
29
31
|
"@types/convert-excel-to-json": "1.7.4",
|
|
30
32
|
"@types/node": "20.14.0",
|
|
31
33
|
"@types/react": "18.3.3",
|
|
32
34
|
"eslint": "9.34.0",
|
|
33
|
-
"eslint-config-next": "
|
|
35
|
+
"eslint-config-next": "16.1.6",
|
|
34
36
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
35
37
|
"eslint-plugin-react": "7.37.5",
|
|
36
38
|
"eslint-plugin-react-hooks": "5.2.0",
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
"build": "swc src -d dist --strip-leading-paths && tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
48
50
|
"pre_release": "yarn clean && yarn && yarn build",
|
|
49
51
|
"raw_publish": "npm publish --userconfig ./.npmrc --otp 000000",
|
|
50
|
-
"clean": "rm -rf build && rm -rf dist
|
|
52
|
+
"clean": "rm -rf build && rm -rf dist && yarn clean:node",
|
|
51
53
|
"clean:node": "rm -rf node_modules",
|
|
52
54
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
53
55
|
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
@@ -67,5 +69,5 @@
|
|
|
67
69
|
"require": "./dist/index.js"
|
|
68
70
|
}
|
|
69
71
|
},
|
|
70
|
-
"version": "0.2.
|
|
72
|
+
"version": "0.2.76"
|
|
71
73
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type StorageType = 'localStorage' | 'sessionStorage';
|
|
2
|
-
export declare const useStorage: () => {
|
|
3
|
-
getItem: ({ key, type }: {
|
|
4
|
-
key: string;
|
|
5
|
-
type: StorageType;
|
|
6
|
-
}) => any;
|
|
7
|
-
setItem: ({ key, value, type }: {
|
|
8
|
-
key: string;
|
|
9
|
-
value: unknown;
|
|
10
|
-
type: StorageType;
|
|
11
|
-
}) => void;
|
|
12
|
-
removeItem: ({ key, type }: {
|
|
13
|
-
key: string;
|
|
14
|
-
type: StorageType;
|
|
15
|
-
}) => void;
|
|
16
|
-
clear: ({ type }: {
|
|
17
|
-
type: StorageType;
|
|
18
|
-
}) => void;
|
|
19
|
-
getStorageLength: ({ type }: {
|
|
20
|
-
type: StorageType;
|
|
21
|
-
}) => number | null;
|
|
22
|
-
};
|
|
23
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useStorage", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useStorage;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const isWindow = typeof window !== 'undefined';
|
|
12
|
-
const useStorage = ()=>{
|
|
13
|
-
const isStorageTypeProvided = (type)=>{
|
|
14
|
-
if (!type) {
|
|
15
|
-
throw new Error('Provide type of storage: localStorage or sessionStorage.');
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const getItem = ({ key, type })=>{
|
|
19
|
-
try {
|
|
20
|
-
if (isWindow) {
|
|
21
|
-
isStorageTypeProvided(type);
|
|
22
|
-
//@ts-ignore
|
|
23
|
-
const item = JSON.parse(window[type].getItem(key));
|
|
24
|
-
if (!item) return null;
|
|
25
|
-
return item;
|
|
26
|
-
}
|
|
27
|
-
} catch (error) {
|
|
28
|
-
// console.log(error)
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const setItem = ({ key, value, type })=>{
|
|
32
|
-
try {
|
|
33
|
-
if (isWindow) {
|
|
34
|
-
isStorageTypeProvided(type);
|
|
35
|
-
window[type].setItem(key, JSON.stringify(value));
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
// console.log(error)
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const removeItem = ({ key, type })=>{
|
|
42
|
-
try {
|
|
43
|
-
if (isWindow) {
|
|
44
|
-
isStorageTypeProvided(type);
|
|
45
|
-
window[type].removeItem(key);
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
// console.log(error)
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const clear = ({ type })=>{
|
|
52
|
-
try {
|
|
53
|
-
if (isWindow) {
|
|
54
|
-
isStorageTypeProvided(type);
|
|
55
|
-
window[type].clear();
|
|
56
|
-
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
// console.log(error)
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const getStorageLength = ({ type })=>{
|
|
62
|
-
try {
|
|
63
|
-
if (isWindow) {
|
|
64
|
-
isStorageTypeProvided(type);
|
|
65
|
-
return window[type].length;
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
// console.log(error)
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
73
|
-
getItem,
|
|
74
|
-
setItem,
|
|
75
|
-
removeItem,
|
|
76
|
-
clear,
|
|
77
|
-
getStorageLength
|
|
78
|
-
};
|
|
79
|
-
};
|
package/dist/storage/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useStorage } from './hooks/use-storage';
|
package/dist/storage/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useStorage", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _usestorage.useStorage;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _usestorage = require("./hooks/use-storage");
|
package/dist/validate/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { MaybeN } from '@fixefy/fixefy-entities';
|
|
2
|
-
export declare const is_array_valid: (arr: unknown, min_length?: MaybeN<number>, max_length?: MaybeN<number>) => arr is Array<unknown>;
|
|
3
|
-
export declare const is_date_valid: (d: unknown) => d is Date;
|
|
4
|
-
export declare const is_object_valid: (obj: unknown) => obj is Record<string, unknown>;
|
|
5
|
-
export declare const is_string_valid: (str: unknown, minLength?: MaybeN<number>, maxLength?: MaybeN<number>) => str is string;
|
|
6
|
-
export declare const is_object_id: (value: unknown) => value is string;
|
package/dist/validate/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
is_array_valid: function() {
|
|
13
|
-
return is_array_valid;
|
|
14
|
-
},
|
|
15
|
-
is_date_valid: function() {
|
|
16
|
-
return is_date_valid;
|
|
17
|
-
},
|
|
18
|
-
is_object_id: function() {
|
|
19
|
-
return is_object_id;
|
|
20
|
-
},
|
|
21
|
-
is_object_valid: function() {
|
|
22
|
-
return is_object_valid;
|
|
23
|
-
},
|
|
24
|
-
is_string_valid: function() {
|
|
25
|
-
return is_string_valid;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const is_array_valid = (arr, min_length = 1, max_length = null)=>{
|
|
29
|
-
if (null == arr) return false;
|
|
30
|
-
if (false == Array.isArray(arr)) return false;
|
|
31
|
-
if (min_length) {
|
|
32
|
-
if (arr.length < min_length) return false;
|
|
33
|
-
}
|
|
34
|
-
if (max_length) {
|
|
35
|
-
if (arr.length > max_length) return false;
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
};
|
|
39
|
-
const is_date_valid = (d)=>{
|
|
40
|
-
if (!d) return false;
|
|
41
|
-
if (Object.prototype.toString.call(d) != '[object Date]') return false;
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
const is_object_valid = (obj)=>{
|
|
45
|
-
if (null == obj) return false;
|
|
46
|
-
if (typeof obj != 'object') return false;
|
|
47
|
-
if (Object.keys(obj).length == 0) return false;
|
|
48
|
-
if (Object.getOwnPropertyNames(obj).length == 0) return false;
|
|
49
|
-
const rv = true;
|
|
50
|
-
return rv;
|
|
51
|
-
};
|
|
52
|
-
const is_string_valid = (str, minLength = null, maxLength = null)=>{
|
|
53
|
-
if (str == null) return false;
|
|
54
|
-
if (typeof str != 'string') return false;
|
|
55
|
-
if (str.length == 0) return false;
|
|
56
|
-
let rv = true;
|
|
57
|
-
if (minLength && minLength > 0 && isNaN(minLength) == false) {
|
|
58
|
-
rv = rv && str.length >= minLength;
|
|
59
|
-
}
|
|
60
|
-
if (rv == false) return false;
|
|
61
|
-
if (maxLength && maxLength > 0 && isNaN(maxLength) == false) {
|
|
62
|
-
rv = rv && str.length <= maxLength;
|
|
63
|
-
}
|
|
64
|
-
return rv;
|
|
65
|
-
};
|
|
66
|
-
const is_object_id = (value)=>{
|
|
67
|
-
///!* input check - if value is invalid - return false *!/
|
|
68
|
-
if (false == is_string_valid(value, 1, 24)) return false;
|
|
69
|
-
///!* set the regex *!/
|
|
70
|
-
const regex = /^[0-9a-fA-F]{24}$/;
|
|
71
|
-
//!* get the match *!/
|
|
72
|
-
const matches = regex.exec(value);
|
|
73
|
-
//!* check is null *!/
|
|
74
|
-
const rv = matches != null && is_array_valid(matches);
|
|
75
|
-
return rv;
|
|
76
|
-
};
|