@react-fabric/date 1.0.0-beta.5 → 1.0.0-beta.52
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 +2 -9
- package/{src/components/Date.module.css → css/_date.css} +5 -5
- package/{src/superdate/SuperDate.module.css → css/styles.css} +2 -8
- package/dist/cjs/components/DatePage.js +2 -3
- package/dist/cjs/components/TimeSliders.js +5 -6
- package/dist/cjs/display/DateDisplay.js +24 -2
- package/dist/cjs/display/DateDuration.js +143 -0
- package/dist/cjs/hijri/DateConverter.js +154 -0
- package/dist/cjs/hijri/FormatDate.js +116 -0
- package/dist/cjs/hijri/HijriDate.js +531 -0
- package/dist/cjs/hijri/StringDateParser.js +74 -0
- package/dist/cjs/hijri/index.js +17 -1025
- package/dist/cjs/hijri/initializer.js +113 -0
- package/dist/cjs/hijri/locales.js +19 -0
- package/dist/cjs/hijri/safe.js +17 -0
- package/dist/cjs/i18n/ar.json.js +191 -3
- package/dist/cjs/i18n/en.json.js +63 -1
- package/dist/cjs/i18n/index.js +0 -6
- package/dist/cjs/index.js +13 -2
- package/dist/cjs/panels/DatePanel.js +26 -0
- package/dist/cjs/{superdate → panels}/EventPanel.js +16 -4
- package/dist/cjs/panels/RangePanel.js +22 -0
- package/dist/cjs/utils/dateUtil.js +3 -3
- package/dist/esm/components/DatePage.js +2 -3
- package/dist/esm/components/TimeSliders.js +5 -6
- package/dist/esm/display/DateDisplay.js +24 -2
- package/dist/esm/display/DateDuration.js +143 -0
- package/dist/esm/hijri/DateConverter.js +152 -0
- package/dist/esm/hijri/FormatDate.js +113 -0
- package/dist/esm/hijri/HijriDate.js +528 -0
- package/dist/esm/hijri/StringDateParser.js +74 -0
- package/dist/esm/hijri/index.js +17 -1025
- package/dist/esm/hijri/initializer.js +113 -0
- package/dist/esm/hijri/locales.js +18 -0
- package/dist/esm/hijri/safe.js +14 -0
- package/dist/esm/i18n/ar.json.js +191 -3
- package/dist/esm/i18n/en.json.js +63 -2
- package/dist/esm/i18n/index.js +0 -6
- package/dist/esm/index.js +6 -1
- package/dist/esm/panels/DatePanel.js +26 -0
- package/dist/esm/{superdate → panels}/EventPanel.js +17 -5
- package/dist/esm/panels/RangePanel.js +22 -0
- package/dist/esm/utils/dateUtil.js +3 -3
- package/dist/types/display/DateDisplay.d.ts +21 -3
- package/dist/types/display/DateDuration.d.ts +31 -0
- package/dist/types/hijri/DateConverter.d.ts +13 -0
- package/dist/types/hijri/FormatDate.d.ts +19 -0
- package/dist/types/hijri/HijriDate.d.ts +214 -0
- package/dist/types/hijri/StringDateParser.d.ts +11 -0
- package/dist/types/hijri/index.d.ts +2 -2
- package/dist/types/hijri/initializer.d.ts +129 -0
- package/dist/types/hijri/locales.d.ts +19 -0
- package/dist/types/hijri/safe.d.ts +3 -0
- package/dist/types/index.d.ts +6 -1
- package/dist/types/panels/DatePanel.d.ts +26 -0
- package/dist/types/panels/EventPanel.d.ts +17 -0
- package/dist/types/panels/RangePanel.d.ts +22 -0
- package/dist/types/types/index.d.ts +8 -35
- package/dist/types/utils/dateUtil.d.ts +1 -1
- package/package.json +11 -11
- package/src/components/DatePage.tsx +2 -3
- package/src/components/TimeSliders.tsx +5 -6
- package/src/display/DateDisplay.tsx +32 -4
- package/src/display/DateDuration.tsx +180 -0
- package/src/hijri/DateConverter.js +175 -0
- package/src/hijri/FormatDate.js +134 -0
- package/src/hijri/HijriDate.js +477 -0
- package/src/hijri/StringDateParser.js +68 -0
- package/src/hijri/index.js +16 -1535
- package/src/hijri/initializer.js +96 -0
- package/src/hijri/locales.js +109 -0
- package/src/hijri/safe.js +16 -0
- package/src/i18n/ar.json +190 -1
- package/src/i18n/en.json +60 -0
- package/src/i18n/index.ts +0 -3
- package/src/index.ts +7 -1
- package/src/panels/DatePanel.tsx +26 -0
- package/src/{superdate → panels}/EventPanel.tsx +41 -6
- package/src/panels/RangePanel.tsx +22 -0
- package/src/types/index.ts +8 -38
- package/src/utils/dateUtil.ts +4 -7
- package/dist/cjs/components/Date.module.css +0 -1
- package/dist/cjs/i18n/superdate/ar.json.js +0 -86
- package/dist/cjs/i18n/superdate/en.json.js +0 -93
- package/dist/cjs/superdate/QuickSelect.js +0 -134
- package/dist/cjs/superdate/RelativeInput.js +0 -79
- package/dist/cjs/superdate/RelativePanel.js +0 -91
- package/dist/cjs/superdate/SuperDate.module.css +0 -1
- package/dist/cjs/superdate/Superdate.js +0 -169
- package/dist/esm/components/Date.module.css +0 -1
- package/dist/esm/i18n/superdate/ar.json.js +0 -79
- package/dist/esm/i18n/superdate/en.json.js +0 -85
- package/dist/esm/superdate/QuickSelect.js +0 -134
- package/dist/esm/superdate/RelativeInput.js +0 -79
- package/dist/esm/superdate/RelativePanel.js +0 -91
- package/dist/esm/superdate/SuperDate.module.css +0 -1
- package/dist/esm/superdate/Superdate.js +0 -168
- package/dist/types/superdate/EventPanel.d.ts +0 -4
- package/dist/types/superdate/QuickSelect.d.ts +0 -1
- package/dist/types/superdate/RelativeInput.d.ts +0 -1
- package/dist/types/superdate/RelativePanel.d.ts +0 -1
- package/dist/types/superdate/Superdate.d.ts +0 -17
- package/src/i18n/superdate/ar.json +0 -70
- package/src/i18n/superdate/en.json +0 -75
- package/src/superdate/QuickSelect.tsx +0 -121
- package/src/superdate/RelativeInput.tsx +0 -64
- package/src/superdate/RelativePanel.tsx +0 -103
- package/src/superdate/Superdate.tsx +0 -186
package/README.md
CHANGED
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
@layer
|
|
25
|
-
.dateHeader {
|
|
26
|
-
box-shadow: 0 -1px 0
|
|
24
|
+
@layer components {
|
|
25
|
+
.fabric-dateHeader {
|
|
26
|
+
box-shadow: 0 -1px 0 --alpha(var(--color-tint-200) / 50%) inset;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.timeSlider {
|
|
29
|
+
.fabric-date-timeSlider {
|
|
30
30
|
height: 11.25rem;
|
|
31
31
|
|
|
32
32
|
&::before,
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
content: "";
|
|
35
35
|
z-index: 10;
|
|
36
36
|
display: block;
|
|
37
|
-
box-shadow: 0 0 3rem 0.25rem
|
|
37
|
+
box-shadow: 0 0 3rem 0.25rem var(--color-tint-600);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&::before {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
*
|
|
6
6
|
* The MIT License (MIT)
|
|
7
|
-
* Copyright (c)
|
|
7
|
+
* Copyright (c) 2025 Adarsh Pastakia
|
|
8
8
|
*
|
|
9
9
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
10
|
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
@@ -21,10 +21,4 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
@
|
|
25
|
-
.superDate {
|
|
26
|
-
&:root {
|
|
27
|
-
font-size: 10px;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
24
|
+
@import "./_date.css";
|
|
@@ -9,7 +9,6 @@ var dateUtil = require('../utils/dateUtil.js');
|
|
|
9
9
|
var DateCell = require('./DateCell.js');
|
|
10
10
|
var classNames = require('classnames');
|
|
11
11
|
var index = require('../types/index.js');
|
|
12
|
-
var Date_module = require('./Date.module.css');
|
|
13
12
|
var jsxRuntime = require('react/jsx-runtime');
|
|
14
13
|
|
|
15
14
|
var _excluded = ["pageDate", "isHijri"];
|
|
@@ -29,11 +28,11 @@ var DatePage = function DatePage(_ref) {
|
|
|
29
28
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
30
29
|
className: classNames("grid grid-cols-8 area-content", props.page !== index.PageType.DATE && "invisible"),
|
|
31
30
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
32
|
-
className: classNames(
|
|
31
|
+
className: classNames("fabric-dateHeader", "px-1 text-center bg-tint-50 h-7")
|
|
33
32
|
}), cols.map(function (col) {
|
|
34
33
|
var dt = dateUtil.DateUtil.addDays(startDate, col, isHijri);
|
|
35
34
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
36
|
-
className: classNames(
|
|
35
|
+
className: classNames("fabric-dateHeader", "font-medium text-sm p-1 mx-px text-center text-muted bg-tint-50 h-7"),
|
|
37
36
|
children: dateUtil.DateUtil.format(dt, "eeeeee", i18next.language, isHijri)
|
|
38
37
|
}, dt.toISOString());
|
|
39
38
|
}), rows.map(function (row) {
|
|
@@ -4,7 +4,6 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
|
4
4
|
var core = require('@react-fabric/core');
|
|
5
5
|
var classNames = require('classnames');
|
|
6
6
|
var react = require('react');
|
|
7
|
-
var Date_module = require('./Date.module.css');
|
|
8
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
8
|
|
|
10
9
|
var TimeSlider = function TimeSlider(_ref) {
|
|
@@ -58,16 +57,16 @@ var TimeSlider = function TimeSlider(_ref) {
|
|
|
58
57
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
59
58
|
className: "flex",
|
|
60
59
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
61
|
-
className: classNames(
|
|
60
|
+
className: classNames("fabric-dateHeader", "flex-1 font-medium text-muted text-sm p-1 mx-px text-center bg-tint-50"),
|
|
62
61
|
children: "H"
|
|
63
62
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
64
|
-
className: classNames(
|
|
63
|
+
className: classNames("fabric-dateHeader", "flex-1 font-medium text-muted text-sm p-1 mx-px text-center bg-tint-50"),
|
|
65
64
|
children: "M"
|
|
66
65
|
})]
|
|
67
66
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
68
|
-
className: "flex flex-1 flex-nowrap overflow-hidden relative",
|
|
67
|
+
className: "flex flex-1 flex-nowrap items-stretch overflow-hidden relative",
|
|
69
68
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
70
|
-
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory",
|
|
69
|
+
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory", "fabric-date-timeSlider"),
|
|
71
70
|
onScroll: calculateTime,
|
|
72
71
|
ref: hourRef,
|
|
73
72
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -92,7 +91,7 @@ var TimeSlider = function TimeSlider(_ref) {
|
|
|
92
91
|
className: "w-full"
|
|
93
92
|
})]
|
|
94
93
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
95
|
-
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory",
|
|
94
|
+
className: classNames("flex-1 overflow-auto scroll-hide snap-y snap-mandatory", "fabric-date-timeSlider"),
|
|
96
95
|
onScroll: calculateTime,
|
|
97
96
|
ref: minuteRef,
|
|
98
97
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -4,30 +4,52 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
4
4
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
5
|
var core = require('@react-fabric/core');
|
|
6
6
|
var dateUtil = require('../utils/dateUtil.js');
|
|
7
|
+
var classNames = require('classnames');
|
|
7
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
9
|
|
|
9
|
-
var _excluded = ["date", "className", "format", "children"];
|
|
10
|
+
var _excluded = ["date", "className", "format", "children", "showAlternateDate"];
|
|
10
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
/**
|
|
14
|
+
* DateDisplay component to display a formatted gregorian or hijri date with optional tooltip and dropdown.
|
|
15
|
+
* It uses the current calendar and locale from the global context.
|
|
16
|
+
* It formats the date using the provided format or a default format.
|
|
17
|
+
* If `showAlternateDate` is true, it shows a tooltip with the formatted date.
|
|
18
|
+
* If `children` are provided, it wraps the date in a dropdown.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props - The component props.
|
|
21
|
+
* @returns {JSX.Element} - The rendered component.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <DateDisplay date={new Date()} />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
29
|
+
*/
|
|
12
30
|
var DateDisplay = function DateDisplay(_ref) {
|
|
13
31
|
var date = _ref.date,
|
|
14
32
|
className = _ref.className,
|
|
15
33
|
_ref$format = _ref.format,
|
|
16
34
|
format = _ref$format === void 0 ? "eee, PPpp" : _ref$format,
|
|
17
35
|
children = _ref.children,
|
|
36
|
+
showAlternateDate = _ref.showAlternateDate,
|
|
18
37
|
aria = _objectWithoutProperties(_ref, _excluded);
|
|
19
38
|
var _useGlobals = core.useGlobals(),
|
|
20
39
|
currentCalendar = _useGlobals.currentCalendar,
|
|
21
40
|
currentLocale = _useGlobals.currentLocale;
|
|
22
41
|
var dtLabel = /*#__PURE__*/jsxRuntime.jsx(core.Tooltip, {
|
|
42
|
+
disabled: !showAlternateDate,
|
|
23
43
|
content: dateUtil.DateUtil.format(date, format, currentLocale, currentCalendar !== "hijri"),
|
|
24
44
|
children: /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({
|
|
25
|
-
className: className
|
|
45
|
+
className: classNames(className, !!children && "underline decoration-dotted cursor-pointer")
|
|
26
46
|
}, aria), {}, {
|
|
27
47
|
children: dateUtil.DateUtil.format(date, format, currentLocale, currentCalendar === "hijri")
|
|
28
48
|
}))
|
|
29
49
|
});
|
|
30
50
|
return children ? /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
|
|
51
|
+
showArrow: true,
|
|
52
|
+
closeOnClick: true,
|
|
31
53
|
children: [dtLabel, children]
|
|
32
54
|
}) : dtLabel;
|
|
33
55
|
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
|
+
var core = require('@react-fabric/core');
|
|
6
|
+
var utilities = require('@react-fabric/utilities');
|
|
7
|
+
var classNames = require('classnames');
|
|
8
|
+
var dateFns = require('date-fns');
|
|
9
|
+
var react = require('react');
|
|
10
|
+
var reactI18next = require('react-i18next');
|
|
11
|
+
var dateUtil = require('../utils/dateUtil.js');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
+
|
|
14
|
+
var _excluded = ["date", "children", "className", "format"];
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
/**
|
|
18
|
+
* DateDuration component to display the duration from a given date to now.
|
|
19
|
+
* It calculates the difference in years, months, weeks, days, hours, minutes, and seconds,
|
|
20
|
+
* and displays it in a human-readable format.
|
|
21
|
+
* It uses the current locale for translations.
|
|
22
|
+
*
|
|
23
|
+
* @param {Props} props - The properties for the component.
|
|
24
|
+
* @returns {JSX.Element} The rendered component.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```jsx
|
|
28
|
+
* <DateDuration date={new Date("2020-01-01")} />
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/date-date-display--docs}
|
|
32
|
+
*/
|
|
33
|
+
var DateDuration = function DateDuration(_ref) {
|
|
34
|
+
var date = _ref.date,
|
|
35
|
+
children = _ref.children,
|
|
36
|
+
className = _ref.className,
|
|
37
|
+
_ref$format = _ref.format,
|
|
38
|
+
format = _ref$format === void 0 ? "PPpp" : _ref$format,
|
|
39
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
40
|
+
var _useTranslation = reactI18next.useTranslation("date"),
|
|
41
|
+
t = _useTranslation.t;
|
|
42
|
+
var interval = react.useMemo(function () {
|
|
43
|
+
return dateFns.intervalToDuration({
|
|
44
|
+
start: new Date(date),
|
|
45
|
+
end: new Date()
|
|
46
|
+
});
|
|
47
|
+
}, [date]);
|
|
48
|
+
var label = react.useMemo(function () {
|
|
49
|
+
var before = dateFns.isBefore(dateUtil.DateUtil.parseDate(date), new Date());
|
|
50
|
+
var tkey = before ? "relative.before" : "relative.after";
|
|
51
|
+
var part = "now";
|
|
52
|
+
var count = 0;
|
|
53
|
+
if (interval.years && interval.years > 0) {
|
|
54
|
+
var _interval$months;
|
|
55
|
+
part = "years";
|
|
56
|
+
count = interval.years;
|
|
57
|
+
if (((_interval$months = interval.months) !== null && _interval$months !== void 0 ? _interval$months : 0) > 10) {
|
|
58
|
+
part = "yearsX";
|
|
59
|
+
count += 1;
|
|
60
|
+
}
|
|
61
|
+
} else if (interval.months && interval.months > 0) {
|
|
62
|
+
var _interval$weeks;
|
|
63
|
+
part = "months";
|
|
64
|
+
count = interval.months;
|
|
65
|
+
if (interval.months > 10) {
|
|
66
|
+
part = "yearsX";
|
|
67
|
+
count = 1;
|
|
68
|
+
} else if (((_interval$weeks = interval.weeks) !== null && _interval$weeks !== void 0 ? _interval$weeks : 0) > 3) {
|
|
69
|
+
part = "monthsX";
|
|
70
|
+
count += 1;
|
|
71
|
+
}
|
|
72
|
+
} else if (interval.weeks && interval.weeks > 0) {
|
|
73
|
+
var _interval$days;
|
|
74
|
+
part = "weeks";
|
|
75
|
+
count = interval.weeks;
|
|
76
|
+
if (interval.weeks > 3) {
|
|
77
|
+
part = "monthsX";
|
|
78
|
+
count = 1;
|
|
79
|
+
} else if (((_interval$days = interval.days) !== null && _interval$days !== void 0 ? _interval$days : 0) > 5) {
|
|
80
|
+
part = "weeksX";
|
|
81
|
+
count += 1;
|
|
82
|
+
}
|
|
83
|
+
} else if (interval.days && interval.days > 0) {
|
|
84
|
+
var _interval$hours;
|
|
85
|
+
part = "days";
|
|
86
|
+
count = interval.days;
|
|
87
|
+
if (interval.days > 5) {
|
|
88
|
+
part = "weeksX";
|
|
89
|
+
count = 1;
|
|
90
|
+
} else if (((_interval$hours = interval.hours) !== null && _interval$hours !== void 0 ? _interval$hours : 0) > 20) {
|
|
91
|
+
part = "daysX";
|
|
92
|
+
count += 1;
|
|
93
|
+
}
|
|
94
|
+
} else if (interval.hours && interval.hours > 0) {
|
|
95
|
+
var _interval$minutes;
|
|
96
|
+
part = "hours";
|
|
97
|
+
count = interval.hours;
|
|
98
|
+
if (interval.hours > 20) {
|
|
99
|
+
part = "daysX";
|
|
100
|
+
count = 1;
|
|
101
|
+
} else if (((_interval$minutes = interval.minutes) !== null && _interval$minutes !== void 0 ? _interval$minutes : 0) > 45) {
|
|
102
|
+
part = "hoursX";
|
|
103
|
+
count += 1;
|
|
104
|
+
}
|
|
105
|
+
} else if (interval.minutes && interval.minutes > 0) {
|
|
106
|
+
var _interval$seconds;
|
|
107
|
+
part = "minutes";
|
|
108
|
+
count = interval.minutes;
|
|
109
|
+
if (interval.minutes > 45) {
|
|
110
|
+
part = "hoursX";
|
|
111
|
+
count = 1;
|
|
112
|
+
} else if (((_interval$seconds = interval.seconds) !== null && _interval$seconds !== void 0 ? _interval$seconds : 0) > 45) {
|
|
113
|
+
part = "minuteX";
|
|
114
|
+
count += 1;
|
|
115
|
+
}
|
|
116
|
+
} else if (interval.seconds && interval.seconds > 15) {
|
|
117
|
+
part = "seconds";
|
|
118
|
+
count = interval.seconds;
|
|
119
|
+
if (interval.seconds > 45) {
|
|
120
|
+
part = "minutesX";
|
|
121
|
+
count = 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return t("".concat(tkey, ".").concat(part), {
|
|
125
|
+
count: count
|
|
126
|
+
});
|
|
127
|
+
}, [interval, date]);
|
|
128
|
+
var dtLabel = /*#__PURE__*/jsxRuntime.jsx(core.Tooltip, {
|
|
129
|
+
content: utilities.Format.date(date, format),
|
|
130
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({
|
|
131
|
+
className: classNames(className, !!children && "underline decoration-dotted cursor-pointer")
|
|
132
|
+
}, props), {}, {
|
|
133
|
+
children: label
|
|
134
|
+
}))
|
|
135
|
+
});
|
|
136
|
+
return children ? /*#__PURE__*/jsxRuntime.jsxs(core.Dropdown, {
|
|
137
|
+
showArrow: true,
|
|
138
|
+
closeOnClick: true,
|
|
139
|
+
children: [dtLabel, children]
|
|
140
|
+
}) : dtLabel;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
exports.DateDuration = DateDuration;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function intPart(floatNum) {
|
|
4
|
+
if (floatNum < -0.0000001) {
|
|
5
|
+
return Math.ceil(floatNum - 0.0000001);
|
|
6
|
+
}
|
|
7
|
+
return Math.floor(floatNum + 0.0000001);
|
|
8
|
+
}
|
|
9
|
+
var delta = 1;
|
|
10
|
+
function GregToIsl(arg) {
|
|
11
|
+
var d = parseInt(arg.CDay.value);
|
|
12
|
+
var m = parseInt(arg.CMonth.value);
|
|
13
|
+
var y = parseInt(arg.CYear.value);
|
|
14
|
+
var jd,
|
|
15
|
+
l,
|
|
16
|
+
jd1,
|
|
17
|
+
n,
|
|
18
|
+
j,
|
|
19
|
+
delta = 1;
|
|
20
|
+
if (y > 1582 || y == 1582 && m > 10 || y == 1582 && m == 10 && d > 14) {
|
|
21
|
+
//added delta=1 on jd to comply isna rulling 2007
|
|
22
|
+
jd = intPart(1461 * (y + 4800 + intPart((m - 14) / 12)) / 4) + intPart(367 * (m - 2 - 12 * intPart((m - 14) / 12)) / 12) - intPart(3 * intPart((y + 4900 + intPart((m - 14) / 12)) / 100) / 4) + d - 32075 + delta;
|
|
23
|
+
} else {
|
|
24
|
+
//added +1 on jd to comply isna rulling
|
|
25
|
+
jd = 367 * y - intPart(7 * (y + 5001 + intPart((m - 9) / 7)) / 4) + intPart(275 * m / 9) + d + 1729777 + delta;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//added -1 on jd1 to comply isna rulling
|
|
29
|
+
jd1 = jd - delta;
|
|
30
|
+
l = jd - 1948440 + 10632;
|
|
31
|
+
n = intPart((l - 1) / 10631);
|
|
32
|
+
l = l - 10631 * n + 354;
|
|
33
|
+
j = intPart((10985 - l) / 5316) * intPart(50 * l / 17719) + intPart(l / 5670) * intPart(43 * l / 15238);
|
|
34
|
+
l = l - intPart((30 - j) / 15) * intPart(17719 * j / 50) - intPart(j / 16) * intPart(15238 * j / 43) + 29;
|
|
35
|
+
m = intPart(24 * l / 709);
|
|
36
|
+
d = l - intPart(709 * m / 24);
|
|
37
|
+
y = 30 * n + j - 30;
|
|
38
|
+
return {
|
|
39
|
+
d: d,
|
|
40
|
+
m: m,
|
|
41
|
+
y: y,
|
|
42
|
+
dateOfWeek: jd1 % 7,
|
|
43
|
+
dayName: weekDay(jd1 % 7)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function IslToGreg(arg) {
|
|
47
|
+
var d = parseInt(arg.HDay.value);
|
|
48
|
+
var m = parseInt(arg.HMonth.value);
|
|
49
|
+
var y = parseInt(arg.HYear.value);
|
|
50
|
+
//added - delta=1 on jd to comply isna rulling
|
|
51
|
+
var jd = intPart((11 * y + 3) / 30) + 354 * y + 30 * m - intPart((m - 1) / 2) + d + 1948440 - 385 - delta;
|
|
52
|
+
var l, n, i, j, k;
|
|
53
|
+
if (jd > 2299160) {
|
|
54
|
+
l = jd + 68569;
|
|
55
|
+
n = intPart(4 * l / 146097);
|
|
56
|
+
l = l - intPart((146097 * n + 3) / 4);
|
|
57
|
+
i = intPart(4000 * (l + 1) / 1461001);
|
|
58
|
+
l = l - intPart(1461 * i / 4) + 31;
|
|
59
|
+
j = intPart(80 * l / 2447);
|
|
60
|
+
d = l - intPart(2447 * j / 80);
|
|
61
|
+
l = intPart(j / 11);
|
|
62
|
+
m = j + 2 - 12 * l;
|
|
63
|
+
y = 100 * (n - 49) + i + l;
|
|
64
|
+
} else {
|
|
65
|
+
j = jd + 1402;
|
|
66
|
+
k = intPart((j - 1) / 1461);
|
|
67
|
+
l = j - 1461 * k;
|
|
68
|
+
n = intPart((l - 1) / 365) - intPart(l / 1461);
|
|
69
|
+
i = l - 365 * n + 30;
|
|
70
|
+
j = intPart(80 * i / 2447);
|
|
71
|
+
d = i - intPart(2447 * j / 80);
|
|
72
|
+
i = intPart(j / 11);
|
|
73
|
+
m = j + 2 - 12 * i;
|
|
74
|
+
y = 4 * k + n + i - 4716;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//arg.CDay.value=d
|
|
78
|
+
//arg.CMonth.value=m
|
|
79
|
+
//arg.CYear.value=y
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
d: d,
|
|
83
|
+
m: m,
|
|
84
|
+
y: y,
|
|
85
|
+
dateOfWeek: jd % 7,
|
|
86
|
+
dayName: weekDay(jd % 7)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function weekDay(wdn) {
|
|
90
|
+
if (wdn == 0) {
|
|
91
|
+
return "Mon";
|
|
92
|
+
}
|
|
93
|
+
if (wdn == 1) {
|
|
94
|
+
return "Tue";
|
|
95
|
+
}
|
|
96
|
+
if (wdn == 2) {
|
|
97
|
+
return "Wed";
|
|
98
|
+
}
|
|
99
|
+
if (wdn == 3) {
|
|
100
|
+
return "Thu";
|
|
101
|
+
}
|
|
102
|
+
if (wdn == 4) {
|
|
103
|
+
return "Fri";
|
|
104
|
+
}
|
|
105
|
+
if (wdn == 5) {
|
|
106
|
+
return "Sat";
|
|
107
|
+
}
|
|
108
|
+
if (wdn == 6) {
|
|
109
|
+
return "Sun";
|
|
110
|
+
}
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
function GregToHijri(gregDate) {
|
|
114
|
+
var hijriDate = GregToIsl({
|
|
115
|
+
CDay: {
|
|
116
|
+
value: gregDate.getDate()
|
|
117
|
+
},
|
|
118
|
+
CYear: {
|
|
119
|
+
value: gregDate.getFullYear()
|
|
120
|
+
},
|
|
121
|
+
CMonth: {
|
|
122
|
+
value: gregDate.getMonth() + 1
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
year: hijriDate.y,
|
|
127
|
+
month: hijriDate.m,
|
|
128
|
+
date: hijriDate.d,
|
|
129
|
+
hours: gregDate.getHours(),
|
|
130
|
+
minutes: gregDate.getMinutes(),
|
|
131
|
+
seconds: gregDate.getSeconds(),
|
|
132
|
+
milliseconds: gregDate.getMilliseconds(),
|
|
133
|
+
day: hijriDate.dateOfWeek,
|
|
134
|
+
dayName: hijriDate.dayName
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function HijriToGreg(hijriDate) {
|
|
138
|
+
var gregDate = IslToGreg({
|
|
139
|
+
HDay: {
|
|
140
|
+
value: hijriDate._date || hijriDate.date
|
|
141
|
+
},
|
|
142
|
+
HYear: {
|
|
143
|
+
value: hijriDate._year || hijriDate.year
|
|
144
|
+
},
|
|
145
|
+
HMonth: {
|
|
146
|
+
value: hijriDate._month || hijriDate.month
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return new Date(gregDate.y, gregDate.m - 1, gregDate.d, hijriDate.getHours(), hijriDate.getMinutes(), hijriDate.getSeconds(), hijriDate.getMilliseconds());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
exports.GregToHijri = GregToHijri;
|
|
153
|
+
exports.HijriToGreg = HijriToGreg;
|
|
154
|
+
exports.weekDay = weekDay;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var HijriDate = require('./HijriDate.js');
|
|
6
|
+
|
|
7
|
+
var dateFormat = function () {
|
|
8
|
+
var token = /P{1,4}|p{1,4}|d{1,2}|e{3,6}|M{1,4}|yy(?:yy)?|([Hhms])\1?|[a]{1,4}|[LloSZ]|('at')|"[^"]*"|'[^']*'/g,
|
|
9
|
+
pad = function pad(val, len) {
|
|
10
|
+
val = String(val);
|
|
11
|
+
len = len || 2;
|
|
12
|
+
while (val.length < len) val = "0" + val;
|
|
13
|
+
return val;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Regexes and supporting functions are cached through closure
|
|
17
|
+
return function (date, mask) {
|
|
18
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
19
|
+
utc: false
|
|
20
|
+
};
|
|
21
|
+
var locales = HijriDate.default.locales,
|
|
22
|
+
defaultLocale = HijriDate.default.defaultLocale;
|
|
23
|
+
options.locale = options.locale || defaultLocale;
|
|
24
|
+
if (!locales[options.locale]) {
|
|
25
|
+
throw new Error("Locale ".concat(options.locale, " is not supported yet .\n Please, try to extend \"HijriDate.locales\" :\n i.e: HijriDate.locales.").concat(options.locale, " = {dayNames:[..14 items..], monthNames:[..24 items..]}\n "));
|
|
26
|
+
}
|
|
27
|
+
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
|
|
28
|
+
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
|
|
29
|
+
mask = date;
|
|
30
|
+
date = undefined;
|
|
31
|
+
}
|
|
32
|
+
mask = String(masks[mask] || mask || masks["default"]);
|
|
33
|
+
|
|
34
|
+
// Allow setting the utc argument via the mask
|
|
35
|
+
if (mask.slice(0, 4) == "UTC:") {
|
|
36
|
+
mask = mask.slice(4);
|
|
37
|
+
options.utc = true;
|
|
38
|
+
}
|
|
39
|
+
var _ = options.utc ? "getUTC" : "get",
|
|
40
|
+
d = date[_ + "Date"](),
|
|
41
|
+
D = date[_ + "Day"](),
|
|
42
|
+
M = date[_ + "Month"](),
|
|
43
|
+
mIndex = date[_ + "MonthIndex"](),
|
|
44
|
+
y = date[_ + "FullYear"](),
|
|
45
|
+
H = date[_ + "Hours"](),
|
|
46
|
+
m = date[_ + "Minutes"](),
|
|
47
|
+
s = date[_ + "Seconds"](),
|
|
48
|
+
L = date[_ + "Milliseconds"](),
|
|
49
|
+
o = options.utc ? 0 : date.getTimezoneOffset(),
|
|
50
|
+
flags = {
|
|
51
|
+
d: d,
|
|
52
|
+
dd: pad(d),
|
|
53
|
+
ddd: locales[options.locale].dayNames[D === 7 ? 0 : D + 1],
|
|
54
|
+
dddd: locales[options.locale].dayNames[(D === 7 ? 0 : D + 1) + 7],
|
|
55
|
+
ee: locales[options.locale].dayNames[D],
|
|
56
|
+
eee: locales[options.locale].dayNames[D + 7],
|
|
57
|
+
eeee: locales[options.locale].dayNames[D + 14],
|
|
58
|
+
eeeeee: locales[options.locale].dayNames[D],
|
|
59
|
+
M: M,
|
|
60
|
+
MM: pad(M),
|
|
61
|
+
MMM: locales[options.locale].monthNames[mIndex],
|
|
62
|
+
MMMM: locales[options.locale].monthNames[mIndex + 12],
|
|
63
|
+
yy: String(y).slice(2),
|
|
64
|
+
yyyy: y,
|
|
65
|
+
h: H % 12 || 12,
|
|
66
|
+
hh: pad(H % 12 || 12),
|
|
67
|
+
H: H,
|
|
68
|
+
HH: pad(H),
|
|
69
|
+
m: m,
|
|
70
|
+
mm: pad(m),
|
|
71
|
+
s: s,
|
|
72
|
+
ss: pad(s),
|
|
73
|
+
l: pad(L, 3),
|
|
74
|
+
L: pad(L > 99 ? Math.round(L / 10) : L),
|
|
75
|
+
a: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
76
|
+
aa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
77
|
+
aaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
78
|
+
aaaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
79
|
+
aaaaa: H < 12 ? locales[options.locale].am : locales[options.locale].pm,
|
|
80
|
+
"'at'": locales[options.locale].separator,
|
|
81
|
+
t: H < 12 ? "a" : "p",
|
|
82
|
+
tt: H < 12 ? "am" : "pm",
|
|
83
|
+
T: H < 12 ? "A" : "P",
|
|
84
|
+
TT: H < 12 ? "AM" : "PM",
|
|
85
|
+
// Z: options.utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
|
|
86
|
+
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
|
|
87
|
+
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
|
|
88
|
+
};
|
|
89
|
+
return mask.replace(token, function ($0) {
|
|
90
|
+
if ($0 === "P") return "".concat(flags.d, "/").concat(flags.M, "/").concat(flags.yyyy, " ");
|
|
91
|
+
if ($0.startsWith("PP")) return "".concat(flags.MMM, " ").concat(flags.dd, ", ").concat(flags.yyyy, " ");
|
|
92
|
+
if ($0 === "p") return "".concat(flags.h, ":").concat(flags.m, " ").concat(flags.a);
|
|
93
|
+
if ($0.startsWith("pp")) return "".concat(flags.hh, ":").concat(flags.mm, ":").concat(flags.ss, " ").concat(flags.a);
|
|
94
|
+
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
}();
|
|
98
|
+
|
|
99
|
+
// Some common format strings
|
|
100
|
+
var masks = {
|
|
101
|
+
"default": "ddd MMM dd yyyy HH:mm:ss",
|
|
102
|
+
shortDate: "M/d/yy",
|
|
103
|
+
mediumDate: "MMM d, yyyy",
|
|
104
|
+
longDate: "MMMM d, yyyy",
|
|
105
|
+
fullDate: "dddd, MMMM d, yyyy",
|
|
106
|
+
shortTime: "h:mm TT",
|
|
107
|
+
mediumTime: "h:mm:ss TT",
|
|
108
|
+
longTime: "h:mm:ss TT Z",
|
|
109
|
+
isoDate: "yyyy-MM-dd",
|
|
110
|
+
isoTime: "HH:mm:ss",
|
|
111
|
+
isoDateTime: "yyyy-MM-dd'T'HH:mm:ss",
|
|
112
|
+
isoUtcDateTime: "UTC:yyyy-MM-dd'T'HH:mm:ss'Z'"
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
exports.default = dateFormat;
|
|
116
|
+
exports.masks = masks;
|