Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import {FileUpload} from '../primereact/index.js';
import type {IWidgetProps} from '@feasibleone/blong';
import {useRef} from 'react';
// PrimeReact 8 declares chooseOptions/uploadOptions/cancelOptions via defaultProps,
// which React 19 no longer merges — pass them explicitly to prevent crashes.
const FILE_UPLOAD_OPTIONS = {
label: undefined,
icon: undefined,
iconOnly: false,
className: undefined,
style: undefined,
} as const;
export function FileWidget({
name: _name,
schema,
onChange,
error: _error,
readOnly,
disabled,
}: IWidgetProps) {
const uploadRef = useRef<FileUpload>(null);
const {accept, maxSize = 5_000_000} = schema.widget ?? {};
if (readOnly || disabled) return null;
return (
<FileUpload
ref={uploadRef}
mode="basic"
accept={accept ?? '*'}
maxFileSize={maxSize}
customUpload
uploadHandler={e => {
onChange(e.files[0] ?? null);
uploadRef.current?.clear();
}}
className="blong-file"
auto
chooseLabel="Choose"
chooseOptions={FILE_UPLOAD_OPTIONS}
uploadOptions={FILE_UPLOAD_OPTIONS}
cancelOptions={FILE_UPLOAD_OPTIONS}
/>
);
}
|