mumineen-ui-plugins 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +66 -0
  2. package/dist/hijri-calendar/Calendar.d.ts +9 -0
  3. package/dist/hijri-calendar/Calendar.js +21 -0
  4. package/dist/hijri-calendar/CalendarDay.d.ts +9 -0
  5. package/dist/hijri-calendar/CalendarDay.js +58 -0
  6. package/dist/hijri-calendar/CalendarFrame.d.ts +10 -0
  7. package/dist/hijri-calendar/CalendarFrame.js +54 -0
  8. package/dist/hijri-calendar/CalendarWeek.d.ts +9 -0
  9. package/dist/hijri-calendar/CalendarWeek.js +11 -0
  10. package/dist/hijri-calendar/CalenderContext.d.ts +7 -0
  11. package/dist/hijri-calendar/CalenderContext.js +7 -0
  12. package/dist/hijri-calendar/HijriCalender.interface.d.ts +12 -0
  13. package/dist/hijri-calendar/HijriCalender.interface.js +2 -0
  14. package/dist/hijri-calendar/MiqaatList.d.ts +7 -0
  15. package/dist/hijri-calendar/MiqaatList.js +27 -0
  16. package/dist/hijri-calendar/Modal.d.ts +9 -0
  17. package/dist/hijri-calendar/Modal.js +15 -0
  18. package/dist/hijri-calendar/MonthControls.d.ts +5 -0
  19. package/dist/hijri-calendar/MonthControls.js +12 -0
  20. package/dist/hijri-calendar/TodayButton.d.ts +4 -0
  21. package/dist/hijri-calendar/TodayButton.js +6 -0
  22. package/dist/hijri-calendar/YearControls.d.ts +5 -0
  23. package/dist/hijri-calendar/YearControls.js +13 -0
  24. package/dist/hijri-calendar/libs/ArabicNumerals.d.ts +3 -0
  25. package/dist/hijri-calendar/libs/ArabicNumerals.js +20 -0
  26. package/dist/hijri-calendar/libs/HijriCalendar.d.ts +35 -0
  27. package/dist/hijri-calendar/libs/HijriCalendar.js +117 -0
  28. package/dist/hijri-calendar/libs/HijriDate.d.ts +21 -0
  29. package/dist/hijri-calendar/libs/HijriDate.js +183 -0
  30. package/dist/hijri-calendar/libs/classSet.d.ts +1 -0
  31. package/dist/hijri-calendar/libs/classSet.js +41 -0
  32. package/dist/hijri-calendar/libs/date.d.ts +5 -0
  33. package/dist/hijri-calendar/libs/date.js +26 -0
  34. package/dist/hijri-calendar/utils.d.ts +10 -0
  35. package/dist/hijri-calendar/utils.js +37 -0
  36. package/dist/index.d.ts +5 -0
  37. package/dist/index.js +10 -0
  38. package/package.json +51 -0
  39. package/src/hijri-calendar/styles.css +922 -0
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HijriDate = void 0;
4
+ // Hijri year remainders for determining Kabisa years
5
+ const KABISA_YEAR_REMAINDERS = [2, 5, 8, 10, 13, 16, 19, 21, 24, 27, 29];
6
+ // number of days in a Hijri year per month
7
+ const DAYS_IN_YEAR = [30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325];
8
+ // number of days in 30-years per Hijri year
9
+ const DAYS_IN_30_YEARS = [
10
+ 354, 708, 1063, 1417, 1771, 2126, 2480, 2834, 3189, 3543, 3898, 4252, 4606, 4961, 5315, 5669, 6024, 6378, 6732,
11
+ 7087, 7441, 7796, 8150, 8504, 8859, 9213, 9567, 9922, 10276, 10631,
12
+ ];
13
+ const MONTH_NAMES = {
14
+ long: {
15
+ en: [
16
+ "Moharram al-Haraam",
17
+ "Safar al-Muzaffar",
18
+ "Rabi al-Awwal",
19
+ "Rabi al-Aakhar",
20
+ "Jumada al-Ula",
21
+ "Jumada al-Ukhra",
22
+ "Rajab al-Asab",
23
+ "Shabaan al-Karim",
24
+ "Ramadaan al-Moazzam",
25
+ "Shawwal al-Mukarram",
26
+ "Zilqadah al-Haraam",
27
+ "Zilhaj al-Haraam",
28
+ ],
29
+ },
30
+ short: {
31
+ en: [
32
+ "Moharram",
33
+ "Safar",
34
+ "Rabi I",
35
+ "Rabi II",
36
+ "Jumada I",
37
+ "Jumada II",
38
+ "Rajab",
39
+ "Shabaan",
40
+ "Ramadaan",
41
+ "Shawwal",
42
+ "Zilqadah",
43
+ "Zilhaj",
44
+ ],
45
+ },
46
+ };
47
+ class HijriDate {
48
+ constructor(year, month, day) {
49
+ this.year = year;
50
+ this.month = month;
51
+ this.day = day;
52
+ }
53
+ getYear() {
54
+ return this.year;
55
+ }
56
+ getMonth() {
57
+ return this.month;
58
+ }
59
+ getDate() {
60
+ return this.day;
61
+ }
62
+ static getMonthName(month) {
63
+ return MONTH_NAMES.long.en[month];
64
+ }
65
+ getShortMonthName(month) {
66
+ return MONTH_NAMES.short.en[month];
67
+ }
68
+ // is the specified Gregorian Date object a Julian date?
69
+ static isJulian(date) {
70
+ if (date.getFullYear() < 1582) {
71
+ return true;
72
+ }
73
+ else if (date.getFullYear() === 1582) {
74
+ if (date.getMonth() < 9) {
75
+ return true;
76
+ }
77
+ else if (date.getMonth() === 9) {
78
+ if (date.getDate() < 5) {
79
+ return true;
80
+ }
81
+ }
82
+ }
83
+ return false;
84
+ }
85
+ // return Astronomical Julian Date corresponding to the specified Gregorian Date object
86
+ static gregorianToAJD(date) {
87
+ var a, b, year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate() +
88
+ date.getHours() / 24 +
89
+ date.getMinutes() / 1440 +
90
+ date.getSeconds() / 86400 +
91
+ date.getMilliseconds() / 86400000;
92
+ if (month < 3) {
93
+ year--;
94
+ month += 12;
95
+ }
96
+ if (HijriDate.isJulian(date)) {
97
+ b = 0;
98
+ }
99
+ else {
100
+ a = Math.floor(year / 100);
101
+ b = 2 - a + Math.floor(a / 4);
102
+ }
103
+ return Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day + b - 1524.5;
104
+ }
105
+ // return Gregorian Date object corresponding to the specified Astronomical Julian Date
106
+ ajdToGregorian(ajd) {
107
+ var a, b, c, d, e, f, z, alpha, year, month, day, hrs, min, sec, msc;
108
+ z = Math.floor(ajd + 0.5);
109
+ f = ajd + 0.5 - z;
110
+ if (z < 2299161) {
111
+ a = z;
112
+ }
113
+ else {
114
+ alpha = Math.floor((z - 1867216.25) / 36524.25);
115
+ a = z + 1 + alpha - Math.floor(0.25 * alpha);
116
+ }
117
+ b = a + 1524;
118
+ c = Math.floor((b - 122.1) / 365.25);
119
+ d = Math.floor(365.25 * c);
120
+ e = Math.floor((b - d) / 30.6001);
121
+ day = b - d - Math.floor(30.6001 * e) + f;
122
+ hrs = (day - Math.floor(day)) * 24;
123
+ min = (hrs - Math.floor(hrs)) * 60;
124
+ sec = (min - Math.floor(min)) * 60;
125
+ msc = (sec - Math.floor(sec)) * 1000;
126
+ month = e < 14 ? e - 2 : e - 14;
127
+ year = month < 2 ? c - 4715 : c - 4716;
128
+ return new Date(year, month, day, hrs, min, sec, msc);
129
+ }
130
+ // is the specified Hijri year a Kabisa year?
131
+ static isKabisa(year) {
132
+ for (var i in KABISA_YEAR_REMAINDERS) {
133
+ if (year % 30 === KABISA_YEAR_REMAINDERS[i]) {
134
+ return true;
135
+ }
136
+ }
137
+ return false;
138
+ }
139
+ // return number of days in the specified Hijri year and month
140
+ static daysInMonth(year, month) {
141
+ return (month === 11 && HijriDate.isKabisa(year)) || month % 2 === 0 ? 30 : 29;
142
+ }
143
+ // return day of Hijri year corresponding to this Hijri Date object
144
+ dayOfYear() {
145
+ return this.month === 0 ? this.day : DAYS_IN_YEAR[this.month - 1] + this.day;
146
+ }
147
+ // return Hijri Date object corresponding to specified Astronomical Julian Date
148
+ static fromAJD(ajd) {
149
+ var year, month, date, i = 0, left = Math.floor(ajd - 1948083.5), y30 = Math.floor(left / 10631.0);
150
+ left -= y30 * 10631;
151
+ while (left > DAYS_IN_30_YEARS[i]) {
152
+ i += 1;
153
+ }
154
+ year = Math.round(y30 * 30.0 + i);
155
+ if (i > 0) {
156
+ left -= DAYS_IN_30_YEARS[i - 1];
157
+ }
158
+ i = 0;
159
+ while (left > DAYS_IN_YEAR[i]) {
160
+ i += 1;
161
+ }
162
+ month = Math.round(i);
163
+ date = i > 0 ? Math.round(left - DAYS_IN_YEAR[i - 1]) : Math.round(left);
164
+ return new HijriDate(year, month, date);
165
+ }
166
+ // return Astronomical Julian Date corresponding to this Hijri Date object
167
+ toAJD() {
168
+ var y30 = Math.floor(this.year / 30.0), ajd = 1948083.5 + y30 * 10631 + this.dayOfYear();
169
+ if (this.year % 30 !== 0) {
170
+ ajd += DAYS_IN_30_YEARS[this.year - y30 * 30 - 1];
171
+ }
172
+ return ajd;
173
+ }
174
+ // return Hijri Date object corresponding to the specified Gregorian date object
175
+ static fromGregorian(date) {
176
+ return HijriDate.fromAJD(HijriDate.gregorianToAJD(date));
177
+ }
178
+ // return Gregorian date object corresponding to this Hijri Date object
179
+ toGregorian() {
180
+ return this.ajdToGregorian(this.toAJD());
181
+ }
182
+ }
183
+ exports.HijriDate = HijriDate;
@@ -0,0 +1 @@
1
+ export function classSet(classNames: any): string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2013 Facebook, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.classSet = void 0;
19
+ const classSet = classNames => {
20
+ var names = "";
21
+ if (typeof classNames == "object") {
22
+ for (var name in classNames) {
23
+ if (!classNames.hasOwnProperty(name) || !classNames[name]) {
24
+ continue;
25
+ }
26
+ names += name + " ";
27
+ }
28
+ }
29
+ else {
30
+ for (var i = 0; i < arguments.length; i++) {
31
+ // We should technically exclude 0 too, but for the sake of backward
32
+ // compat we'll keep it (for now)
33
+ if (arguments[i] == null) {
34
+ continue;
35
+ }
36
+ names += arguments[i] + " ";
37
+ }
38
+ }
39
+ return names.trim();
40
+ };
41
+ exports.classSet = classSet;
@@ -0,0 +1,5 @@
1
+ export declare class DateUtil {
2
+ static monthNames: string[];
3
+ static getMonthName(month: any): string;
4
+ static getShortMonthName(month: any): string;
5
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateUtil = void 0;
4
+ class DateUtil {
5
+ static getMonthName(month) {
6
+ return DateUtil.monthNames[month];
7
+ }
8
+ static getShortMonthName(month) {
9
+ return DateUtil.getMonthName(month).substr(0, 3);
10
+ }
11
+ }
12
+ exports.DateUtil = DateUtil;
13
+ DateUtil.monthNames = [
14
+ "January",
15
+ "February",
16
+ "March",
17
+ "April",
18
+ "May",
19
+ "June",
20
+ "July",
21
+ "August",
22
+ "September",
23
+ "October",
24
+ "November",
25
+ "December",
26
+ ];
@@ -0,0 +1,10 @@
1
+ import { Miqaat, MiqaatMonth } from "./HijriCalender.interface";
2
+ import { Day } from "./libs/HijriCalendar";
3
+ export declare const useDayMiqaats: (miqaats: MiqaatMonth[], day: Day) => Miqaat[];
4
+ export declare const getHijriDate: (day: Day) => string;
5
+ export declare const getGregorianDate: (day: Day) => string;
6
+ /**
7
+ * Returns a function that will call the given handler and prevent the default event behavior.
8
+ * @param handler: The handler to call.
9
+ */
10
+ export declare const preventDefault: (handler?: (event: any) => void) => (event: any) => void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.preventDefault = exports.getGregorianDate = exports.getHijriDate = exports.useDayMiqaats = void 0;
4
+ const HijriDate_1 = require("./libs/HijriDate");
5
+ const date_1 = require("./libs/date");
6
+ const useDayMiqaats = (miqaats, day) => {
7
+ const { hijri } = day;
8
+ return miqaats
9
+ .filter(({ date, month }) => date == hijri.date && month == hijri.month)
10
+ .map(({ miqaats }) => miqaats)
11
+ .flat()
12
+ .filter(miqaat => !(miqaat.year && miqaat.year > hijri.year));
13
+ };
14
+ exports.useDayMiqaats = useDayMiqaats;
15
+ const getHijriDate = (day) => {
16
+ if (day && day.hijri) {
17
+ const { hijri: { date, month, year }, } = day;
18
+ return `${date.toString()} ${HijriDate_1.HijriDate.getMonthName(month)} ${year.toString()} H`;
19
+ }
20
+ };
21
+ exports.getHijriDate = getHijriDate;
22
+ const getGregorianDate = (day) => {
23
+ if (day && day.gregorian) {
24
+ const { gregorian: { date, month, year }, } = day;
25
+ return `${date.toString()} ${date_1.DateUtil.getMonthName(month)} ${year.toString()} AD`;
26
+ }
27
+ };
28
+ exports.getGregorianDate = getGregorianDate;
29
+ /**
30
+ * Returns a function that will call the given handler and prevent the default event behavior.
31
+ * @param handler: The handler to call.
32
+ */
33
+ const preventDefault = (handler) => (event) => {
34
+ event.preventDefault();
35
+ handler && handler(event);
36
+ };
37
+ exports.preventDefault = preventDefault;
@@ -0,0 +1,5 @@
1
+ export { CalendarFrame as HijriCalendar } from "./hijri-calendar/CalendarFrame";
2
+ export { MiqaatList } from "./hijri-calendar/MiqaatList";
3
+ export { Day } from "./hijri-calendar/libs/HijriCalendar";
4
+ export { MiqaatMonth, Miqaat } from "./hijri-calendar/HijriCalender.interface";
5
+ export { getGregorianDate, getHijriDate } from "./hijri-calendar/utils";
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHijriDate = exports.getGregorianDate = exports.MiqaatList = exports.HijriCalendar = void 0;
4
+ var CalendarFrame_1 = require("./hijri-calendar/CalendarFrame");
5
+ Object.defineProperty(exports, "HijriCalendar", { enumerable: true, get: function () { return CalendarFrame_1.CalendarFrame; } });
6
+ var MiqaatList_1 = require("./hijri-calendar/MiqaatList");
7
+ Object.defineProperty(exports, "MiqaatList", { enumerable: true, get: function () { return MiqaatList_1.MiqaatList; } });
8
+ var utils_1 = require("./hijri-calendar/utils");
9
+ Object.defineProperty(exports, "getGregorianDate", { enumerable: true, get: function () { return utils_1.getGregorianDate; } });
10
+ Object.defineProperty(exports, "getHijriDate", { enumerable: true, get: function () { return utils_1.getHijriDate; } });
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "mumineen-ui-plugins",
3
+ "version": "1.1.0",
4
+ "description": "",
5
+ "main": "dist/index",
6
+ "scripts": {
7
+ "build": "rimraf dist/ && tsc",
8
+ "watch": "rimraf dist/ && tsc --watch",
9
+ "format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
10
+ "update:version": "npm version minor --no-git-tag-version",
11
+ "prepub:npm": "npm run format && npm run build && npm run update:version",
12
+ "publish:npm": "npm run prepub:npm && npm publish"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/navedr/mumineen_calendar_react.git"
17
+ },
18
+ "files": [
19
+ "dist/**/*",
20
+ "src/hijri-calendar/styles.css"
21
+ ],
22
+ "keywords": [],
23
+ "author": "Naved Rangwala",
24
+ "license": "ISC",
25
+ "devDependencies": {
26
+ "@types/node": "^20.4.10",
27
+ "@types/react": "^17.0.0",
28
+ "prettier": "^2.2.1",
29
+ "react": "^16.8.2",
30
+ "react-dom": "^16.8.2",
31
+ "rimraf": "^3.0.2",
32
+ "typescript": "*"
33
+ },
34
+ "peerDependencies": {
35
+ "@types/react": ">=16.14.8",
36
+ "react": ">=16.14.0",
37
+ "react-dom": ">=16.14.0"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "@types/react": {
41
+ "optional": true
42
+ }
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/navedr/mumineen-ui-plugins/issues"
46
+ },
47
+ "homepage": "https://github.com/navedr/mumineen-ui-plugins#readme",
48
+ "dependencies": {
49
+ "lazy.js": "^0.5.1"
50
+ }
51
+ }