Socket
Socket
Sign inDemoInstall

@majidh1/jalalidatepicker

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@majidh1/jalalidatepicker - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

dist/jalaliDatepicker.js

@@ -59,3 +59,3 @@ /*

eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"isNaN\": function() { return /* binding */ isNaN; },\n/* harmony export */ \"isNumber\": function() { return /* binding */ isNumber; },\n/* harmony export */ \"isUndefined\": function() { return /* binding */ isUndefined; },\n/* harmony export */ \"isFunction\": function() { return /* binding */ isFunction; },\n/* harmony export */ \"isString\": function() { return /* binding */ isString; },\n/* harmony export */ \"clon\": function() { return /* binding */ clon; },\n/* harmony export */ \"isLeapYear\": function() { return /* binding */ isLeapYear; },\n/* harmony export */ \"getDaysInMonth\": function() { return /* binding */ getDaysInMonth; },\n/* harmony export */ \"mod\": function() { return /* binding */ mod; },\n/* harmony export */ \"getDays\": function() { return /* binding */ getDays; },\n/* harmony export */ \"getDiffDays\": function() { return /* binding */ getDiffDays; },\n/* harmony export */ \"getWeekDay\": function() { return /* binding */ getWeekDay; },\n/* harmony export */ \"getYears\": function() { return /* binding */ getYears; },\n/* harmony export */ \"addLeadingZero\": function() { return /* binding */ addLeadingZero; },\n/* harmony export */ \"isPlainObject\": function() { return /* binding */ isPlainObject; },\n/* harmony export */ \"extend\": function() { return /* binding */ extend; },\n/* harmony export */ \"createElement\": function() { return /* binding */ createElement; },\n/* harmony export */ \"addListenerMulti\": function() { return /* binding */ addListenerMulti; },\n/* harmony export */ \"setInnerHTML\": function() { return /* binding */ setInnerHTML; },\n/* harmony export */ \"normalizeMinMaxDate\": function() { return /* binding */ normalizeMinMaxDate; },\n/* harmony export */ \"getValidMonths\": function() { return /* binding */ getValidMonths; },\n/* harmony export */ \"isValidDay\": function() { return /* binding */ isValidDay; },\n/* harmony export */ \"setClassName\": function() { return /* binding */ setClassName; },\n/* harmony export */ \"isValidDateString\": function() { return /* binding */ isValidDateString; },\n/* harmony export */ \"getDateFromString\": function() { return /* binding */ getDateFromString; },\n/* harmony export */ \"getDateToString\": function() { return /* binding */ getDateToString; },\n/* harmony export */ \"jalaliToday\": function() { return /* binding */ jalaliToday; },\n/* harmony export */ \"getScrollParent\": function() { return /* binding */ getScrollParent; },\n/* harmony export */ \"getEventTarget\": function() { return /* binding */ getEventTarget; },\n/* harmony export */ \"containsDom\": function() { return /* binding */ containsDom; },\n/* harmony export */ \"createEvent\": function() { return /* binding */ createEvent; },\n/* harmony export */ \"triggerEvent\": function() { return /* binding */ triggerEvent; }\n/* harmony export */ });\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nvar _this = undefined;\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n\nvar isNaN = Number.isNaN || window.isNaN;\nvar isNumber = function isNumber(value) {\n return typeof value === \"number\" && !isNaN(value);\n};\nvar isUndefined = function isUndefined(value) {\n return typeof value === \"undefined\";\n};\nvar isFunction = function isFunction(value) {\n return typeof value === \"function\";\n};\nvar isString = function isString(value) {\n return typeof value === \"string\";\n};\nvar clon = function clon(a) {\n return JSON.parse(JSON.stringify(a));\n};\nvar isLeapYear = function isLeapYear(year) {\n return ((year - 474) % 2820 + 512) * 682 % 2816 < 682;\n};\nvar getDaysInMonth = function getDaysInMonth(year, month) {\n return [0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, isLeapYear(year) ? 30 : 29][month];\n};\nvar mod = function mod(a, b) {\n return window.Math.abs(a - b * window.Math.floor(a / b));\n};\nvar getDays = function getDays(month, day) {\n if (month < 8) return (month - 1) * 31 + day;\n return 6 * 31 + (month - 7) * 30 + day;\n};\nvar getDiffDays = function getDiffDays(year1, month1, day1, year2, month2, day2) {\n var diffDays = getDays(month2, day2) - getDays(month1, day1);\n var y1 = year1 < year2 ? year1 : year2;\n var y2 = year1 < year2 ? year2 : year1;\n\n for (var y = y1; y < y2; y++) {\n if (isLeapYear(y)) diffDays += year1 < year2 ? 366 : -366;else diffDays += year1 < year2 ? 365 : -365;\n }\n\n return diffDays;\n};\nvar getWeekDay = function getWeekDay(year, month, day) {\n return mod(getDiffDays(1392, 3, 25, year, month, day), 7);\n};\nvar getYears = function getYears(month, day) {\n return 6 * 31 + (month - 7) * 30 + day;\n};\nvar addLeadingZero = function addLeadingZero(value) {\n var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;\n var str = String(Math.abs(value));\n var i = str.length;\n var result = \"\";\n\n if (value < 0) {\n result += \"-\";\n }\n\n while (i < length) {\n i += 1;\n result += \"0\";\n }\n\n return result + str;\n};\nvar isPlainObject = function isPlainObject(obj) {\n if (!obj || !obj.constructor || obj.nodeType) {\n return false;\n }\n\n try {\n return JSON.stringify(obj) === \"{}\";\n } catch (e) {\n return true;\n }\n};\nvar extend = function extend() {\n var options;\n var src;\n var copy;\n var copyIsArray;\n var clone;\n\n for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {\n params[_key] = arguments[_key];\n }\n\n var target = params[0] || {};\n var i = 1;\n var length = params.length;\n var deep = false; // Handle a deep copy situation\n\n if (typeof target === \"boolean\") {\n deep = target; // Skip the boolean and the target\n\n target = params[i] || {};\n i += 1;\n } // Handle case when target is a string or something (possible in deep copy)\n\n\n if (_typeof(target) !== \"object\" && isFunction(target)) {\n target = {};\n } // Extend jQuery itself if only one argument is passed\n\n\n if (i === length) {\n target = _this;\n i -= 1;\n }\n\n for (; i < length; i++) {\n options = params[i]; // Only deal with non-null/undefined values\n\n if (!isUndefined(options) && options !== null) {\n // Extend the base object\n for (var j = 0; j < window.Object.keys(options).length; j++) {\n var name = window.Object.keys(options)[j];\n\n if (Object.prototype.hasOwnProperty.call(options, name)) {\n copy = options[name]; // Prevent Object.prototype pollution\n // Prevent never-ending loop\n\n if (name === \"__proto__\" || target === copy) {\n return true;\n }\n\n copyIsArray = Array.isArray(copy); // Recurse if we're merging plain objects or arrays\n\n if (deep && copy && (isPlainObject(copy) || copyIsArray)) {\n src = target[name]; // Ensure proper type for the source value\n\n if (copyIsArray && !Array.isArray(src)) {\n clone = [];\n } else if (!copyIsArray && !isPlainObject(src)) {\n clone = {};\n } else {\n clone = src;\n } // Never move original objects, clone them\n\n\n target[name] = extend(deep, clone, copy); // Don't bring in undefined values\n } else if (!isUndefined(copy)) {\n target[name] = copy;\n }\n }\n }\n }\n } // Return the modified object\n\n\n return target;\n};\nvar createElement = function createElement(tag, parent, eventNames, event, content) {\n var splits = tag.split(\".\");\n tag = splits.shift() || \"div\";\n var className = splits;\n var element = window.document.createElement(tag);\n\n if (isString(parent)) {\n window.document.querySelector(parent).appendChild(element);\n } else {\n parent.appendChild(element);\n }\n\n if (className.length) {\n element.className = className.join(\" \");\n }\n\n if (eventNames && event) {\n addListenerMulti(element, eventNames, event);\n }\n\n if (!isUndefined(content)) {\n setInnerHTML(element, content);\n }\n\n return element;\n};\nvar addListenerMulti = function addListenerMulti(element, eventNames, listener) {\n var events = eventNames.split(\" \");\n\n for (var i = 0, iLen = events.length; i < iLen; i++) {\n element.addEventListener(events[i], listener, false);\n }\n};\nvar setInnerHTML = function setInnerHTML(element, html) {\n element.innerHTML = html;\n};\nvar normalizeMinMaxDate = function normalizeMinMaxDate(year, month, day, initDate, minDate, maxDate) {\n if (isNaN(year) || year < 1000 || year > 1999) {\n year = initDate.year;\n } else {\n if (year < minDate.year) {\n year = minDate.year;\n } else if (year > maxDate.year) {\n year = maxDate.year;\n }\n }\n\n if (isNaN(month) || month < 1 || month > 12) {\n month = initDate.month;\n } else {\n if (year <= minDate.year && month < minDate.month) {\n month = minDate.month;\n } else if (year >= maxDate.year && month > maxDate.month) {\n month = maxDate.month;\n }\n }\n\n if (isNaN(day) || day < 1) {\n day = initDate.day;\n } else {\n if (month <= minDate.month && day < minDate.day) {\n day = minDate.day;\n } else if (month >= maxDate.month && day > maxDate.day) {\n day = maxDate.day;\n }\n }\n\n return {\n year: parseInt(year),\n month: parseInt(month),\n day: parseInt(day)\n };\n};\nvar getValidMonths = function getValidMonths(initDate, minDate, maxDate) {\n var months = [];\n var start = 1;\n var finish = 12;\n\n if (initDate.year === minDate.year) {\n start = minDate.month;\n\n if (initDate.year === maxDate.year) {\n finish = maxDate.month;\n }\n } else if (initDate.year === maxDate.year) {\n start = 1;\n finish = maxDate.month;\n }\n\n for (var i = start; i <= finish; i++) {\n months.push(i);\n }\n\n return months;\n};\nvar isValidDay = function isValidDay(initDate, day, minDate, maxDate) {\n if (isPlainObject(minDate) && isPlainObject(maxDate)) {\n return true;\n }\n\n if (minDate.year === maxDate.year && minDate.month === maxDate.month) {\n return day >= minDate.day && day <= maxDate.day;\n }\n\n if (initDate.year === minDate.year && initDate.month === minDate.month) {\n return day >= minDate.day;\n }\n\n if (initDate.year === maxDate.year && initDate.month === maxDate.month) {\n return day <= maxDate.day;\n }\n\n return true;\n};\nvar setClassName = function setClassName(element, className) {\n element.className = className;\n};\nvar isValidDateString = function isValidDateString(str, sepChar) {\n if (!str) {\n return false;\n }\n\n var date = str.split(sepChar);\n return date.length === 3 && date[0].length === 4 && date[1].length === 2 && date[2].length === 2;\n};\nvar getDateFromString = function getDateFromString(str, sepChar) {\n var date = str.split(sepChar);\n return {\n year: parseInt(date[0]),\n month: parseInt(date[1]),\n day: parseInt(date[2])\n };\n};\nvar getDateToString = function getDateToString(y, m, d, sepChar) {\n return y + sepChar + addLeadingZero(m) + sepChar + addLeadingZero(d);\n};\nvar jalaliToday = function jalaliToday() {\n var date = new Date();\n var gy = parseInt(date.getFullYear());\n var gm = parseInt(date.getMonth()) + 1;\n var gd = parseInt(date.getDate());\n var jy, days;\n var gdm = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];\n\n if (gy > 1600) {\n jy = 979;\n gy -= 1600;\n } else {\n jy = 0;\n gy -= 621;\n }\n\n var gy2 = gm > 2 ? gy + 1 : gy;\n days = 365 * gy + parseInt((gy2 + 3) / 4) - parseInt((gy2 + 99) / 100) + parseInt((gy2 + 399) / 400) - 80 + gd + gdm[gm - 1];\n jy += 33 * parseInt(days / 12053);\n days %= 12053;\n jy += 4 * parseInt(days / 1461);\n days %= 1461;\n\n if (days > 365) {\n jy += parseInt((days - 1) / 365);\n days = (days - 1) % 365;\n }\n\n var jm = days < 186 ? 1 + parseInt(days / 31) : 7 + parseInt((days - 186) / 30);\n var jd = 1 + (days < 186 ? days % 31 : (days - 186) % 30);\n return {\n year: jy,\n month: jm,\n day: jd\n };\n};\nvar getScrollParent = function getScrollParent(node) {\n if ([\"html\", \"body\", \"#document\"].indexOf((node.nodeName || \"\").toLowerCase()) >= 0) {\n return window;\n }\n\n if (node instanceof HTMLElement) {\n var _window$getComputedSt = window.getComputedStyle(node),\n overflow = _window$getComputedSt.overflow,\n overflowX = _window$getComputedSt.overflowX,\n overflowY = _window$getComputedSt.overflowY;\n\n if (/auto|scroll|overlay/.test(overflow + overflowY + overflowX)) {\n return node;\n }\n }\n\n return getScrollParent(node.parentNode);\n};\nvar getEventTarget = function getEventTarget(event) {\n try {\n if (isFunction(event.composedPath)) {\n return event.composedPath()[0];\n }\n\n return event.target;\n } catch (error) {\n return event.target;\n }\n};\nvar containsDom = function containsDom(parent, event) {\n var path = event.path || event.composedPath && event.composedPath() || false;\n\n if (!path) {\n return parent.outerHTML.indexOf(event.target.outerHTML) > -1;\n }\n\n return path.indexOf(parent) !== -1;\n};\nvar createEvent = function createEvent(name) {\n var e = document.createEvent(\"Event\");\n e.initEvent(name, true, true);\n return e;\n};\nvar triggerEvent = function triggerEvent(elm, event) {\n if (!elm) return;\n elm.dispatchEvent(createEvent(event));\n\n if (event === _constants__WEBPACK_IMPORTED_MODULE_0__.EVENT_CHANGE_INPUT_STR) {\n elm.dispatchEvent(createEvent(\"change\"));\n elm.dispatchEvent(createEvent(\"input\"));\n }\n};\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/utils.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"isNaN\": function() { return /* binding */ isNaN; },\n/* harmony export */ \"isNumber\": function() { return /* binding */ isNumber; },\n/* harmony export */ \"isUndefined\": function() { return /* binding */ isUndefined; },\n/* harmony export */ \"isFunction\": function() { return /* binding */ isFunction; },\n/* harmony export */ \"isString\": function() { return /* binding */ isString; },\n/* harmony export */ \"clon\": function() { return /* binding */ clon; },\n/* harmony export */ \"isLeapYear\": function() { return /* binding */ isLeapYear; },\n/* harmony export */ \"getDaysInMonth\": function() { return /* binding */ getDaysInMonth; },\n/* harmony export */ \"mod\": function() { return /* binding */ mod; },\n/* harmony export */ \"getDays\": function() { return /* binding */ getDays; },\n/* harmony export */ \"getDiffDays\": function() { return /* binding */ getDiffDays; },\n/* harmony export */ \"getWeekDay\": function() { return /* binding */ getWeekDay; },\n/* harmony export */ \"getYears\": function() { return /* binding */ getYears; },\n/* harmony export */ \"addLeadingZero\": function() { return /* binding */ addLeadingZero; },\n/* harmony export */ \"isPlainObject\": function() { return /* binding */ isPlainObject; },\n/* harmony export */ \"extend\": function() { return /* binding */ extend; },\n/* harmony export */ \"createElement\": function() { return /* binding */ createElement; },\n/* harmony export */ \"addListenerMulti\": function() { return /* binding */ addListenerMulti; },\n/* harmony export */ \"setInnerHTML\": function() { return /* binding */ setInnerHTML; },\n/* harmony export */ \"normalizeMinMaxDate\": function() { return /* binding */ normalizeMinMaxDate; },\n/* harmony export */ \"getValidMonths\": function() { return /* binding */ getValidMonths; },\n/* harmony export */ \"isValidDay\": function() { return /* binding */ isValidDay; },\n/* harmony export */ \"setClassName\": function() { return /* binding */ setClassName; },\n/* harmony export */ \"isValidDateString\": function() { return /* binding */ isValidDateString; },\n/* harmony export */ \"getDateFromString\": function() { return /* binding */ getDateFromString; },\n/* harmony export */ \"getDateToString\": function() { return /* binding */ getDateToString; },\n/* harmony export */ \"jalaliToday\": function() { return /* binding */ jalaliToday; },\n/* harmony export */ \"getScrollParent\": function() { return /* binding */ getScrollParent; },\n/* harmony export */ \"getEventTarget\": function() { return /* binding */ getEventTarget; },\n/* harmony export */ \"containsDom\": function() { return /* binding */ containsDom; },\n/* harmony export */ \"createEvent\": function() { return /* binding */ createEvent; },\n/* harmony export */ \"triggerEvent\": function() { return /* binding */ triggerEvent; }\n/* harmony export */ });\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nvar _this = undefined;\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n\nvar isNaN = Number.isNaN || window.isNaN;\nvar isNumber = function isNumber(value) {\n return typeof value === \"number\" && !isNaN(value);\n};\nvar isUndefined = function isUndefined(value) {\n return typeof value === \"undefined\";\n};\nvar isFunction = function isFunction(value) {\n return typeof value === \"function\";\n};\nvar isString = function isString(value) {\n return typeof value === \"string\";\n};\nvar clon = function clon(a) {\n return JSON.parse(JSON.stringify(a));\n};\nvar isLeapYear = function isLeapYear(jy) {\n function div(a, b) {\n return ~~(a / b);\n }\n\n var breaks = [-61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210, 1635, 2060, 2097, 2192, 2262, 2324, 2394, 2456, 3178],\n bl = breaks.length;\n var jump = 0,\n leapJ = -14,\n jp = breaks[0],\n leap;\n\n for (var i = 1; i < bl; i += 1) {\n var jm = breaks[i];\n jump = jm - jp;\n if (jy < jm) break;\n leapJ = leapJ + div(jump, 33) * 8 + div(mod(jump, 33), 4);\n jp = jm;\n }\n\n var n = jy - jp;\n if (jump - n < 6) n = n - jump + div(jump + 4, 33) * 33;\n leap = mod(mod(n + 1, 33) - 1, 4);\n if (leap === -1) leap = 4;\n return leap === 0;\n};\nvar getDaysInMonth = function getDaysInMonth(year, month) {\n return [0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, isLeapYear(year) ? 30 : 29][month];\n};\nvar mod = function mod(a, b) {\n return window.Math.abs(a - b * window.Math.floor(a / b));\n};\nvar getDays = function getDays(month, day) {\n if (month < 8) return (month - 1) * 31 + day;\n return 6 * 31 + (month - 7) * 30 + day;\n};\nvar getDiffDays = function getDiffDays(year1, month1, day1, year2, month2, day2) {\n var diffDays = getDays(month2, day2) - getDays(month1, day1);\n var y1 = year1 < year2 ? year1 : year2;\n var y2 = year1 < year2 ? year2 : year1;\n\n for (var y = y1; y < y2; y++) {\n if (isLeapYear(y)) diffDays += year1 < year2 ? 366 : -366;else diffDays += year1 < year2 ? 365 : -365;\n }\n\n return diffDays;\n};\nvar getWeekDay = function getWeekDay(year, month, day) {\n return mod(getDiffDays(1392, 3, 25, year, month, day), 7);\n};\nvar getYears = function getYears(month, day) {\n return 6 * 31 + (month - 7) * 30 + day;\n};\nvar addLeadingZero = function addLeadingZero(value) {\n var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;\n var str = String(Math.abs(value));\n var i = str.length;\n var result = \"\";\n\n if (value < 0) {\n result += \"-\";\n }\n\n while (i < length) {\n i += 1;\n result += \"0\";\n }\n\n return result + str;\n};\nvar isPlainObject = function isPlainObject(obj) {\n if (!obj || !obj.constructor || obj.nodeType) {\n return false;\n }\n\n try {\n return JSON.stringify(obj) === \"{}\";\n } catch (e) {\n return true;\n }\n};\nvar extend = function extend() {\n var options;\n var src;\n var copy;\n var copyIsArray;\n var clone;\n\n for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {\n params[_key] = arguments[_key];\n }\n\n var target = params[0] || {};\n var i = 1;\n var length = params.length;\n var deep = false; // Handle a deep copy situation\n\n if (typeof target === \"boolean\") {\n deep = target; // Skip the boolean and the target\n\n target = params[i] || {};\n i += 1;\n } // Handle case when target is a string or something (possible in deep copy)\n\n\n if (_typeof(target) !== \"object\" && isFunction(target)) {\n target = {};\n } // Extend jQuery itself if only one argument is passed\n\n\n if (i === length) {\n target = _this;\n i -= 1;\n }\n\n for (; i < length; i++) {\n options = params[i]; // Only deal with non-null/undefined values\n\n if (!isUndefined(options) && options !== null) {\n // Extend the base object\n for (var j = 0; j < window.Object.keys(options).length; j++) {\n var name = window.Object.keys(options)[j];\n\n if (Object.prototype.hasOwnProperty.call(options, name)) {\n copy = options[name]; // Prevent Object.prototype pollution\n // Prevent never-ending loop\n\n if (name === \"__proto__\" || target === copy) {\n return true;\n }\n\n copyIsArray = Array.isArray(copy); // Recurse if we're merging plain objects or arrays\n\n if (deep && copy && (isPlainObject(copy) || copyIsArray)) {\n src = target[name]; // Ensure proper type for the source value\n\n if (copyIsArray && !Array.isArray(src)) {\n clone = [];\n } else if (!copyIsArray && !isPlainObject(src)) {\n clone = {};\n } else {\n clone = src;\n } // Never move original objects, clone them\n\n\n target[name] = extend(deep, clone, copy); // Don't bring in undefined values\n } else if (!isUndefined(copy)) {\n target[name] = copy;\n }\n }\n }\n }\n } // Return the modified object\n\n\n return target;\n};\nvar createElement = function createElement(tag, parent, eventNames, event, content) {\n var splits = tag.split(\".\");\n tag = splits.shift() || \"div\";\n var className = splits;\n var element = window.document.createElement(tag);\n\n if (isString(parent)) {\n window.document.querySelector(parent).appendChild(element);\n } else {\n parent.appendChild(element);\n }\n\n if (className.length) {\n element.className = className.join(\" \");\n }\n\n if (eventNames && event) {\n addListenerMulti(element, eventNames, event);\n }\n\n if (!isUndefined(content)) {\n setInnerHTML(element, content);\n }\n\n return element;\n};\nvar addListenerMulti = function addListenerMulti(element, eventNames, listener) {\n var events = eventNames.split(\" \");\n\n for (var i = 0, iLen = events.length; i < iLen; i++) {\n element.addEventListener(events[i], listener, false);\n }\n};\nvar setInnerHTML = function setInnerHTML(element, html) {\n element.innerHTML = html;\n};\nvar normalizeMinMaxDate = function normalizeMinMaxDate(year, month, day, initDate, minDate, maxDate) {\n if (isNaN(year) || year < 1000 || year > 1999) {\n year = initDate.year;\n } else {\n if (year < minDate.year) {\n year = minDate.year;\n } else if (year > maxDate.year) {\n year = maxDate.year;\n }\n }\n\n if (isNaN(month) || month < 1 || month > 12) {\n month = initDate.month;\n } else {\n if (year <= minDate.year && month < minDate.month) {\n month = minDate.month;\n } else if (year >= maxDate.year && month > maxDate.month) {\n month = maxDate.month;\n }\n }\n\n if (isNaN(day) || day < 1) {\n day = initDate.day;\n } else {\n if (month <= minDate.month && day < minDate.day) {\n day = minDate.day;\n } else if (month >= maxDate.month && day > maxDate.day) {\n day = maxDate.day;\n }\n }\n\n return {\n year: parseInt(year),\n month: parseInt(month),\n day: parseInt(day)\n };\n};\nvar getValidMonths = function getValidMonths(initDate, minDate, maxDate) {\n var months = [];\n var start = 1;\n var finish = 12;\n\n if (initDate.year === minDate.year) {\n start = minDate.month;\n\n if (initDate.year === maxDate.year) {\n finish = maxDate.month;\n }\n } else if (initDate.year === maxDate.year) {\n start = 1;\n finish = maxDate.month;\n }\n\n for (var i = start; i <= finish; i++) {\n months.push(i);\n }\n\n return months;\n};\nvar isValidDay = function isValidDay(initDate, day, minDate, maxDate) {\n if (isPlainObject(minDate) && isPlainObject(maxDate)) {\n return true;\n }\n\n if (minDate.year === maxDate.year && minDate.month === maxDate.month) {\n return day >= minDate.day && day <= maxDate.day;\n }\n\n if (initDate.year === minDate.year && initDate.month === minDate.month) {\n return day >= minDate.day;\n }\n\n if (initDate.year === maxDate.year && initDate.month === maxDate.month) {\n return day <= maxDate.day;\n }\n\n return true;\n};\nvar setClassName = function setClassName(element, className) {\n element.className = className;\n};\nvar isValidDateString = function isValidDateString(str, sepChar) {\n if (!str) {\n return false;\n }\n\n var date = str.split(sepChar);\n return date.length === 3 && date[0].length === 4 && date[1].length === 2 && date[2].length === 2;\n};\nvar getDateFromString = function getDateFromString(str, sepChar) {\n var date = str.split(sepChar);\n return {\n year: parseInt(date[0]),\n month: parseInt(date[1]),\n day: parseInt(date[2])\n };\n};\nvar getDateToString = function getDateToString(y, m, d, sepChar) {\n return y + sepChar + addLeadingZero(m) + sepChar + addLeadingZero(d);\n};\nvar jalaliToday = function jalaliToday() {\n var date = new Date();\n var gy = parseInt(date.getFullYear());\n var gm = parseInt(date.getMonth()) + 1;\n var gd = parseInt(date.getDate());\n var jy, days;\n var gdm = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];\n\n if (gy > 1600) {\n jy = 979;\n gy -= 1600;\n } else {\n jy = 0;\n gy -= 621;\n }\n\n var gy2 = gm > 2 ? gy + 1 : gy;\n days = 365 * gy + parseInt((gy2 + 3) / 4) - parseInt((gy2 + 99) / 100) + parseInt((gy2 + 399) / 400) - 80 + gd + gdm[gm - 1];\n jy += 33 * parseInt(days / 12053);\n days %= 12053;\n jy += 4 * parseInt(days / 1461);\n days %= 1461;\n\n if (days > 365) {\n jy += parseInt((days - 1) / 365);\n days = (days - 1) % 365;\n }\n\n var jm = days < 186 ? 1 + parseInt(days / 31) : 7 + parseInt((days - 186) / 30);\n var jd = 1 + (days < 186 ? days % 31 : (days - 186) % 30);\n return {\n year: jy,\n month: jm,\n day: jd\n };\n};\nvar getScrollParent = function getScrollParent(node) {\n if ([\"html\", \"body\", \"#document\"].indexOf((node.nodeName || \"\").toLowerCase()) >= 0) {\n return window;\n }\n\n if (node instanceof HTMLElement) {\n var _window$getComputedSt = window.getComputedStyle(node),\n overflow = _window$getComputedSt.overflow,\n overflowX = _window$getComputedSt.overflowX,\n overflowY = _window$getComputedSt.overflowY;\n\n if (/auto|scroll|overlay/.test(overflow + overflowY + overflowX)) {\n return node;\n }\n }\n\n return getScrollParent(node.parentNode);\n};\nvar getEventTarget = function getEventTarget(event) {\n try {\n if (isFunction(event.composedPath)) {\n return event.composedPath()[0];\n }\n\n return event.target;\n } catch (error) {\n return event.target;\n }\n};\nvar containsDom = function containsDom(parent, event) {\n var path = event.path || event.composedPath && event.composedPath() || false;\n\n if (!path) {\n return parent.outerHTML.indexOf(event.target.outerHTML) > -1;\n }\n\n return path.indexOf(parent) !== -1;\n};\nvar createEvent = function createEvent(name) {\n var e = document.createEvent(\"Event\");\n e.initEvent(name, true, true);\n return e;\n};\nvar triggerEvent = function triggerEvent(elm, event) {\n if (!elm) return;\n elm.dispatchEvent(createEvent(event));\n\n if (event === _constants__WEBPACK_IMPORTED_MODULE_0__.EVENT_CHANGE_INPUT_STR) {\n elm.dispatchEvent(createEvent(\"change\"));\n elm.dispatchEvent(createEvent(\"input\"));\n }\n};\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/utils.js?");

@@ -62,0 +62,0 @@ /***/ }),

@@ -1,1 +0,1 @@

!function(){"use strict";!function(){var t="jdp",n="".concat(t,"-container"),e="div.".concat(t,"-years"),i="div.".concat(t,"-year"),a="div.".concat(t,"-months"),o="div.".concat(t,"-month"),r="div.".concat(t,"-days"),s="div.".concat(t,"-day"),h="div.".concat(t,"-day-name"),c="div.".concat(t,"-icon-plus"),u="div.".concat(t,"-icon-minus"),d="div.".concat(t,"-footer"),p="div.".concat(t,"-btn-today"),y="div.".concat(t,"-btn-empty"),l="not-in-range",f="".concat(t,":change"),m="click",v="focusin",D="today",g="attr",w=("data-".concat(t),"visible"),_=void 0;function C(t){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var b=Number.isNaN||window.isNaN,x=function(t){return void 0===t},I=function(t){return"function"==typeof t},M=function(t){return"string"==typeof t},E=function(t){return JSON.parse(JSON.stringify(t))},S=function(t){return 682*((t-474)%2820+512)%2816<682},O=function(t,n){return t<8?31*(t-1)+n:186+30*(t-7)+n},H=function(t,n,e){return i=function(t,n,e,i,a,o){for(var r=O(a,o)-O(n,e),s=t<i?i:t,h=t<i?t:i;h<s;h++)S(h)?r+=t<i?366:-366:r+=t<i?365:-365;return r}(1392,3,25,t,n,e),a=7,window.Math.abs(i-a*window.Math.floor(i/a));var i,a},N=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=String(Math.abs(t)),i=e.length,a="";for(t<0&&(a+="-");i<n;)i+=1,a+="0";return a+e},j=function(t){if(!t||!t.constructor||t.nodeType)return!1;try{return"{}"===JSON.stringify(t)}catch(t){return!0}},P=function t(){for(var n,e,i,a,o,r=arguments.length,s=new Array(r),h=0;h<r;h++)s[h]=arguments[h];var c=s[0]||{},u=1,d=s.length,p=!1;for("boolean"==typeof c&&(p=c,c=s[u]||{},u+=1),"object"!==C(c)&&I(c)&&(c={}),u===d&&(c=_,u-=1);u<d;u++)if(n=s[u],!x(n)&&null!==n)for(var y=0;y<window.Object.keys(n).length;y++){var l=window.Object.keys(n)[y];if(Object.prototype.hasOwnProperty.call(n,l)){if(i=n[l],"__proto__"===l||c===i)return!0;a=Array.isArray(i),p&&i&&(j(i)||a)?(e=c[l],o=a&&!Array.isArray(e)?[]:a||j(e)?e:{},c[l]=t(p,o,i)):x(i)||(c[l]=i)}}return c},Y=function(t,n,e,i,a){var o=t.split(".");t=o.shift()||"div";var r=o,s=window.document.createElement(t);return M(n)?window.document.querySelector(n).appendChild(s):n.appendChild(s),r.length&&(s.className=r.join(" ")),e&&i&&k(s,e,i),x(a)||L(s,a),s},k=function(t,n,e){for(var i=n.split(" "),a=0,o=i.length;a<o;a++)t.addEventListener(i[a],e,!1)},L=function(t,n){t.innerHTML=n},z=function(t,n,e,i,a,o){return b(t)||t<1e3||t>1999?t=i.year:t<a.year?t=a.year:t>o.year&&(t=o.year),b(n)||n<1||n>12?n=i.month:t<=a.year&&n<a.month?n=a.month:t>=o.year&&n>o.month&&(n=o.month),b(e)||e<1?e=i.day:n<=a.month&&e<a.day?e=a.day:n>=o.month&&e>o.day&&(e=o.day),{year:parseInt(t),month:parseInt(n),day:parseInt(e)}},B=function(t,n){if(!t)return!1;var e=t.split(n);return 3===e.length&&4===e[0].length&&2===e[1].length&&2===e[2].length},T=function(t,n){var e=t.split(n);return{year:parseInt(e[0]),month:parseInt(e[1]),day:parseInt(e[2])}},A=function t(n){if(["html","body","#document"].indexOf((n.nodeName||"").toLowerCase())>=0)return window;if(n instanceof HTMLElement){var e=window.getComputedStyle(n),i=e.overflow,a=e.overflowX,o=e.overflowY;if(/auto|scroll|overlay/.test(i+o+a))return n}return t(n.parentNode)},R=function(t){var n=document.createEvent("Event");return n.initEvent(t,!0,!0),n},V=function(t){return 6===t?".".concat("last-week"):""},W=function(t,n){Y(c+(n?K.options.maxDate.year===K.initDate.year?".".concat(l):"":K.options.maxDate.year===K.initDate.year&&K.options.maxDate.month===K.initDate.month?".".concat(l):""),t,m,n?function(){K.increaseYear()}:function(){K.increaseMonth()},K.options.plusHtml)},J=function(t,n){Y(u+(n?K.options.minDate.year===K.initDate.year?".".concat(l):"":K.options.minDate.year===K.initDate.year&&K.options.minDate.month===K.initDate.month?".".concat(l):""),t,m,n?function(){K.decreaseYear()}:function(){K.decreaseMonth()},K.options.minusHtml)},q=function(){var t=Y(e,K.dpContainer);W(t,!0);var n=Y(i,t);J(t,!0);var a=Y("input",n,"keyup change",(function(t){K.yearChange(t.target.value)}));a.tabIndex=-1,a.value=K.initDate.year,a.type="number"},F=function(){var t=Y(a,K.dpContainer);W(t,!1);var n=Y(o,t);J(t,!1);var e=Y("select",n,"change",(function(t){K.monthChange(t.target.value)}));e.tabIndex=-1;for(var i=function(t,n,e){var i=[],a=1,o=12;t.year===n.year?(a=n.month,t.year===e.year&&(o=e.month)):t.year===e.year&&(a=1,o=e.month);for(var r=a;r<=o;r++)i.push(r);return i}(K.initDate,K.options.minDate,K.options.maxDate),r=K.options.months,s=0;s<i.length;s++){var h=Y("option",e);h.value=i[s],h.text=r[i[s]-1],h.selected=i[s]===K.initDate.month}},X=function(){for(var t=Y(r,K.dpContainer),n=0;n<7;n++)Y(h+V(n),t,null,null,K.options.days[n]);for(var e,i,a=(e=K.initDate.year,i=K.initDate.month,[0,31,31,31,31,31,31,30,30,30,30,30,S(e)?30:29][i]),o=H(K.initDate.year,K.initDate.month,1),c=7*Math.ceil((o+a)/7)-1,u=1,d=function(n){var e,i,o,r,h=H(K.initDate.year,K.initDate.month,u),c=(e=K.initDate,i=u,o=K.options.minDate,r=K.options.maxDate,!(!j(o)||!j(r))||(o.year===r.year&&o.month===r.month?i>=o.day&&i<=r.day:e.year===o.year&&e.month===o.month?i>=o.day:e.year!==r.year||e.month!==r.month||i<=r.day));if(u<=h&&n<h||u>a)return Y(s,t),"continue";if(!c)return Y(s,t),u+=1,"continue";var d=V(h);K.valueDate.day===u&&K.valueDate.year===K.initDate.year&&K.valueDate.month===K.initDate.month&&(d+=".".concat("selected")),K.today.day===u&&K.today.year===K.initDate.year&&K.today.month===K.initDate.month&&(d+=".".concat("today"));var p=Y(s+d,t,null,null,u);p.day=u,p.addEventListener(m,(function(){K.setValue(K.initDate.year,K.initDate.month,p.day)})),u+=1},p=0;p<=c;p++)d(p)},G=function(){var t=Y(d,K.dpContainer);K.options.showTodayBtn&&Y(p,t,m,(function(){K.setValue(K.today.year,K.today.month,K.today.day)}),"امروز"),K.options.showEmptyBtn&&Y(y,t,m,(function(){K.setValue()}),"خالی")},K=null;var Q={days:["ش","ی","د","س","چ","پ","ج"],months:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],initDate:null,minDate:{},maxDate:{},separatorChar:"/",zIndex:1e3,container:"body",dpContainer:null,selector:"input[data-jdp]",autoShow:!0,autoHide:!0,plusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-256v256h-84v-256h-256v-84h256v-256h84v256h256v84z"></path></g></svg>',minusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-596v-84h596v84z"></path></g></svg>',changeMonthRotateYear:!1,showTodayBtn:!0,showEmptyBtn:!0,autoReadOnlyInput:window.innerWidth<=800&&window.innerHeight<=600},U={init:function(t){var n;this.options=P(Q,t),this.options=$(this.options),window.onresize=nt,this.options.autoHide&&(document.body.onclick=tt),this.options.autoShow&&(n=this.options.selector,Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector,document.body.addEventListener(v,(function(t){t.target&&t.target.matches(n)&&U.show(t.target)})))},options:Q,input:null,get dpContainer(){return this._dpContainer=this._dpContainer||Y(n,this.options.container),this._dpContainer},get today(){return this._today=this._today||function(){var t,n,e=new Date,i=parseInt(e.getFullYear()),a=parseInt(e.getMonth())+1,o=parseInt(e.getDate());i>1600?(t=979,i-=1600):(t=0,i-=621);var r=a>2?i+1:i;return n=365*i+parseInt((r+3)/4)-parseInt((r+99)/100)+parseInt((r+399)/400)-80+o+[0,31,59,90,120,151,181,212,243,273,304,334][a-1],t+=33*parseInt(n/12053),n%=12053,t+=4*parseInt(n/1461),(n%=1461)>365&&(t+=parseInt((n-1)/365),n=(n-1)%365),{year:t,month:n<186?1+parseInt(n/31):7+parseInt((n-186)/30),day:1+(n<186?n%31:(n-186)%30)}}(),this._today},get valueDate(){return this._valueDate=E(this.input.value),M(this._valueDate)&&(B(this._valueDate,this.options.separatorChar)?this._valueDate=T(this._valueDate,this.options.separatorChar):this._valueDate={}),this._valueDate},get initDate(){return this._initDate=this._initDate||E(this.valueDate),j(this._initDate)&&(this._initDate=this.options.initDate||E(this.today)),M(this._initDate)&&B(this._initDate,this.options.separatorChar)&&(this._initDate=T(this._initDate,this.options.separatorChar)),z(this._initDate.year,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate)},_draw:function(){L((K=this).dpContainer,""),q(),F(),X(),G()},show:function(t){this._initDate=null,this._valueDate=null,this.input=t,this._draw(),this.dpContainer.style.visibility=w,this.dpContainer.style.display="block",this.dpContainer.style.zIndex=this.options.zIndex,this.setPosition(),function(t){A(t).addEventListener("scroll",(function(){U.setPosition()}),{passive:!0})}(t),function(t,n){n.autoReadOnlyInput&&!t.readOnly&&(t.readOnly=!0)}(t,this.options)},hide:function(){this.dpContainer.style.visibility="hidden",this.dpContainer.style.display="none"},setPosition:function(){if(this.dpContainer.style.visibility===w){var t=this.input.getBoundingClientRect(),n=t.left,e=t.top,i=t.height,a=window.document.body.offsetWidth,o=this.dpContainer.offsetWidth,r=this.dpContainer.offsetHeight;n+o>=a&&(n-=n+o-(a+10)),e>=r&&e+r>=window.innerHeight&&(e-=r+i),this.dpContainer.style.position="fixed",this.dpContainer.style.left=n+"px",this.dpContainer.style.top=e+this.input.offsetHeight+"px"}},setValue:function(t,n,e){var i,a,o,r,s,h;this._valueDate.year=t,this._valueDate.month=n,this._valueDate.day=e,this.hide(),isNaN(t+n+e)?this.input.value="":this.input.value=(i=t,a=n,o=e,r=this.options.separatorChar,i+r+N(a)+r+N(o)),s=this.input,h=f,s&&(s.dispatchEvent(R(h)),h===f&&(s.dispatchEvent(R("change")),s.dispatchEvent(R("input"))))},increaseMonth:function(){var t=12===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.increaseYear(),this.monthChange(t?1:this._initDate.month+1)},decreaseMonth:function(){var t=1===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.decreaseYear(),this.monthChange(t?12:this._initDate.month-1)},monthChange:function(t){this._initDate=z(this._initDate.year,t,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()},increaseYear:function(){this.yearChange(this._initDate.year+1)},decreaseYear:function(){this.yearChange(this._initDate.year-1)},yearChange:function(t){this._initDate=z(t,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()}},Z=function(t,n){var e=U.input.getAttribute(t);return e=e===D?E(U.today):M(e)&&B(e,n)?T(e,n):{}},$=function(t){return t.minDate===D&&(t.minDate=E(U.today)),t.maxDate===D&&(t.maxDate=E(U.today)),t.minDate===g&&(delete t.minDate,window.Object.defineProperty(t,"minDate",{get:function(){return Z("data-jdp-min-date",t.separatorChar)}})),t.maxDate===g&&(delete t.maxDate,window.Object.defineProperty(t,"maxDate",{get:function(){return Z("data-jdp-max-date",t.separatorChar)}})),t};function tt(t){var n,e,i;U.dpContainer.style.visibility!==w||(n=U.dpContainer,(i=(e=t).path||e.composedPath&&e.composedPath()||!1)?-1!==i.indexOf(n):n.outerHTML.indexOf(e.target.outerHTML)>-1)||function(t){try{return I(t.composedPath)?t.composedPath()[0]:t.target}catch(n){return t.target}}(t)===U.input||U.hide()}function nt(){U.setPosition()}window.jalaliDatepicker={startWatch:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};U.init(t)},show:function(t){U.show(t)},hide:function(){U.hide()}}}()}();
!function(){"use strict";!function(){var t="jdp",n="".concat(t,"-container"),e="div.".concat(t,"-years"),i="div.".concat(t,"-year"),a="div.".concat(t,"-months"),o="div.".concat(t,"-month"),r="div.".concat(t,"-days"),s="div.".concat(t,"-day"),h="div.".concat(t,"-day-name"),u="div.".concat(t,"-icon-plus"),c="div.".concat(t,"-icon-minus"),d="div.".concat(t,"-footer"),p="div.".concat(t,"-btn-today"),y="div.".concat(t,"-btn-empty"),l="not-in-range",f="".concat(t,":change"),m="click",v="focusin",D="today",g="attr",w=("data-".concat(t),"visible"),_=void 0;function C(t){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var b=Number.isNaN||window.isNaN,x=function(t){return void 0===t},I=function(t){return"function"==typeof t},M=function(t){return"string"==typeof t},E=function(t){return JSON.parse(JSON.stringify(t))},S=function(t){function n(t,n){return~~(t/n)}for(var e,i=[-61,9,38,199,426,686,756,818,1111,1181,1210,1635,2060,2097,2192,2262,2324,2394,2456,3178],a=i.length,o=0,r=-14,s=i[0],h=1;h<a;h+=1){var u=i[h];if(o=u-s,t<u)break;r=r+8*n(o,33)+n(O(o,33),4),s=u}var c=t-s;return o-c<6&&(c=c-o+33*n(o+4,33)),-1===(e=O(O(c+1,33)-1,4))&&(e=4),0===e},O=function(t,n){return window.Math.abs(t-n*window.Math.floor(t/n))},H=function(t,n){return t<8?31*(t-1)+n:186+30*(t-7)+n},N=function(t,n,e){return O(function(t,n,e,i,a,o){for(var r=H(a,o)-H(n,e),s=t<i?i:t,h=t<i?t:i;h<s;h++)S(h)?r+=t<i?366:-366:r+=t<i?365:-365;return r}(1392,3,25,t,n,e),7)},j=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=String(Math.abs(t)),i=e.length,a="";for(t<0&&(a+="-");i<n;)i+=1,a+="0";return a+e},P=function(t){if(!t||!t.constructor||t.nodeType)return!1;try{return"{}"===JSON.stringify(t)}catch(t){return!0}},Y=function t(){for(var n,e,i,a,o,r=arguments.length,s=new Array(r),h=0;h<r;h++)s[h]=arguments[h];var u=s[0]||{},c=1,d=s.length,p=!1;for("boolean"==typeof u&&(p=u,u=s[c]||{},c+=1),"object"!==C(u)&&I(u)&&(u={}),c===d&&(u=_,c-=1);c<d;c++)if(n=s[c],!x(n)&&null!==n)for(var y=0;y<window.Object.keys(n).length;y++){var l=window.Object.keys(n)[y];if(Object.prototype.hasOwnProperty.call(n,l)){if(i=n[l],"__proto__"===l||u===i)return!0;a=Array.isArray(i),p&&i&&(P(i)||a)?(e=u[l],o=a&&!Array.isArray(e)?[]:a||P(e)?e:{},u[l]=t(p,o,i)):x(i)||(u[l]=i)}}return u},k=function(t,n,e,i,a){var o=t.split(".");t=o.shift()||"div";var r=o,s=window.document.createElement(t);return M(n)?window.document.querySelector(n).appendChild(s):n.appendChild(s),r.length&&(s.className=r.join(" ")),e&&i&&L(s,e,i),x(a)||z(s,a),s},L=function(t,n,e){for(var i=n.split(" "),a=0,o=i.length;a<o;a++)t.addEventListener(i[a],e,!1)},z=function(t,n){t.innerHTML=n},B=function(t,n,e,i,a,o){return b(t)||t<1e3||t>1999?t=i.year:t<a.year?t=a.year:t>o.year&&(t=o.year),b(n)||n<1||n>12?n=i.month:t<=a.year&&n<a.month?n=a.month:t>=o.year&&n>o.month&&(n=o.month),b(e)||e<1?e=i.day:n<=a.month&&e<a.day?e=a.day:n>=o.month&&e>o.day&&(e=o.day),{year:parseInt(t),month:parseInt(n),day:parseInt(e)}},T=function(t,n){if(!t)return!1;var e=t.split(n);return 3===e.length&&4===e[0].length&&2===e[1].length&&2===e[2].length},A=function(t,n){var e=t.split(n);return{year:parseInt(e[0]),month:parseInt(e[1]),day:parseInt(e[2])}},R=function t(n){if(["html","body","#document"].indexOf((n.nodeName||"").toLowerCase())>=0)return window;if(n instanceof HTMLElement){var e=window.getComputedStyle(n),i=e.overflow,a=e.overflowX,o=e.overflowY;if(/auto|scroll|overlay/.test(i+o+a))return n}return t(n.parentNode)},V=function(t){var n=document.createEvent("Event");return n.initEvent(t,!0,!0),n},W=function(t){return 6===t?".".concat("last-week"):""},J=function(t,n){k(u+(n?Q.options.maxDate.year===Q.initDate.year?".".concat(l):"":Q.options.maxDate.year===Q.initDate.year&&Q.options.maxDate.month===Q.initDate.month?".".concat(l):""),t,m,n?function(){Q.increaseYear()}:function(){Q.increaseMonth()},Q.options.plusHtml)},q=function(t,n){k(c+(n?Q.options.minDate.year===Q.initDate.year?".".concat(l):"":Q.options.minDate.year===Q.initDate.year&&Q.options.minDate.month===Q.initDate.month?".".concat(l):""),t,m,n?function(){Q.decreaseYear()}:function(){Q.decreaseMonth()},Q.options.minusHtml)},F=function(){var t=k(e,Q.dpContainer);J(t,!0);var n=k(i,t);q(t,!0);var a=k("input",n,"keyup change",(function(t){Q.yearChange(t.target.value)}));a.tabIndex=-1,a.value=Q.initDate.year,a.type="number"},X=function(){var t=k(a,Q.dpContainer);J(t,!1);var n=k(o,t);q(t,!1);var e=k("select",n,"change",(function(t){Q.monthChange(t.target.value)}));e.tabIndex=-1;for(var i=function(t,n,e){var i=[],a=1,o=12;t.year===n.year?(a=n.month,t.year===e.year&&(o=e.month)):t.year===e.year&&(a=1,o=e.month);for(var r=a;r<=o;r++)i.push(r);return i}(Q.initDate,Q.options.minDate,Q.options.maxDate),r=Q.options.months,s=0;s<i.length;s++){var h=k("option",e);h.value=i[s],h.text=r[i[s]-1],h.selected=i[s]===Q.initDate.month}},G=function(){for(var t=k(r,Q.dpContainer),n=0;n<7;n++)k(h+W(n),t,null,null,Q.options.days[n]);for(var e,i,a=(e=Q.initDate.year,i=Q.initDate.month,[0,31,31,31,31,31,31,30,30,30,30,30,S(e)?30:29][i]),o=N(Q.initDate.year,Q.initDate.month,1),u=7*Math.ceil((o+a)/7)-1,c=1,d=function(n){var e,i,o,r,h=N(Q.initDate.year,Q.initDate.month,c),u=(e=Q.initDate,i=c,o=Q.options.minDate,r=Q.options.maxDate,!(!P(o)||!P(r))||(o.year===r.year&&o.month===r.month?i>=o.day&&i<=r.day:e.year===o.year&&e.month===o.month?i>=o.day:e.year!==r.year||e.month!==r.month||i<=r.day));if(c<=h&&n<h||c>a)return k(s,t),"continue";if(!u)return k(s,t),c+=1,"continue";var d=W(h);Q.valueDate.day===c&&Q.valueDate.year===Q.initDate.year&&Q.valueDate.month===Q.initDate.month&&(d+=".".concat("selected")),Q.today.day===c&&Q.today.year===Q.initDate.year&&Q.today.month===Q.initDate.month&&(d+=".".concat("today"));var p=k(s+d,t,null,null,c);p.day=c,p.addEventListener(m,(function(){Q.setValue(Q.initDate.year,Q.initDate.month,p.day)})),c+=1},p=0;p<=u;p++)d(p)},K=function(){var t=k(d,Q.dpContainer);Q.options.showTodayBtn&&k(p,t,m,(function(){Q.setValue(Q.today.year,Q.today.month,Q.today.day)}),"امروز"),Q.options.showEmptyBtn&&k(y,t,m,(function(){Q.setValue()}),"خالی")},Q=null;var U={days:["ش","ی","د","س","چ","پ","ج"],months:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],initDate:null,minDate:{},maxDate:{},separatorChar:"/",zIndex:1e3,container:"body",dpContainer:null,selector:"input[data-jdp]",autoShow:!0,autoHide:!0,plusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-256v256h-84v-256h-256v-84h256v-256h84v256h256v84z"></path></g></svg>',minusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-596v-84h596v84z"></path></g></svg>',changeMonthRotateYear:!1,showTodayBtn:!0,showEmptyBtn:!0,autoReadOnlyInput:window.innerWidth<=800&&window.innerHeight<=600},Z={init:function(t){var n;this.options=Y(U,t),this.options=tt(this.options),window.onresize=et,this.options.autoHide&&(document.body.onclick=nt),this.options.autoShow&&(n=this.options.selector,Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector,document.body.addEventListener(v,(function(t){t.target&&t.target.matches(n)&&Z.show(t.target)})))},options:U,input:null,get dpContainer(){return this._dpContainer=this._dpContainer||k(n,this.options.container),this._dpContainer},get today(){return this._today=this._today||function(){var t,n,e=new Date,i=parseInt(e.getFullYear()),a=parseInt(e.getMonth())+1,o=parseInt(e.getDate());i>1600?(t=979,i-=1600):(t=0,i-=621);var r=a>2?i+1:i;return n=365*i+parseInt((r+3)/4)-parseInt((r+99)/100)+parseInt((r+399)/400)-80+o+[0,31,59,90,120,151,181,212,243,273,304,334][a-1],t+=33*parseInt(n/12053),n%=12053,t+=4*parseInt(n/1461),(n%=1461)>365&&(t+=parseInt((n-1)/365),n=(n-1)%365),{year:t,month:n<186?1+parseInt(n/31):7+parseInt((n-186)/30),day:1+(n<186?n%31:(n-186)%30)}}(),this._today},get valueDate(){return this._valueDate=E(this.input.value),M(this._valueDate)&&(T(this._valueDate,this.options.separatorChar)?this._valueDate=A(this._valueDate,this.options.separatorChar):this._valueDate={}),this._valueDate},get initDate(){return this._initDate=this._initDate||E(this.valueDate),P(this._initDate)&&(this._initDate=this.options.initDate||E(this.today)),M(this._initDate)&&T(this._initDate,this.options.separatorChar)&&(this._initDate=A(this._initDate,this.options.separatorChar)),B(this._initDate.year,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate)},_draw:function(){z((Q=this).dpContainer,""),F(),X(),G(),K()},show:function(t){this._initDate=null,this._valueDate=null,this.input=t,this._draw(),this.dpContainer.style.visibility=w,this.dpContainer.style.display="block",this.dpContainer.style.zIndex=this.options.zIndex,this.setPosition(),function(t){R(t).addEventListener("scroll",(function(){Z.setPosition()}),{passive:!0})}(t),function(t,n){n.autoReadOnlyInput&&!t.readOnly&&(t.readOnly=!0)}(t,this.options)},hide:function(){this.dpContainer.style.visibility="hidden",this.dpContainer.style.display="none"},setPosition:function(){if(this.dpContainer.style.visibility===w){var t=this.input.getBoundingClientRect(),n=t.left,e=t.top,i=t.height,a=window.document.body.offsetWidth,o=this.dpContainer.offsetWidth,r=this.dpContainer.offsetHeight;n+o>=a&&(n-=n+o-(a+10)),e>=r&&e+r>=window.innerHeight&&(e-=r+i),this.dpContainer.style.position="fixed",this.dpContainer.style.left=n+"px",this.dpContainer.style.top=e+this.input.offsetHeight+"px"}},setValue:function(t,n,e){var i,a,o,r,s,h;this._valueDate.year=t,this._valueDate.month=n,this._valueDate.day=e,this.hide(),isNaN(t+n+e)?this.input.value="":this.input.value=(i=t,a=n,o=e,r=this.options.separatorChar,i+r+j(a)+r+j(o)),s=this.input,h=f,s&&(s.dispatchEvent(V(h)),h===f&&(s.dispatchEvent(V("change")),s.dispatchEvent(V("input"))))},increaseMonth:function(){var t=12===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.increaseYear(),this.monthChange(t?1:this._initDate.month+1)},decreaseMonth:function(){var t=1===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.decreaseYear(),this.monthChange(t?12:this._initDate.month-1)},monthChange:function(t){this._initDate=B(this._initDate.year,t,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()},increaseYear:function(){this.yearChange(this._initDate.year+1)},decreaseYear:function(){this.yearChange(this._initDate.year-1)},yearChange:function(t){this._initDate=B(t,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()}},$=function(t,n){var e=Z.input.getAttribute(t);return e=e===D?E(Z.today):M(e)&&T(e,n)?A(e,n):{}},tt=function(t){return t.minDate===D&&(t.minDate=E(Z.today)),t.maxDate===D&&(t.maxDate=E(Z.today)),t.minDate===g&&(delete t.minDate,window.Object.defineProperty(t,"minDate",{get:function(){return $("data-jdp-min-date",t.separatorChar)}})),t.maxDate===g&&(delete t.maxDate,window.Object.defineProperty(t,"maxDate",{get:function(){return $("data-jdp-max-date",t.separatorChar)}})),t};function nt(t){var n,e,i;Z.dpContainer.style.visibility!==w||(n=Z.dpContainer,(i=(e=t).path||e.composedPath&&e.composedPath()||!1)?-1!==i.indexOf(n):n.outerHTML.indexOf(e.target.outerHTML)>-1)||function(t){try{return I(t.composedPath)?t.composedPath()[0]:t.target}catch(n){return t.target}}(t)===Z.input||Z.hide()}function et(){Z.setPosition()}window.jalaliDatepicker={startWatch:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Z.init(t)},show:function(t){Z.show(t)},hide:function(){Z.hide()}}}()}();

@@ -9,3 +9,3 @@ {

"main": "dist/jalaliDatepicker.min.js",
"version": "0.3.0",
"version": "0.3.1",
"keywords": [

@@ -12,0 +12,0 @@ "date",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc