Skip to content

Commit

Permalink
upgrade to 0.6.9 and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Jan 2, 2019
1 parent 3771f16 commit b0a8e91
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 19 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

## 0.6.9 - 2019-01-02
### Added

### Changed
- Support objects in selects #153. Thanks @naeemba
- Remove peer dependancy on a fixed version of material-ui #154. Thanks @psamim


## 0.6.8 - 2018-12-31
### Added

Expand Down
11 changes: 9 additions & 2 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5899,14 +5899,14 @@ react-lifecycles-compat@^3.0.2, react-lifecycles-compat@^3.0.4:
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"

"react-schema-form@file:..":
version "0.6.2"
version "0.6.8"
dependencies:
classnames "^2.2.6"
lodash "^4.17.11"
notevil "^1.1.0"
objectpath "1.2.2"
react-autosuggest "^9.3.4"
supports-color "^5.4.0"
supports-color "^6.0.0"
tv4 "^1.2.7"
webpack-config "^7.5.0"

Expand Down Expand Up @@ -6810,6 +6810,13 @@ supports-color@^5.1.0, supports-color@^5.3.0, supports-color@^5.4.0, supports-co
dependencies:
has-flag "^3.0.0"

supports-color@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a"
integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==
dependencies:
has-flag "^3.0.0"

[email protected]:
version "1.0.4"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
Expand Down
75 changes: 60 additions & 15 deletions lib/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,45 @@ var Select = function (_Component) {
var _this = _possibleConstructorReturn(this, (Select.__proto__ || Object.getPrototypeOf(Select)).call(this, props));

_this.onSelected = function (event) {
var onChangeValidate = _this.props.onChangeValidate;
var _this$props = _this.props,
onChangeValidate = _this$props.onChangeValidate,
onChange = _this$props.onChange,
_this$props$form = _this$props.form,
key = _this$props$form.key,
_this$props$form$sche = _this$props$form.schema,
isObject = _this$props$form$sche.isObject,
values = _this$props$form$sche.enum,
findFn = _this$props$form$sche.findFn;

var currentValue = event.target.value;
_this.setState({ currentValue: currentValue });
onChangeValidate(event);
if (isObject) {
var item = values.find(function (each) {
return findFn ? findFn(each, currentValue) : each === currentValue;
});
onChange(key, item);
} else {
onChangeValidate(event);
}
};

var _this$props = _this.props,
model = _this$props.model,
form = _this$props.form;
_this.getLabel = function (each) {
var _this$props2 = _this.props,
_this$props2$form$sch = _this$props2.form.schema,
displayFn = _this$props2$form$sch.displayFn,
noLocalization = _this$props2$form$sch.noLocalization,
getLocalizedString = _this$props2.localization.getLocalizedString;

if (displayFn) {
return displayFn(each);
}
if (noLocalization) return each.name;
return getLocalizedString(each.name);
};

var _this$props3 = _this.props,
model = _this$props3.model,
form = _this$props3.form;

_this.state = {
currentValue: _utils2.default.getValueFromModel(model, form.key) || ""
Expand All @@ -71,21 +100,37 @@ var Select = function (_Component) {
_createClass(Select, [{
key: "render",
value: function render() {
var _this2 = this;

var _props = this.props,
form = _props.form,
getLocalizedString = _props.localization.getLocalizedString;
var currentValue = this.state.currentValue;

var menuItems = form.titleMap.map(function (item, idx) {
return (
// eslint-disable-next-line react/no-array-index-key
_react2.default.createElement(
_MenuItem2.default,
{ key: idx, value: item.value },
item.name && getLocalizedString(item.name)
)
);
});
var menuItems = [];
if (form.schema.isObject) {
menuItems = form.schema.enum.map(function (item, idx) {
return (
// eslint-disable-next-line react/no-array-index-key
_react2.default.createElement(
_MenuItem2.default,
{ key: idx, value: item },
_this2.getLabel(item)
)
);
});
} else {
menuItems = form.titleMap.map(function (item, idx) {
return (
// eslint-disable-next-line react/no-array-index-key
_react2.default.createElement(
_MenuItem2.default,
{ key: idx, value: item.value },
_this2.getLabel(item)
)
);
});
}
return _react2.default.createElement(
_FormControl2.default,
{ fullWidth: true },
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ var select = function select(name, schema, options) {
var f = stdFormObj(name, schema, options);
f.key = options.path;
f.type = "select";
if (!f.titleMap) {
if (!f.titleMap && !schema.isObject) {
f.titleMap = enumToTitleMap(schema.enum);
}
options.lookup[_objectpath2.default.stringify(options.path)] = f;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-schema-form",
"version": "0.6.8",
"version": "0.6.9",
"description": "React json schema form",
"keywords": [
"json schema",
Expand Down

0 comments on commit b0a8e91

Please sign in to comment.