@dative-gpi/foundation-shared-components 1.0.85 → 1.0.87

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.
@@ -47,6 +47,7 @@
47
47
  v-for="location in $props.locations"
48
48
  :selected="location.id === $props.selectedLocationId"
49
49
  :key="location.id"
50
+ :label="location.label"
50
51
  :color="location.color ?? ColorEnum.Primary"
51
52
  :icon="location.icon ?? 'mdi-map-marker'"
52
53
  :latlng="{lat: location.address.latitude, lng: location.address.longitude}"
@@ -120,7 +121,7 @@
120
121
  import { computed, defineComponent, onMounted, type Ref, provide, type PropType, ref, type StyleValue, watch, onUnmounted, markRaw } from "vue";
121
122
 
122
123
  import type {} from "leaflet.markercluster";
123
- import { map as createMap, control, tileLayer, latLngBounds, latLng, type LatLng, LatLngBounds, type FitBoundsOptions } from "leaflet";
124
+ import { map as createMap, control, tileLayer, latLngBounds, latLng, type LatLng, type FitBoundsOptions, type ZoomPanOptions, type LatLngBounds } from "leaflet";
124
125
 
125
126
  import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
126
127
  import { type FSArea } from '@dative-gpi/foundation-shared-domain/models';
@@ -322,11 +323,11 @@ export default defineComponent({
322
323
  return map.value.unproject(targetPoint, zoom);
323
324
  }
324
325
 
325
- const flyTo = (lat: number, lng: number, zoom: number = defaultZoom) => {
326
+ const flyTo = (lat: number, lng: number, zoom: number = defaultZoom, options?: ZoomPanOptions) => {
326
327
  if(!map.value) {
327
328
  return;
328
329
  }
329
- map.value.flyTo(calculateTargetPosition(latLng(lat, lng), zoom), zoom);
330
+ map.value.flyTo(calculateTargetPosition(latLng(lat, lng), zoom), zoom, options);
330
331
  }
331
332
 
332
333
  const setView = (lat: number, lng: number, zoom: number) => {
@@ -337,15 +338,24 @@ export default defineComponent({
337
338
  }
338
339
 
339
340
  const fitBounds = (bounds: LatLngBounds, options?: FitBoundsOptions) => {
340
- if(!map.value) {
341
+ if (!map.value) {
341
342
  return;
342
343
  }
343
- const calculatedBounds = new LatLngBounds(
344
- calculateTargetPosition(bounds.getSouthWest()),
345
- calculateTargetPosition(bounds.getNorthEast())
346
- );
347
- map.value.fitBounds(calculatedBounds, options);
348
- }
344
+
345
+ let paddingRatio = 1
346
+ if(leftOffset.value) {
347
+ paddingRatio = leftOffset.value / map.value.getSize().x
348
+ }
349
+ else if(bottomOffset.value) {
350
+ paddingRatio = bottomOffset.value / map.value.getSize().y
351
+ }
352
+ if(paddingRatio > 0.5) {
353
+ paddingRatio = 0.5;
354
+ }
355
+ const paddedBounds = bounds.pad(paddingRatio);
356
+
357
+ map.value.fitBounds(paddedBounds, options);
358
+ };
349
359
 
350
360
  onMounted(() => {
351
361
  if(!leafletContainer.value) {
@@ -369,7 +379,6 @@ export default defineComponent({
369
379
  });
370
380
 
371
381
  map.value.attributionControl.remove();
372
- // to display google attribution in bottom left corner
373
382
  control.attribution({ position: 'bottomleft' }).addTo(map.value);
374
383
 
375
384
  map.value.on('locationfound', (e: L.LocationEvent) => {
@@ -408,7 +417,7 @@ export default defineComponent({
408
417
  if(!selectedLocation) {
409
418
  return;
410
419
  }
411
- flyTo(selectedLocation?.address.latitude, selectedLocation?.address.longitude);
420
+ flyTo(selectedLocation?.address.latitude, selectedLocation?.address.longitude, defaultZoom, { animate: false });
412
421
  }, { immediate: true });
413
422
 
414
423
  watch(() => props.selectedAreaId, (selectedAreaId) => {
@@ -5,7 +5,7 @@
5
5
  <script lang="ts">
6
6
  import { inject, type PropType, onMounted, type Ref, watch, ref } from 'vue';
7
7
 
8
- import { type Map, type DivIcon, divIcon, type LatLng, marker, type Marker, type MarkerClusterGroup, type Layer } from 'leaflet';
8
+ import { type Map, type DivIcon, divIcon, type LatLng, marker, type Marker, type MarkerClusterGroup } from 'leaflet';
9
9
 
10
10
  import { useColors } from "../../composables";
11
11
 
@@ -37,6 +37,10 @@ export default {
37
37
  type: Boolean,
38
38
  default: false,
39
39
  required: false
40
+ },
41
+ label: {
42
+ type: String,
43
+ required: false
40
44
  }
41
45
  },
42
46
  emits: ['click'],
@@ -63,9 +67,9 @@ export default {
63
67
 
64
68
  if(lastMarker.value) {
65
69
  if(markerClusterGroup && markerClusterGroup.value) {
66
- markerClusterGroup.value.removeLayer(lastMarker.value);
70
+ markerClusterGroup.value.removeLayer(lastMarker.value as Marker);
67
71
  } else {
68
- map.value.removeLayer(lastMarker.value as Layer);
72
+ map.value.removeLayer(lastMarker.value as Marker);
69
73
  }
70
74
  }
71
75
 
@@ -81,7 +85,7 @@ export default {
81
85
  } else if(props.variant === 'location' && props.icon) {
82
86
  const size = 36;
83
87
  icon = divIcon({
84
- html: locationMarkerHtml(props.icon, getColors(props.color).base),
88
+ html: locationMarkerHtml(props.icon, getColors(props.color).base, props.label),
85
89
  iconSize: [size, size],
86
90
  className: props.selected ? 'fs-map-location fs-map-location-selected' : 'fs-map-location',
87
91
  iconAnchor: [size / 2, size / 2],
@@ -110,10 +110,12 @@ export default defineComponent({
110
110
 
111
111
  if (mobileOverlayWrapper.value) {
112
112
  mobileResizeObserver.value.observe(mobileOverlayWrapper.value);
113
+ emit("update:height", mobileOverlayWrapper.value.offsetHeight);
113
114
  }
114
115
 
115
116
  if (desktopOverlay.value) {
116
117
  desktopResizeObserver.value.observe(desktopOverlay.value.$el);
118
+ emit("update:width", desktopOverlay.value.$el.offsetWidth);
117
119
  }
118
120
  });
119
121
 
@@ -47,9 +47,9 @@ export default {
47
47
 
48
48
  if(lastPolygon.value) {
49
49
  if(featureGroup && featureGroup.value) {
50
- featureGroup.value.removeLayer(lastPolygon.value);
50
+ featureGroup.value.removeLayer(lastPolygon.value as Polygon);
51
51
  } else {
52
- map.value.removeLayer(lastPolygon.value);
52
+ map.value.removeLayer(lastPolygon.value as Polygon);
53
53
  }
54
54
  }
55
55
 
@@ -38,11 +38,12 @@
38
38
  </FSSpan>
39
39
  </FSCol>
40
40
  <FSRow
41
+ v-if="$props.deviceCount"
41
42
  :wrap="false"
42
43
  align="center-left"
43
44
  >
44
45
  <FSColor
45
- padding="0 8px"
46
+ width="24px"
46
47
  height="24px"
47
48
  :color="ColorEnum.Light"
48
49
  :border="false"
@@ -53,7 +54,7 @@
53
54
  <FSSpan
54
55
  font="text-overline"
55
56
  >
56
- {{ $props.deviceCount }}
57
+ {{ $props.deviceCount <= 99 ? $props.deviceCount : "99+" }}
57
58
  </FSSpan>
58
59
  </FSRow>
59
60
  </FSColor>
@@ -63,6 +64,32 @@
63
64
  {{ $tr("entity.location.devices", "Devices") }}
64
65
  </FSSpan>
65
66
  </FSRow>
67
+ <FSRow
68
+ v-if="$props.address"
69
+ :wrap="false"
70
+ align="center-left"
71
+ >
72
+ <FSColor
73
+ width="24px"
74
+ height="24px"
75
+ :color="ColorEnum.Light"
76
+ :border="false"
77
+ >
78
+ <FSRow
79
+ align="center-center"
80
+ >
81
+ <FSIcon
82
+ icon="mdi-map-marker"
83
+ size="16px"
84
+ />
85
+ </FSRow>
86
+ </FSColor>
87
+ <FSSpan
88
+ font="text-overline"
89
+ >
90
+ {{ $props.address }}
91
+ </FSSpan>
92
+ </FSRow>
66
93
  </FSCol>
67
94
  <FSIconCard
68
95
  backgroundVariant="standard"
@@ -115,6 +142,10 @@ export default defineComponent({
115
142
  required: false,
116
143
  default: "mdi-map-marker"
117
144
  },
145
+ address: {
146
+ type: String,
147
+ required: false
148
+ },
118
149
  deviceCount: {
119
150
  type: Number,
120
151
  required: false,
@@ -2,13 +2,17 @@ import { computed, ref } from "vue";
2
2
 
3
3
  let initialized = false;
4
4
 
5
- const windowHeight = ref(window.outerHeight);
6
- const windowWidth = ref(window.outerWidth);
5
+ const windowHeight = ref(window.innerHeight);
6
+ const windowWidth = ref(window.innerWidth);
7
+
8
+ const windowOuterWidth = ref(window.outerWidth);
7
9
 
8
10
  export const useBreakpoints = () => {
9
11
  const onSizeChange = (): void => {
10
- windowHeight.value = window.outerHeight;
11
- windowWidth.value = window.outerWidth;
12
+ windowHeight.value = window.innerHeight;
13
+ windowWidth.value = window.innerWidth;
14
+
15
+ windowOuterWidth.value = window.outerWidth;
12
16
  };
13
17
 
14
18
  const isTouchScreenEnabled = computed((): boolean => {
@@ -16,11 +20,11 @@ export const useBreakpoints = () => {
16
20
  });
17
21
 
18
22
  const isMobileSized = computed((): boolean => {
19
- return windowWidth.value < 1264;
23
+ return windowOuterWidth.value < 1264;
20
24
  });
21
25
 
22
26
  const isExtraSmall = computed((): boolean => {
23
- return windowWidth.value < 600;
27
+ return windowOuterWidth.value < 600;
24
28
  });
25
29
 
26
30
  if (!initialized) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-shared-components",
3
3
  "sideEffects": false,
4
- "version": "1.0.85",
4
+ "version": "1.0.87",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,8 +10,8 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@dative-gpi/foundation-shared-domain": "1.0.85",
14
- "@dative-gpi/foundation-shared-services": "1.0.85"
13
+ "@dative-gpi/foundation-shared-domain": "1.0.87",
14
+ "@dative-gpi/foundation-shared-services": "1.0.87"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@dative-gpi/bones-ui": "^1.0.0",
@@ -35,5 +35,5 @@
35
35
  "sass": "1.71.1",
36
36
  "sass-loader": "13.3.2"
37
37
  },
38
- "gitHead": "178fc269ca3ac29c4a0a6e3b1c163b52d1865dbf"
38
+ "gitHead": "180b62cf6fa6a72b6eff933df6f245c7cdc341db"
39
39
  }
@@ -1,6 +1,6 @@
1
- export const locationMarkerHtml = (icon: string, color: string) => {
1
+ export const locationMarkerHtml = (icon: string, color: string, label: string = '') => {
2
2
  const iconHtml = `
3
- <div style="--fs-map-location-pin-color-alpha:${color}50;--fs-map-location-pin-color: ${color}">
3
+ <div title="${label}" style="--fs-map-location-pin-color-alpha:${color}50;--fs-map-location-pin-color: ${color}">
4
4
  <i class="${icon} mdi notranslate v-theme--DefaultTheme fs-icon" aria-hidden="true" style="--fs-icon-font-size: 22px;" />
5
5
  </div>`;
6
6
 
@@ -22,8 +22,8 @@ export const gpsMarkerHtml = () => {
22
22
  return iconHtml;
23
23
  }
24
24
 
25
- export const pinMarkerHtml = (color: string) => {
26
- const iconHtml = `<div style="--fs-map-point-pin-color:${color}" class="fs-map-point-pin" />`;
25
+ export const pinMarkerHtml = (color: string, label: string = "") => {
26
+ const iconHtml = `<div title="${label}" style="--fs-map-point-pin-color:${color}" class="fs-map-point-pin" />`;
27
27
 
28
28
  return iconHtml;
29
29
  }