@alfalab/core-components-file-upload-item 5.11.0 → 6.0.1
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.d.ts +7 -92
- package/Component.js +41 -65
- package/actions-control.module-2b1ea7b3.js +6 -0
- package/components/actions-control/actions-control.css +34 -0
- package/components/actions-control/actions.d.ts +4 -0
- package/components/actions-control/actions.js +24 -0
- package/components/actions-control/components/delete-button/delete-button.d.ts +4 -0
- package/components/actions-control/components/delete-button/delete-button.js +26 -0
- package/components/actions-control/components/delete-button/index.d.ts +1 -0
- package/components/actions-control/components/delete-button/index.js +9 -0
- package/components/actions-control/components/download-button/download-button.d.ts +4 -0
- package/components/actions-control/components/download-button/download-button.js +27 -0
- package/components/actions-control/components/download-button/index.d.ts +1 -0
- package/components/actions-control/components/download-button/index.js +9 -0
- package/components/actions-control/components/restore-button/index.d.ts +1 -0
- package/components/actions-control/components/restore-button/index.js +9 -0
- package/components/actions-control/components/restore-button/restore-button.d.ts +4 -0
- package/components/actions-control/components/restore-button/restore-button.js +26 -0
- package/components/actions-control/index.d.ts +1 -0
- package/components/actions-control/index.js +9 -0
- package/components/content/components/content-error/content-error.css +4 -0
- package/components/content/components/content-error/content-error.d.ts +4 -0
- package/components/content/components/content-error/content-error.js +27 -0
- package/components/content/components/content-error/index.d.ts +1 -0
- package/components/content/components/content-error/index.js +9 -0
- package/components/content/components/content-subtitle/content-subtitle.css +31 -0
- package/components/content/components/content-subtitle/content-subtitle.d.ts +4 -0
- package/components/content/components/content-subtitle/content-subtitle.js +62 -0
- package/components/content/content.css +50 -0
- package/components/content/content.d.ts +4 -0
- package/components/content/content.js +35 -0
- package/components/content/index.d.ts +1 -0
- package/components/content/index.js +9 -0
- package/components/content/utils/isError.d.ts +2 -0
- package/components/content/utils/isError.js +15 -0
- package/components/status-control/components/status-control-icon/index.d.ts +1 -0
- package/components/status-control/components/status-control-icon/index.js +9 -0
- package/components/status-control/components/status-control-icon/status-control-icon.css +37 -0
- package/components/status-control/components/status-control-icon/status-control-icon.d.ts +4 -0
- package/components/status-control/components/status-control-icon/status-control-icon.js +70 -0
- package/components/status-control/components/status-control-progress-bar/index.d.ts +1 -0
- package/components/status-control/components/status-control-progress-bar/index.js +9 -0
- package/components/status-control/components/status-control-progress-bar/status-control-progress-bar.d.ts +6 -0
- package/components/status-control/components/status-control-progress-bar/status-control-progress-bar.js +22 -0
- package/components/status-control/index.d.ts +1 -0
- package/components/status-control/index.js +9 -0
- package/components/status-control/status-control.css +57 -0
- package/components/status-control/status-control.d.ts +4 -0
- package/components/status-control/status-control.js +49 -0
- package/const/progress-bar.d.ts +3 -0
- package/const/progress-bar.js +9 -0
- package/context/file-upload-item-context.d.ts +30 -0
- package/context/file-upload-item-context.js +32 -0
- package/cssm/Component.d.ts +7 -92
- package/cssm/Component.js +40 -64
- package/cssm/components/actions-control/actions-control.module.css +33 -0
- package/cssm/components/actions-control/actions.d.ts +4 -0
- package/cssm/components/actions-control/actions.js +25 -0
- package/cssm/components/actions-control/components/delete-button/delete-button.d.ts +4 -0
- package/cssm/components/actions-control/components/delete-button/delete-button.js +27 -0
- package/cssm/components/actions-control/components/delete-button/index.d.ts +1 -0
- package/cssm/components/actions-control/components/delete-button/index.js +9 -0
- package/cssm/components/actions-control/components/download-button/download-button.d.ts +4 -0
- package/cssm/components/actions-control/components/download-button/download-button.js +28 -0
- package/cssm/components/actions-control/components/download-button/index.d.ts +1 -0
- package/cssm/components/actions-control/components/download-button/index.js +9 -0
- package/cssm/components/actions-control/components/restore-button/index.d.ts +1 -0
- package/cssm/components/actions-control/components/restore-button/index.js +9 -0
- package/cssm/components/actions-control/components/restore-button/restore-button.d.ts +4 -0
- package/cssm/components/actions-control/components/restore-button/restore-button.js +27 -0
- package/cssm/components/actions-control/index.d.ts +1 -0
- package/cssm/components/actions-control/index.js +9 -0
- package/cssm/components/content/components/content-error/content-error.d.ts +4 -0
- package/cssm/components/content/components/content-error/content-error.js +26 -0
- package/cssm/components/content/components/content-error/content-error.module.css +3 -0
- package/cssm/components/content/components/content-error/index.d.ts +1 -0
- package/cssm/components/content/components/content-error/index.js +9 -0
- package/cssm/components/content/components/content-subtitle/content-subtitle.d.ts +4 -0
- package/cssm/components/content/components/content-subtitle/content-subtitle.js +61 -0
- package/cssm/components/content/components/content-subtitle/content-subtitle.module.css +30 -0
- package/cssm/components/content/content.d.ts +4 -0
- package/cssm/components/content/content.js +34 -0
- package/cssm/components/content/content.module.css +49 -0
- package/cssm/components/content/index.d.ts +1 -0
- package/cssm/components/content/index.js +9 -0
- package/cssm/components/content/utils/isError.d.ts +2 -0
- package/cssm/components/content/utils/isError.js +15 -0
- package/cssm/components/status-control/components/status-control-icon/index.d.ts +1 -0
- package/cssm/components/status-control/components/status-control-icon/index.js +9 -0
- package/cssm/components/status-control/components/status-control-icon/status-control-icon.d.ts +4 -0
- package/cssm/components/status-control/components/status-control-icon/status-control-icon.js +69 -0
- package/cssm/components/status-control/components/status-control-icon/status-control-icon.module.css +36 -0
- package/cssm/components/status-control/components/status-control-progress-bar/index.d.ts +1 -0
- package/cssm/components/status-control/components/status-control-progress-bar/index.js +9 -0
- package/cssm/components/status-control/components/status-control-progress-bar/status-control-progress-bar.d.ts +6 -0
- package/cssm/components/status-control/components/status-control-progress-bar/status-control-progress-bar.js +22 -0
- package/cssm/components/status-control/index.d.ts +1 -0
- package/cssm/components/status-control/index.js +9 -0
- package/cssm/components/status-control/status-control.d.ts +4 -0
- package/cssm/components/status-control/status-control.js +48 -0
- package/cssm/components/status-control/status-control.module.css +56 -0
- package/cssm/const/progress-bar.d.ts +3 -0
- package/cssm/const/progress-bar.js +9 -0
- package/cssm/context/file-upload-item-context.d.ts +30 -0
- package/cssm/context/file-upload-item-context.js +32 -0
- package/cssm/index.js +1 -0
- package/cssm/index.module.css +5 -96
- package/cssm/types/file-upload-item-props.d.ts +113 -0
- package/cssm/types/file-upload-item-props.js +2 -0
- package/cssm/utils.d.ts +6 -3
- package/cssm/utils.js +10 -28
- package/esm/Component.d.ts +7 -92
- package/esm/Component.js +41 -66
- package/esm/actions-control.module-8a4353b3.js +4 -0
- package/esm/components/actions-control/actions-control.css +34 -0
- package/esm/components/actions-control/actions.d.ts +4 -0
- package/esm/components/actions-control/actions.js +16 -0
- package/esm/components/actions-control/components/delete-button/delete-button.d.ts +4 -0
- package/esm/components/actions-control/components/delete-button/delete-button.js +17 -0
- package/esm/components/actions-control/components/delete-button/index.d.ts +1 -0
- package/esm/components/actions-control/components/delete-button/index.js +1 -0
- package/esm/components/actions-control/components/download-button/download-button.d.ts +4 -0
- package/esm/components/actions-control/components/download-button/download-button.js +18 -0
- package/esm/components/actions-control/components/download-button/index.d.ts +1 -0
- package/esm/components/actions-control/components/download-button/index.js +1 -0
- package/esm/components/actions-control/components/restore-button/index.d.ts +1 -0
- package/esm/components/actions-control/components/restore-button/index.js +1 -0
- package/esm/components/actions-control/components/restore-button/restore-button.d.ts +4 -0
- package/esm/components/actions-control/components/restore-button/restore-button.js +17 -0
- package/esm/components/actions-control/index.d.ts +1 -0
- package/esm/components/actions-control/index.js +1 -0
- package/esm/components/content/components/content-error/content-error.css +4 -0
- package/esm/components/content/components/content-error/content-error.d.ts +4 -0
- package/esm/components/content/components/content-error/content-error.js +19 -0
- package/esm/components/content/components/content-error/index.d.ts +1 -0
- package/esm/components/content/components/content-error/index.js +1 -0
- package/esm/components/content/components/content-subtitle/content-subtitle.css +31 -0
- package/esm/components/content/components/content-subtitle/content-subtitle.d.ts +4 -0
- package/esm/components/content/components/content-subtitle/content-subtitle.js +53 -0
- package/esm/components/content/content.css +50 -0
- package/esm/components/content/content.d.ts +4 -0
- package/esm/components/content/content.js +26 -0
- package/esm/components/content/index.d.ts +1 -0
- package/esm/components/content/index.js +1 -0
- package/esm/components/content/utils/isError.d.ts +2 -0
- package/esm/components/content/utils/isError.js +11 -0
- package/esm/components/status-control/components/status-control-icon/index.d.ts +1 -0
- package/esm/components/status-control/components/status-control-icon/index.js +1 -0
- package/esm/components/status-control/components/status-control-icon/status-control-icon.css +37 -0
- package/esm/components/status-control/components/status-control-icon/status-control-icon.d.ts +4 -0
- package/esm/components/status-control/components/status-control-icon/status-control-icon.js +60 -0
- package/esm/components/status-control/components/status-control-progress-bar/index.d.ts +1 -0
- package/esm/components/status-control/components/status-control-progress-bar/index.js +1 -0
- package/esm/components/status-control/components/status-control-progress-bar/status-control-progress-bar.d.ts +6 -0
- package/esm/components/status-control/components/status-control-progress-bar/status-control-progress-bar.js +14 -0
- package/esm/components/status-control/index.d.ts +1 -0
- package/esm/components/status-control/index.js +1 -0
- package/esm/components/status-control/status-control.css +57 -0
- package/esm/components/status-control/status-control.d.ts +4 -0
- package/esm/components/status-control/status-control.js +40 -0
- package/esm/const/progress-bar.d.ts +3 -0
- package/esm/const/progress-bar.js +4 -0
- package/esm/context/file-upload-item-context.d.ts +30 -0
- package/esm/context/file-upload-item-context.js +28 -0
- package/esm/index.css +8 -99
- package/esm/index.js +1 -1
- package/esm/types/file-upload-item-props.d.ts +113 -0
- package/esm/types/file-upload-item-props.js +1 -0
- package/esm/utils.d.ts +6 -3
- package/esm/utils.js +6 -28
- package/index.css +8 -99
- package/index.js +1 -0
- package/modern/Component.d.ts +7 -92
- package/modern/Component.js +40 -66
- package/modern/actions-control.module-594eefc0.js +4 -0
- package/modern/components/actions-control/actions-control.css +34 -0
- package/modern/components/actions-control/actions.d.ts +4 -0
- package/modern/components/actions-control/actions.js +16 -0
- package/modern/components/actions-control/components/delete-button/delete-button.d.ts +4 -0
- package/modern/components/actions-control/components/delete-button/delete-button.js +17 -0
- package/modern/components/actions-control/components/delete-button/index.d.ts +1 -0
- package/modern/components/actions-control/components/delete-button/index.js +1 -0
- package/modern/components/actions-control/components/download-button/download-button.d.ts +4 -0
- package/modern/components/actions-control/components/download-button/download-button.js +18 -0
- package/modern/components/actions-control/components/download-button/index.d.ts +1 -0
- package/modern/components/actions-control/components/download-button/index.js +1 -0
- package/modern/components/actions-control/components/restore-button/index.d.ts +1 -0
- package/modern/components/actions-control/components/restore-button/index.js +1 -0
- package/modern/components/actions-control/components/restore-button/restore-button.d.ts +4 -0
- package/modern/components/actions-control/components/restore-button/restore-button.js +17 -0
- package/modern/components/actions-control/index.d.ts +1 -0
- package/modern/components/actions-control/index.js +1 -0
- package/modern/components/content/components/content-error/content-error.css +4 -0
- package/modern/components/content/components/content-error/content-error.d.ts +4 -0
- package/modern/components/content/components/content-error/content-error.js +19 -0
- package/modern/components/content/components/content-error/index.d.ts +1 -0
- package/modern/components/content/components/content-error/index.js +1 -0
- package/modern/components/content/components/content-subtitle/content-subtitle.css +31 -0
- package/modern/components/content/components/content-subtitle/content-subtitle.d.ts +4 -0
- package/modern/components/content/components/content-subtitle/content-subtitle.js +52 -0
- package/modern/components/content/content.css +50 -0
- package/modern/components/content/content.d.ts +4 -0
- package/modern/components/content/content.js +25 -0
- package/modern/components/content/index.d.ts +1 -0
- package/modern/components/content/index.js +1 -0
- package/modern/components/content/utils/isError.d.ts +2 -0
- package/modern/components/content/utils/isError.js +11 -0
- package/modern/components/status-control/components/status-control-icon/index.d.ts +1 -0
- package/modern/components/status-control/components/status-control-icon/index.js +1 -0
- package/modern/components/status-control/components/status-control-icon/status-control-icon.css +37 -0
- package/modern/components/status-control/components/status-control-icon/status-control-icon.d.ts +4 -0
- package/modern/components/status-control/components/status-control-icon/status-control-icon.js +59 -0
- package/modern/components/status-control/components/status-control-progress-bar/index.d.ts +1 -0
- package/modern/components/status-control/components/status-control-progress-bar/index.js +1 -0
- package/modern/components/status-control/components/status-control-progress-bar/status-control-progress-bar.d.ts +6 -0
- package/modern/components/status-control/components/status-control-progress-bar/status-control-progress-bar.js +11 -0
- package/modern/components/status-control/index.d.ts +1 -0
- package/modern/components/status-control/index.js +1 -0
- package/modern/components/status-control/status-control.css +57 -0
- package/modern/components/status-control/status-control.d.ts +4 -0
- package/modern/components/status-control/status-control.js +36 -0
- package/modern/const/progress-bar.d.ts +3 -0
- package/modern/const/progress-bar.js +4 -0
- package/modern/context/file-upload-item-context.d.ts +30 -0
- package/modern/context/file-upload-item-context.js +28 -0
- package/modern/index.css +8 -99
- package/modern/index.js +1 -1
- package/modern/types/file-upload-item-props.d.ts +113 -0
- package/modern/types/file-upload-item-props.js +1 -0
- package/modern/utils.d.ts +6 -3
- package/modern/utils.js +6 -28
- package/moderncssm/Component.d.ts +7 -92
- package/moderncssm/Component.js +39 -65
- package/moderncssm/components/actions-control/actions-control.module.css +23 -0
- package/moderncssm/components/actions-control/actions.d.ts +4 -0
- package/moderncssm/components/actions-control/actions.js +16 -0
- package/moderncssm/components/actions-control/components/delete-button/delete-button.d.ts +4 -0
- package/moderncssm/components/actions-control/components/delete-button/delete-button.js +17 -0
- package/moderncssm/components/actions-control/components/delete-button/index.d.ts +1 -0
- package/moderncssm/components/actions-control/components/delete-button/index.js +1 -0
- package/moderncssm/components/actions-control/components/download-button/download-button.d.ts +4 -0
- package/moderncssm/components/actions-control/components/download-button/download-button.js +18 -0
- package/moderncssm/components/actions-control/components/download-button/index.d.ts +1 -0
- package/moderncssm/components/actions-control/components/download-button/index.js +1 -0
- package/moderncssm/components/actions-control/components/restore-button/index.d.ts +1 -0
- package/moderncssm/components/actions-control/components/restore-button/index.js +1 -0
- package/moderncssm/components/actions-control/components/restore-button/restore-button.d.ts +4 -0
- package/moderncssm/components/actions-control/components/restore-button/restore-button.js +17 -0
- package/moderncssm/components/actions-control/index.d.ts +1 -0
- package/moderncssm/components/actions-control/index.js +1 -0
- package/moderncssm/components/content/components/content-error/content-error.d.ts +4 -0
- package/moderncssm/components/content/components/content-error/content-error.js +17 -0
- package/moderncssm/components/content/components/content-error/content-error.module.css +3 -0
- package/moderncssm/components/content/components/content-error/index.d.ts +1 -0
- package/moderncssm/components/content/components/content-error/index.js +1 -0
- package/moderncssm/components/content/components/content-subtitle/content-subtitle.d.ts +4 -0
- package/moderncssm/components/content/components/content-subtitle/content-subtitle.js +50 -0
- package/moderncssm/components/content/components/content-subtitle/content-subtitle.module.css +15 -0
- package/moderncssm/components/content/content.d.ts +4 -0
- package/moderncssm/components/content/content.js +23 -0
- package/moderncssm/components/content/content.module.css +37 -0
- package/moderncssm/components/content/index.d.ts +1 -0
- package/moderncssm/components/content/index.js +1 -0
- package/moderncssm/components/content/utils/isError.d.ts +2 -0
- package/moderncssm/components/content/utils/isError.js +11 -0
- package/moderncssm/components/status-control/components/status-control-icon/index.d.ts +1 -0
- package/moderncssm/components/status-control/components/status-control-icon/index.js +1 -0
- package/moderncssm/components/status-control/components/status-control-icon/status-control-icon.d.ts +4 -0
- package/moderncssm/components/status-control/components/status-control-icon/status-control-icon.js +57 -0
- package/moderncssm/components/status-control/components/status-control-icon/status-control-icon.module.css +22 -0
- package/moderncssm/components/status-control/components/status-control-progress-bar/index.d.ts +1 -0
- package/moderncssm/components/status-control/components/status-control-progress-bar/index.js +1 -0
- package/moderncssm/components/status-control/components/status-control-progress-bar/status-control-progress-bar.d.ts +6 -0
- package/moderncssm/components/status-control/components/status-control-progress-bar/status-control-progress-bar.js +11 -0
- package/moderncssm/components/status-control/index.d.ts +1 -0
- package/moderncssm/components/status-control/index.js +1 -0
- package/moderncssm/components/status-control/status-control.d.ts +4 -0
- package/moderncssm/components/status-control/status-control.js +34 -0
- package/moderncssm/components/status-control/status-control.module.css +48 -0
- package/moderncssm/const/progress-bar.d.ts +3 -0
- package/moderncssm/const/progress-bar.js +4 -0
- package/moderncssm/context/file-upload-item-context.d.ts +30 -0
- package/moderncssm/context/file-upload-item-context.js +28 -0
- package/moderncssm/index.js +1 -1
- package/moderncssm/index.module.css +2 -117
- package/moderncssm/types/file-upload-item-props.d.ts +113 -0
- package/moderncssm/types/file-upload-item-props.js +1 -0
- package/moderncssm/utils.d.ts +6 -3
- package/moderncssm/utils.js +6 -28
- package/package.json +5 -4
- package/src/Component.tsx +60 -251
- package/src/components/actions-control/actions-control.module.css +23 -0
- package/src/components/actions-control/actions.tsx +23 -0
- package/src/components/actions-control/components/delete-button/delete-button.tsx +29 -0
- package/src/components/actions-control/components/delete-button/index.ts +1 -0
- package/src/components/actions-control/components/download-button/download-button.tsx +40 -0
- package/src/components/actions-control/components/download-button/index.ts +1 -0
- package/src/components/actions-control/components/restore-button/index.ts +1 -0
- package/src/components/actions-control/components/restore-button/restore-button.tsx +29 -0
- package/src/components/actions-control/index.ts +1 -0
- package/src/components/content/components/content-error/content-error.module.css +3 -0
- package/src/components/content/components/content-error/content-error.tsx +42 -0
- package/src/components/content/components/content-error/index.ts +1 -0
- package/src/components/content/components/content-subtitle/content-subtitle.module.css +15 -0
- package/src/components/content/components/content-subtitle/content-subtitle.tsx +92 -0
- package/src/components/content/content.module.css +37 -0
- package/src/components/content/content.tsx +46 -0
- package/src/components/content/index.ts +1 -0
- package/src/components/content/utils/isError.ts +11 -0
- package/src/components/status-control/components/status-control-icon/index.ts +1 -0
- package/src/components/status-control/components/status-control-icon/status-control-icon.module.css +22 -0
- package/src/components/status-control/components/status-control-icon/status-control-icon.tsx +75 -0
- package/src/components/status-control/components/status-control-progress-bar/index.ts +1 -0
- package/src/components/status-control/components/status-control-progress-bar/status-control-progress-bar.tsx +37 -0
- package/src/components/status-control/index.ts +1 -0
- package/src/components/status-control/status-control.module.css +45 -0
- package/src/components/status-control/status-control.tsx +52 -0
- package/src/const/progress-bar.ts +2 -0
- package/src/context/file-upload-item-context.tsx +51 -0
- package/src/index.module.css +2 -113
- package/src/types/file-upload-item-props.ts +133 -0
- package/src/utils.ts +5 -28
- package/types/file-upload-item-props.d.ts +113 -0
- package/types/file-upload-item-props.js +2 -0
- package/utils.d.ts +6 -3
- package/utils.js +10 -28
package/src/Component.tsx
CHANGED
|
@@ -1,141 +1,25 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ClockMIcon } from '@alfalab/icons-glyph/ClockMIcon';
|
|
10
|
-
import { CrossSIcon } from '@alfalab/icons-glyph/CrossSIcon';
|
|
11
|
-
import { PointerDownSIcon } from '@alfalab/icons-glyph/PointerDownSIcon';
|
|
12
|
-
|
|
13
|
-
import { fileIcon, humanFileSize } from './utils';
|
|
4
|
+
import { Actions } from './components/actions-control';
|
|
5
|
+
import { Content } from './components/content';
|
|
6
|
+
import { StatusControl } from './components/status-control';
|
|
7
|
+
import { FileUploadItemContext } from './context/file-upload-item-context';
|
|
8
|
+
import { FileUploadItemProps } from './types/file-upload-item-props';
|
|
14
9
|
|
|
15
10
|
import styles from './index.module.css';
|
|
16
11
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export type FileUploadItemProps = {
|
|
20
|
-
/**
|
|
21
|
-
* Дополнительный класс
|
|
22
|
-
*/
|
|
23
|
-
className?: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Идентификатор элемента
|
|
27
|
-
*/
|
|
28
|
-
id?: string;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Имя файла с расширением
|
|
32
|
-
*/
|
|
33
|
-
name?: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Размер файла
|
|
37
|
-
*/
|
|
38
|
-
size?: string | number;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Дата загрузки файла
|
|
42
|
-
*/
|
|
43
|
-
uploadDate?: string;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Ссылка на файл. Если прокидывается этот параметр, то появляется кнопка скачивания
|
|
47
|
-
*/
|
|
48
|
-
downloadLink?: string;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Рекомендует браузеру скачивать контент по ссылке.
|
|
52
|
-
* В проп может быть передано рекомендуемое название скачиваемого файла.
|
|
53
|
-
*/
|
|
54
|
-
download?: string | true;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Отображение кнопки удаления
|
|
58
|
-
*/
|
|
59
|
-
showDelete?: boolean;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Отображение кнопки восстановления
|
|
63
|
-
*/
|
|
64
|
-
showRestore?: boolean;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Процент загрузки файла
|
|
68
|
-
*/
|
|
69
|
-
uploadPercent?: number;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Статус загрузки файла
|
|
73
|
-
*/
|
|
74
|
-
uploadStatus?: FileStatuses;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Сообщение об ошибке
|
|
78
|
-
*/
|
|
79
|
-
error?: ReactNode;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Дочерние элементы
|
|
83
|
-
*/
|
|
84
|
-
children?: React.ReactNode;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Компонент кастомной иконки
|
|
88
|
-
*/
|
|
89
|
-
icon?: ElementType<{ className?: string }>;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Обработчик загрузки файла
|
|
93
|
-
*/
|
|
94
|
-
onDownload?: (id: string) => void;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Обработчик удаления файла
|
|
98
|
-
*/
|
|
99
|
-
onDelete?: (id: string, event?: MouseEvent<HTMLElement>) => void;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Обработчик восстановления файла
|
|
103
|
-
*/
|
|
104
|
-
onRestore?: (id: string) => void;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Управление активностью кнопок
|
|
108
|
-
*/
|
|
109
|
-
disableButtons?: boolean;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Разрешить многострочное название файла
|
|
113
|
-
*/
|
|
114
|
-
multiline?: boolean;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Указывает, где открыть скачиваемый документ
|
|
118
|
-
*/
|
|
119
|
-
target?: HTMLAttributeAnchorTarget;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Идентификатор для систем автоматизированного тестирования
|
|
123
|
-
*/
|
|
124
|
-
dataTestId?: string;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const FileUploadItem: React.FC<FileUploadItemProps> = ({
|
|
12
|
+
export const FileUploadItemComponent: React.FC<FileUploadItemProps> = ({
|
|
128
13
|
className,
|
|
129
14
|
children,
|
|
130
15
|
id = '0',
|
|
131
|
-
|
|
16
|
+
title = '',
|
|
17
|
+
subtitle,
|
|
132
18
|
size,
|
|
133
|
-
icon: Icon = fileIcon(name),
|
|
134
19
|
uploadDate,
|
|
135
20
|
downloadLink,
|
|
136
21
|
download,
|
|
137
22
|
uploadStatus,
|
|
138
|
-
uploadPercent = 0,
|
|
139
23
|
error,
|
|
140
24
|
showDelete,
|
|
141
25
|
showRestore,
|
|
@@ -143,132 +27,57 @@ export const FileUploadItem: React.FC<FileUploadItemProps> = ({
|
|
|
143
27
|
onDownload,
|
|
144
28
|
onRestore,
|
|
145
29
|
disableButtons,
|
|
146
|
-
multiline = false,
|
|
147
30
|
target,
|
|
148
31
|
dataTestId,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const errorContent =
|
|
191
|
-
uploadStatus === 'ERROR' && !error ? 'Не удалось загрузить файл' : error;
|
|
192
|
-
|
|
193
|
-
return (
|
|
194
|
-
<div className={styles.infoSection}>
|
|
195
|
-
<div className={cn(styles.name, { [styles.rowLimit]: !multiline })}>{name}</div>
|
|
196
|
-
|
|
197
|
-
{shouldShownError && (
|
|
198
|
-
<div className={styles.errorWrapper} role='alert'>
|
|
199
|
-
{errorContent}
|
|
200
|
-
</div>
|
|
201
|
-
)}
|
|
202
|
-
</div>
|
|
203
|
-
);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const showMeta = !showRestore && (!uploadStatus || uploadStatus === 'SUCCESS');
|
|
207
|
-
const showDownload = Boolean(downloadLink) && !showRestore;
|
|
208
|
-
|
|
209
|
-
return (
|
|
210
|
-
<div
|
|
211
|
-
className={cn(
|
|
212
|
-
className,
|
|
213
|
-
styles.component,
|
|
214
|
-
uploadStatus && styles[uploadStatus.toLocaleLowerCase()],
|
|
215
|
-
)}
|
|
216
|
-
data-test-id={dataTestId}
|
|
32
|
+
customIcon,
|
|
33
|
+
iconStyle = 'gray',
|
|
34
|
+
progressBar = 0,
|
|
35
|
+
customContent,
|
|
36
|
+
truncate,
|
|
37
|
+
imageUrl,
|
|
38
|
+
}) => (
|
|
39
|
+
<div
|
|
40
|
+
className={cn(
|
|
41
|
+
className,
|
|
42
|
+
styles.component,
|
|
43
|
+
uploadStatus && styles[uploadStatus.toLocaleLowerCase()],
|
|
44
|
+
)}
|
|
45
|
+
data-test-id={dataTestId}
|
|
46
|
+
>
|
|
47
|
+
<FileUploadItemContext.Provider
|
|
48
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
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
|
+
}}
|
|
217
73
|
>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
{showMeta && (
|
|
230
|
-
<div className={styles.meta}>
|
|
231
|
-
{uploadDate && <span key={uploadDate}>{uploadDate}</span>}
|
|
232
|
-
|
|
233
|
-
{size && (
|
|
234
|
-
<span key={size} className={styles.size}>
|
|
235
|
-
{humanFileSize(size)}
|
|
236
|
-
</span>
|
|
237
|
-
)}
|
|
238
|
-
</div>
|
|
239
|
-
)}
|
|
240
|
-
</div>
|
|
241
|
-
|
|
242
|
-
{showRestore && (
|
|
243
|
-
<Link pseudo={true} className={styles.restore} onClick={handleRestore}>
|
|
244
|
-
Восстановить
|
|
245
|
-
</Link>
|
|
246
|
-
)}
|
|
247
|
-
|
|
248
|
-
{showDownload && (
|
|
249
|
-
<IconButton
|
|
250
|
-
size='xxs'
|
|
251
|
-
icon={PointerDownSIcon}
|
|
252
|
-
className={styles.download}
|
|
253
|
-
aria-label='скачать'
|
|
254
|
-
href={downloadLink}
|
|
255
|
-
onClick={handleDownload}
|
|
256
|
-
disabled={disableButtons}
|
|
257
|
-
download={download}
|
|
258
|
-
target={target}
|
|
259
|
-
/>
|
|
260
|
-
)}
|
|
261
|
-
|
|
262
|
-
{showDelete && !showRestore && (
|
|
263
|
-
<IconButton
|
|
264
|
-
size='xxs'
|
|
265
|
-
icon={CrossSIcon}
|
|
266
|
-
onClick={handleDelete}
|
|
267
|
-
disabled={disableButtons}
|
|
268
|
-
className={styles.delete}
|
|
269
|
-
aria-label='удалить'
|
|
270
|
-
/>
|
|
271
|
-
)}
|
|
272
|
-
</div>
|
|
273
|
-
);
|
|
274
|
-
};
|
|
74
|
+
{children}
|
|
75
|
+
</FileUploadItemContext.Provider>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export const FileUploadItem = Object.assign(FileUploadItemComponent, {
|
|
80
|
+
StatusControl,
|
|
81
|
+
Content,
|
|
82
|
+
Actions,
|
|
83
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
display: flex;
|
|
5
|
+
max-width: 144px;
|
|
6
|
+
|
|
7
|
+
& .icon {
|
|
8
|
+
width: 48px;
|
|
9
|
+
height: 48px;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.deleteIconColor {
|
|
14
|
+
fill: var(--color-light-text-tertiary);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.downloadIconColor {
|
|
18
|
+
fill: var(--color-light-text-tertiary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.restoreIconColor {
|
|
22
|
+
fill: var(--color-light-text-tertiary);
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { FileUploadItemContext } from '../../context/file-upload-item-context';
|
|
4
|
+
|
|
5
|
+
import { DeleteButton } from './components/delete-button';
|
|
6
|
+
import { DownloadButton } from './components/download-button';
|
|
7
|
+
import { RestoreButton } from './components/restore-button';
|
|
8
|
+
|
|
9
|
+
import styles from './actions-control.module.css';
|
|
10
|
+
|
|
11
|
+
export const Actions = () => {
|
|
12
|
+
const { showRestore, downloadLink, showDelete } = useContext(FileUploadItemContext);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className={styles.container}>
|
|
16
|
+
{showRestore && <RestoreButton />}
|
|
17
|
+
|
|
18
|
+
{Boolean(downloadLink) && !showRestore && <DownloadButton />}
|
|
19
|
+
|
|
20
|
+
{showDelete && !showRestore && <DeleteButton />}
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { MouseEvent, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { IconButton } from '@alfalab/core-components-icon-button';
|
|
4
|
+
import CrossMIcon from '@alfalab/icons-glyph/CrossMIcon';
|
|
5
|
+
|
|
6
|
+
import { FileUploadItemContext } from '../../../../context/file-upload-item-context';
|
|
7
|
+
|
|
8
|
+
import styles from '../../actions-control.module.css';
|
|
9
|
+
|
|
10
|
+
export const DeleteButton = () => {
|
|
11
|
+
const { id = '0', disableButtons, onDelete } = useContext(FileUploadItemContext);
|
|
12
|
+
|
|
13
|
+
const handleDelete = (e: MouseEvent<HTMLElement>) => {
|
|
14
|
+
if (onDelete) {
|
|
15
|
+
onDelete(id, e);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<IconButton
|
|
21
|
+
className={styles.icon}
|
|
22
|
+
size='xxs'
|
|
23
|
+
aria-label='удалить'
|
|
24
|
+
icon={<CrossMIcon className={styles.deleteIconColor} />}
|
|
25
|
+
disabled={disableButtons}
|
|
26
|
+
onClick={handleDelete}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DeleteButton } from './delete-button';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { MouseEvent, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { IconButton } from '@alfalab/core-components-icon-button';
|
|
4
|
+
import ArrowDownLineDownCompactMIcon from '@alfalab/icons-glyph/ArrowDownLineDownCompactMIcon';
|
|
5
|
+
|
|
6
|
+
import { FileUploadItemContext } from '../../../../context/file-upload-item-context';
|
|
7
|
+
|
|
8
|
+
import styles from '../../actions-control.module.css';
|
|
9
|
+
|
|
10
|
+
export const DownloadButton = () => {
|
|
11
|
+
const {
|
|
12
|
+
id = '0',
|
|
13
|
+
downloadLink,
|
|
14
|
+
download,
|
|
15
|
+
disableButtons,
|
|
16
|
+
target,
|
|
17
|
+
onDownload,
|
|
18
|
+
} = useContext(FileUploadItemContext);
|
|
19
|
+
|
|
20
|
+
const handleDownload = (e: MouseEvent<HTMLElement>) => {
|
|
21
|
+
if (onDownload) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
onDownload(id);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<IconButton
|
|
29
|
+
className={styles.icon}
|
|
30
|
+
size='xxs'
|
|
31
|
+
aria-label='скачать'
|
|
32
|
+
icon={<ArrowDownLineDownCompactMIcon className={styles.downloadIconColor} />}
|
|
33
|
+
disabled={disableButtons}
|
|
34
|
+
href={downloadLink}
|
|
35
|
+
download={download}
|
|
36
|
+
target={target}
|
|
37
|
+
onClick={handleDownload}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DownloadButton } from './download-button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RestoreButton } from './restore-button';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { IconButton } from '@alfalab/core-components-icon-button';
|
|
4
|
+
import ArrowsCwCompactMIcon from '@alfalab/icons-glyph/ArrowsCwCompactMIcon';
|
|
5
|
+
|
|
6
|
+
import { FileUploadItemContext } from '../../../../context/file-upload-item-context';
|
|
7
|
+
|
|
8
|
+
import styles from '../../actions-control.module.css';
|
|
9
|
+
|
|
10
|
+
export const RestoreButton = () => {
|
|
11
|
+
const { id = '0', disableButtons, onRestore } = useContext(FileUploadItemContext);
|
|
12
|
+
|
|
13
|
+
const handleRestore = () => {
|
|
14
|
+
if (onRestore) {
|
|
15
|
+
onRestore(id);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<IconButton
|
|
21
|
+
className={styles.icon}
|
|
22
|
+
size='xxs'
|
|
23
|
+
aria-label='восстановить'
|
|
24
|
+
icon={<ArrowsCwCompactMIcon className={styles.restoreIconColor} />}
|
|
25
|
+
disabled={disableButtons}
|
|
26
|
+
onClick={handleRestore}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Actions } from './actions';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Typography } from '@alfalab/core-components-typography';
|
|
4
|
+
|
|
5
|
+
import { FileUploadItemContext } from '../../../../context/file-upload-item-context';
|
|
6
|
+
|
|
7
|
+
import styles from './content-error.module.css';
|
|
8
|
+
|
|
9
|
+
export const ContentError = () => {
|
|
10
|
+
const { error } = useContext(FileUploadItemContext);
|
|
11
|
+
|
|
12
|
+
if (typeof error === 'string' && error.length > 0) {
|
|
13
|
+
return (
|
|
14
|
+
<Typography.Text className={styles.errorItem} view='primary-small' color='negative'>
|
|
15
|
+
{error}
|
|
16
|
+
</Typography.Text>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (Array.isArray(error) && error.length > 0) {
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
{error.map((item) => (
|
|
24
|
+
<Typography.Text
|
|
25
|
+
key={item}
|
|
26
|
+
className={styles.errorItem}
|
|
27
|
+
view='primary-small'
|
|
28
|
+
color='negative'
|
|
29
|
+
>
|
|
30
|
+
{item}
|
|
31
|
+
</Typography.Text>
|
|
32
|
+
))}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Typography.Text className={styles.errorItem} view='primary-small' color='negative'>
|
|
39
|
+
Не удалось загрузить файл
|
|
40
|
+
</Typography.Text>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContentError } from './content-error';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { Typography } from '@alfalab/core-components-typography';
|
|
5
|
+
|
|
6
|
+
import { MAX_PROGRESS_BAR_VALUE } from '../../../../const/progress-bar';
|
|
7
|
+
import { FileUploadItemContext } from '../../../../context/file-upload-item-context';
|
|
8
|
+
import {
|
|
9
|
+
humanFileSize,
|
|
10
|
+
isErrorStatus,
|
|
11
|
+
isSuccessStatus,
|
|
12
|
+
isUploadedStatus,
|
|
13
|
+
isUploadingStatus,
|
|
14
|
+
} from '../../../../utils';
|
|
15
|
+
import { isError } from '../../utils/isError';
|
|
16
|
+
import { ContentError } from '../content-error';
|
|
17
|
+
|
|
18
|
+
import styles from './content-subtitle.module.css';
|
|
19
|
+
|
|
20
|
+
export const ContentSubtitle = () => {
|
|
21
|
+
const { uploadStatus, subtitle, uploadDate, size, truncate, showRestore, error, progressBar } =
|
|
22
|
+
useContext(FileUploadItemContext);
|
|
23
|
+
|
|
24
|
+
const shouldShownError = isErrorStatus(uploadStatus) || isError(error);
|
|
25
|
+
const showMeta =
|
|
26
|
+
!showRestore && (isSuccessStatus(uploadStatus) || isUploadedStatus(uploadStatus));
|
|
27
|
+
|
|
28
|
+
// валидация progressBar (не должен превышать 100 и быть меньше 0)
|
|
29
|
+
const validateProgressBarValue = (progressValue: number | undefined) => {
|
|
30
|
+
if (progressValue === undefined) {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return Math.min(Math.max(progressValue, 0), MAX_PROGRESS_BAR_VALUE);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const validProgressBar = validateProgressBarValue(progressBar);
|
|
38
|
+
|
|
39
|
+
// uploading status
|
|
40
|
+
if (isUploadingStatus(uploadStatus)) {
|
|
41
|
+
return (
|
|
42
|
+
<Typography.Text view='primary-small' color='secondary'>
|
|
43
|
+
Загрузка{'\u00A0'}
|
|
44
|
+
{Math.floor(validProgressBar)}%
|
|
45
|
+
</Typography.Text>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// error status
|
|
50
|
+
if (shouldShownError) {
|
|
51
|
+
return <ContentError />;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// success status
|
|
55
|
+
if (showMeta) {
|
|
56
|
+
return (
|
|
57
|
+
<div>
|
|
58
|
+
{size && (
|
|
59
|
+
<Typography.Text className={styles.size} view='primary-small' color='secondary'>
|
|
60
|
+
{humanFileSize(size)}
|
|
61
|
+
</Typography.Text>
|
|
62
|
+
)}
|
|
63
|
+
{uploadDate && (
|
|
64
|
+
<Typography.Text view='primary-small' color='secondary'>
|
|
65
|
+
{uploadDate}
|
|
66
|
+
</Typography.Text>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// restore status
|
|
73
|
+
if (showRestore) {
|
|
74
|
+
return (
|
|
75
|
+
<Typography.Text view='primary-small' color='tertiary'>
|
|
76
|
+
Файл удален
|
|
77
|
+
</Typography.Text>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<Typography.Text
|
|
83
|
+
className={cn(styles.subtitle, {
|
|
84
|
+
[styles.truncate]: truncate,
|
|
85
|
+
})}
|
|
86
|
+
view='primary-small'
|
|
87
|
+
color='secondary'
|
|
88
|
+
>
|
|
89
|
+
{subtitle}
|
|
90
|
+
</Typography.Text>
|
|
91
|
+
);
|
|
92
|
+
};
|