aloha-vue 1.2.73 → 1.2.75

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.
@@ -0,0 +1,20 @@
1
+ const path = require("path");
2
+
3
+ module.exports = {
4
+ presets: [
5
+ ["@babel/env"]
6
+ ],
7
+ env: {
8
+ test: {
9
+ presets: [["@babel/env"]]
10
+ }
11
+ },
12
+ plugins: [
13
+ ["module-resolver", {
14
+ root: ["./src"],
15
+ alias: {
16
+ "@": path.resolve(__dirname, "./src")
17
+ }
18
+ }]
19
+ ]
20
+ };
@@ -1,6 +1,7 @@
1
1
  import AModal from "../../../../src/AModal/AModal";
2
2
 
3
3
  import AConfirmAPI from "../../../../src/compositionAPI/AConfirmAPI";
4
+ import EventBus from "../../../../src/utils/EventBus";
4
5
 
5
6
  export default {
6
7
  name: "PageConfirm",
@@ -30,8 +31,22 @@ export default {
30
31
  });
31
32
  };
32
33
 
34
+ const openConfirmWithTimeout = () => {
35
+ openConfirm({
36
+ headerText: "Aloha",
37
+ bodyHtml: "<div>Aloha <strong>Hola</strong></div>",
38
+ save: save,
39
+ selectorClose: "#btn_confirm_timeout",
40
+ });
41
+
42
+ setTimeout(() => {
43
+ EventBus.$emit("closeModalConfirm");
44
+ }, 5000);
45
+ };
46
+
33
47
  return {
34
48
  openConfirmLocal,
49
+ openConfirmWithTimeout,
35
50
  };
36
51
  },
37
52
  };
@@ -5,3 +5,10 @@ div
5
5
  type="button"
6
6
  @click="openConfirmLocal"
7
7
  ) Open confirm
8
+
9
+ button.a_btn.a_btn_primary(
10
+ id="btn_confirm_timeout"
11
+ type="button"
12
+ @click="openConfirmWithTimeout"
13
+ ) Open confirm with timeout
14
+
@@ -34,16 +34,6 @@ function resolveAlias(mode) {
34
34
  function getRules(mode) {
35
35
  const TARGET = process.env.npm_lifecycle_event;
36
36
  const RULES = [
37
- {
38
- test: /\.m?js?json/,
39
- type: "javascript/auto",
40
- },
41
- {
42
- test: /\.m?js/,
43
- resolve: {
44
- fullySpecified: false,
45
- },
46
- },
47
37
  // {
48
38
  // test: /\.js$/,
49
39
  // enforce: "pre",
package/jest.config.js ADDED
@@ -0,0 +1,16 @@
1
+ // For a detailed explanation regarding each configuration property, visit:
2
+ // https://jestjs.io/docs/en/configuration.html
3
+
4
+ module.exports = {
5
+ coverageDirectory: "coverage",
6
+ moduleNameMapper: {
7
+ "@/(.*)$": "<rootDir>/src/$1"
8
+ },
9
+ testEnvironment: "node",
10
+ transform: {
11
+ "^.+\\.jsx?$": "babel-jest"
12
+ },
13
+ transformIgnorePatterns: [
14
+ "<rootDir>/node_modules/(?!lodash-es)"
15
+ ],
16
+ };
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "Vue.js"
15
15
  ],
16
16
  "homepage": "https://github.com/ilia-brykin/aloha/#README.md",
17
- "version": "1.2.73",
17
+ "version": "1.2.75",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "scripts": {
40
40
  "build-icons": "node scriptsNode/iconsSvgToJs.js bootstrap3 && node scriptsNode/iconsSvgToJs.js bootstrap-1-9-1",
41
- "test": "node --trace-warnings --experimental-vm-modules node_modules/jest/bin/jest.js"
41
+ "test": "jest"
42
42
  },
43
43
  "dependencies": {
44
44
  "@floating-ui/vue": "1.0.2",
@@ -55,10 +55,12 @@
55
55
  "@vue/test-utils": "^2.4.3",
56
56
  "eslint-plugin-jest": "^27.6.1",
57
57
  "jest": "^29.7.0",
58
- "lodash": "^4.17.21"
59
- },
60
- "jest": {
61
- "transform": {}
62
- },
63
- "type": "module"
58
+ "lodash": "^4.17.21",
59
+ "@babel/cli": "^7.23.4",
60
+ "@babel/core": "^7.23.7",
61
+ "@babel/preset-env": "^7.23.8",
62
+ "babel-core": "^7.0.0-bridge.0",
63
+ "babel-jest": "29.7.0",
64
+ "babel-plugin-module-resolver": "5.0.0"
65
+ }
64
66
  }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  h,
3
+ onBeforeUnmount,
3
4
  onMounted,
4
5
  onUnmounted,
5
6
  Teleport,
@@ -10,6 +11,7 @@ import {
10
11
  import AButton from "../AButton/AButton";
11
12
  import ATranslation from "../ATranslation/ATranslation";
12
13
 
14
+ import CloseFromOutsideAPI from "./compositionAPI/CloseFromOutsideAPI";
13
15
  import DisabledAPI from "./compositionAPI/DisabledAPI";
14
16
  import EscapeAPI from "./compositionAPI/EscapeAPI";
15
17
  import FocusAPI from "./compositionAPI/FocusAPI";
@@ -167,6 +169,11 @@ export default {
167
169
  setup(props) {
168
170
  const isModalHidden = toRef(props, "isModalHidden");
169
171
 
172
+ const {
173
+ destroyEventBusCloseFromOutside,
174
+ initEventBusCloseFromOutside,
175
+ } = CloseFromOutsideAPI(props);
176
+
170
177
  const {
171
178
  sizeClass,
172
179
  } = SizeAPI(props);
@@ -220,10 +227,16 @@ export default {
220
227
  }
221
228
  });
222
229
 
230
+ initEventBusCloseFromOutside();
231
+
223
232
  onMounted(() => {
224
233
  showModal();
225
234
  });
226
235
 
236
+ onBeforeUnmount(() => {
237
+ destroyEventBusCloseFromOutside();
238
+ });
239
+
227
240
  onUnmounted(() => {
228
241
  hideModal();
229
242
  });
@@ -236,8 +249,6 @@ export default {
236
249
  sizeClass,
237
250
  };
238
251
  },
239
- computed: {
240
- },
241
252
  render() {
242
253
  return h(Teleport, {
243
254
  to: "body",
@@ -0,0 +1,29 @@
1
+ import {
2
+ toRef,
3
+ } from "vue";
4
+
5
+ import EventBus from "../../utils/EventBus";
6
+
7
+ export default function CloseFromOutsideAPI(props) {
8
+ const close = toRef(props, "close");
9
+ const isConfirm = toRef(props, "isConfirm");
10
+
11
+ const closeModalFromOutside = () => {
12
+ if (!isConfirm.value) {
13
+ close.value();
14
+ }
15
+ };
16
+
17
+ const initEventBusCloseFromOutside = () => {
18
+ EventBus.$on("closeModal", closeModalFromOutside);
19
+ };
20
+
21
+ const destroyEventBusCloseFromOutside = () => {
22
+ EventBus.$off("closeModal", closeModalFromOutside);
23
+ };
24
+
25
+ return {
26
+ destroyEventBusCloseFromOutside,
27
+ initEventBusCloseFromOutside,
28
+ };
29
+ }
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  computed,
3
- h,
3
+ h, onBeforeUnmount,
4
4
  } from "vue";
5
5
 
6
6
  import AModal from "../AModal/AModal";
7
7
 
8
8
  import AConfirmAPI from "../compositionAPI/AConfirmAPI";
9
+ import CloseFromOutsideAPI from "./compositionAPI/CloseFromOutsideAPI";
9
10
 
10
11
  // @vue/component
11
12
  export default {
@@ -17,6 +18,13 @@ export default {
17
18
  isModalHidden,
18
19
  } = AConfirmAPI();
19
20
 
21
+ const {
22
+ destroyEventBusCloseFromOutside,
23
+ initEventBusCloseFromOutside,
24
+ } = CloseFromOutsideAPI({
25
+ isModalHidden,
26
+ });
27
+
20
28
  const modalProps = computed(() => {
21
29
  return {
22
30
  isModalHidden: isModalHidden.value,
@@ -26,6 +34,12 @@ export default {
26
34
  };
27
35
  });
28
36
 
37
+ initEventBusCloseFromOutside();
38
+
39
+ onBeforeUnmount(() => {
40
+ destroyEventBusCloseFromOutside();
41
+ });
42
+
29
43
  return {
30
44
  modalProps,
31
45
  };
@@ -0,0 +1,26 @@
1
+ import {
2
+ ref,
3
+ } from "vue";
4
+
5
+ import EventBus from "../../utils/EventBus";
6
+
7
+ export default function CloseFromOutsideAPI({
8
+ isModalHidden = ref(false),
9
+ }) {
10
+ const closeModalFromOutside = () => {
11
+ isModalHidden.value = true;
12
+ };
13
+
14
+ const initEventBusCloseFromOutside = () => {
15
+ EventBus.$on("closeModalConfirm", closeModalFromOutside);
16
+ };
17
+
18
+ const destroyEventBusCloseFromOutside = () => {
19
+ EventBus.$off("closeModalConfirm", closeModalFromOutside);
20
+ };
21
+
22
+ return {
23
+ destroyEventBusCloseFromOutside,
24
+ initEventBusCloseFromOutside,
25
+ };
26
+ }