@momo-kits/calendar 0.0.60-beta → 0.0.60-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 +17 -16
- package/publish.sh +2 -2
- package/src/Calendar.js +268 -96
- package/src/CalendarPro.js +191 -116
- package/src/Day/index.js +173 -99
- package/src/Day/style.js +27 -29
- package/src/HeaderControl.js +52 -47
- package/src/Month/index.js +24 -19
- package/src/MonthList.js +84 -54
- package/src/TabHeader.js +40 -37
- package/src/calendarPicker/Day.js +34 -34
- package/src/calendarPicker/WeekDaysLabels.js +6 -7
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
"name": "@momo-kits/calendar",
|
|
3
|
+
"version": "0.0.60-beta.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@momo-kits/date-picker": "latest",
|
|
8
|
+
"moment": "^2.24.0",
|
|
9
|
+
"@momo-platform/versions": "4.0.2"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"react": "16.9.0",
|
|
13
|
+
"react-native": ">=0.55",
|
|
14
|
+
"prop-types": "^15.7.2",
|
|
15
|
+
"@momo-kits/core": ">=0.0.5-beta"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {},
|
|
18
|
+
"license": "MoMo"
|
|
18
19
|
}
|
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/Calendar.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import React, { Component
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
3
|
import {
|
|
4
|
-
View,
|
|
4
|
+
View,
|
|
5
|
+
ScrollView,
|
|
6
|
+
Platform,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
Dimensions,
|
|
5
9
|
} from 'react-native';
|
|
6
10
|
import moment from 'moment';
|
|
7
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
Text,
|
|
13
|
+
SwitchLanguage,
|
|
14
|
+
Colors,
|
|
15
|
+
Spacing,
|
|
16
|
+
Radius,
|
|
17
|
+
ScaleSize,
|
|
18
|
+
} from '@momo-kits/core';
|
|
19
|
+
import Switch from '@momo-kits/switch';
|
|
8
20
|
import CalendarPro from './CalendarPro';
|
|
9
21
|
import TabHeader from './TabHeader';
|
|
10
22
|
|
|
@@ -13,15 +25,24 @@ const DOUBLE = 'doubleDate';
|
|
|
13
25
|
class Calendar extends Component {
|
|
14
26
|
constructor(props) {
|
|
15
27
|
super(props);
|
|
16
|
-
this.doubleDate = props.doubleDate
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
this.doubleDate = props.doubleDate
|
|
29
|
+
? {
|
|
30
|
+
first: props.doubleDate.first
|
|
31
|
+
? moment(props.doubleDate.first)
|
|
32
|
+
: null,
|
|
33
|
+
second: props.doubleDate.second
|
|
34
|
+
? moment(props.doubleDate.second)
|
|
35
|
+
: null,
|
|
36
|
+
}
|
|
37
|
+
: {};
|
|
20
38
|
this.tabSelected = 0;
|
|
21
|
-
|
|
39
|
+
|
|
40
|
+
this.selectedDate = props.selectedDate
|
|
41
|
+
? moment(props.selectedDate)
|
|
42
|
+
: moment();
|
|
22
43
|
|
|
23
44
|
this.state = {
|
|
24
|
-
isDoubleDateMode: props.mode === DOUBLE
|
|
45
|
+
isDoubleDateMode: props.mode === DOUBLE,
|
|
25
46
|
};
|
|
26
47
|
this.calendarPicker = React.createRef();
|
|
27
48
|
this.cellHeader1 = React.createRef();
|
|
@@ -38,19 +59,41 @@ class Calendar extends Component {
|
|
|
38
59
|
viewInit() {
|
|
39
60
|
const { mode } = this.props;
|
|
40
61
|
if (mode === DOUBLE) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
this.
|
|
62
|
+
if (
|
|
63
|
+
this.cellHeader1.current &&
|
|
64
|
+
this.cellHeader2.current &&
|
|
65
|
+
this.calendarPicker.current
|
|
66
|
+
) {
|
|
67
|
+
const start = this.doubleDate.first
|
|
68
|
+
? this.doubleDate.first
|
|
69
|
+
: null;
|
|
70
|
+
const end = this.doubleDate.second
|
|
71
|
+
? this.doubleDate.second
|
|
72
|
+
: null;
|
|
73
|
+
this.cellHeader1.current.updateView(
|
|
74
|
+
start,
|
|
75
|
+
this.tabSelected === 0,
|
|
76
|
+
);
|
|
77
|
+
this.cellHeader2.current.updateView(
|
|
78
|
+
end,
|
|
79
|
+
this.tabSelected === 1,
|
|
80
|
+
);
|
|
81
|
+
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
82
|
+
this.doubleDate.first,
|
|
83
|
+
this.doubleDate.second,
|
|
84
|
+
this.tabSelected,
|
|
85
|
+
);
|
|
47
86
|
}
|
|
48
87
|
} else if (this.calendarPicker.current) {
|
|
49
|
-
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
88
|
+
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
89
|
+
this.selectedDate,
|
|
90
|
+
);
|
|
50
91
|
}
|
|
51
92
|
}
|
|
52
93
|
|
|
53
94
|
onChangeTab = (idTab) => {
|
|
95
|
+
this.props.onChangeTab && this.props.onChangeTab(idTab);
|
|
96
|
+
|
|
54
97
|
this.tabSelected = idTab;
|
|
55
98
|
if (this.cellHeader1.current && this.cellHeader2.current) {
|
|
56
99
|
this.cellHeader1.current.setActiveTab(idTab === 0);
|
|
@@ -61,19 +104,43 @@ class Calendar extends Component {
|
|
|
61
104
|
|
|
62
105
|
updateViewFlowPicker() {
|
|
63
106
|
if (this.calendarPicker.current) {
|
|
64
|
-
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
107
|
+
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
108
|
+
this.doubleDate.first,
|
|
109
|
+
this.doubleDate.second,
|
|
110
|
+
this.tabSelected,
|
|
111
|
+
);
|
|
65
112
|
}
|
|
66
113
|
}
|
|
67
114
|
|
|
68
115
|
processDateFirst() {
|
|
69
116
|
const { onDateChange, onCTAStateChange } = this.props;
|
|
70
|
-
if (
|
|
71
|
-
|
|
117
|
+
if (
|
|
118
|
+
this.cellHeader1.current &&
|
|
119
|
+
this.cellHeader2.current &&
|
|
120
|
+
this.calendarPicker.current
|
|
121
|
+
) {
|
|
122
|
+
if (
|
|
123
|
+
this.doubleDate.first &&
|
|
124
|
+
this.doubleDate.second &&
|
|
125
|
+
this.selectedDate <= this.doubleDate.first
|
|
126
|
+
) {
|
|
72
127
|
this.doubleDate.first = this.selectedDate;
|
|
128
|
+
this.doubleDate.second = null;
|
|
73
129
|
this.tabSelected = 1;
|
|
74
|
-
this.cellHeader1.current.updateView(
|
|
130
|
+
this.cellHeader1.current.updateView(
|
|
131
|
+
this.selectedDate,
|
|
132
|
+
this.tabSelected === 0,
|
|
133
|
+
);
|
|
134
|
+
this.cellHeader2.current.updateView(
|
|
135
|
+
this.doubleDate.second,
|
|
136
|
+
this.tabSelected === 1,
|
|
137
|
+
);
|
|
75
138
|
this.cellHeader2.current.setActiveTab(this.tabSelected === 1);
|
|
76
|
-
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
139
|
+
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
140
|
+
this.doubleDate.first,
|
|
141
|
+
this.doubleDate.second,
|
|
142
|
+
this.tabSelected,
|
|
143
|
+
);
|
|
77
144
|
if (onDateChange) {
|
|
78
145
|
// const cloned = {
|
|
79
146
|
// first: this.doubleDate.first ? this.doubleDate.first.toDate() : null,
|
|
@@ -82,8 +149,12 @@ class Calendar extends Component {
|
|
|
82
149
|
// this.doubleDate.second ? new Date(this.doubleDate.second.year(), this.doubleDate.second.month(), this.doubleDate.second.date()) : null
|
|
83
150
|
// };
|
|
84
151
|
onDateChange({
|
|
85
|
-
first: this.doubleDate.first
|
|
86
|
-
|
|
152
|
+
first: this.doubleDate.first
|
|
153
|
+
? this.doubleDate.first.toDate()
|
|
154
|
+
: null,
|
|
155
|
+
second: this.doubleDate.second
|
|
156
|
+
? this.doubleDate.second.toDate()
|
|
157
|
+
: null,
|
|
87
158
|
});
|
|
88
159
|
}
|
|
89
160
|
} else {
|
|
@@ -92,11 +163,19 @@ class Calendar extends Component {
|
|
|
92
163
|
this.cellHeader1.current.updateView(this.selectedDate, false);
|
|
93
164
|
this.cellHeader2.current.updateView(null, true);
|
|
94
165
|
this.tabSelected = 1;
|
|
95
|
-
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
166
|
+
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
167
|
+
this.doubleDate.first,
|
|
168
|
+
this.doubleDate.second,
|
|
169
|
+
this.tabSelected,
|
|
170
|
+
);
|
|
96
171
|
if (onDateChange) {
|
|
97
172
|
onDateChange({
|
|
98
|
-
first: this.doubleDate.first
|
|
99
|
-
|
|
173
|
+
first: this.doubleDate.first
|
|
174
|
+
? this.doubleDate.first.toDate()
|
|
175
|
+
: null,
|
|
176
|
+
second: this.doubleDate.second
|
|
177
|
+
? this.doubleDate.second.toDate()
|
|
178
|
+
: null,
|
|
100
179
|
});
|
|
101
180
|
// const cloned = {
|
|
102
181
|
// first: this.doubleDate.first ? new Date(this.doubleDate.first.year(), this.doubleDate.first.month(), this.doubleDate.first.date()) : null,
|
|
@@ -107,25 +186,36 @@ class Calendar extends Component {
|
|
|
107
186
|
}
|
|
108
187
|
}
|
|
109
188
|
if (onCTAStateChange) {
|
|
110
|
-
onCTAStateChange(!!
|
|
189
|
+
onCTAStateChange(!!this.doubleDate.second);
|
|
111
190
|
}
|
|
112
191
|
}
|
|
113
192
|
|
|
114
193
|
processDateSecond() {
|
|
115
194
|
const { onDateChange, onCTAStateChange } = this.props;
|
|
116
|
-
if (
|
|
195
|
+
if (
|
|
196
|
+
this.cellHeader2.current &&
|
|
197
|
+
this.selectedDate >= this.doubleDate.first
|
|
198
|
+
) {
|
|
199
|
+
this.doubleDate.second = this.selectedDate;
|
|
117
200
|
this.cellHeader2.current.updateView(this.selectedDate, false);
|
|
118
201
|
this.cellHeader1.current.setActiveTab(true);
|
|
119
|
-
this.doubleDate.second = this.selectedDate;
|
|
120
202
|
this.tabSelected = 0;
|
|
121
|
-
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
203
|
+
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
204
|
+
this.doubleDate.first,
|
|
205
|
+
this.doubleDate.second,
|
|
206
|
+
this.tabSelected,
|
|
207
|
+
);
|
|
122
208
|
if (onCTAStateChange) {
|
|
123
|
-
onCTAStateChange(!!
|
|
209
|
+
onCTAStateChange(!!this.doubleDate.second);
|
|
124
210
|
}
|
|
125
211
|
if (onDateChange) {
|
|
126
212
|
onDateChange({
|
|
127
|
-
first: this.doubleDate.first
|
|
128
|
-
|
|
213
|
+
first: this.doubleDate.first
|
|
214
|
+
? this.doubleDate.first.toDate()
|
|
215
|
+
: null,
|
|
216
|
+
second: this.doubleDate.second
|
|
217
|
+
? this.doubleDate.second.toDate()
|
|
218
|
+
: null,
|
|
129
219
|
});
|
|
130
220
|
// const cloned = {
|
|
131
221
|
// first: this.doubleDate.first ? new Date(this.doubleDate.first.year(), this.doubleDate.first.month(), this.doubleDate.first.date()) : null,
|
|
@@ -133,6 +223,12 @@ class Calendar extends Component {
|
|
|
133
223
|
// };
|
|
134
224
|
// onDateChange(cloned);
|
|
135
225
|
}
|
|
226
|
+
} else {
|
|
227
|
+
this.doubleDate.first = this.selectedDate;
|
|
228
|
+
this.doubleDate.second = null;
|
|
229
|
+
|
|
230
|
+
this.cellHeader1.current.updateView(this.selectedDate, false);
|
|
231
|
+
this.cellHeader2.current.updateView(null, false);
|
|
136
232
|
}
|
|
137
233
|
}
|
|
138
234
|
|
|
@@ -152,7 +248,10 @@ class Calendar extends Component {
|
|
|
152
248
|
this.processDoubleDate();
|
|
153
249
|
} else {
|
|
154
250
|
if (this.cellHeaderSingle.current) {
|
|
155
|
-
this.cellHeaderSingle.current.updateView(
|
|
251
|
+
this.cellHeaderSingle.current.updateView(
|
|
252
|
+
this.selectedDate,
|
|
253
|
+
true,
|
|
254
|
+
);
|
|
156
255
|
}
|
|
157
256
|
if (onDateChange) {
|
|
158
257
|
const date = new Date(this.selectedDate.toDate());
|
|
@@ -164,7 +263,7 @@ class Calendar extends Component {
|
|
|
164
263
|
onDateChange = (date) => {
|
|
165
264
|
this.selectedDate = date;
|
|
166
265
|
this.updateView();
|
|
167
|
-
}
|
|
266
|
+
};
|
|
168
267
|
|
|
169
268
|
updateHeaderView = () => {
|
|
170
269
|
const { onDateChange, onCTAStateChange } = this.props;
|
|
@@ -173,7 +272,11 @@ class Calendar extends Component {
|
|
|
173
272
|
if (this.cellHeader1.current && this.cellHeader2.current) {
|
|
174
273
|
this.cellHeader1.current.updateView(this.selectedDate, true);
|
|
175
274
|
this.cellHeader2.current.updateView(null, false);
|
|
176
|
-
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
275
|
+
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
276
|
+
this.selectedDate,
|
|
277
|
+
null,
|
|
278
|
+
this.tabSelected,
|
|
279
|
+
);
|
|
177
280
|
this.doubleDate.first = moment(this.selectedDate);
|
|
178
281
|
this.doubleDate.second = null;
|
|
179
282
|
this.tabSelected = 0;
|
|
@@ -183,8 +286,12 @@ class Calendar extends Component {
|
|
|
183
286
|
}
|
|
184
287
|
if (onDateChange) {
|
|
185
288
|
onDateChange({
|
|
186
|
-
first: this.doubleDate.first
|
|
187
|
-
|
|
289
|
+
first: this.doubleDate.first
|
|
290
|
+
? this.doubleDate.first.toDate()
|
|
291
|
+
: null,
|
|
292
|
+
second: this.doubleDate.second
|
|
293
|
+
? this.doubleDate.second.toDate()
|
|
294
|
+
: null,
|
|
188
295
|
});
|
|
189
296
|
// const cloned = {
|
|
190
297
|
// first: this.doubleDate.first ? new Date(this.doubleDate.first.year(), this.doubleDate.first.month(), this.doubleDate.first.date()) : null,
|
|
@@ -199,10 +306,16 @@ class Calendar extends Component {
|
|
|
199
306
|
}
|
|
200
307
|
if (this.cellHeaderSingle.current) {
|
|
201
308
|
if (this.doubleDate.first) {
|
|
202
|
-
this.cellHeaderSingle.current.updateView(
|
|
309
|
+
this.cellHeaderSingle.current.updateView(
|
|
310
|
+
this.doubleDate.first,
|
|
311
|
+
true,
|
|
312
|
+
);
|
|
203
313
|
this.selectedDate = this.doubleDate.first;
|
|
204
314
|
} else {
|
|
205
|
-
this.cellHeaderSingle.current.updateView(
|
|
315
|
+
this.cellHeaderSingle.current.updateView(
|
|
316
|
+
this.selectedDate,
|
|
317
|
+
true,
|
|
318
|
+
);
|
|
206
319
|
}
|
|
207
320
|
|
|
208
321
|
if (onDateChange) {
|
|
@@ -216,29 +329,37 @@ class Calendar extends Component {
|
|
|
216
329
|
|
|
217
330
|
toggleSelectionDateMode = () => {
|
|
218
331
|
const { onCallbackCalendar } = this.props;
|
|
219
|
-
this.setState(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
332
|
+
this.setState(
|
|
333
|
+
(preState) => ({ isDoubleDateMode: !preState.isDoubleDateMode }),
|
|
334
|
+
() => {
|
|
335
|
+
const { isDoubleDateMode } = this.state;
|
|
336
|
+
this.updateHeaderView();
|
|
337
|
+
if (
|
|
338
|
+
onCallbackCalendar &&
|
|
339
|
+
typeof onCallbackCalendar === 'function'
|
|
340
|
+
) {
|
|
341
|
+
onCallbackCalendar('switch', isDoubleDateMode);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
);
|
|
226
345
|
};
|
|
227
346
|
|
|
228
347
|
renderSwitchReturnSelection = () => {
|
|
229
348
|
const { isDoubleDateMode } = this.state;
|
|
230
349
|
return (
|
|
231
|
-
<View style={styles.
|
|
232
|
-
<
|
|
233
|
-
{
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
350
|
+
<View style={styles.headerContainer}>
|
|
351
|
+
<View style={styles.viewSwitch}>
|
|
352
|
+
<Text.Title weight="medium" style={styles.textSwitch}>
|
|
353
|
+
{SwitchLanguage.chooseRoundtrip}
|
|
354
|
+
</Text.Title>
|
|
355
|
+
<Switch
|
|
356
|
+
value={isDoubleDateMode}
|
|
357
|
+
onChange={this.toggleSelectionDateMode}
|
|
358
|
+
thumbColor={isDoubleDateMode ? '#78ca32' : 'white'}
|
|
359
|
+
trackColor={{ false: '#e5e7ec', true: '#e5e7ec' }}
|
|
360
|
+
/>
|
|
361
|
+
</View>
|
|
362
|
+
<View style={styles.seperator} />
|
|
242
363
|
</View>
|
|
243
364
|
);
|
|
244
365
|
};
|
|
@@ -246,7 +367,7 @@ class Calendar extends Component {
|
|
|
246
367
|
renderHeaderPanel = () => {
|
|
247
368
|
const { isDoubleDateMode } = this.state;
|
|
248
369
|
const { headerFrom, headerTo } = this.props;
|
|
249
|
-
return
|
|
370
|
+
return isDoubleDateMode ? (
|
|
250
371
|
<View style={styles.viewPanel}>
|
|
251
372
|
<TabHeader
|
|
252
373
|
id={0}
|
|
@@ -277,33 +398,75 @@ class Calendar extends Component {
|
|
|
277
398
|
date={this.selectedDate}
|
|
278
399
|
/>
|
|
279
400
|
</View>
|
|
280
|
-
)
|
|
401
|
+
);
|
|
281
402
|
};
|
|
282
403
|
|
|
283
404
|
setDateRange = (dateRange, isScrollToStartDate) => {
|
|
284
405
|
const { mode, doubleDate = {} } = this.props;
|
|
285
406
|
if (mode === 'doubleDate') {
|
|
286
|
-
this.cellHeader1.current.updateView(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
407
|
+
this.cellHeader1.current.updateView(
|
|
408
|
+
dateRange.startDate,
|
|
409
|
+
this.tabSelected === 0,
|
|
410
|
+
);
|
|
411
|
+
this.cellHeader2.current.updateView(
|
|
412
|
+
dateRange.endDate,
|
|
413
|
+
this.tabSelected === 1,
|
|
414
|
+
);
|
|
415
|
+
this.calendarPicker?.current?.setDateRange(
|
|
416
|
+
dateRange,
|
|
417
|
+
isScrollToStartDate,
|
|
418
|
+
);
|
|
419
|
+
this.doubleDate = doubleDate
|
|
420
|
+
? {
|
|
421
|
+
first: dateRange.startDate
|
|
422
|
+
? moment(dateRange.startDate)
|
|
423
|
+
: null,
|
|
424
|
+
second: dateRange.endDate
|
|
425
|
+
? moment(dateRange.endDate)
|
|
426
|
+
: null,
|
|
427
|
+
}
|
|
428
|
+
: {};
|
|
293
429
|
}
|
|
294
|
-
}
|
|
430
|
+
};
|
|
295
431
|
|
|
296
432
|
render() {
|
|
297
433
|
const {
|
|
298
|
-
isOffLunar,
|
|
299
|
-
|
|
434
|
+
isOffLunar,
|
|
435
|
+
isHideHoliday,
|
|
436
|
+
isHiddenSwitch,
|
|
437
|
+
isShowLunar,
|
|
438
|
+
onCallbackCalendar,
|
|
439
|
+
priceList,
|
|
440
|
+
labelFrom,
|
|
441
|
+
labelTo,
|
|
442
|
+
isHideLabel,
|
|
443
|
+
minDate,
|
|
444
|
+
maxDate,
|
|
445
|
+
doubleDate,
|
|
446
|
+
isHideHeaderPanel,
|
|
447
|
+
style,
|
|
300
448
|
} = this.props;
|
|
301
449
|
const { isDoubleDateMode } = this.state;
|
|
450
|
+
const { width } = Dimensions.get('window');
|
|
302
451
|
return (
|
|
303
|
-
<ScrollView
|
|
304
|
-
{
|
|
305
|
-
|
|
452
|
+
<ScrollView
|
|
453
|
+
style={[
|
|
454
|
+
styles.scrollView,
|
|
455
|
+
{
|
|
456
|
+
width: width - ScaleSize(24),
|
|
457
|
+
},
|
|
458
|
+
style,
|
|
459
|
+
]}>
|
|
460
|
+
<View
|
|
461
|
+
style={{
|
|
462
|
+
backgroundColor: Colors.black_01,
|
|
463
|
+
borderRadius: Radius.XS,
|
|
464
|
+
}}>
|
|
465
|
+
{!isHiddenSwitch && this.renderSwitchReturnSelection()}
|
|
466
|
+
{!isHideHeaderPanel && this.renderHeaderPanel()}
|
|
467
|
+
</View>
|
|
306
468
|
<CalendarPro
|
|
469
|
+
priceList={priceList}
|
|
307
470
|
ref={this.calendarPicker}
|
|
308
471
|
startDate={doubleDate?.first}
|
|
309
472
|
endDate={doubleDate?.second}
|
|
@@ -312,7 +475,6 @@ class Calendar extends Component {
|
|
|
312
475
|
selectedDate={this.selectedDate}
|
|
313
476
|
isShowLunar={isShowLunar}
|
|
314
477
|
onCallbackCalendar={onCallbackCalendar}
|
|
315
|
-
priceList={priceList}
|
|
316
478
|
labelFrom={labelFrom}
|
|
317
479
|
labelTo={labelTo}
|
|
318
480
|
isHideLabel={isHideLabel}
|
|
@@ -331,7 +493,7 @@ export default Calendar;
|
|
|
331
493
|
Calendar.propTypes = {
|
|
332
494
|
doubleDate: PropTypes.shape({
|
|
333
495
|
first: PropTypes.any,
|
|
334
|
-
second: PropTypes.any
|
|
496
|
+
second: PropTypes.any,
|
|
335
497
|
}),
|
|
336
498
|
id: PropTypes.any,
|
|
337
499
|
isHiddenSwitch: PropTypes.bool,
|
|
@@ -348,47 +510,57 @@ Calendar.propTypes = {
|
|
|
348
510
|
headerTo: PropTypes.string,
|
|
349
511
|
isHideLabel: PropTypes.bool,
|
|
350
512
|
isHideHoliday: PropTypes.bool,
|
|
351
|
-
minDate: PropTypes.oneOfType([
|
|
352
|
-
|
|
513
|
+
minDate: PropTypes.oneOfType([
|
|
514
|
+
PropTypes.string,
|
|
515
|
+
PropTypes.instanceOf(Date),
|
|
516
|
+
]),
|
|
517
|
+
maxDate: PropTypes.oneOfType([
|
|
518
|
+
PropTypes.string,
|
|
519
|
+
PropTypes.instanceOf(Date),
|
|
520
|
+
]),
|
|
521
|
+
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
353
522
|
};
|
|
354
523
|
|
|
355
524
|
Calendar.defaultProps = {
|
|
356
525
|
mode: 'single',
|
|
357
|
-
isHiddenSwitch: false
|
|
526
|
+
isHiddenSwitch: false,
|
|
358
527
|
};
|
|
359
528
|
|
|
360
529
|
const styles = StyleSheet.create({
|
|
361
530
|
viewPanel_2: {
|
|
362
|
-
height:
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
backgroundColor: 'white',
|
|
367
|
-
borderRadius: 8
|
|
531
|
+
height: 50,
|
|
532
|
+
marginHorizontal: 12,
|
|
533
|
+
marginTop: 6,
|
|
534
|
+
flexDirection: 'row',
|
|
368
535
|
},
|
|
369
536
|
viewPanel: {
|
|
370
537
|
height: 50,
|
|
371
538
|
marginHorizontal: 12,
|
|
372
539
|
marginTop: 6,
|
|
373
|
-
marginBottom: 25,
|
|
374
|
-
padding: 2,
|
|
375
540
|
flexDirection: 'row',
|
|
376
|
-
backgroundColor: '#eeeeef',
|
|
377
|
-
justifyContent: 'space-around',
|
|
378
|
-
borderRadius: 8
|
|
379
541
|
},
|
|
380
542
|
textSwitch: {
|
|
381
|
-
|
|
382
|
-
fontWeight: 'bold',
|
|
383
|
-
color: '#222222'
|
|
543
|
+
color: Colors.black_15,
|
|
384
544
|
},
|
|
385
545
|
viewSwitch: {
|
|
386
546
|
flexDirection: 'row',
|
|
387
547
|
justifyContent: 'space-between',
|
|
388
|
-
paddingHorizontal: 12,
|
|
389
548
|
alignItems: 'center',
|
|
390
|
-
backgroundColor:
|
|
391
|
-
|
|
392
|
-
|
|
549
|
+
backgroundColor: Colors.white,
|
|
550
|
+
height: 42,
|
|
551
|
+
},
|
|
552
|
+
seperator: {
|
|
553
|
+
height: 1,
|
|
554
|
+
width: '100%',
|
|
555
|
+
backgroundColor: Colors.black_04,
|
|
556
|
+
},
|
|
557
|
+
headerContainer: {
|
|
558
|
+
paddingHorizontal: 12,
|
|
559
|
+
paddingVertical: 8,
|
|
560
|
+
},
|
|
561
|
+
scrollView: {
|
|
562
|
+
flex: 1,
|
|
563
|
+
backgroundColor: 'transparent',
|
|
564
|
+
alignSelf: 'center',
|
|
393
565
|
},
|
|
394
566
|
});
|