@veritree/ui 0.19.2-9 → 0.20.0-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.
Files changed (65) hide show
  1. package/index.js +64 -68
  2. package/mixins/floating-ui-content.js +81 -0
  3. package/mixins/floating-ui-item.js +266 -0
  4. package/mixins/floating-ui.js +67 -0
  5. package/mixins/form-control-icon.js +53 -0
  6. package/mixins/form-control.js +71 -0
  7. package/nuxt.js +3 -0
  8. package/package.json +7 -3
  9. package/src/components/Alert/VTAlert.vue +55 -14
  10. package/src/components/Avatar/VTAvatar.vue +32 -29
  11. package/src/components/Button/VTButton.vue +9 -5
  12. package/src/components/Checkbox/VTCheckbox.vue +134 -0
  13. package/src/components/Checkbox/VTCheckboxLabel.vue +3 -0
  14. package/src/components/Checkbox/VTCheckboxText.vue +20 -0
  15. package/src/components/Dialog/VTDialog.vue +16 -21
  16. package/src/components/Dialog/VTDialogClose.vue +13 -19
  17. package/src/components/Dialog/VTDialogContent.vue +17 -12
  18. package/src/components/Dialog/VTDialogFooter.vue +9 -14
  19. package/src/components/Dialog/VTDialogHeader.vue +11 -13
  20. package/src/components/Dialog/VTDialogMain.vue +6 -13
  21. package/src/components/Dialog/VTDialogOverlay.vue +9 -13
  22. package/src/components/Dialog/VTDialogTitle.vue +8 -5
  23. package/src/components/Disclosure/VTDisclosureContent.vue +1 -1
  24. package/src/components/Disclosure/VTDisclosureDetails.vue +1 -1
  25. package/src/components/Disclosure/VTDisclosureHeader.vue +2 -2
  26. package/src/components/Disclosure/VTDisclosureIcon.vue +1 -1
  27. package/src/components/DropdownMenu/VTDropdownMenu.vue +42 -25
  28. package/src/components/DropdownMenu/VTDropdownMenuContent.vue +29 -64
  29. package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +7 -13
  30. package/src/components/DropdownMenu/VTDropdownMenuItem.vue +11 -135
  31. package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +3 -12
  32. package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +95 -115
  33. package/src/components/Form/VTFormFeedback.vue +39 -22
  34. package/src/components/Form/VTFormGroup.vue +5 -7
  35. package/src/components/Form/VTFormLabel.vue +22 -0
  36. package/src/components/Form/VTFormRow.vue +5 -0
  37. package/src/components/Form/VTInput.vue +40 -0
  38. package/src/components/Form/VTInputIcon.vue +35 -0
  39. package/src/components/Form/VTInputPassword.vue +55 -0
  40. package/src/components/Form/VTTextarea.vue +22 -0
  41. package/src/components/Listbox/VTListbox.vue +119 -47
  42. package/src/components/Listbox/VTListboxContent.vue +18 -114
  43. package/src/components/Listbox/VTListboxItem.vue +112 -163
  44. package/src/components/Listbox/VTListboxLabel.vue +3 -14
  45. package/src/components/Listbox/VTListboxList.vue +8 -38
  46. package/src/components/Listbox/VTListboxSearch.vue +75 -67
  47. package/src/components/Listbox/VTListboxTrigger.vue +73 -84
  48. package/src/components/Popover/VTPopover.vue +39 -26
  49. package/src/components/Popover/VTPopoverContent.vue +23 -58
  50. package/src/components/Popover/VTPopoverDivider.vue +4 -11
  51. package/src/components/Popover/VTPopoverItem.vue +13 -10
  52. package/src/components/Popover/VTPopoverTrigger.vue +120 -20
  53. package/src/components/ProgressBar/VTProgressBar.vue +21 -3
  54. package/src/components/Skeleton/VTSkeleton.vue +11 -0
  55. package/src/components/Skeleton/VTSkeletonItem.vue +9 -0
  56. package/src/components/Tabs/VTTab.vue +14 -12
  57. package/src/components/Tabs/VTTabPanel.vue +1 -1
  58. package/src/components/Tooltip/VTTooltip.vue +65 -0
  59. package/src/components/Tooltip/VTTooltipContent.vue +59 -0
  60. package/src/components/Tooltip/VTTooltipTrigger.vue +98 -0
  61. package/src/components/Utils/FloatingUi.vue +93 -0
  62. package/src/components/Input/VTInput.vue +0 -82
  63. package/src/components/Input/VTInputDate.vue +0 -36
  64. package/src/components/Input/VTInputFile.vue +0 -60
  65. package/src/components/Input/VTInputUpload.vue +0 -54
@@ -11,15 +11,13 @@
11
11
  <div
12
12
  v-show="visible"
13
13
  :id="id"
14
- :class="{
15
- 'Dialog-content': headless,
16
- 'relative m-auto max-h-full max-w-full overflow-auto rounded p-6 focus:outline-none sm:p-10 flex flex-col':
17
- !headless,
18
- 'bg-white': !dark,
19
- 'bg-fd-600': dark,
20
- }"
14
+ :class="
15
+ headless
16
+ ? 'dialog-content'
17
+ : `relative m-auto flex flex-col overflow-auto rounded bg-white p-4 focus:outline-none lg:p-6 ${classes}`
18
+ "
21
19
  tabindex="-1"
22
- @keyup.esc="hide"
20
+ @keydown.esc.stop="hide"
23
21
  >
24
22
  <slot></slot>
25
23
  </div>
@@ -32,6 +30,13 @@ export default {
32
30
 
33
31
  inject: ['apiDialog'],
34
32
 
33
+ props: {
34
+ headless: {
35
+ type: Boolean,
36
+ default: false,
37
+ },
38
+ },
39
+
35
40
  data() {
36
41
  return {
37
42
  visible: false,
@@ -43,12 +48,12 @@ export default {
43
48
  return `dialog-content-${this.apiDialog().componentId}`;
44
49
  },
45
50
 
46
- dark() {
47
- return this.apiDialog().isDark;
51
+ classes() {
52
+ return this.full ? 'h-screen w-screen' : 'max-h-full max-w-full';
48
53
  },
49
54
 
50
- headless() {
51
- return this.apiDialog().isHeadless;
55
+ full() {
56
+ return this.apiDialog().full;
52
57
  },
53
58
  },
54
59
 
@@ -1,7 +1,11 @@
1
1
  <template>
2
2
  <component
3
3
  :is="as"
4
- :class="{ 'Dialog-footer': headless, 'w-full': !headless }"
4
+ :class="[
5
+ headless
6
+ ? 'dialog-footer'
7
+ : '-mx-4 -mb-4 flex items-center justify-between gap-x-3 p-4 md:-mx-6 md:-mb-6 md:p-6',
8
+ ]"
5
9
  >
6
10
  <slot></slot>
7
11
  </component>
@@ -10,24 +14,15 @@
10
14
  <script>
11
15
  export default {
12
16
  name: 'VTDialogFooter',
13
-
14
- inject: ['apiDialog'],
15
-
16
17
  props: {
18
+ headless: {
19
+ type: Boolean,
20
+ default: false,
21
+ },
17
22
  as: {
18
23
  type: String,
19
24
  default: 'footer',
20
25
  },
21
26
  },
22
-
23
- computed: {
24
- dark() {
25
- return this.apiDialog().isDark;
26
- },
27
-
28
- headless() {
29
- return this.apiDialog().isHeadless;
30
- },
31
- },
32
27
  };
33
28
  </script>
@@ -2,10 +2,12 @@
2
2
  <component
3
3
  :is="as"
4
4
  :id="id"
5
- :class="{
6
- 'Dialog-header': headless,
7
- 'mb-8 flex justify-between gap-x-3 items-center w-full': !headless,
8
- }"
5
+ :class="[
6
+ headless
7
+ ? 'dialog-header'
8
+ : '-mx-4 -mt-4 flex items-center justify-between gap-x-3 p-4 md:-mx-6 md:-mt-6 md:p-6',
9
+ ]"
10
+ @click.stop
9
11
  >
10
12
  <slot></slot>
11
13
  </component>
@@ -18,6 +20,10 @@ export default {
18
20
  inject: ['apiDialog'],
19
21
 
20
22
  props: {
23
+ headless: {
24
+ type: Boolean,
25
+ default: false,
26
+ },
21
27
  as: {
22
28
  type: String,
23
29
  default: 'header',
@@ -25,16 +31,8 @@ export default {
25
31
  },
26
32
 
27
33
  computed: {
28
- dark() {
29
- return this.apiDialog().isDark;
30
- },
31
-
32
- headless() {
33
- return this.apiDialog().isHeadless;
34
- },
35
-
36
34
  id() {
37
- return `${this.apiDialog().id}-header`;
35
+ return `dialog-header-${this.apiDialog().componentId}`;
38
36
  },
39
37
  },
40
38
 
@@ -2,10 +2,7 @@
2
2
  <component
3
3
  :is="as"
4
4
  :id="id"
5
- :class="{
6
- 'Dialog-body': headless,
7
- 'flex-1 w-full h-full overflow-y-auto': !headless,
8
- }"
5
+ :class="[headless ? 'dialog-body' : 'h-full flex-1 overflow-y-auto']"
9
6
  >
10
7
  <slot></slot>
11
8
  </component>
@@ -18,6 +15,10 @@ export default {
18
15
  inject: ['apiDialog'],
19
16
 
20
17
  props: {
18
+ headless: {
19
+ type: Boolean,
20
+ default: false,
21
+ },
21
22
  as: {
22
23
  type: String,
23
24
  default: 'main',
@@ -25,16 +26,8 @@ export default {
25
26
  },
26
27
 
27
28
  computed: {
28
- dark() {
29
- return this.apiDialog().isDark;
30
- },
31
-
32
- headless() {
33
- return this.apiDialog().isHeadless;
34
- },
35
-
36
29
  id() {
37
- return `${this.apiDialog().id}-desc`;
30
+ return `dialog-main-${this.apiDialog().componentId}`;
38
31
  },
39
32
  },
40
33
 
@@ -3,11 +3,8 @@
3
3
  <div
4
4
  v-if="visible"
5
5
  :id="id"
6
- :class="{
7
- 'Dialog-overlay': headless,
8
- 'fixed inset-0 bg-fd-450/80': !headless,
9
- }"
10
- ></div>
6
+ :class="[headless ? 'dialog-overlay' : 'bg-primary-200/80 fixed inset-0']"
7
+ />
11
8
  </FadeInOut>
12
9
  </template>
13
10
 
@@ -23,6 +20,13 @@ export default {
23
20
 
24
21
  inject: ['apiDialog'],
25
22
 
23
+ props: {
24
+ headless: {
25
+ type: Boolean,
26
+ default: false,
27
+ },
28
+ },
29
+
26
30
  data() {
27
31
  return {
28
32
  visible: false,
@@ -33,14 +37,6 @@ export default {
33
37
  id() {
34
38
  return `dialog-overlay-${this.apiDialog().componentId}`;
35
39
  },
36
-
37
- dark() {
38
- return this.apiDialog().isDark;
39
- },
40
-
41
- headless() {
42
- return this.apiDialog().isHeadless;
43
- },
44
40
  },
45
41
 
46
42
  mounted() {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <span
3
3
  :id="id"
4
- :class="{ 'Dialog-header': headless, 'text-2xl font-semibold': !headless }"
4
+ :class="[headless ? 'dialog-header' : 'text-2xl font-semibold']"
5
5
  >
6
6
  <slot></slot
7
7
  ></span>
@@ -13,13 +13,16 @@ export default {
13
13
 
14
14
  inject: ['apiDialog'],
15
15
 
16
- computed: {
17
- headless() {
18
- return this.apiDialog().isHeadless;
16
+ props: {
17
+ headless: {
18
+ type: Boolean,
19
+ default: false,
19
20
  },
21
+ },
20
22
 
23
+ computed: {
21
24
  id() {
22
- return `${this.apiDialog().id}-title`;
25
+ return `dialog-overlay-${this.apiDialog().componentId}`;
23
26
  },
24
27
  },
25
28
  };
@@ -59,7 +59,7 @@ export default {
59
59
  this.apiDisclosure().register('contents', content);
60
60
  },
61
61
 
62
- beforeDestroy() {
62
+ beforeUnmount() {
63
63
  this.apiDisclosure().unregister('contents', this.id);
64
64
  },
65
65
 
@@ -63,7 +63,7 @@ export default {
63
63
  this.apiDisclosure().register('details', detail);
64
64
  },
65
65
 
66
- beforeDestroy() {
66
+ beforeUnmount() {
67
67
  this.apiDisclosure().unregister('details', this.id);
68
68
  },
69
69
 
@@ -4,7 +4,7 @@
4
4
  :class="[
5
5
  headless
6
6
  ? 'details-header'
7
- : 'flex cursor-pointer justify-between gap-3 text-body font-semibold',
7
+ : 'text-body flex cursor-pointer justify-between gap-3 font-semibold',
8
8
  ]"
9
9
  :aria-controls="ariaControls"
10
10
  :aria-expanded="String(ariaExpanded)"
@@ -78,7 +78,7 @@ export default {
78
78
  this.apiDisclosure().register('headers', header);
79
79
  },
80
80
 
81
- beforeDestroy() {
81
+ beforeUnmount() {
82
82
  this.apiDisclosure().unregister('headers', this.id);
83
83
  },
84
84
 
@@ -50,7 +50,7 @@ export default {
50
50
  this.apiDisclosure().register('icons', icon);
51
51
  },
52
52
 
53
- beforeDestroy() {
53
+ beforeUnmount() {
54
54
  this.apiDisclosure().unregister('icons', this.id);
55
55
  },
56
56
 
@@ -5,45 +5,47 @@
5
5
  </template>
6
6
 
7
7
  <script>
8
+ import { floatingUiMixin } from '../../../mixins/floating-ui';
8
9
  import { genId } from '../../utils/ids';
9
10
 
10
11
  export default {
11
12
  name: 'VTDropdownMenu',
12
13
 
14
+ mixins: [floatingUiMixin],
15
+
13
16
  provide() {
14
17
  return {
15
18
  apiDropdownMenu: () => {
16
- const { dark: isDark, headless: isHeadless, right: isRight } = this;
17
- const { id, trigger, content, items } = this;
18
-
19
19
  const registerTrigger = (trigger) => {
20
- this.trigger = trigger;
20
+ if (!trigger) return;
21
+ this.componentTrigger = trigger;
21
22
  };
22
23
 
23
24
  const registerContent = (content) => {
24
- this.content = content;
25
+ if (!content) return;
26
+ this.componentContent = content;
25
27
  };
26
28
 
27
29
  const registerItem = (item) => {
30
+ if (!item) return;
28
31
  this.items.push(item);
29
32
  };
30
33
 
31
- const unregisterItems = () => {
32
- this.items = [];
34
+ const unregisterItem = (id) => {
35
+ const index = this.items.findIndex((item) => item.id === id);
36
+ this.items.splice(index, 1);
33
37
  };
34
38
 
35
39
  return {
36
- id,
37
- isDark,
38
- isHeadless,
39
- isRight,
40
- trigger,
41
- content,
42
- items,
40
+ id: this.componentId,
41
+ component: this.component,
42
+ componentTrigger: this.componentTrigger,
43
+ componentContent: this.componentContent,
44
+ items: this.items,
43
45
  registerTrigger,
44
46
  registerContent,
45
47
  registerItem,
46
- unregisterItems,
48
+ unregisterItem,
47
49
  };
48
50
  },
49
51
  };
@@ -54,23 +56,38 @@ export default {
54
56
  type: Boolean,
55
57
  default: false,
56
58
  },
57
- dark: {
58
- type: Boolean,
59
- default: false,
60
- },
61
- right: {
62
- type: Boolean,
63
- default: false,
59
+ placement: {
60
+ type: String,
61
+ default: 'bottom-start',
64
62
  },
65
63
  },
66
64
 
67
65
  data() {
68
66
  return {
69
- id: `menu-${genId()}`,
70
- trigger: null,
71
- content: null,
67
+ componentId: genId(),
72
68
  items: [],
69
+ /**
70
+ * Explaining the need for the floatingUiMinWidth data
71
+ *
72
+ * The floating ui is a result of two items:
73
+ *
74
+ * 1. Trigger: the action button
75
+ * 2. Content: the popper/wrapper that appears after triggering the action button
76
+ *
77
+ * By default, the content will match the triggers width.
78
+ * The problem with this is that the trigger width
79
+ * might be too small causing the content to not fit
80
+ * what is inside it properly. So, to avoid this,
81
+ * a min width is needed.
82
+ */
83
+ floatingUiMinWidth: 200,
73
84
  };
74
85
  },
86
+
87
+ computed: {
88
+ id() {
89
+ return `dropdown-menu-${this.componentId}`;
90
+ },
91
+ },
75
92
  };
76
93
  </script>
@@ -1,93 +1,58 @@
1
1
  <template>
2
- <transition
3
- enter-active-class="duration-200 ease-out"
4
- enter-from-class="translate-y-[15px] opacity-0"
5
- enter-to-class="translate-y-0 opacity-100"
6
- leave-active-class="duration-200 ease-in"
7
- leave-from-class="translate-y-0 opacity-100"
8
- leave-to-class="translate-y-[15px] opacity-0"
9
- @after-leave="hide"
2
+ <FloatingUi
3
+ :id="id"
4
+ :visible="visible"
5
+ :headless="headless"
6
+ component="dropdown"
10
7
  >
11
- <div
12
- v-if="visible"
13
- :id="id"
14
- :class="{
15
- MenuList: headless,
16
- 'absolute top-full mt-3 grid min-w-[222px] overflow-hidden rounded border border-solid py-2 px-3 transition-all':
17
- !headless,
18
- 'border-gray-100 bg-white shadow-300': !dark,
19
- 'bg-forest-default border-gray-700 shadow-gray-700': dark,
20
- 'left-0': !right,
21
- 'right-0': right,
22
- }"
23
- >
24
- <slot></slot>
25
- </div>
26
- </transition>
8
+ <slot></slot>
9
+ </FloatingUi>
27
10
  </template>
28
11
 
29
12
  <script>
30
- import { genId } from '../../utils/ids';
13
+ import { floatingUiContentMixin } from '../../../mixins/floating-ui-content';
31
14
 
32
15
  export default {
33
16
  name: 'VTDropdownMenuContent',
34
17
 
35
- inject: ['apiDropdownMenu'],
18
+ inheritAttrs: false,
36
19
 
37
- data() {
38
- return {
39
- id: `menucontent-${genId()}`,
40
- visible: false,
41
- };
42
- },
20
+ mixins: [floatingUiContentMixin],
43
21
 
44
- computed: {
45
- dark() {
46
- return this.apiDropdownMenu().isDark;
47
- },
22
+ inject: ['apiDropdownMenu'],
48
23
 
49
- headless() {
50
- return this.apiDropdownMenu().isHeadless;
24
+ computed: {
25
+ id() {
26
+ return `dropdown-menu-content-${this.apiDropdownMenu().id}`;
51
27
  },
52
28
 
53
- right() {
54
- return this.apiDropdownMenu().isRight;
29
+ component() {
30
+ return this.apiDropdownMenu().component;
55
31
  },
56
32
 
57
- trigger() {
58
- return this.apiDropdownMenu().trigger;
33
+ componentTrigger() {
34
+ return this.apiDropdownMenu().componentTrigger;
59
35
  },
60
36
  },
61
37
 
62
38
  mounted() {
63
- this.apiDropdownMenu().registerContent(this);
64
-
65
- this.$nextTick(() => {
66
- if (this.trigger) this.trigger.toggleHasPopup();
67
- });
68
-
69
- // T-79 Create a directive or mixin for this
70
- document.addEventListener('click', (e) => {
71
- e.stopPropagation();
72
- if (this.visible && !this.$el.contains(e.target)) this.trigger.onClick();
73
- });
74
- },
39
+ const content = {
40
+ id: this.id,
41
+ hide: this.hide,
42
+ show: this.show,
43
+ setActiveDescedant: this.setActiveDescedant,
44
+ };
75
45
 
76
- destroyed() {
77
- // TODO: Create a directive or mixin for this
78
- document.removeEventListener('click', this.trigger.onClick());
46
+ this.apiDropdownMenu().registerContent(content);
79
47
  },
80
48
 
81
49
  methods: {
82
- show() {
83
- this.visible = true;
84
- this.$emit('shown');
50
+ hidden() {
51
+ this.$emit('hidden');
85
52
  },
86
53
 
87
- hide() {
88
- this.visible = false;
89
- this.$emit('hidden');
90
- this.apiDropdownMenu().unregisterItems();
54
+ shown() {
55
+ this.$emit('shown');
91
56
  },
92
57
  },
93
58
  };
@@ -1,11 +1,8 @@
1
1
  <template>
2
2
  <div
3
- :class="{
4
- PopoverDivider: headless,
5
- '-mx-3 my-2 h-[1px]': !headless,
6
- 'bg-gray-200': !dark,
7
- 'bg-fd-500': dark,
8
- }"
3
+ :class="[
4
+ headless ? 'dropdown-menu-divider' : '-mx-3 my-2 h-[1px] bg-gray-200',
5
+ ]"
9
6
  ></div>
10
7
  </template>
11
8
 
@@ -15,13 +12,10 @@ export default {
15
12
 
16
13
  inject: ['apiDropdownMenu'],
17
14
 
18
- computed: {
19
- dark() {
20
- return this.apiDropdownMenu().isDark;
21
- },
22
-
23
- headless() {
24
- return this.apiDropdownMenu().isHeadless;
15
+ props: {
16
+ headless: {
17
+ type: Boolean,
18
+ default: false,
25
19
  },
26
20
  },
27
21
  };