@appquality/unguess-design-system 3.1.105-attachments → 3.1.106-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/.vscode/settings.json +3 -0
- package/CHANGELOG.md +130 -0
- package/build/index.js +187 -266
- package/build/stories/buttons/button/index.stories.d.ts +0 -1
- package/build/stories/buttons/utils.d.ts +27 -27
- package/build/stories/chat/_types.d.ts +1 -1
- package/build/stories/chat/hooks/useMedia.d.ts +5 -0
- package/build/stories/chat/index.stories.d.ts +1 -3
- package/build/stories/chat/parts/MediaLightbox.d.ts +14 -0
- package/build/stories/chat/parts/ThumbnailContainer/Thumbnail.d.ts +11 -0
- package/build/stories/chat/parts/comment.d.ts +2 -7
- package/build/stories/dropdowns/select/index.stories.d.ts +0 -1
- package/build/stories/editor/index.stories.d.ts +0 -1
- package/build/stories/highlight/index.stories.d.ts +0 -1
- package/build/stories/player/index.stories.d.ts +0 -1
- package/package.json +1 -1
- package/build/stories/chat/parts/ThumbnailContainer/ImageThumbnail.d.ts +0 -11
- package/build/stories/chat/parts/ThumbnailContainer/VideoThumbnail.d.ts +0 -11
- package/yarn-error.log +0 -17994
package/build/index.js
CHANGED
|
@@ -25,9 +25,9 @@ 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');
|
|
29
28
|
var react = require('@tiptap/react');
|
|
30
29
|
var reactTooltips = require('@zendeskgarden/react-tooltips');
|
|
30
|
+
var uuid = require('uuid');
|
|
31
31
|
var Typography = require('@tiptap/extension-typography');
|
|
32
32
|
var Link = require('@tiptap/extension-link');
|
|
33
33
|
var StarterKit = require('@tiptap/starter-kit');
|
|
@@ -2351,7 +2351,6 @@ const ChatContextProvider = ({ onSave, onFileUpload, onDeleteThumbnail, setMenti
|
|
|
2351
2351
|
}));
|
|
2352
2352
|
},
|
|
2353
2353
|
addThumbnails: ({ files }) => {
|
|
2354
|
-
files.forEach((file) => (file.isLoadingMedia = true));
|
|
2355
2354
|
setThumbnails((prev) => [...prev, ...files]);
|
|
2356
2355
|
if (onFileUpload) {
|
|
2357
2356
|
onFileUpload(files).then((data) => {
|
|
@@ -2737,74 +2736,6 @@ const ChatTitle = styled__default["default"](Title$1) `
|
|
|
2737
2736
|
padding: ${({ theme }) => `${theme.space.sm} ${theme.space.md}`};
|
|
2738
2737
|
`;
|
|
2739
2738
|
|
|
2740
|
-
const UgClose$1 = styled__default["default"](reactNotifications.Close) `
|
|
2741
|
-
display: flex;
|
|
2742
|
-
align-items: center;
|
|
2743
|
-
justify-content: center;
|
|
2744
|
-
width: ${({ theme }) => theme.space.xl};
|
|
2745
|
-
height: ${({ theme }) => theme.space.xl};
|
|
2746
|
-
`;
|
|
2747
|
-
/**
|
|
2748
|
-
* Title is a basic component used to display a title. Often used in card headers.
|
|
2749
|
-
*/
|
|
2750
|
-
const Close = (props) => jsxRuntime.jsx(UgClose$1, Object.assign({}, props));
|
|
2751
|
-
|
|
2752
|
-
const NOTIFICATION_COMPONENT_ID = "notifications.notification";
|
|
2753
|
-
const CLOSE_COMPONENT_ID = "notifications.notification.close";
|
|
2754
|
-
const CLOSE_ICON_COMPONENT_ID = "notifications.notification.close-icon";
|
|
2755
|
-
const TITLE_COMPONENT_ID = "notifications.notification.title";
|
|
2756
|
-
const UgClose = styled__default["default"](Close).attrs((props) => {
|
|
2757
|
-
var _a;
|
|
2758
|
-
return ({
|
|
2759
|
-
"data-custom-id": (_a = props["data-custom-id"]) !== null && _a !== void 0 ? _a : CLOSE_ICON_COMPONENT_ID,
|
|
2760
|
-
});
|
|
2761
|
-
}) `
|
|
2762
|
-
${(props) => reactTheming.retrieveComponentStyles(CLOSE_ICON_COMPONENT_ID, props)};
|
|
2763
|
-
`;
|
|
2764
|
-
const UgAnchor = styled__default["default"](reactButtons.Anchor).attrs((props) => {
|
|
2765
|
-
var _a;
|
|
2766
|
-
return ({
|
|
2767
|
-
"data-custom-id": (_a = props["data-custom-id"]) !== null && _a !== void 0 ? _a : CLOSE_COMPONENT_ID,
|
|
2768
|
-
});
|
|
2769
|
-
}) `
|
|
2770
|
-
${(props) => reactTheming.retrieveComponentStyles(CLOSE_COMPONENT_ID, props)};
|
|
2771
|
-
`;
|
|
2772
|
-
const UgTitle = styled__default["default"](Title$1).attrs((props) => {
|
|
2773
|
-
var _a;
|
|
2774
|
-
return ({
|
|
2775
|
-
"data-custom-id": (_a = props["data-custom-id"]) !== null && _a !== void 0 ? _a : TITLE_COMPONENT_ID,
|
|
2776
|
-
});
|
|
2777
|
-
}) `
|
|
2778
|
-
${(props) => reactTheming.retrieveComponentStyles(TITLE_COMPONENT_ID, props)};
|
|
2779
|
-
`;
|
|
2780
|
-
const UgNotification = styled__default["default"](reactNotifications.Notification) `
|
|
2781
|
-
display: flex;
|
|
2782
|
-
align-items: center;
|
|
2783
|
-
justify-content: space-between;
|
|
2784
|
-
padding-right: ${({ theme }) => theme.space.md};
|
|
2785
|
-
white-space: pre;
|
|
2786
|
-
|
|
2787
|
-
${UgAnchor} {
|
|
2788
|
-
flex-shrink: 0;
|
|
2789
|
-
margin-left: ${({ theme }) => theme.space.md};
|
|
2790
|
-
}
|
|
2791
|
-
|
|
2792
|
-
${(props) => reactTheming.retrieveComponentStyles(NOTIFICATION_COMPONENT_ID, props)};
|
|
2793
|
-
`;
|
|
2794
|
-
/**
|
|
2795
|
-
* A Notification is a passive status update that keeps users informed of system progress.
|
|
2796
|
-
* <hr>
|
|
2797
|
-
* Used for this:
|
|
2798
|
-
- For a passive status update about user or system activity
|
|
2799
|
-
*/
|
|
2800
|
-
const Notification = (_a) => {
|
|
2801
|
-
var { closeText, message, onClose, type, isPrimary, isRegular } = _a, props = __rest(_a, ["closeText", "message", "onClose", "type", "isPrimary", "isRegular"]);
|
|
2802
|
-
return (jsxRuntime.jsxs(UgNotification, Object.assign({ type: type, isPrimary: isPrimary }, props, { children: [jsxRuntime.jsx(UgTitle, Object.assign({ isRegular: isRegular, type: type, isPrimary: isPrimary }, { children: message })), jsxRuntime.jsx(UgAnchor, Object.assign({ type: type, isPrimary: isPrimary, onClick: onClose }, { children: closeText !== null && closeText !== void 0 ? closeText : jsxRuntime.jsx(UgClose, {}) }))] })));
|
|
2803
|
-
};
|
|
2804
|
-
// ToastProvider
|
|
2805
|
-
const ToastProvider = (props) => (jsxRuntime.jsx(reactNotifications.ToastProvider, Object.assign({}, props)));
|
|
2806
|
-
const useToast = reactNotifications.useToast;
|
|
2807
|
-
|
|
2808
2739
|
var _path$w;
|
|
2809
2740
|
function _extends$E() { _extends$E = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$E.apply(this, arguments); }
|
|
2810
2741
|
const SvgBoldFill = props => /*#__PURE__*/React__namespace.createElement("svg", _extends$E({
|
|
@@ -3042,6 +2973,97 @@ const SvgClipboard = props => /*#__PURE__*/React__namespace.createElement("svg",
|
|
|
3042
2973
|
d: "M9.5 4v7.7c0 .8-.7 1.5-1.5 1.5s-1.5-.7-1.5-1.5V3C6.5 1.6 7.6.5 9 .5s2.5 1.1 2.5 2.5v9c0 1.9-1.6 3.5-3.5 3.5S4.5 13.9 4.5 12V4"
|
|
3043
2974
|
})));
|
|
3044
2975
|
|
|
2976
|
+
const UgClose$1 = styled__default["default"](reactNotifications.Close) `
|
|
2977
|
+
display: flex;
|
|
2978
|
+
align-items: center;
|
|
2979
|
+
justify-content: center;
|
|
2980
|
+
width: ${({ theme }) => theme.space.xl};
|
|
2981
|
+
height: ${({ theme }) => theme.space.xl};
|
|
2982
|
+
`;
|
|
2983
|
+
/**
|
|
2984
|
+
* Title is a basic component used to display a title. Often used in card headers.
|
|
2985
|
+
*/
|
|
2986
|
+
const Close = (props) => jsxRuntime.jsx(UgClose$1, Object.assign({}, props));
|
|
2987
|
+
|
|
2988
|
+
const NOTIFICATION_COMPONENT_ID = "notifications.notification";
|
|
2989
|
+
const CLOSE_COMPONENT_ID = "notifications.notification.close";
|
|
2990
|
+
const CLOSE_ICON_COMPONENT_ID = "notifications.notification.close-icon";
|
|
2991
|
+
const TITLE_COMPONENT_ID = "notifications.notification.title";
|
|
2992
|
+
const UgClose = styled__default["default"](Close).attrs((props) => {
|
|
2993
|
+
var _a;
|
|
2994
|
+
return ({
|
|
2995
|
+
"data-custom-id": (_a = props["data-custom-id"]) !== null && _a !== void 0 ? _a : CLOSE_ICON_COMPONENT_ID,
|
|
2996
|
+
});
|
|
2997
|
+
}) `
|
|
2998
|
+
${(props) => reactTheming.retrieveComponentStyles(CLOSE_ICON_COMPONENT_ID, props)};
|
|
2999
|
+
`;
|
|
3000
|
+
const UgAnchor = styled__default["default"](reactButtons.Anchor).attrs((props) => {
|
|
3001
|
+
var _a;
|
|
3002
|
+
return ({
|
|
3003
|
+
"data-custom-id": (_a = props["data-custom-id"]) !== null && _a !== void 0 ? _a : CLOSE_COMPONENT_ID,
|
|
3004
|
+
});
|
|
3005
|
+
}) `
|
|
3006
|
+
${(props) => reactTheming.retrieveComponentStyles(CLOSE_COMPONENT_ID, props)};
|
|
3007
|
+
`;
|
|
3008
|
+
const UgTitle = styled__default["default"](Title$1).attrs((props) => {
|
|
3009
|
+
var _a;
|
|
3010
|
+
return ({
|
|
3011
|
+
"data-custom-id": (_a = props["data-custom-id"]) !== null && _a !== void 0 ? _a : TITLE_COMPONENT_ID,
|
|
3012
|
+
});
|
|
3013
|
+
}) `
|
|
3014
|
+
${(props) => reactTheming.retrieveComponentStyles(TITLE_COMPONENT_ID, props)};
|
|
3015
|
+
`;
|
|
3016
|
+
const UgNotification = styled__default["default"](reactNotifications.Notification) `
|
|
3017
|
+
display: flex;
|
|
3018
|
+
align-items: center;
|
|
3019
|
+
justify-content: space-between;
|
|
3020
|
+
padding-right: ${({ theme }) => theme.space.md};
|
|
3021
|
+
white-space: pre;
|
|
3022
|
+
|
|
3023
|
+
${UgAnchor} {
|
|
3024
|
+
flex-shrink: 0;
|
|
3025
|
+
margin-left: ${({ theme }) => theme.space.md};
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
${(props) => reactTheming.retrieveComponentStyles(NOTIFICATION_COMPONENT_ID, props)};
|
|
3029
|
+
`;
|
|
3030
|
+
/**
|
|
3031
|
+
* A Notification is a passive status update that keeps users informed of system progress.
|
|
3032
|
+
* <hr>
|
|
3033
|
+
* Used for this:
|
|
3034
|
+
- For a passive status update about user or system activity
|
|
3035
|
+
*/
|
|
3036
|
+
const Notification = (_a) => {
|
|
3037
|
+
var { closeText, message, onClose, type, isPrimary, isRegular } = _a, props = __rest(_a, ["closeText", "message", "onClose", "type", "isPrimary", "isRegular"]);
|
|
3038
|
+
return (jsxRuntime.jsxs(UgNotification, Object.assign({ type: type, isPrimary: isPrimary }, props, { children: [jsxRuntime.jsx(UgTitle, Object.assign({ isRegular: isRegular, type: type, isPrimary: isPrimary }, { children: message })), jsxRuntime.jsx(UgAnchor, Object.assign({ type: type, isPrimary: isPrimary, onClick: onClose }, { children: closeText !== null && closeText !== void 0 ? closeText : jsxRuntime.jsx(UgClose, {}) }))] })));
|
|
3039
|
+
};
|
|
3040
|
+
// ToastProvider
|
|
3041
|
+
const ToastProvider = (props) => (jsxRuntime.jsx(reactNotifications.ToastProvider, Object.assign({}, props)));
|
|
3042
|
+
const useToast = reactNotifications.useToast;
|
|
3043
|
+
|
|
3044
|
+
const acceptedMediaTypes = /^(image|video)\//;
|
|
3045
|
+
function useMedia() {
|
|
3046
|
+
const { addToast } = useToast();
|
|
3047
|
+
function getValidMedia(data) {
|
|
3048
|
+
const wrongFiles = Array.from(data).filter((file) => !acceptedMediaTypes.test(file.type));
|
|
3049
|
+
if (wrongFiles.length) {
|
|
3050
|
+
addToast(({ close }) => (jsxRuntime.jsx(Notification, { onClose: close, type: "error", message: wrongFiles.length === 1
|
|
3051
|
+
? `${wrongFiles[0].name} not supported, please upload video or image only`
|
|
3052
|
+
: "Some attachments are not supported, please upload video or image only", isPrimary: true })), { placement: "top" });
|
|
3053
|
+
}
|
|
3054
|
+
return Array.from(data).filter((file) => acceptedMediaTypes.test(file.type));
|
|
3055
|
+
}
|
|
3056
|
+
function getMedia(data) {
|
|
3057
|
+
return getValidMedia(data).map((file) => {
|
|
3058
|
+
return Object.assign(file, {
|
|
3059
|
+
isLoadingMedia: true,
|
|
3060
|
+
internal_id: uuid.v4(),
|
|
3061
|
+
});
|
|
3062
|
+
});
|
|
3063
|
+
}
|
|
3064
|
+
return { getMedia };
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3045
3067
|
const MenuContainer = styled__default["default"].div `
|
|
3046
3068
|
padding: ${({ theme }) => theme.space.xs} 0;
|
|
3047
3069
|
display: flex;
|
|
@@ -3059,59 +3081,33 @@ const VerticalDivider = styled__default["default"].div `
|
|
|
3059
3081
|
const CommentBar = ({ editor, i18n, }) => {
|
|
3060
3082
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3061
3083
|
const { addThumbnails } = useChatContext();
|
|
3084
|
+
const { getMedia } = useMedia();
|
|
3062
3085
|
if (!editor)
|
|
3063
3086
|
return null;
|
|
3064
|
-
const
|
|
3065
|
-
|
|
3066
|
-
case "bold":
|
|
3067
|
-
return jsxRuntime.jsx(SvgBoldStroke, {});
|
|
3068
|
-
case "italic":
|
|
3069
|
-
return jsxRuntime.jsx(SvgItalicStroke, {});
|
|
3070
|
-
case "mention":
|
|
3071
|
-
return jsxRuntime.jsx(SvgAtStroke, {});
|
|
3072
|
-
case "attachment":
|
|
3073
|
-
return jsxRuntime.jsx(SvgClipboard, {});
|
|
3074
|
-
default:
|
|
3075
|
-
return null;
|
|
3076
|
-
}
|
|
3087
|
+
const handleBoldClick = () => {
|
|
3088
|
+
editor.chain().focus().toggleBold().run();
|
|
3077
3089
|
};
|
|
3078
|
-
const
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
const { from } = editor.state.selection;
|
|
3086
|
-
const char = from > 1 ? " @" : "@";
|
|
3087
|
-
return editor.chain().focus().insertContent(char).run();
|
|
3088
|
-
case "attachment":
|
|
3089
|
-
//open a file browser to select one or more images
|
|
3090
|
-
const fileInput = document.createElement("input");
|
|
3091
|
-
fileInput.type = "file";
|
|
3092
|
-
fileInput.accept = "image/*,video/*";
|
|
3093
|
-
fileInput.multiple = true;
|
|
3094
|
-
fileInput.click();
|
|
3095
|
-
fileInput.onchange = () => {
|
|
3096
|
-
const files = fileInput.files;
|
|
3097
|
-
if (files) {
|
|
3098
|
-
const mediaFiles = Array.from(files).map((file) => {
|
|
3099
|
-
return Object.assign(file, {
|
|
3100
|
-
isLoadingMedia: false,
|
|
3101
|
-
internal_id: uuid.v4(),
|
|
3102
|
-
});
|
|
3103
|
-
});
|
|
3104
|
-
if (mediaFiles.length === 0)
|
|
3105
|
-
return;
|
|
3106
|
-
addThumbnails({ files: mediaFiles });
|
|
3107
|
-
}
|
|
3108
|
-
};
|
|
3109
|
-
return;
|
|
3110
|
-
default:
|
|
3111
|
-
return;
|
|
3112
|
-
}
|
|
3090
|
+
const handleItalicClick = () => {
|
|
3091
|
+
editor.chain().focus().toggleItalic().run();
|
|
3092
|
+
};
|
|
3093
|
+
const handleMentionClick = () => {
|
|
3094
|
+
const { from } = editor.state.selection;
|
|
3095
|
+
const char = from > 1 ? " @" : "@";
|
|
3096
|
+
editor.chain().focus().insertContent(char).run();
|
|
3113
3097
|
};
|
|
3114
|
-
|
|
3098
|
+
const handleAttachmentClick = () => {
|
|
3099
|
+
const fileInput = document.createElement("input");
|
|
3100
|
+
fileInput.type = "file";
|
|
3101
|
+
fileInput.accept = "image/*,video/*";
|
|
3102
|
+
fileInput.multiple = true;
|
|
3103
|
+
fileInput.click();
|
|
3104
|
+
fileInput.onchange = () => {
|
|
3105
|
+
if (fileInput.files) {
|
|
3106
|
+
addThumbnails({ files: getMedia(fileInput.files) });
|
|
3107
|
+
}
|
|
3108
|
+
};
|
|
3109
|
+
};
|
|
3110
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(MenuContainer, Object.assign({ id: "menu-container" }, { children: [jsxRuntime.jsx(Tooltip, Object.assign({ content: `${(_b = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _a === void 0 ? void 0 : _a.bold) !== null && _b !== void 0 ? _b : "Bold text"} ${isMac() ? "Cmd" : "Ctrl"} + B`, placement: "top", type: "light", size: "small", hasArrow: false }, { children: jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !editor.isActive("bold"), isPrimary: editor.isActive("bold"), isPill: false, onClick: handleBoldClick }, { children: jsxRuntime.jsx(SvgBoldStroke, {}) })) })), jsxRuntime.jsx(Tooltip, Object.assign({ content: `${(_d = (_c = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _c === void 0 ? void 0 : _c.italic) !== null && _d !== void 0 ? _d : "Italic text"} ${isMac() ? "Cmd" : "Ctrl"} + I`, placement: "top", type: "light", size: "small", hasArrow: false }, { children: jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !editor.isActive("italic"), isPrimary: editor.isActive("italic"), isPill: false, onClick: handleItalicClick }, { children: jsxRuntime.jsx(SvgItalicStroke, {}) })) })), jsxRuntime.jsx(VerticalDivider, {}), jsxRuntime.jsx(Tooltip, Object.assign({ content: (_f = (_e = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _e === void 0 ? void 0 : _e.mention) !== null && _f !== void 0 ? _f : "Add a mention", placement: "top", type: "light", size: "small", hasArrow: false }, { children: jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !editor.isActive("mention"), isPrimary: editor.isActive("mention"), isPill: false, onClick: handleMentionClick }, { children: jsxRuntime.jsx(SvgAtStroke, {}) })) })), jsxRuntime.jsx(Tooltip, Object.assign({ content: (_h = (_g = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _g === void 0 ? void 0 : _g.attachment) !== null && _h !== void 0 ? _h : "Upload images and video. Max size: 5GB", placement: "top", type: "light", size: "small", hasArrow: true }, { children: jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !editor.isActive("attachment"), isPrimary: editor.isActive("attachment"), isPill: false, onClick: handleAttachmentClick }, { children: jsxRuntime.jsx(SvgClipboard, {}) })) }))] })) }));
|
|
3115
3111
|
};
|
|
3116
3112
|
|
|
3117
3113
|
const CustomMention = Mention__default["default"].extend({
|
|
@@ -3392,45 +3388,13 @@ const StyledDeleteThumbnailX = styled__default["default"].div `
|
|
|
3392
3388
|
width: 32px;
|
|
3393
3389
|
height: 32px;
|
|
3394
3390
|
opacity: 0;
|
|
3391
|
+
transition: opacity 0.2s;
|
|
3395
3392
|
z-index: 2;
|
|
3396
3393
|
`;
|
|
3397
3394
|
const DeleteThumbnailX = ({ deleteThumbnail }) => {
|
|
3398
3395
|
return (jsxRuntime.jsx(StyledDeleteThumbnailX, Object.assign({ className: "deleteThumbnail" }, { children: jsxRuntime.jsx(SvgRemoveMediaIcon, { onClick: (e) => deleteThumbnail(e) }) })));
|
|
3399
3396
|
};
|
|
3400
3397
|
|
|
3401
|
-
const ImageCard = styled__default["default"](SpecialCard) `
|
|
3402
|
-
padding: 0;
|
|
3403
|
-
:hover .deleteThumbnail {
|
|
3404
|
-
opacity: 1;
|
|
3405
|
-
}
|
|
3406
|
-
`;
|
|
3407
|
-
const Preview$1 = styled__default["default"].div `
|
|
3408
|
-
display: flex;
|
|
3409
|
-
justify-content: center;
|
|
3410
|
-
align-items: center;
|
|
3411
|
-
height: 150px;
|
|
3412
|
-
width: 100%;
|
|
3413
|
-
background-image: url(${(props) => props.url});
|
|
3414
|
-
background-color: ${({ theme }) => theme.palette.grey[100]};
|
|
3415
|
-
background-size: contain;
|
|
3416
|
-
background-position: center;
|
|
3417
|
-
background-repeat: no-repeat;
|
|
3418
|
-
`;
|
|
3419
|
-
const ImageThumbnail = ({ src, index = 0, removeThumbnail, clickThumbnail, showX = true, isLoadingMedia = true, isError = false, }) => {
|
|
3420
|
-
const handleCancel = (e) => {
|
|
3421
|
-
e.stopPropagation();
|
|
3422
|
-
if (removeThumbnail)
|
|
3423
|
-
removeThumbnail(index);
|
|
3424
|
-
};
|
|
3425
|
-
return (jsxRuntime.jsxs(ImageCard, Object.assign({ onClick: clickThumbnail }, { children: [isLoadingMedia && (jsxRuntime.jsx(Preview$1, Object.assign({ url: "" }, { children: jsxRuntime.jsx(reactLoaders.Spinner, { style: {
|
|
3426
|
-
display: "flex",
|
|
3427
|
-
alignItems: "center",
|
|
3428
|
-
justifyContent: "center",
|
|
3429
|
-
}, size: "large" }) }))), isError && (
|
|
3430
|
-
// todo: add error icon
|
|
3431
|
-
jsxRuntime.jsx("span", { children: "error uploading media" })), !isLoadingMedia && (jsxRuntime.jsx(Preview$1, Object.assign({ url: src }, { children: showX && (jsxRuntime.jsx(DeleteThumbnailX, { deleteThumbnail: (e) => handleCancel(e) })) })))] })));
|
|
3432
|
-
};
|
|
3433
|
-
|
|
3434
3398
|
var _circle$2, _path$o;
|
|
3435
3399
|
function _extends$t() { _extends$t = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$t.apply(this, arguments); }
|
|
3436
3400
|
const SvgVideoPlayIcon = props => /*#__PURE__*/React__namespace.createElement("svg", _extends$t({
|
|
@@ -3449,16 +3413,11 @@ const SvgVideoPlayIcon = props => /*#__PURE__*/React__namespace.createElement("s
|
|
|
3449
3413
|
fill: "currentColor"
|
|
3450
3414
|
})));
|
|
3451
3415
|
|
|
3452
|
-
const
|
|
3416
|
+
const ImageCard = styled__default["default"](SpecialCard) `
|
|
3453
3417
|
padding: 0;
|
|
3454
3418
|
position: relative;
|
|
3455
3419
|
overflow: hidden;
|
|
3456
|
-
|
|
3457
|
-
&:hover .deleteThumbnail {
|
|
3458
|
-
opacity: 1;
|
|
3459
|
-
z-index: 9999;
|
|
3460
|
-
}
|
|
3461
|
-
|
|
3420
|
+
|
|
3462
3421
|
&:before {
|
|
3463
3422
|
content: "";
|
|
3464
3423
|
position: absolute;
|
|
@@ -3467,46 +3426,66 @@ const VideoCard = styled__default["default"](SpecialCard) `
|
|
|
3467
3426
|
width: 100%;
|
|
3468
3427
|
height: 100%;
|
|
3469
3428
|
background-color: ${({ theme }) => theme.palette.grey[800]};
|
|
3470
|
-
opacity: 0
|
|
3429
|
+
opacity: 0;
|
|
3430
|
+
transition: opacity 0.2s;
|
|
3471
3431
|
z-index: 1;
|
|
3472
3432
|
}
|
|
3473
3433
|
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3434
|
+
&:hover {
|
|
3435
|
+
.deleteThumbnail {
|
|
3436
|
+
opacity: 1;
|
|
3437
|
+
}
|
|
3438
|
+
&:before {
|
|
3439
|
+
opacity: 0.3;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
|
|
3443
|
+
&.video{
|
|
3444
|
+
|
|
3445
|
+
svg {
|
|
3446
|
+
position: absolute;
|
|
3447
|
+
top: 50%;
|
|
3448
|
+
left: 50%;
|
|
3449
|
+
transform: translate(-50%, -50%);
|
|
3450
|
+
width: 32px;
|
|
3451
|
+
height: 32px;
|
|
3452
|
+
z-index: 2;
|
|
3453
|
+
}
|
|
3482
3454
|
}
|
|
3483
3455
|
`;
|
|
3484
3456
|
const Preview = styled__default["default"].div `
|
|
3485
|
-
padding: ${({ theme }) => theme.space.md};
|
|
3486
3457
|
display: flex;
|
|
3487
3458
|
justify-content: center;
|
|
3488
3459
|
align-items: center;
|
|
3489
3460
|
height: 150px;
|
|
3490
3461
|
width: 100%;
|
|
3491
3462
|
|
|
3463
|
+
${p => p.url && `
|
|
3464
|
+
background-image: url(${p.url});
|
|
3465
|
+
background-color: ${p.theme.palette.grey[100]};
|
|
3466
|
+
background-size: contain;
|
|
3467
|
+
background-position: center;
|
|
3468
|
+
background-repeat: no-repeat;
|
|
3469
|
+
`}
|
|
3470
|
+
|
|
3492
3471
|
> video {
|
|
3493
3472
|
width: 100%;
|
|
3494
3473
|
height: 100%;
|
|
3495
3474
|
}
|
|
3496
3475
|
`;
|
|
3497
|
-
const
|
|
3476
|
+
const Thumbnail = ({ src, type, removeThumbnail, clickThumbnail, showX, isLoadingMedia = true, isError = false, }) => {
|
|
3498
3477
|
const handleCancel = (e) => {
|
|
3499
3478
|
e.stopPropagation();
|
|
3500
3479
|
if (removeThumbnail)
|
|
3501
|
-
removeThumbnail(
|
|
3480
|
+
removeThumbnail();
|
|
3502
3481
|
};
|
|
3503
|
-
return (jsxRuntime.jsxs(
|
|
3482
|
+
return (jsxRuntime.jsxs(ImageCard, Object.assign({ onClick: clickThumbnail, className: type.includes('video') ? 'video' : 'image' }, { children: [isError && (
|
|
3483
|
+
// todo: add error icon
|
|
3484
|
+
jsxRuntime.jsx("span", { children: "error uploading media" })), isLoadingMedia ? (jsxRuntime.jsx(Preview, { children: jsxRuntime.jsx(reactLoaders.Spinner, { style: {
|
|
3504
3485
|
display: "flex",
|
|
3505
3486
|
alignItems: "center",
|
|
3506
3487
|
justifyContent: "center",
|
|
3507
|
-
}, size: "large" }) })),
|
|
3508
|
-
// todo: add error icon
|
|
3509
|
-
jsxRuntime.jsx("span", { children: "error uploading media" })), !isLoadingMedia && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showX && (jsxRuntime.jsx(DeleteThumbnailX, { deleteThumbnail: (e) => handleCancel(e) })), jsxRuntime.jsx(Preview, { children: jsxRuntime.jsx("video", Object.assign({ src: src }, { children: jsxRuntime.jsx("track", { kind: "captions" }) })) }), jsxRuntime.jsx(SvgVideoPlayIcon, {})] }))] })));
|
|
3488
|
+
}, size: "large" }) })) : (jsxRuntime.jsxs(Preview, Object.assign({ url: src }, { children: [showX && (jsxRuntime.jsx(DeleteThumbnailX, { deleteThumbnail: (e) => handleCancel(e) })), type.includes('video') && jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("video", Object.assign({ src: src }, { children: jsxRuntime.jsx("track", { kind: "captions" }) })), jsxRuntime.jsx(SvgVideoPlayIcon, {})] })] })))] })));
|
|
3510
3489
|
};
|
|
3511
3490
|
|
|
3512
3491
|
const UgGrid = styled__default["default"](reactGrid.Grid) `
|
|
@@ -3546,24 +3525,12 @@ const ThumbnailContainer = ({ openLightbox }) => {
|
|
|
3546
3525
|
if (!mediaFiles || mediaFiles.length === 0) {
|
|
3547
3526
|
return null;
|
|
3548
3527
|
}
|
|
3549
|
-
return (jsxRuntime.jsx(Grid, { children: jsxRuntime.jsx(Row$1, Object.assign({ className: "responsive-container" }, { children: mediaFiles.map((file, index) => {
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
}, clickThumbnail: () => {
|
|
3556
|
-
openLightbox(thumbnails[index], index);
|
|
3557
|
-
} }, index) })));
|
|
3558
|
-
if (file.fileType.includes("video"))
|
|
3559
|
-
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.isLoadingMedia, removeThumbnail: () => {
|
|
3560
|
-
removeThumbnail(index);
|
|
3561
|
-
onDeleteThumbnail(file.internal_id);
|
|
3562
|
-
}, clickThumbnail: () => {
|
|
3563
|
-
openLightbox(thumbnails[index], index);
|
|
3564
|
-
} }, index) })));
|
|
3565
|
-
return null;
|
|
3566
|
-
}) })) }));
|
|
3528
|
+
return (jsxRuntime.jsx(Grid, { children: jsxRuntime.jsx(Row$1, Object.assign({ className: "responsive-container" }, { children: mediaFiles.map((file, index) => (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 3, className: "flex-3-sm" }, { children: jsxRuntime.jsx(Thumbnail, { src: file.previewUrl, showX: true, type: file.fileType, isLoadingMedia: file.isLoadingMedia, removeThumbnail: () => {
|
|
3529
|
+
removeThumbnail(index);
|
|
3530
|
+
onDeleteThumbnail(file.internal_id);
|
|
3531
|
+
}, clickThumbnail: () => {
|
|
3532
|
+
openLightbox(thumbnails[index], index);
|
|
3533
|
+
} }, file.internal_id) })))) })) }));
|
|
3567
3534
|
};
|
|
3568
3535
|
|
|
3569
3536
|
const UgModalBody = styled__default["default"](reactModals.Body) `
|
|
@@ -4722,11 +4689,7 @@ const VideoSpinner = () => (jsxRuntime.jsx(StyledDiv, { children: jsxRuntime.jsx
|
|
|
4722
4689
|
* Used for this:
|
|
4723
4690
|
- To display a video
|
|
4724
4691
|
*/
|
|
4725
|
-
const Player = React.forwardRef((props, forwardRef) => {
|
|
4726
|
-
const videoRef = React.useRef(null);
|
|
4727
|
-
React.useImperativeHandle(forwardRef, () => videoRef.current);
|
|
4728
|
-
return (jsxRuntime.jsx(Video__default["default"], Object.assign({ src: props.url }, props, { children: jsxRuntime.jsx(PlayerCore, Object.assign({ ref: videoRef }, props)) })));
|
|
4729
|
-
});
|
|
4692
|
+
const Player = React.forwardRef((props, forwardRef) => (jsxRuntime.jsx(Video__default["default"], Object.assign({ src: props.url }, props, { children: jsxRuntime.jsx(PlayerCore, Object.assign({ ref: forwardRef }, props)) }))));
|
|
4730
4693
|
const PlayerCore = React.forwardRef((props, forwardRef) => {
|
|
4731
4694
|
var _a;
|
|
4732
4695
|
const { context, togglePlay, setIsPlaying } = Video.useVideoContext();
|
|
@@ -4734,7 +4697,7 @@ const PlayerCore = React.forwardRef((props, forwardRef) => {
|
|
|
4734
4697
|
const videoRef = (_a = context.player) === null || _a === void 0 ? void 0 : _a.ref.current;
|
|
4735
4698
|
const isLoaded = !!videoRef;
|
|
4736
4699
|
const containerRef = React.useRef(null);
|
|
4737
|
-
React.useImperativeHandle(forwardRef, () => videoRef);
|
|
4700
|
+
React.useImperativeHandle(forwardRef, () => videoRef, [videoRef]);
|
|
4738
4701
|
React.useEffect(() => {
|
|
4739
4702
|
if (videoRef) {
|
|
4740
4703
|
videoRef.addEventListener("pause", () => {
|
|
@@ -4752,6 +4715,15 @@ const PlayerCore = React.forwardRef((props, forwardRef) => {
|
|
|
4752
4715
|
return (jsxRuntime.jsxs(Container$1, Object.assign({ isLoaded: isLoaded, isPlaying: context.isPlaying, ref: containerRef }, { children: [!isLoaded ? (jsxRuntime.jsx(VideoSpinner, {})) : (jsxRuntime.jsx(FloatingControls, { isPlaying: context.isPlaying, onClick: togglePlay })), jsxRuntime.jsx(Video__default["default"].Player, { className: "player-container" }), jsxRuntime.jsx(ProgressContextProvider, { children: jsxRuntime.jsx(Controls, { container: containerRef.current, onCutHandler: onCutHandler, bookmarks: bookmarks, isCutting: isCutting, onBookMarkUpdated: props.handleBookmarkUpdate, i18n: props.i18n }) })] })));
|
|
4753
4716
|
});
|
|
4754
4717
|
|
|
4718
|
+
const MediaLightBox = ({ header, onClose, slideChange, selectedImageIndex, thumbnails, videoRefs, isOpen, details }) => {
|
|
4719
|
+
if (!isOpen) {
|
|
4720
|
+
return null;
|
|
4721
|
+
}
|
|
4722
|
+
return (jsxRuntime.jsxs(Lightbox, Object.assign({ onClose: onClose }, { children: [jsxRuntime.jsx(Lightbox.Header, { children: header }), jsxRuntime.jsxs(Lightbox.Body, { children: [jsxRuntime.jsx(Lightbox.Body.Main, Object.assign({ style: { flex: details ? 2 : 3 } }, { children: jsxRuntime.jsx(Slider, Object.assign({ prevArrow: jsxRuntime.jsx(Slider.PrevButton, { isBright: true }), nextArrow: jsxRuntime.jsx(Slider.NextButton, { isBright: true }), onSlideChange: slideChange, initialSlide: selectedImageIndex }, { children: thumbnails.map((item) => (jsxRuntime.jsxs(Slider.Slide, { children: [item.type.includes("image") && (jsxRuntime.jsx("img", { src: item.url || URL.createObjectURL(item), alt: `media ${item.name}`, style: { maxHeight: "100%", height: "auto" } })), item.type.includes("video") && (jsxRuntime.jsx(Player, { ref: (ref) => {
|
|
4723
|
+
videoRefs.current.push(ref);
|
|
4724
|
+
}, url: item.url || URL.createObjectURL(item) }))] }, item.internal_id))) })) })), details && (jsxRuntime.jsx(Lightbox.Body.Details, Object.assign({ style: { flex: 1 } }, { children: details })))] }), jsxRuntime.jsx(Lightbox.Close, { "aria-label": "Close modal" })] })));
|
|
4725
|
+
};
|
|
4726
|
+
|
|
4755
4727
|
const ChatBoxContainer = styled__default["default"].div `
|
|
4756
4728
|
display: flex;
|
|
4757
4729
|
border-top: 1px solid ${({ theme }) => theme.palette.grey[200]};
|
|
@@ -4771,14 +4743,19 @@ const ChatBoxContainer = styled__default["default"].div `
|
|
|
4771
4743
|
- Simple text input, use textarea instead.
|
|
4772
4744
|
*/
|
|
4773
4745
|
const CommentBox = (_a) => {
|
|
4746
|
+
var _b;
|
|
4774
4747
|
var { placeholderOptions } = _a, props = __rest(_a, ["placeholderOptions"]);
|
|
4775
4748
|
const { children, hasFloatingMenu, hasButtonsMenu, bubbleOptions, i18n } = props;
|
|
4776
4749
|
const { editor, setEditor, mentionableUsers, triggerSave, thumbnails, addThumbnails, } = useChatContext();
|
|
4777
|
-
const { addToast } = useToast();
|
|
4778
4750
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
4779
|
-
const [selectedImage, setSelectedImage] = React.useState({});
|
|
4780
4751
|
const [selectedImageIndex, setSelectedImageIndex] = React.useState(0);
|
|
4752
|
+
const { getMedia } = useMedia();
|
|
4781
4753
|
const ext = editorExtensions({ placeholderOptions, mentionableUsers });
|
|
4754
|
+
function handleEvent(data) {
|
|
4755
|
+
if (!data || !data.files)
|
|
4756
|
+
return;
|
|
4757
|
+
addThumbnails({ files: getMedia(data.files) });
|
|
4758
|
+
}
|
|
4782
4759
|
const closeLightbox = () => {
|
|
4783
4760
|
setIsOpen(false);
|
|
4784
4761
|
};
|
|
@@ -4794,7 +4771,6 @@ const CommentBox = (_a) => {
|
|
|
4794
4771
|
const handleOpenLightbox = (file, index) => {
|
|
4795
4772
|
if (!file)
|
|
4796
4773
|
throw Error("Error with the image");
|
|
4797
|
-
setSelectedImage(file);
|
|
4798
4774
|
setSelectedImageIndex(index);
|
|
4799
4775
|
setIsOpen(true);
|
|
4800
4776
|
};
|
|
@@ -4806,48 +4782,12 @@ const CommentBox = (_a) => {
|
|
|
4806
4782
|
return false;
|
|
4807
4783
|
},
|
|
4808
4784
|
handleDrop: function (view, event, slice, moved) {
|
|
4809
|
-
if (!event.dataTransfer || !event.dataTransfer.files)
|
|
4810
|
-
return false;
|
|
4811
4785
|
event.preventDefault();
|
|
4812
|
-
|
|
4813
|
-
return Object.assign(file, {
|
|
4814
|
-
isLoadingMedia: false,
|
|
4815
|
-
internal_id: uuid.v4(),
|
|
4816
|
-
});
|
|
4817
|
-
});
|
|
4818
|
-
const wrongFiles = files.filter((file) => !/^(image|video)\//.test(file.type));
|
|
4819
|
-
if (wrongFiles.length > 0) {
|
|
4820
|
-
for (const file of wrongFiles) {
|
|
4821
|
-
addToast(({ close }) => (jsxRuntime.jsx(Notification, { onClose: close, type: "error", message: `${props.messageBadFileFormat} - ${file.name}`, isPrimary: true })), { placement: "top" });
|
|
4822
|
-
}
|
|
4823
|
-
}
|
|
4824
|
-
const mediaFiles = files.filter((file) => /^(image|video)\//.test(file.type));
|
|
4825
|
-
if (mediaFiles.length === 0)
|
|
4826
|
-
return false;
|
|
4827
|
-
addThumbnails({ files: mediaFiles });
|
|
4828
|
-
return false;
|
|
4786
|
+
handleEvent(event.dataTransfer);
|
|
4829
4787
|
},
|
|
4830
4788
|
handlePaste: (view, event, slice) => {
|
|
4831
|
-
if (!event.clipboardData || !event.clipboardData.items)
|
|
4832
|
-
return false;
|
|
4833
4789
|
event.preventDefault();
|
|
4834
|
-
|
|
4835
|
-
return Object.assign(file, {
|
|
4836
|
-
isLoadingMedia: false,
|
|
4837
|
-
internal_id: uuid.v4(),
|
|
4838
|
-
});
|
|
4839
|
-
});
|
|
4840
|
-
const wrongFiles = files.filter((file) => !/^(image|video)\//.test(file.type));
|
|
4841
|
-
if (wrongFiles.length > 0) {
|
|
4842
|
-
for (const file of wrongFiles) {
|
|
4843
|
-
addToast(({ close }) => (jsxRuntime.jsx(Notification, { onClose: close, type: "error", message: `${props.messageBadFileFormat} - ${file.name}`, isPrimary: true })), { placement: "top" });
|
|
4844
|
-
}
|
|
4845
|
-
}
|
|
4846
|
-
const mediaFiles = files.filter((file) => /^(image|video)\//.test(file.type));
|
|
4847
|
-
if (mediaFiles.length === 0)
|
|
4848
|
-
return false;
|
|
4849
|
-
addThumbnails({ files: mediaFiles });
|
|
4850
|
-
return false;
|
|
4790
|
+
handleEvent(event.clipboardData);
|
|
4851
4791
|
},
|
|
4852
4792
|
} }, props));
|
|
4853
4793
|
const onKeyDown = (event) => {
|
|
@@ -4860,12 +4800,7 @@ const CommentBox = (_a) => {
|
|
|
4860
4800
|
return null;
|
|
4861
4801
|
ed.on("create", ({ editor }) => setEditor(editor));
|
|
4862
4802
|
ed.on("update", ({ editor }) => setEditor(editor));
|
|
4863
|
-
|
|
4864
|
-
return Object.assign(file, { isLoadingMedia: file.isLoadingMedia });
|
|
4865
|
-
});
|
|
4866
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isOpen && selectedImage && (jsxRuntime.jsxs(Lightbox, Object.assign({ onClose: closeLightbox }, { children: [jsxRuntime.jsx(Lightbox.Header, { children: selectedImage.name }), jsxRuntime.jsx(Lightbox.Body, { children: jsxRuntime.jsx(Lightbox.Body.Main, Object.assign({ style: { flex: 3 } }, { children: jsxRuntime.jsx(Slider, Object.assign({ prevArrow: jsxRuntime.jsx(Slider.PrevButton, { isBright: true }), nextArrow: jsxRuntime.jsx(Slider.NextButton, { isBright: true }), onSlideChange: slideChange, initialSlide: selectedImageIndex }, { children: mediaFiles.map((item, index) => (jsxRuntime.jsxs(Slider.Slide, { children: [item.type.includes("image") && (jsxRuntime.jsx("img", { src: URL.createObjectURL(item), alt: `media ${item.name}` })), item.type.includes("video") && (jsxRuntime.jsx(Player, { ref: (ref) => {
|
|
4867
|
-
videoRefs.current.push(ref);
|
|
4868
|
-
}, url: URL.createObjectURL(item) }))] }))) })) })) }), jsxRuntime.jsx(Lightbox.Close, { "aria-label": "Close modal" })] }))), jsxRuntime.jsx(ChatBoxContainer, { children: jsxRuntime.jsxs(EditorContainer$1, Object.assign({ editable: true, style: { marginLeft: 0, paddingBottom: 12 } }, { children: [hasFloatingMenu && (jsxRuntime.jsx(FloatingMenu, { editor: ed, tippyOptions: Object.assign({}, bubbleOptions) })), jsxRuntime.jsx(react.EditorContent, { editor: ed, onKeyDown: onKeyDown }), jsxRuntime.jsx(ThumbnailContainer, { openLightbox: handleOpenLightbox })] })) }), hasButtonsMenu && jsxRuntime.jsx(CommentBar, { editor: ed, i18n: i18n })] }));
|
|
4803
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MediaLightBox, { isOpen: isOpen, header: (_b = thumbnails[selectedImageIndex]) === null || _b === void 0 ? void 0 : _b.name, onClose: closeLightbox, slideChange: slideChange, selectedImageIndex: selectedImageIndex, thumbnails: thumbnails, videoRefs: videoRefs }), jsxRuntime.jsx(ChatBoxContainer, { children: jsxRuntime.jsxs(EditorContainer$1, Object.assign({ editable: true, style: { marginLeft: 0, paddingBottom: 12 } }, { children: [hasFloatingMenu && (jsxRuntime.jsx(FloatingMenu, { editor: ed, tippyOptions: Object.assign({}, bubbleOptions) })), jsxRuntime.jsx(react.EditorContent, { editor: ed, onKeyDown: onKeyDown }), jsxRuntime.jsx(ThumbnailContainer, { openLightbox: handleOpenLightbox })] })) }), hasButtonsMenu && jsxRuntime.jsx(CommentBar, { editor: ed, i18n: i18n })] }));
|
|
4869
4804
|
};
|
|
4870
4805
|
|
|
4871
4806
|
const CommentCard = styled.styled(Card) `
|
|
@@ -4911,13 +4846,11 @@ const Comment = ({ author, message, children, date, media = [], header, }) => {
|
|
|
4911
4846
|
var _a, _b;
|
|
4912
4847
|
const { mentionableUsers } = useChatContext();
|
|
4913
4848
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
4914
|
-
const [selectedImage, setSelectedImage] = React.useState({});
|
|
4915
4849
|
const [selectedImageIndex, setSelectedImageIndex] = React.useState(0);
|
|
4916
4850
|
const ext = editorExtensions({ mentionableUsers });
|
|
4917
4851
|
const handleClickThumbnail = (file, index) => {
|
|
4918
4852
|
if (!file)
|
|
4919
4853
|
throw Error("Error with the image");
|
|
4920
|
-
setSelectedImage(file);
|
|
4921
4854
|
setSelectedImageIndex(index);
|
|
4922
4855
|
setIsOpen(true);
|
|
4923
4856
|
};
|
|
@@ -4926,7 +4859,6 @@ const Comment = ({ author, message, children, date, media = [], header, }) => {
|
|
|
4926
4859
|
};
|
|
4927
4860
|
const videoRefs = React.useRef([]);
|
|
4928
4861
|
const slideChange = React.useCallback((index) => {
|
|
4929
|
-
setSelectedImage(media[index]);
|
|
4930
4862
|
setSelectedImageIndex(index);
|
|
4931
4863
|
videoRefs.current.forEach((ref) => {
|
|
4932
4864
|
if (ref) {
|
|
@@ -4943,23 +4875,12 @@ const Comment = ({ author, message, children, date, media = [], header, }) => {
|
|
|
4943
4875
|
ed.setOptions({
|
|
4944
4876
|
editable: false,
|
|
4945
4877
|
});
|
|
4946
|
-
return (jsxRuntime.jsxs(CommentCard, { children: [jsxRuntime.jsxs(AuthorContainer, { children: [jsxRuntime.jsx(Avatar, Object.assign({ avatarType: (_a = author.avatarType) !== null && _a !== void 0 ? _a : "text", style: { flexShrink: 0 } }, { children: author.avatar })), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(CommentTitle, { children: [(_b = author.name) !== null && _b !== void 0 ? _b : "User", " ", jsxRuntime.jsx(CommentDate, { children: date })] }), jsxRuntime.jsx(ReadOnly, { children: jsxRuntime.jsx(EditorContainer$1, Object.assign({ editable: false }, { children: jsxRuntime.jsx(react.EditorContent, { editor: ed }) })) })] })] }), jsxRuntime.jsx(Grid, { children: jsxRuntime.jsx(Row$1, Object.assign({ className: "responsive-container" }, { children: media.map((file, index) => {
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
if (file.type.includes("video"))
|
|
4953
|
-
return (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 4, className: "flex-3-sm" }, { children: jsxRuntime.jsx(VideoThumbnail, { src: file.url, index: index, showX: false, isLoadingMedia: false, clickThumbnail: () => {
|
|
4954
|
-
handleClickThumbnail(file, index);
|
|
4955
|
-
} }, index) })));
|
|
4956
|
-
return null;
|
|
4957
|
-
}) })) }), isOpen && selectedImage && (jsxRuntime.jsxs(Lightbox, Object.assign({ onClose: closeLightbox }, { children: [jsxRuntime.jsx(Lightbox.Header, { children: jsxRuntime.jsxs(reactTypography.MD, Object.assign({ isBold: true }, { children: [jsxRuntime.jsx(Grey600Span, { children: header && header.title }), header && header.message && (jsxRuntime.jsxs(Grey800Span, { children: [" | ", header.message] }))] })) }), jsxRuntime.jsxs(Lightbox.Body, { children: [jsxRuntime.jsx(Lightbox.Body.Main, Object.assign({ style: { flex: 2 } }, { children: jsxRuntime.jsx(Slider, Object.assign({ prevArrow: jsxRuntime.jsx(Slider.PrevButton, { isBright: true }), nextArrow: jsxRuntime.jsx(Slider.NextButton, { isBright: true }), onSlideChange: slideChange, initialSlide: selectedImageIndex }, { children: media.map((item, index) => (jsxRuntime.jsxs(Slider.Slide, { children: [item.type === "image" && (jsxRuntime.jsx("img", { src: item.url, alt: `{{${item.url}}}` })), item.type === "video" && (jsxRuntime.jsx(Player, { ref: (ref) => {
|
|
4958
|
-
videoRefs.current.push(ref);
|
|
4959
|
-
}, url: item.url }))] }))) })) })), jsxRuntime.jsx(Lightbox.Body.Details, Object.assign({ style: { flex: 1 } }, { children: jsxRuntime.jsx(Comment, Object.assign({ header: header, author: {
|
|
4960
|
-
avatar: author.avatar,
|
|
4961
|
-
name: author.name,
|
|
4962
|
-
}, date: date, message: message }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("br", {}) }) })) }))] }), jsxRuntime.jsx(Lightbox.Footer, {}), jsxRuntime.jsx(Lightbox.Close, { "aria-label": "Close modal" })] }))), jsxRuntime.jsx(Footer$2, { children: children })] }));
|
|
4878
|
+
return (jsxRuntime.jsxs(CommentCard, { children: [jsxRuntime.jsxs(AuthorContainer, { children: [jsxRuntime.jsx(Avatar, Object.assign({ avatarType: (_a = author.avatarType) !== null && _a !== void 0 ? _a : "text", style: { flexShrink: 0 } }, { children: author.avatar })), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(CommentTitle, { children: [(_b = author.name) !== null && _b !== void 0 ? _b : "User", " ", jsxRuntime.jsx(CommentDate, { children: date })] }), jsxRuntime.jsx(ReadOnly, { children: jsxRuntime.jsx(EditorContainer$1, Object.assign({ editable: false }, { children: jsxRuntime.jsx(react.EditorContent, { editor: ed }) })) })] })] }), jsxRuntime.jsx(Grid, { children: jsxRuntime.jsx(Row$1, Object.assign({ className: "responsive-container" }, { children: media.map((file, index) => (jsxRuntime.jsx(Col, Object.assign({ xs: 12, sm: 4, className: "flex-3-sm" }, { children: jsxRuntime.jsx(Thumbnail, { src: file.url || URL.createObjectURL(file), type: file.type, showX: false, isLoadingMedia: false, clickThumbnail: () => {
|
|
4879
|
+
handleClickThumbnail(file, index);
|
|
4880
|
+
} }) }), index))) })) }), jsxRuntime.jsx(MediaLightBox, { isOpen: isOpen, header: jsxRuntime.jsxs(reactTypography.MD, Object.assign({ isBold: true }, { children: [jsxRuntime.jsx(Grey600Span, { children: header && header.title }), header && header.message && (jsxRuntime.jsxs(Grey800Span, { children: [" | ", header.message] }))] })), onClose: closeLightbox, slideChange: slideChange, selectedImageIndex: selectedImageIndex, thumbnails: media, videoRefs: videoRefs, details: jsxRuntime.jsx(Comment, Object.assign({ header: header, author: {
|
|
4881
|
+
avatar: author.avatar,
|
|
4882
|
+
name: author.name,
|
|
4883
|
+
}, date: date, message: message }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("br", {}) }) })) }), jsxRuntime.jsx(Footer$2, { children: children })] }));
|
|
4963
4884
|
};
|
|
4964
4885
|
|
|
4965
4886
|
/**
|