Skip to content

Commit 3f97278

Browse files
Add additional props renderer & enhance allOf, anyOf, oneOf, data, number controls (#91)
* add support for oneOf with select switch, add examples, allow allOf to render extra properties * allow date control when in year mode to work with schema type number and integer * make oneOf with select the default one * make errors reactive * Add control for additional properties * update additional properties implementation * when bundling, extract css from the library to support shadow dom * allow full usage of ajv validator in example * add option `showAdditionalProperties` to configure whether additional properties are rendered * Enhance number handling in number controls * use `parseFloat` instead of `parseInt` so if we enter number with decimal point it will show an error and not just floor the number * add clear button on hover * No longer use input `type="number"` because it works strange under chome when using values such as e121 or values larger than Number.MAX_VALUE the returned string from the component is empty string. If we can't convert to number then pass the original string so that AJV will report an error * use string data to represent the input value, use regex to check if the number is valid becaue input type=number is not used * update the input value for number control if the string representation of the number does not match the input Co-authored-by: Lucas Koehler <lkoehler@eclipsesource.com>
1 parent 0019a86 commit 3f97278

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1854
-216
lines changed

packages/example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@jsonforms/vue2-vuetify": "3.0.0",
1414
"core-js": "^3.9.1",
1515
"json-refs": "^3.0.15",
16+
"ajv-keywords": "^5.1.0",
1617
"monaco-editor": "^0.26.0",
1718
"vue": "^2.7.0",
1819
"vue-router": "^3.2.0",

packages/example/src/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
<script lang="ts">
88
export default { name: 'App' };
99
</script>
10+
11+
<style scoped>
12+
@import '~@jsonforms/vue2-vuetify/lib/jsonforms-vue2-vuetify.esm.css';
13+
</style>

packages/example/src/core/jsonschema/specification/uischema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
"scope": {
299299
"type": "string",
300300
"$id": "#scope",
301-
"pattern": "^#\\/properties\\/{1}"
301+
"pattern": "^#$|^#\\/$|^#\\/properties\\/{1}"
302302
},
303303
"options": {
304304
"type": "object",

packages/example/src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type Example = {
1010
input: {
1111
schema?: JsonSchema;
1212
uischema?: UISchemaElement;
13-
data: Record<string, any>;
13+
data: string | number | boolean | any[] | Record<string, any>;
1414
i18n?: Record<string, any>;
1515
renderers?: JsonFormsRendererRegistryEntry[];
1616
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"propertiesString": "data",
3+
"string": "string value",
4+
"number": 10.2,
5+
"integer": 11,
6+
"object": {
7+
"prop1": "prop 1 value"
8+
},
9+
"boolean": true,
10+
"stringArray": ["value1", "value2"],
11+
"numberArray": [12.2],
12+
"integerArray": [33],
13+
"objectArray": [{ "prop1": "prop1 val" }, {}],
14+
"booleanArray": [false, true]
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"en": {
3+
"root": {
4+
"additionalProperties": {
5+
"title": "Additional Properties",
6+
"newProperty": {
7+
"placeholder": "New Property"
8+
},
9+
"btn": {
10+
"add": "Add to ${additionalProperties.title}",
11+
"delete": "Delete from ${additionalProperties.title}"
12+
}
13+
}
14+
}
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import schema from './schema.json';
2+
import uischema from './uischema.json';
3+
import data from './data.json';
4+
import i18n from './i18n.json';
5+
import { UISchemaElement, JsonSchema } from '@jsonforms/core';
6+
7+
export const input: {
8+
schema: JsonSchema;
9+
uischema: UISchemaElement;
10+
data: any;
11+
i18n: any;
12+
} = { schema, uischema, data, i18n };
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"propertiesString": {
6+
"type": "string"
7+
}
8+
},
9+
"propertyNames": {
10+
"minLength": 2
11+
},
12+
"patternProperties": {
13+
"^string$": {
14+
"type": "string"
15+
},
16+
"^number$": {
17+
"type": "number"
18+
},
19+
"^integer$": {
20+
"type": "integer"
21+
},
22+
"^object$": {
23+
"type": "object",
24+
"properties": {
25+
"prop1": {
26+
"type": "string"
27+
}
28+
}
29+
},
30+
"^boolean$": {
31+
"type": "boolean"
32+
},
33+
"^stringArray$": {
34+
"type": "array",
35+
"items": {
36+
"type": "string"
37+
}
38+
},
39+
"^numberArray$": {
40+
"type": "array",
41+
"items": {
42+
"type": "number"
43+
}
44+
},
45+
"^integerArray$": {
46+
"type": "array",
47+
"items": {
48+
"type": "integer"
49+
}
50+
},
51+
"^objectArray$": {
52+
"type": "array",
53+
"items": {
54+
"type": "object",
55+
"properties": {
56+
"prop1": {
57+
"type": "string"
58+
}
59+
}
60+
}
61+
},
62+
"^booleanArray$": {
63+
"type": "array",
64+
"items": {
65+
"type": "boolean"
66+
}
67+
}
68+
},
69+
"additionalProperties": {
70+
"type": "string",
71+
"title": "Additional Properties"
72+
},
73+
"maxProperties": 15
74+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Control",
3+
"scope": "#/"
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"addressOrUser": {
3+
"street_address": "1600 Pennsylvania Avenue NW",
4+
"city": "Washington",
5+
"state": "DC"
6+
}
7+
}

0 commit comments

Comments
 (0)