@fy-/fws-vue 0.3.4 → 0.3.5

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"
@@ -71,12 +71,11 @@ onUnmounted(() => {
71
71
  v-if="title"
72
72
  >
73
73
  <slot name="before"></slot>
74
- <DialogTitle
74
+ <h2
75
75
  class="text-xl font-semibold text-fv-neutral-900 dark:text-white"
76
76
  v-if="title"
77
- >
78
- {{ title }}
79
- </DialogTitle>
77
+ v-html="title"
78
+ />
80
79
  <button
81
80
  @click="setModal(false)"
82
81
  class="text-fv-neutral-400 bg-transparent hover:bg-fv-neutral-200 hover:text-fv-neutral-900 rounded-lg text-sm w-8 h-8 ml-auto inline-flex justify-center items-center dark:hover:bg-fv-neutral-600 dark:hover:text-white"
@@ -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 tags" :key="index" :class="`tag ${color}`">
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, watch, onMounted } from "vue";
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
- watch(
67
- tags,
68
- (newTags) => {
69
- emit("update:modelValue", newTags);
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
- { deep: true },
72
- );
70
+ });
73
71
 
74
72
  onMounted(() => {
75
73
  if (props.autofocus) {
@@ -92,23 +90,32 @@ const addTag = () => {
92
90
  .split(separatorsRegex)
93
91
  .map((tag: string) => tag.trim())
94
92
  .filter((tag: string) => tag.length > 0);
95
- tags.value.push(...newTags);
93
+ model.value.push(...newTags);
96
94
  textInput.value.innerText = "";
97
95
  };
98
96
 
99
97
  const removeTag = (index: number) => {
100
- tags.value.splice(index, 1);
98
+ model.value.splice(index, 1);
101
99
  focusInput();
102
100
  };
103
101
 
104
102
  const removeLastTag = () => {
105
103
  if (!textInput.value) return;
106
-
107
104
  if (textInput.value.innerText === "") {
108
- tags.value.pop();
105
+ model.value.pop();
106
+ } else {
107
+ const currentLength = textInput.value.innerText.length;
108
+ textInput.value.innerText = textInput.value.innerText.slice(0, -1);
109
+
110
+ const range = document.createRange();
111
+ const sel = window.getSelection();
112
+ range.selectNodeContents(textInput.value);
113
+ range.collapse(false);
114
+ if (!sel) return;
115
+ sel.removeAllRanges();
116
+ sel.addRange(range);
109
117
  }
110
118
  };
111
-
112
119
  const focusInput = () => {
113
120
  if (!textInput.value) return;
114
121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "repository": {