corpushub-design-system 0.1.0 → 0.1.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/common/AppDropzone/AppDropzoneBody.js +2 -1
- package/dist/common/AppDropzone/UploadedFile.d.ts +2 -0
- package/dist/common/AppDropzone/index.d.ts +2 -0
- package/dist/common/AppDropzone/index.js +1 -0
- package/dist/common/AppDropzone/toMediaDisplayUrl.d.ts +10 -0
- package/dist/common/AppDropzone/toMediaDisplayUrl.js +27 -0
- package/dist/common/AppPicture/AppPicture.js +1 -1
- package/dist/common/AppTable/styles.scss +6 -2
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -1
- package/dist/configs/Localization.js +4 -0
- package/dist/configs/api/applyAuthErrorHandling.js +5 -0
- package/dist/configs/api/index.js +2 -0
- package/dist/configs/auth/authApi.js +6 -0
- package/dist/configs/auth/installAuthRefreshInterceptor.js +5 -0
- package/dist/configs/auth/isPublicAuthRequest.d.ts +6 -0
- package/dist/configs/auth/isPublicAuthRequest.js +28 -0
- package/dist/configs/auth/session.js +8 -6
- package/dist/configs/brand.d.ts +6 -0
- package/dist/configs/brand.js +10 -3
- package/dist/configs/index.d.ts +3 -2
- package/dist/configs/index.js +2 -1
- package/dist/configs/localization/BackupTexts.d.ts +74 -0
- package/dist/configs/localization/BackupTexts.js +74 -0
- package/dist/configs/localization/CommentsTexts.d.ts +145 -145
- package/dist/configs/localization/CommentsTexts.js +145 -145
- package/dist/configs/localization/CommonTexts.d.ts +15 -0
- package/dist/configs/localization/CommonTexts.js +18 -3
- package/dist/configs/localization/HeaderTexts.js +3 -3
- package/dist/configs/localization/HelpTexts.d.ts +44 -2
- package/dist/configs/localization/HelpTexts.js +53 -11
- package/dist/configs/localization/HistoryTexts.d.ts +6 -0
- package/dist/configs/localization/HistoryTexts.js +6 -0
- package/dist/configs/localization/ParserRuleGroupsTexts.d.ts +53 -0
- package/dist/configs/localization/ParserRuleGroupsTexts.js +53 -0
- package/dist/configs/localization/SentenceTexts.js +33 -33
- package/dist/configs/services/ProfileService.js +3 -3
- package/dist/configs/tour/index.d.ts +1 -1
- package/dist/configs/types/CorpusImage.d.ts +3 -0
- package/dist/features/AccessControl/AccessControlService.d.ts +9 -0
- package/dist/features/AccessControl/AccessControlService.js +22 -8
- package/dist/features/AccessControl/AccessGrant/AccessGrant.js +3 -1
- package/dist/features/AccessControl/AccessUser/AccessData.d.ts +2 -2
- package/dist/features/AccessControl/AccessUser/AccessData.js +21 -21
- package/dist/features/AccessControl/AccessUser/AccessUser.js +20 -3
- package/dist/features/AccessControl/AccessUser/AccessUserGroups.d.ts +8 -0
- package/dist/features/AccessControl/AccessUser/AccessUserGroups.js +77 -0
- package/dist/features/AccessControl/AccessUser/style.scss +41 -3
- package/dist/features/AccessControl/AccessUsers/AccessUsers.js +44 -29
- package/dist/features/AccessControl/AccessUsers/styles.scss +5 -0
- package/dist/features/AccessControl/index.d.ts +1 -0
- package/dist/features/AccessControl/types/CorpusGroup.d.ts +10 -0
- package/dist/features/AccessControl/types/CorpusGroup.js +1 -0
- package/dist/features/AccessControl/types/UserAccessResponse.d.ts +4 -0
- package/dist/features/Backup/BackupCreate/BackupCreate.d.ts +11 -0
- package/dist/features/Backup/BackupCreate/BackupCreate.js +89 -0
- package/dist/features/Backup/BackupCreate/index.d.ts +2 -0
- package/dist/features/Backup/BackupCreate/index.js +2 -0
- package/dist/features/Backup/BackupCreate/style.scss +5 -0
- package/dist/features/Backup/BackupInfo/BackupInfo.d.ts +8 -0
- package/dist/features/Backup/BackupInfo/BackupInfo.js +36 -0
- package/dist/features/Backup/BackupInfo/index.d.ts +2 -0
- package/dist/features/Backup/BackupInfo/index.js +2 -0
- package/dist/features/Backup/BackupInfo/style.scss +23 -0
- package/dist/features/Backup/BackupRestore/BackupRestore.d.ts +7 -0
- package/dist/features/Backup/BackupRestore/BackupRestore.js +52 -0
- package/dist/features/Backup/BackupRestore/index.d.ts +3 -0
- package/dist/features/Backup/BackupRestore/index.js +2 -0
- package/dist/features/Backup/BackupRestore/style.scss +17 -0
- package/dist/features/Backup/BackupService.d.ts +20 -0
- package/dist/features/Backup/BackupService.js +43 -0
- package/dist/features/Backup/BackupTable/BackupSearchFilter.d.ts +5 -0
- package/dist/features/Backup/BackupTable/BackupSearchFilter.js +4 -0
- package/dist/features/Backup/BackupTable/BackupTable.d.ts +8 -0
- package/dist/features/Backup/BackupTable/BackupTable.js +121 -0
- package/dist/features/Backup/BackupTable/index.d.ts +4 -0
- package/dist/features/Backup/BackupTable/index.js +3 -0
- package/dist/features/Backup/BackupTable/style.scss +19 -0
- package/dist/features/Backup/index.d.ts +7 -0
- package/dist/features/Backup/index.js +4 -0
- package/dist/features/Backup/types/Backup.d.ts +14 -0
- package/dist/features/Backup/types/Backup.js +1 -0
- package/dist/features/Comments/CommentService.js +2 -1
- package/dist/features/PageRender/PageRenderView.d.ts +1 -1
- package/dist/features/PageRender/PageRenderView.js +67 -9
- package/dist/features/PageRender/style.scss +27 -5
- package/dist/features/PageRender/types.d.ts +5 -1
- package/dist/features/ParserRuleGroups/ParserRuleGroupItem.d.ts +9 -0
- package/dist/features/ParserRuleGroups/ParserRuleGroupItem.js +18 -0
- package/dist/features/ParserRuleGroups/ParserRuleGroupsEditor.d.ts +17 -0
- package/dist/features/ParserRuleGroups/ParserRuleGroupsEditor.js +129 -0
- package/dist/features/ParserRuleGroups/index.d.ts +2 -0
- package/dist/features/ParserRuleGroups/index.js +2 -0
- package/dist/features/ParserRuleGroups/style.scss +81 -0
- package/dist/features/ServerErrorReport/ServerErrorReport.js +9 -48
- package/dist/features/ServerErrorReport/ServerErrorReportForm.d.ts +22 -0
- package/dist/features/ServerErrorReport/ServerErrorReportForm.js +85 -0
- package/dist/features/ServerErrorReport/captureTabScreenshot.d.ts +1 -1
- package/dist/features/ServerErrorReport/captureTabScreenshot.js +5 -20
- package/dist/features/ServerErrorReport/index.d.ts +2 -0
- package/dist/features/ServerErrorReport/index.js +1 -0
- package/dist/features/ServerErrorReport/styles.scss +22 -9
- package/dist/features/index.d.ts +5 -1
- package/dist/features/index.js +2 -0
- package/dist/functions/EditionTierUtils.js +11 -5
- package/dist/primitives/AsyncSelectField/AsyncSelectField.js +2 -2
- package/dist/primitives/AsyncSelectField/styles.scss +31 -31
- package/dist/primitives/Button/Button.d.ts +5 -4
- package/dist/primitives/Button/Button.js +19 -19
- package/dist/primitives/DropdownButton/DropdownButton.d.ts +2 -1
- package/dist/primitives/DropdownButton/DropdownButton.js +2 -2
- package/dist/primitives/DropdownMenu/DropdownMenu.js +7 -1
- package/dist/primitives/Icon/Icon.d.ts +2 -1
- package/dist/primitives/Icon/Icon.js +2 -2
- package/dist/primitives/IconButton/IconButton.d.ts +2 -1
- package/dist/primitives/IconButton/IconButton.js +2 -2
- package/dist/primitives/Tag/Tag.d.ts +2 -1
- package/dist/primitives/Tag/Tag.js +3 -3
- package/dist/primitives/index.js +1 -1
- package/dist/shell/Header/HelpButton/HelpModal.js +3 -69
- package/dist/shell/Header/HelpButton/HelpModalMainColumn.d.ts +5 -0
- package/dist/shell/Header/HelpButton/HelpModalMainColumn.js +76 -0
- package/dist/shell/Header/HelpButton/HelpModalSideColumn.d.ts +7 -0
- package/dist/shell/Header/HelpButton/HelpModalSideColumn.js +18 -0
- package/dist/shell/Header/HelpButton/live-tour.png +0 -0
- package/dist/shell/Header/HelpButton/style.scss +330 -47
- package/dist/styles/base/_typographs.scss +376 -1
- package/dist/styles/main.scss +112 -1
- package/package.json +1 -1
- package/dist/primitives/styles/base/_typographs.scss +0 -376
- package/dist/primitives/styles/font-googleapis.scss +0 -222
- package/dist/primitives/styles/main.scss +0 -112
- /package/dist/{primitives/fonts → fonts}/material-symbols-outlined.woff2 +0 -0
- /package/dist/{primitives/fonts → fonts}/work-sans-latin-ext.woff2 +0 -0
- /package/dist/{primitives/fonts → fonts}/work-sans-latin.woff2 +0 -0
- /package/dist/{primitives/fonts → fonts}/work-sans-vietnamese.woff2 +0 -0
- /package/dist/{primitives/fonts.d.ts → fonts.d.ts} +0 -0
- /package/dist/{primitives/fonts.js → fonts.js} +0 -0
- /package/dist/{primitives/styles → styles}/base/_borders.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_colors.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_displays.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_margins.css +0 -0
- /package/dist/{primitives/styles → styles}/base/_spacing.scss +0 -0
- /package/dist/{primitives/styles → styles}/base/_tokens.scss +0 -0
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
.mark {
|
|
24
|
-
font-family:
|
|
24
|
+
font-family: 'Georgia', serif;
|
|
25
25
|
cursor: pointer;
|
|
26
26
|
@include body-xmedium-1;
|
|
27
27
|
display: inline-flex;
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
margin-bottom: var(--spacing-050);
|
|
31
31
|
width: auto;
|
|
32
32
|
background-color: var(--layer-semantic-info);
|
|
33
|
-
line-height: var(--spacing-300);
|
|
34
33
|
|
|
35
34
|
&.selected {
|
|
36
35
|
background-color: var(--layer-semantic-info);
|
|
@@ -39,13 +38,12 @@
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
.token {
|
|
42
|
-
font-family:
|
|
41
|
+
font-family: 'Georgia', serif;
|
|
43
42
|
cursor: pointer;
|
|
44
43
|
@include body-xmedium-1;
|
|
45
44
|
display: inline-flex;
|
|
46
45
|
align-items: center;
|
|
47
46
|
height: var(--spacing-300);
|
|
48
|
-
line-height: var(--spacing-300);
|
|
49
47
|
min-height: 0;
|
|
50
48
|
padding: 0 var(--spacing-050);
|
|
51
49
|
margin-bottom: var(--spacing-050);
|
|
@@ -63,7 +61,9 @@
|
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
&.edited {
|
|
66
|
-
border-bottom: 1px dashed var(--text-on-color-accent);
|
|
64
|
+
//border-bottom: 1px dashed var(--text-on-color-accent);
|
|
65
|
+
text-decoration: underline dashed var(--text-on-color-accent);
|
|
66
|
+
text-underline-offset: 4px;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
&.review {
|
|
@@ -106,4 +106,26 @@
|
|
|
106
106
|
cursor: pointer;
|
|
107
107
|
height: var(--spacing-300);
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
.section-anchor {
|
|
111
|
+
position: relative;
|
|
112
|
+
display: inline-flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.section {
|
|
117
|
+
position: absolute;
|
|
118
|
+
left: 0;
|
|
119
|
+
bottom: calc(100% - var(--spacing-050));
|
|
120
|
+
z-index: 1;
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
border-radius: var(--radius-100);
|
|
124
|
+
padding: 0 var(--spacing-050);
|
|
125
|
+
background-color: var(--layer-semantic-info);
|
|
126
|
+
border: 1px solid var(--semantic-info-70);
|
|
127
|
+
color: var(--text-primary);
|
|
128
|
+
line-height: 1.2;
|
|
129
|
+
@include helper-small-1;
|
|
130
|
+
}
|
|
109
131
|
}
|
|
@@ -57,7 +57,7 @@ export type PageRenderTokenContext = {
|
|
|
57
57
|
isSplit: boolean;
|
|
58
58
|
isMark: boolean;
|
|
59
59
|
isCollapsedJunction: boolean;
|
|
60
|
-
splitIdx: number;
|
|
60
|
+
splitIdx: number | undefined;
|
|
61
61
|
highlight: boolean;
|
|
62
62
|
selected: boolean;
|
|
63
63
|
};
|
|
@@ -68,6 +68,8 @@ export type PageRenderViewProps = {
|
|
|
68
68
|
document?: Document | null;
|
|
69
69
|
displayTags?: boolean;
|
|
70
70
|
showLineNumbers?: boolean;
|
|
71
|
+
/** When false, section/block labels are hidden. Defaults to true. */
|
|
72
|
+
showSectionLabels?: boolean;
|
|
71
73
|
highlightSentenceUid?: string;
|
|
72
74
|
activeTokenKey?: string;
|
|
73
75
|
selectedTokenKeys?: Set<string>;
|
|
@@ -78,6 +80,8 @@ export type PageRenderViewProps = {
|
|
|
78
80
|
isTokenEdited?: (token: Token) => boolean;
|
|
79
81
|
getParticipantName?: (code: string) => string;
|
|
80
82
|
getParticipantColor?: (code: string) => string | undefined;
|
|
83
|
+
/** Section/block label for a sentence uid; shown once before that sentence's first token. */
|
|
84
|
+
getSectionLabel?: (sentenceUid: string) => string | undefined;
|
|
81
85
|
onTokenClick?: (ref: TokenRef, splitIdx: number | undefined, source: TokenClickSource, modifiers: TokenClickModifiers) => void;
|
|
82
86
|
onTokenHover?: (sentenceUid: string | undefined) => void;
|
|
83
87
|
onParticipantHover?: (code: string | undefined) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ParserRuleGroupItem = {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
group?: string;
|
|
5
|
+
};
|
|
6
|
+
/** Build the persisted map (rule id → group name) from items that have a group. */
|
|
7
|
+
export declare function toParserRuleGroupsMap(items: ParserRuleGroupItem[]): Record<string, string>;
|
|
8
|
+
/** Apply a groups map onto items; missing keys clear the group. */
|
|
9
|
+
export declare function applyParserRuleGroupsMap(items: ParserRuleGroupItem[], groups: Record<string, string>): ParserRuleGroupItem[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Build the persisted map (rule id → group name) from items that have a group. */
|
|
2
|
+
export function toParserRuleGroupsMap(items) {
|
|
3
|
+
return items
|
|
4
|
+
.filter((item) => item.group)
|
|
5
|
+
.reduce((acc, item) => {
|
|
6
|
+
acc[item.id] = item.group || '';
|
|
7
|
+
return acc;
|
|
8
|
+
}, {});
|
|
9
|
+
}
|
|
10
|
+
/** Apply a groups map onto items; missing keys clear the group. */
|
|
11
|
+
export function applyParserRuleGroupsMap(items, groups) {
|
|
12
|
+
return items.map((item) => {
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(groups, item.id)) {
|
|
14
|
+
return { ...item, group: groups[item.id] };
|
|
15
|
+
}
|
|
16
|
+
return { ...item, group: undefined };
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DropdownMenuItem } from '../../primitives';
|
|
2
|
+
import { type ParserRuleGroupItem } from './ParserRuleGroupItem';
|
|
3
|
+
import './style.scss';
|
|
4
|
+
export type ParserRuleGroupsEditorProps = {
|
|
5
|
+
items: ParserRuleGroupItem[];
|
|
6
|
+
onChange: (items: ParserRuleGroupItem[]) => void;
|
|
7
|
+
/** Persist committed group changes (row save, delete, import). */
|
|
8
|
+
onSave: (items: ParserRuleGroupItem[]) => void;
|
|
9
|
+
title?: React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
exportFileName?: string;
|
|
12
|
+
/** Extra card menu actions (e.g. load defaults in revision). */
|
|
13
|
+
extraOptions?: DropdownMenuItem[];
|
|
14
|
+
/** When set (e.g. revision modal), adds a Close item to the card menu. */
|
|
15
|
+
onClose?: () => void;
|
|
16
|
+
};
|
|
17
|
+
export default function ParserRuleGroupsEditor({ items, onChange, onSave, title, className, exportFileName, extraOptions, onClose, }: ParserRuleGroupsEditorProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import { saveAs } from 'file-saver';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import AppCard from '../../common/AppCard/AppCard';
|
|
7
|
+
import AppDropzoneLocal from '../../common/AppDropzoneLocal';
|
|
8
|
+
import { Button, IconButton } from '../../primitives';
|
|
9
|
+
import { applyParserRuleGroupsMap, toParserRuleGroupsMap, } from './ParserRuleGroupItem';
|
|
10
|
+
import './style.scss';
|
|
11
|
+
const JSON_ACCEPT = {
|
|
12
|
+
'application/json': ['.json'],
|
|
13
|
+
'text/plain': ['.json'],
|
|
14
|
+
};
|
|
15
|
+
export default function ParserRuleGroupsEditor({ items, onChange, onSave, title, className, exportFileName = 'parser-rule-groups.json', extraOptions = [], onClose, }) {
|
|
16
|
+
const { t } = useTranslation('parser-rule-groups');
|
|
17
|
+
const [drafts, setDrafts] = useState({});
|
|
18
|
+
const [openImport, setOpenImport] = useState(false);
|
|
19
|
+
const isEditing = (line) => Object.prototype.hasOwnProperty.call(drafts, line.id);
|
|
20
|
+
const commit = (next) => {
|
|
21
|
+
onChange(next);
|
|
22
|
+
onSave(next);
|
|
23
|
+
};
|
|
24
|
+
const handleChange = (item, value) => {
|
|
25
|
+
const idx = items.findIndex((s) => s.id === item.id);
|
|
26
|
+
if (idx < 0)
|
|
27
|
+
return;
|
|
28
|
+
commit([
|
|
29
|
+
...items.slice(0, idx),
|
|
30
|
+
{ ...item, group: value || undefined },
|
|
31
|
+
...items.slice(idx + 1),
|
|
32
|
+
]);
|
|
33
|
+
};
|
|
34
|
+
const getDraft = (line) => drafts[line.id] !== undefined ? drafts[line.id] : line.group || '';
|
|
35
|
+
const startEdit = (line, initial) => {
|
|
36
|
+
setDrafts((prev) => ({ ...prev, [line.id]: initial }));
|
|
37
|
+
};
|
|
38
|
+
const clearDraft = (line) => {
|
|
39
|
+
setDrafts((prev) => {
|
|
40
|
+
const next = { ...prev };
|
|
41
|
+
delete next[line.id];
|
|
42
|
+
return next;
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const handleGroupSave = (line) => {
|
|
46
|
+
const value = getDraft(line).trim();
|
|
47
|
+
handleChange(line, value || undefined);
|
|
48
|
+
clearDraft(line);
|
|
49
|
+
};
|
|
50
|
+
const handleGroupCancel = (line) => {
|
|
51
|
+
clearDraft(line);
|
|
52
|
+
};
|
|
53
|
+
const handleAdd = (line) => {
|
|
54
|
+
startEdit(line, t('default.group.name'));
|
|
55
|
+
};
|
|
56
|
+
const handleEdit = (line) => {
|
|
57
|
+
startEdit(line, line.group || '');
|
|
58
|
+
};
|
|
59
|
+
const handleDelete = (line) => {
|
|
60
|
+
handleChange(line);
|
|
61
|
+
clearDraft(line);
|
|
62
|
+
};
|
|
63
|
+
const handleExport = () => {
|
|
64
|
+
const blob = new Blob([JSON.stringify(toParserRuleGroupsMap(items))], {
|
|
65
|
+
type: 'application/json;charset=utf-8',
|
|
66
|
+
});
|
|
67
|
+
saveAs(blob, exportFileName);
|
|
68
|
+
};
|
|
69
|
+
const handleImportSuccess = (files) => {
|
|
70
|
+
const content = files[0]?.content;
|
|
71
|
+
if (!content) {
|
|
72
|
+
setOpenImport(false);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
let groups;
|
|
76
|
+
try {
|
|
77
|
+
groups = JSON.parse(content);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
console.error('Failed to parse imported groups:', error);
|
|
81
|
+
setOpenImport(false);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
commit(applyParserRuleGroupsMap(items, groups));
|
|
85
|
+
setDrafts({});
|
|
86
|
+
setOpenImport(false);
|
|
87
|
+
};
|
|
88
|
+
const menuOptions = [
|
|
89
|
+
{
|
|
90
|
+
icon: 'upload',
|
|
91
|
+
label: t('menu.import'),
|
|
92
|
+
onClick: () => setOpenImport(true),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
icon: 'download',
|
|
96
|
+
label: t('menu.export'),
|
|
97
|
+
onClick: handleExport,
|
|
98
|
+
},
|
|
99
|
+
...extraOptions,
|
|
100
|
+
...(onClose
|
|
101
|
+
? [
|
|
102
|
+
{
|
|
103
|
+
icon: 'close',
|
|
104
|
+
label: t('menu.close'),
|
|
105
|
+
onClick: onClose,
|
|
106
|
+
},
|
|
107
|
+
]
|
|
108
|
+
: []),
|
|
109
|
+
];
|
|
110
|
+
const renderGroupCell = (line) => {
|
|
111
|
+
if (isEditing(line)) {
|
|
112
|
+
return (_jsxs("div", { className: "group-edit", children: [_jsx("input", { type: "text", className: "group-name-input", value: getDraft(line), onChange: (e) => setDrafts((prev) => ({ ...prev, [line.id]: e.target.value })), placeholder: t('placeholder.input'), "aria-label": t('placeholder.input'), autoFocus: true }), _jsx(Button, { text: t('button.save.row'), size: "x-small", onClick: () => handleGroupSave(line) })] }));
|
|
113
|
+
}
|
|
114
|
+
if (line.group) {
|
|
115
|
+
return _jsx("span", { className: "group-name", children: line.group });
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
};
|
|
119
|
+
const renderActions = (line) => {
|
|
120
|
+
if (isEditing(line)) {
|
|
121
|
+
return (_jsx(IconButton, { name: "close", size: "small", title: t('button.cancel.row'), onClick: () => handleGroupCancel(line) }));
|
|
122
|
+
}
|
|
123
|
+
if (line.group) {
|
|
124
|
+
return (_jsxs("div", { className: "group-actions", children: [_jsx(IconButton, { name: "edit", size: "small", title: t('button.edit.row'), onClick: () => handleEdit(line) }), _jsx(IconButton, { name: "delete", size: "small", color: "danger", title: t('button.delete.row'), onClick: () => handleDelete(line) })] }));
|
|
125
|
+
}
|
|
126
|
+
return (_jsx(IconButton, { name: "add", size: "small", title: t('button.add.row'), onClick: () => handleAdd(line) }));
|
|
127
|
+
};
|
|
128
|
+
return (_jsxs(_Fragment, { children: [_jsx(AppCard, { title: title ?? t('label.title'), className: cx('ds-parser-rule-groups', className), options: menuOptions, children: _jsxs("table", { className: "table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("td", { width: "55%", children: t('table.column.rule') }), _jsx("td", { width: "45%", children: t('table.column.group') }), _jsx("td", { children: "\u00A0" })] }) }), _jsx("tbody", { children: items.map((line) => (_jsxs("tr", { children: [_jsx("td", { children: line.label }), _jsx("td", { children: renderGroupCell(line) }), _jsx("td", { children: renderActions(line) })] }, line.id))) })] }) }), openImport && (_jsx(AppDropzoneLocal, { accept: JSON_ACCEPT, title: t('modal.import.title'), onClose: () => setOpenImport(false), onSuccess: handleImportSuccess }))] }));
|
|
129
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.ds-parser-rule-groups {
|
|
2
|
+
.ds-app-card-body,
|
|
3
|
+
.body {
|
|
4
|
+
overflow: auto;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.table {
|
|
8
|
+
width: 100%;
|
|
9
|
+
border-collapse: collapse;
|
|
10
|
+
|
|
11
|
+
> thead {
|
|
12
|
+
> tr {
|
|
13
|
+
> td {
|
|
14
|
+
border-bottom: 1px solid var(--border-accent-2);
|
|
15
|
+
padding: 8px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
> tbody {
|
|
21
|
+
> tr {
|
|
22
|
+
> td {
|
|
23
|
+
border-bottom: 1px solid var(--border-subtle-2);
|
|
24
|
+
padding: 8px;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.group-name {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
max-width: 100%;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
text-overflow: ellipsis;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.group-edit {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: var(--spacing-100);
|
|
42
|
+
min-width: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.group-actions {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: var(--spacing-50, 4px);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.group-name-input {
|
|
52
|
+
flex: 1;
|
|
53
|
+
min-width: 0;
|
|
54
|
+
max-width: 220px;
|
|
55
|
+
height: 32px;
|
|
56
|
+
padding: 0 12px;
|
|
57
|
+
border: 1px solid var(--border-accent-2, #eaeaeb);
|
|
58
|
+
border-radius: 4px;
|
|
59
|
+
background: var(--surface-primary, #fff);
|
|
60
|
+
color: var(--text-primary);
|
|
61
|
+
font: inherit;
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
line-height: 1.2;
|
|
64
|
+
outline: none;
|
|
65
|
+
transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
|
|
66
|
+
|
|
67
|
+
&::placeholder {
|
|
68
|
+
color: var(--text-placeholder);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:hover {
|
|
72
|
+
border-color: var(--border-accent-1, #c8c8cb);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&:focus {
|
|
76
|
+
border-color: var(--border-focus, var(--color-accent, #3d5a80));
|
|
77
|
+
box-shadow: 0 0 0 2px
|
|
78
|
+
color-mix(in srgb, var(--color-accent, #3d5a80) 25%, transparent);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,54 +1,15 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import
|
|
3
|
-
import { useState } from 'react';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
4
3
|
import { useTranslation } from 'react-i18next';
|
|
5
4
|
import AppModal from '../../common/AppModal/AppModal';
|
|
6
|
-
import
|
|
7
|
-
import ErrorReportService from '../../configs/services/ErrorReportService';
|
|
8
|
-
import { captureTabScreenshot } from './captureTabScreenshot';
|
|
9
|
-
import { getConsoleLogs } from './consoleCapture';
|
|
5
|
+
import ServerErrorReportForm from './ServerErrorReportForm';
|
|
10
6
|
import './styles.scss';
|
|
11
7
|
export default function ServerErrorReport({ errorContext, corpus, onClose, onSent, }) {
|
|
12
|
-
const { t
|
|
13
|
-
const
|
|
8
|
+
const { t } = useTranslation('common');
|
|
9
|
+
const formRef = useRef(null);
|
|
14
10
|
const [sending, setSending] = useState(false);
|
|
15
|
-
const [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
setSending(true);
|
|
22
|
-
setSendError(null);
|
|
23
|
-
try {
|
|
24
|
-
const screenshot = await captureTabScreenshot();
|
|
25
|
-
await ErrorReportService.send({
|
|
26
|
-
userMessage,
|
|
27
|
-
errorContext,
|
|
28
|
-
sendContext: {
|
|
29
|
-
locale: i18n.resolvedLanguage || i18n.language,
|
|
30
|
-
corpusUid: corpus?.uid,
|
|
31
|
-
corpusName: corpus?.name,
|
|
32
|
-
},
|
|
33
|
-
consoleLogs: getConsoleLogs(),
|
|
34
|
-
screenshot,
|
|
35
|
-
});
|
|
36
|
-
onSent();
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.error('Failed to send server error report:', axios.isAxiosError(error)
|
|
40
|
-
? {
|
|
41
|
-
message: error.message,
|
|
42
|
-
status: error.response?.status,
|
|
43
|
-
data: error.response?.data,
|
|
44
|
-
url: error.config?.url,
|
|
45
|
-
}
|
|
46
|
-
: error);
|
|
47
|
-
setSendError(t('server.error.report.send.failed'));
|
|
48
|
-
}
|
|
49
|
-
finally {
|
|
50
|
-
setSending(false);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: handleSend, disableConfirm: sending || !userMessage.trim(), confirmLabel: t('server.error.report.modal.send'), className: "server-error-report-modal", children: _jsxs("div", { className: "server-error-report-modal__body", children: [_jsx(AppTextArea, { value: userMessage, onChange: (e) => setUserMessage(e.target.value), placeholder: t('server.error.report.modal.placeholder'), rows: 6, disabled: sending, "aria-label": t('server.error.report.modal.placeholder') }), sendError && (_jsx("p", { className: "server-error-report-modal__error", role: "alert", children: sendError }))] }) }));
|
|
11
|
+
const [canSend, setCanSend] = useState(true);
|
|
12
|
+
return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: () => {
|
|
13
|
+
void formRef.current?.send();
|
|
14
|
+
}, disableConfirm: sending || !canSend, confirmLabel: t('server.error.report.modal.send'), className: "server-error-report-modal", children: _jsx(ServerErrorReportForm, { ref: formRef, errorContext: errorContext, corpus: corpus, intent: "error", onSent: onSent, onSendingChange: setSending, onCanSendChange: setCanSend }) }));
|
|
54
15
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServerErrorContext } from '../../common/AppToast/ToastMessage';
|
|
2
|
+
import type { Corpus } from '../../configs/types/Corpus';
|
|
3
|
+
import './styles.scss';
|
|
4
|
+
export type ServerErrorReportIntent = 'error' | 'feedback';
|
|
5
|
+
export type ServerErrorReportFormHandle = {
|
|
6
|
+
send: () => Promise<void>;
|
|
7
|
+
canSend: boolean;
|
|
8
|
+
sending: boolean;
|
|
9
|
+
};
|
|
10
|
+
type Props = {
|
|
11
|
+
errorContext?: ServerErrorContext;
|
|
12
|
+
corpus?: Corpus;
|
|
13
|
+
intent?: ServerErrorReportIntent;
|
|
14
|
+
/** When true, renders a Send button inside the form (Help Center embed). */
|
|
15
|
+
showSendButton?: boolean;
|
|
16
|
+
onSent: () => void;
|
|
17
|
+
onSendingChange?: (sending: boolean) => void;
|
|
18
|
+
onCanSendChange?: (canSend: boolean) => void;
|
|
19
|
+
className?: string;
|
|
20
|
+
};
|
|
21
|
+
declare const ServerErrorReportForm: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<ServerErrorReportFormHandle>>;
|
|
22
|
+
export default ServerErrorReportForm;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import AppTextArea from '../../common/AppTextArea/AppTextArea';
|
|
6
|
+
import ErrorReportService from '../../configs/services/ErrorReportService';
|
|
7
|
+
import { Button } from '../../primitives';
|
|
8
|
+
import { captureTabScreenshot } from './captureTabScreenshot';
|
|
9
|
+
import { getConsoleLogs } from './consoleCapture';
|
|
10
|
+
import './styles.scss';
|
|
11
|
+
const DEFAULT_USER_MESSAGE = 'No extra information given by the user';
|
|
12
|
+
const ServerErrorReportForm = forwardRef(function ServerErrorReportForm({ errorContext, corpus, intent = 'error', showSendButton = false, onSent, onSendingChange, onCanSendChange, className, }, ref) {
|
|
13
|
+
const { t, i18n } = useTranslation('common');
|
|
14
|
+
const [userMessage, setUserMessage] = useState('');
|
|
15
|
+
const [sending, setSending] = useState(false);
|
|
16
|
+
const [sendError, setSendError] = useState(null);
|
|
17
|
+
const canSend = !sending;
|
|
18
|
+
const placeholderKey = intent === 'feedback'
|
|
19
|
+
? 'server.error.report.feedback.placeholder'
|
|
20
|
+
: 'server.error.report.modal.placeholder';
|
|
21
|
+
const sendLabelKey = intent === 'feedback'
|
|
22
|
+
? 'server.error.report.feedback.send'
|
|
23
|
+
: 'server.error.report.modal.send';
|
|
24
|
+
const handleSend = async () => {
|
|
25
|
+
setSending(true);
|
|
26
|
+
onSendingChange?.(true);
|
|
27
|
+
setSendError(null);
|
|
28
|
+
try {
|
|
29
|
+
const screenshot = await captureTabScreenshot();
|
|
30
|
+
await ErrorReportService.send({
|
|
31
|
+
userMessage: userMessage.trim() || DEFAULT_USER_MESSAGE,
|
|
32
|
+
errorContext,
|
|
33
|
+
sendContext: {
|
|
34
|
+
locale: i18n.resolvedLanguage || i18n.language,
|
|
35
|
+
corpusUid: corpus?.uid,
|
|
36
|
+
corpusName: corpus?.name,
|
|
37
|
+
},
|
|
38
|
+
consoleLogs: getConsoleLogs(),
|
|
39
|
+
screenshot,
|
|
40
|
+
});
|
|
41
|
+
setUserMessage('');
|
|
42
|
+
onSent();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('Failed to send server error report:', axios.isAxiosError(error)
|
|
46
|
+
? {
|
|
47
|
+
message: error.message,
|
|
48
|
+
status: error.response?.status,
|
|
49
|
+
data: error.response?.data,
|
|
50
|
+
url: error.config?.url,
|
|
51
|
+
}
|
|
52
|
+
: error);
|
|
53
|
+
setSendError(t('server.error.report.send.failed'));
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
setSending(false);
|
|
57
|
+
onSendingChange?.(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
useImperativeHandle(ref, () => ({
|
|
61
|
+
send: handleSend,
|
|
62
|
+
canSend,
|
|
63
|
+
sending,
|
|
64
|
+
}),
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- handleSend closes over latest state
|
|
66
|
+
[canSend, sending, userMessage, errorContext, corpus, intent]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
onCanSendChange?.(canSend);
|
|
69
|
+
}, [canSend, onCanSendChange]);
|
|
70
|
+
const rootClass = [
|
|
71
|
+
'server-error-report-form',
|
|
72
|
+
intent === 'feedback' && 'server-error-report-form--feedback',
|
|
73
|
+
className,
|
|
74
|
+
]
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.join(' ');
|
|
77
|
+
return (_jsxs("div", { className: rootClass, children: [_jsx(AppTextArea, { value: userMessage, onChange: (e) => {
|
|
78
|
+
setUserMessage(e.target.value);
|
|
79
|
+
if (sendError)
|
|
80
|
+
setSendError(null);
|
|
81
|
+
}, placeholder: t(placeholderKey), rows: intent === 'feedback' ? 5 : 6, disabled: sending, "aria-label": t(placeholderKey) }), sendError && (_jsx("p", { className: "server-error-report-form__error", role: "alert", children: sendError })), showSendButton && (_jsx(Button, { text: t(sendLabelKey), size: "small", icon: "send", onClick: () => {
|
|
82
|
+
void handleSend();
|
|
83
|
+
}, disabled: !canSend }))] }));
|
|
84
|
+
});
|
|
85
|
+
export default ServerErrorReportForm;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Best-effort tab screenshot for error reports.
|
|
3
|
-
*
|
|
3
|
+
* Skips open MUI modals (incl. Help Center) and toasts so the page underneath is captured.
|
|
4
4
|
*/
|
|
5
5
|
export declare function captureTabScreenshot(): Promise<string | null>;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import html2canvas from 'html2canvas';
|
|
2
2
|
const MAX_WIDTH = 1600;
|
|
3
3
|
const JPEG_QUALITY = 0.85;
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const root = modal?.closest('.MuiModal-root') ||
|
|
8
|
-
modal;
|
|
9
|
-
if (root) {
|
|
10
|
-
hidden.push({ el: root, display: root.style.display });
|
|
11
|
-
root.style.display = 'none';
|
|
12
|
-
}
|
|
13
|
-
return hidden;
|
|
14
|
-
}
|
|
15
|
-
function restoreHidden(hidden) {
|
|
16
|
-
hidden.forEach(({ el, display }) => {
|
|
17
|
-
el.style.display = display;
|
|
18
|
-
});
|
|
4
|
+
function shouldIgnoreElement(el) {
|
|
5
|
+
return (el.classList.contains('MuiModal-root') ||
|
|
6
|
+
el.classList.contains('Toastify'));
|
|
19
7
|
}
|
|
20
8
|
function toJpegDataUrl(canvas) {
|
|
21
9
|
let out = canvas;
|
|
@@ -33,24 +21,21 @@ function toJpegDataUrl(canvas) {
|
|
|
33
21
|
}
|
|
34
22
|
/**
|
|
35
23
|
* Best-effort tab screenshot for error reports.
|
|
36
|
-
*
|
|
24
|
+
* Skips open MUI modals (incl. Help Center) and toasts so the page underneath is captured.
|
|
37
25
|
*/
|
|
38
26
|
export async function captureTabScreenshot() {
|
|
39
27
|
if (typeof document === 'undefined' || !document.body) {
|
|
40
28
|
return null;
|
|
41
29
|
}
|
|
42
|
-
const hidden = hideReportUi();
|
|
43
30
|
try {
|
|
44
31
|
const canvas = await html2canvas(document.body, {
|
|
45
32
|
logging: false,
|
|
46
33
|
useCORS: true,
|
|
34
|
+
ignoreElements: shouldIgnoreElement,
|
|
47
35
|
});
|
|
48
36
|
return toJpegDataUrl(canvas);
|
|
49
37
|
}
|
|
50
38
|
catch {
|
|
51
39
|
return null;
|
|
52
40
|
}
|
|
53
|
-
finally {
|
|
54
|
-
restoreHidden(hidden);
|
|
55
|
-
}
|
|
56
41
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
.server-error-report-modal {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
gap: var(--spacing-200);
|
|
2
|
+
.app-text-area {
|
|
3
|
+
min-height: 160px;
|
|
6
4
|
}
|
|
5
|
+
}
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
7
|
+
.server-error-report-form {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: var(--spacing-200);
|
|
13
11
|
|
|
14
12
|
.app-text-area {
|
|
15
13
|
min-height: 160px;
|
|
@@ -17,4 +15,19 @@
|
|
|
17
15
|
border-radius: var(--radius-100);
|
|
18
16
|
background-color: var(--background-default);
|
|
19
17
|
}
|
|
18
|
+
|
|
19
|
+
&--feedback .app-text-area {
|
|
20
|
+
min-height: 120px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__error {
|
|
24
|
+
margin: 0;
|
|
25
|
+
color: var(--text-danger);
|
|
26
|
+
@include body-small-1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
> .ds-button {
|
|
30
|
+
align-self: flex-start;
|
|
31
|
+
margin-top: var(--spacing-050);
|
|
32
|
+
}
|
|
20
33
|
}
|
package/dist/features/index.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ export { default as CommentComponent } from "./Comments";
|
|
|
2
2
|
export { default as HeaderNotifications } from "./Comments/HeaderNotifications";
|
|
3
3
|
export type { Comment, CommentRequest } from "./Comments/types/Comment";
|
|
4
4
|
export { default as CommentService } from "./Comments/CommentService";
|
|
5
|
+
export { BackupTable, BackupRestore, BackupService, EMPTY_BACKUP_SEARCH_FILTER, } from "./Backup";
|
|
6
|
+
export type { Backup, BackupStatus, BackupTableProps, BackupRestoreProps, BackupSearchFilter, } from "./Backup";
|
|
5
7
|
export { AccessUsers, AccessUser, AccessGrant, AccessControlService, EMPTY_ACCESS_SEARCH_FILTER, EMPTY_PORTAL, PortalRoleName, } from "./AccessControl";
|
|
6
|
-
export type { AccessUsersProps, AccessUsersFilter, AccessResponse, UserAccessRequest, UserAccessResponse, PortalInformation, PortalInformationRequest, PortalRole, } from "./AccessControl";
|
|
8
|
+
export type { AccessUsersProps, AccessUsersFilter, AccessResponse, UserAccessRequest, UserAccessResponse, CorpusGroup, CorpusGroupRole, CorpusGroupStatus, PortalInformation, PortalInformationRequest, PortalRole, } from "./AccessControl";
|
|
7
9
|
export { CorpusOwner } from "./CorpusOwner";
|
|
8
10
|
export type { CorpusOwnerProps, CorpusOwnerUser } from "./CorpusOwner";
|
|
11
|
+
export { ParserRuleGroupsEditor, applyParserRuleGroupsMap, toParserRuleGroupsMap, } from "./ParserRuleGroups";
|
|
12
|
+
export type { ParserRuleGroupsEditorProps, ParserRuleGroupItem, } from "./ParserRuleGroups";
|
|
9
13
|
export { default as SentenceView } from "./SentenceView";
|
|
10
14
|
export { default as TreeView } from "./TreeView";
|
|
11
15
|
export { default as ConlluGraphViewer } from "./ConlluGraphViewer";
|