@alfalab/core-components-file-upload-item 5.10.1 → 6.0.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.d.ts +7 -92
- package/Component.js +41 -65
- package/actions-control.module-5a87c347.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-10db6600.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-86bcd03c.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 +7 -6
- 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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useContext, useRef } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { SuperEllipse } from '@alfalab/core-components/icon-view/super-ellipse';
|
|
4
|
+
import { RADIUS, MAX_PROGRESS_BAR_VALUE } from '../../const/progress-bar.js';
|
|
5
|
+
import { FileUploadItemContext } from '../../context/file-upload-item-context.js';
|
|
6
|
+
import { isUploadingStatus, isSuccessStatus, isErrorStatus } from '../../utils.js';
|
|
7
|
+
import { StatusControlIcon } from './components/status-control-icon/status-control-icon.js';
|
|
8
|
+
import { StatusControlProgressBar } from './components/status-control-progress-bar/status-control-progress-bar.js';
|
|
9
|
+
import styles from './status-control.module.css';
|
|
10
|
+
|
|
11
|
+
const StatusControl = () => {
|
|
12
|
+
const { uploadStatus = 'INITIAL', progressBar, imageUrl } = useContext(FileUploadItemContext);
|
|
13
|
+
const progressRef = useRef(null);
|
|
14
|
+
if (progressRef.current && progressBar) {
|
|
15
|
+
progressRef.current.style.maskImage = `conic-gradient(red ${(RADIUS / MAX_PROGRESS_BAR_VALUE) * progressBar}deg, transparent 0)`;
|
|
16
|
+
}
|
|
17
|
+
const isTransparentProgressBar = () => uploadStatus === 'INITIAL' || uploadStatus === 'UPLOADED' || uploadStatus === 'DELETED';
|
|
18
|
+
return (React.createElement("div", { className: styles.container },
|
|
19
|
+
React.createElement(SuperEllipse, { size: 48, ...(imageUrl && { imageUrl }) },
|
|
20
|
+
React.createElement(StatusControlIcon, null)),
|
|
21
|
+
React.createElement("div", { ref: progressRef, className: cn(styles.progress, {
|
|
22
|
+
[styles.uploading]: isUploadingStatus(uploadStatus),
|
|
23
|
+
[styles.success]: isSuccessStatus(uploadStatus),
|
|
24
|
+
[styles.error]: isErrorStatus(uploadStatus),
|
|
25
|
+
}) },
|
|
26
|
+
React.createElement(StatusControlProgressBar, { className: cn({
|
|
27
|
+
[styles.progressBarTransparent]: isTransparentProgressBar(),
|
|
28
|
+
[styles.progressBarUploading]: uploadStatus === 'UPLOADING',
|
|
29
|
+
[styles.progressBarSuccess]: uploadStatus === 'SUCCESS',
|
|
30
|
+
[styles.progressBarError]: uploadStatus === 'ERROR',
|
|
31
|
+
}) }))));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { StatusControl };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
position: relative;
|
|
5
|
+
cursor: pointer
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.container .progress {
|
|
9
|
+
position: absolute;
|
|
10
|
+
top: var(--gap-4-neg);
|
|
11
|
+
left: var(--gap-4-neg);
|
|
12
|
+
z-index: 1;
|
|
13
|
+
|
|
14
|
+
width: 56px;
|
|
15
|
+
height: 56px;
|
|
16
|
+
|
|
17
|
+
-webkit-mask-image: conic-gradient(black 0, transparent 0);
|
|
18
|
+
|
|
19
|
+
mask-image: conic-gradient(black 0, transparent 0)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.container .progress.uploading {
|
|
23
|
+
opacity: 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.container .progress.success,
|
|
27
|
+
.container .progress.error {
|
|
28
|
+
transition: opacity 400ms ease-in;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
-webkit-mask-image: conic-gradient(black 360deg, transparent 0);
|
|
31
|
+
mask-image: conic-gradient(black 360deg, transparent 0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.container .progressBarTransparent {
|
|
35
|
+
fill: transparent;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.container .progressBarUploading {
|
|
39
|
+
fill: var(--color-light-neutral-500);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.container .progressBarSuccess {
|
|
43
|
+
fill: var(--color-light-status-positive);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.container .progressBarError {
|
|
47
|
+
fill: var(--color-light-status-negative);
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ElementType, HTMLAttributeAnchorTarget, MouseEvent } from 'react';
|
|
3
|
+
type TFileUploadItemContext = {
|
|
4
|
+
showRestore?: boolean;
|
|
5
|
+
uploadStatus?: string;
|
|
6
|
+
error?: string | string[];
|
|
7
|
+
title?: string;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
uploadDate?: string;
|
|
10
|
+
size?: string | number;
|
|
11
|
+
id?: string;
|
|
12
|
+
onDownload?: (id: string) => void;
|
|
13
|
+
onDelete?: (id: string, event?: MouseEvent<HTMLElement>) => void;
|
|
14
|
+
onRestore?: (id: string) => void;
|
|
15
|
+
downloadLink?: string;
|
|
16
|
+
download?: string | true;
|
|
17
|
+
disableButtons?: boolean;
|
|
18
|
+
target?: HTMLAttributeAnchorTarget;
|
|
19
|
+
showDelete?: boolean;
|
|
20
|
+
customIcon?: ElementType<{
|
|
21
|
+
className?: string;
|
|
22
|
+
}>;
|
|
23
|
+
iconStyle?: 'gray' | 'colored';
|
|
24
|
+
progressBar?: number;
|
|
25
|
+
customContent?: ElementType;
|
|
26
|
+
truncate?: boolean;
|
|
27
|
+
imageUrl?: string;
|
|
28
|
+
};
|
|
29
|
+
declare const FileUploadItemContext: import("react").Context<TFileUploadItemContext>;
|
|
30
|
+
export { FileUploadItemContext };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const FileUploadItemContext = createContext({
|
|
4
|
+
showRestore: false,
|
|
5
|
+
uploadStatus: 'INITIAL',
|
|
6
|
+
error: undefined,
|
|
7
|
+
title: '',
|
|
8
|
+
subtitle: '',
|
|
9
|
+
uploadDate: '',
|
|
10
|
+
size: 0,
|
|
11
|
+
id: '0',
|
|
12
|
+
onDownload: undefined,
|
|
13
|
+
onDelete: undefined,
|
|
14
|
+
onRestore: undefined,
|
|
15
|
+
downloadLink: '',
|
|
16
|
+
download: '',
|
|
17
|
+
disableButtons: false,
|
|
18
|
+
target: undefined,
|
|
19
|
+
showDelete: false,
|
|
20
|
+
iconStyle: 'gray',
|
|
21
|
+
customIcon: undefined,
|
|
22
|
+
progressBar: 0,
|
|
23
|
+
customContent: undefined,
|
|
24
|
+
truncate: false,
|
|
25
|
+
imageUrl: undefined,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export { FileUploadItemContext };
|
package/moderncssm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FileUploadItem } from './Component.js';
|
|
1
|
+
export { FileUploadItem, FileUploadItemComponent } from './Component.js';
|
|
@@ -1,129 +1,14 @@
|
|
|
1
1
|
/* */
|
|
2
2
|
|
|
3
3
|
.component {
|
|
4
|
-
|
|
5
|
-
line-height: 16px;
|
|
6
|
-
font-weight: 400;
|
|
7
|
-
|
|
4
|
+
box-sizing: border-box;
|
|
8
5
|
display: flex;
|
|
9
6
|
align-items: flex-start;
|
|
10
7
|
width: 100%;
|
|
11
|
-
|
|
12
|
-
color: var(--color-light-text-secondary);
|
|
13
|
-
box-shadow: 0 -1px 0 0 var(--color-light-neutral-300) inset;
|
|
14
|
-
box-sizing: border-box
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.component svg {
|
|
18
|
-
display: block;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.component:last-child {
|
|
22
|
-
box-shadow: none;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.infoSection {
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
flex: 1;
|
|
29
|
-
margin-top: var(--gap-4);
|
|
30
|
-
margin-left: var(--gap-12);
|
|
31
|
-
min-width: 40%;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.info {
|
|
35
|
-
display: flex;
|
|
36
|
-
flex-wrap: wrap;
|
|
37
|
-
flex: 1;
|
|
38
|
-
overflow: hidden;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.icon {
|
|
42
|
-
display: block;
|
|
43
|
-
flex-shrink: 0;
|
|
44
|
-
color: var(--color-light-neutral-translucent-1300);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.errorIcon {
|
|
48
|
-
flex-shrink: 0;
|
|
49
|
-
color: var(--color-light-status-negative);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.successIcon {
|
|
53
|
-
flex-shrink: 0;
|
|
54
|
-
color: var(--color-light-status-positive);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.name {
|
|
58
|
-
color: var(--color-light-text-primary)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.name a {
|
|
62
|
-
display: block;
|
|
63
|
-
margin-bottom: 1px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.name.rowLimit {
|
|
67
|
-
white-space: nowrap;
|
|
68
|
-
overflow: hidden;
|
|
69
|
-
text-overflow: ellipsis;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.meta {
|
|
73
|
-
display: flex;
|
|
74
|
-
white-space: nowrap;
|
|
75
|
-
margin-right: var(--gap-4);
|
|
76
|
-
margin-left: 36px;
|
|
77
|
-
padding: var(--gap-4) var(--gap-0)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.meta > * {
|
|
81
|
-
margin-right: var(--gap-12)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.meta > *:last-child {
|
|
85
|
-
margin-right: var(--gap-0);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.size {
|
|
89
|
-
text-align: right;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.delete,
|
|
93
|
-
.download {
|
|
94
|
-
height: 24px;
|
|
95
|
-
width: 24px;
|
|
96
|
-
margin-left: var(--gap-8);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.errorWrapper {
|
|
100
|
-
margin-top: var(--gap-4);
|
|
101
|
-
color: var(--color-light-text-negative);
|
|
8
|
+
min-height: 48px;
|
|
102
9
|
}
|
|
103
10
|
|
|
104
11
|
.restore {
|
|
105
|
-
font-size: 14px;
|
|
106
|
-
line-height: 20px;
|
|
107
|
-
font-weight: 400;
|
|
108
|
-
|
|
109
12
|
margin-left: var(--gap-12);
|
|
110
13
|
margin-top: var(--gap-2);
|
|
111
14
|
}
|
|
112
|
-
|
|
113
|
-
.spinnerWrapper {
|
|
114
|
-
display: flex;
|
|
115
|
-
justify-content: center;
|
|
116
|
-
align-items: center;
|
|
117
|
-
width: 24px;
|
|
118
|
-
height: 24px;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.spinner {
|
|
122
|
-
width: 20px;
|
|
123
|
-
height: 20px;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.uploadPercent {
|
|
127
|
-
margin-top: var(--gap-4);
|
|
128
|
-
margin-left: var(--gap-24);
|
|
129
|
-
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ElementType, HTMLAttributeAnchorTarget, MouseEvent } from "react";
|
|
4
|
+
type FileUploadItemProps = {
|
|
5
|
+
/**
|
|
6
|
+
* Дополнительный класс
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Идентификатор элемента
|
|
11
|
+
*/
|
|
12
|
+
id?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Имя файла / заголовок
|
|
15
|
+
*/
|
|
16
|
+
title?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Подзаголовок файла
|
|
19
|
+
*/
|
|
20
|
+
subtitle?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Размер файла
|
|
23
|
+
*/
|
|
24
|
+
size?: string | number;
|
|
25
|
+
/**
|
|
26
|
+
* Дата загрузки файла
|
|
27
|
+
*/
|
|
28
|
+
uploadDate?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Ссылка на файл. Если прокидывается этот параметр, то появляется кнопка скачивания
|
|
31
|
+
*/
|
|
32
|
+
downloadLink?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Рекомендует браузеру скачивать контент по ссылке.
|
|
35
|
+
* В проп может быть передано рекомендуемое название скачиваемого файла.
|
|
36
|
+
*/
|
|
37
|
+
download?: string | true;
|
|
38
|
+
/**
|
|
39
|
+
* Отображение кнопки удаления
|
|
40
|
+
*/
|
|
41
|
+
showDelete?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Отображение кнопки восстановления
|
|
44
|
+
*/
|
|
45
|
+
showRestore?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Статус загрузки файла
|
|
48
|
+
*/
|
|
49
|
+
uploadStatus?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Сообщение об ошибке
|
|
52
|
+
*/
|
|
53
|
+
error?: string | string[];
|
|
54
|
+
/**
|
|
55
|
+
* Дочерние элементы
|
|
56
|
+
*/
|
|
57
|
+
children?: React.ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Обработчик загрузки файла
|
|
60
|
+
*/
|
|
61
|
+
onDownload?: (id: string) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Обработчик удаления файла
|
|
64
|
+
*/
|
|
65
|
+
onDelete?: (id: string, event?: MouseEvent<HTMLElement>) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Обработчик восстановления файла
|
|
68
|
+
*/
|
|
69
|
+
onRestore?: (id: string) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Управление активностью кнопок
|
|
72
|
+
*/
|
|
73
|
+
disableButtons?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Указывает, где открыть скачиваемый документ
|
|
76
|
+
*/
|
|
77
|
+
target?: HTMLAttributeAnchorTarget;
|
|
78
|
+
/**
|
|
79
|
+
* Идентификатор для систем автоматизированного тестирования
|
|
80
|
+
*/
|
|
81
|
+
dataTestId?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Цвет заполнения иконки
|
|
84
|
+
* @default gray
|
|
85
|
+
*/
|
|
86
|
+
iconStyle?: 'gray' | 'colored';
|
|
87
|
+
/**
|
|
88
|
+
* Кастомная иконка
|
|
89
|
+
*/
|
|
90
|
+
customIcon?: ElementType<{
|
|
91
|
+
className?: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Шкала прогресса
|
|
95
|
+
* от 0 до 100
|
|
96
|
+
* @default 0
|
|
97
|
+
*/
|
|
98
|
+
progressBar?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Кастомный контент
|
|
101
|
+
*/
|
|
102
|
+
customContent?: ElementType;
|
|
103
|
+
/**
|
|
104
|
+
* Отсечение контента
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
truncate?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Фоновое изображение. Имеет приоритет над иконкой и заливкой
|
|
110
|
+
*/
|
|
111
|
+
imageUrl?: string;
|
|
112
|
+
};
|
|
113
|
+
export { FileUploadItemProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/moderncssm/utils.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
declare function humanFileSize(size: string | number): string;
|
|
3
2
|
declare const getExtension: (filename: string) => string | undefined;
|
|
4
|
-
declare
|
|
5
|
-
|
|
3
|
+
declare const isInitialStatus: (status?: string) => boolean;
|
|
4
|
+
declare const isSuccessStatus: (status?: string) => boolean;
|
|
5
|
+
declare const isErrorStatus: (status?: string) => boolean;
|
|
6
|
+
declare const isUploadingStatus: (status?: string) => boolean;
|
|
7
|
+
declare const isUploadedStatus: (status?: string) => boolean;
|
|
8
|
+
export { humanFileSize, getExtension, isInitialStatus, isSuccessStatus, isErrorStatus, isUploadingStatus, isUploadedStatus };
|
package/moderncssm/utils.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { DocumentDocMIcon } from '@alfalab/icons-glyph/DocumentDocMIcon';
|
|
2
|
-
import { DocumentImageMIcon } from '@alfalab/icons-glyph/DocumentImageMIcon';
|
|
3
|
-
import { DocumentPdfMIcon } from '@alfalab/icons-glyph/DocumentPdfMIcon';
|
|
4
|
-
import { DocumentTxtMIcon } from '@alfalab/icons-glyph/DocumentTxtMIcon';
|
|
5
|
-
import { DocumentUnknownMIcon } from '@alfalab/icons-glyph/DocumentUnknownMIcon';
|
|
6
|
-
|
|
7
1
|
function humanFileSize(size) {
|
|
8
2
|
const units = ['Б', 'КБ', 'МБ', 'ГБ'];
|
|
9
3
|
let humanSize = Number(size);
|
|
@@ -16,26 +10,10 @@ function humanFileSize(size) {
|
|
|
16
10
|
return `${Number(humanSize)} ${units[factor]}`;
|
|
17
11
|
}
|
|
18
12
|
const getExtension = (filename) => filename.toLowerCase().split('.').pop();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
case 'jpeg':
|
|
25
|
-
case 'svg':
|
|
26
|
-
case 'tif':
|
|
27
|
-
case 'tiff':
|
|
28
|
-
return DocumentImageMIcon;
|
|
29
|
-
case 'doc':
|
|
30
|
-
case 'docx':
|
|
31
|
-
return DocumentDocMIcon;
|
|
32
|
-
case 'pdf':
|
|
33
|
-
return DocumentPdfMIcon;
|
|
34
|
-
case 'txt':
|
|
35
|
-
return DocumentTxtMIcon;
|
|
36
|
-
default:
|
|
37
|
-
return DocumentUnknownMIcon;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
13
|
+
const isInitialStatus = (status) => status === 'INITIAL';
|
|
14
|
+
const isSuccessStatus = (status) => status === 'SUCCESS';
|
|
15
|
+
const isErrorStatus = (status) => status === 'ERROR';
|
|
16
|
+
const isUploadingStatus = (status) => status === 'UPLOADING';
|
|
17
|
+
const isUploadedStatus = (status) => status === 'UPLOADED';
|
|
40
18
|
|
|
41
|
-
export {
|
|
19
|
+
export { getExtension, humanFileSize, isErrorStatus, isInitialStatus, isSuccessStatus, isUploadedStatus, isUploadingStatus };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-file-upload-item",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
"react": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@alfalab/core-components-icon-button": "^6.
|
|
17
|
+
"@alfalab/core-components-icon-button": "^6.11.1",
|
|
18
18
|
"@alfalab/core-components-link": "^5.3.1",
|
|
19
|
-
"@alfalab/core-components-spinner": "^
|
|
20
|
-
"@alfalab/icons-glyph": "^2.
|
|
19
|
+
"@alfalab/core-components-spinner": "^4.0.0",
|
|
20
|
+
"@alfalab/icons-glyph": "^2.189.0",
|
|
21
|
+
"@alfalab/core-components-typography": "^4.10.0",
|
|
21
22
|
"classnames": "^2.3.1",
|
|
22
23
|
"tslib": "^2.4.0"
|
|
23
24
|
},
|
|
24
|
-
"themesVersion": "13.
|
|
25
|
-
"varsVersion": "9.
|
|
25
|
+
"themesVersion": "13.5.0",
|
|
26
|
+
"varsVersion": "9.15.0"
|
|
26
27
|
}
|