@momo-kits/calendar 0.80.3 → 0.80.4
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 +1 -1
- package/Day.tsx +1 -1
- package/HeaderControl.tsx +5 -3
- package/Util.ts +14 -33
- package/index.tsx +14 -12
- package/package.json +1 -1
- package/styles.ts +8 -0
- package/types.ts +1 -2
package/CalendarPro.tsx
CHANGED
package/Day.tsx
CHANGED
package/HeaderControl.tsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
forwardRef,
|
|
3
3
|
ForwardRefRenderFunction,
|
|
4
|
+
useContext,
|
|
4
5
|
useImperativeHandle,
|
|
5
6
|
useState,
|
|
6
7
|
} from 'react';
|
|
7
8
|
import {TouchableOpacity, View} from 'react-native';
|
|
8
9
|
import moment from 'moment';
|
|
9
10
|
import Moment from 'moment';
|
|
10
|
-
import {Icon, Text} from '@momo-kits/foundation';
|
|
11
|
+
import {ApplicationContext, Icon, Text} from '@momo-kits/foundation';
|
|
11
12
|
|
|
12
13
|
import Util from './Util';
|
|
13
14
|
import {HeaderControlProps, HeaderControlRef} from './types';
|
|
@@ -17,6 +18,7 @@ const HeaderControl: ForwardRefRenderFunction<
|
|
|
17
18
|
HeaderControlRef,
|
|
18
19
|
HeaderControlProps
|
|
19
20
|
> = ({onPressBackArrow, onPressNextArrow, selectedDate}, ref) => {
|
|
21
|
+
const {translate} = useContext(ApplicationContext);
|
|
20
22
|
const [info, setInfo] = useState<{date: Moment.Moment}>({
|
|
21
23
|
date: moment(selectedDate || new Date()),
|
|
22
24
|
});
|
|
@@ -30,8 +32,8 @@ const HeaderControl: ForwardRefRenderFunction<
|
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
if (info && info.date) {
|
|
33
|
-
const headerFormat = `${
|
|
34
|
-
info.date.month() + 1,
|
|
35
|
+
const headerFormat = `${translate(
|
|
36
|
+
Util.mapMonth(info.date.month() + 1),
|
|
35
37
|
)}/${info.date.year()}`;
|
|
36
38
|
return (
|
|
37
39
|
<View style={styles.headerControlContainer}>
|
package/Util.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
|
-
|
|
3
|
-
import {SwitchLanguage} from '@momo-kits/core';
|
|
4
2
|
import LunarDateConverter from './LunarDateConverter';
|
|
5
3
|
import holiday from './holidayData';
|
|
6
4
|
|
|
@@ -108,15 +106,7 @@ const sortByDate = arr => {
|
|
|
108
106
|
module.exports = {
|
|
109
107
|
WEEKDAYS: ['T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'CN'],
|
|
110
108
|
|
|
111
|
-
WEEKDAYSFROMMOMENT: [
|
|
112
|
-
SwitchLanguage.sun,
|
|
113
|
-
SwitchLanguage.mon,
|
|
114
|
-
SwitchLanguage.tue,
|
|
115
|
-
SwitchLanguage.wed,
|
|
116
|
-
SwitchLanguage.thu,
|
|
117
|
-
SwitchLanguage.fri,
|
|
118
|
-
SwitchLanguage.sat,
|
|
119
|
-
],
|
|
109
|
+
WEEKDAYSFROMMOMENT: ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
|
|
120
110
|
|
|
121
111
|
WEEKDAYSNAME: [
|
|
122
112
|
'Thứ 2',
|
|
@@ -148,33 +138,24 @@ module.exports = {
|
|
|
148
138
|
MAX_COLUMNS: 7,
|
|
149
139
|
|
|
150
140
|
mapWeeKDate(i) {
|
|
151
|
-
const date = [
|
|
152
|
-
'',
|
|
153
|
-
SwitchLanguage.mon,
|
|
154
|
-
SwitchLanguage.tue,
|
|
155
|
-
SwitchLanguage.wed,
|
|
156
|
-
SwitchLanguage.thu,
|
|
157
|
-
SwitchLanguage.fri,
|
|
158
|
-
SwitchLanguage.sat,
|
|
159
|
-
SwitchLanguage.sun,
|
|
160
|
-
];
|
|
141
|
+
const date = ['', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'];
|
|
161
142
|
return date[i];
|
|
162
143
|
},
|
|
163
144
|
|
|
164
145
|
mapMonth(i) {
|
|
165
146
|
const month = new Map([
|
|
166
|
-
[1,
|
|
167
|
-
[2,
|
|
168
|
-
[3,
|
|
169
|
-
[4,
|
|
170
|
-
[5,
|
|
171
|
-
[6,
|
|
172
|
-
[7,
|
|
173
|
-
[8,
|
|
174
|
-
[9,
|
|
175
|
-
[10,
|
|
176
|
-
[11,
|
|
177
|
-
[12,
|
|
147
|
+
[1, 'jan'],
|
|
148
|
+
[2, 'feb'],
|
|
149
|
+
[3, 'mar'],
|
|
150
|
+
[4, 'apr'],
|
|
151
|
+
[5, 'may'],
|
|
152
|
+
[6, 'jun'],
|
|
153
|
+
[7, 'jul'],
|
|
154
|
+
[8, 'aug'],
|
|
155
|
+
[9, 'sep'],
|
|
156
|
+
[10, 'oct'],
|
|
157
|
+
[11, 'nov'],
|
|
158
|
+
[12, 'dec'],
|
|
178
159
|
]);
|
|
179
160
|
return month.get(i);
|
|
180
161
|
},
|
package/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {Component, createContext, RefObject} from 'react';
|
|
2
|
-
import {Dimensions, LayoutChangeEvent,
|
|
2
|
+
import {Dimensions, LayoutChangeEvent, View} from 'react-native';
|
|
3
3
|
import moment from 'moment';
|
|
4
4
|
import {
|
|
5
5
|
ApplicationContext,
|
|
@@ -422,19 +422,18 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
422
422
|
const {
|
|
423
423
|
isOffLunar,
|
|
424
424
|
isHideHoliday,
|
|
425
|
-
isHiddenSwitch,
|
|
426
425
|
isShowLunar,
|
|
427
426
|
onCallbackCalendar,
|
|
428
427
|
priceList,
|
|
429
428
|
labelFrom,
|
|
430
429
|
labelTo,
|
|
431
430
|
isHideLabel,
|
|
432
|
-
minDate,
|
|
433
|
-
maxDate,
|
|
431
|
+
minDate = minDateDefault,
|
|
432
|
+
maxDate = maxDateDefault,
|
|
434
433
|
doubleDate,
|
|
435
|
-
isHideHeaderPanel,
|
|
436
434
|
style,
|
|
437
435
|
disabledDays = [],
|
|
436
|
+
hideHeaderTab = false,
|
|
438
437
|
} = this.props;
|
|
439
438
|
const {isDoubleDateMode, containerWidth} = this.state;
|
|
440
439
|
const {theme} = this.context;
|
|
@@ -446,13 +445,16 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
446
445
|
}}>
|
|
447
446
|
<View onLayout={this.onLayout} style={[style, styles.scrollView]}>
|
|
448
447
|
<View
|
|
449
|
-
style={
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
448
|
+
style={[
|
|
449
|
+
{
|
|
450
|
+
backgroundColor: theme.colors.background.surface,
|
|
451
|
+
borderRadius: Radius.XS,
|
|
452
|
+
marginBottom: Spacing.S,
|
|
453
|
+
},
|
|
454
|
+
hideHeaderTab && styles.invisible,
|
|
455
|
+
]}>
|
|
456
|
+
{this.renderSwitchReturnSelection()}
|
|
457
|
+
{this.renderHeaderPanel(theme)}
|
|
456
458
|
</View>
|
|
457
459
|
<CalendarPro
|
|
458
460
|
priceList={priceList}
|
package/package.json
CHANGED
package/styles.ts
CHANGED
package/types.ts
CHANGED
|
@@ -72,7 +72,6 @@ export type CalendarProps = {
|
|
|
72
72
|
headerTo?: string;
|
|
73
73
|
isOffLunar?: boolean;
|
|
74
74
|
isHideHoliday?: boolean;
|
|
75
|
-
isHiddenSwitch?: boolean;
|
|
76
75
|
isShowLunar?: boolean;
|
|
77
76
|
priceList?: PriceListData;
|
|
78
77
|
labelFrom?: string;
|
|
@@ -80,9 +79,9 @@ export type CalendarProps = {
|
|
|
80
79
|
isHideLabel?: boolean;
|
|
81
80
|
minDate?: Date;
|
|
82
81
|
maxDate?: Date;
|
|
83
|
-
isHideHeaderPanel?: boolean;
|
|
84
82
|
style?: ViewStyle | ViewStyle[];
|
|
85
83
|
disabledDays?: Date[];
|
|
84
|
+
hideHeaderTab?: boolean;
|
|
86
85
|
};
|
|
87
86
|
|
|
88
87
|
export type CalendarProRef = {
|