@dative-gpi/foundation-shared-components 1.1.7 → 1.1.9-sandbox-1
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,26 +48,30 @@ 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
|
|
51
55
|
}
|
|
52
56
|
},
|
|
53
57
|
emits: ['click', 'auxclick'],
|
|
54
58
|
setup(props, { emit }) {
|
|
55
59
|
const map = inject<Ref<Map | null>>(MAP);
|
|
56
60
|
const markerClusterGroup = inject<Ref<MarkerClusterGroup | null>>(MARKERCLUSTERGROUP, ref(null));
|
|
57
|
-
|
|
61
|
+
|
|
58
62
|
const { getColors } = useColors();
|
|
59
63
|
const { handleRoutingEvent } = useRouting();
|
|
60
64
|
|
|
61
|
-
if(!map) {
|
|
65
|
+
if (!map) {
|
|
62
66
|
throw new Error('FSMapTileLayer must be used inside a FSMap component');
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
if(!map.value) {
|
|
69
|
+
if (!map.value) {
|
|
66
70
|
throw new Error('FSMapTileLayer must be used inside a FSMap component with a map');
|
|
67
71
|
}
|
|
68
|
-
|
|
72
|
+
|
|
69
73
|
const getMarkerIcon = () => {
|
|
70
|
-
if(props.variant === 'gps') {
|
|
74
|
+
if (props.variant === 'gps') {
|
|
71
75
|
const size = 16;
|
|
72
76
|
return divIcon({
|
|
73
77
|
html: gpsMarkerHtml(),
|
|
@@ -77,7 +81,7 @@ export default {
|
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
if(props.variant === 'location') {
|
|
84
|
+
if (props.variant === 'location') {
|
|
81
85
|
const size = 36;
|
|
82
86
|
return divIcon({
|
|
83
87
|
html: locationMarkerHtml(props.icon ?? "mdi-map-marker", getColors(props.color).base, props.label),
|
|
@@ -89,7 +93,7 @@ export default {
|
|
|
89
93
|
|
|
90
94
|
const size = 16;
|
|
91
95
|
return divIcon({
|
|
92
|
-
html: pinMarkerHtml(getColors(props.color).base, props.label),
|
|
96
|
+
html: props.html ?? pinMarkerHtml(getColors(props.color).base, props.label),
|
|
93
97
|
iconSize: [size, size],
|
|
94
98
|
className: props.selected ? 'fs-map-marker fs-map-pin fs-map-pin-selected' : 'fs-map-marker fs-map-pin',
|
|
95
99
|
iconAnchor: [size / 2, size / 2],
|
|
@@ -103,11 +107,11 @@ export default {
|
|
|
103
107
|
});
|
|
104
108
|
|
|
105
109
|
const onClick = (event: MouseEvent) => {
|
|
106
|
-
if(props.to) {
|
|
110
|
+
if (props.to) {
|
|
107
111
|
handleRoutingEvent(event, props.to, true);
|
|
108
112
|
return;
|
|
109
113
|
}
|
|
110
|
-
|
|
114
|
+
|
|
111
115
|
emit('click', {
|
|
112
116
|
...event,
|
|
113
117
|
latlng: props.latlng
|
|
@@ -115,7 +119,7 @@ export default {
|
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
const onAuxClick = (event: MouseEvent) => {
|
|
118
|
-
if(props.to) {
|
|
122
|
+
if (props.to) {
|
|
119
123
|
handleRoutingEvent(event, props.to);
|
|
120
124
|
return;
|
|
121
125
|
}
|
|
@@ -127,19 +131,19 @@ export default {
|
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
watch(map, () => {
|
|
130
|
-
if(!map.value) {
|
|
134
|
+
if (!map.value) {
|
|
131
135
|
return;
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
if(markerClusterGroup && markerClusterGroup.value) {
|
|
138
|
+
if (markerClusterGroup && markerClusterGroup.value) {
|
|
135
139
|
actualMarker.value.addTo(markerClusterGroup.value);
|
|
136
140
|
} else {
|
|
137
141
|
actualMarker.value.addTo(map.value);
|
|
138
142
|
}
|
|
139
143
|
}, { immediate: true });
|
|
140
144
|
|
|
141
|
-
watch([() => props.variant, () => props.color, () => props.selected], () => {
|
|
142
|
-
if(!actualMarker.value || !map.value) {
|
|
145
|
+
watch([() => props.variant, () => props.color, () => props.selected, () => props.html], () => {
|
|
146
|
+
if (!actualMarker.value || !map.value) {
|
|
143
147
|
return;
|
|
144
148
|
}
|
|
145
149
|
|
|
@@ -148,7 +152,7 @@ export default {
|
|
|
148
152
|
});
|
|
149
153
|
|
|
150
154
|
watch([() => props.latlng?.lat, () => props.latlng?.lng], () => {
|
|
151
|
-
if(!actualMarker.value || !map.value || !props.latlng) {
|
|
155
|
+
if (!actualMarker.value || !map.value || !props.latlng) {
|
|
152
156
|
return;
|
|
153
157
|
}
|
|
154
158
|
|
|
@@ -156,7 +160,7 @@ export default {
|
|
|
156
160
|
});
|
|
157
161
|
|
|
158
162
|
watch(markerElement, (newMarkerElement) => {
|
|
159
|
-
if(!newMarkerElement) {
|
|
163
|
+
if (!newMarkerElement) {
|
|
160
164
|
return;
|
|
161
165
|
}
|
|
162
166
|
|
|
@@ -165,8 +169,8 @@ export default {
|
|
|
165
169
|
}, { immediate: true });
|
|
166
170
|
|
|
167
171
|
onUnmounted(() => {
|
|
168
|
-
if(actualMarker.value && map.value) {
|
|
169
|
-
if(markerClusterGroup && markerClusterGroup.value) {
|
|
172
|
+
if (actualMarker.value && map.value) {
|
|
173
|
+
if (markerClusterGroup && markerClusterGroup.value) {
|
|
170
174
|
markerClusterGroup.value.removeLayer(actualMarker.value as Marker);
|
|
171
175
|
} else {
|
|
172
176
|
map.value.removeLayer(actualMarker.value as Marker);
|
|
@@ -6,6 +6,34 @@
|
|
|
6
6
|
<template
|
|
7
7
|
#append-info
|
|
8
8
|
>
|
|
9
|
+
<FSRow
|
|
10
|
+
v-if="$props.groupingLabel && $props.groupingIcon"
|
|
11
|
+
align="center-left"
|
|
12
|
+
:wrap="false"
|
|
13
|
+
>
|
|
14
|
+
<FSColor
|
|
15
|
+
height="24px"
|
|
16
|
+
:color="$props.groupingColor"
|
|
17
|
+
:border="false"
|
|
18
|
+
variant="standard"
|
|
19
|
+
>
|
|
20
|
+
<FSRow
|
|
21
|
+
align="center-center"
|
|
22
|
+
width="24px"
|
|
23
|
+
>
|
|
24
|
+
<FSIcon
|
|
25
|
+
size="16px"
|
|
26
|
+
>
|
|
27
|
+
{{ $props.groupingIcon }}
|
|
28
|
+
</FSIcon>
|
|
29
|
+
</FSRow>
|
|
30
|
+
</FSColor>
|
|
31
|
+
<FSSpan
|
|
32
|
+
font="text-overline"
|
|
33
|
+
>
|
|
34
|
+
{{ $props.groupingLabel }}
|
|
35
|
+
</FSSpan>
|
|
36
|
+
</FSRow>
|
|
9
37
|
<FSEntityCountBadge
|
|
10
38
|
:label="$tr('ui.common.devices', 'Devices')"
|
|
11
39
|
:count="$props.deviceOrganisationsCount ?? 0"
|
|
@@ -16,20 +44,43 @@
|
|
|
16
44
|
</template>
|
|
17
45
|
|
|
18
46
|
<script lang="ts">
|
|
19
|
-
import { defineComponent } from "vue";
|
|
47
|
+
import { defineComponent, type PropType } from "vue";
|
|
20
48
|
|
|
21
|
-
import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
49
|
+
import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
|
|
22
50
|
|
|
23
51
|
import FSEntityCountBadge from "./FSEntityCountBadge.vue";
|
|
24
52
|
import FSSimpleTileUI from './FSSimpleTileUI.vue';
|
|
53
|
+
import FSColor from "../FSColor.vue";
|
|
54
|
+
import FSIcon from "../FSIcon.vue";
|
|
55
|
+
import FSSpan from "../FSSpan.vue";
|
|
56
|
+
import FSRow from "../FSRow.vue";
|
|
25
57
|
|
|
26
58
|
export default defineComponent({
|
|
27
59
|
name: "FSSubgroupingTileUI",
|
|
28
60
|
components: {
|
|
61
|
+
FSEntityCountBadge,
|
|
29
62
|
FSSimpleTileUI,
|
|
30
|
-
|
|
63
|
+
FSColor,
|
|
64
|
+
FSIcon,
|
|
65
|
+
FSSpan,
|
|
66
|
+
FSRow
|
|
31
67
|
},
|
|
32
68
|
props: {
|
|
69
|
+
groupingLabel: {
|
|
70
|
+
type: String as PropType<string | null>,
|
|
71
|
+
required: false,
|
|
72
|
+
default: null
|
|
73
|
+
},
|
|
74
|
+
groupingIcon: {
|
|
75
|
+
type: String as PropType<string | null>,
|
|
76
|
+
required: false,
|
|
77
|
+
default: null
|
|
78
|
+
},
|
|
79
|
+
groupingColor: {
|
|
80
|
+
type: String as PropType<ColorBase>,
|
|
81
|
+
required: false,
|
|
82
|
+
default: ColorEnum.Dark
|
|
83
|
+
},
|
|
33
84
|
deviceOrganisationsCount: {
|
|
34
85
|
type: Number,
|
|
35
86
|
required: false,
|
package/composables/index.ts
CHANGED
|
@@ -5,8 +5,10 @@ export * from "./useBreakpoints";
|
|
|
5
5
|
export * from "./useColors";
|
|
6
6
|
export * from "./useCountUp";
|
|
7
7
|
export * from "./useDebounce";
|
|
8
|
+
export * from "./useDomRenderer";
|
|
8
9
|
export * from "./useElementVisibility";
|
|
9
10
|
export * from "./useMapLayers";
|
|
11
|
+
export * from "./useResize";
|
|
10
12
|
export * from "./useRules";
|
|
11
13
|
export * from "./useSlots";
|
|
12
14
|
export * from "./useTables";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { h, render, getCurrentInstance, onBeforeUnmount, toValue, type Component, type MaybeRefOrGetter, watch } from "vue";
|
|
2
|
+
|
|
3
|
+
interface RenderHandle {
|
|
4
|
+
unmount: () => void;
|
|
5
|
+
getElement: (style?: Partial<CSSStyleDeclaration>) => HTMLElement;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface Subscriber {
|
|
9
|
+
container: HTMLElement | null;
|
|
10
|
+
mountPoint: HTMLElement;
|
|
11
|
+
stopWatching: (() => void) | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useDomRenderer<TProps extends Record<string, any>>(component: Component<TProps>) {
|
|
15
|
+
|
|
16
|
+
const instance = getCurrentInstance();
|
|
17
|
+
if (!instance) {
|
|
18
|
+
throw new Error("useDomRenderer must be used inside setup()");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const appContext = instance.appContext;
|
|
22
|
+
const subscribers = new Map<symbol, Subscriber>();
|
|
23
|
+
|
|
24
|
+
const mount = (getProps: MaybeRefOrGetter<TProps>, style?: Partial<CSSStyleDeclaration>): RenderHandle => {
|
|
25
|
+
const id = Symbol();
|
|
26
|
+
const mountPoint = document.createElement("div");
|
|
27
|
+
Object.assign(mountPoint.style, style ?? {});
|
|
28
|
+
|
|
29
|
+
const container = document.createElement("div");
|
|
30
|
+
mountPoint.appendChild(container);
|
|
31
|
+
|
|
32
|
+
const stopWatching = watch(
|
|
33
|
+
getProps,
|
|
34
|
+
() => {
|
|
35
|
+
const vnode = h(component, toValue(getProps));
|
|
36
|
+
vnode.appContext = appContext;
|
|
37
|
+
render(vnode, container);
|
|
38
|
+
},
|
|
39
|
+
{ immediate: true }
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
subscribers.set(id, { container, mountPoint, stopWatching });
|
|
43
|
+
|
|
44
|
+
const unmount = () => {
|
|
45
|
+
const subscriber = subscribers.get(id);
|
|
46
|
+
if (!subscriber) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (subscriber.stopWatching) {
|
|
51
|
+
subscriber.stopWatching();
|
|
52
|
+
}
|
|
53
|
+
render(null, subscriber.container!);
|
|
54
|
+
subscriber.container!.remove();
|
|
55
|
+
subscriber.mountPoint.remove();
|
|
56
|
+
subscribers.delete(id);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const getElement = (newStyle?: Partial<CSSStyleDeclaration>): HTMLElement => {
|
|
60
|
+
const subscriber = subscribers.get(id);
|
|
61
|
+
if (!subscriber) {
|
|
62
|
+
throw new Error("This render handle has already been unmounted");
|
|
63
|
+
}
|
|
64
|
+
Object.assign(subscriber.mountPoint.style, newStyle ?? {});
|
|
65
|
+
return subscriber.mountPoint;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return { unmount, getElement };
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const unmountAll = () => {
|
|
72
|
+
for (const [id, subscriber] of subscribers) {
|
|
73
|
+
if (subscriber.stopWatching) {
|
|
74
|
+
subscriber.stopWatching();
|
|
75
|
+
}
|
|
76
|
+
render(null, subscriber.container!);
|
|
77
|
+
subscriber.container!.remove();
|
|
78
|
+
subscriber.mountPoint.remove();
|
|
79
|
+
subscribers.delete(id);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
onBeforeUnmount(unmountAll);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
mount,
|
|
87
|
+
unmountAll,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { watch } from 'vue';
|
|
2
|
+
|
|
3
|
+
export function useResize(
|
|
4
|
+
getElement: () => HTMLElement | null | undefined,
|
|
5
|
+
onResize: () => void
|
|
6
|
+
) {
|
|
7
|
+
let resizeObserver: ResizeObserver | null = null;
|
|
8
|
+
|
|
9
|
+
watch(
|
|
10
|
+
() => getElement(),
|
|
11
|
+
(newElement, _, onCleanup) => {
|
|
12
|
+
if (newElement && typeof ResizeObserver !== 'undefined') {
|
|
13
|
+
resizeObserver = new ResizeObserver(() => {
|
|
14
|
+
onResize();
|
|
15
|
+
});
|
|
16
|
+
resizeObserver.observe(newElement);
|
|
17
|
+
|
|
18
|
+
onCleanup(() => {
|
|
19
|
+
resizeObserver?.disconnect();
|
|
20
|
+
resizeObserver = null;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{ immediate: true }
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return {};
|
|
28
|
+
}
|
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.9-sandbox-1",
|
|
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.9-sandbox-1",
|
|
17
|
+
"@dative-gpi/foundation-shared-services": "1.1.9-sandbox-1"
|
|
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": "3c1f52d5262262dcb567c0af3956ee0050ad9126"
|
|
42
42
|
}
|