elseware-ui 2.31.2 → 2.31.5
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 +42 -236
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -236
- 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 {
|
|
@@ -18167,110 +18013,70 @@ function CommentThread({
|
|
|
18167
18013
|
setComments((prev) => insertReply(prev, parentComment.id, reply));
|
|
18168
18014
|
}
|
|
18169
18015
|
async function handleLike(comment) {
|
|
18170
|
-
const
|
|
18016
|
+
const optimistic = {
|
|
18017
|
+
liked: !comment.liked,
|
|
18018
|
+
disliked: false,
|
|
18019
|
+
likes: comment.liked ? comment.likes - 1 : comment.likes + 1,
|
|
18020
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
18021
|
+
};
|
|
18171
18022
|
setComments(
|
|
18172
18023
|
(prev) => updateComment(prev, comment.id, (item) => ({
|
|
18173
18024
|
...item,
|
|
18174
|
-
likes:
|
|
18175
|
-
dislikes:
|
|
18176
|
-
liked:
|
|
18177
|
-
disliked:
|
|
18025
|
+
likes: optimistic.likes,
|
|
18026
|
+
dislikes: optimistic.dislikes,
|
|
18027
|
+
liked: optimistic.liked,
|
|
18028
|
+
disliked: optimistic.disliked
|
|
18178
18029
|
}))
|
|
18179
18030
|
);
|
|
18031
|
+
try {
|
|
18032
|
+
await dataSource.toggleLike(comment.id);
|
|
18033
|
+
} catch {
|
|
18034
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18035
|
+
}
|
|
18180
18036
|
}
|
|
18181
18037
|
async function handleDislike(comment) {
|
|
18182
|
-
const
|
|
18038
|
+
const optimistic = {
|
|
18039
|
+
liked: false,
|
|
18040
|
+
disliked: !comment.disliked,
|
|
18041
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
18042
|
+
dislikes: comment.disliked ? comment.dislikes - 1 : comment.dislikes + 1
|
|
18043
|
+
};
|
|
18183
18044
|
setComments(
|
|
18184
18045
|
(prev) => updateComment(prev, comment.id, (item) => ({
|
|
18185
18046
|
...item,
|
|
18186
|
-
likes:
|
|
18187
|
-
dislikes:
|
|
18188
|
-
liked:
|
|
18189
|
-
disliked:
|
|
18047
|
+
likes: optimistic.likes,
|
|
18048
|
+
dislikes: optimistic.dislikes,
|
|
18049
|
+
liked: optimistic.liked,
|
|
18050
|
+
disliked: optimistic.disliked
|
|
18190
18051
|
}))
|
|
18191
18052
|
);
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
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);
|
|
18053
|
+
try {
|
|
18054
|
+
await dataSource.toggleDislike(comment.id);
|
|
18055
|
+
} catch {
|
|
18056
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18057
|
+
}
|
|
18212
18058
|
}
|
|
18213
18059
|
if (loading || isLoadingComments) {
|
|
18214
18060
|
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|
|
18215
18061
|
}
|
|
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
|
-
),
|
|
18062
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
18258
18063
|
/* @__PURE__ */ jsx(
|
|
18259
|
-
|
|
18064
|
+
CommentComposer_default,
|
|
18260
18065
|
{
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
handleCloseModal: modals.closeDeleteModal,
|
|
18264
|
-
onDelete: handleDeleteComment
|
|
18066
|
+
avatar: currentUser.avatar,
|
|
18067
|
+
onSubmit: handleCreateComment
|
|
18265
18068
|
}
|
|
18266
18069
|
),
|
|
18267
18070
|
/* @__PURE__ */ jsx(
|
|
18268
|
-
|
|
18071
|
+
CommentList_default,
|
|
18269
18072
|
{
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18073
|
+
comments,
|
|
18074
|
+
onLike: handleLike,
|
|
18075
|
+
onDislike: handleDislike,
|
|
18076
|
+
onReply: handleReply,
|
|
18077
|
+
onEdit,
|
|
18078
|
+
onDelete,
|
|
18079
|
+
onReport
|
|
18274
18080
|
}
|
|
18275
18081
|
)
|
|
18276
18082
|
] });
|