@appquality/unguess-design-system 3.1.85-beta-attachments → 3.1.87-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
|
@@ -2336,21 +2336,41 @@ const ChatContextProvider = ({ onSave, onFileUpload, setMentionableUsers, childr
|
|
|
2336
2336
|
editor,
|
|
2337
2337
|
setEditor,
|
|
2338
2338
|
thumbnails,
|
|
2339
|
-
|
|
2340
|
-
|
|
2339
|
+
afterUploadCallback: (failed) => {
|
|
2340
|
+
setThumbnails(thumbnails.map((file) => {
|
|
2341
|
+
if (failed.includes(file.name)) {
|
|
2342
|
+
file.isLoadingMedia = false;
|
|
2343
|
+
//file.isError = true;
|
|
2344
|
+
}
|
|
2345
|
+
else {
|
|
2346
|
+
file.isLoadingMedia = false;
|
|
2347
|
+
//file.isError = false
|
|
2348
|
+
}
|
|
2349
|
+
return file;
|
|
2350
|
+
}));
|
|
2341
2351
|
},
|
|
2342
2352
|
//isMediaUploading, // Incluso nel valore del contesto
|
|
2343
2353
|
//setIsMediaUploading, // Incluso nel valore del contesto
|
|
2344
2354
|
addThumbnails: ({ files, }) => {
|
|
2345
|
-
|
|
2355
|
+
files.forEach((file) => (file.isLoadingMedia = true));
|
|
2356
|
+
setThumbnails((prev) => [...prev, ...files]);
|
|
2357
|
+
if (onFileUpload) {
|
|
2358
|
+
onFileUpload(files).then((data) => {
|
|
2359
|
+
var _a;
|
|
2360
|
+
const failed = (_a = data.failed) === null || _a === void 0 ? void 0 : _a.map(f => f.name);
|
|
2361
|
+
setThumbnails(thumbnails.map((file) => {
|
|
2362
|
+
file.isLoadingMedia = false;
|
|
2363
|
+
if ((failed === null || failed === void 0 ? void 0 : failed.length) && failed.includes(file.name)) ;
|
|
2364
|
+
return file;
|
|
2365
|
+
}));
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2346
2368
|
/* const media = files.map((file) => ({
|
|
2347
2369
|
...file,
|
|
2348
2370
|
isLoadingMedia: false,
|
|
2349
2371
|
}));
|
|
2350
2372
|
media[0].isLoadingMedia = false;*/
|
|
2351
2373
|
//setIsMediaUploading(true);
|
|
2352
|
-
files.forEach((file) => (file.isLoadingMedia = true));
|
|
2353
|
-
setThumbnails((prev) => [...prev, ...files]);
|
|
2354
2374
|
//setIsMediaUploading(false);
|
|
2355
2375
|
},
|
|
2356
2376
|
removeThumbnail: (index) => setThumbnails(thumbnails.filter((_, i) => i !== index)),
|
|
@@ -4325,9 +4345,7 @@ const ChatBoxContainer = styled__default["default"].div `
|
|
|
4325
4345
|
const CommentBox = (_a) => {
|
|
4326
4346
|
var { placeholderOptions } = _a, props = __rest(_a, ["placeholderOptions"]);
|
|
4327
4347
|
const { children, hasFloatingMenu, hasButtonsMenu, bubbleOptions, i18n } = props;
|
|
4328
|
-
const { editor, setEditor, mentionableUsers, triggerSave, thumbnails, addThumbnails
|
|
4329
|
-
//setIsMediaUploading,
|
|
4330
|
-
} = useChatContext();
|
|
4348
|
+
const { editor, setEditor, mentionableUsers, triggerSave, thumbnails, addThumbnails } = useChatContext();
|
|
4331
4349
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
4332
4350
|
const [selectedImage, setSelectedImage] = React.useState({});
|
|
4333
4351
|
const [selectedImageIndex, setSelectedImageIndex] = React.useState(0);
|
|
@@ -10,7 +10,6 @@ export type SuggestedUser = {
|
|
|
10
10
|
export interface ChatEditorArgs extends Partial<EditorOptions> {
|
|
11
11
|
placeholderOptions?: Partial<PlaceholderOptions>;
|
|
12
12
|
hasFloatingMenu?: boolean;
|
|
13
|
-
isNewMedia: boolean;
|
|
14
13
|
hasButtonsMenu?: boolean;
|
|
15
14
|
bubbleOptions?: any;
|
|
16
15
|
author: Author;
|
|
@@ -17,16 +17,21 @@ export type ChatContextType = {
|
|
|
17
17
|
mentionableUsers: (props: {
|
|
18
18
|
query: string;
|
|
19
19
|
}) => SuggestedUser[];
|
|
20
|
-
|
|
21
|
-
isLoadingMedia: boolean;
|
|
22
|
-
})[], index: number) => void;
|
|
20
|
+
afterUploadCallback: (failed: string[]) => void;
|
|
23
21
|
};
|
|
24
22
|
export declare const ChatContext: React.Context<ChatContextType | null>;
|
|
23
|
+
export interface Data {
|
|
24
|
+
uploaded_ids?: number[];
|
|
25
|
+
failed?: {
|
|
26
|
+
name: string;
|
|
27
|
+
errorCode: string;
|
|
28
|
+
}[];
|
|
29
|
+
}
|
|
25
30
|
export declare const ChatContextProvider: ({ onSave, onFileUpload, setMentionableUsers, children, }: {
|
|
26
31
|
onSave?: ((editor: Editor, mentions: SuggestedUser[]) => void) | undefined;
|
|
27
32
|
onFileUpload?: ((files: (File & {
|
|
28
33
|
isLoadingMedia: boolean;
|
|
29
|
-
})[]) => Promise<
|
|
34
|
+
})[]) => Promise<Data>) | undefined;
|
|
30
35
|
children: React.ReactNode;
|
|
31
36
|
setMentionableUsers: (props: {
|
|
32
37
|
query: string;
|
|
@@ -2,6 +2,7 @@ import { PlaceholderOptions } from "@tiptap/extension-placeholder";
|
|
|
2
2
|
import { Editor as TipTapEditor } from "@tiptap/react";
|
|
3
3
|
import { ChatEditorArgs, SuggestedUser } from "./_types";
|
|
4
4
|
import { MediaType } from "./parts/comment";
|
|
5
|
+
import { Data } from "./context/chatContext";
|
|
5
6
|
interface EditorStoryArgs extends ChatEditorArgs {
|
|
6
7
|
children?: any;
|
|
7
8
|
comments?: {
|
|
@@ -17,7 +18,7 @@ interface EditorStoryArgs extends ChatEditorArgs {
|
|
|
17
18
|
editorText?: string;
|
|
18
19
|
background?: string;
|
|
19
20
|
onSave: (editor: TipTapEditor, mentions: SuggestedUser[]) => void;
|
|
20
|
-
onFileUpload?: (files: File[]) => Promise<
|
|
21
|
+
onFileUpload?: (files: File[]) => Promise<Data>;
|
|
21
22
|
placeholderOptions?: Partial<PlaceholderOptions>;
|
|
22
23
|
}
|
|
23
24
|
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, EditorStoryArgs>;
|