UNPKG

react-range-picker-fr

Version:

React Js based date/range picker. With this picker user can select date or range in the single calander not like other pickers which gives you two calander to pick start date and end date.

1,443 lines (1,172 loc) 135 kB
module.exports = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 6); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { module.exports = require("react"); /***/ }), /* 1 */ /***/ (function(module, exports) { /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ // css base code, injected by the css-loader module.exports = function(useSourceMap) { var list = []; // return the list of modules as css string list.toString = function toString() { return this.map(function (item) { var content = cssWithMappingToString(item, useSourceMap); if(item[2]) { return "@media " + item[2] + "{" + content + "}"; } else { return content; } }).join(""); }; // import a list of modules into the list list.i = function(modules, mediaQuery) { if(typeof modules === "string") modules = [[null, modules, ""]]; var alreadyImportedModules = {}; for(var i = 0; i < this.length; i++) { var id = this[i][0]; if(typeof id === "number") alreadyImportedModules[id] = true; } for(i = 0; i < modules.length; i++) { var item = modules[i]; // skip already imported module // this implementation is not 100% perfect for weird media query combinations // when a module is imported multiple times with different media queries. // I hope this will never occur (Hey this way we have smaller bundles) if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { if(mediaQuery && !item[2]) { item[2] = mediaQuery; } else if(mediaQuery) { item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; } list.push(item); } } }; return list; }; function cssWithMappingToString(item, useSourceMap) { var content = item[1] || ''; var cssMapping = item[3]; if (!cssMapping) { return content; } if (useSourceMap && typeof btoa === 'function') { var sourceMapping = toComment(cssMapping); var sourceURLs = cssMapping.sources.map(function (source) { return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' }); return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); } return [content].join('\n'); } // Adapted from convert-source-map (MIT) function toComment(sourceMap) { // eslint-disable-next-line no-undef var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; return '/*# ' + data + ' */'; } /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ var stylesInDom = {}; var memoize = function (fn) { var memo; return function () { if (typeof memo === "undefined") memo = fn.apply(this, arguments); return memo; }; }; var isOldIE = memoize(function () { // Test for IE <= 9 as proposed by Browserhacks // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805 // Tests for existence of standard globals is to allow style-loader // to operate correctly into non-standard environments // @see https://github.com/webpack-contrib/style-loader/issues/177 return window && document && document.all && !window.atob; }); var getElement = (function (fn) { var memo = {}; return function(selector) { if (typeof memo[selector] === "undefined") { var styleTarget = fn.call(this, selector); // Special case to return head of iframe instead of iframe itself if (styleTarget instanceof window.HTMLIFrameElement) { try { // This will throw an exception if access to iframe is blocked // due to cross-origin restrictions styleTarget = styleTarget.contentDocument.head; } catch(e) { styleTarget = null; } } memo[selector] = styleTarget; } return memo[selector] }; })(function (target) { return document.querySelector(target) }); var singleton = null; var singletonCounter = 0; var stylesInsertedAtTop = []; var fixUrls = __webpack_require__(11); module.exports = function(list, options) { if (typeof DEBUG !== "undefined" && DEBUG) { if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); } options = options || {}; options.attrs = typeof options.attrs === "object" ? options.attrs : {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style> // tags it will allow on a page if (!options.singleton) options.singleton = isOldIE(); // By default, add <style> tags to the <head> element if (!options.insertInto) options.insertInto = "head"; // By default, add <style> tags to the bottom of the target if (!options.insertAt) options.insertAt = "bottom"; var styles = listToStyles(list, options); addStylesToDom(styles, options); return function update (newList) { var mayRemove = []; for (var i = 0; i < styles.length; i++) { var item = styles[i]; var domStyle = stylesInDom[item.id]; domStyle.refs--; mayRemove.push(domStyle); } if(newList) { var newStyles = listToStyles(newList, options); addStylesToDom(newStyles, options); } for (var i = 0; i < mayRemove.length; i++) { var domStyle = mayRemove[i]; if(domStyle.refs === 0) { for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j](); delete stylesInDom[domStyle.id]; } } }; }; function addStylesToDom (styles, options) { for (var i = 0; i < styles.length; i++) { var item = styles[i]; var domStyle = stylesInDom[item.id]; if(domStyle) { domStyle.refs++; for(var j = 0; j < domStyle.parts.length; j++) { domStyle.parts[j](item.parts[j]); } for(; j < item.parts.length; j++) { domStyle.parts.push(addStyle(item.parts[j], options)); } } else { var parts = []; for(var j = 0; j < item.parts.length; j++) { parts.push(addStyle(item.parts[j], options)); } stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts}; } } } function listToStyles (list, options) { var styles = []; var newStyles = {}; for (var i = 0; i < list.length; i++) { var item = list[i]; var id = options.base ? item[0] + options.base : item[0]; var css = item[1]; var media = item[2]; var sourceMap = item[3]; var part = {css: css, media: media, sourceMap: sourceMap}; if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]}); else newStyles[id].parts.push(part); } return styles; } function insertStyleElement (options, style) { var target = getElement(options.insertInto) if (!target) { throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid."); } var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1]; if (options.insertAt === "top") { if (!lastStyleElementInsertedAtTop) { target.insertBefore(style, target.firstChild); } else if (lastStyleElementInsertedAtTop.nextSibling) { target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling); } else { target.appendChild(style); } stylesInsertedAtTop.push(style); } else if (options.insertAt === "bottom") { target.appendChild(style); } else if (typeof options.insertAt === "object" && options.insertAt.before) { var nextSibling = getElement(options.insertInto + " " + options.insertAt.before); target.insertBefore(style, nextSibling); } else { throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n"); } } function removeStyleElement (style) { if (style.parentNode === null) return false; style.parentNode.removeChild(style); var idx = stylesInsertedAtTop.indexOf(style); if(idx >= 0) { stylesInsertedAtTop.splice(idx, 1); } } function createStyleElement (options) { var style = document.createElement("style"); options.attrs.type = "text/css"; addAttrs(style, options.attrs); insertStyleElement(options, style); return style; } function createLinkElement (options) { var link = document.createElement("link"); options.attrs.type = "text/css"; options.attrs.rel = "stylesheet"; addAttrs(link, options.attrs); insertStyleElement(options, link); return link; } function addAttrs (el, attrs) { Object.keys(attrs).forEach(function (key) { el.setAttribute(key, attrs[key]); }); } function addStyle (obj, options) { var style, update, remove, result; // If a transform function was defined, run it on the css if (options.transform && obj.css) { result = options.transform(obj.css); if (result) { // If transform returns a value, use that instead of the original css. // This allows running runtime transformations on the css. obj.css = result; } else { // If the transform function returns a falsy value, don't add this css. // This allows conditional loading of css return function() { // noop }; } } if (options.singleton) { var styleIndex = singletonCounter++; style = singleton || (singleton = createStyleElement(options)); update = applyToSingletonTag.bind(null, style, styleIndex, false); remove = applyToSingletonTag.bind(null, style, styleIndex, true); } else if ( obj.sourceMap && typeof URL === "function" && typeof URL.createObjectURL === "function" && typeof URL.revokeObjectURL === "function" && typeof Blob === "function" && typeof btoa === "function" ) { style = createLinkElement(options); update = updateLink.bind(null, style, options); remove = function () { removeStyleElement(style); if(style.href) URL.revokeObjectURL(style.href); }; } else { style = createStyleElement(options); update = applyToTag.bind(null, style); remove = function () { removeStyleElement(style); }; } update(obj); return function updateStyle (newObj) { if (newObj) { if ( newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap ) { return; } update(obj = newObj); } else { remove(); } }; } var replaceText = (function () { var textStore = []; return function (index, replacement) { textStore[index] = replacement; return textStore.filter(Boolean).join('\n'); }; })(); function applyToSingletonTag (style, index, remove, obj) { var css = remove ? "" : obj.css; if (style.styleSheet) { style.styleSheet.cssText = replaceText(index, css); } else { var cssNode = document.createTextNode(css); var childNodes = style.childNodes; if (childNodes[index]) style.removeChild(childNodes[index]); if (childNodes.length) { style.insertBefore(cssNode, childNodes[index]); } else { style.appendChild(cssNode); } } } function applyToTag (style, obj) { var css = obj.css; var media = obj.media; if(media) { style.setAttribute("media", media) } if(style.styleSheet) { style.styleSheet.cssText = css; } else { while(style.firstChild) { style.removeChild(style.firstChild); } style.appendChild(document.createTextNode(css)); } } function updateLink (link, options, obj) { var css = obj.css; var sourceMap = obj.sourceMap; /* If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled and there is no publicPath defined then lets turn convertToAbsoluteUrls on by default. Otherwise default to the convertToAbsoluteUrls option directly */ var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap; if (options.convertToAbsoluteUrls || autoFixUrls) { css = fixUrls(css); } if (sourceMap) { // http://stackoverflow.com/a/26603875 css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */"; } var blob = new Blob([css], { type: "text/css" }); var oldSrc = link.href; link.href = URL.createObjectURL(blob); if(oldSrc) URL.revokeObjectURL(oldSrc); } /***/ }), /* 3 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getDays; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return getDaysArray; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return getNewMonthFrom; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return noHandler; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getCustomDateObject; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return getTime; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getActualDate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return dateToInt; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return formatDate; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_const__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__date_formators_js__ = __webpack_require__(12); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var getDays = function getDays(month, year) { // Month here is 1-indexed (January is 1, February is 2, etc). This is // because we're using 0 as the day so that it returns the last day // of the last month, so we add +1 to the month number // so it returns the correct amount of days if (typeof month !== 'number' || typeof year !== 'number') { var date = new Date(); month = date.getMonth(); year = date.getFullYear(); } return new Date(year, month + 1, 0).getDate(); }; var getDaysArray = function getDaysArray(_ref) { var month = _ref.month, year = _ref.year; var days = getDays(month, year); var daysArray = []; var i = 1; for (i; i <= days; i += 1) { daysArray.push(i); } return daysArray; }; var getNewMonthFrom = function getNewMonthFrom(from) { var months = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var newInstance = new Date(from); newInstance.setMonth(newInstance.getMonth() + months); newInstance.setDate(1); return newInstance; }; var noHandler = function noHandler(message) { return function () { return console.log(message); }; }; var getCustomDateObject = function getCustomDateObject() { var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date(); return { day: date.getDay(), date: date.getDate(), month: date.getMonth(), year: date.getFullYear() }; }; var getTime = function getTime(format) { var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date(); var tempHours = date.getHours(); var hours = format === 12 && tempHours > 12 ? tempHours - 12 : tempHours; var period = format === 12 ? tempHours > 12 ? 'PM' : 'AM' : ''; return { hours: hours, minutes: date.getMinutes(), period: period }; }; var getActualDate = function getActualDate() { var intDate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var timeObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12; var strDate = (intDate || '').toString(); var hours = void 0, minutes = void 0, period = void 0; if (!strDate || strDate.length !== 8) { return {}; } var year = parseInt(strDate.substring(0, 4), 10); var month = parseInt(strDate.substring(4, 6), 10); var date = parseInt(strDate.substring(6, 8), 10); var newDate = new Date(year, month, date); if (!timeObj) { var time = getTime(format); hours = time.hours; minutes = time.minutes; period = time.period; } else if ((typeof timeObj === 'undefined' ? 'undefined' : _typeof(timeObj)) === 'object') { hours = parseInt(timeObj.hours, 10); minutes = timeObj.minutes; period = '' + timeObj.period; var dateHours = 0; // format date to 24 hours for date object if (period === 'PM') { dateHours = hours < 12 ? hours + 12 : hours; } else { dateHours = hours === 12 ? 0 : hours; } newDate.setHours(dateHours); newDate.setMinutes(minutes); } return { _date: newDate, _intDate: intDate, customObject: { minutes: minutes, hours: hours, period: period, date: date, month: month, year: year, monthNameShort: __WEBPACK_IMPORTED_MODULE_0_const__["c" /* monthsShort */][month], monthNameFull: __WEBPACK_IMPORTED_MODULE_0_const__["b" /* monthsFull */][month], day: newDate.getDay() } }; }; var dateToInt = function dateToInt(date) { // make sure both month and day starts with 0 if single digit; var month = date.month < 10 ? '0' + date.month : date.month; var day = date.date < 10 ? '0' + date.date : date.date; return parseInt('' + date.year + month + day, 10); }; var formatDate = function formatDate(format) { var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date(); __WEBPACK_IMPORTED_MODULE_1__date_formators_js__["a" /* formators */].forEach(function (formator) { var _f = formator(format, date); format = _f || format; }); return format; }; /***/ }), /* 4 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Provider; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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 Context = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext({}); var Provider = function (_React$Component) { _inherits(Provider, _React$Component); function Provider() { var _ref; var _temp, _this, _ret; _classCallCheck(this, Provider); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Provider.__proto__ || Object.getPrototypeOf(Provider)).call.apply(_ref, [this].concat(args))), _this), _this.state = { today: new Date(), startDate: null, endDate: null, startTime: null, endTime: null }, _this.updateContext = function (partialState) { _this.setState(Object.assign({}, _this.state, partialState)); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(Provider, [{ key: 'render', value: function render() { return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( Context.Provider, { value: Object.assign({}, this.state, { updateContext: this.updateContext }) }, this.props.children ); } }]); return Provider; }(__WEBPACK_IMPORTED_MODULE_0_react___default.a.Component); /* harmony default export */ __webpack_exports__["b"] = (Context); /***/ }), /* 5 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return monthsFull; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return monthsShort; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return days; }); var monthsFull = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre']; var monthsShort = ['Janv.', 'Févr.', 'Mars', 'Avr.', 'Mai', 'Juin', 'Juil.', 'Août', 'Sept.', 'Oct.', 'Nov.', 'Déc.']; var days = [{ micro: 'D', short: 'Dim.', full: 'Dimanche' }, { micro: 'L', short: 'Lun.', full: 'Lundi' }, { micro: 'M', short: 'Mar.', full: 'Mardi' }, { micro: 'M', short: 'Mer.', full: 'Mercredi' }, { micro: 'J', short: 'Jeu.', full: 'Jeudi' }, { micro: 'V', short: 'Ven.', full: 'Vendredi' }, { micro: 'S', short: 'Sam.', full: 'Samedi' }]; /***/ }), /* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react_dom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react_dom__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__placeholder__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__calendar__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__context__ = __webpack_require__(4); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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; } /* apis ==> onDateSelected (function) - 'gets called when a date/range is selected and time selected', onClose (function) - 'when your pressed ok/select button in footer' disableRange (boolean) - 'if true user can select only one single' selectTime (boolean) - if true time picker will show up each time a date gets selected rangeTillEndOfDay (boolean) - if true end(last) date of range will have time of 11:59 PM(end of day) else it will have 12:00 selectTime(boolean) - show time picker if true after very date selection placeholder (function which return a React Component) - if user wants custom placeholder, placeholder function will recieve following object as param {startDate (date object), endDate (date object)} footer (function which return a React Component) - if user wants custom footer, footer will recieve following object as param {startDate (date object) endDate (date object) today (function) - to select today's date close (function) - closes the calendar and calls onClose API callback} */ var hiddenStyle = { top: '-150%' }; var RangePicker = function (_React$Component) { _inherits(RangePicker, _React$Component); function RangePicker(props) { _classCallCheck(this, RangePicker); var _this = _possibleConstructorReturn(this, (RangePicker.__proto__ || Object.getPrototypeOf(RangePicker)).call(this, props)); _this.calendar_ref = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createRef(); _this.popup_ref = __WEBPACK_IMPORTED_MODULE_0_react___default.a.createRef(); _this.isVisibilityControlled = false; _this.preventBubbling = function (e) { e.stopPropagation(); }; _this.handleOutsideClick = function () { var _this$props = _this.props, closeOnOutsideClick = _this$props.closeOnOutsideClick, onClose = _this$props.onClose; if (closeOnOutsideClick === false) { return; } var showCalendar = _this.state.showCalendar; // if calendar is hidden, return. if (!showCalendar) { return; } // if user clicked outside of the calendar then hide it _this.setState({ showCalendar: false }); onClose && onClose(); }; _this.calculateCalendarPosition = function (isVisible) { var current = _this.calendar_ref.current; if (!current || !isVisible) return hiddenStyle; var top = current.offsetTop; var left = current.offsetLeft; return { left: left, top: top }; }; _this.toggleCalendar = function () { var showCalendar = _this.state.showCalendar; var _this$props2 = _this.props, onOpen = _this$props2.onOpen, visible = _this$props2.visible; if (_this.isVisibilityControlled && !visible || !_this.isVisibilityControlled && !showCalendar) { onOpen && onOpen(); } if (_this.isVisibilityControlled) return; var style = _this.calculateCalendarPosition(!showCalendar); _this.setState({ showCalendar: !showCalendar, style: style }); }; _this.onClose = function () { var onClose = _this.props.onClose; _this.toggleCalendar(); onClose && onClose(); }; _this.onDateSelected = function (startDate, endDate) { var onDateSelected = _this.props.onDateSelected; var firstDate = startDate ? startDate._date : null; var lastDate = endDate ? endDate._date : null; onDateSelected && onDateSelected(firstDate, lastDate); }; _this.isVisibilityControlled = typeof props.visible === 'boolean'; _this.state = { showCalendar: false, style: hiddenStyle }; return _this; } _createClass(RangePicker, [{ key: 'componentDidMount', value: function componentDidMount() { var popup = this.popup_ref.current; window.addEventListener('mousedown', this.handleOutsideClick, false); popup && popup.addEventListener('mousedown', this.preventBubbling, false); // force upate as style in render function won't get calculated because "calendar_ref.current" was null // on componentDidMount "calendar_ref.current" will be available, so force rerender the component // to calulate the popup position if (this.isVisibilityControlled) { this.setState({}); } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { var popup = this.popup_ref.current; window.removeEventListener('mousedown', this.handleOutsideClick, false); popup && popup.removeEventListener('mousedown', this.preventBubbling, false); } }, { key: 'render', value: function render() { var showCalendar = this.state.showCalendar; var _props = this.props, placeholder = _props.placeholder, dateFormat = _props.dateFormat, placeholderText = _props.placeholderText; var visible = this.isVisibilityControlled ? this.props.visible === true : showCalendar; var style = this.calculateCalendarPosition(visible); return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( __WEBPACK_IMPORTED_MODULE_4__context__["a" /* Provider */], null, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'date-picker-app-wrapper', ref: this.calendar_ref }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'user-placeholder', onClick: this.toggleCalendar }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_2__placeholder__["a" /* default */], { customPlaceholder: placeholder, showTime: this.props.selectTime, placeholder: placeholderText, format: dateFormat }) ), PortalCreator(__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { style: style, className: 'calendar' + (visible ? ' visible' : ''), ref: this.popup_ref }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_3__calendar__["a" /* default */], Object.assign({}, this.props, { onDateSelected: this.onDateSelected, isVisible: visible, onClose: this.onClose })) )) ) ); } }]); return RangePicker; }(__WEBPACK_IMPORTED_MODULE_0_react___default.a.Component); var PortalCreator = function PortalCreator(child) { var container = document.getElementById('__range-picker-container'); if (!container) { container = document.createElement('div'); container.id = '__range-picker-container'; document.body.appendChild(container); } return __WEBPACK_IMPORTED_MODULE_1_react_dom___default.a.createPortal(child, container); }; /* harmony default export */ __webpack_exports__["default"] = (RangePicker); /***/ }), /* 7 */ /***/ (function(module, exports) { module.exports = require("react-dom"); /***/ }), /* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index_scss__ = __webpack_require__(9); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__index_scss___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__index_scss__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_utils__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__context__ = __webpack_require__(4); var Placeholder = function Placeholder(_ref) { var _ref$showTime = _ref.showTime, showTime = _ref$showTime === undefined ? false : _ref$showTime, customPlaceholder = _ref.customPlaceholder, placeholder = _ref.placeholder, format = _ref.format, provider = _ref.provider; var startDate = provider.startDate, endDate = provider.endDate; var s_date = startDate ? startDate.customObject : null, e_date = endDate ? endDate.customObject : null; if (customPlaceholder) { var _ref2 = startDate || {}, _startDate = _ref2._date; var _ref3 = endDate || {}, _endDate = _ref3._date; return customPlaceholder({ startDate: _startDate, endDate: _endDate }); } return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'default-placeholder' }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'text' }, !!s_date || !!e_date ? __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'dates-container' }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(DateAndTime, { format: format, date: s_date, showTime: showTime }), !!e_date && __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'b', null, ' ~ ' ), __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(DateAndTime, { format: format, date: e_date, showTime: showTime }) ) : placeholder || 'Select Date / Date Range' ), __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(CalendarIcon, null) ); }; var DateAndTime = function DateAndTime(_ref4) { var date = _ref4.date, format = _ref4.format, showTime = _ref4.showTime; if (!date) return null; var _format = showTime ? 'dd-mm-yyyy h:mi A' : 'dd-mm-yyyy'; var dateStr = Object(__WEBPACK_IMPORTED_MODULE_2_utils__["b" /* formatDate */])(format || _format, date); return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( __WEBPACK_IMPORTED_MODULE_0_react___default.a.Fragment, null, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'span', { className: 'date' }, ' ', dateStr, ' ' ) ); }; var CalendarIcon = function CalendarIcon() { var dateDots = new Array(5).fill(''); return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'icon' }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'calendar-hooks' }, __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement('div', { className: 'hook' }), __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement('div', { className: 'hook' }) ), __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( 'div', { className: 'date-dots' }, dateDots.map(function (dot, index) { return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement('div', { key: index, className: 'dot' }); }) ) ); }; /* harmony default export */ __webpack_exports__["a"] = (function (props) { return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement( __WEBPACK_IMPORTED_MODULE_3__context__["b" /* default */].Consumer, null, function (provider) { return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(Placeholder, Object.assign({}, props, { provider: provider })); } ); }); /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a <style> tag // load the styles var content = __webpack_require__(10); if(typeof content === 'string') content = [[module.i, content, '']]; // Prepare cssTransformation var transform; var options = {"hmr":true} options.transform = transform // add the styles to the DOM var update = __webpack_require__(2)(content, options); if(content.locals) module.exports = content.locals; // Hot Module Replacement if(false) { // When the styles change, update the <style> tags if(!content.locals) { module.hot.accept("!!../../../node_modules/css-loader/index.js!../../../node_modules/sass-loader/dist/cjs.js!./index.scss", function() { var newContent = require("!!../../../node_modules/css-loader/index.js!../../../node_modules/sass-loader/dist/cjs.js!./index.scss"); if(typeof newContent === 'string') newContent = [[module.id, newContent, '']]; update(newContent); }); } // When the module is disposed, remove the <style> tags module.hot.dispose(function() { update(); }); } /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { exports = module.exports = __webpack_require__(1)(undefined); // imports // module exports.push([module.i, ".default-placeholder{border-radius:3px;box-shadow:0 1px 6px -2px rgba(74,102,165,.1);background-color:#fff;border:solid 1px #e5e9f2;display:flex;flex-direction:row;align-items:center;justify-content:center;padding:12px 12px;letter-spacing:.2px;color:#b8c2cc;font-size:90%;box-sizing:border-box;min-width:280px}.default-placeholder .text{flex:1;min-width:190px;text-align:left}.default-placeholder .text .dates-container{font-size:90%}.default-placeholder .text .dates-container .time{font-size:75%}.default-placeholder .icon{border-radius:2px;height:15px;width:16px;border:.11em solid #6597ff;margin-left:10px;box-sizing:border-box;position:relative}.default-placeholder .icon .calendar-hooks{position:absolute;left:.01em;top:-0.2em;width:100%;display:flex;flex-direction:row;justify-content:space-between}.default-placeholder .icon .calendar-hooks .hook{height:3px;border:1px solid #6597ff}.default-placeholder .icon .date-dots{display:grid;padding:3px 2px;grid-template-columns:1fr 1fr 1fr}.default-placeholder .icon .date-dots .dot{background-color:#6597ff;height:2px;width:2px;margin-bottom:2px}", ""]); // exports /***/ }), /* 11 */ /***/ (function(module, exports) { /** * When source maps are enabled, `style-loader` uses a link element with a data-uri to * embed the css on the page. This breaks all relative urls because now they are relative to a * bundle instead of the current page. * * One solution is to only use full urls, but that may be impossible. * * Instead, this function "fixes" the relative urls to be absolute according to the current page location. * * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command. * */ module.exports = function (css) { // get current location var location = typeof window !== "undefined" && window.location; if (!location) { throw new Error("fixUrls requires window.location"); } // blank or null? if (!css || typeof css !== "string") { return css; } var baseUrl = location.protocol + "//" + location.host; var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/"); // convert each url(...) /* This regular expression is just a way to recursively match brackets within a string. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens ( = Start a capturing group (?: = Start a non-capturing group [^)(] = Match anything that isn't a parentheses | = OR \( = Match a start parentheses (?: = Start another non-capturing groups [^)(]+ = Match anything that isn't a parentheses | = OR \( = Match a start parentheses [^)(]* = Match anything that isn't a parentheses \) = Match a end parentheses ) = End Group *\) = Match anything and then a close parens ) = Close non-capturing group * = Match anything ) = Close capturing group \) = Match a close parens /gi = Get all matches, not the first. Be case insensitive. */ var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) { // strip quotes (if they exist) var unquotedOrigUrl = origUrl .trim() .replace(/^"(.*)"$/, function(o, $1){ return $1; }) .replace(/^'(.*)'$/, function(o, $1){ return $1; }); // already a full url? no change if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(unquotedOrigUrl)) { return fullMatch; } // convert the url to a full url var newUrl; if (unquotedOrigUrl.indexOf("//") === 0) { //TODO: should we add protocol? newUrl = unquotedOrigUrl; } else if (unquotedOrigUrl.indexOf("/") === 0) { // path should be relative to the base url newUrl = baseUrl + unquotedOrigUrl; // already starts with '/' } else { // path should be relative to current directory newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './' } // send back the fixed url(...) return "url(" + JSON.stringify(newUrl) + ")"; }); // send back the fixed css return fixedCss; }; /***/ }), /* 12 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return formators; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_const__ = __webpack_require__(5); /* FORMATS ==> dd - date DD - day short DDDD - day full mm - month MM - month short MMMM - month full yyyy/YYYY - full year h - hours mi - minutes a - lowercase period (am), A - capital period (AM) */ var dd = function dd(str, date) { return str.replace('dd', date.date); }; var mm = function mm(str, date) { return str.replace('mm', date.month + 1); }; var yyyy = function yyyy(str, date) { return str.replace('yyyy', date.year); }; var DD = function DD(str, date) { return str.replace('DD', __WEBPACK_IMPORTED_MODULE_0_const__["a" /* days */][date.day].short); }; var MM = function MM(str, date) { return str.replace('MM', date.monthNameShort); }; var YYYY = function YYYY(str, date) { return str.replace('YYYY', date.year); }; var DDDD = function DDDD(str, date) { return str.replace('DDDD', __WEBPACK_IMPORTED_MODULE_0_const__["a" /* days */][date.day].full); }; var MMMM = function MMMM(str, date) { return str.replace('MMMM', date.monthNameFull); }; var a = function a(str, date) { return str.replace('a', date.period.toLowerCase()); }; var A = function A(str, date) { return str.replace('A', date.period.toUpperCase()); }; var h = function h(str, date) { return str.replace('h', date.hours); }; var H = function H(str, date) { return str.replace('H', date.hours); }; var mi = function mi(str, date) { return str.replace('mi', date.minutes); }; var MI = function MI(str, date) { return str.replace('MI', date.minutes); }; // order of the formators matters // as next formator may replace the characters in it var formators = [h, H, a, A, dd, mm, YYYY, DDDD, MMMM, yyyy, DD, MM, mi, MI]; /***/ }), /* 13 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_utils__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_const__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__grids__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__navigator__ = __webpack_require__(23); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__month_picker__ = __webpack_require__(26); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__year_picker__ = __webpack_require__(29); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__footer__ = __webpack_require__(32); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__time_picker__ = __webpack_require__(35); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__context__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__index_scss__ = __webpack_require__(41); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__index_scss___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10__index_scss__); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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 ANIMATE_LEFT = 'move-left'; var ANIMATE_RIGHT = 'move-right'; var START_DATE_TIME = { hours: '12', minutes: '00', period: 'AM' }; var END_DATE_TIME = { hours: '12', minutes: '00', period: 'AM' }; var END_DATE_TIME_END_OF_DAY = { hours: '11', minutes: '59', period: 'PM' }; function getDefaultValues(date) { if (!date) return null; if (!date instanceof Date) { console.warn(' start and end must be a valid date object in defaultValue prop '); return null; } var customDate = Object(__WEBPACK_IMPORTED_MODULE_1_utils__["d" /* getCustomDateObject */])(date); var time = Object(__WEBPACK_IMPORTED_MODULE_1_utils__["h" /* getTime */])(12, date); return Object(__WEBPACK_IMPORTED_MODULE_1_utils__["c" /* getActualDate */])(Object(__WEBPACK_IMPORTED_MODULE_1_utils__["a" /* dateToInt */])(customDate), time); } var Calander = function (_React$Component) { _inherits(Calander, _React$Component); function Calander() { var _ref; var _temp, _this, _ret; _classCallCheck(this, Calander); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Calander.__proto__ || Object.getPrototypeOf(Calander)).call.apply(_ref, [this].concat(args))), _this), _this.actualDate = new Date(), _this.actualIntDate = Object(__WEBPACK_IMPORTED_MODULE_1_utils__["a" /* dateT