@veritree/ui 0.19.2-3 → 0.19.2-5

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.
Files changed (36) hide show
  1. package/package.json +2 -2
  2. package/src/components/Dialog/VTDialog.vue +1 -1
  3. package/src/components/Dialog/VTDialogClose.vue +9 -9
  4. package/src/components/Dialog/VTDialogContent.vue +9 -9
  5. package/src/components/Dialog/VTDialogFooter.vue +5 -5
  6. package/src/components/Dialog/VTDialogHeader.vue +8 -8
  7. package/src/components/Dialog/VTDialogMain.vue +8 -8
  8. package/src/components/Dialog/VTDialogOverlay.vue +7 -7
  9. package/src/components/Dialog/VTDialogTitle.vue +4 -4
  10. package/src/components/Drawer/VTDrawer.vue +12 -10
  11. package/src/components/Drawer/VTDrawerClose.vue +9 -9
  12. package/src/components/Drawer/VTDrawerContent.vue +8 -8
  13. package/src/components/Drawer/VTDrawerFooter.vue +3 -3
  14. package/src/components/Drawer/VTDrawerHeader.vue +4 -4
  15. package/src/components/Drawer/VTDrawerMain.vue +5 -5
  16. package/src/components/Drawer/VTDrawerOverlay.vue +6 -6
  17. package/src/components/Drawer/VTDrawerTitle.vue +5 -5
  18. package/src/components/DropdownMenu/VTDropdownMenu.vue +3 -3
  19. package/src/components/DropdownMenu/VTDropdownMenuContent.vue +10 -10
  20. package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +3 -3
  21. package/src/components/DropdownMenu/VTDropdownMenuItem.vue +20 -9
  22. package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +27 -37
  23. package/src/components/Listbox/VTListbox.vue +5 -5
  24. package/src/components/Listbox/VTListboxContent.vue +15 -15
  25. package/src/components/Listbox/VTListboxItem.vue +13 -13
  26. package/src/components/Listbox/VTListboxLabel.vue +2 -2
  27. package/src/components/Listbox/VTListboxList.vue +4 -4
  28. package/src/components/Listbox/VTListboxSearch.vue +6 -6
  29. package/src/components/Listbox/VTListboxTrigger.vue +5 -5
  30. package/src/components/Popover/VTPopover.vue +3 -3
  31. package/src/components/Popover/VTPopoverContent.vue +13 -13
  32. package/src/components/Popover/VTPopoverDivider.vue +3 -3
  33. package/src/components/Popover/VTPopoverItem.vue +8 -4
  34. package/src/components/Popover/VTPopoverTrigger.vue +21 -16
  35. package/src/components/Transitions/FadeInOut.vue +2 -2
  36. package/src/utils/genId.js +0 -13
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <transition
3
3
  enter-active-class="duration-200 ease-out"
4
- enter-class="translate-y-[15px] opacity-0"
4
+ enter-from-class="translate-y-[15px] opacity-0"
5
5
  enter-to-class="translate-y-0 opacity-100"
6
6
  leave-active-class="duration-200 ease-in"
7
- leave-class="translate-y-0 opacity-100"
7
+ leave-from-class="translate-y-0 opacity-100"
8
8
  leave-to-class="translate-y-[15px] opacity-0"
9
9
  @after-leave="hide"
10
10
  >
@@ -32,7 +32,7 @@ import { genId } from '../../utils/ids';
32
32
  export default {
33
33
  name: 'VTDropdownMenuContent',
34
34
 
35
- inject: ['api'],
35
+ inject: ['apiDropdownMenu'],
36
36
 
37
37
  data() {
38
38
  return {
@@ -43,30 +43,30 @@ export default {
43
43
 
44
44
  computed: {
45
45
  dark() {
46
- return this.api().isDark;
46
+ return this.apiDropdownMenu().isDark;
47
47
  },
48
48
 
49
49
  headless() {
50
- return this.api().isHeadless;
50
+ return this.apiDropdownMenu().isHeadless;
51
51
  },
52
52
 
53
53
  right() {
54
- return this.api().isRight;
54
+ return this.apiDropdownMenu().isRight;
55
55
  },
56
56
 
57
57
  trigger() {
58
- return this.api().trigger;
58
+ return this.apiDropdownMenu().trigger;
59
59
  },
60
60
  },
61
61
 
62
62
  mounted() {
63
- this.api().registerContent(this);
63
+ this.apiDropdownMenu().registerContent(this);
64
64
 
65
65
  this.$nextTick(() => {
66
66
  if (this.trigger) this.trigger.toggleHasPopup();
67
67
  });
68
68
 
69
- // TODO: Create a directive or mixin for this
69
+ // T-79 Create a directive or mixin for this
70
70
  document.addEventListener('click', (e) => {
71
71
  e.stopPropagation();
72
72
  if (this.visible && !this.$el.contains(e.target)) this.trigger.onClick();
@@ -87,7 +87,7 @@ export default {
87
87
  hide() {
88
88
  this.visible = false;
89
89
  this.$emit('hidden');
90
- this.api().unregisterItems();
90
+ this.apiDropdownMenu().unregisterItems();
91
91
  },
92
92
  },
93
93
  };
@@ -13,15 +13,15 @@
13
13
  export default {
14
14
  name: 'VTDropdownMenuDivider',
15
15
 
16
- inject: ['api'],
16
+ inject: ['apiDropdownMenu'],
17
17
 
18
18
  computed: {
19
19
  dark() {
20
- return this.api().isDark;
20
+ return this.apiDropdownMenu().isDark;
21
21
  },
22
22
 
23
23
  headless() {
24
- return this.api().isHeadless;
24
+ return this.apiDropdownMenu().isHeadless;
25
25
  },
26
26
  },
27
27
  };
@@ -33,7 +33,7 @@ import { genId } from '../../utils/ids';
33
33
  export default {
34
34
  name: 'VTDropdownMenuItem',
35
35
 
36
- inject: ['api'],
36
+ inject: ['apiDropdownMenu'],
37
37
 
38
38
  props: {
39
39
  to: {
@@ -60,19 +60,23 @@ export default {
60
60
 
61
61
  computed: {
62
62
  dark() {
63
- return this.api().isDark;
63
+ return this.apiDropdownMenu().isDark;
64
64
  },
65
65
 
66
66
  headless() {
67
- return this.api().isHeadless;
67
+ return this.apiDropdownMenu().isHeadless;
68
68
  },
69
69
 
70
70
  as() {
71
- return this.href ? 'a' : this.to ? 'NuxtLink' : 'button';
71
+ return this.href
72
+ ? 'a'
73
+ : this.to
74
+ ? resolveComponent('NuxtLink')
75
+ : 'button';
72
76
  },
73
77
 
74
78
  items() {
75
- return this.api().items;
79
+ return this.apiDropdownMenu().items;
76
80
  },
77
81
 
78
82
  el() {
@@ -80,11 +84,11 @@ export default {
80
84
  },
81
85
 
82
86
  trigger() {
83
- return this.api().trigger;
87
+ return this.apiDropdownMenu().trigger;
84
88
  },
85
89
 
86
90
  content() {
87
- return this.api().content;
91
+ return this.apiDropdownMenu().content;
88
92
  },
89
93
  },
90
94
 
@@ -94,7 +98,7 @@ export default {
94
98
  el: this.el,
95
99
  };
96
100
 
97
- this.api().registerItem(item);
101
+ this.apiDropdownMenu().registerItem(item);
98
102
 
99
103
  this.index = this.items.length - 1;
100
104
  },
@@ -160,9 +164,16 @@ export default {
160
164
  this.leaveMenu();
161
165
  },
162
166
 
163
- onClick() {
167
+ onClick(ev) {
164
168
  if (this.disabled) return;
165
169
 
170
+ // Nuxtlink doesn't understand enter as a click
171
+ // so, we need to force it here
172
+ if (ev.key === 'Enter') {
173
+ ev.target.click();
174
+ return;
175
+ }
176
+
166
177
  this.$emit('click');
167
178
  this.$nextTick(() => this.leaveMenu());
168
179
  },
@@ -15,32 +15,25 @@
15
15
  export default {
16
16
  name: 'VTDropdownMenuTrigger',
17
17
 
18
- inject: ['api'],
18
+ inject: ['apiDropdownMenu'],
19
19
 
20
20
  data() {
21
21
  return {
22
+ trigger: null,
22
23
  expanded: false,
23
- hasPopup: false,
24
24
  controls: null,
25
+ hasPopup: false,
25
26
  };
26
27
  },
27
28
 
28
29
  computed: {
29
30
  // gets slot element
30
- slotElm() {
31
- return this.$slots.default[0].elm;
32
- },
33
-
34
- slotLength() {
35
- return this.$slots.default.length;
36
- },
37
-
38
31
  content() {
39
- return this.api().content;
32
+ return this.apiDropdownMenu().content;
40
33
  },
41
34
 
42
35
  items() {
43
- return this.api().items;
36
+ return this.apiDropdownMenu().items;
44
37
  },
45
38
 
46
39
  firstMenuItem() {
@@ -53,35 +46,32 @@ export default {
53
46
  },
54
47
 
55
48
  mounted() {
56
- this.api().registerTrigger(this);
57
- this.addEventListenerToSlotElm();
49
+ this.apiDropdownMenu().registerTrigger(this);
50
+ this.setTrigger();
51
+ this.addTriggerEvents();
58
52
  },
59
53
 
60
54
  destroyed() {
61
- this.slotElm.removeEventListener('click', this.onClick());
55
+ this.trigger.removeEventListener('click', this.onClick());
62
56
  },
63
57
 
64
58
  methods: {
65
- /**
66
- * Add event listener to slot element
67
- *
68
- * The click event has to be added to the slot child element
69
- * since we are not setting the onclick on the component
70
- * itself.
71
- *
72
- * Slot must have only one child element. It avoids
73
- * errors related to adding the event listener.
74
- */
75
- addEventListenerToSlotElm() {
76
- if (!this.slotLength) return;
77
-
78
- if (this.slotLength > 1) {
79
- throw new Error('VTPopoverButton only accepts one item in its slot');
80
- }
81
-
82
- this.slotElm.addEventListener('click', (e) => {
83
- e.stopImmediatePropagation();
84
- this.onClick();
59
+ setTrigger() {
60
+ this.trigger = this.$el.querySelector(':first-child');
61
+ },
62
+
63
+ addTriggerEvents() {
64
+ this.trigger.addEventListener('click', (e) => {
65
+ if (this.expanded) {
66
+ this.onClick();
67
+ return;
68
+ }
69
+
70
+ // delay stop propagation to close other visible
71
+ // dropdowns and delay click event to control
72
+ // this dropdown visibility
73
+ setTimeout(() => e.stopImmediatePropagation(), 50);
74
+ setTimeout(() => this.onClick(), 100);
85
75
  });
86
76
  },
87
77
 
@@ -99,9 +89,9 @@ export default {
99
89
  * Focus slot element if it exists and toggle expanded
100
90
  */
101
91
  focus() {
102
- if (!this.slotElm) return;
92
+ if (!this.trigger) return;
103
93
 
104
- this.slotElm.focus();
94
+ this.trigger.focus();
105
95
  this.toggleExpanded();
106
96
  },
107
97
 
@@ -5,14 +5,14 @@
5
5
  </template>
6
6
 
7
7
  <script>
8
- import { genId } from "../../utils/ids";
8
+ import { genId } from '../../utils/ids';
9
9
 
10
10
  export default {
11
- name: "VTListbox",
11
+ name: 'VTListbox',
12
12
 
13
13
  provide() {
14
14
  return {
15
- api: () => {
15
+ apiListbox: () => {
16
16
  const { dark: isDark, right: isRight } = this;
17
17
  const { id, listbox, trigger, content, search, list, items } = this;
18
18
 
@@ -47,8 +47,8 @@ export default {
47
47
  };
48
48
 
49
49
  const emit = (value) => {
50
- this.$emit("input", value);
51
- this.$emit("change", value);
50
+ this.$emit('input', value);
51
+ this.$emit('change', value);
52
52
  };
53
53
 
54
54
  return {
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <transition
3
3
  enter-active-class="duration-200 ease-out"
4
- enter-class="translate-y-[15px] opacity-0"
4
+ enter-from-class="translate-y-[15px] opacity-0"
5
5
  enter-to-class="translate-y-0 opacity-100"
6
6
  leave-active-class="duration-200 ease-in"
7
- leave-class="translate-y-0 opacity-100"
7
+ leave-from-class="translate-y-0 opacity-100"
8
8
  leave-to-class="translate-y-[15px] opacity-0"
9
9
  @after-leave="hide"
10
10
  >
@@ -32,12 +32,12 @@
32
32
  </template>
33
33
 
34
34
  <script>
35
- import { genId } from "../../utils/ids";
35
+ import { genId } from '../../utils/ids';
36
36
 
37
37
  export default {
38
- name: "VTListboxContent",
38
+ name: 'VTListboxContent',
39
39
 
40
- inject: ["api"],
40
+ inject: ['apiListbox'],
41
41
 
42
42
  props: {
43
43
  headless: {
@@ -64,23 +64,23 @@ export default {
64
64
 
65
65
  computed: {
66
66
  dark() {
67
- return this.api().isDark;
67
+ return this.apiListbox().isDark;
68
68
  },
69
69
 
70
70
  right() {
71
- return this.api().isRight;
71
+ return this.apiListbox().isRight;
72
72
  },
73
73
 
74
74
  listbox() {
75
- return this.api().listbox;
75
+ return this.apiListbox().listbox;
76
76
  },
77
77
 
78
78
  trigger() {
79
- return this.api().trigger;
79
+ return this.apiListbox().trigger;
80
80
  },
81
81
 
82
82
  search() {
83
- return this.api().search;
83
+ return this.apiListbox().search;
84
84
  },
85
85
 
86
86
  // directions
@@ -101,18 +101,18 @@ export default {
101
101
  setActiveDescedant: this.setActiveDescedant,
102
102
  };
103
103
 
104
- this.api().registerContent(content);
104
+ this.apiListbox().registerContent(content);
105
105
 
106
- // TODO: Create a directive or mixin for this
107
- document.addEventListener("click", (e) => {
106
+ // T-87 Create a directive or mixin for this
107
+ document.addEventListener('click', (e) => {
108
108
  e.stopPropagation();
109
109
  if (this.visible && !this.$el.contains(e.target)) this.trigger.onClick();
110
110
  });
111
111
  },
112
112
 
113
113
  destroyed() {
114
- // TODO: Create a directive or mixin for this
115
- document.removeEventListener("click", this.trigger.onClick());
114
+ // T-88 Create a directive or mixin for this
115
+ document.removeEventListener('click', this.trigger.onClick());
116
116
  },
117
117
 
118
118
  methods: {
@@ -29,13 +29,13 @@
29
29
  </template>
30
30
 
31
31
  <script>
32
- import { scrollElementIntoView } from "../../utils/components";
33
- import { genId } from "../../utils/ids";
32
+ import { scrollElementIntoView } from '../../utils/components';
33
+ import { genId } from '../../utils/ids';
34
34
 
35
35
  export default {
36
- name: "VTListboxItem",
36
+ name: 'VTListboxItem',
37
37
 
38
- inject: ["api"],
38
+ inject: ['apiListbox'],
39
39
 
40
40
  props: {
41
41
  headless: {
@@ -63,11 +63,11 @@ export default {
63
63
 
64
64
  computed: {
65
65
  dark() {
66
- return this.api().isDark;
66
+ return this.apiListbox().isDark;
67
67
  },
68
68
 
69
69
  items() {
70
- return this.api().items;
70
+ return this.apiListbox().items;
71
71
  },
72
72
 
73
73
  el() {
@@ -75,19 +75,19 @@ export default {
75
75
  },
76
76
 
77
77
  trigger() {
78
- return this.api().trigger;
78
+ return this.apiListbox().trigger;
79
79
  },
80
80
 
81
81
  content() {
82
- return this.api().content;
82
+ return this.apiListbox().content;
83
83
  },
84
84
 
85
85
  list() {
86
- return this.api().list;
86
+ return this.apiListbox().list;
87
87
  },
88
88
 
89
89
  search() {
90
- return this.api().search;
90
+ return this.apiListbox().search;
91
91
  },
92
92
  },
93
93
 
@@ -116,13 +116,13 @@ export default {
116
116
  onClick: this.onClick,
117
117
  };
118
118
 
119
- this.api().registerItem(item);
119
+ this.apiListbox().registerItem(item);
120
120
 
121
121
  this.index = this.items.length - 1;
122
122
  },
123
123
 
124
124
  beforeDestroy() {
125
- this.api().unregisterItem(this.id);
125
+ this.apiListbox().unregisterItem(this.id);
126
126
  },
127
127
 
128
128
  methods: {
@@ -206,7 +206,7 @@ export default {
206
206
  onClick() {
207
207
  if (this.disabled) return;
208
208
 
209
- this.api().emit(this.value);
209
+ this.apiListbox().emit(this.value);
210
210
  this.$nextTick(() => this.leaveMenu());
211
211
  },
212
212
 
@@ -16,7 +16,7 @@
16
16
  export default {
17
17
  name: 'VTListboxLabel',
18
18
 
19
- inject: ['api'],
19
+ inject: ['apiListbox'],
20
20
 
21
21
  props: {
22
22
  as: {
@@ -31,7 +31,7 @@ export default {
31
31
 
32
32
  computed: {
33
33
  dark() {
34
- return this.api().isDark;
34
+ return this.apiListbox().isDark;
35
35
  },
36
36
  },
37
37
  };
@@ -11,12 +11,12 @@
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: "VTListboxList",
17
+ name: 'VTListboxList',
18
18
 
19
- inject: ["api"],
19
+ inject: ['apiListbox'],
20
20
 
21
21
  props: {
22
22
  headless: {
@@ -40,7 +40,7 @@ export default {
40
40
  unsetMousemove: this.unsetMousemove,
41
41
  };
42
42
 
43
- this.api().registerList(list);
43
+ this.apiListbox().registerList(list);
44
44
  },
45
45
 
46
46
  methods: {
@@ -18,7 +18,7 @@
18
18
  export default {
19
19
  name: 'VTListboxSearch',
20
20
 
21
- inject: ['api'],
21
+ inject: ['apiListbox'],
22
22
 
23
23
  props: {
24
24
  headless: {
@@ -36,19 +36,19 @@ export default {
36
36
 
37
37
  computed: {
38
38
  content() {
39
- return this.api().content;
39
+ return this.apiListbox().content;
40
40
  },
41
41
 
42
42
  trigger() {
43
- return this.api().trigger;
43
+ return this.apiListbox().trigger;
44
44
  },
45
45
 
46
46
  list() {
47
- return this.api().list;
47
+ return this.apiListbox().list;
48
48
  },
49
49
 
50
50
  items() {
51
- return this.api().items;
51
+ return this.apiListbox().items;
52
52
  },
53
53
 
54
54
  item() {
@@ -61,7 +61,7 @@ export default {
61
61
  el: this.$el,
62
62
  };
63
63
 
64
- this.api().registerSearch(search);
64
+ this.apiListbox().registerSearch(search);
65
65
  },
66
66
 
67
67
  beforeDestroy() {
@@ -45,7 +45,7 @@ export default {
45
45
 
46
46
  components: { IconChevronDown },
47
47
 
48
- inject: ['api'],
48
+ inject: ['apiListbox'],
49
49
 
50
50
  props: {
51
51
  headless: {
@@ -63,15 +63,15 @@ export default {
63
63
 
64
64
  computed: {
65
65
  dark() {
66
- return this.api().isDark;
66
+ return this.apiListbox().isDark;
67
67
  },
68
68
 
69
69
  content() {
70
- return this.api().content;
70
+ return this.apiListbox().content;
71
71
  },
72
72
 
73
73
  items() {
74
- return this.api().items;
74
+ return this.apiListbox().items;
75
75
  },
76
76
 
77
77
  firstMenuItem() {
@@ -91,7 +91,7 @@ export default {
91
91
  contract: this.contract,
92
92
  };
93
93
 
94
- this.api().registerTrigger(trigger);
94
+ this.apiListbox().registerTrigger(trigger);
95
95
  },
96
96
 
97
97
  methods: {
@@ -10,14 +10,14 @@
10
10
  </template>
11
11
 
12
12
  <script>
13
- import { genId } from "../../utils/ids";
13
+ import { genId } from '../../utils/ids';
14
14
 
15
15
  export default {
16
- name: "VTPopover",
16
+ name: 'VTPopover',
17
17
 
18
18
  provide() {
19
19
  return {
20
- api: () => {
20
+ apiPopover: () => {
21
21
  const { dark: isDark, headless: isHeadless, right: isRight } = this;
22
22
  const { id, button, content } = this;
23
23
 
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <transition
3
3
  enter-active-class="duration-200 ease-out"
4
- enter-class="translate-y-[15px] opacity-0"
4
+ enter-from-class="translate-y-[15px] opacity-0"
5
5
  enter-to-class="translate-y-0 opacity-100"
6
6
  leave-active-class="duration-200 ease-in"
7
- leave-class="translate-y-0 opacity-100"
7
+ leave-from-class="translate-y-0 opacity-100"
8
8
  leave-to-class="translate-y-[15px] opacity-0"
9
9
  @after-leave="hide"
10
10
  >
@@ -26,12 +26,12 @@
26
26
  </template>
27
27
 
28
28
  <script>
29
- import { genId } from "../../utils/ids";
29
+ import { genId } from '../../utils/ids';
30
30
 
31
31
  export default {
32
- name: "VTPopoverContent",
32
+ name: 'VTPopoverContent',
33
33
 
34
- inject: ["api"],
34
+ inject: ['apiPopover'],
35
35
 
36
36
  data() {
37
37
  return {
@@ -42,31 +42,31 @@ export default {
42
42
 
43
43
  computed: {
44
44
  dark() {
45
- return this.api().isDark;
45
+ return this.apiPopover().isDark;
46
46
  },
47
47
 
48
48
  headless() {
49
- return this.api().isHeadless;
49
+ return this.apiPopover().isHeadless;
50
50
  },
51
51
 
52
52
  right() {
53
- return this.api().isRight;
53
+ return this.apiPopover().isRight;
54
54
  },
55
55
  },
56
56
 
57
57
  mounted() {
58
- this.api().registerContent(this);
58
+ this.apiPopover().registerContent(this);
59
59
 
60
- // TODO: Create a directive or mixin for this
61
- document.addEventListener("click", (e) => {
60
+ // T-75 Create a directive or mixin for this
61
+ document.addEventListener('click', (e) => {
62
62
  e.stopPropagation();
63
63
  if (this.visible && !this.$el.contains(e.target)) this.hide();
64
64
  });
65
65
  },
66
66
 
67
67
  destroyed() {
68
- // TODO: Create a directive or mixin for this
69
- document.removeEventListener("click", this.hide());
68
+ // T-76 Create a directive or mixin for this
69
+ document.removeEventListener('click', this.hide());
70
70
  },
71
71
 
72
72
  methods: {
@@ -13,15 +13,15 @@
13
13
  export default {
14
14
  name: 'VTPopoverDivider',
15
15
 
16
- inject: ['api'],
16
+ inject: ['apiPopover'],
17
17
 
18
18
  computed: {
19
19
  dark() {
20
- return this.api().isDark;
20
+ return this.apiPopover().isDark;
21
21
  },
22
22
 
23
23
  headless() {
24
- return this.api().isHeadless;
24
+ return this.apiPopover().isHeadless;
25
25
  },
26
26
  },
27
27
  };