@dialob/composer-material 0.0.13 → 0.0.15
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 +257 -0
- package/dist-lib/index.d.ts +10 -1
- package/dist-lib/index.js +13922 -12874
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -101,6 +101,263 @@ 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
|
+
### Item type configuration
|
|
105
|
+
|
|
106
|
+
Item type configuration defines the structure of the "Add Item" menu and available item types with their properties and behavior.
|
|
107
|
+
|
|
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
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
export const DEFAULT_ITEMTYPE_CONFIG: ItemTypeConfig = {
|
|
124
|
+
categories: [
|
|
125
|
+
{
|
|
126
|
+
title: 'Structure',
|
|
127
|
+
type: 'structure',
|
|
128
|
+
items: [
|
|
129
|
+
{
|
|
130
|
+
title: 'Group',
|
|
131
|
+
convertible: ['rowgroup'],
|
|
132
|
+
optionEditors: [
|
|
133
|
+
{ name: 'Additional option', editor: PropEditors.InputProp }
|
|
134
|
+
],
|
|
135
|
+
propEditors: {
|
|
136
|
+
columns: {
|
|
137
|
+
component: PropEditors.InputProp,
|
|
138
|
+
props: {
|
|
139
|
+
type: 'number',
|
|
140
|
+
min: 1,
|
|
141
|
+
max: 20
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
config: {
|
|
146
|
+
type: 'group',
|
|
147
|
+
props: {
|
|
148
|
+
columns: 1
|
|
149
|
+
}
|
|
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
|
+
}
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
title: 'Text box',
|
|
178
|
+
convertible: ['text', 'address'],
|
|
179
|
+
config: {
|
|
180
|
+
type: 'text',
|
|
181
|
+
view: 'textBox'
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
title: 'Numbers',
|
|
188
|
+
items: [
|
|
189
|
+
{
|
|
190
|
+
title: 'Decimal',
|
|
191
|
+
config: { type: 'decimal' }
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
title: 'Integer',
|
|
195
|
+
config: { type: 'number' }
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
]
|
|
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
|
|
212
|
+
```
|
|
213
|
+
|
|
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
|
|
262
|
+
|
|
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`
|
|
269
|
+
|
|
270
|
+
**Note:** `props` in the config are item-specific properties available at form filling time, not to be confused with React component props.
|
|
271
|
+
|
|
272
|
+
#### Prop Editor Configurations
|
|
273
|
+
|
|
274
|
+
Built in editors:
|
|
275
|
+
|
|
276
|
+
* `PropEditors.InputProp` - Plain input component, supports HTML `<input>` attributes as props for defining input type etc.
|
|
277
|
+
|
|
278
|
+
* `PropEditors.ChoiceProp` - Dropdown selection list, `options` prop having an array of `{key: '', label: ''},` entries, where `key` is value stored in prop and `label` is text displayed in UI.
|
|
279
|
+
|
|
280
|
+
* `PropEditors.BoolProp` - Boolean switch.
|
|
281
|
+
|
|
282
|
+
* `PropEditors.MultiChoiceProp` - Dropdown selection list, allows multiple selections (Array of string value). `options` prop as in `ChoiceProp`, `allowAdditions` true/false -- Allow adding arbitrary strings to list.
|
|
283
|
+
|
|
284
|
+
Custom editing component template
|
|
285
|
+
```typescript
|
|
286
|
+
const CustomProp = ({ onChange, value, name, item, ...props }) => {
|
|
287
|
+
// onChange(value) - callback function for setting the prop's value
|
|
288
|
+
// value - current value of the prop
|
|
289
|
+
// name - prop name
|
|
290
|
+
// item - item data for current item. (Immutable.Map)
|
|
291
|
+
// props - additional editor component props passed on from configuration
|
|
292
|
+
|
|
293
|
+
// Return react component here that renders UI for prop editor
|
|
294
|
+
return (<Input onChange={(e) => onChange(e.target.value)} value={value || ''} {...props} />);
|
|
295
|
+
};
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
### Item editor configuration
|
|
300
|
+
|
|
301
|
+
For example: `src/defaults/itemConfig.js`
|
|
302
|
+
|
|
303
|
+
Item editor configuration defines which kind of item editing components are used in which conditions.
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
export const DEFAULT_ITEM_CONFIG: ItemConfig = {
|
|
307
|
+
defaultIcon: Circle,
|
|
308
|
+
items: [
|
|
309
|
+
{
|
|
310
|
+
matcher: item => item.type === 'group',
|
|
311
|
+
component: Group,
|
|
312
|
+
props: {
|
|
313
|
+
icon: CropSquare,
|
|
314
|
+
placeholder: 'placeholders.group',
|
|
315
|
+
treeCollapsible: true,
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
...
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Where:
|
|
324
|
+
|
|
325
|
+
- **mathcer** Function that receives item data and returns true if this configuration is applied to the item
|
|
326
|
+
- **component** React component used for rendering the item in the form editor
|
|
327
|
+
- **props** Additional properties passed to the component
|
|
328
|
+
- **icon** MUI Icon component used for representing the item in tree view
|
|
329
|
+
- **placeholder** Placeholder text identifier shown when item has no title
|
|
330
|
+
- **treeCollapsible** (Group items only) true/false - Allow collapsing/expanding the group in tree view
|
|
331
|
+
|
|
332
|
+
### Valueset property configuration
|
|
333
|
+
|
|
334
|
+
This is for controlling additional metadata properties for value set entries that are stored with form data, but *not communicated to filling side*.
|
|
335
|
+
|
|
336
|
+
For example: `src/defaults/valueSetProps.js`
|
|
337
|
+
|
|
338
|
+
```javascript
|
|
339
|
+
export const DEFAULT_VALUESET_PROPS: ValueSetProp[] = [
|
|
340
|
+
{
|
|
341
|
+
title: 'Custom attribute',
|
|
342
|
+
name: 'attr',
|
|
343
|
+
editor: Box,
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
* `title` Title shown in table column header
|
|
349
|
+
* `attr` attribute name
|
|
350
|
+
* `editor` React component for editing the value
|
|
351
|
+
|
|
352
|
+
Valueset entry metadata prop editor React component template
|
|
353
|
+
```javascript
|
|
354
|
+
const CustomValueSetProp = ({ onChange, value }) => {
|
|
355
|
+
// onChange(value) - callback function for setting the prop's value
|
|
356
|
+
// value - current value of the prop
|
|
357
|
+
|
|
358
|
+
// Return react component here that renders UI for prop editor
|
|
359
|
+
};
|
|
360
|
+
```
|
|
104
361
|
---
|
|
105
362
|
|
|
106
363
|
### Customixing Markdown components
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -227,6 +227,7 @@ declare namespace DefaultTypes {
|
|
|
227
227
|
ConfigItemProps,
|
|
228
228
|
ItemTypeConfig,
|
|
229
229
|
ItemTypeCategory,
|
|
230
|
+
Subcategory,
|
|
230
231
|
CategoryItem,
|
|
231
232
|
OptionEditor,
|
|
232
233
|
PropEditorsType
|
|
@@ -353,6 +354,7 @@ declare interface FlattenedItem extends TreeItem {
|
|
|
353
354
|
parentId: UniqueIdentifier | null;
|
|
354
355
|
depth: number;
|
|
355
356
|
index: number;
|
|
357
|
+
isFallbackLabel?: boolean;
|
|
356
358
|
}
|
|
357
359
|
|
|
358
360
|
declare type FormMetadata = {
|
|
@@ -438,7 +440,8 @@ declare interface ItemProp {
|
|
|
438
440
|
declare interface ItemTypeCategory {
|
|
439
441
|
title: string;
|
|
440
442
|
type: DialobCategoryType;
|
|
441
|
-
items
|
|
443
|
+
items?: CategoryItem[];
|
|
444
|
+
subcategories?: Subcategory[];
|
|
442
445
|
}
|
|
443
446
|
|
|
444
447
|
declare interface ItemTypeConfig {
|
|
@@ -563,6 +566,11 @@ export declare const SimpleField: default_2.FC<{
|
|
|
563
566
|
|
|
564
567
|
export { StyledTable }
|
|
565
568
|
|
|
569
|
+
declare interface Subcategory {
|
|
570
|
+
title: string;
|
|
571
|
+
items: CategoryItem[];
|
|
572
|
+
}
|
|
573
|
+
|
|
566
574
|
export declare const TranslationDialog: default_2.FC<{
|
|
567
575
|
open: boolean;
|
|
568
576
|
onClose: () => void;
|
|
@@ -587,6 +595,7 @@ declare interface TreeItem {
|
|
|
587
595
|
title: string;
|
|
588
596
|
collapsible?: boolean;
|
|
589
597
|
collapsed?: boolean;
|
|
598
|
+
isFallbackLabel?: boolean;
|
|
590
599
|
}
|
|
591
600
|
|
|
592
601
|
export declare const UploadValuesetDialog: default_2.FC<{
|