@dolanske/vui 0.3.1 → 0.3.2

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": "@dolanske/vui",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "private": false,
6
6
  "description": "Brother in Christ there's a new UI library ",
7
7
  "author": "dolanske",
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { Icon } from '@iconify/vue'
3
3
  import { useResizeObserver } from '@vueuse/core'
4
- import { ref, useTemplateRef, watch, watchEffect } from 'vue'
4
+ import { onMounted, ref, useTemplateRef, watch, watchEffect } from 'vue'
5
5
  import './accordion.scss'
6
6
 
7
7
  export interface AccordionProps {
@@ -58,10 +58,12 @@ defineExpose({
58
58
  isOpen,
59
59
  })
60
60
 
61
- useResizeObserver(contentRef, ([entry]) => {
62
- if (isOpen.value && contentMaxHeight.value !== entry.contentRect.height) {
63
- contentMaxHeight.value = entry.contentRect.height || 0
64
- }
61
+ onMounted(() => {
62
+ useResizeObserver(contentRef, ([entry]) => {
63
+ if (isOpen.value && contentMaxHeight.value !== entry.contentRect.height) {
64
+ contentMaxHeight.value = entry.contentRect.height || 0
65
+ }
66
+ })
65
67
  })
66
68
  </script>
67
69
 
@@ -2,7 +2,7 @@
2
2
  import { autoUpdate, flip, offset, shift, useFloating } from '@floating-ui/vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import { useClipboard } from '@vueuse/core'
5
- import { onBeforeMount, useSlots, useTemplateRef } from 'vue'
5
+ import { onMounted, useSlots, useTemplateRef } from 'vue'
6
6
  import Flex from '../Flex/Flex.vue'
7
7
  import './copy-clipboard.scss'
8
8
 
@@ -36,7 +36,7 @@ const {
36
36
  })
37
37
  const slots = useSlots()
38
38
 
39
- onBeforeMount(() => {
39
+ onMounted(() => {
40
40
  if (!isSupported.value) {
41
41
  console.error('Clipboard API is not supported. This component will not work')
42
42
  }
@@ -53,7 +53,7 @@ onClickOutside(dropdownRef, (event) => {
53
53
  })
54
54
 
55
55
  const anchorWidth = computed(() => {
56
- if (!expand)
56
+ if (!expand || !window)
57
57
  return 0
58
58
  return anchorRef.value?.getBoundingClientRect().width
59
59
  })
@@ -2,7 +2,7 @@
2
2
  import type { InputProps } from './Input.vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import { useEventListener } from '@vueuse/core'
5
- import { ref, useTemplateRef } from 'vue'
5
+ import { onMounted, ref, useTemplateRef } from 'vue'
6
6
  import Flex from '../Flex/Flex.vue'
7
7
  import Input from './Input.vue'
8
8
 
@@ -25,11 +25,13 @@ function onSubmitHandler(e: any, isFromField?: boolean) {
25
25
 
26
26
  const dropzoneRef = useTemplateRef<HTMLDivElement>('dropzone')
27
27
 
28
- useEventListener(dropzoneRef, 'dragenter', onSubmitHandler, false)
29
- useEventListener(dropzoneRef, 'dragleave', onSubmitHandler, false)
30
- useEventListener(dropzoneRef, 'dragover', onSubmitHandler, false)
31
- useEventListener(dropzoneRef, 'drop', onSubmitHandler, false)
32
- useEventListener(dropzoneRef, 'input', e => onSubmitHandler(e, true), false)
28
+ onMounted(() => {
29
+ useEventListener(dropzoneRef, 'dragenter', onSubmitHandler, false)
30
+ useEventListener(dropzoneRef, 'dragleave', onSubmitHandler, false)
31
+ useEventListener(dropzoneRef, 'dragover', onSubmitHandler, false)
32
+ useEventListener(dropzoneRef, 'drop', onSubmitHandler, false)
33
+ useEventListener(dropzoneRef, 'input', e => onSubmitHandler(e, true), false)
34
+ })
33
35
  </script>
34
36
 
35
37
  <template>
@@ -4,7 +4,7 @@ import { computed, useSlots, useTemplateRef } from 'vue'
4
4
  const slots = useSlots()
5
5
  const contextRef = useTemplateRef<HTMLTableCellElement>('context')
6
6
  const computedStyle = computed(() => {
7
- if (!slots.context)
7
+ if (!slots.context || !window)
8
8
  return {}
9
9
  const width = contextRef.value?.getBoundingClientRect().width ?? 0
10
10
  return {
@@ -27,6 +27,9 @@ const underlineRef = useTemplateRef('underline')
27
27
  const tabsRef = useTemplateRef('tabs')
28
28
 
29
29
  function computeUnderlinePosition() {
30
+ if (!window)
31
+ return
32
+
30
33
  if (tabsRef.value && underlineRef.value) {
31
34
  const activeBounds = tabsRef.value.querySelector('.vui-tab.active')?.getBoundingClientRect()
32
35
  const parentBounds = tabsRef.value.getBoundingClientRect()
@@ -39,6 +42,8 @@ function computeUnderlinePosition() {
39
42
  }
40
43
 
41
44
  onMounted(() => {
45
+ useEventListener(window, 'resize', computeUnderlinePosition)
46
+
42
47
  watch(
43
48
  [active, () => expand],
44
49
  computeUnderlinePosition,
@@ -48,8 +53,6 @@ onMounted(() => {
48
53
  },
49
54
  )
50
55
  })
51
-
52
- useEventListener(window, 'resize', computeUnderlinePosition)
53
56
  </script>
54
57
 
55
58
  <template>