@blocklet/discuss-kit-ux 2.1.46 → 2.1.47

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.
@@ -1,6 +1,6 @@
1
1
  import { Emitter } from 'mitt';
2
2
  import { User } from '../../types';
3
- import { Chat, Message, Channel } from './types';
3
+ import { Chat, Message, Channel, ChannelUpdatePayload } from './types';
4
4
  type Events = {
5
5
  message: {
6
6
  chatId: string;
@@ -59,7 +59,8 @@ export default abstract class ChatClient {
59
59
  nextCursor: string;
60
60
  }>;
61
61
  abstract sendMessage: (chatId: string, content: string) => Promise<Message>;
62
- abstract createChannel: (name: string, description: string) => Promise<Channel>;
62
+ abstract createChannel: (payload: Omit<ChannelUpdatePayload, 'id'>) => Promise<Channel>;
63
+ abstract updateChannel: (payload: ChannelUpdatePayload) => Promise<Channel>;
63
64
  abstract joinChannel: (chatId: string) => Promise<void>;
64
65
  abstract leaveChannel: (chatId: string) => Promise<void>;
65
66
  abstract deleteChannel: (chatId: string) => Promise<void>;
@@ -1,6 +1,12 @@
1
1
  import { SxProps } from '@mui/material';
2
+ import { ChannelUpdatePayload } from './types';
2
3
  interface ChatProps {
3
4
  sx?: SxProps;
5
+ ChannelEditComponent?: React.ComponentType<{
6
+ initialValue: ChannelUpdatePayload;
7
+ onClose: () => void;
8
+ onSubmit: (payload: ChannelUpdatePayload) => void;
9
+ }>;
4
10
  }
5
- export default function Chat({ sx, ...rest }: ChatProps): import("react/jsx-runtime").JSX.Element;
11
+ export default function Chat({ sx, ChannelEditComponent, ...rest }: ChatProps): import("react/jsx-runtime").JSX.Element;
6
12
  export {};
@@ -1,16 +1,18 @@
1
1
  import { User } from '../../types';
2
2
  import { default as ChatClient } from './chat-client';
3
- import { Chat as ChatType } from './types';
3
+ import { Chat as ChatType, ChannelUpdatePayload } from './types';
4
4
  export interface ChatProviderProps {
5
5
  children: React.ReactNode;
6
6
  client: ChatClient;
7
7
  activeChatId?: string | null;
8
8
  isInWallet: boolean;
9
9
  }
10
+ type EditingChannel = ChannelUpdatePayload | null;
10
11
  interface ChatState {
11
12
  initialized: boolean;
12
13
  chats: ChatType[];
13
14
  activeChatId?: string | null;
15
+ editingChannel: EditingChannel;
14
16
  error?: string;
15
17
  }
16
18
  interface ChatContextValue extends ChatState {
@@ -22,6 +24,7 @@ interface ChatContextValue extends ChatState {
22
24
  loadMessages: (chatId: string, cursor?: string) => Promise<void>;
23
25
  sendMessage: (chatId: string, content: string) => Promise<void>;
24
26
  addChat: (chat: ChatType) => void;
27
+ updateChat: (chatId: string, mapper: (chat: ChatType) => ChatType) => void;
25
28
  initChatRoom: (chatId: string) => Promise<void>;
26
29
  joinChannel: (chatId: string) => Promise<void>;
27
30
  leaveChannel: (chatId: string) => Promise<void>;
@@ -32,6 +35,7 @@ interface ChatContextValue extends ChatState {
32
35
  orderedChats: ChatType[];
33
36
  getLastMessageText: (chat: ChatType) => string;
34
37
  isInWallet: boolean;
38
+ setEditingChannel: (channel: EditingChannel) => void;
35
39
  }
36
40
  export declare const useChatContext: () => ChatContextValue;
37
41
  export declare function ChatProvider({ client, activeChatId, children, isInWallet }: ChatProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -86,5 +86,11 @@ export interface Channel extends CommonChat {
86
86
  description?: string;
87
87
  hasJoined: boolean;
88
88
  }
89
+ export interface ChannelUpdatePayload {
90
+ id?: string;
91
+ name: string;
92
+ description?: string;
93
+ boardId?: string;
94
+ }
89
95
  export type Chat = DM | Channel | Notification;
90
96
  export {};
@@ -45,10 +45,10 @@ declare const _default: {
45
45
  reply: string;
46
46
  unknown: string;
47
47
  chats: string;
48
- create: string;
49
48
  channel: string;
50
49
  description: string;
51
50
  newChannel: string;
51
+ updateChannel: string;
52
52
  noChats: string;
53
53
  unknownChannel: string;
54
54
  channelDescription: string;
@@ -77,6 +77,7 @@ declare const _default: {
77
77
  notYetJoinedTheChannel: string;
78
78
  typeSomething: string;
79
79
  send: string;
80
+ selectBoardTip: string;
80
81
  };
81
82
  userActionLog: {
82
83
  editedCapital: string;
@@ -51,6 +51,7 @@ export declare const translations: {
51
51
  channel: string;
52
52
  description: string;
53
53
  newChannel: string;
54
+ updateChannel: string;
54
55
  noChats: string;
55
56
  unknownChannel: string;
56
57
  channelDescription: string;
@@ -79,6 +80,7 @@ export declare const translations: {
79
80
  notYetJoinedTheChannel: string;
80
81
  typeSomething: string;
81
82
  send: string;
83
+ selectBoardTip: string;
82
84
  };
83
85
  userActionLog: {
84
86
  editedCapital: string;
@@ -135,10 +137,10 @@ export declare const translations: {
135
137
  reply: string;
136
138
  unknown: string;
137
139
  chats: string;
138
- create: string;
139
140
  channel: string;
140
141
  description: string;
141
142
  newChannel: string;
143
+ updateChannel: string;
142
144
  noChats: string;
143
145
  unknownChannel: string;
144
146
  channelDescription: string;
@@ -167,6 +169,7 @@ export declare const translations: {
167
169
  notYetJoinedTheChannel: string;
168
170
  typeSomething: string;
169
171
  send: string;
172
+ selectBoardTip: string;
170
173
  };
171
174
  userActionLog: {
172
175
  editedCapital: string;
@@ -50,6 +50,7 @@ declare const _default: {
50
50
  channel: string;
51
51
  description: string;
52
52
  newChannel: string;
53
+ updateChannel: string;
53
54
  noChats: string;
54
55
  unknownChannel: string;
55
56
  channelDescription: string;
@@ -78,6 +79,7 @@ declare const _default: {
78
79
  notYetJoinedTheChannel: string;
79
80
  typeSomething: string;
80
81
  send: string;
82
+ selectBoardTip: string;
81
83
  };
82
84
  userActionLog: {
83
85
  editedCapital: string;
@@ -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-vYGfcLWv.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-DDQnH71T.mjs";
8
8
  const BlockletEditor = lazy(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -7,7 +7,7 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
7
7
  import { useTheme, ThemeProvider, styled } from "@mui/material/styles";
8
8
  import { create as create$1, styled as styled$1 } from "@arcblock/ux/lib/Theme";
9
9
  import { useEffect, useRef, useState, createElement, useContext, useMemo, useCallback, isValidElement, lazy, Suspense, createContext, Fragment as Fragment$1, forwardRef, useImperativeHandle } from "react";
10
- import { Box, useTheme as useTheme$1, useMediaQuery, styled as styled$2, 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, CircularProgress, Backdrop, Autocomplete, Typography as Typography$1, TextField as TextField$1, InputAdornment, SwipeableDrawer, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
10
+ import { Box, useTheme as useTheme$1, useMediaQuery, styled as styled$2, 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, CircularProgress, Backdrop, Autocomplete, Typography as Typography$1, TextField, InputAdornment, SwipeableDrawer, Badge as Badge$1, Paper, ToggleButtonGroup, ToggleButton } from "@mui/material";
11
11
  import isNil from "lodash/isNil";
12
12
  import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/config";
13
13
  import { lazyWithPreload } from "react-lazy-with-preload";
@@ -73,8 +73,6 @@ import Fab from "@mui/material/Fab";
73
73
  import debounce from "lodash/debounce";
74
74
  import { useIsFocused } from "@blocklet/editor/lib/main/hooks/useIsFocused";
75
75
  import { BusyPlugin } from "@blocklet/editor/lib/ext/BusyPlugin";
76
- import TextField from "@mui/material/TextField";
77
- import AddIcon from "@mui/icons-material/Add";
78
76
  import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
79
77
  import ShortTextIcon from "@mui/icons-material/ShortText";
80
78
  import { AxiosError } from "axios";
@@ -842,7 +840,7 @@ const Root$3 = styled$1(AvatarGroup)`
842
840
  }
843
841
 
844
842
  // use avatarGroup first is last
845
- .avatars-item:first-child {
843
+ .avatars-item:first-of-type {
846
844
  width: 24px;
847
845
  }
848
846
 
@@ -3803,6 +3801,7 @@ function ChatProvider({ client: client2, activeChatId, children, isInWallet }) {
3803
3801
  initialized: false,
3804
3802
  chats: [],
3805
3803
  activeChatId: void 0,
3804
+ editingChannel: null,
3806
3805
  error: void 0
3807
3806
  });
3808
3807
  const { markAsUnread } = useUnreadNotification();
@@ -4056,6 +4055,7 @@ function ChatProvider({ client: client2, activeChatId, children, isInWallet }) {
4056
4055
  loadMessages,
4057
4056
  sendMessage,
4058
4057
  addChat,
4058
+ updateChat,
4059
4059
  initChatRoom,
4060
4060
  joinChannel,
4061
4061
  leaveChannel,
@@ -4065,7 +4065,8 @@ function ChatProvider({ client: client2, activeChatId, children, isInWallet }) {
4065
4065
  orderedChats,
4066
4066
  getLastMessageText,
4067
4067
  isInWallet,
4068
- createDM
4068
+ createDM,
4069
+ setEditingChannel: (payload) => setState((prev) => ({ ...prev, editingChannel: payload }))
4069
4070
  };
4070
4071
  }, [state, client2, currentUser == null ? void 0 : currentUser.did]);
4071
4072
  return /* @__PURE__ */ jsx(ChatContext.Provider, { value, children });
@@ -4470,7 +4471,7 @@ function NotificationMessage({ chat, message, prevMessage }) {
4470
4471
  const { points, post, comment, eventKey = "" } = message;
4471
4472
  const unit = points > 1 ? t("chat.points") : t("chat.point");
4472
4473
  const event = eventKey ? `for ${eventKey.toLowerCase().replaceAll("-", " ")}: ` : ": ";
4473
- const tip = t("chat.pointUp", { points, unit, event });
4474
+ const tip = t("chat.pointUp", { points: points + "", unit, event });
4474
4475
  return /* @__PURE__ */ jsxs(Box$1, { children: [
4475
4476
  /* @__PURE__ */ jsx(Box$1, { component: "span", sx: { color: "grey.600" }, children: tip }),
4476
4477
  comment && /* @__PURE__ */ jsx(Typography, { variant: "body1", children: comment.excerpt }),
@@ -4734,7 +4735,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
4734
4735
  }
4735
4736
  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" }) });
4736
4737
  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" }) });
4737
- const Editor = lazy(() => import("./editor-CqPVERyE.mjs"));
4738
+ const Editor = lazy(() => import("./editor-BhPOcPBU.mjs"));
4738
4739
  function LazyEditor(props) {
4739
4740
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4740
4741
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -5055,7 +5056,16 @@ function ChatRoom({ chat, inWallet, ...rest }) {
5055
5056
  const { t } = useLocaleContext();
5056
5057
  const theme = useTheme();
5057
5058
  const downSm = useMediaQuery((currentTheme) => currentTheme.breakpoints.down("sm"));
5058
- const { initChatRoom, isActiveChat, getOppositeUser, sendMessage, joinChannel, leaveChannel, deleteChannel } = useChatContext();
5059
+ const {
5060
+ initChatRoom,
5061
+ isActiveChat,
5062
+ getOppositeUser,
5063
+ sendMessage,
5064
+ joinChannel,
5065
+ leaveChannel,
5066
+ deleteChannel,
5067
+ setEditingChannel
5068
+ } = useChatContext();
5059
5069
  const { confirm } = useConfirm();
5060
5070
  const isActive = isActiveChat(chat.id);
5061
5071
  const { session, isAdmin } = useSessionContext();
@@ -5101,6 +5111,7 @@ function ChatRoom({ chat, inWallet, ...rest }) {
5101
5111
  }
5102
5112
  if (isAdmin || isCreator) {
5103
5113
  menuItems.push(
5114
+ /* @__PURE__ */ jsx(Menu.Item, { onClick: () => setEditingChannel(chat), children: /* @__PURE__ */ jsx(Box$1, { component: "span", children: "Edit" }) }, "edit"),
5104
5115
  /* @__PURE__ */ jsx(Menu.Item, { onClick: handleDeleteChannel, children: /* @__PURE__ */ jsx(Box$1, { component: "span", sx: { color: "error.main" }, children: t("chat.deleteChannel") }) }, "delete")
5105
5116
  );
5106
5117
  }
@@ -5212,94 +5223,6 @@ function ChatRoom({ chat, inWallet, ...rest }) {
5212
5223
  ] })
5213
5224
  ] });
5214
5225
  }
5215
- function NewChannelDialog({ open, onSubmit, onClose, ...rest }) {
5216
- const [state, setState] = useSetState({
5217
- name: "",
5218
- description: ""
5219
- });
5220
- const { t } = useLocaleContext();
5221
- const theme = useTheme();
5222
- const canSubmit = useMemo(() => {
5223
- return state.name;
5224
- }, [state]);
5225
- const handleSubmit = () => {
5226
- onSubmit(state);
5227
- };
5228
- return /* @__PURE__ */ jsx(
5229
- Dialog,
5230
- {
5231
- open,
5232
- showCloseButton: true,
5233
- maxWidth: "lg",
5234
- title: t("chat.newChannel"),
5235
- actions: /* @__PURE__ */ jsxs(Button, { color: "primary", variant: "contained", size: "small", onClick: handleSubmit, disabled: !canSubmit, children: [
5236
- /* @__PURE__ */ jsx(AddIcon, { sx: { mr: 0.375 } }),
5237
- t("chat.create")
5238
- ] }),
5239
- onClose,
5240
- ...rest,
5241
- children: /* @__PURE__ */ jsxs(
5242
- Box$1,
5243
- {
5244
- width: { xs: "100%", md: 560 },
5245
- sx: {
5246
- display: "flex",
5247
- flexDirection: "column",
5248
- gap: 2,
5249
- lineHeight: 1.75
5250
- },
5251
- minHeight: 140,
5252
- children: [
5253
- /* @__PURE__ */ jsxs(Box$1, { children: [
5254
- /* @__PURE__ */ jsx(Box$1, { sx: { fontSize: 14, fontWeight: "medium", mb: 0 }, children: t("chat.channelName") }),
5255
- /* @__PURE__ */ jsx(
5256
- TextField,
5257
- {
5258
- value: state.name,
5259
- placeholder: t("chat.channelName"),
5260
- size: "small",
5261
- fullWidth: true,
5262
- sx: {
5263
- "& .MuiInputBase-root": {
5264
- height: 40,
5265
- backgroundColor: theme.palette.grey[100]
5266
- }
5267
- },
5268
- onChange: (e) => setState({ name: e.target.value })
5269
- }
5270
- )
5271
- ] }),
5272
- /* @__PURE__ */ jsxs(Box$1, { children: [
5273
- /* @__PURE__ */ jsx(Box$1, { sx: { fontSize: 14, fontWeight: "medium", mb: 0 }, children: t("chat.channelDescription") }),
5274
- /* @__PURE__ */ jsx(
5275
- TextField,
5276
- {
5277
- value: state.description,
5278
- placeholder: t("chat.channelDescription"),
5279
- fullWidth: true,
5280
- multiline: true,
5281
- onChange: (e) => setState({ description: e.target.value }),
5282
- minRows: 2,
5283
- sx: {
5284
- "& .MuiInputBase-root": {
5285
- display: "flex",
5286
- alignItems: "flex-start",
5287
- backgroundColor: theme.palette.grey[100]
5288
- },
5289
- "& .MuiInputBase-inputMultiline": {
5290
- maxHeight: "100%",
5291
- overflowY: "auto"
5292
- }
5293
- }
5294
- }
5295
- )
5296
- ] })
5297
- ]
5298
- }
5299
- )
5300
- }
5301
- );
5302
- }
5303
5226
  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" }) });
5304
5227
  function UserSearch({ sx, inputSx, ...rest }) {
5305
5228
  var _a2;
@@ -5330,8 +5253,8 @@ function UserSearch({ sx, inputSx, ...rest }) {
5330
5253
  }
5331
5254
  );
5332
5255
  const mergedSx = mergeSx({}, sx);
5333
- return /* @__PURE__ */ jsxs(Box, { sx: mergedSx, ...rest, children: [
5334
- /* @__PURE__ */ jsx(
5256
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
5257
+ /* @__PURE__ */ jsx(Box, { sx: mergedSx, ...rest, children: /* @__PURE__ */ jsx(
5335
5258
  Autocomplete,
5336
5259
  {
5337
5260
  open,
@@ -5404,7 +5327,7 @@ function UserSearch({ sx, inputSx, ...rest }) {
5404
5327
  setInputValue(newInputValue);
5405
5328
  },
5406
5329
  renderInput: (params) => /* @__PURE__ */ jsx(
5407
- TextField$1,
5330
+ TextField,
5408
5331
  {
5409
5332
  ...params,
5410
5333
  placeholder: "Search user",
@@ -5426,7 +5349,7 @@ function UserSearch({ sx, inputSx, ...rest }) {
5426
5349
  isOptionEqualToValue: (option, value) => option.did === value.did,
5427
5350
  sx: { ".MuiAutocomplete-endAdornment": { display: "none" } }
5428
5351
  }
5429
- ),
5352
+ ) }),
5430
5353
  ReactDOM.createPortal(
5431
5354
  /* @__PURE__ */ jsx(Backdrop, { open, sx: { zIndex: "modal", bgcolor: "transparent" } }),
5432
5355
  window.document.body
@@ -5451,10 +5374,20 @@ function Empty$2({ sx }) {
5451
5374
  /* @__PURE__ */ jsx(Box$1, { component: "span", sx: { fontSize: 14, fontWeight: 500 }, children: t("chat.noChats") })
5452
5375
  ] });
5453
5376
  }
5454
- function Chat({ sx, ...rest }) {
5377
+ function Chat({ sx, ChannelEditComponent, ...rest }) {
5455
5378
  var _a2;
5456
- const { client: client2, initialized, chats, activeChatId, addChat, setActiveChat, getOppositeUser } = useChatContext();
5457
- const [newChannelVisible, setNewChannelVisible] = useState(false);
5379
+ const {
5380
+ client: client2,
5381
+ initialized,
5382
+ chats,
5383
+ activeChatId,
5384
+ addChat,
5385
+ updateChat,
5386
+ setActiveChat,
5387
+ getOppositeUser,
5388
+ editingChannel,
5389
+ setEditingChannel
5390
+ } = useChatContext();
5458
5391
  const downMd = useMediaQuery((theme) => theme.breakpoints.down("sm"));
5459
5392
  const { t } = useLocaleContext();
5460
5393
  const activeChat = (_a2 = chats == null ? void 0 : chats.filter((chat) => (chat == null ? void 0 : chat.id) === activeChatId)) == null ? void 0 : _a2[0];
@@ -5500,12 +5433,18 @@ function Chat({ sx, ...rest }) {
5500
5433
  );
5501
5434
  }
5502
5435
  const mergedSx = [{ display: "flex", height: "100%", bgcolor: "#fff" }, ...Array.isArray(sx) ? sx : [sx]];
5503
- const handleNewChannel = async ({ name, description }) => {
5504
- const saved = await client2.createChannel(name, description);
5505
- const newChannel = { ...saved, hasJoined: true };
5506
- addChat(newChannel);
5507
- setNewChannelVisible(false);
5508
- setActiveChat(newChannel);
5436
+ const handleChannelEdit = async (payload) => {
5437
+ if (payload.id) {
5438
+ await client2.updateChannel(payload);
5439
+ updateChat(payload.id, (chat) => ({ ...chat, ...payload }));
5440
+ setEditingChannel(null);
5441
+ } else {
5442
+ const saved = await client2.createChannel(payload);
5443
+ const newChannel = { ...saved, hasJoined: true };
5444
+ addChat(newChannel);
5445
+ setEditingChannel(null);
5446
+ setActiveChat(newChannel);
5447
+ }
5509
5448
  };
5510
5449
  return /* @__PURE__ */ jsxs(Box$1, { ...rest, sx: mergedSx, children: [
5511
5450
  /* @__PURE__ */ jsx(Helmet, { title: getWebTitle() }),
@@ -5536,7 +5475,7 @@ function Chat({ sx, ...rest }) {
5536
5475
  /* @__PURE__ */ jsx(AccessControl, { roles: ["owner", "admin"], children: /* @__PURE__ */ jsx(
5537
5476
  IconButton$1,
5538
5477
  {
5539
- onClick: () => setNewChannelVisible(true),
5478
+ onClick: () => setEditingChannel({ name: "", description: "" }),
5540
5479
  sx: { p: 1, borderRadius: 1, border: 1, borderColor: "grey.200", height: 32, width: 32 },
5541
5480
  children: /* @__PURE__ */ jsx(Add, { sx: { color: "#000" } })
5542
5481
  }
@@ -5555,14 +5494,13 @@ function Chat({ sx, ...rest }) {
5555
5494
  }),
5556
5495
  !activeChatId && /* @__PURE__ */ jsx(Empty$2, { sx: { height: 1 } })
5557
5496
  ] }),
5558
- /* @__PURE__ */ jsx(
5559
- NewChannelDialog,
5497
+ ChannelEditComponent && /* @__PURE__ */ jsx(
5498
+ ChannelEditComponent,
5560
5499
  {
5561
- open: newChannelVisible,
5562
- onClose: () => setNewChannelVisible(false),
5563
- onSubmit: handleNewChannel
5564
- },
5565
- newChannelVisible ? 1 : 0
5500
+ initialValue: editingChannel,
5501
+ onClose: () => setEditingChannel(null),
5502
+ onSubmit: handleChannelEdit
5503
+ }
5566
5504
  )
5567
5505
  ] });
5568
5506
  }
@@ -6218,10 +6156,10 @@ const en = {
6218
6156
  reply: "Reply",
6219
6157
  unknown: "Unknown",
6220
6158
  chats: "Chats",
6221
- create: "Create",
6222
6159
  channel: "Channel",
6223
6160
  description: "Description",
6224
6161
  newChannel: "New channel",
6162
+ updateChannel: "Update channel",
6225
6163
  noChats: "No chats",
6226
6164
  unknownChannel: "Unknown Channel",
6227
6165
  channelDescription: "Channel Description",
@@ -6249,7 +6187,8 @@ const en = {
6249
6187
  loadMore: "Load older messages",
6250
6188
  notYetJoinedTheChannel: "Not yet joined the channel",
6251
6189
  typeSomething: "Type here. Use Markdown, Drag or paste images",
6252
- send: "Send"
6190
+ send: "Send",
6191
+ selectBoardTip: "Only board members can join board-specific channels"
6253
6192
  },
6254
6193
  userActionLog: {
6255
6194
  editedCapital: "Edited",
@@ -6311,6 +6250,7 @@ const zh = {
6311
6250
  channel: "频道",
6312
6251
  description: "描述",
6313
6252
  newChannel: "新的频道",
6253
+ updateChannel: "更新频道",
6314
6254
  noChats: "暂无对话",
6315
6255
  unknownChannel: "未命名的频道",
6316
6256
  channelDescription: "频道描述",
@@ -6338,7 +6278,8 @@ const zh = {
6338
6278
  loadMore: "加载更多消息",
6339
6279
  notYetJoinedTheChannel: "暂未加入这个频道",
6340
6280
  typeSomething: "在这里输入,适用 MarkDown,拽入或者黏贴图片",
6341
- send: "发送"
6281
+ send: "发送",
6282
+ selectBoardTip: "只有 board 成员可以加入 board 专属频道"
6342
6283
  },
6343
6284
  userActionLog: {
6344
6285
  editedCapital: "编辑",
@@ -11921,7 +11862,7 @@ function PointUp({ points }) {
11921
11862
  fontWeight: "bold"
11922
11863
  },
11923
11864
  children: t("common.pointUp", {
11924
- points
11865
+ points: points + ""
11925
11866
  })
11926
11867
  }
11927
11868
  )
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, ar, N, am, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-vYGfcLWv.mjs";
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, ar, N, am, as, l, f, p, r, j, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-DDQnH71T.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/react-hooks"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("semver-compare"), require("@arcblock/bridge"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@blocklet/editor/lib/ext/EditorHolderPlugin"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("react-dom"), require("ufo"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("url-join"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/colors/grey"), require("@blocklet/editor"), require("@mui/material/Fab"), require("lodash/debounce"), require("@blocklet/editor/lib/main/hooks/useIsFocused"), require("@blocklet/editor/lib/ext/BusyPlugin"), require("@mui/material/TextField"), require("@mui/icons-material/Add"), require("@mui/icons-material/ArrowBackIos"), require("@mui/icons-material/ShortText"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), require("@emotion/css"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("@blocklet/editor/lib/main/nodes/ImageNode"), require("@blocklet/editor/lib/ext/VideoPlugin/VideoNode")) : typeof define === "function" && define.amd ? define(["exports", "@blocklet/labels", "react/jsx-runtime", "@mui/material/styles", "@arcblock/ux/lib/Theme", "react", "@mui/material", "lodash/isNil", "@blocklet/editor/lib/config", "react-lazy-with-preload", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/material/Box", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "lodash/isBoolean", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/AvatarGroup", "@mui/material/colors", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@arcblock/react-hooks", "@arcblock/ux/lib/RelativeTime", "@mui/material/Chip", "@mui/material/Stack", "lodash/groupBy", "lodash/flatMap", "lodash/uniqBy", "lodash/trim", "@mui/material/Avatar", "@mui/icons-material/BrokenImage", "@iconify/react", "@arcblock/ux/lib/Empty", "@arcblock/did-connect/lib/Session", "semver-compare", "@arcblock/bridge", "@mui/icons-material/NotificationsActiveOutlined", "@blocklet/editor/lib/ext/CheckboxPlugin", "@arcblock/did-connect/lib/Address", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@blocklet/editor/lib/ext/EditorHolderPlugin", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "react-dom", "ufo", "dayjs", "dayjs/plugin/relativeTime", "url-join", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/colors/grey", "@blocklet/editor", "@mui/material/Fab", "lodash/debounce", "@blocklet/editor/lib/main/hooks/useIsFocused", "@blocklet/editor/lib/ext/BusyPlugin", "@mui/material/TextField", "@mui/icons-material/Add", "@mui/icons-material/ArrowBackIos", "@mui/icons-material/ShortText", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@emotion/css", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "@blocklet/editor/lib/main/nodes/ImageNode", "@blocklet/editor/lib/ext/VideoPlugin/VideoNode"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitComponents = {}, global.labels, global.jsxRuntime, global.styles, global.Theme, global.react, global.material, global.isNil, global.config, global.reactLazyWithPreload, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.Box, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.AvatarGroup, global.colors, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.reactHooks, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$3, global.Session, global.cmp, global.bridge, global.NotificationsActiveOutlinedIcon, global.CheckboxPlugin, global.DIDAddress, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.EditorHolderPlugin, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.ReactDOM, global.ufo, global.dayjs, global.relativeTime, global.joinUrl, global.mitt, global.CircularProgress, global.reactHelmet, global.reactFlipToolkit, global.grey, global.editor$1, global.Fab, global.debounce, global.useIsFocused, global.BusyPlugin, global.TextField, global.AddIcon, global.ArrowBackIosIcon, global.ShortTextIcon, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.css, global.OnContentChangePlugin, global.ShortcutPlugin$1, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
3
- })(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, Box, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, AvatarGroup, colors, useMediaQuery, DID, Tooltip, reactRouterDom, reactHooks, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$3, Session, cmp, bridge, NotificationsActiveOutlinedIcon, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, EditorHolderPlugin, Dialog, orderBy, Typography, Skeleton, ReactDOM, ufo, dayjs, relativeTime, joinUrl, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, editor$1, Fab, debounce, useIsFocused, BusyPlugin, TextField, AddIcon, ArrowBackIosIcon, ShortTextIcon, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, css, OnContentChangePlugin, ShortcutPlugin$1, SafeAreaPlugin, text, ImageNode, VideoNode) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/react-hooks"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("semver-compare"), require("@arcblock/bridge"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@blocklet/editor/lib/ext/EditorHolderPlugin"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("react-dom"), require("ufo"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("url-join"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/colors/grey"), require("@blocklet/editor"), require("@mui/material/Fab"), require("lodash/debounce"), require("@blocklet/editor/lib/main/hooks/useIsFocused"), require("@blocklet/editor/lib/ext/BusyPlugin"), require("@mui/icons-material/ArrowBackIos"), require("@mui/icons-material/ShortText"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), require("@emotion/css"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("@blocklet/editor/lib/main/nodes/ImageNode"), require("@blocklet/editor/lib/ext/VideoPlugin/VideoNode")) : typeof define === "function" && define.amd ? define(["exports", "@blocklet/labels", "react/jsx-runtime", "@mui/material/styles", "@arcblock/ux/lib/Theme", "react", "@mui/material", "lodash/isNil", "@blocklet/editor/lib/config", "react-lazy-with-preload", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/material/Box", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "lodash/isBoolean", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/AvatarGroup", "@mui/material/colors", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@arcblock/react-hooks", "@arcblock/ux/lib/RelativeTime", "@mui/material/Chip", "@mui/material/Stack", "lodash/groupBy", "lodash/flatMap", "lodash/uniqBy", "lodash/trim", "@mui/material/Avatar", "@mui/icons-material/BrokenImage", "@iconify/react", "@arcblock/ux/lib/Empty", "@arcblock/did-connect/lib/Session", "semver-compare", "@arcblock/bridge", "@mui/icons-material/NotificationsActiveOutlined", "@blocklet/editor/lib/ext/CheckboxPlugin", "@arcblock/did-connect/lib/Address", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@blocklet/editor/lib/ext/EditorHolderPlugin", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "react-dom", "ufo", "dayjs", "dayjs/plugin/relativeTime", "url-join", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/colors/grey", "@blocklet/editor", "@mui/material/Fab", "lodash/debounce", "@blocklet/editor/lib/main/hooks/useIsFocused", "@blocklet/editor/lib/ext/BusyPlugin", "@mui/icons-material/ArrowBackIos", "@mui/icons-material/ShortText", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@emotion/css", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "@blocklet/editor/lib/main/nodes/ImageNode", "@blocklet/editor/lib/ext/VideoPlugin/VideoNode"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitComponents = {}, global.labels, global.jsxRuntime, global.styles, global.Theme, global.react, global.material, global.isNil, global.config, global.reactLazyWithPreload, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.Box, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.AvatarGroup, global.colors, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.reactHooks, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$3, global.Session, global.cmp, global.bridge, global.NotificationsActiveOutlinedIcon, global.CheckboxPlugin, global.DIDAddress, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.EditorHolderPlugin, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.ReactDOM, global.ufo, global.dayjs, global.relativeTime, global.joinUrl, global.mitt, global.CircularProgress, global.reactHelmet, global.reactFlipToolkit, global.grey, global.editor$1, global.Fab, global.debounce, global.useIsFocused, global.BusyPlugin, global.ArrowBackIosIcon, global.ShortTextIcon, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.css, global.OnContentChangePlugin, global.ShortcutPlugin$1, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
3
+ })(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, Box, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, AvatarGroup, colors, useMediaQuery, DID, Tooltip, reactRouterDom, reactHooks, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$3, Session, cmp, bridge, NotificationsActiveOutlinedIcon, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, EditorHolderPlugin, Dialog, orderBy, Typography, Skeleton, ReactDOM, ufo, dayjs, relativeTime, joinUrl, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, editor$1, Fab, debounce, useIsFocused, BusyPlugin, ArrowBackIosIcon, ShortTextIcon, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, css, OnContentChangePlugin, ShortcutPlugin$1, SafeAreaPlugin, text, ImageNode, VideoNode) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -764,7 +764,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
764
764
  }
765
765
 
766
766
  // use avatarGroup first is last
767
- .avatars-item:first-child {
767
+ .avatars-item:first-of-type {
768
768
  width: 24px;
769
769
  }
770
770
 
@@ -3725,6 +3725,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3725
3725
  initialized: false,
3726
3726
  chats: [],
3727
3727
  activeChatId: void 0,
3728
+ editingChannel: null,
3728
3729
  error: void 0
3729
3730
  });
3730
3731
  const { markAsUnread } = useUnreadNotification();
@@ -3978,6 +3979,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3978
3979
  loadMessages,
3979
3980
  sendMessage,
3980
3981
  addChat,
3982
+ updateChat,
3981
3983
  initChatRoom,
3982
3984
  joinChannel,
3983
3985
  leaveChannel,
@@ -3987,7 +3989,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
3987
3989
  orderedChats,
3988
3990
  getLastMessageText,
3989
3991
  isInWallet,
3990
- createDM
3992
+ createDM,
3993
+ setEditingChannel: (payload) => setState((prev) => ({ ...prev, editingChannel: payload }))
3991
3994
  };
3992
3995
  }, [state, client2, currentUser == null ? void 0 : currentUser.did]);
3993
3996
  return /* @__PURE__ */ jsxRuntime.jsx(ChatContext.Provider, { value, children });
@@ -4392,7 +4395,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4392
4395
  const { points, post, comment, eventKey = "" } = message;
4393
4396
  const unit = points > 1 ? t("chat.points") : t("chat.point");
4394
4397
  const event = eventKey ? `for ${eventKey.toLowerCase().replaceAll("-", " ")}: ` : ": ";
4395
- const tip = t("chat.pointUp", { points, unit, event });
4398
+ const tip = t("chat.pointUp", { points: points + "", unit, event });
4396
4399
  return /* @__PURE__ */ jsxRuntime.jsxs(Box, { children: [
4397
4400
  /* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { color: "grey.600" }, children: tip }),
4398
4401
  comment && /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body1", children: comment.excerpt }),
@@ -4977,7 +4980,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4977
4980
  const { t } = context.useLocaleContext();
4978
4981
  const theme = styles.useTheme();
4979
4982
  const downSm = material.useMediaQuery((currentTheme) => currentTheme.breakpoints.down("sm"));
4980
- const { initChatRoom, isActiveChat, getOppositeUser, sendMessage, joinChannel, leaveChannel, deleteChannel } = useChatContext();
4983
+ const {
4984
+ initChatRoom,
4985
+ isActiveChat,
4986
+ getOppositeUser,
4987
+ sendMessage,
4988
+ joinChannel,
4989
+ leaveChannel,
4990
+ deleteChannel,
4991
+ setEditingChannel
4992
+ } = useChatContext();
4981
4993
  const { confirm } = useConfirm();
4982
4994
  const isActive = isActiveChat(chat.id);
4983
4995
  const { session, isAdmin } = useSessionContext();
@@ -5023,6 +5035,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5023
5035
  }
5024
5036
  if (isAdmin || isCreator) {
5025
5037
  menuItems.push(
5038
+ /* @__PURE__ */ jsxRuntime.jsx(Menu.Item, { onClick: () => setEditingChannel(chat), children: /* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", children: "Edit" }) }, "edit"),
5026
5039
  /* @__PURE__ */ jsxRuntime.jsx(Menu.Item, { onClick: handleDeleteChannel, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { color: "error.main" }, children: t("chat.deleteChannel") }) }, "delete")
5027
5040
  );
5028
5041
  }
@@ -5134,94 +5147,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5134
5147
  ] })
5135
5148
  ] });
5136
5149
  }
5137
- function NewChannelDialog({ open, onSubmit, onClose, ...rest }) {
5138
- const [state, setState] = ahooks.useSetState({
5139
- name: "",
5140
- description: ""
5141
- });
5142
- const { t } = context.useLocaleContext();
5143
- const theme = styles.useTheme();
5144
- const canSubmit = react.useMemo(() => {
5145
- return state.name;
5146
- }, [state]);
5147
- const handleSubmit = () => {
5148
- onSubmit(state);
5149
- };
5150
- return /* @__PURE__ */ jsxRuntime.jsx(
5151
- Dialog,
5152
- {
5153
- open,
5154
- showCloseButton: true,
5155
- maxWidth: "lg",
5156
- title: t("chat.newChannel"),
5157
- actions: /* @__PURE__ */ jsxRuntime.jsxs(Button, { color: "primary", variant: "contained", size: "small", onClick: handleSubmit, disabled: !canSubmit, children: [
5158
- /* @__PURE__ */ jsxRuntime.jsx(AddIcon, { sx: { mr: 0.375 } }),
5159
- t("chat.create")
5160
- ] }),
5161
- onClose,
5162
- ...rest,
5163
- children: /* @__PURE__ */ jsxRuntime.jsxs(
5164
- Box,
5165
- {
5166
- width: { xs: "100%", md: 560 },
5167
- sx: {
5168
- display: "flex",
5169
- flexDirection: "column",
5170
- gap: 2,
5171
- lineHeight: 1.75
5172
- },
5173
- minHeight: 140,
5174
- children: [
5175
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { children: [
5176
- /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { fontSize: 14, fontWeight: "medium", mb: 0 }, children: t("chat.channelName") }),
5177
- /* @__PURE__ */ jsxRuntime.jsx(
5178
- TextField,
5179
- {
5180
- value: state.name,
5181
- placeholder: t("chat.channelName"),
5182
- size: "small",
5183
- fullWidth: true,
5184
- sx: {
5185
- "& .MuiInputBase-root": {
5186
- height: 40,
5187
- backgroundColor: theme.palette.grey[100]
5188
- }
5189
- },
5190
- onChange: (e) => setState({ name: e.target.value })
5191
- }
5192
- )
5193
- ] }),
5194
- /* @__PURE__ */ jsxRuntime.jsxs(Box, { children: [
5195
- /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { fontSize: 14, fontWeight: "medium", mb: 0 }, children: t("chat.channelDescription") }),
5196
- /* @__PURE__ */ jsxRuntime.jsx(
5197
- TextField,
5198
- {
5199
- value: state.description,
5200
- placeholder: t("chat.channelDescription"),
5201
- fullWidth: true,
5202
- multiline: true,
5203
- onChange: (e) => setState({ description: e.target.value }),
5204
- minRows: 2,
5205
- sx: {
5206
- "& .MuiInputBase-root": {
5207
- display: "flex",
5208
- alignItems: "flex-start",
5209
- backgroundColor: theme.palette.grey[100]
5210
- },
5211
- "& .MuiInputBase-inputMultiline": {
5212
- maxHeight: "100%",
5213
- overflowY: "auto"
5214
- }
5215
- }
5216
- }
5217
- )
5218
- ] })
5219
- ]
5220
- }
5221
- )
5222
- }
5223
- );
5224
- }
5225
5150
  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" }) });
5226
5151
  function UserSearch({ sx, inputSx, ...rest }) {
5227
5152
  var _a2;
@@ -5252,8 +5177,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5252
5177
  }
5253
5178
  );
5254
5179
  const mergedSx = mergeSx({}, sx);
5255
- return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: mergedSx, ...rest, children: [
5256
- /* @__PURE__ */ jsxRuntime.jsx(
5180
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5181
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: mergedSx, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(
5257
5182
  material.Autocomplete,
5258
5183
  {
5259
5184
  open,
@@ -5348,7 +5273,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5348
5273
  isOptionEqualToValue: (option, value) => option.did === value.did,
5349
5274
  sx: { ".MuiAutocomplete-endAdornment": { display: "none" } }
5350
5275
  }
5351
- ),
5276
+ ) }),
5352
5277
  ReactDOM.createPortal(
5353
5278
  /* @__PURE__ */ jsxRuntime.jsx(material.Backdrop, { open, sx: { zIndex: "modal", bgcolor: "transparent" } }),
5354
5279
  window.document.body
@@ -5373,10 +5298,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5373
5298
  /* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { fontSize: 14, fontWeight: 500 }, children: t("chat.noChats") })
5374
5299
  ] });
5375
5300
  }
5376
- function Chat({ sx, ...rest }) {
5301
+ function Chat({ sx, ChannelEditComponent, ...rest }) {
5377
5302
  var _a2;
5378
- const { client: client2, initialized, chats, activeChatId, addChat, setActiveChat, getOppositeUser } = useChatContext();
5379
- const [newChannelVisible, setNewChannelVisible] = react.useState(false);
5303
+ const {
5304
+ client: client2,
5305
+ initialized,
5306
+ chats,
5307
+ activeChatId,
5308
+ addChat,
5309
+ updateChat,
5310
+ setActiveChat,
5311
+ getOppositeUser,
5312
+ editingChannel,
5313
+ setEditingChannel
5314
+ } = useChatContext();
5380
5315
  const downMd = material.useMediaQuery((theme) => theme.breakpoints.down("sm"));
5381
5316
  const { t } = context.useLocaleContext();
5382
5317
  const activeChat = (_a2 = chats == null ? void 0 : chats.filter((chat) => (chat == null ? void 0 : chat.id) === activeChatId)) == null ? void 0 : _a2[0];
@@ -5422,12 +5357,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5422
5357
  );
5423
5358
  }
5424
5359
  const mergedSx = [{ display: "flex", height: "100%", bgcolor: "#fff" }, ...Array.isArray(sx) ? sx : [sx]];
5425
- const handleNewChannel = async ({ name, description }) => {
5426
- const saved = await client2.createChannel(name, description);
5427
- const newChannel = { ...saved, hasJoined: true };
5428
- addChat(newChannel);
5429
- setNewChannelVisible(false);
5430
- setActiveChat(newChannel);
5360
+ const handleChannelEdit = async (payload) => {
5361
+ if (payload.id) {
5362
+ await client2.updateChannel(payload);
5363
+ updateChat(payload.id, (chat) => ({ ...chat, ...payload }));
5364
+ setEditingChannel(null);
5365
+ } else {
5366
+ const saved = await client2.createChannel(payload);
5367
+ const newChannel = { ...saved, hasJoined: true };
5368
+ addChat(newChannel);
5369
+ setEditingChannel(null);
5370
+ setActiveChat(newChannel);
5371
+ }
5431
5372
  };
5432
5373
  return /* @__PURE__ */ jsxRuntime.jsxs(Box, { ...rest, sx: mergedSx, children: [
5433
5374
  /* @__PURE__ */ jsxRuntime.jsx(reactHelmet.Helmet, { title: getWebTitle() }),
@@ -5458,7 +5399,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5458
5399
  /* @__PURE__ */ jsxRuntime.jsx(AccessControl, { roles: ["owner", "admin"], children: /* @__PURE__ */ jsxRuntime.jsx(
5459
5400
  IconButton$1,
5460
5401
  {
5461
- onClick: () => setNewChannelVisible(true),
5402
+ onClick: () => setEditingChannel({ name: "", description: "" }),
5462
5403
  sx: { p: 1, borderRadius: 1, border: 1, borderColor: "grey.200", height: 32, width: 32 },
5463
5404
  children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.Add, { sx: { color: "#000" } })
5464
5405
  }
@@ -5477,14 +5418,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5477
5418
  }),
5478
5419
  !activeChatId && /* @__PURE__ */ jsxRuntime.jsx(Empty$2, { sx: { height: 1 } })
5479
5420
  ] }),
5480
- /* @__PURE__ */ jsxRuntime.jsx(
5481
- NewChannelDialog,
5421
+ ChannelEditComponent && /* @__PURE__ */ jsxRuntime.jsx(
5422
+ ChannelEditComponent,
5482
5423
  {
5483
- open: newChannelVisible,
5484
- onClose: () => setNewChannelVisible(false),
5485
- onSubmit: handleNewChannel
5486
- },
5487
- newChannelVisible ? 1 : 0
5424
+ initialValue: editingChannel,
5425
+ onClose: () => setEditingChannel(null),
5426
+ onSubmit: handleChannelEdit
5427
+ }
5488
5428
  )
5489
5429
  ] });
5490
5430
  }
@@ -6140,10 +6080,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6140
6080
  reply: "Reply",
6141
6081
  unknown: "Unknown",
6142
6082
  chats: "Chats",
6143
- create: "Create",
6144
6083
  channel: "Channel",
6145
6084
  description: "Description",
6146
6085
  newChannel: "New channel",
6086
+ updateChannel: "Update channel",
6147
6087
  noChats: "No chats",
6148
6088
  unknownChannel: "Unknown Channel",
6149
6089
  channelDescription: "Channel Description",
@@ -6171,7 +6111,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6171
6111
  loadMore: "Load older messages",
6172
6112
  notYetJoinedTheChannel: "Not yet joined the channel",
6173
6113
  typeSomething: "Type here. Use Markdown, Drag or paste images",
6174
- send: "Send"
6114
+ send: "Send",
6115
+ selectBoardTip: "Only board members can join board-specific channels"
6175
6116
  },
6176
6117
  userActionLog: {
6177
6118
  editedCapital: "Edited",
@@ -6233,6 +6174,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6233
6174
  channel: "频道",
6234
6175
  description: "描述",
6235
6176
  newChannel: "新的频道",
6177
+ updateChannel: "更新频道",
6236
6178
  noChats: "暂无对话",
6237
6179
  unknownChannel: "未命名的频道",
6238
6180
  channelDescription: "频道描述",
@@ -6260,7 +6202,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6260
6202
  loadMore: "加载更多消息",
6261
6203
  notYetJoinedTheChannel: "暂未加入这个频道",
6262
6204
  typeSomething: "在这里输入,适用 MarkDown,拽入或者黏贴图片",
6263
- send: "发送"
6205
+ send: "发送",
6206
+ selectBoardTip: "只有 board 成员可以加入 board 专属频道"
6264
6207
  },
6265
6208
  userActionLog: {
6266
6209
  editedCapital: "编辑",
@@ -11843,7 +11786,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
11843
11786
  fontWeight: "bold"
11844
11787
  },
11845
11788
  children: t("common.pointUp", {
11846
- points
11789
+ points: points + ""
11847
11790
  })
11848
11791
  }
11849
11792
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.1.46",
3
+ "version": "2.1.47",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -18,8 +18,8 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@arcblock/bridge": "^2.10.65",
22
- "@arcblock/react-hooks": "^2.10.65",
21
+ "@arcblock/bridge": "^2.10.70",
22
+ "@arcblock/react-hooks": "^2.10.70",
23
23
  "@arcblock/ws": "^1.18.135",
24
24
  "@blocklet/uploader": "^0.1.51",
25
25
  "@emotion/css": "^11.13.0",
@@ -44,8 +44,8 @@
44
44
  "ufo": "^1.5.4",
45
45
  "unstated-next": "^1.1.0",
46
46
  "url-join": "^4.0.1",
47
- "@blocklet/editor": "^2.1.46",
48
- "@blocklet/labels": "^2.1.46"
47
+ "@blocklet/editor": "^2.1.47",
48
+ "@blocklet/labels": "^2.1.47"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@arcblock/did-connect": "^2.10.36",
@@ -1,11 +0,0 @@
1
- interface NewChannel {
2
- name: string;
3
- description: string;
4
- }
5
- interface NewChannelDialogProps {
6
- open: boolean;
7
- onClose: () => void;
8
- onSubmit: (payload: NewChannel) => void;
9
- }
10
- export default function NewChannelDialog({ open, onSubmit, onClose, ...rest }: NewChannelDialogProps): import("react/jsx-runtime").JSX.Element;
11
- export {};