corpushub-design-system 0.1.1 → 0.1.3
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.
|
@@ -5,17 +5,17 @@ export const SentenceTexts = {
|
|
|
5
5
|
"label.tag": "Tag",
|
|
6
6
|
"label.morphemes": "Morphemes",
|
|
7
7
|
"label.empty": "-",
|
|
8
|
-
"label.tier.original": "
|
|
9
|
-
"label.tier.junction": "
|
|
10
|
-
"label.tier.segmentation": "
|
|
11
|
-
"label.tier.spelling": "
|
|
12
|
-
"label.tier.expansion": "
|
|
13
|
-
"label.tier.correction": "
|
|
14
|
-
"label.tier.punctuation": "
|
|
15
|
-
"label.tier.illegible": "
|
|
16
|
-
"label.tier.modernization": "
|
|
17
|
-
"label.tier.padronization": "
|
|
18
|
-
"label.tier.inflection": "
|
|
8
|
+
"label.tier.original": "Original",
|
|
9
|
+
"label.tier.junction": "Junction",
|
|
10
|
+
"label.tier.segmentation": "Segmentation",
|
|
11
|
+
"label.tier.spelling": "Spelling",
|
|
12
|
+
"label.tier.expansion": "Expansion",
|
|
13
|
+
"label.tier.correction": "Correction",
|
|
14
|
+
"label.tier.punctuation": "Punctuation",
|
|
15
|
+
"label.tier.illegible": "Illegible",
|
|
16
|
+
"label.tier.modernization": "Modernization",
|
|
17
|
+
"label.tier.padronization": "Standardization",
|
|
18
|
+
"label.tier.inflection": "Inflection",
|
|
19
19
|
},
|
|
20
20
|
"pt-BR": {
|
|
21
21
|
"label.word": "Palavra",
|
|
@@ -23,17 +23,17 @@ export const SentenceTexts = {
|
|
|
23
23
|
"label.tag": "Etiqueta",
|
|
24
24
|
"label.morphemes": "Morfemas",
|
|
25
25
|
"label.empty": "-",
|
|
26
|
-
"label.tier.original": "
|
|
27
|
-
"label.tier.junction": "
|
|
28
|
-
"label.tier.segmentation": "
|
|
29
|
-
"label.tier.spelling": "
|
|
30
|
-
"label.tier.expansion": "
|
|
31
|
-
"label.tier.correction": "
|
|
32
|
-
"label.tier.punctuation": "
|
|
33
|
-
"label.tier.illegible": "
|
|
34
|
-
"label.tier.modernization": "
|
|
35
|
-
"label.tier.padronization": "
|
|
36
|
-
"label.tier.inflection": "
|
|
26
|
+
"label.tier.original": "Original",
|
|
27
|
+
"label.tier.junction": "Junção",
|
|
28
|
+
"label.tier.segmentation": "Segmentação",
|
|
29
|
+
"label.tier.spelling": "Grafia",
|
|
30
|
+
"label.tier.expansion": "Expansão",
|
|
31
|
+
"label.tier.correction": "Correção",
|
|
32
|
+
"label.tier.punctuation": "Pontuação",
|
|
33
|
+
"label.tier.illegible": "Ilegível",
|
|
34
|
+
"label.tier.modernization": "Modernização",
|
|
35
|
+
"label.tier.padronization": "Padronização",
|
|
36
|
+
"label.tier.inflection": "Flexão",
|
|
37
37
|
},
|
|
38
38
|
it: {
|
|
39
39
|
"label.word": "Parola",
|
|
@@ -41,16 +41,16 @@ export const SentenceTexts = {
|
|
|
41
41
|
"label.tag": "Etichetta",
|
|
42
42
|
"label.morphemes": "Morfemi",
|
|
43
43
|
"label.empty": "-",
|
|
44
|
-
"label.tier.original": "
|
|
45
|
-
"label.tier.junction": "
|
|
46
|
-
"label.tier.segmentation": "
|
|
47
|
-
"label.tier.spelling": "
|
|
48
|
-
"label.tier.expansion": "
|
|
49
|
-
"label.tier.correction": "
|
|
50
|
-
"label.tier.punctuation": "
|
|
51
|
-
"label.tier.illegible": "
|
|
52
|
-
"label.tier.modernization": "
|
|
53
|
-
"label.tier.padronization": "
|
|
54
|
-
"label.tier.inflection": "
|
|
44
|
+
"label.tier.original": "Originale",
|
|
45
|
+
"label.tier.junction": "Giunzione",
|
|
46
|
+
"label.tier.segmentation": "Segmentazione",
|
|
47
|
+
"label.tier.spelling": "Ortografia",
|
|
48
|
+
"label.tier.expansion": "Espansione",
|
|
49
|
+
"label.tier.correction": "Correzione",
|
|
50
|
+
"label.tier.punctuation": "Punteggiatura",
|
|
51
|
+
"label.tier.illegible": "Illeggibile",
|
|
52
|
+
"label.tier.modernization": "Modernizzazione",
|
|
53
|
+
"label.tier.padronization": "Standardizzazione",
|
|
54
|
+
"label.tier.inflection": "Flessione",
|
|
55
55
|
},
|
|
56
56
|
};
|
|
@@ -8,7 +8,7 @@ export default function ServerErrorReport({ errorContext, corpus, onClose, onSen
|
|
|
8
8
|
const { t } = useTranslation('common');
|
|
9
9
|
const formRef = useRef(null);
|
|
10
10
|
const [sending, setSending] = useState(false);
|
|
11
|
-
const [canSend, setCanSend] = useState(
|
|
11
|
+
const [canSend, setCanSend] = useState(false);
|
|
12
12
|
return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: () => {
|
|
13
13
|
void formRef.current?.send();
|
|
14
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 }) }));
|
|
@@ -8,27 +8,33 @@ import { Button } from '../../primitives';
|
|
|
8
8
|
import { captureTabScreenshot } from './captureTabScreenshot';
|
|
9
9
|
import { getConsoleLogs } from './consoleCapture';
|
|
10
10
|
import './styles.scss';
|
|
11
|
-
const DEFAULT_USER_MESSAGE = 'No extra information given by the user';
|
|
12
11
|
const ServerErrorReportForm = forwardRef(function ServerErrorReportForm({ errorContext, corpus, intent = 'error', showSendButton = false, onSent, onSendingChange, onCanSendChange, className, }, ref) {
|
|
13
12
|
const { t, i18n } = useTranslation('common');
|
|
14
13
|
const [userMessage, setUserMessage] = useState('');
|
|
15
14
|
const [sending, setSending] = useState(false);
|
|
16
15
|
const [sendError, setSendError] = useState(null);
|
|
17
|
-
const canSend = !sending;
|
|
16
|
+
const canSend = !!userMessage.trim() && !sending;
|
|
18
17
|
const placeholderKey = intent === 'feedback'
|
|
19
18
|
? 'server.error.report.feedback.placeholder'
|
|
20
19
|
: 'server.error.report.modal.placeholder';
|
|
21
20
|
const sendLabelKey = intent === 'feedback'
|
|
22
21
|
? 'server.error.report.feedback.send'
|
|
23
22
|
: 'server.error.report.modal.send';
|
|
23
|
+
const validationKey = intent === 'feedback'
|
|
24
|
+
? 'server.error.report.feedback.validation'
|
|
25
|
+
: 'server.error.report.validation';
|
|
24
26
|
const handleSend = async () => {
|
|
27
|
+
if (!userMessage.trim()) {
|
|
28
|
+
setSendError(t(validationKey));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
25
31
|
setSending(true);
|
|
26
32
|
onSendingChange?.(true);
|
|
27
33
|
setSendError(null);
|
|
28
34
|
try {
|
|
29
35
|
const screenshot = await captureTabScreenshot();
|
|
30
36
|
await ErrorReportService.send({
|
|
31
|
-
userMessage
|
|
37
|
+
userMessage,
|
|
32
38
|
errorContext,
|
|
33
39
|
sendContext: {
|
|
34
40
|
locale: i18n.resolvedLanguage || i18n.language,
|
|
@@ -25,12 +25,13 @@ const getTierLabelKey = (symbol) => {
|
|
|
25
25
|
return `sentence:label.tier.${key}`;
|
|
26
26
|
};
|
|
27
27
|
const usesI18nLabel = (symbol) => isDefaultTierSymbol(symbol) || isStructuralEditionTier(symbol);
|
|
28
|
+
const capitalize = (value) => value ? value.charAt(0).toUpperCase() + value.slice(1) : value;
|
|
28
29
|
const getStaticFallbackLabel = (symbol) => {
|
|
29
30
|
const defaultDef = DEFAULT_EDITION_TIERS.find((tier) => tier.symbol === symbol);
|
|
30
31
|
if (defaultDef?.label) {
|
|
31
32
|
return defaultDef.label;
|
|
32
33
|
}
|
|
33
|
-
return getEditionTierName(symbol).toLowerCase();
|
|
34
|
+
return capitalize(getEditionTierName(symbol).toLowerCase());
|
|
34
35
|
};
|
|
35
36
|
const getTierLabel = (symbol, corpus, t) => {
|
|
36
37
|
if (usesI18nLabel(symbol)) {
|
|
@@ -54,6 +55,10 @@ const isUnderSelected = (selected, tier, corpus) => {
|
|
|
54
55
|
}
|
|
55
56
|
return tierIndex <= selectedIndex;
|
|
56
57
|
};
|
|
58
|
+
const STRUCTURAL_PAIR = [
|
|
59
|
+
StructuralEditionTiers.JUNCTION,
|
|
60
|
+
StructuralEditionTiers.SEGMENTATION,
|
|
61
|
+
];
|
|
57
62
|
const buildEditionGroups = (corpus) => {
|
|
58
63
|
const tiers = getCorpusEditionTiers(corpus);
|
|
59
64
|
const semi = tiers
|
|
@@ -62,20 +67,21 @@ const buildEditionGroups = (corpus) => {
|
|
|
62
67
|
const modern = tiers
|
|
63
68
|
.filter((tier) => tier.group === 'modernized')
|
|
64
69
|
.map((tier) => tier.symbol);
|
|
70
|
+
const hasSemi = semi.length > 0;
|
|
65
71
|
return [
|
|
66
72
|
{
|
|
67
73
|
id: 'diplomatic',
|
|
68
74
|
labelKey: 'edition.group.diplomatic',
|
|
69
|
-
//
|
|
70
|
-
tiers: [],
|
|
75
|
+
// When no semi-diplomatic group, jun/seg are clickable under diplomatic.
|
|
76
|
+
tiers: hasSemi ? [] : [...STRUCTURAL_PAIR],
|
|
71
77
|
defaultTier: StructuralEditionTiers.ORIGINAL,
|
|
72
78
|
},
|
|
73
|
-
...(
|
|
79
|
+
...(hasSemi
|
|
74
80
|
? [
|
|
75
81
|
{
|
|
76
82
|
id: 'semiDiplomatic',
|
|
77
83
|
labelKey: 'edition.group.semiDiplomatic',
|
|
78
|
-
tiers: semi,
|
|
84
|
+
tiers: [...STRUCTURAL_PAIR, ...semi],
|
|
79
85
|
defaultTier: semi[semi.length - 1],
|
|
80
86
|
},
|
|
81
87
|
]
|