ff-operation/src/components/admin/operation/mission/DetailFormInput.vue

88 lines
1.8 KiB
Vue
Raw Normal View History

2025-03-03 17:06:10 +01:00
<template>
<div :class="growing ? 'grow' : 'w-full'">
<div class="flex flex-row gap-2 items-center">
<label :for="title">{{ title }}</label>
2025-03-04 15:03:34 +01:00
<lottie-player
v-if="currentEditors.length != 0"
src="/typing_animation.json"
class="w-fit h-5"
loop
autoplay
v-tippy="currentEditors.map((c) => c.username).join(', ')"
/>
2025-03-03 17:06:10 +01:00
</div>
2025-03-04 15:03:34 +01:00
<input :type="type" :id="title" v-model="value" :min="min" @focus="focused" @blur="blured" />
2025-03-03 17:06:10 +01:00
</div>
</template>
<script setup lang="ts">
2025-03-04 15:03:34 +01:00
import { defineComponent, type PropType } from "vue";
2025-03-03 17:06:10 +01:00
import "@lottiefiles/lottie-player";
2025-03-04 15:03:34 +01:00
import type { Awareness } from "@/helpers/awareness";
2025-03-03 17:06:10 +01:00
</script>
<script lang="ts">
export default defineComponent({
props: {
modelValue: {
type: String,
default: "",
},
title: {
type: String,
default: "",
},
growing: {
type: Boolean,
default: false,
},
type: {
type: String,
default: "text",
},
min: {
type: String,
default: "",
},
2025-03-04 15:03:34 +01:00
awareness: {
type: Object as PropType<Awareness>,
required: true,
},
2025-03-03 17:06:10 +01:00
},
emits: ["update:model-value"],
2025-03-04 15:03:34 +01:00
data() {
return {
typing: false,
};
},
2025-03-03 17:06:10 +01:00
computed: {
value: {
get() {
return this.modelValue;
},
set(val: string) {
this.$emit("update:model-value", val);
},
},
2025-03-04 15:03:34 +01:00
currentEditors() {
return this.awareness.getEditorObjsByField(this.title);
},
},
mounted() {
this.awareness.emitter.on("change", (d) => {});
},
methods: {
focused() {
this.awareness.publishMyState({
field: this.title,
});
},
blured() {
this.awareness.publishMyState({
field: "blured user",
});
},
2025-03-03 17:06:10 +01:00
},
});
</script>