sprintify-ui 0.10.65 → 0.10.67
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/README.md +266 -266
- package/dist/{BaseCkeditor-D6D4FPEb.js → BaseCkeditor-B4PbYw6a.js} +2 -2
- package/dist/sprintify-ui.es.js +4435 -4557
- package/dist/style.css +3 -3
- package/dist/tailwindcss/button.js +260 -260
- package/dist/tailwindcss/index.js +21 -21
- package/dist/tailwindcss/input.js +22 -22
- package/dist/tailwindcss/overlay.js +12 -12
- package/dist/tailwindcss/table.js +91 -91
- package/dist/tailwindcss/theme.js +52 -52
- package/dist/types/components/BaseActionButtons.vue.d.ts +1 -1
- package/dist/types/components/BaseActionItem.vue.d.ts +7 -10
- package/dist/types/components/BaseAddressForm.vue.d.ts +1 -1
- package/dist/types/components/BaseAlert.vue.d.ts +24 -11
- package/dist/types/components/BaseApp.vue.d.ts +14 -12
- package/dist/types/components/BaseAssign.vue.d.ts +1 -1
- package/dist/types/components/BaseAutocomplete.vue.d.ts +665 -455
- package/dist/types/components/BaseAutocompleteDrawer.vue.d.ts +119 -24
- package/dist/types/components/BaseAutocompleteFetch.vue.d.ts +1033 -412
- package/dist/types/components/BaseAvatarGroup.vue.d.ts +1 -1
- package/dist/types/components/BaseBadge.vue.d.ts +23 -11
- package/dist/types/components/BaseBelongsTo.vue.d.ts +998 -411
- package/dist/types/components/BaseBelongsToFetch.vue.d.ts +754 -371
- package/dist/types/components/BaseBoolean.vue.d.ts +1 -1
- package/dist/types/components/BaseBreadcrumbs.vue.d.ts +1 -1
- package/dist/types/components/BaseButton.vue.d.ts +78 -16
- package/dist/types/components/BaseButtonGroup.vue.d.ts +166 -15
- package/dist/types/components/BaseCard.vue.d.ts +26 -12
- package/dist/types/components/BaseCardRow.vue.d.ts +20 -11
- package/dist/types/components/BaseCharacterCounter.vue.d.ts +1 -1
- package/dist/types/components/BaseClipboard.vue.d.ts +45 -13
- package/dist/types/components/BaseCollapse.vue.d.ts +41 -20
- package/dist/types/components/BaseContainer.vue.d.ts +16 -11
- package/dist/types/components/BaseCounter.vue.d.ts +1 -1
- package/dist/types/components/BaseCropper.vue.d.ts +55 -30
- package/dist/types/components/BaseDataIterator.vue.d.ts +43 -42
- package/dist/types/components/BaseDataIteratorSectionBox.vue.d.ts +15 -12
- package/dist/types/components/BaseDataIteratorSectionColumns.vue.d.ts +1 -1
- package/dist/types/components/BaseDataIteratorSectionModal.vue.d.ts +19 -10
- package/dist/types/components/BaseDataTable.vue.d.ts +2090 -738
- package/dist/types/components/BaseDataTableTemplate.vue.d.ts +576 -100
- package/dist/types/components/BaseDatePicker.vue.d.ts +1 -1
- package/dist/types/components/BaseDateSelect.vue.d.ts +1 -1
- package/dist/types/components/BaseDescriptionList.vue.d.ts +12 -12
- package/dist/types/components/BaseDescriptionListItem.vue.d.ts +16 -15
- package/dist/types/components/BaseDialog.vue.d.ts +114 -413
- package/dist/types/components/BaseDisplayRelativeTime.vue.d.ts +55 -13
- package/dist/types/components/BaseDraggable.vue.d.ts +25 -16
- package/dist/types/components/BaseDropdown.vue.d.ts +155 -17
- package/dist/types/components/BaseDropdownAutocomplete.vue.d.ts +131 -16
- package/dist/types/components/BaseField.vue.d.ts +103 -12
- package/dist/types/components/BaseFieldI18n.vue.d.ts +1 -1
- package/dist/types/components/BaseFilePicker.vue.d.ts +35 -16
- package/dist/types/components/BaseFilePickerCrop.vue.d.ts +87 -42
- package/dist/types/components/BaseFileUploader.vue.d.ts +195 -29
- package/dist/types/components/BaseForm.vue.d.ts +161 -20
- package/dist/types/components/BaseGantt.vue.d.ts +1130 -409
- package/dist/types/components/BaseHasMany.vue.d.ts +590 -347
- package/dist/types/components/BaseHasManyFetch.vue.d.ts +602 -251
- package/dist/types/components/BaseHeader.vue.d.ts +1 -1
- package/dist/types/components/BaseIconPicker.vue.d.ts +1 -1
- package/dist/types/components/BaseInputError.vue.d.ts +23 -11
- package/dist/types/components/BaseJsonReaderItem.vue.d.ts +1 -1
- package/dist/types/components/BaseLayoutNotificationItemContent.vue.d.ts +1 -1
- package/dist/types/components/BaseLayoutSidebar.vue.d.ts +124 -16
- package/dist/types/components/BaseLayoutSidebarConfigurable.vue.d.ts +115 -13
- package/dist/types/components/BaseLayoutStacked.vue.d.ts +69 -22
- package/dist/types/components/BaseLayoutStackedConfigurable.vue.d.ts +120 -10
- package/dist/types/components/BaseLazy.vue.d.ts +20 -15
- package/dist/types/components/BaseMediaGallery.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaGalleryItem.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaItem.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaLibrary.vue.d.ts +234 -34
- package/dist/types/components/BaseMediaListItem.vue.d.ts +1 -1
- package/dist/types/components/BaseMediaPicturesItem.vue.d.ts +1 -1
- package/dist/types/components/BaseMenu.vue.d.ts +233 -30
- package/dist/types/components/BaseMenuItem.vue.d.ts +1 -1
- package/dist/types/components/BaseModalCenter.vue.d.ts +88 -12
- package/dist/types/components/BaseModalSide.vue.d.ts +85 -12
- package/dist/types/components/BaseNavbar.vue.d.ts +88 -22
- package/dist/types/components/BaseNavbarItem.vue.d.ts +1 -1
- package/dist/types/components/BaseNavbarItemContent.vue.d.ts +1 -1
- package/dist/types/components/BaseNavbarSideItem.vue.d.ts +1 -1
- package/dist/types/components/BaseNavbarSideItemContent.vue.d.ts +1 -1
- package/dist/types/components/BasePagination.vue.d.ts +1 -1
- package/dist/types/components/BaseRadioGroup.vue.d.ts +113 -13
- package/dist/types/components/BaseReadMore.vue.d.ts +31 -12
- package/dist/types/components/BaseRichText.vue.d.ts +1 -1
- package/dist/types/components/BaseSelect.vue.d.ts +149 -12
- package/dist/types/components/BaseShortcut.vue.d.ts +1 -1
- package/dist/types/components/BaseSideNavigation.vue.d.ts +11 -12
- package/dist/types/components/BaseSideNavigationItem.vue.d.ts +22 -13
- package/dist/types/components/BaseSkeleton.vue.d.ts +3 -3
- package/dist/types/components/BaseStepper.vue.d.ts +1 -1
- package/dist/types/components/BaseSwitch.vue.d.ts +122 -13
- package/dist/types/components/BaseSystemAlert.vue.d.ts +58 -11
- package/dist/types/components/BaseTabItem.vue.d.ts +35 -18
- package/dist/types/components/BaseTable.vue.d.ts +29 -14
- package/dist/types/components/BaseTableBody.vue.d.ts +9 -12
- package/dist/types/components/BaseTableCell.vue.d.ts +40 -15
- package/dist/types/components/BaseTableColumn.vue.d.ts +3 -3
- package/dist/types/components/BaseTableHead.vue.d.ts +14 -12
- package/dist/types/components/BaseTableHeader.vue.d.ts +46 -17
- package/dist/types/components/BaseTableRow.vue.d.ts +40 -13
- package/dist/types/components/BaseTabs.vue.d.ts +21 -15
- package/dist/types/components/BaseTagAutocomplete.vue.d.ts +602 -203
- package/dist/types/components/BaseTagAutocompleteFetch.vue.d.ts +807 -348
- package/dist/types/components/BaseTextareaAutoresize.vue.d.ts +1 -1
- package/dist/types/components/BaseTimeline.vue.d.ts +1 -1
- package/dist/types/components/BaseTimelineItem.vue.d.ts +1 -1
- package/dist/types/components/BaseToast.vue.d.ts +1 -1
- package/dist/types/components/BaseTooltip.vue.d.ts +41 -15
- package/dist/types/components/BaseUniqueCode.vue.d.ts +1 -1
- package/dist/types/stories/PageInputSizes.vue.d.ts +1 -1
- package/dist/types/stories/PageShow.vue.d.ts +1 -1
- package/dist/types/svg/BaseEmptyState.vue.d.ts +1 -1
- package/dist/types/svg/BaseSpinnerSmall.vue.d.ts +1 -1
- package/package.json +135 -135
- package/src/assets/base-cropper.css +61 -61
- package/src/assets/base-date-picker.css +4 -4
- package/src/assets/base-rich-text.css +270 -270
- package/src/assets/base-spinner.css +18 -18
- package/src/assets/base-tabs.css +4 -4
- package/src/assets/base-time-picker.css +9 -9
- package/src/assets/flatpickr.css +247 -247
- package/src/assets/form.css +6 -6
- package/src/assets/google-pac.css +25 -25
- package/src/assets/main.css +56 -56
- package/src/assets/tailwind.css +2 -2
- package/src/changelog.mdx +6 -6
- package/src/components/BaseActionButtons.vue +76 -76
- package/src/components/BaseActionItem.vue +80 -80
- package/src/components/BaseActionItemButton.vue +75 -75
- package/src/components/BaseAddressForm.stories.js +114 -114
- package/src/components/BaseAddressForm.vue +382 -382
- package/src/components/BaseAlert.stories.js +75 -75
- package/src/components/BaseAlert.vue +101 -101
- package/src/components/BaseApp.vue +16 -16
- package/src/components/BaseAppDialogs.vue +126 -126
- package/src/components/BaseAppSnackbars.vue +40 -40
- package/src/components/BaseAssign.mdx +98 -98
- package/src/components/BaseAssign.stories.js +78 -78
- package/src/components/BaseAssign.vue +366 -366
- package/src/components/BaseAutocomplete.stories.js +243 -243
- package/src/components/BaseAutocomplete.vue +603 -603
- package/src/components/BaseAutocompleteDrawer.vue +386 -386
- package/src/components/BaseAutocompleteFetch.stories.js +224 -224
- package/src/components/BaseAutocompleteFetch.vue +314 -314
- package/src/components/BaseAvatar.stories.js +39 -39
- package/src/components/BaseAvatar.vue +164 -164
- package/src/components/BaseAvatarGroup.stories.js +71 -71
- package/src/components/BaseAvatarGroup.vue +148 -148
- package/src/components/BaseBadge.stories.js +132 -130
- package/src/components/BaseBadge.vue +118 -97
- package/src/components/BaseBelongsTo.stories.js +220 -220
- package/src/components/BaseBelongsTo.vue +164 -164
- package/src/components/BaseBelongsToFetch.stories.js +223 -223
- package/src/components/BaseBelongsToFetch.vue +213 -213
- package/src/components/BaseBoolean.stories.js +35 -35
- package/src/components/BaseBoolean.vue +26 -26
- package/src/components/BaseBreadcrumbs.stories.js +50 -50
- package/src/components/BaseBreadcrumbs.vue +109 -109
- package/src/components/BaseButton.stories.js +126 -126
- package/src/components/BaseButton.vue +279 -279
- package/src/components/BaseButtonGroup.stories.js +114 -114
- package/src/components/BaseButtonGroup.vue +193 -193
- package/src/components/BaseCard.stories.js +63 -63
- package/src/components/BaseCard.vue +49 -49
- package/src/components/BaseCardRow.vue +53 -53
- package/src/components/BaseCharacterCounter.stories.js +30 -30
- package/src/components/BaseCharacterCounter.vue +64 -64
- package/src/components/BaseCkeditor.vue +154 -154
- package/src/components/BaseClipboard.stories.js +55 -55
- package/src/components/BaseClipboard.vue +105 -105
- package/src/components/BaseCollapse.stories.js +168 -168
- package/src/components/BaseCollapse.vue +98 -98
- package/src/components/BaseColor.stories.js +66 -66
- package/src/components/BaseColor.vue +155 -155
- package/src/components/BaseContainer.stories.js +34 -34
- package/src/components/BaseContainer.vue +64 -64
- package/src/components/BaseCounter.stories.js +47 -47
- package/src/components/BaseCounter.vue +83 -83
- package/src/components/BaseCropper.stories.js +113 -113
- package/src/components/BaseCropper.vue +390 -390
- package/src/components/BaseCropperModal.stories.js +54 -54
- package/src/components/BaseCropperModal.vue +143 -143
- package/src/components/BaseDataIterator.stories.js +292 -292
- package/src/components/BaseDataIterator.vue +986 -986
- package/src/components/BaseDataIteratorSectionBox.vue +36 -36
- package/src/components/BaseDataIteratorSectionButton.vue +42 -42
- package/src/components/BaseDataIteratorSectionColumns.vue +150 -150
- package/src/components/BaseDataIteratorSectionModal.vue +41 -41
- package/src/components/BaseDataTable.stories.js +393 -393
- package/src/components/BaseDataTable.vue +966 -966
- package/src/components/BaseDataTableRowAction.vue +70 -70
- package/src/components/BaseDataTableTemplate.vue +831 -838
- package/src/components/BaseDatePicker.stories.js +166 -166
- package/src/components/BaseDatePicker.vue +372 -372
- package/src/components/BaseDateSelect.stories.js +68 -68
- package/src/components/BaseDateSelect.vue +222 -222
- package/src/components/BaseDescriptionList.stories.js +35 -35
- package/src/components/BaseDescriptionList.vue +13 -13
- package/src/components/BaseDescriptionListItem.vue +47 -47
- package/src/components/BaseDialog.stories.js +95 -95
- package/src/components/BaseDialog.vue +221 -221
- package/src/components/BaseDisplayRelativeTime.stories.js +47 -47
- package/src/components/BaseDisplayRelativeTime.vue +126 -126
- package/src/components/BaseDraggable.stories.js +34 -34
- package/src/components/BaseDraggable.vue +111 -111
- package/src/components/BaseDropdown.stories.js +164 -164
- package/src/components/BaseDropdown.vue +74 -74
- package/src/components/BaseDropdownAutocomplete.stories.js +208 -208
- package/src/components/BaseDropdownAutocomplete.vue +203 -203
- package/src/components/BaseField.vue +151 -151
- package/src/components/BaseFieldI18n.stories.js +37 -37
- package/src/components/BaseFieldI18n.vue +170 -170
- package/src/components/BaseFilePicker.stories.js +84 -84
- package/src/components/BaseFilePicker.vue +163 -163
- package/src/components/BaseFilePickerCrop.stories.js +135 -135
- package/src/components/BaseFilePickerCrop.vue +130 -130
- package/src/components/BaseFileUploader.stories.js +101 -101
- package/src/components/BaseFileUploader.vue +185 -185
- package/src/components/BaseForm.mdx +87 -87
- package/src/components/BaseForm.stories.js +133 -133
- package/src/components/BaseForm.vue +372 -372
- package/src/components/BaseGantt.stories.js +145 -145
- package/src/components/BaseGantt.vue +384 -384
- package/src/components/BaseHasMany.stories.js +211 -211
- package/src/components/BaseHasMany.vue +135 -135
- package/src/components/BaseHasManyFetch.stories.js +278 -278
- package/src/components/BaseHasManyFetch.vue +222 -222
- package/src/components/BaseHeader.stories.js +137 -137
- package/src/components/BaseHeader.vue +141 -141
- package/src/components/BaseIconPicker.stories.js +22 -22
- package/src/components/BaseIconPicker.vue +225 -225
- package/src/components/BaseInput.stories.js +202 -202
- package/src/components/BaseInput.vue +402 -402
- package/src/components/BaseInputError.vue +39 -39
- package/src/components/BaseInputLabel.stories.js +36 -36
- package/src/components/BaseInputLabel.vue +83 -83
- package/src/components/BaseInputPercent.stories.js +66 -66
- package/src/components/BaseInputPercent.vue +139 -139
- package/src/components/BaseJsonReader.stories.js +120 -120
- package/src/components/BaseJsonReader.vue +51 -51
- package/src/components/BaseJsonReaderItem.vue +119 -119
- package/src/components/BaseLayoutNotificationDropdown.vue +153 -153
- package/src/components/BaseLayoutNotificationItem.vue +53 -53
- package/src/components/BaseLayoutNotificationItemContent.vue +41 -41
- package/src/components/BaseLayoutSidebar.vue +300 -300
- package/src/components/BaseLayoutSidebarConfigurable.stories.js +217 -217
- package/src/components/BaseLayoutSidebarConfigurable.vue +202 -202
- package/src/components/BaseLayoutStacked.vue +78 -78
- package/src/components/BaseLayoutStackedConfigurable.stories.js +181 -181
- package/src/components/BaseLayoutStackedConfigurable.vue +196 -196
- package/src/components/BaseLazy.stories.js +59 -59
- package/src/components/BaseLazy.vue +80 -80
- package/src/components/BaseLoadingCover.stories.js +55 -55
- package/src/components/BaseLoadingCover.vue +101 -101
- package/src/components/BaseMediaGallery.vue +96 -96
- package/src/components/BaseMediaGalleryItem.vue +101 -101
- package/src/components/BaseMediaItem.stories.js +41 -41
- package/src/components/BaseMediaItem.vue +80 -80
- package/src/components/BaseMediaLibrary.stories.js +267 -267
- package/src/components/BaseMediaLibrary.vue +357 -357
- package/src/components/BaseMediaList.vue +67 -67
- package/src/components/BaseMediaListItem.vue +213 -213
- package/src/components/BaseMediaPictures.vue +64 -64
- package/src/components/BaseMediaPicturesItem.vue +100 -100
- package/src/components/BaseMediaPreview.stories.js +72 -72
- package/src/components/BaseMediaPreview.vue +106 -106
- package/src/components/BaseMenu.stories.js +134 -134
- package/src/components/BaseMenu.vue +187 -187
- package/src/components/BaseMenuItem.vue +177 -177
- package/src/components/BaseModalCenter.stories.js +68 -68
- package/src/components/BaseModalCenter.vue +128 -128
- package/src/components/BaseModalSide.stories.js +61 -61
- package/src/components/BaseModalSide.vue +130 -130
- package/src/components/BaseNavbar.stories.js +152 -152
- package/src/components/BaseNavbar.vue +191 -191
- package/src/components/BaseNavbarItem.vue +108 -108
- package/src/components/BaseNavbarItemContent.vue +124 -124
- package/src/components/BaseNavbarSideItem.vue +187 -187
- package/src/components/BaseNavbarSideItemContent.vue +126 -126
- package/src/components/BasePagination.stories.js +35 -35
- package/src/components/BasePagination.vue +266 -266
- package/src/components/BasePanel.stories.js +56 -56
- package/src/components/BasePanel.vue +42 -42
- package/src/components/BasePassword.stories.js +80 -80
- package/src/components/BasePassword.vue +87 -87
- package/src/components/BaseProgressCircle.stories.js +27 -27
- package/src/components/BaseProgressCircle.vue +80 -80
- package/src/components/BaseRadioGroup.stories.js +87 -87
- package/src/components/BaseRadioGroup.vue +124 -124
- package/src/components/BaseReadMore.stories.js +30 -30
- package/src/components/BaseReadMore.vue +73 -73
- package/src/components/BaseRichText.stories.js +90 -90
- package/src/components/BaseRichText.vue +87 -87
- package/src/components/BaseScrollColumn.vue +128 -128
- package/src/components/BaseSelect.stories.js +151 -151
- package/src/components/BaseSelect.vue +241 -241
- package/src/components/BaseShortcut.stories.js +100 -100
- package/src/components/BaseShortcut.vue +114 -114
- package/src/components/BaseSideNavigation.stories.js +85 -85
- package/src/components/BaseSideNavigation.vue +32 -32
- package/src/components/BaseSideNavigationItem.vue +99 -99
- package/src/components/BaseSkeleton.stories.js +36 -36
- package/src/components/BaseSkeleton.vue +40 -40
- package/src/components/BaseStatistic.stories.js +51 -51
- package/src/components/BaseStatistic.vue +98 -98
- package/src/components/BaseStepper.stories.js +94 -94
- package/src/components/BaseStepper.vue +72 -72
- package/src/components/BaseStepperItem.stories.js +65 -65
- package/src/components/BaseStepperItem.vue +149 -149
- package/src/components/BaseSwitch.stories.js +133 -133
- package/src/components/BaseSwitch.vue +228 -226
- package/src/components/BaseSystemAlert.stories.js +63 -63
- package/src/components/BaseSystemAlert.vue +89 -89
- package/src/components/BaseTabItem.vue +192 -192
- package/src/components/BaseTable.stories.js +214 -214
- package/src/components/BaseTable.vue +111 -111
- package/src/components/BaseTableBody.vue +14 -14
- package/src/components/BaseTableCell.vue +204 -204
- package/src/components/BaseTableColumn.vue +140 -140
- package/src/components/BaseTableHead.vue +38 -38
- package/src/components/BaseTableHeader.vue +139 -139
- package/src/components/BaseTableRow.vue +197 -197
- package/src/components/BaseTabs.stories.js +165 -165
- package/src/components/BaseTabs.vue +203 -203
- package/src/components/BaseTagAutocomplete.stories.js +271 -271
- package/src/components/BaseTagAutocomplete.vue +565 -565
- package/src/components/BaseTagAutocompleteFetch.stories.js +211 -211
- package/src/components/BaseTagAutocompleteFetch.vue +237 -237
- package/src/components/BaseTextarea.stories.js +81 -81
- package/src/components/BaseTextarea.vue +138 -138
- package/src/components/BaseTextareaAutoresize.stories.js +125 -125
- package/src/components/BaseTextareaAutoresize.vue +187 -187
- package/src/components/BaseTimePicker.stories.js +68 -68
- package/src/components/BaseTimePicker.vue +379 -379
- package/src/components/BaseTimeline.stories.js +55 -55
- package/src/components/BaseTimeline.vue +38 -38
- package/src/components/BaseTimelineItem.stories.js +77 -77
- package/src/components/BaseTimelineItem.vue +90 -90
- package/src/components/BaseToast.stories.js +50 -50
- package/src/components/BaseToast.vue +43 -43
- package/src/components/BaseTooltip.stories.js +65 -65
- package/src/components/BaseTooltip.vue +93 -93
- package/src/components/BaseUniqueCode.stories.js +36 -36
- package/src/components/BaseUniqueCode.vue +183 -183
- package/src/components/SlotComponent.ts +37 -37
- package/src/components/index.ts +222 -222
- package/src/composables/breakpoints.ts +94 -94
- package/src/composables/clickOutside.ts +80 -80
- package/src/composables/field.ts +156 -156
- package/src/composables/hasOptions.ts +86 -86
- package/src/composables/inputSize.ts +35 -35
- package/src/composables/isLastColumn.ts +30 -30
- package/src/composables/mediaQuery.ts +42 -42
- package/src/composables/modal.ts +73 -73
- package/src/composables/paginatedData.ts +76 -76
- package/src/composables/tooltip.ts +84 -84
- package/src/constants/MyConstants.ts +1 -1
- package/src/constants/index.ts +5 -5
- package/src/env.d.ts +15 -15
- package/src/i18n/index.ts +60 -60
- package/src/index.ts +138 -138
- package/src/lang/en.json +101 -101
- package/src/lang/fr.json +101 -101
- package/src/services/gantt/format.ts +133 -133
- package/src/services/gantt/timescale.ts +250 -250
- package/src/services/gantt/types.ts +81 -81
- package/src/services/table/classes.ts +37 -37
- package/src/services/table/customKeyActions.ts +2 -2
- package/src/services/table/types.ts +27 -27
- package/src/stores/dialogs.ts +48 -48
- package/src/stores/i18n.ts +14 -14
- package/src/stores/snackbars.ts +47 -47
- package/src/stores/systemAlerts.ts +32 -32
- package/src/stories/InputSizes.stories.js +21 -21
- package/src/stories/List.stories.js +136 -136
- package/src/stories/PageInputSizes.vue +228 -228
- package/src/stories/PageShow.vue +423 -423
- package/src/stories/Show.stories.js +21 -21
- package/src/svg/BaseEmptyState.vue +38 -38
- package/src/svg/BaseSpinnerLarge.vue +40 -40
- package/src/svg/BaseSpinnerSmall.vue +13 -13
- package/src/types/Color.ts +9 -9
- package/src/types/Country.ts +4 -4
- package/src/types/ImagePickerResult.ts +5 -5
- package/src/types/Media.ts +10 -10
- package/src/types/Notification.ts +11 -11
- package/src/types/Region.ts +5 -5
- package/src/types/Status.ts +5 -5
- package/src/types/StepperItem.ts +8 -8
- package/src/types/ToolbarOption.ts +1 -1
- package/src/types/UploadedFile.ts +11 -11
- package/src/types/User.ts +7 -7
- package/src/types/index.ts +302 -302
- package/src/utils/blob.ts +30 -30
- package/src/utils/colors.ts +239 -239
- package/src/utils/cropper/avatar.ts +33 -33
- package/src/utils/cropper/cover.ts +41 -41
- package/src/utils/cropper/presetInterface.ts +16 -16
- package/src/utils/cropper/presets.ts +7 -7
- package/src/utils/deepIncludes.ts +76 -76
- package/src/utils/fileSizeFormat.ts +15 -15
- package/src/utils/fileValidations.ts +26 -26
- package/src/utils/getApiData.ts +11 -11
- package/src/utils/index.ts +18 -18
- package/src/utils/resizeImageFromURI.ts +118 -118
- package/src/utils/scrollPreventer.ts +11 -11
- package/src/utils/sizeBehaviors.ts +3 -3
- package/src/utils/sizes.ts +38 -38
- package/src/utils/slots.ts +12 -12
- package/src/utils/storage.ts +36 -36
- package/src/utils/toHumanList.ts +20 -20
- package/src/utils/uuid.ts +7 -7
|
@@ -1,565 +1,565 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div ref="autocomplete">
|
|
3
|
-
<div
|
|
4
|
-
ref="inputRef"
|
|
5
|
-
:class="wrapperClass"
|
|
6
|
-
>
|
|
7
|
-
<slot
|
|
8
|
-
name="items"
|
|
9
|
-
:items="normalizedModelValue"
|
|
10
|
-
:remove-option="removeOption"
|
|
11
|
-
:disabled="disabled"
|
|
12
|
-
>
|
|
13
|
-
<div
|
|
14
|
-
v-for="selection in normalizedModelValue"
|
|
15
|
-
:key="selection.value ? selection.value : 'null'"
|
|
16
|
-
:class="selectionClass(selection)"
|
|
17
|
-
>
|
|
18
|
-
<div
|
|
19
|
-
:title="selection.label"
|
|
20
|
-
class="truncate"
|
|
21
|
-
>
|
|
22
|
-
{{ selection.label }}
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
<button
|
|
26
|
-
type="button"
|
|
27
|
-
tabindex="-1"
|
|
28
|
-
:class="selectionDeleteClasses"
|
|
29
|
-
@click="removeOption(selection)"
|
|
30
|
-
>
|
|
31
|
-
✕
|
|
32
|
-
</button>
|
|
33
|
-
</div>
|
|
34
|
-
</slot>
|
|
35
|
-
|
|
36
|
-
<input
|
|
37
|
-
ref="inputElement"
|
|
38
|
-
:value="keywords"
|
|
39
|
-
type="text"
|
|
40
|
-
:placeholder="placeholder ? placeholder : t('sui.select_an_item')"
|
|
41
|
-
:class="inputClasses"
|
|
42
|
-
autocomplete="off"
|
|
43
|
-
:disabled="disabled"
|
|
44
|
-
@focus="open"
|
|
45
|
-
@input="onTextInput"
|
|
46
|
-
@keydown="onTextKeydown"
|
|
47
|
-
>
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<Teleport
|
|
51
|
-
to="body"
|
|
52
|
-
:disabled="inline"
|
|
53
|
-
>
|
|
54
|
-
<div
|
|
55
|
-
v-if="dropdownOpened"
|
|
56
|
-
ref="dropdownRef"
|
|
57
|
-
:style="!inline ? { ...floatingStyles, width: inputRefWidth + 'px' } : {}"
|
|
58
|
-
class="min-h-[110px] overflow-hidden bg-white border-slate-300 input-rounded"
|
|
59
|
-
:class="[
|
|
60
|
-
inline
|
|
61
|
-
? 'relative border-b border-x rounded-t-none'
|
|
62
|
-
: 'fixed border shadow-2xl z-menu',
|
|
63
|
-
]"
|
|
64
|
-
>
|
|
65
|
-
<BaseAutocompleteDrawer
|
|
66
|
-
ref="drawer"
|
|
67
|
-
:selected="normalizedModelValue"
|
|
68
|
-
:options="filteredNormalizedOptions"
|
|
69
|
-
:size="size"
|
|
70
|
-
:loading="loading"
|
|
71
|
-
:loading-bottom="loadingBottom"
|
|
72
|
-
tw-drawer="p-1"
|
|
73
|
-
:keywords="keywords"
|
|
74
|
-
@select="onSelect"
|
|
75
|
-
@scroll-bottom="emit('scrollBottom')"
|
|
76
|
-
>
|
|
77
|
-
<template #empty="emptyProps">
|
|
78
|
-
<slot
|
|
79
|
-
name="empty"
|
|
80
|
-
v-bind="{ ...emptyProps, ...slotProps }"
|
|
81
|
-
/>
|
|
82
|
-
</template>
|
|
83
|
-
<template #option="optionProps">
|
|
84
|
-
<slot
|
|
85
|
-
name="option"
|
|
86
|
-
v-bind="{ ...optionProps, ...slotProps }"
|
|
87
|
-
/>
|
|
88
|
-
</template>
|
|
89
|
-
<template #footer="footerProps">
|
|
90
|
-
<slot
|
|
91
|
-
name="footer"
|
|
92
|
-
v-bind="{ ...footerProps, ...slotProps }"
|
|
93
|
-
/>
|
|
94
|
-
</template>
|
|
95
|
-
</BaseAutocompleteDrawer>
|
|
96
|
-
</div>
|
|
97
|
-
</Teleport>
|
|
98
|
-
</div>
|
|
99
|
-
</template>
|
|
100
|
-
|
|
101
|
-
<script lang="ts" setup>
|
|
102
|
-
import { cloneDeep, get } from 'lodash';
|
|
103
|
-
import { PropType, ComputedRef } from 'vue';
|
|
104
|
-
import { NormalizedOption, RawOption } from '@/types';
|
|
105
|
-
import { useHasOptions } from '@/composables/hasOptions';
|
|
106
|
-
import { useField } from '@/composables/field';
|
|
107
|
-
import { useClickOutside } from '@/composables/clickOutside';
|
|
108
|
-
import { useSnackbarsStore } from '@/stores/snackbars';
|
|
109
|
-
import BaseAutocompleteDrawer from './BaseAutocompleteDrawer.vue';
|
|
110
|
-
import { twMerge } from 'tailwind-merge';
|
|
111
|
-
import { t } from '@/i18n';
|
|
112
|
-
import { Size, sizes } from '@/utils/sizes';
|
|
113
|
-
import { autoUpdate, flip, offset, useFloating } from '@floating-ui/vue';
|
|
114
|
-
import { useElementBounding } from '@vueuse/core';
|
|
115
|
-
|
|
116
|
-
const snackbars = useSnackbarsStore();
|
|
117
|
-
|
|
118
|
-
const props = defineProps({
|
|
119
|
-
modelValue: {
|
|
120
|
-
required: true,
|
|
121
|
-
type: [Array, null] as PropType<RawOption[] | null>,
|
|
122
|
-
},
|
|
123
|
-
options: {
|
|
124
|
-
required: true,
|
|
125
|
-
type: Array as PropType<RawOption[]>,
|
|
126
|
-
},
|
|
127
|
-
labelKey: {
|
|
128
|
-
required: true,
|
|
129
|
-
type: [String, Function] as PropType<string | ((option: RawOption) => string)>,
|
|
130
|
-
},
|
|
131
|
-
valueKey: {
|
|
132
|
-
required: true,
|
|
133
|
-
type: [String, Function] as PropType<string | ((option: RawOption) => string)>,
|
|
134
|
-
},
|
|
135
|
-
name: {
|
|
136
|
-
default: undefined,
|
|
137
|
-
type: String,
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
placeholder: {
|
|
141
|
-
default: undefined,
|
|
142
|
-
type: String,
|
|
143
|
-
},
|
|
144
|
-
loading: {
|
|
145
|
-
default: false,
|
|
146
|
-
type: Boolean,
|
|
147
|
-
},
|
|
148
|
-
loadingBottom: {
|
|
149
|
-
default: false,
|
|
150
|
-
type: Boolean,
|
|
151
|
-
},
|
|
152
|
-
required: {
|
|
153
|
-
default: undefined,
|
|
154
|
-
type: Boolean,
|
|
155
|
-
},
|
|
156
|
-
disabled: {
|
|
157
|
-
default: false,
|
|
158
|
-
type: Boolean,
|
|
159
|
-
},
|
|
160
|
-
max: {
|
|
161
|
-
default: undefined,
|
|
162
|
-
type: Number,
|
|
163
|
-
},
|
|
164
|
-
filter: {
|
|
165
|
-
default: undefined,
|
|
166
|
-
type: Function as PropType<(option: NormalizedOption) => boolean>,
|
|
167
|
-
},
|
|
168
|
-
hasError: {
|
|
169
|
-
default: false,
|
|
170
|
-
type: Boolean,
|
|
171
|
-
},
|
|
172
|
-
inline: {
|
|
173
|
-
default: false,
|
|
174
|
-
type: Boolean,
|
|
175
|
-
},
|
|
176
|
-
size: {
|
|
177
|
-
default: undefined,
|
|
178
|
-
type: String as PropType<Size>,
|
|
179
|
-
},
|
|
180
|
-
dropdownShow: {
|
|
181
|
-
default: 'focus',
|
|
182
|
-
type: String as PropType<'focus' | 'always'>,
|
|
183
|
-
},
|
|
184
|
-
focusOnMount: {
|
|
185
|
-
default: false,
|
|
186
|
-
type: Boolean,
|
|
187
|
-
},
|
|
188
|
-
twContainer: {
|
|
189
|
-
default: '',
|
|
190
|
-
type: [String, Array] as PropType<string | string[]>,
|
|
191
|
-
},
|
|
192
|
-
visibleFocus: {
|
|
193
|
-
default: true,
|
|
194
|
-
type: Boolean,
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
const emit = defineEmits([
|
|
199
|
-
'update:modelValue',
|
|
200
|
-
'typing',
|
|
201
|
-
'open',
|
|
202
|
-
'close',
|
|
203
|
-
'scrollBottom',
|
|
204
|
-
]);
|
|
205
|
-
|
|
206
|
-
const { hasErrorInternal, emitUpdate, sizeInternal } = useField({
|
|
207
|
-
name: computed(() => props.name),
|
|
208
|
-
required: computed(() => props.required),
|
|
209
|
-
size: computed(() => props.size),
|
|
210
|
-
hasError: computed(() => props.hasError),
|
|
211
|
-
emit: emit,
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
const hasOptions = useHasOptions(
|
|
215
|
-
computed(() => props.modelValue),
|
|
216
|
-
computed(() => props.options),
|
|
217
|
-
computed(() => props.labelKey),
|
|
218
|
-
computed(() => props.valueKey),
|
|
219
|
-
computed(() => true)
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
onMounted(() => {
|
|
223
|
-
window.addEventListener('keydown', onWindowKeydown);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
onBeforeUnmount(() => {
|
|
227
|
-
window.removeEventListener('keydown', onWindowKeydown);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
function onWindowKeydown(event: KeyboardEvent) {
|
|
231
|
-
|
|
232
|
-
if (!opened.value) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const key = event.key;
|
|
237
|
-
|
|
238
|
-
if (key === 'Tab') {
|
|
239
|
-
close();
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (key === 'Escape') {
|
|
243
|
-
close();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
let openOfFocusTimeout = 0;
|
|
248
|
-
|
|
249
|
-
onMounted(() => {
|
|
250
|
-
openOfFocusTimeout = setTimeout(() => {
|
|
251
|
-
if (props.focusOnMount) {
|
|
252
|
-
open();
|
|
253
|
-
}
|
|
254
|
-
}, 10)
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
onBeforeUnmount(() => {
|
|
258
|
-
clearTimeout(openOfFocusTimeout);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
const inputRef = ref<HTMLElement | null>(null);
|
|
262
|
-
const dropdownRef = ref<HTMLElement | null>(null);
|
|
263
|
-
const drawer = ref<InstanceType<typeof BaseAutocompleteDrawer> | null>(null);
|
|
264
|
-
|
|
265
|
-
const keywords = ref('');
|
|
266
|
-
const autocomplete = ref<HTMLElement | null>(null);
|
|
267
|
-
const inputElement = ref<HTMLInputElement | null>(null);
|
|
268
|
-
const shouldFilter = ref(false);
|
|
269
|
-
const opened = ref(false);
|
|
270
|
-
const selectionToDelete = ref<NormalizedOption | null>(null);
|
|
271
|
-
|
|
272
|
-
const dropdownOpened = computed(() => opened.value || props.dropdownShow == 'always');
|
|
273
|
-
|
|
274
|
-
const isSelected = hasOptions.isSelected;
|
|
275
|
-
const normalizedOptions = hasOptions.normalizedOptions;
|
|
276
|
-
const normalizedModelValue = hasOptions.normalizedModelValue as ComputedRef<
|
|
277
|
-
NormalizedOption[]
|
|
278
|
-
>;
|
|
279
|
-
|
|
280
|
-
const filteredNormalizedOptions = computed((): NormalizedOption[] => {
|
|
281
|
-
return normalizedOptions.value
|
|
282
|
-
.filter((option) => {
|
|
283
|
-
if (shouldFilter.value === false) {
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
if (props.filter !== undefined) {
|
|
287
|
-
return props.filter(option);
|
|
288
|
-
}
|
|
289
|
-
if (!option.label) {
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
return option.label.toLowerCase().includes(keywords.value.toLowerCase());
|
|
293
|
-
})
|
|
294
|
-
.filter((option) => {
|
|
295
|
-
return !isSelected(option);
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
useClickOutside(autocomplete, () => {
|
|
300
|
-
close();
|
|
301
|
-
}, { includes: () => [dropdownRef] });
|
|
302
|
-
|
|
303
|
-
function open() {
|
|
304
|
-
// Always focus as a safety
|
|
305
|
-
focus();
|
|
306
|
-
// Only emit open if value changes
|
|
307
|
-
if (!opened.value) {
|
|
308
|
-
opened.value = true;
|
|
309
|
-
emit('open');
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
function close() {
|
|
314
|
-
shouldFilter.value = false;
|
|
315
|
-
opened.value = false;
|
|
316
|
-
selectionToDelete.value = null;
|
|
317
|
-
blur();
|
|
318
|
-
emit('close');
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const onTextInput = (event: Event) => {
|
|
322
|
-
open();
|
|
323
|
-
shouldFilter.value = true;
|
|
324
|
-
setKeywords(get(event, 'target.value', '') + '');
|
|
325
|
-
emit('typing', keywords.value);
|
|
326
|
-
|
|
327
|
-
selectionToDelete.value = null;
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
const onTextKeydown = (event: KeyboardEvent) => {
|
|
331
|
-
const key = event.key;
|
|
332
|
-
|
|
333
|
-
drawer.value?.onKeydown(event);
|
|
334
|
-
|
|
335
|
-
// Prevent default behavior for up/down arrows
|
|
336
|
-
|
|
337
|
-
if (key === 'ArrowUp') {
|
|
338
|
-
event.preventDefault();
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (key === 'ArrowDown') {
|
|
343
|
-
event.preventDefault();
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Attempt to remove last selection on backspace
|
|
348
|
-
if (key === 'Backspace' && keywords.value == '') {
|
|
349
|
-
attemptRemoveLastSelection();
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
const onSelect = (option: NormalizedOption) => {
|
|
355
|
-
focus();
|
|
356
|
-
|
|
357
|
-
if (props.max && normalizedModelValue.value.length >= props.max) {
|
|
358
|
-
snackbars.push({
|
|
359
|
-
title: t('sui.whoops'),
|
|
360
|
-
text: t('sui.you_cannot_select_more_than_x_items', {
|
|
361
|
-
count: props.max,
|
|
362
|
-
}),
|
|
363
|
-
color: 'warning',
|
|
364
|
-
});
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (isSelected(option)) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
selectionToDelete.value = null;
|
|
373
|
-
update([...normalizedModelValue.value, option]);
|
|
374
|
-
setKeywords('');
|
|
375
|
-
emit('typing', keywords.value);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
function update(value: NormalizedOption[]) {
|
|
379
|
-
// Re-activate filter
|
|
380
|
-
shouldFilter.value = false;
|
|
381
|
-
// Emit update
|
|
382
|
-
emitUpdate(value.map((v) => v.option));
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function setKeywords(input: string) {
|
|
386
|
-
keywords.value = input;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
function focus() {
|
|
390
|
-
inputElement.value?.focus();
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
function blur() {
|
|
394
|
-
inputElement.value?.blur();
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const slotProps = {
|
|
398
|
-
focus,
|
|
399
|
-
blur,
|
|
400
|
-
open,
|
|
401
|
-
close,
|
|
402
|
-
keywords: computed(() => keywords.value),
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
const attemptRemoveLastSelection = () => {
|
|
406
|
-
const optionValueToDelete =
|
|
407
|
-
normalizedModelValue.value[normalizedModelValue.value.length - 1] ?? null;
|
|
408
|
-
|
|
409
|
-
if (
|
|
410
|
-
selectionToDelete.value &&
|
|
411
|
-
optionValueToDelete &&
|
|
412
|
-
optionValueToDelete.value == selectionToDelete.value.value
|
|
413
|
-
) {
|
|
414
|
-
removeOption(selectionToDelete.value);
|
|
415
|
-
selectionToDelete.value = null;
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
selectionToDelete.value =
|
|
420
|
-
normalizedModelValue.value.find((v) => {
|
|
421
|
-
return v.value === optionValueToDelete.value;
|
|
422
|
-
}) ?? null;
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
const removeOption = (option: NormalizedOption) => {
|
|
426
|
-
|
|
427
|
-
if (props.disabled) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
focus();
|
|
432
|
-
let newModelValue = cloneDeep(normalizedModelValue.value);
|
|
433
|
-
newModelValue = newModelValue.filter((v) => v.value != option.value);
|
|
434
|
-
update(newModelValue);
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
// Floating UI
|
|
438
|
-
|
|
439
|
-
const inputRefRect = useElementBounding(inputRef);
|
|
440
|
-
const inputRefWidth = computed(() => {
|
|
441
|
-
return inputRefRect.width.value;
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
const { floatingStyles } = useFloating(inputRef, dropdownRef, {
|
|
445
|
-
middleware: [offset(4), flip({
|
|
446
|
-
fallbackPlacements: ['right', 'bottom'],
|
|
447
|
-
})],
|
|
448
|
-
whileElementsMounted: autoUpdate,
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// Element Classes
|
|
452
|
-
|
|
453
|
-
const wrapperClass = computed(() => {
|
|
454
|
-
const base = 'relative z-[1] input-rounded border bg-white flex flex-wrap';
|
|
455
|
-
const error = hasErrorInternal.value ? 'border-red-600' : 'border-slate-300'
|
|
456
|
-
const height = {
|
|
457
|
-
'xs': 'min-h-control-xs gap-0.5 p-0.5',
|
|
458
|
-
'sm': 'min-h-control-sm gap-0.5 p-0.5',
|
|
459
|
-
'md': 'min-h-control-md gap-1 p-1',
|
|
460
|
-
'lg': 'min-h-control-lg gap-1 p-1',
|
|
461
|
-
'xl': 'min-h-control-xl gap-1 p-1',
|
|
462
|
-
}[sizeInternal.value];
|
|
463
|
-
|
|
464
|
-
const focus = (dropdownOpened.value && !props.inline) ? 'input-focus border-blue-300' : '';
|
|
465
|
-
const inline = (dropdownOpened.value && props.inline) ? 'rounded-b-none' : '';
|
|
466
|
-
|
|
467
|
-
const internalClasses = [base, error, height, focus, inline];
|
|
468
|
-
|
|
469
|
-
if (props.twContainer) {
|
|
470
|
-
return twMerge(internalClasses, props.twContainer);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
return internalClasses;
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
const innerHeight = computed(() => {
|
|
477
|
-
const height = {
|
|
478
|
-
'xs': 'h-[calc(theme(spacing.control-xs)_-_theme(spacing[0.5])_-_theme(spacing[0.5])_-_2px)]',
|
|
479
|
-
'sm': 'h-[calc(theme(spacing.control-sm)_-_theme(spacing[0.5])_-_theme(spacing[0.5])_-_2px)]',
|
|
480
|
-
'md': 'h-[calc(theme(spacing.control-md)_-_theme(spacing.1)_-_theme(spacing.1)_-_2px)]',
|
|
481
|
-
'lg': 'h-[calc(theme(spacing.control-lg)_-_theme(spacing.1)_-_theme(spacing.1)_-_2px)]',
|
|
482
|
-
'xl': 'h-[calc(theme(spacing.control-xl)_-_theme(spacing.1)_-_theme(spacing.1)_-_2px)]',
|
|
483
|
-
}[sizeInternal.value];
|
|
484
|
-
|
|
485
|
-
return height;
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
const inputClasses = computed(() => {
|
|
489
|
-
const base = 'grow min-w-[50px] py-0 border-none shadow-none outline-none bg-transparent';
|
|
490
|
-
const focus = 'focus:border-none focus:shadow-none focus:outline-none focus:ring-0';
|
|
491
|
-
const disabled = 'disabled:cursor-not-allowed';
|
|
492
|
-
const sizeConfig = sizes[sizeInternal.value];
|
|
493
|
-
|
|
494
|
-
const inline = props.inline ? 'relative focus:ring-0 focus:border-slate-300' : '';
|
|
495
|
-
const inlineOpen = props.inline && dropdownOpened.value ? 'rounded-b-none' : '';
|
|
496
|
-
|
|
497
|
-
const padding = {
|
|
498
|
-
'xs': 'pl-1.5',
|
|
499
|
-
'sm': 'pl-2',
|
|
500
|
-
'md': 'pl-2.5',
|
|
501
|
-
'lg': 'pl-2.5',
|
|
502
|
-
'xl': 'pl-2.5',
|
|
503
|
-
}[sizeInternal.value];
|
|
504
|
-
|
|
505
|
-
return [base, padding, innerHeight.value, focus, disabled, sizeConfig.fontSize, inline, inlineOpen];
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
const selectionClass = (selection: NormalizedOption): string => {
|
|
509
|
-
|
|
510
|
-
const base = 'flex items-center rounded border overflow-hidden';
|
|
511
|
-
|
|
512
|
-
const fontSize = {
|
|
513
|
-
'xs': 'text-xs',
|
|
514
|
-
'sm': 'text-xs',
|
|
515
|
-
'md': 'text-sm',
|
|
516
|
-
'lg': 'text-base',
|
|
517
|
-
'xl': 'text-base',
|
|
518
|
-
}[sizeInternal.value];
|
|
519
|
-
|
|
520
|
-
const padding = {
|
|
521
|
-
'xs': 'pl-2',
|
|
522
|
-
'sm': 'pl-2',
|
|
523
|
-
'md': 'pl-3',
|
|
524
|
-
'lg': 'pl-3',
|
|
525
|
-
'xl': 'pl-4',
|
|
526
|
-
}[sizeInternal.value];
|
|
527
|
-
|
|
528
|
-
let color = 'bg-slate-200 border-slate-300';
|
|
529
|
-
|
|
530
|
-
if (
|
|
531
|
-
selectionToDelete.value &&
|
|
532
|
-
selectionToDelete.value.value == selection.value
|
|
533
|
-
) {
|
|
534
|
-
color = 'bg-red-200 border-red-300 text-red-800';
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const disabled = props.disabled ? 'cursor-not-allowed opacity-60' : '';
|
|
538
|
-
|
|
539
|
-
return twMerge(base, innerHeight.value, padding, color, disabled, fontSize);
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
const selectionDeleteClasses = computed(() => {
|
|
543
|
-
const base = 'flex shrink-0 appearance-none items-center justify-center border-0 bg-transparent outline-none';
|
|
544
|
-
|
|
545
|
-
const padding = {
|
|
546
|
-
'xs': 'pl-1 pr-2',
|
|
547
|
-
'sm': 'pl-1 pr-2',
|
|
548
|
-
'md': 'pl-1 pr-3',
|
|
549
|
-
'lg': 'pl-2 pr-3',
|
|
550
|
-
'xl': 'pl-3 pr-4',
|
|
551
|
-
}[sizeInternal.value];
|
|
552
|
-
|
|
553
|
-
const disabled = props.disabled ? 'cursor-not-allowed opacity-60' : '';
|
|
554
|
-
|
|
555
|
-
return twMerge(base, padding, disabled);
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
defineExpose({
|
|
559
|
-
focus,
|
|
560
|
-
blur,
|
|
561
|
-
close,
|
|
562
|
-
open,
|
|
563
|
-
setKeywords,
|
|
564
|
-
});
|
|
565
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="autocomplete">
|
|
3
|
+
<div
|
|
4
|
+
ref="inputRef"
|
|
5
|
+
:class="wrapperClass"
|
|
6
|
+
>
|
|
7
|
+
<slot
|
|
8
|
+
name="items"
|
|
9
|
+
:items="normalizedModelValue"
|
|
10
|
+
:remove-option="removeOption"
|
|
11
|
+
:disabled="disabled"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
v-for="selection in normalizedModelValue"
|
|
15
|
+
:key="selection.value ? selection.value : 'null'"
|
|
16
|
+
:class="selectionClass(selection)"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
:title="selection.label"
|
|
20
|
+
class="truncate"
|
|
21
|
+
>
|
|
22
|
+
{{ selection.label }}
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
tabindex="-1"
|
|
28
|
+
:class="selectionDeleteClasses"
|
|
29
|
+
@click="removeOption(selection)"
|
|
30
|
+
>
|
|
31
|
+
✕
|
|
32
|
+
</button>
|
|
33
|
+
</div>
|
|
34
|
+
</slot>
|
|
35
|
+
|
|
36
|
+
<input
|
|
37
|
+
ref="inputElement"
|
|
38
|
+
:value="keywords"
|
|
39
|
+
type="text"
|
|
40
|
+
:placeholder="placeholder ? placeholder : t('sui.select_an_item')"
|
|
41
|
+
:class="inputClasses"
|
|
42
|
+
autocomplete="off"
|
|
43
|
+
:disabled="disabled"
|
|
44
|
+
@focus="open"
|
|
45
|
+
@input="onTextInput"
|
|
46
|
+
@keydown="onTextKeydown"
|
|
47
|
+
>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<Teleport
|
|
51
|
+
to="body"
|
|
52
|
+
:disabled="inline"
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
v-if="dropdownOpened"
|
|
56
|
+
ref="dropdownRef"
|
|
57
|
+
:style="!inline ? { ...floatingStyles, width: inputRefWidth + 'px' } : {}"
|
|
58
|
+
class="min-h-[110px] overflow-hidden bg-white border-slate-300 input-rounded"
|
|
59
|
+
:class="[
|
|
60
|
+
inline
|
|
61
|
+
? 'relative border-b border-x rounded-t-none'
|
|
62
|
+
: 'fixed border shadow-2xl z-menu',
|
|
63
|
+
]"
|
|
64
|
+
>
|
|
65
|
+
<BaseAutocompleteDrawer
|
|
66
|
+
ref="drawer"
|
|
67
|
+
:selected="normalizedModelValue"
|
|
68
|
+
:options="filteredNormalizedOptions"
|
|
69
|
+
:size="size"
|
|
70
|
+
:loading="loading"
|
|
71
|
+
:loading-bottom="loadingBottom"
|
|
72
|
+
tw-drawer="p-1"
|
|
73
|
+
:keywords="keywords"
|
|
74
|
+
@select="onSelect"
|
|
75
|
+
@scroll-bottom="emit('scrollBottom')"
|
|
76
|
+
>
|
|
77
|
+
<template #empty="emptyProps">
|
|
78
|
+
<slot
|
|
79
|
+
name="empty"
|
|
80
|
+
v-bind="{ ...emptyProps, ...slotProps }"
|
|
81
|
+
/>
|
|
82
|
+
</template>
|
|
83
|
+
<template #option="optionProps">
|
|
84
|
+
<slot
|
|
85
|
+
name="option"
|
|
86
|
+
v-bind="{ ...optionProps, ...slotProps }"
|
|
87
|
+
/>
|
|
88
|
+
</template>
|
|
89
|
+
<template #footer="footerProps">
|
|
90
|
+
<slot
|
|
91
|
+
name="footer"
|
|
92
|
+
v-bind="{ ...footerProps, ...slotProps }"
|
|
93
|
+
/>
|
|
94
|
+
</template>
|
|
95
|
+
</BaseAutocompleteDrawer>
|
|
96
|
+
</div>
|
|
97
|
+
</Teleport>
|
|
98
|
+
</div>
|
|
99
|
+
</template>
|
|
100
|
+
|
|
101
|
+
<script lang="ts" setup>
|
|
102
|
+
import { cloneDeep, get } from 'lodash';
|
|
103
|
+
import { PropType, ComputedRef } from 'vue';
|
|
104
|
+
import { NormalizedOption, RawOption } from '@/types';
|
|
105
|
+
import { useHasOptions } from '@/composables/hasOptions';
|
|
106
|
+
import { useField } from '@/composables/field';
|
|
107
|
+
import { useClickOutside } from '@/composables/clickOutside';
|
|
108
|
+
import { useSnackbarsStore } from '@/stores/snackbars';
|
|
109
|
+
import BaseAutocompleteDrawer from './BaseAutocompleteDrawer.vue';
|
|
110
|
+
import { twMerge } from 'tailwind-merge';
|
|
111
|
+
import { t } from '@/i18n';
|
|
112
|
+
import { Size, sizes } from '@/utils/sizes';
|
|
113
|
+
import { autoUpdate, flip, offset, useFloating } from '@floating-ui/vue';
|
|
114
|
+
import { useElementBounding } from '@vueuse/core';
|
|
115
|
+
|
|
116
|
+
const snackbars = useSnackbarsStore();
|
|
117
|
+
|
|
118
|
+
const props = defineProps({
|
|
119
|
+
modelValue: {
|
|
120
|
+
required: true,
|
|
121
|
+
type: [Array, null] as PropType<RawOption[] | null>,
|
|
122
|
+
},
|
|
123
|
+
options: {
|
|
124
|
+
required: true,
|
|
125
|
+
type: Array as PropType<RawOption[]>,
|
|
126
|
+
},
|
|
127
|
+
labelKey: {
|
|
128
|
+
required: true,
|
|
129
|
+
type: [String, Function] as PropType<string | ((option: RawOption) => string)>,
|
|
130
|
+
},
|
|
131
|
+
valueKey: {
|
|
132
|
+
required: true,
|
|
133
|
+
type: [String, Function] as PropType<string | ((option: RawOption) => string)>,
|
|
134
|
+
},
|
|
135
|
+
name: {
|
|
136
|
+
default: undefined,
|
|
137
|
+
type: String,
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
placeholder: {
|
|
141
|
+
default: undefined,
|
|
142
|
+
type: String,
|
|
143
|
+
},
|
|
144
|
+
loading: {
|
|
145
|
+
default: false,
|
|
146
|
+
type: Boolean,
|
|
147
|
+
},
|
|
148
|
+
loadingBottom: {
|
|
149
|
+
default: false,
|
|
150
|
+
type: Boolean,
|
|
151
|
+
},
|
|
152
|
+
required: {
|
|
153
|
+
default: undefined,
|
|
154
|
+
type: Boolean,
|
|
155
|
+
},
|
|
156
|
+
disabled: {
|
|
157
|
+
default: false,
|
|
158
|
+
type: Boolean,
|
|
159
|
+
},
|
|
160
|
+
max: {
|
|
161
|
+
default: undefined,
|
|
162
|
+
type: Number,
|
|
163
|
+
},
|
|
164
|
+
filter: {
|
|
165
|
+
default: undefined,
|
|
166
|
+
type: Function as PropType<(option: NormalizedOption) => boolean>,
|
|
167
|
+
},
|
|
168
|
+
hasError: {
|
|
169
|
+
default: false,
|
|
170
|
+
type: Boolean,
|
|
171
|
+
},
|
|
172
|
+
inline: {
|
|
173
|
+
default: false,
|
|
174
|
+
type: Boolean,
|
|
175
|
+
},
|
|
176
|
+
size: {
|
|
177
|
+
default: undefined,
|
|
178
|
+
type: String as PropType<Size>,
|
|
179
|
+
},
|
|
180
|
+
dropdownShow: {
|
|
181
|
+
default: 'focus',
|
|
182
|
+
type: String as PropType<'focus' | 'always'>,
|
|
183
|
+
},
|
|
184
|
+
focusOnMount: {
|
|
185
|
+
default: false,
|
|
186
|
+
type: Boolean,
|
|
187
|
+
},
|
|
188
|
+
twContainer: {
|
|
189
|
+
default: '',
|
|
190
|
+
type: [String, Array] as PropType<string | string[]>,
|
|
191
|
+
},
|
|
192
|
+
visibleFocus: {
|
|
193
|
+
default: true,
|
|
194
|
+
type: Boolean,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const emit = defineEmits([
|
|
199
|
+
'update:modelValue',
|
|
200
|
+
'typing',
|
|
201
|
+
'open',
|
|
202
|
+
'close',
|
|
203
|
+
'scrollBottom',
|
|
204
|
+
]);
|
|
205
|
+
|
|
206
|
+
const { hasErrorInternal, emitUpdate, sizeInternal } = useField({
|
|
207
|
+
name: computed(() => props.name),
|
|
208
|
+
required: computed(() => props.required),
|
|
209
|
+
size: computed(() => props.size),
|
|
210
|
+
hasError: computed(() => props.hasError),
|
|
211
|
+
emit: emit,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const hasOptions = useHasOptions(
|
|
215
|
+
computed(() => props.modelValue),
|
|
216
|
+
computed(() => props.options),
|
|
217
|
+
computed(() => props.labelKey),
|
|
218
|
+
computed(() => props.valueKey),
|
|
219
|
+
computed(() => true)
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
onMounted(() => {
|
|
223
|
+
window.addEventListener('keydown', onWindowKeydown);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
onBeforeUnmount(() => {
|
|
227
|
+
window.removeEventListener('keydown', onWindowKeydown);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
function onWindowKeydown(event: KeyboardEvent) {
|
|
231
|
+
|
|
232
|
+
if (!opened.value) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const key = event.key;
|
|
237
|
+
|
|
238
|
+
if (key === 'Tab') {
|
|
239
|
+
close();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (key === 'Escape') {
|
|
243
|
+
close();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
let openOfFocusTimeout = 0;
|
|
248
|
+
|
|
249
|
+
onMounted(() => {
|
|
250
|
+
openOfFocusTimeout = setTimeout(() => {
|
|
251
|
+
if (props.focusOnMount) {
|
|
252
|
+
open();
|
|
253
|
+
}
|
|
254
|
+
}, 10)
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
onBeforeUnmount(() => {
|
|
258
|
+
clearTimeout(openOfFocusTimeout);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const inputRef = ref<HTMLElement | null>(null);
|
|
262
|
+
const dropdownRef = ref<HTMLElement | null>(null);
|
|
263
|
+
const drawer = ref<InstanceType<typeof BaseAutocompleteDrawer> | null>(null);
|
|
264
|
+
|
|
265
|
+
const keywords = ref('');
|
|
266
|
+
const autocomplete = ref<HTMLElement | null>(null);
|
|
267
|
+
const inputElement = ref<HTMLInputElement | null>(null);
|
|
268
|
+
const shouldFilter = ref(false);
|
|
269
|
+
const opened = ref(false);
|
|
270
|
+
const selectionToDelete = ref<NormalizedOption | null>(null);
|
|
271
|
+
|
|
272
|
+
const dropdownOpened = computed(() => opened.value || props.dropdownShow == 'always');
|
|
273
|
+
|
|
274
|
+
const isSelected = hasOptions.isSelected;
|
|
275
|
+
const normalizedOptions = hasOptions.normalizedOptions;
|
|
276
|
+
const normalizedModelValue = hasOptions.normalizedModelValue as ComputedRef<
|
|
277
|
+
NormalizedOption[]
|
|
278
|
+
>;
|
|
279
|
+
|
|
280
|
+
const filteredNormalizedOptions = computed((): NormalizedOption[] => {
|
|
281
|
+
return normalizedOptions.value
|
|
282
|
+
.filter((option) => {
|
|
283
|
+
if (shouldFilter.value === false) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
if (props.filter !== undefined) {
|
|
287
|
+
return props.filter(option);
|
|
288
|
+
}
|
|
289
|
+
if (!option.label) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
return option.label.toLowerCase().includes(keywords.value.toLowerCase());
|
|
293
|
+
})
|
|
294
|
+
.filter((option) => {
|
|
295
|
+
return !isSelected(option);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
useClickOutside(autocomplete, () => {
|
|
300
|
+
close();
|
|
301
|
+
}, { includes: () => [dropdownRef] });
|
|
302
|
+
|
|
303
|
+
function open() {
|
|
304
|
+
// Always focus as a safety
|
|
305
|
+
focus();
|
|
306
|
+
// Only emit open if value changes
|
|
307
|
+
if (!opened.value) {
|
|
308
|
+
opened.value = true;
|
|
309
|
+
emit('open');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function close() {
|
|
314
|
+
shouldFilter.value = false;
|
|
315
|
+
opened.value = false;
|
|
316
|
+
selectionToDelete.value = null;
|
|
317
|
+
blur();
|
|
318
|
+
emit('close');
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const onTextInput = (event: Event) => {
|
|
322
|
+
open();
|
|
323
|
+
shouldFilter.value = true;
|
|
324
|
+
setKeywords(get(event, 'target.value', '') + '');
|
|
325
|
+
emit('typing', keywords.value);
|
|
326
|
+
|
|
327
|
+
selectionToDelete.value = null;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
const onTextKeydown = (event: KeyboardEvent) => {
|
|
331
|
+
const key = event.key;
|
|
332
|
+
|
|
333
|
+
drawer.value?.onKeydown(event);
|
|
334
|
+
|
|
335
|
+
// Prevent default behavior for up/down arrows
|
|
336
|
+
|
|
337
|
+
if (key === 'ArrowUp') {
|
|
338
|
+
event.preventDefault();
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (key === 'ArrowDown') {
|
|
343
|
+
event.preventDefault();
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Attempt to remove last selection on backspace
|
|
348
|
+
if (key === 'Backspace' && keywords.value == '') {
|
|
349
|
+
attemptRemoveLastSelection();
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const onSelect = (option: NormalizedOption) => {
|
|
355
|
+
focus();
|
|
356
|
+
|
|
357
|
+
if (props.max && normalizedModelValue.value.length >= props.max) {
|
|
358
|
+
snackbars.push({
|
|
359
|
+
title: t('sui.whoops'),
|
|
360
|
+
text: t('sui.you_cannot_select_more_than_x_items', {
|
|
361
|
+
count: props.max,
|
|
362
|
+
}),
|
|
363
|
+
color: 'warning',
|
|
364
|
+
});
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (isSelected(option)) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
selectionToDelete.value = null;
|
|
373
|
+
update([...normalizedModelValue.value, option]);
|
|
374
|
+
setKeywords('');
|
|
375
|
+
emit('typing', keywords.value);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
function update(value: NormalizedOption[]) {
|
|
379
|
+
// Re-activate filter
|
|
380
|
+
shouldFilter.value = false;
|
|
381
|
+
// Emit update
|
|
382
|
+
emitUpdate(value.map((v) => v.option));
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function setKeywords(input: string) {
|
|
386
|
+
keywords.value = input;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function focus() {
|
|
390
|
+
inputElement.value?.focus();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function blur() {
|
|
394
|
+
inputElement.value?.blur();
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const slotProps = {
|
|
398
|
+
focus,
|
|
399
|
+
blur,
|
|
400
|
+
open,
|
|
401
|
+
close,
|
|
402
|
+
keywords: computed(() => keywords.value),
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
const attemptRemoveLastSelection = () => {
|
|
406
|
+
const optionValueToDelete =
|
|
407
|
+
normalizedModelValue.value[normalizedModelValue.value.length - 1] ?? null;
|
|
408
|
+
|
|
409
|
+
if (
|
|
410
|
+
selectionToDelete.value &&
|
|
411
|
+
optionValueToDelete &&
|
|
412
|
+
optionValueToDelete.value == selectionToDelete.value.value
|
|
413
|
+
) {
|
|
414
|
+
removeOption(selectionToDelete.value);
|
|
415
|
+
selectionToDelete.value = null;
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
selectionToDelete.value =
|
|
420
|
+
normalizedModelValue.value.find((v) => {
|
|
421
|
+
return v.value === optionValueToDelete.value;
|
|
422
|
+
}) ?? null;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const removeOption = (option: NormalizedOption) => {
|
|
426
|
+
|
|
427
|
+
if (props.disabled) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
focus();
|
|
432
|
+
let newModelValue = cloneDeep(normalizedModelValue.value);
|
|
433
|
+
newModelValue = newModelValue.filter((v) => v.value != option.value);
|
|
434
|
+
update(newModelValue);
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// Floating UI
|
|
438
|
+
|
|
439
|
+
const inputRefRect = useElementBounding(inputRef);
|
|
440
|
+
const inputRefWidth = computed(() => {
|
|
441
|
+
return inputRefRect.width.value;
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const { floatingStyles } = useFloating(inputRef, dropdownRef, {
|
|
445
|
+
middleware: [offset(4), flip({
|
|
446
|
+
fallbackPlacements: ['right', 'bottom'],
|
|
447
|
+
})],
|
|
448
|
+
whileElementsMounted: autoUpdate,
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// Element Classes
|
|
452
|
+
|
|
453
|
+
const wrapperClass = computed(() => {
|
|
454
|
+
const base = 'relative z-[1] input-rounded border bg-white flex flex-wrap';
|
|
455
|
+
const error = hasErrorInternal.value ? 'border-red-600' : 'border-slate-300'
|
|
456
|
+
const height = {
|
|
457
|
+
'xs': 'min-h-control-xs gap-0.5 p-0.5',
|
|
458
|
+
'sm': 'min-h-control-sm gap-0.5 p-0.5',
|
|
459
|
+
'md': 'min-h-control-md gap-1 p-1',
|
|
460
|
+
'lg': 'min-h-control-lg gap-1 p-1',
|
|
461
|
+
'xl': 'min-h-control-xl gap-1 p-1',
|
|
462
|
+
}[sizeInternal.value];
|
|
463
|
+
|
|
464
|
+
const focus = (dropdownOpened.value && !props.inline) ? 'input-focus border-blue-300' : '';
|
|
465
|
+
const inline = (dropdownOpened.value && props.inline) ? 'rounded-b-none' : '';
|
|
466
|
+
|
|
467
|
+
const internalClasses = [base, error, height, focus, inline];
|
|
468
|
+
|
|
469
|
+
if (props.twContainer) {
|
|
470
|
+
return twMerge(internalClasses, props.twContainer);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return internalClasses;
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
const innerHeight = computed(() => {
|
|
477
|
+
const height = {
|
|
478
|
+
'xs': 'h-[calc(theme(spacing.control-xs)_-_theme(spacing[0.5])_-_theme(spacing[0.5])_-_2px)]',
|
|
479
|
+
'sm': 'h-[calc(theme(spacing.control-sm)_-_theme(spacing[0.5])_-_theme(spacing[0.5])_-_2px)]',
|
|
480
|
+
'md': 'h-[calc(theme(spacing.control-md)_-_theme(spacing.1)_-_theme(spacing.1)_-_2px)]',
|
|
481
|
+
'lg': 'h-[calc(theme(spacing.control-lg)_-_theme(spacing.1)_-_theme(spacing.1)_-_2px)]',
|
|
482
|
+
'xl': 'h-[calc(theme(spacing.control-xl)_-_theme(spacing.1)_-_theme(spacing.1)_-_2px)]',
|
|
483
|
+
}[sizeInternal.value];
|
|
484
|
+
|
|
485
|
+
return height;
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
const inputClasses = computed(() => {
|
|
489
|
+
const base = 'grow min-w-[50px] py-0 border-none shadow-none outline-none bg-transparent';
|
|
490
|
+
const focus = 'focus:border-none focus:shadow-none focus:outline-none focus:ring-0';
|
|
491
|
+
const disabled = 'disabled:cursor-not-allowed';
|
|
492
|
+
const sizeConfig = sizes[sizeInternal.value];
|
|
493
|
+
|
|
494
|
+
const inline = props.inline ? 'relative focus:ring-0 focus:border-slate-300' : '';
|
|
495
|
+
const inlineOpen = props.inline && dropdownOpened.value ? 'rounded-b-none' : '';
|
|
496
|
+
|
|
497
|
+
const padding = {
|
|
498
|
+
'xs': 'pl-1.5',
|
|
499
|
+
'sm': 'pl-2',
|
|
500
|
+
'md': 'pl-2.5',
|
|
501
|
+
'lg': 'pl-2.5',
|
|
502
|
+
'xl': 'pl-2.5',
|
|
503
|
+
}[sizeInternal.value];
|
|
504
|
+
|
|
505
|
+
return [base, padding, innerHeight.value, focus, disabled, sizeConfig.fontSize, inline, inlineOpen];
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
const selectionClass = (selection: NormalizedOption): string => {
|
|
509
|
+
|
|
510
|
+
const base = 'flex items-center rounded border overflow-hidden';
|
|
511
|
+
|
|
512
|
+
const fontSize = {
|
|
513
|
+
'xs': 'text-xs',
|
|
514
|
+
'sm': 'text-xs',
|
|
515
|
+
'md': 'text-sm',
|
|
516
|
+
'lg': 'text-base',
|
|
517
|
+
'xl': 'text-base',
|
|
518
|
+
}[sizeInternal.value];
|
|
519
|
+
|
|
520
|
+
const padding = {
|
|
521
|
+
'xs': 'pl-2',
|
|
522
|
+
'sm': 'pl-2',
|
|
523
|
+
'md': 'pl-3',
|
|
524
|
+
'lg': 'pl-3',
|
|
525
|
+
'xl': 'pl-4',
|
|
526
|
+
}[sizeInternal.value];
|
|
527
|
+
|
|
528
|
+
let color = 'bg-slate-200 border-slate-300';
|
|
529
|
+
|
|
530
|
+
if (
|
|
531
|
+
selectionToDelete.value &&
|
|
532
|
+
selectionToDelete.value.value == selection.value
|
|
533
|
+
) {
|
|
534
|
+
color = 'bg-red-200 border-red-300 text-red-800';
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const disabled = props.disabled ? 'cursor-not-allowed opacity-60' : '';
|
|
538
|
+
|
|
539
|
+
return twMerge(base, innerHeight.value, padding, color, disabled, fontSize);
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
const selectionDeleteClasses = computed(() => {
|
|
543
|
+
const base = 'flex shrink-0 appearance-none items-center justify-center border-0 bg-transparent outline-none';
|
|
544
|
+
|
|
545
|
+
const padding = {
|
|
546
|
+
'xs': 'pl-1 pr-2',
|
|
547
|
+
'sm': 'pl-1 pr-2',
|
|
548
|
+
'md': 'pl-1 pr-3',
|
|
549
|
+
'lg': 'pl-2 pr-3',
|
|
550
|
+
'xl': 'pl-3 pr-4',
|
|
551
|
+
}[sizeInternal.value];
|
|
552
|
+
|
|
553
|
+
const disabled = props.disabled ? 'cursor-not-allowed opacity-60' : '';
|
|
554
|
+
|
|
555
|
+
return twMerge(base, padding, disabled);
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
defineExpose({
|
|
559
|
+
focus,
|
|
560
|
+
blur,
|
|
561
|
+
close,
|
|
562
|
+
open,
|
|
563
|
+
setKeywords,
|
|
564
|
+
});
|
|
565
|
+
</script>
|