@fiscozen/dialog 0.1.18 → 0.1.20
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 +6 -5
- package/src/FzDialog.vue +27 -75
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiscozen/dialog",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Design System Dialog component",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"tailwindcss": "^3.4.1",
|
|
11
11
|
"vue": "^3.4.13",
|
|
12
12
|
"@fiscozen/style": "^0.1.1",
|
|
13
|
-
"@fiscozen/composables": "^0.1.
|
|
13
|
+
"@fiscozen/composables": "^0.1.29",
|
|
14
14
|
"@fiscozen/button": "^0.1.7"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
@@ -32,12 +32,13 @@
|
|
|
32
32
|
"vitest": "^1.2.0",
|
|
33
33
|
"vue-tsc": "^1.8.25",
|
|
34
34
|
"@fiscozen/eslint-config": "^0.1.0",
|
|
35
|
-
"@fiscozen/
|
|
36
|
-
"@fiscozen/
|
|
35
|
+
"@fiscozen/prettier-config": "^0.1.0",
|
|
36
|
+
"@fiscozen/tsconfig": "^0.1.0"
|
|
37
37
|
},
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"
|
|
40
|
+
"dialog-polyfill": "^0.5.6",
|
|
41
|
+
"@fiscozen/composables": "^0.1.29"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"coverage": "vitest run --coverage",
|
package/src/FzDialog.vue
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
v-if="shouldRender || shouldAlwaysRender"
|
|
4
4
|
ref="backdrop"
|
|
5
5
|
v-show="visible"
|
|
6
|
-
class="fz-dialog__backdrop w-screen h-screen fixed flex flex-col items-center justify-start sm:justify-center z-30"
|
|
6
|
+
class="fz-dialog__backdrop w-screen h-screen fixed flex flex-col items-center justify-start sm:justify-center z-30"
|
|
7
|
+
>
|
|
7
8
|
<dialog
|
|
8
9
|
ref="dialog"
|
|
9
10
|
@close="handleModalClose"
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
>
|
|
16
17
|
<slot name="header"></slot>
|
|
17
18
|
</div>
|
|
18
|
-
<div :class="['grow
|
|
19
|
+
<div :class="['grow p-12', bodyClasses]">
|
|
19
20
|
<slot name="body"></slot>
|
|
20
21
|
</div>
|
|
21
22
|
<div
|
|
@@ -34,10 +35,12 @@ import { computed, ref, watch } from "vue";
|
|
|
34
35
|
import { FzDialogProps } from "./types";
|
|
35
36
|
import { useKeyUp } from "@fiscozen/composables";
|
|
36
37
|
import { useClickOutside } from "@fiscozen/composables";
|
|
38
|
+
import dialogPolyfill from "dialog-polyfill";
|
|
39
|
+
import "dialog-polyfill/dist/dialog-polyfill.css";
|
|
37
40
|
|
|
38
41
|
const props = withDefaults(defineProps<FzDialogProps>(), {
|
|
39
42
|
size: "md",
|
|
40
|
-
closeOnBackdrop: true
|
|
43
|
+
closeOnBackdrop: true,
|
|
41
44
|
});
|
|
42
45
|
const emit = defineEmits(["fzmodal:cancel"]);
|
|
43
46
|
|
|
@@ -54,8 +57,9 @@ const showModal = () => {
|
|
|
54
57
|
setTimeout(() => {
|
|
55
58
|
backdropClickTimeout = false;
|
|
56
59
|
}, 100);
|
|
57
|
-
|
|
60
|
+
|
|
58
61
|
if (props.shouldAlwaysRender) {
|
|
62
|
+
dialogPolyfill.registerDialog(dialog.value!);
|
|
59
63
|
dialog.value!.show();
|
|
60
64
|
visible.value = true;
|
|
61
65
|
} else {
|
|
@@ -76,6 +80,7 @@ function handleModalClose() {
|
|
|
76
80
|
|
|
77
81
|
watch(dialog, (dialog) => {
|
|
78
82
|
if (dialog && shouldRender.value) {
|
|
83
|
+
dialogPolyfill.registerDialog(dialog);
|
|
79
84
|
dialog.show();
|
|
80
85
|
visible.value = true;
|
|
81
86
|
}
|
|
@@ -107,100 +112,43 @@ const handleKeyUp = (e: KeyboardEvent) => {
|
|
|
107
112
|
|
|
108
113
|
useKeyUp(handleKeyUp);
|
|
109
114
|
|
|
110
|
-
const staticClasses =
|
|
111
|
-
|
|
112
|
-
const dialogStaticClasses = {
|
|
113
|
-
"border-1": true,
|
|
114
|
-
rounded: true,
|
|
115
|
-
"border-grey-100": true,
|
|
116
|
-
};
|
|
115
|
+
const staticClasses = "flex flex-col bg-core-white h-dvh max-h-dvh-fallback";
|
|
116
|
+
const dialogStaticClasses = "border-1 rounded border-grey-100 p-0";
|
|
117
117
|
|
|
118
118
|
const dialogClasses = computed(() => {
|
|
119
|
-
let res: string[] = [];
|
|
120
119
|
if (props.isDrawer) {
|
|
121
|
-
|
|
122
|
-
return res;
|
|
120
|
+
return "m-0 fixed top-0 ml-auto max-h-screen";
|
|
123
121
|
}
|
|
122
|
+
|
|
124
123
|
switch (props.size) {
|
|
125
|
-
case "sm":
|
|
126
|
-
res = [];
|
|
127
|
-
break;
|
|
128
124
|
case "md":
|
|
129
|
-
|
|
130
|
-
"xs:max-sm:m-0",
|
|
131
|
-
"xs:max-sm:max-h-screen",
|
|
132
|
-
"xs:max-sm:h-dvh",
|
|
133
|
-
"xs:max-sm:w-dvw",
|
|
134
|
-
"xs:max-sm:max-w-screen-xl",
|
|
135
|
-
];
|
|
136
|
-
break;
|
|
125
|
+
return "xs:max-sm:m-0 xs:max-sm:max-h-screen xs:max-sm:h-dvh xs:max-sm:w-dvw xs:max-sm:max-w-screen-xl";
|
|
137
126
|
case "lg":
|
|
138
|
-
|
|
139
|
-
"xs:max-md:m-0",
|
|
140
|
-
"xs:max-md:max-h-screen",
|
|
141
|
-
"xs:max-md:h-dvh",
|
|
142
|
-
"xs:max-md:w-dvw",
|
|
143
|
-
"xs:max-md:max-w-screen-xl",
|
|
144
|
-
];
|
|
145
|
-
break;
|
|
127
|
+
return "xs:max-md:m-0 xs:max-md:max-h-screen xs:max-md:h-dvh xs:max-md:w-dvw xs:max-md:max-w-screen-xl";
|
|
146
128
|
case "xl":
|
|
147
|
-
|
|
148
|
-
"xs:max-xl:m-0",
|
|
149
|
-
"xs:max-xl:max-h-screen",
|
|
150
|
-
"xs:max-xl:h-dvh",
|
|
151
|
-
"xs:max-xl:w-dvw",
|
|
152
|
-
"xs:max-xl:max-w-screen-xl",
|
|
153
|
-
];
|
|
154
|
-
break;
|
|
155
|
-
default:
|
|
156
|
-
res = [];
|
|
157
|
-
break;
|
|
129
|
+
return "xs:max-xl:m-0 xs:max-xl:max-h-screen xs:max-xl:h-dvh xs:max-xl:w-dvw xs:max-xl:max-w-screen-xl";
|
|
158
130
|
}
|
|
159
|
-
return res;
|
|
160
131
|
});
|
|
161
132
|
|
|
162
133
|
const classes = computed(() => {
|
|
163
|
-
let res: string[] = [];
|
|
164
134
|
if (props.isDrawer) {
|
|
165
|
-
|
|
166
|
-
return res;
|
|
135
|
+
return "w-[480px]";
|
|
167
136
|
}
|
|
137
|
+
|
|
168
138
|
switch (props.size) {
|
|
169
139
|
case "sm":
|
|
170
|
-
|
|
171
|
-
break;
|
|
140
|
+
return "w-[320px] min-h-[200px] max-h-[432px]";
|
|
172
141
|
case "md":
|
|
173
|
-
|
|
174
|
-
"w-dvw sm:w-[480px]",
|
|
175
|
-
"min-h-[300px]",
|
|
176
|
-
"sm:max-h-[600px]",
|
|
177
|
-
"h-dvh sm:h-auto",
|
|
178
|
-
];
|
|
179
|
-
break;
|
|
142
|
+
return "w-dvw sm:w-[480px] min-h-[300px] sm:max-h-[600px] sm:h-auto";
|
|
180
143
|
case "lg":
|
|
181
|
-
|
|
182
|
-
"w-dvw md:w-[640px]",
|
|
183
|
-
"min-h-[300px]",
|
|
184
|
-
"md:max-h-[600px]",
|
|
185
|
-
"h-dvh md:h-auto",
|
|
186
|
-
];
|
|
187
|
-
break;
|
|
144
|
+
return "w-dvw md:w-[640px] min-h-[300px] md:max-h-[600px] md:h-auto";
|
|
188
145
|
case "xl":
|
|
189
|
-
|
|
190
|
-
"w-dvw xl:w-[960px]",
|
|
191
|
-
"min-h-[400px]",
|
|
192
|
-
"xl:max-h-[600px]",
|
|
193
|
-
"h-dvh xl:h-auto",
|
|
194
|
-
];
|
|
195
|
-
break;
|
|
196
|
-
default:
|
|
197
|
-
break;
|
|
146
|
+
return "w-dvw xl:w-[960px] min-h-[400px] xl:max-h-[600px] xl:h-auto";
|
|
198
147
|
}
|
|
199
|
-
return res;
|
|
200
148
|
});
|
|
201
149
|
</script>
|
|
202
150
|
|
|
203
|
-
<style>
|
|
151
|
+
<style scoped>
|
|
204
152
|
dialog::backdrop {
|
|
205
153
|
background: var(--core-black, #2c282f);
|
|
206
154
|
opacity: 0.8;
|
|
@@ -210,4 +158,8 @@ dialog::backdrop {
|
|
|
210
158
|
top: 0;
|
|
211
159
|
left: 0;
|
|
212
160
|
}
|
|
161
|
+
.max-h-dvh-fallback {
|
|
162
|
+
max-height: calc(100vh - 48px); /** If dvh is supported, this gets overridden */
|
|
163
|
+
max-height: 100dvh;
|
|
164
|
+
}
|
|
213
165
|
</style>
|