@momo-kits/calendar 0.80.3 → 0.80.4-beta.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 CHANGED
@@ -291,7 +291,7 @@ export default class CalendarPro extends Component<
291
291
  },
292
292
  ]}
293
293
  key={item}>
294
- {Util.mapWeeKDate(item)}
294
+ {translate(Util.mapWeeKDate(item))}
295
295
  </Text>
296
296
  ))}
297
297
  </View>
package/Day.tsx CHANGED
@@ -13,7 +13,7 @@ import {ContainerContext} from './index';
13
13
  import styles from './styles';
14
14
 
15
15
  class Day extends Component<DayProps> {
16
- isFocus?: boolean;
16
+ isFocus: boolean;
17
17
  isValid?: boolean;
18
18
  isMid?: boolean;
19
19
  isStart?: boolean;
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 = `${Util.mapMonth(
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, SwitchLanguage.jan],
167
- [2, SwitchLanguage.feb],
168
- [3, SwitchLanguage.mar],
169
- [4, SwitchLanguage.apr],
170
- [5, SwitchLanguage.may],
171
- [6, SwitchLanguage.jun],
172
- [7, SwitchLanguage.jul],
173
- [8, SwitchLanguage.aug],
174
- [9, SwitchLanguage.sep],
175
- [10, SwitchLanguage.oct],
176
- [11, SwitchLanguage.nov],
177
- [12, SwitchLanguage.dec],
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, ScrollView, View} from 'react-native';
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
- backgroundColor: theme.colors.background.surface,
451
- borderRadius: Radius.XS,
452
- marginBottom: Spacing.S,
453
- }}>
454
- {!isHiddenSwitch && this.renderSwitchReturnSelection()}
455
- {!isHideHeaderPanel && this.renderHeaderPanel(theme)}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/calendar",
3
- "version": "0.80.3",
3
+ "version": "0.80.4-beta.1",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "peerDependencies": {
@@ -14,4 +14,4 @@
14
14
  "dependencies": {
15
15
  "moment": "^2.24.0"
16
16
  }
17
- }
17
+ }
package/styles.ts CHANGED
@@ -112,4 +112,12 @@ export default StyleSheet.create({
112
112
  borderTopRightRadius: Radius.XS,
113
113
  borderBottomRightRadius: Radius.XS,
114
114
  },
115
+
116
+ invisible: {
117
+ height: 0,
118
+ width: 0,
119
+ padding: 0,
120
+ marginBottom: 0,
121
+ overflow: 'hidden',
122
+ },
115
123
  });
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 = {