feat: Upload adds id and name prop

This commit is contained in:
luoxiao 2024-08-22 16:52:24 +08:00 committed by luoxiaozero
parent 9fbf507a36
commit fb98d608ae
2 changed files with 16 additions and 7 deletions

View file

@ -47,8 +47,10 @@ view! {
### Upload Props
| Name | Type | Default | Description |
| -------------- | ---------------------------------- | -------------------- | ------------------------------------ |
| --- | --- | --- | --- |
| class | `MaybeProp<String>` | `Default::default()` | |
| id | `MaybeProp<String>` | `Default::default()` | |
| name | `MaybeProp<String>` | `Default::default()` | A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. |
| accept | `MaybeSignal<String>` | `Default::default()` | The accept type of upload. |
| multiple | `MaybeSignal<bool>` | `false` | Allow multiple files to be selected. |
| custom_request | `Option<ArcOneCallback<FileList>>` | `None` | Customize upload request. |

View file

@ -9,6 +9,11 @@ use thaw_utils::{add_event_listener, class_list, mount_style, ArcOneCallback};
#[component]
pub fn Upload(
#[prop(optional, into)] class: MaybeProp<String>,
#[prop(optional, into)] id: MaybeProp<String>,
/// A string specifying a name for the input control.
/// This name is submitted along with the control's value when the form data is submitted.
#[prop(optional, into)]
name: MaybeProp<String>,
/// The accept type of upload.
#[prop(optional, into)]
accept: MaybeSignal<String>,
@ -87,6 +92,8 @@ pub fn Upload(
]>
<input
class="thaw-upload__input"
id=move || id.get()
name=move || name.get()
node_ref=input_ref
type="file"
accept=move || accept.get()