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

Commit 06e7c57

Browse files
committed
Add more examples and add selected property on MenuItems
1 parent cf4bee6 commit 06e7c57

File tree

35 files changed

+162
-21
lines changed

35 files changed

+162
-21
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"firstName": "Chuck",
3+
"lastName": "Norris",
4+
"assKickCount": "infinity"
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
key: 'aditionalProperties',
7+
title: 'Aditional Properties',
8+
schema,
9+
uiSchema,
10+
formData,
11+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"title": "A customizable registration form",
3+
"description": "A simple form with additional properties example.",
4+
"type": "object",
5+
"required": ["firstName", "lastName"],
6+
"additionalProperties": {
7+
"type": "string"
8+
},
9+
"properties": {
10+
"firstName": {
11+
"type": "string",
12+
"title": "First name"
13+
},
14+
"lastName": {
15+
"type": "string",
16+
"title": "Last name"
17+
}
18+
}
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"firstName": {
3+
"ui:autofocus": true,
4+
"ui:emptyValue": ""
5+
}
6+
}

example/src/examples/alternatives/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'alternatives',
67
title: 'Alternatives',
78
schema,
89
uiSchema,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'anyOf',
67
title: 'Any Of',
78
schema,
89
uiSchema,

example/src/examples/arrays/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import schema from './schema.json';
22
import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

5-
export default ({
5+
export default {
6+
key: 'arrays',
67
title: 'Arrays',
78
schema,
89
uiSchema,
910
formData,
10-
});
11+
};

example/src/examples/budget/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import schema from './schema.json';
22
import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

5-
export default ({
5+
export default {
6+
key: 'budget',
67
title: 'Budget',
78
schema,
89
uiSchema,
910
formData,
10-
});
11+
};

example/src/examples/custom-array/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'customArray',
67
title: 'Custom Array',
78
schema,
89
uiSchema,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"firstName": "Chuck",
3+
"lastName": "Norris",
4+
"age": 75,
5+
"bio": "Roundhouse kicking asses since 1940",
6+
"password": "noneed"
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
key: 'customObject',
7+
title: 'Custom Object',
8+
schema,
9+
uiSchema,
10+
formData,
11+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"title": "A registration form",
3+
"description": "This is the same as the simple form, but it is rendered as a bootstrap grid. Try shrinking the browser window to see it in action.",
4+
"type": "object",
5+
"required": ["firstName", "lastName"],
6+
"properties": {
7+
"firstName": {
8+
"type": "string",
9+
"title": "First name"
10+
},
11+
"lastName": {
12+
"type": "string",
13+
"title": "Last name"
14+
},
15+
"age": {
16+
"type": "integer",
17+
"title": "Age"
18+
},
19+
"bio": {
20+
"type": "string",
21+
"title": "Bio"
22+
},
23+
"password": {
24+
"type": "string",
25+
"title": "Password",
26+
"minLength": 3
27+
},
28+
"telephone": {
29+
"type": "string",
30+
"title": "Telephone",
31+
"minLength": 10
32+
}
33+
}
34+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example/src/examples/custom/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'custom',
67
title: 'Custom',
78
schema,
89
uiSchema,

example/src/examples/errors/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'errors',
67
title: 'Errors',
78
schema,
89
uiSchema,

example/src/examples/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import aditionalProperties from './aditional-properties';
2+
import alternatives from './alternatives';
13
import anyOf from './any-of';
24
import arrays from './arrays';
3-
import alternatives from './alternatives';
45
import budget from './budget';
56
import custom from './custom';
67
import customArray from './custom-array';
8+
import customObject from './custom-object';
79
import errors from './errors';
810
import large from './large';
911
import multipleChoice from './multiple-choice';
@@ -21,12 +23,14 @@ import single from './single';
2123
import validation from './validation';
2224

2325
export default {
26+
aditionalProperties,
27+
alternatives,
2428
anyOf,
2529
arrays,
26-
alternatives,
2730
budget,
2831
custom,
2932
customArray,
33+
customObject,
3034
errors,
3135
large,
3236
multipleChoice,

example/src/examples/large/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'large',
67
title: 'Large',
78
schema,
89
uiSchema,

example/src/examples/multiple-choice/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import schema from './schema.json';
22
import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

5-
export default ({
5+
export default {
6+
key: 'multipleChoice',
67
title: 'Multiple Choice',
78
schema,
89
uiSchema,
910
formData,
10-
});
11+
};

example/src/examples/nested/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import schema from './schema.json';
22
import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

5-
export default ({
5+
export default {
6+
key: 'nested',
67
title: 'Nested',
78
schema,
89
uiSchema,
910
formData,
10-
});
11+
};

example/src/examples/null-fields/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'nullFields',
67
title: 'Null Fields',
78
schema,
89
uiSchema,

example/src/examples/nullable/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'nullable',
67
title: 'Nullable',
78
schema,
89
uiSchema,

example/src/examples/numbers/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import schema from './schema.json';
22
import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

5-
export default ({
5+
export default {
6+
key: 'numbers',
67
title: 'Numbers',
78
schema,
89
uiSchema,
910
formData,
10-
});
11+
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'oneOf',
67
title: 'One Of',
78
schema,
89
uiSchema,

example/src/examples/ordering/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'ordering',
67
title: 'Ordering',
78
schema,
89
uiSchema,

example/src/examples/property-dependencies/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'propertyDependencies',
67
title: 'Property Dependencies',
78
schema,
89
uiSchema,

example/src/examples/references/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'references',
67
title: 'References',
78
schema,
89
uiSchema,

example/src/examples/schema-dependencies/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

55
export default {
6+
key: 'schemaDependencies',
67
title: 'Schema Dependencies',
78
schema,
89
uiSchema,

example/src/examples/simple/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import schema from './schema.json';
22
import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

5-
export default ({
5+
export default {
6+
key: 'simple',
67
title: 'Simple',
78
schema,
89
uiSchema,
910
formData,
10-
});
11+
};

example/src/examples/single/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import schema from './schema.json';
22
import uiSchema from './ui-schema.json';
33
import formData from './form-data.json';
44

5-
export default ({
5+
export default {
6+
key: 'single',
67
title: 'Single',
78
schema,
89
uiSchema,
910
formData,
10-
});
11+
};

example/src/examples/validation/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import formData from './form-data.json';
44
import validate from './validate';
55

66
export default {
7+
key: 'validation',
78
title: 'Validation',
89
schema,
910
uiSchema,

example/src/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ const App = () => {
1818
<div>
1919
<CssBaseLine />
2020

21-
<Menu onSelectMenuItem={onSelectMenuItem} />
21+
<Menu
22+
onSelectMenuItem={onSelectMenuItem}
23+
selectedMenuItem={selectedExample.key}
24+
/>
2225
<Body selectedDemo={selectedExample} />
2326
</div>
2427
);

example/src/menu/LeftDrawer.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ import MenuItems from './MenuItems';
88
import menuStyles from './menu-styles';
99

1010
export default withStyles(menuStyles)(
11-
({ classes, open, toggleDrawer, onSelectMenuItem }: any) => (
11+
({
12+
classes,
13+
open,
14+
toggleDrawer,
15+
onSelectMenuItem,
16+
selectedMenuItem,
17+
}: any) => (
1218
<>
1319
<Hidden only={['xs', 'sm', 'md']}>
1420
<Drawer variant={'permanent'} className={classes.permanentLeftDrawer}>
1521
<MenuItems
1622
toggleDrawer={toggleDrawer}
1723
onSelectMenuItem={onSelectMenuItem}
24+
selectedMenuItem={selectedMenuItem}
1825
/>
1926
</Drawer>
2027
</Hidden>
@@ -27,6 +34,7 @@ export default withStyles(menuStyles)(
2734
<MenuItems
2835
toggleDrawer={toggleDrawer}
2936
onSelectMenuItem={onSelectMenuItem}
37+
selectedMenuItem={selectedMenuItem}
3038
/>
3139
</Drawer>
3240
</Hidden>

example/src/menu/Menu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class RawMenuAppBar extends React.Component<any, any> {
2323
};
2424

2525
render() {
26-
const { classes, onSelectMenuItem } = this.props;
26+
const { classes, onSelectMenuItem, selectedMenuItem } = this.props;
2727
const { drawerOpen } = this.state;
2828

2929
return (
@@ -49,6 +49,7 @@ class RawMenuAppBar extends React.Component<any, any> {
4949
open={drawerOpen}
5050
toggleDrawer={this.toggleDrawer}
5151
onSelectMenuItem={onSelectMenuItem}
52+
selectedMenuItem={selectedMenuItem}
5253
/>
5354
</AppBar>
5455
);

0 commit comments

Comments
 (0)