@soul-refiner/design-system 0.2.38 → 0.2.40

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.
@@ -7,7 +7,7 @@ export interface CommentProps {
7
7
  onReact: (reaction: string) => void;
8
8
  onShowReplies?: () => void;
9
9
  reactions?: Record<string, number>;
10
- replies?: CommentProps[];
10
+ replies?: React.ReactElement[];
11
11
  userImageUri: string;
12
12
  userName: string;
13
13
  userReactions?: string[];
@@ -14,6 +14,7 @@ export const Comment = ({ content, createdDate, hasMoreReplies, onComment, onRea
14
14
  const [toggleShowCommentInput, setShowCommentInput] = React.useState(false);
15
15
  const [toggleShowReplies, setShowReplies] = React.useState(false);
16
16
  const [comment, setComment] = React.useState('');
17
+ const _replies = React.Children.toArray(replies);
17
18
  const handleCommentChange = (event) => {
18
19
  setComment(event.target.value);
19
20
  };
@@ -44,15 +45,20 @@ export const Comment = ({ content, createdDate, hasMoreReplies, onComment, onRea
44
45
  .map((reaction) => (React.createElement(Reaction, { key: id + reaction[0], "$align": "center", "$dir": "row", "$gap": 5, "$userSelected": userReactions?.includes(reaction[0]) },
45
46
  reaction[0],
46
47
  React.createElement(P, { "$bold": true, "$fontSize": 10, "$lineHeight": 14 }, reaction[1]))));
47
- const hasReplies = !!replies?.length && replies.length > 0;
48
+ const hasReplies = !!_replies?.length && _replies.length > 0;
48
49
  const replyElements = hasReplies &&
49
- replies.map((reply, index) => (React.createElement(ReplyWrapper, { "$isNotLastReply": index !== replies.length - 1, key: id + reply.createdDate.getTime().toString(36) },
50
- React.createElement(Comment, { ...reply }),
51
- React.createElement(ReplyIndicator, null))));
50
+ _replies.map((reply, index) => {
51
+ if (!React.isValidElement(reply))
52
+ return null;
53
+ const key = reply.props?.id;
54
+ return (React.createElement(ReplyWrapper, { "$isNotLastReply": index !== _replies.length - 1, key: key },
55
+ reply,
56
+ React.createElement(ReplyIndicator, null)));
57
+ });
52
58
  return (React.createElement(Wrapper, null,
53
59
  React.createElement(Avatar, { href: userProfileUri, image: userImageUri, size: 32 }),
54
60
  React.createElement(Box, { "$flex": 1, "$dir": "column" },
55
- React.createElement(ContentWrapper, { "$hasReplies": hasReplies },
61
+ React.createElement(ContentWrapper, { "$hasReplies": hasReplies || !!hasMoreReplies },
56
62
  React.createElement(CommentBox, null,
57
63
  React.createElement(P, { "$bold": true, "$color": "grey-2", "$fontSize": 14, "$lineHeight": 20 }, userName),
58
64
  React.createElement(P, { sx: "letter-spacing: -0.176px;" }, content)),
@@ -64,14 +70,15 @@ export const Comment = ({ content, createdDate, hasMoreReplies, onComment, onRea
64
70
  React.createElement(Box, { "$display": "flex", "$flow": "row wrap", "$gap": 6, sx: "max-width: calc(100% - 190px); margin-left: auto;" }, reactionElements),
65
71
  showPicker && (React.createElement(PickerWrapper, null,
66
72
  React.createElement(Picker, { data: emojis, onEmojiSelect: handleReaction, onClickOutside: handlePickerBlur, maxFrequentRows: 1, navPosition: "none", previewPosition: "none", perLine: 9, theme: "auto" }))))),
67
- hasMoreReplies && !toggleShowReplies && (React.createElement(RepliesWrapper, null,
68
- React.createElement(ReplyWrapper, { "$isNotLastReply": false },
69
- React.createElement(Button, { onClick: handleToggleReplies, size: "small", sx: "color: var(--color-grey-3);", type: "text" },
70
- "show ",
71
- replies && replies.length ? 'more' : '',
72
- " replies"),
73
- React.createElement(ReplyIndicator, null)))),
74
73
  hasReplies && toggleShowReplies && (React.createElement(RepliesWrapper, null, replyElements)),
74
+ hasMoreReplies ||
75
+ (!toggleShowReplies && hasReplies && (React.createElement(RepliesWrapper, null,
76
+ React.createElement(ReplyWrapper, { "$isNotLastReply": false },
77
+ React.createElement(Button, { onClick: handleToggleReplies, size: "small", sx: "color: var(--color-grey-3);", type: "text" },
78
+ "show ",
79
+ replies && replies.length ? 'more' : '',
80
+ " replies"),
81
+ React.createElement(ReplyIndicator, null))))),
75
82
  toggleShowCommentInput && (React.createElement(CommentWrapper, { onSubmit: handleCommentSubmit },
76
83
  React.createElement(TextInput, { bg: "var(--color-grey-10)", placeholder: "Write a reply", onChange: handleCommentChange, value: comment }))))));
77
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.38",
3
+ "version": "0.2.40",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {