GhostFileUpload reference
Package: @ghostvue/vue. Status: experimental (stability policy).
Headless file picker with a removable File[] list. Browse and drop share one intake path that checks accept, maxFileSize, validate, and capacity in input order, appends accepted files, and reports each rejected file with a typed reason. Optional form participation through a visually hidden file input mirror (name, form, required, reset). Outcomes are announced through a polite live region. Client-side checks are UX, not a security control; consumers own uploads.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
accept | string | — | No | Native `accept` grammar: a picker hint that is also enforced on intake. |
defaultValue | File[] | "[]" | No | Uncontrolled seed and form-reset baseline, captured once at setup. |
disabled | boolean | false | No | Disables the trigger, drops, and remove buttons, and omits the mirror from submit. |
form | string | — | No | `form` attribute for the mirror and the picker. |
id | string | — | No | Id of the trigger (the labelable control), not of the root element. |
invalid | boolean | false | No | Consumer validity, combined with native constraint failure. |
maxFiles | number | — | No | Total list capacity. Floored; not finite or below 1 is unlimited. `1` turns `multiple` off. |
maxFileSize | number | — | No | Per-file limit in bytes; equal is accepted. Not finite or negative is unset. |
messages | Partial<GhostFileUploadMessages> | — | No | Typed, reactive overrides of announcement and label text. |
modelValue | File[] | — | No | Controlled list. `undefined` is uncontrolled; `[]` is a real empty value. |
name | string | — | No | Form mirror `name`. Without it no mirror renders and nothing is submitted. |
preventDocumentDrop | boolean | true | No | Cancel file drags and drops outside every dropzone while an enabled dropzone is mounted. |
required | boolean | false | No | Native `required` on the form mirror when `name` is set. |
validate | GhostFileUploadValidate | — | No | Synchronous, pure check after `accept` and `maxFileSize`; return a string to reject. |
Emits
| Name | Payload | Description |
|---|---|---|
reject | GhostFileUploadRejection[] | Once per intake batch with at least one rejection, after update:modelValue. Fires even when a controlled parent ignores the list update. |
Models
| Prop | Event | Type | Description |
|---|---|---|---|
modelValue | update:modelValue | File[] | v-model for the File[] list. Every change emits a new array with the same File instances; the consumer array is never mutated. |
Slots
| Name | Description |
|---|---|
default | Consumer layout of the parts, with the list entries, rejections from the latest intake, remaining capacity, effective invalid state, and actions. |
Slot props: default
| Name | Type | Description |
|---|---|---|
clear | () => void | Empties the list and `rejections`, and announces it. |
clearRejections | () => void | Empties `rejections` without touching the list. |
entries | readonly GhostFileUploadEntry[] | Current list with stable ids for `v-for` keys. |
invalid | boolean | Effective invalid state: `invalid` prop or native constraint failure. |
openPicker | () => void | Opens the native picker. No-op when disabled. |
rejections | readonly GhostFileUploadRejection[] | Rejections from the most recent intake only. |
remaining | number | undefined | `maxFiles` minus list length, never below 0; `undefined` when unlimited. |
remove | (file: File) => void | Removes the first identical entry and applies the focus rule. |
Exposed members
| Name | Type | Description |
|---|---|---|
blur | () => void | Blurs the trigger. |
clear | () => void | Same as the slot `clear`. |
element | HTMLElement | null | The root element. |
focus | (options?: FocusOptions) => void | Focuses the trigger. |
openPicker | () => void | Opens the native picker; call inside a user gesture. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | State owner element (div). Internal picker, form-input mirror, and announcer are not styling hooks. |
data-state | invalid | invalid prop or native required failure from the mirror. Wins over disabled. |
data-state | disabled | Root is disabled. |
CSS variables
None declared.
Accessibility
Role: generic. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/button/.
Required ARIA attributes: none.
Keyboard
None declared.
Verification
Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.
| Category | Status | Evidence |
|---|---|---|
| Automated keyboard | Not reviewed | No declared key is mapped to a browser test yet. |
| Manual interaction | Not reviewed | No review recorded. |
| Assistive technology | Not reviewed | No review recorded. |
Examples
file-upload/basic
Dropzone, trigger, and a removable file list.
file-upload/button-only
Trigger and list without a drop target.
file-upload/field
Inside GhostField with a visible error built from rejections.
file-upload/validation
accept, maxFileSize, and maxFiles with visible rejection messages.
file-upload/duplicates
A validate callback that rejects files already in the list.
file-upload/controlled
v-model with a synchronous parent update, a clear action, and a disabled toggle.
file-upload/form
Native form with FormData from the mirror, required, and reset.