@momo-kits/calendar 0.79.6 → 0.80.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/CalendarPro.tsx +386 -0
- package/Day.tsx +242 -0
- package/HeaderControl.tsx +53 -0
- package/Month.tsx +114 -0
- package/{src/MonthList.tsx → MonthList.tsx} +96 -65
- package/{src/TabHeader.tsx → TabHeader.tsx} +30 -12
- package/index.tsx +481 -2
- package/package.json +1 -1
- package/styles.ts +115 -0
- package/types.ts +155 -27
- package/src/Calendar.tsx +0 -488
- package/src/CalendarPro.tsx +0 -436
- package/src/Day/index.tsx +0 -248
- package/src/Day/style.ts +0 -113
- package/src/HeaderControl.tsx +0 -69
- package/src/Month/index.tsx +0 -88
- package/src/Month/style.ts +0 -0
- /package/{src/LunarDateConverter.ts → LunarDateConverter.ts} +0 -0
- /package/{src/LunarService.ts → LunarService.ts} +0 -0
- /package/{src/Util.ts → Util.ts} +0 -0
- /package/{src/holidayData.ts → holidayData.ts} +0 -0
package/src/Day/style.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import {Dimensions, StyleSheet} from 'react-native';
|
|
2
|
-
import {Spacing, Colors, scaleSize} from '@momo-kits/foundation';
|
|
3
|
-
|
|
4
|
-
const dayWidth = (Dimensions.get('window').width - 38) / 7;
|
|
5
|
-
const SCREEN_WIDTH = Dimensions.get('window').width;
|
|
6
|
-
const SCREEN_DPI_WIDTH = SCREEN_WIDTH * Dimensions.get('window').scale;
|
|
7
|
-
const IPHONE_4_5_WIDTH = 640;
|
|
8
|
-
const dayTextSize = SCREEN_DPI_WIDTH === IPHONE_4_5_WIDTH ? 13 : 15;
|
|
9
|
-
const lunarTextSize = SCREEN_DPI_WIDTH === IPHONE_4_5_WIDTH ? 8 : 10;
|
|
10
|
-
const priceTextSize = SCREEN_DPI_WIDTH === IPHONE_4_5_WIDTH ? 8 : 10;
|
|
11
|
-
const lineHeightDayText = 1.3 * dayTextSize;
|
|
12
|
-
const lineHeightLunarText = 1.3 * lunarTextSize;
|
|
13
|
-
const lineHeightPriceText = 1.3 * priceTextSize;
|
|
14
|
-
const containerDayHeight =
|
|
15
|
-
lineHeightDayText + lineHeightLunarText + lineHeightPriceText + 10;
|
|
16
|
-
const heightDefault = lineHeightDayText + lineHeightLunarText;
|
|
17
|
-
export default StyleSheet.create({
|
|
18
|
-
dayContainer: {
|
|
19
|
-
borderRadius: 4,
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
height: scaleSize(48),
|
|
22
|
-
},
|
|
23
|
-
day: {
|
|
24
|
-
justifyContent: 'center',
|
|
25
|
-
alignItems: 'center',
|
|
26
|
-
borderRadius: 4,
|
|
27
|
-
},
|
|
28
|
-
dayText: {
|
|
29
|
-
textAlign: 'center',
|
|
30
|
-
},
|
|
31
|
-
lunarDayText: {
|
|
32
|
-
width: dayWidth,
|
|
33
|
-
textAlign: 'right',
|
|
34
|
-
paddingRight: Spacing.XS,
|
|
35
|
-
position: 'absolute',
|
|
36
|
-
top: Spacing.XXS,
|
|
37
|
-
},
|
|
38
|
-
todayText: {
|
|
39
|
-
color: 'blue',
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
focused: {
|
|
43
|
-
backgroundColor: Colors.pink_03,
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
dayStartContainer: {
|
|
47
|
-
borderTopLeftRadius: 4,
|
|
48
|
-
borderBottomLeftRadius: 4,
|
|
49
|
-
backgroundColor: Colors.pink_03,
|
|
50
|
-
},
|
|
51
|
-
dayEndContainer: {
|
|
52
|
-
borderTopRightRadius: 4,
|
|
53
|
-
borderBottomRightRadius: 4,
|
|
54
|
-
backgroundColor: Colors.pink_03,
|
|
55
|
-
},
|
|
56
|
-
mid: {
|
|
57
|
-
backgroundColor: Colors.pink_09,
|
|
58
|
-
// height: heightDefault
|
|
59
|
-
},
|
|
60
|
-
departLabel: {
|
|
61
|
-
position: 'absolute',
|
|
62
|
-
backgroundColor: 'yellow',
|
|
63
|
-
width: 20,
|
|
64
|
-
height: 20,
|
|
65
|
-
borderRadius: 10,
|
|
66
|
-
justifyContent: 'center',
|
|
67
|
-
alignItems: 'center',
|
|
68
|
-
},
|
|
69
|
-
returnLabel: {
|
|
70
|
-
position: 'absolute',
|
|
71
|
-
backgroundColor: 'yellow',
|
|
72
|
-
width: 20,
|
|
73
|
-
height: 20,
|
|
74
|
-
borderRadius: 10,
|
|
75
|
-
justifyContent: 'center',
|
|
76
|
-
alignItems: 'center',
|
|
77
|
-
top: 0,
|
|
78
|
-
right: 0,
|
|
79
|
-
},
|
|
80
|
-
containerDayHeight,
|
|
81
|
-
txtBack: {
|
|
82
|
-
position: 'absolute',
|
|
83
|
-
backgroundColor: '#ffbb1e',
|
|
84
|
-
borderRadius: 100,
|
|
85
|
-
top: -2,
|
|
86
|
-
right: -2,
|
|
87
|
-
zIndex: 999,
|
|
88
|
-
padding: 2,
|
|
89
|
-
width: 15,
|
|
90
|
-
height: 15,
|
|
91
|
-
justifyContent: 'center',
|
|
92
|
-
alignItems: 'center',
|
|
93
|
-
},
|
|
94
|
-
txtGo: {
|
|
95
|
-
position: 'absolute',
|
|
96
|
-
backgroundColor: '#ffbb1e',
|
|
97
|
-
top: -2,
|
|
98
|
-
left: -2,
|
|
99
|
-
borderRadius: 100,
|
|
100
|
-
padding: 2,
|
|
101
|
-
zIndex: 999,
|
|
102
|
-
width: 15,
|
|
103
|
-
height: 15,
|
|
104
|
-
justifyContent: 'center',
|
|
105
|
-
alignItems: 'center',
|
|
106
|
-
},
|
|
107
|
-
price: {
|
|
108
|
-
color: Colors.black_15,
|
|
109
|
-
marginTop: -4,
|
|
110
|
-
lineHeight: 14,
|
|
111
|
-
},
|
|
112
|
-
lineHeightPriceText,
|
|
113
|
-
});
|
package/src/HeaderControl.tsx
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React, {forwardRef, useImperativeHandle, useState} from 'react';
|
|
2
|
-
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
|
-
import moment from 'moment';
|
|
4
|
-
import {Colors, Icon, scaleSize, Text} from '@momo-kits/foundation';
|
|
5
|
-
|
|
6
|
-
import Util from './Util';
|
|
7
|
-
|
|
8
|
-
const HeaderControl = forwardRef(
|
|
9
|
-
({onPressBackArrow, onPressNextArrow, selectedDate}, ref) => {
|
|
10
|
-
const [info, setInfo] = useState({
|
|
11
|
-
date: moment(selectedDate || new Date()),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
useImperativeHandle(ref, () => ({
|
|
15
|
-
onUpdateInfo,
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
const onUpdateInfo = date => {
|
|
19
|
-
setInfo(date);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
if (info && info.date) {
|
|
23
|
-
const headerFormat = `${Util.mapMonth(
|
|
24
|
-
info.date.month() + 1,
|
|
25
|
-
)}/${info.date.year()}`;
|
|
26
|
-
return (
|
|
27
|
-
<View style={styles.container}>
|
|
28
|
-
<TouchableOpacity style={styles.btnLeft} onPress={onPressBackArrow}>
|
|
29
|
-
<Icon source="24_arrow_chevron_left_small" />
|
|
30
|
-
</TouchableOpacity>
|
|
31
|
-
<Text typography={'header_s'} style={styles.txtHeader}>
|
|
32
|
-
{headerFormat}
|
|
33
|
-
</Text>
|
|
34
|
-
<TouchableOpacity style={styles.btnRight} onPress={onPressNextArrow}>
|
|
35
|
-
<Icon source="24_arrow_chevron_right_small" />
|
|
36
|
-
</TouchableOpacity>
|
|
37
|
-
</View>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return <View />;
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
export default HeaderControl;
|
|
45
|
-
const styles = StyleSheet.create({
|
|
46
|
-
txtHeader: {
|
|
47
|
-
textAlign: 'center',
|
|
48
|
-
},
|
|
49
|
-
btnRight: {
|
|
50
|
-
width: 36,
|
|
51
|
-
height: 36,
|
|
52
|
-
justifyContent: 'center',
|
|
53
|
-
alignItems: 'center',
|
|
54
|
-
},
|
|
55
|
-
btnLeft: {
|
|
56
|
-
width: 36,
|
|
57
|
-
height: 36,
|
|
58
|
-
justifyContent: 'center',
|
|
59
|
-
alignItems: 'center',
|
|
60
|
-
},
|
|
61
|
-
container: {
|
|
62
|
-
height: scaleSize(44),
|
|
63
|
-
flexDirection: 'row',
|
|
64
|
-
justifyContent: 'space-between',
|
|
65
|
-
backgroundColor: Colors.blue_10,
|
|
66
|
-
alignItems: 'center',
|
|
67
|
-
borderRadius: 4,
|
|
68
|
-
},
|
|
69
|
-
});
|
package/src/Month/index.tsx
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, {PureComponent} from 'react';
|
|
2
|
-
|
|
3
|
-
import {View, Dimensions} from 'react-native';
|
|
4
|
-
import moment from 'moment';
|
|
5
|
-
import Day from '../Day';
|
|
6
|
-
import {Spacing, scaleSize} from '@momo-kits/foundation';
|
|
7
|
-
|
|
8
|
-
export default class Month extends PureComponent {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
super(props);
|
|
11
|
-
const {dateList} = props;
|
|
12
|
-
this.rowArray = new Array(dateList.length / 7).fill('');
|
|
13
|
-
this.temp = this.rowArray.map((item, i) =>
|
|
14
|
-
dateList.slice(i * 7, i * 7 + 7),
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
findHoliday = date => {
|
|
19
|
-
const {holidays} = this.props;
|
|
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
|
-
};
|
|
27
|
-
|
|
28
|
-
checkHoliday = date => {
|
|
29
|
-
const holiday = this.findHoliday(date);
|
|
30
|
-
return {
|
|
31
|
-
isSolarHoliday: !!(holiday && !holiday.lunar),
|
|
32
|
-
isLunarHoliday: !!(holiday && holiday.lunar),
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
renderDayRow = (dayList, index, disabledWeekend) => (
|
|
37
|
-
<View
|
|
38
|
-
style={{
|
|
39
|
-
flexDirection: 'row',
|
|
40
|
-
justifyContent: 'space-between',
|
|
41
|
-
}}
|
|
42
|
-
key={`row${index}`}>
|
|
43
|
-
{dayList.map((item, i) => {
|
|
44
|
-
const keyDay = moment(item.date).format('YYYY-MM-DD');
|
|
45
|
-
const priceInfo = this.props?.priceListDate?.[keyDay];
|
|
46
|
-
const itemWidth = (this.props.containerWidth - Spacing.M) / 7;
|
|
47
|
-
return (
|
|
48
|
-
<Day
|
|
49
|
-
{...this.props}
|
|
50
|
-
{...this.checkHoliday(item.date)}
|
|
51
|
-
disabledWeekend={disabledWeekend}
|
|
52
|
-
date={item.date}
|
|
53
|
-
havePriceList={!!this.props.priceListDate}
|
|
54
|
-
lunarDate={item.lunarDate}
|
|
55
|
-
empty={item.empty}
|
|
56
|
-
key={`day${i.toString()}`}
|
|
57
|
-
index={i}
|
|
58
|
-
price={priceInfo?.priceAsString}
|
|
59
|
-
isBestPrice={priceInfo?.isBestPrice}
|
|
60
|
-
width={itemWidth}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
})}
|
|
64
|
-
</View>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
render() {
|
|
68
|
-
const {month, disabledWeekend} = this.props;
|
|
69
|
-
|
|
70
|
-
if (month) {
|
|
71
|
-
return (
|
|
72
|
-
<View>
|
|
73
|
-
<View
|
|
74
|
-
style={{
|
|
75
|
-
paddingHorizontal: Spacing.S,
|
|
76
|
-
paddingVertical: 5,
|
|
77
|
-
width: '100%',
|
|
78
|
-
}}>
|
|
79
|
-
{this.temp.map((item, i) =>
|
|
80
|
-
this.renderDayRow(item, i, disabledWeekend),
|
|
81
|
-
)}
|
|
82
|
-
</View>
|
|
83
|
-
</View>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
return <View />;
|
|
87
|
-
}
|
|
88
|
-
}
|
package/src/Month/style.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{src/Util.ts → Util.ts}
RENAMED
|
File without changes
|
|
File without changes
|