glib-web 5.0.4 → 5.0.5

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.
@@ -3,7 +3,10 @@
3
3
  import countries from "moment-timezone/data/meta/latest.json";
4
4
  import Action from "../../action";
5
5
  import http from "../../utils/http";
6
- import merge from 'lodash.merge';
6
+ import * as mergeModule from 'lodash.merge';
7
+ import { interopDefault } from "../../utils/interop.js";
8
+
9
+ const merge = interopDefault(mergeModule);
7
10
 
8
11
  export default class {
9
12
  async execute(spec, component) {
@@ -1,4 +1,7 @@
1
- import Push from "push.js";
1
+ import * as PushModule from "push.js";
2
+ import { interopDefault } from "../../utils/interop.js";
3
+
4
+ const Push = interopDefault(PushModule);
2
5
 
3
6
  export default class {
4
7
  execute(properties, component) {
@@ -1,9 +1,12 @@
1
- import jsonLogic from 'json-logic-js';
1
+ import * as jsonLogicModule from 'json-logic-js';
2
+ import { interopDefault } from "../../utils/interop.js";
2
3
  // Method "closest" return nothing, so use getAllFormData instead
3
4
  // One page can consist of many forms
4
5
  // so please use carefully
5
6
  import { getAllFormData } from "../../components/composable/form";
6
7
 
8
+ const jsonLogic = interopDefault(jsonLogicModule);
9
+
7
10
  export default class {
8
11
  execute(spec, component) {
9
12
  let condition = spec.condition;
@@ -1,10 +1,14 @@
1
- import jsonLogic from 'json-logic-js';
2
- import merge from 'lodash.merge';
1
+ import * as jsonLogicModule from 'json-logic-js';
2
+ import * as mergeModule from 'lodash.merge';
3
3
  import { nextTick } from "vue";
4
4
  import { sanitize } from "../../components/composable/date";
5
5
  import { isPresent } from "../../utils/type";
6
+ import { interopDefault } from "../../utils/interop.js";
6
7
  import { getFormData as _getFormData } from "../../components/composable/form";
7
8
 
9
+ const jsonLogic = interopDefault(jsonLogicModule);
10
+ const merge = interopDefault(mergeModule);
11
+
8
12
  const sumDate = function (a, b) {
9
13
  const date = new Date(a);
10
14
  const tzoffset = date.getTimezoneOffset() * 60000;
@@ -1,5 +1,8 @@
1
- import moment from "moment-timezone";
1
+ import * as momentModule from "moment-timezone";
2
2
  import { isString } from "../../utils/type";
3
+ import { interopDefault } from "../../utils/interop.js";
4
+
5
+ const moment = interopDefault(momentModule);
3
6
 
4
7
  export function sanitize(val, type, timeZone) {
5
8
  if (!val) return;
@@ -3,8 +3,11 @@
3
3
  </template>
4
4
 
5
5
  <script>
6
- import moment from "moment";
6
+ import * as momentModule from "moment";
7
7
  import GlibBase from "./base/glibBase.js";
8
+ import { interopDefault } from "../utils/interop.js";
9
+
10
+ const moment = interopDefault(momentModule);
8
11
 
9
12
  export default {
10
13
  extends: GlibBase,
@@ -26,8 +26,11 @@
26
26
 
27
27
  <script>
28
28
  import GlibBase from "../../base/glibBase.js";
29
- import PhoneNumber from "awesome-phonenumber";
29
+ import * as PhoneNumberModule from "awesome-phonenumber";
30
30
  import allCountries from "./countries";
31
+ import { interopDefault } from "../../../utils/interop.js";
32
+
33
+ const PhoneNumber = interopDefault(PhoneNumberModule);
31
34
 
32
35
  function getCountryByIp() {
33
36
  return fetch("https://ip2c.org/s")
@@ -2,8 +2,12 @@ import Hash from "../../utils/hash";
2
2
  import { determineColor } from "../../utils/constant";
3
3
  import { triggerOnChange } from "../composable/form";
4
4
  import { realComponent } from "../helper";
5
- import set from "lodash.set";
6
- import merge from "lodash.merge";
5
+ import * as setModule from "lodash.set";
6
+ import * as mergeModule from "lodash.merge";
7
+ import { interopDefault } from "../../utils/interop.js";
8
+
9
+ const set = interopDefault(setModule);
10
+ const merge = interopDefault(mergeModule);
7
11
  const NUMBER_PRECISION = 2;
8
12
  const isNeedToBeFixed = (val, component) => {
9
13
  return component.type == 'number' && !Number.isInteger(val) && Number.isFinite(val);
@@ -70,9 +70,12 @@ export default {
70
70
  import { computed, getCurrentInstance, onMounted, reactive, ref, watch } from "vue";
71
71
  import Action from "../../action";
72
72
  import Hash from "../../utils/hash";
73
- import Papa from "papaparse";
73
+ import * as PapaModule from "papaparse";
74
74
  import launch from "../../utils/launch";
75
75
  import { isPresent } from "../../utils/type";
76
+ import { interopDefault } from "../../utils/interop.js";
77
+
78
+ const Papa = interopDefault(PapaModule);
76
79
 
77
80
  class Row {
78
81
  constructor({ id, columns, selected, index, status }) {
@@ -14,7 +14,7 @@
14
14
  -->
15
15
  <!-- <component ref="ccomp" :is="template" v-if="customData" :name="spec.template" :spec="customData" /> -->
16
16
 
17
- <component :is="template" :name="spec.template" :spec="contentSpec" />
17
+ <component :is="template" :compName="spec.template" :spec="contentSpec" />
18
18
 
19
19
  </div>
20
20
  </template>
@@ -46,6 +46,7 @@ export default {
46
46
  busCloseHandler: null,
47
47
  onAppClick: null,
48
48
  onResize: null,
49
+ dialogClickEl: null,
49
50
  body: null,
50
51
  };
51
52
  },
@@ -59,29 +60,63 @@ export default {
59
60
  },
60
61
  mounted() {
61
62
  popovers.value.push(this);
62
- this.busOpenHandler = (body) => {
63
- this.body = body;
64
- this.key = strandom();
65
- };
66
- bus.$on(`popovers/open-${this.spec.key}`, this.busOpenHandler);
63
+ this.registerBusOpen();
64
+ this.handleMounted();
67
65
  },
68
66
  methods: {
69
- $mounted() {
70
- const appEl = document.getElementById(APP_ID);
67
+ registerBusOpen() {
68
+ this.busOpenHandler = (body) => {
69
+ this.body = body;
70
+ this.key = strandom();
71
+ };
72
+ bus.$on(`popovers/open-${this.spec.key}`, this.busOpenHandler);
73
+ },
74
+ registerBusClose(appEl) {
71
75
  this.busCloseHandler = () => {
72
76
  if (appEl) {
73
77
  appEl.removeEventListener("click", this.onAppClick);
74
78
  }
79
+ if (TypeUtils.isNotNull(this.dialogClickEl)) {
80
+ this.dialogClickEl.removeEventListener("click", this.onAppClick);
81
+ }
75
82
  this.close();
76
83
  };
77
84
  bus.$once(`popover/close-${this.spec.key}`, this.busCloseHandler);
85
+ },
86
+ registerOutsideListeners(appEl) {
87
+ this.onAppClick = this.handleClose;
88
+ if (appEl) {
89
+ appEl.addEventListener("click", this.onAppClick);
90
+ }
91
+ this.dialogClickEl = this.resolveDialogEl();
92
+ if (TypeUtils.isNotNull(this.dialogClickEl)) {
93
+ this.dialogClickEl.addEventListener("click", this.onAppClick);
94
+ }
95
+ this.onResize = () => this.close();
96
+ window.addEventListener("resize", this.onResize);
97
+ },
98
+ removeOutsideListeners(appEl) {
99
+ if (TypeUtils.isFunction(this.onAppClick) && appEl) {
100
+ appEl.removeEventListener("click", this.onAppClick);
101
+ }
102
+ if (TypeUtils.isFunction(this.onAppClick) && TypeUtils.isNotNull(this.dialogClickEl)) {
103
+ this.dialogClickEl.removeEventListener("click", this.onAppClick);
104
+ }
105
+ if (TypeUtils.isFunction(this.onResize)) {
106
+ window.removeEventListener("resize", this.onResize);
107
+ }
108
+ },
109
+ resolveDialogEl() {
110
+ if (TypeUtils.isNotNull(this.reference) && TypeUtils.isFunction(this.reference.closest)) {
111
+ return this.reference.closest(".v-dialog");
112
+ }
113
+ return null;
114
+ },
115
+ handleMounted() {
116
+ const appEl = document.getElementById(APP_ID);
117
+ this.registerBusClose(appEl);
78
118
  if (!this.spec.persistent) {
79
- this.onAppClick = this.handleClose;
80
- if (appEl) {
81
- appEl.addEventListener("click", this.onAppClick);
82
- }
83
- this.onResize = () => this.close();
84
- window.addEventListener("resize", this.onResize);
119
+ this.registerOutsideListeners(appEl);
85
120
  }
86
121
  if (this.spec.overlay) {
87
122
  this.driverObj.highlight({ element: this.reference });
@@ -96,12 +131,7 @@ export default {
96
131
  }
97
132
  if (!this.spec.persistent) {
98
133
  const appEl = document.getElementById(APP_ID);
99
- if (TypeUtils.isFunction(this.onAppClick) && appEl) {
100
- appEl.removeEventListener("click", this.onAppClick);
101
- }
102
- if (TypeUtils.isFunction(this.onResize)) {
103
- window.removeEventListener("resize", this.onResize);
104
- }
134
+ this.removeOutsideListeners(appEl);
105
135
  }
106
136
  },
107
137
  handleClose(event) {
@@ -14,7 +14,10 @@ import GlibBase from "./base/glibBase.js";
14
14
  import Action from "../action";
15
15
  import { Vue } from "..";
16
16
 
17
- import VueSocialSharing from "vue-social-sharing";
17
+ import * as VueSocialSharingModule from "vue-social-sharing";
18
+ import { interopDefault } from "../utils/interop.js";
19
+
20
+ const VueSocialSharing = interopDefault(VueSocialSharingModule);
18
21
  Vue.use(VueSocialSharing, { networks: { copy: "" } });
19
22
 
20
23
  export default {
@@ -34,8 +34,11 @@ import { defineComponent, ref } from "vue";
34
34
  import * as dropUploader from "./composable/upload";
35
35
  import * as delegateUploader from "./composable/upload_delegator";
36
36
  import { watch } from "vue";
37
- import merge from 'lodash.merge';
37
+ import * as mergeModule from 'lodash.merge';
38
38
  import { useFileUtils } from "./composable/file";
39
+ import { interopDefault } from "../utils/interop.js";
40
+
41
+ const merge = interopDefault(mergeModule);
39
42
  const { signedIds } = useFileUtils();
40
43
 
41
44
  export default defineComponent({
package/index.js CHANGED
@@ -8,7 +8,10 @@ import { jsonView, vueApp } from "./store";
8
8
  import './app.scss';
9
9
 
10
10
  // lib for deep merge
11
- import merge from 'lodash.merge';
11
+ import * as mergeModule from 'lodash.merge';
12
+ import { interopDefault } from "./utils/interop.js";
13
+
14
+ const merge = interopDefault(mergeModule);
12
15
 
13
16
  const APP_ID = 'app';
14
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "glib-web",
4
- "version": "5.0.4",
4
+ "version": "5.0.5",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -1,12 +1,12 @@
1
1
  <template>
2
- <div>Unsupported template: {{ name }}</div>
2
+ <div>Unsupported template: {{ compName }}</div>
3
3
  </template>
4
4
 
5
5
  <script>
6
6
  export default {
7
7
  props: {
8
8
  spec: { type: Object, required: true },
9
- name: { type: String, required: true }
9
+ compName: { type: String, required: true }
10
10
  }
11
11
  };
12
12
  </script>
package/utils/eventBus.js CHANGED
@@ -1,5 +1,8 @@
1
1
  // eventBus.js
2
- import EventEmitter2 from "eventemitter2";
2
+ import * as EventEmitter2Module from "eventemitter2";
3
+ import { interopDefaultOr } from "./interop.js";
4
+
5
+ const EventEmitter2 = interopDefaultOr(EventEmitter2Module, "EventEmitter2");
3
6
 
4
7
  const emitter = new EventEmitter2({ delimiter: '-', maxListeners: 0 });
5
8
 
package/utils/hash.js CHANGED
@@ -1,4 +1,7 @@
1
- import merge from 'lodash.merge';
1
+ import * as mergeModule from 'lodash.merge';
2
+ import { interopDefault } from "./interop.js";
3
+
4
+ const merge = interopDefault(mergeModule);
2
5
  export default class Hash {
3
6
  constructor(object) {
4
7
  if (object) {
@@ -0,0 +1,9 @@
1
+ export function interopDefault(moduleRef) {
2
+ return moduleRef && moduleRef.default ? moduleRef.default : moduleRef;
3
+ }
4
+
5
+ export function interopDefaultOr(moduleRef, namedExport) {
6
+ if (moduleRef && moduleRef.default) return moduleRef.default;
7
+ if (moduleRef && moduleRef[namedExport]) return moduleRef[namedExport];
8
+ return moduleRef;
9
+ }