@it-enterprise/forcebpm-ui-kit 1.0.2-beta.3 → 1.0.2-beta.30

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.
Files changed (86) hide show
  1. package/README.md +81 -65
  2. package/index.js +48 -1
  3. package/package.json +35 -15
  4. package/plugin.js +117 -0
  5. package/src/FActionSnackbar.vue +107 -0
  6. package/src/FAvatar.vue +10 -8
  7. package/src/{FConfirmModal.vue → FConfirmDialog.vue} +38 -28
  8. package/src/FContextMenu.vue +87 -0
  9. package/src/FDialog.vue +264 -0
  10. package/src/FLangSwitcher.vue +47 -0
  11. package/src/FNoData.vue +80 -0
  12. package/src/FNotify.vue +257 -0
  13. package/src/FPagination.vue +163 -0
  14. package/src/FPreLoader.vue +105 -0
  15. package/src/FSearchPanel.vue +191 -0
  16. package/src/FShare.vue +134 -0
  17. package/src/FTruncate.vue +121 -0
  18. package/src/FUserGroupPicker.vue +634 -0
  19. package/src/FUserRoles.vue +195 -0
  20. package/src/assets/fonts/ProximaNova-Bold.woff +0 -0
  21. package/src/assets/fonts/ProximaNova-Bold.woff2 +0 -0
  22. package/src/assets/fonts/ProximaNova-Regular.woff +0 -0
  23. package/src/assets/fonts/ProximaNova-Regular.woff2 +0 -0
  24. package/src/assets/fonts/ProximaNova-Semibold.woff +0 -0
  25. package/src/assets/fonts/ProximaNova-Semibold.woff2 +0 -0
  26. package/src/assets/fonts/loadFonts.js +55 -0
  27. package/src/assets/icons/bell-mute.svg +4 -0
  28. package/src/assets/icons/bell.svg +3 -0
  29. package/src/assets/icons/check.svg +3 -0
  30. package/src/assets/icons/checkbox-false.svg +3 -0
  31. package/src/assets/icons/checkbox-true.svg +4 -0
  32. package/src/assets/icons/chevron.svg +3 -0
  33. package/src/assets/icons/color-radio-active.svg +4 -0
  34. package/src/assets/icons/color-radio.svg +3 -0
  35. package/src/assets/icons/ctx-arrow.svg +3 -0
  36. package/src/assets/icons/ctx-delete.svg +6 -0
  37. package/src/assets/icons/ctx-link.svg +5 -0
  38. package/src/assets/icons/ctx-more.svg +5 -0
  39. package/src/assets/icons/ctx-pen.svg +4 -0
  40. package/src/assets/icons/delete.svg +6 -0
  41. package/src/assets/icons/dots.svg +5 -0
  42. package/src/assets/icons/filter.svg +3 -0
  43. package/src/assets/icons/folder.svg +3 -0
  44. package/src/assets/icons/open-envelope.svg +6 -0
  45. package/src/assets/icons/pass-eye-close.svg +3 -0
  46. package/src/assets/icons/pass-eye-open.svg +4 -0
  47. package/src/assets/icons/plus-solid.svg +4 -0
  48. package/src/assets/icons/plus.svg +4 -0
  49. package/src/assets/icons/radio-false.svg +3 -0
  50. package/src/assets/icons/radio-true.svg +4 -0
  51. package/src/assets/icons/search.svg +3 -0
  52. package/src/assets/icons/sort-solid.svg +3 -0
  53. package/src/assets/icons/sort.svg +6 -0
  54. package/src/assets/icons/star-line.svg +3 -0
  55. package/src/assets/icons/star.svg +3 -0
  56. package/src/assets/icons/times.svg +4 -0
  57. package/src/assets/images/0.gif +0 -0
  58. package/src/assets/images/0.svg +4 -0
  59. package/src/assets/images/3.svg +4 -0
  60. package/src/assets/images/4.svg +4 -0
  61. package/src/assets/images/5.svg +4 -0
  62. package/src/assets/scss/buttons.scss +60 -0
  63. package/src/assets/scss/card.scss +11 -0
  64. package/src/assets/scss/expansion.scss +45 -0
  65. package/src/assets/scss/icons.scss +273 -0
  66. package/src/assets/scss/index.scss +10 -0
  67. package/src/assets/scss/input.scss +344 -0
  68. package/src/assets/scss/overlay.scss +69 -0
  69. package/src/assets/scss/skeleton.scss +22 -0
  70. package/src/assets/scss/tables.scss +143 -0
  71. package/src/assets/scss/tabs.scss +42 -0
  72. package/src/assets/scss/utilities.scss +167 -0
  73. package/src/f-date-picker/FDatePicker.vue +322 -0
  74. package/src/f-date-picker/FMenuDatePicker.vue +337 -0
  75. package/src/f-date-picker/FTextFieldDate.vue +498 -0
  76. package/src/f-toolbar/FFilterPanel.vue +62 -0
  77. package/src/f-toolbar/FSortPanel.vue +55 -0
  78. package/src/f-toolbar/FTabPanel.vue +123 -0
  79. package/src/f-toolbar/FToolbar.vue +131 -0
  80. package/src/f-toolbar/FViewerPanel.vue +71 -0
  81. package/src/forcebpmIcon.js +69 -0
  82. package/src/locales/en.json +115 -0
  83. package/src/locales/index.js +7 -0
  84. package/src/locales/ru.json +116 -0
  85. package/src/locales/uk.json +116 -0
  86. package/src/utils/color.js +38 -0
@@ -0,0 +1,257 @@
1
+ <script setup>
2
+ // FNotify
3
+ import { ref, onBeforeUnmount, onMounted, watch } from 'vue'
4
+
5
+ const props = defineProps({
6
+ notify: {
7
+ type: Array,
8
+ default: () => []
9
+ }
10
+ })
11
+ const emit = defineEmits(['removeNotify', 'goTo'])
12
+ const timers = ref({}) // Store intervals for each notification by id
13
+ const hoveredNotifyId = ref(null)
14
+ const removeNotifyById = id => {
15
+ clearTimer(id)
16
+ emit('removeNotify', id)
17
+ }
18
+
19
+ const goTo = nf => {
20
+ emit('goTo', nf)
21
+ }
22
+ const removeNotifyAfterTimeOut = notify => {
23
+ // Initialize timer object for this notification
24
+ timers.value[notify.id] = {
25
+ intervalId: null,
26
+ remainingTime: notify.timeout,
27
+ pausedAt: Date.now()
28
+ }
29
+
30
+ const timer = timers.value[notify.id]
31
+
32
+ // Update timer every 100ms
33
+ timer.intervalId = setInterval(() => {
34
+ if (timer.pausedAt && timer.remainingTime) {
35
+ const elapsed = Date.now() - timer.pausedAt
36
+ timer.remainingTime = timer.remainingTime - elapsed
37
+ timer.pausedAt = Date.now()
38
+
39
+ if (timer.remainingTime <= 0) {
40
+ emit('removeNotify', notify.id)
41
+ clearTimer(notify.id)
42
+ }
43
+ }
44
+ }, 100)
45
+ }
46
+ const stopTimer = notifyId => {
47
+ const timer = timers.value[notifyId]
48
+ if (!timer || !timer.intervalId) return
49
+
50
+ // Calculate how much time has passed
51
+ const elapsed = Date.now() - timer.pausedAt
52
+ timer.remainingTime = timer.remainingTime - elapsed
53
+
54
+ // Stop interval
55
+ clearInterval(timer.intervalId)
56
+ timer.intervalId = null
57
+ timer.pausedAt = null
58
+ }
59
+ const continueTimer = notifyId => {
60
+ const timer = timers.value[notifyId]
61
+ if (!timer || !timer.remainingTime || timer.remainingTime <= 0) return
62
+
63
+ // Remember when we continued
64
+ timer.pausedAt = Date.now()
65
+
66
+ // Update every 100ms
67
+ timer.intervalId = setInterval(() => {
68
+ if (timer.pausedAt && timer.remainingTime) {
69
+ const elapsed = Date.now() - timer.pausedAt
70
+ timer.remainingTime = timer.remainingTime - elapsed
71
+ timer.pausedAt = Date.now()
72
+
73
+ if (timer.remainingTime <= 0) {
74
+ emit('removeNotify', notifyId)
75
+ clearTimer(notifyId)
76
+ }
77
+ }
78
+ }, 100)
79
+ }
80
+ const clearTimer = notifyId => {
81
+ const timer = timers.value[notifyId]
82
+ if (!timer) return
83
+
84
+ if (timer.intervalId) clearInterval(timer.intervalId)
85
+
86
+ delete timers.value[notifyId]
87
+ }
88
+ const handleGlobalKeydown = event => {
89
+ // Ctrl+A или Cmd+A (Mac)
90
+ if ((event.ctrlKey || event.metaKey) && event.key === 'a' && hoveredNotifyId.value) {
91
+ event.preventDefault()
92
+
93
+ const hoveredCard = document.querySelector(`[data-notify-id="${hoveredNotifyId.value}"]`)
94
+ if (hoveredCard) {
95
+ const textElement = hoveredCard.querySelector('.snack-text')
96
+ if (textElement) {
97
+ const range = document.createRange()
98
+ const selection = window.getSelection()
99
+
100
+ range.selectNodeContents(textElement)
101
+ selection.removeAllRanges()
102
+ selection.addRange(range)
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ onMounted(() => {
109
+ document.addEventListener('keydown', handleGlobalKeydown)
110
+ })
111
+
112
+ onBeforeUnmount(() => {
113
+ document.removeEventListener('keydown', handleGlobalKeydown)
114
+ })
115
+
116
+ watch(
117
+ () => props.notify,
118
+ (newval, oldVal) => {
119
+ if (newval.length > oldVal?.length) {
120
+ // New notifications added
121
+ const newNotifications = newval.filter(n => !timers.value[n.id])
122
+ newNotifications.forEach(v => removeNotifyAfterTimeOut(v))
123
+ }
124
+ },
125
+ { deep: true }
126
+ )
127
+ </script>
128
+ <template>
129
+ <div v-if="props.notify.length" class="f-notify">
130
+ <div
131
+ v-for="nf in props.notify"
132
+ :key="nf.id"
133
+ :data-notify-id="nf.id"
134
+ :style="`border-color: rgb(var(--v-theme-${!nf.color ? 'secondary' : nf.color}))`"
135
+ class="snack"
136
+ @mouseover="hoveredNotifyId = nf.id"
137
+ @mouseleave="
138
+ () => {
139
+ hoveredNotifyId = null
140
+ continueTimer(nf.id)
141
+ }
142
+ "
143
+ @mouseenter="stopTimer(nf.id)"
144
+ >
145
+ <!-- Icon -->
146
+ <div class="icon" :class="`bg-${nf.color || 'secondary'}`">
147
+ <span v-if="nf.color === 'secondary' || nf.color === undefined" class="simple-icon">i</span>
148
+ <FIcon v-if="nf.color === 'success' || nf.color === 'primary'" icon="check" size="16" color="white" />
149
+ <span v-if="nf.color === 'info' || nf.color === 'warning'" class="info-icon">!</span>
150
+ <FIcon v-if="nf.color === 'error' || nf.color === 'danger'" icon="times" size="16" color="white" />
151
+ </div>
152
+
153
+ <!-- Text -->
154
+ <div
155
+ v-if="nf.taskId || (nf.businessObjectKey && nf.businessObjectKeyType && nf.businessObjectDefinitionCode)"
156
+ class="text-subTitle"
157
+ style="overflow-wrap: anywhere"
158
+ >
159
+ <div class="d-flex flex-column">
160
+ <span class="snack-text selectable-text">
161
+ {{ nf.text }}
162
+ </span>
163
+ <span v-if="nf.commentId && nf.taskId" class="link-open-text cursor-pointer" @click.stop="goTo(nf)">
164
+ {{ $t('notification.openDescussion') }}
165
+ </span>
166
+ <span v-else-if="nf.taskId" class="link-open-text cursor-pointer" @click.stop="goTo(nf)">
167
+ {{ $t('notification.openTask') }}
168
+ </span>
169
+ <span
170
+ v-else-if="nf.businessObjectKey && nf.businessObjectKeyType && nf.businessObjectDefinitionCode"
171
+ class="link-open-text cursor-pointer"
172
+ @click.stop="goTo(nf)"
173
+ >
174
+ {{ $t('notification.openDocument') }}
175
+ </span>
176
+ </div>
177
+ </div>
178
+ <div v-else class="text-subTitle" style="overflow-wrap: anywhere">
179
+ <FHtmlContent alowed-links class="snack-text selectable-text" :data="nf.text" />
180
+ </div>
181
+
182
+ <!-- Close btn -->
183
+ <v-tooltip :text="$t('buttons.close')" attach offset="12">
184
+ <template #activator="{ props: tooltipProps }">
185
+ <v-btn class="mb-auto ml-auto" size="20" variant="text" v-bind="tooltipProps" @click="removeNotifyById(nf.id)">
186
+ <FIcon icon="times" color="text" size="0.9em" />
187
+ </v-btn>
188
+ </template>
189
+ </v-tooltip>
190
+ </div>
191
+ </div>
192
+ </template>
193
+
194
+ <style lang="scss" scoped>
195
+ .link-open-text {
196
+ margin: 2px 0;
197
+ color: rgb(var(--v-theme-links));
198
+ text-decoration: underline;
199
+ width: max-content;
200
+ }
201
+ .f-notify {
202
+ position: fixed;
203
+ height: auto;
204
+ max-width: 400px;
205
+ width: 100%;
206
+ bottom: 0;
207
+ right: 20px;
208
+ z-index: 4000;
209
+ display: flex;
210
+ flex-direction: column;
211
+ justify-content: flex-end;
212
+ .snack {
213
+ border-width: 0.5px;
214
+ border-style: solid;
215
+ margin: 10px 0;
216
+ position: relative;
217
+ min-width: 100%;
218
+ width: 100%;
219
+ height: auto;
220
+ border-radius: 10.8px;
221
+ box-shadow: var(--f-box-shadow);
222
+ background: rgb(var(--v-theme-background));
223
+ display: flex;
224
+ align-items: center;
225
+ padding: 12px 12px 12px 20px;
226
+ color: rgb(var(--v-theme-subTitle));
227
+ font-size: 0.95em;
228
+ line-height: 1;
229
+ transition: all 0.5s ease-out;
230
+ outline: none;
231
+ .icon {
232
+ margin-right: 12px;
233
+ margin-top: 0;
234
+ margin-bottom: auto;
235
+ height: 32px;
236
+ min-height: 32px;
237
+ width: 32px;
238
+ min-width: 32px;
239
+ display: flex;
240
+ align-items: center;
241
+ justify-content: center;
242
+ border-radius: 50%;
243
+ -webkit-touch-callout: none;
244
+ -webkit-user-select: none;
245
+ -khtml-user-select: none;
246
+ -moz-user-select: none;
247
+ -ms-user-select: none;
248
+ user-select: none;
249
+ .simple-icon,
250
+ .info-icon {
251
+ color: white;
252
+ font-size: 1.8em;
253
+ }
254
+ }
255
+ }
256
+ }
257
+ </style>
@@ -0,0 +1,163 @@
1
+ <script setup>
2
+ // FPagination
3
+ import { computed, useTemplateRef } from 'vue'
4
+ import { useI18n } from 'vue-i18n'
5
+
6
+ const { t } = useI18n()
7
+
8
+ const props = defineProps({
9
+ length: {
10
+ type: Number,
11
+ default: 1
12
+ },
13
+ total: {
14
+ type: Number,
15
+ default: 0
16
+ },
17
+ itemsPerPageOptions: {
18
+ type: Array,
19
+ default: () => [18, 36, 72, -1],
20
+ validator: value => {
21
+ return value.every(number => typeof number === 'number')
22
+ }
23
+ },
24
+ itemsPerPageText: {
25
+ type: String,
26
+ default: ''
27
+ }
28
+ })
29
+
30
+ const page = defineModel('page', {
31
+ type: Number,
32
+ default: 1
33
+ })
34
+ const itemsPerPage = defineModel('itemsPerPage', {
35
+ type: Number,
36
+ default: 18
37
+ })
38
+
39
+ const itemCountBtnRef = useTemplateRef('item-count-btn')
40
+
41
+ const itemsCountLabel = computed(() => {
42
+ const label = props.itemsPerPageText || t('pagination.itemsPerPage')
43
+ const count = itemsPerPage.value === -1 || props.length === 1 ? t('pagination.all') : itemsPerPage.value
44
+ return `${label} ${count} ${t('pagination.of')} ${props.total}`
45
+ })
46
+
47
+ const offset = computed(() => {
48
+ return itemCountBtnRef.value ? -itemCountBtnRef.value.$el.offsetWidth : 0
49
+ })
50
+
51
+ const changeItemsPerPage = number => {
52
+ itemsPerPage.value = number
53
+ page.value = 1
54
+ }
55
+ </script>
56
+
57
+ <template>
58
+ <div class="f-pagination d-flex">
59
+ <!-- Pagination -->
60
+ <v-pagination
61
+ v-if="itemsPerPage !== -1 && length > 1"
62
+ v-model="page"
63
+ :length="length"
64
+ :total-visible="7"
65
+ color="secondary"
66
+ class="ml-auto"
67
+ next-icon="chevron-right bg-secondary"
68
+ prev-icon="chevron-left bg-secondary"
69
+ :style="`margin-right: ${offset}px`"
70
+ />
71
+
72
+ <!-- Items Per Page -->
73
+ <div class="d-flex flex-column flex-end ml-auto f-pagination--items-per-page">
74
+ <span v-if="!length" class="text-secondary f-pagination--items-per-page-text">
75
+ {{ props.itemsPerPageText || t('pagination.itemsPerPage') }}: {{ $t('pagination.all') }}
76
+ </span>
77
+
78
+ <v-menu v-else>
79
+ <template #activator="{ props: propsMenu }">
80
+ <v-btn v-bind="propsMenu" ref="item-count-btn" variant="text" height="22" color="secondary" class="pa-0 f-pagination--item-count-btn">
81
+ {{ itemsCountLabel }}
82
+ <FIcon icon="chevron-down" color="secondary" size="16" class="ml-1" />
83
+ </v-btn>
84
+ </template>
85
+
86
+ <v-list>
87
+ <v-list-item v-for="(number, idx) in itemsPerPageOptions" :key="idx" :active="number === itemsPerPage" @click="changeItemsPerPage(number)">
88
+ <v-list-item-title>
89
+ {{ number === -1 ? $t('pagination.all') : number }}
90
+ </v-list-item-title>
91
+ </v-list-item>
92
+ </v-list>
93
+ </v-menu>
94
+ </div>
95
+ </div>
96
+ </template>
97
+
98
+ <style lang="scss" scoped>
99
+ .f-pagination {
100
+ .v-pagination {
101
+ :deep(.v-pagination__list) {
102
+ .v-pagination__item,
103
+ .v-pagination__first,
104
+ .v-pagination__prev,
105
+ .v-pagination__next,
106
+ .v-pagination__last {
107
+ margin: 0;
108
+ .v-btn {
109
+ min-width: 22px;
110
+ width: 22px;
111
+ height: 22px;
112
+ border-radius: 4px;
113
+ }
114
+ }
115
+ .v-pagination__prev,
116
+ .v-pagination__next {
117
+ .v-btn {
118
+ border: 1px solid rgb(var(--v-theme-secondary));
119
+ }
120
+ .f-icon {
121
+ min-height: 12px;
122
+ min-width: 12px;
123
+ width: 12px;
124
+ height: 12px;
125
+ }
126
+ }
127
+ .v-pagination__next {
128
+ margin-left: 12px;
129
+ }
130
+ .v-pagination__prev {
131
+ margin-right: 12px;
132
+ }
133
+ .v-pagination__item {
134
+ margin: 0 2px;
135
+ .v-btn {
136
+ font-size: 0.9em;
137
+ }
138
+ &.v-pagination__item--is-active {
139
+ .v-btn {
140
+ background: rgb(var(--v-theme-secondary));
141
+ .v-btn__content {
142
+ color: white;
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ .f-pagination--items-per-page {
150
+ .f-pagination--items-per-page-text {
151
+ line-height: 22px;
152
+ }
153
+ .f-pagination--item-count-btn {
154
+ margin-left: -1px;
155
+ }
156
+ .v-list-item--active {
157
+ .v-list-item-title {
158
+ font-weight: 500;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ </style>
@@ -0,0 +1,105 @@
1
+ <script setup>
2
+ // FPreLoader
3
+ const props = defineProps({
4
+ preLoaders: {
5
+ type: Array,
6
+ default: () => []
7
+ }
8
+ })
9
+ </script>
10
+
11
+ <template>
12
+ <v-overlay :model-value="!!props.preLoaders.length" persistent z-index="1005" opacity="0.5" class="f-preloader">
13
+ <div v-if="props.preLoaders.includes('tokenUpdate')" class="text-title">
14
+ {{ $t('tokenRefresh') }}
15
+ </div>
16
+ <div class="f-preloader-lds-ellipsis">
17
+ <div></div>
18
+ <div></div>
19
+ <div></div>
20
+ <div></div>
21
+ </div>
22
+ </v-overlay>
23
+ </template>
24
+
25
+ <style lang="scss" scoped>
26
+ .f-preloader {
27
+ display: flex;
28
+ flex-direction: column;
29
+ align-items: center;
30
+ justify-content: center;
31
+ :deep(.v-overlay__scrim) {
32
+ background: rgb(var(--v-theme-background)) !important;
33
+ }
34
+ :deep(.v-overlay__content) {
35
+ display: flex;
36
+ flex-direction: column;
37
+ align-items: center;
38
+ justify-content: center;
39
+ }
40
+ }
41
+
42
+ .f-preloader-lds-ellipsis {
43
+ display: inline-block;
44
+ position: relative;
45
+ width: 80px;
46
+ height: 80px;
47
+ }
48
+
49
+ .f-preloader-lds-ellipsis div {
50
+ position: absolute;
51
+ top: 33px;
52
+ width: 13px;
53
+ height: 13px;
54
+ border-radius: 50%;
55
+ background: rgb(var(--v-theme-primary));
56
+ animation-timing-function: cubic-bezier(0, 1, 1, 0);
57
+ }
58
+
59
+ .f-preloader-lds-ellipsis div:nth-child(1) {
60
+ left: 8px;
61
+ animation: lds-ellipsis1 0.6s infinite;
62
+ }
63
+
64
+ .f-preloader-lds-ellipsis div:nth-child(2) {
65
+ left: 8px;
66
+ animation: lds-ellipsis2 0.6s infinite;
67
+ }
68
+
69
+ .f-preloader-lds-ellipsis div:nth-child(3) {
70
+ left: 32px;
71
+ animation: lds-ellipsis2 0.6s infinite;
72
+ }
73
+
74
+ .f-preloader-lds-ellipsis div:nth-child(4) {
75
+ left: 56px;
76
+ animation: lds-ellipsis3 0.6s infinite;
77
+ }
78
+
79
+ @keyframes lds-ellipsis1 {
80
+ 0% {
81
+ transform: scale(0);
82
+ }
83
+ 100% {
84
+ transform: scale(1);
85
+ }
86
+ }
87
+
88
+ @keyframes lds-ellipsis3 {
89
+ 0% {
90
+ transform: scale(1);
91
+ }
92
+ 100% {
93
+ transform: scale(0);
94
+ }
95
+ }
96
+
97
+ @keyframes lds-ellipsis2 {
98
+ 0% {
99
+ transform: translate(0, 0);
100
+ }
101
+ 100% {
102
+ transform: translate(24px, 0);
103
+ }
104
+ }
105
+ </style>
@@ -0,0 +1,191 @@
1
+ <script setup>
2
+ // FSearchPanel
3
+ import { ref, watch, useTemplateRef } from 'vue'
4
+ import { useDebounceFn, useEventListener } from '@vueuse/core'
5
+
6
+ const props = defineProps({
7
+ disabled: {
8
+ type: Boolean,
9
+ default: false
10
+ },
11
+ color: {
12
+ type: String,
13
+ default: 'text'
14
+ },
15
+ background: {
16
+ type: String,
17
+ default: 'background'
18
+ },
19
+ outlined: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ searchOnBlur: {
24
+ type: Boolean,
25
+ default: false
26
+ },
27
+ tooltipProps: {
28
+ type: Object,
29
+ default: () => ({ location: 'top' })
30
+ },
31
+ ctrlF: {
32
+ type: Boolean,
33
+ default: false
34
+ }
35
+ })
36
+
37
+ const modelValue = defineModel({
38
+ type: String,
39
+ default: null
40
+ })
41
+
42
+ const search = ref(null)
43
+
44
+ const updateModelValue = useDebounceFn(value => {
45
+ if (modelValue.value === value) return
46
+ modelValue.value = value
47
+ }, 300)
48
+
49
+ const searchInputRef = useTemplateRef('search-input')
50
+ useEventListener('keydown', e => {
51
+ if (!props.ctrlF) return
52
+
53
+ // Focus the search input when Ctrl+F or Cmd+F is pressed
54
+ if ((e.ctrlKey || e.metaKey) && e.key === 'f') {
55
+ e.preventDefault()
56
+ searchInputRef.value?.focus()
57
+ }
58
+ })
59
+
60
+ watch(
61
+ modelValue,
62
+ val => {
63
+ if (val === search.value) return
64
+ search.value = val
65
+ },
66
+ { immediate: true }
67
+ )
68
+
69
+ watch(search, v => {
70
+ if (props.searchOnBlur) return
71
+ updateModelValue(v)
72
+ })
73
+
74
+ const blurHandler = () => {
75
+ updateModelValue(search.value)
76
+ }
77
+
78
+ const keydownEnter = () => {
79
+ searchInputRef.value?.blur()
80
+ updateModelValue(search.value)
81
+ }
82
+
83
+ const keydownEsc = () => {
84
+ searchInputRef.value?.blur()
85
+ }
86
+ </script>
87
+
88
+ <template>
89
+ <div class="f-search-panel">
90
+ <v-text-field
91
+ ref="search-input"
92
+ v-model.trim="search"
93
+ clearable
94
+ :disabled="disabled"
95
+ :bg-color="background"
96
+ :class="{ 'is-outlined': outlined }"
97
+ @blur="blurHandler"
98
+ @keydown.esc.stop.prevent="keydownEsc"
99
+ @keydown.enter="keydownEnter"
100
+ >
101
+ <template #prepend-inner>
102
+ <v-tooltip :disabled="disabled" :text="$t('tooltip.search')" v-bind="tooltipProps">
103
+ <template #activator="{ props: propsTooltip }">
104
+ <FIcon icon="search" :color="color" v-bind="propsTooltip" />
105
+ </template>
106
+ </v-tooltip>
107
+ </template>
108
+ </v-text-field>
109
+
110
+ <!-- Global search -->
111
+ <slot name="globalSearch"></slot>
112
+ </div>
113
+ </template>
114
+
115
+ <style lang="scss" scoped>
116
+ .f-search-panel {
117
+ position: relative;
118
+ min-height: 30px;
119
+ width: auto;
120
+ :deep(.f-input) {
121
+ height: 30px;
122
+ width: 30px;
123
+ transition: all 0.2s ease-in-out;
124
+ .v-input__control {
125
+ background-color: transparent;
126
+ }
127
+ &.v-input--focused {
128
+ .v-field__prepend-inner {
129
+ margin-left: 0px;
130
+ cursor: default;
131
+ .f-icon {
132
+ background: rgb(var(--v-theme-primary)) !important;
133
+ }
134
+ }
135
+ }
136
+ &.v-input--focused,
137
+ &.v-input--dirty {
138
+ width: 250px;
139
+ max-width: 250px;
140
+ .f-icon {
141
+ background: rgb(var(--v-theme-text)) !important;
142
+ }
143
+ }
144
+
145
+ &:not(.is-outlined) {
146
+ background: transparent !important;
147
+ .v-field__prepend-inner {
148
+ cursor: pointer;
149
+ margin-left: -6px;
150
+ }
151
+ .v-field {
152
+ background: transparent !important;
153
+ .v-field__outline__start,
154
+ .v-field__outline__notch,
155
+ .v-field__outline__end {
156
+ border-color: transparent;
157
+ }
158
+ }
159
+ &.v-input--dirty,
160
+ &.v-input--focused {
161
+ background: rgb(var(--v-theme-background)) !important;
162
+ }
163
+ }
164
+ &.is-outlined {
165
+ &:not(.v-input--dirty, .v-input--focused) {
166
+ background: transparent !important;
167
+ .v-field__prepend-inner {
168
+ cursor: pointer;
169
+ margin-left: -6px;
170
+ }
171
+ .v-field {
172
+ background: transparent !important;
173
+ .v-field__outline__start,
174
+ .v-field__outline__notch,
175
+ .v-field__outline__end {
176
+ border-color: transparent;
177
+ }
178
+ }
179
+ }
180
+ }
181
+
182
+ .v-field {
183
+ .v-field__input {
184
+ padding-left: 8px;
185
+ padding-top: 8px;
186
+ padding-bottom: 4px;
187
+ }
188
+ }
189
+ }
190
+ }
191
+ </style>