@fy-/fws-vue 0.3.47 → 0.3.49
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.
|
@@ -145,6 +145,7 @@ defineExpose({ focus, blur, getInputRef });
|
|
|
145
145
|
}"
|
|
146
146
|
v-model="model"
|
|
147
147
|
:autocomplete="autocomplete"
|
|
148
|
+
:placeholder="placeholder"
|
|
148
149
|
:disabled="disabled"
|
|
149
150
|
:aria-describedby="help ? `${id}-help` : id"
|
|
150
151
|
class="bg-fv-neutral-50 border border-fv-neutral-300 text-fv-neutral-900 text-sm rounded-lg focus:ring-fv-primary-500 focus:border-fv-primary-500 block w-full p-2.5 dark:bg-fv-neutral-700 dark:border-fv-neutral-600 dark:placeholder-fv-neutral-400 dark:text-white dark:focus:ring-fv-primary-500 dark:focus:border-fv-primary-500"
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
@keydown.delete.prevent="removeLastTag"
|
|
6
6
|
@keydown.enter.prevent="addTag"
|
|
7
7
|
>
|
|
8
|
-
<span v-for="(tag, index) in
|
|
8
|
+
<span v-for="(tag, index) in model" :key="index" :class="`tag ${color}`">
|
|
9
9
|
{{ tag }}
|
|
10
10
|
<button type="button" @click.prevent="removeTag(index)">
|
|
11
11
|
<svg
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
</template>
|
|
38
38
|
|
|
39
39
|
<script setup lang="ts">
|
|
40
|
-
import { ref,
|
|
40
|
+
import { ref, computed, onMounted } from "vue";
|
|
41
41
|
type colorType = "blue" | "red" | "green" | "purple" | "orange" | "neutral";
|
|
42
42
|
|
|
43
43
|
const props = withDefaults(
|
|
@@ -59,17 +59,15 @@ const props = withDefaults(
|
|
|
59
59
|
},
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
-
const emit = defineEmits(["update:modelValue"]);
|
|
63
|
-
const tags = ref([...props.modelValue]);
|
|
64
62
|
const textInput = ref<HTMLElement>();
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
(
|
|
69
|
-
|
|
64
|
+
const emit = defineEmits(["update:modelValue"]);
|
|
65
|
+
const model = computed({
|
|
66
|
+
get: () => props.modelValue,
|
|
67
|
+
set: (items) => {
|
|
68
|
+
emit("update:modelValue", items);
|
|
70
69
|
},
|
|
71
|
-
|
|
72
|
-
);
|
|
70
|
+
});
|
|
73
71
|
|
|
74
72
|
onMounted(() => {
|
|
75
73
|
if (props.autofocus) {
|
|
@@ -92,19 +90,19 @@ const addTag = () => {
|
|
|
92
90
|
.split(separatorsRegex)
|
|
93
91
|
.map((tag: string) => tag.trim())
|
|
94
92
|
.filter((tag: string) => tag.length > 0);
|
|
95
|
-
|
|
93
|
+
model.value.push(...newTags);
|
|
96
94
|
textInput.value.innerText = "";
|
|
97
95
|
};
|
|
98
96
|
|
|
99
97
|
const removeTag = (index: number) => {
|
|
100
|
-
|
|
98
|
+
model.value.splice(index, 1);
|
|
101
99
|
focusInput();
|
|
102
100
|
};
|
|
103
101
|
|
|
104
102
|
const removeLastTag = () => {
|
|
105
103
|
if (!textInput.value) return;
|
|
106
104
|
if (textInput.value.innerText === "") {
|
|
107
|
-
|
|
105
|
+
model.value.pop();
|
|
108
106
|
} else {
|
|
109
107
|
const currentLength = textInput.value.innerText.length;
|
|
110
108
|
textInput.value.innerText = textInput.value.innerText.slice(0, -1);
|