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.17.1 to 0.17.2

54

lib/createBaseForm.js

@@ -7,4 +7,14 @@ 'use strict';

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 _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _react = require('react');

@@ -22,4 +32,2 @@

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';

@@ -87,7 +95,7 @@ var defaultTrigger = defaultValidateTrigger;

var field = this.getField(name);
fieldContent = _extends({}, field, {
fieldContent = (0, _extends3["default"])({}, field, {
value: value,
dirty: (0, _utils.hasRules)(validate)
});
this.setFields(_defineProperty({}, name, fieldContent));
this.setFields((0, _defineProperty3["default"])({}, name, fieldContent));
},

@@ -133,3 +141,3 @@ onChangeValidate: function onChangeValidate(name_, action) {

return _extends({}, fields[name], {
return (0, _extends3["default"])({}, fields[name], {
name: name

@@ -194,3 +202,3 @@ });

var validateRules = validate.map(function (item) {
var newItem = _extends({}, item, {
var newItem = (0, _extends3["default"])({}, item, {
trigger: item.trigger || []

@@ -237,3 +245,3 @@ });

if (getValueProps) {
inputProps = _extends({}, inputProps, getValueProps(fieldValue));
inputProps = (0, _extends3["default"])({}, inputProps, getValueProps(fieldValue));
} else {

@@ -245,3 +253,3 @@ inputProps[valuePropName] = fieldValue;

var meta = _extends({}, fieldMeta, fieldOption, {
var meta = (0, _extends3["default"])({}, fieldMeta, fieldOption, {
validate: validateRules

@@ -267,3 +275,3 @@ });

var fieldsMeta = this.fieldsMeta;
return fieldsMeta ? Object.keys(fieldsMeta).filter(function (name) {
return fieldsMeta ? (0, _keys2["default"])(fieldsMeta).filter(function (name) {
return !fieldsMeta[name].hidden;

@@ -328,5 +336,5 @@ }) : [];

var fields = fields_;
var nowFields = _extends({}, this.fields, fields);
var nowFields = (0, _extends3["default"])({}, this.fields, fields);
var nowValues = {};
Object.keys(fieldsMeta).forEach(function (f) {
(0, _keys2["default"])(fieldsMeta).forEach(function (f) {
var _getNameKeyObj = (0, _utils.getNameKeyObj)(f);

@@ -342,4 +350,4 @@

});
var changedFieldsName = Object.keys(fields);
Object.keys(nowValues).forEach(function (f) {
var changedFieldsName = (0, _keys2["default"])(fields);
(0, _keys2["default"])(nowValues).forEach(function (f) {
var value = nowValues[f];

@@ -350,3 +358,3 @@ var fieldMeta = fieldsMeta[f];

if (nowValue !== value) {
nowFields[f] = _extends({}, nowFields[f], {
nowFields[f] = (0, _extends3["default"])({}, nowFields[f], {
value: nowValue

@@ -399,3 +407,3 @@ });

var fieldMeta = fieldsMeta[name];
fieldsMeta[name] = _extends({}, fieldMeta, {
fieldsMeta[name] = (0, _extends3["default"])({}, fieldMeta, {
initialValue: initialValues[name]

@@ -447,3 +455,3 @@ });

var fieldMeta = _this4.getFieldMeta(name);
var newField = _extends({}, field);
var newField = (0, _extends3["default"])({}, field);
newField.errors = undefined;

@@ -458,3 +466,3 @@ newField.validating = true;

// in case normalize
Object.keys(allValues).forEach(function (f) {
(0, _keys2["default"])(allValues).forEach(function (f) {
allValues[f] = _this4.getFieldValue(f);

@@ -471,3 +479,3 @@ });

validator.validate(allValues, options, function (errors) {
var errorsGroup = _extends({}, alreadyErrors);
var errorsGroup = (0, _extends3["default"])({}, alreadyErrors);
if (errors && errors.length) {

@@ -487,3 +495,3 @@ errors.forEach(function (e) {

var nowAllFields = {};
Object.keys(allRules).forEach(function (name) {
(0, _keys2["default"])(allRules).forEach(function (name) {
var fieldErrors = errorsGroup[name];

@@ -594,3 +602,3 @@ var nowField = _this4.getField(name);

var changed = false;
var names = ns || Object.keys(fields);
var names = ns || (0, _keys2["default"])(fields);
names.forEach(function (name) {

@@ -608,7 +616,7 @@ var field = fields[name];

render: function render() {
var formProps = _defineProperty({}, formPropName, this.getForm());
var formProps = (0, _defineProperty3["default"])({}, formPropName, this.getForm());
if (withRef) {
formProps.ref = 'wrappedComponent';
}
var props = mapProps.call(this, _extends({}, formProps, this.props));
var props = mapProps.call(this, (0, _extends3["default"])({}, formProps, this.props));
return _react2["default"].createElement(WrappedComponent, props);

@@ -615,0 +623,0 @@ }

@@ -7,4 +7,6 @@ 'use strict';

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 _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _createBaseForm = require('./createBaseForm');

@@ -68,3 +70,3 @@

getForm: function getForm() {
return _extends({}, _createForm.mixin.getForm.call(this), {
return (0, _extends3["default"])({}, _createForm.mixin.getForm.call(this), {
validateFieldsAndScroll: this.validateFieldsAndScroll

@@ -102,3 +104,3 @@ });

var c = options.container || getScrollableContainer(firstNode);
(0, _domScrollIntoView2["default"])(firstNode, c, _extends({
(0, _domScrollIntoView2["default"])(firstNode, c, (0, _extends3["default"])({
onlyScrollIfNeeded: true

@@ -119,3 +121,3 @@ }, options.scroll));

function createDOMForm(option) {
return (0, _createBaseForm2["default"])(_extends({}, option), [mixin]);
return (0, _createBaseForm2["default"])((0, _extends3["default"])({}, option), [mixin]);
}

@@ -122,0 +124,0 @@

@@ -7,4 +7,10 @@ 'use strict';

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 _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
exports.argumentContainer = argumentContainer;

@@ -65,3 +71,3 @@ exports.getValueFromEvent = getValueFromEvent;

function isEmptyObject(obj) {
return Object.keys(obj).length === 0;
return (0, _keys2["default"])(obj).length === 0;
}

@@ -144,4 +150,4 @@

function flatFields(fields_, fieldsMeta) {
var fields = _extends({}, fields_);
Object.keys(fields).forEach(function (k) {
var fields = (0, _extends3["default"])({}, fields_);
(0, _keys2["default"])(fields).forEach(function (k) {
if (fieldsMeta[k] && fieldsMeta[k].virtual) {

@@ -166,3 +172,3 @@ var value = fields[k];

});
return Object.keys(ret);
return (0, _keys2["default"])(ret);
}

@@ -173,3 +179,3 @@

/* eslint no-loop-func:0 */
Object.keys(fields).forEach(function (ok) {
(0, _keys2["default"])(fields).forEach(function (ok) {
if (getNameKeyObj(ok).name === name) {

@@ -176,0 +182,0 @@ delete fields[ok];

{
"name": "rc-form",
"version": "0.17.1",
"version": "0.17.2",
"description": "React High Order Form Component",

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

"start": "rc-tools run server",
"pub": "rc-tools run pub",
"pub": "rc-tools run pub --babel-runtime",
"lint": "rc-tools run lint",

@@ -61,2 +61,3 @@ "karma": "rc-tools run karma",

"dependencies": {
"babel-runtime": "6.x",
"async-validator": "1.x",

@@ -63,0 +64,0 @@ "dom-scroll-into-view": "1.x",

@@ -96,2 +96,6 @@ # rc-form

### formOption.withRef: boolean
Maintain an ref for wrapped component instance, use `refs.wrappedComponent` to access.
createForm() will return another function:

@@ -98,0 +102,0 @@

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