@momo-kits/calendar 0.0.49-beta → 0.0.49-beta.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/package.json +1 -1
- package/publish.sh +2 -2
- package/src/Day/index.js +193 -176
- package/src/MonthList.js +8 -7
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -21,9 +21,9 @@ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type
|
|
|
21
21
|
#npm login
|
|
22
22
|
#publish dist to npm
|
|
23
23
|
cd dist
|
|
24
|
-
npm publish --access=public
|
|
24
|
+
npm publish --tag beta --access=public
|
|
25
25
|
cd ..
|
|
26
26
|
rm -rf dist
|
|
27
27
|
|
|
28
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"}'
|
|
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/src/Day/index.js
CHANGED
|
@@ -1,193 +1,210 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {Component} from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
TouchableHighlight,
|
|
7
|
-
Text
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import { Colors, SwitchLanguage } from '@momo-kits/core';
|
|
4
|
+
import {View, TouchableHighlight, Text} from 'react-native';
|
|
5
|
+
import {Colors, SwitchLanguage} from '@momo-kits/core';
|
|
10
6
|
import style from './style';
|
|
11
7
|
|
|
12
8
|
class Day extends Component {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.statusCheck();
|
|
12
|
+
}
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
chooseDay = () => {
|
|
15
|
+
const {onChoose, date} = this.props;
|
|
16
|
+
onChoose && onChoose(date);
|
|
17
|
+
};
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
findHoliday = (date, holidays) => {
|
|
20
|
+
if (date && holidays && holidays.length > 0) {
|
|
21
|
+
const day = date.date();
|
|
22
|
+
const month = date.month() + 1;
|
|
23
|
+
return holidays.find(item => item.day === day && item.month === month);
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
28
|
+
checkHoliday = (date, holidays) => {
|
|
29
|
+
const holiday = this.findHoliday(date, holidays);
|
|
30
|
+
return {
|
|
31
|
+
solarHoliday: !!(holiday && !holiday.lunar),
|
|
32
|
+
lunarHoliday: !!(holiday && holiday.lunar),
|
|
38
33
|
};
|
|
34
|
+
};
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
36
|
+
statusCheck = props => {
|
|
37
|
+
const {
|
|
38
|
+
startDate,
|
|
39
|
+
endDate,
|
|
40
|
+
date = null,
|
|
41
|
+
minDate,
|
|
42
|
+
maxDate,
|
|
43
|
+
empty,
|
|
44
|
+
index,
|
|
45
|
+
isShowLunar,
|
|
46
|
+
tabSelected,
|
|
47
|
+
isDoubleDateMode,
|
|
48
|
+
lunarDate,
|
|
49
|
+
isSolarHoliday,
|
|
50
|
+
isLunarHoliday,
|
|
51
|
+
price,
|
|
52
|
+
} = props || this.props;
|
|
53
|
+
this.isValid =
|
|
54
|
+
date &&
|
|
55
|
+
(date >= minDate || date.isSame(minDate, 'day')) &&
|
|
56
|
+
(date <= maxDate || date.isSame(maxDate, 'day'));
|
|
57
|
+
this.isMid =
|
|
58
|
+
(isDoubleDateMode && date > startDate && date < endDate) ||
|
|
59
|
+
(!date && empty >= startDate && empty <= endDate);
|
|
60
|
+
this.isStart = date && date.isSame(startDate, 'd');
|
|
61
|
+
this.isStartPart = this.isStart && endDate;
|
|
62
|
+
this.isEnd = isDoubleDateMode && date && date.isSame(endDate, 'day');
|
|
63
|
+
this.isFocus = this.isMid || this.isStart || this.isEnd;
|
|
64
|
+
this.isWeekEnd = index === 6 || index === 5;
|
|
65
|
+
this.showLunar = isShowLunar;
|
|
66
|
+
this.lunarDate = lunarDate;
|
|
67
|
+
this.isDoubleDateMode = isDoubleDateMode;
|
|
68
|
+
this.isLunarHoliday = isLunarHoliday;
|
|
69
|
+
this.isLunarDayStart = this.lunarDate && this.lunarDate.lunarDay === 1;
|
|
70
|
+
this.isSolarHoliday = isSolarHoliday;
|
|
71
|
+
this.isInScope = isDoubleDateMode
|
|
72
|
+
? tabSelected === 0 ||
|
|
73
|
+
(tabSelected === 1 &&
|
|
74
|
+
startDate &&
|
|
75
|
+
date &&
|
|
76
|
+
date.isSameOrAfter(startDate, 'day'))
|
|
77
|
+
: true;
|
|
78
|
+
return this.isFocus || this.diffPrice;
|
|
79
|
+
};
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
shouldComponentUpdate(nextProps) {
|
|
82
|
+
const {
|
|
83
|
+
isDoubleDateMode,
|
|
84
|
+
isShowLunar,
|
|
85
|
+
tabSelected,
|
|
86
|
+
isSolarHoliday,
|
|
87
|
+
isLunarHoliday,
|
|
88
|
+
price,
|
|
89
|
+
isBestPrice,
|
|
90
|
+
startDate,
|
|
91
|
+
endDate,
|
|
92
|
+
} = this.props;
|
|
93
|
+
const prevStatus = this.isFocus;
|
|
94
|
+
const selectionModeChange = isDoubleDateMode !== nextProps.isDoubleDateMode;
|
|
95
|
+
const lunarChange = isShowLunar !== nextProps.isShowLunar;
|
|
96
|
+
const nextStatus = this.statusCheck(nextProps);
|
|
97
|
+
const tabChange = tabSelected !== nextProps.tabSelected;
|
|
98
|
+
const solarHoliday = isSolarHoliday !== nextProps.isSolarHoliday;
|
|
99
|
+
const lunarHoliday = isLunarHoliday !== nextProps.isLunarHoliday;
|
|
100
|
+
const diffPrice =
|
|
101
|
+
price !== nextProps.price && isBestPrice !== nextProps.isBestPrice;
|
|
102
|
+
const startDateChange =
|
|
103
|
+
startDate && !startDate?.isSame?.(nextProps.startDate, 'day');
|
|
104
|
+
const endDateChange =
|
|
105
|
+
endDate && !endDate?.isSame?.(nextProps.endDate, 'day');
|
|
106
|
+
return !!(
|
|
107
|
+
prevStatus !== nextStatus ||
|
|
108
|
+
selectionModeChange ||
|
|
109
|
+
lunarChange ||
|
|
110
|
+
tabChange ||
|
|
111
|
+
solarHoliday ||
|
|
112
|
+
lunarHoliday ||
|
|
113
|
+
diffPrice ||
|
|
114
|
+
startDateChange ||
|
|
115
|
+
endDateChange
|
|
116
|
+
);
|
|
117
|
+
}
|
|
96
118
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
)
|
|
146
|
-
: (
|
|
147
|
-
<View style={[style.day]}>
|
|
148
|
-
<Text style={[
|
|
149
|
-
style.dayText,
|
|
150
|
-
style.dayTextDisabled,
|
|
151
|
-
]}
|
|
152
|
-
>
|
|
153
|
-
{text}
|
|
154
|
-
</Text>
|
|
155
|
-
{
|
|
156
|
-
this.lunarDate && this.showLunar && text ? (
|
|
157
|
-
<Text style={[
|
|
158
|
-
style.lunarDayText,
|
|
159
|
-
style.dayTextDisabled,
|
|
160
|
-
]}
|
|
161
|
-
>
|
|
162
|
-
{this.lunarDate.lunarDay === 1 ? `${this.lunarDate.lunarDay}/${this.lunarDate.lunarMonth}` : this.lunarDate.lunarDay}
|
|
163
|
-
</Text>
|
|
164
|
-
) : <View />
|
|
165
|
-
}
|
|
166
|
-
</View>
|
|
167
|
-
)}
|
|
168
|
-
</View>
|
|
169
|
-
|
|
170
|
-
{(isDoubleDateMode && this.isStart && !isHideLabel) && (
|
|
171
|
-
<View style={style.txtGo}>
|
|
172
|
-
<Text style={{ fontSize: 8, color: 'white' }}>
|
|
173
|
-
{labelFrom || SwitchLanguage.departing}
|
|
174
|
-
</Text>
|
|
175
|
-
</View>
|
|
176
|
-
)}
|
|
177
|
-
{(isDoubleDateMode && this.isEnd && !isHideLabel) && (
|
|
178
|
-
<View style={style.txtBack}>
|
|
179
|
-
<Text style={{ fontSize: 8, color: 'white' }}>
|
|
180
|
-
{labelTo || SwitchLanguage.returning}
|
|
181
|
-
</Text>
|
|
182
|
-
</View>
|
|
119
|
+
render() {
|
|
120
|
+
const {
|
|
121
|
+
date,
|
|
122
|
+
empty,
|
|
123
|
+
isDoubleDateMode,
|
|
124
|
+
price,
|
|
125
|
+
isBestPrice,
|
|
126
|
+
isShowPrice,
|
|
127
|
+
labelFrom,
|
|
128
|
+
labelTo,
|
|
129
|
+
isHideLabel,
|
|
130
|
+
} = this.props;
|
|
131
|
+
const text = date ? date.date() : '';
|
|
132
|
+
return (
|
|
133
|
+
<View style={style.dayContainer}>
|
|
134
|
+
<View
|
|
135
|
+
style={[
|
|
136
|
+
this.isMid && !empty && style.mid,
|
|
137
|
+
this.isStartPart && style.dayStartContainer,
|
|
138
|
+
this.isEnd && style.dayEndContainer,
|
|
139
|
+
]}>
|
|
140
|
+
{this.isValid && this.isInScope ? (
|
|
141
|
+
<TouchableHighlight
|
|
142
|
+
style={[style.day, (this.isStart || this.isEnd) && style.focused]}
|
|
143
|
+
underlayColor="rgba(255, 255, 255, 0.35)"
|
|
144
|
+
onPress={this.chooseDay}>
|
|
145
|
+
<>
|
|
146
|
+
<Text
|
|
147
|
+
style={[
|
|
148
|
+
style.dayText,
|
|
149
|
+
this.isWeekEnd && style.weekendDay,
|
|
150
|
+
this.isSolarHoliday && style.weekendDay,
|
|
151
|
+
(this.isStart || this.isEnd) && style.focusedText,
|
|
152
|
+
]}>
|
|
153
|
+
{text}
|
|
154
|
+
</Text>
|
|
155
|
+
{this.lunarDate && this.showLunar && (
|
|
156
|
+
<Text
|
|
157
|
+
style={[
|
|
158
|
+
style.lunarDayText,
|
|
159
|
+
(this.isLunarHoliday || this.isLunarDayStart) &&
|
|
160
|
+
style.weekendDay,
|
|
161
|
+
(this.isStart || this.isEnd) && style.focusedText,
|
|
162
|
+
]}>
|
|
163
|
+
{this.lunarDate.lunarDay === 1
|
|
164
|
+
? `${this.lunarDate.lunarDay}/${this.lunarDate.lunarMonth}`
|
|
165
|
+
: this.lunarDate.lunarDay}
|
|
166
|
+
</Text>
|
|
183
167
|
)}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
168
|
+
</>
|
|
169
|
+
</TouchableHighlight>
|
|
170
|
+
) : (
|
|
171
|
+
<View style={[style.day]}>
|
|
172
|
+
<Text style={[style.dayText, style.dayTextDisabled]}>{text}</Text>
|
|
173
|
+
{this.lunarDate && this.showLunar && text ? (
|
|
174
|
+
<Text style={[style.lunarDayText, style.dayTextDisabled]}>
|
|
175
|
+
{this.lunarDate.lunarDay === 1
|
|
176
|
+
? `${this.lunarDate.lunarDay}/${this.lunarDate.lunarMonth}`
|
|
177
|
+
: this.lunarDate.lunarDay}
|
|
178
|
+
</Text>
|
|
179
|
+
) : (
|
|
180
|
+
<View />
|
|
181
|
+
)}
|
|
188
182
|
</View>
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
)}
|
|
184
|
+
</View>
|
|
185
|
+
|
|
186
|
+
{isDoubleDateMode && this.isStart && !isHideLabel && (
|
|
187
|
+
<View style={style.txtGo}>
|
|
188
|
+
<Text style={{fontSize: 8, color: 'white'}}>
|
|
189
|
+
{labelFrom || SwitchLanguage.departing}
|
|
190
|
+
</Text>
|
|
191
|
+
</View>
|
|
192
|
+
)}
|
|
193
|
+
{isDoubleDateMode && this.isEnd && !isHideLabel && (
|
|
194
|
+
<View style={style.txtBack}>
|
|
195
|
+
<Text style={{fontSize: 8, color: 'white'}}>
|
|
196
|
+
{labelTo || SwitchLanguage.returning}
|
|
197
|
+
</Text>
|
|
198
|
+
</View>
|
|
199
|
+
)}
|
|
200
|
+
{this.isValid && this.isInScope && !!price && (
|
|
201
|
+
<Text style={[style.price, isBestPrice && {color: Colors.pink_05_b}]}>
|
|
202
|
+
{price}
|
|
203
|
+
</Text>
|
|
204
|
+
)}
|
|
205
|
+
</View>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
191
208
|
}
|
|
192
209
|
|
|
193
210
|
export default Day;
|
package/src/MonthList.js
CHANGED
|
@@ -8,10 +8,12 @@ import {
|
|
|
8
8
|
import moment from 'moment';
|
|
9
9
|
import Month from './Month';
|
|
10
10
|
import style from './Day/style';
|
|
11
|
-
import
|
|
11
|
+
import LunarDateConverter from './LunarDateConverter';
|
|
12
12
|
|
|
13
13
|
const ITEM_WIDTH = Dimensions.get('window').width - 24;
|
|
14
14
|
const MAX_RENDER_PER_BATCH = Platform.OS === 'android' ? 1 : 12;
|
|
15
|
+
|
|
16
|
+
const converter = new LunarDateConverter();
|
|
15
17
|
export default class MonthList extends Component {
|
|
16
18
|
constructor(props) {
|
|
17
19
|
super(props);
|
|
@@ -76,12 +78,11 @@ export default class MonthList extends Component {
|
|
|
76
78
|
};
|
|
77
79
|
|
|
78
80
|
convertLunarToSolar(date) {
|
|
79
|
-
return date
|
|
80
|
-
date.date(),
|
|
81
|
-
date.month() + 1,
|
|
82
|
-
date.year()
|
|
83
|
-
|
|
84
|
-
) : {};
|
|
81
|
+
return date ? converter.SolarToLunar({
|
|
82
|
+
solarDay: date.date(),
|
|
83
|
+
solarMonth: date.month() + 1,
|
|
84
|
+
solarYear: date.year()
|
|
85
|
+
}) : {};
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
findHoliday = (date) => {
|