@digital-ai/dot-components 2.24.2 → 2.25.0
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.
package/index.esm.js
CHANGED
|
@@ -10040,29 +10040,35 @@ const renderDropzoneContent = ({
|
|
|
10040
10040
|
}
|
|
10041
10041
|
};
|
|
10042
10042
|
const getUploadedFilesList = ({
|
|
10043
|
+
contentErrors,
|
|
10043
10044
|
maxSize,
|
|
10044
10045
|
onFileClick,
|
|
10045
10046
|
onFileDelete,
|
|
10046
10047
|
uploadedFiles
|
|
10047
10048
|
}) => uploadedFiles.map((fileToBeParsed, index) => parseListItem({
|
|
10049
|
+
contentError: contentErrors && contentErrors.length === uploadedFiles.length ? contentErrors[index] : null,
|
|
10048
10050
|
fileToBeParsed,
|
|
10049
|
-
onFileDelete,
|
|
10050
|
-
onFileClick,
|
|
10051
10051
|
index,
|
|
10052
|
-
maxSize
|
|
10052
|
+
maxSize,
|
|
10053
|
+
onFileDelete,
|
|
10054
|
+
onFileClick
|
|
10053
10055
|
}));
|
|
10054
10056
|
const parseListItem = ({
|
|
10055
|
-
|
|
10056
|
-
onFileClick,
|
|
10057
|
+
contentError,
|
|
10057
10058
|
fileToBeParsed,
|
|
10058
10059
|
index,
|
|
10059
|
-
maxSize
|
|
10060
|
+
maxSize,
|
|
10061
|
+
onFileDelete,
|
|
10062
|
+
onFileClick
|
|
10060
10063
|
}) => {
|
|
10061
10064
|
const fileErrors = fileToBeParsed.errors;
|
|
10062
10065
|
const parsedFile = fileToBeParsed.file;
|
|
10063
|
-
const
|
|
10066
|
+
const hasFileErrors = fileErrors.length > 0;
|
|
10067
|
+
const hasContentError = contentError && contentError !== null;
|
|
10064
10068
|
let errorText;
|
|
10065
|
-
if (
|
|
10069
|
+
if (hasContentError) {
|
|
10070
|
+
errorText = contentError;
|
|
10071
|
+
} else if (hasFileErrors) {
|
|
10066
10072
|
errorText = fileErrors.map(e => {
|
|
10067
10073
|
switch (e.code) {
|
|
10068
10074
|
case 'file-too-large':
|
|
@@ -10079,7 +10085,7 @@ const parseListItem = ({
|
|
|
10079
10085
|
return {
|
|
10080
10086
|
child: jsx(DotFileListItem, {
|
|
10081
10087
|
deleteFile: onFileDelete,
|
|
10082
|
-
error:
|
|
10088
|
+
error: hasContentError || hasFileErrors,
|
|
10083
10089
|
errorText: errorText,
|
|
10084
10090
|
file: {
|
|
10085
10091
|
id: index,
|
|
@@ -10104,6 +10110,7 @@ const DotFileUpload = ({
|
|
|
10104
10110
|
},
|
|
10105
10111
|
buttonOnly: _buttonOnly = false,
|
|
10106
10112
|
className,
|
|
10113
|
+
contentErrors,
|
|
10107
10114
|
'data-pendoid': dataPendoId = rootClassName$7,
|
|
10108
10115
|
'data-testid': dataTestId,
|
|
10109
10116
|
disabled,
|
|
@@ -10160,6 +10167,7 @@ const DotFileUpload = ({
|
|
|
10160
10167
|
onChange(uploadedFiles);
|
|
10161
10168
|
};
|
|
10162
10169
|
const uploadedFilesList = getUploadedFilesList({
|
|
10170
|
+
contentErrors,
|
|
10163
10171
|
maxSize,
|
|
10164
10172
|
onFileClick,
|
|
10165
10173
|
onFileDelete: deleteFile,
|
package/package.json
CHANGED
|
@@ -18,6 +18,8 @@ export interface FileUploadProps extends CommonProps {
|
|
|
18
18
|
buttonOnly?: boolean;
|
|
19
19
|
/** the file upload button props, not all button props are available */
|
|
20
20
|
buttonProps?: FileUploadButtonProps;
|
|
21
|
+
/** An array of strings describing errors with the contents of the file at that index, or null if there are no errors */
|
|
22
|
+
contentErrors?: Array<string>;
|
|
21
23
|
/** If true, the upload zone will be disabled */
|
|
22
24
|
disabled?: boolean;
|
|
23
25
|
/** If true, upload file list won't be displayed. Used when consumer wants to render his own list. */
|
|
@@ -33,5 +35,5 @@ export interface FileUploadProps extends CommonProps {
|
|
|
33
35
|
/** Optional callback which gets triggered when the file (from the list) is clicked. */
|
|
34
36
|
onFileClick?: (file: ListItemFile) => void;
|
|
35
37
|
}
|
|
36
|
-
export declare const DotFileUpload: ({ accept, ariaLabel, ariaRole, buttonProps, buttonOnly, className, "data-pendoid": dataPendoId, "data-testid": dataTestId, disabled, hideFilesList, maxFiles, maxSize, onChange, onDragEnter, onFileClick, }: FileUploadProps) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare const DotFileUpload: ({ accept, ariaLabel, ariaRole, buttonProps, buttonOnly, className, contentErrors, "data-pendoid": dataPendoId, "data-testid": dataTestId, disabled, hideFilesList, maxFiles, maxSize, onChange, onDragEnter, onFileClick, }: FileUploadProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
39
|
export {};
|
|
@@ -8,10 +8,10 @@ export declare const renderSelectFilesButton: (buttonProps: FileUploadButtonProp
|
|
|
8
8
|
export declare const renderActiveDragArea: () => ReactNode;
|
|
9
9
|
export declare const renderDragAndDropArea: (buttonProps: FileUploadButtonProps, isUploadDisabled: boolean, onSelectButtonClick: () => void) => ReactNode;
|
|
10
10
|
export declare const renderDropzoneContent: ({ buttonOnly, buttonProps, isDragActive, isUploadDisabled, open, }: DropzoneContentArgs) => React.ReactNode;
|
|
11
|
-
export declare const getUploadedFilesList: ({ maxSize, onFileClick, onFileDelete, uploadedFiles, }: UploadedFilesListArgs) => {
|
|
11
|
+
export declare const getUploadedFilesList: ({ contentErrors, maxSize, onFileClick, onFileDelete, uploadedFiles, }: UploadedFilesListArgs) => {
|
|
12
12
|
child: import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
}[];
|
|
14
|
-
export declare const parseListItem: ({
|
|
14
|
+
export declare const parseListItem: ({ contentError, fileToBeParsed, index, maxSize, onFileDelete, onFileClick, }: ParseListItemArgs) => {
|
|
15
15
|
child: import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
};
|
|
17
17
|
export declare const mapAcceptedFiles: (files: File[]) => {
|
|
@@ -21,12 +21,14 @@ export interface DropzoneContentArgs {
|
|
|
21
21
|
open: () => void;
|
|
22
22
|
}
|
|
23
23
|
export interface UploadedFilesListArgs {
|
|
24
|
+
contentErrors?: string[];
|
|
24
25
|
maxSize: number;
|
|
25
26
|
onFileClick?: (file: ListItemFile) => void;
|
|
26
27
|
onFileDelete: (fileIndexToBeRemoved: number) => void;
|
|
27
28
|
uploadedFiles: MappedFile[];
|
|
28
29
|
}
|
|
29
30
|
export interface ParseListItemArgs {
|
|
31
|
+
contentError?: string;
|
|
30
32
|
fileToBeParsed: MappedFile;
|
|
31
33
|
index: number;
|
|
32
34
|
maxSize: number;
|