UNPKG

@reversecurrent/formrenderer

Version:

A simple React component capable of building HTML forms based on JSON meta schema.

1,304 lines (1,089 loc) 206 kB
(function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 14); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process) { if (process.env.NODE_ENV === 'production') { module.exports = __webpack_require__(15); } else { module.exports = __webpack_require__(16); } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if (process.env.NODE_ENV !== 'production') { var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; var isValidElement = function(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; }; // By explicitly using `prop-types` you are opting into new development behavior. // http://fb.me/prop-types-in-prod var throwOnDirectAccess = true; module.exports = __webpack_require__(18)(isValidElement, throwOnDirectAccess); } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod module.exports = __webpack_require__(19)(); } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }), /* 2 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["b"] = getFieldControl; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getFieldAttributes; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Fields_ShortTextField__ = __webpack_require__(24); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Fields_LongTextField__ = __webpack_require__(25); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Fields_DataTimeField__ = __webpack_require__(26); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Fields_CheckBoxField__ = __webpack_require__(27); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Fields_Dropdown__ = __webpack_require__(28); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Fields_RadioField__ = __webpack_require__(29); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Fields_File_FileFieldContainer__ = __webpack_require__(30); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Fields_LabelField__ = __webpack_require__(7); var components = { 'ShortText': __WEBPACK_IMPORTED_MODULE_0__Fields_ShortTextField__["a" /* default */], 'LongText': __WEBPACK_IMPORTED_MODULE_1__Fields_LongTextField__["a" /* default */], 'Number': __WEBPACK_IMPORTED_MODULE_0__Fields_ShortTextField__["a" /* default */], 'Email': __WEBPACK_IMPORTED_MODULE_0__Fields_ShortTextField__["a" /* default */], 'Password': __WEBPACK_IMPORTED_MODULE_0__Fields_ShortTextField__["a" /* default */], 'DateTime': __WEBPACK_IMPORTED_MODULE_2__Fields_DataTimeField__["a" /* default */], 'CheckBox': __WEBPACK_IMPORTED_MODULE_3__Fields_CheckBoxField__["a" /* default */], 'DropDown': __WEBPACK_IMPORTED_MODULE_4__Fields_Dropdown__["a" /* default */], 'Radio': __WEBPACK_IMPORTED_MODULE_5__Fields_RadioField__["a" /* default */], 'File': __WEBPACK_IMPORTED_MODULE_6__Fields_File_FileFieldContainer__["a" /* default */], 'Label': __WEBPACK_IMPORTED_MODULE_7__Fields_LabelField__["a" /* default */] }; function getFieldControl(type) { return components[type]; } var getFieldAttributes = function getFieldAttributes(type, props) { var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : props.value; var className = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "form-control"; var id = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : props.id; return { type: type, className: className, defaultValue: value, name: props.field.name, id: id, placeholder: props.field.placeholder }; }; /***/ }), /* 3 */ /***/ (function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* object-assign (c) Sindre Sorhus @license MIT */ /* eslint-disable no-unused-vars */ var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function shouldUseNative() { try { if (!Object.assign) { return false; } // Detect buggy property enumeration order in older V8 versions. // https://bugs.chromium.org/p/v8/issues/detail?id=4118 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test2 = {}; for (var i = 0; i < 10; i++) { test2['_' + String.fromCharCode(i)] = i; } var order2 = Object.getOwnPropertyNames(test2).map(function (n) { return test2[n]; }); if (order2.join('') !== '0123456789') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test3 = {}; 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { test3[letter] = letter; }); if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') { return false; } return true; } catch (err) { // We don't expect any of the above to throw, but better to be safe. return false; } } module.exports = shouldUseNative() ? Object.assign : function (target, source) { var from; var to = toObject(target); var symbols; for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; } } } } return to; }; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ function makeEmptyFunction(arg) { return function () { return arg; }; } /** * This function accepts and discards inputs; it has no side effects. This is * primarily useful idiomatically for overridable function endpoints which * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ var emptyFunction = function emptyFunction() {}; emptyFunction.thatReturns = makeEmptyFunction; emptyFunction.thatReturnsFalse = makeEmptyFunction(false); emptyFunction.thatReturnsTrue = makeEmptyFunction(true); emptyFunction.thatReturnsNull = makeEmptyFunction(null); emptyFunction.thatReturnsThis = function () { return this; }; emptyFunction.thatReturnsArgument = function (arg) { return arg; }; module.exports = emptyFunction; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; /***/ }), /* 7 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = LabelField; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__); function LabelField(props) { var field = props.field; var requiredUI = isRequired(field) ? __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'span', { className: 'required' }, '*' ) : ''; var showLabel = field.showLabel === undefined ? true : field.showLabel; if (showLabel) { return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'label', { className: props.className, htmlFor: field.name }, field.label, requiredUI ); } return ''; } var isRequired = function isRequired(field) { var required = Object.keys(field.validators).find(function (value) { return value === 'required'; }); if (required == null) { return false; } return field.validators[required].args[0] === true; }; LabelField.propTypes = { field: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.object.isRequired, className: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.string }; /***/ }), /* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; 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; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ErrorMessage = function () { function ErrorMessage() { _classCallCheck(this, ErrorMessage); this.isValid = true; this.errorMessage = ''; } _createClass(ErrorMessage, [{ key: 'getValidMessage', value: function getValidMessage() { return { isValid: this.isValid, errorMessage: this.errorMessage }; } }, { key: 'getErrorMessage', value: function getErrorMessage(message) { this.errorMessage = message; return { isValid: false, errorMessage: this.errorMessage }; } }]); return ErrorMessage; }(); /* harmony default export */ __webpack_exports__["a"] = (ErrorMessage); /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var validateFormat = function validateFormat(format) {}; if (process.env.NODE_ENV !== 'production') { validateFormat = function validateFormat(format) { if (format === undefined) { throw new Error('invariant requires an error message argument'); } }; } function invariant(condition, format, a, b, c, d, e, f) { validateFormat(format); if (!condition) { var error; if (format === undefined) { error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } } module.exports = invariant; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ var emptyObject = {}; if (process.env.NODE_ENV !== 'production') { Object.freeze(emptyObject); } module.exports = emptyObject; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var printWarning = function() {}; if (process.env.NODE_ENV !== 'production') { var ReactPropTypesSecret = __webpack_require__(6); var loggedTypeFailures = {}; printWarning = function(text) { var message = 'Warning: ' + text; if (typeof console !== 'undefined') { console.error(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; } /** * Assert that the values match with the type specs. * Error messages are memorized and will only be shown once. * * @param {object} typeSpecs Map of name to a ReactPropType * @param {object} values Runtime values that need to be type-checked * @param {string} location e.g. "prop", "context", "child context" * @param {string} componentName Name of the component for error messages. * @param {?Function} getStack Returns the component stack. * @private */ function checkPropTypes(typeSpecs, values, location, componentName, getStack) { if (process.env.NODE_ENV !== 'production') { for (var typeSpecName in typeSpecs) { if (typeSpecs.hasOwnProperty(typeSpecName)) { var error; // Prop type validation may throw. In case they do, we don't want to // fail the render phase where it didn't fail before. So we log it. // After these have been cleaned up, we'll let them throw. try { // This is intentionally an invariant that gets caught. It's the same // behavior as without this statement except with a better message. if (typeof typeSpecs[typeSpecName] !== 'function') { var err = Error( (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' ); err.name = 'Invariant Violation'; throw err; } error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); } catch (ex) { error = ex; } if (error && !(error instanceof Error)) { printWarning( (componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).' ) } if (error instanceof Error && !(error.message in loggedTypeFailures)) { // Only monitor this failure once because there tends to be a lot of the // same error. loggedTypeFailures[error.message] = true; var stack = getStack ? getStack() : ''; printWarning( 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') ); } } } } } module.exports = checkPropTypes; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(31); /***/ }), /* 13 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /** * Defines context for Form Renderer component */ var FormRendererContext = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext(); /* harmony default export */ __webpack_exports__["a"] = (FormRendererContext); /***/ }), /* 14 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormRenderer", function() { return FormRenderer; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_prop_types___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__FormElements_FormError__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__FormElements_Rows_Rows__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__FormElements_Form_Form__ = __webpack_require__(44); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__FormElements_ActionButtons__ = __webpack_require__(48); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Store_FormRendererContext__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__FieldControlFactory__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__validators_validatorFactory__ = __webpack_require__(51); 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; }; }(); 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"); } } 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; } /** * React specific imports */ /** * Lib specific imports */ /** * Main container component which bootstraps the form rendering based on the passed * form schema definition. */ var FormRenderer = function (_React$Component) { _inherits(FormRenderer, _React$Component); /** * Initializes a new instance of FormRenderer * @param {*} props - Passed in props */ function FormRenderer(props) { _classCallCheck(this, FormRenderer); // set internal component state var _this = _possibleConstructorReturn(this, (FormRenderer.__proto__ || Object.getPrototypeOf(FormRenderer)).call(this, props)); _this.deriveState(); // Bind the event handlers _this.bindEventHandlers(); // set field validators _this.setValidators(); return _this; } _createClass(FormRenderer, [{ key: 'render', value: function render() { var FormErrorComponent = this.getFormErrorComponent(); var context = this.getContext(); return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( __WEBPACK_IMPORTED_MODULE_6__Store_FormRendererContext__["a" /* default */].Provider, { value: context }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( FormErrorComponent, { onRenderError: this.onRenderError }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( __WEBPACK_IMPORTED_MODULE_4__FormElements_Form_Form__["a" /* default */], { formProperties: this.schema.formProperties, onChange: this.onChange, onFocus: this.props.onFocus ? this.onFocus : undefined, actionButtons: this.getActionButtons() }, this.getFormBody() ) ) ); } }, { key: 'deriveState', value: function deriveState() { // Holds form data. If client has passed formData object use it else initialize to empty object this.formData = this.props.formData || {}; // Hold the form schema this.schema = this.props.schema; // Hold the field validators this.validators = []; this.state = { showError: false, validationMessages: {} }; } }, { key: 'bindEventHandlers', value: function bindEventHandlers() { this.onSubmit = this.onSubmit.bind(this); this.onChange = this.onChange.bind(this); this.onFocus = this.onFocus.bind(this); this.onRenderError = this.onRenderError.bind(this); this.onNonSubmitAction = this.onNonSubmitAction.bind(this); this.getField = this.getField.bind(this); } /** * Creates Form Renderer context object */ }, { key: 'getContext', value: function getContext() { return { schema: this.schema, state: this.state, onChange: this.onChange, onSubmit: this.onSubmit, getField: this.getField, getValidationMessage: this.getValidationMessage }; } }, { key: 'getFormErrorComponent', value: function getFormErrorComponent() { return this.props.errorBoundary ? this.props.errorBoundary : __WEBPACK_IMPORTED_MODULE_2__FormElements_FormError__["a" /* default */]; } }, { key: 'getActionButtons', value: function getActionButtons() { var _this2 = this; return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_5__FormElements_ActionButtons__["a" /* ActionButtons */], { actionButtons: this.schema.actionButtons, onClick: function onClick(e) { _this2.onSubmit(e); }, onNonSubmitClick: this.onNonSubmitAction }); } }, { key: 'getFormBody', value: function getFormBody() { return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_3__FormElements_Rows_Rows__["a" /* default */], { rows: this.schema.rows }); } }, { key: 'onChange', value: function onChange(event, value) { this.formData[event.target.name] = this.getFieldValue(event, value); this.validate(); // if client has supplied onChange event handler via props, invoke it if (this.props.onChange) { this.props.onChange(this.formData); } } }, { key: 'onSubmit', value: function onSubmit(e) { e.preventDefault(); // perform form validation based on each field validator //this.validate(); this.props.onSubmit(this.formData); } }, { key: 'onNonSubmitAction', value: function onNonSubmitAction(event, action) { event.preventDefault(); action(event, this.formData); } }, { key: 'onFocus', value: function onFocus(event, value) { var fieldValue = this.getFieldValue(event, value); this.formData[event.target.name] = fieldValue; // if client has supplied onChange event handler via props, invoke it if (this.props.onFocus) { this.props.onFocus(event.target.name, fieldValue); } } }, { key: 'getField', value: function getField(fieldControl) { var Field = __WEBPACK_IMPORTED_MODULE_7__FieldControlFactory__["b" /* getFieldControl */](fieldControl.type); var id = this.getId(fieldControl); return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(Field, { field: fieldControl, id: id, onChange: this.onChange, onFocus: this.onFocus, value: this.formData[fieldControl.name] || '' }); } }, { key: 'getFieldValue', value: function getFieldValue(event, value) { return value != null ? value : event.target.value; } }, { key: 'onRenderError', value: function onRenderError(error, info) { if (this.props.onRenderError) { this.props.onRenderError(error, info); } } /** * Computes the id for each field. * By default, name is used as id for all rendered field. If schema contains rootIdPrefix, it is used * as a prefix * @param {object} fieldControl - Field control */ }, { key: 'getId', value: function getId(fieldControl) { var rootIdPrefix = this.schema.formProperties.rootIdPrefix; return rootIdPrefix ? rootIdPrefix + '-' + fieldControl.name : fieldControl.name; } }, { key: 'setValidators', value: function setValidators() { var _this3 = this; var rows = this.schema.rows; Object.keys(rows).forEach(function (rowKey) { var row = rows[rowKey]; Object.keys(row.fields).forEach(function (fieldKey) { var fieldControl = row.fields[fieldKey]; _this3.validators.push({ field: fieldControl.name, fieldTitle: fieldControl.label, validators: fieldControl.validators }); }, _this3); }, this); } }, { key: 'validate', value: function validate() { var _this4 = this; var validationMessages = {}; this.validators.forEach(function (fieldValidator) { var field = fieldValidator.field; var fieldTitle = fieldValidator.fieldTitle; var validators = fieldValidator.validators || []; // // get the field value from the form data var fieldValue = _this4.formData[field]; validationMessages[field] = []; Object.keys(validators).forEach(function (validatorKey) { var controlValidator = validators[validatorKey]; // call the validator var args = [field, fieldValue, fieldTitle].concat(_toConsumableArray(controlValidator.args)); var errorMessage = Object(__WEBPACK_IMPORTED_MODULE_8__validators_validatorFactory__["a" /* default */])(controlValidator.name).apply(undefined, _toConsumableArray(args)); if (!errorMessage.isValid) { validationMessages[field].push(errorMessage); } }); }, this); if (Object.keys(validationMessages).length > 0) { this.setState({ showError: true, validationMessages: validationMessages }); } } }, { key: 'getValidationMessage', value: function getValidationMessage(field) { var messages = this.state.validationMessages[field]; if (messages == null) { return []; } return messages.map(function (message) { return message.errorMessage; }); } }]); return FormRenderer; }(__WEBPACK_IMPORTED_MODULE_0_react___default.a.Component); // Define prop types for Form component FormRenderer.propTypes = { schema: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.object.isRequired, formData: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.object, onSubmit: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func, onChange: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func, onFocus: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func, onRenderError: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.func, errorBoundary: __WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.element }; // Give a default schema, so Form is rendered empty and not throwing errors FormRenderer.defaultProps = { schema: {} }; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** @license React v16.4.2 * react.production.min.js * * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var k=__webpack_require__(4),n=__webpack_require__(9),p=__webpack_require__(10),q=__webpack_require__(5),r="function"===typeof Symbol&&Symbol.for,t=r?Symbol.for("react.element"):60103,u=r?Symbol.for("react.portal"):60106,v=r?Symbol.for("react.fragment"):60107,w=r?Symbol.for("react.strict_mode"):60108,x=r?Symbol.for("react.profiler"):60114,y=r?Symbol.for("react.provider"):60109,z=r?Symbol.for("react.context"):60110,A=r?Symbol.for("react.async_mode"):60111,B= r?Symbol.for("react.forward_ref"):60112;r&&Symbol.for("react.timeout");var C="function"===typeof Symbol&&Symbol.iterator;function D(a){for(var b=arguments.length-1,e="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)e+="&args[]="+encodeURIComponent(arguments[c+1]);n(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",e)} var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}};function F(a,b,e){this.props=a;this.context=b;this.refs=p;this.updater=e||E}F.prototype.isReactComponent={};F.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?D("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};F.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};function G(){} G.prototype=F.prototype;function H(a,b,e){this.props=a;this.context=b;this.refs=p;this.updater=e||E}var I=H.prototype=new G;I.constructor=H;k(I,F.prototype);I.isPureReactComponent=!0;var J={current:null},K=Object.prototype.hasOwnProperty,L={key:!0,ref:!0,__self:!0,__source:!0}; function M(a,b,e){var c=void 0,d={},g=null,h=null;if(null!=b)for(c in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(g=""+b.key),b)K.call(b,c)&&!L.hasOwnProperty(c)&&(d[c]=b[c]);var f=arguments.length-2;if(1===f)d.children=e;else if(1<f){for(var l=Array(f),m=0;m<f;m++)l[m]=arguments[m+2];d.children=l}if(a&&a.defaultProps)for(c in f=a.defaultProps,f)void 0===d[c]&&(d[c]=f[c]);return{$$typeof:t,type:a,key:g,ref:h,props:d,_owner:J.current}} function N(a){return"object"===typeof a&&null!==a&&a.$$typeof===t}function escape(a){var b={"=":"=0",":":"=2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}var O=/\/+/g,P=[];function Q(a,b,e,c){if(P.length){var d=P.pop();d.result=a;d.keyPrefix=b;d.func=e;d.context=c;d.count=0;return d}return{result:a,keyPrefix:b,func:e,context:c,count:0}}function R(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>P.length&&P.push(a)} function S(a,b,e,c){var d=typeof a;if("undefined"===d||"boolean"===d)a=null;var g=!1;if(null===a)g=!0;else switch(d){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case t:case u:g=!0}}if(g)return e(c,a,""===b?"."+T(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var h=0;h<a.length;h++){d=a[h];var f=b+T(d,h);g+=S(d,f,e,c)}else if(null===a||"undefined"===typeof a?f=null:(f=C&&a[C]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a=f.call(a), h=0;!(d=a.next()).done;)d=d.value,f=b+T(d,h++),g+=S(d,f,e,c);else"object"===d&&(e=""+a,D("31","[object Object]"===e?"object with keys {"+Object.keys(a).join(", ")+"}":e,""));return g}function T(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function U(a,b){a.func.call(a.context,b,a.count++)} function V(a,b,e){var c=a.result,d=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?W(a,c,e,q.thatReturnsArgument):null!=a&&(N(a)&&(b=d+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(O,"$&/")+"/")+e,a={$$typeof:t,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}),c.push(a))}function W(a,b,e,c,d){var g="";null!=e&&(g=(""+e).replace(O,"$&/")+"/");b=Q(b,g,c,d);null==a||S(a,"",V,b);R(b)} var X={Children:{map:function(a,b,e){if(null==a)return a;var c=[];W(a,c,null,b,e);return c},forEach:function(a,b,e){if(null==a)return a;b=Q(null,null,b,e);null==a||S(a,"",U,b);R(b)},count:function(a){return null==a?0:S(a,"",q.thatReturnsNull,null)},toArray:function(a){var b=[];W(a,b,null,q.thatReturnsArgument);return b},only:function(a){N(a)?void 0:D("143");return a}},createRef:function(){return{current:null}},Component:F,PureComponent:H,createContext:function(a,b){void 0===b&&(b=null);a={$$typeof:z, _calculateChangedBits:b,_defaultValue:a,_currentValue:a,_currentValue2:a,_changedBits:0,_changedBits2:0,Provider:null,Consumer:null};a.Provider={$$typeof:y,_context:a};return a.Consumer=a},forwardRef:function(a){return{$$typeof:B,render:a}},Fragment:v,StrictMode:w,unstable_AsyncMode:A,unstable_Profiler:x,createElement:M,cloneElement:function(a,b,e){null===a||void 0===a?D("267",a):void 0;var c=void 0,d=k({},a.props),g=a.key,h=a.ref,f=a._owner;if(null!=b){void 0!==b.ref&&(h=b.ref,f=J.current);void 0!== b.key&&(g=""+b.key);var l=void 0;a.type&&a.type.defaultProps&&(l=a.type.defaultProps);for(c in b)K.call(b,c)&&!L.hasOwnProperty(c)&&(d[c]=void 0===b[c]&&void 0!==l?l[c]:b[c])}c=arguments.length-2;if(1===c)d.children=e;else if(1<c){l=Array(c);for(var m=0;m<c;m++)l[m]=arguments[m+2];d.children=l}return{$$typeof:t,type:a.type,key:g,ref:h,props:d,_owner:f}},createFactory:function(a){var b=M.bind(null,a);b.type=a;return b},isValidElement:N,version:"16.4.2",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:J, assign:k}},Y={default:X},Z=Y&&X||Y;module.exports=Z.default?Z.default:Z; /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(process) {/** @license React v16.4.2 * react.development.js * * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if (process.env.NODE_ENV !== "production") { (function() { 'use strict'; var _assign = __webpack_require__(4); var invariant = __webpack_require__(9); var emptyObject = __webpack_require__(10); var warning = __webpack_require__(17); var emptyFunction = __webpack_require__(5); var checkPropTypes = __webpack_require__(11); // TODO: this is special because it gets imported during build. var ReactVersion = '16.4.2'; // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === 'function' && Symbol.for; var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = '@@iterator'; function getIteratorFn(maybeIterable) { if (maybeIterable === null || typeof maybeIterable === 'undefined') { return null; } var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; if (typeof maybeIterator === 'function') { return maybeIterator; } return null; } // Relying on the `invariant()` implementation lets us // have preserve the format and params in the www builds. // Exports ReactDOM.createRoot // Experimental error-boundary API that can recover from errors within a single // render phase // Suspense var enableSuspense = false; // Helps identify side effects in begin-phase lifecycle hooks and setState reducers: // In some cases, StrictMode should also double-render lifecycles. // This can be confusing for tests though, // And it can be bad for performance in production. // This feature flag can be used to control the behavior: // To preserve the "Pause on caught exceptions" behavior of the debugger, we // replay the begin phase of a failed component inside invokeGuardedCallback. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: // Warn about legacy context API // Gather advanced timing metrics for Profiler subtrees. // Only used in www builds. /** * Forked from fbjs/warning: * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js * * Only change is we use console.warn instead of console.error, * and do nothing when 'console' is not supported. * This really simplifies the code. * --- * Similar to invariant but only logs a warning if the condition is not met. * This can be used to log issues in development environments in critical * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ var lowPriorityWarning = function () {}; { var printWarning = function (format) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } var argIndex = 0; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); if (typeof console !== 'undefined') { console.warn(message); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. throw new Error(message); } catch (x) {} }; lowPriorityWarning = function (condition, format) { if (format === undefined) { throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); } if (!condition) { for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { args[_key2 - 2] = arguments[_key2]; } printWarning.apply