@blocklet/discuss-kit-ux 2.1.139 → 2.1.141
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,8 @@
|
|
|
1
|
+
import { default as hotToast } from 'react-hot-toast';
|
|
2
|
+
type Message = Parameters<typeof hotToast>[0];
|
|
3
|
+
export type ToastOptions = Parameters<typeof hotToast>[1];
|
|
4
|
+
type Toast = typeof hotToast & {
|
|
5
|
+
warning: (message: Message, options?: ToastOptions) => string;
|
|
6
|
+
};
|
|
7
|
+
declare let toast: Toast;
|
|
8
|
+
export { toast };
|
|
@@ -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 { lazyRetry } from "@arcblock/ux/lib/Util";
|
|
7
|
-
import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-
|
|
7
|
+
import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-BB0w4gSN.mjs";
|
|
8
8
|
const BlockletEditor = lazyRetry(() => import("@blocklet/editor"));
|
|
9
9
|
const Root = styled(Box)`
|
|
10
10
|
.be-editable,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
var _a, _b, _c, _d;
|
|
4
|
+
var _a, _b, _c, _d, _e;
|
|
5
5
|
import { Labels2, LabelPicker } from "@blocklet/labels";
|
|
6
6
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
7
7
|
import { useTheme, ThemeProvider, styled as styled$1 } from "@mui/material/styles";
|
|
@@ -77,7 +77,7 @@ import { useIsFocused } from "@blocklet/editor/lib/main/hooks/useIsFocused";
|
|
|
77
77
|
import { BusyPlugin } from "@blocklet/editor/lib/ext/BusyPlugin";
|
|
78
78
|
import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
|
|
79
79
|
import { AxiosError } from "axios";
|
|
80
|
-
import
|
|
80
|
+
import hotToast from "react-hot-toast";
|
|
81
81
|
import MuiPagination from "@mui/material/Pagination";
|
|
82
82
|
import { createContainer } from "unstated-next";
|
|
83
83
|
import Cookie from "js-cookie";
|
|
@@ -1024,13 +1024,13 @@ function Badge({
|
|
|
1024
1024
|
] }) : null;
|
|
1025
1025
|
}
|
|
1026
1026
|
const useSessionContext = () => {
|
|
1027
|
-
var _a2, _b2, _c2, _d2,
|
|
1027
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
1028
1028
|
const ctx = useContext(SessionContext) || {};
|
|
1029
1029
|
const roles = [...((_c2 = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.passports) == null ? void 0 : _c2.map((p) => p.name)) || [], "guest"];
|
|
1030
1030
|
const permissionSet = useMemo(() => {
|
|
1031
1031
|
var _a3, _b3;
|
|
1032
1032
|
return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
|
|
1033
|
-
}, [(
|
|
1033
|
+
}, [(_e2 = (_d2 = ctx.session) == null ? void 0 : _d2.user) == null ? void 0 : _e2.permissions]);
|
|
1034
1034
|
const hasAnyPassport = (passports) => {
|
|
1035
1035
|
if (!passports || passports.length === 0) {
|
|
1036
1036
|
return true;
|
|
@@ -1207,25 +1207,25 @@ const useChatInWallet = () => {
|
|
|
1207
1207
|
const navigate = useNavigate();
|
|
1208
1208
|
const { walletVersion, mobile } = useBrowser();
|
|
1209
1209
|
const chatInWallet = useMatch("/chat-in-wallet/:chatId?");
|
|
1210
|
-
const
|
|
1210
|
+
const isInArcSphere2 = ((_a2 = window == null ? void 0 : window.navigator) == null ? void 0 : _a2.userAgent.indexOf("ArcSphere")) > -1;
|
|
1211
1211
|
const isChatInWalletV2 = useMemo(() => {
|
|
1212
1212
|
try {
|
|
1213
1213
|
const targetVersion = mobile.apple.device ? "5.3.5" : "5.3.1";
|
|
1214
|
-
return
|
|
1214
|
+
return isInArcSphere2 || !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1215
1215
|
} catch (e) {
|
|
1216
1216
|
console.error(e);
|
|
1217
1217
|
return false;
|
|
1218
1218
|
}
|
|
1219
|
-
}, [walletVersion, mobile,
|
|
1219
|
+
}, [walletVersion, mobile, isInArcSphere2]);
|
|
1220
1220
|
const isWebNavbar = useMemo(() => {
|
|
1221
1221
|
try {
|
|
1222
1222
|
const targetVersion = mobile.apple.device ? "5.4.6" : "5.4.4";
|
|
1223
|
-
return
|
|
1223
|
+
return isInArcSphere2 || !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1224
1224
|
} catch (e) {
|
|
1225
1225
|
console.error(e);
|
|
1226
1226
|
return false;
|
|
1227
1227
|
}
|
|
1228
|
-
}, [walletVersion, mobile,
|
|
1228
|
+
}, [walletVersion, mobile, isInArcSphere2]);
|
|
1229
1229
|
const navigateToChat = ({ id: id2, title }) => {
|
|
1230
1230
|
if (isChatInWalletV2) {
|
|
1231
1231
|
navigate(`/chat-in-wallet/${id2}`);
|
|
@@ -1244,7 +1244,7 @@ const useChatInWallet = () => {
|
|
|
1244
1244
|
navigateToChatList,
|
|
1245
1245
|
isChatInWalletV2,
|
|
1246
1246
|
isWebNavbar,
|
|
1247
|
-
isInArcSphere,
|
|
1247
|
+
isInArcSphere: isInArcSphere2,
|
|
1248
1248
|
updateUnreadState,
|
|
1249
1249
|
chatInWallet
|
|
1250
1250
|
};
|
|
@@ -4799,7 +4799,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, ...rest }) {
|
|
|
4799
4799
|
}
|
|
4800
4800
|
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" }) });
|
|
4801
4801
|
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" }) });
|
|
4802
|
-
const Editor = lazyRetry(() => import("./editor-
|
|
4802
|
+
const Editor = lazyRetry(() => import("./editor-BADlWI3X.mjs"));
|
|
4803
4803
|
function LazyEditor(props) {
|
|
4804
4804
|
const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
|
|
4805
4805
|
/* @__PURE__ */ jsx(Skeleton, {}),
|
|
@@ -5663,7 +5663,7 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5663
5663
|
const { session } = useSessionContext();
|
|
5664
5664
|
const { initialized, chats, activeChatId } = useChatContext();
|
|
5665
5665
|
const { unread } = useUnreadNotification();
|
|
5666
|
-
const { navigateToChatList, updateUnreadState, isWebNavbar, isInArcSphere } = useChatInWallet();
|
|
5666
|
+
const { navigateToChatList, updateUnreadState, isWebNavbar, isInArcSphere: isInArcSphere2 } = useChatInWallet();
|
|
5667
5667
|
useEffect(() => {
|
|
5668
5668
|
if (unread !== void 0) {
|
|
5669
5669
|
updateUnreadState(unread);
|
|
@@ -5704,7 +5704,7 @@ function ChatListInWallet({ sx, ...rest }) {
|
|
|
5704
5704
|
mb: 1
|
|
5705
5705
|
},
|
|
5706
5706
|
children: [
|
|
5707
|
-
|
|
5707
|
+
isInArcSphere2 && /* @__PURE__ */ jsx(IconButton$2, { onClick: () => bridge.call("arcClosePage"), children: /* @__PURE__ */ jsx(Box$1, { component: ArrowBackIosIcon, sx: { fontSize: 16 } }) }),
|
|
5708
5708
|
/* @__PURE__ */ jsxs(
|
|
5709
5709
|
Box$1,
|
|
5710
5710
|
{
|
|
@@ -5848,14 +5848,55 @@ const useApiErrorHandler = ({ request, errorHandler }) => {
|
|
|
5848
5848
|
};
|
|
5849
5849
|
}, []);
|
|
5850
5850
|
};
|
|
5851
|
+
let toast = Object.assign(hotToast, {
|
|
5852
|
+
warning: (message, options) => {
|
|
5853
|
+
return hotToast.error(message, { ...options, icon: "⚠️" });
|
|
5854
|
+
}
|
|
5855
|
+
});
|
|
5856
|
+
const isInArcSphere = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
|
|
5857
|
+
if (isInArcSphere) {
|
|
5858
|
+
toast = Object.assign(
|
|
5859
|
+
(message) => {
|
|
5860
|
+
try {
|
|
5861
|
+
return bridge.call("arc__toast", { text: message });
|
|
5862
|
+
} catch (e) {
|
|
5863
|
+
return hotToast(message);
|
|
5864
|
+
}
|
|
5865
|
+
},
|
|
5866
|
+
hotToast,
|
|
5867
|
+
{
|
|
5868
|
+
error: (message) => {
|
|
5869
|
+
try {
|
|
5870
|
+
return bridge.call("arc__toast", { text: message, level: "error" });
|
|
5871
|
+
} catch (e) {
|
|
5872
|
+
return hotToast.error(message);
|
|
5873
|
+
}
|
|
5874
|
+
},
|
|
5875
|
+
success: (message) => {
|
|
5876
|
+
try {
|
|
5877
|
+
return bridge.call("arc__toast", { text: message, level: "success" });
|
|
5878
|
+
} catch (e) {
|
|
5879
|
+
return hotToast.success(message);
|
|
5880
|
+
}
|
|
5881
|
+
},
|
|
5882
|
+
warning: (message, options) => {
|
|
5883
|
+
try {
|
|
5884
|
+
return bridge.call("arc__toast", { text: message, level: "warning" });
|
|
5885
|
+
} catch (e) {
|
|
5886
|
+
return hotToast.error(message, { ...options, icon: "⚠️" });
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
}
|
|
5890
|
+
);
|
|
5891
|
+
}
|
|
5851
5892
|
const useDefaultApiErrorHandler = (options) => {
|
|
5852
5893
|
const { request, onError } = options;
|
|
5853
5894
|
const { t } = useLocaleContext();
|
|
5854
5895
|
const showError = (msg, toastOptions) => {
|
|
5855
|
-
|
|
5896
|
+
toast.error(msg, toastOptions);
|
|
5856
5897
|
};
|
|
5857
5898
|
const showWarning = (msg, toastOptions) => {
|
|
5858
|
-
|
|
5899
|
+
toast.warning(msg, toastOptions);
|
|
5859
5900
|
};
|
|
5860
5901
|
const errorHandler = {
|
|
5861
5902
|
handleError(error) {
|
|
@@ -5892,7 +5933,7 @@ const useDefaultApiErrorHandler = (options) => {
|
|
|
5892
5933
|
")"
|
|
5893
5934
|
] })
|
|
5894
5935
|
] }),
|
|
5895
|
-
{
|
|
5936
|
+
{ duration: 1e4, style: { maxWidth: "500px" } }
|
|
5896
5937
|
);
|
|
5897
5938
|
break;
|
|
5898
5939
|
}
|
|
@@ -11875,14 +11916,14 @@ function create(prefix2) {
|
|
|
11875
11916
|
}
|
|
11876
11917
|
});
|
|
11877
11918
|
}
|
|
11878
|
-
function getWsClient(prefix2 = ((
|
|
11919
|
+
function getWsClient(prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") {
|
|
11879
11920
|
if (!client) {
|
|
11880
11921
|
client = create(prefix2);
|
|
11881
11922
|
}
|
|
11882
11923
|
return client;
|
|
11883
11924
|
}
|
|
11884
11925
|
const useSubscription = (event, cb = () => {
|
|
11885
|
-
}, deps = [], prefix2 = ((
|
|
11926
|
+
}, deps = [], prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") => {
|
|
11886
11927
|
useEffect(() => {
|
|
11887
11928
|
if (event) {
|
|
11888
11929
|
if (!client) {
|
|
@@ -12329,6 +12370,7 @@ export {
|
|
|
12329
12370
|
create as ar,
|
|
12330
12371
|
getWsClient as as,
|
|
12331
12372
|
useSubscription as at,
|
|
12373
|
+
toast as au,
|
|
12332
12374
|
Input as b,
|
|
12333
12375
|
useChanged as c,
|
|
12334
12376
|
useSessionContext as d,
|
package/dist/index.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export * from './components/point-up';
|
|
|
27
27
|
export * from './components/button-group';
|
|
28
28
|
export * from './components/segmented-control';
|
|
29
29
|
export * from './ws';
|
|
30
|
+
export * from './components/toast';
|
|
30
31
|
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 { 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-
|
|
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, au, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-BB0w4gSN.mjs";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
5
|
import "@mui/material/Box";
|
|
@@ -71,6 +71,7 @@ export {
|
|
|
71
71
|
p as preloadInput,
|
|
72
72
|
r as routes,
|
|
73
73
|
j as themeOverrides,
|
|
74
|
+
au as toast,
|
|
74
75
|
t as translations,
|
|
75
76
|
h as typography,
|
|
76
77
|
aa as useApiErrorHandler,
|
package/dist/index.umd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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("@arcblock/ux/lib/Locale/context"), require("@mui/icons-material"), require("@mui/lab/LoadingButton"), require("@mui/material/Alert"), require("@mui/material/Box"), 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("@arcblock/ux/lib/Util"), 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("@mui/material/colors/red"), 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("axios"), require("
|
|
3
|
-
})(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, context, iconsMaterial, LoadingButton, Alert, Box, 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, Util, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, EditorHolderPlugin, red, Dialog, orderBy, Typography, Skeleton, ReactDOM, ufo, dayjs, relativeTime, joinUrl, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, editor$1, Fab, debounce, useIsFocused, BusyPlugin, ArrowBackIosIcon, axios,
|
|
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("@arcblock/ux/lib/Locale/context"), require("@mui/icons-material"), require("@mui/lab/LoadingButton"), require("@mui/material/Alert"), require("@mui/material/Box"), 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("@arcblock/ux/lib/Util"), 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("@mui/material/colors/red"), 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("axios"), require("react-hot-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", "@arcblock/ux/lib/Locale/context", "@mui/icons-material", "@mui/lab/LoadingButton", "@mui/material/Alert", "@mui/material/Box", "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", "@arcblock/ux/lib/Util", "@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", "@mui/material/colors/red", "@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", "axios", "react-hot-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.context, global.iconsMaterial, global.LoadingButton, global.Alert, global.Box, 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.Util, global.CheckboxPlugin, global.DIDAddress, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.EditorHolderPlugin, global.red, 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.axios, global.hotToast, 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, context, iconsMaterial, LoadingButton, Alert, Box, 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, Util, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, EditorHolderPlugin, red, Dialog, orderBy, Typography, Skeleton, ReactDOM, ufo, dayjs, relativeTime, joinUrl, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, editor$1, Fab, debounce, useIsFocused, BusyPlugin, ArrowBackIosIcon, axios, hotToast, 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);
|
|
7
7
|
|
|
8
|
-
var _a, _b, _c, _d;
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
9
|
const typography = {
|
|
10
10
|
h1: {
|
|
11
11
|
fontSize: "1.875rem",
|
|
@@ -947,13 +947,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
947
947
|
] }) : null;
|
|
948
948
|
}
|
|
949
949
|
const useSessionContext = () => {
|
|
950
|
-
var _a2, _b2, _c2, _d2,
|
|
950
|
+
var _a2, _b2, _c2, _d2, _e2, _f;
|
|
951
951
|
const ctx = react.useContext(Session.SessionContext) || {};
|
|
952
952
|
const roles = [...((_c2 = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.passports) == null ? void 0 : _c2.map((p) => p.name)) || [], "guest"];
|
|
953
953
|
const permissionSet = react.useMemo(() => {
|
|
954
954
|
var _a3, _b3;
|
|
955
955
|
return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
|
|
956
|
-
}, [(
|
|
956
|
+
}, [(_e2 = (_d2 = ctx.session) == null ? void 0 : _d2.user) == null ? void 0 : _e2.permissions]);
|
|
957
957
|
const hasAnyPassport = (passports) => {
|
|
958
958
|
if (!passports || passports.length === 0) {
|
|
959
959
|
return true;
|
|
@@ -1130,25 +1130,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1130
1130
|
const navigate = reactRouterDom.useNavigate();
|
|
1131
1131
|
const { walletVersion, mobile } = reactHooks.useBrowser();
|
|
1132
1132
|
const chatInWallet = reactRouterDom.useMatch("/chat-in-wallet/:chatId?");
|
|
1133
|
-
const
|
|
1133
|
+
const isInArcSphere2 = ((_a2 = window == null ? void 0 : window.navigator) == null ? void 0 : _a2.userAgent.indexOf("ArcSphere")) > -1;
|
|
1134
1134
|
const isChatInWalletV2 = react.useMemo(() => {
|
|
1135
1135
|
try {
|
|
1136
1136
|
const targetVersion = mobile.apple.device ? "5.3.5" : "5.3.1";
|
|
1137
|
-
return
|
|
1137
|
+
return isInArcSphere2 || !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1138
1138
|
} catch (e) {
|
|
1139
1139
|
console.error(e);
|
|
1140
1140
|
return false;
|
|
1141
1141
|
}
|
|
1142
|
-
}, [walletVersion, mobile,
|
|
1142
|
+
}, [walletVersion, mobile, isInArcSphere2]);
|
|
1143
1143
|
const isWebNavbar = react.useMemo(() => {
|
|
1144
1144
|
try {
|
|
1145
1145
|
const targetVersion = mobile.apple.device ? "5.4.6" : "5.4.4";
|
|
1146
|
-
return
|
|
1146
|
+
return isInArcSphere2 || !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
1147
1147
|
} catch (e) {
|
|
1148
1148
|
console.error(e);
|
|
1149
1149
|
return false;
|
|
1150
1150
|
}
|
|
1151
|
-
}, [walletVersion, mobile,
|
|
1151
|
+
}, [walletVersion, mobile, isInArcSphere2]);
|
|
1152
1152
|
const navigateToChat = ({ id: id2, title }) => {
|
|
1153
1153
|
if (isChatInWalletV2) {
|
|
1154
1154
|
navigate(`/chat-in-wallet/${id2}`);
|
|
@@ -1167,7 +1167,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1167
1167
|
navigateToChatList,
|
|
1168
1168
|
isChatInWalletV2,
|
|
1169
1169
|
isWebNavbar,
|
|
1170
|
-
isInArcSphere,
|
|
1170
|
+
isInArcSphere: isInArcSphere2,
|
|
1171
1171
|
updateUnreadState,
|
|
1172
1172
|
chatInWallet
|
|
1173
1173
|
};
|
|
@@ -5586,7 +5586,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5586
5586
|
const { session } = useSessionContext();
|
|
5587
5587
|
const { initialized, chats, activeChatId } = useChatContext();
|
|
5588
5588
|
const { unread } = useUnreadNotification();
|
|
5589
|
-
const { navigateToChatList, updateUnreadState, isWebNavbar, isInArcSphere } = useChatInWallet();
|
|
5589
|
+
const { navigateToChatList, updateUnreadState, isWebNavbar, isInArcSphere: isInArcSphere2 } = useChatInWallet();
|
|
5590
5590
|
react.useEffect(() => {
|
|
5591
5591
|
if (unread !== void 0) {
|
|
5592
5592
|
updateUnreadState(unread);
|
|
@@ -5627,7 +5627,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5627
5627
|
mb: 1
|
|
5628
5628
|
},
|
|
5629
5629
|
children: [
|
|
5630
|
-
|
|
5630
|
+
isInArcSphere2 && /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { onClick: () => bridge.call("arcClosePage"), children: /* @__PURE__ */ jsxRuntime.jsx(Box, { component: ArrowBackIosIcon, sx: { fontSize: 16 } }) }),
|
|
5631
5631
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5632
5632
|
Box,
|
|
5633
5633
|
{
|
|
@@ -5771,14 +5771,55 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5771
5771
|
};
|
|
5772
5772
|
}, []);
|
|
5773
5773
|
};
|
|
5774
|
+
exports2.toast = Object.assign(hotToast, {
|
|
5775
|
+
warning: (message, options) => {
|
|
5776
|
+
return hotToast.error(message, { ...options, icon: "⚠️" });
|
|
5777
|
+
}
|
|
5778
|
+
});
|
|
5779
|
+
const isInArcSphere = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
|
|
5780
|
+
if (isInArcSphere) {
|
|
5781
|
+
exports2.toast = Object.assign(
|
|
5782
|
+
(message) => {
|
|
5783
|
+
try {
|
|
5784
|
+
return bridge.call("arc__toast", { text: message });
|
|
5785
|
+
} catch (e) {
|
|
5786
|
+
return hotToast(message);
|
|
5787
|
+
}
|
|
5788
|
+
},
|
|
5789
|
+
hotToast,
|
|
5790
|
+
{
|
|
5791
|
+
error: (message) => {
|
|
5792
|
+
try {
|
|
5793
|
+
return bridge.call("arc__toast", { text: message, level: "error" });
|
|
5794
|
+
} catch (e) {
|
|
5795
|
+
return hotToast.error(message);
|
|
5796
|
+
}
|
|
5797
|
+
},
|
|
5798
|
+
success: (message) => {
|
|
5799
|
+
try {
|
|
5800
|
+
return bridge.call("arc__toast", { text: message, level: "success" });
|
|
5801
|
+
} catch (e) {
|
|
5802
|
+
return hotToast.success(message);
|
|
5803
|
+
}
|
|
5804
|
+
},
|
|
5805
|
+
warning: (message, options) => {
|
|
5806
|
+
try {
|
|
5807
|
+
return bridge.call("arc__toast", { text: message, level: "warning" });
|
|
5808
|
+
} catch (e) {
|
|
5809
|
+
return hotToast.error(message, { ...options, icon: "⚠️" });
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
}
|
|
5813
|
+
);
|
|
5814
|
+
}
|
|
5774
5815
|
const useDefaultApiErrorHandler = (options) => {
|
|
5775
5816
|
const { request, onError } = options;
|
|
5776
5817
|
const { t } = context.useLocaleContext();
|
|
5777
5818
|
const showError = (msg, toastOptions) => {
|
|
5778
|
-
|
|
5819
|
+
exports2.toast.error(msg, toastOptions);
|
|
5779
5820
|
};
|
|
5780
5821
|
const showWarning = (msg, toastOptions) => {
|
|
5781
|
-
|
|
5822
|
+
exports2.toast.warning(msg, toastOptions);
|
|
5782
5823
|
};
|
|
5783
5824
|
const errorHandler = {
|
|
5784
5825
|
handleError(error) {
|
|
@@ -5815,7 +5856,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5815
5856
|
")"
|
|
5816
5857
|
] })
|
|
5817
5858
|
] }),
|
|
5818
|
-
{
|
|
5859
|
+
{ duration: 1e4, style: { maxWidth: "500px" } }
|
|
5819
5860
|
);
|
|
5820
5861
|
break;
|
|
5821
5862
|
}
|
|
@@ -11798,14 +11839,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
11798
11839
|
}
|
|
11799
11840
|
});
|
|
11800
11841
|
}
|
|
11801
|
-
function getWsClient(prefix2 = ((
|
|
11842
|
+
function getWsClient(prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") {
|
|
11802
11843
|
if (!client) {
|
|
11803
11844
|
client = create(prefix2);
|
|
11804
11845
|
}
|
|
11805
11846
|
return client;
|
|
11806
11847
|
}
|
|
11807
11848
|
const useSubscription = (event, cb = () => {
|
|
11808
|
-
}, deps = [], prefix2 = ((
|
|
11849
|
+
}, deps = [], prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") => {
|
|
11809
11850
|
react.useEffect(() => {
|
|
11810
11851
|
if (event) {
|
|
11811
11852
|
if (!client) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit-ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.141",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@arcblock/bridge": "^2.11.30",
|
|
22
22
|
"@arcblock/react-hooks": "^2.11.30",
|
|
23
23
|
"@arcblock/ws": "^1.19.6",
|
|
24
|
-
"@blocklet/uploader": "^0.1.
|
|
24
|
+
"@blocklet/uploader": "^0.1.66",
|
|
25
25
|
"@emotion/css": "^11.13.0",
|
|
26
26
|
"@emotion/react": "^11.13.3",
|
|
27
27
|
"@emotion/styled": "^11.13.0",
|
|
@@ -38,14 +38,15 @@
|
|
|
38
38
|
"mitt": "^3.0.1",
|
|
39
39
|
"react-flip-toolkit": "^7.2.4",
|
|
40
40
|
"react-helmet": "^6.1.0",
|
|
41
|
+
"react-hot-toast": "^2.4.1",
|
|
41
42
|
"react-lazy-with-preload": "^2.2.1",
|
|
42
43
|
"react-select": "^5.8.1",
|
|
43
44
|
"semver-compare": "^1.0.0",
|
|
44
45
|
"ufo": "^1.5.4",
|
|
45
46
|
"unstated-next": "^1.1.0",
|
|
46
47
|
"url-join": "^4.0.1",
|
|
47
|
-
"@blocklet/editor": "^2.1.
|
|
48
|
-
"@blocklet/labels": "^2.1.
|
|
48
|
+
"@blocklet/editor": "^2.1.141",
|
|
49
|
+
"@blocklet/labels": "^2.1.141"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"@arcblock/did-connect": "^2.10.36",
|