@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
package/lib/es/comments.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
1
2
|
import { useMemo, useEffect, useContext } from "react";
|
|
2
3
|
import { styled } from "@arcblock/ux/lib/Theme";
|
|
3
4
|
import joinUrl from "url-join";
|
|
@@ -16,16 +17,9 @@ import ErrorFallback from "./components/error-fallback";
|
|
|
16
17
|
import { translations } from "./locales";
|
|
17
18
|
import getWsClient, { useSubscription } from "./ws";
|
|
18
19
|
import api, { fetchRatings } from "./api";
|
|
19
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
20
20
|
const useAsyncRetry = (fn, deps = []) => {
|
|
21
|
-
const state = useRequest(fn, {
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
...state,
|
|
26
|
-
value: state == null ? void 0 : state.data,
|
|
27
|
-
retry: state == null ? void 0 : state.run
|
|
28
|
-
};
|
|
21
|
+
const state = useRequest(fn, { refreshDeps: deps });
|
|
22
|
+
return { ...state, value: state == null ? void 0 : state.data, retry: state == null ? void 0 : state.run };
|
|
29
23
|
};
|
|
30
24
|
const getPrefix = () => {
|
|
31
25
|
var _a, _b;
|
|
@@ -35,10 +29,12 @@ const getPrefix = () => {
|
|
|
35
29
|
const getCurrentBlockletComponentName = () => {
|
|
36
30
|
var _a, _b;
|
|
37
31
|
const ensureTrailingSlash = (str) => str.endsWith("/") ? str : `${str}/`;
|
|
38
|
-
const matched = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
const matched = (_b = (_a = window.blocklet) == null ? void 0 : _a.componentMountPoints) == null ? void 0 : _b.find(
|
|
33
|
+
(x) => {
|
|
34
|
+
var _a2;
|
|
35
|
+
return ensureTrailingSlash(x.mountPoint) === ensureTrailingSlash((_a2 = window.blocklet) == null ? void 0 : _a2.prefix);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
42
38
|
return matched == null ? void 0 : matched.title;
|
|
43
39
|
};
|
|
44
40
|
const formatComment = (comment) => {
|
|
@@ -60,58 +56,24 @@ const commentAPI = {
|
|
|
60
56
|
size: params.limit
|
|
61
57
|
};
|
|
62
58
|
const {
|
|
63
|
-
data: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
total
|
|
67
|
-
}
|
|
68
|
-
} = await api.get("/comments", {
|
|
69
|
-
params: copy
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
data: data == null ? void 0 : data.map(formatComment),
|
|
73
|
-
nextCursor,
|
|
74
|
-
total
|
|
75
|
-
};
|
|
59
|
+
data: { data, nextCursor, total }
|
|
60
|
+
} = await api.get("/comments", { params: copy });
|
|
61
|
+
return { data: data == null ? void 0 : data.map(formatComment), nextCursor, total };
|
|
76
62
|
},
|
|
77
|
-
fetchCommentPosition: async ({
|
|
78
|
-
id
|
|
79
|
-
...params
|
|
80
|
-
}) => {
|
|
81
|
-
const {
|
|
82
|
-
data
|
|
83
|
-
} = await api.get(`/comments/${id}/position`, {
|
|
84
|
-
params
|
|
85
|
-
});
|
|
63
|
+
fetchCommentPosition: async ({ id, ...params }) => {
|
|
64
|
+
const { data } = await api.get(`/comments/${id}/position`, { params });
|
|
86
65
|
return data;
|
|
87
66
|
},
|
|
88
|
-
deleteComment: async ({
|
|
89
|
-
id
|
|
90
|
-
}) => {
|
|
91
|
-
const {
|
|
92
|
-
data
|
|
93
|
-
} = await api.delete(`/comments/${id}`);
|
|
67
|
+
deleteComment: async ({ id }) => {
|
|
68
|
+
const { data } = await api.delete(`/comments/${id}`);
|
|
94
69
|
return data;
|
|
95
70
|
},
|
|
96
|
-
updateComment: async ({
|
|
97
|
-
id,
|
|
98
|
-
updatedAt
|
|
99
|
-
}, content) => {
|
|
100
|
-
const {
|
|
101
|
-
data
|
|
102
|
-
} = await api.put(`/comments/${id}`, {
|
|
103
|
-
content,
|
|
104
|
-
updatedAt
|
|
105
|
-
});
|
|
71
|
+
updateComment: async ({ id, updatedAt }, content) => {
|
|
72
|
+
const { data } = await api.put(`/comments/${id}`, { content, updatedAt });
|
|
106
73
|
return formatComment(data);
|
|
107
74
|
},
|
|
108
|
-
reply: async ({
|
|
109
|
-
id
|
|
110
|
-
rootId
|
|
111
|
-
}, content) => {
|
|
112
|
-
const {
|
|
113
|
-
data
|
|
114
|
-
} = await api.post(`/comments/${rootId || id}/replies`, {
|
|
75
|
+
reply: async ({ id, rootId }, content) => {
|
|
76
|
+
const { data } = await api.post(`/comments/${rootId || id}/replies`, {
|
|
115
77
|
content,
|
|
116
78
|
parentId: id,
|
|
117
79
|
link: window.location.href
|
|
@@ -119,18 +81,13 @@ const commentAPI = {
|
|
|
119
81
|
return formatComment(data);
|
|
120
82
|
},
|
|
121
83
|
rate: async (comment, value, ratingType) => {
|
|
122
|
-
await api.post(`/topics/${comment.topicId}/comments/${comment.id}/ratings`, {
|
|
123
|
-
ratingType,
|
|
124
|
-
value
|
|
125
|
-
});
|
|
84
|
+
await api.post(`/topics/${comment.topicId}/comments/${comment.id}/ratings`, { ratingType, value });
|
|
126
85
|
},
|
|
127
86
|
unrate: async (comment) => {
|
|
128
87
|
await api.delete(`/topics/${comment.topicId}/comments/${comment.id}/ratings`);
|
|
129
88
|
},
|
|
130
89
|
fetchRatings: async (id) => {
|
|
131
|
-
const {
|
|
132
|
-
data
|
|
133
|
-
} = await api.get(`/ratings/${id}`);
|
|
90
|
+
const { data } = await api.get(`/ratings/${id}`);
|
|
134
91
|
return data;
|
|
135
92
|
}
|
|
136
93
|
};
|
|
@@ -142,26 +99,11 @@ function DiscussKitComments({
|
|
|
142
99
|
commentInputPosition,
|
|
143
100
|
showTopbar
|
|
144
101
|
}) {
|
|
145
|
-
useDefaultApiErrorHandler({
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
const {
|
|
149
|
-
|
|
150
|
-
} = useContext(SessionContext) || {};
|
|
151
|
-
const {
|
|
152
|
-
state,
|
|
153
|
-
sort,
|
|
154
|
-
add,
|
|
155
|
-
updateCommentState
|
|
156
|
-
} = useCommentsContext();
|
|
157
|
-
const {
|
|
158
|
-
total,
|
|
159
|
-
order,
|
|
160
|
-
initialized
|
|
161
|
-
} = state;
|
|
162
|
-
const {
|
|
163
|
-
t
|
|
164
|
-
} = useLocaleContext();
|
|
102
|
+
useDefaultApiErrorHandler({ request: api });
|
|
103
|
+
const { session } = useContext(SessionContext) || {};
|
|
104
|
+
const { state, sort, add, updateCommentState } = useCommentsContext();
|
|
105
|
+
const { total, order, initialized } = state;
|
|
106
|
+
const { t } = useLocaleContext();
|
|
165
107
|
const objectRatingState = useAsyncRetry(() => fetchRatings(object.id));
|
|
166
108
|
const handlers = {
|
|
167
109
|
ADD_COMMENT: (data) => {
|
|
@@ -176,9 +118,7 @@ function DiscussKitComments({
|
|
|
176
118
|
});
|
|
177
119
|
},
|
|
178
120
|
RATING: () => objectRatingState.retry(),
|
|
179
|
-
RATING_COMMENT: async ({
|
|
180
|
-
commentId
|
|
181
|
-
}) => {
|
|
121
|
+
RATING_COMMENT: async ({ commentId }) => {
|
|
182
122
|
const rating = await fetchRatings(commentId);
|
|
183
123
|
updateCommentState(commentId, (current) => ({
|
|
184
124
|
...current,
|
|
@@ -186,42 +126,27 @@ function DiscussKitComments({
|
|
|
186
126
|
}));
|
|
187
127
|
}
|
|
188
128
|
};
|
|
189
|
-
useSubscription(
|
|
190
|
-
|
|
191
|
-
data
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
129
|
+
useSubscription(
|
|
130
|
+
object.id,
|
|
131
|
+
({ event, data }) => {
|
|
132
|
+
var _a;
|
|
133
|
+
(_a = handlers[event]) == null ? void 0 : _a.call(handlers, data);
|
|
134
|
+
},
|
|
135
|
+
[object.id, state]
|
|
136
|
+
);
|
|
196
137
|
if (!initialized) {
|
|
197
|
-
return /* @__PURE__ */ jsx(Box, {
|
|
198
|
-
width: "100%",
|
|
199
|
-
display: "flex",
|
|
200
|
-
justifyContent: "center",
|
|
201
|
-
children: /* @__PURE__ */ jsx(CircularProgress, {})
|
|
202
|
-
});
|
|
138
|
+
return /* @__PURE__ */ jsx(Box, { width: "100%", display: "flex", justifyContent: "center", children: /* @__PURE__ */ jsx(CircularProgress, {}) });
|
|
203
139
|
}
|
|
204
140
|
const sendComment = async (content) => {
|
|
205
|
-
const {
|
|
206
|
-
data
|
|
207
|
-
} = await api.post("/comments", {
|
|
208
|
-
content,
|
|
209
|
-
object
|
|
210
|
-
});
|
|
141
|
+
const { data } = await api.post("/comments", { content, object });
|
|
211
142
|
add(formatComment(data));
|
|
212
143
|
};
|
|
213
|
-
const handleOnRate = async ({
|
|
214
|
-
ratingType,
|
|
215
|
-
value
|
|
216
|
-
}) => {
|
|
144
|
+
const handleOnRate = async ({ ratingType, value }) => {
|
|
217
145
|
if (!session.user) {
|
|
218
146
|
session.login();
|
|
219
147
|
throw new Error("Unauthenticated.");
|
|
220
148
|
}
|
|
221
|
-
await api.post(`/topics/${object.id}/ratings`, {
|
|
222
|
-
ratingType,
|
|
223
|
-
value
|
|
224
|
-
});
|
|
149
|
+
await api.post(`/topics/${object.id}/ratings`, { ratingType, value });
|
|
225
150
|
};
|
|
226
151
|
const handleOnUnrate = async () => {
|
|
227
152
|
if (!session.user) {
|
|
@@ -230,88 +155,52 @@ function DiscussKitComments({
|
|
|
230
155
|
}
|
|
231
156
|
await api.delete(`/topics/${object.id}/ratings`);
|
|
232
157
|
};
|
|
233
|
-
return /* @__PURE__ */ jsxs(Container, {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
})
|
|
280
|
-
})]
|
|
281
|
-
}), !!total && showTopbar && /* @__PURE__ */ jsxs(Box, {
|
|
282
|
-
display: "flex",
|
|
283
|
-
justifyContent: "space-between",
|
|
284
|
-
mt: 3,
|
|
285
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
286
|
-
children: [total > 0 ? `${total} ${t("comments")}` : t("comment"), " "]
|
|
287
|
-
}), /* @__PURE__ */ jsxs(ButtonGroup, {
|
|
288
|
-
children: [/* @__PURE__ */ jsx(Button, {
|
|
289
|
-
variant: "contained",
|
|
290
|
-
color: order !== "desc" ? "primary" : "inherit",
|
|
291
|
-
size: "small",
|
|
292
|
-
onClick: () => sort("asc"),
|
|
293
|
-
className: order !== "desc" ? "" : "unselected-button",
|
|
294
|
-
children: t("oldest")
|
|
295
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
296
|
-
variant: "contained",
|
|
297
|
-
color: order === "desc" ? "primary" : "inherit",
|
|
298
|
-
size: "small",
|
|
299
|
-
onClick: () => sort("desc"),
|
|
300
|
-
className: order === "desc" ? "" : "unselected-button",
|
|
301
|
-
children: t("newest")
|
|
302
|
-
})]
|
|
303
|
-
})]
|
|
304
|
-
}), /* @__PURE__ */ jsx(CommentList, {
|
|
305
|
-
className: "comment-list"
|
|
306
|
-
}), session.user && commentInputPosition === "bottom" && /* @__PURE__ */ jsx(Box, {
|
|
307
|
-
mt: 6,
|
|
308
|
-
children: /* @__PURE__ */ jsx(CommentInput, {
|
|
309
|
-
send: sendComment,
|
|
310
|
-
draftKey: `object-${object.id}`,
|
|
311
|
-
autoFocus: false
|
|
312
|
-
})
|
|
313
|
-
})]
|
|
314
|
-
});
|
|
158
|
+
return /* @__PURE__ */ jsxs(Container, { className: "comment-container", children: [
|
|
159
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
160
|
+
/* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "end", children: [
|
|
161
|
+
displayReaction && objectRatingState.value && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(GithubReaction, { data: objectRatingState.value, onRate: handleOnRate, onUnrate: handleOnUnrate }) }),
|
|
162
|
+
displayConnectButton && (session.user ? /* @__PURE__ */ jsx(SessionManager, { style: { padding: 0 }, showText: true, showRole: true, session }) : /* @__PURE__ */ jsx(Button, { size: "medium", variant: "contained", color: "primary", onClick: () => session.login(), children: t("connect") }))
|
|
163
|
+
] }),
|
|
164
|
+
displayConnectButton && !session.user && /* @__PURE__ */ jsx("div", { className: "input-no-connect", children: /* @__PURE__ */ jsxs("span", { className: "connect-tip", children: [
|
|
165
|
+
t("connectDIDWallet"),
|
|
166
|
+
" ",
|
|
167
|
+
/* @__PURE__ */ jsx("a", { className: "down-load-wallet", href: "https://www.didwallet.io/", target: "_blank", rel: "noreferrer", children: t("installDIDWallet") })
|
|
168
|
+
] }) }),
|
|
169
|
+
session.user && commentInputPosition === "top" && /* @__PURE__ */ jsx(Box, { mt: 2, className: "comment-editor", children: /* @__PURE__ */ jsx(CommentInput, { send: sendComment, draftKey: `object-${object.id}`, autoFocus: false }) })
|
|
170
|
+
] }),
|
|
171
|
+
!!total && showTopbar && /* @__PURE__ */ jsxs(Box, { display: "flex", justifyContent: "space-between", mt: 3, children: [
|
|
172
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
173
|
+
total > 0 ? `${total} ${t("comments")}` : t("comment"),
|
|
174
|
+
" "
|
|
175
|
+
] }),
|
|
176
|
+
/* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
Button,
|
|
179
|
+
{
|
|
180
|
+
variant: "contained",
|
|
181
|
+
color: order !== "desc" ? "primary" : "inherit",
|
|
182
|
+
size: "small",
|
|
183
|
+
onClick: () => sort("asc"),
|
|
184
|
+
className: order !== "desc" ? "" : "unselected-button",
|
|
185
|
+
children: t("oldest")
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ jsx(
|
|
189
|
+
Button,
|
|
190
|
+
{
|
|
191
|
+
variant: "contained",
|
|
192
|
+
color: order === "desc" ? "primary" : "inherit",
|
|
193
|
+
size: "small",
|
|
194
|
+
onClick: () => sort("desc"),
|
|
195
|
+
className: order === "desc" ? "" : "unselected-button",
|
|
196
|
+
children: t("newest")
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
] })
|
|
200
|
+
] }),
|
|
201
|
+
/* @__PURE__ */ jsx(CommentList, { className: "comment-list" }),
|
|
202
|
+
session.user && commentInputPosition === "bottom" && /* @__PURE__ */ jsx(Box, { mt: 6, children: /* @__PURE__ */ jsx(CommentInput, { send: sendComment, draftKey: `object-${object.id}`, autoFocus: false }) })
|
|
203
|
+
] });
|
|
315
204
|
}
|
|
316
205
|
DiscussKitComments.propTypes = {
|
|
317
206
|
displayConnectButton: PropTypes.bool,
|
|
@@ -342,15 +231,14 @@ function Wrapper({
|
|
|
342
231
|
if (!(target == null ? void 0 : target.id)) {
|
|
343
232
|
throw new Error("target is required.");
|
|
344
233
|
}
|
|
345
|
-
const {
|
|
346
|
-
locale = "en"
|
|
347
|
-
} = useLocaleContext() || {};
|
|
234
|
+
const { locale = "en" } = useLocaleContext() || {};
|
|
348
235
|
const object = useMemo(
|
|
349
236
|
() => ({
|
|
350
237
|
...target,
|
|
351
238
|
link: window.location.href,
|
|
352
239
|
blockletName: getCurrentBlockletComponentName()
|
|
353
240
|
}),
|
|
241
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
354
242
|
[target]
|
|
355
243
|
);
|
|
356
244
|
const _prefix = prefix || getPrefix();
|
|
@@ -367,33 +255,19 @@ function Wrapper({
|
|
|
367
255
|
};
|
|
368
256
|
}, []);
|
|
369
257
|
api.defaults.baseURL = joinUrl(_prefix, "/api/");
|
|
370
|
-
return /* @__PURE__ */ jsx(UploaderProvider, {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
order,
|
|
384
|
-
autoCollapse,
|
|
385
|
-
allowCopyLink,
|
|
386
|
-
showProfileCard,
|
|
387
|
-
children: /* @__PURE__ */ jsx(DiscussKitComments, {
|
|
388
|
-
...rest,
|
|
389
|
-
object
|
|
390
|
-
})
|
|
391
|
-
})
|
|
392
|
-
})
|
|
393
|
-
})
|
|
394
|
-
})
|
|
395
|
-
})
|
|
396
|
-
});
|
|
258
|
+
return /* @__PURE__ */ jsx(UploaderProvider, { children: /* @__PURE__ */ jsx(ErrorBoundary, { FallbackComponent: ErrorFallback, children: /* @__PURE__ */ jsx(LocaleProvider, { translations, locale, children: /* @__PURE__ */ jsx(InternalThemeProvider, { children: /* @__PURE__ */ jsx(DefaultEditorConfigProvider, { request: api, children: /* @__PURE__ */ jsx(
|
|
259
|
+
CommentsProvider,
|
|
260
|
+
{
|
|
261
|
+
target: object,
|
|
262
|
+
api: commentAPI,
|
|
263
|
+
flatView,
|
|
264
|
+
order,
|
|
265
|
+
autoCollapse,
|
|
266
|
+
allowCopyLink,
|
|
267
|
+
showProfileCard,
|
|
268
|
+
children: /* @__PURE__ */ jsx(DiscussKitComments, { ...rest, object })
|
|
269
|
+
}
|
|
270
|
+
) }) }) }) }) });
|
|
397
271
|
}
|
|
398
272
|
Wrapper.propTypes = {
|
|
399
273
|
target: PropTypes.shape({
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
2
|
import PropTypes from "prop-types";
|
|
2
3
|
import Alert from "@mui/material/Alert";
|
|
3
4
|
import AlertTitle from "@mui/material/AlertTitle";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
return /* @__PURE__ */ jsxs(Alert, {
|
|
12
|
-
severity: "warning",
|
|
13
|
-
children: [/* @__PURE__ */ jsx(AlertTitle, {
|
|
14
|
-
children: "Oops!"
|
|
15
|
-
}), "Discuss Kit is not working properly.", errorMessageElement]
|
|
16
|
-
});
|
|
5
|
+
function ErrorFallback({ error }) {
|
|
6
|
+
const errorMessageElement = process.env.NODE_ENV === "production" ? null : /* @__PURE__ */ jsx("pre", { children: error.message });
|
|
7
|
+
return /* @__PURE__ */ jsxs(Alert, { severity: "warning", children: [
|
|
8
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: "Oops!" }),
|
|
9
|
+
"Discuss Kit is not working properly.",
|
|
10
|
+
errorMessageElement
|
|
11
|
+
] });
|
|
17
12
|
}
|
|
18
13
|
ErrorFallback.propTypes = {
|
|
19
14
|
error: PropTypes.instanceOf(Error).isRequired
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
1
2
|
import { useState } from "react";
|
|
2
3
|
import PropTypes from "prop-types";
|
|
3
4
|
import { styled } from "@arcblock/ux/lib/Theme";
|
|
@@ -6,11 +7,7 @@ import { MoreVert } from "@mui/icons-material";
|
|
|
6
7
|
import Box from "@mui/material/Box";
|
|
7
8
|
import MuiMenu from "@mui/material/Menu";
|
|
8
9
|
import MuiMenuItem from "@mui/material/MenuItem";
|
|
9
|
-
|
|
10
|
-
function Menu({
|
|
11
|
-
items,
|
|
12
|
-
...rest
|
|
13
|
-
}) {
|
|
10
|
+
function Menu({ items, ...rest }) {
|
|
14
11
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
15
12
|
const open = Boolean(anchorEl);
|
|
16
13
|
const handleClick = (event) => {
|
|
@@ -19,48 +16,35 @@ function Menu({
|
|
|
19
16
|
const handleClose = () => {
|
|
20
17
|
setAnchorEl(null);
|
|
21
18
|
};
|
|
22
|
-
return /* @__PURE__ */ jsxs(Root, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
handleClose();
|
|
52
|
-
};
|
|
53
|
-
return /* @__PURE__ */ jsx(StyledMenuItem, {
|
|
54
|
-
onClick: _onClick,
|
|
55
|
-
...itemProps,
|
|
56
|
-
children: /* @__PURE__ */ jsx(Box, {
|
|
57
|
-
minWidth: 100,
|
|
58
|
-
children: text
|
|
59
|
-
})
|
|
60
|
-
}, index);
|
|
61
|
-
})
|
|
62
|
-
})]
|
|
63
|
-
});
|
|
19
|
+
return /* @__PURE__ */ jsxs(Root, { ...rest, children: [
|
|
20
|
+
/* @__PURE__ */ jsx(IconButton, { size: "medium", onClick: handleClick, children: /* @__PURE__ */ jsx(MoreVert, { sx: { fontSize: 18 } }) }),
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
MuiMenu,
|
|
23
|
+
{
|
|
24
|
+
anchorEl,
|
|
25
|
+
anchorOrigin: {
|
|
26
|
+
vertical: "bottom",
|
|
27
|
+
horizontal: "right"
|
|
28
|
+
},
|
|
29
|
+
transformOrigin: {
|
|
30
|
+
vertical: "top",
|
|
31
|
+
horizontal: "right"
|
|
32
|
+
},
|
|
33
|
+
open,
|
|
34
|
+
onClose: handleClose,
|
|
35
|
+
children: items.map(({ onClick, text, ...itemProps }, index) => {
|
|
36
|
+
const _onClick = () => {
|
|
37
|
+
onClick();
|
|
38
|
+
handleClose();
|
|
39
|
+
};
|
|
40
|
+
return (
|
|
41
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
42
|
+
/* @__PURE__ */ jsx(StyledMenuItem, { onClick: _onClick, ...itemProps, children: /* @__PURE__ */ jsx(Box, { minWidth: 100, children: text }) }, index)
|
|
43
|
+
);
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
] });
|
|
64
48
|
}
|
|
65
49
|
Menu.propTypes = {
|
|
66
50
|
items: PropTypes.array.isRequired
|
package/lib/es/locales/en.js
CHANGED
|
@@ -9,7 +9,7 @@ const en = flat({
|
|
|
9
9
|
newest: "Newest",
|
|
10
10
|
loadMore: "Click To Load More",
|
|
11
11
|
connectDIDWallet: "Please connect DID Wallet.",
|
|
12
|
-
installDIDWallet: "Click to get your own DID Wallet
|
|
12
|
+
installDIDWallet: "Click to get your own DID Wallet→",
|
|
13
13
|
empty: "Be the first to leave a comment.",
|
|
14
14
|
delete: "Delete",
|
|
15
15
|
edit: "Edit",
|
package/lib/es/locales/zh.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import flat from "flat";
|
|
2
2
|
const zh = flat({
|
|
3
|
-
comments: "
|
|
4
|
-
comment: "
|
|
5
|
-
poweredBy: "-
|
|
6
|
-
connect: "
|
|
7
|
-
inputPlaceHolder: "
|
|
8
|
-
oldest: "
|
|
9
|
-
newest: "
|
|
10
|
-
loadMore: "
|
|
11
|
-
connectDIDWallet: "
|
|
12
|
-
installDIDWallet: "
|
|
13
|
-
empty: "
|
|
14
|
-
delete: "
|
|
15
|
-
edit: "
|
|
16
|
-
confirm: "
|
|
17
|
-
cancel: "
|
|
18
|
-
tip: "
|
|
19
|
-
deleteCommentDesc: "
|
|
20
|
-
readMore: "
|
|
21
|
-
showMoreReplies: "
|
|
22
|
-
deleted: "
|
|
3
|
+
comments: "条评论",
|
|
4
|
+
comment: "评论",
|
|
5
|
+
poweredBy: "- 由 Discuss Kit 提供支持",
|
|
6
|
+
connect: "连接",
|
|
7
|
+
inputPlaceHolder: "写评论",
|
|
8
|
+
oldest: "最旧",
|
|
9
|
+
newest: "最新",
|
|
10
|
+
loadMore: "点击加载更多",
|
|
11
|
+
connectDIDWallet: "请先连接 DID Wallet.",
|
|
12
|
+
installDIDWallet: "点击拥有你的 DID Wallet→",
|
|
13
|
+
empty: "成为第一个留下评论的人.",
|
|
14
|
+
delete: "删除",
|
|
15
|
+
edit: "编辑",
|
|
16
|
+
confirm: "确认",
|
|
17
|
+
cancel: "取消",
|
|
18
|
+
tip: "提示",
|
|
19
|
+
deleteCommentDesc: "确认删除这条评论?",
|
|
20
|
+
readMore: "更多内容",
|
|
21
|
+
showMoreReplies: "显示更多回复",
|
|
22
|
+
deleted: "该评论已被删除"
|
|
23
23
|
});
|
|
24
24
|
export {
|
|
25
25
|
zh as default
|
package/lib/es/theme-provider.js
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
1
2
|
import { createContext, useState, useEffect, useContext } from "react";
|
|
2
3
|
import PropTypes from "prop-types";
|
|
3
4
|
import { ThemeProvider as ThemeProvider$2 } from "@emotion/react";
|
|
4
5
|
import { createTheme, ThemeProvider as ThemeProvider$1 } from "@mui/material/styles";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
const defaultTheme = createTheme({});
|
|
7
7
|
const ThemeContext = createContext({});
|
|
8
|
-
function ThemeProvider({
|
|
9
|
-
children,
|
|
10
|
-
theme: _theme
|
|
11
|
-
} = {}) {
|
|
8
|
+
function ThemeProvider({ children, theme: _theme } = {}) {
|
|
12
9
|
const [theme, setTheme] = useState(defaultTheme);
|
|
13
10
|
useEffect(() => {
|
|
14
11
|
if (_theme && typeof _theme === "object")
|
|
15
12
|
setTheme(_theme);
|
|
16
13
|
}, [_theme]);
|
|
17
14
|
if (theme) {
|
|
18
|
-
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children: (themeValue) => {
|
|
22
|
-
return /* @__PURE__ */ jsx(ThemeProvider$1, {
|
|
23
|
-
theme: themeValue,
|
|
24
|
-
children: /* @__PURE__ */ jsx(ThemeProvider$2, {
|
|
25
|
-
theme: themeValue,
|
|
26
|
-
children
|
|
27
|
-
})
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
});
|
|
15
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: theme, children: /* @__PURE__ */ jsx(ThemeContext.Consumer, { children: (themeValue) => {
|
|
16
|
+
return /* @__PURE__ */ jsx(ThemeProvider$1, { theme: themeValue, children: /* @__PURE__ */ jsx(ThemeProvider$2, { theme: themeValue, children }) });
|
|
17
|
+
} }) });
|
|
32
18
|
}
|
|
33
19
|
return children;
|
|
34
20
|
}
|