@appquality/unguess-design-system 3.1.93-beta-attachments → 3.1.94-beta-attachments
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/build/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var sunburst = require('@nivo/sunburst');
|
|
|
25
25
|
var waffle = require('@nivo/waffle');
|
|
26
26
|
var line = require('@nivo/line');
|
|
27
27
|
var reactForms = require('@zendeskgarden/react-forms');
|
|
28
|
+
var uuid = require('uuid');
|
|
28
29
|
var react = require('@tiptap/react');
|
|
29
30
|
var reactTooltips = require('@zendeskgarden/react-tooltips');
|
|
30
31
|
var Typography = require('@tiptap/extension-typography');
|
|
@@ -2313,7 +2314,7 @@ const ChatFooter = ({ saveText, children, showShortcut, }) => {
|
|
|
2313
2314
|
};
|
|
2314
2315
|
|
|
2315
2316
|
const ChatContext = React.createContext(null);
|
|
2316
|
-
const ChatContextProvider = ({ onSave, onFileUpload, setMentionableUsers, children, }) => {
|
|
2317
|
+
const ChatContextProvider = ({ onSave, onFileUpload, onDeleteThumbnail, setMentionableUsers, children, }) => {
|
|
2317
2318
|
const [editor, setEditor] = React.useState();
|
|
2318
2319
|
const [thumbnails, setThumbnails] = React.useState([]);
|
|
2319
2320
|
const getMentions = (editor) => {
|
|
@@ -2331,10 +2332,14 @@ const ChatContextProvider = ({ onSave, onFileUpload, setMentionableUsers, childr
|
|
|
2331
2332
|
});
|
|
2332
2333
|
return result;
|
|
2333
2334
|
};
|
|
2335
|
+
React.useMemo(() => {
|
|
2336
|
+
console.log("thumbnails", thumbnails);
|
|
2337
|
+
}, [thumbnails]);
|
|
2334
2338
|
const chatContextValue = React.useMemo(() => ({
|
|
2335
2339
|
editor,
|
|
2336
2340
|
setEditor,
|
|
2337
2341
|
thumbnails,
|
|
2342
|
+
setThumbnails,
|
|
2338
2343
|
afterUploadCallback: (failed) => {
|
|
2339
2344
|
setThumbnails(thumbnails.map((file) => {
|
|
2340
2345
|
if (failed.includes(file.name)) {
|
|
@@ -2378,7 +2383,12 @@ const ChatContextProvider = ({ onSave, onFileUpload, setMentionableUsers, childr
|
|
|
2378
2383
|
setThumbnails([]);
|
|
2379
2384
|
console.log("thumbnails clear triggered", thumbnails);
|
|
2380
2385
|
},
|
|
2381
|
-
|
|
2386
|
+
onDeleteThumbnail: (id) => {
|
|
2387
|
+
onDeleteThumbnail(id);
|
|
2388
|
+
},
|
|
2389
|
+
removeThumbnail: (index) => {
|
|
2390
|
+
setThumbnails(thumbnails.filter((_, i) => i !== index));
|
|
2391
|
+
},
|
|
2382
2392
|
triggerSave: () => {
|
|
2383
2393
|
if (editor && onSave && !editor.isEmpty) {
|
|
2384
2394
|
onSave(editor, getMentions(editor));
|
|
@@ -2396,6 +2406,7 @@ const ChatContextProvider = ({ onSave, onFileUpload, setMentionableUsers, childr
|
|
|
2396
2406
|
thumbnails,
|
|
2397
2407
|
setThumbnails,
|
|
2398
2408
|
onFileUpload,
|
|
2409
|
+
onDeleteThumbnail,
|
|
2399
2410
|
]);
|
|
2400
2411
|
return (jsxRuntime.jsx(ChatContext.Provider, Object.assign({ value: chatContextValue }, { children: children })));
|
|
2401
2412
|
};
|
|
@@ -3090,7 +3101,10 @@ const CommentBar = ({ editor, i18n, }) => {
|
|
|
3090
3101
|
const files = fileInput.files;
|
|
3091
3102
|
if (files) {
|
|
3092
3103
|
const mediaFiles = Array.from(files).map((file) => {
|
|
3093
|
-
return Object.assign(file, {
|
|
3104
|
+
return Object.assign(file, {
|
|
3105
|
+
isLoadingMedia: false,
|
|
3106
|
+
internal_id: uuid.v4(),
|
|
3107
|
+
});
|
|
3094
3108
|
});
|
|
3095
3109
|
if (mediaFiles.length === 0)
|
|
3096
3110
|
return;
|
|
@@ -3523,8 +3537,9 @@ const StyledCol$1 = styled__default["default"](reactGrid.Col) `
|
|
|
3523
3537
|
`;
|
|
3524
3538
|
const Col = (props) => jsxRuntime.jsx(StyledCol$1, Object.assign({}, props));
|
|
3525
3539
|
|
|
3526
|
-
const ThumbnailContainer = ({
|
|
3527
|
-
|
|
3540
|
+
const ThumbnailContainer = ({
|
|
3541
|
+
/*removeMediaToUpload,*/ openLightbox, }) => {
|
|
3542
|
+
const { thumbnails, removeThumbnail, onDeleteThumbnail } = useChatContext();
|
|
3528
3543
|
if (!thumbnails || thumbnails.length === 0) {
|
|
3529
3544
|
return null;
|
|
3530
3545
|
}
|
|
@@ -3535,6 +3550,7 @@ const ThumbnailContainer = ({ openLightbox }) => {
|
|
|
3535
3550
|
fileType: file.type,
|
|
3536
3551
|
status: file.isLoadingMedia ? "uploading" : "success",
|
|
3537
3552
|
previewUrl: URL.createObjectURL(file),
|
|
3553
|
+
internal_id: file.internal_id,
|
|
3538
3554
|
});
|
|
3539
3555
|
});
|
|
3540
3556
|
console.log("mediafiles", mediaFiles);
|
|
@@ -3544,11 +3560,17 @@ const ThumbnailContainer = ({ openLightbox }) => {
|
|
|
3544
3560
|
return (jsxRuntime.jsx(Grid, { children: jsxRuntime.jsx(Row$1, Object.assign({ className: "responsive-container" }, { children: mediaFiles.map((file, index) => {
|
|
3545
3561
|
// Check if item is an image or a video
|
|
3546
3562
|
if (file.fileType.includes("image"))
|
|
3547
|
-
return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, xl: 3, lg: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(ImageThumbnail, { src: file.previewUrl, index: index, showX: true, isLoadingMedia: file.status === "uploading", removeThumbnail: () =>
|
|
3563
|
+
return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, xl: 3, lg: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(ImageThumbnail, { src: file.previewUrl, index: index, showX: true, isLoadingMedia: file.status === "uploading", removeThumbnail: () => {
|
|
3564
|
+
removeThumbnail(index);
|
|
3565
|
+
onDeleteThumbnail(file.internal_id);
|
|
3566
|
+
}, clickThumbnail: () => {
|
|
3548
3567
|
openLightbox(thumbnails[index], index);
|
|
3549
3568
|
} }, index) })));
|
|
3550
3569
|
if (file.fileType.includes("video"))
|
|
3551
|
-
return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(VideoThumbnail, { src: file.previewUrl, index: index, showX: true, isLoadingMedia: file.status === "uploading", removeThumbnail: () =>
|
|
3570
|
+
return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(VideoThumbnail, { src: file.previewUrl, index: index, showX: true, isLoadingMedia: file.status === "uploading", removeThumbnail: () => {
|
|
3571
|
+
removeThumbnail(index);
|
|
3572
|
+
//removeMediaToUpload(thumbnails[index]);
|
|
3573
|
+
}, clickThumbnail: () => {
|
|
3552
3574
|
openLightbox(thumbnails[index], index);
|
|
3553
3575
|
} }, index) })));
|
|
3554
3576
|
return null;
|
|
@@ -4545,11 +4567,14 @@ const CommentBox = (_a) => {
|
|
|
4545
4567
|
return false;
|
|
4546
4568
|
event.preventDefault();
|
|
4547
4569
|
const files = Array.from(event.dataTransfer.files).map((file) => {
|
|
4548
|
-
return Object.assign(file, {
|
|
4570
|
+
return Object.assign(file, {
|
|
4571
|
+
isLoadingMedia: false,
|
|
4572
|
+
internal_id: uuid.v4(),
|
|
4573
|
+
});
|
|
4549
4574
|
});
|
|
4550
|
-
const
|
|
4551
|
-
if (
|
|
4552
|
-
for (const file of
|
|
4575
|
+
const wrongFiles = files.filter((file) => !/^(image|video)\//.test(file.type));
|
|
4576
|
+
if (wrongFiles.length > 0) {
|
|
4577
|
+
for (const file of wrongFiles) {
|
|
4553
4578
|
addToast(({ close }) => (jsxRuntime.jsx(Notification, { onClose: close, type: "error", message: `${props.messageBadFileFormat} - ${file.name}`, isPrimary: true })), { placement: "top" });
|
|
4554
4579
|
}
|
|
4555
4580
|
}
|
|
@@ -15,6 +15,7 @@ export type ChatContextType = {
|
|
|
15
15
|
}) => SuggestedUser[];
|
|
16
16
|
afterUploadCallback: (failed: string[]) => void;
|
|
17
17
|
clearInput: () => void;
|
|
18
|
+
onDeleteThumbnail: (id: string) => void;
|
|
18
19
|
};
|
|
19
20
|
export declare const ChatContext: React.Context<ChatContextType | null>;
|
|
20
21
|
export interface Data {
|
|
@@ -26,9 +27,10 @@ export interface Data {
|
|
|
26
27
|
errorCode: string;
|
|
27
28
|
}[];
|
|
28
29
|
}
|
|
29
|
-
export declare const ChatContextProvider: ({ onSave, onFileUpload, setMentionableUsers, children, }: {
|
|
30
|
+
export declare const ChatContextProvider: ({ onSave, onFileUpload, onDeleteThumbnail, setMentionableUsers, children, }: {
|
|
30
31
|
onSave?: ((editor: Editor, mentions: SuggestedUser[]) => void) | undefined;
|
|
31
32
|
onFileUpload?: ((files: FileItem[]) => Promise<Data>) | undefined;
|
|
33
|
+
onDeleteThumbnail: (id: string) => void;
|
|
32
34
|
children: React.ReactNode;
|
|
33
35
|
setMentionableUsers: (props: {
|
|
34
36
|
query: string;
|
|
@@ -4,9 +4,10 @@ export interface FileElement {
|
|
|
4
4
|
status: "success" | "failed" | "uploading";
|
|
5
5
|
errorCode?: "FILE_TOO_BIG" | "INVALID_FILE_EXTENSION" | "GENERIC_ERROR";
|
|
6
6
|
previewUrl: string;
|
|
7
|
+
internal_id: string;
|
|
7
8
|
}
|
|
8
9
|
interface Props {
|
|
9
10
|
openLightbox: (file: File, index: number) => void;
|
|
10
11
|
}
|
|
11
|
-
declare const ThumbnailContainer: ({ openLightbox }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
|
+
declare const ThumbnailContainer: ({ openLightbox, }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
12
13
|
export default ThumbnailContainer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appquality/unguess-design-system",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.94-beta-attachments",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -68,7 +68,8 @@
|
|
|
68
68
|
"react-slick": "^0.29.0",
|
|
69
69
|
"react-window": "^1.8.6",
|
|
70
70
|
"tippy.js": "^6.3.7",
|
|
71
|
-
"ua-parser-js": "^1.0.2"
|
|
71
|
+
"ua-parser-js": "^1.0.2",
|
|
72
|
+
"uuid": "^9.0.1"
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
74
75
|
"@babel/preset-env": "^7.21.5",
|
|
@@ -92,6 +93,7 @@
|
|
|
92
93
|
"@types/react-window": "^1.8.5",
|
|
93
94
|
"@types/styled-components": "^5.1.23",
|
|
94
95
|
"@types/ua-parser-js": "^0.7.36",
|
|
96
|
+
"@types/uuid": "^9.0.8",
|
|
95
97
|
"@zendeskgarden/react-dropdowns": "^8.49.0",
|
|
96
98
|
"@zendeskgarden/react-forms": "^8.49.0",
|
|
97
99
|
"@zendeskgarden/react-theming": "^8.48.2",
|