@blocklet/discuss-kit-ux 2.1.160 → 2.1.162

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
+ export declare const isInArcSphere: boolean;
2
+ export declare const isInArcSphereDialog: boolean;
3
+ interface OpenDialogOptions {
4
+ url: string;
5
+ type?: 'full' | 'half';
6
+ onClose?: (reason: string) => void;
7
+ }
8
+ export declare const openArcSphereDialog: ({ url, type, onClose }: OpenDialogOptions) => void;
9
+ export declare const closeArcSphereDialog: (reason?: string) => void;
10
+ export declare const useArcSphereDialog: () => {
11
+ open: ({ authRequired, ...options }: OpenDialogOptions & {
12
+ authRequired?: boolean | undefined;
13
+ }) => void;
14
+ close: (reason?: string) => void;
15
+ };
16
+ export {};
@@ -6,5 +6,5 @@ interface BackProps {
6
6
  sx?: SxProps;
7
7
  icon?: React.ReactNode;
8
8
  }
9
- export declare function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }: BackProps & ButtonProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }: BackProps & ButtonProps): import("react/jsx-runtime").JSX.Element | null;
10
10
  export {};
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
4
4
  import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
5
5
  import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
6
6
  import { 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-MPAyKNVs.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-CeuyJya0.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, _e;
4
+ var _a, _b, _c, _d, _e, _f;
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";
@@ -13,7 +13,7 @@ import { useEditorConfig, EditorConfigProvider } from "@blocklet/editor/lib/conf
13
13
  import { lazyWithPreload } from "react-lazy-with-preload";
14
14
  import { $getRoot, $createParagraphNode, $createTextNode, KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getSelection } from "lexical";
15
15
  import { $isRootTextContentEmpty } from "@lexical/text";
16
- import { joinURL, withTrailingSlash, withQuery } from "ufo";
16
+ import { joinURL, withTrailingSlash, withQuery, parseQuery } from "ufo";
17
17
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
18
18
  import { ImageNode } from "@blocklet/editor/lib/main/nodes/ImageNode";
19
19
  import { VideoNode } from "@blocklet/editor/lib/ext/VideoPlugin/VideoNode";
@@ -76,6 +76,7 @@ import debounce from "lodash/debounce";
76
76
  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
+ import { AddonButton } from "@arcblock/ux/lib/Header/addon-button";
79
80
  import { AxiosError } from "axios";
80
81
  import hotToast from "react-hot-toast";
81
82
  import MuiPagination from "@mui/material/Pagination";
@@ -1038,7 +1039,7 @@ function Badge({
1038
1039
  ] }) : null;
1039
1040
  }
1040
1041
  const useSessionContext = () => {
1041
- var _a2, _b2, _c2, _d2, _e2, _f;
1042
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1042
1043
  const ctx = useContext(SessionContext) || {};
1043
1044
  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.role)) || [], "guest"];
1044
1045
  const permissionSet = useMemo(() => {
@@ -1054,7 +1055,7 @@ const useSessionContext = () => {
1054
1055
  };
1055
1056
  return {
1056
1057
  ...ctx,
1057
- isAuthenticated: !!((_f = ctx.session) == null ? void 0 : _f.user),
1058
+ isAuthenticated: !!((_f2 = ctx.session) == null ? void 0 : _f2.user),
1058
1059
  isAdmin: hasAnyPassport(["admin", "owner"]),
1059
1060
  isMember: hasAnyPassport(["member"]),
1060
1061
  isBlogEditor: hasAnyPassport(["blogEditor"]),
@@ -4780,10 +4781,60 @@ function Participants({ users, sx, ...rest }) {
4780
4781
  }
4781
4782
  ) }) });
4782
4783
  }
4784
+ const isInArcSphere$1 = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
4785
+ const isInArcSphereDialog = !!parseQuery(window.location.search).arcSphereDialog;
4786
+ function normalizeUrl(url) {
4787
+ if (url.startsWith("/")) {
4788
+ return withQuery(joinURL(window.origin, window.blocklet.prefix, url), { arcSphereDialog: 1 });
4789
+ }
4790
+ return url;
4791
+ }
4792
+ const openArcSphereDialog = ({ url, type = "full", onClose }) => {
4793
+ bridge.register("closePopupCallback", (arg) => {
4794
+ onClose == null ? void 0 : onClose(arg);
4795
+ });
4796
+ bridge.call("arc__openPopup", {
4797
+ url: normalizeUrl(url),
4798
+ type
4799
+ });
4800
+ };
4801
+ const closeArcSphereDialog = (reason) => {
4802
+ if (isInArcSphereDialog) {
4803
+ bridge.call("arc__closePopup", {
4804
+ callback: "closePopupCallback",
4805
+ args: [reason || ""]
4806
+ });
4807
+ }
4808
+ };
4809
+ const useArcSphereDialog = () => {
4810
+ const { session } = useSessionContext();
4811
+ const open = useCallback(
4812
+ ({ authRequired = true, ...options }) => {
4813
+ if (authRequired && !session.user) {
4814
+ session.login(() => {
4815
+ openArcSphereDialog(options);
4816
+ });
4817
+ } else {
4818
+ openArcSphereDialog(options);
4819
+ }
4820
+ },
4821
+ [session]
4822
+ );
4823
+ const close = useCallback((reason) => {
4824
+ closeArcSphereDialog(reason);
4825
+ }, []);
4826
+ return {
4827
+ open,
4828
+ close
4829
+ };
4830
+ };
4783
4831
  function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4784
4832
  const navigate = useNavigate();
4785
4833
  const location = useLocation();
4786
4834
  const mergedSx = [{}, ...Array.isArray(sx) ? sx : [sx]];
4835
+ if (isInArcSphere$1) {
4836
+ return null;
4837
+ }
4787
4838
  const handleClick = () => {
4788
4839
  var _a2;
4789
4840
  if (url) {
@@ -4803,7 +4854,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4803
4854
  }
4804
4855
  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" }) });
4805
4856
  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" }) });
4806
- const Editor = lazyRetry(() => import("./editor-BIFIUTiW.mjs"));
4857
+ const Editor = lazyRetry(() => import("./editor-BFgzPrJQ.mjs"));
4807
4858
  function LazyEditor(props) {
4808
4859
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4809
4860
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -5773,16 +5824,21 @@ function ChatListInWallet({ sx, ...rest }) {
5773
5824
  }
5774
5825
  ) });
5775
5826
  }
5776
- const iconoirMessageText = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: 1.5, children: [
5777
- /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M7 12h10M7 8h6" }),
5778
- /* @__PURE__ */ jsx("path", { d: "M3 20.29V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7.961a2 2 0 0 0-1.561.75l-2.331 2.914A.6.6 0 0 1 3 20.29Z" })
5779
- ] }) });
5780
5827
  function ChatHeaderAddon({ ...rest }) {
5781
5828
  const { unread } = useUnreadNotification();
5782
5829
  if (!preferences.enableNotificationBadge || !preferences.chatEnabled) {
5783
5830
  return null;
5784
5831
  }
5785
- return /* @__PURE__ */ jsx(IconButton$2, { size: "medium", ...rest, component: Link, to: "/chat", children: /* @__PURE__ */ jsx(Badge$1, { color: "error", variant: "dot", invisible: !unread, children: /* @__PURE__ */ jsx(iconoirMessageText, { style: { fontSize: 20 } }) }) });
5832
+ return /* @__PURE__ */ jsx(
5833
+ AddonButton,
5834
+ {
5835
+ size: "medium",
5836
+ icon: /* @__PURE__ */ jsx(Badge$1, { color: "error", variant: "dot", invisible: !unread, children: /* @__PURE__ */ jsx(tablerMessageCircle, {}) }),
5837
+ ...rest,
5838
+ component: Link,
5839
+ to: "/chat"
5840
+ }
5841
+ );
5786
5842
  }
5787
5843
  const materialSymbolsEditOutline = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "currentColor", d: "M5 19h1.425L16.2 9.225L14.775 7.8L5 17.575zm-2 2v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM19 6.4L17.6 5zm-3.525 2.125l-.7-.725L16.2 9.225z" }) });
5788
5844
  function SecureLabelPicker(props) {
@@ -5857,7 +5913,7 @@ let toast = Object.assign(hotToast, {
5857
5913
  return hotToast.error(message, { ...options, icon: "⚠️" });
5858
5914
  }
5859
5915
  });
5860
- const isInArcSphere = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
5916
+ const isInArcSphere = ((_f = window == null ? void 0 : window.navigator) == null ? void 0 : _f.userAgent.indexOf("ArcSphere")) > -1;
5861
5917
  if (isInArcSphere) {
5862
5918
  toast = Object.assign(
5863
5919
  (message) => {
@@ -11920,14 +11976,14 @@ function create(prefix2) {
11920
11976
  }
11921
11977
  });
11922
11978
  }
11923
- function getWsClient(prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") {
11979
+ function getWsClient(prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") {
11924
11980
  if (!client) {
11925
11981
  client = create(prefix2);
11926
11982
  }
11927
11983
  return client;
11928
11984
  }
11929
11985
  const useSubscription = (event, cb = () => {
11930
- }, deps = [], prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") => {
11986
+ }, deps = [], prefix2 = ((_h) => (_h = window.blocklet) == null ? void 0 : _h.prefix)() || "/") => {
11931
11987
  useEffect(() => {
11932
11988
  if (event) {
11933
11989
  if (!client) {
@@ -12375,6 +12431,11 @@ export {
12375
12431
  getWsClient as as,
12376
12432
  useSubscription as at,
12377
12433
  toast as au,
12434
+ isInArcSphere$1 as av,
12435
+ isInArcSphereDialog as aw,
12436
+ openArcSphereDialog as ax,
12437
+ closeArcSphereDialog as ay,
12438
+ useArcSphereDialog as az,
12378
12439
  Input as b,
12379
12440
  useChanged as c,
12380
12441
  useSessionContext as d,
package/dist/index.d.ts CHANGED
@@ -28,4 +28,5 @@ export * from './components/button-group';
28
28
  export * from './components/segmented-control';
29
29
  export * from './ws';
30
30
  export * from './components/toast';
31
+ export * from './components/arcsphere';
31
32
  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, au, t, h, aa, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-MPAyKNVs.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, ay, ar, N, am, as, av, aw, l, ax, f, p, r, j, au, t, h, aa, az, U, c, a0, z, a7, ab, u, an, d, at, a3, aj, e } from "./index-CeuyJya0.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
@@ -62,11 +62,15 @@ export {
62
62
  ai as UploaderContext,
63
63
  al as UploaderProvider,
64
64
  ak as UploaderTrigger,
65
+ ay as closeArcSphereDialog,
65
66
  ar as create,
66
67
  N as getBlogLink,
67
68
  am as getUploadedImageUrl,
68
69
  as as getWsClient,
70
+ av as isInArcSphere,
71
+ aw as isInArcSphereDialog,
69
72
  l as lexicalUtils,
73
+ ax as openArcSphereDialog,
70
74
  f as preferences,
71
75
  p as preloadInput,
72
76
  r as routes,
@@ -75,6 +79,7 @@ export {
75
79
  t as translations,
76
80
  h as typography,
77
81
  aa as useApiErrorHandler,
82
+ az as useArcSphereDialog,
78
83
  U as useAuthzContext,
79
84
  c as useChanged,
80
85
  a0 as useChatContext,
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("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) {
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("@arcblock/ux/lib/Header/addon-button"), 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", "@arcblock/ux/lib/Header/addon-button", "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.addonButton, 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, addonButton, 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, _e;
8
+ var _a, _b, _c, _d, _e, _f;
9
9
  const typography = {
10
10
  h1: {
11
11
  fontSize: "1.875rem",
@@ -961,7 +961,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
961
961
  ] }) : null;
962
962
  }
963
963
  const useSessionContext = () => {
964
- var _a2, _b2, _c2, _d2, _e2, _f;
964
+ var _a2, _b2, _c2, _d2, _e2, _f2;
965
965
  const ctx = react.useContext(Session.SessionContext) || {};
966
966
  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.role)) || [], "guest"];
967
967
  const permissionSet = react.useMemo(() => {
@@ -977,7 +977,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
977
977
  };
978
978
  return {
979
979
  ...ctx,
980
- isAuthenticated: !!((_f = ctx.session) == null ? void 0 : _f.user),
980
+ isAuthenticated: !!((_f2 = ctx.session) == null ? void 0 : _f2.user),
981
981
  isAdmin: hasAnyPassport(["admin", "owner"]),
982
982
  isMember: hasAnyPassport(["member"]),
983
983
  isBlogEditor: hasAnyPassport(["blogEditor"]),
@@ -4703,10 +4703,60 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4703
4703
  }
4704
4704
  ) }) });
4705
4705
  }
4706
+ const isInArcSphere$1 = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
4707
+ const isInArcSphereDialog = !!ufo.parseQuery(window.location.search).arcSphereDialog;
4708
+ function normalizeUrl(url) {
4709
+ if (url.startsWith("/")) {
4710
+ return ufo.withQuery(ufo.joinURL(window.origin, window.blocklet.prefix, url), { arcSphereDialog: 1 });
4711
+ }
4712
+ return url;
4713
+ }
4714
+ const openArcSphereDialog = ({ url, type = "full", onClose }) => {
4715
+ bridge.register("closePopupCallback", (arg) => {
4716
+ onClose == null ? void 0 : onClose(arg);
4717
+ });
4718
+ bridge.call("arc__openPopup", {
4719
+ url: normalizeUrl(url),
4720
+ type
4721
+ });
4722
+ };
4723
+ const closeArcSphereDialog = (reason) => {
4724
+ if (isInArcSphereDialog) {
4725
+ bridge.call("arc__closePopup", {
4726
+ callback: "closePopupCallback",
4727
+ args: [reason || ""]
4728
+ });
4729
+ }
4730
+ };
4731
+ const useArcSphereDialog = () => {
4732
+ const { session } = useSessionContext();
4733
+ const open = react.useCallback(
4734
+ ({ authRequired = true, ...options }) => {
4735
+ if (authRequired && !session.user) {
4736
+ session.login(() => {
4737
+ openArcSphereDialog(options);
4738
+ });
4739
+ } else {
4740
+ openArcSphereDialog(options);
4741
+ }
4742
+ },
4743
+ [session]
4744
+ );
4745
+ const close = react.useCallback((reason) => {
4746
+ closeArcSphereDialog(reason);
4747
+ }, []);
4748
+ return {
4749
+ open,
4750
+ close
4751
+ };
4752
+ };
4706
4753
  function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4707
4754
  const navigate = reactRouterDom.useNavigate();
4708
4755
  const location = reactRouterDom.useLocation();
4709
4756
  const mergedSx = [{}, ...Array.isArray(sx) ? sx : [sx]];
4757
+ if (isInArcSphere$1) {
4758
+ return null;
4759
+ }
4710
4760
  const handleClick = () => {
4711
4761
  var _a2;
4712
4762
  if (url) {
@@ -5696,16 +5746,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5696
5746
  }
5697
5747
  ) });
5698
5748
  }
5699
- const iconoirMessageText = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: 1.5, children: [
5700
- /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M7 12h10M7 8h6" }),
5701
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 20.29V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7.961a2 2 0 0 0-1.561.75l-2.331 2.914A.6.6 0 0 1 3 20.29Z" })
5702
- ] }) });
5703
5749
  function ChatHeaderAddon({ ...rest }) {
5704
5750
  const { unread } = useUnreadNotification();
5705
5751
  if (!preferences.enableNotificationBadge || !preferences.chatEnabled) {
5706
5752
  return null;
5707
5753
  }
5708
- return /* @__PURE__ */ jsxRuntime.jsx(material.IconButton, { size: "medium", ...rest, component: reactRouterDom.Link, to: "/chat", children: /* @__PURE__ */ jsxRuntime.jsx(material.Badge, { color: "error", variant: "dot", invisible: !unread, children: /* @__PURE__ */ jsxRuntime.jsx(iconoirMessageText, { style: { fontSize: 20 } }) }) });
5754
+ return /* @__PURE__ */ jsxRuntime.jsx(
5755
+ addonButton.AddonButton,
5756
+ {
5757
+ size: "medium",
5758
+ icon: /* @__PURE__ */ jsxRuntime.jsx(material.Badge, { color: "error", variant: "dot", invisible: !unread, children: /* @__PURE__ */ jsxRuntime.jsx(tablerMessageCircle, {}) }),
5759
+ ...rest,
5760
+ component: reactRouterDom.Link,
5761
+ to: "/chat"
5762
+ }
5763
+ );
5709
5764
  }
5710
5765
  const materialSymbolsEditOutline = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "currentColor", d: "M5 19h1.425L16.2 9.225L14.775 7.8L5 17.575zm-2 2v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM19 6.4L17.6 5zm-3.525 2.125l-.7-.725L16.2 9.225z" }) });
5711
5766
  function SecureLabelPicker(props) {
@@ -5780,7 +5835,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5780
5835
  return hotToast.error(message, { ...options, icon: "⚠️" });
5781
5836
  }
5782
5837
  });
5783
- const isInArcSphere = ((_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.userAgent.indexOf("ArcSphere")) > -1;
5838
+ const isInArcSphere = ((_f = window == null ? void 0 : window.navigator) == null ? void 0 : _f.userAgent.indexOf("ArcSphere")) > -1;
5784
5839
  if (isInArcSphere) {
5785
5840
  exports2.toast = Object.assign(
5786
5841
  (message) => {
@@ -11843,14 +11898,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
11843
11898
  }
11844
11899
  });
11845
11900
  }
11846
- function getWsClient(prefix2 = ((_f) => (_f = window.blocklet) == null ? void 0 : _f.prefix)() || "/") {
11901
+ function getWsClient(prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") {
11847
11902
  if (!client) {
11848
11903
  client = create(prefix2);
11849
11904
  }
11850
11905
  return client;
11851
11906
  }
11852
11907
  const useSubscription = (event, cb = () => {
11853
- }, deps = [], prefix2 = ((_g) => (_g = window.blocklet) == null ? void 0 : _g.prefix)() || "/") => {
11908
+ }, deps = [], prefix2 = ((_h) => (_h = window.blocklet) == null ? void 0 : _h.prefix)() || "/") => {
11854
11909
  react.useEffect(() => {
11855
11910
  if (event) {
11856
11911
  if (!client) {
@@ -12329,11 +12384,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12329
12384
  exports2.UploaderContext = UploaderContext;
12330
12385
  exports2.UploaderProvider = UploaderProvider;
12331
12386
  exports2.UploaderTrigger = UploaderTrigger;
12387
+ exports2.closeArcSphereDialog = closeArcSphereDialog;
12332
12388
  exports2.create = create;
12333
12389
  exports2.getBlogLink = getBlogLink;
12334
12390
  exports2.getUploadedImageUrl = getUploadedImageUrl;
12335
12391
  exports2.getWsClient = getWsClient;
12392
+ exports2.isInArcSphere = isInArcSphere$1;
12393
+ exports2.isInArcSphereDialog = isInArcSphereDialog;
12336
12394
  exports2.lexicalUtils = lexical;
12395
+ exports2.openArcSphereDialog = openArcSphereDialog;
12337
12396
  exports2.preferences = preferences;
12338
12397
  exports2.preloadInput = preloadInput;
12339
12398
  exports2.routes = routes;
@@ -12341,6 +12400,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12341
12400
  exports2.translations = translations;
12342
12401
  exports2.typography = typography;
12343
12402
  exports2.useApiErrorHandler = useApiErrorHandler;
12403
+ exports2.useArcSphereDialog = useArcSphereDialog;
12344
12404
  exports2.useAuthzContext = useAuthzContext;
12345
12405
  exports2.useChanged = useChanged;
12346
12406
  exports2.useChatContext = useChatContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.1.160",
3
+ "version": "2.1.162",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -18,10 +18,10 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@arcblock/bridge": "^2.11.34",
22
- "@arcblock/react-hooks": "^2.11.34",
21
+ "@arcblock/bridge": "^2.11.37",
22
+ "@arcblock/react-hooks": "^2.11.37",
23
23
  "@arcblock/ws": "^1.19.9",
24
- "@blocklet/uploader": "^0.1.67",
24
+ "@blocklet/uploader": "^0.1.68",
25
25
  "@emotion/css": "^11.13.0",
26
26
  "@emotion/react": "^11.13.3",
27
27
  "@emotion/styled": "^11.13.0",
@@ -45,8 +45,8 @@
45
45
  "ufo": "^1.5.4",
46
46
  "unstated-next": "^1.1.0",
47
47
  "url-join": "^4.0.1",
48
- "@blocklet/editor": "^2.1.160",
49
- "@blocklet/labels": "^2.1.160"
48
+ "@blocklet/editor": "^2.1.162",
49
+ "@blocklet/labels": "^2.1.162"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@arcblock/did-connect": "^2.10.36",