forked from noxious/client
npm update, npm run format, cleaned and enhanced chipsInput JS
This commit is contained in:
parent
e714bd94b5
commit
a7bf51fa7e
14
package-lock.json
generated
14
package-lock.json
generated
@ -4836,9 +4836,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jsdom": {
|
"node_modules/jsdom": {
|
||||||
"version": "24.1.0",
|
"version": "24.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-24.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-24.1.1.tgz",
|
||||||
"integrity": "sha512-6gpM7pRXCwIOKxX47cgOyvyQDN/Eh0f1MeKySBV2xGdKtqJBLj8P25eY3EVCWo2mglDDzozR2r2MW4T+JiNUZA==",
|
"integrity": "sha512-5O1wWV99Jhq4DV7rCLIoZ/UIhyQeDR7wHVyZAHAshbrvZsLs+Xzz7gtwnlJTJDjleiTKh54F4dXrX70vJQTyJQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -4848,11 +4848,11 @@
|
|||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"html-encoding-sniffer": "^4.0.0",
|
"html-encoding-sniffer": "^4.0.0",
|
||||||
"http-proxy-agent": "^7.0.2",
|
"http-proxy-agent": "^7.0.2",
|
||||||
"https-proxy-agent": "^7.0.4",
|
"https-proxy-agent": "^7.0.5",
|
||||||
"is-potential-custom-element-name": "^1.0.1",
|
"is-potential-custom-element-name": "^1.0.1",
|
||||||
"nwsapi": "^2.2.10",
|
"nwsapi": "^2.2.12",
|
||||||
"parse5": "^7.1.2",
|
"parse5": "^7.1.2",
|
||||||
"rrweb-cssom": "^0.7.0",
|
"rrweb-cssom": "^0.7.1",
|
||||||
"saxes": "^6.0.0",
|
"saxes": "^6.0.0",
|
||||||
"symbol-tree": "^3.2.4",
|
"symbol-tree": "^3.2.4",
|
||||||
"tough-cookie": "^4.1.4",
|
"tough-cookie": "^4.1.4",
|
||||||
@ -4861,7 +4861,7 @@
|
|||||||
"whatwg-encoding": "^3.1.1",
|
"whatwg-encoding": "^3.1.1",
|
||||||
"whatwg-mimetype": "^4.0.0",
|
"whatwg-mimetype": "^4.0.0",
|
||||||
"whatwg-url": "^14.0.0",
|
"whatwg-url": "^14.0.0",
|
||||||
"ws": "^8.17.0",
|
"ws": "^8.18.0",
|
||||||
"xml-name-validator": "^5.0.0"
|
"xml-name-validator": "^5.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -2,54 +2,45 @@
|
|||||||
<div class="flex flex-wrap items-center input-cyan gap-1">
|
<div class="flex flex-wrap items-center input-cyan gap-1">
|
||||||
<div v-for="(chip, i) in modelValue" :key="i" class="flex gap-2.5 items-center bg-cyan rounded py-1 px-2">
|
<div v-for="(chip, i) in modelValue" :key="i" class="flex gap-2.5 items-center bg-cyan rounded py-1 px-2">
|
||||||
<span class="text-xs">{{ chip }}</span>
|
<span class="text-xs">{{ chip }}</span>
|
||||||
<i class="text-xs cursor-pointer text-white font-light font-default not-italic hover:text-gray-50" @click="deleteChip(i)">X</i>
|
<button type="button" class="text-xs cursor-pointer text-white font-light font-default not-italic hover:text-gray-50" @click="deleteChip(i)" aria-label="Remove chip">X</button>
|
||||||
</div>
|
</div>
|
||||||
<input class="outline-none border-none p-1" placeholder="Tag name" v-model="currentInput" @keypress.enter.prevent="saveChip" @keydown.delete="backspaceDelete" />
|
<input class="outline-none border-none p-1" placeholder="Tag name" v-model="currentInput" @keypress.enter.prevent="addChip" @keydown.backspace="handleBackspace" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
|
import type { Ref } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
interface Props {
|
||||||
modelValue: {
|
modelValue: string[]
|
||||||
type: Array,
|
}
|
||||||
default: () => []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
const currentInput = ref('')
|
const emit = defineEmits<{
|
||||||
const internalValue = ref(props.modelValue || [])
|
(e: 'update:modelValue', value: string[]): void
|
||||||
|
}>()
|
||||||
|
|
||||||
watch(
|
const currentInput: Ref<string> = ref('')
|
||||||
() => props.modelValue,
|
|
||||||
(newVal) => {
|
|
||||||
internalValue.value = newVal || []
|
|
||||||
},
|
|
||||||
{ immediate: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
const saveChip = (event) => {
|
const addChip = () => {
|
||||||
event.preventDefault()
|
if (currentInput.value.trim() && !props.modelValue.includes(currentInput.value)) {
|
||||||
|
emit('update:modelValue', [...props.modelValue, currentInput.value.trim()])
|
||||||
if (currentInput.value.trim() && !internalValue.value.includes(currentInput.value)) {
|
|
||||||
emit('update:modelValue', [...internalValue.value, currentInput.value])
|
|
||||||
currentInput.value = ''
|
currentInput.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteChip = (index) => {
|
const deleteChip = (index: number) => {
|
||||||
emit(
|
emit(
|
||||||
'update:modelValue',
|
'update:modelValue',
|
||||||
internalValue.value.filter((_, i) => i !== index)
|
props.modelValue.filter((_, i) => i !== index)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const backspaceDelete = (event) => {
|
const handleBackspace = (event: KeyboardEvent) => {
|
||||||
if (event.key === 'Backspace' && currentInput.value === '' && internalValue.value.length > 0) {
|
if (event.key === 'Backspace' && currentInput.value === '' && props.modelValue.length > 0) {
|
||||||
emit('update:modelValue', internalValue.value.slice(0, -1))
|
emit('update:modelValue', props.modelValue.slice(0, -1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Image
|
<Image :depth="2" texture="waypoint" :x="waypoint.x" :y="waypoint.y" :visible="waypoint.visible" />
|
||||||
:depth="2"
|
|
||||||
texture="waypoint"
|
|
||||||
:x="waypoint.x"
|
|
||||||
:y="waypoint.y"
|
|
||||||
:visible="waypoint.visible"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user