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.mjs
CHANGED
|
@@ -17924,149 +17924,6 @@ function CommentList({
|
|
|
17924
17924
|
)) });
|
|
17925
17925
|
}
|
|
17926
17926
|
var CommentList_default = CommentList;
|
|
17927
|
-
function EditCommentModal({
|
|
17928
|
-
show,
|
|
17929
|
-
comment,
|
|
17930
|
-
handleCloseModal,
|
|
17931
|
-
onSubmit
|
|
17932
|
-
}) {
|
|
17933
|
-
if (!comment) return null;
|
|
17934
|
-
return /* @__PURE__ */ jsx(Modal_default, { title: "Edit Comment", show, handleOnClose: handleCloseModal, children: /* @__PURE__ */ jsx(
|
|
17935
|
-
Form,
|
|
17936
|
-
{
|
|
17937
|
-
enableReinitialize: true,
|
|
17938
|
-
initialValues: {
|
|
17939
|
-
content: comment.content
|
|
17940
|
-
},
|
|
17941
|
-
onSubmit: async (values) => {
|
|
17942
|
-
await onSubmit?.(comment, values.content);
|
|
17943
|
-
handleCloseModal();
|
|
17944
|
-
},
|
|
17945
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
17946
|
-
/* @__PURE__ */ jsx(TextArea_default, { name: "content", rows: 5, placeholder: "Comment" }),
|
|
17947
|
-
/* @__PURE__ */ jsx(Button_default, { type: "submit", variant: "success", text: "Save Changes" })
|
|
17948
|
-
] })
|
|
17949
|
-
}
|
|
17950
|
-
) });
|
|
17951
|
-
}
|
|
17952
|
-
var EditCommentModal_default = EditCommentModal;
|
|
17953
|
-
function DeleteCommentModal({
|
|
17954
|
-
show,
|
|
17955
|
-
comment,
|
|
17956
|
-
handleCloseModal,
|
|
17957
|
-
onDelete
|
|
17958
|
-
}) {
|
|
17959
|
-
if (!comment) return null;
|
|
17960
|
-
return /* @__PURE__ */ jsx(Modal_default, { title: "Delete Comment", show, handleOnClose: handleCloseModal, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-5", children: [
|
|
17961
|
-
/* @__PURE__ */ jsx(Typography.Paragraph, { children: "Are you sure you want to permanently delete this comment?" }),
|
|
17962
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-3 justify-end", children: [
|
|
17963
|
-
/* @__PURE__ */ jsx(Button_default, { text: "Cancel", appearance: "ghost", onClick: handleCloseModal }),
|
|
17964
|
-
/* @__PURE__ */ jsx(
|
|
17965
|
-
Button_default,
|
|
17966
|
-
{
|
|
17967
|
-
text: "Delete",
|
|
17968
|
-
variant: "danger",
|
|
17969
|
-
onClick: async () => {
|
|
17970
|
-
await onDelete?.(comment);
|
|
17971
|
-
handleCloseModal();
|
|
17972
|
-
}
|
|
17973
|
-
}
|
|
17974
|
-
)
|
|
17975
|
-
] })
|
|
17976
|
-
] }) });
|
|
17977
|
-
}
|
|
17978
|
-
var DeleteCommentModal_default = DeleteCommentModal;
|
|
17979
|
-
var REPORT_REASONS = [
|
|
17980
|
-
{
|
|
17981
|
-
label: "Spam",
|
|
17982
|
-
value: "spam"
|
|
17983
|
-
},
|
|
17984
|
-
{
|
|
17985
|
-
label: "Harassment",
|
|
17986
|
-
value: "harassment"
|
|
17987
|
-
},
|
|
17988
|
-
{
|
|
17989
|
-
label: "Hate Speech",
|
|
17990
|
-
value: "hate_speech"
|
|
17991
|
-
},
|
|
17992
|
-
{
|
|
17993
|
-
label: "Misleading Information",
|
|
17994
|
-
value: "misleading_information"
|
|
17995
|
-
},
|
|
17996
|
-
{
|
|
17997
|
-
label: "Other",
|
|
17998
|
-
value: "other"
|
|
17999
|
-
}
|
|
18000
|
-
];
|
|
18001
|
-
function ReportCommentModal({
|
|
18002
|
-
show,
|
|
18003
|
-
comment,
|
|
18004
|
-
handleCloseModal,
|
|
18005
|
-
onSubmit
|
|
18006
|
-
}) {
|
|
18007
|
-
if (!comment) return null;
|
|
18008
|
-
return /* @__PURE__ */ jsx(Modal_default, { title: "Report Comment", show, handleOnClose: handleCloseModal, children: /* @__PURE__ */ jsx(
|
|
18009
|
-
Form,
|
|
18010
|
-
{
|
|
18011
|
-
initialValues: {
|
|
18012
|
-
reason: "",
|
|
18013
|
-
description: ""
|
|
18014
|
-
},
|
|
18015
|
-
onSubmit: async (values) => {
|
|
18016
|
-
await onSubmit?.(comment, {
|
|
18017
|
-
reason: values.reason,
|
|
18018
|
-
description: values.description
|
|
18019
|
-
});
|
|
18020
|
-
handleCloseModal();
|
|
18021
|
-
},
|
|
18022
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
18023
|
-
/* @__PURE__ */ jsx(Select_default, { name: "reason", placeholder: "Reason", options: REPORT_REASONS }),
|
|
18024
|
-
/* @__PURE__ */ jsx(
|
|
18025
|
-
TextArea_default,
|
|
18026
|
-
{
|
|
18027
|
-
name: "description",
|
|
18028
|
-
rows: 4,
|
|
18029
|
-
placeholder: "Additional details"
|
|
18030
|
-
}
|
|
18031
|
-
),
|
|
18032
|
-
/* @__PURE__ */ jsx(Button_default, { type: "submit", variant: "danger", text: "Submit Report" })
|
|
18033
|
-
] })
|
|
18034
|
-
}
|
|
18035
|
-
) });
|
|
18036
|
-
}
|
|
18037
|
-
var ReportCommentModal_default = ReportCommentModal;
|
|
18038
|
-
function useCommentModals() {
|
|
18039
|
-
const [showEditModal, setShowEditModal] = useState(false);
|
|
18040
|
-
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
18041
|
-
const [showReportModal, setShowReportModal] = useState(false);
|
|
18042
|
-
return {
|
|
18043
|
-
showEditModal,
|
|
18044
|
-
openEditModal: () => setShowEditModal(true),
|
|
18045
|
-
closeEditModal: () => setShowEditModal(false),
|
|
18046
|
-
showDeleteModal,
|
|
18047
|
-
openDeleteModal: () => setShowDeleteModal(true),
|
|
18048
|
-
closeDeleteModal: () => setShowDeleteModal(false),
|
|
18049
|
-
showReportModal,
|
|
18050
|
-
openReportModal: () => setShowReportModal(true),
|
|
18051
|
-
closeReportModal: () => setShowReportModal(false)
|
|
18052
|
-
};
|
|
18053
|
-
}
|
|
18054
|
-
function useCommentSelection() {
|
|
18055
|
-
const [selectedComment, setSelectedComment] = useState(
|
|
18056
|
-
null
|
|
18057
|
-
);
|
|
18058
|
-
function selectComment(comment) {
|
|
18059
|
-
setSelectedComment(comment);
|
|
18060
|
-
}
|
|
18061
|
-
function clearSelection() {
|
|
18062
|
-
setSelectedComment(null);
|
|
18063
|
-
}
|
|
18064
|
-
return {
|
|
18065
|
-
selectedComment,
|
|
18066
|
-
selectComment,
|
|
18067
|
-
clearSelection
|
|
18068
|
-
};
|
|
18069
|
-
}
|
|
18070
17927
|
|
|
18071
17928
|
// src/compositions/comment-thread/utils/buildCommentTree.ts
|
|
18072
17929
|
function buildCommentTree(comments) {
|
|
@@ -18105,14 +17962,6 @@ function updateComment(comments, commentId, updater) {
|
|
|
18105
17962
|
});
|
|
18106
17963
|
}
|
|
18107
17964
|
|
|
18108
|
-
// src/compositions/comment-thread/utils/removeComment.ts
|
|
18109
|
-
function removeComment(comments, commentId) {
|
|
18110
|
-
return comments.filter((comment) => comment.id !== commentId).map((comment) => ({
|
|
18111
|
-
...comment,
|
|
18112
|
-
replies: comment.replies ? removeComment(comment.replies, commentId) : []
|
|
18113
|
-
}));
|
|
18114
|
-
}
|
|
18115
|
-
|
|
18116
17965
|
// src/compositions/comment-thread/utils/insertReply.ts
|
|
18117
17966
|
function insertReply(comments, parentId, reply) {
|
|
18118
17967
|
return comments.map((comment) => {
|
|
@@ -18129,7 +17978,6 @@ function insertReply(comments, parentId, reply) {
|
|
|
18129
17978
|
});
|
|
18130
17979
|
}
|
|
18131
17980
|
function CommentThread({
|
|
18132
|
-
postId,
|
|
18133
17981
|
currentUser,
|
|
18134
17982
|
dataSource,
|
|
18135
17983
|
loading = false,
|
|
@@ -18139,8 +17987,6 @@ function CommentThread({
|
|
|
18139
17987
|
}) {
|
|
18140
17988
|
const [comments, setComments] = useState([]);
|
|
18141
17989
|
const [isLoadingComments, setIsLoadingComments] = useState(true);
|
|
18142
|
-
const selection = useCommentSelection();
|
|
18143
|
-
const modals = useCommentModals();
|
|
18144
17990
|
useEffect(() => {
|
|
18145
17991
|
async function loadComments() {
|
|
18146
17992
|
try {
|
|
@@ -18190,87 +18036,27 @@ function CommentThread({
|
|
|
18190
18036
|
}))
|
|
18191
18037
|
);
|
|
18192
18038
|
}
|
|
18193
|
-
async function handleUpdateComment(comment, content) {
|
|
18194
|
-
const updated = await dataSource.updateComment({
|
|
18195
|
-
id: comment.id,
|
|
18196
|
-
content
|
|
18197
|
-
});
|
|
18198
|
-
setComments((prev) => updateComment(prev, comment.id, () => updated));
|
|
18199
|
-
}
|
|
18200
|
-
async function handleDeleteComment(comment) {
|
|
18201
|
-
await dataSource.deleteComment(comment.id);
|
|
18202
|
-
setComments((prev) => removeComment(prev, comment.id));
|
|
18203
|
-
onDelete?.(comment);
|
|
18204
|
-
}
|
|
18205
|
-
async function handleReportComment(comment, payload) {
|
|
18206
|
-
await dataSource.reportComment?.(
|
|
18207
|
-
comment.id,
|
|
18208
|
-
payload.reason,
|
|
18209
|
-
payload.description
|
|
18210
|
-
);
|
|
18211
|
-
onReport?.(comment);
|
|
18212
|
-
}
|
|
18213
18039
|
if (loading || isLoadingComments) {
|
|
18214
18040
|
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|
|
18215
18041
|
}
|
|
18216
|
-
return /* @__PURE__ */ jsxs(
|
|
18217
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
18218
|
-
/* @__PURE__ */ jsx(
|
|
18219
|
-
CommentComposer_default,
|
|
18220
|
-
{
|
|
18221
|
-
avatar: currentUser.avatar,
|
|
18222
|
-
onSubmit: handleCreateComment
|
|
18223
|
-
}
|
|
18224
|
-
),
|
|
18225
|
-
/* @__PURE__ */ jsx(
|
|
18226
|
-
CommentList_default,
|
|
18227
|
-
{
|
|
18228
|
-
comments,
|
|
18229
|
-
onLike: handleLike,
|
|
18230
|
-
onDislike: handleDislike,
|
|
18231
|
-
onReply: handleReply,
|
|
18232
|
-
onEdit: (comment) => {
|
|
18233
|
-
selection.selectComment(comment);
|
|
18234
|
-
onEdit?.(comment);
|
|
18235
|
-
modals.openEditModal();
|
|
18236
|
-
},
|
|
18237
|
-
onDelete: (comment) => {
|
|
18238
|
-
selection.selectComment(comment);
|
|
18239
|
-
modals.openDeleteModal();
|
|
18240
|
-
},
|
|
18241
|
-
onReport: (comment) => {
|
|
18242
|
-
selection.selectComment(comment);
|
|
18243
|
-
onReport?.(comment);
|
|
18244
|
-
modals.openReportModal();
|
|
18245
|
-
}
|
|
18246
|
-
}
|
|
18247
|
-
)
|
|
18248
|
-
] }),
|
|
18249
|
-
/* @__PURE__ */ jsx(
|
|
18250
|
-
EditCommentModal_default,
|
|
18251
|
-
{
|
|
18252
|
-
show: modals.showEditModal,
|
|
18253
|
-
comment: selection.selectedComment,
|
|
18254
|
-
handleCloseModal: modals.closeEditModal,
|
|
18255
|
-
onSubmit: handleUpdateComment
|
|
18256
|
-
}
|
|
18257
|
-
),
|
|
18042
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
18258
18043
|
/* @__PURE__ */ jsx(
|
|
18259
|
-
|
|
18044
|
+
CommentComposer_default,
|
|
18260
18045
|
{
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
handleCloseModal: modals.closeDeleteModal,
|
|
18264
|
-
onDelete: handleDeleteComment
|
|
18046
|
+
avatar: currentUser.avatar,
|
|
18047
|
+
onSubmit: handleCreateComment
|
|
18265
18048
|
}
|
|
18266
18049
|
),
|
|
18267
18050
|
/* @__PURE__ */ jsx(
|
|
18268
|
-
|
|
18051
|
+
CommentList_default,
|
|
18269
18052
|
{
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18053
|
+
comments,
|
|
18054
|
+
onLike: handleLike,
|
|
18055
|
+
onDislike: handleDislike,
|
|
18056
|
+
onReply: handleReply,
|
|
18057
|
+
onEdit,
|
|
18058
|
+
onDelete,
|
|
18059
|
+
onReport
|
|
18274
18060
|
}
|
|
18275
18061
|
)
|
|
18276
18062
|
] });
|