sprintify-ui 0.10.65 → 0.10.66
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 +3324 -3461
- 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 +130 -130
- package/src/components/BaseBadge.vue +97 -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,390 +1,390 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="relative"
|
|
4
|
-
:style="{
|
|
5
|
-
width: cropperConfiguration?.boundary?.width + 'px',
|
|
6
|
-
}"
|
|
7
|
-
>
|
|
8
|
-
<slot
|
|
9
|
-
name="header"
|
|
10
|
-
:saving="saving"
|
|
11
|
-
:initializing="initializing"
|
|
12
|
-
v-bind="shared"
|
|
13
|
-
/>
|
|
14
|
-
|
|
15
|
-
<div
|
|
16
|
-
ref="container"
|
|
17
|
-
class="base-cropper-wrapper relative"
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
:style="{
|
|
21
|
-
width: cropperConfiguration?.boundary?.width + 'px',
|
|
22
|
-
height: cropperConfiguration?.showZoomer
|
|
23
|
-
? (cropperConfiguration?.boundary?.height ?? 0) + ZOOMER_HEIGHT + 'px'
|
|
24
|
-
: cropperConfiguration?.boundary?.height + 'px',
|
|
25
|
-
}"
|
|
26
|
-
>
|
|
27
|
-
<div
|
|
28
|
-
ref="croppie"
|
|
29
|
-
:style="{
|
|
30
|
-
visibility: initializing ? 'hidden' : 'visible',
|
|
31
|
-
}"
|
|
32
|
-
/>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div
|
|
36
|
-
v-show="!initializing"
|
|
37
|
-
class="absolute left-0 z-[1] flex w-full items-center justify-center"
|
|
38
|
-
:style="{
|
|
39
|
-
bottom: cropperConfiguration?.showZoomer
|
|
40
|
-
? ZOOMER_HEIGHT - 13 + 'px'
|
|
41
|
-
: 6 + 'px',
|
|
42
|
-
}"
|
|
43
|
-
>
|
|
44
|
-
<div class="flex overflow-hidden rounded-full shadow-md">
|
|
45
|
-
<button
|
|
46
|
-
type="button"
|
|
47
|
-
:disabled="disabled"
|
|
48
|
-
class="border-r border-slate-300 bg-white px-3 py-1.5 hover:bg-slate-100"
|
|
49
|
-
@click="rotateLeft"
|
|
50
|
-
>
|
|
51
|
-
<BaseIcon
|
|
52
|
-
icon="mdi:rotate-left"
|
|
53
|
-
class="h-4 w-4"
|
|
54
|
-
/>
|
|
55
|
-
</button>
|
|
56
|
-
<button
|
|
57
|
-
type="button"
|
|
58
|
-
:disabled="disabled"
|
|
59
|
-
class="bg-white px-3 py-1.5 hover:bg-slate-100"
|
|
60
|
-
@click="rotateRight"
|
|
61
|
-
>
|
|
62
|
-
<BaseIcon
|
|
63
|
-
icon="mdi:rotate-right"
|
|
64
|
-
class="h-4 w-4"
|
|
65
|
-
/>
|
|
66
|
-
</button>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<div
|
|
71
|
-
v-if="showDragHelp"
|
|
72
|
-
class="pointer-events-none absolute left-0 top-14 z-[1] flex w-full animate-pulse justify-center"
|
|
73
|
-
>
|
|
74
|
-
<div
|
|
75
|
-
class="flex items-center rounded-lg bg-black bg-opacity-75 px-3 py-1.5 text-center text-white"
|
|
76
|
-
>
|
|
77
|
-
<BaseIcon
|
|
78
|
-
icon="ri:drag-move-2-fill"
|
|
79
|
-
class="mr-1 h-5 w-5"
|
|
80
|
-
/>
|
|
81
|
-
<span>
|
|
82
|
-
{{ t('drag_to_reposition') }}
|
|
83
|
-
</span>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
|
|
87
|
-
<BaseLoadingCover
|
|
88
|
-
:delay="40"
|
|
89
|
-
class="z-[1]"
|
|
90
|
-
:model-value="initializing"
|
|
91
|
-
/>
|
|
92
|
-
</div>
|
|
93
|
-
|
|
94
|
-
<slot
|
|
95
|
-
name="footer"
|
|
96
|
-
:saving="saving"
|
|
97
|
-
:initializing="initializing"
|
|
98
|
-
v-bind="shared"
|
|
99
|
-
/>
|
|
100
|
-
</div>
|
|
101
|
-
</template>
|
|
102
|
-
|
|
103
|
-
<script lang="ts" setup>
|
|
104
|
-
import { onBeforeUnmount, Ref } from 'vue';
|
|
105
|
-
import Croppie, { CroppieOptions, CropType, ResultOptions } from 'croppie';
|
|
106
|
-
import { ref, onMounted } from 'vue';
|
|
107
|
-
import { resizeImageFromURI } from '@/utils';
|
|
108
|
-
import { cloneDeep, debounce } from 'lodash';
|
|
109
|
-
import { CropperConfig } from '../types';
|
|
110
|
-
import { BaseIcon, BaseLoadingCover } from '.';
|
|
111
|
-
import { presets } from '@/utils/cropper/presets';
|
|
112
|
-
import { t } from '@/i18n';
|
|
113
|
-
|
|
114
|
-
const props = defineProps<{
|
|
115
|
-
source: string;
|
|
116
|
-
config?: CropperConfig;
|
|
117
|
-
preset?: 'avatar' | 'cover';
|
|
118
|
-
presetOptions?: Record<string, any>;
|
|
119
|
-
disabled?: boolean;
|
|
120
|
-
saveOptions?: ResultOptions;
|
|
121
|
-
}>();
|
|
122
|
-
|
|
123
|
-
const RESIZE_MAX_SIZE = 1000;
|
|
124
|
-
const ZOOMER_HEIGHT = 44;
|
|
125
|
-
|
|
126
|
-
const container = ref(null) as Ref<HTMLElement | null>;
|
|
127
|
-
const croppie = ref(null) as Ref<HTMLElement | null>;
|
|
128
|
-
|
|
129
|
-
let lastSource = null as string | null;
|
|
130
|
-
let lastInitialResize = null as number | null;
|
|
131
|
-
let lastSourceResized = null as string | null;
|
|
132
|
-
|
|
133
|
-
let cropper = null as Croppie | null;
|
|
134
|
-
|
|
135
|
-
// Croppie initialization
|
|
136
|
-
const initializing = ref(false);
|
|
137
|
-
|
|
138
|
-
// Croppie saving cropped image
|
|
139
|
-
const saving = ref(false);
|
|
140
|
-
|
|
141
|
-
const showDragHelp = ref(false);
|
|
142
|
-
|
|
143
|
-
const sourceOriginalWidth = ref(0);
|
|
144
|
-
const sourceOriginalHeight = ref(0);
|
|
145
|
-
|
|
146
|
-
const resetViewPortDebounced = debounce(() => {
|
|
147
|
-
resetViewPort();
|
|
148
|
-
}, 100);
|
|
149
|
-
|
|
150
|
-
watch(
|
|
151
|
-
() =>
|
|
152
|
-
JSON.stringify({
|
|
153
|
-
...(props.config ?? {}),
|
|
154
|
-
source: props.source,
|
|
155
|
-
preset: props.preset,
|
|
156
|
-
presetOptions: props.presetOptions,
|
|
157
|
-
}),
|
|
158
|
-
() => {
|
|
159
|
-
resetViewPortDebounced();
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
onMounted(() => {
|
|
164
|
-
init();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
onBeforeUnmount(() => {
|
|
168
|
-
// Give time for animations to finish
|
|
169
|
-
setTimeout(() => {
|
|
170
|
-
destroy();
|
|
171
|
-
}, 400);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
const cropperConfiguration = computed<CroppieOptions>(() => {
|
|
175
|
-
let config = cloneDeep(props.config ?? {});
|
|
176
|
-
|
|
177
|
-
if (props.preset) {
|
|
178
|
-
const preset = presets[props.preset] ?? null;
|
|
179
|
-
|
|
180
|
-
if (preset) {
|
|
181
|
-
const presetClass = new preset(config, props.presetOptions);
|
|
182
|
-
config = presetClass.handle();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Put default values
|
|
187
|
-
|
|
188
|
-
config.width = config.width ?? 300;
|
|
189
|
-
config.height = config.height ?? 300;
|
|
190
|
-
config.maxWidth = config.maxWidth ?? undefined;
|
|
191
|
-
config.enableResize = config.enableResize ?? false;
|
|
192
|
-
config.enableZoom = config.enableZoom ?? true;
|
|
193
|
-
config.enableOrientation = config.enableOrientation ?? true;
|
|
194
|
-
config.showZoomer = config.showZoomer ?? true;
|
|
195
|
-
config.viewport = config.viewport ?? {
|
|
196
|
-
width: config.width,
|
|
197
|
-
height: config.height,
|
|
198
|
-
type: 'square' as CropType,
|
|
199
|
-
};
|
|
200
|
-
config.boundary = config.boundary ?? {
|
|
201
|
-
width: config.width,
|
|
202
|
-
height: config.height,
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
// Make sure values respect max width
|
|
206
|
-
|
|
207
|
-
if (config.maxWidth) {
|
|
208
|
-
const ratio = (config.width as number) / (config.height as number);
|
|
209
|
-
config.width = Math.min(config.width as number, config.maxWidth);
|
|
210
|
-
config.height = config.width / ratio;
|
|
211
|
-
config.boundary.width = Math.min(config.boundary.width, config.maxWidth);
|
|
212
|
-
config.boundary.height = config.boundary.width / ratio;
|
|
213
|
-
config.viewport.width = Math.min(config.viewport.width, config.maxWidth);
|
|
214
|
-
config.viewport.height = config.viewport.width / ratio;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
enableExif: true,
|
|
219
|
-
enableResize: config.enableResize,
|
|
220
|
-
enableZoom: config.enableZoom,
|
|
221
|
-
enableOrientation: config.enableOrientation,
|
|
222
|
-
showZoomer: config.showZoomer,
|
|
223
|
-
viewport: config.viewport,
|
|
224
|
-
boundary: config.boundary,
|
|
225
|
-
};
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
function init() {
|
|
229
|
-
if (initializing.value) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Start the loading state...
|
|
234
|
-
initializing.value = true;
|
|
235
|
-
|
|
236
|
-
// ...Give time to the loading state to render before doing CPU intensive tasks
|
|
237
|
-
setTimeout(async () => {
|
|
238
|
-
try {
|
|
239
|
-
await initCropper();
|
|
240
|
-
} catch (error) {
|
|
241
|
-
console.error(error);
|
|
242
|
-
} finally {
|
|
243
|
-
initializing.value = false;
|
|
244
|
-
}
|
|
245
|
-
}, 10);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function initCropper() {
|
|
249
|
-
if (croppie.value == null) {
|
|
250
|
-
throw new Error('Croppie element not found');
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
cropper = new Croppie(croppie.value, cropperConfiguration.value);
|
|
254
|
-
|
|
255
|
-
const sourceWasChanged = lastSource != props.source;
|
|
256
|
-
const initialResizeWasChanged =
|
|
257
|
-
lastInitialResize != props.config?.initialResize;
|
|
258
|
-
|
|
259
|
-
if (sourceWasChanged || initialResizeWasChanged) {
|
|
260
|
-
// Try to resize image to avoid using too much memory
|
|
261
|
-
lastSourceResized = await resizeImage(props.source);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
lastSource = props.source;
|
|
265
|
-
lastInitialResize = props.config?.initialResize ?? null;
|
|
266
|
-
|
|
267
|
-
lastSourceResized = lastSourceResized ?? props.source;
|
|
268
|
-
|
|
269
|
-
await cropper.bind({
|
|
270
|
-
url: lastSourceResized,
|
|
271
|
-
zoom: 0,
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
showDragHelp.value = true;
|
|
275
|
-
|
|
276
|
-
croppie.value.addEventListener('update', (a) => {
|
|
277
|
-
if (initializing.value) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
showDragHelp.value = false;
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
async function resizeImage(url: string): Promise<string> {
|
|
286
|
-
await getOriginalDimensions();
|
|
287
|
-
|
|
288
|
-
try {
|
|
289
|
-
const initialResize = getInitialResize();
|
|
290
|
-
|
|
291
|
-
if (!initialResize) {
|
|
292
|
-
return url;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return await resizeImageFromURI(
|
|
296
|
-
url,
|
|
297
|
-
initialResize.height,
|
|
298
|
-
initialResize.width
|
|
299
|
-
);
|
|
300
|
-
} catch (e: any) {
|
|
301
|
-
return url;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
async function save(
|
|
306
|
-
result?: ResultOptions
|
|
307
|
-
): Promise<HTMLCanvasElement | string | Blob | null> {
|
|
308
|
-
if (!cropper) {
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
saving.value = true;
|
|
313
|
-
|
|
314
|
-
const resultConfig = result ??
|
|
315
|
-
props.saveOptions ?? {
|
|
316
|
-
type: 'blob',
|
|
317
|
-
size: 'original',
|
|
318
|
-
circle: false,
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const r = await cropper.result(resultConfig);
|
|
322
|
-
|
|
323
|
-
saving.value = false;
|
|
324
|
-
|
|
325
|
-
return r;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function resetViewPort() {
|
|
329
|
-
if (!initializing.value) {
|
|
330
|
-
destroy();
|
|
331
|
-
init();
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function rotateLeft() {
|
|
336
|
-
cropper?.rotate(90);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function rotateRight() {
|
|
340
|
-
cropper?.rotate(-90);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const destroy = () => {
|
|
344
|
-
cropper?.destroy();
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
async function getOriginalDimensions() {
|
|
348
|
-
return new Promise((resolve) => {
|
|
349
|
-
const img = new Image();
|
|
350
|
-
img.src = props.source;
|
|
351
|
-
img.onload = () => {
|
|
352
|
-
sourceOriginalWidth.value = img.width;
|
|
353
|
-
sourceOriginalHeight.value = img.height;
|
|
354
|
-
resolve(true);
|
|
355
|
-
};
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function getInitialResize() {
|
|
360
|
-
const resizeMax = props.config?.initialResize ?? RESIZE_MAX_SIZE;
|
|
361
|
-
|
|
362
|
-
const reducedWidth =
|
|
363
|
-
sourceOriginalWidth.value > resizeMax
|
|
364
|
-
? resizeMax
|
|
365
|
-
: sourceOriginalWidth.value;
|
|
366
|
-
|
|
367
|
-
const reducedHeight =
|
|
368
|
-
sourceOriginalHeight.value > resizeMax
|
|
369
|
-
? resizeMax
|
|
370
|
-
: sourceOriginalHeight.value;
|
|
371
|
-
|
|
372
|
-
const ratioWidth = reducedWidth / sourceOriginalWidth.value;
|
|
373
|
-
const ratioHeight = reducedHeight / sourceOriginalHeight.value;
|
|
374
|
-
const ratio = ratioWidth > ratioHeight ? ratioWidth : ratioHeight;
|
|
375
|
-
|
|
376
|
-
return {
|
|
377
|
-
width: sourceOriginalWidth.value * ratio,
|
|
378
|
-
height: sourceOriginalHeight.value * ratio,
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const shared = {
|
|
383
|
-
save,
|
|
384
|
-
resetViewPort,
|
|
385
|
-
rotateLeft,
|
|
386
|
-
rotateRight,
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
defineExpose(shared);
|
|
390
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="relative"
|
|
4
|
+
:style="{
|
|
5
|
+
width: cropperConfiguration?.boundary?.width + 'px',
|
|
6
|
+
}"
|
|
7
|
+
>
|
|
8
|
+
<slot
|
|
9
|
+
name="header"
|
|
10
|
+
:saving="saving"
|
|
11
|
+
:initializing="initializing"
|
|
12
|
+
v-bind="shared"
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
ref="container"
|
|
17
|
+
class="base-cropper-wrapper relative"
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
:style="{
|
|
21
|
+
width: cropperConfiguration?.boundary?.width + 'px',
|
|
22
|
+
height: cropperConfiguration?.showZoomer
|
|
23
|
+
? (cropperConfiguration?.boundary?.height ?? 0) + ZOOMER_HEIGHT + 'px'
|
|
24
|
+
: cropperConfiguration?.boundary?.height + 'px',
|
|
25
|
+
}"
|
|
26
|
+
>
|
|
27
|
+
<div
|
|
28
|
+
ref="croppie"
|
|
29
|
+
:style="{
|
|
30
|
+
visibility: initializing ? 'hidden' : 'visible',
|
|
31
|
+
}"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div
|
|
36
|
+
v-show="!initializing"
|
|
37
|
+
class="absolute left-0 z-[1] flex w-full items-center justify-center"
|
|
38
|
+
:style="{
|
|
39
|
+
bottom: cropperConfiguration?.showZoomer
|
|
40
|
+
? ZOOMER_HEIGHT - 13 + 'px'
|
|
41
|
+
: 6 + 'px',
|
|
42
|
+
}"
|
|
43
|
+
>
|
|
44
|
+
<div class="flex overflow-hidden rounded-full shadow-md">
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
:disabled="disabled"
|
|
48
|
+
class="border-r border-slate-300 bg-white px-3 py-1.5 hover:bg-slate-100"
|
|
49
|
+
@click="rotateLeft"
|
|
50
|
+
>
|
|
51
|
+
<BaseIcon
|
|
52
|
+
icon="mdi:rotate-left"
|
|
53
|
+
class="h-4 w-4"
|
|
54
|
+
/>
|
|
55
|
+
</button>
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
:disabled="disabled"
|
|
59
|
+
class="bg-white px-3 py-1.5 hover:bg-slate-100"
|
|
60
|
+
@click="rotateRight"
|
|
61
|
+
>
|
|
62
|
+
<BaseIcon
|
|
63
|
+
icon="mdi:rotate-right"
|
|
64
|
+
class="h-4 w-4"
|
|
65
|
+
/>
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div
|
|
71
|
+
v-if="showDragHelp"
|
|
72
|
+
class="pointer-events-none absolute left-0 top-14 z-[1] flex w-full animate-pulse justify-center"
|
|
73
|
+
>
|
|
74
|
+
<div
|
|
75
|
+
class="flex items-center rounded-lg bg-black bg-opacity-75 px-3 py-1.5 text-center text-white"
|
|
76
|
+
>
|
|
77
|
+
<BaseIcon
|
|
78
|
+
icon="ri:drag-move-2-fill"
|
|
79
|
+
class="mr-1 h-5 w-5"
|
|
80
|
+
/>
|
|
81
|
+
<span>
|
|
82
|
+
{{ t('drag_to_reposition') }}
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<BaseLoadingCover
|
|
88
|
+
:delay="40"
|
|
89
|
+
class="z-[1]"
|
|
90
|
+
:model-value="initializing"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<slot
|
|
95
|
+
name="footer"
|
|
96
|
+
:saving="saving"
|
|
97
|
+
:initializing="initializing"
|
|
98
|
+
v-bind="shared"
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<script lang="ts" setup>
|
|
104
|
+
import { onBeforeUnmount, Ref } from 'vue';
|
|
105
|
+
import Croppie, { CroppieOptions, CropType, ResultOptions } from 'croppie';
|
|
106
|
+
import { ref, onMounted } from 'vue';
|
|
107
|
+
import { resizeImageFromURI } from '@/utils';
|
|
108
|
+
import { cloneDeep, debounce } from 'lodash';
|
|
109
|
+
import { CropperConfig } from '../types';
|
|
110
|
+
import { BaseIcon, BaseLoadingCover } from '.';
|
|
111
|
+
import { presets } from '@/utils/cropper/presets';
|
|
112
|
+
import { t } from '@/i18n';
|
|
113
|
+
|
|
114
|
+
const props = defineProps<{
|
|
115
|
+
source: string;
|
|
116
|
+
config?: CropperConfig;
|
|
117
|
+
preset?: 'avatar' | 'cover';
|
|
118
|
+
presetOptions?: Record<string, any>;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
saveOptions?: ResultOptions;
|
|
121
|
+
}>();
|
|
122
|
+
|
|
123
|
+
const RESIZE_MAX_SIZE = 1000;
|
|
124
|
+
const ZOOMER_HEIGHT = 44;
|
|
125
|
+
|
|
126
|
+
const container = ref(null) as Ref<HTMLElement | null>;
|
|
127
|
+
const croppie = ref(null) as Ref<HTMLElement | null>;
|
|
128
|
+
|
|
129
|
+
let lastSource = null as string | null;
|
|
130
|
+
let lastInitialResize = null as number | null;
|
|
131
|
+
let lastSourceResized = null as string | null;
|
|
132
|
+
|
|
133
|
+
let cropper = null as Croppie | null;
|
|
134
|
+
|
|
135
|
+
// Croppie initialization
|
|
136
|
+
const initializing = ref(false);
|
|
137
|
+
|
|
138
|
+
// Croppie saving cropped image
|
|
139
|
+
const saving = ref(false);
|
|
140
|
+
|
|
141
|
+
const showDragHelp = ref(false);
|
|
142
|
+
|
|
143
|
+
const sourceOriginalWidth = ref(0);
|
|
144
|
+
const sourceOriginalHeight = ref(0);
|
|
145
|
+
|
|
146
|
+
const resetViewPortDebounced = debounce(() => {
|
|
147
|
+
resetViewPort();
|
|
148
|
+
}, 100);
|
|
149
|
+
|
|
150
|
+
watch(
|
|
151
|
+
() =>
|
|
152
|
+
JSON.stringify({
|
|
153
|
+
...(props.config ?? {}),
|
|
154
|
+
source: props.source,
|
|
155
|
+
preset: props.preset,
|
|
156
|
+
presetOptions: props.presetOptions,
|
|
157
|
+
}),
|
|
158
|
+
() => {
|
|
159
|
+
resetViewPortDebounced();
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
onMounted(() => {
|
|
164
|
+
init();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
onBeforeUnmount(() => {
|
|
168
|
+
// Give time for animations to finish
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
destroy();
|
|
171
|
+
}, 400);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const cropperConfiguration = computed<CroppieOptions>(() => {
|
|
175
|
+
let config = cloneDeep(props.config ?? {});
|
|
176
|
+
|
|
177
|
+
if (props.preset) {
|
|
178
|
+
const preset = presets[props.preset] ?? null;
|
|
179
|
+
|
|
180
|
+
if (preset) {
|
|
181
|
+
const presetClass = new preset(config, props.presetOptions);
|
|
182
|
+
config = presetClass.handle();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Put default values
|
|
187
|
+
|
|
188
|
+
config.width = config.width ?? 300;
|
|
189
|
+
config.height = config.height ?? 300;
|
|
190
|
+
config.maxWidth = config.maxWidth ?? undefined;
|
|
191
|
+
config.enableResize = config.enableResize ?? false;
|
|
192
|
+
config.enableZoom = config.enableZoom ?? true;
|
|
193
|
+
config.enableOrientation = config.enableOrientation ?? true;
|
|
194
|
+
config.showZoomer = config.showZoomer ?? true;
|
|
195
|
+
config.viewport = config.viewport ?? {
|
|
196
|
+
width: config.width,
|
|
197
|
+
height: config.height,
|
|
198
|
+
type: 'square' as CropType,
|
|
199
|
+
};
|
|
200
|
+
config.boundary = config.boundary ?? {
|
|
201
|
+
width: config.width,
|
|
202
|
+
height: config.height,
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// Make sure values respect max width
|
|
206
|
+
|
|
207
|
+
if (config.maxWidth) {
|
|
208
|
+
const ratio = (config.width as number) / (config.height as number);
|
|
209
|
+
config.width = Math.min(config.width as number, config.maxWidth);
|
|
210
|
+
config.height = config.width / ratio;
|
|
211
|
+
config.boundary.width = Math.min(config.boundary.width, config.maxWidth);
|
|
212
|
+
config.boundary.height = config.boundary.width / ratio;
|
|
213
|
+
config.viewport.width = Math.min(config.viewport.width, config.maxWidth);
|
|
214
|
+
config.viewport.height = config.viewport.width / ratio;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
enableExif: true,
|
|
219
|
+
enableResize: config.enableResize,
|
|
220
|
+
enableZoom: config.enableZoom,
|
|
221
|
+
enableOrientation: config.enableOrientation,
|
|
222
|
+
showZoomer: config.showZoomer,
|
|
223
|
+
viewport: config.viewport,
|
|
224
|
+
boundary: config.boundary,
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
function init() {
|
|
229
|
+
if (initializing.value) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Start the loading state...
|
|
234
|
+
initializing.value = true;
|
|
235
|
+
|
|
236
|
+
// ...Give time to the loading state to render before doing CPU intensive tasks
|
|
237
|
+
setTimeout(async () => {
|
|
238
|
+
try {
|
|
239
|
+
await initCropper();
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.error(error);
|
|
242
|
+
} finally {
|
|
243
|
+
initializing.value = false;
|
|
244
|
+
}
|
|
245
|
+
}, 10);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function initCropper() {
|
|
249
|
+
if (croppie.value == null) {
|
|
250
|
+
throw new Error('Croppie element not found');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
cropper = new Croppie(croppie.value, cropperConfiguration.value);
|
|
254
|
+
|
|
255
|
+
const sourceWasChanged = lastSource != props.source;
|
|
256
|
+
const initialResizeWasChanged =
|
|
257
|
+
lastInitialResize != props.config?.initialResize;
|
|
258
|
+
|
|
259
|
+
if (sourceWasChanged || initialResizeWasChanged) {
|
|
260
|
+
// Try to resize image to avoid using too much memory
|
|
261
|
+
lastSourceResized = await resizeImage(props.source);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
lastSource = props.source;
|
|
265
|
+
lastInitialResize = props.config?.initialResize ?? null;
|
|
266
|
+
|
|
267
|
+
lastSourceResized = lastSourceResized ?? props.source;
|
|
268
|
+
|
|
269
|
+
await cropper.bind({
|
|
270
|
+
url: lastSourceResized,
|
|
271
|
+
zoom: 0,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
showDragHelp.value = true;
|
|
275
|
+
|
|
276
|
+
croppie.value.addEventListener('update', (a) => {
|
|
277
|
+
if (initializing.value) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
showDragHelp.value = false;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async function resizeImage(url: string): Promise<string> {
|
|
286
|
+
await getOriginalDimensions();
|
|
287
|
+
|
|
288
|
+
try {
|
|
289
|
+
const initialResize = getInitialResize();
|
|
290
|
+
|
|
291
|
+
if (!initialResize) {
|
|
292
|
+
return url;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return await resizeImageFromURI(
|
|
296
|
+
url,
|
|
297
|
+
initialResize.height,
|
|
298
|
+
initialResize.width
|
|
299
|
+
);
|
|
300
|
+
} catch (e: any) {
|
|
301
|
+
return url;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async function save(
|
|
306
|
+
result?: ResultOptions
|
|
307
|
+
): Promise<HTMLCanvasElement | string | Blob | null> {
|
|
308
|
+
if (!cropper) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
saving.value = true;
|
|
313
|
+
|
|
314
|
+
const resultConfig = result ??
|
|
315
|
+
props.saveOptions ?? {
|
|
316
|
+
type: 'blob',
|
|
317
|
+
size: 'original',
|
|
318
|
+
circle: false,
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const r = await cropper.result(resultConfig);
|
|
322
|
+
|
|
323
|
+
saving.value = false;
|
|
324
|
+
|
|
325
|
+
return r;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function resetViewPort() {
|
|
329
|
+
if (!initializing.value) {
|
|
330
|
+
destroy();
|
|
331
|
+
init();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function rotateLeft() {
|
|
336
|
+
cropper?.rotate(90);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function rotateRight() {
|
|
340
|
+
cropper?.rotate(-90);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const destroy = () => {
|
|
344
|
+
cropper?.destroy();
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
async function getOriginalDimensions() {
|
|
348
|
+
return new Promise((resolve) => {
|
|
349
|
+
const img = new Image();
|
|
350
|
+
img.src = props.source;
|
|
351
|
+
img.onload = () => {
|
|
352
|
+
sourceOriginalWidth.value = img.width;
|
|
353
|
+
sourceOriginalHeight.value = img.height;
|
|
354
|
+
resolve(true);
|
|
355
|
+
};
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function getInitialResize() {
|
|
360
|
+
const resizeMax = props.config?.initialResize ?? RESIZE_MAX_SIZE;
|
|
361
|
+
|
|
362
|
+
const reducedWidth =
|
|
363
|
+
sourceOriginalWidth.value > resizeMax
|
|
364
|
+
? resizeMax
|
|
365
|
+
: sourceOriginalWidth.value;
|
|
366
|
+
|
|
367
|
+
const reducedHeight =
|
|
368
|
+
sourceOriginalHeight.value > resizeMax
|
|
369
|
+
? resizeMax
|
|
370
|
+
: sourceOriginalHeight.value;
|
|
371
|
+
|
|
372
|
+
const ratioWidth = reducedWidth / sourceOriginalWidth.value;
|
|
373
|
+
const ratioHeight = reducedHeight / sourceOriginalHeight.value;
|
|
374
|
+
const ratio = ratioWidth > ratioHeight ? ratioWidth : ratioHeight;
|
|
375
|
+
|
|
376
|
+
return {
|
|
377
|
+
width: sourceOriginalWidth.value * ratio,
|
|
378
|
+
height: sourceOriginalHeight.value * ratio,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const shared = {
|
|
383
|
+
save,
|
|
384
|
+
resetViewPort,
|
|
385
|
+
rotateLeft,
|
|
386
|
+
rotateRight,
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
defineExpose(shared);
|
|
390
|
+
</script>
|