@fiscozen/dialog 0.1.9-beta.2 → 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 +10 -7
- package/src/FzDialog.vue +12 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiscozen/dialog",
|
|
3
|
-
"version": "0.1.9-beta.
|
|
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
|
-
"@fiscozen/tsconfig": "^0.1.0",
|
|
35
34
|
"@fiscozen/eslint-config": "^0.1.0",
|
|
36
|
-
"@fiscozen/prettier-config": "^0.1.0"
|
|
35
|
+
"@fiscozen/prettier-config": "^0.1.0",
|
|
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,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
v-show="visible"
|
|
4
|
-
class="fz-dialog__backdrop w-screen h-screen fixed flex flex-col items-center justify-center z-
|
|
4
|
+
class="fz-dialog__backdrop w-screen h-screen fixed flex flex-col items-center justify-center z-30">
|
|
5
5
|
<dialog
|
|
6
6
|
ref="dialog"
|
|
7
7
|
@close="visible = false"
|
|
8
8
|
:class="[dialogStaticClasses, dialogClasses]"
|
|
9
9
|
>
|
|
10
|
-
<div :class="[staticClasses, classes]">
|
|
10
|
+
<div ref="innerDialog" :class="[staticClasses, classes]">
|
|
11
11
|
<div
|
|
12
12
|
class="flex items-center p-12 w-full border-b-1 border-grey-100 border-solid"
|
|
13
13
|
>
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
</template>
|
|
29
29
|
|
|
30
30
|
<script setup lang="ts">
|
|
31
|
-
import { computed, ref
|
|
31
|
+
import { computed, ref } from "vue";
|
|
32
32
|
import { FzDialogProps } from "./types";
|
|
33
33
|
import { useKeyUp } from "@fiscozen/composables";
|
|
34
|
+
import { useClickOutside } from "@fiscozen/composables";
|
|
34
35
|
|
|
35
36
|
const props = withDefaults(defineProps<FzDialogProps>(), {
|
|
36
37
|
size: "md",
|
|
@@ -39,6 +40,7 @@ const props = withDefaults(defineProps<FzDialogProps>(), {
|
|
|
39
40
|
const emit = defineEmits(["fzmodal:cancel"]);
|
|
40
41
|
|
|
41
42
|
const dialog = ref<HTMLDialogElement>();
|
|
43
|
+
const innerDialog = ref<HTMLDivElement>();
|
|
42
44
|
const visible = ref(false);
|
|
43
45
|
|
|
44
46
|
let backdropClickTimeout = false;
|
|
@@ -58,21 +60,15 @@ defineExpose({
|
|
|
58
60
|
visible,
|
|
59
61
|
});
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var rect = dialog.value!.getBoundingClientRect();
|
|
66
|
-
var isInDialog =
|
|
67
|
-
rect.top <= event.clientY &&
|
|
68
|
-
event.clientY <= rect.top + rect.height &&
|
|
69
|
-
rect.left <= event.clientX &&
|
|
70
|
-
event.clientX <= rect.left + rect.width;
|
|
71
|
-
if (!isInDialog && props.closeOnBackdrop) {
|
|
63
|
+
useClickOutside(
|
|
64
|
+
innerDialog,
|
|
65
|
+
() => {
|
|
66
|
+
if (!props.closeOnBackdrop) return;
|
|
72
67
|
dialog.value!.close();
|
|
73
68
|
emit("fzmodal:cancel");
|
|
74
|
-
}
|
|
75
|
-
|
|
69
|
+
},
|
|
70
|
+
dialog,
|
|
71
|
+
);
|
|
76
72
|
|
|
77
73
|
const handleKeyUp = (e: KeyboardEvent) => {
|
|
78
74
|
if (!visible.value || e.key !== "Escape") {
|
|
@@ -84,13 +80,6 @@ const handleKeyUp = (e: KeyboardEvent) => {
|
|
|
84
80
|
|
|
85
81
|
useKeyUp(handleKeyUp);
|
|
86
82
|
|
|
87
|
-
onMounted(() => {
|
|
88
|
-
document.addEventListener("click", handleBackdropClick);
|
|
89
|
-
});
|
|
90
|
-
onUnmounted(() => {
|
|
91
|
-
document.removeEventListener("click", handleBackdropClick);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
83
|
const staticClasses = ["flex", "flex-col", "bg-core-white"];
|
|
95
84
|
|
|
96
85
|
const dialogStaticClasses = {
|