srcdev-nuxt-components 0.0.15 → 0.0.17
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.
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dialog class="display-dialog wrapper" :class="[elementClasses]" :align-dialog="`${positionY}-${positionX}`" :open="displayDialog" ref="dialogRef">
|
|
3
|
+
<focus-trap v-model:active="displayDialog" :clickOutsideDeactivates="true" @deactivate="closeDialog()">
|
|
4
|
+
<div class="inner">
|
|
5
|
+
<div class="top-bar">
|
|
6
|
+
<template v-if="hasDialogTitle">
|
|
7
|
+
<div class="col-left">
|
|
8
|
+
<slot name="dialogTitle"></slot>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<div class="col-center">
|
|
13
|
+
<p class="text-normal wght-700">Center col</p>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="col-right">
|
|
16
|
+
<button @click.prevent="closeDialog()">x</button>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<slot v-if="hasDialogContent" name="dialogContent"></slot>
|
|
20
|
+
<template v-if="hasActionButtons">
|
|
21
|
+
<div class="button-row">
|
|
22
|
+
<slot name="actionButtons"></slot>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
</div>
|
|
26
|
+
</focus-trap>
|
|
27
|
+
</dialog>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import { FocusTrap } from 'focus-trap-vue';
|
|
32
|
+
const props = defineProps({
|
|
33
|
+
styleClassPassthrough: {
|
|
34
|
+
type: Array as PropType<string[]>,
|
|
35
|
+
default: () => [],
|
|
36
|
+
},
|
|
37
|
+
variant: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: 'dialog',
|
|
40
|
+
validator: (val) => ['dialog', 'modal'].includes(val as string),
|
|
41
|
+
},
|
|
42
|
+
positionX: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: 'center',
|
|
45
|
+
validator: (val) => ['left', 'center', 'right'].includes(val as string),
|
|
46
|
+
},
|
|
47
|
+
positionY: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: 'center',
|
|
50
|
+
validator: (val) => ['top', 'center', 'bottom'].includes(val as string),
|
|
51
|
+
},
|
|
52
|
+
lockViewport: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: true,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough);
|
|
59
|
+
|
|
60
|
+
const displayDialog = defineModel<boolean>();
|
|
61
|
+
const bodyTag = ref<HTMLBodyElement | null>(null);
|
|
62
|
+
const lockViewport = toRef<boolean>(props.lockViewport);
|
|
63
|
+
|
|
64
|
+
const closeDialog = () => {
|
|
65
|
+
displayDialog.value = false;
|
|
66
|
+
|
|
67
|
+
if (lockViewport.value && bodyTag.value !== null) {
|
|
68
|
+
bodyTag.value.classList.remove('lock');
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const slots = useSlots();
|
|
73
|
+
const hasDialogTitle = computed(() => slots.dialogTitle !== undefined);
|
|
74
|
+
const hasDialogContent = computed(() => slots.dialogContent !== undefined);
|
|
75
|
+
const hasActionButtons = computed(() => slots.actionButtons !== undefined);
|
|
76
|
+
|
|
77
|
+
onMounted(() => {
|
|
78
|
+
bodyTag.value = document.querySelector('body');
|
|
79
|
+
if (lockViewport.value && bodyTag.value !== null) {
|
|
80
|
+
bodyTag.value.classList.add('lock');
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<style lang="css">
|
|
86
|
+
.display-dialog {
|
|
87
|
+
display: flex;
|
|
88
|
+
|
|
89
|
+
&[align-dialog$='center'] {
|
|
90
|
+
justify-content: center;
|
|
91
|
+
}
|
|
92
|
+
&[align-dialog^='center'] {
|
|
93
|
+
align-items: center;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.wrapper {
|
|
97
|
+
position: fixed;
|
|
98
|
+
left: 0;
|
|
99
|
+
top: 0;
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
backdrop-filter: blur(5px);
|
|
103
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
104
|
+
border: 1px solid var(--color-grey-1);
|
|
105
|
+
z-index: 13;
|
|
106
|
+
opacity: 0;
|
|
107
|
+
|
|
108
|
+
display: none;
|
|
109
|
+
transition: opacity 200ms, display 200ms, overlay 200ms;
|
|
110
|
+
transition-behavior: allow-discrete;
|
|
111
|
+
|
|
112
|
+
&[open] {
|
|
113
|
+
display: flex;
|
|
114
|
+
opacity: 1;
|
|
115
|
+
|
|
116
|
+
@starting-style {
|
|
117
|
+
display: flex;
|
|
118
|
+
opacity: 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.inner {
|
|
124
|
+
background-color: var(--page-bg);
|
|
125
|
+
width: 100vw;
|
|
126
|
+
margin: 12px;
|
|
127
|
+
padding: 12px;
|
|
128
|
+
|
|
129
|
+
@media only screen and (min-width: 768px) {
|
|
130
|
+
width: 720px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* @media only screen and (min-width: 1024px) {
|
|
134
|
+
height: 100dvh;
|
|
135
|
+
width: 100vw;
|
|
136
|
+
} */
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.top-bar {
|
|
140
|
+
display: grid;
|
|
141
|
+
grid-template-columns: auto 1fr auto;
|
|
142
|
+
align-items: center;
|
|
143
|
+
|
|
144
|
+
.col-left {
|
|
145
|
+
/* grid-column: 1; */
|
|
146
|
+
/* display: none; */
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.col-center {
|
|
150
|
+
/* grid-column: 2; */
|
|
151
|
+
text-align: center;
|
|
152
|
+
|
|
153
|
+
color: var(--color-red-1);
|
|
154
|
+
display: none;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.col-right {
|
|
158
|
+
grid-column: 3;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* .button-row {
|
|
163
|
+
display: flex;
|
|
164
|
+
gap: 12px;
|
|
165
|
+
justify-content: flex-end;
|
|
166
|
+
} */
|
|
167
|
+
}
|
|
168
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DisplayDialogCore :styleClassPassthrough :lockViewport="true">
|
|
3
|
+
<template #dialogTitle>
|
|
4
|
+
<slot name="dialogTitle">
|
|
5
|
+
<p class="text-normal wght-700">Confirm</p>
|
|
6
|
+
</slot>
|
|
7
|
+
</template>
|
|
8
|
+
<template #dialogContent>
|
|
9
|
+
<slot name="dialogContent"></slot>
|
|
10
|
+
</template>
|
|
11
|
+
<template #actionButtons>
|
|
12
|
+
<slot name="actionButtonLeft"></slot>
|
|
13
|
+
<slot name="actionButtonRight"></slot>
|
|
14
|
+
</template>
|
|
15
|
+
</DisplayDialogCore>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
styleClassPassthrough: {
|
|
21
|
+
type: Array as PropType<string[]>,
|
|
22
|
+
default: () => [],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<style lang="css">
|
|
28
|
+
.display-dialog {
|
|
29
|
+
&.content-width {
|
|
30
|
+
.inner {
|
|
31
|
+
width: initial;
|
|
32
|
+
|
|
33
|
+
.button-row {
|
|
34
|
+
display: grid;
|
|
35
|
+
gap: 12px;
|
|
36
|
+
grid-template-columns: 1fr 1fr;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
<slot name="trigger"></slot>
|
|
5
5
|
</button>
|
|
6
6
|
|
|
7
|
-
<
|
|
7
|
+
<dialog class="dialog-popover" popover :id="popovertarget" :class="[elementClasses]">
|
|
8
8
|
<slot name="popoverCotent"></slot>
|
|
9
|
-
</
|
|
9
|
+
</dialog>
|
|
10
10
|
</ClientOnly>
|
|
11
11
|
</template>
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srcdev-nuxt-components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.17",
|
|
5
5
|
"main": "nuxt.config.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"clean": "rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"focus-trap-vue": "^4.0.3",
|
|
44
45
|
"modern-normalize": "3.0.1"
|
|
45
46
|
}
|
|
46
47
|
}
|