@blocklet/discuss-kit-ux 2.0.50 → 2.0.51
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/components/chat/chat-input.d.ts +3 -2
- package/dist/components/chat/chat-list-in-wallet.d.ts +1 -1
- package/dist/components/chat/chat.d.ts +1 -1
- package/dist/components/chat/message-list.d.ts +5 -2
- package/dist/components/chat/user-search.d.ts +2 -1
- package/dist/components/empty-status/empty-status.d.ts +7 -1
- package/dist/{editor-Bfs1bQVr.mjs → editor-B9hd6BuF.mjs} +1 -1
- package/dist/{index-CTvEVXs8.mjs → index-DohoZtqi.mjs} +50 -27
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +48 -25
- package/package.json +4 -4
|
@@ -2,8 +2,9 @@ import { EditorProps } from '../editor';
|
|
|
2
2
|
|
|
3
3
|
interface Props extends EditorProps {
|
|
4
4
|
initialContent?: string;
|
|
5
|
-
send: (content: string) => void
|
|
5
|
+
send: (content: string) => Promise<void>;
|
|
6
6
|
onContentChange?: (content: string) => void;
|
|
7
|
+
onInputFocus?: (v: boolean) => void;
|
|
7
8
|
}
|
|
8
|
-
export declare function ChatInput({ initialContent, send, onContentChange }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function ChatInput({ initialContent, send, onContentChange, onInputFocus }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -3,5 +3,8 @@ import { Chat } from './types';
|
|
|
3
3
|
interface ChatProps {
|
|
4
4
|
chat: Chat;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
export interface MessageListHandle {
|
|
7
|
+
scrollToBottom: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const MessageList: import('react').ForwardRefExoticComponent<ChatProps & import("react").RefAttributes<MessageListHandle>>;
|
|
10
|
+
export default MessageList;
|
|
@@ -2,6 +2,7 @@ import { SxProps } from '@mui/material';
|
|
|
2
2
|
|
|
3
3
|
interface Props {
|
|
4
4
|
sx?: SxProps;
|
|
5
|
+
inputSx?: SxProps;
|
|
5
6
|
}
|
|
6
|
-
export declare function UserSearch({ sx, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function UserSearch({ sx, inputSx, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { SxProps } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
sx?: SxProps;
|
|
5
|
+
}
|
|
6
|
+
export default function EmptyStatus({ sx }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
|
|
|
4
4
|
import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
|
|
5
5
|
import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
|
|
6
6
|
import { lazy } from "react";
|
|
7
|
-
import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-
|
|
7
|
+
import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-DohoZtqi.mjs";
|
|
8
8
|
const BlockletEditor = lazy(() => import("@blocklet/editor"));
|
|
9
9
|
const Root = styled(Box)`
|
|
10
10
|
.be-editable,
|
|
@@ -9,7 +9,7 @@ import { Labels2, LabelPicker } from "@blocklet/labels";
|
|
|
9
9
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
10
10
|
import { useTheme, ThemeProvider, styled } from "@mui/material/styles";
|
|
11
11
|
import { create as create$1, styled as styled$1 } from "@arcblock/ux/lib/Theme";
|
|
12
|
-
import { useEffect, useRef, useState, createElement, useContext, useMemo, useCallback, isValidElement, lazy, Suspense, createContext, Fragment as Fragment$1, forwardRef } from "react";
|
|
12
|
+
import { useEffect, useRef, useState, createElement, useContext, useMemo, useCallback, isValidElement, lazy, Suspense, createContext, Fragment as Fragment$1, forwardRef, useImperativeHandle } from "react";
|
|
13
13
|
import { Box, useTheme as useTheme$1, useMediaQuery, Tooltip as Tooltip$1, Chip as Chip$1, alpha, ClickAwayListener, Dialog as Dialog$1, DialogTitle, DialogContent, DialogActions, DialogContentText, Button as Button$1, Divider, Skeleton, IconButton as IconButton$2, InputBase, tooltipClasses as tooltipClasses$1, Backdrop, Autocomplete, Typography as Typography$1, TextField as TextField$1, InputAdornment, SwipeableDrawer, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
|
|
14
14
|
import isNil from "lodash/isNil";
|
|
15
15
|
import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/config";
|
|
@@ -868,12 +868,12 @@ function RelativeTime({ value, ...rest }) {
|
|
|
868
868
|
const v2 = value instanceof Date ? value.getTime() : value;
|
|
869
869
|
return /* @__PURE__ */ jsx(UxRelativeTime, { value: v2, ...rest });
|
|
870
870
|
}
|
|
871
|
-
function EmptyStatus() {
|
|
871
|
+
function EmptyStatus({ sx }) {
|
|
872
872
|
const { t } = useLocaleContext();
|
|
873
873
|
return /* @__PURE__ */ jsx(
|
|
874
874
|
Box$1,
|
|
875
875
|
{
|
|
876
|
-
sx: { height: "50vh", width: "100%" },
|
|
876
|
+
sx: { height: "50vh", width: "100%", ...sx },
|
|
877
877
|
display: "flex",
|
|
878
878
|
flexDirection: "column",
|
|
879
879
|
alignItems: "cetner",
|
|
@@ -4137,11 +4137,13 @@ function Message({ message, prevMessage, showTime = true, ...rest }) {
|
|
|
4137
4137
|
const { confirm } = useConfirm();
|
|
4138
4138
|
const { activeChatId, deleteMessage, isInWallet } = useChatContext();
|
|
4139
4139
|
const handleDeleteMessage = async () => {
|
|
4140
|
+
var _a3;
|
|
4140
4141
|
if (activeChatId) {
|
|
4141
4142
|
const proceed = await confirm({
|
|
4142
4143
|
title: t("deleteMessage.title"),
|
|
4143
4144
|
description: t("deleteMessage.desc"),
|
|
4144
|
-
okButtonProps: { color: "error" }
|
|
4145
|
+
okButtonProps: { color: "error" },
|
|
4146
|
+
dialogProps: { sx: { top: ((_a3 = window.chatInWallet) == null ? void 0 : _a3.safeAreaInsetTop) ?? 0 } }
|
|
4145
4147
|
});
|
|
4146
4148
|
if (proceed) {
|
|
4147
4149
|
deleteMessage(activeChatId, message.id);
|
|
@@ -4512,8 +4514,8 @@ function NotificationMessage({ chat, message, prevMessage }) {
|
|
|
4512
4514
|
const checkIsAtBottom = (element) => {
|
|
4513
4515
|
return element && (element.scrollHeight === 0 || element.scrollHeight - element.scrollTop < element.clientHeight + 60);
|
|
4514
4516
|
};
|
|
4515
|
-
|
|
4516
|
-
var _a2, _b2;
|
|
4517
|
+
const MessageList = forwardRef(({ chat, ...rest }, ref) => {
|
|
4518
|
+
var _a2, _b2, _c2;
|
|
4517
4519
|
const { isActiveChat, loadMessages } = useChatContext();
|
|
4518
4520
|
const { t } = useLocaleContext();
|
|
4519
4521
|
const isActive = isActiveChat(chat.id);
|
|
@@ -4525,6 +4527,9 @@ function MessageList({ chat, ...rest }) {
|
|
|
4525
4527
|
(_b3 = containerRef.current) == null ? void 0 : _b3.scrollTo({ top: ((_a3 = containerRef.current) == null ? void 0 : _a3.scrollHeight) || 0 });
|
|
4526
4528
|
setIsAtBottom(true);
|
|
4527
4529
|
};
|
|
4530
|
+
useImperativeHandle(ref, () => ({
|
|
4531
|
+
scrollToBottom
|
|
4532
|
+
}));
|
|
4528
4533
|
useEffect(() => {
|
|
4529
4534
|
const handleScroll = debounce(() => {
|
|
4530
4535
|
setIsAtBottom(checkIsAtBottom(containerRef.current));
|
|
@@ -4627,24 +4632,27 @@ function MessageList({ chat, ...rest }) {
|
|
|
4627
4632
|
const prev = (_a3 = chat.messages) == null ? void 0 : _a3[index - 1];
|
|
4628
4633
|
return /* @__PURE__ */ jsx(Box$1, { className: "message-item", id: message.id, children: /* @__PURE__ */ jsx(Message, { message, prevMessage: prev }) }, message.id);
|
|
4629
4634
|
})),
|
|
4630
|
-
chat.type === "notification" &&
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
{
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4635
|
+
chat.type === "notification" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4636
|
+
((_b2 = chat.messages) == null ? void 0 : _b2.length) === 0 && /* @__PURE__ */ jsx(EmptyStatus, { sx: { height: "100%" } }),
|
|
4637
|
+
(_c2 = chat.messages) == null ? void 0 : _c2.map((message, index) => {
|
|
4638
|
+
var _a3;
|
|
4639
|
+
const prev = (_a3 = chat.messages) == null ? void 0 : _a3[index - 1];
|
|
4640
|
+
return /* @__PURE__ */ jsx(Box$1, { className: "message-item", id: message.id, children: /* @__PURE__ */ jsx(
|
|
4641
|
+
NotificationMessage,
|
|
4642
|
+
{
|
|
4643
|
+
chat,
|
|
4644
|
+
message,
|
|
4645
|
+
prevMessage: prev
|
|
4646
|
+
}
|
|
4647
|
+
) }, message.id);
|
|
4648
|
+
})
|
|
4649
|
+
] })
|
|
4642
4650
|
]
|
|
4643
4651
|
}
|
|
4644
4652
|
),
|
|
4645
4653
|
!isAtBottom && /* @__PURE__ */ jsx(Box$1, { sx: { position: "absolute", bottom: 16, right: 24 }, onClick: scrollToBottom, children: /* @__PURE__ */ jsx(Fab, { color: "inherit", sx: { width: { xs: 36, sm: 44 }, height: { xs: 36, sm: 44 } }, children: /* @__PURE__ */ jsx(ArrowDownward, {}) }) })
|
|
4646
4654
|
] });
|
|
4647
|
-
}
|
|
4655
|
+
});
|
|
4648
4656
|
const HtmlTooltip = styled(({ className, ...props }) => /* @__PURE__ */ jsx(Tooltip$1, { ...props, classes: { popper: className } }))(() => ({
|
|
4649
4657
|
[`& .${tooltipClasses$1.tooltip}`]: {
|
|
4650
4658
|
color: "inherit",
|
|
@@ -4733,7 +4741,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
|
|
|
4733
4741
|
}
|
|
4734
4742
|
const tablerSend = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14L21 3m0 0l-6.5 18a.55.55 0 0 1-1 0L10 14l-7-3.5a.55.55 0 0 1 0-1z" }) });
|
|
4735
4743
|
const tablerLetterCase = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0-7 0M3 19V8.5a3.5 3.5 0 0 1 7 0V19m-7-6h7m11-1v7" }) });
|
|
4736
|
-
const Editor = lazy(() => import("./editor-
|
|
4744
|
+
const Editor = lazy(() => import("./editor-B9hd6BuF.mjs"));
|
|
4737
4745
|
function LazyEditor(props) {
|
|
4738
4746
|
const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
|
|
4739
4747
|
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
@@ -4868,7 +4876,7 @@ function ShortcutPlugin({ callback }) {
|
|
|
4868
4876
|
}, [editor, callback, mobile.any]);
|
|
4869
4877
|
return null;
|
|
4870
4878
|
}
|
|
4871
|
-
function ChatInput({ initialContent, send, onContentChange }) {
|
|
4879
|
+
function ChatInput({ initialContent, send, onContentChange, onInputFocus }) {
|
|
4872
4880
|
const { t } = useLocaleContext();
|
|
4873
4881
|
const [content, setContent] = useState("");
|
|
4874
4882
|
const [lastSent, setLastSent] = useState(0);
|
|
@@ -4877,6 +4885,14 @@ function ChatInput({ initialContent, send, onContentChange }) {
|
|
|
4877
4885
|
});
|
|
4878
4886
|
const { mobile } = useBrowser();
|
|
4879
4887
|
const [focused, setFocused] = useState(false);
|
|
4888
|
+
const onFocusWrapper = (v2) => {
|
|
4889
|
+
setFocused(v2);
|
|
4890
|
+
onInputFocus == null ? void 0 : onInputFocus(v2);
|
|
4891
|
+
};
|
|
4892
|
+
const onToolbarBtnMouseDown = (e) => {
|
|
4893
|
+
e.preventDefault();
|
|
4894
|
+
setToolbarVisible((x) => !x);
|
|
4895
|
+
};
|
|
4880
4896
|
const compactView = mobile.any && !focused;
|
|
4881
4897
|
const handleSend = () => {
|
|
4882
4898
|
if (!content) {
|
|
@@ -4961,7 +4977,7 @@ function ChatInput({ initialContent, send, onContentChange }) {
|
|
|
4961
4977
|
/* @__PURE__ */ jsx(AutoClearPlugin, { clearKey: lastSent }),
|
|
4962
4978
|
/* @__PURE__ */ jsx(ShortcutPlugin, { callback: handleSend }),
|
|
4963
4979
|
/* @__PURE__ */ jsx(DraggerPlugin, {}),
|
|
4964
|
-
/* @__PURE__ */ jsx(FocusPlugin, { callback:
|
|
4980
|
+
/* @__PURE__ */ jsx(FocusPlugin, { callback: onFocusWrapper })
|
|
4965
4981
|
]
|
|
4966
4982
|
}
|
|
4967
4983
|
) })
|
|
@@ -4990,7 +5006,7 @@ function ChatInput({ initialContent, send, onContentChange }) {
|
|
|
4990
5006
|
size: "small",
|
|
4991
5007
|
color: "primary",
|
|
4992
5008
|
variant: "text",
|
|
4993
|
-
|
|
5009
|
+
onMouseDown: onToolbarBtnMouseDown,
|
|
4994
5010
|
startIcon: /* @__PURE__ */ jsx(Box, { component: tablerLetterCase, sx: { fontSize: "14px !important" } }),
|
|
4995
5011
|
sx: {
|
|
4996
5012
|
width: 32,
|
|
@@ -5045,6 +5061,7 @@ function ChatRoom({ chat, inWallet, ...rest }) {
|
|
|
5045
5061
|
const { session, isAdmin } = useSessionContext();
|
|
5046
5062
|
const isCreator = chat.creator.did === ((_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.did);
|
|
5047
5063
|
const [input, setInput] = useLocalStorageState(`chat-input-${chat.id}`, { defaultValue: "" });
|
|
5064
|
+
const messageListRef = useRef(null);
|
|
5048
5065
|
useEffect(() => {
|
|
5049
5066
|
if (chat.isActivated) {
|
|
5050
5067
|
initChatRoom(chat.id);
|
|
@@ -5060,6 +5077,10 @@ function ChatRoom({ chat, inWallet, ...rest }) {
|
|
|
5060
5077
|
deleteChannel(chat.id);
|
|
5061
5078
|
}
|
|
5062
5079
|
};
|
|
5080
|
+
const onInputFocus = () => {
|
|
5081
|
+
var _a3;
|
|
5082
|
+
(_a3 = messageListRef.current) == null ? void 0 : _a3.scrollToBottom();
|
|
5083
|
+
};
|
|
5063
5084
|
const renderRoomHeader = () => {
|
|
5064
5085
|
if (chat.type === "notification") {
|
|
5065
5086
|
return /* @__PURE__ */ jsx(RoomTitle, { title: t("chat.notification") });
|
|
@@ -5154,13 +5175,14 @@ function ChatRoom({ chat, inWallet, ...rest }) {
|
|
|
5154
5175
|
]
|
|
5155
5176
|
}
|
|
5156
5177
|
),
|
|
5157
|
-
/* @__PURE__ */ jsx(Box$1, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx(EditorConfigProvider$1, { value: { openLinkInNewTab: !!inWallet }, children: /* @__PURE__ */ jsx(MessageList, { chat }) }) }),
|
|
5178
|
+
/* @__PURE__ */ jsx(Box$1, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx(EditorConfigProvider$1, { value: { openLinkInNewTab: !!inWallet }, children: /* @__PURE__ */ jsx(MessageList, { ref: messageListRef, chat }) }) }),
|
|
5158
5179
|
/* @__PURE__ */ jsxs(Box$1, { sx: { position: "relative" }, children: [
|
|
5159
5180
|
chat.isActivated && chat.type !== "notification" && /* @__PURE__ */ jsx(Box$1, { sx: { px: { xs: 0, sm: 2.5 }, pb: { xs: 0, sm: 2.5 } }, children: /* @__PURE__ */ jsx(
|
|
5160
5181
|
ChatInput,
|
|
5161
5182
|
{
|
|
5162
5183
|
initialContent: input,
|
|
5163
5184
|
onContentChange: (v2) => setInput(v2),
|
|
5185
|
+
onInputFocus,
|
|
5164
5186
|
send: (content) => sendMessage(chat.id, content)
|
|
5165
5187
|
}
|
|
5166
5188
|
) }),
|
|
@@ -5280,7 +5302,7 @@ function NewChannelDialog({ open, onSubmit, onClose, ...rest }) {
|
|
|
5280
5302
|
);
|
|
5281
5303
|
}
|
|
5282
5304
|
const tablerSearch = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m18 11l-6-6" }) });
|
|
5283
|
-
function UserSearch({ sx, ...rest }) {
|
|
5305
|
+
function UserSearch({ sx, inputSx, ...rest }) {
|
|
5284
5306
|
var _a2;
|
|
5285
5307
|
const { session } = useSessionContext();
|
|
5286
5308
|
const navigate = useNavigate();
|
|
@@ -5391,6 +5413,7 @@ function UserSearch({ sx, ...rest }) {
|
|
|
5391
5413
|
InputProps: {
|
|
5392
5414
|
...params.InputProps,
|
|
5393
5415
|
type: "search",
|
|
5416
|
+
sx: inputSx,
|
|
5394
5417
|
startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(Box, { component: tablerSearch, sx: { fontSize: 14 } }) })
|
|
5395
5418
|
},
|
|
5396
5419
|
sx: {
|
|
@@ -5618,7 +5641,7 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5618
5641
|
updateUnreadState(unread);
|
|
5619
5642
|
}, [unread, updateUnreadState]);
|
|
5620
5643
|
if (!initialized) {
|
|
5621
|
-
return /* @__PURE__ */ jsx(CircularProgress, {});
|
|
5644
|
+
return /* @__PURE__ */ jsx(Backdrop, { open: true, sx: { zIndex: (theme) => theme.zIndex.drawer + 1, bgcolor: "transparent" }, children: /* @__PURE__ */ jsx(CircularProgress, {}) });
|
|
5622
5645
|
}
|
|
5623
5646
|
const mergedSx = [
|
|
5624
5647
|
{
|
|
@@ -5689,7 +5712,7 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5689
5712
|
]
|
|
5690
5713
|
}
|
|
5691
5714
|
),
|
|
5692
|
-
/* @__PURE__ */ jsx(UserSearch, {})
|
|
5715
|
+
/* @__PURE__ */ jsx(UserSearch, { inputSx: { fontSize: 16 } })
|
|
5693
5716
|
] }),
|
|
5694
5717
|
/* @__PURE__ */ jsx(Divider, {}),
|
|
5695
5718
|
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: true }),
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "@blocklet/labels";
|
|
2
|
-
import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-
|
|
2
|
+
import { T, n, W, A, m, ad, B, F, K, J, L, ap, Y, X, $, Z, _, a1, w, C, x, y, E, a5, a6, ah, a8, O, Q, ac, D, ag, af, H, G, b, k, ae, M, P, ao, v, q, R, S, a9, aq, o, a2, a4, ai, al, ak, am, ar, N, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-DohoZtqi.mjs";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
5
|
import "@mui/material/Box";
|
package/dist/index.umd.js
CHANGED
|
@@ -794,12 +794,12 @@ var __publicField = (obj, key, value) => {
|
|
|
794
794
|
const v2 = value instanceof Date ? value.getTime() : value;
|
|
795
795
|
return /* @__PURE__ */ jsxRuntime.jsx(UxRelativeTime, { value: v2, ...rest });
|
|
796
796
|
}
|
|
797
|
-
function EmptyStatus() {
|
|
797
|
+
function EmptyStatus({ sx }) {
|
|
798
798
|
const { t } = context.useLocaleContext();
|
|
799
799
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
800
800
|
Box,
|
|
801
801
|
{
|
|
802
|
-
sx: { height: "50vh", width: "100%" },
|
|
802
|
+
sx: { height: "50vh", width: "100%", ...sx },
|
|
803
803
|
display: "flex",
|
|
804
804
|
flexDirection: "column",
|
|
805
805
|
alignItems: "cetner",
|
|
@@ -4063,11 +4063,13 @@ var __publicField = (obj, key, value) => {
|
|
|
4063
4063
|
const { confirm } = useConfirm();
|
|
4064
4064
|
const { activeChatId, deleteMessage, isInWallet } = useChatContext();
|
|
4065
4065
|
const handleDeleteMessage = async () => {
|
|
4066
|
+
var _a3;
|
|
4066
4067
|
if (activeChatId) {
|
|
4067
4068
|
const proceed = await confirm({
|
|
4068
4069
|
title: t("deleteMessage.title"),
|
|
4069
4070
|
description: t("deleteMessage.desc"),
|
|
4070
|
-
okButtonProps: { color: "error" }
|
|
4071
|
+
okButtonProps: { color: "error" },
|
|
4072
|
+
dialogProps: { sx: { top: ((_a3 = window.chatInWallet) == null ? void 0 : _a3.safeAreaInsetTop) ?? 0 } }
|
|
4071
4073
|
});
|
|
4072
4074
|
if (proceed) {
|
|
4073
4075
|
deleteMessage(activeChatId, message.id);
|
|
@@ -4438,8 +4440,8 @@ var __publicField = (obj, key, value) => {
|
|
|
4438
4440
|
const checkIsAtBottom = (element) => {
|
|
4439
4441
|
return element && (element.scrollHeight === 0 || element.scrollHeight - element.scrollTop < element.clientHeight + 60);
|
|
4440
4442
|
};
|
|
4441
|
-
|
|
4442
|
-
var _a2, _b2;
|
|
4443
|
+
const MessageList = react.forwardRef(({ chat, ...rest }, ref) => {
|
|
4444
|
+
var _a2, _b2, _c2;
|
|
4443
4445
|
const { isActiveChat, loadMessages } = useChatContext();
|
|
4444
4446
|
const { t } = context.useLocaleContext();
|
|
4445
4447
|
const isActive = isActiveChat(chat.id);
|
|
@@ -4451,6 +4453,9 @@ var __publicField = (obj, key, value) => {
|
|
|
4451
4453
|
(_b3 = containerRef.current) == null ? void 0 : _b3.scrollTo({ top: ((_a3 = containerRef.current) == null ? void 0 : _a3.scrollHeight) || 0 });
|
|
4452
4454
|
setIsAtBottom(true);
|
|
4453
4455
|
};
|
|
4456
|
+
react.useImperativeHandle(ref, () => ({
|
|
4457
|
+
scrollToBottom
|
|
4458
|
+
}));
|
|
4454
4459
|
react.useEffect(() => {
|
|
4455
4460
|
const handleScroll = debounce(() => {
|
|
4456
4461
|
setIsAtBottom(checkIsAtBottom(containerRef.current));
|
|
@@ -4553,24 +4558,27 @@ var __publicField = (obj, key, value) => {
|
|
|
4553
4558
|
const prev = (_a3 = chat.messages) == null ? void 0 : _a3[index - 1];
|
|
4554
4559
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "message-item", id: message.id, children: /* @__PURE__ */ jsxRuntime.jsx(Message, { message, prevMessage: prev }) }, message.id);
|
|
4555
4560
|
})),
|
|
4556
|
-
chat.type === "notification" &&
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
{
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4561
|
+
chat.type === "notification" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4562
|
+
((_b2 = chat.messages) == null ? void 0 : _b2.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(EmptyStatus, { sx: { height: "100%" } }),
|
|
4563
|
+
(_c2 = chat.messages) == null ? void 0 : _c2.map((message, index) => {
|
|
4564
|
+
var _a3;
|
|
4565
|
+
const prev = (_a3 = chat.messages) == null ? void 0 : _a3[index - 1];
|
|
4566
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "message-item", id: message.id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4567
|
+
NotificationMessage,
|
|
4568
|
+
{
|
|
4569
|
+
chat,
|
|
4570
|
+
message,
|
|
4571
|
+
prevMessage: prev
|
|
4572
|
+
}
|
|
4573
|
+
) }, message.id);
|
|
4574
|
+
})
|
|
4575
|
+
] })
|
|
4568
4576
|
]
|
|
4569
4577
|
}
|
|
4570
4578
|
),
|
|
4571
4579
|
!isAtBottom && /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { position: "absolute", bottom: 16, right: 24 }, onClick: scrollToBottom, children: /* @__PURE__ */ jsxRuntime.jsx(Fab, { color: "inherit", sx: { width: { xs: 36, sm: 44 }, height: { xs: 36, sm: 44 } }, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.ArrowDownward, {}) }) })
|
|
4572
4580
|
] });
|
|
4573
|
-
}
|
|
4581
|
+
});
|
|
4574
4582
|
const HtmlTooltip = styles.styled(({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(material.Tooltip, { ...props, classes: { popper: className } }))(() => ({
|
|
4575
4583
|
[`& .${material.tooltipClasses.tooltip}`]: {
|
|
4576
4584
|
color: "inherit",
|
|
@@ -4794,7 +4802,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4794
4802
|
}, [editor2, callback, mobile.any]);
|
|
4795
4803
|
return null;
|
|
4796
4804
|
}
|
|
4797
|
-
function ChatInput({ initialContent, send, onContentChange }) {
|
|
4805
|
+
function ChatInput({ initialContent, send, onContentChange, onInputFocus }) {
|
|
4798
4806
|
const { t } = context.useLocaleContext();
|
|
4799
4807
|
const [content, setContent] = react.useState("");
|
|
4800
4808
|
const [lastSent, setLastSent] = react.useState(0);
|
|
@@ -4803,6 +4811,14 @@ var __publicField = (obj, key, value) => {
|
|
|
4803
4811
|
});
|
|
4804
4812
|
const { mobile } = reactHooks.useBrowser();
|
|
4805
4813
|
const [focused, setFocused] = react.useState(false);
|
|
4814
|
+
const onFocusWrapper = (v2) => {
|
|
4815
|
+
setFocused(v2);
|
|
4816
|
+
onInputFocus == null ? void 0 : onInputFocus(v2);
|
|
4817
|
+
};
|
|
4818
|
+
const onToolbarBtnMouseDown = (e) => {
|
|
4819
|
+
e.preventDefault();
|
|
4820
|
+
setToolbarVisible((x) => !x);
|
|
4821
|
+
};
|
|
4806
4822
|
const compactView = mobile.any && !focused;
|
|
4807
4823
|
const handleSend = () => {
|
|
4808
4824
|
if (!content) {
|
|
@@ -4887,7 +4903,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4887
4903
|
/* @__PURE__ */ jsxRuntime.jsx(AutoClearPlugin, { clearKey: lastSent }),
|
|
4888
4904
|
/* @__PURE__ */ jsxRuntime.jsx(ShortcutPlugin, { callback: handleSend }),
|
|
4889
4905
|
/* @__PURE__ */ jsxRuntime.jsx(DraggerPlugin, {}),
|
|
4890
|
-
/* @__PURE__ */ jsxRuntime.jsx(FocusPlugin, { callback:
|
|
4906
|
+
/* @__PURE__ */ jsxRuntime.jsx(FocusPlugin, { callback: onFocusWrapper })
|
|
4891
4907
|
]
|
|
4892
4908
|
}
|
|
4893
4909
|
) })
|
|
@@ -4916,7 +4932,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4916
4932
|
size: "small",
|
|
4917
4933
|
color: "primary",
|
|
4918
4934
|
variant: "text",
|
|
4919
|
-
|
|
4935
|
+
onMouseDown: onToolbarBtnMouseDown,
|
|
4920
4936
|
startIcon: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: tablerLetterCase, sx: { fontSize: "14px !important" } }),
|
|
4921
4937
|
sx: {
|
|
4922
4938
|
width: 32,
|
|
@@ -4971,6 +4987,7 @@ var __publicField = (obj, key, value) => {
|
|
|
4971
4987
|
const { session, isAdmin } = useSessionContext();
|
|
4972
4988
|
const isCreator = chat.creator.did === ((_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.did);
|
|
4973
4989
|
const [input, setInput] = ahooks.useLocalStorageState(`chat-input-${chat.id}`, { defaultValue: "" });
|
|
4990
|
+
const messageListRef = react.useRef(null);
|
|
4974
4991
|
react.useEffect(() => {
|
|
4975
4992
|
if (chat.isActivated) {
|
|
4976
4993
|
initChatRoom(chat.id);
|
|
@@ -4986,6 +5003,10 @@ var __publicField = (obj, key, value) => {
|
|
|
4986
5003
|
deleteChannel(chat.id);
|
|
4987
5004
|
}
|
|
4988
5005
|
};
|
|
5006
|
+
const onInputFocus = () => {
|
|
5007
|
+
var _a3;
|
|
5008
|
+
(_a3 = messageListRef.current) == null ? void 0 : _a3.scrollToBottom();
|
|
5009
|
+
};
|
|
4989
5010
|
const renderRoomHeader = () => {
|
|
4990
5011
|
if (chat.type === "notification") {
|
|
4991
5012
|
return /* @__PURE__ */ jsxRuntime.jsx(RoomTitle, { title: t("chat.notification") });
|
|
@@ -5080,13 +5101,14 @@ var __publicField = (obj, key, value) => {
|
|
|
5080
5101
|
]
|
|
5081
5102
|
}
|
|
5082
5103
|
),
|
|
5083
|
-
/* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(editor$1.EditorConfigProvider, { value: { openLinkInNewTab: !!inWallet }, children: /* @__PURE__ */ jsxRuntime.jsx(MessageList, { chat }) }) }),
|
|
5104
|
+
/* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(editor$1.EditorConfigProvider, { value: { openLinkInNewTab: !!inWallet }, children: /* @__PURE__ */ jsxRuntime.jsx(MessageList, { ref: messageListRef, chat }) }) }),
|
|
5084
5105
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { position: "relative" }, children: [
|
|
5085
5106
|
chat.isActivated && chat.type !== "notification" && /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { px: { xs: 0, sm: 2.5 }, pb: { xs: 0, sm: 2.5 } }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5086
5107
|
ChatInput,
|
|
5087
5108
|
{
|
|
5088
5109
|
initialContent: input,
|
|
5089
5110
|
onContentChange: (v2) => setInput(v2),
|
|
5111
|
+
onInputFocus,
|
|
5090
5112
|
send: (content) => sendMessage(chat.id, content)
|
|
5091
5113
|
}
|
|
5092
5114
|
) }),
|
|
@@ -5206,7 +5228,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5206
5228
|
);
|
|
5207
5229
|
}
|
|
5208
5230
|
const tablerSearch = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", "data-iconify": "tabler", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 10a7 7 0 1 0 14 0a7 7 0 1 0-14 0m18 11l-6-6" }) });
|
|
5209
|
-
function UserSearch({ sx, ...rest }) {
|
|
5231
|
+
function UserSearch({ sx, inputSx, ...rest }) {
|
|
5210
5232
|
var _a2;
|
|
5211
5233
|
const { session } = useSessionContext();
|
|
5212
5234
|
const navigate = reactRouterDom.useNavigate();
|
|
@@ -5317,6 +5339,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5317
5339
|
InputProps: {
|
|
5318
5340
|
...params.InputProps,
|
|
5319
5341
|
type: "search",
|
|
5342
|
+
sx: inputSx,
|
|
5320
5343
|
startAdornment: /* @__PURE__ */ jsxRuntime.jsx(material.InputAdornment, { position: "start", children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: tablerSearch, sx: { fontSize: 14 } }) })
|
|
5321
5344
|
},
|
|
5322
5345
|
sx: {
|
|
@@ -5544,7 +5567,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5544
5567
|
updateUnreadState(unread);
|
|
5545
5568
|
}, [unread, updateUnreadState]);
|
|
5546
5569
|
if (!initialized) {
|
|
5547
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CircularProgress, {});
|
|
5570
|
+
return /* @__PURE__ */ jsxRuntime.jsx(material.Backdrop, { open: true, sx: { zIndex: (theme) => theme.zIndex.drawer + 1, bgcolor: "transparent" }, children: /* @__PURE__ */ jsxRuntime.jsx(CircularProgress, {}) });
|
|
5548
5571
|
}
|
|
5549
5572
|
const mergedSx = [
|
|
5550
5573
|
{
|
|
@@ -5615,7 +5638,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5615
5638
|
]
|
|
5616
5639
|
}
|
|
5617
5640
|
),
|
|
5618
|
-
/* @__PURE__ */ jsxRuntime.jsx(UserSearch, {})
|
|
5641
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserSearch, { inputSx: { fontSize: 16 } })
|
|
5619
5642
|
] }),
|
|
5620
5643
|
/* @__PURE__ */ jsxRuntime.jsx(material.Divider, {}),
|
|
5621
5644
|
!!(chats == null ? void 0 : chats.length) && /* @__PURE__ */ jsxRuntime.jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: true }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit-ux",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.51",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@arcblock/bridge": "^2.10.1",
|
|
32
32
|
"@arcblock/react-hooks": "^2.10.1",
|
|
33
33
|
"@arcblock/ws": "^1.18.123",
|
|
34
|
-
"@blocklet/editor": "2.0.
|
|
35
|
-
"@blocklet/labels": "2.0.
|
|
34
|
+
"@blocklet/editor": "2.0.51",
|
|
35
|
+
"@blocklet/labels": "2.0.51",
|
|
36
36
|
"@blocklet/uploader": "^0.1.15",
|
|
37
37
|
"@emotion/css": "^11.10.5",
|
|
38
38
|
"@emotion/react": "^11.10.5",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"resolutions": {
|
|
101
101
|
"react": "^18.2.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "8fc2c4a6f1c073443e56c933354ec6deb3be1a96"
|
|
104
104
|
}
|