@momo-kits/calendar 0.150.2-phuc.13 → 0.150.3-beta.40
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 +25 -20
- package/Day.tsx +21 -18
- package/MonthList.tsx +30 -24
- package/holidayData.ts +0 -7
- package/index.tsx +2 -0
- package/package.json +20 -20
- package/types.ts +17 -8
package/CalendarPro.tsx
CHANGED
|
@@ -7,8 +7,8 @@ import React, {
|
|
|
7
7
|
forwardRef,
|
|
8
8
|
useImperativeHandle,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import {ScrollView, View} from 'react-native';
|
|
11
|
-
import moment, {Moment} from 'moment';
|
|
10
|
+
import { ScrollView, View } from 'react-native';
|
|
11
|
+
import moment, { Moment } from 'moment';
|
|
12
12
|
import {
|
|
13
13
|
ApplicationContext,
|
|
14
14
|
CheckBox,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
MonthListRef,
|
|
28
28
|
Holidays,
|
|
29
29
|
} from './types';
|
|
30
|
-
import {ContainerContext} from './index';
|
|
30
|
+
import { ContainerContext } from './index';
|
|
31
31
|
import styles from './styles';
|
|
32
32
|
|
|
33
33
|
const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
@@ -46,10 +46,11 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
46
46
|
isOffLunar,
|
|
47
47
|
onCallbackCalendar,
|
|
48
48
|
disabledDays,
|
|
49
|
+
bestPriceColor,
|
|
49
50
|
},
|
|
50
|
-
ref
|
|
51
|
+
ref,
|
|
51
52
|
) => {
|
|
52
|
-
const {theme, translate} = useContext(ApplicationContext);
|
|
53
|
+
const { theme, translate } = useContext(ApplicationContext);
|
|
53
54
|
const size = useContext(ContainerContext);
|
|
54
55
|
|
|
55
56
|
const today = useMemo(() => moment(), []);
|
|
@@ -90,15 +91,13 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
90
91
|
setDoubleDateAndTabIndex: (
|
|
91
92
|
firstDate?: Moment | null,
|
|
92
93
|
secondDate?: Moment | null,
|
|
93
|
-
tabIdx?: number
|
|
94
|
+
tabIdx?: number,
|
|
94
95
|
) => {
|
|
95
96
|
if (typeof tabIdx === 'number') setTabSelected(tabIdx);
|
|
96
97
|
if (firstDate) setStartDate(firstDate);
|
|
97
98
|
if (secondDate !== undefined) setEndDate(secondDate);
|
|
98
99
|
},
|
|
99
|
-
setDateRange: (
|
|
100
|
-
dateRange: {startDate: any; endDate: any},
|
|
101
|
-
) => {
|
|
100
|
+
setDateRange: (dateRange: { startDate: any; endDate: any }) => {
|
|
102
101
|
if (monthListRef.current && dateRange.startDate) {
|
|
103
102
|
monthListRef.current.scrollToMonth(moment(dateRange.startDate));
|
|
104
103
|
}
|
|
@@ -148,7 +147,7 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
148
147
|
const filtered = showLunar
|
|
149
148
|
? allHolidays
|
|
150
149
|
: allHolidays.filter(item => !item.lunar || item.mixedLabel);
|
|
151
|
-
headerControlRef.current?.onUpdateInfo({date});
|
|
150
|
+
headerControlRef.current?.onUpdateInfo({ date });
|
|
152
151
|
headerRef.current = date.clone().startOf('month');
|
|
153
152
|
setHolidays(allHolidays);
|
|
154
153
|
setTemp(filtered);
|
|
@@ -183,7 +182,7 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
183
182
|
.subtract(1, 'months');
|
|
184
183
|
if (prev.isSameOrAfter(minDate, 'month')) {
|
|
185
184
|
headerRef.current = prev;
|
|
186
|
-
headerControlRef.current?.onUpdateInfo({date: prev});
|
|
185
|
+
headerControlRef.current?.onUpdateInfo({ date: prev });
|
|
187
186
|
monthListRef.current?.scrollToMonth(prev);
|
|
188
187
|
}
|
|
189
188
|
};
|
|
@@ -192,7 +191,7 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
192
191
|
const next = headerRef.current.clone().startOf('month').add(1, 'months');
|
|
193
192
|
if (next.isSameOrBefore(maxDate, 'month')) {
|
|
194
193
|
headerRef.current = next;
|
|
195
|
-
headerControlRef.current?.onUpdateInfo({date: next});
|
|
194
|
+
headerControlRef.current?.onUpdateInfo({ date: next });
|
|
196
195
|
monthListRef.current?.scrollToMonth(next);
|
|
197
196
|
}
|
|
198
197
|
};
|
|
@@ -222,8 +221,9 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
222
221
|
typography="label_s_medium"
|
|
223
222
|
style={[
|
|
224
223
|
styles.textDay,
|
|
225
|
-
{width: (size.width - Spacing.M * 2) / 7},
|
|
226
|
-
]}
|
|
224
|
+
{ width: (size.width - Spacing.M * 2) / 7 },
|
|
225
|
+
]}
|
|
226
|
+
>
|
|
227
227
|
{translate?.(Util.mapWeeKDate(dayIdx))}
|
|
228
228
|
</Text>
|
|
229
229
|
))}
|
|
@@ -245,14 +245,16 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
245
245
|
selectedDate={propSelectedDate}
|
|
246
246
|
priceList={priceListFormat}
|
|
247
247
|
disabledDays={disabledDays}
|
|
248
|
+
bestPriceColor={bestPriceColor}
|
|
248
249
|
/>
|
|
249
250
|
</View>
|
|
250
251
|
{!isOffLunar && (
|
|
251
252
|
<View
|
|
252
253
|
style={[
|
|
253
254
|
styles.viewLunar,
|
|
254
|
-
{borderColor: theme.colors.border.default},
|
|
255
|
-
]}
|
|
255
|
+
{ borderColor: theme.colors.border.default },
|
|
256
|
+
]}
|
|
257
|
+
>
|
|
256
258
|
<CheckBox
|
|
257
259
|
onChange={onToggleLunar}
|
|
258
260
|
value={showLunar}
|
|
@@ -264,7 +266,8 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
264
266
|
<ScrollView
|
|
265
267
|
contentContainerStyle={styles.contentScroll}
|
|
266
268
|
showsVerticalScrollIndicator={false}
|
|
267
|
-
nestedScrollEnabled
|
|
269
|
+
nestedScrollEnabled
|
|
270
|
+
>
|
|
268
271
|
{temp.map((item, idx) => {
|
|
269
272
|
const labelDate = `${item.day > 9 ? item.day : `0${item.day}`}/${
|
|
270
273
|
item.month > 9 ? item.month : `0${item.month}`
|
|
@@ -278,12 +281,14 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
278
281
|
<Text
|
|
279
282
|
color={theme.colors.error.primary}
|
|
280
283
|
typography="description_default_regular"
|
|
281
|
-
style={styles.txtMonthLunar}
|
|
284
|
+
style={styles.txtMonthLunar}
|
|
285
|
+
>
|
|
282
286
|
{labelDate}
|
|
283
287
|
</Text>
|
|
284
288
|
<Text
|
|
285
289
|
typography="description_default_regular"
|
|
286
|
-
style={styles.subTextLunar}
|
|
290
|
+
style={styles.subTextLunar}
|
|
291
|
+
>
|
|
287
292
|
{translate?.(labelHoliday)}
|
|
288
293
|
</Text>
|
|
289
294
|
<Text typography="description_default_regular">
|
|
@@ -296,7 +301,7 @@ const CalendarPro = forwardRef<CalendarProRef, CalendarProProps>(
|
|
|
296
301
|
)}
|
|
297
302
|
</View>
|
|
298
303
|
);
|
|
299
|
-
}
|
|
304
|
+
},
|
|
300
305
|
);
|
|
301
306
|
|
|
302
307
|
export default CalendarPro;
|
package/Day.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, {useContext} from 'react';
|
|
2
|
-
import {Text as RNText, TouchableOpacity, View} from 'react-native';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { Text as RNText, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import {
|
|
4
4
|
ApplicationContext,
|
|
5
5
|
Colors,
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
Spacing,
|
|
8
8
|
Text,
|
|
9
9
|
} from '@momo-kits/foundation';
|
|
10
|
-
import {DayProps} from './types';
|
|
11
|
-
import {ContainerContext} from './index';
|
|
10
|
+
import { DayProps } from './types';
|
|
11
|
+
import { ContainerContext } from './index';
|
|
12
12
|
import styles from './styles';
|
|
13
13
|
|
|
14
14
|
const Day: React.FC<DayProps> = props => {
|
|
@@ -30,14 +30,15 @@ const Day: React.FC<DayProps> = props => {
|
|
|
30
30
|
onChoose,
|
|
31
31
|
price,
|
|
32
32
|
isBestPrice,
|
|
33
|
+
bestPriceColor,
|
|
33
34
|
} = props;
|
|
34
35
|
|
|
35
|
-
const {theme} = useContext(ApplicationContext);
|
|
36
|
+
const { theme } = useContext(ApplicationContext);
|
|
36
37
|
const size = useContext(ContainerContext);
|
|
37
38
|
|
|
38
39
|
const itemWidth = (size.width - Spacing.M) / 7;
|
|
39
40
|
if (isEmpty || !date) {
|
|
40
|
-
return <View style={[styles.dayContainer, {width: itemWidth}]} />;
|
|
41
|
+
return <View style={[styles.dayContainer, { width: itemWidth }]} />;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
const isValid =
|
|
@@ -70,11 +71,10 @@ const Day: React.FC<DayProps> = props => {
|
|
|
70
71
|
|
|
71
72
|
if (isWeekEnd || isSolarHoliday || isLunarHoliday) {
|
|
72
73
|
textColor = theme.colors.error.primary;
|
|
73
|
-
priceColor = theme.colors.error.primary;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
if (isBestPrice) {
|
|
77
|
-
priceColor =
|
|
76
|
+
if (isBestPrice && bestPriceColor) {
|
|
77
|
+
priceColor = bestPriceColor;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
if (isStart || isEnd) {
|
|
@@ -90,13 +90,14 @@ const Day: React.FC<DayProps> = props => {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
return (
|
|
93
|
-
<View style={[styles.dayContainer, {width: itemWidth}]}>
|
|
93
|
+
<View style={[styles.dayContainer, { width: itemWidth }]}>
|
|
94
94
|
<View
|
|
95
95
|
style={[
|
|
96
|
-
isMid && {backgroundColor: theme.colors.background.tonal},
|
|
96
|
+
isMid && { backgroundColor: theme.colors.background.tonal },
|
|
97
97
|
isStartPart && styles.dayStartContainer,
|
|
98
98
|
isEnd && styles.dayEndContainer,
|
|
99
|
-
]}
|
|
99
|
+
]}
|
|
100
|
+
>
|
|
100
101
|
<TouchableOpacity
|
|
101
102
|
style={[
|
|
102
103
|
styles.day,
|
|
@@ -104,12 +105,13 @@ const Day: React.FC<DayProps> = props => {
|
|
|
104
105
|
width: itemWidth,
|
|
105
106
|
paddingVertical: !!price ? Spacing.XS : Spacing.S,
|
|
106
107
|
},
|
|
107
|
-
(isStart || isEnd) && {backgroundColor: theme.colors.primary},
|
|
108
|
-
!!price && {height: scaleSize(48)},
|
|
109
|
-
{height: size.height},
|
|
108
|
+
(isStart || isEnd) && { backgroundColor: theme.colors.primary },
|
|
109
|
+
!!price && { height: scaleSize(48) },
|
|
110
|
+
{ height: size.height },
|
|
110
111
|
]}
|
|
111
112
|
disabled={!(isValid && isInScope)}
|
|
112
|
-
onPress={chooseDay}
|
|
113
|
+
onPress={chooseDay}
|
|
114
|
+
>
|
|
113
115
|
{lunarDate && showLunar && !!date && (
|
|
114
116
|
<RNText
|
|
115
117
|
style={{
|
|
@@ -119,13 +121,14 @@ const Day: React.FC<DayProps> = props => {
|
|
|
119
121
|
color: lunarTextColor,
|
|
120
122
|
fontSize: scaleSize(8),
|
|
121
123
|
lineHeight: scaleSize(12),
|
|
122
|
-
}}
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
123
126
|
{lunarDate.lunarDay === 1
|
|
124
127
|
? `${lunarDate.lunarDay}/${lunarDate.lunarMonth}`
|
|
125
128
|
: lunarDate.lunarDay}
|
|
126
129
|
</RNText>
|
|
127
130
|
)}
|
|
128
|
-
<Text typography="
|
|
131
|
+
<Text typography="body_default_regular" color={textColor}>
|
|
129
132
|
{date ? date.date() : ''}
|
|
130
133
|
</Text>
|
|
131
134
|
{!!price && (
|
package/MonthList.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {scaleSize, Spacing} from '@momo-kits/foundation';
|
|
2
|
-
import moment, {Moment} from 'moment';
|
|
1
|
+
import { scaleSize, Spacing } from '@momo-kits/foundation';
|
|
2
|
+
import moment, { Moment } from 'moment';
|
|
3
3
|
import React, {
|
|
4
4
|
forwardRef,
|
|
5
5
|
useImperativeHandle,
|
|
@@ -10,11 +10,11 @@ import React, {
|
|
|
10
10
|
useRef,
|
|
11
11
|
useState,
|
|
12
12
|
} from 'react';
|
|
13
|
-
import {FlatList, Platform} from 'react-native';
|
|
14
|
-
import {ContainerContext} from './index';
|
|
13
|
+
import { FlatList, Platform } from 'react-native';
|
|
14
|
+
import { ContainerContext } from './index';
|
|
15
15
|
import LunarDateConverter from './LunarDateConverter';
|
|
16
16
|
import Month from './Month';
|
|
17
|
-
import {MonthListProps, MonthListRef} from './types';
|
|
17
|
+
import { MonthListProps, MonthListRef } from './types';
|
|
18
18
|
|
|
19
19
|
const MAX_RENDER_PER_BATCH = Platform.OS === 'android' ? 1 : 12;
|
|
20
20
|
|
|
@@ -43,7 +43,7 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
43
43
|
const [heightStyle, setHeightStyle] = useState({});
|
|
44
44
|
|
|
45
45
|
const data = useMemo(() => {
|
|
46
|
-
const months: {date: Moment; dateList: any[]}[] = [];
|
|
46
|
+
const months: { date: Moment; dateList: any[] }[] = [];
|
|
47
47
|
const mMin = moment(minDate).date(1);
|
|
48
48
|
const mMax = moment(maxDate);
|
|
49
49
|
while (
|
|
@@ -57,13 +57,13 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
57
57
|
let weekday = cursor.isoWeekday();
|
|
58
58
|
if (weekday !== 1) {
|
|
59
59
|
dayList.push(
|
|
60
|
-
...new Array(weekday - 1).fill(0).map(() => ({ isEmpty: true }))
|
|
60
|
+
...new Array(weekday - 1).fill(0).map(() => ({ isEmpty: true })),
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
while (cursor.month() === monthIdx) {
|
|
64
64
|
const cloned = cursor.clone();
|
|
65
65
|
const hol = holidays.find(
|
|
66
|
-
h => h.day === cloned.date() && h.month === cloned.month() + 1
|
|
66
|
+
h => h.day === cloned.date() && h.month === cloned.month() + 1,
|
|
67
67
|
);
|
|
68
68
|
dayList.push({
|
|
69
69
|
isEmpty: false,
|
|
@@ -82,10 +82,10 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
82
82
|
weekday = cursor.isoWeekday();
|
|
83
83
|
if (weekday !== 7) {
|
|
84
84
|
dayList.push(
|
|
85
|
-
...new Array(7 - weekday).fill(0).map(() => ({ isEmpty: true }))
|
|
85
|
+
...new Array(7 - weekday).fill(0).map(() => ({ isEmpty: true })),
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
|
-
months.push({date: d, dateList: dayList});
|
|
88
|
+
months.push({ date: d, dateList: dayList });
|
|
89
89
|
mMin.add(1, 'month');
|
|
90
90
|
}
|
|
91
91
|
return months;
|
|
@@ -93,25 +93,25 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
93
93
|
|
|
94
94
|
const getIndexOfMonth = useCallback(
|
|
95
95
|
(date: Moment) => data.findIndex(item => item.date.isSame(date, 'month')),
|
|
96
|
-
[data]
|
|
96
|
+
[data],
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
const currentScrollIndex = useMemo(
|
|
100
100
|
() => getIndexOfMonth(moment(selectedDate)),
|
|
101
|
-
[selectedDate, getIndexOfMonth]
|
|
101
|
+
[selectedDate, getIndexOfMonth],
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
const scrollToMonth = useCallback(
|
|
105
105
|
(month: Moment) => {
|
|
106
106
|
const idx = getIndexOfMonth(month);
|
|
107
107
|
if (listRef.current && idx !== -1) {
|
|
108
|
-
listRef.current.scrollToIndex({index: idx, animated: true});
|
|
108
|
+
listRef.current.scrollToIndex({ index: idx, animated: true });
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
|
-
[getIndexOfMonth]
|
|
111
|
+
[getIndexOfMonth],
|
|
112
112
|
);
|
|
113
113
|
|
|
114
|
-
useImperativeHandle(ref, () => ({scrollToMonth}));
|
|
114
|
+
useImperativeHandle(ref, () => ({ scrollToMonth }));
|
|
115
115
|
|
|
116
116
|
useEffect(() => {
|
|
117
117
|
const timer = setTimeout(() => {
|
|
@@ -120,9 +120,9 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
120
120
|
return () => clearTimeout(timer);
|
|
121
121
|
}, []);
|
|
122
122
|
|
|
123
|
-
const onViewableItemsChanged = useRef(({changed}: {changed: any[]}) => {
|
|
123
|
+
const onViewableItemsChanged = useRef(({ changed }: { changed: any[] }) => {
|
|
124
124
|
if (changed.length > 0) {
|
|
125
|
-
const {item, key, index} = changed[0];
|
|
125
|
+
const { item, key, index } = changed[0];
|
|
126
126
|
if (onScrollCalendar && item && currentKey.current !== key) {
|
|
127
127
|
currentKey.current = key;
|
|
128
128
|
try {
|
|
@@ -135,16 +135,16 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
135
135
|
} catch {
|
|
136
136
|
setHeightStyle({});
|
|
137
137
|
}
|
|
138
|
-
onScrollCalendar({date: item.date, key, currentIndex: index});
|
|
138
|
+
onScrollCalendar({ date: item.date, key, currentIndex: index });
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}).current;
|
|
142
142
|
|
|
143
|
-
const viewabilityConfig = {itemVisiblePercentThreshold: 50};
|
|
143
|
+
const viewabilityConfig = { itemVisiblePercentThreshold: 50 };
|
|
144
144
|
|
|
145
145
|
const keyExtractor = useCallback(
|
|
146
|
-
(item: {date: Moment}) => `${item.date.month() + 1}/${item.date.year()}`,
|
|
147
|
-
[]
|
|
146
|
+
(item: { date: Moment }) => `${item.date.month() + 1}/${item.date.year()}`,
|
|
147
|
+
[],
|
|
148
148
|
);
|
|
149
149
|
|
|
150
150
|
const getItemLayout = useCallback(
|
|
@@ -153,11 +153,17 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
153
153
|
offset: size.width * index,
|
|
154
154
|
index,
|
|
155
155
|
}),
|
|
156
|
-
[size.width]
|
|
156
|
+
[size.width],
|
|
157
157
|
);
|
|
158
158
|
|
|
159
159
|
const renderItem = useCallback(
|
|
160
|
-
({
|
|
160
|
+
({
|
|
161
|
+
item,
|
|
162
|
+
index,
|
|
163
|
+
}: {
|
|
164
|
+
item: { date: Moment; dateList: any[] };
|
|
165
|
+
index: number;
|
|
166
|
+
}) => {
|
|
161
167
|
const keyMonth = moment(item.date).format('YYYY-MM');
|
|
162
168
|
const priceListDate = priceList?.[keyMonth]?.day;
|
|
163
169
|
return (
|
|
@@ -189,7 +195,7 @@ const MonthList = forwardRef<MonthListRef, MonthListProps>((props, ref) => {
|
|
|
189
195
|
isShowLunar,
|
|
190
196
|
isDoubleDateMode,
|
|
191
197
|
disabledDays,
|
|
192
|
-
]
|
|
198
|
+
],
|
|
193
199
|
);
|
|
194
200
|
|
|
195
201
|
return (
|
package/holidayData.ts
CHANGED
package/index.tsx
CHANGED
|
@@ -55,6 +55,7 @@ const Calendar: React.FC<CalendarProps> = props => {
|
|
|
55
55
|
style,
|
|
56
56
|
disabledDays = [],
|
|
57
57
|
hideHeaderTab = false,
|
|
58
|
+
bestPriceColor,
|
|
58
59
|
} = props;
|
|
59
60
|
|
|
60
61
|
const [containerWidth, setContainerWidth] = useState<number>(
|
|
@@ -370,6 +371,7 @@ const Calendar: React.FC<CalendarProps> = props => {
|
|
|
370
371
|
isHideHoliday={isHideHoliday}
|
|
371
372
|
isOffLunar={isOffLunar}
|
|
372
373
|
disabledDays={disabledDays}
|
|
374
|
+
bestPriceColor={bestPriceColor}
|
|
373
375
|
/>
|
|
374
376
|
</View>
|
|
375
377
|
</ContainerContext.Provider>
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
2
|
+
"name": "@momo-kits/calendar",
|
|
3
|
+
"version": "0.150.3-beta.40",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.tsx",
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react": "*",
|
|
9
|
+
"react-native": "*"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@momo-platform/versions": "4.1.11"
|
|
13
|
+
},
|
|
14
|
+
"license": "MoMo",
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"registry": "https://registry.npmjs.org/"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"moment": "^2.24.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Moment from 'moment';
|
|
2
|
-
import {ViewStyle} from 'react-native';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
export type Holidays = {
|
|
5
5
|
solar: object;
|
|
@@ -18,12 +18,16 @@ export type PriceInfo = {
|
|
|
18
18
|
export type PriceListData = {
|
|
19
19
|
inbound: {
|
|
20
20
|
[keyMonth: string]: {
|
|
21
|
-
|
|
21
|
+
day: {
|
|
22
|
+
[keyDay: string]: PriceInfo;
|
|
23
|
+
};
|
|
22
24
|
};
|
|
23
25
|
};
|
|
24
26
|
outbound: {
|
|
25
27
|
[keyMonth: string]: {
|
|
26
|
-
|
|
28
|
+
day: {
|
|
29
|
+
[keyDay: string]: PriceInfo;
|
|
30
|
+
};
|
|
27
31
|
};
|
|
28
32
|
};
|
|
29
33
|
};
|
|
@@ -45,6 +49,7 @@ export type CalendarProProps = {
|
|
|
45
49
|
isOffLunar?: boolean;
|
|
46
50
|
onCallbackCalendar?: (lunar: string, nextStateShowLunar: boolean) => void;
|
|
47
51
|
disabledDays?: Date[];
|
|
52
|
+
bestPriceColor?: string;
|
|
48
53
|
};
|
|
49
54
|
|
|
50
55
|
export type CalendarProState = {
|
|
@@ -64,7 +69,7 @@ export type DoubleDate = {
|
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
export type CalendarProps = {
|
|
67
|
-
doubleDate
|
|
72
|
+
doubleDate?: DoubleDate;
|
|
68
73
|
selectedDate?: Moment.Moment;
|
|
69
74
|
mode?: 'doubleDate' | 'singleDate';
|
|
70
75
|
id?: number;
|
|
@@ -88,17 +93,18 @@ export type CalendarProps = {
|
|
|
88
93
|
hideHeaderTab?: boolean;
|
|
89
94
|
titleHeader?: string;
|
|
90
95
|
hideSwitchReturnSelection?: boolean;
|
|
96
|
+
bestPriceColor?: string;
|
|
91
97
|
};
|
|
92
98
|
|
|
93
99
|
export type CalendarProRef = {
|
|
94
100
|
setDoubleDateAndTabIndex: (
|
|
95
101
|
firstDate?: Moment.Moment | null,
|
|
96
102
|
secondDate?: Moment.Moment | null,
|
|
97
|
-
tabSelected?: number
|
|
103
|
+
tabSelected?: number,
|
|
98
104
|
) => void;
|
|
99
105
|
setDateRange: (
|
|
100
|
-
dateRange: {startDate: any; endDate: any},
|
|
101
|
-
isScrollToStartDate: any
|
|
106
|
+
dateRange: { startDate: any; endDate: any },
|
|
107
|
+
isScrollToStartDate: any,
|
|
102
108
|
) => void;
|
|
103
109
|
};
|
|
104
110
|
|
|
@@ -108,7 +114,7 @@ export type CalendarState = {
|
|
|
108
114
|
};
|
|
109
115
|
|
|
110
116
|
export type HeaderControlRef = {
|
|
111
|
-
onUpdateInfo: (date: {date: Moment.Moment}) => void;
|
|
117
|
+
onUpdateInfo: (date: { date: Moment.Moment }) => void;
|
|
112
118
|
};
|
|
113
119
|
|
|
114
120
|
export type HeaderControlProps = {
|
|
@@ -137,6 +143,7 @@ export type MonthListProps = {
|
|
|
137
143
|
}) => void;
|
|
138
144
|
lunarConverter: any;
|
|
139
145
|
disabledDays?: Date[];
|
|
146
|
+
bestPriceColor?: string;
|
|
140
147
|
};
|
|
141
148
|
|
|
142
149
|
export type MonthListState = {
|
|
@@ -160,6 +167,7 @@ export type MonthProps = {
|
|
|
160
167
|
isShowLunar: boolean;
|
|
161
168
|
isDoubleDateMode: boolean;
|
|
162
169
|
disabledDays?: Date[];
|
|
170
|
+
bestPriceColor?: string;
|
|
163
171
|
};
|
|
164
172
|
|
|
165
173
|
export type DayProps = {
|
|
@@ -181,6 +189,7 @@ export type DayProps = {
|
|
|
181
189
|
isBestPrice?: boolean;
|
|
182
190
|
havePriceList: boolean;
|
|
183
191
|
isDisabled?: boolean;
|
|
192
|
+
bestPriceColor?: string;
|
|
184
193
|
};
|
|
185
194
|
|
|
186
195
|
export type TabHeaderState = {
|