<baht-file>
The type: 'file' field for JSON forms. Two modes: capture (default) hands the host a
File | File[] | null and never uploads; upload (field.uploader naming a registry
function) uploads on pick and the value becomes a serializable { name, size, type, url } ref.
Want to point at an endpoint from markup with no host code? That is <baht-upload>.
Basic
Events (name)
<baht-file></baht-file>
<script>
const el = document.querySelector('baht-file');
el.field = {
"order": 1,
"type": "file",
"key": "resume",
"label": "Resume (PDF)",
"accept": ".pdf",
"max_size": 5242880
};
el.value = null;
</script>| Name | Type | Default | Description |
|---|---|---|---|
uploaderJS | (file: File) => Promise<UploadedFile> | undefined | — | Resolved registry uploader — <baht-form> injects it when `field.uploader` is set. |
fieldJS | FieldDescriptor | — | Field spec: { order, type, key, label?, placeholder?, options?, … } |
valueJS | unknown | null | Controlled value. Re-feed on every baht-input |
disabled | boolean | false | Disable the control |
readonly | boolean | false | Read-only |
required | boolean | false | Show required mark |
show-optional | boolean | false | Append the localized "(optional)" marker to the label when not required (set by <baht-form show-optional>). |
errorJS | string | null | null | Validation message to display |
debounce | number | undefined | — | Debounce for typed edits (ms); unset = BahtFieldBase.defaultDebounce. |
Events
Section titled “Events”| Event | detail | Description |
|---|---|---|
name | CustomEvent | |
baht-input | { key, value } | Fired on every user edit |