Skip to content

Commit

Permalink
upgrade to 0.6.7 and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Dec 26, 2018
1 parent df436f7 commit ca14fcb
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 133 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

## 0.6.7 - 2018-12-25
### Added
- Render custom labels for required fields #146. Thanks @naeemba

### Changed

## 0.6.6 - 2018-12-23
### Added
- Add support for localization #144. Thanks @naeemba
Expand Down
14 changes: 7 additions & 7 deletions lib/Array.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ var _Close = require("@material-ui/icons/Close");

var _Close2 = _interopRequireDefault(_Close);

var _Typography = require("@material-ui/core/Typography");

var _Typography2 = _interopRequireDefault(_Typography);

var _cloneDeep = require("lodash/cloneDeep");

var _cloneDeep2 = _interopRequireDefault(_cloneDeep);

var _FormLabel = require("@material-ui/core/FormLabel");

var _FormLabel2 = _interopRequireDefault(_FormLabel);

var _utils = require("./utils");

var _utils2 = _interopRequireDefault(_utils);
Expand Down Expand Up @@ -182,9 +182,9 @@ var Array = function (_Component) {
"div",
null,
_react2.default.createElement(
_Typography2.default,
{ variant: "h6" },
getLocalizedString(form.title)
_FormLabel2.default,
{ variant: "h6", required: form.required },
form.title && getLocalizedString(form.title)
),
_react2.default.createElement(
"div",
Expand Down
2 changes: 1 addition & 1 deletion lib/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var FormCheckbox = function FormCheckbox(_ref) {
{ row: true },
_react2.default.createElement(_FormControlLabel2.default, {
className: form.className,
label: getLocalizedString(form.title),
label: form.title && getLocalizedString(form.title),
control: _react2.default.createElement(_Checkbox2.default, {
name: form.key.slice(-1)[0],
value: form.key.slice(-1)[0],
Expand Down
4 changes: 2 additions & 2 deletions lib/FieldSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var FieldSet = function FieldSet(_ref) {
{ component: "fieldset", className: classes.root },
_react2.default.createElement(
_FormLabel2.default,
{ component: "legend" },
getLocalizedString(form.title)
{ component: "legend", required: form.required },
form.title && getLocalizedString(form.title)
),
_react2.default.createElement(
"div",
Expand Down
10 changes: 5 additions & 5 deletions lib/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,23 @@ var MultiSelect = function (_Component) {
value: item.value,
className: currentValue.indexOf(item.value) === -1 ? classes.menuItem : classes.selectedMenuItem
},
getLocalizedString(item.name)
item.name && getLocalizedString(item.name)
);
});
return _react2.default.createElement(
_FormControl2.default,
{ fullWidth: true },
_react2.default.createElement(
_InputLabel2.default,
null,
getLocalizedString(form.title)
{ required: form.required },
form.title && getLocalizedString(form.title)
),
_react2.default.createElement(
_Select2.default,
{
multiple: true,
value: currentValue || "",
placeholder: getLocalizedString(form.title),
placeholder: form.placeholder && getLocalizedString(form.placeholder),
disabled: form.readonly,
onChange: this.onSelected,
MenuProps: MenuProps,
Expand All @@ -152,7 +152,7 @@ var MultiSelect = function (_Component) {
selected.map(function (value) {
return _react2.default.createElement(_Chip2.default, {
key: value,
label: getLocalizedString(getTitle(value)),
label: getTitle(value) && getLocalizedString(getTitle(value)),
className: classes.chip
});
})
Expand Down
41 changes: 20 additions & 21 deletions lib/NativeDateField.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,34 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
/*
Native date field.
Contains common logic for final components Date and DateTime.
*/


var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _TextField = require("@material-ui/core/TextField");
var _Text = require("./Text");

var _TextField2 = _interopRequireDefault(_TextField);
var _Text2 = _interopRequireDefault(_Text);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/*
Native date field.
Contains common logic for final components Date and DateTime.
*/
var NativeDateField = function NativeDateField(_ref) {
var form = _ref.form,
value = _ref.value,
type = _ref.type,
onChangeValidate = _ref.onChangeValidate,
_ref$localization = _ref.localization,
getLocalizedString = _ref$localization.getLocalizedString,
getLocalizedDate = _ref$localization.getLocalizedDate;
return _react2.default.createElement(_TextField2.default, {
label: getLocalizedString(form.title),
type: type,
var NativeDateField = function NativeDateField(props) {
var value = props.value,
getLocalizedDate = props.localization.getLocalizedDate,
form = props.form,
type = props.type;

return _react2.default.createElement(_Text2.default, _extends({}, props, {
form: Object.assign({}, form, { type: type }),
value: getLocalizedDate(value),
InputLabelProps: { shrink: true },
onChange: onChangeValidate,
disabled: form.readonly
});
otherProps: { InputLabelProps: { shrink: true } }
}));
};

exports.default = NativeDateField;
71 changes: 18 additions & 53 deletions lib/Number.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,42 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _FormControl = require("@material-ui/core/FormControl");

var _FormControl2 = _interopRequireDefault(_FormControl);

var _FormHelperText = require("@material-ui/core/FormHelperText");

var _FormHelperText2 = _interopRequireDefault(_FormHelperText);

var _Input = require("@material-ui/core/Input");
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
/**
* Created by steve on 15/09/15.
*/

var _Input2 = _interopRequireDefault(_Input);

var _InputLabel = require("@material-ui/core/InputLabel");
var _react = require("react");

var _InputLabel2 = _interopRequireDefault(_InputLabel);
var _react2 = _interopRequireDefault(_react);

var _ComposedComponent = require("./ComposedComponent");

var _ComposedComponent2 = _interopRequireDefault(_ComposedComponent);

var _Text = require("./Text");

var _Text2 = _interopRequireDefault(_Text);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* There is no default number picker as part of Material-UI.
* Instead, use a TextField and validate.
*/

/**
* Created by steve on 15/09/15.
*/
var NumberComponent = function NumberComponent(_ref) {
var form = _ref.form,
error = _ref.error,
onChangeValidate = _ref.onChangeValidate,
value = _ref.value,
_ref$localization = _ref.localization,
getLocalizedString = _ref$localization.getLocalizedString,
getLocalizedNumber = _ref$localization.getLocalizedNumber;
var NumberComponent = function NumberComponent(props) {
var form = props.form,
value = props.value,
getLocalizedNumber = props.localization.getLocalizedNumber;

var inputValue = value || value === 0 ? value : "";
if (form.useLocalizer) inputValue = getLocalizedNumber(inputValue);

return _react2.default.createElement(
_FormControl2.default,
{ fullWidth: true, error: !!error },
_react2.default.createElement(
_InputLabel2.default,
{
htmlFor: "input-" + form.key[0],
required: form.required
},
getLocalizedString(form.title)
),
_react2.default.createElement(_Input2.default, {
id: "input-" + form.key[0],
type: "string",
placeholder: getLocalizedString(form.placeholder),
onChange: onChangeValidate,
value: inputValue,
disabled: form.readonly
}),
Boolean(error || form.description) && _react2.default.createElement(
_FormHelperText2.default,
null,
getLocalizedString(error || form.description)
)
);
return _react2.default.createElement(_Text2.default, _extends({}, props, {
form: Object.assign({}, form, { type: "string" }),
value: inputValue
}));
};

exports.default = (0, _ComposedComponent2.default)(NumberComponent);
6 changes: 3 additions & 3 deletions lib/Radios.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var Radios = function (_Component) {
// eslint-disable-next-line react/no-array-index-key
, { key: index,
control: _react2.default.createElement(_Radio2.default, null),
label: getLocalizedString(item.name),
label: item.name && getLocalizedString(item.name),
value: item.value,
disabled: form.readonly
});
Expand All @@ -100,8 +100,8 @@ var Radios = function (_Component) {
{ component: "fieldset", className: classes.formControl },
_react2.default.createElement(
_FormLabel2.default,
{ component: "legend" },
getLocalizedString(form.title)
{ component: "legend", required: form.required },
form.title && getLocalizedString(form.title)
),
_react2.default.createElement(
_RadioGroup2.default,
Expand Down
8 changes: 4 additions & 4 deletions lib/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var Select = function (_Component) {
_react2.default.createElement(
_MenuItem2.default,
{ key: idx, value: item.value },
getLocalizedString(item.name)
item.name && getLocalizedString(item.name)
)
);
});
Expand All @@ -91,14 +91,14 @@ var Select = function (_Component) {
{ fullWidth: true },
_react2.default.createElement(
_InputLabel2.default,
null,
getLocalizedString(form.title)
{ required: form.required },
form.title && getLocalizedString(form.title)
),
_react2.default.createElement(
_Select2.default,
{
value: currentValue || "",
placeholder: getLocalizedString(form.title),
placeholder: form.placeholder && getLocalizedString(form.placeholder),
disabled: form.readonly,
onChange: this.onSelected
},
Expand Down
21 changes: 14 additions & 7 deletions lib/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require("react");
Expand Down Expand Up @@ -57,23 +59,28 @@ var Text = function (_React$Component) {
error = _props.error,
value = _props.value,
onChangeValidate = _props.onChangeValidate,
getLocalizedString = _props.localization.getLocalizedString;
getLocalizedString = _props.localization.getLocalizedString,
otherProps = _props.otherProps;

return _react2.default.createElement(_TextField2.default, {
return _react2.default.createElement(_TextField2.default, _extends({
type: form.type,
label: getLocalizedString(form.title),
placeholder: getLocalizedString(form.placeholder),
helperText: getLocalizedString(error || form.description),
label: form.title && getLocalizedString(form.title),
placeholder: form.placeholder && getLocalizedString(form.placeholder),
helperText: (error || form.description) && getLocalizedString(error || form.description),
error: !!error,
onChange: onChangeValidate,
value: value || "",
disabled: form.readonly,
fullWidth: true
});
fullWidth: true,
required: form.required
}, otherProps));
}
}]);

return Text;
}(_react2.default.Component);

Text.defaultProps = {
otherProps: undefined
};
exports.default = (0, _ComposedComponent2.default)(Text);
Loading

0 comments on commit ca14fcb

Please sign in to comment.