@astral/ui 4.103.0 → 4.103.2
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/components/Accordion/Accordion.js +2 -2
- package/components/Accordion/styles.d.ts +0 -4
- package/components/Accordion/styles.js +6 -7
- package/components/Accordion/useLogic/useLogic.d.ts +1 -1
- package/components/fileUploading/FileUploader/FIleList/FileList.d.ts +1 -1
- package/components/fileUploading/FileUploaderFile/Actions/Actions.js +2 -2
- package/components/fileUploading/FileUploaderFile/Actions/styles.js +7 -0
- package/components/fileUploading/FileUploaderFile/Actions/useLogic/useLogic.d.ts +6 -1
- package/components/fileUploading/FileUploaderFile/Actions/useLogic/useLogic.js +2 -1
- package/components/fileUploading/FileUploaderFile/FileUploaderFile.d.ts +1 -1
- package/components/fileUploading/PreviewFileUploader/FileList/FileList.d.ts +1 -1
- package/components/fileUploading/PreviewFileUploaderFile/FilePreview/FilePreview.d.ts +4 -0
- package/components/fileUploading/PreviewFileUploaderFile/FilePreview/FilePreview.js +1 -1
- package/components/fileUploading/PreviewFileUploaderFile/FilePreview/useLogic/useLogic.d.ts +13 -51
- package/components/fileUploading/PreviewFileUploaderFile/FilePreview/useLogic/useLogic.js +5 -1
- package/components/fileUploading/PreviewFileUploaderFile/PreviewFileUploaderFile.d.ts +4 -0
- package/components/fileUploading/PreviewFileUploaderFile/PreviewFileUploaderFile.js +2 -2
- package/components/fileUploading/hooks/useFileUploader/useFileUploader.d.ts +1 -0
- package/components/fileUploading/hooks/useFileUploader/useFileUploader.js +1 -0
- package/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.d.ts +1 -0
- package/node/components/Accordion/Accordion.js +1 -1
- package/node/components/Accordion/styles.d.ts +0 -4
- package/node/components/Accordion/styles.js +7 -8
- package/node/components/Accordion/useLogic/useLogic.d.ts +1 -1
- package/node/components/fileUploading/FileUploader/FIleList/FileList.d.ts +1 -1
- package/node/components/fileUploading/FileUploaderFile/Actions/Actions.js +2 -2
- package/node/components/fileUploading/FileUploaderFile/Actions/styles.js +7 -0
- package/node/components/fileUploading/FileUploaderFile/Actions/useLogic/useLogic.d.ts +6 -1
- package/node/components/fileUploading/FileUploaderFile/Actions/useLogic/useLogic.js +2 -1
- package/node/components/fileUploading/FileUploaderFile/FileUploaderFile.d.ts +1 -1
- package/node/components/fileUploading/PreviewFileUploader/FileList/FileList.d.ts +1 -1
- package/node/components/fileUploading/PreviewFileUploaderFile/FilePreview/FilePreview.d.ts +4 -0
- package/node/components/fileUploading/PreviewFileUploaderFile/FilePreview/FilePreview.js +1 -1
- package/node/components/fileUploading/PreviewFileUploaderFile/FilePreview/useLogic/useLogic.d.ts +13 -51
- package/node/components/fileUploading/PreviewFileUploaderFile/FilePreview/useLogic/useLogic.js +5 -1
- package/node/components/fileUploading/PreviewFileUploaderFile/PreviewFileUploaderFile.d.ts +4 -0
- package/node/components/fileUploading/PreviewFileUploaderFile/PreviewFileUploaderFile.js +2 -2
- package/node/components/fileUploading/hooks/useFileUploader/useFileUploader.d.ts +1 -0
- package/node/components/fileUploading/hooks/useFileUploader/useFileUploader.js +1 -0
- package/node/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { Collapse } from '../Collapse';
|
|
4
|
-
import { Chevron, ChevronWrapper, ContentWrapper, Header, SubtitleWrapper, Summary,
|
|
4
|
+
import { Chevron, ChevronWrapper, ContentWrapper, Header, SubtitleWrapper, Summary, } from './styles';
|
|
5
5
|
import { useLogic } from './useLogic';
|
|
6
6
|
export const Accordion = forwardRef(({ summary, startAdornment, isExpanded, onChange, children, summaryVariant = 'h6', subtitle, }, forwardedRef) => {
|
|
7
7
|
const { actualIsExpanded, hasStartAdornment, handleClick, handleKeyDown, hasSubtitle, } = useLogic({ startAdornment, isExpanded, onChange, subtitle });
|
|
8
|
-
return (_jsxs(
|
|
8
|
+
return (_jsxs("div", { ref: forwardedRef, children: [_jsxs(Header, { role: "button", tabIndex: 0, onClick: handleClick, onKeyDown: handleKeyDown, "$withStartAdornment": hasStartAdornment, "$hasSubtitle": hasSubtitle, children: [startAdornment, typeof summary === 'string' ? (_jsx(Summary, { variant: summaryVariant, children: summary })) : (summary), _jsx(ChevronWrapper, { children: _jsx(Chevron, { "$isActive": actualIsExpanded }) }), hasSubtitle && (_jsx(SubtitleWrapper, { "$withStartAdornment": hasStartAdornment, children: subtitle }))] }), _jsx(Collapse, { in: actualIsExpanded, unmountOnExit: true, children: _jsx(ContentWrapper, { "$withStartAdornment": hasStartAdornment, "$hasSubtitle": hasSubtitle, children: children }) })] }));
|
|
9
9
|
});
|
|
@@ -34,10 +34,6 @@ export declare const ChevronWrapper: import("../styled").StyledComponent<{
|
|
|
34
34
|
theme?: import("@emotion/react").Theme | undefined;
|
|
35
35
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
36
36
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
37
|
-
export declare const Wrapper: import("../styled").StyledComponent<{
|
|
38
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
39
|
-
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
40
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
41
37
|
export declare const Chevron: import("../styled").StyledComponent<{
|
|
42
38
|
children?: import("react").ReactNode;
|
|
43
39
|
color?: string | undefined;
|
|
@@ -11,6 +11,8 @@ export const Header = styled.header `
|
|
|
11
11
|
grid-template-columns: ${({ $withStartAdornment }) => $withStartAdornment ? '20px 1fr 20px' : ' 1fr 20px'};
|
|
12
12
|
grid-template-rows: ${({ $hasSubtitle }) => $hasSubtitle ? '20px 1fr' : '1fr'};
|
|
13
13
|
|
|
14
|
+
border-radius: ${({ theme }) => theme.shape.medium};
|
|
15
|
+
|
|
14
16
|
${({ theme }) => theme.breakpoints.down('mobile')} {
|
|
15
17
|
grid-row-gap: ${({ theme }) => theme.spacing(1)};
|
|
16
18
|
grid-template-rows: ${({ $hasSubtitle }) => $hasSubtitle ? '24px 1fr' : '1fr'};
|
|
@@ -18,6 +20,10 @@ export const Header = styled.header `
|
|
|
18
20
|
/* Убирает highlight на мобильных устройствах */
|
|
19
21
|
-webkit-tap-highlight-color: transparent;
|
|
20
22
|
}
|
|
23
|
+
|
|
24
|
+
&:focus-visible {
|
|
25
|
+
outline: 2px solid ${({ theme }) => theme.palette.components.focused};
|
|
26
|
+
}
|
|
21
27
|
|
|
22
28
|
& .${svgIconClassnames.root} {
|
|
23
29
|
font-size: 20px;
|
|
@@ -54,13 +60,6 @@ export const ChevronWrapper = styled.div `
|
|
|
54
60
|
height: 24px;
|
|
55
61
|
}
|
|
56
62
|
`;
|
|
57
|
-
export const Wrapper = styled.div `
|
|
58
|
-
border-radius: ${({ theme }) => theme.shape.medium};
|
|
59
|
-
|
|
60
|
-
&:focus-visible {
|
|
61
|
-
outline: 2px solid ${({ theme }) => theme.palette.components.focused};
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
63
|
export const Chevron = styled(DownOutlineMd, {
|
|
65
64
|
shouldForwardProp: (prop) => !['$isActive'].includes(prop),
|
|
66
65
|
}) `
|
|
@@ -3,7 +3,7 @@ import { type AccordionProps } from '../types';
|
|
|
3
3
|
type UseLogicParams = Pick<AccordionProps, 'startAdornment' | 'isExpanded' | 'onChange' | 'subtitle'>;
|
|
4
4
|
export declare const useLogic: ({ startAdornment, isExpanded, onChange, subtitle, }: UseLogicParams) => {
|
|
5
5
|
handleClick: (event: SyntheticEvent<HTMLElement>) => void;
|
|
6
|
-
handleKeyDown: (event: KeyboardEvent<
|
|
6
|
+
handleKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
7
7
|
actualIsExpanded: boolean;
|
|
8
8
|
isUncontrolledExpanded: boolean;
|
|
9
9
|
hasStartAdornment: boolean;
|
|
@@ -11,5 +11,5 @@ export type FileListProps = {
|
|
|
11
11
|
* Идентификатор файла, для которого выполняется удаление
|
|
12
12
|
*/
|
|
13
13
|
deletingFileId?: FileId | null;
|
|
14
|
-
} & Pick<FileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile'>;
|
|
14
|
+
} & Pick<FileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile' | 'isDisabled'>;
|
|
15
15
|
export declare const FileList: ({ isMultiple, files, className, deletingFileId, ...restProps }: FileListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,7 +10,7 @@ import { useViewportType } from '../../../useViewportType';
|
|
|
10
10
|
import { Wrapper } from './styles';
|
|
11
11
|
import { useLogic } from './useLogic';
|
|
12
12
|
export const Actions = (props) => {
|
|
13
|
-
const { downloadButtonProps, viewButtonProps, isVisibleAbortButton, isVisibleRetryButton, handleAbort, handleDelete, handleRetry, isLoading, isError, isDeletingFile, fileName, } = useLogic(props);
|
|
13
|
+
const { downloadButtonProps, viewButtonProps, isVisibleAbortButton, isVisibleRetryButton, handleAbort, handleDelete, handleRetry, isLoading, isError, isDeletingFile, isDisabled, fileName, } = useLogic(props);
|
|
14
14
|
const { isMobile } = useViewportType();
|
|
15
15
|
if (isLoading) {
|
|
16
16
|
return (_jsx(Wrapper, { children: isVisibleAbortButton && (_jsx(Tooltip, { title: "\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0443", children: _jsx(IconButton, { variant: "text", onClick: handleAbort, children: _jsx(CrossOutlineMd, {}) }) })) }));
|
|
@@ -19,5 +19,5 @@ export const Actions = (props) => {
|
|
|
19
19
|
return (_jsxs(Wrapper, { children: [isVisibleRetryButton && (_jsx(Tooltip, { title: "\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0443", children: _jsx(IconButton, { variant: "text", onClick: handleRetry, children: _jsx(RetryOutlineMd, {}) }) })), _jsx(Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", children: _jsx(IconButton, { variant: "text", onClick: handleDelete, loading: isDeletingFile, children: _jsx(CrossOutlineMd, {}) }) })] }));
|
|
20
20
|
}
|
|
21
21
|
const { isShowViewButton, ...restViewButtonProps } = viewButtonProps;
|
|
22
|
-
return (_jsxs(Wrapper, { children: [!isMobile && (_jsxs(_Fragment, { children: [isShowViewButton && (_jsx(Tooltip, { title: "\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C", children: _jsx(IconButton, { variant: "text", ...restViewButtonProps, children: _jsx(EyeOutlineMd, {}) }) })), _jsx(Tooltip, { title: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C", children: _jsx(IconButton, { component: "a", variant: "text", download: fileName, ...downloadButtonProps, children: _jsx(DownloadOutlineMd, {}) }) })] })), _jsx(Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", children: _jsx(IconButton, { variant: "text", onClick: handleDelete, loading: isDeletingFile, children: _jsx(BinOutlineMd, {}) }) })] }));
|
|
22
|
+
return (_jsxs(Wrapper, { children: [!isMobile && (_jsxs(_Fragment, { children: [isShowViewButton && (_jsx(Tooltip, { title: "\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C", children: _jsx(IconButton, { variant: "text", ...restViewButtonProps, children: _jsx(EyeOutlineMd, {}) }) })), _jsx(Tooltip, { title: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C", children: _jsx(IconButton, { component: "a", variant: "text", download: fileName, ...downloadButtonProps, children: _jsx(DownloadOutlineMd, {}) }) })] })), _jsx(Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", withoutContainer: !isDisabled, children: _jsx(IconButton, { variant: "text", onClick: handleDelete, loading: isDeletingFile, disabled: isDisabled, "aria-label": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", children: _jsx(BinOutlineMd, {}) }) })] }));
|
|
23
23
|
};
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { styled } from '../../../styled';
|
|
2
|
+
import { tooltipClassnames } from '../../../Tooltip';
|
|
2
3
|
export const Wrapper = styled.div `
|
|
3
4
|
text-align: right;
|
|
5
|
+
|
|
6
|
+
& .${tooltipClassnames.contentWrapper} {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
|
|
9
|
+
vertical-align: middle;
|
|
10
|
+
}
|
|
4
11
|
`;
|
|
@@ -49,9 +49,13 @@ export type UseLogicParams = {
|
|
|
49
49
|
* Флаг загрузки при удалении файла
|
|
50
50
|
*/
|
|
51
51
|
isDeletingFile?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Флаг блокировки действий
|
|
54
|
+
*/
|
|
55
|
+
isDisabled?: boolean;
|
|
52
56
|
abortController?: AbortController;
|
|
53
57
|
} & Pick<SelfFileApi, 'selfFiles' | 'setErrorStatusFile'>;
|
|
54
|
-
export declare const useLogic: ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, fileName, }: UseLogicParams) => {
|
|
58
|
+
export declare const useLogic: ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, isDisabled, fileName, }: UseLogicParams) => {
|
|
55
59
|
downloadButtonProps: {
|
|
56
60
|
href: string;
|
|
57
61
|
};
|
|
@@ -74,5 +78,6 @@ export declare const useLogic: ({ fileId, file, fileUrl, isUploadError, generate
|
|
|
74
78
|
isLoading: boolean | undefined;
|
|
75
79
|
isError: boolean | undefined;
|
|
76
80
|
isDeletingFile: boolean | undefined;
|
|
81
|
+
isDisabled: boolean | undefined;
|
|
77
82
|
fileName: string;
|
|
78
83
|
};
|
|
@@ -3,7 +3,7 @@ import { ABORT_ERROR_MESSAGE, EXTENSIONS_IN_NEW_TAB, VIEW_NEW_TAB_ERROR_MESSAGE,
|
|
|
3
3
|
import { useGenerateLocalFileURL } from '../../../hooks/useGenerateLocalFileURL';
|
|
4
4
|
import { MimeTypeRegistry } from '../../../services/MimeTypeRegistry';
|
|
5
5
|
import { generateAttrLinkNewTab } from '../../../utils/generateAttrLinkNewTab';
|
|
6
|
-
export const useLogic = ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, fileName, }) => {
|
|
6
|
+
export const useLogic = ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, isDisabled, fileName, }) => {
|
|
7
7
|
const { generateUrl } = useGenerateLocalFileURL();
|
|
8
8
|
const { controller } = selfFiles[fileId] || {};
|
|
9
9
|
const isVisibleAbortButton = Boolean(controller);
|
|
@@ -71,6 +71,7 @@ export const useLogic = ({ fileId, file, fileUrl, isUploadError, generateDownloa
|
|
|
71
71
|
isLoading,
|
|
72
72
|
isError,
|
|
73
73
|
isDeletingFile,
|
|
74
|
+
isDisabled,
|
|
74
75
|
fileName,
|
|
75
76
|
};
|
|
76
77
|
};
|
|
@@ -21,5 +21,5 @@ export type FileUploaderFileProps = UploadFile & {
|
|
|
21
21
|
* Флаг загрузки при удалении файла
|
|
22
22
|
*/
|
|
23
23
|
isDeletingFile?: boolean;
|
|
24
|
-
} & Pick<ActionsProps, 'selfFiles' | 'setErrorStatusFile'>;
|
|
24
|
+
} & Pick<ActionsProps, 'selfFiles' | 'setErrorStatusFile' | 'isDisabled'>;
|
|
25
25
|
export declare const FileUploaderFile: (props: FileUploaderFileProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,5 +6,5 @@ export type FileListProps = {
|
|
|
6
6
|
* Идентификатор файла, для которого выполняется удаление
|
|
7
7
|
*/
|
|
8
8
|
deletingFileId?: FileId | null;
|
|
9
|
-
} & Pick<PreviewFileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile'>;
|
|
9
|
+
} & Pick<PreviewFileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile' | 'isDisabled'>;
|
|
10
10
|
export declare const FileList: ({ files, deletingFileId, ...restProps }: FileListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,5 +10,5 @@ import { useLogic } from './useLogic';
|
|
|
10
10
|
export const FilePreview = (props) => {
|
|
11
11
|
const { getActionsList, isImageFile, isPdfFile, isOtherFile } = useLogic(props);
|
|
12
12
|
const { file, fileName, fileSize, fileUrl, generateDownloadLink, isHidePersonalData, PdfViewer, } = props;
|
|
13
|
-
return (_jsxs(Wrapper, { children: [!isOtherFile && (_jsx(Preview, { isImageFile: isImageFile, isPdfFile: isPdfFile, file: file, fileUrl: fileUrl, generateDownloadLink: generateDownloadLink, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer })), _jsxs(Details, { className: previewFileUploaderClassnames.details, "$isOtherFile": isOtherFile, children: [isOtherFile && _jsx(Typography, { variant: "h6", children: "\u0424\u0430\u0439\u043B \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D" }), _jsx(StyledFileInfo, { "$isOtherFile": isOtherFile, fileName: fileName, fileSize: fileSize }), _jsx(Actions, { children: getActionsList().map(({ type, ...action }) => (_jsx(Tooltip, { title: action.tooltip, disableInteractive: true, children: type === 'iconButton' ? (_jsx(IconButton, { ...action, children: action.icon })) : (_jsx(Button, { ...action, children:
|
|
13
|
+
return (_jsxs(Wrapper, { children: [!isOtherFile && (_jsx(Preview, { isImageFile: isImageFile, isPdfFile: isPdfFile, file: file, fileUrl: fileUrl, generateDownloadLink: generateDownloadLink, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer })), _jsxs(Details, { className: previewFileUploaderClassnames.details, "$isOtherFile": isOtherFile, children: [isOtherFile && _jsx(Typography, { variant: "h6", children: "\u0424\u0430\u0439\u043B \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D" }), _jsx(StyledFileInfo, { "$isOtherFile": isOtherFile, fileName: fileName, fileSize: fileSize }), _jsx(Actions, { children: getActionsList().map(({ type, ...action }) => (_jsx(Tooltip, { title: action.tooltip, disableInteractive: true, withoutContainer: !action.disabled, children: type === 'iconButton' ? (_jsx(IconButton, { ...action, children: action.icon })) : (_jsx(Button, { ...action, children: action.title ?? '' })) }, action.tooltip))) })] })] }));
|
|
14
14
|
};
|
|
@@ -1,61 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type ButtonProps } from '../../../../Button';
|
|
2
3
|
import { type FilePreviewProps } from '../FilePreview';
|
|
3
4
|
type UseLogicParams = FilePreviewProps;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Действие в списке actions превью файла.
|
|
7
|
+
*/
|
|
8
|
+
type FileAction = Omit<ButtonProps, 'type'> & {
|
|
9
|
+
type: 'button' | 'iconButton';
|
|
10
|
+
tooltip: string;
|
|
11
|
+
icon?: ReactElement;
|
|
12
|
+
title?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const useLogic: ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDelete, onView, fileType, isDeletingFile, isDisabled, }: UseLogicParams) => {
|
|
5
15
|
isImageFile: boolean;
|
|
6
16
|
isPdfFile: boolean;
|
|
7
17
|
/**
|
|
8
18
|
* Формат файла отличающийся от pdf и изображения
|
|
9
19
|
*/
|
|
10
20
|
isOtherFile: boolean;
|
|
11
|
-
getActionsList: () =>
|
|
12
|
-
type: string;
|
|
13
|
-
tooltip: string;
|
|
14
|
-
title: string;
|
|
15
|
-
variant: "light";
|
|
16
|
-
color: "grey";
|
|
17
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
18
|
-
loading: boolean | undefined;
|
|
19
|
-
onClick: () => void;
|
|
20
|
-
}[] | ({
|
|
21
|
-
component: import("react").ElementType;
|
|
22
|
-
href: string;
|
|
23
|
-
target: string;
|
|
24
|
-
rel: string;
|
|
25
|
-
type: string;
|
|
26
|
-
tooltip: string;
|
|
27
|
-
variant: "light";
|
|
28
|
-
color: "grey";
|
|
29
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
30
|
-
} | {
|
|
31
|
-
onClick: () => void | undefined;
|
|
32
|
-
type: string;
|
|
33
|
-
tooltip: string;
|
|
34
|
-
variant: "light";
|
|
35
|
-
color: "grey";
|
|
36
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
37
|
-
} | {
|
|
38
|
-
type: string;
|
|
39
|
-
tooltip: string;
|
|
40
|
-
component: "a";
|
|
41
|
-
variant: "light";
|
|
42
|
-
color: "grey";
|
|
43
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
44
|
-
download: string;
|
|
45
|
-
href: string;
|
|
46
|
-
loading?: undefined;
|
|
47
|
-
onClick?: undefined;
|
|
48
|
-
} | {
|
|
49
|
-
type: string;
|
|
50
|
-
tooltip: string;
|
|
51
|
-
variant: "light";
|
|
52
|
-
color: "grey";
|
|
53
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
54
|
-
loading: boolean | undefined;
|
|
55
|
-
onClick: () => void;
|
|
56
|
-
component?: undefined;
|
|
57
|
-
download?: undefined;
|
|
58
|
-
href?: undefined;
|
|
59
|
-
})[];
|
|
21
|
+
getActionsList: () => FileAction[];
|
|
60
22
|
};
|
|
61
23
|
export {};
|
|
@@ -8,7 +8,7 @@ import { EXTENSIONS_IN_NEW_TAB, VIEW_NEW_TAB_ERROR_MESSAGE, } from '../../../con
|
|
|
8
8
|
import { useGenerateLocalFileURL } from '../../../hooks/useGenerateLocalFileURL';
|
|
9
9
|
import { MimeTypeRegistry } from '../../../services/MimeTypeRegistry';
|
|
10
10
|
import { generateAttrLinkNewTab } from '../../../utils/generateAttrLinkNewTab';
|
|
11
|
-
export const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDelete, onView, fileType, isDeletingFile, }) => {
|
|
11
|
+
export const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDelete, onView, fileType, isDeletingFile, isDisabled, }) => {
|
|
12
12
|
const { generateUrl } = useGenerateLocalFileURL();
|
|
13
13
|
const { isMobile } = useViewportType();
|
|
14
14
|
const isPdfFile = MimeTypeRegistry.getInstance()
|
|
@@ -81,6 +81,8 @@ export const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink
|
|
|
81
81
|
color: 'grey',
|
|
82
82
|
icon: createElement(BinOutlineMd),
|
|
83
83
|
loading: isDeletingFile,
|
|
84
|
+
disabled: isDisabled,
|
|
85
|
+
'aria-label': 'Удалить',
|
|
84
86
|
onClick: handleDelete,
|
|
85
87
|
},
|
|
86
88
|
];
|
|
@@ -104,6 +106,8 @@ export const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink
|
|
|
104
106
|
color: 'grey',
|
|
105
107
|
icon: createElement(BinOutlineMd),
|
|
106
108
|
loading: isDeletingFile,
|
|
109
|
+
disabled: isDisabled,
|
|
110
|
+
'aria-label': 'Удалить',
|
|
107
111
|
onClick: handleDelete,
|
|
108
112
|
},
|
|
109
113
|
];
|
|
@@ -27,6 +27,10 @@ export type PreviewFileUploaderFileProps = UploadFile & {
|
|
|
27
27
|
* Флаг загрузки при удалении файла
|
|
28
28
|
*/
|
|
29
29
|
isDeletingFile?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Флаг блокировки действий
|
|
32
|
+
*/
|
|
33
|
+
isDisabled?: boolean;
|
|
30
34
|
/**
|
|
31
35
|
* Компонент для отображения превью pdf-файлов
|
|
32
36
|
*/
|
|
@@ -5,8 +5,8 @@ import { FileLoading } from './FileLoading';
|
|
|
5
5
|
import { FilePreview } from './FilePreview';
|
|
6
6
|
import { Wrapper } from './styles';
|
|
7
7
|
export const PreviewFileUploaderFile = (props) => {
|
|
8
|
-
const { id, name, type, file, url, size, status, generateDownloadLink, onRetry, onDelete, onView, selfFiles, setErrorStatusFile, isHidePersonalData, PdfViewer, isDeletingFile, } = props;
|
|
8
|
+
const { id, name, type, file, url, size, status, generateDownloadLink, onRetry, onDelete, onView, selfFiles, setErrorStatusFile, isHidePersonalData, PdfViewer, isDeletingFile, isDisabled, } = props;
|
|
9
9
|
const { isLoading, isUploadError, isRestrictionError, errorMsg, progress } = status || {};
|
|
10
10
|
const isError = isUploadError || isRestrictionError;
|
|
11
|
-
return (_jsx(Fade, { in: true, children: _jsxs(Wrapper, { "$isLoading": isLoading, "$isError": isError, children: [!isLoading && !isError && (_jsx(FilePreview, { fileId: id, fileName: name, fileType: type, file: file, fileUrl: url, fileSize: size, generateDownloadLink: generateDownloadLink, onView: onView, onDelete: onDelete, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer, isDeletingFile: isDeletingFile })), isLoading && (_jsx(FileLoading, { selfFiles: selfFiles, setErrorStatusFile: setErrorStatusFile, fileId: id, fileName: name, fileSize: size, progress: progress })), isError && (_jsx(FileError, { fileId: id, fileName: name, file: file, fileSize: size, errorMsg: errorMsg, isUploadError: isUploadError, onRetry: onRetry, onDelete: onDelete }))] }) }));
|
|
11
|
+
return (_jsx(Fade, { in: true, children: _jsxs(Wrapper, { "$isLoading": isLoading, "$isError": isError, children: [!isLoading && !isError && (_jsx(FilePreview, { fileId: id, fileName: name, fileType: type, file: file, fileUrl: url, fileSize: size, generateDownloadLink: generateDownloadLink, onView: onView, onDelete: onDelete, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer, isDeletingFile: isDeletingFile, isDisabled: isDisabled })), isLoading && (_jsx(FileLoading, { selfFiles: selfFiles, setErrorStatusFile: setErrorStatusFile, fileId: id, fileName: name, fileSize: size, progress: progress })), isError && (_jsx(FileError, { fileId: id, fileName: name, file: file, fileSize: size, errorMsg: errorMsg, isUploadError: isUploadError, onRetry: onRetry, onDelete: onDelete }))] }) }));
|
|
12
12
|
};
|
|
@@ -44,6 +44,7 @@ export declare const useFileUploader: ({ value, isDisabled, isMultiple, accept,
|
|
|
44
44
|
className: string;
|
|
45
45
|
};
|
|
46
46
|
fileListProps: {
|
|
47
|
+
isDisabled: boolean | undefined;
|
|
47
48
|
onDelete: (fileId: FileId) => void;
|
|
48
49
|
onRetry: ((fileId: FileId, file: File) => void) | undefined;
|
|
49
50
|
onView: ((fileId: string, file?: File | undefined, fileUrl?: string | undefined) => void) | undefined;
|
|
@@ -90,6 +90,7 @@ export declare const usePreviewFileUploader: ({ placeholderImgSrc, isHidePersona
|
|
|
90
90
|
fileListProps: {
|
|
91
91
|
isHidePersonalData: boolean | undefined;
|
|
92
92
|
PdfViewer: LazyExoticComponent<(props: PdfViewerProps) => ReactElement> | ((props: PdfViewerProps) => ReactElement) | undefined;
|
|
93
|
+
isDisabled: boolean | undefined;
|
|
93
94
|
onDelete: (fileId: string) => void;
|
|
94
95
|
onRetry: ((fileId: string, file: File) => void) | undefined;
|
|
95
96
|
onView: ((fileId: string, file?: File | undefined, fileUrl?: string | undefined) => void) | undefined;
|
|
@@ -8,5 +8,5 @@ const styles_1 = require("./styles");
|
|
|
8
8
|
const useLogic_1 = require("./useLogic");
|
|
9
9
|
exports.Accordion = (0, react_1.forwardRef)(({ summary, startAdornment, isExpanded, onChange, children, summaryVariant = 'h6', subtitle, }, forwardedRef) => {
|
|
10
10
|
const { actualIsExpanded, hasStartAdornment, handleClick, handleKeyDown, hasSubtitle, } = (0, useLogic_1.useLogic)({ startAdornment, isExpanded, onChange, subtitle });
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: forwardedRef, children: [(0, jsx_runtime_1.jsxs)(styles_1.Header, { role: "button", tabIndex: 0, onClick: handleClick, onKeyDown: handleKeyDown, "$withStartAdornment": hasStartAdornment, "$hasSubtitle": hasSubtitle, children: [startAdornment, typeof summary === 'string' ? ((0, jsx_runtime_1.jsx)(styles_1.Summary, { variant: summaryVariant, children: summary })) : (summary), (0, jsx_runtime_1.jsx)(styles_1.ChevronWrapper, { children: (0, jsx_runtime_1.jsx)(styles_1.Chevron, { "$isActive": actualIsExpanded }) }), hasSubtitle && ((0, jsx_runtime_1.jsx)(styles_1.SubtitleWrapper, { "$withStartAdornment": hasStartAdornment, children: subtitle }))] }), (0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { in: actualIsExpanded, unmountOnExit: true, children: (0, jsx_runtime_1.jsx)(styles_1.ContentWrapper, { "$withStartAdornment": hasStartAdornment, "$hasSubtitle": hasSubtitle, children: children }) })] }));
|
|
12
12
|
});
|
|
@@ -34,10 +34,6 @@ export declare const ChevronWrapper: import("@emotion/styled/dist/declarations/s
|
|
|
34
34
|
theme?: import("@emotion/react").Theme | undefined;
|
|
35
35
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
36
36
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
37
|
-
export declare const Wrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
38
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
39
|
-
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
40
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
41
37
|
export declare const Chevron: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
42
38
|
children?: import("react").ReactNode;
|
|
43
39
|
color?: string | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Chevron = exports.
|
|
3
|
+
exports.Chevron = exports.ChevronWrapper = exports.Summary = exports.ContentWrapper = exports.SubtitleWrapper = exports.Header = void 0;
|
|
4
4
|
const DownOutlineMd_1 = require("../../icons/DownOutlineMd");
|
|
5
5
|
const SvgIcon_1 = require("../SvgIcon");
|
|
6
6
|
const styled_1 = require("../styled");
|
|
@@ -14,6 +14,8 @@ exports.Header = styled_1.styled.header `
|
|
|
14
14
|
grid-template-columns: ${({ $withStartAdornment }) => $withStartAdornment ? '20px 1fr 20px' : ' 1fr 20px'};
|
|
15
15
|
grid-template-rows: ${({ $hasSubtitle }) => $hasSubtitle ? '20px 1fr' : '1fr'};
|
|
16
16
|
|
|
17
|
+
border-radius: ${({ theme }) => theme.shape.medium};
|
|
18
|
+
|
|
17
19
|
${({ theme }) => theme.breakpoints.down('mobile')} {
|
|
18
20
|
grid-row-gap: ${({ theme }) => theme.spacing(1)};
|
|
19
21
|
grid-template-rows: ${({ $hasSubtitle }) => $hasSubtitle ? '24px 1fr' : '1fr'};
|
|
@@ -21,6 +23,10 @@ exports.Header = styled_1.styled.header `
|
|
|
21
23
|
/* Убирает highlight на мобильных устройствах */
|
|
22
24
|
-webkit-tap-highlight-color: transparent;
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
&:focus-visible {
|
|
28
|
+
outline: 2px solid ${({ theme }) => theme.palette.components.focused};
|
|
29
|
+
}
|
|
24
30
|
|
|
25
31
|
& .${SvgIcon_1.svgIconClassnames.root} {
|
|
26
32
|
font-size: 20px;
|
|
@@ -57,13 +63,6 @@ exports.ChevronWrapper = styled_1.styled.div `
|
|
|
57
63
|
height: 24px;
|
|
58
64
|
}
|
|
59
65
|
`;
|
|
60
|
-
exports.Wrapper = styled_1.styled.div `
|
|
61
|
-
border-radius: ${({ theme }) => theme.shape.medium};
|
|
62
|
-
|
|
63
|
-
&:focus-visible {
|
|
64
|
-
outline: 2px solid ${({ theme }) => theme.palette.components.focused};
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
67
66
|
exports.Chevron = (0, styled_1.styled)(DownOutlineMd_1.DownOutlineMd, {
|
|
68
67
|
shouldForwardProp: (prop) => !['$isActive'].includes(prop),
|
|
69
68
|
}) `
|
|
@@ -3,7 +3,7 @@ import { type AccordionProps } from '../types';
|
|
|
3
3
|
type UseLogicParams = Pick<AccordionProps, 'startAdornment' | 'isExpanded' | 'onChange' | 'subtitle'>;
|
|
4
4
|
export declare const useLogic: ({ startAdornment, isExpanded, onChange, subtitle, }: UseLogicParams) => {
|
|
5
5
|
handleClick: (event: SyntheticEvent<HTMLElement>) => void;
|
|
6
|
-
handleKeyDown: (event: KeyboardEvent<
|
|
6
|
+
handleKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
7
7
|
actualIsExpanded: boolean;
|
|
8
8
|
isUncontrolledExpanded: boolean;
|
|
9
9
|
hasStartAdornment: boolean;
|
|
@@ -11,5 +11,5 @@ export type FileListProps = {
|
|
|
11
11
|
* Идентификатор файла, для которого выполняется удаление
|
|
12
12
|
*/
|
|
13
13
|
deletingFileId?: FileId | null;
|
|
14
|
-
} & Pick<FileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile'>;
|
|
14
|
+
} & Pick<FileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile' | 'isDisabled'>;
|
|
15
15
|
export declare const FileList: ({ isMultiple, files, className, deletingFileId, ...restProps }: FileListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,7 +13,7 @@ const useViewportType_1 = require("../../../useViewportType");
|
|
|
13
13
|
const styles_1 = require("./styles");
|
|
14
14
|
const useLogic_1 = require("./useLogic");
|
|
15
15
|
const Actions = (props) => {
|
|
16
|
-
const { downloadButtonProps, viewButtonProps, isVisibleAbortButton, isVisibleRetryButton, handleAbort, handleDelete, handleRetry, isLoading, isError, isDeletingFile, fileName, } = (0, useLogic_1.useLogic)(props);
|
|
16
|
+
const { downloadButtonProps, viewButtonProps, isVisibleAbortButton, isVisibleRetryButton, handleAbort, handleDelete, handleRetry, isLoading, isError, isDeletingFile, isDisabled, fileName, } = (0, useLogic_1.useLogic)(props);
|
|
17
17
|
const { isMobile } = (0, useViewportType_1.useViewportType)();
|
|
18
18
|
if (isLoading) {
|
|
19
19
|
return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { children: isVisibleAbortButton && ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0443", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", onClick: handleAbort, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) }) })) }));
|
|
@@ -22,6 +22,6 @@ const Actions = (props) => {
|
|
|
22
22
|
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [isVisibleRetryButton && ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0443", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", onClick: handleRetry, children: (0, jsx_runtime_1.jsx)(RetryOutlineMd_1.RetryOutlineMd, {}) }) })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", onClick: handleDelete, loading: isDeletingFile, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) }) })] }));
|
|
23
23
|
}
|
|
24
24
|
const { isShowViewButton, ...restViewButtonProps } = viewButtonProps;
|
|
25
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [!isMobile && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isShowViewButton && ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", ...restViewButtonProps, children: (0, jsx_runtime_1.jsx)(EyeOutlineMd_1.EyeOutlineMd, {}) }) })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { component: "a", variant: "text", download: fileName, ...downloadButtonProps, children: (0, jsx_runtime_1.jsx)(DownloadOutlineMd_1.DownloadOutlineMd, {}) }) })] })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", onClick: handleDelete, loading: isDeletingFile, children: (0, jsx_runtime_1.jsx)(BinOutlineMd_1.BinOutlineMd, {}) }) })] }));
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [!isMobile && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isShowViewButton && ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", ...restViewButtonProps, children: (0, jsx_runtime_1.jsx)(EyeOutlineMd_1.EyeOutlineMd, {}) }) })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C", children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { component: "a", variant: "text", download: fileName, ...downloadButtonProps, children: (0, jsx_runtime_1.jsx)(DownloadOutlineMd_1.DownloadOutlineMd, {}) }) })] })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", withoutContainer: !isDisabled, children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "text", onClick: handleDelete, loading: isDeletingFile, disabled: isDisabled, "aria-label": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", children: (0, jsx_runtime_1.jsx)(BinOutlineMd_1.BinOutlineMd, {}) }) })] }));
|
|
26
26
|
};
|
|
27
27
|
exports.Actions = Actions;
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Wrapper = void 0;
|
|
4
4
|
const styled_1 = require("../../../styled");
|
|
5
|
+
const Tooltip_1 = require("../../../Tooltip");
|
|
5
6
|
exports.Wrapper = styled_1.styled.div `
|
|
6
7
|
text-align: right;
|
|
8
|
+
|
|
9
|
+
& .${Tooltip_1.tooltipClassnames.contentWrapper} {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
}
|
|
7
14
|
`;
|
|
@@ -49,9 +49,13 @@ export type UseLogicParams = {
|
|
|
49
49
|
* Флаг загрузки при удалении файла
|
|
50
50
|
*/
|
|
51
51
|
isDeletingFile?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Флаг блокировки действий
|
|
54
|
+
*/
|
|
55
|
+
isDisabled?: boolean;
|
|
52
56
|
abortController?: AbortController;
|
|
53
57
|
} & Pick<SelfFileApi, 'selfFiles' | 'setErrorStatusFile'>;
|
|
54
|
-
export declare const useLogic: ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, fileName, }: UseLogicParams) => {
|
|
58
|
+
export declare const useLogic: ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, isDisabled, fileName, }: UseLogicParams) => {
|
|
55
59
|
downloadButtonProps: {
|
|
56
60
|
href: string;
|
|
57
61
|
};
|
|
@@ -74,5 +78,6 @@ export declare const useLogic: ({ fileId, file, fileUrl, isUploadError, generate
|
|
|
74
78
|
isLoading: boolean | undefined;
|
|
75
79
|
isError: boolean | undefined;
|
|
76
80
|
isDeletingFile: boolean | undefined;
|
|
81
|
+
isDisabled: boolean | undefined;
|
|
77
82
|
fileName: string;
|
|
78
83
|
};
|
|
@@ -6,7 +6,7 @@ const constants_1 = require("../../../constants");
|
|
|
6
6
|
const useGenerateLocalFileURL_1 = require("../../../hooks/useGenerateLocalFileURL");
|
|
7
7
|
const MimeTypeRegistry_1 = require("../../../services/MimeTypeRegistry");
|
|
8
8
|
const generateAttrLinkNewTab_1 = require("../../../utils/generateAttrLinkNewTab");
|
|
9
|
-
const useLogic = ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, fileName, }) => {
|
|
9
|
+
const useLogic = ({ fileId, file, fileUrl, isUploadError, generateDownloadLink, onDelete, onRetry, onView, setErrorStatusFile, selfFiles, isLoading, isError, isDeletingFile, isDisabled, fileName, }) => {
|
|
10
10
|
const { generateUrl } = (0, useGenerateLocalFileURL_1.useGenerateLocalFileURL)();
|
|
11
11
|
const { controller } = selfFiles[fileId] || {};
|
|
12
12
|
const isVisibleAbortButton = Boolean(controller);
|
|
@@ -74,6 +74,7 @@ const useLogic = ({ fileId, file, fileUrl, isUploadError, generateDownloadLink,
|
|
|
74
74
|
isLoading,
|
|
75
75
|
isError,
|
|
76
76
|
isDeletingFile,
|
|
77
|
+
isDisabled,
|
|
77
78
|
fileName,
|
|
78
79
|
};
|
|
79
80
|
};
|
|
@@ -21,5 +21,5 @@ export type FileUploaderFileProps = UploadFile & {
|
|
|
21
21
|
* Флаг загрузки при удалении файла
|
|
22
22
|
*/
|
|
23
23
|
isDeletingFile?: boolean;
|
|
24
|
-
} & Pick<ActionsProps, 'selfFiles' | 'setErrorStatusFile'>;
|
|
24
|
+
} & Pick<ActionsProps, 'selfFiles' | 'setErrorStatusFile' | 'isDisabled'>;
|
|
25
25
|
export declare const FileUploaderFile: (props: FileUploaderFileProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,5 +6,5 @@ export type FileListProps = {
|
|
|
6
6
|
* Идентификатор файла, для которого выполняется удаление
|
|
7
7
|
*/
|
|
8
8
|
deletingFileId?: FileId | null;
|
|
9
|
-
} & Pick<PreviewFileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile'>;
|
|
9
|
+
} & Pick<PreviewFileUploaderFileProps, 'onDelete' | 'onRetry' | 'onView' | 'generateDownloadLink' | 'selfFiles' | 'setErrorStatusFile' | 'isDisabled'>;
|
|
10
10
|
export declare const FileList: ({ files, deletingFileId, ...restProps }: FileListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,6 +13,6 @@ const useLogic_1 = require("./useLogic");
|
|
|
13
13
|
const FilePreview = (props) => {
|
|
14
14
|
const { getActionsList, isImageFile, isPdfFile, isOtherFile } = (0, useLogic_1.useLogic)(props);
|
|
15
15
|
const { file, fileName, fileSize, fileUrl, generateDownloadLink, isHidePersonalData, PdfViewer, } = props;
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [!isOtherFile && ((0, jsx_runtime_1.jsx)(Preview_1.Preview, { isImageFile: isImageFile, isPdfFile: isPdfFile, file: file, fileUrl: fileUrl, generateDownloadLink: generateDownloadLink, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer })), (0, jsx_runtime_1.jsxs)(styles_1.Details, { className: constants_1.previewFileUploaderClassnames.details, "$isOtherFile": isOtherFile, children: [isOtherFile && (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "h6", children: "\u0424\u0430\u0439\u043B \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D" }), (0, jsx_runtime_1.jsx)(styles_1.StyledFileInfo, { "$isOtherFile": isOtherFile, fileName: fileName, fileSize: fileSize }), (0, jsx_runtime_1.jsx)(styles_1.Actions, { children: getActionsList().map(({ type, ...action }) => ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: action.tooltip, disableInteractive: true, children: type === 'iconButton' ? ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { ...action, children: action.icon })) : ((0, jsx_runtime_1.jsx)(Button_1.Button, { ...action, children:
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [!isOtherFile && ((0, jsx_runtime_1.jsx)(Preview_1.Preview, { isImageFile: isImageFile, isPdfFile: isPdfFile, file: file, fileUrl: fileUrl, generateDownloadLink: generateDownloadLink, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer })), (0, jsx_runtime_1.jsxs)(styles_1.Details, { className: constants_1.previewFileUploaderClassnames.details, "$isOtherFile": isOtherFile, children: [isOtherFile && (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "h6", children: "\u0424\u0430\u0439\u043B \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D" }), (0, jsx_runtime_1.jsx)(styles_1.StyledFileInfo, { "$isOtherFile": isOtherFile, fileName: fileName, fileSize: fileSize }), (0, jsx_runtime_1.jsx)(styles_1.Actions, { children: getActionsList().map(({ type, ...action }) => ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: action.tooltip, disableInteractive: true, withoutContainer: !action.disabled, children: type === 'iconButton' ? ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { ...action, children: action.icon })) : ((0, jsx_runtime_1.jsx)(Button_1.Button, { ...action, children: action.title ?? '' })) }, action.tooltip))) })] })] }));
|
|
17
17
|
};
|
|
18
18
|
exports.FilePreview = FilePreview;
|
package/node/components/fileUploading/PreviewFileUploaderFile/FilePreview/useLogic/useLogic.d.ts
CHANGED
|
@@ -1,61 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type ButtonProps } from '../../../../Button';
|
|
2
3
|
import { type FilePreviewProps } from '../FilePreview';
|
|
3
4
|
type UseLogicParams = FilePreviewProps;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Действие в списке actions превью файла.
|
|
7
|
+
*/
|
|
8
|
+
type FileAction = Omit<ButtonProps, 'type'> & {
|
|
9
|
+
type: 'button' | 'iconButton';
|
|
10
|
+
tooltip: string;
|
|
11
|
+
icon?: ReactElement;
|
|
12
|
+
title?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const useLogic: ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDelete, onView, fileType, isDeletingFile, isDisabled, }: UseLogicParams) => {
|
|
5
15
|
isImageFile: boolean;
|
|
6
16
|
isPdfFile: boolean;
|
|
7
17
|
/**
|
|
8
18
|
* Формат файла отличающийся от pdf и изображения
|
|
9
19
|
*/
|
|
10
20
|
isOtherFile: boolean;
|
|
11
|
-
getActionsList: () =>
|
|
12
|
-
type: string;
|
|
13
|
-
tooltip: string;
|
|
14
|
-
title: string;
|
|
15
|
-
variant: "light";
|
|
16
|
-
color: "grey";
|
|
17
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
18
|
-
loading: boolean | undefined;
|
|
19
|
-
onClick: () => void;
|
|
20
|
-
}[] | ({
|
|
21
|
-
component: import("react").ElementType;
|
|
22
|
-
href: string;
|
|
23
|
-
target: string;
|
|
24
|
-
rel: string;
|
|
25
|
-
type: string;
|
|
26
|
-
tooltip: string;
|
|
27
|
-
variant: "light";
|
|
28
|
-
color: "grey";
|
|
29
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
30
|
-
} | {
|
|
31
|
-
onClick: () => void | undefined;
|
|
32
|
-
type: string;
|
|
33
|
-
tooltip: string;
|
|
34
|
-
variant: "light";
|
|
35
|
-
color: "grey";
|
|
36
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
37
|
-
} | {
|
|
38
|
-
type: string;
|
|
39
|
-
tooltip: string;
|
|
40
|
-
component: "a";
|
|
41
|
-
variant: "light";
|
|
42
|
-
color: "grey";
|
|
43
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
44
|
-
download: string;
|
|
45
|
-
href: string;
|
|
46
|
-
loading?: undefined;
|
|
47
|
-
onClick?: undefined;
|
|
48
|
-
} | {
|
|
49
|
-
type: string;
|
|
50
|
-
tooltip: string;
|
|
51
|
-
variant: "light";
|
|
52
|
-
color: "grey";
|
|
53
|
-
icon: import("react").FunctionComponentElement<import("../../../..").SvgIconProps>;
|
|
54
|
-
loading: boolean | undefined;
|
|
55
|
-
onClick: () => void;
|
|
56
|
-
component?: undefined;
|
|
57
|
-
download?: undefined;
|
|
58
|
-
href?: undefined;
|
|
59
|
-
})[];
|
|
21
|
+
getActionsList: () => FileAction[];
|
|
60
22
|
};
|
|
61
23
|
export {};
|
package/node/components/fileUploading/PreviewFileUploaderFile/FilePreview/useLogic/useLogic.js
CHANGED
|
@@ -11,7 +11,7 @@ const constants_1 = require("../../../constants");
|
|
|
11
11
|
const useGenerateLocalFileURL_1 = require("../../../hooks/useGenerateLocalFileURL");
|
|
12
12
|
const MimeTypeRegistry_1 = require("../../../services/MimeTypeRegistry");
|
|
13
13
|
const generateAttrLinkNewTab_1 = require("../../../utils/generateAttrLinkNewTab");
|
|
14
|
-
const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDelete, onView, fileType, isDeletingFile, }) => {
|
|
14
|
+
const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDelete, onView, fileType, isDeletingFile, isDisabled, }) => {
|
|
15
15
|
const { generateUrl } = (0, useGenerateLocalFileURL_1.useGenerateLocalFileURL)();
|
|
16
16
|
const { isMobile } = (0, useViewportType_1.useViewportType)();
|
|
17
17
|
const isPdfFile = MimeTypeRegistry_1.MimeTypeRegistry.getInstance()
|
|
@@ -84,6 +84,8 @@ const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDel
|
|
|
84
84
|
color: 'grey',
|
|
85
85
|
icon: (0, react_1.createElement)(BinOutlineMd_1.BinOutlineMd),
|
|
86
86
|
loading: isDeletingFile,
|
|
87
|
+
disabled: isDisabled,
|
|
88
|
+
'aria-label': 'Удалить',
|
|
87
89
|
onClick: handleDelete,
|
|
88
90
|
},
|
|
89
91
|
];
|
|
@@ -107,6 +109,8 @@ const useLogic = ({ fileId, file, fileUrl, fileName, generateDownloadLink, onDel
|
|
|
107
109
|
color: 'grey',
|
|
108
110
|
icon: (0, react_1.createElement)(BinOutlineMd_1.BinOutlineMd),
|
|
109
111
|
loading: isDeletingFile,
|
|
112
|
+
disabled: isDisabled,
|
|
113
|
+
'aria-label': 'Удалить',
|
|
110
114
|
onClick: handleDelete,
|
|
111
115
|
},
|
|
112
116
|
];
|
|
@@ -27,6 +27,10 @@ export type PreviewFileUploaderFileProps = UploadFile & {
|
|
|
27
27
|
* Флаг загрузки при удалении файла
|
|
28
28
|
*/
|
|
29
29
|
isDeletingFile?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Флаг блокировки действий
|
|
32
|
+
*/
|
|
33
|
+
isDisabled?: boolean;
|
|
30
34
|
/**
|
|
31
35
|
* Компонент для отображения превью pdf-файлов
|
|
32
36
|
*/
|
|
@@ -8,9 +8,9 @@ const FileLoading_1 = require("./FileLoading");
|
|
|
8
8
|
const FilePreview_1 = require("./FilePreview");
|
|
9
9
|
const styles_1 = require("./styles");
|
|
10
10
|
const PreviewFileUploaderFile = (props) => {
|
|
11
|
-
const { id, name, type, file, url, size, status, generateDownloadLink, onRetry, onDelete, onView, selfFiles, setErrorStatusFile, isHidePersonalData, PdfViewer, isDeletingFile, } = props;
|
|
11
|
+
const { id, name, type, file, url, size, status, generateDownloadLink, onRetry, onDelete, onView, selfFiles, setErrorStatusFile, isHidePersonalData, PdfViewer, isDeletingFile, isDisabled, } = props;
|
|
12
12
|
const { isLoading, isUploadError, isRestrictionError, errorMsg, progress } = status || {};
|
|
13
13
|
const isError = isUploadError || isRestrictionError;
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)(Fade_1.Fade, { in: true, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { "$isLoading": isLoading, "$isError": isError, children: [!isLoading && !isError && ((0, jsx_runtime_1.jsx)(FilePreview_1.FilePreview, { fileId: id, fileName: name, fileType: type, file: file, fileUrl: url, fileSize: size, generateDownloadLink: generateDownloadLink, onView: onView, onDelete: onDelete, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer, isDeletingFile: isDeletingFile })), isLoading && ((0, jsx_runtime_1.jsx)(FileLoading_1.FileLoading, { selfFiles: selfFiles, setErrorStatusFile: setErrorStatusFile, fileId: id, fileName: name, fileSize: size, progress: progress })), isError && ((0, jsx_runtime_1.jsx)(FileError_1.FileError, { fileId: id, fileName: name, file: file, fileSize: size, errorMsg: errorMsg, isUploadError: isUploadError, onRetry: onRetry, onDelete: onDelete }))] }) }));
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(Fade_1.Fade, { in: true, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { "$isLoading": isLoading, "$isError": isError, children: [!isLoading && !isError && ((0, jsx_runtime_1.jsx)(FilePreview_1.FilePreview, { fileId: id, fileName: name, fileType: type, file: file, fileUrl: url, fileSize: size, generateDownloadLink: generateDownloadLink, onView: onView, onDelete: onDelete, isHidePersonalData: isHidePersonalData, PdfViewer: PdfViewer, isDeletingFile: isDeletingFile, isDisabled: isDisabled })), isLoading && ((0, jsx_runtime_1.jsx)(FileLoading_1.FileLoading, { selfFiles: selfFiles, setErrorStatusFile: setErrorStatusFile, fileId: id, fileName: name, fileSize: size, progress: progress })), isError && ((0, jsx_runtime_1.jsx)(FileError_1.FileError, { fileId: id, fileName: name, file: file, fileSize: size, errorMsg: errorMsg, isUploadError: isUploadError, onRetry: onRetry, onDelete: onDelete }))] }) }));
|
|
15
15
|
};
|
|
16
16
|
exports.PreviewFileUploaderFile = PreviewFileUploaderFile;
|
|
@@ -44,6 +44,7 @@ export declare const useFileUploader: ({ value, isDisabled, isMultiple, accept,
|
|
|
44
44
|
className: string;
|
|
45
45
|
};
|
|
46
46
|
fileListProps: {
|
|
47
|
+
isDisabled: boolean | undefined;
|
|
47
48
|
onDelete: (fileId: FileId) => void;
|
|
48
49
|
onRetry: ((fileId: FileId, file: File) => void) | undefined;
|
|
49
50
|
onView: ((fileId: string, file?: File | undefined, fileUrl?: string | undefined) => void) | undefined;
|
package/node/components/fileUploading/hooks/usePreviewFileUploader/usePreviewFileUploader.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ export declare const usePreviewFileUploader: ({ placeholderImgSrc, isHidePersona
|
|
|
90
90
|
fileListProps: {
|
|
91
91
|
isHidePersonalData: boolean | undefined;
|
|
92
92
|
PdfViewer: LazyExoticComponent<(props: PdfViewerProps) => ReactElement> | ((props: PdfViewerProps) => ReactElement) | undefined;
|
|
93
|
+
isDisabled: boolean | undefined;
|
|
93
94
|
onDelete: (fileId: string) => void;
|
|
94
95
|
onRetry: ((fileId: string, file: File) => void) | undefined;
|
|
95
96
|
onView: ((fileId: string, file?: File | undefined, fileUrl?: string | undefined) => void) | undefined;
|