tycho-components 0.13.3 → 0.14.1
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/Header.d.ts +2 -1
- package/dist/Header/Header.js +3 -3
- package/dist/Header/HeaderCorpora/HeaderCorpora.d.ts +2 -1
- package/dist/Header/HeaderCorpora/HeaderCorpora.js +4 -3
- package/dist/functions/ToolsUtils.d.ts +18 -0
- package/dist/functions/ToolsUtils.js +84 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/Header/Header.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ type Props = {
|
|
|
18
18
|
navigateLogout?: () => void;
|
|
19
19
|
navigateNotLogged?: () => void;
|
|
20
20
|
helpActions?: HelpAction[];
|
|
21
|
+
useOpenCorpora?: boolean;
|
|
21
22
|
};
|
|
22
|
-
export default function Header({ tool, redirect, autoload, hideKeyboard, hideReplaceAll, customHeader, notifications, keyboardLayout, navigateHome, navigateCorpora, navigateLogout, navigateNotLogged, helpActions, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default function Header({ tool, redirect, autoload, hideKeyboard, hideReplaceAll, customHeader, notifications, keyboardLayout, navigateHome, navigateCorpora, navigateLogout, navigateNotLogged, helpActions, useOpenCorpora, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
export {};
|
package/dist/Header/Header.js
CHANGED
|
@@ -16,13 +16,13 @@ import HelpButton from './HelpButton';
|
|
|
16
16
|
import './styles.scss';
|
|
17
17
|
export default function Header({ tool, redirect, autoload, hideKeyboard, hideReplaceAll, customHeader, notifications, keyboardLayout, navigateHome, navigateCorpora, navigateLogout, navigateNotLogged = () => {
|
|
18
18
|
location.href = '/auth';
|
|
19
|
-
}, helpActions, }) {
|
|
19
|
+
}, helpActions, useOpenCorpora = true, }) {
|
|
20
20
|
const { t } = useTranslation('header');
|
|
21
|
-
const { getCorpus
|
|
21
|
+
const { getCorpus } = useCorpusUtils();
|
|
22
22
|
const { isLogged } = useLoggedUtils();
|
|
23
23
|
const [openKeyboard, setOpenKeyboard] = useState(false);
|
|
24
24
|
const homeTextsClass = cx('app-title', {
|
|
25
25
|
pointer: navigateHome !== undefined,
|
|
26
26
|
});
|
|
27
|
-
return (_jsxs("div", { className: "ds-header", children: [_jsxs("div", { className: "header-left", children: [_jsx(HeaderApps, {}), _jsxs("div", { className: homeTextsClass, onClick: () => navigateHome && navigateHome(), children: [_jsx("span", { className: "title", children: t('label.platform') }), _jsx("span", { className: "subtitle", children: tool })] })] }), _jsx("div", { className: "header-center", children: customHeader ? (customHeader) : (_jsx(HeaderCorpora, { redirect: redirect, autoload: autoload, navigateCorpora: navigateCorpora })) }), _jsxs("div", { className: "header-right", children: [!hideReplaceAll && _jsx(HeaderReplaceAll, {}), !hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard') })), _jsx(HelpButton, { helpActions: helpActions }), notifications && isLogged() && (_jsx(HeaderNotifications, { uid: notifications.ref, mode: notifications.mode })), _jsx(LanguageSelector, {}), _jsx(HeaderUser, { navigateLogout: navigateLogout, navigateNotLogged: navigateNotLogged })] }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: keyboardLayout || getCorpus().keyboardLayout || 'english' }))] }));
|
|
27
|
+
return (_jsxs("div", { className: "ds-header", children: [_jsxs("div", { className: "header-left", children: [_jsx(HeaderApps, {}), _jsxs("div", { className: homeTextsClass, onClick: () => navigateHome && navigateHome(), children: [_jsx("span", { className: "title", children: t('label.platform') }), _jsx("span", { className: "subtitle", children: tool })] })] }), _jsx("div", { className: "header-center", children: customHeader ? (customHeader) : (_jsx(HeaderCorpora, { redirect: redirect, autoload: autoload, navigateCorpora: navigateCorpora, useOpenCorpora: useOpenCorpora })) }), _jsxs("div", { className: "header-right", children: [!hideReplaceAll && _jsx(HeaderReplaceAll, {}), !hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard') })), _jsx(HelpButton, { helpActions: helpActions }), notifications && isLogged() && (_jsx(HeaderNotifications, { uid: notifications.ref, mode: notifications.mode })), _jsx(LanguageSelector, {}), _jsx(HeaderUser, { navigateLogout: navigateLogout, navigateNotLogged: navigateNotLogged })] }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: keyboardLayout || getCorpus().keyboardLayout || 'english' }))] }));
|
|
28
28
|
}
|
|
@@ -3,6 +3,7 @@ type Props = {
|
|
|
3
3
|
navigateCorpora?: (uid: string) => void;
|
|
4
4
|
autoload?: boolean;
|
|
5
5
|
redirect?: string;
|
|
6
|
+
useOpenCorpora: boolean;
|
|
6
7
|
};
|
|
7
|
-
export default function HeaderCorpora({ navigateCorpora, redirect, autoload, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default function HeaderCorpora({ navigateCorpora, redirect, autoload, useOpenCorpora, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -9,7 +9,7 @@ import { useLoggedUtils } from '../../configs/useLoggedUtils';
|
|
|
9
9
|
import CorpusService from '../types/CorpusService';
|
|
10
10
|
import HeaderCorpus from './HeaderCorpus';
|
|
11
11
|
import './style.scss';
|
|
12
|
-
export default function HeaderCorpora({ navigateCorpora, redirect, autoload, }) {
|
|
12
|
+
export default function HeaderCorpora({ navigateCorpora, redirect, autoload, useOpenCorpora, }) {
|
|
13
13
|
const { t } = useTranslation('header');
|
|
14
14
|
const { setCorpus, getCorpus, hasCorpus } = useCorpusUtils();
|
|
15
15
|
const { isLogged } = useLoggedUtils();
|
|
@@ -58,8 +58,9 @@ export default function HeaderCorpora({ navigateCorpora, redirect, autoload, })
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
const handleCorpusClick = () => {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
const shouldNavigate = !useOpenCorpora && isLogged() && hasCorpus();
|
|
62
|
+
if (shouldNavigate) {
|
|
63
|
+
navigateCorpora?.(getCorpus().uid);
|
|
63
64
|
}
|
|
64
65
|
else {
|
|
65
66
|
setOpenCorpora(true);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Corpus } from "../configs/types/Corpus";
|
|
2
|
+
export type PlatformTools = "EDICTOR" | "TRANSLATION" | "DESIGN" | "TRANSCRIBER" | "SYNTREES";
|
|
3
|
+
type EditionToolsMenu = {
|
|
4
|
+
parameter: string;
|
|
5
|
+
name: PlatformTools;
|
|
6
|
+
action: string;
|
|
7
|
+
title: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const EDITION_TOOLS: EditionToolsMenu[];
|
|
12
|
+
declare const ToolsUtils: {
|
|
13
|
+
redirectPage: (corpus: Corpus, tool: PlatformTools | undefined, uid: string, hasParameter: (corpus: Corpus, param: string) => boolean) => void;
|
|
14
|
+
getIcon: (defaultTool?: PlatformTools) => string;
|
|
15
|
+
openDocument: (page: string, corpus: Corpus | undefined, hasParameter: (corpus: Corpus, param: string) => boolean, defaultTool?: PlatformTools) => void;
|
|
16
|
+
getTitle: (defaultTool?: PlatformTools) => string;
|
|
17
|
+
};
|
|
18
|
+
export default ToolsUtils;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const EDITION_TOOLS = [
|
|
2
|
+
{
|
|
3
|
+
parameter: "useEdictor",
|
|
4
|
+
name: "EDICTOR",
|
|
5
|
+
action: "actions:actions.label.edictor",
|
|
6
|
+
title: "actions:actions.name.edictor",
|
|
7
|
+
icon: "edit_square",
|
|
8
|
+
path: "/editor",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
parameter: "useTranslations",
|
|
12
|
+
name: "TRANSLATION",
|
|
13
|
+
action: "actions:actions.label.translations",
|
|
14
|
+
title: "actions:actions.name.translations",
|
|
15
|
+
icon: "language_japanese_kana",
|
|
16
|
+
path: "/translation",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
parameter: "useDesigner",
|
|
20
|
+
name: "DESIGN",
|
|
21
|
+
action: "actions:actions.label.design",
|
|
22
|
+
title: "actions:actions.name.design",
|
|
23
|
+
icon: "design_services",
|
|
24
|
+
path: "/editor/box",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
parameter: "useTranscriber",
|
|
28
|
+
name: "TRANSCRIBER",
|
|
29
|
+
action: "actions:actions.label.transcriber",
|
|
30
|
+
title: "actions:actions.name.transcriber",
|
|
31
|
+
icon: "music_cast",
|
|
32
|
+
path: "/transcriber",
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
const getTitle = (defaultTool) => {
|
|
36
|
+
const tool = defaultTool || "EDICTOR";
|
|
37
|
+
return EDITION_TOOLS.filter((t) => t.name === tool)[0].title;
|
|
38
|
+
};
|
|
39
|
+
const getIcon = (defaultTool) => {
|
|
40
|
+
const tool = defaultTool || "EDICTOR";
|
|
41
|
+
return EDITION_TOOLS.filter((t) => t.name === tool)[0].icon;
|
|
42
|
+
};
|
|
43
|
+
const openDocument = (page, corpus, hasParameter, defaultTool) => {
|
|
44
|
+
if (!corpus)
|
|
45
|
+
return;
|
|
46
|
+
redirectPage(corpus, defaultTool, page, hasParameter);
|
|
47
|
+
};
|
|
48
|
+
const openTranslations = (uid) => {
|
|
49
|
+
window.open(`/translation/${uid}`);
|
|
50
|
+
};
|
|
51
|
+
const openTranscriber = (uid) => {
|
|
52
|
+
window.open(`/transcriber/${uid}`);
|
|
53
|
+
};
|
|
54
|
+
const openEdictor = (uid) => {
|
|
55
|
+
window.open(`/editor/${uid}`);
|
|
56
|
+
};
|
|
57
|
+
const openDesign = (uid) => {
|
|
58
|
+
window.open(`/editor/box/${uid}`);
|
|
59
|
+
};
|
|
60
|
+
const redirectPage = (corpus, tool, uid, hasParameter) => {
|
|
61
|
+
if (tool) {
|
|
62
|
+
window.open(`${EDITION_TOOLS.find((t) => t.name === tool)?.path}/${uid}`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (hasParameter(corpus, "useEdictor")) {
|
|
66
|
+
openEdictor(uid);
|
|
67
|
+
}
|
|
68
|
+
else if (hasParameter(corpus, "useTranslations")) {
|
|
69
|
+
openTranslations(uid);
|
|
70
|
+
}
|
|
71
|
+
else if (hasParameter(corpus, "useDesigner")) {
|
|
72
|
+
openDesign(uid);
|
|
73
|
+
}
|
|
74
|
+
else if (hasParameter(corpus, "useTranscriber")) {
|
|
75
|
+
openTranscriber(uid);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const ToolsUtils = {
|
|
79
|
+
redirectPage,
|
|
80
|
+
getIcon,
|
|
81
|
+
openDocument,
|
|
82
|
+
getTitle,
|
|
83
|
+
};
|
|
84
|
+
export default ToolsUtils;
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export { default as ImageUtils } from './functions/ImageUtils';
|
|
|
65
65
|
export { default as SecurityUtils } from './functions/SecurityUtils';
|
|
66
66
|
export { default as SentenceUtils } from './functions/SentenceUtils';
|
|
67
67
|
export { default as UsabilityUtils } from './functions/UsabilityUtils';
|
|
68
|
+
export { default as ToolsUtils, EDITION_TOOLS, type PlatformTools, } from './functions/ToolsUtils';
|
|
68
69
|
export { default as Header } from './Header';
|
|
69
70
|
export { default as HeaderCorpus } from './Header/HeaderCorpora/HeaderCorpus';
|
|
70
71
|
export { default as HelpButton } from './Header/HelpButton';
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ export { default as ImageUtils } from './functions/ImageUtils';
|
|
|
49
49
|
export { default as SecurityUtils } from './functions/SecurityUtils';
|
|
50
50
|
export { default as SentenceUtils } from './functions/SentenceUtils';
|
|
51
51
|
export { default as UsabilityUtils } from './functions/UsabilityUtils';
|
|
52
|
+
export { default as ToolsUtils, EDITION_TOOLS, } from './functions/ToolsUtils';
|
|
52
53
|
export { default as Header } from './Header';
|
|
53
54
|
export { default as HeaderCorpus } from './Header/HeaderCorpora/HeaderCorpus';
|
|
54
55
|
export { default as HelpButton } from './Header/HelpButton';
|