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 CHANGED
@@ -11,7 +11,7 @@
11
11
  "build-css": "node-sass --include-path scss styles/styles.scss public/styles.css"
12
12
  },
13
13
  "dependencies": {
14
- "aloha-css": "1.0.11",
14
+ "aloha-css": "1.0.13",
15
15
  "lodash-es": "^4.17.21",
16
16
  "vue": "3.2.31",
17
17
  "vue-router": "4.0.14",
@@ -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
  },
@@ -9,4 +9,5 @@ div
9
9
  )
10
10
  router-view
11
11
 
12
- a-modal-confirm
12
+ a-modal-confirm
13
+ a-notification
@@ -58,6 +58,11 @@ export default {
58
58
  name: "PageConfirm",
59
59
  label: "Confirm",
60
60
  },
61
+ {
62
+ id: "notification",
63
+ name: "PageNotification",
64
+ label: "Notification",
65
+ },
61
66
  ],
62
67
  };
63
68
  },
@@ -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
@@ -14,7 +14,6 @@ export default {
14
14
  } = ConfirmAPI();
15
15
 
16
16
  const save = () => {
17
- console.log("Aloha");
18
17
  closeConfirm();
19
18
  };
20
19
 
@@ -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
+ };
@@ -0,0 +1,9 @@
1
+ div
2
+ h1 ANotification
3
+ button.a_btn.a_mr_2(
4
+ v-for="type in types"
5
+ :key="type"
6
+ :class="'a_btn_' + type"
7
+ type="button"
8
+ @click="addNotificationLocal(type)"
9
+ ) Add Notification {{ type }}
@@ -0,0 +1,2 @@
1
+ <template lang="pug" src="./PageNotification.pug"></template>
2
+ <script src="./PageNotification.js"></script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
3
  "description": "Project aloha",
4
- "version": "1.0.13",
4
+ "version": "1.0.14",
5
5
  "author": "Ilia Brykin",
6
6
  "dependencies": {
7
7
  "@popperjs/core": "2.11.5",
@@ -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.showModal();
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
- if (this.confirmOptions && isFunction(this.confirmOptions.cancelCallback)) {
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
+ }