Socket
Socket
Sign inDemoInstall

formact

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formact - npm Package Compare versions

Comparing version 0.10.2 to 0.10.3

105

lib/Input.js

@@ -23,6 +23,6 @@ 'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -42,49 +42,4 @@

_this.propagateValue = function () {
if (_this.context && _this.context.valueChanged) {
_this.context.valueChanged(_this.props.name, _this.state.value);
}
};
_initialiseProps.call(_this);
_this.onChange = function (e) {
var _ref = e.currentTarget,
value = _ref.value;
_this.setState({
value: value
}, _this.propagateValue);
if (_this.props.onChange) {
_this.props.onChange(e);
}
};
_this.validate = function () {
var _this$props = _this.props,
validation = _this$props.validation,
required = _this$props.required;
if (!validation) {
validation = [];
} else if (!Array.isArray(validation)) {
validation = [validation];
}
if (required) {
validation = [_validation.REQUIRED].concat(_toConsumableArray(validation));
}
if (_this.props.type === 'email') {
validation = [_validation.EMAIL].concat(_toConsumableArray(validation));
}
return validation.map(function (fun) {
return fun(_this.state.value, _this.props.label);
}).filter(function (m) {
return m;
}).join(' ');
};
_this.state = {

@@ -180,2 +135,56 @@ value: props.value || props.defaultValue || ''

};
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.propagateValue = function () {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this2.props;
if (_this2.context && _this2.context.valueChanged) {
_this2.context.valueChanged(props.name, _this2.state.value);
}
};
this.onChange = function (e) {
var _ref = e.currentTarget,
value = _ref.value;
_this2.setState({
value: value
}, _this2.propagateValue);
if (_this2.props.onChange) {
_this2.props.onChange(e);
}
};
this.validate = function () {
var _props2 = _this2.props,
validation = _props2.validation,
required = _props2.required;
if (!validation) {
validation = [];
} else if (!Array.isArray(validation)) {
validation = [validation];
}
if (required) {
validation = [_validation.REQUIRED].concat(_toConsumableArray(validation));
}
if (_this2.props.type === 'email') {
validation = [_validation.EMAIL].concat(_toConsumableArray(validation));
}
return validation.map(function (fun) {
return fun(_this2.state.value, _this2.props.label);
}).filter(function (m) {
return m;
}).join(' ');
};
};
exports.default = Input;
{
"name": "formact",
"version": "0.10.2",
"version": "0.10.3",
"description": "A React Set of Form Components with Context",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -22,3 +22,2 @@ // @flow

ElementChildren,
ElementChild,
} from './types'

@@ -94,5 +94,5 @@ // @flow

propagateValue = () => {
propagateValue = (props: Props = this.props) => {
if (this.context && this.context.valueChanged) {
this.context.valueChanged(this.props.name, this.state.value)
this.context.valueChanged(props.name, this.state.value)
}

@@ -99,0 +99,0 @@ }

@@ -5,6 +5,4 @@ // @flow

export type ElementChild = void | number | string | Element<*>
export type ElementChildren = ?any
export type ElementChildren = ElementChild | Array<ElementChild>
export type FieldName = string

@@ -11,0 +9,0 @@

@@ -5,6 +5,4 @@ // @flow

export type ElementChild = void | number | string | Element<*>
export type ElementChildren = ?any
export type ElementChildren = ElementChild | Array<ElementChild>
export type FieldName = string

@@ -11,0 +9,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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