@witchcraft/ui 0.1.0 → 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/dist/module.json +2 -2
- package/dist/module.mjs +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 +10 -31
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +58 -77
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +48 -75
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -108
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +271 -352
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +32 -57
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +17 -38
- package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +53 -82
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +50 -67
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +7 -8
- package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
- package/dist/runtime/components/LibDebug/LibDebug.vue +42 -70
- package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +18 -31
- package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
- package/dist/runtime/components/LibFileInput/LibFileInput.vue +113 -157
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +215 -242
- 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 +44 -59
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +32 -49
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -84
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +67 -112
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +20 -23
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +314 -352
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +70 -92
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +133 -178
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +73 -100
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +49 -78
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +123 -157
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +63 -100
- 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 +6 -9
- package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
- package/dist/runtime/directives/vResizableCols.js +89 -83
- package/dist/types.d.mts +2 -6
- package/package.json +11 -11
- package/src/runtime/components/Focus.stories.ts +3 -2
- package/src/runtime/components/Icon/Icon.vue +0 -1
- package/src/runtime/components/LibButton/LibButton.vue +0 -1
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -1
- package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -1
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +0 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +0 -1
- package/src/runtime/components/LibFileInput/LibFileInput.vue +0 -1
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -1
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -1
- package/src/runtime/components/LibNotifications/LibNotification.vue +0 -1
- package/src/runtime/components/LibNotifications/LibNotifications.vue +0 -1
- package/src/runtime/components/LibPagination/LibPagination.vue +0 -1
- package/src/runtime/components/LibPopup/LibPopup.vue +0 -1
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -1
- package/src/runtime/components/LibRecorder/LibRecorder.vue +0 -1
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +0 -1
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -1
- package/src/runtime/components/LibTable/LibTable.vue +0 -1
- package/src/runtime/directives/vResizableCols.ts +79 -73
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -36
- 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 -9
- package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -68
- 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/LibInputDeprecated/LibInputDeprecated.stories.d.ts +0 -33
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.js +0 -384
- 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 -61
- 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/components/Scrolling.stories.d.ts +0 -6
- package/dist/runtime/components/Scrolling.stories.js +0 -44
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
- package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
- package/dist/types.d.ts +0 -7
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { HsvaColor, RgbaColor } from "../../types/index.js.js";
|
|
2
|
+
import { type LabelProps, type LinkableByIdProps } from "../shared/props.js.js";
|
|
3
|
+
type __VLS_Props = LabelProps & LinkableByIdProps & {
|
|
4
|
+
allowAlpha?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The precision of the rgba string representation of the color. Defaults to 3. Extra trailing zeros are removed for a prettier number.
|
|
7
|
+
*
|
|
8
|
+
* Does not affect the number saved unless the user manually edits the color.
|
|
9
|
+
*
|
|
10
|
+
* Ignored if `customRepresentation` is set.
|
|
11
|
+
*/
|
|
12
|
+
stringPrecision?: number;
|
|
13
|
+
/** Allows overriding the string representation of the color. Useful for using a different representation than rgba (e.g. hex). The fromStringToHsva part is rarely needed as the colorjs.io library can normally parse the color. Returning undefined signals an error. */
|
|
14
|
+
customRepresentation?: {
|
|
15
|
+
fromHsvaToString: (hsva: HsvaColor, includeAlpha: boolean) => string;
|
|
16
|
+
fromStringToHsva?: (string: string) => HsvaColor | undefined;
|
|
17
|
+
};
|
|
18
|
+
border?: boolean;
|
|
19
|
+
/** Modify what the user copies to the clipboard. */
|
|
20
|
+
copyTransform?: (val: HsvaColor, stringVal: string) => any;
|
|
21
|
+
valid?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
24
|
+
modelValue?: RgbaColor;
|
|
25
|
+
"tempValue"?: RgbaColor | undefined;
|
|
26
|
+
};
|
|
27
|
+
declare var __VLS_1: {}, __VLS_27: {};
|
|
28
|
+
type __VLS_Slots = {} & {
|
|
29
|
+
input?: (props: typeof __VLS_1) => any;
|
|
30
|
+
} & {
|
|
31
|
+
buttons?: (props: typeof __VLS_27) => any;
|
|
32
|
+
};
|
|
33
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
34
|
+
"update:modelValue": (value: RgbaColor) => any;
|
|
35
|
+
"update:tempValue": (value: RgbaColor | undefined) => any;
|
|
36
|
+
} & {
|
|
37
|
+
cancel: () => any;
|
|
38
|
+
save: (val: RgbaColor) => any;
|
|
39
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
40
|
+
"onUpdate:modelValue"?: ((value: RgbaColor) => any) | undefined;
|
|
41
|
+
onCancel?: (() => any) | undefined;
|
|
42
|
+
onSave?: ((val: RgbaColor) => any) | undefined;
|
|
43
|
+
"onUpdate:tempValue"?: ((value: RgbaColor | undefined) => any) | undefined;
|
|
44
|
+
}>, {
|
|
45
|
+
border: boolean;
|
|
46
|
+
valid: boolean;
|
|
47
|
+
allowAlpha: boolean;
|
|
48
|
+
stringPrecision: number;
|
|
49
|
+
customRepresentation: {
|
|
50
|
+
fromHsvaToString: (hsva: HsvaColor, includeAlpha: boolean) => string;
|
|
51
|
+
fromStringToHsva?: (string: string) => HsvaColor | undefined;
|
|
52
|
+
};
|
|
53
|
+
copyTransform: (val: HsvaColor, stringVal: string) => any;
|
|
54
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
55
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
56
|
+
export default _default;
|
|
57
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
58
|
+
new (): {
|
|
59
|
+
$slots: S;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<lib-button
|
|
3
|
-
v-bind="{...$attrs, class:
|
|
4
|
-
:class="
|
|
3
|
+
v-bind="{ ...$attrs, class: void 0 }"
|
|
4
|
+
:class="!$attrs.unstyle && twMerge(
|
|
5
|
+
`
|
|
5
6
|
dark-mode-switcher
|
|
6
7
|
rounded-full
|
|
7
8
|
after:rounded-full
|
|
8
9
|
`,
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
$attrs?.class
|
|
11
|
+
)"
|
|
11
12
|
:title="`${t('dark-mode-switcher.title')}${t(`dark-mode-switcher.${darkModeState}`)}`"
|
|
12
13
|
@click="cycleDarkMode"
|
|
13
14
|
>
|
|
14
15
|
<!-- content-vertical-holder will keep the icon the height of a text line regardless of the svg used -->
|
|
15
16
|
<template #icon>
|
|
16
17
|
<icon
|
|
17
|
-
v-if="darkModeState==='dark'"
|
|
18
|
+
v-if="darkModeState === 'dark'"
|
|
18
19
|
class="w-[1em] flex items-center content-vertical-holder"
|
|
19
20
|
>
|
|
20
21
|
<i-fa-solid-moon/>
|
|
21
22
|
</icon>
|
|
22
23
|
<icon
|
|
23
|
-
v-else-if="darkModeState==='light'"
|
|
24
|
+
v-else-if="darkModeState === 'light'"
|
|
24
25
|
class="w-[1em] content-vertical-holder"
|
|
25
26
|
>
|
|
26
27
|
<i-ph-sun-bold/>
|
|
@@ -39,60 +40,34 @@
|
|
|
39
40
|
</template>
|
|
40
41
|
</lib-button>
|
|
41
42
|
</template>
|
|
42
|
-
<script lang="ts" setup>
|
|
43
|
-
import { type ButtonHTMLAttributes,onMounted,useAttrs, watch } from "vue"
|
|
44
|
-
|
|
45
|
-
import { useInjectedDarkMode } from "../../composables/useInjectedDarkMode.js"
|
|
46
|
-
import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
|
|
47
|
-
import { twMerge } from "../../utils/twMerge.js"
|
|
48
|
-
import Icon from "../Icon/Icon.vue"
|
|
49
|
-
import LibButton from "../LibButton/LibButton.vue"
|
|
50
|
-
import type { TailwindClassProp } from "../shared/props.js"
|
|
51
|
-
|
|
52
|
-
const t = useInjectedI18n()
|
|
53
|
-
|
|
54
|
-
const emit = defineEmits<{
|
|
55
|
-
/** Emits whether dark mode should be enabled. */
|
|
56
|
-
(e: "update:darkMode", value: boolean): void
|
|
57
|
-
/** Emits the change, but as a state string (dark, light, system) */
|
|
58
|
-
(e: "update:darkModeState", value: "dark" | "light" | "system"): void
|
|
59
|
-
}>()
|
|
60
|
-
const $attrs = useAttrs()
|
|
61
|
-
|
|
62
|
-
// eslint-disable-next-line no-use-before-define
|
|
63
|
-
withDefaults(defineProps<Props>(), { showLabel: true })
|
|
64
|
-
|
|
65
43
|
|
|
44
|
+
<script setup>
|
|
45
|
+
import { onMounted, useAttrs, watch } from "vue";
|
|
46
|
+
import { useInjectedDarkMode } from "../../composables/useInjectedDarkMode.js";
|
|
47
|
+
import { useInjectedI18n } from "../../composables/useInjectedI18n.js";
|
|
48
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
49
|
+
import Icon from "../Icon/Icon.vue";
|
|
50
|
+
import LibButton from "../LibButton/LibButton.vue";
|
|
51
|
+
const t = useInjectedI18n();
|
|
52
|
+
const emit = defineEmits(["update:darkMode", "update:darkModeState"]);
|
|
53
|
+
const $attrs = useAttrs();
|
|
54
|
+
defineProps({
|
|
55
|
+
showLabel: { type: Boolean, required: false, default: true }
|
|
56
|
+
});
|
|
66
57
|
const {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} = useInjectedDarkMode()
|
|
71
|
-
|
|
72
|
-
watch(
|
|
73
|
-
watch(darkModeState, value => emit("update:darkModeState", value))
|
|
74
|
-
|
|
58
|
+
darkMode,
|
|
59
|
+
cycleDarkMode,
|
|
60
|
+
darkModeState
|
|
61
|
+
} = useInjectedDarkMode();
|
|
62
|
+
watch(darkMode, (value) => emit("update:darkMode", value));
|
|
63
|
+
watch(darkModeState, (value) => emit("update:darkModeState", value));
|
|
75
64
|
onMounted(() => {
|
|
76
|
-
|
|
77
|
-
})
|
|
65
|
+
emit("update:darkMode", darkMode.value);
|
|
66
|
+
});
|
|
78
67
|
</script>
|
|
79
|
-
<script lang="ts">
|
|
80
|
-
export default {
|
|
81
|
-
name: "lib-dark-mode-switcher"
|
|
82
|
-
}
|
|
83
|
-
type RealProps = {
|
|
84
|
-
showLabel?: boolean
|
|
85
|
-
}
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
& TailwindClassProp
|
|
92
|
-
& {
|
|
93
|
-
disabled?: boolean
|
|
94
|
-
unstyle?: boolean
|
|
95
|
-
}>,
|
|
96
|
-
RealProps
|
|
97
|
-
{ }
|
|
69
|
+
<script>
|
|
70
|
+
export default {
|
|
71
|
+
name: "lib-dark-mode-switcher"
|
|
72
|
+
};
|
|
98
73
|
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes } from "vue";
|
|
2
|
+
import type { TailwindClassProp } from "../shared/props.js.js";
|
|
3
|
+
declare const _default: import("vue").DefineComponent<Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
+
"update:darkMode": (value: boolean) => any;
|
|
5
|
+
"update:darkModeState": (value: "system" | "dark" | "light") => any;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
7
|
+
"onUpdate:darkMode"?: ((value: boolean) => any) | undefined;
|
|
8
|
+
"onUpdate:darkModeState"?: ((value: "system" | "dark" | "light") => any) | undefined;
|
|
9
|
+
}>, {
|
|
10
|
+
showLabel: boolean;
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
export default _default;
|
|
13
|
+
type RealProps = {
|
|
14
|
+
showLabel?: boolean;
|
|
15
|
+
};
|
|
16
|
+
interface Props extends
|
|
17
|
+
/** @vue-ignore */
|
|
18
|
+
Partial<Omit<ButtonHTMLAttributes, "class" | "color" | "disabled"> & TailwindClassProp & {
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
unstyle?: boolean;
|
|
21
|
+
}>, RealProps {
|
|
22
|
+
}
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
<script setup
|
|
2
|
-
import { getLocalTimeZone } from "@internationalized/date"
|
|
3
|
-
import { computed, useAttrs } from "vue"
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
fallbackDate?: Date
|
|
18
|
-
/** The local user's timezone, defaults to @internationalized/date's getLocalTimeZone(). */
|
|
19
|
-
timeZone?: string
|
|
20
|
-
}>(), {
|
|
21
|
-
showTime: false,
|
|
22
|
-
id: undefined,
|
|
23
|
-
fallbackDate: () => new Date(),
|
|
24
|
-
timeZone: getLocalTimeZone()
|
|
25
|
-
})
|
|
26
|
-
const fallbackId = getFallbackId()
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* modelValue can be undefined or an object with start/end undefined, but it must be passed, otherwise we can't tell the difference between a single date and a range date.
|
|
30
|
-
*
|
|
31
|
-
* In the case of an undefined date, the current date at NOON UTC will be used to avoid the date changing.
|
|
32
|
-
*
|
|
33
|
-
* The @internationalized/date library's fromDate function is used internally to convert the date given (should be UTC) to the local time zone. It's converted back via it's toDate function.
|
|
34
|
-
*/
|
|
35
|
-
const date = defineModel<SingleDate | RangeDate>({ required: true })
|
|
36
|
-
const isRange = computed(() => date.value !== undefined && !(date.value instanceof Date))
|
|
37
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { getLocalTimeZone } from "@internationalized/date";
|
|
3
|
+
import { computed, useAttrs } from "vue";
|
|
4
|
+
import LibRangeDatePicker from "./LibRangeDatePicker.vue";
|
|
5
|
+
import LibSingleDatePicker from "./LibSingleDatePicker.vue";
|
|
6
|
+
import { getFallbackId } from "../shared/props.js";
|
|
7
|
+
const attrs = useAttrs();
|
|
8
|
+
defineProps({
|
|
9
|
+
showTime: { type: Boolean, required: false, default: false },
|
|
10
|
+
id: { type: String, required: false, default: void 0 },
|
|
11
|
+
fallbackDate: { type: Date, required: false, default: () => /* @__PURE__ */ new Date() },
|
|
12
|
+
timeZone: { type: String, required: false, default: getLocalTimeZone() }
|
|
13
|
+
});
|
|
14
|
+
const fallbackId = getFallbackId();
|
|
15
|
+
const date = defineModel({ type: null, ...{ required: true } });
|
|
16
|
+
const isRange = computed(() => date.value !== void 0 && !(date.value instanceof Date));
|
|
38
17
|
</script>
|
|
39
18
|
|
|
40
19
|
<template>
|
|
@@ -45,7 +24,7 @@ const isRange = computed(() => date.value !== undefined && !(date.value instance
|
|
|
45
24
|
:time-zone="timeZone"
|
|
46
25
|
:fallback-date="fallbackDate"
|
|
47
26
|
:is="isRange ? LibRangeDatePicker : LibSingleDatePicker"
|
|
48
|
-
v-model="date
|
|
27
|
+
v-model="date"
|
|
49
28
|
>
|
|
50
29
|
<template #default="slotProps">
|
|
51
30
|
<slot v-bind="slotProps"/>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RangeDate, SingleDate } from "../../types/index.js.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
showTime?: boolean;
|
|
4
|
+
id?: string;
|
|
5
|
+
/** The fallback suggested date when the modelValue is undefined (it will not update modelValue, it only serves as a suggestions and is used internally in the temporary value). If ignoring the time element, you should probably use the {@link createNoonTodayUtc} function (`createNonTodayUtc().toDate(())`) in the helpers, otherwise `new Date()` (the default) will do. */
|
|
6
|
+
fallbackDate?: Date;
|
|
7
|
+
/** The local user's timezone, defaults to @internationalized/date's getLocalTimeZone(). */
|
|
8
|
+
timeZone?: string;
|
|
9
|
+
};
|
|
10
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
11
|
+
/**
|
|
12
|
+
* modelValue can be undefined or an object with start/end undefined, but it must be passed, otherwise we can't tell the difference between a single date and a range date.
|
|
13
|
+
*
|
|
14
|
+
* In the case of an undefined date, the current date at NOON UTC will be used to avoid the date changing.
|
|
15
|
+
*
|
|
16
|
+
* The @internationalized/date library's fromDate function is used internally to convert the date given (should be UTC) to the local time zone. It's converted back via it's toDate function.
|
|
17
|
+
*/
|
|
18
|
+
modelValue: SingleDate | RangeDate;
|
|
19
|
+
};
|
|
20
|
+
declare var __VLS_8: any;
|
|
21
|
+
type __VLS_Slots = {} & {
|
|
22
|
+
default?: (props: typeof __VLS_8) => any;
|
|
23
|
+
};
|
|
24
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
|
+
"update:modelValue": (value: SingleDate | RangeDate) => any;
|
|
26
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
27
|
+
"onUpdate:modelValue"?: ((value: SingleDate | RangeDate) => any) | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
id: string;
|
|
30
|
+
fallbackDate: Date;
|
|
31
|
+
timeZone: string;
|
|
32
|
+
showTime: boolean;
|
|
33
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
35
|
+
export default _default;
|
|
36
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
37
|
+
new (): {
|
|
38
|
+
$slots: S;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -1,84 +1,55 @@
|
|
|
1
|
-
<script setup
|
|
2
|
-
import { CalendarDate,
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const date = defineModel<RangeDate>({ required: true })
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
1
|
+
<script setup>
|
|
2
|
+
import { CalendarDate, getLocalTimeZone, ZonedDateTime } from "@internationalized/date";
|
|
3
|
+
import { DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell, DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger } from "reka-ui";
|
|
4
|
+
import { onBeforeUnmount, ref, toRaw, useAttrs, watch } from "vue";
|
|
5
|
+
import { convertDateWithFallback, getNow, toEmittableDate } from "./helpers.js";
|
|
6
|
+
import { useInjectedLocale } from "../../composables/useInjectedLocale.js";
|
|
7
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
8
|
+
import Icon from "../Icon/Icon.vue";
|
|
9
|
+
const attrs = useAttrs();
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
useTime: { type: Boolean, required: false, default: false },
|
|
12
|
+
id: { type: String, required: true },
|
|
13
|
+
fallbackDate: { type: Date, required: false, default: (_) => getNow({ withTime: _.useTime ?? false }).toDate(_.timeZone ?? getLocalTimeZone()) },
|
|
14
|
+
timeZone: { type: String, required: false, default: getLocalTimeZone() },
|
|
15
|
+
updateInterval: { type: Number, required: false, default: 1e4 }
|
|
16
|
+
});
|
|
17
|
+
const date = defineModel({ type: Object, ...{ required: true } });
|
|
18
|
+
let justSet = false;
|
|
19
|
+
const tempDate = ref({});
|
|
20
|
+
function updateTempDate(keys = ["start", "end"]) {
|
|
21
|
+
const newValue = { ...tempDate.value };
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
newValue[key] = convertDateWithFallback(date.value?.[key], props);
|
|
24
|
+
}
|
|
25
|
+
tempDate.value = newValue;
|
|
44
26
|
}
|
|
45
|
-
|
|
46
|
-
// to avoid too deep of a watch
|
|
47
27
|
watch([() => date.value.start, () => date.value.end], () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
|
|
28
|
+
if (!justSet) {
|
|
29
|
+
updateTempDate();
|
|
30
|
+
} else {
|
|
31
|
+
justSet = false;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
55
34
|
watch(tempDate, () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
63
|
-
|
|
35
|
+
if (!tempDate.value.start || !tempDate.value.end) return;
|
|
36
|
+
justSet = true;
|
|
37
|
+
date.value = {
|
|
38
|
+
start: tempDate.value.start ? toEmittableDate(toRaw(tempDate.value.start)) : void 0,
|
|
39
|
+
end: tempDate.value.end ? toEmittableDate(toRaw(tempDate.value.end)) : void 0
|
|
40
|
+
};
|
|
41
|
+
});
|
|
64
42
|
watch(() => props.timeZone, () => {
|
|
65
|
-
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
updateTempDate();
|
|
44
|
+
});
|
|
69
45
|
const interval = setInterval(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, props.updateInterval)
|
|
74
|
-
|
|
46
|
+
if (!date.value.start) updateTempDate(["start"]);
|
|
47
|
+
if (!date.value.end) updateTempDate(["end"]);
|
|
48
|
+
}, props.updateInterval);
|
|
75
49
|
onBeforeUnmount(() => {
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const locale = useInjectedLocale().timeLocale
|
|
80
|
-
|
|
81
|
-
|
|
50
|
+
clearInterval(interval);
|
|
51
|
+
});
|
|
52
|
+
const locale = useInjectedLocale().timeLocale;
|
|
82
53
|
</script>
|
|
83
54
|
|
|
84
55
|
<template>
|
|
@@ -86,7 +57,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
86
57
|
:id="id"
|
|
87
58
|
:locale="locale"
|
|
88
59
|
class="date-range-picker--root"
|
|
89
|
-
v-model="tempDate
|
|
60
|
+
v-model="tempDate"
|
|
90
61
|
>
|
|
91
62
|
<DateRangePickerField
|
|
92
63
|
v-slot="{ segments }"
|
|
@@ -97,14 +68,14 @@ const locale = useInjectedLocale().timeLocale
|
|
|
97
68
|
data-[invalid]:border-red-500
|
|
98
69
|
metadata-input-border
|
|
99
70
|
rounded-sm
|
|
100
|
-
`,
|
|
71
|
+
`, attrs.class)"
|
|
101
72
|
>
|
|
102
73
|
<div class="date-range-picker--segments-input flex items-center flex-1 overflow-scroll scrollbar-hidden whitespace-nowrap">
|
|
103
74
|
<div :class="twMerge(`
|
|
104
75
|
date-range-picker--start-segment
|
|
105
76
|
flex
|
|
106
77
|
items-center
|
|
107
|
-
`, date.start ===
|
|
78
|
+
`, date.start === void 0 && 'text-neutral-400')"
|
|
108
79
|
>
|
|
109
80
|
<template
|
|
110
81
|
v-for="item in segments.start"
|
|
@@ -151,7 +122,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
151
122
|
date-range-picker--end-segment
|
|
152
123
|
flex
|
|
153
124
|
items-center
|
|
154
|
-
`, date.end ===
|
|
125
|
+
`, date.end === void 0 && 'text-neutral-400')"
|
|
155
126
|
>
|
|
156
127
|
<template
|
|
157
128
|
v-for="item in segments.end"
|
|
@@ -258,7 +229,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
258
229
|
outlined
|
|
259
230
|
px-1
|
|
260
231
|
"
|
|
261
|
-
:prev-page="(
|
|
232
|
+
:prev-page="(date2) => date2.subtract({ years: 1 })"
|
|
262
233
|
>
|
|
263
234
|
<Icon class="scale-150">
|
|
264
235
|
<i-radix-icons-double-arrow-left/>
|
|
@@ -312,7 +283,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
312
283
|
outlined
|
|
313
284
|
px-1
|
|
314
285
|
"
|
|
315
|
-
:next-page="(
|
|
286
|
+
:next-page="(date2) => date2.add({ years: 1 })"
|
|
316
287
|
>
|
|
317
288
|
<Icon class="scale-150">
|
|
318
289
|
<i-radix-icons-double-arrow-right/>
|
|
@@ -424,7 +395,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
424
395
|
</DateRangePickerGridBody>
|
|
425
396
|
</DateRangePickerGrid>
|
|
426
397
|
</div>
|
|
427
|
-
<slot v-bind="{tempValue: tempDate}"/>
|
|
398
|
+
<slot v-bind="{ tempValue: tempDate }"/>
|
|
428
399
|
</DateRangePickerCalendar>
|
|
429
400
|
</DateRangePickerContent>
|
|
430
401
|
</DateRangePickerRoot>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RangeDate } from "../../types/index.js.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
useTime?: boolean;
|
|
4
|
+
id: string;
|
|
5
|
+
fallbackDate?: Date;
|
|
6
|
+
timeZone?: string;
|
|
7
|
+
updateInterval?: number;
|
|
8
|
+
};
|
|
9
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
10
|
+
modelValue: RangeDate;
|
|
11
|
+
};
|
|
12
|
+
declare var __VLS_167: {
|
|
13
|
+
tempValue: any;
|
|
14
|
+
};
|
|
15
|
+
type __VLS_Slots = {} & {
|
|
16
|
+
default?: (props: typeof __VLS_167) => any;
|
|
17
|
+
};
|
|
18
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
19
|
+
"update:modelValue": (value: RangeDate) => any;
|
|
20
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
|
+
"onUpdate:modelValue"?: ((value: RangeDate) => any) | undefined;
|
|
22
|
+
}>, {
|
|
23
|
+
fallbackDate: Date;
|
|
24
|
+
timeZone: string;
|
|
25
|
+
useTime: boolean;
|
|
26
|
+
updateInterval: number;
|
|
27
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
29
|
+
export default _default;
|
|
30
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
31
|
+
new (): {
|
|
32
|
+
$slots: S;
|
|
33
|
+
};
|
|
34
|
+
};
|