@momo-kits/calendar 0.73.3-beta.5 → 0.74.2-react-native.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 +390 -0
- package/Day.tsx +221 -0
- package/HeaderControl.tsx +55 -0
- package/{src/LunarDateConverter.js → LunarDateConverter.ts} +43 -27
- package/{src/LunarService.js → LunarService.ts} +16 -10
- package/Month.tsx +114 -0
- package/{src/MonthList.js → MonthList.tsx} +96 -62
- package/TabHeader.tsx +90 -0
- package/{src/Util.js → Util.ts} +45 -57
- package/{src/holidayData.js → holidayData.ts} +20 -20
- package/{src/Calendar.js → index.tsx} +133 -182
- package/package.json +13 -13
- package/styles.ts +123 -0
- package/types.ts +200 -0
- package/index.js +0 -4
- package/src/CalendarPro.js +0 -436
- package/src/Day/index.js +0 -233
- package/src/Day/style.js +0 -127
- package/src/HeaderControl.js +0 -83
- package/src/Month/index.js +0 -89
- package/src/Month/style.js +0 -0
- package/src/TabHeader.js +0 -72
- package/src/calendarPicker/Day.js +0 -146
- package/src/calendarPicker/Days.js +0 -230
- package/src/calendarPicker/HeaderControls.js +0 -167
- package/src/calendarPicker/WeekDaysLabels.js +0 -27
- package/src/calendarPicker/index.js +0 -125
- package/src/calendarPicker/styles.js +0 -183
- package/src/calendarPicker/util.js +0 -84
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {Dimensions, ScrollView, StyleSheet, View} from 'react-native';
|
|
1
|
+
import React, {Component, createContext, RefObject} from 'react';
|
|
2
|
+
import {Dimensions, LayoutChangeEvent, View} from 'react-native';
|
|
4
3
|
import moment from 'moment';
|
|
5
4
|
import {
|
|
6
|
-
|
|
5
|
+
ApplicationContext,
|
|
7
6
|
Radius,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
scaleSize,
|
|
8
|
+
Spacing,
|
|
9
|
+
Switch,
|
|
10
10
|
Text,
|
|
11
|
-
} from '@momo-kits/
|
|
12
|
-
import Switch from '@momo-kits/switch';
|
|
11
|
+
} from '@momo-kits/foundation';
|
|
13
12
|
import CalendarPro from './CalendarPro';
|
|
14
13
|
import TabHeader from './TabHeader';
|
|
14
|
+
import {CalendarProps, CalendarState} from './types';
|
|
15
|
+
import styles from './styles';
|
|
15
16
|
|
|
16
17
|
const DOUBLE = 'doubleDate';
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
export const ContainerContext = createContext({width: 0, height: 0});
|
|
20
|
+
|
|
21
|
+
class Calendar extends Component<CalendarProps, CalendarState> {
|
|
22
|
+
static contextType = ApplicationContext;
|
|
23
|
+
doubleDate: any;
|
|
24
|
+
tabSelected;
|
|
25
|
+
selectedDate: moment.Moment;
|
|
26
|
+
calendarPicker: RefObject<CalendarPro>;
|
|
27
|
+
cellHeader1: RefObject<TabHeader>;
|
|
28
|
+
cellHeader2: RefObject<TabHeader>;
|
|
29
|
+
cellHeaderSingle: RefObject<TabHeader>;
|
|
30
|
+
constructor(props: CalendarProps) {
|
|
21
31
|
super(props);
|
|
22
32
|
this.doubleDate = props.doubleDate
|
|
23
33
|
? {
|
|
@@ -35,11 +45,12 @@ class Calendar extends Component {
|
|
|
35
45
|
|
|
36
46
|
this.state = {
|
|
37
47
|
isDoubleDateMode: props.mode === DOUBLE,
|
|
48
|
+
containerWidth: Dimensions.get('window').width,
|
|
38
49
|
};
|
|
39
|
-
this.calendarPicker = React.createRef();
|
|
40
|
-
this.cellHeader1 = React.createRef();
|
|
41
|
-
this.cellHeader2 = React.createRef();
|
|
42
|
-
this.cellHeaderSingle = React.createRef();
|
|
50
|
+
this.calendarPicker = React.createRef<CalendarPro>();
|
|
51
|
+
this.cellHeader1 = React.createRef<TabHeader>();
|
|
52
|
+
this.cellHeader2 = React.createRef<TabHeader>();
|
|
53
|
+
this.cellHeaderSingle = React.createRef<TabHeader>();
|
|
43
54
|
}
|
|
44
55
|
|
|
45
56
|
componentDidMount() {
|
|
@@ -71,10 +82,10 @@ class Calendar extends Component {
|
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
84
|
|
|
74
|
-
onChangeTab = idTab => {
|
|
75
|
-
this.props.onChangeTab
|
|
76
|
-
|
|
85
|
+
onChangeTab = (idTab: number) => {
|
|
86
|
+
this.props.onChangeTab?.(idTab);
|
|
77
87
|
this.tabSelected = idTab;
|
|
88
|
+
|
|
78
89
|
if (this.cellHeader1.current && this.cellHeader2.current) {
|
|
79
90
|
this.cellHeader1.current.setActiveTab(idTab === 0);
|
|
80
91
|
this.cellHeader2.current.setActiveTab(idTab === 1);
|
|
@@ -122,12 +133,6 @@ class Calendar extends Component {
|
|
|
122
133
|
this.tabSelected,
|
|
123
134
|
);
|
|
124
135
|
if (onDateChange) {
|
|
125
|
-
// const cloned = {
|
|
126
|
-
// first: this.doubleDate.first ? this.doubleDate.first.toDate() : null,
|
|
127
|
-
// this.doubleDate.first ? new Date(this.doubleDate.first.year(), this.doubleDate.first.month(), this.doubleDate.first.date()) : null,
|
|
128
|
-
// second: this.doubleDate.second ? this.doubleDate.second.toDate() : null
|
|
129
|
-
// this.doubleDate.second ? new Date(this.doubleDate.second.year(), this.doubleDate.second.month(), this.doubleDate.second.date()) : null
|
|
130
|
-
// };
|
|
131
136
|
onDateChange({
|
|
132
137
|
first: this.doubleDate.first
|
|
133
138
|
? this.doubleDate.first.toDate()
|
|
@@ -157,11 +162,6 @@ class Calendar extends Component {
|
|
|
157
162
|
? this.doubleDate.second.toDate()
|
|
158
163
|
: null,
|
|
159
164
|
});
|
|
160
|
-
// const cloned = {
|
|
161
|
-
// first: this.doubleDate.first ? new Date(this.doubleDate.first.year(), this.doubleDate.first.month(), this.doubleDate.first.date()) : null,
|
|
162
|
-
// second: this.doubleDate.second ? new Date(this.doubleDate.second.year(), this.doubleDate.second.month(), this.doubleDate.second.date()) : null
|
|
163
|
-
// };
|
|
164
|
-
// onDateChange(cloned);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -178,9 +178,9 @@ class Calendar extends Component {
|
|
|
178
178
|
) {
|
|
179
179
|
this.doubleDate.second = this.selectedDate;
|
|
180
180
|
this.cellHeader2.current.updateView(this.selectedDate, false);
|
|
181
|
-
this.cellHeader1
|
|
181
|
+
this.cellHeader1?.current?.setActiveTab(true);
|
|
182
182
|
this.tabSelected = 0;
|
|
183
|
-
this.calendarPicker
|
|
183
|
+
this.calendarPicker?.current?.setDoubleDateAndTabIndex(
|
|
184
184
|
this.doubleDate.first,
|
|
185
185
|
this.doubleDate.second,
|
|
186
186
|
this.tabSelected,
|
|
@@ -195,18 +195,13 @@ class Calendar extends Component {
|
|
|
195
195
|
? this.doubleDate.second.toDate()
|
|
196
196
|
: null,
|
|
197
197
|
});
|
|
198
|
-
// const cloned = {
|
|
199
|
-
// first: this.doubleDate.first ? new Date(this.doubleDate.first.year(), this.doubleDate.first.month(), this.doubleDate.first.date()) : null,
|
|
200
|
-
// second: this.doubleDate.second ? new Date(this.doubleDate.second.year(), this.doubleDate.second.month(), this.doubleDate.second.date()) : null
|
|
201
|
-
// };
|
|
202
|
-
// onDateChange(cloned);
|
|
203
198
|
}
|
|
204
199
|
} else {
|
|
205
200
|
this.doubleDate.first = this.selectedDate;
|
|
206
201
|
this.doubleDate.second = null;
|
|
207
202
|
|
|
208
|
-
this.cellHeader1
|
|
209
|
-
this.cellHeader2
|
|
203
|
+
this.cellHeader1?.current?.updateView(this.selectedDate, false);
|
|
204
|
+
this.cellHeader2?.current?.updateView(null, false);
|
|
210
205
|
}
|
|
211
206
|
}
|
|
212
207
|
|
|
@@ -235,7 +230,7 @@ class Calendar extends Component {
|
|
|
235
230
|
}
|
|
236
231
|
}
|
|
237
232
|
|
|
238
|
-
onDateChange = date => {
|
|
233
|
+
onDateChange = (date: moment.Moment) => {
|
|
239
234
|
this.selectedDate = date;
|
|
240
235
|
this.updateView();
|
|
241
236
|
};
|
|
@@ -247,14 +242,22 @@ class Calendar extends Component {
|
|
|
247
242
|
if (this.cellHeader1.current && this.cellHeader2.current) {
|
|
248
243
|
this.cellHeader1.current.updateView(this.selectedDate, true);
|
|
249
244
|
this.cellHeader2.current.updateView(null, false);
|
|
250
|
-
this.calendarPicker.current
|
|
245
|
+
this.calendarPicker.current?.setDoubleDateAndTabIndex(
|
|
251
246
|
this.selectedDate,
|
|
252
247
|
null,
|
|
253
248
|
this.tabSelected,
|
|
254
249
|
);
|
|
255
250
|
this.doubleDate.first = moment(this.selectedDate);
|
|
256
251
|
this.doubleDate.second = null;
|
|
257
|
-
|
|
252
|
+
|
|
253
|
+
this.tabSelected = 1;
|
|
254
|
+
this.cellHeader2.current?.setActiveTab(true);
|
|
255
|
+
this.cellHeader1.current?.setActiveTab(false);
|
|
256
|
+
this.calendarPicker?.current?.setDoubleDateAndTabIndex(
|
|
257
|
+
this.doubleDate.first,
|
|
258
|
+
this.doubleDate.second,
|
|
259
|
+
this.tabSelected,
|
|
260
|
+
);
|
|
258
261
|
|
|
259
262
|
if (onCTAStateChange) {
|
|
260
263
|
onCTAStateChange(false);
|
|
@@ -268,11 +271,6 @@ class Calendar extends Component {
|
|
|
268
271
|
? this.doubleDate.second.toDate()
|
|
269
272
|
: null,
|
|
270
273
|
});
|
|
271
|
-
// const cloned = {
|
|
272
|
-
// first: this.doubleDate.first ? new Date(this.doubleDate.first.year(), this.doubleDate.first.month(), this.doubleDate.first.date()) : null,
|
|
273
|
-
// second: this.doubleDate.second ? new Date(this.doubleDate.second.year(), this.doubleDate.second.month(), this.doubleDate.second.date()) : null
|
|
274
|
-
// };
|
|
275
|
-
// onDateChange(cloned);
|
|
276
274
|
}
|
|
277
275
|
}
|
|
278
276
|
} else {
|
|
@@ -286,10 +284,7 @@ class Calendar extends Component {
|
|
|
286
284
|
} else {
|
|
287
285
|
this.cellHeaderSingle.current.updateView(this.selectedDate, true);
|
|
288
286
|
}
|
|
289
|
-
|
|
290
287
|
if (onDateChange) {
|
|
291
|
-
// const clone = moment(this.selectedDate);
|
|
292
|
-
// const cloned = new Date(clone.year(), clone.month(), clone.date());
|
|
293
288
|
onDateChange(this.selectedDate.toDate());
|
|
294
289
|
}
|
|
295
290
|
}
|
|
@@ -312,57 +307,64 @@ class Calendar extends Component {
|
|
|
312
307
|
|
|
313
308
|
renderSwitchReturnSelection = () => {
|
|
314
309
|
const {isDoubleDateMode} = this.state;
|
|
310
|
+
const {translate, theme} = this.context;
|
|
315
311
|
return (
|
|
316
312
|
<View style={styles.headerContainer}>
|
|
317
|
-
<View
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
313
|
+
<View
|
|
314
|
+
style={[
|
|
315
|
+
styles.viewSwitch,
|
|
316
|
+
{backgroundColor: theme.colors.background.surface},
|
|
317
|
+
]}>
|
|
318
|
+
<Text typography={'label_default_medium'}>
|
|
319
|
+
{translate('chooseRoundtrip')}
|
|
320
|
+
</Text>
|
|
321
321
|
<Switch
|
|
322
322
|
value={isDoubleDateMode}
|
|
323
323
|
onChange={this.toggleSelectionDateMode}
|
|
324
|
-
thumbColor={isDoubleDateMode ? '#78ca32' : 'white'}
|
|
325
|
-
trackColor={{
|
|
326
|
-
false: '#e5e7ec',
|
|
327
|
-
true: '#e5e7ec',
|
|
328
|
-
}}
|
|
329
324
|
/>
|
|
330
325
|
</View>
|
|
331
|
-
<View style={styles.seperator} />
|
|
332
326
|
</View>
|
|
333
327
|
);
|
|
334
328
|
};
|
|
335
329
|
|
|
336
|
-
renderHeaderPanel = () => {
|
|
330
|
+
renderHeaderPanel = (theme: {colors: {background: {default: string}}}) => {
|
|
337
331
|
const {isDoubleDateMode} = this.state;
|
|
338
332
|
const {headerFrom, headerTo} = this.props;
|
|
339
333
|
return isDoubleDateMode ? (
|
|
340
|
-
<View
|
|
334
|
+
<View
|
|
335
|
+
style={[
|
|
336
|
+
styles.viewPanel,
|
|
337
|
+
{backgroundColor: theme.colors.background.default},
|
|
338
|
+
]}>
|
|
341
339
|
<TabHeader
|
|
342
340
|
id={0}
|
|
343
341
|
ref={this.cellHeader1}
|
|
344
342
|
onChangeTab={this.onChangeTab}
|
|
345
|
-
label={headerFrom ||
|
|
343
|
+
label={headerFrom || 'depart'}
|
|
346
344
|
activeTab
|
|
347
345
|
date={this.doubleDate.first}
|
|
348
346
|
/>
|
|
349
|
-
|
|
347
|
+
<View style={{width: 4, height: '100%'}} />
|
|
350
348
|
<TabHeader
|
|
351
349
|
id={1}
|
|
352
350
|
ref={this.cellHeader2}
|
|
353
351
|
onChangeTab={this.onChangeTab}
|
|
354
|
-
label={headerTo ||
|
|
352
|
+
label={headerTo || 'return'}
|
|
355
353
|
activeTab={false}
|
|
356
354
|
date=""
|
|
357
355
|
/>
|
|
358
356
|
</View>
|
|
359
357
|
) : (
|
|
360
|
-
<View
|
|
358
|
+
<View
|
|
359
|
+
style={[
|
|
360
|
+
styles.viewPanel,
|
|
361
|
+
{backgroundColor: theme.colors.background.default},
|
|
362
|
+
]}>
|
|
361
363
|
<TabHeader
|
|
362
|
-
id={
|
|
364
|
+
id={0}
|
|
363
365
|
disabled
|
|
364
366
|
ref={this.cellHeaderSingle}
|
|
365
|
-
label={headerFrom ||
|
|
367
|
+
label={headerFrom || 'depart'}
|
|
366
368
|
activeTab
|
|
367
369
|
date={this.selectedDate}
|
|
368
370
|
/>
|
|
@@ -370,14 +372,20 @@ class Calendar extends Component {
|
|
|
370
372
|
);
|
|
371
373
|
};
|
|
372
374
|
|
|
373
|
-
setDateRange = (
|
|
375
|
+
setDateRange = (
|
|
376
|
+
dateRange: {
|
|
377
|
+
startDate: moment.Moment | undefined;
|
|
378
|
+
endDate: moment.Moment | undefined;
|
|
379
|
+
},
|
|
380
|
+
isScrollToStartDate: any,
|
|
381
|
+
) => {
|
|
374
382
|
const {mode, doubleDate = {}} = this.props;
|
|
375
383
|
if (mode === 'doubleDate') {
|
|
376
|
-
this.cellHeader1
|
|
384
|
+
this.cellHeader1?.current?.updateView(
|
|
377
385
|
dateRange.startDate,
|
|
378
386
|
this.tabSelected === 0,
|
|
379
387
|
);
|
|
380
|
-
this.cellHeader2
|
|
388
|
+
this.cellHeader2?.current?.updateView(
|
|
381
389
|
dateRange.endDate,
|
|
382
390
|
this.tabSelected === 1,
|
|
383
391
|
);
|
|
@@ -394,134 +402,77 @@ class Calendar extends Component {
|
|
|
394
402
|
}
|
|
395
403
|
};
|
|
396
404
|
|
|
405
|
+
onLayout = (e: LayoutChangeEvent) => {
|
|
406
|
+
this.setState({containerWidth: e.nativeEvent.layout.width});
|
|
407
|
+
};
|
|
408
|
+
|
|
397
409
|
render() {
|
|
410
|
+
const currentDate = new Date();
|
|
411
|
+
const minDateDefault = new Date(currentDate);
|
|
412
|
+
const maxDateDefault = new Date(currentDate);
|
|
413
|
+
minDateDefault.setFullYear(minDateDefault.getFullYear() - 1);
|
|
414
|
+
maxDateDefault.setFullYear(maxDateDefault.getFullYear() + 1);
|
|
415
|
+
|
|
398
416
|
const {
|
|
399
417
|
isOffLunar,
|
|
400
418
|
isHideHoliday,
|
|
401
|
-
isHiddenSwitch,
|
|
402
419
|
isShowLunar,
|
|
403
420
|
onCallbackCalendar,
|
|
404
421
|
priceList,
|
|
405
422
|
labelFrom,
|
|
406
423
|
labelTo,
|
|
407
424
|
isHideLabel,
|
|
408
|
-
minDate,
|
|
409
|
-
maxDate,
|
|
425
|
+
minDate = minDateDefault,
|
|
426
|
+
maxDate = maxDateDefault,
|
|
410
427
|
doubleDate,
|
|
411
|
-
isHideHeaderPanel,
|
|
412
|
-
disabledWeekend,
|
|
413
428
|
style,
|
|
429
|
+
disabledDays = [],
|
|
430
|
+
hideHeaderTab = false,
|
|
414
431
|
} = this.props;
|
|
415
|
-
const {isDoubleDateMode} = this.state;
|
|
416
|
-
const {
|
|
432
|
+
const {isDoubleDateMode, containerWidth} = this.state;
|
|
433
|
+
const {theme} = this.context;
|
|
417
434
|
return (
|
|
418
|
-
<
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
435
|
+
<ContainerContext.Provider
|
|
436
|
+
value={{
|
|
437
|
+
width: containerWidth,
|
|
438
|
+
height: priceList ? scaleSize(48) : scaleSize(34),
|
|
439
|
+
}}>
|
|
440
|
+
<View onLayout={this.onLayout} style={[style, styles.scrollView]}>
|
|
441
|
+
<View
|
|
442
|
+
style={[
|
|
443
|
+
{
|
|
444
|
+
backgroundColor: theme.colors.background.surface,
|
|
445
|
+
borderRadius: Radius.XS,
|
|
446
|
+
marginBottom: Spacing.S,
|
|
447
|
+
},
|
|
448
|
+
hideHeaderTab && styles.invisible,
|
|
449
|
+
]}>
|
|
450
|
+
{this.renderSwitchReturnSelection()}
|
|
451
|
+
{this.renderHeaderPanel(theme)}
|
|
452
|
+
</View>
|
|
453
|
+
<CalendarPro
|
|
454
|
+
priceList={priceList}
|
|
455
|
+
ref={this.calendarPicker}
|
|
456
|
+
startDate={doubleDate?.first}
|
|
457
|
+
endDate={doubleDate?.second}
|
|
458
|
+
onDateChange={this.onDateChange}
|
|
459
|
+
isDoubleDateMode={isDoubleDateMode}
|
|
460
|
+
selectedDate={this.selectedDate}
|
|
461
|
+
isShowLunar={isShowLunar}
|
|
462
|
+
onCallbackCalendar={onCallbackCalendar}
|
|
463
|
+
labelFrom={labelFrom}
|
|
464
|
+
labelTo={labelTo}
|
|
465
|
+
isHideLabel={isHideLabel}
|
|
466
|
+
minDate={minDate}
|
|
467
|
+
maxDate={maxDate}
|
|
468
|
+
isHideHoliday={isHideHoliday}
|
|
469
|
+
isOffLunar={isOffLunar}
|
|
470
|
+
disabledDays={disabledDays}
|
|
471
|
+
/>
|
|
433
472
|
</View>
|
|
434
|
-
|
|
435
|
-
disabledWeekend={disabledWeekend}
|
|
436
|
-
priceList={priceList}
|
|
437
|
-
ref={this.calendarPicker}
|
|
438
|
-
startDate={doubleDate?.first}
|
|
439
|
-
endDate={doubleDate?.second}
|
|
440
|
-
onDateChange={this.onDateChange}
|
|
441
|
-
isDoubleDateMode={isDoubleDateMode}
|
|
442
|
-
selectedDate={this.selectedDate}
|
|
443
|
-
isShowLunar={isShowLunar}
|
|
444
|
-
onCallbackCalendar={onCallbackCalendar}
|
|
445
|
-
labelFrom={labelFrom}
|
|
446
|
-
labelTo={labelTo}
|
|
447
|
-
isHideLabel={isHideLabel}
|
|
448
|
-
minDate={minDate}
|
|
449
|
-
maxDate={maxDate}
|
|
450
|
-
isHideHoliday={isHideHoliday}
|
|
451
|
-
isOffLunar={isOffLunar}
|
|
452
|
-
/>
|
|
453
|
-
</ScrollView>
|
|
473
|
+
</ContainerContext.Provider>
|
|
454
474
|
);
|
|
455
475
|
}
|
|
456
476
|
}
|
|
457
477
|
|
|
458
|
-
export
|
|
459
|
-
|
|
460
|
-
Calendar.propTypes = {
|
|
461
|
-
doubleDate: PropTypes.shape({
|
|
462
|
-
first: PropTypes.any,
|
|
463
|
-
second: PropTypes.any,
|
|
464
|
-
}),
|
|
465
|
-
id: PropTypes.any,
|
|
466
|
-
isHiddenSwitch: PropTypes.bool,
|
|
467
|
-
isShowLunar: PropTypes.bool,
|
|
468
|
-
mode: PropTypes.string,
|
|
469
|
-
onCTAStateChange: PropTypes.func,
|
|
470
|
-
onCallbackCalendar: PropTypes.func,
|
|
471
|
-
onDateChange: PropTypes.func,
|
|
472
|
-
selectedDate: PropTypes.any,
|
|
473
|
-
priceList: PropTypes.any,
|
|
474
|
-
labelFrom: PropTypes.string,
|
|
475
|
-
labelTo: PropTypes.string,
|
|
476
|
-
headerFrom: PropTypes.string,
|
|
477
|
-
headerTo: PropTypes.string,
|
|
478
|
-
isHideLabel: PropTypes.bool,
|
|
479
|
-
isHideHoliday: PropTypes.bool,
|
|
480
|
-
minDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
481
|
-
maxDate: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
482
|
-
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
Calendar.defaultProps = {
|
|
486
|
-
mode: 'single',
|
|
487
|
-
isHiddenSwitch: false,
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
const styles = StyleSheet.create({
|
|
491
|
-
viewPanel_2: {
|
|
492
|
-
height: 50,
|
|
493
|
-
marginHorizontal: 12,
|
|
494
|
-
marginTop: 6,
|
|
495
|
-
flexDirection: 'row',
|
|
496
|
-
},
|
|
497
|
-
viewPanel: {
|
|
498
|
-
height: 50,
|
|
499
|
-
marginHorizontal: 12,
|
|
500
|
-
marginTop: 6,
|
|
501
|
-
flexDirection: 'row',
|
|
502
|
-
},
|
|
503
|
-
textSwitch: {
|
|
504
|
-
color: Colors.black_15,
|
|
505
|
-
},
|
|
506
|
-
viewSwitch: {
|
|
507
|
-
flexDirection: 'row',
|
|
508
|
-
justifyContent: 'space-between',
|
|
509
|
-
alignItems: 'center',
|
|
510
|
-
backgroundColor: Colors.white,
|
|
511
|
-
height: 42,
|
|
512
|
-
},
|
|
513
|
-
seperator: {
|
|
514
|
-
height: 1,
|
|
515
|
-
width: '100%',
|
|
516
|
-
backgroundColor: Colors.black_04,
|
|
517
|
-
},
|
|
518
|
-
headerContainer: {
|
|
519
|
-
paddingHorizontal: 12,
|
|
520
|
-
paddingVertical: 8,
|
|
521
|
-
},
|
|
522
|
-
scrollView: {
|
|
523
|
-
flex: 1,
|
|
524
|
-
backgroundColor: 'transparent',
|
|
525
|
-
alignSelf: 'center',
|
|
526
|
-
},
|
|
527
|
-
});
|
|
478
|
+
export {Calendar};
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/calendar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.2-react-native.1",
|
|
4
4
|
"private": false,
|
|
5
|
-
"main": "index.
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@momo-kits/date-picker": "latest",
|
|
8
|
-
"moment": "^2.24.0",
|
|
9
|
-
"@momo-platform/versions": "4.0.2"
|
|
10
|
-
},
|
|
5
|
+
"main": "index.tsx",
|
|
11
6
|
"peerDependencies": {
|
|
12
|
-
"
|
|
13
|
-
"react
|
|
14
|
-
"
|
|
15
|
-
"
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react": "*",
|
|
9
|
+
"react-native": "*",
|
|
10
|
+
"prop-types": "15.7.2"
|
|
16
11
|
},
|
|
17
|
-
"devDependencies": {
|
|
18
|
-
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@momo-platform/versions": "4.1.11"
|
|
14
|
+
},
|
|
15
|
+
"license": "MoMo",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"moment": "^2.24.0"
|
|
18
|
+
}
|
|
19
19
|
}
|
package/styles.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Colors, Radius, Spacing} from '@momo-kits/foundation';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
//calendar
|
|
6
|
+
viewPanel: {
|
|
7
|
+
flexDirection: 'row',
|
|
8
|
+
marginHorizontal: Spacing.M,
|
|
9
|
+
marginVertical: Spacing.S,
|
|
10
|
+
borderRadius: Radius.S,
|
|
11
|
+
padding: Spacing.XXS,
|
|
12
|
+
},
|
|
13
|
+
viewSwitch: {
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
justifyContent: 'space-between',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
marginBottom: Spacing.XS,
|
|
18
|
+
},
|
|
19
|
+
headerContainer: {
|
|
20
|
+
paddingHorizontal: Spacing.M,
|
|
21
|
+
marginTop: Spacing.S,
|
|
22
|
+
},
|
|
23
|
+
scrollView: {
|
|
24
|
+
backgroundColor: 'transparent',
|
|
25
|
+
alignSelf: 'center',
|
|
26
|
+
width: '100%',
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
//calendar pro
|
|
30
|
+
row: {flexDirection: 'row'},
|
|
31
|
+
txtMonthLunar: {
|
|
32
|
+
marginRight: Spacing.S,
|
|
33
|
+
},
|
|
34
|
+
subTextLunar: {
|
|
35
|
+
marginRight: Spacing.XS,
|
|
36
|
+
},
|
|
37
|
+
contentScroll: {
|
|
38
|
+
paddingHorizontal: Spacing.M,
|
|
39
|
+
paddingTop: Spacing.S,
|
|
40
|
+
paddingBottom: Spacing.M,
|
|
41
|
+
},
|
|
42
|
+
viewLunar: {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
marginHorizontal: Spacing.M,
|
|
46
|
+
borderTopWidth: 1,
|
|
47
|
+
paddingVertical: Spacing.S,
|
|
48
|
+
},
|
|
49
|
+
textDay: {
|
|
50
|
+
textAlign: 'center',
|
|
51
|
+
},
|
|
52
|
+
viewDay: {
|
|
53
|
+
flexDirection: 'row',
|
|
54
|
+
justifyContent: 'space-between',
|
|
55
|
+
paddingHorizontal: Spacing.S,
|
|
56
|
+
paddingVertical: Spacing.S,
|
|
57
|
+
marginTop: Spacing.S,
|
|
58
|
+
},
|
|
59
|
+
container: {
|
|
60
|
+
backgroundColor: 'white',
|
|
61
|
+
borderRadius: Radius.XS,
|
|
62
|
+
},
|
|
63
|
+
blueSeperator: {
|
|
64
|
+
height: 1,
|
|
65
|
+
width: '100%',
|
|
66
|
+
backgroundColor: Colors.blue_05,
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
//headerControl
|
|
70
|
+
txtHeader: {
|
|
71
|
+
textAlign: 'center',
|
|
72
|
+
},
|
|
73
|
+
btnRight: {
|
|
74
|
+
width: 36,
|
|
75
|
+
height: 36,
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
},
|
|
79
|
+
btnLeft: {
|
|
80
|
+
width: 36,
|
|
81
|
+
height: 36,
|
|
82
|
+
justifyContent: 'center',
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
},
|
|
85
|
+
headerControlContainer: {
|
|
86
|
+
flexDirection: 'row',
|
|
87
|
+
justifyContent: 'space-between',
|
|
88
|
+
backgroundColor: Colors.blue_10,
|
|
89
|
+
alignItems: 'center',
|
|
90
|
+
borderRadius: Radius.XS,
|
|
91
|
+
padding: Spacing.S,
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
//day
|
|
95
|
+
dayContainer: {
|
|
96
|
+
borderRadius: Radius.XS,
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
},
|
|
99
|
+
day: {
|
|
100
|
+
justifyContent: 'center',
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
borderRadius: Radius.XS,
|
|
103
|
+
},
|
|
104
|
+
dayText: {
|
|
105
|
+
textAlign: 'center',
|
|
106
|
+
},
|
|
107
|
+
dayStartContainer: {
|
|
108
|
+
borderTopLeftRadius: Radius.XS,
|
|
109
|
+
borderBottomLeftRadius: Radius.XS,
|
|
110
|
+
},
|
|
111
|
+
dayEndContainer: {
|
|
112
|
+
borderTopRightRadius: Radius.XS,
|
|
113
|
+
borderBottomRightRadius: Radius.XS,
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
invisible: {
|
|
117
|
+
height: 0,
|
|
118
|
+
width: 0,
|
|
119
|
+
padding: 0,
|
|
120
|
+
marginBottom: 0,
|
|
121
|
+
overflow: 'hidden',
|
|
122
|
+
},
|
|
123
|
+
});
|