@it-enterprise/forcebpm-ui-kit 1.0.2-beta.4 → 1.0.2-beta.6
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/index.js +2 -0
- package/package.json +9 -1
- package/src/FNoData.vue +60 -0
- package/src/FNotify.vue +258 -0
package/index.js
CHANGED
|
@@ -2,3 +2,5 @@ export { default as FHtmlContent } from './src/FHtmlContent.vue'
|
|
|
2
2
|
export { default as FAvatar } from './src/FAvatar.vue'
|
|
3
3
|
export { default as FConfirmModal } from './src/FConfirmModal.vue'
|
|
4
4
|
export { default as FPreLoader } from './src/FPreLoader.vue'
|
|
5
|
+
export { default as FNoData } from './src/FNoData.vue'
|
|
6
|
+
export { default as FNotify } from './src/FNotify.vue'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@it-enterprise/forcebpm-ui-kit",
|
|
3
|
-
"version": "1.0.2-beta.
|
|
3
|
+
"version": "1.0.2-beta.6",
|
|
4
4
|
"description": "FBPM UI Kit",
|
|
5
5
|
"author": "it-enterprise",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
"./FPreLoader": {
|
|
27
27
|
"import": "./src/FPreLoader.vue",
|
|
28
28
|
"require": "./src/FPreLoader.vue"
|
|
29
|
+
},
|
|
30
|
+
"./FNoData": {
|
|
31
|
+
"import": "./src/FNoData.vue",
|
|
32
|
+
"require": "./src/FNoData.vue"
|
|
33
|
+
},
|
|
34
|
+
"./FNotify": {
|
|
35
|
+
"import": "./src/FNotify.vue",
|
|
36
|
+
"require": "./src/FNotify.vue"
|
|
29
37
|
}
|
|
30
38
|
},
|
|
31
39
|
"files": [
|
package/src/FNoData.vue
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// FNoData
|
|
3
|
+
defineProps({
|
|
4
|
+
text: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: null
|
|
7
|
+
},
|
|
8
|
+
height: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: '100%',
|
|
11
|
+
validator: value => {
|
|
12
|
+
return /^(calc\([^()]+\)|\d+(\.\d+)?(px|em|rem|vh|vw|%)|auto)$/.test(value)
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
width: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'auto',
|
|
18
|
+
validator: value => {
|
|
19
|
+
return /^(calc\([^()]+\)|\d+(\.\d+)?(px|em|rem|vh|vw|%)|auto)$/.test(value)
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
gradient: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: ''
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<div class="f-no-data" :style="`height: ${height}; width: ${width}`">
|
|
32
|
+
<div class="f-no-data-overlay" :style="`background: ${gradient}`">
|
|
33
|
+
<span class="f-no-data-text">{{ text || $t('noData.title') }}</span>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<style lang="scss" scoped>
|
|
39
|
+
.f-no-data {
|
|
40
|
+
min-height: 150px;
|
|
41
|
+
position: relative;
|
|
42
|
+
.f-no-data-overlay {
|
|
43
|
+
position: absolute;
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
text-align: center;
|
|
49
|
+
height: 100%;
|
|
50
|
+
width: 100%;
|
|
51
|
+
color: rgb(var(--v-theme-primary));
|
|
52
|
+
top: calc(50% - 100% / 2);
|
|
53
|
+
left: calc(50% - 100% / 2);
|
|
54
|
+
font-size: 1em;
|
|
55
|
+
.f-no-data-text {
|
|
56
|
+
width: 250px;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</style>
|
package/src/FNotify.vue
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// FNotify
|
|
3
|
+
import { computed, ref, onBeforeUnmount, onMounted, watch, defineAsyncComponent, defineEmits } from 'vue'
|
|
4
|
+
const FHtmlContent = defineAsyncComponent(() => import('./FHtmlContent'))
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
notify: {
|
|
8
|
+
type: Array,
|
|
9
|
+
default: () => []
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
const emit = defineEmits(['removeNotify', 'goToL'])
|
|
13
|
+
const timers = ref({}) // Store intervals for each notification by id
|
|
14
|
+
const hoveredNotifyId = ref(null)
|
|
15
|
+
const removeNotifyById = id => {
|
|
16
|
+
clearTimer(id)
|
|
17
|
+
emit('removeNotify', id)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const goToL = nf => {
|
|
21
|
+
emit('goToL', nf)
|
|
22
|
+
}
|
|
23
|
+
const removeNotifyAfterTimeOut = notify => {
|
|
24
|
+
// Initialize timer object for this notification
|
|
25
|
+
timers.value[notify.id] = {
|
|
26
|
+
intervalId: null,
|
|
27
|
+
remainingTime: notify.timeout,
|
|
28
|
+
pausedAt: Date.now()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const timer = timers.value[notify.id]
|
|
32
|
+
|
|
33
|
+
// Update timer every 100ms
|
|
34
|
+
timer.intervalId = setInterval(() => {
|
|
35
|
+
if (timer.pausedAt && timer.remainingTime) {
|
|
36
|
+
const elapsed = Date.now() - timer.pausedAt
|
|
37
|
+
timer.remainingTime = timer.remainingTime - elapsed
|
|
38
|
+
timer.pausedAt = Date.now()
|
|
39
|
+
|
|
40
|
+
if (timer.remainingTime <= 0) {
|
|
41
|
+
emit('removeNotify', notify.id)
|
|
42
|
+
clearTimer(notify.id)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, 100)
|
|
46
|
+
}
|
|
47
|
+
const stopTimer = notifyId => {
|
|
48
|
+
const timer = timers.value[notifyId]
|
|
49
|
+
if (!timer || !timer.intervalId) return
|
|
50
|
+
|
|
51
|
+
// Calculate how much time has passed
|
|
52
|
+
const elapsed = Date.now() - timer.pausedAt
|
|
53
|
+
timer.remainingTime = timer.remainingTime - elapsed
|
|
54
|
+
|
|
55
|
+
// Stop interval
|
|
56
|
+
clearInterval(timer.intervalId)
|
|
57
|
+
timer.intervalId = null
|
|
58
|
+
timer.pausedAt = null
|
|
59
|
+
}
|
|
60
|
+
const continueTimer = notifyId => {
|
|
61
|
+
const timer = timers.value[notifyId]
|
|
62
|
+
if (!timer || !timer.remainingTime || timer.remainingTime <= 0) return
|
|
63
|
+
|
|
64
|
+
// Remember when we continued
|
|
65
|
+
timer.pausedAt = Date.now()
|
|
66
|
+
|
|
67
|
+
// Update every 100ms
|
|
68
|
+
timer.intervalId = setInterval(() => {
|
|
69
|
+
if (timer.pausedAt && timer.remainingTime) {
|
|
70
|
+
const elapsed = Date.now() - timer.pausedAt
|
|
71
|
+
timer.remainingTime = timer.remainingTime - elapsed
|
|
72
|
+
timer.pausedAt = Date.now()
|
|
73
|
+
|
|
74
|
+
if (timer.remainingTime <= 0) {
|
|
75
|
+
emit('removeNotify', notifyId)
|
|
76
|
+
clearTimer(notifyId)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, 100)
|
|
80
|
+
}
|
|
81
|
+
const clearTimer = notifyId => {
|
|
82
|
+
const timer = timers.value[notifyId]
|
|
83
|
+
if (!timer) return
|
|
84
|
+
|
|
85
|
+
if (timer.intervalId) clearInterval(timer.intervalId)
|
|
86
|
+
|
|
87
|
+
delete timers.value[notifyId]
|
|
88
|
+
}
|
|
89
|
+
const handleGlobalKeydown = event => {
|
|
90
|
+
// Ctrl+A или Cmd+A (Mac)
|
|
91
|
+
if ((event.ctrlKey || event.metaKey) && event.key === 'a' && hoveredNotifyId.value) {
|
|
92
|
+
event.preventDefault()
|
|
93
|
+
|
|
94
|
+
const hoveredCard = document.querySelector(`[data-notify-id="${hoveredNotifyId.value}"]`)
|
|
95
|
+
if (hoveredCard) {
|
|
96
|
+
const textElement = hoveredCard.querySelector('.snack-text')
|
|
97
|
+
if (textElement) {
|
|
98
|
+
const range = document.createRange()
|
|
99
|
+
const selection = window.getSelection()
|
|
100
|
+
|
|
101
|
+
range.selectNodeContents(textElement)
|
|
102
|
+
selection.removeAllRanges()
|
|
103
|
+
selection.addRange(range)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
onMounted(() => {
|
|
110
|
+
document.addEventListener('keydown', handleGlobalKeydown)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
onBeforeUnmount(() => {
|
|
114
|
+
document.removeEventListener('keydown', handleGlobalKeydown)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
watch(
|
|
118
|
+
notify,
|
|
119
|
+
(newval, oldVal) => {
|
|
120
|
+
if (newval.length > oldVal.length) {
|
|
121
|
+
// New notifications added
|
|
122
|
+
const newNotifications = newval.filter(n => !timers.value[n.id])
|
|
123
|
+
newNotifications.forEach(v => removeNotifyAfterTimeOut(v))
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{ deep: true }
|
|
127
|
+
)
|
|
128
|
+
</script>
|
|
129
|
+
<template>
|
|
130
|
+
<div v-if="notify.length" class="f-notify">
|
|
131
|
+
<div
|
|
132
|
+
v-for="nf in notify"
|
|
133
|
+
:key="nf.id"
|
|
134
|
+
:data-notify-id="nf.id"
|
|
135
|
+
:style="`border-color: rgb(var(--v-theme-${!nf.color ? 'secondary' : nf.color}))`"
|
|
136
|
+
class="snack"
|
|
137
|
+
@mouseover="hoveredNotifyId = nf.id"
|
|
138
|
+
@mouseleave="
|
|
139
|
+
() => {
|
|
140
|
+
hoveredNotifyId = null
|
|
141
|
+
continueTimer(nf.id)
|
|
142
|
+
}
|
|
143
|
+
"
|
|
144
|
+
@mouseenter="stopTimer(nf.id)"
|
|
145
|
+
>
|
|
146
|
+
<!-- Icon -->
|
|
147
|
+
<div class="icon" :class="`bg-${nf.color || 'secondary'}`">
|
|
148
|
+
<span v-if="nf.color === 'secondary' || nf.color === undefined" class="simple-icon">i</span>
|
|
149
|
+
<FIcon v-if="nf.color === 'success' || nf.color === 'primary'" icon="check" size="16" color="white" />
|
|
150
|
+
<span v-if="nf.color === 'info'" class="info-icon">!</span>
|
|
151
|
+
<FIcon v-if="nf.color === 'error' || nf.color === 'danger'" icon="times" size="16" color="white" />
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<!-- Text -->
|
|
155
|
+
<div
|
|
156
|
+
v-if="nf.taskId || (nf.businessObjectKey && nf.businessObjectKeyType && nf.businessObjectDefinitionCode)"
|
|
157
|
+
class="text-subTitle"
|
|
158
|
+
style="overflow-wrap: anywhere"
|
|
159
|
+
>
|
|
160
|
+
<div class="d-flex flex-column">
|
|
161
|
+
<span class="snack-text selectable-text">
|
|
162
|
+
{{ nf.text }}
|
|
163
|
+
</span>
|
|
164
|
+
<span v-if="nf.commentId && nf.taskId" class="link-open-text cursor-pointer" @click.stop="goToL(nf)">
|
|
165
|
+
{{ $t('notification.openDescussion') }}
|
|
166
|
+
</span>
|
|
167
|
+
<span v-else-if="nf.taskId" class="link-open-text cursor-pointer" @click.stop="goToL(nf)">
|
|
168
|
+
{{ $t('notification.openTask') }}
|
|
169
|
+
</span>
|
|
170
|
+
<span
|
|
171
|
+
v-else-if="nf.businessObjectKey && nf.businessObjectKeyType && nf.businessObjectDefinitionCode"
|
|
172
|
+
class="link-open-text cursor-pointer"
|
|
173
|
+
@click.stop="goToL(nf)"
|
|
174
|
+
>
|
|
175
|
+
{{ $t('notification.openDocument') }}
|
|
176
|
+
</span>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
<div v-else class="text-subTitle" style="overflow-wrap: anywhere">
|
|
180
|
+
<FHtmlContent alowed-links class="snack-text selectable-text" :data="nf.text" />
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<!-- Close btn -->
|
|
184
|
+
<v-tooltip :text="$t('buttons.close')" attach offset="12">
|
|
185
|
+
<template #activator="{ props: tooltipProps }">
|
|
186
|
+
<v-btn class="mb-auto ml-auto" size="20" variant="text" v-bind="tooltipProps" @click="removeNotifyById(nf.id)">
|
|
187
|
+
<FIcon icon="times" color="text" size="0.9em" />
|
|
188
|
+
</v-btn>
|
|
189
|
+
</template>
|
|
190
|
+
</v-tooltip>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</template>
|
|
194
|
+
|
|
195
|
+
<style lang="scss" scoped>
|
|
196
|
+
.link-open-text {
|
|
197
|
+
margin: 2px 0;
|
|
198
|
+
color: rgb(var(--v-theme-links));
|
|
199
|
+
text-decoration: underline;
|
|
200
|
+
width: max-content;
|
|
201
|
+
}
|
|
202
|
+
.f-notify {
|
|
203
|
+
position: fixed;
|
|
204
|
+
height: auto;
|
|
205
|
+
max-width: 400px;
|
|
206
|
+
width: 100%;
|
|
207
|
+
bottom: 0;
|
|
208
|
+
right: 20px;
|
|
209
|
+
z-index: 4000;
|
|
210
|
+
display: flex;
|
|
211
|
+
flex-direction: column;
|
|
212
|
+
justify-content: flex-end;
|
|
213
|
+
.snack {
|
|
214
|
+
border-width: 0.5px;
|
|
215
|
+
border-style: solid;
|
|
216
|
+
margin: 10px 0;
|
|
217
|
+
position: relative;
|
|
218
|
+
min-width: 100%;
|
|
219
|
+
width: 100%;
|
|
220
|
+
height: auto;
|
|
221
|
+
border-radius: 10.8px;
|
|
222
|
+
box-shadow: var(--f-box-shadow);
|
|
223
|
+
background: rgb(var(--v-theme-background));
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
padding: 12px 12px 12px 20px;
|
|
227
|
+
color: rgb(var(--v-theme-subTitle));
|
|
228
|
+
font-size: 0.95em;
|
|
229
|
+
line-height: 1;
|
|
230
|
+
transition: all 0.5s ease-out;
|
|
231
|
+
outline: none;
|
|
232
|
+
.icon {
|
|
233
|
+
margin-right: 12px;
|
|
234
|
+
margin-top: 0;
|
|
235
|
+
margin-bottom: auto;
|
|
236
|
+
height: 32px;
|
|
237
|
+
min-height: 32px;
|
|
238
|
+
width: 32px;
|
|
239
|
+
min-width: 32px;
|
|
240
|
+
display: flex;
|
|
241
|
+
align-items: center;
|
|
242
|
+
justify-content: center;
|
|
243
|
+
border-radius: 50%;
|
|
244
|
+
-webkit-touch-callout: none;
|
|
245
|
+
-webkit-user-select: none;
|
|
246
|
+
-khtml-user-select: none;
|
|
247
|
+
-moz-user-select: none;
|
|
248
|
+
-ms-user-select: none;
|
|
249
|
+
user-select: none;
|
|
250
|
+
.simple-icon,
|
|
251
|
+
.info-icon {
|
|
252
|
+
color: white;
|
|
253
|
+
font-size: 1.8em;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
</style>
|