Comparing version 0.14.1 to 0.15.0-beta.0
# History | ||
---- | ||
## 0.15.0 / 2016-03-28 | ||
- add getValueFromEvent/getValueProps | ||
## 0.14.0 / 2016-02-27 | ||
@@ -4,0 +10,0 @@ |
@@ -19,3 +19,3 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -43,3 +43,3 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function decorate(WrappedComponent) { | ||
var Form = _react2.default.createClass({ | ||
var Form = _react2["default"].createClass({ | ||
displayName: 'Form', | ||
@@ -50,3 +50,3 @@ | ||
getInitialState: function getInitialState() { | ||
var fields = undefined; | ||
var fields = void 0; | ||
if (mapPropsToFields) { | ||
@@ -85,3 +85,3 @@ fields = mapPropsToFields(this.props); | ||
} | ||
var value = (0, _utils.getValueFromEvent)(event); | ||
var value = fieldMeta.getValueFromEvent ? fieldMeta.getValueFromEvent(event) : (0, _utils.getValueFromEvent)(event); | ||
var field = this.getField(name, true); | ||
@@ -98,3 +98,3 @@ this.setFields(_defineProperty({}, name, _extends({}, field, { | ||
} | ||
var value = (0, _utils.getValueFromEvent)(event); | ||
var value = fieldMeta.getValueFromEvent ? fieldMeta.getValueFromEvent(event) : (0, _utils.getValueFromEvent)(event); | ||
var field = this.getField(name, true); | ||
@@ -139,2 +139,7 @@ field.value = value; | ||
var fieldOption = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
if (!name) { | ||
throw new Error('must call getFieldProps with valid name string!'); | ||
} | ||
var rules = fieldOption.rules; | ||
@@ -145,2 +150,3 @@ var _fieldOption$trigger = fieldOption.trigger; | ||
var valuePropName = _fieldOption$valuePro === undefined ? 'value' : _fieldOption$valuePro; | ||
var getValueProps = fieldOption.getValueProps; | ||
var _fieldOption$validate = fieldOption.validateTrigger; | ||
@@ -158,3 +164,3 @@ var validateTrigger = _fieldOption$validate === undefined ? defaultValidateTrigger : _fieldOption$validate; | ||
var inputProps = _defineProperty({}, valuePropName, fieldMeta.initialValue); | ||
var inputProps = {}; | ||
@@ -200,5 +206,11 @@ if (fieldNameProp) { | ||
var field = this.getField(name); | ||
var fieldValue = fieldMeta.initialValue; | ||
if (field && 'value' in field) { | ||
inputProps[valuePropName] = field.value; | ||
fieldValue = field.value; | ||
} | ||
if (getValueProps) { | ||
inputProps = _extends({}, inputProps, getValueProps(fieldValue)); | ||
} else { | ||
inputProps[valuePropName] = fieldValue; | ||
} | ||
@@ -390,3 +402,3 @@ inputProps.ref = this.getCacheBind(name, name + '__ref', this.saveRef); | ||
} | ||
var validator = new _asyncValidator2.default(allRules); | ||
var validator = new _asyncValidator2["default"](allRules); | ||
if (validateMessages) { | ||
@@ -539,3 +551,3 @@ validator.messages(validateMessages); | ||
var props = mapProps.call(this, _extends({}, formProps, this.props)); | ||
return _react2.default.createElement(WrappedComponent, props); | ||
return _react2["default"].createElement(WrappedComponent, props); | ||
} | ||
@@ -550,3 +562,3 @@ }); | ||
exports.default = createBaseForm; | ||
exports["default"] = createBaseForm; | ||
module.exports = exports['default']; |
@@ -25,3 +25,3 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -54,3 +54,3 @@ function computedStyle(el, prop) { | ||
var node = n; | ||
var nodeName = undefined; | ||
var nodeName = void 0; | ||
/* eslint no-cond-assign:0 */ | ||
@@ -83,7 +83,7 @@ while ((nodeName = node.nodeName.toLowerCase()) !== 'body') { | ||
if (error) { | ||
var firstNode = undefined; | ||
var firstTop = undefined; | ||
var firstNode = void 0; | ||
var firstTop = void 0; | ||
for (var name in error) { | ||
if (error.hasOwnProperty(name) && error[name].instance) { | ||
var node = _reactDom2.default.findDOMNode(error[name].instance); | ||
var node = _reactDom2["default"].findDOMNode(error[name].instance); | ||
var top = node.getBoundingClientRect().top; | ||
@@ -98,3 +98,3 @@ if (firstTop === undefined || firstTop > top) { | ||
var c = options.container || getScrollableContainer(firstNode); | ||
(0, _domScrollIntoView2.default)(firstNode, c, { | ||
(0, _domScrollIntoView2["default"])(firstNode, c, { | ||
onlyScrollIfNeeded: true | ||
@@ -115,6 +115,6 @@ }); | ||
function createDOMForm(option) { | ||
return (0, _createBaseForm2.default)(_extends({}, option), [mixin]); | ||
return (0, _createBaseForm2["default"])(_extends({}, option), [mixin]); | ||
} | ||
exports.default = createDOMForm; | ||
exports["default"] = createDOMForm; | ||
module.exports = exports['default']; |
@@ -12,3 +12,3 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -37,5 +37,5 @@ var mixin = exports.mixin = { | ||
function createForm(options) { | ||
return (0, _createBaseForm2.default)(options, [mixin]); | ||
return (0, _createBaseForm2["default"])(options, [mixin]); | ||
} | ||
exports.default = createForm; | ||
exports["default"] = createForm; |
@@ -12,4 +12,4 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
exports.createForm = _createForm2.default; // export this package's api | ||
exports.createForm = _createForm2["default"]; // export this package's api |
@@ -19,3 +19,3 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -30,3 +30,3 @@ function getDisplayName(WrappedComponent) { | ||
Container.WrappedComponent = WrappedComponent; | ||
return (0, _hoistNonReactStatics2.default)(Container, WrappedComponent); | ||
return (0, _hoistNonReactStatics2["default"])(Container, WrappedComponent); | ||
} | ||
@@ -33,0 +33,0 @@ |
@@ -104,4 +104,4 @@ { | ||
{ | ||
"name": "mjackson", | ||
"email": "mjijackson@gmail.com" | ||
"email": "mjijackson@gmail.com", | ||
"name": "mjackson" | ||
} | ||
@@ -108,0 +108,0 @@ ], |
{ | ||
"name": "rc-form", | ||
"version": "0.14.1", | ||
"version": "0.15.0-beta.0", | ||
"description": "React High Order Form Component", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -110,4 +110,28 @@ # rc-form | ||
Prop name of component's value field, eg: checkbox should be set ti `checked` ... | ||
Prop name of component's value field, eg: checkbox should be set to `checked` ... | ||
#### option.getValueFromEvent | ||
Specify how to get value from event. Defaults to | ||
```js | ||
function (e) { | ||
if (!e || !e.target) { | ||
return e; | ||
} | ||
const { target } = e; | ||
return target.type === 'checkbox' ? target.checked : target.value; | ||
} | ||
``` | ||
#### option.getValueProps | ||
get the component props according to field value. Defaults to | ||
```js | ||
function (value) { | ||
return { value }; | ||
} | ||
``` | ||
#### option.initialValue | ||
@@ -114,0 +138,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
260293
4912
294