elseware-ui 2.31.2 → 2.31.4
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -226
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -226
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1444,7 +1444,7 @@ interface CommentThreadProps {
|
|
|
1444
1444
|
onDelete?: (comment: CommentEntity) => void;
|
|
1445
1445
|
onReport?: (comment: CommentEntity) => void;
|
|
1446
1446
|
}
|
|
1447
|
-
declare function CommentThread({
|
|
1447
|
+
declare function CommentThread({ currentUser, dataSource, loading, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1448
1448
|
|
|
1449
1449
|
type SortOption = {
|
|
1450
1450
|
value: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1444,7 +1444,7 @@ interface CommentThreadProps {
|
|
|
1444
1444
|
onDelete?: (comment: CommentEntity) => void;
|
|
1445
1445
|
onReport?: (comment: CommentEntity) => void;
|
|
1446
1446
|
}
|
|
1447
|
-
declare function CommentThread({
|
|
1447
|
+
declare function CommentThread({ currentUser, dataSource, loading, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1448
1448
|
|
|
1449
1449
|
type SortOption = {
|
|
1450
1450
|
value: string;
|
package/dist/index.js
CHANGED
|
@@ -17952,149 +17952,6 @@ function CommentList({
|
|
|
17952
17952
|
)) });
|
|
17953
17953
|
}
|
|
17954
17954
|
var CommentList_default = CommentList;
|
|
17955
|
-
function EditCommentModal({
|
|
17956
|
-
show,
|
|
17957
|
-
comment,
|
|
17958
|
-
handleCloseModal,
|
|
17959
|
-
onSubmit
|
|
17960
|
-
}) {
|
|
17961
|
-
if (!comment) return null;
|
|
17962
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Modal_default, { title: "Edit Comment", show, handleOnClose: handleCloseModal, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
17963
|
-
Form,
|
|
17964
|
-
{
|
|
17965
|
-
enableReinitialize: true,
|
|
17966
|
-
initialValues: {
|
|
17967
|
-
content: comment.content
|
|
17968
|
-
},
|
|
17969
|
-
onSubmit: async (values) => {
|
|
17970
|
-
await onSubmit?.(comment, values.content);
|
|
17971
|
-
handleCloseModal();
|
|
17972
|
-
},
|
|
17973
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
17974
|
-
/* @__PURE__ */ jsxRuntime.jsx(TextArea_default, { name: "content", rows: 5, placeholder: "Comment" }),
|
|
17975
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button_default, { type: "submit", variant: "success", text: "Save Changes" })
|
|
17976
|
-
] })
|
|
17977
|
-
}
|
|
17978
|
-
) });
|
|
17979
|
-
}
|
|
17980
|
-
var EditCommentModal_default = EditCommentModal;
|
|
17981
|
-
function DeleteCommentModal({
|
|
17982
|
-
show,
|
|
17983
|
-
comment,
|
|
17984
|
-
handleCloseModal,
|
|
17985
|
-
onDelete
|
|
17986
|
-
}) {
|
|
17987
|
-
if (!comment) return null;
|
|
17988
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Modal_default, { title: "Delete Comment", show, handleOnClose: handleCloseModal, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-5", children: [
|
|
17989
|
-
/* @__PURE__ */ jsxRuntime.jsx(Typography.Paragraph, { children: "Are you sure you want to permanently delete this comment?" }),
|
|
17990
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3 justify-end", children: [
|
|
17991
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button_default, { text: "Cancel", appearance: "ghost", onClick: handleCloseModal }),
|
|
17992
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17993
|
-
Button_default,
|
|
17994
|
-
{
|
|
17995
|
-
text: "Delete",
|
|
17996
|
-
variant: "danger",
|
|
17997
|
-
onClick: async () => {
|
|
17998
|
-
await onDelete?.(comment);
|
|
17999
|
-
handleCloseModal();
|
|
18000
|
-
}
|
|
18001
|
-
}
|
|
18002
|
-
)
|
|
18003
|
-
] })
|
|
18004
|
-
] }) });
|
|
18005
|
-
}
|
|
18006
|
-
var DeleteCommentModal_default = DeleteCommentModal;
|
|
18007
|
-
var REPORT_REASONS = [
|
|
18008
|
-
{
|
|
18009
|
-
label: "Spam",
|
|
18010
|
-
value: "spam"
|
|
18011
|
-
},
|
|
18012
|
-
{
|
|
18013
|
-
label: "Harassment",
|
|
18014
|
-
value: "harassment"
|
|
18015
|
-
},
|
|
18016
|
-
{
|
|
18017
|
-
label: "Hate Speech",
|
|
18018
|
-
value: "hate_speech"
|
|
18019
|
-
},
|
|
18020
|
-
{
|
|
18021
|
-
label: "Misleading Information",
|
|
18022
|
-
value: "misleading_information"
|
|
18023
|
-
},
|
|
18024
|
-
{
|
|
18025
|
-
label: "Other",
|
|
18026
|
-
value: "other"
|
|
18027
|
-
}
|
|
18028
|
-
];
|
|
18029
|
-
function ReportCommentModal({
|
|
18030
|
-
show,
|
|
18031
|
-
comment,
|
|
18032
|
-
handleCloseModal,
|
|
18033
|
-
onSubmit
|
|
18034
|
-
}) {
|
|
18035
|
-
if (!comment) return null;
|
|
18036
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Modal_default, { title: "Report Comment", show, handleOnClose: handleCloseModal, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18037
|
-
Form,
|
|
18038
|
-
{
|
|
18039
|
-
initialValues: {
|
|
18040
|
-
reason: "",
|
|
18041
|
-
description: ""
|
|
18042
|
-
},
|
|
18043
|
-
onSubmit: async (values) => {
|
|
18044
|
-
await onSubmit?.(comment, {
|
|
18045
|
-
reason: values.reason,
|
|
18046
|
-
description: values.description
|
|
18047
|
-
});
|
|
18048
|
-
handleCloseModal();
|
|
18049
|
-
},
|
|
18050
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
18051
|
-
/* @__PURE__ */ jsxRuntime.jsx(Select_default, { name: "reason", placeholder: "Reason", options: REPORT_REASONS }),
|
|
18052
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18053
|
-
TextArea_default,
|
|
18054
|
-
{
|
|
18055
|
-
name: "description",
|
|
18056
|
-
rows: 4,
|
|
18057
|
-
placeholder: "Additional details"
|
|
18058
|
-
}
|
|
18059
|
-
),
|
|
18060
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button_default, { type: "submit", variant: "danger", text: "Submit Report" })
|
|
18061
|
-
] })
|
|
18062
|
-
}
|
|
18063
|
-
) });
|
|
18064
|
-
}
|
|
18065
|
-
var ReportCommentModal_default = ReportCommentModal;
|
|
18066
|
-
function useCommentModals() {
|
|
18067
|
-
const [showEditModal, setShowEditModal] = React4.useState(false);
|
|
18068
|
-
const [showDeleteModal, setShowDeleteModal] = React4.useState(false);
|
|
18069
|
-
const [showReportModal, setShowReportModal] = React4.useState(false);
|
|
18070
|
-
return {
|
|
18071
|
-
showEditModal,
|
|
18072
|
-
openEditModal: () => setShowEditModal(true),
|
|
18073
|
-
closeEditModal: () => setShowEditModal(false),
|
|
18074
|
-
showDeleteModal,
|
|
18075
|
-
openDeleteModal: () => setShowDeleteModal(true),
|
|
18076
|
-
closeDeleteModal: () => setShowDeleteModal(false),
|
|
18077
|
-
showReportModal,
|
|
18078
|
-
openReportModal: () => setShowReportModal(true),
|
|
18079
|
-
closeReportModal: () => setShowReportModal(false)
|
|
18080
|
-
};
|
|
18081
|
-
}
|
|
18082
|
-
function useCommentSelection() {
|
|
18083
|
-
const [selectedComment, setSelectedComment] = React4.useState(
|
|
18084
|
-
null
|
|
18085
|
-
);
|
|
18086
|
-
function selectComment(comment) {
|
|
18087
|
-
setSelectedComment(comment);
|
|
18088
|
-
}
|
|
18089
|
-
function clearSelection() {
|
|
18090
|
-
setSelectedComment(null);
|
|
18091
|
-
}
|
|
18092
|
-
return {
|
|
18093
|
-
selectedComment,
|
|
18094
|
-
selectComment,
|
|
18095
|
-
clearSelection
|
|
18096
|
-
};
|
|
18097
|
-
}
|
|
18098
17955
|
|
|
18099
17956
|
// src/compositions/comment-thread/utils/buildCommentTree.ts
|
|
18100
17957
|
function buildCommentTree(comments) {
|
|
@@ -18133,14 +17990,6 @@ function updateComment(comments, commentId, updater) {
|
|
|
18133
17990
|
});
|
|
18134
17991
|
}
|
|
18135
17992
|
|
|
18136
|
-
// src/compositions/comment-thread/utils/removeComment.ts
|
|
18137
|
-
function removeComment(comments, commentId) {
|
|
18138
|
-
return comments.filter((comment) => comment.id !== commentId).map((comment) => ({
|
|
18139
|
-
...comment,
|
|
18140
|
-
replies: comment.replies ? removeComment(comment.replies, commentId) : []
|
|
18141
|
-
}));
|
|
18142
|
-
}
|
|
18143
|
-
|
|
18144
17993
|
// src/compositions/comment-thread/utils/insertReply.ts
|
|
18145
17994
|
function insertReply(comments, parentId, reply) {
|
|
18146
17995
|
return comments.map((comment) => {
|
|
@@ -18157,7 +18006,6 @@ function insertReply(comments, parentId, reply) {
|
|
|
18157
18006
|
});
|
|
18158
18007
|
}
|
|
18159
18008
|
function CommentThread({
|
|
18160
|
-
postId,
|
|
18161
18009
|
currentUser,
|
|
18162
18010
|
dataSource,
|
|
18163
18011
|
loading = false,
|
|
@@ -18167,8 +18015,6 @@ function CommentThread({
|
|
|
18167
18015
|
}) {
|
|
18168
18016
|
const [comments, setComments] = React4.useState([]);
|
|
18169
18017
|
const [isLoadingComments, setIsLoadingComments] = React4.useState(true);
|
|
18170
|
-
const selection = useCommentSelection();
|
|
18171
|
-
const modals = useCommentModals();
|
|
18172
18018
|
React4.useEffect(() => {
|
|
18173
18019
|
async function loadComments() {
|
|
18174
18020
|
try {
|
|
@@ -18218,87 +18064,27 @@ function CommentThread({
|
|
|
18218
18064
|
}))
|
|
18219
18065
|
);
|
|
18220
18066
|
}
|
|
18221
|
-
async function handleUpdateComment(comment, content) {
|
|
18222
|
-
const updated = await dataSource.updateComment({
|
|
18223
|
-
id: comment.id,
|
|
18224
|
-
content
|
|
18225
|
-
});
|
|
18226
|
-
setComments((prev) => updateComment(prev, comment.id, () => updated));
|
|
18227
|
-
}
|
|
18228
|
-
async function handleDeleteComment(comment) {
|
|
18229
|
-
await dataSource.deleteComment(comment.id);
|
|
18230
|
-
setComments((prev) => removeComment(prev, comment.id));
|
|
18231
|
-
onDelete?.(comment);
|
|
18232
|
-
}
|
|
18233
|
-
async function handleReportComment(comment, payload) {
|
|
18234
|
-
await dataSource.reportComment?.(
|
|
18235
|
-
comment.id,
|
|
18236
|
-
payload.reason,
|
|
18237
|
-
payload.description
|
|
18238
|
-
);
|
|
18239
|
-
onReport?.(comment);
|
|
18240
|
-
}
|
|
18241
18067
|
if (loading || isLoadingComments) {
|
|
18242
18068
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|
|
18243
18069
|
}
|
|
18244
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18245
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
18246
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18247
|
-
CommentComposer_default,
|
|
18248
|
-
{
|
|
18249
|
-
avatar: currentUser.avatar,
|
|
18250
|
-
onSubmit: handleCreateComment
|
|
18251
|
-
}
|
|
18252
|
-
),
|
|
18253
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18254
|
-
CommentList_default,
|
|
18255
|
-
{
|
|
18256
|
-
comments,
|
|
18257
|
-
onLike: handleLike,
|
|
18258
|
-
onDislike: handleDislike,
|
|
18259
|
-
onReply: handleReply,
|
|
18260
|
-
onEdit: (comment) => {
|
|
18261
|
-
selection.selectComment(comment);
|
|
18262
|
-
onEdit?.(comment);
|
|
18263
|
-
modals.openEditModal();
|
|
18264
|
-
},
|
|
18265
|
-
onDelete: (comment) => {
|
|
18266
|
-
selection.selectComment(comment);
|
|
18267
|
-
modals.openDeleteModal();
|
|
18268
|
-
},
|
|
18269
|
-
onReport: (comment) => {
|
|
18270
|
-
selection.selectComment(comment);
|
|
18271
|
-
onReport?.(comment);
|
|
18272
|
-
modals.openReportModal();
|
|
18273
|
-
}
|
|
18274
|
-
}
|
|
18275
|
-
)
|
|
18276
|
-
] }),
|
|
18277
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18278
|
-
EditCommentModal_default,
|
|
18279
|
-
{
|
|
18280
|
-
show: modals.showEditModal,
|
|
18281
|
-
comment: selection.selectedComment,
|
|
18282
|
-
handleCloseModal: modals.closeEditModal,
|
|
18283
|
-
onSubmit: handleUpdateComment
|
|
18284
|
-
}
|
|
18285
|
-
),
|
|
18070
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
18286
18071
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18287
|
-
|
|
18072
|
+
CommentComposer_default,
|
|
18288
18073
|
{
|
|
18289
|
-
|
|
18290
|
-
|
|
18291
|
-
handleCloseModal: modals.closeDeleteModal,
|
|
18292
|
-
onDelete: handleDeleteComment
|
|
18074
|
+
avatar: currentUser.avatar,
|
|
18075
|
+
onSubmit: handleCreateComment
|
|
18293
18076
|
}
|
|
18294
18077
|
),
|
|
18295
18078
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18296
|
-
|
|
18079
|
+
CommentList_default,
|
|
18297
18080
|
{
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
|
|
18301
|
-
|
|
18081
|
+
comments,
|
|
18082
|
+
onLike: handleLike,
|
|
18083
|
+
onDislike: handleDislike,
|
|
18084
|
+
onReply: handleReply,
|
|
18085
|
+
onEdit,
|
|
18086
|
+
onDelete,
|
|
18087
|
+
onReport
|
|
18302
18088
|
}
|
|
18303
18089
|
)
|
|
18304
18090
|
] });
|