{"ast":null,"code":"'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n  return typeof obj;\n} : function (obj) {\n  return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n};\n\nvar _createClass = function () {\n  function defineProperties(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n\n  return function (Constructor, protoProps, staticProps) {\n    if (protoProps) defineProperties(Constructor.prototype, protoProps);\n    if (staticProps) defineProperties(Constructor, staticProps);\n    return Constructor;\n  };\n}();\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\n\nvar _promisePolyfill = require('promise-polyfill');\n\nvar _promisePolyfill2 = _interopRequireDefault(_promisePolyfill);\n\nvar _reactLifecyclesCompat = require('react-lifecycles-compat');\n\nvar _ValidatorForm = require('./ValidatorForm');\n\nvar _ValidatorForm2 = _interopRequireDefault(_ValidatorForm);\n\nvar _utils = require('./utils');\n\nfunction _interopRequireDefault(obj) {\n  return obj && obj.__esModule ? obj : {\n    default: obj\n  };\n}\n\nfunction _classCallCheck(instance, Constructor) {\n  if (!(instance instanceof Constructor)) {\n    throw new TypeError(\"Cannot call a class as a function\");\n  }\n}\n\nfunction _possibleConstructorReturn(self, call) {\n  if (!self) {\n    throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n  }\n\n  return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self;\n}\n\nfunction _inherits(subClass, superClass) {\n  if (typeof superClass !== \"function\" && superClass !== null) {\n    throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n  }\n\n  subClass.prototype = Object.create(superClass && superClass.prototype, {\n    constructor: {\n      value: subClass,\n      enumerable: false,\n      writable: true,\n      configurable: true\n    }\n  });\n  if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n}\n/* eslint-disable */\n\n/* eslint-enable */\n\n\nvar ValidatorComponent = function (_React$Component) {\n  _inherits(ValidatorComponent, _React$Component);\n\n  function ValidatorComponent() {\n    var _ref;\n\n    var _temp, _this, _ret;\n\n    _classCallCheck(this, ValidatorComponent);\n\n    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n      args[_key] = arguments[_key];\n    }\n\n    return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ValidatorComponent.__proto__ || Object.getPrototypeOf(ValidatorComponent)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n      isValid: true,\n      value: _this.props.value,\n      errorMessages: _this.props.errorMessages,\n      validators: _this.props.validators\n    }, _this.getErrorMessage = function () {\n      var errorMessages = _this.state.errorMessages;\n      var type = typeof errorMessages === 'undefined' ? 'undefined' : _typeof(errorMessages);\n\n      if (type === 'string') {\n        return errorMessages;\n      } else if (type === 'object') {\n        if (_this.invalid.length > 0) {\n          return errorMessages[_this.invalid[0]];\n        }\n      } // eslint-disable-next-line\n\n\n      console.log('unknown errorMessages type', errorMessages);\n      return true;\n    }, _this.instantValidate = true, _this.invalid = [], _this.configure = function () {\n      _this.form.attachToForm(_this);\n\n      _this.instantValidate = _this.form.instantValidate;\n      _this.debounceTime = _this.form.debounceTime;\n      _this.validateDebounced = (0, _utils.debounce)(_this.validate, _this.debounceTime);\n    }, _this.validate = function (value) {\n      var includeRequired = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n      var dryRun = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n\n      var validations = _promisePolyfill2.default.all(_this.state.validators.map(function (validator) {\n        return _ValidatorForm2.default.getValidator(validator, value, includeRequired);\n      }));\n\n      return validations.then(function (results) {\n        _this.invalid = [];\n        var valid = true;\n        results.forEach(function (result, key) {\n          if (!result) {\n            valid = false;\n\n            _this.invalid.push(key);\n          }\n        });\n\n        if (!dryRun) {\n          _this.setState({\n            isValid: valid\n          }, function () {\n            _this.props.validatorListener(_this.state.isValid);\n          });\n        }\n\n        return valid;\n      });\n    }, _this.isValid = function () {\n      return _this.state.isValid;\n    }, _this.makeInvalid = function () {\n      _this.setState({\n        isValid: false\n      });\n    }, _this.makeValid = function () {\n      _this.setState({\n        isValid: true\n      });\n    }, _this.renderComponent = function (form) {\n      if (!_this.form) {\n        _this.form = form;\n      }\n\n      return _this.renderValidatorComponent();\n    }, _temp), _possibleConstructorReturn(_this, _ret);\n  }\n\n  _createClass(ValidatorComponent, [{\n    key: 'componentDidMount',\n    value: function componentDidMount() {\n      this.configure();\n    }\n  }, {\n    key: 'shouldComponentUpdate',\n    value: function shouldComponentUpdate(nextProps, nextState) {\n      return this.state !== nextState || this.props !== nextProps;\n    }\n  }, {\n    key: 'componentDidUpdate',\n    value: function componentDidUpdate(prevProps, prevState) {\n      if (this.instantValidate && this.props.value !== prevState.value) {\n        this.validateDebounced(this.props.value, this.props.withRequiredValidator);\n      }\n    }\n  }, {\n    key: 'componentWillUnmount',\n    value: function componentWillUnmount() {\n      this.form.detachFromForm(this);\n      this.validateDebounced.cancel();\n    }\n  }, {\n    key: 'render',\n    value: function render() {\n      var _this2 = this;\n\n      return _react2.default.createElement(_ValidatorForm.FormContext.Consumer, null, function (_ref2) {\n        var form = _ref2.form;\n        return _react2.default.createElement('div', _this2.props.containerProps, _this2.renderComponent(form));\n      });\n    }\n  }], [{\n    key: 'getDerivedStateFromProps',\n    value: function getDerivedStateFromProps(nextProps, prevState) {\n      if (nextProps.validators && nextProps.errorMessages && (prevState.validators !== nextProps.validators || prevState.errorMessages !== nextProps.errorMessages)) {\n        return {\n          value: nextProps.value,\n          validators: nextProps.validators,\n          errorMessages: nextProps.errorMessages\n        };\n      }\n\n      return {\n        value: nextProps.value\n      };\n    }\n  }]);\n\n  return ValidatorComponent;\n}(_react2.default.Component);\n\nValidatorComponent.propTypes = {\n  errorMessages: _propTypes2.default.oneOfType([_propTypes2.default.array, _propTypes2.default.string]),\n  validators: _propTypes2.default.array,\n  value: _propTypes2.default.any,\n  validatorListener: _propTypes2.default.func,\n  withRequiredValidator: _propTypes2.default.bool,\n  containerProps: _propTypes2.default.object\n};\nValidatorComponent.defaultProps = {\n  errorMessages: 'error',\n  validators: [],\n  validatorListener: function validatorListener() {}\n};\n(0, _reactLifecyclesCompat.polyfill)(ValidatorComponent);\nexports.default = ValidatorComponent;","map":{"version":3,"sources":["C:/laragon/www/itokin/DriverOPCDA/frontend/node_modules/react-form-validator-core/lib/ValidatorComponent.js"],"names":["Object","defineProperty","exports","value","_typeof","Symbol","iterator","obj","constructor","prototype","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","key","Constructor","protoProps","staticProps","_react","require","_react2","_interopRequireDefault","_propTypes","_propTypes2","_promisePolyfill","_promisePolyfill2","_reactLifecyclesCompat","_ValidatorForm","_ValidatorForm2","_utils","__esModule","default","_classCallCheck","instance","TypeError","_possibleConstructorReturn","self","call","ReferenceError","_inherits","subClass","superClass","create","setPrototypeOf","__proto__","ValidatorComponent","_React$Component","_ref","_temp","_this","_ret","_len","arguments","args","Array","_key","getPrototypeOf","apply","concat","state","isValid","errorMessages","validators","getErrorMessage","type","invalid","console","log","instantValidate","configure","form","attachToForm","debounceTime","validateDebounced","debounce","validate","includeRequired","undefined","dryRun","validations","all","map","validator","getValidator","then","results","valid","forEach","result","push","setState","validatorListener","makeInvalid","makeValid","renderComponent","renderValidatorComponent","componentDidMount","shouldComponentUpdate","nextProps","nextState","componentDidUpdate","prevProps","prevState","withRequiredValidator","componentWillUnmount","detachFromForm","cancel","render","_this2","createElement","FormContext","Consumer","_ref2","containerProps","getDerivedStateFromProps","Component","propTypes","oneOfType","array","string","any","func","bool","object","defaultProps","polyf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,OAAZ,CAAoB0F,IAJZ;AAK3BlB,EAAAA,qBAAqB,EAAEhF,WAAW,CAACQ,OAAZ,CAAoB2F,IALhB;AAM3BT,EAAAA,cAAc,EAAE1F,WAAW,CAACQ,OAAZ,CAAoB4F;AANT,CAA/B;AASA9E,kBAAkB,CAAC+E,YAAnB,GAAkC;AAC9B/D,EAAAA,aAAa,EAAE,OADe;AAE9BC,EAAAA,UAAU,EAAE,EAFkB;AAG9B6B,EAAAA,iBAAiB,EAAE,SAASA,iBAAT,GAA6B,CAAE;AAHpB,CAAlC;AAMA,CAAC,GAAGjE,sBAAsB,CAACmG,QAA3B,EAAqChF,kBAArC;AAEAjD,OAAO,CAACmC,OAAR,GAAkBc,kBAAlB","sourcesContent":["'use strict';\n\nObject.defineProperty(exports, \"__esModule\", {\n    value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _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; }; }();\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\n\nvar _promisePolyfill = require('promise-polyfill');\n\nvar _promisePolyfill2 = _interopRequireDefault(_promisePolyfill);\n\nvar _reactLifecyclesCompat = require('react-lifecycles-compat');\n\nvar _ValidatorForm = require('./ValidatorForm');\n\nvar _ValidatorForm2 = _interopRequireDefault(_ValidatorForm);\n\nvar _utils = require('./utils');\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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; }\n\nfunction _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; } /* eslint-disable */\n\n/* eslint-enable */\n\n\nvar ValidatorComponent = function (_React$Component) {\n    _inherits(ValidatorComponent, _React$Component);\n\n    function ValidatorComponent() {\n        var _ref;\n\n        var _temp, _this, _ret;\n\n        _classCallCheck(this, ValidatorComponent);\n\n        for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n            args[_key] = arguments[_key];\n        }\n\n        return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ValidatorComponent.__proto__ || Object.getPrototypeOf(ValidatorComponent)).call.apply(_ref, [this].concat(args))), _this), _this.state = {\n            isValid: true,\n            value: _this.props.value,\n            errorMessages: _this.props.errorMessages,\n            validators: _this.props.validators\n        }, _this.getErrorMessage = function () {\n            var errorMessages = _this.state.errorMessages;\n\n            var type = typeof errorMessages === 'undefined' ? 'undefined' : _typeof(errorMessages);\n\n            if (type === 'string') {\n                return errorMessages;\n            } else if (type === 'object') {\n                if (_this.invalid.length > 0) {\n                    return errorMessages[_this.invalid[0]];\n                }\n            }\n            // eslint-disable-next-line\n            console.log('unknown errorMessages type', errorMessages);\n            return true;\n        }, _this.instantValidate = true, _this.invalid = [], _this.configure = function () {\n            _this.form.attachToForm(_this);\n            _this.instantValidate = _this.form.instantValidate;\n            _this.debounceTime = _this.form.debounceTime;\n            _this.validateDebounced = (0, _utils.debounce)(_this.validate, _this.debounceTime);\n        }, _this.validate = function (value) {\n            var includeRequired = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n            var dryRun = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n\n            var validations = _promisePolyfill2.default.all(_this.state.validators.map(function (validator) {\n                return _ValidatorForm2.default.getValidator(validator, value, includeRequired);\n            }));\n\n            return validations.then(function (results) {\n                _this.invalid = [];\n                var valid = true;\n                results.forEach(function (result, key) {\n                    if (!result) {\n                        valid = false;\n                        _this.invalid.push(key);\n                    }\n                });\n                if (!dryRun) {\n                    _this.setState({ isValid: valid }, function () {\n                        _this.props.validatorListener(_this.state.isValid);\n                    });\n                }\n                return valid;\n            });\n        }, _this.isValid = function () {\n            return _this.state.isValid;\n        }, _this.makeInvalid = function () {\n            _this.setState({ isValid: false });\n        }, _this.makeValid = function () {\n            _this.setState({ isValid: true });\n        }, _this.renderComponent = function (form) {\n            if (!_this.form) {\n                _this.form = form;\n            }\n            return _this.renderValidatorComponent();\n        }, _temp), _possibleConstructorReturn(_this, _ret);\n    }\n\n    _createClass(ValidatorComponent, [{\n        key: 'componentDidMount',\n        value: function componentDidMount() {\n            this.configure();\n        }\n    }, {\n        key: 'shouldComponentUpdate',\n        value: function shouldComponentUpdate(nextProps, nextState) {\n            return this.state !== nextState || this.props !== nextProps;\n        }\n    }, {\n        key: 'componentDidUpdate',\n        value: function componentDidUpdate(prevProps, prevState) {\n            if (this.instantValidate && this.props.value !== prevState.value) {\n                this.validateDebounced(this.props.value, this.props.withRequiredValidator);\n            }\n        }\n    }, {\n        key: 'componentWillUnmount',\n        value: function componentWillUnmount() {\n            this.form.detachFromForm(this);\n            this.validateDebounced.cancel();\n        }\n    }, {\n        key: 'render',\n        value: function render() {\n            var _this2 = this;\n\n            return _react2.default.createElement(\n                _ValidatorForm.FormContext.Consumer,\n                null,\n                function (_ref2) {\n                    var form = _ref2.form;\n                    return _react2.default.createElement(\n                        'div',\n                        _this2.props.containerProps,\n                        _this2.renderComponent(form)\n                    );\n                }\n            );\n        }\n    }], [{\n        key: 'getDerivedStateFromProps',\n        value: function getDerivedStateFromProps(nextProps, prevState) {\n            if (nextProps.validators && nextProps.errorMessages && (prevState.validators !== nextProps.validators || prevState.errorMessages !== nextProps.errorMessages)) {\n                return {\n                    value: nextProps.value,\n                    validators: nextProps.validators,\n                    errorMessages: nextProps.errorMessages\n                };\n            }\n\n            return {\n                value: nextProps.value\n            };\n        }\n    }]);\n\n    return ValidatorComponent;\n}(_react2.default.Component);\n\nValidatorComponent.propTypes = {\n    errorMessages: _propTypes2.default.oneOfType([_propTypes2.default.array, _propTypes2.default.string]),\n    validators: _propTypes2.default.array,\n    value: _propTypes2.default.any,\n    validatorListener: _propTypes2.default.func,\n    withRequiredValidator: _propTypes2.default.bool,\n    containerProps: _propTypes2.default.object\n};\n\nValidatorComponent.defaultProps = {\n    errorMessages: 'error',\n    validators: [],\n    validatorListener: function validatorListener() {}\n};\n\n(0, _reactLifecyclesCompat.polyfill)(ValidatorComponent);\n\nexports.default = ValidatorComponent;"]},"metadata":{},"sourceType":"script"}