renusify 1.1.4 → 1.2.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 (84) hide show
  1. package/components/app/notify/notification.vue +2 -1
  2. package/components/app/toast/index.vue +7 -2
  3. package/components/app/toast/toast.vue +2 -0
  4. package/components/avatar/index.vue +29 -23
  5. package/components/bar/bottomNavigationCircle.vue +8 -3
  6. package/components/bar/scss/bottomNav.scss +1 -1
  7. package/components/bar/toolbar/laptop.vue +4 -4
  8. package/components/bar/toolbar/mixin.js +1 -2
  9. package/components/bar/toolbar/mobile.vue +5 -4
  10. package/components/breadcrumb/index.vue +1 -0
  11. package/components/button/buttonConfirm.vue +1 -1
  12. package/components/button/buttonGroup.vue +1 -0
  13. package/components/button/style.scss +1 -0
  14. package/components/calendar/index.vue +1 -0
  15. package/components/calendar/month.vue +1 -0
  16. package/components/calendar/year.vue +1 -0
  17. package/components/chat/chatInput.vue +1 -0
  18. package/components/chat/chatMsg.vue +1 -0
  19. package/components/chat/index.vue +1 -0
  20. package/components/chip/index.vue +1 -0
  21. package/components/codeEditor/index.vue +0 -2
  22. package/components/confirm/index.vue +1 -0
  23. package/components/countdown/index.vue +1 -0
  24. package/components/float/index.vue +1 -0
  25. package/components/form/address.vue +6 -2
  26. package/components/form/camInput.vue +10 -3
  27. package/components/form/check-input.vue +95 -94
  28. package/components/form/checkbox.vue +1 -1
  29. package/components/form/colorPicker/index.vue +1 -0
  30. package/components/form/colorPicker/picker.vue +1 -0
  31. package/components/form/datePicker/index.vue +349 -348
  32. package/components/form/datePicker/month.vue +1 -0
  33. package/components/form/datePicker/year.vue +1 -0
  34. package/components/form/fileUploader/file.js +21 -3
  35. package/components/form/fileUploader/index.vue +13 -2
  36. package/components/form/fileUploader/single.vue +4 -2
  37. package/components/form/form.vue +1 -0
  38. package/components/form/group-input.vue +42 -38
  39. package/components/form/input.vue +253 -1
  40. package/components/form/inputTel/index.vue +22 -12
  41. package/components/form/json/JsonView.vue +95 -94
  42. package/components/form/json/index.vue +2 -0
  43. package/components/form/mask-input.vue +1 -0
  44. package/components/form/number.vue +25 -12
  45. package/components/form/password.vue +121 -121
  46. package/components/form/radioInput.vue +1 -0
  47. package/components/form/range.vue +26 -1
  48. package/components/form/rating.vue +13 -1
  49. package/components/form/select.vue +67 -4
  50. package/components/form/switch.vue +64 -2
  51. package/components/form/text-area.vue +1 -1
  52. package/components/form/text-editor/index.vue +18 -11
  53. package/components/form/text-input.vue +1 -1
  54. package/components/form/timepicker/index.vue +2 -1
  55. package/components/form/timepicker/range.vue +2 -1
  56. package/components/form/timepicker/timepicker.vue +2 -1
  57. package/components/form/unique/index.vue +3 -1
  58. package/components/form/unit-input.vue +2 -1
  59. package/components/formCreator/index.vue +8 -6
  60. package/components/html2pdf/index.vue +1 -0
  61. package/components/img/index.vue +12 -2
  62. package/components/img/svgImg.vue +43 -0
  63. package/components/infinite/div.vue +2 -1
  64. package/components/infinite/page.vue +24 -23
  65. package/components/list/index.vue +35 -32
  66. package/components/map/index.vue +324 -306
  67. package/components/map/route.vue +1 -0
  68. package/components/map/select.vue +1 -0
  69. package/components/menu/index.vue +1 -0
  70. package/components/modal/index.vue +1 -0
  71. package/components/searchBox/index.vue +5 -3
  72. package/components/slider/index.vue +1 -0
  73. package/components/table/crud/footer.vue +1 -1
  74. package/components/table/crud/header.vue +10 -4
  75. package/components/table/crud/index.vue +463 -458
  76. package/components/tabs/index.vue +1 -0
  77. package/components/tree/index.vue +15 -13
  78. package/components/tree/tree-element.vue +8 -4
  79. package/package.json +1 -1
  80. package/style/colors.scss +1 -1
  81. package/components/form/scss/input.scss +0 -249
  82. package/components/form/scss/rating.scss +0 -9
  83. package/components/form/scss/select.scss +0 -55
  84. package/components/form/scss/switch.scss +0 -68
@@ -1,331 +1,349 @@
1
1
  <template>
2
- <div ref="map"
3
- :class="{[`${$r.prefix}map`]:true,'map-dark': dark, 'attribution-show': attribution }"
2
+ <div ref="map"
3
+ :class="{[`${$r.prefix}map`]:true,'map-dark': dark, 'attribution-show': attribution }"
4
+ >
5
+ <div class="map-search" v-if="searchBox">
6
+ <r-search-box
7
+ :label="$t('search','renusify')"
8
+ @select="go"
9
+ url="https://nominatim.openstreetmap.org/search.php?polygon_geojson=0&accept-language=fa&countrycodes=IR&format=jsonv2"
10
+ query="q"
11
+ no-overlay
12
+ inputControlClass="sheet"
13
+ :notFoundMsg="$t('map_not_found','renusify')"
14
+ >
15
+ <template v-slot="{ item }">
16
+ {{ item["display_name"] }}
17
+ </template>
18
+ </r-search-box>
19
+ </div>
20
+ <div class="map-box" :id="map_id" :style="`height: ${height}`"></div>
21
+
22
+ <r-btn
23
+ v-if="meLocation"
24
+ class="map-location color-white color-primary-text"
25
+ icon
26
+ @click.prevent="showConfirm"
27
+ :loading="loading"
4
28
  >
5
- <div class="map-search" v-if="searchBox">
6
- <r-search-box
7
- :label="$t('search','renusify')"
8
- @select="go"
9
- url="https://nominatim.openstreetmap.org/search.php?polygon_geojson=0&accept-language=fa&countrycodes=IR&format=jsonv2"
10
- query="q"
11
- no-overlay
12
- inputControlClass="sheet"
13
- :notFoundMsg="$t('map_not_found','renusify')"
14
- >
15
- <template v-slot="{ item }">
16
- {{ item["display_name"] }}
17
- </template>
18
- </r-search-box>
19
- </div>
20
- <div class="map-box" :id="map_id" :style="`height: ${height}`"></div>
29
+ <r-icon v-html="$r.icons.crosshairs_gps"></r-icon>
30
+ </r-btn>
31
+ <r-btn
32
+ class="map-attribution color-white color-primary-text"
33
+ @click.prevent="attribution = !attribution"
34
+ size="x-small"
35
+ icon
36
+ >
37
+ <r-icon v-html="$r.icons.copyright" exact></r-icon>
38
+ </r-btn>
21
39
 
22
- <r-btn
23
- class="map-location color-white"
24
- icon
25
- @click.prevent="showConfirm"
26
- :loading="loading"
27
- >
28
- <r-icon v-html="$r.icons.crosshairs_gps"></r-icon>
29
- </r-btn>
30
- <r-btn
31
- class="map-attribution color-white"
32
- @click.prevent="attribution = !attribution"
33
- size="x-small"
34
- icon
35
- >
36
- <r-icon v-html="$r.icons.copyright" exact></r-icon>
37
- </r-btn>
38
-
39
- <r-confirm v-model="confirm"
40
- @accept="getLocation"
41
- @cancel="confirm = false" :text="$t('map_location_confirm','renusify')"></r-confirm>
42
- </div>
40
+ <r-confirm v-model="confirm"
41
+ @accept="getLocation"
42
+ @cancel="confirm = false" :text="$t('map_location_confirm','renusify')"></r-confirm>
43
+ </div>
43
44
 
44
45
  </template>
45
46
 
46
47
  <script>
47
- export default {
48
- name: "rMap",
49
- props: {
50
- modelValue: Array,
51
- height: {type: String, default: "500px"},
52
- zoom: {type: Number, default: 13},
53
- center: {
54
- type: Array,
55
- default: () => {
56
- return [35.69940749291485, 51.33705139160157];
57
- }
58
- },
59
- markers: {
60
- type: Array,
61
- default: () => {
62
- return [];
63
- }
64
- },
65
- searchBox: Boolean,
66
- darkMode: Boolean
67
- },
68
- data() {
69
- return {
70
- dark: this.darkMode,
71
- attribution: false,
72
- confirm: false,
73
- loading: false,
74
- L: null,
75
- map: null,
76
- layerGroup: null,
77
- map_id: "map_" + this.$helper.uniqueId(12),
78
- layers: {},
79
- license: '&copy; | <a href="https://leafletjs.com" target="_blank">Leaflet</a> | <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors | Renusify'
80
- };
81
- },
82
- created(){
83
- if(!this.$r.icons.crosshairs_gps){
84
- this.$r.icons.crosshairs_gps = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M12 8a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m-8.95 5H1v-2h2.05C3.5 6.83 6.83 3.5 11 3.05V1h2v2.05c4.17.45 7.5 3.78 7.95 7.95H23v2h-2.05c-.45 4.17-3.78 7.5-7.95 7.95V23h-2v-2.05C6.83 20.5 3.5 17.17 3.05 13M12 5a7 7 0 0 0-7 7a7 7 0 0 0 7 7a7 7 0 0 0 7-7a7 7 0 0 0-7-7Z"/></svg>'
85
- }
86
- if(!this.$r.icons.copyright){
87
- this.$r.icons.copyright = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M10.08 10.86c.05-.33.16-.62.3-.86c.3-.56.81-.85 1.5-.86c.45 0 .86.2 1.15.49c.28.31.47.74.47 1.17h1.8c-.02-.47-.11-.9-.3-1.3c-.15-.38-.38-.72-.68-1c-1.45-1.34-4.14-1.15-5.37.37c-1.29 1.67-1.32 4.59-.01 6.26c1.21 1.49 3.86 1.7 5.3.37c.31-.25.56-.56.76-.92c.16-.36.27-.74.28-1.15H13.5c0 .21-.07.4-.16.57c-.09.19-.21.34-.34.47c-.33.26-.72.4-1.14.4c-.36-.01-.66-.08-.89-.23a1.41 1.41 0 0 1-.59-.64c-.5-.9-.42-2.15-.3-3.14M12 2C6.5 2 2 6.5 2 12c.53 13.27 19.5 13.26 20 0c0-5.5-4.5-10-10-10m0 18c-4.41 0-8-3.59-8-8c.44-10.61 15.56-10.61 16 0c0 4.41-3.59 8-8 8Z"/></svg>'
88
- }
89
- },
90
- async beforeMount() {
91
- await this.add();
92
- },
93
- watch: {
94
- modelValue: function () {
95
- this.map.flyTo(this.modelValue);
96
- },
97
- markers: function () {
98
- this.printMarkers()
99
- }
100
- },
101
- methods: {
102
- showConfirm() {
103
- if (this.$storage.has('map_location_access')) {
104
- this.getLocation()
105
- } else {
106
- this.confirm = true
107
- }
108
- },
109
- go(e) {
110
- if (e.lat) {
111
- this.map.flyTo([e.lat, e.lon]);
112
- }
113
- },
114
- initMap() {
115
- let opt = {
116
- maxZoom: 19,
117
- zoomControl: false,
118
- minZoom: 3,
119
- noWrap: true
120
- };
121
- this.layers[this.$t('map_hot','renusify')] = this.L.tileLayer(
122
- "https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png",
123
- opt
124
- );
125
- opt.dark = true;
126
- this.layers[this.$t('map_hot_dark','renusify')] = this.L.tileLayer(
127
- "https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png",
128
- opt
129
- );
130
- opt.dark = false;
131
- this.layers[this.$t('map_standard','renusify')] = this.L.tileLayer(
132
- "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
133
- opt
134
- );
135
- opt.dark = true;
136
- this.layers[this.$t('map_standard_dark','renusify')] = this.L.tileLayer(
137
- "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
138
- opt
139
- );
140
- opt.dark = false;
141
- opt.subdomains = ["mt0", "mt1", "mt2", "mt3"];
142
- this.layers[this.$t('map_google','renusify')] = this.L.tileLayer(
143
- "http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
144
- opt
145
- );
146
- opt.dark = true;
147
- this.layers[this.$t('map_google_dark','renusify')] = this.L.tileLayer(
148
- "http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
149
- opt
150
- );
151
- opt.dark = false;
152
- this.layers[this.$t('map_satelite','renusify')] = this.L.tileLayer(
153
- "http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}",
154
- opt
155
- );
156
-
157
- this.layers[this.$t('map_hot','renusify')].addTo(this.map);
158
- this.L.control
159
- .zoom({
160
- zoomInTitle: this.$t("map_zoom_in",'renusify'),
161
- zoomOutTitle: this.$t("map_zoom_out",'renusify')
162
- })
163
- .addTo(this.map);
48
+ export default {
49
+ name: "rMap",
50
+ props: {
51
+ modelValue: Array,
52
+ height: {type: String, default: "500px"},
53
+ zoom: {type: Number, default: 13},
54
+ center: {
55
+ type: Array,
56
+ default: () => {
57
+ return [35.69940749291485, 51.33705139160157];
58
+ }
59
+ },
60
+ markers: {
61
+ type: Array,
62
+ default: () => {
63
+ return [];
64
+ }
65
+ },
66
+ searchBox: Boolean,
67
+ zoomControl: {type: Boolean, default: true},
68
+ layerControl: {type: Boolean, default: true},
69
+ meLocation: {type: Boolean, default: true},
70
+ disableMove: {type: Boolean, default: false},
71
+ darkMode: Boolean
72
+ },
73
+ data() {
74
+ return {
75
+ dark: this.darkMode,
76
+ attribution: false,
77
+ confirm: false,
78
+ loading: false,
79
+ L: null,
80
+ map: null,
81
+ layerGroup: null,
82
+ map_id: "map_" + this.$helper.uniqueId(12),
83
+ layers: {},
84
+ license: '&copy; | <a href="https://leafletjs.com" target="_blank">Leaflet</a> | <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors | Renusify'
85
+ };
86
+ },
87
+ emits:['update:modelValue','leaflet','map'],
88
+ created() {
89
+ if (!this.$r.icons.crosshairs_gps) {
90
+ this.$r.icons.crosshairs_gps = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M12 8a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m-8.95 5H1v-2h2.05C3.5 6.83 6.83 3.5 11 3.05V1h2v2.05c4.17.45 7.5 3.78 7.95 7.95H23v2h-2.05c-.45 4.17-3.78 7.5-7.95 7.95V23h-2v-2.05C6.83 20.5 3.5 17.17 3.05 13M12 5a7 7 0 0 0-7 7a7 7 0 0 0 7 7a7 7 0 0 0 7-7a7 7 0 0 0-7-7Z"/></svg>'
91
+ }
92
+ if (!this.$r.icons.copyright) {
93
+ this.$r.icons.copyright = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M10.08 10.86c.05-.33.16-.62.3-.86c.3-.56.81-.85 1.5-.86c.45 0 .86.2 1.15.49c.28.31.47.74.47 1.17h1.8c-.02-.47-.11-.9-.3-1.3c-.15-.38-.38-.72-.68-1c-1.45-1.34-4.14-1.15-5.37.37c-1.29 1.67-1.32 4.59-.01 6.26c1.21 1.49 3.86 1.7 5.3.37c.31-.25.56-.56.76-.92c.16-.36.27-.74.28-1.15H13.5c0 .21-.07.4-.16.57c-.09.19-.21.34-.34.47c-.33.26-.72.4-1.14.4c-.36-.01-.66-.08-.89-.23a1.41 1.41 0 0 1-.59-.64c-.5-.9-.42-2.15-.3-3.14M12 2C6.5 2 2 6.5 2 12c.53 13.27 19.5 13.26 20 0c0-5.5-4.5-10-10-10m0 18c-4.41 0-8-3.59-8-8c.44-10.61 15.56-10.61 16 0c0 4.41-3.59 8-8 8Z"/></svg>'
94
+ }
95
+ },
96
+ async beforeMount() {
97
+ await this.add();
98
+ },
99
+ watch: {
100
+ modelValue: function () {
101
+ this.map.flyTo(this.modelValue);
102
+ },
103
+ markers: function () {
104
+ this.printMarkers()
105
+ }
106
+ },
107
+ methods: {
108
+ showConfirm() {
109
+ if (this.$storage.has('map_location_access')) {
110
+ this.getLocation()
111
+ } else {
112
+ this.confirm = true
113
+ }
114
+ },
115
+ go(e) {
116
+ if (e.lat) {
117
+ this.map.flyTo([e.lat, e.lon]);
118
+ }
119
+ },
120
+ initMap() {
121
+ let opt = {
122
+ maxZoom: 19,
123
+ zoomControl: false,
124
+ minZoom: 3,
125
+ noWrap: true
126
+ };
127
+ this.layers[this.$t('map_hot', 'renusify')] = this.L.tileLayer(
128
+ "https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png",
129
+ opt
130
+ );
131
+ opt.dark = true;
132
+ this.layers[this.$t('map_hot_dark', 'renusify')] = this.L.tileLayer(
133
+ "https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png",
134
+ opt
135
+ );
136
+ opt.dark = false;
137
+ this.layers[this.$t('map_standard', 'renusify')] = this.L.tileLayer(
138
+ "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
139
+ opt
140
+ );
141
+ opt.dark = true;
142
+ this.layers[this.$t('map_standard_dark', 'renusify')] = this.L.tileLayer(
143
+ "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
144
+ opt
145
+ );
146
+ opt.dark = false;
147
+ opt.subdomains = ["mt0", "mt1", "mt2", "mt3"];
148
+ this.layers[this.$t('map_google', 'renusify')] = this.L.tileLayer(
149
+ "http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
150
+ opt
151
+ );
152
+ opt.dark = true;
153
+ this.layers[this.$t('map_google_dark', 'renusify')] = this.L.tileLayer(
154
+ "http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}",
155
+ opt
156
+ );
157
+ opt.dark = false;
158
+ this.layers[this.$t('map_satelite', 'renusify')] = this.L.tileLayer(
159
+ "http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}",
160
+ opt
161
+ );
164
162
 
165
- this.L.control.layers(this.layers).addTo(this.map);
166
- const that = this;
167
- this.map.on("baselayerchange", function (e) {
168
- if (that.$helper.ifHas(e, false, "layer", "options", "dark")) {
169
- that.dark = true;
170
- } else {
171
- that.dark = that.darkMode;
172
- }
173
- });
174
- this.map.on("move", function () {
175
- that.$emit("update:modelValue", Object.values(that.map.getCenter()));
176
- });
177
- },
178
- run() {
179
- this.map = this.L.map(this.map_id, {
180
- center: this.center,
181
- zoom: this.zoom,
182
- zoomControl: false
183
- });
184
- this.initMap();
185
- this.layerGroup = new this.L.layerGroup().addTo(this.map);
186
- this.printMarkers()
187
- this.$emit("update:modelValue", this.center);
188
- this.$emit("leaflet", this.L);
189
- this.$emit("map", this.map);
190
- this.printCopy()
191
- },
192
- printCopy() {
193
- const attr = this.$refs.map.querySelector('.leaflet-control-attribution')
194
- attr.innerHTML = '&copy; | <a href="https://leafletjs.com" target="_blank">Leaflet</a> | <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors | Renusify'
195
- },
196
- printMarkers() {
197
- if (!this.layerGroup) {
198
- return
199
- }
200
- this.layerGroup.clearLayers();
201
- this.markers.forEach((item) => {
202
- let options = {riseOnHover: true, item: item}
203
- if (item.icon) {
204
- options.icon = new this.L.icon(item.icon);
205
- }
206
- let marker = new this.L.Marker(item.loc, options);
207
- marker.addTo(this.layerGroup)
208
- if (item.popup) {
209
- marker.bindPopup(item.popup);
210
- }
211
- if (item.open_popup) {
212
- marker.openPopup();
213
- }
214
- if (item.tooltip) {
215
- marker.bindTooltip(item.tooltip);
216
- }
217
- if (item.open_tooltip) {
218
- marker.openTooltip();
219
- }
220
- if (item.click) {
221
- marker.on('click', item.click)
222
- }
223
- })
224
- },
225
- getLocation() {
226
- this.$storage.set('map_location_access', true)
227
- this.confirm = false
228
- this.loading = true;
229
- if (navigator.geolocation) {
230
- navigator.geolocation.getCurrentPosition(
231
- this.showPosition,
232
- this.showError
233
- );
234
- } else {
235
- this.loading = false;
236
- this.$toast(this.$t("map_not_support_location",'renusify'), {type: "error"});
237
- }
238
- },
239
- showPosition(position) {
240
- this.map.flyTo([position.coords.latitude, position.coords.longitude]);
241
- this.map.zoom = 18;
242
- this.loading = false;
243
- },
244
- showError(error) {
245
- this.loading = false;
246
- switch (error.code) {
247
- case error.PERMISSION_DENIED:
248
- this.$toast(this.$t("map_access_denied",'renusify'), {type: "error"});
249
- break;
250
- default:
251
- this.$toast(this.$t("map_unavailable",'renusify'), {type: "error"});
252
- break;
253
- }
254
- },
255
- async add() {
256
- import('./leaflet.css')
257
- this.L = await import('./leaflet')
258
- this.run();
259
- },
163
+ this.layers[this.$t('map_hot', 'renusify')].addTo(this.map);
164
+ if (this.zoomControl) {
165
+ this.L.control
166
+ .zoom({
167
+ zoomInTitle: this.$t("map_zoom_in", 'renusify'),
168
+ zoomOutTitle: this.$t("map_zoom_out", 'renusify')
169
+ })
170
+ .addTo(this.map);
171
+ } else {
172
+ this.map.touchZoom.disable();
173
+ this.map.doubleClickZoom.disable();
174
+ this.map.scrollWheelZoom.disable();
175
+ this.map.boxZoom.disable();
176
+ this.map.keyboard.disable();
177
+ }
178
+ if (this.layerControl) {
179
+ this.L.control.layers(this.layers).addTo(this.map);
180
+ }
181
+ const that = this;
182
+ this.map.on("baselayerchange", function (e) {
183
+ if (that.$helper.ifHas(e, false, "layer", "options", "dark")) {
184
+ that.dark = true;
185
+ } else {
186
+ that.dark = that.darkMode;
260
187
  }
261
- };
188
+ });
189
+ this.map.on("move", function () {
190
+ that.$emit("update:modelValue", Object.values(that.map.getCenter()));
191
+ });
192
+ },
193
+ run() {
194
+ this.map = this.L.map(this.map_id, {
195
+ center: this.center,
196
+ zoom: this.zoom,
197
+ zoomControl: false,
198
+ dragging: !this.disableMove,
199
+ tap: !this.disableMove
200
+ });
201
+ this.initMap();
202
+ this.layerGroup = new this.L.layerGroup().addTo(this.map);
203
+ this.printMarkers()
204
+ this.$emit("update:modelValue", this.center);
205
+ this.$emit("leaflet", this.L);
206
+ this.$emit("map", this.map);
207
+ this.printCopy()
208
+ },
209
+ printCopy() {
210
+ const attr = this.$refs.map.querySelector('.leaflet-control-attribution')
211
+ attr.innerHTML = '&copy; | <a href="https://leafletjs.com" target="_blank">Leaflet</a> | <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors | Renusify'
212
+ },
213
+ printMarkers() {
214
+ if (!this.layerGroup) {
215
+ return
216
+ }
217
+ this.layerGroup.clearLayers();
218
+ this.markers.forEach((item) => {
219
+ let options = {riseOnHover: true, item: item}
220
+ if (item.icon) {
221
+ options.icon = new this.L.icon(item.icon);
222
+ }
223
+ let marker = new this.L.Marker(item.loc, options);
224
+ marker.addTo(this.layerGroup)
225
+ if (item.popup) {
226
+ marker.bindPopup(item.popup);
227
+ }
228
+ if (item.open_popup) {
229
+ marker.openPopup();
230
+ }
231
+ if (item.tooltip) {
232
+ marker.bindTooltip(item.tooltip);
233
+ }
234
+ if (item.open_tooltip) {
235
+ marker.openTooltip();
236
+ }
237
+ if (item.click) {
238
+ marker.on('click', item.click)
239
+ }
240
+ })
241
+ },
242
+ getLocation() {
243
+ this.$storage.set('map_location_access', true)
244
+ this.confirm = false
245
+ this.loading = true;
246
+ if (navigator.geolocation) {
247
+ navigator.geolocation.getCurrentPosition(
248
+ this.showPosition,
249
+ this.showError
250
+ );
251
+ } else {
252
+ this.loading = false;
253
+ this.$toast(this.$t("map_not_support_location", 'renusify'), {type: "error"});
254
+ }
255
+ },
256
+ showPosition(position) {
257
+ this.map.flyTo([position.coords.latitude, position.coords.longitude]);
258
+ this.map.zoom = 18;
259
+ this.loading = false;
260
+ },
261
+ showError(error) {
262
+ this.loading = false;
263
+ switch (error.code) {
264
+ case error.PERMISSION_DENIED:
265
+ this.$toast(this.$t("map_access_denied", 'renusify'), {type: "error"});
266
+ break;
267
+ default:
268
+ this.$toast(this.$t("map_unavailable", 'renusify'), {type: "error"});
269
+ break;
270
+ }
271
+ },
272
+ async add() {
273
+ import('./leaflet.css')
274
+ await import('./leaflet')
275
+ this.L = global.L
276
+ this.run();
277
+ },
278
+ }
279
+ };
262
280
  </script>
263
281
 
264
282
  <style lang="scss">
265
- @import "~renusify/style/include";
283
+ @import "~renusify/style/include";
266
284
 
267
- .#{$prefix}map {
268
- position: relative;
285
+ .#{$prefix}map {
286
+ position: relative;
269
287
 
270
- .leaflet-popup {
271
- max-width: 250px;
272
- }
288
+ .leaflet-popup {
289
+ max-width: 250px;
290
+ }
273
291
 
274
- .leaflet-popup-content {
275
- text-align: center;
276
- }
292
+ .leaflet-popup-content {
293
+ text-align: center;
294
+ }
277
295
 
278
- .map-box {
279
- z-index: 1;
280
- }
296
+ .map-box {
297
+ z-index: 1;
298
+ }
281
299
 
282
- .map-search {
283
- width: 400px;
284
- position: absolute;
285
- top: 0;
286
- left: 0;
287
- right: 0;
288
- margin-right: auto;
289
- margin-left: auto;
290
- z-index: 2;
291
- max-width: calc(100vw - 130px);
292
- }
300
+ .map-search {
301
+ width: 400px;
302
+ position: absolute;
303
+ top: 0;
304
+ left: 0;
305
+ right: 0;
306
+ margin-right: auto;
307
+ margin-left: auto;
308
+ z-index: 2;
309
+ max-width: calc(100vw - 130px);
310
+ }
293
311
 
294
- .map-location {
295
- position: absolute;
296
- left: 10px;
297
- bottom: 10px;
298
- z-index: 2;
299
- }
312
+ .map-location {
313
+ position: absolute;
314
+ left: 10px;
315
+ bottom: 10px;
316
+ z-index: 2;
317
+ }
300
318
 
301
- &.map-dark .leaflet-tile {
302
- -webkit-filter: hue-rotate(180deg) invert(100%);
303
- }
319
+ &.map-dark .leaflet-tile {
320
+ -webkit-filter: hue-rotate(180deg) invert(100%);
321
+ }
304
322
 
305
- .map-attribution {
306
- position: absolute;
307
- right: 10px;
308
- bottom: 10px;
309
- z-index: 2;
310
- }
323
+ .map-attribution {
324
+ position: absolute;
325
+ right: 10px;
326
+ bottom: 10px;
327
+ z-index: 2;
328
+ }
311
329
 
312
- .leaflet-control-attribution {
313
- transition: all 0.3s ease-in-out;
314
- position: absolute;
315
- bottom: -30px;
316
- right: 0;
317
- width: 100vw;
318
- direction: ltr;
319
- }
330
+ .leaflet-control-attribution {
331
+ transition: all 0.3s ease-in-out;
332
+ position: absolute;
333
+ bottom: -30px;
334
+ right: 0;
335
+ width: 100vw;
336
+ direction: ltr;
337
+ }
320
338
 
321
- &.attribution-show {
322
- .map-attribution {
323
- bottom: 20px;
324
- }
339
+ &.attribution-show {
340
+ .map-attribution {
341
+ bottom: 20px;
342
+ }
325
343
 
326
- .leaflet-control-attribution {
327
- bottom: 0;
328
- }
329
- }
344
+ .leaflet-control-attribution {
345
+ bottom: 0;
330
346
  }
347
+ }
348
+ }
331
349
  </style>
@@ -71,6 +71,7 @@
71
71
  darkMode: Boolean,
72
72
  editable: Boolean
73
73
  },
74
+ emits:['update:modelValue'],
74
75
  data() {
75
76
  return {
76
77
  loading: false,