Skip to content

Commit

Permalink
Merge pull request #30 from mozilla-services/namespace-uiSchema-widget
Browse files Browse the repository at this point in the history
Renamed uiSchema widget to ui:widget to avoid name collisions.
  • Loading branch information
n1k0 committed Jan 9, 2016
2 parents 2998175 + 526e06f commit 7bfbea6
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ That should give something like this (if you use the default stylesheet):

### Alternative widgets

JSONSchema is limited for describing how a given data type should be rendered as an input component, that's why this lib introduces the concept of *UI schema*. A UI schema is basically an object literal describing which UI widget should be used to render a certain field.
JSONSchema is limited for describing how a given data type should be rendered as an input component, that's why this lib introduces the concept of *UI schema*. A UI schema is basically an object literal describing how the form should be rendered, eg. which UI widget should be used to render a certain field thanks to the `ui:widget` property:

Example:

```jsx
const uiSchema =  {
done: {
widget: "radio" // could also be "select"
"ui:widget": "radio" // could also be "select"
}
};

Expand Down Expand Up @@ -176,7 +176,7 @@ const schema = {
};

const uiSchema = {
widget: (props) => {
"ui:widget": (props) => {
return (
<input type="text"
className="custom"
Expand Down
2 changes: 1 addition & 1 deletion playground/samples/nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
tasks: {
items: {
details: {
widget: "textarea"
"ui:widget": "textarea"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions playground/samples/numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ module.exports = {
},
uiSchema: {
integer: {
widget: "updown"
"ui:widget": "updown"
},
integerRange: {
widget: "range"
"ui:widget": "range"
},
integerRangeSteps: {
widget: "range"
"ui:widget": "range"
}
},
formData: {
Expand Down
6 changes: 3 additions & 3 deletions playground/samples/ordering.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ module.exports = {
uiSchema: {
"ui:order": ["firstName", "lastName", "age", "bio", "password"],
age: {
widget: "updown"
"ui:widget": "updown"
},
bio: {
widget: "textarea"
"ui:widget": "textarea"
},
password: {
widget: "password"
"ui:widget": "password"
}
},
formData: {
Expand Down
6 changes: 3 additions & 3 deletions playground/samples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ module.exports = {
},
uiSchema: {
age: {
widget: "updown"
"ui:widget": "updown"
},
bio: {
widget: "textarea"
"ui:widget": "textarea"
},
password: {
widget: "password"
"ui:widget": "password"
}
},
formData: {
Expand Down
6 changes: 3 additions & 3 deletions playground/samples/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ module.exports = {
uiSchema: {
boolean: {
radio: {
widget: "radio"
"ui:widget": "radio"
},
select: {
widget: "select"
"ui:widget": "select"
}
},
string: {
textarea: {
widget: "textarea"
"ui:widget": "textarea"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/fields/BooleanField.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CheckboxWidget from "./../widgets/CheckboxWidget";

function BooleanField({schema, name, uiSchema, formData, required, onChange}) {
const {title, description} = schema;
const {widget} = uiSchema;
const widget = uiSchema["ui:widget"];
const commonProps = {
schema,
onChange,
Expand Down
2 changes: 1 addition & 1 deletion src/components/fields/StringField.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SelectWidget from "./../widgets/SelectWidget";

function StringField({schema, name, uiSchema, formData, required, onChange}) {
const {title, description} = schema;
const {widget} = uiSchema;
const widget = uiSchema["ui:widget"];
const commonProps = {
schema,
label: title || name,
Expand Down
20 changes: 10 additions & 10 deletions test/index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ describe("Form", () => {
};

const uiSchema = {
widget: (props) => {
"ui:widget": (props) => {
return (
<input type="text"
className="custom"
Expand Down Expand Up @@ -637,7 +637,7 @@ describe("Form", () => {
describe("textarea", () => {
const uiSchema = {
foo: {
widget: "textarea"
"ui:widget": "textarea"
}
};

Expand Down Expand Up @@ -673,7 +673,7 @@ describe("Form", () => {
describe("password", () => {
const uiSchema = {
foo: {
widget: "password"
"ui:widget": "password"
}
};

Expand Down Expand Up @@ -721,7 +721,7 @@ describe("Form", () => {
describe("radio", () => {
const uiSchema = {
foo: {
widget: "radio"
"ui:widget": "radio"
}
};

Expand Down Expand Up @@ -768,7 +768,7 @@ describe("Form", () => {
describe("updown", () => {
const uiSchema = {
foo: {
widget: "updown"
"ui:widget": "updown"
}
};

Expand Down Expand Up @@ -804,7 +804,7 @@ describe("Form", () => {
describe("range", () => {
const uiSchema = {
foo: {
widget: "range"
"ui:widget": "range"
}
};

Expand Down Expand Up @@ -851,7 +851,7 @@ describe("Form", () => {
describe("updown", () => {
const uiSchema = {
foo: {
widget: "updown"
"ui:widget": "updown"
}
};

Expand Down Expand Up @@ -887,7 +887,7 @@ describe("Form", () => {
describe("range", () => {
const uiSchema = {
foo: {
widget: "range"
"ui:widget": "range"
}
};

Expand Down Expand Up @@ -934,7 +934,7 @@ describe("Form", () => {
describe("radio", () => {
const uiSchema = {
foo: {
widget: "radio"
"ui:widget": "radio"
}
};

Expand Down Expand Up @@ -996,7 +996,7 @@ describe("Form", () => {
describe("select", () => {
const uiSchema = {
foo: {
widget: "select"
"ui:widget": "select"
}
};

Expand Down

0 comments on commit 7bfbea6

Please sign in to comment.