@dative-gpi/foundation-shared-components 1.1.9-sandbox-2 → 1.1.10
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.
|
@@ -48,30 +48,26 @@ export default {
|
|
|
48
48
|
to: {
|
|
49
49
|
type: Object as PropType<RouteLocation | null>,
|
|
50
50
|
required: false
|
|
51
|
-
},
|
|
52
|
-
html: {
|
|
53
|
-
type: [String, HTMLElement] as PropType<string | HTMLElement>,
|
|
54
|
-
required: false
|
|
55
51
|
}
|
|
56
52
|
},
|
|
57
53
|
emits: ['click', 'auxclick'],
|
|
58
54
|
setup(props, { emit }) {
|
|
59
55
|
const map = inject<Ref<Map | null>>(MAP);
|
|
60
56
|
const markerClusterGroup = inject<Ref<MarkerClusterGroup | null>>(MARKERCLUSTERGROUP, ref(null));
|
|
61
|
-
|
|
57
|
+
|
|
62
58
|
const { getColors } = useColors();
|
|
63
59
|
const { handleRoutingEvent } = useRouting();
|
|
64
60
|
|
|
65
|
-
if
|
|
61
|
+
if(!map) {
|
|
66
62
|
throw new Error('FSMapTileLayer must be used inside a FSMap component');
|
|
67
63
|
}
|
|
68
64
|
|
|
69
|
-
if
|
|
65
|
+
if(!map.value) {
|
|
70
66
|
throw new Error('FSMapTileLayer must be used inside a FSMap component with a map');
|
|
71
67
|
}
|
|
72
|
-
|
|
68
|
+
|
|
73
69
|
const getMarkerIcon = () => {
|
|
74
|
-
if
|
|
70
|
+
if(props.variant === 'gps') {
|
|
75
71
|
const size = 16;
|
|
76
72
|
return divIcon({
|
|
77
73
|
html: gpsMarkerHtml(),
|
|
@@ -81,7 +77,7 @@ export default {
|
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
if
|
|
80
|
+
if(props.variant === 'location') {
|
|
85
81
|
const size = 36;
|
|
86
82
|
return divIcon({
|
|
87
83
|
html: locationMarkerHtml(props.icon ?? "mdi-map-marker", getColors(props.color).base, props.label),
|
|
@@ -93,7 +89,7 @@ export default {
|
|
|
93
89
|
|
|
94
90
|
const size = 16;
|
|
95
91
|
return divIcon({
|
|
96
|
-
html:
|
|
92
|
+
html: pinMarkerHtml(getColors(props.color).base, props.label),
|
|
97
93
|
iconSize: [size, size],
|
|
98
94
|
className: props.selected ? 'fs-map-marker fs-map-pin fs-map-pin-selected' : 'fs-map-marker fs-map-pin',
|
|
99
95
|
iconAnchor: [size / 2, size / 2],
|
|
@@ -107,11 +103,11 @@ export default {
|
|
|
107
103
|
});
|
|
108
104
|
|
|
109
105
|
const onClick = (event: MouseEvent) => {
|
|
110
|
-
if
|
|
106
|
+
if(props.to) {
|
|
111
107
|
handleRoutingEvent(event, props.to, true);
|
|
112
108
|
return;
|
|
113
109
|
}
|
|
114
|
-
|
|
110
|
+
|
|
115
111
|
emit('click', {
|
|
116
112
|
...event,
|
|
117
113
|
latlng: props.latlng
|
|
@@ -119,7 +115,7 @@ export default {
|
|
|
119
115
|
}
|
|
120
116
|
|
|
121
117
|
const onAuxClick = (event: MouseEvent) => {
|
|
122
|
-
if
|
|
118
|
+
if(props.to) {
|
|
123
119
|
handleRoutingEvent(event, props.to);
|
|
124
120
|
return;
|
|
125
121
|
}
|
|
@@ -131,19 +127,19 @@ export default {
|
|
|
131
127
|
}
|
|
132
128
|
|
|
133
129
|
watch(map, () => {
|
|
134
|
-
if
|
|
130
|
+
if(!map.value) {
|
|
135
131
|
return;
|
|
136
132
|
}
|
|
137
133
|
|
|
138
|
-
if
|
|
134
|
+
if(markerClusterGroup && markerClusterGroup.value) {
|
|
139
135
|
actualMarker.value.addTo(markerClusterGroup.value);
|
|
140
136
|
} else {
|
|
141
137
|
actualMarker.value.addTo(map.value);
|
|
142
138
|
}
|
|
143
139
|
}, { immediate: true });
|
|
144
140
|
|
|
145
|
-
watch([() => props.variant, () => props.color, () => props.selected
|
|
146
|
-
if
|
|
141
|
+
watch([() => props.variant, () => props.color, () => props.selected], () => {
|
|
142
|
+
if(!actualMarker.value || !map.value) {
|
|
147
143
|
return;
|
|
148
144
|
}
|
|
149
145
|
|
|
@@ -152,7 +148,7 @@ export default {
|
|
|
152
148
|
});
|
|
153
149
|
|
|
154
150
|
watch([() => props.latlng?.lat, () => props.latlng?.lng], () => {
|
|
155
|
-
if
|
|
151
|
+
if(!actualMarker.value || !map.value || !props.latlng) {
|
|
156
152
|
return;
|
|
157
153
|
}
|
|
158
154
|
|
|
@@ -160,7 +156,7 @@ export default {
|
|
|
160
156
|
});
|
|
161
157
|
|
|
162
158
|
watch(markerElement, (newMarkerElement) => {
|
|
163
|
-
if
|
|
159
|
+
if(!newMarkerElement) {
|
|
164
160
|
return;
|
|
165
161
|
}
|
|
166
162
|
|
|
@@ -169,8 +165,8 @@ export default {
|
|
|
169
165
|
}, { immediate: true });
|
|
170
166
|
|
|
171
167
|
onUnmounted(() => {
|
|
172
|
-
if
|
|
173
|
-
if
|
|
168
|
+
if(actualMarker.value && map.value) {
|
|
169
|
+
if(markerClusterGroup && markerClusterGroup.value) {
|
|
174
170
|
markerClusterGroup.value.removeLayer(actualMarker.value as Marker);
|
|
175
171
|
} else {
|
|
176
172
|
map.value.removeLayer(actualMarker.value as Marker);
|
package/composables/index.ts
CHANGED
|
@@ -5,7 +5,6 @@ export * from "./useBreakpoints";
|
|
|
5
5
|
export * from "./useColors";
|
|
6
6
|
export * from "./useCountUp";
|
|
7
7
|
export * from "./useDebounce";
|
|
8
|
-
export * from "./useDomRenderer";
|
|
9
8
|
export * from "./useElementVisibility";
|
|
10
9
|
export * from "./useMapLayers";
|
|
11
10
|
export * from "./useResize";
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/Dative-GPI/foundation-shared-ui.git"
|
|
5
5
|
},
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"version": "1.1.
|
|
7
|
+
"version": "1.1.10",
|
|
8
8
|
"description": "",
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@dative-gpi/foundation-shared-domain": "1.1.
|
|
17
|
-
"@dative-gpi/foundation-shared-services": "1.1.
|
|
16
|
+
"@dative-gpi/foundation-shared-domain": "1.1.10",
|
|
17
|
+
"@dative-gpi/foundation-shared-services": "1.1.10"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"sass": "1.71.1",
|
|
39
39
|
"sass-loader": "13.3.2"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "9fab51b9fc34cd8a60f870ef40e5a437115f2f2b"
|
|
42
42
|
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { h, render, getCurrentInstance, onBeforeUnmount, toValue, type Component, type MaybeRefOrGetter, watch } from "vue";
|
|
2
|
-
|
|
3
|
-
interface RenderHandle {
|
|
4
|
-
unsubscribe: () => void;
|
|
5
|
-
getElement: (style?: Partial<CSSStyleDeclaration>) => HTMLElement;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface Subscription {
|
|
9
|
-
container: HTMLElement;
|
|
10
|
-
mountPoint: HTMLElement;
|
|
11
|
-
stopWatching: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function destroySubscription(subscription: Subscription) {
|
|
15
|
-
subscription.stopWatching();
|
|
16
|
-
render(null, subscription.container);
|
|
17
|
-
subscription.container.remove();
|
|
18
|
-
subscription.mountPoint.remove();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function useDomRenderer<TProps extends Record<string, any>>(component: Component<TProps>) {
|
|
22
|
-
|
|
23
|
-
const instance = getCurrentInstance();
|
|
24
|
-
if (!instance) {
|
|
25
|
-
throw new Error("useDomRenderer must be used inside setup()");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const appContext = instance.appContext;
|
|
29
|
-
const subscriptions = new Set<Subscription>();
|
|
30
|
-
|
|
31
|
-
const subscribe = (getProps: MaybeRefOrGetter<TProps>, style?: Partial<CSSStyleDeclaration>): RenderHandle => {
|
|
32
|
-
const mountPoint = document.createElement("div");
|
|
33
|
-
|
|
34
|
-
const container = document.createElement("div");
|
|
35
|
-
mountPoint.appendChild(container);
|
|
36
|
-
|
|
37
|
-
const stopWatching = watch(
|
|
38
|
-
getProps,
|
|
39
|
-
() => {
|
|
40
|
-
const vnode = h(component, toValue(getProps));
|
|
41
|
-
vnode.appContext = appContext;
|
|
42
|
-
render(vnode, container);
|
|
43
|
-
},
|
|
44
|
-
{ immediate: true }
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const subscription: Subscription = { container, mountPoint, stopWatching };
|
|
48
|
-
subscriptions.add(subscription);
|
|
49
|
-
|
|
50
|
-
const unsubscribe = () => {
|
|
51
|
-
if (!subscriptions.has(subscription)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
destroySubscription(subscription);
|
|
55
|
-
subscriptions.delete(subscription);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getElement = (newStyle?: Partial<CSSStyleDeclaration>): HTMLElement => {
|
|
59
|
-
if (!subscriptions.has(subscription)) {
|
|
60
|
-
throw new Error("This render handle has already been unsubscribed");
|
|
61
|
-
}
|
|
62
|
-
mountPoint.style.cssText = "";
|
|
63
|
-
Object.assign(mountPoint.style, style ?? {}, newStyle ?? {});
|
|
64
|
-
return mountPoint;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return { unsubscribe, getElement };
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const unsubscribeAll = () => {
|
|
71
|
-
for (const subscription of subscriptions) {
|
|
72
|
-
destroySubscription(subscription);
|
|
73
|
-
}
|
|
74
|
-
subscriptions.clear();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
onBeforeUnmount(unsubscribeAll);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
subscribe,
|
|
81
|
-
unsubscribeAll,
|
|
82
|
-
};
|
|
83
|
-
}
|