Data Entry
Upload
File inputs, drop zones and image grids.
import { DropZone, FileUpload, ImageDropZone } from 'faifo-design'FileUpload is a native file input with the design system's frame. DropZone adds a drop target
and a list of chosen files; ImageDropZone is the image-only surface with thumbnails and inline
actions.
#When to use
- The native input owns submission. The application owns transport, storage and the URLs of stored files.
- Use
ImageDropZonewhen the files are pictures the reader arranges.
#Examples
Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.
#File upload and drop zone
Native file input owns submission; the application owns transport and storage.
- Jacket front.jpgJacket front.jpg: Uploaded
- Jacket back with detachable hood and adjustable storm cuffs.jpgUploading Jacket back with detachable hood and adjustable storm cuffs.jpg
- Collar detail.jpgUploading Collar detail.jpg
- Side zip.jpgSide zip.jpg: Connection interrupted. Try again.
- Jacket front.jpgJacket front.jpg: Uploaded
Show codeHide code
import { renderIsland, trustedMarkup } from '@ketvietlab/ketjs-view'
import { DropZone, Field, FileUpload, ImageDropZone, Stack } from 'faifo-design'
// disabledPictureGridDemo: a catalogue fixture, packages/faifo-design/src/catalogue/picture-grid-demo.tsx
// pictureGridDemo: a catalogue fixture, packages/faifo-design/src/catalogue/picture-grid-demo.tsx
export const Example = () => (
<Stack
items={[
<Field
id="catalogue-product-photo"
name="product-photo"
label="Product photo"
layout="inline"
control={
<ImageDropZone
label="Product photo"
picker={
<label data-ui="image-drop-picker">
<input
id="catalogue-product-photo"
type="file"
accept="image/*"
aria-label="Choose product photo"
/>
<span>Choose or drop photo</span>
</label>
}
/>
}
/>,
<FileUpload id="invoice" name="invoice" label="Invoice" accept="application/pdf" />,
<DropZone
id="photos"
name="photos"
label="Delivery photos"
accept="image/*"
multiple
preview={null}
status="Drop images here or click to choose · Up to 10 files"
/>,
trustedMarkup(
renderIsland('design-system.picture-grid-demo', pictureGridDemo, {
id: 'catalogue-gallery',
}),
),
trustedMarkup(
renderIsland('design-system.picture-grid-demo', pictureGridDemo, {
id: 'catalogue-gallery-empty',
empty: true,
}),
),
disabledPictureGridDemo(),
]}
/>
)#Contract
#Picture-grid uploads
Use <DropZone variant="picture-grid" id="gallery" name="photos" label="Gallery" multiple />
to show an image field as a responsive list of cards with a native picker. The default
accept is image/*. Pass span="full" when the field should take a whole form row.
The default DropZone frame, ImageDropZone and FileUpload keep their existing APIs.
- Supply
itemsas a controlled array ofDropZonePictureItem.idmust be unique and stay stable through upload, retry and replacement.nameis the visible filename and names each action. UsethumbnailSrcfor the card andpreviewSrcfor the full image. An available URL can fill either slot. For local files, the host supplies and releases any object URLs. An item without an image URL shows the image symbol. onFiles(files)receives an accepted batch from the picker or drop. The picker clears so the same file can be chosen again. WithoutonFiles, the input retains itsFileListfor native multipart submission. Accepted batches emit bubblinginputandchangeevents in native form mode. Server rendering includes the input, thumbnails and status. Mount the view through KetJS for drag handling, validation and callback actions.maxItemscounts saved, pending and failed items. A batch that exceeds the remaining capacity or failsacceptvalidation is rejected together and announced. Omitmultipleto accept at most one file per selection. At capacity the picker remains focusable for its limit notice.requiredapplies to the native input whileitemsis empty. A host usingonFilesvalidates upload completion and saved state in its own save flow.onPreview(item, trigger)can open a host viewer. The default opens a named image dialog and returns focus when it closes.onReplace(item)requests the host's replacement flow,onRemove(item)requests removal, andonRetry(item)appears on failed items. Activating a focused Retry button moves focus to its card as the action restarts. The host publishes newitemsafter handling the action. IfonRemoveoronRetryremoves the card asynchronously, return a promise that resolves after the list update so focus can move to a neighboring action or the Add picker.disableddisables the whole field.disabledActionsdisables selected actions for one item, for example while a request is pending.- An uploading item uses a
progressvalue from0to100when available. Leave it undefined for an indeterminate indicator. Setstatustodonefor explicit completion, orerrorwith an optionalerrormessage. Omit the status for a saved thumbnail without a status label. Pass localizedlabelsand the host's localized error text. Item action labels anduploadingsupport the{name}placeholder.
The catalogue's File upload and drop zone specimen includes editable, empty and disabled galleries. Its file and retry interactions use local demonstration state.
#API
Generated from the package source. A property without a description has none in the source yet.
#DropZoneComponent
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
namerequired | – | string | – |
labelrequired | – | string | – |
accept | – | string | – |
multiple | – | boolean | – |
required | – | boolean | – |
disabled | – | boolean | – |
help | – | string | null | – |
error | – | string | null | – |
issues | – | readonly FieldIssue[] | – |
status | – | JSXChild | – |
span | – | 'half' | 'full' | – |
items | – | readonly DropZonePictureItem[] | – |
maxItems | – | number | – |
labels | – | Partial<DropZonePictureLabels> | – |
onFiles | – | (files: File[]) => void | – |
onPreview | – | (item: DropZonePictureItem, trigger: HTMLButtonElement) => void | – |
onReplace | – | (item: DropZonePictureItem) => void | – |
onRemove | – | (item: DropZonePictureItem) => void | Promise<void> | – |
onRetry | – | (item: DropZonePictureItem) => void | – |
variant | – | 'picture-grid' | – |
preview | null reserves a square image frame before an image is selected. | { src: string; alt: string } | null | – |
dragging | The application drag runtime owns this state and upload transport. | boolean | – |
#FileUploadComponent
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
namerequired | – | string | – |
labelrequired | – | string | – |
accept | – | string | – |
multiple | – | boolean | – |
required | – | boolean | – |
disabled | – | boolean | – |
help | – | string | null | – |
error | – | string | null | – |
issues | – | readonly FieldIssue[] | – |
status | – | JSXChild | – |
span | – | 'half' | 'full' | – |
#ImageDropZoneComponent
Image-only upload surface. The record adapter owns commands and file events; this component owns the thumbnail, hidden native picker and inline actions.
| Property | Description | Type | Default |
|---|---|---|---|
labelrequired | – | string | – |
viewer | – | JSXChild | null | – |
picker | – | JSXChild | – |
actions | – | JSXChild | – |
help | – | string | null | – |
error | – | string | null | – |
busy | – | boolean | – |
dragging | – | boolean | – |
#Types
#DropZonePictureAction
type DropZonePictureAction = 'preview' | 'replace' | 'remove' | 'retry'#DropZonePictureItem
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
namerequired | – | string | – |
thumbnailSrc | – | string | – |
previewSrc | – | string | – |
status | – | 'uploading' | 'done' | 'error' | – |
progress | – | number | – |
error | – | string | – |
disabledActions | – | readonly DropZonePictureAction[] | – |
#DropZonePictureLabels
| Property | Description | Type | Default |
|---|---|---|---|
addrequired | – | string | – |
fullrequired | – | string | – |
limitrequired | – | string | – |
invalidTyperequired | – | string | – |
previewrequired | Item labels accept a {name} placeholder. | string | – |
replacerequired | – | string | – |
removerequired | – | string | – |
retryrequired | – | string | – |
uploadingrequired | – | string | – |
pendingrequired | – | string | – |
donerequired | – | string | – |
failedrequired | – | string | – |
closerequired | – | string | – |
#DropZoneProps
The properties of DropZone, listed above.
#FileUploadProps
The properties of FileUpload, listed above.
#Hooks
The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.
file-uploaddrop-zoneupload-previewupload-captionupload-statuspicture-gridpicture-grid-itemspicture-grid-itempicture-grid-thumbnailpicture-grid-namepicture-grid-actionspicture-grid-statuspicture-grid-addpicture-grid-validationpicture-grid-previewimage-drop-zoneimage-drop-previewimage-drop-actionsimage-drop-pickerimage-drop-helpimage-drop-error