@fy-/fws-vue 1.2.8 → 1.3.0

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
- import DefaultTagInput from "./DefaultTagInput.vue";
6
+ //import DefaultTagInput from "./DefaultTagInput.vue";
7
7
 
8
8
  type modelValueType = string | number | string[] | number[] | undefined;
9
9
 
@@ -96,11 +96,16 @@ 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);
99
100
  onMounted(async () => {
100
101
  if (props.type === "datepicker") {
101
102
  const { default: VueDatePicker } = await import("@vuepic/vue-datepicker");
102
103
  dpComponent.value = VueDatePicker;
103
104
  }
105
+ if (props.type === "tags" || props.type === "chips") {
106
+ const { default: DefaultTagInput } = await import("./DefaultTagInput.vue");
107
+ dptagComponent.value = DefaultTagInput;
108
+ }
104
109
  });
105
110
  </script>
106
111
  <template>
@@ -210,7 +215,9 @@ onMounted(async () => {
210
215
  >{{ label ? label : placeholder }}
211
216
  </label>
212
217
  <!-- @vue-skip -->
213
- <DefaultTagInput
218
+ <component
219
+ :is="dptagComponent"
220
+ v-if="dptagComponent"
214
221
  v-model="model"
215
222
  :id="id"
216
223
  :disabled="disabled"
@@ -64,11 +64,11 @@ const removeTag = (index: number) => {
64
64
  };
65
65
 
66
66
  const removeLastTag = () => {
67
- if (!textInput.value) return;
68
- if (textInput.value.innerText === "") {
69
- model.value.pop();
70
- } else {
71
- try {
67
+ if (!import.meta.env.SSR) {
68
+ if (!textInput.value) return;
69
+ if (textInput.value.innerText === "") {
70
+ model.value.pop();
71
+ } else {
72
72
  const currentLength = textInput.value.innerText.length;
73
73
  textInput.value.innerText = textInput.value.innerText.slice(0, -1);
74
74
 
@@ -79,8 +79,6 @@ const removeLastTag = () => {
79
79
  if (!sel) return;
80
80
  sel.removeAllRanges();
81
81
  sel.addRange(range);
82
- } catch (e) {
83
- console.error(e);
84
82
  }
85
83
  }
86
84
  };
@@ -91,15 +89,17 @@ const focusInput = () => {
91
89
  };
92
90
 
93
91
  const handlePaste = (e: any) => {
94
- if (!textInput.value) return;
95
-
96
- // @ts-ignore
97
- const text = (e.clipboardData || window.clipboardData).getData("text");
98
- const separatorsRegex = new RegExp(props.separators.join("|"), "g");
99
- const pasteText = text.replace(separatorsRegex, ",");
100
- textInput.value.innerText += pasteText;
101
- e.preventDefault();
102
- addTag();
92
+ if (!import.meta.env.SSR) {
93
+ if (!textInput.value) return;
94
+
95
+ // @ts-ignore
96
+ const text = (e.clipboardData || window.clipboardData).getData("text");
97
+ const separatorsRegex = new RegExp(props.separators.join("|"), "g");
98
+ const pasteText = text.replace(separatorsRegex, ",");
99
+ textInput.value.innerText += pasteText;
100
+ e.preventDefault();
101
+ addTag();
102
+ }
103
103
  };
104
104
  </script>
105
105
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "repository": {