@blocklet/discuss-kit 1.5.131 → 1.5.133
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.
- package/lib/cjs/api.js +1 -3
- package/lib/cjs/comments-with-session.js +5 -15
- package/lib/cjs/comments.js +126 -263
- package/lib/cjs/components/error-fallback.js +9 -18
- package/lib/cjs/components/menu.js +33 -55
- package/lib/cjs/index.js +4 -17
- package/lib/cjs/lib/utils.js +1 -1
- package/lib/cjs/locales/en.js +2 -4
- package/lib/cjs/locales/index.js +2 -6
- package/lib/cjs/locales/zh.js +21 -23
- package/lib/cjs/session.js +1 -1
- package/lib/cjs/theme-provider.js +7 -23
- package/lib/cjs/ws.js +2 -4
- package/lib/es/comments-with-session.js +4 -12
- package/lib/es/comments.js +101 -227
- package/lib/es/components/error-fallback.js +8 -13
- package/lib/es/components/menu.js +31 -47
- package/lib/es/locales/en.js +1 -1
- package/lib/es/locales/zh.js +20 -20
- package/lib/es/theme-provider.js +5 -19
- package/package.json +8 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
2
3
|
const react = require("react");
|
|
3
4
|
const PropTypes = require("prop-types");
|
|
4
5
|
const Theme = require("@arcblock/ux/lib/Theme");
|
|
@@ -7,17 +8,7 @@ const iconsMaterial = require("@mui/icons-material");
|
|
|
7
8
|
const Box = require("@mui/material/Box");
|
|
8
9
|
const MuiMenu = require("@mui/material/Menu");
|
|
9
10
|
const MuiMenuItem = require("@mui/material/MenuItem");
|
|
10
|
-
|
|
11
|
-
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
12
|
-
const PropTypes__default = /* @__PURE__ */ _interopDefaultLegacy(PropTypes);
|
|
13
|
-
const IconButton__default = /* @__PURE__ */ _interopDefaultLegacy(IconButton);
|
|
14
|
-
const Box__default = /* @__PURE__ */ _interopDefaultLegacy(Box);
|
|
15
|
-
const MuiMenu__default = /* @__PURE__ */ _interopDefaultLegacy(MuiMenu);
|
|
16
|
-
const MuiMenuItem__default = /* @__PURE__ */ _interopDefaultLegacy(MuiMenuItem);
|
|
17
|
-
function Menu({
|
|
18
|
-
items,
|
|
19
|
-
...rest
|
|
20
|
-
}) {
|
|
11
|
+
function Menu({ items, ...rest }) {
|
|
21
12
|
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
22
13
|
const open = Boolean(anchorEl);
|
|
23
14
|
const handleClick = (event) => {
|
|
@@ -26,57 +17,44 @@ function Menu({
|
|
|
26
17
|
const handleClose = () => {
|
|
27
18
|
setAnchorEl(null);
|
|
28
19
|
};
|
|
29
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Root, {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
handleClose();
|
|
59
|
-
};
|
|
60
|
-
return /* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, {
|
|
61
|
-
onClick: _onClick,
|
|
62
|
-
...itemProps,
|
|
63
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Box__default.default, {
|
|
64
|
-
minWidth: 100,
|
|
65
|
-
children: text
|
|
66
|
-
})
|
|
67
|
-
}, index);
|
|
68
|
-
})
|
|
69
|
-
})]
|
|
70
|
-
});
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Root, { ...rest, children: [
|
|
21
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconButton, { size: "medium", onClick: handleClick, children: /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.MoreVert, { sx: { fontSize: 18 } }) }),
|
|
22
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
23
|
+
MuiMenu,
|
|
24
|
+
{
|
|
25
|
+
anchorEl,
|
|
26
|
+
anchorOrigin: {
|
|
27
|
+
vertical: "bottom",
|
|
28
|
+
horizontal: "right"
|
|
29
|
+
},
|
|
30
|
+
transformOrigin: {
|
|
31
|
+
vertical: "top",
|
|
32
|
+
horizontal: "right"
|
|
33
|
+
},
|
|
34
|
+
open,
|
|
35
|
+
onClose: handleClose,
|
|
36
|
+
children: items.map(({ onClick, text, ...itemProps }, index) => {
|
|
37
|
+
const _onClick = () => {
|
|
38
|
+
onClick();
|
|
39
|
+
handleClose();
|
|
40
|
+
};
|
|
41
|
+
return (
|
|
42
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
43
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledMenuItem, { onClick: _onClick, ...itemProps, children: /* @__PURE__ */ jsxRuntime.jsx(Box, { minWidth: 100, children: text }) }, index)
|
|
44
|
+
);
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
] });
|
|
71
49
|
}
|
|
72
50
|
Menu.propTypes = {
|
|
73
|
-
items:
|
|
51
|
+
items: PropTypes.array.isRequired
|
|
74
52
|
};
|
|
75
53
|
Menu.defaultProps = {};
|
|
76
54
|
const Root = Theme.styled("div")`
|
|
77
55
|
display: inline-block;
|
|
78
56
|
`;
|
|
79
|
-
const StyledMenuItem = Theme.styled(
|
|
57
|
+
const StyledMenuItem = Theme.styled(MuiMenuItem)`
|
|
80
58
|
font-size: 14px;
|
|
81
59
|
`;
|
|
82
60
|
module.exports = Menu;
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const themeProvider = require("./theme-provider");
|
|
4
4
|
const comments = require("./comments");
|
|
5
5
|
const commentsWithSession = require("./comments-with-session");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const commentsWithSession__default = /* @__PURE__ */ _interopDefaultLegacy(commentsWithSession);
|
|
10
|
-
Object.defineProperty(exports, "ThemeProvider", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: () => themeProvider__default.default
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, "Comments", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: () => comments__default.default
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "CommentsWithSession", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: () => commentsWithSession__default.default
|
|
21
|
-
});
|
|
6
|
+
exports.ThemeProvider = themeProvider;
|
|
7
|
+
exports.Comments = comments;
|
|
8
|
+
exports.CommentsWithSession = commentsWithSession;
|
package/lib/cjs/lib/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const protectLogin = (session, action) => {
|
|
4
4
|
if (session.user) {
|
|
5
5
|
return action();
|
package/lib/cjs/locales/en.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const flat = require("flat");
|
|
3
|
-
const
|
|
4
|
-
const flat__default = /* @__PURE__ */ _interopDefaultLegacy(flat);
|
|
5
|
-
const en = flat__default.default({
|
|
3
|
+
const en = flat({
|
|
6
4
|
comments: "Comments",
|
|
7
5
|
comment: "Comment",
|
|
8
6
|
poweredBy: "- powered by Discuss Kit",
|
|
@@ -12,7 +10,7 @@ const en = flat__default.default({
|
|
|
12
10
|
newest: "Newest",
|
|
13
11
|
loadMore: "Click To Load More",
|
|
14
12
|
connectDIDWallet: "Please connect DID Wallet.",
|
|
15
|
-
installDIDWallet: "Click to get your own DID Wallet
|
|
13
|
+
installDIDWallet: "Click to get your own DID Wallet→",
|
|
16
14
|
empty: "Be the first to leave a comment.",
|
|
17
15
|
delete: "Delete",
|
|
18
16
|
edit: "Edit",
|
package/lib/cjs/locales/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const flat = require("flat");
|
|
4
4
|
const discussKitUx = require("@blocklet/discuss-kit-ux");
|
|
5
5
|
const en = require("./en");
|
|
6
6
|
const zh = require("./zh");
|
|
7
|
-
const
|
|
8
|
-
const flat__default = /* @__PURE__ */ _interopDefaultLegacy(flat);
|
|
9
|
-
const en__default = /* @__PURE__ */ _interopDefaultLegacy(en);
|
|
10
|
-
const zh__default = /* @__PURE__ */ _interopDefaultLegacy(zh);
|
|
11
|
-
const translations = { zh: { ...zh__default.default, ...flat__default.default(discussKitUx.translations.zh) }, en: { ...en__default.default, ...flat__default.default(discussKitUx.translations.en) } };
|
|
7
|
+
const translations = { zh: { ...zh, ...flat(discussKitUx.translations.zh) }, en: { ...en, ...flat(discussKitUx.translations.en) } };
|
|
12
8
|
exports.translations = translations;
|
package/lib/cjs/locales/zh.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const flat = require("flat");
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
showMoreReplies: "\u663E\u793A\u66F4\u591A\u56DE\u590D",
|
|
25
|
-
deleted: "\u8BE5\u8BC4\u8BBA\u5DF2\u88AB\u5220\u9664"
|
|
3
|
+
const zh = flat({
|
|
4
|
+
comments: "条评论",
|
|
5
|
+
comment: "评论",
|
|
6
|
+
poweredBy: "- 由 Discuss Kit 提供支持",
|
|
7
|
+
connect: "连接",
|
|
8
|
+
inputPlaceHolder: "写评论",
|
|
9
|
+
oldest: "最旧",
|
|
10
|
+
newest: "最新",
|
|
11
|
+
loadMore: "点击加载更多",
|
|
12
|
+
connectDIDWallet: "请先连接 DID Wallet.",
|
|
13
|
+
installDIDWallet: "点击拥有你的 DID Wallet→",
|
|
14
|
+
empty: "成为第一个留下评论的人.",
|
|
15
|
+
delete: "删除",
|
|
16
|
+
edit: "编辑",
|
|
17
|
+
confirm: "确认",
|
|
18
|
+
cancel: "取消",
|
|
19
|
+
tip: "提示",
|
|
20
|
+
deleteCommentDesc: "确认删除这条评论?",
|
|
21
|
+
readMore: "更多内容",
|
|
22
|
+
showMoreReplies: "显示更多回复",
|
|
23
|
+
deleted: "该评论已被删除"
|
|
26
24
|
});
|
|
27
25
|
module.exports = zh;
|
package/lib/cjs/session.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const react = require("react");
|
|
4
4
|
const Session = require("@arcblock/did-connect/lib/Session");
|
|
5
5
|
const { SessionProvider, SessionContext, SessionConsumer, withSession } = Session.createAuthServiceSessionContext();
|
|
@@ -1,44 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
4
|
const react = require("react");
|
|
4
5
|
const PropTypes = require("prop-types");
|
|
5
6
|
const react$1 = require("@emotion/react");
|
|
6
7
|
const styles = require("@mui/material/styles");
|
|
7
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
9
|
-
const PropTypes__default = /* @__PURE__ */ _interopDefaultLegacy(PropTypes);
|
|
10
8
|
const defaultTheme = styles.createTheme({});
|
|
11
9
|
const ThemeContext = react.createContext({});
|
|
12
|
-
function ThemeProvider({
|
|
13
|
-
children,
|
|
14
|
-
theme: _theme
|
|
15
|
-
} = {}) {
|
|
10
|
+
function ThemeProvider({ children, theme: _theme } = {}) {
|
|
16
11
|
const [theme, setTheme] = react.useState(defaultTheme);
|
|
17
12
|
react.useEffect(() => {
|
|
18
13
|
if (_theme && typeof _theme === "object")
|
|
19
14
|
setTheme(_theme);
|
|
20
15
|
}, [_theme]);
|
|
21
16
|
if (theme) {
|
|
22
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
children: (themeValue) => {
|
|
26
|
-
return /* @__PURE__ */ jsxRuntime.jsx(styles.ThemeProvider, {
|
|
27
|
-
theme: themeValue,
|
|
28
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.ThemeProvider, {
|
|
29
|
-
theme: themeValue,
|
|
30
|
-
children
|
|
31
|
-
})
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
});
|
|
17
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Consumer, { children: (themeValue) => {
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsx(styles.ThemeProvider, { theme: themeValue, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.ThemeProvider, { theme: themeValue, children }) });
|
|
19
|
+
} }) });
|
|
36
20
|
}
|
|
37
21
|
return children;
|
|
38
22
|
}
|
|
39
23
|
ThemeProvider.propTypes = {
|
|
40
|
-
children:
|
|
41
|
-
theme:
|
|
24
|
+
children: PropTypes.any.isRequired,
|
|
25
|
+
theme: PropTypes.object.isRequired
|
|
42
26
|
};
|
|
43
27
|
function useThemeContext() {
|
|
44
28
|
return react.useContext(ThemeContext);
|
package/lib/cjs/ws.js
CHANGED
|
@@ -3,8 +3,6 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
3
3
|
const react = require("react");
|
|
4
4
|
const Cookie = require("js-cookie");
|
|
5
5
|
const ws = require("@arcblock/ws");
|
|
6
|
-
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
7
|
-
const Cookie__default = /* @__PURE__ */ _interopDefaultLegacy(Cookie);
|
|
8
6
|
let client;
|
|
9
7
|
function create(prefix) {
|
|
10
8
|
const pathPrefix = prefix;
|
|
@@ -12,10 +10,10 @@ function create(prefix) {
|
|
|
12
10
|
return new ws.WsClient(url, {
|
|
13
11
|
heartbeatIntervalMs: 10 * 1e3,
|
|
14
12
|
params: () => ({
|
|
15
|
-
token:
|
|
13
|
+
token: Cookie.get("login_token")
|
|
16
14
|
}),
|
|
17
15
|
reconnectAfterMs: (tries) => {
|
|
18
|
-
if (
|
|
16
|
+
if (Cookie.get("login_token")) {
|
|
19
17
|
return Math.floor(Math.random() * 2 ** tries * 1e3);
|
|
20
18
|
}
|
|
21
19
|
return 2 ** tries * 1e3;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { getWebWalletUrl } from "@arcblock/did-connect/lib/utils";
|
|
2
3
|
import Comments from "./comments";
|
|
3
4
|
import { SessionProvider } from "./session";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
const CommentsHOC = (WrappedComponent) => {
|
|
6
6
|
const webWalletUrl = getWebWalletUrl();
|
|
7
7
|
return function(props) {
|
|
8
|
-
return /* @__PURE__ */ jsx(SessionProvider, {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
children: (session) => {
|
|
12
|
-
return /* @__PURE__ */ jsx(WrappedComponent, {
|
|
13
|
-
...props,
|
|
14
|
-
session: session.session,
|
|
15
|
-
showConnectBtn: true
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
8
|
+
return /* @__PURE__ */ jsx(SessionProvider, { serviceHost: "/", webWalletUrl, children: (session) => {
|
|
9
|
+
return /* @__PURE__ */ jsx(WrappedComponent, { ...props, session: session.session, showConnectBtn: true });
|
|
10
|
+
} });
|
|
19
11
|
};
|
|
20
12
|
};
|
|
21
13
|
const commentsWithSession = CommentsHOC(Comments);
|