Skip to content

Commit ea6fe82

Browse files
committed
Update Angular packages
- Fixes the module declaration in @jsonforms/angular so the ESM build can be picked up reliably - Exports all functions used in Angular components to avoid name clashes by the ngc transpiler - Removes the redundant zonejs peer dependency - Indicate compatibility with Angular 13 - Adapts i18n change detection to allow updating i18n via the JsonFormsAngularService independent from the root component props
1 parent 95018ca commit ea6fe82

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

packages/angular-material/package.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,19 @@
5454
]
5555
},
5656
"peerDependencies": {
57-
"@angular/animations": "^12.0.0",
58-
"@angular/cdk": "^12.0.0",
59-
"@angular/common": "^12.0.0",
60-
"@angular/core": "^12.0.0",
61-
"@angular/flex-layout": "^12.0.0-beta",
62-
"@angular/forms": "^12.0.0",
63-
"@angular/material": "^12.0.0",
64-
"@angular/platform-browser": "^12.0.0",
65-
"@angular/router": "^12.0.0",
57+
"@angular/animations": "^12.0.0 || ^13.0.0",
58+
"@angular/cdk": "^12.0.0 || ^13.0.0",
59+
"@angular/common": "^12.0.0 || ^13.0.0",
60+
"@angular/core": "^12.0.0 || ^13.0.0",
61+
"@angular/flex-layout": "^12.0.0-beta || ^13.0.0-beta",
62+
"@angular/forms": "^12.0.0 || ^13.0.0",
63+
"@angular/material": "^12.0.0 || ^13.0.0",
64+
"@angular/platform-browser": "^12.0.0 || ^13.0.0",
65+
"@angular/router": "^12.0.0 || ^13.0.0",
6666
"@jsonforms/angular": "^3.0.0-beta.0",
6767
"@jsonforms/core": "^3.0.0-beta.0",
6868
"core-js": "^2.5.3",
69-
"rxjs": "^6.4.0",
70-
"zone.js": "^0.10.2"
69+
"rxjs": "^6.4.0"
7170
},
7271
"dependencies": {
7372
"hammerjs": "2.0.8"
@@ -116,6 +115,6 @@
116115
"webpack": "^4.41.2",
117116
"webpack-cli": "^3.2.1",
118117
"webpack-dev-server": "^3.9.0",
119-
"zone.js": "^0.10.2"
118+
"zone.js": "^0.11.4"
120119
}
121120
}

packages/angular-material/src/other/label.renderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
} from '@jsonforms/core';
4141
import { Subscription } from 'rxjs';
4242

43-
const mapStateToProps = (
43+
export const mapStateToLabelProps = (
4444
state: JsonFormsState,
4545
ownProps: OwnPropsOfRenderer
4646
) => {
@@ -77,7 +77,7 @@ export class LabelRenderer extends JsonFormsBaseRenderer<LabelElement> {
7777
labelElement.text;
7878
this.subscription = this.jsonFormsService.$state.subscribe({
7979
next: (state: JsonFormsState) => {
80-
const props = mapStateToProps(state, this.getOwnProps());
80+
const props = mapStateToLabelProps(state, this.getOwnProps());
8181
this.visible = props.visible;
8282
}
8383
});

packages/angular-material/src/other/table.renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ interface ColumnDescription {
155155
props: OwnPropsOfRenderer;
156156
}
157157

158-
const controlWithoutLabel = (scope: string): ControlElement => ({
158+
export const controlWithoutLabel = (scope: string): ControlElement => ({
159159
type: 'Control',
160160
scope: scope,
161161
label: false

packages/angular/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"customization"
3131
],
3232
"main": "./lib/cjs/index.js",
33-
"esm": "./lib/esm/index.js",
33+
"module": "./lib/esm/index.js",
3434
"typings": "./lib/esm/index.d.ts",
3535
"scripts": {
3636
"build": "ngc && ngc -p tsconfig.cjs.json",
@@ -61,8 +61,8 @@
6161
]
6262
},
6363
"peerDependencies": {
64-
"@angular/core": "^12.0.0",
65-
"@angular/forms": "^12.0.0",
64+
"@angular/core": "^12.0.0 || ^13.0.0",
65+
"@angular/forms": "^12.0.0 || ^13.0.0",
6666
"@jsonforms/core": "^3.0.0-beta.0",
6767
"rxjs": "^6.4.0"
6868
},

packages/angular/src/jsonforms-root.component.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class JsonForms implements OnChanges, OnInit {
5252
private previousErrors:ErrorObject[];
5353

5454
private initialized = false;
55+
oldI18N: JsonFormsI18nState;
5556

5657
constructor(private jsonformsService: JsonFormsAngularService) {
5758
}
@@ -83,15 +84,33 @@ export class JsonForms implements OnChanges, OnInit {
8384
this.errors.emit(errors);
8485
}
8586
});
87+
this.oldI18N = this.i18n;
8688
this.initialized = true;
8789
}
8890

8991
ngDoCheck(): void {
9092
// we can't use ngOnChanges as then nested i18n changes will not be detected
9193
// the update will result in a no-op when the parameters did not change
92-
this.jsonformsService.updateI18n(
93-
Actions.updateI18n(this.i18n?.locale, this.i18n?.translate, this.i18n?.translateError)
94-
);
94+
if (
95+
this.oldI18N?.locale !== this.i18n?.locale ||
96+
this.oldI18N?.translate !== this.i18n?.translate ||
97+
this.oldI18N?.translateError !== this.i18n?.translateError
98+
) {
99+
this.jsonformsService.updateI18n(
100+
Actions.updateI18n(
101+
this.oldI18N?.locale === this.i18n?.locale
102+
? this.jsonformsService.getState().jsonforms.i18n.locale
103+
: this.i18n?.locale,
104+
this.oldI18N?.translate === this.i18n?.translate
105+
? this.jsonformsService.getState().jsonforms.i18n.translate
106+
: this.i18n?.translate,
107+
this.oldI18N?.translateError === this.i18n?.translateError
108+
? this.jsonformsService.getState().jsonforms.i18n.translateError
109+
: this.i18n?.translateError
110+
)
111+
);
112+
this.oldI18N = this.i18n;
113+
}
95114
}
96115

97116
// tslint:disable-next-line: cyclomatic-complexity

0 commit comments

Comments
 (0)