@momo-kits/calendar 0.89.4 → 0.89.6-rc.1
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/CalendarPro.tsx +10 -9
- package/Day.tsx +6 -7
- package/HeaderControl.tsx +1 -1
- package/LunarService.ts +2 -23
- package/TabHeader.tsx +1 -1
- package/index.tsx +15 -14
- package/package.json +2 -2
- package/publish.sh +21 -23
- package/styles.ts +6 -2
package/CalendarPro.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {Component, createRef} from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {ScrollView, View} from 'react-native';
|
|
4
4
|
import Moment from 'moment';
|
|
5
5
|
import {
|
|
6
6
|
ApplicationContext,
|
|
@@ -59,7 +59,7 @@ export default class CalendarPro extends Component<
|
|
|
59
59
|
|
|
60
60
|
static getDerivedStateFromProps(
|
|
61
61
|
nextProps: {isShowLunar: any},
|
|
62
|
-
prevState: {ownUpdate: any; showLunar: any}
|
|
62
|
+
prevState: {ownUpdate: any; showLunar: any}
|
|
63
63
|
) {
|
|
64
64
|
if (prevState.ownUpdate) {
|
|
65
65
|
return {
|
|
@@ -74,7 +74,7 @@ export default class CalendarPro extends Component<
|
|
|
74
74
|
|
|
75
75
|
setDateRange = (
|
|
76
76
|
dateRange: {startDate: any; endDate: any},
|
|
77
|
-
isScrollToStartDate: any
|
|
77
|
+
isScrollToStartDate: any
|
|
78
78
|
) => {
|
|
79
79
|
if (dateRange && dateRange.startDate && dateRange.endDate) {
|
|
80
80
|
this.setState(
|
|
@@ -88,7 +88,7 @@ export default class CalendarPro extends Component<
|
|
|
88
88
|
: dateRange.endDate;
|
|
89
89
|
|
|
90
90
|
this.monthListRef?.scrollToMonth(dateScroll);
|
|
91
|
-
}
|
|
91
|
+
}
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
};
|
|
@@ -116,7 +116,8 @@ export default class CalendarPro extends Component<
|
|
|
116
116
|
if (maxValid && !minValid) {
|
|
117
117
|
min = max.subtract(12, 'months');
|
|
118
118
|
}
|
|
119
|
-
if (min.
|
|
119
|
+
if (min.isSame(max) && this.props.isDoubleDateMode) return {};
|
|
120
|
+
if (min.isAfter(max)) return {};
|
|
120
121
|
this.minDate = min;
|
|
121
122
|
this.maxDate = max;
|
|
122
123
|
};
|
|
@@ -154,7 +155,7 @@ export default class CalendarPro extends Component<
|
|
|
154
155
|
|
|
155
156
|
executeProcessAfterScrollCalendar = (date: Moment.Moment, key: any) => {
|
|
156
157
|
const holidays: any[] = Object.values(
|
|
157
|
-
Util.getHolidaysInMonth(Moment(date))
|
|
158
|
+
Util.getHolidaysInMonth(Moment(date))
|
|
158
159
|
);
|
|
159
160
|
const {showLunar} = this.state;
|
|
160
161
|
if (this.headerControlRef) {
|
|
@@ -186,7 +187,7 @@ export default class CalendarPro extends Component<
|
|
|
186
187
|
setDoubleDateAndTabIndex = (
|
|
187
188
|
firstDate: Moment.Moment | Date | undefined,
|
|
188
189
|
secondDate?: Moment.Moment | Date | undefined | null,
|
|
189
|
-
tabSelected?: any
|
|
190
|
+
tabSelected?: any
|
|
190
191
|
) => {
|
|
191
192
|
this.ownSetState({
|
|
192
193
|
startDate: firstDate ? Moment(firstDate) : null,
|
|
@@ -349,7 +350,7 @@ export default class CalendarPro extends Component<
|
|
|
349
350
|
month: number;
|
|
350
351
|
highlight: string;
|
|
351
352
|
},
|
|
352
|
-
idx: {toString: () => React.Key | null | undefined}
|
|
353
|
+
idx: {toString: () => React.Key | null | undefined}
|
|
353
354
|
) => {
|
|
354
355
|
const labelHoliday = showLunar
|
|
355
356
|
? item.mixedLabel || item.label || ''
|
|
@@ -378,7 +379,7 @@ export default class CalendarPro extends Component<
|
|
|
378
379
|
</Text>
|
|
379
380
|
</View>
|
|
380
381
|
);
|
|
381
|
-
}
|
|
382
|
+
}
|
|
382
383
|
)}
|
|
383
384
|
</ScrollView>
|
|
384
385
|
)}
|
package/Day.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {Component} from 'react';
|
|
2
2
|
|
|
3
|
-
import {TouchableOpacity, View} from 'react-native';
|
|
3
|
+
import {Text as RNText, TouchableOpacity, View} from 'react-native';
|
|
4
4
|
import {
|
|
5
5
|
ApplicationContext,
|
|
6
6
|
Colors,
|
|
@@ -13,6 +13,7 @@ import {ContainerContext} from './index';
|
|
|
13
13
|
import styles from './styles';
|
|
14
14
|
|
|
15
15
|
class Day extends Component<DayProps> {
|
|
16
|
+
static contextType = ApplicationContext;
|
|
16
17
|
isFocus?: boolean;
|
|
17
18
|
isValid?: boolean;
|
|
18
19
|
isMid?: boolean;
|
|
@@ -29,7 +30,6 @@ class Day extends Component<DayProps> {
|
|
|
29
30
|
isInScope?: boolean;
|
|
30
31
|
diffPrice: any;
|
|
31
32
|
|
|
32
|
-
static contextType = ApplicationContext;
|
|
33
33
|
constructor(props: DayProps) {
|
|
34
34
|
super(props);
|
|
35
35
|
this.statusCheck();
|
|
@@ -185,18 +185,17 @@ class Day extends Component<DayProps> {
|
|
|
185
185
|
disabled={!(this.isValid && this.isInScope)}
|
|
186
186
|
onPress={this.chooseDay}>
|
|
187
187
|
{this.lunarDate && this.showLunar && !!text && (
|
|
188
|
-
<
|
|
188
|
+
<RNText
|
|
189
189
|
style={{
|
|
190
190
|
position: 'absolute',
|
|
191
191
|
top: Spacing.XS,
|
|
192
192
|
right: Spacing.XS,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
color={lunarTextColor}>
|
|
193
|
+
color: lunarTextColor,
|
|
194
|
+
}}>
|
|
196
195
|
{this.lunarDate.lunarDay === 1
|
|
197
196
|
? `${this.lunarDate.lunarDay}/${this.lunarDate.lunarMonth}`
|
|
198
197
|
: this.lunarDate.lunarDay}
|
|
199
|
-
</
|
|
198
|
+
</RNText>
|
|
200
199
|
)}
|
|
201
200
|
<Text typography={'header_s_semibold'} color={textColor}>
|
|
202
201
|
{text}
|
package/HeaderControl.tsx
CHANGED
|
@@ -33,7 +33,7 @@ const HeaderControl: ForwardRefRenderFunction<
|
|
|
33
33
|
|
|
34
34
|
if (info && info.date) {
|
|
35
35
|
const headerFormat = `${translate?.(
|
|
36
|
-
Util.mapMonth(info.date.month() + 1) || ''
|
|
36
|
+
Util.mapMonth(info.date.month() + 1) || ''
|
|
37
37
|
)}/${info.date.year()}`;
|
|
38
38
|
return (
|
|
39
39
|
<View style={styles.headerControlContainer}>
|
package/LunarService.ts
CHANGED
|
@@ -29,27 +29,6 @@ const jdFromDate = (dd: number, mm: number, yy: number) => {
|
|
|
29
29
|
return jd;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
/* Convert a Julian day number to day/month/year. Parameter jd is an integer */
|
|
33
|
-
const jdToDate = (jd: number) => {
|
|
34
|
-
let a, b, c, d, e, m, day, month, year;
|
|
35
|
-
if (jd > 2299160) {
|
|
36
|
-
// After 5/10/1582, Gregorian calendar
|
|
37
|
-
a = jd + 32044;
|
|
38
|
-
b = removeFractionalPart((4 * a + 3) / 146097);
|
|
39
|
-
c = a - removeFractionalPart((b * 146097) / 4);
|
|
40
|
-
} else {
|
|
41
|
-
b = 0;
|
|
42
|
-
c = jd + 32082;
|
|
43
|
-
}
|
|
44
|
-
d = removeFractionalPart((4 * c + 3) / 1461);
|
|
45
|
-
e = c - removeFractionalPart((1461 * d) / 4);
|
|
46
|
-
m = removeFractionalPart((5 * e + 2) / 153);
|
|
47
|
-
day = e - removeFractionalPart((153 * m + 2) / 5) + 1;
|
|
48
|
-
month = m + 3 - 12 * removeFractionalPart(m / 10);
|
|
49
|
-
year = b * 100 + d - 4800 + removeFractionalPart(m / 10);
|
|
50
|
-
return [day, month, year];
|
|
51
|
-
};
|
|
52
|
-
|
|
53
32
|
/* Compute the time of the k-th new moon after the new moon of 1/1/1900 13:52 UCT
|
|
54
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).
|
|
55
34
|
* Returns a floating number, e.g., 2415079.9758617813 for k=2 or 2414961.935157746 for k=-2
|
|
@@ -127,7 +106,7 @@ const SunLongitude = (jdn: number) => {
|
|
|
127
106
|
*/
|
|
128
107
|
const getSunLongitude = (dayNumber: number, timeZone: number) => {
|
|
129
108
|
return removeFractionalPart(
|
|
130
|
-
(SunLongitude(dayNumber - 0.5 - timeZone / 24) / Math.PI) * 6
|
|
109
|
+
(SunLongitude(dayNumber - 0.5 - timeZone / 24) / Math.PI) * 6
|
|
131
110
|
);
|
|
132
111
|
};
|
|
133
112
|
|
|
@@ -172,7 +151,7 @@ export const convertSolar2Lunar = (
|
|
|
172
151
|
dd: number,
|
|
173
152
|
mm: number,
|
|
174
153
|
yy: number,
|
|
175
|
-
timeZone: number
|
|
154
|
+
timeZone: number
|
|
176
155
|
) => {
|
|
177
156
|
let k,
|
|
178
157
|
dayNumber,
|
package/TabHeader.tsx
CHANGED
|
@@ -15,10 +15,10 @@ export default class TabHeader extends React.Component<
|
|
|
15
15
|
TabHeaderProps,
|
|
16
16
|
TabHeaderState
|
|
17
17
|
> {
|
|
18
|
+
static contextType = ApplicationContext;
|
|
18
19
|
label;
|
|
19
20
|
defaultDate: Moment.Moment;
|
|
20
21
|
|
|
21
|
-
static contextType = ApplicationContext;
|
|
22
22
|
constructor(props: TabHeaderProps) {
|
|
23
23
|
super(props);
|
|
24
24
|
this.state = {
|
package/index.tsx
CHANGED
|
@@ -27,6 +27,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
27
27
|
cellHeader1: RefObject<TabHeader>;
|
|
28
28
|
cellHeader2: RefObject<TabHeader>;
|
|
29
29
|
cellHeaderSingle: RefObject<TabHeader>;
|
|
30
|
+
|
|
30
31
|
constructor(props: CalendarProps) {
|
|
31
32
|
super(props);
|
|
32
33
|
this.doubleDate = props.doubleDate
|
|
@@ -74,7 +75,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
74
75
|
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
75
76
|
this.doubleDate.first,
|
|
76
77
|
this.doubleDate.second,
|
|
77
|
-
this.tabSelected
|
|
78
|
+
this.tabSelected
|
|
78
79
|
);
|
|
79
80
|
}
|
|
80
81
|
} else if (this.calendarPicker.current) {
|
|
@@ -98,7 +99,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
98
99
|
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
99
100
|
this.doubleDate.first,
|
|
100
101
|
this.doubleDate.second,
|
|
101
|
-
this.tabSelected
|
|
102
|
+
this.tabSelected
|
|
102
103
|
);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
@@ -120,17 +121,17 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
120
121
|
this.tabSelected = 1;
|
|
121
122
|
this.cellHeader1.current.updateView(
|
|
122
123
|
this.selectedDate,
|
|
123
|
-
this.tabSelected === 0
|
|
124
|
+
this.tabSelected === 0
|
|
124
125
|
);
|
|
125
126
|
this.cellHeader2.current.updateView(
|
|
126
127
|
this.doubleDate.second,
|
|
127
|
-
this.tabSelected === 1
|
|
128
|
+
this.tabSelected === 1
|
|
128
129
|
);
|
|
129
130
|
this.cellHeader2.current.setActiveTab(this.tabSelected === 1);
|
|
130
131
|
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
131
132
|
this.doubleDate.first,
|
|
132
133
|
this.doubleDate.second,
|
|
133
|
-
this.tabSelected
|
|
134
|
+
this.tabSelected
|
|
134
135
|
);
|
|
135
136
|
if (onDateChange) {
|
|
136
137
|
onDateChange({
|
|
@@ -151,7 +152,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
151
152
|
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
152
153
|
this.doubleDate.first,
|
|
153
154
|
this.doubleDate.second,
|
|
154
|
-
this.tabSelected
|
|
155
|
+
this.tabSelected
|
|
155
156
|
);
|
|
156
157
|
if (onDateChange) {
|
|
157
158
|
onDateChange({
|
|
@@ -183,7 +184,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
183
184
|
this.calendarPicker?.current?.setDoubleDateAndTabIndex(
|
|
184
185
|
this.doubleDate.first,
|
|
185
186
|
this.doubleDate.second,
|
|
186
|
-
this.tabSelected
|
|
187
|
+
this.tabSelected
|
|
187
188
|
);
|
|
188
189
|
if (onCTAStateChange) {
|
|
189
190
|
onCTAStateChange(!!this.doubleDate.second);
|
|
@@ -245,7 +246,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
245
246
|
this.calendarPicker.current?.setDoubleDateAndTabIndex(
|
|
246
247
|
this.selectedDate,
|
|
247
248
|
null,
|
|
248
|
-
this.tabSelected
|
|
249
|
+
this.tabSelected
|
|
249
250
|
);
|
|
250
251
|
this.doubleDate.first = moment(this.selectedDate);
|
|
251
252
|
this.doubleDate.second = null;
|
|
@@ -256,7 +257,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
256
257
|
this.calendarPicker?.current?.setDoubleDateAndTabIndex(
|
|
257
258
|
this.doubleDate.first,
|
|
258
259
|
this.doubleDate.second,
|
|
259
|
-
this.tabSelected
|
|
260
|
+
this.tabSelected
|
|
260
261
|
);
|
|
261
262
|
|
|
262
263
|
if (onCTAStateChange) {
|
|
@@ -301,7 +302,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
301
302
|
if (onCallbackCalendar && typeof onCallbackCalendar === 'function') {
|
|
302
303
|
onCallbackCalendar('switch', isDoubleDateMode);
|
|
303
304
|
}
|
|
304
|
-
}
|
|
305
|
+
}
|
|
305
306
|
);
|
|
306
307
|
};
|
|
307
308
|
|
|
@@ -377,21 +378,21 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
377
378
|
startDate: moment.Moment | undefined;
|
|
378
379
|
endDate: moment.Moment | undefined;
|
|
379
380
|
},
|
|
380
|
-
isScrollToStartDate: any
|
|
381
|
+
isScrollToStartDate: any
|
|
381
382
|
) => {
|
|
382
383
|
const {mode, doubleDate = {}} = this.props;
|
|
383
384
|
if (mode === 'doubleDate') {
|
|
384
385
|
this.cellHeader1?.current?.updateView(
|
|
385
386
|
dateRange.startDate,
|
|
386
|
-
this.tabSelected === 0
|
|
387
|
+
this.tabSelected === 0
|
|
387
388
|
);
|
|
388
389
|
this.cellHeader2?.current?.updateView(
|
|
389
390
|
dateRange.endDate,
|
|
390
|
-
this.tabSelected === 1
|
|
391
|
+
this.tabSelected === 1
|
|
391
392
|
);
|
|
392
393
|
this.calendarPicker?.current?.setDateRange(
|
|
393
394
|
dateRange,
|
|
394
|
-
isScrollToStartDate
|
|
395
|
+
isScrollToStartDate
|
|
395
396
|
);
|
|
396
397
|
this.doubleDate = doubleDate
|
|
397
398
|
? {
|
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Prepare dist files
|
|
2
4
|
rm -rf dist
|
|
3
5
|
mkdir dist
|
|
4
|
-
|
|
5
|
-
cp . ./dist
|
|
6
|
-
|
|
7
|
-
# GET VERSION from mck_package.json
|
|
8
|
-
VERSIONSTRING=( v$(jq .version package.json) )
|
|
9
|
-
VERSION=(${VERSIONSTRING//[\"]/})
|
|
10
|
-
echo VERSION: $VERSION
|
|
11
|
-
|
|
12
|
-
rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
|
|
13
|
-
|
|
14
|
-
# #babel component to dist
|
|
15
|
-
#babel ./dist -d dist --copy-files
|
|
16
|
-
|
|
17
|
-
#copy option
|
|
18
|
-
#cp -r ./src/ dist
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#npm login
|
|
22
|
-
#publish dist to npm
|
|
6
|
+
rsync -r --exclude=/dist ./* dist
|
|
23
7
|
cd dist
|
|
24
|
-
|
|
8
|
+
|
|
9
|
+
if [ "$1" == "stable" ]; then
|
|
10
|
+
npm version $(npm view @momo-kits/foundation@stable version)
|
|
11
|
+
npm version patch
|
|
12
|
+
npm publish --tag stable --access=public
|
|
13
|
+
elif [ "$1" == "latest" ]; then
|
|
14
|
+
npm version $(npm view @momo-kits/foundation@latest version)
|
|
15
|
+
npm publish --tag latest --access=public
|
|
16
|
+
else
|
|
17
|
+
npm version $(npm view @momo-kits/calendar@beta version)
|
|
18
|
+
npm version prerelease --preid=beta
|
|
19
|
+
npm publish --tag beta --access=public
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
PACKAGE_NAME=$(npm pkg get name)
|
|
23
|
+
NEW_PACKAGE_VERSION=$(npm pkg get version)
|
|
24
|
+
|
|
25
|
+
# Clean up
|
|
25
26
|
cd ..
|
|
26
27
|
rm -rf dist
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
##curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/calendar new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/calendar"}'
|
package/styles.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Colors, Radius, Spacing} from '@momo-kits/foundation';
|
|
2
|
+
import {Colors, Radius, scaleSize, Spacing} from '@momo-kits/foundation';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
//calendar
|
|
@@ -112,7 +112,6 @@ export default StyleSheet.create({
|
|
|
112
112
|
borderTopRightRadius: Radius.XS,
|
|
113
113
|
borderBottomRightRadius: Radius.XS,
|
|
114
114
|
},
|
|
115
|
-
|
|
116
115
|
invisible: {
|
|
117
116
|
height: 0,
|
|
118
117
|
width: 0,
|
|
@@ -120,4 +119,9 @@ export default StyleSheet.create({
|
|
|
120
119
|
marginBottom: 0,
|
|
121
120
|
overflow: 'hidden',
|
|
122
121
|
},
|
|
122
|
+
lunarText: {
|
|
123
|
+
fontSize: scaleSize(8),
|
|
124
|
+
lineHeight: scaleSize(12),
|
|
125
|
+
fontWeight: '500',
|
|
126
|
+
},
|
|
123
127
|
});
|