@alfalab/core-components-file-upload-item 6.2.5 → 6.3.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/Component.js +6 -2
- package/actions-control.module-4114c202.js +6 -0
- package/components/actions-control/actions-control.css +19 -12
- package/components/actions-control/actions.js +7 -2
- package/components/actions-control/components/delete-button/delete-button.js +1 -1
- package/components/actions-control/components/download-button/download-button.js +1 -1
- package/components/actions-control/components/restore-button/restore-button.js +1 -1
- package/components/content/components/content-error/content-error.css +2 -2
- package/components/content/components/content-error/content-error.js +1 -1
- package/components/content/components/content-subtitle/content-subtitle.css +5 -5
- package/components/content/components/content-subtitle/content-subtitle.js +2 -2
- package/components/content/content.css +11 -10
- package/components/content/content.js +3 -2
- package/components/status-control/components/status-control-icon/status-control-icon.css +7 -7
- package/components/status-control/components/status-control-icon/status-control-icon.js +1 -1
- package/components/status-control/status-control.css +14 -13
- package/components/status-control/status-control.js +18 -16
- package/context/file-upload-item-context.d.ts +3 -0
- package/context/file-upload-item-context.js +3 -0
- package/cssm/Component.js +5 -1
- package/cssm/components/actions-control/actions-control.module.css +15 -8
- package/cssm/components/actions-control/actions.js +6 -1
- package/cssm/components/content/components/content-subtitle/content-subtitle.js +1 -1
- package/cssm/components/content/components/content-subtitle/content-subtitle.module.css +1 -1
- package/cssm/components/content/content.js +2 -1
- package/cssm/components/content/content.module.css +5 -4
- package/cssm/components/status-control/components/status-control-icon/status-control-icon.module.css +1 -1
- package/cssm/components/status-control/status-control.js +17 -15
- package/cssm/components/status-control/status-control.module.css +5 -4
- package/cssm/context/file-upload-item-context.d.ts +3 -0
- package/cssm/context/file-upload-item-context.js +3 -0
- package/cssm/index.module.css +1 -1
- package/cssm/types/file-upload-item-props.d.ts +4 -0
- package/esm/Component.js +7 -3
- package/esm/actions-control.module-cc662da0.js +4 -0
- package/esm/components/actions-control/actions-control.css +19 -12
- package/esm/components/actions-control/actions.js +8 -3
- package/esm/components/actions-control/components/delete-button/delete-button.js +1 -1
- package/esm/components/actions-control/components/download-button/download-button.js +1 -1
- package/esm/components/actions-control/components/restore-button/restore-button.js +1 -1
- package/esm/components/content/components/content-error/content-error.css +2 -2
- package/esm/components/content/components/content-error/content-error.js +1 -1
- package/esm/components/content/components/content-subtitle/content-subtitle.css +5 -5
- package/esm/components/content/components/content-subtitle/content-subtitle.js +2 -2
- package/esm/components/content/content.css +11 -10
- package/esm/components/content/content.js +3 -2
- package/esm/components/status-control/components/status-control-icon/status-control-icon.css +7 -7
- package/esm/components/status-control/components/status-control-icon/status-control-icon.js +1 -1
- package/esm/components/status-control/status-control.css +14 -13
- package/esm/components/status-control/status-control.js +18 -16
- package/esm/context/file-upload-item-context.d.ts +3 -0
- package/esm/context/file-upload-item-context.js +3 -0
- package/esm/index.css +4 -4
- package/esm/types/file-upload-item-props.d.ts +4 -0
- package/index.css +4 -4
- package/modern/Component.js +36 -30
- package/modern/actions-control.module-3ddc9e8e.js +4 -0
- package/modern/components/actions-control/actions-control.css +19 -12
- package/modern/components/actions-control/actions.js +8 -3
- package/modern/components/actions-control/components/delete-button/delete-button.js +1 -1
- package/modern/components/actions-control/components/download-button/download-button.js +1 -1
- package/modern/components/actions-control/components/restore-button/restore-button.js +1 -1
- package/modern/components/content/components/content-error/content-error.css +2 -2
- package/modern/components/content/components/content-error/content-error.js +1 -1
- package/modern/components/content/components/content-subtitle/content-subtitle.css +5 -5
- package/modern/components/content/components/content-subtitle/content-subtitle.js +2 -2
- package/modern/components/content/content.css +11 -10
- package/modern/components/content/content.js +3 -2
- package/modern/components/status-control/components/status-control-icon/status-control-icon.css +7 -7
- package/modern/components/status-control/components/status-control-icon/status-control-icon.js +1 -1
- package/modern/components/status-control/status-control.css +14 -13
- package/modern/components/status-control/status-control.js +6 -4
- package/modern/context/file-upload-item-context.d.ts +3 -0
- package/modern/context/file-upload-item-context.js +3 -0
- package/modern/index.css +4 -4
- package/modern/types/file-upload-item-props.d.ts +4 -0
- package/moderncssm/Component.js +35 -29
- package/moderncssm/components/actions-control/actions-control.module.css +15 -3
- package/moderncssm/components/actions-control/actions.js +7 -2
- package/moderncssm/components/content/components/content-subtitle/content-subtitle.js +1 -1
- package/moderncssm/components/content/content.js +2 -1
- package/moderncssm/components/content/content.module.css +5 -2
- package/moderncssm/components/status-control/status-control.js +5 -3
- package/moderncssm/components/status-control/status-control.module.css +5 -2
- package/moderncssm/context/file-upload-item-context.d.ts +3 -0
- package/moderncssm/context/file-upload-item-context.js +3 -0
- package/moderncssm/types/file-upload-item-props.d.ts +4 -0
- package/package.json +5 -6
- package/src/Component.tsx +48 -40
- package/src/components/actions-control/actions-control.module.css +12 -0
- package/src/components/actions-control/actions.tsx +9 -2
- package/src/components/content/components/content-subtitle/content-subtitle.tsx +1 -1
- package/src/components/content/content.module.css +4 -1
- package/src/components/content/content.tsx +3 -0
- package/src/components/status-control/status-control.module.css +4 -1
- package/src/components/status-control/status-control.tsx +13 -3
- package/src/context/file-upload-item-context.tsx +6 -0
- package/src/types/file-upload-item-props.ts +5 -0
- package/types/file-upload-item-props.d.ts +4 -0
- package/actions-control.module-d60492fb.js +0 -6
- package/esm/actions-control.module-e1988df9.js +0 -4
- package/modern/actions-control.module-05603b9e.js +0 -4
package/src/Component.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
import { Actions } from './components/actions-control';
|
|
@@ -27,6 +27,7 @@ export const FileUploadItemComponent: React.FC<FileUploadItemProps> = ({
|
|
|
27
27
|
onDownload,
|
|
28
28
|
onRestore,
|
|
29
29
|
disableButtons,
|
|
30
|
+
isClickable = true,
|
|
30
31
|
target,
|
|
31
32
|
dataTestId,
|
|
32
33
|
customIcon,
|
|
@@ -35,46 +36,53 @@ export const FileUploadItemComponent: React.FC<FileUploadItemProps> = ({
|
|
|
35
36
|
customContent,
|
|
36
37
|
truncate,
|
|
37
38
|
imageUrl,
|
|
38
|
-
}) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value={{
|
|
50
|
-
showRestore,
|
|
51
|
-
uploadStatus,
|
|
52
|
-
error,
|
|
53
|
-
title,
|
|
54
|
-
subtitle,
|
|
55
|
-
uploadDate,
|
|
56
|
-
size,
|
|
57
|
-
id,
|
|
58
|
-
onDownload,
|
|
59
|
-
onDelete,
|
|
60
|
-
onRestore,
|
|
61
|
-
downloadLink,
|
|
62
|
-
download,
|
|
63
|
-
disableButtons,
|
|
64
|
-
target,
|
|
65
|
-
showDelete,
|
|
66
|
-
customIcon,
|
|
67
|
-
iconStyle,
|
|
68
|
-
progressBar,
|
|
69
|
-
customContent,
|
|
70
|
-
truncate,
|
|
71
|
-
imageUrl,
|
|
72
|
-
}}
|
|
39
|
+
}) => {
|
|
40
|
+
const [actionsPresent, setActionsPresent] = useState(false);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
className={cn(
|
|
45
|
+
className,
|
|
46
|
+
styles.component,
|
|
47
|
+
uploadStatus && styles[uploadStatus.toLocaleLowerCase()],
|
|
48
|
+
)}
|
|
49
|
+
data-test-id={dataTestId}
|
|
73
50
|
>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
51
|
+
<FileUploadItemContext.Provider
|
|
52
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
53
|
+
value={{
|
|
54
|
+
showRestore,
|
|
55
|
+
uploadStatus,
|
|
56
|
+
error,
|
|
57
|
+
title,
|
|
58
|
+
subtitle,
|
|
59
|
+
uploadDate,
|
|
60
|
+
size,
|
|
61
|
+
id,
|
|
62
|
+
onDownload,
|
|
63
|
+
onDelete,
|
|
64
|
+
onRestore,
|
|
65
|
+
downloadLink,
|
|
66
|
+
download,
|
|
67
|
+
disableButtons,
|
|
68
|
+
isClickable,
|
|
69
|
+
target,
|
|
70
|
+
showDelete,
|
|
71
|
+
customIcon,
|
|
72
|
+
iconStyle,
|
|
73
|
+
progressBar,
|
|
74
|
+
customContent,
|
|
75
|
+
truncate,
|
|
76
|
+
imageUrl,
|
|
77
|
+
actionsPresent,
|
|
78
|
+
setActionsPresent,
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{children}
|
|
82
|
+
</FileUploadItemContext.Provider>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
78
86
|
|
|
79
87
|
export const FileUploadItem = Object.assign(FileUploadItemComponent, {
|
|
80
88
|
StatusControl,
|
|
@@ -12,12 +12,24 @@
|
|
|
12
12
|
|
|
13
13
|
.deleteIconColor {
|
|
14
14
|
fill: var(--color-light-text-tertiary);
|
|
15
|
+
|
|
16
|
+
&:hover {
|
|
17
|
+
fill: var(--color-light-text-tertiary-hover);
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
.downloadIconColor {
|
|
18
22
|
fill: var(--color-light-text-tertiary);
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
fill: var(--color-light-text-tertiary-hover);
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
.restoreIconColor {
|
|
22
30
|
fill: var(--color-light-text-tertiary);
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
fill: var(--color-light-text-tertiary-hover);
|
|
34
|
+
}
|
|
23
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import { FileUploadItemContext } from '../../context/file-upload-item-context';
|
|
4
4
|
|
|
@@ -9,7 +9,14 @@ import { RestoreButton } from './components/restore-button';
|
|
|
9
9
|
import styles from './actions-control.module.css';
|
|
10
10
|
|
|
11
11
|
export const Actions = () => {
|
|
12
|
-
const { showRestore, downloadLink, showDelete } =
|
|
12
|
+
const { showRestore, downloadLink, showDelete, setActionsPresent } =
|
|
13
|
+
useContext(FileUploadItemContext);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (setActionsPresent) {
|
|
17
|
+
setActionsPresent(!!(showRestore || downloadLink || showDelete));
|
|
18
|
+
}
|
|
19
|
+
}, [showRestore, downloadLink, showDelete, setActionsPresent]);
|
|
13
20
|
|
|
14
21
|
return (
|
|
15
22
|
<div className={styles.container}>
|
|
@@ -16,6 +16,8 @@ export const Content = () => {
|
|
|
16
16
|
truncate,
|
|
17
17
|
subtitle,
|
|
18
18
|
showRestore,
|
|
19
|
+
actionsPresent,
|
|
20
|
+
isClickable,
|
|
19
21
|
} = useContext(FileUploadItemContext);
|
|
20
22
|
|
|
21
23
|
if (CustomContent) {
|
|
@@ -26,6 +28,7 @@ export const Content = () => {
|
|
|
26
28
|
<div
|
|
27
29
|
className={cn(styles.container, {
|
|
28
30
|
[styles.single]: !subtitle,
|
|
31
|
+
[styles.clickable]: !actionsPresent && isClickable,
|
|
29
32
|
})}
|
|
30
33
|
>
|
|
31
34
|
{title && (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useRef } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
-
import { SuperEllipse } from '@alfalab/core-components
|
|
4
|
+
import { SuperEllipse } from '@alfalab/core-components-icon-view/super-ellipse';
|
|
5
5
|
|
|
6
6
|
import { MAX_PROGRESS_BAR_VALUE, RADIUS } from '../../const/progress-bar';
|
|
7
7
|
import { FileUploadItemContext } from '../../context/file-upload-item-context';
|
|
@@ -13,7 +13,13 @@ import { StatusControlProgressBar } from './components/status-control-progress-b
|
|
|
13
13
|
import styles from './status-control.module.css';
|
|
14
14
|
|
|
15
15
|
export const StatusControl = () => {
|
|
16
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
uploadStatus = 'INITIAL',
|
|
18
|
+
progressBar,
|
|
19
|
+
imageUrl,
|
|
20
|
+
actionsPresent,
|
|
21
|
+
isClickable,
|
|
22
|
+
} = useContext(FileUploadItemContext);
|
|
17
23
|
const progressRef = useRef<HTMLDivElement>(null);
|
|
18
24
|
|
|
19
25
|
if (progressRef.current && progressBar) {
|
|
@@ -26,7 +32,11 @@ export const StatusControl = () => {
|
|
|
26
32
|
uploadStatus === 'INITIAL' || uploadStatus === 'UPLOADED' || uploadStatus === 'DELETED';
|
|
27
33
|
|
|
28
34
|
return (
|
|
29
|
-
<div
|
|
35
|
+
<div
|
|
36
|
+
className={cn(styles.container, {
|
|
37
|
+
[styles.clickable]: !actionsPresent && isClickable,
|
|
38
|
+
})}
|
|
39
|
+
>
|
|
30
40
|
<SuperEllipse size={48} {...(imageUrl && { imageUrl })}>
|
|
31
41
|
<StatusControlIcon />
|
|
32
42
|
</SuperEllipse>
|
|
@@ -17,6 +17,7 @@ type TFileUploadItemContext = {
|
|
|
17
17
|
downloadLink?: string;
|
|
18
18
|
download?: string | true;
|
|
19
19
|
disableButtons?: boolean;
|
|
20
|
+
isClickable?: boolean;
|
|
20
21
|
target?: HTMLAttributeAnchorTarget;
|
|
21
22
|
showDelete?: boolean;
|
|
22
23
|
customIcon?: ElementType<{ className?: string }>;
|
|
@@ -25,6 +26,8 @@ type TFileUploadItemContext = {
|
|
|
25
26
|
customContent?: ElementType;
|
|
26
27
|
truncate?: boolean;
|
|
27
28
|
imageUrl?: string;
|
|
29
|
+
actionsPresent?: boolean;
|
|
30
|
+
setActionsPresent?: (present: boolean) => void;
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
export const FileUploadItemContext = createContext<TFileUploadItemContext>({
|
|
@@ -42,6 +45,7 @@ export const FileUploadItemContext = createContext<TFileUploadItemContext>({
|
|
|
42
45
|
downloadLink: '',
|
|
43
46
|
download: '',
|
|
44
47
|
disableButtons: false,
|
|
48
|
+
isClickable: true,
|
|
45
49
|
target: undefined,
|
|
46
50
|
showDelete: false,
|
|
47
51
|
iconStyle: 'gray',
|
|
@@ -50,4 +54,6 @@ export const FileUploadItemContext = createContext<TFileUploadItemContext>({
|
|
|
50
54
|
customContent: undefined,
|
|
51
55
|
truncate: false,
|
|
52
56
|
imageUrl: undefined,
|
|
57
|
+
actionsPresent: false,
|
|
58
|
+
setActionsPresent: undefined,
|
|
53
59
|
});
|
|
@@ -72,6 +72,10 @@ type FileUploadItemProps = {
|
|
|
72
72
|
* Управление активностью кнопок
|
|
73
73
|
*/
|
|
74
74
|
disableButtons?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Управление отображением кликабельности элемента Content
|
|
77
|
+
*/
|
|
78
|
+
isClickable?: boolean;
|
|
75
79
|
/**
|
|
76
80
|
* Указывает, где открыть скачиваемый документ
|
|
77
81
|
*/
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var styles = {"container":"file-upload-item__container_13oj7","icon":"file-upload-item__icon_13oj7","deleteIconColor":"file-upload-item__deleteIconColor_13oj7","downloadIconColor":"file-upload-item__downloadIconColor_13oj7","restoreIconColor":"file-upload-item__restoreIconColor_13oj7"};
|
|
4
|
-
require('./components/actions-control/actions-control.css')
|
|
5
|
-
|
|
6
|
-
exports.styles = styles;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var styles = {"container":"file-upload-item__container_13oj7","icon":"file-upload-item__icon_13oj7","deleteIconColor":"file-upload-item__deleteIconColor_13oj7","downloadIconColor":"file-upload-item__downloadIconColor_13oj7","restoreIconColor":"file-upload-item__restoreIconColor_13oj7"};
|
|
2
|
-
require('./components/actions-control/actions-control.css')
|
|
3
|
-
|
|
4
|
-
export { styles as s };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const styles = {"container":"file-upload-item__container_13oj7","icon":"file-upload-item__icon_13oj7","deleteIconColor":"file-upload-item__deleteIconColor_13oj7","downloadIconColor":"file-upload-item__downloadIconColor_13oj7","restoreIconColor":"file-upload-item__restoreIconColor_13oj7"};
|
|
2
|
-
require('./components/actions-control/actions-control.css')
|
|
3
|
-
|
|
4
|
-
export { styles as s };
|