@saasmakers/ui 2.0.27 → 2.0.28
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/app/components/layout/LayoutBackdrop.vue +56 -0
- package/app/components/layout/LayoutBottomSheet.vue +8 -23
- package/app/components/layout/LayoutModal.vue +5 -16
- package/app/types/bases.d.ts +0 -19
- package/app/types/global.d.ts +1 -3
- package/app/types/layout.d.ts +7 -0
- package/package.json +1 -1
- package/app/components/bases/BaseOverlay.vue +0 -97
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { LayoutBackdrop } from '../../types/layout'
|
|
3
|
+
|
|
4
|
+
defineOptions({ inheritAttrs: false })
|
|
5
|
+
|
|
6
|
+
const props = withDefaults(defineProps<LayoutBackdrop>(), {
|
|
7
|
+
dragTransition: false,
|
|
8
|
+
opacity: undefined,
|
|
9
|
+
transitionless: false,
|
|
10
|
+
zIndex: 60,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const emit = defineEmits<{
|
|
14
|
+
click: [event: MouseEvent]
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
const visible = defineModel<boolean>({ default: false })
|
|
18
|
+
|
|
19
|
+
const backdropStyle = computed(() => {
|
|
20
|
+
if (props.opacity === undefined) {
|
|
21
|
+
return { zIndex: props.zIndex }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
opacity: props.opacity,
|
|
26
|
+
zIndex: props.zIndex,
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<ClientOnly>
|
|
33
|
+
<Teleport to="body">
|
|
34
|
+
<Transition
|
|
35
|
+
enter-active-class="transition-opacity duration-300 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
36
|
+
enter-from-class="opacity-0 motion-reduce:opacity-100"
|
|
37
|
+
enter-to-class="opacity-100"
|
|
38
|
+
leave-active-class="transition-opacity duration-300 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
39
|
+
leave-from-class="opacity-100"
|
|
40
|
+
leave-to-class="opacity-0 motion-reduce:opacity-100"
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
v-if="visible"
|
|
44
|
+
aria-hidden="true"
|
|
45
|
+
class="layout-backdrop fixed inset-0 bg-black/50"
|
|
46
|
+
:class="{
|
|
47
|
+
'transition-none motion-reduce:transition-none': transitionless,
|
|
48
|
+
'transition-opacity duration-200 ease motion-reduce:transition-none motion-reduce:duration-0': dragTransition,
|
|
49
|
+
}"
|
|
50
|
+
:style="backdropStyle"
|
|
51
|
+
@click="emit('click', $event)"
|
|
52
|
+
/>
|
|
53
|
+
</Transition>
|
|
54
|
+
</Teleport>
|
|
55
|
+
</ClientOnly>
|
|
56
|
+
</template>
|
|
@@ -177,31 +177,16 @@ watch(visible, (isVisible) => {
|
|
|
177
177
|
</script>
|
|
178
178
|
|
|
179
179
|
<template>
|
|
180
|
+
<LayoutBackdrop
|
|
181
|
+
v-model="visible"
|
|
182
|
+
:drag-transition="!drag.isDragging && (drag.closing || drag.offset > 0)"
|
|
183
|
+
:opacity="drag.closing ? 0 : drag.offset > 0 ? Math.max(0, 1 - drag.offset / (panelRef?.offsetHeight ?? 320)) : undefined"
|
|
184
|
+
:transitionless="drag.isDragging"
|
|
185
|
+
@click="onClose"
|
|
186
|
+
/>
|
|
187
|
+
|
|
180
188
|
<ClientOnly>
|
|
181
189
|
<Teleport to="body">
|
|
182
|
-
<Transition
|
|
183
|
-
enter-active-class="transition-opacity duration-300 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
184
|
-
enter-from-class="opacity-0 motion-reduce:opacity-100"
|
|
185
|
-
enter-to-class="opacity-100"
|
|
186
|
-
leave-active-class="transition-opacity duration-300 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
187
|
-
leave-from-class="opacity-100"
|
|
188
|
-
leave-to-class="opacity-0 motion-reduce:opacity-100"
|
|
189
|
-
>
|
|
190
|
-
<div
|
|
191
|
-
v-if="visible"
|
|
192
|
-
aria-hidden="true"
|
|
193
|
-
class="layout-bottom-sheet fixed inset-0 z-[60] bg-black/50"
|
|
194
|
-
:class="{
|
|
195
|
-
'transition-none motion-reduce:transition-none': drag.isDragging,
|
|
196
|
-
'transition-opacity duration-200 ease motion-reduce:transition-none motion-reduce:duration-0': !drag.isDragging && (drag.closing || drag.offset > 0),
|
|
197
|
-
}"
|
|
198
|
-
:style="{
|
|
199
|
-
opacity: drag.closing ? 0 : drag.offset > 0 ? Math.max(0, 1 - drag.offset / (panelRef?.offsetHeight ?? 320)) : undefined,
|
|
200
|
-
}"
|
|
201
|
-
@click="onClose"
|
|
202
|
-
/>
|
|
203
|
-
</Transition>
|
|
204
|
-
|
|
205
190
|
<Transition
|
|
206
191
|
enter-active-class="transition-transform duration-300 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
207
192
|
enter-from-class="translate-y-full motion-reduce:translate-y-0"
|
|
@@ -17,24 +17,13 @@ function onClose() {
|
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
19
|
<template>
|
|
20
|
+
<LayoutBackdrop
|
|
21
|
+
v-model="visible"
|
|
22
|
+
@click="onClose"
|
|
23
|
+
/>
|
|
24
|
+
|
|
20
25
|
<ClientOnly>
|
|
21
26
|
<Teleport to="body">
|
|
22
|
-
<Transition
|
|
23
|
-
enter-active-class="transition-opacity duration-300 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
24
|
-
enter-from-class="opacity-0 motion-reduce:opacity-100"
|
|
25
|
-
enter-to-class="opacity-100"
|
|
26
|
-
leave-active-class="transition-opacity duration-300 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
27
|
-
leave-from-class="opacity-100"
|
|
28
|
-
leave-to-class="opacity-0 motion-reduce:opacity-100"
|
|
29
|
-
>
|
|
30
|
-
<div
|
|
31
|
-
v-if="visible"
|
|
32
|
-
aria-hidden="true"
|
|
33
|
-
class="layout-modal fixed inset-0 z-[60] bg-black/50"
|
|
34
|
-
@click="onClose"
|
|
35
|
-
/>
|
|
36
|
-
</Transition>
|
|
37
|
-
|
|
38
27
|
<Transition
|
|
39
28
|
enter-active-class="transition duration-200 ease motion-reduce:transition-none motion-reduce:duration-0"
|
|
40
29
|
enter-from-class="opacity-0 scale-95 motion-reduce:scale-100 motion-reduce:opacity-100"
|
package/app/types/bases.d.ts
CHANGED
|
@@ -230,25 +230,6 @@ export type BaseMetricPerformance = 'down' | 'equal' | 'up'
|
|
|
230
230
|
|
|
231
231
|
export type BaseMetricSize = 'base' | 'sm'
|
|
232
232
|
|
|
233
|
-
export interface BaseOverlay {
|
|
234
|
-
active?: boolean
|
|
235
|
-
clickable?: boolean
|
|
236
|
-
fixed?: boolean
|
|
237
|
-
hasClose?: boolean
|
|
238
|
-
opacity?: BaseOverlayOpacity
|
|
239
|
-
position?: BaseOverlayPosition
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export type BaseOverlayOpacity
|
|
243
|
-
= | 0
|
|
244
|
-
| 25
|
|
245
|
-
| 50
|
|
246
|
-
| 75
|
|
247
|
-
| 95
|
|
248
|
-
| 100
|
|
249
|
-
|
|
250
|
-
export type BaseOverlayPosition = 'absolute' | 'fixed'
|
|
251
|
-
|
|
252
233
|
export interface BaseParagraph {
|
|
253
234
|
alignment?: BaseAlignment
|
|
254
235
|
size?: BaseParagraphSize
|
package/app/types/global.d.ts
CHANGED
|
@@ -55,9 +55,6 @@ declare global {
|
|
|
55
55
|
type BaseMetricAlignment = import('./bases').BaseMetricAlignment
|
|
56
56
|
type BaseMetricPerformance = import('./bases').BaseMetricPerformance
|
|
57
57
|
type BaseMetricSize = import('./bases').BaseMetricSize
|
|
58
|
-
type BaseOverlay = import('./bases').BaseOverlay
|
|
59
|
-
type BaseOverlayOpacity = import('./bases').BaseOverlayOpacity
|
|
60
|
-
type BaseOverlayPosition = import('./bases').BaseOverlayPosition
|
|
61
58
|
type BaseParagraph = import('./bases').BaseParagraph
|
|
62
59
|
type BaseParagraphAlignment = import('./bases').BaseParagraphAlignment
|
|
63
60
|
type BaseParagraphSize = import('./bases').BaseParagraphSize
|
|
@@ -117,6 +114,7 @@ declare global {
|
|
|
117
114
|
|
|
118
115
|
// Layout
|
|
119
116
|
type LayoutApps = import('./layout').LayoutApps
|
|
117
|
+
type LayoutBackdrop = import('./layout').LayoutBackdrop
|
|
120
118
|
type LayoutBottomSheet = import('./layout').LayoutBottomSheet
|
|
121
119
|
type LayoutModal = import('./layout').LayoutModal
|
|
122
120
|
|
package/app/types/layout.d.ts
CHANGED
|
@@ -3,6 +3,13 @@ export interface LayoutApps {
|
|
|
3
3
|
playStoreId?: string
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
export interface LayoutBackdrop {
|
|
7
|
+
dragTransition?: boolean
|
|
8
|
+
opacity?: number
|
|
9
|
+
transitionless?: boolean
|
|
10
|
+
zIndex?: number
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
export interface LayoutBottomSheet {
|
|
7
14
|
title?: string
|
|
8
15
|
}
|
package/package.json
CHANGED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { onKeyStroke } from '@vueuse/core'
|
|
3
|
-
import { Motion } from 'motion-v'
|
|
4
|
-
import type { BaseOverlay } from '../../types/bases'
|
|
5
|
-
|
|
6
|
-
const props = withDefaults(defineProps<BaseOverlay>(), {
|
|
7
|
-
active: true,
|
|
8
|
-
clickable: true,
|
|
9
|
-
fixed: true,
|
|
10
|
-
hasClose: true,
|
|
11
|
-
opacity: 75,
|
|
12
|
-
position: 'absolute',
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
const emit = defineEmits<{
|
|
16
|
-
click: [event: MouseEvent]
|
|
17
|
-
close: [event: KeyboardEvent | MouseEvent]
|
|
18
|
-
}>()
|
|
19
|
-
|
|
20
|
-
defineSlots<{
|
|
21
|
-
default?: () => VNode[]
|
|
22
|
-
}>()
|
|
23
|
-
|
|
24
|
-
const isClickable = computed(() => {
|
|
25
|
-
return props.clickable || props.hasClose
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
function onClick(event: MouseEvent) {
|
|
29
|
-
emit('click', event)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function onClose(event: KeyboardEvent | MouseEvent) {
|
|
33
|
-
emit('close', event)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function onKeyDown(event: KeyboardEvent) {
|
|
37
|
-
if (isClickable.value) {
|
|
38
|
-
(event.currentTarget as HTMLElement).click()
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
onKeyStroke('Escape', (event) => {
|
|
43
|
-
event.preventDefault()
|
|
44
|
-
onClose(event)
|
|
45
|
-
})
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<template>
|
|
49
|
-
<div
|
|
50
|
-
:class="{
|
|
51
|
-
'fixed inset-0': fixed,
|
|
52
|
-
'cursor-pointer': isClickable,
|
|
53
|
-
}"
|
|
54
|
-
role="button"
|
|
55
|
-
tabindex="0"
|
|
56
|
-
@click="onClick"
|
|
57
|
-
@keydown.enter="onKeyDown"
|
|
58
|
-
@keydown.space.prevent="onKeyDown"
|
|
59
|
-
>
|
|
60
|
-
<BaseIcon
|
|
61
|
-
v-if="hasClose"
|
|
62
|
-
class="pointer-events-auto absolute right-4 top-4 z-50 text-gray-200 dark:text-gray-800"
|
|
63
|
-
clickable
|
|
64
|
-
:icon="getLayerIcon('close')"
|
|
65
|
-
@click="onClose"
|
|
66
|
-
/>
|
|
67
|
-
|
|
68
|
-
<div
|
|
69
|
-
v-if="$slots.default"
|
|
70
|
-
class="relative z-50 h-full w-full"
|
|
71
|
-
>
|
|
72
|
-
<slot />
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
<Motion
|
|
76
|
-
:animate="fadeIn.animate"
|
|
77
|
-
as="span"
|
|
78
|
-
class="absolute inset-0 z-40"
|
|
79
|
-
:initial="fadeIn.initial"
|
|
80
|
-
>
|
|
81
|
-
<div
|
|
82
|
-
class="inset-0 bg-gray-900 dark:bg-gray-100"
|
|
83
|
-
:class="{
|
|
84
|
-
'h-0 w-0': !active,
|
|
85
|
-
'opacity-0': opacity === 0,
|
|
86
|
-
'opacity-25': opacity === 25,
|
|
87
|
-
'opacity-50': opacity === 50,
|
|
88
|
-
'opacity-75': opacity === 75,
|
|
89
|
-
'opacity-95': opacity === 95,
|
|
90
|
-
'opacity-100': opacity === 100,
|
|
91
|
-
'absolute': position === 'absolute',
|
|
92
|
-
'fixed': position === 'fixed',
|
|
93
|
-
}"
|
|
94
|
-
/>
|
|
95
|
-
</Motion>
|
|
96
|
-
</div>
|
|
97
|
-
</template>
|