@witchcraft/ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +236 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +34 -0
- package/dist/module.d.ts +34 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +124 -0
- package/dist/runtime/assets/base.css +1 -0
- package/dist/runtime/assets/locales/en.json +33 -0
- package/dist/runtime/assets/style.css +1 -0
- package/dist/runtime/assets/tailwind.css +1 -0
- package/dist/runtime/assets/theme.css +1 -0
- package/dist/runtime/build/WitchcraftUiResolver.d.ts +5 -0
- package/dist/runtime/build/WitchcraftUiResolver.js +17 -0
- package/dist/runtime/build/generateTheme.d.ts +1 -0
- package/dist/runtime/build/generateTheme.js +14 -0
- package/dist/runtime/build/unpluginIconViteOptions.d.ts +2 -0
- package/dist/runtime/build/unpluginIconViteOptions.js +10 -0
- package/dist/runtime/components/Aria/Aria.vue +18 -0
- package/dist/runtime/components/Focus.stories.d.ts +11 -0
- package/dist/runtime/components/Focus.stories.js +53 -0
- package/dist/runtime/components/Icon/Icon.vue +39 -0
- package/dist/runtime/components/LibButton/LibButton.stories.d.ts +12 -0
- package/dist/runtime/components/LibButton/LibButton.stories.js +94 -0
- package/dist/runtime/components/LibButton/LibButton.vue +247 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +14 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +29 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +132 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +7 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +58 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +125 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +7 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +51 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +448 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +7 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +36 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +95 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +11 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +98 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +67 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +370 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +314 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +27 -0
- package/dist/runtime/components/LibDatePicker/helpers.d.ts +25 -0
- package/dist/runtime/components/LibDatePicker/helpers.js +28 -0
- package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +9 -0
- package/dist/runtime/components/LibDebug/LibDebug.stories.js +46 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +91 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +53 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +10 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +63 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +273 -0
- package/dist/runtime/components/LibInput/LibInput.stories.d.ts +33 -0
- package/dist/runtime/components/LibInput/LibInput.stories.js +339 -0
- package/dist/runtime/components/LibInput/LibInput.vue +372 -0
- package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +6 -0
- package/dist/runtime/components/LibLabel/LibLabel.stories.js +25 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +66 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +23 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +60 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +127 -0
- package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +15 -0
- package/dist/runtime/components/LibNotifications/LibNotification.stories.js +126 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +121 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +6 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +109 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +133 -0
- package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +6 -0
- package/dist/runtime/components/LibPagination/LibPagination.stories.js +40 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +261 -0
- package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +6 -0
- package/dist/runtime/components/LibPalette/LibPalette.stories.js +20 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +49 -0
- package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.stories.js +147 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +441 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +10 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +81 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +192 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +19 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +63 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +243 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +126 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +26 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +78 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +148 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +27 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +112 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +198 -0
- package/dist/runtime/components/LibTable/LibTable.stories.d.ts +16 -0
- package/dist/runtime/components/LibTable/LibTable.stories.js +156 -0
- package/dist/runtime/components/LibTable/LibTable.vue +177 -0
- package/dist/runtime/components/Template/NAME.vue +49 -0
- package/dist/runtime/components/Template/TemplateStory.d.ts +7 -0
- package/dist/runtime/components/Template/TemplateStory.js +22 -0
- package/dist/runtime/components/TestControls/TestControls.vue +19 -0
- package/dist/runtime/components/index.d.ts +19 -0
- package/dist/runtime/components/index.js +19 -0
- package/dist/runtime/components/reset.stories.d.ts +5 -0
- package/dist/runtime/components/reset.stories.js +19 -0
- package/dist/runtime/components/shared/props.d.ts +135 -0
- package/dist/runtime/components/shared/props.js +14 -0
- package/dist/runtime/components/shared/storyHelpers/playInput.d.ts +8 -0
- package/dist/runtime/components/shared/storyHelpers/playInput.js +26 -0
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.d.ts +12 -0
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +83 -0
- package/dist/runtime/composables/index.d.ts +11 -0
- package/dist/runtime/composables/index.js +11 -0
- package/dist/runtime/composables/useAccesibilityOutline.d.ts +41 -0
- package/dist/runtime/composables/useAccesibilityOutline.js +58 -0
- package/dist/runtime/composables/useAriaLabel.d.ts +6 -0
- package/dist/runtime/composables/useAriaLabel.js +15 -0
- package/dist/runtime/composables/useDarkMode.d.ts +38 -0
- package/dist/runtime/composables/useDarkMode.js +79 -0
- package/dist/runtime/composables/useDivideAttrs.d.ts +27 -0
- package/dist/runtime/composables/useDivideAttrs.js +26 -0
- package/dist/runtime/composables/useGlobalResizeObserver.d.ts +3 -0
- package/dist/runtime/composables/useGlobalResizeObserver.js +28 -0
- package/dist/runtime/composables/useInjectedDarkMode.d.ts +2 -0
- package/dist/runtime/composables/useInjectedDarkMode.js +13 -0
- package/dist/runtime/composables/useInjectedI18n.d.ts +2 -0
- package/dist/runtime/composables/useInjectedI18n.js +7 -0
- package/dist/runtime/composables/useInjectedLocale.d.ts +2 -0
- package/dist/runtime/composables/useInjectedLocale.js +21 -0
- package/dist/runtime/composables/useNotificationHandler.d.ts +4 -0
- package/dist/runtime/composables/useNotificationHandler.js +21 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +68 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.js +116 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +7 -0
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +85 -0
- package/dist/runtime/composables/useSetupDarkMode.d.ts +12 -0
- package/dist/runtime/composables/useSetupDarkMode.js +4 -0
- package/dist/runtime/composables/useSetupI18n.d.ts +20 -0
- package/dist/runtime/composables/useSetupI18n.js +50 -0
- package/dist/runtime/composables/useSetupLocale.d.ts +9 -0
- package/dist/runtime/composables/useSetupLocale.js +21 -0
- package/dist/runtime/composables/useShowDevOnlyKey.d.ts +7 -0
- package/dist/runtime/composables/useShowDevOnlyKey.js +20 -0
- package/dist/runtime/composables/useSuggestions.d.ts +38 -0
- package/dist/runtime/composables/useSuggestions.js +226 -0
- package/dist/runtime/directives/index.d.ts +4 -0
- package/dist/runtime/directives/index.js +4 -0
- package/dist/runtime/directives/vDetectFlex.d.ts +2 -0
- package/dist/runtime/directives/vDetectFlex.js +109 -0
- package/dist/runtime/directives/vExtractRootEl.d.ts +22 -0
- package/dist/runtime/directives/vExtractRootEl.js +13 -0
- package/dist/runtime/directives/vResizableCols.d.ts +60 -0
- package/dist/runtime/directives/vResizableCols.js +252 -0
- package/dist/runtime/directives/vResizeObserver.d.ts +2 -0
- package/dist/runtime/directives/vResizeObserver.js +34 -0
- package/dist/runtime/globalResizeObserver.d.ts +5 -0
- package/dist/runtime/globalResizeObserver.js +5 -0
- package/dist/runtime/helpers/NotificationHandler.d.ts +48 -0
- package/dist/runtime/helpers/NotificationHandler.js +162 -0
- package/dist/runtime/helpers/addValue.d.ts +1 -0
- package/dist/runtime/helpers/addValue.js +8 -0
- package/dist/runtime/helpers/base64ToImg.d.ts +1 -0
- package/dist/runtime/helpers/base64ToImg.js +11 -0
- package/dist/runtime/helpers/copy.d.ts +1 -0
- package/dist/runtime/helpers/copy.js +10 -0
- package/dist/runtime/helpers/createNoonUtcDate.d.ts +7 -0
- package/dist/runtime/helpers/createNoonUtcDate.js +14 -0
- package/dist/runtime/helpers/defaultTranslationFunction.d.ts +16 -0
- package/dist/runtime/helpers/defaultTranslationFunction.js +14 -0
- package/dist/runtime/helpers/getTimeZoneList.d.ts +1 -0
- package/dist/runtime/helpers/getTimeZoneList.js +3 -0
- package/dist/runtime/helpers/hasModifiers.d.ts +1 -0
- package/dist/runtime/helpers/hasModifiers.js +1 -0
- package/dist/runtime/helpers/index.d.ts +8 -0
- package/dist/runtime/helpers/index.js +8 -0
- package/dist/runtime/helpers/readFile.d.ts +1 -0
- package/dist/runtime/helpers/readFile.js +13 -0
- package/dist/runtime/helpers/resizeObserverWrapper.d.ts +8 -0
- package/dist/runtime/helpers/resizeObserverWrapper.js +37 -0
- package/dist/runtime/helpers/storybook.d.ts +7 -0
- package/dist/runtime/helpers/storybook.js +42 -0
- package/dist/runtime/main.lib.d.ts +26 -0
- package/dist/runtime/main.lib.js +8 -0
- package/dist/runtime/nuxt/plugins/vue-plugin.d.ts +2 -0
- package/dist/runtime/nuxt/plugins/vue-plugin.js +12 -0
- package/dist/runtime/tailwind/index.d.ts +1 -0
- package/dist/runtime/tailwind/index.js +1 -0
- package/dist/runtime/tailwind/themeConvertionOpts.d.ts +2 -0
- package/dist/runtime/tailwind/themeConvertionOpts.js +12 -0
- package/dist/runtime/theme.d.ts +2 -0
- package/dist/runtime/theme.js +2 -0
- package/dist/runtime/types/index.d.ts +119 -0
- package/dist/runtime/types/index.js +0 -0
- package/dist/runtime/utils/twMerge.d.ts +10 -0
- package/dist/runtime/utils/twMerge.js +10 -0
- package/dist/runtime/vue/VueComponentsPlugin.d.ts +2 -0
- package/dist/runtime/vue/VueComponentsPlugin.js +10 -0
- package/dist/runtime/vue/registerComponents.d.ts +19 -0
- package/dist/runtime/vue/registerComponents.js +10 -0
- package/dist/runtime/vue/registerDirectives.d.ts +3 -0
- package/dist/runtime/vue/registerDirectives.js +9 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/package.json +207 -0
- package/src/module.ts +176 -0
- package/src/runtime/assets/base.css +67 -0
- package/src/runtime/assets/locales/en.json +33 -0
- package/src/runtime/assets/style.css +144 -0
- package/src/runtime/assets/tailwind.css +5 -0
- package/src/runtime/assets/theme.css +65 -0
- package/src/runtime/build/WitchcraftUiResolver.ts +27 -0
- package/src/runtime/build/generateTheme.ts +16 -0
- package/src/runtime/build/unpluginIconViteOptions.ts +11 -0
- package/src/runtime/components/Aria/Aria.vue +27 -0
- package/src/runtime/components/Focus.stories.ts +67 -0
- package/src/runtime/components/Icon/Icon.vue +39 -0
- package/src/runtime/components/LibButton/LibButton.stories.ts +107 -0
- package/src/runtime/components/LibButton/LibButton.vue +247 -0
- package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +41 -0
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +132 -0
- package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +69 -0
- package/src/runtime/components/LibColorInput/LibColorInput.vue +125 -0
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +60 -0
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +448 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +51 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +95 -0
- package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +114 -0
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +67 -0
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +370 -0
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +314 -0
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +27 -0
- package/src/runtime/components/LibDatePicker/helpers.ts +55 -0
- package/src/runtime/components/LibDebug/LibDebug.stories.ts +58 -0
- package/src/runtime/components/LibDebug/LibDebug.vue +91 -0
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +53 -0
- package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +79 -0
- package/src/runtime/components/LibFileInput/LibFileInput.vue +273 -0
- package/src/runtime/components/LibInput/LibInput.stories.ts +367 -0
- package/src/runtime/components/LibInput/LibInput.vue +372 -0
- package/src/runtime/components/LibLabel/LibLabel.stories.ts +37 -0
- package/src/runtime/components/LibLabel/LibLabel.vue +66 -0
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +83 -0
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +127 -0
- package/src/runtime/components/LibNotifications/LibNotification.stories.ts +142 -0
- package/src/runtime/components/LibNotifications/LibNotification.vue +121 -0
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +124 -0
- package/src/runtime/components/LibNotifications/LibNotifications.vue +133 -0
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +53 -0
- package/src/runtime/components/LibPagination/LibPagination.vue +261 -0
- package/src/runtime/components/LibPalette/LibPalette.stories.ts +32 -0
- package/src/runtime/components/LibPalette/LibPalette.vue +49 -0
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +157 -0
- package/src/runtime/components/LibPopup/LibPopup.vue +441 -0
- package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +94 -0
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +192 -0
- package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +81 -0
- package/src/runtime/components/LibRecorder/LibRecorder.vue +243 -0
- package/src/runtime/components/LibRoot/LibRoot.vue +126 -0
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +98 -0
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +148 -0
- package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +137 -0
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +198 -0
- package/src/runtime/components/LibTable/LibTable.stories.ts +170 -0
- package/src/runtime/components/LibTable/LibTable.vue +177 -0
- package/src/runtime/components/Template/NAME.vue +49 -0
- package/src/runtime/components/Template/TemplateStory.ts +38 -0
- package/src/runtime/components/TestControls/TestControls.vue +19 -0
- package/src/runtime/components/index.ts +22 -0
- package/src/runtime/components/reset.stories.ts +32 -0
- package/src/runtime/components/shared/props.ts +142 -0
- package/src/runtime/components/shared/storyHelpers/playInput.ts +35 -0
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +105 -0
- package/src/runtime/composables/index.ts +13 -0
- package/src/runtime/composables/useAccesibilityOutline.ts +104 -0
- package/src/runtime/composables/useAriaLabel.ts +23 -0
- package/src/runtime/composables/useDarkMode.ts +146 -0
- package/src/runtime/composables/useDivideAttrs.ts +52 -0
- package/src/runtime/composables/useGlobalResizeObserver.ts +33 -0
- package/src/runtime/composables/useInjectedDarkMode.ts +15 -0
- package/src/runtime/composables/useInjectedI18n.ts +10 -0
- package/src/runtime/composables/useInjectedLocale.ts +24 -0
- package/src/runtime/composables/useNotificationHandler.ts +32 -0
- package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +93 -0
- package/src/runtime/composables/useScrollNearContainerEdges.ts +205 -0
- package/src/runtime/composables/useSetupDarkMode.ts +14 -0
- package/src/runtime/composables/useSetupI18n.ts +77 -0
- package/src/runtime/composables/useSetupLocale.ts +32 -0
- package/src/runtime/composables/useShowDevOnlyKey.ts +28 -0
- package/src/runtime/composables/useSuggestions.ts +297 -0
- package/src/runtime/directives/index.ts +6 -0
- package/src/runtime/directives/vDetectFlex.ts +159 -0
- package/src/runtime/directives/vExtractRootEl.ts +38 -0
- package/src/runtime/directives/vResizableCols.ts +378 -0
- package/src/runtime/directives/vResizeObserver.ts +45 -0
- package/src/runtime/globalResizeObserver.ts +12 -0
- package/src/runtime/helpers/NotificationHandler.ts +227 -0
- package/src/runtime/helpers/addValue.ts +10 -0
- package/src/runtime/helpers/base64ToImg.ts +14 -0
- package/src/runtime/helpers/copy.ts +11 -0
- package/src/runtime/helpers/createNoonUtcDate.ts +21 -0
- package/src/runtime/helpers/defaultTranslationFunction.ts +33 -0
- package/src/runtime/helpers/getTimeZoneList.ts +4 -0
- package/src/runtime/helpers/hasModifiers.ts +1 -0
- package/src/runtime/helpers/index.ts +10 -0
- package/src/runtime/helpers/readFile.ts +22 -0
- package/src/runtime/helpers/resizeObserverWrapper.ts +45 -0
- package/src/runtime/helpers/storybook.ts +52 -0
- package/src/runtime/main.lib.ts +31 -0
- package/src/runtime/nuxt/plugins/vue-plugin.ts +19 -0
- package/src/runtime/tailwind/index.ts +3 -0
- package/src/runtime/tailwind/themeConvertionOpts.ts +15 -0
- package/src/runtime/theme.ts +5 -0
- package/src/runtime/types/index.ts +116 -0
- package/src/runtime/utils/twMerge.ts +13 -0
- package/src/runtime/vue/VueComponentsPlugin.ts +16 -0
- package/src/runtime/vue/registerComponents.ts +31 -0
- package/src/runtime/vue/registerDirectives.ts +12 -0
- package/types/components.d.ts +27 -0
- package/types/global.d.ts +16 -0
- package/types/index.d.ts +5 -0
- package/types/vite.d.ts +2 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
<!-- Popover API WHEN :sob:
|
|
2
|
+
#awaiting https://developer.mozilla.org/en-US/docs/Web/API/Popover_API#browser_compatibility -->
|
|
3
|
+
<template>
|
|
4
|
+
<slot name="button"
|
|
5
|
+
:extract-el="(_:any)=> buttonEl = _"
|
|
6
|
+
/>
|
|
7
|
+
<!-- <Transition> -->
|
|
8
|
+
<component
|
|
9
|
+
:id="id ?? fallbackId"
|
|
10
|
+
:class="twMerge(
|
|
11
|
+
useBackdrop && `bg-transparent
|
|
12
|
+
p-0
|
|
13
|
+
backdrop:bg-transparent
|
|
14
|
+
`,
|
|
15
|
+
$attrs.class as any
|
|
16
|
+
)"
|
|
17
|
+
v-bind="{...$attrs, class:undefined}"
|
|
18
|
+
:is="useBackdrop ? 'dialog' : 'div'"
|
|
19
|
+
ref="dialogEl"
|
|
20
|
+
@mousedown.self="handleMouseup"
|
|
21
|
+
>
|
|
22
|
+
<div v-if="useBackdrop || modelValue"
|
|
23
|
+
:class="`fixed ${props.avoidRepositioning ? 'transition-[top,left]' : ''}`"
|
|
24
|
+
:style="`
|
|
25
|
+
top:${pos.y}px;
|
|
26
|
+
left:${pos.x}px;
|
|
27
|
+
${pos.maxWidth ? `max-width:${pos.maxWidth}px` : ''}
|
|
28
|
+
${pos.maxHeight ? `max-height:${pos.maxHeight}px` : ''}
|
|
29
|
+
`"
|
|
30
|
+
>
|
|
31
|
+
<slot
|
|
32
|
+
name="popup"
|
|
33
|
+
:position="pos"
|
|
34
|
+
:extract-el="(_:any) => popupEl = _"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</component>
|
|
38
|
+
<!-- </Transition> -->
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup lang="ts">
|
|
42
|
+
// eslint-disable-next-line simple-import-sort/imports
|
|
43
|
+
import { onMounted, nextTick, ref, useAttrs, watch , type HTMLAttributes } from "vue"
|
|
44
|
+
import { getFallbackId, type LinkableByIdProps,type TailwindClassProp } from "../shared/props.js"
|
|
45
|
+
|
|
46
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
47
|
+
import { castType } from "@alanscodelog/utils/castType.js"
|
|
48
|
+
import { isArray } from "@alanscodelog/utils/isArray.js"
|
|
49
|
+
import type { IPopupReference, PopupPosition, PopupPositioner, PopupPositionModifier, SimpleDOMRect } from "../../types/index.js"
|
|
50
|
+
|
|
51
|
+
const fallbackId = getFallbackId()
|
|
52
|
+
// eslint-disable-next-line no-use-before-define
|
|
53
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
54
|
+
useBackdrop: true,
|
|
55
|
+
// vue is getting confused when the prop type can also be a function
|
|
56
|
+
preferredHorizontal: () => ["center-most", "either"] satisfies Props["preferredHorizontal"],
|
|
57
|
+
preferredVertical: () => ["top", "bottom", "either"] satisfies Props["preferredVertical"] ,
|
|
58
|
+
avoidRepositioning: false,
|
|
59
|
+
})
|
|
60
|
+
const $attrs = useAttrs()
|
|
61
|
+
defineOptions({ name: "lib-popup" })
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
const dialogEl = ref<HTMLDialogElement | null>(null)
|
|
65
|
+
const popupEl = ref<IPopupReference | null>(null)
|
|
66
|
+
const buttonEl = ref<IPopupReference | null>(null)
|
|
67
|
+
const backgroundEl = ref<IPopupReference | null>(null)
|
|
68
|
+
|
|
69
|
+
const pos = ref<PopupPosition>({} as any)
|
|
70
|
+
const modelValue = defineModel<boolean>({ default: false })
|
|
71
|
+
let isOpen = false
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* We don't have access to the dialog backdrop and without extra styling, it's of 0 width/height, positioned in the center of the screen, with margins taking up all the space.
|
|
76
|
+
*
|
|
77
|
+
* This returns a modified rect that makes more logical sense.
|
|
78
|
+
*/
|
|
79
|
+
const getDialogBoundingRect = (): SimpleDOMRect => ({
|
|
80
|
+
x: 0,
|
|
81
|
+
y: 0,
|
|
82
|
+
width: window.innerWidth,
|
|
83
|
+
height: window.innerHeight,
|
|
84
|
+
top: 0,
|
|
85
|
+
bottom: 0,
|
|
86
|
+
left: 0,
|
|
87
|
+
right: 0,
|
|
88
|
+
})
|
|
89
|
+
let lastButtonElPos: SimpleDOMRect | undefined
|
|
90
|
+
const recompute = (force: boolean = false): void => {
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
const horzHasCenterScreen = isArray(props.preferredHorizontal)
|
|
93
|
+
&& props.preferredHorizontal[0] === "center-screen"
|
|
94
|
+
const vertHasCenterScreen = isArray(props.preferredVertical)
|
|
95
|
+
&& props.preferredVertical[0] === "center-screen"
|
|
96
|
+
|
|
97
|
+
const canBePositionedWithoutButton =
|
|
98
|
+
(horzHasCenterScreen || typeof props.preferredHorizontal === "function")
|
|
99
|
+
&& (vertHasCenterScreen || typeof props.preferredVertical === "function")
|
|
100
|
+
|
|
101
|
+
if (!popupEl.value || !dialogEl.value || (!buttonEl.value && !canBePositionedWithoutButton)) {
|
|
102
|
+
pos.value = {} as any
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
const el = buttonEl.value?.getBoundingClientRect()
|
|
106
|
+
const bg = backgroundEl.value?.getBoundingClientRect() ?? (
|
|
107
|
+
props.useBackdrop
|
|
108
|
+
? getDialogBoundingRect()
|
|
109
|
+
: document.body.getBoundingClientRect()
|
|
110
|
+
)
|
|
111
|
+
const popup = popupEl.value.getBoundingClientRect()
|
|
112
|
+
|
|
113
|
+
let finalPos: { x: number, y: number, maxWidth?: number, maxHeight?: number } = {} as any
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if (!force && modelValue.value && props.avoidRepositioning && buttonEl.value && lastButtonElPos) {
|
|
117
|
+
const shiftX = buttonEl.value.getBoundingClientRect().x - lastButtonElPos.x
|
|
118
|
+
const shiftY = buttonEl.value.getBoundingClientRect().y - lastButtonElPos.y
|
|
119
|
+
|
|
120
|
+
pos.value.x += shiftX
|
|
121
|
+
pos.value.y += shiftY
|
|
122
|
+
lastButtonElPos = el
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const space = {
|
|
127
|
+
left: 0,
|
|
128
|
+
right: 0,
|
|
129
|
+
leftLeft: 0,
|
|
130
|
+
rightRight: 0,
|
|
131
|
+
leftFromCenter: 0,
|
|
132
|
+
rightFromCenter: 0,
|
|
133
|
+
topFromCenter: 0,
|
|
134
|
+
bottomFromCenter: 0,
|
|
135
|
+
top: 0,
|
|
136
|
+
bottom: 0,
|
|
137
|
+
}
|
|
138
|
+
if (el) {
|
|
139
|
+
space.left = (el.x + el.width) - bg.x
|
|
140
|
+
space.leftLeft = el.x - bg.x
|
|
141
|
+
space.right = (bg.x + bg.width) - (el.x + el.width)
|
|
142
|
+
space.rightRight = bg.x + bg.width - el.x
|
|
143
|
+
space.leftFromCenter = (el.x + (el.width / 2)) - bg.x
|
|
144
|
+
space.rightFromCenter = (bg.x + bg.width) - (el.x + (el.width / 2))
|
|
145
|
+
space.topFromCenter = (el.y + (el.height / 2)) - bg.y
|
|
146
|
+
space.bottomFromCenter = (bg.y + bg.height) - (el.y + (el.height / 2))
|
|
147
|
+
space.top = el.y - bg.y
|
|
148
|
+
space.bottom = (bg.y + bg.height) - (el.y + el.height)
|
|
149
|
+
}
|
|
150
|
+
const { preferredHorizontal, preferredVertical } = props
|
|
151
|
+
let maxWidth: number | undefined
|
|
152
|
+
let maxHeight: number | undefined
|
|
153
|
+
if (typeof preferredHorizontal === "function") {
|
|
154
|
+
finalPos.x = preferredHorizontal(el, popup, bg, space)
|
|
155
|
+
} else {
|
|
156
|
+
/* eslint-disable no-labels */
|
|
157
|
+
outerloop:
|
|
158
|
+
for (const type of preferredHorizontal) {
|
|
159
|
+
switch (type) {
|
|
160
|
+
case "center-screen":
|
|
161
|
+
if (popup.width < bg.width) {
|
|
162
|
+
finalPos.x = (bg.width / 2) - (popup.width / 2)
|
|
163
|
+
} else {
|
|
164
|
+
finalPos.x = 0
|
|
165
|
+
maxWidth = finalPos.x
|
|
166
|
+
}
|
|
167
|
+
break
|
|
168
|
+
case "center-most":
|
|
169
|
+
case "center":
|
|
170
|
+
castType<DOMRect>(el)
|
|
171
|
+
if (space.leftFromCenter >= (popup.width / 2) &&
|
|
172
|
+
space.rightFromCenter >= (popup.width / 2)) {
|
|
173
|
+
finalPos.x = el.x + (el.width / 2) - (popup.width / 2)
|
|
174
|
+
break outerloop
|
|
175
|
+
}
|
|
176
|
+
// todo temp fix when it's too wide, will prefer left
|
|
177
|
+
if (((space.rightFromCenter + space.leftFromCenter) <= popup.width)) {
|
|
178
|
+
finalPos.x = 0
|
|
179
|
+
break outerloop
|
|
180
|
+
}
|
|
181
|
+
if (type === "center-most") {
|
|
182
|
+
if (space.leftFromCenter < space.rightFromCenter) {
|
|
183
|
+
finalPos.x = el.x + (el.width / 2) - space.leftFromCenter; break outerloop
|
|
184
|
+
} else {
|
|
185
|
+
finalPos.x = el.x + (el.width / 2) + space.rightFromCenter - popup.width; break outerloop
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
break
|
|
189
|
+
case "left-most":
|
|
190
|
+
castType<DOMRect>(el)
|
|
191
|
+
if (space.left >= popup.width) {
|
|
192
|
+
finalPos.x = el.x - popup.width; break outerloop
|
|
193
|
+
} else {
|
|
194
|
+
finalPos.x = 0; break outerloop
|
|
195
|
+
}
|
|
196
|
+
case "right-most":
|
|
197
|
+
castType<DOMRect>(el)
|
|
198
|
+
if (space.right >= popup.width) {
|
|
199
|
+
finalPos.x = el.x + el.width; break outerloop
|
|
200
|
+
} else {
|
|
201
|
+
finalPos.x = bg.x + bg.width - popup.width; break outerloop
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
case "right":
|
|
205
|
+
castType<DOMRect>(el)
|
|
206
|
+
if (space.right >= popup.width) {
|
|
207
|
+
finalPos.x = el.x; break outerloop
|
|
208
|
+
}
|
|
209
|
+
break
|
|
210
|
+
case "left":
|
|
211
|
+
castType<DOMRect>(el)
|
|
212
|
+
if (space.left >= popup.width) {
|
|
213
|
+
finalPos.x = (el.x + el.width) - popup.width; break outerloop
|
|
214
|
+
}
|
|
215
|
+
break
|
|
216
|
+
case "either": {
|
|
217
|
+
castType<DOMRect>(el)
|
|
218
|
+
if (space.right >= space.left) {
|
|
219
|
+
finalPos.x = el.x; break outerloop
|
|
220
|
+
} else {
|
|
221
|
+
finalPos.x = (el.x + el.width) - popup.width
|
|
222
|
+
break outerloop
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (typeof preferredVertical === "function") {
|
|
229
|
+
finalPos.y = preferredVertical(el, popup, bg, space)
|
|
230
|
+
} else {
|
|
231
|
+
outerloop:
|
|
232
|
+
for (const type of preferredVertical) {
|
|
233
|
+
switch (type) {
|
|
234
|
+
case "center-screen":
|
|
235
|
+
if (popup.height < bg.height) {
|
|
236
|
+
finalPos.y = (bg.height / 2) - (popup.height / 2)
|
|
237
|
+
} else {
|
|
238
|
+
finalPos.y = 0
|
|
239
|
+
maxHeight = finalPos.y
|
|
240
|
+
}
|
|
241
|
+
break
|
|
242
|
+
case "top":
|
|
243
|
+
castType<DOMRect>(el)
|
|
244
|
+
if (space.top >= popup.height) {
|
|
245
|
+
finalPos.y = el.y - popup.height; break outerloop
|
|
246
|
+
}
|
|
247
|
+
break
|
|
248
|
+
case "bottom":
|
|
249
|
+
castType<DOMRect>(el)
|
|
250
|
+
if (space.bottom >= popup.height) {
|
|
251
|
+
finalPos.y = el.y + el.height; break outerloop
|
|
252
|
+
}
|
|
253
|
+
break
|
|
254
|
+
case "top-most":
|
|
255
|
+
castType<DOMRect>(el)
|
|
256
|
+
if (space.top >= popup.height) {
|
|
257
|
+
finalPos.y = el.y - popup.height; break outerloop
|
|
258
|
+
} else {
|
|
259
|
+
finalPos.y = 0; break outerloop
|
|
260
|
+
}
|
|
261
|
+
case "bottom-most":
|
|
262
|
+
castType<DOMRect>(el)
|
|
263
|
+
if (space.bottom >= popup.height) {
|
|
264
|
+
finalPos.y = el.y + el.height; break outerloop
|
|
265
|
+
} else {
|
|
266
|
+
finalPos.y = bg.y + bg.height - popup.height; break outerloop
|
|
267
|
+
}
|
|
268
|
+
case "center-most":
|
|
269
|
+
case "center":
|
|
270
|
+
castType<DOMRect>(el)
|
|
271
|
+
if (space.topFromCenter >= (popup.height / 2) &&
|
|
272
|
+
space.bottomFromCenter >= (popup.height / 2)) {
|
|
273
|
+
finalPos.y = el.y + (el.height / 2) - (popup.height / 2)
|
|
274
|
+
break outerloop
|
|
275
|
+
}
|
|
276
|
+
// todo temp fix when it's too wide, will prefer the top
|
|
277
|
+
if (((space.bottomFromCenter + space.topFromCenter) <= popup.height)) {
|
|
278
|
+
finalPos.y = 0
|
|
279
|
+
break outerloop
|
|
280
|
+
}
|
|
281
|
+
if (type === "center-most") {
|
|
282
|
+
if (space.topFromCenter < space.bottomFromCenter) {
|
|
283
|
+
finalPos.y = el.y + (el.height / 2) - space.topFromCenter; break outerloop
|
|
284
|
+
} else {
|
|
285
|
+
finalPos.y = el.y + (el.height / 2) + space.bottomFromCenter - popup.height; break outerloop
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
break
|
|
289
|
+
case "either": {
|
|
290
|
+
castType<DOMRect>(el)
|
|
291
|
+
if (space.top >= space.bottom) {
|
|
292
|
+
finalPos.y = el.y - popup.height; break outerloop
|
|
293
|
+
} else { finalPos.y = el.y + el.height; break outerloop }
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
finalPos.maxWidth = maxWidth ?? undefined
|
|
299
|
+
finalPos.maxHeight = maxHeight ?? undefined
|
|
300
|
+
/* eslint-enable no-labels */
|
|
301
|
+
if (props.modifyPosition) {
|
|
302
|
+
finalPos = props.modifyPosition(finalPos, el, popup, bg, space)
|
|
303
|
+
}
|
|
304
|
+
pos.value = finalPos
|
|
305
|
+
lastButtonElPos = el
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const show = () => {
|
|
310
|
+
if (!isOpen) {
|
|
311
|
+
isOpen = true
|
|
312
|
+
modelValue.value = isOpen
|
|
313
|
+
if (props.useBackdrop) dialogEl.value?.showModal()
|
|
314
|
+
recompute(true)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const close = () => {
|
|
319
|
+
if (isOpen) {
|
|
320
|
+
isOpen = false
|
|
321
|
+
modelValue.value = isOpen
|
|
322
|
+
pos.value.maxWidth = undefined
|
|
323
|
+
if (props.useBackdrop) dialogEl.value?.close()
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const toggle = () => {
|
|
328
|
+
if (!isOpen) show()
|
|
329
|
+
else close()
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const recomputeListener = () => recompute()
|
|
333
|
+
|
|
334
|
+
const bindListeners = () => {
|
|
335
|
+
window.addEventListener("resize", recomputeListener)
|
|
336
|
+
window.addEventListener("scroll", recomputeListener, true)
|
|
337
|
+
}
|
|
338
|
+
const unbindListeners = () => {
|
|
339
|
+
window.removeEventListener("resize", recomputeListener)
|
|
340
|
+
window.removeEventListener("scroll", recomputeListener, true)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
watch([modelValue, popupEl], () => {
|
|
344
|
+
if (modelValue.value) {
|
|
345
|
+
show()
|
|
346
|
+
bindListeners()
|
|
347
|
+
} else {
|
|
348
|
+
close()
|
|
349
|
+
unbindListeners()
|
|
350
|
+
}
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
const handleMouseup = ($event: MouseEvent) => {
|
|
355
|
+
$event.preventDefault()
|
|
356
|
+
toggle()
|
|
357
|
+
}
|
|
358
|
+
onMounted(() => {
|
|
359
|
+
recompute()
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
defineExpose({
|
|
363
|
+
recompute,
|
|
364
|
+
setReference: (el: IPopupReference | null) => {
|
|
365
|
+
buttonEl.value = el
|
|
366
|
+
},
|
|
367
|
+
setBackground: (el: IPopupReference | null) => {
|
|
368
|
+
backgroundEl.value = el
|
|
369
|
+
},
|
|
370
|
+
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
</script>
|
|
374
|
+
<script lang="ts">
|
|
375
|
+
|
|
376
|
+
type RealProps =
|
|
377
|
+
& LinkableByIdProps
|
|
378
|
+
& {
|
|
379
|
+
useBackdrop?: boolean
|
|
380
|
+
/**
|
|
381
|
+
* The preferred horizontal positioning of the popup. The first position in the array to fit is used.
|
|
382
|
+
*
|
|
383
|
+
* All elements need to have box-sizing: border-box set. Also note that while the component should work with dynamic popup sizes, in practice there's issues with the positioning being slightly off. Giving the popup element a static size is better. If you need margins around the popup, this can be done with a wrapper element + padding.
|
|
384
|
+
*
|
|
385
|
+
* The positions `right`/`left`/`top`/`bottom` are relative to the opposite side of the button element so as to try not to cover the triggering button.
|
|
386
|
+
*
|
|
387
|
+
* So positioning `right` and `left` look like this:
|
|
388
|
+
*
|
|
389
|
+
* ```
|
|
390
|
+
* // right
|
|
391
|
+
* [button]
|
|
392
|
+
* [----popup----]
|
|
393
|
+
*
|
|
394
|
+
* // left
|
|
395
|
+
* [button]
|
|
396
|
+
* [----popup----]
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* Positions `*-most` try to position the popup as close to that side of the screen as possible, otherwise limiting the popup to that edge. For example:
|
|
400
|
+
*
|
|
401
|
+
* ```
|
|
402
|
+
* [--------------screen---------------]
|
|
403
|
+
* // right-most
|
|
404
|
+
* [button]
|
|
405
|
+
* [----popup----]
|
|
406
|
+
* // near the edge:
|
|
407
|
+
* [button]
|
|
408
|
+
* [----popup----]
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* There is also the `center-screen` position, which centers the popup on the screen.
|
|
412
|
+
*
|
|
413
|
+
* These last two (`*-most` and `center-screen`) are greedy, they will always find a position that fits. Positions listed after are ignored.
|
|
414
|
+
*
|
|
415
|
+
* You can also specify a function instead which is given some additional information regarding the space around the button reference element. It should a number for the x position (or y, if preferredVertical).
|
|
416
|
+
*
|
|
417
|
+
* If you only need to slightly modify the position, you can use the `modifyPosition` option instead.
|
|
418
|
+
*/
|
|
419
|
+
preferredHorizontal?: ("center" | "right" | "left" | "either" | "center-screen" | "right-most" | "left-most" | "center-most")[] | PopupPositioner
|
|
420
|
+
/** See `preferredHorizontal`. */
|
|
421
|
+
preferredVertical?: ("top" | "bottom" | "center" | "either" | "center-screen" | "top-most" | "bottom-most" | "center-most")[] | PopupPositioner
|
|
422
|
+
/**
|
|
423
|
+
* When the user scrolls or resizes, normally the entire popup position is recomputed, taking into account the preferred positioning.
|
|
424
|
+
*
|
|
425
|
+
* This can cause it to shift around.
|
|
426
|
+
*
|
|
427
|
+
* Set this to true to only shift the popup depending on how much the button element moved and avoid recalculating the best position.
|
|
428
|
+
*/
|
|
429
|
+
avoidRepositioning?: boolean
|
|
430
|
+
/**
|
|
431
|
+
* Allows modifying the calculated position, to for example, clamp it.
|
|
432
|
+
*/
|
|
433
|
+
modifyPosition?: PopupPositionModifier
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
interface Props
|
|
437
|
+
extends
|
|
438
|
+
/** @vue-ignore */
|
|
439
|
+
Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
|
|
440
|
+
RealProps { }
|
|
441
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3";
|
|
2
|
+
import LibProgressBar from "./LibProgressBar.vue.js";
|
|
3
|
+
declare const meta: Meta<typeof LibProgressBar>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof LibProgressBar>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Secondary: Story;
|
|
8
|
+
export declare const ReallyLongLabel: Story;
|
|
9
|
+
export declare const Static: Story;
|
|
10
|
+
export declare const AutoHiding: Story;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { onUnmounted, ref } from "vue";
|
|
2
|
+
import LibProgressBar from "./LibProgressBar.vue";
|
|
3
|
+
import * as components from "../index.js";
|
|
4
|
+
const meta = {
|
|
5
|
+
component: LibProgressBar,
|
|
6
|
+
title: "Components/ProgressBar",
|
|
7
|
+
args: {
|
|
8
|
+
label: "Label",
|
|
9
|
+
// @ts-expect-error .
|
|
10
|
+
_timeout: 1e3,
|
|
11
|
+
_add: 10,
|
|
12
|
+
_start: 50
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
export const Primary = {
|
|
17
|
+
render: (args) => ({
|
|
18
|
+
components,
|
|
19
|
+
setup: () => {
|
|
20
|
+
const progress = ref(args._start);
|
|
21
|
+
if (args.progress) {
|
|
22
|
+
progress.value = args.progress;
|
|
23
|
+
} else {
|
|
24
|
+
const interval = setInterval(() => {
|
|
25
|
+
if (progress.value >= 100) {
|
|
26
|
+
progress.value = 0;
|
|
27
|
+
} else {
|
|
28
|
+
progress.value += args._add;
|
|
29
|
+
}
|
|
30
|
+
}, args._timeout);
|
|
31
|
+
onUnmounted(() => {
|
|
32
|
+
clearInterval(interval);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
args: { ...args },
|
|
37
|
+
progress
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
template: `
|
|
41
|
+
<lib-progress-bar class="flex-1" v-bind="args" :progress="progress"></lib-progress-bar>
|
|
42
|
+
<br/>
|
|
43
|
+
Stretched in flexbox:
|
|
44
|
+
<div class="flex w-full">
|
|
45
|
+
<lib-progress-bar class="flex-1" v-bind="args" :progress="progress"></lib-progress-bar>
|
|
46
|
+
</div>
|
|
47
|
+
`
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
export const Secondary = {
|
|
51
|
+
...Primary,
|
|
52
|
+
args: {
|
|
53
|
+
...Primary.args
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export const ReallyLongLabel = {
|
|
57
|
+
...Primary,
|
|
58
|
+
args: {
|
|
59
|
+
...Primary.args,
|
|
60
|
+
label: "Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect Really Long Label Label to See Effect"
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export const Static = {
|
|
64
|
+
...Primary,
|
|
65
|
+
args: {
|
|
66
|
+
...Primary.args,
|
|
67
|
+
progress: 50
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export const AutoHiding = {
|
|
71
|
+
...Primary,
|
|
72
|
+
args: {
|
|
73
|
+
...Primary.args,
|
|
74
|
+
autohideOnComplete: 500,
|
|
75
|
+
clamp: [10, 100],
|
|
76
|
+
_start: 0,
|
|
77
|
+
// keepSpaceWhenHidden: true,
|
|
78
|
+
_timeout: 1e3,
|
|
79
|
+
_add: 10
|
|
80
|
+
}
|
|
81
|
+
};
|