New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nepali-datepicker-reactjs

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nepali-datepicker-reactjs - npm Package Compare versions

Comparing version 1.0.5 to 1.0.7

dist/Helpers/CalenderData.d.ts

7

dist/index.d.ts

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

import { FC } from "react";
interface DatePickerOptions {
name: string;
}
declare const NepaliDatePicker: FC<DatePickerOptions>;
export default NepaliDatePicker;
export { NepaliDatePicker } from "./NepaliDatePicker";

@@ -1,10 +0,1850 @@

import React, { useRef } from 'react';
import React, { createContext, useReducer, useContext, useMemo, useState, useEffect, useCallback, Fragment, useRef } from 'react';
var NepaliDatePicker = function () {
var dateInputField = useRef(null);
return (React.createElement(React.Fragment, null,
React.createElement("input", { type: "text", ref: dateInputField })));
var Config = {
maxBSYear: 2100,
minBSYear: 1970,
outputSeparator: "-",
bsMonthTotalDaysCount: [
[30, 31],
[31, 32],
[31, 32],
[31, 32],
[31, 32],
[30, 31],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[30, 31],
],
monthReferences: [
[0, 1, 1, 22, 1, 3, 1, 1, 1, 3, 1, 22, 1, 3, 1, 3, 1, 22, 1, 3, 1, 19, 1, 3, 1, 1, 3, 1, 2, 2, 1, 3, 1],
[
1,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
3,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
1,
1,
1,
2,
2,
2,
2,
2,
1,
3,
1,
1,
2,
],
[
0,
1,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
3,
2,
2,
2,
2,
2,
2,
2,
2,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3,
1,
2,
2,
2,
15,
2,
4,
],
[
1,
1,
3,
1,
3,
1,
14,
1,
3,
1,
1,
1,
3,
1,
14,
1,
3,
1,
3,
1,
3,
1,
18,
1,
3,
1,
3,
1,
3,
1,
14,
1,
3,
15,
1,
2,
1,
1,
],
[
0,
1,
1,
3,
1,
3,
1,
10,
1,
3,
1,
3,
1,
1,
1,
3,
1,
3,
1,
10,
1,
3,
1,
3,
1,
3,
1,
3,
1,
14,
1,
3,
1,
3,
1,
3,
1,
3,
1,
10,
1,
20,
1,
1,
1,
],
[
1,
2,
2,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
3,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
20,
3,
],
],
referenceDate: {
AD: "1913-03-13",
BS: "1970-01-01",
},
};
export default NepaliDatePicker;
var Validator = /** @class */ (function () {
function Validator() {
}
Validator.dateType = function (type) {
if (!["BS", "AD"].includes(type)) {
throw new TypeError("Invalid date type. Only 'AD' or 'BS' type supported.");
}
return true;
};
Validator.adYear = function (year) {
var minAdYear = Config.minBSYear - 57;
var maxAdYear = Config.maxBSYear - 57;
if (year < minAdYear || year > maxAdYear) {
throw new RangeError("AD year should be in range of " + minAdYear + " to " + maxAdYear);
}
};
Validator.adMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("AD month should be in range of 1 to 12");
}
};
Validator.adDay = function (day) {
if (day < 1 || day > 31) {
throw new RangeError("AD day should be in range of 1 to 31");
}
};
Validator.bsYear = function (year) {
var midBsYear = Config.minBSYear;
var maxBsYear = Config.maxBSYear;
if (year < midBsYear || year > maxBsYear) {
throw new RangeError("BS year should be in range of " + midBsYear + " to " + maxBsYear);
}
};
Validator.bsMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("BS month should be in range of 1 to 12");
}
};
Validator.bsDay = function (day) {
if (day < 1 || day > 32) {
throw new RangeError("BS day should be in range of 1 to 32");
}
};
return Validator;
}());
var BikramSambat = /** @class */ (function () {
function BikramSambat(date, type) {
if (type === void 0) { type = "AD"; }
this.dateType = "AD";
this.date = { year: 0, month: 0, day: 0 };
if (date) {
this.setDate(date, type);
}
else {
this.setDate(new Date());
}
}
BikramSambat.prototype.setDate = function (date, type) {
if (type === void 0) { type = "AD"; }
Validator.dateType(type);
if (type === "BS") {
if (typeof date !== "string") {
throw new TypeError("BS date should be 'string' type.");
}
this.dateType = "BS";
this.date = this.splitBsDate(date);
return this;
}
this.dateType = "AD";
this.date = this.splitAdDate(date);
return this;
};
BikramSambat.prototype.toAD = function () {
if (this.dateType === "AD") {
return this.format(this.date);
}
var totalDaysSince = this.totalDaysSince();
var _a = this.splitDate(Config.referenceDate.AD), year = _a.year, month = _a.month, day = _a.day;
var adDate = new Date(year, month, day - 1);
adDate.setDate(adDate.getDate() + totalDaysSince);
return this.format(this.splitAdDate(adDate));
};
BikramSambat.prototype.toBS = function () {
if (this.dateType === "BS") {
return this.format(this.date);
}
var _a = this.date, adYear = _a.year, adMonth = _a.month, adDay = _a.day;
var bsYear = adYear + 57;
var bsMonth = (adMonth + 9) % 12 || 12;
var bsDay = 1;
if (adMonth < 4) {
bsYear -= 1;
}
else if (adMonth === 4) {
var bsNewYearAdDate = new BikramSambat(this.format({ year: bsYear, month: 1, day: 1 }), "BS").toAD();
if (adDay < new Date(bsNewYearAdDate).getDate()) {
bsYear -= 1;
}
}
var bsFirstDayOfMonthAdDate = new Date(new BikramSambat(this.format({ year: bsYear, month: bsMonth, day: 1 }), "BS").toAD());
if (adDay >= 1 && adDay < bsFirstDayOfMonthAdDate.getDate()) {
bsMonth = bsMonth !== 1 ? bsMonth - 1 : 12;
var daysInBSMonth = this.daysInBsMonth(bsYear, bsMonth);
bsDay = daysInBSMonth - (bsFirstDayOfMonthAdDate.getDate() - adDay) + 1;
}
else {
bsDay = adDay - bsFirstDayOfMonthAdDate.getDate() + 1;
}
return this.format({ year: bsYear, month: bsMonth, day: bsDay });
};
/**
* Calculate total number of days since minimum reference date
*/
BikramSambat.prototype.totalDaysSince = function () {
var _a = this.date, bsYear = _a.year, bsMonth = _a.month, bsDay = _a.day;
var totalDays = 0;
var diffInYears = bsYear - Config.minBSYear;
for (var i = 1; i <= 12; i++) {
totalDays += this.totalMonthDaysSince(i, i < bsMonth ? diffInYears + 1 : diffInYears);
}
if (bsYear > 2085 && bsYear < 2088) {
totalDays += bsDay - 2;
}
else if (bsYear === 2085 && bsMonth > 5) {
totalDays += bsDay - 2;
}
else if (bsYear > 2088) {
totalDays += bsDay - 4;
}
else if (bsYear === 2088 && bsMonth > 5) {
totalDays += bsDay - 4;
}
else {
totalDays += bsDay;
}
return totalDays;
};
/**
* Total number of bsMonth days since minimum reference date
* @param bsMonth
* @param diffInYear
*/
BikramSambat.prototype.totalMonthDaysSince = function (bsMonth, diffInYear) {
if (diffInYear === 0) {
return 0;
}
var monthData = Config.monthReferences[bsMonth - 1];
var calculated = monthData.slice(0).reduce(function (total, monthDataItem, monthIndex, arr) {
if (monthDataItem === 0) {
return total;
}
var monthTotalDaysCountIndex = monthIndex % 2;
if (diffInYear > total.year + monthDataItem) {
total.year += monthDataItem;
total.month += Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex] * monthDataItem;
}
else {
total.month +=
Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex] * (diffInYear - total.year);
total.year = diffInYear - total.year;
arr.splice(1); // break; dont forget slice(0) before reducing https://stackoverflow.com/questions/36144406/how-to-break-on-reduce-method
}
return total;
}, { month: 0, year: 0 });
return calculated.month;
};
// noinspection JSMethodCanBeStatic
/**
* Returns total number of days in bsMonth for bsYear
* @param bsYear
* @param bsMonth
*/
BikramSambat.prototype.daysInBsMonth = function (bsYear, bsMonth) {
var totalYears = bsYear + 1 - Config.minBSYear;
var monthData = Config.monthReferences[bsMonth - 1];
var yearCount = 0;
for (var i = 0; i < monthData.length; i++) {
if (monthData[i] === 0) {
continue;
}
var monthTotalDaysCountIndex = i % 2;
yearCount += monthData[i];
if (totalYears <= yearCount) {
if ((bsYear === 2085 && bsMonth === 5) || (bsYear === 2088 && bsMonth === 5)) {
return Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex] - 2;
}
else {
return Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex];
}
}
}
return 0;
};
BikramSambat.prototype.splitDate = function (date) {
// tslint:disable-next-line:radix
var _a = date
.replace(/\//g, "-")
.split("-")
.map(function (d) { return Math.floor(Number(d)); }), year = _a[0], month = _a[1], day = _a[2];
return { year: year, month: month, day: day };
};
// noinspection JSMethodCanBeStatic
BikramSambat.prototype.splitAdDate = function (date) {
if (typeof date === "string") {
date = new Date(date);
}
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
Validator.adYear(year);
Validator.adMonth(month);
Validator.adDay(day);
return { year: year, month: month, day: day };
};
BikramSambat.prototype.splitBsDate = function (date) {
var _a = this.splitDate(date), year = _a.year, month = _a.month, day = _a.day;
Validator.bsYear(year);
Validator.bsMonth(month);
Validator.bsDay(day);
return { year: year, month: month, day: day };
};
BikramSambat.prototype.format = function (date) {
var separator = Config.outputSeparator;
var year = date.year, month = date.month, day = date.day;
return "" + year + separator + this.zeroPad(month) + separator + this.zeroPad(day);
};
// noinspection JSMethodCanBeStatic
BikramSambat.prototype.zeroPad = function (x) {
return x > 9 ? "" + x : "0" + x;
};
return BikramSambat;
}());
var BSToAD = function (date) {
return new BikramSambat().setDate(date, "BS").toAD();
};
var ADToBS = function (date) {
return new BikramSambat().setDate(date, "AD").toBS();
};
var months = {
en: [
"Baisakh",
"Jestha",
"Asar",
"Shrawan",
"Bhadra",
"Asoj",
"Kartik",
"Mangsir",
"Pouse",
"Magh",
"Falgun",
"Chaitra",
],
ne: ["बैशाख", "जेठ", "असार", "सावन", "भदौ", "असोज", "कार्तिक", "मंसिर", "पौष", "माघ", "फागुन", "चैत"],
};
var weeks = {
en: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
ne: ["आईत", "सोम", "मंगल", "बुध", "बिही", "शुक्र", "शनि"],
};
var maxBSYear = 2080;
var minBSYear = 2070;
var bsMonthMaxDays = [
[30, 31],
[31, 32],
[31, 32],
[31, 32],
[31, 32],
[30, 31],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[30, 31],
];
var bsMonthCalculatedData = [
[0, 1, 1, 22, 1, 3, 1, 1, 1, 3, 1, 22, 1, 3, 1, 3, 1, 22, 1, 3, 1, 19, 1, 3, 1, 1, 3, 1, 2, 2, 1, 3, 1],
[
1,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
3,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
1,
1,
1,
2,
2,
2,
2,
2,
1,
3,
1,
1,
2,
],
[
0,
1,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
3,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
1,
1,
1,
2,
2,
2,
2,
2,
1,
3,
1,
1,
2,
],
[
1,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
2,
2,
1,
3,
1,
2,
2,
2,
1,
2,
],
[59, 1, 26, 1, 28, 1, 2, 1, 12],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,
2,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
20,
3,
],
];
var CalenderConfig = {
maxBSYear: 2100,
minBSYear: 1970,
outputSeparator: "-",
};
var validateAdYear = function (year) {
var minAdYear = CalenderConfig.minBSYear - 57;
var maxAdYear = CalenderConfig.maxBSYear - 57;
if (year < minAdYear || year > maxAdYear) {
throw new RangeError("AD year should be in range of " + minAdYear + " to " + maxAdYear);
}
};
var validateAdMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("AD month should be in range of 1 to 12");
}
};
var validateAdDay = function (day) {
if (day < 1 || day > 31) {
throw new RangeError("AD day should be in range of 1 to 31");
}
};
var validateBsYear = function (year) {
var midBsYear = CalenderConfig.minBSYear;
var maxBsYear = CalenderConfig.maxBSYear;
if (year < midBsYear || year > maxBsYear) {
throw new RangeError("BS year should be in range of " + midBsYear + " to " + maxBsYear);
}
};
var validateBsMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("BS month should be in range of 1 to 12");
}
};
var validateBsDay = function (day) {
if (day < 1 || day > 32) {
throw new RangeError("BS day should be in range of 1 to 32");
}
};
var range = function (start, end, step) {
if (step === void 0) { step = 1; }
var list = [];
for (var i = start; i <= end; i = i + step) {
list.push(i);
}
return list;
};
var splitDate = function (date, separator) {
if (separator === void 0) { separator = "-"; }
var _a = date.split(separator), year = _a[0], month = _a[1], day = _a[2];
return {
day: parseInt(day, 10),
month: parseInt(month, 10),
year: parseInt(year, 10),
};
};
var stitchDate = function (date, separator) {
if (separator === void 0) { separator = "-"; }
return "" + date.year + separator + date.month + separator + date.day;
};
var validateDateObject = function (date, type) {
if (type === void 0) { type = "BS"; }
var year = date.year, month = date.month, day = date.day;
if (type === "BS") {
validateBsYear(year);
validateBsMonth(month);
validateBsDay(day);
return;
}
validateAdYear(year);
validateAdMonth(month);
validateAdDay(day);
};
var getNumberOfDaysInBSMonth = function (yearMonth) {
var year = yearMonth.year, month = yearMonth.month;
validateBsYear(year);
validateBsMonth(month);
var yearCount = 0;
var totalYears = year + 1 - minBSYear;
var bsMonthData = bsMonthCalculatedData[month - 1];
return bsMonthData.reduce(function (numberOfDays, monthData, index) {
if (monthData === 0 || numberOfDays !== 0) {
return numberOfDays;
}
var bsMonthUpperDaysIndex = index % 2;
yearCount += monthData;
if (totalYears > yearCount) {
return numberOfDays;
}
if ((year === 2085 && month === 5) || (year === 2088 && month === 5)) {
return bsMonthMaxDays[month - 1][bsMonthUpperDaysIndex] - 2;
}
return bsMonthMaxDays[month - 1][bsMonthUpperDaysIndex];
}, 0);
};
var parseBSDate = function (date, separator) {
if (separator === void 0) { separator = "-"; }
var _a = splitDate(date, separator), year = _a.year, month = _a.month, day = _a.day;
validateDateObject({ year: year, month: month, day: day });
var adDate = new Date(BSToAD(date));
var firstAdDateInBSMonth = new Date(BSToAD(stitchDate({ year: year, month: month, day: 1 }, separator)));
var numberOfDaysInMonth = getNumberOfDaysInBSMonth({ year: year, month: month });
return {
adDate: adDate,
bsDay: day,
bsMonth: month,
bsYear: year,
firstAdDayInBSMonth: firstAdDateInBSMonth,
numberOfDaysInBSMonth: numberOfDaysInMonth,
weekDay: adDate.getDay(),
};
};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
var SET_CONFIG = "set_config";
var initialState = {
currentLocale: "en",
selectedDate: {
adDate: new Date(),
bsDay: 0,
bsMonth: 0,
bsYear: 0,
firstAdDayInBSMonth: new Date(),
numberOfDaysInBSMonth: 0,
weekDay: 0,
},
};
var reducer = function (state, action) {
var _a;
if (state === void 0) { state = initialState; }
if (action.type === SET_CONFIG) {
return __assign(__assign({}, state), (_a = {}, _a[action.key] = action.value, _a));
}
return state;
};
var ConfigContext = createContext({
dispatch: function () { return null; },
state: initialState,
});
var ConfigProvider = function (_a) {
var children = _a.children;
var _b = useReducer(reducer, initialState), state = _b[0], dispatch = _b[1];
var contextValue = { state: state, dispatch: dispatch };
return React.createElement(ConfigContext.Provider, { value: contextValue }, children);
};
var useConfig = function () {
var _a = useContext(ConfigContext), state = _a.state, dispatch = _a.dispatch;
function setConfig(key, value) {
dispatch({
key: key,
type: SET_CONFIG,
value: value,
});
}
function getConfig(key) {
return state[key];
}
return {
getConfig: getConfig,
setConfig: setConfig,
};
};
var IconBase = function (props) {
var size = props.size, viewBoxSize = props.viewBoxSize, options = __rest(props, ["size", "viewBoxSize"]);
return (React.createElement("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", width: props.size, height: props.size }, options, { viewBox: "0 0 " + props.viewBoxSize + " " + props.viewBoxSize }), props.children));
};
IconBase.defaultProps = {
color: "currentColor",
size: "24",
viewBoxSize: "24",
};
var Next = function (props) {
var rotationOrigin = parseInt(props.size || "24", 10) / 2;
return (React.createElement(IconBase, __assign({}, props),
React.createElement("path", { transform: "rotate(180 " + rotationOrigin + " " + rotationOrigin + ")", fill: "none", fillRule: "evenodd", stroke: "currentcolor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.4", d: "M16.283 18.907L9.6 12l6.683-5.438" })));
};
var Previous = function (props) { return (React.createElement(IconBase, __assign({}, props),
React.createElement("path", { fill: "none", fillRule: "evenodd", stroke: "currentcolor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.4", d: "M16.283 18.907L9.6 12l6.683-5.438" }))); };
var Today = function (props) {
props = __assign(__assign({}, props), { viewBoxSize: "512", size: "15" });
return (React.createElement(IconBase, __assign({}, props),
React.createElement("defs", null,
React.createElement("path", { id: "a", d: "M468 160H44c-6.6 0-12-5.4-12-12v-36c0-26.5 21.5-48 48-48h48V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h128V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h48c26.5 0 48 21.5 48 48v36c0 6.6-5.4 12-12 12zM44 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H80c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm116 204c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm0-128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm128 128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm0-128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm128 128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm0-128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40z" })),
React.createElement("g", { fill: "none", fillRule: "evenodd" },
React.createElement("mask", { id: "b", fill: "#fff" },
React.createElement("use", { xlinkHref: "#a" })),
React.createElement("use", { fill: "#000", fillRule: "nonzero", xlinkHref: "#a" }),
React.createElement("g", { fill: "currentcolor", mask: "url(#b)" },
React.createElement("path", { d: "M0 0h512v512H0z" })))));
};
var DropDown = function (_a) {
var options = _a.options, value = _a.value;
return (React.createElement("div", { className: "drop-down-content" },
React.createElement("div", { className: "option-wrapper" },
React.createElement("ul", null, options.map(function (option, index) { return (React.createElement("li", { key: index, className: option.value === value ? "active" : "" }, option.label)); })))));
};
var MonthPicker = function () {
var getConfig = useConfig().getConfig;
var currentLocale = useMemo(function () { return getConfig("currentLocale"); }, []);
var currentMonth = useMemo(function () {
var month = getConfig("selectedDate").bsMonth - 1;
return {
label: months[currentLocale][month],
value: month,
};
}, []);
var monthList = useMemo(function () {
return months[currentLocale].map(function (month, index) { return ({
label: month,
value: index,
}); });
}, []);
return (React.createElement("div", { className: "control month" },
React.createElement("span", { className: "current-month" }, currentMonth.label),
React.createElement(DropDown, { options: monthList, value: currentMonth.value })));
};
var YearPicker = function () {
var getConfig = useConfig().getConfig;
var currentYear = useMemo(function () {
var year = getConfig("selectedDate").bsYear;
return {
label: year.toString(),
value: year,
};
}, []);
var years = useMemo(function () {
return range(minBSYear, maxBSYear).map(function (year) { return ({
label: year.toString(),
value: year,
}); });
}, []);
return (React.createElement("div", { className: "control year" },
React.createElement("span", { className: "current-year" }, currentYear.label),
React.createElement(DropDown, { options: years, value: currentYear.value })));
};
var CalenderController = function () {
return (React.createElement("div", { className: "calendar-controller" },
React.createElement("span", { className: "control icon", title: "prev" },
React.createElement(Previous, null)),
React.createElement("span", { className: "control icon", title: "today" },
React.createElement(Today, null)),
React.createElement(MonthPicker, null),
React.createElement(YearPicker, null),
React.createElement("span", { className: "control icon", title: "next" },
React.createElement(Next, null))));
};
var DayPickerBody = function () {
var getConfig = useConfig().getConfig;
var _a = useState({
adDate: new Date(),
bsDay: 0,
bsMonth: 0,
bsYear: 0,
firstAdDayInBSMonth: new Date(),
numberOfDaysInBSMonth: 0,
weekDay: 0,
}), date = _a[0], setDate = _a[1];
var weeksInMonth = useMemo(function () { return Math.ceil((date.firstAdDayInBSMonth.getDay() + date.numberOfDaysInBSMonth) / 7); }, [date]);
var previousMonth = useMemo(function () { return (date.bsMonth - 1 !== 0 ? date.bsMonth - 1 : 12); }, [date]);
var previousYear = useMemo(function () { return (previousMonth === 12 ? date.bsYear - 1 : date.bsYear); }, [date]);
var previousMonthDays = useMemo(function () {
return previousYear >= minBSYear
? getNumberOfDaysInBSMonth({
month: previousMonth,
year: previousYear,
})
: 30;
}, []);
useEffect(function () {
setDate(getConfig("selectedDate"));
}, []);
var dayInfo = useCallback(function (weekNum, weekDayNum) {
var calenderDate = weekNum * 7 + weekDayNum - date.firstAdDayInBSMonth.getDay();
var isCurrentMonth = true;
if (calenderDate <= 0) {
calenderDate = previousMonthDays + calenderDate;
isCurrentMonth = false;
}
else if (calenderDate > date.numberOfDaysInBSMonth) {
calenderDate = calenderDate - date.numberOfDaysInBSMonth;
isCurrentMonth = false;
}
var today = splitDate(ADToBS(new Date()));
// tslint:disable-next-line:no-console
console.log(today);
var isToday = isCurrentMonth
? today.day === calenderDate && today.month === date.bsMonth && today.year === date.bsYear
: false;
var isSelected = isCurrentMonth
? date.bsDay === calenderDate && today.month === date.bsMonth && today.year === date.bsYear
: false;
return { calenderDate: calenderDate, isCurrentMonth: isCurrentMonth, isToday: isToday, isSelected: isSelected };
}, [date]);
return (React.createElement("tbody", null, range(0, weeksInMonth).map(function (weekNum) { return (React.createElement("tr", { key: weekNum }, range(1, 7).map(function (weekDayNum) {
var day = dayInfo(weekNum, weekDayNum);
return (React.createElement("td", { key: weekDayNum, className: "month-day " + (day.isCurrentMonth ? "current" : "previous") + " " + (day.isToday ? "today" : "") + " " + (day.isSelected ? "selected" : "") }, day.calenderDate));
}))); })));
};
var DayPickerHeader = function () {
var getConfig = useConfig().getConfig;
var currentLocale = useMemo(function () { return getConfig("currentLocale"); }, []);
return (React.createElement("thead", null,
React.createElement("tr", null, weeks[currentLocale].map(function (weekDay, index) { return (React.createElement("td", { key: index }, weekDay)); }))));
};
var DayPicker = function () {
return (React.createElement("table", null,
React.createElement(DayPickerHeader, null),
React.createElement(DayPickerBody, null)));
};
var Calender = function (_a) {
var value = _a.value;
var setConfig = useConfig().setConfig;
var _b = useState(false), isInitialized = _b[0], setIsInitialized = _b[1];
useEffect(function () {
setConfig("currentLocale", "ne");
setConfig("selectedDate", parseBSDate(value));
setIsInitialized(true);
}, []);
return (React.createElement("div", { className: "nepali-date-picker" },
React.createElement("div", { className: "calendar-wrapper" }, isInitialized && (React.createElement(Fragment, null,
React.createElement(CalenderController, null),
React.createElement(DayPicker, null))))));
};
function styleInject(css, ref) {
if ( ref === void 0 ) ref = {};
var insertAt = ref.insertAt;
if (!css || typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
var css = ".nepali-date-picker {\n background: #fff none repeat scroll 0 0;\n border: 1px solid #cccccc;\n border-radius: 6px;\n box-shadow: 0 4px 8px 0 rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n color: #1b1b25;\n display: block;\n font-family: NotoSans, serif;\n font-size: 15px;\n font-style: normal;\n font-weight: normal;\n height: 240px;\n letter-spacing: 0.2px;\n line-height: 1.25em;\n padding: 15px;\n position: absolute;\n text-align: right;\n user-select: none;\n width: 280px;\n z-index: 9999; }\n .nepali-date-picker .calendar-controller {\n display: flex;\n justify-content: space-between; }\n .nepali-date-picker .calendar-controller .control {\n cursor: pointer; }\n .nepali-date-picker .calendar-controller .control.icon {\n align-items: center;\n color: #006d12;\n display: inline-flex;\n height: 24px;\n justify-content: center;\n width: 24px; }\n .nepali-date-picker .calendar-controller .control.month, .nepali-date-picker .calendar-controller .control.year {\n line-height: 24px; }\n .nepali-date-picker .calendar-controller .control.year {\n font-weight: bold; }\n";
styleInject(css);
var NepaliDatePicker = function (_a) {
var className = _a.className;
var dateEl = useRef(null);
var value = "2076-07-14";
return (React.createElement(ConfigProvider, null,
React.createElement("input", { type: "text", className: className, readOnly: true, ref: dateEl, value: value }),
React.createElement(Calender, { value: value })));
};
NepaliDatePicker.defaultProps = {
className: "",
};
export { NepaliDatePicker };
//# sourceMappingURL=index.es.js.map

@@ -10,9 +10,1849 @@ 'use strict';

var NepaliDatePicker = function () {
var dateInputField = React.useRef(null);
return (React__default.createElement(React__default.Fragment, null,
React__default.createElement("input", { type: "text", ref: dateInputField })));
var Config = {
maxBSYear: 2100,
minBSYear: 1970,
outputSeparator: "-",
bsMonthTotalDaysCount: [
[30, 31],
[31, 32],
[31, 32],
[31, 32],
[31, 32],
[30, 31],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[30, 31],
],
monthReferences: [
[0, 1, 1, 22, 1, 3, 1, 1, 1, 3, 1, 22, 1, 3, 1, 3, 1, 22, 1, 3, 1, 19, 1, 3, 1, 1, 3, 1, 2, 2, 1, 3, 1],
[
1,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
3,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
1,
1,
1,
2,
2,
2,
2,
2,
1,
3,
1,
1,
2,
],
[
0,
1,
2,
1,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2,
2,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
15,
2,
4,
],
[
1,
1,
3,
1,
3,
1,
14,
1,
3,
1,
1,
1,
3,
1,
14,
1,
3,
1,
3,
1,
3,
1,
18,
1,
3,
1,
3,
1,
3,
1,
14,
1,
3,
15,
1,
2,
1,
1,
],
[
0,
1,
1,
3,
1,
3,
1,
10,
1,
3,
1,
3,
1,
1,
1,
3,
1,
3,
1,
10,
1,
3,
1,
3,
1,
3,
1,
3,
1,
14,
1,
3,
1,
3,
1,
3,
1,
3,
1,
10,
1,
20,
1,
1,
1,
],
[
1,
2,
2,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
3,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
20,
3,
],
],
referenceDate: {
AD: "1913-03-13",
BS: "1970-01-01",
},
};
exports.default = NepaliDatePicker;
var Validator = /** @class */ (function () {
function Validator() {
}
Validator.dateType = function (type) {
if (!["BS", "AD"].includes(type)) {
throw new TypeError("Invalid date type. Only 'AD' or 'BS' type supported.");
}
return true;
};
Validator.adYear = function (year) {
var minAdYear = Config.minBSYear - 57;
var maxAdYear = Config.maxBSYear - 57;
if (year < minAdYear || year > maxAdYear) {
throw new RangeError("AD year should be in range of " + minAdYear + " to " + maxAdYear);
}
};
Validator.adMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("AD month should be in range of 1 to 12");
}
};
Validator.adDay = function (day) {
if (day < 1 || day > 31) {
throw new RangeError("AD day should be in range of 1 to 31");
}
};
Validator.bsYear = function (year) {
var midBsYear = Config.minBSYear;
var maxBsYear = Config.maxBSYear;
if (year < midBsYear || year > maxBsYear) {
throw new RangeError("BS year should be in range of " + midBsYear + " to " + maxBsYear);
}
};
Validator.bsMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("BS month should be in range of 1 to 12");
}
};
Validator.bsDay = function (day) {
if (day < 1 || day > 32) {
throw new RangeError("BS day should be in range of 1 to 32");
}
};
return Validator;
}());
var BikramSambat = /** @class */ (function () {
function BikramSambat(date, type) {
if (type === void 0) { type = "AD"; }
this.dateType = "AD";
this.date = { year: 0, month: 0, day: 0 };
if (date) {
this.setDate(date, type);
}
else {
this.setDate(new Date());
}
}
BikramSambat.prototype.setDate = function (date, type) {
if (type === void 0) { type = "AD"; }
Validator.dateType(type);
if (type === "BS") {
if (typeof date !== "string") {
throw new TypeError("BS date should be 'string' type.");
}
this.dateType = "BS";
this.date = this.splitBsDate(date);
return this;
}
this.dateType = "AD";
this.date = this.splitAdDate(date);
return this;
};
BikramSambat.prototype.toAD = function () {
if (this.dateType === "AD") {
return this.format(this.date);
}
var totalDaysSince = this.totalDaysSince();
var _a = this.splitDate(Config.referenceDate.AD), year = _a.year, month = _a.month, day = _a.day;
var adDate = new Date(year, month, day - 1);
adDate.setDate(adDate.getDate() + totalDaysSince);
return this.format(this.splitAdDate(adDate));
};
BikramSambat.prototype.toBS = function () {
if (this.dateType === "BS") {
return this.format(this.date);
}
var _a = this.date, adYear = _a.year, adMonth = _a.month, adDay = _a.day;
var bsYear = adYear + 57;
var bsMonth = (adMonth + 9) % 12 || 12;
var bsDay = 1;
if (adMonth < 4) {
bsYear -= 1;
}
else if (adMonth === 4) {
var bsNewYearAdDate = new BikramSambat(this.format({ year: bsYear, month: 1, day: 1 }), "BS").toAD();
if (adDay < new Date(bsNewYearAdDate).getDate()) {
bsYear -= 1;
}
}
var bsFirstDayOfMonthAdDate = new Date(new BikramSambat(this.format({ year: bsYear, month: bsMonth, day: 1 }), "BS").toAD());
if (adDay >= 1 && adDay < bsFirstDayOfMonthAdDate.getDate()) {
bsMonth = bsMonth !== 1 ? bsMonth - 1 : 12;
var daysInBSMonth = this.daysInBsMonth(bsYear, bsMonth);
bsDay = daysInBSMonth - (bsFirstDayOfMonthAdDate.getDate() - adDay) + 1;
}
else {
bsDay = adDay - bsFirstDayOfMonthAdDate.getDate() + 1;
}
return this.format({ year: bsYear, month: bsMonth, day: bsDay });
};
/**
* Calculate total number of days since minimum reference date
*/
BikramSambat.prototype.totalDaysSince = function () {
var _a = this.date, bsYear = _a.year, bsMonth = _a.month, bsDay = _a.day;
var totalDays = 0;
var diffInYears = bsYear - Config.minBSYear;
for (var i = 1; i <= 12; i++) {
totalDays += this.totalMonthDaysSince(i, i < bsMonth ? diffInYears + 1 : diffInYears);
}
if (bsYear > 2085 && bsYear < 2088) {
totalDays += bsDay - 2;
}
else if (bsYear === 2085 && bsMonth > 5) {
totalDays += bsDay - 2;
}
else if (bsYear > 2088) {
totalDays += bsDay - 4;
}
else if (bsYear === 2088 && bsMonth > 5) {
totalDays += bsDay - 4;
}
else {
totalDays += bsDay;
}
return totalDays;
};
/**
* Total number of bsMonth days since minimum reference date
* @param bsMonth
* @param diffInYear
*/
BikramSambat.prototype.totalMonthDaysSince = function (bsMonth, diffInYear) {
if (diffInYear === 0) {
return 0;
}
var monthData = Config.monthReferences[bsMonth - 1];
var calculated = monthData.slice(0).reduce(function (total, monthDataItem, monthIndex, arr) {
if (monthDataItem === 0) {
return total;
}
var monthTotalDaysCountIndex = monthIndex % 2;
if (diffInYear > total.year + monthDataItem) {
total.year += monthDataItem;
total.month += Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex] * monthDataItem;
}
else {
total.month +=
Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex] * (diffInYear - total.year);
total.year = diffInYear - total.year;
arr.splice(1); // break; dont forget slice(0) before reducing https://stackoverflow.com/questions/36144406/how-to-break-on-reduce-method
}
return total;
}, { month: 0, year: 0 });
return calculated.month;
};
// noinspection JSMethodCanBeStatic
/**
* Returns total number of days in bsMonth for bsYear
* @param bsYear
* @param bsMonth
*/
BikramSambat.prototype.daysInBsMonth = function (bsYear, bsMonth) {
var totalYears = bsYear + 1 - Config.minBSYear;
var monthData = Config.monthReferences[bsMonth - 1];
var yearCount = 0;
for (var i = 0; i < monthData.length; i++) {
if (monthData[i] === 0) {
continue;
}
var monthTotalDaysCountIndex = i % 2;
yearCount += monthData[i];
if (totalYears <= yearCount) {
if ((bsYear === 2085 && bsMonth === 5) || (bsYear === 2088 && bsMonth === 5)) {
return Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex] - 2;
}
else {
return Config.bsMonthTotalDaysCount[bsMonth - 1][monthTotalDaysCountIndex];
}
}
}
return 0;
};
BikramSambat.prototype.splitDate = function (date) {
// tslint:disable-next-line:radix
var _a = date
.replace(/\//g, "-")
.split("-")
.map(function (d) { return Math.floor(Number(d)); }), year = _a[0], month = _a[1], day = _a[2];
return { year: year, month: month, day: day };
};
// noinspection JSMethodCanBeStatic
BikramSambat.prototype.splitAdDate = function (date) {
if (typeof date === "string") {
date = new Date(date);
}
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
Validator.adYear(year);
Validator.adMonth(month);
Validator.adDay(day);
return { year: year, month: month, day: day };
};
BikramSambat.prototype.splitBsDate = function (date) {
var _a = this.splitDate(date), year = _a.year, month = _a.month, day = _a.day;
Validator.bsYear(year);
Validator.bsMonth(month);
Validator.bsDay(day);
return { year: year, month: month, day: day };
};
BikramSambat.prototype.format = function (date) {
var separator = Config.outputSeparator;
var year = date.year, month = date.month, day = date.day;
return "" + year + separator + this.zeroPad(month) + separator + this.zeroPad(day);
};
// noinspection JSMethodCanBeStatic
BikramSambat.prototype.zeroPad = function (x) {
return x > 9 ? "" + x : "0" + x;
};
return BikramSambat;
}());
var BSToAD = function (date) {
return new BikramSambat().setDate(date, "BS").toAD();
};
var ADToBS = function (date) {
return new BikramSambat().setDate(date, "AD").toBS();
};
var months = {
en: [
"Baisakh",
"Jestha",
"Asar",
"Shrawan",
"Bhadra",
"Asoj",
"Kartik",
"Mangsir",
"Pouse",
"Magh",
"Falgun",
"Chaitra",
],
ne: ["बैशाख", "जेठ", "असार", "सावन", "भदौ", "असोज", "कार्तिक", "मंसिर", "पौष", "माघ", "फागुन", "चैत"],
};
var weeks = {
en: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
ne: ["आईत", "सोम", "मंगल", "बुध", "बिही", "शुक्र", "शनि"],
};
var maxBSYear = 2080;
var minBSYear = 2070;
var bsMonthMaxDays = [
[30, 31],
[31, 32],
[31, 32],
[31, 32],
[31, 32],
[30, 31],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[29, 30],
[30, 31],
];
var bsMonthCalculatedData = [
[0, 1, 1, 22, 1, 3, 1, 1, 1, 3, 1, 22, 1, 3, 1, 3, 1, 22, 1, 3, 1, 19, 1, 3, 1, 1, 3, 1, 2, 2, 1, 3, 1],
[
1,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
3,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
2,
2,
2,
2,
2,
1,
1,
1,
2,
2,
2,
2,
2,
1,
3,
1,
1,
2,
],
[
0,
1,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
3,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
1,
1,
1,
2,
2,
2,
2,
2,
1,
3,
1,
1,
2,
],
[
1,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
3,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,
1,
2,
2,
2,
2,
2,
3,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
3,
1,
3,
1,
2,
2,
2,
2,
2,
2,
2,
1,
3,
1,
3,
1,
20,
3,
],
];
var CalenderConfig = {
maxBSYear: 2100,
minBSYear: 1970,
outputSeparator: "-",
};
var validateAdYear = function (year) {
var minAdYear = CalenderConfig.minBSYear - 57;
var maxAdYear = CalenderConfig.maxBSYear - 57;
if (year < minAdYear || year > maxAdYear) {
throw new RangeError("AD year should be in range of " + minAdYear + " to " + maxAdYear);
}
};
var validateAdMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("AD month should be in range of 1 to 12");
}
};
var validateAdDay = function (day) {
if (day < 1 || day > 31) {
throw new RangeError("AD day should be in range of 1 to 31");
}
};
var validateBsYear = function (year) {
var midBsYear = CalenderConfig.minBSYear;
var maxBsYear = CalenderConfig.maxBSYear;
if (year < midBsYear || year > maxBsYear) {
throw new RangeError("BS year should be in range of " + midBsYear + " to " + maxBsYear);
}
};
var validateBsMonth = function (month) {
if (month < 1 || month > 12) {
throw new RangeError("BS month should be in range of 1 to 12");
}
};
var validateBsDay = function (day) {
if (day < 1 || day > 32) {
throw new RangeError("BS day should be in range of 1 to 32");
}
};
var range = function (start, end, step) {
if (step === void 0) { step = 1; }
var list = [];
for (var i = start; i <= end; i = i + step) {
list.push(i);
}
return list;
};
var splitDate = function (date, separator) {
if (separator === void 0) { separator = "-"; }
var _a = date.split(separator), year = _a[0], month = _a[1], day = _a[2];
return {
day: parseInt(day, 10),
month: parseInt(month, 10),
year: parseInt(year, 10),
};
};
var stitchDate = function (date, separator) {
if (separator === void 0) { separator = "-"; }
return "" + date.year + separator + date.month + separator + date.day;
};
var validateDateObject = function (date, type) {
if (type === void 0) { type = "BS"; }
var year = date.year, month = date.month, day = date.day;
if (type === "BS") {
validateBsYear(year);
validateBsMonth(month);
validateBsDay(day);
return;
}
validateAdYear(year);
validateAdMonth(month);
validateAdDay(day);
};
var getNumberOfDaysInBSMonth = function (yearMonth) {
var year = yearMonth.year, month = yearMonth.month;
validateBsYear(year);
validateBsMonth(month);
var yearCount = 0;
var totalYears = year + 1 - minBSYear;
var bsMonthData = bsMonthCalculatedData[month - 1];
return bsMonthData.reduce(function (numberOfDays, monthData, index) {
if (monthData === 0 || numberOfDays !== 0) {
return numberOfDays;
}
var bsMonthUpperDaysIndex = index % 2;
yearCount += monthData;
if (totalYears > yearCount) {
return numberOfDays;
}
if ((year === 2085 && month === 5) || (year === 2088 && month === 5)) {
return bsMonthMaxDays[month - 1][bsMonthUpperDaysIndex] - 2;
}
return bsMonthMaxDays[month - 1][bsMonthUpperDaysIndex];
}, 0);
};
var parseBSDate = function (date, separator) {
if (separator === void 0) { separator = "-"; }
var _a = splitDate(date, separator), year = _a.year, month = _a.month, day = _a.day;
validateDateObject({ year: year, month: month, day: day });
var adDate = new Date(BSToAD(date));
var firstAdDateInBSMonth = new Date(BSToAD(stitchDate({ year: year, month: month, day: 1 }, separator)));
var numberOfDaysInMonth = getNumberOfDaysInBSMonth({ year: year, month: month });
return {
adDate: adDate,
bsDay: day,
bsMonth: month,
bsYear: year,
firstAdDayInBSMonth: firstAdDateInBSMonth,
numberOfDaysInBSMonth: numberOfDaysInMonth,
weekDay: adDate.getDay(),
};
};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
var SET_CONFIG = "set_config";
var initialState = {
currentLocale: "en",
selectedDate: {
adDate: new Date(),
bsDay: 0,
bsMonth: 0,
bsYear: 0,
firstAdDayInBSMonth: new Date(),
numberOfDaysInBSMonth: 0,
weekDay: 0,
},
};
var reducer = function (state, action) {
var _a;
if (state === void 0) { state = initialState; }
if (action.type === SET_CONFIG) {
return __assign(__assign({}, state), (_a = {}, _a[action.key] = action.value, _a));
}
return state;
};
var ConfigContext = React.createContext({
dispatch: function () { return null; },
state: initialState,
});
var ConfigProvider = function (_a) {
var children = _a.children;
var _b = React.useReducer(reducer, initialState), state = _b[0], dispatch = _b[1];
var contextValue = { state: state, dispatch: dispatch };
return React__default.createElement(ConfigContext.Provider, { value: contextValue }, children);
};
var useConfig = function () {
var _a = React.useContext(ConfigContext), state = _a.state, dispatch = _a.dispatch;
function setConfig(key, value) {
dispatch({
key: key,
type: SET_CONFIG,
value: value,
});
}
function getConfig(key) {
return state[key];
}
return {
getConfig: getConfig,
setConfig: setConfig,
};
};
var IconBase = function (props) {
var size = props.size, viewBoxSize = props.viewBoxSize, options = __rest(props, ["size", "viewBoxSize"]);
return (React__default.createElement("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", width: props.size, height: props.size }, options, { viewBox: "0 0 " + props.viewBoxSize + " " + props.viewBoxSize }), props.children));
};
IconBase.defaultProps = {
color: "currentColor",
size: "24",
viewBoxSize: "24",
};
var Next = function (props) {
var rotationOrigin = parseInt(props.size || "24", 10) / 2;
return (React__default.createElement(IconBase, __assign({}, props),
React__default.createElement("path", { transform: "rotate(180 " + rotationOrigin + " " + rotationOrigin + ")", fill: "none", fillRule: "evenodd", stroke: "currentcolor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.4", d: "M16.283 18.907L9.6 12l6.683-5.438" })));
};
var Previous = function (props) { return (React__default.createElement(IconBase, __assign({}, props),
React__default.createElement("path", { fill: "none", fillRule: "evenodd", stroke: "currentcolor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.4", d: "M16.283 18.907L9.6 12l6.683-5.438" }))); };
var Today = function (props) {
props = __assign(__assign({}, props), { viewBoxSize: "512", size: "15" });
return (React__default.createElement(IconBase, __assign({}, props),
React__default.createElement("defs", null,
React__default.createElement("path", { id: "a", d: "M468 160H44c-6.6 0-12-5.4-12-12v-36c0-26.5 21.5-48 48-48h48V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h128V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h48c26.5 0 48 21.5 48 48v36c0 6.6-5.4 12-12 12zM44 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H80c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm116 204c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm0-128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm128 128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm0-128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm128 128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40zm0-128c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-40z" })),
React__default.createElement("g", { fill: "none", fillRule: "evenodd" },
React__default.createElement("mask", { id: "b", fill: "#fff" },
React__default.createElement("use", { xlinkHref: "#a" })),
React__default.createElement("use", { fill: "#000", fillRule: "nonzero", xlinkHref: "#a" }),
React__default.createElement("g", { fill: "currentcolor", mask: "url(#b)" },
React__default.createElement("path", { d: "M0 0h512v512H0z" })))));
};
var DropDown = function (_a) {
var options = _a.options, value = _a.value;
return (React__default.createElement("div", { className: "drop-down-content" },
React__default.createElement("div", { className: "option-wrapper" },
React__default.createElement("ul", null, options.map(function (option, index) { return (React__default.createElement("li", { key: index, className: option.value === value ? "active" : "" }, option.label)); })))));
};
var MonthPicker = function () {
var getConfig = useConfig().getConfig;
var currentLocale = React.useMemo(function () { return getConfig("currentLocale"); }, []);
var currentMonth = React.useMemo(function () {
var month = getConfig("selectedDate").bsMonth - 1;
return {
label: months[currentLocale][month],
value: month,
};
}, []);
var monthList = React.useMemo(function () {
return months[currentLocale].map(function (month, index) { return ({
label: month,
value: index,
}); });
}, []);
return (React__default.createElement("div", { className: "control month" },
React__default.createElement("span", { className: "current-month" }, currentMonth.label),
React__default.createElement(DropDown, { options: monthList, value: currentMonth.value })));
};
var YearPicker = function () {
var getConfig = useConfig().getConfig;
var currentYear = React.useMemo(function () {
var year = getConfig("selectedDate").bsYear;
return {
label: year.toString(),
value: year,
};
}, []);
var years = React.useMemo(function () {
return range(minBSYear, maxBSYear).map(function (year) { return ({
label: year.toString(),
value: year,
}); });
}, []);
return (React__default.createElement("div", { className: "control year" },
React__default.createElement("span", { className: "current-year" }, currentYear.label),
React__default.createElement(DropDown, { options: years, value: currentYear.value })));
};
var CalenderController = function () {
return (React__default.createElement("div", { className: "calendar-controller" },
React__default.createElement("span", { className: "control icon", title: "prev" },
React__default.createElement(Previous, null)),
React__default.createElement("span", { className: "control icon", title: "today" },
React__default.createElement(Today, null)),
React__default.createElement(MonthPicker, null),
React__default.createElement(YearPicker, null),
React__default.createElement("span", { className: "control icon", title: "next" },
React__default.createElement(Next, null))));
};
var DayPickerBody = function () {
var getConfig = useConfig().getConfig;
var _a = React.useState({
adDate: new Date(),
bsDay: 0,
bsMonth: 0,
bsYear: 0,
firstAdDayInBSMonth: new Date(),
numberOfDaysInBSMonth: 0,
weekDay: 0,
}), date = _a[0], setDate = _a[1];
var weeksInMonth = React.useMemo(function () { return Math.ceil((date.firstAdDayInBSMonth.getDay() + date.numberOfDaysInBSMonth) / 7); }, [date]);
var previousMonth = React.useMemo(function () { return (date.bsMonth - 1 !== 0 ? date.bsMonth - 1 : 12); }, [date]);
var previousYear = React.useMemo(function () { return (previousMonth === 12 ? date.bsYear - 1 : date.bsYear); }, [date]);
var previousMonthDays = React.useMemo(function () {
return previousYear >= minBSYear
? getNumberOfDaysInBSMonth({
month: previousMonth,
year: previousYear,
})
: 30;
}, []);
React.useEffect(function () {
setDate(getConfig("selectedDate"));
}, []);
var dayInfo = React.useCallback(function (weekNum, weekDayNum) {
var calenderDate = weekNum * 7 + weekDayNum - date.firstAdDayInBSMonth.getDay();
var isCurrentMonth = true;
if (calenderDate <= 0) {
calenderDate = previousMonthDays + calenderDate;
isCurrentMonth = false;
}
else if (calenderDate > date.numberOfDaysInBSMonth) {
calenderDate = calenderDate - date.numberOfDaysInBSMonth;
isCurrentMonth = false;
}
var today = splitDate(ADToBS(new Date()));
// tslint:disable-next-line:no-console
console.log(today);
var isToday = isCurrentMonth
? today.day === calenderDate && today.month === date.bsMonth && today.year === date.bsYear
: false;
var isSelected = isCurrentMonth
? date.bsDay === calenderDate && today.month === date.bsMonth && today.year === date.bsYear
: false;
return { calenderDate: calenderDate, isCurrentMonth: isCurrentMonth, isToday: isToday, isSelected: isSelected };
}, [date]);
return (React__default.createElement("tbody", null, range(0, weeksInMonth).map(function (weekNum) { return (React__default.createElement("tr", { key: weekNum }, range(1, 7).map(function (weekDayNum) {
var day = dayInfo(weekNum, weekDayNum);
return (React__default.createElement("td", { key: weekDayNum, className: "month-day " + (day.isCurrentMonth ? "current" : "previous") + " " + (day.isToday ? "today" : "") + " " + (day.isSelected ? "selected" : "") }, day.calenderDate));
}))); })));
};
var DayPickerHeader = function () {
var getConfig = useConfig().getConfig;
var currentLocale = React.useMemo(function () { return getConfig("currentLocale"); }, []);
return (React__default.createElement("thead", null,
React__default.createElement("tr", null, weeks[currentLocale].map(function (weekDay, index) { return (React__default.createElement("td", { key: index }, weekDay)); }))));
};
var DayPicker = function () {
return (React__default.createElement("table", null,
React__default.createElement(DayPickerHeader, null),
React__default.createElement(DayPickerBody, null)));
};
var Calender = function (_a) {
var value = _a.value;
var setConfig = useConfig().setConfig;
var _b = React.useState(false), isInitialized = _b[0], setIsInitialized = _b[1];
React.useEffect(function () {
setConfig("currentLocale", "ne");
setConfig("selectedDate", parseBSDate(value));
setIsInitialized(true);
}, []);
return (React__default.createElement("div", { className: "nepali-date-picker" },
React__default.createElement("div", { className: "calendar-wrapper" }, isInitialized && (React__default.createElement(React.Fragment, null,
React__default.createElement(CalenderController, null),
React__default.createElement(DayPicker, null))))));
};
function styleInject(css, ref) {
if ( ref === void 0 ) ref = {};
var insertAt = ref.insertAt;
if (!css || typeof document === 'undefined') { return; }
var head = document.head || document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if (insertAt === 'top') {
if (head.firstChild) {
head.insertBefore(style, head.firstChild);
} else {
head.appendChild(style);
}
} else {
head.appendChild(style);
}
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
}
var css = ".nepali-date-picker {\n background: #fff none repeat scroll 0 0;\n border: 1px solid #cccccc;\n border-radius: 6px;\n box-shadow: 0 4px 8px 0 rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n color: #1b1b25;\n display: block;\n font-family: NotoSans, serif;\n font-size: 15px;\n font-style: normal;\n font-weight: normal;\n height: 240px;\n letter-spacing: 0.2px;\n line-height: 1.25em;\n padding: 15px;\n position: absolute;\n text-align: right;\n user-select: none;\n width: 280px;\n z-index: 9999; }\n .nepali-date-picker .calendar-controller {\n display: flex;\n justify-content: space-between; }\n .nepali-date-picker .calendar-controller .control {\n cursor: pointer; }\n .nepali-date-picker .calendar-controller .control.icon {\n align-items: center;\n color: #006d12;\n display: inline-flex;\n height: 24px;\n justify-content: center;\n width: 24px; }\n .nepali-date-picker .calendar-controller .control.month, .nepali-date-picker .calendar-controller .control.year {\n line-height: 24px; }\n .nepali-date-picker .calendar-controller .control.year {\n font-weight: bold; }\n";
styleInject(css);
var NepaliDatePicker = function (_a) {
var className = _a.className;
var dateEl = React.useRef(null);
var value = "2076-07-14";
return (React__default.createElement(ConfigProvider, null,
React__default.createElement("input", { type: "text", className: className, readOnly: true, ref: dateEl, value: value }),
React__default.createElement(Calender, { value: value })));
};
NepaliDatePicker.defaultProps = {
className: "",
};
exports.NepaliDatePicker = NepaliDatePicker;
//# sourceMappingURL=index.js.map
{
"name": "nepali-datepicker-reactjs",
"version": "1.0.5",
"version": "1.0.7",
"description": "Nepali Datepicker (Bikram Sambat) as a ReactJS component",

@@ -9,15 +9,43 @@ "main": "dist/index.js",

"types": "dist/index.d.ts",
"engines": {
"node": ">=10",
"npm": ">=6"
},
"scripts": {
"test": "jest --config jestconfig.json -u",
"build": "rollup -c",
"build-example": "cd ./examples && yarn && yarn build",
"start": "rollup -c --watch | yarn --cwd ./examples start",
"clean-modules": "rimraf node_modules",
"clean": "rimraf dist build npm-debug.log* yarn-error.log*",
"build:example": "cd ./examples && yarn && yarn build",
"start:example": "yarn --cwd ./examples start",
"build:plugin": "yarn clean && rollup -c",
"start:plugin": "rollup -c --watch",
"build": "npm-run-all build:*",
"start": "npm-run-all -p start:*",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
"lint": "tslint -p tsconfig.json",
"prepare": "yarn build",
"lint:ts": "tslint-config-prettier-check ./tslint.json",
"lint:ts:fix": "yarn format || yarn lint:ts",
"lint:scss": "stylelint 'src/**/*.scss' --syntax scss",
"lint:scss:fix": "yarn lint:scss --fix",
"lint": "yarn lint:ts:fix && yarn lint:scss:fix",
"prepare": "echo 'yarn build'",
"prepublishOnly": "yarn test && yarn lint",
"preversion": "yarn lint",
"version": "yarn format && git add -A src",
"postversion": "git push && git push --tags"
"postversion": "git push upstream master && git push upstream --tags"
},
"lint-staged": {
"src/**/*.{ts,tsx}": [
"yarn lint:ts:fix",
"git add"
],
"src/**/*.scss": [
"yarn lint:scss:fix",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"repository": {

@@ -40,22 +68,36 @@ "type": "git",

"devDependencies": {
"@types/jest": "^24.0.17",
"@types/react": "^16.9.2",
"@types/react-test-renderer": "^16.9.0",
"@svgr/rollup": "4.3.3",
"@types/jest": "24.0.21",
"@types/react": "16.9.11",
"@types/react-test-renderer": "16.9.1",
"@types/styled-components": "4.1.20",
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.2",
"node-sass": "4.13.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"react": "^16.9.0",
"react-test-renderer": "^16.9.0",
"rollup": "^1.19.4",
"rollup-plugin-commonjs": "^10.0.2",
"prettier-stylelint": "^0.4.2",
"react": "16.11.0",
"react-test-renderer": "16.11.0",
"rimraf": "^3.0.0",
"rollup": "1.26.0",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-typescript2": "^0.22.1",
"ts-jest": "^24.0.2",
"tslint": "^5.18.0",
"rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-typescript2": "0.24.3",
"stylelint": "^11.1.1",
"stylelint-config-standard": "^19.0.0",
"stylelint-declaration-block-no-ignored-properties": "^2.1.0",
"stylelint-no-unsupported-browser-features": "^3.0.2",
"stylelint-order": "^3.1.1",
"stylelint-scss": "^3.12.0",
"ts-jest": "24.1.0",
"tslint": "5.20.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.5.3"
"typescript": "3.6.4"
},
"peerDependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0"
"react": "^16.9.0"
},

@@ -65,3 +107,6 @@ "files": [

],
"dependencies": {}
"dependencies": {
"bikram-sambat-js": "^1.0.1",
"styled-components": "4.4.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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