@ozdao/martyrs 0.2.539 → 0.2.541
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.
- package/dist/{globals.verifier-CJ1lr-NW.cjs → globals.verifier-Bi-XLEi9.cjs} +24 -23
- package/dist/{globals.verifier-BhqUrneb.js → globals.verifier-gPPX_jhf.js} +24 -23
- package/dist/inventory.server.cjs +1 -1
- package/dist/inventory.server.js +1 -1
- package/dist/{main-Zhs0EqRp.cjs → main-7IA3UHca.cjs} +6 -6
- package/dist/{main-gOfhekZG.js → main-BpBtIUcJ.js} +549 -549
- package/dist/martyrs/src/components/Button/Button.vue.cjs +1 -1
- package/dist/martyrs/src/components/Button/Button.vue.js +1 -1
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs → Dropdown.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.js → Dropdown.vue2.js} +2 -2
- package/dist/martyrs/src/components/Dropdown/{Dropdown.vue.cjs.map → Dropdown.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/EditImages/EditImages.vue.cjs +0 -93
- package/dist/martyrs/src/components/EditImages/EditImages.vue.cjs.map +1 -1
- package/dist/martyrs/src/components/EditImages/EditImages.vue.js +1 -94
- package/dist/martyrs/src/components/EditImages/EditImages.vue.js.map +1 -1
- package/dist/martyrs/src/components/EditImages/EditImages.vue2.cjs +93 -0
- package/dist/martyrs/src/components/EditImages/EditImages.vue2.cjs.map +1 -1
- package/dist/martyrs/src/components/EditImages/EditImages.vue2.js +94 -1
- package/dist/martyrs/src/components/EditImages/EditImages.vue2.js.map +1 -1
- package/dist/martyrs/src/components/Feed/Carousel.vue.cjs +1 -1
- package/dist/martyrs/src/components/Feed/Carousel.vue.js +1 -1
- package/dist/martyrs/src/components/Feed/Feed.vue.cjs +3 -3
- package/dist/martyrs/src/components/Feed/Feed.vue.js +3 -3
- package/dist/martyrs/src/components/FieldTags/create-tags.cjs +11 -2
- package/dist/martyrs/src/components/FieldTags/create-tags.cjs.map +1 -1
- package/dist/martyrs/src/components/FieldTags/create-tags.js +11 -2
- package/dist/martyrs/src/components/FieldTags/create-tags.js.map +1 -1
- package/dist/martyrs/src/components/Loader/{Loader.vue.cjs → Loader.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Loader/Loader.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Loader/{Loader.vue.js → Loader.vue2.js} +2 -2
- package/dist/martyrs/src/components/Loader/{Loader.vue.cjs.map → Loader.vue2.js.map} +1 -1
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue.cjs +1 -1
- package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue.js +1 -1
- package/dist/martyrs/src/components/Menu/{Menu.vue.cjs → Menu.vue2.cjs} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue2.cjs.map +1 -0
- package/dist/martyrs/src/components/Menu/{Menu.vue.js → Menu.vue2.js} +2 -2
- package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +1 -0
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.cjs +1 -1
- package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.cjs +3 -3
- package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +3 -3
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/auth/views/store/auth.cjs +0 -2
- package/dist/martyrs/src/modules/auth/views/store/auth.cjs.map +1 -1
- package/dist/martyrs/src/modules/auth/views/store/auth.js +0 -2
- package/dist/martyrs/src/modules/auth/views/store/auth.js.map +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.cjs +1 -1
- package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.cjs +2 -2
- package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +2 -2
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.cjs +3 -3
- package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +3 -3
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/Feed.vue.js +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.cjs +1 -1
- package/dist/martyrs/src/modules/events/components/sections/List.vue.js +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.cjs +1 -1
- package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/globals.client.cjs +0 -3
- package/dist/martyrs/src/modules/globals/globals.client.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/globals.client.js +0 -3
- package/dist/martyrs/src/modules/globals/globals.client.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.cjs +31 -41
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.js +31 -41
- package/dist/martyrs/src/modules/globals/views/classes/globals.app.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/module-registry.cjs +0 -3
- package/dist/martyrs/src/modules/globals/views/classes/module-registry.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/module-registry.js +0 -3
- package/dist/martyrs/src/modules/globals/views/classes/module-registry.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/store.cjs +0 -5
- package/dist/martyrs/src/modules/globals/views/classes/store.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/store.js +0 -5
- package/dist/martyrs/src/modules/globals/views/classes/store.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.cjs +2 -2
- package/dist/martyrs/src/modules/globals/views/components/blocks/CardHeader.vue.js +2 -2
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/blocks/PopupDateSelector.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +1 -1
- package/dist/martyrs/src/modules/globals/views/components/sections/{Filters.vue.cjs → Filters.vue2.cjs} +2 -2
- package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue2.cjs.map +1 -0
- package/dist/martyrs/src/modules/globals/views/components/sections/{Filters.vue.js → Filters.vue2.js} +2 -2
- package/dist/martyrs/src/modules/globals/views/components/sections/{Filters.vue.cjs.map → Filters.vue2.js.map} +1 -1
- package/dist/martyrs/src/modules/globals/views/store/globals.cjs +2 -2
- package/dist/martyrs/src/modules/globals/views/store/globals.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/store/globals.js +2 -2
- package/dist/martyrs/src/modules/globals/views/store/globals.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/utils/vue-app-renderer.cjs +7 -3
- package/dist/martyrs/src/modules/globals/views/utils/vue-app-renderer.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/utils/vue-app-renderer.js +7 -3
- package/dist/martyrs/src/modules/globals/views/utils/vue-app-renderer.js.map +1 -1
- package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.cjs +2 -2
- package/dist/martyrs/src/modules/inventory/components/pages/Inventory.vue.js +1 -1
- package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.cjs +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Artist.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Artist.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.js +1 -1
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.cjs +2 -2
- package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +2 -2
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.cjs +1 -1
- package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/forms/FormSelectCustomer.vue.cjs +1 -1
- package/dist/martyrs/src/modules/orders/components/forms/FormSelectCustomer.vue.js +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +3 -3
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +3 -3
- package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.cjs +4 -4
- package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.js +4 -4
- package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.cjs +4 -4
- package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.js +4 -4
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.cjs +4 -4
- package/dist/martyrs/src/modules/organizations/components/pages/Members.vue.js +4 -4
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +4 -4
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +4 -4
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +1 -1
- package/dist/martyrs/src/modules/organizations/router/organizations.cjs +1 -1
- package/dist/martyrs/src/modules/organizations/router/organizations.js +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.cjs +1 -1
- package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/elements/Image360.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/elements/Image360.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs +19 -3
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +19 -3
- package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditVariants.vue.cjs +1 -1
- package/dist/martyrs/src/modules/products/components/sections/EditVariants.vue.js +1 -1
- package/dist/martyrs/src/modules/products/store/categories.cjs +4 -0
- package/dist/martyrs/src/modules/products/store/categories.cjs.map +1 -1
- package/dist/martyrs/src/modules/products/store/categories.js +4 -0
- package/dist/martyrs/src/modules/products/store/categories.js.map +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.cjs +1 -1
- package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.js +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.cjs +1 -1
- package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +1 -1
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.cjs +1 -1
- package/dist/martyrs/src/modules/wallet/views/components/pages/Wallet.vue.js +1 -1
- package/dist/martyrs.cjs.js +1 -1
- package/dist/martyrs.es.js +1 -1
- package/dist/music.server.cjs +1 -1
- package/dist/music.server.js +1 -1
- package/dist/orders.server.cjs +1 -1
- package/dist/orders.server.js +1 -1
- package/dist/organizations.server.cjs +1 -1
- package/dist/organizations.server.js +1 -1
- package/dist/products.server.cjs +10 -2
- package/dist/products.server.js +10 -2
- package/dist/rents.server.cjs +1 -1
- package/dist/rents.server.js +1 -1
- package/dist/{web-bMa0DMyG.cjs → web-C9bVm6Nw.cjs} +1 -1
- package/dist/{web-DxxU2bwy.js → web-DsdyXC8n.js} +1 -1
- package/package.json +1 -1
- package/src/components/FieldTags/FieldTagsNew.vue +366 -0
- package/src/components/FieldTags/README.md +513 -0
- package/src/components/FieldTags/create-tags.js +15 -2
- package/src/modules/auth/views/store/auth.js +0 -2
- package/src/modules/globals/controllers/classes/globals.validator.js +24 -23
- package/src/modules/globals/globals.client.js +0 -3
- package/src/modules/globals/views/classes/globals.app.js +21 -34
- package/src/modules/globals/views/classes/module-registry.js +0 -3
- package/src/modules/globals/views/classes/store.js +0 -7
- package/src/modules/globals/views/store/globals.js +2 -2
- package/src/modules/globals/views/utils/vue-app-renderer.js +11 -3
- package/src/modules/products/components/pages/CategoryEdit.vue +20 -0
- package/src/modules/products/middlewares/categories.verifier.js +9 -1
- package/src/modules/products/store/categories.js +5 -0
- package/dist/martyrs/src/components/Dropdown/Dropdown.vue.js.map +0 -1
- package/dist/martyrs/src/components/Loader/Loader.vue.js.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue.cjs.map +0 -1
- package/dist/martyrs/src/components/Menu/Menu.vue.js.map +0 -1
- package/dist/martyrs/src/modules/globals/views/components/sections/Filters.vue.js.map +0 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="field-tags-new">
|
|
3
|
+
<!-- Tags container -->
|
|
4
|
+
<div class="tags-container">
|
|
5
|
+
<span
|
|
6
|
+
v-for="(tag, index) in tags"
|
|
7
|
+
:key="index"
|
|
8
|
+
class="tag"
|
|
9
|
+
>
|
|
10
|
+
{{ getTagText(tag) }}
|
|
11
|
+
<button
|
|
12
|
+
@click="removeTag(index)"
|
|
13
|
+
class="tag-remove"
|
|
14
|
+
type="button"
|
|
15
|
+
>
|
|
16
|
+
×
|
|
17
|
+
</button>
|
|
18
|
+
</span>
|
|
19
|
+
|
|
20
|
+
<input
|
|
21
|
+
ref="inputRef"
|
|
22
|
+
v-model="newTag"
|
|
23
|
+
@keydown="handleKeyDown"
|
|
24
|
+
@paste="handlePaste"
|
|
25
|
+
@focus="focused = true"
|
|
26
|
+
@blur="handleBlur"
|
|
27
|
+
:placeholder="placeholder || 'Add tags'"
|
|
28
|
+
:maxlength="maxlength"
|
|
29
|
+
:disabled="disabled"
|
|
30
|
+
class="tag-input"
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<!-- Autocomplete dropdown -->
|
|
35
|
+
<div
|
|
36
|
+
v-if="showAutocomplete && filteredAutocomplete.length > 0"
|
|
37
|
+
class="autocomplete"
|
|
38
|
+
>
|
|
39
|
+
<div
|
|
40
|
+
v-for="(item, index) in filteredAutocomplete"
|
|
41
|
+
:key="getTagText(item)"
|
|
42
|
+
@click="addTag(item)"
|
|
43
|
+
@mouseenter="selectedIndex = index"
|
|
44
|
+
:class="['autocomplete-item', { selected: selectedIndex === index }]"
|
|
45
|
+
>
|
|
46
|
+
{{ getTagText(item) }}
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup>
|
|
53
|
+
import { ref, computed, watch } from 'vue'
|
|
54
|
+
|
|
55
|
+
const props = defineProps({
|
|
56
|
+
modelValue: Array,
|
|
57
|
+
textField: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: 'text'
|
|
60
|
+
},
|
|
61
|
+
autocompleteItems: Array,
|
|
62
|
+
separators: {
|
|
63
|
+
type: Array,
|
|
64
|
+
default: () => [',', ';']
|
|
65
|
+
},
|
|
66
|
+
addOnKey: {
|
|
67
|
+
type: Array,
|
|
68
|
+
default: () => [13] // Enter key
|
|
69
|
+
},
|
|
70
|
+
maxTags: {
|
|
71
|
+
type: Number,
|
|
72
|
+
default: 20
|
|
73
|
+
},
|
|
74
|
+
maxlength: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 50
|
|
77
|
+
},
|
|
78
|
+
placeholder: String,
|
|
79
|
+
disabled: Boolean,
|
|
80
|
+
addOnBlur: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true
|
|
83
|
+
},
|
|
84
|
+
autocompleteMinLength: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 1
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const emit = defineEmits(['update:modelValue', 'tags-changed'])
|
|
91
|
+
|
|
92
|
+
// State
|
|
93
|
+
const newTag = ref('')
|
|
94
|
+
const focused = ref(false)
|
|
95
|
+
const selectedIndex = ref(-1)
|
|
96
|
+
const inputRef = ref(null)
|
|
97
|
+
|
|
98
|
+
// Computed
|
|
99
|
+
const tags = computed({
|
|
100
|
+
get: () => props.modelValue || [],
|
|
101
|
+
set: (value) => {
|
|
102
|
+
emit('update:modelValue', value)
|
|
103
|
+
emit('tags-changed', value)
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const showAutocomplete = computed(() => {
|
|
108
|
+
return focused.value &&
|
|
109
|
+
props.autocompleteItems?.length > 0 &&
|
|
110
|
+
newTag.value.length >= props.autocompleteMinLength
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const filteredAutocomplete = computed(() => {
|
|
114
|
+
if (!props.autocompleteItems) return []
|
|
115
|
+
|
|
116
|
+
const searchText = newTag.value.toLowerCase()
|
|
117
|
+
|
|
118
|
+
return props.autocompleteItems.filter(item => {
|
|
119
|
+
const itemText = getTagText(item).toLowerCase()
|
|
120
|
+
|
|
121
|
+
// Filter by search text
|
|
122
|
+
if (!itemText.includes(searchText)) return false
|
|
123
|
+
|
|
124
|
+
// Filter out duplicates
|
|
125
|
+
return !isDuplicate(itemText)
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// Methods
|
|
130
|
+
function getTagText(tag) {
|
|
131
|
+
if (tag === null || tag === undefined) return ''
|
|
132
|
+
if (typeof tag === 'string') return tag
|
|
133
|
+
return tag[props.textField] || ''
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function createTag(text) {
|
|
137
|
+
// Preserve format based on existing data
|
|
138
|
+
if (tags.value.length > 0) {
|
|
139
|
+
if (typeof tags.value[0] === 'string') {
|
|
140
|
+
return text
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Default to object with custom field
|
|
145
|
+
return { [props.textField]: text }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function isDuplicate(text) {
|
|
149
|
+
const searchText = text.toLowerCase().trim()
|
|
150
|
+
return tags.value.some(tag =>
|
|
151
|
+
getTagText(tag).toLowerCase().trim() === searchText
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function addTag(input) {
|
|
156
|
+
let text = ''
|
|
157
|
+
|
|
158
|
+
if (typeof input === 'string') {
|
|
159
|
+
text = input.trim()
|
|
160
|
+
} else if (typeof input === 'object') {
|
|
161
|
+
// If it's an autocomplete item, preserve the whole object
|
|
162
|
+
if (props.autocompleteItems?.includes(input)) {
|
|
163
|
+
if (!isDuplicate(getTagText(input))) {
|
|
164
|
+
tags.value = [...tags.value, input]
|
|
165
|
+
}
|
|
166
|
+
newTag.value = ''
|
|
167
|
+
selectedIndex.value = -1
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
text = getTagText(input).trim()
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!text || tags.value.length >= props.maxTags) return
|
|
174
|
+
|
|
175
|
+
if (isDuplicate(text)) return
|
|
176
|
+
|
|
177
|
+
const tag = createTag(text)
|
|
178
|
+
tags.value = [...tags.value, tag]
|
|
179
|
+
newTag.value = ''
|
|
180
|
+
selectedIndex.value = -1
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function removeTag(index) {
|
|
184
|
+
if (props.disabled) return
|
|
185
|
+
|
|
186
|
+
const newTags = [...tags.value]
|
|
187
|
+
newTags.splice(index, 1)
|
|
188
|
+
tags.value = newTags
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function handleKeyDown(event) {
|
|
192
|
+
// Handle arrow keys for autocomplete navigation
|
|
193
|
+
if (showAutocomplete.value) {
|
|
194
|
+
if (event.key === 'ArrowDown') {
|
|
195
|
+
event.preventDefault()
|
|
196
|
+
selectedIndex.value = Math.min(
|
|
197
|
+
selectedIndex.value + 1,
|
|
198
|
+
filteredAutocomplete.value.length - 1
|
|
199
|
+
)
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (event.key === 'ArrowUp') {
|
|
204
|
+
event.preventDefault()
|
|
205
|
+
selectedIndex.value = Math.max(selectedIndex.value - 1, -1)
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Add selected autocomplete item on Enter
|
|
210
|
+
if (event.key === 'Enter' && selectedIndex.value >= 0) {
|
|
211
|
+
event.preventDefault()
|
|
212
|
+
addTag(filteredAutocomplete.value[selectedIndex.value])
|
|
213
|
+
return
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Check for add triggers
|
|
218
|
+
const shouldAdd = props.addOnKey.some(key => {
|
|
219
|
+
if (typeof key === 'number') {
|
|
220
|
+
return event.keyCode === key
|
|
221
|
+
}
|
|
222
|
+
return event.key === key
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
if (shouldAdd) {
|
|
226
|
+
event.preventDefault()
|
|
227
|
+
addTag(newTag.value)
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Handle backspace to delete last tag
|
|
232
|
+
if (event.key === 'Backspace' && newTag.value === '' && tags.value.length > 0) {
|
|
233
|
+
removeTag(tags.value.length - 1)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function handlePaste(event) {
|
|
238
|
+
event.preventDefault()
|
|
239
|
+
|
|
240
|
+
const text = event.clipboardData.getData('text')
|
|
241
|
+
if (!text) return
|
|
242
|
+
|
|
243
|
+
// Create regex from separators
|
|
244
|
+
const separatorRegex = new RegExp(
|
|
245
|
+
props.separators.map(s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
// Split by separators and add each tag
|
|
249
|
+
const parts = text.split(separatorRegex)
|
|
250
|
+
|
|
251
|
+
parts.forEach(part => {
|
|
252
|
+
if (tags.value.length >= props.maxTags) return
|
|
253
|
+
addTag(part)
|
|
254
|
+
})
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function handleBlur() {
|
|
258
|
+
// Small delay to allow click on autocomplete items
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
focused.value = false
|
|
261
|
+
selectedIndex.value = -1
|
|
262
|
+
|
|
263
|
+
if (props.addOnBlur && newTag.value) {
|
|
264
|
+
addTag(newTag.value)
|
|
265
|
+
}
|
|
266
|
+
}, 200)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Reset selected index when autocomplete items change
|
|
270
|
+
watch(filteredAutocomplete, () => {
|
|
271
|
+
selectedIndex.value = -1
|
|
272
|
+
})
|
|
273
|
+
</script>
|
|
274
|
+
|
|
275
|
+
<style scoped>
|
|
276
|
+
.field-tags-new {
|
|
277
|
+
position: relative;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.tags-container {
|
|
281
|
+
display: flex;
|
|
282
|
+
flex-wrap: wrap;
|
|
283
|
+
align-items: center;
|
|
284
|
+
gap: 0.5rem;
|
|
285
|
+
padding: 0.5rem;
|
|
286
|
+
background: rgb(var(--gray-light, 248, 248, 248));
|
|
287
|
+
border-radius: 0.5rem;
|
|
288
|
+
min-height: 3rem;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.tag {
|
|
292
|
+
display: inline-flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
background: rgb(var(--main, 255, 215, 0));
|
|
295
|
+
color: rgb(var(--black, 0, 0, 0));
|
|
296
|
+
padding: 0.25rem 0.5rem;
|
|
297
|
+
border-radius: 2rem;
|
|
298
|
+
font-size: 0.875rem;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.tag-remove {
|
|
302
|
+
margin-left: 0.25rem;
|
|
303
|
+
background: none;
|
|
304
|
+
border: none;
|
|
305
|
+
color: inherit;
|
|
306
|
+
font-size: 1.25rem;
|
|
307
|
+
cursor: pointer;
|
|
308
|
+
padding: 0;
|
|
309
|
+
line-height: 1;
|
|
310
|
+
opacity: 0.7;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.tag-remove:hover {
|
|
314
|
+
opacity: 1;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.tag-input {
|
|
318
|
+
flex: 1;
|
|
319
|
+
border: none;
|
|
320
|
+
background: none;
|
|
321
|
+
outline: none;
|
|
322
|
+
min-width: 150px;
|
|
323
|
+
padding: 0.25rem;
|
|
324
|
+
font-size: inherit;
|
|
325
|
+
font-family: inherit;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.tag-input:disabled {
|
|
329
|
+
cursor: not-allowed;
|
|
330
|
+
opacity: 0.5;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.autocomplete {
|
|
334
|
+
position: absolute;
|
|
335
|
+
top: 100%;
|
|
336
|
+
left: 0;
|
|
337
|
+
right: 0;
|
|
338
|
+
margin-top: 0.25rem;
|
|
339
|
+
background: white;
|
|
340
|
+
border: 1px solid rgb(var(--gray, 224, 224, 224));
|
|
341
|
+
border-radius: 0.5rem;
|
|
342
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
343
|
+
max-height: 200px;
|
|
344
|
+
overflow-y: auto;
|
|
345
|
+
z-index: 100;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.autocomplete-item {
|
|
349
|
+
padding: 0.5rem 0.75rem;
|
|
350
|
+
cursor: pointer;
|
|
351
|
+
transition: background-color 0.2s;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.autocomplete-item:hover,
|
|
355
|
+
.autocomplete-item.selected {
|
|
356
|
+
background: rgb(var(--gray-light, 248, 248, 248));
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.autocomplete-item:first-child {
|
|
360
|
+
border-radius: 0.5rem 0.5rem 0 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.autocomplete-item:last-child {
|
|
364
|
+
border-radius: 0 0 0.5rem 0.5rem;
|
|
365
|
+
}
|
|
366
|
+
</style>
|