@jsonforms/angular-material 3.9.0-alpha.0 → 3.9.0-alpha.2
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/lib/fesm2022/jsonforms-angular-material.mjs +236 -122
- package/lib/fesm2022/jsonforms-angular-material.mjs.map +1 -1
- package/lib/index.d.ts +18 -1
- package/lib/index.d.ts.map +1 -1
- package/package.json +20 -23
- package/src/library/layouts/array-layout.renderer.ts +49 -25
- package/src/library/other/master-detail/master.ts +9 -14
- package/src/library/other/object.renderer.ts +39 -25
- package/src/library/util/deps.ts +34 -0
- package/src/library/util/detail-uischema.ts +81 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RankedTester, StatePropsOfControl, JsonFormsState, Layout, OwnPropsOfRenderer, JsonSchema, VerticalLayout, HorizontalLayout, Categorization, Category, GroupLayout, LabelElement, ArrayTranslations, ArrayControlProps, StatePropsOfArrayControl,
|
|
1
|
+
import { RankedTester, StatePropsOfControl, JsonFormsState, Layout, OwnPropsOfRenderer, JsonSchema, VerticalLayout, HorizontalLayout, Categorization, Category, GroupLayout, LabelElement, ArrayTranslations, UISchemaElement, ArrayControlProps, StatePropsOfArrayControl, ControlWithDetailProps, EnumOption, OwnPropsOfEnum, OwnPropsOfControl, ControlElement, StatePropsOfArrayLayout, UISchemaTester, ArrayLayoutProps } from '@jsonforms/core';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { OnInit, ChangeDetectorRef, PipeTransform } from '@angular/core';
|
|
4
4
|
import * as i2 from '@jsonforms/angular';
|
|
@@ -206,6 +206,8 @@ declare class MasterListComponent extends JsonFormsArrayControl implements OnIni
|
|
|
206
206
|
removeItems: (path: string, toDelete: number[]) => () => void;
|
|
207
207
|
highlightedIdx: number;
|
|
208
208
|
translations: ArrayTranslations;
|
|
209
|
+
detailUiSchema: UISchemaElement;
|
|
210
|
+
private resolveDetailUiSchema;
|
|
209
211
|
private changeDetectorRef;
|
|
210
212
|
onListItemHover(idx: number): void;
|
|
211
213
|
trackElement(_index: number, element: any): any;
|
|
@@ -235,6 +237,10 @@ declare class JsonFormsDetailComponent {
|
|
|
235
237
|
|
|
236
238
|
declare class ObjectControlRenderer extends JsonFormsControlWithDetail {
|
|
237
239
|
detailUiSchema: UISchemaElement;
|
|
240
|
+
/** Bound as a whole, as the outlet only re-dispatches when this is set. */
|
|
241
|
+
renderProps: OwnPropsOfRenderer;
|
|
242
|
+
private resolveDetailUiSchema;
|
|
243
|
+
private changeDetectorRef;
|
|
238
244
|
mapAdditionalProps(props: ControlWithDetailProps): void;
|
|
239
245
|
static ɵfac: i0.ɵɵFactoryDeclaration<ObjectControlRenderer, never>;
|
|
240
246
|
static ɵcmp: i0.ɵɵComponentDeclaration<ObjectControlRenderer, "ObjectRenderer", never, {}, {}, never, never, true, never>;
|
|
@@ -322,6 +328,12 @@ declare class ArrayLayoutRenderer extends JsonFormsAbstractControl<StatePropsOfA
|
|
|
322
328
|
tester: UISchemaTester;
|
|
323
329
|
uischema: UISchemaElement;
|
|
324
330
|
}[];
|
|
331
|
+
detailUiSchema: UISchemaElement;
|
|
332
|
+
/** Also determines how many items are rendered. */
|
|
333
|
+
itemProps: OwnPropsOfRenderer[];
|
|
334
|
+
private resolveDetailUiSchema;
|
|
335
|
+
private itemPropsDeps;
|
|
336
|
+
private changeDetectorRef;
|
|
325
337
|
mapToProps(state: JsonFormsState): StatePropsOfArrayLayout & {
|
|
326
338
|
translations: ArrayTranslations;
|
|
327
339
|
};
|
|
@@ -333,6 +345,11 @@ declare class ArrayLayoutRenderer extends JsonFormsAbstractControl<StatePropsOfA
|
|
|
333
345
|
mapAdditionalProps(props: ArrayLayoutProps & {
|
|
334
346
|
translations: ArrayTranslations;
|
|
335
347
|
}): void;
|
|
348
|
+
/**
|
|
349
|
+
* Not created in the template: each new object makes the outlet deep clone
|
|
350
|
+
* the whole form state.
|
|
351
|
+
*/
|
|
352
|
+
private updateItemProps;
|
|
336
353
|
getProps(index: number): OwnPropsOfRenderer;
|
|
337
354
|
trackByFn(index: number): number;
|
|
338
355
|
static ɵfac: i0.ɵɵFactoryDeclaration<ArrayLayoutRenderer, never>;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../src/library/controls/boolean.renderer.ts","../src/library/controls/textarea.renderer.ts","../src/library/controls/text.renderer.ts","../src/library/controls/number.renderer.ts","../src/library/controls/range.renderer.ts","../src/library/util/dayjs-date-adapter.ts","../src/library/controls/date.renderer.ts","../src/library/controls/toggle.renderer.ts","../src/library/layouts/layout.renderer.ts","../src/library/layouts/vertical-layout.renderer.ts","../src/library/layouts/horizontal-layout.renderer.ts","../src/library/layouts/categorization-layout.renderer.ts","../src/library/layouts/group-layout.renderer.ts","../src/library/other/label.renderer.ts","../src/library/other/master-detail/master.ts","../src/library/other/master-detail/detail.ts","../src/library/other/object.renderer.ts","../src/library/controls/enum.renderer.ts","../src/library/other/table.renderer.ts","../src/library/layouts/array-layout.renderer.ts","../src/library/module.ts","../src/library/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,cAAA,sBAoCa,yBAA+B;;AAE1C;;;yCAFW,sBAAsB;2CAAtB,sBAAsB;AAUlC;AAED,cAAA,oBAAa,EAAA,YAAsB;;ACrDnC,cAAA,gBAsCa,yBAAyB;AACpC;;yCADW,gBAAgB;2CAAhB,gBAAgB;AAG5B;AACD,cAAA,sBAAa,EAAA,YAAwB;;AC1CrC,cAAA,mBAuCa,yBAA4B;AACvC;;;yCADW,mBAAmB;2CAAnB,mBAAmB;AAmB/B;AACD,cAAA,yBAAa,EAAA,YAA2B;;ACnDxC,cAAA,qBA0Ca,yBAA8B;AACzC;;;;;;AAOA,kBAAc,IAAI,CAAC,YAAY;;AAE/B;;;AA8CA;8BAU0B,mBAAmB;AAmC7C;yCArGW,qBAAqB;2CAArB,qBAAqB;AAy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BAAoB,QAAQ,GAAG,cAAc;;;;yCALlC,+BAA+B;2CAA/B,+BAA+B;AAqC3C;AAED,cAAA,oBAAa,EAAA,YAAsB;;AC9EnC,cAAA,mBAwCa,SAAoB,cAAQ,CAAA;yCAA5B,mBAAmB;2CAAnB,mBAAmB;AAAuC;AACvE,cAAA,iBAAa,EAAA,YAAmB;;ACpChC,cAAA,sBAYE,qBAAQ,CAAA,YAAsB;;;;;yCADnB,aAAa;2CAAb,aAAa;AAsBzB;AAED,cAAA,mBAAa,EAAA,YAAqB;;ACXlC,cAAA,oBAAa;AASb,cAAA,mBAsGa,SACX,qBAAQ,YACR,MAAA;;;;AAKA;AACA;;kBAEc,iBAAiB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/library/controls/boolean.renderer.ts","../src/library/controls/textarea.renderer.ts","../src/library/controls/text.renderer.ts","../src/library/controls/number.renderer.ts","../src/library/controls/range.renderer.ts","../src/library/util/dayjs-date-adapter.ts","../src/library/controls/date.renderer.ts","../src/library/controls/toggle.renderer.ts","../src/library/layouts/layout.renderer.ts","../src/library/layouts/vertical-layout.renderer.ts","../src/library/layouts/horizontal-layout.renderer.ts","../src/library/layouts/categorization-layout.renderer.ts","../src/library/layouts/group-layout.renderer.ts","../src/library/other/label.renderer.ts","../src/library/other/master-detail/master.ts","../src/library/other/master-detail/detail.ts","../src/library/other/object.renderer.ts","../src/library/controls/enum.renderer.ts","../src/library/other/table.renderer.ts","../src/library/layouts/array-layout.renderer.ts","../src/library/module.ts","../src/library/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,cAAA,sBAoCa,yBAA+B;;AAE1C;;;yCAFW,sBAAsB;2CAAtB,sBAAsB;AAUlC;AAED,cAAA,oBAAa,EAAA,YAAsB;;ACrDnC,cAAA,gBAsCa,yBAAyB;AACpC;;yCADW,gBAAgB;2CAAhB,gBAAgB;AAG5B;AACD,cAAA,sBAAa,EAAA,YAAwB;;AC1CrC,cAAA,mBA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A,GAAA,CAAA,aAAA,SAAA,GAAA,CAAA,mBAAA,SAAA,GAAA,CAAA,aAAA,SAAA,GAAA,CAAA,eAAA,SAAA,GAAA,CAAA,eAAA,SAAA,GAAA,CAAA,aAAA,SAAA,GAAA,CAAA,qBAAA,SAAApB,sBAAA,SAAAC,gBAAA,SAAAC,mBAAA,SAAAC,qBAAA,SAAAC,oBAAA,SAAAC,mBAAA,SAAAC,qBAAA,SAAAC,sBAAA,SAAAC,wBAAA,SAAAC,+BAAA,SAAAC,mBAAA,SAAAC,aAAA,SAAAC,mBAAA,SAAAC,wBAAA,SAAAC,qBAAA,SAAAC,mBAAA,SAAAC,wBAAA,SAAAC,aAAA,SAAAC,mBAAA,SAAAC,6BAAA,SAAAC,QAAA;0CAA9B,8BAA8B;AAAG;;AC/D9C,cAAA;YACU,YAAY;;AAErB;;;;","names":["i23.BooleanControlRenderer","i24.TextAreaRenderer","i25.TextControlRenderer","i26.NumberControlRenderer","i27.RangeControlRenderer","i28.DateControlRenderer","i29.ToggleControlRenderer","i30.VerticalLayoutRenderer","i31.HorizontalLayoutRenderer","i32.CategorizationTabLayoutRenderer","i33.GroupLayoutRenderer","i34.LabelRenderer","i35.MasterListComponent","i36.JsonFormsDetailComponent","i37.ObjectControlRenderer","i38.EnumControlRenderer","i38.OneOfEnumControlRenderer","i39.TableRenderer","i40.ArrayLayoutRenderer","i41.LayoutChildrenRenderPropsPipe","i39.GetProps"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonforms/angular-material",
|
|
3
|
-
"version": "3.9.0-alpha.
|
|
3
|
+
"version": "3.9.0-alpha.2",
|
|
4
4
|
"description": "Material Renderer Set for Angular module of JSON Forms",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
"@angular/material": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
56
56
|
"@angular/platform-browser": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
57
57
|
"@angular/router": "^20.0.0 || ^21.0.0 || ^22.0.0",
|
|
58
|
-
"@jsonforms/angular": "3.9.0-alpha.
|
|
59
|
-
"@jsonforms/core": "3.9.0-alpha.
|
|
58
|
+
"@jsonforms/angular": "3.9.0-alpha.2",
|
|
59
|
+
"@jsonforms/core": "3.9.0-alpha.2",
|
|
60
60
|
"dayjs": "^1.11.10",
|
|
61
61
|
"rxjs": "^6.6.0 || ^7.4.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"lodash": "^4.
|
|
64
|
+
"lodash": "^4.18.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@angular-devkit/build-angular": "^20.0.0",
|
|
@@ -70,29 +70,29 @@
|
|
|
70
70
|
"@angular-eslint/eslint-plugin-template": "^20.7.0",
|
|
71
71
|
"@angular-eslint/schematics": "^20.7.0",
|
|
72
72
|
"@angular-eslint/template-parser": "^20.7.0",
|
|
73
|
-
"@angular/animations": "^20.3.
|
|
73
|
+
"@angular/animations": "^20.3.33",
|
|
74
74
|
"@angular/cdk": "^20.2.14",
|
|
75
|
-
"@angular/cli": "^20.3.
|
|
76
|
-
"@angular/common": "^20.3.
|
|
77
|
-
"@angular/compiler": "^20.3.
|
|
78
|
-
"@angular/compiler-cli": "^20.3.
|
|
79
|
-
"@angular/core": "^20.3.
|
|
80
|
-
"@angular/forms": "^20.3.
|
|
75
|
+
"@angular/cli": "^20.3.38",
|
|
76
|
+
"@angular/common": "^20.3.33",
|
|
77
|
+
"@angular/compiler": "^20.3.33",
|
|
78
|
+
"@angular/compiler-cli": "^20.3.33",
|
|
79
|
+
"@angular/core": "^20.3.33",
|
|
80
|
+
"@angular/forms": "^20.3.33",
|
|
81
81
|
"@angular/material": "^20.2.14",
|
|
82
|
-
"@angular/platform-browser": "^20.3.
|
|
83
|
-
"@angular/platform-browser-dynamic": "^20.3.
|
|
84
|
-
"@angular/router": "^20.3.
|
|
85
|
-
"@
|
|
86
|
-
"@
|
|
82
|
+
"@angular/platform-browser": "^20.3.33",
|
|
83
|
+
"@angular/platform-browser-dynamic": "^20.3.33",
|
|
84
|
+
"@angular/router": "^20.3.33",
|
|
85
|
+
"@jsonforms/angular": "3.9.0-alpha.2",
|
|
86
|
+
"@jsonforms/core": "3.9.0-alpha.2",
|
|
87
|
+
"@jsonforms/examples": "3.9.0-alpha.2",
|
|
87
88
|
"@ngtools/webpack": "^20.0.0",
|
|
88
89
|
"@types/jasmine": "~3.8.0",
|
|
89
90
|
"@types/lodash": "4.14.149",
|
|
90
91
|
"@types/node": "^24.12.2",
|
|
91
92
|
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
92
93
|
"@typescript-eslint/parser": "^5.54.1",
|
|
93
|
-
"babel-loader": "^8.0.6",
|
|
94
94
|
"copy-webpack-plugin": "^11.0.0",
|
|
95
|
-
"dayjs": "^1.11.
|
|
95
|
+
"dayjs": "^1.11.11",
|
|
96
96
|
"eslint": "^8.56.0",
|
|
97
97
|
"eslint-config-prettier": "^8.7.0",
|
|
98
98
|
"eslint-plugin-import": "^2.27.5",
|
|
@@ -114,17 +114,14 @@
|
|
|
114
114
|
"prettier": "^2.8.4",
|
|
115
115
|
"protractor": "^7.0.0",
|
|
116
116
|
"rimraf": "^6.1.0",
|
|
117
|
-
"rxjs": "^6.6.
|
|
117
|
+
"rxjs": "^6.6.7",
|
|
118
118
|
"ts-loader": "^9.5.1",
|
|
119
119
|
"tslib": "^2.5.0",
|
|
120
120
|
"typedoc": "~0.25.3",
|
|
121
121
|
"typescript": "~5.8.3",
|
|
122
122
|
"webpack": "^5.78.0",
|
|
123
123
|
"yargs": "^17.7.2",
|
|
124
|
-
"zone.js": "~0.15.0"
|
|
125
|
-
"@jsonforms/angular": "3.9.0-alpha.0",
|
|
126
|
-
"@jsonforms/core": "3.9.0-alpha.0",
|
|
127
|
-
"@jsonforms/examples": "3.9.0-alpha.0"
|
|
124
|
+
"zone.js": "~0.15.0"
|
|
128
125
|
},
|
|
129
126
|
"scripts": {
|
|
130
127
|
"build": "ng build",
|
|
@@ -22,7 +22,13 @@
|
|
|
22
22
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
ChangeDetectionStrategy,
|
|
27
|
+
ChangeDetectorRef,
|
|
28
|
+
Component,
|
|
29
|
+
inject,
|
|
30
|
+
OnInit,
|
|
31
|
+
} from '@angular/core';
|
|
26
32
|
import { CommonModule } from '@angular/common';
|
|
27
33
|
import { MatCardModule } from '@angular/material/card';
|
|
28
34
|
import { MatButtonModule } from '@angular/material/button';
|
|
@@ -36,7 +42,6 @@ import {
|
|
|
36
42
|
ArrayTranslations,
|
|
37
43
|
createDefaultValue,
|
|
38
44
|
defaultJsonFormsI18nState,
|
|
39
|
-
findUISchema,
|
|
40
45
|
getArrayTranslations,
|
|
41
46
|
isObjectArrayWithNesting,
|
|
42
47
|
JsonFormsState,
|
|
@@ -46,12 +51,12 @@ import {
|
|
|
46
51
|
Paths,
|
|
47
52
|
RankedTester,
|
|
48
53
|
rankWith,
|
|
49
|
-
setReadonly,
|
|
50
54
|
StatePropsOfArrayLayout,
|
|
51
55
|
UISchemaElement,
|
|
52
56
|
UISchemaTester,
|
|
53
|
-
unsetReadonly,
|
|
54
57
|
} from '@jsonforms/core';
|
|
58
|
+
import { depsChanged } from '../util/deps';
|
|
59
|
+
import { createDetailUiSchemaResolver } from '../util/detail-uischema';
|
|
55
60
|
|
|
56
61
|
@Component({
|
|
57
62
|
selector: 'app-array-layout-renderer',
|
|
@@ -84,7 +89,7 @@ import {
|
|
|
84
89
|
<p *ngIf="noData">{{ translations.noDataMessage }}</p>
|
|
85
90
|
<div
|
|
86
91
|
*ngFor="
|
|
87
|
-
let item of
|
|
92
|
+
let item of itemProps;
|
|
88
93
|
let idx = index;
|
|
89
94
|
trackBy: trackByFn;
|
|
90
95
|
last as last;
|
|
@@ -93,7 +98,7 @@ import {
|
|
|
93
98
|
>
|
|
94
99
|
<mat-card class="array-item" appearance="outlined">
|
|
95
100
|
<mat-card-content>
|
|
96
|
-
<jsonforms-outlet [renderProps]="
|
|
101
|
+
<jsonforms-outlet [renderProps]="item"></jsonforms-outlet>
|
|
97
102
|
</mat-card-content>
|
|
98
103
|
<mat-card-actions *ngIf="isEnabled()">
|
|
99
104
|
<button
|
|
@@ -188,6 +193,12 @@ export class ArrayLayoutRenderer
|
|
|
188
193
|
tester: UISchemaTester;
|
|
189
194
|
uischema: UISchemaElement;
|
|
190
195
|
}[];
|
|
196
|
+
detailUiSchema: UISchemaElement;
|
|
197
|
+
/** Also determines how many items are rendered. */
|
|
198
|
+
itemProps: OwnPropsOfRenderer[] = [];
|
|
199
|
+
private resolveDetailUiSchema = createDetailUiSchemaResolver();
|
|
200
|
+
private itemPropsDeps: unknown[] | undefined;
|
|
201
|
+
private changeDetectorRef = inject(ChangeDetectorRef);
|
|
191
202
|
mapToProps(
|
|
192
203
|
state: JsonFormsState
|
|
193
204
|
): StatePropsOfArrayLayout & { translations: ArrayTranslations } {
|
|
@@ -234,27 +245,40 @@ export class ArrayLayoutRenderer
|
|
|
234
245
|
this.noData = !props.data || props.data === 0;
|
|
235
246
|
this.uischemas = props.uischemas;
|
|
236
247
|
this.translations = props.translations;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this.scopedSchema,
|
|
242
|
-
this.uischema.scope,
|
|
243
|
-
this.propsPath,
|
|
244
|
-
undefined,
|
|
245
|
-
this.uischema,
|
|
246
|
-
this.rootSchema
|
|
248
|
+
this.detailUiSchema = this.resolveDetailUiSchema(
|
|
249
|
+
props,
|
|
250
|
+
this.isEnabled(),
|
|
251
|
+
props.uischema.scope
|
|
247
252
|
);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
253
|
+
this.updateItemProps(props, this.detailUiSchema);
|
|
254
|
+
// OnPush: changes without an event in this view must schedule the check
|
|
255
|
+
this.changeDetectorRef.markForCheck();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Not created in the template: each new object makes the outlet deep clone
|
|
259
|
+
* the whole form state.
|
|
260
|
+
*/
|
|
261
|
+
private updateItemProps(
|
|
262
|
+
props: ArrayLayoutProps,
|
|
263
|
+
detailUiSchema: UISchemaElement
|
|
264
|
+
): void {
|
|
265
|
+
// `props.data` is the item count, but it is only derived from `length`, so
|
|
266
|
+
// it is `undefined` for data that isn't an array. Treat that as no items.
|
|
267
|
+
const itemCount = props.data > 0 ? props.data : 0;
|
|
268
|
+
const deps = [detailUiSchema, props.schema, props.path, itemCount];
|
|
269
|
+
if (!depsChanged(this.itemPropsDeps, deps)) {
|
|
270
|
+
return;
|
|
252
271
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
272
|
+
this.itemPropsDeps = deps;
|
|
273
|
+
|
|
274
|
+
this.itemProps = Array.from({ length: itemCount }, (_unused, index) => ({
|
|
275
|
+
schema: props.schema,
|
|
276
|
+
path: Paths.compose(props.path, `${index}`),
|
|
277
|
+
uischema: detailUiSchema,
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
getProps(index: number): OwnPropsOfRenderer {
|
|
281
|
+
return this.itemProps[index];
|
|
258
282
|
}
|
|
259
283
|
trackByFn(index: number) {
|
|
260
284
|
return index;
|
|
@@ -45,7 +45,6 @@ import {
|
|
|
45
45
|
createDefaultValue,
|
|
46
46
|
decode,
|
|
47
47
|
defaultJsonFormsI18nState,
|
|
48
|
-
findUISchema,
|
|
49
48
|
getArrayTranslations,
|
|
50
49
|
getFirstPrimitiveProp,
|
|
51
50
|
JsonFormsState,
|
|
@@ -53,11 +52,12 @@ import {
|
|
|
53
52
|
mapStateToArrayControlProps,
|
|
54
53
|
RankedTester,
|
|
55
54
|
rankWith,
|
|
56
|
-
setReadonly,
|
|
57
55
|
StatePropsOfArrayControl,
|
|
58
56
|
uiTypeIs,
|
|
57
|
+
UISchemaElement,
|
|
59
58
|
} from '@jsonforms/core';
|
|
60
59
|
import { JsonFormsDetailComponent } from './detail';
|
|
60
|
+
import { createDetailUiSchemaResolver } from '../../util/detail-uischema';
|
|
61
61
|
|
|
62
62
|
const keywords = ['#', 'properties', 'items'];
|
|
63
63
|
|
|
@@ -183,6 +183,8 @@ export class MasterListComponent
|
|
|
183
183
|
removeItems: (path: string, toDelete: number[]) => () => void;
|
|
184
184
|
highlightedIdx: number;
|
|
185
185
|
translations: ArrayTranslations;
|
|
186
|
+
detailUiSchema: UISchemaElement;
|
|
187
|
+
private resolveDetailUiSchema = createDetailUiSchemaResolver();
|
|
186
188
|
|
|
187
189
|
private changeDetectorRef = inject(ChangeDetectorRef);
|
|
188
190
|
|
|
@@ -210,20 +212,13 @@ export class MasterListComponent
|
|
|
210
212
|
const { data, path, schema, uischema } = props;
|
|
211
213
|
const controlElement = uischema as ControlElement;
|
|
212
214
|
this.propsPath = props.path;
|
|
213
|
-
|
|
214
|
-
props
|
|
215
|
-
|
|
215
|
+
this.detailUiSchema = this.resolveDetailUiSchema(
|
|
216
|
+
props,
|
|
217
|
+
this.isEnabled(),
|
|
216
218
|
`${controlElement.scope}/items`,
|
|
217
|
-
|
|
218
|
-
'VerticalLayout',
|
|
219
|
-
controlElement,
|
|
220
|
-
props.rootSchema
|
|
219
|
+
'VerticalLayout'
|
|
221
220
|
);
|
|
222
221
|
|
|
223
|
-
if (!this.isEnabled()) {
|
|
224
|
-
setReadonly(detailUISchema);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
222
|
this.translations = props.translations;
|
|
228
223
|
|
|
229
224
|
const masterItems = (data || []).map((d: any, index: number) => {
|
|
@@ -238,7 +233,7 @@ export class MasterListComponent
|
|
|
238
233
|
data: d,
|
|
239
234
|
path: `${path}.${index}`,
|
|
240
235
|
schema,
|
|
241
|
-
uischema:
|
|
236
|
+
uischema: this.detailUiSchema,
|
|
242
237
|
};
|
|
243
238
|
return masterItem;
|
|
244
239
|
});
|
|
@@ -24,7 +24,13 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import isEmpty from 'lodash/isEmpty';
|
|
26
26
|
import startCase from 'lodash/startCase';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
ChangeDetectionStrategy,
|
|
29
|
+
ChangeDetectorRef,
|
|
30
|
+
Component,
|
|
31
|
+
inject,
|
|
32
|
+
} from '@angular/core';
|
|
33
|
+
import { CommonModule } from '@angular/common';
|
|
28
34
|
import {
|
|
29
35
|
JsonFormsControlWithDetail,
|
|
30
36
|
JsonFormsModule,
|
|
@@ -32,27 +38,25 @@ import {
|
|
|
32
38
|
import { MatCardModule } from '@angular/material/card';
|
|
33
39
|
import {
|
|
34
40
|
ControlWithDetailProps,
|
|
35
|
-
findUISchema,
|
|
36
41
|
Generate,
|
|
37
42
|
GroupLayout,
|
|
38
43
|
isObjectControl,
|
|
44
|
+
OwnPropsOfRenderer,
|
|
39
45
|
RankedTester,
|
|
40
46
|
rankWith,
|
|
41
|
-
setReadonly,
|
|
42
47
|
UISchemaElement,
|
|
43
48
|
} from '@jsonforms/core';
|
|
44
49
|
import cloneDeep from 'lodash/cloneDeep';
|
|
50
|
+
import { createDetailUiSchemaResolver } from '../util/detail-uischema';
|
|
45
51
|
|
|
46
52
|
@Component({
|
|
47
53
|
selector: 'ObjectRenderer',
|
|
48
54
|
template: `
|
|
49
55
|
<mat-card class="object-layout" appearance="outlined">
|
|
50
56
|
<jsonforms-outlet
|
|
51
|
-
|
|
52
|
-
[
|
|
53
|
-
|
|
54
|
-
>
|
|
55
|
-
</jsonforms-outlet>
|
|
57
|
+
*ngIf="renderProps"
|
|
58
|
+
[renderProps]="renderProps"
|
|
59
|
+
></jsonforms-outlet>
|
|
56
60
|
</mat-card>
|
|
57
61
|
`,
|
|
58
62
|
styles: [
|
|
@@ -63,40 +67,50 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
63
67
|
`,
|
|
64
68
|
],
|
|
65
69
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
66
|
-
imports: [JsonFormsModule, MatCardModule],
|
|
70
|
+
imports: [CommonModule, JsonFormsModule, MatCardModule],
|
|
67
71
|
})
|
|
68
72
|
export class ObjectControlRenderer extends JsonFormsControlWithDetail {
|
|
69
73
|
detailUiSchema: UISchemaElement;
|
|
74
|
+
/** Bound as a whole, as the outlet only re-dispatches when this is set. */
|
|
75
|
+
renderProps: OwnPropsOfRenderer;
|
|
76
|
+
private resolveDetailUiSchema = createDetailUiSchemaResolver();
|
|
77
|
+
private changeDetectorRef = inject(ChangeDetectorRef);
|
|
70
78
|
mapAdditionalProps(props: ControlWithDetailProps) {
|
|
71
|
-
|
|
72
|
-
props
|
|
73
|
-
|
|
79
|
+
const detailUiSchema = this.resolveDetailUiSchema(
|
|
80
|
+
props,
|
|
81
|
+
this.isEnabled(),
|
|
74
82
|
props.uischema.scope,
|
|
75
|
-
props.path,
|
|
76
83
|
() => {
|
|
77
84
|
const newSchema = cloneDeep(props.schema);
|
|
78
85
|
// delete unsupported operators
|
|
79
86
|
delete newSchema.oneOf;
|
|
80
87
|
delete newSchema.anyOf;
|
|
81
88
|
delete newSchema.allOf;
|
|
82
|
-
|
|
89
|
+
const generated = Generate.uiSchema(
|
|
83
90
|
newSchema,
|
|
84
91
|
'Group',
|
|
85
92
|
undefined,
|
|
86
|
-
|
|
93
|
+
props.rootSchema
|
|
87
94
|
);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
if (isEmpty(props.path)) {
|
|
96
|
+
generated.type = 'VerticalLayout';
|
|
97
|
+
} else {
|
|
98
|
+
(generated as GroupLayout).label = startCase(props.path);
|
|
99
|
+
}
|
|
100
|
+
return generated;
|
|
101
|
+
}
|
|
91
102
|
);
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
} else {
|
|
95
|
-
(this.detailUiSchema as GroupLayout).label = startCase(props.path);
|
|
96
|
-
}
|
|
97
|
-
if (!this.isEnabled()) {
|
|
98
|
-
setReadonly(this.detailUiSchema);
|
|
103
|
+
if (detailUiSchema === this.detailUiSchema) {
|
|
104
|
+
return;
|
|
99
105
|
}
|
|
106
|
+
this.detailUiSchema = detailUiSchema;
|
|
107
|
+
this.renderProps = {
|
|
108
|
+
uischema: detailUiSchema,
|
|
109
|
+
schema: props.schema,
|
|
110
|
+
path: props.path,
|
|
111
|
+
};
|
|
112
|
+
// OnPush: nothing below reports the new detail, so schedule the check
|
|
113
|
+
this.changeDetectorRef.markForCheck();
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
export const ObjectControlRendererTester: RankedTester = rankWith(
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
+
https://github.com/eclipsesource/jsonforms
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Compares two dependency arrays by reference, like React's `useMemo` deps.
|
|
27
|
+
*/
|
|
28
|
+
export const depsChanged = (
|
|
29
|
+
previous: unknown[] | undefined,
|
|
30
|
+
next: unknown[]
|
|
31
|
+
): boolean =>
|
|
32
|
+
previous === undefined ||
|
|
33
|
+
previous.length !== next.length ||
|
|
34
|
+
next.some((dep, index) => dep !== previous[index]);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
+
https://github.com/eclipsesource/jsonforms
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
import {
|
|
26
|
+
findUISchema,
|
|
27
|
+
setReadonly,
|
|
28
|
+
StatePropsOfControlWithDetail,
|
|
29
|
+
UISchemaElement,
|
|
30
|
+
} from '@jsonforms/core';
|
|
31
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
32
|
+
import { depsChanged } from './deps';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Creates a memoized `findUISchema` for renderers rendering a detail.
|
|
36
|
+
*
|
|
37
|
+
* `findUISchema` can return the inline `options.detail` or a registered UI
|
|
38
|
+
* schema, i.e. objects owned by the user, so the result is always a copy, on
|
|
39
|
+
* which the `readonly` option is set when disabled. It is only recalculated
|
|
40
|
+
* when one of its inputs changed, so it can be compared by identity.
|
|
41
|
+
*/
|
|
42
|
+
export const createDetailUiSchemaResolver = () => {
|
|
43
|
+
let deps: unknown[] | undefined;
|
|
44
|
+
let detailUiSchema: UISchemaElement | undefined;
|
|
45
|
+
return (
|
|
46
|
+
props: StatePropsOfControlWithDetail,
|
|
47
|
+
enabled: boolean,
|
|
48
|
+
schemaPath: string,
|
|
49
|
+
fallback?: string | (() => UISchemaElement)
|
|
50
|
+
): UISchemaElement => {
|
|
51
|
+
// `schemaPath` and `fallback` are derived from these as well
|
|
52
|
+
const nextDeps = [
|
|
53
|
+
props.uischema,
|
|
54
|
+
props.uischemas,
|
|
55
|
+
props.schema,
|
|
56
|
+
props.rootSchema,
|
|
57
|
+
props.path,
|
|
58
|
+
enabled,
|
|
59
|
+
];
|
|
60
|
+
if (!depsChanged(deps, nextDeps)) {
|
|
61
|
+
return detailUiSchema;
|
|
62
|
+
}
|
|
63
|
+
deps = nextDeps;
|
|
64
|
+
|
|
65
|
+
detailUiSchema = cloneDeep(
|
|
66
|
+
findUISchema(
|
|
67
|
+
props.uischemas,
|
|
68
|
+
props.schema,
|
|
69
|
+
schemaPath,
|
|
70
|
+
props.path,
|
|
71
|
+
fallback,
|
|
72
|
+
props.uischema,
|
|
73
|
+
props.rootSchema
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
if (!enabled) {
|
|
77
|
+
setReadonly(detailUiSchema);
|
|
78
|
+
}
|
|
79
|
+
return detailUiSchema;
|
|
80
|
+
};
|
|
81
|
+
};
|