@dialob/composer-material 0.0.14 → 0.0.16
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 +126 -41
- package/dist-lib/index.d.ts +51 -6
- package/dist-lib/index.js +14805 -13510
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,21 +103,34 @@ Starts preview server for built application from `/dist` (No hot-reload!). Run `
|
|
|
103
103
|
|
|
104
104
|
### Item type configuration
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
Item type configuration defines the structure of the "Add Item" menu and available item types with their properties and behavior.
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
**See full example:** [`src/defaults/itemTypes.ts`](src/defaults/itemTypes.ts)
|
|
109
|
+
|
|
110
|
+
**TypeScript types:** [`src/defaults/types.ts`](src/defaults/types.ts)
|
|
111
|
+
|
|
112
|
+
#### Menu Structure
|
|
113
|
+
|
|
114
|
+
The configuration supports **flexible menu nesting** with three options:
|
|
115
|
+
|
|
116
|
+
1. **Flat structure** - Direct items in a category
|
|
117
|
+
2. **Nested structure** - Items organized in subcategories
|
|
118
|
+
3. **Mixed mode** - Both direct items AND subcategories in the same category
|
|
119
|
+
|
|
120
|
+
#### Basic Example
|
|
109
121
|
|
|
110
122
|
```typescript
|
|
111
|
-
DEFAULT_ITEMTYPE_CONFIG: ItemTypeConfig = {
|
|
112
|
-
|
|
123
|
+
export const DEFAULT_ITEMTYPE_CONFIG: ItemTypeConfig = {
|
|
124
|
+
categories: [
|
|
113
125
|
{
|
|
114
126
|
title: 'Structure',
|
|
115
127
|
type: 'structure',
|
|
116
128
|
items: [
|
|
117
129
|
{
|
|
118
130
|
title: 'Group',
|
|
131
|
+
convertible: ['rowgroup'],
|
|
119
132
|
optionEditors: [
|
|
120
|
-
{name: 'Additional option', editor: PropEditors.InputProp}
|
|
133
|
+
{ name: 'Additional option', editor: PropEditors.InputProp }
|
|
121
134
|
],
|
|
122
135
|
propEditors: {
|
|
123
136
|
columns: {
|
|
@@ -135,56 +148,128 @@ Item type configuration corresponds to "Add new" item creation menu structure an
|
|
|
135
148
|
columns: 1
|
|
136
149
|
}
|
|
137
150
|
}
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Nested Structure with Subcategories
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
{
|
|
162
|
+
title: 'Inputs',
|
|
163
|
+
type: 'input',
|
|
164
|
+
subcategories: [
|
|
165
|
+
{
|
|
166
|
+
title: 'Text fields',
|
|
167
|
+
items: [
|
|
168
|
+
{
|
|
169
|
+
title: 'Text',
|
|
170
|
+
convertible: ['textBox', 'address'],
|
|
171
|
+
config: {
|
|
172
|
+
type: 'text',
|
|
173
|
+
view: 'text'
|
|
174
|
+
}
|
|
138
175
|
},
|
|
139
176
|
{
|
|
140
|
-
title: '
|
|
141
|
-
convertible: ['
|
|
142
|
-
propEditors: {
|
|
143
|
-
display: {
|
|
144
|
-
component: PropEditors.ChoiceProp,
|
|
145
|
-
props: {
|
|
146
|
-
options: [
|
|
147
|
-
{key: 'dropdown', label: 'Dropdown'},
|
|
148
|
-
{key: 'button', label: 'Button'},
|
|
149
|
-
{key: 'checkbox', label: 'Checkbox'}
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
177
|
+
title: 'Text box',
|
|
178
|
+
convertible: ['text', 'address'],
|
|
154
179
|
config: {
|
|
155
|
-
type: '
|
|
156
|
-
|
|
157
|
-
display: 'dropdown',
|
|
158
|
-
}
|
|
180
|
+
type: 'text',
|
|
181
|
+
view: 'textBox'
|
|
159
182
|
}
|
|
160
183
|
}
|
|
161
184
|
]
|
|
162
185
|
},
|
|
163
|
-
|
|
186
|
+
{
|
|
187
|
+
title: 'Numbers',
|
|
188
|
+
items: [
|
|
189
|
+
{
|
|
190
|
+
title: 'Decimal',
|
|
191
|
+
config: { type: 'decimal' }
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
title: 'Integer',
|
|
195
|
+
config: { type: 'number' }
|
|
196
|
+
}
|
|
164
197
|
]
|
|
165
|
-
}
|
|
166
|
-
// ....
|
|
198
|
+
}
|
|
167
199
|
]
|
|
168
|
-
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
This creates a menu hierarchy:
|
|
204
|
+
```
|
|
205
|
+
Inputs →
|
|
206
|
+
├─ Text fields →
|
|
207
|
+
│ ├─ Text
|
|
208
|
+
│ └─ Text box
|
|
209
|
+
└─ Numbers →
|
|
210
|
+
├─ Decimal
|
|
211
|
+
└─ Integer
|
|
169
212
|
```
|
|
170
213
|
|
|
171
|
-
|
|
214
|
+
#### Mixed Mode (Direct Items + Subcategories)
|
|
215
|
+
|
|
216
|
+
You can combine both approaches in the same category:
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
{
|
|
220
|
+
title: 'Inputs',
|
|
221
|
+
type: 'input',
|
|
222
|
+
items: [
|
|
223
|
+
// Direct items (no submenu)
|
|
224
|
+
{ title: 'Boolean', config: { type: 'boolean' } },
|
|
225
|
+
{ title: 'Date', config: { type: 'date' } }
|
|
226
|
+
],
|
|
227
|
+
subcategories: [
|
|
228
|
+
// Nested items (with submenu)
|
|
229
|
+
{
|
|
230
|
+
title: 'Text fields',
|
|
231
|
+
items: [
|
|
232
|
+
{ title: 'Text', config: { type: 'text', view: 'text' } },
|
|
233
|
+
{ title: 'Text box', config: { type: 'text', view: 'textBox' } }
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Renders as:
|
|
241
|
+
```
|
|
242
|
+
Inputs →
|
|
243
|
+
├─ Boolean (clickable)
|
|
244
|
+
├─ Date (clickable)
|
|
245
|
+
├─── (separator) ───
|
|
246
|
+
└─ Text fields →
|
|
247
|
+
├─ Text
|
|
248
|
+
└─ Text box
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
#### Configuration Reference
|
|
252
|
+
|
|
253
|
+
**Category attributes:**
|
|
254
|
+
* **`title`** - Label displayed in the menu
|
|
255
|
+
* **`type`** - Category type: `'structure'`, `'input'`, or `'output'`. Used to filter which items can be added in different contexts
|
|
256
|
+
* **`items`** - (Optional) Array of item configurations for direct menu items
|
|
257
|
+
* **`subcategories`** - (Optional) Array of subcategory objects for nested menu structure
|
|
258
|
+
|
|
259
|
+
**Subcategory attributes:**
|
|
260
|
+
* **`title`** - Label displayed in the submenu
|
|
261
|
+
* **`items`** - Array of item configurations
|
|
172
262
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
* `optionEditors` (Optional) Array of additional pages for item options dialog. Array of objects: `{name: 'Title of page', editor: OptionEditorComponent}` (see below)
|
|
180
|
-
* `propEditors` (Optional) if custom property editors are configured for item. If prop editor is not defined, it will be fallen back to plain text. Editor configuration is set of objects having prop name as a key:
|
|
181
|
-
* `component` : React component to use for editing the prop
|
|
182
|
-
* `props` : (Optional) Additional properties for the editing component. (see below)
|
|
183
|
-
* `config` : Snippet of Dialob form item configuration (See Dialob Form API). Any predefined structure is supported. only mandatory attribute is `type`. Item's default ID will be based on `view` attribute falling back to `type`
|
|
263
|
+
**Item attributes:**
|
|
264
|
+
* **`title`** - Label displayed in the menu
|
|
265
|
+
* **`convertible`** - (Optional) Array of type identifiers this item can be converted to. Matched by `view` first, then `type`. If omitted, item cannot be converted
|
|
266
|
+
* **`optionEditors`** - (Optional) Additional option pages for the item dialog: `{name: 'Title', editor: Component}`
|
|
267
|
+
* **`propEditors`** - (Optional) Custom property editors (see below). If not defined, falls back to plain text input
|
|
268
|
+
* **`config`** - Dialob form item configuration snippet. Required field: `type`. The item's default ID is based on `view` (if present) or `type`
|
|
184
269
|
|
|
185
|
-
**Note
|
|
270
|
+
**Note:** `props` in the config are item-specific properties available at form filling time, not to be confused with React component props.
|
|
186
271
|
|
|
187
|
-
#### Prop
|
|
272
|
+
#### Prop Editor Configurations
|
|
188
273
|
|
|
189
274
|
Built in editors:
|
|
190
275
|
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { VisibilityField } from '../items/ItemComponents';
|
|
|
18
18
|
|
|
19
19
|
declare interface ApiResponse {
|
|
20
20
|
success: boolean;
|
|
21
|
-
result?: SaveResult | DuplicateResult | CreateTagResult | ChangeIdResult | CreateSessionResult;
|
|
21
|
+
result?: SaveResult | DuplicateResult | CreateTagResult | ChangeIdResult | CreateSessionResult | TranslationResponse;
|
|
22
22
|
apiError?: any;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -32,6 +32,7 @@ declare interface AppConfig {
|
|
|
32
32
|
tenantId: string;
|
|
33
33
|
credentialMode: RequestCredentials;
|
|
34
34
|
version: string;
|
|
35
|
+
translationServiceUrl?: string;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
declare interface BackendState {
|
|
@@ -47,6 +48,7 @@ declare interface BackendState {
|
|
|
47
48
|
getTags(formName: string): Promise<ComposerTag[]>;
|
|
48
49
|
changeItemId(form: ComposerState, oldId: string, newId: string): Promise<ApiResponse>;
|
|
49
50
|
createPreviewSession(formId: string, language: string, context?: PreviewSessionContext): Promise<ApiResponse>;
|
|
51
|
+
translateEntries(request: TranslationRequest): Promise<ApiResponse>;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
declare namespace BackendTypes {
|
|
@@ -63,6 +65,10 @@ declare namespace BackendTypes {
|
|
|
63
65
|
TransportConfig,
|
|
64
66
|
DialobComposerConfig,
|
|
65
67
|
AppConfig,
|
|
68
|
+
TranslationEntry,
|
|
69
|
+
TranslationRequest,
|
|
70
|
+
TranslationResult,
|
|
71
|
+
TranslationResponse,
|
|
66
72
|
BackendState
|
|
67
73
|
}
|
|
68
74
|
}
|
|
@@ -129,6 +135,7 @@ declare type ComposerMetadata = {
|
|
|
129
135
|
contextValues?: {
|
|
130
136
|
[name: string]: string;
|
|
131
137
|
};
|
|
138
|
+
aiTranslations?: TranslationMetadata[];
|
|
132
139
|
};
|
|
133
140
|
|
|
134
141
|
declare type ComposerState = {
|
|
@@ -227,6 +234,7 @@ declare namespace DefaultTypes {
|
|
|
227
234
|
ConfigItemProps,
|
|
228
235
|
ItemTypeConfig,
|
|
229
236
|
ItemTypeCategory,
|
|
237
|
+
Subcategory,
|
|
230
238
|
CategoryItem,
|
|
231
239
|
OptionEditor,
|
|
232
240
|
PropEditorsType
|
|
@@ -252,6 +260,7 @@ declare interface DialobComposerConfig {
|
|
|
252
260
|
itemTypes: ItemTypeConfig;
|
|
253
261
|
backendVersion: string;
|
|
254
262
|
closeHandler: () => void;
|
|
263
|
+
translationServiceUrl?: string;
|
|
255
264
|
}
|
|
256
265
|
|
|
257
266
|
declare type DialobItem = DialobItemTemplate & {
|
|
@@ -299,6 +308,7 @@ declare namespace DialobTypes {
|
|
|
299
308
|
DialobItems,
|
|
300
309
|
VisibilityType,
|
|
301
310
|
ComposerTag,
|
|
311
|
+
TranslationMetadata,
|
|
302
312
|
ComposerMetadata,
|
|
303
313
|
ComposerState,
|
|
304
314
|
FormMetadata,
|
|
@@ -353,6 +363,7 @@ declare interface FlattenedItem extends TreeItem {
|
|
|
353
363
|
parentId: UniqueIdentifier | null;
|
|
354
364
|
depth: number;
|
|
355
365
|
index: number;
|
|
366
|
+
isFallbackLabel?: boolean;
|
|
356
367
|
}
|
|
357
368
|
|
|
358
369
|
declare type FormMetadata = {
|
|
@@ -391,10 +402,7 @@ export declare const GlobalList: default_2.FC<{
|
|
|
391
402
|
entries?: ValueSetEntry[];
|
|
392
403
|
}>;
|
|
393
404
|
|
|
394
|
-
export declare const GlobalListsDialog: default_2.FC
|
|
395
|
-
open: boolean;
|
|
396
|
-
onClose: () => void;
|
|
397
|
-
}>;
|
|
405
|
+
export declare const GlobalListsDialog: default_2.FC;
|
|
398
406
|
|
|
399
407
|
export declare const Group: default_2.FC<{
|
|
400
408
|
item: DialobItem;
|
|
@@ -438,7 +446,8 @@ declare interface ItemProp {
|
|
|
438
446
|
declare interface ItemTypeCategory {
|
|
439
447
|
title: string;
|
|
440
448
|
type: DialobCategoryType;
|
|
441
|
-
items
|
|
449
|
+
items?: CategoryItem[];
|
|
450
|
+
subcategories?: Subcategory[];
|
|
442
451
|
}
|
|
443
452
|
|
|
444
453
|
declare interface ItemTypeConfig {
|
|
@@ -563,13 +572,46 @@ export declare const SimpleField: default_2.FC<{
|
|
|
563
572
|
|
|
564
573
|
export { StyledTable }
|
|
565
574
|
|
|
575
|
+
declare interface Subcategory {
|
|
576
|
+
title: string;
|
|
577
|
+
items: CategoryItem[];
|
|
578
|
+
}
|
|
579
|
+
|
|
566
580
|
export declare const TranslationDialog: default_2.FC<{
|
|
567
581
|
open: boolean;
|
|
568
582
|
onClose: () => void;
|
|
569
583
|
}>;
|
|
570
584
|
|
|
585
|
+
declare interface TranslationEntry {
|
|
586
|
+
id: string;
|
|
587
|
+
text: string;
|
|
588
|
+
}
|
|
589
|
+
|
|
571
590
|
export declare const TranslationFileEditor: default_3.FC;
|
|
572
591
|
|
|
592
|
+
declare type TranslationMetadata = {
|
|
593
|
+
entryId: string;
|
|
594
|
+
sourceLanguage: string;
|
|
595
|
+
targetLanguage: string;
|
|
596
|
+
timestamp: string;
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
declare interface TranslationRequest {
|
|
600
|
+
sourceLanguage: string;
|
|
601
|
+
targetLanguage: string;
|
|
602
|
+
entries: TranslationEntry[];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
declare interface TranslationResponse {
|
|
606
|
+
translations: TranslationResult[];
|
|
607
|
+
targetLanguage: string;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
declare interface TranslationResult {
|
|
611
|
+
id: string;
|
|
612
|
+
translatedText: string;
|
|
613
|
+
}
|
|
614
|
+
|
|
573
615
|
declare interface TransportConfig {
|
|
574
616
|
csrf?: {
|
|
575
617
|
headerName: string;
|
|
@@ -587,6 +629,7 @@ declare interface TreeItem {
|
|
|
587
629
|
title: string;
|
|
588
630
|
collapsible?: boolean;
|
|
589
631
|
collapsed?: boolean;
|
|
632
|
+
isFallbackLabel?: boolean;
|
|
590
633
|
}
|
|
591
634
|
|
|
592
635
|
export declare const UploadValuesetDialog: default_2.FC<{
|
|
@@ -637,6 +680,8 @@ export declare const useComposer: () => {
|
|
|
637
680
|
applyListChanges: (newState: SavingState) => void;
|
|
638
681
|
applyVariableChanges: (newState: SavingState) => void;
|
|
639
682
|
applyFormChanges: (newState: SavingState) => void;
|
|
683
|
+
applyTranslations: (translations: TranslationResult[], sourceLanguage: string, targetLanguage: string) => void;
|
|
684
|
+
removeAITranslation: (entryId: string, targetLanguage: string) => void;
|
|
640
685
|
form: ComposerState;
|
|
641
686
|
};
|
|
642
687
|
|