Skip to content

Commit

Permalink
Merge pull request #4 from mozilla-services/fields-widgets
Browse files Browse the repository at this point in the history
Fields & widgets
  • Loading branch information
n1k0 committed Dec 21, 2015
2 parents 930267d + e1b7a1a commit 29b2bc8
Show file tree
Hide file tree
Showing 52 changed files with 604 additions and 135 deletions.
5 changes: 2 additions & 3 deletions dist/react-jsonschema-form-0.2.0.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-jsonschema-form-0.2.0.js.map

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions fixtures/CheckboxField/default.js

This file was deleted.

6 changes: 6 additions & 0 deletions fixtures/ErrorList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
errors: [
{stack: "error message 1"},
{stack: "error message 2"},
]
};
47 changes: 47 additions & 0 deletions fixtures/Form/nested-formData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = {
schema: {
title: "Todo Tasks",
description: "Tasks collection.",
type: "object",
additionalProperties: false,
required: [
"title", "tasks"
],
properties: {
title: {
type: "string",
title: "Tasks list title",
},
tasks: {
type: "array",
title: "Tasks list",
items: {
type: "object",
properties: {
done: {
type: "boolean",
title: "Done?",
description: "Is that task done already?"
},
title: {
type: "string",
title: "Title",
description: "The task title.",
minLength: 1
}
}
}
}
}
},
formData: {
title: "My tasks",
tasks: [
{title: "Enjoying JSONSchema", done: true},
{title: "Enjoying React", done: true},
{title: "Enjoying react-jsonschema-form", done: false},
]
},
onSubmit: console.log.bind(console, "submit"),
onError: console.log.bind(console, "errors")
};
39 changes: 39 additions & 0 deletions fixtures/Form/nested-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
schema: {
title: "Todo Tasks",
description: "Tasks collection.",
type: "object",
additionalProperties: false,
required: [
"title", "tasks"
],
properties: {
title: {
type: "string",
title: "Tasks list title",
},
tasks: {
type: "array",
title: "Tasks list",
items: {
type: "object",
properties: {
done: {
type: "boolean",
title: "Done?",
description: "Is that task done already?"
},
title: {
type: "string",
title: "Title",
description: "The task title.",
minLength: 1
}
}
}
}
}
},
onSubmit: console.log.bind(console, "submit"),
onError: console.log.bind(console, "errors")
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ module.exports = {
formData: {
title: "My task",
done: true
}
},
onSubmit: console.log.bind(console, "submit"),
onError: console.log.bind(console, "errors")
};
4 changes: 3 additions & 1 deletion fixtures/Form/index.js → fixtures/Form/simple-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ module.exports = {
default: "default value"
}
}
}
},
onSubmit: console.log.bind(console, "submit"),
onError: console.log.bind(console, "errors")
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ module.exports = {
minLength: 1
}
}
}
},
onSubmit: console.log.bind(console, "submit"),
onError: console.log.bind(console, "errors")
};
11 changes: 11 additions & 0 deletions fixtures/fields/ArrayField/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
schema: {
type: "array",
title: "title",
items: {
type: "string",
title: "item"
}
},
onChange: console.log.bind(console)
};
12 changes: 12 additions & 0 deletions fixtures/fields/ArrayField/with-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
schema: {
type: "array",
title: "title",
default: ["default1", "default2"],
items: {
type: "string",
title: "item"
}
},
onChange: console.log.bind(console)
};
12 changes: 12 additions & 0 deletions fixtures/fields/ArrayField/with-formData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
schema: {
type: "array",
title: "title",
items: {
type: "string",
title: "item"
}
},
formData: ["item1", "item2"],
onChange: console.log.bind(console)
};
7 changes: 7 additions & 0 deletions fixtures/fields/BooleanField/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
schema: {
type: "boolean",
title: "My boolean",
},
onChange: console.log.bind(console)
};
8 changes: 8 additions & 0 deletions fixtures/fields/BooleanField/with-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
schema: {
type: "boolean",
title: "My boolean",
default: true,
},
onChange: console.log.bind(console)
};
8 changes: 8 additions & 0 deletions fixtures/fields/BooleanField/with-formData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
schema: {
type: "boolean",
title: "My boolean",
},
formData: true,
onChange: console.log.bind(console)
};
17 changes: 17 additions & 0 deletions fixtures/fields/ObjectField/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
schema: {
type: "object",
title: "object title",
properties: {
string: {
type: "string",
title: "string"
},
bool: {
type: "boolean",
title: "bool"
}
}
},
onChange: console.log.bind(console)
};
21 changes: 21 additions & 0 deletions fixtures/fields/ObjectField/with-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
schema: {
type: "object",
title: "object title",
default: {
string: "a default string",
bool: true
},
properties: {
string: {
type: "string",
title: "string"
},
bool: {
type: "boolean",
title: "bool"
}
}
},
onChange: console.log.bind(console)
};
21 changes: 21 additions & 0 deletions fixtures/fields/ObjectField/with-formData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
schema: {
type: "object",
title: "object title",
properties: {
string: {
type: "string",
title: "string"
},
bool: {
type: "boolean",
title: "bool"
}
}
},
formData: {
string: "an existing string",
bool: true
},
onChange: console.log.bind(console)
};
11 changes: 11 additions & 0 deletions fixtures/fields/SchemaField/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
schema: {
type: "array",
title: "title",
items: {
type: "string",
title: "item"
}
},
onChange: console.log.bind(console)
};
7 changes: 7 additions & 0 deletions fixtures/fields/SchemaField/boolean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
schema: {
type: "boolean",
title: "My boolean",
},
onChange: console.log.bind(console)
};
6 changes: 6 additions & 0 deletions fixtures/fields/SchemaField/date-time.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
schema: {
type: "date-time",
title: "date-time"
}
};
6 changes: 6 additions & 0 deletions fixtures/fields/SchemaField/number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
schema: {
type: "number",
title: "number"
}
};
17 changes: 17 additions & 0 deletions fixtures/fields/SchemaField/object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
schema: {
type: "object",
title: "object title",
properties: {
string: {
type: "string",
title: "string"
},
bool: {
type: "boolean",
title: "bool"
}
}
},
onChange: console.log.bind(console)
};
6 changes: 6 additions & 0 deletions fixtures/fields/SchemaField/string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
schema: {
type: "string",
title: "string"
}
};
6 changes: 6 additions & 0 deletions fixtures/fields/StringField/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
schema: {
type: "string",
title: "string"
}
};
7 changes: 7 additions & 0 deletions fixtures/fields/StringField/with-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
schema: {
type: "string",
title: "string",
default: "a default string"
}
};
7 changes: 7 additions & 0 deletions fixtures/fields/StringField/with-formData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
schema: {
type: "string",
title: "string",
},
formData: "an existing string"
};
6 changes: 6 additions & 0 deletions fixtures/fields/UnsupportedField/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
schema: {
type: "non-existent",
title: "blah"
}
};
5 changes: 5 additions & 0 deletions fixtures/widgets/CheckboxWidget/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
type: "boolean",
label: "foo",
onChange: console.log.bind(console)
};
7 changes: 7 additions & 0 deletions fixtures/widgets/RadioWidget/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
type: "string",
label: "foo",
defaultValue: "b",
options: ["a", "b"],
onChange: console.log.bind(console)
};
6 changes: 6 additions & 0 deletions fixtures/widgets/SelectWidget/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
type: "string",
label: "foo",
options: ["foo", "bar", "baz"],
onChange: console.log.bind(console)
};
6 changes: 6 additions & 0 deletions fixtures/widgets/TextWidget/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
type: "string",
label: "foo",
value: "plop",
onChange: console.log.bind(console)
};
8 changes: 8 additions & 0 deletions fixtures/widgets/Wrapper/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var React = require("react");

module.exports = {
type: "string",
label: "foo",
required: true,
children: React.createElement("div", {}, "content")
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.2.0",
"description": "A simple React component capable of building HTML forms out of a JSON schema.",
"scripts": {
"dist": "babel -d lib/ src/ && rimraf dist && webpack --config webpack.config.dist.js --optimize-minimize",
"build:lib": "rimraf lib && babel -d lib/ src/",
"build:dist": "rimraf dist && webpack --config webpack.config.dist.js --optimize-minimize",
"dist": "npm run build:lib && npm run build:dist",
"lint": "eslint src test",
"publish": "npm run dist && npm publish",
"start": "node devServer.js",
Expand Down
Loading

0 comments on commit 29b2bc8

Please sign in to comment.