File tree Expand file tree Collapse file tree 2 files changed +17
-21
lines changed
web/src/lib/components/files Expand file tree Collapse file tree 2 files changed +17
-21
lines changed Original file line number Diff line number Diff line change 111111 {/if }
112112</div >
113113
114- <!-- TODO: Implement required prop for SingleFileInput -->
115114{#snippet fileInput ()}
116- <SingleFileInput bind:file ={instance .file } class =" flex w-fit items-center gap-2 rounded-md border btn-ghost px-2 py-1 has-focus-visible:outline-2" >
117- <span class =" iconify size-4 shrink-0 text-em-disabled octicon--file-16" ></span >
118- {#if instance .file }
119- {instance .file .name }
120- {:else }
121- <span class ="font-light" >{label }</span >
122- {/if }
123- <span class =" iconify size-4 shrink-0 text-em-disabled octicon--triangle-down-16" ></span >
124- </SingleFileInput >
115+ <SingleFileInput required bind:file ={instance .file } />
125116{/ snippet }
126117
127118{#snippet urlInput ()}
Original file line number Diff line number Diff line change 11<script lang =" ts" >
2- import { useId } from " bits-ui" ;
3- import { type RestProps } from " $lib/types" ;
4- import { type Snippet } from " svelte" ;
52 import { watch } from " runed" ;
63
74 type Props = {
8- children? : Snippet <[{ file? : File }]>;
5+ label? : string ;
6+ required? : boolean ;
97 file? : File ;
10- } & RestProps ;
8+ };
119
12- let { children, file = $bindable <File | undefined >(undefined ), ... restProps }: Props = $props ();
10+ let { label = " File " , required = false , file = $bindable <File | undefined >(undefined ) }: Props = $props ();
1311
1412 let files = $state <FileList | undefined >();
1513
2220 },
2321 );
2422
25- const labelId = useId ();
26- const inputId = useId ();
23+ const uid = $props .id ();
24+ const labelId = ` ${uid }-label ` ;
25+ const inputId = ` ${uid }-input ` ;
2726 </script >
2827
29- <label id ={labelId } for ={inputId } {...restProps }>
30- {@render children ?.({ file })}
31- <input id ={inputId } aria-labelledby ={labelId } type =" file" bind:files class =" sr-only" />
28+ <label id ={labelId } for ={inputId } class =" relative flex w-fit items-center gap-2 rounded-md border btn-ghost px-2 py-1 has-focus-visible:outline-2" >
29+ <span class =" iconify size-4 shrink-0 text-em-disabled octicon--file-16" ></span >
30+ {#if file }
31+ {file .name }
32+ {:else }
33+ <span class ="font-light" >{label }</span >
34+ {/if }
35+ <span class =" iconify size-4 shrink-0 text-em-disabled octicon--triangle-down-16" ></span >
36+ <input id ={inputId } aria-labelledby ={labelId } type ="file" {required } bind:files class =" absolute top-0 left-0 size-full opacity-0" />
3237</label >
You can’t perform that action at this time.
0 commit comments