tycho-components 0.23.8 → 0.23.9

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.
@@ -26,5 +26,5 @@ export { useCorpusUtils } from './useCorpusUtils';
26
26
  export { useLoggedUtils } from './useLoggedUtils';
27
27
  export { useMessageUtils } from './useMessageUtils';
28
28
  export { useTourUtils } from './useTourUtils';
29
- export { useDriverTour, loadKnowledgeBase, defaultMatchPathnames, buildAnchorMap, flattenWorkflowSteps, getWorkflowsForPath, buildDriveSteps, createTourDriver, hasMatchingWorkflow, resolveAnchor, resolveAnchorById, waitForSelector, } from './tour';
30
- export type { AnchorSelector, KnowledgeBase, PopoverSide, ResolveKnowledgeBaseUrl, TourAnchor, TourButtonLabels, TourStep, TourWorkflow, UseDriverTourOptions, } from './tour';
29
+ export { useDriverTour, loadKnowledgeBase, defaultMatchPathnames, buildAnchorMap, flattenWorkflowSteps, getWorkflowsForPath, buildDriveSteps, createTourDriver, hasMatchingWorkflow, resolveAnchor, resolveAnchorById, waitForSelector, localizeKnowledgeBase, pickLocalizedString, resolveTourLocale, TOUR_FALLBACK_LOCALE, TOUR_LOCALES, } from './tour';
30
+ export type { AnchorSelector, KnowledgeBase, KnowledgeBaseRaw, LocalizedString, PopoverSide, ResolveKnowledgeBaseUrl, TourAnchor, TourButtonLabels, TourStep, TourStepCopy, TourStepStructural, TourWorkflow, TourWorkflowRaw, UseDriverTourOptions, } from './tour';
@@ -15,4 +15,4 @@ export { useCorpusUtils } from './useCorpusUtils';
15
15
  export { useLoggedUtils } from './useLoggedUtils';
16
16
  export { useMessageUtils } from './useMessageUtils';
17
17
  export { useTourUtils } from './useTourUtils';
18
- export { useDriverTour, loadKnowledgeBase, defaultMatchPathnames, buildAnchorMap, flattenWorkflowSteps, getWorkflowsForPath, buildDriveSteps, createTourDriver, hasMatchingWorkflow, resolveAnchor, resolveAnchorById, waitForSelector, } from './tour';
18
+ export { useDriverTour, loadKnowledgeBase, defaultMatchPathnames, buildAnchorMap, flattenWorkflowSteps, getWorkflowsForPath, buildDriveSteps, createTourDriver, hasMatchingWorkflow, resolveAnchor, resolveAnchorById, waitForSelector, localizeKnowledgeBase, pickLocalizedString, resolveTourLocale, TOUR_FALLBACK_LOCALE, TOUR_LOCALES, } from './tour';
@@ -1,56 +1,56 @@
1
1
  export declare const SentenceTexts: {
2
2
  en: {
3
- 'label.word': string;
4
- 'label.pos.tag': string;
5
- 'label.tag': string;
6
- 'label.morphemes': string;
7
- 'label.empty': string;
8
- 'label.tier.original': string;
9
- 'label.tier.junction': string;
10
- 'label.tier.segmentation': string;
11
- 'label.tier.spelling': string;
12
- 'label.tier.expansion': string;
13
- 'label.tier.correction': string;
14
- 'label.tier.punctuation': string;
15
- 'label.tier.illegible': string;
16
- 'label.tier.modernization': string;
17
- 'label.tier.padronization': string;
18
- 'label.tier.inflection': string;
3
+ "label.word": string;
4
+ "label.pos.tag": string;
5
+ "label.tag": string;
6
+ "label.morphemes": string;
7
+ "label.empty": string;
8
+ "label.tier.original": string;
9
+ "label.tier.junction": string;
10
+ "label.tier.segmentation": string;
11
+ "label.tier.spelling": string;
12
+ "label.tier.expansion": string;
13
+ "label.tier.correction": string;
14
+ "label.tier.punctuation": string;
15
+ "label.tier.illegible": string;
16
+ "label.tier.modernization": string;
17
+ "label.tier.padronization": string;
18
+ "label.tier.inflection": string;
19
19
  };
20
- 'pt-BR': {
21
- 'label.word': string;
22
- 'label.pos.tag': string;
23
- 'label.tag': string;
24
- 'label.morphemes': string;
25
- 'label.empty': string;
26
- 'label.tier.original': string;
27
- 'label.tier.junction': string;
28
- 'label.tier.segmentation': string;
29
- 'label.tier.spelling': string;
30
- 'label.tier.expansion': string;
31
- 'label.tier.correction': string;
32
- 'label.tier.punctuation': string;
33
- 'label.tier.illegible': string;
34
- 'label.tier.modernization': string;
35
- 'label.tier.padronization': string;
36
- 'label.tier.inflection': string;
20
+ "pt-BR": {
21
+ "label.word": string;
22
+ "label.pos.tag": string;
23
+ "label.tag": string;
24
+ "label.morphemes": string;
25
+ "label.empty": string;
26
+ "label.tier.original": string;
27
+ "label.tier.junction": string;
28
+ "label.tier.segmentation": string;
29
+ "label.tier.spelling": string;
30
+ "label.tier.expansion": string;
31
+ "label.tier.correction": string;
32
+ "label.tier.punctuation": string;
33
+ "label.tier.illegible": string;
34
+ "label.tier.modernization": string;
35
+ "label.tier.padronization": string;
36
+ "label.tier.inflection": string;
37
37
  };
38
38
  it: {
39
- 'label.word': string;
40
- 'label.pos.tag': string;
41
- 'label.tag': string;
42
- 'label.morphemes': string;
43
- 'label.empty': string;
44
- 'label.tier.original': string;
45
- 'label.tier.junction': string;
46
- 'label.tier.segmentation': string;
47
- 'label.tier.spelling': string;
48
- 'label.tier.expansion': string;
49
- 'label.tier.correction': string;
50
- 'label.tier.punctuation': string;
51
- 'label.tier.illegible': string;
52
- 'label.tier.modernization': string;
53
- 'label.tier.padronization': string;
54
- 'label.tier.inflection': string;
39
+ "label.word": string;
40
+ "label.pos.tag": string;
41
+ "label.tag": string;
42
+ "label.morphemes": string;
43
+ "label.empty": string;
44
+ "label.tier.original": string;
45
+ "label.tier.junction": string;
46
+ "label.tier.segmentation": string;
47
+ "label.tier.spelling": string;
48
+ "label.tier.expansion": string;
49
+ "label.tier.correction": string;
50
+ "label.tier.punctuation": string;
51
+ "label.tier.illegible": string;
52
+ "label.tier.modernization": string;
53
+ "label.tier.padronization": string;
54
+ "label.tier.inflection": string;
55
55
  };
56
56
  };
@@ -1,56 +1,56 @@
1
1
  export const SentenceTexts = {
2
2
  en: {
3
- 'label.word': 'Word',
4
- 'label.pos.tag': 'POS Tag',
5
- 'label.tag': 'Tag',
6
- 'label.morphemes': 'Morphemes',
7
- 'label.empty': '-',
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': 'padronization',
18
- 'label.tier.inflection': 'inflection',
3
+ "label.word": "Word",
4
+ "label.pos.tag": "POS Tag",
5
+ "label.tag": "Tag",
6
+ "label.morphemes": "Morphemes",
7
+ "label.empty": "-",
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
- 'pt-BR': {
21
- 'label.word': 'Palavra',
22
- 'label.pos.tag': 'Etiqueta POS',
23
- 'label.tag': 'Etiqueta',
24
- 'label.morphemes': 'Morfemas',
25
- 'label.empty': '-',
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',
20
+ "pt-BR": {
21
+ "label.word": "Palavra",
22
+ "label.pos.tag": "Etiqueta POS",
23
+ "label.tag": "Etiqueta",
24
+ "label.morphemes": "Morfemas",
25
+ "label.empty": "-",
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
- 'label.word': 'Parola',
40
- 'label.pos.tag': 'Etichetta POS',
41
- 'label.tag': 'Etichetta',
42
- 'label.morphemes': 'Morfemi',
43
- 'label.empty': '-',
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',
39
+ "label.word": "Parola",
40
+ "label.pos.tag": "Etichetta POS",
41
+ "label.tag": "Etichetta",
42
+ "label.morphemes": "Morfemi",
43
+ "label.empty": "-",
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
  };
@@ -1,5 +1,6 @@
1
1
  export { useDriverTour } from './useDriverTour';
2
2
  export { buildAnchorMap, defaultMatchPathnames, flattenWorkflowSteps, getWorkflowsForPath, loadKnowledgeBase, } from './knowledgeBase';
3
3
  export { buildDriveSteps, createTourDriver, hasMatchingWorkflow, } from './driverTour';
4
+ export { localizeKnowledgeBase, pickLocalizedString, resolveTourLocale, TOUR_FALLBACK_LOCALE, TOUR_LOCALES, } from './localizeKnowledgeBase';
4
5
  export { resolveAnchor, resolveAnchorById, waitForSelector, } from './anchorResolver';
5
- export type { AnchorSelector, KnowledgeBase, PopoverSide, ResolveKnowledgeBaseUrl, TourAnchor, TourButtonLabels, TourStep, TourWorkflow, UseDriverTourOptions, } from './types';
6
+ export type { AnchorSelector, KnowledgeBase, KnowledgeBaseRaw, LocalizedString, PopoverSide, ResolveKnowledgeBaseUrl, TourAnchor, TourButtonLabels, TourStep, TourStepCopy, TourStepStructural, TourWorkflow, TourWorkflowRaw, UseDriverTourOptions, } from './types';
@@ -1,4 +1,5 @@
1
1
  export { useDriverTour } from './useDriverTour';
2
2
  export { buildAnchorMap, defaultMatchPathnames, flattenWorkflowSteps, getWorkflowsForPath, loadKnowledgeBase, } from './knowledgeBase';
3
3
  export { buildDriveSteps, createTourDriver, hasMatchingWorkflow, } from './driverTour';
4
+ export { localizeKnowledgeBase, pickLocalizedString, resolveTourLocale, TOUR_FALLBACK_LOCALE, TOUR_LOCALES, } from './localizeKnowledgeBase';
4
5
  export { resolveAnchor, resolveAnchorById, waitForSelector, } from './anchorResolver';
@@ -0,0 +1,6 @@
1
+ import type { KnowledgeBase, KnowledgeBaseRaw, LocalizedString } from './types';
2
+ export declare const TOUR_LOCALES: readonly ["en", "pt-BR", "it"];
3
+ export declare const TOUR_FALLBACK_LOCALE = "en";
4
+ export declare function resolveTourLocale(language: string): string;
5
+ export declare function pickLocalizedString(value: LocalizedString, locale: string): string;
6
+ export declare function localizeKnowledgeBase(raw: KnowledgeBaseRaw, locale: string): KnowledgeBase;
@@ -0,0 +1,70 @@
1
+ export const TOUR_LOCALES = ['en', 'pt-BR', 'it'];
2
+ export const TOUR_FALLBACK_LOCALE = 'en';
3
+ const LOCALE_FOLDER_BY_LANGUAGE = {
4
+ en: 'en',
5
+ 'pt-BR': 'pt-BR',
6
+ pt: 'pt-BR',
7
+ it: 'it',
8
+ };
9
+ export function resolveTourLocale(language) {
10
+ return LOCALE_FOLDER_BY_LANGUAGE[language] ?? language;
11
+ }
12
+ export function pickLocalizedString(value, locale) {
13
+ if (typeof value === 'string')
14
+ return value;
15
+ const folder = resolveTourLocale(locale);
16
+ return (value[folder] ??
17
+ value[TOUR_FALLBACK_LOCALE] ??
18
+ Object.values(value).find((entry) => entry.length > 0) ??
19
+ '');
20
+ }
21
+ function isLegacyWorkflow(workflow) {
22
+ if (workflow.copy)
23
+ return false;
24
+ return workflow.steps.some((step) => 'title' in step || 'body' in step);
25
+ }
26
+ function pickCopyBlock(copy, locale) {
27
+ const folder = resolveTourLocale(locale);
28
+ return (copy[folder] ??
29
+ copy[TOUR_FALLBACK_LOCALE] ??
30
+ Object.values(copy).find((block) => block.length > 0) ??
31
+ []);
32
+ }
33
+ function localizeWorkflow(workflow, locale) {
34
+ if (isLegacyWorkflow(workflow)) {
35
+ return {
36
+ id: workflow.id,
37
+ title: pickLocalizedString(workflow.title, locale),
38
+ matchRoute: workflow.matchRoute,
39
+ steps: workflow.steps,
40
+ };
41
+ }
42
+ const copyBlock = workflow.copy
43
+ ? pickCopyBlock(workflow.copy, locale)
44
+ : [];
45
+ if (copyBlock.length !== workflow.steps.length) {
46
+ console.error(`Tour workflow "${workflow.id}": copy length (${copyBlock.length}) does not match steps length (${workflow.steps.length}) for locale "${locale}"`);
47
+ }
48
+ const steps = workflow.steps.map((structural, index) => {
49
+ const text = copyBlock[index] ?? { title: '', body: '' };
50
+ return {
51
+ anchor: structural.anchor,
52
+ title: text.title,
53
+ body: text.body,
54
+ };
55
+ });
56
+ return {
57
+ id: workflow.id,
58
+ title: pickLocalizedString(workflow.title, locale),
59
+ matchRoute: workflow.matchRoute,
60
+ steps,
61
+ };
62
+ }
63
+ export function localizeKnowledgeBase(raw, locale) {
64
+ return {
65
+ title: pickLocalizedString(raw.title, locale),
66
+ module: raw.module,
67
+ anchors: raw.anchors,
68
+ workflows: raw.workflows.map((workflow) => localizeWorkflow(workflow, locale)),
69
+ };
70
+ }
@@ -13,6 +13,14 @@ export type TourAnchor = {
13
13
  guardClickPanel?: string;
14
14
  popoverSide?: PopoverSide;
15
15
  };
16
+ export type LocalizedString = string | Record<string, string>;
17
+ export type TourStepCopy = {
18
+ title: string;
19
+ body: string;
20
+ };
21
+ export type TourStepStructural = {
22
+ anchor?: string;
23
+ };
16
24
  export type TourStep = {
17
25
  title: string;
18
26
  body: string;
@@ -24,12 +32,25 @@ export type TourWorkflow = {
24
32
  matchRoute: string;
25
33
  steps: TourStep[];
26
34
  };
35
+ export type TourWorkflowRaw = {
36
+ id: string;
37
+ title: LocalizedString;
38
+ matchRoute: string;
39
+ steps: TourStepStructural[] | TourStep[];
40
+ copy?: Record<string, TourStepCopy[]>;
41
+ };
27
42
  export type KnowledgeBase = {
28
43
  title: string;
29
44
  module: string;
30
45
  anchors: TourAnchor[];
31
46
  workflows: TourWorkflow[];
32
47
  };
48
+ export type KnowledgeBaseRaw = {
49
+ title: LocalizedString;
50
+ module: string;
51
+ anchors: TourAnchor[];
52
+ workflows: TourWorkflowRaw[];
53
+ };
33
54
  export type TourButtonLabels = {
34
55
  next: string;
35
56
  previous: string;
@@ -38,7 +38,7 @@ export default function HeaderApps({ navigateLogout, navigateNotLogged, hideKeyb
38
38
  goto(item, true);
39
39
  }, title: t("label.open.tab") })] })] }, idx.valueOf()));
40
40
  };
41
- return (_jsxs("div", { className: "header-apps-container", children: [_jsx(IconButton, { name: "apps", className: "icon-apps", size: "large", onClick: () => setOpen(!open), filledIcon: true }), open && (_jsxs(Drawer, { anchor: "left", open: true, onClose: () => setOpen(false), className: "offcanvas-apps", children: [_jsxs("div", { className: "header", children: [_jsx(IconButton, { name: "close", size: "medium", mode: "ghost", iconSize: "medium", onClick: () => setOpen(false) }), _jsx("span", { className: "header-apps-title", children: t("header:label.platform.complete") }), _jsx("div", { className: "header-profile-apps", children: _jsx(HeaderUser, { navigateLogout: navigateLogout, navigateNotLogged: navigateNotLogged }) })] }), _jsxs("div", { className: "body", children: [_jsx("div", { className: "title", children: t("label.tools") }), AvailableApps.map((item, idx) => renderItem(item, idx)), _jsx("div", { className: "title", children: t("label.quick") }), resources.map((item, idx) => renderItem(item, idx))] }), _jsx("div", { className: "footer", children: _jsx("div", { className: "header-apps-buttons", children: _jsx(HeaderButtons, { hideKeyboard: hideKeyboard, notifications: notifications, keyboardLayout: keyboardLayout, helpActions: helpActions, mobile: true }) }) })] }))] }));
41
+ return (_jsxs("div", { className: "header-apps-container", children: [_jsx(IconButton, { name: "apps", className: "icon-apps", size: "large", onClick: () => setOpen(!open), filledIcon: true, "data-tour": "header-apps" }), open && (_jsxs(Drawer, { anchor: "left", open: true, onClose: () => setOpen(false), className: "offcanvas-apps", children: [_jsxs("div", { className: "header", children: [_jsx(IconButton, { name: "close", size: "medium", mode: "ghost", iconSize: "medium", onClick: () => setOpen(false) }), _jsx("span", { className: "header-apps-title", children: t("header:label.platform.complete") }), _jsx("div", { className: "header-profile-apps", children: _jsx(HeaderUser, { navigateLogout: navigateLogout, navigateNotLogged: navigateNotLogged }) })] }), _jsxs("div", { className: "body", children: [_jsx("div", { className: "title", children: t("label.tools") }), AvailableApps.map((item, idx) => renderItem(item, idx)), _jsx("div", { className: "title", children: t("label.quick") }), resources.map((item, idx) => renderItem(item, idx))] }), _jsx("div", { className: "footer", children: _jsx("div", { className: "header-apps-buttons", children: _jsx(HeaderButtons, { hideKeyboard: hideKeyboard, notifications: notifications, keyboardLayout: keyboardLayout, helpActions: helpActions, mobile: true }) }) })] }))] }));
42
42
  }
43
43
  const platformOrigin = (import.meta.env.VITE_APP_ORIGIN ?? "").replace(/\/+$/, "");
44
44
  const resources = [
@@ -66,5 +66,5 @@ export default function HelpModal({ onClose, helpActions = [] }) {
66
66
  },
67
67
  ...helpActions,
68
68
  ];
69
- return (_jsxs(AppModal, { title: t('modal.title'), close: onClose, hideFooter: true, className: "help-modal", children: [_jsxs("div", { className: "live-tour", children: [_jsx(AppPicture, { src: liveTour }), _jsxs("div", { className: "tour-content", 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: t('button.tour'), size: "small", icon: "keyboard_arrow_right", onClick: handleTourToggle, disabled: updatingLiveTour })] })] }), _jsx("div", { className: "other-actions", children: 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: "x-small", mode: "outlined", icon: "keyboard_arrow_right", onClick: () => handleCustomAction(item) })] }, idx))) })] }));
69
+ return (_jsxs(AppModal, { title: t('modal.title'), close: onClose, hideFooter: true, className: "help-modal", children: [_jsxs("div", { className: "live-tour", children: [_jsx(AppPicture, { src: liveTour }), _jsxs("div", { className: "tour-content", 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: t('button.tour'), size: "small", icon: "keyboard_arrow_right", onClick: handleTourToggle, disabled: updatingLiveTour, "data-tour": "guided-tour-start" })] })] }), _jsx("div", { className: "other-actions", children: 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: "x-small", mode: "outlined", icon: "keyboard_arrow_right", onClick: () => handleCustomAction(item) })] }, idx))) })] }));
70
70
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.23.8",
4
+ "version": "0.23.9",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {