@blocklet/discuss-kit-ux 1.6.153 → 1.6.156

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.
@@ -0,0 +1,16 @@
1
+ interface ButtonItem {
2
+ id: string;
3
+ title: string;
4
+ icon: string;
5
+ }
6
+ interface Props {
7
+ data: ButtonItem[];
8
+ theme: string;
9
+ selected: string[];
10
+ urlName: string;
11
+ defaultButton: ButtonItem;
12
+ onSelectTab: (selectTab: string[]) => void;
13
+ type: string;
14
+ }
15
+ export default function ButtonGroup({ data, theme, selected, urlName, defaultButton, onSelectTab, type, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1 @@
1
+ export { default as ButtonGroup } from './button-group';
@@ -28,6 +28,7 @@ interface ChatContextValue extends ChatState {
28
28
  hasUnreadMessages: (chat: ChatType) => boolean;
29
29
  deleteMessage: (chatId: string, messageId: string) => Promise<void>;
30
30
  refresh: () => Promise<void>;
31
+ orderedChats: ChatType[];
31
32
  }
32
33
  export declare const useChatContext: () => ChatContextValue;
33
34
  export declare function ChatProvider({ client, activeChatId, children }: ChatProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -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-0NOeD-2C.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-bzFgbBTK.mjs";
8
8
  import "@blocklet/labels";
9
9
  import "@mui/material/styles";
10
10
  import "@mui/material/Box";
@@ -58,6 +58,7 @@ import "dayjs/plugin/relativeTime";
58
58
  import "mitt";
59
59
  import "@mui/material/CircularProgress";
60
60
  import "react-helmet";
61
+ import "react-flip-toolkit";
61
62
  import "@mui/material/Fab";
62
63
  import "lodash/debounce";
63
64
  import "@mui/material/TextField";
@@ -67,6 +68,7 @@ import "@mui/material/Pagination";
67
68
  import "unstated-next";
68
69
  import "js-cookie";
69
70
  import "@arcblock/ws";
71
+ import "@emotion/css";
70
72
  const BlockletEditor = lazy(() => import("@blocklet/editor"));
71
73
  const Root = styled(Box)`
72
74
  .be-editable,
@@ -21,7 +21,7 @@ import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
21
21
  import { VideoNode } from "@blocklet/editor/lib/ext/VideoPlugin/VideoNode";
22
22
  import { useSize, useInViewport, useSetState, useGetState, useReactive } from "ahooks";
23
23
  import LoadingButton from "@mui/lab/LoadingButton";
24
- import { Send, Save, ChatBubbleOutlineOutlined, MoreVert, AddReactionOutlined, NavigateNext, DeleteOutlineOutlined, ContentCopy, ArrowUpward, ArrowDownward, ArrowBackIos, Add } from "@mui/icons-material";
24
+ import { Send, Save, ChatBubbleOutlineOutlined, MoreVert, AddReactionOutlined, NavigateNext, DeleteOutlineOutlined, ContentCopy, ArrowUpward, ArrowDownward, ArrowBackIos, Add, BorderColorOutlined } from "@mui/icons-material";
25
25
  import { LocaleContext, useLocaleContext } from "@arcblock/ux/lib/Locale/context";
26
26
  import Alert from "@mui/material/Alert";
27
27
  import isBoolean from "lodash/isBoolean";
@@ -61,6 +61,7 @@ import relativeTime from "dayjs/plugin/relativeTime";
61
61
  import mitt from "mitt";
62
62
  import CircularProgress from "@mui/material/CircularProgress";
63
63
  import { Helmet } from "react-helmet";
64
+ import { Flipper, Flipped } from "react-flip-toolkit";
64
65
  import Fab from "@mui/material/Fab";
65
66
  import debounce from "lodash/debounce";
66
67
  import TextField from "@mui/material/TextField";
@@ -70,6 +71,7 @@ import MuiPagination from "@mui/material/Pagination";
70
71
  import { createContainer } from "unstated-next";
71
72
  import Cookie from "js-cookie";
72
73
  import { WsClient } from "@arcblock/ws";
74
+ import { css } from "@emotion/css";
73
75
  const themeOverrides = {
74
76
  components: {
75
77
  MuiButton: {
@@ -3368,6 +3370,9 @@ function ChatProvider({ client: client2, activeChatId, children }) {
3368
3370
  const navigate = useNavigate();
3369
3371
  const { session } = useSessionContext();
3370
3372
  const currentUser = session == null ? void 0 : session.user;
3373
+ const orderedChats = useMemo(() => {
3374
+ return orderBy(state.chats, (x) => x.lastMessageAt || "", "desc");
3375
+ }, [state.chats]);
3371
3376
  const hasUnreadMessages = ({ lastMessageAt, lastAckTime }) => {
3372
3377
  if (lastMessageAt && (!lastAckTime || lastMessageAt > lastAckTime)) {
3373
3378
  return true;
@@ -3575,13 +3580,14 @@ function ChatProvider({ client: client2, activeChatId, children }) {
3575
3580
  deleteChannel,
3576
3581
  deleteMessage,
3577
3582
  hasUnreadMessages,
3578
- refresh
3583
+ refresh,
3584
+ orderedChats
3579
3585
  };
3580
3586
  }, [state, client2, currentUser == null ? void 0 : currentUser.did]);
3581
3587
  return /* @__PURE__ */ jsx(ChatContext.Provider, { value, children });
3582
3588
  }
3583
3589
  function ChatList(props) {
3584
- const { chats, activeChatId, setActiveChat, getOppositeUser, hasUnreadMessages } = useChatContext();
3590
+ const { orderedChats, activeChatId, setActiveChat, getOppositeUser, hasUnreadMessages } = useChatContext();
3585
3591
  const renderItem = (chat) => {
3586
3592
  if (chat.type === "notification") {
3587
3593
  return /* @__PURE__ */ jsx(SystemUser, { name: "Notification" });
@@ -3598,10 +3604,10 @@ function ChatList(props) {
3598
3604
  }
3599
3605
  return null;
3600
3606
  };
3601
- return /* @__PURE__ */ jsx(Box, { ...props, children: chats.map((chat) => {
3607
+ return /* @__PURE__ */ jsx(Box, { ...props, children: /* @__PURE__ */ jsx(Flipper, { flipKey: orderedChats.map((x) => x.id).join(""), children: orderedChats.map((chat) => {
3602
3608
  const isActiveChat = activeChatId === chat.id;
3603
3609
  const _hasUnreadMessages = hasUnreadMessages(chat) && (chat.type !== "channel" || chat.hasJoined);
3604
- return /* @__PURE__ */ jsxs(
3610
+ return /* @__PURE__ */ jsx(Flipped, { flipId: chat.id, children: /* @__PURE__ */ jsxs(
3605
3611
  Box,
3606
3612
  {
3607
3613
  sx: {
@@ -3633,10 +3639,9 @@ function ChatList(props) {
3633
3639
  }
3634
3640
  )
3635
3641
  ]
3636
- },
3637
- chat.id
3638
- );
3639
- }) });
3642
+ }
3643
+ ) }, chat.id);
3644
+ }) }) });
3640
3645
  }
3641
3646
  function Message({ message, showTime = true, ...rest }) {
3642
3647
  var _a2;
@@ -4558,7 +4563,7 @@ function Pagination({ page, size = 20, total, onChange, routerMode = true, ...re
4558
4563
  }
4559
4564
  );
4560
4565
  }
4561
- const Editor = lazy(() => import("./editor-8KrQFW0-.mjs"));
4566
+ const Editor = lazy(() => import("./editor-DQIO9RKL.mjs"));
4562
4567
  function LazyEditor(props) {
4563
4568
  const fallback = /* @__PURE__ */ jsxs(Fragment, { children: [
4564
4569
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -10417,6 +10422,161 @@ function PointUpProvider({ children }) {
10417
10422
  children
10418
10423
  ] });
10419
10424
  }
10425
+ function ButtonGroup({
10426
+ data,
10427
+ theme = "dark",
10428
+ selected,
10429
+ urlName,
10430
+ defaultButton,
10431
+ onSelectTab,
10432
+ type,
10433
+ ...rest
10434
+ }) {
10435
+ const downSm = useMediaQuery$1((mainTheme) => mainTheme.breakpoints.down("sm"));
10436
+ const [searchParams, setSearchParams] = useSearchParams();
10437
+ const selectedString = searchParams.get(urlName);
10438
+ const dataWithDefault = defaultButton ? [defaultButton, ...data] : data;
10439
+ const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault.map((item) => item.id);
10440
+ const [selectTab, setSelectTab] = useState(selectedArray);
10441
+ const [selectAll, setSelectAll] = useState(false);
10442
+ const updateUrl = (url, newSelectTab) => {
10443
+ setSearchParams({
10444
+ ...searchParams,
10445
+ [url]: newSelectTab.join(",")
10446
+ });
10447
+ };
10448
+ const handleClick = (item) => {
10449
+ setSelectTab([item.id]);
10450
+ updateUrl(urlName, [item.id]);
10451
+ };
10452
+ const handleSelectAll = () => {
10453
+ setSelectAll((prevSelectAll) => {
10454
+ const newSelectAll = !prevSelectAll;
10455
+ const newSelectTab = newSelectAll ? dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id) : [];
10456
+ setSelectTab(newSelectTab);
10457
+ updateUrl(urlName, newSelectTab);
10458
+ return newSelectAll;
10459
+ });
10460
+ };
10461
+ useEffect(() => {
10462
+ if (JSON.stringify(selectedArray) !== JSON.stringify(selectTab)) {
10463
+ setSelectTab((selectedArray == null ? void 0 : selectedArray.length) > 0 ? selectedArray : []);
10464
+ }
10465
+ }, [data]);
10466
+ useEffect(() => {
10467
+ if (selectedString === null || selectedString === "") {
10468
+ setSelectAll(true);
10469
+ } else if ((selectTab == null ? void 0 : selectTab.length) === (dataWithDefault == null ? void 0 : dataWithDefault.length)) {
10470
+ setSelectAll(true);
10471
+ } else {
10472
+ setSelectAll(false);
10473
+ }
10474
+ if (onSelectTab)
10475
+ onSelectTab(selectTab);
10476
+ }, [selectTab, selectedArray]);
10477
+ return /* @__PURE__ */ jsxs(Box$1, { className: Group, children: [
10478
+ /* @__PURE__ */ jsxs(
10479
+ Box$1,
10480
+ {
10481
+ sx: {
10482
+ bgcolor: theme === "dark" ? "#F9FAFB" : "",
10483
+ width: "fit-content",
10484
+ maxWidth: "calc(100% - 16px)",
10485
+ borderRadius: "99999px",
10486
+ borderTopRightRadius: downSm ? 0 : "99999px",
10487
+ borderBottomRightRadius: downSm ? 0 : "99999px",
10488
+ overflow: "scroll",
10489
+ whiteSpace: "nowrap"
10490
+ },
10491
+ children: [
10492
+ /* @__PURE__ */ jsx(
10493
+ Button$1,
10494
+ {
10495
+ onClick: handleSelectAll,
10496
+ sx: {
10497
+ backgroundColor: selectAll ? "#ffffff" : "",
10498
+ color: selectAll ? "#030712" : "#4b5563",
10499
+ border: selectAll ? "1px solid #e5e7eb!important" : "1px solid transparent"
10500
+ },
10501
+ ...rest,
10502
+ children: "All"
10503
+ }
10504
+ ),
10505
+ dataWithDefault == null ? void 0 : dataWithDefault.map((item, index) => {
10506
+ const isActive = !selectAll && (selectTab == null ? void 0 : selectTab.includes(item.id));
10507
+ return /* @__PURE__ */ jsx(
10508
+ Button$1,
10509
+ {
10510
+ onClick: () => handleClick(item),
10511
+ sx: {
10512
+ ...isActive && {
10513
+ backgroundColor: "#ffffff",
10514
+ color: "#030712",
10515
+ border: "1px solid #e5e7eb!important"
10516
+ }
10517
+ },
10518
+ ...rest,
10519
+ children: /* @__PURE__ */ jsxs(Box$1, { sx: { display: "flex", alignItems: "center" }, children: [
10520
+ item == null ? void 0 : item.icon,
10521
+ " ",
10522
+ item == null ? void 0 : item.title
10523
+ ] })
10524
+ },
10525
+ index
10526
+ );
10527
+ })
10528
+ ]
10529
+ }
10530
+ ),
10531
+ urlName !== "type" && /* @__PURE__ */ jsx(AccessControl, { roles: ["admin", "owner"], children: /* @__PURE__ */ jsx(
10532
+ IconButton$1,
10533
+ {
10534
+ component: Link,
10535
+ color: "inherit",
10536
+ size: "small",
10537
+ to: `/discussions/boards?type=${type}`,
10538
+ sx: { color: "grey.500" },
10539
+ children: /* @__PURE__ */ jsx(BorderColorOutlined, { sx: { fontSize: 16 } })
10540
+ }
10541
+ ) })
10542
+ ] });
10543
+ }
10544
+ const Group = css`
10545
+ display: flex;
10546
+ flex-direction: row;
10547
+ .MuiButtonBase-root {
10548
+ border-radius: 9999px;
10549
+ color: #4b5563;
10550
+ margin: 5px 8px 5px 5px;
10551
+ padding: 5px 12px;
10552
+ line-height: 22px;
10553
+ font-size: 13px;
10554
+ border: 1px solid transparent;
10555
+ }
10556
+
10557
+ .MuiButtonBase-root:last-of-type {
10558
+ margin-right: 0;
10559
+ }
10560
+
10561
+ .MuiButtonBase-root:first-of-type {
10562
+ margin-left: 0;
10563
+ }
10564
+
10565
+ .MuiButtonBase-root:hover {
10566
+ background-color: #ffffff;
10567
+ color: #030712;
10568
+ border: 1px solid #e5e7eb;
10569
+ }
10570
+
10571
+ * {
10572
+ scrollbar-width: none; /* Firefox */
10573
+ -ms-overflow-style: none; /* IE and Edge */
10574
+ }
10575
+
10576
+ *::-webkit-scrollbar {
10577
+ display: none; /* Chrome, Safari and Opera */
10578
+ }
10579
+ `;
10420
10580
  export {
10421
10581
  UnreadNotificationProvider as $,
10422
10582
  Avatar as A,
@@ -10467,9 +10627,10 @@ export {
10467
10627
  composeImageUrl as ah,
10468
10628
  usePointUpContext as ai,
10469
10629
  PointUpProvider as aj,
10470
- create as ak,
10471
- getWsClient as al,
10472
- useSubscription as am,
10630
+ ButtonGroup as ak,
10631
+ create as al,
10632
+ getWsClient as am,
10633
+ useSubscription as an,
10473
10634
  InternalThemeProvider as b,
10474
10635
  Input as c,
10475
10636
  translations as d,
package/dist/index.d.ts CHANGED
@@ -24,5 +24,6 @@ export * as routes from './components/routes';
24
24
  export { default as preferences } from './preferences';
25
25
  export * from './components/uploader';
26
26
  export * from './components/point-up';
27
+ export * from './components/button-group';
27
28
  export * from './ws';
28
29
  export { default as RelativeTime } from './components/shared/relative-time';
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { N, j, Q, A, h, a8, B, y, F, z, H, U, T, W, Y, o, C, q, v, x, a0, a1, ac, a3, K, L, D, ab, aa, E, G, c, b, a9, M, P, aj, n, m, a7, R, S, a4, k, Z, $, ad, ag, af, ah, ak, J, al, l, p, r, t, d, a5, O, e, X, w, a2, a6, u, ai, am, _, ae, f } from "./index-0NOeD-2C.mjs";
2
+ import { N, j, Q, A, h, a8, B, y, F, z, H, ak, U, T, W, Y, o, C, q, v, x, a0, a1, ac, a3, K, L, D, ab, aa, E, G, c, b, a9, M, P, aj, n, m, a7, R, S, a4, k, Z, $, ad, ag, af, ah, al, J, am, l, p, r, t, d, a5, O, e, X, w, a2, a6, u, ai, an, _, ae, f } from "./index-bzFgbBTK.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
@@ -55,6 +55,7 @@ import "dayjs/plugin/relativeTime";
55
55
  import "mitt";
56
56
  import "@mui/material/CircularProgress";
57
57
  import "react-helmet";
58
+ import "react-flip-toolkit";
58
59
  import "@mui/material/Fab";
59
60
  import "lodash/debounce";
60
61
  import "@mui/material/TextField";
@@ -64,6 +65,7 @@ import "@mui/material/Pagination";
64
65
  import "unstated-next";
65
66
  import "js-cookie";
66
67
  import "@arcblock/ws";
68
+ import "@emotion/css";
67
69
  export {
68
70
  N as AccessControl,
69
71
  j as AuthorInfo,
@@ -76,6 +78,7 @@ export {
76
78
  F as BlogCard,
77
79
  z as BlogList,
78
80
  H as BlogPermaLink,
81
+ ak as ButtonGroup,
79
82
  U as Chat,
80
83
  T as ChatClient,
81
84
  W as ChatHeaderAddon,
@@ -115,9 +118,9 @@ export {
115
118
  ag as UploaderProvider,
116
119
  af as UploaderTrigger,
117
120
  ah as composeImageUrl,
118
- ak as create,
121
+ al as create,
119
122
  J as getBlogLink,
120
- al as getWsClient,
123
+ am as getWsClient,
121
124
  l as lexicalUtils,
122
125
  p as preferences,
123
126
  r as routes,
@@ -132,7 +135,7 @@ export {
132
135
  a6 as useDefaultApiErrorHandler,
133
136
  u as useNow,
134
137
  ai as usePointUpContext,
135
- am as useSubscription,
138
+ an as useSubscription,
136
139
  _ as useUnreadNotification,
137
140
  ae as useUploader,
138
141
  f as utils
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("react"), require("@mui/material/Box"), require("@arcblock/ux/lib/Theme"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), 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/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), 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("@mui/material/colors"), require("@arcblock/did-connect/lib/Session"), require("@mui/material"), require("@arcblock/did-connect/lib/Address"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("url-join"), require("react-dom"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("@mui/material/Fab"), require("lodash/debounce"), require("@mui/material/TextField"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), 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", "react", "@mui/material/Box", "@arcblock/ux/lib/Theme", "lodash/isNil", "@blocklet/editor/lib/config", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@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/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@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", "@mui/material/colors", "@arcblock/did-connect/lib/Session", "@mui/material", "@arcblock/did-connect/lib/Address", "@blocklet/editor/lib/ext/CheckboxPlugin", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "url-join", "react-dom", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "react-helmet", "@mui/material/Fab", "lodash/debounce", "@mui/material/TextField", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@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.react, global.Box, global.Theme, global.isNil, global.config, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$1, global.colors, global.Session, global.material, global.DIDAddress, global.CheckboxPlugin, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.joinUrl, global.reactDom, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.reactHelmet, global.Fab, global.debounce, global.TextField, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.OnContentChangePlugin, global.ShortcutPlugin, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
3
- })(this, function(exports2, labels, jsxRuntime, styles, react, Box, Theme, isNil, config, LexicalComposerContext, lexical$1, ahooks, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, useMediaQuery, DID, Tooltip, reactRouterDom, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$1, colors, Session, material, DIDAddress, CheckboxPlugin, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, joinUrl, reactDom, dayjs, relativeTime, mitt, CircularProgress, reactHelmet, Fab, debounce, TextField, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, OnContentChangePlugin, ShortcutPlugin, 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("react"), require("@mui/material/Box"), require("@arcblock/ux/lib/Theme"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), 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/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), 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("@mui/material/colors"), require("@arcblock/did-connect/lib/Session"), require("@mui/material"), require("@arcblock/did-connect/lib/Address"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("url-join"), require("react-dom"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/Fab"), require("lodash/debounce"), require("@mui/material/TextField"), 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", "react", "@mui/material/Box", "@arcblock/ux/lib/Theme", "lodash/isNil", "@blocklet/editor/lib/config", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@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/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@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", "@mui/material/colors", "@arcblock/did-connect/lib/Session", "@mui/material", "@arcblock/did-connect/lib/Address", "@blocklet/editor/lib/ext/CheckboxPlugin", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "url-join", "react-dom", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/Fab", "lodash/debounce", "@mui/material/TextField", "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.react, global.Box, global.Theme, global.isNil, global.config, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$1, global.colors, global.Session, global.material, global.DIDAddress, global.CheckboxPlugin, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.joinUrl, global.reactDom, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.reactHelmet, global.reactFlipToolkit, global.Fab, global.debounce, global.TextField, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.css, global.OnContentChangePlugin, global.ShortcutPlugin, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
3
+ })(this, function(exports2, labels, jsxRuntime, styles, react, Box, Theme, isNil, config, LexicalComposerContext, lexical$1, ahooks, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, useMediaQuery, DID, Tooltip, reactRouterDom, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$1, colors, Session, material, DIDAddress, CheckboxPlugin, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, joinUrl, reactDom, dayjs, relativeTime, mitt, CircularProgress, reactHelmet, reactFlipToolkit, Fab, debounce, TextField, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, css, OnContentChangePlugin, ShortcutPlugin, 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) => {
@@ -3307,6 +3307,9 @@ var __publicField = (obj, key, value) => {
3307
3307
  const navigate = reactRouterDom.useNavigate();
3308
3308
  const { session } = useSessionContext();
3309
3309
  const currentUser = session == null ? void 0 : session.user;
3310
+ const orderedChats = react.useMemo(() => {
3311
+ return orderBy(state.chats, (x) => x.lastMessageAt || "", "desc");
3312
+ }, [state.chats]);
3310
3313
  const hasUnreadMessages = ({ lastMessageAt, lastAckTime }) => {
3311
3314
  if (lastMessageAt && (!lastAckTime || lastMessageAt > lastAckTime)) {
3312
3315
  return true;
@@ -3514,13 +3517,14 @@ var __publicField = (obj, key, value) => {
3514
3517
  deleteChannel,
3515
3518
  deleteMessage,
3516
3519
  hasUnreadMessages,
3517
- refresh
3520
+ refresh,
3521
+ orderedChats
3518
3522
  };
3519
3523
  }, [state, client2, currentUser == null ? void 0 : currentUser.did]);
3520
3524
  return /* @__PURE__ */ jsxRuntime.jsx(ChatContext.Provider, { value, children });
3521
3525
  }
3522
3526
  function ChatList(props) {
3523
- const { chats, activeChatId, setActiveChat, getOppositeUser, hasUnreadMessages } = useChatContext();
3527
+ const { orderedChats, activeChatId, setActiveChat, getOppositeUser, hasUnreadMessages } = useChatContext();
3524
3528
  const renderItem = (chat) => {
3525
3529
  if (chat.type === "notification") {
3526
3530
  return /* @__PURE__ */ jsxRuntime.jsx(SystemUser, { name: "Notification" });
@@ -3537,10 +3541,10 @@ var __publicField = (obj, key, value) => {
3537
3541
  }
3538
3542
  return null;
3539
3543
  };
3540
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { ...props, children: chats.map((chat) => {
3544
+ return /* @__PURE__ */ jsxRuntime.jsx(Box, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(reactFlipToolkit.Flipper, { flipKey: orderedChats.map((x) => x.id).join(""), children: orderedChats.map((chat) => {
3541
3545
  const isActiveChat = activeChatId === chat.id;
3542
3546
  const _hasUnreadMessages = hasUnreadMessages(chat) && (chat.type !== "channel" || chat.hasJoined);
3543
- return /* @__PURE__ */ jsxRuntime.jsxs(
3547
+ return /* @__PURE__ */ jsxRuntime.jsx(reactFlipToolkit.Flipped, { flipId: chat.id, children: /* @__PURE__ */ jsxRuntime.jsxs(
3544
3548
  Box,
3545
3549
  {
3546
3550
  sx: {
@@ -3572,10 +3576,9 @@ var __publicField = (obj, key, value) => {
3572
3576
  }
3573
3577
  )
3574
3578
  ]
3575
- },
3576
- chat.id
3577
- );
3578
- }) });
3579
+ }
3580
+ ) }, chat.id);
3581
+ }) }) });
3579
3582
  }
3580
3583
  function Message({ message, showTime = true, ...rest }) {
3581
3584
  var _a2;
@@ -10356,6 +10359,161 @@ var __publicField = (obj, key, value) => {
10356
10359
  children
10357
10360
  ] });
10358
10361
  }
10362
+ function ButtonGroup({
10363
+ data,
10364
+ theme = "dark",
10365
+ selected,
10366
+ urlName,
10367
+ defaultButton,
10368
+ onSelectTab,
10369
+ type,
10370
+ ...rest
10371
+ }) {
10372
+ const downSm = useMediaQuery((mainTheme) => mainTheme.breakpoints.down("sm"));
10373
+ const [searchParams, setSearchParams] = reactRouterDom.useSearchParams();
10374
+ const selectedString = searchParams.get(urlName);
10375
+ const dataWithDefault = defaultButton ? [defaultButton, ...data] : data;
10376
+ const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault.map((item) => item.id);
10377
+ const [selectTab, setSelectTab] = react.useState(selectedArray);
10378
+ const [selectAll, setSelectAll] = react.useState(false);
10379
+ const updateUrl = (url, newSelectTab) => {
10380
+ setSearchParams({
10381
+ ...searchParams,
10382
+ [url]: newSelectTab.join(",")
10383
+ });
10384
+ };
10385
+ const handleClick = (item) => {
10386
+ setSelectTab([item.id]);
10387
+ updateUrl(urlName, [item.id]);
10388
+ };
10389
+ const handleSelectAll = () => {
10390
+ setSelectAll((prevSelectAll) => {
10391
+ const newSelectAll = !prevSelectAll;
10392
+ const newSelectTab = newSelectAll ? dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id) : [];
10393
+ setSelectTab(newSelectTab);
10394
+ updateUrl(urlName, newSelectTab);
10395
+ return newSelectAll;
10396
+ });
10397
+ };
10398
+ react.useEffect(() => {
10399
+ if (JSON.stringify(selectedArray) !== JSON.stringify(selectTab)) {
10400
+ setSelectTab((selectedArray == null ? void 0 : selectedArray.length) > 0 ? selectedArray : []);
10401
+ }
10402
+ }, [data]);
10403
+ react.useEffect(() => {
10404
+ if (selectedString === null || selectedString === "") {
10405
+ setSelectAll(true);
10406
+ } else if ((selectTab == null ? void 0 : selectTab.length) === (dataWithDefault == null ? void 0 : dataWithDefault.length)) {
10407
+ setSelectAll(true);
10408
+ } else {
10409
+ setSelectAll(false);
10410
+ }
10411
+ if (onSelectTab)
10412
+ onSelectTab(selectTab);
10413
+ }, [selectTab, selectedArray]);
10414
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { className: Group, children: [
10415
+ /* @__PURE__ */ jsxRuntime.jsxs(
10416
+ material.Box,
10417
+ {
10418
+ sx: {
10419
+ bgcolor: theme === "dark" ? "#F9FAFB" : "",
10420
+ width: "fit-content",
10421
+ maxWidth: "calc(100% - 16px)",
10422
+ borderRadius: "99999px",
10423
+ borderTopRightRadius: downSm ? 0 : "99999px",
10424
+ borderBottomRightRadius: downSm ? 0 : "99999px",
10425
+ overflow: "scroll",
10426
+ whiteSpace: "nowrap"
10427
+ },
10428
+ children: [
10429
+ /* @__PURE__ */ jsxRuntime.jsx(
10430
+ material.Button,
10431
+ {
10432
+ onClick: handleSelectAll,
10433
+ sx: {
10434
+ backgroundColor: selectAll ? "#ffffff" : "",
10435
+ color: selectAll ? "#030712" : "#4b5563",
10436
+ border: selectAll ? "1px solid #e5e7eb!important" : "1px solid transparent"
10437
+ },
10438
+ ...rest,
10439
+ children: "All"
10440
+ }
10441
+ ),
10442
+ dataWithDefault == null ? void 0 : dataWithDefault.map((item, index) => {
10443
+ const isActive = !selectAll && (selectTab == null ? void 0 : selectTab.includes(item.id));
10444
+ return /* @__PURE__ */ jsxRuntime.jsx(
10445
+ material.Button,
10446
+ {
10447
+ onClick: () => handleClick(item),
10448
+ sx: {
10449
+ ...isActive && {
10450
+ backgroundColor: "#ffffff",
10451
+ color: "#030712",
10452
+ border: "1px solid #e5e7eb!important"
10453
+ }
10454
+ },
10455
+ ...rest,
10456
+ children: /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", alignItems: "center" }, children: [
10457
+ item == null ? void 0 : item.icon,
10458
+ " ",
10459
+ item == null ? void 0 : item.title
10460
+ ] })
10461
+ },
10462
+ index
10463
+ );
10464
+ })
10465
+ ]
10466
+ }
10467
+ ),
10468
+ urlName !== "type" && /* @__PURE__ */ jsxRuntime.jsx(AccessControl, { roles: ["admin", "owner"], children: /* @__PURE__ */ jsxRuntime.jsx(
10469
+ IconButton$1,
10470
+ {
10471
+ component: reactRouterDom.Link,
10472
+ color: "inherit",
10473
+ size: "small",
10474
+ to: `/discussions/boards?type=${type}`,
10475
+ sx: { color: "grey.500" },
10476
+ children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.BorderColorOutlined, { sx: { fontSize: 16 } })
10477
+ }
10478
+ ) })
10479
+ ] });
10480
+ }
10481
+ const Group = css.css`
10482
+ display: flex;
10483
+ flex-direction: row;
10484
+ .MuiButtonBase-root {
10485
+ border-radius: 9999px;
10486
+ color: #4b5563;
10487
+ margin: 5px 8px 5px 5px;
10488
+ padding: 5px 12px;
10489
+ line-height: 22px;
10490
+ font-size: 13px;
10491
+ border: 1px solid transparent;
10492
+ }
10493
+
10494
+ .MuiButtonBase-root:last-of-type {
10495
+ margin-right: 0;
10496
+ }
10497
+
10498
+ .MuiButtonBase-root:first-of-type {
10499
+ margin-left: 0;
10500
+ }
10501
+
10502
+ .MuiButtonBase-root:hover {
10503
+ background-color: #ffffff;
10504
+ color: #030712;
10505
+ border: 1px solid #e5e7eb;
10506
+ }
10507
+
10508
+ * {
10509
+ scrollbar-width: none; /* Firefox */
10510
+ -ms-overflow-style: none; /* IE and Edge */
10511
+ }
10512
+
10513
+ *::-webkit-scrollbar {
10514
+ display: none; /* Chrome, Safari and Opera */
10515
+ }
10516
+ `;
10359
10517
  const BlockletEditor = react.lazy(() => import("@blocklet/editor"));
10360
10518
  const Root = material.styled(material.Box)`
10361
10519
  .be-editable,
@@ -10398,6 +10556,7 @@ var __publicField = (obj, key, value) => {
10398
10556
  exports2.BlogCard = BlogCard;
10399
10557
  exports2.BlogList = BlogListWrapper;
10400
10558
  exports2.BlogPermaLink = BlogPermaLink;
10559
+ exports2.ButtonGroup = ButtonGroup;
10401
10560
  exports2.Chat = Chat;
10402
10561
  exports2.ChatClient = ChatClient;
10403
10562
  exports2.ChatHeaderAddon = ChatHeaderAddon;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "1.6.153",
3
+ "version": "1.6.156",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@arcblock/ws": "^1.18.110",
32
- "@blocklet/editor": "1.6.153",
33
- "@blocklet/labels": "1.6.153",
32
+ "@blocklet/editor": "1.6.156",
33
+ "@blocklet/labels": "1.6.156",
34
34
  "@blocklet/uploader": "^0.0.73",
35
35
  "@emotion/css": "^11.10.5",
36
36
  "@emotion/react": "^11.10.5",
@@ -83,6 +83,7 @@
83
83
  "babel-loader": "^8.3.0",
84
84
  "react": "^18.2.0",
85
85
  "react-dom": "^18.2.0",
86
+ "react-flip-toolkit": "^7.1.0",
86
87
  "rollup-plugin-node-externals": "^5.1.3",
87
88
  "typescript": "^4.6.4",
88
89
  "unplugin-icons": "^0.14.14",
@@ -93,5 +94,5 @@
93
94
  "resolutions": {
94
95
  "react": "^18.2.0"
95
96
  },
96
- "gitHead": "1a99cad8310dc12901e2382e66bda73b444988e7"
97
+ "gitHead": "ed66f9bd22b4c0ea39be70562b2dd1b94fa63676"
97
98
  }