tycho-components 0.0.18-SNAPSHOT-9 → 0.0.18-SNAPSHOT-10

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useContext, useState } from 'react';
2
+ import { useContext } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { Avatar, IconButton } from 'tycho-storybook';
5
5
  import CommonContext from '../configs/CommonContext';
@@ -9,7 +9,6 @@ import CommentService from './types/CommentService';
9
9
  export default function CommentInfo({ comment, onRemove, onUpdate, onEdit, onReply, }) {
10
10
  const { t } = useTranslation('comments');
11
11
  const { state } = useContext(CommonContext);
12
- const [comments, setComments] = useState();
13
12
  const handleMarkRead = () => {
14
13
  CommentService.markRead(comment.id).then((r) => {
15
14
  onUpdate(r.data);
@@ -11,6 +11,7 @@ import CommentAdd from './CommentAdd';
11
11
  import CommentInfo from './CommentInfo';
12
12
  import './style.scss';
13
13
  import CommentService from './types/CommentService';
14
+ import UsabilityUtils from '../functions/UsabilityUtils';
14
15
  export default function Comments({ uid, keywords, references, mode, onClose, onChange, }) {
15
16
  const { t } = useTranslation('comments');
16
17
  const { state } = useContext(CommonContext);
@@ -41,7 +42,7 @@ export default function Comments({ uid, keywords, references, mode, onClose, onC
41
42
  useEffect(() => {
42
43
  load();
43
44
  }, []);
44
- return (_jsx(Drawer, { anchor: "right", open: true, onClose: onClose, children: !comments ? (_jsx(AppLoading, {})) : (_jsxs("div", { className: "comments-container", children: [_jsxs("div", { className: "header", children: [_jsx(IconButton, { name: "close", size: "small", mode: "ghost", onClick: onClose }), _jsx("span", { className: "title", children: t('label.title.comments') }), _jsx("div", { className: "actions", children: hasEditAccess && (_jsx(Button, { text: t('button.add'), icon: "add", mode: "outlined", size: "small", className: "edit-button", onClick: () => {
45
+ return (_jsx(Drawer, { anchor: "right", open: true, onClose: onClose, children: !comments ? (_jsx(AppLoading, {})) : (_jsxs("div", { className: "comments-container", id: "comment-top", children: [_jsxs("div", { className: "header", children: [_jsx(IconButton, { name: "close", size: "small", mode: "ghost", onClick: onClose }), _jsx("span", { className: "title", children: t('label.title.comments') }), _jsx("div", { className: "actions", children: hasEditAccess && (_jsx(Button, { text: t('button.add'), icon: "add", mode: "outlined", size: "small", className: "edit-button", onClick: () => {
45
46
  setComment(undefined);
46
47
  setOpenAddComment(!openAddComment);
47
48
  } })) })] }), _jsxs("div", { className: "body", children: [openAddComment && (_jsx(CommentAdd, { uid: uid, mode: mode, users: users, references: references, keywords: keywords, comment: comment, reply: reply, onClose: () => {
@@ -65,9 +66,11 @@ export default function Comments({ uid, keywords, references, mode, onClose, onC
65
66
  }, onEdit: () => {
66
67
  setComment(el);
67
68
  setOpenAddComment(true);
69
+ UsabilityUtils.goToAnchor('comment-top');
68
70
  }, onReply: () => {
69
71
  setReply(el);
70
72
  setOpenAddComment(true);
73
+ UsabilityUtils.goToAnchor('comment-top');
71
74
  } })), hasReplies(el) && (_jsx("div", { className: "replies", children: getReplies(el).map((rel, idy) => (_jsx(CommentInfo, { comment: rel, onRemove: () => {
72
75
  const updated = comments?.filter((c) => c.id !== rel.id);
73
76
  setComments(updated);
@@ -2,7 +2,7 @@ declare const UsabilityUtils: {
2
2
  attachCloseToEscape: (handleClose: () => void) => () => void;
3
3
  executeOnEnter: (event: React.KeyboardEvent<HTMLDivElement>, fn: () => void) => void;
4
4
  isMobile: () => boolean;
5
- goToAnchor: (anchorId: string, e: any) => void;
5
+ goToAnchor: (anchorId: string, e?: any) => void;
6
6
  isDesktop: () => boolean;
7
7
  attachEnter: (event: React.KeyboardEvent<HTMLInputElement>, handleEnter: () => void) => void;
8
8
  };
@@ -8,7 +8,7 @@ const attachEnter = (event, handleEnter) => {
8
8
  }
9
9
  };
10
10
  const goToAnchor = (anchorId, e) => {
11
- e.preventDefault();
11
+ e && e.preventDefault();
12
12
  const anchorElement = document.getElementById(anchorId);
13
13
  if (anchorElement) {
14
14
  anchorElement.scrollIntoView({ behavior: 'smooth' });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.18-SNAPSHOT-9",
4
+ "version": "0.0.18-SNAPSHOT-10",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {