@saasmakers/ui 2.0.71 → 2.0.73

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.
@@ -1,7 +1,10 @@
1
1
  <script lang="ts" setup>
2
2
  import type { LayoutBottomSheet } from '../../types/layout'
3
3
 
4
- const props = withDefaults(defineProps<LayoutBottomSheet>(), { 'aria-label': undefined })
4
+ const props = withDefaults(defineProps<LayoutBottomSheet>(), {
5
+ 'aria-label': undefined,
6
+ 'closeOnBackdrop': true,
7
+ })
5
8
 
6
9
  defineSlots<{
7
10
  default?: () => VNode[]
@@ -29,6 +32,12 @@ const closeThreshold = computed(() => {
29
32
  return (panelRef.value?.offsetHeight ?? 320) * closeThresholdRatio
30
33
  })
31
34
 
35
+ function onBackdropClick() {
36
+ if (props.closeOnBackdrop) {
37
+ onClose()
38
+ }
39
+ }
40
+
32
41
  function onClose() {
33
42
  visible.value = false
34
43
  }
@@ -182,7 +191,7 @@ watch(visible, (isVisible) => {
182
191
  :drag-transition="!drag.isDragging && (drag.closing || drag.offset > 0)"
183
192
  :opacity="drag.closing ? 0 : drag.offset > 0 ? Math.max(0, 1 - drag.offset / (panelRef?.offsetHeight ?? 320)) : undefined"
184
193
  :transitionless="drag.isDragging"
185
- @click="onClose"
194
+ @click="onBackdropClick"
186
195
  />
187
196
 
188
197
  <ClientOnly>
@@ -67,28 +67,10 @@ export default function useDialog(
67
67
  }
68
68
  }
69
69
 
70
- watch(visible, async (isVisible) => {
70
+ watch(visible, (isVisible) => {
71
71
  if (import.meta.client && isVisible) {
72
72
  lockBodyScroll()
73
-
74
- await nextTick()
75
-
76
- if (panelRef.value) {
77
- const focusableElements = getFocusableElements(panelRef.value)
78
- const autofocusTarget = panelRef.value.querySelector<HTMLElement>('[data-autofocus]')
79
-
80
- if (autofocusTarget) {
81
- autofocusTarget.focus()
82
- }
83
- else if (focusableElements.length > 0) {
84
- focusableElements[0].focus()
85
- }
86
- else {
87
- panelRef.value.focus()
88
- }
89
-
90
- window.addEventListener('keydown', onFocusTrap)
91
- }
73
+ window.addEventListener('keydown', onFocusTrap)
92
74
  }
93
75
  }, { immediate: true })
94
76
 
@@ -12,6 +12,7 @@ export interface LayoutBackdrop {
12
12
 
13
13
  export interface LayoutBottomSheet {
14
14
  'aria-label'?: string
15
+ 'closeOnBackdrop'?: boolean
15
16
  }
16
17
 
17
18
  export interface LayoutModal {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasmakers/ui",
3
- "version": "2.0.71",
3
+ "version": "2.0.73",
4
4
  "private": false,
5
5
  "description": "Reusable Nuxt UI components for SaaS Makers projects",
6
6
  "license": "MIT",