@vroskus/library-helpers 1.0.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/dist/browser.js +101 -0
- package/dist/index.js +2 -0
- package/dist/node.js +25 -0
- package/package.json +48 -0
package/dist/browser.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.scrollItem = exports.scrollTop = exports.getUrlGetParams = exports.animationClass = exports.numberValue = exports.cleanFormValues = void 0;
|
|
21
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
22
|
+
const query_string_1 = __importDefault(require("query-string"));
|
|
23
|
+
const react_animations_1 = require("react-animations");
|
|
24
|
+
const aphrodite_1 = require("aphrodite");
|
|
25
|
+
__exportStar(require("./common"), exports);
|
|
26
|
+
const isEmptyString = (value) => {
|
|
27
|
+
if (typeof value === 'string' && value.trim().length === 0) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
};
|
|
32
|
+
const cleanFormValues = (data) => {
|
|
33
|
+
const withoutHiddenItemsData = lodash_1.default.omitBy(data, (value, key) => lodash_1.default.startsWith(key, '_'));
|
|
34
|
+
const cleanData = lodash_1.default.mapValues(withoutHiddenItemsData, (value) => (value === '' || isEmptyString(value) ? null : value));
|
|
35
|
+
return cleanData;
|
|
36
|
+
};
|
|
37
|
+
exports.cleanFormValues = cleanFormValues;
|
|
38
|
+
const numberValue = (input) => (input === '' ? 0 : input);
|
|
39
|
+
exports.numberValue = numberValue;
|
|
40
|
+
const animationClass = (name) => {
|
|
41
|
+
const animations = {
|
|
42
|
+
fadeIn: react_animations_1.fadeIn,
|
|
43
|
+
fadeInDown: react_animations_1.fadeInDown,
|
|
44
|
+
fadeInUp: react_animations_1.fadeInUp,
|
|
45
|
+
};
|
|
46
|
+
const style = aphrodite_1.StyleSheet.create({
|
|
47
|
+
animation: {
|
|
48
|
+
animationDuration: '1s',
|
|
49
|
+
animationName: animations[name],
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return (0, aphrodite_1.css)(style.animation);
|
|
53
|
+
};
|
|
54
|
+
exports.animationClass = animationClass;
|
|
55
|
+
const getUrlGetParams = (input) => {
|
|
56
|
+
const parsedData = query_string_1.default.parse(input);
|
|
57
|
+
const output = {};
|
|
58
|
+
lodash_1.default.forEach(parsedData, (value, key) => {
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
output[key] = value.join(';');
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
output[key] = value;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return output;
|
|
67
|
+
};
|
|
68
|
+
exports.getUrlGetParams = getUrlGetParams;
|
|
69
|
+
const getScrollTopValue = (elementId, offset) => {
|
|
70
|
+
let value = 0;
|
|
71
|
+
if (document && elementId) {
|
|
72
|
+
const element = document.getElementById(elementId);
|
|
73
|
+
if (element) {
|
|
74
|
+
value = element.offsetTop - (offset || 15);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
};
|
|
79
|
+
const scrollTop = (elementId, offset) => {
|
|
80
|
+
if (window && window.scrollTo) {
|
|
81
|
+
window.scrollTo({
|
|
82
|
+
behavior: 'smooth',
|
|
83
|
+
top: getScrollTopValue(elementId, offset),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.scrollTop = scrollTop;
|
|
88
|
+
const scrollItem = (itemId, elementId, offset) => {
|
|
89
|
+
if (document) {
|
|
90
|
+
const item = document.getElementById(itemId);
|
|
91
|
+
const element = document.getElementById(elementId);
|
|
92
|
+
if (item && element) {
|
|
93
|
+
item.scroll({
|
|
94
|
+
behavior: 'smooth',
|
|
95
|
+
top: element.offsetTop + (offset || -50),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.scrollItem = scrollItem;
|
|
101
|
+
//# sourceMappingURL=browser.js.map
|
package/dist/index.js
ADDED
package/dist/node.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.generateHash = void 0;
|
|
21
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
22
|
+
__exportStar(require("./common"), exports);
|
|
23
|
+
const generateHash = (v) => crypto_1.default.createHash('md5').update(v).digest('hex');
|
|
24
|
+
exports.generateHash = generateHash;
|
|
25
|
+
//# sourceMappingURL=node.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vroskus/library-helpers",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Utility helpers",
|
|
5
|
+
"author": "Vilius Roškus <info@regattas.eu>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/vroskus/library-helpers.git"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/browser.js",
|
|
14
|
+
"dist/index.js",
|
|
15
|
+
"dist/node.js"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"postinstall": "npm run build",
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"test": "npm run test:eslint && npm run test:e2e",
|
|
21
|
+
"test:eslint": "eslint src --fix",
|
|
22
|
+
"test:e2e": "echo 'No tests'"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"aigle": "1.14.1",
|
|
26
|
+
"aphrodite": "2.4.0",
|
|
27
|
+
"express": "4.18.2",
|
|
28
|
+
"lodash": "4.17.21",
|
|
29
|
+
"query-string": "8.1.0",
|
|
30
|
+
"react-animations": "1.0.0",
|
|
31
|
+
"short-hash": "1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/jest": "29.5.0",
|
|
35
|
+
"@types/node": "18.15.11",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "5.53.0",
|
|
37
|
+
"@typescript-eslint/parser": "5.53.0",
|
|
38
|
+
"eslint": "8.34.0",
|
|
39
|
+
"eslint-config-airbnb-base": "15.0.0",
|
|
40
|
+
"eslint-config-airbnb-typescript": "17.0.0",
|
|
41
|
+
"eslint-plugin-import": "2.27.5",
|
|
42
|
+
"eslint-plugin-import-newlines": "1.3.1",
|
|
43
|
+
"eslint-plugin-react": "7.32.2",
|
|
44
|
+
"eslint-plugin-sort": "2.4.0",
|
|
45
|
+
"npm-check": "6.0.1",
|
|
46
|
+
"typescript": "4.9.5"
|
|
47
|
+
}
|
|
48
|
+
}
|