@veritree/ui 0.19.2-20 → 0.19.2-22

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 (40) hide show
  1. package/mixins/floating-ui-content.js +1 -22
  2. package/mixins/floating-ui-item.js +93 -46
  3. package/mixins/floating-ui.js +5 -12
  4. package/package.json +1 -1
  5. package/src/components/Alert/VTAlert.vue +55 -14
  6. package/src/components/Dialog/VTDialog.vue +13 -11
  7. package/src/components/Dialog/VTDialogClose.vue +13 -19
  8. package/src/components/Dialog/VTDialogContent.vue +19 -14
  9. package/src/components/Dialog/VTDialogFooter.vue +9 -14
  10. package/src/components/Dialog/VTDialogHeader.vue +11 -13
  11. package/src/components/Dialog/VTDialogMain.vue +6 -13
  12. package/src/components/Dialog/VTDialogOverlay.vue +9 -13
  13. package/src/components/Dialog/VTDialogTitle.vue +8 -5
  14. package/src/components/Disclosure/VTDisclosureHeader.vue +1 -1
  15. package/src/components/DropdownMenu/VTDropdownMenu.vue +19 -0
  16. package/src/components/DropdownMenu/VTDropdownMenuContent.vue +14 -6
  17. package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +7 -16
  18. package/src/components/DropdownMenu/VTDropdownMenuItem.vue +3 -7
  19. package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +1 -10
  20. package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +4 -9
  21. package/src/components/Listbox/VTListbox.vue +105 -14
  22. package/src/components/Listbox/VTListboxContent.vue +3 -7
  23. package/src/components/Listbox/VTListboxItem.vue +127 -6
  24. package/src/components/Listbox/VTListboxLabel.vue +3 -4
  25. package/src/components/Listbox/VTListboxList.vue +3 -24
  26. package/src/components/Listbox/VTListboxSearch.vue +60 -53
  27. package/src/components/Listbox/VTListboxTrigger.vue +12 -6
  28. package/src/components/Popover/VTPopover.vue +19 -0
  29. package/src/components/ProgressBar/VTProgressBar.vue +21 -3
  30. package/src/components/Skeleton/VTSkeleton.vue +11 -0
  31. package/src/components/Skeleton/VTSkeletonItem.vue +9 -0
  32. package/src/components/Tabs/VTTab.vue +13 -11
  33. package/src/components/Tooltip/VTTooltip.vue +65 -0
  34. package/src/components/Tooltip/VTTooltipContent.vue +59 -0
  35. package/src/components/Tooltip/VTTooltipTrigger.vue +98 -0
  36. package/src/components/Utils/FloatingUi.vue +52 -17
  37. package/src/components/Input/VTInput.vue +0 -82
  38. package/src/components/Input/VTInputDate.vue +0 -36
  39. package/src/components/Input/VTInputFile.vue +0 -60
  40. package/src/components/Input/VTInputUpload.vue +0 -54
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <div>
3
+ <slot />
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import { floatingUiMixin } from '../../../mixins/floating-ui';
9
+ import { genId } from '../../utils/ids';
10
+
11
+ export default {
12
+ name: 'VTTooltip',
13
+
14
+ mixins: [floatingUiMixin],
15
+
16
+ props: {
17
+ delayDuration: {
18
+ type: [String, Number],
19
+ default: 500,
20
+ },
21
+ placement: {
22
+ type: String,
23
+ default: 'bottom',
24
+ },
25
+ },
26
+
27
+ data() {
28
+ return {
29
+ floatingUiMinWidth: 0,
30
+ };
31
+ },
32
+
33
+ provide() {
34
+ return {
35
+ apiTooltip: () => {
36
+ const registerTrigger = (trigger) => {
37
+ if (!trigger) return;
38
+ this.componentTrigger = trigger;
39
+ };
40
+
41
+ const registerContent = (content) => {
42
+ if (!content) return;
43
+ this.componentContent = content;
44
+ };
45
+
46
+ return {
47
+ id: this.componentId,
48
+ component: this.component,
49
+ componentTrigger: this.componentTrigger,
50
+ componentContent: this.componentContent,
51
+ delayDuration: this.delayDuration,
52
+ registerTrigger,
53
+ registerContent,
54
+ };
55
+ },
56
+ };
57
+ },
58
+
59
+ data() {
60
+ return {
61
+ componentId: genId(),
62
+ };
63
+ },
64
+ };
65
+ </script>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <FloatingUi
3
+ :id="id"
4
+ :visible="visible"
5
+ :headless="headless"
6
+ component="tooltip"
7
+ >
8
+ <slot></slot>
9
+ </FloatingUi>
10
+ </template>
11
+
12
+ <script>
13
+ import { floatingUiContentMixin } from '../../../mixins/floating-ui-content';
14
+
15
+ export default {
16
+ name: 'VTTooltipContent',
17
+
18
+ inheritAttrs: false,
19
+
20
+ mixins: [floatingUiContentMixin],
21
+
22
+ inject: ['apiTooltip'],
23
+
24
+ data() {
25
+ return {
26
+ visible: false,
27
+ };
28
+ },
29
+
30
+ computed: {
31
+ id() {
32
+ return `tooltip-content-${this.apiTooltip().id}`;
33
+ },
34
+
35
+ component() {
36
+ return this.apiTooltip().component;
37
+ },
38
+
39
+ componentTrigger() {
40
+ return this.apiTooltip().componentTrigger;
41
+ },
42
+
43
+ ariaLabelledby() {
44
+ if (!this.componentTrigger) return null;
45
+ return this.visible ? this.componentTrigger.id : null;
46
+ },
47
+ },
48
+
49
+ mounted() {
50
+ const content = {
51
+ id: this.id,
52
+ hide: this.hide,
53
+ show: this.show,
54
+ };
55
+
56
+ this.apiTooltip().registerContent(content);
57
+ },
58
+ };
59
+ </script>
@@ -0,0 +1,98 @@
1
+ <template>
2
+ <div
3
+ :id="id"
4
+ :aria-describedby="ariaDescribedBy"
5
+ @mouseenter="onMouseenter"
6
+ @mouseleave="onmouseout"
7
+ >
8
+ <slot />
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ let tooltipTriggerTimeout = null;
14
+
15
+ export default {
16
+ name: 'VTTooltipTrigger',
17
+
18
+ inject: ['apiTooltip'],
19
+
20
+ data() {
21
+ return {
22
+ expanded: false,
23
+ };
24
+ },
25
+
26
+ computed: {
27
+ id() {
28
+ return `tooltip-trigger-${this.apiTooltip().id}`;
29
+ },
30
+
31
+ componentContent() {
32
+ return this.apiTooltip().componentContent;
33
+ },
34
+
35
+ ariaDescribedBy() {
36
+ if (!this.componentContent) return null;
37
+ return this.expanded ? this.componentContent.id : null;
38
+ },
39
+ },
40
+
41
+ mounted() {
42
+ const trigger = {
43
+ cancel: this.cancel,
44
+ id: this.id,
45
+ };
46
+
47
+ this.apiTooltip().registerTrigger(trigger);
48
+ },
49
+
50
+ methods: {
51
+ onMouseenter(e) {
52
+ tooltipTriggerTimeout = setTimeout(() => {
53
+ this.init(e);
54
+ }, this.apiTooltip().delayDuration);
55
+ },
56
+
57
+ onmouseout() {
58
+ clearTimeout(tooltipTriggerTimeout);
59
+ this.cancel();
60
+ },
61
+
62
+ init(e) {
63
+ if (!this.componentContent) {
64
+ return;
65
+ }
66
+
67
+ if (this.expanded) {
68
+ this.cancel();
69
+ return;
70
+ }
71
+
72
+ this.expanded = true;
73
+
74
+ // delay stop propagation to close other visible
75
+ // dropdowns and delay click event to control
76
+ // this dropdown visibility
77
+ this.showComponentContent();
78
+ },
79
+
80
+ cancel() {
81
+ if (!this.componentContent) {
82
+ return;
83
+ }
84
+
85
+ this.expanded = false;
86
+ this.hideComponentContent();
87
+ },
88
+
89
+ showComponentContent() {
90
+ this.componentContent.show();
91
+ },
92
+
93
+ hideComponentContent() {
94
+ this.componentContent.hide();
95
+ },
96
+ },
97
+ };
98
+ </script>
@@ -2,25 +2,24 @@
2
2
  <Teleport to="body">
3
3
  <transition
4
4
  enter-active-class="duration-200 ease-out"
5
- enter-from-class="translate-y-[15px] opacity-0"
6
- enter-to-class="translate-y-0 opacity-100"
5
+ :enter-from-class="transitionEnterClass"
6
+ :enter-to-class="transitionEnterToClass"
7
7
  leave-active-class="duration-200 ease-in"
8
- leave-from-class="translate-y-0 opacity-100"
9
- leave-to-class="translate-y-[15px] opacity-0"
10
- @after-leave="hide"
8
+ :leave-from-class="transitionLeaveClass"
9
+ :leave-to-class="transitionLeaveToClass"
10
+ @after-leave="hidden"
11
+ @after-enter="shown"
11
12
  >
12
13
  <div
13
14
  v-if="visible"
14
- :id="id"
15
15
  :class="[
16
16
  headless
17
- ? null
18
- : 'shadow-300 absolute z-50 grid overflow-x-hidden rounded-md border-gray-100 bg-white py-2 px-3',
19
- floatingUiClass ? floatingUiClass : null,
17
+ ? `${this.component}-content`
18
+ : `absolute z-50 grid overflow-hidden rounded-md shadow-md ${this.classes} ${this.portalClass}`,
20
19
  ]"
21
20
  v-bind="$attrs"
22
21
  >
23
- <slot></slot>
22
+ <slot />
24
23
  </div>
25
24
  </transition>
26
25
  </Teleport>
@@ -31,27 +30,63 @@ export default {
31
30
  inheritAttrs: false,
32
31
 
33
32
  props: {
33
+ component: {
34
+ type: String,
35
+ default: null,
36
+ },
34
37
  headless: {
35
38
  type: Boolean,
36
39
  default: false,
37
40
  },
38
- id: {
39
- type: [String, Number],
40
- default: null,
41
- },
42
41
  visible: {
43
42
  type: Boolean,
44
43
  default: false,
45
44
  },
46
- floatingUiClass: {
45
+ ariaActivedescendant: {
46
+ type: String,
47
+ default: null,
48
+ },
49
+ portalClass: {
47
50
  type: [String, Function],
48
51
  default: null,
49
52
  },
50
53
  },
51
54
 
55
+ computed: {
56
+ isTooltip() {
57
+ return this.component === 'tooltip';
58
+ },
59
+
60
+ classes() {
61
+ return this.isTooltip
62
+ ? 'bg-gray-800 text-sm text-white py-1 px-2'
63
+ : 'bg-white py-2 px-3';
64
+ },
65
+
66
+ transitionEnterClass() {
67
+ return this.isTooltip ? 'opacity-0' : 'translate-y-[15px] opacity-0';
68
+ },
69
+
70
+ transitionEnterToClass() {
71
+ return this.isTooltip ? 'opacity-100' : 'translate-y-0 opacity-100';
72
+ },
73
+
74
+ transitionLeaveClass() {
75
+ return this.transitionEnterToClass;
76
+ },
77
+
78
+ transitionLeaveToClass() {
79
+ return this.transitionEnterClass;
80
+ },
81
+ },
82
+
52
83
  methods: {
53
- hide() {
54
- this.$emit('hide');
84
+ shown() {
85
+ this.$emit('shown');
86
+ },
87
+
88
+ hidden() {
89
+ this.$emit('hidden');
55
90
  },
56
91
  },
57
92
  };
@@ -1,82 +0,0 @@
1
- <template>
2
- <input
3
- :class="classes"
4
- class="form-control"
5
- :data-theme="theme"
6
- :type="type"
7
- :value="value"
8
- v-on="listeners"
9
- />
10
- </template>
11
-
12
- <script>
13
- export default {
14
- name: 'VTInput',
15
-
16
- props: {
17
- lazy: {
18
- type: Boolean,
19
- default: false,
20
- },
21
- type: {
22
- type: String,
23
- default: 'text',
24
- },
25
- theme: {
26
- type: String,
27
- default: null,
28
- validator(value) {
29
- return ['dark'].includes(value);
30
- },
31
- },
32
- variant: {
33
- type: [String, Object],
34
- default: '',
35
- validator(value) {
36
- if (value === '' || typeof value === 'object') {
37
- return true;
38
- }
39
-
40
- return ['success', 'warning', 'error'].includes(value);
41
- },
42
- },
43
- value: {
44
- type: [String, Number, Object, Array],
45
- default: null,
46
- },
47
- },
48
-
49
- computed: {
50
- classes() {
51
- const classes = {};
52
-
53
- if (this.variant) {
54
- classes[`form-control--${this.variant}`] = true;
55
- }
56
-
57
- return classes;
58
- },
59
-
60
- listeners() {
61
- // `Object.assign` merges objects together to form a new object
62
- return Object.assign(
63
- {},
64
- // We add all the listeners from the parent
65
- this.$listeners,
66
- // Then we can add custom listeners or override the
67
- // behavior of some listeners.
68
- {
69
- // This ensures that the component works with v-model
70
- input: (event) => {
71
- if (this.lazy) return;
72
- this.$emit('input', event.target.value);
73
- },
74
- blur: (event) => {
75
- this.$emit('blur', event);
76
- },
77
- }
78
- );
79
- },
80
- },
81
- };
82
- </script>
@@ -1,36 +0,0 @@
1
- <template>
2
- <VTInput v-model="date" type="date" />
3
- </template>
4
-
5
- <script>
6
- import VTInput from './VTInput.vue';
7
-
8
- export default {
9
- name: 'VTInputDate',
10
-
11
- components: { VTInput },
12
-
13
- model: {
14
- prop: 'value',
15
- event: 'input',
16
- },
17
-
18
- props: {
19
- value: {
20
- type: String,
21
- default: '',
22
- },
23
- },
24
-
25
- computed: {
26
- date: {
27
- get() {
28
- return this.$date.format(this.value, 'YYYY-MM-DD');
29
- },
30
- set(newDate) {
31
- this.$emit('input', newDate);
32
- },
33
- },
34
- },
35
- };
36
- </script>
@@ -1,60 +0,0 @@
1
- <template>
2
- <div class="flex items-stretch gap-2">
3
- <VTInput
4
- ref="input"
5
- type="file"
6
- :value="value"
7
- :theme="theme"
8
- v-bind="$attrs"
9
- @change="onChange"
10
- />
11
- <VTButton :theme="theme" @click.stop="onButtonClick">Browse</VTButton>
12
- </div>
13
- </template>
14
-
15
- <script>
16
- import VTButton from '../Button/VTButton.vue';
17
- import VTInput from './VTInput.vue';
18
-
19
- export default {
20
- name: 'VTInputFile',
21
-
22
- components: {
23
- VTInput,
24
- VTButton,
25
- },
26
-
27
- inheritAttrs: false,
28
-
29
- props: {
30
- theme: {
31
- type: String,
32
- default: null,
33
- validator(value) {
34
- return ['dark'].includes(value);
35
- },
36
- },
37
- multiple: {
38
- type: Boolean,
39
- default: false,
40
- },
41
- },
42
-
43
- data() {
44
- return {
45
- value: null,
46
- };
47
- },
48
-
49
- methods: {
50
- onChange(event) {
51
- this.value = this.$refs.input.$el.value;
52
- this.$emit('change', event);
53
- },
54
-
55
- onButtonClick() {
56
- this.$refs.input.$el.click();
57
- },
58
- },
59
- };
60
- </script>
@@ -1,54 +0,0 @@
1
- <template>
2
- <label
3
- class="flex h-full w-full flex-col items-center justify-center rounded border-2 border-dotted border-white p-4 text-center hover:border-fl-500 hover:bg-fd-500"
4
- :class="{ 'border-fl-500 bg-fd-500': isDraggingOver }"
5
- @drop.prevent="onDrop"
6
- @dragover.prevent="onDragOver"
7
- @dragleave.prevent="onDragLeave"
8
- >
9
- <IconImagePlaceholder class="mb-3" />
10
- <span>Drop your images here, or click to browse</span>
11
- <VTInput type="file" class="sr-only" v-bind="$attrs" @change="onChange" />
12
- </label>
13
- </template>
14
-
15
- <script>
16
- import { IconImagePlaceholder } from '@veritree/icons';
17
- import VTInput from './VTInput.vue';
18
-
19
- export default {
20
- name: 'VTInputFile',
21
-
22
- components: {
23
- VTInput,
24
- IconImagePlaceholder,
25
- },
26
-
27
- inheritAttrs: false,
28
-
29
- data() {
30
- return {
31
- isDraggingOver: false,
32
- };
33
- },
34
-
35
- methods: {
36
- onDrop(event) {
37
- this.isDraggingOver = false;
38
- this.$emit('drop', event);
39
- },
40
-
41
- onDragOver() {
42
- this.isDraggingOver = true;
43
- },
44
-
45
- onDragLeave() {
46
- this.isDraggingOver = false;
47
- },
48
-
49
- onChange(event) {
50
- this.$emit('change', event);
51
- },
52
- },
53
- };
54
- </script>