codevdesign 0.0.61 → 0.0.63

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.
@@ -1,158 +1,158 @@
1
- <template>
2
- <v-row dense>
3
- <v-col
4
- v-if="afficherChampFr"
5
- cols="12"
6
- >
7
- <label
8
- v-if="!libelleInterieur"
9
- :for="`saisieChampFr-${cleTradFr}`"
10
- :class="{ libelle: true, required: estRequis }"
11
- >{{ $t(cleTradFr) }}</label
12
- >
13
- <v-textarea
14
- v-if="textarea"
15
- :id="`saisieChampFr-${cleTradFr}`"
16
- v-model="model[champs.Francais]"
17
- density="comfortable"
18
- rows="1"
19
- :label="libelleInterieur ? $t(cleTradFr) : ''"
20
- :rules="reglesInterne"
21
- :autofocus="autofocus && afficherChampFr"
22
- />
23
- <v-text-field
24
- v-else
25
- :id="`saisieChampFr-${cleTradFr}`"
26
- v-model="model[champs.Francais]"
27
- density="comfortable"
28
- :label="libelleInterieur ? $t(cleTradFr) : ''"
29
- :rules="reglesInterne"
30
- :autofocus="autofocus && afficherChampFr"
31
- />
32
- </v-col>
33
- <v-col
34
- v-if="afficherChampEn"
35
- cols="12"
36
- >
37
- <label
38
- v-if="!libelleInterieur"
39
- :for="`saisieChampEn-${cleTradEn}`"
40
- :class="{ libelle: true, required: estRequis }"
41
- >{{ $t(cleTradEn) }}</label
42
- >
43
- <v-textarea
44
- v-if="textarea"
45
- :id="`saisieChampEn-${cleTradEn}`"
46
- v-model="model[champs.Anglais]"
47
- rows="1"
48
- density="comfortable"
49
- :label="libelleInterieur ? $t(cleTradEn) : ''"
50
- :rules="reglesInterne"
51
- :autofocus="autofocus && !afficherChampFr"
52
- />
53
- <v-text-field
54
- v-else
55
- :id="`saisieChampEn-${cleTradEn}`"
56
- v-model="model[champs.Anglais]"
57
- density="comfortable"
58
- :label="libelleInterieur ? $t(cleTradEn) : ''"
59
- :rules="reglesInterne"
60
- :autofocus="autofocus && !afficherChampFr"
61
- />
62
- </v-col>
63
- </v-row>
64
- </template>
65
-
66
- <script setup lang="ts" generic="T extends { id: number }">
67
- import { estRequis as estRequisRegle, estUniqueBilingue, estMinimumLongueur, estMaximumLongueur } from './validateurs'
68
- import { ChoixLangue } from '@/enums/choixLangue'
69
- import { computed, type PropType, toRefs } from 'vue'
70
- import { useI18n } from 'vue-i18n'
71
- const { t } = useI18n({ useScope: 'global' })
72
-
73
- const props = defineProps<{
74
- textarea?: boolean
75
- libelleInterieur?: boolean
76
- estRequis?: boolean
77
- autofocus?: boolean
78
- estUniqueValeurs?: T[]
79
- minimumLongueur?: number
80
- maximumLongueur?: number
81
- regles?: ((v: string) => string | true)[]
82
- langue: ChoixLangue
83
- i18nLibelleRacine: string
84
- champs: { ['Francais']: keyof T; ['Anglais']: keyof T }
85
- }>()
86
-
87
- const { textarea, libelleInterieur, autofocus, estUniqueValeurs, regles, langue, i18nLibelleRacine, champs } =
88
- toRefs(props)
89
-
90
- const minimumLongueur = computed(() => props.minimumLongueur)
91
- const maximumLongueur = computed(() => props.maximumLongueur)
92
- const estRequis = computed(() => props.estRequis)
93
-
94
- const model = defineModel({
95
- type: Object as PropType<T>,
96
- required: true,
97
- })
98
-
99
- const reglesInterne = computed(() => {
100
- const _regles: ((v: string) => string | true)[] = regles.value ?? []
101
-
102
- if (minimumLongueur.value && maximumLongueur.value && minimumLongueur.value > maximumLongueur.value) {
103
- console.error(
104
- `CsqcTexteBilingue - Longueur min > max. (Min ${minimumLongueur.value} > Max ${maximumLongueur.value})`,
105
- )
106
- throw Error(
107
- `CsqcTexteBilingue - Longueur min > max. (Min ${minimumLongueur.value} > Max ${maximumLongueur.value})`,
108
- )
109
- }
110
-
111
- if (estRequis.value) _regles.push(v => estRequisRegle(v, t))
112
-
113
- if (estUniqueValeurs.value) {
114
- _regles.push(v =>
115
- estUniqueBilingue(
116
- v,
117
- model.value,
118
- {
119
- champs: { Anglais: champs.value.Anglais, Francais: champs.value.Francais },
120
- valeurs: estUniqueValeurs.value!,
121
- langueCss: langue.value,
122
- },
123
- t,
124
- ),
125
- )
126
- }
127
-
128
- if (minimumLongueur.value !== undefined) _regles.push(v => estMinimumLongueur(v, minimumLongueur.value!, t))
129
-
130
- if (maximumLongueur.value !== undefined) _regles.push(v => estMaximumLongueur(v, maximumLongueur.value!, t))
131
-
132
- return _regles
133
- })
134
-
135
- // Clés i18n
136
- const cleTradEn = computed(() => {
137
- switch (langue.value) {
138
- case ChoixLangue.Bilingue:
139
- case ChoixLangue.Anglais:
140
- return `${i18nLibelleRacine.value}.${String(champs.value.Anglais)}`
141
- default:
142
- return 'cle_manquante'
143
- }
144
- })
145
-
146
- const cleTradFr = computed(() => {
147
- switch (langue.value) {
148
- case ChoixLangue.Bilingue:
149
- case ChoixLangue.Francais:
150
- return `${i18nLibelleRacine.value}.${String(champs.value.Francais)}`
151
- default:
152
- return 'cle_manquante'
153
- }
154
- })
155
-
156
- const afficherChampFr = computed(() => langue.value === ChoixLangue.Francais || langue.value === ChoixLangue.Bilingue)
157
- const afficherChampEn = computed(() => langue.value === ChoixLangue.Anglais || langue.value === ChoixLangue.Bilingue)
158
- </script>
1
+ <template>
2
+ <v-row dense>
3
+ <v-col
4
+ v-if="afficherChampFr"
5
+ cols="12"
6
+ >
7
+ <label
8
+ v-if="!libelleInterieur"
9
+ :for="`saisieChampFr-${cleTradFr}`"
10
+ :class="{ libelle: true, required: estRequis }"
11
+ >{{ $t(cleTradFr) }}</label
12
+ >
13
+ <v-textarea
14
+ v-if="textarea"
15
+ :id="`saisieChampFr-${cleTradFr}`"
16
+ v-model="model[champs.Francais]"
17
+ density="comfortable"
18
+ rows="1"
19
+ :label="libelleInterieur ? $t(cleTradFr) : ''"
20
+ :rules="reglesInterne"
21
+ :autofocus="autofocus && afficherChampFr"
22
+ />
23
+ <v-text-field
24
+ v-else
25
+ :id="`saisieChampFr-${cleTradFr}`"
26
+ v-model="model[champs.Francais]"
27
+ density="comfortable"
28
+ :label="libelleInterieur ? $t(cleTradFr) : ''"
29
+ :rules="reglesInterne"
30
+ :autofocus="autofocus && afficherChampFr"
31
+ />
32
+ </v-col>
33
+ <v-col
34
+ v-if="afficherChampEn"
35
+ cols="12"
36
+ >
37
+ <label
38
+ v-if="!libelleInterieur"
39
+ :for="`saisieChampEn-${cleTradEn}`"
40
+ :class="{ libelle: true, required: estRequis }"
41
+ >{{ $t(cleTradEn) }}</label
42
+ >
43
+ <v-textarea
44
+ v-if="textarea"
45
+ :id="`saisieChampEn-${cleTradEn}`"
46
+ v-model="model[champs.Anglais]"
47
+ rows="1"
48
+ density="comfortable"
49
+ :label="libelleInterieur ? $t(cleTradEn) : ''"
50
+ :rules="reglesInterne"
51
+ :autofocus="autofocus && !afficherChampFr"
52
+ />
53
+ <v-text-field
54
+ v-else
55
+ :id="`saisieChampEn-${cleTradEn}`"
56
+ v-model="model[champs.Anglais]"
57
+ density="comfortable"
58
+ :label="libelleInterieur ? $t(cleTradEn) : ''"
59
+ :rules="reglesInterne"
60
+ :autofocus="autofocus && !afficherChampFr"
61
+ />
62
+ </v-col>
63
+ </v-row>
64
+ </template>
65
+
66
+ <script setup lang="ts" generic="T extends { id: number }">
67
+ import { estRequis as estRequisRegle, estUniqueBilingue, estMinimumLongueur, estMaximumLongueur } from './validateurs'
68
+ import { ChoixLangue } from '@/enums/choixLangue'
69
+ import { computed, type PropType, toRefs } from 'vue'
70
+ import { useI18n } from 'vue-i18n'
71
+ const { t } = useI18n({ useScope: 'global' })
72
+
73
+ const props = defineProps<{
74
+ textarea?: boolean
75
+ libelleInterieur?: boolean
76
+ estRequis?: boolean
77
+ autofocus?: boolean
78
+ estUniqueValeurs?: T[]
79
+ minimumLongueur?: number
80
+ maximumLongueur?: number
81
+ regles?: ((v: string) => string | true)[]
82
+ langue: ChoixLangue
83
+ i18nLibelleRacine: string
84
+ champs: { ['Francais']: keyof T; ['Anglais']: keyof T }
85
+ }>()
86
+
87
+ const { textarea, libelleInterieur, autofocus, estUniqueValeurs, regles, langue, i18nLibelleRacine, champs } =
88
+ toRefs(props)
89
+
90
+ const minimumLongueur = computed(() => props.minimumLongueur)
91
+ const maximumLongueur = computed(() => props.maximumLongueur)
92
+ const estRequis = computed(() => props.estRequis)
93
+
94
+ const model = defineModel({
95
+ type: Object as PropType<T>,
96
+ required: true,
97
+ })
98
+
99
+ const reglesInterne = computed(() => {
100
+ const _regles: ((v: string) => string | true)[] = regles.value ?? []
101
+
102
+ if (minimumLongueur.value && maximumLongueur.value && minimumLongueur.value > maximumLongueur.value) {
103
+ console.error(
104
+ `CsqcTexteBilingue - Longueur min > max. (Min ${minimumLongueur.value} > Max ${maximumLongueur.value})`,
105
+ )
106
+ throw Error(
107
+ `CsqcTexteBilingue - Longueur min > max. (Min ${minimumLongueur.value} > Max ${maximumLongueur.value})`,
108
+ )
109
+ }
110
+
111
+ if (estRequis.value) _regles.push(v => estRequisRegle(v, t))
112
+
113
+ if (estUniqueValeurs.value) {
114
+ _regles.push(v =>
115
+ estUniqueBilingue(
116
+ v,
117
+ model.value,
118
+ {
119
+ champs: { Anglais: champs.value.Anglais, Francais: champs.value.Francais },
120
+ valeurs: estUniqueValeurs.value!,
121
+ langueCss: langue.value,
122
+ },
123
+ t,
124
+ ),
125
+ )
126
+ }
127
+
128
+ if (minimumLongueur.value !== undefined) _regles.push(v => estMinimumLongueur(v, minimumLongueur.value!, t))
129
+
130
+ if (maximumLongueur.value !== undefined) _regles.push(v => estMaximumLongueur(v, maximumLongueur.value!, t))
131
+
132
+ return _regles
133
+ })
134
+
135
+ // Clés i18n
136
+ const cleTradEn = computed(() => {
137
+ switch (langue.value) {
138
+ case ChoixLangue.Bilingue:
139
+ case ChoixLangue.Anglais:
140
+ return `${i18nLibelleRacine.value}.${String(champs.value.Anglais)}`
141
+ default:
142
+ return 'cle_manquante'
143
+ }
144
+ })
145
+
146
+ const cleTradFr = computed(() => {
147
+ switch (langue.value) {
148
+ case ChoixLangue.Bilingue:
149
+ case ChoixLangue.Francais:
150
+ return `${i18nLibelleRacine.value}.${String(champs.value.Francais)}`
151
+ default:
152
+ return 'cle_manquante'
153
+ }
154
+ })
155
+
156
+ const afficherChampFr = computed(() => langue.value === ChoixLangue.Francais || langue.value === ChoixLangue.Bilingue)
157
+ const afficherChampEn = computed(() => langue.value === ChoixLangue.Anglais || langue.value === ChoixLangue.Bilingue)
158
+ </script>
@@ -1,149 +1,149 @@
1
- <template>
2
- <v-navigation-drawer
3
- v-model="visible"
4
- location="right"
5
- temporary
6
- class="pa-0 elevation-2"
7
- :width="grosseurTiroir"
8
- :persistent="persistant"
9
- @keydown.esc="!persistant ? fermeture : ''"
10
- @click:outside="!persistant ? fermeture : ''"
11
- >
12
- <v-card class="pa-0 ma-0 pl-8 pt-8">
13
- <!-- Bouton en haut à droite -->
14
- <v-btn
15
- icon="mdi-close"
16
- variant="text"
17
- class="position-absolute couleurHover"
18
- style="top: 5px; right: 5px"
19
- @click="fermeture"
20
- ></v-btn>
21
-
22
- <v-card-title
23
- class="pa-0 ma-0 pb-6 text-wrap"
24
- style="font-size: 24px"
25
- >
26
- <slot name="titre"></slot>
27
- <div text-h5>{{ titre }}</div>
28
- </v-card-title>
29
-
30
- <v-card-text class="pa-0 ma-0 pb-6 pr-6">
31
- <v-container>
32
- <slot></slot>
33
- <slot name="content"></slot>
34
- </v-container>
35
- </v-card-text>
36
- <v-card-actions class="my-2 d-flex justify-end pr-6 pb-5">
37
- <slot name="actions"></slot>
38
- <v-btn
39
- v-if="btnAnnuler"
40
- color="primary"
41
- variant="text"
42
- :loading="operationEnCours"
43
- @click="fermeture"
44
- >
45
- {{ props.btnAnnulerTexte ? props.btnAnnulerTexte : $t('csqc.bouton.annuler') }}
46
- </v-btn>
47
-
48
- <v-btn
49
- v-if="btnOk"
50
- class="Gouttiere"
51
- color="primary"
52
- variant="flat"
53
- :loading="operationEnCours"
54
- :disabled="btnOkDesactiver || operationEnCours"
55
- @click="okBouton"
56
- >
57
- {{ props.btnOkTexte ? props.btnOkTexte : $t('csqc.bouton.ok') }}
58
- </v-btn>
59
- </v-card-actions>
60
- </v-card>
61
- </v-navigation-drawer>
62
- </template>
63
- <script lang="ts" setup>
64
- import { ref, computed } from 'vue'
65
- import { useDisplay } from 'vuetify'
66
-
67
- const visible = ref(false)
68
- const display = useDisplay()
69
-
70
- // Déclaration des props
71
- const props = defineProps({
72
- titre: {
73
- type: String,
74
- default: '',
75
- required: false,
76
- },
77
- btnAnnuler: {
78
- type: Boolean,
79
- default: true,
80
- required: false,
81
- },
82
- btnOk: {
83
- type: Boolean,
84
- default: true,
85
- required: false,
86
- },
87
- btnAnnulerTexte: {
88
- type: String,
89
- default: '',
90
- required: false,
91
- },
92
- btnOkDesactiver: {
93
- type: Boolean,
94
- default: false,
95
- required: false,
96
- },
97
- operationEnCours: { type: Boolean, default: false },
98
- persistant: { type: Boolean, default: true },
99
- btnOkTexte: {
100
- type: String,
101
- default: '',
102
- required: false,
103
- },
104
- })
105
-
106
- // Déclaration des événements
107
- const emit = defineEmits(['fermer', 'ok'])
108
-
109
- // Méthodes
110
- const ouvrir = () => {
111
- visible.value = true
112
- }
113
-
114
- const fermer = () => {
115
- visible.value = false
116
- }
117
-
118
- const fermeture = () => {
119
- emit('fermer')
120
- fermer()
121
- }
122
-
123
- const okBouton = () => {
124
- emit('ok')
125
- fermer()
126
- }
127
-
128
- // Calcul des tailles du tiroir en fonction du breakpoint
129
- const grosseurTiroir = computed(() => {
130
- switch (display.name.value) {
131
- case 'xs':
132
- return ''
133
- case 'sm':
134
- return 0.95 * display.width.value
135
- case 'md':
136
- return 0.8 * display.width.value
137
- case 'lg':
138
- return 0.7 * display.width.value
139
- case 'xl':
140
- return 0.6 * display.width.value
141
- case 'xxl':
142
- return 0.5 * display.width.value
143
- default:
144
- return ''
145
- }
146
- })
147
-
148
- defineExpose({ ouvrir, fermer })
149
- </script>
1
+ <template>
2
+ <v-navigation-drawer
3
+ v-model="visible"
4
+ location="right"
5
+ temporary
6
+ class="pa-0 elevation-2"
7
+ :width="grosseurTiroir"
8
+ :persistent="persistant"
9
+ @keydown.esc="!persistant ? fermeture : ''"
10
+ @click:outside="!persistant ? fermeture : ''"
11
+ >
12
+ <v-card class="pa-0 ma-0 pl-8 pt-8">
13
+ <!-- Bouton en haut à droite -->
14
+ <v-btn
15
+ icon="mdi-close"
16
+ variant="text"
17
+ class="position-absolute couleurHover"
18
+ style="top: 5px; right: 5px"
19
+ @click="fermeture"
20
+ ></v-btn>
21
+
22
+ <v-card-title
23
+ class="pa-0 ma-0 pb-6 text-wrap"
24
+ style="font-size: 24px"
25
+ >
26
+ <slot name="titre"></slot>
27
+ <div text-h5>{{ titre }}</div>
28
+ </v-card-title>
29
+
30
+ <v-card-text class="pa-0 ma-0 pb-6 pr-6">
31
+ <v-container>
32
+ <slot></slot>
33
+ <slot name="content"></slot>
34
+ </v-container>
35
+ </v-card-text>
36
+ <v-card-actions class="my-2 d-flex justify-end pr-6 pb-5">
37
+ <slot name="actions"></slot>
38
+ <v-btn
39
+ v-if="btnAnnuler"
40
+ color="primary"
41
+ variant="text"
42
+ :loading="operationEnCours"
43
+ @click="fermeture"
44
+ >
45
+ {{ props.btnAnnulerTexte ? props.btnAnnulerTexte : $t('csqc.bouton.annuler') }}
46
+ </v-btn>
47
+
48
+ <v-btn
49
+ v-if="btnOk"
50
+ class="Gouttiere"
51
+ color="primary"
52
+ variant="flat"
53
+ :loading="operationEnCours"
54
+ :disabled="btnOkDesactiver || operationEnCours"
55
+ @click="okBouton"
56
+ >
57
+ {{ props.btnOkTexte ? props.btnOkTexte : $t('csqc.bouton.ok') }}
58
+ </v-btn>
59
+ </v-card-actions>
60
+ </v-card>
61
+ </v-navigation-drawer>
62
+ </template>
63
+ <script lang="ts" setup>
64
+ import { ref, computed } from 'vue'
65
+ import { useDisplay } from 'vuetify'
66
+
67
+ const visible = ref(false)
68
+ const display = useDisplay()
69
+
70
+ // Déclaration des props
71
+ const props = defineProps({
72
+ titre: {
73
+ type: String,
74
+ default: '',
75
+ required: false,
76
+ },
77
+ btnAnnuler: {
78
+ type: Boolean,
79
+ default: true,
80
+ required: false,
81
+ },
82
+ btnOk: {
83
+ type: Boolean,
84
+ default: true,
85
+ required: false,
86
+ },
87
+ btnAnnulerTexte: {
88
+ type: String,
89
+ default: '',
90
+ required: false,
91
+ },
92
+ btnOkDesactiver: {
93
+ type: Boolean,
94
+ default: false,
95
+ required: false,
96
+ },
97
+ operationEnCours: { type: Boolean, default: false },
98
+ persistant: { type: Boolean, default: true },
99
+ btnOkTexte: {
100
+ type: String,
101
+ default: '',
102
+ required: false,
103
+ },
104
+ })
105
+
106
+ // Déclaration des événements
107
+ const emit = defineEmits(['fermer', 'ok'])
108
+
109
+ // Méthodes
110
+ const ouvrir = () => {
111
+ visible.value = true
112
+ }
113
+
114
+ const fermer = () => {
115
+ visible.value = false
116
+ }
117
+
118
+ const fermeture = () => {
119
+ emit('fermer')
120
+ fermer()
121
+ }
122
+
123
+ const okBouton = () => {
124
+ emit('ok')
125
+ fermer()
126
+ }
127
+
128
+ // Calcul des tailles du tiroir en fonction du breakpoint
129
+ const grosseurTiroir = computed(() => {
130
+ switch (display.name.value) {
131
+ case 'xs':
132
+ return ''
133
+ case 'sm':
134
+ return 0.95 * display.width.value
135
+ case 'md':
136
+ return 0.8 * display.width.value
137
+ case 'lg':
138
+ return 0.7 * display.width.value
139
+ case 'xl':
140
+ return 0.6 * display.width.value
141
+ case 'xxl':
142
+ return 0.5 * display.width.value
143
+ default:
144
+ return ''
145
+ }
146
+ })
147
+
148
+ defineExpose({ ouvrir, fermer })
149
+ </script>