elements don't support innerText even when does.
contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText';
}
return contentKey;
}
module.exports = getTextContentAccessor;
/***/ }),
/* 87 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
var _prodInvariant = __webpack_require__(3),
_assign = __webpack_require__(4);
var ReactCompositeComponent = __webpack_require__(158);
var ReactEmptyComponent = __webpack_require__(75);
var ReactHostComponent = __webpack_require__(77);
var getNextDebugID = __webpack_require__(212);
var invariant = __webpack_require__(1);
var warning = __webpack_require__(2);
// To avoid a cyclic dependency, we create the final class in this module
var ReactCompositeComponentWrapper = function (element) {
this.construct(element);
};
_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, {
_instantiateReactComponent: instantiateReactComponent
});
function getDeclarationErrorAddendum(owner) {
if (owner) {
var name = owner.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
}
/**
* Check if the type reference is a known internal type. I.e. not a user
* provided composite type.
*
* @param {function} type
* @return {boolean} Returns true if this is a valid internal type.
*/
function isInternalComponentType(type) {
return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
}
/**
* Given a ReactNode, create an instance that will actually be mounted.
*
* @param {ReactNode} node
* @param {boolean} shouldHaveDebugID
* @return {object} A new instance of the element's constructor.
* @protected
*/
function instantiateReactComponent(node, shouldHaveDebugID) {
var instance;
if (node === null || node === false) {
instance = ReactEmptyComponent.create(instantiateReactComponent);
} else if (typeof node === 'object') {
var element = node;
var type = element.type;
if (typeof type !== 'function' && typeof type !== 'string') {
var info = '';
if (process.env.NODE_ENV !== 'production') {
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.';
}
}
info += getDeclarationErrorAddendum(element._owner);
true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info) : _prodInvariant('130', type == null ? type : typeof type, info) : void 0;
}
// Special case string values
if (typeof element.type === 'string') {
instance = ReactHostComponent.createInternalComponent(element);
} else if (isInternalComponentType(element.type)) {
// This is temporarily available for custom components that are not string
// representations. I.e. ART. Once those are updated to use the string
// representation, we can drop this code path.
instance = new element.type(element);
// We renamed this. Allow the old name for compat. :(
if (!instance.getHostNode) {
instance.getHostNode = instance.getNativeNode;
}
} else {
instance = new ReactCompositeComponentWrapper(element);
}
} else if (typeof node === 'string' || typeof node === 'number') {
instance = ReactHostComponent.createInstanceForText(node);
} else {
true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : _prodInvariant('131', typeof node) : void 0;
}
if (process.env.NODE_ENV !== 'production') {
process.env.NODE_ENV !== 'production' ? warning(typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.getHostNode === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : void 0;
}
// These two fields are used by the DOM and ART diffing algorithms
// respectively. Instead of using expandos on components, we should be
// storing the state needed by the diffing algorithms elsewhere.
instance._mountIndex = 0;
instance._mountImage = null;
if (process.env.NODE_ENV !== 'production') {
instance._debugID = shouldHaveDebugID ? getNextDebugID() : 0;
}
// Internal instances should fully constructed at this point, so they should
// not get any new fields added to them at this point.
if (process.env.NODE_ENV !== 'production') {
if (Object.preventExtensions) {
Object.preventExtensions(instance);
}
}
return instance;
}
module.exports = instantiateReactComponent;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 88 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
/**
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
*/
var supportedInputTypes = {
'color': true,
'date': true,
'datetime': true,
'datetime-local': true,
'email': true,
'month': true,
'number': true,
'password': true,
'range': true,
'search': true,
'tel': true,
'text': true,
'time': true,
'url': true,
'week': true
};
function isTextInputElement(elem) {
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
if (nodeName === 'input') {
return !!supportedInputTypes[elem.type];
}
if (nodeName === 'textarea') {
return true;
}
return false;
}
module.exports = isTextInputElement;
/***/ }),
/* 89 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
var ExecutionEnvironment = __webpack_require__(6);
var escapeTextContentForBrowser = __webpack_require__(34);
var setInnerHTML = __webpack_require__(35);
/**
* Set the textContent property of a node, ensuring that whitespace is preserved
* even in IE8. innerText is a poor substitute for textContent and, among many
* issues, inserts
instead of the literal newline chars. innerHTML behaves
* as it should.
*
* @param {DOMElement} node
* @param {string} text
* @internal
*/
var setTextContent = function (node, text) {
if (text) {
var firstChild = node.firstChild;
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === 3) {
firstChild.nodeValue = text;
return;
}
}
node.textContent = text;
};
if (ExecutionEnvironment.canUseDOM) {
if (!('textContent' in document.documentElement)) {
setTextContent = function (node, text) {
if (node.nodeType === 3) {
node.nodeValue = text;
return;
}
setInnerHTML(node, escapeTextContentForBrowser(text));
};
}
}
module.exports = setTextContent;
/***/ }),
/* 90 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
var _prodInvariant = __webpack_require__(3);
var ReactCurrentOwner = __webpack_require__(11);
var REACT_ELEMENT_TYPE = __webpack_require__(177);
var getIteratorFn = __webpack_require__(211);
var invariant = __webpack_require__(1);
var KeyEscapeUtils = __webpack_require__(42);
var warning = __webpack_require__(2);
var SEPARATOR = '.';
var SUBSEPARATOR = ':';
/**
* This is inlined from ReactElement since this file is shared between
* isomorphic and renderers. We could extract this to a
*
*/
/**
* TODO: Test that a single child and an array with one item have the same key
* pattern.
*/
var didWarnAboutMaps = false;
/**
* Generate a key string that identifies a component within a set.
*
* @param {*} component A component that could contain a manual key.
* @param {number} index Index that is used if a manual key is not provided.
* @return {string}
*/
function getComponentKey(component, index) {
// Do some typechecking here since we call this blindly. We want to ensure
// that we don't block potential future ES APIs.
if (component && typeof component === 'object' && component.key != null) {
// Explicit key
return KeyEscapeUtils.escape(component.key);
}
// Implicit key determined by the index in the set
return index.toString(36);
}
/**
* @param {?*} children Children tree container.
* @param {!string} nameSoFar Name of the key path so far.
* @param {!function} callback Callback to invoke with each child found.
* @param {?*} traverseContext Used to pass information throughout the traversal
* process.
* @return {!number} The number of children in this subtree.
*/
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
var type = typeof children;
if (type === 'undefined' || type === 'boolean') {
// All of the above are perceived as null.
children = null;
}
if (children === null || type === 'string' || type === 'number' ||
// The following is inlined from ReactElement. This means we can optimize
// some checks. React Fiber also inlines this logic for similar purposes.
type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) {
callback(traverseContext, children,
// If it's the only child, treat the name as if it was wrapped in an array
// so that it's consistent if the number of children grows.
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
return 1;
}
var child;
var nextName;
var subtreeCount = 0; // Count of children found in the current subtree.
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
if (Array.isArray(children)) {
for (var i = 0; i < children.length; i++) {
child = children[i];
nextName = nextNamePrefix + getComponentKey(child, i);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
} else {
var iteratorFn = getIteratorFn(children);
if (iteratorFn) {
var iterator = iteratorFn.call(children);
var step;
if (iteratorFn !== children.entries) {
var ii = 0;
while (!(step = iterator.next()).done) {
child = step.value;
nextName = nextNamePrefix + getComponentKey(child, ii++);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
} else {
if (process.env.NODE_ENV !== 'production') {
var mapsAsChildrenAddendum = '';
if (ReactCurrentOwner.current) {
var mapsAsChildrenOwnerName = ReactCurrentOwner.current.getName();
if (mapsAsChildrenOwnerName) {
mapsAsChildrenAddendum = ' Check the render method of `' + mapsAsChildrenOwnerName + '`.';
}
}
process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.%s', mapsAsChildrenAddendum) : void 0;
didWarnAboutMaps = true;
}
// Iterator will provide entry [k,v] tuples rather than values.
while (!(step = iterator.next()).done) {
var entry = step.value;
if (entry) {
child = entry[1];
nextName = nextNamePrefix + KeyEscapeUtils.escape(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0);
subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
}
}
}
} else if (type === 'object') {
var addendum = '';
if (process.env.NODE_ENV !== 'production') {
addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.';
if (children._isReactElement) {
addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.';
}
if (ReactCurrentOwner.current) {
var name = ReactCurrentOwner.current.getName();
if (name) {
addendum += ' Check the render method of `' + name + '`.';
}
}
}
var childrenString = String(children);
true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : _prodInvariant('31', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : void 0;
}
}
return subtreeCount;
}
/**
* Traverses children that are typically specified as `props.children`, but
* might also be specified through attributes:
*
* - `traverseAllChildren(this.props.children, ...)`
* - `traverseAllChildren(this.props.leftPanelChildren, ...)`
*
* The `traverseContext` is an optional argument that is passed through the
* entire traversal. It can be used to store accumulations or anything else that
* the callback might find relevant.
*
* @param {?*} children Children tree object.
* @param {!function} callback To invoke upon traversing each child.
* @param {?*} traverseContext Context for traversal.
* @return {!number} The number of children in this subtree.
*/
function traverseAllChildren(children, callback, traverseContext) {
if (children == null) {
return 0;
}
return traverseAllChildrenImpl(children, '', callback, traverseContext);
}
module.exports = traverseAllChildren;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 91 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
// The Symbol used to tag the ReactElement type. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
module.exports = REACT_ELEMENT_TYPE;
/***/ }),
/* 92 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
/**
* ReactElementValidator provides a wrapper around a element factory
* which validates the props passed to the element. This is intended to be
* used only in DEV and could be replaced by a static type checker for languages
* that support it.
*/
var ReactCurrentOwner = __webpack_require__(11);
var ReactComponentTreeHook = __webpack_require__(7);
var ReactElement = __webpack_require__(16);
var checkReactTypeSpec = __webpack_require__(225);
var canDefineProperty = __webpack_require__(57);
var getIteratorFn = __webpack_require__(58);
var warning = __webpack_require__(2);
function getDeclarationErrorAddendum() {
if (ReactCurrentOwner.current) {
var name = ReactCurrentOwner.current.getName();
if (name) {
return ' Check the render method of `' + name + '`.';
}
}
return '';
}
/**
* Warn if there's no key explicitly set on dynamic arrays of children or
* object keys are not valid. This allows us to keep track of children between
* updates.
*/
var ownerHasKeyUseWarning = {};
function getCurrentComponentErrorInfo(parentType) {
var info = getDeclarationErrorAddendum();
if (!info) {
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
if (parentName) {
info = ' Check the top-level render call using <' + parentName + '>.';
}
}
return info;
}
/**
* Warn if the element doesn't have an explicit key assigned to it.
* This element is in an array. The array could grow and shrink or be
* reordered. All children that haven't already been validated are required to
* have a "key" property assigned to it. Error statuses are cached so a warning
* will only be shown once.
*
* @internal
* @param {ReactElement} element Element that requires a key.
* @param {*} parentType element's parent's type.
*/
function validateExplicitKey(element, parentType) {
if (!element._store || element._store.validated || element.key != null) {
return;
}
element._store.validated = true;
var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
if (memoizer[currentComponentErrorInfo]) {
return;
}
memoizer[currentComponentErrorInfo] = true;
// Usually the current owner is the offender, but if it accepts children as a
// property, it may be the creator of the child that's responsible for
// assigning it a key.
var childOwner = '';
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
// Give the component that originally created this child.
childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
}
process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, ReactComponentTreeHook.getCurrentStackAddendum(element)) : void 0;
}
/**
* Ensure that every element either is passed in a static location, in an
* array with an explicit keys property defined, or in an object literal
* with valid key property.
*
* @internal
* @param {ReactNode} node Statically passed child of any type.
* @param {*} parentType node's parent's type.
*/
function validateChildKeys(node, parentType) {
if (typeof node !== 'object') {
return;
}
if (Array.isArray(node)) {
for (var i = 0; i < node.length; i++) {
var child = node[i];
if (ReactElement.isValidElement(child)) {
validateExplicitKey(child, parentType);
}
}
} else if (ReactElement.isValidElement(node)) {
// This element was passed in a valid location.
if (node._store) {
node._store.validated = true;
}
} else if (node) {
var iteratorFn = getIteratorFn(node);
// Entry iterators provide implicit keys.
if (iteratorFn) {
if (iteratorFn !== node.entries) {
var iterator = iteratorFn.call(node);
var step;
while (!(step = iterator.next()).done) {
if (ReactElement.isValidElement(step.value)) {
validateExplicitKey(step.value, parentType);
}
}
}
}
}
}
/**
* Given an element, validate that its props follow the propTypes definition,
* provided by the type.
*
* @param {ReactElement} element
*/
function validatePropTypes(element) {
var componentClass = element.type;
if (typeof componentClass !== 'function') {
return;
}
var name = componentClass.displayName || componentClass.name;
if (componentClass.propTypes) {
checkReactTypeSpec(componentClass.propTypes, element.props, 'prop', name, element, null);
}
if (typeof componentClass.getDefaultProps === 'function') {
process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
}
}
var ReactElementValidator = {
createElement: function (type, props, children) {
var validType = typeof type === 'string' || typeof type === 'function';
// We warn in this case but don't throw. We expect the element creation to
// succeed and there will likely be errors in render.
if (!validType) {
if (typeof type !== 'function' && typeof type !== 'string') {
var info = '';
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.';
}
info += getDeclarationErrorAddendum();
process.env.NODE_ENV !== 'production' ? warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info) : void 0;
}
}
var element = ReactElement.createElement.apply(this, arguments);
// The result can be nullish if a mock or a custom function is used.
// TODO: Drop this when these are no longer allowed as the type argument.
if (element == null) {
return element;
}
// Skip key warning if the type isn't valid since our key validation logic
// doesn't expect a non-string/function type and can throw confusing errors.
// We don't want exception behavior to differ between dev and prod.
// (Rendering will throw with a helpful message and as soon as the type is
// fixed, the key warnings will appear.)
if (validType) {
for (var i = 2; i < arguments.length; i++) {
validateChildKeys(arguments[i], type);
}
}
validatePropTypes(element);
return element;
},
createFactory: function (type) {
var validatedFactory = ReactElementValidator.createElement.bind(null, type);
// Legacy hook TODO: Warn if this is accessed
validatedFactory.type = type;
if (process.env.NODE_ENV !== 'production') {
if (canDefineProperty) {
Object.defineProperty(validatedFactory, 'type', {
enumerable: false,
get: function () {
process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : void 0;
Object.defineProperty(this, 'type', {
value: type
});
return type;
}
});
}
}
return validatedFactory;
},
cloneElement: function (element, props, children) {
var newElement = ReactElement.cloneElement.apply(this, arguments);
for (var i = 2; i < arguments.length; i++) {
validateChildKeys(arguments[i], newElement.type);
}
validatePropTypes(newElement);
return newElement;
}
};
module.exports = ReactElementValidator;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 93 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
module.exports = ReactPropTypesSecret;
/***/ }),
/* 94 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _react = __webpack_require__(14);
var _react2 = _interopRequireDefault(_react);
var _LoggedOutView = __webpack_require__(97);
var _LoggedOutView2 = _interopRequireDefault(_LoggedOutView);
var _LoggedInView = __webpack_require__(96);
var _LoggedInView2 = _interopRequireDefault(_LoggedInView);
var _client = __webpack_require__(22);
var _client2 = _interopRequireDefault(_client);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var App = function (_React$Component) {
_inherits(App, _React$Component);
function App() {
_classCallCheck(this, App);
var _this = _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).call(this));
_this.state = {
ready: false,
loggedIn: false,
user: {}
};
_this.didAuthenticate = _this.didAuthenticate.bind(_this);
_client2.default.authenticate().then(function (user) {
_this.setState({
ready: true,
loggedIn: true,
user: user.data
});
}).catch(function (error) {
_this.setState({ ready: true });
if (!error.message.match(/stored JWT/)) {
console.error(error);
}
});
return _this;
}
_createClass(App, [{
key: 'didAuthenticate',
value: function didAuthenticate(user) {
console.log(user);
this.setState({
user: user,
loggedIn: true
});
}
}, {
key: 'logOut',
value: function logOut() {
this.setState({
user: null,
loggedIn: false
});
}
}, {
key: 'render',
value: function render() {
if (this.state.ready) {
if (this.state.loggedIn) {
return _react2.default.createElement(_LoggedInView2.default, { user: this.state.user });
} else {
return _react2.default.createElement(_LoggedOutView2.default, { didAuthenticate: this.didAuthenticate });
}
} else {
return _react2.default.createElement(
'div',
null,
'Loading...'
);
}
}
}]);
return App;
}(_react2.default.Component);
exports.default = App;
/***/ }),
/* 95 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(159);
/***/ }),
/* 96 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _react = __webpack_require__(14);
var _react2 = _interopRequireDefault(_react);
var _ModalDialog = __webpack_require__(60);
var _ModalDialog2 = _interopRequireDefault(_ModalDialog);
var _Menu = __webpack_require__(365);
var _Menu2 = _interopRequireDefault(_Menu);
var _UserList = __webpack_require__(100);
var _UserList2 = _interopRequireDefault(_UserList);
var _MealList = __webpack_require__(99);
var _MealList2 = _interopRequireDefault(_MealList);
var _client = __webpack_require__(22);
var _client2 = _interopRequireDefault(_client);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var LoggedInView = function (_React$Component) {
_inherits(LoggedInView, _React$Component);
function LoggedInView(props) {
_classCallCheck(this, LoggedInView);
var _this = _possibleConstructorReturn(this, (LoggedInView.__proto__ || Object.getPrototypeOf(LoggedInView)).call(this));
_this.state = {
user: Object.assign({}, props.user),
meals: [],
mode: 'meals'
};
_this.updateUser = _this.updateUser.bind(_this);
_this.updateMeals = _this.updateMeals.bind(_this);
_this.toggleMode = _this.toggleMode.bind(_this);
return _this;
}
_createClass(LoggedInView, [{
key: 'toggleMode',
value: function toggleMode() {
this.setState({ mode: this.state.mode == 'meals' ? 'users' : 'meals' });
}
}, {
key: 'updateUser',
value: function updateUser(user) {
this.setState({
user: user,
mode: 'meals'
});
}
}, {
key: 'updateMeals',
value: function updateMeals(user) {
this.setState({
meals: meals
});
}
}, {
key: 'render',
value: function render() {
var activity = null;
if (this.state.mode == 'meals') {
activity = _react2.default.createElement(_MealList2.default, { user: this.state.user,
currentUser: this.props.user,
onUpdate: this.updateMeals
});
} else {
activity = _react2.default.createElement(_UserList2.default, { user: this.state.user,
currentUser: this.props.user,
updateUser: this.updateUser
});
}
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(_Menu2.default, { mode: this.state.mode,
user: this.state.user,
toggleMode: this.toggleMode,
currentUser: this.props.user,
updateUser: this.updateUser }),
activity
);
}
}]);
return LoggedInView;
}(_react2.default.Component);
exports.default = LoggedInView;
/***/ }),
/* 97 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _react = __webpack_require__(14);
var _react2 = _interopRequireDefault(_react);
var _ModalDialog = __webpack_require__(60);
var _ModalDialog2 = _interopRequireDefault(_ModalDialog);
var _client = __webpack_require__(22);
var _client2 = _interopRequireDefault(_client);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var LoggedOutView = function (_React$Component) {
_inherits(LoggedOutView, _React$Component);
function LoggedOutView() {
_classCallCheck(this, LoggedOutView);
var _this = _possibleConstructorReturn(this, (LoggedOutView.__proto__ || Object.getPrototypeOf(LoggedOutView)).call(this));
_this.state = { modal: null };
_this.showLogin = _this.showLogin.bind(_this);
_this.showSignup = _this.showSignup.bind(_this);
_this.closeModal = _this.closeModal.bind(_this);
return _this;
}
_createClass(LoggedOutView, [{
key: 'showLogin',
value: function showLogin() {
this.setState({ modal: 'login' });
}
}, {
key: 'showSignup',
value: function showSignup() {
this.setState({ modal: 'signup' });
}
}, {
key: 'closeModal',
value: function closeModal() {
this.setState({ modal: '' });
}
}, {
key: 'render',
value: function render() {
if (this.state.modal == 'login') {
return _react2.default.createElement(LoginForm, {
visible: true,
didAuthenticate: this.props.didAuthenticate,
onClose: this.closeModal });
} else if (this.state.modal == 'signup') {
return _react2.default.createElement(SignupForm, {
visible: true,
didAuthenticate: this.props.didAuthenticate,
onClose: this.closeModal });
} else {
return _react2.default.createElement(Welcome, {
onLoginClick: this.showLogin,
onSignupClick: this.showSignup });
}
}
}]);
return LoggedOutView;
}(_react2.default.Component);
exports.default = LoggedOutView;
var Welcome = function (_React$Component2) {
_inherits(Welcome, _React$Component2);
function Welcome() {
_classCallCheck(this, Welcome);
return _possibleConstructorReturn(this, (Welcome.__proto__ || Object.getPrototypeOf(Welcome)).apply(this, arguments));
}
_createClass(Welcome, [{
key: 'render',
value: function render() {
return _react2.default.createElement(
'div',
{ className: 'welcome inner' },
_react2.default.createElement(
'h1',
null,
'Calorie Counter'
),
_react2.default.createElement(
'button',
{ onClick: this.props.onLoginClick },
'Log In'
),
_react2.default.createElement(
'button',
{ onClick: this.props.onSignupClick },
'Sign Up'
)
);
}
}]);
return Welcome;
}(_react2.default.Component);
var LoginForm = function (_React$Component3) {
_inherits(LoginForm, _React$Component3);
function LoginForm() {
_classCallCheck(this, LoginForm);
var _this3 = _possibleConstructorReturn(this, (LoginForm.__proto__ || Object.getPrototypeOf(LoginForm)).call(this));
_this3.state = {
email: '',
password: '',
error: null
};
_this3.updateState = _this3.updateState.bind(_this3);
_this3.handleSubmit = _this3.handleSubmit.bind(_this3);
return _this3;
}
_createClass(LoginForm, [{
key: 'updateState',
value: function updateState(event) {
var _setState;
var name = event.target.name;
var value = event.target.value;
this.setState((_setState = {}, _defineProperty(_setState, name, value), _defineProperty(_setState, 'error', null), _setState));
}
}, {
key: 'handleSubmit',
value: function handleSubmit(event) {
var _this4 = this;
event.preventDefault();
_client2.default.authenticate({
type: 'local',
email: this.state.email,
password: this.state.password
}).then(function (res) {
console.log('Authenticated!', res);
_this4.props.didAuthenticate(res.data);
}).catch(function (error) {
console.error('Error authenticating!', error);
_this4.setState({
error: error.toString()
});
});
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
_ModalDialog2.default,
{ visible: this.props.visible, onClose: this.props.onClose },
_react2.default.createElement(
'form',
{ onSubmit: this.handleSubmit },
_react2.default.createElement('input', { type: 'email',
name: 'email',
autoFocus: true,
placeholder: 'Email address',
onChange: this.updateState
}),
_react2.default.createElement('br', null),
_react2.default.createElement('input', { type: 'password',
name: 'password',
placeholder: 'Password',
onChange: this.updateState
}),
_react2.default.createElement('br', null),
_react2.default.createElement('input', { type: 'submit',
value: 'Log In'
}),
_react2.default.createElement(
'div',
{ className: 'error' },
this.state.error
)
)
);
}
}]);
return LoginForm;
}(_react2.default.Component);
var SignupForm = function (_React$Component4) {
_inherits(SignupForm, _React$Component4);
function SignupForm() {
_classCallCheck(this, SignupForm);
var _this5 = _possibleConstructorReturn(this, (SignupForm.__proto__ || Object.getPrototypeOf(SignupForm)).call(this));
_this5.state = {
email: '',
password: '',
goal: 0,
error: null
};
_this5.updateState = _this5.updateState.bind(_this5);
_this5.handleSubmit = _this5.handleSubmit.bind(_this5);
return _this5;
}
_createClass(SignupForm, [{
key: 'updateState',
value: function updateState(event) {
var _setState2;
var name = event.target.name;
var value = event.target.value;
this.setState((_setState2 = {}, _defineProperty(_setState2, name, value), _defineProperty(_setState2, 'error', null), _setState2));
}
}, {
key: 'handleSubmit',
value: function handleSubmit(event) {
var _this6 = this;
event.preventDefault();
var usersService = _client2.default.service('users');
usersService.create(this.state).then(function (result) {
console.log(result);
return _client2.default.authenticate({
type: 'local',
email: _this6.state.email,
password: _this6.state.password
});
}).then(function (res) {
console.log('Authenticated!', res);
_this6.props.didAuthenticate(res.data);
}).catch(function (error) {
console.error('Error authenticating!', error);
_this6.setState({
error: error.toString()
});
});
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(
_ModalDialog2.default,
{ visible: this.props.visible, onClose: this.props.onClose },
_react2.default.createElement(
'form',
{ onSubmit: this.handleSubmit },
_react2.default.createElement('input', { type: 'email',
name: 'email',
autoFocus: true,
placeholder: 'Email address',
onChange: this.updateState
}),
_react2.default.createElement('br', null),
_react2.default.createElement('input', { type: 'password',
name: 'password',
placeholder: 'Password',
onChange: this.updateState
}),
_react2.default.createElement('br', null),
_react2.default.createElement('input', { type: 'number',
name: 'goal',
min: '0',
max: '100000',
placeholder: 'Goal',
onChange: this.updateState
}),
_react2.default.createElement('br', null),
_react2.default.createElement('input', { type: 'submit',
value: 'Sign Up'
}),
_react2.default.createElement(
'div',
{ className: 'error' },
this.state.error
)
)
);
}
}]);
return SignupForm;
}(_react2.default.Component);
/***/ }),
/* 98 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _react = __webpack_require__(14);
var _react2 = _interopRequireDefault(_react);
var _reactDateRange = __webpack_require__(363);
var _moment = __webpack_require__(237);
var _moment2 = _interopRequireDefault(_moment);
var _client = __webpack_require__(22);
var _client2 = _interopRequireDefault(_client);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var MealFilter = function (_React$Component) {
_inherits(MealFilter, _React$Component);
function MealFilter() {
_classCallCheck(this, MealFilter);
var _this = _possibleConstructorReturn(this, (MealFilter.__proto__ || Object.getPrototypeOf(MealFilter)).call(this));
var start = new Date();
start.setHours(0);
start.setMinutes(0);
start.setSeconds(0);
start.setDate(start.getDate() - 6);
var end = new Date();
end.setHours(23);
end.setMinutes(59);
end.setSeconds(59);
_this.state = {
startDate: (0, _moment2.default)(start),
endDate: (0, _moment2.default)(end),
startTime: 0,
endTime: 23,
meals: []
};
_this.handleSelect = _this.handleSelect.bind(_this);
_this.fetch = _this.fetch.bind(_this);
_this.filter = _this.filter.bind(_this);
return _this;
}
_createClass(MealFilter, [{
key: 'fetch',
value: function fetch(state) {
var _this2 = this;
state = state || this.state;
var start = state.startDate;
var end = state.endDate;
_client2.default.service('meals').find({
query: {
userid: this.props.user.id,
date: { $gte: start.toDate(), $lte: end.toDate() },
$sort: { 'date': '-1' },
token: _client2.default.get('token')
}
}).then(function (data) {
_this2.setState({ meals: data.data });
_this2.filter(data.data);
}).catch(function (error) {
console.error(error);
});
}
}, {
key: 'filter',
value: function filter(meals, state) {
meals = meals || this.state.meals;
state = state || this.state;
var start = state.startTime;
var end = state.endTime;
var filteredMeals = this.state.meals.filter(function (meal) {
var hours = new Date(meal.date).getHours();
return start <= hours && hours <= end;
});
this.props.onChange(filteredMeals);
}
}, {
key: 'handleSelect',
value: function handleSelect(range) {
var start = range.startDate;
start.hours(0);
start.minutes(0);
start.seconds(0);
var end = start.isSame(range.endDate) ? start.clone() : range.endDate;
end.hours(23);
end.minutes(59);
end.seconds(59);
this.setState({
startDate: start,
endDate: end
});
this.fetch({
startDate: start,
endDate: end
});
}
}, {
key: 'pickTimeRange',
value: function pickTimeRange(event, start, end) {
this.setState({ startTime: start, endTime: end });
this.filter(this.state.meals, { startTime: start, endTime: end });
}
}, {
key: 'render',
value: function render() {
var _this3 = this;
var times = [[0, 11, 'Breakfast'], [12, 15, 'Lunch'], [16, 23, 'Dinner'], [0, 23, 'All']].map(function (r, i) {
var start = r[0];
var end = r[1];
var name = r[2];
var className = '';
if (_this3.state.startTime === start && _this3.state.endTime === end) {
className = 'selected';
}
return _react2.default.createElement(
'button',
{
key: i,
className: className,
onClick: function onClick(e) {
_this3.pickTimeRange(e, start, end);
} },
name
);
});
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(_reactDateRange.DateRange, {
onInit: this.handleSelect,
onChange: this.handleSelect,
startDate: this.state.startDate,
endDate: this.state.endDate
}),
times
);
}
}]);
return MealFilter;
}(_react2.default.Component);
exports.default = MealFilter;
/***/ }),
/* 99 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _react = __webpack_require__(14);
var _react2 = _interopRequireDefault(_react);
var _MealFilter = __webpack_require__(98);
var _MealFilter2 = _interopRequireDefault(_MealFilter);
var _client = __webpack_require__(22);
var _client2 = _interopRequireDefault(_client);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var MealList = function (_React$Component) {
_inherits(MealList, _React$Component);
function MealList(props) {
_classCallCheck(this, MealList);
var _this = _possibleConstructorReturn(this, (MealList.__proto__ || Object.getPrototypeOf(MealList)).call(this));
_this.state = {
total: 0,
limit: 0,
skip: 0,
data: []
};
_this.handleCreate = _this.handleCreate.bind(_this);
_this.handleUpdate = _this.handleUpdate.bind(_this);
_this.handleDelete = _this.handleDelete.bind(_this);
_this.pickMeal = _this.pickMeal.bind(_this);
_this.loadMeals = _this.loadMeals.bind(_this);
return _this;
}
_createClass(MealList, [{
key: 'handleCreate',
value: function handleCreate(meal) {
var meals = this.state.data.slice();
meals.unshift(meal);
this.setState({
data: meals.sort(sortByDate)
});
}
}, {
key: 'handleUpdate',
value: function handleUpdate(meal) {
var meals = this.state.data.map(function (data) {
return data.id === meal.id ? meal : data;
}).sort(sortByDate);
this.setState({
data: meals
});
}
}, {
key: 'handleDelete',
value: function handleDelete(mealid) {
var meals = this.state.data.filter(function (data) {
return data.id !== mealid;
}).sort(sortByDate);
this.setState({
data: meals
});
}
}, {
key: 'pickMeal',
value: function pickMeal(meal) {
this.mealForm.pick(meal);
}
}, {
key: 'loadMeals',
value: function loadMeals(meals) {
this.setState({ data: meals });
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var canEdit = canEditUserMeals(this.props.currentUser, this.props.user);
var groups = groupByDate(this.state.data);
var items = Object.keys(groups).sort().reverse().map(function (date) {
var group = groups[date];
var mealitems = group.meals.map(function (meal) {
return _react2.default.createElement(MealItem, {
key: meal.id,
meal: meal,
canEdit: canEdit,
onClick: _this2.pickMeal,
onDelete: _this2.handleDelete });
});
var isOverLimit = group.calories > _this2.props.user.goal ? 'isOverLimit' : 'isUnderLimit';
return _react2.default.createElement(
'div',
{ key: group.date, className: 'group' },
_react2.default.createElement(
'span',
{ className: 'groupDate' },
group.date
),
_react2.default.createElement(
'span',
{ className: 'calories ' + isOverLimit },
group.calories,
' cal'
),
_react2.default.createElement('br', null),
mealitems
);
});
if (!items.length) {
items.push(_react2.default.createElement(
'div',
{ className: 'quiet', key: 'nomeals' },
'No meals found'
));
}
return _react2.default.createElement(
'div',
null,
_react2.default.createElement(MealForm, { user: this.props.user,
currentUser: this.props.currentUser,
ref: function ref(mealForm) {
_this2.mealForm = mealForm;
},
onCreate: function onCreate(meal) {
_this2.handleCreate(meal);
},
onUpdate: function onUpdate(meal) {
_this2.handleUpdate(meal);
}
}),
_react2.default.createElement(_MealFilter2.default, { user: this.props.user,
ref: function ref(mealFilter) {
_this2.mealFilter = mealFilter;
},
onChange: this.loadMeals
}),
_react2.default.createElement(
'div',
null,
items
)
);
}
}]);
return MealList;
}(_react2.default.Component);
exports.default = MealList;
var MealItem = function (_React$Component2) {
_inherits(MealItem, _React$Component2);
function MealItem() {
_classCallCheck(this, MealItem);
var _this3 = _possibleConstructorReturn(this, (MealItem.__proto__ || Object.getPrototypeOf(MealItem)).call(this));
_this3.handleClick = _this3.handleClick.bind(_this3);
_this3.remove = _this3.remove.bind(_this3);
return _this3;
}
_createClass(MealItem, [{
key: 'handleClick',
value: function handleClick() {
if (this.props.canEdit) {
this.props.onClick(this.props.meal);
}
}
}, {
key: 'remove',
value: function remove(e) {
var _this4 = this;
e.stopPropagation();
var mealid = this.props.meal.id;
var mealsService = _client2.default.service('meals');
var params = { query: { token: _client2.default.get('token') } };
mealsService.remove(mealid, params).then(function (result) {
_this4.props.onDelete(mealid);
}).catch(function (error) {
console.error(error);
});
}
}, {
key: 'render',
value: function render() {
var meal = this.props.meal;
// const canEdit = this.props.meal.userid === this.props.currentUser.id ? 'canEdit' : ''
var canEdit = this.props.canEdit ? 'canEdit' : '';
var date = parseDate(meal.date);
var time = parseTime(meal.date);
return _react2.default.createElement(
'div',
{ className: 'meal row ' + canEdit, onClick: this.handleClick },
_react2.default.createElement(
'div',
{ className: 'name' },
meal.name
),
_react2.default.createElement(
'div',
{ className: 'calories' },
meal.calories,
' cal'
),
_react2.default.createElement(
'div',
{ className: 'date' },
date
),
_react2.default.createElement(
'div',
{ className: 'time' },
time
),
_react2.default.createElement(
'div',
{ className: 'remove', onClick: this.remove },
'x'
)
);
}
}]);
return MealItem;
}(_react2.default.Component);
var MealForm = function (_React$Component3) {
_inherits(MealForm, _React$Component3);
function MealForm(props) {
_classCallCheck(this, MealForm);
var _this5 = _possibleConstructorReturn(this, (MealForm.__proto__ || Object.getPrototypeOf(MealForm)).call(this));
_this5.state = {
id: '',
userid: props.user.id,
name: '',
calories: '',
date: new Date()
};
_this5.updateState = _this5.updateState.bind(_this5);
_this5.handleSubmit = _this5.handleSubmit.bind(_this5);
return _this5;
}
_createClass(MealForm, [{
key: 'reset',
value: function reset() {
this.setState({
id: '',
name: '',
calories: '',
date: new Date()
});
}
}, {
key: 'pick',
value: function pick(meal) {
this.setState(meal);
}
}, {
key: 'updateState',
value: function updateState(event) {
var _setState;
var name = event.target.name;
var value = event.target.value;
if (name === 'date') {
value = new Date(value + 'T' + this.state.date.split("T")[1]).toString();
} else if (name === 'time') {
value = new Date(this.state.date.split("T")[0] + value).toString();
} else if (name === 'calories') {
value = parseInt(value);
}
this.setState((_setState = {}, _defineProperty(_setState, name, value), _defineProperty(_setState, 'error', null), _setState));
}
}, {
key: 'handleSubmit',
value: function handleSubmit(event) {
event.preventDefault();
var id = this.state.id;
if (!id) {
this.create();
} else {
this.update();
}
}
}, {
key: 'create',
value: function create() {
var _this6 = this;
var mealsService = _client2.default.service('meals');
var params = { query: { token: _client2.default.get('token') } };
mealsService.create(this.state, params).then(function (result) {
_this6.props.onCreate(result);
_this6.reset();
}).catch(function (error) {
console.error(error);
_this6.setState({
error: error.toString()
});
});
}
}, {
key: 'update',
value: function update() {
var _this7 = this;
var mealsService = _client2.default.service('meals');
var params = { query: { token: _client2.default.get('token') } };
mealsService.update(this.state.id, this.state, params).then(function (result) {
_this7.props.onUpdate(result);
_this7.reset();
}).catch(function (error) {
console.error(error);
_this7.setState({
error: error.toString()
});
});
}
}, {
key: 'render',
value: function render() {
var _this8 = this;
var id = this.state.id;
var action = id ? 'update' : 'create';
var canEdit = canEditUserMeals(this.props.currentUser, this.props.user);
if (!canEdit) {
return _react2.default.createElement('div', null);
}
var date = parseDate(this.state.date);
var time = parseTime(this.state.date);
return _react2.default.createElement(
'form',
{ onSubmit: this.handleSubmit, className: action },
_react2.default.createElement('input', { type: 'hidden', name: 'id', value: this.state.id, readOnly: true }),
_react2.default.createElement('input', { type: 'hidden', name: 'userid', value: this.state.userid, readOnly: true }),
_react2.default.createElement('input', { type: 'text', name: 'name', placeholder: 'Name', value: this.state.name, required: true, onChange: this.updateState }),
_react2.default.createElement('input', { type: 'number', name: 'calories', placeholder: 'Calories', value: this.state.calories, required: true, onChange: this.updateState, min: '0', max: '10000' }),
_react2.default.createElement('input', { type: 'date', name: 'date', placeholder: 'Date', value: date, required: true, onChange: this.updateState }),
_react2.default.createElement('input', { type: 'time', name: 'time', placeholder: 'Time', value: time, required: true, onChange: this.updateState, step: '60' }),
_react2.default.createElement('input', { type: 'submit', value: capitalize(action) }),
_react2.default.createElement(
'span',
{ className: 'clear', onClick: function onClick() {
return _this8.reset();
} },
'cancel'
),
_react2.default.createElement(
'div',
{ className: 'error' },
this.state.error
)
);
}
}]);
return MealForm;
}(_react2.default.Component);
function canEditUserMeals(currentUser, user) {
var isValidRole = currentUser.role === 'admin';
return user.id == currentUser.id || isValidRole;
}
function groupByDate(a) {
return a.reduce(function (rv, x) {
var date = parseDate(x.date);
var ab = rv[date] = rv[date] || { date: date, calories: 0, meals: [] };
ab.meals.push(x);
ab.calories += x.calories;
return rv;
}, {});
}
function sortByDate(a, b) {
return new Date(b.date) - new Date(a.date);
}
function parseDate(d) {
return new Date(d).toISOString().substr(0, 10);
}
function parseTime(d) {
return new Date(d).toISOString().substr(11, 5);
}
function capitalize(s) {
s = s || '';
return (s[0] || '').toUpperCase() + s.substr(1);
}
/***/ }),
/* 100 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _react = __webpack_require__(14);
var _react2 = _interopRequireDefault(_react);
var _client = __webpack_require__(22);
var _client2 = _interopRequireDefault(_client);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var UserList = function (_React$Component) {
_inherits(UserList, _React$Component);
function UserList(props) {
_classCallCheck(this, UserList);
var _this = _possibleConstructorReturn(this, (UserList.__proto__ || Object.getPrototypeOf(UserList)).call(this));
console.log("USER");
_this.state = {
data: []
};
_client2.default.service('users').find({
query: {
'$sort': { 'email': '1' },
token: _client2.default.get('token')
}
}).then(function (data) {
_this.setState(data);
}).catch(function (error) {
console.error(error);
});
_this.pick.bind(_this);
_this.handleDelete.bind(_this);
return _this;
}
_createClass(UserList, [{
key: 'pick',
value: function pick(user) {
// bubble this up..
console.log(user);
console.log(this);
this.props.updateUser(user);
}
}, {
key: 'handleDelete',
value: function handleDelete(userid) {
var users = this.state.data.filter(function (data) {
return data.id !== userid;
});
this.setState({
data: users
});
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
console.log(this.state.data);
var items = this.state.data.map(function (user, i) {
return _react2.default.createElement(UserItem, { key: user.id,
user: user,
activeUser: _this2.props.user,
onClick: function onClick(user) {
return _this2.pick(user);
},
onDelete: function onDelete(userid) {
return _this2.handleDelete(userid);
} });
});
return _react2.default.createElement(
'div',
null,
items
);
}
}]);
return UserList;
}(_react2.default.Component);
exports.default = UserList;
var UserItem = function (_React$Component2) {
_inherits(UserItem, _React$Component2);
function UserItem() {
_classCallCheck(this, UserItem);
var _this3 = _possibleConstructorReturn(this, (UserItem.__proto__ || Object.getPrototypeOf(UserItem)).call(this));
_this3.remove = _this3.remove.bind(_this3);
return _this3;
}
_createClass(UserItem, [{
key: 'remove',
value: function remove(e) {
var _this4 = this;
e.stopPropagation();
var userid = this.props.user.id;
var usersService = _client2.default.service('users');
var params = { query: { token: _client2.default.get('token') } };
usersService.remove(userid, params).then(function (result) {
_this4.props.onDelete(userid);
}).catch(function (error) {
console.error(error);
});
}
}, {
key: 'render',
value: function render() {
var _this5 = this;
var user = this.props.user;
// const canEdit = this.props.user.userid === this.props.currentUser.id ? 'canEdit' : ''
var userClass = this.props.user.id == this.props.activeUser.id ? 'active' : '';
var canEdit = 'canEdit';
var date = parseDate(user.updatedAt);
var time = parseTime(user.updatedAt);
return _react2.default.createElement(
'div',
{ className: 'user row ' + canEdit, onClick: function onClick() {
return _this5.props.onClick(_this5.props.user);
} },
_react2.default.createElement(
'div',
{ className: 'email ' + userClass },
user.email
),
_react2.default.createElement(
'div',
{ className: 'calories' },
user.goal,
' cal'
),
_react2.default.createElement(
'div',
{ className: 'role ' + user.role },
user.role
),
_react2.default.createElement(
'div',
{ className: 'date' },
date
),
_react2.default.createElement(
'div',
{ className: 'time' },
time
),
_react2.default.createElement(
'div',
{ className: 'remove', onClick: this.remove },
'x'
)
);
}
}]);
return UserItem;
}(_react2.default.Component);
function parseDate(d) {
return new Date(d).toISOString().substr(0, 10);
}
function parseTime(d) {
return new Date(d).toISOString().substr(11, 5);
}
/***/ }),
/* 101 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Expose `Emitter`.
*/
if (true) {
module.exports = Emitter;
}
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks['$' + event];
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
/***/ }),
/* 102 */
/***/ (function(module, exports, __webpack_require__) {
/**
* This is the common logic for both the Node.js and web browser
* implementations of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
exports.coerce = coerce;
exports.disable = disable;
exports.enable = enable;
exports.enabled = enabled;
exports.humanize = __webpack_require__(142);
/**
* The currently active debug mode names, and names to skip.
*/
exports.names = [];
exports.skips = [];
/**
* Map of special "%n" handling functions, for the debug "format" argument.
*
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
*/
exports.formatters = {};
/**
* Previous log timestamp.
*/
var prevTime;
/**
* Select a color.
* @param {String} namespace
* @return {Number}
* @api private
*/
function selectColor(namespace) {
var hash = 0, i;
for (i in namespace) {
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
hash |= 0; // Convert to 32bit integer
}
return exports.colors[Math.abs(hash) % exports.colors.length];
}
/**
* Create a debugger with the given `namespace`.
*
* @param {String} namespace
* @return {Function}
* @api public
*/
function createDebug(namespace) {
function debug() {
// disabled?
if (!debug.enabled) return;
var self = debug;
// set `diff` timestamp
var curr = +new Date();
var ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
// turn the `arguments` into a proper Array
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
args[0] = exports.coerce(args[0]);
if ('string' !== typeof args[0]) {
// anything else let's inspect with %O
args.unshift('%O');
}
// apply any `formatters` transformations
var index = 0;
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
// if we encounter an escaped % then don't increase the array index
if (match === '%%') return match;
index++;
var formatter = exports.formatters[format];
if ('function' === typeof formatter) {
var val = args[index];
match = formatter.call(self, val);
// now we need to remove `args[index]` since it's inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
// apply env-specific formatting (colors, etc.)
exports.formatArgs.call(self, args);
var logFn = debug.log || exports.log || console.log.bind(console);
logFn.apply(self, args);
}
debug.namespace = namespace;
debug.enabled = exports.enabled(namespace);
debug.useColors = exports.useColors();
debug.color = selectColor(namespace);
// env-specific initialization logic for debug instances
if ('function' === typeof exports.init) {
exports.init(debug);
}
return debug;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*
* @param {String} namespaces
* @api public
*/
function enable(namespaces) {
exports.save(namespaces);
exports.names = [];
exports.skips = [];
var split = (namespaces || '').split(/[\s,]+/);
var len = split.length;
for (var i = 0; i < len; i++) {
if (!split[i]) continue; // ignore empty strings
namespaces = split[i].replace(/\*/g, '.*?');
if (namespaces[0] === '-') {
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
} else {
exports.names.push(new RegExp('^' + namespaces + '$'));
}
}
}
/**
* Disable debug output.
*
* @api public
*/
function disable() {
exports.enable('');
}
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
function enabled(name) {
var i, len;
for (i = 0, len = exports.skips.length; i < len; i++) {
if (exports.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = exports.names.length; i < len; i++) {
if (exports.names[i].test(name)) {
return true;
}
}
return false;
}
/**
* Coerce `val`.
*
* @param {Mixed} val
* @return {Mixed}
* @api private
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
/***/ }),
/* 103 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
var _hyphenPattern = /-(.)/g;
/**
* Camelcases a hyphenated string, for example:
*
* > camelize('background-color')
* < "backgroundColor"
*
* @param {string} string
* @return {string}
*/
function camelize(string) {
return string.replace(_hyphenPattern, function (_, character) {
return character.toUpperCase();
});
}
module.exports = camelize;
/***/ }),
/* 104 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
var camelize = __webpack_require__(103);
var msPattern = /^-ms-/;
/**
* Camelcases a hyphenated CSS property name, for example:
*
* > camelizeStyleName('background-color')
* < "backgroundColor"
* > camelizeStyleName('-moz-transition')
* < "MozTransition"
* > camelizeStyleName('-ms-transition')
* < "msTransition"
*
* As Andi Smith suggests
* (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
* is converted to lowercase `ms`.
*
* @param {string} string
* @return {string}
*/
function camelizeStyleName(string) {
return camelize(string.replace(msPattern, 'ms-'));
}
module.exports = camelizeStyleName;
/***/ }),
/* 105 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
var isTextNode = __webpack_require__(113);
/*eslint-disable no-bitwise */
/**
* Checks if a given DOM node contains or is another DOM node.
*/
function containsNode(outerNode, innerNode) {
if (!outerNode || !innerNode) {
return false;
} else if (outerNode === innerNode) {
return true;
} else if (isTextNode(outerNode)) {
return false;
} else if (isTextNode(innerNode)) {
return containsNode(outerNode, innerNode.parentNode);
} else if ('contains' in outerNode) {
return outerNode.contains(innerNode);
} else if (outerNode.compareDocumentPosition) {
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
} else {
return false;
}
}
module.exports = containsNode;
/***/ }),
/* 106 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
var invariant = __webpack_require__(1);
/**
* Convert array-like objects to arrays.
*
* This API assumes the caller knows the contents of the data type. For less
* well defined inputs use createArrayFromMixed.
*
* @param {object|function|filelist} obj
* @return {array}
*/
function toArray(obj) {
var length = obj.length;
// Some browsers builtin objects can report typeof 'function' (e.g. NodeList
// in old versions of Safari).
!(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0;
!(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0;
!(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0;
!(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0;
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
// without method will throw during the slice call and skip straight to the
// fallback.
if (obj.hasOwnProperty) {
try {
return Array.prototype.slice.call(obj);
} catch (e) {
// IE < 9 does not support Array#slice on collections objects
}
}
// Fall back to copying key by key. This assumes all keys have a value,
// so will not preserve sparsely populated inputs.
var ret = Array(length);
for (var ii = 0; ii < length; ii++) {
ret[ii] = obj[ii];
}
return ret;
}
/**
* Perform a heuristic test to determine if an object is "array-like".
*
* A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
* Joshu replied: "Mu."
*
* This function determines if its argument has "array nature": it returns
* true if the argument is an actual array, an `arguments' object, or an
* HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
*
* It will return false for other array-like objects like Filelist.
*
* @param {*} obj
* @return {boolean}
*/
function hasArrayNature(obj) {
return (
// not null/false
!!obj && (
// arrays are objects, NodeLists are functions in Safari
typeof obj == 'object' || typeof obj == 'function') &&
// quacks like an array
'length' in obj &&
// not window
!('setInterval' in obj) &&
// no DOM node should be considered an array-like
// a 'select' element has 'length' and 'item' properties on IE8
typeof obj.nodeType != 'number' && (
// a real array
Array.isArray(obj) ||
// arguments
'callee' in obj ||
// HTMLCollection/NodeList
'item' in obj)
);
}
/**
* Ensure that the argument is an array by wrapping it in an array if it is not.
* Creates a copy of the argument if it is already an array.
*
* This is mostly useful idiomatically:
*
* var createArrayFromMixed = require('createArrayFromMixed');
*
* function takesOneOrMoreThings(things) {
* things = createArrayFromMixed(things);
* ...
* }
*
* This allows you to treat `things' as an array, but accept scalars in the API.
*
* If you need to convert an array-like object, like `arguments`, into an array
* use toArray instead.
*
* @param {*} obj
* @return {array}
*/
function createArrayFromMixed(obj) {
if (!hasArrayNature(obj)) {
return [obj];
} else if (Array.isArray(obj)) {
return obj.slice();
} else {
return toArray(obj);
}
}
module.exports = createArrayFromMixed;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 107 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @typechecks
*/
/*eslint-disable fb-www/unsafe-html*/
var ExecutionEnvironment = __webpack_require__(6);
var createArrayFromMixed = __webpack_require__(106);
var getMarkupWrap = __webpack_require__(108);
var invariant = __webpack_require__(1);
/**
* Dummy container used to render all markup.
*/
var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
/**
* Pattern used by `getNodeName`.
*/
var nodeNamePattern = /^\s*<(\w+)/;
/**
* Extracts the `nodeName` of the first element in a string of markup.
*
* @param {string} markup String of markup.
* @return {?string} Node name of the supplied markup.
*/
function getNodeName(markup) {
var nodeNameMatch = markup.match(nodeNamePattern);
return nodeNameMatch && nodeNameMatch[1].toLowerCase();
}
/**
* Creates an array containing the nodes rendered from the supplied markup. The
* optionally supplied `handleScript` function will be invoked once for each
*