codevdesign 1.0.46 → 1.0.47
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/composants/csqcSnackbar.vue +207 -88
- package/composants/csqcTable/csqcTable.vue +537 -537
- package/package.json +1 -1
|
@@ -1,88 +1,207 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
FIFO Snackbar
|
|
4
|
+
- On affiche 1 snackbar à la fois.
|
|
5
|
+
- Les demandes suivantes sont mises en file (FIFO) et s’affichent après fermeture.
|
|
6
|
+
- color/location sont figées par item via props (pas via $attrs) pour éviter les changements live.
|
|
7
|
+
-->
|
|
8
|
+
<v-snackbar
|
|
9
|
+
:model-value="snackbar"
|
|
10
|
+
v-bind="attrsAffiches"
|
|
11
|
+
:timeout="-1"
|
|
12
|
+
:style="props.styleCss"
|
|
13
|
+
:color="colorAffiche"
|
|
14
|
+
:location="locationAffiche"
|
|
15
|
+
multi-line
|
|
16
|
+
@update:model-value="
|
|
17
|
+
v => {
|
|
18
|
+
if (!v) fermer()
|
|
19
|
+
}
|
|
20
|
+
"
|
|
21
|
+
>
|
|
22
|
+
<template v-if="titreAffiche || messageAffiche">
|
|
23
|
+
<b style="font-size: 12pt">{{ titreAffiche }}</b>
|
|
24
|
+
<br v-if="titreAffiche" />
|
|
25
|
+
<b>{{ messageAffiche }}</b>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<template #actions>
|
|
29
|
+
<!-- Toujours afficher la fermeture si timeout = -1 -->
|
|
30
|
+
<v-icon
|
|
31
|
+
v-if="props.btnFermer || timeoutAffiche === -1"
|
|
32
|
+
color="white"
|
|
33
|
+
style="cursor: pointer"
|
|
34
|
+
@click.stop="fermer"
|
|
35
|
+
>
|
|
36
|
+
mdi-close
|
|
37
|
+
</v-icon>
|
|
38
|
+
</template>
|
|
39
|
+
</v-snackbar>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { computed, ref, watch, useAttrs, toRaw } from 'vue'
|
|
44
|
+
|
|
45
|
+
// - color/location sont en props (et non via $attrs) pour être snapshottées proprement.
|
|
46
|
+
const props = defineProps({
|
|
47
|
+
styleCss: { type: String, required: false },
|
|
48
|
+
|
|
49
|
+
// Durée d’affichage (ms). -1 = ne ferme jamais automatiquement
|
|
50
|
+
temps: { type: Number, required: false, default: 4000 },
|
|
51
|
+
|
|
52
|
+
// Déclencheur : à chaque changement non-vide, on queue un item
|
|
53
|
+
message: { type: String, required: true },
|
|
54
|
+
titre: { type: String, required: false },
|
|
55
|
+
|
|
56
|
+
btnFermer: { type: Boolean, required: false, default: true },
|
|
57
|
+
|
|
58
|
+
// en props pour éviter le "live update" via $attrs
|
|
59
|
+
color: { type: String, required: false, default: 'success' },
|
|
60
|
+
location: { type: [String, Array, Object] as any, required: false },
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const emit = defineEmits(['fermer:snackbar'])
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* ============================================================================
|
|
67
|
+
* $attrs : on forward tout sauf color/location (qui sont gérés par props & snapshot)
|
|
68
|
+
* ============================================================================
|
|
69
|
+
*/
|
|
70
|
+
const attrs = useAttrs()
|
|
71
|
+
|
|
72
|
+
const attrsSansCouleur = computed(() => {
|
|
73
|
+
const { color, location, ...rest } = attrs as any
|
|
74
|
+
return rest
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* ============================================================================
|
|
79
|
+
* FIFO Queue (snapshot par item)
|
|
80
|
+
* ============================================================================
|
|
81
|
+
*/
|
|
82
|
+
type ItemSnack = {
|
|
83
|
+
message: string
|
|
84
|
+
titre?: string
|
|
85
|
+
color: string
|
|
86
|
+
location?: any
|
|
87
|
+
attrs: Record<string, any>
|
|
88
|
+
timeout: number // -1 = manuel
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const file = ref<ItemSnack[]>([])
|
|
92
|
+
const enCours = ref<ItemSnack | null>(null)
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* ============================================================================
|
|
96
|
+
* État UI
|
|
97
|
+
* ============================================================================
|
|
98
|
+
*/
|
|
99
|
+
const snackbar = ref(false)
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* ============================================================================
|
|
103
|
+
* Computeds d’affichage (basés sur l’item en cours)
|
|
104
|
+
* ============================================================================
|
|
105
|
+
*/
|
|
106
|
+
const attrsAffiches = computed(() => {
|
|
107
|
+
// On évite de forward color/location par attrs (même s’ils y étaient)
|
|
108
|
+
const a = (enCours.value?.attrs ?? {}) as any
|
|
109
|
+
const { color, location, ...rest } = a
|
|
110
|
+
return rest
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
const messageAffiche = computed(() => enCours.value?.message ?? '')
|
|
114
|
+
const titreAffiche = computed(() => enCours.value?.titre ?? '')
|
|
115
|
+
const colorAffiche = computed(() => enCours.value?.color ?? 'success')
|
|
116
|
+
const locationAffiche = computed(() => enCours.value?.location)
|
|
117
|
+
const timeoutAffiche = computed(() => enCours.value?.timeout ?? props.temps)
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* ============================================================================
|
|
121
|
+
* Timer (auto-close géré par nous, puisque v-snackbar est timeout=-1)
|
|
122
|
+
* ============================================================================
|
|
123
|
+
*/
|
|
124
|
+
let timer: number | null = null
|
|
125
|
+
|
|
126
|
+
function clearTimer() {
|
|
127
|
+
if (timer != null) {
|
|
128
|
+
window.clearTimeout(timer)
|
|
129
|
+
timer = null
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function scheduleAutoClose() {
|
|
134
|
+
clearTimer()
|
|
135
|
+
|
|
136
|
+
const t = timeoutAffiche.value
|
|
137
|
+
if (t === -1) return
|
|
138
|
+
|
|
139
|
+
// 1 seconde minimum, sinon on ne la voit pas
|
|
140
|
+
const ms = Math.max(1000, t)
|
|
141
|
+
|
|
142
|
+
timer = window.setTimeout(() => {
|
|
143
|
+
fermer()
|
|
144
|
+
}, ms)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* ============================================================================
|
|
149
|
+
* Navigation FIFO
|
|
150
|
+
* ============================================================================
|
|
151
|
+
*/
|
|
152
|
+
function afficherProchain() {
|
|
153
|
+
// Un seul snackbar à la fois
|
|
154
|
+
if (snackbar.value) return
|
|
155
|
+
if (enCours.value) return
|
|
156
|
+
|
|
157
|
+
const next = file.value.shift()
|
|
158
|
+
if (!next) return
|
|
159
|
+
|
|
160
|
+
enCours.value = next
|
|
161
|
+
snackbar.value = true
|
|
162
|
+
scheduleAutoClose()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function fermer() {
|
|
166
|
+
clearTimer()
|
|
167
|
+
snackbar.value = false
|
|
168
|
+
emit('fermer:snackbar')
|
|
169
|
+
|
|
170
|
+
// On attend un tick pour éviter les glitches (transition/DOM)
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
enCours.value = null
|
|
173
|
+
afficherProchain()
|
|
174
|
+
}, 0)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* ============================================================================
|
|
179
|
+
* queue (snapshot) à chaque nouveau message
|
|
180
|
+
* ============================================================================
|
|
181
|
+
*/
|
|
182
|
+
watch(
|
|
183
|
+
() => props.message,
|
|
184
|
+
nouveau => {
|
|
185
|
+
if (!nouveau) return
|
|
186
|
+
|
|
187
|
+
// Normalisation timeout
|
|
188
|
+
const timeout = props.temps < -1 ? -1 : props.temps >= 0 && props.temps < 1000 ? 1000 : props.temps
|
|
189
|
+
|
|
190
|
+
file.value.push({
|
|
191
|
+
message: String(nouveau),
|
|
192
|
+
titre: props.titre ? String(props.titre) : undefined,
|
|
193
|
+
|
|
194
|
+
// ✅ Primitives + props => stable (pas de "live update")
|
|
195
|
+
color: String(props.color ?? 'success'),
|
|
196
|
+
location: props.location,
|
|
197
|
+
|
|
198
|
+
// On forward les autres attrs (snapshot) : variant, rounded, etc.
|
|
199
|
+
attrs: structuredClone(toRaw(attrsSansCouleur.value)),
|
|
200
|
+
|
|
201
|
+
timeout,
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
afficherProchain()
|
|
205
|
+
},
|
|
206
|
+
)
|
|
207
|
+
</script>
|