glib-web 3.4.7 → 3.5.0

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.
Files changed (123) hide show
  1. package/LICENSE +0 -0
  2. package/action.js +6 -5
  3. package/actions/auth/creditCard.js +0 -0
  4. package/actions/auth/restart.js +0 -0
  5. package/actions/commands/copy.js +0 -0
  6. package/actions/dialogs/close.js +0 -0
  7. package/actions/dialogs/notification.js +0 -0
  8. package/actions/dialogs/oauth.js +0 -0
  9. package/actions/dialogs/open.js +0 -0
  10. package/actions/dialogs/options.js +0 -0
  11. package/actions/dialogs/reload.js +0 -0
  12. package/actions/dialogs/show.js +0 -0
  13. package/actions/http/delete.js +0 -0
  14. package/actions/http/patch.js +0 -0
  15. package/actions/http/post.js +0 -0
  16. package/actions/http/put.js +0 -0
  17. package/actions/runMultiple.js +0 -0
  18. package/actions/sheets/select.js +0 -0
  19. package/actions/snackbars/alert.js +0 -0
  20. package/actions/snackbars/select.js +0 -0
  21. package/actions/timeouts/set.js +0 -0
  22. package/actions/windows/close.js +4 -1
  23. package/actions/windows/closeAll.js +3 -1
  24. package/actions/windows/open.js +3 -0
  25. package/actions/windows/openWeb.js +0 -0
  26. package/actions/windows/print.js +0 -0
  27. package/actions/windows/reload.js +4 -0
  28. package/app.vue +5 -5
  29. package/components/_message.vue +0 -0
  30. package/components/calendar.vue +0 -0
  31. package/components/charts/area.vue +4 -4
  32. package/components/charts/column.vue +3 -4
  33. package/components/charts/line.vue +4 -4
  34. package/components/charts/pie.vue +3 -3
  35. package/components/charts/series.js +17 -9
  36. package/components/component.vue +30 -35
  37. package/components/composable/gmap.js +153 -0
  38. package/components/fab.vue +0 -0
  39. package/components/fields/country/countries.js +0 -0
  40. package/components/fields/country/regions.js +0 -0
  41. package/components/fields/creditCard.vue +0 -0
  42. package/components/fields/googlePlace.vue +0 -0
  43. package/components/fields/location.vue +86 -141
  44. package/components/fields/phone/countries.js +0 -0
  45. package/components/fields/phone/sprite.css +0 -0
  46. package/components/fields/richText.vue +19 -6
  47. package/components/fields/stripeToken.vue +0 -0
  48. package/components/fields/text.vue +9 -9
  49. package/components/fields/timer.vue +5 -6
  50. package/components/h1.vue +0 -0
  51. package/components/h2.vue +0 -0
  52. package/components/h3.vue +0 -0
  53. package/components/h5.vue +0 -0
  54. package/components/h6.vue +0 -0
  55. package/components/hr.vue +0 -0
  56. package/components/html.vue +0 -0
  57. package/components/icon.vue +0 -0
  58. package/components/label.vue +3 -3
  59. package/components/map.vue +57 -287
  60. package/components/mixins/chart/annotation.js +0 -0
  61. package/components/mixins/chart/tooltip.js +0 -0
  62. package/components/mixins/dataset.js +0 -0
  63. package/components/mixins/extension.js +0 -0
  64. package/components/mixins/longClick.js +0 -0
  65. package/components/mixins/scrolling.js +0 -0
  66. package/components/mixins/table/export.js +0 -0
  67. package/components/mixins/table/import.js +0 -0
  68. package/components/mixins/text.js +0 -0
  69. package/components/multimedia/video.vue +0 -0
  70. package/components/panels/carousel.vue +0 -0
  71. package/components/panels/list.vue +7 -21
  72. package/components/panels/web.vue +0 -0
  73. package/components/shareButton.vue +7 -2
  74. package/components/spacer.vue +0 -0
  75. package/index.js +4 -27
  76. package/keys.js +0 -0
  77. package/package.json +3 -3
  78. package/plugins/gmap.js +30 -0
  79. package/plugins/vuetify.js +8 -8
  80. package/static/plugins/alignment/alignment.js +0 -0
  81. package/static/plugins/alignment/alignment.min.js +0 -0
  82. package/static/plugins/beyondgrammar/beyondgrammar.js +0 -0
  83. package/static/plugins/beyondgrammar/beyondgrammar.min.js +0 -0
  84. package/static/plugins/blockcode/blockcode.js +0 -0
  85. package/static/plugins/blockcode/blockcode.min.js +0 -0
  86. package/static/plugins/clips/clips.js +0 -0
  87. package/static/plugins/clips/clips.min.js +0 -0
  88. package/static/plugins/counter/counter.js +0 -0
  89. package/static/plugins/counter/counter.min.js +0 -0
  90. package/static/plugins/definedlinks/definedlinks.js +0 -0
  91. package/static/plugins/definedlinks/definedlinks.min.js +0 -0
  92. package/static/plugins/handle/handle.js +0 -0
  93. package/static/plugins/handle/handle.min.js +0 -0
  94. package/static/plugins/icons/icons.js +0 -0
  95. package/static/plugins/icons/icons.min.js +0 -0
  96. package/static/plugins/imageposition/imageposition.js +0 -0
  97. package/static/plugins/imageposition/imageposition.min.js +0 -0
  98. package/static/plugins/inlineformat/inlineformat.js +0 -0
  99. package/static/plugins/inlineformat/inlineformat.min.js +0 -0
  100. package/static/plugins/removeformat/removeformat.js +0 -0
  101. package/static/plugins/removeformat/removeformat.min.js +0 -0
  102. package/static/plugins/selector/selector.js +0 -0
  103. package/static/plugins/selector/selector.min.js +0 -0
  104. package/static/plugins/specialchars/specialchars.js +0 -0
  105. package/static/plugins/specialchars/specialchars.min.js +0 -0
  106. package/static/plugins/textdirection/textdirection.js +0 -0
  107. package/static/plugins/textdirection/textdirection.min.js +0 -0
  108. package/static/plugins/textexpander/textexpander.js +0 -0
  109. package/static/plugins/textexpander/textexpander.min.js +0 -0
  110. package/static/plugins/underline/underline.js +0 -0
  111. package/static/plugins/underline/underline.min.js +0 -0
  112. package/static/redactorx.css +0 -0
  113. package/static/redactorx.min.css +0 -0
  114. package/static/redactorx.min.js +0 -0
  115. package/static/redactorx.usm.min.js +0 -0
  116. package/store.js +3 -2
  117. package/styles/test.sass +0 -0
  118. package/styles/test.scss +0 -0
  119. package/templates/unsupported.vue +0 -0
  120. package/utils/dom.js +0 -0
  121. package/utils/format.js +4 -4
  122. package/utils/helper.js +0 -0
  123. package/utils/type.js +0 -0
package/LICENSE CHANGED
File without changes
package/action.js CHANGED
@@ -53,13 +53,14 @@ import ActionsAnalyticsLogEvent from "./actions/analytics/logEvent";
53
53
  import ActionCommandsCopy from "./actions/commands/copy";
54
54
  import ActionCommandsCustom from "./actions/commands/custom";
55
55
 
56
- import ActionToursStart from "./actions/tours/start";
57
- import ActionToursStop from "./actions/tours/stop";
56
+ // TODO: handle promise action
57
+ const ActionToursStart = import("./actions/tours/start");
58
+ const ActionToursStop = import("./actions/tours/stop");
58
59
 
59
60
  import ActionComponentsUpdate from "./actions/components/update";
60
61
 
61
- import ActionPopoversOpen from "./actions/popovers/open"
62
- import ActionPopoversClose from "./actions/popovers/close"
62
+ import ActionPopoversOpen from "./actions/popovers/open";
63
+ import ActionPopoversClose from "./actions/popovers/close";
63
64
 
64
65
  import { vueApp } from "./store";
65
66
 
@@ -182,7 +183,7 @@ export default class Action {
182
183
  // TODO: The execution should be in the following order: onResponse, page render, onLoad
183
184
  if (response.header || response.body || response.footer) {
184
185
  Utils.http.forceComponentUpdate(() => {
185
- vueApp.page = response
186
+ vueApp.page = response;
186
187
  });
187
188
  }
188
189
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,11 +1,14 @@
1
+ import { vueApp } from "../../store";
2
+
1
3
  export default class {
2
4
  execute(properties, component) {
5
+ vueApp.richTextValues = {};
3
6
  Utils.history.back();
4
7
 
5
8
  Utils.type.ifObject(properties["onClose"], it => {
6
9
  // Allow time for history.back() to complete, which is important for actions that need
7
10
  // to use window.location.href such as windows/reload
8
- setTimeout(function() {
11
+ setTimeout(function () {
9
12
  GLib.action.execute(it, component);
10
13
  }, 100);
11
14
  });
@@ -1,14 +1,16 @@
1
+ import { vueApp } from "../../store";
1
2
  import Type from "../../utils/type";
2
3
 
3
4
  export default class {
4
5
  execute(properties, component) {
6
+ vueApp.richTextValues = {};
5
7
  // TODO
6
8
  // window.history.deleteAll()
7
9
 
8
10
  Type.ifObject(properties["onClose"], it => {
9
11
  // Allow time for history.back() to complete, which is important for actions that need
10
12
  // to use window.location.href such as windows/reload
11
- setTimeout(function() {
13
+ setTimeout(function () {
12
14
  GLib.action.execute(it, component);
13
15
  }, 100);
14
16
  });
@@ -1,5 +1,8 @@
1
+ import { vueApp } from "../../store";
2
+
1
3
  export default class {
2
4
  execute(properties, component) {
5
+ vueApp.richTextValues = {};
3
6
  Utils.http.load(properties, component);
4
7
  }
5
8
  }
File without changes
File without changes
@@ -1,5 +1,9 @@
1
+ import { vueApp } from "../../store";
2
+
1
3
  export default class {
2
4
  execute(properties, component) {
5
+ vueApp.richTextValues = {};
6
+
3
7
  if (Utils.settings.reactive) {
4
8
  Utils.http.reload(properties, component);
5
9
  } else {
package/app.vue CHANGED
@@ -29,8 +29,8 @@
29
29
  <script>
30
30
  import NavAppBar from "./nav/appbar.vue";
31
31
  import Utils from "./utils/helper";
32
- import phoenixSocketMixin from "./components/mixins/ws/phoenixSocket.js";
33
- import actionCableMixin from "./components/mixins/ws/actionCable.js";
32
+ // import phoenixSocketMixin from "./components/mixins/ws/phoenixSocket.js";
33
+ // import actionCableMixin from "./components/mixins/ws/actionCable.js";
34
34
  import FormPanel from "./components/panels/form.vue";
35
35
  import { vueApp } from "./store";
36
36
 
@@ -39,7 +39,7 @@ export default {
39
39
  "nav-appbar": NavAppBar,
40
40
  "panels-form": FormPanel,
41
41
  },
42
- mixins: [phoenixSocketMixin, actionCableMixin],
42
+ // mixins: [phoenixSocketMixin, actionCableMixin],
43
43
  props: {
44
44
  page: { type: Object, required: true },
45
45
  },
@@ -103,8 +103,8 @@ export default {
103
103
  $ready() {
104
104
  document.title = this.page.title;
105
105
 
106
- this.$wsInitPhoenixSocket(this.page.phoenixSocket);
107
- this.$wsInitActionCable(this.page.actionCable);
106
+ // this.$wsInitPhoenixSocket(this.page.phoenixSocket);
107
+ // this.$wsInitActionCable(this.page.actionCable);
108
108
 
109
109
  // TODO: Remove gtag dependency
110
110
  // if (this.$gtag) {
File without changes
File without changes
@@ -6,9 +6,9 @@
6
6
 
7
7
  <script setup>
8
8
  import { computed } from 'vue';
9
- import { singleDataSeries } from './series';
9
+ const { singleDataSeries } = await import('./series');
10
10
 
11
- const { spec } = defineProps({ spec: Object })
12
- const color = spec.colors == null ? '' : [spec.colors]
13
- const series = computed(() => singleDataSeries(spec.dataSeries))
11
+ const { spec } = defineProps({ spec: Object });
12
+ const color = spec.colors == null ? '' : [spec.colors];
13
+ const series = computed(() => singleDataSeries(spec.dataSeries));
14
14
  </script>
@@ -3,12 +3,11 @@
3
3
  </template>
4
4
 
5
5
  <script setup>
6
-
7
6
  import { computed } from 'vue';
8
- import { multipleDataSeries } from './series';
7
+ const { multipleDataSeries } = await import('./series');
9
8
 
10
- const { spec } = defineProps({ spec: Object })
11
- const color = spec.colors == null ? '' : spec.colors
9
+ const { spec } = defineProps({ spec: Object });
10
+ const color = spec.colors == null ? '' : spec.colors;
12
11
  const series = computed(() => multipleDataSeries(spec.dataGroups))
13
12
 
14
13
  </script>
@@ -4,10 +4,10 @@
4
4
 
5
5
  <script setup>
6
6
  import { computed } from 'vue';
7
- import { multipleDataSeries } from './series';
7
+ const { multipleDataSeries } = await import('./series');
8
8
 
9
- const { spec } = defineProps({ spec: Object })
10
- const color = spec.colors == null ? '' : spec.colors
9
+ const { spec } = defineProps({ spec: Object });
10
+ const color = spec.colors == null ? '' : spec.colors;
11
11
 
12
- const series = computed(() => multipleDataSeries(spec.dataSeries))
12
+ const series = computed(() => multipleDataSeries(spec.dataSeries));
13
13
  </script>
@@ -4,10 +4,10 @@
4
4
 
5
5
  <script setup>
6
6
  import { computed } from 'vue';
7
- import { singleDataSeries } from './series';
7
+ const { singleDataSeries } = await import('./series');
8
8
 
9
- const { spec } = defineProps({ spec: Object })
10
- const color = spec.colors == null ? '' : spec.colors
9
+ const { spec } = defineProps({ spec: Object });
10
+ const color = spec.colors == null ? '' : spec.colors;
11
11
  const series = computed(() => singleDataSeries(spec.dataSeries))
12
12
 
13
13
  </script>
@@ -1,18 +1,26 @@
1
+ import { Vue } from "../..";
2
+
3
+ import 'chartkick/chart.js';
4
+
5
+ import VueChartkick from 'vue-chartkick';
6
+ Vue.use(VueChartkick);
7
+
8
+
1
9
  const multipleDataSeries = (dataSeries) => {
2
10
  return dataSeries.map((value) => {
3
- let points = null
11
+ let points = null;
4
12
  if (Array.isArray(value.points)) {
5
13
  points = value.points.reduce((prev, curr) => {
6
- return Object.assign(prev, { [curr.x]: curr.y })
7
- }, {})
14
+ return Object.assign(prev, { [curr.x]: curr.y });
15
+ }, {});
8
16
  } else {
9
- points = value.points
17
+ points = value.points;
10
18
  }
11
- return { name: value.title, data: points }
12
- })
13
- }
19
+ return { name: value.title, data: points };
20
+ });
21
+ };
14
22
 
15
- const singleDataSeries = (dataSeries) => dataSeries.reduce((prev, curr) => Object.assign(prev, { [curr.title]: curr.value }), {})
23
+ const singleDataSeries = (dataSeries) => dataSeries.reduce((prev, curr) => Object.assign(prev, { [curr.title]: curr.value }), {});
16
24
 
17
25
 
18
- export { multipleDataSeries, singleDataSeries }
26
+ export { multipleDataSeries, singleDataSeries };
@@ -1,33 +1,38 @@
1
1
  <template>
2
- <fields-text v-if="name == 'fields-text'" :spec="spec" type="text" />
3
- <fields-text v-else-if="name == 'fields-number'" :spec="spec" type="number" />
4
- <fields-text v-else-if="name == 'fields-email'" :spec="spec" type="email" />
5
- <fields-text v-else-if="name == 'fields-url'" :spec="spec" type="url" />
6
- <fields-text v-else-if="name == 'fields-password'" :spec="spec" type="password" />
7
- <!-- <fields-textarea v-else-if="spec.view == 'fields/textarea-v1'" :spec="spec" />
2
+ <Suspense>
3
+ <fields-text v-if="name == 'fields-text'" :spec="spec" type="text" />
4
+ <fields-text v-else-if="name == 'fields-number'" :spec="spec" type="number" />
5
+ <fields-text v-else-if="name == 'fields-email'" :spec="spec" type="email" />
6
+ <fields-text v-else-if="name == 'fields-url'" :spec="spec" type="url" />
7
+ <fields-text v-else-if="name == 'fields-password'" :spec="spec" type="password" />
8
+ <!-- <fields-textarea v-else-if="spec.view == 'fields/textarea-v1'" :spec="spec" />
8
9
  <fields-richText v-else-if="spec.view == 'fields/richText-v1'" :spec="spec" /> -->
9
- <!-- <fields-file v-else-if="spec.view == 'fields/file-v1'" :spec="spec" />
10
+ <!-- <fields-file v-else-if="spec.view == 'fields/file-v1'" :spec="spec" />
10
11
  <fields-select v-else-if="spec.view == 'fields/select-v1'" :spec="spec" />
11
12
  <fields-dynamicSelect
12
13
  v-else-if="spec.view == 'fields/dynamicSelect-v1'"
13
14
  :spec="spec"
14
15
  /> -->
15
- <!-- <fields-country v-else-if="spec.view == 'fields/country-v1'" :spec="spec" /> -->
16
+ <!-- <fields-country v-else-if="spec.view == 'fields/country-v1'" :spec="spec" /> -->
16
17
 
17
- <!-- <fields-latLong v-else-if="spec.view == 'fields/latLong-v1'" :spec="spec" /> -->
18
- <fields-googlePlace v-else-if="spec.view == 'fields/googlePlace-v1'" :spec="spec" />
18
+ <!-- <fields-latLong v-else-if="spec.view == 'fields/latLong-v1'" :spec="spec" /> -->
19
+ <fields-googlePlace v-else-if="spec.view == 'fields/googlePlace-v1'" :spec="spec" />
19
20
 
20
- <!-- <panels-responsive v-else-if="spec.view == 'panels/scroll-v1'" :spec="spec" /> -->
21
+ <!-- <panels-responsive v-else-if="spec.view == 'panels/scroll-v1'" :spec="spec" /> -->
21
22
 
22
- <!-- This component manages its own mouse events, so don't auto-initialize it. -->
23
- <button v-else-if="name == 'button'" :spec="spec" />
23
+ <!-- This component manages its own mouse events, so don't auto-initialize it. -->
24
+ <button v-else-if="name == 'button'" :spec="spec" />
24
25
 
25
- <component v-else-if="name" :is="name" :id="spec.id" ref="delegate" :spec="spec"
26
- @[menter]="handlePopover(spec.onMouseEnter)" @[mleave]="handlePopover(spec.onMouseLeave)" />
27
- <div v-else>Unsupported view: {{ spec.view }}</div>
26
+ <component v-else-if="name" :is="name" :id="spec.id" ref="delegate" :spec="spec"
27
+ @[menter]="handlePopover(spec.onMouseEnter)" @[mleave]="handlePopover(spec.onMouseLeave)" />
28
+ <div v-else>Unsupported view: {{ spec.view }}</div>
29
+ </Suspense>
28
30
  </template>
29
31
 
30
32
  <script>
33
+ import { getCurrentInstance } from 'vue';
34
+ import { defineAsyncComponent } from "vue";
35
+
31
36
  import H1 from "./h1.vue";
32
37
  import H2 from "./h2.vue";
33
38
  import H3 from "./h3.vue";
@@ -39,7 +44,7 @@ import P from "./p.vue";
39
44
  import Markdown from "./markdown.vue";
40
45
  import Html from "./html.vue";
41
46
  import Chip from "./chip.vue";
42
- import Datetime from "./datetime.vue";
47
+ const Datetime = defineAsyncComponent(() => import("./datetime.vue"));
43
48
 
44
49
  import ProgressBar from "./progressbar.vue";
45
50
  import ProgressCircle from "./progressCircle.vue";
@@ -55,7 +60,7 @@ import Switch from "./switch.vue";
55
60
  import Hr from "./hr.vue";
56
61
  import Spacer from "./spacer.vue";
57
62
 
58
- // import Map from "./map.vue";
63
+ const Map = defineAsyncComponent(() => import("./map.vue"));
59
64
  import TabBar from "./tabBar.vue";
60
65
  import Calendar from "./calendar.vue";
61
66
 
@@ -63,9 +68,9 @@ import HiddenField from "./fields/hidden.vue";
63
68
  import TextField from "./fields/text.vue";
64
69
  import SubmitField from "./fields/submit.vue";
65
70
  import TextAreaField from "./fields/textarea.vue";
66
- import RichTextField from "./fields/richText.vue";
71
+ const RichTextField = defineAsyncComponent(() => import("./fields/richText.vue"));
67
72
  // import NewRichTextField from "./fields/newRichText.vue";
68
- import FileField from "./fields/file.vue";
73
+ const FileField = defineAsyncComponent(() => import("./fields/file.vue"));
69
74
  import AutocompleteField from "./fields/autocomplete.vue";
70
75
  import SelectField from "./fields/select.vue";
71
76
  import TimeZoneField from "./fields/timeZone.vue";
@@ -77,14 +82,14 @@ import CheckGroupField from "./fields/checkGroup.vue";
77
82
  import CheckField from "./fields/check.vue";
78
83
  import DateField from "./fields/date.vue";
79
84
  import DateTimeField from "./fields/datetime.vue";
80
- import LocationField from "./fields/location.vue";
85
+ const LocationField = defineAsyncComponent(() => import("./fields/location.vue"));
81
86
  import GooglePlaceField from "./fields/googlePlace.vue";
82
87
  import DynamicGroupField from "./fields/dynamicGroup.vue";
83
88
  import StripeTokenField from "./fields/stripeToken.vue";
84
89
  import StripeExternalAccount from "./fields/stripeExternalAccount.vue";
85
90
  import CreditCardField from "./fields/creditCard.vue";
86
91
  import RatingField from "./fields/rating.vue";
87
- import PhoneField from "./fields/phone/field.vue";
92
+ const PhoneField = defineAsyncComponent(() => import("./fields/phone/field.vue"));
88
93
  import TimerField from "./fields/timer.vue";
89
94
  import OtpField from "./fields/otpField.vue";
90
95
 
@@ -115,10 +120,7 @@ import ColumnChart from "./charts/column.vue";
115
120
  import PieChart from "./charts/pie.vue";
116
121
  import AreaChart from "./charts/area.vue";
117
122
 
118
- import ShareButton from "./shareButton.vue";
119
- import Action from "../action";
120
-
121
- import { getCurrentInstance } from 'vue';
123
+ const ShareButton = defineAsyncComponent(() => import("./shareButton.vue"));
122
124
 
123
125
  export default {
124
126
  components: {
@@ -148,7 +150,7 @@ export default {
148
150
  "views-hr": Hr,
149
151
  "views-spacer": Spacer,
150
152
 
151
- // "views-map": Map,
153
+ "views-map": Map,
152
154
  "views-tabBar": TabBar,
153
155
  "views-calendar": Calendar,
154
156
  "views-shareButton": ShareButton,
@@ -231,14 +233,7 @@ export default {
231
233
  spec: {
232
234
  handler(spec) {
233
235
  const name = Utils.app.componentName(spec.view);
234
- const strict = true;
235
- if (strict) {
236
- this.name = name;
237
- } else {
238
- if (getCurrentInstance().appContext.app.components[name]) {
239
- this.name = name;
240
- }
241
- }
236
+ this.name = name;
242
237
  },
243
238
  immediate: true
244
239
  }
@@ -0,0 +1,153 @@
1
+ import { onMounted, ref, nextTick } from "vue";
2
+ import { MarkerClusterer } from "@googlemaps/markerclusterer";
3
+
4
+ function waitForGmapLoaded() {
5
+ return new Promise((resolve) => {
6
+ let intervalId = setInterval(() => {
7
+ if (window._gmapLoaded && window.google) {
8
+ clearInterval(intervalId);
9
+ resolve(true);
10
+ }
11
+ }, 150);
12
+ });
13
+ }
14
+
15
+ export function useAutocomplete({ inputRef, options, onPlaceChanged }) {
16
+ let autocompleteInstance = null;
17
+ onMounted(() => {
18
+ let inputElement = null;
19
+ if (inputRef.value instanceof HTMLElement) {
20
+ inputElement = inputRef.value;
21
+ } else {
22
+ inputElement = inputRef.value.$el.querySelector("input[type='text']");
23
+ }
24
+
25
+ autocompleteInstance = new google.maps.places.Autocomplete(inputElement, options);
26
+
27
+ if (onPlaceChanged) {
28
+ autocompleteInstance.addListener('place_changed', () => onPlaceChanged(autocompleteInstance));
29
+ }
30
+ });
31
+
32
+ return { autocompleteInstance };
33
+ }
34
+
35
+ export function useGmap({ mapRef, infoWindowRef, options, locations, showCluster = false, showDirection = false }) {
36
+ let mapInstance = null;
37
+ const markers = ref([]);
38
+ const cluster = ref({});
39
+ const selectedMarker = ref({});
40
+
41
+ let infoWindow = null;
42
+
43
+ const drawDirection = () => {
44
+ let directionService = new google.maps.DirectionsService();
45
+ let directionDisplay = new google.maps.DirectionsRenderer();
46
+
47
+ for (let l = 0; l < locations.length; l++) {
48
+ for (let i = 0; i < locations[l].length; i++) {
49
+ let travel = {
50
+ origin: locations[l][i],
51
+ destination: locations[l][i + 1],
52
+ travelMode: "DRIVING"
53
+ };
54
+
55
+ if (!travel.destination) {
56
+ break;
57
+ }
58
+
59
+ directionService.route(travel, (response, status) => {
60
+ if (status === "OK") {
61
+ directionDisplay = new google.maps.DirectionsRenderer({
62
+ suppressMarkers: true,
63
+ polylineOptions: {
64
+ strokeColor: "#2ab3a6",
65
+ stropeOpacity: 0.8,
66
+ strokeWeight: 5
67
+ }
68
+ });
69
+ directionDisplay.setMap(mapInstance);
70
+ directionDisplay.setDirections(response);
71
+ }
72
+ });
73
+ }
74
+ }
75
+ };
76
+
77
+ const updateMarkers = (locations) => {
78
+ // remove old markers
79
+ if (showCluster && cluster.value.length >= 1) {
80
+ cluster.value.clearMarkers();
81
+ }
82
+
83
+ if (markers.value && markers.value.length >= 1) {
84
+ markers.value.forEach((marker) => marker.setMap(null));
85
+ }
86
+
87
+ // show the new one
88
+ if (locations && locations.length >= 1) {
89
+ markers.value = locations.map((value) => {
90
+ const marker = new google.maps.Marker({
91
+ position: value,
92
+ map: mapInstance
93
+ });
94
+
95
+ if (value.infoWindow) {
96
+ marker.addListener('click', () => {
97
+ selectedMarker.value = value;
98
+
99
+ nextTick(() => {
100
+ infoWindow.setContent(infoWindowRef.value);
101
+
102
+ infoWindow.open({
103
+ map: mapInstance,
104
+ anchor: marker
105
+ });
106
+ });
107
+
108
+ });
109
+ }
110
+
111
+ return marker;
112
+ });
113
+ }
114
+
115
+ if (showCluster) {
116
+ cluster.value = new MarkerClusterer({ map: mapInstance, markers: markers.value });
117
+ }
118
+ };
119
+
120
+ const mapPromise = () => {
121
+ return new Promise((resolve) => {
122
+ let intervalId = setInterval(() => {
123
+ if (mapInstance) {
124
+ clearInterval(intervalId);
125
+ resolve(mapInstance);
126
+ }
127
+ }, 50);
128
+ });
129
+ };
130
+
131
+ onMounted(async () => {
132
+ await waitForGmapLoaded();
133
+ // initialize static info window (only one info window per one map)
134
+ infoWindow = new google.maps.InfoWindow;
135
+
136
+ const defaultOptions = {
137
+ zoom: 4,
138
+ center: { lat: -42.162376, lng: 172.671437 },
139
+ mapId: Math.random().toString(36).slice(2, 7)
140
+ };
141
+
142
+ mapInstance = new google.maps.Map(mapRef.value, { ...defaultOptions, ...options });
143
+
144
+ if (locations) {
145
+ updateMarkers([locations].flat());
146
+ }
147
+ });
148
+
149
+ return { updateMarkers, mapPromise, mapInstance, selectedMarker, drawDirection };
150
+ }
151
+
152
+
153
+
File without changes
File without changes
File without changes
File without changes
File without changes