codevdesign 1.0.41 → 1.0.43

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,120 +1,102 @@
1
- <template>
2
- <div>
3
- <v-row dense>
4
- <v-col
5
- cols="9"
6
- md="8"
7
- lg="6"
8
- class="d-flex align-end"
9
- >
10
- <div class="labelSwitchSiSwitchApres">{{ texte }}</div>
11
- </v-col>
12
- <v-col
13
- cols="2"
14
- class="d-flex align-end justify-end"
15
- >
16
- <v-switch
17
- v-model="maValeur"
18
- :disabled="desactiver"
19
- density="compact"
20
- inset
21
- v-bind="$attrs"
22
- hide-details
23
- @update:model-value="sauvegarder"
24
- />
25
- </v-col>
26
- </v-row>
27
- <v-row dense>
28
- <v-col
29
- cols="9"
30
- md="8"
31
- >
32
- <span v-html="texteDetaille"></span>
33
- </v-col>
34
- </v-row>
35
- </div>
36
- </template>
37
- <script setup lang="ts">
38
- import { ref, watch, onMounted, type PropType } from 'vue'
39
-
40
- // Définition des props
41
- const props = defineProps({
42
- valeurInverse: {
43
- type: Boolean,
44
- default: false,
45
- },
46
- desactiver: {
47
- type: Boolean,
48
- default: false,
49
- },
50
- modelValue: {
51
- type: Boolean,
52
- required: true,
53
- },
54
- texte: {
55
- type: String,
56
- required: true,
57
- },
58
- texteDetaille: {
59
- type: String,
60
- required: true,
61
- },
62
- })
63
-
64
- // Définition de l'événement
65
- const emit = defineEmits(['update:modelValue'])
66
-
67
- // Référence pour la valeur interne
68
- const maValeur = ref<boolean>(false)
69
-
70
- // Montée du composant
71
- onMounted(() => {
72
- if (props.valeurInverse) {
73
- maValeur.value = !props.modelValue
74
- } else {
75
- maValeur.value = props.modelValue
76
- }
77
- })
78
-
79
- // Watcher pour suivre les changements de la prop 'value'
80
- watch(
81
- () => props.modelValue,
82
- newValue => {
83
- if (props.valeurInverse) {
84
- maValeur.value = !newValue
85
- } else {
86
- maValeur.value = newValue
87
- }
88
- },
89
- )
90
-
91
- watch(
92
- () => props.valeurInverse,
93
- newValue => {
94
- if (props.valeurInverse) {
95
- maValeur.value = newValue
96
- } else {
97
- maValeur.value = !newValue
98
- }
99
- },
100
- )
101
-
102
- // Méthode pour sauvegarder la valeur
103
- const sauvegarder = () => {
104
- if (props.valeurInverse) {
105
- emit('update:modelValue', !maValeur.value)
106
- } else {
107
- emit('update:modelValue', maValeur.value)
108
- }
109
- }
110
- </script>
111
-
112
- <style lang="css" scoped>
113
- .labelSwitchSiSwitchApres {
114
- font-weight: bold;
115
- margin-top: 25px;
116
- }
117
- .v-switch {
118
- margin-bottom: -10px; /* aligner le switch avec son texte*/
119
- }
120
- </style>
1
+ <template>
2
+ <v-row
3
+ dense
4
+ class="align-center"
5
+ >
6
+ <!-- Texte + détails -->
7
+ <v-col
8
+ cols="10"
9
+ xl="11"
10
+ class="py-0"
11
+ >
12
+ <component
13
+ :is="labelCliquable ? 'label' : 'div'"
14
+ :for="labelCliquable ? switchId : undefined"
15
+ class="labelSwitchSiSwitchApres"
16
+ :class="{ 'label-cliquable': labelCliquable && !desactiver }"
17
+ >
18
+ <slot name="label">
19
+ {{ texte }}
20
+ </slot>
21
+ </component>
22
+
23
+ <div
24
+ v-if="afficherDetails"
25
+ class="details"
26
+ >
27
+ <slot name="details">
28
+ <span v-html="texteDetaille"></span>
29
+ </slot>
30
+ </div>
31
+ </v-col>
32
+
33
+ <!-- Switch -->
34
+ <v-col
35
+ cols="2"
36
+ xl="1"
37
+ class="d-flex align-center justify-end py-0"
38
+ >
39
+ <v-switch
40
+ :id="switchId"
41
+ v-model="maValeur"
42
+ class="switch-compact"
43
+ :disabled="desactiver"
44
+ :density="($attrs.density as any) ?? 'compact'"
45
+ :inset="($attrs.inset as any) ?? true"
46
+ v-bind="$attrs"
47
+ hide-details
48
+ />
49
+ </v-col>
50
+ </v-row>
51
+ </template>
52
+
53
+ <script setup lang="ts">
54
+ import { computed, useSlots } from 'vue'
55
+
56
+ const props = defineProps({
57
+ valeurInverse: { type: Boolean, default: false },
58
+ desactiver: { type: Boolean, default: false },
59
+ modelValue: { type: Boolean, required: true },
60
+ texte: { type: String, required: true },
61
+ texteDetaille: { type: String, default: '' },
62
+ labelCliquable: { type: Boolean, default: true },
63
+ })
64
+
65
+ const emit = defineEmits(['update:modelValue'])
66
+ const slots = useSlots()
67
+
68
+ const maValeur = computed<boolean>({
69
+ get: () => (props.valeurInverse ? !props.modelValue : props.modelValue),
70
+ set: v => emit('update:modelValue', props.valeurInverse ? !v : v),
71
+ })
72
+
73
+ const afficherDetails = computed(() => {
74
+ const slotExiste = !!slots.details?.().length
75
+ return slotExiste || props.texteDetaille.trim().length > 0
76
+ })
77
+
78
+ const switchId = `sw_${Math.random().toString(36).slice(2)}`
79
+ </script>
80
+
81
+ <style scoped>
82
+ .labelSwitchSiSwitchApres {
83
+ font-weight: bold;
84
+ line-height: 1.2;
85
+ }
86
+
87
+ .label-cliquable {
88
+ cursor: pointer;
89
+ }
90
+
91
+ .details {
92
+ margin-top: 4px;
93
+ }
94
+
95
+ /* compact switch */
96
+ :deep(.switch-compact.v-input) {
97
+ margin: 0;
98
+ }
99
+ :deep(.switch-compact .v-selection-control) {
100
+ margin: 0;
101
+ }
102
+ </style>
@@ -1,213 +1,214 @@
1
- <template>
2
- <div>
3
- <v-row
4
- dense
5
- class="pt-0 mt-0"
6
- >
7
- <v-col
8
- cols="12"
9
- sm="auto"
10
- >
11
- <slot name="recherche"></slot>
12
- <v-text-field
13
- v-if="afficher"
14
- v-model="rechercheLocale"
15
- :label="rechercheTexte ? rechercheTexte : $t('csqc.label.recherche')"
16
- single-line
17
- density="compact"
18
- hide-details
19
- v-bind="$attrs"
20
- clearable
21
- :rounded="0"
22
- variant="outlined"
23
- max-width="640"
24
- min-width="500"
25
- class="BarreRecherche"
26
- :loading="chargement"
27
- :disabled="chargement || desactiver"
28
- >
29
- <template #append>
30
- <v-btn
31
- class="BarreRechercheBackIcone"
32
- :loading="chargement"
33
- :disabled="chargement || desactiver"
34
- >
35
- <v-icon
36
- class="BarreRechercheIcone"
37
- icon="mdi-magnify"
38
- />
39
- </v-btn>
40
- </template>
41
- </v-text-field>
42
- </v-col>
43
- <!-- Entre recherche et ajouté-->
44
- <v-col
45
- cols="12"
46
- sm="auto"
47
- class="pt-1 mt-0 pb-0 mb-0"
48
- >
49
- <slot name="milieu" />
50
- </v-col>
51
-
52
- <!-- Affichage des boutons et icônes-->
53
- <v-col
54
- cols="12"
55
- sm="auto"
56
- class="flex-grow-1 d-flex justify-end"
57
- >
58
- <slot name="droite" />
59
- </v-col>
60
- </v-row>
61
- <v-row
62
- dense
63
- class="pt-0 mt-0"
64
- >
65
- <v-col
66
- cols="12"
67
- :lg="rechercheAvanceeLargeur"
68
- >
69
- <v-expansion-panels
70
- v-if="rechercheAvancee"
71
- static
72
- :readonly="chargement || desactiver"
73
- expand-icon=""
74
- @update:model-value="onPanelChange"
75
- >
76
- <v-expansion-panel
77
- flat
78
- elevation="0"
79
- >
80
- <v-expansion-panel-title
81
- style="color: #095797"
82
- class="pl-0 ml-0"
83
- ><slot name="rechercheAvanceeTitre">
84
- <span
85
- style="text-decoration: underline"
86
- v-html="rechercheAvanceeTexte ? rechercheAvanceeTexte : $t('csqc.label.rechercheAvanceeDefaut')"
87
- ></span>
88
- <slot name="rechercheAvanceeApresTitre"></slot
89
- ></slot>
90
- </v-expansion-panel-title>
91
- <v-expansion-panel-text :style="rechercheAvanceeStyle">
92
- <slot name="rechercheAvancee"></slot>
93
- </v-expansion-panel-text>
94
- </v-expansion-panel>
95
- </v-expansion-panels>
96
- </v-col>
97
- </v-row>
98
- </div>
99
- </template>
100
-
101
- <script lang="ts" setup>
102
- import { ref, watch } from 'vue'
103
-
104
- // Props
105
- const props = defineProps({
106
- afficher: {
107
- type: Boolean,
108
- required: false,
109
- default: true,
110
- },
111
- rechercheTexte: {
112
- type: String,
113
- required: false,
114
- default: '',
115
- },
116
- rechercheAvanceeTexte: {
117
- type: String,
118
- required: false,
119
- default: '',
120
- },
121
- rechercheAvanceeLargeur: {
122
- type: Number,
123
- required: false,
124
- default: 12,
125
- },
126
- chargement: {
127
- type: Boolean,
128
- required: false,
129
- default: false,
130
- },
131
- desactiver: {
132
- type: Boolean,
133
- required: false,
134
- default: false,
135
- },
136
- recherche: {
137
- type: String,
138
- required: false,
139
- default: '',
140
- },
141
- rechercheAvancee: {
142
- type: Boolean,
143
- required: false,
144
- default: false,
145
- },
146
- rechercheAvanceeStyle: {
147
- type: String,
148
- required: false,
149
- default: '',
150
- },
151
- })
152
-
153
- const emit = defineEmits<{
154
- (e: 'update:recherche', recherche: string): void
155
- (e: 'panneau:etat', isOpen: boolean): void // événement pour l'ouverture/fermeture du panneau
156
- }>()
157
-
158
- // Création d'une variable locale pour gérer la recherche
159
- const rechercheLocale = ref(props.recherche)
160
-
161
- // Surveiller les changements de la prop `recherche` et mettre à jour `rechercheLocale`
162
- watch(
163
- () => props.recherche,
164
- nouvelleValeur => {
165
- rechercheLocale.value = nouvelleValeur
166
- },
167
- )
168
-
169
- // Émettre l'événement `update:recherche` chaque fois que l'utilisateur tape
170
- watch(rechercheLocale, nouvelleValeur => {
171
- emit('update:recherche', nouvelleValeur!)
172
- })
173
-
174
- // Fonction pour émettre l'événement d'ouverture/fermeture du panneau
175
- const onPanelChange = (val: unknown) => {
176
- if (typeof val === 'string' || typeof val === 'number' || val === null) {
177
- const isOpen = val !== null && val !== ''
178
- emit('panneau:etat', isOpen)
179
- } else {
180
- emit('panneau:etat', false)
181
- }
182
- }
183
- </script>
184
-
185
- <style lang="css">
186
- /* barre de recherche design QC*/
187
- .BarreRecherche {
188
- min-height: 40px;
189
- }
190
-
191
- .BarreRechercheBackIcone {
192
- border-right: 1px solid #808a9d;
193
- border-top: 1px solid #808a9d;
194
- border-bottom: 1px solid #808a9d;
195
- background-color: #095797 !important;
196
- height: 40px !important;
197
- width: 40px !important;
198
- max-width: 40px !important;
199
- min-width: 40px !important;
200
- padding-right: 0 !important;
201
- padding-left: 0 !important;
202
- border-radius: 0;
203
- margin-left: -16px;
204
- }
205
-
206
- /* icone loupe */
207
- .BarreRechercheIcone {
208
- font-size: 34px !important;
209
- margin-left: 1px !important;
210
- margin-top: 2px !important;
211
- color: white !important;
212
- }
213
- </style>
1
+ <template>
2
+ <div>
3
+ <v-row
4
+ dense
5
+ class="pt-0 mt-0"
6
+ >
7
+ <v-col
8
+ cols="12"
9
+ sm="auto"
10
+ >
11
+ <slot name="recherche"></slot>
12
+ <v-text-field
13
+ v-if="afficher"
14
+ v-model="rechercheLocale"
15
+ :label="rechercheTexte ? rechercheTexte : $t('csqc.label.recherche')"
16
+ single-line
17
+ density="compact"
18
+ hide-details
19
+ v-bind="$attrs"
20
+ clearable
21
+ :rounded="0"
22
+ variant="outlined"
23
+ max-width="640"
24
+ min-width="500"
25
+ class="BarreRecherche"
26
+ :loading="chargement"
27
+ :disabled="chargement || desactiver"
28
+ >
29
+ <template #append>
30
+ <v-btn
31
+ class="BarreRechercheBackIcone"
32
+ :loading="chargement"
33
+ :disabled="chargement || desactiver"
34
+ >
35
+ <v-icon
36
+ class="BarreRechercheIcone"
37
+ icon="mdi-magnify"
38
+ />
39
+ </v-btn>
40
+ </template>
41
+ </v-text-field>
42
+ </v-col>
43
+ <!-- Entre recherche et ajouté-->
44
+ <v-col
45
+ cols="12"
46
+ sm="auto"
47
+ class="pt-1 mt-0 pb-0 mb-0"
48
+ >
49
+ <slot name="milieu" />
50
+ </v-col>
51
+
52
+ <!-- Affichage des boutons et icônes-->
53
+ <v-col
54
+ cols="12"
55
+ sm="auto"
56
+ class="flex-grow-1 d-flex justify-end"
57
+ >
58
+ <slot name="droite" />
59
+ </v-col>
60
+ </v-row>
61
+ <v-row
62
+ dense
63
+ class="pt-0 mt-0"
64
+ >
65
+ <v-col
66
+ cols="12"
67
+ :lg="rechercheAvanceeLargeur"
68
+ >
69
+ <v-expansion-panels
70
+ v-if="rechercheAvancee"
71
+ static
72
+ :readonly="chargement || desactiver"
73
+ expand-icon=""
74
+ @update:model-value="onPanelChange"
75
+ >
76
+ <v-expansion-panel
77
+ flat
78
+ elevation="0"
79
+ >
80
+ <v-expansion-panel-title
81
+ style="color: #095797"
82
+ class="pl-0 ml-0"
83
+ ><slot name="rechercheAvanceeTitre">
84
+ <span
85
+ style="text-decoration: underline"
86
+ v-html="rechercheAvanceeTexte ? rechercheAvanceeTexte : $t('csqc.label.rechercheAvanceeDefaut')"
87
+ ></span>
88
+ <slot name="rechercheAvanceeApresTitre"></slot
89
+ ></slot>
90
+ </v-expansion-panel-title>
91
+ <v-expansion-panel-text :style="rechercheAvanceeStyle">
92
+ <slot name="rechercheAvancee"></slot>
93
+ </v-expansion-panel-text>
94
+ </v-expansion-panel>
95
+ </v-expansion-panels>
96
+ </v-col>
97
+ </v-row>
98
+ </div>
99
+ </template>
100
+
101
+ <script lang="ts" setup>
102
+ import { ref, watch } from 'vue'
103
+
104
+ // Props
105
+ const props = defineProps({
106
+ afficher: {
107
+ type: Boolean,
108
+ required: false,
109
+ default: true,
110
+ },
111
+ rechercheTexte: {
112
+ type: String,
113
+ required: false,
114
+ default: '',
115
+ },
116
+ rechercheAvanceeTexte: {
117
+ type: String,
118
+ required: false,
119
+ default: '',
120
+ },
121
+ rechercheAvanceeLargeur: {
122
+ type: Number,
123
+ required: false,
124
+ default: 12,
125
+ },
126
+ chargement: {
127
+ type: Boolean,
128
+ required: false,
129
+ default: false,
130
+ },
131
+ desactiver: {
132
+ type: Boolean,
133
+ required: false,
134
+ default: false,
135
+ },
136
+ recherche: {
137
+ type: String,
138
+ required: false,
139
+ default: '',
140
+ },
141
+ rechercheAvancee: {
142
+ type: Boolean,
143
+ required: false,
144
+ default: false,
145
+ },
146
+ rechercheAvanceeStyle: {
147
+ type: String,
148
+ required: false,
149
+ default: '',
150
+ },
151
+ })
152
+
153
+ const emit = defineEmits<{
154
+ (e: 'update:recherche', recherche: string): void
155
+ (e: 'panneau:etat', isOpen: boolean): void // événement pour l'ouverture/fermeture du panneau
156
+ }>()
157
+
158
+ // Création d'une variable locale pour gérer la recherche
159
+ const rechercheLocale = ref(props.recherche)
160
+
161
+ // Surveiller les changements de la prop `recherche` et mettre à jour `rechercheLocale`
162
+ watch(
163
+ () => props.recherche,
164
+ nouvelleValeur => {
165
+ rechercheLocale.value = nouvelleValeur
166
+ },
167
+ )
168
+
169
+ // Émettre l'événement `update:recherche` chaque fois que l'utilisateur tape
170
+ watch(rechercheLocale, nouvelleValeur => {
171
+ emit('update:recherche', nouvelleValeur!)
172
+ })
173
+
174
+ // Fonction pour émettre l'événement d'ouverture/fermeture du panneau
175
+ const onPanelChange = (val: unknown) => {
176
+ if (typeof val === 'string' || typeof val === 'number' || val === null) {
177
+ const isOpen = val !== null && val !== ''
178
+ emit('panneau:etat', isOpen)
179
+ } else {
180
+ emit('panneau:etat', false)
181
+ }
182
+ }
183
+ </script>
184
+
185
+ <style lang="css">
186
+ /* barre de recherche design QC*/
187
+ .BarreRecherche {
188
+ border-radius: 4px 0 0 4px !important;
189
+ min-height: 40px;
190
+ }
191
+
192
+ .BarreRechercheBackIcone {
193
+ border-right: 1px solid #808a9d;
194
+ border-top: 1px solid #808a9d;
195
+ border-bottom: 1px solid #808a9d;
196
+ background-color: #095797 !important;
197
+ height: 40px !important;
198
+ width: 40px !important;
199
+ max-width: 40px !important;
200
+ min-width: 40px !important;
201
+ padding-right: 0 !important;
202
+ padding-left: 0 !important;
203
+ border-radius: 0 4px 4px 0 !important;
204
+ margin-left: -16px;
205
+ }
206
+
207
+ /* icone loupe */
208
+ .BarreRechercheIcone {
209
+ font-size: 34px !important;
210
+ margin-left: 1px !important;
211
+ margin-top: 2px !important;
212
+ color: white !important;
213
+ }
214
+ </style>