@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
|
@@ -1,154 +1,146 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
1
|
+
import React, {Component} from 'react';
|
|
2
|
+
import {TouchableOpacity, View, Text} from 'react-native';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { Text } from '@momo-kits/core';
|
|
5
4
|
import styles from './styles';
|
|
6
5
|
|
|
7
6
|
export default class Day extends Component {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
7
|
+
processMinDate() {
|
|
8
|
+
const {minDate} = this.props;
|
|
9
|
+
if (minDate) {
|
|
10
|
+
minDate.setHours(0, 0, 0, 0);
|
|
11
|
+
if (this.date < minDate) {
|
|
12
|
+
this.disableTouch = true;
|
|
13
|
+
}
|
|
16
14
|
}
|
|
15
|
+
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
17
|
+
processMaxDate() {
|
|
18
|
+
const {maxDate} = this.props;
|
|
19
|
+
if (maxDate) {
|
|
20
|
+
maxDate.setHours(0, 0, 0, 0);
|
|
21
|
+
if (this.date > maxDate) {
|
|
22
|
+
this.disableTouch = true;
|
|
23
|
+
}
|
|
26
24
|
}
|
|
25
|
+
}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (date > firstDate && date < secondDate) {
|
|
48
|
-
this.colorCanTouch = '#90d6f3';
|
|
27
|
+
processDoubleDate() {
|
|
28
|
+
const {mode, otherMonth, firstDate, secondDate, tabSelected} = this.props;
|
|
29
|
+
const {date} = this;
|
|
30
|
+
if (mode === 'doubleDate' && !otherMonth) {
|
|
31
|
+
if (firstDate && tabSelected === 1) {
|
|
32
|
+
firstDate.setHours(0, 0, 0, 0);
|
|
33
|
+
if (date < firstDate) {
|
|
34
|
+
this.disableTouch = true;
|
|
35
|
+
this.styleDouble = {};
|
|
36
|
+
} else if (date.getTime() === firstDate.getTime()) {
|
|
37
|
+
this.colorCanTouch = '#2eb3e8';
|
|
38
|
+
this.colorText = 'white';
|
|
39
|
+
this.styleDouble = {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (secondDate && firstDate) {
|
|
43
|
+
secondDate.setHours(0, 0, 0, 0);
|
|
44
|
+
if (date > firstDate && date < secondDate) {
|
|
45
|
+
this.colorCanTouch = '#90d6f3';
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
this.styleDouble = styles.styleBetween;
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
if (secondDate.getTime() !== firstDate.getTime()) {
|
|
55
|
-
if (date.getTime() === firstDate.getTime()) {
|
|
56
|
-
this.colorCanTouch = '#2eb3e8';
|
|
57
|
-
this.colorText = 'white';
|
|
58
|
-
this.styleDouble = styles.styleFirstDate;
|
|
59
|
-
}
|
|
60
|
-
if (date.getTime() === secondDate.getTime()) {
|
|
61
|
-
this.styleDouble = styles.styleSecondDate;
|
|
62
|
-
this.colorCanTouch = '#2eb3e8';
|
|
63
|
-
this.colorText = 'white';
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
49
|
+
this.colorText = 'white';
|
|
67
50
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
processSelected() {
|
|
71
|
-
const { selected } = this.props;
|
|
72
|
-
if (selected && !this.disableTouch) {
|
|
51
|
+
if (secondDate.getTime() !== firstDate.getTime()) {
|
|
52
|
+
if (date.getTime() === firstDate.getTime()) {
|
|
73
53
|
this.colorCanTouch = '#2eb3e8';
|
|
74
54
|
this.colorText = 'white';
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!selected && this.date.getTime() === this.dateNow.getTime()) {
|
|
81
|
-
this.colorCanTouch = '#8F8E94';
|
|
55
|
+
this.styleDouble = styles.styleFirstDate;
|
|
56
|
+
}
|
|
57
|
+
if (date.getTime() === secondDate.getTime()) {
|
|
58
|
+
this.styleDouble = styles.styleSecondDate;
|
|
59
|
+
this.colorCanTouch = '#2eb3e8';
|
|
82
60
|
this.colorText = 'white';
|
|
61
|
+
}
|
|
83
62
|
}
|
|
63
|
+
}
|
|
84
64
|
}
|
|
65
|
+
}
|
|
85
66
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
67
|
+
processSelected() {
|
|
68
|
+
const {selected} = this.props;
|
|
69
|
+
if (selected && !this.disableTouch) {
|
|
70
|
+
this.colorCanTouch = '#2eb3e8';
|
|
71
|
+
this.colorText = 'white';
|
|
91
72
|
}
|
|
73
|
+
}
|
|
92
74
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.processSelected();
|
|
99
|
-
this.processOtherMonth();
|
|
75
|
+
processDateNow() {
|
|
76
|
+
const {selected} = this.props;
|
|
77
|
+
if (!selected && this.date.getTime() === this.dateNow.getTime()) {
|
|
78
|
+
this.colorCanTouch = '#8F8E94';
|
|
79
|
+
this.colorText = 'white';
|
|
100
80
|
}
|
|
81
|
+
}
|
|
101
82
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.colorTextDisable = '#DADADA';
|
|
109
|
-
this.styleDouble = {};
|
|
110
|
-
this.disableTouch = false;
|
|
111
|
-
this.dateNow = new Date();
|
|
112
|
-
this.dateNow.setHours(0, 0, 0, 0);
|
|
113
|
-
this.date = new Date(year, month, day);
|
|
114
|
-
this.date.setHours(0, 0, 0, 0);
|
|
115
|
-
this.processRender();
|
|
116
|
-
return (
|
|
117
|
-
|
|
118
|
-
<View style={styles.dayWrapper}>
|
|
119
|
-
<View style={this.styleDouble} />
|
|
120
|
-
{
|
|
121
|
-
this.disableTouch || otherMonth
|
|
122
|
-
? (
|
|
123
|
-
<View style={styles.dayButton}>
|
|
124
|
-
<Text.Title style={[styles.dayLabel, { color: this.colorTextDisable }]}>
|
|
125
|
-
{day}
|
|
126
|
-
</Text.Title>
|
|
127
|
-
</View>
|
|
128
|
-
)
|
|
129
|
-
: (
|
|
130
|
-
<View style={[styles.dayButtonSelected, { backgroundColor: this.colorCanTouch }]}>
|
|
131
|
-
<TouchableOpacity
|
|
132
|
-
style={styles.dayButton}
|
|
133
|
-
onPress={() => onDayChange(day, month, year)}
|
|
134
|
-
>
|
|
135
|
-
<Text.Title style={[styles.dayLabel, { color: this.colorText }]}>
|
|
136
|
-
{day}
|
|
137
|
-
</Text.Title>
|
|
138
|
-
</TouchableOpacity>
|
|
83
|
+
processOtherMonth() {
|
|
84
|
+
const {otherMonth} = this.props;
|
|
85
|
+
if (otherMonth) {
|
|
86
|
+
this.colorTextDisable = 'white';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
139
89
|
|
|
140
|
-
|
|
141
|
-
|
|
90
|
+
processRender() {
|
|
91
|
+
this.processMinDate();
|
|
92
|
+
this.processMaxDate();
|
|
93
|
+
// this.processDateNow()
|
|
94
|
+
this.processDoubleDate();
|
|
95
|
+
this.processSelected();
|
|
96
|
+
this.processOtherMonth();
|
|
97
|
+
}
|
|
142
98
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
99
|
+
render() {
|
|
100
|
+
const {day, month, year, otherMonth, onDayChange} = this.props;
|
|
101
|
+
this.colorCanTouch = 'white';
|
|
102
|
+
this.colorText = '#393939';
|
|
103
|
+
this.colorTextDisable = '#DADADA';
|
|
104
|
+
this.styleDouble = {};
|
|
105
|
+
this.disableTouch = false;
|
|
106
|
+
this.dateNow = new Date();
|
|
107
|
+
this.dateNow.setHours(0, 0, 0, 0);
|
|
108
|
+
this.date = new Date(year, month, day);
|
|
109
|
+
this.date.setHours(0, 0, 0, 0);
|
|
110
|
+
this.processRender();
|
|
111
|
+
return (
|
|
112
|
+
<View style={styles.dayWrapper}>
|
|
113
|
+
<View style={this.styleDouble} />
|
|
114
|
+
{this.disableTouch || otherMonth ? (
|
|
115
|
+
<View style={styles.dayButton}>
|
|
116
|
+
<Text.Title
|
|
117
|
+
style={[styles.dayLabel, {color: this.colorTextDisable}]}>
|
|
118
|
+
{day}
|
|
119
|
+
</Text.Title>
|
|
120
|
+
</View>
|
|
121
|
+
) : (
|
|
122
|
+
<View
|
|
123
|
+
style={[
|
|
124
|
+
styles.dayButtonSelected,
|
|
125
|
+
{backgroundColor: this.colorCanTouch},
|
|
126
|
+
]}>
|
|
127
|
+
<TouchableOpacity
|
|
128
|
+
style={styles.dayButton}
|
|
129
|
+
onPress={() => onDayChange(day, month, year)}>
|
|
130
|
+
<Text.Title style={[styles.dayLabel, {color: this.colorText}]}>
|
|
131
|
+
{day}
|
|
132
|
+
</Text.Title>
|
|
133
|
+
</TouchableOpacity>
|
|
134
|
+
</View>
|
|
135
|
+
)}
|
|
136
|
+
</View>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
147
139
|
}
|
|
148
140
|
Day.propTypes = {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
141
|
+
day: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
142
|
+
month: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
143
|
+
year: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
144
|
+
otherMonth: PropTypes.bool,
|
|
145
|
+
onDayChange: PropTypes.func,
|
|
154
146
|
};
|