@fiscozen/dialog 0.1.8 → 0.1.9-beta.3
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 +8 -5
- package/src/FzDialog.vue +48 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiscozen/dialog",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9-beta.3",
|
|
4
4
|
"description": "Design System Dialog component",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"vue": "^3.4.13",
|
|
12
12
|
"@fiscozen/button": "^0.1.6",
|
|
13
13
|
"@fiscozen/style": "^0.1.1",
|
|
14
|
-
"@fiscozen/composables": "^0.1.
|
|
14
|
+
"@fiscozen/composables": "^0.1.12"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
|
18
|
+
"@fortawesome/vue-fontawesome": "^3.0.6",
|
|
17
19
|
"@rushstack/eslint-patch": "^1.3.3",
|
|
18
20
|
"@types/jsdom": "^21.1.6",
|
|
19
21
|
"@types/node": "^18.19.3",
|
|
@@ -21,21 +23,22 @@
|
|
|
21
23
|
"@vitest/coverage-v8": "^1.2.1",
|
|
22
24
|
"@vue/test-utils": "^2.4.3",
|
|
23
25
|
"@vue/tsconfig": "^0.5.0",
|
|
24
|
-
"vite-plugin-dts": "^3.8.3",
|
|
25
26
|
"eslint": "^8.49.0",
|
|
26
27
|
"jsdom": "^23.0.1",
|
|
27
28
|
"prettier": "^3.0.3",
|
|
28
29
|
"typescript": "~5.3.0",
|
|
29
30
|
"vite": "^5.0.10",
|
|
31
|
+
"vite-plugin-dts": "^3.8.3",
|
|
30
32
|
"vitest": "^1.2.0",
|
|
31
33
|
"vue-tsc": "^1.8.25",
|
|
32
|
-
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
|
33
|
-
"@fortawesome/vue-fontawesome": "^3.0.6",
|
|
34
34
|
"@fiscozen/eslint-config": "^0.1.0",
|
|
35
35
|
"@fiscozen/prettier-config": "^0.1.0",
|
|
36
36
|
"@fiscozen/tsconfig": "^0.1.0"
|
|
37
37
|
},
|
|
38
38
|
"license": "MIT",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@fiscozen/composables": "^0.1.12"
|
|
41
|
+
},
|
|
39
42
|
"scripts": {
|
|
40
43
|
"coverage": "vitest run --coverage",
|
|
41
44
|
"format": "prettier --write src/",
|
package/src/FzDialog.vue
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
>
|
|
11
|
-
<
|
|
2
|
+
<div
|
|
3
|
+
v-show="visible"
|
|
4
|
+
class="fz-dialog__backdrop w-screen h-screen fixed flex flex-col items-center justify-center z-30">
|
|
5
|
+
<dialog
|
|
6
|
+
ref="dialog"
|
|
7
|
+
@close="visible = false"
|
|
8
|
+
:class="[dialogStaticClasses, dialogClasses]"
|
|
9
|
+
>
|
|
10
|
+
<div ref="innerDialog" :class="[staticClasses, classes]">
|
|
11
|
+
<div
|
|
12
|
+
class="flex items-center p-12 w-full border-b-1 border-grey-100 border-solid"
|
|
13
|
+
>
|
|
14
|
+
<slot name="header"></slot>
|
|
15
|
+
</div>
|
|
16
|
+
<div :class="['grow', 'p-12', bodyClasses]">
|
|
17
|
+
<slot name="body"></slot>
|
|
18
|
+
</div>
|
|
19
|
+
<div
|
|
20
|
+
v-if="$slots.footer"
|
|
21
|
+
class="flex flex-row p-12 border-t-1 border-grey-100 items-center border-solid"
|
|
22
|
+
>
|
|
23
|
+
<slot name="footer"></slot>
|
|
24
|
+
</div>
|
|
12
25
|
</div>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
</div>
|
|
16
|
-
<div
|
|
17
|
-
v-if="$slots.footer"
|
|
18
|
-
class="flex flex-row p-12 border-t-1 border-grey-100 items-center border-solid"
|
|
19
|
-
>
|
|
20
|
-
<slot name="footer"></slot>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</dialog>
|
|
26
|
+
</dialog>
|
|
27
|
+
</div>
|
|
24
28
|
</template>
|
|
25
29
|
|
|
26
30
|
<script setup lang="ts">
|
|
27
|
-
import { computed, ref
|
|
31
|
+
import { computed, ref } from "vue";
|
|
28
32
|
import { FzDialogProps } from "./types";
|
|
29
33
|
import { useKeyUp } from "@fiscozen/composables";
|
|
34
|
+
import { useClickOutside } from "@fiscozen/composables";
|
|
30
35
|
|
|
31
36
|
const props = withDefaults(defineProps<FzDialogProps>(), {
|
|
32
37
|
size: "md",
|
|
@@ -35,10 +40,17 @@ const props = withDefaults(defineProps<FzDialogProps>(), {
|
|
|
35
40
|
const emit = defineEmits(["fzmodal:cancel"]);
|
|
36
41
|
|
|
37
42
|
const dialog = ref<HTMLDialogElement>();
|
|
43
|
+
const innerDialog = ref<HTMLDivElement>();
|
|
38
44
|
const visible = ref(false);
|
|
39
45
|
|
|
46
|
+
let backdropClickTimeout = false;
|
|
47
|
+
|
|
40
48
|
const showModal = () => {
|
|
41
|
-
|
|
49
|
+
backdropClickTimeout = true;
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
backdropClickTimeout = false;
|
|
52
|
+
}, 100)
|
|
53
|
+
dialog.value!.show();
|
|
42
54
|
visible.value = true;
|
|
43
55
|
};
|
|
44
56
|
|
|
@@ -48,35 +60,26 @@ defineExpose({
|
|
|
48
60
|
visible,
|
|
49
61
|
});
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
event.clientY <= rect.top + rect.height &&
|
|
56
|
-
rect.left <= event.clientX &&
|
|
57
|
-
event.clientX <= rect.left + rect.width;
|
|
58
|
-
if (!isInDialog && props.closeOnBackdrop) {
|
|
63
|
+
useClickOutside(
|
|
64
|
+
innerDialog,
|
|
65
|
+
() => {
|
|
66
|
+
if (!props.closeOnBackdrop) return;
|
|
59
67
|
dialog.value!.close();
|
|
60
68
|
emit("fzmodal:cancel");
|
|
61
|
-
}
|
|
62
|
-
|
|
69
|
+
},
|
|
70
|
+
dialog,
|
|
71
|
+
);
|
|
63
72
|
|
|
64
73
|
const handleKeyUp = (e: KeyboardEvent) => {
|
|
65
74
|
if (!visible.value || e.key !== "Escape") {
|
|
66
75
|
return;
|
|
67
76
|
}
|
|
77
|
+
dialog.value!.close();
|
|
68
78
|
emit("fzmodal:cancel");
|
|
69
79
|
};
|
|
70
80
|
|
|
71
81
|
useKeyUp(handleKeyUp);
|
|
72
82
|
|
|
73
|
-
onMounted(() => {
|
|
74
|
-
dialog.value?.addEventListener("click", handleBackdropClick);
|
|
75
|
-
});
|
|
76
|
-
onUnmounted(() => {
|
|
77
|
-
dialog.value?.removeEventListener("click", handleBackdropClick);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
83
|
const staticClasses = ["flex", "flex-col", "bg-core-white"];
|
|
81
84
|
|
|
82
85
|
const dialogStaticClasses = {
|
|
@@ -175,4 +178,9 @@ dialog::backdrop {
|
|
|
175
178
|
background: var(--core-black, #2c282f);
|
|
176
179
|
opacity: 0.8;
|
|
177
180
|
}
|
|
181
|
+
.fz-dialog__backdrop {
|
|
182
|
+
background-color: rgba(44, 40, 47, 0.8);
|
|
183
|
+
top: 0;
|
|
184
|
+
left: 0;
|
|
185
|
+
}
|
|
178
186
|
</style>
|