@appquality/unguess-design-system 3.1.86-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
|
@@ -2352,15 +2352,25 @@ const ChatContextProvider = ({ onSave, onFileUpload, setMentionableUsers, childr
|
|
|
2352
2352
|
//isMediaUploading, // Incluso nel valore del contesto
|
|
2353
2353
|
//setIsMediaUploading, // Incluso nel valore del contesto
|
|
2354
2354
|
addThumbnails: ({ files, }) => {
|
|
2355
|
-
|
|
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
|
+
}
|
|
2356
2368
|
/* const media = files.map((file) => ({
|
|
2357
2369
|
...file,
|
|
2358
2370
|
isLoadingMedia: false,
|
|
2359
2371
|
}));
|
|
2360
2372
|
media[0].isLoadingMedia = false;*/
|
|
2361
2373
|
//setIsMediaUploading(true);
|
|
2362
|
-
files.forEach((file) => (file.isLoadingMedia = true));
|
|
2363
|
-
setThumbnails((prev) => [...prev, ...files]);
|
|
2364
2374
|
//setIsMediaUploading(false);
|
|
2365
2375
|
},
|
|
2366
2376
|
removeThumbnail: (index) => setThumbnails(thumbnails.filter((_, i) => i !== index)),
|
|
@@ -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;
|
|
@@ -20,11 +20,18 @@ export type ChatContextType = {
|
|
|
20
20
|
afterUploadCallback: (failed: string[]) => void;
|
|
21
21
|
};
|
|
22
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
|
+
}
|
|
23
30
|
export declare const ChatContextProvider: ({ onSave, onFileUpload, setMentionableUsers, children, }: {
|
|
24
31
|
onSave?: ((editor: Editor, mentions: SuggestedUser[]) => void) | undefined;
|
|
25
32
|
onFileUpload?: ((files: (File & {
|
|
26
33
|
isLoadingMedia: boolean;
|
|
27
|
-
})[]) => Promise<
|
|
34
|
+
})[]) => Promise<Data>) | undefined;
|
|
28
35
|
children: React.ReactNode;
|
|
29
36
|
setMentionableUsers: (props: {
|
|
30
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>;
|