mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 22:39:14 +01:00
* feat: migrate tools page and label generator to shadcn * chore: lint issues * feat: also do profile page * feat: shadcn 404 page * feat: login page shadcn * fix: daisyui ironically breaks the z height for the login page * feat: componentise the language selector and add it to the login page * feat: use nuxtlink * feat: card and table made more shadcn * feat: shadcn statscard * chore: lint * feat: shadcn labelchip and locationcard * feat: shadcn locations page * refactor: remove unused new item page * chore: lint * feat: shadcn item card * fix: wrapping of location and lint * feat: ctrl enter in text area in form submits form * feat: begin shadcn locations page and remove pageqrcode comp in favour of integrating it into labelmaker * chore: lint + remove unused code * fix: remove uneeded margin * feat: shadcn labels page and fix some issues with location * feat: shadcn scanner * chore: lint * feat: begin shadcning item pages * feat: shadcn maintenance page * feat: begin shadcn search page * fix: quick switch blurry text and crashing page when switching + incorrect z height for create menu * feat: finish shadcn search page * chore: lint * feat: shadcn edit item page * fix: quickmenumodal bug * feat: shadcn item details page * feat: remove all non-color related daisyui classes * fix: type error * fix: quick menu modal again :(
92 lines
2.3 KiB
Vue
92 lines
2.3 KiB
Vue
<template>
|
|
<div v-if="!inline" class="flex w-full flex-col">
|
|
<Label class="cursor-pointer"> {{ label }} </Label>
|
|
<VueDatePicker v-model="selected" :enable-time-picker="false" clearable :dark="isDark" :format="formatDate" />
|
|
</div>
|
|
<div v-else class="sm:flex sm:items-start sm:gap-4">
|
|
<Label class="flex w-full cursor-pointer px-1 py-2"> {{ label }} </Label>
|
|
<VueDatePicker v-model="selected" :enable-time-picker="false" clearable :dark="isDark" :format="formatDate" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
// @ts-ignore
|
|
import VueDatePicker from "@vuepic/vue-datepicker";
|
|
import "@vuepic/vue-datepicker/dist/main.css";
|
|
import * as datelib from "~/lib/datelib/datelib";
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
const emit = defineEmits(["update:modelValue", "update:text"]);
|
|
|
|
const props = defineProps({
|
|
modelValue: {
|
|
type: Date as () => Date | string | null,
|
|
required: false,
|
|
default: null,
|
|
},
|
|
inline: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
label: {
|
|
type: String,
|
|
default: "Date",
|
|
},
|
|
});
|
|
|
|
const isDark = useIsDark();
|
|
|
|
const formatDate = (date: Date | string | number) => fmtDate(date, "human", "date");
|
|
|
|
const selected = computed<Date | null>({
|
|
get() {
|
|
// String
|
|
if (typeof props.modelValue === "string") {
|
|
// Empty string
|
|
if (props.modelValue === "") {
|
|
return null;
|
|
}
|
|
|
|
// Invalid Date string
|
|
if (props.modelValue === "Invalid Date") {
|
|
return null;
|
|
}
|
|
|
|
return datelib.parse(props.modelValue);
|
|
}
|
|
|
|
// Date
|
|
if (props.modelValue instanceof Date) {
|
|
if (props.modelValue.getFullYear() < 1000) {
|
|
return null;
|
|
}
|
|
|
|
if (isNaN(props.modelValue.getTime())) {
|
|
return null;
|
|
}
|
|
|
|
// Valid Date
|
|
return props.modelValue;
|
|
}
|
|
|
|
return null;
|
|
},
|
|
set(value: Date | null) {
|
|
console.debug("DatePicker: SET", value);
|
|
if (value instanceof Date) {
|
|
value = datelib.zeroTime(value);
|
|
emit("update:modelValue", value);
|
|
} else {
|
|
value = value ? datelib.zeroTime(new Date(value)) : null;
|
|
emit("update:modelValue", value);
|
|
}
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style class="scoped">
|
|
::-webkit-calendar-picker-indicator {
|
|
filter: invert(1);
|
|
}
|
|
</style>
|