@fy-/fws-vue 0.2.0 → 0.2.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.
|
@@ -288,13 +288,15 @@ onMounted(async () => {
|
|
|
288
288
|
v-if="
|
|
289
289
|
field.type == 'text' ||
|
|
290
290
|
field.type == 'password' ||
|
|
291
|
-
field.type == 'email'
|
|
291
|
+
field.type == 'email' ||
|
|
292
|
+
field.type == 'mask'
|
|
292
293
|
"
|
|
293
294
|
>
|
|
294
295
|
<DefaultInput
|
|
295
296
|
v-if="field.name"
|
|
296
297
|
:id="field.name"
|
|
297
298
|
:label="field.label"
|
|
299
|
+
:mask="field.mask"
|
|
298
300
|
class="mt-3"
|
|
299
301
|
:placeholder="
|
|
300
302
|
field.name == 'name' ? 'John Doe' : field.label
|
|
@@ -10,6 +10,8 @@ import Password from "primevue/password";
|
|
|
10
10
|
import Checkbox from "primevue/checkbox";
|
|
11
11
|
import Dropdown from "primevue/dropdown";
|
|
12
12
|
import Chips from "primevue/chips";
|
|
13
|
+
import InputSwitch from "primevue/inputswitch";
|
|
14
|
+
import InputMask from "primevue/inputmask";
|
|
13
15
|
|
|
14
16
|
type modelValueType = string | number | string[] | number[] | undefined;
|
|
15
17
|
|
|
@@ -22,6 +24,7 @@ const props = withDefaults(
|
|
|
22
24
|
type?: string;
|
|
23
25
|
placeholder?: string;
|
|
24
26
|
autocomplete?: string;
|
|
27
|
+
mask?: string;
|
|
25
28
|
checkboxTrueValue?: string | boolean;
|
|
26
29
|
checkboxFalseValue?: string | boolean;
|
|
27
30
|
req?: boolean;
|
|
@@ -103,6 +106,8 @@ defineExpose({ focus, getInputRef });
|
|
|
103
106
|
'select',
|
|
104
107
|
'phone',
|
|
105
108
|
'chips',
|
|
109
|
+
'opts',
|
|
110
|
+
'mask',
|
|
106
111
|
].includes(type)
|
|
107
112
|
"
|
|
108
113
|
>
|
|
@@ -115,6 +120,7 @@ defineExpose({ focus, getInputRef });
|
|
|
115
120
|
:placeholder="placeholder"
|
|
116
121
|
:invalid="checkErrors ? true : false"
|
|
117
122
|
:pt:root:autocomplete="autocomplete"
|
|
123
|
+
:pt:root:type="type"
|
|
118
124
|
:aria-describedby="
|
|
119
125
|
help && !['checkbox', 'radio'].includes(type)
|
|
120
126
|
? `${id}-help`
|
|
@@ -129,6 +135,24 @@ defineExpose({ focus, getInputRef });
|
|
|
129
135
|
"
|
|
130
136
|
/>
|
|
131
137
|
<!-- @vue-skip -->
|
|
138
|
+
<InputMask
|
|
139
|
+
:id="id"
|
|
140
|
+
v-model="model"
|
|
141
|
+
:placeholder="placeholder"
|
|
142
|
+
:invalid="checkErrors ? true : false"
|
|
143
|
+
:pt:root:autocomplete="autocomplete"
|
|
144
|
+
:pt:root:type="type"
|
|
145
|
+
:mask="mask"
|
|
146
|
+
:aria-describedby="
|
|
147
|
+
help && !['checkbox', 'radio'].includes(type)
|
|
148
|
+
? `${id}-help`
|
|
149
|
+
: undefined
|
|
150
|
+
"
|
|
151
|
+
v-if="
|
|
152
|
+
type == 'mask',
|
|
153
|
+
"
|
|
154
|
+
/>
|
|
155
|
+
<!-- @vue-skip -->
|
|
132
156
|
<Textarea
|
|
133
157
|
:id="id"
|
|
134
158
|
v-model="model"
|
|
@@ -224,8 +248,23 @@ defineExpose({ focus, getInputRef });
|
|
|
224
248
|
</small>
|
|
225
249
|
</div>
|
|
226
250
|
</template>
|
|
251
|
+
<template v-else-if="type === 'toggle'">
|
|
252
|
+
<label class="inline-flex items-start cursor-pointer">
|
|
253
|
+
<!-- @vue-skip -->
|
|
254
|
+
<InputSwitch v-model="modelCheckbox" class="flex-0 flex-shrink-0" />
|
|
227
255
|
|
|
228
|
-
|
|
256
|
+
<span
|
|
257
|
+
class="ms-3 font-medium text-fv-neutral-900 dark:text-fv-neutral-300"
|
|
258
|
+
>{{ label }}
|
|
259
|
+
<template v-if="help">
|
|
260
|
+
<p class="text-fv-neutral-600 dark:text-fv-neutral-400 !text-sm">
|
|
261
|
+
{{ help }}
|
|
262
|
+
</p>
|
|
263
|
+
</template>
|
|
264
|
+
</span>
|
|
265
|
+
</label>
|
|
266
|
+
</template>
|
|
267
|
+
<template v-else-if="type == 'checkbox'">
|
|
229
268
|
<div class="flex items-center">
|
|
230
269
|
<Checkbox
|
|
231
270
|
v-model="modelCheckbox"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-/fws-vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"author": "Florian 'Fy' Gasquez <m@fy.to>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@fy-/fws-js": "^0.0.x",
|
|
31
|
-
"@fy-/fws-types": "^0.
|
|
31
|
+
"@fy-/fws-types": "^0.5.x",
|
|
32
32
|
"@fy-/head": "^0.0.x",
|
|
33
33
|
"@vuelidate/core": "^2.0.x",
|
|
34
34
|
"@vuelidate/validators": "^2.0.x",
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<label class="tag-label" :for="`tags_${id}`">{{ label }}</label>
|
|
4
|
-
<div
|
|
5
|
-
class="tags-input"
|
|
6
|
-
@click="focusInput"
|
|
7
|
-
@keydown.enter.prevent="addTag"
|
|
8
|
-
@keydown.delete="removeLastTag"
|
|
9
|
-
>
|
|
10
|
-
<span v-for="(tag, index) in tags" :key="index" :class="`tag ${color}`">
|
|
11
|
-
{{ tag }}
|
|
12
|
-
<button @click.stop="removeTag(index)" type="button">
|
|
13
|
-
<svg
|
|
14
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
-
fill="none"
|
|
16
|
-
viewBox="0 0 24 24"
|
|
17
|
-
stroke-width="1.5"
|
|
18
|
-
stroke="currentColor"
|
|
19
|
-
class="w-3 h-3 text-red-600 dark:text-red-200"
|
|
20
|
-
>
|
|
21
|
-
<path
|
|
22
|
-
stroke-linecap="round"
|
|
23
|
-
stroke-linejoin="round"
|
|
24
|
-
d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
|
|
25
|
-
/>
|
|
26
|
-
</svg>
|
|
27
|
-
</button>
|
|
28
|
-
</span>
|
|
29
|
-
<div
|
|
30
|
-
contenteditable
|
|
31
|
-
class="input"
|
|
32
|
-
:id="`tags_${id}`"
|
|
33
|
-
ref="textInput"
|
|
34
|
-
@input="updateInput"
|
|
35
|
-
@paste.prevent="handlePaste"
|
|
36
|
-
placeholder="Add a tag..."
|
|
37
|
-
></div>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
</template>
|
|
41
|
-
|
|
42
|
-
<script setup>
|
|
43
|
-
import { ref, watch, onMounted } from "vue";
|
|
44
|
-
|
|
45
|
-
const props = defineProps({
|
|
46
|
-
modelValue: {
|
|
47
|
-
type: Array,
|
|
48
|
-
default: () => [],
|
|
49
|
-
},
|
|
50
|
-
color: {
|
|
51
|
-
type: String,
|
|
52
|
-
default: "blue",
|
|
53
|
-
},
|
|
54
|
-
label: {
|
|
55
|
-
type: String,
|
|
56
|
-
default: "Tags",
|
|
57
|
-
},
|
|
58
|
-
id: {
|
|
59
|
-
type: String,
|
|
60
|
-
required: true,
|
|
61
|
-
},
|
|
62
|
-
autofocus: {
|
|
63
|
-
type: Boolean,
|
|
64
|
-
default: false,
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const emit = defineEmits(["update:modelValue"]);
|
|
69
|
-
const tags = ref([...props.modelValue]);
|
|
70
|
-
const textInput = ref(null);
|
|
71
|
-
|
|
72
|
-
watch(
|
|
73
|
-
tags,
|
|
74
|
-
(newTags) => {
|
|
75
|
-
emit("update:modelValue", newTags);
|
|
76
|
-
},
|
|
77
|
-
{ deep: true },
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
onMounted(() => {
|
|
81
|
-
if (props.autofocus) {
|
|
82
|
-
focusInput();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const updateInput = (event) => {
|
|
87
|
-
const text = event.target.innerText;
|
|
88
|
-
if (text.includes(",")) {
|
|
89
|
-
addTag();
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const addTag = () => {
|
|
94
|
-
const newTags = textInput.value.innerText
|
|
95
|
-
.split(",")
|
|
96
|
-
.map((tag) => tag.trim())
|
|
97
|
-
.filter((tag) => tag.length > 0);
|
|
98
|
-
tags.value.push(...newTags);
|
|
99
|
-
textInput.value.innerText = "";
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const removeTag = (index) => {
|
|
103
|
-
tags.value.splice(index, 1);
|
|
104
|
-
focusInput();
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const removeLastTag = () => {
|
|
108
|
-
if (textInput.value.innerText === "") {
|
|
109
|
-
tags.value.pop();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const focusInput = () => {
|
|
114
|
-
textInput.value.focus();
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const handlePaste = (e) => {
|
|
118
|
-
const text = (e.clipboardData || window.clipboardData).getData("text");
|
|
119
|
-
textInput.value.innerText += text;
|
|
120
|
-
e.preventDefault();
|
|
121
|
-
};
|
|
122
|
-
</script>
|
|
123
|
-
|
|
124
|
-
<style scoped>
|
|
125
|
-
.tags-input {
|
|
126
|
-
cursor: text;
|
|
127
|
-
@apply flex flex-wrap gap-2 items-center shadow-sm bg-fv-neutral-50 border border-fv-neutral-300 text-fv-neutral-900 text-sm rounded-sm focus:ring-fv-primary-500 focus:border-fv-primary-500 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;
|
|
128
|
-
}
|
|
129
|
-
.tag-label {
|
|
130
|
-
@apply block mb-2 text-sm font-medium text-fv-neutral-900 dark:text-white;
|
|
131
|
-
|
|
132
|
-
&.error {
|
|
133
|
-
@apply text-red-700 dark:text-red-500;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
.tag {
|
|
137
|
-
@apply inline-flex gap-1 font-medium px-2.5 py-0.5 rounded;
|
|
138
|
-
&.blue {
|
|
139
|
-
@apply bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200;
|
|
140
|
-
}
|
|
141
|
-
&.purple {
|
|
142
|
-
@apply bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200;
|
|
143
|
-
}
|
|
144
|
-
&.red {
|
|
145
|
-
@apply bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200;
|
|
146
|
-
}
|
|
147
|
-
&.orange {
|
|
148
|
-
@apply bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200;
|
|
149
|
-
}
|
|
150
|
-
&.neutral {
|
|
151
|
-
@apply bg-fv-neutral-100 text-fv-neutral-800 dark:bg-fv-neutral-900 dark:text-fv-neutral-200;
|
|
152
|
-
}
|
|
153
|
-
&.green {
|
|
154
|
-
@apply bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.input {
|
|
159
|
-
flex-grow: 1;
|
|
160
|
-
min-width: 100px;
|
|
161
|
-
outline: none;
|
|
162
|
-
border: none;
|
|
163
|
-
}
|
|
164
|
-
</style>
|