tycho-components 0.0.18-SNAPSHOT-9 → 0.0.18-SNAPSHOT-11

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);
@@ -11,6 +11,10 @@ type Props = {
11
11
  hideReplaceAll?: boolean;
12
12
  parser?: boolean;
13
13
  customHeader?: React.ReactNode;
14
+ notifications?: {
15
+ mode: 'corpus' | 'parser' | 'lexicon';
16
+ ref: string;
17
+ };
14
18
  };
15
- export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, customHeader, }: Props): import("react/jsx-runtime").JSX.Element;
19
+ export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, customHeader, notifications, }: Props): import("react/jsx-runtime").JSX.Element;
16
20
  export {};
@@ -11,8 +11,9 @@ import HeaderCorpora from './HeaderCorpora/HeaderCorpora';
11
11
  import HeaderReplaceAll from './HeaderReplaceAll';
12
12
  import HeaderUser from './HeaderUser';
13
13
  import './styles.scss';
14
+ import HeaderNotifications from '../Comments/HeaderNotifications';
14
15
  const linkTurorials = 'https://www.tycho.iel.unicamp.br/home/tutorials';
15
- export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, customHeader, }) {
16
+ export default function Header({ tool, navigateHome, navigateCorpora, navigateLogout, redirect, autoload, freeAccess, hideKeyboard, hideReplaceAll, customHeader, notifications, }) {
16
17
  const { t } = useTranslation('header');
17
18
  const { getCorpus, hasCorpus } = useCorpusUtils();
18
19
  const [openKeyboard, setOpenKeyboard] = useState(false);
@@ -22,5 +23,5 @@ export default function Header({ tool, navigateHome, navigateCorpora, navigateLo
22
23
  const homeTextsClass = cx('texts', {
23
24
  pointer: navigateHome !== undefined,
24
25
  });
25
- return (_jsxs("div", { className: "ds-header", children: [_jsx(HeaderApps, { freeAccess: freeAccess }), _jsxs("div", { className: homeTextsClass, onClick: () => navigateHome && navigateHome(), children: [_jsx("span", { className: "title", children: t('label.platform') }), _jsx("span", { className: "subtitle", children: tool })] }), customHeader, !customHeader && (_jsx(HeaderCorpora, { redirect: redirect, autoload: autoload, freeAccess: freeAccess, navigateCorpora: navigateCorpora })), _jsxs("div", { className: profileClass, children: [!hideReplaceAll && _jsx(HeaderReplaceAll, {}), !hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard') })), _jsx(IconButton, { name: "live_help", size: "medium", title: t('tooltip.tutorials'), onClick: () => window.open(linkTurorials, '_blank') }), _jsx(LanguageSelector, {}), !freeAccess && _jsx(HeaderUser, { navigateLogout: navigateLogout })] }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: getCorpus().keyboardLayout || 'english' }))] }));
26
+ return (_jsxs("div", { className: "ds-header", children: [_jsx(HeaderApps, { freeAccess: freeAccess }), _jsxs("div", { className: homeTextsClass, onClick: () => navigateHome && navigateHome(), children: [_jsx("span", { className: "title", children: t('label.platform') }), _jsx("span", { className: "subtitle", children: tool })] }), customHeader, !customHeader && (_jsx(HeaderCorpora, { redirect: redirect, autoload: autoload, freeAccess: freeAccess, navigateCorpora: navigateCorpora })), _jsxs("div", { className: profileClass, children: [!hideReplaceAll && _jsx(HeaderReplaceAll, {}), !hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard') })), _jsx(IconButton, { name: "live_help", size: "medium", title: t('tooltip.tutorials'), onClick: () => window.open(linkTurorials, '_blank') }), notifications && (_jsx(HeaderNotifications, { uid: notifications.ref, mode: notifications.mode })), _jsx(LanguageSelector, {}), !freeAccess && _jsx(HeaderUser, { navigateLogout: navigateLogout })] }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: getCorpus().keyboardLayout || 'english' }))] }));
26
27
  }
@@ -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-11",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {