@momo-kits/calendar 0.0.74-beta → 0.72.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/index.js +1 -1
- package/package.json +17 -16
- package/publish.sh +2 -2
- package/src/Calendar.js +476 -343
- package/src/CalendarPro.js +391 -318
- package/src/Day/index.js +215 -175
- package/src/Day/style.js +114 -116
- package/src/HeaderControl.js +65 -61
- package/src/LunarDateConverter.js +186 -179
- package/src/LunarService.js +76 -40
- package/src/Month/index.js +74 -65
- package/src/MonthList.js +232 -237
- package/src/TabHeader.js +60 -67
- package/src/Util.js +273 -193
- package/src/calendarPicker/Day.js +120 -128
- package/src/calendarPicker/Days.js +208 -181
- package/src/calendarPicker/HeaderControls.js +145 -136
- package/src/calendarPicker/WeekDaysLabels.js +18 -13
- package/src/calendarPicker/index.js +100 -100
- package/src/calendarPicker/styles.js +175 -176
- package/src/calendarPicker/util.js +75 -41
- package/src/holidayData.js +121 -123
package/src/CalendarPro.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/* eslint-disable no-bitwise */
|
|
2
|
-
import React, {
|
|
2
|
+
import React, {Component} from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
Dimensions,
|
|
7
|
+
ScrollView,
|
|
8
|
+
StyleSheet,
|
|
9
|
+
TouchableWithoutFeedback,
|
|
10
|
+
View,
|
|
11
11
|
} from 'react-native';
|
|
12
12
|
import Moment from 'moment';
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Colors,
|
|
15
|
+
IconSource,
|
|
16
|
+
Image,
|
|
17
|
+
Radius,
|
|
18
|
+
Spacing,
|
|
19
|
+
SwitchLanguage,
|
|
20
|
+
Text,
|
|
21
|
+
} from '@momo-kits/core-v2';
|
|
16
22
|
import MonthList from './MonthList';
|
|
17
23
|
import HeaderControl from './HeaderControl';
|
|
18
24
|
import LunarDateConverter from './LunarDateConverter';
|
|
@@ -21,343 +27,410 @@ import Util from './Util';
|
|
|
21
27
|
const widthScreen = Dimensions.get('window').width;
|
|
22
28
|
|
|
23
29
|
export default class CalendarPro extends Component {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
constructor(props) {
|
|
31
|
+
super(props);
|
|
32
|
+
this.today = Moment();
|
|
33
|
+
this.year = this.today.year();
|
|
34
|
+
this.getDateRange();
|
|
35
|
+
this.header = this.today.clone();
|
|
36
|
+
this.selectedDate = props.selectedDate;
|
|
37
|
+
this.state = {
|
|
38
|
+
startDate: props.startDate,
|
|
39
|
+
endDate: props.endDate,
|
|
40
|
+
showLunar: props.isShowLunar,
|
|
41
|
+
tabSelected: 0,
|
|
42
|
+
holidays: [],
|
|
43
|
+
ownUpdate: false,
|
|
44
|
+
};
|
|
45
|
+
this.converter = new LunarDateConverter();
|
|
46
|
+
}
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
} if (nextProps.isShowLunar !== prevState.showLunar) {
|
|
48
|
-
return { showLunar: nextProps.isShowLunar };
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
48
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
49
|
+
if (prevState.ownUpdate) {
|
|
50
|
+
return {
|
|
51
|
+
ownUpdate: false,
|
|
52
|
+
};
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (dateRange && dateRange.startDate && dateRange.endDate) {
|
|
55
|
-
this.setState({ startDate: dateRange.startDate, endDate: dateRange.endDate }, () => {
|
|
56
|
-
const dateScroll = isScrollToStartDate ? dateRange.startDate : dateRange.endDate;
|
|
57
|
-
this.refs.MonthList.scrollToMonth(dateScroll);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
54
|
+
if (nextProps.isShowLunar !== prevState.showLunar) {
|
|
55
|
+
return {showLunar: nextProps.isShowLunar};
|
|
60
56
|
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
setDateRange = (dateRange, isScrollToStartDate) => {
|
|
61
|
+
if (dateRange && dateRange.startDate && dateRange.endDate) {
|
|
62
|
+
this.setState(
|
|
63
|
+
{
|
|
64
|
+
startDate: dateRange.startDate,
|
|
65
|
+
endDate: dateRange.endDate,
|
|
66
|
+
},
|
|
67
|
+
() => {
|
|
68
|
+
const dateScroll = isScrollToStartDate
|
|
69
|
+
? dateRange.startDate
|
|
70
|
+
: dateRange.endDate;
|
|
71
|
+
this.refs.MonthList.scrollToMonth(dateScroll);
|
|
72
|
+
},
|
|
73
|
+
);
|
|
64
74
|
}
|
|
75
|
+
};
|
|
65
76
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return (customI18n[type] || {})[data] || Util.I18N_MAP[i18n][type][data];
|
|
73
|
-
}
|
|
74
|
-
if (type === 'date') {
|
|
75
|
-
return data.format(customI18n[type] || Util.I18N_MAP[i18n][type]);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
getDateRange = () => {
|
|
80
|
-
const {
|
|
81
|
-
maxDate,
|
|
82
|
-
minDate,
|
|
83
|
-
format
|
|
84
|
-
} = this.props;
|
|
85
|
-
let max = Moment(maxDate, format);
|
|
86
|
-
let min = Moment(minDate, format);
|
|
87
|
-
const maxValid = max.isValid();
|
|
88
|
-
const minValid = min.isValid();
|
|
89
|
-
if (!maxValid && !minValid) {
|
|
90
|
-
max = Moment().add(12, 'months');
|
|
91
|
-
min = Moment();
|
|
92
|
-
}
|
|
93
|
-
if (!maxValid && minValid) {
|
|
94
|
-
max = min.add(12, 'months');
|
|
95
|
-
}
|
|
96
|
-
if (maxValid && !minValid) {
|
|
97
|
-
min = max.subtract(12, 'months');
|
|
98
|
-
}
|
|
99
|
-
if (min.isSameOrAfter(max)) return {};
|
|
100
|
-
this.minDate = min;
|
|
101
|
-
this.maxDate = max;
|
|
102
|
-
};
|
|
77
|
+
ownSetState(state) {
|
|
78
|
+
this.setState({
|
|
79
|
+
...state,
|
|
80
|
+
ownUpdate: true,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
103
83
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
endDate: day
|
|
114
|
-
});
|
|
115
|
-
} else if (startDate && day < startDate) {
|
|
116
|
-
this.ownSetState({
|
|
117
|
-
startDate: day,
|
|
118
|
-
endDate: null
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
this.ownSetState({
|
|
123
|
-
startDate: day
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
this.ownSetState({
|
|
128
|
-
startDate: day,
|
|
129
|
-
endDate: null,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (onDateChange) {
|
|
133
|
-
onDateChange(day);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
84
|
+
loadLabel = (data, type) => {
|
|
85
|
+
const {i18n, customI18n} = this.props;
|
|
86
|
+
if (~['w', 'weekday', 'text'].indexOf(type)) {
|
|
87
|
+
return (customI18n[type] || {})[data] || Util.I18N_MAP[i18n][type][data];
|
|
88
|
+
}
|
|
89
|
+
if (type === 'date') {
|
|
90
|
+
return data.format(customI18n[type] || Util.I18N_MAP[i18n][type]);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
136
93
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
};
|
|
94
|
+
getDateRange = () => {
|
|
95
|
+
const {maxDate, minDate, format} = this.props;
|
|
96
|
+
let max = Moment(maxDate, format);
|
|
97
|
+
let min = Moment(minDate, format);
|
|
98
|
+
const maxValid = max.isValid();
|
|
99
|
+
const minValid = min.isValid();
|
|
100
|
+
if (!maxValid && !minValid) {
|
|
101
|
+
max = Moment().add(12, 'months');
|
|
102
|
+
min = Moment();
|
|
103
|
+
}
|
|
104
|
+
if (!maxValid && minValid) {
|
|
105
|
+
max = min.add(12, 'months');
|
|
106
|
+
}
|
|
107
|
+
if (maxValid && !minValid) {
|
|
108
|
+
min = max.subtract(12, 'months');
|
|
109
|
+
}
|
|
110
|
+
if (min.isSameOrAfter(max)) return {};
|
|
111
|
+
this.minDate = min;
|
|
112
|
+
this.maxDate = max;
|
|
113
|
+
};
|
|
154
114
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
115
|
+
onChoose = day => {
|
|
116
|
+
const {startDate, tabSelected} = this.state;
|
|
117
|
+
const {isDoubleDateMode, onDateChange} = this.props;
|
|
118
|
+
if (isDoubleDateMode) {
|
|
119
|
+
if (tabSelected === 1) {
|
|
120
|
+
if (startDate && day >= startDate) {
|
|
121
|
+
this.ownSetState({
|
|
122
|
+
endDate: day,
|
|
123
|
+
});
|
|
124
|
+
} else if (startDate && day < startDate) {
|
|
125
|
+
this.ownSetState({
|
|
126
|
+
startDate: day,
|
|
127
|
+
endDate: null,
|
|
128
|
+
});
|
|
161
129
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
setDoubleDateAndTabIndex = (firstDate, secondDate, tabSelected) => {
|
|
130
|
+
} else {
|
|
165
131
|
this.ownSetState({
|
|
166
|
-
|
|
167
|
-
endDate: secondDate ? Moment(secondDate) : null,
|
|
168
|
-
tabSelected
|
|
132
|
+
startDate: day,
|
|
169
133
|
});
|
|
170
|
-
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
this.ownSetState({
|
|
137
|
+
startDate: day,
|
|
138
|
+
endDate: null,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (onDateChange) {
|
|
142
|
+
onDateChange(day);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
171
145
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
146
|
+
executeProcessAfterScrollCalendar = (date, key) => {
|
|
147
|
+
const holidays = Object.values(Util.getHolidaysInMonth(Moment(date)));
|
|
148
|
+
const {showLunar} = this.state;
|
|
149
|
+
if (this.refs && this.refs.HeaderControl) {
|
|
150
|
+
this.refs.HeaderControl.onUpdateInfo({date});
|
|
151
|
+
this.header = date.clone().startOf('month');
|
|
152
|
+
}
|
|
153
|
+
let data = [];
|
|
154
|
+
if (!showLunar) {
|
|
155
|
+
data = holidays.filter(item => !item.lunar || item.mixedLabel);
|
|
156
|
+
} else {
|
|
157
|
+
data = holidays;
|
|
158
|
+
}
|
|
159
|
+
this.ownSetState({
|
|
160
|
+
holidays,
|
|
161
|
+
temp: data,
|
|
162
|
+
headerKey: key,
|
|
163
|
+
});
|
|
164
|
+
};
|
|
185
165
|
|
|
186
|
-
|
|
187
|
-
};
|
|
166
|
+
onScrollCalendar = data => {
|
|
167
|
+
const {headerKey} = this.state;
|
|
168
|
+
if (data) {
|
|
169
|
+
if (data.key !== headerKey) {
|
|
170
|
+
this.executeProcessAfterScrollCalendar(data.date, data.key);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
188
174
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
};
|
|
175
|
+
setDoubleDateAndTabIndex = (firstDate, secondDate, tabSelected) => {
|
|
176
|
+
this.ownSetState({
|
|
177
|
+
startDate: firstDate ? Moment(firstDate) : null,
|
|
178
|
+
endDate: secondDate ? Moment(secondDate) : null,
|
|
179
|
+
tabSelected,
|
|
180
|
+
});
|
|
181
|
+
};
|
|
197
182
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
183
|
+
toggleLunarDate = () => {
|
|
184
|
+
const {showLunar, holidays} = this.state;
|
|
185
|
+
const {onCallbackCalendar} = this.props;
|
|
186
|
+
let data = [];
|
|
187
|
+
const nextStateShowLunar = !showLunar;
|
|
188
|
+
if (!nextStateShowLunar) {
|
|
189
|
+
data = holidays.filter(item => !item.lunar || item.mixedLabel);
|
|
190
|
+
} else {
|
|
191
|
+
data = holidays;
|
|
192
|
+
}
|
|
193
|
+
if (onCallbackCalendar) {
|
|
194
|
+
onCallbackCalendar('lunar', nextStateShowLunar);
|
|
195
|
+
}
|
|
206
196
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
} = this.props;
|
|
214
|
-
let priceListFormat = priceList?.outbound;
|
|
215
|
-
if (isDoubleDateMode) {
|
|
216
|
-
priceListFormat = tabSelected === 0 ? priceList?.outbound : priceList?.inbound;
|
|
217
|
-
}
|
|
218
|
-
return (
|
|
219
|
-
<View style={styles.container}>
|
|
220
|
-
<View style={styles.viewDate}>
|
|
221
|
-
<HeaderControl
|
|
222
|
-
ref="HeaderControl"
|
|
223
|
-
// selectedDate={this.selectedDate}
|
|
224
|
-
onPressBackArrow={this.onPressBackArrow}
|
|
225
|
-
onPressNextArrow={this.onPressNextArrow}
|
|
226
|
-
/>
|
|
227
|
-
<View style={styles.viewDay}>
|
|
228
|
-
{[1, 2, 3, 4, 5, 6, 7].map((item) => (
|
|
229
|
-
<Text
|
|
230
|
-
style={[styles.textDay, { color: item === 6 || item === 7 ? Colors.red_05 : Colors.black_12 }]}
|
|
231
|
-
key={item}
|
|
232
|
-
>
|
|
233
|
-
{Util.mapWeeKDate(item)}
|
|
234
|
-
</Text>
|
|
235
|
-
)
|
|
236
|
-
)}
|
|
237
|
-
</View>
|
|
238
|
-
<MonthList
|
|
239
|
-
ref="MonthList"
|
|
240
|
-
today={this.today}
|
|
241
|
-
minDate={this.minDate}
|
|
242
|
-
maxDate={this.maxDate}
|
|
243
|
-
startDate={startDate}
|
|
244
|
-
endDate={endDate}
|
|
245
|
-
onChoose={this.onChoose}
|
|
246
|
-
i18n={i18n}
|
|
247
|
-
onScrollCalendar={this.onScrollCalendar}
|
|
248
|
-
isShowLunar={!isOffLunar && showLunar}
|
|
249
|
-
isDoubleDateMode={isDoubleDateMode}
|
|
250
|
-
tabSelected={tabSelected}
|
|
251
|
-
lunarConverter={this.converter}
|
|
252
|
-
holidays={holidays}
|
|
253
|
-
selectedDate={this.selectedDate}
|
|
254
|
-
priceList={priceListFormat}
|
|
255
|
-
labelFrom={labelFrom}
|
|
256
|
-
labelTo={labelTo}
|
|
257
|
-
isHideLabel={isHideLabel}
|
|
258
|
-
/>
|
|
259
|
-
</View>
|
|
260
|
-
{
|
|
261
|
-
!isOffLunar && (
|
|
262
|
-
<View style={styles.viewLunar}>
|
|
263
|
-
<TouchableWithoutFeedback onPress={this.toggleLunarDate}>
|
|
264
|
-
<Image source={showLunar ? IconSource.ic_checkbox_checked_24 : IconSource.ic_checkbox_unchecked_24} style={styles.iconSelected} />
|
|
265
|
-
</TouchableWithoutFeedback>
|
|
266
|
-
<Text.SubTitle
|
|
267
|
-
style={styles.txtLunar}
|
|
268
|
-
onPress={this.toggleLunarDate}
|
|
269
|
-
>
|
|
270
|
-
{SwitchLanguage.showLunar}
|
|
271
|
-
</Text.SubTitle>
|
|
272
|
-
</View>
|
|
273
|
-
)
|
|
274
|
-
}
|
|
197
|
+
this.ownSetState({
|
|
198
|
+
showLunar: !showLunar,
|
|
199
|
+
temp: data,
|
|
200
|
+
ownUpdate: true,
|
|
201
|
+
});
|
|
202
|
+
};
|
|
275
203
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
{labelDate}
|
|
291
|
-
</Text.SubTitle>
|
|
292
|
-
<Text.SubTitle style={styles.subTextLunar}>
|
|
293
|
-
{`${labelHoliday} `}
|
|
294
|
-
{
|
|
295
|
-
labelHighlight ? <Text style={{ color: Colors.red_05 }}>{labelHighlight}</Text> : ''
|
|
296
|
-
}
|
|
297
|
-
</Text.SubTitle>
|
|
298
|
-
</View>
|
|
299
|
-
);
|
|
300
|
-
})}
|
|
301
|
-
</ScrollView>
|
|
302
|
-
)
|
|
303
|
-
}
|
|
204
|
+
onPressBackArrow = () => {
|
|
205
|
+
const previousDate = Moment(this.header)
|
|
206
|
+
.startOf('month')
|
|
207
|
+
.subtract(1, 'months');
|
|
208
|
+
if (
|
|
209
|
+
this.refs &&
|
|
210
|
+
this.refs.HeaderControl &&
|
|
211
|
+
previousDate.isSameOrAfter(this.minDate, 'month')
|
|
212
|
+
) {
|
|
213
|
+
this.header = previousDate;
|
|
214
|
+
this.refs.HeaderControl.onUpdateInfo({date: previousDate});
|
|
215
|
+
this.refs.MonthList.scrollToMonth(previousDate);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
304
218
|
|
|
305
|
-
|
|
306
|
-
|
|
219
|
+
onPressNextArrow = () => {
|
|
220
|
+
const nextDate = Moment(this.header).startOf('month').add(1, 'months');
|
|
221
|
+
if (
|
|
222
|
+
this.refs &&
|
|
223
|
+
this.refs.HeaderControl &&
|
|
224
|
+
nextDate.isSameOrBefore(this.maxDate, 'month')
|
|
225
|
+
) {
|
|
226
|
+
this.header = nextDate;
|
|
227
|
+
this.refs.HeaderControl.onUpdateInfo({date: nextDate});
|
|
228
|
+
this.refs.MonthList.scrollToMonth(nextDate);
|
|
307
229
|
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
render() {
|
|
233
|
+
const {startDate, endDate, showLunar, tabSelected, holidays, temp} =
|
|
234
|
+
this.state;
|
|
235
|
+
const {
|
|
236
|
+
i18n,
|
|
237
|
+
isDoubleDateMode,
|
|
238
|
+
priceList,
|
|
239
|
+
labelFrom,
|
|
240
|
+
labelTo,
|
|
241
|
+
isHideLabel,
|
|
242
|
+
isHideHoliday,
|
|
243
|
+
isOffLunar,
|
|
244
|
+
disabledWeekend,
|
|
245
|
+
isShowLunar,
|
|
246
|
+
} = this.props;
|
|
247
|
+
let priceListFormat = priceList?.outbound;
|
|
248
|
+
if (isDoubleDateMode) {
|
|
249
|
+
priceListFormat =
|
|
250
|
+
tabSelected === 0 ? priceList?.outbound : priceList?.inbound;
|
|
251
|
+
}
|
|
252
|
+
const isDisabledWeekend =
|
|
253
|
+
disabledWeekend && !priceList && !isShowLunar && !isDoubleDateMode;
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<View style={styles.container}>
|
|
257
|
+
<View style={styles.viewDate}>
|
|
258
|
+
<HeaderControl
|
|
259
|
+
ref="HeaderControl"
|
|
260
|
+
// selectedDate={this.selectedDate}
|
|
261
|
+
onPressBackArrow={this.onPressBackArrow}
|
|
262
|
+
onPressNextArrow={this.onPressNextArrow}
|
|
263
|
+
/>
|
|
264
|
+
<View style={styles.blueSeperator} />
|
|
265
|
+
<View>
|
|
266
|
+
<View style={styles.viewDay}>
|
|
267
|
+
{[1, 2, 3, 4, 5, 6, 7].map(item => (
|
|
268
|
+
<Text.Label2
|
|
269
|
+
weight="medium"
|
|
270
|
+
style={[
|
|
271
|
+
styles.textDay,
|
|
272
|
+
{
|
|
273
|
+
color:
|
|
274
|
+
item === 6 || item === 7
|
|
275
|
+
? isDisabledWeekend
|
|
276
|
+
? Colors.red_07
|
|
277
|
+
: Colors.red_03
|
|
278
|
+
: Colors.black_17,
|
|
279
|
+
},
|
|
280
|
+
]}
|
|
281
|
+
key={item}>
|
|
282
|
+
{Util.mapWeeKDate(item)}
|
|
283
|
+
</Text.Label2>
|
|
284
|
+
))}
|
|
285
|
+
</View>
|
|
286
|
+
<MonthList
|
|
287
|
+
disabledWeekend={isDisabledWeekend}
|
|
288
|
+
ref="MonthList"
|
|
289
|
+
today={this.today}
|
|
290
|
+
minDate={this.minDate}
|
|
291
|
+
maxDate={this.maxDate}
|
|
292
|
+
startDate={startDate}
|
|
293
|
+
endDate={endDate}
|
|
294
|
+
onChoose={this.onChoose}
|
|
295
|
+
i18n={i18n}
|
|
296
|
+
onScrollCalendar={this.onScrollCalendar}
|
|
297
|
+
isShowLunar={!isOffLunar && showLunar}
|
|
298
|
+
isDoubleDateMode={isDoubleDateMode}
|
|
299
|
+
tabSelected={tabSelected}
|
|
300
|
+
lunarConverter={this.converter}
|
|
301
|
+
holidays={holidays}
|
|
302
|
+
selectedDate={this.selectedDate}
|
|
303
|
+
priceList={priceListFormat}
|
|
304
|
+
labelFrom={labelFrom}
|
|
305
|
+
labelTo={labelTo}
|
|
306
|
+
isHideLabel={isHideLabel}
|
|
307
|
+
/>
|
|
308
|
+
</View>
|
|
309
|
+
</View>
|
|
310
|
+
{!isOffLunar && (
|
|
311
|
+
<View style={[styles.viewLunar]}>
|
|
312
|
+
<TouchableWithoutFeedback onPress={this.toggleLunarDate}>
|
|
313
|
+
<Image
|
|
314
|
+
tintColor={showLunar ? Colors.pink_03 : Colors.black_17}
|
|
315
|
+
source={
|
|
316
|
+
showLunar
|
|
317
|
+
? IconSource.ic_checkbox_checked_24
|
|
318
|
+
: IconSource.ic_checkbox_unchecked_24
|
|
319
|
+
}
|
|
320
|
+
style={styles.iconSelected}
|
|
321
|
+
/>
|
|
322
|
+
</TouchableWithoutFeedback>
|
|
323
|
+
<Text.Description1
|
|
324
|
+
style={styles.txtLunar}
|
|
325
|
+
onPress={this.toggleLunarDate}>
|
|
326
|
+
{SwitchLanguage.showLunar}
|
|
327
|
+
</Text.Description1>
|
|
328
|
+
</View>
|
|
329
|
+
)}
|
|
330
|
+
|
|
331
|
+
{!isHideHoliday && (
|
|
332
|
+
<ScrollView
|
|
333
|
+
contentContainerStyle={styles.contentScroll}
|
|
334
|
+
showsVerticalScrollIndicator={false}
|
|
335
|
+
enabledNestedScroll>
|
|
336
|
+
{temp &&
|
|
337
|
+
temp.length > 0 &&
|
|
338
|
+
temp.map((item, idx) => {
|
|
339
|
+
const labelHoliday = showLunar
|
|
340
|
+
? item.mixedLabel || item.label || ''
|
|
341
|
+
: item.label || '';
|
|
342
|
+
const labelHighlight = showLunar ? item.highlight || '' : '';
|
|
343
|
+
const labelDate = `${
|
|
344
|
+
item.day > 9 ? item.day : `0${item.day}`
|
|
345
|
+
}/${item.month > 9 ? item.month : `0${item.month}`}`;
|
|
346
|
+
return (
|
|
347
|
+
<View style={styles.row} key={idx.toString()}>
|
|
348
|
+
<Text.Description2 style={styles.txtMonthLunar}>
|
|
349
|
+
{labelDate}
|
|
350
|
+
</Text.Description2>
|
|
351
|
+
<Text.Description2 style={styles.subTextLunar}>
|
|
352
|
+
{`${labelHoliday} `}
|
|
353
|
+
</Text.Description2>
|
|
354
|
+
</View>
|
|
355
|
+
);
|
|
356
|
+
})}
|
|
357
|
+
</ScrollView>
|
|
358
|
+
)}
|
|
359
|
+
</View>
|
|
360
|
+
);
|
|
361
|
+
}
|
|
308
362
|
}
|
|
309
363
|
|
|
310
364
|
CalendarPro.propTypes = {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
365
|
+
i18n: PropTypes.string,
|
|
366
|
+
format: PropTypes.string,
|
|
367
|
+
customI18n: PropTypes.object,
|
|
368
|
+
isShowLunar: PropTypes.bool,
|
|
369
|
+
onCallbackCalendar: PropTypes.func,
|
|
370
|
+
minDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
371
|
+
maxDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
318
372
|
};
|
|
319
373
|
|
|
320
374
|
CalendarPro.defaultProps = {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
375
|
+
format: 'YYYY-MM-DD',
|
|
376
|
+
i18n: 'vi',
|
|
377
|
+
customI18n: {},
|
|
378
|
+
isShowLunar: true,
|
|
325
379
|
};
|
|
326
380
|
|
|
327
381
|
const styles = StyleSheet.create({
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
382
|
+
row: {flexDirection: 'row'},
|
|
383
|
+
txtMonthLunar: {
|
|
384
|
+
color: Colors.red_03,
|
|
385
|
+
marginRight: Spacing.S,
|
|
386
|
+
},
|
|
387
|
+
subTextLunar: {
|
|
388
|
+
color: Colors.black_17,
|
|
389
|
+
},
|
|
390
|
+
contentScroll: {
|
|
391
|
+
paddingHorizontal: 12,
|
|
392
|
+
paddingVertical: 10,
|
|
393
|
+
},
|
|
394
|
+
iconSelected: {
|
|
395
|
+
width: 24,
|
|
396
|
+
height: 24,
|
|
397
|
+
resizeMode: 'cover',
|
|
398
|
+
},
|
|
399
|
+
txtLunar: {
|
|
400
|
+
paddingLeft: 6,
|
|
401
|
+
color: '#222222',
|
|
402
|
+
fontSize: 14,
|
|
403
|
+
},
|
|
404
|
+
viewLunar: {
|
|
405
|
+
flexDirection: 'row',
|
|
406
|
+
alignItems: 'center',
|
|
407
|
+
marginHorizontal: Spacing.M,
|
|
408
|
+
borderTopWidth: 1,
|
|
409
|
+
paddingTop: Spacing.M,
|
|
410
|
+
borderStyle: 'solid',
|
|
411
|
+
borderColor: Colors.black_04,
|
|
412
|
+
},
|
|
413
|
+
viewDate: {},
|
|
414
|
+
textDay: {
|
|
415
|
+
width: (widthScreen - 38) / 7,
|
|
416
|
+
textAlign: 'center',
|
|
417
|
+
},
|
|
418
|
+
viewDay: {
|
|
419
|
+
flexDirection: 'row',
|
|
420
|
+
justifyContent: 'space-between',
|
|
421
|
+
paddingHorizontal: Spacing.S,
|
|
422
|
+
paddingTop: 15,
|
|
423
|
+
paddingBottom: 10,
|
|
424
|
+
},
|
|
425
|
+
container: {
|
|
426
|
+
flex: 1,
|
|
427
|
+
backgroundColor: 'white',
|
|
428
|
+
marginTop: Spacing.S,
|
|
429
|
+
borderRadius: Radius.XS,
|
|
430
|
+
},
|
|
431
|
+
blueSeperator: {
|
|
432
|
+
height: 1,
|
|
433
|
+
width: '100%',
|
|
434
|
+
backgroundColor: Colors.blue_05,
|
|
435
|
+
},
|
|
363
436
|
});
|