corpushub-design-system 0.0.9 → 0.0.10

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.
@@ -54,6 +54,11 @@ export declare const CommonTexts: {
54
54
  'server.error.report.validation': string;
55
55
  'server.error.report.send.failed': string;
56
56
  'server.error.report.sent': string;
57
+ 'server.error.report.feedback.placeholder': string;
58
+ 'server.error.report.feedback.privacy': string;
59
+ 'server.error.report.feedback.send': string;
60
+ 'server.error.report.feedback.validation': string;
61
+ 'server.error.report.feedback.sent': string;
57
62
  'table.label.rows-page': string;
58
63
  'table.label.items': string;
59
64
  'table.pagination.scroll-strip-left': string;
@@ -147,6 +152,11 @@ export declare const CommonTexts: {
147
152
  'server.error.report.validation': string;
148
153
  'server.error.report.send.failed': string;
149
154
  'server.error.report.sent': string;
155
+ 'server.error.report.feedback.placeholder': string;
156
+ 'server.error.report.feedback.privacy': string;
157
+ 'server.error.report.feedback.send': string;
158
+ 'server.error.report.feedback.validation': string;
159
+ 'server.error.report.feedback.sent': string;
150
160
  'table.label.rows-page': string;
151
161
  'table.label.items': string;
152
162
  'table.pagination.scroll-strip-left': string;
@@ -240,6 +250,11 @@ export declare const CommonTexts: {
240
250
  'server.error.report.validation': string;
241
251
  'server.error.report.send.failed': string;
242
252
  'server.error.report.sent': string;
253
+ 'server.error.report.feedback.placeholder': string;
254
+ 'server.error.report.feedback.privacy': string;
255
+ 'server.error.report.feedback.send': string;
256
+ 'server.error.report.feedback.validation': string;
257
+ 'server.error.report.feedback.sent': string;
243
258
  'table.label.rows-page': string;
244
259
  'table.label.items': string;
245
260
  'table.pagination.scroll-strip-left': string;
@@ -54,6 +54,11 @@ export const CommonTexts = {
54
54
  'server.error.report.validation': 'Please describe what happened before sending.',
55
55
  'server.error.report.send.failed': 'We could not send your report. Please try again in a moment.',
56
56
  'server.error.report.sent': 'Thank you — your report was sent.',
57
+ 'server.error.report.feedback.placeholder': 'Share a comment, bug report, idea, or anything else on your mind…',
58
+ 'server.error.report.feedback.privacy': "We automatically include this page's URL, recent console output, and a screenshot so we can help faster.",
59
+ 'server.error.report.feedback.send': 'Send feedback',
60
+ 'server.error.report.feedback.validation': 'Please write a short message before sending.',
61
+ 'server.error.report.feedback.sent': 'Thank you — your feedback was sent.',
57
62
  'table.label.rows-page': 'Items per page',
58
63
  'table.label.items': '{{first}} - {{last}} of {{total}}',
59
64
  'table.pagination.scroll-strip-left': 'Scroll page numbers left',
@@ -147,6 +152,11 @@ export const CommonTexts = {
147
152
  'server.error.report.validation': 'Descreva o que aconteceu antes de enviar.',
148
153
  'server.error.report.send.failed': 'Não foi possível enviar seu relatório. Tente novamente em instantes.',
149
154
  'server.error.report.sent': 'Obrigado — seu relatório foi enviado.',
155
+ 'server.error.report.feedback.placeholder': 'Compartilhe um comentário, relato de bug, ideia ou qualquer outra coisa…',
156
+ 'server.error.report.feedback.privacy': 'Incluímos automaticamente a URL desta página, a saída recente do console e uma captura de tela para podermos ajudar mais rápido.',
157
+ 'server.error.report.feedback.send': 'Enviar feedback',
158
+ 'server.error.report.feedback.validation': 'Escreva uma mensagem curta antes de enviar.',
159
+ 'server.error.report.feedback.sent': 'Obrigado — seu feedback foi enviado.',
150
160
  'table.label.rows-page': 'Itens por página',
151
161
  'table.label.items': '{{first}} - {{last}} de {{total}}',
152
162
  'table.pagination.scroll-strip-left': 'Rolar números das páginas à esquerda',
@@ -240,6 +250,11 @@ export const CommonTexts = {
240
250
  'server.error.report.validation': 'Descrivi cosa è successo prima di inviare.',
241
251
  'server.error.report.send.failed': 'Impossibile inviare la segnalazione. Riprova tra poco.',
242
252
  'server.error.report.sent': 'Grazie — la tua segnalazione è stata inviata.',
253
+ 'server.error.report.feedback.placeholder': "Condividi un commento, una segnalazione di bug, un'idea o qualsiasi altra cosa…",
254
+ 'server.error.report.feedback.privacy': "Includiamo automaticamente l'URL di questa pagina, l'output recente della console e uno screenshot per aiutarti più rapidamente.",
255
+ 'server.error.report.feedback.send': 'Invia feedback',
256
+ 'server.error.report.feedback.validation': 'Scrivi un breve messaggio prima di inviare.',
257
+ 'server.error.report.feedback.sent': 'Grazie — il tuo feedback è stato inviato.',
243
258
  'table.label.rows-page': 'Elementi per pagina',
244
259
  'table.label.items': '{{first}} - {{last}} di {{total}}',
245
260
  'table.pagination.scroll-strip-left': 'Scorri i numeri di pagina a sinistra',
@@ -1,37 +1,70 @@
1
1
  export declare const HelpTexts: {
2
2
  en: {
3
3
  'modal.title': string;
4
+ 'modal.subtitle': string;
4
5
  'title.tutorials': string;
5
6
  'title.tour': string;
6
7
  'title.autoOpen': string;
8
+ 'title.resources': string;
9
+ 'title.feedback': string;
7
10
  'button.tour': string;
11
+ 'button.tour.stop': string;
8
12
  'button.updateLiveTourPreference': string;
9
13
  'description.tutorials': string;
10
14
  'description.tour': string;
15
+ 'description.feedback': string;
16
+ 'tour.step.1': string;
17
+ 'tour.step.2': string;
18
+ 'tour.step.3': string;
19
+ 'tour.status.active': string;
20
+ 'tour.status.idle': string;
21
+ 'resources.empty': string;
11
22
  'checkbox.autoOpen': string;
12
23
  'button.open': string;
13
24
  };
14
25
  'pt-BR': {
15
26
  'modal.title': string;
27
+ 'modal.subtitle': string;
16
28
  'title.tutorials': string;
17
29
  'title.tour': string;
18
30
  'title.autoOpen': string;
31
+ 'title.resources': string;
32
+ 'title.feedback': string;
19
33
  'button.tour': string;
34
+ 'button.tour.stop': string;
20
35
  'button.updateLiveTourPreference': string;
21
36
  'description.tutorials': string;
22
37
  'description.tour': string;
38
+ 'description.feedback': string;
39
+ 'tour.step.1': string;
40
+ 'tour.step.2': string;
41
+ 'tour.step.3': string;
42
+ 'tour.status.active': string;
43
+ 'tour.status.idle': string;
44
+ 'resources.empty': string;
23
45
  'checkbox.autoOpen': string;
24
46
  'button.open': string;
25
47
  };
26
48
  it: {
27
49
  'modal.title': string;
50
+ 'modal.subtitle': string;
28
51
  'title.tutorials': string;
29
- 'button.tour': string;
30
- 'button.updateLiveTourPreference': string;
31
52
  'title.tour': string;
32
53
  'title.autoOpen': string;
54
+ 'title.resources': string;
55
+ 'title.feedback': string;
56
+ 'button.tour': string;
57
+ 'button.tour.stop': string;
58
+ 'button.updateLiveTourPreference': string;
33
59
  'description.tutorials': string;
34
60
  'description.tour': string;
61
+ 'description.feedback': string;
62
+ 'tour.step.1': string;
63
+ 'tour.step.2': string;
64
+ 'tour.step.3': string;
65
+ 'tour.status.active': string;
66
+ 'tour.status.idle': string;
67
+ 'resources.empty': string;
35
68
  'checkbox.autoOpen': string;
36
69
  'button.open': string;
37
70
  };
@@ -1,38 +1,71 @@
1
1
  export const HelpTexts = {
2
2
  en: {
3
3
  'modal.title': 'Help Center',
4
+ 'modal.subtitle': 'Get oriented, dig into resources, or tell us anything on your mind.',
4
5
  'title.tutorials': 'Tutorials',
5
6
  'title.tour': 'Live Tour',
6
7
  'title.autoOpen': 'Enable Auto-Open',
8
+ 'title.resources': 'Resources',
9
+ 'title.feedback': 'Send feedback',
7
10
  'button.tour': 'Start Live Tour',
11
+ 'button.tour.stop': 'Stop Live Tour',
8
12
  'button.updateLiveTourPreference': 'Update preference',
9
13
  'description.tutorials': 'Access our comprehensive tutorials and documentation',
10
- 'description.tour': 'Start an interactive tour of the platform or enable it to open automatically',
11
- 'checkbox.autoOpen': 'Enable Auto-Open',
12
- 'button.open': 'Click to open',
14
+ 'description.tour': 'Walk through the main areas of this page with an interactive guided tour.',
15
+ 'description.feedback': 'Comments, bugs, ideas — we read every message and include page context automatically.',
16
+ 'tour.step.1': 'Highlights key controls on the current page',
17
+ 'tour.step.2': 'Explains what each area is for',
18
+ 'tour.step.3': 'Takes only a couple of minutes',
19
+ 'tour.status.active': 'Tour is running — stop it anytime from here.',
20
+ 'tour.status.idle': 'Ready when you are.',
21
+ 'resources.empty': 'No extra resources for this page right now.',
22
+ 'checkbox.autoOpen': 'Open the tour automatically when I visit',
23
+ 'button.open': 'Open',
13
24
  },
14
25
  'pt-BR': {
15
26
  'modal.title': 'Central de Ajuda',
27
+ 'modal.subtitle': 'Oriente-se, explore recursos ou conte-nos o que quiser.',
16
28
  'title.tutorials': 'Tutoriais',
17
29
  'title.tour': 'Tour ao Vivo',
18
30
  'title.autoOpen': 'Ativar Abertura Automática',
31
+ 'title.resources': 'Recursos',
32
+ 'title.feedback': 'Enviar feedback',
19
33
  'button.tour': 'Iniciar Tour ao Vivo',
34
+ 'button.tour.stop': 'Parar Tour ao Vivo',
20
35
  'button.updateLiveTourPreference': 'Atualizar preferência',
21
36
  'description.tutorials': 'Acesse nossos tutoriais abrangentes e documentação',
22
- 'description.tour': 'Inicie um tour interativo da plataforma ou ative para abrir automaticamente',
23
- 'checkbox.autoOpen': 'Ativar Abertura Automática',
24
- 'button.open': 'Clique para abrir',
37
+ 'description.tour': 'Percorra as áreas principais desta página com um tour guiado interativo.',
38
+ 'description.feedback': 'Comentários, bugs, ideias — lemos cada mensagem e incluímos o contexto da página automaticamente.',
39
+ 'tour.step.1': 'Destaca os controles principais da página atual',
40
+ 'tour.step.2': 'Explica para que serve cada área',
41
+ 'tour.step.3': 'Leva só alguns minutos',
42
+ 'tour.status.active': 'O tour está ativo — você pode pará-lo a qualquer momento.',
43
+ 'tour.status.idle': 'Pronto quando você estiver.',
44
+ 'resources.empty': 'Não há recursos extras para esta página no momento.',
45
+ 'checkbox.autoOpen': 'Abrir o tour automaticamente quando eu visitar',
46
+ 'button.open': 'Abrir',
25
47
  },
26
48
  it: {
27
49
  'modal.title': 'Centro Assistenza',
50
+ 'modal.subtitle': 'Orientati, esplora le risorse o raccontaci qualsiasi cosa.',
28
51
  'title.tutorials': 'Tutorial',
29
- 'button.tour': 'Avvia Tour Interattivo',
30
- 'button.updateLiveTourPreference': 'Aggiorna la preferenza',
31
52
  'title.tour': 'Tour Interattivo',
32
53
  'title.autoOpen': 'Abilita Apertura Automatica',
54
+ 'title.resources': 'Risorse',
55
+ 'title.feedback': 'Invia feedback',
56
+ 'button.tour': 'Avvia Tour Interattivo',
57
+ 'button.tour.stop': 'Ferma Tour Interattivo',
58
+ 'button.updateLiveTourPreference': 'Aggiorna la preferenza',
33
59
  'description.tutorials': 'Accedi ai nostri tutorial completi e alla documentazione',
34
- 'description.tour': 'Avvia un tour interattivo della piattaforma o abilitalo per aprirsi automaticamente',
35
- 'checkbox.autoOpen': 'Abilita Apertura Automatica',
36
- 'button.open': 'Clicca per aprire',
60
+ 'description.tour': 'Esplora le aree principali di questa pagina con un tour guidato interattivo.',
61
+ 'description.feedback': 'Commenti, bug, idee — leggiamo ogni messaggio e includiamo automaticamente il contesto della pagina.',
62
+ 'tour.step.1': 'Evidenzia i controlli chiave della pagina corrente',
63
+ 'tour.step.2': 'Spiega a cosa serve ciascuna area',
64
+ 'tour.step.3': 'Richiede solo un paio di minuti',
65
+ 'tour.status.active': 'Il tour è attivo — puoi fermarlo in qualsiasi momento.',
66
+ 'tour.status.idle': 'Pronto quando lo sei tu.',
67
+ 'resources.empty': 'Nessuna risorsa aggiuntiva per questa pagina al momento.',
68
+ 'checkbox.autoOpen': 'Apri il tour automaticamente quando visito',
69
+ 'button.open': 'Apri',
37
70
  },
38
71
  };
@@ -1,54 +1,13 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import axios from 'axios';
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 AppTextArea from '../../common/AppTextArea/AppTextArea';
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, i18n } = useTranslation('common');
13
- const [userMessage, setUserMessage] = useState('');
8
+ const { t } = useTranslation('common');
9
+ const formRef = useRef(null);
14
10
  const [sending, setSending] = useState(false);
15
- const [sendError, setSendError] = useState(null);
16
- const handleSend = async () => {
17
- if (!userMessage.trim()) {
18
- setSendError(t('server.error.report.validation'));
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(false);
12
+ return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: () => formRef.current?.send(), 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
13
  }
@@ -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,91 @@
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 ServerErrorReportForm = forwardRef(function ServerErrorReportForm({ errorContext, corpus, intent = 'error', showSendButton = false, onSent, onSendingChange, onCanSendChange, className, }, ref) {
12
+ const { t, i18n } = useTranslation('common');
13
+ const [userMessage, setUserMessage] = useState('');
14
+ const [sending, setSending] = useState(false);
15
+ const [sendError, setSendError] = useState(null);
16
+ const canSend = !!userMessage.trim() && !sending;
17
+ const placeholderKey = intent === 'feedback'
18
+ ? 'server.error.report.feedback.placeholder'
19
+ : 'server.error.report.modal.placeholder';
20
+ const sendLabelKey = intent === 'feedback'
21
+ ? 'server.error.report.feedback.send'
22
+ : 'server.error.report.modal.send';
23
+ const validationKey = intent === 'feedback'
24
+ ? 'server.error.report.feedback.validation'
25
+ : 'server.error.report.validation';
26
+ const handleSend = async () => {
27
+ if (!userMessage.trim()) {
28
+ setSendError(t(validationKey));
29
+ return;
30
+ }
31
+ setSending(true);
32
+ onSendingChange?.(true);
33
+ setSendError(null);
34
+ try {
35
+ const screenshot = await captureTabScreenshot();
36
+ await ErrorReportService.send({
37
+ userMessage,
38
+ errorContext,
39
+ sendContext: {
40
+ locale: i18n.resolvedLanguage || i18n.language,
41
+ corpusUid: corpus?.uid,
42
+ corpusName: corpus?.name,
43
+ },
44
+ consoleLogs: getConsoleLogs(),
45
+ screenshot,
46
+ });
47
+ setUserMessage('');
48
+ onSent();
49
+ }
50
+ catch (error) {
51
+ console.error('Failed to send server error report:', axios.isAxiosError(error)
52
+ ? {
53
+ message: error.message,
54
+ status: error.response?.status,
55
+ data: error.response?.data,
56
+ url: error.config?.url,
57
+ }
58
+ : error);
59
+ setSendError(t('server.error.report.send.failed'));
60
+ }
61
+ finally {
62
+ setSending(false);
63
+ onSendingChange?.(false);
64
+ }
65
+ };
66
+ useImperativeHandle(ref, () => ({
67
+ send: handleSend,
68
+ canSend,
69
+ sending,
70
+ }),
71
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- handleSend closes over latest state
72
+ [canSend, sending, userMessage, errorContext, corpus, intent]);
73
+ useEffect(() => {
74
+ onCanSendChange?.(canSend);
75
+ }, [canSend, onCanSendChange]);
76
+ const rootClass = [
77
+ 'server-error-report-form',
78
+ intent === 'feedback' && 'server-error-report-form--feedback',
79
+ className,
80
+ ]
81
+ .filter(Boolean)
82
+ .join(' ');
83
+ return (_jsxs("div", { className: rootClass, children: [_jsx(AppTextArea, { value: userMessage, onChange: (e) => {
84
+ setUserMessage(e.target.value);
85
+ if (sendError)
86
+ setSendError(null);
87
+ }, 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: () => {
88
+ void handleSend();
89
+ }, disabled: !canSend }))] }));
90
+ });
91
+ export default ServerErrorReportForm;
@@ -1,2 +1,4 @@
1
1
  import ServerErrorReport from './ServerErrorReport';
2
+ export { default as ServerErrorReportForm } from './ServerErrorReportForm';
3
+ export type { ServerErrorReportFormHandle, ServerErrorReportIntent, } from './ServerErrorReportForm';
2
4
  export default ServerErrorReport;
@@ -1,2 +1,3 @@
1
1
  import ServerErrorReport from './ServerErrorReport';
2
+ export { default as ServerErrorReportForm } from './ServerErrorReportForm';
2
3
  export default ServerErrorReport;
@@ -1,15 +1,13 @@
1
1
  .server-error-report-modal {
2
- &__body {
3
- display: flex;
4
- flex-direction: column;
5
- gap: var(--spacing-200);
2
+ .app-text-area {
3
+ min-height: 160px;
6
4
  }
5
+ }
7
6
 
8
- &__error {
9
- margin: 0;
10
- color: var(--text-danger);
11
- @include body-small-1;
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
  }
@@ -1,12 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import cx from 'classnames';
3
- import { useState } from 'react';
3
+ import { useEffect, useState } from 'react';
4
+ import UsabilityUtils from '../../functions/UsabilityUtils';
4
5
  import Icon from '../Icon';
5
6
  import IconButton from '../IconButton';
6
7
  import './styles.scss';
7
8
  export const DropdownMenuSizes = ['medium', 'small'];
8
9
  export default function DropdownMenu({ list, className, size = 'medium', }) {
9
10
  const [open, setOpen] = useState(false);
11
+ useEffect(() => {
12
+ if (!open)
13
+ return;
14
+ return UsabilityUtils.attachCloseToEscape(() => setOpen(false));
15
+ }, [open]);
10
16
  const getClassNames = cx('ds-dropdown-menu', className, size);
11
17
  const getOptionClassNames = (optionClassName, disabled) => cx('option', optionClassName, { disabled });
12
18
  const iconSize = size === 'small' ? 'x-small' : 'small';
@@ -1,76 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
2
  import { useTranslation } from 'react-i18next';
4
- import { Button } from '../../../primitives';
5
3
  import AppModal from '../../../common/AppModal/AppModal';
6
- import CookieStorage from '../../../configs/CookieStorage';
7
- import ProfileService from '../../../configs/services/ProfileService';
8
- import { useLoggedUtils } from '../../../configs/useLoggedUtils';
9
- import { useTourUtils } from '../../../configs/useTourUtils';
10
- import SecurityUtils from '../../../functions/SecurityUtils';
4
+ import HelpModalMainColumn from './HelpModalMainColumn';
5
+ import HelpModalSideColumn from './HelpModalSideColumn';
11
6
  import './style.scss';
12
7
  export default function HelpModal({ onClose, helpActions = [] }) {
13
8
  const { t } = useTranslation('help');
14
- const { turnOn, turnOff, status } = useTourUtils();
15
- const { getLogged, setLogged } = useLoggedUtils();
16
- const [autoOpenEnabled, setAutoOpenEnabled] = useState(() => getLogged()?.liveTour ?? false);
17
- const [updatingLiveTour, setUpdatingLiveTour] = useState(false);
18
- const isTourActive = status();
19
- const currentLiveTour = getLogged()?.liveTour ?? false;
20
- const preferenceChanged = autoOpenEnabled !== currentLiveTour;
21
- const isDisablingAutoOpen = preferenceChanged && !autoOpenEnabled;
22
- const handleTutorials = () => {
23
- const origin = (import.meta.env.VITE_APP_ORIGIN ?? '').replace(/\/+$/, '');
24
- window.open(`${origin}/home/tutorials`, '_blank');
25
- };
26
- const handleTourToggle = () => {
27
- const startTour = () => {
28
- if (isTourActive) {
29
- turnOff();
30
- }
31
- else {
32
- turnOn();
33
- }
34
- onClose();
35
- };
36
- if (!preferenceChanged) {
37
- startTour();
38
- return;
39
- }
40
- setUpdatingLiveTour(true);
41
- ProfileService.updateLiveTour(autoOpenEnabled)
42
- .then((response) => {
43
- CookieStorage.setJwtToken(response.data);
44
- setLogged(SecurityUtils.parseJwt(response.data));
45
- })
46
- .catch((error) => {
47
- console.error(error);
48
- })
49
- .finally(() => {
50
- setUpdatingLiveTour(false);
51
- if (isDisablingAutoOpen) {
52
- onClose();
53
- return;
54
- }
55
- startTour();
56
- });
57
- };
58
- const handleCustomAction = (item) => {
59
- item.action();
60
- onClose();
61
- };
62
- const handleAutoOpenChange = (event) => {
63
- setAutoOpenEnabled(event.target.checked);
64
- };
65
- const actionItems = [
66
- // {
67
- // title: t('title.tutorials'),
68
- // desc: t('description.tutorials'),
69
- // action: handleTutorials,
70
- // },
71
- ...helpActions,
72
- ];
73
- return (_jsxs(AppModal, { title: t('modal.title'), close: onClose, hideFooter: true, className: "help-modal", children: [_jsxs("div", { className: "item item-tour", children: [_jsx("div", { className: "title", children: t('title.tour') }), _jsx("div", { className: "desc", children: t('description.tour') }), _jsxs("label", { className: "help-checkbox-label", children: [_jsx("input", { type: "checkbox", checked: autoOpenEnabled, onChange: handleAutoOpenChange, disabled: updatingLiveTour, className: "help-checkbox" }), _jsx("span", { children: t('checkbox.autoOpen') })] }), _jsx(Button, { text: isDisablingAutoOpen
74
- ? t('button.updateLiveTourPreference')
75
- : t('button.tour'), size: "small", icon: isDisablingAutoOpen ? 'save' : 'keyboard_arrow_right', onClick: handleTourToggle, disabled: updatingLiveTour, "data-tour": "guided-tour-start" })] }), actionItems.map((item, idx) => (_jsxs("div", { className: "item", children: [_jsx("div", { className: "title", children: item.title }), _jsx("div", { className: "desc", children: item.desc }), _jsx(Button, { text: t('button.open'), size: "small", mode: "outlined", icon: "keyboard_arrow_right", onClick: () => handleCustomAction(item) })] }, idx)))] }));
9
+ return (_jsx(AppModal, { title: t('modal.title'), subtitle: t('modal.subtitle'), close: onClose, hideFooter: true, className: "help-modal", children: _jsxs("div", { className: "help-modal__layout", children: [_jsx(HelpModalMainColumn, { onClose: onClose }), _jsx(HelpModalSideColumn, { helpActions: helpActions, onClose: onClose })] }) }));
76
10
  }
@@ -0,0 +1,5 @@
1
+ type Props = {
2
+ onClose: () => void;
3
+ };
4
+ export default function HelpModalMainColumn({ onClose }: Props): import("react").JSX.Element;
5
+ export {};
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import CookieStorage from '../../../configs/CookieStorage';
5
+ import ProfileService from '../../../configs/services/ProfileService';
6
+ import { useCorpusUtils } from '../../../configs/useCorpusUtils';
7
+ import { useLoggedUtils } from '../../../configs/useLoggedUtils';
8
+ import { useMessageUtils } from '../../../configs/useMessageUtils';
9
+ import { useTourUtils } from '../../../configs/useTourUtils';
10
+ import { ServerErrorReportForm } from '../../../features/ServerErrorReport';
11
+ import SecurityUtils from '../../../functions/SecurityUtils';
12
+ import { Button } from '../../../primitives';
13
+ import liveTourImg from './live-tour.png';
14
+ export default function HelpModalMainColumn({ onClose }) {
15
+ const { t } = useTranslation('help');
16
+ const { t: tCommon } = useTranslation('common');
17
+ const { turnOn, turnOff, status } = useTourUtils();
18
+ const { getLogged, setLogged } = useLoggedUtils();
19
+ const { getCorpus, hasCorpus } = useCorpusUtils();
20
+ const { dispatchMessageDirect } = useMessageUtils();
21
+ const [autoOpenEnabled, setAutoOpenEnabled] = useState(() => getLogged()?.liveTour ?? false);
22
+ const [updatingLiveTour, setUpdatingLiveTour] = useState(false);
23
+ const isTourActive = status();
24
+ const currentLiveTour = getLogged()?.liveTour ?? false;
25
+ const preferenceChanged = autoOpenEnabled !== currentLiveTour;
26
+ const isDisablingAutoOpen = preferenceChanged && !autoOpenEnabled;
27
+ const handleTourToggle = () => {
28
+ const startTour = () => {
29
+ if (isTourActive) {
30
+ turnOff();
31
+ }
32
+ else {
33
+ turnOn();
34
+ }
35
+ onClose();
36
+ };
37
+ if (!preferenceChanged) {
38
+ startTour();
39
+ return;
40
+ }
41
+ setUpdatingLiveTour(true);
42
+ ProfileService.updateLiveTour(autoOpenEnabled)
43
+ .then((response) => {
44
+ CookieStorage.setJwtToken(response.data);
45
+ setLogged(SecurityUtils.parseJwt(response.data));
46
+ })
47
+ .catch((error) => {
48
+ console.error(error);
49
+ })
50
+ .finally(() => {
51
+ setUpdatingLiveTour(false);
52
+ if (isDisablingAutoOpen) {
53
+ onClose();
54
+ return;
55
+ }
56
+ startTour();
57
+ });
58
+ };
59
+ const handleAutoOpenChange = (event) => {
60
+ setAutoOpenEnabled(event.target.checked);
61
+ };
62
+ const handleFeedbackSent = () => {
63
+ dispatchMessageDirect(tCommon('server.error.report.feedback.sent'), 'success');
64
+ };
65
+ const tourButtonLabel = isDisablingAutoOpen
66
+ ? t('button.updateLiveTourPreference')
67
+ : isTourActive
68
+ ? t('button.tour.stop')
69
+ : t('button.tour');
70
+ const tourButtonIcon = isDisablingAutoOpen
71
+ ? 'save'
72
+ : isTourActive
73
+ ? 'stop_circle'
74
+ : 'play_circle';
75
+ return (_jsxs("div", { className: "help-modal__main", children: [_jsxs("section", { className: "help-modal__tour live-tour", "aria-labelledby": "help-tour-title", children: [_jsxs("div", { className: "help-modal__tour-header", children: [_jsx("h2", { id: "help-tour-title", className: "help-modal__tour-title", children: t('title.tour') }), _jsx("p", { className: "help-modal__tour-desc", children: t('description.tour') })] }), _jsxs("div", { className: "help-modal__tour-body", children: [_jsxs("div", { className: "help-modal__tour-content tour-content", children: [_jsxs("ol", { className: "help-modal__tour-steps", children: [_jsx("li", { children: t('tour.step.1') }), _jsx("li", { children: t('tour.step.2') }), _jsx("li", { children: t('tour.step.3') })] }), _jsxs("label", { className: "help-checkbox-label", children: [_jsx("input", { type: "checkbox", checked: autoOpenEnabled, onChange: handleAutoOpenChange, disabled: updatingLiveTour, className: "help-checkbox" }), _jsx("span", { children: t('checkbox.autoOpen') })] }), _jsx(Button, { text: tourButtonLabel, size: "small", icon: tourButtonIcon, onClick: handleTourToggle, disabled: updatingLiveTour, "data-tour": "guided-tour-start" })] }), _jsx("div", { className: "help-modal__tour-media", children: _jsx("img", { src: liveTourImg, alt: "", className: "help-modal__tour-image" }) })] })] }), _jsxs("section", { className: "help-modal__feedback", "aria-labelledby": "help-feedback-title", children: [_jsx("h2", { id: "help-feedback-title", className: "help-modal__section-title", children: t('title.feedback') }), _jsx("p", { className: "help-modal__section-desc", children: t('description.feedback') }), _jsx(ServerErrorReportForm, { intent: "feedback", showSendButton: true, corpus: hasCorpus() ? getCorpus() : undefined, onSent: handleFeedbackSent })] })] }));
76
+ }
@@ -0,0 +1,7 @@
1
+ import { HelpAction } from './HelpButton';
2
+ type Props = {
3
+ helpActions: HelpAction[];
4
+ onClose: () => void;
5
+ };
6
+ export default function HelpModalSideColumn({ helpActions, onClose }: Props): import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Button } from '../../../primitives';
4
+ export default function HelpModalSideColumn({ helpActions, onClose }) {
5
+ const { t } = useTranslation('help');
6
+ const handleCustomAction = (item) => {
7
+ item.action();
8
+ onClose();
9
+ };
10
+ return (_jsx("div", { className: "help-modal__side", children: helpActions.length > 0 ? (_jsxs("section", { className: "help-modal__resources", "aria-labelledby": "help-resources-title", children: [_jsx("h2", { id: "help-resources-title", className: "help-modal__section-title", children: t('title.resources') }), _jsx("ul", { className: "help-modal__action-list", children: helpActions.map((item, idx) => (_jsxs("li", { className: "help-modal__action-item", children: [_jsxs("div", { className: "help-modal__action-copy", children: [_jsx("div", { className: "help-modal__action-title", children: item.title }), _jsx("div", { className: "help-modal__action-desc", children: item.desc })] }), _jsx(Button, { text: t('button.open'), size: "x-small", mode: "outlined", icon: "keyboard_arrow_right", onClick: () => handleCustomAction(item) })] }, idx))) })] })) : (_jsxs("section", { className: "help-modal__resources help-modal__resources--empty", children: [_jsx("h2", { className: "help-modal__section-title", children: t('title.resources') }), _jsx("p", { className: "help-modal__section-desc", children: t('resources.empty') })] })) }));
11
+ }
@@ -1,58 +1,220 @@
1
1
  .help-modal {
2
- max-width: 60vw !important;
3
- width: 60vw !important;
2
+ max-width: min(1400px, 85vw) !important;
3
+ width: min(1400px, 85vw) !important;
4
+ top: 50% !important;
5
+ max-height: 88vh;
4
6
 
5
- .body {
7
+ > .body {
8
+ display: flex;
9
+ flex-direction: column;
10
+ max-height: calc(88vh - 88px);
11
+ overflow: hidden;
12
+ padding-top: var(--spacing-200);
13
+ }
14
+
15
+ &__layout {
6
16
  display: grid;
7
- grid-template-columns: repeat(3, minmax(0, 1fr));
17
+ grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
18
+ gap: 8px;
19
+ min-height: 0;
20
+ flex: 1;
21
+ animation: help-modal-fade-in 220ms ease-out;
22
+ }
23
+
24
+ &__main {
25
+ display: flex;
26
+ flex-direction: column;
8
27
  gap: var(--spacing-200);
28
+ min-height: 0;
29
+ overflow-y: auto;
30
+ padding-right: 4px;
31
+ }
9
32
 
10
- .item {
11
- display: flex;
12
- flex-direction: column;
13
- min-width: 0;
14
- padding: 24px 24px 16px;
15
- border: 1px solid var(--border-subtle-2);
16
- border-radius: var(--radius-100);
17
-
18
- > .title {
19
- @include subtitle-small-2;
20
- color: var(--text-primary);
21
- margin-bottom: 4px;
22
- }
23
-
24
- > .desc {
25
- @include body-medium-1;
26
- color: var(--text-secondary);
27
- }
28
-
29
- > .ds-button {
30
- margin-top: auto;
31
- }
33
+ &__tour {
34
+ display: flex;
35
+ flex-direction: column;
36
+ gap: var(--spacing-200);
37
+ padding: 16px;
38
+ border: 1px solid var(--border-subtle-2);
39
+ border-radius: var(--radius-200);
40
+ background-color: #ebeff8;
41
+ color: var(--text-primary);
42
+ }
43
+
44
+ &__tour-header {
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: var(--spacing-100);
48
+ width: 100%;
49
+ }
50
+
51
+ &__tour-body {
52
+ display: grid;
53
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
54
+ gap: var(--spacing-300);
55
+ align-items: center;
56
+ width: 100%;
57
+ }
58
+
59
+ &__tour-content {
60
+ display: flex;
61
+ flex-direction: column;
62
+ gap: var(--spacing-100);
63
+ min-width: 0;
64
+ }
65
+
66
+ &__tour-title {
67
+ margin: 0;
68
+ @include subtitle-medium-2;
69
+ color: var(--text-primary);
70
+ }
71
+
72
+ &__tour-desc {
73
+ margin: 0;
74
+ @include body-medium-1;
75
+ color: var(--text-secondary);
76
+ }
77
+
78
+ &__tour-steps {
79
+ margin: 0;
80
+ padding-left: 1.25rem;
81
+ display: flex;
82
+ flex-direction: column;
83
+ gap: var(--spacing-050);
84
+ @include body-medium-1;
85
+ color: var(--text-secondary);
86
+
87
+ li::marker {
88
+ color: var(--text-primary);
89
+ font-weight: 600;
32
90
  }
91
+ }
33
92
 
34
- .item-tour {
35
- background-color: #ebeff8;
93
+ &__tour-media {
94
+ display: flex;
95
+ justify-content: center;
96
+ align-items: center;
97
+ min-width: 0;
98
+ }
99
+
100
+ &__tour-image {
101
+ display: block;
102
+ width: 100%;
103
+ max-width: 240px;
104
+ height: auto;
105
+ aspect-ratio: 240 / 180;
106
+ object-fit: contain;
107
+ }
36
108
 
37
- .help-checkbox-label {
38
- display: flex;
39
- align-items: center;
40
- gap: var(--spacing-100);
41
- cursor: pointer;
42
- margin: 8px 0;
109
+ &__side {
110
+ display: flex;
111
+ flex-direction: column;
112
+ min-height: 0;
113
+ overflow-y: auto;
114
+ }
115
+
116
+ &__resources,
117
+ &__feedback {
118
+ display: flex;
119
+ flex-direction: column;
120
+ gap: var(--spacing-150);
121
+ padding: 16px;
122
+ border: 1px solid var(--border-subtle-2);
123
+ border-radius: var(--radius-200);
124
+ background-color: var(--background-default);
125
+ }
126
+
127
+ &__resources {
128
+ flex: 1;
129
+ min-height: 0;
130
+ }
131
+
132
+ &__section-title {
133
+ margin: 0;
134
+ @include subtitle-medium-2;
135
+ color: var(--text-primary);
136
+ }
137
+
138
+ &__section-desc {
139
+ margin: 0;
140
+ @include body-medium-1;
141
+ color: var(--text-secondary);
142
+ }
43
143
 
44
- .help-checkbox {
45
- cursor: pointer;
46
- }
47
- }
144
+ &__action-list {
145
+ list-style: none;
146
+ margin: 8px 0 0;
147
+ padding: 0;
148
+ display: flex;
149
+ flex-direction: column;
150
+ gap: var(--spacing-150);
151
+ }
152
+
153
+ &__action-item {
154
+ display: flex;
155
+ align-items: flex-start;
156
+ justify-content: space-between;
157
+ gap: var(--spacing-150);
158
+ padding-bottom: var(--spacing-150);
159
+ border-bottom: 1px solid var(--border-subtle-1);
160
+
161
+ &:last-child {
162
+ padding-bottom: 0;
163
+ border-bottom: none;
164
+ }
165
+
166
+ > .ds-button {
167
+ flex-shrink: 0;
48
168
  }
49
169
  }
170
+
171
+ &__action-title {
172
+ @include label-medium-2;
173
+ color: var(--text-primary);
174
+ margin-bottom: 2px;
175
+ }
176
+
177
+ &__action-desc {
178
+ @include body-small-1;
179
+ color: var(--text-secondary);
180
+ }
181
+
182
+ .help-checkbox-label {
183
+ display: flex;
184
+ align-items: center;
185
+ gap: var(--spacing-100);
186
+ cursor: pointer;
187
+ user-select: none;
188
+ @include body-medium-1;
189
+ color: var(--text-primary);
190
+ margin: var(--spacing-100) 0 var(--spacing-200);
191
+
192
+ .help-checkbox {
193
+ cursor: pointer;
194
+ }
195
+ }
196
+ }
197
+
198
+ @keyframes help-modal-fade-in {
199
+ from {
200
+ opacity: 0;
201
+ transform: translateY(6px);
202
+ }
203
+ to {
204
+ opacity: 1;
205
+ transform: translateY(0);
206
+ }
50
207
  }
51
208
 
52
209
  @media (max-width: 1366px) {
53
210
  .help-modal {
54
- max-width: 80vw !important;
55
- width: 80vw !important;
211
+ &__tour-body {
212
+ grid-template-columns: 1fr;
213
+ }
214
+
215
+ &__tour-media {
216
+ display: none;
217
+ }
56
218
  }
57
219
  }
58
220
 
@@ -60,21 +222,47 @@
60
222
  .help-modal {
61
223
  max-width: 90vw !important;
62
224
  width: 90vw !important;
225
+ top: 50% !important;
226
+ max-height: 95vh !important;
63
227
 
64
- .body {
65
- grid-template-columns: repeat(2, minmax(0, 1fr));
228
+ &__layout {
229
+ display: flex;
230
+ flex-direction: column-reverse;
231
+ min-height: unset;
232
+ }
233
+
234
+ > .body {
235
+ overflow-y: auto;
236
+ max-height: 95vh !important;
237
+ }
238
+
239
+ &__main,
240
+ &__side {
241
+ overflow: visible;
242
+ padding-right: 0;
243
+ min-height: unset;
66
244
  }
67
245
  }
68
246
  }
69
247
 
70
248
  @media (max-width: 767px) {
71
249
  .help-modal {
72
- top: 50% !important;
250
+ max-width: 95vw !important;
251
+ width: 95vw !important;
73
252
 
74
- .body {
75
- grid-template-columns: repeat(1, minmax(0, 1fr));
76
- max-height: 86vh;
77
- overflow-y: auto;
253
+ &__tour,
254
+ &__resources,
255
+ &__feedback {
256
+ padding: var(--spacing-200);
257
+ }
258
+
259
+ &__tour-image {
260
+ max-width: 200px;
261
+ }
262
+
263
+ &__action-item {
264
+ flex-direction: column;
265
+ align-items: stretch;
78
266
  }
79
267
  }
80
268
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corpushub-design-system",
3
3
  "private": false,
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {