Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sdirix authored Jun 21, 2022
2 parents 1938d16 + 31972a5 commit 29e6d84
Show file tree
Hide file tree
Showing 43 changed files with 571 additions and 161 deletions.
4 changes: 4 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ The `scope` attribute in `Scopable` is now optional.
Use `Scoped` instead for non optional scopes.
The utility function `fromScopable` was renamed to `fromScoped` accordingly.

### Localization of Date Picker in Angular Material

Date Picker in Angular Material will use the global configuration of your Angular Material application.

## Migrating to JSON Forms 2.5

### JsonForms Component for Angular
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Please see the official JSON Forms website, [jsonforms.io](https://jsonforms.io)
## Getting started

1. Clone the seed app with `git clone https://github.com/eclipsesource/jsonforms-react-seed.git`
2. Install dependencies with `npm ci` (or `npm install` when using an older version)
2. Install dependencies with `npm ci`
3. Run the app with `npm run start`

For more info about the seed app, please see the corresponding README file of the [seed repo](https://github.com/eclipsesource/jsonforms-react-seed).
For a more detailed tutorial about the usage of JSON Forms, please see [this tutorial](http://jsonforms.io/docs/tutorial).

## Upgrading to JSON Forms 3.0 Alpha
## Upgrading to JSON Forms 3.0

With version 3.0 of JSON Forms we removed `json-schema-ref-parser` from the core package.
This change only affects users of the React variant (Vue and Angular are not affected) and even for React only a few users will need to adjust their code.
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"packages/vue/*",
"packages/vue2/*"
],
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.4",
"nohoist": [
"core-js",
"vue",
Expand Down
56 changes: 54 additions & 2 deletions packages/angular-material/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,58 @@ import { angularMaterialRenderers } from "@jsonforms/angular-material";
})
export class AppComponent {
renderers = angularMaterialRenderers;
uischema = {
type: "VerticalLayout",
elements: [
{
type: "Control",
label: false,
scope: "#/properties/done",
},
{
type: "Control",
scope: "#/properties/name",
},
{
type: "HorizontalLayout",
elements: [
{
type: "Control",
scope: "#/properties/due_date",
},
{
type: "Control",
scope: "#/properties/recurrence",
},
],
},
],
};
schema = {
type: "object",
properties: {
name: {
type: "string",
minLength: 1,
},
done: {
type: "boolean",
},
due_date: {
type: "string",
format: "date",
},
recurrence: {
type: "string",
enum: ["Never", "Daily", "Weekly", "Monthly"],
},
},
required: ["name", "due_date"],
};
data = {};
}
```

Example module file:
Example module file `app.module.ts`:

```ts
import { NgModule } from "@angular/core";
Expand All @@ -65,6 +112,7 @@ import { AppComponent } from "./app.component";
bootstrap: [AppComponent],
})

export class AppModule { }
```

## License
Expand All @@ -83,3 +131,7 @@ If you encounter any problems feel free to [open an issue](https://github.com/ec
For questions and discussions please use the [JSON Forms board](https://jsonforms.discourse.group).
You can also reach us via [email](mailto:jsonforms@eclipsesource.com?subject=JSON%20Forms).
In addition, EclipseSource also offers [professional support](https://jsonforms.io/support) for JSON Forms.

## Migration

See our [migration guide](https://github.com/eclipsesource/jsonforms/blob/master/MIGRATION.md) when updating JSON Forms.
8 changes: 7 additions & 1 deletion packages/angular-material/example/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { Component } from '@angular/core';
import { ExampleDescription, getExamples } from '@jsonforms/examples';
import { UISchemaElement, UISchemaTester } from '@jsonforms/core';
import { angularMaterialRenderers } from '../../src/index';
import { DateAdapter } from '@angular/material/core';

const uiSchema = {
type: 'HorizontalLayout',
elements: [
Expand Down Expand Up @@ -89,14 +91,17 @@ export class AppComponent {
i18n = {
locale: 'en-US'
}
private dateAdapter;
private readonly = false;
data: any;
uischemas: { tester: UISchemaTester; uischema: UISchemaElement; }[] = [
{ tester: itemTester, uischema: uiSchema }
];

constructor() {
constructor(dateAdapter: DateAdapter<Date>) {
this.selectedExample = this.examples[19];
this.dateAdapter = dateAdapter;
dateAdapter.setLocale(this.i18n.locale);
}

onChange(ev: any) {
Expand All @@ -105,6 +110,7 @@ export class AppComponent {

changeLocale(locale: string) {
this.i18n.locale = locale;
this.dateAdapter.setLocale(locale);
}

toggleReadonly() {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-material/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions packages/angular-material/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsonforms/angular-material",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.4",
"description": "Material Renderer Set for Angular module of JSON Forms",
"repository": "https://github.com/eclipsesource/jsonforms",
"bugs": "https://github.com/eclipsesource/jsonforms/issues",
Expand Down Expand Up @@ -63,8 +63,8 @@
"@angular/material": "^12.0.0 || ^13.0.0",
"@angular/platform-browser": "^12.0.0 || ^13.0.0",
"@angular/router": "^12.0.0 || ^13.0.0",
"@jsonforms/angular": "3.0.0-beta.2",
"@jsonforms/core": "3.0.0-beta.2",
"@jsonforms/angular": "3.0.0-beta.4",
"@jsonforms/core": "3.0.0-beta.4",
"core-js": "^2.5.3",
"rxjs": "^6.4.0"
},
Expand All @@ -84,10 +84,10 @@
"@angular/platform-browser": "^12.0.0",
"@angular/platform-browser-dynamic": "^12.0.0",
"@angular/router": "^12.0.0",
"@jsonforms/angular": "^3.0.0-beta.2",
"@jsonforms/angular-test": "^3.0.0-beta.2",
"@jsonforms/core": "^3.0.0-beta.2",
"@jsonforms/examples": "^3.0.0-beta.2",
"@jsonforms/angular": "^3.0.0-beta.4",
"@jsonforms/angular-test": "^3.0.0-beta.4",
"@jsonforms/core": "^3.0.0-beta.4",
"@jsonforms/examples": "^3.0.0-beta.4",
"@types/node": "^10.10.0",
"angular2-template-loader": "^0.6.2",
"copy-webpack-plugin": "^5.0.5",
Expand Down
8 changes: 0 additions & 8 deletions packages/angular-material/src/controls/date.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@
*/
import { Component, ChangeDetectionStrategy } from '@angular/core';
import {
getLocale,
isDateControl,
RankedTester,
rankWith
} from '@jsonforms/core';
import { JsonFormsAngularService, JsonFormsControl } from '@jsonforms/angular';
import { DateAdapter, NativeDateAdapter } from '@angular/material/core';

@Component({
selector: 'DateControlRenderer',
Expand Down Expand Up @@ -58,16 +56,10 @@ import { DateAdapter, NativeDateAdapter } from '@angular/material/core';
export class DateControlRenderer extends JsonFormsControl {
constructor(
jsonformsService: JsonFormsAngularService,
private dateAdapter: DateAdapter<NativeDateAdapter>
) {
super(jsonformsService);
}

mapAdditionalProps() {
const locale = getLocale(this.jsonFormsService.getState());
this.dateAdapter.setLocale(locale);
}

getEventValue = (event: any) => event.value.toISOString().substr(0, 10);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/angular-test/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@jsonforms/angular-test",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.4",
"private": true,
"main": "./lib/index.js",
"dependencies": {
"@jsonforms/angular": "^3.0.0-beta.2",
"@jsonforms/core": "^3.0.0-beta.2"
"@jsonforms/angular": "^3.0.0-beta.4",
"@jsonforms/core": "^3.0.0-beta.4"
},
"devDependencies": {
"jasmine": "^3.2.0",
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ import { AppComponent } from "./app.component";
bootstrap: [AppComponent],
})

export class AppModule { }
```

## License
Expand All @@ -145,3 +146,7 @@ If you encounter any problems feel free to [open an issue](https://github.com/ec
For questions and discussions please use the [JSON Forms board](https://jsonforms.discourse.group).
You can also reach us via [email](mailto:jsonforms@eclipsesource.com?subject=JSON%20Forms).
In addition, EclipseSource also offers [professional support](https://jsonforms.io/support) for JSON Forms.

## Migration

See our [migration guide](https://github.com/eclipsesource/jsonforms/blob/master/MIGRATION.md) when updating JSON Forms.
6 changes: 3 additions & 3 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsonforms/angular",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.4",
"description": "Angular module of JSON Forms",
"repository": "https://github.com/eclipsesource/jsonforms",
"bugs": "https://github.com/eclipsesource/jsonforms/issues",
Expand Down Expand Up @@ -63,15 +63,15 @@
"peerDependencies": {
"@angular/core": "^12.0.0 || ^13.0.0",
"@angular/forms": "^12.0.0 || ^13.0.0",
"@jsonforms/core": "3.0.0-beta.2",
"@jsonforms/core": "3.0.0-beta.4",
"rxjs": "^6.4.0"
},
"devDependencies": {
"@angular/compiler": "^12.0.0",
"@angular/compiler-cli": "^12.0.0",
"@angular/core": "^12.0.0",
"@angular/forms": "^12.0.0",
"@jsonforms/core": "^3.0.0-beta.2",
"@jsonforms/core": "^3.0.0-beta.4",
"ava": "~2.4.0",
"copy-webpack-plugin": "^5.0.5",
"cross-env": "^7.0.2",
Expand Down
11 changes: 11 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ See the official [documentation](https://jsonforms.io/) and the [Example Package

Check <https://www.npmjs.com/search?q=%40jsonforms> for all published JSON Forms packages.

## Upgrading to JSON Forms 3.0

With version 3.0 of JSON Forms we removed `json-schema-ref-parser` from the core package.
This change only affects users of the React variant (Vue and Angular are not affected) and even for React only a few users will need to adjust their code.
To avoid issues and for more information, please have a look at our [migration guide](https://github.com/eclipsesource/jsonforms/blob/master/MIGRATION.md).

## License

The JSON Forms project is licensed under the MIT License. See the [LICENSE file](https://github.com/eclipsesource/jsonforms/blob/master/LICENSE) for more information.
Expand All @@ -37,3 +43,8 @@ If you encounter any problems feel free to [open an issue](https://github.com/ec
For questions and discussions please use the [JSON Forms board](https://jsonforms.discourse.group).
You can also reach us via [email](mailto:jsonforms@eclipsesource.com?subject=JSON%20Forms).
In addition, EclipseSource also offers [professional support](https://jsonforms.io/support) for JSON Forms.


## Migration

See our [migration guide](https://github.com/eclipsesource/jsonforms/blob/master/MIGRATION.md) when updating JSON Forms.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsonforms/core",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.4",
"description": "Core module of JSON Forms",
"repository": "https://github.com/eclipsesource/jsonforms",
"bugs": "https://github.com/eclipsesource/jsonforms/issues",
Expand Down
23 changes: 10 additions & 13 deletions packages/core/src/testers/testers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const formatIs = (expectedFormat: string): Tester =>
schema =>
!isEmpty(schema) &&
schema.format === expectedFormat &&
schema.type === 'string'
hasType(schema, 'string')
);

/**
Expand Down Expand Up @@ -445,10 +445,7 @@ export const isObjectArrayWithNesting = (
}
const schemaPath = (uischema as ControlElement).scope;
const resolvedSchema = resolveSchema(schema, schemaPath, rootSchema ?? schema);
const wantedNestingByType: { [key: string]: number } = {
object: 2,
array: 1
};
let objectDepth = 0;
if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
// check if nested arrays
if (
Expand All @@ -459,16 +456,16 @@ export const isObjectArrayWithNesting = (
if (val.$ref !== undefined) {
return false;
}
// we don't support multiple types
if (typeof val.type !== 'string') {
return true;
if (hasType(val, 'object')) {
objectDepth++;
if (objectDepth === 2) {
return true;
}
}
const typeCount = wantedNestingByType[val.type];
if (typeCount === undefined) {
return false;
if (hasType(val, 'array')) {
return true;
}
wantedNestingByType[val.type] = typeCount - 1;
return wantedNestingByType[val.type] === 0;
return false;
}, rootSchema)
) {
return true;
Expand Down
8 changes: 4 additions & 4 deletions packages/example/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@jsonforms/examples-react",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.4",
"private": true,
"dependencies": {
"@jsonforms/core": "^3.0.0-beta.2",
"@jsonforms/examples": "^3.0.0-beta.2",
"@jsonforms/react": "^3.0.0-beta.2",
"@jsonforms/core": "^3.0.0-beta.4",
"@jsonforms/examples": "^3.0.0-beta.4",
"@jsonforms/react": "^3.0.0-beta.4",
"@mui/material": "^5.2.2",
"@types/react-highlight": "^0.12.5",
"@types/react-tabs": "^2.3.3",
Expand Down
6 changes: 5 additions & 1 deletion packages/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ JSON Forms eliminates the tedious task of writing fully-featured forms by hand b

This is the examples package which demonstrates how to integrate JSON Forms with your application.

You can use the examples with any renderer set you want, for example the [Material Renderers](https://github.com/eclipsesource/jsonforms/blob/master/packages/material-renderers) or the [Angular Renderers](https://github.com/eclipsesource/jsonforms/blob/master/packages/vanilla-renderers).
You can use the examples with any renderer set you want, for example the [Material Renderers](https://github.com/eclipsesource/jsonforms/tree/master/packages/material) or the [Angular Renderers](https://github.com/eclipsesource/jsonforms/tree/master/packages/angular-material).

Check <https://www.npmjs.com/search?q=%40jsonforms> for all published JSON Forms packages.

Expand All @@ -28,3 +28,7 @@ If you encounter any problems feel free to [open an issue](https://github.com/ec
For questions and discussions please use the [JSON Forms board](https://jsonforms.discourse.group).
You can also reach us via [email](mailto:jsonforms@eclipsesource.com?subject=JSON%20Forms).
In addition, EclipseSource also offers [professional support](https://jsonforms.io/support) for JSON Forms.

## Migration

See our [migration guide](https://github.com/eclipsesource/jsonforms/blob/master/MIGRATION.md) when updating JSON Forms.
Loading

0 comments on commit 29e6d84

Please sign in to comment.