@veritree/ui 0.4.0 → 0.5.0
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/index.js +2 -0
- package/package.json +1 -1
- package/src/Dialog/VTDialog.vue +23 -7
- package/src/Dialog/VTDialogClose.vue +5 -0
- package/src/Dialog/VTDialogContent.vue +5 -1
- package/src/Dialog/VTDialogOverlay.vue +8 -3
- package/src/Drawer/VTDrawerClose.vue +6 -6
- package/src/Drawer/VTDrawerContent.vue +8 -8
- package/src/Drawer/VTDrawerHeader.vue +4 -19
- package/src/Drawer/VTDrawerTitle.vue +56 -0
package/index.js
CHANGED
|
@@ -44,6 +44,7 @@ import VTDrawerClose from './src/Drawer/VTDrawerClose.vue';
|
|
|
44
44
|
import VTDrawerContent from './src/Drawer/VTDrawerContent.vue';
|
|
45
45
|
import VTDrawerFooter from './src/Drawer/VTDrawerFooter.vue';
|
|
46
46
|
import VTDrawerHeader from './src/Drawer/VTDrawerHeader.vue';
|
|
47
|
+
import VTDrawerTitle from './src/Drawer/VTDrawerTitle.vue';
|
|
47
48
|
import VTDrawerMain from './src/Drawer/VTDrawerMain.vue';
|
|
48
49
|
import VTDrawerOverlay from './src/Drawer/VTDrawerOverlay.vue';
|
|
49
50
|
|
|
@@ -76,6 +77,7 @@ export {
|
|
|
76
77
|
VTDrawerContent,
|
|
77
78
|
VTDrawerFooter,
|
|
78
79
|
VTDrawerHeader,
|
|
80
|
+
VTDrawerTitle,
|
|
79
81
|
VTDrawerMain,
|
|
80
82
|
VTDrawerOverlay,
|
|
81
83
|
VTDialog,
|
package/package.json
CHANGED
package/src/Dialog/VTDialog.vue
CHANGED
|
@@ -7,22 +7,23 @@
|
|
|
7
7
|
'fixed inset-0 z-50 grid grid-cols-1 grid-rows-1 p-4 md:p-8': !headless,
|
|
8
8
|
}"
|
|
9
9
|
aria-modal="true"
|
|
10
|
-
@click="
|
|
10
|
+
@click="onClick"
|
|
11
11
|
>
|
|
12
12
|
<slot></slot>
|
|
13
13
|
</div>
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
|
-
import { genId } from
|
|
17
|
+
import { genId } from "~/utils/ids";
|
|
18
18
|
|
|
19
19
|
export default {
|
|
20
|
-
name:
|
|
20
|
+
name: "VTDialog",
|
|
21
21
|
|
|
22
22
|
provide() {
|
|
23
23
|
return {
|
|
24
24
|
api: () => {
|
|
25
25
|
const id = this.id;
|
|
26
|
+
const componentId = this.componentId;
|
|
26
27
|
const isDark = this.dark;
|
|
27
28
|
const isHeadless = this.headless;
|
|
28
29
|
|
|
@@ -42,6 +43,7 @@ export default {
|
|
|
42
43
|
|
|
43
44
|
return {
|
|
44
45
|
id,
|
|
46
|
+
componentId,
|
|
45
47
|
isDark,
|
|
46
48
|
isHeadless,
|
|
47
49
|
hide,
|
|
@@ -54,7 +56,7 @@ export default {
|
|
|
54
56
|
},
|
|
55
57
|
|
|
56
58
|
model: {
|
|
57
|
-
prop:
|
|
59
|
+
prop: "visible",
|
|
58
60
|
},
|
|
59
61
|
|
|
60
62
|
props: {
|
|
@@ -74,13 +76,17 @@ export default {
|
|
|
74
76
|
|
|
75
77
|
data() {
|
|
76
78
|
return {
|
|
77
|
-
|
|
79
|
+
componentId: genId(),
|
|
78
80
|
content: null,
|
|
79
81
|
overlay: null,
|
|
80
82
|
};
|
|
81
83
|
},
|
|
82
84
|
|
|
83
85
|
computed: {
|
|
86
|
+
id() {
|
|
87
|
+
return `dialog-${this.componentId}`;
|
|
88
|
+
},
|
|
89
|
+
|
|
84
90
|
hasContent() {
|
|
85
91
|
return this.content !== null;
|
|
86
92
|
},
|
|
@@ -109,10 +115,20 @@ export default {
|
|
|
109
115
|
|
|
110
116
|
emit() {
|
|
111
117
|
this.$nextTick(() => {
|
|
112
|
-
this.$emit(
|
|
113
|
-
this.$emit(
|
|
118
|
+
this.$emit("input", false);
|
|
119
|
+
this.$emit("hidden");
|
|
114
120
|
});
|
|
115
121
|
},
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Hides the dialog when clicking outside its content.
|
|
125
|
+
*
|
|
126
|
+
* @param {object} event
|
|
127
|
+
*/
|
|
128
|
+
onClick(ev) {
|
|
129
|
+
if (!ev || ev.target.id !== this.overlay.id) return;
|
|
130
|
+
this.hide();
|
|
131
|
+
},
|
|
116
132
|
},
|
|
117
133
|
};
|
|
118
134
|
</script>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<VTButton
|
|
3
3
|
variant="icon"
|
|
4
|
+
:id="id"
|
|
4
5
|
:class="{
|
|
5
6
|
'Dialog-close': headless,
|
|
6
7
|
}"
|
|
@@ -22,6 +23,10 @@ export default {
|
|
|
22
23
|
inject: ["api"],
|
|
23
24
|
|
|
24
25
|
computed: {
|
|
26
|
+
id() {
|
|
27
|
+
return `dialog-close-${this.api().componentId}`;
|
|
28
|
+
},
|
|
29
|
+
|
|
25
30
|
dark() {
|
|
26
31
|
return this.api().isDark;
|
|
27
32
|
},
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
>
|
|
11
11
|
<div
|
|
12
12
|
v-show="visible"
|
|
13
|
+
:id="id"
|
|
13
14
|
:class="{
|
|
14
15
|
'Dialog-content': headless,
|
|
15
16
|
'relative m-auto max-h-full max-w-full overflow-auto rounded p-6 focus:outline-none sm:p-10':
|
|
@@ -19,7 +20,6 @@
|
|
|
19
20
|
}"
|
|
20
21
|
tabindex="-1"
|
|
21
22
|
@keyup.esc="hide"
|
|
22
|
-
@click.stop
|
|
23
23
|
>
|
|
24
24
|
<slot></slot>
|
|
25
25
|
</div>
|
|
@@ -39,6 +39,10 @@ export default {
|
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
computed: {
|
|
42
|
+
id() {
|
|
43
|
+
return `dialog-content-${this.api().componentId}`;
|
|
44
|
+
},
|
|
45
|
+
|
|
42
46
|
dark() {
|
|
43
47
|
return this.api().isDark;
|
|
44
48
|
},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<FadeInOut>
|
|
3
3
|
<div
|
|
4
4
|
v-if="visible"
|
|
5
|
+
:id="id"
|
|
5
6
|
:class="{
|
|
6
7
|
'Dialog-overlay': headless,
|
|
7
8
|
'fixed inset-0 bg-fd-450/80': !headless,
|
|
@@ -11,16 +12,16 @@
|
|
|
11
12
|
</template>
|
|
12
13
|
|
|
13
14
|
<script>
|
|
14
|
-
import FadeInOut from
|
|
15
|
+
import FadeInOut from "../Transitions/FadeInOut.vue";
|
|
15
16
|
|
|
16
17
|
export default {
|
|
17
|
-
name:
|
|
18
|
+
name: "VTDialogOverlay",
|
|
18
19
|
|
|
19
20
|
components: {
|
|
20
21
|
FadeInOut,
|
|
21
22
|
},
|
|
22
23
|
|
|
23
|
-
inject: [
|
|
24
|
+
inject: ["api"],
|
|
24
25
|
|
|
25
26
|
data() {
|
|
26
27
|
return {
|
|
@@ -29,6 +30,10 @@ export default {
|
|
|
29
30
|
},
|
|
30
31
|
|
|
31
32
|
computed: {
|
|
33
|
+
id() {
|
|
34
|
+
return `dialog-overlay-${this.api().componentId}`;
|
|
35
|
+
},
|
|
36
|
+
|
|
32
37
|
dark() {
|
|
33
38
|
return this.api().isDark;
|
|
34
39
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
variant="icon"
|
|
4
4
|
:class="{
|
|
5
5
|
'Drawer-close': headless,
|
|
6
|
-
'ml-auto
|
|
6
|
+
'ml-auto text-inherit -mr-2': !headless,
|
|
7
7
|
}"
|
|
8
8
|
:theme="theme"
|
|
9
9
|
@click.prevent="hide"
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script>
|
|
15
|
-
import { IconLeft } from
|
|
16
|
-
import VTButton from
|
|
15
|
+
import { IconLeft } from "@veritree/icons";
|
|
16
|
+
import VTButton from "../Button/VTButton.vue";
|
|
17
17
|
|
|
18
18
|
export default {
|
|
19
|
-
name:
|
|
19
|
+
name: "VTDrawerClose",
|
|
20
20
|
|
|
21
21
|
components: { IconLeft, VTButton },
|
|
22
22
|
|
|
23
|
-
inject: [
|
|
23
|
+
inject: ["api"],
|
|
24
24
|
|
|
25
25
|
computed: {
|
|
26
26
|
dark() {
|
|
@@ -37,7 +37,7 @@ export default {
|
|
|
37
37
|
|
|
38
38
|
// temporary till button theme is implemented
|
|
39
39
|
theme() {
|
|
40
|
-
return this.dark ?
|
|
40
|
+
return this.dark ? "dark" : null;
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
43
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
'Drawer-content': headless,
|
|
15
15
|
'absolute z-20 flex h-screen max-h-full max-w-full flex-col overflow-auto p-5 outline-0 sm:px-10 sm:py-6':
|
|
16
16
|
!headless,
|
|
17
|
-
'bg-white': !dark,
|
|
17
|
+
'bg-white text-gray-600': !dark,
|
|
18
18
|
'bg-fd-600': dark,
|
|
19
19
|
'right-0': right,
|
|
20
20
|
}"
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
|
|
30
30
|
<script>
|
|
31
31
|
export default {
|
|
32
|
-
name:
|
|
32
|
+
name: "VTDrawerContent",
|
|
33
33
|
|
|
34
|
-
inject: [
|
|
34
|
+
inject: ["api"],
|
|
35
35
|
|
|
36
36
|
data() {
|
|
37
37
|
return {
|
|
@@ -53,23 +53,23 @@ export default {
|
|
|
53
53
|
},
|
|
54
54
|
|
|
55
55
|
activeClass() {
|
|
56
|
-
return
|
|
56
|
+
return "transform transition duration-300 ease-in-out";
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
enterClass() {
|
|
60
|
-
return `opacity-0 ${this.right ?
|
|
60
|
+
return `opacity-0 ${this.right ? "" : "-"}translate-x-full`;
|
|
61
61
|
},
|
|
62
62
|
|
|
63
63
|
enterToClass() {
|
|
64
|
-
return `opacity-100 ${this.right ?
|
|
64
|
+
return `opacity-100 ${this.right ? "-" : ""}translate-x-0`;
|
|
65
65
|
},
|
|
66
66
|
|
|
67
67
|
leaveClass() {
|
|
68
|
-
return `opacity-100 ${this.right ?
|
|
68
|
+
return `opacity-100 ${this.right ? "-" : ""}translate-x-0`;
|
|
69
69
|
},
|
|
70
70
|
|
|
71
71
|
leaveToClass() {
|
|
72
|
-
return `opacity-0 ${this.right ?
|
|
72
|
+
return `opacity-0 ${this.right ? "" : "-"}translate-x-full`;
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
75
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:id="id"
|
|
5
5
|
:class="{
|
|
6
6
|
'Drawer-header': headless,
|
|
7
|
-
'
|
|
7
|
+
'flex items-center justify-between': !headless,
|
|
8
8
|
}"
|
|
9
9
|
>
|
|
10
10
|
<slot></slot>
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
<script>
|
|
15
15
|
export default {
|
|
16
|
-
name:
|
|
16
|
+
name: "VTDrawerHeader",
|
|
17
17
|
|
|
18
|
-
inject: [
|
|
18
|
+
inject: ["api"],
|
|
19
19
|
|
|
20
20
|
props: {
|
|
21
21
|
as: {
|
|
22
22
|
type: String,
|
|
23
|
-
default:
|
|
23
|
+
default: "header",
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
26
|
|
|
@@ -37,20 +37,5 @@ export default {
|
|
|
37
37
|
return `${this.api().id}-header`;
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
mounted() {
|
|
42
|
-
this.setDialogLabelledby();
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
methods: {
|
|
46
|
-
// In here because if there is no header, the dialog will not be labelled by
|
|
47
|
-
setDialogLabelledby() {
|
|
48
|
-
const dialog = document.getElementById(this.api().id);
|
|
49
|
-
|
|
50
|
-
if (dialog) {
|
|
51
|
-
dialog.setAttribute('aria-labelledby', this.id);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
40
|
};
|
|
56
41
|
</script>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="as"
|
|
4
|
+
:id="id"
|
|
5
|
+
:class="{
|
|
6
|
+
'Drawer-title': headless,
|
|
7
|
+
'mb-8 text-2xl font-semibold': !headless,
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</component>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
name: "VTDrawerTitle",
|
|
17
|
+
|
|
18
|
+
inject: ["api"],
|
|
19
|
+
|
|
20
|
+
props: {
|
|
21
|
+
as: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "div",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
computed: {
|
|
28
|
+
dark() {
|
|
29
|
+
return this.api().isDark;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
headless() {
|
|
33
|
+
return this.api().isHeadless;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
id() {
|
|
37
|
+
return `${this.api().id}-title`;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
mounted() {
|
|
42
|
+
this.setDialogLabelledby();
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
methods: {
|
|
46
|
+
// In here because if there is no header, the dialog will not be labelled by
|
|
47
|
+
setDialogLabelledby() {
|
|
48
|
+
const dialog = document.getElementById(this.api().id);
|
|
49
|
+
|
|
50
|
+
if (dialog) {
|
|
51
|
+
dialog.setAttribute("aria-labelledby", this.id);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
</script>
|