@fiscozen/composables 0.1.0 → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiscozen/composables",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Design System utility composables",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { ref, useSlots, watch, toRef, computed } from 'vue'
3
3
  import { useFloating } from './composables'
4
- import { FzFloatingPosition, FzFloatingProps, FzUseFloatingArgs } from './types'
4
+ import { FzFloatingProps, FzUseFloatingArgs } from './types'
5
5
 
6
6
  const props = withDefaults(defineProps<FzFloatingProps>(), {
7
7
  position: 'auto',
@@ -9,7 +9,7 @@ const props = withDefaults(defineProps<FzFloatingProps>(), {
9
9
  })
10
10
 
11
11
  const opener = ref(null)
12
- const content = ref(null)
12
+ const content = ref<HTMLElement|null>(null)
13
13
 
14
14
  const slots = useSlots()
15
15
 
@@ -36,7 +36,15 @@ watch(
36
36
  )
37
37
  watch(
38
38
  () => props.isOpen,
39
- (newVal) => newVal && floating.setPosition()
39
+ (newVal) => {
40
+ if (!newVal || !content.value) {
41
+ return;
42
+ }
43
+ content.value.style.top = '0px';
44
+ content.value.style.left = '0px';
45
+ content.value.style.transform = 'none';
46
+ floating.setPosition()
47
+ }
40
48
  )
41
49
  </script>
42
50
 
@@ -49,6 +57,7 @@ watch(
49
57
  ref="content"
50
58
  v-show="!$slots.opener || ($slots.opener && isOpen)"
51
59
  class="bg-core-white absolute p-4"
60
+ :class="contentClass"
52
61
  >
53
62
  <slot :isOpen :floating></slot>
54
63
  </div>
@@ -219,6 +219,9 @@ export const useFloating = (
219
219
 
220
220
  const realPos = calcRealPos(rect.value, float.position, translateX, translateY)
221
221
 
222
+ float.position.x = realPos.x;
223
+ float.position.y = realPos.y;
224
+
222
225
  if (realPos.x < containerRect.left) {
223
226
  float.position.x = containerRect.left;
224
227
  translateX = 0
@@ -241,8 +244,8 @@ export const useFloating = (
241
244
 
242
245
  safeElementDomRef.value.style.top = `${float.position.y}px`
243
246
  safeElementDomRef.value.style.left = `${float.position.x}px`
244
- safeElementDomRef.value.style.transform = `translateY(${translateY}%) translateX(${translateX}%)`
245
247
  safeElementDomRef.value.style.position = 'absolute'
248
+ safeElementDomRef.value.style.display = 'flex'
246
249
 
247
250
  rect.value = safeElementDomRef.value.getBoundingClientRect()
248
251
  })
package/src/types.ts CHANGED
@@ -7,7 +7,8 @@ export type FzFloatingPosition = PositionPrimary | `${PositionPrimary}-${Positio
7
7
  export interface FzFloatingProps {
8
8
  isOpen: boolean
9
9
  position?: FzFloatingPosition
10
- container?: string | null
10
+ container?: string | null,
11
+ contentClass?: string | string[] | Record<string, boolean>
11
12
  }
12
13
 
13
14
  export interface FzAbsolutePosition {