Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-form

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-form - npm Package Compare versions

Comparing version 0.13.0 to 0.13.2

141

lib/createBaseForm.js
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true

@@ -9,6 +9,2 @@ });

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
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; }
var _react = require('react');

@@ -24,2 +20,6 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
var defaultValidateTrigger = 'onChange';

@@ -43,4 +43,5 @@ var defaultTrigger = defaultValidateTrigger;

function decorate(WrappedComponent) {
var Form = _react2['default'].createClass({
var Form = _react2.default.createClass({
displayName: 'Form',

@@ -62,7 +63,5 @@

},
componentDidMount: function componentDidMount() {
this.componentDidUpdate();
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {

@@ -76,3 +75,2 @@ if (mapPropsToFields) {

},
componentDidUpdate: function componentDidUpdate() {

@@ -96,3 +94,2 @@ var fields = this.fields;

},
onChange: function onChange(name, action, event) {

@@ -112,3 +109,2 @@ var fieldMeta = this.getFieldMeta(name);

},
onChangeValidate: function onChangeValidate(name, action, event) {

@@ -130,3 +126,2 @@ var fieldMeta = this.getFieldMeta(name);

},
getCacheBind: function getCacheBind(name, action, fn) {

@@ -139,7 +134,5 @@ var cache = this.cachedBind[name] = this.cachedBind[name] || {};

},
getFieldMeta: function getFieldMeta(name) {
return this.fieldsMeta[name];
},
getField: function getField(name, copy) {

@@ -154,7 +147,8 @@ var ret = this.fields[name];

}
return { name: name };
return {
name: name
};
}
return ret;
},
getFieldProps: function getFieldProps(name) {

@@ -167,9 +161,10 @@ var _this = this;

var trigger = _fieldOption$trigger === undefined ? defaultTrigger : _fieldOption$trigger;
var _fieldOption$valuePropName = fieldOption.valuePropName;
var valuePropName = _fieldOption$valuePropName === undefined ? 'value' : _fieldOption$valuePropName;
var _fieldOption$validateTrigger = fieldOption.validateTrigger;
var validateTrigger = _fieldOption$validateTrigger === undefined ? defaultValidateTrigger : _fieldOption$validateTrigger;
var _fieldOption$validate = fieldOption.validate;
var validate = _fieldOption$validate === undefined ? [] : _fieldOption$validate;
var _fieldOption$valuePro = fieldOption.valuePropName;
var valuePropName = _fieldOption$valuePro === undefined ? 'value' : _fieldOption$valuePro;
var _fieldOption$validate = fieldOption.validateTrigger;
var validateTrigger = _fieldOption$validate === undefined ? defaultValidateTrigger : _fieldOption$validate;
var _fieldOption$validate2 = fieldOption.validate;
var validate = _fieldOption$validate2 === undefined ? [] : _fieldOption$validate2;
var fieldMeta = this.fieldsMeta[name] || {};

@@ -188,7 +183,9 @@

var validateRules = validate.map(function (item) {
item.trigger = item.trigger || [];
if (typeof item.trigger === 'string') {
item.trigger = [item.trigger];
var newItem = _extends({}, item, {
trigger: item.trigger || []
});
if (typeof newItem.trigger === 'string') {
newItem.trigger = [newItem.trigger];
}
return item;
return newItem;
});

@@ -213,5 +210,7 @@

if (trigger && validateRules.every(function (item) {
function checkRule(item) {
return item.trigger.indexOf(trigger) === -1 || !item.rules || !item.rules.length;
})) {
}
if (trigger && validateRules.every(checkRule)) {
inputProps[trigger] = this.getCacheBind(name, trigger, this.onChange);

@@ -241,3 +240,2 @@ }

},
getFieldMember: function getFieldMember(name, member) {

@@ -247,7 +245,5 @@ var field = this.getField(name);

},
getFieldError: function getFieldError(name) {
return (0, _utils.getErrorStrs)(this.getFieldMember(name, 'errors'));
},
getValidFieldsName: function getValidFieldsName() {

@@ -259,3 +255,2 @@ var fieldsMeta = this.fieldsMeta;

},
getFieldsValue: function getFieldsValue(names) {

@@ -271,3 +266,2 @@ var _this2 = this;

},
getFieldValue: function getFieldValue(name) {

@@ -278,3 +272,2 @@ var fields = this.fields;

},
getValueFromFields: function getValueFromFields(name, fields) {

@@ -290,3 +283,2 @@ var fieldsMeta = this.fieldsMeta;

},
getRules: function getRules(fieldMeta, action) {

@@ -317,3 +309,5 @@ var actionRules = fieldMeta.validate.filter(function (item) {

if (nowValue !== value) {
nowFields[f] = _extends({}, nowFields[f], { value: nowValue });
nowFields[f] = _extends({}, nowFields[f], {
value: nowValue
});
if (changedFieldsName.indexOf(f) === -1) {

@@ -337,10 +331,9 @@ changedFieldsName.push(f);

},
setFieldsValue: function setFieldsValue(fieldsValue) {
var fields = {};
for (var _name in fieldsValue) {
if (fieldsValue.hasOwnProperty(_name)) {
fields[_name] = {
name: _name,
value: fieldsValue[_name]
for (var name in fieldsValue) {
if (fieldsValue.hasOwnProperty(name)) {
fields[name] = {
name: name,
value: fieldsValue[name]
};

@@ -351,10 +344,9 @@ }

},
setFieldsInitialValue: function setFieldsInitialValue(initialValues) {
var fieldsMeta = this.fieldsMeta;
for (var _name2 in initialValues) {
if (initialValues.hasOwnProperty(_name2)) {
var fieldMeta = fieldsMeta[_name2];
fieldsMeta[_name2] = _extends({}, fieldMeta, {
initialValue: initialValues[_name2]
for (var name in initialValues) {
if (initialValues.hasOwnProperty(name)) {
var fieldMeta = fieldsMeta[name];
fieldsMeta[name] = _extends({}, fieldMeta, {
initialValue: initialValues[name]
});

@@ -364,3 +356,2 @@ }

},
saveRef: function saveRef(name, _, component) {

@@ -377,3 +368,2 @@ var fieldMeta = this.getFieldMeta(name);

},
validateFieldsInternal: function validateFieldsInternal(fields, _ref, callback) {

@@ -403,8 +393,9 @@ var _this4 = this;

var fieldMeta = _this4.getFieldMeta(name);
field.errors = undefined;
field.validating = true;
field.dirty = true;
var newField = _extends({}, field);
newField.errors = undefined;
newField.validating = true;
newField.dirty = true;
allRules[name] = _this4.getRules(fieldMeta, action);
allValues[name] = field.value;
allFields[name] = field;
allValues[name] = newField.value;
allFields[name] = newField;
});

@@ -421,3 +412,3 @@ this.setFields(allFields);

}
var validator = new _asyncValidator2['default'](allRules);
var validator = new _asyncValidator2.default(allRules);
if (validateMessages) {

@@ -431,3 +422,7 @@ validator.messages(validateMessages);

var fieldName = e.field;
errorsGroup[fieldName] = errorsGroup[fieldName] || { errors: [] };
if (!errorsGroup[fieldName]) {
errorsGroup[fieldName] = {
errors: []
};
}
var fieldErrors = errorsGroup[fieldName].errors;

@@ -444,3 +439,6 @@ fieldErrors.push(e);

if (nowField.value !== allValues[name]) {
expired.push({ name: name, instance: nowField.instance });
expired.push({
name: name,
instance: nowField.instance
});
} else {

@@ -464,3 +462,6 @@ nowField.errors = fieldErrors && fieldErrors.errors;

var fieldErrors = [{ message: name + ' need to revalidate', field: name }];
var fieldErrors = [{
message: name + ' need to revalidate',
field: name
}];
errorsGroup[name] = {

@@ -477,3 +478,2 @@ expired: true,

},
validateFields: function validateFields(ns, opt, cb) {

@@ -512,9 +512,10 @@ var _this5 = this;

}
this.validateFieldsInternal(fields, { fieldNames: fieldNames, options: options }, callback);
this.validateFieldsInternal(fields, {
fieldNames: fieldNames,
options: options
}, callback);
},
isFieldValidating: function isFieldValidating(name) {
return this.getFieldMember(name, 'validating');
},
isFieldsValidating: function isFieldsValidating(ns) {

@@ -524,7 +525,5 @@ var names = ns || this.getValidFieldsName();

},
isSubmitting: function isSubmitting() {
return this.state.submitting;
},
submit: function submit(callback) {

@@ -543,3 +542,2 @@ var _this6 = this;

},
resetFields: function resetFields(ns) {

@@ -562,9 +560,8 @@ var newFields = {};

},
render: function render() {
var formProps = _defineProperty({}, formPropName, this.getForm());
var fieldsMeta = this.fieldsMeta;
for (var _name3 in fieldsMeta) {
if (fieldsMeta.hasOwnProperty(_name3)) {
fieldsMeta[_name3].stale = 1;
for (var name in fieldsMeta) {
if (fieldsMeta.hasOwnProperty(name)) {
fieldsMeta[name].stale = 1;
}

@@ -576,3 +573,3 @@ }

var props = mapProps.call(this, _extends({}, formProps, this.props));
return _react2['default'].createElement(WrappedComponent, props);
return _react2.default.createElement(WrappedComponent, props);
}

@@ -587,3 +584,3 @@ });

exports['default'] = createBaseForm;
exports.default = createBaseForm;
module.exports = exports['default'];
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true

@@ -9,4 +9,2 @@ });

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _createBaseForm = require('./createBaseForm');

@@ -28,2 +26,4 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function computedStyle(el, prop) {

@@ -73,3 +73,2 @@ var getComputedStyle = window.getComputedStyle;

},
validateFieldsAndScroll: function validateFieldsAndScroll(ns, opt, cb) {

@@ -82,9 +81,10 @@ var _getParams = (0, _utils.getParams)(ns, opt, cb);

function newCb(error, values) {
if (error) {
for (var _name in error) {
if (error.hasOwnProperty(_name) && error[_name].instance) {
var node = _reactDom2['default'].findDOMNode(error[_name].instance);
for (var name in error) {
if (error.hasOwnProperty(name) && error[name].instance) {
var node = _reactDom2.default.findDOMNode(error[name].instance);
var c = options.container || getScrollableContainer(node);
(0, _domScrollIntoView2['default'])(node, c, {
(0, _domScrollIntoView2.default)(node, c, {
onlyScrollIfNeeded: true

@@ -106,3 +106,3 @@ });

function createDOMForm(option) {
return (0, _createBaseForm2['default'])(_extends({}, option, {
return (0, _createBaseForm2.default)(_extends({}, option, {
refComponent: true

@@ -112,3 +112,3 @@ }), [mixin]);

exports['default'] = createDOMForm;
exports.default = createDOMForm;
module.exports = exports['default'];
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.mixin = undefined;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _createBaseForm = require('./createBaseForm');

@@ -13,3 +12,5 @@

var mixin = {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mixin = exports.mixin = {
getForm: function getForm() {

@@ -34,7 +35,6 @@ return {

exports.mixin = mixin;
function createForm(options) {
return (0, _createBaseForm2['default'])(options, [mixin]);
return (0, _createBaseForm2.default)(options, [mixin]);
}
exports['default'] = createForm;
exports.default = createForm;

@@ -1,12 +0,16 @@

// export this package's api
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true
});
function _interopRequire(obj) { return obj && obj.__esModule ? obj['default'] : obj; }
var _createForm = require('./createForm');
exports.createForm = _interopRequire(_createForm);
Object.defineProperty(exports, 'createForm', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_createForm).default;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
'use strict';
Object.defineProperty(exports, '__esModule', {
Object.defineProperty(exports, "__esModule", {
value: true

@@ -15,4 +15,2 @@ });

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _hoistNonReactStatics = require('hoist-non-react-statics');

@@ -22,2 +20,4 @@

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

@@ -28,5 +28,6 @@ return WrappedComponent.displayName || WrappedComponent.name || 'WrappedComponent';

function argumentContainer(Container, WrappedComponent) {
/* eslint no-param-reassign:0 */
Container.displayName = 'Form(' + getDisplayName(WrappedComponent) + ')';
Container.WrappedComponent = WrappedComponent;
return (0, _hoistNonReactStatics2['default'])(Container, WrappedComponent);
return (0, _hoistNonReactStatics2.default)(Container, WrappedComponent);
}

@@ -99,3 +100,7 @@

}
return { names: names, callback: callback, options: options };
return {
names: names,
callback: callback,
options: options
};
}
{
"name": "rc-form",
"version": "0.13.0",
"version": "0.13.2",
"description": "React High Order Form Component",

@@ -35,3 +35,3 @@ "keywords": [

"gh-pages": "rc-tools run gh-pages",
"start": "rc-server",
"start": "rc-tools run server",
"pub": "rc-tools run pub",

@@ -41,4 +41,5 @@ "lint": "rc-tools run lint",

"saucelabs": "rc-tools run saucelabs",
"browser-test": "rc-tools run browser-test",
"browser-test-cover": "rc-tools run browser-test-cover"
"test": "rc-tools run test",
"chrome-test": "rc-tools run chrome-test",
"coverage": "rc-tools run coverage"
},

@@ -52,4 +53,3 @@ "devDependencies": {

"pre-commit": "1.x",
"rc-server": "3.x",
"rc-tools": "4.x",
"rc-tools": "5.x",
"react": "0.14.x",

@@ -56,0 +56,0 @@ "react-addons-test-utils": "0.14.x",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc