@mapomodule/utils 1.0.0-alpha.10 → 1.0.0-alpha.22
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/CHANGELOG.md +33 -0
- package/helpers/formatters.js +27 -2
- package/helpers/objHelpers.js +2 -2
- package/helpers/slots.js +9 -0
- package/index.js +3 -1
- package/package.json +2 -2
- package/plugins/v-draggable-modals.js +39 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.22](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2022-05-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* big code refactor and improovements to fields management ([a818d8b](https://github.com/lotrekagency/mapo/commit/a818d8b891dbb4892f50267d6355c41297e2c6c6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.0.0-alpha.15](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* enhance findPropPaths to deal also with arrays indexes ([158a9aa](https://github.com/lotrekagency/mapo/commit/158a9aa9329defbecbb39e1f19df2855dd3ece01))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [1.0.0-alpha.13](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2022-03-01)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* make all modals draggable 🛸 ([57da10d](https://github.com/lotrekagency/mapo/commit/57da10d17aa31d58e55fda5385d45d43beed8c4f))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
# [1.0.0-alpha.10](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2022-02-11)
|
|
7
40
|
|
|
8
41
|
|
package/helpers/formatters.js
CHANGED
|
@@ -20,8 +20,33 @@ function humanFileSize(bytes, si = false, dp = 1) {
|
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
return bytes.toFixed(dp) + " " + units[u];
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function slugify(str) {
|
|
26
|
+
str = str || "";
|
|
27
|
+
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
|
28
|
+
str = str.toLowerCase();
|
|
29
|
+
|
|
30
|
+
// remove accents, swap ñ for n, etc
|
|
31
|
+
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
|
|
32
|
+
var to = "aaaaeeeeiiiioooouuuunc------";
|
|
33
|
+
for (var i = 0, l = from.length; i < l; i++) {
|
|
34
|
+
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
|
|
38
|
+
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
|
39
|
+
.replace(/-+/g, '-'); // collapse dashes
|
|
40
|
+
|
|
41
|
+
return str;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function titleCase(string) {
|
|
45
|
+
return (string && string[0].toUpperCase() + string.slice(1).toLowerCase()) || "";
|
|
46
|
+
};
|
|
24
47
|
|
|
25
48
|
module.exports = {
|
|
26
|
-
humanFileSize
|
|
49
|
+
humanFileSize,
|
|
50
|
+
slugify,
|
|
51
|
+
titleCase,
|
|
27
52
|
}
|
package/helpers/objHelpers.js
CHANGED
|
@@ -63,14 +63,14 @@ function findPropPaths(obj, predicate) {
|
|
|
63
63
|
throw new TypeError("Predicate is not a function");
|
|
64
64
|
}
|
|
65
65
|
(function find(obj) {
|
|
66
|
-
for (const key
|
|
66
|
+
for (const key in obj) {
|
|
67
67
|
if (predicate({ val: obj[key], obj, path, key }) === true) {
|
|
68
68
|
path.push(key);
|
|
69
69
|
results.push(path.join("."));
|
|
70
70
|
path.pop();
|
|
71
71
|
}
|
|
72
72
|
const o = obj[key];
|
|
73
|
-
if (o && typeof o === "object"
|
|
73
|
+
if (o && typeof o === "object") {
|
|
74
74
|
if (!discoveredObjects.find(obj => obj === o)) {
|
|
75
75
|
path.push(key);
|
|
76
76
|
discoveredObjects.push(o);
|
package/helpers/slots.js
ADDED
package/index.js
CHANGED
|
@@ -2,10 +2,12 @@ const auth = require('./helpers/auth');
|
|
|
2
2
|
const debounce = require('./helpers/debounce');
|
|
3
3
|
const formatters = require('./helpers/formatters');
|
|
4
4
|
const objHelpers = require('./helpers/objHelpers');
|
|
5
|
+
const VDraggableModals = require('./plugins/v-draggable-modals');
|
|
5
6
|
|
|
6
7
|
module.exports = {
|
|
7
8
|
auth,
|
|
8
9
|
debounce,
|
|
9
10
|
formatters,
|
|
10
|
-
objHelpers
|
|
11
|
+
objHelpers,
|
|
12
|
+
VDraggableModals,
|
|
11
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/utils",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "This is part of Mapo nuxt module. Provides a set of utils for the project.",
|
|
6
6
|
"author": "bnznamco <gabriele.baldi.01@gmail.com>",
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "49f5a6c1ed148cfdaf80a6b610ffc4233aa177cb"
|
|
16
16
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module.exports = function () {
|
|
2
|
+
const d = {};
|
|
3
|
+
document.addEventListener("mousedown", e => {
|
|
4
|
+
const closestDialog = e.target.closest(".v-dialog.v-dialog--active");
|
|
5
|
+
if (e.button === 0 && closestDialog != null && e.target.classList.contains("v-card__title")) {
|
|
6
|
+
d.el = closestDialog;
|
|
7
|
+
d.mouseStartX = e.clientX;
|
|
8
|
+
d.mouseStartY = e.clientY;
|
|
9
|
+
d.elStartX = d.el.getBoundingClientRect().left;
|
|
10
|
+
d.elStartY = d.el.getBoundingClientRect().top;
|
|
11
|
+
d.el.style.position = "fixed";
|
|
12
|
+
d.el.style.margin = 0;
|
|
13
|
+
d.oldTransition = d.el.style.transition;
|
|
14
|
+
d.el.style.transition = "none"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
document.addEventListener("mousemove", e => {
|
|
18
|
+
if (d.el === undefined) return;
|
|
19
|
+
d.el.style.left = Math.min(
|
|
20
|
+
Math.max(d.elStartX + e.clientX - d.mouseStartX, 0),
|
|
21
|
+
window.innerWidth - d.el.getBoundingClientRect().width
|
|
22
|
+
) + "px";
|
|
23
|
+
d.el.style.top = Math.min(
|
|
24
|
+
Math.max(d.elStartY + e.clientY - d.mouseStartY, 0),
|
|
25
|
+
window.innerHeight - d.el.getBoundingClientRect().height
|
|
26
|
+
) + "px";
|
|
27
|
+
});
|
|
28
|
+
document.addEventListener("mouseup", () => {
|
|
29
|
+
if (d.el === undefined) return;
|
|
30
|
+
d.el.style.transition = d.oldTransition;
|
|
31
|
+
d.el = undefined
|
|
32
|
+
});
|
|
33
|
+
setInterval(() => {
|
|
34
|
+
const dialog = document.querySelector(".v-dialog.v-dialog--active");
|
|
35
|
+
if (dialog === null) return;
|
|
36
|
+
dialog.style.left = Math.min(parseInt(dialog.style.left), window.innerWidth - dialog.getBoundingClientRect().width) + "px";
|
|
37
|
+
dialog.style.top = Math.min(parseInt(dialog.style.top), window.innerHeight - dialog.getBoundingClientRect().height) + "px";
|
|
38
|
+
}, 100);
|
|
39
|
+
}
|