@witchcraft/ui 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -61
- package/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +13 -9
- package/dist/runtime/assets/animations.css +1 -1
- package/dist/runtime/assets/locales/en.json +2 -0
- package/dist/runtime/assets/utils.css +1 -1
- package/dist/runtime/build/WitchcraftUiResolver.js +1 -2
- package/dist/runtime/components/TestControls/TestControls.d.vue.ts +2 -1
- package/dist/runtime/components/TestControls/TestControls.vue +3 -3
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +2 -1
- package/dist/runtime/components/WButton/WButton.d.vue.ts +34 -0
- package/dist/runtime/components/{LibButton/LibButton.vue → WButton/WButton.vue} +26 -38
- package/dist/runtime/components/WButton/WButton.vue.d.ts +34 -0
- package/dist/runtime/components/WCheckbox/WCheckbox.d.vue.ts +33 -0
- package/dist/runtime/components/WCheckbox/WCheckbox.vue +110 -0
- package/dist/runtime/components/WCheckbox/WCheckbox.vue.d.ts +33 -0
- package/dist/runtime/components/{LibColorInput/LibColorInput.d.vue.ts → WColorInput/WColorInput.d.vue.ts} +18 -36
- package/dist/runtime/components/WColorInput/WColorInput.vue +85 -0
- package/dist/runtime/components/{LibColorInput/LibColorInput.vue.d.ts → WColorInput/WColorInput.vue.d.ts} +18 -36
- package/dist/runtime/components/WColorInput/WColorSwatchButton.d.vue.ts +28 -0
- package/dist/runtime/components/WColorInput/WColorSwatchButton.vue +86 -0
- package/dist/runtime/components/WColorInput/WColorSwatchButton.vue.d.ts +28 -0
- package/dist/runtime/components/{LibColorPicker/LibColorPicker.d.vue.ts → WColorPicker/WColorPicker.d.vue.ts} +12 -9
- package/dist/runtime/components/{LibColorPicker/LibColorPicker.vue → WColorPicker/WColorPicker.vue} +41 -29
- package/dist/runtime/components/{LibColorPicker/LibColorPicker.vue.d.ts → WColorPicker/WColorPicker.vue.d.ts} +12 -9
- package/dist/runtime/components/WCombobox/WCombobox.d.vue.ts +111 -0
- package/dist/runtime/components/WCombobox/WCombobox.vue +405 -0
- package/dist/runtime/components/WCombobox/WCombobox.vue.d.ts +111 -0
- package/dist/runtime/components/WCombobox/storyPlays.d.ts +18 -0
- package/dist/runtime/components/WCombobox/storyPlays.js +68 -0
- package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.d.vue.ts → WDarkModeSwitcher/WDarkModeSwitcher.d.vue.ts} +9 -13
- package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue → WDarkModeSwitcher/WDarkModeSwitcher.vue} +11 -14
- package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts → WDarkModeSwitcher/WDarkModeSwitcher.vue.d.ts} +9 -13
- package/dist/runtime/components/{LibDatePicker/LibDatePicker.d.vue.ts → WDatePicker/WDatePicker.d.vue.ts} +7 -7
- package/dist/runtime/components/{LibDatePicker/LibDatePicker.vue → WDatePicker/WDatePicker.vue} +3 -7
- package/dist/runtime/components/{LibDatePicker/LibDatePicker.vue.d.ts → WDatePicker/WDatePicker.vue.d.ts} +7 -7
- package/dist/runtime/components/WDatePicker/WRangeDatePicker.d.vue.ts +182 -0
- package/dist/runtime/components/{LibDatePicker/LibRangeDatePicker.vue → WDatePicker/WRangeDatePicker.vue} +29 -25
- package/dist/runtime/components/WDatePicker/WRangeDatePicker.vue.d.ts +182 -0
- package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.d.vue.ts → WDatePicker/WSingleDatePicker.d.vue.ts} +7 -5
- package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.vue → WDatePicker/WSingleDatePicker.vue} +21 -21
- package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.vue.d.ts → WDatePicker/WSingleDatePicker.vue.d.ts} +7 -5
- package/dist/runtime/components/WDatePicker/WTimeZonePicker.d.vue.ts +13 -0
- package/dist/runtime/components/{LibDatePicker/LibTimeZonePicker.vue → WDatePicker/WTimeZonePicker.vue} +5 -12
- package/dist/runtime/components/WDatePicker/WTimeZonePicker.vue.d.ts +13 -0
- package/dist/runtime/components/{LibDebug/LibDebug.d.vue.ts → WDebug/WDebug.d.vue.ts} +3 -2
- package/dist/runtime/components/{LibDebug/LibDebug.vue → WDebug/WDebug.vue} +10 -12
- package/dist/runtime/components/{LibDebug/LibDebug.vue.d.ts → WDebug/WDebug.vue.d.ts} +3 -2
- package/dist/runtime/components/{LibDevOnly/LibDevOnly.d.vue.ts → WDevOnly/WDevOnly.d.vue.ts} +3 -5
- package/dist/runtime/components/{LibDevOnly/LibDevOnly.vue.d.ts → WDevOnly/WDevOnly.vue.d.ts} +3 -5
- package/dist/runtime/components/WFileInput/WFileInput.d.vue.ts +58 -0
- package/dist/runtime/components/WFileInput/WFileInput.vue +348 -0
- package/dist/runtime/components/WFileInput/WFileInput.vue.d.ts +58 -0
- package/dist/runtime/components/WIcon/WIcon.d.vue.ts +18 -0
- package/dist/runtime/components/{Icon/Icon.vue → WIcon/WIcon.vue} +1 -1
- package/dist/runtime/components/WIcon/WIcon.vue.d.ts +18 -0
- package/dist/runtime/components/WMultiValues/WMultiValues.d.vue.ts +28 -0
- package/dist/runtime/components/WMultiValues/WMultiValues.vue +150 -0
- package/dist/runtime/components/WMultiValues/WMultiValues.vue.d.ts +28 -0
- package/dist/runtime/components/WNotifications/WNotification.d.vue.ts +37 -0
- package/dist/runtime/components/{LibNotifications/LibNotification.vue → WNotifications/WNotification.vue} +61 -35
- package/dist/runtime/components/WNotifications/WNotification.vue.d.ts +37 -0
- package/dist/runtime/components/WNotifications/WNotificationTestMessageComponent.d.vue.ts +7 -0
- package/dist/runtime/components/WNotifications/WNotificationTestMessageComponent.vue +29 -0
- package/dist/runtime/components/WNotifications/WNotificationTestMessageComponent.vue.d.ts +7 -0
- package/dist/runtime/components/WNotifications/WNotifications.d.vue.ts +11 -0
- package/dist/runtime/components/{LibNotifications/LibNotifications.vue → WNotifications/WNotifications.vue} +72 -36
- package/dist/runtime/components/WNotifications/WNotifications.vue.d.ts +11 -0
- package/dist/runtime/components/WNotifications/calculateNotificationProgress.d.ts +2 -0
- package/dist/runtime/components/WNotifications/calculateNotificationProgress.js +4 -0
- package/dist/runtime/components/WNumberInput/WNumberInput.d.vue.ts +27 -0
- package/dist/runtime/components/WNumberInput/WNumberInput.vue +96 -0
- package/dist/runtime/components/WNumberInput/WNumberInput.vue.d.ts +27 -0
- package/dist/runtime/components/WPagination/WPagination.d.vue.ts +59 -0
- package/dist/runtime/components/WPagination/WPagination.vue +182 -0
- package/dist/runtime/components/WPagination/WPagination.vue.d.ts +59 -0
- package/dist/runtime/components/WPalette/WPalette.d.vue.ts +11 -0
- package/dist/runtime/components/{LibPalette/LibPalette.vue → WPalette/WPalette.vue} +3 -8
- package/dist/runtime/components/WPalette/WPalette.vue.d.ts +11 -0
- package/dist/runtime/components/WPopover/WPopover.d.vue.ts +45 -0
- package/dist/runtime/components/WPopover/WPopover.vue +144 -0
- package/dist/runtime/components/WPopover/WPopover.vue.d.ts +45 -0
- package/dist/runtime/components/WPopup/WPopup.d.vue.ts +51 -0
- package/dist/runtime/components/WPopup/WPopup.vue +115 -0
- package/dist/runtime/components/WPopup/WPopup.vue.d.ts +51 -0
- package/dist/runtime/components/{LibProgressBar/LibProgressBar.d.vue.ts → WProgressBar/WProgressBar.d.vue.ts} +13 -16
- package/dist/runtime/components/WProgressBar/WProgressBar.vue +150 -0
- package/dist/runtime/components/{LibProgressBar/LibProgressBar.vue.d.ts → WProgressBar/WProgressBar.vue.d.ts} +13 -16
- package/dist/runtime/components/{LibRecorder/LibRecorder.d.vue.ts → WRecorder/WRecorder.d.vue.ts} +13 -27
- package/dist/runtime/components/{LibRecorder/LibRecorder.vue → WRecorder/WRecorder.vue} +37 -36
- package/dist/runtime/components/{LibRecorder/LibRecorder.vue.d.ts → WRecorder/WRecorder.vue.d.ts} +13 -27
- package/dist/runtime/components/{LibRoot/LibRoot.d.vue.ts → WRoot/WRoot.d.vue.ts} +11 -9
- package/dist/runtime/components/{LibRoot/LibRoot.vue → WRoot/WRoot.vue} +17 -15
- package/dist/runtime/components/{LibRoot/LibRoot.vue.d.ts → WRoot/WRoot.vue.d.ts} +11 -9
- package/dist/runtime/components/WSimpleInput/WSimpleInput.d.vue.ts +34 -0
- package/dist/runtime/components/{LibSimpleInput/LibSimpleInput.vue → WSimpleInput/WSimpleInput.vue} +14 -24
- package/dist/runtime/components/WSimpleInput/WSimpleInput.vue.d.ts +34 -0
- package/dist/runtime/components/WTable/WTable.d.vue.ts +102 -0
- package/dist/runtime/components/WTable/WTable.vue +370 -0
- package/dist/runtime/components/WTable/WTable.vue.d.ts +102 -0
- package/dist/runtime/components/WTooltip/WTooltip.d.vue.ts +40 -0
- package/dist/runtime/components/WTooltip/WTooltip.vue +112 -0
- package/dist/runtime/components/WTooltip/WTooltip.vue.d.ts +40 -0
- package/dist/runtime/components/index.d.ts +20 -20
- package/dist/runtime/components/index.js +20 -20
- package/dist/runtime/composables/index.d.ts +4 -4
- package/dist/runtime/composables/index.js +4 -4
- package/dist/runtime/composables/useDelayedLoadingIndicator.d.ts +9 -0
- package/dist/runtime/composables/useDelayedLoadingIndicator.js +18 -0
- package/dist/runtime/composables/useDisplayForReka.d.ts +25 -0
- package/dist/runtime/composables/useDisplayForReka.js +16 -0
- package/dist/runtime/composables/useFallbackId.d.ts +3 -0
- package/dist/runtime/composables/useFallbackId.js +5 -0
- package/dist/runtime/composables/useInjectedDarkMode.d.ts +1 -1
- package/dist/runtime/composables/usePopupConstrainToStyle.d.ts +8 -0
- package/dist/runtime/composables/usePopupConstrainToStyle.js +8 -0
- package/dist/runtime/composables/useSetupDarkMode.d.ts +2 -3
- package/dist/runtime/composables/useSetupDarkMode.js +90 -4
- package/dist/runtime/composables/useTimeConditionally.d.ts +16 -0
- package/dist/runtime/composables/useTimeConditionally.js +27 -0
- package/dist/runtime/directives/vResizableCols.js +101 -34
- package/dist/runtime/helpers/NotificationHandler.d.ts +28 -3
- package/dist/runtime/helpers/NotificationHandler.js +7 -10
- package/dist/runtime/injectionKeys.d.ts +1 -5
- package/dist/runtime/injectionKeys.js +0 -2
- package/dist/runtime/types/index.d.ts +97 -31
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/utils/notifyIfError.d.ts +3 -1
- package/dist/runtime/utils/notifyIfError.js +4 -2
- package/dist/runtime/utils/twMerge.d.ts +1 -0
- package/dist/runtime/utils/twMerge.js +2 -1
- package/package.json +59 -56
- package/src/module.ts +16 -8
- package/src/runtime/assets/animations.css +53 -6
- package/src/runtime/assets/locales/en.json +2 -0
- package/src/runtime/assets/tailwind.css +1 -1
- package/src/runtime/assets/utils.css +52 -4
- package/src/runtime/build/WitchcraftUiResolver.ts +1 -2
- package/src/runtime/components/TestControls/TestControls.vue +3 -3
- package/src/runtime/components/WButton/WButton.stories.ts +112 -0
- package/src/runtime/components/{LibButton/LibButton.vue → WButton/WButton.vue} +34 -50
- package/src/runtime/components/{LibCheckbox/LibCheckbox.stories.ts → WCheckbox/WCheckbox.stories.ts} +5 -5
- package/src/runtime/components/WCheckbox/WCheckbox.vue +125 -0
- package/src/runtime/components/{LibColorInput/LibColorInput.stories.ts → WColorInput/WColorInput.stories.ts} +8 -8
- package/src/runtime/components/WColorInput/WColorInput.vue +112 -0
- package/src/runtime/components/WColorInput/WColorSwatchButton.vue +102 -0
- package/src/runtime/components/{LibColorPicker/LibColorPicker.stories.ts → WColorPicker/WColorPicker.stories.ts} +12 -12
- package/src/runtime/components/{LibColorPicker/LibColorPicker.vue → WColorPicker/WColorPicker.vue} +44 -31
- package/src/runtime/components/WCombobox/WCombobox.stories.ts +209 -0
- package/src/runtime/components/WCombobox/WCombobox.vue +450 -0
- package/src/runtime/components/WCombobox/storyPlays.ts +92 -0
- package/src/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts → WDarkModeSwitcher/WDarkModeSwitcher.stories.ts} +6 -6
- package/src/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue → WDarkModeSwitcher/WDarkModeSwitcher.vue} +19 -30
- package/src/runtime/components/{LibDatePicker/LibDatePicker.stories.ts → WDatePicker/WDatePicker.stories.ts} +42 -34
- package/src/runtime/components/{LibDatePicker/LibDatePicker.vue → WDatePicker/WDatePicker.vue} +3 -7
- package/src/runtime/components/{LibDatePicker/LibRangeDatePicker.vue → WDatePicker/WRangeDatePicker.vue} +29 -25
- package/src/runtime/components/{LibDatePicker/LibSingleDatePicker.vue → WDatePicker/WSingleDatePicker.vue} +21 -21
- package/src/runtime/components/{LibDatePicker/LibTimeZonePicker.vue → WDatePicker/WTimeZonePicker.vue} +5 -12
- package/src/runtime/components/{LibDebug/LibDebug.stories.ts → WDebug/WDebug.stories.ts} +5 -5
- package/src/runtime/components/{LibDebug/LibDebug.vue → WDebug/WDebug.vue} +9 -10
- package/src/runtime/components/{LibDevOnly/LibDevOnly.vue → WDevOnly/WDevOnly.vue} +0 -4
- package/src/runtime/components/{LibFileInput/LibFileInput.stories.ts → WFileInput/WFileInput.stories.ts} +20 -10
- package/src/runtime/components/WFileInput/WFileInput.vue +392 -0
- package/src/runtime/components/{Icon/Icon.vue → WIcon/WIcon.vue} +5 -8
- package/src/runtime/components/{LibMultiValues/LibMultiValues.stories.ts → WMultiValues/WMultiValues.stories.ts} +9 -9
- package/src/runtime/components/WMultiValues/WMultiValues.vue +163 -0
- package/src/runtime/components/{LibNotifications/LibNotification.stories.ts → WNotifications/WNotification.stories.ts} +42 -6
- package/src/runtime/components/{LibNotifications/LibNotification.vue → WNotifications/WNotification.vue} +72 -45
- package/src/runtime/components/WNotifications/WNotificationTestMessageComponent.vue +27 -0
- package/src/runtime/components/WNotifications/WNotifications.stories.ts +139 -0
- package/src/runtime/components/{LibNotifications/LibNotifications.vue → WNotifications/WNotifications.vue} +87 -47
- package/src/runtime/components/WNotifications/calculateNotificationProgress.ts +8 -0
- package/src/runtime/components/WNumberInput/WNumberInput.vue +109 -0
- package/src/runtime/components/WPagination/WPagination.stories.ts +51 -0
- package/src/runtime/components/WPagination/WPagination.vue +207 -0
- package/src/runtime/components/{LibPalette/LibPalette.stories.ts → WPalette/WPalette.stories.ts} +6 -6
- package/src/runtime/components/{LibPalette/LibPalette.vue → WPalette/WPalette.vue} +3 -8
- package/src/runtime/components/WPopover/WPopover.stories.ts +218 -0
- package/src/runtime/components/WPopover/WPopover.vue +168 -0
- package/src/runtime/components/WPopup/WPopup.stories.ts +104 -0
- package/src/runtime/components/WPopup/WPopup.vue +134 -0
- package/src/runtime/components/WProgressBar/WProgressBar.stories.ts +119 -0
- package/src/runtime/components/WProgressBar/WProgressBar.vue +185 -0
- package/src/runtime/components/{LibRecorder/LibRecorder.stories.ts → WRecorder/WRecorder.stories.ts} +9 -6
- package/src/runtime/components/{LibRecorder/LibRecorder.vue → WRecorder/WRecorder.vue} +69 -68
- package/src/runtime/components/{LibRoot/LibRoot.vue → WRoot/WRoot.vue} +18 -15
- package/src/runtime/components/{LibSimpleInput/LibSimpleInput.stories.ts → WSimpleInput/WSimpleInput.stories.ts} +11 -12
- package/src/runtime/components/{LibSimpleInput/LibSimpleInput.vue → WSimpleInput/WSimpleInput.vue} +28 -42
- package/src/runtime/components/WTable/WTable.stories.ts +334 -0
- package/src/runtime/components/WTable/WTable.vue +471 -0
- package/src/runtime/components/WTooltip/WTooltip.stories.ts +82 -0
- package/src/runtime/components/WTooltip/WTooltip.vue +128 -0
- package/src/runtime/components/index.ts +20 -20
- package/src/runtime/composables/index.ts +4 -4
- package/src/runtime/composables/useDelayedLoadingIndicator.ts +30 -0
- package/src/runtime/composables/useDisplayForReka.ts +37 -0
- package/src/runtime/composables/useFallbackId.ts +6 -0
- package/src/runtime/composables/useInjectedDarkMode.ts +1 -2
- package/src/runtime/composables/usePopupConstrainToStyle.ts +29 -0
- package/src/runtime/composables/useSetupDarkMode.ts +122 -4
- package/src/runtime/composables/useTimeConditionally.ts +51 -0
- package/src/runtime/directives/vResizableCols.ts +121 -38
- package/src/runtime/helpers/NotificationHandler.ts +30 -11
- package/src/runtime/injectionKeys.ts +1 -7
- package/src/runtime/types/index.ts +118 -36
- package/src/runtime/utils/notifyIfError.ts +6 -2
- package/src/runtime/utils/twMerge.ts +2 -1
- package/types/components.d.ts +14 -15
- package/dist/runtime/components/Aria/Aria.d.vue.ts +0 -5
- package/dist/runtime/components/Aria/Aria.vue +0 -16
- package/dist/runtime/components/Aria/Aria.vue.d.ts +0 -5
- package/dist/runtime/components/Icon/Icon.d.vue.ts +0 -21
- package/dist/runtime/components/Icon/Icon.vue.d.ts +0 -21
- package/dist/runtime/components/LibButton/LibButton.d.vue.ts +0 -36
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +0 -36
- package/dist/runtime/components/LibCheckbox/LibCheckbox.d.vue.ts +0 -42
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +0 -103
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +0 -42
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +0 -162
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.d.vue.ts +0 -34
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +0 -34
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.d.vue.ts +0 -22
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +0 -22
- package/dist/runtime/components/LibFileInput/LibFileInput.d.vue.ts +0 -43
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +0 -274
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +0 -43
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.d.vue.ts +0 -165
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -387
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +0 -165
- package/dist/runtime/components/LibLabel/LibLabel.d.vue.ts +0 -26
- package/dist/runtime/components/LibLabel/LibLabel.vue +0 -45
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +0 -26
- package/dist/runtime/components/LibMultiValues/LibMultiValues.d.vue.ts +0 -29
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +0 -109
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +0 -29
- package/dist/runtime/components/LibNotifications/LibNotification.d.vue.ts +0 -30
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +0 -30
- package/dist/runtime/components/LibNotifications/LibNotifications.d.vue.ts +0 -13
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +0 -13
- package/dist/runtime/components/LibPagination/LibPagination.d.vue.ts +0 -104
- package/dist/runtime/components/LibPagination/LibPagination.vue +0 -229
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +0 -104
- package/dist/runtime/components/LibPalette/LibPalette.d.vue.ts +0 -14
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +0 -14
- package/dist/runtime/components/LibPopup/LibPopup.d.vue.ts +0 -46
- package/dist/runtime/components/LibPopup/LibPopup.vue +0 -365
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +0 -46
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +0 -169
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.d.vue.ts +0 -35
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +0 -35
- package/dist/runtime/components/LibSuggestions/LibSuggestions.d.vue.ts +0 -94
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +0 -178
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +0 -94
- package/dist/runtime/components/LibTable/LibTable.d.vue.ts +0 -45
- package/dist/runtime/components/LibTable/LibTable.vue +0 -155
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +0 -45
- package/dist/runtime/components/Template/NAME.d.vue.ts +0 -17
- package/dist/runtime/components/Template/NAME.vue +0 -27
- package/dist/runtime/components/Template/NAME.vue.d.ts +0 -17
- package/dist/runtime/components/Template/TemplateStory.d.ts +0 -7
- package/dist/runtime/components/Template/TemplateStory.js +0 -22
- package/dist/runtime/components/shared/props.d.ts +0 -171
- package/dist/runtime/components/shared/props.js +0 -2
- package/dist/runtime/composables/useAriaLabel.d.ts +0 -6
- package/dist/runtime/composables/useAriaLabel.js +0 -15
- package/dist/runtime/composables/useDarkMode.d.ts +0 -77
- package/dist/runtime/composables/useDarkMode.js +0 -89
- package/dist/runtime/composables/useDivideAttrs.d.ts +0 -27
- package/dist/runtime/composables/useDivideAttrs.js +0 -27
- package/dist/runtime/composables/useSuggestions.d.ts +0 -40
- package/dist/runtime/composables/useSuggestions.js +0 -263
- package/src/runtime/components/Aria/Aria.vue +0 -26
- package/src/runtime/components/LibButton/LibButton.stories.ts +0 -106
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -129
- package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -203
- package/src/runtime/components/LibFileInput/LibFileInput.vue +0 -320
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +0 -405
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -414
- package/src/runtime/components/LibLabel/LibLabel.stories.ts +0 -33
- package/src/runtime/components/LibLabel/LibLabel.vue +0 -65
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -123
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +0 -120
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +0 -49
- package/src/runtime/components/LibPagination/LibPagination.vue +0 -274
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +0 -153
- package/src/runtime/components/LibPopup/LibPopup.vue +0 -396
- package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +0 -90
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -197
- package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +0 -134
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -212
- package/src/runtime/components/LibTable/LibTable.stories.ts +0 -167
- package/src/runtime/components/LibTable/LibTable.vue +0 -190
- package/src/runtime/components/Template/NAME.vue +0 -49
- package/src/runtime/components/Template/TemplateStory.ts +0 -37
- package/src/runtime/components/shared/props.ts +0 -199
- package/src/runtime/composables/useAriaLabel.ts +0 -23
- package/src/runtime/composables/useDarkMode.ts +0 -199
- package/src/runtime/composables/useDivideAttrs.ts +0 -53
- package/src/runtime/composables/useSuggestions.ts +0 -339
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.d.ts +0 -0
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.js +0 -0
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.d.ts +0 -0
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.js +0 -0
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.d.ts +0 -0
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.js +0 -0
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.d.ts +0 -0
- /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.js +0 -0
- /package/dist/runtime/components/{LibDatePicker → WDatePicker}/helpers.d.ts +0 -0
- /package/dist/runtime/components/{LibDatePicker → WDatePicker}/helpers.js +0 -0
- /package/dist/runtime/components/{LibDevOnly/LibDevOnly.vue → WDevOnly/WDevOnly.vue} +0 -0
- /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.ts +0 -0
- /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.ts +0 -0
- /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.ts +0 -0
- /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.ts +0 -0
- /package/src/runtime/components/{LibDatePicker → WDatePicker}/helpers.ts +0 -0
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<lib-popup
|
|
3
|
-
class="color-input--popup"
|
|
4
|
-
v-model="showPopup"
|
|
5
|
-
@close="$tempValue = undefined;emit('cancel')"
|
|
6
|
-
>
|
|
7
|
-
<template #button="{ extractEl }">
|
|
8
|
-
<!-- <div -->
|
|
9
|
-
<!-- class=" -->
|
|
10
|
-
<!-- flex -->
|
|
11
|
-
<!-- w-full -->
|
|
12
|
-
<!-- border -->
|
|
13
|
-
<!-- " -->
|
|
14
|
-
<!-- v-extract-root-el="extractEl" -->
|
|
15
|
-
<!-- > -->
|
|
16
|
-
|
|
17
|
-
<!-- -->
|
|
18
|
-
<lib-button
|
|
19
|
-
:id="id ?? fallbackId"
|
|
20
|
-
:class="twMerge(`
|
|
21
|
-
p-0
|
|
22
|
-
color-input--button
|
|
23
|
-
flex flex-nowrap
|
|
24
|
-
min-w-4
|
|
25
|
-
overflow-hidden
|
|
26
|
-
[&_.button--label]:items-stretch
|
|
27
|
-
[&_.button--label]:gap-0
|
|
28
|
-
after:hidden
|
|
29
|
-
`,
|
|
30
|
-
($attrs as any).class
|
|
31
|
-
)"
|
|
32
|
-
:aria-label="t('color-input.aria-and-title-prefix') + stringColor"
|
|
33
|
-
:title="t('color-input.aria-and-title-prefix') + stringColor"
|
|
34
|
-
v-bind="{ ...$attrs, class: undefined }"
|
|
35
|
-
v-extract-root-el="extractEl"
|
|
36
|
-
@click="togglePopup"
|
|
37
|
-
>
|
|
38
|
-
<template #label>
|
|
39
|
-
<div
|
|
40
|
-
class="
|
|
41
|
-
color-input--swatch-wrapper
|
|
42
|
-
flex
|
|
43
|
-
w-full
|
|
44
|
-
"
|
|
45
|
-
>
|
|
46
|
-
<slot v-bind="{ stringColor, classes: swatchClasses }">
|
|
47
|
-
<div
|
|
48
|
-
:class="swatchClasses"
|
|
49
|
-
:style="`background:${stringColor}`"
|
|
50
|
-
/>
|
|
51
|
-
</slot>
|
|
52
|
-
<slot
|
|
53
|
-
v-if="$tempValue"
|
|
54
|
-
v-bind="{ tempStringColor, classes: swatchClasses }"
|
|
55
|
-
name="temp"
|
|
56
|
-
>
|
|
57
|
-
<div
|
|
58
|
-
:class="swatchClasses"
|
|
59
|
-
:style="`background:${tempStringColor}`"
|
|
60
|
-
/>
|
|
61
|
-
</slot>
|
|
62
|
-
</div>
|
|
63
|
-
</template>
|
|
64
|
-
</lib-button>
|
|
65
|
-
</template>
|
|
66
|
-
<template #popup="{ extractEl }">
|
|
67
|
-
<div
|
|
68
|
-
class="color-input--popup-wrapper p-5"
|
|
69
|
-
v-extract-root-el="extractEl"
|
|
70
|
-
>
|
|
71
|
-
<lib-color-picker
|
|
72
|
-
v-if="showPopup"
|
|
73
|
-
:id="id ?? fallbackId"
|
|
74
|
-
:allow-alpha="allowAlpha"
|
|
75
|
-
:custom-representation="customRepresentation"
|
|
76
|
-
:string-precision="stringPrecision"
|
|
77
|
-
v-model="internalTempValue"
|
|
78
|
-
v-model:temp-value="$tempValue"
|
|
79
|
-
@save="save"
|
|
80
|
-
@cancel="cancel"
|
|
81
|
-
/>
|
|
82
|
-
</div>
|
|
83
|
-
</template>
|
|
84
|
-
</lib-popup>
|
|
85
|
-
</template>
|
|
86
|
-
|
|
87
|
-
<script setup lang="ts">
|
|
88
|
-
import Color from "colorjs.io"
|
|
89
|
-
import { type ButtonHTMLAttributes, computed, ref, useAttrs } from "vue"
|
|
90
|
-
|
|
91
|
-
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
92
|
-
import { vExtractRootEl } from "../../directives/vExtractRootEl.js"
|
|
93
|
-
import type { HsvaColor, RgbaColor } from "../../types/index.js"
|
|
94
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
95
|
-
import LibButton from "../LibButton/LibButton.vue"
|
|
96
|
-
import LibColorPicker from "../LibColorPicker/LibColorPicker.vue"
|
|
97
|
-
import LibPopup from "../LibPopup/LibPopup.vue"
|
|
98
|
-
import { getFallbackId, type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
|
|
99
|
-
|
|
100
|
-
defineOptions({
|
|
101
|
-
name: "LibColorInput"
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
const swatchClasses = `
|
|
105
|
-
color-input--swatch
|
|
106
|
-
after:content-vertical-holder
|
|
107
|
-
min-w-4
|
|
108
|
-
flex-1
|
|
109
|
-
relative
|
|
110
|
-
before:content-['']
|
|
111
|
-
before:absolute
|
|
112
|
-
before:inset-0
|
|
113
|
-
before:bg-transparency-squares
|
|
114
|
-
before:z-[-1]
|
|
115
|
-
`
|
|
116
|
-
|
|
117
|
-
const fallbackId = getFallbackId()
|
|
118
|
-
|
|
119
|
-
const t = useInjectedI18n()
|
|
120
|
-
/* const props = */withDefaults(defineProps<Props>(), {
|
|
121
|
-
allowAlpha: true,
|
|
122
|
-
border: true,
|
|
123
|
-
copyTransform: (_val: HsvaColor, stringVal: string) => stringVal,
|
|
124
|
-
stringPrecision: 3,
|
|
125
|
-
customRepresentation: undefined
|
|
126
|
-
})
|
|
127
|
-
const emit = defineEmits<{
|
|
128
|
-
(e: "save"): void
|
|
129
|
-
(e: "cancel"): void
|
|
130
|
-
}>()
|
|
131
|
-
|
|
132
|
-
function save() {
|
|
133
|
-
$value.value = internalTempValue.value
|
|
134
|
-
showPopup.value = false
|
|
135
|
-
$tempValue.value = undefined
|
|
136
|
-
emit("save")
|
|
137
|
-
}
|
|
138
|
-
function cancel() {
|
|
139
|
-
showPopup.value = false
|
|
140
|
-
$tempValue.value = undefined
|
|
141
|
-
emit("cancel")
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const $attrs = useAttrs()
|
|
145
|
-
|
|
146
|
-
const $value = defineModel<RgbaColor>({ required: false, default: () => ({ r: 0, g: 0, b: 0 }) })
|
|
147
|
-
const $tempValue = defineModel<RgbaColor | undefined>("tempValue", { required: false, default: () => (undefined) })
|
|
148
|
-
|
|
149
|
-
const stringColor = computed(() => new Color("srgb", [
|
|
150
|
-
$value.value.r / 255,
|
|
151
|
-
$value.value.g / 255,
|
|
152
|
-
$value.value.b / 255
|
|
153
|
-
], $value.value.a ?? 1).toString())
|
|
154
|
-
|
|
155
|
-
const tempStringColor = computed(() => $tempValue.value
|
|
156
|
-
? new Color("srgb", [
|
|
157
|
-
$tempValue.value.r / 255,
|
|
158
|
-
$tempValue.value.g / 255,
|
|
159
|
-
$tempValue.value.b / 255
|
|
160
|
-
], $tempValue.value.a ?? 1).toString()
|
|
161
|
-
: "")
|
|
162
|
-
|
|
163
|
-
const internalTempValue = ref({ ...$value.value })
|
|
164
|
-
|
|
165
|
-
const showPopup = ref(false)
|
|
166
|
-
|
|
167
|
-
const togglePopup = (): void => {
|
|
168
|
-
if (showPopup.value) {
|
|
169
|
-
$value.value = internalTempValue.value
|
|
170
|
-
}
|
|
171
|
-
showPopup.value = !showPopup.value
|
|
172
|
-
}
|
|
173
|
-
</script>
|
|
174
|
-
|
|
175
|
-
<script lang="ts">
|
|
176
|
-
type RealProps
|
|
177
|
-
= & LabelProps
|
|
178
|
-
& LinkableByIdProps
|
|
179
|
-
& {
|
|
180
|
-
allowAlpha?: boolean
|
|
181
|
-
border?: boolean
|
|
182
|
-
/** See ColorPicker.copyTransform */
|
|
183
|
-
copyTransform?: (val: HsvaColor, stringVal: string) => any
|
|
184
|
-
/** See ColorPicker.allowAlpha */
|
|
185
|
-
stringPrecision?: number
|
|
186
|
-
/** See ColorPicker.customRepresentation */
|
|
187
|
-
customRepresentation?: {
|
|
188
|
-
fromHsvaToString: (hsva: HsvaColor, includeAlpha: boolean) => string
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
interface Props
|
|
192
|
-
extends
|
|
193
|
-
/** @vue-ignore */
|
|
194
|
-
Partial<Omit<ButtonHTMLAttributes, "class">
|
|
195
|
-
& TailwindClassProp
|
|
196
|
-
& {
|
|
197
|
-
// why is this not already a part of button?
|
|
198
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
199
|
-
"aria-label": string
|
|
200
|
-
}>,
|
|
201
|
-
RealProps
|
|
202
|
-
{}
|
|
203
|
-
</script>
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- todo aria errors -->
|
|
3
|
-
<div
|
|
4
|
-
:class="twMerge(`file-input
|
|
5
|
-
justify-center
|
|
6
|
-
border-2
|
|
7
|
-
border-dashed
|
|
8
|
-
border-accent-500/80
|
|
9
|
-
focus-outline-within
|
|
10
|
-
transition-[border-color,box-shadow]
|
|
11
|
-
ease-out`,
|
|
12
|
-
compact && `rounded-sm`,
|
|
13
|
-
!compact && `flex w-full flex-col items-center gap-2 rounded-xl p-2 `,
|
|
14
|
-
errors.length > 0 && errorFlashing && `border-danger-400`,
|
|
15
|
-
($.wrapperAttrs as any).class
|
|
16
|
-
)"
|
|
17
|
-
v-bind="{ ...$.wrapperAttrs, class: undefined }"
|
|
18
|
-
>
|
|
19
|
-
<div
|
|
20
|
-
:class="twMerge(`
|
|
21
|
-
file-input--wrapper
|
|
22
|
-
relative justify-center`,
|
|
23
|
-
compact && `flex gap-2`,
|
|
24
|
-
!compact && `input-wrapper
|
|
25
|
-
flex flex-col items-center
|
|
26
|
-
`
|
|
27
|
-
)"
|
|
28
|
-
>
|
|
29
|
-
<label
|
|
30
|
-
:for="id ?? fallbackId"
|
|
31
|
-
:class="twMerge(`
|
|
32
|
-
file-input--label
|
|
33
|
-
pointer-events-none
|
|
34
|
-
flex
|
|
35
|
-
gap-1
|
|
36
|
-
items-center
|
|
37
|
-
whitespace-nowrap
|
|
38
|
-
`)"
|
|
39
|
-
>
|
|
40
|
-
<slot
|
|
41
|
-
v-if="compact || multiple || files.length === 0"
|
|
42
|
-
name="icon"
|
|
43
|
-
>
|
|
44
|
-
<icon><i-fa6-solid-arrow-up-from-bracket/></icon>
|
|
45
|
-
</slot>
|
|
46
|
-
<slot name="label">
|
|
47
|
-
{{
|
|
48
|
-
(compact
|
|
49
|
-
? multiple
|
|
50
|
-
? t("file-input.compact-choose-file-plural")
|
|
51
|
-
: t("file-input.compact-choose-file")
|
|
52
|
-
: multiple
|
|
53
|
-
? t("file-input.non-compact-choose-file-plural")
|
|
54
|
-
: t("file-input.non-compact-choose-file")
|
|
55
|
-
)
|
|
56
|
-
}}
|
|
57
|
-
</slot>
|
|
58
|
-
<span
|
|
59
|
-
v-if="compact && multiple"
|
|
60
|
-
class="file-input--label-count"
|
|
61
|
-
>
|
|
62
|
-
{{ ` (${files.length})` }}
|
|
63
|
-
</span>
|
|
64
|
-
</label>
|
|
65
|
-
<label
|
|
66
|
-
v-if="!compact && formats?.length > 0"
|
|
67
|
-
class="file-input--formats-label flex flex-col items-center text-sm"
|
|
68
|
-
>
|
|
69
|
-
<slot name="formats">{{ t("file-input.accepted-formats") }}: </slot>
|
|
70
|
-
<div class="file-input--formats-list">
|
|
71
|
-
{{ extensions.join(", ") }}
|
|
72
|
-
</div>
|
|
73
|
-
</label>
|
|
74
|
-
<input
|
|
75
|
-
:id="id ?? fallbackId"
|
|
76
|
-
:class="twMerge(`
|
|
77
|
-
file-input--input
|
|
78
|
-
absolute
|
|
79
|
-
inset-0
|
|
80
|
-
z-0
|
|
81
|
-
cursor-pointer
|
|
82
|
-
text-[0]
|
|
83
|
-
opacity-0
|
|
84
|
-
`,
|
|
85
|
-
($.inputAttrs as any)?.class
|
|
86
|
-
)"
|
|
87
|
-
type="file"
|
|
88
|
-
:accept="formats.join(', ')"
|
|
89
|
-
:multiple="multiple"
|
|
90
|
-
ref="el"
|
|
91
|
-
v-bind="{ ...$.inputAttrs, class: undefined }"
|
|
92
|
-
@input="(inputFile as any)"
|
|
93
|
-
@click="($event.target! as any).value = null"
|
|
94
|
-
>
|
|
95
|
-
<!-- click event allows event to fire even if the user picks the same file -->
|
|
96
|
-
</div>
|
|
97
|
-
<div
|
|
98
|
-
v-if="!compact && files.length > 0"
|
|
99
|
-
:class="twMerge(`file-input--previews
|
|
100
|
-
flex items-stretch justify-center gap-2 flex-wrap
|
|
101
|
-
`,
|
|
102
|
-
multiple && `
|
|
103
|
-
w-full
|
|
104
|
-
`,
|
|
105
|
-
($.previewsAttrs as any)?.class
|
|
106
|
-
)"
|
|
107
|
-
>
|
|
108
|
-
<div class="file-input--preview-spacer flex-1"/>
|
|
109
|
-
<div
|
|
110
|
-
class="file-input--preview-wrapper
|
|
111
|
-
z-1
|
|
112
|
-
relative
|
|
113
|
-
flex
|
|
114
|
-
min-w-0
|
|
115
|
-
max-w-[150px]
|
|
116
|
-
flex-initial
|
|
117
|
-
flex-wrap
|
|
118
|
-
items-center
|
|
119
|
-
gap-2 rounded-sm border border-neutral-400
|
|
120
|
-
shadow-xs
|
|
121
|
-
shadow-neutral-800/20
|
|
122
|
-
"
|
|
123
|
-
v-for="entry of files"
|
|
124
|
-
:key="entry.file.name"
|
|
125
|
-
>
|
|
126
|
-
<div class="file-input--remove-button flex flex-initial basis-full justify-start">
|
|
127
|
-
<lib-button
|
|
128
|
-
:border="false"
|
|
129
|
-
:aria-label="`Remove file ${entry.file.name}`"
|
|
130
|
-
@click="removeFile(entry)"
|
|
131
|
-
>
|
|
132
|
-
<icon><i-fa6-solid-xmark/></icon>
|
|
133
|
-
</lib-button>
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
|
-
<div class="file-input--preview flex flex-initial basis-full justify-center">
|
|
137
|
-
<div
|
|
138
|
-
v-if="entry.isImg"
|
|
139
|
-
class="file-input--preview-image
|
|
140
|
-
bg-transparency-squares flex
|
|
141
|
-
h-[80px] flex-wrap items-center
|
|
142
|
-
justify-center
|
|
143
|
-
"
|
|
144
|
-
>
|
|
145
|
-
<img
|
|
146
|
-
class="max-h-full w-auto"
|
|
147
|
-
:src="getSrc(entry.file)"
|
|
148
|
-
>
|
|
149
|
-
</div>
|
|
150
|
-
<div
|
|
151
|
-
v-if="!entry.isImg"
|
|
152
|
-
class="file-input--preview-no-image
|
|
153
|
-
flex h-[80px]
|
|
154
|
-
flex-1 basis-full flex-wrap items-center justify-center
|
|
155
|
-
"
|
|
156
|
-
>
|
|
157
|
-
<icon><i-fa6-regular-file class="text-4xl opacity-50"/></icon>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|
|
160
|
-
<div
|
|
161
|
-
class="
|
|
162
|
-
file-input--preview-filename
|
|
163
|
-
min-w-0
|
|
164
|
-
flex-1
|
|
165
|
-
basis-0
|
|
166
|
-
truncate
|
|
167
|
-
break-all
|
|
168
|
-
rounded-sm
|
|
169
|
-
p-1
|
|
170
|
-
text-sm
|
|
171
|
-
"
|
|
172
|
-
:title="entry.file.name"
|
|
173
|
-
>
|
|
174
|
-
{{ entry.file.name }}
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
177
|
-
|
|
178
|
-
<div class="flex-1"/>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
</template>
|
|
182
|
-
|
|
183
|
-
<script setup lang="ts">
|
|
184
|
-
import { computed, type HTMLAttributes, type InputHTMLAttributes, ref, shallowReactive, watch } from "vue"
|
|
185
|
-
|
|
186
|
-
import IFa6RegularFile from "~icons/fa6-regular/file"
|
|
187
|
-
import IFa6SolidArrowUpFromBracket from "~icons/fa6-solid/arrow-up-from-bracket"
|
|
188
|
-
import IFa6SolidXmark from "~icons/fa6-solid/xmark"
|
|
189
|
-
|
|
190
|
-
import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
|
|
191
|
-
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
192
|
-
import type { FileInputError } from "../../types/index.js"
|
|
193
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
194
|
-
import Icon from "../Icon/Icon.vue"
|
|
195
|
-
import LibButton from "../LibButton/LibButton.vue"
|
|
196
|
-
import { getFallbackId, type LinkableByIdProps, type TailwindClassProp, type WrapperProps } from "../shared/props.js"
|
|
197
|
-
|
|
198
|
-
const t = useInjectedI18n()
|
|
199
|
-
const el = ref<null | HTMLInputElement>(null)
|
|
200
|
-
type Entry = { file: File, isImg: boolean }
|
|
201
|
-
|
|
202
|
-
const files = shallowReactive<(Entry)[]>([])
|
|
203
|
-
const errors = shallowReactive<(FileInputError)[]>([])
|
|
204
|
-
const errorFlashing = ref(false)
|
|
205
|
-
|
|
206
|
-
watch(files, () => {
|
|
207
|
-
emits("input", files.map(entry => entry.file))
|
|
208
|
-
})
|
|
209
|
-
watch(errors, () => {
|
|
210
|
-
if (errors.length > 0) {
|
|
211
|
-
errorFlashing.value = true
|
|
212
|
-
setTimeout(() => {
|
|
213
|
-
errorFlashing.value = false
|
|
214
|
-
}, 500)
|
|
215
|
-
emits("errors", errors)
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
defineOptions({
|
|
220
|
-
name: "LibFileInput",
|
|
221
|
-
inheritAttrs: false
|
|
222
|
-
})
|
|
223
|
-
const $ = useDivideAttrs(["wrapper", "input", "previews"] as const)
|
|
224
|
-
|
|
225
|
-
const emits = defineEmits<{
|
|
226
|
-
(e: "input", val: File[]): void
|
|
227
|
-
(e: "errors", val: FileInputError[]): void
|
|
228
|
-
}>()
|
|
229
|
-
|
|
230
|
-
const fallbackId = getFallbackId()
|
|
231
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
232
|
-
multiple: false,
|
|
233
|
-
formats: () => ["image/*", ".jpeg", ".jpg", ".png"],
|
|
234
|
-
compact: false
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
const mimeTypes = computed(() => props.formats?.filter(_ => !_.startsWith(".")) ?? [])
|
|
238
|
-
const extensions = computed(() => props.formats?.filter(_ => _.startsWith(".")) ?? [])
|
|
239
|
-
|
|
240
|
-
const getSrc = (file: File) => {
|
|
241
|
-
const src = URL.createObjectURL(file)
|
|
242
|
-
return src
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const removeFile = (entry: Entry) => {
|
|
246
|
-
const index = files.indexOf(entry)
|
|
247
|
-
files.splice(index, 1)
|
|
248
|
-
}
|
|
249
|
-
const extensionsList = computed(() => extensions.value.join(", "))
|
|
250
|
-
const inputFile = async (e: InputEvent): Promise<undefined | boolean> => {
|
|
251
|
-
e.preventDefault()
|
|
252
|
-
if (el.value!.files) {
|
|
253
|
-
const errs = []
|
|
254
|
-
for (const file of el.value!.files) {
|
|
255
|
-
const isImg = file.type.startsWith("image")
|
|
256
|
-
|
|
257
|
-
const byPassValidation = props.formats.length === 0
|
|
258
|
-
const isValidMimeType = mimeTypes.value.find(_ => _.endsWith("/*") ? file.type.startsWith(_.slice(0, -2)) : _ === file.type) !== undefined
|
|
259
|
-
const isValidExtension = extensions.value.find(_ => file.name.endsWith(_)) !== undefined
|
|
260
|
-
if (!byPassValidation && (!isValidMimeType || !isValidExtension)) {
|
|
261
|
-
const extension = file.name.match(/.*(\..*)/)?.[1] ?? "Unknown"
|
|
262
|
-
const type = file.type === "" ? "" : ` (${file.type})`
|
|
263
|
-
const message = `File type ${extension}${type} is not allowed. Allowed file types are: ${extensionsList.value}.`
|
|
264
|
-
const err = new Error(message) as FileInputError
|
|
265
|
-
err.file = file
|
|
266
|
-
err.isValidExtension = isValidExtension
|
|
267
|
-
err.isValidMimeType = isValidMimeType
|
|
268
|
-
errs.push(err)
|
|
269
|
-
continue
|
|
270
|
-
}
|
|
271
|
-
if (errs.length > 0) continue
|
|
272
|
-
if (!files.find(_ => _.file === file)) {
|
|
273
|
-
if ((props.multiple || files.length < 1)
|
|
274
|
-
) {
|
|
275
|
-
files.push({ file, isImg })
|
|
276
|
-
} else {
|
|
277
|
-
files.splice(0, files.length, { file, isImg })
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (errs.length > 0) {
|
|
282
|
-
errors.splice(0, errors.length, ...errs)
|
|
283
|
-
return false
|
|
284
|
-
} else if (errors.length > 0) {
|
|
285
|
-
errors.splice(0, errors.length)
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return undefined
|
|
289
|
-
}
|
|
290
|
-
</script>
|
|
291
|
-
|
|
292
|
-
<script lang="ts">
|
|
293
|
-
export default { name: "LibFileInput" }
|
|
294
|
-
|
|
295
|
-
type WrapperTypes
|
|
296
|
-
= & WrapperProps<"input", InputHTMLAttributes>
|
|
297
|
-
& WrapperProps<"wrapper", HTMLAttributes>
|
|
298
|
-
& WrapperProps<"previews", HTMLAttributes>
|
|
299
|
-
|
|
300
|
-
type RealProps
|
|
301
|
-
= & LinkableByIdProps
|
|
302
|
-
& {
|
|
303
|
-
multiple?: boolean
|
|
304
|
-
/**
|
|
305
|
-
* A list of extensions or mime types to add to the input's accept. Basic validations are done so that files match an extension and mimeType, but note that a file could still be lying, all files should be validated server side.
|
|
306
|
-
*
|
|
307
|
-
* Pass an empty array to allow any filetype.
|
|
308
|
-
*/
|
|
309
|
-
formats?: string[]
|
|
310
|
-
compact?: boolean
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
interface Props
|
|
314
|
-
extends
|
|
315
|
-
/** @vue-ignore */
|
|
316
|
-
Partial<Omit<InputHTMLAttributes, "class" | "multiple" | "formats" | "compact"> & TailwindClassProp>,
|
|
317
|
-
/** @vue-ignore */
|
|
318
|
-
Partial<WrapperTypes>,
|
|
319
|
-
RealProps { }
|
|
320
|
-
</script>
|