@dative-gpi/foundation-shared-components 1.0.193 → 1.0.194-dynamic-v-node
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,26 +47,30 @@ export default {
|
|
|
47
47
|
to: {
|
|
48
48
|
type: Object as PropType<RouteLocation | null>,
|
|
49
49
|
required: false
|
|
50
|
+
},
|
|
51
|
+
html: {
|
|
52
|
+
type: String,
|
|
53
|
+
required: false
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
56
|
emits: ['click', 'auxclick'],
|
|
53
57
|
setup(props, { emit }) {
|
|
54
58
|
const map = inject<Ref<Map | null>>(MAP);
|
|
55
59
|
const markerClusterGroup = inject<Ref<MarkerClusterGroup | null>>(MARKERCLUSTERGROUP, ref(null));
|
|
56
|
-
|
|
60
|
+
|
|
57
61
|
const { getColors } = useColors();
|
|
58
62
|
const { handleRoutingEvent } = useRouting();
|
|
59
63
|
|
|
60
|
-
if(!map) {
|
|
64
|
+
if (!map) {
|
|
61
65
|
throw new Error('FSMapTileLayer must be used inside a FSMap component');
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
if(!map.value) {
|
|
68
|
+
if (!map.value) {
|
|
65
69
|
throw new Error('FSMapTileLayer must be used inside a FSMap component with a map');
|
|
66
70
|
}
|
|
67
|
-
|
|
71
|
+
|
|
68
72
|
const getMarkerIcon = () => {
|
|
69
|
-
if(props.variant === 'gps') {
|
|
73
|
+
if (props.variant === 'gps') {
|
|
70
74
|
const size = 16;
|
|
71
75
|
return divIcon({
|
|
72
76
|
html: gpsMarkerHtml(),
|
|
@@ -76,7 +80,7 @@ export default {
|
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
if(props.variant === 'location') {
|
|
83
|
+
if (props.variant === 'location') {
|
|
80
84
|
const size = 36;
|
|
81
85
|
return divIcon({
|
|
82
86
|
html: locationMarkerHtml(props.icon ?? "mdi-map-marker", getColors(props.color).base, props.label),
|
|
@@ -88,7 +92,7 @@ export default {
|
|
|
88
92
|
|
|
89
93
|
const size = 16;
|
|
90
94
|
return divIcon({
|
|
91
|
-
html: pinMarkerHtml(getColors(props.color).base, props.label),
|
|
95
|
+
html: props.html ?? pinMarkerHtml(getColors(props.color).base, props.label),
|
|
92
96
|
iconSize: [size, size],
|
|
93
97
|
className: props.selected ? 'fs-map-marker fs-map-pin fs-map-pin-selected' : 'fs-map-marker fs-map-pin',
|
|
94
98
|
iconAnchor: [size / 2, size / 2],
|
|
@@ -102,11 +106,11 @@ export default {
|
|
|
102
106
|
});
|
|
103
107
|
|
|
104
108
|
const onClick = (event: MouseEvent) => {
|
|
105
|
-
if(props.to) {
|
|
109
|
+
if (props.to) {
|
|
106
110
|
handleRoutingEvent(event, props.to, true);
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
|
-
|
|
113
|
+
|
|
110
114
|
emit('click', {
|
|
111
115
|
...event,
|
|
112
116
|
latlng: props.latlng
|
|
@@ -114,7 +118,7 @@ export default {
|
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
const onAuxClick = (event: MouseEvent) => {
|
|
117
|
-
if(props.to) {
|
|
121
|
+
if (props.to) {
|
|
118
122
|
handleRoutingEvent(event, props.to);
|
|
119
123
|
return;
|
|
120
124
|
}
|
|
@@ -126,11 +130,11 @@ export default {
|
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
watch(map, () => {
|
|
129
|
-
if(!map.value) {
|
|
133
|
+
if (!map.value) {
|
|
130
134
|
return;
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
if(markerClusterGroup && markerClusterGroup.value) {
|
|
137
|
+
if (markerClusterGroup && markerClusterGroup.value) {
|
|
134
138
|
actualMarker.value.addTo(markerClusterGroup.value);
|
|
135
139
|
} else {
|
|
136
140
|
actualMarker.value.addTo(map.value);
|
|
@@ -138,7 +142,7 @@ export default {
|
|
|
138
142
|
}, { immediate: true });
|
|
139
143
|
|
|
140
144
|
watch([() => props.variant, () => props.color, () => props.selected], () => {
|
|
141
|
-
if(!actualMarker.value || !map.value) {
|
|
145
|
+
if (!actualMarker.value || !map.value) {
|
|
142
146
|
return;
|
|
143
147
|
}
|
|
144
148
|
|
|
@@ -147,7 +151,7 @@ export default {
|
|
|
147
151
|
});
|
|
148
152
|
|
|
149
153
|
watch([() => props.latlng?.lat, () => props.latlng?.lng], () => {
|
|
150
|
-
if(!actualMarker.value || !map.value || !props.latlng) {
|
|
154
|
+
if (!actualMarker.value || !map.value || !props.latlng) {
|
|
151
155
|
return;
|
|
152
156
|
}
|
|
153
157
|
|
|
@@ -155,7 +159,7 @@ export default {
|
|
|
155
159
|
});
|
|
156
160
|
|
|
157
161
|
watch(markerElement, (newMarkerElement) => {
|
|
158
|
-
if(!newMarkerElement) {
|
|
162
|
+
if (!newMarkerElement) {
|
|
159
163
|
return;
|
|
160
164
|
}
|
|
161
165
|
|
|
@@ -164,8 +168,8 @@ export default {
|
|
|
164
168
|
}, { immediate: true });
|
|
165
169
|
|
|
166
170
|
onUnmounted(() => {
|
|
167
|
-
if(actualMarker.value && map.value) {
|
|
168
|
-
if(markerClusterGroup && markerClusterGroup.value) {
|
|
171
|
+
if (actualMarker.value && map.value) {
|
|
172
|
+
if (markerClusterGroup && markerClusterGroup.value) {
|
|
169
173
|
markerClusterGroup.value.removeLayer(actualMarker.value as Marker);
|
|
170
174
|
} else {
|
|
171
175
|
map.value.removeLayer(actualMarker.value as Marker);
|
package/composables/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./useBreakpoints";
|
|
|
5
5
|
export * from "./useColors";
|
|
6
6
|
export * from "./useCountUp";
|
|
7
7
|
export * from "./useDebounce";
|
|
8
|
+
export * from "./useDynamicVNode";
|
|
8
9
|
export * from "./useElementVisibility";
|
|
9
10
|
export * from "./useMapLayers";
|
|
10
11
|
export * from "./useRules";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { uuidv4 } from "@dative-gpi/bones-ui";
|
|
2
|
+
import { h, render, nextTick, getCurrentInstance, onBeforeUnmount, type Component, type VNode } from "vue";
|
|
3
|
+
|
|
4
|
+
export function useDynamicVNode<TProps extends Record<string, any>>(component: Component) {
|
|
5
|
+
const id = uuidv4();
|
|
6
|
+
|
|
7
|
+
let vnode: VNode | null = null;
|
|
8
|
+
let container: HTMLElement | null = null;
|
|
9
|
+
|
|
10
|
+
const instance = getCurrentInstance();
|
|
11
|
+
if (!instance) {
|
|
12
|
+
throw new Error("useDynamicVNode must be used inside setup()");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const appContext = instance.appContext;
|
|
16
|
+
|
|
17
|
+
const mount = async (props: TProps) => {
|
|
18
|
+
await nextTick();
|
|
19
|
+
|
|
20
|
+
const mountPoint = document.getElementById(id);
|
|
21
|
+
if (!mountPoint) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
unmount();
|
|
26
|
+
|
|
27
|
+
container = mountPoint;
|
|
28
|
+
|
|
29
|
+
vnode = h(component, props);
|
|
30
|
+
vnode.appContext = appContext;
|
|
31
|
+
|
|
32
|
+
render(vnode, container);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const unmount = () => {
|
|
36
|
+
if (container) {
|
|
37
|
+
render(null, container);
|
|
38
|
+
}
|
|
39
|
+
vnode = null;
|
|
40
|
+
container = null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const sanitizeStyle = (style?: string): string =>
|
|
44
|
+
style
|
|
45
|
+
? style.replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">")
|
|
46
|
+
: "";
|
|
47
|
+
|
|
48
|
+
const getHtml = (style?: string) => {
|
|
49
|
+
const safeStyle = sanitizeStyle(style);
|
|
50
|
+
return `<div id="${id}"${safeStyle ? ` style="${safeStyle}"` : ""}></div>`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
onBeforeUnmount(unmount);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
mount,
|
|
57
|
+
unmount,
|
|
58
|
+
getHtml
|
|
59
|
+
};
|
|
60
|
+
}
|
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.0.
|
|
7
|
+
"version": "1.0.194-dynamic-v-node",
|
|
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.0.
|
|
17
|
-
"@dative-gpi/foundation-shared-services": "1.0.
|
|
16
|
+
"@dative-gpi/foundation-shared-domain": "1.0.194-dynamic-v-node",
|
|
17
|
+
"@dative-gpi/foundation-shared-services": "1.0.194-dynamic-v-node"
|
|
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": "bae28f289de25e748becbaf3e7d5f6c9bdc12934"
|
|
42
42
|
}
|