@react-fabric/date 1.0.0-beta.4 → 1.0.0-beta.41
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 +5 -1
- package/dist/cjs/hijri/DateConverter.js +154 -0
- package/dist/cjs/hijri/FormatDate.js +115 -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/index.js +0 -6
- package/dist/cjs/index.js +11 -2
- package/dist/cjs/{superdate → panels}/EventPanel.js +16 -4
- 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 +5 -1
- package/dist/esm/hijri/DateConverter.js +152 -0
- package/dist/esm/hijri/FormatDate.js +112 -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/index.js +0 -6
- package/dist/esm/index.js +5 -1
- package/dist/esm/{superdate → panels}/EventPanel.js +17 -5
- package/dist/esm/utils/dateUtil.js +3 -3
- package/dist/types/display/DateDisplay.d.ts +2 -1
- 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 +5 -1
- package/dist/types/panels/EventPanel.d.ts +17 -0
- package/dist/types/types/index.d.ts +8 -35
- package/dist/types/utils/dateUtil.d.ts +1 -1
- package/package.json +8 -8
- package/src/components/DatePage.tsx +2 -3
- package/src/components/TimeSliders.tsx +5 -6
- package/src/display/DateDisplay.tsx +5 -1
- package/src/hijri/DateConverter.js +175 -0
- package/src/hijri/FormatDate.js +132 -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/index.ts +0 -3
- package/src/index.ts +6 -1
- package/src/{superdate → panels}/EventPanel.tsx +41 -6
- 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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GregToHijri
|
|
3
|
+
} from './DateConverter';
|
|
4
|
+
import StringDateParser from './StringDateParser';
|
|
5
|
+
|
|
6
|
+
const defaultFormat = 'yyyy/mm/dd';
|
|
7
|
+
const defaultProps ={
|
|
8
|
+
month:1,
|
|
9
|
+
date:1,
|
|
10
|
+
hours:0,
|
|
11
|
+
minutes:0,
|
|
12
|
+
seconds:0,
|
|
13
|
+
milliseconds:0
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class Initializer {
|
|
17
|
+
|
|
18
|
+
static initDefault() {
|
|
19
|
+
return GregToHijri(new Date());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static init_number (number) {
|
|
23
|
+
return GregToHijri(new Date(number));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static init_number_number (year, month) {
|
|
27
|
+
|
|
28
|
+
return this.init_number_number_number(year, month, 1);
|
|
29
|
+
}
|
|
30
|
+
static init_number_number_number () {
|
|
31
|
+
return this.initFromNumbers(...arguments);
|
|
32
|
+
}
|
|
33
|
+
static init_number_number_number_number () {
|
|
34
|
+
return this.initFromNumbers(...arguments);
|
|
35
|
+
}
|
|
36
|
+
static init_number_number_number_number_number () {
|
|
37
|
+
return this.initFromNumbers(...arguments);
|
|
38
|
+
}
|
|
39
|
+
static init_number_number_number_number_number_number () {
|
|
40
|
+
return this.initFromNumbers(...arguments);
|
|
41
|
+
}
|
|
42
|
+
static init_number_number_number_number_number_number_number () {
|
|
43
|
+
return this.initFromNumbers(...arguments);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static init_string() {
|
|
47
|
+
return this.initFromStrings(...arguments);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static init_string_string() {
|
|
51
|
+
return this.initFromStrings(...arguments);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static init_object(object) {
|
|
55
|
+
return Object.assign({}, defaultProps, object);
|
|
56
|
+
}
|
|
57
|
+
static initFromNumbers(year,
|
|
58
|
+
month,
|
|
59
|
+
date,
|
|
60
|
+
hours = 0,
|
|
61
|
+
minutes = 0,
|
|
62
|
+
seconds = 0,
|
|
63
|
+
milliseconds = 0)
|
|
64
|
+
{
|
|
65
|
+
Array.from(arguments).forEach((arg, index) => {
|
|
66
|
+
arguments[index] = parseInt(arg);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
year,
|
|
71
|
+
month,
|
|
72
|
+
date,
|
|
73
|
+
hours,
|
|
74
|
+
minutes,
|
|
75
|
+
seconds,
|
|
76
|
+
milliseconds
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
//TODO
|
|
82
|
+
static initFromStrings(dateString, format = defaultFormat) {
|
|
83
|
+
const props = {};
|
|
84
|
+
props.year= StringDateParser.extractYear(dateString, format);
|
|
85
|
+
props.month= StringDateParser.extractMonth(dateString, format);
|
|
86
|
+
props.date= StringDateParser.extractDate(dateString, format);
|
|
87
|
+
return Object.assign({}, defaultProps, props);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Initializer.defaultFormat = defaultFormat;
|
|
95
|
+
|
|
96
|
+
export default Initializer;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export const ar = {
|
|
2
|
+
dayNames: [
|
|
3
|
+
"ح",
|
|
4
|
+
"ن",
|
|
5
|
+
"ث",
|
|
6
|
+
"ر",
|
|
7
|
+
"خ",
|
|
8
|
+
"ج",
|
|
9
|
+
"س",
|
|
10
|
+
"أحد",
|
|
11
|
+
"اثن",
|
|
12
|
+
"ثلا",
|
|
13
|
+
"ارب",
|
|
14
|
+
"خم",
|
|
15
|
+
"جم",
|
|
16
|
+
"سبت",
|
|
17
|
+
"الأحد",
|
|
18
|
+
"الإثنين",
|
|
19
|
+
"الثلاثاء",
|
|
20
|
+
"الإربعاء",
|
|
21
|
+
"الخميس",
|
|
22
|
+
"الجمعة",
|
|
23
|
+
"السبت",
|
|
24
|
+
],
|
|
25
|
+
monthNames: [
|
|
26
|
+
"مح",
|
|
27
|
+
"صف",
|
|
28
|
+
"ربع١",
|
|
29
|
+
"ربع٢",
|
|
30
|
+
"جم١",
|
|
31
|
+
"جم٢",
|
|
32
|
+
"رجب",
|
|
33
|
+
"شعب",
|
|
34
|
+
"رمض",
|
|
35
|
+
"شو",
|
|
36
|
+
"ذو ق",
|
|
37
|
+
"ذو ح",
|
|
38
|
+
"محرّم",
|
|
39
|
+
"صفر",
|
|
40
|
+
"ربيع أول",
|
|
41
|
+
"ربيع الآخر",
|
|
42
|
+
"جمادى أولى",
|
|
43
|
+
"جمادى الآخرة",
|
|
44
|
+
"رجب",
|
|
45
|
+
"شعبان",
|
|
46
|
+
"رمضان",
|
|
47
|
+
"شوال",
|
|
48
|
+
"ذو القعدة",
|
|
49
|
+
"ذو الحجّة",
|
|
50
|
+
],
|
|
51
|
+
separator: "عند",
|
|
52
|
+
am: "ص",
|
|
53
|
+
pm: "م",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const en = {
|
|
57
|
+
dayNames: [
|
|
58
|
+
"Su",
|
|
59
|
+
"Mo",
|
|
60
|
+
"Tu",
|
|
61
|
+
"We",
|
|
62
|
+
"Th",
|
|
63
|
+
"Fr",
|
|
64
|
+
"Sa",
|
|
65
|
+
"Sun",
|
|
66
|
+
"Mon",
|
|
67
|
+
"Tue",
|
|
68
|
+
"Wed",
|
|
69
|
+
"Thu",
|
|
70
|
+
"Fri",
|
|
71
|
+
"Sat",
|
|
72
|
+
"Sunday",
|
|
73
|
+
"Monday",
|
|
74
|
+
"Tuesday",
|
|
75
|
+
"Wednesday",
|
|
76
|
+
"Thursday",
|
|
77
|
+
"Friday",
|
|
78
|
+
"Saturday",
|
|
79
|
+
],
|
|
80
|
+
monthNames: [
|
|
81
|
+
"Muha",
|
|
82
|
+
"Saf",
|
|
83
|
+
"Rab1",
|
|
84
|
+
"Rab2",
|
|
85
|
+
"Jumd1",
|
|
86
|
+
"Jumd2",
|
|
87
|
+
"Rajb",
|
|
88
|
+
"Shbn",
|
|
89
|
+
"Rmdn",
|
|
90
|
+
"Shwl",
|
|
91
|
+
"Qada",
|
|
92
|
+
"Hija",
|
|
93
|
+
"Muharram",
|
|
94
|
+
"Safar",
|
|
95
|
+
"Rabi'ul Awwal",
|
|
96
|
+
"Rabi'ul Akhir",
|
|
97
|
+
"Jumadal Ula",
|
|
98
|
+
"Jumadal Akhira",
|
|
99
|
+
"Rajab",
|
|
100
|
+
"Sha'ban",
|
|
101
|
+
"Ramadan",
|
|
102
|
+
"Shawwal",
|
|
103
|
+
"Dhul Qa'ada",
|
|
104
|
+
"Dhul Hijja",
|
|
105
|
+
],
|
|
106
|
+
separator: "at",
|
|
107
|
+
am: "am",
|
|
108
|
+
pm: "pm",
|
|
109
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import HijriDate from './HijriDate';
|
|
2
|
+
import {GregToHijri} from './DateConverter';
|
|
3
|
+
|
|
4
|
+
export const toHijri = ((gregDate) => {
|
|
5
|
+
const {year, month, date} = GregToHijri(gregDate);
|
|
6
|
+
return new HijriDate(
|
|
7
|
+
year,
|
|
8
|
+
month,
|
|
9
|
+
date,
|
|
10
|
+
gregDate.getHours(),
|
|
11
|
+
gregDate.getMinutes(),
|
|
12
|
+
gregDate.getSeconds(),
|
|
13
|
+
gregDate.getMilliseconds()
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
export default HijriDate;
|
package/src/i18n/index.ts
CHANGED
|
@@ -24,8 +24,5 @@
|
|
|
24
24
|
import { addTranslationBundle } from "@react-fabric/core";
|
|
25
25
|
import ar from "./ar.json";
|
|
26
26
|
import en from "./en.json";
|
|
27
|
-
import arSuper from "./superdate/ar.json";
|
|
28
|
-
import enSuper from "./superdate/en.json";
|
|
29
27
|
|
|
30
28
|
addTranslationBundle("date", { en, ar });
|
|
31
|
-
addTranslationBundle("superdate", { en: enSuper, ar: arSuper });
|
package/src/index.ts
CHANGED
|
@@ -24,9 +24,14 @@
|
|
|
24
24
|
import "./hijri";
|
|
25
25
|
import "./i18n";
|
|
26
26
|
|
|
27
|
+
export { DateHeader } from "./components/DateHeader";
|
|
28
|
+
export { DecadePage } from "./components/DecadePage";
|
|
29
|
+
export { YearPage } from "./components/YearPage";
|
|
27
30
|
export { DateDisplay } from "./display/DateDisplay";
|
|
28
31
|
export { DatePanel } from "./panels/DatePanel";
|
|
32
|
+
export { EventPanel } from "./panels/EventPanel";
|
|
29
33
|
export { RangePanel } from "./panels/RangePanel";
|
|
30
|
-
export { SuperDate } from "./superdate/Superdate";
|
|
31
34
|
|
|
32
35
|
export { DateUtil } from "./utils/dateUtil";
|
|
36
|
+
|
|
37
|
+
export * from "./types";
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
|
|
24
24
|
import { Content, Section } from "@react-fabric/core";
|
|
25
25
|
import { EMPTY_ARRAY } from "@react-fabric/utilities";
|
|
26
|
-
import { endOfDay, isSameMonth, startOfDay } from "date-fns";
|
|
26
|
+
import { endOfDay, isSameMonth, setYear, startOfDay } from "date-fns";
|
|
27
27
|
import i18next from "i18next";
|
|
28
28
|
import { useEffect, useReducer, useState } from "react";
|
|
29
29
|
import { useTranslation } from "react-i18next";
|
|
30
30
|
import { DateHeader } from "../components/DateHeader";
|
|
31
31
|
import { DecadePage } from "../components/DecadePage";
|
|
32
32
|
import { YearPage } from "../components/YearPage";
|
|
33
|
-
import { type EventType, PageType
|
|
33
|
+
import { type EventType, PageType } from "../types";
|
|
34
34
|
import { DateUtil } from "../utils/dateUtil";
|
|
35
35
|
|
|
36
36
|
interface EventState {
|
|
@@ -44,8 +44,21 @@ type EventActions =
|
|
|
44
44
|
| { type: "changePage"; page: PageType }
|
|
45
45
|
| { type: "changePageDate"; date: Date; changePage?: boolean };
|
|
46
46
|
|
|
47
|
-
const makeList = (
|
|
47
|
+
const makeList = (
|
|
48
|
+
year: number,
|
|
49
|
+
recurring: EventType[] = [],
|
|
50
|
+
predefined: Array<EventType<Date>> = [],
|
|
51
|
+
) => {
|
|
48
52
|
const list = [...predefined];
|
|
53
|
+
recurring.forEach((evt) =>
|
|
54
|
+
list.push({
|
|
55
|
+
label: evt.label,
|
|
56
|
+
hijri: evt.hijri,
|
|
57
|
+
icon: evt.icon,
|
|
58
|
+
start: setYear(DateUtil.parseDate(evt.start), year),
|
|
59
|
+
end: setYear(DateUtil.parseDate(evt.end), year),
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
49
62
|
list.push({
|
|
50
63
|
label: "superdate:event.newYear",
|
|
51
64
|
start: startOfDay(new Date(`${year - 1}-12-31`)),
|
|
@@ -77,11 +90,29 @@ const makeList = (year: number, predefined: Array<EventType<Date>> = []) => {
|
|
|
77
90
|
});
|
|
78
91
|
};
|
|
79
92
|
|
|
93
|
+
export interface EventProps {
|
|
94
|
+
isHijri?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* list of calendar events
|
|
97
|
+
*/
|
|
98
|
+
events?: EventType[];
|
|
99
|
+
/**
|
|
100
|
+
* list of calendar events
|
|
101
|
+
*/
|
|
102
|
+
recurringEvents?: EventType[];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* change handler
|
|
106
|
+
*/
|
|
107
|
+
onChange?: (value: string, dates: [string, string]) => void;
|
|
108
|
+
}
|
|
109
|
+
|
|
80
110
|
export const EventPanel = ({
|
|
81
111
|
isHijri,
|
|
82
112
|
onChange,
|
|
83
113
|
events = EMPTY_ARRAY,
|
|
84
|
-
|
|
114
|
+
recurringEvents = EMPTY_ARRAY,
|
|
115
|
+
}: EventProps) => {
|
|
85
116
|
const { t } = useTranslation();
|
|
86
117
|
const [predefined, setPredefined] = useState<
|
|
87
118
|
KeyValue<Array<EventType<Date>>>
|
|
@@ -100,13 +131,17 @@ export const EventPanel = ({
|
|
|
100
131
|
if (action.type === "changePageDate") {
|
|
101
132
|
resetList = true;
|
|
102
133
|
state.pageDate = action.date;
|
|
103
|
-
if (action.changePage
|
|
134
|
+
if (action.changePage) {
|
|
104
135
|
state.page = Math.max(state.page - 1, PageType.MONTH);
|
|
105
136
|
}
|
|
106
137
|
}
|
|
107
138
|
if (resetList) {
|
|
108
139
|
const year = state.pageDate.getFullYear();
|
|
109
|
-
state.events = makeList(
|
|
140
|
+
state.events = makeList(
|
|
141
|
+
year,
|
|
142
|
+
recurringEvents ?? [],
|
|
143
|
+
predefined[year] ?? [],
|
|
144
|
+
);
|
|
110
145
|
}
|
|
111
146
|
return { ...state };
|
|
112
147
|
},
|
package/src/types/index.ts
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
type ColorType,
|
|
26
25
|
type CssProp,
|
|
27
26
|
type TestProps,
|
|
28
27
|
} from "@react-fabric/core/dist/types/types";
|
|
@@ -63,6 +62,14 @@ format?:
|
|
|
63
62
|
| string;
|
|
64
63
|
*/
|
|
65
64
|
|
|
65
|
+
export interface EventType<D = DateLike> {
|
|
66
|
+
label: string;
|
|
67
|
+
icon?: string;
|
|
68
|
+
start: D;
|
|
69
|
+
end: D;
|
|
70
|
+
hijri?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
export interface BaseProps {
|
|
67
74
|
min?: DateLike;
|
|
68
75
|
max?: DateLike;
|
|
@@ -82,40 +89,3 @@ export interface RangeProps extends BaseProps, CssProp, TestProps {
|
|
|
82
89
|
onChange?: (dates: [start: string, end: string]) => void;
|
|
83
90
|
presets?: Record<string, [DateLike, DateLike]>;
|
|
84
91
|
}
|
|
85
|
-
|
|
86
|
-
export interface EventType<D = DateLike> {
|
|
87
|
-
label: string;
|
|
88
|
-
icon?: string;
|
|
89
|
-
start: D;
|
|
90
|
-
end: D;
|
|
91
|
-
hijri?: boolean;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface PresetType {
|
|
95
|
-
value: string;
|
|
96
|
-
label: string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface SuperDateProps {
|
|
100
|
-
as?: "button" | "chip";
|
|
101
|
-
color?: ColorType;
|
|
102
|
-
variant?: "solid" | "outline" | "link";
|
|
103
|
-
/**
|
|
104
|
-
* relative date value
|
|
105
|
-
*/
|
|
106
|
-
value?: string;
|
|
107
|
-
/**
|
|
108
|
-
* change handler
|
|
109
|
-
*/
|
|
110
|
-
onChange?: (value: string, dates: [string, string]) => void;
|
|
111
|
-
/**
|
|
112
|
-
* list of calendar events
|
|
113
|
-
*/
|
|
114
|
-
events?: EventType[];
|
|
115
|
-
/**
|
|
116
|
-
* list of relative presets
|
|
117
|
-
*
|
|
118
|
-
* {value:'$year-5|$year', label:'last 5 years'}
|
|
119
|
-
*/
|
|
120
|
-
presets?: PresetType[];
|
|
121
|
-
}
|
package/src/utils/dateUtil.ts
CHANGED
|
@@ -52,7 +52,6 @@ import {
|
|
|
52
52
|
startOfQuarter,
|
|
53
53
|
} from "date-fns";
|
|
54
54
|
import { DatePart, PageType, type DateLike } from "../types";
|
|
55
|
-
// import { parseDate } from "./dateMath";
|
|
56
55
|
import { isNil, isString } from "@react-fabric/utilities";
|
|
57
56
|
import {
|
|
58
57
|
arSA as ar,
|
|
@@ -157,7 +156,7 @@ export namespace DateUtil {
|
|
|
157
156
|
};
|
|
158
157
|
|
|
159
158
|
export const isRelative = (date: DateLike): date is string => {
|
|
160
|
-
return isString(date) && date.match(/^(\$\w+)([+-])(\d+)?$/) !== null;
|
|
159
|
+
return isString(date) && date.match(/^(\$\w+)([+-])?(\d+)?$/) !== null;
|
|
161
160
|
};
|
|
162
161
|
|
|
163
162
|
export const isRelativeRange = (date: DateLike): date is string => {
|
|
@@ -407,7 +406,7 @@ export namespace DateUtil {
|
|
|
407
406
|
);
|
|
408
407
|
};
|
|
409
408
|
|
|
410
|
-
export const parseDate = (datelike:
|
|
409
|
+
export const parseDate = (datelike: DateLike): Date => {
|
|
411
410
|
return _parse(datelike);
|
|
412
411
|
};
|
|
413
412
|
|
|
@@ -490,7 +489,8 @@ export namespace DateUtil {
|
|
|
490
489
|
}
|
|
491
490
|
};
|
|
492
491
|
|
|
493
|
-
const _parse = (dt:
|
|
492
|
+
const _parse = (dt: DateLike, rounded?: "start" | "end") => {
|
|
493
|
+
if (!isRelative(dt)) return new Date(dt);
|
|
494
494
|
const [, part, diff = "0"] = dt.match(/^(\$\w+)([+-]\d+)?$/) ?? [];
|
|
495
495
|
if (part) {
|
|
496
496
|
let date = startOfMinute(new Date());
|
|
@@ -546,6 +546,3 @@ export namespace DateUtil {
|
|
|
546
546
|
return new Date(dt);
|
|
547
547
|
};
|
|
548
548
|
}
|
|
549
|
-
|
|
550
|
-
// @ts-expect-error ignore
|
|
551
|
-
window.DateUtil = DateUtil;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@layer comp{.dateHeader{box-shadow:inset 0 -1px 0 theme(colors.tint.200/50%)}.timeSlider{height:11.25rem;&:after,&:before{box-shadow:0 0 3rem .25rem theme(colors.tint.600);content:"";display:block;z-index:10}&:before{position:sticky;top:0}&:after{bottom:0;position:sticky}&>:first-child,&>:last-child{height:calc(50% - .75rem)}& [data-skew="1"]>div{opacity:.9;transform:scaleY(.9)}& [data-skew="2"]>div{opacity:.75;transform:scaleY(.75)}& [data-skew="3"]>div{opacity:.65;transform:scaleY(.65)}& [data-skew="4"]>div{opacity:.5;transform:scaleY(.5)}}}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var separator = " ⇽ ";
|
|
6
|
-
var label = {
|
|
7
|
-
quick: "حدد مسرعا",
|
|
8
|
-
relative: "نسبيا",
|
|
9
|
-
events: "الأحداث",
|
|
10
|
-
absolute: "مطلق",
|
|
11
|
-
preset: "المسبقة",
|
|
12
|
-
current: "تيار",
|
|
13
|
-
previous: "السابق",
|
|
14
|
-
from: "من عند",
|
|
15
|
-
to: "إلى",
|
|
16
|
-
"+": "من الان",
|
|
17
|
-
"-": "منذ",
|
|
18
|
-
apply: "يتقدم",
|
|
19
|
-
$now: "الآن",
|
|
20
|
-
$minute: "دقيقة",
|
|
21
|
-
$hour: "ساعة",
|
|
22
|
-
$day: "يوم",
|
|
23
|
-
$week: "أسبوع",
|
|
24
|
-
$month: "شهر",
|
|
25
|
-
$quarter: "ربع",
|
|
26
|
-
$year: "عام",
|
|
27
|
-
$decade: "عقد"
|
|
28
|
-
};
|
|
29
|
-
var now = {
|
|
30
|
-
$day: "اليوم",
|
|
31
|
-
$week: "هذا الاسبوع",
|
|
32
|
-
$month: "هذا الشهر",
|
|
33
|
-
$quarter: "هذا الربع",
|
|
34
|
-
$year: "هذه السنة",
|
|
35
|
-
$decade: "هذا العقد"
|
|
36
|
-
};
|
|
37
|
-
var next = {
|
|
38
|
-
$day: "غدا",
|
|
39
|
-
$week: "الاسبوع القادم",
|
|
40
|
-
$month: "الشهر القادم",
|
|
41
|
-
$quarter: "الربع القادم",
|
|
42
|
-
$year: "العام القادم",
|
|
43
|
-
$decade: "العقد القادم",
|
|
44
|
-
$minute: "بعد دقيقة",
|
|
45
|
-
$hour: "بعد ساعة",
|
|
46
|
-
$minute_plural: "بعد {{count}} دقائق",
|
|
47
|
-
$hour_plural: "بعد {{count}} ساعات",
|
|
48
|
-
$day_plural: "بعد {{count}} أيام",
|
|
49
|
-
$week_plural: "بعد {{count}} أسابيع",
|
|
50
|
-
$month_plural: "بعد {{count}} أشهر",
|
|
51
|
-
$quarter_plural: "بعد {{count}} أرباع",
|
|
52
|
-
$year_plural: "بعد {{count}} سنوات",
|
|
53
|
-
$decade_plural: "بعد {{count}} عقود"
|
|
54
|
-
};
|
|
55
|
-
var prev = {
|
|
56
|
-
$day: "في الامس",
|
|
57
|
-
$week: "الاسبوع الماضي",
|
|
58
|
-
$month: "الشهر الماضي",
|
|
59
|
-
$quarter: "الربع الأخير",
|
|
60
|
-
$year: "العام الماضي",
|
|
61
|
-
$decade: "العقد الماضي",
|
|
62
|
-
$minute: "منذ دقيقة",
|
|
63
|
-
$hour: "منذ ساعة",
|
|
64
|
-
$minute_plural: "منذ {{count}} دقيقة",
|
|
65
|
-
$hour_plural: "منذ {{count}} ساعات",
|
|
66
|
-
$day_plural: "منذ {{count}} أيام",
|
|
67
|
-
$week_plural: "من {{count}} اسابيع",
|
|
68
|
-
$month_plural: "قبل {{count}} أشهر",
|
|
69
|
-
$quarter_plural: "منذ {{count}} أرباع",
|
|
70
|
-
$year_plural: "منذ {{count}} سنوات",
|
|
71
|
-
$decade_plural: "منذ {{count}} عقود"
|
|
72
|
-
};
|
|
73
|
-
var arSuper = {
|
|
74
|
-
separator: separator,
|
|
75
|
-
label: label,
|
|
76
|
-
now: now,
|
|
77
|
-
next: next,
|
|
78
|
-
prev: prev
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
exports.default = arSuper;
|
|
82
|
-
exports.label = label;
|
|
83
|
-
exports.next = next;
|
|
84
|
-
exports.now = now;
|
|
85
|
-
exports.prev = prev;
|
|
86
|
-
exports.separator = separator;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var separator = " ⇾ ";
|
|
6
|
-
var event = {
|
|
7
|
-
ramadan: "Ramadan",
|
|
8
|
-
christmas: "Christmas",
|
|
9
|
-
newYear: "New Year"
|
|
10
|
-
};
|
|
11
|
-
var label = {
|
|
12
|
-
quick: "Quick Select",
|
|
13
|
-
relative: "Relative",
|
|
14
|
-
absolute: "Absolute",
|
|
15
|
-
events: "Events",
|
|
16
|
-
preset: "Presets",
|
|
17
|
-
current: "Current",
|
|
18
|
-
previous: "Previous",
|
|
19
|
-
from: "From",
|
|
20
|
-
to: "To",
|
|
21
|
-
"+": "From now",
|
|
22
|
-
"-": "Ago",
|
|
23
|
-
apply: "Apply",
|
|
24
|
-
$now: "Now",
|
|
25
|
-
$minute: "Minute",
|
|
26
|
-
$hour: "Hour",
|
|
27
|
-
$day: "Day",
|
|
28
|
-
$week: "Week",
|
|
29
|
-
$month: "Month",
|
|
30
|
-
$quarter: "Quarter",
|
|
31
|
-
$year: "Year",
|
|
32
|
-
$decade: "Decade"
|
|
33
|
-
};
|
|
34
|
-
var now = {
|
|
35
|
-
$day: "Today",
|
|
36
|
-
$week: "This week",
|
|
37
|
-
$month: "This month",
|
|
38
|
-
$quarter: "This quarter",
|
|
39
|
-
$year: "This year",
|
|
40
|
-
$decade: "This decade"
|
|
41
|
-
};
|
|
42
|
-
var next = {
|
|
43
|
-
$day: "Tomorrow",
|
|
44
|
-
$week: "Next week",
|
|
45
|
-
$month: "Next month",
|
|
46
|
-
$quarter: "Next quarter",
|
|
47
|
-
$year: "Next year",
|
|
48
|
-
$decade: "Next decade",
|
|
49
|
-
$minute: "A minute later",
|
|
50
|
-
$hour: "An hour later",
|
|
51
|
-
$minute_other: "{{count}} minutes later",
|
|
52
|
-
$hour_other: "{{count}} hours later",
|
|
53
|
-
$day_other: "{{count}} days later",
|
|
54
|
-
$week_other: "{{count}} weeks later",
|
|
55
|
-
$month_other: "{{count}} months later",
|
|
56
|
-
$quarter_other: "{{count}} quarters later",
|
|
57
|
-
$year_other: "{{count}} years later",
|
|
58
|
-
$decade_other: "{{count}} decades later"
|
|
59
|
-
};
|
|
60
|
-
var prev = {
|
|
61
|
-
$day: "Yesterday",
|
|
62
|
-
$week: "Last week",
|
|
63
|
-
$month: "Last month",
|
|
64
|
-
$quarter: "Last quarter",
|
|
65
|
-
$year: "Last year",
|
|
66
|
-
$decade: "Last decade",
|
|
67
|
-
$minute: "A minute ago",
|
|
68
|
-
$hour: "An hour ago",
|
|
69
|
-
$minute_other: "{{count}} minutes ago",
|
|
70
|
-
$hour_other: "{{count}} hours ago",
|
|
71
|
-
$day_other: "{{count}} days ago",
|
|
72
|
-
$week_other: "{{count}} weeks ago",
|
|
73
|
-
$month_other: "{{count}} months ago",
|
|
74
|
-
$quarter_other: "{{count}} quarters ago",
|
|
75
|
-
$year_other: "{{count}} years ago",
|
|
76
|
-
$decade_other: "{{count}} decades ago"
|
|
77
|
-
};
|
|
78
|
-
var enSuper = {
|
|
79
|
-
separator: separator,
|
|
80
|
-
event: event,
|
|
81
|
-
label: label,
|
|
82
|
-
now: now,
|
|
83
|
-
next: next,
|
|
84
|
-
prev: prev
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
exports.default = enSuper;
|
|
88
|
-
exports.event = event;
|
|
89
|
-
exports.label = label;
|
|
90
|
-
exports.next = next;
|
|
91
|
-
exports.now = now;
|
|
92
|
-
exports.prev = prev;
|
|
93
|
-
exports.separator = separator;
|