@majapisoftwares/ui 4.1.12 → 4.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,7 +20,7 @@ export type FileUrl = {
|
|
|
20
20
|
size: number;
|
|
21
21
|
};
|
|
22
22
|
export type FileInputFile = FileFile | FileUrl;
|
|
23
|
-
declare function FileInput<PFP extends object>({ error, className, helpText, onChange, name, limit, label, id, required, onMouseOver, onMouseOut, readOnly, value, emptyText, downloadText, openText, fileDisplay, asyncUpload, onRejectFiles, loading, maxConcurrentUploads, fileAdditionalInfo, ref, fileSelectClassName, previewFileClassName, filesPerPage, previewFileComponent, previewFileProps, ...props }: Pick<InputProps<false>, "error" | "className" | "helpText" | "name" | "label" | "id" | "required" | "onMouseOver" | "onMouseOut"> & Omit<FileSelectProps, "onAcceptFiles" | "onRejectFiles"> & {
|
|
23
|
+
declare function FileInput<PFP extends object>({ error, className, helpText, onChange, name, limit, label, id, required, onMouseOver, onMouseOut, readOnly, value, emptyText, downloadText, openText, fileDisplay, asyncUpload, onRejectFiles, loading, maxConcurrentUploads, fileAdditionalInfo, ref, fileSelectClassName, previewFileClassName, filesPerPage, previewFileComponent, previewFileProps, filesClassName, ...props }: Pick<InputProps<false>, "error" | "className" | "helpText" | "name" | "label" | "id" | "required" | "onMouseOver" | "onMouseOut"> & Omit<FileSelectProps, "onAcceptFiles" | "onRejectFiles"> & {
|
|
24
24
|
readOnly?: boolean;
|
|
25
25
|
value?: FileInputFile[];
|
|
26
26
|
onChange?: (event: {
|
|
@@ -46,6 +46,7 @@ declare function FileInput<PFP extends object>({ error, className, helpText, onC
|
|
|
46
46
|
filesPerPage?: number;
|
|
47
47
|
previewFileComponent?: ComponentType<PreviewFileProps & PFP>;
|
|
48
48
|
previewFileProps?: PFP;
|
|
49
|
+
filesClassName?: string;
|
|
49
50
|
}): import("react").JSX.Element;
|
|
50
51
|
export type FileInputProps = ComponentPropsWithRef<typeof FileInput>;
|
|
51
52
|
declare const _default: typeof FileInput;
|
|
@@ -10,7 +10,7 @@ import PreviewFile from "./PreviewFile";
|
|
|
10
10
|
import concurrentForOf from "@majapisoftwares/next/utils/concurrentForOf";
|
|
11
11
|
import paginated from "@majapisoftwares/next/utils/paginated";
|
|
12
12
|
import Pagination from "../Pagination";
|
|
13
|
-
function FileInput({ error, className, helpText, onChange, name, limit, label, id, required, onMouseOver, onMouseOut, readOnly, value, emptyText = "No files", downloadText = "Download", openText = "Open", fileDisplay, asyncUpload, onRejectFiles, loading, maxConcurrentUploads = 1, fileAdditionalInfo, ref, fileSelectClassName, previewFileClassName, filesPerPage = 10, previewFileComponent, previewFileProps, ...props }) {
|
|
13
|
+
function FileInput({ error, className, helpText, onChange, name, limit, label, id, required, onMouseOver, onMouseOut, readOnly, value, emptyText = "No files", downloadText = "Download", openText = "Open", fileDisplay, asyncUpload, onRejectFiles, loading, maxConcurrentUploads = 1, fileAdditionalInfo, ref, fileSelectClassName, previewFileClassName, filesPerPage = 10, previewFileComponent, previewFileProps, filesClassName, ...props }) {
|
|
14
14
|
const [uploading, setUploading] = useState(false);
|
|
15
15
|
const [innerValue, setInnerValue] = useState(value || []);
|
|
16
16
|
const [currentPage, setCurrentPage] = useState(1);
|
|
@@ -127,9 +127,10 @@ function FileInput({ error, className, helpText, onChange, name, limit, label, i
|
|
|
127
127
|
<div className={clsx("flex flex-col gap-4", {
|
|
128
128
|
"md:grid md:grid-cols-2": !!innerValue.length,
|
|
129
129
|
"min-h-[140px]": !!innerValue.length || !readOnly,
|
|
130
|
+
filesClassName,
|
|
130
131
|
})}>
|
|
131
132
|
{paginatedValue.map((file, index) => (<PreviewFileComponent key={index} file={file} readOnly={readOnly} handleDeleteClick={handleDeleteClick(file)} downloadText={downloadText} display={fileDisplay} openText={openText} additionalInfo={fileAdditionalInfo} index={index} className={previewFileClassName} filesPerPage={filesPerPage} currentPage={currentPage} {...previewFileProps}/>))}
|
|
132
|
-
{innerValue.length > filesPerPage && (<Pagination className="col-span-2
|
|
133
|
+
{innerValue.length > filesPerPage && (<Pagination className="mx-auto md:col-span-2" currentPage={currentPage} totalItems={innerValue.length} onChangePage={setCurrentPage} itemsPerPage={filesPerPage}/>)}
|
|
133
134
|
{readOnly && !innerValue.length && (<Text variant="secondary">{emptyText}</Text>)}
|
|
134
135
|
{!readOnly && (!limit || innerValue.length < limit) && (<FileSelect {...props} className={fileSelectClassName} id={id} onAcceptFiles={handleAcceptFiles} limit={limit ? limit - innerValue.length : undefined} uploading={uploading} onRejectFiles={onRejectFiles} error={error}/>)}
|
|
135
136
|
</div>
|