tycho-components 0.18.0 → 0.18.2
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/Header/HeaderApps/style.scss +4 -0
- package/dist/Header/HeaderButtons/HeaderButtons.js +2 -2
- package/dist/Header/HeaderButtons/styles.scss +11 -0
- package/dist/Header/HeaderUser/HeaderUser.js +2 -2
- package/dist/Header/HeaderUser/style.scss +6 -0
- package/dist/Header/styles.scss +1 -1
- package/dist/functions/ToolsUtils.d.ts +2 -1
- package/dist/functions/ToolsUtils.js +22 -14
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { IconButton } from 'tycho-storybook';
|
|
@@ -14,5 +14,5 @@ export default function HeaderButtons({ hideKeyboard, notifications, keyboardLay
|
|
|
14
14
|
const { getCorpus } = useCorpusUtils();
|
|
15
15
|
const { isLogged } = useLoggedUtils();
|
|
16
16
|
const [openKeyboard, setOpenKeyboard] = useState(false);
|
|
17
|
-
return (_jsxs(
|
|
17
|
+
return (_jsxs("div", { className: "header-buttons", children: [!hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard'), mode: mobile ? 'outlined' : 'filled' })), _jsx(HelpButton, { helpActions: helpActions, mobile: mobile }), notifications && isLogged() && (_jsx(HeaderNotifications, { uid: notifications.ref, mode: notifications.mode, mobile: mobile })), _jsx(LanguageSelector, { openToTop: mobile ? true : false, mobile: mobile }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: keyboardLayout || getCorpus().keyboardLayout || 'english' }))] }));
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { Button, Icon
|
|
4
|
+
import { Avatar, Button, Icon } from 'tycho-storybook';
|
|
5
5
|
import { useLoggedUtils } from '../../configs/useLoggedUtils';
|
|
6
6
|
import './style.scss';
|
|
7
7
|
export default function HeaderUser({ navigateLogout, navigateNotLogged, }) {
|
|
@@ -12,7 +12,7 @@ export default function HeaderUser({ navigateLogout, navigateNotLogged, }) {
|
|
|
12
12
|
setOpen(false);
|
|
13
13
|
window.open(import.meta.env.VITE_APP_RESERVED_URL, '_blank');
|
|
14
14
|
};
|
|
15
|
-
return (_jsxs("div", { className: "profile-container", children: [isLogged() ? (_jsx(
|
|
15
|
+
return (_jsxs("div", { className: "profile-container", children: [isLogged() ? (_jsx("div", { onClick: () => setOpen(!open), children: _jsx(Avatar, { size: "small", src: getLogged()?.picture, title: getLogged()?.name || getLogged()?.sub }) })) : (_jsx(Button, { text: t('button.sign.in'), size: "small", onClick: navigateNotLogged })), open && isLogged() && (_jsxs("div", { className: "ds-dropdown-list", children: [_jsx("div", { className: "ds-dropdown-itemlist", children: _jsx("span", { className: "label", children: `${t('profile.label.hello')} ${getLogged()?.name || getLogged()?.sub}` }) }), _jsxs("div", { className: "ds-dropdown-itemlist d-none", children: [_jsx(Icon, { name: "colors", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.theme') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", onClick: handleProfile, children: [_jsx(Icon, { name: "person", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.home') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", children: [_jsx(Icon, { name: "live_help", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.help') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", onClick: () => {
|
|
16
16
|
setOpen(false);
|
|
17
17
|
navigateLogout && navigateLogout();
|
|
18
18
|
}, children: [_jsx(Icon, { name: "logout", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.logout') })] })] }))] }));
|
package/dist/Header/styles.scss
CHANGED
|
@@ -13,6 +13,7 @@ export type RedirectPageParams = {
|
|
|
13
13
|
hasParameter: (corpus: Corpus, param: string) => boolean;
|
|
14
14
|
tool?: PlatformTools;
|
|
15
15
|
ctxPath?: string;
|
|
16
|
+
sameWindow?: boolean;
|
|
16
17
|
};
|
|
17
18
|
type EditionToolsMenu = {
|
|
18
19
|
parameter: string;
|
|
@@ -24,7 +25,7 @@ type EditionToolsMenu = {
|
|
|
24
25
|
};
|
|
25
26
|
export declare const EDITION_TOOLS: EditionToolsMenu[];
|
|
26
27
|
declare const ToolsUtils: {
|
|
27
|
-
redirectPage: ({ corpus, uid, hasParameter, tool, ctxPath, }: RedirectPageParams) => void;
|
|
28
|
+
redirectPage: ({ corpus, uid, hasParameter, tool, ctxPath, sameWindow, }: RedirectPageParams) => void;
|
|
28
29
|
getIcon: (defaultTool?: PlatformTools) => string;
|
|
29
30
|
openDocument: ({ page, corpus, hasParameter, defaultTool, ctxPath, }: OpenDocumentParams) => void;
|
|
30
31
|
getTitle: (defaultTool?: PlatformTools) => string;
|
|
@@ -47,34 +47,42 @@ const withCtxPath = (absolutePath, ctxPath) => {
|
|
|
47
47
|
const path = absolutePath.startsWith('/') ? absolutePath : `/${absolutePath}`;
|
|
48
48
|
return `${base}${path}`;
|
|
49
49
|
};
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const navigateTo = (path, ctxPath, sameWindow) => {
|
|
51
|
+
const targetPath = withCtxPath(path, ctxPath);
|
|
52
|
+
if (sameWindow) {
|
|
53
|
+
window.location.assign(targetPath);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
window.open(targetPath);
|
|
57
|
+
};
|
|
58
|
+
const openTranslations = (uid, ctxPath, sameWindow) => {
|
|
59
|
+
navigateTo(`/translation/${uid}`, ctxPath, sameWindow);
|
|
52
60
|
};
|
|
53
|
-
const openTranscriber = (uid, ctxPath) => {
|
|
54
|
-
|
|
61
|
+
const openTranscriber = (uid, ctxPath, sameWindow) => {
|
|
62
|
+
navigateTo(`/transcriber/${uid}`, ctxPath, sameWindow);
|
|
55
63
|
};
|
|
56
|
-
const openEdictor = (uid, ctxPath) => {
|
|
57
|
-
|
|
64
|
+
const openEdictor = (uid, ctxPath, sameWindow) => {
|
|
65
|
+
navigateTo(`/editor/${uid}`, ctxPath, sameWindow);
|
|
58
66
|
};
|
|
59
|
-
const openDesign = (uid, ctxPath) => {
|
|
60
|
-
|
|
67
|
+
const openDesign = (uid, ctxPath, sameWindow) => {
|
|
68
|
+
navigateTo(`/editor/box/${uid}`, ctxPath, sameWindow);
|
|
61
69
|
};
|
|
62
|
-
const redirectPage = ({ corpus, uid, hasParameter, tool, ctxPath, }) => {
|
|
70
|
+
const redirectPage = ({ corpus, uid, hasParameter, tool, ctxPath, sameWindow, }) => {
|
|
63
71
|
if (tool) {
|
|
64
|
-
|
|
72
|
+
navigateTo(`${EDITION_TOOLS.find((t) => t.name === tool)?.path}/${uid}`, ctxPath, sameWindow);
|
|
65
73
|
return;
|
|
66
74
|
}
|
|
67
75
|
if (hasParameter(corpus, 'useEdictor')) {
|
|
68
|
-
openEdictor(uid, ctxPath);
|
|
76
|
+
openEdictor(uid, ctxPath, sameWindow);
|
|
69
77
|
}
|
|
70
78
|
else if (hasParameter(corpus, 'useTranslations')) {
|
|
71
|
-
openTranslations(uid, ctxPath);
|
|
79
|
+
openTranslations(uid, ctxPath, sameWindow);
|
|
72
80
|
}
|
|
73
81
|
else if (hasParameter(corpus, 'useDesigner')) {
|
|
74
|
-
openDesign(uid, ctxPath);
|
|
82
|
+
openDesign(uid, ctxPath, sameWindow);
|
|
75
83
|
}
|
|
76
84
|
else if (hasParameter(corpus, 'useTranscriber')) {
|
|
77
|
-
openTranscriber(uid, ctxPath);
|
|
85
|
+
openTranscriber(uid, ctxPath, sameWindow);
|
|
78
86
|
}
|
|
79
87
|
};
|
|
80
88
|
const openDocument = ({ page, corpus, hasParameter, defaultTool, ctxPath, }) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-hook-form": "^7.45.2",
|
|
50
50
|
"react-i18next": "^13.0.2",
|
|
51
51
|
"react-router-dom": "^6.14.2",
|
|
52
|
-
"tycho-storybook": "0.6.
|
|
52
|
+
"tycho-storybook": "0.6.4",
|
|
53
53
|
"yup": "^1.2.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|