@veritree/ui 0.27.0 → 0.28.0-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/.claude/settings.local.json +10 -0
- package/index.js +105 -75
- package/mixins/floating-ui-content.js +17 -4
- package/mixins/floating-ui-item.js +31 -15
- package/mixins/floating-ui.js +142 -24
- package/mixins/form-control-icon.js +3 -3
- package/mixins/form-control.js +45 -20
- package/nuxt.js +38 -26
- package/package.json +17 -6
- package/src/components/Alert/VTAlert.vue +55 -14
- package/src/components/Avatar/VTAvatarImage.vue +6 -26
- package/src/components/Badge/VTBadge.vue +60 -0
- package/src/components/Badge/VTBadgeNew.vue +60 -0
- package/src/components/Breadcrumb/VTBreadcrumbItem.vue +11 -0
- package/src/components/Breadcrumb/VTBreadcrumbLink.vue +40 -0
- package/src/components/Breadcrumb/VTBreadcrumbList.vue +11 -0
- package/src/components/Breadcrumb/VTBreadcrumbRoot.vue +11 -0
- package/src/components/Breadcrumb/VTBreadcrumbSeparator.vue +19 -0
- package/src/components/Button/VTButton.vue +104 -56
- package/src/components/Carousel/VTCarousel.vue +69 -0
- package/src/components/Carousel/VTCarouselBackward.vue +36 -0
- package/src/components/Carousel/VTCarouselForward.vue +38 -0
- package/src/components/Carousel/VTCarouselTracker.vue +80 -0
- package/src/components/Checkbox/VTCheckbox.vue +134 -0
- package/src/components/Checkbox/VTCheckboxLabel.vue +3 -0
- package/src/components/Checkbox/VTCheckboxText.vue +20 -0
- package/src/components/Chip/VTChip.vue +29 -0
- package/src/components/Dialog/VTDialog.vue +59 -25
- package/src/components/Dialog/VTDialogClose.vue +3 -2
- package/src/components/Dialog/VTDialogContent.vue +29 -7
- package/src/components/Dialog/VTDialogFooter.vue +17 -2
- package/src/components/Dialog/VTDialogHeader.vue +2 -1
- package/src/components/Dialog/VTDialogMain.vue +5 -1
- package/src/components/Dialog/VTDialogOverlay.vue +5 -1
- package/src/components/Dialog/VTDialogTitle.vue +1 -1
- package/src/components/Disclosure/VTDisclosure.vue +2 -11
- package/src/components/Disclosure/VTDisclosureContent.vue +26 -52
- package/src/components/Disclosure/VTDisclosureDetails.vue +27 -2
- package/src/components/Disclosure/VTDisclosureHeader.vue +56 -89
- package/src/components/Disclosure/VTDisclosureIcon.vue +42 -31
- package/src/components/Divider/VTDivider.vue +9 -0
- package/src/components/Drawer/VTDrawer.vue +6 -15
- package/src/components/Drawer/VTDrawerClose.vue +5 -5
- package/src/components/Drawer/VTDrawerContent.vue +10 -10
- package/src/components/Drawer/VTDrawerFooter.vue +4 -4
- package/src/components/Drawer/VTDrawerHeader.vue +4 -4
- package/src/components/Drawer/VTDrawerMain.vue +5 -5
- package/src/components/Drawer/VTDrawerOverlay.vue +6 -6
- package/src/components/Drawer/VTDrawerTitle.vue +5 -5
- package/src/components/DropdownMenu/VTDropdownMenu.vue +0 -6
- package/src/components/DropdownMenu/VTDropdownMenuContent.vue +10 -1
- package/src/components/DropdownMenu/VTDropdownMenuDivider.vue +7 -16
- package/src/components/DropdownMenu/VTDropdownMenuItem.vue +5 -1
- package/src/components/DropdownMenu/VTDropdownMenuLabel.vue +1 -10
- package/src/components/DropdownMenu/VTDropdownMenuTrigger.vue +2 -4
- package/src/components/Form/VTFieldset.vue +5 -0
- package/src/components/Form/VTForm.vue +11 -0
- package/src/components/Form/VTFormCol.vue +20 -0
- package/src/components/Form/VTFormFeedback.vue +7 -1
- package/src/components/Form/VTFormGroup.vue +5 -7
- package/src/components/Form/VTFormLabel.vue +22 -0
- package/src/components/Form/VTFormLabelHelper.vue +22 -0
- package/src/components/Form/VTFormRow.vue +5 -0
- package/src/components/Form/VTInput.vue +2 -5
- package/src/components/Form/VTInputDate.vue +602 -0
- package/src/components/Form/VTInputIcon.vue +3 -9
- package/src/components/Form/VTInputNumber.vue +198 -0
- package/src/components/Form/VTInputPassword.vue +14 -5
- package/src/components/Form/VTInputRange.vue +92 -0
- package/src/components/Form/VTLegend.vue +24 -0
- package/src/components/Form/VTTextarea.vue +2 -2
- package/src/components/Image/VTImage.vue +10 -10
- package/src/components/Listbox/VTListbox.vue +128 -9
- package/src/components/Listbox/VTListboxContent.vue +14 -1
- package/src/components/Listbox/VTListboxDivider.vue +21 -0
- package/src/components/Listbox/VTListboxGroup.vue +9 -0
- package/src/components/Listbox/VTListboxItem.vue +57 -15
- package/src/components/Listbox/VTListboxLabel.vue +5 -4
- package/src/components/Listbox/VTListboxList.vue +1 -6
- package/src/components/Listbox/VTListboxPlaceholder.vue +25 -0
- package/src/components/Listbox/VTListboxSearch.vue +12 -8
- package/src/components/Listbox/VTListboxTrigger.vue +87 -6
- package/src/components/Listbox/VTListboxTriggerHighlight.vue +204 -0
- package/src/components/Listbox/VTListboxViewport.vue +33 -0
- package/src/components/Popover/VTPopoverContent.vue +3 -3
- package/src/components/Popover/VTPopoverDivider.vue +1 -1
- package/src/components/Popover/VTPopoverItem.vue +6 -2
- package/src/components/ProgressBar/VTProgressBar.vue +35 -10
- package/src/components/ProgressBar/VTProgressBarIndicator.vue +53 -0
- package/src/components/ScrollShadows/VTScrollShadows.vue +76 -0
- package/src/components/Separator/VTSeparator.vue +13 -0
- package/src/components/Switch/VTSwitch.vue +61 -0
- package/src/components/Tabs/VTTab.vue +6 -5
- package/src/components/Tabs/VTTabGroup.vue +88 -9
- package/src/components/Tabs/VTTabPanel.vue +4 -5
- package/src/components/Toast/README.md +263 -0
- package/src/components/Toast/VTToast.vue +145 -0
- package/src/components/Toast/VTToastAction.vue +25 -0
- package/src/components/Toast/VTToastClose.vue +52 -0
- package/src/components/Toast/VTToastContent.vue +25 -0
- package/src/components/Toast/VTToastDescription.vue +36 -0
- package/src/components/Toast/VTToastIcon.vue +72 -0
- package/src/components/Toast/VTToastItem.vue +180 -0
- package/src/components/Toast/VTToastTitle.vue +34 -0
- package/src/components/Tooltip/VTTooltipTrigger.vue +3 -5
- package/src/components/Transitions/FadeInOut.vue +2 -2
- package/src/components/Utils/FloatingUi.vue +31 -13
- package/src/helpers/currency.js +21 -0
- package/src/utils/components.js +18 -0
- package/src/utils/images.js +31 -12
- package/src/components/Input/VTInput.vue +0 -82
- package/src/components/Input/VTInputDate.vue +0 -36
- package/src/components/Input/VTInputFile.vue +0 -60
- package/src/components/Input/VTInputUpload.vue +0 -54
- package/src/components/Modal/VTModal.vue +0 -69
- package/src/utils/genId.js +0 -13
package/index.js
CHANGED
|
@@ -1,71 +1,86 @@
|
|
|
1
|
-
import VTAlert from
|
|
2
|
-
import VTAvatar from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
import
|
|
58
|
-
import
|
|
59
|
-
import
|
|
60
|
-
import
|
|
61
|
-
import
|
|
62
|
-
import
|
|
63
|
-
import
|
|
64
|
-
import
|
|
65
|
-
import
|
|
66
|
-
import
|
|
67
|
-
import
|
|
68
|
-
import
|
|
1
|
+
import VTAlert from './src/components/Alert/VTAlert.vue';
|
|
2
|
+
import VTAvatar from './src/components/Avatar/VTAvatar.vue';
|
|
3
|
+
import VTBadge from './src/components/Badge/VTBadge.vue';
|
|
4
|
+
import VTBreadcrumbRoot from './src/components/Breadcrumb/VTBreadcrumbRoot.vue';
|
|
5
|
+
import VTBreadcrumbList from './src/components/Breadcrumb/VTBreadcrumbList.vue';
|
|
6
|
+
import VTBreadcrumbItem from './src/components/Breadcrumb/VTBreadcrumbItem.vue';
|
|
7
|
+
import VTBreadcrumbLink from './src/components/Breadcrumb/VTBreadcrumbLink.vue';
|
|
8
|
+
import VTBreadcrumbSeparator from './src/components/Breadcrumb/VTBreadcrumbSeparator.vue';
|
|
9
|
+
import VTAvatarImage from './src/components/Avatar/VTAvatarImage.vue';
|
|
10
|
+
import VTAvatarText from './src/components/Avatar/VTAvatarText.vue';
|
|
11
|
+
import VTButton from './src/components/Button/VTButton.vue';
|
|
12
|
+
import VTCarousel from './src/components/Carousel/VTCarousel.vue';
|
|
13
|
+
import VTCarouselBackward from './src/components/Carousel/VTCarouselBackward.vue';
|
|
14
|
+
import VTCarouselForward from './src/components/Carousel/VTCarouselForward.vue';
|
|
15
|
+
import VTCarouselTracker from './src/components/Carousel/VTCarouselTracker.vue';
|
|
16
|
+
import VTChip from './src/components/Chip/VTChip.vue';
|
|
17
|
+
import VTImage from './src/components/Image/VTImage.vue';
|
|
18
|
+
import VTImageCounter from './src/components/Image/VTImageCounter.vue';
|
|
19
|
+
import VTImageHover from './src/components/Image/VTImageHover.vue';
|
|
20
|
+
import VTDropdownMenu from './src/components/DropdownMenu/VTDropdownMenu.vue';
|
|
21
|
+
import VTDropdownMenuContent from './src/components/DropdownMenu/VTDropdownMenuContent.vue';
|
|
22
|
+
import VTDropdownMenuDivider from './src/components/DropdownMenu/VTDropdownMenuDivider.vue';
|
|
23
|
+
import VTDropdownMenuGroup from './src/components/DropdownMenu/VTDropdownMenuGroup.vue';
|
|
24
|
+
import VTDropdownMenuItem from './src/components/DropdownMenu/VTDropdownMenuItem.vue';
|
|
25
|
+
import VTDropdownMenuLabel from './src/components/DropdownMenu/VTDropdownMenuLabel.vue';
|
|
26
|
+
import VTDropdownMenuTrigger from './src/components/DropdownMenu/VTDropdownMenuTrigger.vue';
|
|
27
|
+
import VTPopover from './src/components/Popover/VTPopover.vue';
|
|
28
|
+
import VTPopoverContent from './src/components/Popover/VTPopoverContent.vue';
|
|
29
|
+
import VTPopoverDivider from './src/components/Popover/VTPopoverDivider.vue';
|
|
30
|
+
import VTPopoverGroup from './src/components/Popover/VTPopoverGroup.vue';
|
|
31
|
+
import VTPopoverItem from './src/components/Popover/VTPopoverItem.vue';
|
|
32
|
+
import VTPopoverTrigger from './src/components/Popover/VTPopoverTrigger.vue';
|
|
33
|
+
import VTFormFeedback from './src/components/Form/VTFormFeedback.vue';
|
|
34
|
+
import VTFormGroup from './src/components/Form/VTFormGroup.vue';
|
|
35
|
+
import VTListbox from './src/components/Listbox/VTListbox.vue';
|
|
36
|
+
import VTListboxContent from './src/components/Listbox/VTListboxContent.vue';
|
|
37
|
+
import VTListboxItem from './src/components/Listbox/VTListboxItem.vue';
|
|
38
|
+
import VTListboxLabel from './src/components/Listbox/VTListboxLabel.vue';
|
|
39
|
+
import VTListboxList from './src/components/Listbox/VTListboxList.vue';
|
|
40
|
+
import VTListboxSearch from './src/components/Listbox/VTListboxSearch.vue';
|
|
41
|
+
import VTListboxTrigger from './src/components/Listbox/VTListboxTrigger.vue';
|
|
42
|
+
import VTListboxTriggerHighlight from './src/components/Listbox/VTListboxTriggerHighlight.vue';
|
|
43
|
+
import VTListboxDivider from './src/components/Listbox/VTListboxDivider.vue';
|
|
44
|
+
import VTListboxGroup from './src/components/Listbox/VTListboxGroup.vue';
|
|
45
|
+
import VTListboxPlaceholder from './src/components/Listbox/VTListboxPlaceholder.vue';
|
|
46
|
+
import VTListboxViewport from './src/components/Listbox/VTListboxViewport.vue';
|
|
47
|
+
import VTSpinner from './src/components/Spinner/VTSpinner.vue';
|
|
48
|
+
import VTInput from './src/components/Form/VTInput.vue';
|
|
49
|
+
import VTProgressBar from './src/components/ProgressBar/VTProgressBar.vue';
|
|
50
|
+
import VTProgressBarIndicator from './src/components/ProgressBar/VTProgressBarIndicator.vue';
|
|
51
|
+
import VTTextarea from './src/components/Textarea/VTTextarea.vue';
|
|
52
|
+
import VTTab from './src/components/Tabs/VTTab.vue';
|
|
53
|
+
import VTTabGroup from './src/components/Tabs/VTTabGroup.vue';
|
|
54
|
+
import VTTabList from './src/components/Tabs/VTTabList.vue';
|
|
55
|
+
import VTTabPanel from './src/components/Tabs/VTTabPanel.vue';
|
|
56
|
+
import VTTabPanels from './src/components/Tabs/VTTabPanels.vue';
|
|
57
|
+
import VTDialog from './src/components/Dialog/VTDialog.vue';
|
|
58
|
+
import VTDialogClose from './src/components/Dialog/VTDialogClose.vue';
|
|
59
|
+
import VTDialogContent from './src/components/Dialog/VTDialogContent.vue';
|
|
60
|
+
import VTDialogFooter from './src/components/Dialog/VTDialogFooter.vue';
|
|
61
|
+
import VTDialogHeader from './src/components/Dialog/VTDialogHeader.vue';
|
|
62
|
+
import VTDialogMain from './src/components/Dialog/VTDialogMain.vue';
|
|
63
|
+
import VTDialogOverlay from './src/components/Dialog/VTDialogOverlay.vue';
|
|
64
|
+
import VTDialogTitle from './src/components/Dialog/VTDialogTitle.vue';
|
|
65
|
+
import VTDrawer from './src/components/Drawer/VTDrawer.vue';
|
|
66
|
+
import VTDrawerClose from './src/components/Drawer/VTDrawerClose.vue';
|
|
67
|
+
import VTDrawerContent from './src/components/Drawer/VTDrawerContent.vue';
|
|
68
|
+
import VTDrawerFooter from './src/components/Drawer/VTDrawerFooter.vue';
|
|
69
|
+
import VTDrawerHeader from './src/components/Drawer/VTDrawerHeader.vue';
|
|
70
|
+
import VTDrawerTitle from './src/components/Drawer/VTDrawerTitle.vue';
|
|
71
|
+
import VTDrawerMain from './src/components/Drawer/VTDrawerMain.vue';
|
|
72
|
+
import VTDrawerOverlay from './src/components/Drawer/VTDrawerOverlay.vue';
|
|
73
|
+
import VTDivider from './src/components/Divider/VTDivider.vue';
|
|
74
|
+
import VTDisclosure from './src/components/Disclosure/VTDisclosure.vue';
|
|
75
|
+
import VTDisclosureDetails from './src/components/Disclosure/VTDisclosureDetails.vue';
|
|
76
|
+
import VTDisclosureHeader from './src/components/Disclosure/VTDisclosureHeader.vue';
|
|
77
|
+
import VTDisclosureIcon from './src/components/Disclosure/VTDisclosureIcon.vue';
|
|
78
|
+
import VTDisclosureContent from './src/components/Disclosure/VTDisclosureContent.vue';
|
|
79
|
+
import VTScrollShadows from './src/components/ScrollShadows/VTScrollShadows.vue';
|
|
80
|
+
import VTSeparator from './src/components/Separator/VTSeparator.vue';
|
|
81
|
+
import VTSkeleton from './src/components/Skeleton/VTSkeleton.vue';
|
|
82
|
+
import VTSkeletonItem from './src/components/Skeleton/VTSkeletonItem.vue';
|
|
83
|
+
import VTSwitch from './src/components/Switch/VTSwitch.vue';
|
|
69
84
|
|
|
70
85
|
export {
|
|
71
86
|
VTAvatar,
|
|
@@ -75,6 +90,12 @@ export {
|
|
|
75
90
|
VTImageCounter,
|
|
76
91
|
VTImageHover,
|
|
77
92
|
VTAlert,
|
|
93
|
+
VTBadge,
|
|
94
|
+
VTBreadcrumbRoot,
|
|
95
|
+
VTBreadcrumbList,
|
|
96
|
+
VTBreadcrumbItem,
|
|
97
|
+
VTBreadcrumbLink,
|
|
98
|
+
VTBreadcrumbSeparator,
|
|
78
99
|
VTSpinner,
|
|
79
100
|
VTDropdownMenu,
|
|
80
101
|
VTDropdownMenuContent,
|
|
@@ -98,16 +119,21 @@ export {
|
|
|
98
119
|
VTListboxList,
|
|
99
120
|
VTListboxSearch,
|
|
100
121
|
VTListboxTrigger,
|
|
122
|
+
VTListboxTriggerHighlight,
|
|
123
|
+
VTListboxDivider,
|
|
124
|
+
VTListboxGroup,
|
|
125
|
+
VTListboxPlaceholder,
|
|
126
|
+
VTListboxViewport,
|
|
101
127
|
VTButton,
|
|
128
|
+
VTCarousel,
|
|
129
|
+
VTCarouselBackward,
|
|
130
|
+
VTCarouselForward,
|
|
131
|
+
VTCarouselTracker,
|
|
132
|
+
VTChip,
|
|
102
133
|
VTInput,
|
|
103
|
-
VTInputIcon,
|
|
104
|
-
VTInputPassword,
|
|
105
|
-
VTInputDate,
|
|
106
|
-
VTInputFile,
|
|
107
|
-
VTInputUpload,
|
|
108
134
|
VTProgressBar,
|
|
135
|
+
VTProgressBarIndicator,
|
|
109
136
|
VTTextarea,
|
|
110
|
-
VTModal,
|
|
111
137
|
VTTab,
|
|
112
138
|
VTTabGroup,
|
|
113
139
|
VTTabList,
|
|
@@ -129,11 +155,15 @@ export {
|
|
|
129
155
|
VTDialogMain,
|
|
130
156
|
VTDialogOverlay,
|
|
131
157
|
VTDialogTitle,
|
|
158
|
+
VTDivider,
|
|
132
159
|
VTDisclosure,
|
|
133
160
|
VTDisclosureDetails,
|
|
134
161
|
VTDisclosureHeader,
|
|
135
162
|
VTDisclosureIcon,
|
|
136
163
|
VTDisclosureContent,
|
|
164
|
+
VTScrollShadows,
|
|
165
|
+
VTSeparator,
|
|
137
166
|
VTSkeleton,
|
|
138
|
-
VTSkeletonItem
|
|
167
|
+
VTSkeletonItem,
|
|
168
|
+
VTSwitch,
|
|
139
169
|
};
|
|
@@ -10,6 +10,10 @@ export const floatingUiContentMixin = {
|
|
|
10
10
|
type: Boolean,
|
|
11
11
|
default: false,
|
|
12
12
|
},
|
|
13
|
+
freeze: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false,
|
|
16
|
+
},
|
|
13
17
|
},
|
|
14
18
|
|
|
15
19
|
data() {
|
|
@@ -20,10 +24,10 @@ export const floatingUiContentMixin = {
|
|
|
20
24
|
},
|
|
21
25
|
|
|
22
26
|
mounted() {
|
|
23
|
-
document.addEventListener('click',
|
|
27
|
+
document.addEventListener('click', this.onDocumentClick);
|
|
24
28
|
},
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
unmounted() {
|
|
27
31
|
document.removeEventListener('click', this.onDocumentClick);
|
|
28
32
|
},
|
|
29
33
|
|
|
@@ -39,7 +43,16 @@ export const floatingUiContentMixin = {
|
|
|
39
43
|
this.component.setActive();
|
|
40
44
|
|
|
41
45
|
setTimeout(() => {
|
|
46
|
+
if (!this.id) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
this.el = document.getElementById(this.id);
|
|
51
|
+
|
|
52
|
+
if (!this.el) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
this.$emit('shown');
|
|
44
57
|
}, 100);
|
|
45
58
|
});
|
|
@@ -63,7 +76,7 @@ export const floatingUiContentMixin = {
|
|
|
63
76
|
},
|
|
64
77
|
|
|
65
78
|
onDocumentClick(e) {
|
|
66
|
-
if (!e) {
|
|
79
|
+
if (!e || !this.el || this.freeze) {
|
|
67
80
|
return;
|
|
68
81
|
}
|
|
69
82
|
|
|
@@ -78,4 +91,4 @@ export const floatingUiContentMixin = {
|
|
|
78
91
|
this.activeDescedant = id;
|
|
79
92
|
},
|
|
80
93
|
},
|
|
81
|
-
}
|
|
94
|
+
};
|
|
@@ -32,23 +32,25 @@ export const floatingUiItemMixin = {
|
|
|
32
32
|
// default styles
|
|
33
33
|
this.headless
|
|
34
34
|
? `${this.componentName}`
|
|
35
|
-
: 'relative z-10 flex items-center gap-2 px-3 py-2 text-inherit no-underline',
|
|
35
|
+
: 'relative z-10 text-sm flex items-center gap-2 px-3 py-2 text-inherit no-underline cursor-pointer',
|
|
36
36
|
// disabled state styles
|
|
37
37
|
this.headless
|
|
38
38
|
? this.disabled
|
|
39
39
|
? `${this.componentName}--disabled`
|
|
40
40
|
: null
|
|
41
41
|
: this.disabled
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
? 'pointer-events-none opacity-50'
|
|
43
|
+
: null,
|
|
44
44
|
// selected state styles
|
|
45
45
|
this.headless
|
|
46
46
|
? this.selected
|
|
47
|
-
?
|
|
47
|
+
? this.multiple
|
|
48
|
+
? null
|
|
49
|
+
: `${this.componentName}--selected`
|
|
48
50
|
: null
|
|
49
51
|
: this.selected
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
? 'bg-gray-200'
|
|
53
|
+
: null,
|
|
52
54
|
];
|
|
53
55
|
},
|
|
54
56
|
},
|
|
@@ -84,7 +86,7 @@ export const floatingUiItemMixin = {
|
|
|
84
86
|
this.addMouseEventListeners();
|
|
85
87
|
},
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
beforeUnmount() {
|
|
88
90
|
this.apiInjected().unregisterItem(this.id);
|
|
89
91
|
this.removeMouseEventListeners();
|
|
90
92
|
},
|
|
@@ -95,7 +97,7 @@ export const floatingUiItemMixin = {
|
|
|
95
97
|
|
|
96
98
|
const item = {
|
|
97
99
|
id: this.id,
|
|
98
|
-
text: this.$slots.default[0]
|
|
100
|
+
text: this.$slots.default?.()[0]?.children || this.$el?.textContent?.trim() || '',
|
|
99
101
|
select: this.select,
|
|
100
102
|
unselect: this.unselect,
|
|
101
103
|
isSelected: this.isSelected,
|
|
@@ -217,6 +219,20 @@ export const floatingUiItemMixin = {
|
|
|
217
219
|
return this.items.findIndex((item) => item.isSelected());
|
|
218
220
|
},
|
|
219
221
|
|
|
222
|
+
handleToogle() {
|
|
223
|
+
const checkbox = this.$refs[`${this.id}-checkbox`];
|
|
224
|
+
|
|
225
|
+
if (checkbox) {
|
|
226
|
+
checkbox.click();
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
handleClick() {
|
|
231
|
+
this.value !== undefined
|
|
232
|
+
? this.apiInjected().emit(this.value)
|
|
233
|
+
: this.$emit('click');
|
|
234
|
+
},
|
|
235
|
+
|
|
220
236
|
leaveMenu() {
|
|
221
237
|
if (this.componentTrigger) {
|
|
222
238
|
this.componentTrigger.cancel();
|
|
@@ -229,11 +245,9 @@ export const floatingUiItemMixin = {
|
|
|
229
245
|
return;
|
|
230
246
|
}
|
|
231
247
|
|
|
232
|
-
this
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
this.$nextTick(() => this.leaveMenu());
|
|
248
|
+
this.$emit('click');
|
|
249
|
+
this.multiple ? this.handleToogle() : this.handleClick();
|
|
250
|
+
this.multiple ? null : this.$nextTick(() => this.leaveMenu());
|
|
237
251
|
},
|
|
238
252
|
|
|
239
253
|
onKeyEsc() {
|
|
@@ -245,8 +259,10 @@ export const floatingUiItemMixin = {
|
|
|
245
259
|
return;
|
|
246
260
|
}
|
|
247
261
|
|
|
248
|
-
// unselect all items before selecting new
|
|
249
|
-
|
|
262
|
+
// unselect all items before selecting new one
|
|
263
|
+
for (const item of this.items) {
|
|
264
|
+
item.unselect();
|
|
265
|
+
}
|
|
250
266
|
|
|
251
267
|
/**
|
|
252
268
|
* Select item passing the event type to decide if
|
package/mixins/floating-ui.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
autoUpdate,
|
|
3
|
+
computePosition,
|
|
4
|
+
flip,
|
|
5
|
+
shift,
|
|
6
|
+
offset,
|
|
7
|
+
size,
|
|
8
|
+
// update,
|
|
9
|
+
} from '@floating-ui/dom';
|
|
2
10
|
|
|
3
11
|
export const floatingUiMixin = {
|
|
12
|
+
props: {
|
|
13
|
+
offset: {
|
|
14
|
+
type: [Number, String, Object],
|
|
15
|
+
default: 5,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
|
|
4
19
|
data() {
|
|
5
20
|
return {
|
|
6
21
|
component: null,
|
|
7
22
|
componentTrigger: null,
|
|
8
23
|
componentContent: null,
|
|
9
24
|
active: false,
|
|
25
|
+
floatingUiUpdaterDisposer: null,
|
|
10
26
|
};
|
|
11
27
|
},
|
|
12
28
|
|
|
@@ -23,6 +39,12 @@ export const floatingUiMixin = {
|
|
|
23
39
|
};
|
|
24
40
|
},
|
|
25
41
|
|
|
42
|
+
beforeUnmount() {
|
|
43
|
+
if (this.floatingUiUpdaterDisposer) {
|
|
44
|
+
this.floatingUiUpdaterDisposer();
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
26
48
|
methods: {
|
|
27
49
|
setActive() {
|
|
28
50
|
this.active = true;
|
|
@@ -32,34 +54,130 @@ export const floatingUiMixin = {
|
|
|
32
54
|
this.active = null;
|
|
33
55
|
},
|
|
34
56
|
|
|
57
|
+
positionContentToTriggerByTopAndLeft(trigger, content, minWidthLimit) {
|
|
58
|
+
/*
|
|
59
|
+
TODO: Try to replace this with the offset object from floating-ui, using mainAxis, crossAxis, and alignmentAxis.
|
|
60
|
+
The problem is that the floating-ui offset values are px values, not percentages, which is the use case I am trying to solve.
|
|
61
|
+
I tried to calculate the percentage based off of the width and height of the trigger element,
|
|
62
|
+
but depending on the placement prop, mainAxis could be x OR y and crossAxis could be x OR y,
|
|
63
|
+
so to calculate the offset based on the width/height of the trigger element
|
|
64
|
+
we would have to calculate it differently for each individual placement preset.
|
|
65
|
+
*/
|
|
66
|
+
const contentRect = content.getBoundingClientRect();
|
|
67
|
+
const contentWidth = contentRect.width;
|
|
68
|
+
const contentHeight = contentRect.height;
|
|
69
|
+
const triggerWidth = trigger.getBoundingClientRect().width;
|
|
70
|
+
let leftObject = this.leftPosition || {};
|
|
71
|
+
let topObject = this.topPosition || {};
|
|
72
|
+
let left = leftObject.value || 0;
|
|
73
|
+
let top = topObject.value || 0;
|
|
74
|
+
|
|
75
|
+
if (leftObject.unit === '%') {
|
|
76
|
+
left = (triggerWidth * left) / 100;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (topObject.unit === '%') {
|
|
80
|
+
top = (triggerWidth * top) / 100;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (leftObject.positionBy === 'center') {
|
|
84
|
+
left = left - contentWidth / 2;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (leftObject.positionBy === 'end') {
|
|
88
|
+
left = left - contentWidth;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (topObject.positionBy === 'top') {
|
|
92
|
+
top = top + contentHeight;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (topObject.positionBy === 'center') {
|
|
96
|
+
top = top + contentHeight / 2;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Initializes the auto-update functionality for positioning the floating UI element.
|
|
101
|
+
* This method sets up an automatic update mechanism that adjusts the position of the
|
|
102
|
+
* content element in relation to the trigger element based on changes in the environment,
|
|
103
|
+
* such as scroll or resize events.
|
|
104
|
+
*
|
|
105
|
+
* @param {Element} trigger - The DOM element that acts as the reference point for positioning.
|
|
106
|
+
* @param {Element} content - The DOM element representing the floating UI content that needs to be positioned.
|
|
107
|
+
* @param {Function} updateFunction - A callback function that executes the update logic for positioning.
|
|
108
|
+
*/
|
|
109
|
+
this.floatingUiUpdaterDisposer = autoUpdate(trigger, content, () => {
|
|
110
|
+
computePosition(trigger, content, {
|
|
111
|
+
placement: 'top-start',
|
|
112
|
+
middleware: [
|
|
113
|
+
flip(),
|
|
114
|
+
shift({ padding: 5 }),
|
|
115
|
+
size({
|
|
116
|
+
apply({ rects }) {
|
|
117
|
+
if (!minWidthLimit) return;
|
|
118
|
+
|
|
119
|
+
const width = rects.reference.width;
|
|
120
|
+
const minWidth = width < minWidthLimit ? minWidthLimit : width;
|
|
121
|
+
|
|
122
|
+
Object.assign(content.style, {
|
|
123
|
+
minWidth: `${minWidth}px`,
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
128
|
+
}).then(({ x, y }) => {
|
|
129
|
+
Object.assign(content.style, {
|
|
130
|
+
left: `${x + left}px`,
|
|
131
|
+
top: `${y + top}px`,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
|
|
35
137
|
positionContentToTrigger() {
|
|
36
138
|
const trigger = document.getElementById(this.componentTrigger.id);
|
|
37
139
|
const content = document.getElementById(this.componentContent.id);
|
|
38
140
|
const minWidthLimit = Number(this.floatingUiMinWidth);
|
|
39
141
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
142
|
+
if (!trigger || !content) {
|
|
143
|
+
console.error('The trigger or content element does not exist.');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (this.top || this.left) {
|
|
148
|
+
this.positionContentToTriggerByTopAndLeft(
|
|
149
|
+
trigger,
|
|
150
|
+
content,
|
|
151
|
+
minWidthLimit,
|
|
152
|
+
);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
this.floatingUiUpdaterDisposer = autoUpdate(trigger, content, () => {
|
|
157
|
+
computePosition(trigger, content, {
|
|
158
|
+
placement: this.placement,
|
|
159
|
+
middleware: [
|
|
160
|
+
offset(Number(this.offset)),
|
|
161
|
+
flip(),
|
|
162
|
+
shift({ padding: 5 }),
|
|
163
|
+
size({
|
|
164
|
+
apply({ rects }) {
|
|
165
|
+
if (!minWidthLimit) return;
|
|
166
|
+
|
|
167
|
+
const width = rects.reference.width;
|
|
168
|
+
const minWidth = width < minWidthLimit ? minWidthLimit : width;
|
|
169
|
+
|
|
170
|
+
Object.assign(content.style, {
|
|
171
|
+
minWidth: `${minWidth}px`,
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
],
|
|
176
|
+
}).then(({ x, y }) => {
|
|
177
|
+
Object.assign(content.style, {
|
|
178
|
+
left: `${x}px`,
|
|
179
|
+
top: `${y}px`,
|
|
180
|
+
});
|
|
63
181
|
});
|
|
64
182
|
});
|
|
65
183
|
},
|