@momo-kits/calendar 0.167.1-duo.8 → 0.167.1-rc.2

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/types.ts CHANGED
@@ -42,9 +42,6 @@ export type CalendarProProps = {
42
42
  isDoubleDateMode: boolean;
43
43
  onDateChange: (day: Moment.Moment) => void;
44
44
  priceList?: PriceListData;
45
- labelFrom?: string;
46
- labelTo?: string;
47
- isHideLabel?: boolean;
48
45
  isHideHoliday?: boolean;
49
46
  isOffLunar?: boolean;
50
47
  onCallbackCalendar?: (lunar: string, nextStateShowLunar: boolean) => void;
@@ -52,17 +49,6 @@ export type CalendarProProps = {
52
49
  bestPriceColor?: string;
53
50
  };
54
51
 
55
- export type CalendarProState = {
56
- startDate: Moment.Moment;
57
- endDate: Moment.Moment;
58
- showLunar?: boolean;
59
- tabSelected?: number;
60
- holidays: Holidays[];
61
- ownUpdate?: boolean;
62
- temp?: any;
63
- headerKey?: string;
64
- };
65
-
66
52
  export type DoubleDate = {
67
53
  first: Moment.Moment;
68
54
  second: Moment.Moment | null;
@@ -102,15 +88,6 @@ export type CalendarProRef = {
102
88
  secondDate?: Moment.Moment | null,
103
89
  tabSelected?: number,
104
90
  ) => void;
105
- setDateRange: (
106
- dateRange: { startDate: any; endDate: any },
107
- isScrollToStartDate: any,
108
- ) => void;
109
- };
110
-
111
- export type CalendarState = {
112
- isDoubleDateMode: boolean;
113
- containerWidth: number;
114
91
  };
115
92
 
116
93
  export type HeaderControlRef = {
@@ -134,23 +111,16 @@ export type MonthListProps = {
134
111
  endDate: Moment.Moment;
135
112
  isShowLunar: boolean;
136
113
  tabSelected?: number;
137
- today: Moment.Moment;
138
114
  onChoose: (day: Moment.Moment) => void;
139
115
  onScrollCalendar?: (info: {
140
116
  date: Moment.Moment;
141
117
  key: string;
142
118
  currentIndex: number;
143
119
  }) => void;
144
- lunarConverter: any;
145
120
  disabledDays?: Date[];
146
121
  bestPriceColor?: string;
147
122
  };
148
123
 
149
- export type MonthListState = {
150
- data?: any;
151
- isDoubleDateMode?: boolean;
152
- };
153
-
154
124
  export type MonthListRef = {
155
125
  scrollToMonth: (date: Moment.Moment) => void;
156
126
  };
@@ -168,6 +138,8 @@ export type MonthProps = {
168
138
  isDoubleDateMode: boolean;
169
139
  disabledDays?: Date[];
170
140
  bestPriceColor?: string;
141
+ tabSelected?: number;
142
+ onChoose?: (date: Moment.Moment) => void;
171
143
  };
172
144
 
173
145
  export type DayProps = {
@@ -192,9 +164,9 @@ export type DayProps = {
192
164
  bestPriceColor?: string;
193
165
  };
194
166
 
195
- export type TabHeaderState = {
196
- active?: boolean;
197
- date?: Moment.Moment;
167
+ export type TabHeaderRef = {
168
+ updateView: (date?: Moment.Moment | Date | null, activeTab?: boolean) => void;
169
+ setActiveTab: (active: boolean) => void;
198
170
  };
199
171
 
200
172
  export type TabHeaderProps = {
@@ -205,8 +177,3 @@ export type TabHeaderProps = {
205
177
  id: number;
206
178
  disabled?: boolean;
207
179
  };
208
-
209
- export type TabHeaderRef = {
210
- updateView: (date?: Moment.Moment | null, activeTab?: boolean) => void;
211
- setActiveTab: (active: boolean) => void;
212
- };
package/LunarService.ts DELETED
@@ -1,206 +0,0 @@
1
- const removeFractionalPart = (number: string | number) =>
2
- parseInt(String(number));
3
-
4
- /* Compute the (integral) Julian day number of day dd/mm/yyyy, i.e., the number
5
- * of days between 1/1/4713 BC (Julian calendar) and dd/mm/yyyy.
6
- * Formula from http://www.tondering.dk/claus/calendar.html
7
- */
8
- const jdFromDate = (dd: number, mm: number, yy: number) => {
9
- let a, y, m, jd;
10
- a = removeFractionalPart((14 - mm) / 12);
11
- y = yy + 4800 - a;
12
- m = mm + 12 * a - 3;
13
- jd =
14
- dd +
15
- removeFractionalPart((153 * m + 2) / 5) +
16
- 365 * y +
17
- removeFractionalPart(y / 4) -
18
- removeFractionalPart(y / 100) +
19
- removeFractionalPart(y / 400) -
20
- 32045;
21
- if (jd < 2299161) {
22
- jd =
23
- dd +
24
- removeFractionalPart((153 * m + 2) / 5) +
25
- 365 * y +
26
- removeFractionalPart(y / 4) -
27
- 32083;
28
- }
29
- return jd;
30
- };
31
-
32
- /* Compute the time of the k-th new moon after the new moon of 1/1/1900 13:52 UCT
33
- * (measured as the number of days since 1/1/4713 BC noon UCT, e.g., 2451545.125 is 1/1/2000 15:00 UTC).
34
- * Returns a floating number, e.g., 2415079.9758617813 for k=2 or 2414961.935157746 for k=-2
35
- * Algorithm from: "Astronomical Algorithms" by Jean Meeus, 1998
36
- */
37
- const NewMoon = (k: number) => {
38
- let T, T2, T3, dr, Jd1, M, Mpr, F, C1, deltat, JdNew;
39
- T = k / 1236.85; // Time in Julian centuries from 1900 January 0.5
40
- T2 = T * T;
41
- T3 = T2 * T;
42
- dr = Math.PI / 180;
43
- Jd1 = 2415020.75933 + 29.53058868 * k + 0.0001178 * T2 - 0.000000155 * T3;
44
- Jd1 = Jd1 + 0.00033 * Math.sin((166.56 + 132.87 * T - 0.009173 * T2) * dr); // Mean new moon
45
- M = 359.2242 + 29.10535608 * k - 0.0000333 * T2 - 0.00000347 * T3; // Sun's mean anomaly
46
- Mpr = 306.0253 + 385.81691806 * k + 0.0107306 * T2 + 0.00001236 * T3; // Moon's mean anomaly
47
- F = 21.2964 + 390.67050646 * k - 0.0016528 * T2 - 0.00000239 * T3; // Moon's argument of latitude
48
- C1 =
49
- (0.1734 - 0.000393 * T) * Math.sin(M * dr) + 0.0021 * Math.sin(2 * dr * M);
50
- C1 = C1 - 0.4068 * Math.sin(Mpr * dr) + 0.0161 * Math.sin(dr * 2 * Mpr);
51
- C1 = C1 - 0.0004 * Math.sin(dr * 3 * Mpr);
52
- C1 = C1 + 0.0104 * Math.sin(dr * 2 * F) - 0.0051 * Math.sin(dr * (M + Mpr));
53
- C1 =
54
- C1 -
55
- 0.0074 * Math.sin(dr * (M - Mpr)) +
56
- 0.0004 * Math.sin(dr * (2 * F + M));
57
- C1 =
58
- C1 -
59
- 0.0004 * Math.sin(dr * (2 * F - M)) -
60
- 0.0006 * Math.sin(dr * (2 * F + Mpr));
61
- C1 =
62
- C1 +
63
- 0.001 * Math.sin(dr * (2 * F - Mpr)) +
64
- 0.0005 * Math.sin(dr * (2 * Mpr + M));
65
- if (T < -11) {
66
- deltat =
67
- 0.001 +
68
- 0.000839 * T +
69
- 0.0002261 * T2 -
70
- 0.00000845 * T3 -
71
- 0.000000081 * T * T3;
72
- } else {
73
- deltat = -0.000278 + 0.000265 * T + 0.000262 * T2;
74
- }
75
- JdNew = Jd1 + C1 - deltat;
76
- return JdNew;
77
- };
78
-
79
- /* Compute the longitude of the sun at any time.
80
- * Parameter: floating number jdn, the number of days since 1/1/4713 BC noon
81
- * Algorithm from: "Astronomical Algorithms" by Jean Meeus, 1998
82
- */
83
- const SunLongitude = (jdn: number) => {
84
- let T, T2, dr, M, L0, DL, L;
85
- T = (jdn - 2451545.0) / 36525; // Time in Julian centuries from 2000-01-01 12:00:00 GMT
86
- T2 = T * T;
87
- dr = Math.PI / 180; // degree to radian
88
- M = 357.5291 + 35999.0503 * T - 0.0001559 * T2 - 0.00000048 * T * T2; // mean anomaly, degree
89
- L0 = 280.46645 + 36000.76983 * T + 0.0003032 * T2; // mean longitude, degree
90
- DL = (1.9146 - 0.004817 * T - 0.000014 * T2) * Math.sin(dr * M);
91
- DL =
92
- DL +
93
- (0.019993 - 0.000101 * T) * Math.sin(dr * 2 * M) +
94
- 0.00029 * Math.sin(dr * 3 * M);
95
- L = L0 + DL; // true longitude, degree
96
- L = L * dr;
97
- L = L - Math.PI * 2 * Math.sin(L / (Math.PI * 2)); // Normalize to (0, 2*PI)
98
- return L;
99
- };
100
-
101
- /* Compute sun position at midnight of the day with the given Julian day number.
102
- * The time zone if the time difference between local time and UTC: 7.0 for UTC+7:00.
103
- * The returns a number between 0 and 11.
104
- * From the day after March equinox and the 1st major term after March equinox, 0 is returned.
105
- * After that, return 1, 2, 3 ...
106
- */
107
- const getSunLongitude = (dayNumber: number, timeZone: number) => {
108
- return removeFractionalPart(
109
- (SunLongitude(dayNumber - 0.5 - timeZone / 24) / Math.PI) * 6
110
- );
111
- };
112
-
113
- /* Compute the day of the k-th new moon in the given time zone.
114
- * The time zone if the time difference between local time and UTC: 7.0 for UTC+7:00
115
- */
116
- const getNewMoonDay = (k: number, timeZone: number) => {
117
- return removeFractionalPart(NewMoon(k) + 0.5 + timeZone / 24);
118
- };
119
-
120
- /* Find the day that starts the luner month 11 of the given year for the given time zone */
121
- const getLunarMonth11 = (yy: number, timeZone: number) => {
122
- let k, off, nm, sunLong;
123
- //off = jdFromDate(31, 12, yy) - 2415021.076998695;
124
- off = jdFromDate(31, 12, yy) - 2415021;
125
- k = removeFractionalPart(off / 29.530588853);
126
- nm = getNewMoonDay(k, timeZone);
127
- sunLong = getSunLongitude(nm, timeZone); // sun longitude at local midnight
128
- if (sunLong >= 9) {
129
- nm = getNewMoonDay(k - 1, timeZone);
130
- }
131
- return nm;
132
- };
133
-
134
- /* Find the index of the leap month after the month starting on the day a11. */
135
- const getLeapMonthOffset = (a11: number, timeZone: number) => {
136
- let k, last, arc, i;
137
- k = removeFractionalPart((a11 - 2415021.076998695) / 29.530588853 + 0.5);
138
- last = 0;
139
- i = 1; // We start with the month following lunar month 11
140
- arc = getSunLongitude(getNewMoonDay(k + i, timeZone), timeZone);
141
- do {
142
- last = arc;
143
- i++;
144
- arc = getSunLongitude(getNewMoonDay(k + i, timeZone), timeZone);
145
- } while (arc !== last && i < 14);
146
- return i - 1;
147
- };
148
-
149
- /* Comvert solar date dd/mm/yyyy to the corresponding lunar date */
150
- export const convertSolar2Lunar = (
151
- dd: number,
152
- mm: number,
153
- yy: number,
154
- timeZone: number
155
- ) => {
156
- let k,
157
- dayNumber,
158
- monthStart,
159
- a11,
160
- b11,
161
- lunarDay,
162
- lunarMonth,
163
- lunarYear,
164
- lunarLeap;
165
- dayNumber = jdFromDate(dd, mm, yy);
166
- k = removeFractionalPart((dayNumber - 2415021.076998695) / 29.530588853);
167
- monthStart = getNewMoonDay(k + 1, timeZone);
168
- if (monthStart > dayNumber) {
169
- monthStart = getNewMoonDay(k, timeZone);
170
- }
171
- //alert(dayNumber+" -> "+monthStart);
172
- a11 = getLunarMonth11(yy, timeZone);
173
- b11 = a11;
174
- if (a11 >= monthStart) {
175
- lunarYear = yy;
176
- a11 = getLunarMonth11(yy - 1, timeZone);
177
- } else {
178
- lunarYear = yy + 1;
179
- b11 = getLunarMonth11(yy + 1, timeZone);
180
- }
181
- lunarDay = dayNumber - monthStart + 1;
182
- let diff = removeFractionalPart((monthStart - a11) / 29);
183
- lunarLeap = 0;
184
- lunarMonth = diff + 10;
185
- if (b11 - a11 > 365) {
186
- let leapMonthDiff = getLeapMonthOffset(a11, timeZone);
187
- if (diff >= leapMonthDiff) {
188
- lunarMonth = diff + 10;
189
- if (diff === leapMonthDiff) {
190
- lunarLeap = 1;
191
- }
192
- }
193
- }
194
- if (lunarMonth > 12) {
195
- lunarMonth = lunarMonth - 12;
196
- }
197
- if (lunarMonth >= 11 && diff < 4) {
198
- lunarYear -= 1;
199
- }
200
- return {
201
- lunarDay,
202
- lunarMonth: lunarMonth,
203
- lunarYear,
204
- isleap: lunarLeap,
205
- };
206
- };