@witchcraft/ui 0.0.1 → 0.1.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 +18 -28
- package/dist/module.d.mts +3 -1
- package/dist/module.json +3 -3
- package/dist/module.mjs +21 -12
- package/dist/runtime/assets/base.css +1 -1
- package/dist/runtime/assets/locales/en.json +2 -2
- package/dist/runtime/assets/tailwind.css +1 -1
- package/dist/runtime/assets/utils.css +1 -0
- package/dist/runtime/build/WitchcraftUiResolver.js +1 -1
- package/dist/runtime/components/Aria/Aria.vue +5 -9
- package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
- package/dist/runtime/components/Icon/Icon.vue +12 -28
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +93 -117
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +53 -76
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +131 -101
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +326 -296
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +18 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +17 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.d.ts +2 -0
- package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.js +8 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.d.ts +1 -0
- package/dist/runtime/components/LibColorPicker/utils/truncate.js +5 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +42 -64
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +20 -54
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +205 -173
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +215 -164
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +9 -10
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +47 -65
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +19 -34
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +155 -173
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +352 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +50 -66
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -56
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +71 -83
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +86 -131
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +23 -26
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +326 -400
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +73 -93
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +134 -179
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +75 -89
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +51 -82
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +147 -164
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +69 -106
- package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
- package/dist/runtime/components/Template/NAME.vue +15 -36
- package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
- package/dist/runtime/components/TestControls/TestControls.vue +7 -10
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/components/index.d.ts +12 -11
- package/dist/runtime/components/index.js +12 -11
- package/dist/runtime/components/shared/props.d.ts +81 -16
- package/dist/runtime/components/shared/storyHelpers/playInput.js +5 -5
- package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +15 -11
- package/dist/runtime/composables/index.d.ts +5 -0
- package/dist/runtime/composables/index.js +5 -0
- package/dist/runtime/composables/useDivideAttrs.js +1 -0
- package/dist/runtime/composables/useDragWithThreshold.d.ts +71 -0
- package/dist/runtime/composables/useDragWithThreshold.js +40 -0
- package/dist/runtime/composables/usePreHydrationValue.d.ts +12 -0
- package/dist/runtime/composables/usePreHydrationValue.js +15 -0
- package/dist/runtime/composables/useSetupI18n.d.ts +2 -0
- package/dist/runtime/composables/useSetupI18n.js +5 -1
- package/dist/runtime/composables/useSuggestions.d.ts +7 -5
- package/dist/runtime/composables/useSuggestions.js +94 -57
- package/dist/runtime/directives/vResizableCols.js +92 -84
- package/dist/runtime/helpers/NotificationHandler.d.ts +5 -0
- package/dist/runtime/helpers/index.d.ts +3 -1
- package/dist/runtime/helpers/index.js +3 -1
- package/dist/runtime/types/index.d.ts +6 -0
- package/dist/runtime/utils/notifyIfError.d.ts +14 -0
- package/dist/runtime/utils/notifyIfError.js +29 -0
- package/dist/types.d.mts +2 -6
- package/package.json +27 -29
- package/src/module.ts +31 -12
- package/src/runtime/assets/base.css +10 -1
- package/src/runtime/assets/locales/en.json +2 -2
- package/src/runtime/assets/tailwind.css +1 -1
- package/src/runtime/assets/{style.css → utils.css} +86 -4
- package/src/runtime/build/WitchcraftUiResolver.ts +1 -1
- package/src/runtime/components/Focus.stories.ts +3 -2
- package/src/runtime/components/Icon/Icon.vue +10 -6
- package/src/runtime/components/LibButton/LibButton.vue +41 -47
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +7 -4
- package/src/runtime/components/LibColorInput/LibColorInput.vue +111 -37
- package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +25 -4
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +24 -0
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +23 -0
- package/src/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.ts +13 -0
- package/src/runtime/components/LibColorPicker/utils/truncate.ts +6 -0
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +1 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
- package/src/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
- package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
- package/src/runtime/components/LibDebug/LibDebug.vue +15 -5
- package/src/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
- package/src/runtime/components/LibFileInput/LibFileInput.vue +54 -29
- package/src/runtime/components/{LibInput/LibInput.stories.ts → LibInputDeprecated/LibInputDeprecated.stories.ts} +64 -19
- package/{dist/runtime/components/LibInput/LibInput.vue → src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -34
- package/src/runtime/components/LibLabel/LibLabel.vue +2 -2
- package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +5 -4
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +11 -13
- package/src/runtime/components/LibNotifications/LibNotification.vue +19 -11
- package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +2 -2
- package/src/runtime/components/LibNotifications/LibNotifications.vue +20 -12
- package/src/runtime/components/LibPagination/LibPagination.stories.ts +2 -2
- package/src/runtime/components/LibPagination/LibPagination.vue +19 -20
- package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
- package/src/runtime/components/LibPopup/LibPopup.stories.ts +2 -2
- package/src/runtime/components/LibPopup/LibPopup.vue +30 -67
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +3 -2
- package/src/runtime/components/LibRecorder/LibRecorder.vue +2 -3
- package/src/runtime/components/LibRoot/LibRoot.vue +14 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +1 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -8
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +42 -26
- package/src/runtime/components/LibTable/LibTable.vue +8 -9
- package/src/runtime/components/Scrolling.stories.ts +58 -0
- package/src/runtime/components/Template/NAME.vue +1 -1
- package/src/runtime/components/TestControls/TestControls.vue +1 -1
- package/src/runtime/components/index.ts +12 -12
- package/src/runtime/components/shared/props.ts +82 -19
- package/src/runtime/components/shared/storyHelpers/playInput.ts +6 -5
- package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +25 -11
- package/src/runtime/composables/index.ts +5 -0
- package/src/runtime/composables/useDarkMode.ts +2 -2
- package/src/runtime/composables/useDivideAttrs.ts +1 -0
- package/src/runtime/composables/useDragWithThreshold.ts +108 -0
- package/src/runtime/composables/usePreHydrationValue.ts +30 -0
- package/src/runtime/composables/useSetupI18n.ts +8 -2
- package/src/runtime/composables/useSuggestions.ts +92 -45
- package/src/runtime/directives/vResizableCols.ts +82 -74
- package/src/runtime/helpers/NotificationHandler.ts +5 -0
- package/src/runtime/helpers/index.ts +3 -1
- package/src/runtime/types/index.ts +5 -0
- package/src/runtime/utils/notifyIfError.ts +45 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -34
- package/dist/runtime/assets/style.css +0 -1
- package/dist/runtime/components/Focus.stories.d.ts +0 -11
- package/dist/runtime/components/Focus.stories.js +0 -53
- package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
- package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
- package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
- package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -7
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -51
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
- package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
- package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
- package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
- package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
- package/dist/runtime/components/LibInput/LibInput.stories.d.ts +0 -33
- package/dist/runtime/components/LibInput/LibInput.stories.js +0 -339
- package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
- package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
- package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -60
- package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
- package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
- package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
- package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
- package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
- package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
- package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
- package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
- package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
- package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
- package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
- package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
- package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
- package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
- package/dist/runtime/components/reset.stories.d.ts +0 -5
- package/dist/runtime/components/reset.stories.js +0 -19
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/runtime/helpers/addValue.d.ts +0 -1
- package/dist/runtime/helpers/addValue.js +0 -8
- package/dist/types.d.ts +0 -7
- package/src/runtime/components/LibInput/LibInput.vue +0 -372
- package/src/runtime/helpers/addValue.ts +0 -10
- /package/src/runtime/components/{reset.stories.ts → Reset.stories.ts} +0 -0
|
@@ -2,38 +2,41 @@
|
|
|
2
2
|
<lib-button
|
|
3
3
|
v-bind="{...$attrs, class:undefined}"
|
|
4
4
|
:class="!($attrs as any).unstyle && twMerge(`
|
|
5
|
+
dark-mode-switcher
|
|
5
6
|
rounded-full
|
|
6
7
|
after:rounded-full
|
|
7
8
|
`,
|
|
8
9
|
($attrs as any)?.class
|
|
9
10
|
)"
|
|
10
11
|
:title="`${t('dark-mode-switcher.title')}${t(`dark-mode-switcher.${darkModeState}`)}`"
|
|
11
|
-
:label="showLabel
|
|
12
|
-
? t(`dark-mode-switcher.${darkModeState}`)
|
|
13
|
-
: ''
|
|
14
|
-
"
|
|
15
12
|
@click="cycleDarkMode"
|
|
16
13
|
>
|
|
14
|
+
<!-- content-vertical-holder will keep the icon the height of a text line regardless of the svg used -->
|
|
17
15
|
<template #icon>
|
|
18
16
|
<icon
|
|
19
17
|
v-if="darkModeState==='dark'"
|
|
20
|
-
class="w-[1em] flex items-center"
|
|
18
|
+
class="w-[1em] flex items-center content-vertical-holder"
|
|
21
19
|
>
|
|
22
20
|
<i-fa-solid-moon/>
|
|
23
21
|
</icon>
|
|
24
22
|
<icon
|
|
25
23
|
v-else-if="darkModeState==='light'"
|
|
26
|
-
class="w-[1em]"
|
|
24
|
+
class="w-[1em] content-vertical-holder"
|
|
27
25
|
>
|
|
28
26
|
<i-ph-sun-bold/>
|
|
29
27
|
</icon>
|
|
30
28
|
<icon
|
|
31
29
|
v-else
|
|
32
|
-
class="w-[1em]"
|
|
30
|
+
class="w-[1em] content-vertical-holder"
|
|
33
31
|
>
|
|
34
32
|
<i-fa6-solid-circle-half-stroke/>
|
|
35
33
|
</icon>
|
|
36
34
|
</template>
|
|
35
|
+
<template #default v-if="showLabel">
|
|
36
|
+
<div class="dark-mode-switcher--label pr-[2px]">
|
|
37
|
+
{{ t(`dark-mode-switcher.${darkModeState}`) }}
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
37
40
|
</lib-button>
|
|
38
41
|
</template>
|
|
39
42
|
<script lang="ts" setup>
|
|
@@ -56,8 +59,7 @@ const emit = defineEmits<{
|
|
|
56
59
|
}>()
|
|
57
60
|
const $attrs = useAttrs()
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
withDefaults(defineProps<Props>(), { })
|
|
62
|
+
withDefaults(defineProps<Props>(), { showLabel: true })
|
|
61
63
|
|
|
62
64
|
|
|
63
65
|
const {
|
|
@@ -38,30 +38,17 @@ const isRange = computed(() => date.value !== undefined && !(date.value instance
|
|
|
38
38
|
</script>
|
|
39
39
|
|
|
40
40
|
<template>
|
|
41
|
-
<
|
|
42
|
-
v-if="!isRange"
|
|
43
|
-
v-bind="attrs"
|
|
44
|
-
:id="id ?? fallbackId"
|
|
45
|
-
:use-time="showTime"
|
|
46
|
-
:time-zone="timeZone"
|
|
47
|
-
:fallback-date="fallbackDate"
|
|
48
|
-
v-model="date as SingleDate"
|
|
49
|
-
>
|
|
50
|
-
<template #default="slotProps">
|
|
51
|
-
<slot v-bind="slotProps"/>
|
|
52
|
-
</template>
|
|
53
|
-
</LibSingleDatePicker>
|
|
54
|
-
<LibRangeDatePicker
|
|
55
|
-
v-else
|
|
41
|
+
<component
|
|
56
42
|
:id="id ?? fallbackId"
|
|
57
43
|
v-bind="attrs"
|
|
58
44
|
:use-time="showTime"
|
|
59
45
|
:time-zone="timeZone"
|
|
60
46
|
:fallback-date="fallbackDate"
|
|
61
|
-
|
|
47
|
+
:is="isRange ? LibRangeDatePicker : LibSingleDatePicker"
|
|
48
|
+
v-model="date as any"
|
|
62
49
|
>
|
|
63
50
|
<template #default="slotProps">
|
|
64
51
|
<slot v-bind="slotProps"/>
|
|
65
52
|
</template>
|
|
66
|
-
</
|
|
53
|
+
</component>
|
|
67
54
|
</template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { type DateValue, getLocalTimeZone } from "@internationalized/date"
|
|
3
|
-
import type { DateRange } from "
|
|
4
|
-
import { DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell,DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger } from "
|
|
2
|
+
import { CalendarDate, type DateValue, getLocalTimeZone, ZonedDateTime } from "@internationalized/date"
|
|
3
|
+
import type { DateRange } from "reka-ui"
|
|
4
|
+
import { DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell,DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger } from "reka-ui"
|
|
5
5
|
import { onBeforeUnmount, ref, toRaw, useAttrs, watch } from "vue"
|
|
6
6
|
|
|
7
7
|
import { convertDateWithFallback, getNow,toEmittableDate } from "./helpers.js"
|
|
@@ -28,26 +28,48 @@ const props = withDefaults(defineProps<{
|
|
|
28
28
|
const date = defineModel<RangeDate>({ required: true })
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
let justSet = false
|
|
32
|
+
|
|
33
|
+
const tempDate = ref<{
|
|
34
|
+
start?: CalendarDate | ZonedDateTime
|
|
35
|
+
end?: CalendarDate | ZonedDateTime
|
|
36
|
+
}>({})
|
|
37
|
+
function updateTempDate(keys: ("start" | "end")[] = ["start", "end"]) {
|
|
38
|
+
const newValue = { ...tempDate.value }
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
newValue[key] = convertDateWithFallback(date.value?.[key], props)
|
|
41
|
+
}
|
|
42
|
+
// the WHOLE object must be updated due to how the reka date picker works
|
|
43
|
+
tempDate.value = newValue
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// to avoid too deep of a watch
|
|
47
|
+
watch([() => date.value.start, () => date.value.end], () => {
|
|
48
|
+
if (!justSet) {
|
|
49
|
+
updateTempDate()
|
|
50
|
+
} else {
|
|
51
|
+
justSet = false
|
|
52
|
+
}
|
|
34
53
|
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
|
|
55
|
+
watch(tempDate, () => {
|
|
56
|
+
if (!tempDate.value.start || !tempDate.value.end) return
|
|
57
|
+
justSet = true
|
|
58
|
+
date.value = {
|
|
59
|
+
start: tempDate.value.start ? toEmittableDate(toRaw(tempDate.value.start) as any) : undefined,
|
|
60
|
+
end: tempDate.value.end ? toEmittableDate(toRaw(tempDate.value.end) as any) : undefined
|
|
39
61
|
}
|
|
40
62
|
})
|
|
41
63
|
|
|
64
|
+
watch(() => props.timeZone, () => {
|
|
65
|
+
updateTempDate()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
|
|
42
69
|
const interval = setInterval(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
if (!date.value.end) {
|
|
48
|
-
// update suggested date if none is set
|
|
49
|
-
tempDate.value.end = convertDateWithFallback(date.value.end, props)
|
|
50
|
-
}
|
|
70
|
+
// update suggested date if none is set
|
|
71
|
+
if (!date.value.start) updateTempDate(["start"])
|
|
72
|
+
if (!date.value.end) updateTempDate(["end"])
|
|
51
73
|
}, props.updateInterval)
|
|
52
74
|
|
|
53
75
|
onBeforeUnmount(() => {
|
|
@@ -56,25 +78,20 @@ onBeforeUnmount(() => {
|
|
|
56
78
|
|
|
57
79
|
const locale = useInjectedLocale().timeLocale
|
|
58
80
|
|
|
59
|
-
|
|
60
|
-
date.value = {
|
|
61
|
-
start: tempDate.value.start ? toEmittableDate(toRaw(tempDate.value.start) as any) : undefined,
|
|
62
|
-
end: tempDate.value.end ? toEmittableDate(toRaw(tempDate.value.end) as any) : undefined
|
|
63
|
-
}
|
|
64
|
-
})
|
|
81
|
+
|
|
65
82
|
</script>
|
|
66
83
|
|
|
67
84
|
<template>
|
|
68
85
|
<DateRangePickerRoot
|
|
69
86
|
:id="id"
|
|
70
87
|
:locale="locale"
|
|
71
|
-
class="root"
|
|
88
|
+
class="date-range-picker--root"
|
|
72
89
|
v-model="tempDate as DateRange"
|
|
73
90
|
>
|
|
74
91
|
<DateRangePickerField
|
|
75
92
|
v-slot="{ segments }"
|
|
76
93
|
:class="twMerge(`
|
|
77
|
-
|
|
94
|
+
date-range-picker--field
|
|
78
95
|
flex items-center justify-between
|
|
79
96
|
select-none
|
|
80
97
|
data-[invalid]:border-red-500
|
|
@@ -82,8 +99,13 @@ watch(tempDate, () => {
|
|
|
82
99
|
rounded-sm
|
|
83
100
|
`, (attrs as any).class)"
|
|
84
101
|
>
|
|
85
|
-
<div class="segments flex items-center flex-1 overflow-scroll scrollbar-hidden whitespace-nowrap">
|
|
86
|
-
<div :class="twMerge(`
|
|
102
|
+
<div class="date-range-picker--segments-input flex items-center flex-1 overflow-scroll scrollbar-hidden whitespace-nowrap">
|
|
103
|
+
<div :class="twMerge(`
|
|
104
|
+
date-range-picker--start-segment
|
|
105
|
+
flex
|
|
106
|
+
items-center
|
|
107
|
+
`, date.start === undefined && 'text-neutral-400')"
|
|
108
|
+
>
|
|
87
109
|
<template
|
|
88
110
|
v-for="item in segments.start"
|
|
89
111
|
:key="item.part"
|
|
@@ -92,7 +114,7 @@ watch(tempDate, () => {
|
|
|
92
114
|
v-if="item.part === 'literal'"
|
|
93
115
|
:part="item.part"
|
|
94
116
|
type="start"
|
|
95
|
-
class="
|
|
117
|
+
class="date-range-picker--segment-literal"
|
|
96
118
|
>
|
|
97
119
|
{{ item.value }}
|
|
98
120
|
</DateRangePickerInput>
|
|
@@ -101,7 +123,7 @@ watch(tempDate, () => {
|
|
|
101
123
|
type="start"
|
|
102
124
|
:part="item.part"
|
|
103
125
|
class="
|
|
104
|
-
input
|
|
126
|
+
date-range-picker--segment-input
|
|
105
127
|
focus-outline-hidden
|
|
106
128
|
border
|
|
107
129
|
border-transparent
|
|
@@ -110,6 +132,7 @@ watch(tempDate, () => {
|
|
|
110
132
|
>
|
|
111
133
|
<div
|
|
112
134
|
class="
|
|
135
|
+
date-range-picker--segment-value
|
|
113
136
|
group-focus:z-[2]
|
|
114
137
|
group-focus:bg-accent-500/50
|
|
115
138
|
group-focus:rounded-xs
|
|
@@ -121,10 +144,15 @@ watch(tempDate, () => {
|
|
|
121
144
|
</DateRangePickerInput>
|
|
122
145
|
</template>
|
|
123
146
|
</div>
|
|
124
|
-
<div class="range-separator text-center px-1">
|
|
147
|
+
<div class="date-range-picker--range-separator text-center px-1">
|
|
125
148
|
–
|
|
126
149
|
</div>
|
|
127
|
-
<div :class="twMerge(`
|
|
150
|
+
<div :class="twMerge(`
|
|
151
|
+
date-range-picker--end-segment
|
|
152
|
+
flex
|
|
153
|
+
items-center
|
|
154
|
+
`, date.end === undefined && 'text-neutral-400')"
|
|
155
|
+
>
|
|
128
156
|
<template
|
|
129
157
|
v-for="item in segments.end"
|
|
130
158
|
:key="item.part"
|
|
@@ -133,7 +161,7 @@ watch(tempDate, () => {
|
|
|
133
161
|
v-if="item.part === 'literal'"
|
|
134
162
|
:part="item.part"
|
|
135
163
|
type="end"
|
|
136
|
-
class="
|
|
164
|
+
class="date-range-picker--segment-literal"
|
|
137
165
|
>
|
|
138
166
|
{{ item.value }}
|
|
139
167
|
</DateRangePickerInput>
|
|
@@ -142,7 +170,7 @@ watch(tempDate, () => {
|
|
|
142
170
|
type="end"
|
|
143
171
|
:part="item.part"
|
|
144
172
|
class="
|
|
145
|
-
input
|
|
173
|
+
date-range-picker--segment-input
|
|
146
174
|
focus-outline-hidden
|
|
147
175
|
border
|
|
148
176
|
border-transparent
|
|
@@ -151,6 +179,7 @@ watch(tempDate, () => {
|
|
|
151
179
|
>
|
|
152
180
|
<div
|
|
153
181
|
class="
|
|
182
|
+
date-range-picker--segment-value
|
|
154
183
|
group-focus:z-[2]
|
|
155
184
|
group-focus:bg-accent-500/50
|
|
156
185
|
group-focus:rounded-xs
|
|
@@ -165,7 +194,7 @@ watch(tempDate, () => {
|
|
|
165
194
|
</div>
|
|
166
195
|
<DateRangePickerTrigger
|
|
167
196
|
class="
|
|
168
|
-
trigger
|
|
197
|
+
date-range-picker--trigger
|
|
169
198
|
px-1
|
|
170
199
|
focus-outline
|
|
171
200
|
rounded-tr-sm
|
|
@@ -183,45 +212,52 @@ watch(tempDate, () => {
|
|
|
183
212
|
</DateRangePickerTrigger>
|
|
184
213
|
</DateRangePickerField>
|
|
185
214
|
|
|
186
|
-
<!--
|
|
215
|
+
<!-- side=bottom makes months easier to click through -->
|
|
216
|
+
<!-- @vue-expect-error to exists-->
|
|
187
217
|
<DateRangePickerContent
|
|
188
218
|
:side-offset="4"
|
|
219
|
+
:avoid-collisions="true"
|
|
220
|
+
:prioritize-position="true"
|
|
221
|
+
side="bottom"
|
|
189
222
|
to="#root"
|
|
190
223
|
class="
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
224
|
+
date-range-picker--content
|
|
225
|
+
z-100
|
|
226
|
+
mx-2
|
|
227
|
+
rounded-sm
|
|
228
|
+
bg-bg
|
|
229
|
+
dark:bg-neutral-800
|
|
230
|
+
border
|
|
231
|
+
border-neutral-300
|
|
232
|
+
dark:border-neutral-700
|
|
233
|
+
shadow-lg
|
|
234
|
+
will-change-[transform,opacity]
|
|
235
|
+
data-[state=open]:data-[side=top]:animate-slideDownAndFade
|
|
236
|
+
data-[state=open]:data-[side=right]:animate-slideLeftAndFade
|
|
237
|
+
data-[state=open]:data-[side=bottom]:animate-slideUpAndFade
|
|
238
|
+
data-[state=open]:data-[side=left]:animate-slideRightAndFade
|
|
239
|
+
text-fg
|
|
240
|
+
dark:text-neutral-200
|
|
241
|
+
"
|
|
207
242
|
>
|
|
208
|
-
<DateRangePickerArrow class="fill-neutral-500"/>
|
|
243
|
+
<DateRangePickerArrow class="date-range-picker--arrow fill-neutral-500"/>
|
|
209
244
|
<DateRangePickerCalendar
|
|
210
245
|
v-slot="{ weekDays, grid }"
|
|
211
|
-
class="p-2 flex flex-col"
|
|
246
|
+
class="date-range-picker--calendar p-2 flex flex-col"
|
|
212
247
|
>
|
|
213
|
-
<DateRangePickerHeader class="flex items-center justify-between">
|
|
248
|
+
<DateRangePickerHeader class="date-range-picker--header flex items-center justify-between">
|
|
214
249
|
<DateRangePickerPrev
|
|
215
250
|
class="
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
251
|
+
date-range-picker--year-prev
|
|
252
|
+
inline-flex
|
|
253
|
+
items-center
|
|
254
|
+
cursor-pointer
|
|
255
|
+
active:scale-125
|
|
256
|
+
justify-center
|
|
257
|
+
rounded-sm
|
|
258
|
+
outlined
|
|
259
|
+
px-1
|
|
260
|
+
"
|
|
225
261
|
:prev-page="(date: DateValue) => date.subtract({ years: 1 })"
|
|
226
262
|
>
|
|
227
263
|
<Icon class="scale-150">
|
|
@@ -230,6 +266,7 @@ watch(tempDate, () => {
|
|
|
230
266
|
</DateRangePickerPrev>
|
|
231
267
|
<DateRangePickerPrev
|
|
232
268
|
class="
|
|
269
|
+
date-range-picker--prev
|
|
233
270
|
inline-flex
|
|
234
271
|
items-center
|
|
235
272
|
cursor-pointer
|
|
@@ -245,18 +282,19 @@ watch(tempDate, () => {
|
|
|
245
282
|
</Icon>
|
|
246
283
|
</DateRangePickerPrev>
|
|
247
284
|
|
|
248
|
-
<DateRangePickerHeading class="min-w-[14ch] text-center"/>
|
|
285
|
+
<DateRangePickerHeading class="date-range-picker--heading min-w-[14ch] text-center"/>
|
|
249
286
|
<DateRangePickerNext
|
|
250
287
|
class="
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
288
|
+
date-range-picker--next
|
|
289
|
+
inline-flex
|
|
290
|
+
items-center
|
|
291
|
+
cursor-pointer
|
|
292
|
+
active:scale-125
|
|
293
|
+
justify-center
|
|
294
|
+
rounded-sm
|
|
295
|
+
outlined
|
|
296
|
+
px-1
|
|
297
|
+
"
|
|
260
298
|
>
|
|
261
299
|
<Icon class="scale-150">
|
|
262
300
|
<i-radix-icons-chevron-right/>
|
|
@@ -264,15 +302,16 @@ watch(tempDate, () => {
|
|
|
264
302
|
</DateRangePickerNext>
|
|
265
303
|
<DateRangePickerNext
|
|
266
304
|
class="
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
305
|
+
date-range-picker--year-next
|
|
306
|
+
inline-flex
|
|
307
|
+
items-center
|
|
308
|
+
cursor-pointer
|
|
309
|
+
active:scale-125
|
|
310
|
+
justify-center
|
|
311
|
+
rounded-sm
|
|
312
|
+
outlined
|
|
313
|
+
px-1
|
|
314
|
+
"
|
|
276
315
|
:next-page="(date: DateValue) => date.add({ years: 1 })"
|
|
277
316
|
>
|
|
278
317
|
<Icon class="scale-150">
|
|
@@ -282,25 +321,37 @@ watch(tempDate, () => {
|
|
|
282
321
|
</DateRangePickerHeader>
|
|
283
322
|
<div
|
|
284
323
|
class="
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
324
|
+
date-range-picker--grid-wrapper
|
|
325
|
+
flex
|
|
326
|
+
flex-col
|
|
327
|
+
pt-4
|
|
328
|
+
"
|
|
289
329
|
>
|
|
290
330
|
<DateRangePickerGrid
|
|
291
|
-
class="
|
|
331
|
+
class="
|
|
332
|
+
date-range-picker--grid
|
|
333
|
+
border-collapse
|
|
334
|
+
select-none
|
|
335
|
+
"
|
|
292
336
|
v-for="month in grid"
|
|
293
337
|
:key="month.value.toString()"
|
|
294
338
|
>
|
|
295
|
-
<DateRangePickerGridHead>
|
|
296
|
-
<DateRangePickerGridRow class="
|
|
339
|
+
<DateRangePickerGridHead class="date-range-picker--grid-head">
|
|
340
|
+
<DateRangePickerGridRow class="
|
|
341
|
+
date-range-picker--grid-row
|
|
342
|
+
mb-1
|
|
343
|
+
flex
|
|
344
|
+
justify-between
|
|
345
|
+
"
|
|
346
|
+
>
|
|
297
347
|
<DateRangePickerHeadCell
|
|
298
348
|
class="
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
349
|
+
date-range-picker--head-cell
|
|
350
|
+
w-6
|
|
351
|
+
rounded-md
|
|
352
|
+
text-xs
|
|
353
|
+
text-accent-500
|
|
354
|
+
"
|
|
304
355
|
v-for="day in weekDays"
|
|
305
356
|
:key="day"
|
|
306
357
|
>
|
|
@@ -308,14 +359,21 @@ watch(tempDate, () => {
|
|
|
308
359
|
</DateRangePickerHeadCell>
|
|
309
360
|
</DateRangePickerGridRow>
|
|
310
361
|
</DateRangePickerGridHead>
|
|
311
|
-
<DateRangePickerGridBody>
|
|
362
|
+
<DateRangePickerGridBody class="date-range-picker--grid-body">
|
|
312
363
|
<DateRangePickerGridRow
|
|
313
|
-
class="
|
|
364
|
+
class="
|
|
365
|
+
date-range-picker--grid-row
|
|
366
|
+
flex
|
|
367
|
+
w-full
|
|
368
|
+
justify-between
|
|
369
|
+
my-1
|
|
370
|
+
"
|
|
314
371
|
v-for="(weekDates, index) in month.rows"
|
|
315
372
|
:key="`weekDate-${index}`"
|
|
316
373
|
>
|
|
317
374
|
<DateRangePickerCell
|
|
318
375
|
:date="weekDate"
|
|
376
|
+
class="date-range-picker--cell"
|
|
319
377
|
v-for="weekDate in weekDates"
|
|
320
378
|
:key="weekDate.toString()"
|
|
321
379
|
>
|
|
@@ -323,39 +381,43 @@ watch(tempDate, () => {
|
|
|
323
381
|
:day="weekDate"
|
|
324
382
|
:month="month.value"
|
|
325
383
|
class="
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
384
|
+
date-range-picker--cell-trigger
|
|
385
|
+
relative
|
|
386
|
+
flex
|
|
387
|
+
items-center
|
|
388
|
+
justify-center
|
|
389
|
+
whitespace-nowrap
|
|
390
|
+
rounded-sm
|
|
391
|
+
border
|
|
392
|
+
border-transparent
|
|
393
|
+
bg-transparent
|
|
394
|
+
text-sm
|
|
395
|
+
w-6
|
|
396
|
+
h-6
|
|
397
|
+
focus:shadow
|
|
398
|
+
focus-outline
|
|
399
|
+
hover:border-accent-500
|
|
400
|
+
data-[selected]:bg-accent-500
|
|
401
|
+
dark:data-[selected]:bg-accent-500/80
|
|
402
|
+
data-[selected]:shadow
|
|
403
|
+
data-[disabled]:text-neutral-500
|
|
404
|
+
data-[selected]:text-white
|
|
405
|
+
data-[unavailable]:pointer-events-none
|
|
406
|
+
data-[unavailable]:text-neutral-500
|
|
407
|
+
data-[unavailable]:line-through
|
|
408
|
+
data-[outside-view]:text-neutral-500
|
|
409
|
+
before:absolute
|
|
410
|
+
before:bottom-[1px]
|
|
411
|
+
before:hidden
|
|
412
|
+
before:rounded-full
|
|
413
|
+
before:w-4
|
|
414
|
+
before:h-[2px]
|
|
415
|
+
before:bg-white
|
|
416
|
+
data-[today]:before:block
|
|
417
|
+
data-[today]:before:bg-accent-700
|
|
418
|
+
dark:data-[today]:before:bg-accent-300
|
|
419
|
+
data-[selected]:before:bg-white
|
|
420
|
+
"
|
|
359
421
|
/>
|
|
360
422
|
</DateRangePickerCell>
|
|
361
423
|
</DateRangePickerGridRow>
|
|
@@ -363,7 +425,6 @@ watch(tempDate, () => {
|
|
|
363
425
|
</DateRangePickerGrid>
|
|
364
426
|
</div>
|
|
365
427
|
<slot v-bind="{tempValue: tempDate}"/>
|
|
366
|
-
<slot/>
|
|
367
428
|
</DateRangePickerCalendar>
|
|
368
429
|
</DateRangePickerContent>
|
|
369
430
|
</DateRangePickerRoot>
|