@witchcraft/ui 0.4.0 → 0.4.2
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,22 +1,22 @@
|
|
|
1
1
|
/* Manually Generated Index */
|
|
2
2
|
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as
|
|
7
|
-
export { default as
|
|
8
|
-
export { default as
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
12
|
-
export { default as
|
|
13
|
-
export { default as
|
|
14
|
-
export { default as
|
|
15
|
-
export { default as
|
|
16
|
-
export { default as
|
|
17
|
-
export { default as
|
|
18
|
-
export { default as
|
|
19
|
-
export { default as
|
|
20
|
-
export { default as
|
|
21
|
-
export { default as
|
|
22
|
-
export { default as
|
|
3
|
+
export { default as WButton } from "./WButton/WButton.vue"
|
|
4
|
+
export { default as WCheckbox } from "./WCheckbox/WCheckbox.vue"
|
|
5
|
+
export { default as WColorInput } from "./WColorInput/WColorInput.vue"
|
|
6
|
+
export { default as WColorPicker } from "./WColorPicker/WColorPicker.vue"
|
|
7
|
+
export { default as WCombobox } from "./WCombobox/WCombobox.vue"
|
|
8
|
+
export { default as WDarkModeSwitcher } from "./WDarkModeSwitcher/WDarkModeSwitcher.vue"
|
|
9
|
+
export { default as WDatePicker } from "./WDatePicker/WDatePicker.vue"
|
|
10
|
+
export { default as WDebug } from "./WDebug/WDebug.vue"
|
|
11
|
+
export { default as WFileInput } from "./WFileInput/WFileInput.vue"
|
|
12
|
+
export { default as WNotifications } from "./WNotifications/WNotifications.vue"
|
|
13
|
+
export { default as WPagination } from "./WPagination/WPagination.vue"
|
|
14
|
+
export { default as WPopup } from "./WPopup/WPopup.vue"
|
|
15
|
+
export { default as WPopover } from "./WPopover/WPopover.vue"
|
|
16
|
+
export { default as WProgressBar } from "./WProgressBar/WProgressBar.vue"
|
|
17
|
+
export { default as WRecorder } from "./WRecorder/WRecorder.vue"
|
|
18
|
+
export { default as WRoot } from "./WRoot/WRoot.vue"
|
|
19
|
+
export { default as WSimpleInput } from "./WSimpleInput/WSimpleInput.vue"
|
|
20
|
+
export { default as WTable } from "./WTable/WTable.vue"
|
|
21
|
+
export { default as WTimeZonePicker } from "./WDatePicker/WTimeZonePicker.vue"
|
|
22
|
+
export { default as WTooltip } from "./WTooltip/WTooltip.vue"
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/* Autogenerated Index */
|
|
2
2
|
|
|
3
3
|
export { useAccesibilityOutline } from "./useAccesibilityOutline.js"
|
|
4
|
-
export {
|
|
5
|
-
export { useDarkMode } from "./useDarkMode.js"
|
|
6
|
-
export { useDivideAttrs } from "./useDivideAttrs.js"
|
|
4
|
+
export { useDelayedLoadingIndicator } from "./useDelayedLoadingIndicator.js"
|
|
7
5
|
export { useDragWithThreshold } from "./useDragWithThreshold.js"
|
|
6
|
+
export { useFallbackId } from "./useFallbackId.js"
|
|
8
7
|
export { useGlobalResizeObserver } from "./useGlobalResizeObserver.js"
|
|
9
8
|
export { useInjectedDarkMode } from "./useInjectedDarkMode.js"
|
|
10
9
|
export { useInjectedI18n } from "./useInjectedI18n.js"
|
|
11
10
|
export { useInjectedLocale } from "./useInjectedLocale.js"
|
|
12
11
|
export { useNotificationHandler } from "./useNotificationHandler.js"
|
|
12
|
+
export { usePopupConstrainToStyle } from "./usePopupConstrainToStyle.js"
|
|
13
13
|
export { usePreHydrationValue } from "./usePreHydrationValue.js"
|
|
14
14
|
export { useScrollNearContainerEdges } from "./useScrollNearContainerEdges.js"
|
|
15
15
|
export { useSetupDarkMode } from "./useSetupDarkMode.js"
|
|
16
16
|
export { useSetupLocale } from "./useSetupLocale.js"
|
|
17
17
|
export { useShowDevOnlyKey } from "./useShowDevOnlyKey.js"
|
|
18
18
|
export { useSlotVars } from "./useSlotVars.js"
|
|
19
|
-
export {
|
|
19
|
+
export { useTimeConditionally } from "./useTimeConditionally.js"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Ref } from "vue"
|
|
2
|
+
import { ref, watch } from "vue"
|
|
3
|
+
/**
|
|
4
|
+
* For async operations sometimes it actually loads so fast the loading indicator is not visible but we still want it to be briefly visible. This delays the setting of the returned ref to false by the given timeout so it at least flashes onscreen.
|
|
5
|
+
*
|
|
6
|
+
* Setting to true is not delayed.
|
|
7
|
+
*
|
|
8
|
+
* If the indicator is set to true while the timeout is still running, it's canceled.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function useDelayedLoadingIndicator(
|
|
12
|
+
loading: Ref<boolean>,
|
|
13
|
+
timeout: number = 200
|
|
14
|
+
) {
|
|
15
|
+
const showLoadingIndicator = ref(false)
|
|
16
|
+
let loadingTimeout: number | NodeJS.Timeout | undefined
|
|
17
|
+
watch(loading, newVal => {
|
|
18
|
+
clearTimeout(loadingTimeout)
|
|
19
|
+
if (newVal === true) {
|
|
20
|
+
showLoadingIndicator.value = true
|
|
21
|
+
} else {
|
|
22
|
+
loadingTimeout = setTimeout(() => {
|
|
23
|
+
if (loading.value === false) {
|
|
24
|
+
showLoadingIndicator.value = false
|
|
25
|
+
}
|
|
26
|
+
}, timeout)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
return showLoadingIndicator
|
|
30
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AcceptableValue, ComboboxRootProps } from "reka-ui"
|
|
2
|
+
|
|
3
|
+
export type SuggestionsDisplayProps<T extends NonNullable<AcceptableValue>> = {
|
|
4
|
+
displayKey?: string
|
|
5
|
+
/**
|
|
6
|
+
* Override's reka-ui's displayValue.
|
|
7
|
+
*
|
|
8
|
+
* Prefer displayKey or displayEntry if possible as it's easier to type and requires less code.
|
|
9
|
+
*
|
|
10
|
+
* It's passed a special options object with a `isForEmit` boolean that tells you whether the value will be used for emits or just visually/search. This is useful to v-model an id when suggestions are objects.
|
|
11
|
+
*/
|
|
12
|
+
displayValue?: (value: T | T[], options?: { isForEmit?: boolean }) => string
|
|
13
|
+
/**
|
|
14
|
+
* When displayKey is not enough, prefer this over displayValue as it takes care of extracting the entry (from the array/object/value).
|
|
15
|
+
*
|
|
16
|
+
* The component uses this to filter out the suggestions. In some rare cases you might want to display a different label than the one filtered on (e.g. for example, to indicate some suggestion is active), in these cases, the function will be called with the visualOnly option set to true. This applies only to the visual suggestion in the suggestion list.
|
|
17
|
+
*/
|
|
18
|
+
displayEntry?: (value: T, options: { isForEmit?: boolean }) => string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useDisplayForReka<T extends NonNullable<ComboboxRootProps["modelValue"]>>(props: SuggestionsDisplayProps<T>) {
|
|
22
|
+
const display = props.displayValue ?? function (value: T, options: { isForEmit?: boolean } = {}): string {
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return value.map(v => {
|
|
25
|
+
const val = v[props.displayKey as keyof typeof v]
|
|
26
|
+
return props.displayEntry?.(val, options) ?? val
|
|
27
|
+
}).filter(v => v !== "").join(", ")
|
|
28
|
+
} else if (typeof value === "object") {
|
|
29
|
+
return props.displayEntry?.(value as any, options) ?? value[props.displayKey as keyof typeof value] as any
|
|
30
|
+
} else {
|
|
31
|
+
// special case when reka resets
|
|
32
|
+
if (value === "" && !options.isForEmit) return ""
|
|
33
|
+
return props.displayEntry?.(value as any, options) ?? value as any
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return display
|
|
37
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { inject } from "vue"
|
|
2
2
|
|
|
3
|
-
import type { DarkModeCommands, DarkModeState } from "./useDarkMode.js"
|
|
4
|
-
|
|
5
3
|
import { darkModeCommandsInjectionKey, darkModeStateInjectionKey } from "../injectionKeys.js"
|
|
4
|
+
import type { DarkModeCommands, DarkModeState } from "../types/index.js"
|
|
6
5
|
|
|
7
6
|
export function useInjectedDarkMode(): DarkModeState & DarkModeCommands {
|
|
8
7
|
const darkModeState = inject(darkModeStateInjectionKey)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComputedRef, StyleValue } from "vue"
|
|
2
|
+
import { computed } from "vue"
|
|
3
|
+
|
|
4
|
+
import type { PopupConstrainToProps } from "../types/index.js"
|
|
5
|
+
/**
|
|
6
|
+
* Mostly internal, create the computed style with maxWidth/Height based on the constrain*To props.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export function usePopupConstrainToStyle(rekaName: string, props: PopupConstrainToProps, attrsStyle?: StyleValue[]): ComputedRef<StyleValue[]> {
|
|
11
|
+
const contentStyle = computed(() => ([{
|
|
12
|
+
maxWidth: props.constrainWidthTo === "trigger"
|
|
13
|
+
? `var(--reka-${rekaName}-trigger-width)`
|
|
14
|
+
: props.constrainWidthTo === "available"
|
|
15
|
+
? `var(--reka-${rekaName}-content-available-width)`
|
|
16
|
+
: typeof props.constrainWidthTo === "number"
|
|
17
|
+
? `${props.constrainWidthTo}px`
|
|
18
|
+
: props.constrainWidthTo ?? undefined,
|
|
19
|
+
maxHeight: props.constrainHeightTo === "trigger"
|
|
20
|
+
? `var(--reka-${rekaName}-trigger-height)`
|
|
21
|
+
: props.constrainHeightTo === "available"
|
|
22
|
+
? `var(--reka-${rekaName}-content-available-height)`
|
|
23
|
+
: typeof props.constrainHeightTo === "number"
|
|
24
|
+
? `${props.constrainHeightTo}px`
|
|
25
|
+
: props.constrainHeightTo ?? undefined
|
|
26
|
+
}, ...(attrsStyle ?? [])] satisfies StyleValue[]))
|
|
27
|
+
return contentStyle
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { InjectionKey, Ref } from "vue"
|
|
2
|
+
import { computed, nextTick, onMounted, provide, ref, watch } from "vue"
|
|
3
|
+
|
|
4
|
+
import { darkModeCommandsInjectionKey, darkModeStateInjectionKey } from "../injectionKeys.js"
|
|
5
|
+
import type { DarkModeCommands, DarkModeOptions, DarkModeState } from "../types/index.js"
|
|
6
|
+
import { defaultDarkModeOrder } from "../types/index.js"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const isDarkModeInjectionKey = Symbol("isDarkMode") as InjectionKey<Ref<boolean>>
|
|
10
|
+
const manualDarkModeInjectionKey = Symbol("manualDarkMode") as InjectionKey<Ref<boolean | undefined>>
|
|
11
|
+
const defaultLocalStorageKey = "prefersColorSchemeDark"
|
|
12
|
+
|
|
2
13
|
/**
|
|
3
14
|
* A composable for setting up dark mode that automatically takes care of saving the user's preference.
|
|
4
15
|
*
|
|
@@ -7,8 +18,115 @@ import { useDarkMode } from "./useDarkMode.js"
|
|
|
7
18
|
* Use it's twin, `useInjectedDarkMode` for accessing the injected state and commands in components
|
|
8
19
|
*
|
|
9
20
|
* Note that this should only be called once at the root of the app.
|
|
10
|
-
*
|
|
11
21
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
22
|
+
export const useSetupDarkMode = ({
|
|
23
|
+
useLocalStorage = true,
|
|
24
|
+
darkModeOrder = defaultDarkModeOrder,
|
|
25
|
+
|
|
26
|
+
isClientSide = true,
|
|
27
|
+
useViewTransition = true
|
|
28
|
+
}: DarkModeOptions = {}): DarkModeState & DarkModeCommands => {
|
|
29
|
+
const systemDarkMode = ref(false)
|
|
30
|
+
const manualDarkMode = ref<boolean | undefined>(undefined)
|
|
31
|
+
|
|
32
|
+
if (useLocalStorage && isClientSide) {
|
|
33
|
+
watch(manualDarkMode, () => {
|
|
34
|
+
localStorage.setItem(defaultLocalStorageKey, manualDarkMode.value ? "true" : "false")
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const darkMode = computed(() => manualDarkMode.value ?? systemDarkMode.value)
|
|
39
|
+
const darkModeState = computed(() =>
|
|
40
|
+
manualDarkMode.value === undefined
|
|
41
|
+
? "system"
|
|
42
|
+
: manualDarkMode.value
|
|
43
|
+
? "dark"
|
|
44
|
+
: "light"
|
|
45
|
+
)
|
|
46
|
+
// todo move to useinjected
|
|
47
|
+
function setDarkMode(value: "dark" | "light" | "system"): void {
|
|
48
|
+
manualDarkMode.value
|
|
49
|
+
= value === "dark"
|
|
50
|
+
? true
|
|
51
|
+
: value === "light"
|
|
52
|
+
? false
|
|
53
|
+
: undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getNextValue(): "dark" | "light" | "system" {
|
|
57
|
+
const index = darkModeOrder.indexOf(darkModeState.value)
|
|
58
|
+
|
|
59
|
+
return index === 2
|
|
60
|
+
? darkModeOrder[0]!
|
|
61
|
+
: darkModeOrder[index + 1]!
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _cycleDarkMode(): void {
|
|
65
|
+
setDarkMode(getNextValue())
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function cycleDarkMode(): void {
|
|
69
|
+
if (!useViewTransition) {
|
|
70
|
+
_cycleDarkMode()
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
const nextValue = getNextValue()
|
|
74
|
+
const index = darkModeOrder.indexOf(darkModeState.value)
|
|
75
|
+
const systemDarkModeName = systemDarkMode.value ? "dark" : "light"
|
|
76
|
+
|
|
77
|
+
if (nextValue === "system" && systemDarkModeName === darkModeOrder[index]) {
|
|
78
|
+
// don't do view transitions if we're not really transitioning
|
|
79
|
+
_cycleDarkMode()
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
if (!document.startViewTransition) _cycleDarkMode()
|
|
83
|
+
document.startViewTransition(async () => {
|
|
84
|
+
_cycleDarkMode()
|
|
85
|
+
await nextTick()
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onMounted(() => {
|
|
90
|
+
window.matchMedia("(prefers-color-scheme: dark)")
|
|
91
|
+
.addEventListener("change", ({ matches }) => {
|
|
92
|
+
if (matches) {
|
|
93
|
+
systemDarkMode.value = true
|
|
94
|
+
} else {
|
|
95
|
+
systemDarkMode.value = false
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
if (useLocalStorage !== false) {
|
|
99
|
+
const key = typeof useLocalStorage === "string" ? useLocalStorage : defaultLocalStorageKey
|
|
100
|
+
const value = localStorage.getItem(key)
|
|
101
|
+
|
|
102
|
+
if (value === "true") {
|
|
103
|
+
manualDarkMode.value = true
|
|
104
|
+
} else if (value === "false") {
|
|
105
|
+
manualDarkMode.value = false
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
provide(isDarkModeInjectionKey, darkMode)
|
|
110
|
+
provide(manualDarkModeInjectionKey, manualDarkMode)
|
|
111
|
+
|
|
112
|
+
provide(darkModeStateInjectionKey, {
|
|
113
|
+
darkMode,
|
|
114
|
+
darkModeState,
|
|
115
|
+
manualDarkMode,
|
|
116
|
+
systemDarkMode
|
|
117
|
+
})
|
|
118
|
+
provide(darkModeCommandsInjectionKey, {
|
|
119
|
+
setDarkMode,
|
|
120
|
+
cycleDarkMode
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
darkMode,
|
|
125
|
+
darkModeState,
|
|
126
|
+
setDarkMode,
|
|
127
|
+
cycleDarkMode,
|
|
128
|
+
manualDarkMode,
|
|
129
|
+
systemDarkMode
|
|
130
|
+
}
|
|
14
131
|
}
|
|
132
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Ref, ref, watch } from "vue"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a ref with the current time if the given value ref is true or it's an array with 1 or more items.. It will update the time every 50ms (configurable) if so (within a requestAnimationFrame).
|
|
5
|
+
*
|
|
6
|
+
* When the value is anything else it will clear the interval and set the time to undefined.
|
|
7
|
+
*
|
|
8
|
+
* Useful for use with a progress bar.
|
|
9
|
+
*
|
|
10
|
+
* Updating the time all the time is expensive and not idea. This way we only set the interval if we really need it.
|
|
11
|
+
*/
|
|
12
|
+
export function useTimeConditionally(
|
|
13
|
+
val: Ref<any[] | boolean | any>,
|
|
14
|
+
{
|
|
15
|
+
refreshInterval = 50
|
|
16
|
+
}: {
|
|
17
|
+
refreshInterval?: number
|
|
18
|
+
} = {}
|
|
19
|
+
): {
|
|
20
|
+
time: Ref<undefined | number>
|
|
21
|
+
refresh: () => void
|
|
22
|
+
} {
|
|
23
|
+
const time = ref<undefined | number>(undefined)
|
|
24
|
+
|
|
25
|
+
let interval: ReturnType<typeof setInterval> | undefined
|
|
26
|
+
function refresh(
|
|
27
|
+
/** The value to use for the check. Do not pass unless you know what you're doing. */
|
|
28
|
+
v = val.value
|
|
29
|
+
) {
|
|
30
|
+
if (v === true || (Array.isArray(v) && v.length > 0)) {
|
|
31
|
+
if (interval !== undefined) return
|
|
32
|
+
time.value = Date.now()
|
|
33
|
+
interval = setInterval(() => {
|
|
34
|
+
requestAnimationFrame(() => {
|
|
35
|
+
time.value = Date.now()
|
|
36
|
+
})
|
|
37
|
+
}, refreshInterval)
|
|
38
|
+
} else {
|
|
39
|
+
if (interval === undefined) return
|
|
40
|
+
clearInterval(interval)
|
|
41
|
+
interval = undefined
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
watch(val, val => {
|
|
45
|
+
refresh(val)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
refresh()
|
|
49
|
+
|
|
50
|
+
return { time, refresh }
|
|
51
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { castType } from "@alanscodelog/utils/castType"
|
|
2
2
|
import { override } from "@alanscodelog/utils/override"
|
|
3
|
-
import { throttle } from "@alanscodelog/utils/throttle"
|
|
4
3
|
import { unreachable } from "@alanscodelog/utils/unreachable"
|
|
5
4
|
import type { Directive, Ref } from "vue"
|
|
6
5
|
|
|
@@ -22,6 +21,9 @@ type Data = {
|
|
|
22
21
|
offset?: number
|
|
23
22
|
widths: Ref<string[]>
|
|
24
23
|
selector: string
|
|
24
|
+
onTeardown?: (el: Element) => void
|
|
25
|
+
fixedWidths?: Record<number, number>
|
|
26
|
+
fluidWidthsAsPercentOfFluidWidth?: Record<number, number>
|
|
25
27
|
}
|
|
26
28
|
const elMap = new WeakMap<HTMLElement, Data>()
|
|
27
29
|
type RawOpts = { value: Partial<ResizableOptions> }
|
|
@@ -34,11 +36,13 @@ const defaultOpts: Omit<ResizableOptions, "colCount" | "widths" | "selector"> =
|
|
|
34
36
|
enabled: true
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
// note that while it would be nice to throttle this it seems to loose the reference to the original element
|
|
40
|
+
// haven't found where the issue is yet #future
|
|
37
41
|
const callback: ResizeCallback = (_rect: DOMRectReadOnly, el: Element): void => {
|
|
38
42
|
setColWidths(el as ResizableElement)
|
|
39
43
|
positionGrips(el as ResizableElement)
|
|
40
44
|
}
|
|
41
|
-
|
|
45
|
+
|
|
42
46
|
/**
|
|
43
47
|
* Allow a table like element to be resized along it's columns.
|
|
44
48
|
*
|
|
@@ -103,31 +107,28 @@ export const vResizableCols: Directive = {
|
|
|
103
107
|
|
|
104
108
|
if (options.enabled) {
|
|
105
109
|
setupColumns(el, options)
|
|
106
|
-
observer.observe(el,
|
|
110
|
+
observer.observe(el, callback)
|
|
107
111
|
}
|
|
108
112
|
},
|
|
109
113
|
updated(el: ResizableElement, { value: opts = {} }: RawOpts) {
|
|
110
114
|
const options = override({ ...defaultOpts }, opts) as ResizableOptions
|
|
111
|
-
const info = el && getElInfo(el)
|
|
112
|
-
const hasGrips = el && elMap.get(el)
|
|
115
|
+
const info = el && options.enabled && getElInfo(el, { throwIfMissing: false })
|
|
116
|
+
const hasGrips = el && options.enabled && elMap.get(el)?.grips
|
|
113
117
|
// todo, we should probably check by name
|
|
114
118
|
const colsNotEqual = (info && info.colCount !== options.colCount)
|
|
115
|
-
if (
|
|
119
|
+
if (!options.enabled || colsNotEqual) {
|
|
116
120
|
teardownColumns(el)
|
|
117
|
-
observer.unobserve(el,
|
|
121
|
+
observer.unobserve(el, callback)
|
|
118
122
|
}
|
|
119
123
|
|
|
120
124
|
if ((!hasGrips && options.enabled) || colsNotEqual) {
|
|
121
125
|
setupColumns(el, options)
|
|
122
|
-
observer.observe(el,
|
|
126
|
+
observer.observe(el, callback)
|
|
123
127
|
}
|
|
124
128
|
},
|
|
125
129
|
unmounted(el: ResizableElement) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
teardownColumns(el)
|
|
129
|
-
globalResizeObserver.unobserve(el, throttledCallback)
|
|
130
|
-
}
|
|
130
|
+
teardownColumns(el)
|
|
131
|
+
globalResizeObserver.unobserve(el, callback)
|
|
131
132
|
},
|
|
132
133
|
getSSRProps() {
|
|
133
134
|
return {}
|
|
@@ -140,7 +141,11 @@ function setWidth(col: HTMLElement, amountInPx: number, el: ResizableElement): v
|
|
|
140
141
|
|
|
141
142
|
const index = getColEls(el).findIndex(_ => col === _)
|
|
142
143
|
if ($el.fitWidth) {
|
|
143
|
-
|
|
144
|
+
if (amountInPx <= $el.margin) {
|
|
145
|
+
$el.widths.value[index] = `${$el.margin}px`
|
|
146
|
+
} else {
|
|
147
|
+
$el.widths.value[index] = `${width / getBox(el).width * 100}%`
|
|
148
|
+
}
|
|
144
149
|
} else {
|
|
145
150
|
$el.widths.value[index] = `${width}px`
|
|
146
151
|
}
|
|
@@ -178,13 +183,14 @@ function createPointerDownHandler(el: ResizableElement) {
|
|
|
178
183
|
castType<HTMLElement>(e.target)
|
|
179
184
|
$el.target = e.target
|
|
180
185
|
$el.isDragging = true
|
|
186
|
+
el.classList.add("dragging")
|
|
181
187
|
e.preventDefault()
|
|
182
188
|
|
|
183
189
|
// in case any errors happen, we want the pointer up to still be called
|
|
184
190
|
document.addEventListener("pointerup", $el.pointerUpHandler)
|
|
185
191
|
|
|
186
192
|
const { col, colNext } = getCols(el)
|
|
187
|
-
if (col === null || colNext === null) {
|
|
193
|
+
if (col === null || (colNext === null && $el.fitWidth)) {
|
|
188
194
|
el.classList.add("resizable-cols-error")
|
|
189
195
|
} else {
|
|
190
196
|
document.addEventListener("pointermove", $el.pointerMoveHandler)
|
|
@@ -202,6 +208,8 @@ function createPointerMoveHandler(el: ResizableElement) {
|
|
|
202
208
|
if ($el.isDragging) {
|
|
203
209
|
e.preventDefault()
|
|
204
210
|
|
|
211
|
+
$el.fluidWidthsAsPercentOfFluidWidth = undefined
|
|
212
|
+
|
|
205
213
|
const { col, colNext } = getCols(el)
|
|
206
214
|
|
|
207
215
|
if (col !== null) {
|
|
@@ -244,9 +252,11 @@ function createPointerMoveHandler(el: ResizableElement) {
|
|
|
244
252
|
function createPointerUpHandler(el: ResizableElement) {
|
|
245
253
|
return (e: PointerEvent) => {
|
|
246
254
|
const $el = getElInfo(el)
|
|
255
|
+
$el.pointerMoveHandler(e)
|
|
247
256
|
if ($el.isDragging) {
|
|
248
257
|
e.preventDefault()
|
|
249
258
|
$el.isDragging = false
|
|
259
|
+
el.classList.remove("dragging")
|
|
250
260
|
el.classList.remove("resizable-cols-error")
|
|
251
261
|
$el.offset = 0
|
|
252
262
|
delete $el.target
|
|
@@ -281,15 +291,15 @@ function getTestGripSize(el: ResizableElement): number {
|
|
|
281
291
|
return dynamicMinWidth
|
|
282
292
|
}
|
|
283
293
|
|
|
284
|
-
function getElInfo(el: ResizableElement): Data {
|
|
294
|
+
function getElInfo<T extends boolean = true>(el: ResizableElement, { throwIfMissing = true as T }: { throwIfMissing?: T } = {}): T extends true ? Data : Data | undefined {
|
|
285
295
|
const $el = elMap.get(el)
|
|
286
|
-
if (!$el) unreachable("El went missing.")
|
|
287
|
-
return $el
|
|
296
|
+
if (!$el && throwIfMissing) unreachable("El went missing.")
|
|
297
|
+
return $el as any
|
|
288
298
|
}
|
|
289
299
|
function getColEls(el: ResizableElement): HTMLElement[] {
|
|
290
300
|
const $el = elMap.get(el)
|
|
291
301
|
if (!$el) unreachable("El went missing.")
|
|
292
|
-
return [...el.querySelectorAll(`:scope ${$el.selector
|
|
302
|
+
return [...el.querySelectorAll(`:scope ${$el.selector ?? "tr > th"}`)] as any
|
|
293
303
|
}
|
|
294
304
|
|
|
295
305
|
function setupColumns(el: ResizableElement, opts: ResizableOptions): void {
|
|
@@ -305,12 +315,14 @@ function setupColumns(el: ResizableElement, opts: ResizableOptions): void {
|
|
|
305
315
|
margin: opts.margin === "dynamic" ? gripWidth : opts.margin,
|
|
306
316
|
colCount: opts.colCount,
|
|
307
317
|
widths: opts.widths,
|
|
308
|
-
selector: opts.selector
|
|
318
|
+
selector: opts.selector,
|
|
319
|
+
onTeardown: opts.onTeardown
|
|
309
320
|
}
|
|
310
321
|
elMap.set(el, $el)
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
322
|
+
const headers = getColEls(el)
|
|
323
|
+
if (headers.length !== opts.colCount) {
|
|
324
|
+
throw new Error(`Number of headers matched using selector ${opts.selector ?? "tr > th"} does not match number of columns.`)
|
|
325
|
+
}
|
|
314
326
|
|
|
315
327
|
setColWidths(el, headers)
|
|
316
328
|
el.style.width = $el.fitWidth ? "" : "min-content"
|
|
@@ -325,6 +337,7 @@ function setupColumns(el: ResizableElement, opts: ResizableOptions): void {
|
|
|
325
337
|
}
|
|
326
338
|
positionGrips(el)
|
|
327
339
|
el.classList.add("resizable-cols-setup")
|
|
340
|
+
opts.onSetup?.(el)
|
|
328
341
|
}
|
|
329
342
|
|
|
330
343
|
function positionGrips(el: ResizableElement): void {
|
|
@@ -332,9 +345,9 @@ function positionGrips(el: ResizableElement): void {
|
|
|
332
345
|
const $el = getElInfo(el)
|
|
333
346
|
for (const grip of $el.grips.keys()) {
|
|
334
347
|
const col = $el.grips.get(grip)!
|
|
335
|
-
const
|
|
336
|
-
if (!
|
|
337
|
-
const colBox = getBox(
|
|
348
|
+
const colEl = getColEls(el)[col]
|
|
349
|
+
if (!colEl) unreachable()
|
|
350
|
+
const colBox = getBox(colEl)
|
|
338
351
|
const gripBox = getBox(grip)
|
|
339
352
|
|
|
340
353
|
grip.style.left = `${xPos + colBox.width - (gripBox.width / 2)}px`
|
|
@@ -346,8 +359,59 @@ function setColWidths(el: ResizableElement, children?: Element[]): void {
|
|
|
346
359
|
const $el = getElInfo(el)
|
|
347
360
|
const header = children ?? getColEls(el).slice(0, $el.colCount)
|
|
348
361
|
const len = $el.colCount
|
|
362
|
+
const elWidth = getBox(el).width
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
let fluidTotalPx = 0
|
|
366
|
+
const fluid: Record<number, number> = {}
|
|
367
|
+
|
|
368
|
+
const doCalculateFixed = $el.fixedWidths === undefined
|
|
369
|
+
const doCalculateFluid = $el.fluidWidthsAsPercentOfFluidWidth === undefined
|
|
370
|
+
|
|
371
|
+
if (doCalculateFixed) {
|
|
372
|
+
$el.fixedWidths = { [-1]: 0 } // fixedTotalWidth
|
|
373
|
+
}
|
|
374
|
+
if (doCalculateFluid) {
|
|
375
|
+
$el.fluidWidthsAsPercentOfFluidWidth = {}
|
|
376
|
+
}
|
|
377
|
+
for (let i = 0; i < len; i++) {
|
|
378
|
+
const col = header[i]
|
|
379
|
+
castType<HTMLElement>(col)
|
|
380
|
+
if (col.classList.contains("no-resize")) {
|
|
381
|
+
if (doCalculateFixed) {
|
|
382
|
+
const w = getBox(col).width
|
|
383
|
+
$el.fixedWidths![i] = w
|
|
384
|
+
$el.fixedWidths![-1]! += $el.fixedWidths![i]!
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
if (doCalculateFluid) {
|
|
388
|
+
const w = getBox(col).width
|
|
389
|
+
fluid[i] = w
|
|
390
|
+
fluidTotalPx += w
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const totalFluidCount = len - Object.keys($el.fixedWidths!).length
|
|
396
|
+
|
|
397
|
+
if (doCalculateFluid) {
|
|
398
|
+
for (let i = 0; i < len; i++) {
|
|
399
|
+
if ($el.fixedWidths![i] !== undefined) continue
|
|
400
|
+
$el.fluidWidthsAsPercentOfFluidWidth![i] = fluid[i]! / fluidTotalPx
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const fixedTotalPx = $el.fixedWidths![-1]!
|
|
405
|
+
const minFlexWidth = (totalFluidCount * $el.margin)
|
|
406
|
+
const minTotalWidth = minFlexWidth + fixedTotalPx
|
|
407
|
+
|
|
408
|
+
let leftOverFluidWidth = elWidth - fixedTotalPx
|
|
409
|
+
if (leftOverFluidWidth < minFlexWidth) {
|
|
410
|
+
leftOverFluidWidth = minFlexWidth
|
|
411
|
+
}
|
|
412
|
+
|
|
349
413
|
let width = 0
|
|
350
|
-
|
|
414
|
+
|
|
351
415
|
for (let i = 0; i < len; i++) {
|
|
352
416
|
const col = header[i]
|
|
353
417
|
castType<HTMLElement>(col)
|
|
@@ -355,9 +419,24 @@ function setColWidths(el: ResizableElement, children?: Element[]): void {
|
|
|
355
419
|
* only works if parent table does NOT use `box-sizing:border-box` and either has no border or does `width: calc(100% - BORDERWIDTH*2)`
|
|
356
420
|
*/
|
|
357
421
|
const colBox = getBox(col)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
422
|
+
if ($el.fixedWidths![i] !== undefined) {
|
|
423
|
+
$el.widths.value[i] = `${$el.fixedWidths![i]!}px`
|
|
424
|
+
width += $el.fixedWidths![i]!
|
|
425
|
+
} else {
|
|
426
|
+
if ($el.fitWidth) {
|
|
427
|
+
if (!$el.widths.value[i]) {
|
|
428
|
+
setWidth(col, colBox.width, el)
|
|
429
|
+
width += getBox(col).width
|
|
430
|
+
continue
|
|
431
|
+
}
|
|
432
|
+
const newInPx = $el.fluidWidthsAsPercentOfFluidWidth![i]! * leftOverFluidWidth
|
|
433
|
+
setWidth(col, newInPx, el)
|
|
434
|
+
width += getBox(col).width
|
|
435
|
+
} else {
|
|
436
|
+
setWidth(col, colBox.width, el)
|
|
437
|
+
width += getBox(col).width
|
|
438
|
+
}
|
|
439
|
+
}
|
|
361
440
|
}
|
|
362
441
|
|
|
363
442
|
if (width < minTotalWidth) {
|
|
@@ -368,15 +447,19 @@ function setColWidths(el: ResizableElement, children?: Element[]): void {
|
|
|
368
447
|
}
|
|
369
448
|
|
|
370
449
|
function teardownColumns(el: ResizableElement): void {
|
|
371
|
-
const $el = getElInfo(el)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
450
|
+
const $el = getElInfo(el, { throwIfMissing: false })
|
|
451
|
+
|
|
452
|
+
if ($el) {
|
|
453
|
+
el.removeEventListener("pointerdown", $el.pointerDownHandler)
|
|
454
|
+
document.removeEventListener("pointermove", $el.pointerMoveHandler)
|
|
455
|
+
document.removeEventListener("pointerup", $el.pointerUpHandler)
|
|
456
|
+
for (const key of Object.keys($el)) {
|
|
457
|
+
delete $el[key as keyof typeof $el]
|
|
458
|
+
}
|
|
459
|
+
$el.onTeardown?.(el)
|
|
460
|
+
elMap.delete(el)
|
|
378
461
|
}
|
|
379
|
-
|
|
462
|
+
|
|
380
463
|
el.classList.remove("resizable-cols-setup")
|
|
381
464
|
removeGrips(el)
|
|
382
465
|
}
|