aloha-vue 1.0.13 → 1.0.14
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/docs/package.json +1 -1
- package/docs/src/App/App.js +2 -0
- package/docs/src/App/App.pug +2 -1
- package/docs/src/components/TheMenu/TheMenu.js +5 -0
- package/docs/src/router/index.js +5 -0
- package/docs/src/views/PageConfirm/PageConfirm.js +0 -1
- package/docs/src/views/PageNotification/PageNotification.js +34 -0
- package/docs/src/views/PageNotification/PageNotification.pug +9 -0
- package/docs/src/views/PageNotification/PageNotification.vue +2 -0
- package/package.json +1 -1
- package/src/AModal/AModal.js +16 -6
- package/src/ANotification/ANotification.js +46 -0
- package/src/compositionAPI/ANotificationAPI.js +51 -0
package/docs/package.json
CHANGED
package/docs/src/App/App.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AModalConfirm from "../../../src/AModalConfirm/AModalConfirm";
|
|
2
|
+
import ANotification from "../../../src/ANotification/ANotification";
|
|
2
3
|
import TheMenu from "../components/TheMenu/TheMenu.vue";
|
|
3
4
|
import TheNavbar from "../components/TheNavbar/TheNavbar.vue";
|
|
4
5
|
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
export default defineComponent({
|
|
11
12
|
components: {
|
|
12
13
|
AModalConfirm,
|
|
14
|
+
ANotification,
|
|
13
15
|
TheMenu,
|
|
14
16
|
TheNavbar,
|
|
15
17
|
},
|
package/docs/src/App/App.pug
CHANGED
package/docs/src/router/index.js
CHANGED
|
@@ -69,6 +69,11 @@ const ROUTES = [
|
|
|
69
69
|
name: "PageConfirm",
|
|
70
70
|
component: () => import(/* webpackChunkName: "PageConfirm" */ "../views/PageConfirm/PageConfirm.vue"),
|
|
71
71
|
},
|
|
72
|
+
{
|
|
73
|
+
path: "/notification",
|
|
74
|
+
name: "PageNotification",
|
|
75
|
+
component: () => import(/* webpackChunkName: "PageNotification" */ "../views/PageNotification/PageNotification.vue"),
|
|
76
|
+
},
|
|
72
77
|
{
|
|
73
78
|
// If the routing configuration '*' reports an error, replace it with '/: catchAll(. *)'
|
|
74
79
|
// caught Error: Catch all routes ("*") must now be defined using a param with a custom regexp
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import ANotificationAPI from "../../../../src/compositionAPI/ANotificationAPI";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: "PageNotification",
|
|
5
|
+
setup() {
|
|
6
|
+
const {
|
|
7
|
+
addNotification,
|
|
8
|
+
} = ANotificationAPI();
|
|
9
|
+
|
|
10
|
+
const addNotificationLocal = type => {
|
|
11
|
+
addNotification({
|
|
12
|
+
text: type,
|
|
13
|
+
type,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
addNotificationLocal,
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
types: [
|
|
24
|
+
"primary",
|
|
25
|
+
"secondary",
|
|
26
|
+
"success",
|
|
27
|
+
"danger",
|
|
28
|
+
"warning",
|
|
29
|
+
"info",
|
|
30
|
+
"dark",
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
};
|
package/package.json
CHANGED
package/src/AModal/AModal.js
CHANGED
|
@@ -168,8 +168,19 @@ export default {
|
|
|
168
168
|
return "";
|
|
169
169
|
},
|
|
170
170
|
},
|
|
171
|
+
watch: {
|
|
172
|
+
isModalHidden() {
|
|
173
|
+
if (this.isModalHidden) {
|
|
174
|
+
this.hideModal();
|
|
175
|
+
} else {
|
|
176
|
+
this.showModal();
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
},
|
|
171
180
|
mounted() {
|
|
172
|
-
this.
|
|
181
|
+
if (!this.isModalHidden) {
|
|
182
|
+
this.showModal();
|
|
183
|
+
}
|
|
173
184
|
},
|
|
174
185
|
unmounted() {
|
|
175
186
|
this.hideModal();
|
|
@@ -208,11 +219,7 @@ export default {
|
|
|
208
219
|
if (this.withoutEscape) {
|
|
209
220
|
return;
|
|
210
221
|
}
|
|
211
|
-
|
|
212
|
-
this.confirmOptions.cancelCallback();
|
|
213
|
-
} else {
|
|
214
|
-
this.onClose();
|
|
215
|
-
}
|
|
222
|
+
this.close();
|
|
216
223
|
},
|
|
217
224
|
|
|
218
225
|
trapFocus(EVENT) {
|
|
@@ -401,6 +408,9 @@ export default {
|
|
|
401
408
|
]),
|
|
402
409
|
]),
|
|
403
410
|
]),
|
|
411
|
+
!this.isModalHidden && h("div", {
|
|
412
|
+
class: "a_modal_backdrop a_modal_backdrop_show",
|
|
413
|
+
})
|
|
404
414
|
]);
|
|
405
415
|
},
|
|
406
416
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
h,
|
|
3
|
+
Teleport,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
import AAlert from "../AAlert/AAlert";
|
|
7
|
+
|
|
8
|
+
import ANotificationAPI from "../compositionAPI/ANotificationAPI";
|
|
9
|
+
|
|
10
|
+
// @vue/component
|
|
11
|
+
export default {
|
|
12
|
+
name: "ANotification",
|
|
13
|
+
setup() {
|
|
14
|
+
const {
|
|
15
|
+
notifications,
|
|
16
|
+
removeNotification,
|
|
17
|
+
} = ANotificationAPI();
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
notifications,
|
|
21
|
+
removeNotification,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
render() {
|
|
25
|
+
return h(Teleport, {
|
|
26
|
+
to: "body",
|
|
27
|
+
}, [
|
|
28
|
+
h("div", {
|
|
29
|
+
class: "a_notification_parent",
|
|
30
|
+
}, this.notifications.map(notification => {
|
|
31
|
+
return h(AAlert, {
|
|
32
|
+
key: notification.index,
|
|
33
|
+
isVisible: true,
|
|
34
|
+
isDismissible: true,
|
|
35
|
+
type: notification.type,
|
|
36
|
+
alertClass: "a_notification",
|
|
37
|
+
onOnDismiss: () => this.removeNotification(notification.index),
|
|
38
|
+
}, () => [
|
|
39
|
+
h("div", {
|
|
40
|
+
innerHTML: notification.text,
|
|
41
|
+
}),
|
|
42
|
+
]);
|
|
43
|
+
})),
|
|
44
|
+
]);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
ref,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
values,
|
|
8
|
+
} from "lodash-es";
|
|
9
|
+
|
|
10
|
+
let notificationTimeout = 5000;
|
|
11
|
+
const notificationsObj = ref({});
|
|
12
|
+
const notifications = computed(() => {
|
|
13
|
+
return values(notificationsObj.value);
|
|
14
|
+
});
|
|
15
|
+
let notificationsCount = 0;
|
|
16
|
+
|
|
17
|
+
export default function ANotificationAPI() {
|
|
18
|
+
const removeNotification = notificationIndex => {
|
|
19
|
+
if (notificationsObj.value[notificationIndex]) {
|
|
20
|
+
delete notificationsObj.value[notificationIndex];
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const addNotification = ({ text, type = "success", timeout }) => {
|
|
25
|
+
const TIMEOUT_LOCAL = timeout || notificationTimeout;
|
|
26
|
+
const CURRENT_INDEX = notificationsCount;
|
|
27
|
+
notificationsObj.value[CURRENT_INDEX] = {
|
|
28
|
+
text,
|
|
29
|
+
type,
|
|
30
|
+
index: CURRENT_INDEX,
|
|
31
|
+
};
|
|
32
|
+
notificationsCount++;
|
|
33
|
+
|
|
34
|
+
if (TIMEOUT_LOCAL) {
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
removeNotification(CURRENT_INDEX);
|
|
37
|
+
}, TIMEOUT_LOCAL);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const setNotificationTimeout = timeout => {
|
|
42
|
+
notificationTimeout = timeout;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
addNotification,
|
|
47
|
+
removeNotification,
|
|
48
|
+
notifications,
|
|
49
|
+
setNotificationTimeout,
|
|
50
|
+
};
|
|
51
|
+
}
|