@fy-/fws-vue 1.3.0 → 1.3.2
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.
|
@@ -3,7 +3,7 @@ import { LinkIcon } from "@heroicons/vue/24/solid";
|
|
|
3
3
|
import { computed, onMounted, onUnmounted, ref, toRef } from "vue";
|
|
4
4
|
import type { ErrorObject } from "@vuelidate/core";
|
|
5
5
|
import { useTranslation } from "../../composables/translations";
|
|
6
|
-
|
|
6
|
+
import DefaultTagInput from "./DefaultTagInput.vue";
|
|
7
7
|
|
|
8
8
|
type modelValueType = string | number | string[] | number[] | undefined;
|
|
9
9
|
|
|
@@ -96,16 +96,11 @@ const modelCheckbox = computed({
|
|
|
96
96
|
});
|
|
97
97
|
defineExpose({ focus, blur, getInputRef });
|
|
98
98
|
const dpComponent = ref<any | null>(null);
|
|
99
|
-
const dptagComponent = ref<any | null>(null);
|
|
100
99
|
onMounted(async () => {
|
|
101
100
|
if (props.type === "datepicker") {
|
|
102
101
|
const { default: VueDatePicker } = await import("@vuepic/vue-datepicker");
|
|
103
102
|
dpComponent.value = VueDatePicker;
|
|
104
103
|
}
|
|
105
|
-
if (props.type === "tags" || props.type === "chips") {
|
|
106
|
-
const { default: DefaultTagInput } = await import("./DefaultTagInput.vue");
|
|
107
|
-
dptagComponent.value = DefaultTagInput;
|
|
108
|
-
}
|
|
109
104
|
});
|
|
110
105
|
</script>
|
|
111
106
|
<template>
|
|
@@ -215,9 +210,7 @@ onMounted(async () => {
|
|
|
215
210
|
>{{ label ? label : placeholder }}
|
|
216
211
|
</label>
|
|
217
212
|
<!-- @vue-skip -->
|
|
218
|
-
<
|
|
219
|
-
:is="dptagComponent"
|
|
220
|
-
v-if="dptagComponent"
|
|
213
|
+
<DefaultTagInput
|
|
221
214
|
v-model="model"
|
|
222
215
|
:id="id"
|
|
223
216
|
:disabled="disabled"
|
|
@@ -63,12 +63,13 @@ const removeTag = (index: number) => {
|
|
|
63
63
|
focusInput();
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/*
|
|
66
67
|
const removeLastTag = () => {
|
|
67
|
-
if (!
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
if (!textInput.value) return;
|
|
69
|
+
if (textInput.value.innerText === "") {
|
|
70
|
+
model.value.pop();
|
|
71
|
+
} else {
|
|
72
|
+
try {
|
|
72
73
|
const currentLength = textInput.value.innerText.length;
|
|
73
74
|
textInput.value.innerText = textInput.value.innerText.slice(0, -1);
|
|
74
75
|
|
|
@@ -79,9 +80,12 @@ const removeLastTag = () => {
|
|
|
79
80
|
if (!sel) return;
|
|
80
81
|
sel.removeAllRanges();
|
|
81
82
|
sel.addRange(range);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error(e);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
};
|
|
88
|
+
*/
|
|
85
89
|
const focusInput = () => {
|
|
86
90
|
if (!textInput.value) return;
|
|
87
91
|
|
|
@@ -89,17 +93,15 @@ const focusInput = () => {
|
|
|
89
93
|
};
|
|
90
94
|
|
|
91
95
|
const handlePaste = (e: any) => {
|
|
92
|
-
if (!
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
addTag();
|
|
102
|
-
}
|
|
96
|
+
if (!textInput.value) return;
|
|
97
|
+
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
const text = (e.clipboardData || window.clipboardData).getData("text");
|
|
100
|
+
const separatorsRegex = new RegExp(props.separators.join("|"), "g");
|
|
101
|
+
const pasteText = text.replace(separatorsRegex, ",");
|
|
102
|
+
textInput.value.innerText += pasteText;
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
addTag();
|
|
103
105
|
};
|
|
104
106
|
</script>
|
|
105
107
|
|
|
@@ -107,7 +109,6 @@ const handlePaste = (e: any) => {
|
|
|
107
109
|
<ClientOnly
|
|
108
110
|
:class="`tags-input ${$props.error ? 'error' : ''}`"
|
|
109
111
|
@click="focusInput"
|
|
110
|
-
@keydown.delete.prevent="removeLastTag"
|
|
111
112
|
@keydown.enter.prevent="addTag"
|
|
112
113
|
>
|
|
113
114
|
<span
|