@astral/ui 4.1.6 → 4.1.7
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/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/HintPlaceholder.js +3 -3
- package/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/styles.d.ts +16 -0
- package/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/styles.js +1 -0
- package/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/useLogic/useLogic.d.ts +10 -0
- package/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/useLogic/useLogic.js +8 -3
- package/components/fileUploading/PreviewFileUploaderFile/FileError/FileError.js +3 -3
- package/components/fileUploading/PreviewFileUploaderFile/FileError/styles.d.ts +16 -0
- package/components/fileUploading/PreviewFileUploaderFile/FileError/styles.js +1 -0
- package/components/fileUploading/PreviewFileUploaderFile/FileError/useLogic/useLogic.d.ts +10 -0
- package/components/fileUploading/PreviewFileUploaderFile/FileError/useLogic/useLogic.js +7 -2
- package/node/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/HintPlaceholder.js +2 -2
- package/node/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/styles.d.ts +16 -0
- package/node/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/styles.js +2 -1
- package/node/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/useLogic/useLogic.d.ts +10 -0
- package/node/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/useLogic/useLogic.js +7 -2
- package/node/components/fileUploading/PreviewFileUploaderFile/FileError/FileError.js +2 -2
- package/node/components/fileUploading/PreviewFileUploaderFile/FileError/styles.d.ts +16 -0
- package/node/components/fileUploading/PreviewFileUploaderFile/FileError/styles.js +2 -1
- package/node/components/fileUploading/PreviewFileUploaderFile/FileError/useLogic/useLogic.d.ts +10 -0
- package/node/components/fileUploading/PreviewFileUploaderFile/FileError/useLogic/useLogic.js +6 -1
- package/package.json +1 -1
package/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/HintPlaceholder.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { formatFileSizeToView } from '@astral/utils';
|
|
3
3
|
import { Typography } from '../../../Typography';
|
|
4
|
-
import { Extensions,
|
|
4
|
+
import { Extensions, Wrapper } from './styles';
|
|
5
5
|
import { useLogic } from './useLogic';
|
|
6
6
|
export const HintPlaceholder = (props) => {
|
|
7
|
-
const { extensions, imageProps, maxFileSize, placeholder, className } = useLogic(props);
|
|
8
|
-
return (_jsxs(Wrapper, { className: className, children: [_jsx(
|
|
7
|
+
const { extensions, imageProps, maxFileSize, placeholder, className, RenderImage, } = useLogic(props);
|
|
8
|
+
return (_jsxs(Wrapper, { className: className, children: [_jsx(RenderImage, Object.assign({}, imageProps, { alt: "\u0424\u0430\u0439\u043B\u044B \u0434\u043B\u044F \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438" })), _jsx(Typography, { component: "p", color: "textSecondary", variant: "caption", align: "center", children: placeholder || (_jsxs(_Fragment, { children: ["\u041F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u043B\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0444\u0430\u0439\u043B. \u0420\u0430\u0437\u043C\u0435\u0440\u043E\u043C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435", ' ', formatFileSizeToView(maxFileSize), extensions && ' в формате ', _jsx(Extensions, { children: extensions })] })) })] }));
|
|
9
9
|
};
|
|
@@ -7,6 +7,22 @@ export declare const Image: import("@emotion/styled").StyledComponent<{
|
|
|
7
7
|
theme?: import("@emotion/react").Theme | undefined;
|
|
8
8
|
as?: import("react").ElementType<any> | undefined;
|
|
9
9
|
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
10
|
+
export declare const setDefaultImageStyles: {
|
|
11
|
+
<C extends import("react").ComponentClass<import("react").ComponentProps<C>, any>>(component: C): import("@emotion/styled").StyledComponent<{
|
|
12
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
13
|
+
as?: import("react").ElementType<any> | undefined;
|
|
14
|
+
} & JSX.LibraryManagedAttributes<C, import("react").ComponentProps<C>>, {}, {
|
|
15
|
+
ref?: import("react").Ref<InstanceType<C>> | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
<C_1 extends import("react").ComponentType<import("react").ComponentProps<C_1>>>(component: C_1): import("@emotion/styled").StyledComponent<{
|
|
18
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
19
|
+
as?: import("react").ElementType<any> | undefined;
|
|
20
|
+
} & JSX.LibraryManagedAttributes<C_1, import("react").ComponentProps<C_1>>, {}, {}>;
|
|
21
|
+
<Tag extends keyof JSX.IntrinsicElements>(tag: Tag): import("@emotion/styled").StyledComponent<{
|
|
22
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
23
|
+
as?: import("react").ElementType<any> | undefined;
|
|
24
|
+
}, JSX.IntrinsicElements[Tag], {}>;
|
|
25
|
+
};
|
|
10
26
|
export declare const Extensions: import("@emotion/styled").StyledComponent<{
|
|
11
27
|
theme?: import("@emotion/react").Theme | undefined;
|
|
12
28
|
as?: import("react").ElementType<any> | undefined;
|
package/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/useLogic/useLogic.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export type UseLogicParams = {
|
|
2
3
|
/**
|
|
3
4
|
* Массив разрешенных расширений
|
|
@@ -27,6 +28,15 @@ export declare const useLogic: ({ accept, placeholderImgSrc, ...rest }: UseLogic
|
|
|
27
28
|
*/
|
|
28
29
|
placeholder?: string | undefined;
|
|
29
30
|
className?: string | undefined;
|
|
31
|
+
RenderImage: import("@emotion/styled").StyledComponent<{
|
|
32
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
33
|
+
as?: import("react").ElementType<any> | undefined;
|
|
34
|
+
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}> | import("@emotion/styled").StyledComponent<{
|
|
35
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
36
|
+
as?: import("react").ElementType<any> | undefined;
|
|
37
|
+
} & Pick<import("react").AllHTMLAttributes<HTMLImageElement>, "height" | "width" | "className" | "alt" | "src"> & {
|
|
38
|
+
size?: import("../../../..").PlaceholderSize | undefined;
|
|
39
|
+
}, {}, {}>;
|
|
30
40
|
extensions: string | undefined;
|
|
31
41
|
imageProps: {
|
|
32
42
|
src: string | undefined;
|
package/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/useLogic/useLogic.js
CHANGED
|
@@ -10,12 +10,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { formatFileTypeToView } from '@astral/utils';
|
|
13
|
-
import { useContext } from 'react';
|
|
13
|
+
import { useContext, useMemo } from 'react';
|
|
14
14
|
import { ConfigContext, } from '../../../../ConfigProvider';
|
|
15
|
+
import { Image, setDefaultImageStyles } from '../styles';
|
|
15
16
|
export const useLogic = (_a) => {
|
|
17
|
+
var _b, _c;
|
|
16
18
|
var { accept, placeholderImgSrc } = _a, rest = __rest(_a, ["accept", "placeholderImgSrc"]);
|
|
17
|
-
const { imagesMap } = useContext(ConfigContext);
|
|
19
|
+
const { imagesMap, components } = useContext(ConfigContext);
|
|
18
20
|
const { uploadFileImgSrc } = imagesMap;
|
|
21
|
+
const configRenderImage = (_c = (_b = components === null || components === void 0 ? void 0 : components.placeholder) === null || _b === void 0 ? void 0 : _b.defaultProps) === null || _c === void 0 ? void 0 : _c.renderImage;
|
|
22
|
+
const RenderImage = useMemo(() => configRenderImage ? setDefaultImageStyles(configRenderImage) : Image, [configRenderImage]);
|
|
19
23
|
const extensions = accept === null || accept === void 0 ? void 0 : accept.map(formatFileTypeToView).join(', ');
|
|
20
|
-
return Object.assign({
|
|
24
|
+
return Object.assign({ RenderImage,
|
|
25
|
+
extensions, imageProps: { src: placeholderImgSrc || uploadFileImgSrc } }, rest);
|
|
21
26
|
};
|
|
@@ -4,10 +4,10 @@ import { IconButton } from '../../../IconButton';
|
|
|
4
4
|
import { Tooltip } from '../../../Tooltip';
|
|
5
5
|
import { Typography } from '../../../Typography';
|
|
6
6
|
import { previewFileUploaderClassnames } from '../../constants';
|
|
7
|
-
import { Actions, Details,
|
|
7
|
+
import { Actions, Details, StyledFileInfo, Wrapper } from './styles';
|
|
8
8
|
import { useLogic } from './useLogic';
|
|
9
9
|
export const FileError = (props) => {
|
|
10
|
-
const { isVisibleRetryButton, imageProps, deleteButtonProps, retryButtonProps, } = useLogic(props);
|
|
10
|
+
const { isVisibleRetryButton, imageProps, deleteButtonProps, retryButtonProps, RenderImage, } = useLogic(props);
|
|
11
11
|
const { fileName, fileSize, errorMsg } = props;
|
|
12
|
-
return (_jsxs(Wrapper, { children: [_jsx(
|
|
12
|
+
return (_jsxs(Wrapper, { children: [_jsx(RenderImage, Object.assign({}, imageProps, { alt: "\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u044B\u0439 \u0444\u0430\u0439\u043B" })), _jsx(Typography, { variant: "caption", color: "error", children: errorMsg }), _jsxs(Details, { className: previewFileUploaderClassnames.details, children: [_jsx(StyledFileInfo, { fileName: fileName, fileSize: fileSize }), _jsxs(Actions, { children: [isVisibleRetryButton && (_jsx(Tooltip, { title: "\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0443", disableInteractive: true, children: _jsx(IconButton, Object.assign({ variant: "light", color: "grey" }, retryButtonProps, { children: _jsx(RetryOutlineMd, {}) })) })), _jsx(Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", disableInteractive: true, children: _jsx(IconButton, Object.assign({ variant: "light", color: "grey" }, deleteButtonProps, { children: _jsx(CrossOutlineMd, {}) })) })] })] })] }));
|
|
13
13
|
};
|
|
@@ -7,6 +7,22 @@ export declare const Image: import("@emotion/styled").StyledComponent<{
|
|
|
7
7
|
theme?: import("@emotion/react").Theme | undefined;
|
|
8
8
|
as?: import("react").ElementType<any> | undefined;
|
|
9
9
|
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
10
|
+
export declare const setDefaultImageStyles: {
|
|
11
|
+
<C extends import("react").ComponentClass<import("react").ComponentProps<C>, any>>(component: C): import("@emotion/styled").StyledComponent<{
|
|
12
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
13
|
+
as?: import("react").ElementType<any> | undefined;
|
|
14
|
+
} & JSX.LibraryManagedAttributes<C, import("react").ComponentProps<C>>, {}, {
|
|
15
|
+
ref?: import("react").Ref<InstanceType<C>> | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
<C_1 extends import("react").ComponentType<import("react").ComponentProps<C_1>>>(component: C_1): import("@emotion/styled").StyledComponent<{
|
|
18
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
19
|
+
as?: import("react").ElementType<any> | undefined;
|
|
20
|
+
} & JSX.LibraryManagedAttributes<C_1, import("react").ComponentProps<C_1>>, {}, {}>;
|
|
21
|
+
<Tag extends keyof JSX.IntrinsicElements>(tag: Tag): import("@emotion/styled").StyledComponent<{
|
|
22
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
23
|
+
as?: import("react").ElementType<any> | undefined;
|
|
24
|
+
}, JSX.IntrinsicElements[Tag], {}>;
|
|
25
|
+
};
|
|
10
26
|
export declare const Details: import("@emotion/styled").StyledComponent<{
|
|
11
27
|
theme?: import("@emotion/react").Theme | undefined;
|
|
12
28
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { type FileErrorProps } from '../FileError';
|
|
2
3
|
export type UseLogicParams = FileErrorProps;
|
|
3
4
|
export declare const useLogic: ({ fileId, file, isUploadError, onDelete, onRetry, }: UseLogicParams) => {
|
|
4
5
|
isVisibleRetryButton: boolean;
|
|
6
|
+
RenderImage: import("@emotion/styled").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any> | undefined;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}> | import("@emotion/styled").StyledComponent<{
|
|
10
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
11
|
+
as?: import("react").ElementType<any> | undefined;
|
|
12
|
+
} & Pick<import("react").AllHTMLAttributes<HTMLImageElement>, "height" | "width" | "className" | "alt" | "src"> & {
|
|
13
|
+
size?: import("../../../..").PlaceholderSize | undefined;
|
|
14
|
+
}, {}, {}>;
|
|
5
15
|
imageProps: {
|
|
6
16
|
src: string | undefined;
|
|
7
17
|
};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
2
|
import { ConfigContext, } from '../../../../ConfigProvider';
|
|
3
|
+
import { Image, setDefaultImageStyles } from '../styles';
|
|
3
4
|
export const useLogic = ({ fileId, file, isUploadError, onDelete, onRetry, }) => {
|
|
4
|
-
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const { imagesMap, components } = useContext(ConfigContext);
|
|
7
|
+
const configRenderImage = (_b = (_a = components === null || components === void 0 ? void 0 : components.placeholder) === null || _a === void 0 ? void 0 : _a.defaultProps) === null || _b === void 0 ? void 0 : _b.renderImage;
|
|
8
|
+
const RenderImage = useMemo(() => configRenderImage ? setDefaultImageStyles(configRenderImage) : Image, [configRenderImage]);
|
|
5
9
|
const { errorFileImgSrc } = imagesMap;
|
|
6
10
|
const isVisibleRetryButton = Boolean(isUploadError && onRetry);
|
|
7
11
|
const handleDelete = () => onDelete(fileId);
|
|
8
12
|
const handleRetry = () => onRetry === null || onRetry === void 0 ? void 0 : onRetry(fileId, file);
|
|
9
13
|
return {
|
|
10
14
|
isVisibleRetryButton,
|
|
15
|
+
RenderImage,
|
|
11
16
|
imageProps: {
|
|
12
17
|
src: errorFileImgSrc,
|
|
13
18
|
},
|
package/node/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/HintPlaceholder.js
CHANGED
|
@@ -7,7 +7,7 @@ const Typography_1 = require("../../../Typography");
|
|
|
7
7
|
const styles_1 = require("./styles");
|
|
8
8
|
const useLogic_1 = require("./useLogic");
|
|
9
9
|
const HintPlaceholder = (props) => {
|
|
10
|
-
const { extensions, imageProps, maxFileSize, placeholder, className } = (0, useLogic_1.useLogic)(props);
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: className, children: [(0, jsx_runtime_1.jsx)(
|
|
10
|
+
const { extensions, imageProps, maxFileSize, placeholder, className, RenderImage, } = (0, useLogic_1.useLogic)(props);
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: className, children: [(0, jsx_runtime_1.jsx)(RenderImage, Object.assign({}, imageProps, { alt: "\u0424\u0430\u0439\u043B\u044B \u0434\u043B\u044F \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438" })), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { component: "p", color: "textSecondary", variant: "caption", align: "center", children: placeholder || ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["\u041F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u043B\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0444\u0430\u0439\u043B. \u0420\u0430\u0437\u043C\u0435\u0440\u043E\u043C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435", ' ', (0, utils_1.formatFileSizeToView)(maxFileSize), extensions && ' в формате ', (0, jsx_runtime_1.jsx)(styles_1.Extensions, { children: extensions })] })) })] }));
|
|
12
12
|
};
|
|
13
13
|
exports.HintPlaceholder = HintPlaceholder;
|
package/node/components/fileUploading/PreviewFileUploaderDropZone/HintPlaceholder/styles.d.ts
CHANGED
|
@@ -7,6 +7,22 @@ export declare const Image: import("@emotion/styled").StyledComponent<{
|
|
|
7
7
|
theme?: import("@emotion/react").Theme | undefined;
|
|
8
8
|
as?: import("react").ElementType<any> | undefined;
|
|
9
9
|
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
10
|
+
export declare const setDefaultImageStyles: {
|
|
11
|
+
<C extends import("react").ComponentClass<import("react").ComponentProps<C>, any>>(component: C): import("@emotion/styled").StyledComponent<{
|
|
12
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
13
|
+
as?: import("react").ElementType<any> | undefined;
|
|
14
|
+
} & JSX.LibraryManagedAttributes<C, import("react").ComponentProps<C>>, {}, {
|
|
15
|
+
ref?: import("react").Ref<InstanceType<C>> | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
<C_1 extends import("react").ComponentType<import("react").ComponentProps<C_1>>>(component: C_1): import("@emotion/styled").StyledComponent<{
|
|
18
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
19
|
+
as?: import("react").ElementType<any> | undefined;
|
|
20
|
+
} & JSX.LibraryManagedAttributes<C_1, import("react").ComponentProps<C_1>>, {}, {}>;
|
|
21
|
+
<Tag extends keyof JSX.IntrinsicElements>(tag: Tag): import("@emotion/styled").StyledComponent<{
|
|
22
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
23
|
+
as?: import("react").ElementType<any> | undefined;
|
|
24
|
+
}, JSX.IntrinsicElements[Tag], {}>;
|
|
25
|
+
};
|
|
10
26
|
export declare const Extensions: import("@emotion/styled").StyledComponent<{
|
|
11
27
|
theme?: import("@emotion/react").Theme | undefined;
|
|
12
28
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Extensions = exports.Image = exports.Wrapper = void 0;
|
|
3
|
+
exports.Extensions = exports.setDefaultImageStyles = exports.Image = exports.Wrapper = void 0;
|
|
4
4
|
const styles_1 = require("../../../styles");
|
|
5
5
|
exports.Wrapper = styles_1.styled.div `
|
|
6
6
|
display: flex;
|
|
@@ -16,6 +16,7 @@ exports.Image = styles_1.styled.img `
|
|
|
16
16
|
|
|
17
17
|
object-fit: contain;
|
|
18
18
|
`;
|
|
19
|
+
exports.setDefaultImageStyles = exports.Image.withComponent;
|
|
19
20
|
exports.Extensions = styles_1.styled.span `
|
|
20
21
|
text-transform: uppercase;
|
|
21
22
|
`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export type UseLogicParams = {
|
|
2
3
|
/**
|
|
3
4
|
* Массив разрешенных расширений
|
|
@@ -27,6 +28,15 @@ export declare const useLogic: ({ accept, placeholderImgSrc, ...rest }: UseLogic
|
|
|
27
28
|
*/
|
|
28
29
|
placeholder?: string | undefined;
|
|
29
30
|
className?: string | undefined;
|
|
31
|
+
RenderImage: import("@emotion/styled").StyledComponent<{
|
|
32
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
33
|
+
as?: import("react").ElementType<any> | undefined;
|
|
34
|
+
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}> | import("@emotion/styled").StyledComponent<{
|
|
35
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
36
|
+
as?: import("react").ElementType<any> | undefined;
|
|
37
|
+
} & Pick<import("react").AllHTMLAttributes<HTMLImageElement>, "height" | "width" | "className" | "alt" | "src"> & {
|
|
38
|
+
size?: import("../../../..").PlaceholderSize | undefined;
|
|
39
|
+
}, {}, {}>;
|
|
30
40
|
extensions: string | undefined;
|
|
31
41
|
imageProps: {
|
|
32
42
|
src: string | undefined;
|
|
@@ -15,11 +15,16 @@ exports.useLogic = void 0;
|
|
|
15
15
|
const utils_1 = require("@astral/utils");
|
|
16
16
|
const react_1 = require("react");
|
|
17
17
|
const ConfigProvider_1 = require("../../../../ConfigProvider");
|
|
18
|
+
const styles_1 = require("../styles");
|
|
18
19
|
const useLogic = (_a) => {
|
|
20
|
+
var _b, _c;
|
|
19
21
|
var { accept, placeholderImgSrc } = _a, rest = __rest(_a, ["accept", "placeholderImgSrc"]);
|
|
20
|
-
const { imagesMap } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
22
|
+
const { imagesMap, components } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
21
23
|
const { uploadFileImgSrc } = imagesMap;
|
|
24
|
+
const configRenderImage = (_c = (_b = components === null || components === void 0 ? void 0 : components.placeholder) === null || _b === void 0 ? void 0 : _b.defaultProps) === null || _c === void 0 ? void 0 : _c.renderImage;
|
|
25
|
+
const RenderImage = (0, react_1.useMemo)(() => configRenderImage ? (0, styles_1.setDefaultImageStyles)(configRenderImage) : styles_1.Image, [configRenderImage]);
|
|
22
26
|
const extensions = accept === null || accept === void 0 ? void 0 : accept.map(utils_1.formatFileTypeToView).join(', ');
|
|
23
|
-
return Object.assign({
|
|
27
|
+
return Object.assign({ RenderImage,
|
|
28
|
+
extensions, imageProps: { src: placeholderImgSrc || uploadFileImgSrc } }, rest);
|
|
24
29
|
};
|
|
25
30
|
exports.useLogic = useLogic;
|
|
@@ -10,8 +10,8 @@ const constants_1 = require("../../constants");
|
|
|
10
10
|
const styles_1 = require("./styles");
|
|
11
11
|
const useLogic_1 = require("./useLogic");
|
|
12
12
|
const FileError = (props) => {
|
|
13
|
-
const { isVisibleRetryButton, imageProps, deleteButtonProps, retryButtonProps, } = (0, useLogic_1.useLogic)(props);
|
|
13
|
+
const { isVisibleRetryButton, imageProps, deleteButtonProps, retryButtonProps, RenderImage, } = (0, useLogic_1.useLogic)(props);
|
|
14
14
|
const { fileName, fileSize, errorMsg } = props;
|
|
15
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [(0, jsx_runtime_1.jsx)(
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [(0, jsx_runtime_1.jsx)(RenderImage, Object.assign({}, imageProps, { alt: "\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u044B\u0439 \u0444\u0430\u0439\u043B" })), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "caption", color: "error", children: errorMsg }), (0, jsx_runtime_1.jsxs)(styles_1.Details, { className: constants_1.previewFileUploaderClassnames.details, children: [(0, jsx_runtime_1.jsx)(styles_1.StyledFileInfo, { fileName: fileName, fileSize: fileSize }), (0, jsx_runtime_1.jsxs)(styles_1.Actions, { 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", disableInteractive: true, children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({ variant: "light", color: "grey" }, retryButtonProps, { children: (0, jsx_runtime_1.jsx)(icons_1.RetryOutlineMd, {}) })) })), (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C", disableInteractive: true, children: (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, Object.assign({ variant: "light", color: "grey" }, deleteButtonProps, { children: (0, jsx_runtime_1.jsx)(icons_1.CrossOutlineMd, {}) })) })] })] })] }));
|
|
16
16
|
};
|
|
17
17
|
exports.FileError = FileError;
|
|
@@ -7,6 +7,22 @@ export declare const Image: import("@emotion/styled").StyledComponent<{
|
|
|
7
7
|
theme?: import("@emotion/react").Theme | undefined;
|
|
8
8
|
as?: import("react").ElementType<any> | undefined;
|
|
9
9
|
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
|
|
10
|
+
export declare const setDefaultImageStyles: {
|
|
11
|
+
<C extends import("react").ComponentClass<import("react").ComponentProps<C>, any>>(component: C): import("@emotion/styled").StyledComponent<{
|
|
12
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
13
|
+
as?: import("react").ElementType<any> | undefined;
|
|
14
|
+
} & JSX.LibraryManagedAttributes<C, import("react").ComponentProps<C>>, {}, {
|
|
15
|
+
ref?: import("react").Ref<InstanceType<C>> | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
<C_1 extends import("react").ComponentType<import("react").ComponentProps<C_1>>>(component: C_1): import("@emotion/styled").StyledComponent<{
|
|
18
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
19
|
+
as?: import("react").ElementType<any> | undefined;
|
|
20
|
+
} & JSX.LibraryManagedAttributes<C_1, import("react").ComponentProps<C_1>>, {}, {}>;
|
|
21
|
+
<Tag extends keyof JSX.IntrinsicElements>(tag: Tag): import("@emotion/styled").StyledComponent<{
|
|
22
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
23
|
+
as?: import("react").ElementType<any> | undefined;
|
|
24
|
+
}, JSX.IntrinsicElements[Tag], {}>;
|
|
25
|
+
};
|
|
10
26
|
export declare const Details: import("@emotion/styled").StyledComponent<{
|
|
11
27
|
theme?: import("@emotion/react").Theme | undefined;
|
|
12
28
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Actions = exports.StyledFileInfo = exports.Details = exports.Image = exports.Wrapper = void 0;
|
|
3
|
+
exports.Actions = exports.StyledFileInfo = exports.Details = exports.setDefaultImageStyles = exports.Image = exports.Wrapper = void 0;
|
|
4
4
|
const styles_1 = require("../../../styles");
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
const FileInfo_1 = require("../../FileInfo");
|
|
@@ -30,6 +30,7 @@ exports.Image = styles_1.styled.img `
|
|
|
30
30
|
|
|
31
31
|
object-fit: contain;
|
|
32
32
|
`;
|
|
33
|
+
exports.setDefaultImageStyles = exports.Image.withComponent;
|
|
33
34
|
exports.Details = styles_1.styled.div `
|
|
34
35
|
position: absolute;
|
|
35
36
|
inset: 0;
|
package/node/components/fileUploading/PreviewFileUploaderFile/FileError/useLogic/useLogic.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { type FileErrorProps } from '../FileError';
|
|
2
3
|
export type UseLogicParams = FileErrorProps;
|
|
3
4
|
export declare const useLogic: ({ fileId, file, isUploadError, onDelete, onRetry, }: UseLogicParams) => {
|
|
4
5
|
isVisibleRetryButton: boolean;
|
|
6
|
+
RenderImage: import("@emotion/styled").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any> | undefined;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}> | import("@emotion/styled").StyledComponent<{
|
|
10
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
11
|
+
as?: import("react").ElementType<any> | undefined;
|
|
12
|
+
} & Pick<import("react").AllHTMLAttributes<HTMLImageElement>, "height" | "width" | "className" | "alt" | "src"> & {
|
|
13
|
+
size?: import("../../../..").PlaceholderSize | undefined;
|
|
14
|
+
}, {}, {}>;
|
|
5
15
|
imageProps: {
|
|
6
16
|
src: string | undefined;
|
|
7
17
|
};
|
package/node/components/fileUploading/PreviewFileUploaderFile/FileError/useLogic/useLogic.js
CHANGED
|
@@ -3,14 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const ConfigProvider_1 = require("../../../../ConfigProvider");
|
|
6
|
+
const styles_1 = require("../styles");
|
|
6
7
|
const useLogic = ({ fileId, file, isUploadError, onDelete, onRetry, }) => {
|
|
7
|
-
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const { imagesMap, components } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
10
|
+
const configRenderImage = (_b = (_a = components === null || components === void 0 ? void 0 : components.placeholder) === null || _a === void 0 ? void 0 : _a.defaultProps) === null || _b === void 0 ? void 0 : _b.renderImage;
|
|
11
|
+
const RenderImage = (0, react_1.useMemo)(() => configRenderImage ? (0, styles_1.setDefaultImageStyles)(configRenderImage) : styles_1.Image, [configRenderImage]);
|
|
8
12
|
const { errorFileImgSrc } = imagesMap;
|
|
9
13
|
const isVisibleRetryButton = Boolean(isUploadError && onRetry);
|
|
10
14
|
const handleDelete = () => onDelete(fileId);
|
|
11
15
|
const handleRetry = () => onRetry === null || onRetry === void 0 ? void 0 : onRetry(fileId, file);
|
|
12
16
|
return {
|
|
13
17
|
isVisibleRetryButton,
|
|
18
|
+
RenderImage,
|
|
14
19
|
imageProps: {
|
|
15
20
|
src: errorFileImgSrc,
|
|
16
21
|
},
|