uniforms-bootstrap4
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -12,3 +12,3 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -33,2 +33,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var Bootstrap4 = function Bootstrap4(parent) { | ||
@@ -50,3 +54,3 @@ var _class, _temp; | ||
value: function getChildContextState() { | ||
return (0, _objectSpread2["default"])({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextState", this).call(this), { | ||
return _objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(_class.prototype), "getChildContextState", this).call(this), { | ||
grid: this.props.grid | ||
@@ -65,3 +69,3 @@ }); | ||
return (0, _objectSpread2["default"])({}, props, { | ||
return _objectSpread({}, props, { | ||
className: (0, _classnames["default"])('form', { | ||
@@ -74,3 +78,3 @@ error: error | ||
return _class; | ||
}(parent), _class.Bootstrap4 = Bootstrap4, _class.displayName = "Bootstrap4".concat(parent.displayName), _class.propTypes = (0, _objectSpread2["default"])({}, parent.propTypes, { | ||
}(parent), _class.Bootstrap4 = Bootstrap4, _class.displayName = "Bootstrap4".concat(parent.displayName), _class.propTypes = _objectSpread({}, parent.propTypes, { | ||
grid: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].object, _propTypes["default"].string]) | ||
@@ -77,0 +81,0 @@ }), _temp; |
@@ -10,3 +10,3 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -23,2 +23,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var Bool = function Bool(_ref) { | ||
@@ -28,3 +32,3 @@ var label = _ref.label, | ||
props = (0, _objectWithoutProperties2["default"])(_ref, ["label", "labelBefore"]); | ||
return (0, _wrapField["default"])((0, _objectSpread2["default"])({ | ||
return (0, _wrapField["default"])(_objectSpread({ | ||
label: labelBefore | ||
@@ -31,0 +35,0 @@ }, props), _react["default"].createElement("div", { |
@@ -10,3 +10,3 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -17,2 +17,6 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
_filterDOMProps["default"].register('grid'); | ||
@@ -56,3 +60,3 @@ | ||
if (!grid.xs) { | ||
grid = (0, _objectSpread2["default"])({ | ||
grid = _objectSpread({ | ||
xs: grid.sm || grid.md || grid.lg || grid.xl | ||
@@ -59,0 +63,0 @@ }, grid); |
125
NumField.js
@@ -12,3 +12,3 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
@@ -21,6 +21,4 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
@@ -36,2 +34,6 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
var noneIfNaN = function noneIfNaN(x) { | ||
@@ -41,2 +43,6 @@ return isNaN(x) ? undefined : x; | ||
var parse = function parse(decimal, x) { | ||
return noneIfNaN((decimal ? parseFloat : parseInt)(x)); | ||
}; | ||
var Num_ = function Num_(props) { | ||
@@ -59,59 +65,78 @@ return (0, _wrapField["default"])(props, _react["default"].createElement("input", { | ||
})); | ||
}; // NOTE: React < 16 workaround. Make it optional? | ||
}; | ||
var Num; // istanbul ignore next | ||
var Num = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2["default"])(Num, _Component); | ||
if (parseInt(_react["default"].version, 10) < 16) { | ||
var _temp; | ||
function Num() { | ||
var _this; | ||
Num = (_temp = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
(0, _inherits2["default"])(Num, _Component); | ||
(0, _classCallCheck2["default"])(this, Num); | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Num).apply(this, arguments)); | ||
_this.state = { | ||
value: '' + _this.props.value | ||
}; | ||
_this.onChange = _this.onChange.bind((0, _assertThisInitialized2["default"])(_this)); | ||
return _this; | ||
} | ||
function Num() { | ||
var _getPrototypeOf2; | ||
(0, _createClass2["default"])(Num, [{ | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(_ref) { | ||
var decimal = _ref.decimal, | ||
value = _ref.value; | ||
var parse = decimal ? parseFloat : parseInt; | ||
var _this; | ||
if (noneIfNaN(parse(value)) !== noneIfNaN(parse(this.state.value.replace(/[.,]+$/, '')))) { | ||
this.setState({ | ||
value: value === undefined || value === '' ? '' : '' + value | ||
(0, _classCallCheck2["default"])(this, Num); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = (0, _possibleConstructorReturn2["default"])(this, (_getPrototypeOf2 = (0, _getPrototypeOf3["default"])(Num)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_this.state = { | ||
value: '' + _this.props.value | ||
}; | ||
_this.onChange = function (event) { | ||
var value = event.target.value.replace(/[^\d.,-]/g, ''); | ||
_this.setState({ | ||
value: value | ||
}); | ||
} | ||
_this.props.onChange(parse(_this.props.decimal, value)); | ||
}; | ||
return _this; | ||
} | ||
}, { | ||
key: "onChange", | ||
value: function onChange(_ref2) { | ||
var value = _ref2.target.value; | ||
var change = value.replace(/[^\d.,-]/g, ''); | ||
this.setState({ | ||
value: change | ||
}); | ||
this.props.onChange(noneIfNaN((this.props.decimal ? parseFloat : parseInt)(change))); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
return Num_((0, _objectSpread2["default"])({}, this.props, { | ||
onChange: this.onChange, | ||
value: this.state.value | ||
})); | ||
} | ||
}]); | ||
return Num; | ||
}(_react.Component); | ||
(0, _createClass2["default"])(Num, [{ | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(_ref) { | ||
var decimal = _ref.decimal, | ||
value = _ref.value; | ||
if (parse(decimal, value) !== parse(decimal, this.state.value.replace(/[.,]+$/, ''))) { | ||
this.setState({ | ||
value: value === undefined || value === '' ? '' : '' + value | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
return Num_(_objectSpread({}, this.props, { | ||
onChange: this.onChange, | ||
value: this.state.value | ||
})); | ||
} | ||
}]); | ||
return Num; | ||
}(_react.Component), _temp); | ||
} else { | ||
Num = function Num(props) { | ||
return Num_(_objectSpread({}, props, { | ||
onChange: function onChange(event) { | ||
props.onChange(parse(props.decimal, event.target.value)); | ||
} | ||
})); | ||
}; | ||
} | ||
var _default = (0, _connectField["default"])(Num); | ||
exports["default"] = _default; |
{ | ||
"name": "uniforms-bootstrap4", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"license": "MIT", | ||
@@ -32,6 +32,6 @@ "main": "index.js", | ||
"prop-types": "^15.5.7", | ||
"uniforms": "^2.2.0", | ||
"uniforms": "^2.3.0", | ||
"warning": "^4.0.0" | ||
}, | ||
"gitHead": "b8b570ad583f100f133e1f1ac8d6d6c67439c498" | ||
"gitHead": "dfb223c6b8a4751159f32fa0a2b2a69d8265ce45" | ||
} |
@@ -11,2 +11,2 @@ # uniforms-bootstrap4 | ||
For more in depth documentation see: [https://github.com/vazco/uniforms/](https://github.com/vazco/uniforms/). | ||
For more in depth documentation see [uniforms.tools](https://uniforms.tools). |
@@ -8,2 +8,3 @@ import React, { Component } from 'react'; | ||
const noneIfNaN = x => (isNaN(x) ? undefined : x); | ||
const parse = (decimal, x) => noneIfNaN((decimal ? parseFloat : parseInt)(x)); | ||
@@ -31,43 +32,44 @@ const Num_ = props => | ||
// NOTE: React < 16 workaround. Make it optional? | ||
class Num extends Component { | ||
constructor() { | ||
super(...arguments); | ||
let Num; | ||
// istanbul ignore next | ||
if (parseInt(React.version, 10) < 16) { | ||
Num = class Num extends Component { | ||
state = { value: '' + this.props.value }; | ||
this.state = { value: '' + this.props.value }; | ||
componentWillReceiveProps({ decimal, value }) { | ||
if ( | ||
parse(decimal, value) !== | ||
parse(decimal, this.state.value.replace(/[.,]+$/, '')) | ||
) { | ||
this.setState({ | ||
value: value === undefined || value === '' ? '' : '' + value | ||
}); | ||
} | ||
} | ||
this.onChange = this.onChange.bind(this); | ||
} | ||
onChange = event => { | ||
const value = event.target.value.replace(/[^\d.,-]/g, ''); | ||
componentWillReceiveProps({ decimal, value }) { | ||
const parse = decimal ? parseFloat : parseInt; | ||
this.setState({ value }); | ||
this.props.onChange(parse(this.props.decimal, value)); | ||
}; | ||
if ( | ||
noneIfNaN(parse(value)) !== | ||
noneIfNaN(parse(this.state.value.replace(/[.,]+$/, ''))) | ||
) { | ||
this.setState({ | ||
value: value === undefined || value === '' ? '' : '' + value | ||
render() { | ||
return Num_({ | ||
...this.props, | ||
onChange: this.onChange, | ||
value: this.state.value | ||
}); | ||
} | ||
} | ||
onChange({ target: { value } }) { | ||
const change = value.replace(/[^\d.,-]/g, ''); | ||
this.setState({ value: change }); | ||
this.props.onChange( | ||
noneIfNaN((this.props.decimal ? parseFloat : parseInt)(change)) | ||
); | ||
} | ||
render() { | ||
return Num_({ | ||
...this.props, | ||
onChange: this.onChange, | ||
value: this.state.value | ||
}; | ||
} else { | ||
Num = props => | ||
Num_({ | ||
...props, | ||
onChange(event) { | ||
props.onChange(parse(props.decimal, event.target.value)); | ||
} | ||
}); | ||
} | ||
} | ||
export default connectField(Num); |
88734
2267
Updateduniforms@^2.3.0