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.
- package/README.md +66 -0
- package/dist/hijri-calendar/Calendar.d.ts +9 -0
- package/dist/hijri-calendar/Calendar.js +21 -0
- package/dist/hijri-calendar/CalendarDay.d.ts +9 -0
- package/dist/hijri-calendar/CalendarDay.js +58 -0
- package/dist/hijri-calendar/CalendarFrame.d.ts +10 -0
- package/dist/hijri-calendar/CalendarFrame.js +54 -0
- package/dist/hijri-calendar/CalendarWeek.d.ts +9 -0
- package/dist/hijri-calendar/CalendarWeek.js +11 -0
- package/dist/hijri-calendar/CalenderContext.d.ts +7 -0
- package/dist/hijri-calendar/CalenderContext.js +7 -0
- package/dist/hijri-calendar/HijriCalender.interface.d.ts +12 -0
- package/dist/hijri-calendar/HijriCalender.interface.js +2 -0
- package/dist/hijri-calendar/MiqaatList.d.ts +7 -0
- package/dist/hijri-calendar/MiqaatList.js +27 -0
- package/dist/hijri-calendar/Modal.d.ts +9 -0
- package/dist/hijri-calendar/Modal.js +15 -0
- package/dist/hijri-calendar/MonthControls.d.ts +5 -0
- package/dist/hijri-calendar/MonthControls.js +12 -0
- package/dist/hijri-calendar/TodayButton.d.ts +4 -0
- package/dist/hijri-calendar/TodayButton.js +6 -0
- package/dist/hijri-calendar/YearControls.d.ts +5 -0
- package/dist/hijri-calendar/YearControls.js +13 -0
- package/dist/hijri-calendar/libs/ArabicNumerals.d.ts +3 -0
- package/dist/hijri-calendar/libs/ArabicNumerals.js +20 -0
- package/dist/hijri-calendar/libs/HijriCalendar.d.ts +35 -0
- package/dist/hijri-calendar/libs/HijriCalendar.js +117 -0
- package/dist/hijri-calendar/libs/HijriDate.d.ts +21 -0
- package/dist/hijri-calendar/libs/HijriDate.js +183 -0
- package/dist/hijri-calendar/libs/classSet.d.ts +1 -0
- package/dist/hijri-calendar/libs/classSet.js +41 -0
- package/dist/hijri-calendar/libs/date.d.ts +5 -0
- package/dist/hijri-calendar/libs/date.js +26 -0
- package/dist/hijri-calendar/utils.d.ts +10 -0
- package/dist/hijri-calendar/utils.js +37 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10 -0
- package/package.json +51 -0
- package/src/hijri-calendar/styles.css +922 -0
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Mumineen Calendar
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Mumineen Calendar is a [Hijri calendar] for [Dawoodi Bohra Shia Muslims] who
|
|
6
|
+
follow the 53rd Dai al-Mutlaq, His Holiness, [Syedna Aale Qadr Mufaddal
|
|
7
|
+
Saifuddin] (_TUS_). It provides the user with the Hijri date, [Gregorian date]
|
|
8
|
+
for any day of the calendar year.
|
|
9
|
+
|
|
10
|
+
This version is primarily written in JavaScript using [React] and [Middleman].
|
|
11
|
+
It supercedes the [Ruby on Rails version] I wrote some time ago.
|
|
12
|
+
|
|
13
|
+
[Dawoodi Bohra Shia Muslims]: https://www.thedawoodibohras.com/
|
|
14
|
+
[Gregorian date]: http://en.wikipedia.org/wiki/Gregorian_calendar
|
|
15
|
+
[Hijri Calendar]: http://en.wikipedia.org/wiki/Islamic_calendar
|
|
16
|
+
[Middleman]: http://middlemanapp.com/
|
|
17
|
+
[React]: http://facebook.github.io/react/
|
|
18
|
+
[Ruby on Rails version]: https://github.com/mygulamali/mumineen_calendar
|
|
19
|
+
[Syedna Aale Qadr Mufaddal Saifuddin]: https://www.thedawoodibohras.com/about-the-bohras/the-dai-al-mutlaq/53rd-dai-al-mutlaq/
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
git clone git@github.com:mygulamali/mumineen_calendar_js
|
|
25
|
+
cd mumineen_calendar_js
|
|
26
|
+
bundle install
|
|
27
|
+
cp .env.example .env
|
|
28
|
+
cd source/assets/stylesheets
|
|
29
|
+
bundle exec bourbon install
|
|
30
|
+
bundle exec neat install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then complete the variables in the `.env` file for you environment. The current
|
|
34
|
+
values can be found in the _Build & deploy_ section under the _Site settings_
|
|
35
|
+
tab for the website, on Netlify.
|
|
36
|
+
|
|
37
|
+
## Serve on your localhost
|
|
38
|
+
|
|
39
|
+
`bundle exec middleman`
|
|
40
|
+
|
|
41
|
+
Then visit `http://localhost:4567` to see the site in action.
|
|
42
|
+
|
|
43
|
+
## Deploy to your web server
|
|
44
|
+
|
|
45
|
+
`bundle exec middleman deploy`
|
|
46
|
+
|
|
47
|
+
This command will automagically commit the built website to the correct branch
|
|
48
|
+
of this repo for your static site server (i.e. [GitHub Pages] or [Netlify])
|
|
49
|
+
to serve.
|
|
50
|
+
|
|
51
|
+
[Netlify]: https://www.netlify.com/ "Netlify"
|
|
52
|
+
[GitHub Pages]: https://pages.github.com/ "GitHub Pages"
|
|
53
|
+
|
|
54
|
+
## Testing
|
|
55
|
+
|
|
56
|
+
After starting the local server (see above), visit
|
|
57
|
+
`http://localhost:4567/jasmine` to run the [Jasmine] specs.
|
|
58
|
+
|
|
59
|
+
[Jasmine]: http://jasmine.github.io/
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
This software is released under the terms and conditions of [The MIT License].
|
|
64
|
+
Please see the `LICENSE.txt` file for more details.
|
|
65
|
+
|
|
66
|
+
[The MIT License]: http://www.opensource.org/licenses/mit-license.php
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { MiqaatMonth } from "./HijriCalender.interface";
|
|
3
|
+
import { Day, HijriCalendar } from "./libs/HijriCalendar";
|
|
4
|
+
export declare const Calendar: React.FC<{
|
|
5
|
+
today: any;
|
|
6
|
+
onDayClick: (day: Day) => void;
|
|
7
|
+
calendar: HijriCalendar;
|
|
8
|
+
miqaats?: MiqaatMonth[];
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Calendar = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const CalendarWeek_1 = require("./CalendarWeek");
|
|
6
|
+
exports.Calendar = React.memo(({ today, onDayClick, calendar, miqaats }) => {
|
|
7
|
+
return (React.createElement("div", { className: "calendar" },
|
|
8
|
+
React.createElement("table", null,
|
|
9
|
+
React.createElement("thead", null,
|
|
10
|
+
React.createElement("tr", null,
|
|
11
|
+
React.createElement("th", null, "Sun"),
|
|
12
|
+
React.createElement("th", null, "Mon"),
|
|
13
|
+
React.createElement("th", null, "Tue"),
|
|
14
|
+
React.createElement("th", null, "Wed"),
|
|
15
|
+
React.createElement("th", null, "Thu"),
|
|
16
|
+
React.createElement("th", null, "Fri"),
|
|
17
|
+
React.createElement("th", null, "Sat"))),
|
|
18
|
+
React.createElement("tbody", null, calendar.weeks().map((week, key) => {
|
|
19
|
+
return (React.createElement(CalendarWeek_1.CalendarWeek, { key: key, week: week, today: today, miqaats: miqaats === null || miqaats === void 0 ? void 0 : miqaats.filter(({ month }) => month == calendar.getMonth()), onDayClick: onDayClick }));
|
|
20
|
+
})))));
|
|
21
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { MiqaatMonth } from "./HijriCalender.interface";
|
|
3
|
+
import { Day } from "./libs/HijriCalendar";
|
|
4
|
+
export declare const CalendarDay: React.FC<{
|
|
5
|
+
today: any;
|
|
6
|
+
onDayClick: (day: Day) => void;
|
|
7
|
+
day: Day;
|
|
8
|
+
miqaats?: MiqaatMonth[];
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalendarDay = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const ArabicNumerals_1 = require("./libs/ArabicNumerals");
|
|
6
|
+
const date_1 = require("./libs/date");
|
|
7
|
+
const classSet_1 = require("./libs/classSet");
|
|
8
|
+
exports.CalendarDay = React.memo(({ today, onDayClick, day, miqaats }) => {
|
|
9
|
+
const isToday = React.useMemo(() => day.hijri.year === today.getYear() &&
|
|
10
|
+
day.hijri.month === today.getMonth() &&
|
|
11
|
+
day.hijri.date === today.getDate(), [day, today]);
|
|
12
|
+
const dayClassName = React.useMemo(() => (0, classSet_1.classSet)({
|
|
13
|
+
day: !day.filler,
|
|
14
|
+
filler: day.filler,
|
|
15
|
+
today: isToday,
|
|
16
|
+
}), [day, isToday]);
|
|
17
|
+
const iconClassName = React.useMemo(() => {
|
|
18
|
+
var firstMiqaat = miqaats
|
|
19
|
+
.filter(({ date }) => date == day.hijri.date)
|
|
20
|
+
.map(({ miqaats }) => miqaats)
|
|
21
|
+
.flat()
|
|
22
|
+
.filter(function (miqaat) {
|
|
23
|
+
return miqaat.year ? miqaat.year <= day.hijri.year : true;
|
|
24
|
+
})[0];
|
|
25
|
+
if (!firstMiqaat || day.filler) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return (0, classSet_1.classSet)({
|
|
29
|
+
"icon-sun": firstMiqaat.priority === 1 && firstMiqaat.phase === "day",
|
|
30
|
+
"icon-moon": firstMiqaat.priority === 1 && firstMiqaat.phase === "night",
|
|
31
|
+
"icon-circle": firstMiqaat.priority > 1,
|
|
32
|
+
});
|
|
33
|
+
}, [miqaats, day]);
|
|
34
|
+
const hijriDateString = React.useMemo(() => ArabicNumerals_1.ArabicNumerals.fromInteger(day.hijri.date), [day]);
|
|
35
|
+
const gregorianDateString = React.useMemo(() => {
|
|
36
|
+
var { gregorian } = day, dateString = gregorian.date.toString();
|
|
37
|
+
if (!day.filler) {
|
|
38
|
+
if (day.hijri.date === 1 || gregorian.date === 1) {
|
|
39
|
+
dateString += " " + date_1.DateUtil.getShortMonthName(gregorian.month);
|
|
40
|
+
}
|
|
41
|
+
if (day.hijri.date === 1 || (gregorian.month === 0 && gregorian.date === 1)) {
|
|
42
|
+
dateString += " " + gregorian.year.toString();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return dateString;
|
|
46
|
+
}, [day]);
|
|
47
|
+
const onDayClicked = React.useCallback(day => {
|
|
48
|
+
if (!day.filler) {
|
|
49
|
+
onDayClick(day);
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}, [day, onDayClick]);
|
|
53
|
+
return (React.createElement("td", { className: dayClassName, onClick: onDayClicked.bind(null, day) },
|
|
54
|
+
React.createElement("div", { className: "hijri" }, hijriDateString),
|
|
55
|
+
React.createElement("div", { className: "gregorian" }, gregorianDateString),
|
|
56
|
+
React.createElement("div", { className: "day-icon" },
|
|
57
|
+
React.createElement("i", { className: iconClassName }))));
|
|
58
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
import { Day } from "./libs/HijriCalendar";
|
|
4
|
+
import { Miqaat, MiqaatMonth } from "./HijriCalender.interface";
|
|
5
|
+
export declare const CalendarFrame: React.FC<{
|
|
6
|
+
miqaats?: MiqaatMonth[];
|
|
7
|
+
additionalDayContent?: (day: Day) => React.ReactNode;
|
|
8
|
+
onDayClick?: (day: Day, miqaats: Miqaat[]) => void;
|
|
9
|
+
showDefaultMiqaatData?: boolean;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalendarFrame = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
require("./styles.css");
|
|
6
|
+
const Calendar_1 = require("./Calendar");
|
|
7
|
+
const YearControls_1 = require("./YearControls");
|
|
8
|
+
const TodayButton_1 = require("./TodayButton");
|
|
9
|
+
const MonthControls_1 = require("./MonthControls");
|
|
10
|
+
const Modal_1 = require("./Modal");
|
|
11
|
+
const HijriDate_1 = require("./libs/HijriDate");
|
|
12
|
+
const HijriCalendar_1 = require("./libs/HijriCalendar");
|
|
13
|
+
const CalenderContext_1 = require("./CalenderContext");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
|
+
exports.CalendarFrame = React.memo(({ miqaats: passedMiqaats = [], additionalDayContent, showDefaultMiqaatData, onDayClick }) => {
|
|
16
|
+
const modalId = "modal";
|
|
17
|
+
const today = HijriDate_1.HijriDate.fromGregorian(new Date());
|
|
18
|
+
const [day, setDay] = React.useState(null);
|
|
19
|
+
const [calendar, setCalendar] = React.useState(new HijriCalendar_1.HijriCalendar(today.getYear(), today.getMonth()));
|
|
20
|
+
const [miqaats, setMiqaats] = React.useState([]);
|
|
21
|
+
const navigateToToday = React.useCallback(() => setCalendar(new HijriCalendar_1.HijriCalendar(today.getYear(), today.getMonth())), [setCalendar, today]);
|
|
22
|
+
const changeMonth = React.useCallback((monthChange) => setCalendar(monthChange < 0 ? calendar.previousMonth() : calendar.nextMonth()), [setCalendar, calendar]);
|
|
23
|
+
const changeYear = React.useCallback((yearChange) => setCalendar(yearChange < 0 ? calendar.previousYear() : calendar.nextYear()), [setCalendar, calendar]);
|
|
24
|
+
const showModal = React.useCallback((_day) => {
|
|
25
|
+
setDay(_day);
|
|
26
|
+
document.getElementById(modalId).getElementsByTagName("input").item(0).checked = true;
|
|
27
|
+
}, [setDay]);
|
|
28
|
+
const onDayClickHandler = React.useCallback((day) => {
|
|
29
|
+
if (onDayClick) {
|
|
30
|
+
onDayClick(day, (0, utils_1.useDayMiqaats)(miqaats, day));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
showModal(day);
|
|
34
|
+
}
|
|
35
|
+
}, [onDayClick, showModal]);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (showDefaultMiqaatData) {
|
|
38
|
+
const data = require("./data/miqaats.json");
|
|
39
|
+
setMiqaats(data);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
setMiqaats(passedMiqaats);
|
|
43
|
+
}
|
|
44
|
+
}, [passedMiqaats, showDefaultMiqaatData, setMiqaats]);
|
|
45
|
+
return (React.createElement(CalenderContext_1.CalendarContext.Provider, { value: { miqaats } },
|
|
46
|
+
React.createElement("div", { className: "hijri-calendar" },
|
|
47
|
+
React.createElement("div", { className: "year-row" },
|
|
48
|
+
React.createElement(YearControls_1.YearControls, { year: calendar.getYear(), onYearChange: changeYear }),
|
|
49
|
+
React.createElement(TodayButton_1.TodayButton, { onClick: navigateToToday })),
|
|
50
|
+
React.createElement("div", { className: "month-row" },
|
|
51
|
+
React.createElement(MonthControls_1.MonthControls, { month: calendar.getMonth(), onMonthChange: changeMonth })),
|
|
52
|
+
React.createElement(Calendar_1.Calendar, { calendar: calendar, today: today, miqaats: miqaats, onDayClick: onDayClickHandler }),
|
|
53
|
+
!onDayClick && (React.createElement(Modal_1.Modal, { modalId: modalId, miqaats: miqaats, day: day, additionalContent: additionalDayContent })))));
|
|
54
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { MiqaatMonth } from "./HijriCalender.interface";
|
|
3
|
+
import { Day } from "./libs/HijriCalendar";
|
|
4
|
+
export declare const CalendarWeek: React.FC<{
|
|
5
|
+
today: any;
|
|
6
|
+
onDayClick: (day: Day) => void;
|
|
7
|
+
miqaats?: MiqaatMonth[];
|
|
8
|
+
week: any[];
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalendarWeek = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const CalendarDay_1 = require("./CalendarDay");
|
|
6
|
+
exports.CalendarWeek = React.memo(({ today, onDayClick, miqaats, week }) => {
|
|
7
|
+
return (React.createElement("tr", null, week.map(function (day) {
|
|
8
|
+
const key = [day.hijri.year, day.hijri.month, day.hijri.date].join("-");
|
|
9
|
+
return React.createElement(CalendarDay_1.CalendarDay, { key: key, day: day, today: today, miqaats: miqaats, onDayClick: onDayClick });
|
|
10
|
+
})));
|
|
11
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { MiqaatMonth } from "./HijriCalender.interface";
|
|
3
|
+
export interface ICalendarContext {
|
|
4
|
+
miqaats?: MiqaatMonth[];
|
|
5
|
+
}
|
|
6
|
+
export declare const CalendarContext: React.Context<ICalendarContext>;
|
|
7
|
+
export declare const useCalendarContext: () => ICalendarContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCalendarContext = exports.CalendarContext = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
exports.CalendarContext = React.createContext({});
|
|
6
|
+
const useCalendarContext = () => React.useContext(exports.CalendarContext);
|
|
7
|
+
exports.useCalendarContext = useCalendarContext;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MiqaatList = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
exports.MiqaatList = React.memo(({ miqaats, day }) => {
|
|
7
|
+
const listItems = React.useMemo(() => {
|
|
8
|
+
var items = [];
|
|
9
|
+
if (day) {
|
|
10
|
+
const { hijri } = day;
|
|
11
|
+
items = (0, utils_1.useDayMiqaats)(miqaats, day).map(miqaat => {
|
|
12
|
+
if (miqaat.year && miqaat.year > hijri.year)
|
|
13
|
+
return null;
|
|
14
|
+
return (React.createElement("li", { key: miqaat.title },
|
|
15
|
+
miqaat.title,
|
|
16
|
+
React.createElement("br", null),
|
|
17
|
+
React.createElement("span", { className: "description" }, miqaat.description)));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (items.length < 1) {
|
|
21
|
+
return React.createElement("li", { className: "none" }, "There are no miqaats on this day.");
|
|
22
|
+
}
|
|
23
|
+
return items;
|
|
24
|
+
}, [miqaats, day]);
|
|
25
|
+
return (React.createElement("div", { className: "miqaat-list" },
|
|
26
|
+
React.createElement("ul", { className: "miqaats" }, listItems)));
|
|
27
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { MiqaatMonth } from "./HijriCalender.interface";
|
|
3
|
+
import { Day } from "./libs/HijriCalendar";
|
|
4
|
+
export declare const Modal: React.FC<{
|
|
5
|
+
day: Day;
|
|
6
|
+
modalId: string;
|
|
7
|
+
miqaats?: MiqaatMonth[];
|
|
8
|
+
additionalContent?: (day: Day) => React.ReactNode;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Modal = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const MiqaatList_1 = require("./MiqaatList");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
exports.Modal = React.memo(({ day, modalId, miqaats, additionalContent }) => (React.createElement("div", { className: "day-modal", id: modalId },
|
|
8
|
+
React.createElement("input", { className: "modal-state", id: "modal-checkbox", type: "checkbox" }),
|
|
9
|
+
React.createElement("div", { className: "modal-window" },
|
|
10
|
+
React.createElement("div", { className: "modal-inner" },
|
|
11
|
+
React.createElement("label", { className: "modal-close", htmlFor: "modal-checkbox" }),
|
|
12
|
+
React.createElement("h3", null, (0, utils_1.getHijriDate)(day)),
|
|
13
|
+
React.createElement("h4", null, (0, utils_1.getGregorianDate)(day)),
|
|
14
|
+
React.createElement(MiqaatList_1.MiqaatList, { miqaats: miqaats, day: day }), additionalContent === null || additionalContent === void 0 ? void 0 :
|
|
15
|
+
additionalContent(day))))));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MonthControls = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const HijriDate_1 = require("./libs/HijriDate");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
exports.MonthControls = React.memo(({ month, onMonthChange }) => (React.createElement("div", { className: "month-controls" },
|
|
8
|
+
React.createElement("a", { href: "#", className: "prev", onClick: (0, utils_1.preventDefault)(onMonthChange.bind(null, -1)) },
|
|
9
|
+
React.createElement("i", { className: "icon-chevron-sign-left" })),
|
|
10
|
+
React.createElement("h3", null, HijriDate_1.HijriDate.getMonthName(month)),
|
|
11
|
+
React.createElement("a", { href: "#", className: "next", onClick: (0, utils_1.preventDefault)(onMonthChange.bind(null, +1)) },
|
|
12
|
+
React.createElement("i", { className: "icon-chevron-sign-right" })))));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TodayButton = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
exports.TodayButton = React.memo(({ onClick }) => (React.createElement("div", { className: "today-button" },
|
|
6
|
+
React.createElement("button", { onClick: onClick }, "Today"))));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YearControls = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
exports.YearControls = React.memo(({ year, onYearChange }) => (React.createElement("div", { className: "year-controls" },
|
|
7
|
+
React.createElement("a", { href: "#", onClick: (0, utils_1.preventDefault)(onYearChange.bind(null, -1)) },
|
|
8
|
+
React.createElement("i", { className: "icon-minus-sign" })),
|
|
9
|
+
React.createElement("h2", null,
|
|
10
|
+
year,
|
|
11
|
+
"H"),
|
|
12
|
+
React.createElement("a", { href: "#", onClick: (0, utils_1.preventDefault)(onYearChange.bind(null, +1)) },
|
|
13
|
+
React.createElement("i", { className: "icon-plus-sign" })))));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArabicNumerals = void 0;
|
|
4
|
+
const utf8Codes = ["\u0660", "\u0661", "\u0662", "\u0663", "\u0664", "\u0665", "\u0666", "\u0667", "\u0668", "\u0669"];
|
|
5
|
+
class ArabicNumerals {
|
|
6
|
+
static fromInteger(x) {
|
|
7
|
+
return Math.floor(x)
|
|
8
|
+
.toString()
|
|
9
|
+
.split("")
|
|
10
|
+
.map(function (digit) {
|
|
11
|
+
return parseInt(digit, 10);
|
|
12
|
+
})
|
|
13
|
+
.map(function (digit) {
|
|
14
|
+
return utf8Codes[digit];
|
|
15
|
+
})
|
|
16
|
+
.join("")
|
|
17
|
+
.toString();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ArabicNumerals = ArabicNumerals;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare type Day = {
|
|
2
|
+
hijri: {
|
|
3
|
+
year: number;
|
|
4
|
+
month: number;
|
|
5
|
+
date: number;
|
|
6
|
+
};
|
|
7
|
+
gregorian: {
|
|
8
|
+
year: number;
|
|
9
|
+
month: number;
|
|
10
|
+
date: number;
|
|
11
|
+
};
|
|
12
|
+
ajd: any;
|
|
13
|
+
filler: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare class HijriCalendar {
|
|
16
|
+
private year;
|
|
17
|
+
private month;
|
|
18
|
+
private iso8601;
|
|
19
|
+
constructor(year: number, month: number, iso8601?: boolean);
|
|
20
|
+
getYear(): number;
|
|
21
|
+
getMonth(): number;
|
|
22
|
+
isISO(): boolean;
|
|
23
|
+
getMinYear(): number;
|
|
24
|
+
getMaxYear(): number;
|
|
25
|
+
dayOfWeek(date: any): number;
|
|
26
|
+
days(): any;
|
|
27
|
+
weeks(): any;
|
|
28
|
+
previousDays(): any;
|
|
29
|
+
nextDays(): any;
|
|
30
|
+
previousMonth(): HijriCalendar;
|
|
31
|
+
nextMonth(): HijriCalendar;
|
|
32
|
+
previousYear(): HijriCalendar;
|
|
33
|
+
nextYear(): HijriCalendar;
|
|
34
|
+
private dayHash;
|
|
35
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HijriCalendar = void 0;
|
|
4
|
+
const HijriDate_1 = require("./HijriDate");
|
|
5
|
+
const lazy_js_1 = require("lazy.js");
|
|
6
|
+
const MIN_CALENDAR_YEAR = 1000;
|
|
7
|
+
const MAX_CALENDAR_YEAR = 3000;
|
|
8
|
+
class HijriCalendar {
|
|
9
|
+
constructor(year, month, iso8601 = false) {
|
|
10
|
+
this.year = year;
|
|
11
|
+
this.month = month;
|
|
12
|
+
this.iso8601 = iso8601;
|
|
13
|
+
}
|
|
14
|
+
getYear() {
|
|
15
|
+
return this.year;
|
|
16
|
+
}
|
|
17
|
+
getMonth() {
|
|
18
|
+
return this.month;
|
|
19
|
+
}
|
|
20
|
+
isISO() {
|
|
21
|
+
return this.iso8601;
|
|
22
|
+
}
|
|
23
|
+
getMinYear() {
|
|
24
|
+
return MIN_CALENDAR_YEAR;
|
|
25
|
+
}
|
|
26
|
+
getMaxYear() {
|
|
27
|
+
return MAX_CALENDAR_YEAR;
|
|
28
|
+
}
|
|
29
|
+
// return day of week for the specified date
|
|
30
|
+
dayOfWeek(date) {
|
|
31
|
+
var hijriDate = new HijriDate_1.HijriDate(this.year, this.month, date), offset = this.iso8601 ? 0.5 : 1.5;
|
|
32
|
+
return (hijriDate.toAJD() + offset) % 7;
|
|
33
|
+
}
|
|
34
|
+
// return array of days of this month and year
|
|
35
|
+
days() {
|
|
36
|
+
const self = this;
|
|
37
|
+
return lazy_js_1.default.generate(function (day) {
|
|
38
|
+
var hijriDate = new HijriDate_1.HijriDate(self.year, self.month, day + 1), gregorianDate = hijriDate.toGregorian();
|
|
39
|
+
return self.dayHash(hijriDate, gregorianDate);
|
|
40
|
+
}, HijriDate_1.HijriDate.daysInMonth(this.year, this.month));
|
|
41
|
+
}
|
|
42
|
+
// return array of weeks for this month and year
|
|
43
|
+
weeks() {
|
|
44
|
+
return (0, lazy_js_1.default)([]).concat(this.previousDays(), this.days(), this.nextDays()).chunk(7).toArray();
|
|
45
|
+
}
|
|
46
|
+
// return array of days from beginning of week until start of this month and year
|
|
47
|
+
previousDays() {
|
|
48
|
+
var previousMonth = this.previousMonth(), daysInPreviousMonth = HijriDate_1.HijriDate.daysInMonth(previousMonth.getYear(), previousMonth.getMonth()), dayAtStartOfMonth = this.dayOfWeek(1);
|
|
49
|
+
if (this.month === 0 && this.year === MIN_CALENDAR_YEAR)
|
|
50
|
+
return lazy_js_1.default.repeat(null, 6 - dayAtStartOfMonth);
|
|
51
|
+
const self = this;
|
|
52
|
+
return lazy_js_1.default.generate(function (day) {
|
|
53
|
+
const hijriDate = new HijriDate_1.HijriDate(previousMonth.getYear(), previousMonth.getMonth(), daysInPreviousMonth - dayAtStartOfMonth + day + 1), gregorianDate = hijriDate.toGregorian();
|
|
54
|
+
return self.dayHash(hijriDate, gregorianDate, true);
|
|
55
|
+
}, dayAtStartOfMonth);
|
|
56
|
+
}
|
|
57
|
+
// return array of days from end of this month and year until end of the week
|
|
58
|
+
nextDays() {
|
|
59
|
+
var nextMonth = this.nextMonth(), daysInMonth = HijriDate_1.HijriDate.daysInMonth(this.year, this.month), dayAtEndOfMonth = this.dayOfWeek(daysInMonth);
|
|
60
|
+
if (nextMonth.getYear() === this.year && nextMonth.getMonth() === this.month)
|
|
61
|
+
return lazy_js_1.default.repeat(null, 6 - dayAtEndOfMonth);
|
|
62
|
+
const self = this;
|
|
63
|
+
return lazy_js_1.default.generate(function (day) {
|
|
64
|
+
var hijriDate = new HijriDate_1.HijriDate(nextMonth.getYear(), nextMonth.getMonth(), day + 1), gregorianDate = hijriDate.toGregorian();
|
|
65
|
+
return self.dayHash(hijriDate, gregorianDate, true);
|
|
66
|
+
}, 6 - dayAtEndOfMonth);
|
|
67
|
+
}
|
|
68
|
+
// return Hijri Calendar object for the previous month
|
|
69
|
+
previousMonth() {
|
|
70
|
+
var year = this.month === 0 && this.year > MIN_CALENDAR_YEAR ? this.year - 1 : this.year, month;
|
|
71
|
+
if (this.month === 0 && this.year === MIN_CALENDAR_YEAR)
|
|
72
|
+
month = this.month;
|
|
73
|
+
else if (this.month === 0)
|
|
74
|
+
month = 11;
|
|
75
|
+
else
|
|
76
|
+
month = this.month - 1;
|
|
77
|
+
return new HijriCalendar(year, month, this.iso8601);
|
|
78
|
+
}
|
|
79
|
+
// return Hijri Calendar object for the next month
|
|
80
|
+
nextMonth() {
|
|
81
|
+
var year = this.month === 11 && this.year < MAX_CALENDAR_YEAR ? this.year + 1 : this.year, month;
|
|
82
|
+
if (this.month === 11 && this.year === MAX_CALENDAR_YEAR)
|
|
83
|
+
month = this.month;
|
|
84
|
+
else if (this.month === 11)
|
|
85
|
+
month = 0;
|
|
86
|
+
else
|
|
87
|
+
month = this.month + 1;
|
|
88
|
+
return new HijriCalendar(year, month, this.iso8601);
|
|
89
|
+
}
|
|
90
|
+
// return Hijri Calendar object for the previous year
|
|
91
|
+
previousYear() {
|
|
92
|
+
var year = this.year === MIN_CALENDAR_YEAR ? MIN_CALENDAR_YEAR : this.year - 1;
|
|
93
|
+
return new HijriCalendar(year, this.month, this.iso8601);
|
|
94
|
+
}
|
|
95
|
+
// return Hijri Calendar object for the next year
|
|
96
|
+
nextYear() {
|
|
97
|
+
var year = this.year === MAX_CALENDAR_YEAR ? MAX_CALENDAR_YEAR : this.year + 1;
|
|
98
|
+
return new HijriCalendar(year, this.month, this.iso8601);
|
|
99
|
+
}
|
|
100
|
+
dayHash(hijriDate, gregorianDate, isFiller = false) {
|
|
101
|
+
return {
|
|
102
|
+
hijri: {
|
|
103
|
+
year: hijriDate.getYear(),
|
|
104
|
+
month: hijriDate.getMonth(),
|
|
105
|
+
date: hijriDate.getDate(),
|
|
106
|
+
},
|
|
107
|
+
gregorian: {
|
|
108
|
+
year: gregorianDate.getFullYear(),
|
|
109
|
+
month: gregorianDate.getMonth(),
|
|
110
|
+
date: gregorianDate.getDate(),
|
|
111
|
+
},
|
|
112
|
+
ajd: hijriDate.toAJD(),
|
|
113
|
+
filler: isFiller ? true : undefined,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.HijriCalendar = HijriCalendar;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class HijriDate {
|
|
2
|
+
private year;
|
|
3
|
+
private month;
|
|
4
|
+
private day;
|
|
5
|
+
constructor(year: any, month: any, day: any);
|
|
6
|
+
getYear(): any;
|
|
7
|
+
getMonth(): any;
|
|
8
|
+
getDate(): any;
|
|
9
|
+
static getMonthName(month: any): string;
|
|
10
|
+
getShortMonthName(month: any): string;
|
|
11
|
+
static isJulian(date: any): boolean;
|
|
12
|
+
static gregorianToAJD(date: any): number;
|
|
13
|
+
ajdToGregorian(ajd: any): Date;
|
|
14
|
+
static isKabisa(year: any): boolean;
|
|
15
|
+
static daysInMonth(year: any, month: any): 29 | 30;
|
|
16
|
+
dayOfYear(): any;
|
|
17
|
+
static fromAJD(ajd: any): HijriDate;
|
|
18
|
+
toAJD(): any;
|
|
19
|
+
static fromGregorian(date: any): HijriDate;
|
|
20
|
+
toGregorian(): Date;
|
|
21
|
+
}
|