@macive/ui 0.0.23 → 0.0.24
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/dist/src/components/Upload/components/FileViewer/FileViewer.js +10 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/types/src/components/Input/Input.d.ts +1 -1
- package/dist/types/src/components/Upload/components/FileViewer/FileViewer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ const Image_1 = require("../../../Image");
|
|
|
12
12
|
const FileViewer_classnames_1 = __importDefault(require("./FileViewer.classnames"));
|
|
13
13
|
const VideoPlayer_1 = require("./VideoPlayer");
|
|
14
14
|
const FileViewer = (props) => {
|
|
15
|
+
var _a, _b;
|
|
15
16
|
const [imageSource, setImageSource] = (0, react_1.useState)();
|
|
16
17
|
const { file, disabled, previewable, legacyImage, unAcceptedType, className } = props;
|
|
17
18
|
const { type: fileType } = file || {};
|
|
@@ -22,19 +23,22 @@ const FileViewer = (props) => {
|
|
|
22
23
|
return (0, jsx_runtime_1.jsx)(VideoPlayer_1.VideoPlayer, { file: file, disabled: unAcceptedType });
|
|
23
24
|
}
|
|
24
25
|
if (fileType === 'archive') {
|
|
25
|
-
return ((0, jsx_runtime_1.jsxs)(FileTypeDisplay, { disabled: unAcceptedType, previewable: previewable, file: file, children: [
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(FileTypeDisplay, { disabled: unAcceptedType, previewable: previewable, file: file, children: [(_a = file === null || file === void 0 ? void 0 : file.extension) !== null && _a !== void 0 ? _a : 'zip', (0, jsx_runtime_1.jsx)(FileTypeDisplayTitle, { file: file })] }));
|
|
26
27
|
}
|
|
27
28
|
if (fileType === 'document') {
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(FileTypeDisplay, { disabled: unAcceptedType, previewable: previewable, file: file, children: [
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)(FileTypeDisplay, { disabled: unAcceptedType, previewable: previewable, file: file, children: [(_b = file === null || file === void 0 ? void 0 : file.extension) !== null && _b !== void 0 ? _b : 'pdf', (0, jsx_runtime_1.jsx)(FileTypeDisplayTitle, { file: file })] }));
|
|
29
30
|
}
|
|
30
31
|
return ((0, jsx_runtime_1.jsx)(FileTypeDisplay, { disabled: unAcceptedType, previewable: previewable, file: file, children: "media" }));
|
|
31
32
|
};
|
|
32
33
|
exports.FileViewer = FileViewer;
|
|
33
34
|
const FileTypeDisplayTitle = ({ file, children }) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const truncateString = (str = 'file') => {
|
|
36
|
+
if (str === null || str === undefined || typeof str !== 'string') {
|
|
37
|
+
return 'file';
|
|
38
|
+
}
|
|
39
|
+
return str.length > 9 ? `${str.substring(0, 1)}...${str.substring(str.length - 10)}` : str;
|
|
40
|
+
};
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: FileViewer_classnames_1.default['file-type-title'], children: children !== null && children !== void 0 ? children : truncateString(file === null || file === void 0 ? void 0 : file.fileName) }));
|
|
38
42
|
};
|
|
39
43
|
const FileTypeDisplay = ({ disabled, file, children, className }) => {
|
|
40
44
|
return ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)(FileViewer_classnames_1.default['file-type-display'], disabled && FileViewer_classnames_1.default.disabled, className), children: children || `${file === null || file === void 0 ? void 0 : file.extension} File` }));
|