redux-form
Advanced tools
Comparing version 6.0.0-alpha.10 to 6.0.0-alpha.11
@@ -123,3 +123,3 @@ import { createSpy } from 'expect'; | ||
it('should read sync errors from state', function () { | ||
it('should read sync errors from param', function () { | ||
var noErrorResult = createFieldProps(getIn, 'foo', { | ||
@@ -253,2 +253,9 @@ initial: 'bar', | ||
it('should default value to [] for multi-selects', function () { | ||
expect(createFieldProps(getIn, 'foo', { | ||
state: empty, | ||
type: 'select-multiple' | ||
}).value).toBeA('array').toEqual([]); | ||
}); | ||
it('should replace undefined value with empty string', function () { | ||
@@ -255,0 +262,0 @@ var result = createFieldProps(getIn, 'foo', { |
@@ -209,2 +209,54 @@ 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; }; | ||
it('should provide sync error for array field', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
foo: ['bar'] | ||
} | ||
} | ||
}); | ||
var input = createSpy(function (props) { | ||
return React.createElement('input', props); | ||
}).andCallThrough(); | ||
var validate = function validate() { | ||
return { foo: ['bar error'] }; | ||
}; | ||
var Form = function (_Component3) { | ||
_inherits(Form, _Component3); | ||
function Form() { | ||
_classCallCheck(this, Form); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Form).apply(this, arguments)); | ||
} | ||
_createClass(Form, [{ | ||
key: 'render', | ||
value: function render() { | ||
return React.createElement( | ||
'div', | ||
null, | ||
React.createElement(Field, { name: 'foo[0]', component: input }) | ||
); | ||
} | ||
}]); | ||
return Form; | ||
}(Component); | ||
var TestForm = reduxForm({ | ||
form: 'testForm', | ||
validate: validate | ||
})(Form); | ||
TestUtils.renderIntoDocument(React.createElement( | ||
Provider, | ||
{ store: store }, | ||
React.createElement(TestForm, null) | ||
)); | ||
expect(input).toHaveBeenCalled(); | ||
expect(input.calls[0].arguments[0].valid).toBe(false); | ||
expect(input.calls[0].arguments[0].error).toBe('bar error'); | ||
}); | ||
it('should provide valid getter', function () { | ||
@@ -222,4 +274,4 @@ var store = makeStore({ | ||
var Form = function (_Component3) { | ||
_inherits(Form, _Component3); | ||
var Form = function (_Component4) { | ||
_inherits(Form, _Component4); | ||
@@ -265,4 +317,4 @@ function Form() { | ||
var Form = function (_Component4) { | ||
_inherits(Form, _Component4); | ||
var Form = function (_Component5) { | ||
_inherits(Form, _Component5); | ||
@@ -308,4 +360,4 @@ function Form() { | ||
var Form = function (_Component5) { | ||
_inherits(Form, _Component5); | ||
var Form = function (_Component6) { | ||
_inherits(Form, _Component6); | ||
@@ -362,4 +414,4 @@ function Form() { | ||
var Form = function (_Component6) { | ||
_inherits(Form, _Component6); | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
@@ -369,6 +421,6 @@ function Form() { | ||
var _this6 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this7 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this6.state = { field: 'foo' }; | ||
return _this6; | ||
_this7.state = { field: 'foo' }; | ||
return _this7; | ||
} | ||
@@ -379,3 +431,3 @@ | ||
value: function render() { | ||
var _this7 = this; | ||
var _this8 = this; | ||
@@ -389,3 +441,3 @@ return React.createElement( | ||
{ onClick: function onClick() { | ||
return _this7.setState({ field: 'bar' }); | ||
return _this8.setState({ field: 'bar' }); | ||
} }, | ||
@@ -426,4 +478,4 @@ 'Change' | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
var Form = function (_Component8) { | ||
_inherits(Form, _Component8); | ||
@@ -433,6 +485,6 @@ function Form() { | ||
var _this8 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this9 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this8.state = { foo: 'foo', bar: 'bar' }; | ||
return _this8; | ||
_this9.state = { foo: 'foo', bar: 'bar' }; | ||
return _this9; | ||
} | ||
@@ -443,3 +495,3 @@ | ||
value: function render() { | ||
var _this9 = this; | ||
var _this10 = this; | ||
@@ -453,3 +505,3 @@ return React.createElement( | ||
{ onClick: function onClick() { | ||
return _this9.setState({ foo: 'qux', bar: 'baz' }); | ||
return _this10.setState({ foo: 'qux', bar: 'baz' }); | ||
} }, | ||
@@ -456,0 +508,0 @@ 'Change' |
@@ -13,3 +13,4 @@ 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; }; | ||
import React, { Component } from 'react'; | ||
import { createSpy } from 'expect'; | ||
import domExpect, { createSpy } from 'expect'; | ||
import expectElement from 'expect-element'; | ||
import { Provider } from 'react-redux'; | ||
@@ -22,2 +23,3 @@ import { combineReducers as plainCombineReducers, createStore } from 'redux'; | ||
import createFieldArray from '../FieldArray'; | ||
import createField from '../Field'; | ||
import plain from '../structure/plain'; | ||
@@ -29,5 +31,8 @@ import plainExpectations from '../structure/plain/expectations'; | ||
domExpect.extend(expectElement); | ||
var describeFieldArray = function describeFieldArray(name, structure, combineReducers, expect) { | ||
var reduxForm = createReduxForm(structure); | ||
var FieldArray = createFieldArray(structure); | ||
var Field = createField(structure); | ||
var reducer = createReducer(structure); | ||
@@ -327,10 +332,20 @@ var fromJS = structure.fromJS; | ||
it('should provide name getter', function () { | ||
it('should provide sync error for array field', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
foo: 'bar' | ||
foo: [{ | ||
library: 'redux-form', | ||
author: 'erikras' | ||
}] | ||
} | ||
} | ||
}); | ||
var validate = function validate() { | ||
return { | ||
foo: [{ | ||
_error: 'Too awesome!' | ||
}] | ||
}; | ||
}; | ||
@@ -352,2 +367,67 @@ var Form = function (_Component6) { | ||
null, | ||
React.createElement(FieldArray, { name: 'foo', component: function component(array) { | ||
return React.createElement( | ||
'div', | ||
null, | ||
array.map(function (name, index) { | ||
return React.createElement( | ||
'div', | ||
{ key: index }, | ||
React.createElement(Field, { name: name + '.library', component: 'input' }), | ||
React.createElement(Field, { name: name + '.author', component: 'input' }), | ||
React.createElement(Field, { name: name, component: function component(props) { | ||
return React.createElement( | ||
'strong', | ||
null, | ||
props.error | ||
); | ||
} }) | ||
); | ||
}) | ||
); | ||
} }) | ||
); | ||
} | ||
}]); | ||
return Form; | ||
}(Component); | ||
var TestForm = reduxForm({ | ||
form: 'testForm', | ||
validate: validate | ||
})(Form); | ||
var dom = TestUtils.renderIntoDocument(React.createElement( | ||
Provider, | ||
{ store: store }, | ||
React.createElement(TestForm, null) | ||
)); | ||
var error = TestUtils.findRenderedDOMComponentWithTag(dom, 'strong'); | ||
domExpect(error).toExist().toHaveText('Too awesome!'); | ||
}); | ||
it('should provide name getter', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
foo: 'bar' | ||
} | ||
} | ||
}); | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
function Form() { | ||
_classCallCheck(this, Form); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Form).apply(this, arguments)); | ||
} | ||
_createClass(Form, [{ | ||
key: 'render', | ||
value: function render() { | ||
return React.createElement( | ||
'div', | ||
null, | ||
React.createElement(FieldArray, { name: 'foo', component: TestComponent }) | ||
@@ -384,4 +464,4 @@ ); | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
var Form = function (_Component8) { | ||
_inherits(Form, _Component8); | ||
@@ -391,6 +471,6 @@ function Form() { | ||
var _this7 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this8 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this7.state = { field: 'foo' }; | ||
return _this7; | ||
_this8.state = { field: 'foo' }; | ||
return _this8; | ||
} | ||
@@ -401,3 +481,3 @@ | ||
value: function render() { | ||
var _this8 = this; | ||
var _this9 = this; | ||
@@ -411,3 +491,3 @@ return React.createElement( | ||
{ onClick: function onClick() { | ||
return _this8.setState({ field: 'bar' }); | ||
return _this9.setState({ field: 'bar' }); | ||
} }, | ||
@@ -446,4 +526,4 @@ 'Change' | ||
var Form = function (_Component8) { | ||
_inherits(Form, _Component8); | ||
var Form = function (_Component9) { | ||
_inherits(Form, _Component9); | ||
@@ -453,6 +533,6 @@ function Form() { | ||
var _this9 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this10 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this9.state = { foo: 'foo', bar: 'bar' }; | ||
return _this9; | ||
_this10.state = { foo: 'foo', bar: 'bar' }; | ||
return _this10; | ||
} | ||
@@ -463,3 +543,3 @@ | ||
value: function render() { | ||
var _this10 = this; | ||
var _this11 = this; | ||
@@ -473,3 +553,3 @@ return React.createElement( | ||
{ onClick: function onClick() { | ||
return _this10.setState({ foo: 'qux', bar: 'baz' }); | ||
return _this11.setState({ foo: 'qux', bar: 'baz' }); | ||
} }, | ||
@@ -536,4 +616,4 @@ 'Change' | ||
var Form = function (_Component9) { | ||
_inherits(Form, _Component9); | ||
var Form = function (_Component10) { | ||
_inherits(Form, _Component10); | ||
@@ -540,0 +620,0 @@ function Form() { |
@@ -59,3 +59,3 @@ import createHasErrors from '../hasErrors'; | ||
it('should return true for an empty array with a _error key', function () { | ||
it('should return true for an empty array with a string error under _error key', function () { | ||
var errors = setIn(fromJS([]), '_error', 'oh no!'); | ||
@@ -67,2 +67,10 @@ if (getIn(errors, '_error') === 'oh no!') { | ||
}); | ||
it('should return true for an empty array with an object error under _error key', function () { | ||
var errors = setIn(fromJS([]), '_error', { complex: 'error' }); | ||
if (getIn(errors, '_error')) { | ||
// cannot work for Immutable Lists because you can not set a value under a string key | ||
expect(hasErrors(errors)).toBe(true); | ||
} | ||
}); | ||
}); | ||
@@ -69,0 +77,0 @@ }; |
@@ -6,3 +6,2 @@ require('babel-polyfill'); | ||
global.window = document.defaultView; | ||
global.navigator = global.window.navigator; | ||
global.navigator.product = 'NotReactNative'; | ||
global.navigator = global.window.navigator; |
@@ -70,3 +70,6 @@ import _mapValues from 'lodash-es/mapValues'; | ||
return plain.getIn(getSyncErrors(), name); | ||
var error = plain.getIn(getSyncErrors(), name); | ||
// Because the error for this field might not be at a level in the error structure where | ||
// it can be set directly, it might need to be unwrapped from the _error property | ||
return error && error._error ? error._error : error; | ||
} | ||
@@ -73,0 +76,0 @@ }, { |
@@ -15,3 +15,2 @@ import _mapValues from 'lodash-es/mapValues'; | ||
import React, { Component, PropTypes } from 'react'; | ||
import shallowCompare from 'react/lib/shallowCompare'; | ||
import { connect } from 'react-redux'; | ||
@@ -21,2 +20,3 @@ import createFieldArrayProps from './createFieldArrayProps'; | ||
import plain from './structure/plain'; | ||
import shallowCompare from 'react-addons-shallow-compare'; | ||
@@ -23,0 +23,0 @@ var createConnectedFieldArray = function createConnectedFieldArray(_ref, _ref2, name) { |
@@ -7,2 +7,3 @@ 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; }; | ||
import createFieldArray from './FieldArray'; | ||
import createFormValueSelector from './formValueSelector'; | ||
import createValues from './values'; | ||
@@ -14,5 +15,5 @@ import SubmissionError from './SubmissionError'; | ||
export default function createAll(structure) { | ||
// separate out field actions | ||
var createAll = function createAll(structure) { | ||
return _extends({ | ||
// separate out field actions | ||
actionTypes: actionTypes | ||
@@ -22,2 +23,3 @@ }, actions, { | ||
FieldArray: createFieldArray(structure), | ||
formValueSelector: createFormValueSelector(structure), | ||
propTypes: propTypes, | ||
@@ -29,2 +31,4 @@ reduxForm: createReduxForm(structure), | ||
}); | ||
} | ||
}; | ||
export default createAll; |
@@ -34,2 +34,8 @@ import _noop from 'lodash-es/noop'; | ||
} | ||
if (type === 'select-multiple') { | ||
return _extends({}, rest, { | ||
type: type, | ||
value: value || [] | ||
}); | ||
} | ||
return props; | ||
@@ -36,0 +42,0 @@ }; |
@@ -12,5 +12,5 @@ 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; }; | ||
import React, { Component, PropTypes } from 'react'; | ||
import shallowCompare from 'react/lib/shallowCompare'; | ||
import invariant from 'invariant'; | ||
import createConnectedField from './ConnectedField'; | ||
import shallowCompare from 'react-addons-shallow-compare'; | ||
@@ -17,0 +17,0 @@ var keys = 0; |
@@ -12,5 +12,5 @@ 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; }; | ||
import React, { Component, PropTypes } from 'react'; | ||
import shallowCompare from 'react/lib/shallowCompare'; | ||
import invariant from 'invariant'; | ||
import createConnectedFieldArray from './ConnectedFieldArray'; | ||
import shallowCompare from 'react-addons-shallow-compare'; | ||
@@ -17,0 +17,0 @@ var keys = 0; |
@@ -10,3 +10,3 @@ var createHasErrors = function createHasErrors(_ref) { | ||
var globalError = getIn(errors, '_error'); | ||
if (globalError && typeof globalError === 'string') { | ||
if (globalError) { | ||
return true; | ||
@@ -13,0 +13,0 @@ } |
@@ -14,2 +14,3 @@ import createAll from './createAll'; | ||
var focus = _createAll.focus; | ||
var formValueSelector = _createAll.formValueSelector; | ||
var reducer = _createAll.reducer; | ||
@@ -31,2 +32,2 @@ var reduxForm = _createAll.reduxForm; | ||
var values = _createAll.values; | ||
export { actionTypes, addArrayValue, blur, change, destroy, Field, FieldArray, focus, reducer, reduxForm, removeArrayValue, initialize, propTypes, reset, setSubmitFailed, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, SubmissionError, swapArrayValues, touch, untouch, values }; | ||
export { actionTypes, addArrayValue, blur, change, destroy, Field, FieldArray, focus, formValueSelector, reducer, reduxForm, removeArrayValue, initialize, propTypes, reset, setSubmitFailed, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, SubmissionError, swapArrayValues, touch, untouch, values }; |
@@ -14,2 +14,3 @@ import createAll from './createAll'; | ||
var focus = _createAll.focus; | ||
var formValueSelector = _createAll.formValueSelector; | ||
var reducer = _createAll.reducer; | ||
@@ -31,2 +32,2 @@ var reduxForm = _createAll.reduxForm; | ||
var values = _createAll.values; | ||
export { actionTypes, addArrayValue, blur, change, destroy, Field, FieldArray, focus, reducer, reduxForm, removeArrayValue, initialize, propTypes, reset, setSubmitFailed, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, SubmissionError, swapArrayValues, touch, untouch, values }; | ||
export { actionTypes, addArrayValue, blur, change, destroy, Field, FieldArray, focus, formValueSelector, reducer, reduxForm, removeArrayValue, initialize, propTypes, reset, setSubmitFailed, startAsyncValidation, startSubmit, stopAsyncValidation, stopSubmit, SubmissionError, swapArrayValues, touch, untouch, values }; |
@@ -145,3 +145,3 @@ 'use strict'; | ||
it('should read sync errors from state', function () { | ||
it('should read sync errors from param', function () { | ||
var noErrorResult = (0, _createFieldProps2.default)(getIn, 'foo', { | ||
@@ -275,2 +275,9 @@ initial: 'bar', | ||
it('should default value to [] for multi-selects', function () { | ||
expect((0, _createFieldProps2.default)(getIn, 'foo', { | ||
state: empty, | ||
type: 'select-multiple' | ||
}).value).toBeA('array').toEqual([]); | ||
}); | ||
it('should replace undefined value with empty string', function () { | ||
@@ -277,0 +284,0 @@ var result = (0, _createFieldProps2.default)(getIn, 'foo', { |
@@ -246,2 +246,54 @@ 'use strict'; | ||
it('should provide sync error for array field', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
foo: ['bar'] | ||
} | ||
} | ||
}); | ||
var input = (0, _expect.createSpy)(function (props) { | ||
return _react2.default.createElement('input', props); | ||
}).andCallThrough(); | ||
var validate = function validate() { | ||
return { foo: ['bar error'] }; | ||
}; | ||
var Form = function (_Component3) { | ||
_inherits(Form, _Component3); | ||
function Form() { | ||
_classCallCheck(this, Form); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Form).apply(this, arguments)); | ||
} | ||
_createClass(Form, [{ | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement( | ||
'div', | ||
null, | ||
_react2.default.createElement(Field, { name: 'foo[0]', component: input }) | ||
); | ||
} | ||
}]); | ||
return Form; | ||
}(_react.Component); | ||
var TestForm = reduxForm({ | ||
form: 'testForm', | ||
validate: validate | ||
})(Form); | ||
_reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement( | ||
_reactRedux.Provider, | ||
{ store: store }, | ||
_react2.default.createElement(TestForm, null) | ||
)); | ||
expect(input).toHaveBeenCalled(); | ||
expect(input.calls[0].arguments[0].valid).toBe(false); | ||
expect(input.calls[0].arguments[0].error).toBe('bar error'); | ||
}); | ||
it('should provide valid getter', function () { | ||
@@ -259,4 +311,4 @@ var store = makeStore({ | ||
var Form = function (_Component3) { | ||
_inherits(Form, _Component3); | ||
var Form = function (_Component4) { | ||
_inherits(Form, _Component4); | ||
@@ -302,4 +354,4 @@ function Form() { | ||
var Form = function (_Component4) { | ||
_inherits(Form, _Component4); | ||
var Form = function (_Component5) { | ||
_inherits(Form, _Component5); | ||
@@ -345,4 +397,4 @@ function Form() { | ||
var Form = function (_Component5) { | ||
_inherits(Form, _Component5); | ||
var Form = function (_Component6) { | ||
_inherits(Form, _Component6); | ||
@@ -399,4 +451,4 @@ function Form() { | ||
var Form = function (_Component6) { | ||
_inherits(Form, _Component6); | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
@@ -406,6 +458,6 @@ function Form() { | ||
var _this6 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this7 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this6.state = { field: 'foo' }; | ||
return _this6; | ||
_this7.state = { field: 'foo' }; | ||
return _this7; | ||
} | ||
@@ -416,3 +468,3 @@ | ||
value: function render() { | ||
var _this7 = this; | ||
var _this8 = this; | ||
@@ -426,3 +478,3 @@ return _react2.default.createElement( | ||
{ onClick: function onClick() { | ||
return _this7.setState({ field: 'bar' }); | ||
return _this8.setState({ field: 'bar' }); | ||
} }, | ||
@@ -463,4 +515,4 @@ 'Change' | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
var Form = function (_Component8) { | ||
_inherits(Form, _Component8); | ||
@@ -470,6 +522,6 @@ function Form() { | ||
var _this8 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this9 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this8.state = { foo: 'foo', bar: 'bar' }; | ||
return _this8; | ||
_this9.state = { foo: 'foo', bar: 'bar' }; | ||
return _this9; | ||
} | ||
@@ -480,3 +532,3 @@ | ||
value: function render() { | ||
var _this9 = this; | ||
var _this10 = this; | ||
@@ -490,3 +542,3 @@ return _react2.default.createElement( | ||
{ onClick: function onClick() { | ||
return _this9.setState({ foo: 'qux', bar: 'baz' }); | ||
return _this10.setState({ foo: 'qux', bar: 'baz' }); | ||
} }, | ||
@@ -493,0 +545,0 @@ 'Change' |
@@ -13,2 +13,8 @@ 'use strict'; | ||
var _expect2 = _interopRequireDefault(_expect); | ||
var _expectElement = require('expect-element'); | ||
var _expectElement2 = _interopRequireDefault(_expectElement); | ||
var _reactRedux = require('react-redux'); | ||
@@ -36,2 +42,6 @@ | ||
var _Field = require('../Field'); | ||
var _Field2 = _interopRequireDefault(_Field); | ||
var _plain = require('../structure/plain'); | ||
@@ -66,5 +76,8 @@ | ||
_expect2.default.extend(_expectElement2.default); | ||
var describeFieldArray = function describeFieldArray(name, structure, combineReducers, expect) { | ||
var reduxForm = (0, _reduxForm2.default)(structure); | ||
var FieldArray = (0, _FieldArray2.default)(structure); | ||
var Field = (0, _Field2.default)(structure); | ||
var reducer = (0, _reducer2.default)(structure); | ||
@@ -364,10 +377,20 @@ var fromJS = structure.fromJS; | ||
it('should provide name getter', function () { | ||
it('should provide sync error for array field', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
foo: 'bar' | ||
foo: [{ | ||
library: 'redux-form', | ||
author: 'erikras' | ||
}] | ||
} | ||
} | ||
}); | ||
var validate = function validate() { | ||
return { | ||
foo: [{ | ||
_error: 'Too awesome!' | ||
}] | ||
}; | ||
}; | ||
@@ -389,2 +412,67 @@ var Form = function (_Component6) { | ||
null, | ||
_react2.default.createElement(FieldArray, { name: 'foo', component: function component(array) { | ||
return _react2.default.createElement( | ||
'div', | ||
null, | ||
array.map(function (name, index) { | ||
return _react2.default.createElement( | ||
'div', | ||
{ key: index }, | ||
_react2.default.createElement(Field, { name: name + '.library', component: 'input' }), | ||
_react2.default.createElement(Field, { name: name + '.author', component: 'input' }), | ||
_react2.default.createElement(Field, { name: name, component: function component(props) { | ||
return _react2.default.createElement( | ||
'strong', | ||
null, | ||
props.error | ||
); | ||
} }) | ||
); | ||
}) | ||
); | ||
} }) | ||
); | ||
} | ||
}]); | ||
return Form; | ||
}(_react.Component); | ||
var TestForm = reduxForm({ | ||
form: 'testForm', | ||
validate: validate | ||
})(Form); | ||
var dom = _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement( | ||
_reactRedux.Provider, | ||
{ store: store }, | ||
_react2.default.createElement(TestForm, null) | ||
)); | ||
var error = _reactAddonsTestUtils2.default.findRenderedDOMComponentWithTag(dom, 'strong'); | ||
(0, _expect2.default)(error).toExist().toHaveText('Too awesome!'); | ||
}); | ||
it('should provide name getter', function () { | ||
var store = makeStore({ | ||
testForm: { | ||
values: { | ||
foo: 'bar' | ||
} | ||
} | ||
}); | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
function Form() { | ||
_classCallCheck(this, Form); | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Form).apply(this, arguments)); | ||
} | ||
_createClass(Form, [{ | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement( | ||
'div', | ||
null, | ||
_react2.default.createElement(FieldArray, { name: 'foo', component: TestComponent }) | ||
@@ -421,4 +509,4 @@ ); | ||
var Form = function (_Component7) { | ||
_inherits(Form, _Component7); | ||
var Form = function (_Component8) { | ||
_inherits(Form, _Component8); | ||
@@ -428,6 +516,6 @@ function Form() { | ||
var _this7 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this8 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this7.state = { field: 'foo' }; | ||
return _this7; | ||
_this8.state = { field: 'foo' }; | ||
return _this8; | ||
} | ||
@@ -438,3 +526,3 @@ | ||
value: function render() { | ||
var _this8 = this; | ||
var _this9 = this; | ||
@@ -448,3 +536,3 @@ return _react2.default.createElement( | ||
{ onClick: function onClick() { | ||
return _this8.setState({ field: 'bar' }); | ||
return _this9.setState({ field: 'bar' }); | ||
} }, | ||
@@ -483,4 +571,4 @@ 'Change' | ||
var Form = function (_Component8) { | ||
_inherits(Form, _Component8); | ||
var Form = function (_Component9) { | ||
_inherits(Form, _Component9); | ||
@@ -490,6 +578,6 @@ function Form() { | ||
var _this9 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
var _this10 = _possibleConstructorReturn(this, Object.getPrototypeOf(Form).call(this)); | ||
_this9.state = { foo: 'foo', bar: 'bar' }; | ||
return _this9; | ||
_this10.state = { foo: 'foo', bar: 'bar' }; | ||
return _this10; | ||
} | ||
@@ -500,3 +588,3 @@ | ||
value: function render() { | ||
var _this10 = this; | ||
var _this11 = this; | ||
@@ -510,3 +598,3 @@ return _react2.default.createElement( | ||
{ onClick: function onClick() { | ||
return _this10.setState({ foo: 'qux', bar: 'baz' }); | ||
return _this11.setState({ foo: 'qux', bar: 'baz' }); | ||
} }, | ||
@@ -573,4 +661,4 @@ 'Change' | ||
var Form = function (_Component9) { | ||
_inherits(Form, _Component9); | ||
var Form = function (_Component10) { | ||
_inherits(Form, _Component10); | ||
@@ -577,0 +665,0 @@ function Form() { |
@@ -80,3 +80,3 @@ 'use strict'; | ||
it('should return true for an empty array with a _error key', function () { | ||
it('should return true for an empty array with a string error under _error key', function () { | ||
var errors = setIn(fromJS([]), '_error', 'oh no!'); | ||
@@ -88,2 +88,10 @@ if (getIn(errors, '_error') === 'oh no!') { | ||
}); | ||
it('should return true for an empty array with an object error under _error key', function () { | ||
var errors = setIn(fromJS([]), '_error', { complex: 'error' }); | ||
if (getIn(errors, '_error')) { | ||
// cannot work for Immutable Lists because you can not set a value under a string key | ||
expect(hasErrors(errors)).toBe(true); | ||
} | ||
}); | ||
}); | ||
@@ -90,0 +98,0 @@ }; |
@@ -10,3 +10,2 @@ 'use strict'; | ||
global.window = document.defaultView; | ||
global.navigator = global.window.navigator; | ||
global.navigator.product = 'NotReactNative'; | ||
global.navigator = global.window.navigator; |
@@ -91,3 +91,6 @@ 'use strict'; | ||
return _plain2.default.getIn(getSyncErrors(), name); | ||
var error = _plain2.default.getIn(getSyncErrors(), name); | ||
// Because the error for this field might not be at a level in the error structure where | ||
// it can be set directly, it might need to be unwrapped from the _error property | ||
return error && error._error ? error._error : error; | ||
} | ||
@@ -94,0 +97,0 @@ }, { |
@@ -21,6 +21,2 @@ 'use strict'; | ||
var _shallowCompare = require('react/lib/shallowCompare'); | ||
var _shallowCompare2 = _interopRequireDefault(_shallowCompare); | ||
var _reactRedux = require('react-redux'); | ||
@@ -36,2 +32,6 @@ | ||
var _reactAddonsShallowCompare = require('react-addons-shallow-compare'); | ||
var _reactAddonsShallowCompare2 = _interopRequireDefault(_reactAddonsShallowCompare); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -78,3 +78,3 @@ | ||
value: function shouldComponentUpdate(nextProps) { | ||
return (0, _shallowCompare2.default)(this, nextProps); | ||
return (0, _reactAddonsShallowCompare2.default)(this, nextProps); | ||
} | ||
@@ -81,0 +81,0 @@ }, { |
@@ -9,4 +9,2 @@ 'use strict'; | ||
exports.default = createAll; | ||
var _reducer = require('./reducer'); | ||
@@ -28,2 +26,6 @@ | ||
var _formValueSelector = require('./formValueSelector'); | ||
var _formValueSelector2 = _interopRequireDefault(_formValueSelector); | ||
var _values = require('./values'); | ||
@@ -53,5 +55,5 @@ | ||
function createAll(structure) { | ||
// separate out field actions | ||
var createAll = function createAll(structure) { | ||
return _extends({ | ||
// separate out field actions | ||
actionTypes: actionTypes | ||
@@ -61,2 +63,3 @@ }, actions, { | ||
FieldArray: (0, _FieldArray2.default)(structure), | ||
formValueSelector: (0, _formValueSelector2.default)(structure), | ||
propTypes: _propTypes2.default, | ||
@@ -68,2 +71,4 @@ reduxForm: (0, _reduxForm2.default)(structure), | ||
}); | ||
} | ||
}; | ||
exports.default = createAll; |
@@ -60,2 +60,8 @@ 'use strict'; | ||
} | ||
if (type === 'select-multiple') { | ||
return _extends({}, rest, { | ||
type: type, | ||
value: value || [] | ||
}); | ||
} | ||
return props; | ||
@@ -62,0 +68,0 @@ }; |
@@ -15,6 +15,2 @@ 'use strict'; | ||
var _shallowCompare = require('react/lib/shallowCompare'); | ||
var _shallowCompare2 = _interopRequireDefault(_shallowCompare); | ||
var _invariant = require('invariant'); | ||
@@ -28,2 +24,6 @@ | ||
var _reactAddonsShallowCompare = require('react-addons-shallow-compare'); | ||
var _reactAddonsShallowCompare2 = _interopRequireDefault(_reactAddonsShallowCompare); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -65,3 +65,3 @@ | ||
value: function shouldComponentUpdate(nextProps) { | ||
return (0, _shallowCompare2.default)(this, nextProps); | ||
return (0, _reactAddonsShallowCompare2.default)(this, nextProps); | ||
} | ||
@@ -68,0 +68,0 @@ }, { |
@@ -15,6 +15,2 @@ 'use strict'; | ||
var _shallowCompare = require('react/lib/shallowCompare'); | ||
var _shallowCompare2 = _interopRequireDefault(_shallowCompare); | ||
var _invariant = require('invariant'); | ||
@@ -28,2 +24,6 @@ | ||
var _reactAddonsShallowCompare = require('react-addons-shallow-compare'); | ||
var _reactAddonsShallowCompare2 = _interopRequireDefault(_reactAddonsShallowCompare); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -66,3 +66,3 @@ | ||
value: function shouldComponentUpdate(nextProps) { | ||
return (0, _shallowCompare2.default)(this, nextProps); | ||
return (0, _reactAddonsShallowCompare2.default)(this, nextProps); | ||
} | ||
@@ -69,0 +69,0 @@ }, { |
@@ -15,3 +15,3 @@ 'use strict'; | ||
var globalError = getIn(errors, '_error'); | ||
if (globalError && typeof globalError === 'string') { | ||
if (globalError) { | ||
return true; | ||
@@ -18,0 +18,0 @@ } |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.values = exports.untouch = exports.touch = exports.swapArrayValues = exports.SubmissionError = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitFailed = exports.reset = exports.propTypes = exports.initialize = exports.removeArrayValue = exports.reduxForm = exports.reducer = exports.focus = exports.FieldArray = exports.Field = exports.destroy = exports.change = exports.blur = exports.addArrayValue = exports.actionTypes = undefined; | ||
exports.values = exports.untouch = exports.touch = exports.swapArrayValues = exports.SubmissionError = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitFailed = exports.reset = exports.propTypes = exports.initialize = exports.removeArrayValue = exports.reduxForm = exports.reducer = exports.formValueSelector = exports.focus = exports.FieldArray = exports.Field = exports.destroy = exports.change = exports.blur = exports.addArrayValue = exports.actionTypes = undefined; | ||
@@ -29,2 +29,3 @@ var _createAll2 = require('./createAll'); | ||
var focus = _createAll.focus; | ||
var formValueSelector = _createAll.formValueSelector; | ||
var reducer = _createAll.reducer; | ||
@@ -54,2 +55,3 @@ var reduxForm = _createAll.reduxForm; | ||
exports.focus = focus; | ||
exports.formValueSelector = formValueSelector; | ||
exports.reducer = reducer; | ||
@@ -56,0 +58,0 @@ exports.reduxForm = reduxForm; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.values = exports.untouch = exports.touch = exports.swapArrayValues = exports.SubmissionError = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitFailed = exports.reset = exports.propTypes = exports.initialize = exports.removeArrayValue = exports.reduxForm = exports.reducer = exports.focus = exports.FieldArray = exports.Field = exports.destroy = exports.change = exports.blur = exports.addArrayValue = exports.actionTypes = undefined; | ||
exports.values = exports.untouch = exports.touch = exports.swapArrayValues = exports.SubmissionError = exports.stopSubmit = exports.stopAsyncValidation = exports.startSubmit = exports.startAsyncValidation = exports.setSubmitFailed = exports.reset = exports.propTypes = exports.initialize = exports.removeArrayValue = exports.reduxForm = exports.reducer = exports.formValueSelector = exports.focus = exports.FieldArray = exports.Field = exports.destroy = exports.change = exports.blur = exports.addArrayValue = exports.actionTypes = undefined; | ||
@@ -29,2 +29,3 @@ var _createAll2 = require('./createAll'); | ||
var focus = _createAll.focus; | ||
var formValueSelector = _createAll.formValueSelector; | ||
var reducer = _createAll.reducer; | ||
@@ -54,2 +55,3 @@ var reduxForm = _createAll.reduxForm; | ||
exports.focus = focus; | ||
exports.formValueSelector = formValueSelector; | ||
exports.reducer = reducer; | ||
@@ -56,0 +58,0 @@ exports.reduxForm = reduxForm; |
{ | ||
"name": "redux-form", | ||
"version": "6.0.0-alpha.10", | ||
"version": "6.0.0-alpha.11", | ||
"description": "A higher order component decorator for forms using Redux and React", | ||
@@ -42,3 +42,2 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"classnames": "^2.2.3", | ||
"deep-equal": "^1.0.1", | ||
@@ -50,3 +49,4 @@ "es6-error": "^2.1.0", | ||
"lodash": "^4.12.0", | ||
"lodash-es": "^4.12.0" | ||
"lodash-es": "^4.12.0", | ||
"react-addons-shallow-compare": "^15.0.0" | ||
}, | ||
@@ -73,2 +73,3 @@ "devDependencies": { | ||
"expect": "^1.14.0", | ||
"expect-element": "^1.1.1", | ||
"expect-immutable": "0.0.3", | ||
@@ -92,2 +93,3 @@ "expect-predicate": "^1.0.0", | ||
"peerDependencies": { | ||
"react": "^15.0.0", | ||
"react-redux": "^4.0.0", | ||
@@ -94,0 +96,0 @@ "redux": "^3.0.0" |
@@ -19,10 +19,10 @@ # redux-form | ||
## Installation | ||
```npm install --save redux-form@6.0.0-alpha.10``` | ||
```npm install --save redux-form@6.0.0-alpha.11``` | ||
## Documentation | ||
* [Getting Started](http://redux-form.com/6.0.0-alpha.10/docs/GettingStarted.md/) | ||
* [Examples](http://redux-form.com/6.0.0-alpha.10/examples/) | ||
* [API](http://redux-form.com/6.0.0-alpha.10/docs/api/) | ||
* [FAQ](http://redux-form.com/6.0.0-alpha.10/docs/faq/) | ||
* [Getting Started](http://redux-form.com/6.0.0-alpha.11/docs/GettingStarted.md/) | ||
* [Examples](http://redux-form.com/6.0.0-alpha.11/examples/) | ||
* [API](http://redux-form.com/6.0.0-alpha.11/docs/api/) | ||
* [FAQ](http://redux-form.com/6.0.0-alpha.11/docs/faq/) | ||
* [Release Notes](https://github.com/erikras/redux-form/releases) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
207
980147
11
36
25157
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedreact@15.7.0(transitive)
+ Addedreact-addons-shallow-compare@15.6.3(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.40(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)
- Removedclassnames@^2.2.3
- Removedclassnames@2.5.1(transitive)
- Removedreact@16.14.0(transitive)