@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,314 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { type DateValue, getLocalTimeZone } from "@internationalized/date"
|
|
3
|
+
import { DatePickerArrow, DatePickerCalendar, DatePickerCell, DatePickerCellTrigger, DatePickerContent, DatePickerField, DatePickerGrid, DatePickerGridBody, DatePickerGridHead, DatePickerGridRow, DatePickerHeadCell, DatePickerHeader, DatePickerHeading, DatePickerInput, DatePickerNext, DatePickerPrev, DatePickerRoot, DatePickerTrigger } from "radix-vue"
|
|
4
|
+
import { onBeforeUnmount, ref, toRaw, useAttrs, watch } from "vue"
|
|
5
|
+
|
|
6
|
+
import { convertDateWithFallback, getNow,toEmittableDate } from "./helpers.js"
|
|
7
|
+
|
|
8
|
+
import { useInjectedLocale } from "../../composables/useInjectedLocale.js"
|
|
9
|
+
import type { SingleDate } from "../../types/index.js"
|
|
10
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
11
|
+
import Icon from "../Icon/Icon.vue"
|
|
12
|
+
|
|
13
|
+
const attrs = useAttrs()
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<{
|
|
16
|
+
useTime?: boolean
|
|
17
|
+
id: string
|
|
18
|
+
fallbackDate?: Date
|
|
19
|
+
timeZone?: string
|
|
20
|
+
updateInterval?: number
|
|
21
|
+
}>(), {
|
|
22
|
+
timeZone: getLocalTimeZone(),
|
|
23
|
+
useTime: false,
|
|
24
|
+
fallbackDate: _ => getNow({ withTime: _.useTime ?? false }).toDate(_.timeZone ?? getLocalTimeZone()),
|
|
25
|
+
updateInterval: 10000
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const locale = useInjectedLocale().timeLocale
|
|
29
|
+
|
|
30
|
+
const date = defineModel<SingleDate>({ required: true })
|
|
31
|
+
const tempDate = ref(convertDateWithFallback(date.value, props))
|
|
32
|
+
watch(() => props.timeZone, () => {
|
|
33
|
+
tempDate.value = convertDateWithFallback(date.value, props)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
watch(tempDate, () => {
|
|
37
|
+
date.value = toEmittableDate(toRaw(tempDate.value as any))
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const interval = setInterval(() => {
|
|
41
|
+
if (!date.value) {
|
|
42
|
+
// update suggested date if none is set
|
|
43
|
+
tempDate.value = convertDateWithFallback(date.value, props)
|
|
44
|
+
}
|
|
45
|
+
}, props.updateInterval)
|
|
46
|
+
|
|
47
|
+
onBeforeUnmount(() => {
|
|
48
|
+
clearInterval(interval)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<DatePickerRoot
|
|
55
|
+
:id="id"
|
|
56
|
+
:locale="locale"
|
|
57
|
+
class="root"
|
|
58
|
+
v-model="tempDate as DateValue"
|
|
59
|
+
>
|
|
60
|
+
<DatePickerField
|
|
61
|
+
v-slot="{ segments }"
|
|
62
|
+
:class="twMerge(`
|
|
63
|
+
container
|
|
64
|
+
flex items-center justify-between
|
|
65
|
+
select-none
|
|
66
|
+
data-[invalid]:border-red-500
|
|
67
|
+
metadata-input-border
|
|
68
|
+
rounded-sm
|
|
69
|
+
`,
|
|
70
|
+
(attrs as any).class)
|
|
71
|
+
"
|
|
72
|
+
>
|
|
73
|
+
<div :class="twMerge(`segments flex items-center overflow-scroll scrollbar-hidden whitespace-nowrapa`, date === undefined && 'text-neutral-400')">
|
|
74
|
+
<template
|
|
75
|
+
v-for="item in segments"
|
|
76
|
+
:key="item.part"
|
|
77
|
+
>
|
|
78
|
+
<DatePickerInput
|
|
79
|
+
v-if="item.part === 'literal'"
|
|
80
|
+
:part="item.part"
|
|
81
|
+
class="input-literal"
|
|
82
|
+
>
|
|
83
|
+
{{ item.value }}
|
|
84
|
+
</DatePickerInput>
|
|
85
|
+
<DatePickerInput
|
|
86
|
+
v-else
|
|
87
|
+
:part="item.part"
|
|
88
|
+
class="
|
|
89
|
+
input
|
|
90
|
+
focus-outline-hidden
|
|
91
|
+
border
|
|
92
|
+
border-transparent
|
|
93
|
+
group
|
|
94
|
+
"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
class="
|
|
98
|
+
group-focus:z-[2]
|
|
99
|
+
group-focus:bg-accent-500/50
|
|
100
|
+
group-focus:rounded-xs
|
|
101
|
+
px-[2px]
|
|
102
|
+
"
|
|
103
|
+
>
|
|
104
|
+
{{ item.value }}
|
|
105
|
+
</div>
|
|
106
|
+
</DatePickerInput>
|
|
107
|
+
</template>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<DatePickerTrigger
|
|
111
|
+
class="
|
|
112
|
+
trigger
|
|
113
|
+
px-1
|
|
114
|
+
focus-outline
|
|
115
|
+
rounded-tr-sm
|
|
116
|
+
rounded-br-sm
|
|
117
|
+
bg-bg
|
|
118
|
+
border-l
|
|
119
|
+
border-neutral-300
|
|
120
|
+
dark:border-neutral-700
|
|
121
|
+
dark:bg-neutral-800
|
|
122
|
+
"
|
|
123
|
+
>
|
|
124
|
+
<Icon>
|
|
125
|
+
<i-radix-icons-calendar/>
|
|
126
|
+
</Icon>
|
|
127
|
+
</DatePickerTrigger>
|
|
128
|
+
</DatePickerField>
|
|
129
|
+
|
|
130
|
+
<!-- @vue-expect-error to exists -->
|
|
131
|
+
<DatePickerContent
|
|
132
|
+
:side-offset="4"
|
|
133
|
+
to="#root"
|
|
134
|
+
class="
|
|
135
|
+
mx-2
|
|
136
|
+
rounded-sm
|
|
137
|
+
bg-bg
|
|
138
|
+
dark:bg-neutral-800
|
|
139
|
+
border
|
|
140
|
+
border-neutral-300
|
|
141
|
+
dark:border-neutral-700
|
|
142
|
+
shadow-lg
|
|
143
|
+
will-change-[transform,opacity]
|
|
144
|
+
data-[state=open]:data-[side=top]:animate-slideDownAndFade
|
|
145
|
+
data-[state=open]:data-[side=right]:animate-slideLeftAndFade
|
|
146
|
+
data-[state=open]:data-[side=bottom]:animate-slideUpAndFade
|
|
147
|
+
data-[state=open]:data-[side=left]:animate-slideRightAndFade
|
|
148
|
+
text-fg
|
|
149
|
+
dark:text-neutral-200
|
|
150
|
+
"
|
|
151
|
+
>
|
|
152
|
+
<DatePickerArrow class="fill-neutral-500"/>
|
|
153
|
+
<!-- We set some max-width so it's not so hard to style the slot (which otherwise grows the calendar really wide. The min width is the header (4 icons + their padding + 14ch month), hence the complicated formula. -->
|
|
154
|
+
<DatePickerCalendar
|
|
155
|
+
v-slot="{ weekDays, grid }"
|
|
156
|
+
class="p-2 flex flex-col max-w-[calc(1.2em*4+var(--spacing)*8+14ch)]"
|
|
157
|
+
>
|
|
158
|
+
<DatePickerHeader class="flex items-center justify-between">
|
|
159
|
+
<DatePickerPrev
|
|
160
|
+
class="
|
|
161
|
+
inline-flex
|
|
162
|
+
items-center
|
|
163
|
+
cursor-pointer
|
|
164
|
+
active:scale-125
|
|
165
|
+
justify-center
|
|
166
|
+
rounded-sm
|
|
167
|
+
outlined
|
|
168
|
+
px-1
|
|
169
|
+
"
|
|
170
|
+
:prev-page="(date: DateValue) => date.subtract({ years: 1 })"
|
|
171
|
+
>
|
|
172
|
+
<Icon class="scale-150">
|
|
173
|
+
<i-radix-icons-double-arrow-left/>
|
|
174
|
+
</Icon>
|
|
175
|
+
</DatePickerPrev>
|
|
176
|
+
<DatePickerPrev
|
|
177
|
+
class="
|
|
178
|
+
inline-flex
|
|
179
|
+
items-center
|
|
180
|
+
cursor-pointer
|
|
181
|
+
active:scale-125
|
|
182
|
+
justify-center
|
|
183
|
+
rounded-sm
|
|
184
|
+
outlined
|
|
185
|
+
px-1
|
|
186
|
+
"
|
|
187
|
+
>
|
|
188
|
+
<Icon class="scale-150">
|
|
189
|
+
<i-radix-icons-chevron-left/>
|
|
190
|
+
</Icon>
|
|
191
|
+
</DatePickerPrev>
|
|
192
|
+
|
|
193
|
+
<DatePickerHeading class="min-w-[14ch] text-center"/>
|
|
194
|
+
<DatePickerNext
|
|
195
|
+
class="
|
|
196
|
+
inline-flex
|
|
197
|
+
items-center
|
|
198
|
+
cursor-pointer
|
|
199
|
+
active:scale-125
|
|
200
|
+
justify-center
|
|
201
|
+
rounded-sm
|
|
202
|
+
outlined
|
|
203
|
+
px-1
|
|
204
|
+
"
|
|
205
|
+
>
|
|
206
|
+
<Icon class="scale-150">
|
|
207
|
+
<i-radix-icons-chevron-right/>
|
|
208
|
+
</Icon>
|
|
209
|
+
</DatePickerNext>
|
|
210
|
+
<DatePickerNext
|
|
211
|
+
class="
|
|
212
|
+
inline-flex
|
|
213
|
+
items-center
|
|
214
|
+
cursor-pointer
|
|
215
|
+
active:scale-125
|
|
216
|
+
justify-center
|
|
217
|
+
rounded-sm
|
|
218
|
+
outlined
|
|
219
|
+
px-1
|
|
220
|
+
"
|
|
221
|
+
:next-page="(date: DateValue) => date.add({ years: 1 })"
|
|
222
|
+
>
|
|
223
|
+
<Icon class="scale-150">
|
|
224
|
+
<i-radix-icons-double-arrow-right/>
|
|
225
|
+
</Icon>
|
|
226
|
+
</DatePickerNext>
|
|
227
|
+
</DatePickerHeader>
|
|
228
|
+
<div
|
|
229
|
+
class="
|
|
230
|
+
flex
|
|
231
|
+
flex-col
|
|
232
|
+
pt-4
|
|
233
|
+
"
|
|
234
|
+
>
|
|
235
|
+
<DatePickerGrid
|
|
236
|
+
class="border-collapse select-none"
|
|
237
|
+
v-for="month in grid"
|
|
238
|
+
:key="month.value.toString()"
|
|
239
|
+
>
|
|
240
|
+
<DatePickerGridHead>
|
|
241
|
+
<DatePickerGridRow class="mb-1 flex justify-between">
|
|
242
|
+
<DatePickerHeadCell
|
|
243
|
+
class="
|
|
244
|
+
w-6
|
|
245
|
+
rounded-md
|
|
246
|
+
text-xs
|
|
247
|
+
text-accent-500
|
|
248
|
+
"
|
|
249
|
+
v-for="day in weekDays"
|
|
250
|
+
:key="day"
|
|
251
|
+
>
|
|
252
|
+
{{ day }}
|
|
253
|
+
</DatePickerHeadCell>
|
|
254
|
+
</DatePickerGridRow>
|
|
255
|
+
</DatePickerGridHead>
|
|
256
|
+
<DatePickerGridBody>
|
|
257
|
+
<DatePickerGridRow
|
|
258
|
+
class="flex w-full justify-between my-1"
|
|
259
|
+
v-for="(weekDates, index) in month.rows"
|
|
260
|
+
:key="`weekDate-${index}`"
|
|
261
|
+
>
|
|
262
|
+
<DatePickerCell
|
|
263
|
+
:date="weekDate"
|
|
264
|
+
v-for="weekDate in weekDates"
|
|
265
|
+
:key="weekDate.toString()"
|
|
266
|
+
>
|
|
267
|
+
<DatePickerCellTrigger
|
|
268
|
+
:day="weekDate"
|
|
269
|
+
:month="month.value"
|
|
270
|
+
class="
|
|
271
|
+
relative
|
|
272
|
+
flex
|
|
273
|
+
items-center
|
|
274
|
+
justify-center
|
|
275
|
+
whitespace-nowrap
|
|
276
|
+
rounded-sm
|
|
277
|
+
border
|
|
278
|
+
border-transparent
|
|
279
|
+
bg-transparent
|
|
280
|
+
text-sm
|
|
281
|
+
w-6
|
|
282
|
+
h-6
|
|
283
|
+
focus:shadow
|
|
284
|
+
focus-outline
|
|
285
|
+
hover:border-accent-500
|
|
286
|
+
data-[selected]:bg-accent-700
|
|
287
|
+
data-[selected]:shadow
|
|
288
|
+
data-[disabled]:text-neutral-500
|
|
289
|
+
data-[selected]:text-white
|
|
290
|
+
data-[unavailable]:pointer-events-none
|
|
291
|
+
data-[unavailable]:text-neutral-500
|
|
292
|
+
data-[unavailable]:line-through
|
|
293
|
+
before:absolute
|
|
294
|
+
before:bottom-[1px]
|
|
295
|
+
before:hidden
|
|
296
|
+
before:rounded-full
|
|
297
|
+
before:w-4
|
|
298
|
+
before:h-[2px]
|
|
299
|
+
before:bg-white
|
|
300
|
+
data-[today]:before:block
|
|
301
|
+
data-[today]:before:bg-accent-500
|
|
302
|
+
data-[selected]:before:bg-white
|
|
303
|
+
"
|
|
304
|
+
/>
|
|
305
|
+
</DatePickerCell>
|
|
306
|
+
</DatePickerGridRow>
|
|
307
|
+
</DatePickerGridBody>
|
|
308
|
+
</DatePickerGrid>
|
|
309
|
+
</div>
|
|
310
|
+
<slot v-bind="{tempValue: tempDate}"/>
|
|
311
|
+
</DatePickerCalendar>
|
|
312
|
+
</DatePickerContent>
|
|
313
|
+
</DatePickerRoot>
|
|
314
|
+
</template>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { getLocalTimeZone } from "@internationalized/date"
|
|
3
|
+
|
|
4
|
+
import { getTimeZoneList } from "../../helpers/getTimeZoneList.js"
|
|
5
|
+
import LibInput from "../LibInput/LibInput.vue"
|
|
6
|
+
const timeZone = defineModel<string>({ default: getLocalTimeZone() })
|
|
7
|
+
const label = defineModel<string>("label", { default: "Time Zone" })
|
|
8
|
+
</script>
|
|
9
|
+
<template>
|
|
10
|
+
<LibInput
|
|
11
|
+
:restrict-to-suggestions="true"
|
|
12
|
+
:suggestions="getTimeZoneList()"
|
|
13
|
+
:suggestions-filter="(_, items) => items"
|
|
14
|
+
class="w-full"
|
|
15
|
+
type="text"
|
|
16
|
+
v-model="timeZone"
|
|
17
|
+
>
|
|
18
|
+
<template #label>
|
|
19
|
+
<slot>
|
|
20
|
+
<span class="text-sm">
|
|
21
|
+
{{ label }}
|
|
22
|
+
</span>
|
|
23
|
+
</slot>
|
|
24
|
+
</template>
|
|
25
|
+
</LibInput>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// todo move to helpers
|
|
2
|
+
import {
|
|
3
|
+
type CalendarDate,
|
|
4
|
+
fromDate,
|
|
5
|
+
getLocalTimeZone,
|
|
6
|
+
Time,
|
|
7
|
+
toCalendarDate,
|
|
8
|
+
toCalendarDateTime,
|
|
9
|
+
today,
|
|
10
|
+
toZoned,
|
|
11
|
+
ZonedDateTime } from "@internationalized/date"
|
|
12
|
+
|
|
13
|
+
import { createNoonUtcDate } from "../../helpers/createNoonUtcDate.js"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*
|
|
18
|
+
* Converts the input date to a @internationalized/date instance we can use internally.
|
|
19
|
+
*/
|
|
20
|
+
export function convertDateWithFallback(
|
|
21
|
+
date: Date | undefined,
|
|
22
|
+
{
|
|
23
|
+
fallbackDate,
|
|
24
|
+
timeZone = getLocalTimeZone(),
|
|
25
|
+
useTime
|
|
26
|
+
}: { fallbackDate: Date, timeZone: string, useTime: boolean }
|
|
27
|
+
): ZonedDateTime | CalendarDate {
|
|
28
|
+
const finalDate = fromDate(date ?? fallbackDate, timeZone)
|
|
29
|
+
return useTime ? finalDate : toCalendarDate(finalDate)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*
|
|
35
|
+
* Converts the internal temporary date values to js dates. If the value is a CalendarDate, the time is set to 12 noon and the timezone to UTC so that regardless of what timezone it's converted to, the date itself won't change and the time component can be safely discarded.
|
|
36
|
+
*/
|
|
37
|
+
export function toEmittableDate(date: ZonedDateTime | CalendarDate): Date {
|
|
38
|
+
return date instanceof ZonedDateTime
|
|
39
|
+
? date.toDate()
|
|
40
|
+
: toZoned(toCalendarDateTime(date, new Time(12, 0, 0)), "UTC").toDate()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*
|
|
47
|
+
* Gets the current date, if `withTime` is true, it will return a ZonedDateTime (with the time set to noon), otherwise it will return a CalendarDate (without the time).
|
|
48
|
+
*/
|
|
49
|
+
export function getNow(opts: { withTime: boolean }): ZonedDateTime | CalendarDate {
|
|
50
|
+
if (opts.withTime) {
|
|
51
|
+
return createNoonUtcDate(today(getLocalTimeZone()))
|
|
52
|
+
}
|
|
53
|
+
return today(getLocalTimeZone())
|
|
54
|
+
}
|
|
55
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { crop } from "@alanscodelog/utils/crop.js"
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
4
|
+
|
|
5
|
+
import LibDebug from "./LibDebug.vue"
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
8
|
+
import * as components from "../index.js"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof LibDebug> = {
|
|
12
|
+
component: LibDebug,
|
|
13
|
+
title: "Components/Debug",
|
|
14
|
+
args: {
|
|
15
|
+
value: { any: ["any", { value: "any" }]},
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default meta
|
|
20
|
+
type Story = StoryObj<typeof LibDebug>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export const Primary: Story = {
|
|
24
|
+
render: args => ({
|
|
25
|
+
components,
|
|
26
|
+
setup: () => ({ args }),
|
|
27
|
+
template: `
|
|
28
|
+
<lib-debug v-bind="args" />
|
|
29
|
+
`,
|
|
30
|
+
}),
|
|
31
|
+
}
|
|
32
|
+
export const WithCustomTab: Story = {
|
|
33
|
+
...Primary,
|
|
34
|
+
args: {
|
|
35
|
+
...Primary.args,
|
|
36
|
+
value: { any: ["any", { value: "any" }]},
|
|
37
|
+
tab: 2,
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
export const NoValue: Story = {
|
|
41
|
+
...Primary,
|
|
42
|
+
args: {
|
|
43
|
+
...Primary.args,
|
|
44
|
+
value: undefined,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
export const StringWithWhitespace: Story = {
|
|
48
|
+
...Primary,
|
|
49
|
+
args: {
|
|
50
|
+
...Primary.args,
|
|
51
|
+
value: crop`
|
|
52
|
+
Manually
|
|
53
|
+
Indented
|
|
54
|
+
String
|
|
55
|
+
`,
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="lib-debug
|
|
3
|
+
text-fg
|
|
4
|
+
dark:text-bg
|
|
5
|
+
flex
|
|
6
|
+
flex-col
|
|
7
|
+
rounded-sm
|
|
8
|
+
border
|
|
9
|
+
border-danger-500
|
|
10
|
+
p-2
|
|
11
|
+
overflow-auto
|
|
12
|
+
"
|
|
13
|
+
>
|
|
14
|
+
<div class="flex justify-between">
|
|
15
|
+
<span class="font-bold">{{ title }}</span>
|
|
16
|
+
<LibButton class="w-min-content" @click="copy()">
|
|
17
|
+
<icon><i-fa6-regular-copy/></icon>
|
|
18
|
+
</LibButton>
|
|
19
|
+
</div>
|
|
20
|
+
<pre v-if="value"
|
|
21
|
+
:class="`
|
|
22
|
+
[tab-size:${tab}]
|
|
23
|
+
`
|
|
24
|
+
"
|
|
25
|
+
>{{ getStringValue(value) }}</pre>
|
|
26
|
+
<pre v-if="value === undefined"><slot/></pre>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { type PropType, useSlots } from "vue"
|
|
33
|
+
|
|
34
|
+
import Icon from "../Icon/Icon.vue"
|
|
35
|
+
import LibButton from "../LibButton/LibButton.vue"
|
|
36
|
+
|
|
37
|
+
const $slots = useSlots()
|
|
38
|
+
|
|
39
|
+
const props = withDefaults(defineProps<{
|
|
40
|
+
/** The value to debug, can be anything. */
|
|
41
|
+
// eslint-disable-next-line vue/no-restricted-props
|
|
42
|
+
value?: any
|
|
43
|
+
/** Sets the tab size in css. Defaults to 3. */
|
|
44
|
+
tab?: number
|
|
45
|
+
title?: string
|
|
46
|
+
}>(), {
|
|
47
|
+
tab: 3,
|
|
48
|
+
title: "Debug",
|
|
49
|
+
value: undefined,
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const getStringValue = (value: any): string => value === undefined
|
|
53
|
+
? "undefined"
|
|
54
|
+
: typeof value === "string"
|
|
55
|
+
? value
|
|
56
|
+
: JSON.stringify(value, null, "\t")
|
|
57
|
+
|
|
58
|
+
const findText = (children: any[]): string => {
|
|
59
|
+
let res = ""
|
|
60
|
+
for (const child of children) {
|
|
61
|
+
if (child.children) {
|
|
62
|
+
if (typeof child.children === "string") res += child.children as string
|
|
63
|
+
else res += findText(child.children)
|
|
64
|
+
} else {
|
|
65
|
+
res += "\n"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return res
|
|
69
|
+
}
|
|
70
|
+
const copy = (): void => {
|
|
71
|
+
if (navigator.clipboard) {
|
|
72
|
+
const text = props.value ? getStringValue(props.value) : findText([...$slots.default!()![0].children as any[]])
|
|
73
|
+
navigator.clipboard.writeText(text).catch(() => { })
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<script lang="ts">
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Simple debug component for displaying objects and strings with whitespace.
|
|
82
|
+
*
|
|
83
|
+
* In the case of objects, it JSON.stringifies them with a tab character. The tab width can be controlled with the `tab` prop, which will set the `tab-size` css property on the element.
|
|
84
|
+
*
|
|
85
|
+
* The value can be undefined, it will just display undefined.
|
|
86
|
+
*/
|
|
87
|
+
export default {
|
|
88
|
+
name: "lib-debug",
|
|
89
|
+
// https://v3.vuejs.org/guide/typescript-support.html#annotating-props
|
|
90
|
+
}
|
|
91
|
+
</script>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DevOnly>
|
|
3
|
+
<slot v-if="doShow && $attrs?.['as-child'] !== undefined"/>
|
|
4
|
+
<div v-else-if="doShow"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
:class="twMerge(`
|
|
8
|
+
border
|
|
9
|
+
border-dashed
|
|
10
|
+
border-red-500
|
|
11
|
+
px-2
|
|
12
|
+
py-1
|
|
13
|
+
never-packaged
|
|
14
|
+
`,
|
|
15
|
+
($attrs.class as string)
|
|
16
|
+
)"
|
|
17
|
+
v-bind="{...$attrs, class: undefined}"
|
|
18
|
+
>
|
|
19
|
+
<slot/>
|
|
20
|
+
</div>
|
|
21
|
+
</DevOnly>
|
|
22
|
+
</template>
|
|
23
|
+
<script lang="ts" setup>
|
|
24
|
+
import { computed, inject, ref, useAttrs } from "vue"
|
|
25
|
+
|
|
26
|
+
import { showDevOnlyInjectionKey } from "../../composables/useShowDevOnlyKey.js"
|
|
27
|
+
import { twMerge } from "../../utils/twMerge.js"
|
|
28
|
+
const $attrs = useAttrs()
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<{
|
|
31
|
+
show?: boolean
|
|
32
|
+
}>(), {
|
|
33
|
+
show: false
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const injectedShow = inject(showDevOnlyInjectionKey, ref(false))
|
|
37
|
+
const doShow = computed(() => props.show || injectedShow.value)
|
|
38
|
+
|
|
39
|
+
</script>
|
|
40
|
+
<script lang="ts">
|
|
41
|
+
interface Props {
|
|
42
|
+
show?: boolean
|
|
43
|
+
asChild?: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Not sure why nuxt's types aren't correctly getting detected
|
|
47
|
+
// This should be enough to bypass the type lint error.
|
|
48
|
+
declare module "vue" {
|
|
49
|
+
export interface GlobalComponents {
|
|
50
|
+
DevOnly: any
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/vue3"
|
|
3
|
+
import { ref } from "vue"
|
|
4
|
+
|
|
5
|
+
import LibFileInput from "./LibFileInput.vue"
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
8
|
+
import * as components from "../index.js"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof LibFileInput> = {
|
|
12
|
+
component: LibFileInput,
|
|
13
|
+
title: "Components/FileInput",
|
|
14
|
+
args: {
|
|
15
|
+
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default meta
|
|
20
|
+
type Story = StoryObj<typeof LibFileInput>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export const SingleFile: Story = {
|
|
24
|
+
render: args => ({
|
|
25
|
+
components,
|
|
26
|
+
setup: () => {
|
|
27
|
+
function errorHandler(e: any): void {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.log(e)
|
|
30
|
+
}
|
|
31
|
+
return { args, errorHandler }
|
|
32
|
+
},
|
|
33
|
+
template: `
|
|
34
|
+
<lib-file-input v-bind="{...args}" @errors="errorHandler"></lib-file-input>
|
|
35
|
+
`,
|
|
36
|
+
}),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const MultipleFile: Story = {
|
|
40
|
+
...SingleFile,
|
|
41
|
+
args: {
|
|
42
|
+
...SingleFile.args,
|
|
43
|
+
multiple: true,
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const AnyFormat: Story = {
|
|
48
|
+
...SingleFile,
|
|
49
|
+
args: {
|
|
50
|
+
...SingleFile.args,
|
|
51
|
+
multiple: true,
|
|
52
|
+
formats: [],
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const Compact: Story = {
|
|
57
|
+
...SingleFile,
|
|
58
|
+
args: {
|
|
59
|
+
...SingleFile.args,
|
|
60
|
+
compact: true,
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const ErrorHandling: Story = {
|
|
65
|
+
render: args => ({
|
|
66
|
+
components,
|
|
67
|
+
setup: () => {
|
|
68
|
+
const errors = ref([])
|
|
69
|
+
const errorHandler = (e: any) => errors.value = e
|
|
70
|
+
return {
|
|
71
|
+
args, errors, errorHandler,
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
template: `
|
|
75
|
+
<lib-debug :title="'Errors'">{{errors}}</lib-debug>
|
|
76
|
+
<lib-file-input v-bind="{...args}" @errors="errorHandler"></lib-file-input>
|
|
77
|
+
`,
|
|
78
|
+
}),
|
|
79
|
+
}
|