formula-one
Advanced tools
Comparing version 0.9.0-alpha.8 to 0.9.0-alpha.9
@@ -6,27 +6,38 @@ "use strict"; | ||
}); | ||
exports.default = withFormContext; | ||
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 React = _interopRequireWildcard(require("react")); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _Form = require("./Form"); | ||
exports.default = withFormContext; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
var _react = require("react"); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var React = _interopRequireWildcard(_react); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
var _Form = require("./Form"); | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // strict | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function withFormContext(Component) { | ||
var WithFormContext = function (_React$Component) { | ||
var WithFormContext = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(WithFormContext, _React$Component); | ||
@@ -37,3 +48,3 @@ | ||
return _possibleConstructorReturn(this, (WithFormContext.__proto__ || Object.getPrototypeOf(WithFormContext)).apply(this, arguments)); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(WithFormContext).apply(this, arguments)); | ||
} | ||
@@ -44,19 +55,14 @@ | ||
value: function render() { | ||
var _props = this.props, | ||
forwardedRef = _props.forwardedRef, | ||
otherProps = _objectWithoutProperties(_props, ["forwardedRef"]); | ||
var _this$props = this.props, | ||
forwardedRef = _this$props.forwardedRef, | ||
otherProps = _objectWithoutProperties(_this$props, ["forwardedRef"]); | ||
return React.createElement( | ||
_Form.FormContext.Consumer, | ||
null, | ||
function (formContext) { | ||
return ( | ||
// $FlowFixMe looks right to me | ||
React.createElement(Component, _extends({}, otherProps, { | ||
formContext: formContext, | ||
ref: forwardedRef | ||
})) | ||
); | ||
} | ||
); | ||
return React.createElement(_Form.FormContext.Consumer, null, function (formContext) { | ||
return (// $FlowFixMe looks right to me | ||
React.createElement(Component, _extends({}, otherProps, { | ||
formContext: formContext, | ||
ref: forwardedRef | ||
})) | ||
); | ||
}); | ||
} | ||
@@ -66,10 +72,10 @@ }]); | ||
return WithFormContext; | ||
}(React.Component); | ||
}(React.Component); // $FlowFixMe $FlowBug(0.79.1) | ||
// $FlowFixMe $FlowBug(0.79.1) | ||
return React.forwardRef(function (props, ref) { | ||
return React.createElement(WithFormContext, _extends({}, props, { forwardedRef: ref })); | ||
return React.createElement(WithFormContext, _extends({}, props, { | ||
forwardedRef: ref | ||
})); | ||
}); | ||
} |
{ | ||
"name": "formula-one", | ||
"version": "0.9.0-alpha.8", | ||
"version": "0.9.0-alpha.9", | ||
"description": "Strongly-typed React form state management", | ||
@@ -5,0 +5,0 @@ "author": "Zach Gotsch", |
@@ -326,3 +326,3 @@ # formula-one | ||
<Form serverErrors={serverErrors}> | ||
({(link, handleSubmit)}) => ( | ||
{(link, handleSubmit) => ( | ||
<> | ||
@@ -363,3 +363,3 @@ <ObjectField link={link}> | ||
<Form onSubmit={handleSubmit}> | ||
({(link, handleSubmit, {valid})}) => ( | ||
{(link, handleSubmit, {valid}) => ( | ||
<> | ||
@@ -404,3 +404,3 @@ <Field link={link}> | ||
<Form onSubmit={handleSubmit}> | ||
({(link, handleSubmit)}) => ( | ||
{(link, handleSubmit) => ( | ||
<> | ||
@@ -422,2 +422,4 @@ <UserField link={link} /> | ||
```jsx | ||
function handleSubmit(value) { /* ... */ } | ||
class MyExternalButtonExample extends React.Component<Props> { | ||
@@ -447,4 +449,3 @@ form: null | React.Element<typeof Form>; | ||
> | ||
({(link, handleSubmit)}) => (<UserField link={link} /> | ||
)} | ||
{link => (<UserField link={link} />)} | ||
</Form> | ||
@@ -451,0 +452,0 @@ <button onClick={this.handleSubmitClick}>Submit</button> |
@@ -154,3 +154,3 @@ // @flow strict | ||
const foldedChildren = tree.children.reduce( | ||
(memo, childTree) => | ||
(memo: Folded, childTree) => | ||
mappend(memo, foldMapTree(mapper, mempty, mappend, childTree)), | ||
@@ -162,3 +162,3 @@ mempty | ||
const foldedChildren = Object.keys(tree.children).reduce( | ||
(memo, key) => | ||
(memo: Folded, key) => | ||
mappend(memo, foldMapTree(mapper, mempty, mappend, tree.children[key])), | ||
@@ -165,0 +165,0 @@ mempty |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
339373
64
8124
456
1