tycho-components 0.14.10 → 0.14.12
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/functions/ToolsUtils.d.ts +18 -4
- package/dist/functions/ToolsUtils.js +61 -48
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { Corpus } from
|
|
2
|
-
export type PlatformTools =
|
|
1
|
+
import { Corpus } from '../configs/types/Corpus';
|
|
2
|
+
export type PlatformTools = 'EDICTOR' | 'TRANSLATION' | 'DESIGN' | 'TRANSCRIBER' | 'SYNTREES';
|
|
3
|
+
export type OpenDocumentParams = {
|
|
4
|
+
page: string;
|
|
5
|
+
corpus: Corpus | undefined;
|
|
6
|
+
hasParameter: (corpus: Corpus, param: string) => boolean;
|
|
7
|
+
defaultTool?: PlatformTools;
|
|
8
|
+
ctxPath?: string;
|
|
9
|
+
};
|
|
10
|
+
export type RedirectPageParams = {
|
|
11
|
+
corpus: Corpus;
|
|
12
|
+
uid: string;
|
|
13
|
+
hasParameter: (corpus: Corpus, param: string) => boolean;
|
|
14
|
+
tool?: PlatformTools;
|
|
15
|
+
ctxPath?: string;
|
|
16
|
+
};
|
|
3
17
|
type EditionToolsMenu = {
|
|
4
18
|
parameter: string;
|
|
5
19
|
name: PlatformTools;
|
|
@@ -10,9 +24,9 @@ type EditionToolsMenu = {
|
|
|
10
24
|
};
|
|
11
25
|
export declare const EDITION_TOOLS: EditionToolsMenu[];
|
|
12
26
|
declare const ToolsUtils: {
|
|
13
|
-
redirectPage: (corpus
|
|
27
|
+
redirectPage: ({ corpus, uid, hasParameter, tool, ctxPath, }: RedirectPageParams) => void;
|
|
14
28
|
getIcon: (defaultTool?: PlatformTools) => string;
|
|
15
|
-
openDocument: (page
|
|
29
|
+
openDocument: ({ page, corpus, hasParameter, defaultTool, ctxPath, }: OpenDocumentParams) => void;
|
|
16
30
|
getTitle: (defaultTool?: PlatformTools) => string;
|
|
17
31
|
};
|
|
18
32
|
export default ToolsUtils;
|
|
@@ -1,80 +1,93 @@
|
|
|
1
1
|
export const EDITION_TOOLS = [
|
|
2
2
|
{
|
|
3
|
-
parameter:
|
|
4
|
-
name:
|
|
5
|
-
action:
|
|
6
|
-
title:
|
|
7
|
-
icon:
|
|
8
|
-
path:
|
|
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
9
|
},
|
|
10
10
|
{
|
|
11
|
-
parameter:
|
|
12
|
-
name:
|
|
13
|
-
action:
|
|
14
|
-
title:
|
|
15
|
-
icon:
|
|
16
|
-
path:
|
|
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
17
|
},
|
|
18
18
|
{
|
|
19
|
-
parameter:
|
|
20
|
-
name:
|
|
21
|
-
action:
|
|
22
|
-
title:
|
|
23
|
-
icon:
|
|
24
|
-
path:
|
|
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
25
|
},
|
|
26
26
|
{
|
|
27
|
-
parameter:
|
|
28
|
-
name:
|
|
29
|
-
action:
|
|
30
|
-
title:
|
|
31
|
-
icon:
|
|
32
|
-
path:
|
|
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
33
|
},
|
|
34
34
|
];
|
|
35
35
|
const getTitle = (defaultTool) => {
|
|
36
|
-
const tool = defaultTool ||
|
|
36
|
+
const tool = defaultTool || 'EDICTOR';
|
|
37
37
|
return EDITION_TOOLS.filter((t) => t.name === tool)[0].title;
|
|
38
38
|
};
|
|
39
39
|
const getIcon = (defaultTool) => {
|
|
40
|
-
const tool = defaultTool ||
|
|
40
|
+
const tool = defaultTool || 'EDICTOR';
|
|
41
41
|
return EDITION_TOOLS.filter((t) => t.name === tool)[0].icon;
|
|
42
42
|
};
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
45
|
-
return;
|
|
46
|
-
|
|
43
|
+
const withCtxPath = (absolutePath, ctxPath) => {
|
|
44
|
+
if (!ctxPath)
|
|
45
|
+
return absolutePath;
|
|
46
|
+
const base = ctxPath.endsWith('/') ? ctxPath.slice(0, -1) : ctxPath;
|
|
47
|
+
const path = absolutePath.startsWith('/') ? absolutePath : `/${absolutePath}`;
|
|
48
|
+
return `${base}${path}`;
|
|
47
49
|
};
|
|
48
|
-
const openTranslations = (uid) => {
|
|
49
|
-
window.open(`/translation/${uid}
|
|
50
|
+
const openTranslations = (uid, ctxPath) => {
|
|
51
|
+
window.open(withCtxPath(`/translation/${uid}`, ctxPath));
|
|
50
52
|
};
|
|
51
|
-
const openTranscriber = (uid) => {
|
|
52
|
-
window.open(`/transcriber/${uid}
|
|
53
|
+
const openTranscriber = (uid, ctxPath) => {
|
|
54
|
+
window.open(withCtxPath(`/transcriber/${uid}`, ctxPath));
|
|
53
55
|
};
|
|
54
|
-
const openEdictor = (uid) => {
|
|
55
|
-
window.open(`/editor/${uid}
|
|
56
|
+
const openEdictor = (uid, ctxPath) => {
|
|
57
|
+
window.open(withCtxPath(`/editor/${uid}`, ctxPath));
|
|
56
58
|
};
|
|
57
|
-
const openDesign = (uid) => {
|
|
58
|
-
window.open(`/editor/box/${uid}
|
|
59
|
+
const openDesign = (uid, ctxPath) => {
|
|
60
|
+
window.open(withCtxPath(`/editor/box/${uid}`, ctxPath));
|
|
59
61
|
};
|
|
60
|
-
const redirectPage = (corpus, tool,
|
|
62
|
+
const redirectPage = ({ corpus, uid, hasParameter, tool, ctxPath, }) => {
|
|
61
63
|
if (tool) {
|
|
62
|
-
window.open(`${EDITION_TOOLS.find((t) => t.name === tool)?.path}/${uid}
|
|
64
|
+
window.open(withCtxPath(`${EDITION_TOOLS.find((t) => t.name === tool)?.path}/${uid}`, ctxPath));
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
|
-
if (hasParameter(corpus,
|
|
66
|
-
openEdictor(uid);
|
|
67
|
+
if (hasParameter(corpus, 'useEdictor')) {
|
|
68
|
+
openEdictor(uid, ctxPath);
|
|
67
69
|
}
|
|
68
|
-
else if (hasParameter(corpus,
|
|
69
|
-
openTranslations(uid);
|
|
70
|
+
else if (hasParameter(corpus, 'useTranslations')) {
|
|
71
|
+
openTranslations(uid, ctxPath);
|
|
70
72
|
}
|
|
71
|
-
else if (hasParameter(corpus,
|
|
72
|
-
openDesign(uid);
|
|
73
|
+
else if (hasParameter(corpus, 'useDesigner')) {
|
|
74
|
+
openDesign(uid, ctxPath);
|
|
73
75
|
}
|
|
74
|
-
else if (hasParameter(corpus,
|
|
75
|
-
openTranscriber(uid);
|
|
76
|
+
else if (hasParameter(corpus, 'useTranscriber')) {
|
|
77
|
+
openTranscriber(uid, ctxPath);
|
|
76
78
|
}
|
|
77
79
|
};
|
|
80
|
+
const openDocument = ({ page, corpus, hasParameter, defaultTool, ctxPath, }) => {
|
|
81
|
+
if (!corpus)
|
|
82
|
+
return;
|
|
83
|
+
redirectPage({
|
|
84
|
+
corpus,
|
|
85
|
+
uid: page,
|
|
86
|
+
hasParameter,
|
|
87
|
+
tool: defaultTool,
|
|
88
|
+
ctxPath,
|
|
89
|
+
});
|
|
90
|
+
};
|
|
78
91
|
const ToolsUtils = {
|
|
79
92
|
redirectPage,
|
|
80
93
|
getIcon,
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export { default as SecurityUtils } from './functions/SecurityUtils';
|
|
|
67
67
|
export { default as SentenceUtils } from './functions/SentenceUtils';
|
|
68
68
|
export { default as UsabilityUtils } from './functions/UsabilityUtils';
|
|
69
69
|
export { default as ToolsUtils, EDITION_TOOLS, type PlatformTools, } from './functions/ToolsUtils';
|
|
70
|
+
export type { OpenDocumentParams, RedirectPageParams } from './functions/ToolsUtils';
|
|
70
71
|
export { default as Header } from './Header';
|
|
71
72
|
export { default as HeaderCorpus } from './Header/HeaderCorpora/HeaderCorpus';
|
|
72
73
|
export { default as HelpButton } from './Header/HelpButton';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.12",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@emotion/react": "^11.13.3",
|
|
41
41
|
"@emotion/styled": "^11.13.0",
|
|
42
|
-
"@hookform/resolvers": "^
|
|
42
|
+
"@hookform/resolvers": "^5.2.2",
|
|
43
43
|
"@mui/icons-material": "7.3.0",
|
|
44
44
|
"@mui/material": "7.3.0",
|
|
45
45
|
"i18next": "^23.3.0",
|