@dialob/composer-material 0.0.16 → 0.0.18
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/README.md +35 -0
- package/dist-lib/index.d.ts +28 -8
- package/dist-lib/index.js +12401 -11904
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,6 +101,41 @@ pnpm run preview
|
|
|
101
101
|
|
|
102
102
|
Starts preview server for built application from `/dist` (No hot-reload!). Run `pnpm build` first to build the package
|
|
103
103
|
|
|
104
|
+
## AI Translation Feature
|
|
105
|
+
|
|
106
|
+
The composer includes an AI-powered translation feature that helps automate the translation of form content across multiple languages.
|
|
107
|
+
|
|
108
|
+
### Configuration
|
|
109
|
+
|
|
110
|
+
The AI translation feature needs `translationServiceUrl` to be set in `AppConfig` - it can come from the backend (`config.translationServiceUrl` configuration parameter) or be set manually in the app config (e.g. in `index.html`). This is the URL of the translation service API, including the path to the translation service endpoint.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
export const appConfig: AppConfig = {
|
|
114
|
+
...
|
|
115
|
+
translationServiceUrl: 'http://localhost:8083/api/translate',
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Key Features
|
|
120
|
+
|
|
121
|
+
- **Automated Translation**: Translate labels, descriptions, validation messages, and value set entries from one language to another using AI
|
|
122
|
+
- **Translation Tracking**: All AI-generated translations are tracked with metadata including:
|
|
123
|
+
- Source and target languages
|
|
124
|
+
- Translation timestamp
|
|
125
|
+
- Translation type (label, description, validation, etc.)
|
|
126
|
+
- **Visual Indicators**: AI-translated content is marked with a visual indicator in the translation editor
|
|
127
|
+
- **Manual Validation**: Users can review AI translations and remove the AI flag once validated
|
|
128
|
+
- **Bulk Operations**: Support for translating entire choice lists and multiple form elements at once
|
|
129
|
+
|
|
130
|
+
### Usage
|
|
131
|
+
|
|
132
|
+
The AI translation feature is available in multiple places in the composer, either for translating single items or in bulk:
|
|
133
|
+
- in the translation dialog (for translating entire form content)
|
|
134
|
+
- in the item options dialog (for translating single items)
|
|
135
|
+
- in the choice editor (for translating value set entries)
|
|
136
|
+
|
|
137
|
+
The source language is always the active form language. Translations can be validated by clicking the AI indicator.
|
|
138
|
+
|
|
104
139
|
### Item type configuration
|
|
105
140
|
|
|
106
141
|
Item type configuration defines the structure of the "Add Item" menu and available item types with their properties and behavior.
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { EditorState } from '..';
|
|
|
7
7
|
import { FunctionComponent } from '../../node_modules/@types/react';
|
|
8
8
|
import { IdField } from '../items/ItemComponents';
|
|
9
9
|
import { Indicators } from '../items/ItemComponents';
|
|
10
|
+
import { default as ItemOptionsDialog } from '../dialogs/ItemOptionsDialog';
|
|
10
11
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
11
12
|
import { LabelField } from '../items/ItemComponents';
|
|
12
13
|
import { LanguageEditor } from '../components/translations/LanguageEditor';
|
|
@@ -173,7 +174,7 @@ declare interface ConfigItemProps {
|
|
|
173
174
|
|
|
174
175
|
export declare const ConfirmationDialog: default_2.FC;
|
|
175
176
|
|
|
176
|
-
declare type ConfirmationDialogType = 'duplicate' | 'delete';
|
|
177
|
+
declare type ConfirmationDialogType = 'duplicate' | 'delete' | 'deleteVariable';
|
|
177
178
|
|
|
178
179
|
declare type ContextVariable = {
|
|
179
180
|
name: string;
|
|
@@ -281,6 +282,7 @@ declare type DialobItemTemplate = {
|
|
|
281
282
|
activeWhen?: string;
|
|
282
283
|
canAddRowWhen?: string;
|
|
283
284
|
canRemoveRowWhen?: string;
|
|
285
|
+
readOnlyWhen?: string;
|
|
284
286
|
items?: string[];
|
|
285
287
|
className?: string[];
|
|
286
288
|
props?: {
|
|
@@ -342,6 +344,8 @@ declare type ErrorSeverity = 'ERROR' | 'WARNING' | 'INFO' | 'FATAL';
|
|
|
342
344
|
|
|
343
345
|
declare namespace ErrorUtils {
|
|
344
346
|
export {
|
|
347
|
+
parseVariableItemId,
|
|
348
|
+
parseRowgroupIdFromVariableItemId,
|
|
345
349
|
getErrorSeverity,
|
|
346
350
|
getItemErrorColor,
|
|
347
351
|
useErrorColorSx,
|
|
@@ -364,6 +368,7 @@ declare interface FlattenedItem extends TreeItem {
|
|
|
364
368
|
depth: number;
|
|
365
369
|
index: number;
|
|
366
370
|
isFallbackLabel?: boolean;
|
|
371
|
+
isVariable?: boolean;
|
|
367
372
|
}
|
|
368
373
|
|
|
369
374
|
declare type FormMetadata = {
|
|
@@ -434,9 +439,9 @@ declare interface ItemConfigItem {
|
|
|
434
439
|
props: ConfigItemProps;
|
|
435
440
|
}
|
|
436
441
|
|
|
437
|
-
export declare const itemFactory: (item: DialobItem, itemConfig: ItemConfig, setHighlightedItem?: (item: DialobItem) => void, props?: any) => JSX_2.Element | null;
|
|
442
|
+
export declare const itemFactory: (item: DialobItem | string, itemConfig: ItemConfig, setHighlightedItem?: (item: DialobItem) => void, props?: any) => JSX_2.Element | null;
|
|
438
443
|
|
|
439
|
-
export
|
|
444
|
+
export { ItemOptionsDialog }
|
|
440
445
|
|
|
441
446
|
declare interface ItemProp {
|
|
442
447
|
key: string;
|
|
@@ -461,7 +466,7 @@ export { LabelField }
|
|
|
461
466
|
export { LanguageEditor }
|
|
462
467
|
|
|
463
468
|
declare type LocalizedString = {
|
|
464
|
-
[language: string]: string;
|
|
469
|
+
[language: string]: string | undefined;
|
|
465
470
|
};
|
|
466
471
|
|
|
467
472
|
export declare const LocalizedStringEditor: default_3.FC<{
|
|
@@ -493,6 +498,10 @@ export declare const PageTabs: default_2.FC<{
|
|
|
493
498
|
items: DialobItems;
|
|
494
499
|
}>;
|
|
495
500
|
|
|
501
|
+
declare const parseRowgroupIdFromVariableItemId: (itemId: string) => string | undefined;
|
|
502
|
+
|
|
503
|
+
declare const parseVariableItemId: (itemId: string) => string;
|
|
504
|
+
|
|
496
505
|
export declare const PreviewDialog: default_2.FC<{
|
|
497
506
|
open: boolean;
|
|
498
507
|
onClose: () => void;
|
|
@@ -549,7 +558,7 @@ export declare const RuleEditor: default_3.FC<{
|
|
|
549
558
|
|
|
550
559
|
export declare const RulesEditor: default_3.FC;
|
|
551
560
|
|
|
552
|
-
declare type RuleType = 'visibility' | 'requirement' | 'canaddrow' | 'canremoverow';
|
|
561
|
+
declare type RuleType = 'visibility' | 'requirement' | 'readOnly' | 'canaddrow' | 'canremoverow';
|
|
553
562
|
|
|
554
563
|
declare interface SaveResult {
|
|
555
564
|
ok: boolean;
|
|
@@ -564,6 +573,8 @@ declare interface SavingState {
|
|
|
564
573
|
composerMetadata?: ComposerMetadata;
|
|
565
574
|
variables?: (ContextVariable | Variable)[];
|
|
566
575
|
formMetadata?: FormMetadata;
|
|
576
|
+
items?: DialobItems;
|
|
577
|
+
pendingVariableRenames?: VariableRename[];
|
|
567
578
|
}
|
|
568
579
|
|
|
569
580
|
export declare const SimpleField: default_2.FC<{
|
|
@@ -630,6 +641,7 @@ declare interface TreeItem {
|
|
|
630
641
|
collapsible?: boolean;
|
|
631
642
|
collapsed?: boolean;
|
|
632
643
|
isFallbackLabel?: boolean;
|
|
644
|
+
isVariable?: boolean;
|
|
633
645
|
}
|
|
634
646
|
|
|
635
647
|
export declare const UploadValuesetDialog: default_2.FC<{
|
|
@@ -641,7 +653,7 @@ export declare const UploadValuesetDialog: default_2.FC<{
|
|
|
641
653
|
|
|
642
654
|
export declare const useComposer: () => {
|
|
643
655
|
addItem: (itemTemplate: DialobItemTemplate, parentItemId: string, afterItemId?: string, callbacks?: ComposerCallbacks) => void;
|
|
644
|
-
updateItem: (itemId: string, attribute: string, value:
|
|
656
|
+
updateItem: (itemId: string, attribute: string, value: any, language?: string) => void;
|
|
645
657
|
updateLocalizedString: (itemId: string, attribute: string, value: LocalizedString, index?: number) => void;
|
|
646
658
|
changeItemType: (itemId: string, config: DialobItemTemplate) => void;
|
|
647
659
|
deleteItem: (itemId: string) => void;
|
|
@@ -666,10 +678,11 @@ export declare const useComposer: () => {
|
|
|
666
678
|
setMetadataValue: (attr: string, value: any) => void;
|
|
667
679
|
setContextValue: (name: string, value: string) => void;
|
|
668
680
|
createVariable: (context: boolean) => void;
|
|
681
|
+
createScopedExpressionVariable: (rowgroupId: string, callbacks?: ComposerCallbacks) => void;
|
|
669
682
|
updateContextVariable: (variableId: string, contextType?: ContextVariableType | string, defaultValue?: any) => void;
|
|
670
683
|
updateExpressionVariable: (variableId: string, expression: string) => void;
|
|
671
684
|
updateVariablePublishing: (variableId: string, published: boolean) => void;
|
|
672
|
-
updateVariableDescription: (variableId: string, description: string) => void;
|
|
685
|
+
updateVariableDescription: (variableId: string, description: string | undefined) => void;
|
|
673
686
|
deleteVariable: (variableId: string) => void;
|
|
674
687
|
moveVariable: (origin: ContextVariable | Variable, destination: ContextVariable | Variable) => void;
|
|
675
688
|
addLanguage: (language: string, copyFrom?: string) => void;
|
|
@@ -679,6 +692,7 @@ export declare const useComposer: () => {
|
|
|
679
692
|
applyItemChanges: (newState: SavingState) => void;
|
|
680
693
|
applyListChanges: (newState: SavingState) => void;
|
|
681
694
|
applyVariableChanges: (newState: SavingState) => void;
|
|
695
|
+
applyVariableList: (variables: (ContextVariable | Variable)[]) => void;
|
|
682
696
|
applyFormChanges: (newState: SavingState) => void;
|
|
683
697
|
applyTranslations: (translations: TranslationResult[], sourceLanguage: string, targetLanguage: string) => void;
|
|
684
698
|
removeAITranslation: (entryId: string, targetLanguage: string) => void;
|
|
@@ -697,6 +711,7 @@ export declare const useEditor: () => {
|
|
|
697
711
|
setHighlightedItem: (item?: DialobItem) => void;
|
|
698
712
|
setActiveList: (listId?: string) => void;
|
|
699
713
|
setActiveVariableTab: (tab?: VariableTabType) => void;
|
|
714
|
+
setActiveVariable: (variableId?: string, idEditMode?: boolean) => void;
|
|
700
715
|
setConfirmationActiveItem: (item?: DialobItem) => void;
|
|
701
716
|
toggleItemCollapsed: (itemId: string) => void;
|
|
702
717
|
setMarkdownHelpDialogOpen: (open: boolean) => void;
|
|
@@ -734,7 +749,7 @@ declare interface ValueSetProp {
|
|
|
734
749
|
declare type Variable = {
|
|
735
750
|
name: string;
|
|
736
751
|
published?: boolean;
|
|
737
|
-
expression: string;
|
|
752
|
+
expression: string | undefined;
|
|
738
753
|
description?: string;
|
|
739
754
|
};
|
|
740
755
|
|
|
@@ -744,6 +759,11 @@ declare interface VariableProps {
|
|
|
744
759
|
onClose: () => void;
|
|
745
760
|
}
|
|
746
761
|
|
|
762
|
+
declare interface VariableRename {
|
|
763
|
+
from: string;
|
|
764
|
+
to: string;
|
|
765
|
+
}
|
|
766
|
+
|
|
747
767
|
export declare const VariablesDialog: default_2.FC<{
|
|
748
768
|
open: boolean;
|
|
749
769
|
onClose: () => void;
|