jbpenrath
2025-01-07 23:28:47 +01:00
committed by Jean-Baptiste PENRATH
parent 0f6a8dfa72
commit 56d9ed88f0
27 changed files with 1497 additions and 1546 deletions

View File

@@ -1,11 +1,12 @@
import React, { forwardRef, InputHTMLAttributes, ReactElement } from "react";
import React, { InputHTMLAttributes, ReactElement, RefAttributes } from "react";
import { Field, FieldProps, FieldState } from ":/components/Forms/Field";
import { FileUploaderMulti } from ":/components/Forms/FileUploader/FileUploaderMulti";
import { FileUploaderMono } from ":/components/Forms/FileUploader/FileUploaderMono";
export interface FileUploaderProps
extends Omit<FieldProps, "state">,
InputHTMLAttributes<HTMLInputElement> {
InputHTMLAttributes<HTMLInputElement>,
RefAttributes<FileUploaderRefType> {
state?: FieldState | "uploading" | undefined;
multiple?: boolean;
icon?: ReactElement;
@@ -25,16 +26,18 @@ export interface FileUploaderRefType {
reset: () => void;
}
export const FileUploader = forwardRef<FileUploaderRefType, FileUploaderProps>(
({ fullWidth, ...props }, ref) => {
return (
<Field fullWidth={fullWidth} className={props.className}>
{props.multiple ? (
<FileUploaderMulti {...props} ref={ref} />
) : (
<FileUploaderMono {...props} ref={ref} />
)}
</Field>
);
},
);
export const FileUploader = ({
fullWidth,
ref,
...props
}: FileUploaderProps) => {
return (
<Field fullWidth={fullWidth} className={props.className}>
{props.multiple ? (
<FileUploaderMulti {...props} ref={ref} />
) : (
<FileUploaderMono {...props} ref={ref} />
)}
</Field>
);
};