File tree Expand file tree Collapse file tree 2 files changed +43
-5
lines changed
components/DsfrFileUpload Expand file tree Collapse file tree 2 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,19 @@ export default defineComponent({
2222 type: String ,
2323 default: undefined ,
2424 },
25+ modelValue: {
26+ type: String ,
27+ default: undefined ,
28+ },
29+ },
30+
31+ emits: [' update:modelValue' , ' change' ],
32+
33+ methods: {
34+ onChange ($event ) {
35+ this .$emit (' update:modelValue' , $event .target .value )
36+ this .$emit (' change' , $event .target .files )
37+ },
2538 },
2639})
2740 </script >
@@ -48,6 +61,8 @@ export default defineComponent({
4861 type =" file"
4962 :aria-describedby =" `${id}-desc`"
5063 v-bind =" $attrs"
64+ :value =" modelValue"
65+ @change =" onChange($event)"
5166 >
5267 <p
5368 v-if =" error"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import DsfrHeader from '../components/DsfrHeader/DsfrHeader.vue'
77import DsfrNavigation from ' ../components/DsfrNavigation/DsfrNavigation.vue'
88import DsfrSkipLinks from ' ../components/DsfrSkipLinks/DsfrSkipLinks.vue'
99import DsfrModal from ' ../components/DsfrModal/DsfrModal.vue'
10+ import DsfrFileUpload from ' ../components/DsfrFileUpload/DsfrFileUpload.vue'
1011
1112const isModalOpen = ref (false )
1213const displayAlert = ref (false )
@@ -19,6 +20,16 @@ const close = () => {
1920}
2021
2122const inputValue = ref (' ' )
23+ const filesToUpload = ref (undefined )
24+
25+ const updateFiles = (files ) => {
26+ console .log (files)
27+ }
28+
29+ const sendFile = () => {
30+ console .log (' inputValue:' , inputValue .value )
31+ console .log (' filesToUpload:' , filesToUpload .value )
32+ }
2233
2334// eslint-disable-next-line no-unused-vars
2435const actions = [
@@ -148,11 +159,23 @@ const navItems = [
148159 </DsfrAccordion >
149160 </li >
150161 </DsfrAccordionsGroup >
151- <DsfrInput
152- v-model =" inputValue"
153- label =" Test"
154- label-visible
155- />
162+ <form @submit.prevent =" sendFile()" >
163+ <DsfrInput
164+ v-model =" inputValue"
165+ label =" Test"
166+ label-visible
167+ />
168+ <DsfrFileUpload
169+ v-model =" filesToUpload"
170+ label =" Test"
171+ label-visible
172+ @change =" updateFiles($event)"
173+ />
174+ <input
175+ type =" submit"
176+ value =" OK"
177+ >
178+ </form >
156179 </div >
157180
158181 <DsfrModal
You can’t perform that action at this time.
0 commit comments