File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,39 @@ LabelVisible.args = {
148148 disabled : false ,
149149}
150150
151+ export const ChampObligatoire = ( args ) => ( {
152+ components : {
153+ DsfrInput,
154+ } ,
155+ data ( ) {
156+ return {
157+ ...args ,
158+ }
159+ } ,
160+ template : `
161+ <DsfrInput
162+ :model-value="modelValue"
163+ :label="label"
164+ :label-visible="labelVisible"
165+ :placeholder="placeholder"
166+ :disabled="disabled"
167+ :required="true"
168+ />
169+ ` ,
170+ mounted ( ) {
171+ document . body . parentElement . setAttribute ( 'data-fr-theme' , this . dark ? 'dark' : 'light' )
172+ } ,
173+ } )
174+ ChampObligatoire . args = {
175+ dark : false ,
176+ label : 'Label champ de saisie' ,
177+ labelVisible : true ,
178+ placeholder : 'Placeholder' ,
179+ modelValue : '' ,
180+ disabled : false ,
181+ isTextarea : true ,
182+ }
183+
151184export const ChampEnErreur = ( args ) => ( {
152185 components : {
153186 DsfrInput,
Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ import { getRandomId } from '../../utils/random-utils.js'
55
66export default defineComponent ({
77 name: ' DsfrInput' ,
8+
89 inheritAttrs: false ,
10+
911 props: {
1012 id: {
1113 type: String ,
@@ -39,7 +41,9 @@ export default defineComponent({
3941 isValid: Boolean ,
4042 isTextarea: Boolean ,
4143 },
44+
4245 emits: [' update:modelValue' ],
46+
4347 computed: {
4448 isComponent () {
4549 return this .isTextarea ? ' textarea' : ' input'
@@ -59,12 +63,22 @@ export default defineComponent({
5963 }"
6064 :for =" id"
6165 >
62- {{ label }} {{ $attrs.required ? '*' : '' }}
66+ {{ label }}
67+
68+ <!-- @slot Slot pour indiquer que le champ est obligatoire. Par défaut, met une astérisque (dans un `<span class="required">`) -->
69+ <slot name =" required-tip" >
70+ <span
71+ v-if =" $attrs.required"
72+ class =" required"
73+ >  ; *</span >
74+ </slot >
75+
6376 <span
6477 v-if =" hint"
6578 class =" fr-hint-text"
6679 >{{ hint }}</span >
6780 </label >
81+
6882 <component
6983 :is =" isComponent"
7084 v-if =" !wrapper"
@@ -80,6 +94,7 @@ export default defineComponent({
8094 @input =" $emit('update:modelValue', $event.target.value)"
8195 @keydown.esc =" $emit('update:modelValue', '')"
8296 />
97+
8398 <div
8499 v-else
85100 :class =" [
You can’t perform that action at this time.
0 commit comments