diff --git a/.gitignore b/.gitignore index 4c8d43b7..06efcddb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .DS_Store node_modules -examples/build/app.js +examples/build/app.js \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a58afc28..54de1334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Change Log + +# [1.0.6](https://github.com/andrewhathaway/Winterfell/releases/tag/1.0.6) (2016-01-02) + +**Implemented enhancements & merged pull requests:** + +- Add label/input associations for accessibility. [PR](https://github.com/andrewhathaway/Winterfell/pull/42) +- Implement fixes recommended by react-a11y. [PR](https://github.com/andrewhathaway/Winterfell/pull/48) + + +**Fixed bugs:** + +- Fixed typo in JSON Schema example in README. [Commit](https://github.com/andrewhathaway/Winterfell/commit/c63da73dc95c9f6fb1d418a582813165f5882378) +- Fix validation check in `addInputTypes` to actually check the variable passed in. [Commit](https://github.com/andrewhathaway/Winterfell/commit/196609ee640deac5491dbb7ebcb9562072b7f459) [PR](https://github.com/andrewhathaway/Winterfell/pull/47) + + ## [1.0.5](https://github.com/andrewhathaway/Winterfell/releases/tag/1.0.5) (2015-10-08) **Implemented enhancements & merged pull requests:** diff --git a/dist/button.js b/dist/button.js deleted file mode 100644 index 92e8e235..00000000 --- a/dist/button.js +++ /dev/null @@ -1,53 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var Button = (function (_React$Component) { - _inherits(Button, _React$Component); - - function Button() { - _classCallCheck(this, Button); - - _get(Object.getPrototypeOf(Button.prototype), 'constructor', this).apply(this, arguments); - } - - _createClass(Button, [{ - key: 'handleClick', - value: function handleClick(e) { - e.preventDefault(); - - this.props.onClick(); - } - }, { - key: 'render', - value: function render() { - return React.createElement( - 'a', - { href: '#', - className: this.props.className, - onClick: this.handleClick.bind(this) }, - this.props.text - ); - } - }]); - - return Button; -})(React.Component); - -; - -Button.defaultProps = { - text: 'Submit', - className: undefined, - onClick: function onClick() {} -}; - -module.exports = Button; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6685afa0..00000000 --- a/dist/index.js +++ /dev/null @@ -1,208 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); -var _ = require('lodash').noConflict(); - -var QuestionPanel = require('./questionPanel'); - -var Winterfell = (function (_React$Component) { - _inherits(Winterfell, _React$Component); - - function Winterfell(props) { - _classCallCheck(this, Winterfell); - - _get(Object.getPrototypeOf(Winterfell.prototype), 'constructor', this).call(this, props); - - this.panelHistory = []; - - var schema = _.extend({ - classes: {}, - formPanels: [], - questionPanels: [], - questionSets: [] - }, this.props.schema); - - schema.formPanels = schema.formPanels.sort(function (a, b) { - return a.index > b.index; - }); - - var panelId = typeof this.props.panelId !== 'undefined' ? this.props.panelId : schema.formPanels.length > 0 ? schema.formPanels[0].panelId : undefined; - - var currentPanel = typeof schema !== 'undefined' && typeof schema.formPanels !== 'undefined' && typeof panelId !== 'undefined' ? _.find(schema.formPanels, function (panel) { - return panel.panelId == panelId; - }) : undefined; - - if (!currentPanel) { - throw new Error('Winterfell: Could not find initial panel and failed to render.'); - } - - this.state = { - schema: schema, - currentPanel: currentPanel, - action: this.props.action, - questionAnswers: this.props.questionAnswers - }; - } - - _createClass(Winterfell, [{ - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - this.setState({ - action: nextProps.action, - schema: nextProps.schema, - questionAnswers: nextProps.questionAnswers - }); - } - }, { - key: 'handleAnswerChange', - value: function handleAnswerChange(questionId, questionAnswer) { - var questionAnswers = _.chain(this.state.questionAnswers).set(questionId, questionAnswer).value(); - - this.setState({ - questionAnswers: questionAnswers - }, this.props.onUpdate.bind(null, questionAnswers)); - } - }, { - key: 'handleSwitchPanel', - value: function handleSwitchPanel(panelId, preventHistory) { - var panel = _.find(this.props.schema.formPanels, { - panelId: panelId - }); - - if (!panel) { - throw new Error('Winterfell: Tried to switch to panel "' + panelId + '", which does not exist.'); - } - - if (!preventHistory) { - this.panelHistory.push(panel.panelId); - } - - this.setState({ - currentPanel: panel - }, this.props.onSwitchPanel.bind(null, panel)); - } - }, { - key: 'handleBackButtonClick', - value: function handleBackButtonClick() { - this.panelHistory.pop(); - - this.handleSwitchPanel.call(this, this.panelHistory[this.panelHistory.length - 1], true); - } - }, { - key: 'handleSubmit', - value: function handleSubmit(action) { - var _this = this; - - if (this.props.disableSubmit) { - this.props.onSubmit(this.state.questionAnswers, action); - return; - } - - /* - * If we are not disabling the functionality of the form, - * we need to set the action provided in the form, then submit. - */ - this.setState({ - action: action - }, function () { - React.findDOMNode(_this.refs[_this.props.ref]).submit(); - }); - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var currentPanel = _.find(this.state.schema.questionPanels, function (panel) { - return panel.panelId == _this2.state.currentPanel.panelId; - }); - - return React.createElement( - 'form', - { method: this.props.method, - encType: this.props.encType, - action: this.state.action, - ref: this.props.ref, - className: this.state.schema.classes.form }, - React.createElement( - 'div', - { className: this.state.schema.classes.questionPanels }, - React.createElement(QuestionPanel, { schema: this.state.schema, - classes: this.state.schema.classes, - panelId: currentPanel.panelId, - panelIndex: currentPanel.panelIndex, - panelHeader: currentPanel.panelHeader, - panelText: currentPanel.panelText, - action: currentPanel.action, - button: currentPanel.button, - backButton: currentPanel.backButton, - questionSets: currentPanel.questionSets, - questionAnswers: this.state.questionAnswers, - panelHistory: this.panelHistory, - renderError: this.props.renderError, - renderRequiredAsterisk: this.props.renderRequiredAsterisk, - onAnswerChange: this.handleAnswerChange.bind(this), - onPanelBack: this.handleBackButtonClick.bind(this), - onSwitchPanel: this.handleSwitchPanel.bind(this), - onSubmit: this.handleSubmit.bind(this) }) - ) - ); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - this.panelHistory.push(this.state.currentPanel.panelId); - this.props.onRender(); - } - }]); - - return Winterfell; -})(React.Component); - -; - -// @todo: Proptypes -Winterfell.defaultProps = { - schema: { - formPanels: [], - questionPanels: [], - questionSets: [], - classes: {} - }, - questionAnswers: {}, - ref: 'form', - encType: 'application/x-www-form-urlencoded', - method: 'POST', - action: '', - panelId: undefined, - disableSubmit: false, - renderError: undefined, - renderRequiredAsterisk: undefined, - onSubmit: function onSubmit() {}, - onUpdate: function onUpdate() {}, - onSwitchPanel: function onSwitchPanel() {}, - onRender: function onRender() {} -}; - -Winterfell.inputTypes = require('./inputTypes'); -Winterfell.errorMessages = require('./lib/errors'); -Winterfell.validation = require('./lib/validation'); - -Winterfell.addInputType = Winterfell.inputTypes.addInputType; -Winterfell.addInputTypes = Winterfell.inputTypes.addInputTypes; - -Winterfell.addErrorMessage = Winterfell.errorMessages.addErrorMessage; -Winterfell.addErrorMessages = Winterfell.errorMessages.addErrorMessages; - -Winterfell.addValidationMethod = Winterfell.validation.addValidationMethod; -Winterfell.addValidationMethods = Winterfell.validation.addValidationMethods; - -module.exports = Winterfell; \ No newline at end of file diff --git a/dist/inputTypes/checkboxInput.js b/dist/inputTypes/checkboxInput.js deleted file mode 100644 index ca4d686f..00000000 --- a/dist/inputTypes/checkboxInput.js +++ /dev/null @@ -1,86 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var CheckboxInput = (function (_React$Component) { - _inherits(CheckboxInput, _React$Component); - - function CheckboxInput(props) { - _classCallCheck(this, CheckboxInput); - - _get(Object.getPrototypeOf(CheckboxInput.prototype), 'constructor', this).call(this, props); - - this.state = { - checked: props.defaultChecked - }; - } - - _createClass(CheckboxInput, [{ - key: 'handleChange', - value: function handleChange(e) { - var _this = this; - - if (e) { - this.setState({ - 'checked': !this.state.checked - }, function () { - _this.props.onChange(_this.state.checked ? _this.props.value : undefined); - }); - } else { - this.props.onChange(this.state.checked ? this.props.value : undefined); - } - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - if (this.state.checked) { - this.handleChange(); - } - } - }, { - key: 'render', - value: function render() { - return React.createElement( - 'div', - { className: this.props.classes.checkboxInput }, - React.createElement( - 'label', - { className: this.props.classes.checkboxLabel }, - React.createElement('input', { type: 'checkbox', - name: this.props.name, - className: this.props.classes.checkbox, - defaultChecked: this.state.checked, - value: this.props.value, - required: this.props.required ? 'required' : undefined, - onChange: this.handleChange.bind(this), - onBlur: this.props.onBlur.bind(null, this.state.checked ? this.props.value : undefined) }), - this.props.text - ) - ); - } - }]); - - return CheckboxInput; -})(React.Component); - -; - -CheckboxInput.defaultProps = { - text: '', - defaultChecked: false, - classes: {}, - name: undefined, - value: undefined, - onChange: function onChange() {}, - onBlur: function onBlur() {} -}; - -module.exports = CheckboxInput; \ No newline at end of file diff --git a/dist/inputTypes/checkboxOptionsInput.js b/dist/inputTypes/checkboxOptionsInput.js deleted file mode 100644 index bc20dd7b..00000000 --- a/dist/inputTypes/checkboxOptionsInput.js +++ /dev/null @@ -1,89 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var CheckboxOptionsInput = (function (_React$Component) { - _inherits(CheckboxOptionsInput, _React$Component); - - function CheckboxOptionsInput(props) { - _classCallCheck(this, CheckboxOptionsInput); - - _get(Object.getPrototypeOf(CheckboxOptionsInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(CheckboxOptionsInput, [{ - key: 'handleChange', - value: function handleChange(e) { - var value = this.state.value; - - if (e.target.checked) { - value.push(e.target.value); - } else { - value = value.filter(function (val) { - return val != e.target.value; - }); - } - - this.setState({ - value: value - }, this.props.onChange.bind(null, value)); - } - }, { - key: 'render', - value: function render() { - var _this = this; - - return React.createElement( - 'ul', - { className: this.props.classes.checkboxList }, - this.props.options.map(function (opt) { - return React.createElement( - 'li', - { key: opt.value, - className: _this.props.classes.checkboxListItem }, - React.createElement( - 'label', - { className: _this.props.classes.checkboxLabel }, - React.createElement('input', { type: 'checkbox', - name: _this.props.name, - value: opt.value, - checked: _this.state.value.indexOf(opt.value) > -1, - className: _this.props.classes.checkbox, - required: _this.props.required ? 'required' : undefined, - onChange: _this.handleChange.bind(_this), - onBlur: _this.props.onBlur.bind(null, _this.state.value) }), - opt.text - ) - ); - }) - ); - } - }]); - - return CheckboxOptionsInput; -})(React.Component); - -; - -CheckboxOptionsInput.defaultProps = { - classes: {}, - name: undefined, - value: [], - options: [], - onChange: function onChange() {}, - onBlur: function onBlur() {} -}; - -module.exports = CheckboxOptionsInput; \ No newline at end of file diff --git a/dist/inputTypes/emailInput.js b/dist/inputTypes/emailInput.js deleted file mode 100644 index 2907a76f..00000000 --- a/dist/inputTypes/emailInput.js +++ /dev/null @@ -1,65 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var EmailInput = (function (_React$Component) { - _inherits(EmailInput, _React$Component); - - function EmailInput(props) { - _classCallCheck(this, EmailInput); - - _get(Object.getPrototypeOf(EmailInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(EmailInput, [{ - key: 'handleChange', - value: function handleChange(e) { - this.setState({ - value: e.target.value - }, this.props.onChange.bind(null, e.target.value)); - } - }, { - key: 'render', - value: function render() { - return React.createElement('input', { type: 'email', - name: this.props.name, - id: this.props.id, - className: this.props.classes.input, - placeholder: this.props.placeholder, - value: this.state.value, - required: this.props.required ? 'required' : undefined, - onChange: this.handleChange.bind(this), - onBlur: this.props.onBlur.bind(null, this.state.value), - onKeyDown: this.props.onKeyDown }); - } - }]); - - return EmailInput; -})(React.Component); - -; - -EmailInput.defaultProps = { - classes: {}, - name: undefined, - id: undefined, - value: undefined, - placeholder: undefined, - onChange: function onChange() {}, - onBlur: function onBlur() {}, - onKeyDown: function onKeyDown() {} -}; - -module.exports = EmailInput; \ No newline at end of file diff --git a/dist/inputTypes/fileInput.js b/dist/inputTypes/fileInput.js deleted file mode 100644 index e47f34b8..00000000 --- a/dist/inputTypes/fileInput.js +++ /dev/null @@ -1,60 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var FileInput = (function (_React$Component) { - _inherits(FileInput, _React$Component); - - function FileInput(props) { - _classCallCheck(this, FileInput); - - _get(Object.getPrototypeOf(FileInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(FileInput, [{ - key: 'handleChange', - value: function handleChange(e) { - this.setState({ - value: e.target.value - }, this.props.onChange.bind(null, e.target.value)); - } - }, { - key: 'render', - value: function render() { - return React.createElement('input', { type: 'file', - name: this.props.name, - id: this.props.id, - className: this.props.classes.file, - required: this.props.required ? 'required' : undefined, - onChange: this.handleChange.bind(this), - onBlur: this.props.onBlur.bind(null, this.state.value) }); - } - }]); - - return FileInput; -})(React.Component); - -; - -FileInput.defaultProps = { - classes: {}, - name: undefined, - id: undefined, - value: undefined, - onChange: function onChange() {}, - onBlur: function onBlur() {} -}; - -module.exports = FileInput; \ No newline at end of file diff --git a/dist/inputTypes/hiddenInput.js b/dist/inputTypes/hiddenInput.js deleted file mode 100644 index d450df78..00000000 --- a/dist/inputTypes/hiddenInput.js +++ /dev/null @@ -1,45 +0,0 @@ -"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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -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; } - -var React = require('react'); - -var HiddenInput = (function (_React$Component) { - _inherits(HiddenInput, _React$Component); - - function HiddenInput(props) { - _classCallCheck(this, HiddenInput); - - _get(Object.getPrototypeOf(HiddenInput.prototype), "constructor", this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(HiddenInput, [{ - key: "render", - value: function render() { - return React.createElement("input", { type: "hidden", - name: this.props.name, - value: this.state.value }); - } - }]); - - return HiddenInput; -})(React.Component); - -; - -HiddenInput.defaultProps = { - name: undefined, - value: undefined -}; - -module.exports = HiddenInput; \ No newline at end of file diff --git a/dist/inputTypes/index.js b/dist/inputTypes/index.js deleted file mode 100644 index 3f3814ae..00000000 --- a/dist/inputTypes/index.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -var React = require('react'); - -var inputTypes = { - checkboxInput: require('./checkboxInput'), - checkboxOptionsInput: require('./checkboxOptionsInput'), - emailInput: require('./emailInput'), - fileInput: require('./fileInput'), - hiddenInput: require('./hiddenInput'), - passwordInput: require('./passwordInput'), - radioOptionsInput: require('./radioOptionsInput'), - selectInput: require('./selectInput'), - textareaInput: require('./textareaInput'), - textInput: require('./textInput') -}; - -/** - * Add an input type - * - * @param type name Name of InputType - * @param Component instance Input Type Component - */ -inputTypes.addInputType = function (name, instance) { - if (typeof name !== 'string') { - throw new Error('Winterfell: First parameter of addInputType ' + 'must be of type string'); - } - - if (!React.Component instanceof instance.constructor) { - throw new Error('Winterfell: Cannot not assign "' + name + '" as an inputType. ' + 'Second paramter expects a React component'); - } - - inputTypes[name] = instance; -}; - -/** - * Add multiple InputTypes - * - * @param object types InputTypes to add. string => Component - */ -inputTypes.addInputTypes = function (types) { - if (typeof messages !== 'object') { - throw new Error('Winterfell: First parameter of addInputTypes ' + 'must be of type object'); - } - - for (var type in types) { - inputTypes.addInputType(type, types[type]); - } -}; - -module.exports = inputTypes; \ No newline at end of file diff --git a/dist/inputTypes/passwordInput.js b/dist/inputTypes/passwordInput.js deleted file mode 100644 index dda89e10..00000000 --- a/dist/inputTypes/passwordInput.js +++ /dev/null @@ -1,65 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var PasswordInput = (function (_React$Component) { - _inherits(PasswordInput, _React$Component); - - function PasswordInput(props) { - _classCallCheck(this, PasswordInput); - - _get(Object.getPrototypeOf(PasswordInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(PasswordInput, [{ - key: 'handleChange', - value: function handleChange(e) { - this.setState({ - value: e.target.value - }, this.props.onChange.bind(null, e.target.value)); - } - }, { - key: 'render', - value: function render() { - return React.createElement('input', { type: 'password', - name: this.props.name, - id: this.props.id, - className: this.props.classes.input, - placeholder: this.props.placeholder, - value: this.state.value, - required: this.props.required ? 'required' : undefined, - onChange: this.handleChange.bind(this), - onBlur: this.props.onBlur.bind(null, this.state.value), - onKeyDown: this.props.onKeyDown }); - } - }]); - - return PasswordInput; -})(React.Component); - -; - -PasswordInput.defaultProps = { - classes: {}, - name: undefined, - id: undefined, - value: undefined, - placeholder: undefined, - onChange: function onChange() {}, - onBlur: function onBlur() {}, - onKeyDown: function onKeyDown() {} -}; - -module.exports = PasswordInput; \ No newline at end of file diff --git a/dist/inputTypes/radioOptionsInput.js b/dist/inputTypes/radioOptionsInput.js deleted file mode 100644 index 1958003a..00000000 --- a/dist/inputTypes/radioOptionsInput.js +++ /dev/null @@ -1,78 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var RadioOptionsInput = (function (_React$Component) { - _inherits(RadioOptionsInput, _React$Component); - - function RadioOptionsInput(props) { - _classCallCheck(this, RadioOptionsInput); - - _get(Object.getPrototypeOf(RadioOptionsInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(RadioOptionsInput, [{ - key: 'handleChange', - value: function handleChange(value) { - this.setState({ - value: value - }, this.props.onChange.bind(null, value)); - } - }, { - key: 'render', - value: function render() { - var _this = this; - - return React.createElement( - 'ul', - { className: this.props.classes.radioList }, - this.props.options.map(function (opt) { - return React.createElement( - 'li', - { key: opt.value, - className: _this.props.classes.radioListItem }, - React.createElement( - 'label', - { className: _this.props.classes.radioLabel }, - React.createElement('input', { type: 'radio', - name: _this.props.name, - checked: _this.state.value == opt.value, - className: _this.props.classes.radio, - required: _this.props.required ? 'required' : undefined, - onChange: _this.handleChange.bind(_this, opt.value), - onBlur: _this.props.onBlur.bind(null, _this.state.value) }), - opt.text - ) - ); - }) - ); - } - }]); - - return RadioOptionsInput; -})(React.Component); - -; - -RadioOptionsInput.defaultProps = { - classes: {}, - name: undefined, - value: undefined, - options: [], - onChange: function onChange() {}, - onBlur: function onBlur() {} -}; - -module.exports = RadioOptionsInput; \ No newline at end of file diff --git a/dist/inputTypes/selectInput.js b/dist/inputTypes/selectInput.js deleted file mode 100644 index a6998ebd..00000000 --- a/dist/inputTypes/selectInput.js +++ /dev/null @@ -1,88 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var SelectInput = (function (_React$Component) { - _inherits(SelectInput, _React$Component); - - function SelectInput(props) { - _classCallCheck(this, SelectInput); - - _get(Object.getPrototypeOf(SelectInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(SelectInput, [{ - key: 'handleChange', - value: function handleChange(e) { - this.setState({ - value: e.target.value - }, this.props.onChange.bind(null, e.target.value)); - } - }, { - key: 'render', - value: function render() { - var options = this.props.options.map(function (opt) { - return React.createElement( - 'option', - { key: opt.value, - value: opt.value }, - opt.text - ); - }); - - return React.createElement( - 'select', - { name: this.props.name, - id: this.props.id, - className: this.props.classes.select, - value: this.state.value, - ref: 'select', - required: this.props.required ? 'required' : undefined, - onChange: this.handleChange.bind(this), - onBlur: this.props.onBlur.bind(null, this.state.value) }, - options - ); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - /* - * Selects automatically pick the first item, so - * make sure we set it. - */ - this.handleChange({ - target: { - value: this.refs.select.getDOMNode().value - } - }); - } - }]); - - return SelectInput; -})(React.Component); - -; - -SelectInput.defaultProps = { - classes: {}, - name: undefined, - id: undefined, - value: undefined, - options: [], - onChange: function onChange() {}, - onBlur: function onBlur() {} -}; - -module.exports = SelectInput; \ No newline at end of file diff --git a/dist/inputTypes/textInput.js b/dist/inputTypes/textInput.js deleted file mode 100644 index 1dba441c..00000000 --- a/dist/inputTypes/textInput.js +++ /dev/null @@ -1,65 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var TextInput = (function (_React$Component) { - _inherits(TextInput, _React$Component); - - function TextInput(props) { - _classCallCheck(this, TextInput); - - _get(Object.getPrototypeOf(TextInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(TextInput, [{ - key: 'handleChange', - value: function handleChange(e) { - this.setState({ - value: e.target.value - }, this.props.onChange.bind(null, e.target.value)); - } - }, { - key: 'render', - value: function render() { - return React.createElement('input', { type: 'text', - name: this.props.name, - id: this.props.id, - className: this.props.classes.input, - placeholder: this.props.placeholder, - value: this.state.value, - required: this.props.required ? 'required' : undefined, - onChange: this.handleChange.bind(this), - onBlur: this.props.onBlur.bind(null, this.state.value), - onKeyDown: this.props.onKeyDown }); - } - }]); - - return TextInput; -})(React.Component); - -; - -TextInput.defaultProps = { - classes: {}, - name: undefined, - id: undefined, - value: undefined, - placeholder: undefined, - onChange: function onChange() {}, - onBlur: function onBlur() {}, - onKeyDown: function onKeyDown() {} -}; - -module.exports = TextInput; \ No newline at end of file diff --git a/dist/inputTypes/textareaInput.js b/dist/inputTypes/textareaInput.js deleted file mode 100644 index 14ce6983..00000000 --- a/dist/inputTypes/textareaInput.js +++ /dev/null @@ -1,63 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); - -var TextareaInput = (function (_React$Component) { - _inherits(TextareaInput, _React$Component); - - function TextareaInput(props) { - _classCallCheck(this, TextareaInput); - - _get(Object.getPrototypeOf(TextareaInput.prototype), 'constructor', this).call(this, props); - - this.state = { - value: this.props.value - }; - } - - _createClass(TextareaInput, [{ - key: 'handleChange', - value: function handleChange(e) { - this.setState({ - value: e.target.value - }, this.props.onChange.bind(null, e.target.value)); - } - }, { - key: 'render', - value: function render() { - return React.createElement('textarea', { type: 'text', - name: this.props.name, - id: this.props.id, - className: this.props.classes.input, - placeholder: this.props.placeholder, - value: this.state.value, - required: this.props.required ? 'required' : undefined, - onChange: this.handleChange.bind(this), - onBlur: this.props.onBlur.bind(null, this.state.value) }); - } - }]); - - return TextareaInput; -})(React.Component); - -; - -TextareaInput.defaultProps = { - classes: {}, - name: undefined, - id: undefined, - value: undefined, - placeholder: undefined, - onChange: function onChange() {}, - onBlur: function onBlur() {} -}; - -module.exports = TextareaInput; \ No newline at end of file diff --git a/dist/lib/errors.js b/dist/lib/errors.js deleted file mode 100644 index 7f0b2682..00000000 --- a/dist/lib/errors.js +++ /dev/null @@ -1,198 +0,0 @@ -'use strict'; - -var errorMessages = { - - /* - * Fallback Error Message - */ - 'default': 'Please correct the field below', - - /* - * Min and Max string left message - */ - isLength: function isLength(validationItem) { - switch (validationItem.params.length) { - - case 1: - return 'Please enter a value with at least ' + validationItem.params[0] + ' character' + (validationItem.params[0] != 1 ? 's' : ''); - break; - - case 2: - return 'Please enter a valiue between ' + validationItem.params[0] + ' and ' + validationItem.params[1] + ' characters long'; - break; - - default: - return errorMessages['default']; - break; - - } - - return errorMessage; - }, - - /* - * Valid email address - */ - isEmail: 'Please enter a valid email address', - - /* - * String contains seed - */ - contains: function contains(validationItem) { - return 'Please enter a value that contains "' + validationItem.params[0] + '"'; - }, - - /* - * String equals string - */ - equals: function equals(validationItem) { - return 'Value must equal ' + validationItem.params[0]; - }, - - /* - * Characters A-Z only - */ - isAlpha: 'Please only enter letters', - - /* - * Characters A-Z and 1-9 only - */ - isAlphanumeric: 'Please only enter letters and numbers', - - /* - * Credit card - */ - isCreditCard: 'Please enter a valid credit card number', - - /* - * Currency - */ - isCurrency: 'Please enter a current value only', - - /* - * Date - */ - isDate: 'Please enter a valid date', - - /* - * Decimal value - */ - isDecimal: 'Please enter a decimal value only', - - /* - * Float value - */ - isFloat: 'Please enter a float value only', - - /* - * IP value - */ - isIP: 'Please enter a valid IP address', - - /* - * isIn array of items - */ - isIn: 'Please enter one of the allowed values', - - /* - * isAllIn array of items - */ - isAllIn: 'Please enter one of the allowed values', - - /* - * JSON Value - */ - isJSON: 'Please enter a valid JSON string', - - /* - * Lowercase values only - */ - isLowercase: 'Please enter lowercase characters only', - - /* - * Uppercase values only - */ - isUppercase: 'Please enter uppercase characters only', - - /* - * Mobile phone - */ - isMobilePhone: 'Please enter a valid mobile phone', - - /* - * MongoId only - */ - isMongoId: 'Please enter a valid MongoId', - - /* - * Numbers only - */ - isNumeric: 'Please enter numbers only', - - /* - * URL Only - */ - isURL: 'Please enter a valid URL', - - /* - * isAccepted - checkbox - */ - isAccepted: 'Please accept by clicking the checkbox' -}; - -/** - * Add a single error message - * - * @param string type Error message type - * @param string|function message Message or function to get message - */ -errorMessages.addErrorMessage = function (type, message) { - if (typeof type !== 'string') { - throw new Error('Winterfell: First parameter of addErrorMessage ' + 'must be of type string'); - } - - if (typeof message !== 'function' && typeof message !== 'string') { - throw new Error('Winterfell: Second parameter of addErrorMessage ' + 'must be of type function or string'); - } - - setErrorMessage(type, message); -}; - -/** - * Add multiple error messages - * - * @param object messages Error messages to add. type => func|string - */ -errorMessages.addErrorMessages = function (messages) { - if (typeof messages !== 'object') { - throw new Error('Winterfell: First parameter of addErrorMessages ' + 'must be of type object'); - } - - for (var type in messages) { - errorMessages.addErrorMessage(type, messages[type]); - } -}; - -/** - * Get an error message for a validationItem - * - * @param object validationItem Validation error item - * @return string Error message to display - */ -errorMessages.getErrorMessage = function (validationItem) { - var errorMessage = typeof validationItem.message !== 'undefined' ? validationItem.message : typeof errorMessages[validationItem.type] !== 'undefined' ? errorMessages[validationItem.type] : errorMessages['default']; - - return typeof errorMessage === 'function' ? errorMessage(validationItem) : errorMessage; -}; - -/** - * setErrorMessage - * - * @param string type Error message type - * @param stirng|function message essage or function to get message - */ -var setErrorMessage = function setErrorMessage(type, message) { - errorMessages[type] = message; -}; - -module.exports = errorMessages; \ No newline at end of file diff --git a/dist/lib/stringParser.js b/dist/lib/stringParser.js deleted file mode 100644 index b95b0b71..00000000 --- a/dist/lib/stringParser.js +++ /dev/null @@ -1,71 +0,0 @@ -'use strict'; - -module.exports = function (template, params) { - template = template || ''; - params = params || {}; - - /* - * Split up template in to array of characters - */ - var characters = template.split(''); - - var buffer = ''; - var parsedTemplate = ''; - var collecting = false; - - for (var i = 0; i < characters.length; i++) { - var currentChar = characters[i]; - - /* - * If we're not collecting and we're not - * and opening or closing brace then - * append the charater to the - * parsedTemplate and move on - */ - if (!collecting && currentChar != '{' && currentChar != '}') { - parsedTemplate += currentChar; - continue; - } - - /* - * If we're an opening brace, - * start collecting for the buffer - */ - if (currentChar == '{') { - collecting = true; - } - - /* - * If we're here, we're collecting so if - * we're not a brace of any sort then add - * the character to the buffer - */ - if (currentChar != '{' && currentChar != '}') { - buffer += currentChar; - } - - /* - * If we're a closing brace, then we - * attempt to get the value with the - * buffers name from the params object - * and add it to the parsedTemplate - */ - if (currentChar == '}') { - var value = ''; - if (typeof params[buffer] !== 'undefined') { - value = params[buffer]; - } - - parsedTemplate += value; - - /* - * Stop collecting and reset - * the buffer to nothing - */ - collecting = false; - buffer = ''; - } - } - - return parsedTemplate; -}; \ No newline at end of file diff --git a/dist/lib/validation.js b/dist/lib/validation.js deleted file mode 100644 index 8dea9e74..00000000 --- a/dist/lib/validation.js +++ /dev/null @@ -1,209 +0,0 @@ -'use strict'; - -var _ = require('lodash').noConflict(); -var Validator = require('validator'); -var StringParser = require('./stringParser'); - -var extraValidators = { - - /* - * isAccepted Validation Mehod - */ - isAccepted: function isAccepted(value, expected) { - return value == expected; - }, - - /* - * isAllIn Validation Method - */ - isAllIn: function isAllIn(value, options) { - if (!value) { - return false; - } - - return _.every(value, function (item) { - return options.indexOf(item) > -1; - }); - } - -}; - -/** - * Validate a value against a validation item - * - * @param any value Value being tested - * @param object validationItem Rule set for validator - * @return boolean Valid? - */ -var validateAnswer = function validateAnswer(value, validationItem, questionAnswers) { - var validationMethod = typeof extraValidators[validationItem.type] !== 'undefined' ? extraValidators[validationItem.type] : Validator.hasOwnProperty(validationItem.type) && typeof Validator[validationItem.type] === 'function' ? Validator[validationItem.type] : undefined; - - if (!validationMethod) { - throw new Error('Winterfell: Attempted to validate for undefined method "' + validationItem.type + '"'); - } - - /* - * Clone the validation parameters so it doesn't effect the - * parameters elsewhere by reference. - */ - var validationParameters = (validationItem.params || []).slice(0); - - /* - * Run the parameters through the stringParser with the - * questionAnswers so that it sets the questionAnswer - * as the parameter. - */ - validationParameters = validationParameters.map(function (p) { - return typeof p === 'string' ? StringParser(p, questionAnswers) : p; - }); - - /* - * Push the value of the question we're validating to - * the first parameter of the validationParameters - */ - validationParameters.unshift(value); - - /* - * Return the result of the validation method running - * wtih the validationParameters. - */ - return validationMethod.apply(null, validationParameters); -}; - -/** - * Get active questions from an array of questions, - * recursively. Follows active conditions. - * - * @param array questions Questions to run through - * @param object questionAnswers Current answers for questions - * @param array activeQuestions - * @return array All active questions - */ -var getActiveQuestions = function getActiveQuestions(questions, questionAnswers, activeQuestions) { - activeQuestions = activeQuestions || []; - - questions.forEach(function (question) { - activeQuestions.push({ - questionId: question.questionId, - validations: question.validations - }); - - if (typeof question.input.options === 'undefined' || question.input.options.length === 0) { - return; - } - - question.input.options.forEach(function (option) { - if (typeof option.conditionalQuestions === 'undefined' || option.conditionalQuestions.length == 0 || questionAnswers[question.questionId] != option.value) { - return; - } - - activeQuestions = getActiveQuestions(option.conditionalQuestions, questionAnswers, activeQuestions); - }); - }); - - return activeQuestions; -}; - -/** - * Get active questions from multiple question sets - * - * @param array questionSets All question sets - * @param object questionAnswers Current answers for questions - * @return array All active questions - */ -var getActiveQuestionsFromQuestionSets = function getActiveQuestionsFromQuestionSets(questionSets, questionAnswers) { - var questionsToCheck = []; - - questionSets.forEach(function (questionSet) { - return Array.prototype.push.apply(questionsToCheck, getActiveQuestions(questionSet.questions, questionAnswers)); - }); - - return questionsToCheck; -}; - -/** - * Get all invalid questions from question sets - * - * @param array questionSets All question sets - * @param object questionAnswers Current answers for questions - * @return object Set of questions and their invalidations - */ -var getQuestionPanelInvalidQuestions = function getQuestionPanelInvalidQuestions(questionSets, questionAnswers) { - var questionsToCheck = getActiveQuestionsFromQuestionSets(questionSets, questionAnswers).filter(function (question) { - return question.validations instanceof Array && question.validations.length > 0; - }); - - /* - * Now we run validations for the questions - * we need to check for errors. - * - * Go through every question, and its validations - * then run the question and answer through - * the validation method required. - */ - var errors = {}; - questionsToCheck.forEach(function (_ref) { - var questionId = _ref.questionId; - var validations = _ref.validations; - return [].forEach.bind(validations, function (validation) { - var valid = validateAnswer(questionAnswers[questionId], validation, questionAnswers); - if (valid) { - return; - } - - /* - * If we got here, the validation failed. Add - * an validation error and continue to the next! - */ - if (typeof errors[questionId] === 'undefined') { - errors[questionId] = []; - } - - errors[questionId].push(validation); - })(); - }); - - return errors; -}; - -/** - * Add a single validation method - * - * @param string name Name of validation method - * @param function method Validation method - */ -var addValidationMethod = function addValidationMethod(name, method) { - if (typeof name !== 'string') { - throw new Error('Winterfell: First parameter of addValidationMethod ' + 'must be of type string'); - } - - if (typeof method !== 'function') { - throw new Error('Winterfell: Second parameter of addValidationMethod ' + 'must be of type function'); - } - - extraValidators[name] = method; -}; - -/** - * Add multiple validation methods - * - * @param array methods Methods to add. name => func - */ -var addValidationMethods = function addValidationMethods(methods) { - if (typeof methods !== 'object') { - throw new Error('Winterfell: First parameter of addValidationMethods ' + 'must be of type object'); - } - - for (var methodName in methods) { - addValidationMethod[methodName] = methods[methodName]; - } -}; - -module.exports = { - validateAnswer: validateAnswer, - getActiveQuestions: getActiveQuestions, - getActiveQuestionsFromQuestionSets: getActiveQuestionsFromQuestionSets, - getQuestionPanelInvalidQuestions: getQuestionPanelInvalidQuestions, - addValidationMethod: addValidationMethod, - addValidationMethods: addValidationMethods -}; \ No newline at end of file diff --git a/dist/question.js b/dist/question.js deleted file mode 100644 index fdd86ca5..00000000 --- a/dist/question.js +++ /dev/null @@ -1,173 +0,0 @@ -'use strict'; - -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 _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 _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); -var _ = require('lodash').noConflict(); - -var InputTypes = require('./inputTypes'); - -var Question = (function (_React$Component) { - _inherits(Question, _React$Component); - - function Question() { - _classCallCheck(this, Question); - - _get(Object.getPrototypeOf(Question.prototype), 'constructor', this).apply(this, arguments); - } - - _createClass(Question, [{ - key: 'handleInputChange', - value: function handleInputChange(questionId, value) { - this.props.onAnswerChange(questionId, value, this.props.validations, this.props.validateOn); - } - }, { - key: 'handleInputBlur', - value: function handleInputBlur(questionId, value) { - this.props.onQuestionBlur(questionId, value, this.props.validations, this.props.validateOn); - } - }, { - key: 'render', - value: function render() { - var _this = this; - - var Input = InputTypes[this.props.input.type]; - if (!Input) { - throw new Error('Winterfell: Input Type "' + this.props.input.type + '" not defined as Winterfell Input Type'); - } - - /* - * Conditional Questions - */ - var conditionalItems = []; - if (typeof this.props.input.options !== 'undefined') { - this.props.input.options.filter(function (option) { - return _this.props.value instanceof Array ? _this.props.value.indexOf(option.value) > -1 : _this.props.value == option.value; - }).filter(function (option) { - return typeof option.conditionalQuestions !== 'undefined' && option.conditionalQuestions.length > 0; - }).forEach(function (option) { - return [].forEach.bind(option.conditionalQuestions, function (conditionalQuestion) { - conditionalItems.push(React.createElement(Question, { key: conditionalQuestion.questionId, - questionSetId: _this.props.questionSetId, - questionId: conditionalQuestion.questionId, - question: conditionalQuestion.question, - text: conditionalQuestion.text, - postText: conditionalQuestion.postText, - validateOn: conditionalQuestion.validateOn, - validations: conditionalQuestion.validations, - value: _this.props.questionAnswers[conditionalQuestion.questionId], - input: conditionalQuestion.input, - classes: _this.props.classes, - renderError: _this.props.renderError, - questionAnswers: _this.props.questionAnswers, - validationErrors: _this.props.validationErrors, - onAnswerChange: _this.props.onAnswerChange, - onQuestionBlur: _this.props.onQuestionBlur, - onKeyDown: _this.props.onKeyDown })); - })(); - }); - } - - var value = typeof this.props.value !== 'undefined' ? this.props.value : typeof this.props.input['default'] !== 'undefined' ? this.props.input['default'] : undefined; - - var validationErrors = typeof this.props.validationErrors[this.props.questionId] !== 'undefined' ? this.props.validationErrors[this.props.questionId].map(function (error) { - return typeof _this.props.renderError === 'function' ? _this.props.renderError(error, _this.props.questionId) : React.createElement( - 'div', - { key: _this.props.questionId + 'Error' + error.type, - className: _this.props.classes.errorMessage }, - error.message - ); - }) : []; - - var extraprops = {}; - - if (this.props.input.props) { - extraprops = this.props.input.props; - } - - return React.createElement( - 'div', - { className: this.props.classes.question }, - !!this.props.question ? React.createElement( - 'label', - { className: this.props.classes.label, - htmlFor: this.props.questionId }, - this.props.question, - typeof this.props.renderRequiredAsterisk !== 'undefined' && this.props.input.required ? this.props.renderRequiredAsterisk() : undefined - ) : undefined, - !!this.props.text ? React.createElement( - 'p', - { className: this.props.classes.questionText }, - this.props.text - ) : undefined, - validationErrors, - React.createElement(Input, _extends({ name: this.props.questionId, - id: this.props.questionId, - value: value, - text: this.props.input.text, - options: this.props.input.options, - placeholder: this.props.input.placeholder, - required: this.props.input.required, - classes: this.props.classes, - onChange: this.handleInputChange.bind(this, this.props.questionId), - onBlur: this.handleInputBlur.bind(this, this.props.questionId), - onKeyDown: this.props.onKeyDown - }, extraprops)), - !!this.props.postText ? React.createElement( - 'p', - { className: this.props.classes.questionPostText }, - this.props.postText - ) : undefined, - conditionalItems - ); - } - }, { - key: 'componentDidMount', - value: function componentDidMount() { - if (typeof this.props.input['default'] === 'undefined' || this.props.input.type === 'checkboxInput' && typeof this.props.questionAnswers[this.props.questionId] === 'undefined') { - return; - } - - this.handleInputChange.call(this, this.props.questionId, this.props.input['default']); - } - }]); - - return Question; -})(React.Component); - -; - -Question.defaultProps = { - questionSetId: undefined, - questionId: undefined, - question: '', - validateOn: 'blur', - validations: [], - text: undefined, - postText: undefined, - value: undefined, - input: { - 'default': undefined, - type: 'textInput', - limit: undefined, - placeholder: undefined - }, - classes: {}, - questionAnswers: {}, - validationErrors: {}, - onAnswerChange: function onAnswerChange() {}, - onQuestionBlur: function onQuestionBlur() {}, - onKeyDown: function onKeyDown() {}, - renderError: undefined, - renderRequiredAsterisk: undefined -}; - -module.exports = Question; \ No newline at end of file diff --git a/dist/questionPanel.js b/dist/questionPanel.js deleted file mode 100644 index e935103d..00000000 --- a/dist/questionPanel.js +++ /dev/null @@ -1,273 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); -var _ = require('lodash').noConflict(); -var KeyCodez = require('keycodez'); - -var Validation = require('./lib/validation'); -var ErrorMessages = require('./lib/errors'); - -var Button = require('./button'); -var QuestionSet = require('./questionSet'); - -var QuestionPanel = (function (_React$Component) { - _inherits(QuestionPanel, _React$Component); - - function QuestionPanel(props) { - _classCallCheck(this, QuestionPanel); - - _get(Object.getPrototypeOf(QuestionPanel.prototype), 'constructor', this).call(this, props); - - this.state = { - validationErrors: this.props.validationErrors - }; - } - - _createClass(QuestionPanel, [{ - key: 'handleAnswerValidate', - value: function handleAnswerValidate(questionId, questionAnswer, validations) { - var _this = this; - - if (typeof validations === 'undefined' || validations.length === 0) { - return; - } - - /* - * Run the question through its validations and - * show any error messages if invalid. - */ - var questionValidationErrors = []; - validations.forEach(function (validation) { - if (Validation.validateAnswer(questionAnswer, validation, _this.props.questionAnswers)) { - return; - } - - questionValidationErrors.push({ - type: validation.type, - message: ErrorMessages.getErrorMessage(validation) - }); - }); - - var validationErrors = _.chain(this.state.validationErrors).set(questionId, questionValidationErrors).value(); - - this.setState({ - validationErrors: validationErrors - }); - } - }, { - key: 'handleMainButtonClick', - value: function handleMainButtonClick() { - var _this2 = this; - - var action = this.props.action['default']; - var conditions = this.props.action.conditions || []; - - /* - * We need to get all the question sets for this panel. - * Collate a list of the question set IDs required - * and run through the schema to grab the question sets. - */ - var questionSetIds = this.props.questionSets.map(function (qS) { - return qS.questionSetId; - }); - var questionSets = _.chain(this.props.schema.questionSets).filter(function (qS) { - return questionSetIds.indexOf(qS.questionSetId) > -1; - }).value(); - - /* - * Get any incorrect fields that need erorr messages. - */ - var invalidQuestions = Validation.getQuestionPanelInvalidQuestions(questionSets, this.props.questionAnswers); - - /* - * If the panel isn't valid... - */ - if (Object.keys(invalidQuestions).length > 0) { - var validationErrors = _.mapValues(invalidQuestions, function (validations) { - return validations.map(function (validation) { - return { - type: validation.type, - message: ErrorMessages.getErrorMessage(validation) - }; - }); - }); - - this.setState({ - validationErrors: validationErrors - }); - return; - } - - /* - * Panel is valid. So what do we do next? - * Check our conditions and act upon them, or the default. - */ - conditions.forEach(function (condition) { - var answer = _this2.props.questionAnswers[condition.questionId]; - - action = answer == condition.value ? { - action: condition.action, - target: condition.target - } : action; - }); - - /* - * Decide which action to take depending on - * the action decided upon. - */ - switch (action.action) { - - case 'GOTO': - this.props.onSwitchPanel(action.target); - break; - - case 'SUBMIT': - this.props.onSubmit(action.target); - break; - } - } - }, { - key: 'handleBackButtonClick', - value: function handleBackButtonClick() { - if (this.props.panelHistory.length == 0) { - return; - } - - this.props.onPanelBack(); - } - }, { - key: 'handleAnswerChange', - value: function handleAnswerChange(questionId, questionAnswer, validations, validateOn) { - this.props.onAnswerChange(questionId, questionAnswer); - - this.setState({ - validationErrors: _.chain(this.state.validationErrors).set(questionId, []).value() - }); - - if (validateOn === 'change') { - this.handleAnswerValidate(questionId, questionAnswer, validations); - } - } - }, { - key: 'handleQuestionBlur', - value: function handleQuestionBlur(questionId, questionAnswer, validations, validateOn) { - if (validateOn === 'blur') { - this.handleAnswerValidate(questionId, questionAnswer, validations); - } - } - }, { - key: 'handleInputKeyDown', - value: function handleInputKeyDown(e) { - if (KeyCodez[e.keyCode] === 'enter') { - e.preventDefault(); - this.handleMainButtonClick.call(this); - } - } - }, { - key: 'render', - value: function render() { - var _this3 = this; - - var questionSets = this.props.questionSets.map(function (questionSetMeta) { - var questionSet = _.find(_this3.props.schema.questionSets, { - questionSetId: questionSetMeta.questionSetId - }); - - if (!questionSet) { - return undefined; - } - - return React.createElement(QuestionSet, { key: questionSet.questionSetId, - id: questionSet.questionSetId, - name: questionSet.name, - questionSetHeader: questionSet.questionSetHeader, - questionSetText: questionSet.questionSetText, - questions: questionSet.questions, - classes: _this3.props.classes, - questionAnswers: _this3.props.questionAnswers, - renderError: _this3.props.renderError, - renderRequiredAsterisk: _this3.props.renderRequiredAsterisk, - validationErrors: _this3.state.validationErrors, - onAnswerChange: _this3.handleAnswerChange.bind(_this3), - onQuestionBlur: _this3.handleQuestionBlur.bind(_this3), - onKeyDown: _this3.handleInputKeyDown.bind(_this3) }); - }); - - return React.createElement( - 'div', - { className: this.props.classes.questionPanel }, - typeof this.props.panelHeader !== 'undefined' || typeof this.props.panelText !== 'undefined' ? React.createElement( - 'div', - { className: this.props.classes.questionPanelHeaderContainer }, - typeof this.props.panelHeader !== 'undefined' ? React.createElement( - 'h3', - { className: this.props.classes.questionPanelHeaderText }, - this.props.panelHeader - ) : undefined, - typeof this.props.panelText !== 'undefined' ? React.createElement( - 'p', - { className: this.props.classes.questionPanelText }, - this.props.panelText - ) : undefined - ) : undefined, - React.createElement( - 'div', - { className: this.props.classes.questionSets }, - questionSets - ), - React.createElement( - 'div', - { className: this.props.classes.buttonBar }, - this.props.panelHistory.length > 1 && !this.props.backButton.disabled ? React.createElement(Button, { text: this.props.backButton.text || 'Back', - onClick: this.handleBackButtonClick.bind(this), - className: this.props.classes.backButton }) : undefined, - !this.props.button.disabled ? React.createElement(Button, { text: this.props.button.text, - onClick: this.handleMainButtonClick.bind(this), - className: this.props.classes.controlButton }) : undefined - ) - ); - } - }]); - - return QuestionPanel; -})(React.Component); - -; - -QuestionPanel.defaultProps = { - validationErrors: {}, - schema: {}, - classes: {}, - panelId: undefined, - panelIndex: undefined, - panelHeader: undefined, - panelText: undefined, - action: { - 'default': {}, - conditions: [] - }, - button: { - text: 'Submit' - }, - backButton: { - text: 'Back' - }, - questionSets: [], - questionAnswers: {}, - renderError: undefined, - renderRequiredAsterisk: undefined, - onAnswerChange: function onAnswerChange() {}, - onSwitchPanel: function onSwitchPanel() {}, - onPanelBack: function onPanelBack() {}, - panelHistory: [] -}; - -module.exports = QuestionPanel; \ No newline at end of file diff --git a/dist/questionSet.js b/dist/questionSet.js deleted file mode 100644 index 239fd6e7..00000000 --- a/dist/questionSet.js +++ /dev/null @@ -1,94 +0,0 @@ -'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; }; })(); - -var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - -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; } - -var React = require('react'); -var _ = require('lodash').noConflict(); - -var Question = require('./question'); - -var QuestionSet = (function (_React$Component) { - _inherits(QuestionSet, _React$Component); - - function QuestionSet() { - _classCallCheck(this, QuestionSet); - - _get(Object.getPrototypeOf(QuestionSet.prototype), 'constructor', this).apply(this, arguments); - } - - _createClass(QuestionSet, [{ - key: 'render', - value: function render() { - var _this = this; - - var questions = this.props.questions.map(function (question) { - return React.createElement(Question, { key: question.questionId, - questionSetId: _this.props.id, - questionId: question.questionId, - question: question.question, - validateOn: question.validateOn, - validations: question.validations, - text: question.text, - postText: question.postText, - value: _this.props.questionAnswers[question.questionId], - input: question.input, - classes: _this.props.classes, - renderError: _this.props.renderError, - renderRequiredAsterisk: _this.props.renderRequiredAsterisk, - questionAnswers: _this.props.questionAnswers, - validationErrors: _this.props.validationErrors, - onAnswerChange: _this.props.onAnswerChange, - onQuestionBlur: _this.props.onQuestionBlur, - onKeyDown: _this.props.onKeyDown }); - }); - - return React.createElement( - 'div', - { className: this.props.classes.questionSet }, - typeof this.props.questionSetHeader !== 'undefined' || typeof this.props.questionSetText !== 'undefined' ? React.createElement( - 'div', - { className: this.props.classes.questionSetHeaderContainer }, - typeof this.props.questionSetHeader !== 'undefined' ? React.createElement( - 'h4', - { className: this.props.classes.questionSetHeader }, - this.props.questionSetHeader - ) : undefined, - typeof this.props.questionSetText !== 'undefined' ? React.createElement( - 'p', - { className: this.props.classes.questionSetText }, - this.props.questionSetText - ) : undefined - ) : undefined, - questions - ); - } - }]); - - return QuestionSet; -})(React.Component); - -; - -QuestionSet.defaultProps = { - id: undefined, - name: '', - questionSetHeader: undefined, - questionSetText: undefined, - questions: [], - questionAnswers: {}, - classes: {}, - validationErrors: {}, - renderError: undefined, - renderRequiredAsterisk: undefined, - onAnswerChange: function onAnswerChange() {}, - onQuestionBlur: function onQuestionBlur() {}, - onKeyDown: function onKeyDown() {} -}; - -module.exports = QuestionSet; \ No newline at end of file diff --git a/dist/winterfell.min.js b/dist/winterfell.min.js deleted file mode 100644 index c3d438b8..00000000 --- a/dist/winterfell.min.js +++ /dev/null @@ -1,25 +0,0 @@ -var Winterfell=function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var i=function(){function t(t,e){for(var n=0;ne.index});var o="undefined"!=typeof this.props.panelId?this.props.panelId:n.formPanels.length>0?n.formPanels[0].panelId:void 0,i="undefined"!=typeof n&&"undefined"!=typeof n.formPanels&&"undefined"!=typeof o?s.find(n.formPanels,function(t){return t.panelId==o}):void 0;if(!i)throw new Error("Winterfell: Could not find initial panel and failed to render.");this.state={schema:n,currentPanel:i,action:this.props.action,questionAnswers:this.props.questionAnswers}}return o(e,t),i(e,[{key:"componentWillReceiveProps",value:function(t){this.setState({action:t.action,schema:t.schema,questionAnswers:t.questionAnswers})}},{key:"handleAnswerChange",value:function(t,e){var n=s.chain(this.state.questionAnswers).set(t,e).value();this.setState({questionAnswers:n},this.props.onUpdate.bind(null,n))}},{key:"handleSwitchPanel",value:function(t,e){var n=s.find(this.props.schema.formPanels,{panelId:t});if(!n)throw new Error('Winterfell: Tried to switch to panel "'+t+'", which does not exist.');e||this.panelHistory.push(n.panelId),this.setState({currentPanel:n},this.props.onSwitchPanel.bind(null,n))}},{key:"handleBackButtonClick",value:function(){this.panelHistory.pop(),this.handleSwitchPanel.call(this,this.panelHistory[this.panelHistory.length-1],!0)}},{key:"handleSubmit",value:function(t){var e=this;return this.props.disableSubmit?void this.props.onSubmit(this.state.questionAnswers,t):void this.setState({action:t},function(){a.findDOMNode(e.refs[e.props.ref]).submit()})}},{key:"render",value:function(){var t=this,e=s.find(this.state.schema.questionPanels,function(e){return e.panelId==t.state.currentPanel.panelId});return a.createElement("form",{method:this.props.method,encType:this.props.encType,action:this.state.action,ref:this.props.ref,className:this.state.schema.classes.form},a.createElement("div",{className:this.state.schema.classes.questionPanels},a.createElement(l,{schema:this.state.schema,classes:this.state.schema.classes,panelId:e.panelId,panelIndex:e.panelIndex,panelHeader:e.panelHeader,panelText:e.panelText,action:e.action,button:e.button,backButton:e.backButton,questionSets:e.questionSets,questionAnswers:this.state.questionAnswers,panelHistory:this.panelHistory,renderError:this.props.renderError,renderRequiredAsterisk:this.props.renderRequiredAsterisk,onAnswerChange:this.handleAnswerChange.bind(this),onPanelBack:this.handleBackButtonClick.bind(this),onSwitchPanel:this.handleSwitchPanel.bind(this),onSubmit:this.handleSubmit.bind(this)})))}},{key:"componentDidMount",value:function(){this.panelHistory.push(this.state.currentPanel.panelId),this.props.onRender()}}]),e}(a.Component);c.defaultProps={schema:{formPanels:[],questionPanels:[],questionSets:[],classes:{}},questionAnswers:{},ref:"form",encType:"application/x-www-form-urlencoded",method:"POST",action:"",panelId:void 0,disableSubmit:!1,renderError:void 0,renderRequiredAsterisk:void 0,onSubmit:function(){},onUpdate:function(){},onSwitchPanel:function(){},onRender:function(){}},c.inputTypes=n(3),c.errorMessages=n(4),c.validation=n(5),c.addInputType=c.inputTypes.addInputType,c.addInputTypes=c.inputTypes.addInputTypes,c.addErrorMessage=c.errorMessages.addErrorMessage,c.addErrorMessages=c.errorMessages.addErrorMessages,c.addValidationMethod=c.validation.addValidationMethod,c.addValidationMethods=c.validation.addValidationMethods,t.exports=c},function(t,e){t.exports=React},function(t,e,n){var r;(function(t,o){(function(){function i(t,e){if(t!==e){var n=null===t,r=t===A,o=t===t,i=null===e,u=e===A,a=e===e;if(t>e&&!i||!o||n&&!u&&a||r&&a)return 1;if(e>t&&!n||!a||i&&!r&&o||u&&o)return-1}return 0}function u(t,e,n){for(var r=t.length,o=n?r:-1;n?o--:++o-1;);return n}function f(t,e){for(var n=t.length;n--&&e.indexOf(t.charAt(n))>-1;);return n}function p(t,e){return i(t.criteria,e.criteria)||t.index-e.index}function h(t,e,n){for(var r=-1,o=t.criteria,u=e.criteria,a=o.length,s=n.length;++r=s)return l;var c=n[r];return l*("asc"===c||c===!0?1:-1)}}return t.index-e.index}function d(t){return Qt[t]}function v(t){return zt[t]}function g(t,e,n){return e?t=Jt[t]:n&&(t=Gt[t]),"\\"+t}function y(t){return"\\"+Gt[t]}function _(t,e,n){for(var r=t.length,o=e+(n?0:-1);n?o--:++o=t&&t>=9&&13>=t||32==t||160==t||5760==t||6158==t||t>=8192&&(8202>=t||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function w(t,e){for(var n=-1,r=t.length,o=-1,i=[];++ne,o=n?t.length:0,i=Qn(0,o,this.__views__),u=i.start,a=i.end,s=a-u,l=r?a:u-1,c=this.__iteratees__,f=c.length,p=0,h=Ou(s,this.__takeCount__);if(!n||W>o||o==s&&h==s)return nn(r&&n?t.reverse():t,this.__actions__);var d=[];t:for(;s--&&h>p;){l+=e;for(var v=-1,g=t[l];++v=W?vn(e):null,l=e.length;s&&(i=Gt,u=!1,e=s);t:for(;++on&&(n=-n>o?0:o+n),r=r===A||r>o?o:+r||0,0>r&&(r+=o),o=n>r?0:r>>>0,n>>>=0;o>n;)t[n++]=e;return t}function Ae(t,e){var n=[];return Bu(t,function(t,r,o){e(t,r,o)&&n.push(t)}),n}function je(t,e,n,r){var o;return n(t,function(t,n,i){return e(t,n,i)?(o=r?n:t,!1):void 0}),o}function Ce(t,e,n,r){r||(r=[]);for(var o=-1,i=t.length;++or;)t=t[e[r++]];return r&&r==o?t:A}}function Te(t,e,n,r,o,i){return t===e?!0:null==t||null==e||!To(t)&&!m(e)?t!==t&&e!==e:Be(t,e,Te,n,r,o,i)}function Be(t,e,n,r,o,i,u){var a=Ca(t),s=Ca(e),l=V,c=V;a||(l=ru.call(t),l==z?l=et:l!=et&&(a=Ho(t))),s||(c=ru.call(e),c==z?c=et:c!=et&&(s=Ho(e)));var f=l==et,p=c==et,h=l==c;if(h&&!a&&!f)return $n(t,e,l);if(!o){var d=f&&eu.call(t,"__wrapped__"),v=p&&eu.call(e,"__wrapped__");if(d||v)return n(d?t.value():t,v?e.value():e,r,o,i,u)}if(!h)return!1;i||(i=[]),u||(u=[]);for(var g=i.length;g--;)if(i[g]==t)return u[g]==e;i.push(t),u.push(e);var y=(a?Rn:Mn)(t,e,n,r,o,i,u);return i.pop(),u.pop(),y}function Ne(t,e,n){var r=e.length,o=r,i=!n;if(null==t)return!o;for(t=fr(t);r--;){var u=e[r];if(i&&u[2]?u[1]!==t[u[0]]:!(u[0]in t))return!1}for(;++re&&(e=-e>o?0:o+e),n=n===A||n>o?o:+n||0,0>n&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Li(o);++r=W,s=u?vn():null,l=[];s?(r=Gt,i=!1):(u=!1,s=e?[]:l);t:for(;++n=o){for(;o>r;){var i=r+o>>>1,u=t[i];(n?e>=u:e>u)&&null!==u?r=i+1:o=i}return o}return on(t,e,ji,n)}function on(t,e,n,r){e=n(e);for(var o=0,i=t?t.length:0,u=e!==e,a=null===e,s=e===A;i>o;){var l=_u((o+i)/2),c=n(t[l]),f=c!==A,p=c===c;if(u)var h=p||r;else h=a?p&&f&&(r||null!=c):s?p&&(r||f):null==c?!1:r?e>=c:e>c;h?o=l+1:i=l}return Ou(i,qu)}function un(t,e,n){if("function"!=typeof t)return ji;if(e===A)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 3:return function(n,r,o){return t.call(e,n,r,o)};case 4:return function(n,r,o,i){return t.call(e,n,r,o,i)};case 5:return function(n,r,o,i,u){return t.call(e,n,r,o,i,u)}}return function(){return t.apply(e,arguments)}}function an(t){var e=new uu(t.byteLength),n=new du(e);return n.set(new du(t)),e}function sn(t,e,n){for(var r=n.length,o=-1,i=xu(t.length-r,0),u=-1,a=e.length,s=Li(a+i);++u2?n[o-2]:A,u=o>2?n[2]:A,a=o>1?n[o-1]:A;for("function"==typeof i?(i=un(i,a,5),o-=2):(i="function"==typeof a?a:A,o-=i?1:0),u&&Xn(n[0],n[1],u)&&(i=3>o?A:i,o=1);++r-1?n[i]:A}return je(n,r,t)}}function xn(t){return function(e,n,r){return e&&e.length?(n=Ln(n,r,3),u(e,n,t)):-1}}function On(t){return function(e,n,r){return n=Ln(n,r,3),je(e,n,t,!0)}}function En(t){return function(){for(var e,n=arguments.length,o=t?n:-1,i=0,u=Li(n);t?o--:++o=W)return e.plant(r).value();for(var o=0,i=n?u[o].apply(this,t):r;++o_){var E=a?te(a):A,k=xu(l-_,0),P=d?O:A,j=d?A:O,F=d?b:A,I=d?A:b;e|=d?D:T,e&=~(d?T:D),v||(e&=~(C|q));var S=[t,e,n,F,P,I,j,E,s,k],B=In.apply(A,S);return er(t)&&Uu(B,S),B.placeholder=x,B}}var N=p?n:this,R=h?N[t]:t;return a&&(b=sr(b,a)),f&&s=e||!bu(e))return"";var o=e-r;return n=null==n?" ":n+"",yi(n,gu(o/n.length)).slice(0,o)}function Dn(t,e,n,r){function o(){for(var e=-1,a=arguments.length,s=-1,l=r.length,c=Li(l+a);++ss))return!1;for(;++a-1&&t%1==0&&e>t}function Xn(t,e,n){if(!To(n))return!1;var r=typeof e;if("number"==r?Gn(n)&&Yn(e,n.length):"string"==r&&e in n){var o=n[e];return t===t?t===o:o!==o}return!1}function tr(t,e){var n=typeof t;if("string"==n&&At.test(t)||"number"==n)return!0;if(Ca(t))return!1;var r=!Pt.test(t);return r||null!=e&&t in fr(e)}function er(t){var n=Wn(t);if(!(n in o.prototype))return!1;var r=e[n];if(t===r)return!0;var i=Lu(r);return!!i&&t===i[0]}function nr(t){return"number"==typeof t&&t>-1&&t%1==0&&Iu>=t}function rr(t){return t===t&&!To(t)}function or(t,e){var n=t[1],r=e[1],o=n|r,i=B>o,u=r==B&&n==I||r==B&&n==N&&t[7].length<=e[8]||r==(B|N)&&n==I;if(!i&&!u)return t;r&C&&(t[2]=e[2],o|=n&C?0:F);var a=e[3];if(a){var s=t[3];t[3]=s?sn(s,a,e[4]):te(a),t[4]=s?w(t[3],Q):te(e[4])}return a=e[5],a&&(s=t[5],t[5]=s?ln(s,a,e[6]):te(a),t[6]=s?w(t[5],Q):te(e[6])),a=e[7],a&&(t[7]=te(a)),r&B&&(t[8]=null==t[8]?e[8]:Ou(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=o,t}function ir(t,e){return t===A?e:qa(t,e,ir)}function ur(t,e){t=fr(t);for(var n=-1,r=e.length,o={};++nr;)u[++i]=Ve(t,r,r+=e);return u}function vr(t){for(var e=-1,n=t?t.length:0,r=-1,o=[];++ee?0:e)):[]}function yr(t,e,n){var r=t?t.length:0;return r?((n?Xn(t,e,n):null==e)&&(e=1),e=r-(+e||0),Ve(t,0,0>e?0:e)):[]}function _r(t,e,n){return t&&t.length?en(t,Ln(e,n,3),!0,!0):[]}function mr(t,e,n){return t&&t.length?en(t,Ln(e,n,3),!0):[]}function br(t,e,n,r){var o=t?t.length:0;return o?(n&&"number"!=typeof n&&Xn(t,e,n)&&(n=0,r=o),Pe(t,e,n,r)):[]}function wr(t){return t?t[0]:A}function xr(t,e,n){var r=t?t.length:0;return n&&Xn(t,e,n)&&(e=!1),r?Ce(t,e):[]}function Or(t){var e=t?t.length:0;return e?Ce(t,!0):[]}function Er(t,e,n){var r=t?t.length:0;if(!r)return-1;if("number"==typeof n)n=0>n?xu(r+n,0):n;else if(n){var o=rn(t,e);return r>o&&(e===e?e===t[o]:t[o]!==t[o])?o:-1}return a(t,e,n||0)}function kr(t){return yr(t,1)}function Pr(t){var e=t?t.length:0;return e?t[e-1]:A}function Ar(t,e,n){var r=t?t.length:0;if(!r)return-1;var o=r;if("number"==typeof n)o=(0>n?xu(r+n,0):Ou(n||0,r-1))+1;else if(n){o=rn(t,e,!0)-1;var i=t[o];return(e===e?e===i:i!==i)?o:-1}if(e!==e)return _(t,o,!0);for(;o--;)if(t[o]===e)return o;return-1}function jr(){var t=arguments,e=t[0];if(!e||!e.length)return e;for(var n=0,r=Un(),o=t.length;++n-1;)hu.call(e,i,1);return e}function Cr(t,e,n){var r=[];if(!t||!t.length)return r;var o=-1,i=[],u=t.length;for(e=Ln(e,n,3);++oe?0:e)):[]}function Sr(t,e,n){var r=t?t.length:0;return r?((n?Xn(t,e,n):null==e)&&(e=1),e=r-(+e||0),Ve(t,0>e?0:e)):[]}function Dr(t,e,n){return t&&t.length?en(t,Ln(e,n,3),!1,!0):[]}function Tr(t,e,n){return t&&t.length?en(t,Ln(e,n,3)):[]}function Br(t,e,n,r){var o=t?t.length:0;if(!o)return[];null!=e&&"boolean"!=typeof e&&(r=n,n=Xn(t,e,r)?A:e,e=!1);var i=Ln();return(null!=n||i!==be)&&(n=i(n,r,3)),e&&Un()==a?x(t,n):Xe(t,n)}function Nr(t){if(!t||!t.length)return[];var e=-1,n=0;t=ae(t,function(t){return Gn(t)?(n=xu(t.length,n),!0):void 0});for(var r=Li(n);++en?xu(o+n,0):n||0,"string"==typeof t||!Ca(t)&&Uo(t)?o>=n&&t.indexOf(e,n)>-1:!!o&&Un(t,e,n)>-1}function to(t,e,n){var r=Ca(t)?se:Re;return e=Ln(e,n,3),r(t,e)}function eo(t,e){return to(t,Di(e))}function no(t,e,n){var r=Ca(t)?ae:Ae;return e=Ln(e,n,3),r(t,function(t,n,r){return!e(t,n,r)})}function ro(t,e,n){if(n?Xn(t,e,n):null==e){t=cr(t);var r=t.length;return r>0?t[Qe(0,r-1)]:A}var o=-1,i=Vo(t),r=i.length,u=r-1;for(e=Ou(0>e?0:+e||0,r);++o0&&(n=e.apply(this,arguments)),1>=t&&(e=A),n}}function ho(t,e,n){function r(){h&&au(h),l&&au(l),v=0,l=h=d=A}function o(e,n){n&&au(n),l=h=d=A,e&&(v=va(),c=t.apply(p,s),h||l||(s=p=A))}function i(){var t=e-(va()-f);0>=t||t>e?o(d,l):h=pu(i,t)}function u(){o(y,h)}function a(){if(s=arguments,f=va(),p=this,d=y&&(h||!_),g===!1)var n=_&&!h;else{l||_||(v=f);var r=g-(f-v),o=0>=r||r>g;o?(l&&(l=au(l)),v=f,c=t.apply(p,s)):l||(l=pu(u,r))}return o&&h?h=au(h):h||e===g||(h=pu(i,e)),n&&(o=!0,c=t.apply(p,s)),!o||h||l||(s=p=A),c}var s,l,c,f,p,h,d,v=0,g=!1,y=!0;if("function"!=typeof t)throw new Ji(K);if(e=0>e?0:+e||0,n===!0){var _=!0;y=!1}else To(n)&&(_=!!n.leading,g="maxWait"in n&&xu(+n.maxWait||0,e),y="trailing"in n?!!n.trailing:y);return a.cancel=r, -a}function vo(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new Ji(K);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var u=t.apply(this,r);return n.cache=i.set(o,u),u};return n.cache=new vo.Cache,n}function go(t){if("function"!=typeof t)throw new Ji(K);return function(){return!t.apply(this,arguments)}}function yo(t){return po(2,t)}function _o(t,e){if("function"!=typeof t)throw new Ji(K);return e=xu(e===A?t.length-1:+e||0,0),function(){for(var n=arguments,r=-1,o=xu(n.length-e,0),i=Li(o);++re}function ko(t,e){return t>=e}function Po(t){return m(t)&&Gn(t)&&eu.call(t,"callee")&&!cu.call(t,"callee")}function Ao(t){return t===!0||t===!1||m(t)&&ru.call(t)==Z}function jo(t){return m(t)&&ru.call(t)==J}function Co(t){return!!t&&1===t.nodeType&&m(t)&&!Lo(t)}function qo(t){return null==t?!0:Gn(t)&&(Ca(t)||Uo(t)||Po(t)||m(t)&&Do(t.splice))?!t.length:!Ma(t).length}function Fo(t,e,n,r){n="function"==typeof n?un(n,r,3):A;var o=n?n(t,e):A;return o===A?Te(t,e,n):!!o}function Io(t){return m(t)&&"string"==typeof t.message&&ru.call(t)==G}function So(t){return"number"==typeof t&&bu(t)}function Do(t){return To(t)&&ru.call(t)==Y}function To(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Bo(t,e,n,r){return n="function"==typeof n?un(n,r,3):A,Ne(t,Hn(e),n)}function No(t){return Mo(t)&&t!=+t}function Ro(t){return null==t?!1:Do(t)?iu.test(tu.call(t)):m(t)&&Bt.test(t)}function $o(t){return null===t}function Mo(t){return"number"==typeof t||m(t)&&ru.call(t)==tt}function Lo(t){var e;if(!m(t)||ru.call(t)!=et||Po(t)||!eu.call(t,"constructor")&&(e=t.constructor,"function"==typeof e&&!(e instanceof e)))return!1;var n;return qe(t,function(t,e){n=e}),n===A||eu.call(t,n)}function Wo(t){return To(t)&&ru.call(t)==nt}function Uo(t){return"string"==typeof t||m(t)&&ru.call(t)==ot}function Ho(t){return m(t)&&nr(t.length)&&!!Ht[ru.call(t)]}function Ko(t){return t===A}function Qo(t,e){return e>t}function zo(t,e){return e>=t}function Vo(t){var e=t?Wu(t):0;return nr(e)?e?te(t):[]:ui(t)}function Zo(t){return me(t,ei(t))}function Jo(t,e,n){var r=Tu(t);return n&&Xn(t,e,n)&&(e=A),e?ye(r,e):r}function Go(t){return Se(t,ei(t))}function Yo(t,e,n){var r=null==t?A:De(t,pr(e),e+"");return r===A?n:r}function Xo(t,e){if(null==t)return!1;var n=eu.call(t,e);if(!n&&!tr(e)){if(e=pr(e),t=1==e.length?t:De(t,Ve(e,0,-1)),null==t)return!1;e=Pr(e),n=eu.call(t,e)}return n||nr(t.length)&&Yn(e,t.length)&&(Ca(t)||Po(t))}function ti(t,e,n){n&&Xn(t,e,n)&&(e=A);for(var r=-1,o=Ma(t),i=o.length,u={};++r0;++r=Ou(e,n)&&tn?0:+n||0,r),n-=e.length,n>=0&&t.indexOf(e,n)==n}function hi(t){return t=l(t),t&&xt.test(t)?t.replace(bt,v):t}function di(t){return t=l(t),t&&qt.test(t)?t.replace(Ct,g):t||"(?:)"}function vi(t,e,n){t=l(t),e=+e;var r=t.length;if(r>=e||!bu(e))return t;var o=(e-r)/2,i=_u(o),u=gu(o);return n=Sn("",u,n),n.slice(0,i)+t+n}function gi(t,e,n){return(n?Xn(t,e,n):null==e)?e=0:e&&(e=+e),t=bi(t),ku(t,e||(Tt.test(t)?16:10))}function yi(t,e){var n="";if(t=l(t),e=+e,1>e||!t||!bu(e))return n;do e%2&&(n+=t),e=_u(e/2),t+=t;while(e);return n}function _i(t,e,n){return t=l(t),n=null==n?0:Ou(0>n?0:+n||0,t.length),t.lastIndexOf(e,n)==n}function mi(t,n,r){var o=e.templateSettings;r&&Xn(t,n,r)&&(n=r=A),t=l(t),n=ge(ye({},r||n),o,ve);var i,u,a=ge(ye({},n.imports),o.imports,ve),s=Ma(a),c=tn(a,s),f=0,p=n.interpolate||$t,h="__p += '",d=Vi((n.escape||$t).source+"|"+p.source+"|"+(p===kt?St:$t).source+"|"+(n.evaluate||$t).source+"|$","g"),v="//# sourceURL="+("sourceURL"in n?n.sourceURL:"lodash.templateSources["+ ++Ut+"]")+"\n";t.replace(d,function(e,n,r,o,a,s){return r||(r=o),h+=t.slice(f,s).replace(Mt,y),n&&(i=!0,h+="' +\n__e("+n+") +\n'"),a&&(u=!0,h+="';\n"+a+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),f=s+e.length,e}),h+="';\n";var g=n.variable;g||(h="with (obj) {\n"+h+"\n}\n"),h=(u?h.replace(gt,""):h).replace(yt,"$1").replace(_t,"$1;"),h="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(u?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var _=Ga(function(){return Hi(s,v+"return "+h).apply(A,c)});if(_.source=h,Io(_))throw _;return _}function bi(t,e,n){var r=t;return(t=l(t))?(n?Xn(r,e,n):null==e)?t.slice(O(t),E(t)+1):(e+="",t.slice(c(t,e),f(t,e)+1)):t}function wi(t,e,n){var r=t;return t=l(t),t?(n?Xn(r,e,n):null==e)?t.slice(O(t)):t.slice(c(t,e+"")):t}function xi(t,e,n){var r=t;return t=l(t),t?(n?Xn(r,e,n):null==e)?t.slice(0,E(t)+1):t.slice(0,f(t,e+"")+1):t}function Oi(t,e,n){n&&Xn(t,e,n)&&(e=A);var r=R,o=$;if(null!=e)if(To(e)){var i="separator"in e?e.separator:i;r="length"in e?+e.length||0:r,o="omission"in e?l(e.omission):o}else r=+e||0;if(t=l(t),r>=t.length)return t;var u=r-o.length;if(1>u)return o;var a=t.slice(0,u);if(null==i)return a+o;if(Wo(i)){if(t.slice(u).search(i)){var s,c,f=t.slice(0,u);for(i.global||(i=Vi(i.source,(Dt.exec(i)||"")+"g")),i.lastIndex=0;s=i.exec(f);)c=s.index;a=a.slice(0,null==c?u:c)}}else if(t.indexOf(i,u)!=u){var p=a.lastIndexOf(i);p>-1&&(a=a.slice(0,p))}return a+o}function Ei(t){return t=l(t),t&&wt.test(t)?t.replace(mt,k):t}function ki(t,e,n){return n&&Xn(t,e,n)&&(e=A),t=l(t),t.match(e||Lt)||[]}function Pi(t,e,n){return n&&Xn(t,e,n)&&(e=A),m(t)?Ci(t):be(t,e)}function Ai(t){return function(){return t}}function ji(t){return t}function Ci(t){return $e(we(t,!0))}function qi(t,e){return Me(t,we(e,!0))}function Fi(t,e,n){if(null==n){var r=To(e),o=r?Ma(e):A,i=o&&o.length?Se(e,o):A;(i?i.length:r)||(i=!1,n=e,e=t,t=this)}i||(i=Se(e,Ma(e)));var u=!0,a=-1,s=Do(t),l=i.length;n===!1?u=!1:To(n)&&"chain"in n&&(u=n.chain);for(;++at||!bu(t))return[];var r=-1,o=Li(Ou(t,Cu));for(e=un(e,n,1);++rr?o[r]=e(r):e(r);return o}function Ri(t){var e=++nu;return l(t)+e}function $i(t,e){return(+t||0)+(+e||0)}function Mi(t,e,n){return n&&Xn(t,e,n)&&(e=A),e=Ln(e,n,3),1==e.length?he(Ca(t)?t:cr(t),e):Ye(t,e)}t=t?oe.defaults(re.Object(),t,oe.pick(re,Wt)):re;var Li=t.Array,Wi=t.Date,Ui=t.Error,Hi=t.Function,Ki=t.Math,Qi=t.Number,zi=t.Object,Vi=t.RegExp,Zi=t.String,Ji=t.TypeError,Gi=Li.prototype,Yi=zi.prototype,Xi=Zi.prototype,tu=Hi.prototype.toString,eu=Yi.hasOwnProperty,nu=0,ru=Yi.toString,ou=re._,iu=Vi("^"+tu.call(eu).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),uu=t.ArrayBuffer,au=t.clearTimeout,su=t.parseFloat,lu=Ki.pow,cu=Yi.propertyIsEnumerable,fu=Kn(t,"Set"),pu=t.setTimeout,hu=Gi.splice,du=t.Uint8Array,vu=Kn(t,"WeakMap"),gu=Ki.ceil,yu=Kn(zi,"create"),_u=Ki.floor,mu=Kn(Li,"isArray"),bu=t.isFinite,wu=Kn(zi,"keys"),xu=Ki.max,Ou=Ki.min,Eu=Kn(Wi,"now"),ku=t.parseInt,Pu=Ki.random,Au=Qi.NEGATIVE_INFINITY,ju=Qi.POSITIVE_INFINITY,Cu=4294967295,qu=Cu-1,Fu=Cu>>>1,Iu=9007199254740991,Su=vu&&new vu,Du={};e.support={};e.templateSettings={escape:Ot,evaluate:Et,interpolate:kt,variable:"",imports:{_:e}};var Tu=function(){function t(){}return function(e){if(To(e)){t.prototype=e;var n=new t;t.prototype=A}return n||{}}}(),Bu=pn(Fe),Nu=pn(Ie,!0),Ru=hn(),$u=hn(!0),Mu=Su?function(t,e){return Su.set(t,e),t}:ji,Lu=Su?function(t){return Su.get(t)}:Si,Wu=Ue("length"),Uu=function(){var t=0,e=0;return function(n,r){var o=va(),i=L-(o-e);if(e=o,i>0){if(++t>=M)return n}else t=0;return Mu(n,r)}}(),Hu=_o(function(t,e){return m(t)&&Gn(t)?Oe(t,Ce(e,!1,!0)):[]}),Ku=xn(),Qu=xn(!0),zu=_o(function(t){for(var e=t.length,n=e,r=Li(f),o=Un(),i=o==a,u=[];n--;){var s=t[n]=Gn(s=t[n])?s:[];r[n]=i&&s.length>=120?vn(n&&s):null}var l=t[0],c=-1,f=l?l.length:0,p=r[0];t:for(;++c2?t[e-2]:A,r=e>1?t[e-1]:A;return e>2&&"function"==typeof n?e-=2:(n=e>1&&"function"==typeof r?(--e,r):A,r=A),t.length=e,Rr(t,n,r)}),ea=_o(function(t){return t=Ce(t),this.thru(function(e){return Xt(Ca(e)?e:[fr(e)],t)})}),na=_o(function(t,e){return _e(t,Ce(e))}),ra=cn(function(t,e,n){eu.call(t,n)?++t[n]:t[n]=1}),oa=wn(Bu),ia=wn(Nu,!0),ua=kn(ee,Bu),aa=kn(ne,Nu),sa=cn(function(t,e,n){eu.call(t,n)?t[n].push(e):t[n]=[e]}),la=cn(function(t,e,n){t[n]=e}),ca=_o(function(t,e,n){var r=-1,o="function"==typeof e,i=tr(e),u=Gn(t)?Li(t.length):[];return Bu(t,function(t){var a=o?e:i&&null!=t?t[e]:A;u[++r]=a?a.apply(t,n):Jn(t,e,n)}),u}),fa=cn(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]}),pa=Fn(ce,Bu),ha=Fn(fe,Nu),da=_o(function(t,e){if(null==t)return[];var n=e[2];return n&&Xn(e[0],e[1],n)&&(e.length=1),Ge(t,Ce(e),[])}),va=Eu||function(){return(new Wi).getTime()},ga=_o(function(t,e,n){var r=C;if(n.length){var o=w(n,ga.placeholder);r|=D}return Nn(t,r,e,n,o)}),ya=_o(function(t,e){e=e.length?Ce(e):Go(t);for(var n=-1,r=e.length;++n0||0>e)?new o(n):(0>t?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==A&&(e=+e||0,n=0>e?n.dropRight(-e):n.take(e-t)),n)},o.prototype.takeRightWhile=function(t,e){return this.reverse().takeWhile(t,e).reverse()},o.prototype.toArray=function(){return this.take(ju)},Fe(o.prototype,function(t,n){var i=/^(?:filter|map|reject)|While$/.test(n),u=/^(?:first|last)$/.test(n),a=e[u?"take"+("last"==n?"Right":""):n];a&&(e.prototype[n]=function(){var e=u?[1]:arguments,n=this.__chain__,s=this.__wrapped__,l=!!this.__actions__.length,c=s instanceof o,f=e[0],p=c||Ca(s);p&&i&&"function"==typeof f&&1!=f.length&&(c=p=!1);var h=function(t){return u&&n?a(t,1)[0]:a.apply(A,le([t],e))},d={func:Ur,args:[h],thisArg:A},v=c&&!l;if(u&&!n)return v?(s=s.clone(),s.__actions__.push(d),t.call(s)):a.call(A,this.value())[0];if(!u&&p){s=v?s:new o(this);var g=t.apply(s,e);return g.__actions__.push(d),new r(g,n)}return this.thru(h)})}),ee(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(t){var n=(/^(?:replace|split)$/.test(t)?Xi:Gi)[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",o=/^(?:join|pop|replace|shift)$/.test(t);e.prototype[t]=function(){var t=arguments;return o&&!this.__chain__?n.apply(this.value(),t):this[r](function(e){return n.apply(e,t)})}}),Fe(o.prototype,function(t,n){var r=e[n];if(r){var o=r.name,i=Du[o]||(Du[o]=[]);i.push({name:n,func:r})}}),Du[In(A,q).name]=[{name:"wrapper",func:A}],o.prototype.clone=b,o.prototype.reverse=X,o.prototype.value=rt,e.prototype.chain=Hr,e.prototype.commit=Kr,e.prototype.concat=ea,e.prototype.plant=Qr,e.prototype.reverse=zr,e.prototype.toString=Vr,e.prototype.run=e.prototype.toJSON=e.prototype.valueOf=e.prototype.value=Zr,e.prototype.collect=e.prototype.map,e.prototype.head=e.prototype.first,e.prototype.select=e.prototype.filter,e.prototype.tail=e.prototype.rest,e}var A,j="3.10.1",C=1,q=2,F=4,I=8,S=16,D=32,T=64,B=128,N=256,R=30,$="...",M=150,L=16,W=200,U=1,H=2,K="Expected a function",Q="__lodash_placeholder__",z="[object Arguments]",V="[object Array]",Z="[object Boolean]",J="[object Date]",G="[object Error]",Y="[object Function]",X="[object Map]",tt="[object Number]",et="[object Object]",nt="[object RegExp]",rt="[object Set]",ot="[object String]",it="[object WeakMap]",ut="[object ArrayBuffer]",at="[object Float32Array]",st="[object Float64Array]",lt="[object Int8Array]",ct="[object Int16Array]",ft="[object Int32Array]",pt="[object Uint8Array]",ht="[object Uint8ClampedArray]",dt="[object Uint16Array]",vt="[object Uint32Array]",gt=/\b__p \+= '';/g,yt=/\b(__p \+=) '' \+/g,_t=/(__e\(.*?\)|\b__t\)) \+\n'';/g,mt=/&(?:amp|lt|gt|quot|#39|#96);/g,bt=/[&<>"'`]/g,wt=RegExp(mt.source),xt=RegExp(bt.source),Ot=/<%-([\s\S]+?)%>/g,Et=/<%([\s\S]+?)%>/g,kt=/<%=([\s\S]+?)%>/g,Pt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,At=/^\w*$/,jt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,Ct=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,qt=RegExp(Ct.source),Ft=/[\u0300-\u036f\ufe20-\ufe23]/g,It=/\\(\\)?/g,St=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Dt=/\w*$/,Tt=/^0[xX]/,Bt=/^\[object .+?Constructor\]$/,Nt=/^\d+$/,Rt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,$t=/($^)/,Mt=/['\n\r\u2028\u2029\\]/g,Lt=function(){var t="[A-Z\\xc0-\\xd6\\xd8-\\xde]",e="[a-z\\xdf-\\xf6\\xf8-\\xff]+";return RegExp(t+"+(?="+t+e+")|"+t+"?"+e+"|"+t+"+|[0-9]+","g")}(),Wt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],Ut=-1,Ht={};Ht[at]=Ht[st]=Ht[lt]=Ht[ct]=Ht[ft]=Ht[pt]=Ht[ht]=Ht[dt]=Ht[vt]=!0,Ht[z]=Ht[V]=Ht[ut]=Ht[Z]=Ht[J]=Ht[G]=Ht[Y]=Ht[X]=Ht[tt]=Ht[et]=Ht[nt]=Ht[rt]=Ht[ot]=Ht[it]=!1;var Kt={};Kt[z]=Kt[V]=Kt[ut]=Kt[Z]=Kt[J]=Kt[at]=Kt[st]=Kt[lt]=Kt[ct]=Kt[ft]=Kt[tt]=Kt[et]=Kt[nt]=Kt[ot]=Kt[pt]=Kt[ht]=Kt[dt]=Kt[vt]=!0,Kt[G]=Kt[Y]=Kt[X]=Kt[rt]=Kt[it]=!1;var Qt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},zt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Vt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Zt={"function":!0,object:!0},Jt={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Gt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Yt=Zt[typeof e]&&e&&!e.nodeType&&e,Xt=Zt[typeof t]&&t&&!t.nodeType&&t,te=Yt&&Xt&&"object"==typeof o&&o&&o.Object&&o,ee=Zt[typeof self]&&self&&self.Object&&self,ne=Zt[typeof window]&&window&&window.Object&&window,re=(Xt&&Xt.exports===Yt&&Yt,te||ne!==(this&&this.window)&&ne||ee||this),oe=P();re._=oe,r=function(){return oe}.call(e,n,e,t),!(r!==A&&(t.exports=r))}).call(this)}).call(e,n(23)(t),function(){return this}())},function(t,e,n){"use strict";var r=n(1),o={checkboxInput:n(7),checkboxOptionsInput:n(8),emailInput:n(9),fileInput:n(10),hiddenInput:n(11),passwordInput:n(12),radioOptionsInput:n(13),selectInput:n(14),textareaInput:n(16),textInput:n(15)};o.addInputType=function(t,e){if("string"!=typeof t)throw new Error("Winterfell: First parameter of addInputType must be of type string");if(!r.Component instanceof e.constructor)throw new Error('Winterfell: Cannot not assign "'+t+'" as an inputType. Second paramter expects a React component');o[t]=e},o.addInputTypes=function(t){if("object"!=typeof messages)throw new Error("Winterfell: First parameter of addInputTypes must be of type object");for(var e in t)o.addInputType(e,t[e])},t.exports=o},function(t,e){"use strict";var n={"default":"Please correct the field below",isLength:function(t){switch(t.params.length){case 1:return"Please enter a value with at least "+t.params[0]+" character"+(1!=t.params[0]?"s":"");case 2:return"Please enter a valiue between "+t.params[0]+" and "+t.params[1]+" characters long";default:return n["default"]}return errorMessage},isEmail:"Please enter a valid email address",contains:function(t){return'Please enter a value that contains "'+t.params[0]+'"'},equals:function(t){return"Value must equal "+t.params[0]},isAlpha:"Please only enter letters",isAlphanumeric:"Please only enter letters and numbers",isCreditCard:"Please enter a valid credit card number",isCurrency:"Please enter a current value only",isDate:"Please enter a valid date",isDecimal:"Please enter a decimal value only",isFloat:"Please enter a float value only",isIP:"Please enter a valid IP address",isIn:"Please enter one of the allowed values",isAllIn:"Please enter one of the allowed values",isJSON:"Please enter a valid JSON string",isLowercase:"Please enter lowercase characters only",isUppercase:"Please enter uppercase characters only",isMobilePhone:"Please enter a valid mobile phone",isMongoId:"Please enter a valid MongoId",isNumeric:"Please enter numbers only",isURL:"Please enter a valid URL",isAccepted:"Please accept by clicking the checkbox"};n.addErrorMessage=function(t,e){if("string"!=typeof t)throw new Error("Winterfell: First parameter of addErrorMessage must be of type string");if("function"!=typeof e&&"string"!=typeof e)throw new Error("Winterfell: Second parameter of addErrorMessage must be of type function or string");r(t,e)},n.addErrorMessages=function(t){if("object"!=typeof t)throw new Error("Winterfell: First parameter of addErrorMessages must be of type object");for(var e in t)n.addErrorMessage(e,t[e])},n.getErrorMessage=function(t){var e="undefined"!=typeof t.message?t.message:"undefined"!=typeof n[t.type]?n[t.type]:n["default"];return"function"==typeof e?e(t):e};var r=function(t,e){n[t]=e};t.exports=n},function(t,e,n){"use strict";var r=n(2).noConflict(),o=n(22),i=n(17),u={isAccepted:function(t,e){return t==e},isAllIn:function(t,e){return t?r.every(t,function(t){return e.indexOf(t)>-1}):!1}},a=function(t,e,n){var r="undefined"!=typeof u[e.type]?u[e.type]:o.hasOwnProperty(e.type)&&"function"==typeof o[e.type]?o[e.type]:void 0;if(!r)throw new Error('Winterfell: Attempted to validate for undefined method "'+e.type+'"');var a=(e.params||[]).slice(0);return a=a.map(function(t){return"string"==typeof t?i(t,n):t}),a.unshift(t),r.apply(null,a)},s=function h(t,e,n){return n=n||[],t.forEach(function(t){n.push({questionId:t.questionId,validations:t.validations}),"undefined"!=typeof t.input.options&&0!==t.input.options.length&&t.input.options.forEach(function(r){"undefined"!=typeof r.conditionalQuestions&&0!=r.conditionalQuestions.length&&e[t.questionId]==r.value&&(n=h(r.conditionalQuestions,e,n))})}),n},l=function(t,e){var n=[];return t.forEach(function(t){return Array.prototype.push.apply(n,s(t.questions,e))}),n},c=function(t,e){var n=l(t,e).filter(function(t){return t.validations instanceof Array&&t.validations.length>0}),r={};return n.forEach(function(t){var n=t.questionId,o=t.validations;return[].forEach.bind(o,function(t){var o=a(e[n],t,e);o||("undefined"==typeof r[n]&&(r[n]=[]),r[n].push(t))})()}),r},f=function(t,e){if("string"!=typeof t)throw new Error("Winterfell: First parameter of addValidationMethod must be of type string");if("function"!=typeof e)throw new Error("Winterfell: Second parameter of addValidationMethod must be of type function");u[t]=e},p=function(t){if("object"!=typeof t)throw new Error("Winterfell: First parameter of addValidationMethods must be of type object");for(var e in t)f[e]=t[e]};t.exports={validateAnswer:a,getActiveQuestions:s,getActiveQuestionsFromQuestionSets:l,getQuestionPanelInvalidQuestions:c,addValidationMethod:f,addValidationMethods:p}},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var i=function(){function t(t,e){for(var n=0;n-1,className:t.props.classes.checkbox,required:t.props.required?"required":void 0,onChange:t.handleChange.bind(t),onBlur:t.props.onBlur.bind(null,t.state.value)}),e.text))}))}}]),e}(a.Component);s.defaultProps={classes:{},name:void 0,value:[],options:[],onChange:function(){},onBlur:function(){}},t.exports=s},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var i=function(){function t(t,e){for(var n=0;n-1:t.props.value==e.value}).filter(function(t){return"undefined"!=typeof t.conditionalQuestions&&t.conditionalQuestions.length>0}).forEach(function(n){return[].forEach.bind(n.conditionalQuestions,function(n){r.push(s.createElement(e,{key:n.questionId,questionSetId:t.props.questionSetId,questionId:n.questionId,question:n.question,text:n.text,postText:n.postText,validateOn:n.validateOn,validations:n.validations,value:t.props.questionAnswers[n.questionId],input:n.input,classes:t.props.classes,renderError:t.props.renderError,questionAnswers:t.props.questionAnswers,validationErrors:t.props.validationErrors,onAnswerChange:t.props.onAnswerChange,onQuestionBlur:t.props.onQuestionBlur,onKeyDown:t.props.onKeyDown}))})()});var o="undefined"!=typeof this.props.value?this.props.value:"undefined"!=typeof this.props.input["default"]?this.props.input["default"]:void 0,u="undefined"!=typeof this.props.validationErrors[this.props.questionId]?this.props.validationErrors[this.props.questionId].map(function(e){return"function"==typeof t.props.renderError?t.props.renderError(e,t.props.questionId):s.createElement("div",{key:t.props.questionId+"Error"+e.type,className:t.props.classes.errorMessage},e.message)}):[],a={};return this.props.input.props&&(a=this.props.input.props),s.createElement("div",{className:this.props.classes.question},this.props.question?s.createElement("label",{className:this.props.classes.label,htmlFor:this.props.questionId},this.props.question,"undefined"!=typeof this.props.renderRequiredAsterisk&&this.props.input.required?this.props.renderRequiredAsterisk():void 0):void 0,this.props.text?s.createElement("p",{className:this.props.classes.questionText},this.props.text):void 0,u,s.createElement(n,i({name:this.props.questionId,id:this.props.questionId,value:o,text:this.props.input.text,options:this.props.input.options,placeholder:this.props.input.placeholder,required:this.props.input.required,classes:this.props.classes,onChange:this.handleInputChange.bind(this,this.props.questionId),onBlur:this.handleInputBlur.bind(this,this.props.questionId),onKeyDown:this.props.onKeyDown},a)),this.props.postText?s.createElement("p",{className:this.props.classes.questionPostText},this.props.postText):void 0,r)}},{key:"componentDidMount",value:function(){"undefined"==typeof this.props.input["default"]||"checkboxInput"===this.props.input.type&&"undefined"==typeof this.props.questionAnswers[this.props.questionId]||this.handleInputChange.call(this,this.props.questionId,this.props.input["default"])}}]),e}(s.Component);c.defaultProps={questionSetId:void 0,questionId:void 0,question:"",validateOn:"blur",validations:[],text:void 0,postText:void 0,value:void 0,input:{"default":void 0,type:"textInput",limit:void 0,placeholder:void 0},classes:{},questionAnswers:{},validationErrors:{},onAnswerChange:function(){},onQuestionBlur:function(){},onKeyDown:function(){},renderError:void 0,renderRequiredAsterisk:void 0},t.exports=c},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var i=function(){function t(t,e){for(var n=0;n-1}).value(),i=c.getQuestionPanelInvalidQuestions(o,this.props.questionAnswers);if(Object.keys(i).length>0){var u=s.mapValues(i,function(t){return t.map(function(t){return{type:t.type,message:f.getErrorMessage(t)}})});return void this.setState({validationErrors:u})}switch(n.forEach(function(n){var r=t.props.questionAnswers[n.questionId];e=r==n.value?{action:n.action,target:n.target}:e}),e.action){case"GOTO":this.props.onSwitchPanel(e.target);break;case"SUBMIT":this.props.onSubmit(e.target)}}},{key:"handleBackButtonClick",value:function(){0!=this.props.panelHistory.length&&this.props.onPanelBack()}},{key:"handleAnswerChange",value:function(t,e,n,r){this.props.onAnswerChange(t,e),this.setState({validationErrors:s.chain(this.state.validationErrors).set(t,[]).value()}),"change"===r&&this.handleAnswerValidate(t,e,n)}},{key:"handleQuestionBlur",value:function(t,e,n,r){"blur"===r&&this.handleAnswerValidate(t,e,n)}},{key:"handleInputKeyDown",value:function(t){"enter"===l[t.keyCode]&&(t.preventDefault(),this.handleMainButtonClick.call(this))}},{key:"render",value:function(){var t=this,e=this.props.questionSets.map(function(e){var n=s.find(t.props.schema.questionSets,{questionSetId:e.questionSetId});return n?a.createElement(h,{key:n.questionSetId,id:n.questionSetId,name:n.name,questionSetHeader:n.questionSetHeader,questionSetText:n.questionSetText,questions:n.questions,classes:t.props.classes,questionAnswers:t.props.questionAnswers,renderError:t.props.renderError,renderRequiredAsterisk:t.props.renderRequiredAsterisk,validationErrors:t.state.validationErrors,onAnswerChange:t.handleAnswerChange.bind(t),onQuestionBlur:t.handleQuestionBlur.bind(t),onKeyDown:t.handleInputKeyDown.bind(t)}):void 0});return a.createElement("div",{className:this.props.classes.questionPanel},"undefined"!=typeof this.props.panelHeader||"undefined"!=typeof this.props.panelText?a.createElement("div",{className:this.props.classes.questionPanelHeaderContainer},"undefined"!=typeof this.props.panelHeader?a.createElement("h3",{className:this.props.classes.questionPanelHeaderText},this.props.panelHeader):void 0,"undefined"!=typeof this.props.panelText?a.createElement("p",{className:this.props.classes.questionPanelText},this.props.panelText):void 0):void 0,a.createElement("div",{className:this.props.classes.questionSets},e),a.createElement("div",{className:this.props.classes.buttonBar},this.props.panelHistory.length>1&&!this.props.backButton.disabled?a.createElement(p,{text:this.props.backButton.text||"Back",onClick:this.handleBackButtonClick.bind(this),className:this.props.classes.backButton}):void 0,this.props.button.disabled?void 0:a.createElement(p,{text:this.props.button.text,onClick:this.handleMainButtonClick.bind(this),className:this.props.classes.controlButton})))}}]),e}(a.Component);d.defaultProps={validationErrors:{},schema:{},classes:{},panelId:void 0,panelIndex:void 0,panelHeader:void 0,panelText:void 0,action:{"default":{},conditions:[]},button:{text:"Submit"},backButton:{text:"Back"},questionSets:[],questionAnswers:{},renderError:void 0,renderRequiredAsterisk:void 0,onAnswerChange:function(){},onSwitchPanel:function(){},onPanelBack:function(){},panelHistory:[]},t.exports=d},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var i=function(){function t(t,e){for(var n=0;n - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -!function(e,n){t.exports=n()}("validator",function(t){"use strict";function e(t,e){t=t||{};for(var n in e)"undefined"==typeof t[n]&&(t[n]=e[n]);return t}function n(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),n="-?",r="[1-9]\\d*",o="[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*",i=["0",r,o],u="("+i.join("|")+")?",a="(\\"+t.decimal_separator+"\\d{2})?",s=u+a;return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?s+=n:t.negative_sign_before_digits&&(s=n+s)),t.allow_negative_sign_placeholder?s="( (?!\\-))?"+s:t.allow_space_after_symbol?s=" ?"+s:t.allow_space_after_digits&&(s+="( (?!$))?"),t.symbol_after_digits?s+=e:s=e+s,t.allow_negatives&&(t.parens_for_negatives?s="(\\("+s+"\\)|"+s+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(s=n+s)),new RegExp("^(?!-? )(?=.*\\d)"+s+"$")}t={version:"4.1.0"};var r=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,o=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,i=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,u=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,a=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,s=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,l=/^[A-Z]{2}[0-9A-Z]{9}[0-9]$/,c=/^(?:[0-9]{9}X|[0-9]{10})$/,f=/^(?:[0-9]{13})$/,p=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/,h=/^[0-9A-F]{1,4}$/i,d={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},v=/^[A-Z]+$/i,g=/^[0-9A-Z]+$/i,y=/^[-+]?[0-9]+$/,_=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,m=/^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,b=/^[0-9A-F]+$/i,w=/^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/,x=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,O=/^[\x00-\x7F]+$/,E=/[^\x00-\x7F]/,k=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,P=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,A=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,j=/^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i,C={"zh-CN":/^(\+?0?86\-?)?1[345789]\d{9}$/,"zh-TW":/^(\+?886\-?|0)?9\d{8}$/,"en-ZA":/^(\+?27|0)\d{9}$/,"en-AU":/^(\+?61|0)4\d{8}$/,"en-HK":/^(\+?852\-?)?[569]\d{3}\-?\d{4}$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"pt-PT":/^(\+351)?9[1236]\d{7}$/,"el-GR":/^(\+30)?((2\d{9})|(69\d{8}))$/,"en-GB":/^(\+?44|0)7\d{9}$/,"en-US":/^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,"en-ZM":/^(\+26)?09[567]\d{7}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/},q=/^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;t.extend=function(e,n){t[e]=function(){var e=Array.prototype.slice.call(arguments);return e[0]=t.toString(e[0]),n.apply(t,e)}},t.init=function(){for(var e in t)"function"==typeof t[e]&&"toString"!==e&&"toDate"!==e&&"extend"!==e&&"init"!==e&&t.extend(e,t[e])},t.toString=function(t){return"object"==typeof t&&null!==t&&t.toString?t=t.toString():null===t||"undefined"==typeof t||isNaN(t)&&!t.length?t="":"string"!=typeof t&&(t+=""),t},t.toDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)?t:(t=Date.parse(t),isNaN(t)?null:new Date(t))},t.toFloat=function(t){return parseFloat(t)},t.toInt=function(t,e){return parseInt(t,e||10)},t.toBoolean=function(t,e){return e?"1"===t||"true"===t:"0"!==t&&"false"!==t&&""!==t},t.equals=function(e,n){return e===t.toString(n)},t.contains=function(e,n){return e.indexOf(t.toString(n))>=0},t.matches=function(t,e,n){return"[object RegExp]"!==Object.prototype.toString.call(e)&&(e=new RegExp(e,n)),e.test(t)};var F={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0};t.isEmail=function(n,s){if(s=e(s,F),s.allow_display_name){var l=n.match(a);l&&(n=l[1])}var c=n.split("@"),f=c.pop(),p=c.join("@"),h=f.toLowerCase();if(("gmail.com"===h||"googlemail.com"===h)&&(p=p.replace(/\./g,"").toLowerCase()),!t.isByteLength(p,0,64)||!t.isByteLength(f,0,256))return!1;if(!t.isFQDN(f,{require_tld:s.require_tld}))return!1;if('"'===p[0])return p=p.slice(1,p.length-1),s.allow_utf8_local_part?u.test(p):o.test(p);for(var d=s.allow_utf8_local_part?i:r,v=p.split("."),g=0;g=2083||/\s/.test(n))return!1;if(0===n.indexOf("mailto:"))return!1;r=e(r,I);var o,i,u,a,s,l,c;if(c=n.split("://"),c.length>1){if(o=c.shift(),r.require_valid_protocol&&-1===r.protocols.indexOf(o))return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===n.substr(0,2)&&(c[0]=n.substr(2))}return n=c.join("://"),c=n.split("#"),n=c.shift(),c=n.split("?"),n=c.shift(),c=n.split("/"),n=c.shift(),c=n.split("@"),c.length>1&&(i=c.shift(),i.indexOf(":")>=0&&i.split(":").length>2)?!1:(a=c.join("@"),c=a.split(":"),u=c.shift(),c.length&&(l=c.join(":"),s=parseInt(l,10),!/^[0-9]+$/.test(l)||0>=s||s>65535)?!1:t.isIP(u)||t.isFQDN(u,r)||"localhost"===u?r.host_whitelist&&-1===r.host_whitelist.indexOf(u)?!1:r.host_blacklist&&-1!==r.host_blacklist.indexOf(u)?!1:!0:!1)},t.isIP=function(e,n){if(n=t.toString(n),!n)return t.isIP(e,4)||t.isIP(e,6);if("4"===n){if(!p.test(e))return!1;var r=e.split(".").sort(function(t,e){return t-e});return r[3]<=255}if("6"===n){var o=e.split(":"),i=!1,u=t.isIP(o[o.length-1],4),a=u?7:8;if(o.length>a)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(o.shift(),o.shift(),i=!0):"::"===e.substr(e.length-2)&&(o.pop(),o.pop(),i=!0);for(var s=0;s0&&s=1:o.length===a}return!1};var S={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1};t.isFQDN=function(t,n){n=e(n,S),n.allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var r=t.split(".");if(n.require_tld){var o=r.pop();if(!r.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(o))return!1}for(var i,u=0;u=0)return!1;i=i.replace(/_/g,"")}if(!/^[a-z\u00a1-\uffff0-9-]+$/i.test(i))return!1;if(/[\uff01-\uff5e]/.test(i))return!1;if("-"===i[0]||"-"===i[i.length-1]||i.indexOf("---")>=0)return!1}return!0},t.isBoolean=function(t){return["true","false","1","0"].indexOf(t)>=0},t.isAlpha=function(t){return v.test(t)},t.isAlphanumeric=function(t){return g.test(t)},t.isNumeric=function(t){return y.test(t)},t.isDecimal=function(t){return""!==t&&w.test(t)},t.isHexadecimal=function(t){return b.test(t)},t.isHexColor=function(t){return x.test(t)},t.isLowercase=function(t){return t===t.toLowerCase()},t.isUppercase=function(t){return t===t.toUpperCase()},t.isInt=function(t,e){return e=e||{},_.test(t)&&(!e.hasOwnProperty("min")||t>=e.min)&&(!e.hasOwnProperty("max")||t<=e.max)},t.isFloat=function(t,e){return e=e||{},""!==t&&m.test(t)&&(!e.hasOwnProperty("min")||t>=e.min)&&(!e.hasOwnProperty("max")||t<=e.max)},t.isDivisibleBy=function(e,n){return t.toFloat(e)%t.toInt(n)===0},t.isNull=function(t){return 0===t.length},t.isLength=function(t,e,n){var r=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],o=t.length-r.length;return o>=e&&("undefined"==typeof n||n>=o)},t.isByteLength=function(t,e,n){var r=encodeURI(t).split(/%..|./).length-1;return r>=e&&("undefined"==typeof n||n>=r)},t.isUUID=function(t,e){var n=d[e?e:"all"];return n&&n.test(t)},t.isDate=function(t){var e,n,r,o=new Date(new Date(t).toUTCString()),i=String(o.getDate()),u=String(o.getUTCDate());return isNaN(Date.parse(o))?!1:(n=t.match(/(^|[^:\d])[23]\d([^:\d]|$)/g))?(e=n.map(function(t){return t.match(/\d+/g)[0]}).join("/"),r=String(o.getFullYear()).slice(-2),e===i||e===u||e===r?!0:e===i+"/"+r||e===r+"/"+i?!0:e===u+"/"+r||e===r+"/"+u?!0:!1):!0},t.isAfter=function(e,n){var r=t.toDate(n||new Date),o=t.toDate(e);return!!(o&&r&&o>r)},t.isBefore=function(e,n){var r=t.toDate(n||new Date),o=t.toDate(e);return!!(o&&r&&r>o)},t.isIn=function(e,n){var r;if("[object Array]"===Object.prototype.toString.call(n)){var o=[];for(r in n)o[r]=t.toString(n[r]);return o.indexOf(e)>=0}return"object"==typeof n?n.hasOwnProperty(e):n&&"function"==typeof n.indexOf?n.indexOf(e)>=0:!1},t.isCreditCard=function(t){var e=t.replace(/[^0-9]+/g,"");if(!s.test(e))return!1;for(var n,r,o,i=0,u=e.length-1;u>=0;u--)n=e.substring(u,u+1),r=parseInt(n,10),o?(r*=2,i+=r>=10?r%10+1:r):i+=r,o=!o;return!!(i%10===0?e:!1)},t.isISIN=function(t){if(!l.test(t))return!1;for(var e,n,r=t.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),o=0,i=!0,u=r.length-2;u>=0;u--)e=r.substring(u,u+1),n=parseInt(e,10),i?(n*=2,o+=n>=10?n+1:n):o+=n,i=!i;return parseInt(t.substr(t.length-1),10)===(1e4-o)%10},t.isISBN=function(e,n){if(n=t.toString(n),!n)return t.isISBN(e,10)||t.isISBN(e,13);var r,o=e.replace(/[\s-]+/g,""),i=0;if("10"===n){if(!c.test(o))return!1;for(r=0;9>r;r++)i+=(r+1)*o.charAt(r);if(i+="X"===o.charAt(9)?100:10*o.charAt(9),i%11===0)return!!o}else if("13"===n){if(!f.test(o))return!1;var u=[1,3];for(r=0;12>r;r++)i+=u[r%2]*o.charAt(r);if(o.charAt(12)-(10-i%10)%10===0)return!!o}return!1},t.isMobilePhone=function(t,e){return e in C?C[e].test(t):!1};var D={symbol:"$",require_symbol:!1,allow_space_after_symbol:!1,symbol_after_digits:!1,allow_negatives:!0,parens_for_negatives:!1,negative_sign_before_digits:!1,negative_sign_after_digits:!1,allow_negative_sign_placeholder:!1,thousands_separator:",",decimal_separator:".",allow_space_after_digits:!1};t.isCurrency=function(t,r){return r=e(r,D),n(r).test(t)},t.isJSON=function(t){try{var e=JSON.parse(t);return!!e&&"object"==typeof e}catch(n){}return!1},t.isMultibyte=function(t){return E.test(t)},t.isAscii=function(t){return O.test(t)},t.isFullWidth=function(t){return k.test(t)},t.isHalfWidth=function(t){return P.test(t)},t.isVariableWidth=function(t){return k.test(t)&&P.test(t)},t.isSurrogatePair=function(t){return A.test(t)},t.isBase64=function(t){return j.test(t)},t.isMongoId=function(e){return t.isHexadecimal(e)&&24===e.length},t.isISO8601=function(t){return q.test(t)},t.ltrim=function(t,e){var n=e?new RegExp("^["+e+"]+","g"):/^\s+/g;return t.replace(n,"")},t.rtrim=function(t,e){var n=e?new RegExp("["+e+"]+$","g"):/\s+$/g;return t.replace(n,"")},t.trim=function(t,e){var n=e?new RegExp("^["+e+"]+|["+e+"]+$","g"):/^\s+|\s+$/g;return t.replace(n,"")},t.escape=function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/\//g,"/").replace(/\`/g,"`")},t.stripLow=function(e,n){var r=n?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return t.blacklist(e,r)},t.whitelist=function(t,e){return t.replace(new RegExp("[^"+e+"]+","g"),"")},t.blacklist=function(t,e){return t.replace(new RegExp("["+e+"]+","g"),"")};var T={lowercase:!0};return t.normalizeEmail=function(n,r){if(r=e(r,T),!t.isEmail(n))return!1;var o=n.split("@",2);if(o[1]=o[1].toLowerCase(),"gmail.com"===o[1]||"googlemail.com"===o[1]){if(o[0]=o[0].toLowerCase().replace(/\./g,""),"+"===o[0][0])return!1;o[0]=o[0].split("+")[0],o[1]="gmail.com"}else r.lowercase&&(o[0]=o[0].toLowerCase());return o.join("@")},t.init(),t})},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}}]); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 99485fbf..f4885de1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,6 +4,9 @@ var source = require('vinyl-source-stream'); var babelify = require('babelify'); var buffer = require('vinyl-buffer'); var uglify = require('gulp-uglify'); +var rimraf = require('rimraf'); +var webpack = require('webpack'); +var run = require('gulp-run'); /** * Examples Build @@ -23,6 +26,10 @@ gulp.task('build-examples', function() { .pipe(gulp.dest('examples/build')); }); +gulp.task('build-onepeace', function() { + return run('bash ../one-peace/updateWinterfell.sh').exec(); +}); + gulp.task('watch-examples', function() { return gulp.watch([ 'src/**/*.js', @@ -31,4 +38,13 @@ gulp.task('watch-examples', function() { ], {}, function() { return gulp.start('build-examples'); }); +}); + +gulp.task('watch-src', function(){ + return gulp.watch([ + 'src/*.js', + 'src/**/*.js' + ], {}, function(){ + return gulp.start('build-onepeace'); + }); }); \ No newline at end of file diff --git a/package.json b/package.json index 288a5f4d..497c67bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "winterfell", - "version": "1.0.5", + "name": "curryroad", + "version": "1.0.6", "description": "Generate complex, validated and extendable JSON-based forms in React", "main": "dist/index.js", "scripts": { @@ -9,6 +9,7 @@ "build": "babel src --out-dir dist && webpack", "prepublish": "npm run clean && npm run build" }, + "private": true, "keywords": [ "winterfell", "form", @@ -40,9 +41,13 @@ "babel-core": "^5.8.23", "babel-loader": "^5.3.2", "browserify": "^11.0.1", + "classnames": "^2.2.3", "gulp": "^3.9.0", + "gulp-run": "^1.6.12", "gulp-uglify": "^1.2.0", - "react": "^0.13.3", + "react": "^0.14.6", + "react-addons-shallow-compare": "^0.14.6", + "react-dom": "^0.14.6", "rimraf": "^2.4.3", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", diff --git a/src/button.js b/src/button.js index d7fc1555..8df8eb6c 100644 --- a/src/button.js +++ b/src/button.js @@ -10,11 +10,11 @@ class Button extends React.Component { render() { return ( - {this.props.text} - + ); } diff --git a/src/core/formSectionHeading.js b/src/core/formSectionHeading.js new file mode 100644 index 00000000..59ca92d2 --- /dev/null +++ b/src/core/formSectionHeading.js @@ -0,0 +1,68 @@ +var React = require('react'), + classNames = require('classnames'), + //TooltipInfo = require('./TooltipInfo.jsx'), + shallowCompare = require('react-addons-shallow-compare'); + +class FormSectionHeading extends React.Component { + + shouldComponentUpdate( nextProps, nextState ) { + // return true; + return shallowCompare( this, nextProps, nextState ); + } + + render() { + var props = this.props; + var fontClass = classNames( + 'u-c-secondary u-t-bold form-group__label__text', + props.fontClass !== undefined ? props.fontClass : '' + ); + var blockWidthClass = classNames( + 'pure-u-1', + props.blockWidthClass !== undefined ? props.blockWidthClass : '' + ); + + // var tooltip = null; + // if(props.tooltip) + // { + // tooltip = ( + // + // ); + // } + + var iconClass = null; + var icon = null; + if(props.iconClass !== undefined) { + iconClass = classNames( + 'form-group__label__icon', + props.iconClass !== null ? props.iconClass : '', + { + 'u-v-hidden' : props.iconClass === null + } + ); + icon = ( + + ); + } + + return ( +
+
+ {icon} + {props.labelText} + {/*tooltip*/} +
+
+ ); + } + +}; + +FormSectionHeading.defaultProps = { + iconClass : undefined, + fontClass : undefined, + blockWidthClass : undefined, + tooltip : undefined, + labelText : null +}; + +module.exports = FormSectionHeading; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 06426953..5dd60e03 100644 --- a/src/index.js +++ b/src/index.js @@ -15,6 +15,7 @@ class Winterfell extends React.Component { formPanels : [], questionPanels : [], questionSets : [], + form : {} }, this.props.schema); schema.formPanels = schema.formPanels @@ -79,7 +80,16 @@ class Winterfell extends React.Component { this.setState({ currentPanel : panel - }, this.props.onSwitchPanel.bind(null, panel)); + }, this.switchPanelCallback.bind( this, panel )); + // this.props.onSwitchPanel.call( null, panel, this.setPanel.bind(this, panel ) ); + // this.setState({ + // currentPanel : panel + // }, this.props.onSwitchPanel.bind(null, panel)); + } + + switchPanelCallback( panel ) { + this.props.onSwitchPanel.call( null, panel); + $('html, body').animate({scrollTop:0}, 'slow'); } handleBackButtonClick() { @@ -113,32 +123,43 @@ class Winterfell extends React.Component { panel => panel.panelId == this.state.currentPanel.panelId); return ( -
-
- +
+
+
+
{this.state.schema.form.header}
+
+
+ + {/*
*/} + + {/*
*/} + +
- +
); } @@ -155,7 +176,8 @@ Winterfell.defaultProps = { formPanels : [], questionPanels : [], questionSets : [], - classes : {} + classes : {}, + form : {} }, questionAnswers : {}, ref : 'form', @@ -169,7 +191,8 @@ Winterfell.defaultProps = { onSubmit : () => {}, onUpdate : () => {}, onSwitchPanel : () => {}, - onRender : () => {} + onRender : () => {}, + getCustomRender : () => {} }; Winterfell.inputTypes = require('./inputTypes'); diff --git a/src/inputTypes/amountInput.js b/src/inputTypes/amountInput.js new file mode 100644 index 00000000..7b47c39c --- /dev/null +++ b/src/inputTypes/amountInput.js @@ -0,0 +1,147 @@ +var React = require('react'); +var reactDOM = require('react-dom'); +var classNames = require('classnames'); + +class AmountInput extends React.Component { + + constructor(props) { + super(props); + + this.state = { + displayValue : this.props.value === null ? null : this.props.value/this.props.denominator, + value : this.props.value + }; + } + + handleChange(e) { + var displayValue = e.target.value, + value; + + displayValue = displayValue === '' ? null : displayValue; + if( displayValue !== null ) { + if ( this.props.isDecimal) { + if (displayValue.indexOf('.') != -1 && displayValue.split('.')[1].length > 2) { + return; + } + } else { + displayValue = displayValue.substring(0, displayValue.indexOf('.')); + } + } + value = displayValue === null ? null : displayValue * this.props.denominator; + this.setState({ + displayValue : displayValue, + value : value + }, this.props.onChange.bind(null, value)); + } + + handleBlur() { + var value = this.state.value === null ? null : this.state.value; + this.props.onBlur.call( null, value); + } + + componentDidMount() { + var inputBox = $(reactDOM.findDOMNode(this)).find('.tool-input-box'); + inputBox.popover({placement: this.props.tooltipPlacement ? this.props.tooltipPlacement : Tooltip.placement(200)}); + } + + render() { + var props = this.props, + value = this.state.value, + errorMessage, + suffix, + info, + inputBoxClassName; + + if(props.suffix !== undefined ) { + suffix = ( + {props.suffix} + ); + } + if( value !== '' && props.enableInfo ) { + info = ( +
+ {value < 0 ? '(' : ''} + + {Common.numberToWords(value)} + {value < 0 ? ')' : ''} +
+ ); + } + + if( props.validationErrors && props.validationErrors.length > 0 ) { + errorMessage = ( +
{props.validationErrors[0].message}
+ ); + } + else { + errorMessage = ( +
{props.typeErrorMessage }
+ ); + } + + inputBoxClassName = classNames( 'tool-input-box', + { + 'tool-input-box--no-placeholder' : props.suffix === '', + 'invalid' : props.validationErrors && props.validationErrors.length > 0 + } + ); + + return ( +
+
+ + + {suffix} + + {props.suffix} +
+ {info} + {errorMessage} +
+ ); + } + +}; + +AmountInput.defaultProps = { + min : 0, + max : 10000, + placeholder : 'eg. 20', + step : 1, + className : '', + disabled : false, + suffix : '', + required : true, + isDecimal : true, + denominator : 1, + validationErrors : undefined, + classes : {}, + name : '', + id : undefined, + displayValue : null, + value : null, + typeErrorMessage : 'Please enter a valid number', + onChange : () => {}, + onBlur : () => {}, + onKeyDown : () => {} +}; + +module.exports = AmountInput; \ No newline at end of file diff --git a/src/inputTypes/checkboxInput.js b/src/inputTypes/checkboxInput.js index b706601d..7968cd14 100644 --- a/src/inputTypes/checkboxInput.js +++ b/src/inputTypes/checkboxInput.js @@ -35,9 +35,11 @@ class CheckboxInput extends React.Component { render() { return (
-