@blocklet/ui-react 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +1,61 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
- import S from "prop-types";
3
- import { useMemo as L, useCallback as T, useEffect as $ } from "react";
4
- import { IconButton as B, Badge as P } from "@mui/material";
5
- import { useSnackbar as V } from "notistack";
6
- import x from "@arcblock/icons/lib/Notification";
2
+ import $ from "prop-types";
3
+ import { useMemo as I, useCallback as L, useEffect as B } from "react";
4
+ import { IconButton as P, Badge as V } from "@mui/material";
5
+ import { useSnackbar as x } from "notistack";
6
+ import W from "@arcblock/icons/lib/Notification";
7
7
  import { useCreation as s } from "ahooks";
8
- import { WELLKNOWN_SERVICE_PATH_PREFIX as W, ROLES as A, EVENTS as O } from "@abtnode/constant";
9
- import j from "@arcblock/react-hooks/lib/useBrowser";
10
- import { compareVersions as F } from "@arcblock/ux/lib/Util";
11
- import { joinURL as H, withQuery as R } from "ufo";
12
- import { useListenWsClient as K } from "./ws.js";
13
- import M from "../Notifications/Snackbar.js";
14
- const E = H(W, "user", "notifications"), z = (r) => R(E, {
15
- id: r.id,
16
- severity: r.severity || "all",
17
- componentDid: r.source === "system" ? "system" : r.componentDid || "all"
8
+ import { WELLKNOWN_SERVICE_PATH_PREFIX as j, ROLES as T, EVENTS as O } from "@abtnode/constant";
9
+ import F from "@arcblock/react-hooks/lib/useBrowser";
10
+ import { compareVersions as H } from "@arcblock/ux/lib/Util";
11
+ import { joinURL as K, withQuery as R } from "ufo";
12
+ import { useListenWsClient as M } from "./ws.js";
13
+ import z from "../Notifications/Snackbar.js";
14
+ const E = K(j, "user", "notifications"), q = (t) => R(E, {
15
+ id: t.id,
16
+ severity: t.severity || "all",
17
+ componentDid: t.source === "system" ? "system" : t.componentDid || "all"
18
18
  });
19
- function q({ session: r = {} }) {
20
- const { unReadCount: l, user: t, setUnReadCount: i } = r, e = s(() => t?.did, [t]), h = s(() => t?.role && [A.ADMIN, A.OWNER].includes(t?.role), [t?.role]), { enqueueSnackbar: N } = V(), d = j(), u = L(() => !e || t?.isPreviewUser || e === window.blocklet.did, [e, t]), k = L(() => d.arcSphere || d.wallet, [d]), y = s(() => window.blocklet?.serverVersion, []), n = K("user"), a = s(
19
+ function Q({ session: t = {} }) {
20
+ const { unReadCount: l, user: r, setUnReadCount: i } = t, e = s(() => r?.did, [r]), h = s(() => r?.role && [T.ADMIN, T.OWNER].includes(r?.role), [r?.role]), { enqueueSnackbar: k } = x(), d = F(), a = I(() => !e || r?.isPreviewUser || e === window.blocklet.did, [e, r]), N = I(() => d.arcSphere || d.wallet, [d]), y = s(() => window.blocklet?.serverVersion, []), n = M("user"), u = s(
21
21
  () => `${window.blocklet.did}/${e}/${O.NOTIFICATION_BLOCKLET_CREATE}`,
22
22
  [e]
23
23
  ), m = s(
24
24
  () => `${window.blocklet.did}/${e}/${O.NOTIFICATION_BLOCKLET_READ}`,
25
25
  [e]
26
- ), p = T(
26
+ ), p = L(
27
27
  (o) => {
28
- const { receivers: v, source: w } = o ?? {}, { receiver: C } = v[0] ?? {};
29
- if (C === e && (h || w !== "system")) {
30
- i((b) => b + 1);
31
- const U = F(y, "1.16.42-beta-20250407");
32
- if (!k && o.source === "component" && U) {
33
- const b = z(o), { severity: I, description: _ } = o || {}, g = ["error", "warning"].includes(I) || o.sticky;
34
- N(_, {
35
- variant: I,
36
- autoHideDuration: g ? null : 5e3,
28
+ const { receivers: w, source: v } = o ?? {}, { receiver: b } = w[0] ?? {};
29
+ if (b === e && (h || v !== "system")) {
30
+ i((C) => C + 1);
31
+ const U = window.blocklet?.settings?.notification?.toastAlert === !0, g = H(y, "1.16.42-beta-20250407");
32
+ if (U && !N && o.source === "component" && g) {
33
+ const C = q(o), { severity: A, description: _ } = o || {}, D = ["error", "warning"].includes(A) || o.sticky;
34
+ k(_, {
35
+ variant: A,
36
+ autoHideDuration: D ? null : 5e3,
37
37
  anchorOrigin: {
38
38
  vertical: "top",
39
39
  horizontal: "center"
40
40
  },
41
41
  // eslint-disable-next-line react/no-unstable-nested-components
42
- content: (D) => /* @__PURE__ */ c(M, { viewAllUrl: b, keyId: D, notification: o })
42
+ content: (S) => /* @__PURE__ */ c(z, { viewAllUrl: C, keyId: S, notification: o })
43
43
  });
44
44
  }
45
45
  }
46
46
  },
47
- [e, i, N, y, k, h]
48
- ), f = T(
47
+ [e, i, k, y, N, h]
48
+ ), f = L(
49
49
  (o) => {
50
- const { receiver: v, readCount: w } = o ?? {};
51
- v === e && i((C) => Math.max(C - w, 0));
50
+ const { receiver: w, readCount: v } = o ?? {};
51
+ w === e && i((b) => Math.max(b - v, 0));
52
52
  },
53
53
  [e, i]
54
54
  );
55
- return $(() => (n && !u && (n.on(a, p), n.on(m, f)), () => {
56
- n && !u && (n.off(a, p), n.off(m, f));
57
- }), [n, i, p, a, f, m, u]), !r.user || !E ? null : /* @__PURE__ */ c(
58
- B,
55
+ return B(() => (n && !a && (n.on(u, p), n.on(m, f)), () => {
56
+ n && !a && (n.off(u, p), n.off(m, f));
57
+ }), [n, i, p, u, f, m, a]), !t.user || !E ? null : /* @__PURE__ */ c(
58
+ P,
59
59
  {
60
60
  size: "medium",
61
61
  variant: "outlined",
@@ -65,13 +65,13 @@ function q({ session: r = {} }) {
65
65
  borderRadius: "50%"
66
66
  }
67
67
  },
68
- children: /* @__PURE__ */ c(P, { badgeContent: l, color: "error", invisible: l === 0, children: /* @__PURE__ */ c(x, { style: { width: "auto", height: 24 } }) })
68
+ children: /* @__PURE__ */ c(V, { badgeContent: l, color: "error", invisible: l === 0, children: /* @__PURE__ */ c(W, { style: { width: "auto", height: 24 } }) })
69
69
  }
70
70
  );
71
71
  }
72
- q.propTypes = {
73
- session: S.object
72
+ Q.propTypes = {
73
+ session: $.object
74
74
  };
75
75
  export {
76
- q as default
76
+ Q as default
77
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -36,9 +36,9 @@
36
36
  "dependencies": {
37
37
  "@abtnode/constant": "^1.17.7",
38
38
  "@abtnode/util": "^1.17.7",
39
- "@arcblock/bridge": "3.5.0",
40
- "@arcblock/icons": "3.5.0",
41
- "@arcblock/react-hooks": "3.5.0",
39
+ "@arcblock/bridge": "3.5.1",
40
+ "@arcblock/icons": "3.5.1",
41
+ "@arcblock/react-hooks": "3.5.1",
42
42
  "@arcblock/ws": "^1.29.4",
43
43
  "@blocklet/did-space-react": "^1.2.15",
44
44
  "@blocklet/uploader": "^0.3.19",
@@ -87,7 +87,7 @@
87
87
  "access": "public"
88
88
  },
89
89
  "devDependencies": {
90
- "@arcblock/did-connect-react": "3.5.0",
90
+ "@arcblock/did-connect-react": "3.5.1",
91
91
  "@babel/preset-env": "^7.28.0",
92
92
  "@babel/preset-react": "^7.27.1",
93
93
  "@babel/preset-typescript": "^7.27.1",
@@ -101,5 +101,5 @@
101
101
  "typescript": "~5.5.4",
102
102
  "unbuild": "^2.0.0"
103
103
  },
104
- "gitHead": "1cfc816004525cf1b352ec2b64d459f4769f0237"
104
+ "gitHead": "78fdd8a869a60672e8b66d4eefc172c8a716acd8"
105
105
  }