@bagelink/vue 1.10.27 → 1.10.31

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.10.27",
4
+ "version": "1.10.31",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -90,7 +90,7 @@
90
90
  "signature_pad": "^5.0.9",
91
91
  "vue-i18n": "^11.2.8",
92
92
  "vue-toastification": "^2.0.0-rc.5",
93
- "@bagelink/utils": "1.10.27"
93
+ "@bagelink/utils": "1.10.31"
94
94
  },
95
95
  "scripts": {
96
96
  "dev": "tsx watch src/index.ts",
@@ -9,6 +9,7 @@ export { useDevice } from './useDevice'
9
9
  export { useExcel } from './useExcel'
10
10
  export { useLocalStore } from './useLocalStore'
11
11
  export { usePolling } from './usePolling'
12
+ export { useResizeObserver } from './useResizeObserver'
12
13
  export { useTheme } from './useTheme'
13
14
  interface UseBglSchemaParamsT<T> {
14
15
  schema?: MaybeRefOrGetter<BglFormSchemaT<T>>
@@ -0,0 +1,34 @@
1
+ import type { Ref } from 'vue'
2
+ import { onMounted, onUnmounted, ref } from 'vue'
3
+
4
+ export function useResizeObserver(elementRef: Ref<HTMLElement | undefined>) {
5
+ const width = ref(0)
6
+ const height = ref(0)
7
+ let resizeObserver: ResizeObserver | null = null
8
+
9
+ onMounted(() => {
10
+ if (elementRef.value) {
11
+ resizeObserver = new ResizeObserver((entries) => {
12
+ for (const entry of entries) {
13
+ width.value = entry.contentRect.width
14
+ height.value = entry.contentRect.height
15
+ }
16
+ })
17
+ resizeObserver.observe(elementRef.value)
18
+ width.value = elementRef.value.clientWidth
19
+ height.value = elementRef.value.clientHeight
20
+ }
21
+ })
22
+
23
+ onUnmounted(() => {
24
+ if (resizeObserver) {
25
+ resizeObserver.disconnect()
26
+ resizeObserver = null
27
+ }
28
+ })
29
+
30
+ return {
31
+ width,
32
+ height
33
+ }
34
+ }