(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react"), require("tether"), require("moment"), require("react-onclickoutside")); else if(typeof define === 'function' && define.amd) define(["react", "tether", "moment", "react-onclickoutside"], factory); else if(typeof exports === 'object') exports["DatePicker"] = factory(require("react"), require("tether"), require("moment"), require("react-onclickoutside")); else root["DatePicker"] = factory(root["React"], root["Tether"], root["moment"], root["OnClickOutside"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_147__, __WEBPACK_EXTERNAL_MODULE_151__, __WEBPACK_EXTERNAL_MODULE_203__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { "use strict"; var React = __webpack_require__(1); var Popover = __webpack_require__(2); var DateUtil = __webpack_require__(148); var Calendar = __webpack_require__(149); var DateInput = __webpack_require__(204); var moment = __webpack_require__(151); var isEqual = __webpack_require__(205); var DatePicker = React.createClass({ displayName: "DatePicker", propTypes: { weekdays: React.PropTypes.arrayOf(React.PropTypes.string), locale: React.PropTypes.string, dateFormatCalendar: React.PropTypes.string, popoverAttachment: React.PropTypes.string, popoverTargetAttachment: React.PropTypes.string, popoverTargetOffset: React.PropTypes.string, weekStart: React.PropTypes.string, onChange: React.PropTypes.func.isRequired, onBlur: React.PropTypes.func, onFocus: React.PropTypes.func }, getDefaultProps: function getDefaultProps() { return { weekdays: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], locale: "en", dateFormatCalendar: "MMMM YYYY", moment: moment, onChange: function onChange() {}, disabled: false, onFocus: function onFocus() {} }; }, getInitialState: function getInitialState() { return { focus: false, virtualFocus: false, selected: this.props.selected }; }, componentWillReceiveProps: function componentWillReceiveProps(nextProps) { this.setState({ selected: nextProps.selected }); }, shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { return !(isEqual(nextProps, this.props) && isEqual(nextState, this.state)); }, getValue: function getValue() { return this.state.selected; }, handleFocus: function handleFocus() { this.props.onFocus(); this.setState({ focus: true }); }, handleBlur: function handleBlur() { this.setState({ virtualFocus: false }, (function () { setTimeout((function () { if (!this.state.virtualFocus && typeof this.props.onBlur === "function") { this.props.onBlur(this.state.selected); this.hideCalendar(); } }).bind(this), 200); }).bind(this)); }, hideCalendar: function hideCalendar() { setTimeout((function () { this.setState({ focus: false }); }).bind(this), 0); }, handleSelect: function handleSelect(date) { this.setSelected(date); setTimeout((function () { this.hideCalendar(); }).bind(this), 200); }, setSelected: function setSelected(date) { this.setState({ selected: date.moment(), virtualFocus: true }, (function () { this.props.onChange(this.state.selected); }).bind(this)); }, clearSelected: function clearSelected() { if (this.state.selected === null) return; //Due to issues with IE onchange events sometimes this gets noisy, so skip if we've already cleared this.setState({ selected: null }, (function () { this.props.onChange(null); }).bind(this)); }, onInputClick: function onInputClick() { this.setState({ focus: true, virtualFocus: true }); }, calendar: function calendar() { if (this.state.focus) { return React.createElement( Popover, { attachment: this.props.popoverAttachment, targetAttachment: this.props.popoverTargetAttachment, targetOffset: this.props.popoverTargetOffset, constraints: this.props.tetherConstraints }, React.createElement(Calendar, { weekdays: this.props.weekdays, locale: this.props.locale, moment: this.props.moment, dateFormat: this.props.dateFormatCalendar, selected: this.state.selected, onSelect: this.handleSelect, hideCalendar: this.hideCalendar, minDate: this.props.minDate, maxDate: this.props.maxDate, excludeDates: this.props.excludeDates, weekStart: this.props.weekStart }) ); } }, render: function render() { var clearButton = null; if (this.props.isClearable && this.state.selected != null) { clearButton = React.createElement("a", { className: "close-icon", href: "#", onClick: this.clearSelected }); } return React.createElement( "div", { className: "datepicker__input-container" }, React.createElement(DateInput, { name: this.props.name, date: this.state.selected, dateFormat: this.props.dateFormat, focus: this.state.focus, onFocus: this.handleFocus, onBlur: this.handleBlur, handleClick: this.onInputClick, handleEnter: this.hideCalendar, setSelected: this.setSelected, clearSelected: this.clearSelected, hideCalendar: this.hideCalendar, placeholderText: this.props.placeholderText, disabled: this.props.disabled, className: this.props.className, title: this.props.title, readOnly: this.props.readOnly, required: this.props.required }), clearButton, this.props.disabled ? null : this.calendar() ); } }); module.exports = DatePicker; /***/ }, /* 1 */ /***/ function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_1__; /***/ }, /* 2 */ /***/ function(module, exports, __webpack_require__) { "use strict"; var React = __webpack_require__(1); var ReactDOM = __webpack_require__(3); var Popover = React.createClass({ displayName: "Popover", propTypes: { attachment: React.PropTypes.string, targetAttachment: React.PropTypes.string, targetOffset: React.PropTypes.string }, getDefaultProps: function getDefaultProps() { return { attachment: "top left", constraints: [{ to: "window", attachment: "together" }], targetAttachment: "bottom left", targetOffset: "10px 0" }; }, componentWillMount: function componentWillMount() { var popoverContainer = document.createElement("span"); popoverContainer.className = "datepicker__container"; this._popoverElement = popoverContainer; document.querySelector("body").appendChild(this._popoverElement); }, componentDidMount: function componentDidMount() { this._renderPopover(); }, componentDidUpdate: function componentDidUpdate() { this._renderPopover(); }, _popoverComponent: function _popoverComponent() { var className = this.props.className; return React.createElement( "div", { className: className }, this.props.children ); }, _tetherOptions: function _tetherOptions() { return { element: this._popoverElement, target: ReactDOM.findDOMNode(this).parentElement.querySelector("input"), attachment: this.props.attachment, targetAttachment: this.props.targetAttachment, targetOffset: this.props.targetOffset, optimizations: { moveElement: false // always moves to
anyway! }, constraints: this.props.constraints }; }, _renderPopover: function _renderPopover() { ReactDOM.render(this._popoverComponent(), this._popoverElement); if (this._tether != null) { this._tether.setOptions(this._tetherOptions()); } else if (window && document) { var Tether = __webpack_require__(147); this._tether = new Tether(this._tetherOptions()); } }, componentWillUnmount: function componentWillUnmount() { this._tether.destroy(); ReactDOM.unmountComponentAtNode(this._popoverElement); if (this._popoverElement.parentNode) { this._popoverElement.parentNode.removeChild(this._popoverElement); } }, render: function render() { return React.createElement("span", null); } }); module.exports = Popover; /***/ }, /* 3 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; module.exports = __webpack_require__(4); /***/ }, /* 4 */ /***/ function(module, exports, __webpack_require__) { /** * Copyright 2013-2015, 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. * * @providesModule ReactDOM */ /* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/ 'use strict'; var ReactCurrentOwner = __webpack_require__(5); var ReactDOMTextComponent = __webpack_require__(6); var ReactDefaultInjection = __webpack_require__(70); var ReactInstanceHandles = __webpack_require__(44); var ReactMount = __webpack_require__(28); var ReactPerf = __webpack_require__(18); var ReactReconciler = __webpack_require__(49); var ReactUpdates = __webpack_require__(53); var ReactVersion = __webpack_require__(145); var findDOMNode = __webpack_require__(90); var renderSubtreeIntoContainer = __webpack_require__(146); var warning = __webpack_require__(25); ReactDefaultInjection.inject(); var render = ReactPerf.measure('React', 'render', ReactMount.render); var React = { findDOMNode: findDOMNode, render: render, unmountComponentAtNode: ReactMount.unmountComponentAtNode, version: ReactVersion, /* eslint-disable camelcase */ unstable_batchedUpdates: ReactUpdates.batchedUpdates, unstable_renderSubtreeIntoContainer: renderSubtreeIntoContainer }; // Inject the runtime into a devtools global hook regardless of browser. // Allows for debugging when the hook is injected on the page. /* eslint-enable camelcase */ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') { __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ CurrentOwner: ReactCurrentOwner, InstanceHandles: ReactInstanceHandles, Mount: ReactMount, Reconciler: ReactReconciler, TextComponent: ReactDOMTextComponent }); } if ((undefined) !== 'production') { var ExecutionEnvironment = __webpack_require__(9); if (ExecutionEnvironment.canUseDOM && window.top === window.self) { // First check if devtools is not installed if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { // If we're in Chrome or Firefox, provide a download link if not installed. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) { console.debug('Download the React DevTools for a better development experience: ' + 'https://fb.me/react-devtools'); } } // If we're in IE8, check to see if we are in compatibility mode and provide // information on preventing compatibility mode var ieCompatibilityMode = document.documentMode && document.documentMode < 8; (undefined) !== 'production' ? warning(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '') : undefined; var expectedFeatures = [ // shims Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim, // shams Object.create, Object.freeze]; for (var i = 0; i < expectedFeatures.length; i++) { if (!expectedFeatures[i]) { console.error('One or more ES5 shim/shams expected by React are not available: ' + 'https://fb.me/react-warning-polyfills'); break; } } } } module.exports = React; /***/ }, /* 5 */ /***/ function(module, exports) { /** * Copyright 2013-2015, 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. * * @providesModule ReactCurrentOwner */ 'use strict'; /** * Keeps track of the current owner. * * The current owner is the component who should own any components that are * currently being constructed. */ var ReactCurrentOwner = { /** * @internal * @type {ReactComponent} */ current: null }; module.exports = ReactCurrentOwner; /***/ }, /* 6 */ /***/ function(module, exports, __webpack_require__) { /** * Copyright 2013-2015, 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. * * @providesModule ReactDOMTextComponent * @typechecks static-only */ 'use strict'; var DOMChildrenOperations = __webpack_require__(7); var DOMPropertyOperations = __webpack_require__(22); var ReactComponentBrowserEnvironment = __webpack_require__(26); var ReactMount = __webpack_require__(28); var assign = __webpack_require__(39); var escapeTextContentForBrowser = __webpack_require__(21); var setTextContent = __webpack_require__(20); var validateDOMNesting = __webpack_require__(69); /** * Text nodes violate a couple assumptions that React makes about components: * * - When mounting text into the DOM, adjacent text nodes are merged. * - Text nodes cannot be assigned a React root ID. * * This component is used to wrap strings in elements so that they can undergo * the same reconciliation that is applied to elements. * * TODO: Investigate representing React components in the DOM with text nodes. * * @class ReactDOMTextComponent * @extends ReactComponent * @internal */ var ReactDOMTextComponent = function (props) { // This constructor and its argument is currently used by mocks. }; assign(ReactDOMTextComponent.prototype, { /** * @param {ReactText} text * @internal */ construct: function (text) { // TODO: This is really a ReactText (ReactNode), not a ReactElement this._currentElement = text; this._stringText = '' + text; // Properties this._rootNodeID = null; this._mountIndex = 0; }, /** * Creates the markup for this text node. This node is not intended to have * any features besides containing text content. * * @param {string} rootID DOM ID of the root node. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction * @return {string} Markup for this text node. * @internal */ mountComponent: function (rootID, transaction, context) { if ((undefined) !== 'production') { if (context[validateDOMNesting.ancestorInfoContextKey]) { validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]); } } this._rootNodeID = rootID; if (transaction.useCreateElement) { var ownerDocument = context[ReactMount.ownerDocumentContextKey]; var el = ownerDocument.createElement('span'); DOMPropertyOperations.setAttributeForID(el, rootID); // Populate node cache ReactMount.getID(el); setTextContent(el, this._stringText); return el; } else { var escapedText = escapeTextContentForBrowser(this._stringText); if (transaction.renderToStaticMarkup) { // Normally we'd wrap this in a `span` for the reasons stated above, but // since this is a situation where React won't take over (static pages), // we can simply return the text as it is. return escapedText; } return '' + escapedText + ''; } }, /** * Updates this component by updating the text content. * * @param {ReactText} nextText The next text content * @param {ReactReconcileTransaction} transaction * @internal */ receiveComponent: function (nextText, transaction) { if (nextText !== this._currentElement) { this._currentElement = nextText; var nextStringText = '' + nextText; if (nextStringText !== this._stringText) { // TODO: Save this as pending props and use performUpdateIfNecessary // and/or updateComponent to do the actual update for consistency with // other component types? this._stringText = nextStringText; var node = ReactMount.getNode(this._rootNodeID); DOMChildrenOperations.updateTextContent(node, nextStringText); } } }, unmountComponent: function () { ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID); } }); module.exports = ReactDOMTextComponent; /***/ }, /* 7 */ /***/ function(module, exports, __webpack_require__) { /** * Copyright 2013-2015, 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. * * @providesModule DOMChildrenOperations * @typechecks static-only */ 'use strict'; var Danger = __webpack_require__(8); var ReactMultiChildUpdateTypes = __webpack_require__(16); var ReactPerf = __webpack_require__(18); var setInnerHTML = __webpack_require__(19); var setTextContent = __webpack_require__(20); var invariant = __webpack_require__(13); /** * Inserts `childNode` as a child of `parentNode` at the `index`. * * @param {DOMElement} parentNode Parent node in which to insert. * @param {DOMElement} childNode Child node to insert. * @param {number} index Index at which to insert the child. * @internal */ function insertChildAt(parentNode, childNode, index) { // By exploiting arrays returning `undefined` for an undefined index, we can // rely exclusively on `insertBefore(node, null)` instead of also using // `appendChild(node)`. However, using `undefined` is not allowed by all // browsers so we must replace it with `null`. // fix render order error in safari // IE8 will throw error when index out of list size. var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index); parentNode.insertBefore(childNode, beforeChild); } /** * Operations for updating with DOM children. */ var DOMChildrenOperations = { dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup, updateTextContent: setTextContent, /** * Updates a component's children by processing a series of updates. The * update configurations are each expected to have a `parentNode` property. * * @param {array