Skip to content
This repository was archived by the owner on Jun 1, 2020. It is now read-only.

Commit 1a17c39

Browse files
committed
Add more examples. Fix number type property
Add margin-top on TitleField Fixes: #26
1 parent 8c7d334 commit 1a17c39

Some content is hidden

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

56 files changed

+1015
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"currentColor": "#00ff00",
3+
"colorMask": ["#0000ff"],
4+
"colorPalette": ["#ff0000"],
5+
"blendMode": "screen"
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import schema from './schema.json';
2+
import uiSchema from './ui-schema.json';
3+
import formData from './form-data.json';
4+
5+
export default {
6+
title: 'Alternatives',
7+
schema,
8+
uiSchema,
9+
formData,
10+
};
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"definitions": {
3+
"Color": {
4+
"title": "Color",
5+
"type": "string",
6+
"anyOf": [
7+
{
8+
"type": "string",
9+
"enum": ["#ff0000"],
10+
"title": "Red"
11+
},
12+
{
13+
"type": "string",
14+
"enum": ["#00ff00"],
15+
"title": "Green"
16+
},
17+
{
18+
"type": "string",
19+
"enum": ["#0000ff"],
20+
"title": "Blue"
21+
}
22+
]
23+
},
24+
"Toggle": {
25+
"title": "Toggle",
26+
"type": "boolean",
27+
"oneOf": [
28+
{
29+
"title": "Enable",
30+
"const": true
31+
},
32+
{
33+
"title": "Disable",
34+
"const": false
35+
}
36+
]
37+
}
38+
},
39+
"title": "Image editor",
40+
"type": "object",
41+
"required": ["currentColor", "colorMask", "blendMode"],
42+
"properties": {
43+
"currentColor": {
44+
"$ref": "#/definitions/Color",
45+
"title": "Brush color"
46+
},
47+
"colorMask": {
48+
"type": "array",
49+
"uniqueItems": true,
50+
"items": {
51+
"$ref": "#/definitions/Color"
52+
},
53+
"title": "Color mask"
54+
},
55+
"toggleMask": {
56+
"title": "Apply color mask",
57+
"$ref": "#/definitions/Toggle"
58+
},
59+
"colorPalette": {
60+
"type": "array",
61+
"title": "Color palette",
62+
"items": {
63+
"$ref": "#/definitions/Color"
64+
}
65+
},
66+
"blendMode": {
67+
"title": "Blend mode",
68+
"type": "string",
69+
"enum": ["screen", "multiply", "overlay"],
70+
"enumNames": ["Screen", "Multiply", "Overlay"]
71+
}
72+
}
73+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"blendMode": {
3+
"ui:enumDisabled": ["multiply"]
4+
},
5+
"toggleMask": {
6+
"ui:widget": "radio"
7+
}
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"firstName": "Chuck"
3+
}

example/src/examples/any-of/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import schema from './schema.json';
2+
import uiSchema from './ui-schema.json';
3+
import formData from './form-data.json';
4+
5+
export default {
6+
title: 'Any Of',
7+
schema,
8+
uiSchema,
9+
formData,
10+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"age": {
5+
"type": "integer",
6+
"title": "Age"
7+
},
8+
"items": {
9+
"type": "array",
10+
"items": {
11+
"type": "object",
12+
"anyOf": [
13+
{
14+
"properties": {
15+
"foo": {
16+
"type": "string"
17+
}
18+
}
19+
},
20+
{
21+
"properties": {
22+
"bar": {
23+
"type": "string"
24+
}
25+
}
26+
}
27+
]
28+
}
29+
}
30+
},
31+
"anyOf": [
32+
{
33+
"title": "First method of identification",
34+
"properties": {
35+
"firstName": {
36+
"type": "string",
37+
"title": "First name",
38+
"default": "Chuck"
39+
},
40+
"lastName": {
41+
"type": "string",
42+
"title": "Last name"
43+
}
44+
}
45+
},
46+
{
47+
"title": "Second method of identification",
48+
"properties": {
49+
"idCode": {
50+
"type": "string",
51+
"title": "ID code"
52+
}
53+
}
54+
}
55+
]
56+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["react", "jsonschema", "form"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import schema from './schema.json';
2+
import uiSchema from './ui-schema.json';
3+
import formData from './form-data.json';
4+
5+
export default {
6+
title: 'Custom Array',
7+
schema,
8+
uiSchema,
9+
formData,
10+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"title": "Custom array of strings",
3+
"type": "array",
4+
"items": {
5+
"type": "string"
6+
}
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"lat": 0,
3+
"lon": 0
4+
}

example/src/examples/custom/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import schema from './schema.json';
2+
import uiSchema from './ui-schema.json';
3+
import formData from './form-data.json';
4+
5+
export default {
6+
title: 'Custom',
7+
schema,
8+
uiSchema,
9+
formData,
10+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"title": "A localisation form",
3+
"type": "object",
4+
"required": ["lat", "lon"],
5+
"properties": {
6+
"lat": {
7+
"type": "number"
8+
},
9+
"lon": {
10+
"type": "number"
11+
}
12+
}
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ui:field": "geo"
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"firstName": "Chuck",
3+
"active": "wrong",
4+
"skills": ["karate", "budo", "aikido"],
5+
"multipleChoicesList": ["foo", "bar", "fuzz"]
6+
}

example/src/examples/errors/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import schema from './schema.json';
2+
import uiSchema from './ui-schema.json';
3+
import formData from './form-data.json';
4+
5+
export default {
6+
title: 'Errors',
7+
schema,
8+
uiSchema,
9+
formData,
10+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"title": "Contextualized errors",
3+
"type": "object",
4+
"properties": {
5+
"firstName": {
6+
"type": "string",
7+
"title": "First name",
8+
"minLength": 8,
9+
"pattern": "\\d+"
10+
},
11+
"active": {
12+
"type": "boolean",
13+
"title": "Active"
14+
},
15+
"skills": {
16+
"type": "array",
17+
"items": {
18+
"type": "string",
19+
"minLength": 5
20+
}
21+
},
22+
"multipleChoicesList": {
23+
"type": "array",
24+
"title": "Pick max two items",
25+
"uniqueItems": true,
26+
"maxItems": 2,
27+
"items": {
28+
"type": "string",
29+
"enum": ["foo", "bar", "fuzz"]
30+
}
31+
}
32+
}
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example/src/examples/index.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
1+
import anyOf from './any-of';
12
import arrays from './arrays';
3+
import alternatives from './alternatives';
24
import budget from './budget';
5+
import custom from './custom';
6+
import customArray from './custom-array';
7+
import errors from './errors';
8+
import large from './large';
9+
import multipleChoice from './multiple-choice';
310
import nested from './nested';
11+
import nullable from './nullable';
12+
import nullFields from './null-fields';
413
import numbers from './numbers';
5-
import multipleChoice from './multiple-choice';
14+
import oneOf from './one-of';
15+
import ordering from './ordering';
16+
import propertyDependencies from './property-dependencies';
17+
import references from './references';
18+
import schemaDependencies from './schema-dependencies';
619
import simple from './simple';
720
import single from './single';
821
import validation from './validation';
922

1023
export default {
24+
anyOf,
1125
arrays,
26+
alternatives,
1227
budget,
28+
custom,
29+
customArray,
30+
errors,
31+
large,
32+
multipleChoice,
1333
nested,
34+
nullable,
35+
nullFields,
1436
numbers,
15-
multipleChoice,
37+
oneOf,
38+
ordering,
39+
propertyDependencies,
40+
references,
41+
schemaDependencies,
1642
simple,
1743
single,
1844
validation,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example/src/examples/large/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import schema from './schema.json';
2+
import uiSchema from './ui-schema.json';
3+
import formData from './form-data.json';
4+
5+
export default {
6+
title: 'Large',
7+
schema,
8+
uiSchema,
9+
formData,
10+
};

0 commit comments

Comments
 (0)