@dative-gpi/foundation-shared-components 1.0.194-sandbox-3 → 1.0.194-sandbox-5

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.
@@ -49,7 +49,7 @@ export default {
49
49
  required: false
50
50
  },
51
51
  html: {
52
- type: String,
52
+ type: [String, HTMLElement] as PropType<string | HTMLElement>,
53
53
  required: false
54
54
  }
55
55
  },
@@ -1,11 +1,10 @@
1
- import { uuidv4 } from "@dative-gpi/bones-ui";
2
- import { h, render, nextTick, getCurrentInstance, onBeforeUnmount, type Component, type VNode } from "vue";
1
+ import { h, render, getCurrentInstance, onBeforeUnmount, type Component, type VNode } from "vue";
3
2
 
4
- export function useDynamicVNode<TProps extends Record<string, any>>(component: Component) {
5
- const id = uuidv4();
3
+ export function useDynamicVNode<TProps extends Record<string, any>>(component: Component<TProps>) {
6
4
 
7
5
  let vnode: VNode | null = null;
8
6
  let container: HTMLElement | null = null;
7
+ let mountPoint: HTMLElement | null = null;
9
8
 
10
9
  const instance = getCurrentInstance();
11
10
  if (!instance) {
@@ -15,11 +14,8 @@ export function useDynamicVNode<TProps extends Record<string, any>>(component: C
15
14
  const appContext = instance.appContext;
16
15
 
17
16
  const mount = async (props: TProps) => {
18
- await nextTick();
19
-
20
- const mountPoint = document.getElementById(id);
21
17
  if (!mountPoint) {
22
- return;
18
+ throw new Error(`You must call getElement() first to create the mount point`);
23
19
  }
24
20
 
25
21
  if (!container) {
@@ -36,19 +32,16 @@ export function useDynamicVNode<TProps extends Record<string, any>>(component: C
36
32
  const unmount = () => {
37
33
  if (container) {
38
34
  render(null, container);
35
+ container.remove();
39
36
  }
40
37
  vnode = null;
41
38
  container = null;
42
39
  };
43
40
 
44
- const sanitizeStyle = (style?: string): string =>
45
- style
46
- ? style.replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
47
- : "";
48
-
49
- const getHtml = (style?: string) => {
50
- const safeStyle = sanitizeStyle(style);
51
- return `<div id="${id}"${safeStyle ? ` style="${safeStyle}"` : ""}></div>`;
41
+ const getElement = (style?: Partial<CSSStyleDeclaration>): HTMLElement => {
42
+ mountPoint = document.createElement("div");
43
+ Object.assign(mountPoint.style, style ?? {});
44
+ return mountPoint;
52
45
  };
53
46
 
54
47
  onBeforeUnmount(unmount);
@@ -56,6 +49,6 @@ export function useDynamicVNode<TProps extends Record<string, any>>(component: C
56
49
  return {
57
50
  mount,
58
51
  unmount,
59
- getHtml
52
+ getElement
60
53
  };
61
54
  }
@@ -1,35 +1,31 @@
1
- import { onMounted, onBeforeUnmount, type Ref } from 'vue';
2
- import type * as echarts from 'echarts';
1
+ import { onMounted, onBeforeUnmount } from 'vue';
3
2
 
4
- export function useResize(chartInstance: Ref<echarts.ECharts | null>) {
3
+ export function useResize(
4
+ getElement: () => HTMLElement | null | undefined,
5
+ onResize: () => void
6
+ ) {
5
7
  let resizeObserver: ResizeObserver | null = null;
6
8
 
7
- const resizeChart = () => {
8
- if (chartInstance.value) {
9
- chartInstance.value.resize();
10
- }
11
- };
12
-
13
9
  onMounted(() => {
14
10
  resizeObserver = new ResizeObserver(() => {
15
- resizeChart();
11
+ onResize();
16
12
  });
17
13
 
18
- const chartElement = chartInstance.value?.getDom();
19
- if (chartElement) {
20
- resizeObserver.observe(chartElement);
14
+ const element = getElement();
15
+ if (element) {
16
+ resizeObserver.observe(element);
21
17
  }
22
18
 
23
- window.addEventListener('resize', resizeChart);
19
+ window.addEventListener('resize', onResize);
24
20
  });
25
21
 
26
22
  onBeforeUnmount(() => {
27
- window.removeEventListener('resize', resizeChart);
23
+ window.removeEventListener('resize', onResize);
28
24
  resizeObserver?.disconnect();
29
25
  resizeObserver = null;
30
26
  });
31
27
 
32
28
  return {
33
- resizeChart
29
+ resize: onResize
34
30
  };
35
31
  }
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.194-sandbox-3",
7
+ "version": "1.0.194-sandbox-5",
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.194-sandbox-3",
17
- "@dative-gpi/foundation-shared-services": "1.0.194-sandbox-3"
16
+ "@dative-gpi/foundation-shared-domain": "1.0.194-sandbox-5",
17
+ "@dative-gpi/foundation-shared-services": "1.0.194-sandbox-5"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@dative-gpi/bones-ui": "^1.0.0",
@@ -30,7 +30,6 @@
30
30
  "@mdi/font": "^7.4.47",
31
31
  "blurhash": "2.0.5",
32
32
  "color": "^4.2.3",
33
- "echarts": "6.0.0",
34
33
  "leaflet": "1.9.4",
35
34
  "leaflet.markercluster": "1.5.3"
36
35
  },
@@ -39,5 +38,5 @@
39
38
  "sass": "1.71.1",
40
39
  "sass-loader": "13.3.2"
41
40
  },
42
- "gitHead": "37b33ba793e53e5fe67567b05fc6be447a0cd022"
41
+ "gitHead": "479e28515d44e7c9602a4717c8eceb44fed607a1"
43
42
  }