mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 11:39:16 +01:00
chore: ⬆️ Upgrade to Nuxt 4
Some checks failed
Some checks failed
This commit is contained in:
parent
8debe97f63
commit
7f7cf20311
386 changed files with 2376 additions and 2332 deletions
32
app/components/ui/input/Input.vue
Normal file
32
app/components/ui/input/Input.vue
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<script setup lang="ts">
|
||||
import { useVModel } from "@vueuse/core";
|
||||
import type { HTMLAttributes } from "vue";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const props = defineProps<{
|
||||
defaultValue?: string | number;
|
||||
modelValue?: string | number;
|
||||
class?: HTMLAttributes["class"];
|
||||
}>();
|
||||
|
||||
const emits =
|
||||
defineEmits<(e: "update:modelValue", payload: string | number) => void>();
|
||||
|
||||
const modelValue = useVModel(props, "modelValue", emits, {
|
||||
passive: true,
|
||||
defaultValue: props.defaultValue,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input
|
||||
v-model="modelValue"
|
||||
data-slot="input"
|
||||
:class="cn(
|
||||
'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
|
||||
'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
|
||||
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
</template>
|
||||
2
app/components/ui/input/index.ts
Normal file
2
app/components/ui/input/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export { default as Input } from "./Input.vue";
|
||||
export { default as UrlInput } from "./url.vue";
|
||||
57
app/components/ui/input/url.vue
Normal file
57
app/components/ui/input/url.vue
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<script setup lang="ts">
|
||||
import { useVModel } from "@vueuse/core";
|
||||
import { Check, X } from "lucide-vue-next";
|
||||
import type { HTMLAttributes } from "vue";
|
||||
import * as m from "~~/paraglide/messages.js";
|
||||
import Input from "./Input.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
defaultValue?: string | number;
|
||||
modelValue?: string | number;
|
||||
class?: HTMLAttributes["class"];
|
||||
}>();
|
||||
|
||||
const emits =
|
||||
defineEmits<(e: "update:modelValue", payload: string | number) => void>();
|
||||
|
||||
const modelValue = useVModel(props, "modelValue", emits, {
|
||||
passive: true,
|
||||
defaultValue: props.defaultValue,
|
||||
});
|
||||
|
||||
const isValid = defineModel<boolean>("isValid");
|
||||
|
||||
const tryGuessUrl = (string: string) =>
|
||||
URL.canParse(`https://${string}`) &&
|
||||
string.includes(".") &&
|
||||
string.length > 3 &&
|
||||
string.charAt(string.length - 1) !== ".";
|
||||
|
||||
const isValidUrl = computed(
|
||||
() =>
|
||||
URL.canParse(modelValue.value as string) ||
|
||||
tryGuessUrl(modelValue.value as string),
|
||||
);
|
||||
|
||||
watch(modelValue, (value) => {
|
||||
if (!URL.canParse(value as string) && tryGuessUrl(value as string)) {
|
||||
modelValue.value = `https://${value}`;
|
||||
}
|
||||
});
|
||||
|
||||
watch(isValidUrl, (value) => {
|
||||
isValid.value = value;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-2">
|
||||
<Input v-model="modelValue" v-bind="$attrs" />
|
||||
<p v-if="isValidUrl" class="text-green-600 text-xs">
|
||||
{{ m.sunny_small_warbler_express() }}
|
||||
</p>
|
||||
<p v-else-if="(modelValue?.toString().length ?? 0) > 0" class="text-destructive text-xs">
|
||||
{{ m.teal_late_grebe_blend() }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue