@witchcraft/ui 0.1.3 → 0.2.1-beta.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 +3 -6
- package/dist/module.json +3 -3
- package/dist/module.mjs +15 -12
- package/dist/runtime/build/generateTheme.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 +10 -30
- package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
- package/dist/runtime/components/LibButton/LibButton.vue +51 -72
- package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +43 -74
- package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
- package/dist/runtime/components/LibColorInput/LibColorInput.vue +63 -107
- package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +272 -352
- package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +1 -1
- package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +1 -1
- package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +35 -69
- 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 +58 -82
- package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
- package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +55 -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 +43 -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 +116 -156
- package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +211 -241
- package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
- package/dist/runtime/components/LibLabel/LibLabel.vue +25 -46
- package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +26 -0
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +43 -58
- package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
- package/dist/runtime/components/LibNotifications/LibNotification.vue +34 -48
- package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
- package/dist/runtime/components/LibNotifications/LibNotifications.vue +63 -83
- package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
- package/dist/runtime/components/LibPagination/LibPagination.vue +67 -111
- package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
- package/dist/runtime/components/LibPalette/LibPalette.vue +17 -23
- package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
- package/dist/runtime/components/LibPopup/LibPopup.vue +314 -351
- package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +65 -91
- package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
- package/dist/runtime/components/LibRecorder/LibRecorder.vue +127 -177
- package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
- package/dist/runtime/components/LibRoot/LibRoot.vue +75 -101
- package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +42 -77
- package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +118 -156
- package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
- package/dist/runtime/components/LibTable/LibTable.vue +63 -99
- 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/components/shared/props.d.ts +0 -29
- package/dist/runtime/components/shared/props.js +0 -12
- package/dist/runtime/composables/useAccesibilityOutline.js +1 -1
- package/dist/runtime/composables/useDivideAttrs.js +1 -1
- package/dist/runtime/composables/useSuggestions.js +4 -4
- package/dist/runtime/directives/vDetectFlex.js +4 -4
- package/dist/runtime/directives/vExtractRootEl.d.ts +1 -1
- package/dist/runtime/directives/vResizableCols.d.ts +1 -1
- package/dist/runtime/directives/vResizableCols.js +4 -4
- package/dist/runtime/helpers/NotificationHandler.js +6 -6
- package/dist/runtime/helpers/base64ToImg.js +2 -2
- package/dist/runtime/nuxt/plugins/vue-plugin.js +1 -1
- package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
- package/dist/runtime/theme.d.ts +1 -1
- package/dist/runtime/theme.js +1 -1
- package/dist/runtime/utils/notifyIfError.js +1 -1
- package/dist/runtime/vue/registerComponents.js +1 -1
- package/dist/types.d.mts +2 -6
- package/package.json +68 -90
- package/src/module.ts +19 -12
- package/src/runtime/build/generateTheme.ts +1 -1
- package/src/runtime/components/LibButton/LibButton.stories.ts +1 -1
- package/src/runtime/components/LibButton/LibButton.vue +3 -3
- package/src/runtime/components/LibCheckbox/LibCheckbox.vue +3 -7
- package/src/runtime/components/LibColorPicker/LibColorPicker.vue +6 -4
- package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -1
- package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -1
- package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +8 -15
- package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +6 -0
- package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +6 -0
- package/src/runtime/components/LibDebug/LibDebug.stories.ts +1 -1
- package/src/runtime/components/LibDebug/LibDebug.vue +2 -0
- package/src/runtime/components/LibFileInput/LibFileInput.vue +4 -0
- package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +7 -5
- package/src/runtime/components/LibLabel/LibLabel.vue +2 -3
- package/src/runtime/components/LibMultiValues/LibMultiValues.vue +5 -3
- package/src/runtime/components/LibNotifications/LibNotification.vue +3 -0
- package/src/runtime/components/LibNotifications/LibNotifications.vue +1 -1
- package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
- package/src/runtime/components/LibPopup/LibPopup.vue +2 -2
- package/src/runtime/components/LibProgressBar/LibProgressBar.vue +2 -2
- package/src/runtime/components/LibRecorder/LibRecorder.vue +3 -3
- package/src/runtime/components/LibRoot/LibRoot.vue +3 -2
- package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +2 -2
- package/src/runtime/components/LibSuggestions/LibSuggestions.vue +2 -2
- package/src/runtime/components/LibTable/LibTable.vue +1 -1
- package/src/runtime/components/Template/NAME.vue +2 -2
- package/src/runtime/components/shared/props.ts +8 -12
- package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
- package/src/runtime/composables/useDivideAttrs.ts +1 -1
- package/src/runtime/composables/useSuggestions.ts +4 -4
- package/src/runtime/directives/vDetectFlex.ts +4 -4
- package/src/runtime/directives/vExtractRootEl.ts +1 -1
- package/src/runtime/directives/vResizableCols.ts +5 -5
- package/src/runtime/helpers/NotificationHandler.ts +6 -6
- package/src/runtime/nuxt/plugins/vue-plugin.ts +1 -1
- package/src/runtime/tailwind/themeConvertionOpts.ts +1 -1
- package/src/runtime/theme.ts +2 -2
- package/src/runtime/utils/notifyIfError.ts +1 -1
- package/src/runtime/vue/registerComponents.ts +1 -1
- 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,35 +1,23 @@
|
|
|
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
|
-
|
|
18
|
-
class="w-[1em] flex items-center content-vertical-holder"
|
|
18
|
+
class="w-[1em] items-center content-vertical-holder"
|
|
19
19
|
>
|
|
20
|
-
<
|
|
21
|
-
</icon>
|
|
22
|
-
<icon
|
|
23
|
-
v-else-if="darkModeState==='light'"
|
|
24
|
-
class="w-[1em] content-vertical-holder"
|
|
25
|
-
>
|
|
26
|
-
<i-ph-sun-bold/>
|
|
27
|
-
</icon>
|
|
28
|
-
<icon
|
|
29
|
-
v-else
|
|
30
|
-
class="w-[1em] content-vertical-holder"
|
|
31
|
-
>
|
|
32
|
-
<i-fa6-solid-circle-half-stroke/>
|
|
20
|
+
<component :is="darkModeState === 'dark' ? IFaSolidMoon : darkModeState === 'light' ? IPhSunBold : IFa6SolidCircleHalfStroke"/>
|
|
33
21
|
</icon>
|
|
34
22
|
</template>
|
|
35
23
|
<template #default v-if="showLabel">
|
|
@@ -39,59 +27,37 @@
|
|
|
39
27
|
</template>
|
|
40
28
|
</lib-button>
|
|
41
29
|
</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
|
-
withDefaults(defineProps<Props>(), { showLabel: true })
|
|
63
|
-
|
|
64
30
|
|
|
31
|
+
<script setup>
|
|
32
|
+
import { onMounted, useAttrs, watch } from "vue";
|
|
33
|
+
import IFaSolidMoon from "~icons/fa-solid/moon";
|
|
34
|
+
import IFa6SolidCircleHalfStroke from "~icons/fa6-solid/circle-half-stroke";
|
|
35
|
+
import IPhSunBold from "~icons/ph/sun-bold";
|
|
36
|
+
import { useInjectedDarkMode } from "../../composables/useInjectedDarkMode.js";
|
|
37
|
+
import { useInjectedI18n } from "../../composables/useInjectedI18n.js";
|
|
38
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
39
|
+
import Icon from "../Icon/Icon.vue";
|
|
40
|
+
import LibButton from "../LibButton/LibButton.vue";
|
|
41
|
+
const t = useInjectedI18n();
|
|
42
|
+
const emit = defineEmits(["update:darkMode", "update:darkModeState"]);
|
|
43
|
+
const $attrs = useAttrs();
|
|
44
|
+
defineProps({
|
|
45
|
+
showLabel: { type: Boolean, required: false, default: true }
|
|
46
|
+
});
|
|
65
47
|
const {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
} = useInjectedDarkMode()
|
|
70
|
-
|
|
71
|
-
watch(
|
|
72
|
-
watch(darkModeState, value => emit("update:darkModeState", value))
|
|
73
|
-
|
|
48
|
+
darkMode,
|
|
49
|
+
cycleDarkMode,
|
|
50
|
+
darkModeState
|
|
51
|
+
} = useInjectedDarkMode();
|
|
52
|
+
watch(darkMode, (value) => emit("update:darkMode", value));
|
|
53
|
+
watch(darkModeState, (value) => emit("update:darkModeState", value));
|
|
74
54
|
onMounted(() => {
|
|
75
|
-
|
|
76
|
-
})
|
|
55
|
+
emit("update:darkMode", darkMode.value);
|
|
56
|
+
});
|
|
77
57
|
</script>
|
|
78
|
-
<script lang="ts">
|
|
79
|
-
export default {
|
|
80
|
-
name: "lib-dark-mode-switcher"
|
|
81
|
-
}
|
|
82
|
-
type RealProps = {
|
|
83
|
-
showLabel?: boolean
|
|
84
|
-
}
|
|
85
58
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
& TailwindClassProp
|
|
91
|
-
& {
|
|
92
|
-
disabled?: boolean
|
|
93
|
-
unstyle?: boolean
|
|
94
|
-
}>,
|
|
95
|
-
RealProps
|
|
96
|
-
{ }
|
|
59
|
+
<script>
|
|
60
|
+
export default {
|
|
61
|
+
name: "lib-dark-mode-switcher"
|
|
62
|
+
};
|
|
97
63
|
</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,60 @@
|
|
|
1
|
-
<script setup
|
|
2
|
-
import { CalendarDate,
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const props =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
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 IRadixIconsCalendar from "~icons/radix-icons/calendar";
|
|
7
|
+
import IRadixIconsChevronLeft from "~icons/radix-icons/chevron-left";
|
|
8
|
+
import IRadixIconsChevronRight from "~icons/radix-icons/chevron-right";
|
|
9
|
+
import IRadixIconsDoubleArrowLeft from "~icons/radix-icons/double-arrow-left";
|
|
10
|
+
import IRadixIconsDoubleArrowRight from "~icons/radix-icons/double-arrow-right";
|
|
11
|
+
import { useInjectedLocale } from "../../composables/useInjectedLocale.js";
|
|
12
|
+
import { twMerge } from "../../utils/twMerge.js";
|
|
13
|
+
import Icon from "../Icon/Icon.vue";
|
|
14
|
+
const attrs = useAttrs();
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
useTime: { type: Boolean, required: false, default: false },
|
|
17
|
+
id: { type: String, required: true },
|
|
18
|
+
fallbackDate: { type: Date, required: false, default: (_) => getNow({ withTime: _.useTime ?? false }).toDate(_.timeZone ?? getLocalTimeZone()) },
|
|
19
|
+
timeZone: { type: String, required: false, default: getLocalTimeZone() },
|
|
20
|
+
updateInterval: { type: Number, required: false, default: 1e4 }
|
|
21
|
+
});
|
|
22
|
+
const date = defineModel({ type: Object, ...{ required: true } });
|
|
23
|
+
let justSet = false;
|
|
24
|
+
const tempDate = ref({});
|
|
25
|
+
function updateTempDate(keys = ["start", "end"]) {
|
|
26
|
+
const newValue = { ...tempDate.value };
|
|
27
|
+
for (const key of keys) {
|
|
28
|
+
newValue[key] = convertDateWithFallback(date.value?.[key], props);
|
|
29
|
+
}
|
|
30
|
+
tempDate.value = newValue;
|
|
44
31
|
}
|
|
45
|
-
|
|
46
|
-
// to avoid too deep of a watch
|
|
47
32
|
watch([() => date.value.start, () => date.value.end], () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
|
|
33
|
+
if (!justSet) {
|
|
34
|
+
updateTempDate();
|
|
35
|
+
} else {
|
|
36
|
+
justSet = false;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
55
39
|
watch(tempDate, () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
63
|
-
|
|
40
|
+
if (!tempDate.value.start || !tempDate.value.end) return;
|
|
41
|
+
justSet = true;
|
|
42
|
+
date.value = {
|
|
43
|
+
start: tempDate.value.start ? toEmittableDate(toRaw(tempDate.value.start)) : void 0,
|
|
44
|
+
end: tempDate.value.end ? toEmittableDate(toRaw(tempDate.value.end)) : void 0
|
|
45
|
+
};
|
|
46
|
+
});
|
|
64
47
|
watch(() => props.timeZone, () => {
|
|
65
|
-
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
updateTempDate();
|
|
49
|
+
});
|
|
69
50
|
const interval = setInterval(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, props.updateInterval)
|
|
74
|
-
|
|
51
|
+
if (!date.value.start) updateTempDate(["start"]);
|
|
52
|
+
if (!date.value.end) updateTempDate(["end"]);
|
|
53
|
+
}, props.updateInterval);
|
|
75
54
|
onBeforeUnmount(() => {
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const locale = useInjectedLocale().timeLocale
|
|
80
|
-
|
|
81
|
-
|
|
55
|
+
clearInterval(interval);
|
|
56
|
+
});
|
|
57
|
+
const locale = useInjectedLocale().timeLocale;
|
|
82
58
|
</script>
|
|
83
59
|
|
|
84
60
|
<template>
|
|
@@ -86,7 +62,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
86
62
|
:id="id"
|
|
87
63
|
:locale="locale"
|
|
88
64
|
class="date-range-picker--root"
|
|
89
|
-
v-model="tempDate
|
|
65
|
+
v-model="tempDate"
|
|
90
66
|
>
|
|
91
67
|
<DateRangePickerField
|
|
92
68
|
v-slot="{ segments }"
|
|
@@ -97,14 +73,14 @@ const locale = useInjectedLocale().timeLocale
|
|
|
97
73
|
data-[invalid]:border-red-500
|
|
98
74
|
metadata-input-border
|
|
99
75
|
rounded-sm
|
|
100
|
-
`,
|
|
76
|
+
`, attrs.class)"
|
|
101
77
|
>
|
|
102
78
|
<div class="date-range-picker--segments-input flex items-center flex-1 overflow-scroll scrollbar-hidden whitespace-nowrap">
|
|
103
79
|
<div :class="twMerge(`
|
|
104
80
|
date-range-picker--start-segment
|
|
105
81
|
flex
|
|
106
82
|
items-center
|
|
107
|
-
`, date.start ===
|
|
83
|
+
`, date.start === void 0 && 'text-neutral-400')"
|
|
108
84
|
>
|
|
109
85
|
<template
|
|
110
86
|
v-for="item in segments.start"
|
|
@@ -151,7 +127,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
151
127
|
date-range-picker--end-segment
|
|
152
128
|
flex
|
|
153
129
|
items-center
|
|
154
|
-
`, date.end ===
|
|
130
|
+
`, date.end === void 0 && 'text-neutral-400')"
|
|
155
131
|
>
|
|
156
132
|
<template
|
|
157
133
|
v-for="item in segments.end"
|
|
@@ -258,7 +234,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
258
234
|
outlined
|
|
259
235
|
px-1
|
|
260
236
|
"
|
|
261
|
-
:prev-page="(
|
|
237
|
+
:prev-page="(date2) => date2.subtract({ years: 1 })"
|
|
262
238
|
>
|
|
263
239
|
<Icon class="scale-150">
|
|
264
240
|
<i-radix-icons-double-arrow-left/>
|
|
@@ -312,7 +288,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
312
288
|
outlined
|
|
313
289
|
px-1
|
|
314
290
|
"
|
|
315
|
-
:next-page="(
|
|
291
|
+
:next-page="(date2) => date2.add({ years: 1 })"
|
|
316
292
|
>
|
|
317
293
|
<Icon class="scale-150">
|
|
318
294
|
<i-radix-icons-double-arrow-right/>
|
|
@@ -424,7 +400,7 @@ const locale = useInjectedLocale().timeLocale
|
|
|
424
400
|
</DateRangePickerGridBody>
|
|
425
401
|
</DateRangePickerGrid>
|
|
426
402
|
</div>
|
|
427
|
-
<slot v-bind="{tempValue: tempDate}"/>
|
|
403
|
+
<slot v-bind="{ tempValue: tempDate }"/>
|
|
428
404
|
</DateRangePickerCalendar>
|
|
429
405
|
</DateRangePickerContent>
|
|
430
406
|
</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
|
+
};
|