@veritree/ui 0.4.1 → 0.5.1

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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -4,17 +4,17 @@
4
4
  :id="id"
5
5
  :class="{ Drawer: headless, 'fixed inset-0 z-50 h-screen': !headless }"
6
6
  aria-modal="true"
7
- @click="hide"
7
+ @click="onClick"
8
8
  >
9
9
  <slot></slot>
10
10
  </div>
11
11
  </template>
12
12
 
13
13
  <script>
14
- import { genId } from '~/utils/ids';
14
+ import { genId } from "~/utils/ids";
15
15
 
16
16
  export default {
17
- name: 'VTDrawer',
17
+ name: "VTDrawer",
18
18
 
19
19
  provide() {
20
20
  return {
@@ -53,7 +53,7 @@ export default {
53
53
  },
54
54
 
55
55
  model: {
56
- prop: 'visible',
56
+ prop: "visible",
57
57
  },
58
58
 
59
59
  props: {
@@ -104,10 +104,21 @@ export default {
104
104
 
105
105
  emit() {
106
106
  this.$nextTick(() => {
107
- this.$emit('input', false);
108
- this.$emit('hidden');
107
+ this.$emit("input", false);
108
+ this.$emit("hidden");
109
109
  });
110
110
  },
111
+
112
+ /**
113
+ * Hides the dialog when clicking outside its content.
114
+ *
115
+ * @param {object} event
116
+ */
117
+ onClick(ev) {
118
+ console.log(ev);
119
+ if (!ev || ev.target.id !== this.overlay.id) return;
120
+ this.hide();
121
+ },
111
122
  },
112
123
  };
113
124
  </script>
@@ -3,7 +3,7 @@
3
3
  variant="icon"
4
4
  :class="{
5
5
  'Drawer-close': headless,
6
- 'ml-auto mb-4 text-inherit sm:mb-8': !headless,
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 '@veritree/icons';
16
- import VTButton from '../Button/VTButton.vue';
15
+ import { IconLeft } from "@veritree/icons";
16
+ import VTButton from "../Button/VTButton.vue";
17
17
 
18
18
  export default {
19
- name: 'VTDrawerClose',
19
+ name: "VTDrawerClose",
20
20
 
21
21
  components: { IconLeft, VTButton },
22
22
 
23
- inject: ['api'],
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 ? 'dark' : null;
40
+ return this.dark ? "dark" : null;
41
41
  },
42
42
  },
43
43
 
@@ -14,13 +14,12 @@
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
  }"
21
21
  tabindex="-1"
22
22
  @keyup.esc="hide"
23
- @click.stop
24
23
  >
25
24
  <slot></slot>
26
25
  </div>
@@ -29,9 +28,9 @@
29
28
 
30
29
  <script>
31
30
  export default {
32
- name: 'VTDrawerContent',
31
+ name: "VTDrawerContent",
33
32
 
34
- inject: ['api'],
33
+ inject: ["api"],
35
34
 
36
35
  data() {
37
36
  return {
@@ -53,23 +52,23 @@ export default {
53
52
  },
54
53
 
55
54
  activeClass() {
56
- return 'transform transition duration-300 ease-in-out';
55
+ return "transform transition duration-300 ease-in-out";
57
56
  },
58
57
 
59
58
  enterClass() {
60
- return `opacity-0 ${this.right ? '' : '-'}translate-x-full`;
59
+ return `opacity-0 ${this.right ? "" : "-"}translate-x-full`;
61
60
  },
62
61
 
63
62
  enterToClass() {
64
- return `opacity-100 ${this.right ? '-' : ''}translate-x-0`;
63
+ return `opacity-100 ${this.right ? "-" : ""}translate-x-0`;
65
64
  },
66
65
 
67
66
  leaveClass() {
68
- return `opacity-100 ${this.right ? '-' : ''}translate-x-0`;
67
+ return `opacity-100 ${this.right ? "-" : ""}translate-x-0`;
69
68
  },
70
69
 
71
70
  leaveToClass() {
72
- return `opacity-0 ${this.right ? '' : '-'}translate-x-full`;
71
+ return `opacity-0 ${this.right ? "" : "-"}translate-x-full`;
73
72
  },
74
73
  },
75
74
 
@@ -4,7 +4,7 @@
4
4
  :id="id"
5
5
  :class="{
6
6
  'Drawer-header': headless,
7
- 'mb-8 text-2xl font-semibold': !headless,
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: 'VTDrawerHeader',
16
+ name: "VTDrawerHeader",
17
17
 
18
- inject: ['api'],
18
+ inject: ["api"],
19
19
 
20
20
  props: {
21
21
  as: {
22
22
  type: String,
23
- default: 'header',
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>
@@ -2,6 +2,7 @@
2
2
  <FadeInOut>
3
3
  <div
4
4
  v-if="visible"
5
+ :id="id"
5
6
  :class="{
6
7
  'Drawer-overlay': headless,
7
8
  'fixed inset-0 z-10 bg-fd-450/80': !headless,
@@ -11,14 +12,14 @@
11
12
  </template>
12
13
 
13
14
  <script>
14
- import FadeInOut from '../Transitions/FadeInOut.vue';
15
+ import FadeInOut from "../Transitions/FadeInOut.vue";
15
16
 
16
17
  export default {
17
18
  components: {
18
19
  FadeInOut,
19
20
  },
20
21
 
21
- inject: ['api'],
22
+ inject: ["api"],
22
23
 
23
24
  data() {
24
25
  return {
@@ -34,6 +35,10 @@ export default {
34
35
  headless() {
35
36
  return this.api().isHeadless;
36
37
  },
38
+
39
+ id() {
40
+ return `${this.api().id}-overlay`;
41
+ },
37
42
  },
38
43
 
39
44
  mounted() {
@@ -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>