hbp-quickfire
Version:
A library of useful user-interface components built with React on top of React Bootstrap and MobX
39 lines (32 loc) • 10.1 kB
JavaScript
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 _class;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 _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;} /*
* Copyright (c) Human Brain Project
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from "react";
import { observer, Provider } from "mobx-react";
/**
* Form component that wraps the underlying Fields
* @class Form
* @property {object} store required - An instance of the FormStore class
*/var
Form = observer(_class = function (_React$Component) {_inherits(Form, _React$Component);
function Form(props) {_classCallCheck(this, Form);var _this = _possibleConstructorReturn(this, (Form.__proto__ || Object.getPrototypeOf(Form)).call(this,
props));
if (!props.store) {
throw "Form Component must receive a FormStore instance";
}return _this;
}_createClass(Form, [{ key: "render", value: function render()
{
return (
React.createElement(Provider, { formStore: this.props.store, parentPath: "" },
React.createElement("form", { className: "quickfire-form" }, this.props.children)));
}
/**
* Get the form field values
* @return {object} a structured object of the form field values
*/ }, { key: "values", get: function get()
{
return this.props.store.getValues();
} }]);return Form;}(React.Component)) || _class;export { Form as default };